本文整理汇总了C++中FileStorage::isOpened方法的典型用法代码示例。如果您正苦于以下问题:C++ FileStorage::isOpened方法的具体用法?C++ FileStorage::isOpened怎么用?C++ FileStorage::isOpened使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FileStorage
的用法示例。
在下文中一共展示了FileStorage::isOpened方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: load
void load()
{
vector<string> path_preference{
"config.yaml",
"/etc/photo-booth/config.yaml"
};
FileStorage fs;
for (string &path : path_preference)
{
fs.open(path, FileStorage::READ);
if (fs.isOpened())
{
// TODO: Debug level before reading config
//cout << "Reading configuration from " << path << endl;
break;
}
}
if (!fs.isOpened())
{
// TODO: Log search path.
throw runtime_error(string(_("Couldn't find config file.")));
}
string boolString;
fs["debug"] >> boolString;
debug = (boolString == "true");
fs["motion_interval"] >> motion_interval;
fs["frame_pause"] >> frame_pause;
fs["satisfied_pause"] >> satisfied_pause;
fs["output_dir"] >> output_dir;
fs["camera_id"] >> camera_id;
fs["countdown"] >> countdown;
fs["initial_countdown"] >> initial_countdown;
fs["minimum_area"] >> minimum_area;
fs["max_allowed_area"] >> max_allowed_area;
fs["acculum_weight"] >> acculum_weight;
fs["motion_score_threshold"] >> motion_score_threshold;
fs["sound_cmd"] >> sound_cmd;
// Expand output_dir path.
wordexp_t exp_result;
wordexp(output_dir.c_str(), &exp_result, 0);
output_dir = exp_result.we_wordv[0];
wordfree(&exp_result);
// Copy the map of soundfiles.
for (FileNode sound : fs["sounds"])
{
sounds[sound.name()] = (string)sound;
}
}
示例2: assert
//==============================================================================
void
shape_model::
write(FileStorage &fs) const
{
assert(fs.isOpened());
fs << "{" << "V" << V << "e" << e << "C" << C << "Y"<<Y<< "}";
}
示例3: kNNSearchWithHOG
void kNNSearcher::kNNSearchWithHOG(const Mat &inputImage, const QStringList &imPath,
Mat &indexes, Mat &weights, int k)
{
//resize inputImage to the same size of training image
Mat temp = imread( imPath[0].toLocal8Bit().data(), CV_LOAD_IMAGE_GRAYSCALE );
Mat inputIm;
resize( inputImage, inputIm, temp.size() );
//compute the HOG descriptor of target image
HOGDescriptor *hogDesr = new HOGDescriptor( cvSize( 640, 480 ), cvSize( 160, 120 ), cvSize( 160,120 ), cvSize( 160, 120 ), 9 );
std::vector<float> targetDescriptor;
hogDesr->compute( inputIm, targetDescriptor, Size( 0, 0 ), Size( 0, 0) );
//###################################################################################
//load the training descriptors into descriptorMat if there exist a HOGof44blocks.yaml file
//otherwise, execute the train program
Mat descriptorMat;
QString const HOGMatfile = "HOGof44blocks.yaml";
FileStorage fs;
fs.open( HOGMatfile.toLocal8Bit().data(), FileStorage::READ );
if( fs.isOpened() ){
// the HOGof44blocks.yaml does exist
fs["HOGMat"] >> descriptorMat;
}else{
示例4: savePoints
int Orbit::savePoints(std::string name)
{
FileStorage fs;
string fileName=name+"orbit.yml";
fs.open(fileName, FileStorage::WRITE);
if(fs.isOpened()==false)
{
fs.release();
return -1;
}
fs<<"orbit";
fs<<"[";
for(size_t i=0;i<robotPoints.size();i++)
{
fs<<"{";
fs<<"x"<<robotPoints[i].x;
fs<<"y"<<robotPoints[i].y;
fs<<"z"<<robotPoints[i].z;
fs<<"}";
}
fs<<"]";
fs.release();
return 0;
}
示例5: loadPoints
int Orbit::loadPoints(std::string name)
{
FileStorage fs;
string fileName=name+"orbit.yml";
fs.open(fileName, FileStorage::READ);
if(fs.isOpened()==false)
{
fs.release();
return -1;
}
FileNode orbitNode=fs["orbit"];
FileNodeIterator it=orbitNode.begin();
for(size_t i=0;it!=orbitNode.end();i++,it++)
{
Point3f tmp;
(*it)["x"]>>tmp.x;
(*it)["y"]>>tmp.y;
(*it)["z"]>>tmp.z;
cout<<tmp<<endl;
robotPoints.push_back(tmp);
}
fs.release();
return 0;
}
示例6: processStereoMatchingResults
int CV_StereoMatchingTest::processStereoMatchingResults( FileStorage& fs, int caseIdx, bool isWrite,
const Mat& leftImg, const Mat& rightImg,
const Mat& trueLeftDisp, const Mat& trueRightDisp,
const Mat& leftDisp, const Mat& rightDisp,
const QualityEvalParams& qualityEvalParams )
{
// rightDisp is not used in current test virsion
int code = cvtest::TS::OK;
assert( fs.isOpened() );
assert( trueLeftDisp.type() == CV_32FC1 );
assert( trueRightDisp.empty() || trueRightDisp.type() == CV_32FC1 );
assert( leftDisp.type() == CV_32FC1 && rightDisp.type() == CV_32FC1 );
// get masks for unknown ground truth disparity values
Mat leftUnknMask, rightUnknMask;
DatasetParams params = datasetsParams[caseDatasets[caseIdx]];
absdiff( trueLeftDisp, Scalar(params.dispUnknVal), leftUnknMask );
leftUnknMask = leftUnknMask < numeric_limits<float>::epsilon();
assert(leftUnknMask.type() == CV_8UC1);
if( !trueRightDisp.empty() )
{
absdiff( trueRightDisp, Scalar(params.dispUnknVal), rightUnknMask );
rightUnknMask = rightUnknMask < numeric_limits<float>::epsilon();
assert(leftUnknMask.type() == CV_8UC1);
}
// calculate errors
vector<float> rmss, badPxlsFractions;
calcErrors( leftImg, rightImg, trueLeftDisp, trueRightDisp, leftUnknMask, rightUnknMask,
leftDisp, rightDisp, rmss, badPxlsFractions, qualityEvalParams );
if( isWrite )
{
fs << caseNames[caseIdx] << "{";
//cvWriteComment( fs.fs, RMS_STR.c_str(), 0 );
writeErrors( RMS_STR, rmss, &fs );
//cvWriteComment( fs.fs, BAD_PXLS_FRACTION_STR.c_str(), 0 );
writeErrors( BAD_PXLS_FRACTION_STR, badPxlsFractions, &fs );
fs << "}"; // datasetName
}
else // compare
{
ts->printf( cvtest::TS::LOG, "\nquality of case named %s\n", caseNames[caseIdx].c_str() );
ts->printf( cvtest::TS::LOG, "%s\n", RMS_STR.c_str() );
writeErrors( RMS_STR, rmss );
ts->printf( cvtest::TS::LOG, "%s\n", BAD_PXLS_FRACTION_STR.c_str() );
writeErrors( BAD_PXLS_FRACTION_STR, badPxlsFractions );
FileNode fn = fs.getFirstTopLevelNode()[caseNames[caseIdx]];
vector<float> validRmss, validBadPxlsFractions;
readErrors( fn, RMS_STR, validRmss );
readErrors( fn, BAD_PXLS_FRACTION_STR, validBadPxlsFractions );
int tempCode = compareErrors( rmss, validRmss, rmsEps, RMS_STR );
code = tempCode==cvtest::TS::OK ? code : tempCode;
tempCode = compareErrors( badPxlsFractions, validBadPxlsFractions, fracEps, BAD_PXLS_FRACTION_STR );
code = tempCode==cvtest::TS::OK ? code : tempCode;
}
return code;
}
示例7: importGroundTruth
void TODBaseImporter::importGroundTruth(int testImageIdx, PoseRT &model2test, bool shiftByOffset, PoseRT *offsetPtr, bool isKeyFrame) const
{
std::stringstream testPoseFilename;
if (isKeyFrame)
{
testPoseFilename << testFolder +"/image_" << std::setfill('0') << std::setw(5) << testImageIdx << ".png.pose.yaml.kf";
}
else
{
testPoseFilename << testFolder +"/image_" << std::setfill('0') << std::setw(5) << testImageIdx << ".png.pose.yaml";
}
FileStorage testPoseFS;
testPoseFS.open(testPoseFilename.str(), FileStorage::READ);
CV_Assert(testPoseFS.isOpened());
testPoseFS["pose"]["rvec"] >> model2test.rvec;
testPoseFS["pose"]["tvec"] >> model2test.tvec;
testPoseFS.release();
if (shiftByOffset || offsetPtr != 0)
{
PoseRT offset;
importOffset(offset);
if (shiftByOffset)
{
model2test = model2test * offset;
}
if (offsetPtr != 0)
{
*offsetPtr = offset;
}
}
}
示例8: printf
Pattern::Pattern()
{
//-- Read in the file of parameters
std::string file_name = "data/book.yml";
FileStorage fs;
fs.open(file_name, FileStorage::READ);
if(fs.isOpened())
{
printf("Initializer: %s is opened for reading.\n", file_name.c_str());
fs["objWidth"] >> obj_width;
fs["objHeight"] >> obj_height;
fs["intrinsics"] >> camera.mat_intrinsics;
fs["extrinsics"] >> camera.mat_extrinsics;
fs["corners"] >> vec_corners;
fs["distCoeffs"] >> camera.mat_distCoeffs;
fs["scale"] >> scale;
fs.release();
printf("Values are\n");
std::cout << "objWidth: " << obj_width << std::endl
<< "objHeight: " << obj_height << std::endl
<< "intrinsics:\n" << camera.mat_intrinsics << std::endl
<< "extrinsics:\n" << camera.mat_extrinsics << std::endl
<< "corners: " << vec_corners << std::endl
<< "distCoeffs:\n" << camera.mat_distCoeffs << std::endl
<< "H_groundTruth:\n" << H_groundTruth << std::endl;
printf("Pattern is constructed.\n");
current_state = PATTERN_STATE_SUCCESS;
}
示例9: write
void RetinaImpl::write( FileStorage& fs ) const
{
if (!fs.isOpened())
return; // basic error case
fs<<"OPLandIPLparvo"<<"{";
fs << "colorMode" << _retinaParameters.OPLandIplParvo.colorMode;
fs << "normaliseOutput" << _retinaParameters.OPLandIplParvo.normaliseOutput;
fs << "photoreceptorsLocalAdaptationSensitivity" << _retinaParameters.OPLandIplParvo.photoreceptorsLocalAdaptationSensitivity;
fs << "photoreceptorsTemporalConstant" << _retinaParameters.OPLandIplParvo.photoreceptorsTemporalConstant;
fs << "photoreceptorsSpatialConstant" << _retinaParameters.OPLandIplParvo.photoreceptorsSpatialConstant;
fs << "horizontalCellsGain" << _retinaParameters.OPLandIplParvo.horizontalCellsGain;
fs << "hcellsTemporalConstant" << _retinaParameters.OPLandIplParvo.hcellsTemporalConstant;
fs << "hcellsSpatialConstant" << _retinaParameters.OPLandIplParvo.hcellsSpatialConstant;
fs << "ganglionCellsSensitivity" << _retinaParameters.OPLandIplParvo.ganglionCellsSensitivity;
fs << "}";
fs<<"IPLmagno"<<"{";
fs << "normaliseOutput" << _retinaParameters.IplMagno.normaliseOutput;
fs << "parasolCells_beta" << _retinaParameters.IplMagno.parasolCells_beta;
fs << "parasolCells_tau" << _retinaParameters.IplMagno.parasolCells_tau;
fs << "parasolCells_k" << _retinaParameters.IplMagno.parasolCells_k;
fs << "amacrinCellsTemporalCutFrequency" << _retinaParameters.IplMagno.amacrinCellsTemporalCutFrequency;
fs << "V0CompressionParameter" << _retinaParameters.IplMagno.V0CompressionParameter;
fs << "localAdaptintegration_tau" << _retinaParameters.IplMagno.localAdaptintegration_tau;
fs << "localAdaptintegration_k" << _retinaParameters.IplMagno.localAdaptintegration_k;
fs<<"}";
}
示例10: X
//=============================================================================
void
ft_data::
write(FileStorage &fs) const
{
assert(fs.isOpened());
fs << "{";
fs << "n_connections" << (int)connections.size();
for(int i = 0; i < int(connections.size()); i++){
char str[256]; const char* ss;
sprintf(str,"connections %d 0",i); ss = str; fs << ss << connections[i][0];
sprintf(str,"connections %d 1",i); ss = str; fs << ss << connections[i][1];
}
fs << "n_symmetry" << (int)symmetry.size();
for(int i = 0; i < int(symmetry.size()); i++){
char str[256]; const char* ss;
sprintf(str,"symmetry %d",i); ss = str; fs << ss << symmetry[i];
}
fs << "n_images" << (int)imnames.size();
for(int i = 0; i < int(imnames.size()); i++){
char str[256]; const char* ss;
sprintf(str,"image %d",i); ss = str; fs << ss << imnames[i];
}
int n = points[0].size(),N = points.size();
Mat X(2*n,N,CV_32F); X = -1;
for(int i = 0; i < N; i++){
if(int(points[i].size()) == n){
for(int j = 0; j < n; j++){
X.at<float>(2*j ,i) = points[i][j].x;
X.at<float>(2*j+1,i) = points[i][j].y;
}
}
}
fs << "shapes" << X << "}";
}
示例11: writeKeypoints
inline void writeKeypoints( FileStorage& fs, const vector<KeyPoint>& keypoints, int imgIdx )
{
if( fs.isOpened() )
{
stringstream imgName; imgName << "img" << imgIdx;
write( fs, imgName.str(), keypoints );
}
}
示例12: openToWriteKeypointsFile
void DetectorQualityEvaluator::openToWriteKeypointsFile( FileStorage& fs, int datasetIdx )
{
string filename = data_path + KEYPOINTS_DIR + algName + "_"+ DATASET_NAMES[datasetIdx] + ".xml.gz" ;
fs.open(filename, FileStorage::WRITE);
if( !fs.isOpened() )
printf( "keypoints can not be written in file %s because this file can not be opened\n", filename.c_str() );
}
示例13: readKeypointsAndDesc
void readKeypointsAndDesc( char* ymlpath , std::vector<KeyPoint>& ref_keypoints , Mat& ref_desc ){
FileStorage fs ;
fs.open( ymlpath , FileStorage::READ);
if(fs.isOpened()){
read(fs["desc"], ref_keypoints );
read(fs["kps"], ref_desc);
}
fs.release();
}
示例14: PCAwrite
void PCAwrite(FileStorage& fs, PCA& pca)
{
CV_Assert( fs.isOpened() );
fs << "name" << "PCA";
fs << "vectors" << pca.eigenvectors;
fs << "values" << pca.eigenvalues;
fs << "mean" << pca.mean;
}
示例15: loaddistancematrix
void loaddistancematrix(){
tic();
FileStorage fs;
printf("Opening data file...\n");
fs.open("distances.yml", FileStorage::READ);
if(fs.isOpened()){
//file already computed, load it
printf("Loading data...\n");
fs["distances"] >> distances;
fs["freespace"] >> freespace;
}