Another OpenCV 2.3.1 Integration Thread....
-
Followed these directions to integrate the new OpenCV:
http://www.barbato.us/2011/12/20/opencv-2-3-qtcreator-windows/Went ahead to test some sample code from OpenCV's documentation here:
http://opencv.itseez.com/index.htmlHere are my includepaths from the QT Project file:
@
INCLUDEPATH += C:\opencv\build\include \CONFIG(release,debug|release)
{
LIBS += C:\opencv\build\gpu\x64\lib\opencv_calib3d231.lib
C:\opencv\build\gpu\x64\lib\opencv_contrib231.lib
C:\opencv\build\gpu\x64\lib\opencv_core231.lib
C:\opencv\build\gpu\x64\lib\opencv_features2d231.lib
C:\opencv\build\gpu\x64\lib\opencv_flann231.lib
C:\opencv\build\gpu\x64\lib\opencv_gpu231.lib
C:\opencv\build\gpu\x64\lib\opencv_haartraining_engine.lib
C:\opencv\build\gpu\x64\lib\opencv_highgui231.lib
C:\opencv\build\gpu\x64\lib\opencv_imgproc231.lib
C:\opencv\build\gpu\x64\lib\opencv_legacy231.lib
C:\opencv\build\gpu\x64\lib\opencv_ml231.lib
C:\opencv\build\gpu\x64\lib\opencv_objdetect231.lib
C:\opencv\build\gpu\x64\lib\opencv_ts231.lib
C:\opencv\build\gpu\x64\lib\opencv_video231.lib
}CONFIG(debug,debug|release)
{
LIBS += C:\opencv\build\gpu\x64\lib\opencv_calib3d231d.lib
C:\opencv\build\gpu\x64\lib\opencv_contrib231d.lib
C:\opencv\build\gpu\x64\lib\opencv_core231d.lib
C:\opencv\build\gpu\x64\lib\opencv_features2d231d.lib
C:\opencv\build\gpu\x64\lib\opencv_flann231d.lib
C:\opencv\build\gpu\x64\lib\opencv_gpu231d.lib
C:\opencv\build\gpu\x64\lib\opencv_haartraining_engined.lib
C:\opencv\build\gpu\x64\lib\opencv_highgui231d.lib
C:\opencv\build\gpu\x64\lib\opencv_imgproc231d.lib
C:\opencv\build\gpu\x64\lib\opencv_legacy231d.lib
C:\opencv\build\gpu\x64\lib\opencv_ml231d.lib
C:\opencv\build\gpu\x64\lib\opencv_objdetect231d.lib
C:\opencv\build\gpu\x64\lib\opencv_ts231d.lib
C:\opencv\build\gpu\x64\lib\opencv_video231d.lib
}
@Am I am running something basic from the OpenCV documentation like:
@
#include <iostream>
#include <opencv2/opencv.hpp>
#include <opencv/cv.h>
#include <opencv/highgui.h>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/highgui/highgui_c.h>
#include <opencv2/imgproc/imgproc.hpp>
#include <iostream>
#include <stdio.h>
#include <stdlib.h>using namespace cv;
int main()
{IplImage* img = cvLoadImage("likely.jpg");
// IplImage is a structure pre-defined in the OpenCV libraries.
//It used by OpenCV to store an image and contains information about it, like its height, width, etc, and a pointer to the actual image data.cvNamedWindow("myfirstwindow"); cvShowImage("myfirstwindow", img); cvWaitKey(0); cvReleaseImage(&img); return 0;
}
@
I'll get bunch of CV related errors:
!http://img41.imageshack.us/img41/4695/snapsz.jpg(Output errors)!It won't work with even something more simpler like this
@
#include <iostream>
#include <opencv2/opencv.hpp>
#include <opencv/cv.h>
#include <opencv/highgui.h>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/highgui/highgui_c.h>
#include <opencv2/imgproc/imgproc.hpp>
#include <iostream>
#include <stdio.h>
#include <stdlib.h>using namespace cv;
int main()
{Mat img = imread("likely.jpg"); waitKey(0); return 0;
}
@
This should open the picture, but nothing happens either and it gives me this EXE error which makes no sense to me at all. I don't have an exe created i'm just running the QT project
!http://img862.imageshack.us/img862/2379/errros.jpg(EXE error)!
-
-
From one of my projects and it works here ;-):
@win32{
message("Using webcam module ...")
AMK_BASE_PATH = c:/Qt/AMK
INCLUDEPATH *= $$AMK_BASE_PATH/includeDebug{ LIBS += -L$$AMK_BASE_PATH/lib \ -lopencv_highgui231d } Release{ LIBS += -L$$AMK_BASE_PATH/lib \ -lopencv_highgui231 }
} @
You have to adjust "AMK_BASE_PATH" as path to opencv.By the way, did you build the libs for your Qt Version with the right compiler?
-
Thanks for the help so far. I will try it out. However, you have in your code:
@AMK_BASE_PATH = c:/Qt/AMK
....
Debug{
LIBS += -L$$AMK_BASE_PATH/lib
-lopencv_highgui231d
@
The "-L$$AMK_BASE_PATH/lib .." path doesn't exist for OpenCV 2.3. There is no lib folder after the AMK base path.!http://img46.imageshack.us/img46/1982/opencvpic.jpg(OpenCV Root Directory)!
I keep reading stuff about compiling the libraries for QT, but I downloaded the latest QT SDK Superpack which includes GPU, MingW, VC9, VC10 precompiled libraries right? I'm using Windows 64 by the way, so should I still use:
the win32 brackets?win32{
}
I even tried loading the mingW libraries since Nokia QT says it was installed with a built in mingW compiler and it didn't work.
Right now I am using:
!http://img705.imageshack.us/img705/5185/opencver.jpg(Gives me an obvious error)!
-
So do you use the mingw version of the Qt lib's, isn't it?
I guess the OpenCV Superpack lib's don't have Qt support enabled, because if different versions. You can test it with dependeny walker, open the opencv_highgui231.dll inside dependency walker.That's why, I think, you have build the lib's by your self, so I did.
-
bq. The “-L$$AMK_BASE_PATH/lib ..” path doesn’t exist for OpenCV 2.3. There is no lib folder after the AMK base path.
Because I did build the libs by myself and set the install path to this location. That means you have to adjust the libs search path, i.e. for mingw:
@
BASE_PATH = c:/opencv/build/x86/mingw
Debug{
LIBS += -L$$BASE_PATH/lib
-lopencv_highgui231d
}
Release{
LIBS += -L$$BASE_PATH/lib
-lopencv_highgui231}
@
-
I managed to successfully compile my main.cpp using this using Qt 4.8 for Desktop MinGW
.pro file:
@
INCLUDEPATH += C:\opencv\build\include
INCLUDEPATH += "C:\opencv\modules\core\include"
"C:\opencv\modules\highgui\include"CONFIG(release,debug|release)
{
LIBS += C:\opencv\build\gpu\x86\lib\opencv_calib3d231.lib
C:\opencv\build\gpu\x86\lib\opencv_contrib231.lib
C:\opencv\build\gpu\x86\lib\opencv_core231.lib
C:\opencv\build\gpu\x86\lib\opencv_features2d231.lib
C:\opencv\build\gpu\x86\lib\opencv_flann231.lib
C:\opencv\build\gpu\x86\lib\opencv_gpu231.lib
C:\opencv\build\gpu\x86\lib\opencv_haartraining_engine.lib
C:\opencv\build\gpu\x86\lib\opencv_highgui231.lib
C:\opencv\build\gpu\x86\lib\opencv_imgproc231.lib
C:\opencv\build\gpu\x86\lib\opencv_legacy231.lib
C:\opencv\build\gpu\x86\lib\opencv_ml231.lib
C:\opencv\build\gpu\x86\lib\opencv_objdetect231.lib
C:\opencv\build\gpu\x86\lib\opencv_ts231.lib
C:\opencv\build\gpu\x86\lib\opencv_video231.lib
}CONFIG(debug,debug|release)
{
LIBS += C:\opencv\build\gpu\x86\lib\opencv_calib3d231d.lib
C:\opencv\build\gpu\x86\lib\opencv_contrib231d.lib
C:\opencv\build\gpu\x86\lib\opencv_core231d.lib
C:\opencv\build\gpu\x86\lib\opencv_features2d231d.lib
C:\opencv\build\gpu\x86\lib\opencv_flann231d.lib
C:\opencv\build\gpu\x86\lib\opencv_gpu231d.lib
C:\opencv\build\gpu\x86\lib\opencv_haartraining_engined.lib
C:\opencv\build\gpu\x86\lib\opencv_highgui231d.lib
C:\opencv\build\gpu\x86\lib\opencv_imgproc231d.lib
C:\opencv\build\gpu\x86\lib\opencv_legacy231d.lib
C:\opencv\build\gpu\x86\lib\opencv_ml231d.lib
C:\opencv\build\gpu\x86\lib\opencv_objdetect231d.lib
C:\opencv\build\gpu\x86\lib\opencv_ts231d.lib
C:\opencv\build\gpu\x86\lib\opencv_video231d.lib
}@main.cpp
@#include <iostream>
#include <opencv/cv.h>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <stdio.h>
#include <stdlib.h>
#include <opencv2/core/core.hpp>
#include <opencv2/ml/ml.hpp>
#include <opencv.hpp>
#include <opencv/cxcore.h>
#include <opencv/cxcore.hpp>using namespace cv;
IplImage* img;int main()
{img = cvLoadImage("likely.jpg"); cvNamedWindow("Image",CV_WINDOW_AUTOSIZE); cvShowImage("Image", img); cvWaitKey(40); return 0;
}
@As you can see from the include paths that I am using the "x86" libraries instead of the "x64" ones despite my computer being on Windows 7 64bit Home Edition. If I change those folders to "x64" and use the 64bit libraries, I'll get a compiling error below:
!http://img826.imageshack.us/img826/5349/errorsou.jpg(error)!
This makes no sense to me either. So I can compile the code on a 64bit system using the 32bit libraries, but the 64bit libs give me compiling error. The 32bit libraries successfully compiles the code, but nothing happens despite my main.cpp trying to open a image. The "likely.jpg" is placed in the .pro file directory and in the compiled .pro mingw folder that gets created after QT creator runs the project.
SO nothing happens despite me trying to grab this jpg image
!http://img269.imageshack.us/img269/9990/windowu.jpg(window)! -
I am now using your include path method which shortened the library codes, but the x86 libraries only bring me as far as getting the "Press <Return> to close this window..." command prompt window as shown above. Using x64 will give me the same "undefined reference to cv::..." errors as before. Assuming the 32 bit libraries are incompatible with my Windows 64 which gives me empty command prompt, something must be wrong with the 64bit libraries?
@INCLUDEPATH += C:\opencv\build\include \
BASE_PATH = C:\opencv\build\gpu\x86 LIBS += -L$$BASE_PATH\lib \ -lopencv_highgui231 \ -lopencv_core231
@