Returns the size of CvMat or IplImage
| 1208 | |
| 1209 | // Returns the size of CvMat or IplImage |
| 1210 | CV_IMPL CvSize |
| 1211 | cvGetSize( const CvArr* arr ) |
| 1212 | { |
| 1213 | CvSize size = { 0, 0 }; |
| 1214 | |
| 1215 | if( CV_IS_MAT_HDR_Z( arr )) |
| 1216 | { |
| 1217 | CvMat *mat = (CvMat*)arr; |
| 1218 | |
| 1219 | size.width = mat->cols; |
| 1220 | size.height = mat->rows; |
| 1221 | } |
| 1222 | else if( CV_IS_IMAGE_HDR( arr )) |
| 1223 | { |
| 1224 | IplImage* img = (IplImage*)arr; |
| 1225 | |
| 1226 | if( img->roi ) |
| 1227 | { |
| 1228 | size.width = img->roi->width; |
| 1229 | size.height = img->roi->height; |
| 1230 | } |
| 1231 | else |
| 1232 | { |
| 1233 | size.width = img->width; |
| 1234 | size.height = img->height; |
| 1235 | } |
| 1236 | } |
| 1237 | else |
| 1238 | CV_Error( CV_StsBadArg, "Array should be CvMat or IplImage" ); |
| 1239 | |
| 1240 | return size; |
| 1241 | } |
| 1242 | |
| 1243 | |
| 1244 | // Selects sub-array (no data is copied) |