 |
OpenCV
4.5.2
Open Source Computer Vision
|
Class implementing the FLD (Fast Line Detector) algorithm described in [137] .
More...
#include <opencv2/ximgproc/fast_line_detector.hpp>
Class implementing the FLD (Fast Line Detector) algorithm described in [137] .
#include <iostream>
using namespace std;
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;
}
{
return -1;
}
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;
distance_threshold, canny_th1, canny_th2, canny_aperture_size,
do_merge);
vector<Vec4f> lines;
for (int run_count = 0; run_count < 5; run_count++) {
lines.clear();
double duration_ms = double(
getTickCount() - start) * 1000 / freq;
cout << "Elapsed time for FLD " << duration_ms << " ms." << endl;
}
Mat line_image_fld(image);
imshow(
"FLD result", line_image_fld);
vector<Vec6d> ellipses;
for (int run_count = 0; run_count < 5; run_count++) {
lines.clear();
double duration_ms = double(
getTickCount() - start) * 1000 / freq;
cout << "Elapsed time for EdgeDrawing detectLines " << duration_ms << " ms." << endl;
cout << "Elapsed time for EdgeDrawing detectEllipses " << duration_ms << " ms." << endl;
}
for (size_t i = 0; i < segments.size(); i++)
{
const Point* pts = &segments[i][0];
int n = (int)segments[i].
size();
polylines(edge_image_ed, &pts, &n, 1,
false,
Scalar((rand() & 255), (rand() & 255), (rand() & 255)), 1);
}
imshow(
"EdgeDrawing detected edges", edge_image_ed);
Mat line_image_ed(image);
for (size_t i = 0; i < ellipses.size(); i++)
{
Point center((
int)ellipses[i][0], (
int)ellipses[i][1]);
Size axes((
int)ellipses[i][2] + (
int)ellipses[i][3], (
int)ellipses[i][2] + (
int)ellipses[i][4]);
double angle(ellipses[i][5]);
ellipse(line_image_ed, center, axes, angle, 0, 360, color, 2,
LINE_AA);
}
imshow(
"EdgeDrawing result", line_image_ed);
return 0;
}
◆ ~FastLineDetector()
virtual cv::ximgproc::FastLineDetector::~FastLineDetector |
( |
| ) |
|
|
inlinevirtual |
◆ detect()
Python: |
---|
| _lines | = | cv.ximgproc_FastLineDetector.detect( | _image[, _lines] | ) |
Finds lines in the input image. This is the output of the default parameters of the algorithm on the above shown image.
image
- Parameters
-
_image | A grayscale (CV_8UC1) input image. If only a roi needs to be selected, use: fld_ptr-\>detect(image(roi), lines, ...); lines += Scalar(roi.x, roi.y, roi.x, roi.y); |
_lines | A vector of Vec4f elements specifying the beginning and ending point of a line. Where Vec4f is (x1, y1, x2, y2), point 1 is the start, point 2 - end. Returned lines are directed so that the brighter side is on their left. |
- Examples
- fld_lines.cpp.
◆ drawSegments()
Python: |
---|
| _image | = | cv.ximgproc_FastLineDetector.drawSegments( | _image, lines[, draw_arrow] | ) |
Draws the line segments on a given image.
- Parameters
-
_image | The image, where the lines will be drawn. Should be bigger or equal to the image, where the lines were found. |
lines | A vector of the lines that needed to be drawn. |
draw_arrow | If true, arrow heads will be drawn. |
- Examples
- fld_lines.cpp.
The documentation for this class was generated from the following file:
@ SOBEL
Definition: edge_drawing.hpp:39
cv::String findFile(const cv::String &relative_path, bool required=true, bool silentMode=false)
Try to find requested data file.
virtual void detectLines(OutputArray lines)=0
Detects lines.
static MatExpr zeros(int rows, int cols, int type)
Returns a zero array of the specified size and type.
virtual std::vector< std::vector< Point > > getSegments()=0
virtual void detectEdges(InputArray src)=0
Detects edges and prepares them to detect lines and ellipses.
int waitKey(int delay=0)
Waits for a pressed key.
virtual void detectEllipses(OutputArray ellipses)=0
Detects circles and ellipses.
Template class for specifying the size of an image or rectangle.
Definition: types.hpp:315
int64_t int64
Definition: interface.h:61
virtual void drawSegments(InputOutputArray _image, InputArray lines, bool draw_arrow=false)=0
Draws the line segments on a given image.
int AnchorThresholdValue
threshold value used to create gradient image.
Definition: edge_drawing.hpp:54
virtual void detect(InputArray _image, OutputArray _lines)=0
Finds lines in the input image. This is the output of the default parameters of the algorithm on the ...
Mat imread(const String &filename, int flags=IMREAD_COLOR)
Loads an image from a file.
bool empty() const
Returns true if the array has no elements.
void polylines(InputOutputArray img, const Point *const *pts, const int *npts, int ncontours, bool isClosed, const Scalar &color, int thickness=1, int lineType=LINE_8, int shift=0)
#define CV_8UC3
Definition: interface.h:90
MatSize size
Definition: mat.hpp:2118
@ IMREAD_GRAYSCALE
If set, always convert image to the single channel grayscale image (codec internal conversion).
Definition: imgcodecs.hpp:71
int64 getTickCount()
Returns the number of ticks.
GOpaque< Size > size(const GMat &src)
Gets dimensions from Mat.
std::shared_ptr< _Tp > Ptr
Definition: cvstd_wrapper.hpp:23
Ptr< FastLineDetector > createFastLineDetector(int _length_threshold=10, float _distance_threshold=1.414213562f, double _canny_th1=50.0, double _canny_th2=50.0, int _canny_aperture_size=3, bool _do_merge=false)
Creates a smart pointer to a FastLineDetector object and initializes it.
Ptr< EdgeDrawing > createEdgeDrawing()
Creates a smart pointer to a EdgeDrawing object and initializes it.
void imshow(const String &winname, InputArray mat)
Displays an image in the specified window.
Definition: brightedges.hpp:47
double getTickFrequency()
Returns the number of ticks per second.
Scalar_< double > Scalar
Definition: types.hpp:669
n-dimensional dense array class
Definition: mat.hpp:801
int EdgeDetectionOperator
indicates the operator used for gradient calculation.The following operation flags are available(cv::...
Definition: edge_drawing.hpp:50
Designed for command line parsing.
Definition: utility.hpp:799
"black box" representation of the file storage associated with a file on disk.
Definition: affine.hpp:51
int GradientThresholdValue
threshold value used to create gradient image.
Definition: edge_drawing.hpp:52
void ellipse(InputOutputArray img, Point center, Size axes, double angle, double startAngle, double endAngle, const Scalar &color, int thickness=1, int lineType=LINE_8, int shift=0)
Draws a simple or thick elliptic arc or fills an ellipse sector.
Params params
Definition: edge_drawing.hpp:97
@ LINE_AA
antialiased line
Definition: imgproc.hpp:816