首页 > 解决方案 > 从字节转换后图像变为蓝色

问题描述

我正在接收以字节为单位的图像并将其转换为 JPG,但大部分颜色都变成了蓝色。代码中是否有可能导致这种情况的东西?

# Image capture and saving
def take_Images(servo):
    output_list = []
    for i in range(9):
        sys.stdout.flush()
        # Call image 
        img = get_Frame_Buffer_Call_Back("sensor.RGB565", "sensor.QVGA", cutthrough=False, silent=False)
        if img is not None:
            image = Image.open(io.BytesIO(img))
            image_visible = cv2.cvtColor(np.array(image), cv2.COLOR_BGR2RGB)
            output_list.append(image_visible)
            # Move Servo 
            servo.ChangeDutyCycle(1)
            time.sleep(0.05)
            servo.ChangeDutyCycle(0)
        else:
            print("Error!")

    servo.stop()
    time.sleep(1)
    return output_list

标签: pythonimageopencvpython-imaging-library

解决方案


推荐阅读