Download file
This example project shows how to use the GPIOs with CODESYS on a IOT2000 with GPIO expansion module.
In this example a picture gets evaluated via python and the free library of programming functions opencv.
There are different color circles in the picture, the blue ones are filtered and coordinates of the contoures are written in a string.
The string gets combined with a string of the current time stamp. This string gets transferred into a byte array and filed on shared memory.
For a selected time the shared memory is open (in this case 60 seconds), to make it possible for CODESYS to read the data.
In CODESYS the shared memory buffer is read and the byte array is transferred to a string again.
After transferring to string the coordinates of four contoures are in the string such as the time stamp.
Another prepared possibility is the evaluation of a video stream, the contours in this case are limited to five to get no overflow.
Preparations
Open "OpenCV_Example2.project" via CODESYS.
Install Python 3.4 or higher, set the environment variables in Path and install opencv:
Command line : pip install opencv-python
Procedure
Start CODESYS and connect to local ControlWin and log in, start, etc.
In monitoring (PLC_PRG.strRead) value of string is "".
Run python script -> In monitoring string has four coordinates and one time stamp.
Further functionalitys
The main functionality of opencv can be looked up on the website https://opencv.org/.
For more functions the buffer of shared memory maybe must be increased.
System requirements and restrictions | Info |
---|---|
Programming System | CODESYS Development System Version 3.5.17.0 or higher |
Runtime System | CODESYS Control IOT2000 SL Version 4.1.0.0 |
Required Accessories | IOT2000 GPIO expansion module |