📄 opencv image processing and computer vision reference manual.mht
字号:
<HR>
<H3><A name=3Ddecl_cvPreCornerDetect>PreCornerDetect</A></H3>
<P class=3DBlurb>Calculates feature map for corner =
detection</P><PRE>void cvPreCornerDetect( const CvArr* image, CvArr* =
corners, int aperture_size=3D3 );
</PRE>
<P>
<DL>
<DT>image
<DD>Input image.=20
<DT>corners
<DD>Image to store the corner candidates.=20
<DT>aperture_size
<DD>Aperture parameter for Sobel operator (see <A=20
=
href=3D"http://www.assuredigit.com/incoming/sourcecode/opencv/chinese_doc=
s/ref/opencvref_cv.htm#decl_cvSobel">cvSobel</A>).=20
</DD></DL>
<P>The function <A=20
href=3D"http://www.assuredigit.com/incoming/sourcecode/opencv/chinese_doc=
s/ref/opencvref_cv.htm#decl_cvPreCornerDetect">cvPreCornerDetect</A>=20
calculates the function=20
D<SUB>x</SUB><SUP>2</SUP>D<SUB>yy</SUB>+D<SUB>y</SUB><SUP>2</SUP>D<SUB>xx=
</SUB>=20
- 2D<SUB>x</SUB>D<SUB>y</SUB>D<SUB>xy</SUB> where D<SUB>?</SUB> denotes =
one of=20
the first image derivatives and D<SUB>??</SUB> denotes a second image=20
derivative. The corners can be found as local maximums of the =
function:</P><PRE>// assuming that the image is floating-point
IplImage* corners =3D cvCloneImage(image);
IplImage* dilated_corners =3D cvCloneImage(image);
IplImage* corner_mask =3D 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( &corners );
cvReleaseImage( &dilated_corners );
</PRE>
<HR>
<H3><A =
name=3Ddecl_cvCornerEigenValsAndVecs>CornerEigenValsAndVecs</A></H3>
<P class=3DBlurb>Calculates eigenvalues and eigenvectors of image blocks =
for=20
corner detection</P><PRE>void cvCornerEigenValsAndVecs( const CvArr* =
image, CvArr* eigenvv,
int block_size, int aperture_size=3D3 );
</PRE>
<P>
<DL>
<DT>image
<DD>Input image.=20
<DT>eigenvv
<DD>Image to store the results. It must be 6 times wider than the =
input image.=20
<DT>block_size
<DD>Neighborhood size (see discussion).=20
<DT>aperture_size
<DD>Aperture parameter for Sobel operator (see <A=20
=
href=3D"http://www.assuredigit.com/incoming/sourcecode/opencv/chinese_doc=
s/ref/opencvref_cv.htm#decl_cvSobel">cvSobel</A>).=20
</DD></DL>
<P>For every pixel the function <A=20
href=3D"http://www.assuredigit.com/incoming/sourcecode/opencv/chinese_doc=
s/ref/opencvref_cv.htm#decl_cvCornerEigenValsAndVecs">cvCornerEigenValsAn=
dVecs</A>=20
considers <CODE>block_size</CODE> =A1=C1 <CODE>block_size</CODE> =
neigborhood S(p). It=20
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•dI/dy)|
M =3D | |
| sum<SUB>S(p)</SUB>(dI/dx•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=20
them into destination image in form (=A6=CB<SUB>1</SUB>, =
=A6=CB<SUB>2</SUB>,=20
x<SUB>1</SUB>, y<SUB>1</SUB>, x<SUB>2</SUB>, y<SUB>2</SUB>),=20
where<BR>=A6=CB<SUB>1</SUB>, =A6=CB<SUB>2</SUB> - eigenvalues of =
<CODE>M</CODE>; not=20
sorted<BR>(x<SUB>1</SUB>, y<SUB>1</SUB>) - eigenvector corresponding to=20
=A6=CB<SUB>1</SUB><BR>(x<SUB>2</SUB>, y<SUB>2</SUB>) - eigenvector =
corresponding to=20
=A6=CB<SUB>2</SUB><BR></P>
<HR>
<H3><A name=3Ddecl_cvCornerMinEigenVal>CornerMinEigenVal</A></H3>
<P class=3DBlurb>Calculates minimal eigenvalue of gradient matrices for =
corner=20
detection</P><PRE>void cvCornerMinEigenVal( const CvArr* image, CvArr* =
eigenval, int block_size, int aperture_size=3D3 );
</PRE>
<P>
<DL>
<DT>image
<DD>Input image.=20
<DT>eigenval
<DD>Image to store the minimal eigen values. Should have the same size =
as=20
<CODE>image</CODE>=20
<DT>block_size
<DD>Neighborhood size (see discussion of <A=20
=
href=3D"http://www.assuredigit.com/incoming/sourcecode/opencv/chinese_doc=
s/ref/opencvref_cv.htm#decl_cvCornerEigenValsAndVecs">cvCornerEigenValsAn=
dVecs</A>).=20
<DT>aperture_size
<DD>Aperture parameter for Sobel operator (see <A=20
=
href=3D"http://www.assuredigit.com/incoming/sourcecode/opencv/chinese_doc=
s/ref/opencvref_cv.htm#decl_cvSobel">cvSobel</A>).=20
format. In the case of floating-point input format this parameter is =
the=20
number of the fixed float filter used for differencing. </DD></DL>
<P>The function <A=20
href=3D"http://www.assuredigit.com/incoming/sourcecode/opencv/chinese_doc=
s/ref/opencvref_cv.htm#decl_cvCornerMinEigenVal">cvCornerMinEigenVal</A> =
is similar to <A=20
href=3D"http://www.assuredigit.com/incoming/sourcecode/opencv/chinese_doc=
s/ref/opencvref_cv.htm#decl_cvCornerEigenValsAndVecs">cvCornerEigenValsAn=
dVecs</A>=20
but it calculates and stores only the minimal eigen value of derivative=20
covariation matrix for every pixel, i.e. min(=A6=CB<SUB>1</SUB>, =
=A6=CB<SUB>2</SUB>) in=20
terms of the previous function. </P>
<HR>
<H3><A name=3Ddecl_cvFindCornerSubPix>FindCornerSubPix</A></H3>
<P class=3DBlurb>Refines corner locations</P><PRE>void =
cvFindCornerSubPix( const CvArr* image, CvPoint2D32f* corners,
int count, CvSize win, CvSize zero_zone,
CvTermCriteria criteria );
</PRE>
<P>
<DL>
<DT>image
<DD>Input image.=20
<DT>corners
<DD>Initial coordinates of the input corners and refined coordinates =
on=20
output.=20
<DT>count
<DD>Number of corners.=20
<DT>win
<DD>Half sizes of the search window. For example, if =
<CODE>win</CODE>=3D(5,5)=20
then 5*2+1 =A1=C1 5*2+1 =3D 11 =A1=C1 11 search window is used.=20
<DT>zero_zone
<DD>Half size of the dead region in the middle of the search zone over =
which=20
the summation in formulae below is not done. It is used sometimes to =
avoid=20
possible singularities of the autocorrelation matrix. The value of =
(-1,-1)=20
indicates that there is no such size.=20
<DT>criteria
<DD>Criteria for termination of the iterative process of corner =
refinement.=20
That is, the process of corner position refinement stops either after =
certain=20
number of iteration or when a required accuracy is achieved. The=20
<CODE>criteria</CODE> may specify either of or both the maximum number =
of=20
iteration and the required accuracy. </DD></DL>
<P>The function <A=20
href=3D"http://www.assuredigit.com/incoming/sourcecode/opencv/chinese_doc=
s/ref/opencvref_cv.htm#decl_cvFindCornerSubPix">cvFindCornerSubPix</A>=20
iterates to find the sub-pixel accurate location of corners, or radial =
saddle=20
points, as shown in on the picture below.</P>
<P><IMG=20
src=3D"http://www.assuredigit.com/incoming/sourcecode/opencv/chinese_docs=
/ref/pics/cornersubpix.png"=20
align=3Dcenter> </P>
<P>Sub-pixel accurate corner locator is based on the observation that =
every=20
vector from the center <CODE>q</CODE> to a point <CODE>p</CODE> located =
within a=20
neighborhood of <CODE>q</CODE> is orthogonal to the image gradient at=20
<CODE>p</CODE> subject to image and measurement noise. Consider the =
expression:=20
</P><PRE>=A6=C5<SUB>i</SUB>=3DDI<SUB>p<SUB>i</SUB></SUB><SUP>T</SUP>̶=
6;(q-p<SUB>i</SUB>)
</PRE>where <CODE>DI<SUB>p<SUB>i</SUB></SUB></CODE> is the image =
gradient at the=20
one of the points <CODE>p<SUB>i</SUB></CODE> in a neighborhood of=20
<CODE>q</CODE>. The value of <CODE>q</CODE> is to be found such that=20
<CODE>=A6=C5<SUB>i</SUB></CODE> is minimized. A system of equations may =
be set up=20
with <CODE>=A6=C5<SUB>i</SUB></CODE>' set to zero:
<P></P><PRE>sum<SUB>i</SUB>(DI<SUB>p<SUB>i</SUB></SUB>•DI<SUB>p<SUB=
>i</SUB></SUB><SUP>T</SUP>)•q - =
sum<SUB>i</SUB>(DI<SUB>p<SUB>i</SUB></SUB>•DI<SUB>p<SUB>i</SUB></SU=
B><SUP>T</SUP>•p<SUB>i</SUB>) =3D 0
</PRE>
<P>where the gradients are summed within a neighborhood ("search =
window") of=20
<CODE>q</CODE>. Calling the first gradient term <CODE>G</CODE> and the =
second=20
gradient term <CODE>b</CODE> gives:</P><PRE>q=3DG<SUP>-1</SUP>•b
</PRE>
<P>The algorithm sets the center of the neighborhood window at this new =
center=20
<CODE>q</CODE> and then iterates until the center keeps within a set =
threshold.=20
</P>
<HR>
<H3><A name=3Ddecl_cvGoodFeaturesToTrack>GoodFeaturesToTrack</A></H3>
<P class=3DBlurb>Determines strong corners on image</P><PRE>void =
cvGoodFeaturesToTrack( const CvArr* image, CvArr* eig_image, CvArr* =
temp_image,
CvPoint2D32f* corners, int* corner_count,
double quality_level, double min_distance,
const CvArr* mask=3DNULL );
</PRE>
<P>
<DL>
<DT>image
<DD>The source 8-bit or floating-point 32-bit, single-channel image.=20
<DT>eig_image
<DD>Temporary floating-point 32-bit image of the same size as=20
<CODE>image</CODE>.=20
<DT>temp_image
<DD>Another temporary image of the same size and same format as=20
<CODE>eig_image</CODE>.=20
<DT>corners
<DD>Output parameter. Detected corners.=20
<DT>corner_count
<DD>Output parameter. Number of detected corners.=20
<DT>quality_level
<DD>Multiplier for the maxmin eigenvalue; specifies minimal accepted =
quality=20
of image corners.=20
<DT>min_distance
<DD>Limit, specifying minimum possible distance between returned =
corners;=20
Euclidian distance is used.=20
<DT>mask
<DD>Region of interest. The function selects points either in the =
specified=20
region or in the whole image if the mask is NULL. </DD></DL>
<P>The function <A=20
href=3D"http://www.assuredigit.com/incoming/sourcecode/opencv/chinese_doc=
s/ref/opencvref_cv.htm#decl_cvGoodFeaturesToTrack">cvGoodFeaturesToTrack<=
/A>=20
finds corners with big eigenvalues in the image. The function first =
calculates=20
the minimal eigenvalue for every source image pixel using <A=20
href=3D"http://www.assuredigit.com/incoming/sourcecode/opencv/chinese_doc=
s/ref/opencvref_cv.htm#decl_cvCornerMinEigenVal">cvCornerMinEigenVal</A> =
function and stores them in <CODE>eig_image</CODE>. Then it performs =
non-maxima=20
suppression (only local maxima in 3x3 neighborhood remain). The next =
step is=20
rejecting the corners with the minimal eigenvalue less than=20
<CODE>quality_level</CODE>•max(<CODE>eig_image</CODE>(x,y)). =
Finally, the=20
function ensures that all the corners found are distanced enough from =
one=20
another by considering the corners (the most strongest corners are =
considered=20
first) and checking that the distance between the newly considered =
feature and=20
the features considered earlier is larger than =
<CODE>min_distance</CODE>. So,=20
the function removes the features than are too close to the stronger=20
features.</P>
<HR>
<H2><A name=3Dcv_imgproc_resampling>Sampling, Interpolation and =
Geometrical=20
Transforms</A></H2>
<HR>
<H3><A name=3Ddecl_cvInitLineIterator>InitLineIterator</A></H3>
<P class=3DBlurb>Initializes line iterator</P><PRE>int =
cvInitLineIterator( const CvArr* image, CvPoint pt1, CvPoint pt2,
CvLineIterator* line_iterator, int =
connectivity=3D8 );
</PRE>
<P>
<DL>
<DT>image
<DD>Image to sample the line from.=20
<DT>pt1
<DD>Starting the line point.=20
<DT>pt2
<DD>Ending the line point.=20
<DT>line_iterator
<DD>Pointer to the line iterator state structure.=20
<DT>connectivity
<DD>The scanned line connectivity, 4 or 8. </DD></DL>
<P>The function <A=20
href=3D"http://www.assuredigit.com/incoming/sourcecode/opencv/chinese_doc=
s/ref/opencvref_cv.htm#decl_cvInitLineIterator">cvInitLineIterator</A>=20
initializes the line iterator and returns the number of pixels between =
two end=20
points. Both points must be inside the image. After the iterator has =
been=20
initialized, all the points on the raster line that connects the two =
ending=20
points may be retrieved by successive calls of =
<CODE>CV_NEXT_LINE_POINT</CODE>=20
point. The points on the line are calculated one by one using =
4-connected or=20
8-connected Bresenham algorithm.</P>
<H4>Example. Using line iterator to calculate sum of pixel values along =
the=20
color line</H4><PRE> CvScalar sum_line_pixels( IplImage* image, =
CvPoint pt1, CvPoint pt2 )
{
CvLineIterator iterator;
int blue_sum =3D 0, green_sum =3D 0, red_sum =3D 0;
int count =3D cvInitLineIterator( image, pt1, pt2, =
&iterator, 8 );
for( int i =3D 0; i < count; i++ ){
blue_sum +=3D iterator.ptr[0];
green_sum +=3D iterator.ptr[1];
red_sum +=3D iterator.ptr[2];
CV_NEXT_LINE_POINT(iterator);
/* print the pixel coordinates: demonstrates how to =
calculate the coordinates */
{
int offset, x, y;
/* assume that ROI is not set, otherwise need to take it =
into account. */
offset =3D iterator.ptr - (uchar*)(image->imageData);
y =3D offset/image->widthStep;
x =3D (offset - y*image->widthStep)/(3*sizeof(uchar) /* =
size of pixel */);
printf("(%d,%d)\n", x, y );
}
}
return cvScalar( blue_sum, green_sum, red_sum );
}
</PRE>
<HR>
<H3><A name=3Ddecl_cvSampleLine>SampleLine</A></H3>
<P class=3DBlurb>Reads raster line to buffer</P><PRE>int cvSampleLine( =
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -