Can't use old c functions in opencv 3.1 -
opencv3.1 build cmake latest stable. trying cpp example project works fine.
i tried hello-world example from:
http://www.cs.iit.edu/~agam/cs512/lect-notes/opencv-intro/opencv-intro.html
test.c
//////////////////////////////////////////////////////////////////////// // // hello-world // // simple, introductory opencv program. program reads // image file, inverts it, , displays result. // //////////////////////////////////////////////////////////////////////// #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 image img=cvloadimage(argv[1]); if(!img){ printf("could not load image file: %s\n",argv[1]); exit(0); } // image data height = img->height; width = img->width; step = img->widthstep; channels = img->nchannels; data = (uchar *)img->imagedata; printf("processing %dx%d image %d channels\n",height,width,channels); // create window cvnamedwindow("mainwin", cv_window_autosize); cvmovewindow("mainwin", 100, 100); // invert 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 image cvshowimage("mainwin", img ); // wait key cvwaitkey(0); // release image cvreleaseimage(&img ); return 0; }
when copying source code local *.c file, following errors, while compiling:
gcc `pkg-config --cflags opencv` -wall -o2 `pkg-config --libs opencv` -lm -o test test.c /tmp/ccyrzo8f.o: in funktion `main': test.c:(.text.startup+0x32): nicht definierter verweis auf `cvloadimage' test.c:(.text.startup+0x78): nicht definierter verweis auf `cvnamedwindow' test.c:(.text.startup+0x89): nicht definierter verweis auf `cvmovewindow' test.c:(.text.startup+0xed): nicht definierter verweis auf `cvshowimage' test.c:(.text.startup+0xf9): nicht definierter verweis auf `cvwaitkey' test.c:(.text.startup+0x104): nicht definierter verweis auf `cvreleaseimage' collect2: error: ld returned 1 exit status make: *** [prog] fehler 1
how can work?
Comments
Post a Comment