LJMUAstroecology / flirpy

Python library to interact with FLIR camera cores
Other
191 stars 54 forks source link

How to read a fff file without TypeError? #45

Closed Ikhwansong closed 3 years ago

Ikhwansong commented 3 years ago

Hi thanks for your devotion to this wonderful library flirpy

I ran the code split_seqs to convert seq file to many fffs. After processing, when i read one fff file with the function Fff that is imported by from flirpy.io.fff import Fff.

My code from flirpy.io.fff import Fff a = Fff('./test/frame_000000.fff', height=480, width=640)

Below TypeError occurs TypeError: init() got an unexpected keyword argument 'height'

What should i do?

jveitchmichaelis commented 3 years ago

In the newer versions of the code height/width were removed, so just try a = Fff("frame_000000.fff") - flirpy should be able to determine the image shape directly now.

The reason this isn't live on PyPi is that there are still some issues regarding endianness that I haven't fixed yet, and some other SEQ files will break until that's sorted. I think the version online that relies on Exiftool is a bit more stable.

Ikhwansong commented 3 years ago

Thanks for the rapid answer.

I followed your advise, but i suffered another Error.

My code from flirpy.io.fff import Fff a = Fff('./test/frame_000000.fff')

Traceback (most recent call last): File "flir_imshow_test.py", line 11, in a = Fff('./test/frame_000000.fff') File "/home/ihsong/Documents/project/flirpy-master/flirpy/io/fff.py", line 28, in init self._find_data_offset() File "/home/ihsong/Documents/project/flirpy-master/flirpy/io/fff.py", line 115, in _find_data_offset res = s.unpack_from(self.data, record_offset) struct.error: unpack_from requires a buffer of at least 32 bytes

Help me...

jveitchmichaelis commented 3 years ago

Yes, this is partially the reason why this isn't on PyPI yet. Can you try with a version of flirpy installed using pip?

Ikhwansong commented 3 years ago

I made two anaconda env(the one run in the clone directly, the other install the flirpy by pip) I tried to run the same code in the other environment (in which, flirpy was installed by pip) then i met a new Error message.

My code from flirpy.io.fff import Fff a = Fff('./test/frame_000000.fff')

Traceback (most recent call last): File "/home/ihsong/Documents/project/flirpy-master/flir_imshow_test.py", line 11, in a = Fff('/home/ihsong/Documents/proejct/flirpy-master/yp/raw/frame_000001.fff') File "/home/ihsong/Documents/project/flirpy-master/flirpy/io/fff.py", line 28, in init self._find_data_offset() File "/home/ihsong/Documents/project/flirpy-master/flirpy/io/fff.py", line 115, in _find_data_offset res = s.unpack_from(self.data, record_offset) struct.error: unpack_from requires a buffer of at least 1073741856 bytes for unpacking 32 bytes at offset 1073741824 (actual buffer size is 617036)

For reference, my flir hardware spec following is that T620, 640 x 480

jveitchmichaelis commented 3 years ago

Hmm ok can you try with Exiftool directly? This is a known problem for some cameras. Flirpy looks for an offset in the header but we need to make sure we get the endianness right otherwise you get the problem above.

Are you sure the traceback above is from your conda env? It's calling code from the flirpy-master repository (looks like the same struct error, but more information printed? If you're calling your script from the repository while your env is active, it may be using the repo version, not the system-wide install).

e.g. exiftool ./test/frame_000000.fff -flir:all -H -G

Ikhwansong commented 3 years ago

Thanks for your help. Actually, there was my one mistake that after installing by the pip, i didn't run the code at the external directory(i.e., i ran the code in the clone)

So, i moved myself at the external directory and executed the same code, then it worked! If i meet another problem, i will be back to question.

Thanks again!