diff --git a/App.py b/App.py index c8a4764c..fd26a0fc 100644 --- a/App.py +++ b/App.py @@ -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') # --------------------------------------------------------------------- @@ -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__': diff --git a/Person.py b/Person.py new file mode 100644 index 00000000..7dc8aa1f --- /dev/null +++ b/Person.py @@ -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('') diff --git a/module/object_detection.py b/module/object_detection.py index a031a3df..8cbc70d9 100644 --- a/module/object_detection.py +++ b/module/object_detection.py @@ -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") @@ -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: diff --git a/module/person_detection.py b/module/person_detection.py new file mode 100644 index 00000000..9c0abeb5 --- /dev/null +++ b/module/person_detection.py @@ -0,0 +1,8 @@ +import os + +# Paths +person_path = os.getcwd() + '/output/person/' + + +def analyze_image(image_object, bool_move_processed): + print('run...')