Algorithm examples
1. Monitoring candy bar movement on a conveyor belt
Imagine a scenario where we need to monitor candy bars moving along a conveyor belt. The goal is to determine if a candy bar moves entirely within a 3-second window or surpasses a defined size threshold more than 50 times. If either condition is met, notifications are sent via SMS. This process can be automated with an algorithm as follows:
Algorithm structure
1. Add a Model
block to perform inference:
Click
Add model
and select an object detection model capable of identifying candy bars,Ensure the model has been properly trained and includes the relevant categories.
2. Add a Session
block:
- Connect the
Session
block to theModel
block. TheSession
defines a loop that takes a frame from the stream, applies the inferencing engine, and returns the predictions.
3. Add Prediction triggers:
Add a
Speed trigger
to identify candy bars moving entirely across the conveyor belt within 3 seconds,Configure the following:
Categories: Select the relevant candy bar categories,
Seconds: Set to 3,
Distance: Set to 100%,
Add a
Size trigger
to identify candy bars exceeding the specified size thresholds,Configure the following:
Categories: Select the relevant candy bar categories,
Operator: Set to “greater than”,
Height: Set to 80%,
Width: Set to 30%,
- Connect both prediction triggers to the
Session
block.
4. Add a Prediction event
:
Add a
Sends sms action
block to send real-time notifications to a specified phone number,Connect the
Speed trigger
to theSend sms action
block,Configure the following:
Phone numbers list: Add the recipient’s phone number,
SMS body: Set the message (e.g., “The production line is moving too fast”).
5. Add an Aggregator
block:
- Connect the
Aggregator
block to theSize trigger
block. This block groups (aggregates) events derived from prediction triggers.
6. Add an Aggregation trigger
:
Add an
Events quantity
block to track when size violations occur more than 50 times for a single candy bar,Configure the following:
Operator: Set to “greater than”
Number: Set to 50.
7. Add another Prediction event
:
Add a
Send sms action
block to send real-time notifications to a specified phone number,Connect the
Events quantity
block toSends sms action
block,Configure the following:
Phone numbers list: Add the recipient’s phone number,
SMS body: Set the message (e.g., “Candy bars moving on the conveyor belt are too big.”).
2. Analyzing the amount of cards
Suppose we aim to determine the quantity of specific cards captured by both the top and right cameras. The algorithm might be structured as follows:
Algorithm structure
1. Add two Model
blocks to perform inference:
Add one
Model
block for the top camera and another for the right camera,Select object detection models capable of recognizing card symbols,
Ensure models have been properly trained and include the relevant categories.
2. Add two Session
blocks:
- Each
Session
block should be connected to oneModel
block. TheSession
defines a loop that takes a frame from the stream, applies the inferencing engine, and returns the predictions.
3. Add two Prediction triggers:
Add two
Quantity
triggers, one for the top camera and one for the right camera,Configure the following:
Category: Select the relevant card symbols,
Operator: Set to “greater than”,
Number: Set to 1,
- Each
Quantity
trigger block should be connected to oneSession
block.
4. Add an Aggregator
block:
- Connect the
Aggregator
block to theQuantity trigger
blocks. This block groups (aggregates) events derived from prediction triggers.
5. Add an Aggregation trigger
:
Add an
Events quantity
block to track when quantity violations occur more than 1 time,Configure the following:
Operator: Set to “greater than”,
Number: Set to 1,
Enable Consider only events related to the same object.
6. Add a Prediction event
:
Add a
Make screenshot action
block to to save an image of the detected cards,Connect the
Events quantity
block toMake screenshot action
block,Configure the following:
Relative path: Add a relative path and use variables such as OccurredEventsNames
and EventsDetailsJson
to generate file paths dynamically.