In this tutorial you will learn how to use structured forests for the purpose of edge detection in an image.
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.
Definition: affine.hpp:51
Designed for command line parsing.
Definition: utility.hpp:612
Ptr< StructuredEdgeDetection > createStructuredEdgeDetection(const String &model, Ptr< const RFFeatureGetter > howToGetFeatures=Ptr< RFFeatureGetter >())
void namedWindow(const String &winname, int flags=WINDOW_AUTOSIZE)
Creates a window.
Definition: disparity_filter.hpp:45
Template class for smart pointers with shared ownership.
Definition: cvstd.hpp:283
Template "trait" class for OpenCV primitive data types.
Definition: traits.hpp:106
n-dimensional dense array class
Definition: mat.hpp:740
int waitKey(int delay=0)
Waits for a pressed key.