 |
OpenCV
3.2.0
Open Source Computer Vision
|
Class implementing the FLD (Fast Line Detector) algorithm described in [Lee14] .
More...
#include "fast_line_detector.hpp"
Class implementing the FLD (Fast Line Detector) algorithm described in [Lee14] .
#include <iostream>
using namespace std;
int main(int argc, char** argv)
{
std::string in;
cv::CommandLineParser parser(argc, argv,
"{@input|../samples/data/corridor.jpg|input image}{help h||show help message}");
if (parser.has("help"))
{
parser.printMessage();
return 0;
}
in = parser.get<string>("@input");
if( image.empty() )
{
return -1;
}
vector<Vec4f> lines_lsd;
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_fld;
for(int run_count = 0; run_count < 10; run_count++) {
lines_lsd.clear();
lsd->
detect(image, lines_lsd);
double duration_ms_lsd = double(
getTickCount() - start_lsd) * 1000 / freq;
std::cout << "Elapsed time for LSD: " << duration_ms_lsd << " ms." << std::endl;
lines_fld.clear();
fld->
detect(image, lines_fld);
double duration_ms = double(
getTickCount() - start) * 1000 / freq;
std::cout << "Ealpsed time for FLD " << duration_ms << " ms." << std::endl;
}
Mat line_image_lsd(image);
imshow(
"LSD result", line_image_lsd);
Mat line_image_fld(image);
imshow(
"FLD result", line_image_fld);
return 0;
}
◆ ~FastLineDetector()
| virtual cv::ximgproc::FastLineDetector::~FastLineDetector |
( |
| ) |
|
|
virtual |
◆ detect()
Finds lines in the input image. This is the output of the default parameters of the algorithm on the above shown 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()
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:
int waitKey(int delay=0)
Waits for a pressed key.
virtual void drawSegments(InputOutputArray _image, InputArray lines)=0
Draws the line segments on a given image.
@ IMREAD_GRAYSCALE
If set, always convert image to the single channel grayscale image.
Definition: imgcodecs.hpp:66
int64_t int64
Definition: interface.h:57
virtual void drawSegments(InputOutputArray _image, InputArray lines, bool draw_arrow=false)=0
Draws the line segments on a given image.
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.
Template class for smart pointers with shared ownership.
Definition: cvstd.hpp:281
int64 getTickCount()
Returns the number of ticks.
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.
virtual void detect(InputArray _image, OutputArray _lines, OutputArray width=noArray(), OutputArray prec=noArray(), OutputArray nfa=noArray())=0
Finds lines in the input image.
void imshow(const String &winname, InputArray mat)
Displays an image in the specified window.
Definition: deriche_filter.hpp:44
double getTickFrequency()
Returns the number of ticks per second.
n-dimensional dense array class
Definition: mat.hpp:741
Designed for command line parsing.
Definition: utility.hpp:735
Definition: affine.hpp:52
Ptr< LineSegmentDetector > createLineSegmentDetector(int _refine=LSD_REFINE_STD, double _scale=0.8, double _sigma_scale=0.6, double _quant=2.0, double _ang_th=22.5, double _log_eps=0, double _density_th=0.7, int _n_bins=1024)
Creates a smart pointer to a LineSegmentDetector object and initializes it.