Skip to content

Dynamic Discovery

The USB camera device service supports dynamic discovery. During dynamic discovery, the device service scans all connected USB devices and sends the discovered cameras to Core Metadata. The device name of the camera discovered by the device service is comprised of Card Name and Serial Number. Any colon, space, or period characters will be replaced with underscores as they are invalid characters for device names in Edge Xpert. For example, the Logitech C270 camera has the Card Name "C270 HD WEBCAM" and the Serial Number "B1CF0E50". Edge Xpert discovery would provide this camera with the device name "C270_HD_WEBCAM-B1CF0E50".

Note

Card Name and Serial Number are obtained through V4L2 API and udev utility.

Note

Card Name and Serial Number are used by the device service to uniquely identify a camera. However, low-budget mass-produced cameras may have the same serial number.

Configure the Dynamic Discovery Function

By default, dynamic discovery is enabled when the device service starts and a call is made every 1 hour. These settings can be changed using the following environment variables:

Environment Variable Description
DEVICE_DISCOVERY_ENABLED Specifies whether device discovery is enabled

Set to true to enable device discovery

Set to false to disable device discovery

Default is true
DEVICE_DISCOVERY_INTERVAL Specifies the interval between automatic discovery runs

The interval value must be a Go duration

Default is 1h

To manually trigger a Dynamic Discovery, use this device service API.

Provision Watcher Example

Info

If Edge Xpert is running in secure mode, you will need to replace localhost in the URL with the IP address for the service. See CLI Service Ports for details.

curl -X POST \
-d '[
   {
      "provisionwatcher":{
         "apiVersion":"v2",
         "name":"USB-Camera-Provision-Watcher",
         "adminState":"UNLOCKED",
         "identifiers":{
            "Path": "."
         },
         "serviceName": "device-usb-camera",
         "profileName": "USB-Camera-General"
      },
      "apiVersion":"v2"
   }
]' http://localhost:59881/api/v2/provisionwatcher

Keep the Paths of Existing Camera up to Date

The paths (/dev/video*) of the connected cameras may change whenever the cameras are re-connected or the system restarts. To ensure the paths of the existing cameras are up-to-date, the device service scans all the existing cameras to check whether their serial numbers match the connected cameras. If there is a mismatch between them, the device service will scan all paths to find the matching device and update the existing device with the correct path.

This check can also be triggered by using the Device Service API /refreshdevicepaths. For example:

curl -X POST http://localhost:59983/api/v2/refreshdevicepaths

It is recommended to trigger a check after re-plugging cameras.