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

Function cvGet2D

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

Returns specifed element of 2D array

Source from the content-addressed store, hash-verified

1943
1944// Returns specifed element of 2D array
1945CV_IMPL CvScalar
1946cvGet2D( 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

Callers

nothing calls this directly

Calls 3

cvPtr2DFunction · 0.85
icvGetNodePtrFunction · 0.85
cvRawDataToScalarFunction · 0.85

Tested by

no test coverage detected