本文整理汇总了C++中FileNode::end方法的典型用法代码示例。如果您正苦于以下问题:C++ FileNode::end方法的具体用法?C++ FileNode::end怎么用?C++ FileNode::end使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FileNode
的用法示例。
在下文中一共展示了FileNode::end方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: load
bool Calibration::load(string filename, bool absolute) {
imagePoints.clear();
//FileStorage fs(ofToDataPath(filename, absolute), FileStorage::READ);
FileStorage fs(filename, FileStorage::READ);
if (!fs.isOpened())
return false;
cv::Size imageSize, sensorSize;
Mat cameraMatrix;
fs["cameraMatrix"] >> cameraMatrix;
fs["imageSize_width"] >> imageSize.width;
fs["imageSize_height"] >> imageSize.height;
fs["sensorSize_width"] >> sensorSize.width;
fs["sensorSize_height"] >> sensorSize.height;
fs["distCoeffs"] >> distCoeffs;
fs["reprojectionError"] >> reprojectionError;
FileNode features = fs["features"];
for(FileNodeIterator it = features.begin(); it != features.end(); it++) {
vector<Point2f> cur;
(*it) >> cur;
imagePoints.push_back(cur);
}
addedImageSize = imageSize;
distortedIntrinsics.setup(cameraMatrix, imageSize, sensorSize);
updateUndistortion();
ready = true;
return true;
}
示例2: read
void CvCascadeBoostTree::read( const FileNode &node, CvBoost* _ensemble,
CvDTreeTrainData* _data )
{
int maxCatCount = ((CvCascadeBoostTrainData*)_data)->featureEvaluator->getMaxCatCount();
int subsetN = (maxCatCount + 31)/32;
int step = 3 + ( maxCatCount>0 ? subsetN : 1 );
queue<CvDTreeNode*> internalNodesQueue;
FileNodeIterator internalNodesIt, leafValsuesIt;
CvDTreeNode* prntNode, *cldNode;
clear();
data = _data;
ensemble = _ensemble;
pruned_tree_idx = 0;
// read tree nodes
FileNode rnode = node[CC_INTERNAL_NODES];
internalNodesIt = rnode.end();
leafValsuesIt = node[CC_LEAF_VALUES].end();
internalNodesIt--; leafValsuesIt--;
for( size_t i = 0; i < rnode.size()/step; i++ )
{
prntNode = data->new_node( 0, 0, 0, 0 );
if ( maxCatCount > 0 )
{
prntNode->split = data->new_split_cat( 0, 0 );
for( int j = subsetN-1; j>=0; j--)
{
*internalNodesIt >> prntNode->split->subset[j]; internalNodesIt--;
}
}
else
{
示例3: ReadRightRects
void ReadRightRects(vector<ImageRecognition::SlidingRect> &rightRects, const string &xml_filename, RecognitionStatistics &stat)
{
using namespace Utils;
FileStorage file_storage(xml_filename, FileStorage::READ);
FileNode images = file_storage["images"];
rightRects.reserve(images.size());
for (FileNodeIterator it = images.begin(); it != images.end(); ++it)
{
string part_filename = string(*it);
int dot_pos = part_filename.find_first_of('.');
if (dot_pos != -1)
part_filename = part_filename.substr(0, dot_pos);
stringstream ss(part_filename);
vector<string> parts;
string part;
while (getline(ss, part, '_'))
parts.push_back(part);
rightRects.push_back(ImageRecognition::SlidingRect());
int last = parts.size() - 1;
rightRects.back().rect.x = str2int(parts[last - 3]);
rightRects.back().rect.y = str2int(parts[last - 2]);
rightRects.back().rect.width = str2int(parts[last - 1]);
rightRects.back().rect.height = str2int(parts[last]);
}
}
示例4: readModelViews
static bool readModelViews( const string& filename, vector<Point3f>& box,
vector<string>& imagelist,
vector<Rect>& roiList, vector<Vec6f>& poseList )
{
imagelist.resize(0);
roiList.resize(0);
poseList.resize(0);
box.resize(0);
FileStorage fs(filename, FileStorage::READ);
if( !fs.isOpened() )
return false;
fs["box"] >> box;
FileNode all = fs["views"];
if( all.type() != FileNode::SEQ )
return false;
FileNodeIterator it = all.begin(), it_end = all.end();
for(; it != it_end; ++it)
{
FileNode n = *it;
imagelist.push_back((string)n["image"]);
FileNode nr = n["rect"];
roiList.push_back(Rect((int)nr[0], (int)nr[1], (int)nr[2], (int)nr[3]));
FileNode np = n["pose"];
poseList.push_back(Vec6f((float)np[0], (float)np[1], (float)np[2],
(float)np[3], (float)np[4], (float)np[5]));
}
return true;
}
示例5: runTestsSVMTable
/*
* Like runTests, but using the quantized lookup table
* instead of the support vector machine directly.
*/
void runTestsSVMTable()
{
ColonyCounter colonyCounter;
colonyCounter.loadTrainingQuantized(svmLookup, svmQuants);
FileStorage fs("samples/tests.yml", FileStorage::READ);
double absErrorSum = 0;
FileNode features = fs["tests"];
FileNodeIterator it = features.begin(), it_end = features.end();
int idx = 0;
for( ; it != it_end; ++it, idx++ )
{
string path;
(*it)["path"] >> path;
int red = (int)(*it)["red"];
int blue = (int)(*it)["blue"];
double error;
runTest(colonyCounter, "samples/" + path, red, blue, error);
absErrorSum += fabs(error);
}
fs.release();
printf("Error %f\n", absErrorSum);
}
示例6: main
int main(int, char** argv){
FileStorage fs2("test.xml", FileStorage::READ);
if (!fs2.isOpened()){
cout << "failed to open test.xml :(" << endl;
return 1;
}
// first method: use (type) operator on FileNode.
int frameCount = (int)fs2["frameCount"];
std::string date;
// second method: use FileNode::operator >>
fs2["calibrationDate"] >> date;
Mat camera_intrinsics_1, camera_intrinsics_2, camera_intrinsics_3, camera_intrinsics_4;
Mat camera_extrinsics_1, camera_extrinsics_2, camera_extrinsics_3, camera_extrinsics_4;
fs2["camera_intrinsics_1"] >> camera_intrinsics_1;
fs2["camera_intrinsics_2"] >> camera_intrinsics_2;
fs2["camera_intrinsics_3"] >> camera_intrinsics_3;
fs2["camera_intrinsics_4"] >> camera_intrinsics_4;
fs2["camera_extrinsics_1"] >> camera_extrinsics_1;
fs2["camera_extrinsics_2"] >> camera_extrinsics_2;
fs2["camera_extrinsics_3"] >> camera_extrinsics_3;
fs2["camera_extrinsics_4"] >> camera_extrinsics_4;
cout << camera_extrinsics_4 << endl;
cout << camera_intrinsics_4 << endl;
//fs2["distCoeffs"] >> distCoeffs2;
//cout << "frameCount: " << frameCount << endl
// << "calibration date: " << date << endl
// << "camera matrix: " << cameraMatrix2 << endl
// << "distortion coeffs: " << distCoeffs2 << endl;
FileNode features = fs2["features"];
FileNodeIterator it = features.begin(), it_end = features.end();
int idx = 0;
std::vector<uchar> lbpval;
// iterate through a sequence using FileNodeIterator
for( ; it != it_end; ++it, idx++ )
{
cout << "feature #" << idx << ": ";
cout << "x=" << (int)(*it)["x"] << ", y=" << (int)(*it)["y"] << ", lbp: (";
// you can also easily read numerical arrays using FileNode >> std::vector operator.
(*it)["lbp"] >> lbpval;
for( int i = 0; i < (int)lbpval.size(); i++ )
cout << " " << (int)lbpval[i];
cout << ")" << endl;
}
fs2.release();
}
示例7: readFileNodeList
inline void readFileNodeList(const FileNode& fn, vector<_Tp>& result) {
if (fn.type() == FileNode::SEQ) {
for (FileNodeIterator it = fn.begin(); it != fn.end();) {
_Tp item;
it >> item;
result.push_back(item);
}
}
}
示例8: read
void read(const FileNode& node, vector<KeyPoint>& keypoints)
{
keypoints.resize(0);
FileNodeIterator it = node.begin(), it_end = node.end();
for( ; it != it_end; )
{
KeyPoint kpt;
it >> kpt.pt.x >> kpt.pt.y >> kpt.size >> kpt.angle >> kpt.response >> kpt.octave;
keypoints.push_back(kpt);
}
}
示例9: read
bool HOGEvaluator::read( const FileNode& node )
{
features->resize(node.size());
featuresPtr = &(*features)[0];
FileNodeIterator it = node.begin(), it_end = node.end();
for(int i = 0; it != it_end; ++it, i++)
{
if(!featuresPtr[i].read(*it))
return false;
}
return true;
}
示例10: readDetections
static void readDetections( FileStorage fs, const string& nodeName, vector<LatentSvmDetector::ObjectDetection>& detections )
{
detections.clear();
FileNode fn = fs.root()[nodeName];
FileNodeIterator fni = fn.begin();
while( fni != fn.end() )
{
LatentSvmDetector::ObjectDetection d;
fni >> d.rect.x >> d.rect.y >> d.rect.width >> d.rect.height
>> d.score >> d.classID;
detections.push_back( d );
}
}
示例11: readStringList
static bool readStringList( const string& filename, vector<string>& l )
{
l.resize(0);
FileStorage fs(filename, FileStorage::READ);
if( !fs.isOpened() )
return false;
FileNode n = fs.getFirstTopLevelNode();
if( n.type() != FileNode::SEQ )
return false;
FileNodeIterator it = n.begin(), it_end = n.end();
for( ; it != it_end; ++it )
l.push_back((string)*it);
return true;
}
示例12: main
int main( )
{
//改变console字体颜色
system("color 6F");
ShowHelpText();
//初始化
FileStorage fs2("test.yaml", FileStorage::READ);
// 第一种方法,对FileNode操作
int frameCount = (int)fs2["frameCount"];
std::string date;
// 第二种方法,使用FileNode运算符> >
fs2["calibrationDate"] >> date;
Mat cameraMatrix2, distCoeffs2;
fs2["cameraMatrix"] >> cameraMatrix2;
fs2["distCoeffs"] >> distCoeffs2;
cout << "frameCount: " << frameCount << endl
<< "calibration date: " << date << endl
<< "camera matrix: " << cameraMatrix2 << endl
<< "distortion coeffs: " << distCoeffs2 << endl;
FileNode features = fs2["features"];
FileNodeIterator it = features.begin(), it_end = features.end();
int idx = 0;
std::vector<uchar> lbpval;
//使用FileNodeIterator遍历序列
for( ; it != it_end; ++it, idx++ )
{
cout << "feature #" << idx << ": ";
cout << "x=" << (int)(*it)["x"] << ", y=" << (int)(*it)["y"] << ", lbp: (";
// 我们也可以使用使用filenode > > std::vector操作符很容易的读数值阵列
(*it)["lbp"] >> lbpval;
for( int i = 0; i < (int)lbpval.size(); i++ )
cout << " " << (int)lbpval[i];
cout << ")" << endl;
}
fs2.release();
//程序结束,输出一些帮助文字
printf("\n文件读取完毕,请输入任意键结束程序~");
getchar();
return 0;
}
示例13: loadBBoxes
bool DataSetVOC::loadBBoxes(CStr &nameNE, vector<Vec4i> &boxes, vecI &clsIdx)
{
string fName = format(_S(annoPathW), _S(nameNE));
FileStorage fs(fName, FileStorage::READ);
FileNode fn = fs["annotation"]["object"];
boxes.clear();
clsIdx.clear();
if (fn.isSeq()){
for (FileNodeIterator it = fn.begin(), it_end = fn.end(); it != it_end; it++)
loadBox(*it, boxes, clsIdx);
}
else
loadBox(fn, boxes, clsIdx);
return true;
}
示例14: getMapFromFile
int Map::getMapFromFile(string filename)
{
FileStorage fs;
fs.open(filename, FileStorage::READ);
FileNode n = fs["Map"];
if (n.type() != FileNode::SEQ)
return -1; // Map n'est pas une séquence
FileNodeIterator it = n.begin(), it_end = n.end(); // Itérateur pour lire la séquence
for (; it != it_end; ++it)
cout << (string)*it << endl;
fs.release(); // énoncer la fermeture
return 0;
}
示例15: readVectorOfVector
void readVectorOfVector(FileStorage &fns, string name, vector<vector<KeyPoint> > &vov)
{
vov.clear();
FileNode fn = fns[name];
if (fn.empty()){
return;
}
FileNodeIterator current = fn.begin(), it_end = fn.end(); // Go through the node
for (; current != it_end; ++current)
{
vector<KeyPoint> tmp;
FileNode item = *current;
read(item, tmp);
vov.push_back(tmp);
}
}