문제

What is the best way to edit/update YAML/YML file in OpenCV ?

도움이 되었습니까?

해결책

There is NO DIRECT support for update in YAML in general because it need to rewrite the whole file below the update node, so the reason in OpenCV as well as in yaml-cpp dont support direct edit of node value. So, the work around is re-create/write YAML structure again.

다른 팁

It looks like OpenCV has some native ways to read and write YAML. From this SO answer, I found the following "cheat sheet" for the OpenCV C++ interface:

https://code.ros.org/trac/opencv/export/3163/trunk/opencv/doc/opencv_cheatsheet.pdf

A portion of their example to write YAML:

FileStorage fs("test.yml", FileStorage::WRITE);
fs << "i" << 5 << "r" << 3.1 << "str" << "ABCDEFGH";

If you're interested in updating an existing YAML file, it seems like the best way is to read the existing file into your own data type, make your changes, and then write the new data to the file.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top