Library for the Adafruit PyCamera with OV5640 autofocus module

class adafruit_pycamera.PyCamera(init_autofocus=True)

Wrapper class for the PyCamera hardware

class adafruit_pycamera.PyCameraBase

Base class for PyCamera hardware

autofocus() list[int]

Perform an autofocus operation.

If all elements of the list are 0, the autofocus operation failed. Otherwise, if at least one element is nonzero, the operation succeeded.

In principle the elements correspond to 5 autofocus regions, if configured.

autofocus_init()

Initialize the autofocus engine from ov5640_autofocus.bin

autofocus_init_from_bitstream(firmware: bytes)

Initialize the autofocus engine from a bytestring

autofocus_init_from_file(filename)

Initialize the autofocus engine from a .bin file

property autofocus_status

Read the camera autofocus status register

property autofocus_vcm_step

Get the voice coil motor step location

blit(bitmap, x_offset=0, y_offset=32)

Display a bitmap direct to the LCD, bypassing displayio

This can be more efficient than displaying a bitmap as a displayio TileGrid, but if any displayio objects overlap the bitmap, the results can be unpredictable.

The default preview capture is 240x176, leaving 32 pixel rows at the top and bottom for status information.

blit_overlay_into_last_capture()

Create a modified version of the last photo taken that pastes the overlay image on top of the photo and saves the new version in a separate but similarly named .bmp file on the SDCard.

capture_into_bitmap(bitmap)

Capture an image and blit it into the given bitmap

capture_into_jpeg()

Captures an image and returns it in JPEG format.

Returns:

The captured image in JPEG format, otherwise None if the capture failed.

Return type:

bytes

capture_jpeg()

Capture a jpeg file and save it to the SD card

check_for_update_needed()

Check whether CIRCUITPY is too big, indicating it was created by a version of CircuitPython older than 9.0.0 beta 2. If so display and print a message and hang.

continuous_capture()

Capture an image into an internal buffer.

The image is valid at least until the next image capture, or the camera’s capture mode is changed

continuous_capture_start()

Switch the camera to continuous-capture mode

deinit_display()

Release the TFT display

display_message(message, color=0xFF0000, scale=3, full_screen=False)

Display a message on the TFT

property effect

Get or set the effect mode (e.g., B&W, etc) as a numeric constant

get_camera_autosettings()

Collect all the settings related to exposure and white balance

init_accelerometer()

Initialize the accelerometer

init_camera(init_autofocus=True) None

Initialize the camera, by default including autofocus

init_display()

Initialize the TFT display

init_neopixel()

Initialize the neopixels (onboard & ring)

keys_debounce()

Debounce all keys.

This updates the values of self.shutter, etc., buttons

property led_color

Get or set the LED color, from 0 to 7

property led_level

Get or set the LED level, from 0 to 4

live_preview_mode()

Set the camera into live preview mode

make_camera_ui()

Create displayio widgets for the standard camera UI

property mode

Get or set the capture mode (e.g., JPEG, etc) as a numeric constant

property mode_text

Get the capture mode (e.g., JPEG, etc) as a human string

mount_sd_card()

Attempt to mount the SD card

open_next_image(extension='jpg')

Return an opened numbered file on the sdcard, such as “img01234.jpg”.

property overlay: str

The overlay file to be used. A filepath string that points to a .bmp file that has 24bit RGB888 Colorspace. The overlay image will be shown in the camera preview, and combined to create a modified version of the final photo.

read_camera_register(reg: int) int

Read a 1-byte camera register

property resolution

Get or set the resolution as a numeric constant

The resolution can also be set as a string such as “240x240”.

select_setting(setting_name)

For the point & shoot camera mode, control what setting is being set

set_camera_exposure(new_exposure=None)

Set the camera’s exposure values

The argument of None selects auto exposure.

Otherwise, the new exposure data should come from get_camera_autosettings()["exposure"].

set_camera_gain(new_gain=None)

Set the camera’s exposure values

The argument of None selects auto gain control.

Otherwise, the new exposure data should come from get_camera_autosettings()["gain"].

set_camera_wb(wb_register_values=None)

Set the camera white balance.

The argument of None selects auto white balance, while a list of 6 numbers sets a specific white balance.

The numbers can come from the datasheet or from get_camera_autosettings()["wb"].

property timelapse_rate

Get or set the amount of time between timelapse shots

property timelapse_submode

Get or set the power mode for timelapsing

tone(frequency, duration=0.1)

Play a tone on the internal speaker

unmount_sd_card()

