I am trying to write jpg's to a video using cv2. I define a mock image as such:
fake_image = np.array([[[122, 131, 140]] * 416] * 416).astype(np.uint8)
Next, I write this to a video using:
out = cv2.VideoWriter('mock_video.mp4',cv2.VideoWriter_fourcc(*'DIVX'), 1, (416, 416))
out.write(fake_image)
out.release()
Then, I try to read the frames of my video:
vid = cv2.VideoCapture('mock_video.mp4')
return_value, frame = vid.read()
And now the rgb values have changed! Rather than being [122, 131, 140]
, they are now [118, 129, 137]
!
Why is this happening and can I stop it from happening?
Edit: yes i know cv2 uses BGR, that is not what is going on (it is not the case that the order of channels is reversed)