Common Vision Blox 15.0
Getting started with CVB tutorials

This documentation will guide you through the first steps of setting up your system to compile and run CVB tutorials, using CMake, Qt and QML.

Recommended tool chain

Even though you can use Qt or QML in Microsoft Visual Studio as it is to generate Windows C++ applications, it makes sense to use CMake to generate these Visual Studio solutions and GCC Makefiles based on CMakeLists files. For Python applications we recommend using Visual Studio Code, which is a free and open source code editor, running on Windows and Linux.

CMake is an open source, cross-platform toolset to build applications for various operating systems and processors using compiler independent configuration files. To make use of Qt under Linux and Windows STEMMER IMAGING has generated CMake configuration files for Common Vision Blox.

This documentation is based on Common Vision Blox 2019 (minimal CVB version number 13.2).

Setting up your system

This chapter describes, how to setup the tool chain under Windows as well as on Linux based systems. The procedure is mostly similar, but differs in minor details as follows.

It was tested with

  • Windows 10
  • Ubuntu 18.04 LTS
  • Ubuntu 20.04 LTS

CMake version (for details see Service):

  • Minimal 3.5

Qt versions (for details see Service):

  • Minimal 5.9.x
  • Recommended 5.12.x or newer

Microsoft Visual Studio Compiler version (Windows only):

  • Minimal Microsoft Visual Studio 15 VC14

Before you begin, install Common Vision Blox and ensure proper installation by starting one of the supplied sample applications. On Windows system test your compiler environment by recompiling a source code of a supplied tutorials from %CVB%Tutorial directory.

C++, CMake and Qt

This chapter describes, how to set up your system for testing and developing C++ applications on following platforms:

Windows Setup (C++)

1) Install CMake. Minimal version: see Setting up your system

2) Execute the installer and let it add CMake to the system path:


3) Install latest Qt Online Installer for Windows. It is necessary to create a Qt account for commercial purposes before starting the Qt Online Installer. For Open Source purposes the creation of a Qt account can be skipped. Minimal and recommended Qt version: see Setting up your system. See Qt links for further support.

4) Execute the Qt Online Installer and enter your account credentials optionally. Enter the installation path, in our example it is G:\Qt. Select the Qt version you would like to install. The Qt version has to match your compiler and your operating system.


5) Continue the installation.

6) Set the environment variable by adding G:\Qt\<version>\bin to the PATH variable:

  • Windows-Key + R
  • Type sysdm.cpl
  • Set the PATH



7) Create an environment variable named CMAKE_PREFIX_PATH and set it to the path of your Qt directory:


8) Minimal compiler Visual Studio: see Setting up your system

Your system is ready to use CMake and Qt with Common Vision Blox.

Linux (Ubuntu) Setup (C++)

This documentation has been tested with Ubuntu 18.04 and 20.04.

1) Open a terminal and ensure the system integrity by updating your installed components and their dependencies:
sudo apt-get update

2) Install the latest version of the GNU C++ compiler:
sudo apt-get install g++


3) Install CMake:
sudo apt-get install cmake


4) Install latest Qt Online Installer for Linux. It is necessary to create a Qt account for commercial purposes before starting the Qt Online Installer. For Open Source purposes the creation of a Qt account can be skipped.

Minimal and recommended Qt version: see Setting up your system. See Qt links for further support.

On Ubuntu 18.04 based distributions you can get a suitable Qt version through apt-get. The needed packages are listed in the tutorial documentations, e.g. QmlGevServer tutorial.


5) Change the access rights of the downloaded .run file with
chmod u+x <qt-file>.run


6) Execute the file with e.g.
./qt-unified-linux-x64-3.1.1-online.run,
which will start the Qt Online Installer. It is necessary to create a Qt account for commercial purposes before starting the Qt Online Installer. For Open Source purposes the creation of a Qt account can be skipped.

7) Execute the Qt Online Installer and enter your account credentials optionally. Enter the installation path, in our example it is /opt/Qt. Select the Qt version you would like to install. The Qt version has to match your compiler and your operating system.


8) Continue the installation.

9) Install the GL components with
sudo apt-get install libgl-dev.


Your system is ready to use CMake and Qt with Common Vision Blox.

Linux (Ubuntu) Setup on ARM (C++)

