#include <iostream>
int main(
int argc,
char** argv)
{
"{input i|building.jpg|input image}"
"{refine r|false|if true use LSD_REFINE_STD method, if false use LSD_REFINE_NONE method}"
"{canny c|false|use Canny edge detector}"
"{overlay o|false|show result on input image}"
"{help h|false|show help message}");
if (parser.
get<
bool>(
"help"))
{
return 0;
}
bool useRefine = parser.
get<
bool>(
"refine");
bool useCanny = parser.
get<
bool>(
"canny");
bool overlay = parser.
get<
bool>(
"overlay");
if( image.empty() )
{
cout << "Unable to load " << filename;
return 1;
}
imshow(
"Source Image", image);
if (useCanny)
{
Canny(image, image, 50, 200, 3);
}
vector<Vec4f> lines_std;
ls->detect(image, lines_std);
std::cout << "It took " << duration_ms << " ms." << std::endl;
if (!overlay || useCanny)
{
}
ls->drawSegments(image, lines_std);
String window_name = useRefine ?
"Result - standard refinement" :
"Result - no refinement";
window_name += useCanny ? " - Canny edge detector used" : "";
return 0;
}
Designed for command line parsing.
Definition: utility.hpp:890
T get(const String &name, bool space_delete=true) const
Access arguments by name.
Definition: utility.hpp:956
void printMessage() const
Print help message.
std::string String
Definition: cvstd.hpp:149
Scalar_< double > Scalar
Definition: modules/core/include/opencv2/core/types.hpp:709
cv::String findFile(const cv::String &relative_path, bool required=true, bool silentMode=false)
Try to find requested data file.
double getTickFrequency()
Returns the number of ticks per second.
int64 getTickCount()
Returns the number of ticks.
void imshow(const String &winname, InputArray mat)
Displays an image in the specified window.
int waitKey(int delay=0)
Waits for a pressed key.
@ IMREAD_GRAYSCALE
If set, always convert image to the single channel grayscale image (codec internal conversion).
Definition: imgcodecs.hpp:70
CV_EXPORTS_W Mat imread(const String &filename, int flags=IMREAD_COLOR_BGR)
Loads an image from a file.
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 .
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_NONE
No refinement applied.
Definition: imgproc/include/opencv2/imgproc.hpp:494
@ LSD_REFINE_STD
Standard refinement is applied. E.g. breaking arches into smaller straighter line approximations.
Definition: imgproc/include/opencv2/imgproc.hpp:495
int main(int argc, char *argv[])
Definition: highgui_qt.cpp:3
Definition: core/include/opencv2/core.hpp:107