Closed marcus858 closed 3 months ago
Thanks! I'd suggest benchmarking this against the implementation that's currently in the code (which does not use Exiftool). Unfortunately due to some variation in the SEQ header, you can't just search for the magic string - I did something very similar to your method for a while but users repeatedly raised issue that their files didn't load correctly. In the end I had to reverse engineer the header from Exiftool's code and that's what's currently in the library.
Note that you also need to load the calibration coefficients (which flirpy now does correctly - I hope), which your code doesn't handle at the moment. In the first implementation I would parse the first FFF subframe with Exiftool to get the metadata, but now we just read it directly.
A small optimisation - unless this is lazy: file_content.split(pat)
, it's hiding an O(N)
scan of the file. To avoid this, flirpy uses a regex which yields an iterator, so should be a bit kinder on memory.
But the general approach is the same - you find the byte offsets for each frame and the offset for the data within it. Once you've done that, you can read the data (with known size) in a big chunk.
You can look at the current FFF decoder here: https://github.com/LJMUAstroecology/flirpy/blob/main/src/flirpy/io/fff.py
I've discovered a method to convert FLIR .seq files into numpy arrays significantly faster than using exiftool. In my tests, this approach converted 900 frames to an array in approximately 0.5 seconds.
Here's the improved code:
I hope this can be of help to those working with FLIR .seq files. Feedback and improvements are welcome!