journeyapps / zxing-android-embedded

Barcode scanner library for Android, based on the ZXing decoder
https://journeyapps.com/
Apache License 2.0
5.73k stars 1.27k forks source link

migrate to camera2 #92

Open commjoen opened 8 years ago

commjoen commented 8 years ago

The Camera API is currently deprecated. It would be great if we can move to the Camera2 API.

rkistner commented 8 years ago

Agreed. The Camera2 API also has some nice features, for example being able to use different resolutions for the preview and for decoding. We'll still have to support the old API for pre-lollipop devices though.

mattfiocca commented 5 years ago

It's been a while since this was mentioned. Are there any plans for this in the near future?

rkistner commented 5 years ago

@mattfiocca No plans yet, since the current camera implementation works well, and migration to the Camera2 API risks introducing new issues on various devices.

That said, pull requests are welcome.

mattfiocca commented 5 years ago

@rkistner, roger that. Camera2 api has been a pain in my side on other projects... i get it ;)

hanabi1224 commented 4 years ago

+1 it would be nice to switch to camera2 / camerax

seasonyuu commented 4 years ago

@mattfiocca No plans yet, since the current camera implementation works well, and migration to the Camera2 API risks introducing new issues on various devices.

That said, pull requests are welcome.

This lib is not working well in my device, which is run on Android 9 and only support Camera 2 API.

CameraInstance: Failed to configure camera
    java.lang.RuntimeException: Camera not open
        at com.journeyapps.barcodescanner.camera.CameraManager.configure(CameraManager.java:157)
        at com.journeyapps.barcodescanner.camera.CameraInstance$4.run(CameraInstance.java:203)
        at android.os.Handler.handleCallback(Handler.java:873)
        at android.os.Handler.dispatchMessage(Handler.java:99)
        at android.os.Looper.loop(Looper.java:193)
        at android.os.HandlerThread.run(HandlerThread.java:65)
rkistner commented 4 years ago

@seasonyuu Which phone is this? Does the Barcode Scanner app work on your device?

While the original Camera API has been deprecated for a while, I'm not aware of it being removed/disabled anywhere. Android 9 did add other restrictions, such as not allowing apps to use the camera while in the background.

seasonyuu commented 4 years ago

@seasonyuu Which phone is this? Does the Barcode Scanner app work on your device?

While the original Camera API has been deprecated for a while, I'm not aware of it being removed/disabled anywhere. Android 9 did add other restrictions, such as not allowing apps to use the camera while in the background.

That's not a phone, somehow is an speaker which is running on Android 9. And maybe the firmware didn't implement Camera legacy API.

artofbeinghuman commented 4 years ago

Like @seasonyuu I get the CameraInstance: Failed to configure camera error, when implementing the ContinuousScanActivity and trying to run it on the Nexus 5X virtual device on API 28 (Android 9.0). I am using zxing-android-embedded:4.1.0 Is there a way, I could use camera2? Or do I need to manually add permissions? I am a bit confused on what to do.

rkistner commented 4 years ago

@artofbeinghuman It's very rare to see a device not implement the camera 1 API. Migrating to the camera2 API would be for the improved API capabilities, not for device compatibility.

In your case my guess is that it's just an emulator configuration issue. Check that the camera is enabled in the emulator, and that other apps (such as the Barcode Scanner app) works.