fixed test crashes after CV_CN_MAX increase.

pull/13383/head
Vadim Pisarevsky 15 years ago
parent bce9f54152
commit 6e6559d207
  1. 21
      modules/core/include/opencv2/core/types_c.h
  2. 93
      modules/core/src/persistence.cpp
  3. 2
      tests/cv/src/bcameracalibration.cpp

@ -518,7 +518,7 @@ IplConvKernelFP;
* Matrix type (CvMat) *
\****************************************************************************************/
#define CV_CN_MAX 1024
#define CV_CN_MAX 512
#define CV_CN_SHIFT 3
#define CV_DEPTH_MAX (1 << CV_CN_SHIFT)
@ -1428,7 +1428,7 @@ typedef CvContour CvPoint2DSeq;
#define CV_IS_SET(set) \
((set) != NULL && (((CvSeq*)(set))->flags & CV_MAGIC_MASK) == CV_SET_MAGIC_VAL)
#define CV_SEQ_ELTYPE_BITS 9
#define CV_SEQ_ELTYPE_BITS 12
#define CV_SEQ_ELTYPE_MASK ((1 << CV_SEQ_ELTYPE_BITS) - 1)
#define CV_SEQ_ELTYPE_POINT CV_32SC2 /* (x,y) */
@ -1443,7 +1443,7 @@ typedef CvContour CvPoint2DSeq;
#define CV_SEQ_ELTYPE_CONNECTED_COMP 0 /* connected component */
#define CV_SEQ_ELTYPE_POINT3D CV_32FC3 /* (x,y,z) */
#define CV_SEQ_KIND_BITS 3
#define CV_SEQ_KIND_BITS 2
#define CV_SEQ_KIND_MASK (((1 << CV_SEQ_KIND_BITS) - 1)<<CV_SEQ_ELTYPE_BITS)
/* types of sequences */
@ -1452,16 +1452,16 @@ typedef CvContour CvPoint2DSeq;
#define CV_SEQ_KIND_BIN_TREE (2 << CV_SEQ_ELTYPE_BITS)
/* types of sparse sequences (sets) */
#define CV_SEQ_KIND_GRAPH (3 << CV_SEQ_ELTYPE_BITS)
#define CV_SEQ_KIND_SUBDIV2D (4 << CV_SEQ_ELTYPE_BITS)
#define CV_SEQ_KIND_GRAPH (1 << CV_SEQ_ELTYPE_BITS)
#define CV_SEQ_KIND_SUBDIV2D (2 << CV_SEQ_ELTYPE_BITS)
#define CV_SEQ_FLAG_SHIFT (CV_SEQ_KIND_BITS + CV_SEQ_ELTYPE_BITS)
/* flags for curves */
#define CV_SEQ_FLAG_CLOSED (1 << CV_SEQ_FLAG_SHIFT)
#define CV_SEQ_FLAG_SIMPLE (2 << CV_SEQ_FLAG_SHIFT)
#define CV_SEQ_FLAG_CONVEX (4 << CV_SEQ_FLAG_SHIFT)
#define CV_SEQ_FLAG_HOLE (8 << CV_SEQ_FLAG_SHIFT)
#define CV_SEQ_FLAG_SIMPLE (0 << CV_SEQ_FLAG_SHIFT)
#define CV_SEQ_FLAG_CONVEX (0 << CV_SEQ_FLAG_SHIFT)
#define CV_SEQ_FLAG_HOLE (2 << CV_SEQ_FLAG_SHIFT)
/* flags for graphs */
#define CV_GRAPH_FLAG_ORIENTED (1 << CV_SEQ_FLAG_SHIFT)
@ -1499,10 +1499,9 @@ typedef CvContour CvPoint2DSeq;
#define CV_IS_SEQ_CURVE( seq ) (CV_SEQ_KIND(seq) == CV_SEQ_KIND_CURVE)
#define CV_IS_SEQ_CLOSED( seq ) (((seq)->flags & CV_SEQ_FLAG_CLOSED) != 0)
#define CV_IS_SEQ_CONVEX( seq ) (((seq)->flags & CV_SEQ_FLAG_CONVEX) != 0)
#define CV_IS_SEQ_CONVEX( seq ) 0
#define CV_IS_SEQ_HOLE( seq ) (((seq)->flags & CV_SEQ_FLAG_HOLE) != 0)
#define CV_IS_SEQ_SIMPLE( seq ) ((((seq)->flags & CV_SEQ_FLAG_SIMPLE) != 0) || \
CV_IS_SEQ_CONVEX(seq))
#define CV_IS_SEQ_SIMPLE( seq ) 1
/* type checking macros */
#define CV_IS_SEQ_POINT_SET( seq ) \

