OpenCV: fs.open fails

systemerror: <class 'cv2.cascadeclassifier'> returned a result with an error set
opencv python write yaml
cascade classifier opencv
opencv haar cascade
input file is empty in function cvopenfilestorage
opencv xml files
haar cascade xml files for object detection
c :\\ opencv \\ build \\ etc \\ haarcascades \\ haarcascade_frontalface_default xml

I want to read from an .xml file, but this line

fs.open("test.xml", FileStorage::READ);

fails with cv::Exception.

\opencv_source\opencv-3.4.1\modules\core\src\persistence_c.cpp:384: error: (-49) Input file is empty in function cvOpenFileStorage\n" ...} ...} const cv::Exception &

I'm using Win7, OpenCV 3.4.1, c++, VisualStudio 2015. It's my fist time using .xml files and I'm new to opencv.

Any ideas what's wrong?


If you have downloaded the XML file using "save link as..." from chrome, then it might cause the problem. Open the file and check it once if it looks the same as in the repository.

File Input and Output using XML and YAML files, cerr << "Failed to open " << filename << endl;. help(av);. return 1;. } FileNode n = fs["strings"]; // Read string sequence - Get node. if (n.type() != FileNode::SEQ). FAILED: fs.is_open(). i meet the same question,i uninstal my opencv-python and install this new version. access. Sign up for free to join this conversation on


It seems that your program is unable to find the file specified. Is the file you are trying to open in the same directory as your excecutable? Perhaps try to use an absolute path.

Basic FileStorage operation problem - failed to open:, settings if (!fs.isOpened()) { cout << "Could not open the configuration file: \"" << inputSettingsFile << "\"" << endl; return -1; } It always failed. Prev Tutorial: Camera calibration with square chessboard Next Tutorial: Real Time pose estimation of a textured object Cameras have been around for a long-long time. However, with the introduction of the cheap pinhole cameras in the late 20th century, they became a common occurrence in our everyday life.


It requires absolute path of the file to be read. I had the same issue. Giving absolute path solved my problem.

samples/cpp/filestorage.cpp, void write(FileStorage& fs) const //Write serialization for this class if (!fs. isOpened()). {. cerr << "failed to open " << filename << endl;. help(av);. return 1;. }. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58


File Input and Output using XML and YAML files — OpenCV 2.4.13.7 , isOpened()) { cerr << "Failed to open " << filename << endl; help(av); return 1; } FileNode n = fs["strings"]; // Read string sequence - Get node if� In C++, it's possible to serialize this through the OpenCV I/O XML/YAML interface (just as in case of the OpenCV data structures) by adding a read and a write function inside and outside of your class. In Python, you can get close to this by implementing a read and write function inside the class. For the inside part:


Using FileStorage::APPEND � Issue #14130 � opencv/opencv � GitHub, I use FileStorage:: APPEND my code : FileStorage fs; fs.open("test.yml", PS I cannot find previous issue about append problem in yml but I� fs.open(filename, FileStorage::READ); Either one of this you use the second argument is a constant specifying the type of operations you'll be able to on them: WRITE, READ or APPEND. The extension specified in the file name also determinates the output format that will be used.


Unable to open ".yml" file using cv::FileStorage in ROS Kinetic, The output that I get is as follows: "Failed to open file intrinsic.yml" and "Failed the opencv FileStorage method but the program is unable to open both files. cv ::FileStorage fs(intrinsic_filename, cv::FileStorage::READ); if(!fs. Books to Satisfy Anyone from New Learners to Computer Geeks.