OpenCV 4.13.0
Open Source Computer Vision
読み込み中...
検索中...
見つかりません
🤖 AIによる機械翻訳(非公式) — これは OpenCV 4.13.0 公式リファレンス(英語)を AI (Claude) で自動翻訳したものです。訳に誤りを含む場合があります。正確な情報は 公式英語版(原文) を参照してください。
cv::ximgproc::FastLineDetector クラスabstract

[161] で説明されているFLD (Fast Line Detector) アルゴリズムを実装したクラス。続き...

#include <opencv2/ximgproc/fast_line_detector.hpp>

Collaboration diagram for 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
 指定された画像上に線分を描画する。
 
- Public Member Functions inherited from 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
 

Additional Inherited Members

- Static Public Member Functions inherited from 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)
 ファイルノードからアルゴリズムを読み込む。
 
- Protected Member Functions inherited from cv::Algorithm
void writeFormat (FileStorage &fs) const
 

詳細説明

[161] で説明されているFLD (Fast Line Detector) アルゴリズムを実装したクラス。

#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|input image}{help h||show help message}");
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;
}
// Create FLD detector
// Param Default value Description
// length_threshold 10 - Segments shorter than this will be discarded
// distance_threshold 1.41421356 - A point placed from a hypothesis line
// segment farther than this will be
// regarded as an outlier
// canny_th1 50 - First threshold for
// hysteresis procedure in Canny()
// canny_th2 50 - Second threshold for
// hysteresis procedure in Canny()
// canny_aperture_size 3 - Aperturesize for the sobel operator in Canny().
// If zero, Canny() is not applied and the input
// image is taken as an edge image.
// do_merge false - If true, incremental merging of segments
// will be performed
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;
// Because of some CPU's power strategy, it seems that the first running of
// an algorithm takes much longer. So here we run the algorithm 5 times
// to see the algorithm's processing time with sufficiently warmed-up
// CPU performance.
for (int run_count = 0; run_count < 5; run_count++) {
double freq = getTickFrequency();
lines.clear();
int64 start = getTickCount();
// Detect the lines with FLD
fld->detect(image, lines);
double duration_ms = double(getTickCount() - start) * 1000 / freq;
cout << "Elapsed time for FLD " << duration_ms << " ms." << endl;
}
// Show found lines with FLD
Mat line_image_fld(image);
fld->drawSegments(line_image_fld, lines);
imshow("FLD result", line_image_fld);
waitKey();
return 0;
}
Designed for command line parsing.
Definition utility.hpp:890
n-dimensional dense array class
Definition mat.hpp:840
bool empty() const
Returns true if the array has no elements.
std::shared_ptr< _Tp > Ptr
Definition cvstd_wrapper.hpp:23
int64_t int64
Definition interface.h:61
double getTickFrequency()
Returns the number of ticks per second.
int64 getTickCount()
Returns the number of ticks.
Mat imread(const String &filename, int flags=IMREAD_COLOR_BGR)
Loads an image from a file.
int main(int argc, char *argv[])
Definition highgui_qt.cpp:3
Definition ximgproc.hpp:149
Definition core.hpp:107
STL namespace.

構築子と解体子の詳解

◆ ~FastLineDetector()

virtual cv::ximgproc::FastLineDetector::~FastLineDetector ( )
inlinevirtual

メンバ関数詳解

◆ detect()

virtual void cv::ximgproc::FastLineDetector::detect ( InputArray image,
OutputArray lines )
pure virtual
Python:
cv.ximgproc.FastLineDetector.detect(image[, lines]) -> lines

入力画像から線分を検出する。これは上に示した画像に対してアルゴリズムをデフォルトの引数で適用した出力である。

image
引数
imageグレースケール (CV_8UC1) の入力画像。roiのみを選択する必要がある場合は、次のように使用する: fld_ptr-\>detect(image(roi), lines, ...); lines += Scalar(roi.x, roi.y, roi.x, roi.y);
lines線分の始点と終点を指定するVec4f要素のベクトル。Vec4fは (x1, y1, x2, y2) であり、point 1 が始点、point 2 が終点である。返される線分は、明るい側が左になるように向き付けられる。

◆ drawSegments()

virtual void cv::ximgproc::FastLineDetector::drawSegments ( InputOutputArray image,
InputArray lines,
bool draw_arrow = false,
Scalar linecolor = Scalar(0, 0, 255),
int linethickness = 1 )
pure virtual
Python:
cv.ximgproc.FastLineDetector.drawSegments(image, lines[, draw_arrow[, linecolor[, linethickness]]]) -> image

指定された画像上に線分を描画する。

引数
imageラインが描画される画像。ラインが検出された画像以上のサイズである必要がある。
lines描画する必要があるラインのベクトル。
draw_arrowtrue の場合、矢印の先端が描画される。
linecolor線の色。
linethickness線の太さ。

このクラス詳解は次のファイルから抽出されました: