Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Using opencv3.1 with Qt5.5 in Windows 10

Using opencv3.1 with Qt5.5 in Windows 10

Scheduled Pinned Locked Moved Solved General and Desktop
20 Posts 6 Posters 13.8k Views
  • 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.
  • jsulmJ jsulm

    @brotify This should be changed:

    LIBS += -LC:\\opencv2\\release\\install\\x86\\mingw\\bin\
        libopencv_core310 \
        libopencv_highgui310 \
        libopencv_imgproc310 \
        libopencv_features2d310 \
        libopencv_calib3d310 \
    

    to:

    LIBS += -LC:/opencv2/release/install/x86/mingw/bin\
        -lopencv_core310 \
        -lopencv_highgui310 \
        -lopencv_imgproc310 \
        -lopencv_features2d310 \
        -lopencv_calib3d310 \
    

    In pro files you should use forward slashes in paths and not back slashes (even on Windows).
    Are the libraries directly in C:\opencv2\release\install\x86\mingw\bin?

    brotifyB Offline
    brotifyB Offline
    brotify
    wrote on last edited by
    #8

    @jsulm

    INCLUDEPATH += C:\opencv2\release\install\include
    LIBS += -LC:/opencv2/release/install/x86/mingw/bin\
        -lopencv_core310 \
        -lopencv_highgui310 \
        -lopencv_imgproc310 \
        -lopencv_features2d310 \
        -lopencv_calib3d310 \
    
    INCLUDEPATH += C:/opencv2/release/install/include
    LIBS += -LC:/opencv2/release/install/x86/mingw/bin\
        -lopencv_core310 \
        -lopencv_highgui310 \
        -lopencv_imgproc310 \
        -lopencv_features2d310 \
        -lopencv_calib3d310 \
    

    I tried both of them but this time I get this error:
    LNK1104: cannot open file 'opencv_core310.lib'

    Let me show the screenshot of what is inside "C:\opencv2\release\install\x86\mingw\bin"
    http://i.hizliresim.com/0nkDAY.png

    jsulmJ 1 Reply Last reply
    0
    • mrdebugM mrdebug

      Hi. You have to build OpenCV with MinGW only if you want to use Qt on Windows builded with MinGW.
      The OpenCV package already has the vs libraries.
      Anyway which are your cmake switches?

      brotifyB Offline
      brotifyB Offline
      brotify
      wrote on last edited by brotify
      #9

      @mrdebug
      I have to say that I am not experienced developer. Therefore I did not fully understand what are saying. I used Mingw because in the tutorials thay were using Cmake and Mingw. If there are another method to use opencv in Qt project, it will be good to me to know.

      1 Reply Last reply
      0
      • mrdebugM Offline
        mrdebugM Offline
        mrdebug
        wrote on last edited by
        #10

        Sorry but all the tutorials that I have tried in order to to use OpenCV in all platforms are not perfectly usable. To setup OpenCV with Qt is more difficult than to write a OpenCV program.
        To start: what qt version are you using? The Qt version based on mingw32 or the version based on vc?

        Need programmers to hire?
        www.labcsp.com
        www.denisgottardello.it
        GMT+1
        Skype: mrdebug

        brotifyB 1 Reply Last reply
        0
        • brotifyB brotify

          @jsulm

          INCLUDEPATH += C:\opencv2\release\install\include
          LIBS += -LC:/opencv2/release/install/x86/mingw/bin\
              -lopencv_core310 \
              -lopencv_highgui310 \
              -lopencv_imgproc310 \
              -lopencv_features2d310 \
              -lopencv_calib3d310 \
          
          INCLUDEPATH += C:/opencv2/release/install/include
          LIBS += -LC:/opencv2/release/install/x86/mingw/bin\
              -lopencv_core310 \
              -lopencv_highgui310 \
              -lopencv_imgproc310 \
              -lopencv_features2d310 \
              -lopencv_calib3d310 \
          

          I tried both of them but this time I get this error:
          LNK1104: cannot open file 'opencv_core310.lib'

          Let me show the screenshot of what is inside "C:\opencv2\release\install\x86\mingw\bin"
          http://i.hizliresim.com/0nkDAY.png

          jsulmJ Offline
          jsulmJ Offline
          jsulm
          Lifetime Qt Champion
          wrote on last edited by
          #11

          @brotify Can you search for opencv_core310.lib (and other needed *.lib files) in the installation directory?

          https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0
          • A Offline
            A Offline
            asanka424
            wrote on last edited by
            #12

            It seems like you are trying to use OpenCV built using MinGW with Qt built with Visual Studio. There are two things you can do.

            1. use OpenCV pre built. Which is in your build folder of OpenCV downloaded zip

            2. change the kit in your Qt Creator to use MinGW build of Qt.

            Hope this helps

            brotifyB 1 Reply Last reply
            0
            • A asanka424

              It seems like you are trying to use OpenCV built using MinGW with Qt built with Visual Studio. There are two things you can do.

              1. use OpenCV pre built. Which is in your build folder of OpenCV downloaded zip

              2. change the kit in your Qt Creator to use MinGW build of Qt.

              Hope this helps

              brotifyB Offline
              brotifyB Offline
              brotify
              wrote on last edited by brotify
              #13

              Please note that I have solved my problem but I will not delete this post because it may help other people.
              @asanka424
              Thanks, I selected Mingw32 as the kit and it worked but this time I get a different error. I tried a simple opencv program which shows the image however it gives this error:
              undefined reference to `cv::imread(cv::String const&, int)'

              Here is my code,

              #include <opencv2/core/core.hpp>
              #include <opencv2/highgui/highgui.hpp>
              #include <iostream>
              
              using namespace cv;
              using namespace std;
              
              int main(  )
              {
              
              
                  Mat image;
                  image = imread("img.jpg", CV_LOAD_IMAGE_COLOR);   
              
                  if(! image.data )                       
                  {
                      cout <<  "Could not open or find the image" << std::endl ;
                      return -1;
                  }
              
                  namedWindow( "Display window", WINDOW_AUTOSIZE );// Create a window for display.
                  imshow( "Display window", image );             
              
                  waitKey(0);                                      
                  return 0;
              }
              
              

              and here is my .pro file

              QT += core
              QT -= gui
              
              CONFIG += c++11
              
              TARGET = untitled
              CONFIG += console
              CONFIG -= app_bundle
              
              INCLUDEPATH += C:/opencv2/release/install/include
              LIBS += -LC:/opencv2/release/install/x86/mingw/bin\
                  -lopencv_core310 \
                  -lopencv_highgui310 \
                  -lopencv_imgproc310 \
                  -lopencv_features2d310 \
                  -lopencv_calib3d310 \
              
              
              TEMPLATE = app
              
              SOURCES += main.cpp
              

              And lastly can you show me how to use first method that is using opencv pre-built?

              1 Reply Last reply
              0
              • mrdebugM mrdebug

                Sorry but all the tutorials that I have tried in order to to use OpenCV in all platforms are not perfectly usable. To setup OpenCV with Qt is more difficult than to write a OpenCV program.
                To start: what qt version are you using? The Qt version based on mingw32 or the version based on vc?

                brotifyB Offline
                brotifyB Offline
                brotify
                wrote on last edited by brotify
                #14

                @mrdebug
                I was not aware of that Qt has two different versions. So far I was using VC. Now I am using MinGw and it seems that the problem was this. Yet I have another problem which I posted before this post.

                1 Reply Last reply
                0
                • brotifyB Offline
                  brotifyB Offline
                  brotify
                  wrote on last edited by brotify
                  #15

                  Ok, I want to thanks all of you who tried to help me. Hopefully I solved my problem. I solved the last problem by adding to .pro file

                  LIBS += "C:\opencv2\release\lib\libopencv_imgcodecs310.dll.a"
                  
                  1 Reply Last reply
                  0
                  • B Offline
                    B Offline
                    beginMyCoding
                    wrote on last edited by
                    #16

                    Hello
                    I am also in a same situation, i did not find any solution till now.
                    I am using Qt creator 5.5 with mingw492_32 and openCv 3.10 with VC.
                    When i try to write a small code to read the image matrix using cv::imread() it gives me error.

                    error: undefined reference to `cv::imread(cv::String const&, int)
                    

                    this is my

                    test.pro

                    QT       += core gui
                    
                    greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
                    
                    TARGET = Test
                    TEMPLATE = app
                    
                    
                    SOURCES += main.cpp\
                            mainwindow.cpp
                    
                    HEADERS  += mainwindow.h
                    
                    FORMS    += mainwindow.ui
                    
                    INCLUDEPATH += LC:\opencv\build\include
                    
                            LIBS += C:\opencv\build\x64\vc14\lib\opencv_world310.lib \
                                    C:\opencv\build\bin\opencv_ffmpeg310.dll
                    

                    i have only one library file in the openCV folder
                    Do you have any idea what i am suppose to do?

                    1 Reply Last reply
                    0
                    • mrdebugM Offline
                      mrdebugM Offline
                      mrdebug
                      wrote on last edited by
                      #17

                      Hi.
                      You can't use the vc libraries of OpenCV with Qt built with Mingw. If you want to use Qt with mingw you have to build OpenCV with Mingw.
                      I confirm Qt 5.5 works perfectly with OpenCV 3.
                      http://www.denisgottardello.it/ComputerVisionStudio/index.php

                      Need programmers to hire?
                      www.labcsp.com
                      www.denisgottardello.it
                      GMT+1
                      Skype: mrdebug

                      1 Reply Last reply
                      0
                      • B Offline
                        B Offline
                        beginMyCoding
                        wrote on last edited by
                        #18

                        Is there any link which explains perfect installation of OpenCV 3 and Qt5.5?

                        1 Reply Last reply
                        0
                        • mrdebugM Offline
                          mrdebugM Offline
                          mrdebug
                          wrote on last edited by
                          #19

                          These lines of code work perfectly with Qt 5.5.0 and OpenCV 3.0
                          set PATH=%PATH%;C:\Qt\Qt5.5.0\Tools\mingw492_32\bin;C:\Program Files (x86)\CMake 2.8\bin
                          cmake -G "MinGW Makefiles" -DWITH_FFMPEG=OFF -DCMAKE_BUILD_TYPE=RELEASE -DBUILD_opencv_videoio=ON -DWITH_IPP=OFF -DWITH_OPENCL=OFF -DWITH_JASPER=OFF -DWITH_OPENEXR=OFF -DBUILD_SHARED_LIBS=OFF -DBUILD_TESTS=OFF -DBUILD_PERF_TESTS=OFF -DOPENCV_EXTRA_MODULES_PATH=modules/opencv_contrib-master/modules .

                          mingw32-make -j 4

                          I have only some problems with webcams in some 64 bit machines.

                          Another hard problem is to setup the pro file. You have to include the libraries in a particular order (depends from your program). Some libraries can be included more than one time.
                          This solution sounds to be very strange but I assure, to have OpenCV working I have spent a lot of time.

                          If you need professional support please send me an email at info@denisgottardello.it

                          Need programmers to hire?
                          www.labcsp.com
                          www.denisgottardello.it
                          GMT+1
                          Skype: mrdebug

                          B 1 Reply Last reply
                          0
                          • mrdebugM mrdebug

                            These lines of code work perfectly with Qt 5.5.0 and OpenCV 3.0
                            set PATH=%PATH%;C:\Qt\Qt5.5.0\Tools\mingw492_32\bin;C:\Program Files (x86)\CMake 2.8\bin
                            cmake -G "MinGW Makefiles" -DWITH_FFMPEG=OFF -DCMAKE_BUILD_TYPE=RELEASE -DBUILD_opencv_videoio=ON -DWITH_IPP=OFF -DWITH_OPENCL=OFF -DWITH_JASPER=OFF -DWITH_OPENEXR=OFF -DBUILD_SHARED_LIBS=OFF -DBUILD_TESTS=OFF -DBUILD_PERF_TESTS=OFF -DOPENCV_EXTRA_MODULES_PATH=modules/opencv_contrib-master/modules .

                            mingw32-make -j 4

                            I have only some problems with webcams in some 64 bit machines.

                            Another hard problem is to setup the pro file. You have to include the libraries in a particular order (depends from your program). Some libraries can be included more than one time.
                            This solution sounds to be very strange but I assure, to have OpenCV working I have spent a lot of time.

                            If you need professional support please send me an email at info@denisgottardello.it

                            B Offline
                            B Offline
                            beginMyCoding
                            wrote on last edited by
                            #20

                            @mrdebug
                            I seriously did not understand from 3rd line (cmake).

                            I set the paths of Qt and CMake
                            Below are my paths
                            C:\Qt\5.5\mingw492_32\bin
                            C:\CMake\bin

                            I don't understand what I have to do in CMake?
                            Can you say me any step by step procedure or any other way?

                            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