int CvArrTest::write_default_params( CvFileStorage* fs ) { int code = CvTest::write_default_params( fs ); if( code < 0 ) return code; if( ts->get_testing_mode() == CvTS::CORRECTNESS_CHECK_MODE ) { write_param( fs, "test_case_count", test_case_count ); write_param( fs, "min_log_array_size", min_log_array_size ); write_param( fs, "max_log_array_size", max_log_array_size ); } else if( ts->get_testing_mode() == CvTS::TIMING_MODE ) { int i; start_write_param( fs ); // make sure we have written the entry header containing the test name if( size_list ) { cvStartWriteStruct( fs, "size", CV_NODE_SEQ+CV_NODE_FLOW ); for( i = 0; size_list[i].width >= 0; i++ ) { cvStartWriteStruct( fs, 0, CV_NODE_SEQ+CV_NODE_FLOW ); cvWriteInt( fs, 0, size_list[i].width ); cvWriteInt( fs, 0, size_list[i].height ); if( whole_size_list && (whole_size_list[i].width > size_list[i].width || whole_size_list[i].height > size_list[i].height) ) { cvWriteInt( fs, 0, whole_size_list[i].width ); cvWriteInt( fs, 0, whole_size_list[i].height ); } cvEndWriteStruct( fs ); } cvEndWriteStruct(fs); } if( depth_list ) { cvStartWriteStruct( fs, "depth", CV_NODE_SEQ+CV_NODE_FLOW ); for( i = 0; depth_list[i] >= 0; i++ ) cvWriteString( fs, 0, cvTsGetTypeName(depth_list[i]) ); cvEndWriteStruct(fs); } write_int_list( fs, "channels", cn_list, -1, -1 ); if( optional_mask ) { static const int use_mask[] = { 0, 1 }; write_int_list( fs, "use_mask", use_mask, 2 ); } } return 0; }
/** function save data to xml file * xml file is in path data/config.xml */ void save_settings(void){ CvFileStorage* fs=cvOpenFileStorage("data/config.xml", 0,CV_STORAGE_WRITE); //save color char buffer[64]; for(int i=0; i <=10; i++) { sprintf(buffer,"color_key_%d",i); cvWriteString( fs, buffer, color_key[i] ); } cvWriteInt( fs, "treshold", treshold); cvWriteInt( fs, "filter_min", filter[0]); cvWriteInt( fs, "filter_max", filter[1]); cvReleaseFileStorage( &fs); }
/* * Sets up the WriteToDisk given the base of a filname. * Creates a WriteOut Object. * * e.g. if you want to create a files named myexperiment.yaml and myexperiment.mov * pass in the string "myexperiment" * */ WriteOut* SetUpWriteToDisk(const char* dirfilename, const char* outfilename, CvMemStorage* Mem){ /** Create new instance of WriteOut object **/ WriteOut* DataWriter = CreateDataWriter(); /** Create Filenames **/ char* YAMLDataFileName = CreateFileName(dirfilename, outfilename, ".yaml"); /** Open YAML Data File for writing**/ DataWriter->fs=cvOpenFileStorage(YAMLDataFileName,Mem,CV_STORAGE_WRITE); if (DataWriter->fs==0) { printf("DataWriter->fs is zero! Could you have specified the wrong directory?\n"); --(DataWriter->error); } /** If there were errors, return immediately **/ if (DataWriter->error < 0) return DataWriter; /** Write the header for the YAML data file **/ cvWriteComment(DataWriter->fs, "Remote Control Worm Experiment Data Log\nMade by OpticalMindControl software\[email protected]\n",0); cvWriteString(DataWriter->fs, "gitHash", build_git_sha,0); cvWriteString(DataWriter->fs, "gitBuildTime",build_git_time,0); /** Write Out Current Time**/ struct tm *local; time_t t; t = time(NULL); local = localtime(&t); cvWriteString(DataWriter->fs, "ExperimentTime",asctime(local),0); DataWriter->filename=YAMLDataFileName; return DataWriter; }
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); }
void KITECH_HSVColorRecognitionComp::SetDataToDB(const char* database) { char str[256]; CvFileStorage *fs = cvOpenFileStorage(database, 0, CV_STORAGE_WRITE); cvWriteInt(fs, "color_count", (int)_colorRange.size()); for( int i = 0 ; i < (int)_colorRange.size() ; i++ ) { sprintf(str, "color%d", i); cvStartWriteStruct(fs, str, CV_NODE_SEQ); cvWriteString( fs, 0, _colorRange[i].name.c_str() ); cvWriteInt( fs, 0, _colorRange[i].min1 ); cvWriteInt( fs, 0, _colorRange[i].max1 ); cvWriteInt( fs, 0, _colorRange[i].min2 ); cvWriteInt( fs, 0, _colorRange[i].max2 ); cvWriteInt( fs, 0, _colorRange[i].min3 ); cvWriteInt( fs, 0, _colorRange[i].max3 ); cvEndWriteStruct(fs); } cvReleaseFileStorage(&fs); }
void SaveAll() { int ObjNum = m_TrackList.GetBlobNum(); int i; char video_name[1024+1]; char* struct_name = NULL; CvFileStorage* storage = cvOpenFileStorage(m_pFileName,NULL,CV_STORAGE_WRITE_TEXT); if(storage==NULL) { printf("WARNING!!! Cannot open %s file for trajectory output.", m_pFileName); } for(i=0; i<1024 && m_pFileName[i]!='.' && m_pFileName[i]!=0; ++i) video_name[i]=m_pFileName[i]; video_name[i] = 0; for(;i>0; i--) { if(video_name[i-1] == '\\') break; if(video_name[i-1] == '/') break; if(video_name[i-1] == ':') break; } struct_name = video_name + i; cvStartWriteStruct(storage, struct_name, CV_NODE_SEQ); for(i=0; i<ObjNum; ++i) { char obj_name[1024]; DefBlobTrack* pTrack = (DefBlobTrack*)m_TrackList.GetBlob(i); if(pTrack==NULL) continue; sprintf(obj_name,"%s_obj%d",struct_name,i); cvStartWriteStruct(storage, NULL, CV_NODE_MAP); cvWriteInt(storage, "FrameBegin", pTrack->FrameBegin); cvWriteString(storage, "VideoObj", obj_name); cvEndWriteStruct( storage ); pTrack->Saved = 1; } cvEndWriteStruct( storage ); for(i=0;i<ObjNum;++i) { char obj_name[1024]; DefBlobTrack* pTrack = (DefBlobTrack*)m_TrackList.GetBlob(i); CvBlobSeq* pSeq = pTrack->pSeq; sprintf(obj_name,"%s_obj%d",struct_name,i); cvStartWriteStruct(storage, obj_name, CV_NODE_MAP); { /* Write position: */ int j; CvPoint2D32f p; cvStartWriteStruct(storage, "Pos", CV_NODE_SEQ|CV_NODE_FLOW); for(j=0;j<pSeq->GetBlobNum();++j) { CvBlob* pB = pSeq->GetBlob(j); p.x = pB->x/(m_Size.width-1); p.y = pB->y/(m_Size.height-1); cvWriteRawData(storage, &p, 1 ,"ff"); } cvEndWriteStruct( storage ); } { /* Write size: */ int j; CvPoint2D32f p; cvStartWriteStruct(storage, "Size", CV_NODE_SEQ|CV_NODE_FLOW); for(j=0; j<pSeq->GetBlobNum(); ++j) { CvBlob* pB = pSeq->GetBlob(j); p.x = pB->w/(m_Size.width-1); p.y = pB->h/(m_Size.height-1); cvWriteRawData(storage, &p, 1 ,"ff"); } cvEndWriteStruct( storage ); } cvEndWriteStruct( storage ); } cvReleaseFileStorage(&storage); } /* Save All */
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 ); }
void FrameProcessor::saveConfig() { #if CV_MAJOR_VERSION < 4 CvFileStorage* fs = cvOpenFileStorage("./config/FrameProcessor.xml", 0, CV_STORAGE_WRITE); cvWriteString(fs, "tictoc", tictoc.c_str()); cvWriteInt(fs, "enablePreProcessor", enablePreProcessor); cvWriteInt(fs, "enableForegroundMaskAnalysis", enableForegroundMaskAnalysis); cvWriteInt(fs, "enableFrameDifference", enableFrameDifference); cvWriteInt(fs, "enableStaticFrameDifference", enableStaticFrameDifference); cvWriteInt(fs, "enableWeightedMovingMean", enableWeightedMovingMean); cvWriteInt(fs, "enableWeightedMovingVariance", enableWeightedMovingVariance); #if CV_MAJOR_VERSION == 2 cvWriteInt(fs, "enableMixtureOfGaussianV1", enableMixtureOfGaussianV1); #endif cvWriteInt(fs, "enableMixtureOfGaussianV2", enableMixtureOfGaussianV2); cvWriteInt(fs, "enableAdaptiveBackgroundLearning", enableAdaptiveBackgroundLearning); #if CV_MAJOR_VERSION == 2 && CV_MINOR_VERSION >= 4 && CV_SUBMINOR_VERSION >= 3 cvWriteInt(fs, "enableGMG", enableGMG); #endif #if CV_MAJOR_VERSION >= 3 cvWriteInt(fs, "enableKNN", enableKNN); #endif cvWriteInt(fs, "enableDPAdaptiveMedian", enableDPAdaptiveMedian); cvWriteInt(fs, "enableDPGrimsonGMM", enableDPGrimsonGMM); cvWriteInt(fs, "enableDPZivkovicAGMM", enableDPZivkovicAGMM); cvWriteInt(fs, "enableDPMean", enableDPMean); cvWriteInt(fs, "enableDPWrenGA", enableDPWrenGA); cvWriteInt(fs, "enableDPPratiMediod", enableDPPratiMediod); cvWriteInt(fs, "enableDPEigenbackground", enableDPEigenbackground); cvWriteInt(fs, "enableDPTexture", enableDPTexture); cvWriteInt(fs, "enableT2FGMM_UM", enableT2FGMM_UM); cvWriteInt(fs, "enableT2FGMM_UV", enableT2FGMM_UV); cvWriteInt(fs, "enableT2FMRF_UM", enableT2FMRF_UM); cvWriteInt(fs, "enableT2FMRF_UV", enableT2FMRF_UV); cvWriteInt(fs, "enableFuzzySugenoIntegral", enableFuzzySugenoIntegral); cvWriteInt(fs, "enableFuzzyChoquetIntegral", enableFuzzyChoquetIntegral); cvWriteInt(fs, "enableLBSimpleGaussian", enableLBSimpleGaussian); cvWriteInt(fs, "enableLBFuzzyGaussian", enableLBFuzzyGaussian); cvWriteInt(fs, "enableLBMixtureOfGaussians", enableLBMixtureOfGaussians); cvWriteInt(fs, "enableLBAdaptiveSOM", enableLBAdaptiveSOM); cvWriteInt(fs, "enableLBFuzzyAdaptiveSOM", enableLBFuzzyAdaptiveSOM); cvWriteInt(fs, "enableLbpMrf", enableLbpMrf); cvWriteInt(fs, "enableMultiLayer", enableMultiLayer); cvWriteInt(fs, "enablePBAS", enablePBAS); cvWriteInt(fs, "enableVuMeter", enableVuMeter); cvWriteInt(fs, "enableKDE", enableKDE); cvWriteInt(fs, "enableIMBS", enableIMBS); cvWriteInt(fs, "enableMultiCue", enableMultiCue); cvWriteInt(fs, "enableSigmaDelta", enableSigmaDelta); cvWriteInt(fs, "enableSuBSENSE", enableSuBSENSE); cvWriteInt(fs, "enableLOBSTER", enableLOBSTER); cvWriteInt(fs, "enablePAWCS", enablePAWCS); cvWriteInt(fs, "enableTwoPoints", enableTwoPoints); cvWriteInt(fs, "enableViBe", enableViBe); cvWriteInt(fs, "enableCodeBook", enableCodeBook); cvReleaseFileStorage(&fs); #endif }
// 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); }