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

Function icvReadMat

deps/opencv/modules/core/src/persistence.cpp:3573–3612  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3571
3572
3573static void*
3574icvReadMat( CvFileStorage* fs, CvFileNode* node )
3575{
3576 void* ptr = 0;
3577 CvMat* mat;
3578 const char* dt;
3579 CvFileNode* data;
3580 int rows, cols, elem_type;
3581
3582 rows = cvReadIntByName( fs, node, "rows", -1 );
3583 cols = cvReadIntByName( fs, node, "cols", -1 );
3584 dt = cvReadStringByName( fs, node, "dt", 0 );
3585
3586 if( rows < 0 || cols < 0 || !dt )
3587 CV_Error( CV_StsError, "Some of essential matrix attributes are absent" );
3588
3589 elem_type = icvDecodeSimpleFormat( dt );
3590
3591 data = cvGetFileNodeByName( fs, node, "data" );
3592 if( !data )
3593 CV_Error( CV_StsError, "The matrix data is not found in file storage" );
3594
3595 int nelems = icvFileNodeSeqLen( data );
3596 if( nelems > 0 && nelems != rows*cols*CV_MAT_CN(elem_type) )
3597 CV_Error( CV_StsUnmatchedSizes,
3598 "The matrix size does not match to the number of stored elements" );
3599
3600 if( nelems > 0 )
3601 {
3602 mat = cvCreateMat( rows, cols, elem_type );
3603 cvReadRawData( fs, data, mat->data.ptr, dt );
3604 }
3605 else if( rows == 0 && cols == 0 )
3606 mat = cvCreateMatHeader( 0, 1, elem_type );
3607 else
3608 mat = cvCreateMatHeader( rows, cols, elem_type );
3609
3610 ptr = mat;
3611 return ptr;
3612}
3613
3614
3615/******************************* CvMatND ******************************/

Callers

nothing calls this directly

Calls 8

cvReadIntByNameFunction · 0.85
cvReadStringByNameFunction · 0.85
icvDecodeSimpleFormatFunction · 0.85
cvGetFileNodeByNameFunction · 0.85
icvFileNodeSeqLenFunction · 0.85
cvCreateMatFunction · 0.85
cvReadRawDataFunction · 0.85
cvCreateMatHeaderFunction · 0.85

Tested by

no test coverage detected