Skip to content

Commit 2566ef3

Browse files
committed
Merge pull request opencv#9526 from sturkmen72:update_documentation
2 parents 6bf8fe8 + d547c6b commit 2566ef3

File tree

5 files changed

+149
-64
lines changed

5 files changed

+149
-64
lines changed

modules/imgproc/include/opencv2/imgproc.hpp

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1192,6 +1192,7 @@ class CV_EXPORTS_W Subdiv2D
11921192

11931193
/** @example lsd_lines.cpp
11941194
An example using the LineSegmentDetector
1195+
\image html building_lsd.png "Sample output image" width=434 height=300
11951196
*/
11961197

11971198
/** @brief Line segment detector class
@@ -1347,6 +1348,11 @@ operation is shifted.
13471348
*/
13481349
CV_EXPORTS_W Mat getStructuringElement(int shape, Size ksize, Point anchor = Point(-1,-1));
13491350

1351+
/** @example Smoothing.cpp
1352+
Sample code for simple filters
1353+
![Sample screenshot](Smoothing_Tutorial_Result_Median_Filter.jpg)
1354+
Check @ref tutorial_gausian_median_blur_bilateral_filter "the corresponding tutorial" for more details
1355+
*/
13501356
/** @brief Blurs an image using the median filter.
13511357
13521358
The function smoothes an image using the median filter with the \f$\texttt{ksize} \times
@@ -1549,6 +1555,11 @@ CV_EXPORTS_W void sepFilter2D( InputArray src, OutputArray dst, int ddepth,
15491555
Point anchor = Point(-1,-1),
15501556
double delta = 0, int borderType = BORDER_DEFAULT );
15511557

1558+
/** @example Sobel_Demo.cpp
1559+
Sample code using Sobel and/or Scharr OpenCV functions to make a simple Edge Detector
1560+
![Sample screenshot](Sobel_Derivatives_Tutorial_Result.jpg)
1561+
Check @ref tutorial_sobel_derivatives "the corresponding tutorial" for more details
1562+
*/
15521563
/** @brief Calculates the first, second, third, or mixed image derivatives using an extended Sobel operator.
15531564
15541565
In all cases except one, the \f$\texttt{ksize} \times \texttt{ksize}\f$ separable kernel is used to
@@ -1681,7 +1692,9 @@ CV_EXPORTS_W void Laplacian( InputArray src, OutputArray dst, int ddepth,
16811692
//! @{
16821693

16831694
/** @example edge.cpp
1684-
An example on using the canny edge detector
1695+
This program demonstrates usage of the Canny edge detector
1696+
1697+
Check @ref tutorial_canny_detector "the corresponding tutorial" for more details
16851698
*/
16861699

16871700
/** @brief Finds edges in an image using the Canny algorithm @cite Canny86 .
@@ -1908,6 +1921,7 @@ CV_EXPORTS_W void goodFeaturesToTrack( InputArray image, OutputArray corners,
19081921

19091922
/** @example houghlines.cpp
19101923
An example using the Hough line detector
1924+
![Sample input image](Hough_Lines_Tutorial_Original_Image.jpg) ![Output image](Hough_Lines_Tutorial_Result.jpg)
19111925
*/
19121926

19131927
/** @brief Finds lines in a binary image using the standard Hough transform.
@@ -2105,7 +2119,9 @@ CV_EXPORTS_W void HoughCircles( InputArray image, OutputArray circles,
21052119
//! @{
21062120

21072121
/** @example morphology2.cpp
2108-
An example using the morphological operations
2122+
Advanced morphology Transformations sample code
2123+
![Sample screenshot](Morphology_2_Tutorial_Result.jpg)
2124+
Check @ref tutorial_opening_closing_hats "the corresponding tutorial" for more details
21092125
*/
21102126

