0

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?

Mohamed Thasin ah
  • 10,754
  • 11
  • 52
  • 111
  • I'm speculating considering your example code but, given that you are trying to load from .mp4, the raw thermal data is already lost. FLIR's RAW format would be a .seq (sequence file). If it is an .mp4 you're working from it is now a simple video file as any other. – George Kerwood May 14 '20 at 15:50

1 Answers1

0

Just export the movie from the Flir Research Software as a .wmv file then it will work just fine.

import cv2
vidcap = cv2.VideoCapture('3.wmv')
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
bantandor
  • 267
  • 1
  • 15