Added stuff.

master
Matt Theissen 1 year ago
parent 2fdf170b72
commit aa1fe490e6

@ -20,6 +20,7 @@ def find_human(event):
image_data = open(event.src_path, "rb").read() image_data = open(event.src_path, "rb").read()
response = requests.post(f"{codeai_server}/v1/vision/detection", response = requests.post(f"{codeai_server}/v1/vision/detection",
files={"image":image_data}).json() files={"image":image_data}).json()
send_bool = False
for object in response["predictions"]: for object in response["predictions"]:
if object["label"] == "person" and object["confidence"] > 0.60: if object["label"] == "person" and object["confidence"] > 0.60:
path = event.src_path path = event.src_path
@ -28,14 +29,14 @@ def find_human(event):
thickness = 2 thickness = 2
image = cv2.rectangle(image, (object["x_min"], object["y_min"]), (object["x_max"], object["y_max"]), color, thickness) image = cv2.rectangle(image, (object["x_min"], object["y_min"]), (object["x_max"], object["y_max"]), color, thickness)
cv2.imwrite(path,image) cv2.imwrite(path,image)
send_telegram(event) send_bool = True
break if send_bool == True:
# print(response["predictions"]) send_telegram(event)
def send_telegram(event): def send_telegram(event):
time.sleep(1) time.sleep(1)
bot.send_photo(chat_id=chat_id, photo=open(event.src_path, 'rb')) bot.send_photo(chat_id=chat_id, photo=open(event.src_path, 'rb'))
bot.send_message(chat_id=chat_id, text="Tweakers?!") bot.send_message(chat_id=chat_id, text="Tweakers!")
if __name__ == "__main__": if __name__ == "__main__":