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

Function icvReadMatND

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

Source from the content-addressed store, hash-verified

3655
3656
3657static void*
3658icvReadMatND( CvFileStorage* fs, CvFileNode* node )
3659{
3660 void* ptr = 0;
3661 CvMatND* mat;
3662 const char* dt;
3663 CvFileNode* data;
3664 CvFileNode* sizes_node;
3665 int sizes[CV_MAX_DIM], dims, elem_type;
3666 int i, total_size;
3667
3668 sizes_node = cvGetFileNodeByName( fs, node, "sizes" );
3669 dt = cvReadStringByName( fs, node, "dt", 0 );
3670
3671 if( !sizes_node || !dt )
3672 CV_Error( CV_StsError, "Some of essential matrix attributes are absent" );
3673
3674 dims = CV_NODE_IS_SEQ(sizes_node->tag) ? sizes_node->data.seq->total :
3675 CV_NODE_IS_INT(sizes_node->tag) ? 1 : -1;
3676
3677 if( dims <= 0 || dims > CV_MAX_DIM )
3678 CV_Error( CV_StsParseError, "Could not determine the matrix dimensionality" );
3679
3680 cvReadRawData( fs, sizes_node, sizes, "i" );
3681 elem_type = icvDecodeSimpleFormat( dt );
3682
3683 data = cvGetFileNodeByName( fs, node, "data" );
3684 if( !data )
3685 CV_Error( CV_StsError, "The matrix data is not found in file storage" );
3686
3687
3688
3689 for( total_size = CV_MAT_CN(elem_type), i = 0; i < dims; i++ )
3690 total_size *= sizes[i];
3691
3692 int nelems = icvFileNodeSeqLen( data );
3693
3694 if( nelems > 0 && nelems != total_size )
3695 CV_Error( CV_StsUnmatchedSizes,
3696 "The matrix size does not match to the number of stored elements" );
3697
3698 if( nelems > 0 )
3699 {
3700 mat = cvCreateMatND( dims, sizes, elem_type );
3701 cvReadRawData( fs, data, mat->data.ptr, dt );
3702 }
3703 else
3704 mat = cvCreateMatNDHeader( dims, sizes, elem_type );
3705
3706 ptr = mat;
3707 return ptr;
3708}
3709
3710
3711/******************************* CvSparseMat ******************************/

Callers

nothing calls this directly

Calls 7

cvGetFileNodeByNameFunction · 0.85
cvReadStringByNameFunction · 0.85
cvReadRawDataFunction · 0.85
icvDecodeSimpleFormatFunction · 0.85
icvFileNodeSeqLenFunction · 0.85
cvCreateMatNDFunction · 0.85
cvCreateMatNDHeaderFunction · 0.85

Tested by

no test coverage detected