Unmount the SD card, if mounted

write_camera_list(reg_list: Sequence[int]) None

Write a series of 1-byte camera registers

write_camera_register(reg: int, value: int) None

Write a 1-byte camera register

Routines for performing image manipulation

adafruit_pycamera.imageprocessing.alphablend_maker(frac, nfrac=None)

Create an alpha-blending function for a specific fractional value

The resulting function can be used with bitmapfilter.blend and bitmapfilter.blend_precompute.

adafruit_pycamera.imageprocessing.blue_cast(bitmap, mask=None)

Give an image a blue cast by dividing R and G channels in half

adafruit_pycamera.imageprocessing.blur(bitmap, mask=None)

Blur a bitmap

adafruit_pycamera.imageprocessing.color_burn_func(a, b)

The ‘color burn’ blend mode.

This function can be used with bitmapfilter.blend and bitmapfilter.blend_precompute.

adafruit_pycamera.imageprocessing.color_dodge_func(a, b)

The ‘color dodge’ blend mode.

This function can be used with bitmapfilter.blend and bitmapfilter.blend_precompute.

adafruit_pycamera.imageprocessing.darken_only_func()

The ‘darken only’ blend mode.

This function can be used with bitmapfilter.blend and bitmapfilter.blend_precompute.

adafruit_pycamera.imageprocessing.divide_func(a, b)

The ‘divide’ blend mode.

This function can be used with bitmapfilter.blend and bitmapfilter.blend_precompute.

adafruit_pycamera.imageprocessing.emboss(bitmap, mask=None)

Run an emboss filter on the bitmap

adafruit_pycamera.imageprocessing.emboss_greyscale(bitmap, mask=None)

Run an emboss filter on the bitmap in greyscale

adafruit_pycamera.imageprocessing.green_cast(bitmap, mask=None)

Give an image a green cast by dividing R and B channels in half

adafruit_pycamera.imageprocessing.greyscale(bitmap, mask=None)

Convert an image to greyscale

adafruit_pycamera.imageprocessing.hard_light_func(a, b)

The ‘hard light’ blend mode.

This function can be used with bitmapfilter.blend and bitmapfilter.blend_precompute.

adafruit_pycamera.imageprocessing.ironbow(bitmap, mask=None)

Convert an image to false color using the ‘ironbow palette’

adafruit_pycamera.imageprocessing.lighten_only_func()

The ‘screen’ blend mode.

This function can be used with bitmapfilter.blend and bitmapfilter.blend_precompute.

adafruit_pycamera.imageprocessing.linear_burn_func(a, b)

The ‘linear burn’ blend mode.

This function can be used with bitmapfilter.blend and bitmapfilter.blend_precompute.

adafruit_pycamera.imageprocessing.linear_dodge_func(a, b)

The ‘linear dodge’ blend mode.

This function can be used with bitmapfilter.blend and bitmapfilter.blend_precompute.

adafruit_pycamera.imageprocessing.multiply_func(a, b)

The ‘multiply’ blend mode.

This function can be used with bitmapfilter.blend and bitmapfilter.blend_precompute.

adafruit_pycamera.imageprocessing.negative(bitmap, mask=None)

Invert an image

adafruit_pycamera.imageprocessing.overlay_func(a, b)

The ‘overlay’ blend mode.

This function can be used with bitmapfilter.blend and bitmapfilter.blend_precompute.

adafruit_pycamera.imageprocessing.red_cast(bitmap, mask=None)

Give an image a red cast by dividing G and B channels in half

adafruit_pycamera.imageprocessing.screen_func(a, b)

The ‘screen’ blend mode.

This function can be used with bitmapfilter.blend and bitmapfilter.blend_precompute.

adafruit_pycamera.imageprocessing.sepia(bitmap, mask=None)

Apply a sepia filter to an image in place

adafruit_pycamera.imageprocessing.sharpen(bitmap, mask=None)

Sharpen a bitmap

adafruit_pycamera.imageprocessing.soft_light_func(a, b)

The ‘soft light’ blend mode.

There are various soft light blend functions. The “illusions.hu” variant of soft light is used.

This function can be used with bitmapfilter.blend and bitmapfilter.blend_precompute.

adafruit_pycamera.imageprocessing.subtract_func(a, b)

The ‘subtract’ blend mode.

This function can be used with bitmapfilter.blend and bitmapfilter.blend_precompute.

The ‘ironbow’ palette used to convert images to false color

adafruit_pycamera.ironbow.ironbow_palette = <displayio.Palette object>

A palette often used to convert images to false color