MCPcopy Create free account
hub / github.com/creatale/node-dv / cvGetReal2D

Function cvGetReal2D

deps/opencv/modules/core/src/array.cpp:2060–2095  ·  view source on GitHub ↗

Returns specifed element of 2D array

Source from the content-addressed store, hash-verified

2058
2059// Returns specifed element of 2D array
2060CV_IMPL double
2061cvGetReal2D( const CvArr* arr, int y, int x )
2062{
2063 double value = 0;
2064 int type = 0;
2065 uchar* ptr;
2066
2067 if( CV_IS_MAT( arr ))
2068 {
2069 CvMat* mat = (CvMat*)arr;
2070
2071 if( (unsigned)y >= (unsigned)(mat->rows) ||
2072 (unsigned)x >= (unsigned)(mat->cols) )
2073 CV_Error( CV_StsOutOfRange, "index is out of range" );
2074
2075 type = CV_MAT_TYPE(mat->type);
2076 ptr = mat->data.ptr + (size_t)y*mat->step + x*CV_ELEM_SIZE(type);
2077 }
2078 else if( !CV_IS_SPARSE_MAT( arr ))
2079 ptr = cvPtr2D( arr, y, x, &type );
2080 else
2081 {
2082 int idx[] = { y, x };
2083 ptr = icvGetNodePtr( (CvSparseMat*)arr, idx, &type, 0, 0 );
2084 }
2085
2086 if( ptr )
2087 {
2088 if( CV_MAT_CN( type ) > 1 )
2089 CV_Error( CV_BadNumChannels, "cvGetReal* support only single-channel arrays" );
2090
2091 value = icvGetReal( ptr, type );
2092 }
2093
2094 return value;
2095}
2096
2097
2098// Returns specifed element of 3D array

Callers

nothing calls this directly

Calls 3

cvPtr2DFunction · 0.85
icvGetNodePtrFunction · 0.85
icvGetRealFunction · 0.85

Tested by

no test coverage detected