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

    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
    @



  • 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

    Hi,

    You can use pkg-config with qmake
    IIRC:
    @
    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
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.