This work implements a prototype of 3D person surveillance, which fuses all camera views into one consistent 3D scene. In the offline stage, 3D reconstruction of the experiment environment is performed and surveillance cameras are calibrated. In the online stage, the positions of persons are updated using object tracking algorithm, and new persons are added to the tracking list at certain frequency, by comparing the detection and tracking results. Before they are tracked, their identities (person id) are queried using person re-id algorithm. Finally all tracked persons are back-projected into the reconstructed 3D environment model as a textured rectangle, and the 3D scene containing both environment and persons are rendered in a separated thread.
We choose SSD as our person detector.
To obtain only person detections with confidence higher than certain threshold, we should modify main function in the example script caffe/examples/ssd/ssd_detect.py
appropriately:
-
Set confidence threshold
conf_thresh
when callingdetect
method (we set it to 0.3 in our settings). -
In the iteration section, compare
item[-1]
with stringperson
to filter out detections of other categories.
Our tracking algorithm is an improvement to original multi-scale KCF, while person re-id algorithm is based on trinet features. In order to integrate tracking and re-id, we decide to use Python in the top level, so we need a Python wrapper for the tracking algorithm which is originally implemented in C++. It is achieved using Cython.
-
OpenCV for C++ & for Python3
-
Python packages: numpy, matplotlib, tensorflow
-
Compile python extensions for KCF. The directory
tracking/KCF_source
contains C++ source code of KCF, while directorytracking/KCF_wrapper
contains necessary files to compile python extensions. In the latter directory,python/KCF.pyx
defines a python wrapper class for original C++ classKCFTracker
, andsetup.py
sets required paths, such as OpenCV library path. If interface ofKCFTracker
is modified, the definition of its wrapper class should be modified accordingly. And the paths inpython/KCF.pyx
andsetup.py
should be set according to your environment. After all necessary changes are made, just compile the extensions bypython setup.py build_ext --inplace
(If you don't want to compile it yourself, you can simply copy the compiled extensions intracking/KCF_wrapper/build/lib.win-amd64-3.6/
to python library directory). -
Download the network weights of trinet and unzip it. Next create a new directory
checkpoint
insidetracking/trinet
, and put the unzipped files in it. -
Set all required paths in script
tracking/run.py
and just typepython run.py
to execute the program.
The rendering of 3D scene is implemented using a C++ 3D graphics library called OSG (OpenSceneGraph).
It is easy to compile and run it in visual studio, just by adding those sources in rendering
directory into an empty VS project. Note the paths to those required third-party libraries should be set in VS, and paths to dynamic link libraries of OSG (including thrid-party dlls) should be added to SYSTEM PATH.