So I am trying to make OpenCV play the Megamind.avi video for me, but everytime I run my code it gives me this error:
2016-12-29 19:07:39.916 process[17091:382843] *** Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[__NSArrayM objectAtIndex:]: index 0 beyond bounds for empty array'
*** First throw call stack:
(
0 CoreFoundation 0x00007fff92e800db __exceptionPreprocess + 171
1 libobjc.A.dylib 0x00007fffa7b12a2a objc_exception_throw + 48
2 CoreFoundation 0x00007fff92d9c4fb -[__NSArrayM objectAtIndex:] + 203
3 libopencv_highgui.2.4.dylib 0x000000010b2f0270 _ZN13CvCaptureFileC2EPKc + 350
4 libopencv_highgui.2.4.dylib 0x000000010b2eece2 _Z32cvCreateFileCapture_AVFoundationPKc + 34
5 libopencv_highgui.2.4.dylib 0x000000010b2e27de cvCreateFileCapture + 14
6 libopencv_highgui.2.4.dylib 0x000000010b2e2a8e _ZN2cv12VideoCapture4openERKNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEE + 64
7 libopencv_highgui.2.4.dylib 0x000000010b2e28ee _ZN2cv12VideoCaptureC2ERKNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEE + 42
8 process 0x000000010adcd517 main + 215
9 libdyld.dylib 0x00007fffa83f4255 start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
Abort trap: 6
It also occurs whenever I run the sample OpenCV video reading and writing program, so I'm not sure if something is screwed up on my end or has there been a change in OpenCV that broke some methods. Here is my code for reference:
#include <stdio.h>
#include <opencv2/opencv.hpp>
using namespace std;
using namespace cv;
int main()
{
const string source = "Megamind.avi";
VideoCapture inputVideo(source);
if (!inputVideo.isOpened())
{
cout << "Could not open the input video" << source << endl;
return -1;
}
cout << "read!" << endl;
namedWindow("Video",1);
for(;;){
Mat frame;
inputVideo >> frame; // get a new frame from camera
imshow("Video", frame);
if(waitKey(30) >= 0) break;
}
VideoWriter outputVideo;
return 0;
}
Also if I apply the program to the vtest.avi video file in the same github repo, it returns this error.
OpenCV Error: Assertion failed (size.width>0 && size.height>0) in imshow, file /tmp/opencv-20161020-7399-1yrk4nm/opencv-2.4.13.1/modules/highgui/src/window.cpp, line 261
libc++abi.dylib: terminating with uncaught exception of type cv::Exception: /tmp/opencv-20161020-7399-1yrk4nm/opencv-2.4.13.1/modules/highgui/src/window.cpp:261: error: (-215) size.width>0 && size.height>0 in function imshow
I read up online to add this if statement in the for loop:
if (!frame.empty()) {
imshow("window", frame);
}
but there results in just an empty window. Not sure if this changes my issue at all.
Aucun commentaire:
Enregistrer un commentaire