0

I am using EmguCV to create a capture from a video file stored on disk. I set the capture property for frame position and then perform a QueryFrame. On certain frames from the video, when I go to process the Mat further I get the error '{"OpenCV: Unrecognized or unsupported array type"}'. This doesn't happen on all frames of the video but when I run it for the same video it happens for the same frames in the video. If I save the Mat to disk the image looks perfectly fine and saves without error. Here is the code for loading and processing the image:

Capture cap = new Capture(movieLocation);
int framePos = 0;

while (reading)
{
    cap.SetCaptureProperty(CapProp.PosFrames, framePos);
    using (var frame = cap.QueryFrame())
    {
        if (frame != null)
        {
            try
            {
                var fm = Rotate(frame); // Works fine
                // Other Processing including classifier.DetectMultiScale -- Error occurs here
                frameMap.Add(framePos, r);
            }
            catch (Exception ex)
            {
                var s = "";  // Done to just see the error
            }
            framePos = framePos + 2;

        }
        else
        {
            reading = false;
        }
    }
}

Line of code which throws exception in further processing

var r = _classifier.DetectMultiScale(matIn, 1.1, 2, new Size(200, 200), new Size(375, 375));

As I said, this does not fail for every frame of the video.

I'm trying to solve this because sometimes it skips 1 frame but at other times it will skip whole blocks of frames which is causing me to miss important events in the video.

Eric H
  • 55
  • 6

1 Answers1

1

After a bit more working on it, I figured out that the Mat had a ROI set on it before going to the cascade classifier. In the instances where the mat was failing the ROI was set to 0 height and 0 width. This caused the issue.

Eric H
  • 55
  • 6