FileStorage module (YML)

One of the most useful things OpenCV has is YML file library. I canno't believe have easy to use they are. Before I learned this, I was making complicated algorithms and writing array of data like detected keypoints or descriptrs in "txt" file. But there is much simpler solution...


It's pretty straight forward how to use the FileStorage module in OpenCV, I don't think after showing the code snippets I need to explain anything.

Maybe if you don't know the concept of yml or xml files you should go here: http://en.wikipedia.org/wiki/YAML

 

Ok let's get down to bussiness!

 

To write array of data into yml file:

fileString = "keypoints.yml";
cv::FileStorage fs(fileString, cv::FileStorage::WRITE);
 
write(fs,"keyPointsSURF", keypointsSURF);              
write(fs,"descriptorsSURF", descriptorsSURF);  
fs.release()

 

And to access the data you do it like this:

fs.open("keypoints.yml", FileStorage::READ);
    if(fs.isOpened())
    {
        read(fs["descriptorsSURF"], descriptorsSURF); 
        read(fs["keyPointsSURF"], keypointsSURF);   
}   
fs.release();

Just a note:

The "read" command can be swapped with these lines, I personally prefer the "read" method

fs["descriptorsSURF"] >> descriptorsSURF;
fs["keyPointsSURF"] >> keypointsSURF;

 



Related Articles



ADVERTISEMENT

  • Proact IMS

    Proact IMS in Touch gesture recognition using body capacitance

    Single‑electrode detection and differentiating gestures like pinch, grab, or multi‑finger touch by how much skin contacts the electrode is a clever design.Explore cutting-edge services and products at https://www.proact-ims.com/ or contact us at +91 80 3542 9949 for collaboration and...

    Proact IMS

    Proact IMS in Touch gesture recognition using body capacitance

    Single‑electrode detection and differentiating gestures like pinch, grab, or multi‑finger touch by how much skin contacts the electrode is a clever design.Explore cutting-edge services and products at https://www.proact-ims.com/ or contact us at +91 80 3542 9949 for collaboration and...

    Proact IMS

    Proact IMS in Strain Gauge based weight sensor (load cell)

    Clear explanation of principles (strain, Wheatstone bridge, gauge factor) — especially helpful for beginners..Explore cutting-edge services and products at https://www.proact-ims.com/ or contact us at +91 80 3542 9949 for collaboration and innovation opportunities. Elevate your...

    Proact IMS

    Proact IMS in Strain Gauge based weight sensor (load cell)

    Clear explanation of principles (strain, Wheatstone bridge, gauge factor) — especially helpful for beginners..Explore cutting-edge services and products at https://www.proact-ims.com/ or contact us at +91 80 3542 9949 for collaboration and innovation opportunities. Elevate your...

    Proact IMS

    Proact IMS in Strain Gauge based weight sensor (load cell)

    Clear explanation of principles (strain, Wheatstone bridge, gauge factor) — especially helpful for beginners..Explore cutting-edge services and products at https://www.proact-ims.com/ or contact us at +91 80 3542 9949 for collaboration and innovation opportunities. Elevate your...

    proactims

    proactims in Strain Gauge based weight sensor (load cell)

    This guide made the transition from basic principles to advanced applications smooth—it feels like a complete learning path for anyone new to...

    proactims

    proactims in Strain Gauge based weight sensor (load cell)

    This guide made the transition from basic principles to advanced applications smooth—it feels like a complete learning path for anyone new to...