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

📄 cxcore reference manual.mht

📁 比较齐全的OpenCV参考手册
💻 MHT
📖 第 1 页 / 共 5 页
字号:
cvReleaseSparseMat( CvSparseMat** mat );
</PRE>
<P>
<DL>
  <DT>mat
  <DD>Double pointer to the array. </DD></DL>
<P>The function <A=20
href=3D"http://www.assuredigit.com/incoming/sourcecode/opencv/chinese_doc=
s/ref/opencvref_cxcore.htm#decl_cvReleaseSparseMat">cvReleaseSparseMat</A=
>=20
releases the sparse array and clears the array pointer upon exit</P>
<HR>

<H3><A name=3Ddecl_cvCloneSparseMat>CloneSparseMat</A></H3>
<P class=3DBlurb>Creates full copy of sparse array</P><PRE>CvSparseMat* =
cvCloneSparseMat( const CvSparseMat* mat );
</PRE>
<P>
<DL>
  <DT>mat
  <DD>Input array. </DD></DL>
<P>The function <A=20
href=3D"http://www.assuredigit.com/incoming/sourcecode/opencv/chinese_doc=
s/ref/opencvref_cxcore.htm#decl_cvCloneSparseMat">cvCloneSparseMat</A>=20
creates a copy of the input array and returns pointer to the copy.</P>
<HR>

<H2><A name=3Dcxcore_arrays_get_set>Accessing Elements and =
sub-Arrays</A></H2>
<HR>

<H3><A name=3Ddecl_cvGetSubRect>GetSubRect</A></H3>
<P class=3DBlurb>Returns matrix header corresponding to the rectangular =
sub-array=20
of input image or matrix</P><PRE>CvMat* cvGetSubRect( const CvArr* arr, =
CvMat* submat, CvRect rect );
</PRE>
<P>
<DL>
  <DT>arr
  <DD>Input array.=20
  <DT>submat
  <DD>Pointer to the resultant sub-array header.=20
  <DT>rect
  <DD>Zero-based coordinates of the rectangle of interest. </DD></DL>
<P>The function <A=20
href=3D"http://www.assuredigit.com/incoming/sourcecode/opencv/chinese_doc=
s/ref/opencvref_cxcore.htm#decl_cvGetSubRect">cvGetSubRect</A>=20
returns header, corresponding to a specified rectangle of the input =
array. In=20
other words, it allows the user to treat a rectangular part of input =
array as a=20
stand-alone array. ROI is taken into account by the function so the =
sub-array of=20
ROI is actually extracted.</P>
<HR>

<H3><A name=3Ddecl_cvGetRow>GetRow, GetRows</A></H3>
<P class=3DBlurb>Returns array row or row span</P><PRE>CvMat* cvGetRow( =
const CvArr* arr, CvMat* submat, int row );
CvMat* cvGetRows( const CvArr* arr, CvMat* submat, int start_row, int =
end_row, int delta_row=3D1 );
</PRE>
<P>
<DL>
  <DT>arr
  <DD>Input array.=20
  <DT>submat
  <DD>Pointer to the resulting sub-array header.=20
  <DT>row
  <DD>Zero-based index of the selected row.=20
  <DT>start_row
  <DD>Zero-based index of the starting row (inclusive) of the span.=20
  <DT>end_row
  <DD>Zero-based index of the ending row (exclusive) of the span.=20
  <DT>delta_row
  <DD>Index step in the row span. That is, the function extracts every=20
  <CODE>delta_row</CODE>-th row from <CODE>start_row</CODE> and up to =
(but not=20
  including) <CODE>end_row</CODE>. </DD></DL>
<P>The functions <CODE>GetRow</CODE> and <CODE>GetRows</CODE> return the =
header,=20
corresponding to a specified row/row span of the input array. Note that=20
<CODE>GetRow</CODE> is a shortcut for <A=20
href=3D"http://www.assuredigit.com/incoming/sourcecode/opencv/chinese_doc=
s/ref/opencvref_cxcore.htm#decl_cvGetRows">cvGetRows</A>:=20
<PRE>cvGetRow( arr, submat, row ) ~ cvGetRows( arr, submat, row, row + =
1, 1 );
</PRE>
<P></P>
<HR>

