📄 cxcore reference manual.mht
字号:
<H3><A name=3Ddecl_CvMat>CvMat</A></H3>
<P class=3DBlurb>Multi-channel matrix</P><PRE> typedef struct CvMat
{
int type; /* CvMat signature (CV_MAT_MAGIC_VAL), element type =
and flags */
int step; /* full row length in bytes */
int* refcount; /* underlying data reference counter */
union
{
uchar* ptr;
short* s;
int* i;
float* fl;
double* db;
} data; /* data pointers */
#ifdef __cplusplus
union
{
int rows;
int height;
};
union
{
int cols;
int width;
};
#else
int rows; /* number of rows */
int cols; /* number of columns */
#endif
} CvMat;
</PRE>
<HR>
<H3><A name=3Ddecl_CvMatND>CvMatND</A></H3>
<P class=3DBlurb>Multi-dimensional dense multi-channel array</P><PRE> =
typedef struct CvMatND
{
int type; /* CvMatND signature (CV_MATND_MAGIC_VAL), element =
type and flags */
int dims; /* number of array dimensions */
int* refcount; /* underlying data reference counter */
union
{
uchar* ptr;
short* s;
int* i;
float* fl;
double* db;
} data; /* data pointers */
/* pairs (number of elements, distance between elements in =
bytes) for
every dimension */
struct
{
int size;
int step;
}
dim[CV_MAX_DIM];
} CvMatND;
</PRE>
<HR>
<H3><A name=3Ddecl_CvSparseMat>CvSparseMat</A></H3>
<P class=3DBlurb>Multi-dimensional sparse multi-channel array</P><PRE> =
typedef struct CvSparseMat
{
int type; /* CvSparseMat signature (CV_SPARSE_MAT_MAGIC_VAL), =
element type and flags */
int dims; /* number of dimensions */
int* refcount; /* reference counter - not used */
struct CvSet* heap; /* a pool of hashtable nodes */
void** hashtable; /* hashtable: each entry has a list of nodes
having the same "hashvalue modulo hashsize" =
*/
int hashsize; /* size of hashtable */
int total; /* total number of sparse array nodes */
int valoffset; /* value offset in bytes for the array nodes */
int idxoffset; /* index offset in bytes for the array nodes */
int size[CV_MAX_DIM]; /* arr of dimension sizes */
} CvSparseMat;
</PRE>
<HR>
<H3><A name=3Ddecl_IplImage>IplImage</A></H3>
<P class=3DBlurb>IPL image header</P><PRE> typedef struct _IplImage
{
int nSize; /* sizeof(IplImage) */
int ID; /* version (=3D0)*/
int nChannels; /* Most of OpenCV functions support 1,2,3 or =
4 channels */
int alphaChannel; /* ignored by OpenCV */
int depth; /* pixel depth in bits: IPL_DEPTH_8U, =
IPL_DEPTH_8S, IPL_DEPTH_16U,
IPL_DEPTH_16S, IPL_DEPTH_32S, =
IPL_DEPTH_32F and IPL_DEPTH_64F are supported */
char colorModel[4]; /* ignored by OpenCV */
char channelSeq[4]; /* ditto */
int dataOrder; /* 0 - interleaved color channels, 1 - =
separate color channels.
cvCreateImage can only create interleaved =
images */
int origin; /* 0 - top-left origin,
1 - bottom-left origin (Windows bitmaps =
style) */
int align; /* Alignment of image rows (4 or 8).
OpenCV ignores it and uses widthStep =
instead */
int width; /* image width in pixels */
int height; /* image height in pixels */
struct _IplROI *roi;/* image ROI. when it is not NULL, this =
specifies image region to process */
struct _IplImage *maskROI; /* must be NULL in OpenCV */
void *imageId; /* ditto */
struct _IplTileInfo *tileInfo; /* ditto */
int imageSize; /* image data size in bytes
(=3Dimage->height*image->widthStep
in case of interleaved data)*/
char *imageData; /* pointer to aligned image data */
int widthStep; /* size of aligned image row in bytes */
int BorderMode[4]; /* border completion mode, ignored by OpenCV =
*/
int BorderConst[4]; /* ditto */
char *imageDataOrigin; /* pointer to a very origin of image data
(not necessarily aligned) -
it is needed for correct image =
deallocation */
}
IplImage;
</PRE>
<P>The structure <CODE>IplImage</CODE> came from <EM>Intel Image =
Processing=20
Library</EM> where the format is native. OpenCV supports only a subset =
of=20
possible <CODE>IplImage</CODE> formats:=20
<UL>
<LI><CODE>alphaChannel</CODE> is ignored by OpenCV.=20
<LI><CODE>colorModel</CODE> and <CODE>channelSeq</CODE> are ignored by =
OpenCV.=20
The single OpenCV function <A=20
=
href=3D"http://www.assuredigit.com/incoming/sourcecode/opencv/chinese_doc=
s/ref/opencvref_cxcore.htm#decl_cvCvtColor">cvCvtColor</A>=20
working with color spaces takes the source and destination color =
spaces as a=20
parameter.=20
<LI><CODE>dataOrder</CODE> must be IPL_DATA_ORDER_PIXEL (the color =
channels=20
are interleaved), however selected channels of planar images can be =
processed=20
as well if COI is set.=20
<LI><CODE>align</CODE> is ignored by OpenCV, while =
<CODE>widthStep</CODE> is=20
used to access to subsequent image rows.=20
<LI><CODE>maskROI</CODE> is not supported. The function that can work =
with=20
mask take it as a separate parameter. Also the mask in OpenCV is =
8-bit,=20
whereas in IPL it is 1-bit.=20
<LI><CODE>tileInfo</CODE> is not supported.=20
<LI><CODE>BorderMode</CODE> and <CODE>BorderConst</CODE> are not =
supported.=20
Every OpenCV function working with a pixel neigborhood uses a single=20
hard-coded border mode (most often, replication). </LI></UL>Besides =
the above=20
restrictions, OpenCV handles ROI differently. It requires that the sizes =
or ROI=20
sizes of all source and destination images match exactly (according to =
the=20
operation, e.g. for <A=20
href=3D"http://www.assuredigit.com/incoming/sourcecode/opencv/chinese_doc=
s/ref/opencvref_cxcore.htm#decl_cvPyrDown">cvPyrDown</A>=20
destination width(height) must be equal to source width(height) divided =
by 2=20
=A1=C01), whereas IPL processes the intersection area - that is, the =
sizes or ROI=20
sizes of all images may vary independently.=20
<P></P>
<HR>
<H3><A name=3Ddecl_CvArr>CvArr</A></H3>
<P class=3DBlurb>Arbitrary array</P><PRE> typedef void CvArr;
</PRE>
<P><A=20
href=3D"http://www.assuredigit.com/incoming/sourcecode/opencv/chinese_doc=
s/ref/opencvref_cxcore.htm#decl_CvArr*">CvArr*</A>=20
is used <EM>only</EM> as a function parameter to specify that the =
function=20
accepts arrays of more than a single type, for example IplImage*, CvMat* =
or even=20
CvSeq*. The particular array type is determined at runtime by analyzing =
the=20
first 4 bytes of the header. </P><!-- =
*************************************************************************=
****************
=
*************************************************************************=
****************
=
*************************************************************************=
**************** -->
<HR>
<H1><A name=3Dcxcore_arrays>Operations on Arrays</A></H1>
<HR>
<H2><A name=3Dcxcore_arrays_alloc_free>Initialization</A></H2>
<HR>
<H3><A name=3Ddecl_cvCreateImage>CreateImage</A></H3>
<P class=3DBlurb>Creates header and allocates data</P><PRE>IplImage* =
cvCreateImage( CvSize size, int depth, int channels );
</PRE>
<P>
<DL>
<DT>size
<DD>Image width and height.=20
<DT>depth
<DD>Bit depth of image elements. Can be one of:<BR>IPL_DEPTH_8U - =
unsigned=20
8-bit integers<BR>IPL_DEPTH_8S - signed 8-bit =
integers<BR>IPL_DEPTH_16U -=20
unsigned 16-bit integers<BR>IPL_DEPTH_16S - signed 16-bit=20
integers<BR>IPL_DEPTH_32S - signed 32-bit integers<BR>IPL_DEPTH_32F - =
single=20
precision floating-point numbers<BR>IPL_DEPTH_64F - double precision=20
floating-point numbers<BR>
<DT>channels
<DD>Number of channels per element(pixel). Can be 1, 2, 3 or 4. The =
channels=20
are interleaved, for example the usual data layout of a color image =
is:<BR>b0=20
g0 r0 b1 g1 r1 ...<BR>Although in general IPL image format can store=20
non-interleaved images as well and some of OpenCV can process it, this =
function can create interleaved images only. </DD></DL>
<P>The function <A=20
href=3D"http://www.assuredigit.com/incoming/sourcecode/opencv/chinese_doc=
s/ref/opencvref_cxcore.htm#decl_cvCreateImage">cvCreateImage</A>=20
creates the header and allocates data. This call is a shortened form of =
<PRE> header =3D cvCreateImageHeader(size,depth,channels);
cvCreateData(header);
</PRE>
<P></P>
<HR>
<H3><A name=3Ddecl_cvCreateImageHeader>CreateImageHeader</A></H3>
<P class=3DBlurb>Allocates, initializes, and returns structure =
IplImage</P><PRE>IplImage* cvCreateImageHeader( CvSize size, int depth, =
int channels );
</PRE>
<P>
<DL>
<DT>size
<DD>Image width and height.=20
<DT>depth
<DD>Image depth (see CreateImage).=20
<DT>channels
<DD>Number of channels (see CreateImage). </DD></DL>
<P>The function <A=20
href=3D"http://www.assuredigit.com/incoming/sourcecode/opencv/chinese_doc=
s/ref/opencvref_cxcore.htm#decl_cvCreateImageHeader">cvCreateImageHeader<=
/A>=20
allocates, initializes, and returns the structure <CODE>IplImage</CODE>. =
This=20
call is an analogue of <PRE> iplCreateImageHeader( channels, 0, depth,
channels =3D=3D 1 ? "GRAY" : "RGB",
channels =3D=3D 1 ? "GRAY" : channels =3D=3D 3 ? =
"BGR" :
channels =3D=3D 4 ? "BGRA" : "",
IPL_DATA_ORDER_PIXEL, IPL_ORIGIN_TL, 4,
size.width, size.height,
0,0,0,0);
</PRE>though it does not use IPL functions by default (see also=20
<CODE>CV_TURN_ON_IPL_COMPATIBILITY</CODE> macro)=20
<P></P>
<HR>
<H3><A name=3Ddecl_cvReleaseImageHeader>ReleaseImageHeader</A></H3>
<P class=3DBlurb>Releases header</P><PRE>void cvReleaseImageHeader( =
IplImage** image );
</PRE>
<P>
<DL>
<DT>image
<DD>Double pointer to the deallocated 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_cvReleaseImageHeader">cvReleaseImageHeade=
r</A>=20
releases the header. This call is an analogue of <PRE> if( image )
{
iplDeallocate( *image, IPL_IMAGE_HEADER | IPL_IMAGE_ROI );
*image =3D 0;
}
</PRE>though it does not use IPL functions by default (see also=20
<CODE>CV_TURN_ON_IPL_COMPATIBILITY</CODE>)=20
<P></P>
<HR>
<H3><A name=3Ddecl_cvReleaseImage>ReleaseImage</A></H3>
<P class=3DBlurb>Releases header and image data</P><PRE>void =
cvReleaseImage( IplImage** image );
</PRE>
<P>
<DL>
<DT>image
<DD>Double pointer to the header of the deallocated image. </DD></DL>
<P></P>
<P>The function <A=20
href=3D"http://www.assuredigit.com/incoming/sourcecode/opencv/chinese_doc=
s/ref/opencvref_cxcore.htm#decl_cvReleaseImage">cvReleaseImage</A>=20
releases the header and the image data. This call is a shortened form of =
<PRE> if( *image )
{
cvReleaseData( *image );
cvReleaseImageHeader( image );
}
</PRE>
<P></P>
<HR>
<H3><A name=3Ddecl_cvInitImageHeader>InitImageHeader</A></H3>
<P class=3DBlurb>Initializes allocated by user image =
header</P><PRE>IplImage* cvInitImageHeader( IplImage* image, CvSize =
size, int depth,
int channels, int origin=3D0, int align=3D4 =
);
</PRE>
<P>
<DL>
<DT>image
<DD>Image header to initialize.=20
<DT>size
<DD>Image width and height.=20
<DT>depth
<DD>Image depth (see CreateImage).=20
<DT>channels
<DD>Number of channels (see CreateImage).=20
<DT>origin
<DD><CODE>IPL_ORIGIN_TL</CODE> or <CODE>IPL_ORIGIN_BL</CODE>.=20
<DT>align
<DD>Alignment for image rows, typically 4 or 8 bytes. </DD></DL>
<P></P>
<P>The function <A=20
href=3D"http://www.assuredigit.com/incoming/sourcecode/opencv/chinese_doc=
s/ref/opencvref_cxcore.htm#decl_cvInitImageHeader">cvInitImageHeader</A> =
initializes the image header structure, pointer to which is passed by =
the user,=20
and returns the pointer. </P>
<HR>
<H3><A name=3Ddecl_cvCloneImage>CloneImage</A></H3>
<P class=3DBlurb>Makes a full copy of image</P><PRE>IplImage* =
cvCloneImage( const IplImage* image );
</PRE>
<P>
<DL>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -