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 PreProcessor::loadConfig() { #if defined(_WIN32) //CvFileStorage* fs = cvOpenFileStorage("F:\\Developer\\BGS\\AndrewsSobral\\bgslibrary\\config\\PreProcessor.xml", 0, CV_STORAGE_READ); CvFileStorage* fs = cvOpenFileStorage("config\\PreProcessor.xml", 0, CV_STORAGE_READ); #else CvFileStorage* fs = cvOpenFileStorage("./config/PreProcessor.xml", 0, CV_STORAGE_READ); #endif equalizeHist = cvReadIntByName(fs, 0, "equalizeHist", false); gaussianBlur = cvReadIntByName(fs, 0, "gaussianBlur", false); enableShow = cvReadIntByName(fs, 0, "enableShow", true); 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 ReadFeature( char* fileName, FEATURE* feature){ CvFileStorage* fs = cvOpenFileStorage( fileName, 0, CV_STORAGE_READ, NULL); if (fs==NULL){ fprintf(stderr, "can't open feature file!\n"); return; } feature->radius = cvReadIntByName(fs, NULL, "radius", RADIUS); feature->neighbors = cvReadIntByName(fs, NULL, "neighbors", NEIGHBORS); feature->grid_x = cvReadIntByName(fs, NULL, "grid_x", GRID_X); feature->grid_y = cvReadIntByName(fs, NULL, "grid_y", GRID_Y); feature->num_faces = cvReadIntByName(fs, NULL, "num_faces", 0); char faceid[1024]; char id[20]; feature->histogram = (CvMat**) malloc(feature->num_faces*sizeof(CvMat*)); for (int i=0; i<feature->num_faces; i++){ strcpy(faceid, "face-"); sprintf(id, "%d", i); strcat(faceid, id); feature->histogram[i] = cvReadByName(fs, NULL, faceid, NULL); } if (HUELBP_ON){ feature->hue_histogram = (CvMat**) malloc(feature->num_faces*sizeof(CvMat*)); for (int i=0; i<feature->num_faces; i++){ strcpy(faceid, "hue-face-"); sprintf(id, "%d", i); strcat(faceid, id); feature->hue_histogram[i] = cvReadByName(fs, NULL, faceid, NULL); } } cvReleaseFileStorage( &fs ); }
//加载保存过的训练结果 int loadTrainingData(CvMat ** pTrainPersonNumMat) { CvFileStorage * fileStorage; int i; fileStorage = cvOpenFileStorage( "facedata.xml", 0, CV_STORAGE_READ ); if( !fileStorage ) { fprintf(stderr, "Can't open facedata.xml\n"); return 0; } nEigens = cvReadIntByName(fileStorage, 0, "nEigens", 0); nTrainFaces = cvReadIntByName(fileStorage, 0, "nTrainFaces", 0); *pTrainPersonNumMat = (CvMat *)cvReadByName(fileStorage, 0, "trainPersonNumMat", 0); eigenValMat = (CvMat *)cvReadByName(fileStorage, 0, "eigenValMat", 0); projectedTrainFaceMat = (CvMat *)cvReadByName(fileStorage, 0, "projectedTrainFaceMat", 0); pAvgTrainImg = (IplImage *)cvReadByName(fileStorage, 0, "avgTrainImg", 0); eigenVectArr = (IplImage **)cvAlloc(nTrainFaces*sizeof(IplImage *)); for(i=0; i<nEigens; i++) { char varname[200]; sprintf( varname, "eigenVect_%d", i ); eigenVectArr[i] = (IplImage *)cvReadByName(fileStorage, 0, varname, 0); } cvReleaseFileStorage( &fileStorage ); return 1; }
void BlobTrackingNode::loadConfig() { 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("blobtrackingconfig.xml").toLocal8Bit(), 0, CV_STORAGE_READ); if(fs == NULL){ std::cout << "Error opening file"; minArea = 100; maxArea = 20000; debugTrack = false; debugBlob = false; showBlobMask= false; showOutput = false; return; } minArea = cvReadIntByName(fs, 0, "minArea", 100); maxArea = cvReadIntByName(fs, 0, "maxArea", 20000); debugTrack = cvReadIntByName(fs, 0, "debugTrack", false); debugBlob = cvReadIntByName(fs, 0, "debugBlob", false); showBlobMask = cvReadIntByName(fs, 0, "showBlobMask", true); showOutput = cvReadIntByName(fs, 0, "showOutput", true); cvReleaseFileStorage(&fs); }
int main(int argc, char** argv) { if (argc == 1) { printf("Usage: %s <input> <config>\n", argv[0]); return 0; } char* filename = (argc > 1 ? argv[1] : (char*)"input.jpg"); profile_name = (argc > 2 ? argv[2] : (char*)"blue_goal.yml"); fs = cvOpenFileStorage(profile_name, 0, CV_STORAGE_READ, NULL); Hmax = cvReadIntByName(fs, NULL, "m_100", m_100); Hmax = cvReadIntByName(fs, NULL, "Hmax", Hmax); Smax = cvReadIntByName(fs, NULL, "Smax", Smax); Vmax = cvReadIntByName(fs, NULL, "Vmax", Vmax); Hmin = cvReadIntByName(fs, NULL, "Hmin", Hmin); Smin = cvReadIntByName(fs, NULL, "Smin", Smin); Vmin = cvReadIntByName(fs, NULL, "Vmin", Vmin); //minH = cvReadIntByName(fs, NULL, "minH", minH); printf("%s\n", filename); img = cvLoadImage(filename, 1); visy_img_alloc(&img, cvGetSize(img), 8, 1); imgThreshed = cvCreateImage(cvGetSize(img), 8, 1); //cvSmooth( imgHSV, imgHSV, CV_GAUSSIAN, 7, 7 ); //cvInRangeS(imgHSV, cvScalar(20, 100, 100), cvScalar(30, 255, 255), imgThreshed); //cvInRangeS(imgHSV, cvScalar(100, 100, 100), cvScalar(120, 255, 255), imgThreshed); //cvInRangeS(imgHSV, cvScalar(0.11*256, 0.60*256, 0.20*256, 0), // cvScalar(0.14*256, 1.00*256, 1.00*256, 0), imgThreshed); cvNamedWindow("origin", CV_WINDOW_AUTOSIZE); cvNamedWindow("treshed", CV_WINDOW_AUTOSIZE); cvNamedWindow("graph", CV_WINDOW_AUTOSIZE); cvCreateTrackbar("m_100", "treshed", &m_100, 255, onTrack); cvCreateTrackbar("Hmin", "treshed", &Hmin, 180, onTrack); cvCreateTrackbar("Smin", "treshed", &Smin, 255, onTrack); cvCreateTrackbar("Vmin", "treshed", &Vmin, 255, onTrack); cvCreateTrackbar("Hmax", "treshed", &Hmax, 180, onTrack); cvCreateTrackbar("Smax", "treshed", &Smax, 255, onTrack); cvCreateTrackbar("Vmax", "treshed", &Vmax, 255, onTrack); //cvCreateTrackbar("minH", "treshed", &minH, 255, onTrack); onTrack(0); //cvSaveImage("hsv.jpg", imgHSV); while(cvWaitKey(0) != 97); return 0; }
int main (int argc, char *argv[]) { IplImage *img; CvFileStorage *fs; CvSeq* seq; CvMemStorage *str; int N,i; parse_args(argc,argv); str = cvCreateMemStorage(0); img = cvCreateImage(cvSize(WIDTH,HEIGHT), 8, 3); cvZero(img); fs = cvOpenFileStorage(infile, str, CV_STORAGE_READ, NULL); assert(fs); N = cvReadIntByName(fs, NULL, "N", 0); seq = cvReadByName(fs, NULL, "seq", 0); printf("N=%d\n", N); for (i=0; i<seq->total; i++) { CvPoint p; p = *(CvPoint*)cvGetSeqElem(seq, i); cvCircle(img, p, R, CV_RGB(255,0,0), -1, 8, 0); } cvShowImage("proto", img); cvWaitKey(0); cvReleaseFileStorage(&fs); cvReleaseImage(&img); 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 BlobTrackingNode::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("blobtrackingconfig.xml").toLocal8Bit(), 0, CV_STORAGE_WRITE); if(fs == NULL){ return; } cvWriteInt(fs, "minArea", minArea); cvWriteInt(fs, "maxArea", maxArea); cvWriteInt(fs, "debugTrack", debugTrack); cvWriteInt(fs, "debugBlob", debugBlob); cvWriteInt(fs, "showBlobMask", showBlobMask); cvWriteInt(fs, "showOutput", showOutput); cvReleaseFileStorage(&fs); }
//存储训练结果 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 ); }
void GazeTracker::load() { CvFileStorage *in = cvOpenFileStorage("calibration.xml", NULL, CV_STORAGE_READ); CvFileNode *root = cvGetRootFileNode(in); load(in, cvGetFileNodeByName(in, root, "GazeTracker")); cvReleaseFileStorage(&in); updateGaussianProcesses(); }
CvMat * icvReadSVHNLabels(char * filename, const int max_samples) { CvFileStorage * fs = cvOpenFileStorage(filename,0,CV_STORAGE_READ); if (!fs){fprintf(stderr,"file loading error: %s\n",filename);return 0;} CvFileNode * fnode = cvGetRootFileNode(fs); char tagname[20]; int ii; const int nparams = 4; CvMat * data = cvCreateMat(max_samples,1+nparams*10,CV_32S); cvZero(data); for (ii=0;;ii++){ sprintf(tagname,"img%d",ii+1); CvMat * sample = (CvMat*)cvReadByName(fs,fnode,tagname); if (!sample || ii==max_samples){break;} int nnumbers = sample->rows; CV_MAT_ELEM(*data,int,ii,0)=nnumbers; for (int jj=0;jj<nnumbers;jj++){ float xx = CV_MAT_ELEM(*sample,float,jj,0); float yy = CV_MAT_ELEM(*sample,float,jj,1); float ww = CV_MAT_ELEM(*sample,float,jj,2); float hh = CV_MAT_ELEM(*sample,float,jj,3); float ll = CV_MAT_ELEM(*sample,float,jj,4); CV_MAT_ELEM(*data,int,ii,1+nparams*jj+0)=cvRound(xx+ww*.5f); // x CV_MAT_ELEM(*data,int,ii,1+nparams*jj+1)=cvRound(yy+hh*.5f); // y CV_MAT_ELEM(*data,int,ii,1+nparams*jj+2)=cvRound(MAX(ww,hh)); // scale CV_MAT_ELEM(*data,int,ii,1+nparams*jj+3)=cvRound(ll); // label } cvReleaseMat(&sample); } data->rows = ii; cvReleaseFileStorage(&fs); return data; }
////////////////////////////////// // loadTrainingData() // int EigenFace::loadTrainingData() { LOGD("load from %s", mTrainingDataFile); CvFileStorage * fileStorage; int i; // create a file-storage interface fileStorage = cvOpenFileStorage( mTrainingDataFile, 0, CV_STORAGE_READ ); if( !fileStorage ) { LOGE("Can't open facedata.xml\n"); return 0; } nEigens = cvReadIntByName(fileStorage, 0, "nEigens", 0); nTrainFaces = cvReadIntByName(fileStorage, 0, "nTrainFaces", 0); trainPersonNumMat = (CvMat *)cvReadByName(fileStorage, 0, "trainPersonNumMat", 0); eigenValMat = (CvMat *)cvReadByName(fileStorage, 0, "eigenValMat", 0); projectedTrainFaceMat = (CvMat *)cvReadByName(fileStorage, 0, "projectedTrainFaceMat", 0); pAvgTrainImg = (IplImage *)cvReadByName(fileStorage, 0, "avgTrainImg", 0); eigenVectArr = (IplImage **)cvAlloc(nTrainFaces*sizeof(IplImage *)); for(i=0; i<nEigens; i++) { char varname[200]; sprintf( varname, "eigenVect_%d", i ); eigenVectArr[i] = (IplImage *)cvReadByName(fileStorage, 0, varname, 0); } // release the file-storage interface cvReleaseFileStorage( &fileStorage ); return 1; }
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 EntropyOfEntropyArea::loadConfig(){ CvFileStorage* fs1 = cvOpenFileStorage("./Config/ImageResize.xml", 0, CV_STORAGE_READ); CvFileStorage* fs2 = cvOpenFileStorage("./Config/EntropyOfEntropyArea.xml", 0, CV_STORAGE_READ); entropyAreaSize = cvReadIntByName(fs1, 0, "entropyAreaSize", 3); monitorAreaSize = cvReadIntByName(fs1, 0, "monitorAreaSize", 3); windowWidth = cvReadIntByName(fs2, 0, "windowWidth", 5); grayLevel = cvReadIntByName(fs2, 0, "grayLevel", 6); C0 = cvReadRealByName(fs2, 0, "C0", 0.05); learningRate = cvReadRealByName(fs2, 0, "learningRate", 0.7); deltaENToOldENRatioEntropy = cvReadRealByName(fs2, 0, "deltaENToOldENRatioEntropy", 0.1); staticRatioEntropy = cvReadRealByName(fs2, 0, "staticRatioEntropy", 0.7); cvReleaseFileStorage(&fs1); cvReleaseFileStorage(&fs2); }
void LbpMrf::loadConfig() { CvFileStorage* fs = cvOpenFileStorage("./config/LbpMrf.xml", 0, CV_STORAGE_READ); showOutput = cvReadIntByName(fs, 0, "showOutput", true); cvReleaseFileStorage(&fs); }
void IndependentMultimodalBGS::saveConfig() { CvFileStorage* fs = cvOpenFileStorage("./config/IndependentMultimodalBGS.xml", 0, CV_STORAGE_WRITE); cvWriteInt(fs, "showOutput", showOutput); cvReleaseFileStorage(&fs); }
void IndependentMultimodalBGS::loadConfig() { CvFileStorage* fs = cvOpenFileStorage("./config/IndependentMultimodalBGS.xml", 0, CV_STORAGE_READ); showOutput = cvReadIntByName(fs, 0, "showOutput", true); cvReleaseFileStorage(&fs); }
void LbpMrf::saveConfig() { CvFileStorage* fs = cvOpenFileStorage("./config/LbpMrf.xml", 0, CV_STORAGE_WRITE); cvWriteInt(fs, "showOutput", showOutput); cvReleaseFileStorage(&fs); }
void FrameProcessor::saveConfig() { 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, "enableFrameDifferenceBGS", enableFrameDifferenceBGS); cvWriteInt(fs, "enableStaticFrameDifferenceBGS", enableStaticFrameDifferenceBGS); cvWriteInt(fs, "enableWeightedMovingMeanBGS", enableWeightedMovingMeanBGS); cvWriteInt(fs, "enableWeightedMovingVarianceBGS", enableWeightedMovingVarianceBGS); cvWriteInt(fs, "enableMixtureOfGaussianV1BGS", enableMixtureOfGaussianV1BGS); cvWriteInt(fs, "enableMixtureOfGaussianV2BGS", enableMixtureOfGaussianV2BGS); cvWriteInt(fs, "enableAdaptiveBackgroundLearning", enableAdaptiveBackgroundLearning); #if CV_MAJOR_VERSION >= 2 && CV_MINOR_VERSION >= 4 && CV_SUBMINOR_VERSION >= 3 cvWriteInt(fs, "enableGMG", enableGMG); #endif cvWriteInt(fs, "enableDPAdaptiveMedianBGS", enableDPAdaptiveMedianBGS); cvWriteInt(fs, "enableDPGrimsonGMMBGS", enableDPGrimsonGMMBGS); cvWriteInt(fs, "enableDPZivkovicAGMMBGS", enableDPZivkovicAGMMBGS); cvWriteInt(fs, "enableDPMeanBGS", enableDPMeanBGS); cvWriteInt(fs, "enableDPWrenGABGS", enableDPWrenGABGS); cvWriteInt(fs, "enableDPPratiMediodBGS", enableDPPratiMediodBGS); cvWriteInt(fs, "enableDPEigenbackgroundBGS", enableDPEigenbackgroundBGS); cvWriteInt(fs, "enableDPTextureBGS", enableDPTextureBGS); 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, "enableMultiLayerBGS", enableMultiLayerBGS); //cvWriteInt(fs, "enablePBAS", enablePBAS); cvWriteInt(fs, "enableVuMeter", enableVuMeter); cvWriteInt(fs, "enableKDE", enableKDE); cvWriteInt(fs, "enableIMBS", enableIMBS); cvWriteInt(fs, "enableMultiCueBGS", enableMultiCueBGS); cvWriteInt(fs, "enableSigmaDeltaBGS", enableSigmaDeltaBGS); cvWriteInt(fs, "enableSuBSENSEBGS", enableSuBSENSEBGS); cvWriteInt(fs, "enableLOBSTERBGS", enableLOBSTERBGS); cvReleaseFileStorage(&fs); }
void ForegroundMaskAnalysis::loadConfig() { CvFileStorage* fs = cvOpenFileStorage("./config/ForegroundMaskAnalysis.xml", 0, CV_STORAGE_READ); stopAt = cvReadIntByName(fs, 0, "stopAt", 0); img_ref_path = cvReadStringByName(fs, 0, "img_ref_path", ""); cvReleaseFileStorage(&fs); }
void ForegroundMaskAnalysis::saveConfig() { CvFileStorage* fs = cvOpenFileStorage("./config/ForegroundMaskAnalysis.xml", 0, CV_STORAGE_WRITE); cvWriteInt(fs, "stopAt", stopAt); cvWriteString(fs, "img_ref_path", img_ref_path.c_str()); cvReleaseFileStorage(&fs); }
void save_sequence (const char *file, ptseq seq, int N) { CvFileStorage *fs; fs = cvOpenFileStorage(file, NULL, CV_STORAGE_WRITE, NULL); cvWriteInt(fs, "N", N); cvWrite(fs, "seq", seq.ptr, cvAttrList(0,0)); cvReleaseFileStorage(&fs); }
void FrameProcessor::loadConfig() { CvFileStorage* fs = cvOpenFileStorage("./config/FrameProcessor.xml", 0, CV_STORAGE_READ); tictoc = cvReadStringByName(fs, 0, "tictoc", ""); enablePreProcessor = cvReadIntByName(fs, 0, "enablePreProcessor", true); enableForegroundMaskAnalysis = cvReadIntByName(fs, 0, "enableForegroundMaskAnalysis", false); enableFrameDifferenceBGS = cvReadIntByName(fs, 0, "enableFrameDifferenceBGS", false); enableStaticFrameDifferenceBGS = cvReadIntByName(fs, 0, "enableStaticFrameDifferenceBGS", false); enableWeightedMovingMeanBGS = cvReadIntByName(fs, 0, "enableWeightedMovingMeanBGS", false); enableWeightedMovingVarianceBGS = cvReadIntByName(fs, 0, "enableWeightedMovingVarianceBGS", false); enableMixtureOfGaussianV1BGS = cvReadIntByName(fs, 0, "enableMixtureOfGaussianV1BGS", false); enableMixtureOfGaussianV2BGS = cvReadIntByName(fs, 0, "enableMixtureOfGaussianV2BGS", false); enableAdaptiveBackgroundLearning = cvReadIntByName(fs, 0, "enableAdaptiveBackgroundLearning", false); #if CV_MAJOR_VERSION >= 2 && CV_MINOR_VERSION >= 4 && CV_SUBMINOR_VERSION >= 3 enableGMG = cvReadIntByName(fs, 0, "enableGMG", false); #endif enableDPAdaptiveMedianBGS = cvReadIntByName(fs, 0, "enableDPAdaptiveMedianBGS", false); enableDPGrimsonGMMBGS = cvReadIntByName(fs, 0, "enableDPGrimsonGMMBGS", false); enableDPZivkovicAGMMBGS = cvReadIntByName(fs, 0, "enableDPZivkovicAGMMBGS", false); enableDPMeanBGS = cvReadIntByName(fs, 0, "enableDPMeanBGS", false); enableDPWrenGABGS = cvReadIntByName(fs, 0, "enableDPWrenGABGS", false); enableDPPratiMediodBGS = cvReadIntByName(fs, 0, "enableDPPratiMediodBGS", false); enableDPEigenbackgroundBGS = cvReadIntByName(fs, 0, "enableDPEigenbackgroundBGS", false); enableDPTextureBGS = cvReadIntByName(fs, 0, "enableDPTextureBGS", false); enableT2FGMM_UM = cvReadIntByName(fs, 0, "enableT2FGMM_UM", false); enableT2FGMM_UV = cvReadIntByName(fs, 0, "enableT2FGMM_UV", false); enableT2FMRF_UM = cvReadIntByName(fs, 0, "enableT2FMRF_UM", false); enableT2FMRF_UV = cvReadIntByName(fs, 0, "enableT2FMRF_UV", false); enableFuzzySugenoIntegral = cvReadIntByName(fs, 0, "enableFuzzySugenoIntegral", false); enableFuzzyChoquetIntegral = cvReadIntByName(fs, 0, "enableFuzzyChoquetIntegral", false); enableLBSimpleGaussian = cvReadIntByName(fs, 0, "enableLBSimpleGaussian", false); enableLBFuzzyGaussian = cvReadIntByName(fs, 0, "enableLBFuzzyGaussian", false); enableLBMixtureOfGaussians = cvReadIntByName(fs, 0, "enableLBMixtureOfGaussians", false); enableLBAdaptiveSOM = cvReadIntByName(fs, 0, "enableLBAdaptiveSOM", false); enableLBFuzzyAdaptiveSOM = cvReadIntByName(fs, 0, "enableLBFuzzyAdaptiveSOM", false); enableLbpMrf = cvReadIntByName(fs, 0, "enableLbpMrf", false); enableMultiLayerBGS = cvReadIntByName(fs, 0, "enableMultiLayerBGS", false); //enablePBAS = cvReadIntByName(fs, 0, "enablePBAS", false); enableVuMeter = cvReadIntByName(fs, 0, "enableVuMeter", false); enableKDE = cvReadIntByName(fs, 0, "enableKDE", false); enableIMBS = cvReadIntByName(fs, 0, "enableIMBS", false); enableMultiCueBGS = cvReadIntByName(fs, 0, "enableMultiCueBGS", false); enableSigmaDeltaBGS = cvReadIntByName(fs, 0, "enableSigmaDeltaBGS", false); enableSuBSENSEBGS = cvReadIntByName(fs, 0, "enableSuBSENSEBGS", false); enableLOBSTERBGS = cvReadIntByName(fs, 0, "enableLOBSTERBGS", false); cvReleaseFileStorage(&fs); }
// Open the training data from the file 'facedata.xml'. int loadTrainingData(CvMat ** pTrainPersonNumMat) { CvFileStorage * fileStorage; int i; // create a file-storage interface fileStorage = cvOpenFileStorage( facedata, 0, CV_STORAGE_READ ); if( !fileStorage ) { printf("Can't open training database file 'facedata.xml'.\n"); return 0; } // Load the person names. Added by Shervin. personNames.clear(); // Make sure it starts as empty. nPersons = cvReadIntByName( fileStorage, 0, "nPersons", 0 ); if (nPersons == 0) { printf("No people found in the training database 'facedata.xml'.\n"); return 0; } // Load each person's name. for (i=0; i<nPersons; i++) { string sPersonName; char varname[200]; sprintf( varname, "personName_%d", (i+1) ); sPersonName = cvReadStringByName(fileStorage, 0, varname ); personNames.push_back( sPersonName ); } // Load the data nEigens = cvReadIntByName(fileStorage, 0, "nEigens", 0); nTrainFaces = cvReadIntByName(fileStorage, 0, "nTrainFaces", 0); *pTrainPersonNumMat = (CvMat *)cvReadByName(fileStorage, 0, "trainPersonNumMat", 0); eigenValMat = (CvMat *)cvReadByName(fileStorage, 0, "eigenValMat", 0); projectedTrainFaceMat = (CvMat *)cvReadByName(fileStorage, 0, "projectedTrainFaceMat", 0); pAvgTrainImg = (IplImage *)cvReadByName(fileStorage, 0, "avgTrainImg", 0); eigenVectArr = (IplImage **)cvAlloc(nTrainFaces*sizeof(IplImage *)); for(i=0; i<nEigens; i++) { char varname[200]; sprintf( varname, "eigenVect_%d", i ); eigenVectArr[i] = (IplImage *)cvReadByName(fileStorage, 0, varname, 0); } // release the file-storage interface cvReleaseFileStorage( &fileStorage ); printf("Training data loaded (%d training images of %d people):\n", nTrainFaces, nPersons); printf("People: "); if (nPersons > 0) printf("<%s>", personNames[0].c_str()); for (i=1; i<nPersons; i++) { printf(", <%s>", personNames[i].c_str()); } printf(".\n"); return 1; }
int main (int argc, char **argv) { char filename[] = "save_cv.xml"; // file name int i,j,k; CvFileStorage *cvfs; CvFileNode *node, *fn; CvSeq *s; int total; // (1)memory space for loading data int a; float b; CvMat** mat = (CvMat**)cvAlloc(3*sizeof(CvMat*)); // (2)open file storage cvfs = cvOpenFileStorage(filename, NULL, CV_STORAGE_READ); // (3)read data from file storage node = cvGetFileNodeByName(cvfs, NULL, ""); // Get Top Node a = cvReadIntByName(cvfs, node, "a", 0); b = cvReadRealByName(cvfs, node, "b", 0); fn = cvGetFileNodeByName(cvfs,node,"mat_array"); s = fn->data.seq; total = s->total; for(i=0;i<total;i++){ mat[i] = (CvMat*)cvRead(cvfs,(CvFileNode*)cvGetSeqElem(s,i), NULL); } // (4)close file storage cvReleaseFileStorage(&cvfs); // (5)print loaded data printf("a:%d\n", a); printf("b:%f\n", b); for(i=0; i<3; i++){ printf("mat%d:\n",i); for(j=0;j<mat[i]->rows;j++){ for(k=0;k<mat[i]->cols;k++){ printf("%f,",cvmGet(mat[i],j,k)); } printf("\n"); } } // release mat for(i=0; i<3; i++){ cvReleaseMat(mat+i); } cvFree(mat); return 0; }
/*! \fn CvBinGabAdaFeatureSelect::loadweaks(const char* filename) */ void CvBinGabAdaFeatureSelect::loadweaks(const char* filename) { //clear(); { delete new_pool; weaks.clear(); } CvMemStorage* fstorage = cvCreateMemStorage( 0 ); CvFileStorage *fs; fs = cvOpenFileStorage( filename, fstorage, CV_STORAGE_READ ); CvFileNode *root = cvGetRootFileNode( fs, 0); char *weakname = new char[20]; int i = 0; CvMemStorage* storage = cvCreateMemStorage(0); CvSeq* seq = cvCreateSeq(0, sizeof(CvSeq), sizeof(CvGaborTree), storage ); while(1) { sprintf( weakname, "weak_%d", i); CvFileNode *weaknode = cvGetFileNodeByName( fs, root, weakname); if (!weaknode) break; CvGaborTree tree; weaknode2tree(weaknode, fs, &tree); cvSeqPush( seq, &tree ); i++; } /* from squence to vector weaks*/ new_pool = new CvGaborFeaturePool; for (int i = 0; i <seq->total; i++) { CvGaborTree *atree = (CvGaborTree*)cvGetSeqElem(seq, i); CvWeakLearner *weak = new CvWeakLearner; weak->setType( weaklearner_type ); weak->setthreshold(atree->threshold); weak->setparity(atree->parity); weaks.push_back(*weak); CvGaborFeature *feature = new CvGaborFeature(atree->x, atree->y, atree->Mu, atree->Nu); new_pool->add(feature); alphas.push_back(atree->alpha); delete weak; delete feature; } cvReleaseMemStorage( &storage ); cvReleaseFileStorage(&fs); cvReleaseMemStorage( &fstorage ); delete [] weakname; /* set member variables */ current = new_pool->getSize(); falsepositive = 0.0; nexpfeatures = new_pool->getSize(); nselecfeatures = new_pool->getSize(); printf(" %d weak classifiers have been loaded!\n", nselecfeatures); }
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); }
void StaticFrameDifferenceBGS::loadConfig() { CvFileStorage* fs = cvOpenFileStorage("../config/StaticFrameDifferenceBGS.xml", 0, CV_STORAGE_READ); enableThreshold = cvReadIntByName(fs, 0, "enableThreshold", true); threshold = cvReadIntByName(fs, 0, "threshold", 15); showOutput = cvReadIntByName(fs, 0, "showOutput", true); cvReleaseFileStorage(&fs); }