&B57~?5B
#PJ7~~~~~~~7JG#
&GY7~~~~~~~~~~~~^~~7YG&
&B5?!~^~~~~~~~~~~~~~~~~~^~!?5B&
#PJ!~^~~~~~~~~~!!7?J7!~~~~~~~~~^~!JP#
#GY7~^~~~~~~~~~!!77777?JJJJ?7!~~~~~~~~~^~7YB
&B5?~~^~~~~~~~~~!777777777?JJJJJJJJ?7!~~~~~~!!!?
PJ!~^~~~~~~~~~!!777777777777JYJJJJJJJJJJJ?!!77777J
J?7!!~~~~~!!7777777777777777G #G5YJJJJJJJJJ777777?
JJJJJ?7!777777777777?7777777P &#P5JJJJJJ77777?5
JJJJJJJ?777777777??JJ?777777G &BPYJ?7?YP#&
PYJJJJJ77777?YJJJJJJJ?77777!J#& #GB&
#G5YJ77JPB& 5JJJJJJ?77!!~~~~!JP#
5JJJJJJJJJ?7!~~~~!!7!5
5JJJJJJJJJJJJ?77777775
5JJJJJJJJJJJJJ?77777!5
5JJJJJJ??JJJJJ?7777J5#
5JJJJJJ?777??J??5G#
5JJJJJJ?777777P
5JJJJJJ?777777G
5JJJJJJ?777777P
5JJJJJJ?77777!G
&BPYJJJ?777J5B&
#G5JYG#
_____ _____ _______ _____ _____ _____ _____
/\ \ /\ \ /::\ \ /\ \ /\ \ /\ \ /\ \
/::\ \ /::\ \ /::::\ \ /::\ \ /::\ \ /::\ \ /::\ \
/::::\ \ /::::\ \ /::::::\ \ \:::\ \ /::::\ \ /::::\ \ \:::\ \
/::::::\ \ /::::::\ \ /::::::::\ \ \:::\ \ /::::::\ \ /::::::\ \ \:::\ \
/:::/\:::\ \ /:::/\:::\ \ /:::/~~\:::\ \ \:::\ \ /:::/\:::\ \ /:::/\:::\ \ \:::\ \
/:::/__\:::\ \ /:::/__\:::\ \ /:::/ \:::\ \ \:::\ \ /:::/__\:::\ \ /:::/ \:::\ \ \:::\ \
/::::\ \:::\ \ /::::\ \:::\ \ /:::/ / \:::\ \ /::::\ \ /::::\ \:::\ \ /:::/ \:::\ \ /::::\ \
/::::::\ \:::\ \ /::::::\ \:::\ \ /:::/____/ \:::\____\ _____ /::::::\ \ /::::::\ \:::\ \ /:::/ / \:::\ \ /::::::\ \
/:::/\:::\ \:::\____\ /:::/\:::\ \:::\____\ |:::| | |:::| | /\ \ /:::/\:::\ \ /:::/\:::\ \:::\ \ /:::/ / \:::\ \ /:::/\:::\ \
/:::/ \:::\ \:::| |/:::/ \:::\ \:::| ||:::|____| |:::| |/::\ /:::/ \:::\____\/:::/__\:::\ \:::\____\/:::/____/ \:::\____\ /:::/ \:::\____\
\::/ \:::\ /:::|____|\::/ |::::\ /:::|____| \:::\ \ /:::/ / \:::\ /:::/ \::/ /\:::\ \:::\ \::/ /\:::\ \ \::/ / /:::/ \::/ /
\/_____/\:::\/:::/ / \/____|:::::\/:::/ / \:::\ \ /:::/ / \:::\/:::/ / \/____/ \:::\ \:::\ \/____/ \:::\ \ \/____/ /:::/ / \/____/
\::::::/ / |:::::::::/ / \:::\ /:::/ / \::::::/ / \:::\ \:::\ \ \:::\ \ /:::/ /
\::::/ / |::|\::::/ / \:::\__/:::/ / \::::/ / \:::\ \:::\____\ \:::\ \ /:::/ /
\::/____/ |::| \::/____/ \::::::::/ / \::/ / \:::\ \::/ / \:::\ \ \::/ /
~~ |::| ~| \::::::/ / \/____/ \:::\ \/____/ \:::\ \ \/____/
|::| | \::::/ / \:::\ \ \:::\ \
\::| | \::/____/ \:::\____\ \:::\____\
\:| | ~~ \::/ / \::/ /
\|___| \/____/ \/____/
1.Set up and install TensorFlow and OpenCV on your Raspberry Pi by following this great guide by Evan https://github.com/EdjeElectronics/TensorFlow-Object-Detection-on-the-Raspberry-Pi/blob/master/Object_detection_picamera.py The guide walks through the following steps:
2. Make sure your camera is configured by following these instructions https://www.raspberrypi.org/documentation/configuration/camera.md
3. Download or clone this Repo and put the open_cv_group_detection.py in your /object_detection directory
- Select a custom model and number of objects (as described in the repo referenced in step 1).
For this example I used the same coco model as the boilerplate code but depending on what you want to detect and how accurate you need the model to be, other models can be easily referenced in the code instead. Check out https://github.com/tensorflow/models/blob/master/research/object_detection/g3doc/detection_model_zoo.md for more resources or have a go at training your own model if you have the necessary hardware https://github.com/EdjeElectronics/TensorFlow-Object-Detection-API-Tutorial-Train-Multiple-Objects-Windows-10.
- Select which objects to include in the log file
# with details of each of the objects meeting the threshold in a given frame.
Validobj = [category_index.get(value) for index, value in enumerate (classes[0]) if scores [0,index]>0.5]
# Choose your object
to_detect = 'person'
-
Select which criteria to apply for logging in the evidence stamp
# Creates a log if the chosen object has been detected. if Validobj: data = [i["name"] for i in Validobj] # If in the given frame the number of a given object detected meets the condition then a log is made if data.count(to_detect)>2: # Writes a line with how many of the object was detected along with a timestamp Summary = ["There is a group of " + str(data.count(to_detect)) + " people" ,time.ctime()] print(Summary) evidence_stamp = [data.count(to_detect),to_detect,time.ctime()] output.append(evidence_stamp)
-
Specify the save location for the log file and image captures (by default this is the working directory). The log file includes a column for number of objects, object type and timestamp. See evidence.bmp for a sample image capture and output.png for a sample log file.