#code modified from https://pythonprogramming.net/haar-cascade-object-detection-python-opencv-tutorial/ import numpy as np import cv2 import os thot_cascade = cv2.CascadeClassifier('face_cascade.xml') launched = False capturing = False saved = 0 recent_saved = 0 img = cv2.imread("IMG_2619.jpg", 0) print(img) gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY) thots = thot_cascade.detectMultiScale(gray, 1.3, 5) for (x,y,w,h) in thots: font = cv2.FONT_HERSHEY_SIMPLEX if not launched: pass #os.system("ard.exe") capturing = True recent_saved = 0 cv2.putText(img, 'THOT',(x+w,y+h), font, 0.5, (11,255,255), 2, cv2.LINE_AA) cv2.rectangle(img,(x,y),(x+w,y+h),(255,255,0),2) cv2.imwrite("detected_thot_" + str(saved) + ".jpg", img)