Commit 6997fd7e authored by Sikhin VC's avatar Sikhin VC

added server API endpoints

parent 663fd942
Pipeline #69195 failed with stage
import os import os
# os.environ["config"]="{\"MONGO_VALUE\": \"jkv1_dba3e4e8\"}" # os.environ["config"]="{\"deployment ID\": \"jkv1_dba3e4e8\"}"
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 CementBagCounter from scripts import CementBagCounter
......
...@@ -30,10 +30,11 @@ if not os.path.isdir(BASE_LOG_PATH): ...@@ -30,10 +30,11 @@ if not os.path.isdir(BASE_LOG_PATH):
CONFIG_ENV = json.loads(os.environ.get('config', default=None)) CONFIG_ENV = json.loads(os.environ.get('config', default=None))
DEPLOYMENT_ID = CONFIG_ENV.get('MONGO_VALUE',None) DEPLOYMENT_ID = CONFIG_ENV.get('deployment ID',None)
GET_JANUS_DETAILS = CONFIG_ENV.get('GET_JANUS_DETAILS',None)
url = f'http://192.168.3.181/camera_api/custom/get_janus?deploymentId={DEPLOYMENT_ID}' MONGO_URI_ADD_EVENTLOGS = CONFIG_ENV.get('MONGO_URI_ADD_EVENTLOGS',None)
url = GET_JANUS_DETAILS + DEPLOYMENT_ID
print(url)
EDGE_CONFIG = requests.get(url).json()["data"] EDGE_CONFIG = requests.get(url).json()["data"]
LAST_COUNT = requests.get(url).json()["latest_count"] LAST_COUNT = requests.get(url).json()["latest_count"]
......
...@@ -19,7 +19,7 @@ from scripts.utils.infocenter import MongoLogger ...@@ -19,7 +19,7 @@ from scripts.utils.infocenter import MongoLogger
from scripts.utils.tracker import Tracker from scripts.utils.tracker import Tracker
from scripts.utils.yolov5_trt import YoloV5TRT from scripts.utils.yolov5_trt import YoloV5TRT
from scipy.optimize import linear_sum_assignment as linear_assignment from scipy.optimize import linear_sum_assignment as linear_assignment
from edge_engine.common.config import EDGE_CONFIG, LAST_COUNT from edge_engine.common.config import EDGE_CONFIG, LAST_COUNT, MONGO_URI_ADD_EVENTLOGS
import requests import requests
from uuid import uuid1 from uuid import uuid1
...@@ -328,8 +328,7 @@ class CementBagCounter(ModelWrapper): ...@@ -328,8 +328,7 @@ class CementBagCounter(ModelWrapper):
elif object_id in self.uncounted_objects: elif object_id in self.uncounted_objects:
self.uncounted_objects.pop(object_id, None) self.uncounted_objects.pop(object_id, None)
self.count += 1 self.count += 1
url = "http://192.168.3.181/camera_api/events/add_event" url = MONGO_URI_ADD_EVENTLOGS
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
......
# from scripts.common.constants import JanusDeploymentConstants
#
# import cv2
#
# from edge_engine.common.logsetup import logger
# #from scripts.common.config import MONGO_DB_OBJ, APP_MONGO_COLLECTION
# #from scripts.common.constants import JanusDeploymentConstants
#
#
# class Utilities:
#
# @classmethod
# def get_extra_fields(
# cls,
# device_id,
# ):
# _janus_deployment = MONGO_DB_OBJ[
# APP_MONGO_COLLECTION.get(JanusDeploymentConstants.JANUS_DEPLOYMENT_COLLECTION)].find_one(
# {JanusDeploymentConstants.DEPLOYMENT_ID: device_id}).get(
# JanusDeploymentConstants.EXTRA_FIELDS_KEY)
# if _janus_deployment is None:
# raise ValueError("Janus deployment configuration is not found/corrupted")
#
# _key_dictionary = dict()
# for each_field in _janus_deployment:
# _key_dictionary[each_field['key']] = each_field['value']
# return _key_dictionary
#
# @classmethod
# def get_direction(
# cls,
# device_id,
# ):
# logger.debug("Getting the direction from DB")
# return MONGO_DB_OBJ[APP_MONGO_COLLECTION.get(JanusDeploymentConstants.JANUS_DEPLOYMENT_COLLECTION)].find_one(
# {JanusDeploymentConstants.DEPLOYMENT_ID: device_id}).get(
# JanusDeploymentConstants.DIRECTION_KEY)
#
# @classmethod
# def set_direction(
# cls,
# device_id: str,
# direction: bool,
# ):
# logger.debug("Updating the direction in DB")
# updated_values = {"$set": {JanusDeploymentConstants.DIRECTION_KEY: direction}}
# MONGO_DB_OBJ[APP_MONGO_COLLECTION.get(JanusDeploymentConstants.JANUS_DEPLOYMENT_COLLECTION)].update_one(
# {JanusDeploymentConstants.DEPLOYMENT_ID: device_id}, updated_values)
#
# @classmethod
# def draw_circles_on_frame(
# cls,
# frame,
# point,
# radius=3,
# color=(255, 255, 255),
# thickness=1,
# ):
# """
# draw circle on the objects
# :param radius: radius of the circle
# :param frame: frame to draw on
# :param point: co-ordinate to draw on
# :param color: color of the circle
# :param thickness: thickness of the circle
# :return: frame
# """
# return cv2.circle(frame, tuple(point), radius, color, thickness)
#
# @classmethod
# def resize_to_64_64(
# cls,
# frame,
# ):
# """
# resize the from
# :param frame: frame
# :return: frame
# """
# return cv2.resize(frame, (64, 64))
#
#
# def get_extra_fields(device_id):
# # _janus_deployment = [
# # {
# # "type": "number",
# # "key": "x1",
# # "value": 1000
# # },
# # {
# # "type": "number",
# # "key": "y1",
# # "value": 0
# # },
# # {
# # "type": "number",
# # "key": "x2",
# # "value": 1001
# # },
# # {
# # "type": "number",
# # "key": "y2",
# # "value": 720
# # },
# # {
# # "type": "dropdown",
# # "key": "alignment",
# # "value": "vertical"
# # }
# # ]
# _janus_deployment = MONGO_DB_OBJ[APP_MONGO_COLLECTION.get(JanusDeploymentConstants.JANUS_DEPLOYMENT_COLLECTION)]. \
# find_one({JanusDeploymentConstants.DEPLOYMENT_ID: device_id}).get(JanusDeploymentConstants.EXTRA_FIELDS_KEY)
#
# if _janus_deployment is None:
# raise ValueError("Janus deployment configuration is not found/corrupted")
#
# _key_dictionary = dict()
# for each_field in _janus_deployment:
# _key_dictionary[each_field['key']] = each_field['value']
# return _key_dictionary
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