i tried to extract a time frame of a video, and show it as image(JPEG). But unfortunately the displayed image using PIL.Image.fromarray() is bluer than it supposed to be. the tricky part is, when i save it first (using cv2.imwrite) and open that new file using PIL.Image.open(), the image has the right color.
I thought it has something to do with the RGB array composition, but then i checked it, and both array (direct from the frame and from the Image.open()) are exactly the same.
Is there anything i can do to show the right image without saving it as an external file beforehand?
Thank you.
def TimeFrame(file, tf):
capture = cv2.VideoCapture(file)
frameCount = int(capture.get(cv2.CAP_PROP_FRAME_COUNT))
capture.set(cv2.CAP_PROP_POS_FRAMES, tf)
_, frame = capture.read()
directTF = Image.fromarray(frame)
cv2.imwrite("12345678999.jpg", frame)
image = Image.open("12345678999.jpg")
note: file is the name of the video and tf is the certain timeframe that you want to extract the image from.