Nervengift / read_thermal.py

A small tool/lib to read temperatures and original photos from FLIR® thermal camera images.
Creative Commons Zero v1.0 Universal
119 stars 69 forks source link

I can't extract the Thermal Image from JPG #18

Open WagnerDeQueiroz opened 1 year ago

WagnerDeQueiroz commented 1 year ago

Hello, I made this and got this error:

import flir_image_extractor
>>> fir = flir_image_extractor.FlirImageExtractor()
>>> fir.process_image('FLIR0421.jpg')
Warning: [minor] Possibly incorrect maker notes offsets (fix by -42?) - FLIR0421.jpg
Warning: [minor] Possibly incorrect maker notes offsets (fix by -42?) - FLIR0421.jpg
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "flir_image_extractor.py", line 66, in process_image
    self.thermal_image_np = self.extract_thermal_image()
  File "flir_image_extractor.py", line 136, in extract_thermal_image
    thermal_img = Image.open(thermal_img_stream)
  File "/usr/lib/python3/dist-packages/PIL/Image.py", line 3008, in open
    raise UnidentifiedImageError(
PIL.UnidentifiedImageError: cannot identify image file <_io.BytesIO object at 0x7fd124880d10>

and I cannot plot or export to CSV any data, look:

fir.export_thermal_to_csv('file.csv')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "flir_image_extractor.py", line 270, in export_thermal_to_csv
    x, y = e[0]
ValueError: not enough values to unpack (expected 2, got 0)

and plot...

>>> fir.plot()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/wagner/Downloads/flir_image_extractor.py", line 228, in plot
    plt.imshow(thermal_np, cmap='hot')
  File "/home/wagner/.local/lib/python3.10/site-packages/matplotlib/pyplot.py", line 2695, in imshow
    __ret = gca().imshow(
  File "/home/wagner/.local/lib/python3.10/site-packages/matplotlib/__init__.py", line 1442, in inner
    return func(ax, *map(sanitize_sequence, args), **kwargs)
  File "/home/wagner/.local/lib/python3.10/site-packages/matplotlib/axes/_axes.py", line 5665, in imshow
    im.set_data(X)
  File "/home/wagner/.local/lib/python3.10/site-packages/matplotlib/image.py", line 701, in set_data
    raise TypeError("Image data of dtype {} cannot be converted to "
TypeError: Image data of dtype object cannot be converted to float

here one of my files... FLIR0421

eapolo commented 2 months ago

Hey man. It's weird I'm using this library and the code is working perfectly!