PDA

View Full Version : Sample project ( QT4 + OpenCV) --> Request



andre_teprom
23rd July 2011, 22:56
Hi Friends,


Sorry if I´m asking for a stupid and recurrent issue, but really searched for some usable project here, but didn´t found.
I am a JAVA and C++BUILDER ( not advanced ) programmer, but am newer at QT and OpenCV.
I tryed to create a simple panel, just openning an image, but have a lot of problems, and don´t know exacly if the problem is at instalation or at creation itself.

Colud somebody please give to me a web link, or sample project ?



Thanks in advance !

+++

ChrisW67
23rd July 2011, 23:43
Does http://www.qtcentre.org/threads/43056-Qt-OpenCV-simple-example help?

andre_teprom
24th July 2011, 13:33
Hi

I appreciate too much your help.
I downloaded the project, and after some remaining QT isntalations and PATH definitions, now is trying to compile.

However, I guess is happening some problem at QT configuration ( or even, at instalation ).
The project presents ~850 compilation errors.
Not at include path, which are all corrected.
But, those errors are concerned to sintax.

I believe, that QT is compiling at some other language than ANSI-C ( C++ , G++ ).
Could please provide to me some guidelines ?

Thanks in advance...

+++

stampede
24th July 2011, 14:18
You can post in the linked thread, maybe others will benefit in the future.
Post the compilation errors there, I'll try to help. This project was tested (compiled+run) on windows xp (gcc 4.4, Qt 4.5), windows vista (gcc 4.4, Qt 4.5), windows 7 (gcc 4.5, Qt 4.7.2) and ubuntu 9.10 (i dont remember), so I'm pretty sure the code does not contain any syntax errors.
Qt is c++, not ANSI-C, so you need to have c++ compiler, I have tested this with g++, I dont know if it will work with Visual Studio compilers.

andre_teprom
24th July 2011, 15:32
Hi stampede,


I avoided to post at the other thread, due I believe that are too many posts there, and it turns hard to focuse on the punctual problem, but I appreciate too much your sugestion.
( sorry if this procedure is wrong ).

Follows the screens of QT configuration.
It can be seen that elementary sintax errors are occouring.
I´m on : WIN-XP SP2 / QT 4.6.1
What I´m doing wrong ?
( I believe that the compiler settings is not correct )

-------

http://www.teprom.eng.br/arquivos/qt/1.JPG


-------


http://www.teprom.eng.br/arquivos/qt/2.JPG

-------

http://www.teprom.eng.br/arquivos/qt/3.JPG

-------

http://www.teprom.eng.br/arquivos/qt/4.JPG

Thanks in advance !

+++

stampede
24th July 2011, 19:01
I have never tried to build this project with automatic builder, to be honest I'm not sure if these settings are correct, they look ok to me.
It seems you are using qmake & mingw32-make, so why are you setting the cmake options ?
Have you changed the .pro file that comes with the project ? If you are using OpenCV 2.3 then I think you need to change the paths in .pro file, because I was using OpenCV ver. 2.2.
This is meant to be built within command line (I got quite used to it), so try to cd to the project directory and type in the console:


qmake cv=2
mingw32-make

If you do not specify the cv=2 options, by default it will try to include and link to OpenCV 1.1. If you dont want to do that by hand, then just change the .pro file to always use OpenCV 2.3, make sure the paths are correct.
Post the file content and your opencv paths if you are not sure how it should look like.

andre_teprom
24th July 2011, 19:27
Hi stampede,

I will check the other advices you gave.
For while, I will post the .PRO content.
Must I change the 2.2 values to 2.3 ?



EMPLATE = app
DESTDIR = bin
TARGET = cvexample
DEPENDPATH += . src/cpp src/h src/ui
INCLUDEPATH += . src/h

UI_DIR = build
MOC_DIR = build

build_pass:CONFIG(debug, debug|release){
OBJECTS_DIR = build/debug
} else{
OBJECTS_DIR = build/release
}

win32 {
CV11_INCLUDE = C:/OpenCV
CV11_LIB = C:/OpenCV/lib
CV22_INCLUDE = C:/OpenCV2.2/modules
CV22_LIB = C:/OpenCV2.2/build/bin
} else{
CV11_INCLUDE = /usr/local/include/OpenCV
CV11_LIB = /usr/local/lib/OpenCV
CV22_INCLUDE = /usr/local/include/OpenCV2.2
CV22_LIB = /usr/local/lib/OpenCV2.2
}

