Skip to main content

Python bindings for VmbC

Project description

VmbPy python version

Python API of the Vimba X SDK

Vimba X is a fully GenICam compliant SDK and the successor of Vimba. VmbPy is the Python API that is provided by this SDK. It provides access to the full functionality of Vimba X in a pythonic way, allowing for rapid development of applications.

Installation

VmbPy is validated to work with Python versions 3.10 to 3.14. A ready-to-install packaged .whl file of VmbPy can be found as part of the Vimba X installation, or be downloaded from our github release page. The .whl can be installed as usual via the pip install command.

[!NOTE]
Depending on the some systems the command might instead be called pip3. Check your systems Python documentation for details.

Selecting the correct .whl

When selecting the correct .whl file for your project, you have two options. The recommended approach is to use the .whl that includes the VmbC libs, as this provides all the required libraries to get started with development right away. Note, however, that this .whl does not include any Transport Layers or device drivers, which must be installed separately (for example, by installing Vimba X). You can identify .whls with included libs by the platform tag that is included in their filename (for example, win_amd64).

Alternatively, you can use the .whl without the included VmbC libs (platform tag any), but this requires a pre-existing Vimba X installation on your system, as VmbPy will attempt to load the necessary libraries at import time.

[!NOTE]
If a .whl with included VmbC libs is used, it is possible that binary dependencies of VmbC need to be installed separately. For example on windows the Visual C++ Redistributable is required. These dependencies will be automatically installed if Vimba X is installed on the system.

Optional dependencies

For some functionality of VmbPy optional dependencies (also called "extras") are required. These provide for example integration into numpy and OpenCV, as well as some additional code analysis tools that are used in our full test suite. The following extras are defined for VmbPy:

  • numpy: Enables conversion of VmbPy.Frame objects to numpy arrays
  • opencv: Similar to above but ensures that the numpy arrays are valid OpenCV images
  • test: Additional tools such as flake8, mypy, and coverage only necessary for executing run_tests.py

[!NOTE]
Installing these extra dependencies is possible by defining them as part of the installation command like so (note the single quotes around the filename and extras):

pip install '/path/to/vmbpy-X.Y.Z-py-none-any.whl[numpy,opencv]'

Yocto on NXP i.MX8 and OpenCV

The GPU in i.MX8 systems requires using the system-wide opencv-python package. When you create the Python environment, please use the --system-site-packages flag to include the system-wide OpenCV package.

If you don't set up a separate environment, a warning is shown during the VmbPy installation. You can ignore this warning.

Differences to VimbaPython

VmbPy is the successor of VimbaPython. As such it shares many similarities, but in some places major differences exist. An overview of the differences between VimbaPython and VmbPy can be found in the migration guide, that is part of the Vimba X SDK documentation.

Usage

Below is a minimal example demonstrating how to print all available cameras detected by VmbPy. It highlights the general usage of VmbPy. More complete code examples can be found in the Examples directory.

import vmbpy

vmb = vmbpy.VmbSystem.get_instance()
with vmb:
    cams = vmb.get_all_cameras()
    for cam in cams:
        print(cam)

General guidelines

VmbPy makes use of the Python context manager to perform setup and teardown tasks for the used object instances. This ensures the correct call order for the underlying VmbC functions and guarantees, that resources are made available and freed as expected even in cases where errors occur. One example is shown in the example above, where the context of the VmbSystem object must be entered to start the underlying VmbC API.

VmbPy is also designed to closely resemble VmbCPP. While VmbPy aims to be as performant as possible, it might not be fast enough for performance critical applications. In that case the similar structure of VmbPy and VmbCPP makes it easy to migrate an existing VmbPy code base to VmbCPP.

Configuration of the underlying VmbC API

The underlying VmbC API used by VmbPy can be configured in various ways to suit your development needs. Multiple configuration options are available, including the ability to enable logging of VmbC calls and customize the loading behavior of transport layers. Configuration is achieved through the VmbC.xml file, which by default loads Transport Layers from the GENICAM_GENTL64_PATH environment variable. The location of this configuration file depends on the type of .whl installed: if you're using the .whl with included libs, it can be found in /site-packages/vmbpy/c_binding/lib. If you're using the .whl without included libs, it is located in the /api/bin directory of your Vimba X installation.

Alternatively it is also possible for the user to provide a VmbC.xml configuration with the help of VmbSystem.set_path_configuration.

Running the test suite

VmbPy provides a number of unittest as part of the Github repository. The test suite can be run in two ways. Either by using the test discovery mechanic of Python's unittest module, or via the provided run_tests.py.

