IOT Cameras to Catch Drunk Driving

The Scenario

  • Drunk Driving is Extremely Difficult to catch 
  • Lots of cameras for traffic and speeding
    • Not used currently for drunk driving
    • Police look find drunk drivers by sending officers to look for them
  • Can take advantage of machine learning and data science

The Scenario

Camera

Camera

Camera

Camera

Cloud/Fog/Server/

Load Balancer

Desired Outcome

  • Fully Automated stream of data 
  • Reduce costs for governments (less police searching)
  • Improved accuracy/higher rate of success for catching possible drunk/reckless driving

Implementation

  • COAP Protocol  as the primary protocol
    • Similar to HTTP
    • Can add DTLS for security
  • Optimal for sending video
    • Needed an application level protocol

Implementation - Continued

  • Restrictions on Data Set
    • Couldn't find good dataset for traffic cameras
      • Need to collect from a continuous feed of publicly accessible traffic cameras. 
    • For this demo, from dashboard perspective
      • Possible scenario if we have cameras on cars (not likely given privacy laws
  • https://registry.opendata.aws/ford-multi-av-seasonal/

Implementation - Continued

  • Client - Cameras
    • Sends all images to server
    • Currently is command line; however, ideally this will be autonomous.
async def send_content(self, foldername):
    # gets the folder of images to send files
    folder = os.path.dirname(foldername)+foldername
    logging.log(logging.INFO, "Folder to send: " + folder)
    # Loop throuhg all files, and send the data. 
    for f in os.listdir(folder):
        fullpath = os.path.join(folder, f)
        context = await Context.create_client_context()
        with open (fullpath, "rb") as img:
            self.image = img.read()
            request = Message(code=POST, payload=self.image, uri="coap://localhost/api/1.0/receiveVideo")
            response = await context.request(request).response
            print("Result: %s\n%r" % (response.code, response.payload))

Implementation - Continued

  • Server - Cloud, Fog, etc
    • Reads all of the files it receives
    • Stores them
    • Later it will be used for processing by ML/data science algorithms.
    async def render_post(self, request):
        global imageType
        # Gets the current time and puts it in a specific format
        currentTime = datetime.datetime.now().strftime("-%Y-%m-%d-%H-%M-%S")
        logging.log(logging.INFO, "Current Time: " + currentTime)
        #makes directory if it doesn't exist (for receiving files)
        if not os.path.exists('receivedFiles'):
            os.makedirs('receivedFiles')
            logging.log(logging.INFO, "Created new folder for receiving files")
        
        # Constructs the file path and writes the file that it has received
        
        filename = "./receivedFiles/trafficVideo" + currentTime + ".png"
        logging.log(logging.INFO, "FileName: " + filename)
        logging.log(logging.DEBUG, str(request.payload))
        with open(filename, "wb") as f:
            try:
                f.write(request.payload)
                
                logging.log(logging.INFO, "Successfully wrote to file")
            except e:
                logging.log(logging.ERROR, e)

        # constructs and sends response message    
        return aiocoap.Message(code=aiocoap.CREATED, payload="File received".encode("utf-8"))

Demo

Improvements

  • Server
    • Object Detection (to detect driving behavior)
    • Requires use of Deep Neural Network 
  • Camera
    • Save bandwidth using MQTT to start/stop recording
      • Select few cameras will always be recording
    • Cameras don't necessarily have to be record and send data all the time
      • May require basic machine learning

Improvements - Continued

IOT Scenario - Cameras Detecting Drunk Driving

By Ragnar Security

IOT Scenario - Cameras Detecting Drunk Driving

  • 111