Hello
I am trying to make the most basic example of open cv to compile, but looks like something is terrible wrong.
Info about what I am using:
OS: windows ultimate 7 64
Codeblocks 10:05 installed from "codeblocks-10.05mingw-setup.exe"
into d:\develop\codeblocks
opencv2.3 installed from "OpenCV-2.3.0-win-superpack.exe"
into d:\develop\OpenCV2.3
This is the code I am trying to compile
#include "cv.h"
#include "highgui.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include <math.h>
#include <float.h>
#include <limits.h>
#include <time.h>
#include <ctype.h>
const char* cascade_name = "D:\\develop\\OpenCV2.3\\opencv\\data\\haarcascades\\haarcascade_frontalface_alt.xml";
void detect_and_draw( IplImage* image );
int main( int argc, char** argv )
{
IplImage *img = cvLoadImage("face.jpg");
detect_and_draw(img);
cvWaitKey();
cvReleaseImage(&img);
cvDestroyWindow("result");
return 0;
}
void detect_and_draw( IplImage* img )
{
static CvMemStorage* storage = 0;
static CvHaarClassifierCascade* cascade = 0;
int scale = 1;
IplImage* temp = cvCreateImage( cvSize(img->width/scale,img->height/scale), 8, 3 );
CvPoint pt1, pt2;
int i;
cascade = (CvHaarClassifierCascade*)cvLoad( cascade_name, 0, 0, 0 );
if( !cascade )
{
fprintf( stderr, "ERROR: Could not load classifier cascade\n" );
return;
}
storage = cvCreateMemStorage(0);
cvNamedWindow( "result", 1 );
cvClearMemStorage( storage );
if( cascade )
{
CvSeq* faces = cvHaarDetectObjects( img, cascade, storage,1.1, 2, CV_HAAR_DO_CANNY_PRUNING,cvSize(40, 40) );
for( i = 0; i < (faces ? faces->total : 0); i++ )
{
CvRect* r = (CvRect*)cvGetSeqElem( faces, i );
pt1.x = r->x*scale;
pt2.x = (r->x+r->width)*scale;
pt1.y = r->y*scale;
pt2.y = (r->y+r->height)*scale;
cvRectangle( img, pt1, pt2, CV_RGB(255,0,0), 3, 8, 0 );
}
}
cvShowImage( "result", img );
cvReleaseImage( &temp );
}
What I added into my C::B config :
into the Project Build options -> Linker settings tab , I added all Libs from D:\develop\OpenCV2.3\build\x86\mingw\lib\*.dll.a
( I tried with ...\x64\... also )
nto the Project Build options -> Search Directories , I added:
D:\develop\OpenCV2.3\build\include
D:\develop\OpenCV2.3\build\include\opencv
D:\develop\OpenCV2.3\build\include\opencv2
This cause :
-------------- Build: Release in opencv ---------------
Compiling: main.cpp
Linking console executable: bin\Release\opencv.exe
obj\Release\main.o:main.cpp:(.text+0x2d): undefined reference to `cvCreateImage'
obj\Release\main.o:main.cpp:(.text+0x55): undefined reference to `cvLoad'
obj\Release\main.o:main.cpp:(.text+0x6e): undefined reference to `cvCreateMemStorage'
obj\Release\main.o:main.cpp:(.text+0x87): undefined reference to `cvNamedWindow'
obj\Release\main.o:main.cpp:(.text+0x94): undefined reference to `cvClearMemStorage'
obj\Release\main.o:main.cpp:(.text+0xfa): undefined reference to `cvHaarDetectObjects'
obj\Release\main.o:main.cpp:(.text+0x12f): undefined reference to `cvGetSeqElem'
obj\Release\main.o:main.cpp:(.text+0x1c4): undefined reference to `cvRectangle'
obj\Release\main.o:main.cpp:(.text+0x1e7): undefined reference to `cvShowImage'
obj\Release\main.o:main.cpp:(.text+0x1f2): undefined reference to `cvReleaseImage'
obj\Release\main.o:main.cpp:(.text+0x256): undefined reference to `cvLoadImage'
obj\Release\main.o:main.cpp:(.text+0x26e): undefined reference to `cvWaitKey'
obj\Release\main.o:main.cpp:(.text+0x27a): undefined reference to `cvReleaseImage'
obj\Release\main.o:main.cpp:(.text+0x286): undefined reference to `cvDestroyWindow'
collect2: ld returned 1 exit status
Process terminated with status 1 (0 minutes, 1 seconds)
Then
I added into the linker options -lhighgui to see what happens and I got a "cannot find -lhighthui"
I added into the linker options -lopencv_highgui "cannot find -lopencv_hightgui"
I really need some help here.
I know how to use google.
I know how to use search here , there are just a few topics on opencv here I and read all of them.
this:
http://opensourcecollection.blogspot.com/2011/04/how-to-setup-opencv-22-in-codeblocks.html <- dont help
http://opencv.willowgarage.com/wiki/CodeBlocks <- don't help.
But
It worked with this configuration with a windowsXP Sp3, C::B 10.05 without mingw ( installed from mingw installer into c:\minGW ) and opencv 2.2
But I need that working on the w7 box
I am accepting suggestions. Lots of them. I am trying this for more than 2 weeks.
Thanks
Luis