CodeBlocks OpenCV
CodeBlocks OpenCV
1) InstallCode::BlocksIDEonyoursystem...moredetailshere:
http://wiki.codeblocks.org/index.php?title=Installing_Code::Blocks#Ubuntu
2) CreateanewprojektonthemainscreenorchooseFile>New>Project(eg.aconsole
application).FirstofallchecktheOpenCVinstallationpathwiththesetwocommands:
pkgconfigcflagsopencv<showsthepathofheaderfiles(step4)
pkgconfiglibsopencv<showsthepathoflibraryfiles(step3and5)
3) OpentheProject>BuildOptionsdialoganfillitthefollowingwaytheLinkersettings:
Thepathsareknownfromthestep2(youhavetoaddFILEShere,notonlythedirectory).
4) InthisdialogchoosetheSearchdirectoriesandthentheCompilertabandaddthepath:
5) Thelaststep:klickontheLinkertab,andhereaddthefollowingrow:
6) Trytobuildthissimpleprogram:
#include"cv.h"
#include"highgui.h"
#include<stdio.h>
intmain(intargc,char**argv){
CvCapture*capture=0;
IplImage*image=0;
if(argc==1||(argc==2&&strlen(argv[1])==1&&isdigit(argv[1][0])))
capture=cvCaptureFromCAM(argc==2?argv[1][0]'0':0);
elseif(argc==2)
capture=cvCaptureFromAVI(argv[1]);
if(!capture){
fprintf(stderr,"Couldnotinitializecapturing...\n");
return1;}
cvNamedWindow("Input",CV_WINDOW_AUTOSIZE);
for(;;){
intc;
image=cvQueryFrame(capture);
if(!image)
break;
cvShowImage("Input",image);
c=cvWaitKey(10);
if((char)c==27)
break;
}
cvReleaseCapture(&capture);
cvDestroyAllWindows();
return0;
}
DvidLosteiner@2007