:mod:`camera`
=============
.. py:module:: camera
.. autoapi-nested-parse::
Support for camera input
The `camera` module contains classes to control the camera and take pictures.
.. raw:: html
Available on these boards
.. py:class:: Camera
The class to control camera.
Usage::
import board
import sdioio
import storage
import camera
sd = sdioio.SDCard(
clock=board.SDIO_CLOCK,
command=board.SDIO_COMMAND,
data=board.SDIO_DATA,
frequency=25000000)
vfs = storage.VfsFat(sd)
storage.mount(vfs, '/sd')
cam = camera.Camera()
buffer = bytearray(512 * 1024)
file = open("/sd/image.jpg","wb")
size = cam.take_picture(buffer, width=1920, height=1080, format=camera.ImageFormat.JPG)
file.write(buffer, size)
file.close()
Initialize camera.
.. py:method:: deinit() -> None
De-initialize camera.
.. py:method:: take_picture(buf: _typing.WriteableBuffer, format: ImageFormat) -> int
Take picture and save to ``buf`` in the given ``format``. The size of the picture
taken is ``width`` by ``height`` in pixels.
:return: the number of bytes written into buf
:rtype: int
.. py:class:: ImageFormat
Image format
Enum-like class to define the image format.
.. py:attribute:: JPG
:annotation: :ImageFormat
JPG format.
.. py:attribute:: RGB565
:annotation: :ImageFormat
RGB565 format.