mirror of
https://github.com/opencv/opencv.git
synced 2025-06-07 17:44:04 +08:00
documentation improvement
This commit is contained in:
parent
05b99a4dde
commit
d547c6b1a2
@ -1192,6 +1192,7 @@ protected:
|
|||||||
|
|
||||||
/** @example lsd_lines.cpp
|
/** @example lsd_lines.cpp
|
||||||
An example using the LineSegmentDetector
|
An example using the LineSegmentDetector
|
||||||
|
\image html building_lsd.png "Sample output image" width=434 height=300
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/** @brief Line segment detector class
|
/** @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));
|
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.
|
/** @brief Blurs an image using the median filter.
|
||||||
|
|
||||||
The function smoothes an image using the median filter with the \f$\texttt{ksize} \times
|
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),
|
Point anchor = Point(-1,-1),
|
||||||
double delta = 0, int borderType = BORDER_DEFAULT );
|
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.
|
/** @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
|
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
|
/** @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 .
|
/** @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
|
/** @example houghlines.cpp
|
||||||
An example using the Hough line detector
|
An example using the Hough line detector
|
||||||
|
 
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/** @brief Finds lines in a binary image using the standard Hough transform.
|
/** @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
|
/** @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.
|
/** @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,
|
int borderType = BORDER_CONSTANT,
|
||||||
const Scalar& borderValue = morphologyDefaultBorderValue() );
|
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.
|
/** @brief Dilates an image by using a specific structuring element.
|
||||||
|
|
||||||
The function dilates the source image using the specified structuring element that determines the
|
The function dilates the source image using the specified structuring element that determines the
|
||||||
@ -3377,6 +3398,7 @@ CV_EXPORTS_W void pyrMeanShiftFiltering( InputArray src, OutputArray dst,
|
|||||||
|
|
||||||
/** @example grabcut.cpp
|
/** @example grabcut.cpp
|
||||||
An example using the GrabCut algorithm
|
An example using the GrabCut algorithm
|
||||||
|

|
||||||
*/
|
*/
|
||||||
|
|
||||||
/** @brief Runs the GrabCut algorithm.
|
/** @brief Runs the GrabCut algorithm.
|
||||||
@ -4399,7 +4421,8 @@ CV_EXPORTS_W void polylines(InputOutputArray img, InputArrayOfArrays pts,
|
|||||||
int thickness = 1, int lineType = LINE_8, int shift = 0 );
|
int thickness = 1, int lineType = LINE_8, int shift = 0 );
|
||||||
|
|
||||||
/** @example contours2.cpp
|
/** @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
|
/** @example segment_objects.cpp
|
||||||
|
@ -216,6 +216,8 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
/** @example facedetect.cpp
|
/** @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.
|
/** @brief Cascade classifier class for object detection.
|
||||||
*/
|
*/
|
||||||
|
@ -8,7 +8,7 @@ using namespace cv;
|
|||||||
|
|
||||||
static void help()
|
static void help()
|
||||||
{
|
{
|
||||||
cout << "\nThis program demonstrates the cascade recognizer. Now you can use Haar or LBP features.\n"
|
cout << "\nThis program demonstrates the use of cv::CascadeClassifier class to detect objects (Face + eyes). You can use Haar or LBP features.\n"
|
||||||
"This classifier can recognize many kinds of rigid objects, once the appropriate classifier is trained.\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"
|
"It's most known use is for faces.\n"
|
||||||
"Usage:\n"
|
"Usage:\n"
|
||||||
|
@ -1,38 +1,50 @@
|
|||||||
#include <iostream>
|
|
||||||
|
|
||||||
#include "opencv2/imgproc.hpp"
|
#include "opencv2/imgproc.hpp"
|
||||||
#include "opencv2/imgcodecs.hpp"
|
#include "opencv2/imgcodecs.hpp"
|
||||||
#include "opencv2/highgui.hpp"
|
#include "opencv2/highgui.hpp"
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace cv;
|
using namespace cv;
|
||||||
|
|
||||||
int main(int argc, char** argv)
|
int main(int argc, char** argv)
|
||||||
{
|
{
|
||||||
std::string in;
|
cv::CommandLineParser parser(argc, argv,
|
||||||
cv::CommandLineParser parser(argc, argv, "{@input|../data/building.jpg|input image}{help h||show help message}");
|
"{input i|../data/building.jpg|input image}"
|
||||||
if (parser.has("help"))
|
"{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();
|
parser.printMessage();
|
||||||
return 0;
|
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() )
|
if( image.empty() )
|
||||||
{ return -1; }
|
{
|
||||||
|
cout << "Unable to load " << filename;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
#if 0
|
imshow("Source Image", image);
|
||||||
Canny(image, image, 50, 200, 3); // Apply canny edge
|
|
||||||
#endif
|
if (useCanny)
|
||||||
|
{
|
||||||
|
Canny(image, image, 50, 200, 3); // Apply Canny edge detector
|
||||||
|
}
|
||||||
|
|
||||||
// Create and LSD detector with standard or no refinement.
|
// Create and LSD detector with standard or no refinement.
|
||||||
#if 1
|
Ptr<LineSegmentDetector> ls = useRefine ? createLineSegmentDetector(LSD_REFINE_STD) : createLineSegmentDetector(LSD_REFINE_NONE);
|
||||||
Ptr<LineSegmentDetector> ls = createLineSegmentDetector(LSD_REFINE_STD);
|
|
||||||
#else
|
|
||||||
Ptr<LineSegmentDetector> ls = createLineSegmentDetector(LSD_REFINE_NONE);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
double start = double(getTickCount());
|
double start = double(getTickCount());
|
||||||
vector<Vec4f> lines_std;
|
vector<Vec4f> lines_std;
|
||||||
@ -44,9 +56,17 @@ int main(int argc, char** argv)
|
|||||||
std::cout << "It took " << duration_ms << " ms." << std::endl;
|
std::cout << "It took " << duration_ms << " ms." << std::endl;
|
||||||
|
|
||||||
// Show found lines
|
// Show found lines
|
||||||
Mat drawnLines(image);
|
if (!overlay || useCanny)
|
||||||
ls->drawSegments(drawnLines, lines_std);
|
{
|
||||||
imshow("Standard refinement", drawnLines);
|
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();
|
waitKey();
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/**
|
/**
|
||||||
* @file Sobel_Demo.cpp
|
* @file Sobel_Demo.cpp
|
||||||
* @brief Sample code using Sobel and/or Scharr OpenCV functions to make a simple Edge Detector
|
* @brief Sample code uses Sobel or Scharr OpenCV functions for edge detection
|
||||||
* @author OpenCV team
|
* @author OpenCV team
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -8,40 +8,55 @@
|
|||||||
#include "opencv2/imgcodecs.hpp"
|
#include "opencv2/imgcodecs.hpp"
|
||||||
#include "opencv2/highgui.hpp"
|
#include "opencv2/highgui.hpp"
|
||||||
|
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
using namespace cv;
|
using namespace cv;
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @function main
|
* @function main
|
||||||
*/
|
*/
|
||||||
int main( int argc, char** argv )
|
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 << "\nPress 'ESC' to exit program.\nPress 'R' to reset values ( ksize will be -1 equal to Scharr function )";
|
||||||
|
|
||||||
//![variables]
|
//![variables]
|
||||||
Mat src, src_gray;
|
Mat image,src, src_gray;
|
||||||
Mat grad;
|
Mat grad;
|
||||||
const char* window_name = "Sobel Demo - Simple Edge Detector";
|
const String window_name = "Sobel Demo - Simple Edge Detector";
|
||||||
int scale = 1;
|
int ksize = parser.get<int>("ksize");
|
||||||
int delta = 0;
|
int scale = parser.get<int>("scale");
|
||||||
|
int delta = parser.get<int>("delta");
|
||||||
int ddepth = CV_16S;
|
int ddepth = CV_16S;
|
||||||
//![variables]
|
//![variables]
|
||||||
|
|
||||||
//![load]
|
//![load]
|
||||||
String imageName("../data/lena.jpg"); // by default
|
String imageName = parser.get<String>("@input"); // by default
|
||||||
if (argc > 1)
|
image = imread( imageName, IMREAD_COLOR ); // Load an image
|
||||||
{
|
|
||||||
imageName = argv[1];
|
|
||||||
}
|
|
||||||
src = imread( imageName, IMREAD_COLOR ); // Load an image
|
|
||||||
|
|
||||||
if( src.empty() )
|
if( image.empty() )
|
||||||
{ return -1; }
|
{
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
//![load]
|
//![load]
|
||||||
|
|
||||||
|
for (;;)
|
||||||
|
{
|
||||||
//![reduce_noise]
|
//![reduce_noise]
|
||||||
GaussianBlur( src, src, Size(3,3), 0, 0, BORDER_DEFAULT );
|
GaussianBlur(image, src, Size(3, 3), 0, 0, BORDER_DEFAULT);
|
||||||
//![reduce_noise]
|
//![reduce_noise]
|
||||||
|
|
||||||
//![convert_to_gray]
|
//![convert_to_gray]
|
||||||
cvtColor( src, src_gray, COLOR_BGR2GRAY );
|
cvtColor(src, src_gray, COLOR_BGR2GRAY);
|
||||||
//![convert_to_gray]
|
//![convert_to_gray]
|
||||||
|
|
||||||
//![sobel]
|
//![sobel]
|
||||||
@ -50,28 +65,53 @@ int main( int argc, char** argv )
|
|||||||
Mat abs_grad_x, abs_grad_y;
|
Mat abs_grad_x, abs_grad_y;
|
||||||
|
|
||||||
/// Gradient X
|
/// Gradient X
|
||||||
//Scharr( src_gray, grad_x, ddepth, 1, 0, scale, delta, BORDER_DEFAULT );
|
Sobel(src_gray, grad_x, ddepth, 1, 0, ksize, scale, delta, BORDER_DEFAULT);
|
||||||
Sobel( src_gray, grad_x, ddepth, 1, 0, 3, scale, delta, BORDER_DEFAULT );
|
|
||||||
|
|
||||||
/// Gradient Y
|
/// Gradient Y
|
||||||
//Scharr( src_gray, grad_y, ddepth, 0, 1, scale, delta, BORDER_DEFAULT );
|
Sobel(src_gray, grad_y, ddepth, 0, 1, ksize, scale, delta, BORDER_DEFAULT);
|
||||||
Sobel( src_gray, grad_y, ddepth, 0, 1, 3, scale, delta, BORDER_DEFAULT );
|
|
||||||
//![sobel]
|
//![sobel]
|
||||||
|
|
||||||
//![convert]
|
//![convert]
|
||||||
convertScaleAbs( grad_x, abs_grad_x );
|
convertScaleAbs(grad_x, abs_grad_x);
|
||||||
convertScaleAbs( grad_y, abs_grad_y );
|
convertScaleAbs(grad_y, abs_grad_y);
|
||||||
//![convert]
|
//![convert]
|
||||||
|
|
||||||
//![blend]
|
//![blend]
|
||||||
/// Total Gradient (approximate)
|
/// Total Gradient (approximate)
|
||||||
addWeighted( abs_grad_x, 0.5, abs_grad_y, 0.5, 0, grad );
|
addWeighted(abs_grad_x, 0.5, abs_grad_y, 0.5, 0, grad);
|
||||||
//![blend]
|
//![blend]
|
||||||
|
|
||||||
//![display]
|
//![display]
|
||||||
imshow( window_name, grad );
|
imshow(window_name, grad);
|
||||||
waitKey(0);
|
char key = (char)waitKey(0);
|
||||||
//![display]
|
//![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;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user