List Connected Devices Sample

The sample metavision_hal_ls.cpp shows how to use Metavision HAL API to list all connected event-based devices.

The source code of this sample can be found in <install-prefix>/share/metavision/hal/samples/metavision_ls when installing Metavision SDK from installer or packages. For other deployment methods, check the page Path of Samples.

Expected Output

The sample prints information about connected event-based devices to the console.

Example of the output:

$ metavision_hal_ls
Device detected: Prophesee:hal_plugin_imx636_evk4:00ca0009

Example when asking for more information:

$ metavision_hal_ls --verbose
Device detected: Prophesee:hal_plugin_imx636_evk4:00ca0009
## HAL Software
Version:                      4.0.0
VCS branch:                   HEAD
VCS commit:                   a48272ee861e8893ad0a1a9de764bb85bb7b6a61
VCS commit's date:            2023-03-07 14:33:07 +0000

## Plugin Software
Name:                         hal_plugin_imx636_evk4
Version:                      4.0.0
VCS branch:                   HEAD
VCS commit:                   a48272ee861e8893ad0a1a9de764bb85bb7b6a61
VCS commit's date:            2023-03-07 14:33:07 +0000

## Hardware
Available Data Encoding Formats:EVT3,EVT21
Connection:                   USB
Current Data Encoding Format: EVT3
EVK4 Build Date:              Fri Oct  7 14:41:28 2022
EVK4 Release Version:         3.9.0
EVK4 Speed:                   5000
Integrator:                   Prophesee
Sensor Name:                  IMX636
Serial:                       00ca0009
SystemID:                     49
device0 compatible:           psee,ccam5_imx636
device0 name:                 CCam5 Imx636 Event-Based Camera

How to start

First, compile the sample as described in this tutorial.

To start the sample, run:

Linux

./metavision_hal_ls

Windows

metavision_hal_ls.exe

To get more information about connected event-based devices:

Linux

./metavision_hal_ls -v

Windows

metavision_hal_ls.exe -v

Note

If your camera is not detected, please refer to our camera troubleshooting FAQ entry.

Code Overview

The following code snippet shows how to retrieve the serial numbers of connected devices:

    auto v = Metavision::DeviceDiscovery::list();

    if (v.empty()) {
        MV_LOG_ERROR() << "No device found";
    }

Once the serial number is known, a device with the given serial number can be created with the following code:

                // open device from a serial
                device = Metavision::DeviceDiscovery::open(s);

Then, from the device, the available facilities can be retrieved with Metavision::Device::get_facility.

For example, the following code displays the device hardware information:

                // Retrieves the facility that provides information about the hardware
                Metavision::I_HW_Identification *hw_identification =
                    device->get_facility<Metavision::I_HW_Identification>();
                if (hw_identification) {
                    MV_LOG_INFO() << "## Hardware";
                    // Retrieves a map of key/value with the information
                    for (auto system_info : hw_identification->get_system_info()) {
                        auto key            = system_info.first;
                        auto value          = system_info.second;
                        const std::string s = key + ":";
                        MV_LOG_INFO() << Metavision::Log::no_space << std::left << std::setw(30) << s << value;
                    }
                }