⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 opencvref_cv.htm

📁 OpenCV1.0 + C++Builder6 example of finding coners programm. Highlites coners it found in frame.
💻 HTM
📖 第 1 页 / 共 5 页
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN">
<html><head>
<link rel="STYLESHEET" href="opencvref.css" charset="ISO-8859-1" type="text/css">
<title>OpenCV: Image Processing and Computer Vision Reference Manual</title>
</head><body>

<h1>CV Reference Manual</h1>

<hr><p><ul>
<li><a href="#cv_imgproc">Image Processing</a>
<ul>
<li><a href="#cv_imgproc_features">Gradients, Edges and Corners</a>
<li><a href="#cv_imgproc_resampling">Sampling, Interpolation and Geometrical Transforms</a>
<li><a href="#cv_imgproc_morphology">Morphological Operations</a>
<li><a href="#cv_imgproc_filters">Filters and Color Conversion</a>
<li><a href="#cv_imgproc_pyramids">Pyramids and the Applications</a>
<li><a href="#cv_imgproc_ccomp">Image Segmentation, Connected Components and Contour Retrieval</a>
<li><a href="#cv_imgproc_moments">Image and Contour Moments</a>
<li><a href="#cv_imgproc_special">Special Image Transforms</a>
<li><a href="#cv_imgproc_histograms">Histograms</a>
<li><a href="#cv_imgproc_matching">Matching</a>
</ul>
<li><a href="#cv_sa">Structural Analysis</a>
<ul>
<li><a href="#cv_sa_contours">Contour Processing</a>
<li><a href="#cv_sa_compgeom">Computational Geometry</a>
<li><a href="#cv_sa_subdiv">Planar Subdivisions</a>
</ul>
<li><a href="#cv_motion">Motion Analysis and Object Tracking</a>
<ul>
<li><a href="#cv_motion_acc">Accumulation of Background Statistics</a>
<li><a href="#cv_motion_motempl">Motion Templates</a>
<li><a href="#cv_motion_tracking">Object Tracking</a>
<li><a href="#cv_motion_optflow">Optical Flow</a>
<li><a href="#cv_motion_estimators">Estimators</a>
</ul>
<li><a href="#cv_pattern">Pattern Recognition</a>
<ul>
<li><a href="#cv_pattern_objdetection">Object Detection</a>
</ul>
<li><a href="#cv_3d">Camera Calibration and 3D Reconstruction</a>
<ul>
<li><a href="#cv_3d_calibration">Camera Calibration</a>
<li><a href="#cv_3d_pose">Pose Estimation</a>
<li><a href="#cv_3d_epipolar">Epipolar Geometry</a>
</ul>
<li><a href="#cv_func_index">Alphabetical List of Functions</a>
<li><a href="#cv_bib">Bibliography</a>
</ul></p>

<hr><h1><a name="cv_imgproc">Image Processing</a></h1>

<p>
Note:<br>
The chapter describes functions for image processing and analysis.
Most of the functions work with 2d arrays of pixels. We refer the arrays
as "images" however they do not neccesserily have to be IplImage&#146;s, they may
be CvMat&#146;s or CvMatND&#146;s as well.
</p>

<hr><h2><a name="cv_imgproc_features">Gradients, Edges and Corners</a></h2>

<hr><h3><a name="decl_cvSobel">Sobel</a></h3>
<p class="Blurb">Calculates first, second, third or mixed image derivatives using extended Sobel operator</p>
<pre>
void cvSobel( const CvArr* src, CvArr* dst, int xorder, int yorder, int aperture_size=3 );
</pre><p><dl>
<dt>src<dd>Source image.
<dt>dst<dd>Destination image.
<dt>xorder<dd>Order of the derivative x .
<dt>yorder<dd>Order of the derivative y .
<dt>aperture_size<dd>Size of the extended Sobel kernel, must be 1, 3, 5 or 7.
In all cases except 1, aperture_size &times;aperture_size separable kernel will be used to calculate
the derivative. For <code>aperture_size</code>=1 3x1 or 1x3 kernel is used (Gaussian smoothing is not done).
There is also special value <code>CV_SCHARR</code> (=-1) that corresponds to 3x3 Scharr filter that may
give more accurate results than 3x3 Sobel. Scharr aperture is:
<pre>
| -3 0  3|
|-10 0 10|
| -3 0  3|
</pre>
for x-derivative or transposed for y-derivative.
</dl><p>
The function <code>cvSobel</code> calculates the image derivative by convolving the image
with the appropriate kernel:</p>
<pre>
dst(x,y) = d<sup>xorder+yoder</sup>src/dx<sup>xorder</sup>&bull;dy<sup>yorder</sup> |<sub>(x,y)</sub>
</pre>
The Sobel operators combine Gaussian smoothing and differentiation so the result is more or less
robust to the noise. Most often, the function is called with (xorder=1, yorder=0, aperture_size=3) or
(xorder=0, yorder=1, aperture_size=3) to calculate first x- or y- image derivative.
The first case corresponds to</p>
<pre>
  |-1  0  1|
  |-2  0  2|
  |-1  0  1|