If you are using the supplied image for the ARM based Odroid system you will notice that all necessary installation steps have already been carried out for your convenience. If you are using the supplied Common Vision Blox setup package for the ARM architecture follow the steps as described above for Intel based Ubuntu operating systems to install CMake and CMake GUI.

If you are using the image for ARM based Odroid system your system will be configured properly. Nevertheless it makes sense to update your system to the latest software.

1) Open a MATE Terminal you will find on the Desktop of the support user:


2) Update your installed components and their dependencies:
sudo apt-get update
sudo apt-get upgrade

3) Please note that you have to build Qt yourself, except for maybe 18.04 images.

4) All other steps are the same as on Linux, so you may follow the instruction of Linux (Ubuntu) Setup (C++).

Your system is ready to use CMake and Qt with Common Vision Blox.

Python and Qt

This chapter describes, how to set up your system for testing and developing Python applications on following platforms:


Windows Setup (Python)

1) Download and install Python with recommended minimal version (see Setting up your system). Ensure to get the right version of 32 bit or 64 bit!

2) Set the environment variable by adding the Python path and Python Scripts path to the PATH variable:

  • Windows-Key + R
  • Type sysdm.cpl
  • Set the PATH


Current supported Python version by CVB can be read from CVB wheel name (example here 3.6 /3.7 / 3.8 / 3.9) :


3) Go to %CVB%Lib\Python and install the python wheel with
python -m pip install <WHEEL>.whl
or
pip install <WHEEL>

4) Install following additional 3rd party dependencies, if required:

  • python -m pip install pyside2 for all tutorials with Qt and python.
  • python -m pip install numpy for all tutorials with NumPy.

5) It is recommended to use Visual Studio Code for developing with python. After installing Visual Studio Code also install the Python extension as described here: https://code.visualstudio.com/docs/python/python-tutorial.



6) Install Qt as described in following Windows Setup (C++).

Linux (Ubuntu) Setup (Python)

1) Install latest python3 with
sudo apt install python3-pip.


2) Go to /opt/cvb/python and install the python wheel with
python3 -m pip install <WHEEL NAME>.whl.


3) Install following additional 3rd party dependencies, if required:

  • python3 -m pip install pyside2 for all tutorials with Qt and python.
  • python3 -m pip install numpy for all tutorials with NumPy.



4) It is recommended to use Visual Studio Code for developing with python. After installing Visual Studio Code also install the Python extension as described here: https://code.visualstudio.com/docs/python/python-tutorial.


Installation process:




5) Install Qt as described in following Linux (Ubuntu) Setup (C++).

Linux (Ubuntu) Setup on ARM (Python)

Please follow the instructions of Linux (Ubuntu) Setup (Python). The only difference is that you do not have pyside2 on ARM, so no UI will be available.

Building a CVB sample application

This chapter describes, how to compile and run a CVB sample application under Windows as well as on Linux based systems. The procedure is mostly similar, but differs in minor details as follows.

It was tested with

  • Windows 10
  • Ubuntu 18.04 LTS
  • Ubuntu 20.04 LTS

C++ and CMake

This example will demonstrate with QtStatisticsDisplay example (a Qt application that displays a camera image) how to use CVB, Qt and CMake together. There are more examples provided with an installation of CVB. All of them are CMake projects and many based on Qt / QML. Feel free to explore them all.

For further information on programming with CVB explore our Common Vision Blox Online Help.

Windows with CMake

1) From the Windows Start menu start the CMake GUI. For the source directory select
%CVB%Tutorial/Image Manager/Cvb++/QtStatisticsDisplay
and for the build directory select
%CVB%Tutorial/Image Manager/Cvb++/QtStatisticsDisplay/build

Run the tutorial in bin subfolder
%CVB%Tutorial/Image Manager/Cvb++/QtStatisticsDisplay/bin


2) Click the Configure button and select your Visual Studio version and your desired platform (default is Win32). The configuration takes a while to be finalized and no error should be reported.


Click the Finish button and the configuration will start and present the results:


The warning "setting up CVB Qt bridge for UI components - do not forget to link CVB::CvbUI" is not an error and can be ignored.


3) Now click the Generate button. This will generate a couple of Visual Studio solutions in the build directory:


4) Load the QtStatisticsDisplay.sln solution file in Visual Studio and execute a Build Solution command:


5) Finally execute the sample:

Choose QtStatisticsDisplay as StartUp Project.


Then start the application.


The result should look like this after a first snap:


