Femto Bolt Documentation

Find and Open Femto Bolt Devices

 

This document shows how to find and then open Femto Bolt devices. It explains how to handle multiple devices connected to a computer.

You can also refer to the SDK enumeration example which demonstrates using the functions described here.

This document will introduce the following functions:

 

 

Discover Number of Connected Devices

First, use k4a_device_get_installed_count() to get the number of Femto Bolt devices currently connected.

 

 

Open Devices

To get information about a device or read data from it, you first need to open a handle to the device using k4a_device_open().

k4a_device_t device = NULL;

for (uint8_t deviceIndex = 0; deviceIndex < device_count; deviceIndex++)
{
    if (K4A_RESULT_SUCCEEDED != k4a_device_open(deviceIndex, &device))
    {
        printf("%d: Failed to open device\n", deviceIndex);
        continue;
    }

    ...

    k4a_device_close(device);
}

The index parameter to k4a_device_open()  indicates which device to open when multiple devices are connected. If you expect only one device to be connected, you can pass K4A_DEVICE_DEFAULT or 0 to indicate the first device.

Whenever you open a device, you need to call k4a_device_close()  when finished with the handle. You cannot open another handle to the same device until closing the handle.

 

 

Identify Specific Devices

The order devices are enumerated by index does not change before devices are attached or detached. To identify a physical device, you should use the device serial number.

To read the serial number from a device, use the k4a_device_get_serialnum() function after opening the handle.

This example shows how to allocate enough memory to store the serial number.

char *serial_number = NULL;
size_t serial_number_length = 0;

if (K4A_BUFFER_RESULT_TOO_SMALL != k4a_device_get_serialnum(device, NULL, &serial_number_length))
{
    printf("%d: Failed to get serial number length\n", deviceIndex);
    k4a_device_close(device);
    device = NULL;
    continue;
}

serial_number = malloc(serial_number_length);
if (serial_number == NULL)
{
    printf("%d: Failed to allocate memory for serial number (%zu bytes)\n", deviceIndex, serial_number_length);
    k4a_device_close(device);
    device = NULL;
    continue;
}

if (K4A_BUFFER_RESULT_SUCCEEDED != k4a_device_get_serialnum(device, serial_number, &serial_number_length))
{
    printf("%d: Failed to get serial number\n", deviceIndex);
    free(serial_number);
    serial_number = NULL;
    k4a_device_close(device);
    device = NULL;
    continue;
}

printf("%d: Device \"%s\"\n", deviceIndex, serial_number);

 

 

Open Default Device

In most applications, only a single Femto Bolt will be attached to the same computer. If you expect a single device, you can call k4a_device_open() with index K4A_DEVICE_DEFAULT to open the first device.

 

 

Next Steps

《Get Image Data》

Stay updated

Be the first to learn about our new
products and updates.