O'Reilly logo

OpenCV By Example by Vinícius Godoy, David Millán Escrivá, Prateek Joshi

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Basic data persistence and storage

Before we finish this chapter, we will explore the OpenCV functions to store and read our data. In many applications, such as calibration or machine learning, when we are done with the calculations, we need to save the results in order to retrieve them in the next executions. For this purpose, OpenCV provides an XML/YAML persistence layer.

Writing to a file storage

To write a file with some OpenCV data or other numeric data, we can use the FileStorage class using the streaming c operator such as STL streaming:

#include "opencv2/opencv.hpp" using namespace cv; int main(int, char** argv) { // create our writter FileStorage fs("test.yml", FileStorage::WRITE); // Save an int int fps= 5; fs << "fps" << fps; // Create ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required