void GetTrackingParameter( Tracking::Tracker::Parameter& params, const char* ini_file, std::string config_root = ".") { CDataFile iniCDF; if(!iniCDF.Load(ini_file)){ char errmsg[128]; sprintf(errmsg, "[utilities::GetTrackingParameter] Can not open tracking_ini file '%s'", ini_file); throw std::runtime_error(errmsg); } // Tracking // Constraints params.variation.r.x = iniCDF.GetFloat("r.x", "Constraints") * Tracking::pi/180.0f; params.variation.r.y = iniCDF.GetFloat("r.y", "Constraints") * Tracking::pi/180.0f; params.variation.r.z = iniCDF.GetFloat("r.z", "Constraints") * Tracking::pi/180.0f; params.variation.t.x = iniCDF.GetFloat("t.x", "Constraints"); params.variation.t.y = iniCDF.GetFloat("t.y", "Constraints"); params.variation.t.z = iniCDF.GetFloat("t.z", "Constraints"); params.variation.z = iniCDF.GetFloat("z", "Constraints"); // Performance params.num_recursions = iniCDF.GetInt("recursions", "Performance"); params.num_particles = iniCDF.GetInt("particles", "Performance"); params.hypotheses_trials = iniCDF.GetInt("hypotheses", "Performance"); params.convergence = iniCDF.GetInt("convergence", "Performance"); // Resource Path params.modelPath = pal_blort::addRoot(iniCDF.GetString("ModelPath", "ResourcePath"), config_root); params.texturePath = pal_blort::addRoot(iniCDF.GetString("TexturePath", "ResourcePath"), config_root); params.shaderPath = pal_blort::addRoot(iniCDF.GetString("ShaderPath", "ResourcePath"), config_root); // Other params.edge_tolerance = iniCDF.GetFloat("EdgeMatchingTolerance", "Other") * Tracking::pi/180.0f; params.minTexGrabAngle = iniCDF.GetFloat("MinTextureGrabAngle", "Other") * Tracking::pi/180.0f; params.num_spreadings = iniCDF.GetInt("NumberOfSpreadings", "Other"); params.max_kernel_size = iniCDF.GetInt("MaxKernelSize", "Other"); params.model_sobel_th = iniCDF.GetFloat("ModelSobelThreshold", "Other"); params.image_sobel_th = iniCDF.GetFloat("ImageSobelThreshold", "Other"); params.pred_no_convergence = iniCDF.GetFloat("PredictorNoConvergence", "Other"); params.c_th_base = iniCDF.GetFloat("BaseThreshold", "Qualitative"); params.c_th_min = iniCDF.GetFloat("MinThreshold", "Qualitative"); params.c_th_fair = iniCDF.GetFloat("FairThreshold", "Qualitative"); params.c_th_lost = iniCDF.GetFloat("LostThreshold", "Qualitative"); params.c_mv_not = iniCDF.GetFloat("NoMovementThreshold", "Movement"); params.c_mv_slow = iniCDF.GetFloat("SlowMovementThreshold", "Movement"); }
/////////////////////////////////////////////////////////////////////////////// /// Checks if a key that is supposed in a specific section exists in ini file. /// If the key does not exists an error message is generated and the programm /// is quit. /// @param [in] CfgFile Reference to the loaded ini file. /// @param [in] key the key that is to be checked. /// @param [in] section the section in which the key is supposed to be. /////////////////////////////////////////////////////////////////////////////// bool CheckCfgParameterKeyExist(CDataFile CfgFile, string key, string section) { if (CfgFile.GetString(key,section).length() == 0) return false; else return true; }
void GetPlySiftFilenames(const char* ini_file, std::string &ply_file, std::string &sift_file, std::string &model_name) { CDataFile iniCDF; if(!iniCDF.Load(ini_file)){ char errmsg[128]; sprintf(errmsg, "[utilities::GetTrackingParameter] Can not open tracking_ini file '%s'", ini_file); throw std::runtime_error(errmsg); } ply_file = iniCDF.GetString("ModelPath", "ResourcePath"); ply_file.append(iniCDF.GetString("Model", "Files")); sift_file = iniCDF.GetString("SiftPath", "ResourcePath"); sift_file.append(iniCDF.GetString("SiftModel", "Files")); model_name = iniCDF.GetString("Model", "Files"); model_name = model_name.substr(0, model_name.find(".")); }
void getCamPose(const char* pose_cal_file, TomGine::tgPose& camPose){ CDataFile cdfParams; if(!cdfParams.Load(pose_cal_file)){ char errmsg[128]; sprintf(errmsg, "[utilities::getCamPose] Can not open pose_cal file '%s'", pose_cal_file); throw std::runtime_error(errmsg); } vec3 t, r; mat3 R; std::string pose = cdfParams.GetString("pose"); sscanf( pose.c_str(), "[%f %f %f] [%f %f %f]", &(t.x), &(t.y), &(t.z), &(r.x), &(r.y), &(r.z) ); R.fromRotVector(r); camPose.SetPose(R,t); }
void setCameraPose(TomGine::tgCamera::Parameter& camPar, const char* pose_cal_file) { CDataFile poseCDF; if(!poseCDF.Load(pose_cal_file)){ char errmsg[128]; sprintf(errmsg, "[utilities::GetTrackingParameter] Can not open pose_cal file '%s'", pose_cal_file); throw std::runtime_error(errmsg); } // Pose vec3 p, r; std::string pose = poseCDF.GetString("pose"); sscanf( pose.c_str(), "[%f %f %f] [%f %f %f]", &(p.x), &(p.y), &(p.z), &(r.x), &(r.y), &(r.z) ); //printf("%s\n", pose.c_str()); //printf("%f %f %f, %f %f %f\n", p.x, p.y, p.z, r.x, r.y, r.z); camPar.pos.x = p.x; camPar.pos.y = p.y; camPar.pos.z = p.z; camPar.rot.fromRotVector(r); }
bool ReadIniParameters(string szFile, InitialParameter &IniParam) { /////////////////////////////////////////////////////////////////////////////// // Section: Define variables CDataFile CfgFile; vector<int> chset; vector<float> windlen; /////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////// // Section: Testing input parameters and initialize parameters if (CfgFile.Load(szFile.c_str())) { if (CheckCfgParameterKeyExist(CfgFile,"dir","Initialization")) IniParam.dir = CfgFile.GetString("dir","Initialization"); else IniParam.dir = "C:"; if (CheckCfgParameterKeyExist(CfgFile,"decimation_frequency_Hz","Initialization")) IniParam.Decimation_Frequency = CfgFile.GetInt("decimation_frequency_Hz","Initialization"); else IniParam.Decimation_Frequency = 20; if (CheckCfgParameterKeyExist(CfgFile,"spatial_filter","Initialization")) IniParam.SF = CfgFile.GetInt("spatial_filter","Initialization"); else IniParam.SF = 1; if (CheckCfgParameterKeyExist(CfgFile,"penter","Initialization")) IniParam.penter = CfgFile.GetFloat("penter","Initialization"); else IniParam.penter = 0.1000f; if (CheckCfgParameterKeyExist(CfgFile,"premove","Initialization")) IniParam.premove = CfgFile.GetFloat("premove","Initialization"); else IniParam.premove = 0.1500f; if (CheckCfgParameterKeyExist(CfgFile,"maxiter","Initialization")) IniParam.maxiter = CfgFile.GetInt("maxiter","Initialization"); else IniParam.maxiter = 60; if (CheckCfgParameterKeyExist(CfgFile,"channel_set","Initialization")) { string channelset = CfgFile.GetValue("channel_set","Initialization"); read_vector(channelset, IniParam.channel_set); } else IniParam.channel_set.push_back(1); if (CheckCfgParameterKeyExist(CfgFile,"Resp_window_ms","Initialization")) { string Resp_window = CfgFile.GetValue("Resp_window_ms","Initialization"); read_vector(Resp_window, IniParam.windlen); } else { IniParam.windlen.push_back(0); IniParam.windlen.push_back(800); } return true; } else // file does not exist return false; }