コード例 #1
0
ファイル: gbt.cpp プロジェクト: Rocky030/opencv
void CvGBTrees::write_params( CvFileStorage* fs ) const
{
    const char* loss_function_type_str =
        params.loss_function_type == SQUARED_LOSS ? "SquaredLoss" :
        params.loss_function_type == ABSOLUTE_LOSS ? "AbsoluteLoss" :
        params.loss_function_type == HUBER_LOSS ? "HuberLoss" :
        params.loss_function_type == DEVIANCE_LOSS ? "DevianceLoss" : 0;


    if( loss_function_type_str )
        cvWriteString( fs, "loss_function", loss_function_type_str );
    else
        cvWriteInt( fs, "loss_function", params.loss_function_type );

    cvWriteInt( fs, "ensemble_length", params.weak_count );
    cvWriteReal( fs, "shrinkage", params.shrinkage );
    cvWriteReal( fs, "subsample_portion", params.subsample_portion );
    //cvWriteInt( fs, "max_tree_depth", params.max_depth );
    //cvWriteString( fs, "use_surrogate_splits", params.use_surrogates ? "true" : "false");
    if (class_labels) cvWrite( fs, "class_labels", class_labels);

    data->is_classifier = !problem_type();
    data->write_params( fs );
    data->is_classifier = 0;
}
コード例 #2
0
ファイル: DPWrenGABGS.cpp プロジェクト: asus4/ofxBGS
void DPWrenGABGS::saveConfig()
{
  CvFileStorage* fs = cvOpenFileStorage("./config/DPWrenGABGS.xml", 0, CV_STORAGE_WRITE);

  cvWriteReal(fs, "threshold", threshold);
  cvWriteReal(fs, "alpha", alpha);
  cvWriteInt(fs, "learningFrames", learningFrames);
  cvWriteInt(fs, "showOutput", showOutput);

  cvReleaseFileStorage(&fs);
}
コード例 #3
0
void DPGrimsonGMMBGS::saveConfig()
{
  CvFileStorage* fs = cvOpenFileStorage("./config/DPGrimsonGMMBGS.xml", 0, CV_STORAGE_WRITE);

  cvWriteReal(fs, "threshold", threshold);
  cvWriteReal(fs, "alpha", alpha);
  cvWriteInt(fs, "gaussians", gaussians);
  cvWriteInt(fs, "showOutput", showOutput);

  cvReleaseFileStorage(&fs);
}
コード例 #4
0
void EntropyOfEntropyArea::saveConfig(){
	CvFileStorage* fs = cvOpenFileStorage("./Config/EntropyOfEntropyArea.xml", 0, CV_STORAGE_WRITE);

	cvWriteInt(fs, "windowWidth", windowWidth);
	cvWriteInt(fs, "grayLevel", grayLevel);
	cvWriteReal(fs, "C0",C0);
	cvWriteReal(fs, "learningRate", learningRate);
	cvWriteReal(fs, "deltaENToOldENRatioEntropy", deltaENToOldENRatioEntropy);
	cvWriteReal(fs, "staticRatioEntropy", staticRatioEntropy);

	cvReleaseFileStorage(&fs);

}
コード例 #5
0
void T2FGMM_UV::saveConfig()
{
  CvFileStorage* fs = cvOpenFileStorage("./config/T2FGMM_UV.xml", 0, CV_STORAGE_WRITE);

  cvWriteReal(fs, "threshold", threshold);
  cvWriteReal(fs, "alpha", alpha);
  cvWriteReal(fs, "km", km);
  cvWriteReal(fs, "kv", kv);
  cvWriteInt(fs, "gaussians", gaussians);
  cvWriteInt(fs, "showOutput", showOutput);

  cvReleaseFileStorage(&fs);
}
コード例 #6
0
void VuMeter::saveConfig()
{
  CvFileStorage* fs = cvOpenFileStorage("./config/VuMeter.xml", 0, CV_STORAGE_WRITE);

  cvWriteInt(fs, "enableFilter", enableFilter);
  
  cvWriteInt(fs, "binSize", binSize);
  cvWriteReal(fs, "alpha", alpha);
  cvWriteReal(fs, "threshold", threshold);
  
  cvWriteInt(fs, "showOutput", showOutput);

  cvReleaseFileStorage(&fs);
}
コード例 #7
0
void FuzzyChoquetIntegral::saveConfig()
{
  CvFileStorage* fs = cvOpenFileStorage("../config/FuzzyChoquetIntegral.xml", 0, CV_STORAGE_WRITE);
  
  cvWriteInt(fs, "showOutput", showOutput);
  cvWriteInt(fs, "framesToLearn", framesToLearn);
  cvWriteReal(fs, "alphaLearn", alphaLearn);
  cvWriteReal(fs, "alphaUpdate", alphaUpdate);
  cvWriteInt(fs, "colorSpace", colorSpace);
  cvWriteInt(fs, "option", option);
  cvWriteInt(fs, "smooth", smooth);
  cvWriteReal(fs, "threshold", threshold);

  cvReleaseFileStorage(&fs);
}
コード例 #8
0
/*!
    \fn CvBinGabAdaFeatureSelect::saveweaks(const char *filename)
 */