Congratulations. You have built and ran your first Common Vision Blox sample using Qt. The code of the sample can be compiled under different operating systems as well as on different projects. Repeat the steps for the other samples. It is not too difficult.

Linux (Ubuntu) with CMake

1) Copy the tutorial folder to your home folder to compile the tutorials with access rights:

  • E.g. mkdir ~/CVB
  • cp -r /opt/cvb/tutorial ~/CVB

2) Create a build directory in the path of the tutorial (mkdir bin), if it does not exist yet, and change to build directory with cd bin.


3) Run cmake to generate the Makefile:
cmake -DCMAKE_PREFIX_PATH=/opt/Qt/5.13.0/gcc_64 ../


4) Run make to generate the binary file:
make


5) Execute the sample with
./QtStatisticsDisplay


Congratulations. You have built and ran your first Common Vision Blox sample using Qt. The code of the sample can be compiled under different operating systems as well as on different projects. Repeat the steps for the other samples. It is not too difficult.

Python

This example will demonstrate with QmlStreamDisplay (a Qt application that displays a camera image) how to use CVB and QML together. There are more examples provided with an installation of CVB. Many of them are based on Qt / QML. Feel free to explore them all.

For further information on programming with CVB explore our Common Vision Blox Online Help.


Windows with Visual Studio Code

1) From Visual Studio Code open the folder (not the file!) %CVB%Tutorial\Image Manager\CVBpy\QmlStreamDisplay.


2) Start Debugging either from menu or with F5. For additional debug output of QML UI, you may set and enable the environment variable QML_IMPORT_TRACE=1 (see https://doc.qt.io/qt-5/qtquick-debugging.html).


Select Python File.


3) The example will start immediately. The result should look like this after a first snap:


Congratulations. You have ran your first Common Vision Blox sample using Qt with Python. The code of the sample can be run under different operating systems as well as on different projects. Repeat the steps for the other samples. It is not too difficult.

Linux (Ubuntu) with Visual Studio Code

1) Copy the tutorial folder to your home folder to compile the tutorials with access rights:

  • E.g. mkdir ~/CVB
  • cp -r /opt/cvb/tutorial ~/CVB

2) You may start the ~/CVB/tutorial/ImageManager/CvbPy/QmlStreamDisplay with command
python3 display.py.
Or you might use Visual Studio Code (see below).


3) Open the folder (not the file!) ~/CVB/tutorial/ImageManager/CvbPy/QmlStreamDisplay in Visual Studio Code. Follow the instructions in https://code.visualstudio.com/docs/python/python-tutorial to select the Python interpreter.

For additional debug output of QML UI, you may set and enable the environment variable QML_IMPORT_TRACE=1 (see https://doc.qt.io/qt-5/qtquick-debugging.html).

Then start debugging.


Select Python File.


4) The example will start immediately. The result should look like this:


Congratulations. You have ran your first Common Vision Blox sample using Qt with Python. The code of the sample can be run under different operating systems as well as on different projects. Repeat the steps for the other samples. It is not too difficult.

Conclusion

The configuration and generation steps in CMake and installation of Qt, Python and Visual Studio Code have to be done only once per system. By finishing this on all of your different machines, you can further develop your application on your preferred machine and distribute the file changes to the other platforms for recompilation. This allows you to select the target platform depending on the required performance of your application.

Service and Troubleshooting

If you determine issues with any 3rd party applications like CMake, Qt, Python or Visual Studio Code, please check the according websites for help as they mostly offer help pages and tutorials:

CMake

CMake is an open-source, cross-platform family of tools designed to build, test and package software.

CVB

Python

Python is an interpreted, high-level programming language.

QML

QML (Qt Modeling Language) is a user interface markup language. It is associated with Qt Quick, the UI creation kit within the Qt framework.

Qt

Qt is a free and open-source widget toolkit for creating graphical user interfaces as well as cross-platform applications.

Visual Studio Code

Visual Studio Code is a source-code editor developed by Microsoft for Windows, Linux and macOS.

Updates

Please check the CVB Web pages for CVB service packs, hotfixes or new versions. Therefore please visit the Service-Download area of the CVB User Forum Download area and choose the CVB Version and Operating System.

Technical Support

Before contacting the Technical Support please review the

  • configuration hints in sections before,
  • save logs and hardware configuration settings.

Report also the versions of Common Vision Blox, Operating System and the devices serial numbers.