Skip to content

Small example ACAP application that reads analog gauges with video analytics and exposes the value via OPC UA.

License

Notifications You must be signed in to change notification settings

AxisCommunications/opc-ua-gaugereader-acap

Copyright (C) 2022, Axis Communications AB, Lund, Sweden. All Rights Reserved.

OPC UA Gauge Reader ACAP

Build ACAPs GitHub Super-Linter

Image of a water level gauge

This repository contains the source code to build a small example ACAP version 3 application that reads an analog gauge using video analytics with OpenCV and exposes the value through a built-in OPC UA (open62541) server.

Architectural overview

The exposed value is in percent.

Note

Even if this application would fit right into your usecase, its purpose is above all to serve as an example and boilerplate rather than being ready for production.

Example Use Cases

The following examples assume that you have a SCADA (Supervisory Control And Data Acquisition) system or a PLC (Programmable Logic Controller) system with OPC UA as the communication protocol and you want to take advantage of the Axis device capabilities to enrich or complement your operations.

Analog gauges are common in the industry, and it is often impossible to add digital sensors due to regulations or warranty restrictions. However, having a human operator monitor these gauges (which is what is done today) is inconvenient and error-prone. Instead, we can use an IP camera with very basic video analysis to automatically capture the digital reading and feed it into the industrial system. Automating the capture of digital values from analog gauges opens up a multitude of possibilities.

For example:

  • shutdown or start a PLC process if a gauge reading exceeds or falls below a specified threshold
  • generate alarms when the gauge reading goes outside a predefined range
  • display real-time gauge values within the SCADA server's operational interface
  • maintain historical logs of gauge values to track changes over time

Warning

Please note that any analytic process can never be 100% accurate and the system designer has to account for this.

Build

The build process uses the ACAP SDK build container and Docker.

The Docker commands are integrated in the Makefile, so if you have Docker and make on your computer all you need to do is:

make dockerbuild

or perhaps build in parallel:

make -j dockerbuild

If you do have Docker but no make on your system:

# 32-bit ARM, e.g. ARTPEC-6- and ARTPEC-7-based devices
DOCKER_BUILDKIT=1 docker build --build-arg ARCH=armv7hf -o type=local,dest=. .
# 64-bit ARM, e.g. ARTPEC-8-based devices
DOCKER_BUILDKIT=1 docker build --build-arg ARCH=aarch64 -o type=local,dest=. .

Debug

If you would like the application to store the images from each step in the video analysis to disk for debugging, set the DEBUG_WRITE variable for the build:

DEBUG_WRITE=y make -j dockerbuild

or

# 32-bit ARM, e.g. ARTPEC-6- and ARTPEC-7-based devices
DOCKER_BUILDKIT=1 docker build --build-arg DEBUG_WRITE=y --build-arg ARCH=armv7hf -o type=local,dest=. .
# 64-bit ARM, e.g. ARTPEC-8-based devices
DOCKER_BUILDKIT=1 docker build --build-arg DEBUG_WRITE=y --build-arg ARCH=aarch64 -o type=local,dest=. .

Setup

Manual installation and configuration

Upload the ACAP application file (the file with the .eap extension for the camera's architecture) through the camera's web UI: Apps->Add app

When installed, start the application.

Web UI Screenshot

Open the application's settings page in the web interface (available when the application is running) by clicking the Open button.

Web UI Screenshot

In the settings page, simply click in the image to set up the calibration points in the following order:

  1. Center of the gauge
  2. Minimum value of the gauge
  3. Maximum value of the gauge

The calibration points can also, along with the OPC UA Server port (default is 4840) and clockwise/counterclockwise (default is clockwise), be set directly through the application's parameter settings, found in the three vertical dots menu:

Web UI Screenshot

Web UI Screenshot

Scripted installation and configuration

Use the camera's applications/upload.cgi to upload the ACAP application file (the file with the .eap extension for the camera's architecture):

curl -k --anyauth -u root:<password> \
    -F packfil=@OPC_UA_Gauge_Reader_<version>_<architecture>.eap \
    https://<camera hostname/ip>/axis-cgi/applications/upload.cgi

To start (or stop/restart/remove) the application, you can make a call like this:

curl -k --anyauth -u root:<password> \
    'https://<camera hostname/ip>/axis-cgi/applications/control.cgi?package=opcuagaugereader&action=start'

Use the camera's param.cgi to set the center/min/max points, as well as clockwise/counterclockwise and the OPC UA server port number.

The call

curl -k --anyauth -u root:<password> \
    'https://<camera hostname/ip>/axis-cgi/param.cgi?action=list&group=opcuagaugereader'

will list the current settings:

root.Opcuagaugereader.centerX=479
root.Opcuagaugereader.centerY=355
root.Opcuagaugereader.clockwise=1
root.Opcuagaugereader.maxX=678
root.Opcuagaugereader.maxY=165
root.Opcuagaugereader.minX=283
root.Opcuagaugereader.minY=167
root.Opcuagaugereader.port=4840

If you want to set the OPC UA server port to e.g. 4842:

curl -k --anyauth -u root:<password> \
    'https://<camera hostname/ip>/axis-cgi/param.cgi?action=update&opcuagaugereader.port=4842'

Usage

Attach an OPC UA client to the port set in ACAP. The client will then be able to read the value (and its timestamp) from the application's OPC UA server.

Note

The application will also log the gauge value in the camera's syslog.

License

Apache 2.0