#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");
Mat image = imread(filename, IMREAD_GRAYSCALE);
if( image.empty() )
{
cout << "Unable to load " << filename;
return 1;
}
imshow("Source Image", image);
if (useCanny)
{
Canny(image, image, 50, 200, 3);
}
Ptr<LineSegmentDetector> ls = useRefine ? createLineSegmentDetector(LSD_REFINE_STD) : createLineSegmentDetector(LSD_REFINE_NONE);
double start = double(getTickCount());
vector<Vec4f> lines_std;
ls->detect(image, lines_std);
double duration_ms = (double(getTickCount()) - start) * 1000 / getTickFrequency();
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" : "";
imshow(window_name, image);
waitKey();
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.
n-dimensional dense array class
Definition mat.hpp:828
std::string String
Definition cvstd.hpp:151
std::shared_ptr< _Tp > Ptr
Definition cvstd_wrapper.hpp:23
int main(int argc, char *argv[])
Definition highgui_qt.cpp:3