detecttechnologies / thermal_base

Decoding and common processing for thermographs / thermograms. Currently supports FLIR's TIFF and PNG encoded metadata, and DJI-encoded metadata
MIT License
54 stars 9 forks source link

[Errno 2] No such file or directory: 'output.raw' #8

Closed bksrocks closed 2 years ago

bksrocks commented 2 years ago

Hi, I am trying to use the library on some dji captured images but it's returning me this error:

      1 from thermal_base import ThermalImage
      2 
----> 3 image = ThermalImage(image_path=dji_img_sample, camera_manufacturer="dji")
      4 thermal_np = image.thermal_np           # The temperature matrix as a np array
      5 raw_sensor_np = image.raw_sensor_np     # The raw thermal sensor excitation values as a np array

~\Anaconda3\lib\site-packages\thermal_base\thermal_base.py in __init__(self, image_path, camera_manufacturer, color_map, thermal_np)
     42             self.thermal_np, self.raw_sensor_np, self.meta = self.extract_temperatures_flir()
     43         elif camera_manufacturer.lower() == "dji":
---> 44             self.thermal_np, self.raw_sensor_np, self.meta = self.extract_temperatures_dji()
     45         elif camera_manufacturer.lower() == "pass":
     46             pass

~\Anaconda3\lib\site-packages\thermal_base\thermal_base.py in extract_temperatures_dji(self)
    156         sp.run([str(Path(path_executable, dji_binary)), "-s", f"{self.image_path}", "-a", "extract"], \
    157             universal_newlines=True, stdout=sp.DEVNULL, stderr=sp.STDOUT)  
--> 158         data = Path('output.raw').read_bytes()
    159         # Read the contents of the generated output.raw file.
    160         img = Image.frombytes("I;16L", (640, 512), data)

~\Anaconda3\lib\pathlib.py in read_bytes(self)
   1257         Open the file in bytes mode, read it, and close the file.
   1258         """
-> 1259         with self.open(mode='rb') as f:
   1260             return f.read()
   1261 

~\Anaconda3\lib\pathlib.py in open(self, mode, buffering, encoding, errors, newline)
   1250         the built-in open() function does.
   1251         """
-> 1252         return io.open(self, mode, buffering, encoding, errors, newline,
   1253                        opener=self._opener)
   1254 

~\Anaconda3\lib\pathlib.py in _opener(self, name, flags, mode)
   1118     def _opener(self, name, flags, mode=0o666):
   1119         # A stub for the opener argument to built-in open()
-> 1120         return self._accessor.open(self, flags, mode)
   1121 
   1122     def _raw_open(self, flags, mode=0o777):

FileNotFoundError: [Errno 2] No such file or directory: 'output.raw'

Any thoughts?

Thank you.

rsnk96 commented 2 years ago

@agarwalkunal12 - can you check this out?

agarwalkunal12 commented 2 years ago

Hey @bksrocks , Could you please provide the following details:

  1. What OS were you running this on and the architecture? (Windows/Linux and 32/64 bit?)

  2. Can you verify that you had your internet connection working fine at the time of running the program? The DJI executables are downloaded the first time the program is run which create a file called 'output.raw'. If at the time of running the internet wasn't connected, it wouldn't have downloaded those executable files.

  3. Also, those executables are downloaded as a zip file called 'dji_executables.zip' in the same location as your python script in which you import the library. Can you confirm once that the location where your python file exists contains a zip file called 'dji_executables.zip' or a folder by the name 'dji_executables'?

Thank You

bksrocks commented 2 years ago

Hi @agarwalkunal12 , thank you for responding!

1 - Windows 10 Enterprise, 64 bit

2 - Internet connection is fine. Is the .raw file downloaded to the folder in which I have my Jupiter notebook?

3 - Dji executables are in the folder.

agarwalkunal12 commented 2 years ago

Hi @bksrocks , thanks a lot for the information.

A couple of other users were getting a similar error and we figured that they were using the Mavic 2 Enterprise Advanced camera to capture the thermal images and the SDK didn't support that.

We have pushed a code update and it is supporting the Mavic 2 Enterprise Advanced cameras now too. Request you to refresh your codebase with the updated version and try and test it out. Let me know if the error still persists.

And if it does persist, request you to kindly upload the captured images that throw the error if they continue to do so.

Thanks Kunal

bksrocks commented 2 years ago

I bet that was the problem. It seems to be working now! Thank you very much!