I'm new to openCV and I'm having trouble with VideoCapture.isOpened() always returning false. I've seen other posts that have similar problems, but I'm not managing to make headway towards a solution for my case.
Text version of what is in the screenshot:
import <opencv2 opencv.hpp="">
include <opencv2 core="" core.hpp="">
include <opencv2 highgui="" highgui.hpp="">
include <iostream>
import "OpenCVWrapper.h"
#import <opencv2/opencv.hpp>
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <iostream>
#import "OpenCVWrapper.h"
using namespace cv;
using namespace
std; std;
@implementation
OpenCVWrapper OpenCVWrapper
+ (int) testing {
VideoCapture cap("spaceMinimal.mp4");
cout << "did it work : " << cap.isOpened() <<
endl; endl;
Mat frame;
cap >> frame; // get the next frame from video
frame.push_back(frame);
cout << "mat = " << endl << frame <<
endl; endl;
return 1;
} }
+ (NSString *)openCVVersionString {
return [NSString stringWithFormat:@"OpenCV Version %s", CV_VERSION];
} @end
}
@end
And below is how they are called (in Swift):
Swift):
var testa = OpenCVWrapper.testing()
print("Before : (OpenCVWrapper.openCVVersionString())")\(OpenCVWrapper.openCVVersionString())")
The image shows the two functions in my header that uses openCV libraries. I call both functions on my first ViewController, and you can see the output at the bottom of the image. I've pasted the output below as well:
did it work : 0 // This is the result for VideoCapture.isOpened()
VideoCapture.isOpened()
Before : OpenCV Version 4.1.0 // This is the result of the other function, which is workingworking
For whatever reason, VideoCapture is not opening the mp4 file, even though the mp4 file is in the directory (as can be seen in the image).
From other posts it seems like there may be an issue with some ffmpeg dll or something (I'm not familiar with these), but I have no idea where to go from here. Please help!
additional details:
- openCV-4.1.0
openCV-4.0
- 1.0 included the ios package framework
framework
- using XCode 10.1