Skip to main content
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:
  1. QQVGA - 160x120
  2. QQVGA2 - 128x160
  3. QCIF - 176x144
  4. HQVGA - 240x176
  5. QVGA - 320x240
  6. CIF - 400x296
  7. VGA - 640x480
  8. SVGA - 800x600
  9. XGA - 1024x768 (default)
  10. SXGA - 1280x1024
  11. UXGA - 1600x1200
  12. 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:
  1. negative
  2. black and white
  3. reddish
  4. greenish
  5. blueish
  6. retro (sepia)
The default value is 0 for no special effect.

7) http://10.0.0.33:82/apikey/wbl/0
wbl set the white balance property corresponds to the values below:
  1. sunny
  2. cloudy
  3. office
  4. home
The default value is 0 for automatic.

The webcam.py server implements a simple uasyncio based HTTP server serving three ports concurrently:
  1. 80 - live streaming
  2. 81 - still photos
  3. 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

Popular posts from this blog

Custom made - Sometimes, it is nice to be able to build custom made things. Thanks to Damien George and all the clever people at micropython.org for making it easy. So that, to custom build a micropython is not that difficult. Why do you want to build customize firmware anyway? Well, you might want to include some functionalities of your own and removed some functionalities from the standard distribution. The choices are there for you to make. I have a few changes that I want to make in micropython. version header -kaki5 (pronounce kaki-lima) an additional thread cleanup function for esp32 add frozen modules CryptoXo and uasyncio remove help, upip, and webrepl camera C module for esp32 camera board These are accomplished by modifying and adding files. py/makeversionhdr.py py/modthread.c extra/CryptoXo.py, extra/uasyncio.py, and manifest.py mpconfigport.h main.c and modcamera.c I also want to remove some modules specifically, help, upip, and webrepl from esp32...
Multi-threading : I previously used an uasyncio webcam server. This time around, I am testing a multi-thread webcam server. The result is promising. A multi-thread server seems to give a better throughput. The program logic is simpler when compared to the server based on uasyncio. The server is a four threaded application, two for port 80, one for port 81, and port 82 runs on the main thread, which blocks the REPL.  You can start a dedicated thread for port 82 if you do not want to block the REPL. I found pix/7 gives the best performance. A spe/2 will reduce the image size but give you a grayscale image. Please see my previous blog if all these seem mysterious to you. I have compiled a new firmware, MicroPython v1.11-571-g7e374d231.  You can download the new firmware from my repository at GitHub. The soft reset is not functioning properly. You need to do a hard reset. I also include four new functions in modcamera.c: pixformat agcgain aelevels aecvalue The pixfo...