Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. [solved]using inpaint of opencv in qt
Forum Updated to NodeBB v4.3 + New Features

[solved]using inpaint of opencv in qt

Scheduled Pinned Locked Moved QML and Qt Quick
4 Posts 4 Posters 3.3k 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.
  • B Offline
    B Offline
    bts-007
    wrote on last edited by
    #1

    I am using inpaint from opencv. I am getting an output when I compile it with g++(i.e g++ impaint.c pkg-config opencv --cflags --libs). I have planned it use in qt. I am getting an error message

    undefined reference to 'cv::inpaint(cv::_InputArray const&, cv::_InputArray const&, cv::_OutputArray const&, double, int)'

    main.cpp
    @

    #include <iostream>
    #include <opencv2/opencv.hpp>
    #include <opencv2/photo/photo.hpp>
    #include<QApplication>

    int main(int argc,char *argv[])
    {
    QApplication app(argc,argv);

    //Our color image
    cv::Mat imageMat = cv::imread("cat.jpg", CV_LOAD_IMAGE_COLOR);
    
    //Grayscale matrix
    cv::Mat grayscaleMat (imageMat.size(), CV_8U);
    
    //Convert BGR to Gray
    cv::cvtColor( imageMat, grayscaleMat, CV_BGR2GRAY );
    
    //Binary image
    cv::Mat binaryMat(grayscaleMat.size(), grayscaleMat.type());
    
    //Apply thresholding
    cv::threshold(grayscaleMat, binaryMat, 180, 255, cv::THRESH_BINARY);
    
    //Show the results
    cv::namedWindow("original", cv::WINDOW_AUTOSIZE);
    cv::imshow("original", imageMat);
    
    cv::namedWindow("Output", cv::WINDOW_AUTOSIZE);
    cv::imshow("Output", binaryMat);
    
    cv::Mat dst;
    cv::inpaint(imageMat, binaryMat, dst, 1, cv::INPAINT_TELEA);
    
    cv::namedWindow("result", cv::WINDOW_AUTOSIZE);
    cv::imshow("result", dst);
    
    return app.exec&#40;&#41;;
    

    }
    @

    inpaint.pro

    @
    SOURCES +=
    main.cpp

    QT += widgets core

    LIBS += -L/usr/local/lib
    -lopencv_core
    -lopencv_imgproc
    -lopencv_highgui
    -lopencv_ml
    -lopencv_video
    -lopencv_features2d
    -lopencv_calib3d
    -lopencv_objdetect
    -lopencv_contrib
    -lopencv_legacy
    -lopencv_flann
    @

    1 Reply Last reply
    0
    • G Offline
      G Offline
      Guigui
      wrote on last edited by
      #2

      Hi,
      Ain't the cv::inpaint() function in opencv_photo, about the only lib you did not include in your project file?

      1 Reply Last reply
      0
      • SGaistS Offline
        SGaistS Offline
        SGaist
        Lifetime Qt Champion
        wrote on last edited by
        #3

        Hi,

        You can use pkg-config with qmake
        IIRC:
        @
        CONFIG += link_pkgconfig
        PKGCONFIG += opencv
        @

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        1 Reply Last reply
        0
        • S Offline
          S Offline
          stereomatching
          wrote on last edited by
          #4

          If you are on windows and using the g++ come with Qt, you need to recompile the openCV by yourself.

          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