-
Notifications
You must be signed in to change notification settings - Fork 0
Home
This guide presumes some experience with CDP Studio. For new users it is recommended to first watch some tutorial videos of CDP Studio, like creating Raspberry LED Blinker to get general idea how to use Studio.
There is also a different OpenCV example on our page, named OpenCV-ColorTracker. The Camera component of that project is similar to the CameraWidget, but the component shows in a separate window and cannot be edited in CDP Studio design mode.
This project is a small demo of using OpenCV computer vision library with CDP Studio. It includes two projects:
- CameraWidget - contains pre-configured CDP Application that is ready to run
- CameraWidgetLib - contains the C++ code that uses OpenCV
Inside CameraWidgetLib there is one component and one widget:
- CameraWidgetDependencies - empty component that is not activated, but ensures deployment of required dependencies
- CameraWidget - the widget is not visible as a resource, but is made available to the dynamic loader at run-time
This project depends on OpenCV:
- Download OpenCV from http://download.cdpstudio.com/libs/opencv/3.4.1
- Follow the Using OpenCV with CDP Studio guide
- Make sure OpenCV is downloaded and imported as described under Prerequisites
- Open both CameraWidget and CameraWidgetLib projects with CDP Studio
- First build the library project CameraWidgetLib. Then run the CameraWidget system
If successful, a window should display the image from webcam.
To see the implementation of CameraWidget, go to Code Mode and open CameraWidgetLib -> Sources -> camerawidget.cpp.
Users that are familiar with CDP Studio and that are curious about custom widgets should note the following:
- The CameraWidget class is created as shown in camerawidget.h and camerawidget.cpp
- The widget is made available to the ui loader by making the CameraWidgetLibBuilder inherit CDP2QtBuilder and implement CreateNewWidget.
- The widget is added in the ui file by promoting a QWidget to CameraWidget (promoted widgets are often referred to as placeholders).
- Properties that are added to the CameraWidget must also be added to the promoted widget as dynamic properties to enable editing.
- The GUI application contains a dummy component, CameraWidgetDependencies, to ensure that CDP Studio deploys the required dependencies.