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

Function cvGetMat

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

convert array (CvMat or IplImage) to CvMat

Source from the content-addressed store, hash-verified

2371
2372// convert array (CvMat or IplImage) to CvMat
2373CV_IMPL CvMat*
2374cvGetMat( const CvArr* array, CvMat* mat,
2375 int* pCOI, int allowND )
2376{
2377 CvMat* result = 0;
2378 CvMat* src = (CvMat*)array;
2379 int coi = 0;
2380
2381 if( !mat || !src )
2382 CV_Error( CV_StsNullPtr, "NULL array pointer is passed" );
2383
2384 if( CV_IS_MAT_HDR(src))
2385 {
2386 if( !src->data.ptr )
2387 CV_Error( CV_StsNullPtr, "The matrix has NULL data pointer" );
2388
2389 result = (CvMat*)src;
2390 }
2391 else if( CV_IS_IMAGE_HDR(src) )
2392 {
2393 const IplImage* img = (const IplImage*)src;
2394 int depth, order;
2395
2396 if( img->imageData == 0 )
2397 CV_Error( CV_StsNullPtr, "The image has NULL data pointer" );
2398
2399 depth = IPL2CV_DEPTH( img->depth );
2400 if( depth < 0 )
2401 CV_Error( CV_BadDepth, "" );
2402
2403 order = img->dataOrder & (img->nChannels > 1 ? -1 : 0);
2404
2405 if( img->roi )
2406 {
2407 if( order == IPL_DATA_ORDER_PLANE )
2408 {
2409 int type = depth;
2410
2411 if( img->roi->coi == 0 )
2412 CV_Error( CV_StsBadFlag,
2413 "Images with planar data layout should be used with COI selected" );
2414
2415 cvInitMatHeader( mat, img->roi->height,
2416 img->roi->width, type,
2417 img->imageData + (img->roi->coi-1)*img->imageSize +
2418 img->roi->yOffset*img->widthStep +
2419 img->roi->xOffset*CV_ELEM_SIZE(type),
2420 img->widthStep );
2421 }
2422 else /* pixel order */
2423 {
2424 int type = CV_MAKETYPE( depth, img->nChannels );
2425 coi = img->roi->coi;
2426
2427 if( img->nChannels > CV_CN_MAX )
2428 CV_Error( CV_BadNumChannels,
2429 "The image is interleaved and has over CV_CN_MAX channels" );
2430

Callers 15

cvRangeFunction · 0.85
cvGetMatNDFunction · 0.85
cvGetSubRectFunction · 0.85
cvGetRowsFunction · 0.85
cvGetColsFunction · 0.85
cvGetDiagFunction · 0.85
cvReshapeMatNDFunction · 0.85
cvReshapeFunction · 0.85
cvThreshHistFunction · 0.85
cvNormalizeHistFunction · 0.85
cvGetMinMaxHistValueFunction · 0.85

Calls 2

cvInitMatHeaderFunction · 0.85
icvCheckHugeFunction · 0.85

Tested by

no test coverage detected