Skip to content

Commit 012fb23

Browse files
committed
Merge remote-tracking branch 'upstream/3.4' into merge-3.4
2 parents 4ed2c37 + bcd47ed commit 012fb23

File tree

5 files changed

+58
-62
lines changed

5 files changed

+58
-62
lines changed

modules/img_hash/src/radial_variance_hash.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ class RadialVarianceHashImpl CV_FINAL : public ImgHashBase::ImgHashImpl
266266
}
267267
else
268268
{
269-
hash = 0;
269+
hash.setTo(cv::Scalar::all(0));
270270
}
271271
}
272272

modules/ximgproc/include/opencv2/ximgproc/structured_edge_detection.hpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -102,31 +102,31 @@ class CV_EXPORTS_W StructuredEdgeDetection : public Algorithm
102102
103103
The algorithm underlies this function is much more robust to texture presence, than common
104104
approaches, e.g. Sobel
105-
@param _src source image (RGB, float, in [0;1]) to detect edges
106-
@param _dst destination image (grayscale, float, in [0;1]) where edges are drawn
105+
@param src source image (RGB, float, in [0;1]) to detect edges
106+
@param dst destination image (grayscale, float, in [0;1]) where edges are drawn
107107
@sa Sobel, Canny
108108
*/
109-
CV_WRAP virtual void detectEdges(cv::InputArray _src, cv::OutputArray _dst) const = 0;
109+
CV_WRAP virtual void detectEdges(cv::InputArray src, cv::OutputArray dst) const = 0;
110110

111111
/** @brief The function computes orientation from edge image.
112112
113-
@param _src edge image.
114-
@param _dst orientation image.
113+
@param src edge image.
114+
@param dst orientation image.
115115
*/
116-
CV_WRAP virtual void computeOrientation(cv::InputArray _src, cv::OutputArray _dst) const = 0;
116+
CV_WRAP virtual void computeOrientation(cv::InputArray src, cv::OutputArray dst) const = 0;
117117

118118

119119
/** @brief The function edgenms in edge image and suppress edges where edge is stronger in orthogonal direction.
120120
121121
@param edge_image edge image from detectEdges function.
122122
@param orientation_image orientation image from computeOrientation function.
123-
@param _dst suppressed image (grayscale, float, in [0;1])
123+
@param dst suppressed image (grayscale, float, in [0;1])
124124
@param r radius for NMS suppression.
125125
@param s radius for boundary suppression.
126126
@param m multiplier for conservative suppression.
127127
@param isParallel enables/disables parallel computing.
128128
*/
129-
CV_WRAP 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;
129+
CV_WRAP 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;
130130
};
131131

132132
/*!
Lines changed: 36 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,29 @@
11
/**************************************************************************************
2-
The structered edge demo requires you to provide a model.
2+
The structured forests for fast edge detection demo requires you to provide a model.
33
This model can be found at the opencv_extra repository on Github on the following link:
44
https://github.com/opencv/opencv_extra/blob/master/testdata/cv/ximgproc/model.yml.gz
55
***************************************************************************************/
66

77
#include <opencv2/ximgproc.hpp>
88
#include "opencv2/highgui.hpp"
9-
#include "opencv2/core/utility.hpp"
109
#include <iostream>
1110

1211
using namespace cv;
1312
using namespace cv::ximgproc;
1413

1514
const char* keys =
1615
{
17-
"{i || input image name}"
18-
"{m || model name}"
19-
"{o || output image name}"
16+
"{i || input image file name}"
17+
"{m || model file name}"
18+
"{o || output image file name}"
2019
};
2120

