Returns specifed element of 2D array
| 1943 | |
| 1944 | // Returns specifed element of 2D array |
| 1945 | CV_IMPL CvScalar |
| 1946 | cvGet2D( const CvArr* arr, int y, int x ) |
| 1947 | { |
| 1948 | CvScalar scalar = {{0,0,0,0}}; |
| 1949 | int type = 0; |
| 1950 | uchar* ptr; |
| 1951 | |
| 1952 | if( CV_IS_MAT( arr )) |
| 1953 | { |
| 1954 | CvMat* mat = (CvMat*)arr; |
| 1955 | |
| 1956 | if( (unsigned)y >= (unsigned)(mat->rows) || |
| 1957 | (unsigned)x >= (unsigned)(mat->cols) ) |
| 1958 | CV_Error( CV_StsOutOfRange, "index is out of range" ); |
| 1959 | |
| 1960 | type = CV_MAT_TYPE(mat->type); |
| 1961 | ptr = mat->data.ptr + (size_t)y*mat->step + x*CV_ELEM_SIZE(type); |
| 1962 | } |
| 1963 | else if( !CV_IS_SPARSE_MAT( arr )) |
| 1964 | ptr = cvPtr2D( arr, y, x, &type ); |
| 1965 | else |
| 1966 | { |
| 1967 | int idx[] = { y, x }; |
| 1968 | ptr = icvGetNodePtr( (CvSparseMat*)arr, idx, &type, 0, 0 ); |
| 1969 | } |
| 1970 | |
| 1971 | if( ptr ) |
| 1972 | cvRawDataToScalar( ptr, type, &scalar ); |
| 1973 | |
| 1974 | return scalar; |
| 1975 | } |
| 1976 | |
| 1977 | |
| 1978 | // Returns specifed element of 3D array |
nothing calls this directly
no test coverage detected