In this tutorial you will learn how to use structured forests for the purpose of edge detection in an image.
17 "{i || input image name}" 19 "{o || output image name}" 22 int main(
int argc,
const char** argv )
24 bool printHelp = ( argc == 1 );
25 printHelp = printHelp || ( argc == 2 &&
String(argv[1]) ==
"--help" );
26 printHelp = printHelp || ( argc == 2 &&
String(argv[1]) ==
"-h" );
30 std::cout <<
"\nThis sample demonstrates structured forests for fast edge detection\n" 32 " structured_edge_detection -i=in_image_name -m=model_name [-o=out_image_name]\n\n";
37 if ( !parser.check() )
47 Mat image =
imread(inFilename, 1);
51 if ( modelFilename.
size() == 0)
56 Mat edges(image.size(), image.type());
60 pDollar->detectEdges(image, edges);
64 pDollar->computeOrientation(edges, orientation_map);
68 pDollar->edgesNms(edges, orientation_map, edge_nms, 2, 0, 1,
true);
70 if ( outFilename.size() == 0 )
75 imshow(
"edges nms", edge_nms);
79 imwrite(outFilename, 255*edges);
bool imwrite(const String &filename, InputArray img, const std::vector< int > ¶ms=std::vector< int >())
Saves an image to a specified file.
unknown /unspecified error
Definition: base.hpp:71
Mat imread(const String &filename, int flags=IMREAD_COLOR)
Loads an image from a file.
#define CV_Error(code, msg)
Call the error handler.
Definition: base.hpp:405
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:784
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: deriche_filter.hpp:44
Template class for smart pointers with shared ownership.
Definition: cvstd.hpp:261
Template "trait" class for OpenCV primitive data types.
Definition: traits.hpp:106
Definition: cvstd.hpp:458
int waitKey(int delay=0)
Waits for a pressed key.