contains(cv,2){
message(build with opencv 2.2)
DEFINES += OPEN_CV_22
INCLUDEPATH += $$CV22_INCLUDE/core/include/opencv2/core \
$$CV22_INCLUDE/highgui/include/opencv2/highgui \
$$CV22_INCLUDE/imgproc/include/opencv2/imgproc \
$$CV22_INCLUDE/core/include \
$$CV22_INCLUDE/imgproc/include
LIBS += -L$$CV22_LIB
LIBS += -lopencv_highgui220 -lopencv_core220 -lopencv_imgproc220
} else{
message(build with opencv 1.1)
DEFINES -= OPEN_CV_22
INCLUDEPATH += $$CV11_INCLUDE/cv/include $$CV11_INCLUDE/otherlibs/highgui $$CV11_INCLUDE/cxcore/include
LIBS += -L$$CV11_LIB
LIBS += -lcv -lhighgui -lcxcore
}

HEADERS += src/h/ImageCapture.h src/h/MainWidget.h
FORMS += src/ui/MainWidget.ui
SOURCES += src/cpp/ImageCapture.cpp src/cpp/MainWidget.cpp main.cpp


+++

stampede
24th July 2011, 20:50
If you have OpenCV 2.3, then yes, change the paths to match your system.
Here is simplified .pro file, fill the paths yourself:

TEMPLATE = app
DESTDIR = bin
TARGET = cvexample
DEPENDPATH += . src/cpp src/h src/ui
INCLUDEPATH += . src/h

UI_DIR = build
MOC_DIR = build

build_pass:CONFIG(debug, debug|release){
OBJECTS_DIR = build/debug
} else{
OBJECTS_DIR = build/release
}

# here, fille the correct path, if you have Opencv 2.3 in C:/OpenCV2.3/ then leave this as is
CV22_INCLUDE = C:/OpenCV2.3/modules
CV22_LIB = C:/OpenCV2.3/build/bin

DEFINES += OPEN_CV_22
INCLUDEPATH += $$CV22_INCLUDE/core/include/opencv2/core \
$$CV22_INCLUDE/highgui/include/opencv2/highgui \
$$CV22_INCLUDE/imgproc/include/opencv2/imgproc \
$$CV22_INCLUDE/core/include\
$$CV22_INCLUDE/imgproc/include
LIBS += -L$$CV22_LIB
LIBS += -lopencv_highgui230 -lopencv_core230 -lopencv_imgproc230

HEADERS += src/h/ImageCapture.h src/h/MainWidget.h
FORMS += src/ui/MainWidget.ui
SOURCES += src/cpp/ImageCapture.cpp src/cpp/MainWidget.cpp main.cpp

andre_teprom
24th July 2011, 22:01
Hi,

I already had performed that changes by other way, but even replacing by your file still is not working.
I believe the reason could be at __cplusplus directive definition ( I noticed here is '1' ).

Could you please check that compiling error messages and infer some cause ?

http://www.teprom.eng.br/arquivos/qt/imagem.JPG

+++

andre_teprom
25th July 2011, 00:28
Great nwes !


I solve most problems, and remains just one ( I hope to be an elementary issue, regarding to tool configuration subject ).
Could check it please ?


collect2: ld returned 1 exit status
mingw32-make.exe[1]: *** [bin\cvexample.exe] Error 1
C:\MinGW\bin\mingw32-make.exe: *** [debug] Error 2
Exited with code 2.

http://www.teprom.eng.br/arquivos/qt/result.JPG

+++

stampede
25th July 2011, 07:34
I'm glad you have it solved, maybe you can post how did you do that, so that others could use your solution in the future.
And yes, this should be easy to solve, this:

CV22_LIB = C:/OpenCV2.3/build/bin
should point to a directory containing libopencv_core230.dll and libopencv_highgui230.dll (if you are using opencv 2.3), if those files are in other directory, change this value. After you do that, copy the .dlls to a directory where cvexample.exe is located (default is "bin" folder in project directory), because you will have problems with running the app.

andre_teprom
26th July 2011, 01:54
Hi,

You´re right about to share the solution, but the way I did to solve the problem is almost stupid.
I changed all paths at include files in OpenCV files ( c , h , cpp , hpp ).

In fact, I had to use other LIB path than what you sugested above, due there was nothing there :

CV22_LIB = C:\OpenCV2.3\build\x86\mingw\bin

I will copy the DLLs and post results here later.
Thanks a lot !

+++



--------------------------------
Added after 29 minutes:
--------------------------------



Hi,


I did what you sugested, but did not work, returning following exit code at QT Creator IDE : 1073741511
When I run generated EXE file, the above message appears ( my Windows is at Portugueese language ), warning that is missing an input entry to the LIBSTDC++-6.DLL:
http://www.teprom.eng.br/arquivos/qt/b.JPG
Note that I put all related files at the same Bin folder where executable is on :
http://www.teprom.eng.br/arquivos/qt/a.JPG
Do you know what I could try to solve this ?

The most strange, is that running a sample QT project, works fine.

+++

stampede
26th July 2011, 06:40
Where did you get this libstdc++-6.dll from ? Try to use the one that comes with your mingw installation.