C++ 图片从底部做直线检测

本文介绍了如何使用C++和OpenCV库来实现图片底部的直线检测。通过提供的主要代码段,展示了关键步骤,并在2016.05.11进行了补充更新,提供了源代码下载链接。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

主要代码:

<pre name="code" class="cpp">int  ImageDeal::findLines( IplImage* I, std::vector<std::vector<int>> &lines) {

	int x_threshold = 2;  //x轴方向x_threshold范围内存在要检测的点,即看作直线连续
	double width_proportion = 0.2;  //直线连续超过图片宽度的width_proportion时,确定为一条跨越图片整个宽度的直线
	double height_proportion = 0.1667;  //检测图片从底部起的height_proportion部分区域
	lines.clear(); //lines存储每条直线的起始、结束四个顶点的坐标

	//I: binary graph,为canny处理过的二值图像
	CV_Assert( I->depth != sizeof(uchar) );
	int cols = I->width;
	int rows = I->height;
	int channels = I->nChannels;
	if(channels != 1){
		std::cout<<"the image needs to be binary graph!"<<std::endl;
		return -1;			
	}
	
	// push the bottom coordinates of image I(height_proportion)先将图片最底部作为一条直线,存储其顶点位置
	std::vector<int> lines_botoom_temp;
	lines_botoom_temp.clear();
	lines_botoom_temp.push_back(0);
	lines_botoom_temp.push_back(rows - 1);
	lines_botoom_temp.push_back(cols-1);
	lines_botoom_te
评论 6
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Bicelove

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值