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

Function cvLoad

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

Source from the content-addressed store, hash-verified

5061}
5062
5063CV_IMPL void*
5064cvLoad( const char* filename, CvMemStorage* memstorage,
5065 const char* name, const char** _real_name )
5066{
5067 void* ptr = 0;
5068 const char* real_name = 0;
5069 cv::FileStorage fs(cvOpenFileStorage(filename, memstorage, CV_STORAGE_READ));
5070
5071 CvFileNode* node = 0;
5072
5073 if( !fs.isOpened() )
5074 return 0;
5075
5076 if( name )
5077 {
5078 node = cvGetFileNodeByName( *fs, 0, name );
5079 }
5080 else
5081 {
5082 int i, k;
5083 for( k = 0; k < (*fs)->roots->total; k++ )
5084 {
5085 CvSeq* seq;
5086 CvSeqReader reader;
5087
5088 node = (CvFileNode*)cvGetSeqElem( (*fs)->roots, k );
5089 if( !CV_NODE_IS_MAP( node->tag ))
5090 return 0;
5091 seq = node->data.seq;
5092 node = 0;
5093
5094 cvStartReadSeq( seq, &reader, 0 );
5095
5096 // find the first element in the map
5097 for( i = 0; i < seq->total; i++ )
5098 {
5099 if( CV_IS_SET_ELEM( reader.ptr ))
5100 {
5101 node = (CvFileNode*)reader.ptr;
5102 goto stop_search;
5103 }
5104 CV_NEXT_SEQ_ELEM( seq->elem_size, reader );
5105 }
5106 }
5107
5108stop_search:
5109 ;
5110 }
5111
5112 if( !node )
5113 CV_Error( CV_StsObjectNotFound, "Could not find the/an object in file storage" );
5114
5115 real_name = cvGetFileNodeName( node );
5116 ptr = cvRead( *fs, node, 0 );
5117
5118 // sanity check
5119 if( !memstorage && (CV_IS_SEQ( ptr ) || CV_IS_SET( ptr )) )
5120 CV_Error( CV_StsNullPtr,

Callers

nothing calls this directly

Calls 9

cvGetFileNodeByNameFunction · 0.85
cvGetSeqElemFunction · 0.85
cvStartReadSeqFunction · 0.85
cvGetFileNodeNameFunction · 0.85
cvReadFunction · 0.85
cvGetErrStatusFunction · 0.85
cvReleaseFunction · 0.85
cvAllocFunction · 0.85
isOpenedMethod · 0.80

Tested by

no test coverage detected