 |
OpenCV
3.2.0
Open Source Computer Vision
|
An example using the LineSegmentDetector
#include <iostream>
using namespace std;
int main(int argc, char** argv)
{
std::string in;
cv::CommandLineParser parser(argc, argv,
"{@input|../data/building.jpg|input image}{help h||show help message}");
{
return 0;
}
in = parser.
get<
string>(
"@input");
if( image.empty() )
{ return -1; }
#if 0
Canny(image, image, 50, 200, 3);
#endif
#if 1
#else
#endif
vector<Vec4f> lines_std;
std::cout << "It took " << duration_ms << " ms." << std::endl;
imshow(
"Standard refinement", drawnLines);
return 0;
}
@ LSD_REFINE_NONE
No refinement applied.
Definition: imgproc.hpp:479
T get(const String &name, bool space_delete=true) const
Access arguments by name.
Definition: utility.hpp:801
int waitKey(int delay=0)
Waits for a pressed key.
void Canny(InputArray image, OutputArray edges, double threshold1, double threshold2, int apertureSize=3, bool L2gradient=false)
Finds edges in an image using the Canny algorithm .
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
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.
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.
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
void printMessage() const
Print help message.
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.
@ LSD_REFINE_STD
Standard refinement is applied. E.g. breaking arches into smaller straighter line approximations.
Definition: imgproc.hpp:480
bool has(const String &name) const
Check if field was provided in the command line.