Patrick Liao
unread,May 9, 2021, 12:28:38 AM5/9/21Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Sign in to report message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Android CameraX Discussion Group, Scott Nien, Android CameraX Discussion Group, Patrick Liao
Hi Scott,
Thanks for the tips. I would definitely try it out.
And is there a way to query the current focal distance as set by the AF algorithm? That is, is it possible to get focal distance info when AF is trying to focus?
Also, is there a way to slow down AF with CaptureRequest? In Video AF, the AF speed shall be slowed down to become more precise and more importantly natural ( see CONTROL_AF_MODE_CONTINUOUS_VIDEO). But when manually set the AF_MODE to be continuous video, the touch-to-focus thing stops responding altogether and I found no way of tweaking the AF speed under CONTINUOUS_PICTURE mode (which is what CameraX uses for touch-to-focus).
And a quick update regarding the "servo AF" thing, the following code snippet worked well under good lighting conditons except I could not find a way to enlarge the AF area...
private static float [] focusPoint = {0,0};
private static void focusToPoint(EventListener listener) {focusToPoint(focusPoint[0],focusPoint[1],true,listener);}
public static void focusToPoint(float x, float y, boolean isContinuous, EventListener listener) {
focusPoint[0] = x;
focusPoint[1] = y;
new Thread(() -> {
isFocusBusy_ = true;
listener.onEventBegan("Start focusing...");
runLater(() -> {
//Start focusing
MeteringPointFactory factory = previewView_.getMeteringPointFactory();
MeteringPoint point = factory.createPoint(focusPoint[0], focusPoint[1]);
FocusMeteringAction action = new FocusMeteringAction.Builder(point).disableAutoCancel().build();
ListenableFuture<FocusMeteringResult> focusResult = camera.getCameraControl().startFocusAndMetering(action);
focusResult.addListener(() -> {
try {
focusResult.get();
listener.onEventUpdated("Focused");
isFocusBusy_ = false;
if(!isCvfStopped_ && isContinuous) focusToPoint(listener);
else if(isContinuous) isCvfStopped_ = false;
} catch (Exception e) {
SAL.print(e);
SAL.print("Focus cancelled");
listener.onEventFinished(false, "Focus cancelled");
}
}, ContextCompat.getMainExecutor(context_));
});
}).start();
}