Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7838455
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T15:06:42+00:00 2026-06-02T15:06:42+00:00

I am trying to load a matrix from .yaml file but opencv gives me

  • 0

I am trying to load a matrix from .yaml file but opencv gives me the following error :

OpenCV Error: Parsing Error (myFile.yaml(1): valid xml should start with ‘)
OpenCV Error: Parsing Error (myFile.yaml(1): Tag should start with ‘<‘> in unknown function)

this is my Write into Storage file, whcih works fine :

cv::FileStorage fs("myFile.yaml", cv::FileStorage::APPEND);   
while(counter<_imgPtrVector.size()){    
    unsigned char* _pointer=(unsigned char*)_imgPtrVector.at(counter);
    cv::Mat _matrixImage(cv::Size( width,height), CV_8UC1,_pointer , cv::Mat::AUTO_STEP);       
    fs <<"Matrix"<<_matrixImage;
    counter++;
}

but when I want to load the data from the same file I got those errors; this is the code for Reading from storage file :

cv::FileStorage f("myFile.yaml", cv::FileStorage::READ );
cv::Mat mat(cv::Size( width,height), CV_8UC1);  
if(f.isOpened()){
    cv::FileNode n = f["Matrix"];
    if (n.type() != cv::FileNode::SEQ){
     std::cout << "error!";
    }
    f["Matrix"] >>  mat; 
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T15:06:43+00:00Added an answer on June 2, 2026 at 3:06 pm

    The problem might be that you are always appending to an existing file. So you might have to change your code to:

    FileStorage fs("test.yml", FileStorage::WRITE);
    

    This will recreate the file each time your program runs.

    The OpenCV docs have an example on how to write with XML/YAML Persistence that is pretty clear:

    #include "opencv2/opencv.hpp"
    #include <time.h>
    
    using namespace cv;
    
    int main(int, char** argv)
    {
        FileStorage fs("test.yml", FileStorage::WRITE);
    
        fs << "frameCount" << 5;
        time_t rawtime; time(&rawtime);
        fs << "calibrationDate" << asctime(localtime(&rawtime));
        Mat cameraMatrix = (Mat_<double>(3,3) << 1000, 0, 320, 0, 1000, 240, 0, 0, 1);
        Mat distCoeffs = (Mat_<double>(5,1) << 0.1, 0.01, -0.001, 0, 0);
        fs << "cameraMatrix" << cameraMatrix << "distCoeffs" << distCoeffs;
        fs << "features" << "[";
        for( int i = 0; i < 3; i++ )
        {
            int x = rand() % 640;
            int y = rand() % 480;
            uchar lbp = rand() % 256;
    
            fs << "{:" << "x" << x << "y" << y << "lbp" << "[:";
            for( int j = 0; j < 8; j++ )
                fs << ((lbp >> j) & 1);
            fs << "]" << "}";
        }
        fs << "]";
        fs.release();
        return 0;
    }
    

    And there is another example that shows how to read.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i am trying load file after it created from /stext command line but its
Trying to load a small .txt file into mysql but get all my data
I'm trying load a 3rd party DLL but I get an error when attempting
I am trying load settings.php?id=5 by accessing xml/5/settings.xml here is the code but its
Trying to load a block with a datepicker from a view.. but it loads
Im trying to load an xml file using the jquery ajax function,it works fine
I trying to load Tomcat server with Spring but failing with error(see below), i
I am trying to test that a method to load a UI matrix is
i m trying load UIImages from server asynchronously in UITableViewCell. My code worked fine
trying to load in a bunch of images into a list from a directory...my

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.