Closed allanwolski closed 3 years ago
Hi, thanks for your input!
I will look into it.
My only concern would be that the user cannot know whether detection is enabled or not. At least not without additional ui.
I pushed a new version (1.1.1) which should fix this.
Please confirm, so I can close this issue.
Thanks for the quick fix.
DetectionMode.pauseDetection works correctly now, but the camera freezes a bit when we call CameraController.instance.resumeDetector().
Is there anything that can be done?
If you are talking about Android then it's because the camera is basically restarted from scratch. Every time the Camera is resumed all use cases are rebound and I don't know if we can avoid rebinding the preview...
I'm trying to change from fast_qr_reader_view to fast_barcode_scanner because it has been descontinued. The fast_qr_reader_view packeage does not freeze at scan interval.
Ah okay, great to hear!
I'll try the plugin and see what they are doing different. I am confident that we can achieve the same experience.
Edit: Isn't it the same as the continous mode? The only difference is that calls are throttled.
Thanks for the quick answer.
Yes, but I need to pause detection for a few seconds to prevent the same code from being read multiple times.
What you are describing is basically throttling. You can use somethink like this. I think I'll add some configurable throttling on the native side (in seconds).
Edit: Oh wait, you are right. pauseDetection should not freeze the screen. Will look into that.
Please check the latest commit on the dev branch (#17). It should work on Android, but I didn't touch the ios implementation, yet.
Basically, on Android, CameraController now has pause/resumeCamera() and pause/resumeScanner(). When using pauseDetector mode, you have to call resumeScanner() to resume actually scanning frames.
Great @jhoogstraat, it's worked.
I can't use CameraController.instance anymore? Do I need to update minSdkVersion to 23?
Yeah you can just use CameraController() now. It will return a singleton, still.
Yeah you need to updated to 23. That will allow a for a simplified permissions handling.
I thought it was because the camera2 API.
I have many users who still use API 21 and 22. Is it possible to support this level of API in version 2.0.0 of the package?
Wow, that's quite old software. I'll see what I can do.
Thanks man, your package is very good.
I think I was wrong about the minSdk requirement. It should be reverted on #17.
I was right, Android Studio just didn't output the error. I will push an update.
Oh and this plugin uses CameraX on Android, instead of Camera2.
Perfect.
I have an error when I go back to the scanner, even calling CameraController().dispose()
.
I/flutter (21449): Error reading from camera: PlatformException(NOT_RUNNING, Camera is not running, null, null)
I/flutter (21449): Error reading from camera: PlatformException(ALREADY_RUNNING, Camera is already running, null, null)
That's weird. Android or iOS? You don't need to call dispose if the user is able to pull up the scanner it any time. You can just pause it and keep everything in memory.
The sample app has a configuration screen, which pauses the scanner when it is shown.
I'm testing on Android.
When closing the scanner screen, the log below is displayed on the console.
D/UseCaseAttachState(23127): Active and attached use case: [] for camera: 0
D/DeferrableSurface(23127): use count-1, useCount=0 closed=true androidx.camera.core.impl.ImmediateSurface@ec6c6c2
D/DeferrableSurface(23127): Surface no longer in use[total_surfaces=2, used_surfaces=1](androidx.camera.core.impl.ImmediateSurface@ec6c6c2}
D/DeferrableSurface(23127): Surface terminated[total_surfaces=1, used_surfaces=1](androidx.camera.core.impl.ImmediateSurface@ec6c6c2}
D/DeferrableSurface(23127): use count-1, useCount=0 closed=true androidx.camera.core.SurfaceRequest$2@e834437
D/DeferrableSurface(23127): Surface no longer in use[total_surfaces=1, used_surfaces=0](androidx.camera.core.SurfaceRequest$2@e834437}
D/DeferrableSurface(23127): Surface terminated[total_surfaces=0, used_surfaces=0](androidx.camera.core.SurfaceRequest$2@e834437}
D/Camera2CameraImpl(23127): {Camera@8b1a575[id=0]} CameraDevice.onClosed()
D/Camera2CameraImpl(23127): {Camera@8b1a575[id=0]} Transitioning camera internal state: CLOSING --> INITIALIZED
D/CameraStateRegistry(23127): Recalculating open cameras:
D/CameraStateRegistry(23127): Camera State
D/CameraStateRegistry(23127): -------------------------------------------------------------------
D/CameraStateRegistry(23127): Camera@8b1a575[id=0] CLOSED
D/CameraStateRegistry(23127): Camera@5afce57[id=1] UNKNOWN
D/CameraStateRegistry(23127): -------------------------------------------------------------------
D/CameraStateRegistry(23127): Open count: 0 (Max allowed: 1)
D/CameraStateMachine(23127): New public camera state CameraState{type=CLOSED, error=null} from CLOSED and null
D/CameraStateMachine(23127): Publishing new public camera state CameraState{type=CLOSED, error=null}
This looks normal. How does you dart code look like?
You have to call start/pauseCamera and not pause/start Scanner if you need to restart the whole camera (on #17).
When navigating to the scanner screen for the first time it works, but when going back to home and navigating to the scanner screen again it shows the error.
Check out the latest commit. Is your crash gone? It replicated your navigation path in the example app and it does not crash anymore.
It worked, thanks a lot.
When do you plan to publish this version?
@jhoogstraat great job, your package is good!
I'm waiting for this too, when do you intend to publish this version?
I am currently overthinking CameraController and writing tests for all classes and behaviours. I'd be great if you used (aka test) the Plugin intensively.
What would you like to see in the plugin? What don't you need?
Good job, this plugin is very good.
I want to pause the detector when a barcode is detected, but without freeze the camera.
I tried with pauseDetection and pauseVideo modes, but both freeze the camera.