</pre>
<p>kernel and the second one corresponds to</p>
<pre>
  |-1 -2 -1|
  | 0  0  0|
  | 1  2  1|
or
  | 1  2  1|
  | 0  0  0|
  |-1 -2 -1|
</pre>
kernel, depending on the image origin (<code>origin</code> field of <code>IplImage</code> structure).
No scaling is done, so the destination image usually has larger by absolute value numbers than
the source image. To avoid overflow, the function requires 16-bit destination image if
the source image is 8-bit. The result can be converted back to 8-bit using <a href="#decl_cvConvertScale">cvConvertScale</a> or
<a href="opencvref_cxcore.htm#decl_cvConvertScaleAbs">cvConvertScaleAbs</a> functions. Besides 8-bit images the function
can process 32-bit floating-point images.
Both source and destination must be single-channel images of equal size or ROI size.
</p>


<hr><h3><a name="decl_cvLaplace">Laplace</a></h3>
<p class="Blurb">Calculates Laplacian of the image</p>
<pre>
void cvLaplace( const CvArr* src, CvArr* dst, int aperture_size=3 );
</pre><p><dl>
<dt>src<dd>Source image.
<dt>dst<dd>Destination image.
<dt>aperture_size<dd>Aperture size (it has the same meaning as in <a href="#decl_cvSobel">cvSobel</a>).
</dl><p>
The function <code>cvLaplace</code> calculates Laplacian of the source image by summing
second x- and y- derivatives calculated using Sobel operator:</p>
<pre>
dst(x,y) = d<sup>2</sup>src/dx<sup>2</sup> + d<sup>2</sup>src/dy<sup>2</sup>
</pre>
<p>
Specifying <code>aperture_size</code>=1 gives the fastest variant that is equal to
convolving the image with the following kernel:</p>
<pre>
|0  1  0|
|1 -4  1|
|0  1  0|
</pre><p>
Similar to <a href="#decl_cvSobel">cvSobel</a> function, no scaling is done and the same combinations of input and
output formats are supported.
</p>


<hr><h3><a name="decl_cvCanny">Canny</a></h3>
<p class="Blurb">Implements Canny algorithm for edge detection</p>
<pre>
void cvCanny( const CvArr* image, CvArr* edges, double threshold1,
              double threshold2, int aperture_size=3 );
</pre><p><dl>
<dt>image<dd>Input image.
<dt>edges<dd>Image to store the edges found by the function.
<dt>threshold1<dd>The first threshold.
<dt>threshold2<dd>The second threshold.
<dt>aperture_size<dd>Aperture parameter for Sobel operator (see <a href="#decl_cvSobel">cvSobel</a>).
</dl><p>
The function <code>cvCanny</code> finds the edges on the input image <code>image</code> and marks them in the
output image <code>edges</code> using the Canny algorithm. The smallest of <code>threshold1</code> and
<code>threshold2</code> is used for edge linking, the largest - to find initial segments of strong edges.</p>


<hr><h3><a name="decl_cvPreCornerDetect">PreCornerDetect</a></h3>
<p class="Blurb">Calculates feature map for corner detection</p>
<pre>
void cvPreCornerDetect( const CvArr* image, CvArr* corners, int aperture_size=3 );
</pre><p><dl>
<dt>image<dd>Input image.
<dt>corners<dd>Image to store the corner candidates.
<dt>aperture_size<dd>Aperture parameter for Sobel operator (see <a href="#decl_cvSobel">cvSobel</a>).
</dl><p>
The function <code>cvPreCornerDetect</code> calculates the function
D<sub>x</sub><sup>2</sup>D<sub>yy</sub>+D<sub>y</sub><sup>2</sup>D<sub>xx</sub> - 2D<sub>x</sub>D<sub>y</sub>D<sub>xy</sub>
where D<sub>?</sub> denotes one of the first image derivatives and D<sub>??</sub> denotes a second image
derivative. The corners can be found as local maximums of the function:</p>
<pre>
// assume that the image is floating-point
IplImage* corners = cvCloneImage(image);
IplImage* dilated_corners = cvCloneImage(image);
IplImage* corner_mask = cvCreateImage( cvGetSize(image), 8, 1 );
cvPreCornerDetect( image, corners, 3 );
cvDilate( corners, dilated_corners, 0, 1 );
cvSubS( corners, dilated_corners, corners );
cvCmpS( corners, 0, corner_mask, CV_CMP_GE );
cvReleaseImage( &amp;corners );
cvReleaseImage( &amp;dilated_corners );
</pre>

<hr><h3><a name="decl_cvCornerEigenValsAndVecs">CornerEigenValsAndVecs</a></h3>
<p class="Blurb">Calculates eigenvalues and eigenvectors of image blocks for corner detection</p>
<pre>
void cvCornerEigenValsAndVecs( const CvArr* image, CvArr* eigenvv,
                               int block_size, int aperture_size=3 );
