mirror of
https://github.com/rendies/People-Counting-in-Real-Time.git
synced 2025-07-01 22:29:17 +07:00
added config.
This commit is contained in:
parent
bd4bcfd8c1
commit
7b8a0f746c
|
@ -61,7 +61,7 @@ python run.py --prototxt mobilenet_ssd/MobileNetSSD_deploy.prototxt --model mobi
|
||||||
```
|
```
|
||||||
|
|
||||||
## Features
|
## 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):
|
||||||
|
|
||||||
<img src="https://imgur.com/9hw1NP0.png" width=500>
|
<img src="https://imgur.com/9hw1NP0.png" width=500>
|
||||||
|
|
||||||
|
|
37
Run.py
37
Run.py
|
@ -3,36 +3,15 @@ from mylib.trackableobject import TrackableObject
|
||||||
from imutils.video import VideoStream
|
from imutils.video import VideoStream
|
||||||
from imutils.video import FPS
|
from imutils.video import FPS
|
||||||
from mylib.mailer import Mailer
|
from mylib.mailer import Mailer
|
||||||
|
from mylib import config
|
||||||
import time, schedule, csv
|
import time, schedule, csv
|
||||||
import numpy as np
|
import numpy as np
|
||||||
import argparse
|
import argparse, imutils
|
||||||
import imutils
|
import time, dlib, cv2, datetime
|
||||||
import time
|
|
||||||
import dlib
|
|
||||||
import cv2, datetime
|
|
||||||
from itertools import zip_longest
|
from itertools import zip_longest
|
||||||
|
|
||||||
t0 = time.time()
|
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():
|
def run():
|
||||||
|
|
||||||
|
@ -264,9 +243,9 @@ def run():
|
||||||
# if the limit exceeds, send an email alert
|
# if the limit exceeds, send an email alert
|
||||||
people_limit = 10
|
people_limit = 10
|
||||||
if sum(x) == people_limit:
|
if sum(x) == people_limit:
|
||||||
if ALERT:
|
if config.ALERT:
|
||||||
print("[INFO] Sending email alert..")
|
print("[INFO] Sending email alert..")
|
||||||
Mailer().send(MAIL)
|
Mailer().send(config.MAIL)
|
||||||
print("[INFO] Alert sent")
|
print("[INFO] Alert sent")
|
||||||
|
|
||||||
to.counted = True
|
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)
|
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
|
# Initiate a simple log to save data at end of the day
|
||||||
if Log:
|
if config.Log:
|
||||||
datetimee = [datetime.datetime.now()]
|
datetimee = [datetime.datetime.now()]
|
||||||
d = [datetimee, empty1, empty, x]
|
d = [datetimee, empty1, empty, x]
|
||||||
export_data = zip_longest(*d, fillvalue = '')
|
export_data = zip_longest(*d, fillvalue = '')
|
||||||
|
@ -327,7 +306,7 @@ def run():
|
||||||
totalFrames += 1
|
totalFrames += 1
|
||||||
fps.update()
|
fps.update()
|
||||||
|
|
||||||
if Timer:
|
if config.Timer:
|
||||||
# Automatic timer to stop the live stream. Set to 8 hours (28800s).
|
# Automatic timer to stop the live stream. Set to 8 hours (28800s).
|
||||||
t1 = time.time()
|
t1 = time.time()
|
||||||
num_seconds=(t1-t0)
|
num_seconds=(t1-t0)
|
||||||
|
@ -353,7 +332,7 @@ def run():
|
||||||
|
|
||||||
|
|
||||||
##learn more about different schedules here: https://pypi.org/project/schedule/
|
##learn more about different schedules here: https://pypi.org/project/schedule/
|
||||||
if Scheduler:
|
if config.Scheduler:
|
||||||
##Runs for every 1 second
|
##Runs for every 1 second
|
||||||
#schedule.every(1).seconds.do(run)
|
#schedule.every(1).seconds.do(run)
|
||||||
##Runs at every day (9:00 am). You can change it.
|
##Runs at every day (9:00 am). You can change it.
|
||||||
|
|
18
mylib/config.py
Normal file
18
mylib/config.py
Normal file
|
@ -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
|
||||||
|
#===============================================================================
|
||||||
|
#===============================================================================
|
|
@ -1,15 +1,8 @@
|
||||||
smtplib
|
|
||||||
ssl
|
|
||||||
time
|
|
||||||
schedule
|
schedule
|
||||||
csv
|
|
||||||
numpy
|
numpy
|
||||||
argparse
|
argparse
|
||||||
imutils
|
imutils
|
||||||
time
|
|
||||||
dlib
|
dlib
|
||||||
cv2
|
opencv-python
|
||||||
datetime
|
|
||||||
itertools
|
itertools
|
||||||
scipy
|
scipy
|
||||||
collections
|
|
Loading…
Reference in New Issue
Block a user