|
| 1 | +# data_folder_Structure |
| 2 | +# ├── mask |
| 3 | +# │ ├── 0000000000.png |
| 4 | +# │ ├── 0000000001.png |
| 5 | +# │ ├── ... |
| 6 | +# ├── other |
| 7 | +# │ ├── 0000000000.png |
| 8 | +# │ ├── 0000000001.png |
| 9 | +# │ ├── ... |
| 10 | +# ├── output |
| 11 | + |
| 12 | +from pathlib import Path |
| 13 | +import os |
| 14 | +import tkinter as tk |
| 15 | +from tkinter import filedialog |
| 16 | +from datetime import datetime |
| 17 | +import calculate_zoom as calz |
| 18 | +import noiseReduction as nr |
| 19 | + |
| 20 | +def reconstrucionFromImages(pathstring): |
| 21 | + # pathstring = "/media/xujx/MyPassport/sfm-pro/20221028-1-T154-0/" |
| 22 | + |
| 23 | + pathstring += "/" |
| 24 | + mask_dir_string = os.path.join(pathstring, 'mask') |
| 25 | + other_dir_string = os.path.join(pathstring, 'other') |
| 26 | + path_outputs_string = os.path.join(pathstring, 'output/') |
| 27 | + |
| 28 | + # openMVS |
| 29 | + converter = "cd /usr/local/bin/OpenMVS" |
| 30 | + converter = converter + "\n" |
| 31 | + |
| 32 | + converter = converter + "./InterfaceCOLMAP -i " |
| 33 | + converter = converter + path_outputs_string |
| 34 | + converter = converter + " -o " |
| 35 | + converter = converter + path_outputs_string + "scene_panicle.mvs" |
| 36 | + converter = converter + " --image-folder " |
| 37 | + converter = converter + mask_dir_string |
| 38 | + converter = converter + "\n" |
| 39 | + |
| 40 | + converter = converter + "./DensifyPointCloud -w " |
| 41 | + converter = converter + path_outputs_string |
| 42 | + converter = converter + " -i scene_panicle.mvs -o panicle.mvs --remove-dmaps 1" |
| 43 | + converter = converter + "\n" |
| 44 | + |
| 45 | + converter = converter + "./InterfaceCOLMAP -i " |
| 46 | + converter = converter + path_outputs_string |
| 47 | + converter = converter + " -o " |
| 48 | + converter = converter + path_outputs_string + "scene_other.mvs" |
| 49 | + converter = converter + " --image-folder " |
| 50 | + converter = converter + other_dir_string |
| 51 | + converter = converter + "\n" |
| 52 | + |
| 53 | + converter = converter + "./DensifyPointCloud -w " |
| 54 | + converter = converter + path_outputs_string |
| 55 | + converter = converter + " -i scene_other.mvs -o other.mvs --remove-dmaps 1" |
| 56 | + converter = converter + "\n" |
| 57 | + |
| 58 | + os.system(converter) |
| 59 | + |
| 60 | + return 0 |
| 61 | + |
| 62 | +def process_folders(root_path, folder): |
| 63 | + folder_path = os.path.join(root_path, folder) |
| 64 | + video_folder_path = folder_path |
| 65 | + images_output_path = os.path.join(folder_path, 'images') |
| 66 | + |
| 67 | + if os.path.exists(video_folder_path) and os.path.isdir(video_folder_path): |
| 68 | + # 创建images文件夹,如果不存在 |
| 69 | + if not os.path.exists(images_output_path): |
| 70 | + os.makedirs(images_output_path) |
| 71 | + for video_name in os.listdir(video_folder_path): |
| 72 | + video_file_path = os.path.join(video_folder_path, video_name) |
| 73 | + video_to_frames(video_file_path, images_output_path) |
| 74 | + |
| 75 | +def check_dense_scene_ply(folder_path): |
| 76 | + ply_file_path = os.path.join(folder_path, 'output', 'dense_scene.ply') |
| 77 | + return os.path.exists(ply_file_path) |
| 78 | + |
| 79 | +def traverse_folders(root_path): |
| 80 | + folders_to_exclude = [] |
| 81 | + # check |
| 82 | + for folder_name in os.listdir(root_path): |
| 83 | + folder_path = os.path.join(root_path, folder_name) |
| 84 | + if os.path.isdir(folder_path) and check_dense_scene_ply(folder_path): |
| 85 | + print(f"Excluding folder name: {folder_name}") |
| 86 | + folders_to_exclude.append(folder_name) |
| 87 | + |
| 88 | + filtered_folders = [folder_name for folder_name in os.listdir(root_path) if folder_name not in folders_to_exclude] |
| 89 | + return filtered_folders |
| 90 | + |
| 91 | +if __name__ == '__main__': |
| 92 | + |
| 93 | + path = '/your/path' |
| 94 | + reconstrucionFromImages(path) |
| 95 | + |
0 commit comments