Image Streamer Driver Module by Automation Professionals
E-Mail Support
Return

OpenCV Installation

Starting with version 0.5 of this module, OpenCV scripting is also supported in clients and designers that have a compatible version of OpenCV installed locally. Perform the appropriate instructions below for any client or designer that will use/test OpenCV scripting.

Windows 7+

64-bit Windows 10 is the primary test platform for development of this driver module under Windows. Manual installation of FFmpeg and OpenCV is required. Installation of the appropriate Microsoft Visual-C redistributable package may also be required. The instructions below should work for all versions of Windows from Windows 7 on.

FFmpeg

FFmpeg v4.2 is used to test this module in Windows 10. Newer release versions are also expected to work.

    Zeranoe Download Options
  1. The official Windows releases of FFmpeg are distributed by Zeranoe. Select the release version with shared linking for your architecture, as shown to the right, and download that build.

  2. Expand the FFmpeg build's zip file directly into C:\Program Files\, using the path names within to produce the FFmpeg folder hierarchy underneath. In 64-bit Windows, the resulting folder should be C:\Program Files\ffmpeg-4.2-win64-shared\ or similar.

  3. Add the bin subfolder of the above hierarchy to the system PATH environment variable, as shown in the System Settings section below. OpenCV will use this path to find FFmpeg when its own DLL is loaded within Ignition.

OpenCV

OpenCV v3.2.0 is used to test this module in Windows 10. Other release versions in the v3.x (x>=2) and v4.x series are expected to work. Newer versions will expose more data types, functions, and constants in the scripting namespaces. Versions as old as v2.4.9 are known to have java bindings and may work, but are officially unsupported.

    OpenCV Releases
  1. Visit the OpenCV Releases page and advance to find the version you wish to use, as shown to the right, and download the Windows build. This is a 32/64-bit combination build in self-extracting executable form, intended for Windows 7 and later.

  2. After downloading, open the containing folder and right-click on the executable. Select "Run as Administrator". In the following pop-up, replace the suggested expansion location with C:\Program Files\. This will expand OpenCV into the C:\Program Files\opencv\ folder.

  3. Use Windows Explorer to drill down into C:\Program Files\opencv\build\java and locate the version-specific JAR file for OpenCV. Make a copy of this file and name it opencv.jar (in the same folder). This is the default name the driver module will attempt to load.

  4. Add C:\Program Files\opencv\build\x64\vc14\bin and C:\Program Files\opencv\build\java\x64 to the system PATH environment variable, as shown in the System Settings section below. Although the folder containing the JNI DLL file is specified in the driver module, the JNI DLL must be able to locate the rest of the DLLs that comprise the OpenCV library.

  5. Open a command prompt and change to the C:\Program Files\opencv\build\x64\vc14\bin directory. Execute opencv_version. It should report the version you installed. Otherwise, obtain and install the VC14 redistributable from Microsoft and try again. (Use a later redistributable if so indicated in the OpenCV folder hierarchy for the version chosen.)

System Properties Dialog

System Settings

Follow these steps to set the system PATH environment variable as required by FFmpeg and OpenCV, and adjust the Ignition Service (if applicable) to permit network video connections:

  1. Start by right-clicking on My Computer on your desktop, or This PC in Windows Explorer. If you don't see the System Properties window as shown on the right, you may need to also click on "Advanced System Properties".

    Then select Environment Variables.

  2. Environment Variables Dialog
  3. Within the Environment Variables dialog, locate the Path variable in the bottom section, among the System variables. Double-click, or click Edit... to proceed.

  4. System Path Editing Dialog
  5. Within the Edit environment variable dialog for the system Path, use the New button to insert the required entries, then click OK. The result should be similar to that shown to the right.

    If this Windows machine runs clients or designers, installation is complete for them. Restart all local clients and/or designers for them to recognize the changes and activate OpenCV scripting support. The following step may be omitted if the machine will not be a gateway.

    For a gateway, the Ignition Service must be restarted for it to recognize the changes to the system Path. Defer that until after changing the service user account (the next step).

  6. During installation of Ignition, the Ignition service is set up to use the LOCALSYSTEM account. This account has limited network privileges, such that OpenCV and the FFmpeg library it uses will be unable to make RTSP or similar connections. (It also prevents access to shared drives and folders...)

    The simplest way to enable networking is to create a normal local Windows user account, grant it full access to the Ignition install folder hierarchy, and set the service to log in with this account. Automation Professionals recommends the user name Ignition, though any account name will work. The precise steps to follow vary by Windows version.

    The Ignition Service must be restarted for it to recognize the changes to its login account.

