Skip to content

Commit c95a973

Browse files
committed
Merge pull request opencv#9235 from sturkmen72:patch-3
2 parents 2e608b1 + 8948080 commit c95a973

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+260
-187
lines changed

modules/core/include/opencv2/core.hpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,9 @@ of p and len.
273273
*/
274274
CV_EXPORTS_W int borderInterpolate(int p, int len, int borderType);
275275

276+
/** @example copyMakeBorder_demo.cpp
277+
An example using copyMakeBorder function
278+
*/
276279
/** @brief Forms a border around an image.
277280
278281
The function copies the source image into the middle of the destination image. The areas to the
@@ -471,6 +474,9 @@ The function can also be emulated with a matrix expression, for example:
471474
*/
472475
CV_EXPORTS_W void scaleAdd(InputArray src1, double alpha, InputArray src2, OutputArray dst);
473476

477+
/** @example AddingImagesTrackbar.cpp
478+
479+
*/
474480
/** @brief Calculates the weighted sum of two arrays.
475481
476482
The function addWeighted calculates the weighted sum of two arrays as follows:

modules/imgproc/include/opencv2/imgproc.hpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2795,6 +2795,9 @@ CV_EXPORTS_W void adaptiveThreshold( InputArray src, OutputArray dst,
27952795
//! @addtogroup imgproc_filter
27962796
//! @{
27972797

2798+
/** @example Pyramids.cpp
2799+
An example using pyrDown and pyrUp functions
2800+
*/
27982801
/** @brief Blurs an image and downsamples it.
27992802
28002803
By default, size of the output image is computed as `Size((src.cols+1)/2, (src.rows+1)/2)`, but in
@@ -3669,6 +3672,9 @@ enum TemplateMatchModes {
36693672
TM_CCOEFF_NORMED = 5 //!< \f[R(x,y)= \frac{ \sum_{x',y'} (T'(x',y') \cdot I'(x+x',y+y')) }{ \sqrt{\sum_{x',y'}T'(x',y')^2 \cdot \sum_{x',y'} I'(x+x',y+y')^2} }\f]
36703673
};
36713674

3675+
/** @example MatchTemplate_Demo.cpp
3676+
An example using Template Matching algorithm
3677+
*/
36723678
/** @brief Compares a template against overlapped image regions.
36733679
36743680
The function slides through image , compares the overlapped patches of size \f$w \times h\f$ against
@@ -4134,6 +4140,9 @@ enum ColormapTypes
41344140
COLORMAP_PARULA = 12 //!< ![parula](pics/colormaps/colorscale_parula.jpg)
41354141
};
41364142

4143+
/** @example falsecolor.cpp
4144+
An example using applyColorMap function
4145+
*/
41374146
/** @brief Applies a GNU Octave/MATLAB equivalent colormap on a given image.
41384147
41394148
@param src The source image, grayscale or colored of type CV_8UC1 or CV_8UC3.
@@ -4216,6 +4225,9 @@ CV_EXPORTS void rectangle(CV_IN_OUT Mat& img, Rect rec,
42164225
const Scalar& color, int thickness = 1,
42174226
int lineType = LINE_8, int shift = 0);
42184227

4228+
/** @example Drawing_2.cpp
4229+
An example using drawing functions
4230+
*/
42194231
/** @brief Draws a circle.
42204232
42214233
The function circle draws a simple or filled circle with a given center and radius.
@@ -4339,6 +4351,9 @@ CV_EXPORTS void fillPoly(Mat& img, const Point** pts,
43394351
const Scalar& color, int lineType = LINE_8, int shift = 0,
43404352
Point offset = Point() );
43414353

4354+
/** @example Drawing_1.cpp
4355+
An example using drawing functions
4356+
*/
43424357
/** @brief Fills the area bounded by one or more polygons.
43434358
43444359
The function fillPoly fills an area bounded by several polygonal contours. The function can fill

modules/objdetect/include/opencv2/objdetect.hpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,8 @@ class CV_EXPORTS_W BaseCascadeClassifier : public Algorithm
215215
virtual Ptr<MaskGenerator> getMaskGenerator() = 0;
216216
};
217217

218+
/** @example facedetect.cpp
219+
*/
218220
/** @brief Cascade classifier class for object detection.
219221
*/
220222
class CV_EXPORTS_W CascadeClassifier
@@ -348,6 +350,8 @@ struct DetectionROI
348350
std::vector<double> confidences;
349351
};
350352

