摄像头输出有明显色差,

如图,摄像头是 MIPI相机树莓派4B摄像头模块500万像素OV5647感光芯片1080P高清摄像头 ,

img

调用代码:


import cv2
cap = cv2.VideoCapture(0)
flag = cap.isOpened()
index = 1
print(flag)
while (flag):
    ret, frame = cap.read()
    cv2.imshow("Capture_Paizhao", frame)
    k = cv2.waitKey(1) & 0xFF
    if k == ord('s'):  # 按下s键,进入下面的保存图片操作
        cv2.imwrite("E:/PyCharm Workspaces/" + str(index) + ".jpg", frame)
        print("save" + str(index) + ".jpg successfuly!")
        print("-------------------------")
        index += 1
    elif k == ord('q'):  # 按下q键,程序退出
        break
cap.release() # 释放摄像头
cv2.destroyAllWindows()# 释放并销毁窗口

报警告结果

[ WARN:0] global ../modules/videoio/src/cap_gstreamer.cpp (961) open OpenCV | GStreamer warning: Cannot query video position: status=0, value=-1, duration=-1

Unable to init server: 无法连接:拒绝连接
Traceback (most recent call last):
  File "/home/husters/camera.py", line 8, in <module>
    cv2.imshow("Capture_Paizhao", frame)
cv2.error: OpenCV(4.5.1) ../modules/highgui/src/window_gtk.cpp:624: error: (-2:Unspecified error) Can't initialize GTK backend in function 'cvInitSystem'

输出结果是有的,但是出现两块明显的色差区域,经验不足,不好判断是程序有问题,还是硬件有问题。

尝试使用一张图片打开展示一下,看看正常不