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

code changes for staging

parent 310b078e
This diff is collapsed.
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%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 Pubs
from scripts import Ppe
......
......@@ -7,8 +7,6 @@ class FrameProcessor:
self.model = model
self.stream = stream
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):
while self.stream.stream.isOpened():
......@@ -16,13 +14,9 @@ class FrameProcessor:
logger.debug("Getting frame mask_model")
frame = self.stream.read()
logger.debug("Running mask_model")
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")
data = {"frame": frame[0], "frameId":frame[1] , "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
......@@ -3,6 +3,7 @@ from threading import Thread
import sys
import cv2
import time
# import the Queue class from Python 3
if sys.version_info >= (3, 0):
from queue import Queue
......@@ -13,16 +14,15 @@ else:
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
# used to indicate if the thread should be stopped or not
self.transform = transform
self.stream_config =stream_config
self.stream_config = stream_config
# initialize the queue used to store frames read from
# the video file
self.build_pipeline()
def start(self):
# start a thread to read frames from the file video stream
self.thread.start()
......@@ -35,19 +35,19 @@ class FileVideoStream:
def build_pipeline(self):
self.build_cv_obj()
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"]))
# intialize thread
self.thread = Thread(target=self.update, args=())
self.thread.daemon = True
def is_opened(self):
return self.stream.isOpened()
def update(self):
# keep looping infinitely
count = 0
while True:
# if the thread indicator variable is set, stop the
# thread
......@@ -62,7 +62,8 @@ class FileVideoStream:
# if the `grabbed` boolean is `False`, then we have
# reached the end of the video file
if grabbed is False or frame is None:
#self.stopped = True
# self.stopped = True
count = 0
self.build_cv_obj()
continue
......@@ -82,7 +83,8 @@ class FileVideoStream:
frame = self.transform(frame)
# add the frame to the queue
self.Q.put(frame)
self.Q.put((frame, count))
count = count+1
else:
time.sleep(0.1) # Rest for 10ms, we have a full queue
......@@ -111,4 +113,4 @@ class FileVideoStream:
# indicate that the thread should be stopped
self.stopped = True
# wait until stream resources are released (producer thread might be still grabbing frame)
self.thread.join()
\ No newline at end of file
self.thread.join()
This diff is collapsed.
numpy
numpy==1.23.1
pymongo
opencv-python
cachetools
......@@ -14,4 +14,5 @@ tqdm
torch==1.9.0
torchvision==0.10.0
pandas
seaborn
\ No newline at end of file
seaborn
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
import cv2
np.seterr(divide='ignore', invalid='ignore')
class Box:
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