0
<?xml version="1.0" encoding="UTF-8"?>
-<video>
<!--Total video No.: 10-->
    <Subject>abc</Subject>
    -<Video1>
        <Video_No>1</Video_No>
       -<segment1>         
           <Start_Frame>0</Start_Frame>
           <End_Frame>123</End_Frame>
           <Status>0</Status>
        </segment1>
        -<segment2>         
           <Start_Frame>1</Start_Frame>
           <End_Frame>12</End_Frame>
           <Status>1</Status>
        </segment2>

As the xml file above, how can I read data('status') tagged in different segments. I was trying to use filestorge and filenode to do this, but I didn't find any samples demonstrating it. If I can get access to the child Node, the problem will be solved. Is there any way to get access to one node's child node in xml with OPENCV? Please feel free to throw any thoughts or examples. Appreciate it.

Chris Su
  • 543
  • 8
  • 16

1 Answers1

0

I've just found a useful library. cvFileStorage which is different from FileStorage. Apparently, this one is much more useful. Attached is the code to retrieve data of child Node. With this, we can retrieve any level node .

//path is file name;
CvFileStorage*  fs = cvOpenFileStorage(path.c_str(), 0, CV_STORAGE_READ);
CvFileNode* fn = cvGetFileNodeByName(fs,0,"Video1");
CvFileNode*  fn1 = cvGetFileNode( fs, fn, cvGetHashedKey(fs, "segment1", -1,0 ), 0 );
int i = cvReadIntByName(fs,fn1,"Start_Frame"); 

It seems the code is little troublesome, if you have better idea, please do post your ideas.

Attached are API:

CvStringHashNode* cvGetHashedKey(CvFileStorage* fs, const char* name, int len=-1, int create_missing=0 )
CvFileNode* cvGetFileNode(CvFileStorage* fs, CvFileNode* map, const CvStringHashNode* key, int create_missing=0 )

Details please check the link:

http://docs.opencv.org/modules/core/doc/old_xml_yaml_persistence.html?highlight=cvgetfilenodebyname#cvfilestorage

Chris Su
  • 543
  • 8
  • 16