r/MantisX • u/MinnisotaDigger • 26d ago
Using zoom camera (TitanX)
I’d like to have my camera near me with my target down my hallway. Is there a reason it only allows the 1x camera instead of my 5x camera?
1
u/MantisLegit 22d ago
You can definitely use an attached optical zoom device. I forget what they are called. Telephoto something or other.
One of the developers used that during development and was able to shoot at 25 yards with no issue.
1
u/MinnisotaDigger 22d ago edited 22d ago
I understand. What I am asking for is to be able to select which camera is being used. My iphone has a 5x built in. I would like to be able to select that 5x camera instead of the 1x camera.
Buying a gadget for something that can be fixed in software isn’t ideal.
How to add a telephoto camera switch in AVFoundation
If you're using the standard 1x wide lens by default, here is the high-level workflow to let users switch to the 5x lens:
Query the available lenses: Create an AVCaptureDevice.DiscoverySession looking for video media on the back position. Be sure to include .builtInTelephotoCamera in your device types.
Retrieve the device list: Pull the devices array from your discovery session to get a list of the exact lenses the user's specific iPhone has available.
Lock the session: When a user triggers the switch, call beginConfiguration() on your active AVCaptureSession to pause the feed for updates.
Remove the old input: Find the active 1x camera input in the session's input list and remove it.
Add the new input: Initialize a new AVCaptureDeviceInput using the 5x telephoto device, check if the session can accept it, and add it.
Commit the changes: Call commitConfiguration() to unlock the session and resume the live camera feed with the new lens.
Build the UI: Create a menu that loops through your discovered devices. You can use the device's localizedName property to automatically generate user-friendly button labels (like "Back Telephoto Camera") that trigger your swapping function.
1
u/Shivaess 25d ago
You know I never thought about this, but this is definitely something that would be nice especially when training with my black beard X on a rifle
1
u/Loud-Principle-7922 26d ago
Red slider on the left side lets you zoom.