As a continuation of the Izon camera hack //TODO: link to previous article, I wanted to detect if my dog was using the doggy door in the main room. The approach was going to be simple at first, detect the dog in the room and not in the room. When in the room changes (or not in the room), upload 10 seconds worth of images to Azure to see if the dog used the door.
To detect the dog, the first and largest challenge to these types of tasks is getting enough images to train the model. For me, this meant saving images of the dog in a pre-aligned shot. This is easy enough to accomplish; the room the images will be processed in should only have the dog moving in it. Since he is the only moving object, YOLO can be used to detect the position of objects in the room and then the position of these objects can be checked to see if there is any movement. If there is any movement, the images can be saved for later categorization. To accomplish this, there will be four modules:
- Camera Module – Accesses the camera feeds to save the images
- Object Detection Module – Uses YOLO to detect object and object positions
- Motion Detection Module – Uses Stream Analytics Service to detect if object positions are moving.
- Image Storage Module – Uses Blob Storage so save and delete the images
The Camera module will send the timestamped images to the Object Detection Module and the Image Storage Module. The Object Detection Module will then use YOLO to detect the objects and their positions in the image. Those detection results will be sent to the Motion Detection Module, which will use Streaming Analytics Service to see if there was motion detected over the last ten seconds. If there is no motion detected over the last ten seconds, then the Motion Detection Module will send a delete command to the Image Storage Module to remove the image without motion from the store. The routing Table will look as so:
|"cameraToObjectDetection": "FROM /messages/modules/camera/outputs/imageOutput INTO BrokeredEndpoint(\"/modules/objectDetection/inputs/incomingImages\")",|
|"cameraToImageStorage": "FROM /messages/modules/camera/outputs/imageOutput INTO BrokeredEndpoint(\"/modules/imageStorage/inputs/incomingImages\")",|
|"objectDetectionToMotionDetection": "FROM /messages/modules/objectDetection/outputs/objectDetectionOutput INTO BrokeredEndpoint(\"/modules/motionDetection/inputs/incomingObjectDetection\")",|
|"motionDetectionToDeleteImage": "FROM /messages/modules/motionDetection/outputs/motionDetectionOutput INTO BrokeredEndpoint(\"/modules/imageStorage/inputs/deleteImages\")"|
These modules will be broken up into their own articles for readability and searchability. If there is no link to a module article it is because that article is not completed or is not published yet.