MCPcopy Index your code
hub / github.com/LCBOWER33/StegoScan / process_and_save

Function process_and_save

StegoScan.py:762–800  ·  view source on GitHub ↗

Runs YOLO and TrOCR on the image. Saves the image if objects or text are detected.

(image, variant_name)

Source from the content-addressed store, hash-verified

760# I think the above line is making it to where there is going to save all the file variations
761
762def process_and_save(image, variant_name):
763 """
764 Runs YOLO and TrOCR on the image.
765 Saves the image if objects or text are detected.
766 """
767 object_detected = detect_objects(image)
768
769 # Check for text in both grayscale and color versions using TrOCR
770 text_detected_grayscale, text_grayscale = detect_text(image) # , is_grayscale=True)
771 text_detected_color, text_color = detect_text(image) # , is_grayscale=False)
772
773 text_detected = text_detected_grayscale or text_detected_color
774
775 if object_detected: # or text_detected:
776 # NEED TO MAKE IT ROUTE TO THE OUTPUT DIR THEN HERE
777 object_detection_dir = os.path.join(results_folder, "object_detection")
778 os.makedirs(object_detection_dir, exist_ok=True)
779
780 save_path = os.path.join(results_folder, f"object_detection/{variant_name}.png")
781 # print("\n\n" + save_path + "\n\n")
782 cv2.imwrite(save_path, image)
783 # print(f"Saved: {save_path} (Object: {object_detected}, Text: {text_detected})")
784
785 # If text was detected, print it
786 # if text_detected_grayscale:
787 # print(f"Text (grayscale): {text_grayscale}")
788 # if text_detected_color:
789 # print(f"Text (color): {text_color}")
790
791 # Show the processed image
792 object_detection_dir = os.path.join(results_folder, "object_detection")
793 os.makedirs(object_detection_dir, exist_ok=True)
794
795 save_path = os.path.join(results_folder, f"object_detection/{variant_name}.png")
796 cv2.imwrite(save_path, image)
797
798 # cv2.imshow(f"Processed: {variant_name}", image)
799 # cv2.waitKey(500) # Show for 500ms before moving to the next image
800 # cv2.destroyAllWindows()
801
802
803def extract_lsb_and_normalize(image, bits):

Callers 1

object_detectionFunction · 0.85

Calls 2

detect_objectsFunction · 0.85
detect_textFunction · 0.85

Tested by

no test coverage detected