Important: Please read the Qt Code of Conduct -

[solved]using inpaint of opencv in qt

  • 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)'


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

    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;;


    SOURCES +=

    QT += widgets core

    LIBS += -L/usr/local/lib

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

  • Lifetime Qt Champion


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

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

Log in to reply