Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 5420

Beginners • RaspberryPi camera code

$
0
0
Hello everyone!
I am new to RaspberryPi. I am currently using a RaspberryPi 5 with a Camera Module 3 (WIDE).
I did this script to capture an image with a good quality and resolution.
Could anyone tell me if I am configuring the camera correctly as to get a good image quality and focus?
I don't have the RaspberryPi with me right now, but I would like to know if I am doing this correctly because when I get the Raspberry I will not have much time to set the configurations up, and I want to be able to quickly adjust the focus and the quality of the image.

Code:

from gpiozero import Buttonimport timeimport osfrom picamera2 import Picamera2from libcamera import controlscamera = Picamera2()preview_config = camera.create_preview_configuration()capture_config = camera.create_still_configuration()camera.configure(preview_config)camera.start(show_preview=True)output_folder = "/home/raspberrypi/captured_image"os.makedirs(output_folder, exist_ok=True)# Set exposure timecamera.set_controls({'ExposureTime': 5000}) # Example: 5000 microseconds (0.005 seconds)camera.set_controls({'AfMode': controls.AfModeEnum.Manual})camera.set_controls({'LensPosition': 0.5})  # Set focus distance: 2 meters# Capture imageimage_path = os.path.join(output_folder, f"image_test.jpg")camera.switch_mode_and_capture_file(capture_config, image_path)        camera.close()
I appreciate the help! :D

Statistics: Posted by BeaPeCo — Mon Jul 22, 2024 2:33 pm



Viewing all articles
Browse latest Browse all 5420

Trending Articles