Had a look through the tutorial and noticed that my previous code snippet might have been misleading, as the tutorial is using a three colour plane array - with no fourth transparency 'X' plane.
So the snippet below should directly replace the old Picamera code as the basis of a working version of the tutorial.Hope that helps!
So the snippet below should directly replace the old Picamera code as the basis of a working version of the tutorial.
Code:
import cv2import numpy as npfrom fastiecm import fastiecm# Replace# from picamera import PiCamera# import picamera.array# With:-from picamera2 import Picamera2# import Transform to allow hflip vflip to replace 180 rotationfrom libcamera import Transform# Replace # cam = PiCamera()# With:-picam2=Picamera2()# Replace #cam.rotation = 180#cam.resolution = (2592, 1952) # Comment this line if using a Pi Noir camera#cam.capture(stream, format='bgr', use_video_port=True)# With :-picam2.configure (picam2.create_still_configuration(main={'format': 'RGB888', 'size' :(2028,1520)}, transform=Transform(hflip=True,vflip=True)))#Use format RGB888 as the later cv2 code is expecting rgb planes without a fourth X transparency plane# And start picam2.start()# Then capture array and the remaining code is unchangedoriginal=picam2.capture_array()
Statistics: Posted by sandyol — Sun Feb 11, 2024 7:19 pm