LSD在opencv中的实现
来源:互联网 发布:如何查看网络是否稳定 编辑:程序博客网 时间:2024/04/27 17:33
LSD算法是一种直线检测的算法,比hough效果好,作者将代码和文章上传了,详见http://www.ipol.im/pub/art/2012/gjmr-lsd/。
opencv3.0也集成了其算法,这边说下如何在opencv里面调用。下面代码其实也是opencv给的example 可以在http://docs.opencv.org/master/d8/dd4/lsd_lines_8cpp-example.html#a9
#include <iostream>#include <string>#include "opencv2/core/core.hpp"#include "opencv2/core/utility.hpp"#include "opencv2/imgproc/imgproc.hpp"#include "opencv2/imgcodecs.hpp"#include "opencv2/highgui/highgui.hpp"using namespace std;using namespace cv;int main(int argc, char** argv){ std::string in; if (argc != 2) { std::cout << "Usage: lsd_lines [input image]. Now loading ../data/building.jpg" << std::endl; in = "../data/building.jpg"; } else { in = argv[1]; } Mat image = imread(in, IMREAD_GRAYSCALE);//读入原图,需为灰度图像#if 0 Canny(image, image, 50, 200, 3); // Apply canny edge//可选canny算子#endif // Create and LSD detector with standard or no refinement.#if 1 Ptr<LineSegmentDetector> ls = createLineSegmentDetector(LSD_REFINE_STD);//或者两种LSD算法,这边用的是standard的#else Ptr<LineSegmentDetector> ls = createLineSegmentDetector(LSD_REFINE_NONE);#endif double start = double(getTickCount()); vector<Vec4f> lines_std; // Detect the lines ls->detect(image, lines_std);//这里把检测到的直线线段都存入了lines_std中,4个float的值,分别为起止点的坐标 double duration_ms = (double(getTickCount()) - start) * 1000 / getTickFrequency(); std::cout << "It took " << duration_ms << " ms." << std::endl; // Show found lines Mat drawnLines(image); ls->drawSegments(drawnLines, lines_std); imshow("Standard refinement", drawnLines); waitKey(); return 0;}
这边初学,有许多不正确的地方,还请批评指正。
对LSD原理的东西这两篇写的比较好
http://blog.csdn.net/carson2005/article/details/9326847
http://blog.csdn.net/polly_yang/article/details/10085401
大家有兴趣也可以对比下源码看看,我把opencv里面LSD的源码也整理出来了
http://download.csdn.net/detail/mollylee1011/8961213
1 0
- LSD在opencv中的实现
- 直线检测算法 LSD 的相关介绍及其在 OpenCV 和 MATLAB 中的可视化
- 各种距离在opencv中的实现
- OTSU 阈值计算在OpenCV中的实现
- LSD快速直线检测的原理概要及OpenCV代码实现(CV类LineSegmentDetector)
- opencv的直线识别(Hough & LSD )
- SAD立体匹配算法在opencv中的实现
- SAD立体匹配算法在opencv中的实现
- 基数排序中的LSD方法和MSD方法
- Opencv中的PCA实现
- 基数排序简介及LSD、MSD实现
- OpenCV自学笔记29. lsd直线检测算法(未完)
- 【OpenCV】cvColor在OpenCV中的应用
- OpenCv在Qt中的使用
- OpenCv在Qt中的使用
- OpenCV在MFC中的使用
- opencv在Qt中的使用
- opencv在VS2010中的配置
- 数据结构入门——链表的实现
- RecyclerView初探
- 项目总结——传说中的反射竟然是这个样子
- android INSTALL_FAILED_OLDER_SDK
- [分享]牛牛图片查看器[仿QQ图片查看器]及大致原理说明
- LSD在opencv中的实现
- 九度 题目1026:又一版 A+B
- 【黑马程序员-学习笔记】数据结构-顺序表
- 南邮 OJ 1161 飞弹
- 《深入理解Android 卷III》推荐序
- HDU 5347(2015多校5)-MZL's chemistry(打表)
- Android系统SettingsPrivider分析与修改方法
- POJ 2752 Seek the Name,Seek the Fame
- Hibernate使用sql语句查询