(OpenCV)findcoutours函数出现is_block_tybe_vaild(header->_block_use)问题

#include "stdafx.h"
#include "opencv2/highgui/highgui.hpp"  
#include "opencv2/imgproc/imgproc.hpp"  
#include <iostream>   


using namespace cv;
using namespace std;


Mat src; Mat src_gray;
RNG rng(12345);


int main()
{
src = imread("D://1.jpg");
imshow("原图", src);
cvtColor(src, src_gray, CV_BGR2GRAY);
blur(src_gray, src_gray, Size(3, 3));
Mat threshold_output;
vector<vector<Point> > contours;
vector<Vec4i> hierarchy;


threshold(src_gray, threshold_output, 245, 255, 1); // 注意!!这里用的是模式1,  


findContours(threshold_output, contours, hierarchy, CV_RETR_TREE, CHAIN_APPROX_NONE, Point(0, 0));//CHAIN_APPROX_NONE全体,CV_CHAIN_APPROX_SIMPLE,,,RETR_TREE  


Scalar color = Scalar(211, 55, 155);
//hierarchy[3][3]表示轮廓3的父级轮廓    hierarchy[ hierarchy[3][3]][3]表示轮廓3父级轮廓的父级轮廓   
//hierarchy[3][0]、hierarchy[3][1]、hierarchy[3][2]、hierarchy[3][3]分别表示轮廓3的 前一个、后一个、子级、父级轮廓  
//只有轮廓8才有同级的前后轮廓,即hierarchy[8][0]和hierarchy[8][1]  
drawContours(src, contours, hierarchy[8][1], color, 2, 8, vector<Vec4i>(), 0, Point());
printf("轮廓数%d\n", contours.size());
imshow("Contours", src);
waitKey(0);
return(0);

}


本人小白一名,今天运行某博主的程序时出现了is_block_tybe_vaild(header->_block_use)这个问题,求大神们解答,感激不尽!!



  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 3
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值