简体   繁体   中英

ARCore – How do I change camera focus to “Auto Focus”?

I am trying to implement the Augmented Images example but for an object that is really close to the camera. Thus, I need the focus to be changed as the fixed focus makes the foreground object completely blurred.

I am using Java in Android Studio along with Sceneform ARCore 1.6 for this project and it would really help if some code were posted along with a solution so I can implement this.

I have tried the following, but get an error saying 'Cannot resolve symbol 'context''

Session session = new Session(context);
Config config = new Config(session);

config.setFocusMode(Config.FocusMode.AUTO);
session.configure(config);

Use the following code for proper configuration:

Session session = new Session(context);
Config configuration = new Config(session);

if (enableAutoFocus) {
    configuration.setFocusMode(Config.FocusMode.AUTO);
} else {
    configuration.setFocusMode(Config.FocusMode.FIXED);
}

session.configure(configuration);

But at the time of writing this post, Google confirms that autofocus isn't working in ARCore 1.8 for some LG models.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM