Commit 2f1e4e02 authored by Sikhin VC's avatar Sikhin VC

frame skip added

parent dd217aee
import os
# os.environ["config"]="{\"TZ\": \"Asia/Kolkata\", \"MONGO_URI\": \"mongodb://svc-ilens:svc2345@192.168.3.220:21017\", \"MONGO_DATABASE\": \"ilens_wps\", \"MONGO_COLLECTION\": \"janusDeployment\", \"MONGO_KEY\": \"deploymentId\", \"MONGO_VALUE\": \"rahul_12345\", \"MONGO_COLL\": \"serviceConfiguration\", \"MONGO_DB\": \"ilens_wps\"}"
# os.environ["config"]="{\"TZ\": \"Asia/Kolkata\", \"MONGO_URI\": \"mongodb://admin:iLens$HPCLv605@10.5.2.91:2717\", \"MONGO_DATABASE\": \"ilens_ai\", \"MONGO_COLLECTION\": \"janusDeployment\", \"MONGO_KEY\": \"deploymentId\", \"MONGO_VALUE\": \"hpcl_cctv_ppe\", \"MONGO_COLL\": \"serviceConfiguration\", \"MONGO_DB\": \"ilens_ai\"}"
os.environ["config"]="{\"TZ\": \"Asia/Kolkata\", \"MONGO_URI\": \"mongodb://admin:iLens$1234@192.168.3.181:2717/admin\", \"MONGO_DATABASE\": \"ilens_ai\", \"MONGO_COLLECTION\": \"janusDeployment\", \"MONGO_KEY\": \"deploymentId\", \"MONGO_VALUE\": \"aarti_ppe\", \"MONGO_COLL\": \"serviceConfiguration\", \"MONGO_DB\": \"ilens_ai\"}"
# os.environ["config"]="{\"TZ\": \"Asia/Kolkata\", \"MONGO_URI\": \"mongodb://admin:iLens$1234@192.168.3.181:2717/admin\", \"MONGO_DATABASE\": \"ilens_ai\", \"MONGO_COLLECTION\": \"janusDeployment\", \"MONGO_KEY\": \"deploymentId\", \"MONGO_VALUE\": \"aarti_ppe\", \"MONGO_COLL\": \"serviceConfiguration\", \"MONGO_DB\": \"ilens_ai\"}"
from edge_engine.edge_processor import ExecutePipeline
from edge_engine.edge_processor import Pubs
from scripts import Ppe
......
......@@ -8,6 +8,7 @@ class FrameProcessor:
self.stream = stream
logger.info("Setting up frame processor !!")
self.count = 0
self.skip_frame_every = 30 # 1 does not skip any frame (n-1 frames get skipped)
def run_model(self):
while self.stream.stream.isOpened():
......@@ -15,10 +16,13 @@ class FrameProcessor:
logger.debug("Getting frame mask_model")
frame = self.stream.read()
logger.debug("Running mask_model")
data = {"frame": frame, "frameId": "{}".format(self.count), "deviceId": "{}".format(DEVICE_ID)}
self.model.predict(data)
logger.debug("publishing mask_model output")
self.count += 1
if frame is not None and self.count % self.skip_frame_every == 0:
data = {"frame": frame, "frameId": "{}".format(self.count), "deviceId": "{}".format(DEVICE_ID)}
self.model.predict(data)
logger.debug("publishing mask_model output")
except Exception as e:
logger.error(e)
logger.error(traceback.format_exc())
\ No newline at end of file
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -436,14 +436,16 @@ class Ppe(ModelWrapper):
print("sending to mongo")
self.send_payload(frame=resize_to_64_64(frame), message=temp_violation_list, event = violated_items,frame_id=self.frame_id)
self.reported_violation_ids[object_id] = time.time()
sql = 'INSERT INTO "aarti_violation_event_table" ("camera_id", "frame_id", "timestamp", "violation_type") VALUES (%s, %s, %s, %s);'
# for violated_items in violations:
# present_event_id = 'SELECT "event_id" FROM aarti_violation_event_table'
cur = self.conn.cursor()
frame_count = self.frame_id
cur.execute(sql, [4, frame_count, datetime.datetime.now(), violated_items])
self.conn.commit()
cur.close()
for v in violations:
sql = 'INSERT INTO "aarti_violation_event_table" ("camera_id", "frame_id", "timestamp", "violation_type") VALUES (%s, %s, %s, %s);'
# for violated_items in violations:
# present_event_id = 'SELECT "event_id" FROM aarti_violation_event_table'
cur = self.conn.cursor()
frame_count = self.frame_id
cur.execute(sql, [4, frame_count, datetime.datetime.now(), v])
self.conn.commit()
cur.close()
else:
time_diff = time.time() - self.reported_violation_ids[object_id]
if(time_diff > 30):
......@@ -486,14 +488,16 @@ class Ppe(ModelWrapper):
print("sending to mongo")
self.send_payload(frame=resize_to_64_64(frame), message=temp_violation_list , event = violated_items, frame_id=self.frame_id)
self.reported_violation_ids[object_id] = time.time()
sql = 'INSERT INTO "aarti_violation_event_table" ("camera_id", "frame_id", "timestamp", "violation_type") VALUES (%s, %s, %s, %s);'
# for violated_items in violations:
# present_event_id = 'SELECT "event_id" FROM aarti_violation_event_table'
cur = self.conn.cursor()
frame_count = self.frame_id
cur.execute(sql, [4, frame_count, datetime.datetime.now(), violated_items])
self.conn.commit()
cur.close()
for v in violations:
sql = 'INSERT INTO "aarti_violation_event_table" ("camera_id", "frame_id", "timestamp", "violation_type") VALUES (%s, %s, %s, %s);'
# for violated_items in violations:
# present_event_id = 'SELECT "event_id" FROM aarti_violation_event_table'
cur = self.conn.cursor()
frame_count = self.frame_id
cur.execute(sql, [4, frame_count, datetime.datetime.now(), v])
self.conn.commit()
cur.close()
else:
time_diff = time.time() - self.reported_violation_ids[object_id]
......@@ -537,14 +541,16 @@ class Ppe(ModelWrapper):
print("sending to mongo")
self.send_payload(frame=resize_to_64_64(frame), message=temp_violation_list, event = violated_items, frame_id=self.frame_id)
self.reported_violation_ids[object_id] = time.time()
sql = 'INSERT INTO "aarti_violation_event_table" ("camera_id", "frame_id", "timestamp", "violation_type") VALUES (%s, %s, %s, %s);'
# for violated_items in violations:
# present_event_id = 'SELECT "event_id" FROM aarti_violation_event_table'
cur = self.conn.cursor()
frame_count = self.frame_id
cur.execute(sql, [4, frame_count, datetime.datetime.now(), violated_items])
self.conn.commit()
cur.close()
for v in violations:
sql = 'INSERT INTO "aarti_violation_event_table" ("camera_id", "frame_id", "timestamp", "violation_type") VALUES (%s, %s, %s, %s);'
# for violated_items in violations:
# present_event_id = 'SELECT "event_id" FROM aarti_violation_event_table'
cur = self.conn.cursor()
frame_count = self.frame_id
cur.execute(sql, [4, frame_count, datetime.datetime.now(), v])
self.conn.commit()
cur.close()
else:
......
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