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

Function icvGetFormat

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

Source from the content-addressed store, hash-verified

4102
4103
4104static char*
4105icvGetFormat( const CvSeq* seq, const char* dt_key, CvAttrList* attr,
4106 int initial_elem_size, char* dt_buf )
4107{
4108 char* dt = 0;
4109 dt = (char*)cvAttrValue( attr, dt_key );
4110
4111 if( dt )
4112 {
4113 int dt_elem_size;
4114 dt_elem_size = icvCalcElemSize( dt, initial_elem_size );
4115 if( dt_elem_size != seq->elem_size )
4116 CV_Error( CV_StsUnmatchedSizes,
4117 "The size of element calculated from \"dt\" and "
4118 "the elem_size do not match" );
4119 }
4120 else if( CV_MAT_TYPE(seq->flags) != 0 || seq->elem_size == 1 )
4121 {
4122 if( CV_ELEM_SIZE(seq->flags) != seq->elem_size )
4123 CV_Error( CV_StsUnmatchedSizes,
4124 "Size of sequence element (elem_size) is inconsistent with seq->flags" );
4125 dt = icvEncodeFormat( CV_MAT_TYPE(seq->flags), dt_buf );
4126 }
4127 else if( seq->elem_size > initial_elem_size )
4128 {
4129 unsigned extra_elem_size = seq->elem_size - initial_elem_size;
4130 // a heuristic to provide nice defaults for sequences of int's & float's
4131 if( extra_elem_size % sizeof(int) == 0 )
4132 sprintf( dt_buf, "%ui", (unsigned)(extra_elem_size/sizeof(int)) );
4133 else
4134 sprintf( dt_buf, "%uu", extra_elem_size );
4135 dt = dt_buf;
4136 }
4137
4138 return dt;
4139}
4140
4141
4142static void

Callers 2

icvWriteSeqFunction · 0.85
icvWriteGraphFunction · 0.85

Calls 3

cvAttrValueFunction · 0.85
icvCalcElemSizeFunction · 0.85
icvEncodeFormatFunction · 0.85

Tested by

no test coverage detected