Skip to content

Instantly share code, notes, and snippets.

@Hermann-SW
Created January 14, 2023 01:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Hermann-SW/ec9660498244f960b3e6c25f2c6e666b to your computer and use it in GitHub Desktop.
Save Hermann-SW/ec9660498244f960b3e6c25f2c6e666b to your computer and use it in GitHub Desktop.
Overlay displaying 640x75 and 640x150 areas for Raspberry v2 camera raspiraw capturing at 1007fps (with 640x75 and 640x150_s tools)
#!/usr/bin/python3
import numpy as np
from picamera import PiCamera
win = 100, 100, 640, 480
picam = PiCamera()
picam.resolution = (640, 480)
picam.preview_window = win
picam.preview_fullscreen = False
picam.start_preview()
overlay = np.zeros((480, 640, 4), dtype=np.uint8)
col = (0xFF, 0xFF, 0x00)
overlay[0 , : ] = (col) + (0xFF,)
overlay[74 , : ] = (col) + (0x80,)
overlay[149 , : ] = (col) + (0xFF,)
overlay[:150, :1] = (col) + (0xFF,)
overlay[:150, 639: ] = (col) + (0xFF,)
o = picam.add_overlay(overlay, layer=3, alpha=64)
o.window = win
o.fullscreen = False
input("Press Enter to continue ...")
picam.remove_overlay(o)
@Hermann-SW
Copy link
Author

Hermann-SW commented Jan 14, 2023

Example screenshot, shows the 640x75 and 640x150 areas on top of 640x480 camera preview window. To focus camera onto scene for later raspiraw capturing. picamera2 version is not useful for raspiraw capturing, since raspiraw needs legacy camera mode and picamera2 needs libcamera stack.

@Hermann-SW
Copy link
Author

Hermann-SW commented Jan 14, 2023

Above screenshot was on legacy Raspberry PiOS (Buster).
This is on 32bit Busllseye in legacy camera mode (different default background):

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment