mirror of
https://github.com/andwati/image-sort.git
synced 2026-10-18 08:22:55 +00:00
@@ -173,3 +173,4 @@ pyrightconfig.json
|
||||
rejects/
|
||||
done/
|
||||
.vscode/
|
||||
image_sorter.log
|
||||
@@ -42,3 +42,4 @@ python cli.py --source <image folder path> --destination <pass folder> --rejects
|
||||
- Remove blurry images
|
||||
- Use multithreading to increase performance
|
||||
- Remove images with no meter readings
|
||||
- Progress functionality
|
||||
|
||||
@@ -2,6 +2,7 @@ import argparse
|
||||
from pathlib import Path
|
||||
import cv2
|
||||
from sorter.image_sorter import process_image
|
||||
from concurrent.futures import ThreadPoolExecutor
|
||||
|
||||
# CLI argument parsing
|
||||
def parse_arguments():
|
||||
@@ -35,12 +36,14 @@ def main():
|
||||
image_paths = list(input_folder.glob("*.jpg")) + list(input_folder.glob("*.png"))
|
||||
|
||||
# Process the images
|
||||
with ThreadPoolExecutor() as executor:
|
||||
for image_path in image_paths:
|
||||
"""
|
||||
try catch block to handle errors in processing individual images.
|
||||
"""
|
||||
try:
|
||||
process_image(image_path, pass_folder, reject_folder)
|
||||
#process_image(image_path, pass_folder, reject_folder)
|
||||
executor.submit(process_image, image_path, pass_folder, reject_folder)
|
||||
except cv2.error as e:
|
||||
print(f"Error processing image {image_path.name}: {str(e)}")
|
||||
|
||||
|
||||
@@ -14,6 +14,17 @@ threshold_type = cv2.THRESH_BINARY
|
||||
logging.basicConfig(level=logging.INFO, format="%(asctime)s - %(levelname)s - %(message)s" , datefmt="%Y-%m-%d %H:%M:%S")
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
# Create a file handler and set the log file path
|
||||
log_file = "./image_sorter.log"
|
||||
file_handler = logging.FileHandler(log_file)
|
||||
|
||||
# Configure the file handler to use a more verbose log format than the console output
|
||||
formatter = logging.Formatter("[%(levelname)s] %(asctime)s %(message)s")
|
||||
file_handler.setFormatter(formatter)
|
||||
|
||||
# Add the file handler to the logger
|
||||
logger.addHandler(file_handler)
|
||||
|
||||
def is_image_below_threshold(image_path, size_threshold):
|
||||
"""Check if the image size is below the threshold.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user