Hello Anthony, nice to meet you, and welcome to the Forum!
I am the original author of the post you are referring to.
Two years ago I built a version 2 camera with RPi4-2GB/HQCamera/HyperPixel4.0Square
BlueDot trigger is always nice and easy solution on handheld HyperPixel projects, but for this camera sitting on a GorillaPod I needed something different, so I “developed” this script, scraped and stitched together from various sources.
The script uses a keyboard as a trigger for still images and timed video capture. The smaller the keyboard, the cooler your device. I use a Rii keyboard, but any keyboard wiil do!
Ok wait, this only works with RasPiOs Buster and older.
import sys, termios, tty, os, time
from picamera import PiCamera, Color
camera = PiCamera()
camera.start_preview()
def getch():
fd = sys.stdin.fileno()
old_settings = termios.tcgetattr(fd)
try:
tty.setraw(sys.stdin.fileno())
ch = sys.stdin.read(1)
finally:
termios.tcsetattr(fd, termios.TCSADRAIN, old_settings)
return ch
while True:
char = getch()
if (char == "1"):
camera.stop_preview()
camera.start_preview()
camera.resolution = (3840, 2160)
camera.iso = 200
ts=time.strftime("%Y-%m-%d-%H%M%S", time.gmtime())
camera.capture('/media/pi/KINGSTON/camera/img-'+ts+'.jpg')
if (char == "2"):
camera.stop_preview()
camera.start_preview()
camera.resolution = (3840, 2160)
camera.iso = 100
ts=time.strftime("%Y-%m-%d-%H%M%S", time.gmtime())
camera.capture('/media/pi/KINGSTON/camera/img-'+ts+'.jpg')
if (char == "3"):
camera.stop_preview()
camera.exposure_mode = 'auto'
camera.start_preview()
camera.resolution = (3840, 2160)
camera.iso = 400
ts=time.strftime("%Y-%m-%d-%H%M%S", time.gmtime())
camera.capture('/media/pi/KINGSTON/camera/img-'+ts+'.jpg')
if (char == "q"):
print("stop")
exit(0)
if (char == "v"):
camera.resolution = (1348, 762)
camera.framerate = 25
ts=time.strftime("%Y-%m-%d-%H%M%S", time.gmtime())
camera.start_recording('/media/pi/KINGSTON/camera2/vid-'+ts+'.h264')
camera.wait_recording(30)
camera.stop_recording()
camera.annotate_text_size = 60
camera.annotate_background = Color('black')
camera.annotate_foreground = Color('white')
camera.annotate_text = ' Video ready! '
time.sleep(2)
camera.annotate_text = ''
time.sleep(0.2)
As you can see, keys “1”, “2” and “3” just sets the camera ISO before capturing a still.
“v” captures a 30sec video
“q” quits
Set your paths accordingly
This will get you going and make a good starting point for your camera experiments, especially when mounting your camera stationary.
You can also install BlueDot on your Android device and use it as a remote for your camera.
The true video start/stop functionality would be your programming challenge?
If you do solve it, please share your solution!
I can post some pics of my camera, if you wish.
Let’s hear from you ok?
EDIT:
My RPi4 is running Buster and therefore a legacy Raspicam
camera stack.
Now, my script has to be written using libcamera
software. Hmm. Wait a minute… I’ll have to study this. There is no Python support using libcamera
, which is disappointing.
I see I would have to build my camera anew starting with a fresh RasPiOs, see how HyperPixel install goes, and learning those “new” camera apps… I am so late with this thing! :D
Can’t help but wondering why would I ever want to use HyperPixel4 on Bullseye?
Buster is heavenly good for this particular combination of hardware.
…