Commit dc01eb99 authored by Sikhin VC's avatar Sikhin VC

added datetime change API

parent 86f18c39
Pipeline #69354 canceled with stage
...@@ -36,6 +36,9 @@ MONGO_URI_ADD_EVENTLOGS = CONFIG_ENV.get('MONGO_URI',None) ...@@ -36,6 +36,9 @@ MONGO_URI_ADD_EVENTLOGS = CONFIG_ENV.get('MONGO_URI',None)
url = GET_JANUS_DETAILS + DEPLOYMENT_ID url = GET_JANUS_DETAILS + DEPLOYMENT_ID
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"]
date_url = "http://192.168.3.181/camera_api/get_curr_datetime"
DATE_TIME = requests.get(date_url).json()["current_time"]
if not LAST_COUNT: if not LAST_COUNT:
LAST_COUNT = 0 LAST_COUNT = 0
DEVICE_ID = EDGE_CONFIG["deviceId"] DEVICE_ID = EDGE_CONFIG["deviceId"]
......
...@@ -13,9 +13,12 @@ from scripts.utils.image_utils import draw_circles_on_frame ...@@ -13,9 +13,12 @@ from scripts.utils.image_utils import draw_circles_on_frame
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, MONGO_URI_ADD_EVENTLOGS from edge_engine.common.config import EDGE_CONFIG, LAST_COUNT, MONGO_URI_ADD_EVENTLOGS, DATE_TIME
import requests import requests
from uuid import uuid1 from uuid import uuid1
import ctypes
import ctypes.util
import time
class CementBagCounter(ModelWrapper): class CementBagCounter(ModelWrapper):
...@@ -55,7 +58,36 @@ class CementBagCounter(ModelWrapper): ...@@ -55,7 +58,36 @@ class CementBagCounter(ModelWrapper):
self.frame_count = 0 self.frame_count = 0
self.frame = None self.frame = None
self.centroid_distance = 10 self.centroid_distance = 10
self.set_time(DATE_TIME)
def set_time(self, time_tuple):
# /usr/include/linux/time.h:
#
# define CLOCK_REALTIME 0
CLOCK_REALTIME = 0
# /usr/include/time.h
#
# struct timespec
# {
# __time_t tv_sec; /* Seconds. */
# long int tv_nsec; /* Nanoseconds. */
# };
class timespec(ctypes.Structure):
_fields_ = [("tv_sec", ctypes.c_long),
("tv_nsec", ctypes.c_long)]
librt = ctypes.CDLL(ctypes.util.find_library("rt"))
ts = timespec()
ts.tv_sec = int( time.mktime( datetime.datetime( *time_tuple[:6]).timetuple() ) )
ts.tv_nsec = time_tuple[6] * 1000000 # Millisecond to nanosecond
# http://linux.die.net/man/3/clock_settime
librt.clock_settime(CLOCK_REALTIME, ctypes.byref(ts))
logger.info(f"Time set to {DATE_TIME}")
def _pre_process(self, x): def _pre_process(self, x):
""" """
Do preprocessing here, if any Do preprocessing here, if any
......
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