├── sdk ├── doc │ └── .gitkeep ├── CMakeVersion ├── src │ ├── cv_modules │ │ ├── CMakeLists.txt │ │ └── max_depth_value_module │ │ │ ├── CMakeLists.txt │ │ │ └── max_depth_value_module.cpp │ ├── tools │ │ ├── CMakeLists.txt │ │ ├── capture_tool │ │ │ └── CMakeLists.txt │ │ └── projection_tool │ │ │ ├── CMakeLists.txt │ │ │ └── projection_cmd_util.h │ ├── core │ │ ├── CMakeLists.txt │ │ ├── pipeline │ │ │ ├── device_streaming_guard.h │ │ │ ├── sample_set_releaser.h │ │ │ ├── device_streaming_guard.cpp │ │ │ ├── CMakeLists.txt │ │ │ ├── device_config_guard.h │ │ │ ├── async_samples_consumer.h │ │ │ ├── sync_samples_consumer.h │ │ │ ├── samples_consumer_base.h │ │ │ ├── config_util.h │ │ │ ├── device_manager.h │ │ │ ├── pipeline_async.cpp │ │ │ ├── async_samples_consumer.cpp │ │ │ └── sync_samples_consumer.cpp │ │ ├── image │ │ │ ├── lrs_image │ │ │ │ ├── CMakeLists.txt │ │ │ │ ├── lrs_image.h │ │ │ │ └── lrs_image.cpp │ │ │ ├── CMakeLists.txt │ │ │ ├── image_conversion_util.h │ │ │ ├── metadata.h │ │ │ ├── image_base.h │ │ │ ├── custom_image.h │ │ │ ├── metadata.cpp │ │ │ ├── image_base.cpp │ │ │ └── custom_image.cpp │ │ └── projection │ │ │ ├── CMakeLists.txt │ │ │ └── math_projection_interface.h │ ├── cameras │ │ ├── CMakeLists.txt │ │ ├── compression │ │ │ ├── CMakeLists.txt │ │ │ ├── codec_interface.h │ │ │ ├── decoder.h │ │ │ ├── encoder.h │ │ │ ├── lz4_codec.h │ │ │ ├── decoder.cpp │ │ │ ├── encoder.cpp │ │ │ └── lz4_codec.cpp │ │ ├── record │ │ │ ├── include │ │ │ │ └── record_device_interface.h │ │ │ ├── record_context.cpp │ │ │ └── CMakeLists.txt │ │ ├── playback │ │ │ ├── include │ │ │ │ ├── disk_read.h │ │ │ │ ├── linux │ │ │ │ │ └── v1 │ │ │ │ │ │ └── disk_read.h │ │ │ │ ├── windows │ │ │ │ │ └── v10 │ │ │ │ │ │ ├── disk_read.h │ │ │ │ │ │ └── conversions.h │ │ │ │ ├── playback_device_interface.h │ │ │ │ ├── disk_read_factory.h │ │ │ │ ├── disk_read_interface.h │ │ │ │ └── rs_stream_impl.h │ │ │ ├── playback_context.cpp │ │ │ ├── CMakeLists.txt │ │ │ └── rs_stream_impl.cpp │ │ └── include │ │ │ └── linear_algebra.h │ ├── utilities │ │ ├── CMakeLists.txt │ │ ├── logger │ │ │ ├── logger │ │ │ │ ├── CMakeLists.txt │ │ │ │ ├── package_logger_configure.json │ │ │ │ ├── xlevel.h │ │ │ │ └── xlevel.cpp │ │ │ ├── log_utils │ │ │ │ └── CMakeLists.txt │ │ │ ├── CMakeLists.txt │ │ │ └── rslog.properties │ │ ├── samples_time_sync │ │ │ ├── samples_time_sync_ds5.cpp │ │ │ ├── samples_time_sync_external_camera.cpp │ │ │ ├── samples_time_sync_external_camera.h │ │ │ ├── samples_time_sync_ds5.h │ │ │ ├── samples_time_sync_zr300.h │ │ │ ├── CMakeLists.txt │ │ │ ├── samples_time_sync_impl.cpp │ │ │ └── samples_time_sync_base.h │ │ ├── viewer │ │ │ └── CMakeLists.txt │ │ └── command_line │ │ │ └── CMakeLists.txt │ └── include │ │ ├── basic_cmd_util.h │ │ └── viewer.h ├── include │ ├── rs_record.h │ ├── rs_playback.h │ ├── rs_sdk.h │ ├── rs_utils.h │ ├── rs_sdk_version.h │ ├── rs_core.h │ └── rs │ │ ├── core │ │ ├── motion_sample.h │ │ ├── release_interface.h │ │ ├── ref_count_interface.h │ │ ├── context.h │ │ ├── context_interface.h │ │ └── status.h │ │ ├── utils │ │ ├── release_self_base.h │ │ ├── self_releasing_array_data_releaser.h │ │ ├── ref_count_base.h │ │ └── smart_ptr_helpers.h │ │ ├── cv_modules │ │ └── max_depth_value_module │ │ │ ├── max_depth_value_output_interface.h │ │ │ └── max_depth_value_module.h │ │ ├── record │ │ └── record_context.h │ │ └── playback │ │ └── playback_context.h └── CMakeLists.txt ├── .gitignore ├── dependencies_versions ├── tests ├── main.cpp ├── logger_tests.cpp ├── utilities │ └── utilities.h └── CMakeLists.txt ├── cmake_includes ├── pkg-config.pc.cmake ├── check_os.cmake ├── pkg_config ├── config_linux.cmake └── config_windows.cmake ├── samples ├── src │ ├── fps_counter_sample │ │ ├── CMakeLists.txt │ │ ├── README.md │ │ └── main.cpp │ ├── projection_sample │ │ ├── README.md │ │ └── CMakeLists.txt │ ├── record_sync_sample │ │ ├── CMakeLists.txt │ │ ├── README.md │ │ └── main.cpp │ ├── playback_sync_sample │ │ ├── CMakeLists.txt │ │ ├── README.md │ │ └── main.cpp │ ├── record_async_sample │ │ ├── CMakeLists.txt │ │ ├── README.md │ │ └── main.cpp │ ├── playback_async_sample │ │ ├── CMakeLists.txt │ │ ├── README.md │ │ └── main.cpp │ ├── samples_time_sync_sample │ │ ├── CMakeLists.txt │ │ └── README.md │ ├── video_module_sync_sample │ │ ├── CMakeLists.txt │ │ └── README.md │ ├── video_module_async_sample │ │ ├── CMakeLists.txt │ │ └── README.md │ └── pipeline_async_sample │ │ ├── CMakeLists.txt │ │ └── README.md └── CMakeLists.txt ├── CMakeLists.txt └── package_configure.json /sdk/doc/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /sdk/CMakeVersion: -------------------------------------------------------------------------------- 1 | set(SDK_VERSION_MAJOR 0 ) 2 | set(SDK_VERSION_MINOR 7 ) 3 | set(SDK_VERSION_PATCH 2 ) 4 | -------------------------------------------------------------------------------- /sdk/src/cv_modules/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 2.8) 2 | project(cv_modules) 3 | 4 | add_subdirectory(max_depth_value_module) 5 | -------------------------------------------------------------------------------- /sdk/src/tools/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 2.8) 2 | project(tools) 3 | 4 | add_subdirectory(projection_tool) 5 | add_subdirectory(capture_tool) 6 | -------------------------------------------------------------------------------- /sdk/src/core/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 2.8) 2 | project(core) 3 | add_subdirectory(image) 4 | add_subdirectory(projection) 5 | add_subdirectory(pipeline) 6 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Files to be ignored by git 2 | 3 | CMakeFiles 4 | CMakeCache* 5 | build 6 | build-debug 7 | build-release 8 | sdk/3rdparty 9 | *.user 10 | Makefile 11 | *.*~ 12 | -------------------------------------------------------------------------------- /sdk/src/cameras/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 2.8) 2 | project(cameras) 3 | 4 | add_subdirectory(compression) 5 | add_subdirectory(record) 6 | add_subdirectory(playback) 7 | -------------------------------------------------------------------------------- /dependencies_versions: -------------------------------------------------------------------------------- 1 | librealsense_version = 1.12.1 2 | zr300_camera_firmware_version = 2.0.71.28 3 | zr300_adapter_board_firmware_version = 1.29.0.0 4 | zr300_motion_module_firmware_version = 1.25.0.0 5 | -------------------------------------------------------------------------------- /sdk/src/utilities/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 2.8) 2 | project(utilities) 3 | 4 | add_subdirectory(logger) 5 | add_subdirectory(viewer) 6 | add_subdirectory(command_line) 7 | add_subdirectory(samples_time_sync) 8 | -------------------------------------------------------------------------------- /sdk/include/rs_record.h: -------------------------------------------------------------------------------- 1 | // License: Apache 2.0. See LICENSE file in root directory. 2 | // Copyright(c) 2016 Intel Corporation. All Rights Reserved. 3 | 4 | #pragma once 5 | 6 | #include "rs/record/record_context.h" 7 | #include "rs/record/record_device.h" 8 | -------------------------------------------------------------------------------- /sdk/include/rs_playback.h: -------------------------------------------------------------------------------- 1 | // License: Apache 2.0. See LICENSE file in root directory. 2 | // Copyright(c) 2016 Intel Corporation. All Rights Reserved. 3 | 4 | #pragma once 5 | 6 | #include "rs/playback/playback_context.h" 7 | #include "rs/playback/playback_device.h" 8 | -------------------------------------------------------------------------------- /sdk/include/rs_sdk.h: -------------------------------------------------------------------------------- 1 | // License: Apache 2.0. See LICENSE file in root directory. 2 | // Copyright(c) 2016 Intel Corporation. All Rights Reserved. 3 | 4 | #pragma once 5 | 6 | #include "rs_core.h" 7 | #include "rs_utils.h" 8 | #include "rs_record.h" 9 | #include "rs_playback.h" 10 | -------------------------------------------------------------------------------- /tests/main.cpp: -------------------------------------------------------------------------------- 1 | // License: Apache 2.0. See LICENSE file in root directory. 2 | // Copyright(c) 2016 Intel Corporation. All Rights Reserved. 3 | 4 | #include "gtest/gtest.h" 5 | 6 | int main(int argc, char **argv) 7 | { 8 | testing::InitGoogleTest(&argc, argv); 9 | return RUN_ALL_TESTS(); 10 | } 11 | -------------------------------------------------------------------------------- /cmake_includes/pkg-config.pc.cmake: -------------------------------------------------------------------------------- 1 | Name: ${PACKAGE_NAME} 2 | Description: ${CPACK_PACKAGE_DESCRIPTION_SUMMARY} 3 | Version: ${SDK_VERSION_MAJOR}.${SDK_VERSION_MINOR}.${SDK_VERSION_PATCH} 4 | prefix=${CMAKE_INSTALL_PREFIX} 5 | includedir=${includedir} 6 | libdir=${libdir} 7 | Libs: ${CPACK_PACKAGE_CONFIG_LIBS} 8 | Cflags: ${CPACK_PACKAGE_CONFIG_CFLAGS} 9 | -------------------------------------------------------------------------------- /samples/src/fps_counter_sample/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 2.8) 2 | project(realsense_fps_counter_sample) 3 | 4 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") 5 | 6 | add_executable(${PROJECT_NAME} main.cpp) 7 | 8 | target_link_libraries(${PROJECT_NAME} realsense) 9 | 10 | install(TARGETS ${PROJECT_NAME} DESTINATION bin) 11 | -------------------------------------------------------------------------------- /tests/logger_tests.cpp: -------------------------------------------------------------------------------- 1 | // License: Apache 2.0. See LICENSE file in root directory. 2 | // Copyright(c) 2016 Intel Corporation. All Rights Reserved. 3 | 4 | #include "gtest/gtest.h" 5 | #include "rs_sdk.h" 6 | 7 | GTEST_TEST(LoggerTests, logger_configured_test) 8 | { 9 | ASSERT_NE(LOGGER_TYPE,rs::utils::logging_service::logger_type::empty_logger) << "Logger .so file is not loaded, or logger configuration failure."; 10 | } 11 | -------------------------------------------------------------------------------- /sdk/src/utilities/logger/logger/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 2.8) 2 | project(realsense_logger) 3 | 4 | set(SOURCE_FILES logger.cpp xlevel.cpp) 5 | 6 | add_library(${PROJECT_NAME} SHARED ${SOURCE_FILES}) 7 | 8 | target_link_libraries(${PROJECT_NAME} log4cxx apr-1 aprutil-1 ) 9 | 10 | set_target_properties(${PROJECT_NAME} PROPERTIES VERSION "${LIBVERSION}" SOVERSION "${LIBSOVERSION}") 11 | 12 | install(TARGETS ${PROJECT_NAME} DESTINATION lib) 13 | 14 | -------------------------------------------------------------------------------- /samples/src/fps_counter_sample/README.md: -------------------------------------------------------------------------------- 1 | # Intel® RealSense™ Linux SDK 2 | ## Fps Counter Sample 3 | --- 4 | ### Description 5 | 6 | 7 | ### Category 8 | RealSense(TM) SDK 9 | 10 | ### Author 11 | Intel(R) Corporation 12 | 13 | ### Hardware Requirements 14 | zr300 15 | 16 | ### Libraries 17 | 18 | 19 | ### Compiler Flags 20 | -std=c++11 21 | 22 | ### Libraries Flags 23 | -lrealsense 24 | 25 | ### Date 26 | 15/08/2016 27 | -------------------------------------------------------------------------------- /sdk/src/utilities/samples_time_sync/samples_time_sync_ds5.cpp: -------------------------------------------------------------------------------- 1 | // License: Apache 2.0. See LICENSE file in root directory. 2 | // Copyright(c) 2016 Intel Corporation. All Rights Reserved. 3 | 4 | #include "samples_time_sync_ds5.h" 5 | 6 | using namespace std; 7 | using namespace rs::core; 8 | using namespace rs::utils; 9 | 10 | bool rs::utils::samples_time_sync_ds5::sync_all(streams_map& streams, motions_map& motions, rs::core::correlated_sample_set& sample_set ) 11 | { 12 | return false; 13 | } 14 | -------------------------------------------------------------------------------- /sdk/include/rs_utils.h: -------------------------------------------------------------------------------- 1 | // License: Apache 2.0. See LICENSE file in root directory. 2 | // Copyright(c) 2016 Intel Corporation. All Rights Reserved. 3 | 4 | #pragma once 5 | 6 | #include "rs/utils/librealsense_conversion_utils.h" 7 | #include "rs/utils/log_utils.h" 8 | #include "rs/utils/samples_time_sync_interface.h" 9 | #include "rs/utils/fps_counter.h" 10 | #include "rs/utils/ref_count_base.h" 11 | #include "rs/utils/release_self_base.h" 12 | #include "rs/utils/self_releasing_array_data_releaser.h" 13 | #include "rs/utils/smart_ptr_helpers.h" 14 | 15 | -------------------------------------------------------------------------------- /sdk/src/utilities/logger/log_utils/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 2.8) 2 | project(realsense_log_utils) 3 | 4 | set(SOURCE_FILES log_utils.cpp 5 | ${ROOT_DIR}/include/rs/utils/log_utils.h) 6 | 7 | add_library(${PROJECT_NAME} SHARED ${SOURCE_FILES}) 8 | 9 | target_link_libraries(${PROJECT_NAME} ${DL}) 10 | 11 | MESSAGE("User home directory is: " $ENV{HOME}) 12 | 13 | set_target_properties(${PROJECT_NAME} PROPERTIES VERSION "${LIBVERSION}" SOVERSION "${LIBSOVERSION}") 14 | 15 | install(TARGETS ${PROJECT_NAME} DESTINATION lib) 16 | -------------------------------------------------------------------------------- /samples/src/projection_sample/README.md: -------------------------------------------------------------------------------- 1 | # Intel® RealSense™ Linux SDK 2 | ## Projection Sample 3 | --- 4 | ### Description 5 | 6 | 7 | ### Category 8 | RealSense(TM) SDK 9 | 10 | ### Author 11 | Intel(R) Corporation 12 | 13 | ### Hardware Requirements 14 | zr300 15 | 16 | ### Libraries 17 | 18 | 19 | ### Compiler Flags 20 | -std=c++11 21 | 22 | ### Libraries Flags 23 | -lrealsense_projection -lrealsense_image -lrealsense -lopencv_imgproc -lopencv_core 24 | 25 | ### Date 26 | 22/08/2016 27 | 28 | -------------------------------------------------------------------------------- /samples/src/projection_sample/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 2.8) 2 | project(realsense_projection_sample) 3 | 4 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") 5 | 6 | add_executable(${PROJECT_NAME} main.cpp) 7 | 8 | target_link_libraries(${PROJECT_NAME} realsense 9 | realsense_image 10 | realsense_projection 11 | opencv_imgproc 12 | opencv_core) 13 | 14 | install(TARGETS ${PROJECT_NAME} DESTINATION bin) 15 | -------------------------------------------------------------------------------- /samples/src/record_sync_sample/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 2.8) 2 | project(realsense_record_sync_sample) 3 | 4 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") 5 | 6 | add_executable(${PROJECT_NAME} main.cpp) 7 | 8 | target_link_libraries(${PROJECT_NAME} realsense_image 9 | realsense_record 10 | realsense pthread 11 | opencv_imgproc 12 | opencv_core) 13 | 14 | 15 | install(TARGETS ${PROJECT_NAME} DESTINATION bin) 16 | -------------------------------------------------------------------------------- /samples/src/playback_sync_sample/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 2.8) 2 | project(realsense_playback_sync_sample) 3 | 4 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") 5 | 6 | add_executable(${PROJECT_NAME} main.cpp) 7 | 8 | target_link_libraries(${PROJECT_NAME} realsense 9 | realsense_image 10 | realsense_playback 11 | opencv_imgproc 12 | opencv_core pthread) 13 | 14 | install(TARGETS ${PROJECT_NAME} DESTINATION bin) 15 | 16 | -------------------------------------------------------------------------------- /samples/src/record_async_sample/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 2.8) 2 | project(realsense_record_async_sample) 3 | 4 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") 5 | 6 | add_executable(${PROJECT_NAME} main.cpp) 7 | 8 | target_link_libraries(${PROJECT_NAME} realsense_image 9 | realsense_record 10 | realsense pthread 11 | opencv_imgproc 12 | opencv_core) 13 | 14 | 15 | install(TARGETS ${PROJECT_NAME} DESTINATION bin) 16 | -------------------------------------------------------------------------------- /samples/src/playback_async_sample/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 2.8) 2 | project(realsense_playback_async_sample) 3 | 4 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") 5 | 6 | add_executable(${PROJECT_NAME} main.cpp) 7 | 8 | target_link_libraries(${PROJECT_NAME} realsense 9 | realsense_image 10 | realsense_playback 11 | opencv_imgproc 12 | opencv_core pthread) 13 | 14 | install(TARGETS ${PROJECT_NAME} DESTINATION bin) 15 | 16 | -------------------------------------------------------------------------------- /sdk/src/utilities/logger/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 2.8) 2 | project(logger) 3 | 4 | include_directories( 5 | include 6 | ${ROOT_DIR}/include/rs/core 7 | ) 8 | 9 | set(LOGGER_DIR ${CMAKE_CURRENT_SOURCE_DIR}) 10 | 11 | add_subdirectory(log_utils) 12 | 13 | 14 | # Logging will be enabled only if log4cxx is installed on your system 15 | 16 | if(BUILD_LOGGER) 17 | MESSAGE("Building logger. Note: Logging will be enabled only if log4cxx is installed on your system") 18 | add_subdirectory(logger) 19 | else() 20 | MESSAGE("Building without logger") 21 | endif(BUILD_LOGGER) 22 | 23 | 24 | -------------------------------------------------------------------------------- /sdk/include/rs_sdk_version.h: -------------------------------------------------------------------------------- 1 | // License: Apache 2.0. See LICENSE file in root directory. 2 | // Copyright(c) 2016 Intel Corporation. All Rights Reserved. 3 | 4 | #pragma once 5 | 6 | #define SDK_VER_MAJOR 0 7 | #define SDK_VER_MINOR 7 8 | #define SDK_VER_PATCH 2 9 | #define SDK_VERSION_STRING static volatile char version_id[] = "VERSION: 0.7.2"; 10 | #define SDK_BUILD_STRING static volatile char build[]= "BUILD DATE: " __DATE__ " " __TIME__; 11 | #define SDK_COPYRIGHT_STRING static volatile char copyright[]="COPYRIGHT: Intel Confidential Copyright 2016"; 12 | 13 | SDK_VERSION_STRING 14 | SDK_BUILD_STRING 15 | SDK_COPYRIGHT_STRING 16 | -------------------------------------------------------------------------------- /samples/src/record_sync_sample/README.md: -------------------------------------------------------------------------------- 1 | # Intel® RealSense™ Linux SDK 2 | ## Record Sample 3 | --- 4 | ### Description 5 | This sample demonstrates a synchronous usage of the record device. 6 | 7 | ### Category 8 | RealSense(TM) SDK 9 | 10 | ### Author 11 | Intel(R) Corporation 12 | 13 | ### Hardware Requirements 14 | zr300 15 | 16 | ### Libraries 17 | 18 | 19 | ### Compiler Flags 20 | -std=c++11 21 | 22 | ### Libraries Flags 23 | -lrealsense_record -lrealsense_image -lrealsense_log_utils -lrealsense -lpthread -lopencv_imgproc -lopencv_core 24 | 25 | ### Date 26 | 07/08/2016 27 | 28 | -------------------------------------------------------------------------------- /samples/src/samples_time_sync_sample/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 2.8) 2 | project(realsense_samples_time_sync_sample) 3 | 4 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") 5 | 6 | add_executable(${PROJECT_NAME} main.cpp) 7 | 8 | target_link_libraries(${PROJECT_NAME} realsense_image 9 | realsense_lrs_image 10 | realsense_samples_time_sync 11 | realsense 12 | opencv_imgproc 13 | opencv_core) 14 | 15 | install(TARGETS ${PROJECT_NAME} DESTINATION bin) 16 | -------------------------------------------------------------------------------- /samples/src/record_async_sample/README.md: -------------------------------------------------------------------------------- 1 | # Intel® RealSense™ Linux SDK 2 | ## Record Sample 3 | --- 4 | ### Description 5 | This sample demonstrates an synchronous usage of the record device. 6 | 7 | ### Category 8 | RealSense(TM) SDK 9 | 10 | ### Author 11 | Intel(R) Corporation 12 | 13 | ### Hardware Requirements 14 | zr300 15 | 16 | ### Libraries 17 | 18 | 19 | ### Compiler Flags 20 | -std=c++11 21 | 22 | ### Libraries Flags 23 | -lrealsense_record -lrealsense_image -lrealsense_log_utils -lrealsense -lpthread -lopencv_imgproc -lopencv_core 24 | 25 | ### Date 26 | 07/08/2016 27 | 28 | -------------------------------------------------------------------------------- /sdk/src/cv_modules/max_depth_value_module/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 2.8.9) 2 | project(realsense_max_depth_value_module) 3 | 4 | set(SOURCE_FILES max_depth_value_module_impl.h 5 | max_depth_value_module_impl.cpp 6 | max_depth_value_module.cpp) 7 | 8 | add_library(${PROJECT_NAME} SHARED ${SOURCE_FILES}) 9 | 10 | target_link_libraries(${PROJECT_NAME} realsense_log_utils ${SHLWAPI}) 11 | 12 | add_dependencies(${PROJECT_NAME} realsense_log_utils) 13 | 14 | set_target_properties(${PROJECT_NAME} PROPERTIES VERSION "${LIBVERSION}" SOVERSION "${LIBSOVERSION}") 15 | 16 | install(TARGETS ${PROJECT_NAME} DESTINATION lib) 17 | -------------------------------------------------------------------------------- /samples/src/playback_async_sample/README.md: -------------------------------------------------------------------------------- 1 | # Intel® RealSense™ Linux SDK 2 | ## Playback Sample 3 | --- 4 | ### Description 5 | This sample demonstrates an asynchronous usage of the playback device. 6 | 7 | ### Category 8 | RealSense(TM) SDK 9 | 10 | ### Author 11 | Intel(R) Corporation 12 | 13 | ### Hardware Requirements 14 | zr300 15 | 16 | ### Libraries 17 | 18 | 19 | ### Compiler Flags 20 | -std=c++11 21 | 22 | ### Libraries Flags 23 | -lrealsense_playback -lrealsense_image -lrealsense_log_utils -pthread -lrealsense -lopencv_imgproc -lopencv_core 24 | 25 | ### Date 26 | 07/08/2016 27 | 28 | -------------------------------------------------------------------------------- /samples/src/playback_sync_sample/README.md: -------------------------------------------------------------------------------- 1 | # Intel® RealSense™ Linux SDK 2 | ## Playback Sample 3 | --- 4 | ### Description 5 | This sample demonstrates a synchronous usage of the playback device. 6 | 7 | ### Category 8 | RealSense(TM) SDK 9 | 10 | ### Author 11 | Intel(R) Corporation 12 | 13 | ### Hardware Requirements 14 | zr300 15 | 16 | ### Libraries 17 | 18 | 19 | ### Compiler Flags 20 | -std=c++11 21 | 22 | ### Libraries Flags 23 | -lrealsense_playback -lrealsense_image -lrealsense_log_utils -pthread -lrealsense -lopencv_imgproc -lopencv_core 24 | 25 | ### Date 26 | 07/08/2016 27 | 28 | -------------------------------------------------------------------------------- /sdk/include/rs_core.h: -------------------------------------------------------------------------------- 1 | // License: Apache 2.0. See LICENSE file in root directory. 2 | // Copyright(c) 2016 Intel Corporation. All Rights Reserved. 3 | 4 | #pragma once 5 | 6 | #include "rs/core/release_interface.h" 7 | #include "rs/core/ref_count_interface.h" 8 | #include "rs/core/context_interface.h" 9 | #include "rs/core/context.h" 10 | #include "rs/core/correlated_sample_set.h" 11 | #include "rs/core/image_interface.h" 12 | #include "rs/core/motion_sample.h" 13 | #include "rs/core/metadata_interface.h" 14 | #include "rs/core/status.h" 15 | #include "rs/core/types.h" 16 | #include "rs/core/video_module_interface.h" 17 | #include "rs/core/projection_interface.h" 18 | #include "rs/core/pipeline_async.h" 19 | -------------------------------------------------------------------------------- /sdk/src/cameras/compression/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 2.8) 2 | 3 | project(realsense_compression) 4 | 5 | set(SOURCE_FILES 6 | codec_interface.h 7 | lz4_codec.h 8 | lz4_codec.cpp 9 | encoder.h 10 | decoder.h 11 | encoder.cpp 12 | decoder.cpp 13 | ) 14 | 15 | include_directories( 16 | ${ROOT_DIR}/src/cameras 17 | ) 18 | 19 | add_library(${PROJECT_NAME} ${SDK_LIB_TYPE} ${SOURCE_FILES}) 20 | 21 | set_target_properties(${PROJECT_NAME} PROPERTIES VERSION "${LIBVERSION}" SOVERSION "${LIBSOVERSION}") 22 | 23 | target_link_libraries(${PROJECT_NAME} 24 | ${LZ4} 25 | realsense_log_utils 26 | ) 27 | 28 | install(TARGETS ${PROJECT_NAME} DESTINATION lib) 29 | -------------------------------------------------------------------------------- /sdk/src/utilities/viewer/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 2.8) 2 | project(realsense_viewer) 3 | 4 | include_directories( 5 | ${ROOT_DIR} 6 | ${ROOT_DIR}/include 7 | ${ROOT_DIR}/src/utilities 8 | ${ROOT_DIR}/src/include 9 | 10 | ) 11 | 12 | set(SOURCE_FILES 13 | # viewer.h 14 | viewer.cpp 15 | ) 16 | 17 | add_library(${PROJECT_NAME} ${SDK_LIB_TYPE} ${SOURCE_FILES}) 18 | 19 | target_link_libraries(${PROJECT_NAME} 20 | realsense_image 21 | ${PTHREAD} 22 | ${GLFW_LIBS} 23 | ${OPENGL_LIBS} 24 | ) 25 | 26 | set_target_properties(${PROJECT_NAME} PROPERTIES VERSION "${LIBVERSION}" SOVERSION "${LIBSOVERSION}") 27 | 28 | install(TARGETS ${PROJECT_NAME} DESTINATION lib) 29 | -------------------------------------------------------------------------------- /sdk/src/utilities/command_line/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 2.8) 2 | project(realsense_cl_util) 3 | 4 | include_directories( 5 | ${ROOT_DIR} 6 | ${ROOT_DIR}/include 7 | ${ROOT_DIR}/src/utilities 8 | ${ROOT_DIR}/src/include 9 | ) 10 | 11 | set(SOURCE_FILES 12 | # cmd_base.h 13 | cmd_base.cpp 14 | # basic_cmd_util.h 15 | basic_cmd_util.cpp 16 | ) 17 | 18 | add_library(${PROJECT_NAME} ${SDK_LIB_TYPE} ${SOURCE_FILES}) 19 | 20 | set_target_properties(${PROJECT_NAME} PROPERTIES VERSION "${LIBVERSION}" SOVERSION "${LIBSOVERSION}") 21 | 22 | target_link_libraries(${PROJECT_NAME} 23 | realsense 24 | realsense_playback 25 | ) 26 | 27 | install(TARGETS ${PROJECT_NAME} DESTINATION lib) 28 | -------------------------------------------------------------------------------- /samples/src/video_module_sync_sample/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 2.8) 2 | project(realsense_video_module_sync_sample) 3 | 4 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") 5 | 6 | add_executable(${PROJECT_NAME} main.cpp) 7 | 8 | target_link_libraries(${PROJECT_NAME} realsense_max_depth_value_module 9 | realsense_image 10 | realsense_playback 11 | realsense_projection 12 | realsense 13 | pthread 14 | opencv_imgproc opencv_core) 15 | 16 | install(TARGETS ${PROJECT_NAME} DESTINATION bin) 17 | -------------------------------------------------------------------------------- /sdk/src/tools/capture_tool/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 2.8.9) 2 | project(rs_capture_tool) 3 | 4 | include_directories( 5 | ${ROOT_DIR} 6 | ${ROOT_DIR}/include 7 | ${ROOT_DIR}/src/utilities 8 | ${ROOT_DIR}/src/include 9 | ) 10 | 11 | add_executable(${PROJECT_NAME} 12 | capture_tool.cpp 13 | ) 14 | 15 | target_link_libraries(${PROJECT_NAME} 16 | realsense 17 | realsense_lrs_image 18 | realsense_record 19 | realsense_playback 20 | realsense_viewer 21 | realsense_cl_util 22 | ${OPENGL_LIBS} 23 | ${GLFW_LIBS} 24 | ) 25 | 26 | add_dependencies(${PROJECT_NAME} 27 | realsense_record 28 | realsense_playback 29 | ) 30 | 31 | install(TARGETS ${PROJECT_NAME} DESTINATION bin) 32 | -------------------------------------------------------------------------------- /samples/src/video_module_async_sample/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 2.8) 2 | project(realsense_video_module_async_sample) 3 | 4 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") 5 | 6 | add_executable(${PROJECT_NAME} main.cpp) 7 | 8 | target_link_libraries(${PROJECT_NAME} realsense_max_depth_value_module 9 | realsense_image 10 | realsense_lrs_image 11 | realsense_playback 12 | realsense_projection 13 | realsense 14 | pthread 15 | opencv_imgproc opencv_core) 16 | 17 | install(TARGETS ${PROJECT_NAME} DESTINATION bin) 18 | -------------------------------------------------------------------------------- /sdk/src/cameras/record/include/record_device_interface.h: -------------------------------------------------------------------------------- 1 | // License: Apache 2.0. See LICENSE file in root directory. 2 | // Copyright(c) 2016 Intel Corporation. All Rights Reserved. 3 | 4 | #pragma once 5 | #include 6 | #include 7 | #include "rs/record/record_device.h" 8 | 9 | namespace rs 10 | { 11 | namespace record 12 | { 13 | class device_interface : public rs_device 14 | { 15 | public: 16 | virtual ~device_interface() {} 17 | virtual void pause_record() = 0; 18 | virtual void resume_record() = 0; 19 | virtual bool set_compression(rs_stream stream, record::compression_level compression_level) = 0; 20 | virtual record::compression_level get_compression(rs_stream stream) = 0; 21 | }; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /cmake_includes/check_os.cmake: -------------------------------------------------------------------------------- 1 | # This file might be processed several times in certain builds. 2 | # It is included several times since different projects need to compile as stand-alones and they all need to have some 3 | # or all of the definitions set (or included) in this file 4 | 5 | get_filename_component(CMAKE_INCLUDES_DIR ${CMAKE_CURRENT_LIST_FILE} DIRECTORY) 6 | 7 | ## Define CMake macros to identify the current OS easily throughout the CMakeLists files 8 | ## And include cmake according to current operating system 9 | 10 | if( ${CMAKE_SYSTEM_NAME} STREQUAL "Linux") 11 | set(IS_CURRENT_SYSTEM_LINUX_OS ON) 12 | include(${CMAKE_INCLUDES_DIR}/config_linux.cmake) 13 | endif() 14 | 15 | if( ${CMAKE_SYSTEM_NAME} STREQUAL "Windows") 16 | set(IS_CURRENT_SYSTEM_WINDOWS_OS ON) 17 | include(${CMAKE_INCLUDES_DIR}/config_windows.cmake) 18 | endif() 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /sdk/src/core/pipeline/device_streaming_guard.h: -------------------------------------------------------------------------------- 1 | // License: Apache 2.0. See LICENSE file in root directory. 2 | // Copyright(c) 2016 Intel Corporation. All Rights Reserved. 3 | 4 | #pragma once 5 | #include 6 | 7 | namespace rs 8 | { 9 | namespace core 10 | { 11 | class device_streaming_guard 12 | { 13 | public: 14 | device_streaming_guard(rs::device * device, 15 | rs::source enabled_sources); 16 | 17 | device_streaming_guard(const device_streaming_guard&) = delete; 18 | device_streaming_guard & operator=(const device_streaming_guard&) = delete; 19 | 20 | virtual ~device_streaming_guard(); 21 | private: 22 | rs::device * m_device; 23 | rs::source m_enabled_sources; 24 | }; 25 | } 26 | } 27 | 28 | -------------------------------------------------------------------------------- /cmake_includes/pkg_config: -------------------------------------------------------------------------------- 1 | include(${SDK_DIR}/CMakeVersion) 2 | set(PACKAGE_NAME "realsense-sdk") 3 | 4 | set(prefix "${CMAKE_INSTALL_PREFIX}") 5 | set(libdir "\${prefix}/lib") 6 | set(includedir "\${prefix}/include") 7 | 8 | execute_process(COMMAND bash "-c" "cat `grep -rw --include=\"CMakeLists.txt\" \"add_library\" .. | cut -d\":\" -f1` | grep \"project(\" | cut -d\"(\" -f2 | cut -d\")\" -f1 | sed -e 's/^/-l/'" 9 | OUTPUT_VARIABLE SHARED_LIBS) 10 | 11 | #pckg-config settings 12 | set(CPACK_PACKAGE_CONFIG_LIBS "-L\${libdir} ${SHARED_LIBS}") 13 | set(CPACK_PACKAGE_CONFIG_CFLAGS "-I\${includedir}") 14 | 15 | CONFIGURE_FILE( 16 | "${CMAKE_CURRENT_SOURCE_DIR}/cmake_includes/pkg-config.pc.cmake" 17 | "${CMAKE_CURRENT_BINARY_DIR}/${PACKAGE_NAME}.pc" 18 | ) 19 | 20 | install( 21 | FILES ${CMAKE_CURRENT_BINARY_DIR}/${PACKAGE_NAME}.pc 22 | DESTINATION lib/pkgconfig 23 | ) -------------------------------------------------------------------------------- /cmake_includes/config_linux.cmake: -------------------------------------------------------------------------------- 1 | set(COMPILE_DEFINITIONS -Wall -Wno-write-strings -Wno-comment -Wno-unknown-pragmas -Wno-unused-function -Wno-unused-variable -Wno-reorder -Werror) 2 | set(PTHREAD pthread) 3 | set(DL dl) 4 | set(GLFW_LIBS glfw) 5 | set(OPENGL_LIBS GL) 6 | set(GTEST_LIBS gtest gtest_main) 7 | set(LZ4 lz4) 8 | 9 | if(CMAKE_BUILD_TYPE STREQUAL "Release") 10 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O2 ") 11 | endif() 12 | 13 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wformat -Wformat-security") 14 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wconversion") 15 | set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -z noexecstack") 16 | set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -z relro -z now") 17 | set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -pie") 18 | 19 | set(SAMPLES_TIME_SYNC_TESTS samples_time_sync_tests.cpp) 20 | set(FIND_DATA_PATH_TEST find_data_path_test.cpp) -------------------------------------------------------------------------------- /samples/src/pipeline_async_sample/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 2.8) 2 | project(realsense_pipeline_async_sample) 3 | 4 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") 5 | 6 | add_executable(${PROJECT_NAME} main.cpp) 7 | 8 | target_link_libraries(${PROJECT_NAME} realsense_pipeline 9 | realsense_max_depth_value_module 10 | realsense_image 11 | realsense_lrs_image 12 | realsense_playback 13 | realsense_projection 14 | realsense_samples_time_sync 15 | realsense 16 | pthread 17 | opencv_imgproc opencv_core) 18 | 19 | install(TARGETS ${PROJECT_NAME} DESTINATION bin) 20 | -------------------------------------------------------------------------------- /sdk/src/cameras/playback/include/disk_read.h: -------------------------------------------------------------------------------- 1 | // License: Apache 2.0. See LICENSE file in root directory. 2 | // Copyright(c) 2016 Intel Corporation. All Rights Reserved. 3 | 4 | #pragma once 5 | #include "disk_read_base.h" 6 | 7 | namespace rs 8 | { 9 | namespace playback 10 | { 11 | class disk_read : public disk_read_base 12 | { 13 | public: 14 | disk_read(const char *file_name) : disk_read_base(file_name) {} 15 | virtual ~disk_read(void); 16 | protected: 17 | virtual rs::core::status read_headers() override; 18 | virtual void index_next_samples(uint32_t number_of_samples) override; 19 | virtual int32_t size_of_pitches(void) override; 20 | virtual uint32_t read_frame_metadata(const std::shared_ptr & frame, unsigned long num_bytes_to_read) override; 21 | }; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /sdk/src/core/image/lrs_image/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 2.8.9) 2 | 3 | project(realsense_lrs_image) 4 | 5 | #------------------------------------------------------------------------------------ 6 | #Include 7 | include_directories( 8 | .. 9 | ${ROOT_DIR}/include 10 | ) 11 | #------------------------------------------------------------------------------------ 12 | #Source Files 13 | set(SOURCE_FILES 14 | lrs_image.cpp 15 | lrs_image.h 16 | ../image_base.h 17 | ../metadata.h 18 | ) 19 | 20 | add_library(${PROJECT_NAME} ${SDK_LIB_TYPE} 21 | ${SOURCE_FILES} 22 | ) 23 | 24 | target_link_libraries(${PROJECT_NAME} 25 | realsense 26 | realsense_image 27 | realsense_log_utils 28 | opencv_imgproc${OPENCV_VER} opencv_core${OPENCV_VER} 29 | ) 30 | 31 | set_target_properties(${PROJECT_NAME} PROPERTIES VERSION "${LIBVERSION}" SOVERSION "${LIBSOVERSION}") 32 | 33 | install(TARGETS ${PROJECT_NAME} DESTINATION lib) 34 | -------------------------------------------------------------------------------- /sdk/src/core/image/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 2.8.9) 2 | 3 | project(realsense_image) 4 | add_subdirectory(lrs_image) 5 | 6 | include_directories( 7 | ${ROOT_DIR}/include 8 | ) 9 | 10 | set(SOURCE_FILES 11 | image_base.cpp 12 | image_base.h 13 | custom_image.cpp 14 | custom_image.h 15 | image_conversion_util.cpp 16 | image_conversion_util.h 17 | metadata.cpp 18 | metadata.h 19 | ${ROOT_DIR}/include/rs/utils/ref_count_base.h 20 | ${ROOT_DIR}/include/rs/core/image_interface.h 21 | ${ROOT_DIR}/include/rs/core/metadata_interface.h 22 | ) 23 | 24 | add_library(${PROJECT_NAME} ${SDK_LIB_TYPE} 25 | ${SOURCE_FILES} 26 | ) 27 | 28 | target_link_libraries(${PROJECT_NAME} 29 | opencv_imgproc${OPENCV_VER} opencv_core${OPENCV_VER} 30 | ) 31 | 32 | set_target_properties(${PROJECT_NAME} PROPERTIES VERSION "${LIBVERSION}" SOVERSION "${LIBSOVERSION}") 33 | 34 | install(TARGETS ${PROJECT_NAME} DESTINATION lib) 35 | -------------------------------------------------------------------------------- /samples/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 2.8) 2 | project(samples) 3 | 4 | if(CMAKE_BUILD_TYPE STREQUAL "Debug") 5 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -O0 ") 6 | endif() 7 | 8 | add_definitions(${COMPILE_DEFINITIONS}) 9 | 10 | #--------------Add security options -------------------- 11 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_FORTIFY_SOURCE=2 ") #TODO: Check what it is 12 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fstack-protector-strong") 13 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIE -fPIC") 14 | 15 | add_subdirectory(src/projection_sample) 16 | add_subdirectory(src/record_sync_sample) 17 | add_subdirectory(src/playback_sync_sample) 18 | add_subdirectory(src/record_async_sample) 19 | add_subdirectory(src/playback_async_sample) 20 | add_subdirectory(src/samples_time_sync_sample) 21 | add_subdirectory(src/video_module_async_sample) 22 | add_subdirectory(src/video_module_sync_sample) 23 | add_subdirectory(src/fps_counter_sample) 24 | add_subdirectory(src/pipeline_async_sample) 25 | -------------------------------------------------------------------------------- /samples/src/samples_time_sync_sample/README.md: -------------------------------------------------------------------------------- 1 | # Intel® RealSense™ Linux SDK 2 | ## Time Sync Sample 3 | --- 4 | ### Description 5 | This sample demonstrates an application usage of a samples time sync utility. The samples time sync utility syncronizes the frames from different streams. The streams need to be registered with the samples time sync module, 6 | prior to first usage. For zr300 cmarea, the sync between all color/depth/ir streams is calculates based on equity of timestamps. For fisheye stream and IMU, best matched is chosen. 7 | 8 | 9 | 10 | ### Category 11 | RealSense(TM) SDK 12 | 13 | ### Author 14 | Intel(R) Corporation 15 | 16 | ### Hardware Requirements 17 | zr300 18 | 19 | ### Libraries 20 | 21 | 22 | ### Compiler Flags 23 | -std=c++11 24 | 25 | ### Libraries Flags 26 | -lrealsense_samples_time_sync -lrealsense_image -lrealsense -lrealsense_log_utils -lopencv_imgproc -lopencv_core 27 | 28 | ### Date 29 | 22/08/2016 30 | 31 | -------------------------------------------------------------------------------- /sdk/include/rs/core/motion_sample.h: -------------------------------------------------------------------------------- 1 | // License: Apache 2.0. See LICENSE file in root directory. 2 | // Copyright(c) 2016 Intel Corporation. All Rights Reserved. 3 | 4 | /** 5 | * \file motion_sample.h 6 | * @brief Describes the \c rs::core::motion_sample struct. 7 | */ 8 | 9 | #pragma once 10 | 11 | #include "types.h" 12 | 13 | namespace rs 14 | { 15 | namespace core 16 | { 17 | /** 18 | * @brief Represents a sample of inertial sensor units. 19 | */ 20 | struct motion_sample 21 | { 22 | motion_type type; /**< Type of the IMU sample */ 23 | double timestamp; /**< Timestamp of the IMU sample in millisecond units. 24 | If the value is zero, the sample should be considered as invalid.*/ 25 | uint64_t frame_number; /**< Sample frame number */ 26 | float data[3]; /**< Three-dimensional sample data representing x, y, z or yaw, pitch, roll */ 27 | }; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /samples/src/video_module_sync_sample/README.md: -------------------------------------------------------------------------------- 1 | # Intel® RealSense™ Linux SDK 2 | ## Video Module Synchronized Sample 3 | --- 4 | ### Description 5 | This sample demonstrates an application usage of a computer vision module, which implements a synchronous samples processing. The video module implements the video module interface, which is a common way for the application or SDK to interact with the module. It also implements a module specific interface, in this example - the module calculates the maximal depth value in the image. 6 | 7 | ### Category 8 | RealSense(TM) SDK 9 | 10 | ### Author 11 | Intel(R) Corporation 12 | 13 | ### Hardware Requirements 14 | zr300 15 | 16 | ### Libraries 17 | 18 | 19 | ### Compiler Flags 20 | -std=c++11 21 | 22 | ### Libraries Flags 23 | -lrealsense_max_depth_value_module -lrealsense_image -lrealsense_playback -lrealsense_projection -lrealsense_log_utils -lrealsense -lpthread -lopencv_imgproc -lopencv_core 24 | 25 | ### Date 26 | 23/08/2016 27 | 28 | -------------------------------------------------------------------------------- /samples/src/video_module_async_sample/README.md: -------------------------------------------------------------------------------- 1 | # Intel® RealSense™ Linux SDK 2 | ## Video Module Asynchronized Sample 3 | --- 4 | ### Description 5 | This sample demonstrates an application usage of a computer vision module, which implements asynchronous samples processing. The video module implements the video module interface, which is a common way for the application or SDK to interact with the module. It also implements a module specific interface, in this example - the module calculates the maximal depth value in the image. 6 | 7 | ### Category 8 | RealSense(TM) SDK 9 | 10 | ### Author 11 | Intel(R) Corporation 12 | 13 | ### Hardware Requirements 14 | zr300 15 | 16 | ### Libraries 17 | 18 | 19 | ### Compiler Flags 20 | -std=c++11 21 | 22 | ### Libraries Flags 23 | -lrealsense -lrealsense_max_depth_value_module -lrealsense_image -lrealsense_playback -lrealsense_log_utils -lrealsense_projection -lpthread -lopencv_imgproc -lopencv_core 24 | 25 | ### Date 26 | 22/08/2016 27 | 28 | -------------------------------------------------------------------------------- /sdk/src/cameras/playback/include/linux/v1/disk_read.h: -------------------------------------------------------------------------------- 1 | // License: Apache 2.0. See LICENSE file in root directory. 2 | // Copyright(c) 2016 Intel Corporation. All Rights Reserved. 3 | 4 | #pragma once 5 | #include "disk_read_base.h" 6 | 7 | namespace rs 8 | { 9 | namespace playback 10 | { 11 | namespace linux 12 | { 13 | namespace v1 14 | { 15 | class disk_read : public disk_read_base 16 | { 17 | public: 18 | disk_read(const char *file_name) : disk_read_base(file_name) {} 19 | virtual ~disk_read(void); 20 | protected: 21 | virtual rs::core::status read_headers() override; 22 | virtual void index_next_samples(uint32_t number_of_samples) override; 23 | virtual int32_t size_of_pitches(void) override; 24 | virtual uint32_t read_frame_metadata(const std::shared_ptr& frame, unsigned long num_bytes_to_read) override; 25 | }; 26 | } 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /sdk/src/tools/projection_tool/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 2.8.9) 2 | project(rs_projection_tool) 3 | 4 | add_definitions(${COMPILE_DEFINITIONS}) 5 | 6 | include_directories( 7 | include 8 | ${ROOT_DIR} 9 | ${ROOT_DIR}/include 10 | ${ROOT_DIR}/src/include 11 | ${ROOT_DIR}/include/rs/core 12 | ${ROOT_DIR}/src/cameras/playback/include 13 | ${ROOT_DIR}/src/utilities 14 | ${OpenCV_INCLUDE_DIRS} 15 | ) 16 | 17 | add_executable(${PROJECT_NAME} 18 | projection_cmd_util.h 19 | projection_viewer.cpp 20 | projection_tool.cpp 21 | ) 22 | 23 | target_link_libraries(${PROJECT_NAME} 24 | realsense 25 | realsense_lrs_image 26 | realsense_playback 27 | realsense_projection 28 | realsense_cl_util 29 | realsense_samples_time_sync 30 | ${PTHREAD} 31 | ${GLFW_LIBS} 32 | ${OPENGL_LIBS} 33 | ) 34 | 35 | add_dependencies(${PROJECT_NAME} 36 | realsense_image 37 | realsense_playback 38 | realsense_projection 39 | realsense_viewer 40 | realsense_cl_util 41 | realsense_samples_time_sync 42 | ) 43 | 44 | install(TARGETS ${PROJECT_NAME} DESTINATION bin) 45 | -------------------------------------------------------------------------------- /sdk/include/rs/core/release_interface.h: -------------------------------------------------------------------------------- 1 | // License: Apache 2.0. See LICENSE file in root directory. 2 | // Copyright(c) 2016 Intel Corporation. All Rights Reserved. 3 | 4 | /** 5 | * \file release_interface.h 6 | * @brief Describes the \c rs::core::release_interface class. 7 | */ 8 | 9 | 10 | #pragma once 11 | 12 | namespace rs 13 | { 14 | namespace core 15 | { 16 | /** 17 | * 18 | * @brief Provides an abstract way to release the inheriting object memory. 19 | * 20 | * An inheriting class should be destructed through a release function call instead of directly deleting it. 21 | */ 22 | class release_interface 23 | { 24 | public: 25 | /** 26 | * @brief Releases the object according to its internal logic. 27 | * 28 | * @return int Current object reference count if the object is reference counted. 29 | */ 30 | virtual int release() const = 0; 31 | protected: 32 | //force deletion using the release function 33 | virtual ~release_interface() {} 34 | }; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /sdk/src/core/image/image_conversion_util.h: -------------------------------------------------------------------------------- 1 | // License: Apache 2.0. See LICENSE file in root directory. 2 | // Copyright(c) 2016 Intel Corporation. All Rights Reserved. 3 | 4 | #pragma once 5 | #include "rs/core/image_interface.h" 6 | #include "rs/core/types.h" 7 | #include "rs/core/status.h" 8 | 9 | namespace rs 10 | { 11 | namespace core 12 | { 13 | class image_conversion_util 14 | { 15 | image_conversion_util() = delete; 16 | image_conversion_util(const image_conversion_util &) = delete; 17 | image_conversion_util & operator = (const image_conversion_util &) = delete; 18 | ~image_conversion_util() = delete; 19 | public: 20 | static status convert(const image_info &src_info, const uint8_t *src_data, const image_info &dst_info, uint8_t *dst_data); 21 | static status is_conversion_valid(const image_info &src_info, const image_info &dst_info); 22 | private: 23 | static int rs_format_to_cv_pixel_type(rs::core::pixel_format format); 24 | static int get_cv_convert_enum(rs::core::pixel_format from, rs::core::pixel_format to); 25 | }; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /sdk/src/core/pipeline/sample_set_releaser.h: -------------------------------------------------------------------------------- 1 | // License: Apache 2.0. See LICENSE file in root directory. 2 | // Copyright(c) 2016 Intel Corporation. All Rights Reserved. 3 | 4 | #pragma once 5 | #include "rs/core/correlated_sample_set.h" 6 | 7 | namespace rs 8 | { 9 | namespace core 10 | { 11 | /** 12 | * @brief The sample_set_releaser struct 13 | * a releaser to be used with heap allocated correlated_sample_set 14 | */ 15 | struct sample_set_releaser 16 | { 17 | void operator()(correlated_sample_set * sample_set_ptr) const 18 | { 19 | if (sample_set_ptr) 20 | { 21 | for(int i = 0; i < static_cast(stream_type::max); i++) 22 | { 23 | if(sample_set_ptr->images[i]) 24 | { 25 | sample_set_ptr->images[i]->release(); 26 | sample_set_ptr->images[i] = nullptr; 27 | } 28 | } 29 | delete sample_set_ptr; 30 | } 31 | } 32 | }; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /sdk/src/utilities/logger/logger/package_logger_configure.json: -------------------------------------------------------------------------------- 1 | { 2 | "PackageName": "librealsense-sdk-logger", 3 | "Maintainer": "Intel Realsense", 4 | "MaintainerEmail": "realsense@intel.com", 5 | "UseCmake": true, 6 | "BuildDepends": [{"PackageName": "debhelper", "PackageVersion": "(>=9)"} , 7 | {"PackageName": "cmake", "PackageVersion": ""}, 8 | {"PackageName": "libopencv-dev", "PackageVersion": "(>= 3.1.0)"}, 9 | {"PackageName": "librealsense-dev", "PackageVersion": ""}, 10 | {"PackageName": "libglfw3-dev", "PackageVersion": ""}, 11 | {"PackageName": "liblz4-dev", "PackageVersion": ""}, 12 | {"PackageName": "liblog4cxx-dev", "PackageVersion": ""}], 13 | "RuntimePackage": { 14 | "Depends": [], 15 | "Installs": [{"Source": "usr/lib/librealsense_logger.so.*", "Destination": "usr/lib/"}, 16 | {"Source": "sdk/src/utilities/logger/rslog.properties", "Destination": "usr/share/librealsense"}], 17 | "Description": "Intel(R) RealSense(TM) SDK Logger library" 18 | }, 19 | "DevelopmentPackage": { 20 | "Depends": [], 21 | "Installs": [{"Source": "usr/lib/librealsense_logger.so", "Destination": "usr/lib/"}], 22 | "Description": "Intel(R) RealSense(TM) SDK Logger development files" 23 | } 24 | } 25 | 26 | -------------------------------------------------------------------------------- /sdk/src/cameras/compression/codec_interface.h: -------------------------------------------------------------------------------- 1 | // License: Apache 2.0. See LICENSE file in root directory. 2 | // Copyright(c) 2016 Intel Corporation. All Rights Reserved. 3 | 4 | #pragma once 5 | #include 6 | #include "rs/core/status.h" 7 | #include "include/file_types.h" 8 | 9 | #ifdef WIN32 10 | #ifdef realsense_compression_EXPORTS 11 | #define DLL_EXPORT __declspec(dllexport) 12 | #else 13 | #define DLL_EXPORT __declspec(dllimport) 14 | #endif /* realsense_compression_EXPORTS */ 15 | #else /* defined (WIN32) */ 16 | #define DLL_EXPORT 17 | #endif 18 | 19 | namespace rs 20 | { 21 | namespace core 22 | { 23 | namespace compression 24 | { 25 | class DLL_EXPORT codec_interface 26 | { 27 | public: 28 | codec_interface() {} 29 | virtual ~codec_interface() {} 30 | 31 | virtual file_types::compression_type get_compression_type() = 0; 32 | virtual status encode(file_types::frame_info &info, const uint8_t * input, uint8_t * output, uint32_t &output_size) = 0; 33 | virtual std::shared_ptr decode(std::shared_ptr frame, uint8_t * input, uint32_t input_size) = 0; 34 | }; 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /sdk/src/cameras/record/record_context.cpp: -------------------------------------------------------------------------------- 1 | // License: Apache 2.0. See LICENSE file in root directory. 2 | // Copyright(c) 2016 Intel Corporation. All Rights Reserved. 3 | 4 | #include "rs/record/record_context.h" 5 | #include "include/record_device_impl.h" 6 | 7 | namespace rs 8 | { 9 | namespace record 10 | { 11 | context::context(const char *file_path) 12 | { 13 | m_devices = new rs_device*[get_device_count()]; 14 | for(auto i = 0; i < get_device_count(); i++) 15 | { 16 | m_devices[i] = new rs_device_ex(file_path, (rs_device*)(m_context.get_device(i)));//revert casting to cpp wrapper done by librealsense 17 | } 18 | } 19 | 20 | context::~context() 21 | { 22 | for(auto i = 0; i < get_device_count(); i++) 23 | { 24 | if(m_devices[i]) 25 | delete m_devices[i]; 26 | } 27 | delete[] m_devices; 28 | } 29 | 30 | rs::device * context::get_device(int index) 31 | { 32 | return (rs::device*)get_record_device(index); 33 | } 34 | 35 | device * context::get_record_device(int index) 36 | { 37 | return (device*)m_devices[index]; 38 | } 39 | } 40 | } 41 | 42 | -------------------------------------------------------------------------------- /sdk/src/core/pipeline/device_streaming_guard.cpp: -------------------------------------------------------------------------------- 1 | // License: Apache 2.0. See LICENSE file in root directory. 2 | // Copyright(c) 2016 Intel Corporation. All Rights Reserved. 3 | 4 | #include "rs/utils/log_utils.h" 5 | #include "device_streaming_guard.h" 6 | 7 | using namespace std; 8 | using namespace rs::utils; 9 | 10 | namespace rs 11 | { 12 | namespace core 13 | { 14 | device_streaming_guard::device_streaming_guard(rs::device *device, 15 | rs::source enabled_sources) : 16 | m_device(device), 17 | m_enabled_sources(enabled_sources) 18 | { 19 | if(!m_device) 20 | { 21 | throw std::runtime_error("got invalid device"); 22 | } 23 | 24 | m_device->start(m_enabled_sources); 25 | } 26 | 27 | device_streaming_guard::~device_streaming_guard() 28 | { 29 | try 30 | { 31 | m_device->stop(m_enabled_sources); 32 | } 33 | catch(...) 34 | { 35 | LOG_ERROR("failed to stop librealsense device"); 36 | } 37 | m_device = nullptr; 38 | m_enabled_sources = static_cast(0); 39 | } 40 | } 41 | } 42 | 43 | -------------------------------------------------------------------------------- /sdk/src/utilities/samples_time_sync/samples_time_sync_external_camera.cpp: -------------------------------------------------------------------------------- 1 | // License: Apache 2.0. See LICENSE file in root directory. 2 | // Copyright(c) 2016 Intel Corporation. All Rights Reserved. 3 | 4 | #include "samples_time_sync_external_camera.h" 5 | 6 | using namespace std; 7 | using namespace rs::core; 8 | using namespace rs::utils; 9 | 10 | bool rs::utils::samples_time_sync_external_camera::sync_all(streams_map& streams, motions_map& motions, rs::core::correlated_sample_set &sample_set) 11 | { 12 | if (empty_list_exists()) 13 | { 14 | return false; 15 | } 16 | 17 | //Go over all the lists and get every stream and then motion 18 | for (auto& pair : streams) 19 | { 20 | assert(pair.second.size() == 1); //assuming here that samples_time_sync_external_camera was created with a single buffer 21 | stream_type st = pair.first; 22 | image_interface* image = pair.second.back().get(); 23 | image->add_ref(); 24 | sample_set[st] = image; 25 | pair.second.pop_back(); 26 | } 27 | 28 | for (auto& pair : motions) 29 | { 30 | assert(pair.second.size() == 1); 31 | motion_type mt = pair.first; 32 | sample_set[mt] = pair.second.back(); 33 | pair.second.pop_back(); 34 | } 35 | return true; 36 | } 37 | -------------------------------------------------------------------------------- /sdk/src/cameras/compression/decoder.h: -------------------------------------------------------------------------------- 1 | // License: Apache 2.0. See LICENSE file in root directory. 2 | // Copyright(c) 2016 Intel Corporation. All Rights Reserved. 3 | 4 | #pragma once 5 | #include 6 | #include 7 | #include 8 | #include "codec_interface.h" 9 | 10 | #ifdef WIN32 11 | #ifdef realsense_compression_EXPORTS 12 | #define DLL_EXPORT __declspec(dllexport) 13 | #else 14 | #define DLL_EXPORT __declspec(dllimport) 15 | #endif /* realsense_compression_EXPORTS */ 16 | #else /* defined (WIN32) */ 17 | #define DLL_EXPORT 18 | #endif 19 | 20 | namespace rs 21 | { 22 | namespace core 23 | { 24 | namespace compression 25 | { 26 | class DLL_EXPORT decoder 27 | { 28 | public: 29 | decoder(std::map configuration); 30 | ~decoder(); 31 | 32 | std::shared_ptr decode_frame(std::shared_ptr frame, uint8_t * input, uint32_t input_size); 33 | 34 | private: 35 | void add_codec(rs_stream stream_type, file_types::compression_type compression_type); 36 | std::map> m_codecs; 37 | }; 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /sdk/src/core/image/metadata.h: -------------------------------------------------------------------------------- 1 | // License: Apache 2.0. See LICENSE file in root directory. 2 | // Copyright(c) 2016 Intel Corporation. All Rights Reserved. 3 | 4 | #pragma once 5 | #include "rs/utils/ref_count_base.h" 6 | #include "rs/core/metadata_interface.h" 7 | #include 8 | #include 9 | #include 10 | namespace rs 11 | { 12 | namespace core 13 | { 14 | /** 15 | * @brief The metadata class 16 | * see complete metadata documantation in the interface declaration. 17 | */ 18 | class metadata : public metadata_interface 19 | { 20 | public: 21 | metadata() = default; 22 | virtual ~metadata() = default; 23 | bool is_metadata_available(metadata_type id) const override; 24 | uint32_t query_buffer_size(metadata_type id) const override; 25 | uint32_t get_metadata(metadata_type id, uint8_t* buffer) const override; 26 | status add_metadata(metadata_type id, const uint8_t* buffer, uint32_t size) override; 27 | status remove_metadata(metadata_type id) override; 28 | private: 29 | bool exists(metadata_type id) const; 30 | 31 | std::map> m_data; 32 | mutable std::mutex m_mutex; 33 | }; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /sdk/src/cameras/playback/playback_context.cpp: -------------------------------------------------------------------------------- 1 | // License: Apache 2.0. See LICENSE file in root directory. 2 | // Copyright(c) 2016 Intel Corporation. All Rights Reserved. 3 | 4 | #include 5 | #include "rs/playback/playback_context.h" 6 | #include "playback_device_impl.h" 7 | 8 | namespace rs 9 | { 10 | namespace playback 11 | { 12 | context::context(const char *file_path) : m_init_status(false) 13 | { 14 | m_devices = new rs_device*[1]; 15 | m_devices[0] = new rs_device_ex(file_path); 16 | m_init_status = ((rs_device_ex*)m_devices[0])->init(); 17 | } 18 | 19 | context::~context() 20 | { 21 | for(auto i = 0; i < 1; i++) 22 | { 23 | if(m_devices[i]) 24 | delete m_devices[i]; 25 | } 26 | delete[] m_devices; 27 | } 28 | 29 | int context::get_device_count() const 30 | { 31 | return m_init_status ? 1 : 0; 32 | } 33 | 34 | rs::device * context::get_device(int index) 35 | { 36 | return (rs::device*)get_playback_device(); 37 | } 38 | 39 | device * context::get_playback_device() 40 | { 41 | return m_init_status ? (device*)m_devices[0] : nullptr; 42 | } 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /sdk/src/utilities/samples_time_sync/samples_time_sync_external_camera.h: -------------------------------------------------------------------------------- 1 | // License: Apache 2.0. See LICENSE file in root directory. 2 | // Copyright(c) 2016 Intel Corporation. All Rights Reserved. 3 | #pragma once 4 | 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include "rs_sdk.h" 12 | 13 | #include "samples_time_sync_base.h" 14 | 15 | namespace rs 16 | { 17 | namespace utils 18 | { 19 | class samples_time_sync_external_camera : public samples_time_sync_base 20 | { 21 | public: 22 | samples_time_sync_external_camera(int streams_fps[static_cast(rs::core::stream_type::max)], 23 | int motions_fps[static_cast(rs::core::motion_type::max)], 24 | unsigned int max_input_latency, 25 | unsigned int not_matched_frames_buffer_size) : 26 | samples_time_sync_base(streams_fps, motions_fps, max_input_latency, not_matched_frames_buffer_size) {} 27 | 28 | virtual ~samples_time_sync_external_camera() {} 29 | 30 | protected: 31 | virtual bool sync_all(streams_map& streams, motions_map& motions, rs::core::correlated_sample_set &sample_set) override; 32 | 33 | }; 34 | } 35 | } 36 | 37 | -------------------------------------------------------------------------------- /sdk/src/utilities/samples_time_sync/samples_time_sync_ds5.h: -------------------------------------------------------------------------------- 1 | // License: Apache 2.0. See LICENSE file in root directory. 2 | // Copyright(c) 2016 Intel Corporation. All Rights Reserved. 3 | 4 | 5 | #pragma once 6 | 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | 14 | #include "rs_sdk.h" 15 | #include "rs/utils/cyclic_array.h" 16 | 17 | #include "samples_time_sync_base.h" 18 | 19 | namespace rs 20 | { 21 | namespace utils 22 | { 23 | class samples_time_sync_ds5 : public samples_time_sync_base 24 | { 25 | public: 26 | samples_time_sync_ds5(int streams_fps[static_cast(rs::core::stream_type::max)], 27 | int motions_fps[static_cast(rs::core::motion_type::max)], 28 | unsigned int max_input_latency, 29 | unsigned int not_matched_frames_buffer_size) : 30 | samples_time_sync_base(streams_fps, motions_fps, max_input_latency, not_matched_frames_buffer_size) {} 31 | 32 | virtual ~samples_time_sync_ds5() {} 33 | 34 | protected: 35 | virtual bool sync_all(streams_map& streams, motions_map& motions, rs::core::correlated_sample_set &sample_set) override; 36 | 37 | }; 38 | } 39 | } 40 | 41 | -------------------------------------------------------------------------------- /sdk/src/core/pipeline/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 2.8.9) 2 | project(realsense_pipeline) 3 | 4 | include_directories( 5 | ${ROOT_DIR}/include/ 6 | ) 7 | 8 | set(SOURCE_FILES 9 | ${ROOT_DIR}/include/rs/core/pipeline_async_interface.h 10 | ${ROOT_DIR}/include/rs/core/pipeline_async.h 11 | sample_set_releaser.h 12 | pipeline_async_impl.h 13 | pipeline_async_impl.cpp 14 | pipeline_async.cpp 15 | samples_consumer_base.h 16 | samples_consumer_base.cpp 17 | sync_samples_consumer.h 18 | sync_samples_consumer.cpp 19 | async_samples_consumer.h 20 | async_samples_consumer.cpp 21 | device_manager.h 22 | device_manager.cpp 23 | device_streaming_guard.h 24 | device_streaming_guard.cpp 25 | device_config_guard.h 26 | device_config_guard.cpp 27 | config_util.h 28 | config_util.cpp 29 | ) 30 | 31 | add_library(${PROJECT_NAME} ${SDK_LIB_TYPE} 32 | ${SOURCE_FILES} 33 | ) 34 | 35 | target_link_libraries(${PROJECT_NAME} 36 | realsense 37 | realsense_log_utils 38 | realsense_image 39 | realsense_lrs_image 40 | realsense_samples_time_sync 41 | realsense_playback 42 | realsense_record 43 | realsense_projection 44 | ) 45 | 46 | set_target_properties(${PROJECT_NAME} PROPERTIES VERSION "${LIBVERSION}" SOVERSION "${LIBSOVERSION}") 47 | 48 | install(TARGETS ${PROJECT_NAME} DESTINATION lib) 49 | -------------------------------------------------------------------------------- /sdk/src/utilities/samples_time_sync/samples_time_sync_zr300.h: -------------------------------------------------------------------------------- 1 | // License: Apache 2.0. See LICENSE file in root directory. 2 | // Copyright(c) 2016 Intel Corporation. All Rights Reserved. 3 | 4 | 5 | #pragma once 6 | 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | 14 | #include "rs_sdk.h" 15 | #include "rs/utils/cyclic_array.h" 16 | 17 | #include "samples_time_sync_base.h" 18 | 19 | namespace rs 20 | { 21 | namespace utils 22 | { 23 | class samples_time_sync_zr300 : public samples_time_sync_base 24 | { 25 | public: 26 | samples_time_sync_zr300(int streams_fps[static_cast(rs::core::stream_type::max)], 27 | int motions_fps[static_cast(rs::core::motion_type::max)], 28 | unsigned int max_input_latency, 29 | unsigned int not_matched_frames_buffer_size) : 30 | samples_time_sync_base(streams_fps, motions_fps, max_input_latency, not_matched_frames_buffer_size) {} 31 | 32 | virtual ~samples_time_sync_zr300() {} 33 | 34 | protected: 35 | virtual bool sync_all(streams_map& streams, motions_map& motions, rs::core::correlated_sample_set &sample_set) override; 36 | 37 | }; 38 | } 39 | } 40 | 41 | -------------------------------------------------------------------------------- /sdk/src/cameras/playback/include/windows/v10/disk_read.h: -------------------------------------------------------------------------------- 1 | // License: Apache 2.0. See LICENSE file in root directory. 2 | // Copyright(c) 2016 Intel Corporation. All Rights Reserved. 3 | 4 | #pragma once 5 | #include "disk_read_base.h" 6 | 7 | namespace rs 8 | { 9 | namespace playback 10 | { 11 | namespace windows 12 | { 13 | namespace v10 14 | { 15 | class disk_read : public disk_read_base 16 | { 17 | 18 | public: 19 | disk_read(const char *file_name) : disk_read_base(file_name), m_time_stamp_base(0) {} 20 | virtual ~disk_read(void); 21 | 22 | protected: 23 | virtual rs::core::status read_headers() override; 24 | virtual void index_next_samples(uint32_t number_of_samples) override; 25 | virtual int32_t size_of_pitches(void) override; 26 | void handle_ds_projection(std::vector &projection_data); 27 | rs::core::status get_image_offset(rs_stream stream, int64_t & offset); 28 | virtual uint32_t read_frame_metadata(const std::shared_ptr & frame, unsigned long num_bytes_to_read) override; 29 | private: 30 | uint64_t m_time_stamp_base; 31 | }; 32 | } 33 | } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /sdk/include/rs/utils/release_self_base.h: -------------------------------------------------------------------------------- 1 | // License: Apache 2.0. See LICENSE file in root directory. 2 | // Copyright(c) 2016 Intel Corporation. All Rights Reserved. 3 | 4 | /** 5 | * \file release_self_base.h 6 | * @brief Describes the \c rs::utils::release_self_base template. 7 | **/ 8 | 9 | #pragma once 10 | 11 | namespace rs 12 | { 13 | namespace utils 14 | { 15 | /** 16 | * 17 | * @brief Provides an ABI-safe release operation for a single non-ref counted object. 18 | * 19 | * Calling to release will delete the object from the context of the intializing side. With this method, 20 | * there is no need to supply an additional ABI-safe object deleter method. 21 | */ 22 | template 23 | class release_self_base : public T 24 | { 25 | 26 | public: 27 | /** 28 | * @brief Deletes the current instance. 29 | * 30 | * Releases the object from the context of the intializing side. With this method, 31 | * there is no need to supply an additional ABI-safe object deleter method. 32 | * @return int Number of valid references for this instance 33 | */ 34 | virtual int release() const override 35 | { 36 | delete(this); 37 | return 0; 38 | } 39 | protected: 40 | virtual ~release_self_base () {} 41 | }; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /sdk/src/core/pipeline/device_config_guard.h: -------------------------------------------------------------------------------- 1 | // License: Apache 2.0. See LICENSE file in root directory. 2 | // Copyright(c) 2016 Intel Corporation. All Rights Reserved. 3 | 4 | #pragma once 5 | #include 6 | #include 7 | #include 8 | #include "rs/core/video_module_interface.h" 9 | #include 10 | 11 | namespace rs 12 | { 13 | namespace core 14 | { 15 | class device_config_guard 16 | { 17 | public: 18 | device_config_guard(rs::device * device, 19 | const video_module_interface::actual_module_config& given_config, 20 | std::function sample_set)> non_blocking_notify_sample); 21 | 22 | device_config_guard(const device_config_guard&) = delete; 23 | device_config_guard & operator=(const device_config_guard&) = delete; 24 | 25 | virtual ~device_config_guard(); 26 | private: 27 | rs::device * m_device; 28 | const video_module_interface::actual_module_config m_config; 29 | std::function sample_set)> m_non_blocking_notify_sample; 30 | 31 | std::map> m_stream_callback_per_stream; 32 | std::function m_motion_callback; 33 | }; 34 | } 35 | } 36 | 37 | -------------------------------------------------------------------------------- /sdk/src/utilities/samples_time_sync/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 2.8.9) 2 | project(realsense_samples_time_sync) 3 | 4 | #------------------------------------------------------------------------------------ 5 | #Include 6 | include_directories( 7 | . 8 | .. 9 | include 10 | ${ROOT_DIR}/include/rs/core 11 | ) 12 | 13 | #Source Files 14 | set(SOURCE_FILES_BASE samples_time_sync_zr300.cpp samples_time_sync_impl.cpp 15 | samples_time_sync_base.cpp 16 | samples_time_sync_ds5.cpp 17 | samples_time_sync_external_camera.cpp) 18 | 19 | #Building Library 20 | add_library(${PROJECT_NAME} ${SDK_LIB_TYPE} 21 | ${SOURCE_FILES_BASE} 22 | ) 23 | 24 | #------------------------------------------------------------------------------------ 25 | #LINK_LIBRARIES 26 | target_link_libraries(${PROJECT_NAME} 27 | realsense_log_utils 28 | ) 29 | 30 | #------------------------------------------------------------------------------------ 31 | #Dependencies 32 | add_dependencies(${PROJECT_NAME} 33 | realsense_log_utils 34 | ) 35 | 36 | #------------------------------------------------------------------------------------ 37 | #Versioning 38 | set_target_properties(${PROJECT_NAME} PROPERTIES VERSION "${LIBVERSION}" SOVERSION "${LIBSOVERSION}") 39 | 40 | #------------------------------------------------------------------------------------ 41 | #Install 42 | install(TARGETS ${PROJECT_NAME} DESTINATION lib) 43 | -------------------------------------------------------------------------------- /sdk/src/cameras/playback/include/playback_device_interface.h: -------------------------------------------------------------------------------- 1 | // License: Apache 2.0. See LICENSE file in root directory. 2 | // Copyright(c) 2016 Intel Corporation. All Rights Reserved. 3 | 4 | #pragma once 5 | #include 6 | #include 7 | #include "rs/playback/playback_device.h" 8 | 9 | #ifdef WIN32 10 | #ifdef realsense_playback_EXPORTS 11 | #define DLL_EXPORT __declspec(dllexport) 12 | #else 13 | #define DLL_EXPORT __declspec(dllimport) 14 | #endif /* realsense_playback_EXPORTS */ 15 | #else /* defined (WIN32) */ 16 | #define DLL_EXPORT 17 | #endif 18 | 19 | namespace rs 20 | { 21 | namespace playback 22 | { 23 | class DLL_EXPORT device_interface : public rs_device 24 | { 25 | public: 26 | virtual ~device_interface() {} 27 | virtual bool init() = 0; 28 | virtual bool is_real_time() = 0; 29 | virtual void pause() = 0; 30 | virtual void resume() = 0; 31 | virtual bool set_frame_by_index(int index, rs_stream stream) = 0; 32 | virtual bool set_frame_by_timestamp(uint64_t timestamp) = 0; 33 | virtual void set_real_time(bool realtime) = 0; 34 | virtual int get_frame_index(rs_stream stream) = 0; 35 | virtual int get_frame_count(rs_stream stream) = 0; 36 | virtual int get_frame_count() = 0; 37 | virtual playback::file_info get_file_info() = 0; 38 | }; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /sdk/src/core/image/lrs_image/lrs_image.h: -------------------------------------------------------------------------------- 1 | // License: Apache 2.0. See LICENSE file in root directory. 2 | // Copyright(c) 2016 Intel Corporation. All Rights Reserved. 3 | 4 | #pragma once 5 | #include 6 | #include "image_base.h" 7 | 8 | namespace rs 9 | { 10 | namespace core 11 | { 12 | /** 13 | * @brief The lrs_image class 14 | * implements the sdk image interface for a frame defined by librealsense. 15 | * see complete documantation in the interface declaration. 16 | */ 17 | class lrs_image : public image_base 18 | { 19 | public: 20 | lrs_image(const lrs_image &) = delete; 21 | lrs_image & operator = (const lrs_image &) = delete; 22 | 23 | lrs_image(rs::frame &frame, 24 | image_interface::flag flags); 25 | image_info query_info(void) const override; 26 | double query_time_stamp(void) const override; 27 | timestamp_domain query_time_stamp_domain(void) const override; 28 | flag query_flags(void) const override; 29 | const void * query_data(void) const override; 30 | stream_type query_stream_type() const override; 31 | uint64_t query_frame_number() const override; 32 | protected: 33 | virtual ~lrs_image(); 34 | private: 35 | rs::frame m_frame; 36 | image_interface::flag m_flags; 37 | }; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /sdk/src/cameras/compression/encoder.h: -------------------------------------------------------------------------------- 1 | // License: Apache 2.0. See LICENSE file in root directory. 2 | // Copyright(c) 2016 Intel Corporation. All Rights Reserved. 3 | 4 | #pragma once 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include "codec_interface.h" 10 | #include "rs/record/record_device.h" 11 | 12 | #ifdef WIN32 13 | #ifdef realsense_compression_EXPORTS 14 | #define DLL_EXPORT __declspec(dllexport) 15 | #else 16 | #define DLL_EXPORT __declspec(dllimport) 17 | #endif /* realsense_compression_EXPORTS */ 18 | #else /* defined (WIN32) */ 19 | #define DLL_EXPORT 20 | #endif 21 | 22 | namespace rs 23 | { 24 | namespace core 25 | { 26 | namespace compression 27 | { 28 | class DLL_EXPORT encoder 29 | { 30 | public: 31 | encoder(); 32 | ~encoder(); 33 | 34 | status encode_frame(file_types::frame_info &info, const uint8_t * input, uint8_t * output, uint32_t &output_size); 35 | file_types::compression_type get_compression_type(rs_stream stream); 36 | void add_codec(rs_stream stream, rs_format format, record::compression_level compression_level); 37 | 38 | private: 39 | file_types::compression_type compression_policy(rs_stream stream, rs_format format); 40 | std::map> m_codecs; 41 | }; 42 | } 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /sdk/src/cameras/compression/lz4_codec.h: -------------------------------------------------------------------------------- 1 | // License: Apache 2.0. See LICENSE file in root directory. 2 | // Copyright(c) 2016 Intel Corporation. All Rights Reserved. 3 | 4 | #pragma once 5 | #include 6 | #include 7 | #include "codec_interface.h" 8 | #include "rs/record/record_device.h" 9 | 10 | #ifdef WIN32 11 | #ifdef realsense_compression_EXPORTS 12 | #define DLL_EXPORT __declspec(dllexport) 13 | #else 14 | #define DLL_EXPORT __declspec(dllimport) 15 | #endif /* realsense_compression_EXPORTS */ 16 | #else /* defined (WIN32) */ 17 | #define DLL_EXPORT 18 | #endif 19 | 20 | namespace rs 21 | { 22 | namespace core 23 | { 24 | namespace compression 25 | { 26 | class DLL_EXPORT lz4_codec : public codec_interface 27 | { 28 | public: 29 | lz4_codec(); 30 | lz4_codec(record::compression_level compression_level); 31 | virtual ~lz4_codec(); 32 | 33 | virtual status encode(file_types::frame_info &info, const uint8_t * input, uint8_t * output, uint32_t &output_size) override; 34 | virtual std::shared_ptr decode(std::shared_ptr frame, uint8_t * input, uint32_t input_size) override; 35 | virtual file_types::compression_type get_compression_type() override { return file_types::compression_type::lz4; } 36 | private: 37 | uint32_t m_compression_level; 38 | }; 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 2.8.9) 2 | project(realsense_sdk) 3 | 4 | include(cmake_includes/check_os.cmake) 5 | 6 | ## Set preprocessors defines accroding to OS, to be used within header files 7 | 8 | if( ${IS_CURRENT_SYSTEM_LINUX_OS}) 9 | add_definitions(-DLINUX) 10 | MESSAGE("Added preprocessor definition: LINUX") 11 | endif() 12 | 13 | 14 | set(SDK_DIR sdk) 15 | add_subdirectory(${SDK_DIR}) 16 | 17 | #samples built using this cmake will link to local sdk compilation 18 | include_directories(${SDK_DIR}/include ${SDK_DIR}/src/include) 19 | 20 | if(CMAKE_BUILD_TYPE STREQUAL "Debug") 21 | link_directories(${SDK_DIR}/lib/debug) 22 | else() 23 | link_directories(${SDK_DIR}/lib/release) 24 | endif() 25 | 26 | if(${IS_CURRENT_SYSTEM_LINUX_OS}) 27 | add_subdirectory(samples) 28 | option(BUILD_PKG_CONFIG "set BUILD_PKG_CONFIG to ON if pkg-config tool should be built, set to OFF to skip it" OFF) 29 | if(BUILD_PKG_CONFIG) 30 | include(cmake_includes/pkg_config) 31 | endif(BUILD_PKG_CONFIG) 32 | endif(${IS_CURRENT_SYSTEM_LINUX_OS}) 33 | 34 | if(${IS_CURRENT_SYSTEM_WINDOWS_OS}) 35 | option(WINDOWS_PKG "set WINDOWS_PKG to ON if build tests should be run, set to OFF to skip tests" OFF) 36 | if(WINDOWS_PKG) 37 | include(cmake_includes/pkg_windows.cmake) 38 | endif(WINDOWS_PKG) 39 | endif(${IS_CURRENT_SYSTEM_WINDOWS_OS}) 40 | 41 | option(BUILD_TESTS "set BUILD_TESTS to ON if build tests should be run, set to OFF to skip tests" OFF) 42 | if(BUILD_TESTS) 43 | add_subdirectory(tests) 44 | endif(BUILD_TESTS) -------------------------------------------------------------------------------- /samples/src/pipeline_async_sample/README.md: -------------------------------------------------------------------------------- 1 | # Intel® RealSense™ Linux SDK 2 | ## Pipeline Asynchronized Sample 3 | --- 4 | ### Description 5 | This sample demonstrates an application usage of an asynchronized pipeline. The pipeline simplifies the user interaction with computer vision modules. It abstracts the camera configuration and streaming, the video modules triggering and threading, and lets the application focus on the computer vision output of the modules. The pipeline can manage computer vision modules, which implement the video module interface. The pipeline is the consumer of the video module interface, while the application consumes the module specific interface, which completes the video module interface. The async pipeline provides the user main loop, which runs on the calling thread, and computer vision modules callbacks, which are triggered on different threads. In this sample an example computer vision module, the max depth value module is used to demonstrate the pipeline usage. 6 | ### Category 7 | RealSense(TM) SDK 8 | 9 | ### Author 10 | Intel(R) Corporation 11 | 12 | ### Hardware Requirements 13 | zr300 14 | 15 | ### Libraries 16 | 17 | 18 | ### Compiler Flags 19 | -std=c++11 20 | 21 | ### Libraries Flags 22 | -lrealsense_pipeline -lrealsense_max_depth_value_module -lrealsense_image -lrealsense_playback -lrealsense_projection -lrealsense_samples_time_sync -lrealsense_log_utils -lrealsense -lpthread -lopencv_imgproc -lopencv_core 23 | 24 | ### Date 25 | 25/10/2016 26 | 27 | -------------------------------------------------------------------------------- /sdk/include/rs/core/ref_count_interface.h: -------------------------------------------------------------------------------- 1 | // License: Apache 2.0. See LICENSE file in root directory. 2 | // Copyright(c) 2016 Intel Corporation. All Rights Reserved. 3 | 4 | /** 5 | * \file ref_count_interface.h 6 | * @brief Describes the \c rs::core::ref_count_interface class. 7 | */ 8 | 9 | #pragma once 10 | #include "rs/core/release_interface.h" 11 | 12 | namespace rs 13 | { 14 | namespace core 15 | { 16 | /** 17 | * @brief Provides an ABI-safe interface extension for inheriting classes. 18 | * 19 | * Classes that inherit from \c ref_count_interface are restricted to call \c rs::core::ref_count_interface::add_ref() when the object is shared 20 | * across library boundaries and release it when it stops using it. 21 | * The interface is completely \c const to allow \c const inheriting objects to change the reference count. 22 | */ 23 | class ref_count_interface : public release_interface 24 | { 25 | public: 26 | /** 27 | * @brief Adds +1 to the object reference count. 28 | * @return int Reference count 29 | */ 30 | virtual int add_ref() const = 0; 31 | 32 | /** 33 | * @brief Gets the current object reference count. 34 | * @return int Reference count 35 | */ 36 | virtual int ref_count() const = 0; 37 | protected: 38 | //force deletion using the release function 39 | virtual ~ref_count_interface() {} 40 | }; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /sdk/src/core/pipeline/async_samples_consumer.h: -------------------------------------------------------------------------------- 1 | // License: Apache 2.0. See LICENSE file in root directory. 2 | // Copyright(c) 2016 Intel Corporation. All Rights Reserved. 3 | 4 | #pragma once 5 | #include 6 | #include 7 | #include 8 | #include "rs/core/pipeline_async_interface.h" 9 | #include "samples_consumer_base.h" 10 | 11 | namespace rs 12 | { 13 | namespace core 14 | { 15 | class async_samples_consumer : public samples_consumer_base, 16 | public video_module_interface::processing_event_handler 17 | { 18 | public: 19 | async_samples_consumer(pipeline_async_interface::callback_handler* app_callbacks_handler, 20 | video_module_interface* cv_module, 21 | const video_module_interface::actual_module_config &module_config, 22 | const video_module_interface::supported_module_config::time_sync_mode time_sync_mode); 23 | 24 | // processing_event_handler interface 25 | void module_output_ready(video_module_interface *sender, correlated_sample_set *sample) override; 26 | 27 | ~async_samples_consumer(); 28 | private: 29 | pipeline_async_interface::callback_handler * m_app_callbacks_handler; 30 | video_module_interface * m_cv_module; 31 | 32 | void on_complete_sample_set(std::shared_ptr ready_sample_set) override; 33 | void consumer_loop(); 34 | }; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /sdk/src/core/pipeline/sync_samples_consumer.h: -------------------------------------------------------------------------------- 1 | // License: Apache 2.0. See LICENSE file in root directory. 2 | // Copyright(c) 2016 Intel Corporation. All Rights Reserved. 3 | 4 | #pragma once 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include "rs/core/pipeline_async_interface.h" 10 | #include "samples_consumer_base.h" 11 | 12 | namespace rs 13 | { 14 | namespace core 15 | { 16 | /** 17 | * @brief The samples_consumer class 18 | */ 19 | class sync_samples_consumer : public samples_consumer_base 20 | { 21 | public: 22 | sync_samples_consumer(std::function)> sample_set_ready_handler, 23 | const video_module_interface::actual_module_config & module_config, 24 | const video_module_interface::supported_module_config::time_sync_mode time_sync_mode); 25 | 26 | virtual ~sync_samples_consumer(); 27 | private: 28 | std::thread m_samples_consumer_thread; 29 | bool m_is_closing; 30 | std::shared_ptr m_current_sample_set; 31 | std::mutex m_lock; 32 | std::condition_variable m_conditional_variable; 33 | 34 | std::function)> m_sample_set_ready_handler; 35 | void on_complete_sample_set(std::shared_ptr ready_sample_set) override; 36 | void consumer_loop(); 37 | }; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /package_configure.json: -------------------------------------------------------------------------------- 1 | { 2 | "PackageName": "librealsense-sdk", 3 | "Maintainer": "Intel Realsense", 4 | "MaintainerEmail": "realsense@intel.com", 5 | "UseCmake": true, 6 | "BuildDepends": [{"PackageName": "debhelper", "PackageVersion": "(>=9)"} , 7 | {"PackageName": "cmake", "PackageVersion": ""}, 8 | {"PackageName": "libopencv-dev", "PackageVersion": "(>= 3.1.0)"}, 9 | {"PackageName": "librealsense-dev", "PackageVersion": ""}, 10 | {"PackageName": "libglfw3-dev", "PackageVersion": ""}, 11 | {"PackageName": "liblz4-dev", "PackageVersion": ""}], 12 | "RuntimePackage": { 13 | "Depends": [{"PackageName": "librealsense-sdk-projection0", "PackageVersion": ""}], 14 | "Installs": [{"Source": "usr/lib/librealsense_*.so.*", "Destination": "usr/lib/"}, 15 | {"Source": "sdk/doc/*", "Destination": "usr/share/doc/realsense_sdk/doc/"}], 16 | "Description": "Intel(R) RealSense(TM) SDK libraries" 17 | }, 18 | "DevelopmentPackage": { 19 | "Depends": [{"PackageName": "librealsense-sdk-projection-dev", "PackageVersion": ""}, 20 | {"PackageName": "librealsense-dev", "PackageVersion": ""}], 21 | "Installs": [{"Source": "usr/bin/*", "Destination": ""}, 22 | {"Source": "usr/lib/librealsense_*.so", "Destination": "usr/lib/"}, 23 | {"Source": "usr/include/*", "Destination": ""}, 24 | {"Source": "samples/src/*", "Destination": "usr/share/doc/realsense_sdk/samples/src/"}, 25 | {"Source": "samples/*.txt", "Destination": "usr/share/doc/realsense_sdk/samples/"}, 26 | {"Source": "usr/lib/pkgconfig/*", "Destination": ""}], 27 | "Description": "Intel(R) RealSense(TM) SDK development files" 28 | } 29 | } 30 | 31 | -------------------------------------------------------------------------------- /sdk/src/core/image/image_base.h: -------------------------------------------------------------------------------- 1 | // License: Apache 2.0. See LICENSE file in root directory. 2 | // Copyright(c) 2016 Intel Corporation. All Rights Reserved. 3 | 4 | #pragma once 5 | #include "rs/utils/ref_count_base.h" 6 | #include "rs/utils/smart_ptr_helpers.h" 7 | #include "rs/core/image_interface.h" 8 | #include "metadata.h" 9 | #include 10 | #include 11 | 12 | #ifdef WIN32 13 | #ifdef realsense_image_EXPORTS 14 | #define DLL_EXPORT __declspec(dllexport) 15 | #else 16 | #define DLL_EXPORT __declspec(dllimport) 17 | #endif /* realsense_image_EXPORTS */ 18 | #else /* defined (WIN32) */ 19 | #define DLL_EXPORT 20 | #endif 21 | 22 | namespace rs 23 | { 24 | namespace core 25 | { 26 | /** 27 | * @brief The image_base class 28 | * base implementation to common image api. 29 | */ 30 | class DLL_EXPORT image_base : public rs::utils::ref_count_base 31 | { 32 | public: 33 | image_base(); 34 | virtual metadata_interface* query_metadata() override; 35 | virtual status convert_to(pixel_format format, const image_interface ** converted_image) override; 36 | virtual status convert_to(rs::core::rotation rotation, const image_interface ** converted_image) override; 37 | 38 | protected: 39 | std::map> image_cache_per_pixel_format; 40 | std::mutex image_caching_lock; 41 | virtual ~image_base() = default; 42 | private: 43 | rs::core::metadata metadata; 44 | }; 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /sdk/src/utilities/logger/logger/xlevel.h: -------------------------------------------------------------------------------- 1 | // License: Apache 2.0. See LICENSE file in root directory. 2 | // Copyright(c) 2016 Intel Corporation. All Rights Reserved. 3 | 4 | 5 | #pragma once 6 | 7 | #include 8 | 9 | namespace log4cxx 10 | { 11 | class XLevel : public Level 12 | { 13 | DECLARE_LOG4CXX_LEVEL(XLevel) 14 | 15 | public: 16 | enum 17 | { 18 | VERBOSE_INT = 2500, 19 | }; 20 | 21 | static LevelPtr getVerbose(); 22 | 23 | 24 | XLevel(int level, const LogString& name, int syslogEquivalent); 25 | /** 26 | Convert the string passed as argument to a level. If the 27 | conversion fails, then this method returns #DEBUG. 28 | */ 29 | static LevelPtr toLevelLS(const LogString& sArg); 30 | 31 | /** 32 | Convert an integer passed as argument to a level. If the 33 | conversion fails, then this method returns #DEBUG. 34 | 35 | */ 36 | static LevelPtr toLevel(int val); 37 | 38 | /** 39 | Convert an integer passed as argument to a level. If the 40 | conversion fails, then this method returns the specified default. 41 | */ 42 | static LevelPtr toLevel(int val, const LevelPtr& defaultLevel); 43 | 44 | 45 | /** 46 | Convert the string passed as argument to a level. If the 47 | conversion fails, then this method returns the value of 48 | defaultLevel. 49 | */ 50 | static LevelPtr toLevelLS(const LogString& sArg, 51 | const LevelPtr& defaultLevel); 52 | }; 53 | } 54 | 55 | -------------------------------------------------------------------------------- /sdk/src/core/projection/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 2.8.9) 2 | project(realsense_projection) 3 | 4 | #Source Files 5 | set(SOURCE_FILES 6 | projection_r200.cpp 7 | projection_r200.h 8 | ${ROOT_DIR}/include/rs/core/projection_interface.h 9 | math_projection_interface.h 10 | math_projection.cpp 11 | ) 12 | 13 | #------------------------------------------------------------------------------------ 14 | #Flags 15 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") 16 | 17 | #------------------------------------------------------------------------------------ 18 | #Include 19 | include_directories( 20 | . 21 | .. 22 | ${ROOT_DIR} 23 | ${ROOT_DIR}/include 24 | ${ROOT_DIR}/src/utilities 25 | ${ROOT_DIR}/src/core/image 26 | ${ROOT_DIR}/src/utilities/image 27 | ) 28 | 29 | #------------------------------------------------------------------------------------ 30 | #Building Library 31 | add_library(${PROJECT_NAME} SHARED 32 | ${SOURCE_FILES} 33 | ) 34 | 35 | #------------------------------------------------------------------------------------ 36 | #LINK_LIBRARIES 37 | target_link_libraries(${PROJECT_NAME} 38 | realsense_image 39 | realsense_log_utils 40 | ) 41 | 42 | 43 | #------------------------------------------------------------------------------------ 44 | #Dependencies 45 | add_dependencies(${PROJECT_NAME} 46 | realsense_log_utils 47 | ) 48 | 49 | set_target_properties(${PROJECT_NAME} PROPERTIES VERSION "${LIBVERSION}" SOVERSION "${LIBSOVERSION}") 50 | 51 | #------------------------------------------------------------------------------------ 52 | install(TARGETS ${PROJECT_NAME} DESTINATION lib) 53 | -------------------------------------------------------------------------------- /sdk/src/utilities/logger/logger/xlevel.cpp: -------------------------------------------------------------------------------- 1 | // License: Apache 2.0. See LICENSE file in root directory. 2 | // Copyright(c) 2016 Intel Corporation. All Rights Reserved. 3 | 4 | 5 | #include "xlevel.h" 6 | #include 7 | 8 | using namespace log4cxx; 9 | using namespace log4cxx::helpers; 10 | 11 | 12 | IMPLEMENT_LOG4CXX_LEVEL(XLevel) 13 | 14 | XLevel::XLevel(int level1, const LogString& name1, int syslogEquivalent1) : 15 | Level(level1, name1, syslogEquivalent1) 16 | { 17 | } 18 | 19 | LevelPtr XLevel::getVerbose() 20 | { 21 | static const LevelPtr trace( 22 | new XLevel(XLevel::VERBOSE_INT, LOG4CXX_STR("VERBOSE"), 7)); 23 | return trace; 24 | } 25 | 26 | LevelPtr XLevel::toLevelLS(const LogString& sArg) 27 | { 28 | return toLevelLS(sArg, getVerbose()); 29 | } 30 | 31 | LevelPtr XLevel::toLevel(int val) 32 | { 33 | return toLevel(val, getVerbose()); 34 | } 35 | 36 | LevelPtr XLevel::toLevel(int val, const LevelPtr& defaultLevel) 37 | { 38 | switch (val) 39 | { 40 | case VERBOSE_INT: 41 | return getVerbose(); 42 | default: 43 | return Level::toLevel(val, defaultLevel); 44 | } 45 | } 46 | 47 | LevelPtr XLevel::toLevelLS(const LogString& sArg, 48 | const LevelPtr& defaultLevel) 49 | { 50 | if (sArg.empty()) 51 | { 52 | return defaultLevel; 53 | } 54 | 55 | if (StringHelper::equalsIgnoreCase(sArg, LOG4CXX_STR("VERBOSE"), 56 | LOG4CXX_STR("verbose"))) 57 | { 58 | return getVerbose(); 59 | } 60 | 61 | return Level::toLevel(sArg, defaultLevel); 62 | } 63 | 64 | -------------------------------------------------------------------------------- /sdk/include/rs/cv_modules/max_depth_value_module/max_depth_value_output_interface.h: -------------------------------------------------------------------------------- 1 | // License: Apache 2.0. See LICENSE file in root directory. 2 | // Copyright(c) 2016 Intel Corporation. All Rights Reserved. 3 | 4 | /** 5 | * \file max_depth_value_output_interface.h 6 | * @brief Describes the \c rs::cv_modules::max_depth_value_output_interface class. 7 | **/ 8 | 9 | #pragma once 10 | 11 | namespace rs 12 | { 13 | namespace cv_modules 14 | { 15 | /** 16 | * @brief Example of a computer vision module interface that calculates the maximum depth pixel value of the current depth image from the depth images stream. 17 | * 18 | * This interface represent a single module specific output. The input stream and motion samples 19 | * are defined commonly for all the CV modules through \c rs::core::video_module_interface. 20 | */ 21 | class max_depth_value_output_interface 22 | { 23 | public: 24 | /** 25 | * @brief CV module output data structure. 26 | */ 27 | struct max_depth_value_output_data 28 | { 29 | uint16_t max_depth_value; /**< Max depth value */ 30 | uint64_t frame_number; /**< Frame number for which the maximum depth value was calculated */ 31 | }; 32 | 33 | /** 34 | * @brief Returns latest maximum depth value data. 35 | * 36 | * @return Latest maximum depth value data 37 | */ 38 | virtual max_depth_value_output_data get_max_depth_value_data() = 0; 39 | virtual ~max_depth_value_output_interface() {} 40 | }; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /sdk/src/cameras/record/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | cmake_minimum_required(VERSION 2.8.9) 3 | project(realsense_record) 4 | 5 | #------------------------------------------------------------------------------------ 6 | #Include 7 | include_directories( 8 | . 9 | .. 10 | include 11 | ${ROOT_DIR}/include/rs/core 12 | ) 13 | 14 | #------------------------------------------------------------------------------------ 15 | #Source Files 16 | set(SOURCE_FILES 17 | disk_write.cpp 18 | record_device_impl.cpp 19 | record_context.cpp 20 | include/disk_write.h 21 | include/record_device_impl.h 22 | include/record_device_interface.h 23 | ${ROOT_DIR}/src/cameras/include/file_types.h 24 | ${ROOT_DIR}/include/rs/record/record_device.h 25 | ${ROOT_DIR}/include/rs/record/record_context.h 26 | ) 27 | 28 | #------------------------------------------------------------------------------------ 29 | #Building Library 30 | add_library(${PROJECT_NAME} ${SDK_LIB_TYPE} 31 | ${SOURCE_FILES} 32 | ) 33 | 34 | #------------------------------------------------------------------------------------ 35 | #LINK_LIBRARIES 36 | target_link_libraries(${PROJECT_NAME} 37 | realsense_compression 38 | realsense_log_utils 39 | realsense 40 | ) 41 | 42 | #------------------------------------------------------------------------------------ 43 | #Dependencies 44 | add_dependencies(${PROJECT_NAME} 45 | realsense_compression 46 | realsense_log_utils 47 | ) 48 | 49 | set_target_properties(${PROJECT_NAME} PROPERTIES VERSION "${LIBVERSION}" SOVERSION "${LIBSOVERSION}") 50 | 51 | #------------------------------------------------------------------------------------ 52 | install(TARGETS ${PROJECT_NAME} DESTINATION lib) 53 | -------------------------------------------------------------------------------- /sdk/src/cameras/compression/decoder.cpp: -------------------------------------------------------------------------------- 1 | // License: Apache 2.0. See LICENSE file in root directory. 2 | // Copyright(c) 2016 Intel Corporation. All Rights Reserved. 3 | 4 | #include "decoder.h" 5 | #include "lz4_codec.h" 6 | #include "rs/utils/log_utils.h" 7 | #include "rs_sdk_version.h" 8 | 9 | namespace rs 10 | { 11 | namespace core 12 | { 13 | namespace compression 14 | { 15 | 16 | decoder::decoder(std::map configuration) 17 | { 18 | for(auto config : configuration) 19 | { 20 | add_codec(config.first, config.second); 21 | } 22 | } 23 | 24 | decoder::~decoder() 25 | { 26 | 27 | } 28 | 29 | void decoder::add_codec(rs_stream stream_type, file_types::compression_type compression_type) 30 | { 31 | if(m_codecs.find(stream_type) != m_codecs.end()) return; 32 | auto & codec = m_codecs[stream_type]; 33 | switch (compression_type) 34 | { 35 | case file_types::compression_type::lz4: codec = std::shared_ptr(new lz4_codec()); break; 36 | default: codec = nullptr; break; 37 | } 38 | } 39 | 40 | std::shared_ptr decoder::decode_frame(std::shared_ptr frame, uint8_t *input, uint32_t input_size) 41 | { 42 | LOG_FUNC_SCOPE(); 43 | if(!frame) 44 | return nullptr; 45 | auto codec = m_codecs.at(frame->finfo.stream); 46 | return codec ? m_codecs[frame->finfo.stream]->decode(frame, input, input_size) : nullptr; 47 | } 48 | } 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /sdk/src/core/pipeline/samples_consumer_base.h: -------------------------------------------------------------------------------- 1 | // License: Apache 2.0. See LICENSE file in root directory. 2 | // Copyright(c) 2016 Intel Corporation. All Rights Reserved. 3 | 4 | #pragma once 5 | #include 6 | #include 7 | #include "rs/utils/samples_time_sync_interface.h" 8 | 9 | namespace rs 10 | { 11 | namespace core 12 | { 13 | class samples_consumer_base 14 | { 15 | public: 16 | samples_consumer_base(const video_module_interface::actual_module_config &module_config, 17 | const video_module_interface::supported_module_config::time_sync_mode time_sync_mode); 18 | void notify_sample_set_non_blocking(std::shared_ptr sample_set); 19 | virtual ~samples_consumer_base(); 20 | protected: 21 | virtual void on_complete_sample_set(std::shared_ptr ready_sample_set) = 0; 22 | private: 23 | const video_module_interface::actual_module_config m_module_config; 24 | rs::utils::unique_ptr m_time_sync_util; 25 | 26 | bool is_sample_set_relevant(const std::shared_ptr & sample_set) const; 27 | std::shared_ptr insert_to_time_sync_util(const std::shared_ptr & input_sample_set); 28 | std::vector> get_unmatched_frames(); 29 | rs::utils::unique_ptr get_time_sync_util_from_module_config(const video_module_interface::actual_module_config &module_config, 30 | const video_module_interface::supported_module_config::time_sync_mode time_sync_mode); 31 | }; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /sdk/src/cameras/include/linear_algebra.h: -------------------------------------------------------------------------------- 1 | // License: Apache 2.0. See LICENSE file in root directory. 2 | // Copyright(c) 2016 Intel Corporation. All Rights Reserved. 3 | 4 | // World's tiniest linear algebra library // 5 | 6 | namespace rs 7 | { 8 | namespace utils 9 | { 10 | struct int2 { int x,y; }; 11 | struct float3 { float x,y,z; float & operator [] (int i) { return (&x)[i]; } }; 12 | struct float3x3 { float3 x,y,z; float & operator () (int i, int j) { return (&x)[j][i]; } }; // column-major 13 | struct pose { float3x3 orientation; float3 position; }; 14 | inline bool operator == (const float3 & a, const float3 & b) { return a.x==b.x && a.y==b.y && a.z==b.z; } 15 | inline float3 operator + (const float3 & a, const float3 & b) { return {a.x+b.x, a.y+b.y, a.z+b.z}; } 16 | inline float3 operator * (const float3 & a, float b) { return {a.x*b, a.y*b, a.z*b}; } 17 | inline bool operator == (const float3x3 & a, const float3x3 & b) { return a.x==b.x && a.y==b.y && a.z==b.z; } 18 | inline float3 operator * (const float3x3 & a, const float3 & b) { return a.x*b.x + a.y*b.y + a.z*b.z; } 19 | inline float3x3 operator * (const float3x3 & a, const float3x3 & b) { return {a*b.x, a*b.y, a*b.z}; } 20 | inline float3x3 transpose(const float3x3 & a) { return {{a.x.x,a.y.x,a.z.x}, {a.x.y,a.y.y,a.z.y}, {a.x.z,a.y.z,a.z.z}}; } 21 | inline bool operator == (const pose & a, const pose & b) { return a.orientation==b.orientation && a.position==b.position; } 22 | inline float3 operator * (const pose & a, const float3 & b) { return a.orientation * b + a.position; } 23 | inline pose operator * (const pose & a, const pose & b) { return {a.orientation * b.orientation, a * b.position}; } 24 | inline pose inverse(const pose & a) { auto inv = transpose(a.orientation); return {inv, inv * a.position * -1}; } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /sdk/include/rs/utils/self_releasing_array_data_releaser.h: -------------------------------------------------------------------------------- 1 | // License: Apache 2.0. See LICENSE file in root directory. 2 | // Copyright(c) 2016 Intel Corporation. All Rights Reserved. 3 | 4 | /** 5 | * \file self_releasing_array_data_releaser.h 6 | * @brief Describes the \c rs::utils::self_releasing_array_data_releaser class. 7 | */ 8 | 9 | #pragma once 10 | #include "rs/utils/release_self_base.h" 11 | #include "rs/core/release_interface.h" 12 | 13 | namespace rs 14 | { 15 | namespace utils 16 | { 17 | /** 18 | * 19 | * @brief Array deallocation memory management class. 20 | * 21 | * A buffer releaser implementation that manages a simple array deallocation and its own memory deallocation. 22 | * When release is called, it deletes the provided data array using delete[] and itself using the 23 | * \c release_self_base class. 24 | */ 25 | class self_releasing_array_data_releaser : public release_self_base 26 | { 27 | public: 28 | /** 29 | * @brief Constructor 30 | * @param[in] data Allocated data array 31 | */ 32 | self_releasing_array_data_releaser(uint8_t* data) :data(data) {} 33 | 34 | /** 35 | * @brief Deallocating the data array provided in the constructor using operator delete [] and itself using \c release_self_base class. 36 | * @return int Number of instances 37 | */ 38 | int release() const override 39 | { 40 | if(data) 41 | { 42 | delete [] data; 43 | } 44 | return release_self_base::release(); //object destructed, return immediately 45 | } 46 | protected: 47 | ~self_releasing_array_data_releaser() {} 48 | private: 49 | uint8_t* data; 50 | }; 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /sdk/src/core/pipeline/config_util.h: -------------------------------------------------------------------------------- 1 | // License: Apache 2.0. See LICENSE file in root directory. 2 | // Copyright(c) 2016 Intel Corporation. All Rights Reserved. 3 | 4 | #pragma once 5 | #include 6 | #include "rs/core/video_module_interface.h" 7 | 8 | #ifdef WIN32 9 | #ifdef realsense_pipeline_EXPORTS 10 | #define DLL_EXPORT __declspec(dllexport) 11 | #else 12 | #define DLL_EXPORT __declspec(dllimport) 13 | #endif /* realsense_pipeline_EXPORTS */ 14 | #else /* defined (WIN32) */ 15 | #define DLL_EXPORT 16 | #endif 17 | 18 | namespace rs 19 | { 20 | namespace core 21 | { 22 | class DLL_EXPORT config_util 23 | { 24 | public: 25 | config_util(const config_util&) = delete; 26 | config_util& operator=(const config_util&) = delete; 27 | 28 | static void generete_matching_supersets(const std::vector>& groups, 29 | std::vector &matching_supersets); 30 | 31 | static bool is_config_empty(const video_module_interface::supported_module_config & config); 32 | 33 | private: 34 | config_util(){} 35 | 36 | static void recursive_cartesian_multiplicity(const std::vector > &groups, 37 | const uint32_t group_index, 38 | const std::vector &combination_prefix, 39 | std::vector>& combinations); 40 | 41 | static bool can_flatten_to_superset(const std::vector& combination, 42 | video_module_interface::supported_module_config &matching_supersets); 43 | 44 | }; 45 | } 46 | } 47 | 48 | -------------------------------------------------------------------------------- /sdk/src/core/pipeline/device_manager.h: -------------------------------------------------------------------------------- 1 | // License: Apache 2.0. See LICENSE file in root directory. 2 | // Copyright(c) 2016 Intel Corporation. All Rights Reserved. 3 | 4 | #pragma once 5 | #include 6 | #include 7 | #include 8 | #include "rs/core/correlated_sample_set.h" 9 | #include "device_config_guard.h" 10 | #include "device_streaming_guard.h" 11 | 12 | namespace rs 13 | { 14 | namespace core 15 | { 16 | class device_manager 17 | { 18 | public: 19 | device_manager(rs::device * device, 20 | const video_module_interface::supported_module_config & config, 21 | std::function sample_set)> non_blocking_notify_sample); 22 | 23 | device_manager(const device_manager & other) = delete; 24 | device_manager & operator=(const device_manager & other) = delete; 25 | 26 | void start(); 27 | void stop(); 28 | void query_current_config(video_module_interface::actual_module_config & current_config) const; 29 | rs::device * get_underlying_device(); 30 | const video_module_interface::actual_module_config create_actual_config_from_supported_config( 31 | const video_module_interface::supported_module_config & supported_config) const; 32 | 33 | virtual ~device_manager(); 34 | private: 35 | rs::device * m_device; 36 | video_module_interface::actual_module_config m_actual_config; 37 | 38 | std::unique_ptr m_device_streaming_guard; 39 | std::unique_ptr m_device_config_guard; 40 | rs::utils::unique_ptr m_projection; 41 | 42 | bool is_there_a_satisfying_device_mode(const video_module_interface::supported_module_config& given_config, video_module_interface::actual_module_config &actual_config) const; 43 | bool does_config_contains_valid_source_type(const video_module_interface::actual_module_config &config, source &source_type) const; 44 | }; 45 | } 46 | } 47 | 48 | -------------------------------------------------------------------------------- /sdk/include/rs/core/context.h: -------------------------------------------------------------------------------- 1 | // License: Apache 2.0. See LICENSE file in root directory. 2 | // Copyright(c) 2016 Intel Corporation. All Rights Reserved. 3 | 4 | /** 5 | * \file context.h 6 | * @brief Describes the \c rs::core::context class. 7 | */ 8 | 9 | #pragma once 10 | #include 11 | #include "context_interface.h" 12 | 13 | namespace rs 14 | { 15 | namespace core 16 | { 17 | /** 18 | * @brief Implements \c rs::core::context_interface for live camera streaming. 19 | * 20 | * See the interface class for more details. 21 | */ 22 | class context : public context_interface 23 | { 24 | public: 25 | context() {} 26 | virtual ~context() {} 27 | 28 | /** 29 | * @brief Gets the device count owned by this context. 30 | * 31 | * The number of devices do not change throughout the context lifespan. 32 | * The output of this method should be used for enumerating the devices using \c get_device(). 33 | * @return int Number of devices 34 | */ 35 | virtual int get_device_count() const override 36 | { 37 | return m_context.get_device_count(); 38 | } 39 | 40 | /** 41 | * @brief Retrieves a device by index. 42 | * 43 | * The available devices and their indices do not change throughout the context lifespan. If a device is connected or disconnected 44 | * in the context lifespan, the device list does not change, and may expose disconnected devices, or not reflect connected devices. 45 | * @param[in] index Zero-based index of device to retrieve 46 | * @return rs::device* Requested device 47 | */ 48 | virtual rs::device * get_device(int index) override 49 | { 50 | return m_context.get_device(index); 51 | } 52 | 53 | protected: 54 | rs::context m_context; /**< the actual libRealSense context. */ 55 | context(const context &) = delete; 56 | context & operator = (const context &) = delete; 57 | }; 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /sdk/src/cameras/compression/encoder.cpp: -------------------------------------------------------------------------------- 1 | // License: Apache 2.0. See LICENSE file in root directory. 2 | // Copyright(c) 2016 Intel Corporation. All Rights Reserved. 3 | 4 | #include "encoder.h" 5 | #include "lz4_codec.h" 6 | #include "rs/utils/log_utils.h" 7 | 8 | namespace rs 9 | { 10 | namespace core 11 | { 12 | namespace compression 13 | { 14 | 15 | encoder::encoder() 16 | { 17 | 18 | } 19 | 20 | encoder::~encoder() 21 | { 22 | 23 | } 24 | 25 | file_types::compression_type encoder::get_compression_type(rs_stream stream) 26 | { 27 | if(m_codecs.find(stream) != m_codecs.end()) 28 | { 29 | auto codec = m_codecs.at(stream); 30 | return codec ? m_codecs[stream]->get_compression_type() : file_types::compression_type::none; 31 | } 32 | return file_types::compression_type::none; 33 | } 34 | 35 | file_types::compression_type encoder::compression_policy(rs_stream stream, rs_format format) 36 | { 37 | return file_types::compression_type::lz4; 38 | } 39 | 40 | void encoder::add_codec(rs_stream stream, rs_format format, record::compression_level compression_level) 41 | { 42 | if(m_codecs.find(stream) != m_codecs.end()) return; 43 | auto & codec = m_codecs[stream]; 44 | switch (compression_policy(stream, format)) 45 | { 46 | case file_types::compression_type::lz4: codec = std::shared_ptr(new lz4_codec(compression_level)); break; 47 | default: codec = nullptr; break; 48 | } 49 | } 50 | 51 | status encoder::encode_frame(file_types::frame_info &info, const uint8_t *input, uint8_t * output, uint32_t &output_size) 52 | { 53 | LOG_FUNC_SCOPE(); 54 | auto codec = m_codecs.at(info.stream); 55 | return codec ? m_codecs[info.stream]->encode(info, input, output, output_size) : status::status_feature_unsupported; 56 | } 57 | } 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /sdk/src/tools/projection_tool/projection_cmd_util.h: -------------------------------------------------------------------------------- 1 | // License: Apache 2.0. See LICENSE file in root directory. 2 | // Copyright(c) 2016 Intel Corporation. All Rights Reserved. 3 | 4 | #include "types.h" 5 | #include "basic_cmd_util.h" 6 | 7 | /** @brief The projection_cmd_util class 8 | * 9 | * Command line utility with options suitable for projection tool usage. 10 | * Derived from basic_cmd_util to use its public methods. 11 | */ 12 | class projection_cmd_util : public rs::utils::basic_cmd_util 13 | { 14 | public: 15 | /** @brief projection_cmd_util 16 | * 17 | * Constructor. Sets the relevant command line options. 18 | */ 19 | projection_cmd_util() : 20 | basic_cmd_util(false) 21 | { 22 | add_option("-h --h -help --help -?", "show help"); 23 | 24 | add_multi_args_option_safe("-dconf", "set depth profile - [--]", 3, '-', "", "628-468-30"); 25 | add_single_arg_option("-dpf", "set depth streams pixel format", "z16", "z16"); 26 | 27 | add_multi_args_option_safe("-cconf", "set color stream profile - [--]", 3, '-', "", "640-480-30"); 28 | add_single_arg_option("-cpf", "set color stream pixel format", "rgb8 rgba8 bgr8 bgra8", "rgba8"); 29 | 30 | add_multi_args_option_safe("-fconf", "set fisheye stream profile - [--]", 3, '-', "", "640-480-30"); 31 | add_single_arg_option("-fpf", "set fisheye stream pixel format", "raw8", "raw8"); 32 | 33 | add_single_arg_option("-pb -playback", "set playback file path"); 34 | 35 | set_usage_example("-cconf 640-480-30 -cpf rgb8\n\n" 36 | "The following command will configure the camera to\n" 37 | "show color stream of VGA resolution at 30 frames\n" 38 | "per second in rgb8 pixel format.\n" 39 | "Color, Depth and Fisheye streams MUST be available in case of prerecorded clips.\n" 40 | "Color, Depth, Fisheye streams and World image are ALWAYS shown.\n" 41 | "Other projection-generated images can be also viewed using specific keyboard keys.\n" 42 | "GUI help message is always shown in the main window.\n"); 43 | } 44 | }; 45 | -------------------------------------------------------------------------------- /cmake_includes/config_windows.cmake: -------------------------------------------------------------------------------- 1 | #if your current path of librealsense folder isn't C:/realsense/3rdparty/librealsense, please update it 2 | if(NOT DEFINED LIBREALSENSE_DIR) 3 | set(LIBREALSENSE_DIR "C:/realsense/3rdparty/librealsense") 4 | endif(NOT DEFINED LIBREALSENSE_DIR) 5 | 6 | set(LIBREALSENSE_INCLUDE_PATH ${LIBREALSENSE_DIR}/examples/third_party/glfw/include/ ${LIBREALSENSE_DIR}/include/) 7 | set(LIBREALSENSE_LIB_PATH ${LIBREALSENSE_DIR}/ ${LIBREALSENSE_DIR}/bin/x64/ ${LIBREALSENSE_DIR}/examples/third_party/glfw/msvc140/obj/Release-x64) 8 | 9 | #if your current path of opencv folder isn't C:/realsense/3rdparty/opencv, please update it 10 | if(NOT DEFINED OPENCV_DIR) 11 | set(OPENCV_DIR "C:/realsense/3rdparty/opencv") 12 | endif(NOT DEFINED OPENCV_DIR) 13 | 14 | set(OPENCV_INCLUDE_PATH ${OPENCV_DIR}/build/include/) 15 | set(OPENCV_LIB_PATH ${OPENCV_DIR}/build/x64/vc14/lib ${OPENCV_DIR}/lib/Release) 16 | 17 | 18 | #if your current path of log4cxx folder isn't C:/realsense/3rdparty/apache-log4cxx-0.10.0, please update it 19 | if(NOT DEFINED LOG4CXX_DIR) 20 | set(LOG4CXX_DIR "C:/realsense/3rdparty/apache-log4cxx-0.10.0") 21 | endif(NOT DEFINED LOG4CXX_DIR) 22 | set(LOG4CXX_INCLUDE_PATH ${LOG4CXX_DIR}/src/main/include/) 23 | 24 | 25 | #if your current path of gtest folder isn't C:/realsense/3rdparty/gtest, please update it 26 | if(NOT DEFINED GTEST_DIR) 27 | set(GTEST_DIR "C:/realsense/3rdparty/gtest") 28 | endif(NOT DEFINED GTEST_DIR) 29 | set(GTEST_INCLUDE_PATH ${GTEST_DIR}/include/) 30 | set(GTEST_LIB_PATH ${GTEST_DIR}/${CMAKE_BUILD_TYPE}) 31 | 32 | #if your current path of lz4 folder isn't C:/realsense/3rdparty/lz4, please update it 33 | if(NOT DEFINED LZ4_DIR) 34 | set(LZ4_DIR "C:/realsense/3rdparty/lz4") 35 | endif(NOT DEFINED LZ4_DIR) 36 | set(LZ4_INCLUDE_PATH ${LZ4_DIR}/lib/) 37 | set(LZ4_LIB_PATH ${LZ4_DIR}/visual/VS2010/bin/x64_Release/) 38 | 39 | set(COMPILE_DEFINITIONS /W3) 40 | set(OPENCV_VER 310) 41 | set(OPENGL_LIBS OpenGL32) 42 | set(GLFW_LIBS glfw3) 43 | set(SHLWAPI Shlwapi) 44 | set(GTEST_LIBS gtest gtest_main-md) 45 | set(LZ4 liblz4_x64) 46 | 47 | include_directories(${OPENCV_INCLUDE_PATH} ${OPENCV_DIR} ${LIBREALSENSE_INCLUDE_PATH} ${LOG4CXX_INCLUDE_PATH} ${GTEST_INCLUDE_PATH} ${LZ4_INCLUDE_PATH}) 48 | link_directories(${LIBREALSENSE_LIB_PATH} ${OPENCV_LIB_PATH} ${GTEST_LIB_PATH} ${LZ4_LIB_PATH}) -------------------------------------------------------------------------------- /sdk/src/core/image/custom_image.h: -------------------------------------------------------------------------------- 1 | // License: Apache 2.0. See LICENSE file in root directory. 2 | // Copyright(c) 2016 Intel Corporation. All Rights Reserved. 3 | 4 | #pragma once 5 | #include "image_base.h" 6 | 7 | namespace rs 8 | { 9 | namespace core 10 | { 11 | /** 12 | * @brief The custom_image class 13 | * implements the sdk image interface for a customized image, where the user provides an allocated image data and 14 | * an optional image deallocation method with the data_releaser_interface, if no deallocation method is provided, 15 | * it assumes that the user is handling memory deallocation outside of the custom image class. 16 | * see complete image documantation in the interface declaration. 17 | */ 18 | class custom_image : public image_base 19 | { 20 | public: 21 | custom_image(const custom_image &) = delete; 22 | custom_image & operator = (const custom_image &) = delete; 23 | 24 | custom_image(image_info * info, 25 | const void * data, 26 | stream_type stream, 27 | image_interface::flag flags, 28 | double time_stamp, 29 | rs::core::timestamp_domain time_stamp_domain, 30 | uint64_t frame_number, 31 | rs::utils::unique_ptr data_releaser); 32 | image_info query_info(void) const override; 33 | double query_time_stamp(void) const override; 34 | timestamp_domain query_time_stamp_domain(void) const override; 35 | flag query_flags(void) const override; 36 | const void * query_data(void) const override; 37 | stream_type query_stream_type() const override; 38 | uint64_t query_frame_number() const override; 39 | protected: 40 | image_info m_info; 41 | const void * m_data; 42 | double m_time_stamp; 43 | timestamp_domain m_time_stamp_domain; 44 | image_interface::flag m_flags; 45 | stream_type m_stream; 46 | uint64_t m_frame_number; 47 | rs::utils::unique_ptr m_data_releaser; 48 | virtual ~custom_image(); 49 | }; 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /sdk/src/include/basic_cmd_util.h: -------------------------------------------------------------------------------- 1 | // License: Apache 2.0. See LICENSE file in root directory. 2 | // Copyright(c) 2016 Intel Corporation. All Rights Reserved. 3 | 4 | #pragma once 5 | #include "cmd_base.h" 6 | #include "rs/core/types.h" 7 | #include "rs/record/record_device.h" 8 | #include "rs/core/image_interface.h" 9 | 10 | #ifdef WIN32 11 | #ifdef realsense_cl_util_EXPORTS 12 | #define DLL_EXPORT __declspec(dllexport) 13 | #else 14 | #define DLL_EXPORT __declspec(dllimport) 15 | #endif /* realsense_cl_util_EXPORTS */ 16 | #else /* defined (WIN32) */ 17 | #define DLL_EXPORT 18 | #endif 19 | 20 | namespace rs 21 | { 22 | namespace utils 23 | { 24 | enum streaming_mode 25 | { 26 | live, 27 | record, 28 | playback 29 | }; 30 | 31 | class DLL_EXPORT basic_cmd_util : public cmd_base 32 | { 33 | public: 34 | basic_cmd_util(const bool add_basic_options = true); 35 | std::vector get_enabled_streams(); 36 | int get_stream_width(core::stream_type stream); 37 | int get_stream_height(core::stream_type stream); 38 | int get_stream_fps(core::stream_type stream); 39 | rs::record::compression_level get_compression_level(core::stream_type stream); 40 | core::pixel_format get_stream_pixel_format(core::stream_type stream); 41 | bool is_stream_profile_available(core::stream_type stream); 42 | bool is_stream_pixel_format_available(core::stream_type stream); 43 | int get_capture_time(); 44 | size_t get_number_of_frames(); 45 | bool is_real_time(); 46 | bool is_print_file_info(); 47 | bool is_rendering_enabled(); 48 | bool is_motion_enabled(); 49 | streaming_mode get_streaming_mode(); 50 | std::string get_file_path(streaming_mode sm); 51 | std::string get_file_info(); 52 | private: 53 | struct stream_profile 54 | { 55 | int width; 56 | int height; 57 | core::pixel_format format; 58 | int fps; 59 | }; 60 | bool is_number(std::string str); 61 | bool get_profile_data(rs::core::stream_type stream, stream_profile &profile); 62 | }; 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /sdk/src/core/pipeline/pipeline_async.cpp: -------------------------------------------------------------------------------- 1 | // License: Apache 2.0. See LICENSE file in root directory. 2 | // Copyright(c) 2016 Intel Corporation. All Rights Reserved. 3 | 4 | #include "rs/core/pipeline_async.h" 5 | #include "pipeline_async_impl.h" 6 | #include "rs_sdk_version.h" 7 | 8 | using namespace std; 9 | using namespace rs::utils; 10 | 11 | namespace rs 12 | { 13 | namespace core 14 | { 15 | pipeline_async::pipeline_async():m_pimpl(new pipeline_async_impl()){} 16 | 17 | pipeline_async::pipeline_async(const testing_mode mode, const char * file_path): 18 | m_pimpl(new pipeline_async_impl(mode, file_path)) 19 | {} 20 | 21 | status pipeline_async::add_cv_module(video_module_interface *cv_module) 22 | { 23 | return m_pimpl->add_cv_module(cv_module); 24 | } 25 | 26 | status pipeline_async::query_cv_module(uint32_t index, video_module_interface **cv_module) const 27 | { 28 | return m_pimpl->query_cv_module(index, cv_module); 29 | } 30 | 31 | status pipeline_async::query_default_config(uint32_t index, video_module_interface::supported_module_config &default_config) const 32 | { 33 | return m_pimpl->query_default_config(index, default_config); 34 | } 35 | 36 | status pipeline_async::set_config(const video_module_interface::supported_module_config &config) 37 | { 38 | return m_pimpl->set_config(config); 39 | } 40 | 41 | status pipeline_async::query_current_config(video_module_interface::actual_module_config ¤t_config) const 42 | { 43 | return m_pimpl->query_current_config(current_config); 44 | } 45 | 46 | status pipeline_async::start(callback_handler * app_callbacks_handler) 47 | { 48 | return m_pimpl->start(app_callbacks_handler); 49 | } 50 | 51 | status pipeline_async::stop() 52 | { 53 | return m_pimpl->stop(); 54 | } 55 | 56 | status pipeline_async::reset() 57 | { 58 | return m_pimpl->reset(); 59 | } 60 | 61 | rs::device * pipeline_async::get_device() 62 | { 63 | return m_pimpl->get_device(); 64 | } 65 | 66 | pipeline_async::~pipeline_async() 67 | { 68 | delete m_pimpl; 69 | } 70 | } 71 | } 72 | 73 | -------------------------------------------------------------------------------- /sdk/include/rs/record/record_context.h: -------------------------------------------------------------------------------- 1 | // License: Apache 2.0. See LICENSE file in root directory. 2 | // Copyright(c) 2016 Intel Corporation. All Rights Reserved. 3 | 4 | /** 5 | * \file record_context.h 6 | * @brief Describes the \c rs::record::context class. 7 | */ 8 | 9 | #pragma once 10 | #include 11 | #include "rs/core/context.h" 12 | 13 | #ifdef WIN32 14 | #ifdef realsense_record_EXPORTS 15 | #define DLL_EXPORT __declspec(dllexport) 16 | #else 17 | #define DLL_EXPORT __declspec(dllimport) 18 | #endif /* realsense_record_EXPORTS */ 19 | #else /* defined (WIN32) */ 20 | #define DLL_EXPORT 21 | #endif 22 | 23 | namespace rs 24 | { 25 | namespace record 26 | { 27 | class device; 28 | /** 29 | * @brief Extends \c rs::core::context for capturing data to file during live camera streaming. 30 | * 31 | * See the interface class for more details. 32 | */ 33 | class DLL_EXPORT context : public rs::core::context 34 | { 35 | public: 36 | context(const char * file_path); 37 | virtual ~context(); 38 | 39 | /** 40 | * @brief Retrieves a device by index. 41 | * 42 | * The available devices and their indices do not change throughout the context lifespan. If a device is connected or disconnected 43 | * in the context lifespan, the devices list will not change, and may expose disconnected devices, or not reflect connected devices. 44 | * @param[in] index Zero-based index of device to retrieve 45 | * @return rs::device* Requested device 46 | */ 47 | rs::device * get_device(int index) override; 48 | 49 | /** 50 | * @brief Returns a record device by the given index. Makes all record capabilities available. 51 | * 52 | * The method returns \c rs::record::device, to provide access to all record capabilities, which extend the basic device functionality. 53 | * @param[in] index Zero-based index of device to retrieve 54 | * @return record::device* Requested device 55 | */ 56 | device * get_record_device(int index); 57 | 58 | private: 59 | context(const context& cxt) = delete; 60 | context& operator=(const context& cxt) = delete; 61 | 62 | rs_device ** m_devices; 63 | }; 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /sdk/include/rs/core/context_interface.h: -------------------------------------------------------------------------------- 1 | // License: Apache 2.0. See LICENSE file in root directory. 2 | // Copyright(c) 2016 Intel Corporation. All Rights Reserved. 3 | 4 | /** 5 | * \file context_interface.h 6 | * @brief Describes the \c rs::core::context_interface class. 7 | */ 8 | 9 | #pragma once 10 | #include 11 | 12 | namespace rs 13 | { 14 | namespace core 15 | { 16 | /** 17 | * @brief Provides the ability to use the same application with minimal changes and to access a camera while recording or playing back a recorded file. 18 | * 19 | * The changes are encapsulated in the context and device construction 20 | * when creating the relevant implementation class. 21 | * The context object owns the devices lifetime. It is responsible for creating and releasing its devices, and must outlive the lifespan of the devices. 22 | * The context provides access only to devices, which are available upon context creation. If a device is connected or disconnected 23 | * after the context is created, the device list will not change, and will not reflect the actual connected devices list. 24 | */ 25 | class context_interface 26 | { 27 | public: 28 | virtual ~context_interface() {} 29 | /** 30 | * @brief Gets the device count owned by this context. 31 | * 32 | * The number of devices owned by the context depends on the specific context type. 33 | * The number of devices does not change throughout the context lifespan. 34 | * The output of this method should be used for enumerating the devices using \c get_device(). 35 | * @return int Number of devices 36 | */ 37 | virtual int get_device_count() const = 0; 38 | 39 | /** 40 | * @brief Retrieves a device by index. 41 | * 42 | * The available devices and their index do not change throughout the context lifespan. If a device is connected or disconnected 43 | * in the context lifespan, the devices list will not change, and may expose disconnected devices, or not reflect connected devices. 44 | * @param[in] index Zero-based index of device to retrieve 45 | * @return rs::device * Requested device 46 | */ 47 | virtual rs::device * get_device(int index) = 0; 48 | }; 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /sdk/src/utilities/logger/rslog.properties: -------------------------------------------------------------------------------- 1 | # Default level=INFO and output=DEBUGVIEW 2 | # includes all logs 3 | 4 | ################################################################################### 5 | ################################ FACE ######################################### 6 | ################################################################################### 7 | # Logging Levels: ALL < DEBUG < INFO < WARN < ERROR < FATAL < OFF 8 | # Set Loggers and Level filtering (for example: INFO will show INFO,WARN,ERROR,...) 9 | 10 | 11 | #File should be absolute path, no env. variables allowed 12 | 13 | log4j.rootLogger = DEBUG, ROOT_FILE 14 | log4j.appender.ROOT_FILE=org.apache.log4j.RollingFileAppender 15 | log4j.appender.ROOT_FILE.File=rssdk.log 16 | log4j.appender.ROOT_FILE.MaxFileSize=1MB 17 | log4j.appender.ROOT_FILE.ImmediateFlush=true 18 | log4j.appender.ROOT_FILE.MaxBackupIndex=10 19 | log4j.appender.ROOT_FILE.Append=false 20 | log4j.appender.ROOT_FILE.layout=org.apache.log4j.PatternLayout 21 | log4j.appender.ROOT_FILE.layout.ConversionPattern=%d %c %25F:%8L %25M %10p - %m%n 22 | 23 | log4j.logger.test_log = DEBUG, TEST_FILE 24 | 25 | ######################################################################### Appenders 26 | # Appender 'FILE' writes to file rssdk.log, max 100KB with 1 backup file 27 | # Default Log file 28 | log4j.appender.TEST_FILE=org.apache.log4j.RollingFileAppender 29 | log4j.appender.TEST_FILE.File=test_log.log 30 | log4j.appender.TEST_FILE.MaxFileSize=1MB 31 | log4j.appender.TEST_FILE.ImmediateFlush=true 32 | log4j.appender.TEST_FILE.MaxBackupIndex=10 33 | log4j.appender.TEST_FILE.Append=true 34 | log4j.appender.TEST_FILE.layout=org.apache.log4j.PatternLayout 35 | log4j.appender.TEST_FILE.layout.ConversionPattern=%d %c %25F:%8L %25M %10p - %m%n 36 | 37 | log4j.logger.GENLogger = DEBUG, TEST_FILE 38 | 39 | ######################################################################### Appenders 40 | # Appender 'FILE' writes to file rssdk.log, max 100KB with 1 backup file 41 | # Default Log file 42 | log4j.appender.TEST_FILE=org.apache.log4j.RollingFileAppender 43 | log4j.appender.TEST_FILE.File=genlogger.log 44 | log4j.appender.TEST_FILE.MaxFileSize=1MB 45 | log4j.appender.TEST_FILE.ImmediateFlush=true 46 | log4j.appender.TEST_FILE.MaxBackupIndex=10 47 | log4j.appender.TEST_FILE.Append=true 48 | log4j.appender.TEST_FILE.layout=org.apache.log4j.PatternLayout 49 | log4j.appender.TEST_FILE.layout.ConversionPattern=%d %c %25F:%8L %25M %10p - %m%n 50 | -------------------------------------------------------------------------------- /sdk/src/core/pipeline/async_samples_consumer.cpp: -------------------------------------------------------------------------------- 1 | // License: Apache 2.0. See LICENSE file in root directory. 2 | // Copyright(c) 2016 Intel Corporation. All Rights Reserved. 3 | 4 | #include "async_samples_consumer.h" 5 | 6 | #include 7 | 8 | using namespace rs::utils; 9 | 10 | namespace rs 11 | { 12 | namespace core 13 | { 14 | async_samples_consumer::async_samples_consumer(pipeline_async_interface::callback_handler *app_callbacks_handler, 15 | video_module_interface * cv_module, 16 | const video_module_interface::actual_module_config &module_config, 17 | const video_module_interface::supported_module_config::time_sync_mode time_sync_mode): 18 | samples_consumer_base(module_config, time_sync_mode), 19 | m_app_callbacks_handler(app_callbacks_handler), 20 | m_cv_module(cv_module) 21 | { 22 | m_cv_module->register_event_handler(this); 23 | } 24 | 25 | void async_samples_consumer::on_complete_sample_set(std::shared_ptr ready_sample_set) 26 | { 27 | status process_sample_set_status = m_cv_module->process_sample_set(*ready_sample_set); 28 | if(process_sample_set_status < status_no_error) 29 | { 30 | LOG_ERROR("failed async sample process"); 31 | if(m_app_callbacks_handler) 32 | { 33 | m_app_callbacks_handler->on_error(process_sample_set_status); 34 | } 35 | return; 36 | } 37 | } 38 | 39 | void async_samples_consumer::module_output_ready(video_module_interface *sender, correlated_sample_set *sample) 40 | { 41 | if(m_app_callbacks_handler) 42 | { 43 | try 44 | { 45 | m_app_callbacks_handler->on_cv_module_process_complete(m_cv_module); 46 | } 47 | catch(const std::exception & ex) 48 | { 49 | LOG_ERROR("app callbacks handler throw ex" << ex.what()); 50 | throw ex; 51 | } 52 | } 53 | } 54 | 55 | async_samples_consumer::~async_samples_consumer() 56 | { 57 | m_cv_module->unregister_event_handler(this); 58 | } 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /sdk/include/rs/utils/ref_count_base.h: -------------------------------------------------------------------------------- 1 | // License: Apache 2.0. See LICENSE file in root directory. 2 | // Copyright(c) 2016 Intel Corporation. All Rights Reserved. 3 | 4 | /** 5 | * \file ref_count_base.h 6 | * @brief Describes the \c rs::utils::ref_count_base template. 7 | **/ 8 | 9 | #pragma once 10 | #include 11 | 12 | namespace rs 13 | { 14 | namespace utils 15 | { 16 | /** 17 | * @brief Implements atomic reference counting operations. 18 | */ 19 | template 20 | class ref_count_base : public T 21 | { 22 | public: 23 | ref_count_base(const ref_count_base &) = delete; 24 | ref_count_base& operator= (const ref_count_base &) = delete; 25 | ref_count_base(ref_count_base &&) = delete; 26 | ref_count_base& operator= (ref_count_base &&) = delete; 27 | 28 | /** 29 | * @brief Constructor: Any reference counted inheriting class is initialized with 1. 30 | */ 31 | ref_count_base() : m_ref_count(1) {} 32 | 33 | /** 34 | * @brief Increments the reference count by 1. 35 | * @return Reference count after the method operation 36 | */ 37 | virtual int add_ref() const override 38 | { 39 | return ++m_ref_count; 40 | } 41 | 42 | /** 43 | * @brief Decrements the reference count by 1; if this is the last instance, deletes this instance. 44 | * @return Reference count after the method operation 45 | */ 46 | virtual int release() const override 47 | { 48 | int post_fetched_ref_count = --m_ref_count; 49 | if(post_fetched_ref_count == 0) 50 | { 51 | delete(this); 52 | return 0; // must return after the object's memory returned to the os. 53 | } 54 | return post_fetched_ref_count; 55 | } 56 | 57 | /** 58 | * @brief Gets the current reference count. 59 | * @return int Count 60 | */ 61 | virtual int ref_count() const override 62 | { 63 | return m_ref_count; 64 | } 65 | protected: 66 | virtual ~ref_count_base() {} 67 | private: 68 | mutable std::atomic m_ref_count; 69 | }; 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /sdk/src/core/image/metadata.cpp: -------------------------------------------------------------------------------- 1 | // License: Apache 2.0. See LICENSE file in root directory. 2 | // Copyright(c) 2016 Intel Corporation. All Rights Reserved. 3 | 4 | #include 5 | #include 6 | #include "metadata.h" 7 | 8 | namespace rs 9 | { 10 | namespace core 11 | { 12 | bool metadata::is_metadata_available(metadata_type id) const 13 | { 14 | std::lock_guard lock(m_mutex); 15 | return exists(id); 16 | } 17 | 18 | uint32_t metadata::query_buffer_size(metadata_type id) const 19 | { 20 | return get_metadata(id, nullptr); 21 | } 22 | 23 | uint32_t metadata::get_metadata(metadata_type id, uint8_t* buffer) const 24 | { 25 | std::lock_guard lock(m_mutex); 26 | 27 | if(!exists(id)) 28 | { 29 | return 0; 30 | } 31 | 32 | const std::vector& md = m_data.at(id); 33 | int32_t buffer_size = static_cast(md.size()); 34 | 35 | if(buffer != nullptr) 36 | { 37 | std::memcpy(buffer, md.data(), buffer_size); 38 | } 39 | 40 | return buffer_size; 41 | } 42 | 43 | status metadata::add_metadata(metadata_type id, const uint8_t* buffer, uint32_t size) 44 | { 45 | std::lock_guard lock(m_mutex); 46 | 47 | if(buffer == nullptr) 48 | { 49 | return status_handle_invalid; 50 | } 51 | 52 | if(size == 0) 53 | { 54 | return status_invalid_argument; 55 | } 56 | 57 | if(exists(id)) 58 | { 59 | return status_key_already_exists; 60 | } 61 | 62 | m_data.emplace(id, std::vector(buffer, buffer + size)); 63 | return status::status_no_error; 64 | } 65 | 66 | status metadata::remove_metadata(metadata_type id) 67 | { 68 | std::lock_guard lock(m_mutex); 69 | 70 | if(!exists(id)) 71 | { 72 | return status::status_item_unavailable; 73 | } 74 | 75 | m_data.erase(id); 76 | return status::status_no_error; 77 | } 78 | 79 | bool metadata::exists(metadata_type id) const 80 | { 81 | return m_data.find(id) != m_data.end(); 82 | } 83 | } 84 | } 85 | 86 | 87 | -------------------------------------------------------------------------------- /sdk/include/rs/utils/smart_ptr_helpers.h: -------------------------------------------------------------------------------- 1 | // License: Apache 2.0. See LICENSE file in root directory. 2 | // Copyright(c) 2016 Intel Corporation. All Rights Reserved. 3 | 4 | /** 5 | * \file smart_ptr_helpers.h 6 | * @brief Describes helper methods that provide shared pointers and unique pointers with a customized deleter. 7 | */ 8 | 9 | #pragma once 10 | #include 11 | 12 | // helper functions providing shared_ptr and unique_ptr with a customized deleter. 13 | 14 | namespace rs 15 | { 16 | namespace utils 17 | { 18 | /** 19 | * @brief Customized deleter which calls release upon the object destruction. 20 | */ 21 | template 22 | struct releaser 23 | { 24 | void operator()(T *p) const { if (p) p->release(); } 25 | }; 26 | 27 | /** 28 | * @brief 29 | * Uses \c unique_ptr under the \c rs::utils namespace, containing a customized deleter which calls the object release method. 30 | */ 31 | template 32 | using unique_ptr = std::unique_ptr>; 33 | 34 | 35 | /** 36 | * @brief 37 | * Wraps the given pointer with \c unique_ptr with the customized deleter. 38 | */ 39 | template 40 | inline unique_ptr get_unique_ptr_with_releaser(T* object) 41 | { 42 | return unique_ptr(object); 43 | } 44 | 45 | /** 46 | * @brief 47 | * Wraps the given const pointer with \c unique_ptr with the customized deleter. 48 | */ 49 | template 50 | inline unique_ptr get_unique_ptr_with_releaser(const T* object) 51 | { 52 | return unique_ptr(object); 53 | } 54 | 55 | /** 56 | * @brief 57 | * Wraps the given pointer with \c shared_ptr with the customized deleter. 58 | */ 59 | template 60 | inline std::shared_ptr get_shared_ptr_with_releaser(T* object) 61 | { 62 | return std::move(get_unique_ptr_with_releaser(object)); 63 | } 64 | 65 | /** 66 | * @brief 67 | * Wraps the given const pointer with \c shared_ptr with the customized deleter. 68 | */ 69 | template 70 | inline std::shared_ptr get_shared_ptr_with_releaser(const T* object) 71 | { 72 | return std::move(get_unique_ptr_with_releaser(object)); 73 | } 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /sdk/src/cameras/playback/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 2.8.9) 2 | project(realsense_playback) 3 | 4 | #------------------------------------------------------------------------------------ 5 | #Include 6 | include_directories( 7 | . 8 | .. 9 | include 10 | ${ROOT_DIR}/include/rs/core 11 | ) 12 | 13 | #------------------------------------------------------------------------------------ 14 | #Source Files 15 | set(SOURCE_FILES_BASE 16 | disk_read_base.cpp 17 | playback_context.cpp 18 | playback_device_impl.cpp 19 | rs_stream_impl.cpp 20 | disk_read.cpp 21 | include/disk_read.h 22 | include/rs_stream_impl.h 23 | include/disk_read_factory.h 24 | include/disk_read_base.h 25 | include/disk_read_interface.h 26 | include/playback_device_impl.h 27 | include/playback_device_interface.h 28 | ${ROOT_DIR}/include/rs/core/context.h 29 | ${ROOT_DIR}/include/rs/playback/playback_device.h 30 | ${ROOT_DIR}/include/rs/playback/playback_context.h 31 | ) 32 | 33 | set(SOURCE_FILES_LINUX 34 | include/linux/v1/file_types.h 35 | include/linux/v1/disk_read.h 36 | include/linux/v1/conversions.h 37 | linux/v1/disk_read.cpp 38 | ) 39 | 40 | set(SOURCE_FILES_WINDOWS 41 | include/windows/v10/conversions.h 42 | include/windows/v10/file_types.h 43 | include/windows/v10/disk_read.h 44 | windows/v10/conversions.cpp 45 | windows/v10/disk_read.cpp 46 | ) 47 | 48 | set(SOURCE_FILES_FILE 49 | ${ROOT_DIR}/src/cameras/include/file.h 50 | ${ROOT_DIR}/src/cameras/include/linear_algebra.h 51 | ${ROOT_DIR}/src/cameras/include/file_types.h 52 | ) 53 | 54 | #Building Library 55 | add_library(${PROJECT_NAME} ${SDK_LIB_TYPE} 56 | ${SOURCE_FILES_BASE} 57 | ${SOURCE_FILES_LINUX} 58 | ${SOURCE_FILES_WINDOWS} 59 | ${SOURCE_FILES_FILE} 60 | ) 61 | 62 | #------------------------------------------------------------------------------------ 63 | #LINK_LIBRARIES 64 | target_link_libraries(${PROJECT_NAME} 65 | realsense_compression 66 | realsense_log_utils 67 | ) 68 | 69 | #------------------------------------------------------------------------------------ 70 | #Dependencies 71 | add_dependencies(${PROJECT_NAME} 72 | realsense_compression 73 | realsense_log_utils 74 | ) 75 | 76 | set_target_properties(${PROJECT_NAME} PROPERTIES VERSION "${LIBVERSION}" SOVERSION "${LIBSOVERSION}") 77 | 78 | #------------------------------------------------------------------------------------ 79 | install(TARGETS ${PROJECT_NAME} DESTINATION lib) 80 | -------------------------------------------------------------------------------- /sdk/include/rs/playback/playback_context.h: -------------------------------------------------------------------------------- 1 | // License: Apache 2.0. See LICENSE file in root directory. 2 | // Copyright(c) 2016 Intel Corporation. All Rights Reserved. 3 | 4 | /** 5 | * \file playback_context.h 6 | * @brief Describes the \c rs::core::context class. 7 | */ 8 | 9 | #pragma once 10 | #include 11 | #include "rs/core/context.h" 12 | 13 | #ifdef WIN32 14 | #ifdef realsense_playback_EXPORTS 15 | #define DLL_EXPORT __declspec(dllexport) 16 | #else 17 | #define DLL_EXPORT __declspec(dllimport) 18 | #endif /* realsense_playback_EXPORTS */ 19 | #else /* defined (WIN32) */ 20 | #define DLL_EXPORT 21 | #endif 22 | 23 | namespace rs 24 | { 25 | namespace playback 26 | { 27 | class device; 28 | /** 29 | * @brief Implements \c rs::core::context_interface for playback from recorded files. 30 | * 31 | * See the interface class for more details. 32 | */ 33 | class DLL_EXPORT context : public rs::core::context_interface 34 | { 35 | public: 36 | context(const char * file_path); 37 | ~context(); 38 | 39 | /** 40 | * @brief Gets number of available playback devices. 41 | * 42 | * The playback context provides access to the single device that was recorded in the session. Therefore, this method always returns 1. 43 | * @return int Number of available devices 44 | */ 45 | int get_device_count() const override; 46 | 47 | /** 48 | * @brief Gets single playback device. 49 | * 50 | * The method returns \c rs::playback::device, down-casted to \c rs::device. 51 | * @param[in] index Zero-based index of device to retrieve 52 | * @return rs::device* Requested device 53 | */ 54 | rs::device * get_device(int index) override; 55 | 56 | /** 57 | * @brief Gets single playback device. 58 | * 59 | * The function returns \c rs::playback::device, to provide access to all playback capabilities, which extend the basic device functionality. 60 | * @return playback::device* Requested device. 61 | */ 62 | device * get_playback_device(); 63 | 64 | private: 65 | context(const context& cxt) = delete; 66 | context& operator=(const context& cxt) = delete; 67 | 68 | rs_device ** m_devices; 69 | bool m_init_status; 70 | }; 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /sdk/src/cameras/playback/include/windows/v10/conversions.h: -------------------------------------------------------------------------------- 1 | // License: Apache 2.0. See LICENSE file in root directory. 2 | // Copyright(c) 2016 Intel Corporation. All Rights Reserved. 3 | 4 | #pragma once 5 | #include 6 | #include 7 | #include "windows/v10/file_types.h" 8 | #include "include/file_types.h" 9 | #include "include/windows/projection_types.h" 10 | #include "status.h" 11 | #include "types.h" 12 | 13 | namespace rs 14 | { 15 | namespace playback 16 | { 17 | namespace windows 18 | { 19 | namespace v10 20 | { 21 | namespace conversions 22 | { 23 | uint64_t rssdk2lrs_timestamp(uint64_t time); 24 | core::status convert(file_types::stream_type source, rs_stream &target); 25 | core::status convert(file_types::compression_type source, core::file_types::compression_type &target); 26 | core::status convert(file_types::rotation source, rs::core::rotation &target); 27 | core::status convert(file_types::pixel_format source, rs_format &target); 28 | core::status convert(const file_types::coordinate_system &source, core::file_types::coordinate_system &target); 29 | core::status convert(const file_types::disk_format::header &source, core::file_types::file_header &target); 30 | core::status convert(const file_types::disk_format::stream_info &source, core::file_types::stream_info &target); 31 | core::status convert(const file_types::disk_format::device_info_disk &source, std::map& target); 32 | core::status convert(const file_types::image_info &source, std::map& target); 33 | core::status convert(const file_types::disk_format::stream_profile_disk &source, core::file_types::stream_profile &target); 34 | core::status convert(const file_types::disk_format::stream_profile_set_disk &source, std::map &target); 35 | core::status convert(const file_types::disk_format::frame_metadata &source, core::file_types::frame_info &target); 36 | rs_intrinsics get_intrinsics(file_types::stream_type stream, ds_projection::ProjectionData* projection); 37 | rs_extrinsics get_extrinsics(file_types::stream_type stream, ds_projection::ProjectionData *projection); 38 | } 39 | } 40 | } 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /sdk/src/utilities/samples_time_sync/samples_time_sync_impl.cpp: -------------------------------------------------------------------------------- 1 | // License: Apache 2.0. See LICENSE file in root directory. 2 | // Copyright(c) 2016 Intel Corporation. All Rights Reserved. 3 | 4 | #include "rs_sdk.h" 5 | #include "samples_time_sync_zr300.h" 6 | #include "samples_time_sync_ds5.h" 7 | #include "rs_sdk_version.h" 8 | #include "samples_time_sync_external_camera.h" 9 | 10 | namespace rs { 11 | namespace utils { 12 | samples_time_sync_interface * 13 | samples_time_sync_interface::create_instance( 14 | int streams_fps[], int motions_fps[], const char* device_name, unsigned int max_input_latency, 15 | unsigned int not_matched_frames_buffer_size) 16 | { 17 | if (device_name != nullptr) 18 | { 19 | std::string str(device_name); 20 | if ( str.find("ZR300") != std::string::npos ) 21 | return new samples_time_sync_zr300(streams_fps, motions_fps, max_input_latency, not_matched_frames_buffer_size); 22 | 23 | if ( str.compare(external_device_name) == 0 ) 24 | { 25 | //External camera synchronization requires that a single buffer is used for the images arrays 26 | const int SINGLE_BUFFER = 1; 27 | return new samples_time_sync_external_camera(streams_fps, 28 | motions_fps, SINGLE_BUFFER, 29 | not_matched_frames_buffer_size); 30 | } 31 | /*if ( str.find("RS400") != std::string::npos ) 32 | return new samples_time_sync_ds5(streams_fps, motions_fps, max_input_latency, not_matched_frames_buffer_size);*/ 33 | 34 | 35 | } 36 | 37 | throw std::invalid_argument("Unsupported device or missing device name."); 38 | } 39 | 40 | samples_time_sync_interface * 41 | samples_time_sync_interface::create_instance(int streams_fps[], int motions_fps[], const char* device_name, unsigned int max_input_latency) 42 | { 43 | return samples_time_sync_interface::create_instance(streams_fps, motions_fps, device_name, max_input_latency, 0); 44 | } 45 | 46 | samples_time_sync_interface * 47 | samples_time_sync_interface::create_instance(int streams_fps[], int motions_fps[], const char* device_name) 48 | { 49 | return samples_time_sync_interface::create_instance(streams_fps, motions_fps, device_name, 150, 0); 50 | } 51 | } 52 | } 53 | 54 | -------------------------------------------------------------------------------- /sdk/src/include/viewer.h: -------------------------------------------------------------------------------- 1 | // License: Apache 2.0. See LICENSE file in root directory. 2 | // Copyright(c) 2016 Intel Corporation. All Rights Reserved. 3 | 4 | #pragma once 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | 17 | //opengl api 18 | #define GLFW_INCLUDE_GLU 19 | 20 | #include 21 | 22 | #ifdef WIN32 23 | #ifdef realsense_viewer_EXPORTS 24 | #define DLL_EXPORT __declspec(dllexport) 25 | #else 26 | #define DLL_EXPORT __declspec(dllimport) 27 | #endif /* realsense_viewer_EXPORTS */ 28 | #else /* defined (WIN32) */ 29 | #define DLL_EXPORT 30 | #endif 31 | 32 | namespace rs 33 | { 34 | namespace utils 35 | { 36 | class DLL_EXPORT viewer 37 | { 38 | using int_pair = std::pair; 39 | public: 40 | viewer(size_t stream_count, uint32_t width, uint32_t height, std::function on_close_callback, std::string title = ""); 41 | 42 | ~viewer(); 43 | 44 | void show_image(const rs::core::image_interface * image); 45 | void show_image(std::shared_ptr image); 46 | 47 | private: 48 | void setup_window(uint32_t width, uint32_t height, std::string window_title); 49 | void render_image(std::shared_ptr image); 50 | void draw(const rs::core::image_interface * image, int gl_format, int gl_channel_type); 51 | void ui_refresh(); 52 | void update_buffer(std::shared_ptr& image); 53 | bool add_window(rs::core::stream_type stream); 54 | 55 | int_pair calc_grid(size_t width, size_t height, size_t streams); 56 | std::pair calc_window_size(const core::image_interface *image); 57 | std::map> m_render_buffer; 58 | uint32_t m_width; 59 | uint32_t m_height; 60 | std::string m_title; 61 | std::function m_user_on_close_callback; 62 | std::condition_variable m_render_thread_cv; 63 | std::thread m_ui_thread; 64 | std::mutex m_render_mutex; 65 | GLFWwindow * m_window; 66 | size_t m_stream_count; 67 | std::map m_windows_positions; 68 | std::atomic m_is_running; 69 | }; 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /sdk/src/cameras/playback/rs_stream_impl.cpp: -------------------------------------------------------------------------------- 1 | // License: Apache 2.0. See LICENSE file in root directory. 2 | // Copyright(c) 2016 Intel Corporation. All Rights Reserved. 3 | 4 | #include "rs_stream_impl.h" 5 | #include "include/linear_algebra.h" 6 | 7 | namespace rs 8 | { 9 | namespace playback 10 | { 11 | void rs_stream_impl::create_extrinsics(const std::map> & streams) 12 | { 13 | for(auto it = streams.begin(); it != streams.end(); ++it) 14 | { 15 | //set identity matrix if stream types are similar 16 | if(m_stream_info.stream == it->first) 17 | { 18 | m_extrinsics_to[it->first] = { 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0 }; 19 | continue; 20 | } 21 | if(it->first == rs_stream::RS_STREAM_DEPTH) 22 | { 23 | m_extrinsics_to[it->first] = m_stream_info.profile.extrinsics; 24 | continue; 25 | } 26 | //rs_extrinsics is assumed to be identical to rs::utils::pose 27 | rs::utils::pose from_pose,to_pose;//matrix for linear_algebra lib 28 | auto from = it->second->get_stream_info().profile.extrinsics; 29 | memcpy(&from_pose, &m_stream_info.profile.extrinsics, sizeof(from_pose));// from_stream -> depth_stream 30 | memcpy(&to_pose, &from, sizeof(to_pose));// to_stream -> depth_stream 31 | auto transform = from_pose * inverse(to_pose); 32 | rs_extrinsics extrin; 33 | memcpy(&extrin, &transform, sizeof(extrin)); 34 | m_extrinsics_to[it->first] = extrin; 35 | } 36 | } 37 | 38 | rs_extrinsics rs_stream_impl::get_extrinsics_to(const rs_stream_interface &r) const 39 | { 40 | rs_extrinsics rv = {0}; 41 | auto stream_type = r.get_stream_type(); 42 | if(m_extrinsics_to.find(stream_type) != m_extrinsics_to.end()) 43 | rv = m_extrinsics_to.at(stream_type); 44 | return rv; 45 | } 46 | 47 | void rs_stream_impl::get_mode(int mode, int *w, int *h, rs_format *f, int *fps) const 48 | { 49 | if(mode != 0) 50 | { 51 | *w = *h = *fps = 0; 52 | *f = rs_format::RS_FORMAT_ANY; 53 | return; 54 | } 55 | *w = m_stream_info.profile.info.width; 56 | *h = m_stream_info.profile.info.height; 57 | *f = m_stream_info.profile.info.format; 58 | *fps = m_stream_info.profile.frame_rate; 59 | } 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /samples/src/playback_sync_sample/main.cpp: -------------------------------------------------------------------------------- 1 | // License: Apache 2.0. See LICENSE file in root directory. 2 | // Copyright(c) 2016 Intel Corporation. All Rights Reserved. 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include "rs_sdk.h" 9 | #include "unistd.h" 10 | 11 | using namespace rs::core; 12 | using namespace std; 13 | 14 | int main(int argc, char* argv[]) try 15 | { 16 | if (argc < 2) 17 | { 18 | cerr << "missing playback file argument" << endl; 19 | return -1; 20 | } 21 | if (access(argv[1], F_OK) == -1) 22 | { 23 | cerr << "playback file does not exists" << endl; 24 | return -1; 25 | } 26 | const string input_file(argv[1]); 27 | 28 | //create a playback enabled context with a given output file 29 | rs::playback::context context(input_file.c_str()); 30 | 31 | //get device count, in playback context there should be a single device. 32 | //in case device count is 0 there is probably problem with file location or permissions 33 | int device_count = context.get_device_count(); 34 | if (device_count == 0) 35 | { 36 | cerr << "failed to open playback file" << endl; 37 | return -1; 38 | } 39 | 40 | //create a playback enabled device 41 | rs::device* device = context.get_device(0); 42 | 43 | //enable the recorded streams 44 | vector streams = { rs::stream::color, rs::stream::depth, rs::stream::infrared, rs::stream::infrared2, rs::stream::fisheye }; 45 | 46 | for(auto stream : streams) 47 | { 48 | if(device->get_stream_mode_count(stream) > 0) 49 | { 50 | device->enable_stream(stream, rs::preset::best_quality); 51 | std::cout << "stream type: " << stream << ", width: " << device->get_stream_width(stream) << ", height: " << device->get_stream_height(stream) << ", format: " << device->get_stream_format(stream) << ", fps: " << device->get_stream_framerate(stream) << std::endl; 52 | } 53 | } 54 | 55 | device->start(); 56 | 57 | //if theres no more frames the playback device will report that its not streaming 58 | while(device->is_streaming()) 59 | { 60 | device->wait_for_frames(); 61 | for(auto stream : streams) 62 | { 63 | if(device->is_stream_enabled(stream)) 64 | std::cout << "stream type: " << stream << ", timestamp: " << device->get_frame_timestamp(stream) << std::endl; 65 | auto frame_data = device->get_frame_data(stream); 66 | 67 | //use the recorded frame... 68 | } 69 | } 70 | device->stop(); 71 | 72 | return 0; 73 | } 74 | 75 | catch(rs::error e) 76 | { 77 | std::cout << e.what() << std::endl; 78 | return -1; 79 | } 80 | -------------------------------------------------------------------------------- /sdk/src/cameras/playback/include/disk_read_factory.h: -------------------------------------------------------------------------------- 1 | // License: Apache 2.0. See LICENSE file in root directory. 2 | // Copyright(c) 2016 Intel Corporation. All Rights Reserved. 3 | 4 | #pragma once 5 | #include 6 | #include "include/file.h" 7 | #include "disk_read.h" 8 | #include "linux/v1/disk_read.h" 9 | #include "windows/v10/disk_read.h" 10 | #include "rs/utils/log_utils.h" 11 | 12 | namespace rs 13 | { 14 | namespace playback 15 | { 16 | class disk_read_factory 17 | { 18 | 19 | public: 20 | static rs::core::status create_disk_read(const char *file_name, std::unique_ptr &disk_read) 21 | { 22 | std::unique_ptr file_ = std::unique_ptr(new rs::core::file()); 23 | 24 | rs::core::status status = file_->open(file_name, rs::core::open_file_option::read); 25 | if (status != rs::core::status_no_error) 26 | { 27 | std::string str = file_name; 28 | return rs::core::status::status_file_open_failed; 29 | } 30 | 31 | /* Get the file header */ 32 | status = file_->set_position(0, rs::core::move_method::begin); 33 | if (status != rs::core::status_no_error) return status; 34 | 35 | uint32_t nbytesRead = 0; 36 | int32_t file_type_id; 37 | status = file_->read_bytes(&file_type_id, sizeof(file_type_id), nbytesRead); 38 | if (status != rs::core::status_no_error) return status; 39 | 40 | if (file_type_id == UID('R', 'S', 'L', '2')) 41 | { 42 | LOG_INFO("create disk read for Linux file format version 2") 43 | disk_read = std::unique_ptr(new playback::disk_read(file_name)); 44 | return disk_read->init(); 45 | } 46 | 47 | if (file_type_id == UID('R', 'S', 'L', '1')) 48 | { 49 | LOG_INFO("create disk read for Linux file format version 1") 50 | disk_read = std::unique_ptr(new linux::v1::disk_read(file_name)); 51 | return disk_read->init(); 52 | } 53 | 54 | if (file_type_id == UID('R', 'S', 'C', 'F')) 55 | { 56 | LOG_INFO("create disk read for Windows file format") 57 | disk_read = std::unique_ptr(new windows::v10::disk_read(file_name)); 58 | return disk_read->init(); 59 | } 60 | LOG_ERROR("failed to create disk read") 61 | return rs::core::status_file_read_failed; 62 | } 63 | }; 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /sdk/src/cv_modules/max_depth_value_module/max_depth_value_module.cpp: -------------------------------------------------------------------------------- 1 | // License: Apache 2.0. See LICENSE file in root directory. 2 | // Copyright(c) 2016 Intel Corporation. All Rights Reserved. 3 | 4 | #include "rs_sdk_version.h" 5 | #include "rs/cv_modules/max_depth_value_module/max_depth_value_module.h" 6 | #include "max_depth_value_module_impl.h" 7 | 8 | using namespace rs::core; 9 | using namespace rs::utils; 10 | 11 | namespace rs 12 | { 13 | namespace cv_modules 14 | { 15 | max_depth_value_module::max_depth_value_module(uint64_t milliseconds_added_to_simulate_larger_computation_time, bool is_async_processing): 16 | m_pimpl(new max_depth_value_module_impl(milliseconds_added_to_simulate_larger_computation_time, is_async_processing)) 17 | {} 18 | 19 | int32_t max_depth_value_module::query_module_uid() 20 | { 21 | return m_pimpl->query_module_uid(); 22 | } 23 | 24 | status max_depth_value_module::query_supported_module_config(int32_t idx, supported_module_config &supported_config) 25 | { 26 | return m_pimpl->query_supported_module_config(idx, supported_config); 27 | } 28 | 29 | status max_depth_value_module::query_current_module_config(actual_module_config &module_config) 30 | { 31 | return m_pimpl->query_current_module_config(module_config); 32 | } 33 | 34 | status max_depth_value_module::set_module_config(const actual_module_config &module_config) 35 | { 36 | return m_pimpl->set_module_config(module_config); 37 | } 38 | 39 | status max_depth_value_module::process_sample_set(const correlated_sample_set& sample_set) 40 | { 41 | return m_pimpl->process_sample_set(sample_set); 42 | } 43 | 44 | status max_depth_value_module::register_event_handler(video_module_interface::processing_event_handler *handler) 45 | { 46 | return m_pimpl->register_event_handler(handler); 47 | } 48 | 49 | status max_depth_value_module::unregister_event_handler(video_module_interface::processing_event_handler *handler) 50 | { 51 | return m_pimpl->unregister_event_handler(handler); 52 | } 53 | 54 | core::status max_depth_value_module::flush_resources() 55 | { 56 | return m_pimpl->flush_resources(); 57 | } 58 | 59 | core::status max_depth_value_module::reset_config() 60 | { 61 | return m_pimpl->reset_config(); 62 | } 63 | 64 | max_depth_value_module::max_depth_value_output_data max_depth_value_module::get_max_depth_value_data() 65 | { 66 | return m_pimpl->get_max_depth_value_data(); 67 | } 68 | 69 | max_depth_value_module::~max_depth_value_module() 70 | { 71 | delete m_pimpl; 72 | } 73 | } 74 | } 75 | 76 | -------------------------------------------------------------------------------- /sdk/src/cameras/playback/include/disk_read_interface.h: -------------------------------------------------------------------------------- 1 | // License: Apache 2.0. See LICENSE file in root directory. 2 | // Copyright(c) 2016 Intel Corporation. All Rights Reserved. 3 | 4 | #pragma once 5 | #include 6 | #include 7 | #include 8 | #include "include/file_types.h" 9 | #include "rs/playback/playback_device.h" 10 | #include "status.h" 11 | 12 | namespace rs 13 | { 14 | namespace playback 15 | { 16 | class disk_read_interface 17 | { 18 | public: 19 | disk_read_interface() {} 20 | virtual ~disk_read_interface(void) {} 21 | virtual core::status init() = 0; 22 | virtual void reset() = 0; 23 | virtual void resume() = 0; 24 | virtual void pause() = 0; 25 | virtual void enable_stream(rs_stream stream, bool state) = 0; 26 | virtual void enable_motions_callback(bool state) = 0; 27 | virtual bool is_motion_tracking_enabled() = 0; 28 | virtual const std::map& get_camera_info() = 0; 29 | virtual std::map get_streams_infos() = 0; 30 | virtual rs_motion_intrinsics get_motion_intrinsics() = 0; 31 | virtual std::vector get_capabilities() = 0; 32 | virtual std::map get_properties() = 0; 33 | virtual void set_realtime(bool realtime) = 0; 34 | virtual std::map> set_frame_by_index(uint32_t index, rs_stream stream_type) = 0; 35 | virtual std::map> set_frame_by_time_stamp(uint64_t ts) = 0; 36 | virtual bool query_realtime() = 0; 37 | virtual uint32_t query_number_of_frames(rs_stream stream_type) = 0; 38 | virtual int32_t query_coordinate_system() = 0; 39 | virtual core::file_types::version query_sdk_version() = 0; 40 | virtual core::file_types::version query_librealsense_version() = 0; 41 | virtual playback::capture_mode query_capture_mode() = 0; 42 | virtual playback::file_info query_file_info() = 0; 43 | virtual uint64_t query_run_time() = 0; 44 | virtual bool is_stream_profile_available(rs_stream stream, int width, int height, rs_format format, int framerate) = 0;//TODO:[mk]consider moving to device 45 | virtual void set_callback(std::function)> handler) = 0; 46 | virtual void set_callback(std::function handler) = 0; 47 | virtual void set_total_frame_drop_count(double value) = 0; 48 | virtual void update_frame_drop_count(rs_stream stream, uint32_t frame_drop) = 0; 49 | virtual void update_imu_drop_count(uint32_t frame_drop) = 0; 50 | }; 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /sdk/src/core/pipeline/sync_samples_consumer.cpp: -------------------------------------------------------------------------------- 1 | // License: Apache 2.0. See LICENSE file in root directory. 2 | // Copyright(c) 2016 Intel Corporation. All Rights Reserved. 3 | 4 | #include "rs/utils/log_utils.h" 5 | #include "sync_samples_consumer.h" 6 | 7 | #include "samples_consumer_base.h" 8 | using namespace rs::utils; 9 | 10 | namespace rs 11 | { 12 | namespace core 13 | { 14 | sync_samples_consumer::sync_samples_consumer(std::function)> sample_set_ready_handler, 15 | const video_module_interface::actual_module_config &module_config, 16 | const video_module_interface::supported_module_config::time_sync_mode time_sync_mode): 17 | samples_consumer_base(module_config, time_sync_mode), 18 | m_is_closing(false), 19 | m_current_sample_set(nullptr), 20 | m_sample_set_ready_handler(sample_set_ready_handler) 21 | { 22 | m_samples_consumer_thread = std::thread(&sync_samples_consumer::consumer_loop, this); 23 | } 24 | 25 | void sync_samples_consumer::on_complete_sample_set(std::shared_ptr ready_sample_set) 26 | { 27 | //update the current object even if no one took it 28 | { 29 | std::unique_lock lock(m_lock); 30 | m_current_sample_set = std::move(ready_sample_set); 31 | } 32 | m_conditional_variable.notify_one(); 33 | } 34 | 35 | void sync_samples_consumer::consumer_loop() 36 | { 37 | while(!m_is_closing) 38 | { 39 | std::shared_ptr samples_set; 40 | { 41 | std::unique_lock lock(m_lock); 42 | m_conditional_variable.wait(lock, [this]() { return m_is_closing || ( !m_is_closing && m_current_sample_set);}); 43 | samples_set.swap(m_current_sample_set); 44 | } 45 | 46 | if(!samples_set) 47 | { 48 | continue; 49 | } 50 | 51 | try 52 | { 53 | m_sample_set_ready_handler(samples_set); 54 | } 55 | catch(const std::exception & ex) 56 | { 57 | LOG_ERROR("m_sample_set_ready_handler callback throw ex" << ex.what()); 58 | throw ex; 59 | } 60 | } 61 | } 62 | 63 | sync_samples_consumer::~sync_samples_consumer() 64 | { 65 | m_is_closing = true; 66 | m_conditional_variable.notify_one(); 67 | if(m_samples_consumer_thread.joinable()) 68 | { 69 | m_samples_consumer_thread.join(); 70 | } 71 | } 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /sdk/src/core/projection/math_projection_interface.h: -------------------------------------------------------------------------------- 1 | // License: Apache 2.0. See LICENSE file in root directory. 2 | // Copyright(c) 2016 Intel Corporation. All Rights Reserved. 3 | 4 | #pragma once 5 | #include "rs/core/status.h" 6 | #include "rs/core/types.h" 7 | #include "math.h" 8 | 9 | namespace rs 10 | { 11 | namespace core 12 | { 13 | 14 | #define REFCALL 15 | 16 | struct projection_spec_32f; 17 | typedef struct projection_spec_32f projection_spec_32f; 18 | 19 | class math_projection 20 | { 21 | public: 22 | math_projection(); 23 | 24 | rs::core::status REFCALL rs_projection_init_32f(rs::core::sizeI32 roi_size, float camera_src[4], float inv_distortion[5], projection_spec_32f *pspec); 25 | 26 | rs::core::status REFCALL rs_3d_array_projection_32f(const float *psrc, float *pdst, int length, float camera_src[4], 27 | float inv_distortion_src[5], float rotation[9], float translation[3], 28 | float distortion_dst[5], float camera_dst[4]); 29 | 30 | rs::core::status REFCALL rs_projection_16u32f_c1cxr(const unsigned short *psrc, rs::core::sizeI32 roi_size, int src_step, float *pdst, int dst_step, 31 | float rotation[9], float translation[3], float distortion_dst[5], 32 | float camera_dst[4], const projection_spec_32f *pspec); 33 | 34 | rs::core::status REFCALL rs_projection_get_size_32f(rs::core::sizeI32 roi_size, int *pspec_size); 35 | 36 | rs::core::status REFCALL rs_remap_16u_c1r(const unsigned short* psrc, rs::core::sizeI32 src_size, int src_step, const float* pxy_map, 37 | int xy_map_step, unsigned short* pdst, rs::core::sizeI32 dstroi_size, 38 | int dst_step, int interpolation_type, unsigned short default_value); 39 | 40 | rs::core::status REFCALL rs_uvmap_filter_32f_c2ir(float *psrc_dst, int srcdst_step, rs::core::sizeI32 roi_size, 41 | const unsigned short *pdepth, int depth_step, unsigned short invalid_depth); 42 | 43 | rs::core::status REFCALL rs_uvmap_invertor_32f_c2r(const float *psrc, int src_step, rs::core::sizeI32 src_size, rs::core::rect src_roi, 44 | float *pdst, int dst_step, rs::core::sizeI32 dst_size, int units_is_relative, pointF32 threshold); 45 | 46 | rs::core::status REFCALL rs_qr_decomp_m_64f(const double* psrc, int src_stride1, int src_stride2, 47 | double* pbuffer, 48 | double* pdst, int dststride1, int dststride2, 49 | int width, int height); 50 | 51 | rs::core::status REFCALL rs_qr_back_subst_mva_64f(const double* psrc1, int src1stride1, int src1stride2, double* pbuffer, 52 | const double* psrc2, int src2stride0, int src2stride2, 53 | double* pdst, int dststride0, int dststride2, int width, int height, int count); 54 | }; 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /samples/src/fps_counter_sample/main.cpp: -------------------------------------------------------------------------------- 1 | // License: Apache 2.0. See LICENSE file in root directory. 2 | // Copyright(c) 2016 Intel Corporation. All Rights Reserved. 3 | 4 | // Frames Per Second Counting Sample 5 | // This sample demonstrates an application usage of an fps counter class which implements frames per second counting. 6 | // The class provides an easy way to count frames per second value both per second and as an overall average. 7 | 8 | #include 9 | #include 10 | #include 11 | #include "rs_sdk.h" 12 | 13 | using namespace rs::core; 14 | using namespace rs::utils; 15 | using namespace std; 16 | 17 | const int count_stream_fps(rs::device* device, int requested_from_stream_fps); 18 | 19 | int main(int argc, char* argv[]) 20 | { 21 | rs::context context; 22 | if(context.get_device_count() == 0) 23 | { 24 | cerr << "no device detected" << endl; 25 | return -1; 26 | } 27 | rs::device* device = context.get_device(0); 28 | 29 | const int default_fps = 60; 30 | 31 | /* calculate fps for first stream */ 32 | //color profile 33 | const int color_width = 640, color_height = 480, color_fps = default_fps; 34 | const rs::format color_format = rs::format::rgb8; 35 | device->enable_stream(rs::stream::color, color_width, color_height, color_format, color_fps); 36 | device->start(); 37 | 38 | /* fps measurement */ 39 | int average_fps = count_stream_fps(device, default_fps); // counting color stream fps 40 | std::cout << "Color stream: average fps = " << average_fps << std::endl; 41 | 42 | device->stop(); 43 | device->disable_stream(rs::stream::color); // disable first tested stream in order to have more precise result 44 | 45 | /* calculate fps for second stream */ 46 | //depth profile 47 | const int depthWidth = 640, depthHeight = 480, depthFps = default_fps; 48 | const rs::format depthFormat = rs::format::z16; 49 | device->enable_stream(rs::stream::depth, depthWidth, depthHeight, depthFormat, depthFps); 50 | device->start(); 51 | 52 | /* fps measurement */ 53 | average_fps = count_stream_fps(device, default_fps); // counting depth stream fps 54 | std::cout << "Depth stream: average fps = " << average_fps << std::endl; 55 | 56 | device->stop(); 57 | 58 | return 0; 59 | } 60 | 61 | const int count_stream_fps(rs::device* device, int requested_from_stream_fps) 62 | { 63 | fps_counter _fps_counter(requested_from_stream_fps); // create fps_counter 64 | int frames_to_stream = 300; // approx. 5 seconds for requested 60 fps 65 | while(device->is_streaming() && frames_to_stream--) 66 | { 67 | device->wait_for_frames(); // stream frames 68 | 69 | _fps_counter.tick(); // store time value 70 | 71 | if (frames_to_stream % 100 == 0) // print fps 72 | std::cout << "Last second fps = " << _fps_counter.current_fps() << std::endl; 73 | } 74 | return static_cast(_fps_counter.total_average_fps()); // return total average fps 75 | } 76 | -------------------------------------------------------------------------------- /sdk/src/core/image/image_base.cpp: -------------------------------------------------------------------------------- 1 | // License: Apache 2.0. See LICENSE file in root directory. 2 | // Copyright(c) 2016 Intel Corporation. All Rights Reserved. 3 | 4 | #include "image_base.h" 5 | #include "custom_image.h" 6 | #include "image_conversion_util.h" 7 | #include "rs/utils/self_releasing_array_data_releaser.h" 8 | #include "rs/utils/smart_ptr_helpers.h" 9 | #include "rs_sdk_version.h" 10 | #include "metadata.h" 11 | 12 | namespace rs 13 | { 14 | namespace core 15 | { 16 | image_base::image_base() 17 | : ref_count_base() 18 | { 19 | 20 | } 21 | 22 | metadata_interface * image_base::query_metadata() 23 | { 24 | return &metadata; 25 | } 26 | 27 | status image_base::convert_to(pixel_format format, const image_interface **converted_image) 28 | { 29 | image_info dst_info = query_info(); 30 | dst_info.format = format; 31 | dst_info.pitch = get_pixel_size(format) * query_info().width; 32 | 33 | if(image_conversion_util::is_conversion_valid(query_info(), dst_info) < status_no_error) 34 | { 35 | return status_param_unsupported; 36 | } 37 | 38 | std::lock_guard lock(image_caching_lock); 39 | if(image_cache_per_pixel_format.find(format) == image_cache_per_pixel_format.end()) 40 | { 41 | //allocate image data 42 | auto dst_data = new uint8_t[dst_info.height * dst_info.pitch]; 43 | 44 | //create a releaser for the above allocation 45 | auto data_releaser = new rs::utils::self_releasing_array_data_releaser(dst_data); 46 | 47 | // update the dst image data 48 | if(image_conversion_util::convert(query_info(), static_cast(query_data()), dst_info, dst_data) < status_no_error) 49 | { 50 | data_releaser->release(); 51 | return status_param_unsupported; 52 | } 53 | 54 | //cache the image 55 | const image_interface * dst_image = image_interface::create_instance_from_raw_data( 56 | &dst_info, 57 | {dst_data, data_releaser}, 58 | query_stream_type(), 59 | query_flags(), 60 | query_time_stamp(), 61 | query_frame_number()); 62 | 63 | image_cache_per_pixel_format[format] = rs::utils::get_unique_ptr_with_releaser(dst_image); 64 | } 65 | image_cache_per_pixel_format[format]->add_ref(); 66 | *converted_image = image_cache_per_pixel_format[format].get(); 67 | return status_no_error; 68 | } 69 | 70 | status image_base::convert_to(rs::core::rotation rotation, const image_interface **converted_image) 71 | { 72 | return status_feature_unsupported; 73 | } 74 | } 75 | } 76 | 77 | 78 | -------------------------------------------------------------------------------- /sdk/src/core/image/lrs_image/lrs_image.cpp: -------------------------------------------------------------------------------- 1 | // License: Apache 2.0. See LICENSE file in root directory. 2 | // Copyright(c) 2016 Intel Corporation. All Rights Reserved. 3 | 4 | #include "lrs_image.h" 5 | #include "rs/utils/librealsense_conversion_utils.h" 6 | 7 | using namespace rs::utils; 8 | 9 | namespace rs 10 | { 11 | namespace core 12 | { 13 | lrs_image::lrs_image(rs::frame &frame, 14 | image_interface::flag flags) 15 | : image_base(), m_flags(flags) 16 | { 17 | m_frame.swap(frame); 18 | for(int i = 0; i < rs_frame_metadata::RS_FRAME_METADATA_COUNT; i++) 19 | { 20 | rs_frame_metadata rs_md_id = static_cast(i); 21 | if(m_frame.supports_frame_metadata(rs_md_id)) 22 | { 23 | double val = m_frame.get_frame_metadata(rs_md_id); 24 | rs::frame_metadata md_id = static_cast(rs_md_id); 25 | metadata_type md_type = convert(md_id); 26 | query_metadata()->add_metadata(md_type, reinterpret_cast(&val), static_cast(sizeof(val))); 27 | } 28 | } 29 | } 30 | 31 | image_info lrs_image::query_info() const 32 | { 33 | image_info info; 34 | info.format = utils::convert_pixel_format(m_frame.get_format()); 35 | info.height = m_frame.get_height(); 36 | info.width = m_frame.get_width(); 37 | info.pitch = m_frame.get_stride(); 38 | return info; 39 | } 40 | 41 | double lrs_image::query_time_stamp() const 42 | { 43 | return m_frame.get_timestamp(); 44 | } 45 | 46 | timestamp_domain lrs_image::query_time_stamp_domain() const 47 | { 48 | return utils::convert_timestamp_domain(m_frame.get_frame_timestamp_domain()); 49 | } 50 | 51 | image_interface::flag lrs_image::query_flags() const 52 | { 53 | return m_flags; 54 | } 55 | 56 | const void * lrs_image::query_data() const 57 | { 58 | return m_frame.get_data(); 59 | } 60 | 61 | stream_type lrs_image::query_stream_type() const 62 | { 63 | //the frame const cast can be remove if librealsense made get_stream_type const 64 | return utils::convert_stream_type(const_cast(&m_frame)->get_stream_type()); 65 | } 66 | 67 | uint64_t lrs_image::query_frame_number() const 68 | { 69 | return m_frame.get_frame_number(); 70 | } 71 | 72 | image_interface * image_interface::create_instance_from_librealsense_frame(rs::frame& frame, 73 | flag flags) 74 | { 75 | return new lrs_image(frame, flags); 76 | } 77 | 78 | lrs_image::~lrs_image() {} 79 | } 80 | } 81 | 82 | 83 | -------------------------------------------------------------------------------- /samples/src/record_sync_sample/main.cpp: -------------------------------------------------------------------------------- 1 | // License: Apache 2.0. See LICENSE file in root directory. 2 | // Copyright(c) 2016 Intel Corporation. All Rights Reserved. 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | #include "rs_sdk.h" 9 | 10 | using namespace rs::core; 11 | using namespace std; 12 | 13 | void enable_motion_tracking(rs::device * device) 14 | { 15 | auto motion_callback = [](rs::motion_data motion_data) 16 | { 17 | //process motion data here 18 | }; 19 | 20 | device->enable_motion_tracking(motion_callback); 21 | 22 | //set the camera to produce all streams timestamps from a single clock - the microcontroller's clock. 23 | //this option takes effect only if motion tracking is enabled and device->start() is called with rs::source::all_sources argument. 24 | device->set_option(rs::option::fisheye_strobe, 1); 25 | } 26 | 27 | int main(int argc, char* argv[]) try 28 | { 29 | if (argc < 2) 30 | { 31 | cerr << "missing record file argument" << endl; 32 | return -1; 33 | } 34 | 35 | const int number_of_frames = 200; 36 | const string output_file(argv[1]); 37 | 38 | //create a record enabled context with a given output file 39 | rs::record::context context(output_file.c_str()); 40 | 41 | if(context.get_device_count() == 0) 42 | { 43 | cerr<<"no device detected" << endl; 44 | return -1; 45 | } 46 | 47 | //each device created from the record enabled context will write the streaming data to the given file 48 | rs::device* device = context.get_device(0); 49 | 50 | //enable required streams 51 | device->enable_stream(rs::stream::color, 640, 480, rs::format::rgba8, 30); 52 | device->enable_stream(rs::stream::depth, 640, 480, rs::format::z16, 30); 53 | device->enable_stream(rs::stream::fisheye, 640, 480, rs::format::raw8, 30); 54 | 55 | vector streams = { rs::stream::color, rs::stream::depth, rs::stream::fisheye }; 56 | 57 | for(auto stream : streams) 58 | { 59 | std::cout << "stream type: " << stream << ", width: " << device->get_stream_width(stream) << ", height: " << device->get_stream_height(stream) << ", format: " << device->get_stream_format(stream) << ", fps: " << device->get_stream_framerate(stream) << std::endl; 60 | } 61 | 62 | //enable motion tracking, provides IMU events, mandatory for fisheye stream timestamp sync. 63 | enable_motion_tracking(device); 64 | 65 | device->start(rs::source::all_sources); 66 | 67 | for(auto i = 0; i < number_of_frames; ++i) 68 | { 69 | //each available frame will be written to the output file 70 | device->wait_for_frames(); 71 | for(auto stream : streams) 72 | { 73 | if(device->is_stream_enabled(stream)) 74 | std::cout << "stream type: " << stream << ", timestamp: " << device->get_frame_timestamp(stream) << std::endl; 75 | } 76 | } 77 | device->stop(rs::source::all_sources); 78 | 79 | return 0; 80 | } 81 | 82 | catch(rs::error e) 83 | { 84 | std::cout << e.what() << std::endl; 85 | return -1; 86 | } 87 | -------------------------------------------------------------------------------- /samples/src/playback_async_sample/main.cpp: -------------------------------------------------------------------------------- 1 | // License: Apache 2.0. See LICENSE file in root directory. 2 | // Copyright(c) 2016 Intel Corporation. All Rights Reserved. 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include "rs_sdk.h" 11 | 12 | using namespace rs::core; 13 | using namespace std; 14 | 15 | int main(int argc, char* argv[]) try 16 | { 17 | if (argc < 2) 18 | { 19 | cerr << "missing playback file argument" << endl; 20 | return -1; 21 | } 22 | 23 | const string input_file(argv[1]); 24 | 25 | //create a playback context with file to play 26 | rs::playback::context context(input_file.c_str()); 27 | 28 | if(context.get_device_count() == 0) 29 | { 30 | cerr<<"failed to create playback device" << endl; 31 | return -1; 32 | } 33 | 34 | //get the playback device 35 | rs::playback::device* device = context.get_playback_device(); 36 | 37 | std::mutex print_mutex; 38 | auto frame_callback = [&print_mutex](rs::frame frame) 39 | { 40 | std::lock_guard guard(print_mutex);//this mutex is synchronising the prints, it is not mandatory 41 | auto timestamp_domain_str = frame.get_frame_timestamp_domain() == rs::timestamp_domain::camera ? "CAMERA" : "MICROCONTROLLER"; 42 | std::cout << "stream type: " << frame.get_stream_type() << ", frame time domain: " << timestamp_domain_str << ", frame timestamp: " << frame.get_timestamp() << std::endl; }; 43 | 44 | auto motion_callback = [](rs::motion_data motion_data) 45 | { 46 | //process motion data here 47 | }; 48 | 49 | //enable available streams and set the frame callbacks 50 | vector streams = { rs::stream::color, rs::stream::depth, rs::stream::infrared, rs::stream::infrared2, rs::stream::fisheye }; 51 | 52 | for(auto stream : streams) 53 | { 54 | if(device->get_stream_mode_count(stream) > 0) 55 | { 56 | int width, height, fps; 57 | rs::format format; 58 | int streaming_mode_index = 0; 59 | device->get_stream_mode(stream, streaming_mode_index, width, height, format, fps); 60 | device->enable_stream(stream, width, height, format, fps); 61 | device->set_frame_callback(stream, frame_callback); 62 | std::cout << "stream type: " << stream << ", width: " << device->get_stream_width(stream) << ", height: " << device->get_stream_height(stream) << ", format: " << device->get_stream_format(stream) << ", fps: " << device->get_stream_framerate(stream) << std::endl; 63 | } 64 | } 65 | 66 | if(device->supports(rs::capabilities::motion_events)) 67 | device->enable_motion_tracking(motion_callback); 68 | 69 | //stream until the end of filee 70 | device->start(rs::source::all_sources); 71 | while(device->is_streaming()) 72 | std::this_thread::sleep_for(std::chrono::milliseconds(100)); 73 | device->stop(rs::source::all_sources); 74 | 75 | return 0; 76 | } 77 | 78 | catch(rs::error e) 79 | { 80 | std::cout << e.what() << std::endl; 81 | return -1; 82 | } 83 | 84 | -------------------------------------------------------------------------------- /sdk/src/cameras/compression/lz4_codec.cpp: -------------------------------------------------------------------------------- 1 | // License: Apache 2.0. See LICENSE file in root directory. 2 | // Copyright(c) 2016 Intel Corporation. All Rights Reserved. 3 | 4 | #include 5 | #include "lz4_codec.h" 6 | #include "rs/utils/log_utils.h" 7 | #include "lz4.h" 8 | 9 | namespace rs 10 | { 11 | namespace core 12 | { 13 | namespace compression 14 | { 15 | 16 | lz4_codec::lz4_codec() : m_compression_level(0) 17 | { 18 | 19 | } 20 | 21 | lz4_codec::lz4_codec(record::compression_level compression_level) : m_compression_level(0) 22 | { 23 | switch (compression_level) 24 | { 25 | case record::compression_level::low: m_compression_level = 100; break; 26 | case record::compression_level::medium: m_compression_level = 17; break; 27 | case record::compression_level::high: m_compression_level = 0; break; 28 | default: m_compression_level = 0; break; 29 | } 30 | } 31 | 32 | lz4_codec::~lz4_codec(void) 33 | { 34 | LOG_FUNC_SCOPE(); 35 | } 36 | 37 | std::shared_ptr lz4_codec::decode(std::shared_ptr frame, uint8_t * input, uint32_t input_size) 38 | { 39 | LOG_FUNC_SCOPE(); 40 | 41 | auto rv = std::shared_ptr( 42 | new file_types::frame_sample(frame.get()), [](file_types::frame_sample* f){delete[] f->data; delete f;}); 43 | 44 | int frame_size = frame->finfo.stride * frame->finfo.height; 45 | auto data = new uint8_t[frame_size]; 46 | auto read = LZ4_decompress_fast (reinterpret_cast(input), reinterpret_cast(data), frame_size); 47 | if(read < 0) 48 | { 49 | LOG_ERROR("failed to decode frame - " << frame->finfo.number << ", stream - " << frame->finfo.stream); 50 | return nullptr; 51 | } 52 | rv->data = data; 53 | return rv; 54 | } 55 | 56 | status lz4_codec::encode(file_types::frame_info &info, const uint8_t * input, uint8_t * output, uint32_t &output_size) 57 | { 58 | LOG_FUNC_SCOPE(); 59 | 60 | if (!input) 61 | { 62 | LOG_ERROR("input data is null"); 63 | return status::status_process_failed; 64 | } 65 | 66 | int input_size = info.stride * info.height; 67 | output_size = LZ4_compress_fast(reinterpret_cast(input), reinterpret_cast(output), input_size, input_size, m_compression_level); 68 | if(output_size == 0 || output_size == static_cast(input_size)) 69 | { 70 | LOG_ERROR("failed to encode frame - " << info.number << ", stream - " << info.stream); 71 | return status::status_process_failed; 72 | } 73 | return status::status_no_error; 74 | } 75 | } 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /sdk/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 2.8.9) 2 | project(realsense_sdk) 3 | 4 | get_filename_component(ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR} DIRECTORY) 5 | include(${ROOT_DIR}/cmake_includes/check_os.cmake) 6 | 7 | if(CMAKE_USE_INTEL_COMPILER EQUAL 1) 8 | MESSAGE("--------- Using Intel compiler------------") 9 | include(CMakeForceCompiler) 10 | CMAKE_FORCE_CXX_COMPILER(icpc "Intel C++ Compiler") 11 | else() 12 | MESSAGE("--------- Using Default compiler ---------") 13 | endif() 14 | 15 | #-------------------- Lets make in-source-builds forbidden -------- 16 | MACRO(MACRO_ENSURE_OUT_OF_SOURCE_BUILD MSG) 17 | STRING(COMPARE EQUAL "${CMAKE_SOURCE_DIR}" 18 | "${CMAKE_BINARY_DIR}" insource) 19 | GET_FILENAME_COMPONENT(PARENTDIR ${CMAKE_SOURCE_DIR} PATH) 20 | STRING(COMPARE EQUAL "${CMAKE_SOURCE_DIR}" 21 | "${PARENTDIR}" insourcesubdir) 22 | IF(insource OR insourcesubdir) 23 | file(REMOVE_RECURSE "${CMAKE_SOURCE_DIR}/CMakeCache.txt" "${CMAKE_SOURCE_DIR}/CMakeFiles") 24 | MESSAGE("============================================================") 25 | MESSAGE("====== ") 26 | MESSAGE("====== ${MSG}") 27 | MESSAGE("====== ") 28 | MESSAGE("============================================================") 29 | MESSAGE(FATAL_ERROR "Error occured") 30 | ENDIF(insource OR insourcesubdir) 31 | ENDMACRO(MACRO_ENSURE_OUT_OF_SOURCE_BUILD) 32 | 33 | MACRO_ENSURE_OUT_OF_SOURCE_BUILD( 34 | "${CMAKE_PROJECT_NAME} requires an out of source build." 35 | ) 36 | 37 | add_definitions(${COMPILE_DEFINITIONS}) 38 | 39 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") 40 | set(ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR}) 41 | 42 | #--------------------- Release or Debug Builds ---------- 43 | if(CMAKE_BUILD_TYPE STREQUAL "Debug") 44 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -O0 ") 45 | endif() 46 | 47 | #-------------- Add security options -------------------- 48 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_FORTIFY_SOURCE=2 ") #TODO: Check what it is 49 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fstack-protector-strong") 50 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIE -fPIC") 51 | 52 | set(INCLUDE_DIR ${ROOT_DIR}/include) 53 | include_directories(${INCLUDE_DIR}) 54 | 55 | set(THIRDPARTY_DIR ${ROOT_DIR}/3rdparty) 56 | MESSAGE("==> Found thirparty dir: ${THIRDPARTY_DIR}") 57 | 58 | install(DIRECTORY ${INCLUDE_DIR}/ DESTINATION include/ ) 59 | 60 | include(CMakeVersion) 61 | 62 | set(LIBVERSION ${SDK_VERSION_MAJOR}.${SDK_VERSION_MINOR}.${SDK_VERSION_PATCH}) 63 | set(LIBSOVERSION ${SDK_VERSION_MAJOR}) 64 | 65 | #----------- Build shared or static library ------------ 66 | option(BUILD_STATIC "Set to ON to build static libraries. Some libraries are always shared" OFF) 67 | if(BUILD_STATIC) 68 | MESSAGE("Building libraries as static objects") 69 | set(SDK_LIB_TYPE "STATIC") 70 | else() 71 | MESSAGE("Building libraries as shared objects(default)") 72 | set(SDK_LIB_TYPE "SHARED") 73 | endif(BUILD_STATIC) 74 | 75 | #------------ Enable logger -------------------------- 76 | option(BUILD_LOGGER "Set to ON to build logger." OFF) 77 | 78 | add_subdirectory(src/utilities) 79 | add_subdirectory(src/core) 80 | add_subdirectory(src/tools) 81 | add_subdirectory(src/cameras) 82 | add_subdirectory(src/cv_modules) 83 | -------------------------------------------------------------------------------- /sdk/src/core/image/custom_image.cpp: -------------------------------------------------------------------------------- 1 | // License: Apache 2.0. See LICENSE file in root directory. 2 | // Copyright(c) 2016 Intel Corporation. All Rights Reserved. 3 | 4 | #include "custom_image.h" 5 | 6 | namespace rs 7 | { 8 | namespace core 9 | { 10 | custom_image::custom_image(image_info * info, 11 | const void * data, 12 | stream_type stream, 13 | image_interface::flag flags, 14 | double time_stamp, 15 | rs::core::timestamp_domain time_stamp_domain, 16 | uint64_t frame_number, 17 | rs::utils::unique_ptr data_releaser) 18 | : image_base(), m_info(*info), m_data(data), m_stream(stream), m_flags(flags), 19 | m_frame_number(frame_number), m_time_stamp(time_stamp),m_time_stamp_domain(time_stamp_domain), m_data_releaser(std::move(data_releaser)) 20 | { 21 | 22 | } 23 | 24 | image_info custom_image::query_info() const 25 | { 26 | return m_info; 27 | } 28 | 29 | double custom_image::query_time_stamp() const 30 | { 31 | return m_time_stamp; 32 | } 33 | 34 | timestamp_domain custom_image::query_time_stamp_domain() const 35 | { 36 | return m_time_stamp_domain; 37 | } 38 | 39 | image_interface::flag custom_image::query_flags() const 40 | { 41 | return m_flags; 42 | } 43 | 44 | const void * custom_image::query_data() const 45 | { 46 | return m_data; 47 | } 48 | 49 | stream_type custom_image::query_stream_type() const 50 | { 51 | return m_stream; 52 | } 53 | 54 | uint64_t custom_image::query_frame_number() const 55 | { 56 | return m_frame_number; 57 | } 58 | 59 | custom_image::~custom_image() {} 60 | 61 | image_interface * image_interface::create_instance_from_raw_data(image_info * info, 62 | const image_data_with_data_releaser & data_container, 63 | stream_type stream, 64 | image_interface::flag flags, 65 | double time_stamp, 66 | uint64_t frame_number, 67 | timestamp_domain time_stamp_domain) 68 | { 69 | return new custom_image(info, 70 | data_container.data, 71 | stream, 72 | flags, 73 | time_stamp, 74 | time_stamp_domain, 75 | frame_number, 76 | std::move(rs::utils::get_unique_ptr_with_releaser(data_container.data_releaser))); 77 | } 78 | } 79 | } 80 | 81 | 82 | -------------------------------------------------------------------------------- /samples/src/record_async_sample/main.cpp: -------------------------------------------------------------------------------- 1 | // License: Apache 2.0. See LICENSE file in root directory. 2 | // Copyright(c) 2016 Intel Corporation. All Rights Reserved. 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | #include "rs_sdk.h" 10 | 11 | using namespace rs::core; 12 | using namespace std; 13 | 14 | void enable_motion_tracking(rs::device * device) 15 | { 16 | auto motion_callback = [](rs::motion_data motion_data) 17 | { 18 | //process motion data here 19 | }; 20 | 21 | device->enable_motion_tracking(motion_callback); 22 | 23 | //set the camera to produce all streams timestamps from a single clock - the microcontroller's clock. 24 | //this option takes effect only if motion tracking is enabled and device->start() is called with rs::source::all_sources argument. 25 | device->set_option(rs::option::fisheye_strobe, 1); 26 | } 27 | 28 | int main(int argc, char* argv[]) try 29 | { 30 | if (argc < 2) 31 | { 32 | cerr << "missing record file argument" << endl; 33 | return -1; 34 | } 35 | 36 | const string output_file(argv[1]); 37 | 38 | //create a record enabled context with a given output file 39 | rs::record::context context(output_file.c_str()); 40 | 41 | if(context.get_device_count() == 0) 42 | { 43 | cerr<<"no device detected" << endl; 44 | return -1; 45 | } 46 | 47 | //each device created from the record enabled context will write the streaming data to the given file 48 | rs::record::device* device = context.get_record_device(0); 49 | 50 | auto frame_callback = [](rs::frame frame) 51 | { 52 | auto timestamp_domain_str = frame.get_frame_timestamp_domain() == rs::timestamp_domain::camera ? "CAMERA" : "MICROCONTROLLER"; 53 | std::cout << "stream type: " << frame.get_stream_type() << ", frame time domain: " << timestamp_domain_str << ", frame timestamp: " << frame.get_timestamp() << std::endl; 54 | }; 55 | 56 | //enable required streams and set the frame callbacks 57 | vector streams = { rs::stream::color, rs::stream::depth, rs::stream::fisheye }; 58 | 59 | for(auto stream : streams) 60 | { 61 | device->enable_stream(stream, rs::preset::best_quality); 62 | device->set_frame_callback(stream, frame_callback); 63 | std::cout << "stream type: " << stream << ", width: " << device->get_stream_width(stream) << ", height: " << device->get_stream_height(stream) << ", format: " << device->get_stream_format(stream) << ", fps: " << device->get_stream_framerate(stream) << std::endl; 64 | } 65 | 66 | //enable motion tracking, provides IMU events, mandatory for fisheye stream timestamp sync. 67 | enable_motion_tracking(device); 68 | 69 | // the following scenario will start record for one second, then will pause the record (not the streaming) 70 | // for one second and resume recording for one more second 71 | device->start(rs::source::all_sources); 72 | std::this_thread::sleep_for(std::chrono::seconds(1)); 73 | device->pause_record(); 74 | std::this_thread::sleep_for(std::chrono::seconds(1)); 75 | device->resume_record(); 76 | std::this_thread::sleep_for(std::chrono::seconds(1)); 77 | device->stop(rs::source::all_sources); 78 | 79 | return 0; 80 | } 81 | 82 | catch(rs::error e) 83 | { 84 | std::cout << e.what() << std::endl; 85 | return -1; 86 | } 87 | -------------------------------------------------------------------------------- /sdk/include/rs/core/status.h: -------------------------------------------------------------------------------- 1 | // License: Apache 2.0. See LICENSE file in root directory. 2 | // Copyright(c) 2016 Intel Corporation. All Rights Reserved. 3 | 4 | /** 5 | * \file status.h 6 | * @brief Describes the return status codes used by SDK interfaces. 7 | */ 8 | 9 | #pragma once 10 | 11 | namespace rs 12 | { 13 | namespace core 14 | { 15 | /** @brief 16 | * Defines return codes that SDK interfaces 17 | * use. Negative values indicate errors, a zero value indicates success, 18 | * and positive values indicate warnings. 19 | */ 20 | enum status 21 | { 22 | /* success */ 23 | status_no_error = 0, /**< Operation succeeded without any warning */ 24 | 25 | /* errors */ 26 | status_feature_unsupported = -1, /**< Unsupported feature */ 27 | status_param_unsupported = -2, /**< Unsupported parameter(s) */ 28 | status_item_unavailable = -3, /**< Item not found/not available */ 29 | status_key_already_exists = -4, /**< Key already exists in the data structure */ 30 | status_invalid_argument = -5, /**< Argument passed to the method is invalid */ 31 | 32 | status_handle_invalid = -101, /**< Invalid session, algorithm instance, or pointer */ 33 | status_alloc_failed = -102, /**< Memory allocation failure */ 34 | 35 | status_device_failed = -201, /**< Device failed due to malfunctioning */ 36 | status_device_lost = -202, /**< Device failed due to unplug or unavailability */ 37 | 38 | status_exec_aborted = -301, /**< Execution aborted due to errors in upstream components */ 39 | status_exec_inprogress = -302, /**< Asynchronous operation is in execution */ 40 | status_exec_timeout = -303, /**< Operation timeout */ 41 | 42 | status_file_write_failed = -401, /**< Failure in open file in WRITE mode */ 43 | status_file_read_failed = -402, /**< Failure in open file in READ mode */ 44 | status_file_close_failed = -403, /**< Failure in close a file handle */ 45 | status_file_open_failed = -404, /**< Failure in open a file handle */ 46 | 47 | status_data_unavailable = -501, /**< Data not available for middleware model or processing */ 48 | 49 | status_data_not_initialized = -502, /**< Data failed to initialize */ 50 | status_init_failed = -503, /**< Module failure during initialization */ 51 | 52 | status_match_not_found = -601, /**< Matching frame not found */ 53 | 54 | status_invalid_state = -701, /**< Current state does not allow this operation */ 55 | 56 | /* warnings */ 57 | status_time_gap = 101, /**< Time gap in timestamps */ 58 | status_param_inplace = 102, /**< Same parameters already defined */ 59 | status_data_not_changed = 103, /**< Data not changed (no new data available)*/ 60 | status_process_failed = 104, /**< Module failure during processing */ 61 | status_value_out_of_range = 105, /**< Data value(s) out of range*/ 62 | status_data_pending = 106, /**< Not all data was copied, more data is available for fetching*/ 63 | }; 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /sdk/include/rs/cv_modules/max_depth_value_module/max_depth_value_module.h: -------------------------------------------------------------------------------- 1 | // License: Apache 2.0. See LICENSE file in root directory. 2 | // Copyright(c) 2016 Intel Corporation. All Rights Reserved. 3 | 4 | 5 | /** 6 | * \file max_depth_value_module.h 7 | * @brief Describes the \c rs::cv_modules::max_depth_value_module and \c rs::cv_modules::max_depth_value_module_impl classes. 8 | **/ 9 | 10 | #pragma once 11 | #include "rs_core.h" 12 | #include "rs/cv_modules/max_depth_value_module/max_depth_value_output_interface.h" 13 | 14 | #ifdef WIN32 15 | #ifdef realsense_max_depth_value_module_EXPORTS 16 | #define DLL_EXPORT __declspec(dllexport) 17 | #else 18 | #define DLL_EXPORT __declspec(dllimport) 19 | #endif /* realsense_log_utils_EXPORTS */ 20 | #else /* defined (WIN32) */ 21 | #define DLL_EXPORT 22 | #endif 23 | 24 | namespace rs 25 | { 26 | namespace cv_modules 27 | { 28 | /** 29 | * @brief Forward declaration for the maximum depth value module implementation, as part of the pimpl pattern. 30 | */ 31 | class DLL_EXPORT max_depth_value_module_impl; 32 | 33 | /** 34 | * @brief Example computer vision module that calculates the maximum depth value. 35 | * 36 | * See the interfaces for complete documentation. 37 | */ 38 | class DLL_EXPORT max_depth_value_module : public rs::core::video_module_interface, 39 | public max_depth_value_output_interface 40 | { 41 | public: 42 | /** 43 | * @brief Constructor 44 | * @param m_milliseconds_added_to_simulate_larger_computation_time Milliseconds added to simulate larger computation time 45 | * @param is_async_processing Configures the module in sync or async processing mode 46 | */ 47 | max_depth_value_module(uint64_t m_milliseconds_added_to_simulate_larger_computation_time = 0, 48 | bool is_async_processing = true); 49 | 50 | max_depth_value_module(const max_depth_value_module&) = delete; 51 | max_depth_value_module& operator= (const max_depth_value_module&) = delete; 52 | max_depth_value_module(max_depth_value_module&&) = delete; 53 | max_depth_value_module& operator= (max_depth_value_module&&) = delete; 54 | 55 | // video_module_interface interface 56 | int32_t query_module_uid() override; 57 | core::status query_supported_module_config(int32_t idx, supported_module_config &supported_config) override; 58 | core::status query_current_module_config(actual_module_config &module_config) override; 59 | core::status set_module_config(const actual_module_config &module_config) override; 60 | core::status process_sample_set(const core::correlated_sample_set & sample_set) override; 61 | core::status register_event_handler(processing_event_handler *handler) override; 62 | core::status unregister_event_handler(processing_event_handler *handler) override; 63 | core::status flush_resources() override; 64 | core::status reset_config() override; 65 | 66 | // max_depth_value_output_interface interface 67 | max_depth_value_output_data get_max_depth_value_data() override; 68 | 69 | ~max_depth_value_module(); 70 | private: 71 | max_depth_value_module_impl * m_pimpl; 72 | }; 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /tests/utilities/utilities.h: -------------------------------------------------------------------------------- 1 | // License: Apache 2.0. See LICENSE file in root directory. 2 | // Copyright(c) 2016 Intel Corporation. All Rights Reserved. 3 | 4 | #pragma once 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include "rs/core/image_interface.h" 11 | #include "rs/utils/librealsense_conversion_utils.h" 12 | #include "rs/utils/smart_ptr_helpers.h" 13 | #include "rs/utils/self_releasing_array_data_releaser.h" 14 | 15 | namespace test_utils 16 | { 17 | static std::shared_ptr create_image(rs::device * device, rs::stream stream) 18 | { 19 | if(device->get_frame_data(stream) == nullptr) 20 | return nullptr; 21 | auto sdk_stream = rs::utils::convert_stream_type(stream); 22 | auto sdk_format = rs::utils::convert_pixel_format(device->get_stream_format(stream)); 23 | const int pitch = device->get_stream_width(stream) * rs::core::get_pixel_size(sdk_format); 24 | rs::core::image_info info = {device->get_stream_width(stream), 25 | device->get_stream_height(stream), 26 | sdk_format, 27 | pitch 28 | }; 29 | auto size = pitch * device->get_stream_height(stream); 30 | uint8_t * dst_data = new uint8_t[size]; 31 | memcpy(dst_data, device->get_frame_data(stream), size); 32 | auto data_releaser = new rs::utils::self_releasing_array_data_releaser(dst_data); 33 | return rs::utils::get_shared_ptr_with_releaser(rs::core::image_interface::create_instance_from_raw_data(&info, 34 | {dst_data, data_releaser}, 35 | sdk_stream, 36 | rs::core::image_interface::flag::any, 37 | device->get_frame_timestamp(stream), 38 | device->get_frame_number(stream))); 39 | } 40 | 41 | static std::map parse_configuration_file(std::string conf_file_path) 42 | { 43 | std::map pairs; 44 | 45 | std::ifstream conf_file(conf_file_path); 46 | if(conf_file.good()) 47 | { 48 | std::string line; 49 | while (std::getline(conf_file, line)) 50 | { 51 | //remove whitespaces 52 | auto removed = std::remove_if(line.begin(), line.end(), ::isspace); 53 | line.erase(removed, line.end()); 54 | 55 | std::string key; 56 | std::istringstream iss_line(line); 57 | if (std::getline(iss_line, key, '=')) 58 | { 59 | if (key[0] == '#') //comment line 60 | { 61 | continue; 62 | } 63 | std::string value; 64 | if (std::getline(iss_line, value)) 65 | { 66 | pairs[key] = value; 67 | } 68 | } 69 | } 70 | } 71 | return pairs; 72 | } 73 | 74 | } 75 | 76 | 77 | -------------------------------------------------------------------------------- /sdk/src/utilities/samples_time_sync/samples_time_sync_base.h: -------------------------------------------------------------------------------- 1 | // License: Apache 2.0. See LICENSE file in root directory. 2 | // Copyright(c) 2016 Intel Corporation. All Rights Reserved. 3 | 4 | #pragma once 5 | 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | 13 | #include "rs_sdk.h" 14 | #include "rs/utils/cyclic_array.h" 15 | 16 | 17 | namespace rs 18 | { 19 | namespace utils 20 | { 21 | 22 | typedef std::map>> streams_map; 23 | typedef std::map> motions_map; 24 | 25 | class samples_time_sync_base : public release_self_base 26 | { 27 | public: 28 | samples_time_sync_base(int streams_fps[static_cast(rs::core::stream_type::max)], 29 | int motions_fps[static_cast(rs::core::motion_type::max)], 30 | unsigned int max_input_latency, 31 | unsigned int not_matched_frames_buffer_size); 32 | 33 | virtual bool insert(rs::core::image_interface * new_image, rs::core::correlated_sample_set& sample_set) override; 34 | 35 | virtual bool insert(rs::core::motion_sample& new_motion, rs::core::correlated_sample_set& sample_set) override; 36 | 37 | virtual bool get_not_matched_frame(rs::core::stream_type stream_type, rs::core::image_interface ** not_matched_frame) override; 38 | 39 | virtual void flush() override; 40 | 41 | virtual ~samples_time_sync_base() {} 42 | 43 | protected: 44 | 45 | bool empty_list_exists(); 46 | 47 | virtual bool sync_all(streams_map&, motions_map&, rs::core::correlated_sample_set &sample_set) = 0; 48 | 49 | void pop_or_save_to_not_matched(rs::core::stream_type st_type); 50 | 51 | inline bool is_stream_registered(rs::core::stream_type stream) { return m_streams_fps[static_cast(stream)] != 0; } 52 | inline bool is_motion_registered(rs::core::motion_type motion) { return m_motions_fps[static_cast(motion)] != 0; } 53 | 54 | double get_max_diff() { return m_max_diff; } 55 | 56 | private: 57 | 58 | samples_time_sync_base& operator=(const samples_time_sync_base&) = delete; 59 | samples_time_sync_base(const samples_time_sync_base&) = delete; 60 | 61 | streams_map m_streams_map; 62 | motions_map m_motions_map; 63 | 64 | streams_map m_stream_lists_dropped_frames; 65 | 66 | std::mutex m_image_mutex; 67 | std::mutex m_dropped_images_mutex; 68 | 69 | unsigned int m_max_input_latency; 70 | unsigned int m_not_matched_frames_buffer_size; 71 | 72 | int m_streams_fps[static_cast(rs::core::stream_type::max)]; 73 | int m_motions_fps[static_cast(rs::core::motion_type::max)]; 74 | 75 | int m_highest_fps; // store the highest fps of all streams (not motions) 76 | double m_max_diff; // while searching for the closest match between two different frames 77 | // the difference in timestamp should not be karger than max_diff 78 | // which is half of the period of stream with highest fps (in ms) 79 | }; 80 | } 81 | } 82 | 83 | -------------------------------------------------------------------------------- /tests/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 2.8) 2 | include(ExternalProject) 3 | project(rs_tests) 4 | 5 | get_filename_component(ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR} DIRECTORY) 6 | set(SDK_DIR "${ROOT_DIR}/sdk") 7 | include(${ROOT_DIR}/cmake_includes/check_os.cmake) 8 | 9 | #Common settings 10 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") 11 | 12 | add_definitions(${COMPILE_DEFINITIONS}) 13 | 14 | if(CMAKE_BUILD_TYPE STREQUAL "Debug") 15 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -O0 ") 16 | endif() 17 | 18 | #--------------Add security options -------------------- 19 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_FORTIFY_SOURCE=2 ") #TODO: Check what it is 20 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fstack-protector-strong") 21 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIE -fPIC") 22 | 23 | #Add Gtest project 24 | ExternalProject_Add( 25 | gtest_lib 26 | URL https://github.com/google/googletest/archive/release-1.8.0.zip 27 | URL_HASH SHA1=667f873ab7a4d246062565fad32fb6d8e203ee73 28 | CMAKE_ARGS -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} 29 | -DCMAKE_SYSTEM_NAME=${CMAKE_SYSTEM_NAME} 30 | -DCMAKE_CXX_FLAGS=${CMAKE_CXX_FLAGS} 31 | -DCMAKE_EXE_LINKER_FLAGS=${CMAKE_EXE_LINKER_FLAGS} 32 | -DBUILD_GMOCK=OFF -DBUILD_GTEST=ON 33 | PREFIX ${CMAKE_CURRENT_BINARY_DIR}/gtest 34 | # Disable install step 35 | INSTALL_COMMAND "" 36 | ) 37 | # Set gtest properties 38 | ExternalProject_Get_Property(gtest_lib source_dir binary_dir) 39 | include_directories("${source_dir}/googletest/include") 40 | link_directories("${binary_dir}/googletest/") 41 | 42 | #build unit tests 43 | include_directories( 44 | ${SDK_DIR} 45 | ${SDK_DIR}/include/rs/core 46 | ${SDK_DIR}/src/cameras/include 47 | ${SDK_DIR}/src/cameras/playback/include 48 | ${SDK_DIR}/src/cameras/record/include 49 | ${SDK_DIR}/src/core/image 50 | ${SDK_DIR}/src/utilities/logger/include 51 | ${SDK_DIR}/src/include 52 | ${SDK_DIR}/include 53 | ) 54 | 55 | add_executable(${PROJECT_NAME} 56 | projection_fixture.h 57 | utilities/utilities.h 58 | utilities/version.h 59 | ${SDK_DIR}/include/rs/core/ref_count_interface.h 60 | 61 | main.cpp 62 | simple_streaming_tests.cpp 63 | record_device_tests.cpp 64 | playback_device_tests.cpp 65 | compression_tests.cpp 66 | image_tests.cpp 67 | logger_tests.cpp 68 | projection_tests.cpp 69 | librealsense_conversion_tests.cpp 70 | fps_counter_tests.cpp 71 | ref_count_tests.cpp 72 | ${SAMPLES_TIME_SYNC_TESTS} 73 | pipeline_tests.cpp 74 | ${FIND_DATA_PATH_TEST} 75 | rs_utils_tests.cpp 76 | versions_tests.cpp 77 | ) 78 | 79 | target_link_libraries(${PROJECT_NAME} 80 | ${GTEST_LIBS} 81 | ${PTHREAD} 82 | ${GLFW_LIBS} 83 | realsense_max_depth_value_module 84 | realsense_pipeline 85 | realsense 86 | realsense_image 87 | realsense_playback 88 | realsense_record 89 | realsense_log_utils 90 | realsense_viewer 91 | realsense_projection 92 | realsense_samples_time_sync 93 | ) 94 | 95 | add_dependencies(${PROJECT_NAME} 96 | realsense_max_depth_value_module 97 | realsense_pipeline 98 | realsense_image 99 | realsense_playback 100 | realsense_record 101 | realsense_log_utils 102 | realsense_viewer 103 | realsense_projection 104 | realsense_samples_time_sync 105 | gtest_lib 106 | ) 107 | 108 | install(TARGETS ${PROJECT_NAME} DESTINATION bin) 109 | 110 | file(COPY ${ROOT_DIR}/dependencies_versions DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) 111 | -------------------------------------------------------------------------------- /sdk/src/cameras/playback/include/rs_stream_impl.h: -------------------------------------------------------------------------------- 1 | // License: Apache 2.0. See LICENSE file in root directory. 2 | // Copyright(c) 2016 Intel Corporation. All Rights Reserved. 3 | 4 | #pragma once 5 | #include 6 | #include 7 | #include "include/file_types.h" 8 | 9 | namespace rs 10 | { 11 | namespace playback 12 | { 13 | class rs_stream_impl : public rs_stream_interface 14 | { 15 | public: 16 | rs_stream_impl() : m_is_enabled(false) {} 17 | rs_stream_impl(rs::core::file_types::stream_info &stream_info) : m_stream_info(stream_info), m_is_enabled(false) {} 18 | void set_frame(std::shared_ptr &frame) { m_frame = frame;} 19 | std::shared_ptr get_frame() { return m_frame; } 20 | void clear_data() { m_frame.reset(); } 21 | void set_is_enabled(bool state) { m_is_enabled = state; } 22 | virtual rs_extrinsics get_extrinsics_to(const rs_stream_interface &r) const override; 23 | virtual float get_depth_scale() const override { return m_stream_info.profile.depth_scale; } 24 | virtual rs_intrinsics get_intrinsics() const override { return m_stream_info.profile.intrinsics; } 25 | virtual rs_intrinsics get_rectified_intrinsics() const override { return m_stream_info.profile.rect_intrinsics; } 26 | virtual rs_format get_format() const override { return m_stream_info.profile.info.format; } 27 | virtual int get_framerate() const override { return m_stream_info.profile.frame_rate; } 28 | virtual double get_frame_metadata(rs_frame_metadata frame_metadata) const override { return m_frame ? m_frame->metadata.at(frame_metadata) : throw std::runtime_error("frame is nullptr"); } 29 | virtual bool supports_frame_metadata(rs_frame_metadata frame_metadata) const override { return m_frame && (m_frame->metadata.find(frame_metadata) != m_frame->metadata.end()); } 30 | virtual unsigned long long get_frame_number() const override { return m_frame ? m_frame->finfo.number : 0; } 31 | virtual long long get_frame_system_time() const override { return m_frame ? m_frame->finfo.system_time : 0; } 32 | virtual const uint8_t *get_frame_data() const override { return m_frame ? m_frame->data : nullptr; } 33 | virtual int get_mode_count() const override { return get_format() == rs_format::RS_FORMAT_ANY ? 0 : 1; } 34 | virtual double get_frame_timestamp() const override { return m_frame ? m_frame->finfo.time_stamp : 0; } 35 | virtual void get_mode(int mode, int *w, int *h, rs_format *f, int *fps) const override; 36 | virtual bool is_enabled() const override { return m_is_enabled; } 37 | virtual bool has_data() const { return m_frame ? true : false; } 38 | virtual rs_stream get_stream_type() const { return m_stream_info.stream; } 39 | virtual int get_frame_stride() const { return m_frame ? m_frame->finfo.stride : 0; } 40 | virtual int get_frame_bpp() const { return m_frame ? m_frame->finfo.bpp : 0; } 41 | rs::core::file_types::stream_info get_stream_info() { return m_stream_info; } 42 | void create_extrinsics(const std::map> & streams); 43 | private: 44 | bool m_is_enabled; 45 | rs::core::file_types::stream_info m_stream_info; 46 | std::shared_ptr m_frame; 47 | std::map m_extrinsics_to; 48 | }; 49 | } 50 | } 51 | --------------------------------------------------------------------------------