-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Change the path to save temperature bound json file
- Loading branch information
1 parent
86cb0cf
commit a5bf7b6
Showing
7 changed files
with
137 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,7 @@ name: Python application | |
on: | ||
workflow_dispatch: | ||
pull_request: | ||
types: [ labeled ] | ||
types: [labeled] | ||
|
||
permissions: | ||
contents: read | ||
|
@@ -15,19 +15,26 @@ jobs: | |
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/setup-python@v5 | ||
with: | ||
python-version: "3.10" | ||
cache: 'pip' | ||
- name: Install dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install flake8 | ||
- name: Lint with flake8 | ||
run: | | ||
flake8 . --count --show-source --statistics | ||
- run: pip install -e . | ||
- name: Test with unittest | ||
run: | | ||
python -m unittest discover tests | ||
- uses: actions/checkout@v4 | ||
- uses: actions/setup-python@v5 | ||
with: | ||
python-version: "3.10" | ||
cache: "pip" | ||
- name: Install dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install flake8 | ||
- name: Clone FlirImageExtractor | ||
uses: ITVRoC/[email protected] | ||
with: | ||
repository: "FlirImageExtractor" | ||
branch: "main" | ||
fetch-depth: 1 | ||
owner: "ITVRoC" | ||
- name: Lint with flake8 | ||
run: | | ||
flake8 . --count --show-source --statistics | ||
- run: pip install -e . | ||
- name: Test with unittest | ||
run: | | ||
python -m unittest discover tests |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
import shutil | ||
import unittest | ||
from pathlib import Path | ||
|
||
from thermo_scenes.flir_thermal_images.custom_flir import CustomFlir | ||
|
||
|
||
class TestThermalConversion(unittest.TestCase): | ||
def test_process_thermal(self) -> None: | ||
""" | ||
Test of extracting RGB, thermal and csv files from the given msx images. | ||
2 msx images will generate 2 RGB PNG files, 2 thermal PNG files, 2 csv files | ||
and 1 temperature_bound.json file. | ||
""" | ||
msx_path = Path("tests/data/process_thermal/msx") | ||
output_path = Path("tests/data/process_thermal/output") | ||
|
||
shutil.rmtree(output_path) | ||
output_path.mkdir(exist_ok=True, parents=True) | ||
|
||
CustomFlir(path_to_msx_images=msx_path, path_to_output_folder=output_path) | ||
|
||
json_count = 0 | ||
PNG_count = 0 | ||
csv_count = 0 | ||
|
||
for folder in output_path.iterdir(): | ||
if folder.suffix == ".json": | ||
json_count += 1 | ||
continue | ||
for files in folder.iterdir(): | ||
if files.suffix == ".PNG": | ||
PNG_count += 1 | ||
elif files.suffix == ".csv": | ||
csv_count += 1 | ||
|
||
self.assertEqual(json_count, 1, "The number of the JSON file is not correct!") | ||
self.assertEqual(PNG_count, 4, "The number of the PNG files is not correct!") | ||
self.assertEqual(csv_count, 2, "The number of the CSV files is not correct!") | ||
|
||
def test_name_consistency(self) -> None: | ||
""" | ||
Test the name consistency of extracting RGB, thermal and csv files from the | ||
given msx images. | ||
RGB image, thermal image and csv file should have the same stem as the extracted | ||
msx image. | ||
""" | ||
msx_path = Path("tests/data/process_thermal/msx") | ||
output_path = Path("tests/data/process_thermal/output") | ||
|
||
shutil.rmtree(output_path) | ||
output_path.mkdir(exist_ok=True, parents=True) | ||
|
||
CustomFlir(path_to_msx_images=msx_path, path_to_output_folder=output_path) | ||
|
||
for folder in output_path.iterdir(): | ||
if folder.suffix == ".json": | ||
continue | ||
namelist = [file.stem for file in msx_path.iterdir()] | ||
for files in folder.iterdir(): | ||
if files.stem in namelist: | ||
namelist.remove(files.stem) | ||
self.assertEqual( | ||
len(namelist), | ||
0, | ||
"Names of the extracted files are not consistent with the " | ||
+ "given msx images!", | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters