iOS Question Tap to focus camera

Hypnos

Active Member
Licensed User
Longtime User
I would like to use "tap to focus" on my camera app (just like the iphone camera app), is that possible to do it using LLCamera? Thank you!
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
Add these two methods to CameraEx: https://www.b4x.com/android/forum/t...control-the-camera-setting.49216/#post-306521
B4X:
Public Sub IsFocusPointSupported As Boolean
   Return device.GetField("focusPointOfInterestSupported").AsBoolean
End Sub

Public Sub SetFocusPoint(x As Float, y As Float)
   device.RunMethod ("setFocusPointOfInterest:", Array(device.MakePoint(x, y)))
End Sub

You need to change the focus point in a configuration block (BeginConfiguration / CommitConfiguration).
The values are between 0 to 1: https://developer.apple.com/referen...ce/1385853-focuspointofinterest?language=objc
 
Upvote 0

Hypnos

Active Member
Licensed User
Longtime User
Add these two methods to CameraEx: https://www.b4x.com/android/forum/t...control-the-camera-setting.49216/#post-306521
B4X:
Public Sub IsFocusPointSupported As Boolean
   Return device.GetField("focusPointOfInterestSupported").AsBoolean
End Sub

Public Sub SetFocusPoint(x As Float, y As Float)
   device.RunMethod ("setFocusPointOfInterest:", Array(device.MakePoint(x, y)))
End Sub

You need to change the focus point in a configuration block (BeginConfiguration / CommitConfiguration).
The values are between 0 to 1: https://developer.apple.com/reference/avfoundation/avcapturedevice/1385853-focuspointofinterest?language=objc

Thank you Erel, just tried and the new methods for FocusPoint worked !
Can you also let me know the code to add the following methods? I tried by myself but failed due to my limitation knowledge...

exposurePointOfInterest
https://developer.apple.com/referen...1388777-exposurepointofinterest?language=objc

exposurePointOfInterestSupported
https://developer.apple.com/referen...xposurepointofinterestsupported?language=objc

lowLightBoostSupported
https://developer.apple.com/referen.../1624595-lowlightboostsupported?language=objc

lowLightBoostEnabled
https://developer.apple.com/referen...ce/1624602-lowlightboostenabled?language=objc

automaticallyEnablesLowLightBoostWhenAvailable
https://developer.apple.com/referen...utomaticallyenableslowlightboos?language=objc
 
Upvote 0

Hypnos

Active Member
Licensed User
Longtime User
They are almost identical to the code I posted. You just need to change the method name.

Hi Erel,

I can only successfully add the code for "SetExposurePoint" using the following code:

B4X:
Public Sub SetExposurePoint(x As Float, y As Float)
    device.RunMethod ("setExposurePointOfInterest:", Array(device.MakePoint(x, y)))
End Sub


But I got error for below : (

B4X:
Public Sub IsExposurePointSupported As Boolean 
    Return device.GetField("exposurePointOfInterestSupported").AsBoolean
End Sub

Public Sub SetLowLightBoost (v As Boolean)
    device.SetField ("LowLightBoostEnabled", v)
End Sub


Error configuring camera: [<AVCaptureFigVideoDevice 0x14e6d520> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key LowLightBoostEnabled.

[<AVCaptureFigVideoDevice 0x14e6d520> valueForUndefinedKey:]: this class is not key value coding-compliant for the key exposurePointOfInterestSupported.
 
Upvote 0
Top