Device Connection

This sample shows how to connect a DELTA Series camera over USB and perform basic device communication through the DELTA SDK. It is the recommended first sample to run when you want to verify that the camera, USB driver, and SDK environment are ready.

Back to Code Samples.

Note

To connect a DELTA camera over USB, the Cypress driver must be installed for the device. For details, see the USB Driver Installation guide. If the driver is not installed correctly, the PC may not detect the camera.

Example Overview

Step SDK API Purpose
1 scanDevices() Find connected DELTA Series cameras.
2 getDeviceInfo() Read model, USB packet size, port ID, and description.
3 openDevice() Open the selected camera and get a device handle.
4 applySensorSetting() Apply the recommended sensor setting file.
5 getStreamVersion() Check whether the stream format is Single, Stereo, or Unknown.
6 readSensorRegister() / writeSensorRegister() Verify basic sensor register access.
7 closeDevice() Release the camera handle.

Code Walkthrough

Select a Camera

The sample selects one camera from the latest scanDevices() result. Change selectDeviceIndex if multiple cameras are connected.

const std::int32_t selectDeviceIndex = 0;
const std::int32_t sensorRegisterAddress = 0x303b; // Example sensor register address

selectDeviceIndex = 0 selects the first detected camera, and selectDeviceIndex = 1 selects the second detected camera. This value is the device index in the latest scan result, not the number of cameras to use.

Scan and Open the Device

First, scan connected cameras and check that at least one device was found.

std::int32_t deviceCount = 0;
delta::Status status = delta::scanDevices(&deviceCount);

if (status != delta::Status::Success) {
    std::cout << "scanDevices failed: "
              << delta::getStatusMessage(status) << "\n";
    return 1;
}

if (deviceCount <= 0) {
    std::cout << "No camera found.\n";
    return 1;
}

Then, read the selected camera information and open it.

delta::DeviceInfo deviceInfo{};
status = delta::getDeviceInfo(selectDeviceIndex, &deviceInfo);

if (status != delta::Status::Success) {
    std::cout << "getDeviceInfo failed: "
              << delta::getStatusMessage(status) << "\n";
    return 1;
}

delta::DeviceHandle cameraHandle = nullptr;
status = delta::openDevice(deviceInfo.index, &cameraHandle);

if (status != delta::Status::Success) {
    std::cout << "openDevice failed: "
              << delta::getStatusMessage(status) << "\n";
    return 1;
}

Apply Sensor Settings

After opening the camera, apply the recommended sensor setting file for the detected model.

// The setting file used in this example is only a recommended default.
// Replace this path with your own sensor setting file if needed.

const std::filesystem::path settingFilePath =
    deviceInfo.type == delta::DeviceType::Delta_01
        ? std::filesystem::path(DELTA_SETTINGS_DIR) / "Delta_01_1000FPS.txt"
        : std::filesystem::path(DELTA_SETTINGS_DIR) / "Delta_10_2000FPS.txt";

const std::string settingFileString = settingFilePath.generic_string();
status = delta::applySensorSetting(cameraHandle, settingFileString.c_str());

if (status != delta::Status::Success) {
    std::cout << "applySensorSetting failed: "
              << delta::getStatusMessage(status) << "\n";
    delta::closeDevice(cameraHandle);
    return 1;
}

Note

Call applySensorSetting() before starting live streaming. The setting file configures the sensor and allows the SDK to detect the stream version.

Check the Stream Version

The stream version is detected after the sensor setting file is applied.

delta::Version streamVersion = delta::Version::Unknown;
status = delta::getStreamVersion(cameraHandle, &streamVersion);

if (status != delta::Status::Success) {
    std::cout << "getStreamVersion failed: "
              << delta::getStatusMessage(status) << "\n";
    delta::closeDevice(cameraHandle);
    return 1;
}

Read and Write a Sensor Register

The sample reads a sensor register, writes the same value back, and reads it again to confirm that basic sensor communication is working.

std::int32_t originalValue = 0;
status = delta::readSensorRegister(
    cameraHandle,
    sensorRegisterAddress,
    &originalValue
);

if (status != delta::Status::Success) {
    std::cout << "readSensorRegister failed: "
              << delta::getStatusMessage(status) << "\n";
    delta::closeDevice(cameraHandle);
    return 1;
}

status = delta::writeSensorRegister(
    cameraHandle,
    sensorRegisterAddress,
    originalValue
);

This write operation uses the same value that was just read. It is intended as a safe communication check, not as a sensor tuning example.

Close the Device

Always close the device when the application finishes using the camera.

status = delta::closeDevice(cameraHandle);

if (status != delta::Status::Success) {
    std::cout << "closeDevice failed: "
              << delta::getStatusMessage(status) << "\n";
    return 1;
}