Add object detection, tracking, mobile notifications, and search to any security camera.
img in byo notif
Rory Clear0719ea4c41d3
diff --git a/clearcam.py b/clearcam.pyindex 649a34d..3a1474b 100644--- a/clearcam.py+++ b/clearcam.py@@ -480,7 +480,7 @@ class VideoCapture:self.filename[cam_name] = filepath / f"{ts}_notif.jpg"if global_settings.use_notifs() is not None and not self.vod[cam_name] and alert.is_notif:title = f"Event Detected ({cam_name})"- threading.Thread(target=send_notif, kwargs={"session_token": global_settings.userID,"text":title,"body_text": None,"host": global_settings.server_url,}, daemon=True).start()+ threading.Thread(target=send_notif, kwargs={"session_token": global_settings.userID,"text":title,"body_text": None,"host": global_settings.server_url, "img": self.filename[cam_name]}, daemon=True).start()if global_settings.use_qwen: # extra notif if qwen# use frames before last, only one reset needed, must convert to RGBfor i in range(len(self.last_frames[cam_name])-1): qwen.generate(image=cv2.cvtColor(self.last_frames[cam_name][i], cv2.COLOR_BGR2RGB), reset=True if i==0 else False)diff --git a/utils/helpers.py b/utils/helpers.pyindex b651ef2..ae9cfe6 100644--- a/utils/helpers.py+++ b/utils/helpers.py@@ -15,7 +15,7 @@ import numpy as npBASE_DIR = Path(__file__).parent.parent / "data"from tinygrad import Tensor, TinyJit-def send_notif(session_token: str, text=None, body_text=None, host="https://clearcam.org"):+def send_notif(session_token: str, text=None, body_text=None, host="https://clearcam.org", img=None):https = host.startswith("https://")if host.startswith("http"): host = host[host.index("//")+2:] # remove https:// / http:endpoint = "/send" #/test@@ -43,8 +43,11 @@ def send_notif(session_token: str, text=None, body_text=None, host="https://clea"",body_text,])-body = "\r\n".join(lines).encode("utf-8")+ if img is not None and host != "clearcam.org":+ with open(img, "rb") as f: img_data = f.read()+ body += (f"--{boundary}\r\n"f'Content-Disposition: form-data; name="img"; filename="{os.path.basename(img)}"\r\n'f"Content-Type: image/jpeg\r\n\r\n").encode() + img_data + f"\r\n--{boundary}--\r\n".encode()+conn = http.client.HTTPSConnection(host) if https else http.client.HTTPConnection(host)headers = {"Content-Type": content_type, "Content-Length": str(len(body))}try: