OpenCV_(HougLines transform)霍夫变换检测直线
来源:互联网 发布:苏亚雷斯巴萨数据 编辑:程序博客网 时间:2024/06/04 18:15
2.hough transform 霍夫变换检测直线
cv::Mat image = cv::imread("../../aTestImage/road2.jpg", 0);//Buildingcv::Mat contours;cv::Canny(image, contours, 125, 350);//主体为白色 std::vector<cv::Vec2f> lines;//二维向量组cv::HoughLines(contours, lines, 1, PI / 180, 150);//获取hough变换的直线数据存储在lines向量中std::cout << "lines count:" << lines.size() << std::endl;cv::Mat result(contours.rows, contours.cols, CV_8U, cv::Scalar(255));//和轮廓图像大小一致的图像image.copyTo(result);std::vector <cv::Vec2f>::const_iterator it = lines.begin();while (it != lines.end()){float rho = (*it)[0];//半径float theta = (*it)[1];//角度if (theta<PI / 4. || theta>3.*PI / 4.){//垂直线cv::Point pt1(rho / cos(theta), 0);//与第一行交点cv::Point pt2((rho - result.rows*sin(theta)) / cos(theta), result.rows);//与最后一行交点cv::line(result, pt1, pt2, cv::Scalar(255), 1);}else{//水平线cv::Point pt1(0, rho / sin(theta));//与第一列交点cv::Point pt2(result.cols, (rho - result.cols*cos(theta)) / sin(theta));//与最后一列交点cv::line(result, pt1, pt2, cv::Scalar(255), 1);}std::cout << "lines Detail:" <<"("<<rho<<","<<theta <<")"<< std::endl;++it;}cv::namedWindow("resultL", 1);cv::imshow("resultL", result);
0 0
- OpenCV_(HougLines transform)霍夫变换检测直线
- Hough Transform 霍夫变换检测直线
- 霍夫变换(Hough Transform)直线检测
- Hough Transform 霍夫变换检测直线
- Hough Transform 霍夫变换检测直线
- Hough Transform 霍夫变换检测直线
- Hough Transform 霍夫变换检测直线
- 霍夫变换(Hough Transform)直线检测
- 霍夫变换 ( Hough Transform) 直线检测(Matlab 源码)
- OpenCV的霍夫变换(Hough Transform)直线检测
- 霍夫变换(Hough Transform)直线检测原理
- 霍夫变换直线检测
- 霍夫变换检测直线
- 霍夫变换检测直线
- 霍夫变换检测直线
- 霍夫变换-检测直线
- 霍夫变换 检测直线
- 图像的直线检测——霍夫变换(Hough transform)
- RecyclerView的使用和封装
- 使用Xshell连接服务器SSH
- 字符串hash+map——BZOJ2081/Luogu3498 [Poi2010]Beads
- SelectSort 选择排序
- centos 7配置ip地址
- OpenCV_(HougLines transform)霍夫变换检测直线
- 基础算法——快速排序
- Android 自定义View学习之文字绘制
- UItableveiw的一些使用
- Linux系统内核分析实验——system_call中断处理过程
- JAVA HttpURLConnection Post方式提交传递参数
- css3实现的手风琴效果
- GYM 101102 C.Bored Judge(map)
- Struts2配置RESULT中TYPE的参数说明