I am trying to write this simple image modifier program in c++ with opencv on netbeans. I am using ubuntu 10.04. Everytime I try to run or compile it, it returns the below errors. I have opencv configured in the linker and the additional tools. What is going wrong?
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;
}
"/usr/bin/make" -f nbproject/Makefile-Debug.mk QMAKE= SUBPROJECTS= .build-conf
make[1]: Entering directory `/home/kevin/NetBeansProjects/CppApplication_4'
"/usr/bin/make" -f nbproject/Makefile-Debug.mk dist/Debug/GNU-Linux-x86/cppapplication_4
make[2]: Entering directory `/home/kevin/NetBeansProjects/CppApplication_4'
mkdir -p build/Debug/GNU-Linux-x86
rm -f build/Debug/GNU-Linux-x86/main.o.d
g++ -c -g -MMD -MP -MF build/Debug/GNU-Linux-x86/main.o.d -o build/Debug/GNU-Linux-x86/ main.o main.cpp
main.cpp:4:16: warning: cv.h: No such file or directory
main.cpp:5:21: warning: 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
make[2]: *** [build/Debug/GNU-Linux-x86/main.o] Error 1
make[1]: *** [.build-conf] Error 2
make: *** [.build-impl] Error 2
make[2]: Leaving directory `/home/kevin/NetBeansProjects/CppApplication_4'
make[1]: Leaving directory `/home/kevin/NetBeansProjects/CppApplication_4'
BUILD FAILED (exit value 2, total time: 115ms)
EDIT: Sorry for the massive jumble