-
Notifications
You must be signed in to change notification settings - Fork 4
/
example.py
39 lines (31 loc) · 1.04 KB
/
example.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
"""Example code for using FlirExtractor
To run this, first install exiftool.
Follow your OS's instructions.
Next, install this library. You can either use pip or poetry (recommended).
Finally, run this script, with
```bash
# if you used pip
python3 scripts/example.py
# if you used poetry
poetry run python3 scripts/example.py
```
"""
# load the thermal data
from flirextractor import FlirExtractor
with FlirExtractor() as extractor:
thermal_data = extractor.get_thermal("tests/IR_2412.jpg")
# save the thermal data as a csv
import numpy as np
np.savetxt("example.csv", thermal_data, delimiter=",")
# open the thermal data as an image
from PIL import Image
from PIL.ImageOps import autocontrast, colorize
thermal_image = Image.fromarray(thermal_data)
thermal_image.show() # warning, might be quite dark
# use matplotlib to colorize the image
# Make sure you install matplotlib first
import matplotlib.pyplot as plt
plt.matshow(thermal_data)
colorbar = plt.colorbar()
colorbar.set_label("Temperature in Degrees Celcius")
plt.savefig("example.png")