Results 1 to 4 of 4

Thread: OpenCV cvSmooth not working in Qt, but OK in Visual C++ 2008

  1. #1
    Join Date
    Mar 2012
    Posts
    3
    Qt products
    Qt4
    Platforms
    Windows

    Default OpenCV cvSmooth not working in Qt, but OK in Visual C++ 2008

    I am using Qt with OpenCV 2.3.1 (Qt version: Qt 4.8.0 for Desktop - MSVC2008, Tool Chain: Visual C++ Compiler 9.0 (x86)).
    I am trying to run a simple tutorial example:

    Qt Code:
    1. #include <QtGui/QApplication>
    2. #include <cv.h>
    3. #include <highgui.h>
    4.  
    5. int main(int argc, char *argv[])
    6. {
    7. QApplication a(argc, argv);
    8.  
    9. IplImage* img = 0;
    10. img=cvLoadImage("angrybird.jpg");
    11.  
    12. // create a window
    13. cvNamedWindow("mainWin", CV_WINDOW_AUTOSIZE);
    14. cvMoveWindow("mainWin", 100, 100);
    15.  
    16. // show the image
    17. cvShowImage("mainWin", img );
    18.  
    19.  
    20. //cvWaitKey(0);
    21. IplImage* img2 = cvCreateImage(cvGetSize(img),IPL_DEPTH_8U,3);
    22. cvSmooth( img, img2, CV_GAUSSIAN, 3, 3 );
    23. cvNamedWindow("Smooth", CV_WINDOW_AUTOSIZE);
    24. cvMoveWindow("Smooth", 200, 200);
    25. cvShowImage("Smooth", img2 );
    26. cvWaitKey(0);
    27.  
    28. // release the image
    29. cvReleaseImage(&img );
    30. cvReleaseImage(&img2 );
    31. return a.exec();
    32. }
    To copy to clipboard, switch view to plain text mode 

    When I run it, I got the error message:
    The program has unexpectedly finished.
    ... exited with code -1073741515
    The code run fine though if I comment out the cvSmooth() line.

    I believe I have the correct .pro file
    Qt Code:
    1. #-------------------------------------------------
    2. #
    3. # Project created by QtCreator 2012-02-13T22:03:03
    4. #
    5. #-------------------------------------------------
    6.  
    7. QT += core gui
    8.  
    9. TARGET = QImageJpegTest1
    10. TEMPLATE = app
    11.  
    12.  
    13. SOURCES += main.cpp
    14.  
    15. INCLUDEPATH += C:\OpenCV\opencv\build\include\opencv
    16. INCLUDEPATH += C:\OpenCV\opencv\build\include\opencv2
    17. INCLUDEPATH += C:\OpenCV\opencv\modules\core\include
    18. INCLUDEPATH += C:\OpenCV\opencv\modules\features2d\include
    19. INCLUDEPATH += C:\OpenCV\opencv\modules\flann\include
    20. INCLUDEPATH += C:\OpenCV\opencv\modules\legacy\include
    21. INCLUDEPATH += C:\OpenCV\opencv\modules\imgproc\include
    22. INCLUDEPATH += C:\OpenCV\opencv\modules\video\include
    23. INCLUDEPATH += C:\OpenCV\opencv\modules\calib3d\include
    24. INCLUDEPATH += C:\OpenCV\opencv\modules\gpu\include
    25. INCLUDEPATH += C:\OpenCV\opencv\modules\contrib\include
    26. INCLUDEPATH += C:\OpenCV\opencv\modules\haartraining\include
    27. INCLUDEPATH += C:\OpenCV\opencv\modules\highgui\include
    28. INCLUDEPATH += C:\OpenCV\opencv\modules\java\include
    29. INCLUDEPATH += C:\OpenCV\opencv\modules\ml\include
    30. INCLUDEPATH += C:\OpenCV\opencv\modules\objdetect\include
    31. INCLUDEPATH += C:\OpenCV\opencv\modules\python\include
    32. INCLUDEPATH += C:\OpenCV\opencv\modules\stitching\include
    33. INCLUDEPATH += C:\OpenCV\opencv\modules\traincascade\include
    34. INCLUDEPATH += C:\OpenCV\opencv\modules\ts\include
    35. INCLUDEPATH += C:\OpenCV\opencv\modules\androidcamera\include
    36. INCLUDEPATH += $$PWD/../../../../../OpenCV/opencv/build/x86/vc9
    37. DEPENDPATH += $$PWD/../../../../../OpenCV/opencv/build/x86/vc9
    38.  
    39.  
    40. win32:CONFIG(release, debug|release): LIBS += -L$$PWD/../../../../../OpenCV/opencv/build/x86/vc9/lib/ -lopencv_contrib231
    41. else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/../../../../../OpenCV/opencv/build/x86/vc9/lib/ -lopencv_contrib231d
    42. else:symbian: LIBS += -lopencv_contrib231
    43. else:unix: LIBS += -L$$PWD/../../../../../OpenCV/opencv/build/x86/vc9/lib/ -lopencv_contrib231
    44.  
    45. win32:CONFIG(release, debug|release): LIBS += -L$$PWD/../../../../../OpenCV/opencv/build/x86/vc9/lib/ -lopencv_core231
    46. else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/../../../../../OpenCV/opencv/build/x86/vc9/lib/ -lopencv_core231d
    47. else:symbian: LIBS += -lopencv_core231
    48. else:unix: LIBS += -L$$PWD/../../../../../OpenCV/opencv/build/x86/vc9/lib/ -lopencv_core231
    49.  
    50. win32:CONFIG(release, debug|release): LIBS += -L$$PWD/../../../../../OpenCV/opencv/build/x86/vc9/lib/ -lopencv_calib3d231
    51. else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/../../../../../OpenCV/opencv/build/x86/vc9/lib/ -lopencv_calib3d231d
    52. else:symbian: LIBS += -lopencv_calib3d231
    53. else:unix: LIBS += -L$$PWD/../../../../../OpenCV/opencv/build/x86/vc9/lib/ -lopencv_calib3d231
    54.  
    55. win32:CONFIG(release, debug|release): LIBS += -L$$PWD/../../../../../OpenCV/opencv/build/x86/vc9/lib/ -lopencv_flann231
    56. else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/../../../../../OpenCV/opencv/build/x86/vc9/lib/ -lopencv_flann231d
    57. else:symbian: LIBS += -lopencv_flann231
    58. else:unix: LIBS += -L$$PWD/../../../../../OpenCV/opencv/build/x86/vc9/lib/ -lopencv_flann231
    59.  
    60. win32:CONFIG(release, debug|release): LIBS += -L$$PWD/../../../../../OpenCV/opencv/build/x86/vc9/lib/ -lopencv_imgproc231
    61. else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/../../../../../OpenCV/opencv/build/x86/vc9/lib/ -lopencv_imgproc231d
    62. else:symbian: LIBS += -lopencv_imgproc231
    63. else:unix: LIBS += -L$$PWD/../../../../../OpenCV/opencv/build/x86/vc9/lib/ -lopencv_imgproc231
    64.  
    65. win32:CONFIG(release, debug|release): LIBS += -L$$PWD/../../../../../OpenCV/opencv/build/x86/vc9/lib/ -lopencv_features2d231
    66. else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/../../../../../OpenCV/opencv/build/x86/vc9/lib/ -lopencv_features2d231d
    67. else:symbian: LIBS += -lopencv_features2d231
    68. else:unix: LIBS += -L$$PWD/../../../../../OpenCV/opencv/build/x86/vc9/lib/ -lopencv_features2d231
    69.  
    70. win32:CONFIG(release, debug|release): LIBS += -L$$PWD/../../../../../OpenCV/opencv/build/x86/vc9/lib/ -lopencv_gpu231
    71. else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/../../../../../OpenCV/opencv/build/x86/vc9/lib/ -lopencv_gpu231d
    72. else:symbian: LIBS += -lopencv_gpu231
    73. else:unix: LIBS += -L$$PWD/../../../../../OpenCV/opencv/build/x86/vc9/lib/ -lopencv_gpu231
    74.  
    75. win32:CONFIG(release, debug|release): LIBS += -L$$PWD/../../../../../OpenCV/opencv/build/x86/vc9/lib/ -lopencv_haartraining_engine
    76. else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/../../../../../OpenCV/opencv/build/x86/vc9/lib/ -lopencv_haartraining_engined
    77. else:symbian: LIBS += -lopencv_haartraining_engine
    78. else:unix: LIBS += -L$$PWD/../../../../../OpenCV/opencv/build/x86/vc9/lib/ -lopencv_haartraining_engine
    79.  
    80. win32:CONFIG(release, debug|release): LIBS += -L$$PWD/../../../../../OpenCV/opencv/build/x86/vc9/lib/ -lopencv_highgui231
    81. else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/../../../../../OpenCV/opencv/build/x86/vc9/lib/ -lopencv_highgui231d
    82. else:symbian: LIBS += -lopencv_highgui231
    83. else:unix: LIBS += -L$$PWD/../../../../../OpenCV/opencv/build/x86/vc9/lib/ -lopencv_highgui231
    84.  
    85. win32:CONFIG(release, debug|release): LIBS += -L$$PWD/../../../../../OpenCV/opencv/build/x86/vc9/lib/ -lopencv_legacy231
    86. else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/../../../../../OpenCV/opencv/build/x86/vc9/lib/ -lopencv_legacy231d
    87. else:symbian: LIBS += -lopencv_legacy231
    88. else:unix: LIBS += -L$$PWD/../../../../../OpenCV/opencv/build/x86/vc9/lib/ -lopencv_legacy231
    89.  
    90. win32:CONFIG(release, debug|release): LIBS += -L$$PWD/../../../../../OpenCV/opencv/build/x86/vc9/lib/ -lopencv_video231
    91. else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/../../../../../OpenCV/opencv/build/x86/vc9/lib/ -lopencv_video231d
    92. else:symbian: LIBS += -lopencv_video231
    93. else:unix: LIBS += -L$$PWD/../../../../../OpenCV/opencv/build/x86/vc9/lib/ -lopencv_video231
    94.  
    95. win32:CONFIG(release, debug|release): LIBS += -L$$PWD/../../../../../OpenCV/opencv/build/x86/vc9/lib/ -lopencv_ts231
    96. else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/../../../../../OpenCV/opencv/build/x86/vc9/lib/ -lopencv_ts231d
    97. else:symbian: LIBS += -lopencv_ts231
    98. else:unix: LIBS += -L$$PWD/../../../../../OpenCV/opencv/build/x86/vc9/lib/ -lopencv_ts231
    99.  
    100. win32:CONFIG(release, debug|release): LIBS += -L$$PWD/../../../../../OpenCV/opencv/build/x86/vc9/lib/ -lopencv_ts231
    101. else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/../../../../../OpenCV/opencv/build/x86/vc9/lib/ -lopencv_ts231d
    102. else:symbian: LIBS += -lopencv_ts231
    103. else:unix: LIBS += -L$$PWD/../../../../../OpenCV/opencv/build/x86/vc9/lib/ -lopencv_ts231
    104.  
    105. win32:CONFIG(release, debug|release): LIBS += -L$$PWD/../../../../../OpenCV/opencv/build/x86/vc9/lib/ -lopencv_objdetect231
    106. else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/../../../../../OpenCV/opencv/build/x86/vc9/lib/ -lopencv_objdetect231d
    107. else:symbian: LIBS += -lopencv_objdetect231
    108. else:unix: LIBS += -L$$PWD/../../../../../OpenCV/opencv/build/x86/vc9/lib/ -lopencv_objdetect231
    To copy to clipboard, switch view to plain text mode 

    I was thinking it might be due to missing dll. But when I test the same code in Visual Studio 2008, it works fine with cvSmooth() there and smooth the image as it suppose to do. If it is a dll problem, VC++ code shouldn't work either, isn't it?
    Here is the VC++ code:

    Qt Code:
    1. // testOpenCV.cpp : Defines the entry point for the console application.
    2. //
    3.  
    4. #include "stdafx.h"
    5. #include <math.h>
    6. #include <cv.h>
    7. #include <highgui.h>
    8.  
    9. int _tmain(int argc, _TCHAR* argv[])
    10. {
    11. IplImage* img = 0;
    12. img=cvLoadImage("angrybird.jpg");
    13.  
    14. // create a window
    15. cvNamedWindow("mainWin", CV_WINDOW_AUTOSIZE);
    16. cvMoveWindow("mainWin", 100, 100);
    17. // show the image
    18. cvShowImage("mainWin", img );
    19.  
    20. //cvWaitKey(0);
    21.  
    22. IplImage* img2 = cvCreateImage(cvGetSize(img),IPL_DEPTH_8U,3);
    23. cvSmooth( img, img2, CV_GAUSSIAN, 3, 3 );
    24. cvNamedWindow("Smooth", CV_WINDOW_AUTOSIZE);
    25. cvMoveWindow("Smooth", 200, 200);
    26. cvShowImage("Smooth", img2 );
    27. cvWaitKey(0);
    28. // release the image
    29. cvReleaseImage(&img );
    30. cvReleaseImage(&img2 );
    31. return 0;
    32. }
    To copy to clipboard, switch view to plain text mode 

    I am now run out of idea where to look for the problem. I will appreciate if anyone can point me to a new direction.
    Thanks.

  2. #2
    Join Date
    Mar 2012
    Posts
    3
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: OpenCV cvSmooth not working in Qt, but OK in Visual C++ 2008

    BTW, I tried the same thing on two machines, one is a desktop at work and another is a laptop, both running Windows 7. Got the same result on both machines: VC++ version runs fine, the Qt one is not working.

    Anyone has experienced similar problem before?

    I would really appreciate if someone try the Qt code above and see if they got the same problem. Thanks.

  3. #3
    Join Date
    Apr 2011
    Posts
    1
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: OpenCV cvSmooth not working in Qt, but OK in Visual C++ 2008

    hi
    did you found any answer ?

  4. #4
    Join Date
    Mar 2012
    Posts
    3
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: OpenCV cvSmooth not working in Qt, but OK in Visual C++ 2008

    No. For now, I switch back to VC++ and am not using Qt for anything OpenCV. I still wish I could use Qt though.
    Did you try using cvSmooth in Qt and got similar problem?

Similar Threads

  1. QT4 not working in Visual Studio 2008
    By mnemonic69 in forum Installation and Deployment
    Replies: 4
    Last Post: 27th May 2010, 05:37
  2. Integrating opencv with QT in visualstudio 2008
    By reem in forum Qt Programming
    Replies: 1
    Last Post: 12th April 2010, 09:12
  3. Visual Studio 2008 and Qt
    By konx in forum Installation and Deployment
    Replies: 2
    Last Post: 22nd January 2010, 21:24
  4. How to use Qt with Visual Studio 2008?
    By N3wb in forum Installation and Deployment
    Replies: 2
    Last Post: 13th August 2009, 16:23
  5. Qt 4.3.2 + Visual studio 2008
    By moowy in forum Installation and Deployment
    Replies: 6
    Last Post: 6th December 2007, 06:41

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.