Building tools to help create a system to prevent elephant poaching with Microsoft Cognitive Service

Published 04-23-2021 09:21 AM 737 Views
Microsoft

About Me

Chak.jfif

My name is Chak Koppula https://ckoppula199.github.io/ and I’m a 3rd year Computer Science student at University College London and have been working alongside Microsoft’s Project 15 team to help in creating a system to reduce the poaching of elephants.

Project Aims and Goals

The overall aim of the project is to create a system that utilises the Project 15 platform to identify and track the movement of elephants. The African elephant population has reduced by 20% in the past decade due to poaching meaning keeping track of them has become vital in preventing their numbers from further decreasing.

 

To help in the development of this system I made three tools:

  • A short script that takes videos of surveillance footage from Azure cloud storage and passes them to Azure Video Indexer to obtain quick insights into a video.
  • A camera trap simulator to make the development and prototyping of solutions using camera traps easier and quicker
  • A set of Machine Learning models to identify elephants from an image. The models vary from image classification to object detection with some made using TensorFlow and other using Azure Custom Vision

Source Code

ckoppula199/UCL-Microsoft-IXN-Final-Year-Project (github.com)

 

Video Indexer Analysis Script

The following Python script that takes videos of surveillance footage from Azure cloud storage and passes them to Azure Video Indexer to obtain quick insights into a video.

 

 

import requests
import os
import io
import json
import time

from azure.storage.blob import (
    ContentSettings,
    BlobBlock,
    BlockListType,
    BlockBlobService
)


# Load details from config file
with open('config.json', 'r') as config_file:
        config = json.load(config_file)

storage_account_name = config["storage_account_name"]
storage_account_key = config["storage_account_key"]
storage_container_name = config["storage_container_name"]

video_indexer_account_id = config["video_indexer_account_id"]
video_indexer_api_key = config["video_indexer_api_key"]
video_indexer_api_region = config["video_indexer_api_region"]

file_name = config["file_name"]

confidence_threshold = config["confidence_threshold"]

print('Blob Storage: Account: {}, Container: {}.'.format(storage_account_name,storage_container_name))

# Get File content from blob
block_blob_service = BlockBlobService(account_name=storage_account_name, account_key=storage_account_key)
audio_blob = block_blob_service.get_blob_to_bytes(storage_container_name, file_name)
audio_file = io.BytesIO(audio_blob.content).read()

print('Blob Storage: Blob {} loaded.'.format(file_name))

# Authorize against Video Indexer API
auth_uri = 'https://api.videoindexer.ai/auth/{}/Accounts/{}/AccessToken'.format(video_indexer_api_region,video_indexer_account_id)
auth_params = {'allowEdit':'true'}
auth_header = {'Ocp-Apim-Subscription-Key': video_indexer_api_key}
auth_token = requests.get(auth_uri,headers=auth_header,params=auth_params).text.replace('"','')

print('Video Indexer API: Authorization Complete.')
print('Video Indexer API: Uploading file: ',file_name)

# Upload Video to Video Indexer API
upload_uri = 'https://api.videoindexer.ai/{}/Accounts/{}/Videos'.format(video_indexer_api_region,video_indexer_account_id)
upload_header = {'Content-Type': 'multipart/form-data'}
upload_params = {
    'name':file_name,
    'accessToken':auth_token,
    'streamingPreset':'Default',
    'fileName':file_name,
    'description': '#testfile',
    'privacy': 'Private',
    'indexingPreset': 'Default',
    'sendSuccessEmail': 'False'}

files= {'file': (file_name, audio_file)}
r = requests.post(upload_uri,params=upload_params, files=files)
response_body = r.json()

print('Video Indexer API: Upload Completed.')
print('Video Indexer API: File Id: {}.'.format(response_body.get('id')))
video_id = response_body.get('id')

# Check if video is done processing
video_index_uri = 'https://api.videoindexer.ai/{}/Accounts/{}/Videos/{}/Index'.format(video_indexer_api_region, video_indexer_account_id, video_id)
video_index_params = {
    'accessToken': auth_token,
    'reTranslate': 'False',
    'includeStreamingUrls': 'True'
}
r = requests.get(video_index_uri, params=video_index_params)
response_body = r.json()

while response_body.get('state') != 'Processed':
    time.sleep(10)
    r = requests.get(video_index_uri, params=video_index_params)
    response_body = r.json()
    print(response_body.get('state'))

print("Done")

output_response = []
item_index = 1
for item in response_body.get('videos')[0]['insights']['labels']:
    reformatted_item = {}
    instances = []
    reformatted_item['id'] = item_index
    reformatted_item['label'] = item['name']
    for instance in item['instances']:
        reformatted_instance = {}
        if instance['confidence'] > confidence_threshold:
            reformatted_instance['confidence'] = instance['confidence']
            reformatted_instance['start'] = instance['start']
            reformatted_instance['end'] = instance['end']
            instances.append(reformatted_instance)
    if len(instances) > 0:
        item_index += 1
        reformatted_item['instances'] = instances
        output_response.append(reformatted_item)