</pre><p><dl>
<dt>image<dd>Input image.
<dt>eigenvv<dd>Image to store the results. It must be 6 times wider than the input image.
<dt>block_size<dd>Neighborhood size (see discussion).
<dt>aperture_size<dd>Aperture parameter for Sobel operator (see <a href="#decl_cvSobel">cvSobel</a>).
</dl><p>
For every pixel The function <code>cvCornerEigenValsAndVecs</code> considers
<code>block_size</code> &times; <code>block_size</code> neigborhood S(p). It calcualtes
covariation matrix of derivatives over the neigborhood as:</p>
<pre>
    | sum<sub>S(p)</sub>(dI/dx)<sup>2</sup>   sum<sub>S(p)</sub>(dI/dx&bull;dI/dy)|
M = |                                 |
    | sum<sub>S(p)</sub>(dI/dx&bull;dI/dy)  sum<sub>S(p)</sub>(dI/dy)<sup>2</sup> |
</pre><p>
After that it finds eigenvectors and eigenvalues of the matrix and stores
them into destination image in form
(&lambda;<sub>1</sub>, &lambda;<sub>2</sub>, x<sub>1</sub>, y<sub>1</sub>, x<sub>2</sub>, y<sub>2</sub>),
where<br>
&lambda;<sub>1</sub>, &lambda;<sub>2</sub> - eigenvalues of <code>M</code>; not sorted<br>
(x<sub>1</sub>, y<sub>1</sub>) - eigenvector corresponding to &lambda;<sub>1</sub><br>
(x<sub>2</sub>, y<sub>2</sub>) - eigenvector corresponding to &lambda;<sub>2</sub><br>
</p>


<hr><h3><a name="decl_cvCornerMinEigenVal">CornerMinEigenVal</a></h3>
<p class="Blurb">Calculates minimal eigenvalue of gradient matrices for corner detection</p>
<pre>
void cvCornerMinEigenVal( const CvArr* image, CvArr* eigenval, int block_size, int aperture_size=3 );
</pre><p><dl>
<dt>image<dd>Input image.
<dt>eigenval<dd>Image to store the minimal eigen values. Should have the same size as <code>image</code>
<dt>block_size<dd>Neighborhood size (see discussion of <a href="#decl_cvCornerEigenValsAndVecs">cvCornerEigenValsAndVecs</a>).
<dt>aperture_size<dd>Aperture parameter for Sobel operator (see <a href="#decl_cvSobel">cvSobel</a>).
format. In the case of floating-point input format this parameter is the number
of the fixed float filter used for differencing.
</dl><p>
The function <code>cvCornerMinEigenVal</code> is similar to <a href="#decl_cvCornerEigenValsAndVecs">cvCornerEigenValsAndVecs</a> but
it calculates and stores only the minimal eigen value of derivative covariation matrix for every pixel,
i.e. min(&lambda;<sub>1</sub>, &lambda;<sub>2</sub>) in terms of the previous function.
</p>


<hr><h3><a name="decl_cvCornerHarris">CornerHarris</a></h3>
<p class="Blurb">Harris edge detector</p>
<pre>
void cvCornerHarris( const CvArr* image, CvArr* harris_responce,
                     int block_size, int aperture_size=3, double k=0.04 );
</pre><p><dl>
<dt>image<dd>Input image.
<dt>harris_responce<dd>Image to store the Harris detector responces. Should have the same size as <code>image</code>
<dt>block_size<dd>Neighborhood size (see discussion of <a href="#decl_cvCornerEigenValsAndVecs">cvCornerEigenValsAndVecs</a>).
<dt>aperture_size<dd>Aperture parameter for Sobel operator (see <a href="#decl_cvSobel">cvSobel</a>).
format. In the case of floating-point input format this parameter is the number
of the fixed float filter used for differencing.
<dt>k<dd>Harris detector free parameter. See the formula below.
</dl><p>
The function <code>cvCornerHarris</code> runs the Harris edge detector on image. Similarly to
<a href="#decl_cvCornerMinEigenVal">cvCornerMinEigenVal</a> and
<a href="#decl_cvCornerEigenValsAndVecs">cvCornerEigenValsAndVecs</a>, for each pixel it calculates 2x2 gradient
covariation matrix <code>M</code> over <code>block_size&times;block_size</code> neighborhood.
Then, it stores</p>
<pre>det(M) - k*trace(M)<sup>2</sup>
</pre>
to the destination image. Corners in the image can be found as local maxima of the destination image.
</p>


<hr><h3><a name="decl_cvFindCornerSubPix">FindCornerSubPix</a></h3>
<p class="Blurb">Refines corner locations</p>
<pre>
void cvFindCornerSubPix( const CvArr* image, CvPoint2D32f* corners,
                         int count, CvSize win, CvSize zero_zone,
                         CvTermCriteria criteria );
</pre><p><dl>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -