Object Detection Tutorial#

Run on Google Colab View source on GitHub Download notebook

Start EVA server#

We are reusing the start server notebook for launching the EVA server.

!wget -nc "https://raw.githubusercontent.com/georgia-tech-db/eva/master/tutorials/00-start-eva-server.ipynb"
%run 00-start-eva-server.ipynb
cursor = connect_to_server()
File '00-start-eva-server.ipynb' already there; not retrieving.

[  -z "$(lsof -ti:5432)" ] || kill -9 $(lsof -ti:5432)
nohup eva_server > eva.log 2>&1 &

WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv
Note: you may need to restart the kernel to use updated packages.

Download the Videos#

# Getting the video files
!wget -nc https://www.dropbox.com/s/k00wge9exwkfxz6/ua_detrac.mp4
# Getting the Yolo object detector
!wget -nc https://raw.githubusercontent.com/georgia-tech-db/eva/master/eva/udfs/yolo_object_detector.py
--2022-12-18 17:38:12--  https://www.dropbox.com/s/k00wge9exwkfxz6/ua_detrac.mp4
Resolving www.dropbox.com (www.dropbox.com)... 162.125.81.18, 2620:100:6031:18::a27d:5112
Connecting to www.dropbox.com (www.dropbox.com)|162.125.81.18|:443... connected.
HTTP request sent, awaiting response... 302 Found
Location: /s/raw/k00wge9exwkfxz6/ua_detrac.mp4 [following]
--2022-12-18 17:38:14--  https://www.dropbox.com/s/raw/k00wge9exwkfxz6/ua_detrac.mp4
Reusing existing connection to www.dropbox.com:443.
HTTP request sent, awaiting response... 302 Found
Location: https://ucc182f7290bf0f438c01b8fc207.dl.dropboxusercontent.com/cd/0/inline/By37SE7JfGI9ZH1VKwVKYxa0-Asp7zMnwk4ZDt5wCtUiFDTf56SBzPl1l-tjPlWUUpBM-7aoMOiHeLHG4Wm9IyY2q8dD5A9wO77NbHxJhIEnxmRXCLMqHXaIIamCY1bxRRJoBsx8H-K0XupGg-5VwbVL4NA4xufvjpraiqjb2BmMmA/file# [following]
--2022-12-18 17:38:15--  https://ucc182f7290bf0f438c01b8fc207.dl.dropboxusercontent.com/cd/0/inline/By37SE7JfGI9ZH1VKwVKYxa0-Asp7zMnwk4ZDt5wCtUiFDTf56SBzPl1l-tjPlWUUpBM-7aoMOiHeLHG4Wm9IyY2q8dD5A9wO77NbHxJhIEnxmRXCLMqHXaIIamCY1bxRRJoBsx8H-K0XupGg-5VwbVL4NA4xufvjpraiqjb2BmMmA/file
Resolving ucc182f7290bf0f438c01b8fc207.dl.dropboxusercontent.com (ucc182f7290bf0f438c01b8fc207.dl.dropboxusercontent.com)... 162.125.81.15, 2620:100:6031:15::a27d:510f
Connecting to ucc182f7290bf0f438c01b8fc207.dl.dropboxusercontent.com (ucc182f7290bf0f438c01b8fc207.dl.dropboxusercontent.com)|162.125.81.15|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 1661565 (1.6M) [video/mp4]
Saving to: 'ua_detrac.mp4'

ua_detrac.mp4       100%[===================>]   1.58M   781KB/s    in 2.1s    

2022-12-18 17:38:19 (781 KB/s) - 'ua_detrac.mp4' saved [1661565/1661565]

File 'yolo_object_detector.py' already there; not retrieving.

Load the surveillance videos for analysis#

We use regular expression to load all the videos into the table#

cursor.execute('DROP TABLE ObjectDetectionVideos')
response = cursor.fetch_all()
print(response)
cursor.execute('LOAD VIDEO "*.mp4" INTO ObjectDetectionVideos;')
response = cursor.fetch_all()
print(response)
@status: ResponseStatus.SUCCESS
@batch: 
                                                    0
0  Table Successfully dropped: ObjectDetectionVideos
@query_time: 0.025422052000067197
@status: ResponseStatus.SUCCESS
@batch: 
                            0
0  Number of loaded VIDEO: 1
@query_time: 0.0706567309998718

Visualize Video#

from IPython.display import Video
Video("ua_detrac.mp4", embed=True)