//存储训练结果 void storeTrainingData() { CvFileStorage * fileStorage; int i; fileStorage = cvOpenFileStorage( "facedata.xml", 0, CV_STORAGE_WRITE ); //存储特征值,投影矩阵,平均矩阵等训练结果 cvWriteInt( fileStorage, "nEigens", nEigens ); cvWriteInt( fileStorage, "nTrainFaces", nTrainFaces ); cvWrite(fileStorage, "trainPersonNumMat", personNumTruthMat, cvAttrList(0,0)); cvWrite(fileStorage, "eigenValMat", eigenValMat, cvAttrList(0,0)); cvWrite(fileStorage, "projectedTrainFaceMat", projectedTrainFaceMat, cvAttrList(0,0)); cvWrite(fileStorage, "avgTrainImg", pAvgTrainImg, cvAttrList(0,0)); for(i=0; i<nEigens; i++) { char varname[200]; sprintf( varname, "eigenVect_%d", i ); cvWrite(fileStorage, varname, eigenVectArr[i], cvAttrList(0,0)); } cvReleaseFileStorage( &fileStorage ); }
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; }
// Save the training data to the file 'facedata.xml'. void storeTrainingData() { CvFileStorage * fileStorage; int i; // create a file-storage interface fileStorage = cvOpenFileStorage( facedata, 0, CV_STORAGE_WRITE ); // Store the person names. Added by Shervin. cvWriteInt( fileStorage, "nPersons", nPersons ); for (i=0; i<nPersons; i++) { char varname[200]; sprintf( varname, "personName_%d", (i+1) ); cvWriteString(fileStorage, varname, personNames[i].c_str(), 0); } // store all the data cvWriteInt( fileStorage, "nEigens", nEigens ); cvWriteInt( fileStorage, "nTrainFaces", nTrainFaces ); cvWrite(fileStorage, "trainPersonNumMat", personNumTruthMat, cvAttrList(0,0)); cvWrite(fileStorage, "eigenValMat", eigenValMat, cvAttrList(0,0)); cvWrite(fileStorage, "projectedTrainFaceMat", projectedTrainFaceMat, cvAttrList(0,0)); cvWrite(fileStorage, "avgTrainImg", pAvgTrainImg, cvAttrList(0,0)); for(i=0; i<nEigens; i++) { char varname[200]; sprintf( varname, "eigenVect_%d", i ); cvWrite(fileStorage, varname, eigenVectArr[i], cvAttrList(0,0)); } // release the file-storage interface cvReleaseFileStorage( &fileStorage ); }
void SaveFeature( FEATURE* feature, char* fileName){ CvFileStorage* fs = cvOpenFileStorage( fileName, 0, CV_STORAGE_WRITE, NULL); if (fs==NULL){ fprintf(stderr, "can't open feature file\n"); return; } cvWriteInt(fs, "radius", feature->radius); cvWriteInt(fs, "neighbors", feature->neighbors); cvWriteInt(fs, "grid_x", feature->grid_x); cvWriteInt(fs, "grid_y", feature->grid_y); cvWriteInt(fs, "num_faces", feature->num_faces); char faceid[1024]; char id[1024]; for (int i=0; i<feature->num_faces; i++){ strcpy(faceid, "face-"); sprintf(id, "%d", i); strcat(faceid, id); cvWrite( fs, faceid, feature->histogram[i], cvAttrList(0,0) ); } if (HUELBP_ON){ for (int i=0; i<feature->num_faces; i++){ strcpy(faceid, "hue-face-"); sprintf(id, "%d", i); strcat(faceid, id); cvWrite( fs, faceid, feature->hue_histogram[i], cvAttrList(0,0) ); } } cvReleaseFileStorage( &fs ); }
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; }
/* * Write out to YAML the default grid size for non-protocol based illumination */ void WriteOutDefaultGridSize(WriteOut* DataWriter, WormAnalysisParam* Param){ /** Write out default grid size for non-protocol illumination **/ cvStartWriteStruct(DataWriter->fs,"DefaultGridSizeForNonProtocolIllum",CV_NODE_MAP,NULL); cvWriteInt(DataWriter->fs,"x",Param->DefaultGridSize.width); cvWriteInt(DataWriter->fs,"y",Param->DefaultGridSize.height); cvEndWriteStruct(DataWriter->fs); return; }
/** * Write out a Protocol to YAML file, given an initialized CvFileStorage */ void WriteProtocol(Protocol* myP, CvFileStorage* fs){ if (fs==0){ printf("fs is zero! Could you have specified the wrong directory?\n"); return; } /** Write out Protocol **/ cvStartWriteStruct(fs,"Protocol",CV_NODE_MAP,NULL); if (myP->Filename!=NULL) cvWriteString(fs,"Filename",myP->Filename); if (myP->Description!=NULL) cvWriteString(fs,"Description",myP->Description); cvStartWriteStruct(fs,"GridSize",CV_NODE_MAP,NULL); cvWriteInt(fs,"height",myP->GridSize.height); cvWriteInt(fs,"width",myP->GridSize.width); cvEndWriteStruct(fs); //printf("yo\n"); /** Write Out Steps **/ cvStartWriteStruct(fs,"Steps",CV_NODE_SEQ,NULL); int j; int jtot=myP->Steps->total; CvSeqReader StepReader; cvStartReadSeq(myP->Steps,&StepReader,0); for (j = 0; j < jtot; ++j) { //printf("About to write step number %d\n",j); CvSeq** CurrentMontagePtr = (CvSeq**) StepReader.ptr; CvSeq* CurrentMontage=*CurrentMontagePtr; assert(CurrentMontage!=NULL); // printf("ping\n"); // printf("CurrentMontage->total=%d",CurrentMontage->total); cvStartWriteStruct(fs,NULL,CV_NODE_SEQ,NULL); int k; int ktot=CurrentMontage->total; // printf("ktot=%d\n",ktot); CvSeqReader MontageReader; cvStartReadSeq(CurrentMontage,&MontageReader); for (k = 0; k < ktot; ++k) { // printf("About to write polygon number %d\n",k); WormPolygon** CurrentPolygonPtr= (WormPolygon**) MontageReader.ptr; WormPolygon* CurrentPolygon=*CurrentPolygonPtr; cvWrite(fs,NULL,CurrentPolygon->Points); CV_NEXT_SEQ_ELEM(CurrentMontage->elem_size,MontageReader); } CurrentMontagePtr=NULL; CurrentMontage=NULL; cvEndWriteStruct(fs); /** Loop to Next Step **/ CV_NEXT_SEQ_ELEM(myP->Steps->elem_size,StepReader); } cvEndWriteStruct(fs); cvEndWriteStruct(fs); }
void FrameDifferenceBGS::saveConfig() { CvFileStorage* fs = cvOpenFileStorage("E:\\yzbx_programe\\QT\\qt_bgslibrary\\config\\FrameDifferenceBGS.xml", 0, CV_STORAGE_WRITE); cvWriteInt(fs, "enableThreshold", enableThreshold); cvWriteInt(fs, "threshold", threshold); cvWriteInt(fs, "showOutput", showOutput); cvReleaseFileStorage(&fs); }
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); }
void StaticFrameDifferenceBGS::saveConfig() { CvFileStorage* fs = cvOpenFileStorage("../config/StaticFrameDifferenceBGS.xml", 0, CV_STORAGE_WRITE); cvWriteInt(fs, "enableThreshold", enableThreshold); cvWriteInt(fs, "threshold", threshold); cvWriteInt(fs, "showOutput", showOutput); cvReleaseFileStorage(&fs); }
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; }
void DPEigenbackgroundBGS::saveConfig() { CvFileStorage* fs = cvOpenFileStorage("./config/DPEigenbackgroundBGS.xml", 0, CV_STORAGE_WRITE); cvWriteInt(fs, "threshold", threshold); cvWriteInt(fs, "historySize", historySize); cvWriteInt(fs, "embeddedDim", embeddedDim); cvWriteInt(fs, "showOutput", showOutput); cvReleaseFileStorage(&fs); }
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__; }
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); }
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); }
void DPAdaptiveMedianBGS::saveConfig() { CvFileStorage* fs = cvOpenFileStorage("DPAdaptiveMedianBGS.xml", 0, CV_STORAGE_WRITE); cvWriteInt(fs, "threshold", threshold); cvWriteInt(fs, "samplingRate", samplingRate); cvWriteInt(fs, "learningFrames", learningFrames); cvWriteInt(fs, "showOutput", showOutput); cvReleaseFileStorage(&fs); }
void LBSimpleGaussian::saveConfig() { CvFileStorage* fs = cvOpenFileStorage("./config/LBSimpleGaussian.xml", 0, CV_STORAGE_WRITE); cvWriteInt(fs, "sensitivity", sensitivity); cvWriteInt(fs, "noiseVariance", noiseVariance); cvWriteInt(fs, "learningRate", learningRate); cvWriteInt(fs, "showOutput", showOutput); cvReleaseFileStorage(&fs); }
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); }
void PreProcessor::saveConfig() { #if CV_MAJOR_VERSION < 4 CvFileStorage* fs = cvOpenFileStorage("./config/PreProcessor.xml", 0, CV_STORAGE_WRITE); cvWriteInt(fs, "equalizeHist", equalizeHist); cvWriteInt(fs, "gaussianBlur", gaussianBlur); cvWriteInt(fs, "enableShow", enableShow); cvReleaseFileStorage(&fs); #endif }
void WeightedMovingMeanBGS::saveConfig() { CvFileStorage* fs = cvOpenFileStorage("./config/WeightedMovingMeanBGS.xml", 0, CV_STORAGE_WRITE); cvWriteInt(fs, "enableWeight", enableWeight); cvWriteInt(fs, "enableThreshold", enableThreshold); cvWriteInt(fs, "threshold", threshold); cvWriteInt(fs, "showOutput", showOutput); cvWriteInt(fs, "showBackground", showBackground); cvReleaseFileStorage(&fs); }
void DPPratiMediodBGS::saveConfig() { CvFileStorage* fs = cvOpenFileStorage("./config/DPPratiMediodBGS.xml", 0, CV_STORAGE_WRITE); cvWriteInt(fs, "threshold", threshold); cvWriteInt(fs, "samplingRate", samplingRate); cvWriteInt(fs, "historySize", historySize); cvWriteInt(fs, "weight", weight); cvWriteInt(fs, "showOutput", showOutput); cvReleaseFileStorage(&fs); }
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); }
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); }
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); }
/** 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); }
void WeightedMovingVarianceBGS::saveConfig() { string xmlDirectory = QCoreApplication::applicationDirPath().toStdString() + "//WeightedMovingVarianceBGS.xml"; const char *xmlDirect = xmlDirectory.c_str(); CvFileStorage* fs = cvOpenFileStorage(xmlDirect, 0, CV_STORAGE_WRITE); cvWriteInt(fs, "enableWeight", enableWeight); cvWriteInt(fs, "enableThreshold", enableThreshold); cvWriteInt(fs, "threshold", threshold); cvWriteInt(fs, "showOutput", showOutput); cvReleaseFileStorage(&fs); }
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); }
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); }
void PreProcessor::saveConfig() { #if defined(_WIN32) //CvFileStorage* fs = cvOpenFileStorage("F:\\Developer\\BGS\\AndrewsSobral\\bgslibrary\\config\\PreProcessor.xml", 0, CV_STORAGE_WRITE); CvFileStorage* fs = cvOpenFileStorage("config\\PreProcessor.xml", 0, CV_STORAGE_WRITE); #else CvFileStorage* fs = cvOpenFileStorage("./config/PreProcessor.xml", 0, CV_STORAGE_WRITE); #endif cvWriteInt(fs, "equalizeHist", equalizeHist); cvWriteInt(fs, "gaussianBlur", gaussianBlur); cvWriteInt(fs, "enableShow", enableShow); cvReleaseFileStorage(&fs); }
void IndependentMultimodalBGS::saveConfig() { CvFileStorage* fs = cvOpenFileStorage("./config/IndependentMultimodalBGS.xml", 0, CV_STORAGE_WRITE); cvWriteInt(fs, "showOutput", showOutput); cvReleaseFileStorage(&fs); }