Ask Your Question
0

Problem with OpenCV camera calibration from video file

asked 2013-06-11 13:17:12 -0500

Hi all,

I am trying to get calibration parameters for my camera using the sample code included with OpenCV. When I try to run the calibration using a video file as an input I get the following error:

OpenCV Error: Parsing error (GOPR0047.avi(0): Too long string or a last string w/o newline) in unknown function, file ......\src\opencv\modules\core\src\persistence.cpp, line 1844

Anyone know what might be causing this error? Is there a size limit on the input video perhaps?

Thanks for any help

edit retag flag offensive close merge delete

Comments

OpenCV Version 2.4.5

aknight0 gravatar imageaknight0 ( 2013-06-11 13:19:39 -0500 )edit

To add some more information, I tried breaking my video into frames and loading the image list as the input. When I do that the first image pops up with the colored lines drawn correctly on the checkerboard, then the program immediately crashes. I'm not sure if this is related to the first problem...

aknight0 gravatar imageaknight0 ( 2013-06-11 15:24:14 -0500 )edit

That sounds weird, maybe you could share your video or some of the images, we could give it a go and try to help you locate the problem.

Martin Peris gravatar imageMartin Peris ( 2013-06-11 19:48:48 -0500 )edit

2 answers

Sort by ยป oldest newest most voted
2

answered 2014-01-13 11:01:29 -0500

dmackay gravatar image

It's a bug in calibrate_camera. At line 104 in calibrate_camera.cpp, it's calling readStringList with the name of the video file. Attempting to parse the video file as an xml file gets you that error.

edit flag offensive delete link more

Comments

What is the solution to this problem? Has anyone posted a fix?

The_Mad_Geometer gravatar imageThe_Mad_Geometer ( 2015-11-10 09:25:15 -0500 )edit

add a new line right above 160 ("l.clear();") with "return false;"

GermanEspinosa gravatar imageGermanEspinosa ( 2016-03-31 15:05:44 -0500 )edit
0

answered 2016-08-03 14:02:19 -0500

sweeneychris gravatar image

I had the same issue. This is because OpenCV tries to open the video file as an xml file and crashes. I modified my readStringList function with a try-catch and it works for me:

static bool readStringList(const string& filename, vector<string>& l) {
    l.clear();
    FileStorage fs;
    try {
      fs.open(filename, FileStorage::READ);
    } catch (...) {
      return false;
    }
    if (!fs.isOpened()) return false;
    FileNode n = fs.getFirstTopLevelNode();
    if (n.type() != FileNode::SEQ) return false;
    FileNodeIterator it = n.begin(), it_end = n.end();
    for (; it != it_end; ++it) l.push_back((string)*it);
    return true;
  }
edit flag offensive delete link more
Login/Signup to Answer

Question Tools

Stats

Asked: 2013-06-11 13:17:12 -0500

Seen: 1,369 times

Last updated: Aug 03 '16