4/26调APRN过程
来源:互联网 发布:双语名著阅读软件 编辑:程序博客网 时间:2024/06/05 15:50
vector<vector<Point>>::iterator itc = contours.begin();vector<RotatedRect> rect;for(;itc != contours.end();){RotatedRect mr = minAreaRect(contours[164]);//啊啊啊,直接就把轮廓转换成mat,还是用没见过的方法if(!verifySizes(mr)){itc = contours.erase(itc);}else{rect.push_back(mr);itc++;}}
今天写这段代码的时候出不来想要的轮廓,但是调试也调试不出来,然后花了一个下午来解决
首先是我想给每一个轮廓标号,然后看车牌所在的轮廓是多少号
所以用到了如下的代码
for( int i = 0; i< contours.size(); i++ ) { drawContours( result, contours,164,Scalar(0,0,255) ); string str = to_string((_ULonglong)i); Point point(contours[i][0].x,contours[i][0].y); putText(result,str,point, FONT_HERSHEY_PLAIN, 1, Scalar(0,0,200)); }之后我知道了想要的轮廓的下标
然后我想知道每一个轮廓的宽高比 ,有了下边这些代码
//找到每一个轮廓的宽高比RotatedRect m = minAreaRect(contours[164]);int height = m.size.width;int weight = m.size.height;float scale = weight/height;cout<<"height = "<<height<<endl<<"weight = "<<weight<<endl<<"scale = "<<scale<<endl;我发现我想要的轮廓符合条件,但是就是画不出来
所以有了下面这行代码
RotatedRect mr = minAreaRect(contours[164]);我将该轮廓直接作为参数传递给了minAreaRect()
然后进入下面的语句调试
RotatedRect mr = minAreaRect(contours[164]);//啊啊啊,直接就把轮廓转换成mat,还是用没见过的方法if(!verifySizes(mr)){itc = contours.erase(itc);}else{rect.push_back(mr);itc++;}
其中vector.erase的用法在另一片转载的博文
进入到verifySizes()里面
int area = mr.size.height * mr.size.width;float r = mr.size.width / mr.size.height;if(r<1) r = mr.size.height / mr.size.width;
我当时写的是
float r = mr.size.height / mr.size.width;导致 编译器又定义了一个r ,该变量的作用域是if语句块内
0 0
- 4/26调APRN过程
- 存储过程调存储过程
- 存储过程调存储过程实例
- 存储过程调存储过程的事务
- 前台调后台过程
- springTemplete调存储过程
- 调存储过程shell
- elasticsearch 调优过程
- java 调存储过程
- 安装GCC3.4过程
- C++学习过程 4
- C++学习过程 4
- 存储过程示例4
- 性能过程管理(4)
- 2015.7.4 过程抽象
- apache2.4安装过程
- 存储过程4
- 4、存储过程(procedure)
- java并发编程之——volatile详解
- python如何实现简单的爬虫功能
- Java报表工具打印方案对比
- EA&UML日拱一卒--类图::协作(collaboration)
- FreeRadius数据表详解
- 4/26调APRN过程
- Angular入门
- 架设双站点
- nyoj1278 zzuli1929 Prototypes analyze(河南省acm第九届省赛)
- HDU
- 归并排序(Java)
- PHP MySQL 数据字典生成器
- Linux变量
- 具体的设计模式(二):结构型模式