void CvBinGabAdaFeatureSelect::saveweaks(const char *filename)
{
  CvMemStorage* storage = cvCreateMemStorage(0);
  CvSeq* seq = cvCreateSeq(0, sizeof(CvSeq), sizeof(CvGaborTree), storage );
  int num = weaks.size();
  for(int i = 0; i < num; i++ )
  {
    CvGaborFeature *feature;
    feature = new_pool->getfeature(i);
    
    CvGaborTree tree;
    
    tree.x = feature->getx();
    tree.y = feature->gety();
    tree.Mu = feature->getMu();
    tree.Nu = feature->getNu();
    tree.alpha = alphas[i];      
    tree.threshold = weaks[i].getthreshold();
    tree.parity = weaks[i].getparity();
    cvSeqPush( seq, &tree );
  }
  
  char *weakname = new char[20];
  CvMemStorage* xstorage = cvCreateMemStorage( 0 );
  CvFileStorage *fs = cvOpenFileStorage( filename, xstorage, CV_STORAGE_WRITE );
  for (int i = 0; i <seq->total; i++)
  {
    CvGaborTree *atree = (CvGaborTree*)cvGetSeqElem(seq, i);
    sprintf(weakname, "weak_%d", i);
    cvStartWriteStruct( fs, weakname, CV_NODE_MAP, "CvGaborTree", cvAttrList(0,0) );
    cvWriteInt(fs, "x", atree->x);
    cvWriteInt(fs, "y", atree->y);
    cvWriteInt(fs, "Mu", atree->Mu);
    cvWriteInt(fs, "Nu", atree->Nu);
    cvWriteReal(fs, "alpha", atree->alpha);
    cvWriteReal(fs, "threshold", atree->threshold);
    cvWriteReal(fs, "parity", atree->parity);
    cvEndWriteStruct( fs ); 
  } 
  
    /* release memory storage in the end */
  delete [] weakname;
  cvReleaseMemStorage( &xstorage );
  cvReleaseMemStorage( &storage );
  cvReleaseFileStorage(&fs);
}
コード例 #9
0
void GMG::saveConfig()
{
  CvFileStorage* fs = cvOpenFileStorage("./config/GMG.xml", 0, CV_STORAGE_WRITE);

  cvWriteInt(fs, "initializationFrames", initializationFrames);
  cvWriteReal(fs, "decisionThreshold", decisionThreshold);
  cvWriteInt(fs, "showOutput", showOutput);

  cvReleaseFileStorage(&fs);
}
コード例 #10
0
void MixtureOfGaussianV2BGS::saveConfig()
{
  CvFileStorage* fs = cvOpenFileStorage("./config/MixtureOfGaussianV2BGS.xml", 0, CV_STORAGE_WRITE);

  cvWriteReal(fs, "alpha", alpha);
  cvWriteInt(fs, "enableThreshold", enableThreshold);
  cvWriteInt(fs, "threshold", threshold);
  cvWriteInt(fs, "showOutput", showOutput);

  cvReleaseFileStorage(&fs);
}
コード例 #11
0
void AdaptiveBackgroundLearning::saveConfig()
{
  CvFileStorage* fs = cvOpenFileStorage("AdaptiveBackgroundLearning.xml", 0, CV_STORAGE_WRITE);

  cvWriteReal(fs, "alpha", alpha);
  cvWriteInt(fs, "limit", limit);
  cvWriteInt(fs, "enableThreshold", enableThreshold);
  cvWriteInt(fs, "threshold", threshold);
  cvWriteInt(fs, "showForeground", showForeground);
  cvWriteInt(fs, "showBackground", showBackground);

  cvReleaseFileStorage(&fs);
}
コード例 #12
0
void PixelBasedAdaptiveSegmenter::saveConfig()
{
	CvFileStorage* fs = cvOpenFileStorage("./config/PixelBasedAdaptiveSegmenter.xml", 0, CV_STORAGE_WRITE);

	cvWriteInt(fs, "enableInputBlur", enableInputBlur);
	cvWriteInt(fs, "enableOutputBlur", enableOutputBlur);

	cvWriteReal(fs, "alpha", alpha);
	cvWriteReal(fs, "beta", beta);
	cvWriteInt(fs, "N", N);
	cvWriteInt(fs, "Raute_min", Raute_min);
	cvWriteReal(fs, "R_incdec", R_incdec);
	cvWriteInt(fs, "R_lower", R_lower);
	cvWriteInt(fs, "R_scale", R_scale);
	cvWriteReal(fs, "T_dec", T_dec);
	cvWriteInt(fs, "T_inc", T_inc);
	cvWriteInt(fs, "T_init", T_init);
	cvWriteInt(fs, "T_lower", T_lower);
	cvWriteInt(fs, "T_upper", T_upper);

	cvWriteInt(fs, "showOutput", showOutput);

	cvReleaseFileStorage(&fs);
}
コード例 #13
0
ファイル: Config.cpp プロジェクト: quangthi/TrackCam
void CConfig::SaveXmlFile()
{
    CvFileStorage* fs = cvOpenFileStorage(XML_FILE, 0, CV_STORAGE_WRITE);
    cvWriteInt(fs, "IpCam", _config.ipCam);
    cvWriteString(fs, "VsCamGV", _config.strCamUrl_GV.data());
    cvWriteString(fs, "IrCamGV", _config.strCamUrl_GV_ir.data());
    cvWriteString(fs, "VsCamIP", _config.strCamUrl_IP.data());
    cvWriteString(fs, "IrCamIP", _config.strCamUrl_IP_ir.data());
    cvWriteInt(fs, "TrkWidth", _config.trkWidth);
    cvWriteInt(fs, "TrkHeight", _config.trkHeight);
    cvWriteInt(fs, "FrmPosX", _config.frmPosX);
    cvWriteInt(fs, "FrmPosY", _config.frmPosY);
    cvWriteInt(fs, "FrmWidth", _config.frmWidth);
    cvWriteInt(fs, "FrmHeight", _config.frmHeight);
    cvWriteReal(fs, "Fps", _config.fps);
    cvReleaseFileStorage(&fs);
}
コード例 #14
0
ファイル: Eigenfaces.cpp プロジェクト: dmitry123/iss
int Eigenfaces::saveConfig(const string& dir)
{
    if (DEBUG)
        cout << "Saving config in "<< dir << endl;

    string configFile          = dir + string("/libface-config.xml");
    CvFileStorage* fileStorage = cvOpenFileStorage(d->configFile.c_str(), 0, CV_STORAGE_WRITE);

    if (!fileStorage)
    {
        if (DEBUG)
            cout << "Cant open for storing :" << d->configFile << endl;

        return 1;
    }

    // Start storing
    unsigned int nIds = d->faceImgArr.size(), i;

    // Write some initial params and matrices
    cvWriteInt( fileStorage, "nIds", nIds );
    cvWriteInt( fileStorage, "FACE_WIDTH", d->FACE_WIDTH);
    cvWriteInt( fileStorage, "FACE_HEIGHT", d->FACE_HEIGHT);
    cvWriteReal( fileStorage, "THRESHOLD", d->THRESHOLD);

    // Write all the training faces
    for ( i = 0; i < nIds; i++ )
    {
        char facename[200];
        sprintf(facename, "person_%d", i);
        cvWrite(fileStorage, facename, d->faceImgArr.at(i), cvAttrList(0,0));
    }

    for ( i = 0; i < nIds; i++ )
    {
        char idname[200];
        sprintf(idname, "id_%d", i);
        cvWriteInt(fileStorage, idname, d->indexMap.at(i));
    }

    // Release the fileStorage
    cvReleaseFileStorage(&fileStorage);
    return 0;
}
コード例 #15
0
int
main (int argc, char **argv)
{
  char filename[] = "save_cv.xml";	// file name
  int i;
  int a;
  float b;
  CvMat** mat;
  CvFileStorage *cvfs;

  // (1)create sample data
  a = 10;
  b = 0.1;
  mat = (CvMat**)cvAlloc(3*sizeof(CvMat*));
  for(i=0;i<3;i++){
    mat[i] = cvCreateMat(3,3,CV_32FC1);
    cvSet(mat[i], cvScalarAll(i), NULL);
  }

  // (2)open file storage
  cvfs = cvOpenFileStorage(filename,NULL,CV_STORAGE_WRITE);

  // (3)write data to file
  cvWriteInt(cvfs, "a", a);
  cvWriteReal(cvfs, "b", b);

  cvStartWriteStruct(cvfs, "mat_array", CV_NODE_SEQ, NULL, cvAttrList(NULL, NULL));	// create node
  for(i=0; i<3; i++){
    cvWrite(cvfs, NULL, mat[i], cvAttrList(NULL, NULL));
  }
  cvEndWriteStruct(cvfs);

  // (4)close file storage
  cvReleaseFileStorage(&cvfs);

  // release mat
  for(i=0; i<3; i++){
    cvReleaseMat(mat+i);
  }
  cvFree(mat);

  return 0;
}
コード例 #16
0
ファイル: gbt.cpp プロジェクト: Rocky030/opencv
void CvGBTrees::write( CvFileStorage* fs, const char* name ) const
{
    CV_FUNCNAME( "CvGBTrees::write" );

    __BEGIN__;

    CvSeqReader reader;
    int i;
    cv::String s;

    cvStartWriteStruct( fs, name, CV_NODE_MAP, CV_TYPE_NAME_ML_GBT );

    if( !weak )
        CV_ERROR( CV_StsBadArg, "The model has not been trained yet" );

    write_params( fs );
    cvWriteReal( fs, "base_value", base_value);
    cvWriteInt( fs, "class_count", class_count);

    for ( int j=0; j < class_count; ++j )
    {
        s = cv::format("trees_%d", j);
        cvStartWriteStruct( fs, s.c_str(), CV_NODE_SEQ );

        cvStartReadSeq( weak[j], &reader );

        for( i = 0; i < weak[j]->total; i++ )
        {
            CvDTree* tree;
            CV_READ_SEQ_ELEM( tree, reader );
            cvStartWriteStruct( fs, 0, CV_NODE_MAP );
            tree->write( fs );
            cvEndWriteStruct( fs );
        }

        cvEndWriteStruct( fs );
    }

    cvEndWriteStruct( fs );

    __END__;
}
コード例 #17
0
void MixtureOfGaussianV1BGS::saveConfig()
{

    QDir dir(QDir::home());
    if(!dir.exists("NoobaVSS")) {
        dir.mkdir("NoobaVSS");
    }
    dir.cd("NoobaVSS");
    if(!dir.exists("config")) {
        dir.mkdir("config");
    }
    dir.cd("config");

    CvFileStorage* fs = cvOpenFileStorage(dir.absoluteFilePath("MixtureOfGaussianV1BGS.xml").toLocal8Bit(), 0, CV_STORAGE_WRITE);
    cvWriteReal(fs, "alpha", alpha);
    cvWriteInt(fs, "enableThreshold", enableThreshold);
    cvWriteInt(fs, "threshold", threshold);
    cvWriteInt(fs, "showOutput", showOutput);

    cvReleaseFileStorage(&fs);
}
コード例 #18
0
void AdaptiveBackgroundLearning::saveConfig()
{
    QDir dir(QDir::home());
    if(!dir.exists("NoobaVSS")){
        dir.mkdir("NoobaVSS");
    }
    dir.cd("NoobaVSS");
    if(!dir.exists("config")){
        dir.mkdir("config");
    }
    dir.cd("config");
    CvFileStorage* fs = cvOpenFileStorage(dir.absoluteFilePath("AdaptiveBackgroundLearning.xml").toLocal8Bit(), 0, CV_STORAGE_WRITE);

    cvWriteReal(fs, "alpha", alpha);
    cvWriteInt(fs, "limit", limit);
    cvWriteInt(fs, "enableThreshold", enableThreshold);
    cvWriteInt(fs, "threshold", threshold);
    cvWriteInt(fs, "showForeground", showForeground);
    cvWriteInt(fs, "showBackground", showBackground);

    cvReleaseFileStorage(&fs);
}
コード例 #19
0
void MultiLayerBGS::saveConfig()
{
  CvFileStorage* fs = cvOpenFileStorage("MultiLayerBGS.xml", 0, CV_STORAGE_WRITE);
  if(fs == NULL)
  {
	  cout << "Do not open file MultiLayerBGS.xml - saveConfig()" << endl;
	  return;
  }

  cvWriteString(fs, "preloadModel", bg_model_preload.c_str());
  cvWriteInt(fs, "saveModel", saveModel);
  cvWriteInt(fs, "detectAfter", detectAfter);
  cvWriteInt(fs, "disableDetectMode", disableDetectMode);
  cvWriteInt(fs, "disableLearningInDetecMode", disableLearning);
  cvWriteInt(fs, "loadDefaultParams", loadDefaultParams);

  cvWriteInt(fs, "max_mode_num", max_mode_num);
  cvWriteReal(fs, "weight_updating_constant", weight_updating_constant);
  cvWriteReal(fs, "texture_weight", texture_weight);
  cvWriteReal(fs, "bg_mode_percent", bg_mode_percent);
  cvWriteInt(fs, "pattern_neig_half_size", pattern_neig_half_size);
  cvWriteReal(fs, "pattern_neig_gaus_sigma", pattern_neig_gaus_sigma);
  cvWriteReal(fs, "bg_prob_threshold", bg_prob_threshold);
  cvWriteReal(fs, "bg_prob_updating_threshold", bg_prob_updating_threshold);
  cvWriteInt(fs, "robust_LBP_constant", robust_LBP_constant);
  cvWriteReal(fs, "min_noised_angle", min_noised_angle);
  cvWriteReal(fs, "shadow_rate", shadow_rate);
  cvWriteReal(fs, "highlight_rate", highlight_rate);
  cvWriteReal(fs, "bilater_filter_sigma_s", bilater_filter_sigma_s);
  cvWriteReal(fs, "bilater_filter_sigma_r", bilater_filter_sigma_r);

  cvWriteReal(fs, "frame_duration", frame_duration);

  cvWriteReal(fs, "learn_mode_learn_rate_per_second", learn_mode_learn_rate_per_second);
  cvWriteReal(fs, "learn_weight_learn_rate_per_second", learn_weight_learn_rate_per_second);
  cvWriteReal(fs, "learn_init_mode_weight", learn_init_mode_weight);

  cvWriteReal(fs, "detect_mode_learn_rate_per_second", detect_mode_learn_rate_per_second);
  cvWriteReal(fs, "detect_weight_learn_rate_per_second", detect_weight_learn_rate_per_second);
  cvWriteReal(fs, "detect_init_mode_weight", detect_init_mode_weight);

  cvWriteInt(fs, "showOutput", showOutput);

  cvReleaseFileStorage(&fs);
}
コード例 #20
0
ファイル: Point.cpp プロジェクト: flexibity-team/OpenGazer
void Point::save(CvFileStorage *out, const char *name) const {
    cvStartWriteStruct(out, name, CV_NODE_MAP);
    cvWriteReal(out, "x", x);
    cvWriteReal(out, "y", y);
    cvEndWriteStruct(out);
}
コード例 #21
0
ファイル: mlann_mlp.cpp プロジェクト: cybertk/opencv
void CvANN_MLP::write_params( CvFileStorage* fs )
{
    //CV_FUNCNAME( "CvANN_MLP::write_params" );

    __BEGIN__;

    const char* activ_func_name = activ_func == IDENTITY ? "IDENTITY" :
                            activ_func == SIGMOID_SYM ? "SIGMOID_SYM" :
                            activ_func == GAUSSIAN ? "GAUSSIAN" : 0;

    if( activ_func_name )
        cvWriteString( fs, "activation_function", activ_func_name );
    else
        cvWriteInt( fs, "activation_function", activ_func );

    if( activ_func != IDENTITY )
    {
        cvWriteReal( fs, "f_param1", f_param1 );
        cvWriteReal( fs, "f_param2", f_param2 );
    }

    cvWriteReal( fs, "min_val", min_val );
    cvWriteReal( fs, "max_val", max_val );
    cvWriteReal( fs, "min_val1", min_val1 );
    cvWriteReal( fs, "max_val1", max_val1 );

    cvStartWriteStruct( fs, "training_params", CV_NODE_MAP );
    if( params.train_method == CvANN_MLP_TrainParams::BACKPROP )
    {
        cvWriteString( fs, "train_method", "BACKPROP" );
        cvWriteReal( fs, "dw_scale", params.bp_dw_scale );
        cvWriteReal( fs, "moment_scale", params.bp_moment_scale );
    }
    else if( params.train_method == CvANN_MLP_TrainParams::RPROP )
    {
        cvWriteString( fs, "train_method", "RPROP" );
        cvWriteReal( fs, "dw0", params.rp_dw0 );
        cvWriteReal( fs, "dw_plus", params.rp_dw_plus );
        cvWriteReal( fs, "dw_minus", params.rp_dw_minus );
        cvWriteReal( fs, "dw_min", params.rp_dw_min );
        cvWriteReal( fs, "dw_max", params.rp_dw_max );
    }

    cvStartWriteStruct( fs, "term_criteria", CV_NODE_MAP + CV_NODE_FLOW );
    if( params.term_crit.type & CV_TERMCRIT_EPS )
        cvWriteReal( fs, "epsilon", params.term_crit.epsilon );
    if( params.term_crit.type & CV_TERMCRIT_ITER )
        cvWriteInt( fs, "iterations", params.term_crit.max_iter );
    cvEndWriteStruct( fs );

    cvEndWriteStruct( fs );

    __END__;
}
コード例 #22
0
ファイル: calibration.cpp プロジェクト: janfrs/kwc-ros-pkg
void save_camera_params( const char* out_filename, int image_count, CvSize img_size,
                         CvSize board_size, float square_size,
                         float aspect_ratio, int flags,
                         const CvMat* camera_matrix, CvMat* dist_coeffs,
                         const CvMat* extr_params, const CvSeq* image_points_seq,
                         const CvMat* reproj_errs, double avg_reproj_err )
{
    CvFileStorage* fs = cvOpenFileStorage( out_filename, 0, CV_STORAGE_WRITE );
    
    time_t t;
    time( &t );
    struct tm *t2 = localtime( &t );
    char buf[1024];
    strftime( buf, sizeof(buf)-1, "%c", t2 );

    cvWriteString( fs, "calibration_time", buf );
    
    cvWriteInt( fs, "image_count", image_count );
    cvWriteInt( fs, "image_width", img_size.width );
    cvWriteInt( fs, "image_height", img_size.height );
    cvWriteInt( fs, "board_width", board_size.width );
    cvWriteInt( fs, "board_height", board_size.height );
    cvWriteReal( fs, "square_size", square_size );
    
    if( flags & CV_CALIB_FIX_ASPECT_RATIO )
        cvWriteReal( fs, "aspect_ratio", aspect_ratio );

    if( flags != 0 )
    {
        sprintf( buf, "flags: %s%s%s%s",
            flags & CV_CALIB_USE_INTRINSIC_GUESS ? "+use_intrinsic_guess" : "",
            flags & CV_CALIB_FIX_ASPECT_RATIO ? "+fix_aspect_ratio" : "",
            flags & CV_CALIB_FIX_PRINCIPAL_POINT ? "+fix_principal_point" : "",
            flags & CV_CALIB_ZERO_TANGENT_DIST ? "+zero_tangent_dist" : "" );
        cvWriteComment( fs, buf, 0 );
    }
    
    cvWriteInt( fs, "flags", flags );

    cvWrite( fs, "camera_matrix", camera_matrix );
    cvWrite( fs, "distortion_coefficients", dist_coeffs );

    cvWriteReal( fs, "avg_reprojection_error", avg_reproj_err );
    if( reproj_errs )
        cvWrite( fs, "per_view_reprojection_errors", reproj_errs );

    if( extr_params )
    {
        cvWriteComment( fs, "a set of 6-tuples (rotation vector + translation vector) for each view", 0 );
        cvWrite( fs, "extrinsic_parameters", extr_params );
    }

    if( image_points_seq )
    {
        cvWriteComment( fs, "the array of board corners projections used for calibration", 0 );
        assert( image_points_seq->total == image_count );
        CvMat* image_points = cvCreateMat( 1, image_count*board_size.width*board_size.height, CV_32FC2 );
        cvCvtSeqToArray( image_points_seq, image_points->data.fl );

        cvWrite( fs, "image_points", image_points );
        cvReleaseMat( &image_points );
    }

    cvReleaseFileStorage( &fs );
}
コード例 #23
0
ファイル: cvUtilProCam.cpp プロジェクト: Pacmanfan/MultiScan
// Save XML-formatted configuration file.
void writeConfiguration(const char* filename, struct slParams* sl_params){

	// Create file storage for XML-formatted configuration file.
	CvFileStorage* fs = cvOpenFileStorage(filename, 0, CV_STORAGE_WRITE);
	
	// Write output directory and object (or sequence) name.
	cvStartWriteStruct(fs, "output", CV_NODE_MAP);
	cvWriteString(fs, "output_directory",          sl_params->outdir, 1);
	cvWriteString(fs, "object_name",               sl_params->object, 1);
	cvWriteInt(fs,    "save_intermediate_results", sl_params->save);
	cvEndWriteStruct(fs);
	
	// Write camera parameters.
	cvStartWriteStruct(fs, "camera", CV_NODE_MAP);
	cvWriteInt(fs, "width",                           sl_params->cam_w);
	cvWriteInt(fs, "height",                          sl_params->cam_h);
	cvWriteInt(fs, "Logitech_Quickcam_9000_raw_mode", sl_params->Logitech_9000);
	cvEndWriteStruct(fs);

	// Write projector parameters.
	cvStartWriteStruct(fs, "projector", CV_NODE_MAP);
	cvWriteInt(fs, "width",            sl_params->proj_w);
	cvWriteInt(fs, "height",           sl_params->proj_h);
	cvWriteInt(fs, "invert_projector", sl_params->proj_invert);
	cvEndWriteStruct(fs);

	// Write camera and projector gain parameters.
	cvStartWriteStruct(fs, "gain", CV_NODE_MAP);
	cvWriteInt(fs, "camera_gain",    sl_params->cam_gain);
	cvWriteInt(fs, "projector_gain", sl_params->proj_gain);
	cvEndWriteStruct(fs);

	// Write distortion model parameters.
	cvStartWriteStruct(fs, "distortion_model", CV_NODE_MAP);
	cvWriteInt(fs, "enable_tangential_camera",          sl_params->cam_dist_model[0]);
	cvWriteInt(fs, "enable_6th_order_radial_camera",    sl_params->cam_dist_model[1]);
	cvWriteInt(fs, "enable_tangential_projector",       sl_params->proj_dist_model[0]);
	cvWriteInt(fs, "enable_6th_order_radial_projector", sl_params->proj_dist_model[1]);
	cvEndWriteStruct(fs);

	// Write camera calibration chessboard parameters.
	cvStartWriteStruct(fs, "camera_chessboard", CV_NODE_MAP);
	cvWriteInt(fs,  "interior_horizontal_corners",  sl_params->cam_board_w);
	cvWriteInt(fs,  "interior_vertical_corners",    sl_params->cam_board_h);
	cvWriteReal(fs, "square_width_mm",              sl_params->cam_board_w_mm);
	cvWriteReal(fs, "square_height_mm",             sl_params->cam_board_h_mm);
	cvEndWriteStruct(fs);

	// Write projector calibration chessboard parameters.
	cvStartWriteStruct(fs, "projector_chessboard", CV_NODE_MAP);
	cvWriteInt(fs, "interior_horizontal_corners",  sl_params->proj_board_w);
	cvWriteInt(fs, "interior_vertical_corners",    sl_params->proj_board_h);
	cvWriteInt(fs, "square_width_pixels",          sl_params->proj_board_w_pixels);
	cvWriteInt(fs, "square_height_pixels",         sl_params->proj_board_h_pixels);
	cvEndWriteStruct(fs);

	// Write scanning and reconstruction parameters.
	cvStartWriteStruct(fs, "scanning_and_reconstruction", CV_NODE_MAP);
	cvWriteInt(fs,  "mode",                           sl_params->mode);
	cvWriteInt(fs,  "reconstruct_columns",            sl_params->scan_cols);
	cvWriteInt(fs,  "reconstruct_rows",               sl_params->scan_rows);
	cvWriteInt(fs,  "frame_delay_ms",                 sl_params->delay);
	cvWriteInt(fs,  "minimum_contrast_threshold",     sl_params->thresh);
	cvWriteReal(fs, "minimum_distance_mm",            sl_params->dist_range[0]);
	cvWriteReal(fs, "maximum_distance_mm",            sl_params->dist_range[1]);
	cvWriteReal(fs, "maximum_distance_variation_mm",  sl_params->dist_reject);
	cvWriteReal(fs, "minimum_background_distance_mm", sl_params->background_depth_thresh);
	cvEndWriteStruct(fs);

	// Write visualization options.
	cvStartWriteStruct(fs, "visualization", CV_NODE_MAP);
	cvWriteInt(fs, "display_intermediate_results", sl_params->display);
	cvWriteInt(fs, "display_window_width_pixels",  sl_params->window_w);
	cvEndWriteStruct(fs);

	// Close file storage for XML-formatted configuration file.
	cvReleaseFileStorage(&fs);
}