2221
int main( int argc, const char** argv )
2322
{
24-
bool printHelp = ( argc == 1 );
25-
printHelp = printHelp || ( argc == 2 && String(argv[1]) == "--help" );
26-
printHelp = printHelp || ( argc == 2 && String(argv[1]) == "-h" );
27-
28-
if ( printHelp )
29-
{
30-
std::cout << "\nThis sample demonstrates structured forests for fast edge detection\n"
31-
"Call:\n"
32-
" structured_edge_detection -i=in_image_name -m=model_name [-o=out_image_name]\n\n";
33-
return 0;
34-
}
35-
3623
CommandLineParser parser(argc, argv, keys);
24+
parser.about("This sample demonstrates usage of structured forests for fast edge detection");
25+
parser.printMessage();
26+
3727
if ( !parser.check() )
3828
{
3929
parser.printErrors();
@@ -44,39 +34,63 @@ int main( int argc, const char** argv )
4434
String inFilename = parser.get<String>("i");
4535
String outFilename = parser.get<String>("o");
4636

47-
Mat image = imread(inFilename, 1);
37+
//! [imread]
38+
Mat image = imread(inFilename, IMREAD_COLOR);
4839
if ( image.empty() )
4940
CV_Error(Error::StsError, String("Cannot read image file: ") + inFilename);
41+
//! [imread]
5042

5143
if ( modelFilename.size() == 0)
5244
CV_Error(Error::StsError, String("Empty model name"));
5345

46+
//! [convert]
5447
image.convertTo(image, DataType<float>::type, 1/255.0);
48+
//! [convert]
5549

56-
Mat edges(image.size(), image.type());
57-
50+
TickMeter tm;
51+
tm.start();
52+
//! [create]
5853
Ptr<StructuredEdgeDetection> pDollar =
5954
createStructuredEdgeDetection(modelFilename);
55+
//! [create]
56+
57+
tm.stop();
58+
std::cout << "createStructuredEdgeDetection() time : " << tm << std::endl;
59+
60+
tm.reset();
61+
tm.start();
62+
//! [detect]
63+
Mat edges;
6064
pDollar->detectEdges(image, edges);
65+
//! [detect]
66+
tm.stop();
67+
std::cout << "detectEdges() time : " << tm << std::endl;
6168

69+
tm.reset();
70+
tm.start();
71+
//! [nms]
6272
// computes orientation from edge map
6373
Mat orientation_map;
6474
pDollar->computeOrientation(edges, orientation_map);
6575

6676
// suppress edges
6777
Mat edge_nms;
6878
pDollar->edgesNms(edges, orientation_map, edge_nms, 2, 0, 1, true);
79+
//! [nms]
80+
81+
tm.stop();
82+
std::cout << "nms time : " << tm << std::endl;
6983

84+
//! [imshow]
7085
if ( outFilename.size() == 0 )
7186
{
72-
namedWindow("edges", 1);
7387
imshow("edges", edges);
74-
namedWindow("edges nms", 1);
7588
imshow("edges nms", edge_nms);
7689
waitKey(0);
7790
}
7891
else
7992
imwrite(outFilename, 255*edges);
93+
//! [imshow]
8094

8195
return 0;
8296
}

modules/ximgproc/test/test_fld.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,8 @@ TEST_F(ximgproc_ED, ManySmallCircles)
292292
size_t lines_size = 6264;
293293
size_t ellipses_size = 2449;
294294
EXPECT_EQ(detector->getSegments().size(), segments_size);
295-
EXPECT_EQ(lines.size(), lines_size);
295+
EXPECT_GE(lines.size(), lines_size);
296+
EXPECT_LE(lines.size(), lines_size + 2);
296297
EXPECT_EQ(ellipses.size(), ellipses_size);
297298
}
298299
}} // namespace

modules/ximgproc/tutorials/prediction.markdown

Lines changed: 11 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -46,41 +46,22 @@ Explanation
4646
-----------
4747

4848
-# **Load source color image**
49-
@code{.cpp}
50-
cv::Mat image = cv::imread(inFilename, 1);
51-
if ( image.empty() )
52-
{
53-
printf("Cannot read image file: %s\n", inFilename.c_str());
54-
return -1;
55-
}
56-
@endcode
57-
58-
-# **Convert source image to [0;1] range**
59-
@code{.cpp}
60-
image.convertTo(image, cv::DataType<float>::type, 1/255.0);
61-
@endcode
49+
50+
@snippet ximgproc/samples/structured_edge_detection.cpp imread
51+
52+
-# **Convert source image to float [0;1] range**
53+
54+
@snippet ximgproc/samples/structured_edge_detection.cpp convert
6255

6356
-# **Run main algorithm**
64-
@code{.cpp}
65-
cv::Mat edges(image.size(), image.type());
6657

67-
cv::Ptr<StructuredEdgeDetection> pDollar =
68-
cv::createStructuredEdgeDetection(modelFilename);
69-
pDollar->detectEdges(image, edges);
70-
@endcode
58+
@snippet ximgproc/samples/structured_edge_detection.cpp create
59+
@snippet ximgproc/samples/structured_edge_detection.cpp detect
60+
@snippet ximgproc/samples/structured_edge_detection.cpp nms
7161

7262
-# **Show results**
73-
@code{.cpp}
74-
if ( outFilename == "" )
75-
{
76-
cv::namedWindow("edges", 1);
77-
cv::imshow("edges", edges);
78-
79-
cv::waitKey(0);
80-
}
81-
else
82-
cv::imwrite(outFilename, 255*edges);
83-
@endcode
63+
64+
@snippet ximgproc/samples/structured_edge_detection.cpp imshow
8465

8566
Literature
8667
----------

0 commit comments

Comments
 (0)