Micropython - v1.11-498 introduced a few changes in the source-code directory structure. Changes to specific files, as previously described in esp32-cam, will no longer work.
A simple working summary on how to build esp32-cam firmware is described below:
Make a recursive copy of ports/esp32 to ports/esp32-cam, and you will need to modify the following files:
1) ports/esp32-cam/main.c
2) ports/esp32-cam/Makefile
3) ports/esp32-cam/modcamera.c
4) ports/esp32-cam/mpconfigport.h
5) ports/esp32-cam/boards/manifest.py
6) ports/esp32-cam/boards/sdkconfig.base
Or, you can just download a precompiled Micropython v1.11-498 from firmware.bin at GitHub if you want to save some work. However, I encourage you to compile the firmware yourself. You will learn a lot and you can choose to modify anything to your liking.
The modcamera.c includes something new. The still photo was taken using these settings; pix=8, con=2, qua=10, and spe=2. You will understand those parameters, later on, I promise.
I have improved the modcamera.c code to incorporate seven new additional functions:
1) framesize
2) quality
3) contrast
4) saturation
5) brightness
6) speffect
7) whitebalance
They are all callable after camera.init(), which means, we can change those properties at the run time. In our case, we will use HTTP GET requests to do just that.
Let assume that the esp32-cam webcam server is listening on IP-address 10.0.0.33 and port 82, then:
1) http://10.0.0.33:82/apikey/pix/9
pix sets frame size corresponds to the values below:
2) http://10.0.0.33:82/apikey/qua/12
qua sets quality property. The valid value is from 10 to 63, a lower value means higher quality. The default value is 12.
3) http://10.0.0.33:82/apikey/con/0
con sets contrast property.
4) http://10.0.0.33:82/apikey/sta/0
sta sets the saturation property.
5) http://10.0.0.33:82/apikey/bri/0
bri sets brightness property.
The value for a con, sta, and bri is from -2 to 2, where a lower
value means a lower property value. For example, con=2 will set the camera to the highest contrast setting. The default value is 0.
6) http://10.0.0.33:82/apikey/spe/0
spe sets special effect property corresponds to the values below:
7) http://10.0.0.33:82/apikey/wbl/0
wbl set the white balance property corresponds to the values below:
The webcam.py server implements a simple uasyncio based HTTP server serving three ports concurrently:
The sample video shows the effect of changing camera properties by sending command requests to port 82 while streaming live feed on port 80. The commands were sent in this sequence; pix=8, qua=10, spe=2, pix=6, spe=0, and con=2.
Are you interested yet? Yes? The ability to change camera properties on the fly opens up many possibilities. We have full control of the camera from a web browser or any application that can perform HTTP GET requests.
Go to my GitHub repository and get a copy of 1-11-498 firmware and the MicroPython scripts. Mind you, I exclude help, upip, and webrepl modules from the firmware to reduce its size.
Those who prefer self-compiled firmware can following the guidelines described at my GitHub page.
A simple working summary on how to build esp32-cam firmware is described below:
Make a recursive copy of ports/esp32 to ports/esp32-cam, and you will need to modify the following files:
1) ports/esp32-cam/main.c
2) ports/esp32-cam/Makefile
3) ports/esp32-cam/modcamera.c
4) ports/esp32-cam/mpconfigport.h
5) ports/esp32-cam/boards/manifest.py
6) ports/esp32-cam/boards/sdkconfig.base
Or, you can just download a precompiled Micropython v1.11-498 from firmware.bin at GitHub if you want to save some work. However, I encourage you to compile the firmware yourself. You will learn a lot and you can choose to modify anything to your liking.
The modcamera.c includes something new. The still photo was taken using these settings; pix=8, con=2, qua=10, and spe=2. You will understand those parameters, later on, I promise.
I have improved the modcamera.c code to incorporate seven new additional functions:
1) framesize
2) quality
3) contrast
4) saturation
5) brightness
6) speffect
7) whitebalance
They are all callable after camera.init(), which means, we can change those properties at the run time. In our case, we will use HTTP GET requests to do just that.
Let assume that the esp32-cam webcam server is listening on IP-address 10.0.0.33 and port 82, then:
1) http://10.0.0.33:82/apikey/pix/9
pix sets frame size corresponds to the values below:
- QQVGA - 160x120
- QQVGA2 - 128x160
- QCIF - 176x144
- HQVGA - 240x176
- QVGA - 320x240
- CIF - 400x296
- VGA - 640x480
- SVGA - 800x600
- XGA - 1024x768 (default)
- SXGA - 1280x1024
- UXGA - 1600x1200
- QXGA - 2048x1536
2) http://10.0.0.33:82/apikey/qua/12
qua sets quality property. The valid value is from 10 to 63, a lower value means higher quality. The default value is 12.
3) http://10.0.0.33:82/apikey/con/0
con sets contrast property.
4) http://10.0.0.33:82/apikey/sta/0
sta sets the saturation property.
5) http://10.0.0.33:82/apikey/bri/0
bri sets brightness property.
The value for a con, sta, and bri is from -2 to 2, where a lower
value means a lower property value. For example, con=2 will set the camera to the highest contrast setting. The default value is 0.
6) http://10.0.0.33:82/apikey/spe/0
spe sets special effect property corresponds to the values below:
- negative
- black and white
- reddish
- greenish
- blueish
- retro (sepia)
7) http://10.0.0.33:82/apikey/wbl/0
wbl set the white balance property corresponds to the values below:
- sunny
- cloudy
- office
- home
The webcam.py server implements a simple uasyncio based HTTP server serving three ports concurrently:
- 80 - live streaming
- 81 - still photos
- 82 - command
The sample video shows the effect of changing camera properties by sending command requests to port 82 while streaming live feed on port 80. The commands were sent in this sequence; pix=8, qua=10, spe=2, pix=6, spe=0, and con=2.
Are you interested yet? Yes? The ability to change camera properties on the fly opens up many possibilities. We have full control of the camera from a web browser or any application that can perform HTTP GET requests.
Go to my GitHub repository and get a copy of 1-11-498 firmware and the MicroPython scripts. Mind you, I exclude help, upip, and webrepl modules from the firmware to reduce its size.
Those who prefer self-compiled firmware can following the guidelines described at my GitHub page.
Comments
Post a Comment