Commit 5f3b1f85 authored by Sikhin VC's avatar Sikhin VC

added app key in events API

parent fcf7fca5
Pipeline #69493 canceled with stage
...@@ -75,27 +75,6 @@ class CementBagCounter(ModelWrapper): ...@@ -75,27 +75,6 @@ class CementBagCounter(ModelWrapper):
logger.info("Pushed frame") logger.info("Pushed frame")
return x return x
def send_payload(self, frame,count, bag_type='', label='CementBagDetected', bg_color="#474520", font_color="#FFFF00",
alert_sound=None, message="Cement Bag Detected!"):
"""
Insert event to Mongo
:param message:
:param frame:
:param label:
:param bg_color:
:param font_color:
:param alert_sound:
:return: None
"""
payload = {"deviceId": self.device_id, "message": message,
"frame": 'data:image/jpeg;base64,' + base64.b64encode(
cv2.imencode('.jpg', frame)[1].tostring()).decode("utf-8"), "activity": label,
"bg_color": bg_color, "font_color": font_color, "alert_sound": alert_sound, "bag_type": bag_type, "cement_bag_count": count
}
self.mongo_logger.insert_attendance_event_to_mongo(payload)
def kalman_tracker( def kalman_tracker(
self, self,
bboxs, bboxs,
...@@ -323,7 +302,7 @@ class CementBagCounter(ModelWrapper): ...@@ -323,7 +302,7 @@ class CementBagCounter(ModelWrapper):
img2 = frame.copy() img2 = frame.copy()
img2 = cv2.resize(img2, (64, 64)) img2 = cv2.resize(img2, (64, 64))
bs64 = str(base64.b64encode(img2).decode('utf-8')) # Changed this line. converted byte to string bs64 = str(base64.b64encode(img2).decode('utf-8')) # Changed this line. converted byte to string
json = {"eventId": str(uuid1()).split('-')[0], "cameraId": EDGE_CONFIG['deviceId'], "cameraName": EDGE_CONFIG['deviceId'], "timestamp": datetime.isoformat(datetime.now()), "frame": bs64, "cement_bag_count": str(self.count)} json = {"eventId": str(uuid1()).split('-')[0], "cameraId": EDGE_CONFIG['deviceId'], "cameraName": EDGE_CONFIG['deviceId'], "timestamp": datetime.isoformat(datetime.now()), "frame": bs64, "cement_bag_count": str(self.count), "app":"cement"}
requests.post(url=MONGO_URI_ADD_EVENTLOGS, json=json) requests.post(url=MONGO_URI_ADD_EVENTLOGS, json=json)
logger.info(f"Count: {self.count}") logger.info(f"Count: {self.count}")
frame = draw_circles_on_frame( frame = draw_circles_on_frame(
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment