mirror of
https://github.com/zxing/zxing.git
synced 2024-11-09 20:44:03 -08:00
Zoom and use subset of larger preview
This commit is contained in:
parent
d5852ff9ef
commit
9b2ddac3cf
|
@ -25,15 +25,14 @@ import com.google.zxing.client.android.camera.CameraConfigurationUtils;
|
|||
*/
|
||||
final class CameraConfigurationManager {
|
||||
|
||||
static final int ZOOM = 2;
|
||||
|
||||
private CameraConfigurationManager() {
|
||||
}
|
||||
|
||||
static void configure(Camera camera) {
|
||||
Camera.Parameters parameters = camera.getParameters();
|
||||
//parameters.setPreviewSize(1024, 768);
|
||||
parameters.setPreviewSize(1024, 576);
|
||||
// parameters.setPreviewSize(512, 288);
|
||||
|
||||
parameters.setPreviewSize(1280, 720);
|
||||
configureAdvanced(parameters);
|
||||
camera.setParameters(parameters);
|
||||
}
|
||||
|
@ -43,7 +42,7 @@ final class CameraConfigurationManager {
|
|||
CameraConfigurationUtils.setBarcodeSceneMode(parameters);
|
||||
CameraConfigurationUtils.setVideoStabilization(parameters);
|
||||
CameraConfigurationUtils.setMetering(parameters);
|
||||
CameraConfigurationUtils.setZoom(parameters, 2.0);
|
||||
CameraConfigurationUtils.setZoom(parameters, ZOOM);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -141,8 +141,19 @@ final class DecodeRunnable implements Runnable, Camera.PreviewCallback {
|
|||
|
||||
private void decode(byte[] data) {
|
||||
Result rawResult = null;
|
||||
|
||||
int subtendedWidth = width / CameraConfigurationManager.ZOOM;
|
||||
int subtendedHeight = height / CameraConfigurationManager.ZOOM;
|
||||
int excessWidth = width - subtendedWidth;
|
||||
int excessHeight = height - subtendedHeight;
|
||||
|
||||
//long start = System.currentTimeMillis();
|
||||
PlanarYUVLuminanceSource source =
|
||||
new PlanarYUVLuminanceSource(data, width, height, 0, 0, width, height, false);
|
||||
new PlanarYUVLuminanceSource(data,
|
||||
width, height,
|
||||
excessWidth / 2, excessHeight / 2,
|
||||
subtendedWidth, subtendedHeight,
|
||||
false);
|
||||
BinaryBitmap bitmap = new BinaryBitmap(new HybridBinarizer(source));
|
||||
try {
|
||||
rawResult = new MultiFormatReader().decode(bitmap, hints);
|
||||
|
@ -150,6 +161,8 @@ final class DecodeRunnable implements Runnable, Camera.PreviewCallback {
|
|||
// continue
|
||||
}
|
||||
|
||||
//long end = System.currentTimeMillis();
|
||||
//Log.i(TAG, "Decode in " + (end - start));
|
||||
Handler handler = getHandler();
|
||||
Message message;
|
||||
if (rawResult == null) {
|
||||
|
|
Loading…
Reference in a new issue