Ask Your Question
0

Xml and yml read

asked 2015-05-21 14:53:52 -0500

LBerger gravatar image

Hi,

I have saved two files one in xml and the other in yml using same method void ParametreOperation::write(cv::FileStorage& fs) const . Now I want to read it :

#include <opencv2/opencv.hpp> 
#include <iostream>
#include <map>
#include <fstream>

using namespace cv;

int main (int argc,char **argv)
{
FileStorage fsx("test.xml", FileStorage::READ);
FileStorage fsy("test.yml", FileStorage::READ);
}

I have got an exception for fsy :

OpenCV Error: Parsing error (test.yml(5): Incorrect indentation) in icvYMLParseValue, fi le ......\modules\core\src\persistence.cpp, line 1327

What's wrong in this file ?

Thanks you for your help

edit retag flag offensive close merge delete

Comments

I am not sure, have you saved it in yml format, or it is hand-made (written by you or someone else)? Try to open it with another yml library...

thdrksdfthmn gravatar imagethdrksdfthmn ( 2015-05-22 02:56:24 -0500 )edit

thanks for your answer To save it

FileStorage fsx("test.xml", FileStorage::WRITE);
FileStorage fsy("test.yml", FileStorage::WRITE);
p.write(fsx);
p.write(fsy);

I can read my data using xml data without problem. It looks like a bug in yml parser. But I'm not sure. have you got same exception with my data?

LBerger gravatar imageLBerger ( 2015-05-22 02:59:34 -0500 )edit

I have not tested, not enough time ... :(

thdrksdfthmn gravatar imagethdrksdfthmn ( 2015-05-22 04:00:24 -0500 )edit

1 answer

Sort by ยป oldest newest most voted
2

answered 2015-05-22 10:17:25 -0500

LBerger gravatar image

updated 2015-05-22 11:22:07 -0500

File generated in yml by opencv is not good if we believe this site (http://nodeca.github.io/js-yaml/)

For this site this file is good

%YAML:1.0 Operation1: { op:scharr_y, op1:1, op2:-1, res:-1, indEtape:1,
    idOperation:26, nomSequence:Macro 26, intParam:
    { nom:borderType, valeur:0, minVal:0, maxVal:3, pasVal:1 },
    { nom:ddepth, valeur:-1, minVal:-1, maxVal:5, pasVal:1 },
    doubleParam:
    { nom:delta, valeur:0., minVal:0., maxVal:1000., pasVal:1. },
    { nom:scale, valeur:1., minVal:1.0000000000000000e-002, maxVal:10.,
        pasVal:1.0000000000000001e-001 }, sizeParam:
    [], pointParam:
    [] } Operation0: { op:laplacian, op1:0, op2:-1, res:-1, indEtape:0,
    idOperation:26, nomSequence:Macro 26, intParam:
    { nom:borderType, valeur:0, minVal:0, maxVal:3, pasVal:1 },
    { nom:ddepth, valeur:50, minVal:0, maxVal:255, pasVal:1 },
    { nom:ksize, valeur:3, minVal:1, maxVal:7, pasVal:2 }, doubleParam:
    { nom:delta, valeur:0., minVal:0., maxVal:255., pasVal:1. },
    { nom:scale, valeur:1., minVal:0., maxVal:255.,
        pasVal:1.0000000000000001e-001 }, sizeParam:
    [], pointParam:
    [] }

I have deleted some underscore before "{" and put some comma after "}" bug 4356

edit flag offensive delete link more
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2015-05-21 14:53:52 -0500

Seen: 8,312 times

Last updated: May 22 '15