Пример #1
0
import os
from pathlib import Path
import cv2
import numpy as np
import shutil
from module import database, detection_utils, configparser

# Paths
models_path = os.getcwd() + '/models/'
output_path = os.getcwd() + '/output/'
object_detection_image_path = os.getcwd() + '/output/object_detection/'

# Config
yolo_ignored_labels = str(
    configparser.any_config(section='yolo')['ignored_labels']).split(',')


def bool_label_is_ignored(label):
    for ignored_label in yolo_ignored_labels:
        if ignored_label == label:
            return True
    return False


def filter_negative_values(array_boxes):
    result = []
    for value in array_boxes:
        result.append(0 if value < 0 else value)
    return result
Пример #2
0
import os
from pathlib import Path
import cv2
import numpy as np
import shutil
from module import database, detection_utils, configparser

# Paths
models_path = os.getcwd() + '/models/'
output_path = os.getcwd() + '/output/'
object_detection_image_path = os.getcwd() + '/output/object_detection/'

# Config
yolo_ignored_labels = str(
    configparser.any_config(section='yolo')['ignored_labels']).split(',')
cv2_imshow_enabled = True if configparser.any_config(
    section='app')['cv2_imshow_enabled'] == 'True' else False
print('[Info] cv2_imshow_enabled is ' + str(cv2_imshow_enabled))


def bool_label_is_ignored(label):
    for ignored_label in yolo_ignored_labels:
        if ignored_label == label:
            return True
    return False


def filter_negative_values(array_boxes):
    result = []
    for value in array_boxes:
Пример #3
0
import os
import sys
from module import configparser, process_utils, database, detection_utils
from objects import SrFile
from pathlib import Path
import psycopg2
import time

super_resolution_config = configparser.any_config(filename=os.getcwd() +
                                                  '/config.ini',
                                                  section='super_resolution')
use_gpu = super_resolution_config['use_gpu'] == 'True'
if use_gpu is False:
    os.environ["CUDA_VISIBLE_DEVICES"] = "-1"
    print('GPU Disabled at config')
from libraries.fast_srgan import infer_oi
from module import gpu_utils
from module.vehicle_color import vehicle_color_detect

# Check does system has GPU support
print('GPU support available: ' + str(gpu_utils.is_gpu_available()))

# Parse configs
app_config = configparser.any_config(filename=os.getcwd() + '/config.ini',
                                     section='app')
process_sleep_seconds = app_config['process_sleep_seconds']
max_width = int(super_resolution_config['max_width'])
max_height = int(super_resolution_config['max_height'])

# Output path
output_root_folder_path = app_config['output_folder']
Пример #4
0
from pathlib import Path
from module import configparser
import numpy as np
import shutil
import imutils
import pickle
import cv2
import os

# App config
app_config = configparser.any_config(filename=os.getcwd() + '/config.ini', section='app')
output_root_folder_path = app_config['output_folder']

# Config
face_recognition_config = configparser.any_config(filename=os.getcwd() + '/config.ini', section='facerecognition')
file_name_prefix = str(face_recognition_config['file_name_prefix'])
cv2_imshow_enabled = True if configparser.any_config(section='app')['cv2_imshow_enabled'] == 'True' else False

# Paths
recognizer_path = None
label_encoder_path = None
output_faces_path = None
output_faces_dataset = None

# Set paths
output_root_path = face_recognition_config['output_root_path']
if str(output_root_path) == 'cwd':
    # Stock paths
    recognizer_path = output_root_folder_path + '/faces_models/' + 'recognizer.pickle'
    label_encoder_path = output_root_folder_path + '/faces_models/' + 'label_encoder.pickle'
    output_faces_path = output_root_folder_path + '/faces/'
Пример #5
0
import os
from datetime import datetime
from argparse import ArgumentParser
from module import fileutils, object_detection, configparser, actions, process_utils
from objects import File
import psycopg2
import sys
import time

# Config
app_config = configparser.any_config(filename=os.getcwd() + '/config.ini',
                                     section='app')
move_to_processed = app_config['move_to_processed'] == 'True'
process_sleep_seconds = int(app_config['process_sleep_seconds'])

# Get current time offset
ts = time.time()
utc_offset = (datetime.fromtimestamp(ts) -
              datetime.utcfromtimestamp(ts)).total_seconds()
time_offset_hours = int(utc_offset / 60 / 60)
print('Time offset: ' + str(time_offset_hours))

# Specify your names and folders at config.ini
# split them by a,b,c,d
names = ['App1']
folders = [os.getcwd() + '/images/']

