功能inpaint“未在此范围内声明”

时间:2013-05-10 15:13:32

标签: c++ opencv

我正在尝试在opencv中使用inpaint函数,但我收到此错误

loadimg.cpp: In function 'int main(int, char**)':
loadimg.cpp:19:28: error: 'INPAINT_TELEA' is not a member of 'cv'
loadimg.cpp:19:45: error: 'inpaint' was not declared in this scope

输入内容:

C:\Users\Francesco\Desktop\prova>g++ -I"C:\opencv\build\include" 
 -L"C:\opencv\build\x86\mingw\lib" loadimg.cpp -lopencv_core245 -lopencv_highgui245 
 -lopencv_img proc245 -o loadimg

这是我的代码:

#include "opencv2/highgui/highgui.hpp"
#include "opencv2/imgproc/imgproc.hpp"
#include <opencv/cv.h>
#include <stdlib.h>
#include <stdio.h>
#include <iostream>

using namespace cv;
using namespace std;

int main(int argc, char** argv)
{

    Mat src = cv::imread("prova.jpg");
    Mat mask;
    cvtColor(src, mask, CV_RGB2GRAY);
    threshold(mask, mask, 220, 255, CV_THRESH_BINARY);
    Mat dst;
    inpaint(src, mask, dst, 1, cv::INPAINT_TELEA);
    imshow("image", dst);
    waitKey(0);

    return 0;
}

任何人都可以帮助我吗?非常感谢你。

2 个答案:

答案 0 :(得分:3)

cv::inpaint()photo模块中声明。您需要#include <opencv2/photo/photo.hpp>。或者,您可以#include <opencv2/opencv.hpp>,其中包括OpenCV的所有功能。

答案 1 :(得分:1)

尝试:

inpaint(src, mask, dst, 1, INPAINT_TELEA);

另外,包括:opencv2 / photo / photo.hpp