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

Add Flashlight Feature. #5

Open
pranjalchalise opened this issue Jul 13, 2021 · 6 comments
Open

Add Flashlight Feature. #5

pranjalchalise opened this issue Jul 13, 2021 · 6 comments
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@pranjalchalise
Copy link
Member

pranjalchalise commented Jul 13, 2021

Recognizing notes in dim light and nights is a huge functional requirement for our users. Due to time constraints, the team could not implement the flashlight feature in the camera package.

@pranjalchalise pranjalchalise added enhancement New feature or request help wanted Extra attention is needed labels Jul 13, 2021
@aadarshadhakalg
Copy link
Contributor

Is anyone working on this issue?

@basnetsoyuj
Copy link
Member

Not currently. I want to specify that there is already FlashMode.auto in the camera plugin which is straightforward to use https://pub.dev/packages/camera/example (Just change https://github.com/DrishtiNP/Drishti/blob/master/lib/src/utils/camera.dart#L86 to FlashMode.auto)

But using this is not reliable + it can make the inference slower (It takes time to turn on the flash and focus, so it might be better for us to use something like FlashMode.torch but only when the intensity of light is below a certain threshold.

We also need to update the model by augmenting brighter images to mimic images taken using flash. I can work on this.

@aadarshadhakalg
Copy link
Contributor

I think for checking light intensity we can use the light sensors in android devices. I found this plugin but it only supports Android devices: https://pub.dev/packages/light

If there are other good approaches then please enlighten me.

@aadarshadhakalg
Copy link
Contributor

@basnetsoyuj I tried to implement the flashlight feature. For that, I used 'light' package to get the intensity of light. Then mapped the stream of light intensity provided by light package to the stream of FlashMode.

To prevent the unnecessary call of setFlashMode() method, I used distinct() method from the stream class. But while doing so, there arises a problem. The distinct method skips data events if they are equal to the previous data event. So, the listener will not get any data unless there is a change in FlashMode from either off or torch at the beginning.

For example:
I am in the darkroom, I open the app. In this case, FlashMode will be torch mode from the beginning so there is no change in FlashMode so the stream will not yield any value. Therefore the listener will not be invoked. So the flash won't turn on. Then if I go to a lightroom and then again return back to the darkroom then there is the change in FlashMode so the stream will yield the new FlashMode value and only the listener will be invoked. Then only the flash turns on.

I need help so that I can fix this issue.

Here's my latest code: https://github.com/aadarshadhakalg/Drishti

@basnetsoyuj
Copy link
Member

@aadarshadhakalg Thank you. I will look into this issue by today.

@aadarshadhakalg
Copy link
Contributor

@basnetsoyuj I somehow managed to fix the issue but after when testing I realized that even when flash mode is FlashMode.torch while taking the picture camera flashes which makes the picture quality no different than the one captured when flash mode is FlashMode.auto.

To Reproduce,
Keep flash mode to FlashMode.torch by default in the current app code. Then take the picture.

You can see the camera flashes while taking the picture.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

3 participants