import os | |
import cv2 | |
def process_directory(directory, output_file): | |
for root, dirs, files in os.walk(directory): | |
if not dirs: | |
# ๋ ์ด์ ํ์ ๋๋ ํ ๋ฆฌ๊ฐ ์๋ ๊ฒฝ์ฐ | |
print("Directory:", root) | |
# ์ด๋ฏธ์ง ํ์ผ ๊ฒฝ๋ก ๊ฒ์ฌ | |
image_found = False | |
for filename in files: | |
if filename in ["im1.png","im1.jpg"]: | |
image_found = True | |
image_path = os.path.join(root, filename) | |
# ์ด๋ฏธ์ง ์ฝ๊ธฐ | |
image = cv2.imread(image_path)[:, :, ::-1] | |
if image is not None: | |
print("Image:", image_path) | |
# ์ด๋ฏธ์ง๋ฅผ ์ฐพ์ง ๋ชปํ ๊ฒฝ์ฐ ๊ฒฝ๋ก๋ฅผ ํ์ผ์ ์ฐ๊ธฐ | |
if not image_found: | |
with open(output_file, "a") as f: | |
f.write(root + "\n") | |
if __name__ == "__main__": | |
# ๋๋ ํ ๋ฆฌ ๊ฒฝ๋ก ์ง์ | |
start_directory = "../../ins4/Triplet_250p_new/sequences" | |
# ๊ฒฐ๊ณผ๋ฅผ ์ ์ฅํ ํ ์คํธ ํ์ผ ๊ฒฝ๋ก ์ง์ | |
output_file = "missing_images.txt" | |
# ํ ์คํธ ํ์ผ ์ด๊ธฐํ | |
open(output_file, "w").close() | |
# ์์ ๋๋ ํ ๋ฆฌ์์ ์ํ ์์ | |
process_directory(start_directory, output_file) | |