Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletter Hub
Free Learning
Arrow right icon
timer SALE ENDS IN
0 Days
:
00 Hours
:
00 Minutes
:
00 Seconds
Arrow up icon
GO TO TOP
OpenCV By Example

You're reading from   OpenCV By Example Enhance your understanding of Computer Vision and image processing by developing real-world projects in OpenCV 3

Arrow left icon
Product type Paperback
Published in Jan 2016
Publisher Packt
ISBN-13 9781785280948
Length 296 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Authors (3):
Arrow left icon
 Joshi Joshi
Author Profile Icon Joshi
Joshi
 Millán Escrivá Millán Escrivá
Author Profile Icon Millán Escrivá
Millán Escrivá
Vinícius G. Mendonça Vinícius G. Mendonça
Author Profile Icon Vinícius G. Mendonça
Vinícius G. Mendonça
Arrow right icon
View More author details
Toc

Table of Contents (18) Chapters Close

OpenCV By Example
Credits
About the Authors
About the Reviewers
www.PacktPub.com
Preface
1. Getting Started with OpenCV FREE CHAPTER 2. An Introduction to the Basics of OpenCV 3. Learning the Graphical User Interface and Basic Filtering 4. Delving into Histograms and Filters 5. Automated Optical Inspection, Object Segmentation, and Detection 6. Learning Object Classification 7. Detecting Face Parts and Overlaying Masks 8. Video Surveillance, Background Modeling, and Morphological Operations 9. Learning Object Tracking 10. Developing Segmentation Algorithms for Text Recognition 11. Text Recognition with Tesseract Index

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 some mat sample
    Mat m1= Mat::eye(2,3, CV_32F);
     Mat m2= Mat::ones(3,2, CV_32F);
     Mat result= (m1+1).mul(m1+3);
     // write the result
    fs << "Result" << result;
    // release the file...
lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at £13.99/month. Cancel anytime
Visually different images