run the following to do the conversions
def yuv420p_from_cv(): bgr_img = cv.imread(r"bgr.jpg") print(bgr_img.shape) yuv420p_img = cv.cvtColor(bgr_img, cv.COLOR_BGR2YUV_I420) print(yuv420p_img.shape) np.save("cv_yuv420p", yuv420p_img) # new_bgr = cv.cvtColor(yuv420p_img, cv.COLOR_YUV420P2BGR) cv.imwrite("new_bgr.jpg", new_bgr) print(new_bgr.shape) cv.imshow("adsd", new_bgr) cv.waitKey()
the new_bgr looked like a rgb image, it was a wrong image with r and b misplacement.
the left one is the bgr_img, the original one, and the right one is the new_bgr.
but if i converted the yuv420p_img to rgb, like
new_bgr = cv.cvtColor(yuv420p_img, cv.COLOR_YUV420P2RGB)
then the new_bgr looked fine, it looked exact like the bgr_img.