Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. Include OpenCV library into a project.
Forum Updated to NodeBB v4.3 + New Features

Include OpenCV library into a project.

Scheduled Pinned Locked Moved Unsolved Mobile and Embedded
3 Posts 2 Posters 625 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.
  • J Offline
    J Offline
    jenya7
    wrote on 1 Jul 2021, 13:28 last edited by
    #1

    I installed OpenCV

    sudo apt-get install libopencv-dev
    

    Now I open a project and in main.cpp include

     #include "opencv2/opencv.hpp"
    

    Qt sees the directory and files in it. But when I compile I get a lot of errors in the opencv library files. Why?
    May be I should include it in the *.pro file - LIB+= ????? - what should I include?

    J 1 Reply Last reply 2 Jul 2021, 04:45
    0
    • J jenya7
      1 Jul 2021, 13:28

      I installed OpenCV

      sudo apt-get install libopencv-dev
      

      Now I open a project and in main.cpp include

       #include "opencv2/opencv.hpp"
      

      Qt sees the directory and files in it. But when I compile I get a lot of errors in the opencv library files. Why?
      May be I should include it in the *.pro file - LIB+= ????? - what should I include?

      J Offline
      J Offline
      jsulm
      Lifetime Qt Champion
      wrote on 2 Jul 2021, 04:45 last edited by
      #2

      @jenya7 said in Include OpenCV library into a project.:

      May be I should include it in the *.pro file - LIB+= ?

      Yes.
      "what should I include?" - all OpenCV libs you're using.
      Which libs exactly you can deduce from the error messages and then checking OpenCV documentation.

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

      1 Reply Last reply
      1
      • J Offline
        J Offline
        jenya7
        wrote on 4 Jul 2021, 05:45 last edited by jenya7 7 May 2021, 05:20
        #3

        The errors I get

        -1: error: main.o: in function cv::String::~String()': -1: error: main.o: in function cv::String::operator=(cv::String const&)' :/usr/include/opencv2/core/cvstd.hpp:672: error: undefined reference to `cv::String::deallocate()' -1: error: collect2: error: ld returned 1 exit status
        

        What exactly I should include? In usr/include/ I see opencv2 folder with a lot of folders and files in it.

        I found the solution

        LIBS += -lopencv_core -lopencv_imgproc -lopencv_imgcodecs
        

        Now I’m facing another problem - Build is OK but when I run I get

        qt5ct: using qt5ct plugin
        GLib-GObject-WARNING **: 11:53:16.119: cannot register existing type ‘GtkWidget’
        GLib-GObject-CRITICAL **: 11:53:16.119: g_type_add_interface_static: assertion ‘G_TYPE_IS_INSTANTIATABLE (instance_type)’ failed
        GLib-GObject-WARNING **: 11:53:16.119: cannot register existing type ‘GtkBuildable’
        GLib-GObject-CRITICAL **: 11:53:16.119: g_type_interface_add_prerequisite: assertion ‘G_TYPE_IS_INTERFACE (interface_type)’ failed
        GLib-CRITICAL **: 11:53:16.119: g_once_init_leave: assertion ‘result != 0’ failed
        GLib-GObject-CRITICAL **: 11:53:16.119: g_type_add_interface_static: assertion ‘G_TYPE_IS_INSTANTIATABLE (instance_type)’ failed
        GLib-GObject-CRITICAL **: 11:53:16.119: g_type_register_static: assertion ‘parent_type > 0’ failed
        

        I found a fix
        sudo nano /etc/xdg/qt5ct/qt5ct.conf
        replace style=gtk2 with style=gtk3

        1 Reply Last reply
        0

        1/3

        1 Jul 2021, 13:28

        • Login

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