From 72728b44818ba10e54507bf9edd6e1e159024d00 Mon Sep 17 00:00:00 2001 From: Ethan Rublee Date: Mon, 23 May 2011 19:52:23 +0000 Subject: [PATCH] Applying patch mentioned in ticket #1085 --- .../com/opencv/camera/NativePreviewer.java | 44 ++++++++----------- 1 file changed, 19 insertions(+), 25 deletions(-) diff --git a/android/android-opencv/src/com/opencv/camera/NativePreviewer.java b/android/android-opencv/src/com/opencv/camera/NativePreviewer.java index 4554d49050..1accee723e 100644 --- a/android/android-opencv/src/com/opencv/camera/NativePreviewer.java +++ b/android/android-opencv/src/com/opencv/camera/NativePreviewer.java @@ -153,35 +153,28 @@ public class NativePreviewer extends SurfaceView implements Log.d("NativePreviewer", "Supported params: " + mCamera.getParameters().flatten()); - - // this is available in 8+ - // parameters.setExposureCompensation(0); - if (parameters.getSupportedWhiteBalance().contains(whitebalance_mode)) { + List whiteBalanceModes = parameters.getSupportedWhiteBalance(); + if (whiteBalanceModes != null + && whiteBalanceModes.contains(whitebalance_mode) ) { parameters.setWhiteBalance(whitebalance_mode); } -// if (parameters.getSupportedAntibanding().contains( -// Camera.Parameters.ANTIBANDING_OFF)) { -// parameters.setAntibanding(Camera.Parameters.ANTIBANDING_OFF); -// } - - List fmodes = mCamera.getParameters().getSupportedFocusModes(); - // for(String x: fmodes){ - - // } - - if (parameters.get("meter-mode") != null) parameters.set("meter-mode", "meter-average"); - int idx = fmodes.indexOf(Camera.Parameters.FOCUS_MODE_INFINITY); - if (idx != -1) { - parameters.setFocusMode(Camera.Parameters.FOCUS_MODE_INFINITY); - } else if (fmodes.indexOf(Camera.Parameters.FOCUS_MODE_FIXED) != -1) { - parameters.setFocusMode(Camera.Parameters.FOCUS_MODE_FIXED); - } - if (fmodes.indexOf(Camera.Parameters.FOCUS_MODE_AUTO) != -1) { - hasAutoFocus = true; + List fmodes = mCamera.getParameters().getSupportedFocusModes(); + if(fmodes != null) + { + int idx = fmodes.indexOf(Camera.Parameters.FOCUS_MODE_INFINITY); + if (idx != -1) { + parameters.setFocusMode(Camera.Parameters.FOCUS_MODE_INFINITY); + } else if (fmodes.indexOf(Camera.Parameters.FOCUS_MODE_FIXED) != -1) { + parameters.setFocusMode(Camera.Parameters.FOCUS_MODE_FIXED); + } + + if (fmodes.indexOf(Camera.Parameters.FOCUS_MODE_AUTO) != -1) { + hasAutoFocus = true; + } } List scenemodes = mCamera.getParameters() @@ -211,7 +204,7 @@ public class NativePreviewer extends SurfaceView implements initForACB(); initForPCWB(); - // Use only one buffer, so that we don't preview to many frames and bog + // Use only one buffer, so that we don't preview too many frames and bog // down system byte[] buffer = new byte[bufSize]; addCallbackBuffer(buffer); @@ -479,4 +472,5 @@ public class NativePreviewer extends SurfaceView implements } -} \ No newline at end of file +} +