# Process arguments
parser = ArgumentParser()
parser.add_argument(
    '--bool_slave_node',
Пример #6
0
from skimage.metrics import structural_similarity as ssim
from pathlib import Path
from module import configparser, database, process_utils
from objects import SrFile
import shutil
import os
import cv2
import sys
import time

# Parse configs
app_config = configparser.any_config(filename=os.getcwd() + '/config.ini',
                                     section='app')
similarity_config = configparser.any_config(filename=os.getcwd() +
                                            '/config.ini',
                                            section='similarity')
process_sleep_seconds = app_config['process_sleep_seconds']
delete_files = similarity_config['delete_files'] == 'True'

# Define paths
output_root_folder_path = os.getcwd() + '/output/'
test_move_path = output_root_folder_path + 'recycle/'

# Check directory existence
Path(test_move_path).mkdir(parents=True, exist_ok=True)

# Similarity level
similarity_level = 0.30


# Image compare process
Пример #7
0
import os
import psycopg2
from module import configparser
from argparse import ArgumentParser

# Process arguments
parser = ArgumentParser()
parser.add_argument('--bool_slave_node', type=str, help='Multi node support, give string True as input if slave.')
args = parser.parse_args()
if args.bool_slave_node == 'True':
    print('[INFO] Process running in slave mode!')

params = configparser.any_config(
    filename=os.getcwd() + ('/config_slave.ini' if args.bool_slave_node == 'True' else '/config.ini'),
    section='postgresql'
)


# connection = psycopg2.connect(**params)
# print(connection.get_backend_pid())


def db_connected():
    connection = psycopg2.connect(**params)
    try:
        cur = connection.cursor()
        cur.execute('SELECT 1')
        cur.close()
        return True
    except psycopg2.OperationalError:
        return False
from pathlib import Path
from module import configparser
import time
import os
import sys
import cv2

# Paths
grab_image_output_path = os.getcwd() + '/images/'

# Check folder existence
Path(grab_image_output_path).mkdir(parents=True, exist_ok=True)

# Config
sleep_seconds = float(
    configparser.any_config(section='streamgrab')['sleep_seconds'])
jpeg_stream_names = configparser.any_config(
    section='streamgrab')['jpeg_stream_names'].split(',')
steam_urls_config = configparser.any_config(
    section='streamgrab')['jpeg_streams'].split(',')


def grab():
    for stream_name, stream_url in zip(jpeg_stream_names, steam_urls_config):
        cap = cv2.VideoCapture(stream_url)
        ret, img = cap.read()

        # Create file name from date time
        now = datetime.now()
        output_file_name = str(stream_name + '_' +
                               now.strftime("%d_%m_%Y_%H_%M_%S") + '.jpg')
Пример #9
0
import os
from os import environ
from pathlib import Path
import imutils
from libraries.openalpr_64.openalpr import Alpr
from module import configparser
import numpy as np
import cv2
from objects import Plate

# Custom config
open_alpr_config = configparser.any_config(filename=os.getcwd() +
                                           '/config.ini',
                                           section='openalpr')

# Paths
car_labels_path = os.getcwd() + '/output/car/'
rotation_temp_images_path = os.getcwd() + '/output/rotation_temp/'
alpr_dir = os.getcwd() + '/libraries/openalpr_64'
open_alpr_conf = os.getcwd() + '/libraries/openalpr_64/openalpr.conf'
open_alpr_runtime_data = os.getcwd() + '/libraries/openalpr_64/runtime_data'


def detect_license_plate(input_image, file_name, use_rotation=False):
    try:

        if open_alpr_config['enabled'] == 'True':

            region = open_alpr_config['region']

            # Validate file path
Пример #10
0
from pathlib import Path
from module import configparser
import numpy as np
import shutil
import imutils
import pickle
import cv2
import os

# Config
face_recognition_config = configparser.any_config(filename=os.getcwd() +
                                                  '/config.ini',
                                                  section='facerecognition')
file_name_prefix = str(face_recognition_config['file_name_prefix'])

# Paths
recognizer_path = None
label_encoder_path = None
output_faces_path = None
output_faces_dataset = None

# Set paths
output_root_path = face_recognition_config['output_root_path']
if str(output_root_path) == 'cwd':
    # Stock paths
    recognizer_path = os.getcwd(
    ) + '/output/faces_models/' + 'recognizer.pickle'
    label_encoder_path = os.getcwd(
    ) + '/output/faces_models/' + 'label_encoder.pickle'
    output_faces_path = os.getcwd() + '/output/faces/'
    output_faces_dataset = os.getcwd() + '/output/faces_dataset/'
Пример #11
0
# Responsible for first and second stage object detection
# then sorts objects to specific categories (labels)
# which are in corresponding folders,
# makes database intelligence inserts

import os
from pathlib import Path
import cv2
import numpy as np
import shutil
from module import database, detection_utils, configparser

# App config
app_config = configparser.any_config(filename=os.getcwd() + '/config.ini',
                                     section='app')
output_root_folder_path = app_config['output_folder']

# Paths
models_path = os.getcwd() + '/models/'
output_path = output_root_folder_path
object_detection_image_path = output_root_folder_path + '/object_detection/'

# Config
yolo_ignored_labels = str(
    configparser.any_config(section='yolo')['ignored_labels']).split(',')
cv2_imshow_enabled = True if configparser.any_config(
    section='app')['cv2_imshow_enabled'] == 'True' else False
print('[Info] cv2_imshow_enabled is ' + str(cv2_imshow_enabled))


def bool_label_is_ignored(label):