21112127
/** @brief Erodes an image by using a specific structuring element.
@@ -2135,6 +2151,11 @@ CV_EXPORTS_W void erode( InputArray src, OutputArray dst, InputArray kernel,
21352151
int borderType = BORDER_CONSTANT,
21362152
const Scalar& borderValue = morphologyDefaultBorderValue() );
21372153

2154+
/** @example Morphology_1.cpp
2155+
Erosion and Dilation sample code
2156+
![Sample Screenshot-Erosion](Morphology_1_Tutorial_Erosion_Result.jpg)![Sample Screenshot-Dilation](Morphology_1_Tutorial_Dilation_Result.jpg)
2157+
Check @ref tutorial_erosion_dilatation "the corresponding tutorial" for more details
2158+
*/
21382159
/** @brief Dilates an image by using a specific structuring element.
21392160
21402161
The function dilates the source image using the specified structuring element that determines the
@@ -3384,6 +3405,7 @@ CV_EXPORTS_W void pyrMeanShiftFiltering( InputArray src, OutputArray dst,
33843405

33853406
/** @example grabcut.cpp
33863407
An example using the GrabCut algorithm
3408+
![Sample Screenshot](grabcut_output1.jpg)
33873409
*/
33883410

33893411
/** @brief Runs the GrabCut algorithm.
@@ -4406,7 +4428,8 @@ CV_EXPORTS_W void polylines(InputOutputArray img, InputArrayOfArrays pts,
44064428
int thickness = 1, int lineType = LINE_8, int shift = 0 );
44074429

44084430
/** @example contours2.cpp
4409-
An example using the drawContour functionality
4431+
An example program illustrates the use of cv::findContours and cv::drawContours
4432+
\image html WindowsQtContoursOutput.png "Screenshot of the program"
44104433
*/
44114434

44124435
/** @example segment_objects.cpp

modules/objdetect/include/opencv2/objdetect.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,8 @@ class CV_EXPORTS_W BaseCascadeClassifier : public Algorithm
216216
};
217217

218218
/** @example facedetect.cpp
219+
This program demonstrates usage of the Cascade classifier class
220+
\image html Cascade_Classifier_Tutorial_Result_Haar.jpg "Sample screenshot" width=321 height=254
219221
*/
220222
/** @brief Cascade classifier class for object detection.
221223
*/

samples/cpp/facedetect.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ using namespace cv;
88

