Bug in conversion from FileNode to Vec2i (Bug #4417)
Description
Hi! I'm using OpenCV 3.0.0 with Visual Studio 2013 C++.
I catched some bug in conversion from FileNode to Vec2i.
I have file with data, that was created by class Params (see below):%YAML:1.0
prms0:
mh: [ 233, 255 ]
I have class, write and read functions was created as http://docs.opencv.org/doc/tutorials/core/file_input_output_with_xml_yml/file_input_output_with_xml_yml.html chapterâ„–5:
@class Params{
public:
Vec2i mh;
void write(FileStorage& fs) const {
fs << "{" << "mh" << mh <<"}";
}
void read(const FileNode& node){
mh = (Vec2i)node["mh"]; //if I use this way for read node "mh" then mh=[ 2147483647, 0 ], this is NOT properly!
//if I use this way for read node "mh" then mh=[ 233, 255 ], this is properly!
FileNode n = node["mh"];
FileNodeIterator it = n.begin(), it_end = n.end();
for (int i=0; it != it_end; +it,i+)
mh[i] = (int)*it;
}
Params(){
mh = Vec2i(100, 500);
}
};
void write(FileStorage& fs, const std::string&, const Params& x)
{
x.write(fs);
}
void read(const FileNode& node, Params& x, const Params& default_value = Params())
{
if (node.empty())
x = default_value;
else
x.read(node);
}@
I don't why site doesn't show this part as code.
How I used this:
...blablabla.....
fs = FileStorage(param_n, FileStorage::WRITE);
fs << "prms0" << prms[0];
fs.release();
...blablabla.....
History
Updated by Maksim Shabunin over 9 years ago
Issue has been transferred to GitHub: https://github.com/Itseez/opencv/issues/5029