Documentation / Gemini 330 series /
C++ Sample Depth Stream Viewer

C++ Sample Depth Stream Viewer

Function description: This example mainly demonstrates the use of SDK to get depth data and draw display, get resolution and select settings, display depth images, and exit the program through the ESC_KEY key

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

Firstly, it is necessary to create a pipeline, through which multiple types of streams can be easily opened and closed, and a set of frame data can be obtained

ob::Pipeline pipe;

Get all stream configurations of the depth camera, including stream resolution, frame rate, and frame format

auto profiles = pipe.getStreamProfileList(OB_SENSOR_DEPTH);

std::shared_ptr<ob::VideoStreamProfile> depthProfile = nullptr;
try{
//Find the corresponding Profile according to the specified format, with priority given to Y16 format
depthProfile = profiles->getVideoStreamProfile(640, 480, OB_FORMAT_Y16, 30);
}catch(ob::Error &e){
//If the Y16 format is not found and does not match the format, search for the corresponding profile to open the stream
depthProfile = std::const_pointer_cast<ob::StreamProfile>(profiles->getProfile(OB_PROFILE_DEFAULT))->as<ob::VideoStreamProfile>();
}

Configure which streams to enable or disable in the Pipeline by creating a Configuration, where deep streams will be enabled

std::shared_ptr<ob::Config> config = std::make_shared<ob::Config>();
config->enableStream(depthProfile);

Select sequence ID

ob::SequenceIdFilter sequenceIdFilter;
sequenceIdFilter.selectSequenceId(0);

Start the stream configured in Configuration. If no parameters are passed, the default configuration startup stream will be started

pipe.start(config);

Wait for a frame of data in a blocking manner, which is a composite frame containing frame data for all streams enabled in the configuration, and set the waiting timeout time for the frame

auto frameSet = pipe.waitForFrames(100);//Set the waiting time to 100ms

Stop Pipeline, no more frame data will be generated

pipe.stop();

Expected Output

Stay updated

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