Skip to content
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

feat: New Observable for when Camera has been initalized #158

Open
3 of 7 tasks
derekdavieUH opened this issue Jun 13, 2024 · 4 comments
Open
3 of 7 tasks

feat: New Observable for when Camera has been initalized #158

derekdavieUH opened this issue Jun 13, 2024 · 4 comments
Labels

Comments

@derekdavieUH
Copy link

Plugin(s)

  • Barcode Scanning
  • Face Detection
  • Face Mesh Detection
  • Selfie Segmentation
  • Translation

Current problem

I am trying to save the state of the torch so that when a user re-opens the camera the torch is set to the same state as when they last closed the camera. However, if I enable to torch right after opening the camera, the torch flashes but does not stay on. If I add a 200ms delay the torch stays on as expected. I suspect this is because the torch is being turned on before the camera is finished being initialized/open and when it is open it defaults the torch to be off.

Preferred solution

An observable for the camera being initalized and/or opened would be a more elegant and reliable solution. I worry that with older and slower deviced the 200ms delay won't be enough, but I don't want to increase that delay to the point it's noticable by users.

Alternative options

The torch not being reset by the camera opening would be great, but I assume that is being set at the OS level.

Additional context

I only selected bardcode scanning as that is the only part of the library I have used, but I suspect the same issue woudl happen for all of the features.

Before submitting

@robingenz
Copy link
Member

Is this an issue on Android or iOS or both?

@derekdavieUH
Copy link
Author

@robingenz Both, I've observed the issue on an Android phone and a iPad mini. I was going back and forth but now I'm feeling like this is more of a bug? I have some free time later today, I'll fork the demo project and see if I can reproduce it there.

LMK if you want me to close and resubmit as a bug

@derekdavieUH
Copy link
Author

derekdavieUH commented Jun 15, 2024

I was mistaken, this only occurs in iOS (testing on iPad mini), and only occurs on the second time the scanner is open. I modifed the demo code to add a initialTorchState parameter to the Barcode Reader component. For this demo I set initialTorchState to always be True.

https://github.com/derekdavieUH/capacitor-mlkit-plugin-demo-persistent-torch

Commit with changes: derekdavieUH/capacitor-mlkit-plugin-demo-persistent-torch@f7a8d18

@robingenz
Copy link
Member

Thanks, i will take a look as soon as i have some time.

@robingenz robingenz added the platform: ios iOS platform label Jun 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants