Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ def extract_photos(image_path, output_folder, debug_folder):
# Debug: Draw all contours
debug_image = padded_image.copy()
cv2.drawContours(debug_image, contours, -1, (0, 255, 0), 2)
cv2.imwrite(os.path.join(debug_folder, "debug_all_contours.png"), debug_image)
cv2.imwrite(os.path.join(debug_folder, f"debug_all_contours_{os.path.basename(image_path)}.png"), debug_image)

# Loop through contours and extract rectangular photos
photo_count = 0
Expand All @@ -175,7 +175,7 @@ def extract_photos(image_path, output_folder, debug_folder):

# Debug: Save the transformed photo before cropping white margins
cv2.imwrite(
os.path.join(debug_folder, f"debug_transformed_{photo_count}.png"),
os.path.join(debug_folder, f"debug_transformed_{os.path.basename(image_path)}_{photo_count}.png"),
photo,
)

Expand All @@ -186,7 +186,7 @@ def extract_photos(image_path, output_folder, debug_folder):
photo = crop_edges(photo, 5)

# Save the photo
output_path = os.path.join(output_folder, f"photo_{photo_count}.png")
output_path = os.path.join(output_folder, f"{os.path.basename(image_path)}_{photo_count}.png")
cv2.imwrite(output_path, photo)
photo_count += 1
else:
Expand All @@ -200,7 +200,7 @@ def extract_photos(image_path, output_folder, debug_folder):
# Debug: Save the transformed photo before cropping white margins
cv2.imwrite(
os.path.join(
debug_folder, f"debug_transformed_skew_{photo_count}.png"
debug_folder, f"debug_transformed_skew_{os.path.basename(image_path)}_{photo_count}.png"
),
photo,
)
Expand All @@ -212,7 +212,7 @@ def extract_photos(image_path, output_folder, debug_folder):
photo = crop_edges(photo, 5)

# Save the photo
output_path = os.path.join(output_folder, f"photo_{photo_count}.png")
output_path = os.path.join(output_folder, f"{os.path.basename(image_path)}_{photo_count}.png")
cv2.imwrite(output_path, photo)
photo_count += 1

Expand Down