From 63f67dbe6ff0032d4250c9192ee677225262428f Mon Sep 17 00:00:00 2001 From: Andreas Demmelbauer Date: Thu, 23 Sep 2021 13:57:33 +0200 Subject: [PATCH] activate, add pre-built tiles counter --- convert-svg-to-geotiff.py | 33 ++++++++++++++++++++------------- 1 file changed, 20 insertions(+), 13 deletions(-) diff --git a/convert-svg-to-geotiff.py b/convert-svg-to-geotiff.py index d18a889..9469c8d 100644 --- a/convert-svg-to-geotiff.py +++ b/convert-svg-to-geotiff.py @@ -56,17 +56,23 @@ def make_thermalpng_tiles(): Path(os.path.join(INPUT_DIR, THERMALPNG_DIR)).mkdir(parents=True, exist_ok=True) png_output_dir = os.path.join(INPUT_DIR, THERMALPNG_DIR) + done_files_count = 0 for root_path, directories, file in os.walk(os.path.join(dirname, INPUT_DIR)): for file in file: if(file.endswith(".jpg")): - print(' Processing ' + file) - full_filepath = os.path.join(root_path, file) - flir = flirimageextractor.FlirImageExtractor() - flir.process_image(full_filepath) - thermal_img_np = flir.thermal_image_np - multiplied_image = cv2.multiply(thermal_img_np, 1000) output_file_path = os.path.join(png_output_dir, file + '.thermal.png') - cv2.imwrite(output_file_path, multiplied_image.astype(np.uint16)) + if os.path.isfile(output_file_path): + done_files_count = done_files_count+1 + else: + print(' Processing ' + file) + full_filepath = os.path.join(root_path, file) + flir = flirimageextractor.FlirImageExtractor() + flir.process_image(full_filepath) + thermal_img_np = flir.thermal_image_np + multiplied_image = cv2.multiply(thermal_img_np, 1000) + cv2.imwrite(output_file_path, multiplied_image.astype(np.uint16)) + if done_files_count != 0: + print('Using {} pre-built tiles.'.format(str(done_files_count))) @@ -87,7 +93,8 @@ def make_thermalpng_svg(): tile_elements = root.xpath('//*[@class="thermal_image"]') linkattrib ='{http://www.w3.org/1999/xlink}href' for tile in tile_elements: - tile.attrib[linkattrib] = os.path.join(THERMALPNG_DIR, tile.attrib[linkattrib] + '.thermal.png') + new_file_path = os.path.join(THERMALPNG_DIR, tile.attrib[linkattrib] + '.thermal.png') + tile.attrib[linkattrib] = new_file_path # Post Production # tile.attrib["mask"] = 'url(#tilefademask)' # tile.attrib["style"] = 'opacity:.7' @@ -368,11 +375,11 @@ def make_geotiff_image(): -# make_thermalpng_tiles() -# make_thermalpng_svg() -# make_thermalpng() -# make_geotiff_image() +make_thermalpng_tiles() +make_thermalpng_svg() +make_thermalpng() +make_geotiff_image() # # Helpers for debugging -verify_coordinate_matching() +# verify_coordinate_matching() # make_vector_shapefile()