OpenCV 4.12.0
開源計算機視覺
載入中...
搜尋中...
無匹配項
cv::ximgproc::FastLineDetector 類參考抽象類

實現 [158] 中描述的 FLD(快速直線檢測器)演算法的類。 更多...

#include <opencv2/ximgproc/fast_line_detector.hpp>

cv::ximgproc::FastLineDetector 的協作圖

公共成員函式

virtual ~FastLineDetector ()
 
virtual void detect (InputArray image, OutputArray lines)=0
 在輸入影像中查詢直線。 這是上述影像演算法的預設引數的輸出。
 
virtual void drawSegments (InputOutputArray image, InputArray lines, bool draw_arrow=false, Scalar linecolor=Scalar(0, 0, 255), int linethickness=1)=0
 在給定影像上繪製線段。
 
- 從 cv::Algorithm 繼承的公共成員函式
 Algorithm ()
 
virtual ~Algorithm ()
 
virtual void clear ()
 清除演算法狀態。
 
virtual bool empty () const
 如果 Algorithm 為空(例如,在最開始或讀取失敗後),則返回 true。
 
virtual String getDefaultName () const
 
virtual void read (const FileNode &fn)
 從檔案儲存中讀取演算法引數。
 
virtual void save (const String &filename) const
 
void write (const Ptr< FileStorage > &fs, const String &name=String()) const
 
virtual void write (FileStorage &fs) const
 將演算法引數儲存到檔案儲存中。
 
void write (FileStorage &fs, const String &name) const
 

附加的繼承成員

- 從 cv::Algorithm 繼承的靜態公共成員函式
template<typename _Tp >
static Ptr< _Tpload (const String &filename, const String &objname=String())
 從檔案中載入演算法。
 
template<typename _Tp >
static Ptr< _TploadFromString (const String &strModel, const String &objname=String())
 從字串載入演算法。
 
template<typename _Tp >
static Ptr< _Tpread (const FileNode &fn)
 從檔案節點讀取演算法。
 
- 從 cv::Algorithm 繼承的保護成員函式
void writeFormat (FileStorage &fs) const
 

詳細描述

實現 [158] 中描述的 FLD(快速直線檢測器)演算法的類。

#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。
// do_merge false - 如果為 true,將執行線段的增量合併
// 將被執行
int length_threshold = 10;
float distance_threshold = 1.41421356f;
double canny_th1 = 50.0;
double canny_th2 = 50.0;
int canny_aperture_size = 3;
bool do_merge = false;
Ptr<FastLineDetector> fld = createFastLineDetector(length_threshold,
distance_threshold, canny_th1, canny_th2, canny_aperture_size,
do_merge);
vector<Vec4f> lines;
// 由於某些 CPU 的電源策略,似乎演算法的第一次執行需要更長的時間。
// 因此,我們在此處執行該演算法 5 次,以檢視演算法在充分預熱後的處理時間
// CPU 效能。
for (int run_count = 0; run_count < 5; run_count++) {
double freq = getTickFrequency();
lines.clear();
int64 start = getTickCount();
// 使用 FLD 檢測直線
fld->detect(image, lines);
double duration_ms = double(getTickCount() - start) * 1000 / freq;
cout << "FLD 經過的時間 " << duration_ms << " 毫秒。" << endl;
// 使用 FLD 顯示找到的直線
Mat line_image_fld(image);
fld->drawSegments(line_image_fld, lines);
imshow("FLD 結果", line_image_fld);
}
waitKey();
cv::CommandLineParser
專為命令列解析而設計。
定義 utility.hpp:890
cv::Mat::empty
return 0;
}
如果陣列沒有元素,則返回 true。
int64_t int64
n 維密集陣列類
定義 mat.hpp:830
cv::getTickFrequency
double getTickFrequency()
std::shared_ptr< _Tp > Ptr
Definition cvstd_wrapper.hpp:23
cv::getTickCount
int64 getTickCount()
ximgproc.hpp
返回時鐘週期數。
◆ ~FastLineDetector()
從檔案載入影像。
int main(int argc, char *argv[])
定義 highgui_qt.cpp:3
定義 core.hpp:107
STL 名稱空間。
◆ detect()

建構函式 & 解構函式文件

virtual void cv::ximgproc::FastLineDetector::detect

cv.ximgproc.FastLineDetector.detect( ( )
image[, lines]

成員函式文件

灰度 (CV_8UC1) 輸入影像。 如果只需要選擇一個 roi,請使用: fld_ptr-\>detect(image(roi), lines, ...); lines += Scalar(roi.x, roi.y, roi.x, roi.y);

一個 Vec4f 元素的向量,用於指定直線的起點和終點。 其中 Vec4f 是 (x1, y1, x2, y2),點 1 是起點,點 2 是終點。 返回的直線是有方向的,因此較亮的一側在其左側。 ( InputArray image,
OutputArray lines )
純虛擬函式
Python
◆ drawSegments()virtual void cv::ximgproc::FastLineDetector::drawSegments) -> 輸出向量,包含與另一影像中點對應的對極線。每條線\(ax + by + c=0\)由3個數字\((a, b, c)\)編碼。

在輸入影像中查詢直線。 這是上述影像演算法的預設引數的輸出。

image
引數
imagedraw_arrow = false,
輸出向量,包含與另一影像中點對應的對極線。每條線\(ax + by + c=0\)由3個數字\((a, b, c)\)編碼。linecolor = Scalar(0, 0, 255),

linethickness = 1 )

cv.ximgproc.FastLineDetector.drawSegments( ( InputOutputArray image,
InputArray 輸出向量,包含與另一影像中點對應的對極線。每條線\(ax + by + c=0\)由3個數字\((a, b, c)\)編碼。,
bool image, lines[, draw_arrow[, linecolor[, linethickness]]]
Scalar 將在其上繪製直線的影像。 應該大於或等於找到直線的影像。
int 需要繪製的直線的向量。
純虛擬函式
Python
draw_arrow如果為 true,則將繪製箭頭。) -> image

在給定影像上繪製線段。

引數
imagelinecolor
輸出向量,包含與另一影像中點對應的對極線。每條線\(ax + by + c=0\)由3個數字\((a, b, c)\)編碼。線條顏色。
linethickness線條粗細。
此類文件由以下檔案生成opencv2/ximgproc/fast_line_detector.hpp
在 2025 年 7 月 3 日星期四 12:14:40 為 OpenCV 生成,作者是 doxygen 1.12.0線條粗細。

此類文件由以下檔案生成