circuitpython/shared-module
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
..
_bleio Merge tag 'v1.17' into merge-1.17 2021-10-15 08:20:54 -05:00
_eve run code formatting script 2021-03-15 19:27:36 +05:30
_stage Stage: add support for viewport scrolling 2021-10-09 00:05:49 +02:00
adafruit_bus_device Merge tag 'v1.17' into merge-1.17 2021-10-15 08:20:54 -05:00
adafruit_pixelbuf Remove _ from common_hal__adafruit_pixelbuf. 2021-07-16 14:08:39 -04:00
aesio run code formatting script 2021-03-15 19:27:36 +05:30
atexit Merge tag 'v1.17' into merge-1.17 2021-10-15 08:20:54 -05:00
audiocore Track more carefully which audio buffers to fill, based on interrupt channels 2021-08-10 22:00:09 -04:00
audioio bring MixerVoice back to building state; update documentation 2019-08-03 11:20:06 -05:00
audiomixer RP2040 PWMAudioOut: Release DMA channels after play has finished. 2021-07-01 17:36:29 -04:00
audiomp3 MP3Decoder: Fix playback stopping issue 2021-08-17 10:03:47 -05:00
audiopwmio audiopwmio: Add the shared files for this new module 2019-07-26 07:52:37 -05:00
bitbangio Move OneWire to `onewireio` from `busio` 2021-08-12 10:47:14 -07:00
bitmaptools Correct the 24bit decoding in bitmaptools.readinto() 2021-09-13 19:50:35 +01:00
bitops Merge MicroPython 1.14 into CircuitPython 2021-05-11 15:07:40 -07:00
board unlock board.I2C() on reset 2021-05-21 17:49:50 -04:00
busio Move OneWire to `onewireio` from `busio` 2021-08-12 10:47:14 -07:00
canio run code formatting script 2021-03-15 19:27:36 +05:30
displayio Merge tag 'v1.17' into merge-1.17 2021-10-15 08:20:54 -05:00
fontio Merge tag 'v1.17' into merge-1.17 2021-10-15 08:20:54 -05:00
framebufferio add initial esp32c3 support 2021-09-26 09:39:40 +05:30
gamepadshift Merge MicroPython v1.11 into CircuitPython 2021-04-26 15:47:41 -07:00
getpass Merge tag 'v1.17' into merge-1.17 2021-10-15 08:20:54 -05:00
imagecapture ParallelImageCapture: Add continuous capture on espressif 2021-11-03 11:02:46 -05:00
ipaddress run code formatting script 2021-03-15 19:27:36 +05:30
keypad keypad: Event: add timestamp. 2021-09-16 21:08:05 -05:00
memorymonitor run code formatting script 2021-03-15 19:27:36 +05:30
msgpack Merge MicroPython v1.11 into CircuitPython 2021-04-26 15:47:41 -07:00
multiterminal Merge tag 'v1.9.3' 2017-11-02 12:41:50 -07:00
onewireio Move OneWire to `onewireio` from `busio` 2021-08-12 10:47:14 -07:00
os run code formatting script 2021-03-15 19:27:36 +05:30
paralleldisplay Stub out the non-sequential parallel bus constructor 2021-09-21 15:00:43 -05:00
qrio Merge tag 'v1.17' into merge-1.17 2021-10-15 08:20:54 -05:00
rainbowio Rename rainbow to rainbowio 2021-07-12 14:40:01 -04:00
random run code formatting script 2021-03-15 19:27:36 +05:30
rgbmatrix remove commented-out code 2021-05-27 11:33:17 -05:00
rotaryio rotaryio: Add the ability to set the divisor 2021-10-16 09:43:45 -05:00
sdcardio remove debug print 2021-10-25 16:52:23 -05:00
sharpdisplay run code formatting script 2021-03-15 19:27:36 +05:30
storage Create first BLE-only board, Micro:Bit v2 2021-07-14 09:55:51 -07:00
struct Merge MicroPython 1.12 into CircuitPython 2021-05-03 14:01:18 -07:00
synthio RP2040 PWMAudioOut: Release DMA channels after play has finished. 2021-07-01 17:36:29 -04:00
terminalio Add ability to disable BLE workflow 2021-08-02 18:37:19 -07:00
time merge from upstream + wip 2020-11-25 17:52:06 -05:00
touchio run code formatting script 2021-03-15 19:27:36 +05:30
traceback Reduce code duplication in traceback module 2021-08-09 08:27:28 -05:00
uheap Merge MicroPython v1.11 into CircuitPython 2021-04-26 15:47:41 -07:00
usb_cdc Merge tag 'v1.17' into merge-1.17 2021-10-15 08:20:54 -05:00
usb_hid check that boot device is interface #0; remove instrumentation 2021-10-13 12:30:01 -04:00
usb_midi Handle USB_HIGHSPEED for MIDI also 2021-05-19 07:43:47 -04:00
ustack run code formatting script 2021-03-15 19:27:36 +05:30
vectorio Make the x and y bounds checking functions static 2021-09-11 17:10:21 +01:00