3

Video Capture Frame Colors Are Wrong | Snakey Code

 2 years ago
source link: https://snakeycode.wordpress.com/2021/07/24/video-capture-frame-colors-are-wrong/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Standard

Video Capture Frame Colors Are Wrong

I wanted to grab some images from a .mov video taken with my iPhone and process them with Pillow. There are lots of tutorials on how to use Open CV to grab the images. However, when you try to view those images using Pillow, the colors have been transformed in some odd way. I my case, the correct image was very red and the frame capture image was very blue.

I turns out that Open CV stores the images as BGR, while Pillow uses RGB. Here is how to fix this:

rgb_frame = cv2.cvtColor(bgr_frame, cv2.COLOR_BGR2RGB)

# Load as a pillow Image
image = Image.fromarray(rgb_frame)
image.show()
Advertisements
Report this ad

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK