I have a IR camera video file. I want to extract this video into n-frames. I followed normal opencv method to extract frames from video. like below,
import cv2
vidcap = cv2.VideoCapture('3.mp4')
success,image = vidcap.read()
count = 0
while success:
cv2.imwrite("frame%d.jpg" % count, image) # save frame as JPEG file
success,image = vidcap.read()
print('Read a new frame: ', success)
count += 1
It extracts image as a normal image, instead of thermal image.
I found that using below code.
import flirimageextractor
from matplotlib import cm
from glob import glob
flir = flirimageextractor.FlirImageExtractor(palettes=[cm.jet, cm.bwr, cm.gist_ncar])
for file_ in glob("images/*.jpg"):
flir.process_image(file_)
flir.save_images()
flir.plot()
it throws KeyError: 'RawThermalImageType'
Full stack trace
Traceback (most recent call last): File "thermal_camera.py", line 8, in flir.process_image(file_) File "/usr/local/lib/python3.5/dist-packages/flirimageextractor/flirimageextractor.py", line 101, in process_image if self.get_image_type().upper().strip() == "TIFF": File "/usr/local/lib/python3.5/dist-packages/flirimageextractor/flirimageextractor.py", line 133, in get_image_type return json.loads(meta_json.decode())[0]["RawThermalImageType"] KeyError: 'RawThermalImageType'
But the above code works well for sample thermal images. Which means i am not extracting frame from the video as a proper frame.
How to extract frame from FLIR video without losing thermal(raw) information?