Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Installation and Deployment
  4. Machine Learning Library OpenCV
Forum Updated to NodeBB v4.3 + New Features

Machine Learning Library OpenCV

Scheduled Pinned Locked Moved Installation and Deployment
13 Posts 2 Posters 8.2k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N Offline
    N Offline
    nackasha
    wrote on last edited by
    #1

    i've tried to compile the CvEM example of the documentation (http://opencv.willowgarage.com/wiki/MachineLearning#Expectation-Maximization). i've set the library search path to opencv\lib and also the include path. i inlcude the -lml machine learning library however i got the following error:

    undefined reference to `CvEM::CvEM()'

    // CvEM em_model; CvEMParams params;

    if i comment CvEM em_model the code compiles - CvEMParams doesn't result in an error. so i think that i didn't have problems with the include paths!? does anyone know how to solve this problem? thank you in advance

    Also if i run the code in Visual Studio, it runs perfectly. best regards

    1 Reply Last reply
    0
    • N Offline
      N Offline
      nackasha
      wrote on last edited by
      #2

      Here what i have in the .pro

      INCLUDEPATH += "C:/OpenCV2.1/include/opencv"

      LIBS += -L"C:/OpenCV2.1/bin" -lcv210 -lcxcore210 -lcvaux210 -lhighgui210 -lml210 -lcxts210
      -lnetapi32

      1 Reply Last reply
      0
      • C Offline
        C Offline
        Chris H
        wrote on last edited by
        #3

        I gather that the code actually compiles fine, but fails at the linking stage? As you mention, that implies that your INCLUDE path is fine (especially since it's correctly finding the definition of the CvEMParams struct). Can you paste in the actual linker command that is failing?

        1 Reply Last reply
        0
        • N Offline
          N Offline
          nackasha
          wrote on last edited by
          #4

          Thank you Chris, here is the compilation output.
          @
          Running build steps for project Check...
          Configuration unchanged, skipping qmake step.
          Starting: "C:\QtSDK\mingw\bin\mingw32-make.exe"
          C:/QtSDK/mingw/bin/mingw32-make -f Makefile.Debug
          mingw32-make[1]: Entering directory C:/Documents and Settings/Bush/Check-build-desktop-Qt_4_7_4_for_Desktop_-_MinGW_4_4__Qt_SDK__Debug' g++ -c -g -frtti -fexceptions -mthreads -Wall -DUNICODE -DQT_LARGEFILE_SUPPORT -DQT_DLL -DQT_GUI_LIB -DQT_CORE_LIB -DQT_HAVE_MMX -DQT_HAVE_3DNOW -DQT_HAVE_SSE -DQT_HAVE_MMXEXT -DQT_HAVE_SSE2 -DQT_THREAD_SUPPORT -DQT_NEEDS_QMAIN -I"..\..\..\QtSDK\Desktop\Qt\4.7.4\mingw\include\QtCore" -I"..\..\..\QtSDK\Desktop\Qt\4.7.4\mingw\include\QtGui" -I"..\..\..\QtSDK\Desktop\Qt\4.7.4\mingw\include" -I"..\..\..\OpenCV2.1\include" -I"..\..\..\OpenCV2.1\include\opencv" -I"..\..\..\QtSDK\Desktop\Qt\4.7.4\mingw\include\ActiveQt" -I"debug" -I"." -I"..\Check" -I"." -I"..\..\..\QtSDK\Desktop\Qt\4.7.4\mingw\mkspecs\win32-g++" -o debug\mainwindow.o ..\Check\mainwindow.cpp g++ -mthreads -Wl,-subsystem,windows -o debug\Check.exe debug/main.o debug/mainwindow.o debug/moc_mainwindow.o -L"c:\QtSDK\Desktop\Qt\4.7.4\mingw\lib" -lmingw32 -lqtmaind -LC:/OpenCV2.1/bin -lcv210 -lcxcore210 -lcvaux210 -lhighgui210 -lml210 -lcxts210 -lnetapi32 -lQtGuid4 -lQtCored4 -LC:\OpenSSL-Win32_full\lib debug/mainwindow.o: In function MainWindow':
          C:\Documents and Settings\Bush\Check-build-desktop-Qt_4_7_4_for_Desktop_-MinGW_4_4__Qt_SDK__Debug/../Check/mainwindow.cpp:23: undefined reference to CvEM::CvEM()' C:\Documents and Settings\Bush\Check-build-desktop-Qt_4_7_4_for_Desktop_-_MinGW_4_4__Qt_SDK__Debug/../Check/mainwindow.cpp:49: undefined reference to CvEM::train(CvMat const*, CvMat const*, CvEMParams, CvMat*)'
          C:\Documents and Settings\Bush\Check-build-desktop-Qt_4_7_4_for_Desktop
          -MinGW_4_4__Qt_SDK__Debug/../Check/mainwindow.cpp:59: undefined reference to CvEM::predict(CvMat const*, CvMat*) const' C:\Documents and Settings\Bush\Check-build-desktop-Qt_4_7_4_for_Desktop_-_MinGW_4_4__Qt_SDK__Debug/../Check/mainwindow.cpp:76: undefined reference to CvEM::~CvEM()'
          C:\Documents and Settings\Bush\Check-build-desktop-Qt_4_7_4_for_Desktop
          -MinGW_4_4__Qt_SDK__Debug/../Check/mainwindow.cpp:76: undefined reference to CvEM::~CvEM()' C:\Documents and Settings\Bush\Check-build-desktop-Qt_4_7_4_for_Desktop_-_MinGW_4_4__Qt_SDK__Debug/../Check/mainwindow.cpp:23: undefined reference to CvEM::CvEM()'
          C:\Documents and Settings\Bush\Check-build-desktop-Qt_4_7_4_for_Desktop
          -MinGW_4_4__Qt_SDK__Debug/../Check/mainwindow.cpp:49: undefined reference to CvEM::train(CvMat const*, CvMat const*, CvEMParams, CvMat*)' C:\Documents and Settings\Bush\Check-build-desktop-Qt_4_7_4_for_Desktop_-_MinGW_4_4__Qt_SDK__Debug/../Check/mainwindow.cpp:59: undefined reference to CvEM::predict(CvMat const*, CvMat*) const'
          C:\Documents and Settings\Bush\Check-build-desktop-Qt_4_7_4_for_Desktop
          -MinGW_4_4__Qt_SDK__Debug/../Check/mainwindow.cpp:76: undefined reference to CvEM::~CvEM()' mingw32-make[1]: Leaving directory C:/Documents and Settings/Bush/Check-build-desktop-Qt_4_7_4_for_Desktop-MinGW_4_4__Qt_SDK__Debug'
          C:\Documents and Settings\Bush\Check-build-desktop-Qt_4_7_4_for_Desktop
          -_MinGW_4_4__Qt_SDK__Debug/../Check/mainwindow.cpp:76: undefined reference to `CvEM::~CvEM()'
          collect2: ld returned 1 exit status
          mingw32-make[1]: *** [debug\Check.exe] Error 1
          mingw32-make: *** [debug] Error 2
          The process "C:\QtSDK\mingw\bin\mingw32-make.exe" exited with code 2.
          Error while building project Check (target: Desktop)
          When executing build step 'Make' @

          1 Reply Last reply
          0
          • C Offline
            C Offline
            Chris H
            wrote on last edited by
            #5

            I see you are telling it to look for OpenCV in "C:/OpenCV2.1/bin" -- do you mean to be using "C:/OpenCV2.1/lib"?

            1 Reply Last reply
            0
            • N Offline
              N Offline
              nackasha
              wrote on last edited by
              #6

              I haven't noticed that, but for some bizarre reason it runs perfectly with the above syntax. I changed to /lib and same problem still persist. Here is the new compilation code

              @Running build steps for project Check...
              Configuration unchanged, skipping qmake step.
              Starting: "C:\QtSDK\mingw\bin\mingw32-make.exe"
              C:/QtSDK/mingw/bin/mingw32-make -f Makefile.Debug
              mingw32-make[1]: Entering directory C:/Documents and Settings/Bush/Check-build-desktop-Qt_4_7_4_for_Desktop_-_MinGW_4_4__Qt_SDK__Debug' c:\QtSDK\Desktop\Qt\4.7.4\mingw\bin\uic.exe ..\Check\mainwindow.ui -o ui_mainwindow.h g++ -c -g -frtti -fexceptions -mthreads -Wall -DUNICODE -DQT_LARGEFILE_SUPPORT -DQT_DLL -DQT_GUI_LIB -DQT_CORE_LIB -DQT_HAVE_MMX -DQT_HAVE_3DNOW -DQT_HAVE_SSE -DQT_HAVE_MMXEXT -DQT_HAVE_SSE2 -DQT_THREAD_SUPPORT -DQT_NEEDS_QMAIN -I"..\..\..\QtSDK\Desktop\Qt\4.7.4\mingw\include\QtCore" -I"..\..\..\QtSDK\Desktop\Qt\4.7.4\mingw\include\QtGui" -I"..\..\..\QtSDK\Desktop\Qt\4.7.4\mingw\include" -I"..\..\..\OpenCV2.1\include" -I"..\..\..\OpenCV2.1\include\opencv" -I"..\..\..\QtSDK\Desktop\Qt\4.7.4\mingw\include\ActiveQt" -I"debug" -I"." -I"..\Check" -I"." -I"..\..\..\QtSDK\Desktop\Qt\4.7.4\mingw\mkspecs\win32-g++" -o debug\main.o ..\Check\main.cpp g++ -c -g -frtti -fexceptions -mthreads -Wall -DUNICODE -DQT_LARGEFILE_SUPPORT -DQT_DLL -DQT_GUI_LIB -DQT_CORE_LIB -DQT_HAVE_MMX -DQT_HAVE_3DNOW -DQT_HAVE_SSE -DQT_HAVE_MMXEXT -DQT_HAVE_SSE2 -DQT_THREAD_SUPPORT -DQT_NEEDS_QMAIN -I"..\..\..\QtSDK\Desktop\Qt\4.7.4\mingw\include\QtCore" -I"..\..\..\QtSDK\Desktop\Qt\4.7.4\mingw\include\QtGui" -I"..\..\..\QtSDK\Desktop\Qt\4.7.4\mingw\include" -I"..\..\..\OpenCV2.1\include" -I"..\..\..\OpenCV2.1\include\opencv" -I"..\..\..\QtSDK\Desktop\Qt\4.7.4\mingw\include\ActiveQt" -I"debug" -I"." -I"..\Check" -I"." -I"..\..\..\QtSDK\Desktop\Qt\4.7.4\mingw\mkspecs\win32-g++" -o debug\mainwindow.o ..\Check\mainwindow.cpp C:\QtSDK\Desktop\Qt\4.7.4\mingw\bin\moc.exe -DUNICODE -DQT_LARGEFILE_SUPPORT -DQT_DLL -DQT_GUI_LIB -DQT_CORE_LIB -DQT_HAVE_MMX -DQT_HAVE_3DNOW -DQT_HAVE_SSE -DQT_HAVE_MMXEXT -DQT_HAVE_SSE2 -DQT_THREAD_SUPPORT -DQT_NEEDS_QMAIN -I"..\..\..\QtSDK\Desktop\Qt\4.7.4\mingw\include\QtCore" -I"..\..\..\QtSDK\Desktop\Qt\4.7.4\mingw\include\QtGui" -I"..\..\..\QtSDK\Desktop\Qt\4.7.4\mingw\include" -I"..\..\..\OpenCV2.1\include" -I"..\..\..\OpenCV2.1\include\opencv" -I"..\..\..\QtSDK\Desktop\Qt\4.7.4\mingw\include\ActiveQt" -I"debug" -I"." -I"..\Check" -I"." -I"..\..\..\QtSDK\Desktop\Qt\4.7.4\mingw\mkspecs\win32-g++" -D__GNUC__ -DWIN32 ..\Check\mainwindow.h -o debug\moc_mainwindow.cpp g++ -c -g -frtti -fexceptions -mthreads -Wall -DUNICODE -DQT_LARGEFILE_SUPPORT -DQT_DLL -DQT_GUI_LIB -DQT_CORE_LIB -DQT_HAVE_MMX -DQT_HAVE_3DNOW -DQT_HAVE_SSE -DQT_HAVE_MMXEXT -DQT_HAVE_SSE2 -DQT_THREAD_SUPPORT -DQT_NEEDS_QMAIN -I"..\..\..\QtSDK\Desktop\Qt\4.7.4\mingw\include\QtCore" -I"..\..\..\QtSDK\Desktop\Qt\4.7.4\mingw\include\QtGui" -I"..\..\..\QtSDK\Desktop\Qt\4.7.4\mingw\include" -I"..\..\..\OpenCV2.1\include" -I"..\..\..\OpenCV2.1\include\opencv" -I"..\..\..\QtSDK\Desktop\Qt\4.7.4\mingw\include\ActiveQt" -I"debug" -I"." -I"..\Check" -I"." -I"..\..\..\QtSDK\Desktop\Qt\4.7.4\mingw\mkspecs\win32-g++" -o debug\moc_mainwindow.o debug\moc_mainwindow.cpp g++ -mthreads -Wl,-subsystem,windows -o debug\Check.exe debug/main.o debug/mainwindow.o debug/moc_mainwindow.o -L"c:\QtSDK\Desktop\Qt\4.7.4\mingw\lib" -lmingw32 -lqtmaind -LC:/OpenCV2.1/lib -lcv210 -lcxcore210 -lcvaux210 -lhighgui210 -lml210 -lcxts210 -lnetapi32 -lQtGuid4 -lQtCored4 -LC:\OpenSSL-Win32_full\lib mingw32-make[1]: Leaving directory C:/Documents and Settings/Bush/Check-build-desktop-Qt_4_7_4_for_Desktop_-MinGW_4_4__Qt_SDK__Debug'
              debug/mainwindow.o: In function MainWindow': C:\Documents and Settings\Bush\Check-build-desktop-Qt_4_7_4_for_Desktop_-_MinGW_4_4__Qt_SDK__Debug/../Check/mainwindow.cpp:23: undefined reference to CvEM::CvEM()'
              C:\Documents and Settings\Bush\Check-build-desktop-Qt_4_7_4_for_Desktop
              -MinGW_4_4__Qt_SDK__Debug/../Check/mainwindow.cpp:76: undefined reference to CvEM::~CvEM()' C:\Documents and Settings\Bush\Check-build-desktop-Qt_4_7_4_for_Desktop_-_MinGW_4_4__Qt_SDK__Debug/../Check/mainwindow.cpp:76: undefined reference to CvEM::~CvEM()'
              C:\Documents and Settings\Bush\Check-build-desktop-Qt_4_7_4_for_Desktop
              -MinGW_4_4__Qt_SDK__Debug/../Check/mainwindow.cpp:23: undefined reference to CvEM::CvEM()' C:\Documents and Settings\Bush\Check-build-desktop-Qt_4_7_4_for_Desktop_-_MinGW_4_4__Qt_SDK__Debug/../Check/mainwindow.cpp:76: undefined reference to CvEM::~CvEM()'
              C:\Documents and Settings\Bush\Check-build-desktop-Qt_4_7_4_for_Desktop
              -_MinGW_4_4__Qt_SDK__Debug/../Check/mainwindow.cpp:76: undefined reference to `CvEM::~CvEM()'
              collect2: ld returned 1 exit status
              mingw32-make[1]: *** [debug\Check.exe] Error 1
              mingw32-make: *** [debug] Error 2
              The process "C:\QtSDK\mingw\bin\mingw32-make.exe" exited with code 2.
              Error while building project Check (target: Desktop)
              When executing build step 'Make'@

              1 Reply Last reply
              0
              • C Offline
                C Offline
                Chris H
                wrote on last edited by
                #7

                Ordinarily the linker will tell you if it can't find a library, so presumably it is in fact finding cv210 someplace, but wherever it is, it does not actually contain the definition of the CvEM class. Did you compile it yourself, or download a binary? I'm not sure how to examine the contents of a library on windows, but on Linux and Mac the "nm" command will list all the symbols defined in there: you could grep that list for CvEM to make sure it's in there.

                1 Reply Last reply
                0
                • N Offline
                  N Offline
                  nackasha
                  wrote on last edited by
                  #8

                  I downloaded it and didn't compile the library myself. The weird thing, if i copy/paste my code on visual studio, it runs perfectly without any problems which indicates the CvEM is there.

                  Is it possible that ml210.lib compiled file is compatible with VS2010 and not with Qt, so maybe i need to compile the file myself ? (sorry for the noob question, i am not really experienced there)

                  1 Reply Last reply
                  0
                  • N Offline
                    N Offline
                    nackasha
                    wrote on last edited by
                    #9

                    Chris, I can't read/understand the compilation report i posted. Does it say that the library is linked properly or it doesn't mention such thing ? Many thanks

                    1 Reply Last reply
                    0
                    • C Offline
                      C Offline
                      Chris H
                      wrote on last edited by
                      #10

                      It doesn't say anything about the library: if it could not find the library I'd expect to see "library not found for -lcv210" or some such. When you compile it with VS, you are telling it to find this library in the same place it's looking here?

                      1 Reply Last reply
                      0
                      • N Offline
                        N Offline
                        nackasha
                        wrote on last edited by
                        #11

                        Yes Sir. And the same code just compile right away.

                        1 Reply Last reply
                        0
                        • C Offline
                          C Offline
                          Chris H
                          wrote on last edited by
                          #12

                          I'm afraid I'm not familiar enough with Windows libraries to help you much, then. Is there a difference between a library for use with VS2010 and one for use with gcc/mingw? If so then you should just need to compile a new version of OpenCV.

                          1 Reply Last reply
                          0
                          • N Offline
                            N Offline
                            nackasha
                            wrote on last edited by
                            #13

                            Hello Chris,

                            I finally solved the issue. I just recompiled opencv with mingw (which qt uses) . Despite there were some libraries that worked with the cmake for vs2010 but apparently the one i wanted didn't.

                            Hope the solution help some other dude.

                            Cheers

                            1 Reply Last reply
                            0

                            • Login

                            • Login or register to search.
                            • First post
                              Last post
                            0
                            • Categories
                            • Recent
                            • Tags
                            • Popular
                            • Users
                            • Groups
                            • Search
                            • Get Qt Extensions
                            • Unsolved