Skip to content

Commit d2c8116

Browse files
authored
Merge pull request #3 from LolloCappo/master
Add SFMOV package for reading infrared data from FLIR Cameras
2 parents 61a3426 + ab35e3f commit d2c8116

File tree

5 files changed

+75
-0
lines changed

5 files changed

+75
-0
lines changed

docs/source/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ The ``io`` module is imported as follows:
2323
uff
2424
lvm
2525
mraw
26+
sfmov
2627

2728

2829
.. _GitHub: https://github.com/sdypy/sdypy-io

docs/source/sfmov.rst

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
SFMOV file format
2+
=================
3+
4+
FLIR SFMOV File Reader.
5+
6+
The ``sfmov`` module provides a direct link to the `pysfmov <https://github.com/LolloCappo/pysfmov>`_ package.
7+
8+
A simple example:
9+
10+
.. code-block:: python
11+
12+
# Import the module
13+
import pysfmov
14+
15+
# Set the path and the filename
16+
filename = './data/rec.sfmov'
17+
18+
# Get data from sfmov file
19+
data = pysfmov.get_data(filename)
20+
21+
# Get meta data from sfmov file
22+
meta_data = pysfmov.get_meta_data(filename)
23+
24+
For reference, see the `pyMRAW <https://github.com/LolloCappo/pysfmov>`_.

sdypy/io/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@
77
import pyuff as uff
88
import lvm_read as lvm
99
import pyMRAW as mraw
10+
from sfmov import sfmovcd

sdypy/io/sfmov/__init__.py

Whitespace-only changes.

sdypy/io/sfmov/sfmov.py

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
import numpy as np
2+
3+
def get_meta_data(filename):
4+
"""
5+
Function to open sfmov image sequences (exported from FLIR ResearchIR) and obtain metadata
6+
7+
Arguments:
8+
filename {str} -- path to the file
9+
10+
Returns:
11+
dict -- a dictionary of metadata
12+
"""
13+
with open(filename, 'rt', errors='ignore') as f:
14+
meta = {}
15+
for line in f:
16+
if line[:11] == 'saf_padding':
17+
break
18+
a = line[:-1].split(' ')
19+
meta[a[0]] = a[1]
20+
21+
int_values = ['xPixls', 'yPixls', 'NumDPs']
22+
23+
for i in int_values:
24+
meta[i] = int(meta[i])
25+
26+
return meta
27+
28+
29+
def get_data(filename):
30+
"""
31+
Function to open sfmov image sequences (exported from FLIR ResearchIR) and obtain raw data
32+
33+
Arguments:
34+
filename {str} -- path to the file
35+
36+
Returns:
37+
data -- raw data
38+
"""
39+
meta = get_meta_data(filename=filename)
40+
f = open(filename,'rb')
41+
f.seek(f.read().find(b'DATA')+6)
42+
43+
if meta['DaType'] == 'Flt32':
44+
ty = np.float32
45+
else:
46+
ty = np.uint16
47+
48+
data = np.fromfile(f, dtype=ty).reshape(-1, meta['yPixls'], meta['xPixls'])
49+
return data

0 commit comments

Comments
 (0)