Ubuntu Linux 20.04 LTS

Ubuntu Server is the primary test platform for development of this driver module under Linux. Ubuntu 20.04 packages a Jar file for OpenCV 4.2.0 compiled with OpenJDK 11. This is perfect for Ignition v8.0, as v8 runs with its own copy of Java 11. Execute the following command on the gateway and you should be ready to run:

sudo apt install libopencv4.2-java

Ubuntu Linux 20.04 LTS with Ignition v7.9.x

Ignition v7.9 cannot run under Java11 and therefore cannot use the above jar file. Fortunately, the Jar files distributed in the Windows builds of OpenCV are packaged for Java8. Obtain and extract the Windows build of OpenCV 4.2.0, and locate opencv-420.jar within. This is the only file needed from the Windows build. (One could also download the source for OpenCV and compile it within a Linux environment, using java8, yielding a compatible jar file.)

Execute the following commands on the gateway:

sudo apt install libopencv4.2-jni
sudo mkdir -p /usr/share/java

Ubuntu's package manager will pull in the entire opencv library (except the jar) and a number of other dependencies, including the necessary parts of FFmpeg. (FFmpeg is licensed under the GPL v3, and therefore cannot be directly included in Ignition modules.)

Copy opencv-420.jar from the Windows build to /usr/share/java, ensure its permissions are +rx, and then create a soft link there as opencv.jar.

Restart the streamer module via the gateway's web configuration interface to pick up the newly-installed libraries.

Ubuntu Linux 18.04 LTS

Ubuntu 18.04 packages a Jar file for OpenCV 3.2.0 compiled with OpenJDK 10. This is perfect for Ignition v8.0, as v8 runs with its own copy of Java 11. Execute the following command on the gateway and you should be ready to run:

sudo apt install libopencv3.2-java

Ubuntu Linux 18.04 LTS with Ignition v7.9.x

Like Ubuntu Server 20.04, 18.04 packages a jar file that is incompatible with Java8. In this case, it is OpenCV 3.2.0 compiled with OpenJDK 10. Ignition v7.9 cannot run under Java10+ and therefore cannot use the above jar file. Follow the above instructions for Ubuntu 20.04, but use the jar file from the Windows OpenCV 3.2.0 installer instead of 4.2.0.

Execute the following commands on the gateway:

sudo apt install libopencv3.2-jni
sudo mkdir -p /usr/share/java

Copy opencv-320.jar from the Windows build to /usr/share/java, ensure its permissions are +rx, and then create a soft link there as opencv.jar.

Restart the streamer module via the gateway's web configuration interface to pick up the newly-installed libraries.

OpenCV Library Location Override

If the default library locations for your platform do not match the preferred OpenCV install locations for your operating system and architecture, you may specify the correct locations (Jar and JNI) in the gateway's configure => OPC-UA Server => OpenCV settings page.

When creating an override for the gateway, use Gateway as the Machine ID (verbatim).

When creating an override for a specific machine for client or designer scope, use the Ethernet MacID as the Machine ID. It must be six bytes shown in lower case hexidecimal, separated by colons. Be sure to use the MacID for the ethernet port that will carry the connection to the gateway. If in doubt, look at your designer's console or your client's diagnostic console, where the module will report the machine ID it is looking up.

Return