函数上漆"was not declare in this scope"

Function inpaint "was not declare in this scope"

本文关键字:in this scope declare was 函数 not      更新时间:2023-10-16

我试图在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:UsersFrancescoDesktopprova>g++ -I"C:opencvbuildinclude" 
 -L"C:opencvbuildx86mingwlib" 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;
}

有人能帮我吗?非常感谢。

cv::inpaint()photo模块中声明。你需要#include <opencv2/photo/photo.hpp>。或者,你可以选择#include <opencv2/opencv.hpp>,它包含了所有OpenCV的功能。

try:

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

还包括:opencv2/photo/photo.hpp