Event driven Serverless solution for Surveillance Using Oracle Cloud AI Vision Object Detection, Functions and Notifications


In previous post we made a solution for sending captured cam images to object storage buckets.

Object storage emit events upon actions such as object creation, deletion, etc.

Functions is a serverless platform that enables you to create, run, and scale business logic without managing any infrastructure.

AI Vision object detection provides a framework (SDK & batch) for detection of object in images. In this use case we are using the vision go sdk

Notifications broadcasts messages to distributed components through a publish-subscribe pattern, delivering secure, highly reliable, low latency and durable messages for applications hosted on Oracle Cloud Infrastructure and externally. Use Notifications to get messages whenever alarms, service connectors, and event rules are triggered.

STEP 1: OBJECT STORAGE EVENT TRIGGERING

Set the [Emit Object Events] option in the bucket in wich you are storing the cam pictures.

STEP 2: DEPLOY THE FUNCTION CODE

Create an Application:

Clone this repo and deploy the function:

fn create context humans --provider oracle
fn use context humans
fn update context  oracle.compartment-id ocid1.compart......m5wa
fn update context  api-url https://functions.eu-frankfurt-1.oraclecloud.com
fn update context  registry fra.ocir.io/<namespace>/humans
docker login -u '<tenancyname>/oracleidentitycloudservice/<user>' fra.ocir.io
<the password here is an auth token created by the user>
fn deploy --app humans_around  --verbose --no-bump

STEP 3: CREATE EVENT RULE

Create a rule that fires the deployed function when a file is stored in the target bucket:

STEP 4: NOTIFICATION TOPIC AND SUBSCRIPTION

Create a topic:

Grab the ocid of the topic.

Create an email subscription in the topic:

STEP 5: CONFIGURE FUNCTION PARAMETERS

Go to the deployed function and configure the following parameters:

NOTIFICATION_TOPIC: The ocid of the notification topic created in step 4

SEARCH_FOR: Comma separated list of objects to detect

CONFIDENCE: If the object detected has a confidence value greater than this setting the notification event in sent

STEP 6: POLICIES

Set up policies to allow the Functions service to reach the other cloud services subsystems:

# note: more restricted policies can be stated if that is the case 

allow any-user to manage ai-service-vision-family in compartment <xxxxx>

allow any-user to manage ons-topics in compartment <xxxxx>

STEP 7: TEST IT ALL

Walk around one of your cameras and see what happens…

CONCLUSION

The use of serverless managed cloud services turbocharges the deployment of a bunch of solutions, this is just an example that a hobbyist can create in a few hours. The solution can be extended with autonomous databases, AI algorithms, kafka and much more.

That’s all, hope it helps!!! 🙂

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.