def test_lcd(): print('Testing LCD...') lcd = LCD() lcd.text('Works', 1) ans = input('Is Works printed on the LCD? y/n: ') lcd.clear() return ans == 'y'
def customCallback(client, userdata, message): payload = json.loads(message.payload) if payload["deviceID"] == "CA2": lcd = LCD() lcd.clear() takePic() lcd.text('Time to eat', 1) lcd.text('medicine', 2) buzzerOn() lcd.clear()
def customCallback(client, userdata, message): #get the updated string for the sign from the topic print("Received a new message: ") print(message.payload) message = message.payload lcd = LCD() data = message.split(":") #split the message from user, string contains a : to seperate row 1 and row 2 for LCD lcd.text(data[0],1) #display text onto row 1 of lcd lcd.text(data[1],2) #display text onto row 2 of lcd print("--------------\n\n") f = open("led.txt","w") f.write(message) f.close()
def lcd_display(text_list): lcd = LCD() print "displaying" print text_list try: if 'clear' in text_list[0]: lcd.clear() else: lcd.text(text_list[0], 1) lcd.text(text_list[1], 2) sleep(1) except Exception: lcd.clear()
def main(): lcd = LCD() swarm = SwarmInfo() while True: sleep(1) if not swarm.is_manager(): lcd.text('Swarm is disabled', 1) else: managers = len(swarm.get_managers()) workers = len(swarm.get_workers()) lcd.text( '%s manager, %s worker%s' % (managers, workers, '' if workers == 1 else 's'), 1) lcd.text('IP: %s' % (swarm.get_node_ip(), ), 2) lcd.text('Memory: %s' % (swarm.get_total_memory(), ), 3) lcd.text('Running tasks: %s' % (len(swarm.get_running_tasks())), 4)
class LCDScroller: def __init__(self): self.lcd = LCD(rows = 2) self.lcd.clear() self.internalclear() self.update_time = time.time() def text(self, text, line): print(text) self.lcd.text(text,line) line -= 1 self.index[line] = 0 self.texts[line] = text def update(self): if time.time() - self.update_time < 0.5: return self.update_time = time.time() line = 0 for txt in self.texts: text_len = len(txt) if text_len > 16: self.index[line] += 1 new_text = txt[self.index[line] : self.index[line] + 16] if self.index[line] + 17 > text_len: if len(new_text) <= 0: self.index[line] = 0 new_text = txt[0 : 16 - len(new_text)] else: new_text += ' ' + txt[0 : 16 - len(new_text)] self.lcd.text(new_text,line + 1) line += 1 def clear(self): self.lcd.clear() self.texts self.internalclear() def internalclear(self): self.texts = ['',''] self.index = [0,0]
def button_sens(): global passEnter global passwordCounter global passEnterDisplay passwordCounter = 0 while (True): for j in range(4): GPIO.output(COL[j], 0) for i in range(4): if GPIO.input(ROW[i]) == 0: bz.on() print MATRIX[i][j] sleep(0.2) bz.off() if MATRIX[i][j] == "A": passEnter = passEnter[0:len(passEnter) - 1:] passEnterDisplay = passEnterDisplay[ 0:len(passEnterDisplay) - 1:] LCD.text(passEnterDisplay, 2) sleep(0.2) else: passEnter = passEnter + str(MATRIX[i][j]) passEnterDisplay = passEnterDisplay + str(MATRIX[i][j]) if len(passEnterDisplay) > 1: passEnterDisplay_list = list(passEnterDisplay) passEnterDisplay_list[len(passEnterDisplay) - 2] = "*" passEnterDisplay = "".join(passEnterDisplay_list) LCD.text(passEnterDisplay, 2) if passEnter == passcode and len(passEnter) == 5: correct_pass() passEnter = '' passEnterDisplay = '' LCD.text('Password: '******'' passEnterDisplay = '' LCD.text('Password: ', 1) while (GPIO.input(ROW[i]) == 0): pass GPIO.output(COL[j], 1)
def wrong_pass(passwordCounter): bz.on() sleep(0.1) bz.off() sleep(0.1) bz.on() sleep(0.1) bz.off() print "failed" LCD.text('Wrong Password!', 1) passwordCounter += 1 countdown = 10 LCD.text('', 2) if passwordCounter == 3: bot.sendMessage( chat_id, "Password keyed in wrong 3 times! Lock disabled for 10 Seconds.") while countdown != 0: LCD.text('Disabled for:{}'.format(countdown), 1) countdown = countdown - 1 sleep(1) passwordCounter = 0 sleep(3) return passwordCounter
#setting values as json format to publish to dynamoDB message = {} message["deviceid"] = "greenhouse_1" import datetime as datetime now = datetime.datetime.now() message["datetime_value"] = now.strftime("%d/%m/%Y, %H:%M:%S") message["temperature_value"] = temperature message["humidity_value"] = humidity message["light_value"] = light import json my_rpi.publish("sensors/environment/greenhouse", json.dumps(message), 1) print( "Wait 4 secs before getting next temperature and humidity values.." ) sleep(2) #display temperature and humidity on LCD lcd.text("Temp: " + str(temperature) + unichr(223) + "C", 1) lcd.text("Humidity: " + str(humidity) + "%", 2) except KeyboardInterrupt: update = False lcd.clear() except: print("Error while inserting data...") print(sys.exc_info()[0]) print(sys.exc_info()[1]) except: print(sys.exc_info()[0]) print(sys.exc_info()[1])
def options_menu(): LCD.text('A:NightM B:Door', 1) LCD.text('C:TemHum D:GDoor', 2)
def correct_pass(): bz.on() sleep(1) bz.off() print "success" bot.sendMessage(chat_id, "Correct password, main door opened.") LCD.text('Welcome to the', 1) LCD.text('Community!', 2) sleep(5) options_menu() NightBool = False mode = 'Day Mode' publishMode(mode) p = proc_start() while (True): for j in range(4): GPIO.output(COL[j], 0) for i in range(4): if GPIO.input(ROW[i]) == 0: if MATRIX[i][j] == "A": if NightBool == True: LCD.text('Day Mode', 1) LCD.text('Activated', 2) p = proc_start() sleep(3) options_menu() NightBool = False mode = 'Day Mode' publishMode(mode) else: LCD.text('Night Mode', 1) LCD.text('Activated', 2) proc_stop(p) if GPIO.input(21) == 1: led.off() sleep(3) options_menu() NightBool = True mode = 'Night Mode' publishMode(mode) elif MATRIX[i][j] == "B": bot.sendMessage(chat_id, 'Main Door opened') LCD.text('Door', 1) LCD.text('Opening', 2) doorled.on() sleep(10) doorled.off() options_menu() elif MATRIX[i][j] == "C": temperature, humidity = getTempHum() LCD.text('Temperature:{:.1f}'.format(temperature), 1) LCD.text('Humidity:{:.1f}'.format(humidity), 2) sleep(7) options_menu() elif MATRIX[i][j] == "D": bot.sendMessage(chat_id, 'Garage door opened for 10 Seconds') LCD.text('Garage Door', 1) LCD.text('Opening', 2) openGarage() options_menu() GPIO.output(COL[j], 1)
if ser.in_waiting > 0: time.sleep(.1) serial_data = ser.readline().decode('utf-8').strip() print(serial_data) data_split = serial_data.split("|") time.sleep(.5) while(x < 1): print(data_split) pH = data_split[0] temp = data_split[1] waterLevel = data_split[2] avgLux = data_split[3] print("pH: ",pH) lcd.clear() lcd.text('pH:'+ str(pH),1) if float(pH) < 7 and float(pH) > 5: GPIO.output(LED_red, GPIO.LOW) GPIO.output(LED_blue, GPIO.HIGH) lcd.text('Good',2) pH_flag = 0 elif float(pH) >= 7: GPIO.output(LED_blue, GPIO.LOW) GPIO.output(LED_red, GPIO.HIGH) lcd.text('pH too high',2) pH_flag = 1 elif float(pH) <= 5: GPIO.output(LED_blue, GPIO.LOW) GPIO.output(LED_red, GPIO.HIGH) lcd.text('pH too low',2) pH_flag = 1
def proc_stop(p_to_stop): p_to_stop.terminate() for j in range(4): GPIO.setup(COL[j], GPIO.OUT) GPIO.output(COL[j], 1) for i in range(4): GPIO.setup(ROW[i], GPIO.IN, pull_up_down=GPIO.PUD_UP) bot = telepot.Bot(my_bot_token) bot.message_loop(respondToMsg) try: LCD.text('Password: '******'' passEnterDisplay = '' t1 = threading.Thread(target=publishTempHum) t2 = threading.Thread(target=publishLight) t3 = threading.Thread(target=senseMotion) t4 = threading.Thread(target=button_sens) # starting thread 1 t1.start() # starting thread 2 t2.start() # starting thread 3 t3.start() # starting thread 4 t4.start()
from rpi_lcd import LCD from time import sleep lcd = LCD(address=0x27, bus=1, width=16, rows=2) lcd.text('Hello World!', 1) lcd.text('Raspberry Pi', 2) sleep(2) lcd.clear() lcd.text("This is test string for i2c lcd screen, which has 16x2 demension.", 1) sleep(5)
my_rpi.connect() my_rpi.subscribe("school/attendance/" + gate_number + "/#", 1, customCallback) uid = None prev_uid = None # =================================================================== # Main # =================================================================== if __name__ == "__main__": # Publish to the same topic in a loop forever print("Scan card to record Attendance ...") lcd.clear() lcd.text("Scan card for Attendance ...", 1) while scanning: # Scan for cards (status, TagType) = mfrc522.MFRC522_Request(mfrc522.PICC_REQIDL) # If a card is found if status == mfrc522.MI_OK: # Get the UID of the card (status, uid) = mfrc522.MFRC522_Anticoll() if uid != prev_uid: prev_uid = uid print("Card detected! UID of card is {}".format(uid))
message = {} message["deviceid"] = "class2" message["datetimeid"] = now.isoformat() message["studentid"] = str(uid) message['studentname'] = student[2].studentname message['class'] = 'class 2' message['timein'] = time message['attendance'] = attendance import json my_rpi.publish("data/timein/class2", json.dumps(message), 1) message1 = {} message1['deviceid'] = 'class2' message1['datetimeid'] = now.isoformat() message1['number'] = len(studentinclass) my_rpi.publish("data/student/class2", json.dumps(message1), 1) else: print("You don't belong to this class!") print(uid) ledwrong.on() lcd.text("You don't belong to this class!", 1) sms = 'Someone unauthorized is trying to enter the classroom, ' + classid message = client.api.account.messages.create(to=my_hp, from_=twilio_hp, body=sms) # camera.start_recording('/home/pi/Desktop/video1.h264') # camera.wait_recording(5) # camera.stop_recording() sleep(5) lcd.clear() ledwrong.off()
publisher() watering() elif data['turn'] == 'Off': closewater() my_rpi.connect() my_rpi.subscribe("farm/pump/farm1", 1, pumpCallback) print("Successfully connected to MQTT!") update = True while update: try: lcd = LCD() if soil.is_held: lcd.text('Soil is wet', 1) lcd.text('Pump OFF', 2) print("Soil moisture is wet, Pump is not turned on") sleep(10) print("Checking Soil moisture after 10 seconds...") sleep(5) else: activation() sleep(3) except Exception as e: print(e) print('error') print(sys.exc_info()[0]) print(sys.exc_info()[1])
except Exception as e: print(e) print('error') print(sys.exc_info()[0]) print(sys.exc_info()[1]) my_rpi.connect() print("Successfully connected to MQTT!") update = True while update: try: lcd = LCD() if soil.is_held: lcd.text('Soil is wet', 1) print("Soil moisture is wet") sleep(10) else: print("Checking Soil moisture after 10 seconds...") sleep(5) checking() sleep(3) except Exception as e: print(e) print('error') print(sys.exc_info()[0]) print(sys.exc_info()[1])
from rpi_lcd import LCD from time import sleep lcd = LCD() a = 1 print("schau auf dein Display") lcd.text("Hello", 1) lcd.text("1 2 3 4 5 6", 2) a = input() if (a == 'A'): lcd.clear() lcd.text("A", 1) lcd.text("1 2 3 4 5 6", 2) elif (a == 'B'): lcd.clear() lcd.text("B", 1) lcd.text("1 2 3 4 5 6", 2)
from flask import Flask, render_template, request from AWSIoTPythonSDK.MQTTLib import AWSIoTMQTTClient from time import sleep from gpiozero import Buzzer import json from rpi_lcd import LCD foodorderid=[] drinkorderid=[] currentorderid="" pastservedorderid=[] bz = Buzzer(26) lcd = LCD() lcd.text('Serving:', 1) lcd.text('', 2) # Custom MQTT message callback def customCallback(client, userdata, message): global foodorderid global drinkorderid global currentorderid global pastservedorderid j = json.loads(message.payload) if j['orderid'] in drinkorderid: bz.on() sleep(0.5) bz.off() sleep(0.5) drinkorderid.remove(j['orderid']) if currentorderid!="":
#get drinks response = drinks.scan() item = response['Items'] for a in item: drinkslist.append([a['name'], a['description'], a['imagelocation']]) drinkprice[a['name']] = float(a['price']) app = Flask(__name__) app.secret_key = os.urandom(24) orderid = 1 lcd = LCD() mfrc522 = MFRC522.MFRC522() continue_reading = True lcd.text('MasterCard', 1) lcd.text('Payment', 2) @app.route("/") def main(): return render_template('index.html') @app.route("/order", methods=['POST', 'GET']) def selectfood(): try: global continue_reading global foodlist if 'allorders' not in session: session['allorders'] = []
# Import SDK packages from AWSIoTPythonSDK.MQTTLib import AWSIoTMQTTClient from time import sleep from gpiozero import Buzzer, LED from rpi_lcd import LCD import random import sys import pyrebase from datetime import datetime import json lcd = LCD() lcd.text('Launching...', 1) sleep(1) lcd.text('Getting ready', 1) lcd.text('......', 2) bz = Buzzer(22) led = LED(18) config = { #Firebase API Key } firebase = pyrebase.initialize_app(config) auth = firebase.auth() #Firebase login (username, password) user = auth.sign_in_with_email_and_password("", "") db = firebase.database()
certificatePath = "certificate.pem.crt" privateKeyPath = "private.pem.key" my_rpi = AWSIoTMQTTClient("basicPubSub") my_rpi.configureEndpoint(host, 8883) my_rpi.configureCredentials(rootCAPath, privateKeyPath, certificatePath) my_rpi.configureOfflinePublishQueueing(-1) # Infinite offline Publish queueing my_rpi.configureDrainingFrequency(2) # Draining: 2 Hz my_rpi.configureConnectDisconnectTimeout(10) # 10 sec my_rpi.configureMQTTOperationTimeout(5) # 5 sec # Connect and subscribe to AWS IoT my_rpi.connect() my_rpi.subscribe("smartgarden/readings", 1, customCallback) lcd.text(" SMART GARDEN ", 1) lcd.text("* Welcome back *", 2) sleep(2) lcd.clear() # Publish to the same topic in a loop forever loopCount = 0 while True: temp = float(ser.readline()) hum = float(ser.readline()) soil = int(ser.readline()) light = int(ser.readline()) lcd.text('Humidity: {:.2f}%'.format(hum), 1) lcd.text('Temp: {:.2f} C'.format(temp), 2) sleep(2)
for Student in StudentList: if int(Student[0]) == StudentID: exist = True break if not exist: print("\n Student ID doesn't exist \n ") else: break except: print("\n Student ID must be an Integer \n ") #Error Message while scanning: #print("Scan card to register ...") lcd.text("Scan card to register ...", 1) # Scan for cards (status, TagType) = mfrc522.MFRC522_Request(mfrc522.PICC_REQIDL) # If a card is found if status == mfrc522.MI_OK: # Get the UID of the card (status, uid) = mfrc522.MFRC522_Anticoll() if uid != prev_uid: prev_uid = uid print("Card detected! UID of card is {}".format(uid)) payload = json.dumps({ "RFID": str(uid),
def pillSchedule(): try: # Setting up the pin for the dht sensor, the buzzer and motion sensor pin = 4 bz = Buzzer(5) pir = MotionSensor(26, sample_rate=20, queue_len=1) # To setup the certificate etc for mqtt host = "acway7h5aefsa-ats.iot.us-east-1.amazonaws.com" rootCAPath = "getEnvironmentCert/rootca.pem" certificatePath = "getEnvironmentCert/certificate.pem.crt" privateKeyPath = "getEnvironmentCert/private.pem.key" # Set the filename and bucket name BUCKET = 'sp-p1726819-s3-bucket' location = {'LocationConstraint': 'us-east-1'} file_path = "/home/pi/labs/assignment/photo" file_name = "user.jpg" my_rpi = AWSIoTMQTTClient("PubSub-p1726819" + rand_str_gen()) my_rpi.configureEndpoint(host, 8883) my_rpi.configureCredentials(rootCAPath, privateKeyPath, certificatePath) my_rpi.configureOfflinePublishQueueing( -1) # Infinite offline Publish queueing my_rpi.configureDrainingFrequency(2) # Draining: 2 Hz my_rpi.configureConnectDisconnectTimeout(10) # 10 sec my_rpi.configureMQTTOperationTimeout(5) # 5 sec # Connect and subscribe to AWS IoT my_rpi.connect() update = True while update: try: global medicine_time data = get_data_from_dynamodb(1, 'pillSchedule', -1) medicine_time = data global medicine_time_plus medicine_time_plus = datetime.datetime.strptime( medicine_time, "%H:%M:%S") medicine_time_plus += datetime.timedelta(0, 60) medicine_time_plus = medicine_time_plus.strftime("%H:%M:%S") # Get the current time now and check if it is the time specified now = datetime.datetime.now() time_string = now.strftime("%H:%M:%S") if (medicine_time_plus > time_string > medicine_time): # Alert the user by turning on the buzzer bz.on() print("Time to eat medicine") # Print on the LCD to tell the user to take med lcd = LCD() lcd.text('Time to eat', 1) lcd.text('medicine :)', 2) # Checking how long did the user take to take the medicine after buzzer on old_now = datetime.datetime.now().strftime("%H:%M:%S") start_dt = datetime.datetime.strptime(old_now, '%H:%M:%S') pir.wait_for_motion( 10) # Motion sensor will only wait for 10 seconds new_now = datetime.datetime.now() new_time = new_now.strftime("%H:%M:%S") end_dt = datetime.datetime.strptime(new_time, '%H:%M:%S') duration = (end_dt - start_dt) diff = int(duration.seconds) # If the user took more than 10 seconds it means that the user did not take the medicine on time if diff < 8: # Take a photo and store to S3 takePhoto(file_path, file_name) uploadToS3(file_path, file_name, BUCKET, location) ageLow = 0 ageHigh = 0 # Print the deteced face attribute print('Detected faces for') for faceDetail in detect_faces(BUCKET, file_name): ageLow = faceDetail['AgeRange']['Low'] ageHigh = faceDetail['AgeRange']['High'] print('Age between {} and {} years old'.format( ageLow, ageHigh)) print('Here are the other attributes:') print( json.dumps(faceDetail, indent=4, sort_keys=True)) # To ensure that the medicine is taken by elderly and not others (Kids or pets) if (ageLow < 20 < ageHigh): # The medicine is taken in less than 10 seconds, turn off buzzer lcd.text('Medicine taken', 1) lcd.text('successfully :)', 2) print("User ate medicine after {:.2f} seconds". format(diff)) bz.off() # Get the current date and time and insert the data into the database True_string = 'True' message = {} message["deviceID"] = "CA2" message["datetimeID"] = new_now.isoformat() message["takenOnTime"] = True_string my_rpi.publish("sensor/takeMed", json.dumps(message), 1) # Clear LCD print("Uploaded data to database") print("Waiting for next schedule") lcd.clear() sleep(60) # The medicine is not taken by elderly else: bz.off() print("Medicine not taken by patient") # Send a msg to the user telling that the patient did not take medicine on time send_user_Msg("Medicine not taken by patient") # Get the current date and time and insert into the database False_string = 'False' message = {} message["deviceID"] = "CA2" message["datetimeID"] = new_now.isoformat() message["takenOnTime"] = False_string my_rpi.publish("sensor/takeMed", json.dumps(message), 1) # Clear LCD print("Uploaded data to database") print("Waiting for next schedule") lcd.clear() sleep(60) else: # The user did not take medicine within 10 seconds bz.off() print("Patient did not take medicine on time") # Send a msg to the user telling that the patient did not take medicine on time send_user_Msg("User did not eat medicine on time") # Get the current date and time and insert into the database False_string = 'False' message = {} message["deviceID"] = "CA2" message["datetimeID"] = new_now.isoformat() message["takenOnTime"] = False_string my_rpi.publish("sensor/takeMed", json.dumps(message), 1) # Clear LCD print("Uploaded data to database") print("Waiting for next schedule") lcd.clear() sleep(60) except KeyboardInterrupt: update = False except: print("Error while inserting data...") print(sys.exc_info()[0]) print(sys.exc_info()[1]) except: print(sys.exc_info()[0]) print(sys.exc_info()[1])
GPIO.setup(mot_A_PWM, GPIO.OUT) GPIO.setup(mot_A_IN2, GPIO.OUT) GPIO.setup(mot_A_IN1, GPIO.OUT) GPIO.setup(mot_standby, GPIO.OUT) GPIO.setup(mot_B_IN1, GPIO.OUT) GPIO.setup(mot_B_IN2, GPIO.OUT) GPIO.setup(mot_B_PWM, GPIO.OUT) # Setup Arquivo distance_csv = "/home/pi/CORGOZINHO/stand_counter/csv_data/distance.csv" count_csv = "/home/pi/CORGOZINHO/stand_counter/csv_data/count.csv" f_distance = open(distance_csv, 'a') f_count = open(count_csv, 'a') # Cabeçalho Inicial lcd.text("*STAND COUNTER*", 1) lcd.text("by CorgozinhoDev", 2) print("\n****Bem-vindo ao Stand Counter!***") print("\n **BY CORGOZINHO MEGA DEV**\n\n") time.sleep(2) # Código Principal try: #print("B1: " + str(GPIO.input(b1))) #print("B2: " + str(GPIO.input(b2))) #print("B3: " + str(GPIO.input(b3))) print("\nPressione o botão 1 para iniciar a contagem...\n") lcd.text("Pressione B1", 1) lcd.text("para iniciar", 2)
userpass.append(number) print(userpass) def checkPass(userpass, password): #print("CHECKING PASSWORD: " + str(userpass))' if userpass == password: result = True else: result = False return result while True: lcd.text('Please Enter \nPasscode!', 1) btn1.when_pressed = buttonOne btn2.when_pressed = buttonTwo if len(userpass) == len(password): lcd.clear() lcd.text('Authenticating...', 1) sleep(1) result = checkPass(userpass, password) if result is True: lcd.text('Passcode', 1) lcd.text('Correct!', 2) buzz.on() greenled.on() sleep(2)
from signal import signal, SIGTERM, SIGHUP, pause from rpi_lcd import LCD lcd = LCD() def safe_exit(signum, frame): exit(1) try: signal(SIGTERM, safe_exit) signal(SIGHUP, safe_exit) lcd.text("--Welcome--", 1) lcd.text("Raspberry Pi!", 2) pause() except KeyboardInterrupt: pass finally: lcd.clear()
# Get the UID of the card (status, uid) = mfrc522.MFRC522_Anticoll() print(uid) # If card is the authorised card if uid == [136, 4, 93, 174, 127] or uid == [8, 138, 147, 144, 129]: message = {} message["deviceid"] = "deviceid_1828034" now = datetime.datetime.now() message["datetimeid"] = now.isoformat() message["rfid"] = 1 message["servo"] = 1 message["bot"] = 0 message["camera"] = 0 message["webcontrol"] = 0 my_rpi.publish("lockdata", json.dumps(message), 1) lcd.text('Welcome', 1) lcd.text('Home!', 2) unlockDoor() lcd.clear() message = {} message["deviceid"] = "deviceid_1828034" now = datetime.datetime.now() message["datetimeid"] = now.isoformat() message["rfid"] = 0 message["servo"] = 0 message["bot"] = 0 message["camera"] = 0 message["webcontrol"] = 0 my_rpi.publish("lockdata", json.dumps(message), 1) else: message = {}
sql = "SELECT FaceScanConfidence FROM assignment.Security" curs.execute(sql) result = curs.fetchall() setconfidence = int(result[0][0]) # Initialize and start realtime video capture cam = cv2.VideoCapture(0) cam.set(3, 640) # set video widht cam.set(4, 480) # set video height # Define min window size to be recognized as a face minW = 0.1 * cam.get(3) minH = 0.1 * cam.get(4) lcd = LCD() lcd.text('Scanning...', 1) starttime = time.time() while True: confidentint = 0 ret, img = cam.read() img = cv2.flip(img, -1) # Flip vertically gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY) faces = faceCascade.detectMultiScale( gray, scaleFactor=1.2, minNeighbors=5, minSize=(int(minW), int(minH)), ) for (x, y, w, h) in faces: