Results 1 to 20 of 34

Thread: Qt + OpenCV, simple example

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Sep 2009
    Location
    Wroclaw, Poland
    Posts
    1,394
    Thanked 342 Times in 324 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Qt + OpenCV, simple example

    Hi,

    today I've found my old project I wrote some time ago. This is simple application that uses OpenCV to capture images from camera or video, optionally process them and displays in QLabel. I've decided to share it with community, made the code more self-explanatory, added some comments, especially explaining BGR24 IplImage to QImage conversion stuff (it can be done easier, but I think its better this way for "educational" purposes).
    This app does not use separate threads for capturing or processing images, I think everything is as simple as possible.
    I've seen many posts about using basic OpenCV with Qt, so maybe this will be useful for some "newbies".

    I hope this helps someone.
    Attached Images Attached Images
    Attached Files Attached Files
    Last edited by stampede; 11th July 2011 at 23:58.

  2. The following 5 users say thank you to stampede for this useful post:

    andre_teprom (26th July 2013), harley (1st September 2011), ikmqt (28th August 2012), Ksenia (15th October 2013), mvuori (12th July 2011)

  3. #2
    Join Date
    Jul 2010
    Posts
    22
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows Symbian S60

    Default Re: Qt + OpenCV, simple example

    Hi Stampede,
    I'm new to QT and opencv, I'm tring to learn to use QT and opencv by following the example given by the book. But I have problem in pointing the directory. So I search and found your free example application. I have installed Opencv2.3 and I tried to edit the project file...and just want to see if it will run..but still I have the similar problem.
    Qt Code:
    1. TEMPLATE = app
    2. DESTDIR = bin
    3. TARGET = cvexample
    4. DEPENDPATH += . src/cpp src/h src/ui
    5. INCLUDEPATH += . src/h
    6.  
    7. UI_DIR = build
    8. MOC_DIR = build
    9.  
    10. build_pass:CONFIG(debug, debug|release){
    11. OBJECTS_DIR = build/debug
    12. } else{
    13. OBJECTS_DIR = build/release
    14. }
    15.  
    16. win32 {
    17. CV11_INCLUDE = C:/OpenCV2.3
    18. CV11_LIB = C:/OpenCV2.3/lib
    19. CV22_INCLUDE = C:/OpenCV2.3/modules
    20. CV22_LIB = C:/OpenCV2.3/build/bin
    21. } else{
    22. CV11_INCLUDE = /usr/local/include/OpenCV
    23. CV11_LIB = /usr/local/lib/OpenCV
    24. CV22_INCLUDE = /usr/local/include/OpenCV2.3
    25. CV22_LIB = /usr/local/lib/OpenCV2.3
    26. }
    27.  
    28. contains(cv,2){
    29. message(build with opencv 2)
    30. DEFINES += OPEN_CV_22
    31. INCLUDEPATH += $$CV22_INCLUDE/core/include/opencv2.3/core \
    32. $$CV22_INCLUDE/highgui/include/opencv2.3/highgui \
    33. $$CV22_INCLUDE/imgproc/include/opencv2.3/imgproc \
    34. $$CV22_INCLUDE/core/include \
    35. $$CV22_INCLUDE/imgproc/include
    36. LIBS += -L$$CV22_LIB
    37. LIBS += -lopencv_highgui220 -lopencv_core220 -lopencv_imgproc220
    38. } else{
    39. message(build with opencv 1.1)
    40. DEFINES -= OPEN_CV_22
    41. INCLUDEPATH += $$CV11_INCLUDE/cv/include $$CV11_INCLUDE/otherlibs/highgui $$CV11_INCLUDE/cxcore/include
    42. LIBS += -L$$CV11_LIB
    43. LIBS += -lcv -lhighgui -lcxcore
    44. }
    45.  
    46. HEADERS += src/h/ImageCapture.h src/h/MainWidget.h
    47. FORMS += src/ui/MainWidget.ui
    48. SOURCES += src/cpp/ImageCapture.cpp src/cpp/MainWidget.cpp main.cpp
    To copy to clipboard, switch view to plain text mode 
    When I compiled it says "C:\QtCvExample-build-desktop\..\QtCvExample\src\h\ImageCapture.h:16: error: cv.h: No such file or directory"
    I know there are some link in this forum regarding opencv, but still I cant find what I'm looking for.

    thanks in advance,
    lam-ang

  4. #3
    Join Date
    Sep 2009
    Location
    Wroclaw, Poland
    Posts
    1,394
    Thanked 342 Times in 324 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: Qt + OpenCV, simple example

    If you are using OpenCV 2.2 or 2.3, you need to run qmake cv=2 and then make, because by default it will include and link to OpenCV 1.1 (btw. its in README ).
    What does it print when you run qmake ? Probably "build with opencv 1.1", right ?

  5. The following user says thank you to stampede for this useful post:

    andre_teprom (26th July 2013)

  6. #4
    Join Date
    Jul 2010
    Posts
    22
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows Symbian S60

    Default Re: Qt + OpenCV, simple example

    Hi, thanks..hmm I think I better do some more reading in order follow your suggestion...I appreciate the help. I'll get back, as soon I got it.

    regards,
    lam-ang

  7. #5
    Join Date
    Jul 2010
    Posts
    22
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows Symbian S60

    Default Re: Qt + OpenCV, simple example

    Hi, I have a question, I appoligize if this is so obvious, but I'm really struggling to learn QT. And I came back to post it here because I feel I'm not going anywhere..I was reading "OpenCV 2 Computer application Porgramming cookbook". The first exercise in the book is to display an image. But I found out my QT and Opencv configuration is not correct. I tried to search into this forum and found this useful example(by stampede) that I will gain from but obviously I dont have any idea how to do the procedure as suggested, I must use qmake and make ( tried to read some document) but I was getting lost ..So here is my question.
    1. How can I configure QT and OpenCv using qmake and make?
    Before trying the "QtCvexample" I want to try to display an image to the screen, please see my attachemnt. I have Qt 4.7.3 and OpenCv2.3 installed

    Thanks in advance,
    lam-ang
    Attached Images Attached Images

Similar Threads

  1. OpenCV + QT4
    By thereisnoknife in forum Qt Programming
    Replies: 6
    Last Post: 8th March 2013, 05:19
  2. opencv-qt-mac
    By ireneluis in forum Qt Programming
    Replies: 0
    Last Post: 16th March 2010, 15:24
  3. Qt and OpenCV
    By malorie in forum Newbie
    Replies: 2
    Last Post: 7th March 2010, 14:57
  4. OpenCv & Qt4
    By switch in forum Qt Programming
    Replies: 0
    Last Post: 4th August 2009, 15:12
  5. JAI vs. OpenCV vs. ITK
    By tpieciak in forum General Programming
    Replies: 0
    Last Post: 8th July 2009, 13:45

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.