In this tutorial you will learn how to use structured forests for the purpose of edge detection in an image.
16 "{i || input image name}" 18 "{o || output image name}" 21 int main(
int argc,
const char** argv )
23 bool printHelp = ( argc == 1 );
24 printHelp = printHelp || ( argc == 2 && std::string(argv[1]) ==
"--help" );
25 printHelp = printHelp || ( argc == 2 && std::string(argv[1]) ==
"-h" );
29 printf(
"\nThis sample demonstrates structured forests for fast edge detection\n" 31 " structured_edge_detection -i=in_image_name -m=model_name [-o=out_image_name]\n\n");
36 if ( !parser.check() )
42 std::string modelFilename = parser.get<std::string>(
"m");
43 std::string inFilename = parser.get<std::string>(
"i");
44 std::string outFilename = parser.get<std::string>(
"o");
49 printf(
"Cannot read image file: %s\n", inFilename.c_str());
55 cv::Mat edges(image.size(), image.type());
59 pDollar->detectEdges(image, edges);
61 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:734
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:280
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.