• Skip to main content
  • Skip to header right navigation
  • Skip to site footer
CDP Studio logo

CDP Studio

The no-code and full-code software development tool for distributed control systems and HMI

  • Doc
  • Why CDP
    • Software developers
    • Automation engineers
    • Managers
  • Products
    • Automation Designer
    • HMI Designer
    • Maritime HMIs
  • Services
  • Use cases
  • Pricing
  • Try CDP

Blog

How to integrate OpenCV with CDP Studio

CDP Studio can be integrated with OpenCV to use their vision libraries, this allows you to develop control systems using computer vision. This blog explains how you integrate OpenCV and some useful tips.

OpenCV and CDP Studio logo

Open Source Computer Vision Library (OpenCV) is an open source computer vision and machine learning software library. OpenCV was built to provide a common infrastructure for computer vision applications and to accelerate the use of machine perception in the commercial products.

Download the OpenCV libraries from the CDP Technologies download server. See also OpenCV colour tracking project example on the CDP Technologies GitHub, make sure to read the project wiki page.

Import OpenCV libraries to CDP Studio

The first step is to import the OpenCV libraries to CDP Studio, from the File menu:
Select File -> Import Library

Import_openCV

Next a dialog appears where one must specify headers directory and binaries. OpenCV header files are in include directory.

  • For Windows binaries are in opencv-windows-release/x86/mingw/bin folder folder and debug versions in opencv-windows-debug/x86/mingw/bin. Select and add all .dll files.
  • For other targets binaries are in lib directory. Select all .so files and add same files for both debug and release versions.
    Note: make sure to select a toolkit that matches the CDP version of your project.
Import_openCV_details

Note: Import Library dialog must be run for both host and target platforms.

For example, when developing a CDP system using OpenCV on Windows and deploying it on Raspberry Pi, the dialog must be run once for Windows binaries and once for Raspbian binaries. Make sure to set same Name each time (e.g. “opencv”).

Using OpenCV in CDP library

Adding dependencies

To use OpenCV in your CDP application one should first create a CDP library project and add a CDP Component to it. Next one must add OpenCV dependency to this library project. For that go to Code Mode, right click on the library project and select Add Library.

OpenCV_add_library

In the dialog select External library and from the list the name you entered when running Import Library wizard, e.g. “opencv”. Next open again the Add Library dialog, select CDP library and from the list CDP2QtLib.

Code and multi-threading

The UI part of OpenCV must always be accessed from main thread that runs the UI event loop. Do not create windows from CDP thread (like the Process() function in CDP Component). One easy way to execute code on UI thread is to use QTimer::SingleShot() function that takes lambda as an argument.

Also note that to access objects living in CDP Component thread (like CDPProperty, CDPSignal, CDPParameter) from UI thread, one should first lock component mutex or use RunInComponentThread() function.

OpenCV-add-lib2

Adding Component to CDP Application

The pre-built OpenCV binaries bundled with this guide have Qt dependency. Therefore, they work correctly only when dragged into a CDP GUI Application, which always bundles Qt. After creating a System project, go to Configure Mode, right click on the System and select Add GUI Application.

After that, drag your CDP Component into from Resource pane into your CDP GUI Application. By default, CDP GUI Application includes an empty form called mainwidget for creating your own UI. If you have no need for it, remove the CDP2Qt subcomponent.

OpenCV-adding-components

Technical

Get CDP Studio

Download and get started with CDP Studio today.
All our plans includes a free 30 day trial.

Try CDP Studio now

CDP Technologies AS
Hundsværgata 8,
P.O. Box 144
6001 Ålesund, Norway

Tel: +47 990 80 900
E-mail: info@cdptech.com

Company

About CDP

Contact us

Services

Partners

Blog

Developers

Get started

User manuals

Support

Document download

Release notes

My account

Follow CDP

  • LinkedIn
  • YouTube
  • GitHub

© Copyright 2025 CDP Technologies. Privacy and cookie policy.

Return to top