#Print response given by the script
print(json.dumps(output_response, indent=4))

 

 


Demo

 

Camera Trap Simulator

The camera trap simulator allows users to simulate a real camera trap on their own computers and can even be run on devices such as a Raspberry Pi. It takes in a video feed and then uses a detection method over that video feed. If the detection method is triggered then it will send a message to Azure IoT hub. Once the data is in the cloud the user can test out their cloud paths and solutions as if the data had come from a real camera trap.

The camera trap can operate over both a live video feed such as a webcam or it can be used with a pre-recorded video feed. A video of the intended deployment area can be provided to the simulator to make the simulation more realistic, but for projects who don’t have access to videos of their deployment area, a live video feed may be fine for testing and development purposes.

 

The camera trap can use motion based detection or can utilise a Machine Learning model to more accurately identify points of interest within a video frame. Use of an ML model will reduce the number of false positives the systems gives and will be a more accurate.

 

MotionDetection.png

Above is an image showing the motion detection software running. It uses a method of motion detection known as foreground detection. The top left is the normal video feed, the top right is a greyscaled and blurred version of the video feed, the bottom left is the difference between the current frame and the reference frame and the bottom right is the final result showing any moving object in white.simulation but if an ML model isn’t available then motion detection can be used for testing and development purposes.

 

Demo 

 

 

 

Machine Learning Models

When creating the models there was difficulty in collecting a suitable dataset. Initially the plan was to use our own devices in the deployment area to create our own dataset of images to use for training purposes but due to time constraints and various blockers I ended up having to utilise a public dataset called Animals-10 from Kaggle which contained images of elephants among other animals.

 

I then created a set of image classification models using Python with TensorFlow and also created a set of object detection models using Azure Custom Vision services.

The first image classification model that was made used a very simple Convolutional Neural Network and achieved an accuracy of 77% on a test set. The second image classification model used a CNN architecture known as VGG-16 which performed much better with an accuracy of 97% on the test set. The confusion matrices for these two models can be seen below.

 

confusionmatrix.JPG

The object detection models made using Azure Custom Vision also achieved quite high results as shown below.

 

PPMap.png

The object detection model was only trained using around 130 images of elephants and managed to achieve the above metrics. More images weren’t used since when providing images for the object detection models to train on, you have to tag every occurrence of every object you want to model to identify which can be quite time consuming.

 

 

 

ElephantsViewDown.png

The object detection model ended up being able to identify most elephants in an image, struggling on in cases where elephants were obscured. In the above image you can see in the bottom middle of the image there is a single elephant hidden by bush the model didn’t quite manage to identify.

 

The conclusion that was reached was that for our use case object detection should be used. This is due to it not only saying if an image is of an elephant, but it providing the additional information of how many elephants are in the image and where in the image they are. This extra information that can’t be provided by image classification allows for more uses case to be fulfilled by the system later on. Azure custom vision was also chosen as the method to use as while TensorFlow is an incredible library allowing users to specify the exact architecture and hyperparameters that they want to use, it can take a long time to find the optimal setup and also requires more data to train on to achieve the same level of results produced by Azure Custom Vision. The ease of use and its ability to seamlessly work with other Azure services being used in the Project 15 platform make Azure Custom Vision the best choice for this project.

 

Demo 

 

Summary

Overall, the process of learning about cloud services and machine learning tools has been extremely enjoyable and getting the opportunity to apply what I learnt to a real world project like this has been an incredible experience. So if your interested in building a project to support Project 15 see Project 15 Open Platform for Conservation and Ecological Sustainability Solutions or if your new to this see the amazing resources to help get your started at Microsoft Learn.

 

 

