Skip to content

Commit

Permalink
Change the path to save temperature bound json file
Browse files Browse the repository at this point in the history
  • Loading branch information
jiaruiyu99 committed Oct 30, 2024
1 parent 86cb0cf commit e00f6a1
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 15 deletions.
4 changes: 2 additions & 2 deletions thermo_scenes/docs/Collect_new_dataset.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,10 @@ sudo pip install numpy matplotlib pillow
### Extact raw data

To create the CSV files, rgb images, and the greyscale raw temperature images, run
the following command, with `<path_to_thermal>` the path to the MSX images, and `<path_to_output_thermal>`, `<path_to_csv>`, and `<path_to_rgb>` the paths where the temperature and rgb images, and csv files extracted will be saved.
the following command, with `<path_to_thermal>` the path to the MSX images, and `<path_to_output_folder>` the path where the temperature and rgb images, and csv files extracted will be saved.

```bash
thermoscenes_preprocess_thermal.py --path-to-thermal-images <path_to_thermal> --path-to-thermal-images-curated <path_to_output_thermal> --path-to-rgb <path_to_rgb> --path-to-csv-files <path_to_csv>
thermoscenes_preprocess_thermal.py --path-to-thermal-images <path_to_thermal> --path-to-output-folder <path_to_output_folder>
```

> If your MSX images are in more than one folder, do it for all folders, and make sure that the temperature are rescaled to the same range in the next step.
Expand Down
29 changes: 16 additions & 13 deletions thermo_scenes/scripts/preprocess_thermal.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,36 +8,39 @@

@dataclass
class Paths:
path_to_thermal_images: str
path_to_thermal_images: str = "/home/jiyu/LES-dorm2/msx_train"
"""Path to the thermal data extracted from Flir One App."""
path_to_thermal_images_curated: str
"""Path to the output thermal images created using raw thermal data."""
path_to_rgb: str
"""Path to the output rgb images"""
path_to_csv_files: str
"""Path to the output csv files of temperature values"""
path_to_txt: str = "temperature_bounds.json"
"""Path to the txt file with temperature bounds for the dataset"""
path_to_output_folder: str = "/home/jiyu/LES-dorm2/test"
"""Path to the output folder"""


def main() -> None:
paths = tyro.cli(Paths)
output_json_path = Path(paths.path_to_output_folder, "temperature_bounds.json")
output_rgb_folder = Path(paths.path_to_output_folder, "rgb")
output_thermal_folder = Path(paths.path_to_output_folder, "thermal")
output_csv_folder = Path(paths.path_to_output_folder, "csv")

output_rgb_folder.mkdir(parents=True, exist_ok=True)
output_thermal_folder.mkdir(parents=True, exist_ok=True)
output_csv_folder.mkdir(parents=True, exist_ok=True)

list_thermal = []
list_filenames = []
flir = CustomFlir()
for img_name in Path(paths.path_to_thermal_images).iterdir():
flir.process_image(Path(paths.path_to_thermal_images, img_name.name))
flir.export_thermal_to_csv(
Path(paths.path_to_csv_files, str(img_name.name).split(".")[0] + ".csv")
Path(output_csv_folder, str(img_name.name).split(".")[0] + ".csv")
)
flir.save_rgb_images(Path(paths.path_to_rgb))
flir.save_rgb_images(output_rgb_folder)
list_thermal.append(flir.get_thermal_np())
list_filenames.append(str(img_name.name))

flir.save_normalised_thermal_images(
paths.path_to_thermal_images_curated, paths.path_to_csv_files
str(output_thermal_folder), str(output_csv_folder)
)
flir.save_temperature_bounds(paths.path_to_txt)
flir.save_temperature_bounds(str(output_json_path))


if __name__ == "__main__":
Expand Down

0 comments on commit e00f6a1

Please sign in to comment.