Makers Blog Archive

Compile OpenCV for a PLCnext Control

PLCnext Team 28 May 2018 min. read
108 views 0 comments

OpenCV (Open Source Computer Vision) is a cross-platform and free-for-use library for use in the emerging field of computer vision, a science on how computers extract information from digital images or videos. It’s about acquiring and processing visual data, and making decisions and performing actions based on the analysis. OpenCV support deep learning frameworks and includes a statistical machine learning library, what makes it applicable for motion tracking, gesture and facial recognition, and object identification.

Because community member David Petter was really interested in using OpenCV in combination with a PLCnext Control, he made an updated tutorial on this topic, using the current versions of FFmpegOpenCV, and the AXC firmware.

For this, he used the ‘old’ tutorial he got from community member Vincent Gijsen, who works at Phoenix Contact. All the used scripts and install commands are originally created by Vincent. David only changed small details to make it all work for the current versions of the used libraries and its dependencies.

Thanks a lot to both of them for sharing this tutorial with the community. This is a great example on how to implement open source code with PLCnext Technology!

(…virtually handing over the microphone to David…)

Preconditions and links

Preconditions

So, to get started, I need to make some assumptions. If you don’t have the listed things ready yet, I suggest you start at the ‘getting started’ pages on the community website.

  • Operating System (VM): Linux
    (tested with Ubuntu 16.04.1 LTS 64-bit)
  • nano editor in use
  • CMake installed
  • Eclipse with PLCnext Technology Plug-in already installed
    (tested with Neon.3 rel. 4.6.3)
  • Newest PLCnext Technology SDK installed in this folder:
    /opt/pxc/2.2.1
  • You can consider a symlink:
    /opt/pxc/current

A symlink or “symbolic link” can be used as a reference to a directory. Example: Your files are in /opt/pxc/folder1/folder2/folder3/.
If you were to make a symlink, you can for instance link /opt/file to /opt/pxc/folder1/folder2/folder3/.
This is useful for many things, especially if you need to reference that file in folder3 a lot. Instead of needing to re-type that long file location, you just type /opt/file. I did not use a symlink in this tutorial.

Download links:

  • nano – this tutorial is based on the nano editor for Linux; adapt, if you use another editor.
  • CMake – we will use it later
  • PLCnext Technology SDK – be sure to download the matching SDK, either for 32-bit or 64-bit Linux OS
  • Eclipse Plug-in – same source as the SDK, second link just for convenience

Make sure everything is set up to create, build, and export the library. If all that is working, you can proceed with this tutorial. All other dependencies will be compiled in the course of this tutorial.

Set up the build environment





disclaimer-root-user

Compile FFmpeg









Screenshot Machine ARM

Compile OpenCV

Screenshot: Output









Transfer Libraries to PLCnext Control

Configure Eclipse

Choose Properties
Choose Settings
Add Include path
Cross G++ Linker

Write a test program

Note:

The Makers Blog shows applications and user stories of community members that are not tested or reviewed by Phoenix Contact. Use them at your own risk.

Discussion

Please login/register to comment
Login/Register
Newsletter
Never miss a new article
Sign up for the newsletter
Never miss news about PLCnext Technology
Get interesting content via newsletter four times a year
Receive exclusive information before all other users