DOC Skip to main content

C++ Sample Config Depth Work Mode

Update on 2025-07-25 07:16:13

Supported devices: G2 series, G3 series cameras, Astra 2 series cameras

Function description: Demonstrate the operation of converting deep working mode

| This example is based on the C++High Level API for demonstration

Create a pipeline to get device

// Create a pipeline with default device
ob::Pipeline pipe;

// Get the device inside the pipeline
auto device = pipe.getDevice();

Check if work mode conversion is supported

// Check whether the camera depth working mode is supported, currently (December 5, 2022) only the Gemini2 binocular camera supports the depth working mode
if(!device->isPropertySupported(OB_STRUCT_CURRENT_DEPTH_ALG_MODE, OB_PERMISSION_READ_WRITE)) {
    pressKeyExit("Current device not support depth work mode!");
    return -1;
}

Get a list of deep work modes

// Query the current camera depth mode
auto curDepthMode = device->getCurrentDepthWorkMode();
// Get the list of camera depth modes
auto depthModeList = device->getDepthWorkModeList();
std::cout << "depthModeList size: " << depthModeList->count() << std::endl;
for(uint32_t i = 0; i < depthModeList->count(); i++) {
    std::cout << "depthModeList[" << i << "]: " << (*depthModeList)[i];
    if(strcmp(curDepthMode.name, (*depthModeList)[i].name) == 0) {
        std::cout << "  (Current WorkMode)";
    }

    std::cout << std::endl;
}

Set deep working mode

// Let the user choose a mode, then switch
if(depthModeList->count() > 0) {
    uint32_t index = 0;
    std::cout << "Please input the index from above depthModeList, newIndex = ";
    std::cin >> index;
    if(index >= 0 && index < depthModeList->count()) {  // legitimacy check
        device->switchDepthWorkMode((*depthModeList)[index].name);

        // Check whether the mode changes after the display is switched
        curDepthMode = device->getCurrentDepthWorkMode();
        if(strcmp(curDepthMode.name, (*depthModeList)[index].name) == 0) {
            std::cout << "Switch depth work mode success! currentDepthMode: " << curDepthMode << std::endl;
        }
        else {
            std::cout << "Switch depth work mode failed!" << std::endl;
        }
    }
    else {
        std::cout << "switchDepthMode faild. invalid index: " << index << std::endl;
    }
}

Expected Output

ON THIS PAGE

Add

  • Name:

  • Link Address:

Cancel

Add

  • Name:

  • Link Address:

Cancel
Questions or
Feedback?

Feedback

  • Your feedback matters! Share your thoughts on this page, report errors, or let us know how we can improve to better support your needs. If applicable, please include the specific sentence or section to help us identify and address the issue.