This module implements a vision service that detects duplicate images from the previous frame. It takes the average pixel-wise difference between the current frame and the previous frame to determine if they are under a certain threshold of similarity.
NOTE: This module will return a classification of "different" if the images are different, and nothing if the images are similar.
- API:
rdk:service:vision - Organization Namespace:
viam - Model:
viam:duplicate-classifier:duplicate-classifier
The following attributes are available for this model:
| Name | Type | Inclusion | Description |
|---|---|---|---|
camera_name |
string | Required | The name of the camera configured on your robot. |
average_pixel_difference_threshold |
float | Optional | The threshold above which an image would be considered different. The range is 0.0 to 255.0. The default value is 5.0. |
Start by configuring a camera on your robot. Remember the name you give to the camera, it will be important later.
Note
Before configuring your camera or vision service, you must create a robot.
Navigate to the Config tab of your robot’s page in the Viam app. Click on the Services subtab and click Create service. Select the vision type, then select the duplicate-image-classifier model. Enter a name for your service and click Create.
On the new component panel, copy and paste the following attribute template into your base’s Attributes box.
{
"camera_name": "myCam",
"average_pixel_difference_threshold": 5.0
}{
"modules": [
{
"type": "registry",
"name": "viam-duplicate-image-classifier",
"module_id": "viam:duplicate-image-classifier",
"version": "0.0.1"
}
],
"services": [
{
"name": "myDuplicateImageClassifier",
"type": "vision",
"namespace": "rdk",
"model": "viam:duplicate-image-classifier:duplicate-image-classifier",
"attributes": {
"camera_name": "myCam",
"average_pixel_difference_threshold": 5.0
}
}
]
}The following methods are implemented from the Vision Service API:
When the module returns classifications, the class_name will always be "different" and the confidence will always be 1.0 if the images are different. Nothing will be returned if the images are similar.