#include "opencv2/highgui/highgui.hpp"
#include "opencv2/imgproc/imgproc.hpp" #include <iostream> using namespace cv;
using namespace std; void help()
{
cout << "\nThis program demonstrates line finding with the Hough transform.\n"
"Usage:\n"
"./houghlines <image_name>, Default is pic1.jpg\n" << endl;
} int main(int argc, char** argv)
{
const char* filename = argc >= ? argv[] : "pic1.jpg"; Mat src = imread(filename, );
if(src.empty())
{
help();
cout << "can not open " << filename << endl;
return -;
} Mat dst, cdst;
Canny(src, dst, , , );
cvtColor(dst, cdst, CV_GRAY2BGR); #if 0
vector<Vec2f> lines;
HoughLines(dst, lines, , CV_PI/, , , ); for( size_t i = ; i < lines.size(); i++ )
{
float rho = lines[i][], theta = lines[i][];
Point pt1, pt2;
double a = cos(theta), b = sin(theta);
double x0 = a*rho, y0 = b*rho;
pt1.x = cvRound(x0 + *(-b));
pt1.y = cvRound(y0 + *(a));
pt2.x = cvRound(x0 - *(-b));
pt2.y = cvRound(y0 - *(a));
line( cdst, pt1, pt2, Scalar(,,), , CV_AA);
}
#else
vector<Vec4i> lines;
HoughLinesP(dst, lines, , CV_PI/, , , );
for( size_t i = ; i < lines.size(); i++ )
{
Vec4i l = lines[i];
line( cdst, Point(l[], l[]), Point(l[], l[]), Scalar(,,), , CV_AA);
}
#endif
imshow("source", src);
imshow("detected lines", cdst); waitKey(); return ;
}

最新文章

  1. (转)ubuntu apache2 的负载均衡和反向代理
  2. jQuery插件treeview点击节点名称不展开、收缩节点 分类: JavaScript 2014-06-16 20:28 539人阅读 评论(0) 收藏
  3. java中的三种取整函数
  4. nginx server_name
  5. MySQL编码问题
  6. apt-get remove, apt-get autoremove和aptitude remove的区别
  7. (转载)[MySQL技巧]INSERT INTO… ON DUPLICATE KEY UPDATE
  8. Andoird开发手机壁纸
  9. 201521123077 《Java程序设计》第4周学习总结
  10. 深入浅出 Spring
  11. 巨星陨落 - Jim Gary
  12. 就这么 来ADO.net类操作数据库
  13. SQL 是一门美丽的语言 她来自艺术
  14. (二)stm32f103~~GPIO基本操作二(按键)
  15. 5.2 SW1控制LED1亮灭(中断功能)
  16. 初入MEF-IOC导入导出
  17. day14 Python集合
  18. svn:Cannot negotiate authentication mechanism
  19. 爬虫笔记之自如房屋价格图片识别(价格字段css背景图片偏移显示)
  20. CCBAnimationManager

热门文章

  1. MVC——再探MVC——增删查改
  2. IDA解析so文件异常(Binary data is incorrect maximum possible value is xx)
  3. unity学习 5.x依赖打包和解包
  4. node/静态路由/express框架中的express.static()和app.use()
  5. ZJNU 1531 - 丢手绢--中级
  6. 第一章 mysql 的架构与历史
  7. python-day1 爬虫基础之HTTP基本原理
  8. c++语法(2)
  9. document.write的时机
  10. JS - ES5与ES6面向对象编程