espressif / esp-who

Face detection and recognition framework
Other
1.67k stars 466 forks source link

Feature: Control a LED Illuminator or Flash from Camera_Web_Server Web Page #104

Closed bkeevil closed 4 years ago

bkeevil commented 5 years ago

Control the LED flash on AI Thinker boards from web control panel.

See issues #24 and #96

This replaces my previous pull request. I squashed some commits and renamed the branch this patch is in on my fork from development->Feature/AIThinker-Flash.

me-no-dev commented 5 years ago

If other boards are to get use of this feature, code will need to be adjusted. Why not make the flash code a menuconfig configuration value, like define the pin as -1 if not to be used? that way you can check #if CONFIG_FLASH_LED_PIN >= 0 and include the code. I would also add the LEDC channel, timer and so on needed for LEDC config to menuconfig. And... flash is really only needed while vsync is active. That is actually when the image is capture by the sensor. Implementing that in software might be an issue though... will check what can be done in the driver.

me-no-dev commented 5 years ago

oh and for the web page... you can check agains a known bad value and hide the control in javascript

bkeevil commented 5 years ago

@me-no-dev what is an example of a "known bad value"?

bkeevil commented 5 years ago

A flash could be added to any board really. It could also be used to control the intensity of an IR illuminator. Maybe rename flash->led

bkeevil commented 5 years ago

@me-no-dev re triggering on vsync: the LED needed to be turned on ~150 ms before a photo was taken to have the most effect. Presumably it takes that long to get to full brightness.

me-no-dev commented 5 years ago

@me-no-dev what is an example of a "known bad value"?

If intensity goes from 0 to 100, then any value below 0 and above 100 will be a bad value, in which case the control can be hidden :)

@me-no-dev re triggering on vsync: the LED needed to be turned on ~150 ms before a photo was taken to have the most effect. Presumably it takes that long to get to full brightness.

150 us or ms? 150ms is a lot (a few frames), you might as well keep it on all the time ;)

bkeevil commented 5 years ago

Oh I see. There is no state data being sent with that page at all. It is stores as a gzip and adding state data would involve uncompressing it or sending data as an http header.

I think the best solution would be to modify the demo to serve a json file containing current camera state and retrieving it periodically from the main page with javascript.

On August 9, 2019 11:16:40 AM EDT, Me No Dev notifications@github.com wrote:

@me-no-dev what is an example of a "known bad value"?

If intensity goes from 0 to 100, then any value below 0 and above 100 will be a bad value, in which case the control can be hidden :)

@me-no-dev re triggering on vsync: the LED needed to be turned on ~150 ms before a photo was taken to have the most effect. Presumably it takes that long to get to full brightness.

150 us or ms? 150ms is a lot (a few frames), you might as well keep it on all the time ;)

-- You are receiving this because you authored the thread. Reply to this email directly or view it on GitHub: https://github.com/espressif/esp-who/pull/104#issuecomment-519958073

-- Sent from my Android device with K-9 Mail. Please excuse my brevity.

me-no-dev commented 5 years ago

this is how it actually works... when the page is loaded a json is retrieved from the server with the sensor state. Based on that state some controls are added, others are removed and proper state for all is set.

bkeevil commented 5 years ago

I missed that. I see it now. I will need to make some improvements to this patch then.

bkeevil commented 5 years ago

150 us or ms? 150ms is a lot (a few frames), you might as well keep it on all the time ;)

For video streams the flash stays on all the time. For stills the flash turns on and there is a vTaskDelay for 150 ms. At 100 ms the flash was visible but dim.

bkeevil commented 5 years ago

Screenshot from 2019-08-09 21-37-19

bkeevil commented 5 years ago

@me-no-dev the changes you wanted have been added as of 6a5f049 and the code compiles but I have not tested on any hardware yet. Will test tomorrow. Squashed all my commits.

bkeevil commented 5 years ago

I think I'm happy with this patch ea5abe5:

bkeevil commented 5 years ago

@XiaochaoGONG I may have lost your review when I rebased on your latest changes. Sorry. But your requested changes have been made.