In this tutorial you will learn how to use structured forests for the purpose of edge detection in an image.
16 "{i || input image file name}"
17 "{m || model file name}"
18 "{o || output image file name}"
21int main(
int argc,
const char** argv )
24 parser.about(
"This sample demonstrates usage of structured forests for fast edge detection");
25 parser.printMessage();
27 if ( !parser.check() )
38 Mat image = imread(inFilename, IMREAD_COLOR);
40 CV_Error(Error::StsError,
String(
"Cannot read image file: ") + inFilename);
43 if ( modelFilename.size() == 0)
54 createStructuredEdgeDetection(modelFilename);
58 std::cout <<
"createStructuredEdgeDetection() time : " << tm << std::endl;
64 pDollar->detectEdges(image, edges);
67 std::cout <<
"detectEdges() time : " << tm << std::endl;
74 pDollar->computeOrientation(edges, orientation_map);
78 pDollar->edgesNms(edges, orientation_map, edge_nms, 2, 0, 1,
true);
82 std::cout <<
"nms time : " << tm << std::endl;
85 if ( outFilename.size() == 0 )
87 imshow(
"edges", edges);
88 imshow(
"edges nms", edge_nms);
92 imwrite(outFilename, 255*edges);
Designed for command line parsing.
Definition utility.hpp:890
Template "trait" class for OpenCV primitive data types.
Definition traits.hpp:113
n-dimensional dense array class
Definition mat.hpp:951
a Class to measure passing time.
Definition utility.hpp:326
void start()
starts counting ticks.
Definition utility.hpp:335
void stop()
stops counting ticks.
Definition utility.hpp:341
void reset()
resets internal values.
Definition utility.hpp:430
std::string String
Definition cvstd.hpp:151
std::shared_ptr< _Tp > Ptr
Definition cvstd_wrapper.hpp:23
#define CV_Error(code, msg)
Call the error handler.
Definition exception.hpp:174
CV_EXPORTS_W bool imwrite(const String &filename, InputArray img, const std::vector< int > ¶ms=std::vector< int >())
Saves an image to a specified file.
int main(int argc, char *argv[])
Definition highgui_qt.cpp:3
Definition ximgproc.hpp:125