-
Notifications
You must be signed in to change notification settings - Fork 493
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Autofocus as parameter #64
Changes from all commits
b603da4
3f7da00
126e661
e6ab092
b9445d9
947b684
618c116
8cb1d78
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -108,8 +108,7 @@ void initFromCameraParameters(OpenCamera camera, int width, int height) { | |
} | ||
Log.i(TAG, "Clockwise rotation from display to camera: " + cwNeededRotation); | ||
|
||
Point viewDimensions = new Point(width,height); | ||
resolution = viewDimensions; | ||
resolution = new Point(width, height); | ||
Log.i(TAG, "Screen resolution in current orientation: " + resolution); | ||
cameraResolution = findBestPreviewSizeValue(parameters, resolution); | ||
Log.i(TAG, "Camera resolution: " + cameraResolution); | ||
|
@@ -288,24 +287,24 @@ boolean getTorchState(Camera camera) { | |
return false; | ||
} | ||
|
||
void setTorch(Camera camera, boolean newSetting) { | ||
void setTorchEnabled(Camera camera, boolean enabled) { | ||
Camera.Parameters parameters = camera.getParameters(); | ||
doSetTorch(parameters, newSetting, false); | ||
setTorchEnabled(parameters, enabled, false); | ||
camera.setParameters(parameters); | ||
} | ||
|
||
private void doSetTorch(Camera.Parameters parameters, boolean newSetting, boolean safeMode) { | ||
setTorch(parameters, newSetting); | ||
void setTorchEnabled(Camera.Parameters parameters, boolean enabled, boolean safeMode) { | ||
setTorchEnabled(parameters, enabled); | ||
|
||
if (!safeMode) { | ||
setBestExposure(parameters, newSetting); | ||
setBestExposure(parameters, enabled); | ||
} | ||
} | ||
|
||
public static void setTorch(Camera.Parameters parameters, boolean on) { | ||
public static void setTorchEnabled(Camera.Parameters parameters, boolean enabled) { | ||
List<String> supportedFlashModes = parameters.getSupportedFlashModes(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. setTorchEnabled(boolean enabled) |
||
String flashMode; | ||
if (on) { | ||
if (enabled) { | ||
flashMode = | ||
findSettableValue("flash mode", supportedFlashModes, Camera.Parameters.FLASH_MODE_TORCH, | ||
Camera.Parameters.FLASH_MODE_ON); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -49,6 +49,7 @@ public final class CameraManager { | |
// PreviewCallback references are also removed from original ZXING authors work, since We're using our own interface | ||
// FramingRects references are also removed from original ZXING authors work, since We're using all view size while detecting QR-Codes | ||
private int requestedCameraId = OpenCameraInterface.NO_REQUESTED_CAMERA; | ||
private long autofocusIntervalInMs = AutoFocusManager.DEFAULT_AUTO_FOCUS_INTERVAL_MS; | ||
|
||
public CameraManager(Context context) { | ||
this.context = context; | ||
|
@@ -71,6 +72,13 @@ public void setDisplayOrientation(int degrees) { | |
} | ||
} | ||
|
||
public void setAutofocusInterval(long autofocusIntervalInMs) { | ||
if (autoFocusManager != null) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You forgot the: this. autofocusIntervalInMs = autofocusIntervalInMs; |
||
this.autofocusIntervalInMs = autofocusIntervalInMs; | ||
autoFocusManager.setAutofocusInterval(autofocusIntervalInMs); | ||
} | ||
} | ||
|
||
public Point getPreviewSize() { | ||
return configManager.getCameraResolution(); | ||
} | ||
|
@@ -137,20 +145,20 @@ public synchronized void setManualCameraId(int cameraId) { | |
} | ||
|
||
/** | ||
* @param newSetting if {@code true}, light should be turned on if currently off. And vice versa. | ||
* @param enabled if {@code true}, light should be turned on if currently off. And vice versa. | ||
*/ | ||
public synchronized void setTorch(boolean newSetting) { | ||
public synchronized void setTorchEnabled(boolean enabled) { | ||
OpenCamera theCamera = openCamera; | ||
if (theCamera != null) { | ||
if (newSetting != configManager.getTorchState(theCamera.getCamera())) { | ||
if (enabled != configManager.getTorchState(theCamera.getCamera())) { | ||
boolean wasAutoFocusManager = autoFocusManager != null; | ||
if (wasAutoFocusManager) { | ||
autoFocusManager.stop(); | ||
autoFocusManager = null; | ||
} | ||
configManager.setTorch(theCamera.getCamera(), newSetting); | ||
configManager.setTorchEnabled(theCamera.getCamera(), enabled); | ||
if (wasAutoFocusManager) { | ||
autoFocusManager = new AutoFocusManager(context, theCamera.getCamera()); | ||
autoFocusManager = new AutoFocusManager(theCamera.getCamera()); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why setting the torch on/off requires a new AutoFocusManager? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is how original Zxing project is doing it. It seems like you need to create a new AutoFocusManager every time you change the configuration. |
||
autoFocusManager.start(); | ||
} | ||
} | ||
|
@@ -183,7 +191,8 @@ public synchronized void startPreview() { | |
if (theCamera != null && !previewing) { | ||
theCamera.getCamera().startPreview(); | ||
previewing = true; | ||
autoFocusManager = new AutoFocusManager(context, theCamera.getCamera()); | ||
autoFocusManager = new AutoFocusManager(theCamera.getCamera()); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why start previewing requires a new AutoFocusManager? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is how original Zxing project is doing it. It seems like you need to create a new AutoFocusManager every time you change the configuration. |
||
autoFocusManager.setAutofocusInterval(autofocusIntervalInMs); | ||
} | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
private
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I need this protected, to access this default value from other classes in the same package.
For example: https://github.com/dlazaro66/QRCodeReaderView/pull/64/files#diff-63e2aacd2af702b6dfe82ecf928463efR52
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