In this tutorial you will learn how to use structured forests for the purpose of edge detection in an image.
6 using namespace cv::ximgproc;
10 "{i || input image name}"
12 "{o || output image name}"
15 int main(
int argc,
const char** argv )
17 bool printHelp = ( argc == 1 );
18 printHelp = printHelp || ( argc == 2 && std::string(argv[1]) ==
"--help" );
19 printHelp = printHelp || ( argc == 2 && std::string(argv[1]) ==
"-h" );
23 printf(
"\nThis sample demonstrates structured forests for fast edge detection\n"
25 " structured_edge_detection -i=in_image_name -m=model_name [-o=out_image_name]\n\n");
30 if ( !parser.check() )
36 std::string modelFilename = parser.get<std::string>(
"m");
37 std::string inFilename = parser.get<std::string>(
"i");
38 std::string outFilename = parser.get<std::string>(
"o");
43 printf(
"Cannot read image file: %s\n", inFilename.c_str());
49 cv::Mat edges(image.size(), image.type());
53 pDollar->detectEdges(image, edges);
55 if ( outFilename ==
"" )
bool imwrite(const String &filename, InputArray img, const std::vector< int > ¶ms=std::vector< int >())
Saves an image to a specified file.
Mat imread(const String &filename, int flags=IMREAD_COLOR)
Loads an image from a file.
void imshow(const String &winname, InputArray mat)
Displays an image in the specified window.
designed for command line arguments parsing
Definition: utility.hpp:594
Ptr< StructuredEdgeDetection > createStructuredEdgeDetection(const String &model, Ptr< const RFFeatureGetter > howToGetFeatures=Ptr< RFFeatureGetter >())
void namedWindow(const String &winname, int flags=WINDOW_AUTOSIZE)
Creates a window.
Template class for smart pointers with shared ownership.
Definition: cvstd.hpp:283
Template "trait" class for OpenCV primitive data types.
Definition: traits.hpp:106
int main(int argc, const char *argv[])
Definition: facerec_demo.cpp:67
n-dimensional dense array class
Definition: mat.hpp:726
int waitKey(int delay=0)
Waits for a pressed key.