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}" 21 int 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() )
43 if ( modelFilename.
size() == 0)
58 std::cout <<
"createStructuredEdgeDetection() time : " << tm << std::endl;
67 std::cout <<
"detectEdges() time : " << tm << std::endl;
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 )
88 imshow(
"edges nms", edge_nms);
92 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
virtual void edgesNms(cv::InputArray edge_image, cv::InputArray orientation_image, cv::OutputArray dst, int r=2, int s=0, float m=1, bool isParallel=true) const =0
The function edgenms in edge image and suppress edges where edge is stronger in orthogonal direction...
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:333
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:812
void reset()
resets internal values.
Definition: utility.hpp:372
If set, always convert image to the 3 channel BGR color image.
Definition: imgcodecs.hpp:71
Ptr< StructuredEdgeDetection > createStructuredEdgeDetection(const String &model, Ptr< const RFFeatureGetter > howToGetFeatures=Ptr< RFFeatureGetter >())
a Class to measure passing time.
Definition: utility.hpp:292
Definition: brightedges.hpp:47
Template class for smart pointers with shared ownership.
Definition: cvstd.hpp:261
void stop()
stops counting ticks.
Definition: utility.hpp:308
void start()
starts counting ticks.
Definition: utility.hpp:302
virtual void detectEdges(cv::InputArray src, cv::OutputArray dst) const =0
The function detects edges in src and draw them to dst.
Template "trait" class for OpenCV primitive data types.
Definition: traits.hpp:112
Definition: cvstd.hpp:458
n-dimensional dense array class
Definition: mat.hpp:822
virtual void computeOrientation(cv::InputArray src, cv::OutputArray dst) const =0
The function computes orientation from edge image.
int waitKey(int delay=0)
Waits for a pressed key.