<H3><A name=3Ddecl_cvGetCol>GetCol, GetCols</A></H3>
<P class=3DBlurb>Returns array column or column span</P><PRE>CvMat* =
cvGetCol( const CvArr* arr, CvMat* submat, int col );
CvMat* cvGetCols( const CvArr* arr, CvMat* submat, int start_col, int =
end_col );
</PRE>
<P>
<DL>
  <DT>arr
  <DD>Input array.=20
  <DT>submat
  <DD>Pointer to the resulting sub-array header.=20
  <DT>col
  <DD>Zero-based index of the selected column.=20
  <DT>start_col
  <DD>Zero-based index of the starting column (inclusive) of the span.=20
  <DT>end_col
  <DD>Zero-based index of the ending column (exclusive) of the span. =
</DD></DL>
<P>The functions <CODE>GetCol</CODE> and <CODE>GetCols</CODE> return the =
header,=20
corresponding to a specified column/column span of the input array. Note =
that=20
<CODE>GetCol</CODE> is a shortcut for <A=20
href=3D"http://www.assuredigit.com/incoming/sourcecode/opencv/chinese_doc=
s/ref/opencvref_cxcore.htm#decl_cvGetCols">cvGetCols</A>:=20
<PRE>cvGetCol( arr, submat, col ); // ~ cvGetCols( arr, submat, col, col =
+ 1 );
</PRE>
<P></P>
<HR>

<H3><A name=3Ddecl_cvGetDiag>GetDiag</A></H3>
<P class=3DBlurb>Returns one of array diagonals</P><PRE>CvMat* =
cvGetDiag( const CvArr* arr, CvMat* submat, int diag=3D0 );
</PRE>
<P>
<DL>
  <DT>arr
  <DD>Input array.=20
  <DT>submat
  <DD>Pointer to the resulting sub-array header.=20
  <DT>diag
  <DD>Array diagonal. Zero corresponds to the main diagonal, -1 =
corresponds to=20
  the diagonal above the main etc., 1 corresponds to the diagonal below =
the main=20
  etc. </DD></DL>
<P>The function <A=20
href=3D"http://www.assuredigit.com/incoming/sourcecode/opencv/chinese_doc=
s/ref/opencvref_cxcore.htm#decl_cvGetDiag">cvGetDiag</A>=20
returns the header, corresponding to a specified diagonal of the input=20
array.</P>
<HR>

<H3><A name=3Ddecl_cvGetSize>GetSize</A></H3>
<P class=3DBlurb>Returns size of matrix or image ROI</P><PRE>CvSize =
cvGetSize( const CvArr* arr );
</PRE>
<P>
<DL>
  <DT>arr
  <DD>array header. </DD></DL>
<P>The function <A=20
href=3D"http://www.assuredigit.com/incoming/sourcecode/opencv/chinese_doc=
s/ref/opencvref_cxcore.htm#decl_cvGetSize">cvGetSize</A>=20
returns number of rows (CvSize::height) and number of columns =
(CvSize::width) of=20
the input matrix or image. In case of image the size of ROI is =
returned.</P>
<HR>

<H3><A =
name=3Ddecl_cvInitSparseMatIterator>InitSparseMatIterator</A></H3>
<P class=3DBlurb>Initializes sparse array elements =
iterator</P><PRE>CvSparseNode* cvInitSparseMatIterator( const =
CvSparseMat* mat,
                                       CvSparseMatIterator* mat_iterator =
);
</PRE>
<P>
<DL>
  <DT>mat
  <DD>Input array.=20
  <DT>mat_iterator
  <DD>Initialized iterator. </DD></DL>
<P>The function <A=20
href=3D"http://www.assuredigit.com/incoming/sourcecode/opencv/chinese_doc=
s/ref/opencvref_cxcore.htm#decl_cvInitSparseMatIterator">cvInitSparseMatI=
terator</A>=20
initializes iterator of sparse array elements and returns pointer to the =
first=20
element, or NULL if the array is empty.</P>
<HR>

