C++ OpenCV中的findContours函数错误

C++ OpenCV中的findContours函数错误,c++,opencv,image-processing,error-handling,C++,Opencv,Image Processing,Error Handling,我正在尝试运行以下代码(仅发布部分代码) 现在,我尝试搜索解决方案,一篇帖子建议更改前两个include头,使用而不是双引号来搜索当前目录。但这没用。因此,如果有人能帮我的话,我就把它贴在这里。谢谢 如果您使用的是最新版本的opencv,请从CV_RETR_树和CV_CHAIN_approw_SIMPLE中删除CV。 单击此处了解更多详细信息如果您使用的是最新版本的opencv,请从CV_RETR_树和CV_CHAIN_近似_SIMPLE中删除CV。 单击此处了解更多详细信息Wierd。。。尝试

我正在尝试运行以下代码(仅发布部分代码)


现在,我尝试搜索解决方案,一篇帖子建议更改前两个include头,使用
而不是双引号来搜索当前目录。但这没用。因此,如果有人能帮我的话,我就把它贴在这里。谢谢

如果您使用的是最新版本的opencv,请从CV_RETR_树和CV_CHAIN_approw_SIMPLE中删除CV。
单击此处了解更多详细信息

如果您使用的是最新版本的opencv,请从CV_RETR_树和CV_CHAIN_近似_SIMPLE中删除CV。
单击此处了解更多详细信息

Wierd。。。尝试删除“CV”。。。所以“RETR_TREE”等…这确实是一个奇怪的错误。@Miki为meWierd工作。。。尝试删除“CV”。。。所以“重做树”等等……这确实是一个奇怪的错误。@Miki,这对我很有用
#include "opencv2/highgui/highgui.hpp"
#include "opencv2/imgproc/imgproc.hpp"
#include <opencv2/core/core.hpp>
#include <opencv2/opencv.hpp>
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <tesseract/baseapi.h>
#include <leptonica/allheaders.h>

using namespace cv;
using namespace std;

/// Global variables
Mat erosion_dst, dilation_dst,adt,dst;
Mat threshold_output;

int erosion_elem = 0;
int erosion_size = 15;
int dilation_elem = 0;
int dilation_size = 0;
int const max_elem = 2;
int const max_kernel_size = 21;

/** Function Headers */
void Erosion( int, void* );
void Dilation( int, void* );

Mat src; Mat src_gray;
Mat denoised,blur_image;
int thresh = 100;
int max_thresh = 255;
RNG rng(12345);

// Function header
//void thresh_callback(int, void* );

vector<vector<Point> > contours;

vector<Vec4i> hierarchy;
// Approximate contours to polygons + get bounding rects and circles


/* @function main */
int main( int argc, char** argv )
{   
    tesseract::TessBaseAPI *api = new tesseract::TessBaseAPI();


    int count; 
    char *outText;


    // Initialize tesseract-ocr with English, without specifying tessdata path
    if (api->Init(NULL, "eng")) {
        fprintf(stderr, "Could not initialize tesseract.\n");
        exit(1);
    }

    // Load source image and convert it to gray
    src = imread("swine.jpg");
    fastNlMeansDenoisingColored(src, denoised,10,10,7,21 );

    GaussianBlur(denoised,blur_image,Size(5,5),0,0);
    // Convert image to gray and blur it
    cvtColor(blur_image, src_gray, COLOR_BGR2GRAY );


    // Create Window
    //char* source_window = "Source";
    //namedWindow( source_window, CV_WINDOW_AUTOSIZE );

    //imshow( source_window, src );
    adaptiveThreshold(src_gray, adt, 255, ADAPTIVE_THRESH_GAUSSIAN_C, THRESH_BINARY, 11, 2);
    imwrite("Adaptive_thresholding.tif",adt);

    //Erosion
    Erosion(0,0);

    //Thresholding for contours
    //createTrackbar( " Threshold:", "Source", &thresh, max_thresh, thresh_callback );
    //thresh_callback( 0, 0 );
    // Detect edges using Threshold
    threshold( erosion_dst, threshold_output, thresh, 255, THRESH_BINARY );

    // Find contours
    imwrite("thresh_out.jpg",threshold_output);
    findContours( threshold_output, contours, hierarchy, CV_RETR_TREE, CV_CHAIN_APPROX_SIMPLE, Point(0, 0) );

    vector<Rect> boundRect( contours.size() );
    vector<vector<Point> > contours_poly( contours.size() );
    vector<Point2f> ContArea(contours.size());
test_rect.cpp: In function ‘int main(int, char**)’:
test_rect.cpp:88:55: error: ‘CV_RETR_TREE’ was not declared in this scope
  findContours( threshold_output, contours, hierarchy, CV_RETR_TREE, CV_CHAIN_APPROX_SIMPLE, Point(0, 0) );
                                                       ^
test_rect.cpp:88:69: error: ‘CV_CHAIN_APPROX_SIMPLE’ was not declared in this scope
  findContours( threshold_output, contours, hierarchy, CV_RETR_TREE, CV_CHAIN_APPROX_SIMPLE, Point(0, 0) );