#include <iostream>
int main(
int argc,
char** argv)
{
string in;
CommandLineParser parser(argc, argv,
"{@input|corridor.jpg|input image}{help h||show help message}");
{
return 0;
}
in = samples::findFile(parser.
get<
string>(
"@input"));
Mat image = imread(in, IMREAD_GRAYSCALE);
{
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++) {
double freq = getTickFrequency();
lines.clear();
int64 start = getTickCount();
fld->detect(image, lines);
double duration_ms = double(getTickCount() - start) * 1000 / freq;
cout << "Elapsed time for FLD " << duration_ms << " ms." << endl;
}
Mat line_image_fld(image);
fld->drawSegments(line_image_fld, lines);
imshow("FLD result", line_image_fld);
waitKey(1);
ed->params.EdgeDetectionOperator = EdgeDrawing::SOBEL;
ed->params.GradientThresholdValue = 38;
ed->params.AnchorThresholdValue = 8;
vector<Vec6d> ellipses;
for (int run_count = 0; run_count < 5; run_count++) {
double freq = getTickFrequency();
lines.clear();
int64 start = getTickCount();
ed->detectEdges(image);
ed->detectLines(lines);
double duration_ms = double(getTickCount() - start) * 1000 / freq;
cout << "Elapsed time for EdgeDrawing detectLines " << duration_ms << " ms." << endl;
start = getTickCount();
ed->detectEllipses(ellipses);
duration_ms = double(getTickCount() - start) * 1000 / freq;
cout << "Elapsed time for EdgeDrawing detectEllipses " << duration_ms << " ms." << endl;
}
vector<vector<Point> > segments = ed->getSegments();
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);
fld->drawSegments(line_image_ed, lines);
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);
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.
bool has(const String &name) const
Check if field was provided in the command line.
n-dimensional dense array class
Definition mat.hpp:951
MatSize size
Definition mat.hpp:2448
bool empty() const
Returns true if the array has no elements.
Template class for specifying the size of an image or rectangle.
Definition types.hpp:338
std::shared_ptr< _Tp > Ptr
Definition cvstd_wrapper.hpp:23
int64_t int64
Definition interface.h:38
#define CV_8UC3
Definition interface.h:79
int main(int argc, char *argv[])
Definition highgui_qt.cpp:3
Definition ximgproc.hpp:125