Embedded live stream monitoring with BVS CA industrial cameras
1. Introduction
Embedded devices now have a computing power and variety of interfaces that make them extremely interesting for use in industrial image processing. Embedded devices can master applications in the field of artificial intelligence (AI) such as machine learning (ML) or its sub-aspect deep learning (DL). Balluff has been supporting ARM-based devices for almost ten years with suitable drivers for the BVS CA-IGC (USB 2.0), BVS CA-SF (USB 3.0) and BVS CA-GX0 (Gigabit Ethernet) product families. The following table provides an overview of the platforms we have tested with our cameras:
System |
ARM architecture |
Technology Test Results |
Performance |
Suitable for |
More information |
||||
USB2.0 |
USB3.0 |
GigE |
10GigE |
PCIe |
|||||
Arm Cortex-A78AE v8.2 |
! |
X |
X |
X |
X |
+++++ |
Demanding Applications |
nvidia.com |
|
NVIDIA Carmel ARMv8.2 |
X |
X |
X |
- |
X |
++++ |
Demanding Applications |
nvidia.com |
|
NVIDIA Carmel ARMv8.2 |
X |
X |
X |
- |
X |
+++ |
Demanding Applications |
nvidia.com |
|
ARM Cortex-A57 |
X |
X |
X |
- |
* |
+ |
Mid-Range Applications |
nvidia.com |
|
NVIDIA Denver 2 and ARM Cortex-A57 |
X |
X |
X |
- |
? |
++ |
Demanding Applications |
nvidia.com |
|
ARM Cortex-A72 |
X |
X |
! |
- |
- |
+ |
Price Sensitive Projects |
raspberrypi.org |
|
ARM Cortex-A72 |
X |
X |
! |
- |
! |
+ |
Price Sensitive Projects |
raspberrypi.org |
|
ARM Cortex-A53 |
X |
! |
! |
- |
! |
+ |
Mid-Range Applications |
nxp.com |
X = The system delivers good performance with this device.
- = The system doesn't work with this device.
* = The developer kit doesn't work with this device because it provides no PCI Express interface.
! = The system delivers limited performance with this device.
? = The system hasn't been tested yet with this device.
The Raspberry Pi is very popular for price-sensitive applications and the Internet offers many life hacks and smart applications in conjunction with the Raspberry Pi.
This document shows how, for example, live stream monitoring can be implemented with a BVS CA-SF industrial camera in conjunction with the Raspberry Pi. The Raspberry Pi receives the images from the camera and embeds them in a website that can be accessed on the local network. With the appropriate hardware, live streaming demo can also be realized with the USB 2.0 camera BVS CA-IGC or with the Gigabit Ethernet camera BVS CA-GX0.
The following points are covered in this document:
-
What hardware is required?
-
Which software components are required on the Raspberry Pi?
-
How is the application actually implemented?
-
How can I set up an autostart?
2. Structure
hardware |
Order Code |
Quantity |
Description |
BVS CA-SF2-0016ZG-111120-001 |
BVS00JL |
1 |
USB3 industrial camera with 1.6 Mpixel |
B10M5425C |
B10M5425C |
1 |
S-mount lens 5.4 mm |
ADAPTER S-C AD01S |
1 |
C- to S-Mount adapter |
|
MV-LOCK RING SMOUNT |
1 |
S-Mount locking ring |
|
Raspberry Pi 4 |
1 |
ARM device as host |
|
USB3 cable |
A74-9968-2-001 |
1 |
USB3 cable |
Ethernet cable |
A72-8075-5 |
1 |
Ethernet cable |
Power supply Raspberry Pi |
1 |
Power supply for Raspberry Pi |
The setup is simple:
3. Installing the components
The following package must be built or installed on the Raspberry Pi for the application (the links refer to the respective installation and setup instructions):
-
mvIMPACT Acquire Python API (camera driver and API for image acquisition)
-
OpenCV (image manipulation and processing)
-
numpy (image manipulation)
-
Flask (framework for a web interface)
4. Implementation
The program structure is as follows:
| - camera.py
| - main.py
| - templates
| - index.html
camera.py is the helper file in which the cam class is specified. This manages the image acquisition, whereby the camera is initialized (SoftwareTrigger, BGR8 as pixel format, etc.) and the singleFrame function is defined. The singleFrame function starts the acquisition of an image and provides the image with a time stamp:
- camera.py (please rename the appendix to *.py)
The actual Python main program is called main.py. This is where the cam class is imported. In the main function, the creation of a frame(genFrame) is started in a thread using single image recordings and copied into an outputFrame via numpy.
The displayFrame function then converts the outputFrame data into a JPG, which is then displayed in HTML using the video_feed function:
- main.py (please rename the appendix to *.py)
The corresponding index.html calls up the video feed:
- index.html (please rename attachment to *.html)
5. Autostart
In order for the system to be used as a plug & play device, the Python program main.py must be started automatically at the end of the boot process. This requires three files under /etc/systemd/system:
-
'mvIA_env.conf'
-
'run-script-with-delay.service'
-
'run-script-with-delay.timer' (with the same name as .service, only with .timer as the extension for the delay)
mvIA_env.conf: Creates the required environment variables for mvIMPACT Acquire. This is necessary because systemd ignores the environment variables under /etc/profile.d, which would mean that the Impact Acquire packages from the systemd service cannot be used.
- mvIA_env.conf (please rename the appendix to *.conf)
run-script-with-delay.service: Defines the service that is started when booting. The path to the Python program is specified here:'ExecStart='.
- run-script-with-delay.service (please rename the appendix to *.service)
run-script-with-delay.timer: Specifies how long the start of the service should be delayed after booting. The delay can be specified here:'OnBootSec='.
- run-script-with-delay.timer (please rename the appendix to *.timer)
As soon as everything is set up, systemd can be reloaded as follows:
$sudo systemctl daemon-reload
The status can be checked using this command:
$sudo systemctl status run-script-with-delay.service
If this was successful, the service can be started to check whether the Python program has also been started and is running without problems.
$sudo systemctl start run-script-with-delay.service
To do this, the configuration with the delay must be activated:
$sudo systemctl enable run-script-with-delay.timer
Finally, the system must be restarted. After the reboot, the Python program should start automatically.
$reboot