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__; }
void DPGrimsonGMMBGS::loadConfig() { CvFileStorage* fs = cvOpenFileStorage("./config/DPGrimsonGMMBGS.xml", 0, CV_STORAGE_READ); threshold = cvReadRealByName(fs, 0, "threshold", 9.0); alpha = cvReadRealByName(fs, 0, "alpha", 0.01); gaussians = cvReadIntByName(fs, 0, "gaussians", 3); showOutput = cvReadIntByName(fs, 0, "showOutput", true); cvReleaseFileStorage(&fs); }
void DPWrenGABGS::loadConfig() { CvFileStorage* fs = cvOpenFileStorage("./config/DPWrenGABGS.xml", 0, CV_STORAGE_READ); threshold = cvReadRealByName(fs, 0, "threshold", 12.25f); alpha = cvReadRealByName(fs, 0, "alpha", 0.005f); learningFrames = cvReadIntByName(fs, 0, "learningFrames", 30); showOutput = cvReadIntByName(fs, 0, "showOutput", true); cvReleaseFileStorage(&fs); }
void T2FGMM_UV::loadConfig() { CvFileStorage* fs = cvOpenFileStorage("./config/T2FGMM_UV.xml", 0, CV_STORAGE_READ); threshold = cvReadRealByName(fs, 0, "threshold", 9.0); alpha = cvReadRealByName(fs, 0, "alpha", 0.01); km = cvReadRealByName(fs, 0, "km", 1.5); kv = cvReadRealByName(fs, 0, "kv", 0.6); gaussians = cvReadIntByName(fs, 0, "gaussians", 3); showOutput = cvReadIntByName(fs, 0, "showOutput", true); cvReleaseFileStorage(&fs); }
void VuMeter::loadConfig() { CvFileStorage* fs = cvOpenFileStorage("./config/VuMeter.xml", 0, CV_STORAGE_READ); enableFilter = cvReadIntByName(fs, 0, "enableFilter", true); binSize = cvReadIntByName(fs, 0, "binSize", 8); alpha = cvReadRealByName(fs, 0, "alpha", 0.995); threshold = cvReadRealByName(fs, 0, "threshold", 0.03); showOutput = cvReadIntByName(fs, 0, "showOutput", true); cvReleaseFileStorage(&fs); }
void FuzzyChoquetIntegral::loadConfig() { CvFileStorage* fs = cvOpenFileStorage("../config/FuzzyChoquetIntegral.xml", 0, CV_STORAGE_READ); showOutput = cvReadIntByName(fs, 0, "showOutput", true); framesToLearn = cvReadIntByName(fs, 0, "framesToLearn", 10); alphaLearn = cvReadRealByName(fs, 0, "alphaLearn", 0.1); alphaUpdate = cvReadRealByName(fs, 0, "alphaUpdate", 0.01); colorSpace = cvReadIntByName(fs, 0, "colorSpace", 1); option = cvReadIntByName(fs, 0, "option", 2); smooth = cvReadIntByName(fs, 0, "smooth", true); threshold = cvReadRealByName(fs, 0, "threshold", 0.67); 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); }
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; }
void GMG::loadConfig() { CvFileStorage* fs = cvOpenFileStorage("./config/GMG.xml", 0, CV_STORAGE_READ); initializationFrames = cvReadIntByName(fs, 0, "initializationFrames", 20); decisionThreshold = cvReadRealByName(fs, 0, "decisionThreshold", 0.7); showOutput = cvReadIntByName(fs, 0, "showOutput", true); cvReleaseFileStorage(&fs); }
void MixtureOfGaussianV2BGS::loadConfig() { CvFileStorage* fs = cvOpenFileStorage("./config/MixtureOfGaussianV2BGS.xml", 0, CV_STORAGE_READ); alpha = cvReadRealByName(fs, 0, "alpha", 0.05); enableThreshold = cvReadIntByName(fs, 0, "enableThreshold", true); threshold = cvReadIntByName(fs, 0, "threshold", 15); showOutput = cvReadIntByName(fs, 0, "showOutput", true); cvReleaseFileStorage(&fs); }
void CvGBTrees::read( CvFileStorage* fs, CvFileNode* node ) { CV_FUNCNAME( "CvGBTrees::read" ); __BEGIN__; CvSeqReader reader; CvFileNode* trees_fnode; CvMemStorage* storage; int i, ntrees; cv::String s; clear(); read_params( fs, node ); if( !data ) EXIT; base_value = (float)cvReadRealByName( fs, node, "base_value", 0.0 ); class_count = cvReadIntByName( fs, node, "class_count", 1 ); weak = new pCvSeq[class_count]; for (int j=0; j<class_count; ++j) { s = cv::format("trees_%d", j); trees_fnode = cvGetFileNodeByName( fs, node, s.c_str() ); if( !trees_fnode || !CV_NODE_IS_SEQ(trees_fnode->tag) ) CV_ERROR( CV_StsParseError, "<trees_x> tag is missing" ); cvStartReadSeq( trees_fnode->data.seq, &reader ); ntrees = trees_fnode->data.seq->total; if( ntrees != params.weak_count ) CV_ERROR( CV_StsUnmatchedSizes, "The number of trees stored does not match <ntrees> tag value" ); CV_CALL( storage = cvCreateMemStorage() ); weak[j] = cvCreateSeq( 0, sizeof(CvSeq), sizeof(CvDTree*), storage ); for( i = 0; i < ntrees; i++ ) { CvDTree* tree = new CvDTree(); CV_CALL(tree->read( fs, (CvFileNode*)reader.ptr, data )); CV_NEXT_SEQ_ELEM( reader.seq->elem_size, reader ); cvSeqPush( weak[j], &tree ); } } __END__; }
void AdaptiveBackgroundLearning::loadConfig() { CvFileStorage* fs = cvOpenFileStorage("AdaptiveBackgroundLearning.xml", 0, CV_STORAGE_READ); alpha = cvReadRealByName(fs, 0, "alpha", 0.05); limit = cvReadIntByName(fs, 0, "limit", -1); enableThreshold = cvReadIntByName(fs, 0, "enableThreshold", true); threshold = cvReadIntByName(fs, 0, "threshold", 15); showForeground = cvReadIntByName(fs, 0, "showForeground", true); showBackground = cvReadIntByName(fs, 0, "showBackground", true); cvReleaseFileStorage(&fs); }
void PixelBasedAdaptiveSegmenter::loadConfig() { CvFileStorage* fs = cvOpenFileStorage("./config/PixelBasedAdaptiveSegmenter.xml", 0, CV_STORAGE_READ); enableInputBlur = cvReadIntByName(fs, 0, "enableInputBlur", true); enableOutputBlur = cvReadIntByName(fs, 0, "enableOutputBlur", true); alpha = cvReadRealByName(fs, 0, "alpha", 7.0); beta = cvReadRealByName(fs, 0, "beta", 1.0); N = cvReadIntByName(fs, 0, "N", 20); Raute_min = cvReadIntByName(fs, 0, "Raute_min", 2); R_incdec = cvReadRealByName(fs, 0, "R_incdec", 0.05); R_lower = cvReadIntByName(fs, 0, "R_lower", 18); R_scale = cvReadIntByName(fs, 0, "R_scale", 5); T_dec = cvReadRealByName(fs, 0, "T_dec", 0.05); T_inc = cvReadIntByName(fs, 0, "T_inc", 1); T_init = cvReadIntByName(fs, 0, "T_init", 18); T_lower = cvReadIntByName(fs, 0, "T_lower", 2); T_upper = cvReadIntByName(fs, 0, "T_upper", 200); showOutput = cvReadIntByName(fs, 0, "showOutput", true); cvReleaseFileStorage(&fs); }
int Eigenfaces::loadConfig(const string& dir) { d->configFile = dir + string("/libface-config.xml"); if (DEBUG) cout << "Load training data" << endl; CvFileStorage* fileStorage = cvOpenFileStorage(d->configFile.data(), 0, CV_STORAGE_READ); cout << "opened" << endl; if (!fileStorage) { if (DEBUG) cout << "Can't open config file for reading :" << d->configFile << endl; return 1; } //d->clearTrainingStructures(); int nIds = cvReadIntByName(fileStorage, 0, "nIds", 0), i; d->FACE_WIDTH = cvReadIntByName(fileStorage, 0, "FACE_WIDTH",d->FACE_WIDTH); d->FACE_HEIGHT = cvReadIntByName(fileStorage, 0, "FACE_HEIGHT",d->FACE_HEIGHT); d->THRESHOLD = cvReadRealByName(fileStorage, 0, "THRESHOLD", d->THRESHOLD); //LibFaceUtils::printMatrix(d->projectedTrainFaceMat); for ( i = 0; i < nIds; i++ ) { char facename[200]; sprintf(facename, "person_%d", i); d->faceImgArr.push_back( (IplImage*)cvReadByName(fileStorage, 0, facename, 0) ); } for ( i = 0; i < nIds; i++ ) { char idname[200]; sprintf(idname, "id_%d", i); d->indexMap.push_back( cvReadIntByName(fileStorage, 0, idname, 0)); } // Release file storage cvReleaseFileStorage(&fileStorage); return 0; }
void MixtureOfGaussianV1BGS::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("MixtureOfGaussianV1BGS.xml").toLocal8Bit(), 0, CV_STORAGE_READ); alpha = cvReadRealByName(fs, 0, "alpha", 0.05); enableThreshold = cvReadIntByName(fs, 0, "enableThreshold", true); threshold = cvReadIntByName(fs, 0, "threshold", 15); showOutput = cvReadIntByName(fs, 0, "showOutput", false); cvReleaseFileStorage(&fs); }
void GMG::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("GMG.xml").toLocal8Bit(), 0, CV_STORAGE_WRITE); initializationFrames = cvReadIntByName(fs, 0, "initializationFrames", 20); decisionThreshold = cvReadRealByName(fs, 0, "decisionThreshold", 0.7); showOutput = cvReadIntByName(fs, 0, "showOutput", false); cvReleaseFileStorage(&fs); }
void CConfig::LoadXmlFile() { if (!QDir(CONF_PATH).exists()) QDir().mkdir(CONF_PATH); CvFileStorage* fs = NULL; try { fs = cvOpenFileStorage(XML_FILE, 0, CV_STORAGE_READ); } catch (...) { setDefault(); return; } if (fs == NULL) { setDefault(); return; } _config.ipCam = cvReadIntByName(fs, 0, "IpCam", 0); _config.strCamUrl_GV = cvReadStringByName(fs, 0, "VsCamGV", CAM_URL_GV); _config.strCamUrl_GV_ir = cvReadStringByName(fs, 0, "IrCamGV", CAM_URL_GV_IR); _config.strCamUrl_IP = cvReadStringByName(fs, 0, "VsCamIP", CAM_URL_IP); _config.strCamUrl_IP_ir = cvReadStringByName(fs, 0, "IrCamIP", CAM_URL_IP_IR); _config.trkWidth = cvReadIntByName(fs, 0, "TrkWidth", QApplication::desktop()->screenGeometry(0).width()/6); _config.trkHeight = cvReadIntByName(fs, 0, "TrkHeight", QApplication::desktop()->screenGeometry(0).height()/6); _config.frmPosX = cvReadIntByName(fs, 0, "FrmPosX", 0); _config.frmPosY = cvReadIntByName(fs, 0, "FrmPosY", 0); _config.frmWidth = cvReadIntByName(fs, 0, "FrmWidth", QApplication::desktop()->screenGeometry(0).width()); _config.frmHeight = cvReadIntByName(fs, 0, "FrmHeight", QApplication::desktop()->screenGeometry(0).height()); _config.fps = cvReadRealByName(fs, 0, "Fps", 18.5); cvReleaseFileStorage(&fs); }
void AdaptiveBackgroundLearning::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("AdaptiveBackgroundLearning.xml").toLocal8Bit(), 0, CV_STORAGE_READ); alpha = cvReadRealByName(fs, 0, "alpha", 0.05); limit = cvReadIntByName(fs, 0, "limit", -1); enableThreshold = cvReadIntByName(fs, 0, "enableThreshold", true); threshold = cvReadIntByName(fs, 0, "threshold", 15); showForeground = cvReadIntByName(fs, 0, "showForeground", true); showBackground = cvReadIntByName(fs, 0, "showBackground", true); cvReleaseFileStorage(&fs); }
static CvTestSeqElem* icvTestSeqReadElemOne(CvTestSeq_* pTS, CvFileStorage* fs, CvFileNode* node) { int noise_type = CV_NOISE_NONE;; CvTestSeqElem* pElem = NULL; const char* pVideoName = cvReadStringByName( fs, node,"Video", NULL); const char* pVideoObjName = cvReadStringByName( fs, node,"VideoObj", NULL); if(pVideoName) { /* Check to noise flag: */ if( cv_stricmp(pVideoName,"noise_gaussian") == 0 || cv_stricmp(pVideoName,"noise_normal") == 0) noise_type = CV_NOISE_GAUSSIAN; if( cv_stricmp(pVideoName,"noise_uniform") == 0) noise_type = CV_NOISE_UNIFORM; if( cv_stricmp(pVideoName,"noise_speckle") == 0) noise_type = CV_NOISE_SPECKLE; if( cv_stricmp(pVideoName,"noise_salt_and_pepper") == 0) noise_type = CV_NOISE_SALT_AND_PEPPER; } if((pVideoName || pVideoObjName ) && noise_type == CV_NOISE_NONE) { /* Read other elements: */ if(pVideoName) pElem = icvTestSeqReadElemAll(pTS, fs, pVideoName); if(pVideoObjName) { CvTestSeqElem* pE; pElem = icvTestSeqReadElemAll(pTS, fs, pVideoObjName); for(pE=pElem;pE;pE=pE->next) { pE->ObjID = pTS->ObjNum; pE->pObjName = pVideoObjName; } pTS->ObjNum++; } } /* Read other elements. */ else { /* Create new element: */ CvFileNode* pPosNode = cvGetFileNodeByName( fs, node,"Pos"); CvFileNode* pSizeNode = cvGetFileNodeByName( fs, node,"Size"); int AutoSize = (pSizeNode && CV_NODE_IS_STRING(pSizeNode->tag) && cv_stricmp("auto",cvReadString(pSizeNode,""))==0); int AutoPos = (pPosNode && CV_NODE_IS_STRING(pPosNode->tag) && cv_stricmp("auto",cvReadString(pPosNode,""))==0); const char* pFileName = cvReadStringByName( fs, node,"File", NULL); pElem = (CvTestSeqElem*)cvAlloc(sizeof(CvTestSeqElem)); memset(pElem,0,sizeof(CvTestSeqElem)); pElem->ObjID = -1; pElem->noise_type = noise_type; cvRandInit( &pElem->rnd_state, 1, 0, 0,CV_RAND_NORMAL); if(pFileName && pElem->noise_type == CV_NOISE_NONE) { /* If AVI or BMP: */ size_t l = strlen(pFileName); pElem->pFileName = pFileName; pElem->type = SRC_TYPE_IMAGE; if(cv_stricmp(".avi",pFileName+l-4) == 0)pElem->type = SRC_TYPE_AVI; if(pElem->type == SRC_TYPE_IMAGE) { //pElem->pImg = cvLoadImage(pFileName); if(pElem->pImg) { pElem->FrameNum = 1; if(pElem->pImgMask)cvReleaseImage(&(pElem->pImgMask)); pElem->pImgMask = cvCreateImage( cvSize(pElem->pImg->width,pElem->pImg->height), IPL_DEPTH_8U,1); icvTestSeqCreateMask(pElem->pImg,pElem->pImgMask,FG_BG_THRESHOLD); } } if(pElem->type == SRC_TYPE_AVI && pFileName) { //pElem->pAVI = cvCaptureFromFile(pFileName); if(pElem->pAVI) { IplImage* pImg = 0;//cvQueryFrame(pElem->pAVI); pElem->pImg = cvCloneImage(pImg); pElem->pImg->origin = 0; //cvSetCaptureProperty(pElem->pAVI,CV_CAP_PROP_POS_FRAMES,0); pElem->FrameBegin = 0; pElem->AVILen = pElem->FrameNum = 0;//(int)cvGetCaptureProperty(pElem->pAVI, CV_CAP_PROP_FRAME_COUNT); //cvReleaseCapture(&pElem->pAVI); pElem->pAVI = NULL; } else { printf("WARNING!!! Cannot open avi file %s\n",pFileName); } } } /* If AVI or BMP. */ if(pPosNode) { /* Read positions: */ if(CV_NODE_IS_SEQ(pPosNode->tag)) { int num = pPosNode->data.seq->total; pElem->pPos = (CvPoint2D32f*)cvAlloc(sizeof(float)*num); cvReadRawData( fs, pPosNode, pElem->pPos, "f" ); pElem->PosNum = num/2; if(pElem->FrameNum == 0) pElem->FrameNum = pElem->PosNum; } } if(pSizeNode) { /* Read sizes: */ if(CV_NODE_IS_SEQ(pSizeNode->tag)) { int num = pSizeNode->data.seq->total; pElem->pSize = (CvPoint2D32f*)cvAlloc(sizeof(float)*num); cvReadRawData( fs, pSizeNode, pElem->pSize, "f" ); pElem->SizeNum = num/2; } } if(AutoPos || AutoSize) { /* Auto size and pos: */ int i; int num = (pElem->type == SRC_TYPE_AVI)?pElem->AVILen:1; if(AutoSize) { pElem->pSize = (CvPoint2D32f*)cvAlloc(sizeof(CvPoint2D32f)*num); pElem->SizeNum = num; } if(AutoPos) { pElem->pPos = (CvPoint2D32f*)cvAlloc(sizeof(CvPoint2D32f)*num); pElem->PosNum = num; } for(i=0; i<num; ++i) { IplImage* pFG = NULL; CvPoint2D32f* pPos = AutoPos?(pElem->pPos + i):NULL; CvPoint2D32f* pSize = AutoSize?(pElem->pSize + i):NULL; icvTestSeqQureyFrameElem(pElem,i); pFG = pElem->pImgMask; if(pPos) { pPos->x = 0.5f; pPos->y = 0.5f; } if(pSize) { pSize->x = 0; pSize->y = 0; } if(pFG) { double M00; CvMoments m; cvMoments( pElem->pImgMask, &m, 0 ); M00 = cvGetSpatialMoment( &m, 0, 0 ); if(M00 > 0 && pSize ) { double X = cvGetSpatialMoment( &m, 1, 0 )/M00; double Y = cvGetSpatialMoment( &m, 0, 1 )/M00; double XX = (cvGetSpatialMoment( &m, 2, 0 )/M00) - X*X; double YY = (cvGetSpatialMoment( &m, 0, 2 )/M00) - Y*Y; pSize->x = (float)(4*sqrt(XX))/(pElem->pImgMask->width-1); pSize->y = (float)(4*sqrt(YY))/(pElem->pImgMask->height-1); } if(M00 > 0 && pPos) { pPos->x = (float)(cvGetSpatialMoment( &m, 1, 0 )/(M00*(pElem->pImgMask->width-1))); pPos->y = (float)(cvGetSpatialMoment( &m, 0, 1 )/(M00*(pElem->pImgMask->height-1))); } if(pPos) { /* Another way to calculate y pos * using object median: */ int y0=0, y1=pFG->height-1; for(y0=0; y0<pFG->height; ++y0) { CvMat m; CvScalar s = cvSum(cvGetRow(pFG, &m, y0)); if(s.val[0] > 255*7) break; } for(y1=pFG->height-1; y1>0; --y1) { CvMat m; CvScalar s = cvSum(cvGetRow(pFG, &m, y1)); if(s.val[0] > 255*7) break; } pPos->y = (y0+y1)*0.5f/(pFG->height-1); } } /* pFG */ } /* Next frame. */ //if(pElem->pAVI) cvReleaseCapture(&pElem->pAVI); pElem->pAVI = NULL; } /* End auto position creation. */ } /* Create new element. */ if(pElem) { /* Read transforms and: */ int FirstFrame, LastFrame; CvTestSeqElem* p=pElem; CvFileNode* pTransNode = NULL; CvFileNode* pS = NULL; int ShiftByPos = 0; int KeyFrames[1024]; CvSeq* pTransSeq = NULL; int KeyFrameNum = 0; pTransNode = cvGetFileNodeByName( fs, node,"Trans"); while( pTransNode && CV_NODE_IS_STRING(pTransNode->tag) && cv_stricmp("auto",cvReadString(pTransNode,""))!=0) { /* Trans is reference: */ pTransNode = cvGetFileNodeByName( fs, NULL,cvReadString(pTransNode,"")); } pS = cvGetFileNodeByName( fs, node,"Shift"); ShiftByPos = 0; pTransSeq = pTransNode?(CV_NODE_IS_SEQ(pTransNode->tag)?pTransNode->data.seq:NULL):NULL; KeyFrameNum = pTransSeq?pTransSeq->total:1; if( (pS && CV_NODE_IS_STRING(pS->tag) && cv_stricmp("auto",cvReadString(pS,""))==0) ||(pTransNode && CV_NODE_IS_STRING(pTransNode->tag) && cv_stricmp("auto",cvReadString(pTransNode,""))==0)) { ShiftByPos = 1; } FirstFrame = pElem->FrameBegin; LastFrame = pElem->FrameBegin+pElem->FrameNum-1; /* Calculate length of video and reallocate * transformation array: */ for(p=pElem; p; p=p->next) { int v; v = cvReadIntByName( fs, node, "BG", -1 ); if(v!=-1)p->BG = v; v = cvReadIntByName( fs, node, "Mask", -1 ); if(v!=-1)p->Mask = v; p->FrameBegin += cvReadIntByName( fs, node, "FrameBegin", 0 ); p->FrameNum = cvReadIntByName( fs, node, "FrameNum", p->FrameNum ); p->FrameNum = cvReadIntByName( fs, node, "Dur", p->FrameNum ); { int LastFrame = cvReadIntByName( fs, node, "LastFrame", p->FrameBegin+p->FrameNum-1 ); p->FrameNum = MIN(p->FrameNum,LastFrame - p->FrameBegin+1); } icvTestSeqAllocTrans(p); { /* New range estimation: */ int LF = p->FrameBegin+p->FrameNum-1; if(p==pElem || FirstFrame > p->FrameBegin)FirstFrame = p->FrameBegin; if(p==pElem || LastFrame < LF)LastFrame = LF; } /* New range estimation. */ } /* End allocate new transfrom array. */ if(ShiftByPos) { for(p=pElem;p;p=p->next) { /* Modify transformation to make autoshift: */ int i; int num = p->FrameNum; assert(num <= p->TransNum); p->TransNum = MAX(1,num); for(i=0; i<num; ++i) { CvTSTrans* pT = p->pTrans+i; //float t = (num>1)?((float)i/(num-1)):0.0f; float newx = p->pPos[i%p->PosNum].x; float newy = p->pPos[i%p->PosNum].y; pT->Shift.x = -newx*pT->Scale.x; pT->Shift.y = -newy*pT->Scale.y; if(p->pImg) { newx *= p->pImg->width-1; newy *= p->pImg->height-1; } pT->T[2] = -(pT->T[0]*newx+pT->T[1]*newy); pT->T[5] = -(pT->T[3]*newx+pT->T[4]*newy); } } /* Modify transformation old. */ } /* Next record. */ /* Initialize frame number array: */ KeyFrames[0] = FirstFrame; if(pTransSeq&&KeyFrameNum>1) { int i0,i1,i; for(i=0; i<KeyFrameNum; ++i) { CvFileNode* pTN = (CvFileNode*)cvGetSeqElem(pTransSeq,i); KeyFrames[i] = cvReadIntByName(fs,pTN,"frame",-1); } if(KeyFrames[0]<0)KeyFrames[0]=FirstFrame; if(KeyFrames[KeyFrameNum-1]<0)KeyFrames[KeyFrameNum-1]=LastFrame; for(i0=0, i1=1; i1<KeyFrameNum;) { int i; for(i1=i0+1; i1<KeyFrameNum && KeyFrames[i1]<0; i1++); assert(i1<KeyFrameNum); assert(i1>i0); for(i=i0+1; i<i1; ++i) { KeyFrames[i] = cvRound(KeyFrames[i0] + (float)(i-i0)*(float)(KeyFrames[i1] - KeyFrames[i0])/(float)(i1-i0)); } i0 = i1; i1++; } /* Next key run. */ } /* Initialize frame number array. */ if(pTransNode || pTransSeq) { /* More complex transform. */ int param; CvFileNode* pTN = pTransSeq?(CvFileNode*)cvGetSeqElem(pTransSeq,0):pTransNode; for(p=pElem; p; p=p->next) { //int trans_num = p->TransNum; for(param=0; param_name[param]; ++param) { const char* name = param_name[param]; float defv = param_defval[param]; if(KeyFrameNum==1) { /* Only one transform record: */ int i; double val; CvFileNode* node = cvGetFileNodeByName( fs, pTN,name); if(node == NULL) continue; val = cvReadReal(node,defv); for(i=0; i<p->TransNum; ++i) { icvUpdateTrans( p->pTrans+i, param, val, p->pImg?(float)(p->pImg->width-1):1.0f, p->pImg?(float)(p->pImg->height-1):1.0f); } } /* Next record. */ else { /* Several transforms: */ int i0,i1; double v0; double v1; CvFileNode* pTN = (CvFileNode*)cvGetSeqElem(pTransSeq,0); v0 = cvReadRealByName(fs, pTN,name,defv); for(i1=1,i0=0; i1<KeyFrameNum; ++i1) { int f0,f1; int i; CvFileNode* pTN = (CvFileNode*)cvGetSeqElem(pTransSeq,i1); CvFileNode* pVN = cvGetFileNodeByName(fs,pTN,name); if(pVN)v1 = cvReadReal(pVN,defv); else if(pVN == NULL && i1 == KeyFrameNum-1) v1 = defv; else continue; f0 = KeyFrames[i0]; f1 = KeyFrames[i1]; if(i1==(KeyFrameNum-1)) f1++; for(i=f0; i<f1; ++i) { double val; double t = (float)(i-f0); int li = i - p->FrameBegin; if(li<0) continue; if(li>= p->TransNum) break; if(KeyFrames[i1]>KeyFrames[i0]) t /=(float)(KeyFrames[i1]-KeyFrames[i0]); val = t*(v1-v0)+v0; icvUpdateTrans( p->pTrans+li, param, val, p->pImg?(float)(p->pImg->width-1):1.0f, p->pImg?(float)(p->pImg->height-1):1.0f); } /* Next transform. */ i0 = i1; v0 = v1; } /* Next value run. */ } /* Several transforms. */ } /* Next parameter. */ } /* Next record. */ } /* More complex transform. */ } /* Read transfroms. */ return pElem; } /* icvTestSeqReadElemOne */
LKInverseComp::LKInverseComp(char *path) { CvFileStorage *fs; fs = cvOpenFileStorage(path, 0, CV_STORAGE_READ ); nA = (int)cvReadRealByName(fs, 0, "numberOfAppearanceEigenVectors", 0); nS = (int)cvReadRealByName(fs, 0, "numberOfShapeEigenVectors", 0); printf("%d %d \n",nS,nA); //nS=16; // //nA=2; //nS=4;/ nA=10; nA+=1; negNewParam = (float *)malloc(sizeof(float)*(nS+4)); negNewParamnS = (float *)malloc(sizeof(float)*(nS+4)); negNewParam4 = (float *)malloc(sizeof(float)*(nS+4)); ParamnS = (float *)malloc(sizeof(float)*(nS+4)); Param4 = (float *)malloc(sizeof(float)*(nS+4)); ptemp1 = (float *)malloc(sizeof(float)*(nS+4)); ptemp2 = (float *)malloc(sizeof(float)*(nS+4)); param = (float *) malloc((4+nS)*sizeof(float)); nonRigidShapeVectors=(IplImage**)cvAlloc(sizeof(IplImage*) * nS); appearanceVectors=(IplImage**)cvAlloc(sizeof(IplImage*) * nA); globalShapeVectors=(IplImage**)cvAlloc(sizeof(IplImage*) * 4); combineshapevectors=(IplImage**)cvAlloc(sizeof(IplImage*) * (4+nS)); srcShape =cvCreateImage(cvSize(totalnumberofpoints,1),IPL_DEPTH_64F,1); destShape =cvCreateImage(cvSize(totalnumberofpoints,1),IPL_DEPTH_64F,1); destShapeTemp =cvCreateImage(cvSize(totalnumberofpoints,1),IPL_DEPTH_64F,1); destShapewithoutQ =cvCreateImage(cvSize(totalnumberofpoints,1),IPL_DEPTH_64F,1); for (int m=0;m<(nS+4);m++) { combineshapevectors[m]=cvCreateImage(cvSize(totalnumberofpoints,1),IPL_DEPTH_64F,1); param[m]=0; negNewParam[m]=0; negNewParamnS[m]=0; negNewParam4[m]=0; ParamnS[m]=0; Param4[m]=0; ptemp1[m]=0; ptemp2[m]=0; } for (int m=0;m<4;m++) globalShapeVectors[m]=cvCreateImage(cvSize(totalnumberofpoints,1),IPL_DEPTH_64F,1); CvMat * meanShapeDel=cvCreateMat(numberofpoints,2,CV_64FC1); eigenVal= (CvMat *)cvReadByName( fs,0,"eigenVal",0 ); // minProjVal=(IplImage *)cvReadByName( fs,0,"minProjVal",0 ); // maxProjVal=(IplImage *)cvReadByName( fs,0,"maxProjVal",0 ); meanAppearance=(IplImage *)cvReadByName( fs,0,"avgApp",0 ); ErrorImage = cvCreateMat((meanAppearance->width*meanAppearance->height),1, CV_64FC1); IplImage* meanShapeTemp=(IplImage *)cvReadByName( fs,0,"avgShape",0 ); meanShape=cvCreateImage(cvSize(meanShapeTemp->width,meanShapeTemp->height),IPL_DEPTH_64F,1); cvConvertScale( meanShapeTemp,meanShape,1,0); for (int m=0;m<nS;m++) { char temp[200]; sprintf(temp,"shapeEigenVectors%d",m); nonRigidShapeVectors[m]=(IplImage *)cvReadByName( fs,0,temp,0 ); } for (int m=0;m<nA-1;m++) { char temp[200]; sprintf(temp,"appEigenVectors%d",m); appearanceVectors[m]=(IplImage *)cvReadByName( fs,0,temp,0 ); } appearanceVectors[nA-1]=cvCreateImage(cvSize(appearanceVectors[nA-2]->width,appearanceVectors[nA-2]->height),IPL_DEPTH_32F,1); for(int i=0;i<(appearanceVectors[nA-2]->width);i++) { for(int j=0;j<appearanceVectors[nA-2]->height;j++) { CvScalar s; s.val[0]=1; cvSet2D(appearanceVectors[nA-1],j,i,s); } } // IplImage * newImage = cvCreateImage(cvSize(meanAppearance->width,meanAppearance->height),IPL_DEPTH_8U,1); for (int m=0;m<nA;m++) { // cvZero(newImage); for (int i=0;i<meanAppearance->width;i++) { for (int j=0;j<meanAppearance->height;j++) { CvScalar s= cvGet2D(appearanceVectors[m],j,i); s.val[0]*=255; CvScalar s1= cvGet2D(meanAppearance,j,i); s.val[0]+=s1.val[0]; ////printf("%e \n",s.val[0]); // cvSet2D(newImage,j,i,s); } } // cvNamedWindow("yoyo",1); //cvShowImage("yoyo",newImage); // cvWaitKey(-1); } for (int m=0;m<numberofpoints;m++) { CvScalar s1,s2; s1=cvGet2D(meanShape,0,2*m); s2=cvGet2D(meanShape,0,2*m+1); cvSet2D(meanShapeDel,m,0,s1); cvSet2D(meanShapeDel,m,1,s2); cvSet2D(globalShapeVectors[0],0,2*m,s1); cvSet2D(globalShapeVectors[0],0,2*m+1,s2); cvSet2D(combineshapevectors[0],0,2*m,s1); cvSet2D(combineshapevectors[0],0,2*m+1,s2); s2.val[0]*=-1; cvSet2D(globalShapeVectors[1],0,2*m,s2); cvSet2D(globalShapeVectors[1],0,2*m+1,s1); cvSet2D(combineshapevectors[1],0,2*m,s2); cvSet2D(combineshapevectors[1],0,2*m+1,s1); CvScalar one,zero; one.val[0]=1; zero.val[0]=0; cvSet2D(globalShapeVectors[2],0,2*m,one); cvSet2D(globalShapeVectors[2],0,2*m+1,zero); cvSet2D(globalShapeVectors[3],0,2*m,zero); cvSet2D(globalShapeVectors[3],0,2*m+1,one); cvSet2D(combineshapevectors[2],0,2*m,one); cvSet2D(combineshapevectors[2],0,2*m+1,zero); cvSet2D(combineshapevectors[3],0,2*m,zero); cvSet2D(combineshapevectors[3],0,2*m+1,one); } for (int i=0;i<numberofpoints;i++) { CvScalar avx,avy; avx=cvGet2D( meanShapeDel, i,0); avy=cvGet2D( meanShapeDel, i,1); // ////printf("%e %e \n",avx.val[0],avy.val[0]); } newDelaunayShapeCompute= new delaunay(meanShapeDel); newDelaunay = new delaunay(meanShapeDel); newDelaunayInverse = new delaunay(meanShapeDel); for (int m=0;m<4;m++) { double val= cvNorm(globalShapeVectors[m],NULL , CV_L2, 0 ); cvConvertScale( globalShapeVectors[m],globalShapeVectors[m],1/val,0); ////printf(" %e \n",val); // cvConvertScale( combineshapevectors[m],combineshapevectors[m],val,0); } for (int m=4;m<(nS+4);m++) { for (int j=0;j<totalnumberofpoints;j++) { CvScalar s1 = cvGet2D(nonRigidShapeVectors[m-4],0,j); cvSet2D(combineshapevectors[m],0,j,s1); } } for (int m=0;m<nS+4;m++) { double val= cvNorm(combineshapevectors[m],NULL , CV_L2, 0 ); cvConvertScale( combineshapevectors[m],combineshapevectors[m],1/val,0); ////printf(" %e \n",val); // cvConvertScale( combineshapevectors[m],combineshapevectors[m],val,0); } for (int m=0;m<nA;m++) { double val= cvNorm(appearanceVectors[m],NULL , CV_L2, 0 ); cvConvertScale( appearanceVectors[m],appearanceVectors[m],1/val,0); // //printf(" %e \n",val); } ////printf("%d %d \n",meanAppearance->width,meanAppearance->height); totalNumberOfPixels=newDelaunay->numberOfPixels(); interpolateMean=(float*)malloc(sizeof(float)*totalNumberOfPixels); for (int i=0;i<totalNumberOfPixels;i++) { interpolateMean[i]=0; pixel * pix = newDelaunay->getpixel(i); interpolateMean[i]=interpolate<float>(meanAppearance,double(pix->x+pix->tx),double(pix->y+pix->ty)); } preCompute(); ////printf("%d %d \n",meanAppearance->width,meanAppearance->height); // preCompute(); }
void MultiLayerBGS::loadConfig() { CvFileStorage* fs = cvOpenFileStorage("MultiLayerBGS.xml", 0, CV_STORAGE_READ); if(fs == NULL) { cout << "Do not open file MultiLayerBGS.xml - loadConfig()" << endl; return; } bg_model_preload = cvReadStringByName(fs, 0, "preloadModel", ""); saveModel = cvReadIntByName(fs, 0, "saveModel", false); detectAfter = cvReadIntByName(fs, 0, "detectAfter", 0); disableDetectMode = cvReadIntByName(fs, 0, "disableDetectMode", true); disableLearning = cvReadIntByName(fs, 0, "disableLearningInDetecMode", false); loadDefaultParams = cvReadIntByName(fs, 0, "loadDefaultParams", true); max_mode_num = cvReadIntByName(fs, 0, "max_mode_num", 5); weight_updating_constant = cvReadRealByName(fs, 0, "weight_updating_constant", 5.0); texture_weight = cvReadRealByName(fs, 0, "texture_weight", 0.5); bg_mode_percent = cvReadRealByName(fs, 0, "bg_mode_percent", 0.6); pattern_neig_half_size = cvReadIntByName(fs, 0, "pattern_neig_half_size", 4); pattern_neig_gaus_sigma = cvReadRealByName(fs, 0, "pattern_neig_gaus_sigma", 3.0); bg_prob_threshold = cvReadRealByName(fs, 0, "bg_prob_threshold", 0.2); bg_prob_updating_threshold = cvReadRealByName(fs, 0, "bg_prob_updating_threshold", 0.2); robust_LBP_constant = cvReadIntByName(fs, 0, "robust_LBP_constant", 3); min_noised_angle = cvReadRealByName(fs, 0, "min_noised_angle", 0.01768); shadow_rate = cvReadRealByName(fs, 0, "shadow_rate", 0.6); highlight_rate = cvReadRealByName(fs, 0, "highlight_rate", 1.2); bilater_filter_sigma_s = cvReadRealByName(fs, 0, "bilater_filter_sigma_s", 3.0); bilater_filter_sigma_r = cvReadRealByName(fs, 0, "bilater_filter_sigma_r", 0.1); frame_duration = cvReadRealByName(fs, 0, "frame_duration", 0.1); learn_mode_learn_rate_per_second = cvReadRealByName(fs, 0, "learn_mode_learn_rate_per_second", 0.5); learn_weight_learn_rate_per_second = cvReadRealByName(fs, 0, "learn_weight_learn_rate_per_second", 0.5); learn_init_mode_weight = cvReadRealByName(fs, 0, "learn_init_mode_weight", 0.05); detect_mode_learn_rate_per_second = cvReadRealByName(fs, 0, "detect_mode_learn_rate_per_second", 0.01); detect_weight_learn_rate_per_second = cvReadRealByName(fs, 0, "detect_weight_learn_rate_per_second", 0.01); detect_init_mode_weight = cvReadRealByName(fs, 0, "detect_init_mode_weight", 0.001); showOutput = cvReadIntByName(fs, 0, "showOutput", true); cvReleaseFileStorage(&fs); }
void CvANN_MLP::read_params( CvFileStorage* fs, CvFileNode* node ) { //CV_FUNCNAME( "CvANN_MLP::read_params" ); __BEGIN__; const char* activ_func_name = cvReadStringByName( fs, node, "activation_function", 0 ); CvFileNode* tparams_node; if( activ_func_name ) activ_func = strcmp( activ_func_name, "SIGMOID_SYM" ) == 0 ? SIGMOID_SYM : strcmp( activ_func_name, "IDENTITY" ) == 0 ? IDENTITY : strcmp( activ_func_name, "GAUSSIAN" ) == 0 ? GAUSSIAN : 0; else activ_func = cvReadIntByName( fs, node, "activation_function" ); f_param1 = cvReadRealByName( fs, node, "f_param1", 0 ); f_param2 = cvReadRealByName( fs, node, "f_param2", 0 ); set_activ_func( activ_func, f_param1, f_param2 ); min_val = cvReadRealByName( fs, node, "min_val", 0. ); max_val = cvReadRealByName( fs, node, "max_val", 1. ); min_val1 = cvReadRealByName( fs, node, "min_val1", 0. ); max_val1 = cvReadRealByName( fs, node, "max_val1", 1. ); tparams_node = cvGetFileNodeByName( fs, node, "training_params" ); params = CvANN_MLP_TrainParams(); if( tparams_node ) { const char* tmethod_name = cvReadStringByName( fs, tparams_node, "train_method", "" ); CvFileNode* tcrit_node; if( strcmp( tmethod_name, "BACKPROP" ) == 0 ) { params.train_method = CvANN_MLP_TrainParams::BACKPROP; params.bp_dw_scale = cvReadRealByName( fs, tparams_node, "dw_scale", 0 ); params.bp_moment_scale = cvReadRealByName( fs, tparams_node, "moment_scale", 0 ); } else if( strcmp( tmethod_name, "RPROP" ) == 0 ) { params.train_method = CvANN_MLP_TrainParams::RPROP; params.rp_dw0 = cvReadRealByName( fs, tparams_node, "dw0", 0 ); params.rp_dw_plus = cvReadRealByName( fs, tparams_node, "dw_plus", 0 ); params.rp_dw_minus = cvReadRealByName( fs, tparams_node, "dw_minus", 0 ); params.rp_dw_min = cvReadRealByName( fs, tparams_node, "dw_min", 0 ); params.rp_dw_max = cvReadRealByName( fs, tparams_node, "dw_max", 0 ); } tcrit_node = cvGetFileNodeByName( fs, tparams_node, "term_criteria" ); if( tcrit_node ) { params.term_crit.epsilon = cvReadRealByName( fs, tcrit_node, "epsilon", -1 ); params.term_crit.max_iter = cvReadIntByName( fs, tcrit_node, "iterations", -1 ); params.term_crit.type = (params.term_crit.epsilon >= 0 ? CV_TERMCRIT_EPS : 0) + (params.term_crit.max_iter >= 0 ? CV_TERMCRIT_ITER : 0); } } __END__; }
double cvReadRealByName_wrap(const CvFileStorage * fs , const CvFileNode * map , const char * name , double default_value ){ return cvReadRealByName(/*const*//*CvFileStorage*//***/fs , /*const*//*CvFileNode*//***/map , /*const*//*char*//***/name , /*double*/default_value); }
void Point::load(CvFileStorage *in, CvFileNode *node) { x = cvReadRealByName(in, node, "x"); y = cvReadRealByName(in, node, "y"); }
// Read XML-formatted configuration file. void readConfiguration(const char* filename, struct slParams* sl_params){ // Open file storage for XML-formatted configuration file. CvFileStorage* fs = cvOpenFileStorage(filename, 0, CV_STORAGE_READ); // Read output directory and object (or sequence) name. CvFileNode* m = cvGetFileNodeByName(fs, 0, "output"); strcpy(sl_params->outdir, cvReadStringByName(fs, m, "output_directory", "./output")); strcpy(sl_params->object, cvReadStringByName(fs, m, "object_name", "./output")); sl_params->save = (cvReadIntByName(fs, m, "save_intermediate_results", 0) != 0); // Read camera parameters. m = cvGetFileNodeByName(fs, 0, "camera"); sl_params->cam_w = cvReadIntByName(fs, m, "width", 960); sl_params->cam_h = cvReadIntByName(fs, m, "height", 720); sl_params->Logitech_9000 = (cvReadIntByName(fs, m, "Logitech_Quickcam_9000_raw_mode", 0) != 0); // Read projector parameters. m = cvGetFileNodeByName(fs, 0, "projector"); sl_params->proj_w = cvReadIntByName(fs, m, "width", 1024); sl_params->proj_h = cvReadIntByName(fs, m, "height", 768); sl_params->proj_invert = (cvReadIntByName(fs, m, "invert_projector", 0) != 0); // Read camera and projector gain parameters. m = cvGetFileNodeByName(fs, 0, "gain"); sl_params->cam_gain = cvReadIntByName(fs, m, "camera_gain", 50); sl_params->proj_gain = cvReadIntByName(fs, m, "projector_gain", 50); // Read distortion model parameters. m = cvGetFileNodeByName(fs, 0, "distortion_model"); sl_params->cam_dist_model[0] = (cvReadIntByName(fs, m, "enable_tangential_camera", 0) != 0); sl_params->cam_dist_model[1] = (cvReadIntByName(fs, m, "enable_6th_order_radial_camera", 0) != 0); sl_params->proj_dist_model[0] = (cvReadIntByName(fs, m, "enable_tangential_projector", 0) != 0); sl_params->proj_dist_model[1] = (cvReadIntByName(fs, m, "enable_6th_order_radial_projector", 0) != 0); // Read camera calibration chessboard parameters. m = cvGetFileNodeByName(fs, 0, "camera_chessboard"); sl_params->cam_board_w = cvReadIntByName(fs, m, "interior_horizontal_corners", 8); sl_params->cam_board_h = cvReadIntByName(fs, m, "interior_vertical_corners", 6); sl_params->cam_board_w_mm = (float)cvReadRealByName(fs, m, "square_width_mm", 30.0); sl_params->cam_board_h_mm = (float)cvReadRealByName(fs, m, "square_height_mm", 30.0); // Read projector calibration chessboard parameters. m = cvGetFileNodeByName(fs, 0, "projector_chessboard"); sl_params->proj_board_w = cvReadIntByName(fs, m, "interior_horizontal_corners", 8); sl_params->proj_board_h = cvReadIntByName(fs, m, "interior_vertical_corners", 6); sl_params->proj_board_w_pixels = cvReadIntByName(fs, m, "square_width_pixels", 75); sl_params->proj_board_h_pixels = cvReadIntByName(fs, m, "square_height_pixels", 75); // Read scanning and reconstruction parameters. m = cvGetFileNodeByName(fs, 0, "scanning_and_reconstruction"); sl_params->mode = cvReadIntByName(fs, m, "mode", 2); sl_params->scan_cols = (cvReadIntByName(fs, m, "reconstruct_columns", 1) != 0); sl_params->scan_rows = (cvReadIntByName(fs, m, "reconstruct_rows", 1) != 0); sl_params->delay = cvReadIntByName(fs, m, "frame_delay_ms", 200); sl_params->thresh = cvReadIntByName(fs, m, "minimum_contrast_threshold", 32); sl_params->dist_range[0] = (float) cvReadRealByName(fs, m, "minimum_distance_mm", 0.0); sl_params->dist_range[1] = (float) cvReadRealByName(fs, m, "maximum_distance_mm", 1.0e4); sl_params->dist_reject = (float) cvReadRealByName(fs, m, "maximum_distance_variation_mm", 10.0); sl_params->background_depth_thresh = (float) cvReadRealByName(fs, m, "minimum_background_distance_mm", 20.0); // Read visualization options. m = cvGetFileNodeByName(fs, 0, "visualization"); sl_params->display = (cvReadIntByName(fs, m, "display_intermediate_results", 1) != 0); sl_params->window_w = cvReadIntByName(fs, m, "display_window_width_pixels", 640); // Enable both row and column scanning, if "ray-ray" reconstruction mode is enabled. if(sl_params->mode == 2){ sl_params->scan_cols = true; sl_params->scan_rows = true; } // Set camera visualization window dimensions. sl_params->window_h = (int)ceil((float)sl_params->window_w*((float)sl_params->cam_h/(float)sl_params->cam_w)); // Close file storage for XML-formatted configuration file. cvReleaseFileStorage(&fs); }