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

Function cvGetSubRect

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

Selects sub-array (no data is copied)

Source from the content-addressed store, hash-verified

1243
1244// Selects sub-array (no data is copied)
1245CV_IMPL CvMat*
1246cvGetSubRect( const CvArr* arr, CvMat* submat, CvRect rect )
1247{
1248 CvMat* res = 0;
1249 CvMat stub, *mat = (CvMat*)arr;
1250
1251 if( !CV_IS_MAT( mat ))
1252 mat = cvGetMat( mat, &stub );
1253
1254 if( !submat )
1255 CV_Error( CV_StsNullPtr, "" );
1256
1257 if( (rect.x|rect.y|rect.width|rect.height) < 0 )
1258 CV_Error( CV_StsBadSize, "" );
1259
1260 if( rect.x + rect.width > mat->cols ||
1261 rect.y + rect.height > mat->rows )
1262 CV_Error( CV_StsBadSize, "" );
1263
1264 {
1265 /*
1266 int* refcount = mat->refcount;
1267
1268 if( refcount )
1269 ++*refcount;
1270
1271 cvDecRefData( submat );
1272 */
1273 submat->data.ptr = mat->data.ptr + (size_t)rect.y*mat->step +
1274 rect.x*CV_ELEM_SIZE(mat->type);
1275 submat->step = mat->step;
1276 submat->type = (mat->type & (rect.width < mat->cols ? ~CV_MAT_CONT_FLAG : -1)) |
1277 (rect.height <= 1 ? CV_MAT_CONT_FLAG : 0);
1278 submat->rows = rect.height;
1279 submat->cols = rect.width;
1280 submat->refcount = 0;
1281 res = submat;
1282 }
1283
1284 return res;
1285}
1286
1287
1288// Selects array's row span.

Callers

nothing calls this directly

Calls 1

cvGetMatFunction · 0.85

Tested by

no test coverage detected