Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AssertionError: Unable to attribute image width/height for higher thermal image resolutions (1280x1024) #4

Open
ChilledFerrum opened this issue Mar 27, 2024 · 3 comments

Comments

@ChilledFerrum
Copy link

ChilledFerrum commented Mar 27, 2024

As the title describes.
I am unable to modify the image_width image_height attributes to higher resolutions to match UHR (Ultra High Resolution).
The M30T model contains a UHR option that produces thermal images up to 1280x1024 (WidthxHeight).

image

The expected result should be a matrix containing the temperature values with the correct shape.
In the above case where the image resolution is 1280x1024 the shape of the temperatures matrix should be 1280x1024

Latest version March 27.
Fails at line 843

@SanNianYiSi
Copy link
Owner

this issue has also troubled me.
it seems that when parsing M30T, a fixed size of 640x512 should be used instead of the 1280x1024 resolution of the jpeg file itself.
you can try the following code instead of directly calling parse_dirp2

import numpy as np
from thermal_parser import Thermal

thermal = Thermal(dtype=np.float32)
temperature = thermal.parse(filepath_image='images/DJI_H20T.jpg')
assert isinstance(temperature, np.ndarray)

@ChilledFerrum
Copy link
Author

ChilledFerrum commented Mar 28, 2024

In that case, the meta data reader fails at a point where some of the metadata contains added characters to its string.
E.g. 5.0 m instead of 5.0 resulting in a conversion error
ValueError: could not convert string to float: '5.0 m'

This I resolved in the version March 27 by simply using the first split value of the meta_data dictionary. This however, is prompted to create issues in latter versions or future.
lines 620 - 627

for key in ['Image Height', 'Image Width']:
    assert key in meta_json, 'The `{}` field is missing'.format(key)

kwargs = {}
for name, key in [('object_distance', 'Object Distance'),
                ('relative_humidity', 'Relative Humidity'),
                ('emissivity', 'Emissivity'),
                ('reflected_apparent_temperature', 'Reflection')]:
    if key in meta_json:
        value_str = meta_json[key].split()[0]
        try:
            kwargs[name] = float(value_str)
        except ValueError:
            print(f"Error converting value for {key}: {value_str} is not a valid float.")

@ChilledFerrum
Copy link
Author

Hello, has this issue been resolved?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants