Ask Your Question
0

Save custom object in .yml

asked 2017-02-22 01:03:13 -0600

vincentliu gravatar image

updated 2017-02-22 01:08:03 -0600

Hi, does anyone know how to save a custom object in .yml using FileStorage ?

According to the online document: http://docs.opencv.org/3.0-rc1/dd/d74...

I add the following snippet in my custom class ColorSample:

void ColorSample::read(const FileNode& node) {
mat = (Mat)node["mat"]; // Error: no matching function for call to cv::Mat::Mat(cv::FileNode)
loc = (Point)node["loc"]; // Error: no matching function for call to cv::Point_<int>::Point_(cv::FileNode)
color = (Scalar)node["color"];
}

Does anyone know how to solve the first two lines in ColorSample::read() ? Thanks

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
2

answered 2017-02-22 01:53:25 -0600

berak gravatar image

please use the >> operator for reading from a filenode, don't try to cast it:

  node["mat"] >> mat;
  node["loc"] >> loc;
  node["color"] >> color;
edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2017-02-22 01:03:13 -0600

Seen: 313 times

Last updated: Feb 22 '17