int main(int argc, const char * argv[]) {
    CvMat *cmatrix = cvCreateMat(5,5,CV_32FC1);
    float element_3_2 = 7.7;
    *((float*)CV_MAT_ELEM_PTR( *cmatrix, 3,2) ) = element_3_2;
    cvmSet(cmatrix,4,4,0.5000);
    cvSetReal2D(cmatrix,3,3,0.5000);
    
    CvFileStorage* fs1 = cvOpenFileStorage("cfg.xml", 0, CV_STORAGE_WRITE);
    cvWriteInt( fs1, "frame_count", 10 );
    cvStartWriteStruct( fs1, "frame_size", CV_NODE_SEQ );
    cvWriteInt( fs1 , 0, 320 );
    cvWriteInt( fs1 , 0, 200 );
    cvEndWriteStruct( fs1 );
    cvWrite( fs1, "color_cvt_matrix", cmatrix );
    cvReleaseFileStorage( &fs1 );
    
    CvFileStorage* fs2 = cvOpenFileStorage("cfg.xml", 0, CV_STORAGE_READ);
    int frame_count = cvReadIntByName( fs2 , 0, "frame_count");
    CvSeq* s = cvGetFileNodeByName( fs2,0,"frame_size" )->data.seq;
    int frame_width = cvReadInt( (CvFileNode*)cvGetSeqElem(s,0) );
    int frame_height = cvReadInt( (CvFileNode*)cvGetSeqElem(s,1) );
    CvMat* color_cvt_matrix = (CvMat*) cvReadByName( fs2, 0 , "color_cvt_matrix");
    
    printf("color_cvt_matrix: width=%d, height=%d\n",color_cvt_matrix->width, color_cvt_matrix->height );
    printf("frame_count=%d, frame_width=%d, frame_height=%d\n",frame_count,frame_width,frame_height);
    
    cvReleaseFileStorage( &fs2 );
    
    return 0;
}
void CvArrTest::get_timing_test_array_types_and_sizes( int /*test_case_idx*/, CvSize** sizes, int** types,
                                                       CvSize** whole_sizes, bool *are_images )
{
    const CvFileNode* size_node = find_timing_param( "size" );
    const CvFileNode* depth_node = find_timing_param( "depth" );
    const CvFileNode* channels_node = find_timing_param( "channels" );
    int i, j;
    int depth = 0, channels = 1;
    CvSize size = {1,1}, whole_size = size;

    if( size_node && CV_NODE_IS_SEQ(size_node->tag) )
    {
        CvSeq* seq = size_node->data.seq;
        size.width = cvReadInt((const CvFileNode*)cvGetSeqElem(seq,0), 1);
        size.height = cvReadInt((const CvFileNode*)cvGetSeqElem(seq,1), 1);
        whole_size = size;
        if( seq->total > 2 )
        {
            whole_size.width = cvReadInt((const CvFileNode*)cvGetSeqElem(seq,2), 1);
            whole_size.height = cvReadInt((const CvFileNode*)cvGetSeqElem(seq,3), 1);
            whole_size.width = MAX( whole_size.width, size.width );
            whole_size.height = MAX( whole_size.height, size.height );
        }
    }

    if( depth_node && CV_NODE_IS_STRING(depth_node->tag) )
    {
        depth = cvTsTypeByName( depth_node->data.str.ptr );
        if( depth < 0 || depth > CV_64F )
            depth = 0;
    }

    if( channels_node && CV_NODE_IS_INT(channels_node->tag) )
    {
        channels = cvReadInt( channels_node, 1 );
        if( channels < 0 || channels > CV_CN_MAX )
            channels = 1;
    }

    for( i = 0; i < max_arr; i++ )
    {
        int count = test_array[i].size();
        for( j = 0; j < count; j++ )
        {
            sizes[i][j] = size;
            whole_sizes[i][j] = whole_size;
            if( i != MASK )
                types[i][j] = CV_MAKETYPE(depth,channels);
            else
                types[i][j] = CV_8UC1;
            if( i == REF_OUTPUT || i == REF_INPUT_OUTPUT )
                sizes[i][j] = cvSize(0,0);
        }
    }

    if( are_images )
        *are_images = false; // by default CvMat is used in performance tests
}
void CV_MHIBaseTest::get_timing_test_array_types_and_sizes( int test_case_idx,
            CvSize** sizes, int** types, CvSize** whole_sizes, bool *are_images )
{
    CvArrTest::get_timing_test_array_types_and_sizes( test_case_idx, sizes, types,
                                                      whole_sizes, are_images );
    types[INPUT][0] = CV_8UC1;
    types[mhi_i][0] = CV_32FC1;
    duration = cvReadInt( find_timing_param( "duration" ), 500 );
    silh_ratio = cvReadInt( find_timing_param( "silh_ratio" ), 25 )*0.01;
    timestamp = duration;
}
Beispiel #4
0
int ArrayTest::read_params( CvFileStorage* fs )
{
    int code = BaseTest::read_params( fs );
    if( code < 0 )
        return code;

    min_log_array_size = cvReadInt( find_param( fs, "min_log_array_size" ), min_log_array_size );
    max_log_array_size = cvReadInt( find_param( fs, "max_log_array_size" ), max_log_array_size );
    test_case_count = cvReadInt( find_param( fs, "test_case_count" ), test_case_count );
    test_case_count = cvRound( test_case_count*ts->get_test_case_count_scale() );

    min_log_array_size = clipInt( min_log_array_size, 0, 20 );
    max_log_array_size = clipInt( max_log_array_size, min_log_array_size, 20 );
    test_case_count = clipInt( test_case_count, 0, 100000 );

    return code;
}
Beispiel #5
0
int CV_BaseHistTest::read_params( CvFileStorage* fs )
{
    int code = CvTest::read_params( fs );
    if( code < 0 )
        return code;

    test_case_count = cvReadInt( find_param( fs, "struct_count" ), test_case_count );
    max_log_size = cvReadInt( find_param( fs, "max_log_size" ), max_log_size );
    max_log_size = cvTsClipInt( max_log_size, 1, 20 );
    img_max_log_size = cvReadInt( find_param( fs, "max_log_array_size" ), img_max_log_size );
    img_max_log_size = cvTsClipInt( img_max_log_size, 1, 9 );
    
    max_cdims = cvReadInt( find_param( fs, "max_cdims" ), max_cdims );
    max_cdims = cvTsClipInt( max_cdims, 1, 6 );

    return 0;
}
Beispiel #6
0
void CvGBTrees::read_params( CvFileStorage* fs, CvFileNode* fnode )
{
    CV_FUNCNAME( "CvGBTrees::read_params" );
    __BEGIN__;


    CvFileNode* temp;

    if( !fnode || !CV_NODE_IS_MAP(fnode->tag) )
        return;

    data = new CvDTreeTrainData();
    CV_CALL( data->read_params(fs, fnode));
    data->shared = true;

    params.max_depth = data->params.max_depth;
    params.min_sample_count = data->params.min_sample_count;
    params.max_categories = data->params.max_categories;
    params.priors = data->params.priors;
    params.regression_accuracy = data->params.regression_accuracy;
    params.use_surrogates = data->params.use_surrogates;

    temp = cvGetFileNodeByName( fs, fnode, "loss_function" );
    if( !temp )
        EXIT;

    if( temp && CV_NODE_IS_STRING(temp->tag) )
    {
        const char* loss_function_type_str = cvReadString( temp, "" );
        params.loss_function_type = strcmp( loss_function_type_str, "SquaredLoss" ) == 0 ? SQUARED_LOSS :
                            strcmp( loss_function_type_str, "AbsoluteLoss" ) == 0 ? ABSOLUTE_LOSS :
                            strcmp( loss_function_type_str, "HuberLoss" ) == 0 ? HUBER_LOSS :
                            strcmp( loss_function_type_str, "DevianceLoss" ) == 0 ? DEVIANCE_LOSS : -1;
    }
    else
        params.loss_function_type = cvReadInt( temp, -1 );


    if( params.loss_function_type < SQUARED_LOSS || params.loss_function_type > DEVIANCE_LOSS ||  params.loss_function_type == 2)
        CV_ERROR( CV_StsBadArg, "Unknown loss function" );

    params.weak_count = cvReadIntByName( fs, fnode, "ensemble_length" );
    params.shrinkage = (float)cvReadRealByName( fs, fnode, "shrinkage", 0.1 );
    params.subsample_portion = (float)cvReadRealByName( fs, fnode, "subsample_portion", 1.0 );

    if (data->is_classifier)
    {
        class_labels = (CvMat*)cvReadByName( fs, fnode, "class_labels" );
        if( class_labels && !CV_IS_MAT(class_labels))
            CV_ERROR( CV_StsParseError, "class_labels must stored as a matrix");
    }
    data->is_classifier = 0;

    __END__;
}
int CvArrTest::read_params( CvFileStorage* fs )
{
    int code = CvTest::read_params( fs );
    if( code < 0 )
        return code;

    if( ts->get_testing_mode() == CvTS::CORRECTNESS_CHECK_MODE )
    {
        min_log_array_size = cvReadInt( find_param( fs, "min_log_array_size" ), min_log_array_size );
        max_log_array_size = cvReadInt( find_param( fs, "max_log_array_size" ), max_log_array_size );
        test_case_count = cvReadInt( find_param( fs, "test_case_count" ), test_case_count );
        test_case_count = cvRound( test_case_count*ts->get_test_case_count_scale() );

        min_log_array_size = cvTsClipInt( min_log_array_size, 0, 20 );
        max_log_array_size = cvTsClipInt( max_log_array_size, min_log_array_size, 20 );
        test_case_count = cvTsClipInt( test_case_count, 0, 100000 );
    }

    return code;
}
void CV_MHIGradientTest::get_timing_test_array_types_and_sizes( int test_case_idx,
            CvSize** sizes, int** types, CvSize** whole_sizes, bool *are_images )
{
    CV_MHIBaseTest::get_timing_test_array_types_and_sizes( test_case_idx, sizes, types,
                                                           whole_sizes, are_images );
    types[OUTPUT][0] = CV_8UC1;
    types[OUTPUT][1] = CV_32FC1;
    aperture_size = cvReadInt( find_timing_param( "aperture" ), 3 );
    delta1 = duration*0.02;
    delta2 = duration*0.2;
}
/*!
    \fn CvGaborFeature::val(const char *filename) const
 */
