MATRIX VISION - mvBlueLYNX-M7 Technical Documentation
|
The "Programming local applications" book gives you a short overview, how you can program local applications for the mvBlueLYNX-M7 the easiest way. It is arranged successively that means if you read the sections one after another you will get the information you need to start programming without any difficulty.
Let's start with
As described System architecture section in the How to get started? chapter, it is possible to run local applications based on mvIMPACT Acquire on the mvBlueLYNX-M7 , given that it runs an embedded Linux OS.
The applications can perform image analysis and decide whether the data is transmitted or not and what additional data will be send, if this is needed. In the latter case, you can either send the image or the processed image or only the processed data like a decoded barcode.
A short introduction to both local application scenarios:
In this scenario you can use the mvBlueLYNX-M7 without any connection to a client PC, except for loading the local driver files. Additionally, a serial connection to start and stop the application could be necessary.
In this scenario the mvBlueLYNX-M7 transfers the data via GigE compliant streaming to a host PC using the vl_transmit library (gevss = GigE Vision streaming server, gevcs = GigE Vision control server).
The application properties can be set up via GenICam.
The directory structure of mvBlueLYNX-M7 , where you can (only) save or change data looks like this:
Programs written by the user are saved in /flash/MatrixVision/bin
while MATRIX VISION libraries (mvIMPACT Acquire and mvIMPACT SDK) are located in /flash/MatrixVision/lib
. Given that the library path is set to /flash/MatrixVision/lib
by default, you do not have to set it manually.
/flash
you can also find the autostart script.If you want to save files on the camera, you can use secure copy and will need write access. The following sample shows, how this will work via Linux:
"root"
. Afterwards the copy procedure will start. On Windows PCs you can use WinSCP. With WinSCP it is possible to start ssh with PuTTY. PuTTY has to be in the same directory.
"remount ro"
). Otherwise the garbage collector of the file system will work permanently, which could decrease the lifetime of the Flash memory.Normally for a development environment, you need and have to install
With mvBlueLYNX-M7 , MATRIX VISION ships a Virtual Machine (VMware) image based on Kubuntu including all these listed things for mvBlueLYNX-M7 development. The image can be run on Windows® systems with VMware server. Please continue with the next section.
The mvBlueLYNX-M7 has an Embedded Linux as its operating system. To develop software applications for the mvBlueLYNX-M7 you would need a suitable development environment based on Linux with all needed software like mvIMPACT Acquire.
So that you have to pay no attention to this, MATRIX VISION created an VMware image, a virtual machine with Linux as operating system and all needed software and installation to start developing immediately.
This section will explain,
For system requirements, please have a look at Requirements.
The base system for our VMware image is the latest Kubuntu distribution "8.04". This Kubuntu image is already optimized for the VMware software like automatic mouse release, VMware grahics card etc.
We do not recommend to use the distribution based update utility like "adept_manager", "synaptic" or any command line version like "apt-get update". We will extend the image with improvements and new software packages which are necessary in developing applications in the near future.
To start the VMware image, please follow these steps:
"...\sdk\"
) onto your PC. Preferably, please use the standard directory of the VMware server ("C:\Virtual Machines"
). It is also possible to access the VMware image via VNC. Please follow the link for further information.
A direct communication (without GigE Vision) with the camera is necessary to copy files and set up the camera. For this, it is important to know the IP address of the camera. You can get the IP address with the programs wxPropView (property: "Device > DeviceIPAddress"
) or mvIPConfigure.
Now, please open a Shell in the VMware:
Please click on the desktop icon "Command Shell".
A Shell window will be opened:
For security reasons, the camera supports only Secure Shell (ssh). Only one user is set up on the camera: root
For this reason, the access to the camera will look like this:
For example:
You will be asked for the password. Please insert root
.
Now, you are logged on the camera and with the commands cd
you can change the directory and with ls
it is possible to list all files in the directory.
With NFS
Although it is possible to copy files to the camera via secure copy (scp
), it is much easier to share a directory (with read and write permissions) which can be used by the development environment and the camera. This can be done by mounting the directory. A directory for shared usage is prepared in the development environment: /home/mvbc/
. This directory includes all libraries as well as the examples.
To mount this directory in the directory structure of the camera, please use the following command in the Shell :
For example:
It is important to use the IP address of the virtual machine instead of the IP address of the host PC, given that both have different addresses. To get the address of the virtual machine, please open a new Shell and enter the command:
You will receive result like the following:
The second line shows the IP address of the virtual machine (here: inet
Adresse:192.168.1.150).
Now you can change to the directory /mnt/user/work
on the camera and with the command ls
the same files are shown which you can find on the virtual machine in /home/mvbc/
.
With CIFS
If you want to mount the folder by hand, with CIFS you can do this in the following way (from mvBlueLYNX-M7 to Virtual Machine (VMware) share (public)):
xxx.xxx.xxx.xxx is the IP address of the Virtual Machine (VMware).
Or alternatively, if you do not want to show the username and password:
The content of credentials would be in this example:
Afterwards, you can create the local sample applications as described in Running an example.
Exchange files between host PC without network connection and VMware
If you have a single PC without network connection and want to exchange files from the VMware image to this host PC, you have to do following:
All needed software can be found in the /home/mvbc/workspace/
directory.
mvIMPACT Acquire is the API for all MATRIX VISION products excluding standard mvBlueLYNX. To control the camera and handle the images, you will have a good introduction by reading the main pages of the mvIMPACT Acquire interface references. Additionally, please have a look at the example programs. Several basic examples are available. The separate mvIMPACT Acquire manuals are
mvIMPACT Acquire development environment is pre-installed and can be found in the directory /home/mvbc/workspace/mvimpact-acquire
of the VMware. mvimpact-acquire is a symbolic link to the mvIMPACT Acquire development directory whose name is composed like this: mvimpact_acquire-
[Version]. E.g. "mvimpact_acquire-1.10.3.81"
.
If you want to (re-)install mvIMPACT Acquire or mvIMPACT SDK in the VMware, please have a look at Installing driver - Linux® Updating mvIMPACT Acquire
For updating mvIMPACT Acquire API, MATRIX VISION offers two files:
".tgz"
file (e.g. mvimpact_acquire-ppc_6xx-1.10.3.84.tgz) Briefly, to install a new mvIMPACT Acquire API in the VMware, you have to
/home/mvbc/workspace
(please have a look at SMB) andIf you want to (re-)install mvIMPACT Acquire or mvIMPACT SDK in the VMware, please have a look at Installing driver - Linux®
The mvIMPACT Acquire API can be found in the directory /home/mvbc/workspace/mvimpact-acquire
. mvimpact-acquire is a symbolic link to the mvIMPACT Acquire development directory with the name:
E.g.:
In this folder, you can find libraries and samples for a remote application (native Linux, TARGET = x86) as well as for a local application (PowerPC Linux (mvBlueCOUGAR/mvBlueLYNX-M7), TARGET = ppc_6xx)
Please follow these steps to build the existing mvIMPACT Acquire applications for mvBlueCOUGAR:
To build a single sample, you have to change in to the corresponding sample directory and execute:
in the corresponding directory or by making all samples in the root directory of mvimpact-acquire
with the same command.
mvIMPACT SDK is a comprehensive library with high performance algorithms for fast image processing. The library offers a software architecture with an object oriented design. With MATRIX VISION hardware, the mvIMPACT Base module, a comprehensive library with about 120 useful functions for e.g. image processing, is free of charge.
Other advanced modules like Blob, Data Matrix, etc. are available on the Virtual Machine (VMware) image as test versions.
The complete mvIMPACT manual is available as a CHM file on the MATRIX VISION website: http://www.matrixvision.de/support/manuals.php
Differences between Windows and mvBlueLYNX-M7 version of mvIMPACT SDK
The following modules are not available for the PPC - Linux mvIMPACT version of mvBlueLYNX-M7 :
vl_display | Display module of mvIMPACT |
vl_3ddisp | mvIMPACT 3D Display |
vl_device | Device module of mvIMPACT |
vl_driver | part of mvIMPACT Base responsible for general frame grabber integration |
Additionally, there is the module vl_transmit, a library for transferring images, result data like texts or overlay elements (like rectangles, points, etc.) via GigE Vision.
The mvIMPACT SDK can be found in the directory /home/mvbc/workspace/mvimpact
.
Please follow these steps to build the existing mvIMPACT SDK applications:
To build a single sample, you have to change in to the corresponding sample directory and execute:
Eclipse is an IDE, which is available on the Virtual Machine (VMware) image. Naturally, you can use your own preferred IDE, but this section will describe the usage of Eclipse.
For the start of Eclipse, you have to indicate the workspace:
/home/mvbc/workspace/mvimpact-acquire/apps
Loading an existing Eclipse project
If an Eclipse applications already exists, you can load it to the IDE as following:
/home/mvbc/workspace/mvimpact-acquire/apps/SingleCapture
. Create a Eclipse project with an existing Makefile application
Please follow these steps:
The new project is displayed in the Project Explorer. Via "Project | Build All" you can start the build (compiling and linking).
Release and debug configuration in Makefile project
After creating an Eclipse Makefile project you can create different configurations. Please follow the next steps to create a Release and a Debug configuration.
Configuration management
To create a new configuration for a project, you have to open the dialog with the project properties:
After creation of Debug and/or Release configuration you can adapt the "Builder settings" and "Behaviour" of the Makefile make command.
You have to adapt following entries in the Debug configuration:
You have to adapt following entries in the Release configuration:
Alternatively, "Denx - an embedded Linux development kit (ELDK)", is available on the VMware image (http://www.denx.de/wiki/DULG/ELDK). It includes the GNU cross development tools, such as the compilers, binutils, gdb, etc. Please have a look at the website of Denx to get an instruction how to use the ELDK.
/opt/
: If you are working with Microsoft's Visual Studio, you can use the virtual machine as cross-compiler.
For this purpose, you can use PuTTY (plink), which can activate a make in the virtual machine via SSH. For example (using the login data of the virtual machine):
In the virtual machine, /mnt/PROJECT_DIR
can be a mounted SMB or NFS share of an existing server and has not to be inside of the virtual machine. Default directory would be /home/mvbc/workspace
. Before, the share has to be mounted manually of entered in /etc/fstab
.
This chapter will give you a short overview about the directory structure of the VMware. This chapter will dwell on important content.
First, please have a look at following figure. This shows the complete directory structure.
" |- mvbcdemos"
The samples in this folder can be compiled for mvBlueCOUGAR(ppc_6xx).
" |- linux"
In this folder you can find mvIMPACT SDK samples, which do not need a display. Display is not available on the mvBlueCOUGAR-P. These samples can be compiled with ppc_6xx and run on the mvBlueCOUGARdirectly.
" |- images"
The folder contains images needed by the samples.
" |- cpp / c"
This folder contains samples, which uses display. These samples are Windows samples and to some extent they cannot be compiled for Linux. Ergo they are not intended for mvBlueCOUGAR
The libraries are built for the mvBlueCOUGAR/mvBlueLYNX-M7 with the "ppc_6xx-gcc" compiler and are placed in the subfolder ppc_6xx.
The Windows® and Linux® common and system specific header files are contained in the include folder.
All samples in this folder are mvIMPACT Acquire samples and do not use mvIMPACT SDK .
There are several ways to check how the physical interfaces are assigned:
To check the assignment of VMNet0 and VMNet1, please start the VMware server console and open the virtual machine as described in Download and installation. Next, please follow these steps:
The select the menu item Host
->
Virtual
Network
Settings
and the tab Host
Virtual
Network
Mapping
.
There, you have an overview about the assignment of the network devices.
In the VMware server console you have a list of all devices of the virtual machine.
Double click on the corresponding Ethernet device to check the assigned VMNet.
Open the virtual machine "Ubuntu.vmx" with an editor.
Please check the Ethernet0 und Ethernet1 MAC addresses.
With the help of the transmitData sample, this section will explain
The transmitData sample uses
The next section Programming will go into detail. But first try to start the example.
Following instruction shows, how to start the mvIMPACT sample transmitData for mvBlueCOUGAR
In the example the PC with the VMware image has the IP address 169.254.4.93
and mvBlueCOUGARthe IP address 169.254.67.186
.
/home/mvbc
to the mvBlueCOUGARyou need to check if the folder /mnt/user/work
already exists. If there is no mnt/user/work/
directory and /mnt/user/
is empty, please use /mnt/user/
instead. LD_LIBRARY_PATH
to mvIMPACT SDK and mvIMPACT Acquire libraries (given that not all necessary libraries are installed on the camera by default): /flash/MatrixVision/bin
. After starting the local application, please follow this steps:
Change into the directory /home/mvbc/workspace/mvimpact/samples/mvbcdemos/transmitData/
an open transmitData.cpp with your preferred editor.
/home/mvbc/workspace/mvimpact/samples/mvbcdemos/transmitData/
Now we will have a look at the source code:
As already mentioned the transmitData.cpp sample is a little example, which uses
In the following lines the required libraries are included:
In the main function a device handle is obtained:
Then an interface to the first MATRIX VISION device with the serial number sDevSerial is created:
Afterwards the Liveloop function is called, which starts live acquisition loop:
As the first action in this loop, the device is opened:
Then a function interface to the device is created:
Afterwards some image request buffers will be allocated. For more information about image requests, please have a look at the "How the capture process works" chapter in the respective mvIMPACT Acquire SDK manual:
Next, an interface to send the data to the host is created (vl_transmit class):
Then the next available result queue entry will be returned:
Next, the image is added to the transmitter (vl_transmit function):
Afterwards a blue rectangle is generated (mvIMPACT SDK function) and added to the transmitter (vl_transmit function). The parameters are the coordinates in the order left, top, right, bottom:
Here a magenta text overlay to the image is created. The text shows the serial number of the mvBlueCOUGARand the amount of captured images. Then the text is added to the transmitter and finally all information are send (vl_transmit function):
The request buffer is unlocked and a new image request is send into the capture queue:
By pressing any key, the application will be stopped.
With the help of vl_transmit library you can transfer images, result data like texts or overlay elements (like rectangles, points, etc.) from a local application on the mvBlueCOUGAR
On a PC these data are interpreted and displayed on wxPropView.
The section Running an example shows how functions of vl_transmit can be used.
Error |
error while loading shared libraries: libxxx.so: cannot open shared object file: No such file or directory |
Description |
This means that mvBlueCOUGARdoes not know the mvIMPACT SDK libraries. |
Solution |
You can set the library path to the mounted folder of your PC in which you have the libraries (see: Starting a local application). You can add the new library path to the environment variable mvBC-P> export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/mnt/user/work/workspace/mvimpact/lib/ppc_6xx
mvBC-P> cd /usr/lib/ppc_6xx mvBC-P> ln -sf libvl_base.so.4.2.3 libvl_base.so.4 mvBC-P> ln -sf libvl_base.so.4.2.3 libvl_base.so |
Error |
error while loading shared libraries: libvl_[name].so.5: cannot open shared object file: No such file or directory |
Description |
The application was linked with the mvIMPACT libraries version 5 and on the VMware image are libraries of version 6 or newer installed. |
Solution |
There are two solutions:
mvBC-P> cd /usr/lib mvBC-P> ln -sf libvl_[name].so.X.X.X libvl_[name].so.5 Please note that X.X.X is the version of the library which should be greater as 6.0.0. Error example: error while loading shared libraries: libvl_display.so.5: \n cannot open shared object file: No such file or directory mvBC-P> cd /usr/lib mvBC-P> ln -sf libvl_base.so.6.1.3 libvl_base.so.5
|
Error |
main (../blob.cpp: 14): "IPL_FlImport(&image, __null, FL_DONT_CARE, "money.tif")" � � "Invalid file" (code: -800) |
Description |
This mvIMPACT SDK sample works with loaded images from the memory. The images for the samples are placed in the folder mvimpact/samples/images . This folder has to be specified for the sample. |
Solution |
You have to export VL_FILE_DIR mvBC-P> cd work/workspace/mvimpact/samples/c/aoi export VL_FILE_DIR=/data/[..]/mvimpact/samples/images/ |
The next section shows, how you can start your own application and how programming with mvBlueCOUGARwill work.
In the previous sections you've already seen, how you can make the samples of the Virtual Machine (VMware) image an how you can run this example locally. This section will show you
The scripts create a dummy sample source file and the needed makefiles for the build ("make"
) under Linux depending on the mvIMPACT and mvIMPACT Acquire directory structure. Because of this you can simply execute "make"
in the new generated sample directory without needing to manually generate the makefiles.
The dummy sample contents also the needed source for the image capturing. The settings of the sample are kept global so that an image with the default camera settings will be captured. This way you could only add the individual needed camera settings (e.g. change the default expose value, change the trigger mode, etc.) and/or add the needed image processing.
To create a new Linux application based on mvIMPACT Acquire, you can use the Shell script mknewappl.sh, which can be found in the directory apps
.
A new directory with the name "myDemo" will be created. In this directory there are
Makefiles
(see also: Adapt the application's Makefiles)Makefile
andMakefile.inc
,The code in myDemo.cpp shows the acquisition of one image. You can modify this code to your own needs.
Based on the work folder e.g. [..]/workFolder/ mvIMPACT Acquire applications like myDemo have following Makefile structure:
apps/myDemo/Makefile
- make
rules (e.g. all, clean, new, build, etc.), see also: Makefile (mvIMPACT Acquire).apps/myDemo/Makefile.inc
- apps/Makefile.samp.inc
automatically, so it should not be named in OOBJ."%.c"
"%.cpp"
"%"
apps/Makefile.samp.inc
- Makefile
. It contains the most settings to build an application. In this file, the settings are identically with all created applications in apps
. To minimize all redundant information for all applications, this file was created.common/System/linux/Makefile.all.inc
- Makefile.all.inc
needs toolchain path settings from the file common/System/linux/config.inc
.To create a new Linux application based on mvIMPACT SDK, you can use the Shell script mkNewmvBCLAppl, which can be found in the directory mvimpact/samples/mvbcdemos/
.
A new directory with the name "myDemo" will be created. In this directory there are
Makefiles
(see also: Adapt the application's Makefiles)Makefile
andMakefile.inc
,The generated file myDemo.cpp
file contains by default the source code for the "Hello, world" sample. You can modify this code to your own needs.
Based on the work folder e.g. [..]/workFolder/ mvIMPACT SDK applications like myDemo have following Makefile structure:
samples/linux/cpp/myDemo/Makefile
- make
rules (e.g. all, clean, new, build, etc.), see also: Makefile (mvIMPACT SDK).samples/linux/cpp/myDemo/Makefile.inc
- MODULE_NAME
you will find the name of your demo or sample. The generated binary will have the same name and will be placed in the subfolder (ppc_6xx
) generated by Makefile.demotarg.inc
.apps/Makefile.samp.inc
automatically, so it should not be named in OOBJ."%.c"
"%.cpp"
"%"
mvimpact/Makefile.samp.inc
- Makefile
. Is needed by all samples, demos and libraries.mvimpact/Makefile.demotarg.inc
- Makefile
. Will create the target subfolders (x86
, arm
, ppc_6xx
, etc.).mvimpact/samples/Makefile.samp.inc
- Makefile
. Contains the build rules. Will be included by Makefile.inc (mvIMPACT SDK) placed in the sample/linux/demo
folder (e.g. in samples/linux/c/aoi
).To mask a user allocated memory for the image buffer as an mvIMPACT image buffer handle (IPL_BUFHANDLE), you need to implement dev_AllocUsrBuf()
.
pImageHandle | Output buffer handle |
pImagePtr | Input pointer to the user memory |
iWidth | width of the user memory |
iHeight | height of the user memory |
For debugging you can use every tool, which can address GDB - this debugger works also remotely. However, GDB is not available locally, but you can mount it via NFS or SMB.
Unlike PCI(e) devices cannot disappear during runtime and USB devices, where the system informs you about appearing and disappearing, network devices haven't got such a behavior.
Thus the GigE Vision standard defines a procedure, which will check, if a device or the connected application to the device still exists. A device, which was opened by a primary application (it has the write access to the register), will closed automatically, if the application does not access (read or write) the device within a predefined timeout (default 3000ms).
This behavior has influence over the debug behavior of an application: If you jump to a breakpoint of the application, the cyclic reading will be stopped, but not the device. During debugging, it could be possible that the device is closed, although the user did not initiate it.
To change this behavior during debugging, it is possible to set the timeout on a high value. But if you finish the application without signing off the device correctly (reset CCP register), you will have no access to the device until the timeout is elapsed or you disconnect the device.