circuitpython/ports/espressif/common-hal
Jeff Epler a8614a61dc ParallelImageCapture: Add continuous capture on espressif
By having a pair of buffers, the capture hardware can fill one buffer while
Python code (including displayio, etc) operates on the other buffer.  This
increases the responsiveness of camera-using code.

On the Kaluga it makes the following improvements:
 * 320x240 viewfinder at 30fps instead of 15fps using directio
 * 240x240 animated gif capture at 10fps instead of 7.5fps

As discussed at length on Discord, the "usual end user" code will look like
this:

    camera = ...

    with camera.continuous_capture(buffer1, buffer2) as capture:
        for frame in capture:
            # Do something with frame

However, rather than presenting a context manager, the core code consists of
three new functions to start & stop continuous capture, and to get the next
frame.  The reason is twofold.  First, it's simply easier to implement the
context manager object in pure Python.  Second, for more advanced usage, the
context manager may be too limiting, and it's easier to iterate on the right
design in Python code.  In particular, I noticed that adapting the
JPEG-capturing programs to use continuous capture mode needed a change in
program structure.

The camera app was structured as
```python
while True:
    if shutter button was just pressed:
        capture a jpeg frame
    else:
        update the viewfinder
```

However, "capture a jpeg frame" needs to (A) switch the camera settings and (B)
capture into a different, larger buffer then (C) return to the earlier
settings. This can't be done during continuous capture mode. So just
restructuring it as follows isn't going to work:

```python
with camera.continuous_capture(buffer1, buffer2) as capture:
    for frame in capture:
        if shutter button was just pressed:
            capture a jpeg frame, without disturbing continuous capture mode
        else:
            update the viewfinder
```

The continuous mode is only implemented in the espressif port; others
will throw an exception if the associated methods are invoked.  It's not
impossible to implement there, just not a priority, since these micros don't
have enough RAM for two framebuffer copies at any resonable sizes.

The capture code, including single-shot capture, now take mp_obj_t in the
common-hal layer, instead of a buffer & length.  This was done for the
continuous capture mode because it has to identify & return to the user the
proper Python object representing the original buffer.  In the Espressif port,
it was convenient to implement single capture in terms of a multi-capture,
which is why I changed the singleshot routine's signature too.
2021-11-03 11:02:46 -05:00
..
alarm add initial esp32c3 support 2021-09-26 09:39:40 +05:30
analogio rename left over esp32s2 to espressif 2021-09-18 19:42:18 +05:30
audiobusio Rename esp32s2 port to espressif 2021-09-13 16:44:55 -07:00
board Rename esp32s2 port to espressif 2021-09-13 16:44:55 -07:00
busio Merge tag 'v1.17' into merge-1.17 2021-10-15 08:20:54 -05:00
canio Rename esp32s2 port to espressif 2021-09-13 16:44:55 -07:00
countio rename left over esp32s2 to espressif 2021-09-18 19:42:18 +05:30
digitalio rename left over esp32s2 to espressif 2021-09-18 19:42:18 +05:30
dualbank rename left over esp32s2 to espressif 2021-09-18 19:42:18 +05:30
frequencyio rename left over esp32s2 to espressif 2021-09-18 19:42:18 +05:30
i2cperipheral rename `i2c_num_status` to `peripherals_i2c_get_free_num` 2021-10-07 14:12:14 +05:30
imagecapture ParallelImageCapture: Add continuous capture on espressif 2021-11-03 11:02:46 -05:00
microcontroller Merge pull request #5394 from microDev1/c3-port 2021-09-28 10:31:11 -07:00
neopixel_write rename left over esp32s2 to espressif 2021-09-18 19:42:18 +05:30
nvm rename left over esp32s2 to espressif 2021-09-18 19:42:18 +05:30
os rename left over esp32s2 to espressif 2021-09-18 19:42:18 +05:30
paralleldisplay Merge pull request #5378 from jepler/esp32s2-paralleldisplay-i2s 2021-09-23 20:25:43 -05:00
ps2io rename left over esp32s2 to espressif 2021-09-18 19:42:18 +05:30
pulseio add initial esp32c3 support 2021-09-26 09:39:40 +05:30
pwmio rename left over esp32s2 to espressif 2021-09-18 19:42:18 +05:30
rgbmatrix Rename esp32s2 port to espressif 2021-09-13 16:44:55 -07:00
rotaryio rotaryio: Add the ability to set the divisor 2021-10-16 09:43:45 -05:00
rtc rename left over esp32s2 to espressif 2021-09-18 19:42:18 +05:30
socketpool Merge tag 'v1.17' into merge-1.17 2021-10-15 08:20:54 -05:00
ssl Merge tag 'v1.17' into merge-1.17 2021-10-15 08:20:54 -05:00
supervisor rename left over esp32s2 to espressif 2021-09-18 19:42:18 +05:30
time Rename esp32s2 port to espressif 2021-09-13 16:44:55 -07:00
touchio rename left over esp32s2 to espressif 2021-09-18 19:42:18 +05:30
watchdog Merge tag 'v1.17' into merge-1.17 2021-10-15 08:20:54 -05:00
wifi Merge tag 'v1.17' into merge-1.17 2021-10-15 08:20:54 -05:00