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

Camera board • RPi Cam Module 3 Wide Image Quality Differences

$
0
0
I am working an a project to do some CV work with python and OpenCV. I am using a RPi Camera Module 3 Wide and I am getting wildly different images when capturing from them command line vs via a python script.

If I execute the command:

Code:

rpicam-still --width 2304 --height 1296 -o images/cli_test2.jpg
I get the following result: https://photos.app.goo.gl/ERUUZBbabnUh5PCk7

I wrote a very simple python script to display the camera output and optionally save the image to a file. I will post the script below but I get the following result:https://photos.app.goo.gl/45hocZPVqPVvjXEdA

I am clearly not setting something correct in the script. Any suggestions on how to get the image quality from the script to match the command line is much appreciated:

Code:

#! /usr/bin/pythonimport cv2import numpy as npimport timefrom picamera2 import Picamera2, Previewfrom libcamera import controlsprint("Step 0: Setup Camera")cam_w = 2304cam_h = 1296picam2 = Picamera2()picam2.preview_configuration.main.size = (cam_w, cam_h)picam2.preview_configuration.main.format = "RGB888"picam2.start()print("Wait for Camera to Stabilize")time.sleep(2)while True:    frame = picam2.capture_array()    # Copy frame to proc_img        proc_img = frame.copy()    # Do ops on proc_img here     # Display the live image    cv2.imshow("PiCam2", proc_img)    # press 'p' to snap a still pic    # press 'q' to quit    c = cv2.waitKey(1)    if c == ord('p'):        #snap picture        file_name = "output" + time.strftime("_%Y%m%d_%H%M%S") + ".png"        cv2.imwrite("images/"+file_name, frame)        pic = cv2.imread("images/"+file_name)         cv2.namedWindow(file_name)        cv2.moveWindow(file_name, 0,0)               cv2.imshow(file_name, pic)        print("Image Taken")    elif c == ord('q') or c == 27: #QUIT        print("Quitting...")        break# When everything done, release the capture#cap.release()cv2.destroyAllWindows()

Statistics: Posted by foofarley — Tue Oct 08, 2024 3:58 pm — Replies 3 — Views 70



Viewing all articles
Browse latest Browse all 5270

Trending Articles