#camera #computer-vision #gen-i-cam #usb3 #uvc #gige


cameleon is a safe, fast, and flexible library for GenICam compatible cameras

13 releases

0.1.12 Aug 29, 2023
0.1.11 May 22, 2023
0.1.10 Apr 15, 2023
0.1.9 Mar 18, 2023
0.1.3 Jun 13, 2021

#19 in Video

Download history 192/week @ 2024-03-17 147/week @ 2024-03-24 220/week @ 2024-03-31 249/week @ 2024-04-07 122/week @ 2024-04-14 158/week @ 2024-04-21 125/week @ 2024-04-28 87/week @ 2024-05-05 137/week @ 2024-05-12 87/week @ 2024-05-19 80/week @ 2024-05-26 168/week @ 2024-06-02 140/week @ 2024-06-09 107/week @ 2024-06-16 134/week @ 2024-06-23 16/week @ 2024-06-30

428 downloads per month

MPL-2.0 license

17K SLoC

cameleon is a safe, fast, and flexible library for GenICam compatible cameras

Crates.io Documentation MPL-2.0 Build Status

cameleon is a safe, fast, and flexible library for GenICam compatible cameras.


cameleon is a library for operating on GenICam compatible cameras. Our main goal is to provide safe, fast, and flexible library for GenICam cameras.

Currently, cameleon supports only USB3 Vision cameras, but it's planned to support other protocols including GigE Vision. See Roadmap for more details.


USB3 Vision cameras

You need to install libusb to use USB3 Vision cameras, see How to install libusb.

First, add dependencies like below.

cameleon = { version = "0.1", features = ["libusb"] }

Then, you can enumerate all cameras connected to the host, and start streaming.

use cameleon::u3v;

// Enumerates all cameras connected to the host.
let mut cameras = u3v::enumerate_cameras().unwrap();

if cameras.is_empty() {
    println!("no camera found");

let mut camera = cameras.pop().unwrap();

// Opens the camera.
// Loads `GenApi` context. This is necessary for streaming.

// Start streaming. Channel capacity is set to 3.
let payload_rx = camera.start_streaming(3).unwrap();

for _ in 0..10 {
    let payload = match payload_rx.recv_blocking() {
        Ok(payload) => payload,
        Err(e) => {
            println!("payload receive error: {e}");
        "payload received! block_id: {:?}, timestamp: {:?}",
    if let Some(image_info) = payload.image_info() {
        println!("{:?}\n", image_info);
        let image = payload.image();
        // do something with the image.
        // ...

    // Send back payload to streaming loop to reuse the buffer. This is optional.

// Closes the camera.

More examples can be found here.

Project Layout

Cameleon consists of several crates.

  • cameleon: Provides high-level APIs to control cameras. This is the primary crate.
  • cameleon-genapi: Provides parser and interpreter of GenApi XML.
  • cameleon-device: Provides device specific protocol decoder and basic I/O operations for devices, also provides emulators.
  • cameleon-gentl: Provides GenTL interfaces as a C library.
  • cameleon-impl: Provides internal APIs for other crates. cameleon-impl is intended to be used only by cameleon project.
  • cameleon-impl-macros: Provides procedural macros for other crates. cameleon-impl-macros is intended to be used only by cameleon project.


USB3 Vision

How to install libusb?


You need to install libusb to the place where pkg-config can find. Basically all you have to do is just installing libusb through your system package manager like sudo apt install libusb-1.0-0-dev or brew install libusb.

If you use Linux, it's probably needed to edit permissions for USB devices. You could add permissions by editing udev rules, a configuration example is found here.


You need to install libusb with vcpkg, please see here to install libusb with vcpkg.

Also, you need to install a driver for your device. You can find resource here for driver-installation.
NOTE: Make sure to install a driver to a composite device not to its child devices.
To do this, you need to list all devices connected to the host computer with zadig like below.
describe zadig list option

Then install WinUSB to your device.
describe how to install WinUSB driver to your composite device

Why is frame rate so low?

Frame rate can be affected by several reasons.

  1. Parameter settings of the camera

AcquisitionFrameRate and ExposureTime directly affect frame rate. So you need to setup the parameters first to improve frame rate. Also, if DeviceLinkThroughputLimitMode is set to On, you would need to increase the value of DeviceLinkThroughputLimit.

  1. Many devices are streaming simultaneously on the same USB host controller

In this case, it's recommended to allocate the equal throughput limit to the connected cameras, making sure that the total throughput does not exceed the maximum bandwidth of the host controller.

  1. usbfs_memory_mb is set to low value

If you use Linux, you may need to increase usbfs_memory_mb limit. By default, USB-FS on Linux systems only allows 16 MB of buffer memory for all USB devices. This is quite low for high-resolution image streaming. We recommend you to set the value to 1000MB. You could set the value as following:

echo 1000 > /sys/module/usbcore/parameters/usbfs_memory_mb



  • Add support for GigE cameras
  • Impelment emulator
  • Add support for saving and loading camera parameters


  • Implement payload chunk parser
  • Add support for GenTL


  • Add support for UVC cameras

Release cycle

We continuously update the minor version every four weeks, until the version reaches 1.0.0.


Thank you for your interest in contributing to Cameleon! We are so happy to have you join the development.
To start developing, please refer to CONTRIBUTING.md.


This project is licenced under MPL 2.0.


~168K SLoC