Creates CvMat header only
| 105 | |
| 106 | // Creates CvMat header only |
| 107 | CV_IMPL CvMat* |
| 108 | cvCreateMatHeader( int rows, int cols, int type ) |
| 109 | { |
| 110 | type = CV_MAT_TYPE(type); |
| 111 | |
| 112 | if( rows < 0 || cols <= 0 ) |
| 113 | CV_Error( CV_StsBadSize, "Non-positive width or height" ); |
| 114 | |
| 115 | int min_step = CV_ELEM_SIZE(type)*cols; |
| 116 | if( min_step <= 0 ) |
| 117 | CV_Error( CV_StsUnsupportedFormat, "Invalid matrix type" ); |
| 118 | |
| 119 | CvMat* arr = (CvMat*)cvAlloc( sizeof(*arr)); |
| 120 | |
| 121 | arr->step = min_step; |
| 122 | arr->type = CV_MAT_MAGIC_VAL | type | CV_MAT_CONT_FLAG; |
| 123 | arr->rows = rows; |
| 124 | arr->cols = cols; |
| 125 | arr->data.ptr = 0; |
| 126 | arr->refcount = 0; |
| 127 | arr->hdr_refcount = 1; |
| 128 | |
| 129 | icvCheckHuge( arr ); |
| 130 | return arr; |
| 131 | } |
| 132 | |
| 133 | |
| 134 | // Initializes CvMat header, allocated by the user |
no test coverage detected