Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Hi guys. I think the cv::Rect class is written as an array of integers. So that

FileStorage fs(fileName, FileStorage::WRITE);   
Rect r(0,0,0,0);
fs << "myRectangle" << r;

Results in a file with an entry like this:

%YAML:1.0
myRectangle: [ 0, 0, 0, 0 ]

You can access it reading it as a vector of int and (if needed) construct a cv::Rect with its data.

std::vector<int> rect;
fs["myRectangle"] >> rect;
cv::Rect myRect(rect[0], rect[1], rect[2], rect[3]);

It worked for me! Best regards.

Hi guys. I think the cv::Rect class is written as an array of integers. So that

FileStorage fs(fileName, FileStorage::WRITE);   
Rect r(0,0,0,0);
fs << "myRectangle" << r;

Results in a file with an entry like this:

%YAML:1.0
myRectangle: [ 0, 0, 0, 0 ]

You can access it reading it as a vector of int and (if needed) construct a cv::Rect with its data.

FileStorage fs(fileName, FileStorage::READ);
std::vector<int> rect;
fs["myRectangle"] >> rect;
cv::Rect myRect(rect[0], rect[1], rect[2], rect[3]);

It worked for me! Best regards.