### Install Documentation and Example Files Source: https://github.com/orbbec/orbbecsdk_v2/blob/main/3rdparty/libjpeg/src/CMakeLists.txt Installs various documentation files, READMEs, examples, and license information to the installation's doc directory. ```cmake install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/README.ijg ${CMAKE_CURRENT_SOURCE_DIR}/README.md ${CMAKE_CURRENT_SOURCE_DIR}/example.txt ${CMAKE_CURRENT_SOURCE_DIR}/tjexample.c ${CMAKE_CURRENT_SOURCE_DIR}/libjpeg.txt ${CMAKE_CURRENT_SOURCE_DIR}/structure.txt ${CMAKE_CURRENT_SOURCE_DIR}/usage.txt ${CMAKE_CURRENT_SOURCE_DIR}/wizard.txt ${CMAKE_CURRENT_SOURCE_DIR}/LICENSE.md DESTINATION ${CMAKE_INSTALL_DOCDIR}) ``` -------------------------------- ### Quick Start Example Source: https://github.com/orbbec/orbbecsdk_v2/blob/main/README.md Demonstrates basic Orbbec SDK usage by creating a pipeline, starting it, and displaying frames in a window. This example requires the Orbbec SDK and associated libraries. ```c++ // Create a pipeline. ob::Pipeline pipe; // Start the pipeline with default config. pipe.start(); // Create a window for showing the frames, and set the size of the window. ob_smpl::CVWindow win("QuickStart", 1280, 720, ob_smpl::ARRANGE_ONE_ROW); while(win.run()) { // Wait for frameSet from the pipeline, the default timeout is 1000ms. auto frameSet = pipe.waitForFrameset(); // Push the frames to the window for showing. win.pushFramesToView(frameSet); } // Stop the Pipeline, no frame data will be generated pipe.stop(); ``` -------------------------------- ### C Quick Start Example Source: https://github.com/orbbec/orbbecsdk_v2/blob/main/examples/README.md This example demonstrates how to quickly start device streams using the SDK C API. It serves as a basic entry point for interacting with Orbbec devices. ```c #include #include #include "libobsensor/ob.h" int main() { ob_context *ctx = ob_create_context(NULL, NULL); if (ctx == NULL) { printf("Failed to create context\n"); return -1; } int device_count = ob_get_device_count(ctx); if (device_count == 0) { printf("No device found\n"); ob_destroy_context(ctx); return -1; } ob_device_list *device_list = ob_create_device_list(ctx); ob_device *device = ob_create_device(device_list, 0); if (device == NULL) { printf("Failed to create device\n"); ob_destroy_device_list(device_list); ob_destroy_context(ctx); return -1; } ob_config *config = ob_create_config(device); ob_stream_profile_list *profiles = ob_get_stream_profiles(device); ob_stream_profile *depth_profile = NULL; for (int i = 0; i < ob_stream_profile_list_count(profiles); i++) { ob_stream_profile *profile = ob_stream_profile_list_get_item(profiles, i); if (ob_stream_profile_get_stream_type(profile) == OB_STREAM_DEPTH) { depth_profile = profile; break; } } if (depth_profile == NULL) { printf("Depth stream not found\n"); ob_destroy_stream_profile_list(profiles); ob_destroy_config(config); ob_destroy_device(device); ob_destroy_context(ctx); return -1; } ob_config_enable_stream(config, depth_profile); ob_config_set_camera_controls(config, OB_CAMERA_CONTROL_LASER_POWER, 100, OB_CONTROL_TYPE_MANUAL); if (ob_config_commit(config) != OB_STATUS_SUCCESS) { printf("Failed to commit config\n"); ob_destroy_stream_profile_list(profiles); ob_destroy_config(config); ob_destroy_device(device); ob_destroy_context(ctx); return -1; } ob_start_device(device); printf("Device started successfully. Press Enter to exit.\n"); getchar(); ob_stop_device(device); ob_destroy_stream_profile_list(profiles); ob_destroy_config(config); ob_destroy_device(device); ob_destroy_context(ctx); return 0; } ``` -------------------------------- ### Install Java Example File Source: https://github.com/orbbec/orbbecsdk_v2/blob/main/3rdparty/libjpeg/src/CMakeLists.txt Installs the TJExample.java file to the installation's doc directory, conditional on WITH_JAVA being true. ```cmake if(WITH_JAVA) install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/java/TJExample.java DESTINATION ${CMAKE_INSTALL_DOCDIR}) endif() ``` -------------------------------- ### CMakeLists.txt for C Lidar Quick Start Source: https://github.com/orbbec/orbbecsdk_v2/blob/main/examples/lidar_examples/0.c_lidar_quick_start/CMakeLists.txt This CMakeLists.txt file sets up the build environment for the C Lidar Quick Start example. It defines the project, adds the main source file, links against Orbbec SDK libraries, and configures target properties for debugging and installation. ```cmake # Copyright (c) Orbbec Inc. All Rights Reserved. # Licensed under the MIT License. cmake_minimum_required(VERSION 3.10) project(ob_lidar_quick_start_c C) add_executable(${PROJECT_NAME} lidar_quick_start.c) target_link_libraries(${PROJECT_NAME} ob::${OB_SDK_LIB_NAME} ob::examples::utils) set_target_properties(${PROJECT_NAME} PROPERTIES FOLDER "lidar_examples") if(MSVC) set_target_properties(${PROJECT_NAME} PROPERTIES VS_DEBUGGER_WORKING_DIRECTORY "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}") endif() install(TARGETS ${PROJECT_NAME} RUNTIME DESTINATION bin) ``` -------------------------------- ### CMakeLists.txt for Infrared Example Source: https://github.com/orbbec/orbbecsdk_v2/blob/main/examples/1.stream.infrared/CMakeLists.txt Configures the build for the infrared example, setting the C++ standard, linking necessary libraries, and defining installation paths. ```cmake cmake_minimum_required(VERSION 3.10) project(ob_infrared) add_executable(${PROJECT_NAME} infrared.cpp) set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 11) target_link_libraries(${PROJECT_NAME} ob::${OB_SDK_LIB_NAME} ob::examples::utils) set_target_properties(${PROJECT_NAME} PROPERTIES FOLDER "examples") if(MSVC) set_target_properties(${PROJECT_NAME} PROPERTIES VS_DEBUGGER_WORKING_DIRECTORY "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}") endif() install(TARGETS ${PROJECT_NAME} RUNTIME DESTINATION bin) ``` -------------------------------- ### CMakeLists.txt for Confidence Example Source: https://github.com/orbbec/orbbecsdk_v2/blob/main/examples/1.stream.confidence/CMakeLists.txt Configures the build system for the confidence example, specifying the C++ standard, linking necessary Orbbec libraries, and setting up installation. ```cmake cmake_minimum_required(VERSION 3.10) project(ob_confidence) add_executable(${PROJECT_NAME} confidence.cpp) set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 11) target_link_libraries(${PROJECT_NAME} ob::${OB_SDK_LIB_NAME} ob::examples::utils) set_target_properties(${PROJECT_NAME} PROPERTIES FOLDER "examples") if(MSVC) set_target_properties(${PROJECT_NAME} PROPERTIES VS_DEBUGGER_WORKING_DIRECTORY "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}") endif() install(TARGETS ${PROJECT_NAME} RUNTIME DESTINATION bin) ``` -------------------------------- ### CMakeLists.txt Configuration Source: https://github.com/orbbec/orbbecsdk_v2/blob/main/examples/0.basic.quick_start/CMakeLists.txt Configures the build for the quick start example, setting the C++ standard, linking libraries, and defining output properties. ```cmake cmake_minimum_required(VERSION 3.10) project(ob_quick_start) add_executable(${PROJECT_NAME} quick_start.cpp) set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 11) target_link_libraries(${PROJECT_NAME} ob::${OB_SDK_LIB_NAME} ob::examples::utils) set_target_properties(${PROJECT_NAME} PROPERTIES FOLDER "examples") if(MSVC) set_target_properties(${PROJECT_NAME} PROPERTIES VS_DEBUGGER_WORKING_DIRECTORY "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}") endif() install(TARGETS ${PROJECT_NAME} RUNTIME DESTINATION bin) ``` -------------------------------- ### CMakeLists.txt for Enumeration Example Source: https://github.com/orbbec/orbbecsdk_v2/blob/main/examples/0.basic.enumerate/CMakeLists.txt Configures the build for the enumeration example, setting the C++ standard, linking libraries, and defining installation rules. ```cmake cmake_minimum_required(VERSION 3.10) project(ob_enumerate) add_executable(${PROJECT_NAME} enumerate.cpp) set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 11) target_link_libraries(${PROJECT_NAME} ob::${OB_SDK_LIB_NAME} ob::examples::utils) set_target_properties(${PROJECT_NAME} PROPERTIES FOLDER "examples") if(MSVC) set_target_properties(${PROJECT_NAME} PROPERTIES VS_DEBUGGER_WORKING_DIRECTORY "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}") endif() install(TARGETS ${PROJECT_NAME} RUNTIME DESTINATION bin) ``` -------------------------------- ### Run OrbbecSDK Example Program Source: https://github.com/orbbec/orbbecsdk_v2/blob/main/docs/tutorial/installation_and_development_guide.md Navigate to the bin directory and execute the sample program to test the OrbbecSDK functionality after installation. ```shell cd bin ./ob_color # ./ob_color for linux ``` -------------------------------- ### CMakeLists.txt for imshow Example Source: https://github.com/orbbec/orbbecsdk_v2/blob/main/examples/5.wrapper.opencv/imshow/CMakeLists.txt Configures the build for the imshow example, linking against Orbbec SDK libraries and utility functions. Sets C++ standard to 11 and specifies installation paths. ```cmake cmake_minimum_required(VERSION 3.10) project(ob_imshow) add_executable(${PROJECT_NAME} imshow.cpp) set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 11) target_link_libraries(${PROJECT_NAME} ob::${OB_SDK_LIB_NAME} ob::examples::utils) set_target_properties(${PROJECT_NAME} PROPERTIES FOLDER "examples") if(MSVC) set_target_properties(${PROJECT_NAME} PROPERTIES VS_DEBUGGER_WORKING_DIRECTORY "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}") endif() install(TARGETS ${PROJECT_NAME} RUNTIME DESTINATION bin) ``` -------------------------------- ### Get Depth Stream with OpenNI2 SDK Source: https://github.com/orbbec/orbbecsdk_v2/blob/main/docs/tutorial/opennisdk_to_orbbecsdkv2.md This comprehensive example demonstrates initializing the OpenNI2 SDK, opening a device, creating and configuring a depth stream, starting it, reading frames, and finally stopping the stream and shutting down the SDK. ```cpp // 1. Initialize SDK Status rc = OpenNI::initialize(); if (rc != STATUS_OK) { printf("Initialize failed\n%s\n", OpenNI::getExtendedError()); return 1; } // 2. Open device // Method 1 // Open the first device Device device; rc = device.open(ANY_DEVICE); if (rc != STATUS_OK) { printf("Couldn't open device\n%s\n", OpenNI::getExtendedError()); return 2; } // 3. Create depth VideoStream depth; if (device.getSensorInfo(SENSOR_DEPTH) != NULL) { rec = depth.create(device, SENSOR_DEPTH); if (rc != STATUS_OK) { printf("Couldn't create depth stream\n%s\n", OpenNI::getExtendedError()); return 3; } } //4. Set videomode const Array& videoModes = device.getSensorInfo(SENSOR_DEPTH)->getSupportedVideoModes(); VideoMode modeSet; for (int i = 0; i < videomodes.getSize(); i++){ VideoMode mode = videomodes[i]; if (mode.getResolutionX() == 640 && mode.getResolutionY() == 400 && mode.getFps() == 30){ modeSet = mode; break; } } depth.setVideoMode(modeSet); //5. Start depth rc = depth.start(); if (rc != STATUS_OK) { printf("Couldn't start the depth stream\n%s\n", OpenNI::getExtendedError()); return 4; } //6. Read frame int changedStreamDummy; VideoFrameRef frame; VideoStream* pStream = &depth; while(true) { rc = OpenNI::waitForAnyStream(&pStream, 1, &changedStreamDummy, SAMPLE_READ_WAIT_TIMEOUT); if (rc != STATUS_OK) { printf("Wait failed! (timeout is %d ms)\n%s\n", SAMPLE_READ_WAIT_TIMEOUT, OpenNI::getExtendedError()); continue; } rc = depth.readFrame(&frame); if (rc != STATUS_OK) { printf("Read failed!\n%s\n", OpenNI::getExtendedError()); continue; } // Get depth data DepthPixel* pDepth = (DepthPixel*)frame.getData(); } // 7.stop stream depth.stop(); depth.destroy(); // 8. Close device device.close(); // 9. Shutdown sdk OpenNI::shutdown(); ``` -------------------------------- ### CMakeLists.txt Configuration for Preset Example Source: https://github.com/orbbec/orbbecsdk_v2/blob/main/examples/3.advanced.preset/CMakeLists.txt This CMake script defines the build settings for the preset example, including executable name, C++ standard, library linking, and installation rules. ```cmake # Copyright (c) Orbbec Inc. All Rights Reserved. # Licensed under the MIT License. cmake_minimum_required(VERSION 3.10) project(ob_preset) add_executable(${PROJECT_NAME} preset.cpp) set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 11) target_link_libraries(${PROJECT_NAME} ob::${OB_SDK_LIB_NAME} ob::examples::utils) set_target_properties(${PROJECT_NAME} PROPERTIES FOLDER "examples") if(MSVC) set_target_properties(${PROJECT_NAME} PROPERTIES VS_DEBUGGER_WORKING_DIRECTORY "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}") endif() install(TARGETS ${PROJECT_NAME} RUNTIME DESTINATION bin) ``` -------------------------------- ### CMakeLists.txt for Depth Example Source: https://github.com/orbbec/orbbecsdk_v2/blob/main/examples/1.stream.depth/CMakeLists.txt Configures the build for the depth example executable, linking against Orbbec SDK libraries and utility modules. Sets C++ standard to 11 and specifies installation paths. ```cmake # Copyright (c) Orbbec Inc. All Rights Reserved. # Licensed under the MIT License. cmake_minimum_required(VERSION 3.10) project(ob_depth) add_executable(${PROJECT_NAME} depth.cpp) set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 11) target_link_libraries(${PROJECT_NAME} ob::${OB_SDK_LIB_NAME} ob::examples::utils) set_target_properties(${PROJECT_NAME} PROPERTIES FOLDER "examples") if(MSVC) set_target_properties(${PROJECT_NAME} PROPERTIES VS_DEBUGGER_WORKING_DIRECTORY "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}") endif() install(TARGETS ${PROJECT_NAME} RUNTIME DESTINATION bin) ``` -------------------------------- ### CMakeLists.txt for Device Record Example Source: https://github.com/orbbec/orbbecsdk_v2/blob/main/examples/2.device.record/CMakeLists.txt This snippet configures the build for the device record example. It sets the minimum CMake version, project name, adds the executable, specifies the C++ standard, links necessary libraries, sets target properties for organization and debugger settings, and defines installation rules. ```cmake cmake_minimum_required(VERSION 3.10) project(ob_device_record) add_executable(${PROJECT_NAME} device_record.cpp) set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 11) target_link_libraries(${PROJECT_NAME} ob::${OB_SDK_LIB_NAME} ob::examples::utils) set_target_properties(${PROJECT_NAME} PROPERTIES FOLDER "examples") if(MSVC) set_target_properties(${PROJECT_NAME} PROPERTIES VS_DEBUGGER_WORKING_DIRECTORY "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}") endif() install(TARGETS ${PROJECT_NAME} RUNTIME DESTINATION bin) ``` -------------------------------- ### CMakeLists.txt for Sync Align Example Source: https://github.com/orbbec/orbbecsdk_v2/blob/main/examples/3.advanced.sync_align/CMakeLists.txt Configures the build for the synchronized alignment example, specifying C++ standard, linking libraries, and installation paths. ```cmake cmake_minimum_required(VERSION 3.10) project(ob_sync_align) add_executable(${PROJECT_NAME} sync_align.cpp) set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 11) target_link_libraries(${PROJECT_NAME} ob::${OB_SDK_LIB_NAME} ob::examples::utils) set_target_properties(${PROJECT_NAME} PROPERTIES FOLDER "examples") if(MSVC) set_target_properties(${PROJECT_NAME} PROPERTIES VS_DEBUGGER_WORKING_DIRECTORY "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}") endif() install(TARGETS ${PROJECT_NAME} RUNTIME DESTINATION bin) ``` -------------------------------- ### CMakeLists.txt for Decimation Example Source: https://github.com/orbbec/orbbecsdk_v2/blob/main/examples/1.stream.decimation/CMakeLists.txt Configures the build for the decimation example, linking against Orbbec SDK libraries and utility functions. Sets C++11 standard and installation paths. ```cmake cmake_minimum_required(VERSION 3.10) project(ob_decimation) add_executable(${PROJECT_NAME} decimation.cpp) set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 11) target_link_libraries(${PROJECT_NAME} ob::${OB_SDK_LIB_NAME} ob::examples::utils) set_target_properties(${PROJECT_NAME} PROPERTIES FOLDER "examples") if(MSVC) set_target_properties(${PROJECT_NAME} PROPERTIES VS_DEBUGGER_WORKING_DIRECTORY "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}") endif() install(TARGETS ${PROJECT_NAME} RUNTIME DESTINATION bin) ``` -------------------------------- ### Project and Version Setup Source: https://github.com/orbbec/orbbecsdk_v2/blob/main/3rdparty/libuvc/src/CMakeLists.txt Sets the minimum CMake version, project name, version, and language. This is a standard starting point for CMake projects. ```cmake cmake_minimum_required(VERSION 3.10) project(libuvc VERSION 0.0.6 LANGUAGES C ) ``` -------------------------------- ### Linux Environment Setup Script Source: https://github.com/orbbec/orbbecsdk_v2/blob/main/docs/tutorial/installation_and_development_guide.md Use this script to install compilation tools, dependencies like OpenCV, compile sample programs, and install libusb rules files on Linux. ```bash cd scripts/env_setup ./setup.sh ``` -------------------------------- ### JPEG Compression Setup and Execution Source: https://github.com/orbbec/orbbecsdk_v2/blob/main/3rdparty/libjpeg/src/example.txt This snippet illustrates the complete process of compressing an image using libjpeg. It covers specifying the output destination, setting compression parameters like image dimensions and color space, starting the compression, writing scanlines, finishing the compression, and releasing the JPEG object. ```c /* Step 2: specify data destination (eg, a file) */ /* Note: steps 2 and 3 can be done in either order. */ /* Here we use the library-supplied code to send compressed data to a * stdio stream. You can also write your own code to do something else. * VERY IMPORTANT: use "b" option to fopen() if you are on a machine that * requires it in order to write binary files. */ if ((outfile = fopen(filename, "wb")) == NULL) { fprintf(stderr, "can't open %s\n", filename); exit(1); } jpeg_stdio_dest(&cinfo, outfile); /* Step 3: set parameters for compression */ /* First we supply a description of the input image. * Four fields of the cinfo struct must be filled in: */ cinfo.image_width = image_width; /* image width and height, in pixels */ cinfo.image_height = image_height; cinfo.input_components = 3; /* # of color components per pixel */ cinfo.in_color_space = JCS_RGB; /* colorspace of input image */ /* Now use the library's routine to set default compression parameters. * (You must set at least cinfo.in_color_space before calling this, * since the defaults depend on the source color space.) */ jpeg_set_defaults(&cinfo); /* Now you can set any non-default parameters you wish to. * Here we just illustrate the use of quality (quantization table) scaling: */ jpeg_set_quality(&cinfo, quality, TRUE /* limit to baseline-JPEG values */); /* Step 4: Start compressor */ /* TRUE ensures that we will write a complete interchange-JPEG file. * Pass TRUE unless you are very sure of what you're doing. */ jpeg_start_compress(&cinfo, TRUE); /* Step 5: while (scan lines remain to be written) */ /* jpeg_write_scanlines(...); */ /* Here we use the library's state variable cinfo.next_scanline as the * loop counter, so that we don't have to keep track ourselves. * To keep things simple, we pass one scanline per call; you can pass * more if you wish, though. */ row_stride = image_width * 3; /* JSAMPLEs per row in image_buffer */ while (cinfo.next_scanline < cinfo.image_height) { /* jpeg_write_scanlines expects an array of pointers to scanlines. * Here the array is only one element long, but you could pass * more than one scanline at a time if that's more convenient. */ row_pointer[0] = &image_buffer[cinfo.next_scanline * row_stride]; (void)jpeg_write_scanlines(&cinfo, row_pointer, 1); } /* Step 6: Finish compression */ jpeg_finish_compress(&cinfo); /* After finish_compress, we can close the output file. */ fclose(outfile); /* Step 7: release JPEG compression object */ /* This is an important step since it will release a good deal of memory. */ jpeg_destroy_compress(&cinfo); /* And we're done! */ ``` -------------------------------- ### CMakeLists.txt for Device Control Example Source: https://github.com/orbbec/orbbecsdk_v2/blob/main/examples/2.device.control/CMakeLists.txt This CMakeLists.txt file defines the build configuration for the device control example. It sets the minimum CMake version, project name, adds the executable, specifies the C++ standard, links Orbbec SDK libraries, and configures installation and debugger properties. ```cmake cmake_minimum_required(VERSION 3.10) project(ob_device_control) add_executable(${PROJECT_NAME} device_control.cpp) set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 11) target_link_libraries(${PROJECT_NAME} ob::${OB_SDK_LIB_NAME} ob::examples::utils) set_target_properties(${PROJECT_NAME} PROPERTIES FOLDER "examples") if(MSVC) set_target_properties(${PROJECT_NAME} PROPERTIES VS_DEBUGGER_WORKING_DIRECTORY "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}") endif() install(TARGETS ${PROJECT_NAME} RUNTIME DESTINATION bin) ``` -------------------------------- ### CMakeLists.txt Configuration for Multi-Streams Example Source: https://github.com/orbbec/orbbecsdk_v2/blob/main/examples/1.stream.multi_streams/CMakeLists.txt This CMake script sets up the build environment for the multi_streams C++ example. It defines the project, adds an executable, links against Orbbec SDK libraries, and configures installation and debugging. ```cmake cmake_minimum_required(VERSION 3.10) project(ob_multi_streams) add_executable(${PROJECT_NAME} multi_streams.cpp) set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 11) target_link_libraries(${PROJECT_NAME} ob::${OB_SDK_LIB_NAME} ob::examples::utils) set_target_properties(${PROJECT_NAME} PROPERTIES FOLDER "examples") if(MSVC) set_target_properties(${PROJECT_NAME} PROPERTIES VS_DEBUGGER_WORKING_DIRECTORY "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}") endif() install(TARGETS ${PROJECT_NAME} RUNTIME DESTINATION bin) ``` -------------------------------- ### Start and Enter Docker Container Source: https://github.com/orbbec/orbbecsdk_v2/blob/main/scripts/docker/README.md Starts the Docker container using ADE and enters it. ```bash ade start ade enter ``` -------------------------------- ### Installing the Benchmark Executable Source: https://github.com/orbbec/orbbecsdk_v2/blob/main/tools/benchmark/CMakeLists.txt Installs the benchmark executable to the 'bin' directory. ```cmake install(TARGETS ob_benchmark RUNTIME DESTINATION bin) ``` -------------------------------- ### CMakeLists.txt Configuration for Device Example Source: https://github.com/orbbec/orbbecsdk_v2/blob/main/examples/2.device.optional_depth_presets_update/CMakeLists.txt This snippet configures the build for the device optional depth presets update example. It sets the minimum CMake version, project name, adds the executable, specifies the C++ standard, links Orbbec SDK libraries, and sets target properties for debugging and installation. ```cmake cmake_minimum_required(VERSION 3.10) project(ob_device_optional_depth_presets_update) add_executable(${PROJECT_NAME} device.optional_depth_presets_update.cpp) set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 11) target_link_libraries(${PROJECT_NAME} ob::${OB_SDK_LIB_NAME} ob::examples::utils) set_target_properties(${PROJECT_NAME} PROPERTIES FOLDER "examples") if(MSVC) set_target_properties(${PROJECT_NAME} PROPERTIES VS_DEBUGGER_WORKING_DIRECTORY "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}") endif() install(TARGETS ${PROJECT_NAME} RUNTIME DESTINATION bin) ``` -------------------------------- ### Build Examples Source: https://github.com/orbbec/orbbecsdk_v2/blob/main/3rdparty/spdlog/src/CMakeLists.txt This snippet conditionally builds the spdlog examples based on build flags like SPDLOG_BUILD_EXAMPLE, SPDLOG_BUILD_EXAMPLE_HO, or SPDLOG_BUILD_ALL. It adds the example subdirectory and enables warnings. ```cmake if(SPDLOG_BUILD_EXAMPLE OR SPDLOG_BUILD_EXAMPLE_HO OR SPDLOG_BUILD_ALL) message(STATUS "Generating example(s)") add_subdirectory(example) spdlog_enable_warnings(example) if(SPDLOG_BUILD_EXAMPLE_HO) spdlog_enable_warnings(example_header_only) endif() endif() ``` -------------------------------- ### Setup for ARM Cross Compilation Source: https://github.com/orbbec/orbbecsdk_v2/blob/main/3rdparty/libyuv/src/docs/getting_started.md Installs necessary development tools and libraries for ARM cross-compilation on a Debian-based system. ```bash sudo apt-get install ssh dkms build-essential linux-headers-generic sudo apt-get install kdevelop cmake git subversion sudo apt-get install graphviz doxygen doxygen-gui sudo apt-get install manpages manpages-dev manpages-posix manpages-posix-dev sudo apt-get install libboost-all-dev libboost-dev libssl-dev sudo apt-get install rpm terminator fish sudo apt-get install g++-arm-linux-gnueabihf gcc-arm-linux-gnueabihf ``` -------------------------------- ### CMakeLists.txt for Post-Processing Example Source: https://github.com/orbbec/orbbecsdk_v2/blob/main/examples/3.advanced.post_processing/CMakeLists.txt This CMakeLists.txt file defines the build configuration for the post-processing example. It sets the minimum CMake version, project name, adds the executable, links Orbbec SDK libraries, and configures installation and debugging. ```cmake # Copyright (c) Orbbec Inc. All Rights Reserved. # Licensed under the MIT License. cmake_minimum_required(VERSION 3.10) project(ob_post_processing) add_executable(${PROJECT_NAME} post_processing.cpp) set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 11) target_link_libraries(${PROJECT_NAME} ob::${OB_SDK_LIB_NAME} ob::examples::utils) set_target_properties(${PROJECT_NAME} PROPERTIES FOLDER "examples") if(MSVC) set_target_properties(${PROJECT_NAME} PROPERTIES VS_DEBUGGER_WORKING_DIRECTORY "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}") endif() install(TARGETS ${PROJECT_NAME} RUNTIME DESTINATION bin) ``` -------------------------------- ### CMakeLists.txt Configuration for Metadata Example Source: https://github.com/orbbec/orbbecsdk_v2/blob/main/examples/4.misc.metadata/CMakeLists.txt This snippet shows the CMake configuration for building the metadata example executable. It sets the minimum CMake version, project name, adds the source file, links against Orbbec SDK libraries, and defines installation rules. ```cmake cmake_minimum_required(VERSION 3.10) project(ob_metadata) add_executable(${PROJECT_NAME} metadata.cpp) set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 11) target_link_libraries(${PROJECT_NAME} ob::${OB_SDK_LIB_NAME} ob::examples::utils) set_target_properties(${PROJECT_NAME} PROPERTIES FOLDER "examples") if(MSVC) set_target_properties(${PROJECT_NAME} PROPERTIES VS_DEBUGGER_WORKING_DIRECTORY "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}") endif() install(TARGETS ${PROJECT_NAME} RUNTIME DESTINATION bin) ``` -------------------------------- ### Start Multi-Device Stream (GMSL) Source: https://github.com/orbbec/orbbecsdk_v2/blob/main/examples/3.advanced.multi_devices_sync/README.md Start streaming for GMSL devices after configuration. ```bash $ ./ob_multi_devices_sync -------------------------------------------------- Please select options: 0 --> config devices sync mode. 1 --> start stream -------------------------------------------------- Please select input: 1 ``` -------------------------------- ### Release build and install with CMake Source: https://github.com/orbbec/orbbecsdk_v2/blob/main/3rdparty/libyuv/src/docs/getting_started.md Configures a Release build of libyuv with a specified installation prefix, builds it, and then installs it using CMake. ```bash mkdir out cd out cmake -DCMAKE_INSTALL_PREFIX="/usr/lib" -DCMAKE_BUILD_TYPE="Release" .. cmake --build . --config Release sudo cmake --build . --target install --config Release ``` -------------------------------- ### Install PkgConfig Files Source: https://github.com/orbbec/orbbecsdk_v2/blob/main/3rdparty/libjpeg/src/CMakeLists.txt This commented-out section shows how to install pkgconfig files for libjpeg and libturbojpeg. ```cmake # install(FILES ${CMAKE_CURRENT_BINARY_DIR}/pkgscripts/libjpeg.pc # ${CMAKE_CURRENT_BINARY_DIR}/pkgscripts/libturbojpeg.pc # DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig) ``` -------------------------------- ### CMakeLists.txt Configuration for Firmware Update Example Source: https://github.com/orbbec/orbbecsdk_v2/blob/main/examples/2.device.firmware_update/CMakeLists.txt This snippet configures the build for the device firmware update example. It sets the minimum CMake version, project name, adds the executable, specifies the C++ standard, links libraries, and defines target properties for debugging and installation. ```cmake cmake_minimum_required(VERSION 3.10) project(ob_device_firmware_update) add_executable(${PROJECT_NAME} device_firmware_update.cpp) set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 11) target_link_libraries(${PROJECT_NAME} ob::${OB_SDK_LIB_NAME} ob::examples::utils) set_target_properties(${PROJECT_NAME} PROPERTIES FOLDER "examples") if(MSVC) set_target_properties(${PROJECT_NAME} PROPERTIES VS_DEBUGGER_WORKING_DIRECTORY "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}") endif() install(TARGETS ${PROJECT_NAME} RUNTIME DESTINATION bin) ``` -------------------------------- ### Create All Examples Target Source: https://github.com/orbbec/orbbecsdk_v2/blob/main/3rdparty/jsoncpp/src/example/CMakeLists.txt Defines a custom target 'examples' that depends on all the individual example executables, allowing them to be built together. ```cmake add_custom_target(examples ALL DEPENDS ${EXAMPLES}) ``` -------------------------------- ### OpenNI2 SDK: Get IR Stream Source: https://github.com/orbbec/orbbecsdk_v2/blob/main/docs/tutorial/opennisdk_to_orbbecsdkv2.md Demonstrates the steps to initialize the SDK, open a device, create an IR stream, set video mode, start the stream, and read frames using the OpenNI2 SDK. ```cpp // 1. Initialize SDK Status rc = OpenNI::initialize(); if (rc != STATUS_OK) { printf("Initialize failed\n%s\n", OpenNI::getExtendedError()); return 1; } // 2. Open device // Open the first device Device device; rc = device.open(ANY_DEVICE); if (rc != STATUS_OK) { printf("Couldn't open device\n%s\n", OpenNI::getExtendedError()); return 2; } // 3. Create ir stream VideoStream ir; if (device.getSensorInfo(SENSOR_IR) != NULL) { rec = ir.create(device, SENSOR_IR); if (rc != STATUS_OK) { printf("Couldn't create ir stream\n%s\n", OpenNI::getExtendedError()); return 3; } } // 4. Set videomode const Array& videoModes = device.getSensorInfo(SENSOR_IR)->getSupportedVideoModes(); VideoMode modeSet; for (int i = 0; i < videomodes.getSize(); i++){ VideoMode mode = videomodes[i]; if (mode.getResolutionX() == 640 && mode.getResolutionY() == 400 && mode.getFps() == 30){ modeSet = mode; break; } } ir.setVideoMode(modeSet); // 5. Start stream rc = ir.start(); if (rc != STATUS_OK) { printf("Couldn't start the ir stream\n%s\n", OpenNI::getExtendedError()); return 4; } // 6. Read frame int changedStreamDummy; VideoFrameRef frame; VideoStream* pStream = &ir; while(true) { rc = OpenNI::waitForAnyStream(&pStream, 1, &changedStreamDummy, SAMPLE_READ_WAIT_TIMEOUT); if (rc != STATUS_OK) { printf("Wait failed! (timeout is %d ms)\n%s\n", SAMPLE_READ_WAIT_TIMEOUT, OpenNI::getExtendedError()); continue; } rc = ir.readFrame(&frame); if (rc != STATUS_OK) { printf("Read failed!\n%s\n", OpenNI::getExtendedError()); continue; } // Get IR data Grayscale16Pixel* pIR = (Grayscale16Pixel*)frame.getData(); } // 7. Stop frame ir.stop(); ir.destroy(); // 8. Close device device.close(); // 9. Shutdown SDK OpenNI::shutdown(); ``` -------------------------------- ### Install Executable Source: https://github.com/orbbec/orbbecsdk_v2/blob/main/examples/5.wrapper.pcl/pcl/CMakeLists.txt Installs the built executable to the 'bin' directory on the target system. ```cmake install(TARGETS ${PROJECT_NAME} RUNTIME DESTINATION bin) ``` -------------------------------- ### Define Examples to Build Source: https://github.com/orbbec/orbbecsdk_v2/blob/main/3rdparty/jsoncpp/src/example/CMakeLists.txt Specifies the list of example executables to be compiled. Each entry corresponds to a subdirectory containing the source code for an example. ```cmake set(EXAMPLES readFromString readFromStream stringWrite streamWrite ) ``` -------------------------------- ### Install libjpeg-turbo Source: https://github.com/orbbec/orbbecsdk_v2/blob/main/3rdparty/libjpeg/src/BUILDING.md Install libjpeg-turbo using the build system by running 'make install' or 'nmake install'. Use CMAKE_INSTALL_PREFIX to specify a custom installation directory. ```bash make install ``` ```bash nmake install ``` -------------------------------- ### Start Pipeline Source: https://github.com/orbbec/orbbecsdk_v2/blob/main/examples/c_examples/0.c_quick_start/readme.md Starts the initialized pipeline. By default, this will begin streaming color and depth data. Always check for errors after starting. ```c // Start Pipeline with default configuration (At default, the pipeline will start with the color and depth streams) ob_pipeline_start(pipe, &error); ``` -------------------------------- ### Get Depth Stream with OrbbecSDK v2 Source: https://github.com/orbbec/orbbecsdk_v2/blob/main/docs/tutorial/opennisdk_to_orbbecsdkv2.md This example shows how to set up and start a depth stream using OrbbecSDK v2. It involves creating a pipeline, configuring the stream with specific resolution and format, starting the pipeline, and then continuously retrieving depth frames. ```cpp // 1.Create a pipeline with default device. or create a pipeline with device // auto pipe = std::make_shared(device); ob::Pipeline pipe; // 2.Create config. std::shared_ptr config = std::make_shared(); // 3.Enable video stream. You can modify the parameters based on your usage requirements, stream format can be either 11-bit(OB_FORMAT_Y11) or 12-bit(OB_FORMAT_Y12). config->enableVideoStream(OB_STREAM_DEPTH, 640, 400, 30, OB_FORMAT_Y11); // 4.Start the pipeline with config. pipe.start(config); while(true) { // 5.Wait for up to 100ms for a frameset in blocking mode. auto frameSet = pipe.waitForFrameset(100); if(frameSet == nullptr) { continue; } // Get the depth frame. auto depthFrameRaw = frameSet->getFrame(OB_FRAME_DEPTH); if(depthFrameRaw) { // Get the depth Frame form depthFrame,process depth data. auto depthFrame = depthFrameRaw->as(); uint32_t width = depthFrame->getWidth(); uint32_t height = depthFrame->getHeight(); const uint16_t *data = reinterpret_cast(depthFrame->getData()); } } // 6.Stop the pipeline pipe.stop(); ``` -------------------------------- ### CMakeLists.txt for C Depth Examples Source: https://github.com/orbbec/orbbecsdk_v2/blob/main/examples/c_examples/2.c_depth/CMakeLists.txt Configures the build for the C depth example using CMake. It links against the Orbbec SDK libraries and example utilities. ```cmake cmake_minimum_required(VERSION 3.10) project(ob_depth_c) add_executable(${PROJECT_NAME} depth.c) target_link_libraries(${PROJECT_NAME} PRIVATE ob::${OB_SDK_LIB_NAME} ob::examples::utils) set_target_properties(${PROJECT_NAME} PROPERTIES FOLDER "examples_c") if(MSVC) set_target_properties(${PROJECT_NAME} PROPERTIES VS_DEBUGGER_WORKING_DIRECTORY "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}") endif() install(TARGETS ${PROJECT_NAME} RUNTIME DESTINATION bin) ``` -------------------------------- ### Example .gclient File Configuration Source: https://github.com/orbbec/orbbecsdk_v2/blob/main/3rdparty/libyuv/src/docs/getting_started.md This is an example of the .gclient file generated after configuration, showing the structure for specifying the source repository. ```python solutions = [ { "name" : "src", "url" : "https://chromium.googlesource.com/libyuv/libyuv", "deps_file" : "DEPS", "managed" : True, "custom_deps" : { }, "safesync_url": "", }, ]; ``` -------------------------------- ### Orbbec SDK v1 QuickStart Sample Source: https://github.com/orbbec/orbbecsdk_v2/blob/main/docs/tutorial/orbbecsdkv1_to_openorbbecsdkv2.md This C++ code demonstrates a basic QuickStart sample using Orbbec SDK v1, including pipeline creation, frame retrieval, and basic frame data printing. ```cpp #include "libobsensor/hpp/Pipeline.hpp" #include "libobsensor/hpp/Error.hpp" #include "utils.hpp" #include #define ESC 27 int main(int argc, char **argv) try { // Create a pipeline with default device ob::Pipeline pipe; // Start the pipeline with default config, more info please refer to the `misc/config/OrbbecSDKConfig_v1.0.xml` pipe.start(); auto lastTime = std::chrono::high_resolution_clock::now(); while(true) { // Check for key press and break if it's ESC if(kbhit() && getch() == ESC) { break; } auto frameSet = pipe.waitForFrames(); if(!frameSet) { continue; } auto colorFrame = frameSet->colorFrame(); auto depthFrame = frameSet->depthFrame(); auto now = std::chrono::high_resolution_clock::now(); // Print the frame data every second if(std::chrono::duration_cast(now - lastTime).count() >= 1) { if(colorFrame) { std::cout << "Color Frame: " << colorFrame->width() << "x" << colorFrame->height() << " " << colorFrame->timeStampUs() << " us" << std::endl; } if(depthFrame) { std::cout << "Depth Frame: " << depthFrame->width() << "x" << depthFrame->height() << " " << depthFrame->timeStampUs() << " us" << std::endl; } lastTime = now; // Reset the timer } } // Stop the Pipeline, no frame data will be generated pipe.stop(); return 0; } catch(ob::Error &e) { std::cerr << "function:" << e.getName() << "\nargs:" << e.getArgs() << "\nmessage:" << e.getMessage() << "\ntype:" << e.getExceptionType() << std::endl; exit(EXIT_FAILURE); } ``` -------------------------------- ### Unix-specific Installations Source: https://github.com/orbbec/orbbecsdk_v2/blob/main/scripts/CMakeLists.txt Installs udev rules and setup scripts for Unix-like systems (excluding macOS) when OB_IS_MAIN_PROJECT is true. ```cmake if(OB_IS_MAIN_PROJECT) if(UNIX) if(NOT APPLE) install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/env_setup/99-obsensor-libusb.rules DESTINATION shared) install(PROGRAMS ${CMAKE_CURRENT_SOURCE_DIR}/env_setup/install_udev_rules.sh DESTINATION shared) endif() install(PROGRAMS ${CMAKE_CURRENT_SOURCE_DIR}/env_setup/setup.sh DESTINATION .) endif() endif() ``` -------------------------------- ### Shell Interaction: Get and Set Property Values Source: https://github.com/orbbec/orbbecsdk_v2/blob/main/examples/lidar_examples/2.lidar_device_control/README.md Example of interactive commands to get the current value of a property and then set a new value for it, followed by a verification get. ```shell 1 get property name:OB_PROP_LIDAR_PORT_INT,get int value:2401 3 set 2 property name:OB_PROP_LIDAR_TAIL_FILTER_LEVEL_INT,set int value:2 3 get property name:OB_PROP_LIDAR_TAIL_FILTER_LEVEL_INT,get int value:2 exit ``` -------------------------------- ### CMakeLists.txt for Orbbec Logger Example Source: https://github.com/orbbec/orbbecsdk_v2/blob/main/examples/4.misc.logger/CMakeLists.txt This CMakeLists.txt file defines the build settings for the logger example. It specifies the C++ standard, links the Orbbec SDK and examples utilities, and configures installation. ```cmake # Copyright (c) Orbbec Inc. All Rights Reserved. # Licensed under the MIT License. cmake_minimum_required(VERSION 3.10) project(ob_logger) add_executable(${PROJECT_NAME} logger.cpp) set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 11) target_link_libraries(${PROJECT_NAME} ob::${OB_SDK_LIB_NAME} ob::examples::utils) set_target_properties(${PROJECT_NAME} PROPERTIES FOLDER "examples") if(MSVC) set_target_properties(${PROJECT_NAME} PROPERTIES VS_DEBUGGER_WORKING_DIRECTORY "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}") endif() install(TARGETS ${PROJECT_NAME} RUNTIME DESTINATION bin) ``` -------------------------------- ### Instantiate and Start Pipeline Source: https://github.com/orbbec/orbbecsdk_v2/blob/main/examples/0.basic.quick_start/README.md Create an instance of the ob::Pipeline and start it with the default configuration. The configuration can be modified via an SDKConfig.xml file. ```cpp // Create a pipeline. ob::Pipeline pipe; // Start the pipeline with default config. // Modify the default configuration by the configuration file: "*SDKConfig.xml" pipe.start(); ``` -------------------------------- ### CMakeLists.txt for Force IP Example Source: https://github.com/orbbec/orbbecsdk_v2/blob/main/examples/2.device.forceip/CMakeLists.txt Configures the build for the device force IP example, linking necessary libraries. ```cmake cmake_minimum_required(VERSION 3.10) project(ob_device_forceip) add_executable(${PROJECT_NAME} forceip.cpp) set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 11) target_link_libraries(${PROJECT_NAME} ob::${OB_SDK_LIB_NAME} ob::examples::utils) set_target_properties(${PROJECT_NAME} PROPERTIES FOLDER "examples") if(MSVC) set_target_properties(${PROJECT_NAME} PROPERTIES VS_DEBUGGER_WORKING_DIRECTORY "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}") endif() install(TARGETS ${PROJECT_NAME} RUNTIME DESTINATION bin) ``` -------------------------------- ### Build and Run Open3D Example Source: https://github.com/orbbec/orbbecsdk_v2/blob/main/examples/5.wrapper.open3d/README.md Provides the bash commands to build and run the Open3D example. This includes creating a build directory, configuring CMake with Open3D specific flags, compiling the project, and executing the compiled binary. ```bash mkdir build cd build cmake .. -DOB_BUILD_OPEN3D_EXAMPLES=ON -DOpen3D_DIR= make -j4 ./ob_open3d ``` -------------------------------- ### Configure and Start Pipeline with Callback Source: https://github.com/orbbec/orbbecsdk_v2/blob/main/examples/2.device.record.nogui/README.md Sets up the pipeline with a configuration and starts it, providing a callback function to process each received frameset. This callback is executed in real-time. ```cpp pipe->start(config, [&](std::shared_ptr frameSet) { std::lock_guard lock(frameMutex); // Do something for frameset }); ``` -------------------------------- ### Build Executable for Each Example Source: https://github.com/orbbec/orbbecsdk_v2/blob/main/3rdparty/jsoncpp/src/example/CMakeLists.txt Iterates through the defined examples, creating an executable for each. It sets up include directories and links against the 'jsoncpp_lib'. ```cmake foreach(example ${EXAMPLES}) add_executable(${example} ${example}/${example}.cpp) target_include_directories(${example} PUBLIC ${CMAKE_SOURCE_DIR}/include) target_link_libraries(${example} jsoncpp_lib) endforeach() ``` -------------------------------- ### Example .gclient file for libyuv Source: https://github.com/orbbec/orbbecsdk_v2/blob/main/3rdparty/libyuv/src/docs/deprecated_builds.md An example of a .gclient file configuration for the libyuv repository. This specifies the repository URL and other managed properties. ```python solutions = [ { "name" : "libyuv", "url" : "https://chromium.googlesource.com/libyuv/libyuv", "deps_file" : "DEPS", "managed" : True, "custom_deps" : { }, "safesync_url": "", }, ]; ``` -------------------------------- ### CMakeLists.txt Configuration for Laser Interleave Example Source: https://github.com/orbbec/orbbecsdk_v2/blob/main/examples/3.advanced.laser_interleave/CMakeLists.txt This CMakeLists.txt file sets up the build environment for the laser interleave example. It defines the project, adds the executable, links Orbbec SDK libraries, and configures installation and debugging. ```cmake cmake_minimum_required(VERSION 3.10) project(ob_laser_interleave) add_executable(${PROJECT_NAME} laser_interleave.cpp) set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 11) target_link_libraries(${PROJECT_NAME} ob::${OB_SDK_LIB_NAME} ob::examples::utils) set_target_properties(${PROJECT_NAME} PROPERTIES FOLDER "examples") if(MSVC) set_target_properties(${PROJECT_NAME} PROPERTIES VS_DEBUGGER_WORKING_DIRECTORY "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}") endif() install(TARGETS ${PROJECT_NAME} RUNTIME DESTINATION bin) ``` -------------------------------- ### C Get Depth Stream and Image Example Source: https://github.com/orbbec/orbbecsdk_v2/blob/main/examples/README.md This example demonstrates how to retrieve depth stream data and process it into a depth image using the SDK C API. It is useful for applications requiring depth perception. ```c #include #include #include "libobsensor/ob.h" int main() { ob_context *ctx = ob_create_context(NULL, NULL); if (ctx == NULL) { printf("Failed to create context\n"); return -1; } int device_count = ob_get_device_count(ctx); if (device_count == 0) { printf("No device found\n"); ob_destroy_context(ctx); return -1; } ob_device_list *device_list = ob_create_device_list(ctx); ob_device *device = ob_create_device(device_list, 0); if (device == NULL) { printf("Failed to create device\n"); ob_destroy_device_list(device_list); ob_destroy_context(ctx); return -1; } ob_config *config = ob_create_config(device); ob_stream_profile_list *profiles = ob_get_stream_profiles(device); ob_stream_profile *depth_profile = NULL; for (int i = 0; i < ob_stream_profile_list_count(profiles); i++) { ob_stream_profile *profile = ob_stream_profile_list_get_item(profiles, i); if (ob_stream_profile_get_stream_type(profile) == OB_STREAM_DEPTH) { depth_profile = profile; break; } } if (depth_profile == NULL) { printf("Depth stream not found\n"); ob_destroy_stream_profile_list(profiles); ob_destroy_config(config); ob_destroy_device(device); ob_destroy_context(ctx); return -1; } ob_config_enable_stream(config, depth_profile); ob_config_set_camera_controls(config, OB_CAMERA_CONTROL_LASER_POWER, 100, OB_CONTROL_TYPE_MANUAL); if (ob_config_commit(config) != OB_STATUS_SUCCESS) { printf("Failed to commit config\n"); ob_destroy_stream_profile_list(profiles); ob_destroy_config(config); ob_destroy_device(device); ob_destroy_context(ctx); return -1; } ob_start_device(device); ob_frame *depth_frame = ob_take_frame(device, 1000); if (depth_frame != NULL) { int width = ob_frame_get_width(depth_frame); int height = ob_frame_get_height(depth_frame); printf("Depth frame received: %dx%d\n", width, height); // Process depth_frame here to get depth image ob_frame_delete(depth_frame); } else { printf("Failed to take depth frame\n"); } ob_stop_device(device); ob_destroy_stream_profile_list(profiles); ob_destroy_config(config); ob_destroy_device(device); ob_destroy_context(ctx); return 0; } ``` -------------------------------- ### Install ADE CLI Source: https://github.com/orbbec/orbbecsdk_v2/blob/main/scripts/docker/README.md Installs the ADE CLI by downloading, making executable, and moving it to the system's PATH. ```bash mv ade+x86_64 ade # or mv ade+aarch64 ade chmod +x ade sudo mv ade /usr/local/bin ```