Camtool plugin development¶
- Camtool plugin development
This page describes how to develop custom plugins for XIMEA software - CamTool.
The plugins are implemented in the Qt framework.
To create a custom plugin, it is necessary to configure the development workspace.
This includes building the Qt, installing Qt Creator.
After this environment is prepared, the custom plugin may be built and added to the XIMEA CamTool.
Development workspace preparation¶
The following instructions assume you are working on Windows.
If you are working with Linux, please have a look at the instructions for Linux.
There are 4 main components required to develop CamTool Plugins:
- Ximea API SP installed.
- CamTool compatible C++ compiler (MSVC 2013 VC++)
is recommended to use).
- Qt Framework - headers and libraries for linking (the .lib files) + runtime (the .dll files).
- Qt Creator - the native Qt development tool.
CamTool SDK installation¶
Check The CamTool Example when installing the XIMEA SP.
Install from source¶
Build Qt from sources (official guide can be found here) - use the commit tagged as v5.6.1
Qt installation steps:¶
- Download the "single zip" package of the QT from this page.
This single package contains all the required Qt source files.
- Create a directory corresponding to the CamTool version you are using:
- For 32-bit CamTool ->
C:\Qt\5.3.1_x86 (for 32bit build)
- For 64-bit CamTool ->
C:\Qt\5.3.1_x64 (for 64bit build)
- For 32-bit CamTool ->
- Unpack the source files and copy the content to the
5.3.1_x64) directory created in the previous step.
- Open the Visual Studio Command Prompt:
- For 32bit: Start - All Programs - Microsoft Visual Studio 2010 - Visual Studio Tools - Visual Studio Command Prompt (2010),
- For 64bit: Start - All Programs - Microsoft Visual Studio 2010 - Visual Studio Tools - Visual Studio x64 Win64 Command Prompt (2010),
- In the command prompt move to:
C:\Qt\5.3.1_x86 (32bit cmd prompt)
C:\Qt\5.3.1_x64 (64bit cmd prompt)\
- Execute "configure -opengl desktop" from the command prompt.
Follow the instructions displayed by the script - compile the Open Source version when asked.
After a while (1-2 minutes) the configuration is done.
- Execute the "nmake" command which starts the Qt compilation.
The compilation takes several hours.
Note: Some modules don't need to be installed. They can be skipped by calling
./configure -skip <selected module> from the command line.
Qt Creator installation¶
The Qt Creator IDE required for the CamTool plugin development can be downloaded here.
Next step is to install the Qt Creator.
Qt Configuration steps:¶
- Start the Qt Creator.
- In the main menu select Tools - Options....
- Select the Build & Run on the left-side toolbar.
- Select the Qt Versions tab.
- Click the Add button, it displays an open file dialog.
- Select the
C:\Qt\5.3.1_x64\qtbase\bin\qmake.exefor 64-bit ).
- Activate the Kits tab.
- Click the Add button. It displays a dialog.
- For 32bit fill the dialog as shown in the image below and click the Apply button.
- For 64bit fill the dialog analogically but be sure that you selected the correct x64 compiler, debugger and Qt version.
- Click the Ok button.
Open xvpSample.pro located in the C:\XIMEA\Examples\CamTool\xvpSample.
Select the desired project configuration (according to the image below) and click Configure Project.
Then select the xvpSample project and build it with the desired configuration.
xvpSampleDist.pri contains paths with regards to the folder structure in Examples. You can rename it to xvpSample.pri and replace the previous one.
Important! - The plugin has to be built with the proper archive type (32-bit, or 64-bit).
The built plugin is located in the C:\XIMEA\Examples\CamTool\xvpSample\bin directory as a xvpSample.dll. file.
To install the plugin into Ximea CamTool, follow these steps:
- Copy the xvpSample.dll into C:\XIMEA\XIMEACamTool root directory
- Open CamTool, go to Plugins -> Plugin Manager. If the plugin is loaded correctly, it should be listed in the Plugins table.
- Check if the plugin is enabled in the Tools menu. It should look like this:
Mean grey measurement¶
Users can draw rectangles into opened image views and the mean intensity is measured inside them.
Users can additionally resize the rectangles and the result is recalculated.
When on a live image from the camera, the result is calculated 4x per second (not to block the CPU for high frame rates).
The results are shown in the docked widget at the bottom of the screen (hidden as default).
The measurement table was designed in Qt Designer inside Qt Creator and is added to the application in CxPlugin::init.
The rectangles are added as CxVectorObjectRect to the image in mouse events relayed to the plugin in CxPlugin::viewMouseBtnPressEvent, CxPlugin::viewMouseMoveEvent and CxPlugin::viewMouseBtnReleaseEvent. The changes to the geometry are detected using CxVectorObjectRect::rectChanging signals called from CxVectorObjectRect instance.
When measuring the image, the image data is obtained using IxAppDelegate::viewCurrentImage.
To measure on live image, the data in CxPlugin::viewGotNewImage notification is used.
The results table stores the view ID and ID of the rectangle for each record to identify the object on the screen, to be able to update the results and delete the objects when the user wishes to.
Simple in-place image processing.
It does not change the image format, so it returns the same SxPicBufInfo as on input in CxImageProvider::queryOutputImageInfo and as it is in place, it does not require any additional image buffers, so returns 0 in CxChainable::buffersCountInMemoryPool.
Another image processing object.
Works with images in RAW format, and sends RGB image as output. As it needs to allocate new image, it returns 1 in CxChainable::buffersCountInMemoryPool.