I’ve been using the legacy camera option to take bird videos with an HQ camera, a motion detector and a Raspberry Pi 3B+. I Run the code headless because the camera is out in the yard. I have not had any problems with this setup. But with an eye to the future I’d like to change to using the libcamera option. I have succeeded in modifying the code so that I can achieve the same results using libcamera, except for one deadly problem: the code won’t run headless. The code works fine if not running headless. I have not been able to find a way to get around this. Can someone help?
My code:
<import os
import RPi.GPIO as GPIO
GPIO.setmode(GPIO.BCM)
GPIO.setup(17,GPIO.IN,GPIO.PUD_DOWN)
import datetime
import time
def f():
from datetime import datetime
dt = datetime.now()
ts = datetime.timestamp(dt)
timestamp = ts
date_time = datetime.fromtimestamp(timestamp)
str_date_time = date_time.strftime("%m-%d-%Y-%H:%M:%S")
f=(str_date_time)
return f
time.sleep(2)
ctr=1
print("Waiting for motion detection...")
while True:
if GPIO.input(17):
print("Pin 17 is high")
os.system("libcamera-vid -t 8000 --width 640 --height 480 --framerate 60 -o "+f()+".h264")
print("Image",ctr,"captured at ",f())
#GPIO.setup(17,GPIO.IN,GPIO.PUD_DOWN)
print("Ready")
ctr+=1
time.sleep(5)>
My code:
<import os
import RPi.GPIO as GPIO
GPIO.setmode(GPIO.BCM)
GPIO.setup(17,GPIO.IN,GPIO.PUD_DOWN)
import datetime
import time
def f():
from datetime import datetime
dt = datetime.now()
ts = datetime.timestamp(dt)
timestamp = ts
date_time = datetime.fromtimestamp(timestamp)
str_date_time = date_time.strftime("%m-%d-%Y-%H:%M:%S")
f=(str_date_time)
return f
time.sleep(2)
ctr=1
print("Waiting for motion detection...")
while True:
if GPIO.input(17):
print("Pin 17 is high")
os.system("libcamera-vid -t 8000 --width 640 --height 480 --framerate 60 -o "+f()+".h264")
print("Image",ctr,"captured at ",f())
#GPIO.setup(17,GPIO.IN,GPIO.PUD_DOWN)
print("Ready")
ctr+=1
time.sleep(5)>
Statistics: Posted by emeyeraway — Sun Mar 03, 2024 5:19 pm