hello guys iam new to lib camera libiray
i write some python code for raspberry pi based push button camera its give me error and freeze the whole raspberry pi
here my rasberry pi specs zero2w, gpu memory64mb, 2022 bullseye os and im using vnc server, camera module v3...
here my code;
from picamera2 import Picamera2, Preview # Import libraries
from time import sleep
from gpiozero import Button
# Button and camera initialization
button = Button(6)
camera = Picamera2()
# Set the preview (optional for troubleshooting)
camera.start_preview
# Configure camera (resolution needs to be set after camera creation)
camera_config = camera.create_still_configuration(main={"size": (4608, 2592)})
camera.configure(camera_config)
# Start the camera
camera.start()
frame = 1
try:
while True:
# Wait for button press
button.wait_for_press()
# Capture image with unique filename based on frame number
file_path = f"/home/murugan/Pictures/frame_{frame}.jpg"
camera.capture_file(file_path)
frame += 1
print(f"Captured {file_path}")
except KeyboardInterrupt:
# Stop preview and cleanup on keyboard interrupt
print("Exiting...")
camera.stop_preview()
camera.close()
i write some python code for raspberry pi based push button camera its give me error and freeze the whole raspberry pi
here my rasberry pi specs zero2w, gpu memory64mb, 2022 bullseye os and im using vnc server, camera module v3...
here my code;
from picamera2 import Picamera2, Preview # Import libraries
from time import sleep
from gpiozero import Button
# Button and camera initialization
button = Button(6)
camera = Picamera2()
# Set the preview (optional for troubleshooting)
camera.start_preview
# Configure camera (resolution needs to be set after camera creation)
camera_config = camera.create_still_configuration(main={"size": (4608, 2592)})
camera.configure(camera_config)
# Start the camera
camera.start()
frame = 1
try:
while True:
# Wait for button press
button.wait_for_press()
# Capture image with unique filename based on frame number
file_path = f"/home/murugan/Pictures/frame_{frame}.jpg"
camera.capture_file(file_path)
frame += 1
print(f"Captured {file_path}")
except KeyboardInterrupt:
# Stop preview and cleanup on keyboard interrupt
print("Exiting...")
camera.stop_preview()
camera.close()
Statistics: Posted by murugan1405 — Sat May 25, 2024 8:03 pm — Replies 0 — Views 29