353+
/**@example peopledetect.cpp
354+
*/
351355
struct CV_EXPORTS_W HOGDescriptor
352356
{
353357
public:

modules/photo/include/opencv2/photo.hpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -730,6 +730,9 @@ CV_EXPORTS_W void decolor( InputArray src, OutputArray grayscale, OutputArray co
730730
//! @addtogroup photo_clone
731731
//! @{
732732

733+
/** @example cloning_demo.cpp
734+
An example using seamlessClone function
735+
*/
733736
/** @brief Image editing tasks concern either global changes (color/intensity corrections, filters,
734737
deformations) or local changes concerned to a selection. Here we are interested in achieving local
735738
changes, ones that are restricted to a region manually selected (ROI), in a seamless and effortless
@@ -833,6 +836,9 @@ CV_EXPORTS_W void edgePreservingFilter(InputArray src, OutputArray dst, int flag
833836
CV_EXPORTS_W void detailEnhance(InputArray src, OutputArray dst, float sigma_s = 10,
834837
float sigma_r = 0.15f);
835838

839+
/** @example npr_demo.cpp
840+
An example using non-photorealistic line drawing functions
841+
*/
836842
/** @brief Pencil-like non-photorealistic line drawing
837843
838844
@param src Input 8-bit 3-channel image.

modules/shape/include/opencv2/shape/shape_distance.hpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,9 @@ namespace cv
5353
//! @addtogroup shape
5454
//! @{
5555

56+
/** @example shape_example.cpp
57+
An example using shape distance algorithm
58+
*/
5659
/** @brief Abstract base class for shape distance algorithms.
5760
*/
5861
class CV_EXPORTS_W ShapeDistanceExtractor : public Algorithm

modules/video/include/opencv2/video/tracking.hpp

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,9 @@ See the OpenCV sample camshiftdemo.c that tracks colored objects.
7878
*/
7979
CV_EXPORTS_W RotatedRect CamShift( InputArray probImage, CV_IN_OUT Rect& window,
8080
TermCriteria criteria );
81-
81+
/** @example camshiftdemo.cpp
82+
An example using the mean-shift tracking algorithm
83+
*/
8284
/** @brief Finds an object on a back projection image.
8385
8486
@param probImage Back projection of the object histogram. See calcBackProject for details.
@@ -97,8 +99,6 @@ projection and remove the noise. For example, you can do this by retrieving conn
9799
with findContours , throwing away contours with small area ( contourArea ), and rendering the
98100
remaining contours with drawContours.
99101
100-
@note
101-
- A mean-shift tracking sample can be found at opencv_source_code/samples/cpp/camshiftdemo.cpp
102102
*/
103103
CV_EXPORTS_W int meanShift( InputArray probImage, CV_IN_OUT Rect& window, TermCriteria criteria );
104104

@@ -123,6 +123,9 @@ CV_EXPORTS_W int buildOpticalFlowPyramid( InputArray img, OutputArrayOfArrays py
123123
int derivBorder = BORDER_CONSTANT,
124124
bool tryReuseInputImage = true );
125125

126+
/** @example lkdemo.cpp
127+
An example using the Lucas-Kanade optical flow algorithm
128+
*/
126129
/** @brief Calculates an optical flow for a sparse feature set using the iterative Lucas-Kanade method with
127130
pyramids.
128131
@@ -258,6 +261,10 @@ enum
258261
MOTION_HOMOGRAPHY = 3
259262
};
260263

264+
/** @example image_alignment.cpp
265+
An example using the image alignment ECC algorithm
266+
*/
267+
261268
/** @brief Finds the geometric transform (warp) between two images in terms of the ECC criterion @cite EP08 .
262269
263270
@param templateImage single-channel template image; CV_8U or CV_32F array.
@@ -313,25 +320,20 @@ CV_EXPORTS_W double findTransformECC( InputArray templateImage, InputArray input
313320
TermCriteria criteria = TermCriteria(TermCriteria::COUNT+TermCriteria::EPS, 50, 0.001),
314321
InputArray inputMask = noArray());
315322

323+
/** @example kalman.cpp
324+
An example using the standard Kalman filter
325+
*/
316326
/** @brief Kalman filter class.
317327
318328
The class implements a standard Kalman filter <http://en.wikipedia.org/wiki/Kalman_filter>,
319329
@cite Welch95 . However, you can modify transitionMatrix, controlMatrix, and measurementMatrix to get
320-
an extended Kalman filter functionality. See the OpenCV sample kalman.cpp.
321-
322-
@note
323-
324-
- An example using the standard Kalman filter can be found at
325-
opencv_source_code/samples/cpp/kalman.cpp
330+
an extended Kalman filter functionality.
331+
@note In C API when CvKalman\* kalmanFilter structure is not needed anymore, it should be released
332+
with cvReleaseKalman(&kalmanFilter)
326333
*/
327334
class CV_EXPORTS_W KalmanFilter
328335
{
329336
public:
330-
/** @brief The constructors.
331-
332-
@note In C API when CvKalman\* kalmanFilter structure is not needed anymore, it should be released
333-
with cvReleaseKalman(&kalmanFilter)
334-
*/
335337
CV_WRAP KalmanFilter();
336338
/** @overload
337339
@param dynamParams Dimensionality of the state.

modules/videoio/include/opencv2/videoio.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -808,12 +808,12 @@ class CV_EXPORTS_W VideoCapture
808808

809809
class IVideoWriter;
810810

811+
/** @example videowriter_basic.cpp
812+
An example using VideoCapture and VideoWriter class
813+
*/
811814
/** @brief Video writer class.
812815
813816
The class provides C++ API for writing video files or image sequences.
814-
815-
Here is how the class can be used:
816-
@include samples/cpp/videowriter_basic.cpp
817817
*/
818818
class CV_EXPORTS_W VideoWriter
819819
{

samples/cpp/create_mask.cpp

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,6 @@ int flag1 = 0;
3333

3434
int minx,miny,maxx,maxy,lenx,leny;
3535

36-
int channel;
37-
3836
void mouseHandler(int, int, int, int, void*);
3937

4038
void mouseHandler(int event, int x, int y, int, void*)
@@ -121,14 +119,22 @@ void mouseHandler(int event, int x, int y, int, void*)
121119
}
122120
}
123121

122+
static void help()
123+
{
124+
cout << "\nThis program demonstrates using mouse events"
125+
"\nCall:\n"
126+
"./create_mask <image_name>\n"
127+
"\n"
128+
"\tleft mouse button - set a point to create mask shape"
129+
"\n"
130+
"\tright mouse button - create mask from points\n"
131+
"\tmiddle mouse button - reset\n" << endl;
132+
}
133+
124134
int main(int argc, char **argv)
125135
{
126-
cv::CommandLineParser parser(argc, argv, "{help h | | show help message}{@input | | input image}");
127-
if (parser.has("help"))
128-
{
129-
parser.printMessage();
130-
return 0;
131-
}
136+
cv::CommandLineParser parser(argc, argv, "{@input | ../data/lena.jpg | input image}");
137+
help();
132138
string input_image = parser.get<string>("@input");
133139
if (input_image.empty())
134140
{
@@ -143,8 +149,6 @@ int main(int argc, char **argv)
143149

144150
img0 = src;
145151

146-
channel = img0.channels();
147-
148152
res1 = Mat::zeros(img0.size(),CV_8UC1);
149153
final = Mat::zeros(img0.size(),CV_8UC3);
150154
//////////// source image ///////////////////
@@ -154,6 +158,5 @@ int main(int argc, char **argv)
154158
imshow("Source", img0);
155159
waitKey(0);
156160

157-
img0.release();
158-
img1.release();
161+
return 0;
159162
}

samples/cpp/drawing.cpp

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#include "opencv2/imgproc.hpp"
33
#include "opencv2/highgui.hpp"
44
#include <stdio.h>
5+
56
using namespace cv;
67

78
static void help()
@@ -16,14 +17,9 @@ static Scalar randomColor(RNG& rng)
1617
return Scalar(icolor&255, (icolor>>8)&255, (icolor>>16)&255);
1718
}
1819

19-
int main(int argc, char** argv)
20+
int main()
2021
{
21-
cv::CommandLineParser parser(argc, argv, "{help h||}");
22-
if (parser.has("help"))
23-
{
24-
help();
25-
return 0;
26-
}
22+
help();
2723
char wndname[] = "Drawing Demo";
2824
const int NUMBER = 100;
2925
const int DELAY = 5;
@@ -36,31 +32,41 @@ int main(int argc, char** argv)
3632
imshow(wndname, image);
3733
waitKey(DELAY);
3834

39-
for (i = 0; i < NUMBER; i++)
35+
for (i = 0; i < NUMBER * 2; i++)
4036
{
4137
Point pt1, pt2;
4238
pt1.x = rng.uniform(x1, x2);
4339
pt1.y = rng.uniform(y1, y2);
4440
pt2.x = rng.uniform(x1, x2);
4541
pt2.y = rng.uniform(y1, y2);
4642

47-
line( image, pt1, pt2, randomColor(rng), rng.uniform(1,10), lineType );
43+
int arrowed = rng.uniform(0, 6);
44+
45+
if( arrowed < 3 )
46+
line( image, pt1, pt2, randomColor(rng), rng.uniform(1,10), lineType );
47+
else
48+
arrowedLine(image, pt1, pt2, randomColor(rng), rng.uniform(1, 10), lineType);
4849

4950
imshow(wndname, image);
5051
if(waitKey(DELAY) >= 0)
5152
return 0;
5253
}
5354

54-
for (i = 0; i < NUMBER; i++)
55+
for (i = 0; i < NUMBER * 2; i++)
5556
{
5657
Point pt1, pt2;
5758
pt1.x = rng.uniform(x1, x2);
5859
pt1.y = rng.uniform(y1, y2);
5960
pt2.x = rng.uniform(x1, x2);
6061
pt2.y = rng.uniform(y1, y2);
6162
int thickness = rng.uniform(-3, 10);
63+
int marker = rng.uniform(0, 10);
64+
int marker_size = rng.uniform(30, 80);
6265

63-
rectangle( image, pt1, pt2, randomColor(rng), MAX(thickness, -1), lineType );
66+
if (marker > 5)
67+
rectangle(image, pt1, pt2, randomColor(rng), MAX(thickness, -1), lineType);
68+
else
69+
drawMarker(image, pt1, randomColor(rng), marker, marker_size );
6470

6571
imshow(wndname, image);
6672
if(waitKey(DELAY) >= 0)
@@ -181,7 +187,3 @@ int main(int argc, char** argv)
181187
waitKey();
182188
return 0;
183189
}
184-
185-
#ifdef _EiC
186-
main(1,"drawing.c");
187-
#endif

samples/cpp/edge.cpp

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,15 +53,11 @@ const char* keys =
5353

5454
int main( int argc, const char** argv )
5555
{
56+
help();
5657
CommandLineParser parser(argc, argv, keys);
57-
if (parser.has("help"))
58-
{
59-
help();
60-
return 0;
61-
}
6258
string filename = parser.get<string>(0);
6359

64-
image = imread(filename, 1);
60+
image = imread(filename, IMREAD_COLOR);
6561
if(image.empty())
6662
{
6763
printf("Cannot read image file: %s\n", filename.c_str());

0 commit comments

Comments
 (0)