Enable autofocus in Pixel 3
Environments
Problem
Hello. I try to do this codelab. I faced the problem that auto focus is diable. even if I added this
config.setFocusMode(Config.FocusMode.AUTO);
Reason
I found this issue
issue
And I know
Google Pixel 3 Supports 60 fps camera capture frame rate on the rear-facing camera
When 60 fps camera capture mode is active, the camera uses fixed focus
So I should use 30fps in Pixel3
Solution
I add CameraConfig
to getSessionConfiguration
code,
ARCore uses only TARGET_FPS_30
.
In AugmentedImageFragment.java
@Override
protected Config getSessionConfiguration(Session session) {
Config config = super.getSessionConfiguration(session);
if (!setupAugmentedImageDatabase(config, session)) {
SnackbarHelper.getInstance()
.showError(getActivity(), "Could not setup augmented image database");
}
if (!setCameraConfig(session)){
SnackbarHelper.getInstance()
.showError(getActivity(), "Could not setup camera config");
}
config.setFocusMode(Config.FocusMode.AUTO);
try{
session.resume();
}catch (Exception e){
Log.e("Error", e.getMessage());
}
return config;
}
private boolean setCameraConfig(Session session){
CameraConfigFilter filter = new CameraConfigFilter(session);
filter.setTargetFps(EnumSet.of(CameraConfig.TargetFps.TARGET_FPS_30));
if(!session.getSupportedCameraConfigs(filter).isEmpty()){
session.setCameraConfig(session.getSupportedCameraConfigs(filter).get(0));
return true;
}
return false;
}
Ref
Read other posts