树莓派CM4+CS-MIPI-SC132 x2 运行python opencv报错
-
由于CS-MIPI-SC132最大支持1280x1080,故修改capture2opencv脚本如下:
import D_mipicamera as Dcam import time import cv2 #sudo apt-get install python-opencv def align_down(size, align): return (size & ~((align)-1)) def align_up(size, align): return align_down(size + align - 1, align) if __name__ == "__main__": try: camera = Dcam.mipi_camera() print("Open camera...") camera.init_camera() while cv2.waitKey(10) != 27: frame = camera.capture(encoding = 'i420') height = int(align_up(1080, 16)) width = int(align_up(1280, 32)) #修改了分辨率 image = frame.as_array.reshape(int(height * 1.5), width) image = cv2.cvtColor(image, cv2.COLOR_YUV2BGR_I420) cv2.imshow("D-Cam", image) # Release memory camera.release_buffer(frame) del frame print("Close camera...") camera.close_camera() except Exception as e: print(e)运行后报错:

-
@sjchen
除了你已经修改的地方之外,
需要用
D_init_camera_ex函数代替D_init_camera,这个函数具备分辨率的定义参数。
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login