how do I save/load a cv::Rect ?
Hi all, newbiw with openCV here. I am trying to save/load a cv::Rect and was hoping it would happen in an easy way - just as is the case with cv::Mat.
ok saving works as expected:
FileStorage fs(ofToDataPath(filename.c_str()), FileStorage::APPEND);
fs << "boundRect" << aCvRect;
opening the file I'll see appended
boundRect: [ 271, 100, 56, 72 ]
but then I fail to use the "expected" way to load this variable. Ideally, this should work (as does with cv::Mat):
FileStorage fs(ofToDataPath(filename.c_str()), FileStorage::READ);
fs["boundRect"] >> loadedCvRect;
well the above does not compile saying:
../../../addons/ofxOpenCv/libs/opencv/include/opencv2/core/operations.hpp|2825|error: no matching function for call to ‘read(const cv::FileNode&, cv::Rect_<int>&, cv::Rect_<int>)’|
If saving didn't work as expected, I would simply choose another way to save the rect, but since saving works, it seems odd that the loading has not been implemented. Am I missing something here? and how can I load the Rect values?
If this is not implemented, what is the suggested way? To store x,y,w,h in a 2x2 Mat and then store that?
thank you for your help