double CvGaborFeature::val(const char *filename) const
{
    double ve;
    CvFileStorage *fs;
    fs = cvOpenFileStorage( filename, NULL, CV_STORAGE_READ );
    if (!fs)
    {
       printf("Error: Can not open %s \n", filename);
       exit(-1);
    }
    char *name;
    name = new char[20];
    extractname(name, filename);
    CvFileNode *node;
    node = cvGetFileNodeByName( fs, 0, name );
    CvFileNode *nodew;
    nodew = cvGetFileNodeByName( fs, node, "width" );
    int width = cvReadInt(nodew);
    CvFileNode *nodeh;
    nodeh = cvGetFileNodeByName( fs, node, "height" );
    int height = cvReadInt(nodeh);

    CvFileNode *nodedata;
    nodedata = cvGetFileNodeByName( fs, node, "data" );
    CvSeq* seq = nodedata->data.seq;
    
    CvSeqReader reader;
    cvStartReadSeq( seq, &reader, 0 );

    int num = (iy-1)*width + ix - 1;
 
    CvFileNode* pt = (CvFileNode*)reader.ptr + num;
    
    ve = pt->data.f;
    delete [] name;
    cvReleaseFileStorage(&fs);
    return ve;
}
/*!
    \fn CvBinGabAdaFeatureSelect::weaknode2tree(CvFileNode *node, CvFileStorage *fs, CvGaborTree *tree)
 */
