Commit 85dfc12b authored by Sikhin VC's avatar Sikhin VC

code changes for staging

parent 310b078e
This diff is collapsed.
import os 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://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$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%241234@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 ExecutePipeline
from edge_engine.edge_processor import Pubs from edge_engine.edge_processor import Pubs
from scripts import Ppe from scripts import Ppe
......
...@@ -7,8 +7,6 @@ class FrameProcessor: ...@@ -7,8 +7,6 @@ class FrameProcessor:
self.model = model self.model = model
self.stream = stream self.stream = stream
logger.info("Setting up frame processor !!") logger.info("Setting up frame processor !!")
self.count = 0
self.skip_frame_every = 1 # 1 does not skip any frame (n-1 frames get skipped)
def run_model(self): def run_model(self):
while self.stream.stream.isOpened(): while self.stream.stream.isOpened():
...@@ -16,13 +14,9 @@ class FrameProcessor: ...@@ -16,13 +14,9 @@ class FrameProcessor:
logger.debug("Getting frame mask_model") logger.debug("Getting frame mask_model")
frame = self.stream.read() frame = self.stream.read()
logger.debug("Running mask_model") logger.debug("Running mask_model")
self.count += 1 data = {"frame": frame[0], "frameId":frame[1] , "deviceId": "{}".format(DEVICE_ID)}
if frame is not None and self.count % self.skip_frame_every == 0: self.model.predict(data)
logger.debug("publishing mask_model output")
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: except Exception as e:
logger.error(e) logger.error(e)
logger.error(traceback.format_exc()) logger.error(traceback.format_exc())
\ No newline at end of file
...@@ -3,6 +3,7 @@ from threading import Thread ...@@ -3,6 +3,7 @@ from threading import Thread
import sys import sys
import cv2 import cv2
import time import time
# import the Queue class from Python 3 # import the Queue class from Python 3
if sys.version_info >= (3, 0): if sys.version_info >= (3, 0):
from queue import Queue from queue import Queue
...@@ -13,16 +14,15 @@ else: ...@@ -13,16 +14,15 @@ else:
class FileVideoStream: class FileVideoStream:
def __init__(self,stream_config, transform=None): def __init__(self, stream_config, transform=None):
# initialize the file video stream along with the boolean # initialize the file video stream along with the boolean
# used to indicate if the thread should be stopped or not # used to indicate if the thread should be stopped or not
self.transform = transform self.transform = transform
self.stream_config =stream_config self.stream_config = stream_config
# initialize the queue used to store frames read from # initialize the queue used to store frames read from
# the video file # the video file
self.build_pipeline() self.build_pipeline()
def start(self): def start(self):
# start a thread to read frames from the file video stream # start a thread to read frames from the file video stream
self.thread.start() self.thread.start()
...@@ -35,19 +35,19 @@ class FileVideoStream: ...@@ -35,19 +35,19 @@ class FileVideoStream:
def build_pipeline(self): def build_pipeline(self):
self.build_cv_obj() self.build_cv_obj()
if "queueSize" not in self.stream_config: if "queueSize" not in self.stream_config:
self.stream_config["queueSize"] =128 self.stream_config["queueSize"] = 128
self.Q = Queue(maxsize=int(self.stream_config["queueSize"])) self.Q = Queue(maxsize=int(self.stream_config["queueSize"]))
# intialize thread # intialize thread
self.thread = Thread(target=self.update, args=()) self.thread = Thread(target=self.update, args=())
self.thread.daemon = True self.thread.daemon = True
def is_opened(self): def is_opened(self):
return self.stream.isOpened() return self.stream.isOpened()
def update(self): def update(self):
# keep looping infinitely # keep looping infinitely
count = 0
while True: while True:
# if the thread indicator variable is set, stop the # if the thread indicator variable is set, stop the
# thread # thread
...@@ -62,7 +62,8 @@ class FileVideoStream: ...@@ -62,7 +62,8 @@ class FileVideoStream:
# if the `grabbed` boolean is `False`, then we have # if the `grabbed` boolean is `False`, then we have
# reached the end of the video file # reached the end of the video file
if grabbed is False or frame is None: if grabbed is False or frame is None:
#self.stopped = True # self.stopped = True
count = 0
self.build_cv_obj() self.build_cv_obj()
continue continue
...@@ -82,7 +83,8 @@ class FileVideoStream: ...@@ -82,7 +83,8 @@ class FileVideoStream:
frame = self.transform(frame) frame = self.transform(frame)
# add the frame to the queue # add the frame to the queue
self.Q.put(frame) self.Q.put((frame, count))
count = count+1
else: else:
time.sleep(0.1) # Rest for 10ms, we have a full queue time.sleep(0.1) # Rest for 10ms, we have a full queue
...@@ -111,4 +113,4 @@ class FileVideoStream: ...@@ -111,4 +113,4 @@ class FileVideoStream:
# indicate that the thread should be stopped # indicate that the thread should be stopped
self.stopped = True self.stopped = True
# wait until stream resources are released (producer thread might be still grabbing frame) # wait until stream resources are released (producer thread might be still grabbing frame)
self.thread.join() self.thread.join()
\ No newline at end of file
This diff is collapsed.
numpy numpy==1.23.1
pymongo pymongo
opencv-python opencv-python
cachetools cachetools
...@@ -14,4 +14,5 @@ tqdm ...@@ -14,4 +14,5 @@ tqdm
torch==1.9.0 torch==1.9.0
torchvision==0.10.0 torchvision==0.10.0
pandas pandas
seaborn seaborn
\ No newline at end of file scikit-learn==0.22.2
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
...@@ -9,6 +9,7 @@ import numpy as np ...@@ -9,6 +9,7 @@ import numpy as np
import cv2 import cv2
np.seterr(divide='ignore', invalid='ignore')
class Box: class Box:
def __init__(self): def __init__(self):
......
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