Ask Your Question

Revision history [back]

VideoCapture.isOpened() is always returning false

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.

image description

This 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()

Before : OpenCV Version 4.1.0 // This is the result of the other function, which is working

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 - included the ios package framework - using XCode 10.1

VideoCapture.isOpened() is always returning false

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.

image description

This 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"

using namespace cv; using namespace std;

@implementation OpenCVWrapper

  • (int) testing { VideoCapture cap("spaceMinimal.mp4"); cout << "did it work : " << cap.isOpened() << endl;

    Mat frame; cap >> frame; // get the next frame from video frame.push_back(frame); cout << "mat = " << endl << frame << endl;

    return 1; }

  • (NSString *)openCVVersionString { return [NSString stringWithFormat:@"OpenCV Version %s", CV_VERSION]; }

@end

And below is how they are called (in Swift): var testa = OpenCVWrapper.testing() print("Before : (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()

Before : OpenCV Version 4.1.0 // This is the result of the other function, which is working

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 - included the ios package framework - using XCode 10.1

VideoCapture.isOpened() is always returning false

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.

image description

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 working

working

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

VideoCapture.isOpened() is always returning false

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.

image description

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"

using namespace cv;
using namespace std;

@implementation OpenCVWrapper

+ (int) testing : (string) filePath {
  VideoCapture cap("spaceMinimal.mp4");
    cap(filePath);
cout << "did it work : " << cap.isOpened() << endl;

 Mat frame;
 cap >> frame; // get the next frame from video
 frame.push_back(frame);
 cout << "mat = " << endl << frame << endl;

 return 1;
}

+ (NSString *)openCVVersionString {
    return [NSString stringWithFormat:@"OpenCV Version %s",  CV_VERSION];
}


@end

And below is how they are called (in Swift):

var testa = OpenCVWrapper.testing()
print("Before : \(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()
Before : OpenCV Version 4.1.0 // This is the result of the other function, which is working

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.0 - 1.0 included the ios package framework - using XCode 10.1

VideoCapture.isOpened() is always returning false

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.

image description

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"

using namespace cv;
using namespace std;

@implementation OpenCVWrapper

+ (int) testing : (string) filePath {
{ // couldn't input parameter as NSString* because that made the VideoCapture's constructor not work, this way it recognized constructor pattern

VideoCapture cap(filePath);
cout << "did it work : " << cap.isOpened() << endl;

Mat frame;
cap >> frame; // get the next frame from video
frame.push_back(frame);
cout << "mat = " << endl << frame << endl;

return 1;
}

+ (NSString *)openCVVersionString {
    return [NSString stringWithFormat:@"OpenCV Version %s",  CV_VERSION];
}


@end

And below is how they are called (in Swift):

// first function's call
let videoFileURL = Bundle.main.url(forResource: "spaceMinimal", withExtension: "mp4")
var testa test = OpenCVWrapper.testing()
OpenCVWrapper.testing(videoFileURL.path)
// second function's call
print("Before : \(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()
Before : OpenCV Version 4.1.0 // This is the result of the other function, which is working

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.0 - 1.0 included the ios package framework - using XCode 10.1

10.1 - my openCVWrapper.h :

#import <UIKit/UIKit.h>

NS_ASSUME_NONNULL_BEGIN

@interface OpenCVWrapper : UICollectionView
+ (NSString *)openCVVersionString;
+ (int) testing : (NSString*)filePath; // had to pass in NSString* here instead of string because 'string' isn't recognised in this file
@end


NS_ASSUME_NONNULL_END