Opencv 找不到嵌套的轮廓

Opencv 找不到嵌套的轮廓,opencv,opencv3.0,contour,opencv3.1,opencv-contour,Opencv,Opencv3.0,Contour,Opencv3.1,Opencv Contour,我正在使用findContours()和drawContours()方法在我的二值图像中查找轮廓。然而,这是我的输出: 如果我进一步设置图像的阈值(如矩形)变得模糊,则内部可见(请注意,外部和内部曲线在左下角合并): 你能解释一下这个问题以及如何解决它吗 以下是我的代码片段: void cb_thresh(int,void*) {vector< vector<Point> > contours; vector<Vec4i> hierarchy; thr

我正在使用
findContours()
drawContours()
方法在我的二值图像中查找轮廓。然而,这是我的输出:

如果我进一步设置图像的阈值(如矩形)变得模糊,则内部可见(请注意,外部和内部曲线在左下角合并):

你能解释一下这个问题以及如何解决它吗

以下是我的代码片段:

void cb_thresh(int,void*)
{vector< vector<Point> > contours; 

vector<Vec4i> hierarchy;
threshold(src, thr,threshval, 255,THRESH_BINARY);
namedWindow("threshold",CV_WINDOW_NORMAL);
imshow("threshold",thr);
findContours( thr, contours, hierarchy,CV_RETR_LIST, CV_CHAIN_APPROX_NONE ); // Find the contours in the image

Scalar color( 255,255,255);

for( int i = 0; i< contours.size(); i++ ) // iterate through each contour

{
drawContours(thr, contours,i, color, CV_FILLED, 8, hierarchy );
}
namedWindow("dst",CV_WINDOW_NORMAL);
imshow("dst",thr);
}
void cb_阈值(int,void*)
{矢量<矢量>等高线;
向量层次;
阈值(src、thr、threshval、255、THRESH_二进制);
namedWindow(“阈值”,CV\u窗口\u正常);
imshow(“阈值”,thr);
查找轮廓(thr、轮廓、层次、CV_RETR_列表、CV_CHAIN_APPROX_NONE);//在图像中查找轮廓
标量颜色(255255);
for(int i=0;i

请注意,我已经删除了等高线的层次结构。

问题在于行
绘制等高线(thr、等高线、I、颜色、CV_填充、8、层次结构)。传递参数CV_FILLED将填充轮廓内的整个区域。因此,矩形被填充。可以用任何正整数替换
CV_FILLED

问题在于线条
绘制轮廓(thr,轮廓,i,颜色,CV_FILLED,8,层次)。传递参数CV_FILLED将填充轮廓内的整个区域。因此,矩形被填充。可以用任何正整数替换
CV\u FILLED

我尝试过更改轮廓提取方法,但在所有4种检索方法中都得到了相同的输出。您想要的输出是什么?我尝试过更改轮廓提取方法,但在所有4种检索方法中都得到了相同的输出。您想要的输出是什么?