@ -3937,10 +3937,22 @@ icvWriteSeq( CvFileStorage* fs, const char* name,
if( level >= 0 )
cvWriteInt( fs, "level", level );
sprintf( buf, "%08x", seq->flags );
cvWriteString( fs, "flags", buf, 1 );
cvWriteInt( fs, "count", seq->total );
dt = icvGetFormat( seq, "dt", &attr, 0, dt_buf );
strcpy(buf, "");
if( CV_IS_SEQ_CLOSED(seq) )
strcat(buf, " closed");
if( CV_IS_SEQ_HOLE(seq) )
strcat(buf, " hole");
if( CV_IS_SEQ_CURVE(seq) )
strcat(buf, " curve");
if( CV_SEQ_ELTYPE(seq) == 0 && seq->elem_size != 1 )
strcat(buf, " untyped");
cvWriteString( fs, "flags", buf + (buf[0] ? 1 : 0), 1 );
cvWriteInt( fs, "count", seq->total );
cvWriteString( fs, "dt", dt, 0 );
icvWriteHeaderData( fs, seq, &attr, sizeof(CvSeq) );
@ -4021,9 +4033,49 @@ icvReadSeq( CvFileStorage* fs, CvFileNode* node )
if( !flags_str || total == -1 || !dt )
CV_Error( CV_StsError, "Some of essential sequence attributes are absent" );
flags = (int)strtol( flags_str, &endptr, 16 );
if( endptr == flags_str || (flags & CV_MAGIC_MASK) != CV_SEQ_MAGIC_VAL )
CV_Error( CV_StsError, "The sequence flags are invalid" );
flags = CV_SEQ_MAGIC_VAL;
if( isdigit(flags_str[0]) )
{
const int OLD_SEQ_ELTYPE_BITS = 9;
const int OLD_SEQ_ELTYPE_MASK = (1 << OLD_SEQ_ELTYPE_BITS) - 1;
const int OLD_SEQ_KIND_BITS = 3;
const int OLD_SEQ_KIND_MASK = ((1 << OLD_SEQ_KIND_BITS) - 1) << OLD_SEQ_ELTYPE_BITS;
const int OLD_SEQ_KIND_CURVE = 1 << OLD_SEQ_ELTYPE_BITS;
const int OLD_SEQ_FLAG_SHIFT = OLD_SEQ_KIND_BITS + OLD_SEQ_ELTYPE_BITS;
const int OLD_SEQ_FLAG_CLOSED = 1 << OLD_SEQ_FLAG_SHIFT;
const int OLD_SEQ_FLAG_HOLE = 8 << OLD_SEQ_FLAG_SHIFT;
int flags0 = (int)strtol( flags_str, &endptr, 16 );
if( endptr == flags_str || (flags0 & CV_MAGIC_MASK) != CV_SEQ_MAGIC_VAL )
CV_Error( CV_StsError, "The sequence flags are invalid" );
if( (flags0 & OLD_SEQ_KIND_MASK) == OLD_SEQ_KIND_CURVE )
flags |= CV_SEQ_KIND_CURVE;
if( flags0 & OLD_SEQ_FLAG_CLOSED )
flags |= CV_SEQ_FLAG_CLOSED;
if( flags0 & OLD_SEQ_FLAG_HOLE )
flags |= CV_SEQ_FLAG_HOLE;
flags |= flags0 & OLD_SEQ_ELTYPE_MASK;
}
else
{
if( strstr(flags_str, "curve") )
flags |= CV_SEQ_KIND_CURVE;
if( strstr(flags_str, "closed") )
flags |= CV_SEQ_FLAG_CLOSED;
if( strstr(flags_str, "hole") )
flags |= CV_SEQ_FLAG_HOLE;
if( !strstr(flags_str, "untyped") )
{
try
{
flags |= icvDecodeSimpleFormat(dt);
}
catch(...)
{
}
}
}
header_dt = cvReadStringByName( fs, node, "header_dt", 0 );
header_node = cvGetFileNodeByName( fs, node, "header_user_data" );
@ -4217,8 +4269,7 @@ icvWriteGraph( CvFileStorage* fs, const char* name,
// write header
cvStartWriteStruct( fs, name, CV_NODE_MAP, CV_TYPE_NAME_GRAPH );
sprintf( buf, "%08x", graph->flags );
cvWriteString( fs, "flags", buf, 1 );
cvWriteString(fs, "flags", CV_IS_GRAPH_ORIENTED(graph) ? "oriented" : "", 1);
cvWriteInt( fs, "vertex_count", vtx_count );
vtx_dt = icvGetFormat( (CvSeq*)graph, "vertex_dt",
@ -4349,12 +4400,28 @@ icvReadGraph( CvFileStorage* fs, CvFileNode* node )
edge_count = cvReadIntByName( fs, node, "edge_count", -1 );
if( !flags_str || vtx_count == -1 || edge_count == -1 || !edge_dt )
CV_Error( CV_StsError, "Some of essential sequence attributes are absent" );
CV_Error( CV_StsError, "Some of essential graph attributes are absent" );
flags = CV_SET_MAGIC_VAL + CV_GRAPH;
flags = (int)strtol( flags_str, &endptr, 16 );
if( endptr == flags_str ||
(flags & (CV_SEQ_KIND_MASK|CV_MAGIC_MASK)) != (CV_GRAPH|CV_SET_MAGIC_VAL))
CV_Error( CV_StsError, "Invalid graph signature" );
if( isxdigit(flags_str[0]) )
{
const int OLD_SEQ_ELTYPE_BITS = 9;
const int OLD_SEQ_KIND_BITS = 3;
const int OLD_SEQ_FLAG_SHIFT = OLD_SEQ_KIND_BITS + OLD_SEQ_ELTYPE_BITS;
const int OLD_GRAPH_FLAG_ORIENTED = 1 << OLD_SEQ_FLAG_SHIFT;
int flags0 = (int)strtol( flags_str, &endptr, 16 );
if( endptr == flags_str || (flags0 & CV_MAGIC_MASK) != CV_SET_MAGIC_VAL )
CV_Error( CV_StsError, "The sequence flags are invalid" );
if( flags0 & OLD_GRAPH_FLAG_ORIENTED )
flags |= CV_GRAPH_FLAG_ORIENTED;
}
else
{
if( strstr(flags_str, "oriented") )
flags |= CV_GRAPH_FLAG_ORIENTED;
}
header_dt = cvReadStringByName( fs, node, "header_dt", 0 );
header_node = cvGetFileNodeByName( fs, node, "header_user_data" );

@ -330,7 +330,7 @@ void CV_CameraCalibrationBadArgTest::run( int /* start_from */ )
//}
}
//CV_CameraCalibrationBadArgTest camera_calibration_bad_arg_test;
CV_CameraCalibrationBadArgTest camera_calibration_bad_arg_test;
class CV_Rodrigues2BadArgTest : public CvBadArgTest

Loading…
Cancel
Save