LSD在opencv中的實現

2021-07-04 08:24:53 字數 1414 閱讀 2929

lsd演算法是一種直線檢測的演算法,比hough效果好,作者將**和文章上傳了,詳見

opencv3.0也整合了其演算法,這邊說下如何在opencv裡面呼叫。下面**其實也是opencv給的example  可以在

#include #include #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)

else

mat image = imread(in, imread_grayscale);//讀入原圖,需為灰度影象

#if 0

#endif

// create and lsd detector with standard or no refinement.

#if 1

ptrls = createlinesegmentdetector(lsd_refine_std);//或者兩種lsd演算法,這邊用的是standard的

#else

ptrls = createlinesegmentdetector(lsd_refine_none);

#endif

double start = double(gettickcount());

vectorlines_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原理的東西這兩篇寫的比較好

opencv在visual studio中配置

f program files opencv2.4.4 opencv build include f program files opencv2.4.4 opencv build include opencv f program files opencv2.4.4 opencv build incl...

在pycharm中安裝opencv

這裡會有乙個坑,注意選擇跟自己python相匹配的版本 檢視本機python的版本匹配哪些檔案 再輸入以下語句 import pip.internal print pip.internal.pep425tags.get supported 查詢得到 安裝opencv pip install open...

在OpenCV裡實現開運算

前面學習腐蝕和膨脹演算法,並且深刻地認識到它們的特性以及作用。如果由這兩種組合出來的運算又有什麼樣的不同呢?比如乙個影象先腐蝕後膨脹的操作,會有什麼結果呢?因為腐蝕是把白色變小,膨脹又是把白色變大,是否會保持原圖不變呢?帶著這些問題來研究一下先腐蝕後膨脹的演算法,我們把這樣的演算法叫做開運算,在數學...