Ask Your Question
0

FileStorage::READ runtime exception

asked 2014-01-19 06:38:17 -0600

pistorinoj gravatar image

updated 2014-01-20 19:24:51 -0600

I am using OpenCV 2.4.6 with VS2012 c++/cli in Windows 8 and trying to simply read a matrix from a file. At runtime, I am crashing when I try and open the file and I am getting an error saying "System.Runtime.InteropServices.SEHException" - "External component has thrown an exception".

I have two questions: 1) what is causing this error; and 2) why is try/catch not handling this error?

My code looks like:

private: System::Void buttonLoadStyle_Click(System::Object^  sender, System::EventArgs^  e) {
    FileStorage fs;
    try
    {
        fs.open("SVStyle0.xml",FileStorage::READ);
    }
    catch(cv::Exception& e)
    {
        const char * err_msg = e.what();
    }
    catch(...)
    {
        System::Windows::Forms::MessageBox::Show("Load Style Exception","Rune Time Error!",MessageBoxButtons::OK,MessageBoxIcon::Error);
    }

    if(fs.isOpened())
    {
        // do something
    }
};

I get the exception when the the fs.open line tries to open the file. Further, the exception is not caught by my try/catch blocks.

Edit: When I remove the ".xml" extension, I execute past the fs.open line but, of course, do not find the file. Seems like it might be something with parsing the filename.

Any help greatly appreciated. Thanks

edit retag flag offensive close merge delete

Comments

Still no progress on this. Anyone else having the same issue?

pistorinoj gravatar imagepistorinoj ( 2014-02-09 18:58:07 -0600 )edit

1 answer

Sort by ยป oldest newest most voted
2

answered 2014-02-12 11:06:40 -0600

pistorinoj gravatar image

updated 2014-02-12 11:09:03 -0600

I finally figured this out. If you improperly code your XML file so that it has multiple nodes with the same name, as soon as you try and open that file (not even reading anything from it) you will immediately get an error.

The error is "duplicate key." Once I corrected this, everything worked correctly.

Also, my catch statement was not specific to OpenCV and thus was not finding this error. Once, I fixed the catch statement, I got the correct error report and that led me to figure out that the XML file was coded incorrectly.

edit flag offensive delete link more

Question Tools

Stats

Asked: 2014-01-19 06:38:17 -0600

Seen: 4,108 times

Last updated: Feb 12 '14