Unittest discovery

Python's unittest module can be used to discover the test cases of VimbaPython automatically. This can be useful as it provides good integration into third party tools like test explorers. To execute the entire test suite the following command can be run inside the Tests directory of this repository:

python -m unittest discover -v -p *_test.py

This will open the first camera, that Vimba detects on the system. If multiple cameras are connected to the system, an unexpected device may be selected. In this situation it is recommended to specify the ID of the device that should be used for test case execution. This is done by setting the environment variable VMBPY_DEVICE_ID. A convenient way to get the IDs of currently available devices is running the list_cameras.py example.

Execute entire test suite using camera with ID DEV_PLACEHOLDER

Windows
set VMBPY_DEVICE_ID=DEV_PLACEHOLDER
python -m unittest discover -v -p *_test.py
Linux
export VMBPY_DEVICE_ID=DEV_PLACEHOLDER
python -m unittest discover -v -p *_test.py

run_tests.py

The provided helper script run_tests.py may also be used to execute the test suite. In addition to the test cases, it also executes flake8, mypy, and coverage. These additional tools need to be installed in the used Python environment. For convenience they are grouped as an optional dependency of VmbPy with the name test that can be added to the pip install command used to install VmbPy.

run_tests.py provides a helpful command line interface that can be used to configure which tests to run and how the output should be structured. To get an overview of the available options the following command can be executed to generate the usage description.

python run_tests.py -h

Beta Disclaimer

Please be aware that all code revisions not explicitly listed in the Github Release section are considered a Beta Version.

For Beta Versions, the following applies in addition to the BSD 2-Clause License:

THE SOFTWARE IS PRELIMINARY AND STILL IN TESTING AND VERIFICATION PHASE AND IS PROVIDED ON AN “AS IS” AND “AS AVAILABLE” BASIS AND IS BELIEVED TO CONTAIN DEFECTS. THE PRIMARY PURPOSE OF THIS EARLY ACCESS IS TO OBTAIN FEEDBACK ON PERFORMANCE AND THE IDENTIFICATION OF DEFECTS IN THE SOFTWARE, HARDWARE AND DOCUMENTATION.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

vmbpy-1.2.1-py3-none-win_amd64.whl (1.5 MB view details)

Uploaded Python 3Windows x86-64

vmbpy-1.2.1-py3-none-manylinux_2_27_x86_64.whl (2.8 MB view details)

Uploaded Python 3manylinux: glibc 2.27+ x86-64

vmbpy-1.2.1-py3-none-manylinux_2_27_aarch64.whl (2.6 MB view details)

Uploaded Python 3manylinux: glibc 2.27+ ARM64

File details

Details for the file vmbpy-1.2.1-py3-none-win_amd64.whl.

File metadata

  • Download URL: vmbpy-1.2.1-py3-none-win_amd64.whl
  • Upload date:
  • Size: 1.5 MB
  • Tags: Python 3, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.1

File hashes

Hashes for vmbpy-1.2.1-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 be6439556d34c7e2645593abfe9a0e9d3329d7cde453ed3514fcee3e71acf050
MD5 23b871be0e9e09582f36eccf17bfb55c
BLAKE2b-256 8a4a943ab120b320d5594ece896c26779654f4356ecfca954c30b875f580713b

See more details on using hashes here.

File details

Details for the file vmbpy-1.2.1-py3-none-manylinux_2_27_x86_64.whl.

File metadata

File hashes

Hashes for vmbpy-1.2.1-py3-none-manylinux_2_27_x86_64.whl
Algorithm Hash digest
SHA256 d2c3c50d08ee551578142ba802123be435cd050fc8620ad2447956bb76dd89d9
MD5 43aa7f0b4524bd409b2244ef4649a487
BLAKE2b-256 3e2c23ae1497d6b692683f33a09d34ebd275e309536f9d87d815a14fd0d5820f

See more details on using hashes here.

File details

Details for the file vmbpy-1.2.1-py3-none-manylinux_2_27_aarch64.whl.

File metadata

File hashes

Hashes for vmbpy-1.2.1-py3-none-manylinux_2_27_aarch64.whl
Algorithm Hash digest
SHA256 6e15a1f816e11966bacdb4ef254c68b498f49c0ebfd83efc2bfdfa464af3833e
MD5 13cdb84434928e0f2646efd4649a9bf9
BLAKE2b-256 018be1906043bc986e3b1ab445fa7f04e5dfbe4598feba96f6c75876b8bccf9c

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page