OpenCV 4.12.0
開源計算機視覺
載入中...
搜尋中...
無匹配項
fld_lines.cpp

使用 FastLineDetector 的示例

#include <iostream>
using namespace std;
using namespace cv;
using namespace cv::ximgproc;
int main(int argc, char** argv)
{
string in;
CommandLineParser parser(argc, argv, "{@input|corridor.jpg|輸入影像}{help h||顯示幫助資訊}");
if (parser.has("help"))
{
parser.printMessage();
return 0;
}
in = samples::findFile(parser.get<string>("@input"));
Mat image = imread(in, IMREAD_GRAYSCALE);
if( image.empty() )
{
parser.printMessage();
return -1;
}
// 建立 FLD 檢測器
// 引數 預設值 描述
// length_threshold 10 - 將丟棄短於此值的線段
// distance_threshold 1.41421356 - 從假設線放置一個點
// 距離大於此值的線段將被視為異常值
// canny_th1 50 - Canny() 中遲滯過程的第一個閾值
// canny_th2 50 - Canny() 中遲滯過程的第二個閾值
// canny_aperture_size 3 - Canny() 中 sobel 運算元的 Aperturesize。
// 如果為零,則不應用 Canny(),並且輸入影像被視為邊緣影像。
// canny_aperture_size 3 - Canny() 中 sobel 運算元的 Aperturesize。
// canny_aperture_size 3 - Canny() 中 Sobel 運算元的 Aperturesize。
// 將被執行
int length_threshold = 10;
float distance_threshold = 1.41421356f;
double canny_th1 = 50.0;
double canny_th2 = 50.0;
float distance_threshold = 1.41421356f;
bool do_merge = false;
Ptr<FastLineDetector> fld = createFastLineDetector(length_threshold,
distance_threshold, canny_th1, canny_th2, canny_aperture_size,
bool do_merge = false;
Ptr<FastLineDetector> fld = createFastLineDetector(length_threshold,
// 由於某些 CPU 的電源策略,似乎演算法的第一次執行需要更長的時間。
// 因此,我們在此處執行該演算法 5 次,以檢視演算法在充分預熱後的處理時間
// CPU 效能。
// 由於某些 CPU 的電源策略,似乎第一次執行
// 一個演算法需要更長的時間。因此,這裡我們執行該演算法 5 次
// 以檢視演算法在充分預熱下的處理時間
int64 start = getTickCount();
for (int run_count = 0; run_count < 5; run_count++) {
double freq = getTickFrequency();
double duration_ms = double(getTickCount() - start) * 1000 / freq;
int64 start = getTickCount();
// 使用 FLD 顯示找到的直線
Mat line_image_fld(image);
double duration_ms = double(getTickCount() - start) * 1000 / freq;
cout << "FLD 的經過時間 " << duration_ms << " 毫秒。" << endl;
}
waitKey();
Mat line_image_fld(image);
專為命令列解析而設計。
imshow("FLD 結果", line_image_fld);
cv::Mat::empty
return 0;
}
如果陣列沒有元素,則返回 true。
int64_t int64
T get(const String &name, bool space_delete=true) const
按名稱訪問引數。
定義 utility.hpp:956
void printMessage() const
列印幫助資訊。
bool has(const String &name) const
檢查命令列中是否提供了欄位。
n 維密集陣列類
定義 mat.hpp:830
cv::getTickFrequency
double getTickFrequency()
std::shared_ptr< _Tp > Ptr
Definition cvstd_wrapper.hpp:23
cv::getTickCount
int64 getTickCount()
int main(int argc, char *argv[])
定義 highgui_qt.cpp:3
定義 core.hpp:107
STL 名稱空間。
◆ detect()