opencv的转换方法调用如下,但是要求输入的图像的长和宽一定要是偶数的,否则报错!
bgr = cv2.cvtColor(Yv12, cv2.COLOR_YUV2BGR_YV12)
实验结果如下:
img = cv2.imread(path) copy_img=img.copy() Y_img = cv2.cvtColor(img, cv2.COLOR_BGR2YCrCb) Yv12 = cv2.cvtColor(copy_img, cv2.COLOR_BGR2YUV_YV12) yv12img = cv2.cvtColor(Yv12, cv2.COLOR_YUV2BGR_YV12) cv2.imshow("original",img) cv2.imshow('YV12',Yv12) cv2.imshow('BGR',yv12img) cv2.waitKey(0)