<H3><A name=3Ddecl_cvGetNextSparseNode>GetNextSparseNode</A></H3>
<P class=3DBlurb>Initializes sparse array elements =
iterator</P><PRE>CvSparseNode* cvGetNextSparseNode( CvSparseMatIterator* =
mat_iterator );
</PRE>
<P>
<DL>
  <DT>mat_iterator
  <DD>Sparse array iterator. </DD></DL>
<P>The function <A=20
href=3D"http://www.assuredigit.com/incoming/sourcecode/opencv/chinese_doc=
s/ref/opencvref_cxcore.htm#decl_cvGetNextSparseNode">cvGetNextSparseNode<=
/A>=20
moves iterator to the next sparse matrix element and returns pointer to =
it. In=20
the current version there is no any particular order of the elements, =
because=20
they are stored in hash table. The sample below demonstrates how to =
iterate=20
through the sparse matrix:</P>
<P><FONT color=3Dblue size=3D4>Using <A=20
href=3D"http://www.assuredigit.com/incoming/sourcecode/opencv/chinese_doc=
s/ref/opencvref_cxcore.htm#decl_cvInitSparseMatIterator">cvInitSparseMatI=
terator</A>=20
and <A=20
href=3D"http://www.assuredigit.com/incoming/sourcecode/opencv/chinese_doc=
s/ref/opencvref_cxcore.htm#decl_cvGetNextSparseNode">cvGetNextSparseNode<=
/A>=20
to calculate sum of floating-point sparse array.</FONT> <PRE>    double =
sum;
    int i, dims =3D cvGetDims( array );
    CvSparseMatIterator mat_iterator;
    CvSparseNode* node =3D cvInitSparseMatIterator( array, =
&amp;mat_iterator );

    for( ; node !=3D 0; node =3D cvGetNextSparseNode( &amp;mat_iterator =
))
    {
        int* idx =3D CV_NODE_IDX( array, node ); /* get pointer to the =
element indices */
        float val =3D *(float*)CV_NODE_VAL( array, node ); /* get value =
of the element
                                                          (assume that =
the type is CV_32FC1) */
        printf( "(" );
        for( i =3D 0; i &lt; dims; i++ )
            printf( "%4d%s", idx[i], i &lt; dims - 1 "," : "): " );
        printf( "%g\n", val );

        sum +=3D val;
    }

    printf( "\nTotal sum =3D %g\n", sum );
</PRE>
<P></P>
<HR>

<H3><A name=3Ddecl_cvGetElemType>GetElemType</A></H3>
<P class=3DBlurb>Returns type of array elements</P><PRE>int =
cvGetElemType( const CvArr* arr );
</PRE>
<P>
<DL>
  <DT>arr
  <DD>Input array. </DD></DL>
<P>The functions <CODE>GetElemType</CODE> returns type of the array =
elements as=20
it is described in cvCreateMat discussion: <PRE>CV_8UC1 ... =
CV_64FC4</PRE>
<P></P>
<HR>

<H3><A name=3Ddecl_cvGetDims>GetDims, GetDimSize</A></H3>
<P class=3DBlurb>Return number of array dimensions and their sizes or =
the size of=20
particular dimension</P><PRE>int cvGetDims( const CvArr* arr, int* =
sizes=3DNULL );
int cvGetDimSize( const CvArr* arr, int index );
</PRE>
<P>
<DL>
  <DT>arr
  <DD>Input array.=20
  <DT>sizes
  <DD>Optional output vector of the array dimension sizes. For 2d arrays =
the=20
  number of rows (height) goes first, number of columns (width) next.=20
  <DT>index
  <DD>Zero-based dimension index (for matrices 0 means number of rows, 1 =
means=20
  number of columns; for images 0 means height, 1 means width). =
