Skip to content

Commit

Permalink
camera autofocus
Browse files Browse the repository at this point in the history
  • Loading branch information
pedro committed May 12, 2017
1 parent 1565fff commit 0f87001
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
6 changes: 6 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Expand Up @@ -76,6 +76,19 @@ public void start() {
parameters.setPreviewFormat(imageFormat);
int[] range = adaptFpsRange(fps, parameters.getSupportedPreviewFpsRange());
parameters.setPreviewFpsRange(range[0], range[1]);

List<String> supportedFocusModes = parameters.getSupportedFocusModes();
if (supportedFocusModes != null && !supportedFocusModes.isEmpty()) {
if (supportedFocusModes.contains(Camera.Parameters.FOCUS_MODE_CONTINUOUS_PICTURE)) {
parameters.setFocusMode(Camera.Parameters.FOCUS_MODE_CONTINUOUS_PICTURE);
} else if (supportedFocusModes.contains(Camera.Parameters.FOCUS_MODE_AUTO)) {
parameters.setFocusMode(Camera.Parameters.FOCUS_MODE_AUTO);
camera.autoFocus(null);
} else {
parameters.setFocusMode(supportedFocusModes.get(0));
}
}

camera.setParameters(parameters);
camera.setDisplayOrientation(orientation);
camera.setPreviewDisplay(surfaceView.getHolder());
Expand Down

0 comments on commit 0f87001

Please sign in to comment.