Microsoft
- Windows Forms (.Net) with C++ or C#; .Net port of Emgu Project
- MFC (Native) - Visual Studio Standard/Professional and up
- Qt: Visual Studio - Qt-add-in to take care of the Qt-specific compilation process. Visual Studio Standard/Pro and up.
- Qt: QT Creator
OpenCV
1. HighGUI + Qt as back-end
2. There is a window_gtk.cpp, wonder if it works on Windows also.
Initial thoughts
Based on what I read from various internet discussions, I could use another GUI framework while keeping highGUI module for image, (camera) video, encode/ decode/read/write. The only work I need to write is to implement cvDrawImage().
Like C# but afraid that .Net would slow down execution. And wonder if C# port would introduce another set of issues/bugs.
The pros of choosing Qt is the cvDrawImage() is already there in window_QT.cpp.
Going with Qt
Problem with MSVC OpenCV DLL
Installed QTCreator. Created a simple app that open a file with the QT File Dialog. It uses OpenCV API to open an image file. Result: C API compiled and ran fine (cvLoadImageM()). Using the corresponding C++ API got linking error (undefined references to cv::imread()). Made the case simpler by trying cvGetTickCount(). Again the C API worked while C++ function cv::GetTickCount() did not. This is the configuration I used for building the application: http://www.barbato.us/2011/03/18/using-opencv2-within-qtcreator-in-windows-2/
Tried to fix the problem with 'reimp' MinGW utility like this: http://www.mingw.org/wiki/MSVC_and_MinGW_DLLs
Unfortunately, 'reimp' did not like opencv_core220d.lib. Giving error 'invalid or corrupt import library'. Someone filed a bug report on this, not sure if that's the same case http://sourceforge.net/tracker/?func=detail&atid=102435&aid=3120866&group_id=2435
Someone points to this article to describe the common issues of linking C++ libraries built with different compilers: http://chadaustin.me/cppinterface.html
Giving up on this for now.
Debugger failed to step into OpenCV DLL
Even though calling OpenCV C API worked, I was unable to get the debugger to step into OpenCV functions. Installed 32-bit Debugging Tools for Windows (x86). Enable CDB in QTCreator Options menu. Followed instructions here: http://msdn.microsoft.com/en-us/windows/hardware/gg463016.aspx ; Still cannot get it to work.
OpenCV MinGW Build
Since QTCreator compiles with the MinGW toolchain. Rebuilt OpenCV 2.2 with latest stable version of MinGW(not the one packaged with QTCreator). Instructions here: http://opencv.willowgarage.com/wiki/MinGW ; Encountered a error linking with VideoInput.a - and the workaround is described here: https://code.ros.org/trac/opencv/ticket/587
The OpenCV was then built successfully. There are some compilation errors with the C/C++ samples. g++ doesn't like:
vector<vector<Point>> cpoints So I changed to this vector<vector<Point> > cpoints
Fixes are trivial. I am now able to run both the adaptiveskindetector and camshiftdemo from the command-line. It can even read from the webcam right away!
QtCreator
MinGW versions
QtCreator uses its own MinGW. The gcc version is 4.4. The latest MinGW that I used to build OpenCV is gcc4.5.2. It caused problem at runtime. I fixed it by setting the PATH such that the newer MinGW DLLs are picked up.
Debugger: Unusably slow stepping in OpenCV DLLs. Wonder why.... Related to this?! http://bugreports.qt.nokia.com/browse/QTCREATORBUG-3115
qmake
The qmake manual says automatic code completion and syntax highlighting will be available from external libraries after they are declared in the INCLUDEPATH and LIBS variables. I noticed that it only works if the directory is assigned to INCLUDEPATH as literal string, not a variable value $().
Initial thoughts
Based on what I read from various internet discussions, I could use another GUI framework while keeping highGUI module for image, (camera) video, encode/ decode/read/write. The only work I need to write is to implement cvDrawImage().
Like C# but afraid that .Net would slow down execution. And wonder if C# port would introduce another set of issues/bugs.
The pros of choosing Qt is the cvDrawImage() is already there in window_QT.cpp.
Going with Qt
Problem with MSVC OpenCV DLL
Installed QTCreator. Created a simple app that open a file with the QT File Dialog. It uses OpenCV API to open an image file. Result: C API compiled and ran fine (cvLoadImageM()). Using the corresponding C++ API got linking error (undefined references to cv::imread()). Made the case simpler by trying cvGetTickCount(). Again the C API worked while C++ function cv::GetTickCount() did not. This is the configuration I used for building the application: http://www.barbato.us/2011/03/18/using-opencv2-within-qtcreator-in-windows-2/
Tried to fix the problem with 'reimp' MinGW utility like this: http://www.mingw.org/wiki/MSVC_and_MinGW_DLLs
Unfortunately, 'reimp' did not like opencv_core220d.lib. Giving error 'invalid or corrupt import library'. Someone filed a bug report on this, not sure if that's the same case http://sourceforge.net/tracker/?func=detail&atid=102435&aid=3120866&group_id=2435
Someone points to this article to describe the common issues of linking C++ libraries built with different compilers: http://chadaustin.me/cppinterface.html
Giving up on this for now.
Debugger failed to step into OpenCV DLL
Even though calling OpenCV C API worked, I was unable to get the debugger to step into OpenCV functions. Installed 32-bit Debugging Tools for Windows (x86). Enable CDB in QTCreator Options menu. Followed instructions here: http://msdn.microsoft.com/en-us/windows/hardware/gg463016.aspx ; Still cannot get it to work.
OpenCV MinGW Build
Since QTCreator compiles with the MinGW toolchain. Rebuilt OpenCV 2.2 with latest stable version of MinGW(not the one packaged with QTCreator). Instructions here: http://opencv.willowgarage.com/wiki/MinGW ; Encountered a error linking with VideoInput.a - and the workaround is described here: https://code.ros.org/trac/opencv/ticket/587
The OpenCV was then built successfully. There are some compilation errors with the C/C++ samples. g++ doesn't like:
vector<vector<Point>> cpoints So I changed to this vector<vector<Point> > cpoints
Fixes are trivial. I am now able to run both the adaptiveskindetector and camshiftdemo from the command-line. It can even read from the webcam right away!
QtCreator
MinGW versions
QtCreator uses its own MinGW. The gcc version is 4.4. The latest MinGW that I used to build OpenCV is gcc4.5.2. It caused problem at runtime. I fixed it by setting the PATH such that the newer MinGW DLLs are picked up.
Debugger: Unusably slow stepping in OpenCV DLLs. Wonder why.... Related to this?! http://bugreports.qt.nokia.com/browse/QTCREATORBUG-3115
qmake
The qmake manual says automatic code completion and syntax highlighting will be available from external libraries after they are declared in the INCLUDEPATH and LIBS variables. I noticed that it only works if the directory is assigned to INCLUDEPATH as literal string, not a variable value $().
At the end...
I am able to get the application to open an image and display it correctly. It uses OpenCV C++ API to load image - swap color channels from BGR to RGB. The display part uses QtGraphicsScene and QtGraphicsView to show the QtImage.
Resources
http://thomasstockx.blogspot.com/2011/03/qt-472-in-visual-studio-2010.html
Here is a hyperlink found in window_QT.hpp, a Qt article on how to interactively pan and zoom images smoothly
http://www.qtcentre.org/wiki/index.php?title=QGraphicsView:_Smooth_Panning_and_Zooming