Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/image-processing/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/opencv/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Image processing ';cvFindContours';未在此范围opencv 2.4.2中声明,编译错误_Image Processing_Opencv_Compiler Errors_Eclipse Cdt - Fatal编程技术网

Image processing ';cvFindContours';未在此范围opencv 2.4.2中声明,编译错误

Image processing ';cvFindContours';未在此范围opencv 2.4.2中声明,编译错误,image-processing,opencv,compiler-errors,eclipse-cdt,Image Processing,Opencv,Compiler Errors,Eclipse Cdt,我正在使用opencv 2.4.2库检测边缘并在图像上查找四边形。一切都很顺利,直到我发现这些编译错误 ../src/GoodFeaturesToDetect.cpp:198:109: error: ‘cvFindContours’ was not declared in this scope ../src/GoodFeaturesToDetect.cpp:203:106: error: ‘cvContourPerimeter’ was not declared in this scope ..

我正在使用opencv 2.4.2库检测边缘并在图像上查找四边形。一切都很顺利,直到我发现这些编译错误

../src/GoodFeaturesToDetect.cpp:198:109: error: ‘cvFindContours’ was not declared in this scope
../src/GoodFeaturesToDetect.cpp:203:106: error: ‘cvContourPerimeter’ was not declared in this scope
../src/GoodFeaturesToDetect.cpp:203:114: error: ‘cvApproxPoly’ was not declared in this scope
../src/GoodFeaturesToDetect.cpp:206:64: error: ‘cvContourArea’ was not declared in this scope
以下是我的标题:

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

using namespace cv;
using namespace std;

void DrawLine( Mat img, Point start, Point end );
vector<Point2f> FindCornersUsingGoodFeaturesToTrack(Mat toTrack);
void ConnectPointsWithLine(Mat img,vector<Point2f> corners);
void DrawQuad(Mat img, Point a, Point b, Point c, Point d);
void DetectAndDrawQuads(Mat img);
我正在研究EclipseCDT(Helois)


如果有任何提示,我将不胜感激。谢谢。

首先,您应该对opencv标题使用
#include
(就像您的第一行,而不是第二行和第三行)

CV >开始的方法,如<代码> CVFIDCONTRONS 是从较老的OpenCV C接口中分离出来的,与新的C++代码分离。例如,

cvFindContour
是在
opencv2/imgproc/imgproc\u c.h
中定义的,而不是在
opencv2/imgproc/imgproc.hpp
中定义的(注意
\u c.h
部分)


在旁注中,您已经包含了两次stdlib.h。

结果表明,我调用的方法来自openCv 2.0。我必须将CVFIDCONTER更改为FixTrimes(…)、CVAdxxPosito到Apple XPDP等,如OpenCV2.4.2. ./P>中所描述的方法仍然可用,但是是的,最好使用它们的C++等价物。它们被移动到OpenCVI遗留模块。包括它的头和到遗留库的链接,它就可以工作了。但是最好用C++的对应来代替它们。
void DetectAndDrawQuads(Mat img){
        CvSeq* contours;
        CvSeq* result;
        CvMemStorage *storage=cvCreateMemStorage(0);
        Mat gray;
        cvtColor(img,gray,CV_BGR2GRAY);
        cvFindContours(&gray,storage, &contours, sizeof(CvContour),CV_RETR_LIST,CV_CHAIN_APPROX_SIMPLE, Point(0,0));

        //Loop through all the contours discovered
        //Figure out which ones form a quad
        while(contours){
            result=cvApproxPoly(contours, sizeof(CvContour),storage, CV_POLY_APPROX_DP,cvContourPerimeter(contours)*0.02,0);

        if(result->total=4 && fabs(cvContourArea(result, CV_WHOLE_SEQ)) > 20){
            CvPoint *pt[4];
            for(int i=0; i<4; i++)
                pt[i]=(CvPoint*) cvGetSeqElem(result,i);

            DrawQuad(gray,*pt[0],*pt[1],*pt[2],*pt[3]); 

        }
        contours = contours->h_next;
        }

}
opencv_contrib opencv_flann opencv_legacy opencv_calib3d opencv_ml opencv_imgproc opencv_highgui opencv_objdetect opencv_core opencv_features2d