void CvBinGabAdaFeatureSelect::weaknode2tree(CvFileNode *node, CvFileStorage *fs, CvGaborTree *tree)
{
  CvFileNode *xnode = cvGetFileNodeByName( fs, node, "x");
  CvFileNode *ynode = cvGetFileNodeByName( fs, node, "y");
  CvFileNode *Munode = cvGetFileNodeByName( fs, node, "Mu");
  CvFileNode *Nunode = cvGetFileNodeByName( fs, node, "Nu");
  CvFileNode *anode = cvGetFileNodeByName( fs, node, "alpha");
  CvFileNode *tnode = cvGetFileNodeByName( fs, node, "threshold");
  CvFileNode *pnode = cvGetFileNodeByName( fs, node, "parity");
  int x = cvReadInt( xnode, 0);
  int y = cvReadInt( ynode, 0);
  int Mu = cvReadInt( Munode, 0);
  int Nu = cvReadInt( Nunode, 0);
  double alpha = cvReadReal( anode, 0);
  double threshold = cvReadReal( tnode, 0);
  double parity = cvReadReal( pnode, 0);
  tree->x = x;
  tree->y = y;
  tree->Mu = Mu;
  tree->Nu = Nu;
  tree->alpha = alpha;
  tree->threshold = threshold;
  tree->parity = parity;
}
void KITECH_HSVColorRecognitionComp::GetDataFromDB(const char* database)
{
	char str[256];
	CvFileStorage *fs = cvOpenFileStorage(database, 0, CV_STORAGE_READ);
	int colorCount = cvReadIntByName(fs, 0, "color_count");
	ColorRange colorRange;
	for( int i = 0  ;  i < colorCount  ;  i++ ) {
		sprintf(str, "color%d", i);
		CvSeq *s = cvGetFileNodeByName(fs, 0, str)->data.seq;
		colorRange.name = cvReadString( (CvFileNode*)cvGetSeqElem(s, 0) );
		colorRange.min1 = cvReadInt( (CvFileNode*)cvGetSeqElem(s, 1) );
		colorRange.max1 = cvReadInt( (CvFileNode*)cvGetSeqElem(s, 2) );
		colorRange.min2 = cvReadInt( (CvFileNode*)cvGetSeqElem(s, 3) );
		colorRange.max2 = cvReadInt( (CvFileNode*)cvGetSeqElem(s, 4) );
		colorRange.min3 = cvReadInt( (CvFileNode*)cvGetSeqElem(s, 5) );
		colorRange.max3 = cvReadInt( (CvFileNode*)cvGetSeqElem(s, 6) );
		_colorRange.push_back(colorRange);
//		PrintMessage("INFO:KITECH_HSVColorRecognitionComp::Add color data : %s\n", colorRange.name.c_str());
	}
}
void read_my_struct( CvFileStorage* fs, CvFileNode* ms_node, my_struct* ms) {

    ms->i = cvReadIntByName(
      fs,
      NULL,       // search a top-level node
      "integer",  // node name
      456         // default value
    );

    CvSeq *s;

    s = cvGetFileNodeByName(fs, 0, "point")->data.seq;
    ms->point.x = cvReadInt( (CvFileNode *)cvGetSeqElem(s, 0) );
    ms->point.y = cvReadInt( (CvFileNode *)cvGetSeqElem(s, 1) );
    
    s = cvGetFileNodeByName(fs, 0, "rectangle")->data.seq;
    ms->rect.x = cvReadInt( (CvFileNode *)cvGetSeqElem(s, 0) );
    ms->rect.y = cvReadInt( (CvFileNode *)cvGetSeqElem(s, 1) );
    ms->rect.width = cvReadInt( (CvFileNode *)cvGetSeqElem(s, 2) );
    ms->rect.height = cvReadInt( (CvFileNode *)cvGetSeqElem(s, 3) );

}
int CvArrTest::prepare_test_case( int test_case_idx )
{
    int code = 1;
    CvSize** sizes = (CvSize**)malloc( max_arr*sizeof(sizes[0]) );
    CvSize** whole_sizes = (CvSize**)malloc( max_arr*sizeof(whole_sizes[0]) );
    int** types = (int**)malloc( max_arr*sizeof(types[0]) );
    int i, j, total = 0;
    CvRNG* rng = ts->get_rng();
    bool is_image = false;
    bool is_timing_test = false;

    CV_FUNCNAME( "CvArrTest::prepare_test_case" );

    __BEGIN__;

    is_timing_test = ts->get_testing_mode() == CvTS::TIMING_MODE;

    if( is_timing_test )
    {
        if( !get_next_timing_param_tuple() )
        {
            code = -1;
            EXIT;
        }
    }

    for( i = 0; i < max_arr; i++ )
    {
        int count = test_array[i].size();
        count = MAX(count, 1);
        sizes[i] = (CvSize*)malloc( count*sizeof(sizes[i][0]) );
        types[i] = (int*)malloc( count*sizeof(types[i][0]) );
        whole_sizes[i] = (CvSize*)malloc( count*sizeof(whole_sizes[i][0]) );
    }

    if( !is_timing_test )
        get_test_array_types_and_sizes( test_case_idx, sizes, types );
    else
    {
        get_timing_test_array_types_and_sizes( test_case_idx, sizes, types,
                                               whole_sizes, &is_image );
    }

    for( i = 0; i < max_arr; i++ )
    {
        int count = test_array[i].size();
        total += count;
        for( j = 0; j < count; j++ )
        {
            unsigned t = cvRandInt(rng);
            bool create_mask = true, use_roi = false;
            CvSize size = sizes[i][j], whole_size = size;
            CvRect roi = {0,0,0,0};

            if( !is_timing_test )
            {
                is_image = !cvmat_allowed ? true : iplimage_allowed ? (t & 1) != 0 : false;
                create_mask = (t & 6) == 0; // ~ each of 3 tests will use mask
                use_roi = (t & 8) != 0;
                if( use_roi )
                {
                    whole_size.width += cvRandInt(rng) % 10;
                    whole_size.height += cvRandInt(rng) % 10;
                }
            }
            else
            {
                whole_size = whole_sizes[i][j];
                use_roi = whole_size.width != size.width || whole_size.height != size.height;
                create_mask = cvReadInt(find_timing_param( "use_mask" ),0) != 0;
            }

            cvRelease( &test_array[i][j] );
            if( size.width > 0 && size.height > 0 &&
                types[i][j] >= 0 && (i != MASK || create_mask) )
            {
                if( use_roi )
                {
                    roi.width = size.width;
                    roi.height = size.height;
                    if( whole_size.width > size.width )
                    {
                        if( !is_timing_test )
                            roi.x = cvRandInt(rng) % (whole_size.width - size.width);
                        else
                            roi.x = 1;
                    }

                    if( whole_size.height > size.height )
                    {
                        if( !is_timing_test )
                            roi.y = cvRandInt(rng) % (whole_size.height - size.height);
                        else
                            roi.y = 1;
                    }
                }

                if( is_image )
                {
                    CV_CALL( test_array[i][j] = cvCreateImage( whole_size,
                        icvTsTypeToDepth[CV_MAT_DEPTH(types[i][j])],
                        CV_MAT_CN(types[i][j]) ));
                    if( use_roi )
                        cvSetImageROI( (IplImage*)test_array[i][j], roi );
                }
                else
                {
                    CV_CALL( test_array[i][j] = cvCreateMat( whole_size.height,
                                                whole_size.width, types[i][j] ));
                    if( use_roi )
                    {
                        CvMat submat, *mat = (CvMat*)test_array[i][j];
                        cvGetSubRect( test_array[i][j], &submat, roi );
                        submat.refcount = mat->refcount;
                        *mat = submat;
                    }
                }
            }
        }
    }

    if( total > max_hdr )
    {
        delete hdr;
        max_hdr = total;
        hdr = new CvMat[max_hdr];
    }

    total = 0;
    for( i = 0; i < max_arr; i++ )
    {
        int count = test_array[i].size();
        test_mat[i] = count > 0 ? hdr + total : 0;
        for( j = 0; j < count; j++ )
        {
            CvArr* arr = test_array[i][j];
            CvMat* mat = &test_mat[i][j];
            if( !arr )
                memset( mat, 0, sizeof(*mat) );
            else if( CV_IS_MAT( arr ))
            {
                *mat = *(CvMat*)arr;
                mat->refcount = 0;
            }
            else
                cvGetMat( arr, mat, 0, 0 );
            if( mat->data.ptr )
                fill_array( test_case_idx, i, j, mat );
        }
        total += count;
    }

    __END__;

    for( i = 0; i < max_arr; i++ )
    {
        if( sizes )
            free( sizes[i] );
        if( whole_sizes )
            free( whole_sizes[i] );
        if( types )
            free( types[i] );
    }

    free( sizes );
    free( whole_sizes );
    free( types );

    return code;
}
void CvArrTest::print_time( int test_case_idx, double time_clocks, double time_cpu_clocks )
{
    int in_type = -1, out_type = -1;
    CvSize size = { -1, -1 };
    const CvFileNode* size_node = find_timing_param( "size" );
    char str[1024], *ptr = str;
    int len;
    bool have_mask;
    double cpe;

    if( size_node )
    {
        if( !CV_NODE_IS_SEQ(size_node->tag) )
        {
            size.width = cvReadInt(size_node,-1);
            size.height = 1;
        }
        else
        {
            size.width = cvReadInt((const CvFileNode*)cvGetSeqElem(size_node->data.seq,0),-1);
            size.height = cvReadInt((const CvFileNode*)cvGetSeqElem(size_node->data.seq,1),-1);
        }
    }

    if( test_array[INPUT].size() )
    {
        in_type = CV_MAT_TYPE(test_mat[INPUT][0].type);
        if( size.width == -1 )
            size = cvGetMatSize(&test_mat[INPUT][0]);
    }

    if( test_array[OUTPUT].size() )
    {
        out_type = CV_MAT_TYPE(test_mat[OUTPUT][0].type);
        if( in_type < 0 )
            in_type = out_type;
        if( size.width == -1 )
            size = cvGetMatSize(&test_mat[OUTPUT][0]);
    }

    if( out_type < 0 && test_array[INPUT_OUTPUT].size() )
    {
        out_type = CV_MAT_TYPE(test_mat[INPUT_OUTPUT][0].type);
        if( in_type < 0 )
            in_type = out_type;
        if( size.width == -1 )
            size = cvGetMatSize(&test_mat[INPUT_OUTPUT][0]);
    }

    have_mask = test_array[MASK].size() > 0 && test_array[MASK][0] != 0;

    if( in_type < 0 && out_type < 0 )
        return;

    if( out_type < 0 )
        out_type = in_type;

    ptr = strchr( (char*)tested_functions, ',' );
    if( ptr )
    {
        len = (int)(ptr - tested_functions);
        strncpy( str, tested_functions, len );
    }
    else
    {
        len = (int)strlen( tested_functions );
        strcpy( str, tested_functions );
    }
    ptr = str + len;
    *ptr = '\0';
    if( have_mask )
    {
        sprintf( ptr, "(Mask)" );
        ptr += strlen(ptr);
    }
    *ptr++ = ',';
    sprintf( ptr, "%s", cvTsGetTypeName(in_type) );
    ptr += strlen(ptr);

    if( CV_MAT_DEPTH(out_type) != CV_MAT_DEPTH(in_type) )
    {
        sprintf( ptr, "%s", cvTsGetTypeName(out_type) );
        ptr += strlen(ptr);
    }
    *ptr++ = ',';

    sprintf( ptr, "C%d", CV_MAT_CN(in_type) );
    ptr += strlen(ptr);

    if( CV_MAT_CN(out_type) != CV_MAT_CN(in_type) )
    {
        sprintf( ptr, "C%d", CV_MAT_CN(out_type) );
        ptr += strlen(ptr);
    }
    *ptr++ = ',';

    sprintf( ptr, "%dx%d,", size.width, size.height );
    ptr += strlen(ptr);

    print_timing_params( test_case_idx, ptr );
    ptr += strlen(ptr);
    cpe = time_cpu_clocks / ((double)size.width * size.height);
    if( cpe >= 100 )
        sprintf( ptr, "%.0f,", cpe );
    else
        sprintf( ptr, "%.1f,", cpe );
    ptr += strlen(ptr);
    sprintf( ptr, "%g", time_clocks*1e6/cv::getTickFrequency() );

    ts->printf( CvTS::CSV, "%s\n", str );
}
Beispiel #15
0
 int cvReadInt_wrap(const CvFileNode * node , int default_value ){
	return cvReadInt(/*const*//*CvFileNode*//***/node , /*int*/default_value);
}
/* ///////////////////// chess_corner_test ///////////////////////// */
void CV_ChessboardDetectorTimingTest::run( int start_from )
{
    int code = cvtest::TS::OK;

    /* test parameters */
    std::string   filepath;
    std::string   filename;

    CvMat*  _v = 0;
    CvPoint2D32f* v;

    IplImage img;
    IplImage* gray = 0;
    IplImage* thresh = 0;

    int  idx, max_idx;
    int  progress = 0;

    filepath = cv::format("%scv/cameracalibration/", ts->get_data_path().c_str() );
    filename = cv::format("%schessboard_timing_list.dat", filepath.c_str() );
    CvFileStorage* fs = cvOpenFileStorage( filename.c_str(), 0, CV_STORAGE_READ );
    CvFileNode* board_list = fs ? cvGetFileNodeByName( fs, 0, "boards" ) : 0;

    if( !fs || !board_list || !CV_NODE_IS_SEQ(board_list->tag) ||
        board_list->data.seq->total % 4 != 0 )
    {
        ts->printf( cvtest::TS::LOG, "chessboard_timing_list.dat can not be readed or is not valid" );
        code = cvtest::TS::FAIL_MISSING_TEST_DATA;
        goto _exit_;
    }

    max_idx = board_list->data.seq->total/4;

    for( idx = start_from; idx < max_idx; idx++ )
    {
        int count0 = -1;
        int count = 0;
        CvSize pattern_size;
        int result, result1 = 0;

        const char* imgname = cvReadString((CvFileNode*)cvGetSeqElem(board_list->data.seq,idx*4), "dummy.txt");
        int is_chessboard = cvReadInt((CvFileNode*)cvGetSeqElem(board_list->data.seq,idx*4+1), 0);
        pattern_size.width = cvReadInt((CvFileNode*)cvGetSeqElem(board_list->data.seq,idx*4 + 2), -1);
        pattern_size.height = cvReadInt((CvFileNode*)cvGetSeqElem(board_list->data.seq,idx*4 + 3), -1);

        ts->update_context( this, idx-1, true );

        /* read the image */
        filename = cv::format("%s%s", filepath.c_str(), imgname );

        cv::Mat img2 = cv::imread( filename );
        img = img2;

        if( img2.empty() )
        {
            ts->printf( cvtest::TS::LOG, "one of chessboard images can't be read: %s\n", filename.c_str() );
            code = cvtest::TS::FAIL_MISSING_TEST_DATA;
            continue;
        }

        ts->printf(cvtest::TS::LOG, "%s: chessboard %d:\n", imgname, is_chessboard);

        gray = cvCreateImage( cvSize( img.width, img.height ), IPL_DEPTH_8U, 1 );
        thresh = cvCreateImage( cvSize( img.width, img.height ), IPL_DEPTH_8U, 1 );
        cvCvtColor( &img, gray, CV_BGR2GRAY );


        count0 = pattern_size.width*pattern_size.height;

        /* allocate additional buffers */
        _v = cvCreateMat(1, count0, CV_32FC2);
        count = count0;

        v = (CvPoint2D32f*)_v->data.fl;

        int64 _time0 = cvGetTickCount();
        result = cvCheckChessboard(gray, pattern_size);
        int64 _time01 = cvGetTickCount();

        OPENCV_CALL( result1 = cvFindChessboardCorners(
                 gray, pattern_size, v, &count, 15 ));
        int64 _time1 = cvGetTickCount();

        if( result != is_chessboard )
        {
            ts->printf( cvtest::TS::LOG, "Error: chessboard was %sdetected in the image %s\n",
                       result ? "" : "not ", imgname );
            code = cvtest::TS::FAIL_INVALID_OUTPUT;
            goto _exit_;
        }
        if(result != result1)
        {
            ts->printf( cvtest::TS::LOG, "Warning: results differ cvCheckChessboard %d, cvFindChessboardCorners %d\n",
                       result, result1);
        }

        int num_pixels = gray->width*gray->height;
        float check_chessboard_time = float(_time01 - _time0)/(float)cvGetTickFrequency(); // in us
        ts->printf(cvtest::TS::LOG, "    cvCheckChessboard time s: %f, us per pixel: %f\n",
                   check_chessboard_time*1e-6, check_chessboard_time/num_pixels);

        float find_chessboard_time = float(_time1 - _time01)/(float)cvGetTickFrequency();
        ts->printf(cvtest::TS::LOG, "    cvFindChessboard time s: %f, us per pixel: %f\n",
                   find_chessboard_time*1e-6, find_chessboard_time/num_pixels);

        cvReleaseMat( &_v );
        cvReleaseImage( &gray );
        cvReleaseImage( &thresh );
        progress = update_progress( progress, idx-1, max_idx, 0 );
    }

_exit_:

    /* release occupied memory */
    cvReleaseMat( &_v );
    cvReleaseFileStorage( &fs );
    cvReleaseImage( &gray );
    cvReleaseImage( &thresh );

    if( code < 0 )
        ts->set_failed_test_info( code );
}