## Inspiration

A few months ago, a van drove into the sidewalk of Toronto and killed 10 people and injured 15. We wanted to find solution to help prevent and reduce the potential casualties when incidents like this occur so we decided to create IoT system that would aid the people who are most in need of help.

## What it does

We use computer vision technology to detect the presence of cars driving into a sidewalk. When detected, an audible alarm will trigger to alert people around the area so that they can hopefully avoid/get away from the vehicle. A SMS message will also trigger to notify people in the area that there is a potential danger on the sidewalks and to remain inside buildings to stay safe until cleared.

## How we built it

We used OpenCV and Tensorflow to classify objects in a video stream. When a Car was identified, it would send a real time message to a buzzer and to a local computer that would send an SMS message with stdlib's SMS function.

## Challenges we ran into

When initially developing the MVP, we thought we could use boundaries to detect when a car was on a sidewalk. This proved to be a bit more challenging than anticipated so we decided to change the requirements to simply detecting a car in the video stream as the camera can always just point at only the sidewalk as a prototype.

## Accomplishments that we're proud of

We completed the MVP and also added additional features like a front-end for local authorities to review for faster reaction time and a way to control the alarm systems.

## What we learned

OpenCV is not a simple program to learn especially when your developers are not familiar with the programming enviroment (Python) used. We also learned how to better design tasks so that they are less intimidating to the developers.

## What's next for SSS

The idea would be to use this technology to expand into illegal parking, shootings, asaults and other criminal offenses.

HackThe6IX - [SSS](https://github.com/Oscar-Kwan/ht6-SmartSurveillanceSystem) Smart Surveillance System -> Oscar Kwan, Tancred Yip, Timothy Wang

## Copyright

See [LICENSE] for details.

Copyright (c) 2018 [Oscar, Tancred, Timothy]
## Inspiration

We were inspired to create the project due to the increased frequency of accidents cause by impaired driving or medical emergencies occurring in the GTA. Below are some statistics from the Canadian Association of Chiefs of Police, which show the importance of mitigating motor vehicle accidents due to reckless driving/Accidents.

1. In 2016, the number of motor vehicle fatalities in Canada was 1,898, up 2% from 2015 (1,860).
2. 16% of serious injury collisions involved a drinking driver
3. In 2008, coroners’ testing showed that almost 40% of fatally injured drivers had been drinking
some amount of alcohol (HBD) prior to the collision.
4. In a 1965 study of California drivers whose medical conditions were known to the Department of Motor Vehicles, drivers with diabetes, epilepsy, cardiovascular disease (CVD), alcoholism and mental illness averaged twice as many crashes per 1,000,000 miles of driving, as compared to a control group without such conditions [Waller, 1965]

## What it does

Our python and OpenCV based application detects if a driver is not paying attention to the road by detecting the EAR. The threshold we used is 0.2 based on a paper written by TDr. Tereza Soukupova and Dr. Jan Cech from the Czech Technical University in Prague. Dr. Soukupova and Dr. Cech found that an average person who is paying attention will have an EAR of 0.2 - 0.25.

## How I built it

We already knew that we wanted to do something with computer vision and the rasberri pi 3 was perfect platform. We did reach about how we could make alarms systems and the Arduino was a chip we we're very familiar with and therefore it was easy to adapt into our one ideas. As for the software aspect of the application we used OpenCV and dlib to detect the EAR. First we used a webcam to monitor a video stream for a face using a pre-classified dataset from dlib.net. Subsequently, if a face is detected, the landmark detection was used to extract the eye regions and contour them on the frame. The EAR was then computed and if the EAR threshold dropped below 0.2 for 30 consecutive frames, then the driver will receive an alert.

## Challenges I ran into

A challenge that we ran into was how to make our program put an alert if a driver is not looking at the camera for 30 consecutive frames. We were able to solve this challenge by checking if the NumPy array holding the facial landmarks is empty.

## Accomplishments that I'm proud of

As a team, we are very proud that we were able to integrate software with hardware. Our team is comprised of one second year electrical engineering student, one computer engineering student at Ryerson University and two second year computer science students. We were able to effectively collaborate together and use each other's strength to develop our application.

Moreover, we are very proud that we were able to successfully use facial landmark techniques in order to detect the eye aspect ratio (EAR). This technique utilized a lot of the concepts we learned in our linear algebra classes such as finding the euclidean distance between 2D points.

## What I learned

The computer science students learned a lot about hardware. The computer science curriculum is very focused on software and theoretical aspects of computer architecture/operating systems. Thus, the computer science students were able to apply the theory to a practical project.

Furthermore, the team learned how to utilize multiple APIs such as the Google geocoding API. We also leveraged machine learning by using landmark detectors trained on the iBUG 300-W dataset. The face detector uses Histogram of Oriented Gradients (HOG) algorithm. HOG taught us about the importance of pre-processing a picture by grayscaling it and resizing the picture. We then learned about how we can use the EAR formula to find a threshold that would classify a driver as driving dangerously.

## What's next for DriveSafe

The next step is making DriveSafe a phone application that can be downloaded from the App Store and Google Play. Drivers can download the application on their personal mobile devices and mount their phone.
## Inspiration

We wanted to solve a unique problem we felt was impacting many people but was not receiving enough attention. With emerging and developing technology, we implemented neural network models to recognize objects and images, and converting them to an auditory output.

## What it does

XTS takes an **X** and turns it **T**o **S**peech.

## How we built it

We used PyTorch, Torchvision, and OpenCV using Python. This allowed us to utilize pre-trained convolutional neural network models and region-based convolutional neural network models without investing too much time into training an accurate model, as we had limited time to build this program.

## Challenges we ran into

While attempting to run the Python code, the video rendering and text-to-speech were out of sync and the frame-by-frame object recognition was limited in speed by our system's graphics processing and machine-learning model implementing capabilities. We also faced an issue while trying to use our computer's GPU for faster video rendering, which led to long periods of frustration trying to solve this issue due to backwards incompatibilities between module versions.

## Accomplishments that we're proud of

We are so proud that we were able to implement neural networks as well as implement object detection using Python. We were also happy to be able to test our program with various images and video recordings, and get an accurate output. Lastly we were able to create a sleek user-interface that would be able to integrate our program.

## What we learned

We learned how neural networks function and how to augment the machine learning model including dataset creation. We also learned object detection using Python.