OpenCV play video not working on MacOsx 2.4.13.2
I'm reproducing example 2-3 from the OpenCV Oreilly book https://books.google.com/books?id=LPm...
#include <iostream>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc/imgproc.hpp>
using namespace std;
int main(int argc, char **argv) {
cv::namedWindow("win", cv::WINDOW_AUTOSIZE);
cv::VideoCapture cap;
if (argc==1) {
cap.open(0);
} else if(argc == 2) {
cout << "Playing " << argv[1] << endl;
cap.open(argv[1]);
}
if (!cap.isOpened()) {
std::cerr << "Coudln't open camera capture." << std::endl;
return -1;
}
cv::Mat frame;
while(1) {
cap >> frame;
if (frame.empty()) break;
cv::imshow("win", frame);
if (cv::waitKey(33) >= 0) break;
}
return 0;
}
The error I'm getting is cryptic:
*** Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[__NSArrayM objectAtIndex:]: index 0 beyond bounds for empty array'
*** First throw call stack:
(
0 CoreFoundation 0x00007fffab35557b __exceptionPreprocess + 171
1 libobjc.A.dylib 0x00007fffc07191da objc_exception_throw + 48
2 CoreFoundation 0x00007fffab2720ab -[__NSArrayM objectAtIndex:] + 203
3 libopencv_highgui.2.4.dylib 0x0000000102305709 _ZN13CvCaptureFileC2EPKc + 281
4 libopencv_highgui.2.4.dylib 0x000000010230423e _Z32cvCreateFileCapture_AVFoundationPKc + 34
5 libopencv_highgui.2.4.dylib 0x00000001022f8afc cvCreateFileCapture + 14
6 libopencv_highgui.2.4.dylib 0x00000001022f8d9e _ZN2cv12VideoCapture4openERKNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEE + 64
7 play 0x0000000101e1a725 main + 661
8 libdyld.dylib 0x00007fffc0ffa235 start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
Is this a bug on the library or a MacOsx issue? I set up OpenCV using brew install.