99
static void help()
1010
{
11-
cout << "\nThis program demonstrates the cascade recognizer. Now you can use Haar or LBP features.\n"
11+
cout << "\nThis program demonstrates the use of cv::CascadeClassifier class to detect objects (Face + eyes). You can use Haar or LBP features.\n"
1212
"This classifier can recognize many kinds of rigid objects, once the appropriate classifier is trained.\n"
1313
"It's most known use is for faces.\n"
1414
"Usage:\n"

samples/cpp/lsd_lines.cpp

Lines changed: 39 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,50 @@
1-
#include <iostream>
2-
31
#include "opencv2/imgproc.hpp"
42
#include "opencv2/imgcodecs.hpp"
53
#include "opencv2/highgui.hpp"
4+
#include <iostream>
65

76
using namespace std;
87
using namespace cv;
98

109
int main(int argc, char** argv)
1110
{
12-
std::string in;
13-
cv::CommandLineParser parser(argc, argv, "{@input|../data/building.jpg|input image}{help h||show help message}");
14-
if (parser.has("help"))
11+
cv::CommandLineParser parser(argc, argv,
12+
"{input i|../data/building.jpg|input image}"
13+
"{refine r|false|if true use LSD_REFINE_STD method, if false use LSD_REFINE_NONE method}"
14+
"{canny c|false|use Canny edge detector}"
15+
"{overlay o|false|show result on input image}"
16+
"{help h|false|show help message}");
17+
18+
if (parser.get<bool>("help"))
1519
{
1620
parser.printMessage();
1721
return 0;
1822
}
19-
in = parser.get<string>("@input");
2023

21-
Mat image = imread(in, IMREAD_GRAYSCALE);
24+
parser.printMessage();
25+
26+
String filename = parser.get<String>("input");
27+
bool useRefine = parser.get<bool>("refine");
28+
bool useCanny = parser.get<bool>("canny");
29+
bool overlay = parser.get<bool>("overlay");
30+
31+
Mat image = imread(filename, IMREAD_GRAYSCALE);
2232

2333
if( image.empty() )
24-
{ return -1; }
34+
{
35+
cout << "Unable to load " << filename;
36+
return 1;
37+
}
2538

26-
#if 0
27-
Canny(image, image, 50, 200, 3); // Apply canny edge
28-
#endif
39+
imshow("Source Image", image);
40+
41+
if (useCanny)
42+
{
43+
Canny(image, image, 50, 200, 3); // Apply Canny edge detector
44+
}
2945

3046
// Create and LSD detector with standard or no refinement.
31-
#if 1
32-
Ptr<LineSegmentDetector> ls = createLineSegmentDetector(LSD_REFINE_STD);
33-
#else
34-
Ptr<LineSegmentDetector> ls = createLineSegmentDetector(LSD_REFINE_NONE);
35-
#endif
47+
Ptr<LineSegmentDetector> ls = useRefine ? createLineSegmentDetector(LSD_REFINE_STD) : createLineSegmentDetector(LSD_REFINE_NONE);
3648

3749
double start = double(getTickCount());
3850
vector<Vec4f> lines_std;
@@ -44,9 +56,17 @@ int main(int argc, char** argv)
4456
std::cout << "It took " << duration_ms << " ms." << std::endl;
4557

4658
// Show found lines
47-
Mat drawnLines(image);
48-
ls->drawSegments(drawnLines, lines_std);
49-
imshow("Standard refinement", drawnLines);
59+
if (!overlay || useCanny)
60+
{
61+
image = Scalar(0, 0, 0);
62+
}
63+
64+
ls->drawSegments(image, lines_std);
65+
66+
String window_name = useRefine ? "Result - standard refinement" : "Result - no refinement";
67+
window_name += useCanny ? " - Canny edge detector used" : "";
68+
69+
imshow(window_name, image);
5070

5171
waitKey();
5272
return 0;
Lines changed: 81 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,77 +1,117 @@
11
/**
22
* @file Sobel_Demo.cpp
3-
* @brief Sample code using Sobel and/or Scharr OpenCV functions to make a simple Edge Detector
3+
* @brief Sample code uses Sobel or Scharr OpenCV functions for edge detection
44
* @author OpenCV team
55
*/
66

77
#include "opencv2/imgproc.hpp"
88
#include "opencv2/imgcodecs.hpp"
99
#include "opencv2/highgui.hpp"
1010

11+
#include <iostream>
12+
1113
using namespace cv;
14+
using namespace std;
1215

1316
/**
1417
* @function main
1518
*/
1619
int main( int argc, char** argv )
1720
{
21+
cv::CommandLineParser parser(argc, argv,
22+
"{@input |../data/lena.jpg|input image}"
23+
"{ksize k|1|ksize (hit 'K' to increase its value)}"
24+
"{scale s|1|scale (hit 'S' to increase its value)}"
25+
"{delta d|0|delta (hit 'D' to increase its value)}"
26+
"{help h|false|show help message}");
27+
28+
cout << "The sample uses Sobel or Scharr OpenCV functions for edge detection\n\n";
29+
parser.printMessage();
30+
cout << "\nPress 'ESC' to exit program.\nPress 'R' to reset values ( ksize will be -1 equal to Scharr function )";
31+
1832
//![variables]
19-
Mat src, src_gray;
33+
Mat image,src, src_gray;
2034
Mat grad;
21-
const char* window_name = "Sobel Demo - Simple Edge Detector";
22-
int scale = 1;
23-
int delta = 0;
35+
const String window_name = "Sobel Demo - Simple Edge Detector";
36+
int ksize = parser.get<int>("ksize");
37+
int scale = parser.get<int>("scale");
38+
int delta = parser.get<int>("delta");
2439
int ddepth = CV_16S;
2540
//![variables]
2641

2742
//![load]
28-
String imageName("../data/lena.jpg"); // by default
29-
if (argc > 1)
43+
String imageName = parser.get<String>("@input"); // by default
44+
image = imread( imageName, IMREAD_COLOR ); // Load an image
45+
46+
if( image.empty() )
3047
{
31-
imageName = argv[1];
48+
return 1;
3249
}
33-
src = imread( imageName, IMREAD_COLOR ); // Load an image
34-
35-
if( src.empty() )
36-
{ return -1; }
3750
//![load]
3851

39-
//![reduce_noise]
40-
GaussianBlur( src, src, Size(3,3), 0, 0, BORDER_DEFAULT );
41-
//![reduce_noise]
52+
for (;;)
53+
{
54+
//![reduce_noise]
55+
GaussianBlur(image, src, Size(3, 3), 0, 0, BORDER_DEFAULT);
56+
//![reduce_noise]
4257

43-
//![convert_to_gray]
44-
cvtColor( src, src_gray, COLOR_BGR2GRAY );
45-
//![convert_to_gray]
58+
//![convert_to_gray]
59+
cvtColor(src, src_gray, COLOR_BGR2GRAY);
60+
//![convert_to_gray]
4661

47-
//![sobel]
48-
/// Generate grad_x and grad_y
49-
Mat grad_x, grad_y;
50-
Mat abs_grad_x, abs_grad_y;
62+
//![sobel]
63+
/// Generate grad_x and grad_y
64+
Mat grad_x, grad_y;
65+
Mat abs_grad_x, abs_grad_y;
5166

52-
/// Gradient X
53-
//Scharr( src_gray, grad_x, ddepth, 1, 0, scale, delta, BORDER_DEFAULT );
54-
Sobel( src_gray, grad_x, ddepth, 1, 0, 3, scale, delta, BORDER_DEFAULT );
67+
/// Gradient X
68+
Sobel(src_gray, grad_x, ddepth, 1, 0, ksize, scale, delta, BORDER_DEFAULT);
5569

56-
/// Gradient Y
57-
//Scharr( src_gray, grad_y, ddepth, 0, 1, scale, delta, BORDER_DEFAULT );
58-
Sobel( src_gray, grad_y, ddepth, 0, 1, 3, scale, delta, BORDER_DEFAULT );
59-
//![sobel]
70+
/// Gradient Y
71+
Sobel(src_gray, grad_y, ddepth, 0, 1, ksize, scale, delta, BORDER_DEFAULT);
72+
//![sobel]
6073

61-
//![convert]
62-
convertScaleAbs( grad_x, abs_grad_x );
63-
convertScaleAbs( grad_y, abs_grad_y );
64-
//![convert]
74+
//![convert]
75+
convertScaleAbs(grad_x, abs_grad_x);
76+
convertScaleAbs(grad_y, abs_grad_y);
77+
//![convert]
6578

66-
//![blend]
67-
/// Total Gradient (approximate)
68-
addWeighted( abs_grad_x, 0.5, abs_grad_y, 0.5, 0, grad );
69-
//![blend]
79+
//![blend]
80+
/// Total Gradient (approximate)
81+
addWeighted(abs_grad_x, 0.5, abs_grad_y, 0.5, 0, grad);
82+
//![blend]
7083

71-
//![display]
72-
imshow( window_name, grad );
73-
waitKey(0);
74-
//![display]
84+
//![display]
85+
imshow(window_name, grad);
86+
char key = (char)waitKey(0);
87+
//![display]
7588

89+
if(key == 27)
90+
{
91+
return 0;
92+
}
93+
94+
if (key == 'k' || key == 'K')
95+
{
96+
ksize = ksize < 30 ? ksize+2 : -1;
97+
}
98+
99+
if (key == 's' || key == 'S')
100+
{
101+
scale++;
102+
}
103+
104+
if (key == 'd' || key == 'D')
105+
{
106+
delta++;
107+
}
108+
109+
if (key == 'r' || key == 'R')
110+
{
111+
scale = 1;
112+
ksize = -1;
113+
delta = 0;
114+
}
115+
}
76116
return 0;
77117
}

0 commit comments

Comments
 (0)