mirror of
https://github.com/opencv/opencv.git
synced 2025-08-01 02:18:01 +08:00
Clean up C API
This commit is contained in:
parent
178240ccf1
commit
703dea4817
@ -408,18 +408,6 @@ CV_INLINE CvMat* cvGetCol( const CvArr* arr, CvMat* submat, int col )
|
|||||||
return cvGetCols( arr, submat, col, col + 1 );
|
return cvGetCols( arr, submat, col, col + 1 );
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @brief Returns one of array diagonals.
|
|
||||||
|
|
||||||
The function returns the header, corresponding to a specified diagonal of the input array.
|
|
||||||
@param arr Input array
|
|
||||||
@param submat Pointer to the resulting sub-array header
|
|
||||||
@param diag Index of the array diagonal. Zero value corresponds to the main diagonal, -1
|
|
||||||
corresponds to the diagonal above the main, 1 corresponds to the diagonal below the main, and so
|
|
||||||
forth.
|
|
||||||
*/
|
|
||||||
CVAPI(CvMat*) cvGetDiag( const CvArr* arr, CvMat* submat,
|
|
||||||
int diag CV_DEFAULT(0));
|
|
||||||
|
|
||||||
/** low-level scalar <-> raw data conversion functions */
|
/** low-level scalar <-> raw data conversion functions */
|
||||||
CVAPI(void) cvScalarToRawData( const CvScalar* scalar, void* data, int type,
|
CVAPI(void) cvScalarToRawData( const CvScalar* scalar, void* data, int type,
|
||||||
int extend_to_12 CV_DEFAULT(0) );
|
int extend_to_12 CV_DEFAULT(0) );
|
||||||
@ -560,37 +548,6 @@ CV_INLINE CvSparseNode* cvGetNextSparseNode( CvSparseMatIterator* mat_iterator )
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#define CV_MAX_ARR 10
|
|
||||||
|
|
||||||
/** matrix iterator: used for n-ary operations on dense arrays */
|
|
||||||
typedef struct CvNArrayIterator
|
|
||||||
{
|
|
||||||
int count; /**< number of arrays */
|
|
||||||
int dims; /**< number of dimensions to iterate */
|
|
||||||
CvSize size; /**< maximal common linear size: { width = size, height = 1 } */
|
|
||||||
uchar* ptr[CV_MAX_ARR]; /**< pointers to the array slices */
|
|
||||||
int stack[CV_MAX_DIM]; /**< for internal use */
|
|
||||||
CvMatND* hdr[CV_MAX_ARR]; /**< pointers to the headers of the
|
|
||||||
matrices that are processed */
|
|
||||||
}
|
|
||||||
CvNArrayIterator;
|
|
||||||
|
|
||||||
#define CV_NO_DEPTH_CHECK 1
|
|
||||||
#define CV_NO_CN_CHECK 2
|
|
||||||
#define CV_NO_SIZE_CHECK 4
|
|
||||||
|
|
||||||
/** initializes iterator that traverses through several arrays simultaneously
|
|
||||||
(the function together with cvNextArraySlice is used for
|
|
||||||
N-ari element-wise operations) */
|
|
||||||
CVAPI(int) cvInitNArrayIterator( int count, CvArr** arrs,
|
|
||||||
const CvArr* mask, CvMatND* stubs,
|
|
||||||
CvNArrayIterator* array_iterator,
|
|
||||||
int flags CV_DEFAULT(0) );
|
|
||||||
|
|
||||||
/** returns zero value if iteration is finished, non-zero (slice length) otherwise */
|
|
||||||
CVAPI(int) cvNextNArraySlice( CvNArrayIterator* array_iterator );
|
|
||||||
|
|
||||||
|
|
||||||
/** @brief Returns type of array elements.
|
/** @brief Returns type of array elements.
|
||||||
|
|
||||||
The function returns type of the array elements. In the case of IplImage the type is converted to
|
The function returns type of the array elements. In the case of IplImage the type is converted to
|
||||||
@ -793,46 +750,6 @@ this function, we will get different headers if the ROI is set in the original i
|
|||||||
CVAPI(IplImage*) cvGetImage( const CvArr* arr, IplImage* image_header );
|
CVAPI(IplImage*) cvGetImage( const CvArr* arr, IplImage* image_header );
|
||||||
|
|
||||||
|
|
||||||
/** @brief Changes the shape of a multi-dimensional array without copying the data.
|
|
||||||
|
|
||||||
The function is an advanced version of cvReshape that can work with multi-dimensional arrays as
|
|
||||||
well (though it can work with ordinary images and matrices) and change the number of dimensions.
|
|
||||||
|
|
||||||
Below are the two samples from the cvReshape description rewritten using cvReshapeMatND:
|
|
||||||
@code
|
|
||||||
IplImage* color_img = cvCreateImage(cvSize(320,240), IPL_DEPTH_8U, 3);
|
|
||||||
IplImage gray_img_hdr, *gray_img;
|
|
||||||
gray_img = (IplImage*)cvReshapeMatND(color_img, sizeof(gray_img_hdr), &gray_img_hdr, 1, 0, 0);
|
|
||||||
...
|
|
||||||
int size[] = { 2, 2, 2 };
|
|
||||||
CvMatND* mat = cvCreateMatND(3, size, CV_32F);
|
|
||||||
CvMat row_header, *row;
|
|
||||||
row = (CvMat*)cvReshapeMatND(mat, sizeof(row_header), &row_header, 0, 1, 0);
|
|
||||||
@endcode
|
|
||||||
In C, the header file for this function includes a convenient macro cvReshapeND that does away with
|
|
||||||
the sizeof_header parameter. So, the lines containing the call to cvReshapeMatND in the examples
|
|
||||||
may be replaced as follow:
|
|
||||||
@code
|
|
||||||
gray_img = (IplImage*)cvReshapeND(color_img, &gray_img_hdr, 1, 0, 0);
|
|
||||||
...
|
|
||||||
row = (CvMat*)cvReshapeND(mat, &row_header, 0, 1, 0);
|
|
||||||
@endcode
|
|
||||||
@param arr Input array
|
|
||||||
@param sizeof_header Size of output header to distinguish between IplImage, CvMat and CvMatND
|
|
||||||
output headers
|
|
||||||
@param header Output header to be filled
|
|
||||||
@param new_cn New number of channels. new_cn = 0 means that the number of channels remains
|
|
||||||
unchanged.
|
|
||||||
@param new_dims New number of dimensions. new_dims = 0 means that the number of dimensions
|
|
||||||
remains the same.
|
|
||||||
@param new_sizes Array of new dimension sizes. Only new_dims-1 values are used, because the
|
|
||||||
total number of elements must remain the same. Thus, if new_dims = 1, new_sizes array is not
|
|
||||||
used.
|
|
||||||
*/
|
|
||||||
CVAPI(CvArr*) cvReshapeMatND( const CvArr* arr,
|
|
||||||
int sizeof_header, CvArr* header,
|
|
||||||
int new_cn, int new_dims, int* new_sizes );
|
|
||||||
|
|
||||||
#define cvReshapeND( arr, header, new_cn, new_dims, new_sizes ) \
|
#define cvReshapeND( arr, header, new_cn, new_dims, new_sizes ) \
|
||||||
cvReshapeMatND( (arr), sizeof(*(header)), (header), \
|
cvReshapeMatND( (arr), sizeof(*(header)), (header), \
|
||||||
(new_cn), (new_dims), (new_sizes))
|
(new_cn), (new_dims), (new_sizes))
|
||||||
@ -867,10 +784,6 @@ unchanged unless it needs to be changed according to new_cn value.
|
|||||||
CVAPI(CvMat*) cvReshape( const CvArr* arr, CvMat* header,
|
CVAPI(CvMat*) cvReshape( const CvArr* arr, CvMat* header,
|
||||||
int new_cn, int new_rows CV_DEFAULT(0) );
|
int new_cn, int new_rows CV_DEFAULT(0) );
|
||||||
|
|
||||||
/** Repeats source 2d array several times in both horizontal and
|
|
||||||
vertical direction to fill destination array */
|
|
||||||
CVAPI(void) cvRepeat( const CvArr* src, CvArr* dst );
|
|
||||||
|
|
||||||
/** @brief Allocates array data
|
/** @brief Allocates array data
|
||||||
|
|
||||||
The function allocates image, matrix or multi-dimensional dense array data. Note that in the case of
|
The function allocates image, matrix or multi-dimensional dense array data. Note that in the case of
|
||||||
@ -1084,12 +997,6 @@ CVAPI(void) cvDiv( const CvArr* src1, const CvArr* src2,
|
|||||||
/** dst = src1 * scale + src2 */
|
/** dst = src1 * scale + src2 */
|
||||||
CVAPI(void) cvScaleAdd( const CvArr* src1, CvScalar scale,
|
CVAPI(void) cvScaleAdd( const CvArr* src1, CvScalar scale,
|
||||||
const CvArr* src2, CvArr* dst );
|
const CvArr* src2, CvArr* dst );
|
||||||
#define cvAXPY( A, real_scalar, B, C ) cvScaleAdd(A, cvRealScalar(real_scalar), B, C)
|
|
||||||
|
|
||||||
/** dst = src1 * alpha + src2 * beta + gamma */
|
|
||||||
CVAPI(void) cvAddWeighted( const CvArr* src1, double alpha,
|
|
||||||
const CvArr* src2, double beta,
|
|
||||||
double gamma, CvArr* dst );
|
|
||||||
|
|
||||||
/** @brief Calculates the dot product of two arrays in Euclidean metrics.
|
/** @brief Calculates the dot product of two arrays in Euclidean metrics.
|
||||||
|
|
||||||
@ -1132,14 +1039,6 @@ CVAPI(void) cvXorS( const CvArr* src, CvScalar value,
|
|||||||
/** dst(idx) = ~src(idx) */
|
/** dst(idx) = ~src(idx) */
|
||||||
CVAPI(void) cvNot( const CvArr* src, CvArr* dst );
|
CVAPI(void) cvNot( const CvArr* src, CvArr* dst );
|
||||||
|
|
||||||
/** dst(idx) = lower(idx) <= src(idx) < upper(idx) */
|
|
||||||
CVAPI(void) cvInRange( const CvArr* src, const CvArr* lower,
|
|
||||||
const CvArr* upper, CvArr* dst );
|
|
||||||
|
|
||||||
/** dst(idx) = lower <= src(idx) < upper */
|
|
||||||
CVAPI(void) cvInRangeS( const CvArr* src, CvScalar lower,
|
|
||||||
CvScalar upper, CvArr* dst );
|
|
||||||
|
|
||||||
#define CV_CMP_EQ 0
|
#define CV_CMP_EQ 0
|
||||||
#define CV_CMP_GT 1
|
#define CV_CMP_GT 1
|
||||||
#define CV_CMP_GE 2
|
#define CV_CMP_GE 2
|
||||||
@ -1150,48 +1049,13 @@ CVAPI(void) cvInRangeS( const CvArr* src, CvScalar lower,
|
|||||||
/** The comparison operation support single-channel arrays only.
|
/** The comparison operation support single-channel arrays only.
|
||||||
Destination image should be 8uC1 or 8sC1 */
|
Destination image should be 8uC1 or 8sC1 */
|
||||||
|
|
||||||
/** dst(idx) = src1(idx) _cmp_op_ src2(idx) */
|
|
||||||
CVAPI(void) cvCmp( const CvArr* src1, const CvArr* src2, CvArr* dst, int cmp_op );
|
|
||||||
|
|
||||||
/** dst(idx) = src1(idx) _cmp_op_ value */
|
/** dst(idx) = src1(idx) _cmp_op_ value */
|
||||||
CVAPI(void) cvCmpS( const CvArr* src, double value, CvArr* dst, int cmp_op );
|
CVAPI(void) cvCmpS( const CvArr* src, double value, CvArr* dst, int cmp_op );
|
||||||
|
|
||||||
/** dst(idx) = min(src1(idx),src2(idx)) */
|
|
||||||
CVAPI(void) cvMin( const CvArr* src1, const CvArr* src2, CvArr* dst );
|
|
||||||
|
|
||||||
/** dst(idx) = max(src1(idx),src2(idx)) */
|
|
||||||
CVAPI(void) cvMax( const CvArr* src1, const CvArr* src2, CvArr* dst );
|
|
||||||
|
|
||||||
/** dst(idx) = min(src(idx),value) */
|
|
||||||
CVAPI(void) cvMinS( const CvArr* src, double value, CvArr* dst );
|
|
||||||
|
|
||||||
/** dst(idx) = max(src(idx),value) */
|
|
||||||
CVAPI(void) cvMaxS( const CvArr* src, double value, CvArr* dst );
|
|
||||||
|
|
||||||
/** dst(x,y,c) = abs(src1(x,y,c) - src2(x,y,c)) */
|
|
||||||
CVAPI(void) cvAbsDiff( const CvArr* src1, const CvArr* src2, CvArr* dst );
|
|
||||||
|
|
||||||
/** dst(x,y,c) = abs(src(x,y,c) - value(c)) */
|
|
||||||
CVAPI(void) cvAbsDiffS( const CvArr* src, CvArr* dst, CvScalar value );
|
|
||||||
#define cvAbs( src, dst ) cvAbsDiffS( (src), (dst), cvScalarAll(0))
|
|
||||||
|
|
||||||
/****************************************************************************************\
|
/****************************************************************************************\
|
||||||
* Math operations *
|
* Math operations *
|
||||||
\****************************************************************************************/
|
\****************************************************************************************/
|
||||||
|
|
||||||
/** Does cartesian->polar coordinates conversion.
|
|
||||||
Either of output components (magnitude or angle) is optional */
|
|
||||||
CVAPI(void) cvCartToPolar( const CvArr* x, const CvArr* y,
|
|
||||||
CvArr* magnitude, CvArr* angle CV_DEFAULT(NULL),
|
|
||||||
int angle_in_degrees CV_DEFAULT(0));
|
|
||||||
|
|
||||||
/** Does polar->cartesian coordinates conversion.
|
|
||||||
Either of output components (magnitude or angle) is optional.
|
|
||||||
If magnitude is missing it is assumed to be all 1's */
|
|
||||||
CVAPI(void) cvPolarToCart( const CvArr* magnitude, const CvArr* angle,
|
|
||||||
CvArr* x, CvArr* y,
|
|
||||||
int angle_in_degrees CV_DEFAULT(0));
|
|
||||||
|
|
||||||
/** Does powering: dst(idx) = src(idx)^power */
|
/** Does powering: dst(idx) = src(idx)^power */
|
||||||
CVAPI(void) cvPow( const CvArr* src, CvArr* dst, double power );
|
CVAPI(void) cvPow( const CvArr* src, CvArr* dst, double power );
|
||||||
|
|
||||||
@ -1200,17 +1064,6 @@ CVAPI(void) cvPow( const CvArr* src, CvArr* dst, double power );
|
|||||||
Maximal relative error is ~7e-6 for single-precision input */
|
Maximal relative error is ~7e-6 for single-precision input */
|
||||||
CVAPI(void) cvExp( const CvArr* src, CvArr* dst );
|
CVAPI(void) cvExp( const CvArr* src, CvArr* dst );
|
||||||
|
|
||||||
/** Calculates natural logarithms: dst(idx) = log(abs(src(idx))).
|
|
||||||
Logarithm of 0 gives large negative number(~-700)
|
|
||||||
Maximal relative error is ~3e-7 for single-precision output
|
|
||||||
*/
|
|
||||||
CVAPI(void) cvLog( const CvArr* src, CvArr* dst );
|
|
||||||
|
|
||||||
/** Fast arctangent calculation */
|
|
||||||
CVAPI(float) cvFastArctan( float y, float x );
|
|
||||||
|
|
||||||
/** Fast cubic root calculation */
|
|
||||||
CVAPI(float) cvCbrt( float value );
|
|
||||||
|
|
||||||
#define CV_CHECK_RANGE 1
|
#define CV_CHECK_RANGE 1
|
||||||
#define CV_CHECK_QUIET 2
|
#define CV_CHECK_QUIET 2
|
||||||
@ -1256,8 +1109,6 @@ CVAPI(void) cvSort( const CvArr* src, CvArr* dst CV_DEFAULT(NULL),
|
|||||||
CvArr* idxmat CV_DEFAULT(NULL),
|
CvArr* idxmat CV_DEFAULT(NULL),
|
||||||
int flags CV_DEFAULT(0));
|
int flags CV_DEFAULT(0));
|
||||||
|
|
||||||
/** Finds real roots of a cubic equation */
|
|
||||||
CVAPI(int) cvSolveCubic( const CvMat* coeffs, CvMat* roots );
|
|
||||||
|
|
||||||
/** Finds all real and complex roots of a polynomial equation */
|
/** Finds all real and complex roots of a polynomial equation */
|
||||||
CVAPI(void) cvSolvePoly(const CvMat* coeffs, CvMat *roots2,
|
CVAPI(void) cvSolvePoly(const CvMat* coeffs, CvMat *roots2,
|
||||||
@ -1917,21 +1768,10 @@ CVAPI(void) cvRemoveNodeFromTree( void* node, void* frame );
|
|||||||
CVAPI(CvSeq*) cvTreeToNodeSeq( const void* first, int header_size,
|
CVAPI(CvSeq*) cvTreeToNodeSeq( const void* first, int header_size,
|
||||||
CvMemStorage* storage );
|
CvMemStorage* storage );
|
||||||
|
|
||||||
/** The function implements the K-means algorithm for clustering an array of sample
|
|
||||||
vectors in a specified number of classes */
|
|
||||||
#define CV_KMEANS_USE_INITIAL_LABELS 1
|
|
||||||
CVAPI(int) cvKMeans2( const CvArr* samples, int cluster_count, CvArr* labels,
|
|
||||||
CvTermCriteria termcrit, int attempts CV_DEFAULT(1),
|
|
||||||
CvRNG* rng CV_DEFAULT(0), int flags CV_DEFAULT(0),
|
|
||||||
CvArr* _centers CV_DEFAULT(0), double* compactness CV_DEFAULT(0) );
|
|
||||||
|
|
||||||
/****************************************************************************************\
|
/****************************************************************************************\
|
||||||
* System functions *
|
* System functions *
|
||||||
\****************************************************************************************/
|
\****************************************************************************************/
|
||||||
|
|
||||||
/** Loads optimized functions from IPP, MKL etc. or switches back to pure C code */
|
|
||||||
CVAPI(int) cvUseOptimized( int on_off );
|
|
||||||
|
|
||||||
typedef IplImage* (CV_STDCALL* Cv_iplCreateImageHeader)
|
typedef IplImage* (CV_STDCALL* Cv_iplCreateImageHeader)
|
||||||
(int,int,int,char*,char*,int,int,int,int,int,
|
(int,int,int,char*,char*,int,int,int,int,int,
|
||||||
IplROI*,IplImage*,void*,IplTileInfo*);
|
IplROI*,IplImage*,void*,IplTileInfo*);
|
||||||
@ -1966,598 +1806,6 @@ CVAPI(void) cvSetIPLAllocators( Cv_iplCreateImageHeader create_header,
|
|||||||
cvSetIPLAllocators( iplCreateImageHeader, iplAllocateImage, \
|
cvSetIPLAllocators( iplCreateImageHeader, iplAllocateImage, \
|
||||||
iplDeallocate, iplCreateROI, iplCloneImage )
|
iplDeallocate, iplCreateROI, iplCloneImage )
|
||||||
|
|
||||||
/****************************************************************************************\
|
|
||||||
* Data Persistence *
|
|
||||||
\****************************************************************************************/
|
|
||||||
|
|
||||||
#if 0
|
|
||||||
/********************************** High-level functions ********************************/
|
|
||||||
|
|
||||||
/** @brief Opens file storage for reading or writing data.
|
|
||||||
|
|
||||||
The function opens file storage for reading or writing data. In the latter case, a new file is
|
|
||||||
created or an existing file is rewritten. The type of the read or written file is determined by the
|
|
||||||
filename extension: .xml for XML, .yml or .yaml for YAML and .json for JSON.
|
|
||||||
|
|
||||||
At the same time, it also supports adding parameters like "example.xml?base64".
|
|
||||||
|
|
||||||
The function returns a pointer to the CvFileStorage structure.
|
|
||||||
If the file cannot be opened then the function returns NULL.
|
|
||||||
@param filename Name of the file associated with the storage
|
|
||||||
@param memstorage Memory storage used for temporary data and for
|
|
||||||
: storing dynamic structures, such as CvSeq or CvGraph . If it is NULL, a temporary memory
|
|
||||||
storage is created and used.
|
|
||||||
@param flags Can be one of the following:
|
|
||||||
> - **CV_STORAGE_READ** the storage is open for reading
|
|
||||||
> - **CV_STORAGE_WRITE** the storage is open for writing
|
|
||||||
(use **CV_STORAGE_WRITE | CV_STORAGE_WRITE_BASE64** to write rawdata in Base64)
|
|
||||||
@param encoding
|
|
||||||
*/
|
|
||||||
CVAPI(CvFileStorage*) cvOpenFileStorage( const char* filename, CvMemStorage* memstorage,
|
|
||||||
int flags, const char* encoding CV_DEFAULT(NULL) );
|
|
||||||
|
|
||||||
/** @brief Releases file storage.
|
|
||||||
|
|
||||||
The function closes the file associated with the storage and releases all the temporary structures.
|
|
||||||
It must be called after all I/O operations with the storage are finished.
|
|
||||||
@param fs Double pointer to the released file storage
|
|
||||||
*/
|
|
||||||
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 );
|
|
||||||
|
|
||||||
/** @brief Starts writing a new structure.
|
|
||||||
|
|
||||||
The function starts writing a compound structure (collection) that can be a sequence or a map. After
|
|
||||||
all the structure fields, which can be scalars or structures, are written, cvEndWriteStruct should
|
|
||||||
be called. The function can be used to group some objects or to implement the write function for a
|
|
||||||
some user object (see CvTypeInfo).
|
|
||||||
@param fs File storage
|
|
||||||
@param name Name of the written structure. The structure can be accessed by this name when the
|
|
||||||
storage is read.
|
|
||||||
@param struct_flags A combination one of the following values:
|
|
||||||
- **CV_NODE_SEQ** the written structure is a sequence (see discussion of CvFileStorage ),
|
|
||||||
that is, its elements do not have a name.
|
|
||||||
- **CV_NODE_MAP** the written structure is a map (see discussion of CvFileStorage ), that
|
|
||||||
is, all its elements have names.
|
|
||||||
One and only one of the two above flags must be specified
|
|
||||||
- **CV_NODE_FLOW** the optional flag that makes sense only for YAML streams. It means that
|
|
||||||
the structure is written as a flow (not as a block), which is more compact. It is
|
|
||||||
recommended to use this flag for structures or arrays whose elements are all scalars.
|
|
||||||
@param type_name Optional parameter - the object type name. In
|
|
||||||
case of XML it is written as a type_id attribute of the structure opening tag. In the case of
|
|
||||||
YAML it is written after a colon following the structure name (see the example in
|
|
||||||
CvFileStorage description). In case of JSON it is written as a name/value pair.
|
|
||||||
Mainly it is used with user objects. When the storage is read, the
|
|
||||||
encoded type name is used to determine the object type (see CvTypeInfo and cvFindType ).
|
|
||||||
@param attributes This parameter is not used in the current implementation
|
|
||||||
*/
|
|
||||||
CVAPI(void) cvStartWriteStruct( CvFileStorage* fs, const char* name,
|
|
||||||
int struct_flags, const char* type_name CV_DEFAULT(NULL),
|
|
||||||
CvAttrList attributes CV_DEFAULT(cvAttrList()));
|
|
||||||
|
|
||||||
/** @brief Finishes writing to a file node collection.
|
|
||||||
@param fs File storage
|
|
||||||
@sa cvStartWriteStruct.
|
|
||||||
*/
|
|
||||||
CVAPI(void) cvEndWriteStruct( CvFileStorage* fs );
|
|
||||||
|
|
||||||
/** @brief Writes an integer value.
|
|
||||||
|
|
||||||
The function writes a single integer value (with or without a name) to the file storage.
|
|
||||||
@param fs File storage
|
|
||||||
@param name Name of the written value. Should be NULL if and only if the parent structure is a
|
|
||||||
sequence.
|
|
||||||
@param value The written value
|
|
||||||
*/
|
|
||||||
CVAPI(void) cvWriteInt( CvFileStorage* fs, const char* name, int value );
|
|
||||||
|
|
||||||
/** @brief Writes a floating-point value.
|
|
||||||
|
|
||||||
The function writes a single floating-point value (with or without a name) to file storage. Special
|
|
||||||
values are encoded as follows: NaN (Not A Number) as .NaN, infinity as +.Inf or -.Inf.
|
|
||||||
|
|
||||||
The following example shows how to use the low-level writing functions to store custom structures,
|
|
||||||
such as termination criteria, without registering a new type. :
|
|
||||||
@code
|
|
||||||
void write_termcriteria( CvFileStorage* fs, const char* struct_name,
|
|
||||||
CvTermCriteria* termcrit )
|
|
||||||
{
|
|
||||||
cvStartWriteStruct( fs, struct_name, CV_NODE_MAP, NULL, cvAttrList(0,0));
|
|
||||||
cvWriteComment( fs, "termination criteria", 1 ); // just a description
|
|
||||||
if( termcrit->type & CV_TERMCRIT_ITER )
|
|
||||||
cvWriteInteger( fs, "max_iterations", termcrit->max_iter );
|
|
||||||
if( termcrit->type & CV_TERMCRIT_EPS )
|
|
||||||
cvWriteReal( fs, "accuracy", termcrit->epsilon );
|
|
||||||
cvEndWriteStruct( fs );
|
|
||||||
}
|
|
||||||
@endcode
|
|
||||||
@param fs File storage
|
|
||||||
@param name Name of the written value. Should be NULL if and only if the parent structure is a
|
|
||||||
sequence.
|
|
||||||
@param value The written value
|
|
||||||
*/
|
|
||||||
CVAPI(void) cvWriteReal( CvFileStorage* fs, const char* name, double value );
|
|
||||||
|
|
||||||
/** @brief Writes a text string.
|
|
||||||
|
|
||||||
The function writes a text string to file storage.
|
|
||||||
@param fs File storage
|
|
||||||
@param name Name of the written string . Should be NULL if and only if the parent structure is a
|
|
||||||
sequence.
|
|
||||||
@param str The written text string
|
|
||||||
@param quote If non-zero, the written string is put in quotes, regardless of whether they are
|
|
||||||
required. Otherwise, if the flag is zero, quotes are used only when they are required (e.g. when
|
|
||||||
the string starts with a digit or contains spaces).
|
|
||||||
*/
|
|
||||||
CVAPI(void) cvWriteString( CvFileStorage* fs, const char* name,
|
|
||||||
const char* str, int quote CV_DEFAULT(0) );
|
|
||||||
|
|
||||||
/** @brief Writes a comment.
|
|
||||||
|
|
||||||
The function writes a comment into file storage. The comments are skipped when the storage is read.
|
|
||||||
@param fs File storage
|
|
||||||
@param comment The written comment, single-line or multi-line
|
|
||||||
@param eol_comment If non-zero, the function tries to put the comment at the end of current line.
|
|
||||||
If the flag is zero, if the comment is multi-line, or if it does not fit at the end of the current
|
|
||||||
line, the comment starts a new line.
|
|
||||||
*/
|
|
||||||
CVAPI(void) cvWriteComment( CvFileStorage* fs, const char* comment,
|
|
||||||
int eol_comment );
|
|
||||||
|
|
||||||
/** @brief Writes an object to file storage.
|
|
||||||
|
|
||||||
The function writes an object to file storage. First, the appropriate type info is found using
|
|
||||||
cvTypeOf. Then, the write method associated with the type info is called.
|
|
||||||
|
|
||||||
Attributes are used to customize the writing procedure. The standard types support the following
|
|
||||||
attributes (all the dt attributes have the same format as in cvWriteRawData):
|
|
||||||
|
|
||||||
-# CvSeq
|
|
||||||
- **header_dt** description of user fields of the sequence header that follow CvSeq, or
|
|
||||||
CvChain (if the sequence is a Freeman chain) or CvContour (if the sequence is a contour or
|
|
||||||
point sequence)
|
|
||||||
- **dt** description of the sequence elements.
|
|
||||||
- **recursive** if the attribute is present and is not equal to "0" or "false", the whole
|
|
||||||
tree of sequences (contours) is stored.
|
|
||||||
-# CvGraph
|
|
||||||
- **header_dt** description of user fields of the graph header that follows CvGraph;
|
|
||||||
- **vertex_dt** description of user fields of graph vertices
|
|
||||||
- **edge_dt** description of user fields of graph edges (note that the edge weight is
|
|
||||||
always written, so there is no need to specify it explicitly)
|
|
||||||
|
|
||||||
Below is the code that creates the YAML file shown in the CvFileStorage description:
|
|
||||||
@code
|
|
||||||
#include "cxcore.h"
|
|
||||||
|
|
||||||
int main( int argc, char** argv )
|
|
||||||
{
|
|
||||||
CvMat* mat = cvCreateMat( 3, 3, CV_32F );
|
|
||||||
CvFileStorage* fs = cvOpenFileStorage( "example.yml", 0, CV_STORAGE_WRITE );
|
|
||||||
|
|
||||||
cvSetIdentity( mat );
|
|
||||||
cvWrite( fs, "A", mat, cvAttrList(0,0) );
|
|
||||||
|
|
||||||
cvReleaseFileStorage( &fs );
|
|
||||||
cvReleaseMat( &mat );
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
@endcode
|
|
||||||
@param fs File storage
|
|
||||||
@param name Name of the written object. Should be NULL if and only if the parent structure is a
|
|
||||||
sequence.
|
|
||||||
@param ptr Pointer to the object
|
|
||||||
@param attributes The attributes of the object. They are specific for each particular type (see
|
|
||||||
the discussion below).
|
|
||||||
*/
|
|
||||||
CVAPI(void) cvWrite( CvFileStorage* fs, const char* name, const void* ptr,
|
|
||||||
CvAttrList attributes CV_DEFAULT(cvAttrList()));
|
|
||||||
|
|
||||||
/** @brief Starts the next stream.
|
|
||||||
|
|
||||||
The function finishes the currently written stream and starts the next stream. In the case of XML
|
|
||||||
the file with multiple streams looks like this:
|
|
||||||
@code{.xml}
|
|
||||||
<opencv_storage>
|
|
||||||
<!-- stream #1 data -->
|
|
||||||
</opencv_storage>
|
|
||||||
<opencv_storage>
|
|
||||||
<!-- stream #2 data -->
|
|
||||||
</opencv_storage>
|
|
||||||
...
|
|
||||||
@endcode
|
|
||||||
The YAML file will look like this:
|
|
||||||
@code{.yaml}
|
|
||||||
%YAML 1.0
|
|
||||||
# stream #1 data
|
|
||||||
...
|
|
||||||
---
|
|
||||||
# stream #2 data
|
|
||||||
@endcode
|
|
||||||
This is useful for concatenating files or for resuming the writing process.
|
|
||||||
@param fs File storage
|
|
||||||
*/
|
|
||||||
CVAPI(void) cvStartNextStream( CvFileStorage* fs );
|
|
||||||
|
|
||||||
/** @brief Writes multiple numbers.
|
|
||||||
|
|
||||||
The function writes an array, whose elements consist of single or multiple numbers. The function
|
|
||||||
call can be replaced with a loop containing a few cvWriteInt and cvWriteReal calls, but a single
|
|
||||||
call is more efficient. Note that because none of the elements have a name, they should be written
|
|
||||||
to a sequence rather than a map.
|
|
||||||
@param fs File storage
|
|
||||||
@param src Pointer to the written array
|
|
||||||
@param len Number of the array elements to write
|
|
||||||
@param dt Specification of each array element, see @ref format_spec "format specification"
|
|
||||||
*/
|
|
||||||
CVAPI(void) cvWriteRawData( CvFileStorage* fs, const void* src,
|
|
||||||
int len, const char* dt );
|
|
||||||
|
|
||||||
/** @brief Writes multiple numbers in Base64.
|
|
||||||
|
|
||||||
If either CV_STORAGE_WRITE_BASE64 or cv::FileStorage::WRITE_BASE64 is used,
|
|
||||||
this function will be the same as cvWriteRawData. If neither, the main
|
|
||||||
difference is that it outputs a sequence in Base64 encoding rather than
|
|
||||||
in plain text.
|
|
||||||
|
|
||||||
This function can only be used to write a sequence with a type "binary".
|
|
||||||
|
|
||||||
@param fs File storage
|
|
||||||
@param src Pointer to the written array
|
|
||||||
@param len Number of the array elements to write
|
|
||||||
@param dt Specification of each array element, see @ref format_spec "format specification"
|
|
||||||
*/
|
|
||||||
CVAPI(void) cvWriteRawDataBase64( CvFileStorage* fs, const void* src,
|
|
||||||
int len, const char* dt );
|
|
||||||
|
|
||||||
/** @brief Returns a unique pointer for a given name.
|
|
||||||
|
|
||||||
The function returns a unique pointer for each particular file node name. This pointer can be then
|
|
||||||
passed to the cvGetFileNode function that is faster than cvGetFileNodeByName because it compares
|
|
||||||
text strings by comparing pointers rather than the strings' content.
|
|
||||||
|
|
||||||
Consider the following example where an array of points is encoded as a sequence of 2-entry maps:
|
|
||||||
@code
|
|
||||||
points:
|
|
||||||
- { x: 10, y: 10 }
|
|
||||||
- { x: 20, y: 20 }
|
|
||||||
- { x: 30, y: 30 }
|
|
||||||
# ...
|
|
||||||
@endcode
|
|
||||||
Then, it is possible to get hashed "x" and "y" pointers to speed up decoding of the points. :
|
|
||||||
@code
|
|
||||||
#include "cxcore.h"
|
|
||||||
|
|
||||||
int main( int argc, char** argv )
|
|
||||||
{
|
|
||||||
CvFileStorage* fs = cvOpenFileStorage( "points.yml", 0, CV_STORAGE_READ );
|
|
||||||
CvStringHashNode* x_key = cvGetHashedNode( fs, "x", -1, 1 );
|
|
||||||
CvStringHashNode* y_key = cvGetHashedNode( fs, "y", -1, 1 );
|
|
||||||
CvFileNode* points = cvGetFileNodeByName( fs, 0, "points" );
|
|
||||||
|
|
||||||
if( CV_NODE_IS_SEQ(points->tag) )
|
|
||||||
{
|
|
||||||
CvSeq* seq = points->data.seq;
|
|
||||||
int i, total = seq->total;
|
|
||||||
CvSeqReader reader;
|
|
||||||
cvStartReadSeq( seq, &reader, 0 );
|
|
||||||
for( i = 0; i < total; i++ )
|
|
||||||
{
|
|
||||||
CvFileNode* pt = (CvFileNode*)reader.ptr;
|
|
||||||
#if 1 // faster variant
|
|
||||||
CvFileNode* xnode = cvGetFileNode( fs, pt, x_key, 0 );
|
|
||||||
CvFileNode* ynode = cvGetFileNode( fs, pt, y_key, 0 );
|
|
||||||
assert( xnode && CV_NODE_IS_INT(xnode->tag) &&
|
|
||||||
ynode && CV_NODE_IS_INT(ynode->tag));
|
|
||||||
int x = xnode->data.i; // or x = cvReadInt( xnode, 0 );
|
|
||||||
int y = ynode->data.i; // or y = cvReadInt( ynode, 0 );
|
|
||||||
#elif 1 // slower variant; does not use x_key & y_key
|
|
||||||
CvFileNode* xnode = cvGetFileNodeByName( fs, pt, "x" );
|
|
||||||
CvFileNode* ynode = cvGetFileNodeByName( fs, pt, "y" );
|
|
||||||
assert( xnode && CV_NODE_IS_INT(xnode->tag) &&
|
|
||||||
ynode && CV_NODE_IS_INT(ynode->tag));
|
|
||||||
int x = xnode->data.i; // or x = cvReadInt( xnode, 0 );
|
|
||||||
int y = ynode->data.i; // or y = cvReadInt( ynode, 0 );
|
|
||||||
#else // the slowest yet the easiest to use variant
|
|
||||||
int x = cvReadIntByName( fs, pt, "x", 0 );
|
|
||||||
int y = cvReadIntByName( fs, pt, "y", 0 );
|
|
||||||
#endif
|
|
||||||
CV_NEXT_SEQ_ELEM( seq->elem_size, reader );
|
|
||||||
printf("
|
|
||||||
}
|
|
||||||
}
|
|
||||||
cvReleaseFileStorage( &fs );
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
@endcode
|
|
||||||
Please note that whatever method of accessing a map you are using, it is still much slower than
|
|
||||||
using plain sequences; for example, in the above example, it is more efficient to encode the points
|
|
||||||
as pairs of integers in a single numeric sequence.
|
|
||||||
@param fs File storage
|
|
||||||
@param name Literal node name
|
|
||||||
@param len Length of the name (if it is known apriori), or -1 if it needs to be calculated
|
|
||||||
@param create_missing Flag that specifies, whether an absent key should be added into the hash table
|
|
||||||
*/
|
|
||||||
CVAPI(CvStringHashNode*) cvGetHashedKey( CvFileStorage* fs, const char* name,
|
|
||||||
int len CV_DEFAULT(-1),
|
|
||||||
int create_missing CV_DEFAULT(0));
|
|
||||||
|
|
||||||
/** @brief Retrieves one of the top-level nodes of the file storage.
|
|
||||||
|
|
||||||
The function returns one of the top-level file nodes. The top-level nodes do not have a name, they
|
|
||||||
correspond to the streams that are stored one after another in the file storage. If the index is out
|
|
||||||
of range, the function returns a NULL pointer, so all the top-level nodes can be iterated by
|
|
||||||
subsequent calls to the function with stream_index=0,1,..., until the NULL pointer is returned.
|
|
||||||
This function can be used as a base for recursive traversal of the file storage.
|
|
||||||
@param fs File storage
|
|
||||||
@param stream_index Zero-based index of the stream. See cvStartNextStream . In most cases,
|
|
||||||
there is only one stream in the file; however, there can be several.
|
|
||||||
*/
|
|
||||||
CVAPI(CvFileNode*) cvGetRootFileNode( const CvFileStorage* fs,
|
|
||||||
int stream_index CV_DEFAULT(0) );
|
|
||||||
|
|
||||||
/** @brief Finds a node in a map or file storage.
|
|
||||||
|
|
||||||
The function finds a file node. It is a faster version of cvGetFileNodeByName (see
|
|
||||||
cvGetHashedKey discussion). Also, the function can insert a new node, if it is not in the map yet.
|
|
||||||
@param fs File storage
|
|
||||||
@param map The parent map. If it is NULL, the function searches a top-level node. If both map and
|
|
||||||
key are NULLs, the function returns the root file node - a map that contains top-level nodes.
|
|
||||||
@param key Unique pointer to the node name, retrieved with cvGetHashedKey
|
|
||||||
@param create_missing Flag that specifies whether an absent node should be added to the map
|
|
||||||
*/
|
|
||||||
CVAPI(CvFileNode*) cvGetFileNode( CvFileStorage* fs, CvFileNode* map,
|
|
||||||
const CvStringHashNode* key,
|
|
||||||
int create_missing CV_DEFAULT(0) );
|
|
||||||
|
|
||||||
/** @brief Finds a node in a map or file storage.
|
|
||||||
|
|
||||||
The function finds a file node by name. The node is searched either in map or, if the pointer is
|
|
||||||
NULL, among the top-level file storage nodes. Using this function for maps and cvGetSeqElem (or
|
|
||||||
sequence reader) for sequences, it is possible to navigate through the file storage. To speed up
|
|
||||||
multiple queries for a certain key (e.g., in the case of an array of structures) one may use a
|
|
||||||
combination of cvGetHashedKey and cvGetFileNode.
|
|
||||||
@param fs File storage
|
|
||||||
@param map The parent map. If it is NULL, the function searches in all the top-level nodes
|
|
||||||
(streams), starting with the first one.
|
|
||||||
@param name The file node name
|
|
||||||
*/
|
|
||||||
CVAPI(CvFileNode*) cvGetFileNodeByName( const CvFileStorage* fs,
|
|
||||||
const CvFileNode* map,
|
|
||||||
const char* name );
|
|
||||||
|
|
||||||
/** @brief Retrieves an integer value from a file node.
|
|
||||||
|
|
||||||
The function returns an integer that is represented by the file node. If the file node is NULL, the
|
|
||||||
default_value is returned (thus, it is convenient to call the function right after cvGetFileNode
|
|
||||||
without checking for a NULL pointer). If the file node has type CV_NODE_INT, then node-\>data.i is
|
|
||||||
returned. If the file node has type CV_NODE_REAL, then node-\>data.f is converted to an integer
|
|
||||||
and returned. Otherwise the error is reported.
|
|
||||||
@param node File node
|
|
||||||
@param default_value The value that is returned if node is NULL
|
|
||||||
*/
|
|
||||||
CV_INLINE int cvReadInt( const CvFileNode* node, int default_value CV_DEFAULT(0) )
|
|
||||||
{
|
|
||||||
return !node ? default_value :
|
|
||||||
CV_NODE_IS_INT(node->tag) ? node->data.i :
|
|
||||||
CV_NODE_IS_REAL(node->tag) ? cvRound(node->data.f) : 0x7fffffff;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** @brief Finds a file node and returns its value.
|
|
||||||
|
|
||||||
The function is a simple superposition of cvGetFileNodeByName and cvReadInt.
|
|
||||||
@param fs File storage
|
|
||||||
@param map The parent map. If it is NULL, the function searches a top-level node.
|
|
||||||
@param name The node name
|
|
||||||
@param default_value The value that is returned if the file node is not found
|
|
||||||
*/
|
|
||||||
CV_INLINE int cvReadIntByName( const CvFileStorage* fs, const CvFileNode* map,
|
|
||||||
const char* name, int default_value CV_DEFAULT(0) )
|
|
||||||
{
|
|
||||||
return cvReadInt( cvGetFileNodeByName( fs, map, name ), default_value );
|
|
||||||
}
|
|
||||||
|
|
||||||
/** @brief Retrieves a floating-point value from a file node.
|
|
||||||
|
|
||||||
The function returns a floating-point value that is represented by the file node. If the file node
|
|
||||||
is NULL, the default_value is returned (thus, it is convenient to call the function right after
|
|
||||||
cvGetFileNode without checking for a NULL pointer). If the file node has type CV_NODE_REAL ,
|
|
||||||
then node-\>data.f is returned. If the file node has type CV_NODE_INT , then node-:math:\>data.f
|
|
||||||
is converted to floating-point and returned. Otherwise the result is not determined.
|
|
||||||
@param node File node
|
|
||||||
@param default_value The value that is returned if node is NULL
|
|
||||||
*/
|
|
||||||
CV_INLINE double cvReadReal( const CvFileNode* node, double default_value CV_DEFAULT(0.) )
|
|
||||||
{
|
|
||||||
return !node ? default_value :
|
|
||||||
CV_NODE_IS_INT(node->tag) ? (double)node->data.i :
|
|
||||||
CV_NODE_IS_REAL(node->tag) ? node->data.f : 1e300;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** @brief Finds a file node and returns its value.
|
|
||||||
|
|
||||||
The function is a simple superposition of cvGetFileNodeByName and cvReadReal .
|
|
||||||
@param fs File storage
|
|
||||||
@param map The parent map. If it is NULL, the function searches a top-level node.
|
|
||||||
@param name The node name
|
|
||||||
@param default_value The value that is returned if the file node is not found
|
|
||||||
*/
|
|
||||||
CV_INLINE double cvReadRealByName( const CvFileStorage* fs, const CvFileNode* map,
|
|
||||||
const char* name, double default_value CV_DEFAULT(0.) )
|
|
||||||
{
|
|
||||||
return cvReadReal( cvGetFileNodeByName( fs, map, name ), default_value );
|
|
||||||
}
|
|
||||||
|
|
||||||
/** @brief Retrieves a text string from a file node.
|
|
||||||
|
|
||||||
The function returns a text string that is represented by the file node. If the file node is NULL,
|
|
||||||
the default_value is returned (thus, it is convenient to call the function right after
|
|
||||||
cvGetFileNode without checking for a NULL pointer). If the file node has type CV_NODE_STR , then
|
|
||||||
node-:math:\>data.str.ptr is returned. Otherwise the result is not determined.
|
|
||||||
@param node File node
|
|
||||||
@param default_value The value that is returned if node is NULL
|
|
||||||
*/
|
|
||||||
CV_INLINE const char* cvReadString( const CvFileNode* node,
|
|
||||||
const char* default_value CV_DEFAULT(NULL) )
|
|
||||||
{
|
|
||||||
return !node ? default_value : CV_NODE_IS_STRING(node->tag) ? node->data.str.ptr : 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** @brief Finds a file node by its name and returns its value.
|
|
||||||
|
|
||||||
The function is a simple superposition of cvGetFileNodeByName and cvReadString .
|
|
||||||
@param fs File storage
|
|
||||||
@param map The parent map. If it is NULL, the function searches a top-level node.
|
|
||||||
@param name The node name
|
|
||||||
@param default_value The value that is returned if the file node is not found
|
|
||||||
*/
|
|
||||||
CV_INLINE const char* cvReadStringByName( const CvFileStorage* fs, const CvFileNode* map,
|
|
||||||
const char* name, const char* default_value CV_DEFAULT(NULL) )
|
|
||||||
{
|
|
||||||
return cvReadString( cvGetFileNodeByName( fs, map, name ), default_value );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/** @brief Decodes an object and returns a pointer to it.
|
|
||||||
|
|
||||||
The function decodes a user object (creates an object in a native representation from the file
|
|
||||||
storage subtree) and returns it. The object to be decoded must be an instance of a registered type
|
|
||||||
that supports the read method (see CvTypeInfo). The type of the object is determined by the type
|
|
||||||
name that is encoded in the file. If the object is a dynamic structure, it is created either in
|
|
||||||
memory storage and passed to cvOpenFileStorage or, if a NULL pointer was passed, in temporary
|
|
||||||
memory storage, which is released when cvReleaseFileStorage is called. Otherwise, if the object is
|
|
||||||
not a dynamic structure, it is created in a heap and should be released with a specialized function
|
|
||||||
or by using the generic cvRelease.
|
|
||||||
@param fs File storage
|
|
||||||
@param node The root object node
|
|
||||||
@param attributes Unused parameter
|
|
||||||
*/
|
|
||||||
CVAPI(void*) cvRead( CvFileStorage* fs, CvFileNode* node,
|
|
||||||
CvAttrList* attributes CV_DEFAULT(NULL));
|
|
||||||
|
|
||||||
/** @brief Finds an object by name and decodes it.
|
|
||||||
|
|
||||||
The function is a simple superposition of cvGetFileNodeByName and cvRead.
|
|
||||||
@param fs File storage
|
|
||||||
@param map The parent map. If it is NULL, the function searches a top-level node.
|
|
||||||
@param name The node name
|
|
||||||
@param attributes Unused parameter
|
|
||||||
*/
|
|
||||||
CV_INLINE void* cvReadByName( CvFileStorage* fs, const CvFileNode* map,
|
|
||||||
const char* name, CvAttrList* attributes CV_DEFAULT(NULL) )
|
|
||||||
{
|
|
||||||
return cvRead( fs, cvGetFileNodeByName( fs, map, name ), attributes );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/** @brief Initializes the file node sequence reader.
|
|
||||||
|
|
||||||
The function initializes the sequence reader to read data from a file node. The initialized reader
|
|
||||||
can be then passed to cvReadRawDataSlice.
|
|
||||||
@param fs File storage
|
|
||||||
@param src The file node (a sequence) to read numbers from
|
|
||||||
@param reader Pointer to the sequence reader
|
|
||||||
*/
|
|
||||||
CVAPI(void) cvStartReadRawData( const CvFileStorage* fs, const CvFileNode* src,
|
|
||||||
CvSeqReader* reader );
|
|
||||||
|
|
||||||
/** @brief Initializes file node sequence reader.
|
|
||||||
|
|
||||||
The function reads one or more elements from the file node, representing a sequence, to a
|
|
||||||
user-specified array. The total number of read sequence elements is a product of total and the
|
|
||||||
number of components in each array element. For example, if dt=2if, the function will read total\*3
|
|
||||||
sequence elements. As with any sequence, some parts of the file node sequence can be skipped or read
|
|
||||||
repeatedly by repositioning the reader using cvSetSeqReaderPos.
|
|
||||||
@param fs File storage
|
|
||||||
@param reader The sequence reader. Initialize it with cvStartReadRawData .
|
|
||||||
@param count The number of elements to read
|
|
||||||
@param dst Pointer to the destination array
|
|
||||||
@param dt Specification of each array element. It has the same format as in cvWriteRawData .
|
|
||||||
*/
|
|
||||||
CVAPI(void) cvReadRawDataSlice( const CvFileStorage* fs, CvSeqReader* reader,
|
|
||||||
int count, void* dst, const char* dt );
|
|
||||||
|
|
||||||
/** @brief Reads multiple numbers.
|
|
||||||
|
|
||||||
The function reads elements from a file node that represents a sequence of scalars.
|
|
||||||
@param fs File storage
|
|
||||||
@param src The file node (a sequence) to read numbers from
|
|
||||||
@param dst Pointer to the destination array
|
|
||||||
@param dt Specification of each array element. It has the same format as in cvWriteRawData .
|
|
||||||
*/
|
|
||||||
CVAPI(void) cvReadRawData( const CvFileStorage* fs, const CvFileNode* src,
|
|
||||||
void* dst, const char* dt );
|
|
||||||
|
|
||||||
/** @brief Writes a file node to another file storage.
|
|
||||||
|
|
||||||
The function writes a copy of a file node to file storage. Possible applications of the function are
|
|
||||||
merging several file storages into one and conversion between XML, YAML and JSON formats.
|
|
||||||
@param fs Destination file storage
|
|
||||||
@param new_node_name New name of the file node in the destination file storage. To keep the
|
|
||||||
existing name, use cvcvGetFileNodeName
|
|
||||||
@param node The written node
|
|
||||||
@param embed If the written node is a collection and this parameter is not zero, no extra level of
|
|
||||||
hierarchy is created. Instead, all the elements of node are written into the currently written
|
|
||||||
structure. Of course, map elements can only be embedded into another map, and sequence elements
|
|
||||||
can only be embedded into another sequence.
|
|
||||||
*/
|
|
||||||
CVAPI(void) cvWriteFileNode( CvFileStorage* fs, const char* new_node_name,
|
|
||||||
const CvFileNode* node, int embed );
|
|
||||||
|
|
||||||
/** @brief Returns the name of a file node.
|
|
||||||
|
|
||||||
The function returns the name of a file node or NULL, if the file node does not have a name or if
|
|
||||||
node is NULL.
|
|
||||||
@param node File node
|
|
||||||
*/
|
|
||||||
CVAPI(const char*) cvGetFileNodeName( const CvFileNode* node );
|
|
||||||
|
|
||||||
/*********************************** Adding own types ***********************************/
|
|
||||||
|
|
||||||
/** @brief Registers a new type.
|
|
||||||
|
|
||||||
The function registers a new type, which is described by info . The function creates a copy of the
|
|
||||||
structure, so the user should delete it after calling the function.
|
|
||||||
@param info Type info structure
|
|
||||||
*/
|
|
||||||
CVAPI(void) cvRegisterType( const CvTypeInfo* info );
|
|
||||||
|
|
||||||
/** @brief Unregisters the type.
|
|
||||||
|
|
||||||
The function unregisters a type with a specified name. If the name is unknown, it is possible to
|
|
||||||
locate the type info by an instance of the type using cvTypeOf or by iterating the type list,
|
|
||||||
starting from cvFirstType, and then calling cvUnregisterType(info-\>typeName).
|
|
||||||
@param type_name Name of an unregistered type
|
|
||||||
*/
|
|
||||||
CVAPI(void) cvUnregisterType( const char* type_name );
|
|
||||||
|
|
||||||
/** @brief Returns the beginning of a type list.
|
|
||||||
|
|
||||||
The function returns the first type in the list of registered types. Navigation through the list can
|
|
||||||
be done via the prev and next fields of the CvTypeInfo structure.
|
|
||||||
*/
|
|
||||||
CVAPI(CvTypeInfo*) cvFirstType(void);
|
|
||||||
|
|
||||||
/** @brief Finds a type by its name.
|
|
||||||
|
|
||||||
The function finds a registered type by its name. It returns NULL if there is no type with the
|
|
||||||
specified name.
|
|
||||||
@param type_name Type name
|
|
||||||
*/
|
|
||||||
CVAPI(CvTypeInfo*) cvFindType( const char* type_name );
|
|
||||||
|
|
||||||
/** @brief Returns the type of an object.
|
|
||||||
|
|
||||||
The function finds the type of a given object. It iterates through the list of registered types and
|
|
||||||
calls the is_instance function/method for every type info structure with that object until one of
|
|
||||||
them returns non-zero or until the whole list has been traversed. In the latter case, the function
|
|
||||||
returns NULL.
|
|
||||||
@param struct_ptr The object pointer
|
|
||||||
*/
|
|
||||||
CVAPI(CvTypeInfo*) cvTypeOf( const void* struct_ptr );
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/** @brief Releases an object.
|
/** @brief Releases an object.
|
||||||
|
|
||||||
@ -2566,34 +1814,6 @@ CVAPI(CvTypeInfo*) cvTypeOf( const void* struct_ptr );
|
|||||||
*/
|
*/
|
||||||
CVAPI(void) cvRelease( void** struct_ptr );
|
CVAPI(void) cvRelease( void** struct_ptr );
|
||||||
|
|
||||||
/** @brief Makes a clone of an object.
|
|
||||||
|
|
||||||
The function finds the type of a given object and calls clone with the passed object. Of course, if
|
|
||||||
you know the object type, for example, struct_ptr is CvMat\*, it is faster to call the specific
|
|
||||||
function, like cvCloneMat.
|
|
||||||
@param struct_ptr The object to clone
|
|
||||||
*/
|
|
||||||
CVAPI(void*) cvClone( const void* struct_ptr );
|
|
||||||
|
|
||||||
/*********************************** Measuring Execution Time ***************************/
|
|
||||||
|
|
||||||
/** helper functions for RNG initialization and accurate time measurement:
|
|
||||||
uses internal clock counter on x86 */
|
|
||||||
CVAPI(int64) cvGetTickCount( void );
|
|
||||||
CVAPI(double) cvGetTickFrequency( void );
|
|
||||||
|
|
||||||
/*********************************** CPU capabilities ***********************************/
|
|
||||||
|
|
||||||
CVAPI(int) cvCheckHardwareSupport(int feature);
|
|
||||||
|
|
||||||
/*********************************** Multi-Threading ************************************/
|
|
||||||
|
|
||||||
/** retrieve/set the number of threads used in OpenMP implementations */
|
|
||||||
CVAPI(int) cvGetNumThreads( void );
|
|
||||||
CVAPI(void) cvSetNumThreads( int threads CV_DEFAULT(0) );
|
|
||||||
/** get index of the thread being executed */
|
|
||||||
CVAPI(int) cvGetThreadNum( void );
|
|
||||||
|
|
||||||
|
|
||||||
/********************************** Error Handling **************************************/
|
/********************************** Error Handling **************************************/
|
||||||
|
|
||||||
@ -2629,25 +1849,6 @@ CVAPI(int) cvGetErrInfo( const char** errcode_desc, const char** description,
|
|||||||
/** Maps IPP error codes to the counterparts from OpenCV */
|
/** Maps IPP error codes to the counterparts from OpenCV */
|
||||||
CVAPI(int) cvErrorFromIppStatus( int ipp_status );
|
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 nothing */
|
|
||||||
CVAPI(int) cvNulDevReport( int status, const char* func_name, const char* err_msg,
|
|
||||||
const char* file_name, int line, void* userdata );
|
|
||||||
|
|
||||||
/** Output to console(fprintf(stderr,...)) */
|
|
||||||
CVAPI(int) cvStdErrReport( int status, const char* func_name, const char* err_msg,
|
|
||||||
const char* file_name, int line, void* userdata );
|
|
||||||
|
|
||||||
/** Output to MessageBox(WIN32) */
|
|
||||||
CVAPI(int) cvGuiBoxReport( int status, const char* func_name, const char* err_msg,
|
|
||||||
const char* file_name, int line, void* userdata );
|
|
||||||
|
|
||||||
#define OPENCV_ERROR(status,func,context) \
|
#define OPENCV_ERROR(status,func,context) \
|
||||||
cvError((status),(func),(context),__FILE__,__LINE__)
|
cvError((status),(func),(context),__FILE__,__LINE__)
|
||||||
@ -2740,17 +1941,9 @@ CV_EXPORTS Mat cvarrToMat(const CvArr* arr, bool copyData=false,
|
|||||||
bool allowND=true, int coiMode=0,
|
bool allowND=true, int coiMode=0,
|
||||||
AutoBuffer<double>* buf=0);
|
AutoBuffer<double>* buf=0);
|
||||||
|
|
||||||
static inline Mat cvarrToMatND(const CvArr* arr, bool copyData=false, int coiMode=0)
|
|
||||||
{
|
|
||||||
return cvarrToMat(arr, copyData, true, coiMode);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//! extracts Channel of Interest from CvMat or IplImage and makes cv::Mat out of it.
|
//! extracts Channel of Interest from CvMat or IplImage and makes cv::Mat out of it.
|
||||||
CV_EXPORTS void extractImageCOI(const CvArr* arr, OutputArray coiimg, int coi=-1);
|
CV_EXPORTS void extractImageCOI(const CvArr* arr, OutputArray coiimg, int coi=-1);
|
||||||
//! inserts single-channel cv::Mat into a multi-channel CvMat or IplImage
|
|
||||||
CV_EXPORTS void insertImageCOI(InputArray coiimg, CvArr* arr, int coi=-1);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
////// specialized implementations of DefaultDeleter::operator() for classic OpenCV types //////
|
////// specialized implementations of DefaultDeleter::operator() for classic OpenCV types //////
|
||||||
|
@ -1999,69 +1999,6 @@ CV_IMPL void cvDiv( const CvArr* srcarr1, const CvArr* srcarr2,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
CV_IMPL void
|
|
||||||
cvAddWeighted( const CvArr* srcarr1, double alpha,
|
|
||||||
const CvArr* srcarr2, double beta,
|
|
||||||
double gamma, CvArr* dstarr )
|
|
||||||
{
|
|
||||||
cv::Mat src1 = cv::cvarrToMat(srcarr1), src2 = cv::cvarrToMat(srcarr2),
|
|
||||||
dst = cv::cvarrToMat(dstarr);
|
|
||||||
CV_Assert( src1.size == dst.size && src1.channels() == dst.channels() );
|
|
||||||
cv::addWeighted( src1, alpha, src2, beta, gamma, dst, dst.type() );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
CV_IMPL void
|
|
||||||
cvAbsDiff( const CvArr* srcarr1, const CvArr* srcarr2, CvArr* dstarr )
|
|
||||||
{
|
|
||||||
cv::Mat src1 = cv::cvarrToMat(srcarr1), dst = cv::cvarrToMat(dstarr);
|
|
||||||
CV_Assert( src1.size == dst.size && src1.type() == dst.type() );
|
|
||||||
|
|
||||||
cv::absdiff( src1, cv::cvarrToMat(srcarr2), dst );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
CV_IMPL void
|
|
||||||
cvAbsDiffS( const CvArr* srcarr1, CvArr* dstarr, CvScalar scalar )
|
|
||||||
{
|
|
||||||
cv::Mat src1 = cv::cvarrToMat(srcarr1), dst = cv::cvarrToMat(dstarr);
|
|
||||||
CV_Assert( src1.size == dst.size && src1.type() == dst.type() );
|
|
||||||
|
|
||||||
cv::absdiff( src1, (const cv::Scalar&)scalar, dst );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
CV_IMPL void
|
|
||||||
cvInRange( const void* srcarr1, const void* srcarr2,
|
|
||||||
const void* srcarr3, void* dstarr )
|
|
||||||
{
|
|
||||||
cv::Mat src1 = cv::cvarrToMat(srcarr1), dst = cv::cvarrToMat(dstarr);
|
|
||||||
CV_Assert( src1.size == dst.size && dst.type() == CV_8U );
|
|
||||||
|
|
||||||
cv::inRange( src1, cv::cvarrToMat(srcarr2), cv::cvarrToMat(srcarr3), dst );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
CV_IMPL void
|
|
||||||
cvInRangeS( const void* srcarr1, CvScalar lowerb, CvScalar upperb, void* dstarr )
|
|
||||||
{
|
|
||||||
cv::Mat src1 = cv::cvarrToMat(srcarr1), dst = cv::cvarrToMat(dstarr);
|
|
||||||
CV_Assert( src1.size == dst.size && dst.type() == CV_8U );
|
|
||||||
|
|
||||||
cv::inRange( src1, (const cv::Scalar&)lowerb, (const cv::Scalar&)upperb, dst );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
CV_IMPL void
|
|
||||||
cvCmp( const void* srcarr1, const void* srcarr2, void* dstarr, int cmp_op )
|
|
||||||
{
|
|
||||||
cv::Mat src1 = cv::cvarrToMat(srcarr1), dst = cv::cvarrToMat(dstarr);
|
|
||||||
CV_Assert( src1.size == dst.size && dst.type() == CV_8U );
|
|
||||||
|
|
||||||
cv::compare( src1, cv::cvarrToMat(srcarr2), dst, cmp_op );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
CV_IMPL void
|
CV_IMPL void
|
||||||
cvCmpS( const void* srcarr1, double value, void* dstarr, int cmp_op )
|
cvCmpS( const void* srcarr1, double value, void* dstarr, int cmp_op )
|
||||||
{
|
{
|
||||||
@ -2071,44 +2008,4 @@ cvCmpS( const void* srcarr1, double value, void* dstarr, int cmp_op )
|
|||||||
cv::compare( src1, value, dst, cmp_op );
|
cv::compare( src1, value, dst, cmp_op );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
CV_IMPL void
|
|
||||||
cvMin( const void* srcarr1, const void* srcarr2, void* dstarr )
|
|
||||||
{
|
|
||||||
cv::Mat src1 = cv::cvarrToMat(srcarr1), dst = cv::cvarrToMat(dstarr);
|
|
||||||
CV_Assert( src1.size == dst.size && src1.type() == dst.type() );
|
|
||||||
|
|
||||||
cv::min( src1, cv::cvarrToMat(srcarr2), dst );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
CV_IMPL void
|
|
||||||
cvMax( const void* srcarr1, const void* srcarr2, void* dstarr )
|
|
||||||
{
|
|
||||||
cv::Mat src1 = cv::cvarrToMat(srcarr1), dst = cv::cvarrToMat(dstarr);
|
|
||||||
CV_Assert( src1.size == dst.size && src1.type() == dst.type() );
|
|
||||||
|
|
||||||
cv::max( src1, cv::cvarrToMat(srcarr2), dst );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
CV_IMPL void
|
|
||||||
cvMinS( const void* srcarr1, double value, void* dstarr )
|
|
||||||
{
|
|
||||||
cv::Mat src1 = cv::cvarrToMat(srcarr1), dst = cv::cvarrToMat(dstarr);
|
|
||||||
CV_Assert( src1.size == dst.size && src1.type() == dst.type() );
|
|
||||||
|
|
||||||
cv::min( src1, value, dst );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
CV_IMPL void
|
|
||||||
cvMaxS( const void* srcarr1, double value, void* dstarr )
|
|
||||||
{
|
|
||||||
cv::Mat src1 = cv::cvarrToMat(srcarr1), dst = cv::cvarrToMat(dstarr);
|
|
||||||
CV_Assert( src1.size == dst.size && src1.type() == dst.type() );
|
|
||||||
|
|
||||||
cv::max( src1, value, dst );
|
|
||||||
}
|
|
||||||
|
|
||||||
/* End of file. */
|
/* End of file. */
|
||||||
|
@ -324,200 +324,6 @@ cvCloneMatND( const CvMatND* src )
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static CvMatND*
|
|
||||||
cvGetMatND( const CvArr* arr, CvMatND* matnd, int* coi )
|
|
||||||
{
|
|
||||||
CvMatND* result = 0;
|
|
||||||
|
|
||||||
if( coi )
|
|
||||||
*coi = 0;
|
|
||||||
|
|
||||||
if( !matnd || !arr )
|
|
||||||
CV_Error( CV_StsNullPtr, "NULL array pointer is passed" );
|
|
||||||
|
|
||||||
if( CV_IS_MATND_HDR(arr))
|
|
||||||
{
|
|
||||||
if( !((CvMatND*)arr)->data.ptr )
|
|
||||||
CV_Error( CV_StsNullPtr, "The matrix has NULL data pointer" );
|
|
||||||
|
|
||||||
result = (CvMatND*)arr;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
CvMat stub, *mat = (CvMat*)arr;
|
|
||||||
|
|
||||||
if( CV_IS_IMAGE_HDR( mat ))
|
|
||||||
mat = cvGetMat( mat, &stub, coi );
|
|
||||||
|
|
||||||
if( !CV_IS_MAT_HDR( mat ))
|
|
||||||
CV_Error( CV_StsBadArg, "Unrecognized or unsupported array type" );
|
|
||||||
|
|
||||||
if( !mat->data.ptr )
|
|
||||||
CV_Error( CV_StsNullPtr, "Input array has NULL data pointer" );
|
|
||||||
|
|
||||||
matnd->data.ptr = mat->data.ptr;
|
|
||||||
matnd->refcount = 0;
|
|
||||||
matnd->hdr_refcount = 0;
|
|
||||||
matnd->type = mat->type;
|
|
||||||
matnd->dims = 2;
|
|
||||||
matnd->dim[0].size = mat->rows;
|
|
||||||
matnd->dim[0].step = mat->step;
|
|
||||||
matnd->dim[1].size = mat->cols;
|
|
||||||
matnd->dim[1].step = CV_ELEM_SIZE(mat->type);
|
|
||||||
result = matnd;
|
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// returns number of dimensions to iterate.
|
|
||||||
/*
|
|
||||||
Checks whether <count> arrays have equal type, sizes (mask is optional array
|
|
||||||
that needs to have the same size, but 8uC1 or 8sC1 type - feature has been disabled).
|
|
||||||
Returns number of dimensions to iterate through:
|
|
||||||
0 means that all arrays are continuous,
|
|
||||||
1 means that all arrays are vectors of continuous arrays etc.
|
|
||||||
and the size of largest common continuous part of the arrays
|
|
||||||
*/
|
|
||||||
CV_IMPL int
|
|
||||||
cvInitNArrayIterator( int count, CvArr** arrs,
|
|
||||||
const CvArr* mask, CvMatND* stubs,
|
|
||||||
CvNArrayIterator* iterator, int flags )
|
|
||||||
{
|
|
||||||
int dims = -1;
|
|
||||||
int i, j, size, dim0 = -1;
|
|
||||||
int64 step;
|
|
||||||
CvMatND* hdr0 = 0;
|
|
||||||
|
|
||||||
if( count < 1 || count > CV_MAX_ARR )
|
|
||||||
CV_Error( CV_StsOutOfRange, "Incorrect number of arrays" );
|
|
||||||
|
|
||||||
if( !arrs || !stubs )
|
|
||||||
CV_Error( CV_StsNullPtr, "Some of required array pointers is NULL" );
|
|
||||||
|
|
||||||
if( !iterator )
|
|
||||||
CV_Error( CV_StsNullPtr, "Iterator pointer is NULL" );
|
|
||||||
|
|
||||||
if (mask)
|
|
||||||
CV_Error( CV_StsBadArg, "Iterator with mask is not supported" );
|
|
||||||
|
|
||||||
for( i = 0; i < count; i++ )
|
|
||||||
{
|
|
||||||
const CvArr* arr = arrs[i];
|
|
||||||
CvMatND* hdr;
|
|
||||||
|
|
||||||
if( !arr )
|
|
||||||
CV_Error( CV_StsNullPtr, "Some of required array pointers is NULL" );
|
|
||||||
|
|
||||||
if( CV_IS_MATND( arr ))
|
|
||||||
hdr = (CvMatND*)arr;
|
|
||||||
else
|
|
||||||
{
|
|
||||||
int coi = 0;
|
|
||||||
hdr = cvGetMatND( arr, stubs + i, &coi );
|
|
||||||
if( coi != 0 )
|
|
||||||
CV_Error( CV_BadCOI, "COI set is not allowed here" );
|
|
||||||
}
|
|
||||||
|
|
||||||
iterator->hdr[i] = hdr;
|
|
||||||
|
|
||||||
if( i > 0 )
|
|
||||||
{
|
|
||||||
if( hdr->dims != hdr0->dims )
|
|
||||||
CV_Error( CV_StsUnmatchedSizes,
|
|
||||||
"Number of dimensions is the same for all arrays" );
|
|
||||||
|
|
||||||
switch( flags & (CV_NO_DEPTH_CHECK|CV_NO_CN_CHECK))
|
|
||||||
{
|
|
||||||
case 0:
|
|
||||||
if( !CV_ARE_TYPES_EQ( hdr, hdr0 ))
|
|
||||||
CV_Error( CV_StsUnmatchedFormats,
|
|
||||||
"Data type is not the same for all arrays" );
|
|
||||||
break;
|
|
||||||
case CV_NO_DEPTH_CHECK:
|
|
||||||
if( !CV_ARE_CNS_EQ( hdr, hdr0 ))
|
|
||||||
CV_Error( CV_StsUnmatchedFormats,
|
|
||||||
"Number of channels is not the same for all arrays" );
|
|
||||||
break;
|
|
||||||
case CV_NO_CN_CHECK:
|
|
||||||
if( !CV_ARE_CNS_EQ( hdr, hdr0 ))
|
|
||||||
CV_Error( CV_StsUnmatchedFormats,
|
|
||||||
"Depth is not the same for all arrays" );
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if( !(flags & CV_NO_SIZE_CHECK) )
|
|
||||||
{
|
|
||||||
for( j = 0; j < hdr->dims; j++ )
|
|
||||||
if( hdr->dim[j].size != hdr0->dim[j].size )
|
|
||||||
CV_Error( CV_StsUnmatchedSizes,
|
|
||||||
"Dimension sizes are the same for all arrays" );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
hdr0 = hdr;
|
|
||||||
|
|
||||||
step = CV_ELEM_SIZE(hdr->type);
|
|
||||||
for( j = hdr->dims - 1; j > dim0; j-- )
|
|
||||||
{
|
|
||||||
if( step != hdr->dim[j].step )
|
|
||||||
break;
|
|
||||||
step *= hdr->dim[j].size;
|
|
||||||
}
|
|
||||||
|
|
||||||
if( j == dim0 && step > INT_MAX )
|
|
||||||
j++;
|
|
||||||
|
|
||||||
if( j > dim0 )
|
|
||||||
dim0 = j;
|
|
||||||
|
|
||||||
iterator->hdr[i] = (CvMatND*)hdr;
|
|
||||||
iterator->ptr[i] = (uchar*)hdr->data.ptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
size = 1;
|
|
||||||
for( j = hdr0->dims - 1; j > dim0; j-- )
|
|
||||||
size *= hdr0->dim[j].size;
|
|
||||||
|
|
||||||
dims = dim0 + 1;
|
|
||||||
iterator->dims = dims;
|
|
||||||
iterator->count = count;
|
|
||||||
iterator->size = cvSize(size,1);
|
|
||||||
|
|
||||||
for( i = 0; i < dims; i++ )
|
|
||||||
iterator->stack[i] = hdr0->dim[i].size;
|
|
||||||
|
|
||||||
return dims;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// returns zero value if iteration is finished, non-zero otherwise
|
|
||||||
CV_IMPL int cvNextNArraySlice( CvNArrayIterator* iterator )
|
|
||||||
{
|
|
||||||
assert( iterator != 0 );
|
|
||||||
int i, dims;
|
|
||||||
|
|
||||||
for( dims = iterator->dims; dims > 0; dims-- )
|
|
||||||
{
|
|
||||||
for( i = 0; i < iterator->count; i++ )
|
|
||||||
iterator->ptr[i] += iterator->hdr[i]->dim[dims-1].step;
|
|
||||||
|
|
||||||
if( --iterator->stack[dims-1] > 0 )
|
|
||||||
break;
|
|
||||||
|
|
||||||
const int size = iterator->hdr[0]->dim[dims-1].size;
|
|
||||||
|
|
||||||
for( i = 0; i < iterator->count; i++ )
|
|
||||||
iterator->ptr[i] -= (size_t)size*iterator->hdr[i]->dim[dims-1].step;
|
|
||||||
|
|
||||||
iterator->stack[dims-1] = size;
|
|
||||||
}
|
|
||||||
|
|
||||||
return dims > 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/****************************************************************************************\
|
/****************************************************************************************\
|
||||||
* CvSparseMat creation and basic operations *
|
* CvSparseMat creation and basic operations *
|
||||||
\****************************************************************************************/
|
\****************************************************************************************/
|
||||||
@ -1387,67 +1193,6 @@ cvGetCols( const CvArr* arr, CvMat* submat, int start_col, int end_col )
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Selects array diagonal
|
|
||||||
CV_IMPL CvMat*
|
|
||||||
cvGetDiag( const CvArr* arr, CvMat* submat, int diag )
|
|
||||||
{
|
|
||||||
CvMat* res = 0;
|
|
||||||
CvMat stub, *mat = (CvMat*)arr;
|
|
||||||
int len, pix_size;
|
|
||||||
|
|
||||||
if( !CV_IS_MAT( mat ))
|
|
||||||
mat = cvGetMat( mat, &stub );
|
|
||||||
|
|
||||||
if( !submat )
|
|
||||||
CV_Error( CV_StsNullPtr, "" );
|
|
||||||
|
|
||||||
pix_size = CV_ELEM_SIZE(mat->type);
|
|
||||||
|
|
||||||
/*{
|
|
||||||
int* refcount = mat->refcount;
|
|
||||||
|
|
||||||
if( refcount )
|
|
||||||
++*refcount;
|
|
||||||
|
|
||||||
cvDecRefData( submat );
|
|
||||||
}*/
|
|
||||||
|
|
||||||
if( diag >= 0 )
|
|
||||||
{
|
|
||||||
len = mat->cols - diag;
|
|
||||||
|
|
||||||
if( len <= 0 )
|
|
||||||
CV_Error( CV_StsOutOfRange, "" );
|
|
||||||
|
|
||||||
len = CV_IMIN( len, mat->rows );
|
|
||||||
submat->data.ptr = mat->data.ptr + diag*pix_size;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
len = mat->rows + diag;
|
|
||||||
|
|
||||||
if( len <= 0 )
|
|
||||||
CV_Error( CV_StsOutOfRange, "" );
|
|
||||||
|
|
||||||
len = CV_IMIN( len, mat->cols );
|
|
||||||
submat->data.ptr = mat->data.ptr - diag*mat->step;
|
|
||||||
}
|
|
||||||
|
|
||||||
submat->rows = len;
|
|
||||||
submat->cols = 1;
|
|
||||||
submat->step = mat->step + (submat->rows > 1 ? pix_size : 0);
|
|
||||||
submat->type = mat->type;
|
|
||||||
if( submat->rows > 1 )
|
|
||||||
submat->type &= ~CV_MAT_CONT_FLAG;
|
|
||||||
else
|
|
||||||
submat->type |= CV_MAT_CONT_FLAG;
|
|
||||||
submat->refcount = 0;
|
|
||||||
submat->hdr_refcount = 0;
|
|
||||||
res = submat;
|
|
||||||
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
|
|
||||||
/****************************************************************************************\
|
/****************************************************************************************\
|
||||||
* Operations on CvScalar and accessing array elements *
|
* Operations on CvScalar and accessing array elements *
|
||||||
\****************************************************************************************/
|
\****************************************************************************************/
|
||||||
@ -2498,214 +2243,6 @@ cvGetMat( const CvArr* array, CvMat* mat,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
CV_IMPL CvArr*
|
|
||||||
cvReshapeMatND( const CvArr* arr,
|
|
||||||
int sizeof_header, CvArr* _header,
|
|
||||||
int new_cn, int new_dims, int* new_sizes )
|
|
||||||
{
|
|
||||||
CvArr* result = 0;
|
|
||||||
int dims, coi = 0;
|
|
||||||
|
|
||||||
if( !arr || !_header )
|
|
||||||
CV_Error( CV_StsNullPtr, "NULL pointer to array or destination header" );
|
|
||||||
|
|
||||||
if( new_cn == 0 && new_dims == 0 )
|
|
||||||
CV_Error( CV_StsBadArg, "None of array parameters is changed: dummy call?" );
|
|
||||||
|
|
||||||
dims = cvGetDims( arr );
|
|
||||||
|
|
||||||
if( new_dims == 0 )
|
|
||||||
{
|
|
||||||
new_sizes = 0;
|
|
||||||
new_dims = dims;
|
|
||||||
}
|
|
||||||
else if( new_dims == 1 )
|
|
||||||
{
|
|
||||||
new_sizes = 0;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if( new_dims <= 0 || new_dims > CV_MAX_DIM )
|
|
||||||
CV_Error( CV_StsOutOfRange, "Non-positive or too large number of dimensions" );
|
|
||||||
if( !new_sizes )
|
|
||||||
CV_Error( CV_StsNullPtr, "New dimension sizes are not specified" );
|
|
||||||
}
|
|
||||||
|
|
||||||
if( new_dims <= 2 )
|
|
||||||
{
|
|
||||||
CvMat* mat = (CvMat*)arr;
|
|
||||||
CvMat header;
|
|
||||||
int* refcount = 0;
|
|
||||||
int hdr_refcount = 0;
|
|
||||||
int total_width, new_rows, cn;
|
|
||||||
|
|
||||||
if( sizeof_header != sizeof(CvMat) && sizeof_header != sizeof(CvMatND) )
|
|
||||||
CV_Error( CV_StsBadArg, "The output header should be CvMat or CvMatND" );
|
|
||||||
|
|
||||||
if( mat == (CvMat*)_header )
|
|
||||||
{
|
|
||||||
refcount = mat->refcount;
|
|
||||||
hdr_refcount = mat->hdr_refcount;
|
|
||||||
}
|
|
||||||
|
|
||||||
if( !CV_IS_MAT( mat ))
|
|
||||||
mat = cvGetMat( mat, &header, &coi, 1 );
|
|
||||||
|
|
||||||
cn = CV_MAT_CN( mat->type );
|
|
||||||
total_width = mat->cols * cn;
|
|
||||||
|
|
||||||
if( new_cn == 0 )
|
|
||||||
new_cn = cn;
|
|
||||||
|
|
||||||
if( new_sizes )
|
|
||||||
new_rows = new_sizes[0];
|
|
||||||
else if( new_dims == 1 )
|
|
||||||
new_rows = total_width*mat->rows/new_cn;
|
|
||||||
else
|
|
||||||
{
|
|
||||||
new_rows = mat->rows;
|
|
||||||
if( new_cn > total_width )
|
|
||||||
new_rows = mat->rows * total_width / new_cn;
|
|
||||||
}
|
|
||||||
|
|
||||||
if( new_rows != mat->rows )
|
|
||||||
{
|
|
||||||
int total_size = total_width * mat->rows;
|
|
||||||
|
|
||||||
if( !CV_IS_MAT_CONT( mat->type ))
|
|
||||||
CV_Error( CV_BadStep,
|
|
||||||
"The matrix is not continuous so the number of rows can not be changed" );
|
|
||||||
|
|
||||||
total_width = total_size / new_rows;
|
|
||||||
|
|
||||||
if( total_width * new_rows != total_size )
|
|
||||||
CV_Error( CV_StsBadArg, "The total number of matrix elements "
|
|
||||||
"is not divisible by the new number of rows" );
|
|
||||||
}
|
|
||||||
|
|
||||||
header.rows = new_rows;
|
|
||||||
header.cols = total_width / new_cn;
|
|
||||||
|
|
||||||
if( header.cols * new_cn != total_width ||
|
|
||||||
(new_sizes && header.cols != new_sizes[1]) )
|
|
||||||
CV_Error( CV_StsBadArg, "The total matrix width is not "
|
|
||||||
"divisible by the new number of columns" );
|
|
||||||
|
|
||||||
header.type = (mat->type & ~CV_MAT_TYPE_MASK) | CV_MAKETYPE(mat->type, new_cn);
|
|
||||||
header.step = header.cols * CV_ELEM_SIZE(mat->type);
|
|
||||||
header.step &= new_rows > 1 ? -1 : 0;
|
|
||||||
header.refcount = refcount;
|
|
||||||
header.hdr_refcount = hdr_refcount;
|
|
||||||
|
|
||||||
if( sizeof_header == sizeof(CvMat) )
|
|
||||||
*(CvMat*)_header = header;
|
|
||||||
else
|
|
||||||
{
|
|
||||||
CvMatND* __header = (CvMatND*)_header;
|
|
||||||
cvGetMatND(&header, __header, 0);
|
|
||||||
if( new_dims > 0 )
|
|
||||||
__header->dims = new_dims;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
CvMatND* header = (CvMatND*)_header;
|
|
||||||
|
|
||||||
if( sizeof_header != sizeof(CvMatND))
|
|
||||||
CV_Error( CV_StsBadSize, "The output header should be CvMatND" );
|
|
||||||
|
|
||||||
if( !new_sizes )
|
|
||||||
{
|
|
||||||
if( !CV_IS_MATND( arr ))
|
|
||||||
CV_Error( CV_StsBadArg, "The input array must be CvMatND" );
|
|
||||||
|
|
||||||
{
|
|
||||||
CvMatND* mat = (CvMatND*)arr;
|
|
||||||
assert( new_cn > 0 );
|
|
||||||
int last_dim_size = mat->dim[mat->dims-1].size*CV_MAT_CN(mat->type);
|
|
||||||
int new_size = last_dim_size/new_cn;
|
|
||||||
|
|
||||||
if( new_size*new_cn != last_dim_size )
|
|
||||||
CV_Error( CV_StsBadArg,
|
|
||||||
"The last dimension full size is not divisible by new number of channels");
|
|
||||||
|
|
||||||
if( mat != header )
|
|
||||||
{
|
|
||||||
memcpy( header, mat, sizeof(*header));
|
|
||||||
header->refcount = 0;
|
|
||||||
header->hdr_refcount = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
header->dim[header->dims-1].size = new_size;
|
|
||||||
header->type = (header->type & ~CV_MAT_TYPE_MASK) | CV_MAKETYPE(header->type, new_cn);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
CvMatND stub;
|
|
||||||
CvMatND* mat = (CvMatND*)arr;
|
|
||||||
int i, size1, size2;
|
|
||||||
int step;
|
|
||||||
|
|
||||||
if( new_cn != 0 )
|
|
||||||
CV_Error( CV_StsBadArg,
|
|
||||||
"Simultaneous change of shape and number of channels is not supported. "
|
|
||||||
"Do it by 2 separate calls" );
|
|
||||||
|
|
||||||
if( !CV_IS_MATND( mat ))
|
|
||||||
{
|
|
||||||
cvGetMatND( mat, &stub, &coi );
|
|
||||||
mat = &stub;
|
|
||||||
}
|
|
||||||
|
|
||||||
if( CV_IS_MAT_CONT( mat->type ))
|
|
||||||
CV_Error( CV_StsBadArg, "Non-continuous nD arrays are not supported" );
|
|
||||||
|
|
||||||
size1 = mat->dim[0].size;
|
|
||||||
for( i = 1; i < dims; i++ )
|
|
||||||
size1 *= mat->dim[i].size;
|
|
||||||
|
|
||||||
size2 = 1;
|
|
||||||
for( i = 0; i < new_dims; i++ )
|
|
||||||
{
|
|
||||||
if( new_sizes[i] <= 0 )
|
|
||||||
CV_Error( CV_StsBadSize,
|
|
||||||
"One of new dimension sizes is non-positive" );
|
|
||||||
size2 *= new_sizes[i];
|
|
||||||
}
|
|
||||||
|
|
||||||
if( size1 != size2 )
|
|
||||||
CV_Error( CV_StsBadSize,
|
|
||||||
"Number of elements in the original and reshaped array is different" );
|
|
||||||
|
|
||||||
if( header != mat )
|
|
||||||
{
|
|
||||||
header->refcount = 0;
|
|
||||||
header->hdr_refcount = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
header->dims = new_dims;
|
|
||||||
header->type = mat->type;
|
|
||||||
header->data.ptr = mat->data.ptr;
|
|
||||||
step = CV_ELEM_SIZE(header->type);
|
|
||||||
|
|
||||||
for( i = new_dims - 1; i >= 0; i-- )
|
|
||||||
{
|
|
||||||
header->dim[i].size = new_sizes[i];
|
|
||||||
header->dim[i].step = step;
|
|
||||||
step *= new_sizes[i];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if( coi )
|
|
||||||
CV_Error( CV_BadCOI, "COI is not supported by this operation" );
|
|
||||||
|
|
||||||
result = _header;
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
CV_IMPL CvMat*
|
CV_IMPL CvMat*
|
||||||
cvReshape( const CvArr* array, CvMat* header,
|
cvReshape( const CvArr* array, CvMat* header,
|
||||||
int new_cn, int new_rows )
|
int new_cn, int new_rows )
|
||||||
@ -3279,20 +2816,5 @@ cvRelease( void** struct_ptr )
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void* cvClone( const void* struct_ptr )
|
|
||||||
{
|
|
||||||
void* ptr = 0;
|
|
||||||
if( !struct_ptr )
|
|
||||||
CV_Error( CV_StsNullPtr, "NULL structure pointer" );
|
|
||||||
|
|
||||||
if( CV_IS_MAT(struct_ptr) )
|
|
||||||
ptr = cvCloneMat((const CvMat*)struct_ptr);
|
|
||||||
else if( CV_IS_IMAGE(struct_ptr))
|
|
||||||
ptr = cvCloneImage((const IplImage*)struct_ptr);
|
|
||||||
else
|
|
||||||
CV_Error( CV_StsError, "Unknown object type" );
|
|
||||||
return ptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/* End of file. */
|
/* End of file. */
|
||||||
|
@ -1606,13 +1606,4 @@ cvFlip( const CvArr* srcarr, CvArr* dstarr, int flip_mode )
|
|||||||
cv::flip( src, dst, flip_mode );
|
cv::flip( src, dst, flip_mode );
|
||||||
}
|
}
|
||||||
|
|
||||||
CV_IMPL void
|
|
||||||
cvRepeat( const CvArr* srcarr, CvArr* dstarr )
|
|
||||||
{
|
|
||||||
cv::Mat src = cv::cvarrToMat(srcarr), dst = cv::cvarrToMat(dstarr);
|
|
||||||
CV_Assert( src.type() == dst.type() &&
|
|
||||||
dst.rows % src.rows == 0 && dst.cols % src.cols == 0 );
|
|
||||||
cv::repeat(src, dst.rows/src.rows, dst.cols/src.cols, dst);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* End of file. */
|
/* End of file. */
|
||||||
|
@ -1638,60 +1638,6 @@ void patchNaNs( InputOutputArray _a, double _val )
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CV_IMPL float cvCbrt(float value) { return cv::cubeRoot(value); }
|
|
||||||
CV_IMPL float cvFastArctan(float y, float x) { return cv::fastAtan2(y, x); }
|
|
||||||
|
|
||||||
CV_IMPL void
|
|
||||||
cvCartToPolar( const CvArr* xarr, const CvArr* yarr,
|
|
||||||
CvArr* magarr, CvArr* anglearr,
|
|
||||||
int angle_in_degrees )
|
|
||||||
{
|
|
||||||
cv::Mat X = cv::cvarrToMat(xarr), Y = cv::cvarrToMat(yarr), Mag, Angle;
|
|
||||||
if( magarr )
|
|
||||||
{
|
|
||||||
Mag = cv::cvarrToMat(magarr);
|
|
||||||
CV_Assert( Mag.size() == X.size() && Mag.type() == X.type() );
|
|
||||||
}
|
|
||||||
if( anglearr )
|
|
||||||
{
|
|
||||||
Angle = cv::cvarrToMat(anglearr);
|
|
||||||
CV_Assert( Angle.size() == X.size() && Angle.type() == X.type() );
|
|
||||||
}
|
|
||||||
if( magarr )
|
|
||||||
{
|
|
||||||
if( anglearr )
|
|
||||||
cv::cartToPolar( X, Y, Mag, Angle, angle_in_degrees != 0 );
|
|
||||||
else
|
|
||||||
cv::magnitude( X, Y, Mag );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
cv::phase( X, Y, Angle, angle_in_degrees != 0 );
|
|
||||||
}
|
|
||||||
|
|
||||||
CV_IMPL void
|
|
||||||
cvPolarToCart( const CvArr* magarr, const CvArr* anglearr,
|
|
||||||
CvArr* xarr, CvArr* yarr, int angle_in_degrees )
|
|
||||||
{
|
|
||||||
cv::Mat X, Y, Angle = cv::cvarrToMat(anglearr), Mag;
|
|
||||||
if( magarr )
|
|
||||||
{
|
|
||||||
Mag = cv::cvarrToMat(magarr);
|
|
||||||
CV_Assert( Mag.size() == Angle.size() && Mag.type() == Angle.type() );
|
|
||||||
}
|
|
||||||
if( xarr )
|
|
||||||
{
|
|
||||||
X = cv::cvarrToMat(xarr);
|
|
||||||
CV_Assert( X.size() == Angle.size() && X.type() == Angle.type() );
|
|
||||||
}
|
|
||||||
if( yarr )
|
|
||||||
{
|
|
||||||
Y = cv::cvarrToMat(yarr);
|
|
||||||
CV_Assert( Y.size() == Angle.size() && Y.type() == Angle.type() );
|
|
||||||
}
|
|
||||||
|
|
||||||
cv::polarToCart( Mag, Angle, X, Y, angle_in_degrees != 0 );
|
|
||||||
}
|
|
||||||
|
|
||||||
CV_IMPL void cvExp( const CvArr* srcarr, CvArr* dstarr )
|
CV_IMPL void cvExp( const CvArr* srcarr, CvArr* dstarr )
|
||||||
{
|
{
|
||||||
cv::Mat src = cv::cvarrToMat(srcarr), dst = cv::cvarrToMat(dstarr);
|
cv::Mat src = cv::cvarrToMat(srcarr), dst = cv::cvarrToMat(dstarr);
|
||||||
@ -1699,13 +1645,6 @@ CV_IMPL void cvExp( const CvArr* srcarr, CvArr* dstarr )
|
|||||||
cv::exp( src, dst );
|
cv::exp( src, dst );
|
||||||
}
|
}
|
||||||
|
|
||||||
CV_IMPL void cvLog( const CvArr* srcarr, CvArr* dstarr )
|
|
||||||
{
|
|
||||||
cv::Mat src = cv::cvarrToMat(srcarr), dst = cv::cvarrToMat(dstarr);
|
|
||||||
CV_Assert( src.type() == dst.type() && src.size == dst.size );
|
|
||||||
cv::log( src, dst );
|
|
||||||
}
|
|
||||||
|
|
||||||
CV_IMPL void cvPow( const CvArr* srcarr, CvArr* dstarr, double power )
|
CV_IMPL void cvPow( const CvArr* srcarr, CvArr* dstarr, double power )
|
||||||
{
|
{
|
||||||
cv::Mat src = cv::cvarrToMat(srcarr), dst = cv::cvarrToMat(dstarr);
|
cv::Mat src = cv::cvarrToMat(srcarr), dst = cv::cvarrToMat(dstarr);
|
||||||
@ -2016,16 +1955,6 @@ double cv::solvePoly( InputArray _coeffs0, OutputArray _roots0, int maxIters )
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
CV_IMPL int
|
|
||||||
cvSolveCubic( const CvMat* coeffs, CvMat* roots )
|
|
||||||
{
|
|
||||||
cv::Mat _coeffs = cv::cvarrToMat(coeffs), _roots = cv::cvarrToMat(roots), _roots0 = _roots;
|
|
||||||
int nroots = cv::solveCubic(_coeffs, _roots);
|
|
||||||
CV_Assert( _roots.data == _roots0.data ); // check that the array of roots was not reallocated
|
|
||||||
return nroots;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void cvSolvePoly(const CvMat* a, CvMat *r, int maxiter, int)
|
void cvSolvePoly(const CvMat* a, CvMat *r, int maxiter, int)
|
||||||
{
|
{
|
||||||
cv::Mat _a = cv::cvarrToMat(a);
|
cv::Mat _a = cv::cvarrToMat(a);
|
||||||
|
@ -200,19 +200,6 @@ void extractImageCOI(const CvArr* arr, OutputArray _ch, int coi)
|
|||||||
mixChannels( &mat, 1, &ch, 1, _pairs, 1 );
|
mixChannels( &mat, 1, &ch, 1, _pairs, 1 );
|
||||||
}
|
}
|
||||||
|
|
||||||
void insertImageCOI(InputArray _ch, CvArr* arr, int coi)
|
|
||||||
{
|
|
||||||
Mat ch = _ch.getMat(), mat = cvarrToMat(arr, false, true, 1);
|
|
||||||
if(coi < 0)
|
|
||||||
{
|
|
||||||
CV_Assert( CV_IS_IMAGE(arr) );
|
|
||||||
coi = cvGetImageCOI((const IplImage*)arr)-1;
|
|
||||||
}
|
|
||||||
CV_Assert(ch.size == mat.size && ch.depth() == mat.depth() && 0 <= coi && coi < mat.channels());
|
|
||||||
int _pairs[] = { 0, coi };
|
|
||||||
mixChannels( &ch, 1, &mat, 1, _pairs, 1 );
|
|
||||||
}
|
|
||||||
|
|
||||||
} // cv::
|
} // cv::
|
||||||
|
|
||||||
// operations
|
// operations
|
||||||
@ -355,33 +342,3 @@ cvSort( const CvArr* _src, CvArr* _dst, CvArr* _idx, int flags )
|
|||||||
CV_Assert( dst0.data == dst.data );
|
CV_Assert( dst0.data == dst.data );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
CV_IMPL int
|
|
||||||
cvKMeans2( const CvArr* _samples, int cluster_count, CvArr* _labels,
|
|
||||||
CvTermCriteria termcrit, int attempts, CvRNG*,
|
|
||||||
int flags, CvArr* _centers, double* _compactness )
|
|
||||||
{
|
|
||||||
cv::Mat data = cv::cvarrToMat(_samples), labels = cv::cvarrToMat(_labels), centers;
|
|
||||||
if( _centers )
|
|
||||||
{
|
|
||||||
centers = cv::cvarrToMat(_centers);
|
|
||||||
|
|
||||||
centers = centers.reshape(1);
|
|
||||||
data = data.reshape(1);
|
|
||||||
|
|
||||||
CV_Assert( !centers.empty() );
|
|
||||||
CV_Assert( centers.rows == cluster_count );
|
|
||||||
CV_Assert( centers.cols == data.cols );
|
|
||||||
CV_Assert( centers.depth() == data.depth() );
|
|
||||||
}
|
|
||||||
CV_Assert( labels.isContinuous() && labels.type() == CV_32S &&
|
|
||||||
(labels.cols == 1 || labels.rows == 1) &&
|
|
||||||
labels.cols + labels.rows - 1 == data.rows );
|
|
||||||
|
|
||||||
double compactness = cv::kmeans(data, cluster_count, labels, termcrit, attempts,
|
|
||||||
flags, _centers ? cv::_OutputArray(centers) : cv::_OutputArray() );
|
|
||||||
if( _compactness )
|
|
||||||
*_compactness = compactness;
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
@ -972,18 +972,3 @@ const char* currentParallelFramework() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
} // namespace cv::
|
} // namespace cv::
|
||||||
|
|
||||||
CV_IMPL void cvSetNumThreads(int nt)
|
|
||||||
{
|
|
||||||
cv::setNumThreads(nt);
|
|
||||||
}
|
|
||||||
|
|
||||||
CV_IMPL int cvGetNumThreads()
|
|
||||||
{
|
|
||||||
return cv::getNumThreads();
|
|
||||||
}
|
|
||||||
|
|
||||||
CV_IMPL int cvGetThreadNum()
|
|
||||||
{
|
|
||||||
return cv::getThreadNum();
|
|
||||||
}
|
|
||||||
|
@ -1178,58 +1178,6 @@ redirectError( ErrorCallback errCallback, void* userdata, void** prevUserdata)
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CV_IMPL int cvCheckHardwareSupport(int feature)
|
|
||||||
{
|
|
||||||
CV_DbgAssert( 0 <= feature && feature <= CV_HARDWARE_MAX_FEATURE );
|
|
||||||
return cv::currentFeatures->have[feature];
|
|
||||||
}
|
|
||||||
|
|
||||||
CV_IMPL int cvUseOptimized( int flag )
|
|
||||||
{
|
|
||||||
int prevMode = cv::useOptimizedFlag;
|
|
||||||
cv::setUseOptimized( flag != 0 );
|
|
||||||
return prevMode;
|
|
||||||
}
|
|
||||||
|
|
||||||
CV_IMPL int64 cvGetTickCount(void)
|
|
||||||
{
|
|
||||||
return cv::getTickCount();
|
|
||||||
}
|
|
||||||
|
|
||||||
CV_IMPL double cvGetTickFrequency(void)
|
|
||||||
{
|
|
||||||
return cv::getTickFrequency()*1e-6;
|
|
||||||
}
|
|
||||||
|
|
||||||
CV_IMPL CvErrorCallback
|
|
||||||
cvRedirectError( CvErrorCallback errCallback, void* userdata, void** prevUserdata)
|
|
||||||
{
|
|
||||||
return cv::redirectError(errCallback, userdata, prevUserdata);
|
|
||||||
}
|
|
||||||
|
|
||||||
CV_IMPL int cvNulDevReport( int, const char*, const char*,
|
|
||||||
const char*, int, void* )
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
CV_IMPL int cvStdErrReport( int, const char*, const char*,
|
|
||||||
const char*, int, void* )
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
CV_IMPL int cvGuiBoxReport( int, const char*, const char*,
|
|
||||||
const char*, int, void* )
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
CV_IMPL int cvGetErrInfo( const char**, const char**, const char**, int* )
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
CV_IMPL const char* cvErrorStr( int status )
|
CV_IMPL const char* cvErrorStr( int status )
|
||||||
{
|
{
|
||||||
|
@ -83,11 +83,6 @@ CVAPI(void) cvRunningAvg( const CvArr* image, CvArr* acc, double alpha,
|
|||||||
* Image Processing *
|
* Image Processing *
|
||||||
\****************************************************************************************/
|
\****************************************************************************************/
|
||||||
|
|
||||||
/** Copies source 2D array inside of the larger destination array and
|
|
||||||
makes a border of the specified type (IPL_BORDER_*) around the copied area. */
|
|
||||||
CVAPI(void) cvCopyMakeBorder( const CvArr* src, CvArr* dst, CvPoint offset,
|
|
||||||
int bordertype, CvScalar value CV_DEFAULT(cvScalarAll(0)));
|
|
||||||
|
|
||||||
/** @brief Smooths the image in one of several ways.
|
/** @brief Smooths the image in one of several ways.
|
||||||
|
|
||||||
@param src The source image
|
@param src The source image
|
||||||
@ -156,47 +151,6 @@ CVAPI(void) cvPyrDown( const CvArr* src, CvArr* dst,
|
|||||||
CVAPI(void) cvPyrUp( const CvArr* src, CvArr* dst,
|
CVAPI(void) cvPyrUp( const CvArr* src, CvArr* dst,
|
||||||
int filter CV_DEFAULT(CV_GAUSSIAN_5x5) );
|
int filter CV_DEFAULT(CV_GAUSSIAN_5x5) );
|
||||||
|
|
||||||
/** @brief Builds pyramid for an image
|
|
||||||
@see buildPyramid
|
|
||||||
*/
|
|
||||||
CVAPI(CvMat**) cvCreatePyramid( const CvArr* img, int extra_layers, double rate,
|
|
||||||
const CvSize* layer_sizes CV_DEFAULT(0),
|
|
||||||
CvArr* bufarr CV_DEFAULT(0),
|
|
||||||
int calc CV_DEFAULT(1),
|
|
||||||
int filter CV_DEFAULT(CV_GAUSSIAN_5x5) );
|
|
||||||
|
|
||||||
/** @brief Releases pyramid */
|
|
||||||
CVAPI(void) cvReleasePyramid( CvMat*** pyramid, int extra_layers );
|
|
||||||
|
|
||||||
|
|
||||||
/** @brief Filters image using meanshift algorithm
|
|
||||||
@see cv::pyrMeanShiftFiltering
|
|
||||||
*/
|
|
||||||
CVAPI(void) cvPyrMeanShiftFiltering( const CvArr* src, CvArr* dst,
|
|
||||||
double sp, double sr, int max_level CV_DEFAULT(1),
|
|
||||||
CvTermCriteria termcrit CV_DEFAULT(cvTermCriteria(CV_TERMCRIT_ITER+CV_TERMCRIT_EPS,5,1)));
|
|
||||||
|
|
||||||
/** @brief Segments image using seed "markers"
|
|
||||||
@see cv::watershed
|
|
||||||
*/
|
|
||||||
CVAPI(void) cvWatershed( const CvArr* image, CvArr* markers );
|
|
||||||
|
|
||||||
/** @brief Calculates an image derivative using generalized Sobel
|
|
||||||
|
|
||||||
(aperture_size = 1,3,5,7) or Scharr (aperture_size = -1) operator.
|
|
||||||
Scharr can be used only for the first dx or dy derivative
|
|
||||||
@see cv::Sobel
|
|
||||||
*/
|
|
||||||
CVAPI(void) cvSobel( const CvArr* src, CvArr* dst,
|
|
||||||
int xorder, int yorder,
|
|
||||||
int aperture_size CV_DEFAULT(3));
|
|
||||||
|
|
||||||
/** @brief Calculates the image Laplacian: (d2/dx + d2/dy)I
|
|
||||||
@see cv::Laplacian
|
|
||||||
*/
|
|
||||||
CVAPI(void) cvLaplace( const CvArr* src, CvArr* dst,
|
|
||||||
int aperture_size CV_DEFAULT(3) );
|
|
||||||
|
|
||||||
/** @brief Converts input array pixels from one color space to another
|
/** @brief Converts input array pixels from one color space to another
|
||||||
@see cv::cvtColor
|
@see cv::cvtColor
|
||||||
*/
|
*/
|
||||||
@ -218,12 +172,6 @@ CVAPI(void) cvWarpAffine( const CvArr* src, CvArr* dst, const CvMat* map_matrix
|
|||||||
int flags CV_DEFAULT(CV_INTER_LINEAR+CV_WARP_FILL_OUTLIERS),
|
int flags CV_DEFAULT(CV_INTER_LINEAR+CV_WARP_FILL_OUTLIERS),
|
||||||
CvScalar fillval CV_DEFAULT(cvScalarAll(0)) );
|
CvScalar fillval CV_DEFAULT(cvScalarAll(0)) );
|
||||||
|
|
||||||
/** @brief Computes affine transform matrix for mapping src[i] to dst[i] (i=0,1,2)
|
|
||||||
@see cv::getAffineTransform
|
|
||||||
*/
|
|
||||||
CVAPI(CvMat*) cvGetAffineTransform( const CvPoint2D32f * src,
|
|
||||||
const CvPoint2D32f * dst,
|
|
||||||
CvMat * map_matrix );
|
|
||||||
|
|
||||||
/** @brief Computes rotation_matrix matrix
|
/** @brief Computes rotation_matrix matrix
|
||||||
@see cv::getRotationMatrix2D
|
@see cv::getRotationMatrix2D
|
||||||
@ -253,26 +201,6 @@ CVAPI(void) cvRemap( const CvArr* src, CvArr* dst,
|
|||||||
int flags CV_DEFAULT(CV_INTER_LINEAR+CV_WARP_FILL_OUTLIERS),
|
int flags CV_DEFAULT(CV_INTER_LINEAR+CV_WARP_FILL_OUTLIERS),
|
||||||
CvScalar fillval CV_DEFAULT(cvScalarAll(0)) );
|
CvScalar fillval CV_DEFAULT(cvScalarAll(0)) );
|
||||||
|
|
||||||
/** @brief Converts mapx & mapy from floating-point to integer formats for cvRemap
|
|
||||||
@see cv::convertMaps
|
|
||||||
*/
|
|
||||||
CVAPI(void) cvConvertMaps( const CvArr* mapx, const CvArr* mapy,
|
|
||||||
CvArr* mapxy, CvArr* mapalpha );
|
|
||||||
|
|
||||||
/** @brief Performs forward or inverse log-polar image transform
|
|
||||||
@see cv::warpPolar
|
|
||||||
*/
|
|
||||||
CVAPI(void) cvLogPolar( const CvArr* src, CvArr* dst,
|
|
||||||
CvPoint2D32f center, double M,
|
|
||||||
int flags CV_DEFAULT(CV_INTER_LINEAR+CV_WARP_FILL_OUTLIERS));
|
|
||||||
|
|
||||||
/** Performs forward or inverse linear-polar image transform
|
|
||||||
@see cv::warpPolar
|
|
||||||
*/
|
|
||||||
CVAPI(void) cvLinearPolar( const CvArr* src, CvArr* dst,
|
|
||||||
CvPoint2D32f center, double maxRadius,
|
|
||||||
int flags CV_DEFAULT(CV_INTER_LINEAR+CV_WARP_FILL_OUTLIERS));
|
|
||||||
|
|
||||||
/** @brief Returns a structuring element of the specified size and shape for morphological operations.
|
/** @brief Returns a structuring element of the specified size and shape for morphological operations.
|
||||||
|
|
||||||
@note the created structuring element IplConvKernel\* element must be released in the end using
|
@note the created structuring element IplConvKernel\* element must be released in the end using
|
||||||
@ -545,12 +473,6 @@ CVAPI(CvSeq*) cvConvexHull2( const CvArr* input,
|
|||||||
CVAPI(int) cvCheckContourConvexity( const CvArr* contour );
|
CVAPI(int) cvCheckContourConvexity( const CvArr* contour );
|
||||||
|
|
||||||
|
|
||||||
/** @brief Finds convexity defects for the contour
|
|
||||||
@see cv::convexityDefects
|
|
||||||
*/
|
|
||||||
CVAPI(CvSeq*) cvConvexityDefects( const CvArr* contour, const CvArr* convexhull,
|
|
||||||
CvMemStorage* storage CV_DEFAULT(NULL));
|
|
||||||
|
|
||||||
/** @brief Fits ellipse into a set of 2d points
|
/** @brief Fits ellipse into a set of 2d points
|
||||||
@see cv::fitEllipse
|
@see cv::fitEllipse
|
||||||
*/
|
*/
|
||||||
@ -778,20 +700,6 @@ CVAPI(void) cvCalcArrBackProjectPatch( CvArr** image, CvArr* dst, CvSize range,
|
|||||||
cvCalcArrBackProjectPatch( (CvArr**)image, dst, range, hist, method, factor )
|
cvCalcArrBackProjectPatch( (CvArr**)image, dst, range, hist, method, factor )
|
||||||
|
|
||||||
|
|
||||||
/** @brief Divides one histogram by another.
|
|
||||||
|
|
||||||
The function calculates the object probability density from two histograms as:
|
|
||||||
|
|
||||||
\f[\texttt{disthist} (I)= \forkthree{0}{if \(\texttt{hist1}(I)=0\)}{\texttt{scale}}{if \(\texttt{hist1}(I) \ne 0\) and \(\texttt{hist2}(I) > \texttt{hist1}(I)\)}{\frac{\texttt{hist2}(I) \cdot \texttt{scale}}{\texttt{hist1}(I)}}{if \(\texttt{hist1}(I) \ne 0\) and \(\texttt{hist2}(I) \le \texttt{hist1}(I)\)}\f]
|
|
||||||
|
|
||||||
@param hist1 First histogram (the divisor).
|
|
||||||
@param hist2 Second histogram.
|
|
||||||
@param dst_hist Destination histogram.
|
|
||||||
@param scale Scale factor for the destination histogram.
|
|
||||||
*/
|
|
||||||
CVAPI(void) cvCalcProbDensity( const CvHistogram* hist1, const CvHistogram* hist2,
|
|
||||||
CvHistogram* dst_hist, double scale CV_DEFAULT(255) );
|
|
||||||
|
|
||||||
/** @brief equalizes histogram of 8-bit single-channel image
|
/** @brief equalizes histogram of 8-bit single-channel image
|
||||||
@see cv::equalizeHist
|
@see cv::equalizeHist
|
||||||
*/
|
*/
|
||||||
@ -818,19 +726,6 @@ CVAPI(double) cvThreshold( const CvArr* src, CvArr* dst,
|
|||||||
double threshold, double max_value,
|
double threshold, double max_value,
|
||||||
int threshold_type );
|
int threshold_type );
|
||||||
|
|
||||||
/** @brief Applies adaptive threshold to grayscale image.
|
|
||||||
|
|
||||||
The two parameters for methods CV_ADAPTIVE_THRESH_MEAN_C and
|
|
||||||
CV_ADAPTIVE_THRESH_GAUSSIAN_C are:
|
|
||||||
neighborhood size (3, 5, 7 etc.),
|
|
||||||
and a constant subtracted from mean (...,-3,-2,-1,0,1,2,3,...)
|
|
||||||
@see cv::adaptiveThreshold
|
|
||||||
*/
|
|
||||||
CVAPI(void) cvAdaptiveThreshold( const CvArr* src, CvArr* dst, double max_value,
|
|
||||||
int adaptive_method CV_DEFAULT(CV_ADAPTIVE_THRESH_MEAN_C),
|
|
||||||
int threshold_type CV_DEFAULT(CV_THRESH_BINARY),
|
|
||||||
int block_size CV_DEFAULT(3),
|
|
||||||
double param1 CV_DEFAULT(5));
|
|
||||||
|
|
||||||
/** @brief Fills the connected component until the color difference gets large enough
|
/** @brief Fills the connected component until the color difference gets large enough
|
||||||
@see cv::floodFill
|
@see cv::floodFill
|
||||||
@ -846,11 +741,6 @@ CVAPI(void) cvFloodFill( CvArr* image, CvPoint seed_point,
|
|||||||
* Feature detection *
|
* Feature detection *
|
||||||
\****************************************************************************************/
|
\****************************************************************************************/
|
||||||
|
|
||||||
/** @brief Runs canny edge detector
|
|
||||||
@see cv::Canny
|
|
||||||
*/
|
|
||||||
CVAPI(void) cvCanny( const CvArr* image, CvArr* edges, double threshold1,
|
|
||||||
double threshold2, int aperture_size CV_DEFAULT(3) );
|
|
||||||
|
|
||||||
/** @brief Calculates constraint image for corner detection
|
/** @brief Calculates constraint image for corner detection
|
||||||
|
|
||||||
@ -875,15 +765,6 @@ CVAPI(void) cvCornerEigenValsAndVecs( const CvArr* image, CvArr* eigenvv,
|
|||||||
CVAPI(void) cvCornerMinEigenVal( const CvArr* image, CvArr* eigenval,
|
CVAPI(void) cvCornerMinEigenVal( const CvArr* image, CvArr* eigenval,
|
||||||
int block_size, int aperture_size CV_DEFAULT(3) );
|
int block_size, int aperture_size CV_DEFAULT(3) );
|
||||||
|
|
||||||
/** @brief Harris corner detector:
|
|
||||||
|
|
||||||
Calculates det(M) - k*(trace(M)^2), where M is 2x2 gradient covariation matrix for each pixel
|
|
||||||
@see cv::cornerHarris
|
|
||||||
*/
|
|
||||||
CVAPI(void) cvCornerHarris( const CvArr* image, CvArr* harris_response,
|
|
||||||
int block_size, int aperture_size CV_DEFAULT(3),
|
|
||||||
double k CV_DEFAULT(0.04) );
|
|
||||||
|
|
||||||
/** @brief Adjust corner position using some sort of gradient search
|
/** @brief Adjust corner position using some sort of gradient search
|
||||||
@see cv::cornerSubPix
|
@see cv::cornerSubPix
|
||||||
*/
|
*/
|
||||||
@ -891,18 +772,6 @@ CVAPI(void) cvFindCornerSubPix( const CvArr* image, CvPoint2D32f* corners,
|
|||||||
int count, CvSize win, CvSize zero_zone,
|
int count, CvSize win, CvSize zero_zone,
|
||||||
CvTermCriteria criteria );
|
CvTermCriteria criteria );
|
||||||
|
|
||||||
/** @brief Finds a sparse set of points within the selected region
|
|
||||||
that seem to be easy to track
|
|
||||||
@see cv::goodFeaturesToTrack
|
|
||||||
*/
|
|
||||||
CVAPI(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 CV_DEFAULT(NULL),
|
|
||||||
int block_size CV_DEFAULT(3),
|
|
||||||
int use_harris CV_DEFAULT(0),
|
|
||||||
double k CV_DEFAULT(0.04) );
|
|
||||||
|
|
||||||
/** @brief Finds lines on binary image using one of several methods.
|
/** @brief Finds lines on binary image using one of several methods.
|
||||||
|
|
||||||
@ -970,14 +839,6 @@ CVAPI(void) cvRectangle( CvArr* img, CvPoint pt1, CvPoint pt2,
|
|||||||
int line_type CV_DEFAULT(8),
|
int line_type CV_DEFAULT(8),
|
||||||
int shift CV_DEFAULT(0));
|
int shift CV_DEFAULT(0));
|
||||||
|
|
||||||
/** @brief Draws a rectangle specified by a CvRect structure
|
|
||||||
@see cv::rectangle
|
|
||||||
*/
|
|
||||||
CVAPI(void) cvRectangleR( CvArr* img, CvRect r,
|
|
||||||
CvScalar color, int thickness CV_DEFAULT(1),
|
|
||||||
int line_type CV_DEFAULT(8),
|
|
||||||
int shift CV_DEFAULT(0));
|
|
||||||
|
|
||||||
|
|
||||||
/** @brief Draws a circle with specified center and radius.
|
/** @brief Draws a circle with specified center and radius.
|
||||||
|
|
||||||
@ -1012,12 +873,6 @@ CV_INLINE void cvEllipseBox( CvArr* img, CvBox2D box, CvScalar color,
|
|||||||
0, 360, color, thickness, line_type, shift );
|
0, 360, color, thickness, line_type, shift );
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @brief Fills convex or monotonous polygon.
|
|
||||||
@see cv::fillConvexPoly
|
|
||||||
*/
|
|
||||||
CVAPI(void) cvFillConvexPoly( CvArr* img, const CvPoint* pts, int npts, CvScalar color,
|
|
||||||
int line_type CV_DEFAULT(8), int shift CV_DEFAULT(0));
|
|
||||||
|
|
||||||
/** @brief Fills an area bounded by one or more arbitrary polygons
|
/** @brief Fills an area bounded by one or more arbitrary polygons
|
||||||
@see cv::fillPoly
|
@see cv::fillPoly
|
||||||
*/
|
*/
|
||||||
@ -1032,19 +887,6 @@ CVAPI(void) cvPolyLine( CvArr* img, CvPoint** pts, const int* npts, int contour
|
|||||||
int is_closed, CvScalar color, int thickness CV_DEFAULT(1),
|
int is_closed, CvScalar color, int thickness CV_DEFAULT(1),
|
||||||
int line_type CV_DEFAULT(8), int shift CV_DEFAULT(0) );
|
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
|
|
||||||
|
|
||||||
/** @brief Clips the line segment connecting *pt1 and *pt2
|
|
||||||
by the rectangular window
|
|
||||||
|
|
||||||
(0<=x<img_size.width, 0<=y<img_size.height).
|
|
||||||
@see cv::clipLine
|
|
||||||
*/
|
|
||||||
CVAPI(int) cvClipLine( CvSize img_size, CvPoint* pt1, CvPoint* pt2 );
|
|
||||||
|
|
||||||
/** @brief Initializes line iterator.
|
/** @brief Initializes line iterator.
|
||||||
|
|
||||||
@ -1135,11 +977,6 @@ CV_INLINE CvFont cvFont( double scale, int thickness CV_DEFAULT(1) )
|
|||||||
CVAPI(void) cvPutText( CvArr* img, const char* text, CvPoint org,
|
CVAPI(void) cvPutText( CvArr* img, const char* text, CvPoint org,
|
||||||
const CvFont* font, CvScalar color );
|
const CvFont* font, CvScalar color );
|
||||||
|
|
||||||
/** @brief Calculates bounding box of text stroke (useful for alignment)
|
|
||||||
@see cv::getTextSize
|
|
||||||
*/
|
|
||||||
CVAPI(void) cvGetTextSize( const char* text_string, const CvFont* font,
|
|
||||||
CvSize* text_size, int* baseline );
|
|
||||||
|
|
||||||
/** @brief Unpacks color value
|
/** @brief Unpacks color value
|
||||||
|
|
||||||
|
@ -1003,14 +1003,4 @@ void Canny( InputArray _dx, InputArray _dy, OutputArray _dst,
|
|||||||
|
|
||||||
} // namespace cv
|
} // namespace cv
|
||||||
|
|
||||||
void cvCanny( const CvArr* image, CvArr* edges, double threshold1,
|
|
||||||
double threshold2, int aperture_size )
|
|
||||||
{
|
|
||||||
cv::Mat src = cv::cvarrToMat(image), dst = cv::cvarrToMat(edges);
|
|
||||||
CV_Assert( src.size == dst.size && src.depth() == CV_8U && dst.type() == CV_8U );
|
|
||||||
|
|
||||||
cv::Canny(src, dst, threshold1, threshold2, aperture_size & 255,
|
|
||||||
(aperture_size & CV_CANNY_L2_GRADIENT) != 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* End of file. */
|
/* End of file. */
|
||||||
|
@ -565,210 +565,6 @@ cvConvexHull2( const CvArr* array, void* hull_storage,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* contour must be a simple polygon */
|
|
||||||
/* it must have more than 3 points */
|
|
||||||
CV_IMPL CvSeq* cvConvexityDefects( const CvArr* array,
|
|
||||||
const CvArr* hullarray,
|
|
||||||
CvMemStorage* storage )
|
|
||||||
{
|
|
||||||
CvSeq* defects = 0;
|
|
||||||
|
|
||||||
int i, index;
|
|
||||||
CvPoint* hull_cur;
|
|
||||||
|
|
||||||
/* is orientation of hull different from contour one */
|
|
||||||
int rev_orientation;
|
|
||||||
|
|
||||||
CvContour contour_header;
|
|
||||||
CvSeq hull_header;
|
|
||||||
CvSeqBlock block, hullblock;
|
|
||||||
CvSeq *ptseq = (CvSeq*)array, *hull = (CvSeq*)hullarray;
|
|
||||||
|
|
||||||
CvSeqReader hull_reader;
|
|
||||||
CvSeqReader ptseq_reader;
|
|
||||||
CvSeqWriter writer;
|
|
||||||
int is_index;
|
|
||||||
|
|
||||||
if( CV_IS_SEQ( ptseq ))
|
|
||||||
{
|
|
||||||
if( !CV_IS_SEQ_POINT_SET( ptseq ))
|
|
||||||
CV_Error( CV_StsUnsupportedFormat,
|
|
||||||
"Input sequence is not a sequence of points" );
|
|
||||||
if( !storage )
|
|
||||||
storage = ptseq->storage;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
ptseq = cvPointSeqFromMat( CV_SEQ_KIND_GENERIC, array, &contour_header, &block );
|
|
||||||
}
|
|
||||||
|
|
||||||
if( CV_SEQ_ELTYPE( ptseq ) != CV_32SC2 )
|
|
||||||
CV_Error( CV_StsUnsupportedFormat, "Floating-point coordinates are not supported here" );
|
|
||||||
|
|
||||||
if( CV_IS_SEQ( hull ))
|
|
||||||
{
|
|
||||||
int hulltype = CV_SEQ_ELTYPE( hull );
|
|
||||||
if( hulltype != CV_SEQ_ELTYPE_PPOINT && hulltype != CV_SEQ_ELTYPE_INDEX )
|
|
||||||
CV_Error( CV_StsUnsupportedFormat,
|
|
||||||
"Convex hull must represented as a sequence "
|
|
||||||
"of indices or sequence of pointers" );
|
|
||||||
if( !storage )
|
|
||||||
storage = hull->storage;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
CvMat* mat = (CvMat*)hull;
|
|
||||||
|
|
||||||
if( !CV_IS_MAT( hull ))
|
|
||||||
CV_Error(CV_StsBadArg, "Convex hull is neither sequence nor matrix");
|
|
||||||
|
|
||||||
if( (mat->cols != 1 && mat->rows != 1) ||
|
|
||||||
!CV_IS_MAT_CONT(mat->type) || CV_MAT_TYPE(mat->type) != CV_32SC1 )
|
|
||||||
CV_Error( CV_StsBadArg,
|
|
||||||
"The matrix should be 1-dimensional and continuous array of int's" );
|
|
||||||
|
|
||||||
if( mat->cols + mat->rows - 1 > ptseq->total )
|
|
||||||
CV_Error( CV_StsBadSize, "Convex hull is larger than the point sequence" );
|
|
||||||
|
|
||||||
hull = cvMakeSeqHeaderForArray(
|
|
||||||
CV_SEQ_KIND_CURVE|CV_MAT_TYPE(mat->type)|CV_SEQ_FLAG_CLOSED,
|
|
||||||
sizeof(hull_header), CV_ELEM_SIZE(mat->type), mat->data.ptr,
|
|
||||||
mat->cols + mat->rows - 1, &hull_header, &hullblock );
|
|
||||||
}
|
|
||||||
|
|
||||||
is_index = CV_SEQ_ELTYPE(hull) == CV_SEQ_ELTYPE_INDEX;
|
|
||||||
|
|
||||||
if( !storage )
|
|
||||||
CV_Error( CV_StsNullPtr, "NULL storage pointer" );
|
|
||||||
|
|
||||||
defects = cvCreateSeq( CV_SEQ_KIND_GENERIC, sizeof(CvSeq), sizeof(CvConvexityDefect), storage );
|
|
||||||
|
|
||||||
if( ptseq->total < 4 || hull->total < 3)
|
|
||||||
{
|
|
||||||
//CV_ERROR( CV_StsBadSize,
|
|
||||||
// "point seq size must be >= 4, convex hull size must be >= 3" );
|
|
||||||
return defects;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* recognize co-orientation of ptseq and its hull */
|
|
||||||
{
|
|
||||||
int sign = 0;
|
|
||||||
int index1, index2, index3;
|
|
||||||
|
|
||||||
if( !is_index )
|
|
||||||
{
|
|
||||||
CvPoint* pos = *CV_SEQ_ELEM( hull, CvPoint*, 0 );
|
|
||||||
index1 = cvSeqElemIdx( ptseq, pos );
|
|
||||||
|
|
||||||
pos = *CV_SEQ_ELEM( hull, CvPoint*, 1 );
|
|
||||||
index2 = cvSeqElemIdx( ptseq, pos );
|
|
||||||
|
|
||||||
pos = *CV_SEQ_ELEM( hull, CvPoint*, 2 );
|
|
||||||
index3 = cvSeqElemIdx( ptseq, pos );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
index1 = *CV_SEQ_ELEM( hull, int, 0 );
|
|
||||||
index2 = *CV_SEQ_ELEM( hull, int, 1 );
|
|
||||||
index3 = *CV_SEQ_ELEM( hull, int, 2 );
|
|
||||||
}
|
|
||||||
|
|
||||||
sign += (index2 > index1) ? 1 : 0;
|
|
||||||
sign += (index3 > index2) ? 1 : 0;
|
|
||||||
sign += (index1 > index3) ? 1 : 0;
|
|
||||||
|
|
||||||
rev_orientation = (sign == 2) ? 0 : 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
cvStartReadSeq( ptseq, &ptseq_reader, 0 );
|
|
||||||
cvStartReadSeq( hull, &hull_reader, rev_orientation );
|
|
||||||
|
|
||||||
if( !is_index )
|
|
||||||
{
|
|
||||||
hull_cur = *(CvPoint**)hull_reader.prev_elem;
|
|
||||||
index = cvSeqElemIdx( ptseq, (char*)hull_cur, 0 );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
index = *(int*)hull_reader.prev_elem;
|
|
||||||
hull_cur = CV_GET_SEQ_ELEM( CvPoint, ptseq, index );
|
|
||||||
}
|
|
||||||
cvSetSeqReaderPos( &ptseq_reader, index );
|
|
||||||
cvStartAppendToSeq( defects, &writer );
|
|
||||||
|
|
||||||
/* cycle through ptseq and hull with computing defects */
|
|
||||||
for( i = 0; i < hull->total; i++ )
|
|
||||||
{
|
|
||||||
CvConvexityDefect defect;
|
|
||||||
int is_defect = 0;
|
|
||||||
double dx0, dy0;
|
|
||||||
double depth = 0, scale;
|
|
||||||
CvPoint* hull_next;
|
|
||||||
|
|
||||||
if( !is_index )
|
|
||||||
hull_next = *(CvPoint**)hull_reader.ptr;
|
|
||||||
else
|
|
||||||
{
|
|
||||||
int t = *(int*)hull_reader.ptr;
|
|
||||||
hull_next = CV_GET_SEQ_ELEM( CvPoint, ptseq, t );
|
|
||||||
}
|
|
||||||
CV_Assert(hull_next != NULL && hull_cur != NULL);
|
|
||||||
|
|
||||||
dx0 = (double)hull_next->x - (double)hull_cur->x;
|
|
||||||
dy0 = (double)hull_next->y - (double)hull_cur->y;
|
|
||||||
assert( dx0 != 0 || dy0 != 0 );
|
|
||||||
scale = 1./std::sqrt(dx0*dx0 + dy0*dy0);
|
|
||||||
|
|
||||||
defect.start = hull_cur;
|
|
||||||
defect.end = hull_next;
|
|
||||||
|
|
||||||
for(;;)
|
|
||||||
{
|
|
||||||
/* go through ptseq to achieve next hull point */
|
|
||||||
CV_NEXT_SEQ_ELEM( sizeof(CvPoint), ptseq_reader );
|
|
||||||
|
|
||||||
if( ptseq_reader.ptr == (schar*)hull_next )
|
|
||||||
break;
|
|
||||||
else
|
|
||||||
{
|
|
||||||
CvPoint* cur = (CvPoint*)ptseq_reader.ptr;
|
|
||||||
|
|
||||||
/* compute distance from current point to hull edge */
|
|
||||||
double dx = (double)cur->x - (double)hull_cur->x;
|
|
||||||
double dy = (double)cur->y - (double)hull_cur->y;
|
|
||||||
|
|
||||||
/* compute depth */
|
|
||||||
double dist = fabs(-dy0*dx + dx0*dy) * scale;
|
|
||||||
|
|
||||||
if( dist > depth )
|
|
||||||
{
|
|
||||||
depth = dist;
|
|
||||||
defect.depth_point = cur;
|
|
||||||
defect.depth = (float)depth;
|
|
||||||
is_defect = 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if( is_defect )
|
|
||||||
{
|
|
||||||
CV_WRITE_SEQ_ELEM( defect, writer );
|
|
||||||
}
|
|
||||||
|
|
||||||
hull_cur = hull_next;
|
|
||||||
if( rev_orientation )
|
|
||||||
{
|
|
||||||
CV_PREV_SEQ_ELEM( hull->elem_size, hull_reader );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
CV_NEXT_SEQ_ELEM( hull->elem_size, hull_reader );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return cvEndWriteSeq( &writer );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
CV_IMPL int
|
CV_IMPL int
|
||||||
cvCheckContourConvexity( const CvArr* array )
|
cvCheckContourConvexity( const CvArr* array )
|
||||||
{
|
{
|
||||||
|
@ -746,17 +746,6 @@ cvCornerMinEigenVal( const CvArr* srcarr, CvArr* dstarr,
|
|||||||
cv::cornerMinEigenVal( src, dst, block_size, aperture_size, cv::BORDER_REPLICATE );
|
cv::cornerMinEigenVal( src, dst, block_size, aperture_size, cv::BORDER_REPLICATE );
|
||||||
}
|
}
|
||||||
|
|
||||||
CV_IMPL void
|
|
||||||
cvCornerHarris( const CvArr* srcarr, CvArr* dstarr,
|
|
||||||
int block_size, int aperture_size, double k )
|
|
||||||
{
|
|
||||||
cv::Mat src = cv::cvarrToMat(srcarr), dst = cv::cvarrToMat(dstarr);
|
|
||||||
|
|
||||||
CV_Assert( src.size() == dst.size() && dst.type() == CV_32FC1 );
|
|
||||||
cv::cornerHarris( src, dst, block_size, aperture_size, k, cv::BORDER_REPLICATE );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
CV_IMPL void
|
CV_IMPL void
|
||||||
cvCornerEigenValsAndVecs( const void* srcarr, void* dstarr,
|
cvCornerEigenValsAndVecs( const void* srcarr, void* dstarr,
|
||||||
int block_size, int aperture_size )
|
int block_size, int aperture_size )
|
||||||
|
@ -875,29 +875,4 @@ void cv::Laplacian( InputArray _src, OutputArray _dst, int ddepth, int ksize,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
CV_IMPL void
|
|
||||||
cvSobel( const void* srcarr, void* dstarr, int dx, int dy, int aperture_size )
|
|
||||||
{
|
|
||||||
cv::Mat src = cv::cvarrToMat(srcarr), dst = cv::cvarrToMat(dstarr);
|
|
||||||
|
|
||||||
CV_Assert( src.size() == dst.size() && src.channels() == dst.channels() );
|
|
||||||
|
|
||||||
cv::Sobel( src, dst, dst.depth(), dx, dy, aperture_size, 1, 0, cv::BORDER_REPLICATE );
|
|
||||||
if( CV_IS_IMAGE(srcarr) && ((IplImage*)srcarr)->origin && dy % 2 != 0 )
|
|
||||||
dst *= -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
CV_IMPL void
|
|
||||||
cvLaplace( const void* srcarr, void* dstarr, int aperture_size )
|
|
||||||
{
|
|
||||||
cv::Mat src = cv::cvarrToMat(srcarr), dst = cv::cvarrToMat(dstarr);
|
|
||||||
|
|
||||||
CV_Assert( src.size() == dst.size() && src.channels() == dst.channels() );
|
|
||||||
|
|
||||||
cv::Laplacian( src, dst, dst.depth(), aperture_size, 1, 0, cv::BORDER_REPLICATE );
|
|
||||||
}
|
|
||||||
|
|
||||||
/* End of file. */
|
/* End of file. */
|
||||||
|
@ -2346,24 +2346,6 @@ cvDrawContours( void* _img, CvSeq* contour,
|
|||||||
contour0->h_next = h_next;
|
contour0->h_next = h_next;
|
||||||
}
|
}
|
||||||
|
|
||||||
CV_IMPL int
|
|
||||||
cvClipLine( CvSize size, CvPoint* pt1, CvPoint* pt2 )
|
|
||||||
{
|
|
||||||
CV_Assert( pt1 && pt2 );
|
|
||||||
return cv::clipLine( size, *(cv::Point*)pt1, *(cv::Point*)pt2 );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
CV_IMPL int
|
|
||||||
cvEllipse2Poly( CvPoint center, CvSize axes, int angle,
|
|
||||||
int arc_start, int arc_end, CvPoint* _pts, int delta )
|
|
||||||
{
|
|
||||||
std::vector<cv::Point> pts;
|
|
||||||
cv::ellipse2Poly( Point(center), Size(axes), angle, arc_start, arc_end, delta, pts );
|
|
||||||
memcpy( _pts, &pts[0], pts.size()*sizeof(_pts[0]) );
|
|
||||||
return (int)pts.size();
|
|
||||||
}
|
|
||||||
|
|
||||||
CV_IMPL CvScalar
|
CV_IMPL CvScalar
|
||||||
cvColorToScalar( double packed_color, int type )
|
cvColorToScalar( double packed_color, int type )
|
||||||
{
|
{
|
||||||
@ -2463,15 +2445,6 @@ cvRectangle( CvArr* _img, CvPoint pt1, CvPoint pt2,
|
|||||||
cv::rectangle( img, pt1, pt2, color, thickness, line_type, shift );
|
cv::rectangle( img, pt1, pt2, color, thickness, line_type, shift );
|
||||||
}
|
}
|
||||||
|
|
||||||
CV_IMPL void
|
|
||||||
cvRectangleR( CvArr* _img, CvRect rec,
|
|
||||||
CvScalar color, int thickness,
|
|
||||||
int line_type, int shift )
|
|
||||||
{
|
|
||||||
cv::Mat img = cv::cvarrToMat(_img);
|
|
||||||
cv::rectangle( img, rec, color, thickness, line_type, shift );
|
|
||||||
}
|
|
||||||
|
|
||||||
CV_IMPL void
|
CV_IMPL void
|
||||||
cvCircle( CvArr* _img, CvPoint center, int radius,
|
cvCircle( CvArr* _img, CvPoint center, int radius,
|
||||||
CvScalar color, int thickness, int line_type, int shift )
|
CvScalar color, int thickness, int line_type, int shift )
|
||||||
@ -2490,15 +2463,6 @@ cvEllipse( CvArr* _img, CvPoint center, CvSize axes,
|
|||||||
color, thickness, line_type, shift );
|
color, thickness, line_type, shift );
|
||||||
}
|
}
|
||||||
|
|
||||||
CV_IMPL void
|
|
||||||
cvFillConvexPoly( CvArr* _img, const CvPoint *pts, int npts,
|
|
||||||
CvScalar color, int line_type, int shift )
|
|
||||||
{
|
|
||||||
cv::Mat img = cv::cvarrToMat(_img);
|
|
||||||
cv::fillConvexPoly( img, (const cv::Point*)pts, npts,
|
|
||||||
color, line_type, shift );
|
|
||||||
}
|
|
||||||
|
|
||||||
CV_IMPL void
|
CV_IMPL void
|
||||||
cvFillPoly( CvArr* _img, CvPoint **pts, const int *npts, int ncontours,
|
cvFillPoly( CvArr* _img, CvPoint **pts, const int *npts, int ncontours,
|
||||||
CvScalar color, int line_type, int shift )
|
CvScalar color, int line_type, int shift )
|
||||||
@ -2546,14 +2510,4 @@ cvInitFont( CvFont *font, int font_face, double hscale, double vscale,
|
|||||||
font->line_type = line_type;
|
font->line_type = line_type;
|
||||||
}
|
}
|
||||||
|
|
||||||
CV_IMPL void
|
|
||||||
cvGetTextSize( const char *text, const CvFont *_font, CvSize *_size, int *_base_line )
|
|
||||||
{
|
|
||||||
CV_Assert(text != 0 && _font != 0);
|
|
||||||
cv::Size size = cv::getTextSize( text, _font->font_face, (_font->hscale + _font->vscale)*0.5,
|
|
||||||
_font->thickness, _base_line );
|
|
||||||
if( _size )
|
|
||||||
*_size = cvSize(size);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* End of file. */
|
/* End of file. */
|
||||||
|
@ -511,29 +511,6 @@ void cv::goodFeaturesToTrack( InputArray _image, OutputArray _corners,
|
|||||||
Mat(corners).convertTo(_corners, _corners.fixedType() ? _corners.type() : CV_32F);
|
Mat(corners).convertTo(_corners, _corners.fixedType() ? _corners.type() : CV_32F);
|
||||||
}
|
}
|
||||||
|
|
||||||
CV_IMPL void
|
|
||||||
cvGoodFeaturesToTrack( const void* _image, void*, void*,
|
|
||||||
CvPoint2D32f* _corners, int *_corner_count,
|
|
||||||
double quality_level, double min_distance,
|
|
||||||
const void* _maskImage, int block_size,
|
|
||||||
int use_harris, double harris_k )
|
|
||||||
{
|
|
||||||
cv::Mat image = cv::cvarrToMat(_image), mask;
|
|
||||||
std::vector<cv::Point2f> corners;
|
|
||||||
|
|
||||||
if( _maskImage )
|
|
||||||
mask = cv::cvarrToMat(_maskImage);
|
|
||||||
|
|
||||||
CV_Assert( _corners && _corner_count );
|
|
||||||
cv::goodFeaturesToTrack( image, corners, *_corner_count, quality_level,
|
|
||||||
min_distance, mask, block_size, use_harris != 0, harris_k );
|
|
||||||
|
|
||||||
size_t i, ncorners = corners.size();
|
|
||||||
for( i = 0; i < ncorners; i++ )
|
|
||||||
_corners[i] = cvPoint2D32f(corners[i]);
|
|
||||||
*_corner_count = (int)ncorners;
|
|
||||||
}
|
|
||||||
|
|
||||||
void cv::goodFeaturesToTrack( InputArray _image, OutputArray _corners,
|
void cv::goodFeaturesToTrack( InputArray _image, OutputArray _corners,
|
||||||
int maxCorners, double qualityLevel, double minDistance,
|
int maxCorners, double qualityLevel, double minDistance,
|
||||||
InputArray _mask, int blockSize,
|
InputArray _mask, int blockSize,
|
||||||
|
@ -3172,50 +3172,6 @@ cvCalcBayesianProb( CvHistogram** src, int count, CvHistogram** dst )
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
CV_IMPL void
|
|
||||||
cvCalcProbDensity( const CvHistogram* hist, const CvHistogram* hist_mask,
|
|
||||||
CvHistogram* hist_dens, double scale )
|
|
||||||
{
|
|
||||||
if( scale <= 0 )
|
|
||||||
CV_Error( CV_StsOutOfRange, "scale must be positive" );
|
|
||||||
|
|
||||||
if( !CV_IS_HIST(hist) || !CV_IS_HIST(hist_mask) || !CV_IS_HIST(hist_dens) )
|
|
||||||
CV_Error( CV_StsBadArg, "Invalid histogram pointer[s]" );
|
|
||||||
|
|
||||||
{
|
|
||||||
CvArr* arrs[] = { hist->bins, hist_mask->bins, hist_dens->bins };
|
|
||||||
CvMatND stubs[3];
|
|
||||||
CvNArrayIterator iterator;
|
|
||||||
|
|
||||||
cvInitNArrayIterator( 3, arrs, 0, stubs, &iterator );
|
|
||||||
|
|
||||||
if( CV_MAT_TYPE(iterator.hdr[0]->type) != CV_32FC1 )
|
|
||||||
CV_Error( CV_StsUnsupportedFormat, "All histograms must have 32fC1 type" );
|
|
||||||
|
|
||||||
do
|
|
||||||
{
|
|
||||||
const float* srcdata = (const float*)(iterator.ptr[0]);
|
|
||||||
const float* maskdata = (const float*)(iterator.ptr[1]);
|
|
||||||
float* dstdata = (float*)(iterator.ptr[2]);
|
|
||||||
int i;
|
|
||||||
|
|
||||||
for( i = 0; i < iterator.size.width; i++ )
|
|
||||||
{
|
|
||||||
float s = srcdata[i];
|
|
||||||
float m = maskdata[i];
|
|
||||||
if( s > FLT_EPSILON )
|
|
||||||
if( m <= s )
|
|
||||||
dstdata[i] = (float)(m*scale/s);
|
|
||||||
else
|
|
||||||
dstdata[i] = (float)scale;
|
|
||||||
else
|
|
||||||
dstdata[i] = (float)0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
while( cvNextNArraySlice( &iterator ));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class EqualizeHistCalcHist_Invoker : public cv::ParallelLoopBody
|
class EqualizeHistCalcHist_Invoker : public cv::ParallelLoopBody
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
@ -3462,36 +3462,6 @@ cvGetPerspectiveTransform( const CvPoint2D32f* src,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
CV_IMPL CvMat*
|
|
||||||
cvGetAffineTransform( const CvPoint2D32f* src,
|
|
||||||
const CvPoint2D32f* dst,
|
|
||||||
CvMat* matrix )
|
|
||||||
{
|
|
||||||
cv::Mat M0 = cv::cvarrToMat(matrix),
|
|
||||||
M = cv::getAffineTransform((const cv::Point2f*)src, (const cv::Point2f*)dst);
|
|
||||||
CV_Assert( M.size() == M0.size() );
|
|
||||||
M.convertTo(M0, M0.type());
|
|
||||||
return matrix;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
CV_IMPL void
|
|
||||||
cvConvertMaps( const CvArr* arr1, const CvArr* arr2, CvArr* dstarr1, CvArr* dstarr2 )
|
|
||||||
{
|
|
||||||
cv::Mat map1 = cv::cvarrToMat(arr1), map2;
|
|
||||||
cv::Mat dstmap1 = cv::cvarrToMat(dstarr1), dstmap2;
|
|
||||||
|
|
||||||
if( arr2 )
|
|
||||||
map2 = cv::cvarrToMat(arr2);
|
|
||||||
if( dstarr2 )
|
|
||||||
{
|
|
||||||
dstmap2 = cv::cvarrToMat(dstarr2);
|
|
||||||
if( dstmap2.type() == CV_16SC1 )
|
|
||||||
dstmap2 = cv::Mat(dstmap2.size(), CV_16UC1, dstmap2.ptr(), dstmap2.step);
|
|
||||||
}
|
|
||||||
|
|
||||||
cv::convertMaps( map1, map2, dstmap1, dstmap2, dstmap1.type(), false );
|
|
||||||
}
|
|
||||||
|
|
||||||
/****************************************************************************************
|
/****************************************************************************************
|
||||||
PkLab.net 2018 based on cv::linearPolar from OpenCV by J.L. Blanco, Apr 2009
|
PkLab.net 2018 based on cv::linearPolar from OpenCV by J.L. Blanco, Apr 2009
|
||||||
@ -3627,30 +3597,4 @@ void cv::logPolar( InputArray _src, OutputArray _dst,
|
|||||||
warpPolar(_src, _dst, ssize, center, M, flags | WARP_POLAR_LOG);
|
warpPolar(_src, _dst, ssize, center, M, flags | WARP_POLAR_LOG);
|
||||||
}
|
}
|
||||||
|
|
||||||
CV_IMPL
|
|
||||||
void cvLinearPolar( const CvArr* srcarr, CvArr* dstarr,
|
|
||||||
CvPoint2D32f center, double maxRadius, int flags )
|
|
||||||
{
|
|
||||||
Mat src = cvarrToMat(srcarr);
|
|
||||||
Mat dst = cvarrToMat(dstarr);
|
|
||||||
|
|
||||||
CV_Assert(src.size == dst.size);
|
|
||||||
CV_Assert(src.type() == dst.type());
|
|
||||||
|
|
||||||
cv::linearPolar(src, dst, center, maxRadius, flags);
|
|
||||||
}
|
|
||||||
|
|
||||||
CV_IMPL
|
|
||||||
void cvLogPolar( const CvArr* srcarr, CvArr* dstarr,
|
|
||||||
CvPoint2D32f center, double M, int flags )
|
|
||||||
{
|
|
||||||
Mat src = cvarrToMat(srcarr);
|
|
||||||
Mat dst = cvarrToMat(dstarr);
|
|
||||||
|
|
||||||
CV_Assert(src.size == dst.size);
|
|
||||||
CV_Assert(src.type() == dst.type());
|
|
||||||
|
|
||||||
cv::logPolar(src, dst, center, M, flags);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* End of file. */
|
/* End of file. */
|
||||||
|
@ -1566,96 +1566,4 @@ CV_IMPL void cvPyrUp( const void* srcarr, void* dstarr, int _filter )
|
|||||||
cv::pyrUp( src, dst, dst.size() );
|
cv::pyrUp( src, dst, dst.size() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
CV_IMPL void
|
|
||||||
cvReleasePyramid( CvMat*** _pyramid, int extra_layers )
|
|
||||||
{
|
|
||||||
if( !_pyramid )
|
|
||||||
CV_Error( CV_StsNullPtr, "" );
|
|
||||||
|
|
||||||
if( *_pyramid )
|
|
||||||
for( int i = 0; i <= extra_layers; i++ )
|
|
||||||
cvReleaseMat( &(*_pyramid)[i] );
|
|
||||||
|
|
||||||
cvFree( _pyramid );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
CV_IMPL CvMat**
|
|
||||||
cvCreatePyramid( const CvArr* srcarr, int extra_layers, double rate,
|
|
||||||
const CvSize* layer_sizes, CvArr* bufarr,
|
|
||||||
int calc, int filter )
|
|
||||||
{
|
|
||||||
const float eps = 0.1f;
|
|
||||||
uchar* ptr = 0;
|
|
||||||
|
|
||||||
CvMat stub, *src = cvGetMat( srcarr, &stub );
|
|
||||||
|
|
||||||
if( extra_layers < 0 )
|
|
||||||
CV_Error( CV_StsOutOfRange, "The number of extra layers must be non negative" );
|
|
||||||
|
|
||||||
int i, layer_step, elem_size = CV_ELEM_SIZE(src->type);
|
|
||||||
cv::Size layer_size, size = cvGetMatSize(src);
|
|
||||||
|
|
||||||
if( bufarr )
|
|
||||||
{
|
|
||||||
CvMat bstub, *buf;
|
|
||||||
int bufsize = 0;
|
|
||||||
|
|
||||||
buf = cvGetMat( bufarr, &bstub );
|
|
||||||
bufsize = buf->rows*buf->cols*CV_ELEM_SIZE(buf->type);
|
|
||||||
layer_size = size;
|
|
||||||
for( i = 1; i <= extra_layers; i++ )
|
|
||||||
{
|
|
||||||
if( !layer_sizes )
|
|
||||||
{
|
|
||||||
layer_size.width = cvRound(layer_size.width*rate+eps);
|
|
||||||
layer_size.height = cvRound(layer_size.height*rate+eps);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
layer_size = layer_sizes[i-1];
|
|
||||||
layer_step = layer_size.width*elem_size;
|
|
||||||
bufsize -= layer_step*layer_size.height;
|
|
||||||
}
|
|
||||||
|
|
||||||
if( bufsize < 0 )
|
|
||||||
CV_Error( CV_StsOutOfRange, "The buffer is too small to fit the pyramid" );
|
|
||||||
ptr = buf->data.ptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
CvMat** pyramid = (CvMat**)cvAlloc( (extra_layers+1)*sizeof(pyramid[0]) );
|
|
||||||
memset( pyramid, 0, (extra_layers+1)*sizeof(pyramid[0]) );
|
|
||||||
|
|
||||||
pyramid[0] = cvCreateMatHeader( size.height, size.width, src->type );
|
|
||||||
cvSetData( pyramid[0], src->data.ptr, src->step );
|
|
||||||
layer_size = size;
|
|
||||||
|
|
||||||
for( i = 1; i <= extra_layers; i++ )
|
|
||||||
{
|
|
||||||
if( !layer_sizes )
|
|
||||||
{
|
|
||||||
layer_size.width = cvRound(layer_size.width*rate + eps);
|
|
||||||
layer_size.height = cvRound(layer_size.height*rate + eps);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
layer_size = layer_sizes[i];
|
|
||||||
|
|
||||||
if( bufarr )
|
|
||||||
{
|
|
||||||
pyramid[i] = cvCreateMatHeader( layer_size.height, layer_size.width, src->type );
|
|
||||||
layer_step = layer_size.width*elem_size;
|
|
||||||
cvSetData( pyramid[i], ptr, layer_step );
|
|
||||||
ptr += layer_step*layer_size.height;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
pyramid[i] = cvCreateMat( layer_size.height, layer_size.width, src->type );
|
|
||||||
|
|
||||||
if( calc )
|
|
||||||
cvPyrDown( pyramid[i-1], pyramid[i], filter );
|
|
||||||
//cvResize( pyramid[i-1], pyramid[i], CV_INTER_LINEAR );
|
|
||||||
}
|
|
||||||
|
|
||||||
return pyramid;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* End of file. */
|
/* End of file. */
|
||||||
|
@ -546,24 +546,3 @@ void cv::pyrMeanShiftFiltering( InputArray _src, OutputArray _dst,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
CV_IMPL void cvWatershed( const CvArr* _src, CvArr* _markers )
|
|
||||||
{
|
|
||||||
cv::Mat src = cv::cvarrToMat(_src), markers = cv::cvarrToMat(_markers);
|
|
||||||
cv::watershed(src, markers);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
CV_IMPL void
|
|
||||||
cvPyrMeanShiftFiltering( const CvArr* srcarr, CvArr* dstarr,
|
|
||||||
double sp0, double sr, int max_level,
|
|
||||||
CvTermCriteria termcrit )
|
|
||||||
{
|
|
||||||
cv::Mat src = cv::cvarrToMat(srcarr);
|
|
||||||
const cv::Mat dst = cv::cvarrToMat(dstarr);
|
|
||||||
|
|
||||||
cv::pyrMeanShiftFiltering(src, dst, sp0, sr, max_level, termcrit);
|
|
||||||
}
|
|
||||||
|
@ -1753,14 +1753,4 @@ cvThreshold( const void* srcarr, void* dstarr, double thresh, double maxval, int
|
|||||||
return thresh;
|
return thresh;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
CV_IMPL void
|
|
||||||
cvAdaptiveThreshold( const void *srcIm, void *dstIm, double maxValue,
|
|
||||||
int method, int type, int blockSize, double delta )
|
|
||||||
{
|
|
||||||
cv::Mat src = cv::cvarrToMat(srcIm), dst = cv::cvarrToMat(dstIm);
|
|
||||||
CV_Assert( src.size == dst.size && src.type() == dst.type() );
|
|
||||||
cv::adaptiveThreshold( src, dst, maxValue, method, type, blockSize, delta );
|
|
||||||
}
|
|
||||||
|
|
||||||
/* End of file. */
|
/* End of file. */
|
||||||
|
@ -75,16 +75,4 @@ CV_IMPL CvSeq* cvPointSeqFromMat( int seq_kind, const CvArr* arr,
|
|||||||
return (CvSeq*)contour_header;
|
return (CvSeq*)contour_header;
|
||||||
}
|
}
|
||||||
|
|
||||||
CV_IMPL void
|
|
||||||
cvCopyMakeBorder( const CvArr* srcarr, CvArr* dstarr, CvPoint offset,
|
|
||||||
int borderType, CvScalar value )
|
|
||||||
{
|
|
||||||
cv::Mat src = cv::cvarrToMat(srcarr), dst = cv::cvarrToMat(dstarr);
|
|
||||||
int left = offset.x, right = dst.cols - src.cols - left;
|
|
||||||
int top = offset.y, bottom = dst.rows - src.rows - top;
|
|
||||||
|
|
||||||
CV_Assert( dst.type() == src.type() );
|
|
||||||
cv::copyMakeBorder( src, dst, top, bottom, left, right, borderType, value );
|
|
||||||
}
|
|
||||||
|
|
||||||
/* End of file. */
|
/* End of file. */
|
||||||
|
@ -65,18 +65,6 @@ In C++ use cv::VideoCapture
|
|||||||
*/
|
*/
|
||||||
typedef struct CvCapture CvCapture;
|
typedef struct CvCapture CvCapture;
|
||||||
|
|
||||||
/** @brief start capturing frames from video file
|
|
||||||
*/
|
|
||||||
CVAPI(CvCapture*) cvCreateFileCapture( const char* filename );
|
|
||||||
|
|
||||||
/** @brief start capturing frames from video file. allows specifying a preferred API to use
|
|
||||||
*/
|
|
||||||
CVAPI(CvCapture*) cvCreateFileCaptureWithPreference( const char* filename , int apiPreference);
|
|
||||||
|
|
||||||
/** @brief start capturing frames from camera: index = camera_index + domain_offset (CV_CAP_*)
|
|
||||||
*/
|
|
||||||
CVAPI(CvCapture*) cvCreateCameraCapture( int index );
|
|
||||||
|
|
||||||
/** @brief grab a frame, return 1 on success, 0 on fail.
|
/** @brief grab a frame, return 1 on success, 0 on fail.
|
||||||
|
|
||||||
this function is thought to be fast
|
this function is thought to be fast
|
||||||
@ -108,12 +96,6 @@ CVAPI(double) cvGetCaptureProperty( CvCapture* capture, int property_id );
|
|||||||
*/
|
*/
|
||||||
CVAPI(int) cvSetCaptureProperty( CvCapture* capture, int property_id, double value );
|
CVAPI(int) cvSetCaptureProperty( CvCapture* capture, int property_id, double value );
|
||||||
|
|
||||||
/** @brief Return the type of the capturer (eg, ::CV_CAP_VFW, ::CV_CAP_UNICAP)
|
|
||||||
|
|
||||||
It is unknown if created with ::CV_CAP_ANY
|
|
||||||
*/
|
|
||||||
CVAPI(int) cvGetCaptureDomain( CvCapture* capture);
|
|
||||||
|
|
||||||
/** @brief "black box" video file writer structure
|
/** @brief "black box" video file writer structure
|
||||||
|
|
||||||
In C++ use cv::VideoWriter
|
In C++ use cv::VideoWriter
|
||||||
@ -134,16 +116,6 @@ CVAPI(int) cvWriteFrame( CvVideoWriter* writer, const IplImage* image );
|
|||||||
*/
|
*/
|
||||||
CVAPI(void) cvReleaseVideoWriter( CvVideoWriter** writer );
|
CVAPI(void) cvReleaseVideoWriter( CvVideoWriter** writer );
|
||||||
|
|
||||||
// ***************************************************************************************
|
|
||||||
//! @name Obsolete functions/synonyms
|
|
||||||
//! @{
|
|
||||||
#define cvCaptureFromCAM cvCreateCameraCapture //!< @deprecated use cvCreateCameraCapture() instead
|
|
||||||
#define cvCaptureFromFile cvCreateFileCapture //!< @deprecated use cvCreateFileCapture() instead
|
|
||||||
#define cvCaptureFromAVI cvCaptureFromFile //!< @deprecated use cvCreateFileCapture() instead
|
|
||||||
#define cvCreateAVIWriter cvCreateVideoWriter //!< @deprecated use cvCreateVideoWriter() instead
|
|
||||||
#define cvWriteToAVI cvWriteFrame //!< @deprecated use cvWriteFrame() instead
|
|
||||||
//! @} Obsolete...
|
|
||||||
|
|
||||||
//! @} videoio_c
|
//! @} videoio_c
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
@ -10,29 +10,6 @@ using namespace cv;
|
|||||||
|
|
||||||
// Legacy C-like API
|
// Legacy C-like API
|
||||||
|
|
||||||
CV_IMPL CvCapture* cvCreateCameraCapture(int)
|
|
||||||
{
|
|
||||||
CV_LOG_WARNING(NULL, "cvCreateCameraCapture doesn't support legacy API anymore.")
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
CV_IMPL CvCapture* cvCreateFileCaptureWithPreference(const char*, int)
|
|
||||||
{
|
|
||||||
CV_LOG_WARNING(NULL, "cvCreateFileCaptureWithPreference doesn't support legacy API anymore.")
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
CV_IMPL CvCapture* cvCreateFileCapture(const char * filename)
|
|
||||||
{
|
|
||||||
return cvCreateFileCaptureWithPreference(filename, CAP_ANY);
|
|
||||||
}
|
|
||||||
|
|
||||||
CV_IMPL CvVideoWriter* cvCreateVideoWriter(const char*, int, double, CvSize, int)
|
|
||||||
{
|
|
||||||
CV_LOG_WARNING(NULL, "cvCreateVideoWriter doesn't support legacy API anymore.")
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
CV_IMPL int cvWriteFrame(CvVideoWriter* writer, const IplImage* image)
|
CV_IMPL int cvWriteFrame(CvVideoWriter* writer, const IplImage* image)
|
||||||
{
|
{
|
||||||
return writer ? writer->writeFrame(image) : 0;
|
return writer ? writer->writeFrame(image) : 0;
|
||||||
@ -84,8 +61,3 @@ CV_IMPL int cvSetCaptureProperty(CvCapture* capture, int id, double value)
|
|||||||
{
|
{
|
||||||
return capture ? capture->setProperty(id, value) : 0;
|
return capture ? capture->setProperty(id, value) : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
CV_IMPL int cvGetCaptureDomain(CvCapture* capture)
|
|
||||||
{
|
|
||||||
return capture ? capture->getCaptureDomain() : 0;
|
|
||||||
}
|
|
||||||
|
Loading…
Reference in New Issue
Block a user