Trouble compiling first OpenCV project

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Trouble compiling first OpenCV project

joycilla
Hi,

I have followed each step of the installation instructions on the OpenCV wiki, but I can't seem to compile the example program for Visual Studio 2010 in 64 bit. I think it is somehow failing to see my include files. I used setx to set the OPENCV_DIR just as directed and the version of OpenCV is OpenCV-2.3.1-win-superpack.exe with changes/steps included below.

Any help would be very greatly appreciated, thank you!



Modifications

Property Pates -> Congifuation Properties -> C/C++ -> General
$(OPENCV_DIR)\include\opencv;$(OPENCV_DIR)\include;%(AdditionalIncludeDirectories)

Property Pates -> Congifuation Properties -> Linker -> Additioinal Library Directories
$(OPENCV_DIR)\lib;%(AdditionalLibraryDirectories)

Property Pates -> Congifuation Properties -> Linker -> Input
C:\Program Files\opencv\opencv\x64\vc10\lib\opencv_core231d.lib;
C:\Program Files\opencv\opencv\x64\vc10\lib\opencv_imgproc231d.lib;
C:\Program Files\opencv\opencv\x64\vc10\lib\opencv_highgui231d.lib;
C:\Program Files\opencv\opencv\x64\vc10\lib\opencv_ml231d.lib;
C:\Program Files\opencv\opencv\x64\vc10\lib\opencv_video231d.lib;%(AdditionalDependencies)

Example program

#include "cv.h"
#include "highgui.h"

int main(int argc, char* argv[]) {
        CvCapture *c=cvCreateCameraCapture(-1);
        IplImage *frame;

        while(true) {
                frame=cvQueryFrame(c);
                cvShowImage("Window",frame);

                char ch=cvWaitKey(15);

                if(ch==27)
                        break;
        }
        return 0;
}

Error listing

Error 1 error C1083: Cannot open include file: 'cv.h': No such file or directory c:\users\project.c 1
        2 IntelliSense: cannot open source file "cv.h" c:\users\user\project\project.c 1
        3 IntelliSense: cannot open source file "highgui.h" c:\users\user\project\project.c 2
        4 IntelliSense: identifier "CvCapture" is undefined c:\users\user\project\project.c 5
        5 IntelliSense: identifier "c" is undefined c:\users\user\project\project.c 5
        6 IntelliSense: identifier "cvCreateCameraCapture" is undefined c:\users\project.c 5
        7 IntelliSense: identifier "IplImage" is undefined c:\users\user\project\project.c 6
        8 IntelliSense: identifier "frame" is undefined c:\users\user\project\project.c 6
        9 IntelliSense: identifier "cvQueryFrame" is undefined c:\users\user\project\project.c 9
        10 IntelliSense: identifier "cvShowImage" is undefined c:\users\user\project\project.c 10
        11 IntelliSense: identifier "cvWaitKey" is undefined c:\users\user\project\project.c 12


Reply | Threaded
Open this post in threaded view
|

Re: Trouble compiling first OpenCV project

Francisco Ares
Hi,

You are receiving compilation errors, the compiler is not able to find  
include files.

On these lines of your original message:


> Property Pates -> Congifuation Properties -> C/C++ -> General
> $(OPENCV_DIR)\include\opencv;$(OPENCV_DIR)\include;%(AdditionalIncludeDirectories)

> Property Pates -> Congifuation Properties -> Linker -> Additioinal  
> Library Directories
> $(OPENCV_DIR)\lib;%(AdditionalLibraryDirectories)

Does the environment of your IDE knows what "OPENCV_DIR" is? If not (by the  
way, quite probable), you might take two actions: one isto  
replace "$(OPENCV_DIR)" with the real path to the OpenCV folder structure,  
and the other is to add that as the name of an environment variable with  
the real folder path as its contents, like OPENCV_DIR="C:\Program  
Files\OpenCV" or something like this.

Hope it helps
Francisco