%3CLINGO-SUB%20id%3D%22lingo-sub-2282777%22%20slang%3D%22en-US%22%3EBuilding%20tools%20to%20help%20create%20a%20system%20to%20prevent%20elephant%20poaching%20with%20Microsoft%20Cognitive%20Service%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2282777%22%20slang%3D%22en-US%22%3E%3CH2%20id%3D%22toc-hId--492878851%22%20id%3D%22toc-hId--492878851%22%3E%3CSTRONG%3EAbout%20Me%3C%2FSTRONG%3E%3C%2FH2%3E%0A%3CP%3E%3CSTRONG%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22Chak.jfif%22%20style%3D%22width%3A%20200px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F275039i0286B4D9DBA21CBE%2Fimage-size%2Fsmall%3Fv%3Dv2%26amp%3Bpx%3D200%22%20role%3D%22button%22%20title%3D%22Chak.jfif%22%20alt%3D%22Chak.jfif%22%20%2F%3E%3C%2FSPAN%3E%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3EMy%20name%20is%20%3CA%20href%3D%22https%3A%2F%2Fwww.linkedin.com%2Fin%2Fchak-koppula-b0691b146%2F%22%20target%3D%22_self%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%3EChak%20Koppula%3C%2FA%3E%20%3CA%20href%3D%22https%3A%2F%2Fckoppula199.github.io%2F%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noreferrer%22%3Ehttps%3A%2F%2Fckoppula199.github.io%2F%3C%2FA%3E%20and%20I%E2%80%99m%20a%203%3CSUP%3Erd%3C%2FSUP%3E%20year%20Computer%20Science%20student%20at%20University%20College%20London%20and%20have%20been%20working%20alongside%20%3CA%20href%3D%22https%3A%2F%2Fazure.microsoft.com%2Fen-gb%2Fresources%2Fvideos%2Fproject-15%2F%3FWT.mc_ID%3Dacademic-26142-leestott%22%20target%3D%22_self%22%20rel%3D%22noopener%20noreferrer%22%3EMicrosoft%E2%80%99s%20Project%2015%3C%2FA%3E%20team%20to%20help%20in%20creating%20a%20system%20to%20reduce%20the%20poaching%20of%20elephants.%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FP%3E%0A%3CH2%20id%3D%22toc-hId-1994633982%22%20id%3D%22toc-hId-1994633982%22%3E%3CSTRONG%3EProject%20Aims%20and%20Goals%3C%2FSTRONG%3E%3C%2FH2%3E%0A%3CP%3EThe%20overall%20aim%20of%20the%20project%20is%20to%20create%20a%20system%20that%20utilises%20the%20Project%2015%20platform%20to%20identify%20and%20track%20the%20movement%20of%20elephants.%20The%20African%20elephant%20population%20has%20reduced%20by%2020%25%20in%20the%20past%20decade%20due%20to%20poaching%20meaning%20keeping%20track%20of%20them%20has%20become%20vital%20in%20preventing%20their%20numbers%20from%20further%20decreasing.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ETo%20help%20in%20the%20development%20of%20this%20system%20I%20made%20three%20tools%3A%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3EA%20short%20script%20that%20takes%20videos%20of%20surveillance%20footage%20from%20Azure%20cloud%20storage%20and%20passes%20them%20to%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fazure%2Fmedia-services%2Fvideo-indexer%2F%3FWT.mc_ID%3Dacademic-26142-leestott%22%20target%3D%22_self%22%20rel%3D%22noopener%20noreferrer%22%3EAzure%20Video%20Indexer%3C%2FA%3E%20to%20obtain%20quick%20insights%20into%20a%20video.%3C%2FLI%3E%0A%3CLI%3EA%20camera%20trap%20simulator%20to%20make%20the%20development%20and%20prototyping%20of%20solutions%20using%20camera%20traps%20easier%20and%20quicker%3C%2FLI%3E%0A%3CLI%3E%3CP%3EA%20set%20of%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fazure%2Fmachine-learning%2F%3FWT.mc_ID%3Dacademic-26142-leestott%22%20target%3D%22_self%22%20rel%3D%22noopener%20noreferrer%22%3EMachine%20Learning%20models%3C%2FA%3E%20to%20identify%20elephants%20from%20an%20image.%20The%20models%20vary%20from%20image%20classification%20to%20object%20detection%20with%20some%20made%20using%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fazure%2Fmachine-learning%2Fhow-to-train-tensorflow%2F%3FWT.mc_ID%3Dacademic-26142-leestott%22%20target%3D%22_self%22%20rel%3D%22noopener%20noreferrer%22%3ETensorFlow%3C%2FA%3E%20and%20other%20using%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2F%2Flearn%2Fmodules%2Fclassify-images-with-custom-vision-service%2F%3FWT.mc_ID%3Dacademic-26142-leestott%22%20target%3D%22_self%22%20rel%3D%22noopener%20noreferrer%22%3EAzure%20Custom%20Vision%3C%2FA%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FP%3E%0A%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CH2%20id%3D%22toc-hId-187179519%22%20id%3D%22toc-hId-187179519%22%3ESource%20Code%3C%2FH2%3E%0A%3CP%3E%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2Fckoppula199%2FUCL-Microsoft-IXN-Final-Year-Project%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Eckoppula199%2FUCL-Microsoft-IXN-Final-Year-Project%20(github.com)%3C%2FA%3E%3C%2FP%3E%0A%3CH2%20id%3D%22toc-hId--1620274944%22%20id%3D%22toc-hId--1620274944%22%3E%26nbsp%3B%3C%2FH2%3E%0A%3CH2%20id%3D%22toc-hId-867237889%22%20id%3D%22toc-hId-867237889%22%3EVideo%20Indexer%20Analysis%20Script%3C%2FH2%3E%0A%3CP%3EThe%20following%20Python%20script%20that%20takes%20videos%20of%20surveillance%20footage%20from%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Flearn%2Fpaths%2Fstore-data-in-azure%2F%3FWT.mc_ID%3Dacademic-26142-leestott%22%20target%3D%22_self%22%20rel%3D%22noopener%20noreferrer%22%3E%20Azure%20cloud%20storage%3C%2FA%3E%20and%20passes%20them%20to%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fazure%2Fmedia-services%2Fvideo-indexer%2F%3FWT.mc_ID%3Dacademic-26142-leestott%22%20target%3D%22_self%22%20rel%3D%22noopener%20noreferrer%22%3EAzure%20Video%20Indexe%3C%2FA%3Er%20to%20obtain%20quick%20insights%20into%20a%20video.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-python%22%3E%3CCODE%3Eimport%20requests%0Aimport%20os%0Aimport%20io%0Aimport%20json%0Aimport%20time%0A%0Afrom%20azure.storage.blob%20import%20(%0A%20%20%20%20ContentSettings%2C%0A%20%20%20%20BlobBlock%2C%0A%20%20%20%20BlockListType%2C%0A%20%20%20%20BlockBlobService%0A)%0A%0A%0A%23%20Load%20details%20from%20config%20file%0Awith%20open('config.json'%2C%20'r')%20as%20config_file%3A%0A%20%20%20%20%20%20%20%20config%20%3D%20json.load(config_file)%0A%0Astorage_account_name%20%3D%20config%5B%22storage_account_name%22%5D%0Astorage_account_key%20%3D%20config%5B%22storage_account_key%22%5D%0Astorage_container_name%20%3D%20config%5B%22storage_container_name%22%5D%0A%0Avideo_indexer_account_id%20%3D%20config%5B%22video_indexer_account_id%22%5D%0Avideo_indexer_api_key%20%3D%20config%5B%22video_indexer_api_key%22%5D%0Avideo_indexer_api_region%20%3D%20config%5B%22video_indexer_api_region%22%5D%0A%0Afile_name%20%3D%20config%5B%22file_name%22%5D%0A%0Aconfidence_threshold%20%3D%20config%5B%22confidence_threshold%22%5D%0A%0Aprint('Blob%20Storage%3A%20Account%3A%20%7B%7D%2C%20Container%3A%20%7B%7D.'.format(storage_account_name%2Cstorage_container_name))%0A%0A%23%20Get%20File%20content%20from%20blob%0Ablock_blob_service%20%3D%20BlockBlobService(account_name%3Dstorage_account_name%2C%20account_key%3Dstorage_account_key)%0Aaudio_blob%20%3D%20block_blob_service.get_blob_to_bytes(storage_container_name%2C%20file_name)%0Aaudio_file%20%3D%20io.BytesIO(audio_blob.content).read()%0A%0Aprint('Blob%20Storage%3A%20Blob%20%7B%7D%20loaded.'.format(file_name))%0A%0A%23%20Authorize%20against%20Video%20Indexer%20API%0Aauth_uri%20%3D%20'https%3A%2F%2Fapi.videoindexer.ai%2Fauth%2F%7B%7D%2FAccounts%2F%7B%7D%2FAccessToken'.format(video_indexer_api_region%2Cvideo_indexer_account_id)%0Aauth_params%20%3D%20%7B'allowEdit'%3A'true'%7D%0Aauth_header%20%3D%20%7B'Ocp-Apim-Subscription-Key'%3A%20video_indexer_api_key%7D%0Aauth_token%20%3D%20requests.get(auth_uri%2Cheaders%3Dauth_header%2Cparams%3Dauth_params).text.replace('%22'%2C'')%0A%0Aprint('Video%20Indexer%20API%3A%20Authorization%20Complete.')%0Aprint('Video%20Indexer%20API%3A%20Uploading%20file%3A%20'%2Cfile_name)%0A%0A%23%20Upload%20Video%20to%20Video%20Indexer%20API%0Aupload_uri%20%3D%20'https%3A%2F%2Fapi.videoindexer.ai%2F%7B%7D%2FAccounts%2F%7B%7D%2FVideos'.format(video_indexer_api_region%2Cvideo_indexer_account_id)%0Aupload_header%20%3D%20%7B'Content-Type'%3A%20'multipart%2Fform-data'%7D%0Aupload_params%20%3D%20%7B%0A%20%20%20%20'name'%3Afile_name%2C%0A%20%20%20%20'accessToken'%3Aauth_token%2C%0A%20%20%20%20'streamingPreset'%3A'Default'%2C%0A%20%20%20%20'fileName'%3Afile_name%2C%0A%20%20%20%20'description'%3A%20'%23testfile'%2C%0A%20%20%20%20'privacy'%3A%20'Private'%2C%0A%20%20%20%20'indexingPreset'%3A%20'Default'%2C%0A%20%20%20%20'sendSuccessEmail'%3A%20'False'%7D%0A%0Afiles%3D%20%7B'file'%3A%20(file_name%2C%20audio_file)%7D%0Ar%20%3D%20requests.post(upload_uri%2Cparams%3Dupload_params%2C%20files%3Dfiles)%0Aresponse_body%20%3D%20r.json()%0A%0Aprint('Video%20Indexer%20API%3A%20Upload%20Completed.')%0Aprint('Video%20Indexer%20API%3A%20File%20Id%3A%20%7B%7D.'.format(response_body.get('id')))%0Avideo_id%20%3D%20response_body.get('id')%0A%0A%23%20Check%20if%20video%20is%20done%20processing%0Avideo_index_uri%20%3D%20'https%3A%2F%2Fapi.videoindexer.ai%2F%7B%7D%2FAccounts%2F%7B%7D%2FVideos%2F%7B%7D%2FIndex'.format(video_indexer_api_region%2C%20video_indexer_account_id%2C%20video_id)%0Avideo_index_params%20%3D%20%7B%0A%20%20%20%20'accessToken'%3A%20auth_token%2C%0A%20%20%20%20'reTranslate'%3A%20'False'%2C%0A%20%20%20%20'includeStreamingUrls'%3A%20'True'%0A%7D%0Ar%20%3D%20requests.get(video_index_uri%2C%20params%3Dvideo_index_params)%0Aresponse_body%20%3D%20r.json()%0A%0Awhile%20response_body.get('state')%20!%3D%20'Processed'%3A%0A%20%20%20%20time.sleep(10)%0A%20%20%20%20r%20%3D%20requests.get(video_index_uri%2C%20params%3Dvideo_index_params)%0A%20%20%20%20response_body%20%3D%20r.json()%0A%20%20%20%20print(response_body.get('state'))%0A%0Aprint(%22Done%22)%0A%0Aoutput_response%20%3D%20%5B%5D%0Aitem_index%20%3D%201%0Afor%20item%20in%20response_body.get('videos')%5B0%5D%5B'insights'%5D%5B'labels'%5D%3A%0A%20%20%20%20reformatted_item%20%3D%20%7B%7D%0A%20%20%20%20instances%20%3D%20%5B%5D%0A%20%20%20%20reformatted_item%5B'id'%5D%20%3D%20item_index%0A%20%20%20%20reformatted_item%5B'label'%5D%20%3D%20item%5B'name'%5D%0A%20%20%20%20for%20instance%20in%20item%5B'instances'%5D%3A%0A%20%20%20%20%20%20%20%20reformatted_instance%20%3D%20%7B%7D%0A%20%20%20%20%20%20%20%20if%20instance%5B'confidence'%5D%20%26gt%3B%20confidence_threshold%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20reformatted_instance%5B'confidence'%5D%20%3D%20instance%5B'confidence'%5D%0A%20%20%20%20%20%20%20%20%20%20%20%20reformatted_instance%5B'start'%5D%20%3D%20instance%5B'start'%5D%0A%20%20%20%20%20%20%20%20%20%20%20%20reformatted_instance%5B'end'%5D%20%3D%20instance%5B'end'%5D%0A%20%20%20%20%20%20%20%20%20%20%20%20instances.append(reformatted_instance)%0A%20%20%20%20if%20len(instances)%20%26gt%3B%200%3A%0A%20%20%20%20%20%20%20%20item_index%20%2B%3D%201%0A%20%20%20%20%20%20%20%20reformatted_item%5B'instances'%5D%20%3D%20instances%0A%20%20%20%20%20%20%20%20output_response.append(reformatted_item)%0A%0A%23Print%20response%20given%20by%20the%20script%0Aprint(json.dumps(output_response%2C%20indent%3D4))%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CBR%20%2F%3EDemo%3C%2FP%3E%0A%3CP%3E%3C%2FP%3E%3CDIV%20class%3D%22video-embed-center%20video-embed%22%3E%3CIFRAME%20class%3D%22embedly-embed%22%20src%3D%22https%3A%2F%2Fcdn.embedly.com%2Fwidgets%2Fmedia.html%3Fsrc%3Dhttps%253A%252F%252Fwww.youtube.com%252Fembed%252FZa1QDbglZP4%253Ffeature%253Doembed%26amp%3Bdisplay_name%3DYouTube%26amp%3Burl%3Dhttps%253A%252F%252Fwww.youtube.com%252Fwatch%253Fv%253DZa1QDbglZP4%26amp%3Bimage%3Dhttps%253A%252F%252Fi.ytimg.com%252Fvi%252FZa1QDbglZP4%252Fhqdefault.jpg%26amp%3Bkey%3Db0d40caa4f094c68be7c29880b16f56e%26amp%3Btype%3Dtext%252Fhtml%26amp%3Bschema%3Dyoutube%22%20width%3D%22600%22%20height%3D%22337%22%20scrolling%3D%22no%22%20title%3D%22YouTube%20embed%22%20frameborder%3D%220%22%20allow%3D%22autoplay%3B%20fullscreen%22%20allowfullscreen%3D%22true%22%3E%3C%2FIFRAME%3E%3C%2FDIV%3E%3CP%3E%3C%2FP%3E%0A%3CH2%20id%3D%22toc-hId--940216574%22%20id%3D%22toc-hId--940216574%22%3E%26nbsp%3B%3C%2FH2%3E%0A%3CH2%20id%3D%22toc-hId-1547296259%22%20id%3D%22toc-hId-1547296259%22%3E%3CSTRONG%3ECamera%20Trap%20Simulator%20%3C%2FSTRONG%3E%3C%2FH2%3E%0A%3CP%3EThe%20camera%20trap%20simulator%20allows%20users%20to%20simulate%20a%20real%20camera%20trap%20on%20their%20own%20computers%20and%20can%20even%20be%20run%20on%20devices%20such%20as%20a%20Raspberry%20Pi.%20It%20takes%20in%20a%20video%20feed%20and%20then%20uses%20a%20detection%20method%20over%20that%20video%20feed.%20If%20the%20detection%20method%20is%20triggered%20then%20it%20will%20send%20a%20message%20to%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Flearn%2Fmodules%2Fintroduction-to-iot-hub%2F%3FWT.mc_ID%3Dacademic-26142-leestott%22%20target%3D%22_self%22%20rel%3D%22noopener%20noreferrer%22%3EAzure%20IoT%20hub%3C%2FA%3E.%20Once%20the%20data%20is%20in%20the%20cloud%20the%20user%20can%20test%20out%20their%20cloud%20paths%20and%20solutions%20as%20if%20the%20data%20had%20come%20from%20a%20real%20camera%20trap.%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FP%3E%0A%3CP%3EThe%20camera%20trap%20can%20operate%20over%20both%20a%20live%20video%20feed%20such%20as%20a%20webcam%20or%20it%20can%20be%20used%20with%20a%20pre-recorded%20video%20feed.%20A%20video%20of%20the%20intended%20deployment%20area%20can%20be%20provided%20to%20the%20simulator%20to%20make%20the%20simulation%20more%20realistic%2C%20but%20for%20projects%20who%20don%E2%80%99t%20have%20access%20to%20videos%20of%20their%20deployment%20area%2C%20a%20live%20video%20feed%20may%20be%20fine%20for%20testing%20and%20development%20purposes.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThe%20camera%20trap%20can%20use%20motion%20based%20detection%20or%20can%20utilise%20a%20Machine%20Learning%20model%20to%20more%20accurately%20identify%20points%20of%20interest%20within%20a%20video%20frame.%20Use%20of%20an%20ML%20model%20will%20reduce%20the%20number%20of%20false%20positives%20the%20systems%20gives%20and%20will%20be%20a%20more%20accurate.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22MotionDetection.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F275040iB273CA896E21D998%2Fimage-size%2Fmedium%3Fv%3Dv2%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22MotionDetection.png%22%20alt%3D%22MotionDetection.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%E2%80%83%3C%2FP%3E%0A%3CP%3EAbove%20is%20an%20image%20showing%20the%20motion%20detection%20software%20running.%20It%20uses%20a%20method%20of%20motion%20detection%20known%20as%20foreground%20detection.%20The%20top%20left%20is%20the%20normal%20video%20feed%2C%20the%20top%20right%20is%20a%20greyscaled%20and%20blurred%20version%20of%20the%20video%20feed%2C%20the%20bottom%20left%20is%20the%20difference%20between%20the%20current%20frame%20and%20the%20reference%20frame%20and%20the%20bottom%20right%20is%20the%20final%20result%20showing%20any%20moving%20object%20in%20white.simulation%20but%20if%20an%20ML%20model%20isn%E2%80%99t%20available%20then%20motion%20detection%20can%20be%20used%20for%20testing%20and%20development%20purposes.%3C%2FP%3E%0A%3CDIV%20id%3D%22tinyMceEditorLee%20Stott_0%22%20class%3D%22mceNonEditable%20lia-copypaste-placeholder%22%3E%26nbsp%3B%3C%2FDIV%3E%0A%3CH3%20id%3D%22toc-hId--2057109563%22%20id%3D%22toc-hId--2057109563%22%3EDemo%26nbsp%3B%3C%2FH3%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3C%2FP%3E%3CDIV%20class%3D%22video-embed-center%20video-embed%22%3E%3CIFRAME%20class%3D%22embedly-embed%22%20src%3D%22https%3A%2F%2Fcdn.embedly.com%2Fwidgets%2Fmedia.html%3Fsrc%3Dhttps%253A%252F%252Fwww.youtube.com%252Fembed%252F2HSEXWkukPg%253Ffeature%253Doembed%26amp%3Bdisplay_name%3DYouTube%26amp%3Burl%3Dhttps%253A%252F%252Fwww.youtube.com%252Fwatch%253Fv%253D2HSEXWkukPg%26amp%3Bimage%3Dhttps%253A%252F%252Fi.ytimg.com%252Fvi%252F2HSEXWkukPg%252Fhqdefault.jpg%26amp%3Bkey%3Dfad07bfa4bd747d3bdea27e17b533c0e%26amp%3Btype%3Dtext%252Fhtml%26amp%3Bschema%3Dyoutube%22%20width%3D%22600%22%20height%3D%22337%22%20scrolling%3D%22no%22%20title%3D%22YouTube%20embed%22%20frameborder%3D%220%22%20allow%3D%22autoplay%3B%20fullscreen%22%20allowfullscreen%3D%22true%22%3E%3C%2FIFRAME%3E%3C%2FDIV%3E%3CP%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH2%20id%3D%22toc-hId--2067612667%22%20id%3D%22toc-hId--2067612667%22%3E%3CSTRONG%3EMachine%20Learning%3C%2FSTRONG%3E%20%3CSTRONG%3EModels%3C%2FSTRONG%3E%3C%2FH2%3E%0A%3CP%3EWhen%20creating%20the%20models%20there%20was%20difficulty%20in%20collecting%20a%20suitable%20dataset.%20Initially%20the%20plan%20was%20to%20use%20our%20own%20devices%20in%20the%20deployment%20area%20to%20create%20our%20own%20dataset%20of%20images%20to%20use%20for%20training%20purposes%20but%20due%20to%20time%20constraints%20and%20various%20blockers%20I%20ended%20up%20having%20to%20utilise%20a%20public%20dataset%20called%3CA%20href%3D%22https%3A%2F%2Fwww.kaggle.com%2Falessiocorrado99%2Fanimals10%22%20target%3D%22_self%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%3E%20Animals-10%20from%20Kaggle%3C%2FA%3E%20which%20contained%20images%20of%20elephants%20among%20other%20animals.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EI%20then%20created%20a%20set%20of%20image%20classification%20models%20using%20Python%20with%20TensorFlow%20and%20also%20created%20a%20set%20of%20object%20detection%20models%20using%20%3CA%20href%3D%22http%3A%2F%2Fwww.customvision.ai%22%20target%3D%22_self%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%3EAzure%20Custom%20Vision%20services%3C%2FA%3E.%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FP%3E%0A%3CP%3EThe%20first%20image%20classification%20model%20that%20was%20made%20used%20a%20very%20simple%20Convolutional%20Neural%20Network%20and%20achieved%20an%20accuracy%20of%2077%25%20on%20a%20test%20set.%20The%20second%20image%20classification%20model%20used%20a%20CNN%20architecture%20known%20as%20VGG-16%20which%20performed%20much%20better%20with%20an%20accuracy%20of%2097%25%20on%20the%20test%20set.%20The%20confusion%20matrices%20for%20these%20two%20models%20can%20be%20seen%20below.%3C%2FP%3E%0A%3CDIV%20id%3D%22tinyMceEditorLee%20Stott_1%22%20class%3D%22mceNonEditable%20lia-copypaste-placeholder%22%3E%26nbsp%3B%3C%2FDIV%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22confusionmatrix.JPG%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F275041i237AA171BF5BCEA3%2Fimage-size%2Flarge%3Fv%3Dv2%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22confusionmatrix.JPG%22%20alt%3D%22confusionmatrix.JPG%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%E2%80%83%3C%2FP%3E%0A%3CP%3EThe%20object%20detection%20models%20made%20using%20Azure%20Custom%20Vision%20also%20achieved%20quite%20high%20results%20as%20shown%20below.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22PPMap.png%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F275042i9919F5CD38441089%2Fimage-size%2Flarge%3Fv%3Dv2%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22PPMap.png%22%20alt%3D%22PPMap.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%E2%80%83%3C%2FP%3E%0A%3CP%3EThe%20object%20detection%20model%20was%20only%20trained%20using%20around%20130%20images%20of%20elephants%20and%20managed%20to%20achieve%20the%20above%20metrics.%20More%20images%20weren%E2%80%99t%20used%20since%20when%20providing%20images%20for%20the%20object%20detection%20models%20to%20train%20on%2C%20you%20have%20to%20tag%20every%20occurrence%20of%20every%20object%20you%20want%20to%20model%20to%20identify%20which%20can%20be%20quite%20time%20consuming.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CDIV%20id%3D%22tinyMceEditorLee%20Stott_4%22%20class%3D%22mceNonEditable%20lia-copypaste-placeholder%22%3E%26nbsp%3B%3C%2FDIV%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22ElephantsViewDown.png%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F275043i2175DD216DFC5BAD%2Fimage-size%2Flarge%3Fv%3Dv2%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22ElephantsViewDown.png%22%20alt%3D%22ElephantsViewDown.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%E2%80%83%3C%2FP%3E%0A%3CP%3EThe%20object%20detection%20model%20ended%20up%20being%20able%20to%20identify%20most%20elephants%20in%20an%20image%2C%20struggling%20on%20in%20cases%20where%20elephants%20were%20obscured.%20In%20the%20above%20image%20you%20can%20see%20in%20the%20bottom%20middle%20of%20the%20image%20there%20is%20a%20single%20elephant%20hidden%20by%20bush%20the%20model%20didn%E2%80%99t%20quite%20manage%20to%20identify.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThe%20conclusion%20that%20was%20reached%20was%20that%20for%20our%20use%20case%20object%20detection%20should%20be%20used.%20This%20is%20due%20to%20it%20not%20only%20saying%20if%20an%20image%20is%20of%20an%20elephant%2C%20but%20it%20providing%20the%20additional%20information%20of%20how%20many%20elephants%20are%20in%20the%20image%20and%20where%20in%20the%20image%20they%20are.%20This%20extra%20information%20that%20can%E2%80%99t%20be%20provided%20by%20image%20classification%20allows%20for%20more%20uses%20case%20to%20be%20fulfilled%20by%20the%20system%20later%20on.%20%3CA%20href%3D%22https%3A%2F%2Fazure.microsoft.com%2Fservices%2Fcognitive-services%2Fcustom-vision-service%2F%3FWT.mc_ID%3Dacademic-26142-leestott%22%20target%3D%22_self%22%20rel%3D%22noopener%20noreferrer%22%3EAzure%20custom%20vision%3C%2FA%3E%20was%20also%20chosen%20as%20the%20method%20to%20use%20as%20while%20TensorFlow%20is%20an%20incredible%20library%20allowing%20users%20to%20specify%20the%20exact%20architecture%20and%20hyperparameters%20that%20they%20want%20to%20use%2C%20it%20can%20take%20a%20long%20time%20to%20find%20the%20optimal%20setup%20and%20also%20requires%20more%20data%20to%20train%20on%20to%20achieve%20the%20same%20level%20of%20results%20produced%20by%20Azure%20Custom%20Vision.%20The%20ease%20of%20use%20and%20its%20ability%20to%20seamlessly%20work%20with%20other%20Azure%20services%20being%20used%20in%20the%20Project%2015%20platform%20make%20Azure%20Custom%20Vision%20the%20best%20choice%20for%20this%20project.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH3%20id%3D%22toc-hId--1377051193%22%20id%3D%22toc-hId--1377051193%22%3EDemo%26nbsp%3B%3CBR%20%2F%3E%3CBR%20%2F%3E%3CDIV%20class%3D%22video-embed-center%20video-embed%22%3E%3CIFRAME%20class%3D%22embedly-embed%22%20src%3D%22https%3A%2F%2Fcdn.embedly.com%2Fwidgets%2Fmedia.html%3Fsrc%3Dhttps%253A%252F%252Fwww.youtube.com%252Fembed%252F9C_m1oRoiwo%253Ffeature%253Doembed%26amp%3Bdisplay_name%3DYouTube%26amp%3Burl%3Dhttps%253A%252F%252Fwww.youtube.com%252Fwatch%253Fv%253D9C_m1oRoiwo%26amp%3Bimage%3Dhttps%253A%252F%252Fi.ytimg.com%252Fvi%252F9C_m1oRoiwo%252Fhqdefault.jpg%26amp%3Bkey%3Db0d40caa4f094c68be7c29880b16f56e%26amp%3Btype%3Dtext%252Fhtml%26amp%3Bschema%3Dyoutube%22%20width%3D%22600%22%20height%3D%22337%22%20scrolling%3D%22no%22%20title%3D%22YouTube%20embed%22%20frameborder%3D%220%22%20allow%3D%22autoplay%3B%20fullscreen%22%20allowfullscreen%3D%22true%22%3E%3C%2FIFRAME%3E%3C%2FDIV%3E%3C%2FH3%3E%0A%3CH2%20id%3D%22toc-hId-286215442%22%20id%3D%22toc-hId-286215442%22%3E%26nbsp%3B%3C%2FH2%3E%0A%3CH2%20id%3D%22toc-hId--1521239021%22%20id%3D%22toc-hId--1521239021%22%3E%3CSTRONG%3ESummary%3C%2FSTRONG%3E%3C%2FH2%3E%0A%3CP%3EOverall%2C%20the%20process%20of%20learning%20about%20cloud%20services%20and%20machine%20learning%20tools%20has%20been%20extremely%20enjoyable%20and%20getting%20the%20opportunity%20to%20apply%20what%20I%20learnt%20to%20a%20real%20world%20project%20like%20this%20has%20been%20an%20incredible%20experience.%20So%20if%20your%20interested%20in%20building%20a%20project%20to%20support%20Project%2015%20see%20%3CA%20href%3D%22https%3A%2F%2Fmicrosoft.github.io%2Fproject15%2F%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noreferrer%22%3EProject%2015%20Open%20Platform%20for%20Conservation%20and%20Ecological%20Sustainability%20Solutions%3C%2FA%3E%26nbsp%3Bor%20if%20your%20new%20to%20this%20see%20the%20amazing%20resources%20to%20help%20get%20your%20started%20at%20%3CA%20href%3D%22http%3A%2F%2Fdocs.microsoft.com%2Flearn%2F%3FWT.mc_ID%3Dacademic-26142-leestott%22%20target%3D%22_self%22%20rel%3D%22noopener%20noreferrer%22%3EMicrosoft%20Learn%3C%2FA%3E.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-TEASER%20id%3D%22lingo-teaser-2282777%22%20slang%3D%22en-US%22%3E%3CP%3ECurious%20about%20Project%2015%3F%20This%20Microsoft%20open-source%20platform%20was%20designed%20with%20sustainability%20and%20preservation%20in%20mind.%20See%20how%20Students%20from%20University%20College%20London%20are%20using%20the%20Project%2015%20Challenge%20to%20develop%20amazing%20open%20source%20solutions%20which%20support%20preservation.%3C%2FP%3E%3C%2FLINGO-TEASER%3E%3CLINGO-LABS%20id%3D%22lingo-labs-2282777%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EAI%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3ECognitive%20Services%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3ECustom%20Vision%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EFaculty%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EIXN%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3ELearning%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EMachine%20Learning%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EStudents%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EUCL%20IXN%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EVideo%20Indexer%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E
Co-Authors
Version history
Last update:
‎Apr 23 2021 09:28 AM
Updated by: