Skip to content

Analytic Support

Warning

Information in this page may be outdated.

The device-onvif-camera implement the Analytic function according to Onvif Profile M to manage the Analytics Module and Rule configuration.

The spec can refer to

Overview

This page uses the BOSCH DINION IP starlight 6000 HD as the test camera and used the BOSCH Configuration Manager as the camera viewer. - The product page refer to https://commerce.boschsecurity.com/tw/en/DINION-IP-starlight-6000-HD/p/20827877387/ - The configuration manager can download from https://downloadstore.boschsecurity.com/index.php?type=CM

In the scope of profile M, the device-onvif-camera should be able to manage the Analytics Module and Rule configuration, we can illustrate the APIs scope as following example:

api-analytic-support-example

For more information, please refer to the Annex D. Radiometry https://www.onvif.org/specs/srv/analytics/ONVIF-Analytics-Service-Spec.pdf

Manage the Analytics Module Configuration

Query the Analytics Module

curl --request GET 'http://0.0.0.0:59882/api/v3/device/name/Camera003/AnalyticsModules?jsonObject=eyJDb25maWd1cmF0aW9uVG9rZW4iOiIxIn0=' | jq .
{
   "apiVersion" : "v3",
   "event" : {
      ...
      "profileName" : "onvif-camera",
      "readings" : [
         {
            ...
            "objectValue" : {
               "AnalyticsModule" : [
                  {
                     "Name" : "Viproc",
                     "Parameters" : {
                        "SimpleItem" : [
                           {
                              "Name" : "Mode",
                              "Value" : "Profile 1"
                           },
                           {
                              "Name" : "AnalysisType",
                              "Value" : "Intelligent Video Analytics"
                           }
                        ]
                     },
                     "Type" : "tt:Viproc"
                  }
               ]
            },
         }
      ],
      "sourceName" : "AnalyticsModules"
   },
   "statusCode" : 200
}

Note

The jsonObject parameter is encoded from {"ConfigurationToken": "{ANALYTIC_CONFIG_TOKEN}"}

query-analytics-module

Query the Supported Analytics Module and Options

curl --request GET 'http://0.0.0.0:59882/api/v3/device/name/Camera003/SupportedAnalyticsModules' | jq .
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   692  100   692    0     0   2134      0 --:--:-- --:--:-- --:--:--  2217
{
   "apiVersion" : "v3",
   "event" : {
      ...
      "readings" : [
         {
            "deviceName" : "Camera003",
            "id" : "70545263-30e7-4c03-9741-0011300f2f9c",
            "objectValue" : {
               "SupportedAnalyticsModules" : {
                  "AnalyticsModuleDescription" : [
                     {
                        "Fixed" : true,
                        "MaxInstances" : 1,
                        "Name" : "tt:Viproc",
                        "Parameters" : {
                           "SimpleItemDescription" : [
                              {
                                 "Name" : "Mode",
                                 "Type" : "xs:string"
                              },
                              {
                                 "Name" : "AnalysisType",
                                 "Type" : "xs:string"
                              }
                           ]
                        }
                     }
                  ]
               }
            },
         }
      ],
      "sourceName" : "SupportedAnalyticsModules"
   },
   "statusCode" : 200
}
curl --request GET 'http://0.0.0.0:59882/api/v3/device/name/Camera003/AnalyticsModuleOptions?jsonObject=eyJDb25maWd1cmF0aW9uVG9rZW4iOiIxIn0=' | jq .
{
   "apiVersion" : "v3",
   "event" : {
      "deviceName" : "Camera003",
      "profileName" : "onvif-camera",
      ...
      "readings" : [
         {
            "deviceName" : "Camera003",
            "id" : "43f0e59b-6f3e-4119-978e-299ccd59049d",
            "objectValue" : {
               "Options" : [
                  {
                     "AnalyticsModule" : "tt:Viproc",
                     "Name" : "Mode",
                     "StringItems" : {
                        "Item" : [
                           "Off",
                           "Silent VCA",
                           "Profile 1",
                           "Profile 2",
                           "Scheduled",
                           "Event Triggered"
                        ]
                     }
                  },
                  {
                     "AnalyticsModule" : "tt:Viproc",
                     "Name" : "AnalysisType",
                     "StringItems" : {
                        "Item" : [
                           "MOTION+",
                           "Intelligent Video Analytics"
                        ]
                     }
                  }
               ]
            },
            ...
            "resourceName" : "AnalyticsModuleOptions",
            "valueType" : "Object"
         }
      ],
      "sourceName" : "AnalyticsModuleOptions"
   },
   "statusCode" : 200
}

Note

The jsonObject parameter is encoded from {"ConfigurationToken": "{ANALYTIC_CONFIG_TOKEN}"}

query-analytics-module query-analytics-module

Modify the Analytics Module Options

curl --request PUT 'http://0.0.0.0:59882/api/v3/device/name/Camera003/AnalyticsModules' \
--header 'Content-Type: application/json' \
--data-raw '{
     "AnalyticsModules": {
         "ConfigurationToken": "1",
         "AnalyticsModule": [
                         {
                             "Name": "Viproc",
                             "Type": "tt:Viproc",
                             "Parameters": {
                                 "SimpleItem": [
                                     {
                                         "Name": "Mode",
                                         "Value": "Profile 1"
                                     },
                                     {
                                         "Name": "AnalysisType",
                                         "Value": "Intelligent Video Analytics"
                                     }
                                 ]
                             }

                         }
                     ]
     }
}'

Manage the Rule Configuration

Query the Rules

curl --request GET 'http://0.0.0.0:59882/api/v3/device/name/Camera003/AnalyticsRules?jsonObject=eyJDb25maWd1cmF0aW9uVG9rZW4iOiIxIn0=' | jq .
{
   "apiVersion" : "v3",
   "event" : {
      "apiVersion" : "v3",
      "deviceName" : "Camera003",
      "profileName" : "onvif-camera",
      ...
      "readings" : [
         {
            "deviceName" : "Camera003",
            "id" : "1abea901-ad51-4a55-b9bb-0b00271307df",
            "objectValue" : {
               "Rule" : [
                  {
                     "Name" : "Detect any object",
                     "Parameters" : {
                        "SimpleItem" : [
                           {
                              "Name" : "Armed",
                              "Value" : "true"
                           }
                        ]
                     },
                     "Type" : "tt:ObjectInField"
                  }
               ]
            },
            "origin" : 1639480270526564000,
            "profileName" : "onvif-camera",
            "resourceName" : "AnalyticsRules",
            "valueType" : "Object"
         }
      ],
      "sourceName" : "AnalyticsRules"
   },
   "statusCode" : 200
}

Note

The jsonObject parameter is encoded from {"ConfigurationToken": "{ANALYTIC_CONFIG_TOKEN}"}

query-analytics-module

Query the Supported Rule and Options

curl --request GET 'http://0.0.0.0:59882/api/v3/device/name/Camera003/AnalyticsSupportedRules?jsonObject=eyJDb25maWd1cmF0aW9uVG9rZW4iOiIxIn0=' | jq .
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  9799    0  9799    0     0   9605      0 --:--:--  0:00:01 --:--:--  9740
{
   "apiVersion" : "v3",
   "event" : {
      "apiVersion" : "v3",
      "deviceName" : "Camera003",
      "id" : "07f7b42e-835b-4ecc-97b1-fe4d5f52575b",
      "origin" : 1639482296788863000,
      "profileName" : "onvif-camera",
      "readings" : [
         {
            "deviceName" : "Camera003",
            "id" : "6fca707b-3c52-4694-be37-2e23ecf65de1",
            "objectValue" : {
               "SupportedRules" : {
                  "RuleDescription" : [
                     ....
                     {
                        "MaxInstances" : 16,
                        "Messages" : {
                           "Data" : {
                              "SimpleItemDescription" : [
                                 {
                                    "Name" : "Count",
                                    "Type" : "xs:int"
                                 }
                              ]
                           },
                           "IsProperty" : true,
                           "ParentTopic" : "tns1:RuleEngine/CountAggregation/Counter",
                           "Source" : {
                              "SimpleItemDescription" : [
                                 {
                                    "Name" : "VideoSource",
                                    "Type" : "tt:ReferenceToken"
                                 },
                                 {
                                    "Name" : "Rule",
                                    "Type" : "xs:string"
                                 }
                              ]
                           }
                        },
                        "Name" : "tt:LineCounting",
                        "Parameters" : {
                           "ElementItemDescription" : [
                              {
                                 "Name" : "Segments"
                              }
                           ],
                           "SimpleItemDescription" : [
                              {
                                 "Name" : "Armed",
                                 "Type" : "xs:boolean"
                              },
                              {
                                 "Name" : "Direction",
                                 "Type" : "tt:Direction"
                              },
                              {
                                 "Name" : "MinObjectHeight",
                                 "Type" : "xs:int"
                              },
                              ...
                              {
                                 "Name" : "ClassFilter",
                                 "Type" : "tt:StringList"
                              }
                           ]
                        }
                     }
                  ]
               }
            },
            "origin" : 1639482296788863000,
            "profileName" : "onvif-camera",
            "resourceName" : "AnalyticsSupportedRules",
            "valueType" : "Object"
         }
      ],
      "sourceName" : "AnalyticsSupportedRules"
   },
   "statusCode" : 200
}
curl --request GET 'http://0.0.0.0:59882/api/v3/device/name/Camera003/RuleOptions?jsonObject=eyJDb25maWd1cmF0aW9uVG9rZW4iOiIxIn0=' | jq .
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  1168  100  1168    0     0    755      0  0:00:01  0:00:01 --:--:--   759
{
   "apiVersion" : "v3",
   "event" : {
      "apiVersion" : "v3",
      "deviceName" : "Camera003",
      "id" : "3ac81a5c-48f2-46d7-a3f9-d4919f97ae8d",
      "origin" : 1639482979553667000,
      "profileName" : "onvif-camera",
      "readings" : [
         {
            "deviceName" : "Camera003",
            "id" : "6eae2e16-71f7-4b92-95b6-32e398be25ca",
            "objectValue" : {
               "RuleOptions" : [
                  ...
                  {
                     "MaxOccurs" : "3",
                     "MinOccurs" : "0",
                     "Name" : "Field",
                     "PolygonOptions" : {
                        "VertexLimits" : {
                           "Max" : 16,
                           "Min" : 3
                        }
                     }
                  },
                  {
                     "IntRange" : {
                        "Max" : 16,
                        "Min" : 2
                     },
                     "MaxOccurs" : "3",
                     "MinOccurs" : "1",
                     "Name" : "Segments"
                  },
                  {
                     "Name" : "Direction",
                     "StringList" : "Any Right Left"
                  },
                  {
                     "Name" : "ClassFilter",
                     "StringList" : "Person Bike Car Truck"
                  }
               ]
            },
            "origin" : 1639482979553667000,
            "profileName" : "onvif-camera",
            "resourceName" : "RuleOptions",
            "valueType" : "Object"
         }
      ],
      "sourceName" : "RuleOptions"
   },
   "statusCode" : 200
}

Add the Rule

curl --location --request PUT 'http://0.0.0.0:59882/api/v3/device/name/Camera003/AnalyticsCreateRules' \
--header 'Content-Type: application/json' \
--data-raw '{
    "AnalyticsCreateRules": {
        "ConfigurationToken": "1",
        "Rule": [
            {
                "Name": "Object Counting",
                "Type": "tt:LineCounting",
                "Parameters": {
                    "SimpleItem": [
                        {
                            "Name":"Armed", 
                            "Value":"true"
                        }
                    ],
                    "ElementItem": [
                        {
                            "Name":"Segments", 
                            "Polyline": {
                                "Point": [
                                    {
                                        "x":"0.16",
                                        "y": "0.5"
                                    },
                                    {
                                        "x":"0.16",
                                        "y": "-0.5"
                                    }
                                ]
                            }
                        }
                    ]
                }

            }
        ]
    }
}'

add-rule