Just to have a discussion with Raspberry Pi enthusiast here
I am trying to capture full quality image as fast as possibile, while saving the captured image in threads.
Running script above, when I am not saving image, capture image time is at average 270ms very constant. But if I enable save image, capture image time become fluctuate between 350-600ms.
I tried running in different raspberry pi version, different sd card, emmc, or ssd all perform the same.
Anyone has experience with this? Any ways to optimise the performance?
I am trying to capture full quality image as fast as possibile, while saving the captured image in threads.
Code:
import timeimport random from picamera2 import Picamera2from libcamera import controlsimport cv2import threadingimport iofrom PIL import Imageimport base64def save_image(image):# time.sleep(1) cv2.imwrite("test.png", image, [cv2.IMWRITE_PNG_COMPRESSION, 0])# cv2.imwrite("test.png", image, [cv2.IMWRITE_JPEG_QUALITY, 95])picam2 = Picamera2()camera_config = picam2.create_still_configuration(main={"size": (4608, 2592), 'format': 'RGB888'}, raw={"size": (4608, 2592)})picam2.configure(camera_config)picam2.start()time.sleep(1)while True: t = time.time() image = picam2.capture_array() print("Capture time: ", ((time.time() - t) * 1000)) x = threading.Thread(target=save_image, args=(image,)) x.start()
I tried running in different raspberry pi version, different sd card, emmc, or ssd all perform the same.
Anyone has experience with this? Any ways to optimise the performance?
Statistics: Posted by waikeat23 — Fri Sep 20, 2024 6:12 am