Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
O
opencv
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
opencv
Commits
2566ef35
Commit
2566ef35
authored
Sep 15, 2017
by
Alexander Alekhin
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #9526 from sturkmen72:update_documentation
parents
6bf8fe81
d547c6b1
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
149 additions
and
64 deletions
+149
-64
imgproc.hpp
modules/imgproc/include/opencv2/imgproc.hpp
+26
-3
objdetect.hpp
modules/objdetect/include/opencv2/objdetect.hpp
+2
-0
facedetect.cpp
samples/cpp/facedetect.cpp
+1
-1
lsd_lines.cpp
samples/cpp/lsd_lines.cpp
+39
-19
Sobel_Demo.cpp
samples/cpp/tutorial_code/ImgTrans/Sobel_Demo.cpp
+81
-41
No files found.
modules/imgproc/include/opencv2/imgproc.hpp
View file @
2566ef35
...
...
@@ -1192,6 +1192,7 @@ protected:
/** @example lsd_lines.cpp
An example using the LineSegmentDetector
\image html building_lsd.png "Sample output image" width=434 height=300
*/
/** @brief Line segment detector class
...
...
@@ -1347,6 +1348,11 @@ operation is shifted.
*/
CV_EXPORTS_W
Mat
getStructuringElement
(
int
shape
,
Size
ksize
,
Point
anchor
=
Point
(
-
1
,
-
1
));
/** @example Smoothing.cpp
Sample code for simple filters

Check @ref tutorial_gausian_median_blur_bilateral_filter "the corresponding tutorial" for more details
*/
/** @brief Blurs an image using the median filter.
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,
Point
anchor
=
Point
(
-
1
,
-
1
),
double
delta
=
0
,
int
borderType
=
BORDER_DEFAULT
);
/** @example Sobel_Demo.cpp
Sample code using Sobel and/or Scharr OpenCV functions to make a simple Edge Detector

Check @ref tutorial_sobel_derivatives "the corresponding tutorial" for more details
*/
/** @brief Calculates the first, second, third, or mixed image derivatives using an extended Sobel operator.
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,
//! @{
/** @example edge.cpp
An example on using the canny edge detector
This program demonstrates usage of the Canny edge detector
Check @ref tutorial_canny_detector "the corresponding tutorial" for more details
*/
/** @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,
/** @example houghlines.cpp
An example using the Hough line detector
 
*/
/** @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,
//! @{
/** @example morphology2.cpp
An example using the morphological operations
Advanced morphology Transformations sample code

Check @ref tutorial_opening_closing_hats "the corresponding tutorial" for more details
*/
/** @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,
int
borderType
=
BORDER_CONSTANT
,
const
Scalar
&
borderValue
=
morphologyDefaultBorderValue
()
);
/** @example Morphology_1.cpp
Erosion and Dilation sample code

Check @ref tutorial_erosion_dilatation "the corresponding tutorial" for more details
*/
/** @brief Dilates an image by using a specific structuring element.
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,
/** @example grabcut.cpp
An example using the GrabCut algorithm

*/
/** @brief Runs the GrabCut algorithm.
...
...
@@ -4406,7 +4428,8 @@ CV_EXPORTS_W void polylines(InputOutputArray img, InputArrayOfArrays pts,
int
thickness
=
1
,
int
lineType
=
LINE_8
,
int
shift
=
0
);
/** @example contours2.cpp
An example using the drawContour functionality
An example program illustrates the use of cv::findContours and cv::drawContours
\image html WindowsQtContoursOutput.png "Screenshot of the program"
*/
/** @example segment_objects.cpp
...
...
modules/objdetect/include/opencv2/objdetect.hpp
View file @
2566ef35
...
...
@@ -216,6 +216,8 @@ public:
};
/** @example facedetect.cpp
This program demonstrates usage of the Cascade classifier class
\image html Cascade_Classifier_Tutorial_Result_Haar.jpg "Sample screenshot" width=321 height=254
*/
/** @brief Cascade classifier class for object detection.
*/
...
...
samples/cpp/facedetect.cpp
View file @
2566ef35
...
...
@@ -8,7 +8,7 @@ using namespace cv;
static
void
help
()
{
cout
<<
"
\n
This program demonstrates the
cascade recognizer. Now y
ou can use Haar or LBP features.
\n
"
cout
<<
"
\n
This program demonstrates the
use of cv::CascadeClassifier class to detect objects (Face + eyes). Y
ou can use Haar or LBP features.
\n
"
"This classifier can recognize many kinds of rigid objects, once the appropriate classifier is trained.
\n
"
"It's most known use is for faces.
\n
"
"Usage:
\n
"
...
...
samples/cpp/lsd_lines.cpp
View file @
2566ef35
#include <iostream>
#include "opencv2/imgproc.hpp"
#include "opencv2/imgcodecs.hpp"
#include "opencv2/highgui.hpp"
#include <iostream>
using
namespace
std
;
using
namespace
cv
;
int
main
(
int
argc
,
char
**
argv
)
{
std
::
string
in
;
cv
::
CommandLineParser
parser
(
argc
,
argv
,
"{@input|../data/building.jpg|input image}{help h||show help message}"
);
if
(
parser
.
has
(
"help"
))
cv
::
CommandLineParser
parser
(
argc
,
argv
,
"{input i|../data/building.jpg|input image}"
"{refine r|false|if true use LSD_REFINE_STD method, if false use LSD_REFINE_NONE method}"
"{canny c|false|use Canny edge detector}"
"{overlay o|false|show result on input image}"
"{help h|false|show help message}"
);
if
(
parser
.
get
<
bool
>
(
"help"
))
{
parser
.
printMessage
();
return
0
;
}
in
=
parser
.
get
<
string
>
(
"@input"
);
Mat
image
=
imread
(
in
,
IMREAD_GRAYSCALE
);
parser
.
printMessage
();
String
filename
=
parser
.
get
<
String
>
(
"input"
);
bool
useRefine
=
parser
.
get
<
bool
>
(
"refine"
);
bool
useCanny
=
parser
.
get
<
bool
>
(
"canny"
);
bool
overlay
=
parser
.
get
<
bool
>
(
"overlay"
);
Mat
image
=
imread
(
filename
,
IMREAD_GRAYSCALE
);
if
(
image
.
empty
()
)
{
return
-
1
;
}
{
cout
<<
"Unable to load "
<<
filename
;
return
1
;
}
#if 0
Canny(image, image, 50, 200, 3); // Apply canny edge
#endif
imshow
(
"Source Image"
,
image
);
if
(
useCanny
)
{
Canny
(
image
,
image
,
50
,
200
,
3
);
// Apply Canny edge detector
}
// Create and LSD detector with standard or no refinement.
#if 1
Ptr
<
LineSegmentDetector
>
ls
=
createLineSegmentDetector
(
LSD_REFINE_STD
);
#else
Ptr
<
LineSegmentDetector
>
ls
=
createLineSegmentDetector
(
LSD_REFINE_NONE
);
#endif
Ptr
<
LineSegmentDetector
>
ls
=
useRefine
?
createLineSegmentDetector
(
LSD_REFINE_STD
)
:
createLineSegmentDetector
(
LSD_REFINE_NONE
);
double
start
=
double
(
getTickCount
());
vector
<
Vec4f
>
lines_std
;
...
...
@@ -44,9 +56,17 @@ int main(int argc, char** argv)
std
::
cout
<<
"It took "
<<
duration_ms
<<
" ms."
<<
std
::
endl
;
// Show found lines
Mat
drawnLines
(
image
);
ls
->
drawSegments
(
drawnLines
,
lines_std
);
imshow
(
"Standard refinement"
,
drawnLines
);
if
(
!
overlay
||
useCanny
)
{
image
=
Scalar
(
0
,
0
,
0
);
}
ls
->
drawSegments
(
image
,
lines_std
);
String
window_name
=
useRefine
?
"Result - standard refinement"
:
"Result - no refinement"
;
window_name
+=
useCanny
?
" - Canny edge detector used"
:
""
;
imshow
(
window_name
,
image
);
waitKey
();
return
0
;
...
...
samples/cpp/tutorial_code/ImgTrans/Sobel_Demo.cpp
View file @
2566ef35
/**
* @file Sobel_Demo.cpp
* @brief Sample code us
ing Sobel and/or Scharr OpenCV functions to make a simple Edge Detector
* @brief Sample code us
es Sobel or Scharr OpenCV functions for edge detection
* @author OpenCV team
*/
...
...
@@ -8,70 +8,110 @@
#include "opencv2/imgcodecs.hpp"
#include "opencv2/highgui.hpp"
#include <iostream>
using
namespace
cv
;
using
namespace
std
;
/**
* @function main
*/
int
main
(
int
argc
,
char
**
argv
)
{
cv
::
CommandLineParser
parser
(
argc
,
argv
,
"{@input |../data/lena.jpg|input image}"
"{ksize k|1|ksize (hit 'K' to increase its value)}"
"{scale s|1|scale (hit 'S' to increase its value)}"
"{delta d|0|delta (hit 'D' to increase its value)}"
"{help h|false|show help message}"
);
cout
<<
"The sample uses Sobel or Scharr OpenCV functions for edge detection
\n\n
"
;
parser
.
printMessage
();
cout
<<
"
\n
Press 'ESC' to exit program.
\n
Press 'R' to reset values ( ksize will be -1 equal to Scharr function )"
;
//![variables]
Mat
src
,
src_gray
;
Mat
image
,
src
,
src_gray
;
Mat
grad
;
const
char
*
window_name
=
"Sobel Demo - Simple Edge Detector"
;
int
scale
=
1
;
int
delta
=
0
;
const
String
window_name
=
"Sobel Demo - Simple Edge Detector"
;
int
ksize
=
parser
.
get
<
int
>
(
"ksize"
);
int
scale
=
parser
.
get
<
int
>
(
"scale"
);
int
delta
=
parser
.
get
<
int
>
(
"delta"
);
int
ddepth
=
CV_16S
;
//![variables]
//![load]
String
imageName
(
"../data/lena.jpg"
);
// by default
if
(
argc
>
1
)
String
imageName
=
parser
.
get
<
String
>
(
"@input"
);
// by default
image
=
imread
(
imageName
,
IMREAD_COLOR
);
// Load an image
if
(
image
.
empty
()
)
{
imageName
=
argv
[
1
]
;
return
1
;
}
src
=
imread
(
imageName
,
IMREAD_COLOR
);
// Load an image
if
(
src
.
empty
()
)
{
return
-
1
;
}
//![load]
//![reduce_noise]
GaussianBlur
(
src
,
src
,
Size
(
3
,
3
),
0
,
0
,
BORDER_DEFAULT
);
//![reduce_noise]
for
(;;)
{
//![reduce_noise]
GaussianBlur
(
image
,
src
,
Size
(
3
,
3
),
0
,
0
,
BORDER_DEFAULT
);
//![reduce_noise]
//![convert_to_gray]
cvtColor
(
src
,
src_gray
,
COLOR_BGR2GRAY
);
//![convert_to_gray]
//![convert_to_gray]
cvtColor
(
src
,
src_gray
,
COLOR_BGR2GRAY
);
//![convert_to_gray]
//![sobel]
/// Generate grad_x and grad_y
Mat
grad_x
,
grad_y
;
Mat
abs_grad_x
,
abs_grad_y
;
//![sobel]
/// Generate grad_x and grad_y
Mat
grad_x
,
grad_y
;
Mat
abs_grad_x
,
abs_grad_y
;
/// Gradient X
//Scharr( src_gray, grad_x, ddepth, 1, 0, scale, delta, BORDER_DEFAULT );
Sobel
(
src_gray
,
grad_x
,
ddepth
,
1
,
0
,
3
,
scale
,
delta
,
BORDER_DEFAULT
);
/// Gradient X
Sobel
(
src_gray
,
grad_x
,
ddepth
,
1
,
0
,
ksize
,
scale
,
delta
,
BORDER_DEFAULT
);
/// Gradient Y
//Scharr( src_gray, grad_y, ddepth, 0, 1, scale, delta, BORDER_DEFAULT );
Sobel
(
src_gray
,
grad_y
,
ddepth
,
0
,
1
,
3
,
scale
,
delta
,
BORDER_DEFAULT
);
//![sobel]
/// Gradient Y
Sobel
(
src_gray
,
grad_y
,
ddepth
,
0
,
1
,
ksize
,
scale
,
delta
,
BORDER_DEFAULT
);
//![sobel]
//![convert]
convertScaleAbs
(
grad_x
,
abs_grad_x
);
convertScaleAbs
(
grad_y
,
abs_grad_y
);
//![convert]
//![convert]
convertScaleAbs
(
grad_x
,
abs_grad_x
);
convertScaleAbs
(
grad_y
,
abs_grad_y
);
//![convert]
//![blend]
/// Total Gradient (approximate)
addWeighted
(
abs_grad_x
,
0.5
,
abs_grad_y
,
0.5
,
0
,
grad
);
//![blend]
//![blend]
/// Total Gradient (approximate)
addWeighted
(
abs_grad_x
,
0.5
,
abs_grad_y
,
0.5
,
0
,
grad
);
//![blend]
//![display]
imshow
(
window_name
,
grad
);
waitKey
(
0
);
//![display]
//![display]
imshow
(
window_name
,
grad
);
char
key
=
(
char
)
waitKey
(
0
);
//![display]
if
(
key
==
27
)
{
return
0
;
}
if
(
key
==
'k'
||
key
==
'K'
)
{
ksize
=
ksize
<
30
?
ksize
+
2
:
-
1
;
}
if
(
key
==
's'
||
key
==
'S'
)
{
scale
++
;
}
if
(
key
==
'd'
||
key
==
'D'
)
{
delta
++
;
}
if
(
key
==
'r'
||
key
==
'R'
)
{
scale
=
1
;
ksize
=
-
1
;
delta
=
0
;
}
}
return
0
;
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment