OpenCV图像处理---RGB与BGR相互转化

方法1 cv2.cvtColor(image, cv2.COLOR_BGR2RGB || cv2.COLOR_RGB2BGR)

import cv2
frame = cv2.imread("test.jpg")
RGBFrame = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)
BGRFrame = cv2.cvtColor(RGBFrame, cv2.COLOR_RGB2BGR)

方法2 numpy

# BGR to RGB
rgb = bgr[...,::-1]

# RGB to BGR   0->2 1->0 2->1
gbr = rgb[...,[2,0,1]]

你可能感兴趣的:(OpenCV)