cv::Algorithm read/write in API 3?
Hi
I am using cv::ml::RTrees to train a Random Forest model and predict some values. I'd like to store the final trained model in some custom structure and also to write ToString and FromString methods. I have seen that API version 2 has read/write methods and a FileStorage structure which would help to read/write from string but I have read that these are deprecated in API 3. Is this true? And if so, are there any alternative methods provided to replace those (save/load are not valid answers here, as these store and read from file which I don't want to do)? Also, does OpenCV provide any class or set of classes to access the final trained model (e.g. trees, nodes, values) so that I can safely store the model in code without any need to train again?
Thanks in advance for your help.
where did you find it ?
what you want is for sure possible (at least with current 4.x),
FileStorage can be initialized from a string in memory, and you can read() from a FileStorage, but you have to solve that problem:
-- how to properly embed an xml string into a c++ program.
Thanks for the reply.
I saw it in "Learning OpenCV 3: Computer Vision in C++ with the OpenCV Library", by Adrian Kaehler and Gary Bradski, page 801, footnote 2 (in the context of cv::Algorithm): "In the distant past, there were two pairs of functions for reading and writing: save()/load() and write()/read(), with the latter pair being lower-level functions that interacted with the now legacy CvFileStorage file interface structure. That pair should now be considered deprecated, along with the structure they once accessed, and the only interface that should be used in modern code is the save()/load() interface".
From this I understood that read() and write() were now deprecated but I understand from your answer they are not?
Any idea about my final question?
^^ if i read that sentence a few times, it seems to say: prefer the high level load/save functions, to the low level read/write methods ?
indeed. it was entirely replaced from scratch with cv::FileStorage