''' start a thread capture frames save frames to redis server ''' import sys import traceback from queue import Queue from threading import Thread import threading import cv2 as cv import logging import datetime import time # sys.path.append('../') from utils_ken.log.getlog import get_logger log_cam = get_logger(logname="cam", logfile='./logs/cam.log') class RecapVideoStream(): ''' Instance used to capture video's frames ''' def __init__(self, cam_cfg): ''' Initialize new object for capturing Args: cam_cfg -> dict: information of camera (camera id, camera address, process fps, ...) Return: None
import os import sys sys.path.append('../') import datetime from openpyxl import Workbook from openpyxl import load_workbook from utils_ken.log.getlog import get_logger from utils.utils_mode_counter import POLYGON_COUNTER_IDS from utils.utils_mode_counter import COUNTER_ONEWAY_IDS logexcel = get_logger('excel','./logs/excel.log') def get_datetime() : currentDT = datetime.datetime.now().strftime("%Y/%m/%d") return currentDT # def rdf_get_datetime() : # now = datetime.datetime.now() # # str_time = now.strftime('%Y-%m-%d %H:%M:%S') # str_time = (datetime.datetime.now() - datetime.timedelta(minutes=2)).strftime('%Y-%m-%d %H:%M:%S') # # legend_db.info(str_time) # return str_time def get_hour() : currentHour = (datetime.datetime.now() - datetime.timedelta(minutes=2)).hour return currentHour def hour_from_test(hour_test) : hout_int = int(hour_test.split(":")[0])
import time import requests import math import random import numpy as np import threading import datetime from utils_ken.log.getlog import get_logger from utils import Conf logubidot_line = get_logger('ubidot', './logs/ubidot.log') class Api_Ubidots(): def __init__(self, conf): self.conf = conf self.token, self.machine, self.lat, self.lng = self.gettoken(self.conf) # ------------------------------------------- if self.lat is not None and self.lng is not None: self.send_postition(self.lat, self.lng) # ----------------------------------------------------------------------------------- # decode json to get token def gettoken(self, conf): # data_configs = Conf(conf) token = conf['ubidot_token'] machine = conf['machine'] lat = conf['lat']
import sys sys.path.append('../') import os import logging import datetime from utils_machine import videos_output from utils_ken.log.getlog import get_logger logging.basicConfig(level=logging.INFO, format='%(asctime)-12s : %(name)-5s : [%(levelname)-5s] : %(message)5s') clear_video = get_logger('clear_video_', './logs/clear_video_.log') # ROOT_PATH = '/home/ken/workspace/nano_package' # ------------------------------------------------------------------------------------ # pose video recored to server # ------------------------------------------------------------------------------------ def get_size(start_path): total_size = 0 list_file = [] for dirpath, dirnames, filenames in os.walk(start_path): for f in filenames: # print(filenames) fp = os.path.join(dirpath, f) # skip if it is symbolic link if not os.path.islink(fp): list_file.append(fp) total_size += os.path.getsize(fp)
import os import cv2 import numpy as np import datetime from utils_ken.log.getlog import get_logger """ This class will save small video at event have object action """ # ID for human log_video = get_logger('video_write', './logs/video_write.log') class SaveVideoHour: def __init__(self, url_folder, cam_id, No_Frame_Flow=60 * 15 * 20): self.cam_id = cam_id self.url = url_folder self._write = None self.No_Frame_Flow = No_Frame_Flow self.writing = False self.counterSkip = 0 self.hour_record = -1 def __create_writer(self): now = datetime.datetime.now() # date_folder = now.strftime('%Y-%m-%d') date_folder = now.strftime('%Y_%m_%d_%H_%M_%S') # Name folder video # folder_save = os.path.join(head_folder,date_folder)
from utils.utils_counter import Counter_Line2Way from utils.utils_label_xml import save_image from ubidots.utils_ubidots import Api_Ubidots from utils.utils_counter import Counter_Polygon from light.lightapi import ApiLight from detectmodel.tf_detector import TfDetector from detectmodel.tracker import Tracker from detectmodel.setting import * from detectmodel import func logcore = get_logger('core', './logs/core.log') if not os.path.exists(videos_output): logcore.info("os.makedirs : {}".format(videos_output)) os.makedirs(videos_output) if not os.path.exists(images_output): logcore.info("os.makedirs : {}".format(images_output)) os.makedirs(images_output) sent_db = False class Core(): def __init__(self, conf, camCfg, lockDetect, frame_out): '''
import time import requests import math import random import numpy as np import threading import datetime from utils_ken.log.getlog import get_logger from utils import Conf light = get_logger('light', './logs/light.log') class ApiLight(): def __init__(self, conf): self.conf = conf self.place_id, self.ip_machine = self.get_info(self.conf) # ------------------------------------------- # ----------------------------------------------------------------------------------- # decode json to get place_id def get_info(self, conf): # data_configs = Conf(conf) place_id = conf['placeId'] ip_machine = conf['ip_machine'] if place_id is None or ip_machine is None: raise "place_id or ip_machine error information"
from utils import Conf from queue import Queue from utils.utils_polygon import decode_note_counter from utils.utils_polygon import decode_note_polygon from flask import request from flask import redirect from flask import url_for from flask import session from datetime import timedelta import time import cv2 logruncv = get_logger('watchdog', './logs/watchdog.log') # initialize a flask object app = Flask(__name__) app.secret_key = "super secret key" app.permanent_session_lifetime = timedelta(minutes=5) myjsonfile = open('./jetson/jetson_config.json', 'r') jsondata = myjsonfile.read() obj = json.loads(jsondata) userJSON = str(obj['jetson_user']) passJSON = str(obj['jetson_pass']) frame_out = Queue(maxsize=4)