VideoCapture resolution not settable with iOS/C++

Hi there,

Has anyone managed to set the capture frame width and height for a VideoCapture object on iOS via C++?

The following works great on Windows, and Mac.

cv::VideoCapture vidCap {0};
vidCap.set(cv::CAP_PROP_FRAME_WIDTH, 1920);
vidCap.set(cv::CAP_PROP_FRAME_HEIGHT, 1080);

However, with iOS (iPhone 6 and Xs), although the above causes no error, this:


still returns 480 and 360.

The technique of setting the WIDTH and HEIGHT to massive numbers like 50000, to coax the camera to the highest available resolution also does not work. The settings when using get are still 480 x 360.

I found this interesting, too:

cv::Mat mat;
VidCap >> mat;
std::cout << mat.cols << " x " << mat.rows;

Here I get “360 x 480” for cols and rows for suggesting a 90 degree rotation, which would be right for a photo taken portrait mode on a phone. I’m just a bit surprised that the capture data was reorientated when pushed to a cv::Mat .

I’ve been googling around for days. Even started poking at objective-c and Swift to try and work with the defaultAVCaptureSessionPreset. No luck with any of that. I’ve also searched for that term in the build directory of my iOS openCV build, and replaced values in a few files to see if there was any change. Again sadly not.

Any advice, suggestions or even sympathy would be greatly appreciated!

With many thanks, Jeff


  • OpenCV 4.5.1 (tagged release) and commit 9d89edff2f to see if this has been fixed since the last tagged release.
  • Xcode 12.3
  • iOS 14.0.1 (iPhone Xs) and 12.4.8 (iPhone 6)
  • tried several other resolution options besides 1920x1080

This looks like it’s still an issue with OpenCV 4.6.0. I’ve been googling and searching but I haven’t seen any solutions as yet. Anyone here had any luck in this regard?

Many thanks, Jeff

I’d recommend browsing for existing issues on Issues · opencv/opencv · GitHub

also browse closed issues and pull requests. this might have been fixed.

if you can’t find anything related, open a new issue about it.

you should definitely make sure this is reproducible (MRE) on the current release. if you can, check with other people and see what behavior they see on their systems (apple obviously, this works elsewhere).

and do not expect too much on iOS (or Android). mobile phones are not the primary targets of OpenCV. anyone who needs this to work on those might have to dig into the code of OpenCV and maintain that small part of it. mobile phone APIs change every few years.

1 Like

Hi Christoph

Thanks for the reply - much appreciated!

I have spent a good chunk of time searching around (thanks for the closed issue and pr suggestions) for a solution to this but have turned up nothing as yet.

In lieu of that I made some modifications to my forked repo of OpenCV. So far in testing it has been reliable in allowing the capture resolution to be changed. I’m definitely happy about that. I’ll keep testing, add some documentation and will submit a pull request if it continues to behave well.

Kind regards,

1 Like