如何知道 OpenCV 中 read 函数返回的数组的每个元素是哪个颜色通道?

Jua*_*ini 1 python opencv

使用 OpenCV 与 Python 绑定,执行以下代码时:

import cv2


cap = cv2.VideoCapture('video.mp4')

while (cap.isOpened()):
    ret, frame = cap.read()
    # ...

# ...
Run Code Online (Sandbox Code Playgroud)

我如何知道frame[:, :, 0]frame[:, :, 1]和中的每个颜色通道是哪个颜色通道frame[:, :, 2]。我的意思是,RGB、RBG、GBR、GRB、BRG 还是 BGR?

非常感谢!

sga*_*zvi 5

BGR默认情况下,OpenCV 按通道顺序读取彩色图像。B、G和Rframe[:, :, 0]也是如此。frame[:, :, 1]frame[:, :, 2]