👨👩👦👦
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import cv2 | |
from concurrent.futures import ThreadPoolExecutor | |
from redis import Redis | |
redis_cache = Redis('127.0.0.1') | |
class RealTimeTracking(object): | |
def __init__(self, src): | |
self.vdo = cv2.VideoCapture(self.args.input) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import warnings | |
from os import getenv | |
import sys | |
from os.path import dirname, abspath | |
sys.path.append(dirname(dirname(abspath(__file__)))) | |
import torch | |
from deep_sort import build_tracker | |
from detector import build_detector |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html lang="en"> | |
<head> | |
<title>Camera #1 </title> | |
</head> | |
<body> | |
<h1>Floor 2 </h1> | |
<img src="{{ url_for('video_feed') }}"> | |
</body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Configuring deep learning models parameters in dictionary variables. | |
""" | |
import sys | |
from os.path import dirname, abspath, isfile | |
sys.path.append(dirname(dirname(abspath(__file__)))) | |
from dotenv import load_dotenv | |
from utils.asserts import assert_in_env |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
This code handles the pedestrian detection service on specified camera. | |
Also provides stream images for clients. | |
""" | |
from os.path import join | |
from os import getenv, environ | |
from dotenv import load_dotenv | |
import argparse |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Label: | |
""" | |
For each bounding box there are various categories with confidences. Label class keeps track of that information. | |
""" | |
def __init__(self, category: str, confidence: float): | |
self.category = category | |
self.confidence = confidence | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class JsonParser: | |
def __init__(self, top_k_labels: int = 1): | |
self.frames = {} | |
self.video_details = dict(frame_width=None, | |
frame_height=None, | |
frame_rate=None, | |
video_name=None) | |
self.top_k_labels = top_k_labels |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import unittest | |
import sys | |
from unittest.case import TestCase | |
sys.path.append('../..') | |
from json_parser.json_parser import * | |
class TestFrame(TestCase): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def test_add_frame(self): | |
frames_ids = [1, 2, 3, 4, 5] | |
self.json_parser.set_top_k(0) | |
for frame_id in frames_ids: | |
self.json_parser.add_frame(frame_id) | |
output = self.json_parser.output() | |
output_ids = [frame['frame_id'] for frame in output['frames']] | |
for frame_id in frames_ids: | |
self.assertIn(frame_id, output_ids) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def set_top_k(self, value): | |
self.top_k_labels = value | |
def frame_exists(self, frame_id: int): | |
return frame_id in self.frames.keys() | |
def add_frame(self, frame_id: int): | |
# Use this function to add frames with index. | |
if not self.frame_exists(frame_id): | |
self.frames[frame_id] = Frame(frame_id) |
OlderNewer