From 7b8a0f746c16445f3cf52f670de1eb7428f33828 Mon Sep 17 00:00:00 2001 From: Sai Subhakar T <36569367+saimj7@users.noreply.github.com> Date: Sun, 27 Sep 2020 12:23:08 +0200 Subject: [PATCH] added config. --- README.md | 2 +- Run.py | 37 ++++++++----------------------------- mylib/config.py | 18 ++++++++++++++++++ requirements.txt | 11 ++--------- 4 files changed, 29 insertions(+), 39 deletions(-) create mode 100644 mylib/config.py diff --git a/README.md b/README.md index 2875621..9152212 100644 --- a/README.md +++ b/README.md @@ -61,7 +61,7 @@ python run.py --prototxt mobilenet_ssd/MobileNetSSD_deploy.prototxt --model mobi ``` ## Features -The following are some of the added features. Note: You can easily on/off them in the config options at the start of 'run.py': +The following are some of the added features. Note: You can easily on/off them in the config. options (mylib>config.py): diff --git a/Run.py b/Run.py index 03d17d0..98dbfef 100644 --- a/Run.py +++ b/Run.py @@ -3,36 +3,15 @@ from mylib.trackableobject import TrackableObject from imutils.video import VideoStream from imutils.video import FPS from mylib.mailer import Mailer +from mylib import config import time, schedule, csv import numpy as np -import argparse -import imutils -import time -import dlib -import cv2, datetime +import argparse, imutils +import time, dlib, cv2, datetime from itertools import zip_longest t0 = time.time() -#=============================================================================== -""" Optional features """ -#=============================================================================== -# Enter mail below to receive real-time email alerts -# e.g., 'email@gmail.com' -MAIL = '' - -# ON/OFF for mail feature. Enter True to turn on the email alert feature. -ALERT = False - -# Simple log to log the counting data -Log = False -# Auto run/Schedule the software to run at your desired time -Scheduler = False -# Auto stop the software after certain a time/hours -Timer = False -#=============================================================================== -#=============================================================================== - def run(): @@ -264,9 +243,9 @@ def run(): # if the limit exceeds, send an email alert people_limit = 10 if sum(x) == people_limit: - if ALERT: + if config.ALERT: print("[INFO] Sending email alert..") - Mailer().send(MAIL) + Mailer().send(config.MAIL) print("[INFO] Alert sent") to.counted = True @@ -303,7 +282,7 @@ def run(): cv2.putText(frame, text, (265, H - ((i * 20) + 60)), cv2.FONT_HERSHEY_SIMPLEX, 0.6, (255, 255, 255), 2) # Initiate a simple log to save data at end of the day - if Log: + if config.Log: datetimee = [datetime.datetime.now()] d = [datetimee, empty1, empty, x] export_data = zip_longest(*d, fillvalue = '') @@ -327,7 +306,7 @@ def run(): totalFrames += 1 fps.update() - if Timer: + if config.Timer: # Automatic timer to stop the live stream. Set to 8 hours (28800s). t1 = time.time() num_seconds=(t1-t0) @@ -353,7 +332,7 @@ def run(): ##learn more about different schedules here: https://pypi.org/project/schedule/ -if Scheduler: +if config.Scheduler: ##Runs for every 1 second #schedule.every(1).seconds.do(run) ##Runs at every day (9:00 am). You can change it. diff --git a/mylib/config.py b/mylib/config.py new file mode 100644 index 0000000..771cbee --- /dev/null +++ b/mylib/config.py @@ -0,0 +1,18 @@ +#=============================================================================== +""" Optional features config. """ +#=============================================================================== +# Enter mail below to receive real-time email alerts +# e.g., 'email@gmail.com' +MAIL = '' + +# ON/OFF for mail feature. Enter True to turn on the email alert feature. +ALERT = False + +# Simple log to log the counting data +Log = False +# Auto run/Schedule the software to run at your desired time +Scheduler = False +# Auto stop the software after certain a time/hours +Timer = False +#=============================================================================== +#=============================================================================== diff --git a/requirements.txt b/requirements.txt index 511609b..246730c 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,15 +1,8 @@ -smtplib -ssl -time schedule -csv numpy argparse imutils -time dlib -cv2 -datetime +opencv-python itertools -scipy -collections \ No newline at end of file +scipy \ No newline at end of file