iPhone 14 Pro & Pro Max not focusing close-up with QCamera
-
Hi there everyone,
I've recently encountered an issue on the iPhone 14 Pro (and Pro Max) in my Qt app. On all iPhone models except this one (including the 13's triple cam), I have been able to focus on close-up objects. However, on this model (on several tested devices), I cannot - this issue happens identically to the issue described in this thread https://developer.apple.com/forums/thread/715568.
When using the iPhone 14 Pro's native camera app, as I bring an object close to the camera the app visibly and literally swaps lenses to use the macro lens. I would expect QCamera, the interface I use currently for all other phone models, would adapt similarly, but it does not. So I dug a little deeper to ensure I was using my available resources, and sure enough
QCameraInfo::availableCameras()
only returns the "front facing" and "back facing" cameras with no distinction between the lenses on the back facing ones, so I have no way to even manually tell my app to focus on close objects.I should note that Facebook & Instagram have also had this issue on the phone I personally tested, not that it is particularly relevant to the question.
Is there a way I can select the macro lens? My application's core function is to scan documents, and it cannot do that without access to the lens for close-up pictures.
Thank you!
-
I'm back with a development.
TLDR: Qt 5 doesn't support Triple Camera lens. Try it on Qt 6 or find a way to route the iPhone's native software camera interface into Qt.
As mentioned above, listing
availableCameras()
on the iPhone only reveals the front and back cameras. However, I forgot to mention that my app was on Qt 5.Using iPhone's
AVCaptureDeviceDiscoverySession
on native Objective-C shows me that I have 8 total cameras available to me. Most notably, index7
contains the TripleCamera that I want to access (since it handles its own lens swapping). On Qt 5, I tried to force my QML Camera's device ID to be the TripleCamera's corresponding device ID by hardcoding it and running a debug session on my iPhone 14 Pro. No error was thrown, but examining theCamera
's properties afterward shows me that thedeviceId
was forced back to device index 0 (the rear facing camera), which makes me think that index7
wasn't supported.Notably, https://doc.qt.io/qt-6/qcamera.html#details shows that we can select the Macro lens in Qt 6, so I'm hopeful that Qt 6 will show all 8 camera options when using
QMediaDevices::videoInputs()
(Qt 6) instead ofQCameraInfo::availableDevices
(Qt 5). Would someone be able to test this for me? I forsee myself upgrading to Qt 6 eventually, but if it's the case that this issue has the solution I'm alluding to I'll probably upgrade sooner than later.Alternatively, I was thinking I could use apple's
AVCaptureSession
on Xcode 14 to generate a video feed and control the focus from there, but I am not sure how to route that directly to a viewfinder orCamera
. If that's a possible solution I would be open to that as well.Would appreciate some input on this development! Thank you :)