nervengift / read_thermal.py Goto Github PK
View Code? Open in Web Editor NEWA small tool/lib to read temperatures and original photos from FLIR® thermal camera images.
License: Creative Commons Zero v1.0 Universal
A small tool/lib to read temperatures and original photos from FLIR® thermal camera images.
License: Creative Commons Zero v1.0 Universal
Hi,
I'm using this code to process some images from the FLIR i7 camera. I know that theoretically the library doesn't support that camera, but after some handwork with exiftool and images from the camera, I realized that I could use it for extract the thermal_np_array which is enough for me.
Even though I made it work properly for a lot of images, I'm getting a 'math domain error' in the raw2temp module in some cases. Do you know why is this happening? All metadata that raw2temp needs are available so I guess that this shouldn't be happening.
Here you have some examples of the 'troublemakers' :)
Thanks in advance. @Nervengift
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
whenever I run the cod on one of my flir one thermal images it produces an array of size 640,480, however when I test the example image it produces 320, 230 image
I am running into an issue with this script when I try to run it on all images within a folder. I initially checked to see that the flir encoded data was in the metadata with exiftool. It is present. When running the code, though, on ironbow filter images I get the following error:
Traceback (most recent call last):
File ".\u_value_module.py", line 438, in
export_temperatures()
File ".\u_value_module.py", line 434, in export_temperatures
flir.process_image(images)
File "C:\Users\sai.peri\Documents\u_value_module\flir_image_extractor.py", line 62, in process_image
self.rgb_image_np = self.extract_embedded_image()
File "C:\Users\sai.peri\Documents\u_value_module\flir_image_extractor.py", line 102, in extract_embedded_image
visual_img = Image.open(visual_img_stream)
File "C:\Users\sai.peri\AppData\Local\Programs\Python\Python37-32\lib\site-packages\PIL\Image.py", line 2822, in open
raise IOError("cannot identify image file %r" % (filename if filename else fp))
OSError: cannot identify image file <_io.BytesIO object at 0x038543C0>
Not sure how to fix it. It occurs at the visual_img = Image.open line.
Can this library work with Flir Lepton 3.5?
Hello!
I am struggling to use the software for some reason. I have exiftool installed and many of the dependencies. However, when I execute the program, I do not see a visual image output alongside the thermal image. It is just thermal image alone. I am not sure what I am doing wrong, it seems fairly straight-forward. If you have any tips for this let me know pls!
I am using ubuntu 20.04 and python3
Thank you!
Traceback (most recent call last):
File "read-thermal.py", line 101, in
thermal_np = extract_thermal(imgpath)
File "read-thermal.py", line 68, in extract_thermal
meta = json.loads(meta_json)[0]
File "/usr/lib/python2.7/json/init.py", line 339, in loads
return _default_decoder.decode(s)
File "/usr/lib/python2.7/json/decoder.py", line 364, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "/usr/lib/python2.7/json/decoder.py", line 382, in raw_decode
raise ValueError("No JSON object could be decoded")
ValueError: No JSON object could be decoded
ValueError: Input file does not exist or this user don't have permission on this file
ValueError: Input file does not exist or this user don't have permission on this file
Thanks for this tool. I would have hoped that it also has an option to extract the exif header information of thermal FLIR images. I have tried other option (e.g. pillow) but the FLIR header seems always different from what I get by using the exiftools command line options. I haven´t managed to run exiftools from Python. Hope you can help?
Cheers,
Rene
Hi!
Thank you for your works which I could extract thermal info numpy from flir image with 👍
Actually I need to analyze flir video. How can I extract meta data from flir video (.MP4) as you extract meta data from jpg image?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.