Retrieves essential information about image ROI or CvMat data
| 999 | |
| 1000 | // Retrieves essential information about image ROI or CvMat data |
| 1001 | CV_IMPL void |
| 1002 | cvGetRawData( const CvArr* arr, uchar** data, int* step, CvSize* roi_size ) |
| 1003 | { |
| 1004 | if( CV_IS_MAT( arr )) |
| 1005 | { |
| 1006 | CvMat *mat = (CvMat*)arr; |
| 1007 | |
| 1008 | if( step ) |
| 1009 | *step = mat->step; |
| 1010 | |
| 1011 | if( data ) |
| 1012 | *data = mat->data.ptr; |
| 1013 | |
| 1014 | if( roi_size ) |
| 1015 | *roi_size = cvGetMatSize( mat ); |
| 1016 | } |
| 1017 | else if( CV_IS_IMAGE( arr )) |
| 1018 | { |
| 1019 | IplImage* img = (IplImage*)arr; |
| 1020 | |
| 1021 | if( step ) |
| 1022 | *step = img->widthStep; |
| 1023 | |
| 1024 | if( data ) |
| 1025 | *data = cvPtr2D( img, 0, 0 ); |
| 1026 | |
| 1027 | if( roi_size ) |
| 1028 | { |
| 1029 | if( img->roi ) |
| 1030 | { |
| 1031 | *roi_size = cvSize( img->roi->width, img->roi->height ); |
| 1032 | } |
| 1033 | else |
| 1034 | { |
| 1035 | *roi_size = cvSize( img->width, img->height ); |
| 1036 | } |
| 1037 | } |
| 1038 | } |
| 1039 | else if( CV_IS_MATND( arr )) |
| 1040 | { |
| 1041 | CvMatND* mat = (CvMatND*)arr; |
| 1042 | |
| 1043 | if( !CV_IS_MAT_CONT( mat->type )) |
| 1044 | CV_Error( CV_StsBadArg, "Only continuous nD arrays are supported here" ); |
| 1045 | |
| 1046 | if( data ) |
| 1047 | *data = mat->data.ptr; |
| 1048 | |
| 1049 | if( roi_size || step ) |
| 1050 | { |
| 1051 | int i, size1 = mat->dim[0].size, size2 = 1; |
| 1052 | |
| 1053 | if( mat->dims > 2 ) |
| 1054 | for( i = 1; i < mat->dims; i++ ) |
| 1055 | size1 *= mat->dim[i].size; |
| 1056 | else |
| 1057 | size2 = mat->dim[1].size; |
| 1058 |
nothing calls this directly
no test coverage detected