</DD></DL>
<P>The function <A=20
href=3D"http://www.assuredigit.com/incoming/sourcecode/opencv/chinese_doc=
s/ref/opencvref_cxcore.htm#decl_cvGetDims">cvGetDims</A>=20
returns number of array dimensions and their sizes. In case of=20
<CODE>IplImage</CODE> or <A=20
href=3D"http://www.assuredigit.com/incoming/sourcecode/opencv/chinese_doc=
s/ref/opencvref_cxcore.htm#decl_CvMat">CvMat</A>=20
it always returns 2 regardless of number of image/matrix rows. The =
function <A=20
href=3D"http://www.assuredigit.com/incoming/sourcecode/opencv/chinese_doc=
s/ref/opencvref_cxcore.htm#decl_cvGetDimSize">cvGetDimSize</A>=20
returns the particular dimension size (number of elements per that =
dimension).=20
For example, the following code calculates total number of array =
elements in two=20
ways:<PRE>
// via cvGetDims()
int sizes[CV_MAX_DIM];
int i, total =3D 1;
int dims =3D cvGetDims( arr, size );
for( i =3D 0; i &lt; dims; i++ )
    total *=3D sizes[i];

// via cvGetDims() and cvGetDimSize()
int i, total =3D 1;
int dims =3D cvGetDims( arr );
for( i =3D 0; i &lt; dims; i++ )
    total *=3D cvGetDimsSize( arr, i );
</PRE>
<P></P>
<HR>

<H3><A name=3Ddecl_cvPtr*D>Ptr*D</A></H3>
<P class=3DBlurb>Return pointer to the particular array =
element</P><PRE>uchar* cvPtr1D( const CvArr* arr, int idx0, int* =
type=3DNULL );
uchar* cvPtr2D( const CvArr* arr, int idx0, int idx1, int* type=3DNULL =
);
uchar* cvPtr3D( const CvArr* arr, int idx0, int idx1, int idx2, int* =
type=3DNULL );
uchar* cvPtrND( const CvArr* arr, int* idx, int* type=3DNULL, int =
create_node=3D1, unsigned* precalc_hashval=3DNULL );
</PRE>
<P>
<DL>
  <DT>arr
  <DD>Input array.=20
  <DT>idx0
  <DD>The first zero-based component of the element index=20
  <DT>idx1
  <DD>The second zero-based component of the element index=20
  <DT>idx2
  <DD>The third zero-based component of the element index=20
  <DT>idx
  <DD>Array of the element indices=20
  <DT>type
  <DD>Optional output parameter: type of matrix elements=20
  <DT>create_node
  <DD>Optional input parameter for sparse matrices. Non-zero value of =
the=20
  parameter means that the requested element is created if it does not =
exist=20
  already.=20
  <DT>precalc_hashval
  <DD>Optional input parameter for sparse matrices. If the pointer is =
not NULL,=20
  the function does not recalculate the node hash value, but takes it =
from the=20
  specified location. It is useful for speeding up pair-wise operations =
(TODO:=20
  provide an example) </DD></DL>
<P>The functions <A=20
href=3D"http://www.assuredigit.com/incoming/sourcecode/opencv/chinese_doc=
s/ref/opencvref_cxcore.htm#decl_cvPtr*D">cvPtr*D</A>=20
return pointer to the particular array element. Number of array =
dimension should=20
match to the number of indices passed to the function except for <A=20
href=3D"http://www.assuredigit.com/incoming/sourcecode/opencv/chinese_doc=
s/ref/opencvref_cxcore.htm#decl_cvPtr1D">cvPtr1D</A>=20
function that can be used for sequential access to 1D, 2D or nD dense =
arrays.=20
</P>
<P>The functions can be used for sparse arrays as well - if the =
requested node=20
does not exist they create it and set it to zero.</P>
<P>All these as well as other functions accessing array elements (<A=20
href=3D"http://www.assuredigit.com/incoming/sourcecode/opencv/chinese_doc=
s/ref/opencvref_cxcore.htm#decl_cvGet[Real]*D">cvGet[Real]*D</

⌨️ 快捷键说明

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