Skip to content
This repository has been archived by the owner on Jan 1, 2023. It is now read-only.

Commit

Permalink
Merge pull request #1 from norkator/Feature/person-detection
Browse files Browse the repository at this point in the history
Feature/person detection
  • Loading branch information
norkator authored Jan 6, 2020
2 parents 6a0d139 + 70416af commit 018d55d
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 8 deletions.
10 changes: 7 additions & 3 deletions App.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,13 @@ def app():
# Analyze image objects
for image_object in image_file_objects:
try:
result = object_detection.analyze_image(image_object, configparser.app_config()['movetoprocessed'] == 'True')
result = object_detection.analyze_image(
image_object,
configparser.app_config()['move_to_processed'] == 'True',
configparser.app_config()['use_database'] == 'True'
)
except:
print('')
print('object_detection.analyze_image exception')


# ---------------------------------------------------------------------
Expand All @@ -51,7 +55,7 @@ def main_loop():
while 1:
app()
print('... running')
time.sleep(10)
time.sleep(int(configparser.app_config()['process_sleep_seconds']))


if __name__ == '__main__':
Expand Down
43 changes: 43 additions & 0 deletions Person.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import os
from module import fileutils, person_detection, configparser
from objects import File

# Configure input image folder
image_folders = [
os.getcwd() + '/output/person/',
]


def app():
# Image objects stored here
image_file_objects = []

# Create image objects
for image_folder in image_folders:
# Check for 'processed' folder existence
fileutils.create_directory(image_folder + 'processed/')
# Process files
for file_name in fileutils.get_camera_image_names(image_folder):
gm_time = fileutils.get_file_create_time(image_folder, file_name)
file = File.File(
image_folder,
file_name,
fileutils.get_file_extension(image_folder, file_name),
fileutils.get_file_create_year(gm_time),
fileutils.get_file_create_month(gm_time),
fileutils.get_file_create_day(gm_time),
fileutils.get_file_create_hour(gm_time),
fileutils.get_file_create_minute(gm_time),
fileutils.get_file_create_second(gm_time)
)
image_file_objects.append(file)

# Analyze image objects
for image_object in image_file_objects:
try:
person_detection.analyze_image(
image_object,
configparser.app_config()['movetoprocessed'] == 'True'
)
except:
print('')
11 changes: 6 additions & 5 deletions module/object_detection.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
output_path = os.getcwd() + '/output/'


def analyze_image(image_object, bool_move_processed):
def analyze_image(image_object, bool_move_processed, bool_use_database):
try:
# Load Yolo
net = cv2.dnn.readNet(models_path + "yolov3.weights", models_path + "yolov3.cfg")
Expand Down Expand Up @@ -85,10 +85,11 @@ def analyze_image(image_object, bool_move_processed):
except:
print('exception imwrite')

try:
database.insert_value(label, image_object.file_name)
except:
print('exception database insert')
if bool_use_database:
try:
database.insert_value(label, image_object.file_name)
except:
print('exception database insert')

# Move processed image
if bool_move_processed:
Expand Down
8 changes: 8 additions & 0 deletions module/person_detection.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import os

# Paths
person_path = os.getcwd() + '/output/person/'


def analyze_image(image_object, bool_move_processed):
print('run...')

0 comments on commit 018d55d

Please # to comment.