×

Discussion Board

Page 1 of 2 12 LastLast
Results 1 to 15 of 26
  1. #1
    Registered User
    Join Date
    Jun 2010
    Posts
    36

    Exclamation OpenCV in Qt example

    Hi guys,

    I just ported a small OpenCV example to Maemo. It builds on http://qt-apps.org/content/show.php/...?content=89995 and is available here: http://www.zshare.net/download/771049800b033e35/

    I have three short questions about it:

    1) Klen and others recommended using OpenCV for an AR application for obvious reasons, but in this example the performance is quite poor. How could it be improved? Is it e.g. better to read the image via GStreamer and then run OpenCV methods over it? This is very important to me, since I'd love to use this library extensively.

    2) QtCreator behaves strangely when I try to build this project: It throws 13 errors if I open the augmentedvision.pro (doesn't find opengl/cv.h & opengl/highgui.h) and use "Build All", whereas it compiles perfectly if done manually in a scratchbox shell (qmake augmentedvision.pro; make - build can be found in ./src). Any ideas how to avoid this?

    3) If I now want to build a fancy AR app - would you use Qt + GStreamer + OpenCV + OpenGL + SDL or would you stick to a subset? My two starting points are this code, some corner detectors and Klen's OpenGLGst example. What are the best parts of both approaches, how can they be combined optimally and what should I add / change? Any last recommendations before I start programming a serious application?

    Thanks in advance.


    Best regards,
    Dorfmeister


    PS:
    Sorry for the last two threads - they were intended to be simple posts instead, but obviously I shouldn't have changed the subject. They can be deleted as far am I'm concerned. Thanks for the helpful answers, though.

  2. #2
    Registered User
    Join Date
    Feb 2010
    Posts
    17

    Re: OpenCV in Qt example

    2) I link OpenCV in my .pro by :

    CONFIG += link_pkgconfig
    PKGCONFIG += opencv

    It could find the header and able to do auto complete for member function. However, it would depend on your setup. It make your software depends on a lot of package.

    p.s My QT creator version is 1.3.84

    3) I have already built an application on Maemo with OpenCV ,but the app do not process video. So can't compare what approach is better. But personally speaking , the functionity of highgui is too limited , I prefer to drop it and use system's utiltiy (gstreamer) for I/O stuff.

  3. #3
    Nokia Developer Moderator
    Join Date
    Oct 2009
    Posts
    4,326

    Re: OpenCV in Qt example

    1) You can try profiling to see what is the bottleneck of the application. Normally optimisation discussion makes no sense before one has figures from profiling report.
    2) pkg-config should be definitely a solution here
    3) There is no point to combine SDL and Qt, you should choose one of them. GStreamer is pretty slow framework, but it gives you an abstraction API, which makes development easier.

  4. #4
    Registered User
    Join Date
    Jun 2010
    Posts
    36

    Re: OpenCV in Qt example

    Thanks for your answers. I really appreciate the tips, but opencv/cv.h is still not found. I tried to replace my stuff with the two lines, but had no success ad currently my src.pro file includes every useful library I'm aware of (based on Klen's .pro):

    Code:
    #-------------------------------------------------
    #
    # Project created by QtCreator 2010-06-10T16:24:32
    #
    #-------------------------------------------------
    
    QT       += core gui opengl
    
    TARGET = augmentedvision
    TEMPLATE = app
    
    CONFIG += link_pkgconfig mobility
    
    ######################################################################
    #Could not link gtk+-2.0 with pkgconfig (Conflict with QtGui library)
    ######################################################################
    
    PKGCONFIG += opencv \
                 gstreamer-plugins-base-0.10 \
                 gstreamer-interfaces-0.10 \
                 gstreamer-0.10 dbus-1 \
                 gstreamer-app-0.10 \
                 gstreamer-plugins-bad-0.10
    
    ######################################################################
    #Include gtk+-2.0 manually (QtGui conflict problem)
    ######################################################################
    INCLUDEPATH +=. /usr/include/ \
                    /usr/include/gtk-2.0/ \
                    /usr/include/gtk-2.0/gtk/\
                    /usr/lib/gtk-2.0/include \
                    /usr/include/glib-2.0/ \
                                    /usr/include/glib-2.0/glib/ \
                                    /usr/include/glib-2.0/gio/ \
                                    /usr/include/glib-2.0/gobject/ \
                    /usr/include/atk-1.0/ \
                    /usr/include/cairo/ \
                    /usr/include/pango-1.0/ \
                    /usr/lib/glib-2.0/include \
                    /usr/include/opengl
    
    # Since this didn't help I additional add the following, but to no avail:
    INCLUDEPATH += /usr/include/opencv
    LIBS          += -lcv -lhighgui
    
    HEADERS += MyCameraWindow.h QOpenCVWidget.h
    FORMS += mainwindow.ui
    SOURCES += main.cpp \
               MyCameraWindow.cpp \
               QOpenCVWidget.cpp
    
    MOBILITY = 
    
    symbian {
        TARGET.UID3 = 0xe8689d1a
        # TARGET.CAPABILITY += 
        TARGET.EPOCSTACKSIZE = 0x14000
        TARGET.EPOCHEAPSIZE = 0x020000 0x800000
    }
    
    unix {
        #VARIABLES
        isEmpty(PREFIX) {
            PREFIX = /usr/local
        }
    
        BINDIR = $$PREFIX/bin
        DATADIR =$$PREFIX/share
    
        DEFINES += DATADIR=\"$$DATADIR\" PKGDATADIR=\"$$PKGDATADIR\"
    
        #MAKE INSTALL
    
        INSTALLS += target desktop scalable
    
        target.path =$$BINDIR
    
        desktop.path = $$DATADIR/applications/hildon
        desktop.files += ../data/$${TARGET}.desktop
    
        scalable.path = $$DATADIR/icons/hicolor/scalable/hildon
        scalable.files += ../data/scalable/$${TARGET}.png
    
    }
    It still doesn't find it, though. Any ideas?

    Regarding point 3: I intuitively prefer Qt over SDL. If there are any objections, I'd be happy to hear them. Furthermore: If GStreamer is "pretty slow" - is there a better and faster solution available to get the video stream? Should OpenCV be faster, but just in this case is not?


    Best regards,
    Dorfmeister

    EDIT:
    Again, the manual scratchbox build works perfectly. Strange, isn't it?
    Last edited by Dorfmeister; 2010-06-11 at 16:52.

  5. #5
    Nokia Developer Moderator
    Join Date
    Oct 2009
    Posts
    4,326

    Re: OpenCV in Qt example

    Did you install libcv-dev?

  6. #6
    Registered User
    Join Date
    Jun 2010
    Posts
    36

    Re: OpenCV in Qt example

    I think so:
    Code:
    [sbox-FREMANTLE_ARMEL: ~/OwnProjects/OpenCV/augmentedvision/src] > apt-get install libcv-dev
    Reading package lists... Done
    Building dependency tree... Done
    libcv-dev is already the newest version.
    0 upgraded, 0 newly installed, 0 to remove and 575 not upgraded
    Btw: I use Qt Creator 1.3.83 based on Qt 4.7.0 (32 bit) built on Apr 22 2010 at 12:07:43 from the Qt SDK Beta on an updated Ubuntu developer VM. All opencv packages available except doc and python bindings should be installed inside Scratchbox.

    EDIT:
    Could anybody be so kind and try to compile my project with Qt Creator either with the original src.pro or with the one I just posted? It would be very helpful to know whether this problem only occurs on my system or whether it is a general problem. Thanks.
    Last edited by Dorfmeister; 2010-06-11 at 22:41.

  7. #7
    Nokia Developer Moderator
    Join Date
    Oct 2009
    Posts
    4,326

    Re: OpenCV in Qt example

    This link leads to file not found
    http://www.zshare.net/download/771049800b033e35/
    But I see a lot of problems in .pro file, which was posted there. There is no need to INCLUDEPATH and LIBS directly as it may cause a problem.
    It's aslo not clear why mobility is semi-configured there.

  8. #8
    Nokia Developer Moderator
    Join Date
    Oct 2009
    Posts
    4,326

    Re: OpenCV in Qt example

    I've modified packaging a bit and this version compiled for me without any problems.
    http://www.mediafire.com/file/mnttid...nGL_V1.tar.bz2

  9. #9
    Registered User
    Join Date
    Jun 2010
    Posts
    36

    Re: OpenCV in Qt example

    Hi Daniil,

    thanks for your suggestion. My problem, however, is exclusively OpenCV related: If I take your clean project and add
    Code:
    #include "opencv/cv.h"
    to glwidget.cpp as well as \ opencv to PKGCONFIG in the .pro file I again have the same problem: It doesn't compile in QtCreator, but if I run
    Code:
    qmake DistanceQT.pro
    make
    manually in scratchbox it works just fine.

    Any ideas?


    Best regards,
    Dorfmeister

  10. #10
    Nokia Developer Moderator
    Join Date
    Mar 2009
    Posts
    1,024

    Re: OpenCV in Qt example

    Did you check the build options and the target?

  11. #11
    Registered User
    Join Date
    Feb 2010
    Posts
    17

    Re: OpenCV in Qt example

    Nokia Qt SDK can not use the library in scratchbox. You need to install those library to Nokia Qt SDK by yourself. I have tried to search document on web , but seems that nobody talk about this before. Therefore , I just extract those .deb to Nokia Qt Sdk. And it works.

    e.g extract to NokiaQtSDK/Maemo/4.6.2/sysroot/fremantle-arm-sysroot-1014-slim

    However, as OpenCV package depends on too many package , it need around 10 packages , and you need to fix the symbolic link.

    Although I have made it work , it could build my app within Nokia Qt SDK. Finally , I have given up this approach as the final package depends on packages from extra-devel. It is quite troublesome for user. Now , I just build a static OpenCV that do not require ffmpeg. (p.s If you need to process video stuff , you still need to build with ffmpeg)

  12. #12
    Registered User
    Join Date
    Jun 2010
    Posts
    36

    Re: OpenCV in Qt example

    Thank you for this tip. Anything the Nokia guys have to say about this? Should we file a bug report about it? I guess I'll ditch QtCreator for now and simply compile my stuff manually. OpenCV is not properly supported and on device debugging with MADDE seems to have problems with camera applications as well. I'd really like Nokia to provide one functioning main way to develop Maemo applications. To have all those options is nice, but everywhere I go it seems like a construction side to me. Hopefully, the situation will improve with Meego, once the SDK has gold status.

  13. #13
    Nokia Developer Moderator
    Join Date
    Oct 2009
    Posts
    4,326

    Re: OpenCV in Qt example

    Quote Originally Posted by Dorfmeister View Post
    Thank you for this tip. Anything the Nokia guys have to say about this? Should we file a bug report about it? I guess I'll ditch QtCreator for now and simply compile my stuff manually. OpenCV is not properly supported and on device debugging with MADDE seems to have problems with camera applications as well. I'd really like Nokia to provide one functioning main way to develop Maemo applications. To have all those options is nice, but everywhere I go it seems like a construction side to me. Hopefully, the situation will improve with Meego, once the SDK has gold status.
    Nokia Qt SDK was made for Qt beginners and is not extendible. If you smart enough to be interested in OpenCV, then you are using scratchbox.

  14. #14
    Regular Contributor
    Join Date
    Nov 2009
    Posts
    83

    Re: OpenCV in Qt example

    Quote Originally Posted by divanov View Post
    I've modified packaging a bit and this version compiled for me without any problems.
    http://www.mediafire.com/file/mnttid...nGL_V1.tar.bz2
    Hi Daniil,

    When I complied the project, I got

    glwidget.cpp:216: error: 'glVertexAttribPointer' was not declared in this scope
    glwidget.cpp:217: error: 'glEnableVertexAttribArray' was not declared in this scope
    glwidget.cpp:221: error: 'glDisableVertexAttribArray' was not declared in this scope

    It seems that the debugger cant find the OpenGL ES 2.0 function.

    Even though I added

    LIBS += -lGLESv2 -lQtOpenGL

    into the .pro, it doesn't work.

    What might be the problem?

  15. #15
    Nokia Developer Moderator
    Join Date
    Oct 2009
    Posts
    4,326

    Re: OpenCV in Qt example

    Where did you compile it?

Page 1 of 2 12 LastLast

Similar Threads

  1. Replies: 18
    Last Post: 2011-08-17, 13:30
  2. Opencv 2 j2me
    By cristiano.olifer in forum Mobile Java General
    Replies: 2
    Last Post: 2011-03-14, 20:05
  3. How to use OpenCV for Maemo5 app?
    By pta0007 in forum Nokia N9
    Replies: 18
    Last Post: 2010-03-10, 21:23
  4. How to Run the Qt example ?
    By qwakaw in forum Symbian Tools & SDKs
    Replies: 1
    Last Post: 2008-12-02, 12:08
  5. Porting openCV library to Symbian
    By berny_ in forum Symbian C++
    Replies: 2
    Last Post: 2007-09-18, 14:04

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •