From 1e253f2b5b43685b927ce210696e5ceccf1a25a5 Mon Sep 17 00:00:00 2001 From: Flejk Date: Tue, 12 Nov 2024 16:20:03 +0100 Subject: [PATCH] removed searchOne --- symposium/searchOne.py | 46 ------------------------------------------ 1 file changed, 46 deletions(-) delete mode 100644 symposium/searchOne.py diff --git a/symposium/searchOne.py b/symposium/searchOne.py deleted file mode 100644 index 9fd4496..0000000 --- a/symposium/searchOne.py +++ /dev/null @@ -1,46 +0,0 @@ -import os -import imagehash -from PIL import Image -import shutil - -# Paths for your folders and Waldo image -input_folder = "images" # Folder with images to check for Waldo -output_folder = "found_waldo_images" # Folder to save images containing Waldo -waldo_image_path = "symposium/waldo_transparent.png" # Path to your Waldo image - -# Create output folder if it doesn't exist -os.makedirs(output_folder, exist_ok=True) - -# Load the Waldo image and compute its hash -waldo_image = Image.open(waldo_image_path) -waldo_hash = imagehash.phash(waldo_image) - -# Function to compare the hash of an image with Waldo's hash -def detect_waldo_in_image(image_path): - try: - # Open image - image = Image.open(image_path) - # Compute the hash of the current image - image_hash = imagehash.phash(image) - - # Compute the difference between the image hash and Waldo's hash - hash_diff = waldo_hash - image_hash - - # If the difference is small (threshold), we consider it a match - return hash_diff < 13 # You can adjust the threshold (10) based on your needs - except Exception as e: - print(f"Error processing {image_path}: {e}") - return False - -# Process each image in the input folder -for filename in os.listdir(input_folder): - if filename.lower().endswith(('.png', '.jpg', '.jpeg', '.bmp', '.tiff')): # Process common image formats - image_path = os.path.join(input_folder, filename) - - # Check if the image matches the Waldo pattern - if detect_waldo_in_image(image_path): - print(f"Found Waldo in {filename}, saving to {output_folder}") - # Copy the image to the output folder - shutil.copy(image_path, os.path.join(output_folder, filename)) - -print("Processing complete. Images with Waldo have been saved.")