📄 cxcore.h
字号:
* for grayscale images. ** If a drawn figure is partially or completely outside of the image, it is clipped.*\****************************************************************************************/#define CV_RGB( r, g, b ) cvScalar( (b), (g), (r), 0 )#define CV_FILLED -1#define CV_AA 16/* Draws 4-connected, 8-connected or antialiased line segment connecting two points */CVAPI(void) cvLine( CvArr* img, CvPoint pt1, CvPoint pt2, CvScalar color, int thickness CV_DEFAULT(1), int line_type CV_DEFAULT(8), int shift CV_DEFAULT(0) );/* Draws a rectangle given two opposite corners of the rectangle (pt1 & pt2), if thickness<0 (e.g. thickness == CV_FILLED), the filled box is drawn */CVAPI(void) cvRectangle( CvArr* img, CvPoint pt1, CvPoint pt2, CvScalar color, int thickness CV_DEFAULT(1), int line_type CV_DEFAULT(8), int shift CV_DEFAULT(0));/* Draws a circle with specified center and radius. Thickness works in the same way as with cvRectangle */CVAPI(void) cvCircle( CvArr* img, CvPoint center, int radius, CvScalar color, int thickness CV_DEFAULT(1), int line_type CV_DEFAULT(8), int shift CV_DEFAULT(0));/* Draws ellipse outline, filled ellipse, elliptic arc or filled elliptic sector, depending on <thickness>, <start_angle> and <end_angle> parameters. The resultant figure is rotated by <angle>. All the angles are in degrees */CVAPI(void) cvEllipse( CvArr* img, CvPoint center, CvSize axes, double angle, double start_angle, double end_angle, CvScalar color, int thickness CV_DEFAULT(1), int line_type CV_DEFAULT(8), int shift CV_DEFAULT(0));/* Fills convex or monotonous polygon. */CVAPI(void) cvFillConvexPoly( CvArr* img, CvPoint* pts, int npts, CvScalar color, int line_type CV_DEFAULT(8), int shift CV_DEFAULT(0));/* Fills an area bounded by one or more arbitrary polygons */CVAPI(void) cvFillPoly( CvArr* img, CvPoint** pts, int* npts, int contours, CvScalar color, int line_type CV_DEFAULT(8), int shift CV_DEFAULT(0) );/* Draws one or more polygonal curves */CVAPI(void) cvPolyLine( CvArr* img, CvPoint** pts, int* npts, int contours, int is_closed, CvScalar color, int thickness CV_DEFAULT(1), int line_type CV_DEFAULT(8), int shift CV_DEFAULT(0) );#define cvDrawRect cvRectangle#define cvDrawLine cvLine#define cvDrawCircle cvCircle#define cvDrawEllipse cvEllipse#define cvDrawPolyLine cvPolyLine/* Clips the line segment connecting *pt1 and *pt2 by the rectangular window (0<=x<img_size.width, 0<=y<img_size.height). */CVAPI(int) cvClipLine( CvSize img_size, CvPoint* pt1, CvPoint* pt2 );/* Initializes line iterator. Initially, line_iterator->ptr will point to pt1 (or pt2, see left_to_right description) location in the image. Returns the number of pixels on the line between the ending points. */CVAPI(int) cvInitLineIterator( const CvArr* image, CvPoint pt1, CvPoint pt2, CvLineIterator* line_iterator, int connectivity CV_DEFAULT(8), int left_to_right CV_DEFAULT(0));/* Moves iterator to the next line point */#define CV_NEXT_LINE_POINT( line_iterator ) \{ \ int _line_iterator_mask = (line_iterator).err < 0 ? -1 : 0; \ (line_iterator).err += (line_iterator).minus_delta + \ ((line_iterator).plus_delta & _line_iterator_mask); \ (line_iterator).ptr += (line_iterator).minus_step + \ ((line_iterator).plus_step & _line_iterator_mask); \}/* basic font types */#define CV_FONT_HERSHEY_SIMPLEX 0#define CV_FONT_HERSHEY_PLAIN 1#define CV_FONT_HERSHEY_DUPLEX 2#define CV_FONT_HERSHEY_COMPLEX 3 #define CV_FONT_HERSHEY_TRIPLEX 4#define CV_FONT_HERSHEY_COMPLEX_SMALL 5#define CV_FONT_HERSHEY_SCRIPT_SIMPLEX 6#define CV_FONT_HERSHEY_SCRIPT_COMPLEX 7/* font flags */#define CV_FONT_ITALIC 16 #define CV_FONT_VECTOR0 CV_FONT_HERSHEY_SIMPLEX/* Font structure */typedef struct CvFont{ int font_face; /* =CV_FONT_* */ const int* ascii; /* font data and metrics */ const int* greek; const int* cyrillic; float hscale, vscale; float shear; /* slope coefficient: 0 - normal, >0 - italic */ int thickness; /* letters thickness */ float dx; /* horizontal interval between letters */ int line_type;}CvFont;/* Initializes font structure used further in cvPutText */CVAPI(void) cvInitFont( CvFont* font, int font_face, double hscale, double vscale, double shear CV_DEFAULT(0), int thickness CV_DEFAULT(1), int line_type CV_DEFAULT(8));CV_INLINE CvFont cvFont( double scale, int thickness CV_DEFAULT(1) ){ CvFont font; cvInitFont( &font, CV_FONT_HERSHEY_PLAIN, scale, scale, 0, thickness, CV_AA ); return font;}/* Renders text stroke with specified font and color at specified location. CvFont should be initialized with cvInitFont */CVAPI(void) cvPutText( CvArr* img, const char* text, CvPoint org, const CvFont* font, CvScalar color );/* Calculates bounding box of text stroke (useful for alignment) */CVAPI(void) cvGetTextSize( const char* text_string, const CvFont* font, CvSize* text_size, int* baseline );/* Unpacks color value, if arrtype is CV_8UC?, <color> is treated as packed color value, otherwise the first channels (depending on arrtype) of destination scalar are set to the same value = <color> */CVAPI(CvScalar) cvColorToScalar( double packed_color, int arrtype );/* Returns the polygon points which make up the given ellipse. The ellipse is define by the box of size 'axes' rotated 'angle' around the 'center'. A partial sweep of the ellipse arc can be done by spcifying arc_start and arc_end to be something other than 0 and 360, respectively. The input array 'pts' must be large enough to hold the result. The total number of points stored into 'pts' is returned by this function. */CVAPI(int) cvEllipse2Poly( CvPoint center, CvSize axes, int angle, int arc_start, int arc_end, CvPoint * pts, int delta );/* Draws contour outlines or filled interiors on the image */CVAPI(void) cvDrawContours( CvArr *img, CvSeq* contour, CvScalar external_color, CvScalar hole_color, int max_level, int thickness CV_DEFAULT(1), int line_type CV_DEFAULT(8), CvPoint offset CV_DEFAULT(cvPoint(0,0)));/* Does look-up transformation. Elements of the source array (that should be 8uC1 or 8sC1) are used as indexes in lutarr 256-element table */CVAPI(void) cvLUT( const CvArr* src, CvArr* dst, const CvArr* lut );/******************* Iteration through the sequence tree *****************/typedef struct CvTreeNodeIterator{ const void* node; int level; int max_level;}CvTreeNodeIterator;CVAPI(void) cvInitTreeNodeIterator( CvTreeNodeIterator* tree_iterator, const void* first, int max_level );CVAPI(void*) cvNextTreeNode( CvTreeNodeIterator* tree_iterator );CVAPI(void*) cvPrevTreeNode( CvTreeNodeIterator* tree_iterator );/* Inserts sequence into tree with specified "parent" sequence. If parent is equal to frame (e.g. the most external contour), then added contour will have null pointer to parent. */CVAPI(void) cvInsertNodeIntoTree( void* node, void* parent, void* frame );/* Removes contour from tree (together with the contour children). */CVAPI(void) cvRemoveNodeFromTree( void* node, void* frame );/* Gathers pointers to all the sequences, accessible from the <first>, to the single sequence */CVAPI(CvSeq*) cvTreeToNodeSeq( const void* first, int header_size, CvMemStorage* storage );/* The function implements the K-means algorithm for clustering an array of sample vectors in a specified number of classes */CVAPI(void) cvKMeans2( const CvArr* samples, int cluster_count, CvArr* labels, CvTermCriteria termcrit );/****************************************************************************************\* System functions *\****************************************************************************************//* Add the function pointers table with associated information to the IPP primitives list */CVAPI(int) cvRegisterModule( const CvModuleInfo* module_info );/* Loads optimized functions from IPP, MKL etc. or switches back to pure C code */CVAPI(int) cvUseOptimized( int on_off );/* Retrieves information about the registered modules and loaded optimized plugins */CVAPI(void) cvGetModuleInfo( const char* module_name, const char** version, const char** loaded_addon_plugins );/* Get current OpenCV error status */CVAPI(int) cvGetErrStatus( void );/* Sets error status silently */CVAPI(void) cvSetErrStatus( int status );#define CV_ErrModeLeaf 0 /* Print error and exit program */#define CV_ErrModeParent 1 /* Print error and continue */#define CV_ErrModeSilent 2 /* Don't print and continue *//* Retrives current error processing mode */CVAPI(int) cvGetErrMode( void );/* Sets error processing mode, returns previously used mode */CVAPI(int) cvSetErrMode( int mode );/* Sets error status and performs some additonal actions (displaying message box, writing message to stderr, terminating application etc.) depending on the current error mode */CVAPI(void) cvError( int status, const char* func_name, const char* err_msg, const char* file_name, int line );/* Retrieves textual description of the error given its code */CVAPI(const char*) cvErrorStr( int status );/* Retrieves detailed information about the last error occured */CVAPI(int) cvGetErrInfo( const char** errcode_desc, const char** description, const char** filename, int* line );/* Maps IPP error codes to the counterparts from OpenCV */CVAPI(int) cvErrorFromIppStatus( int ipp_status );typedef int (CV_CDECL *CvErrorCallback)( int status, const char* func_name, const char* err_msg, const char* file_name, int line, void* userdata );/* Assigns a new error-handling function */CVAPI(CvErrorCallback) cvRedirectError( CvErrorCallback error_handler, void* userdata CV_DEFAULT(NULL), void** prev_userdata CV_DEFAULT(NULL) );/* Output to: cvNulDevReport - nothing cvStdErrReport - console(fprintf(stderr,...)) cvGuiBoxReport - MessageBox(WIN32)*/CVAPI(int) cvNulDevReport( int status, const char* func_name, const char* err_msg, const char* file_name, int line, void* userdata );CVAPI(int) cvStdErrReport( int status, const char* func_name, const char* err_msg, const char* file_name, int line, void* userdata );CVAPI(int) cvGuiBoxReport( int status, const char* func_name, const char* err_msg, const char* file_name, int line, void* userdata );typedef void* (CV_CDECL *CvAllocFunc)(size_t size, void* userdata);typedef int (CV_CDECL *CvFreeFunc)(void* pptr, void* userdata);/* Set user-defined memory managment functions (substitutors for malloc and free) that will be called by cvAlloc, cvFree and higher-level functions (e.g. cvCreateImage) */CVAPI(void) cvSetMemoryManager( CvAllocFunc alloc_func CV_DEFAULT(NULL), CvFreeFunc free_func CV_DEFAULT(NULL), void* userdata CV_DEFAULT(NULL));typedef IplImage* (CV_STDCALL* Cv_iplCreateImageHeader) (int,int,int,char*,char*,int,int,int,int,int, IplROI*,IplImage*,void*,IplTileInfo*);typedef void (CV_STDCALL* Cv_iplAllocateImageData)(IplImage*,int,int);typedef void (CV_STDCALL* Cv_iplDeallocate)(IplImage*,int);typedef IplROI* (CV_STDCALL* Cv_iplCreateROI)(int,int,int,int,int);typedef IplImage* (CV_STDCALL* Cv_iplCloneImage)(const IplImage*);/* Makes OpenCV use IPL functions for IplImage allocation/deallocation */CVAPI(void) cvSetIPLAllocators( Cv_iplCreateImageHeader create_header, Cv_iplAllocateImageData allocate_data, Cv_iplDeallocate deallocate, Cv_iplCreateROI create_roi, Cv_iplCloneImage clone_image );#define CV_TURN_ON_IPL_COMPATIBILITY() \ cvSetIPLAllocators( iplCreateImageHeader, iplAllocateImage, \ iplDeallocate, iplCreateROI, iplCloneImage )/****************************************************************************************\* Data Persistence *\****************************************************************************************//********************************** High-level functions ********************************//* opens existing or creates new file storage */CVAPI(CvFileStorage*) cvOpenFileStorage( const char* filename, CvMemStorage* memstorage, int flags );/* closes file storage and deallocates buffers */CVAPI(void) cvReleaseFileStorage( CvFileStorage** fs );/* returns attribute value or 0 (NULL) if there is no such attribute */CVAPI(const char*) cvAttrValue( const CvAttrList* attr, const char* attr_name );/* starts writing compound structure (map or sequence) */CVAPI(void) cvStartWriteStruct( CvFileStorage* fs, const char* name,
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -