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. opencv error: undefined reference to `cv::VideoCapture::VideoCapture()'
Forum Updated to NodeBB v4.3 + New Features

opencv error: undefined reference to `cv::VideoCapture::VideoCapture()'

Scheduled Pinned Locked Moved Solved General and Desktop
8 Posts 5 Posters 15.7k 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.
  • _ Offline
    _ Offline
    _hunter
    wrote on last edited by
    #1

    I try to use opencv3.2 with qt5.7,but I always get those erros:
    /home/hunter/cameraTt/main.cpp:17: error: undefined reference to cv::VideoCapture::open(int)' /home/hunter/cameraTt/main.cpp:18: error: undefined reference to cv::VideoCapture::isOpened() const'
    /home/hunter/cameraTt/main.cpp:20: error: undefined reference to cv::VideoCapture::get(int) const' /home/hunter/cameraTt/main.cpp:22: error: undefined reference to cv::VideoCapture::operator>>(cv::Mat&)'
    /home/hunter/cameraTt/main.cpp:24: error: undefined reference to `cv::VideoWriter::VideoWriter()'
    ....
    .pro

    INCLUDEPATH += /usr/local/include/opencv2

    LIBS += /usr/local/lib/libopencv_shape.so \

          /usr/local/lib/libopencv_videoio.so \
    

    main.cpp

    #include "mainwindow.h"
    #include <QApplication>
    //#include<cv.h>
    #include<QTimer>
    #include<QPixmap>
    #include <opencv2/core/core.hpp>
    #include <opencv2/highgui/highgui.hpp>
    #include <opencv2/imgproc/imgproc.hpp>
    //using namespace cv;
    int main(int argc, char *argv[])
    {
    QApplication a(argc, argv);
    MainWindow w;
    w.show();

    cv::VideoCapture m_cap;
    m_cap.open(0);
    assert(m_cap.isOpened());
    
    int rate = m_cap.get(CV_CAP_PROP_FPS);
    cv::Mat frame;
    m_cap>>frame;
    
    cv::VideoWriter videowriter;
    videowriter.open("test.wmv",CV_FOURCC('W','M','V','2'),30,cv::Size(frame.cols,frame.rows));
    assert(videowriter.isOpened());
    
    char keycode;
    while ((keycode = cvWaitKey(30))) {
        if (keycode == 27) {
            break;
        }
        if (!m_cap.grab()) {
            break;
        }
        m_cap>>frame;
        videowriter<<frame;
    }
    videowriter.release();
    
    return a.exec();
    

    }

    aha_1980A 1 Reply Last reply
    0
    • _ _hunter

      I try to use opencv3.2 with qt5.7,but I always get those erros:
      /home/hunter/cameraTt/main.cpp:17: error: undefined reference to cv::VideoCapture::open(int)' /home/hunter/cameraTt/main.cpp:18: error: undefined reference to cv::VideoCapture::isOpened() const'
      /home/hunter/cameraTt/main.cpp:20: error: undefined reference to cv::VideoCapture::get(int) const' /home/hunter/cameraTt/main.cpp:22: error: undefined reference to cv::VideoCapture::operator>>(cv::Mat&)'
      /home/hunter/cameraTt/main.cpp:24: error: undefined reference to `cv::VideoWriter::VideoWriter()'
      ....
      .pro

      INCLUDEPATH += /usr/local/include/opencv2

      LIBS += /usr/local/lib/libopencv_shape.so \

            /usr/local/lib/libopencv_videoio.so \
      

      main.cpp

      #include "mainwindow.h"
      #include <QApplication>
      //#include<cv.h>
      #include<QTimer>
      #include<QPixmap>
      #include <opencv2/core/core.hpp>
      #include <opencv2/highgui/highgui.hpp>
      #include <opencv2/imgproc/imgproc.hpp>
      //using namespace cv;
      int main(int argc, char *argv[])
      {
      QApplication a(argc, argv);
      MainWindow w;
      w.show();

      cv::VideoCapture m_cap;
      m_cap.open(0);
      assert(m_cap.isOpened());
      
      int rate = m_cap.get(CV_CAP_PROP_FPS);
      cv::Mat frame;
      m_cap>>frame;
      
      cv::VideoWriter videowriter;
      videowriter.open("test.wmv",CV_FOURCC('W','M','V','2'),30,cv::Size(frame.cols,frame.rows));
      assert(videowriter.isOpened());
      
      char keycode;
      while ((keycode = cvWaitKey(30))) {
          if (keycode == 27) {
              break;
          }
          if (!m_cap.grab()) {
              break;
          }
          m_cap>>frame;
          videowriter<<frame;
      }
      videowriter.release();
      
      return a.exec();
      

      }

      aha_1980A Offline
      aha_1980A Offline
      aha_1980
      Lifetime Qt Champion
      wrote on last edited by aha_1980
      #2

      HI @_hunter,

      LIBS += /usr/local/lib/libopencv_shape.so
      /usr/local/lib/libopencv_videoio.so

      Please change the linker lines to this,

      LIBS += -L/usr/local/lib -lopencv_shape -lopencv_videoio

      and try again.

      If it does not work, please prove the linker command line from the compile log.

      Regards

      Qt has to stay free or it will die.

      _ 1 Reply Last reply
      1
      • _ Offline
        _ Offline
        _hunter
        wrote on last edited by
        #3

        @aha_1980 said in opencv error: undefined reference to `cv::VideoCapture::VideoCapture()':

        compile log

        sorry,i do not know the location of compile log.I did what you sugget and here are the new errors:
        :-1: error: main.o: undefined reference to symbol '_ZN2cv6String10deallocateEv'
        /usr/local/lib/libopencv_core.so.3.2:-1: error: error adding symbols: DSO missing from command line
        :-1: error: collect2: error: ld returned 1 exit status

        S 1 Reply Last reply
        0
        • aha_1980A aha_1980

          HI @_hunter,

          LIBS += /usr/local/lib/libopencv_shape.so
          /usr/local/lib/libopencv_videoio.so

          Please change the linker lines to this,

          LIBS += -L/usr/local/lib -lopencv_shape -lopencv_videoio

          and try again.

          If it does not work, please prove the linker command line from the compile log.

          Regards

          _ Offline
          _ Offline
          _hunter
          wrote on last edited by
          #4

          @aha_1980 thank you with your help,i solved this error

          1 Reply Last reply
          1
          • aha_1980A Offline
            aha_1980A Offline
            aha_1980
            Lifetime Qt Champion
            wrote on last edited by
            #5

            @_hunter

            Glad it worked. So please close this topic as SOLVED. Thanks.

            Qt has to stay free or it will die.

            1 Reply Last reply
            0
            • _ _hunter

              @aha_1980 said in opencv error: undefined reference to `cv::VideoCapture::VideoCapture()':

              compile log

              sorry,i do not know the location of compile log.I did what you sugget and here are the new errors:
              :-1: error: main.o: undefined reference to symbol '_ZN2cv6String10deallocateEv'
              /usr/local/lib/libopencv_core.so.3.2:-1: error: error adding symbols: DSO missing from command line
              :-1: error: collect2: error: ld returned 1 exit status

              S Offline
              S Offline
              SuganyaSP
              wrote on last edited by
              #6

              @_hunter I'm also getting the same error.. How you solved it. Can you please help me?

              jsulmJ A 2 Replies Last reply
              0
              • S SuganyaSP

                @_hunter I'm also getting the same error.. How you solved it. Can you please help me?

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

                @SuganyaSP Did you do what @aha_1980 suggested?

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

                1 Reply Last reply
                0
                • S SuganyaSP

                  @_hunter I'm also getting the same error.. How you solved it. Can you please help me?

                  A Offline
                  A Offline
                  Ahmed_Mostafa
                  wrote on last edited by
                  #8

                  @SuganyaSP i am working on ubuntu18 with qt 4.5.2 opencv4
                  solved this problem with

                  INCLUDEPATH += /usr/local/include/opencv4

                  LIBS += $(shell pkg-config opencv --libs)

                  LIBS += -L/usr/local/lib -lopencv_core -lopencv_imgcodecs -lopencv_highgui -lopencv_shape -lopencv_videoio -lopencv_imgproc

                  then make a "rebuid"

                  1 Reply Last reply
                  2

                  • Login

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