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

Function cvSet1D

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

Assigns new value to specifed element of nD array given linear index

Source from the content-addressed store, hash-verified

2150
2151// Assigns new value to specifed element of nD array given linear index
2152CV_IMPL void
2153cvSet1D( CvArr* arr, int idx, CvScalar scalar )
2154{
2155 int type = 0;
2156 uchar* ptr;
2157
2158 if( CV_IS_MAT( arr ) && CV_IS_MAT_CONT( ((CvMat*)arr)->type ))
2159 {
2160 CvMat* mat = (CvMat*)arr;
2161
2162 type = CV_MAT_TYPE(mat->type);
2163 int pix_size = CV_ELEM_SIZE(type);
2164
2165 // the first part is mul-free sufficient check
2166 // that the index is within the matrix
2167 if( (unsigned)idx >= (unsigned)(mat->rows + mat->cols - 1) &&
2168 (unsigned)idx >= (unsigned)(mat->rows*mat->cols))
2169 CV_Error( CV_StsOutOfRange, "index is out of range" );
2170
2171 ptr = mat->data.ptr + (size_t)idx*pix_size;
2172 }
2173 else if( !CV_IS_SPARSE_MAT( arr ) || ((CvSparseMat*)arr)->dims > 1 )
2174 ptr = cvPtr1D( arr, idx, &type );
2175 else
2176 ptr = icvGetNodePtr( (CvSparseMat*)arr, &idx, &type, -1, 0 );
2177
2178 cvScalarToRawData( &scalar, ptr, type );
2179}
2180
2181
2182// Assigns new value to specifed element of 2D array

Callers

nothing calls this directly

Calls 3

cvPtr1DFunction · 0.85
icvGetNodePtrFunction · 0.85
cvScalarToRawDataFunction · 0.85

Tested by

no test coverage detected