Hello
First of all, I'm new in C++ and also in Code::blocks. I just got it installed yesterday on Ubuntu.
I got installed opencv as well. But I can not link opencv with code::blocks:(
By using console I can compile my program and everything is working fine, but if I try to build it in code::blocks,
I always get the error message
main.cpp|4|error: cv.h: No such file or directory|
main.cpp|5|error: highgui.h: No such file or directory|
main.cpp||In function ‘int main(int, char**)’:|
main.cpp|10|error: ‘IplImage’ was not declared in this scope|
main.cpp|10|error: ‘img’ was not declared in this scope|
main.cpp|12|error: ‘uchar’ was not declared in this scope|
main.cpp|12|error: ‘data’ was not declared in this scope|
main.cpp|21|error: ‘cvLoadImage’ was not declared in this scope|
main.cpp|32|error: expected primary-expression before ‘)’ token|
main.cpp|32|error: expected `;' before ‘img’|
main.cpp|36|error: ‘CV_WINDOW_AUTOSIZE’ was not declared in this scope|
main.cpp|36|error: ‘cvNamedWindow’ was not declared in this scope|
main.cpp|37|error: ‘cvMoveWindow’ was not declared in this scope|
main.cpp|44|error: ‘cvShowImage’ was not declared in this scope|
main.cpp|47|error: ‘cvWaitKey’ was not declared in this scope|
main.cpp|50|error: ‘cvReleaseImage’ was not declared in this scope|
||=== Build finished: 15 errors, 0 warnings ===|
Can maybe someone tell me how do I have to link opencv with code::blocks.
I installes opencv to opt/opencv/
here is also the standard program which I try to build
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include <cv.h>
#include <highgui.h>
int main(int argc, char *argv[])
{
IplImage* img = 0;
int height,width,step,channels;
uchar *data;
int i,j,k;
if(argc<2){
printf("Usage: main <image-file-name>\n\7");
exit(0);
}
// load an image
img=cvLoadImage(argv[1]);
if(!img){
printf("Could not load image file: %s\n",argv[1]);
exit(0);
}
// get the image data
height = img->height;
width = img->width;
step = img->widthStep;
channels = img->nChannels;
data = (uchar *)img->imageData;
printf("Processing a %dx%d image with %d channels\n",height,width,channels);
// create a window
cvNamedWindow("mainWin", CV_WINDOW_AUTOSIZE);
cvMoveWindow("mainWin", 100, 100);
// invert the image
for(i=0;i<height;i++) for(j=0;j<width;j++) for(k=0;k<channels;k++)
data[i*step+j*channels+k]=255-data[i*step+j*channels+k];
// show the image
cvShowImage("mainWin", img );
// wait for a key
cvWaitKey(0);
// release the image
cvReleaseImage(&img );
return 0;
}
Thank for your help