├── .gitattributes ├── .gitignore ├── LICENSE ├── README.md ├── addon_config.mk ├── example ├── Makefile ├── Project.xcconfig ├── addons.make ├── config.make ├── example.sln ├── example.vcxproj ├── example.vcxproj.filters ├── example.xcodeproj │ ├── project.pbxproj │ ├── project.xcworkspace │ │ ├── contents.xcworkspacedata │ │ └── xcshareddata │ │ │ ├── IDEWorkspaceChecks.plist │ │ │ └── WorkspaceSettings.xcsettings │ └── xcshareddata │ │ └── xcschemes │ │ ├── example Debug.xcscheme │ │ └── example Release.xcscheme ├── icon.rc ├── openFrameworks-Info.plist └── src │ ├── main.cpp │ ├── ofApp.cpp │ └── ofApp.h ├── libs ├── librealsense2 │ ├── export │ │ ├── Win32 │ │ │ ├── Intel.Realsense.dll │ │ │ └── realsense2.dll │ │ └── x64 │ │ │ ├── Intel.Realsense.dll │ │ │ └── realsense2.dll │ ├── include │ │ └── librealsense2 │ │ │ ├── h │ │ │ ├── rs_advanced_mode_command.h │ │ │ ├── rs_config.h │ │ │ ├── rs_context.h │ │ │ ├── rs_device.h │ │ │ ├── rs_frame.h │ │ │ ├── rs_internal.h │ │ │ ├── rs_option.h │ │ │ ├── rs_pipeline.h │ │ │ ├── rs_processing.h │ │ │ ├── rs_record_playback.h │ │ │ ├── rs_sensor.h │ │ │ └── rs_types.h │ │ │ ├── hpp │ │ │ ├── rs_context.hpp │ │ │ ├── rs_device.hpp │ │ │ ├── rs_export.hpp │ │ │ ├── rs_frame.hpp │ │ │ ├── rs_internal.hpp │ │ │ ├── rs_options.hpp │ │ │ ├── rs_pipeline.hpp │ │ │ ├── rs_processing.hpp │ │ │ ├── rs_record_playback.hpp │ │ │ ├── rs_sensor.hpp │ │ │ └── rs_types.hpp │ │ │ ├── rs.h │ │ │ ├── rs.hpp │ │ │ ├── rs_advanced_mode.h │ │ │ ├── rs_advanced_mode.hpp │ │ │ └── rsutil.h │ └── lib │ │ ├── osx │ │ ├── libfw.a │ │ ├── librealsense-file.a │ │ ├── librealsense2-gl.a │ │ ├── librealsense2.a │ │ ├── libtm.a │ │ └── libuvc_fw.a │ │ └── vs │ │ ├── Win32 │ │ └── realsense2.lib │ │ └── x64 │ │ └── realsense2.lib └── libusb │ └── lib │ └── osx │ └── libusb-1.0.a └── src ├── ofxRealSense2.h └── ofxRealSense2 ├── Context.cpp ├── Context.h ├── Device.cpp └── Device.h /.gitattributes: -------------------------------------------------------------------------------- 1 | *.a filter=lfs diff=lfs merge=lfs -text 2 | *.dll filter=lfs diff=lfs merge=lfs -text 3 | *.lib filter=lfs diff=lfs merge=lfs -text 4 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.depend 2 | *.layout 3 | *.mode*v3 4 | *.pbxuser 5 | *.app* 6 | *.DS_* 7 | ._*.* 8 | 9 | .svn/ 10 | obj/ 11 | bin/ 12 | !bin/data/ 13 | build/ 14 | xcuserdata/ 15 | 16 | ipch/ 17 | *.suo 18 | *.opensdf 19 | *.vcxproj.user 20 | *.db 21 | *.opendb 22 | 23 | *.obj 24 | *.tlog 25 | *.sdf 26 | *.pdb 27 | *.idb 28 | *.pch 29 | Debug/ 30 | Release/ 31 | 32 | 33 | *~.xml 34 | .vs/ 35 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2019 Elie Zananiri - prisonerjohn.com 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## ofxRealSense2 2 | 3 | Intel RealSense 2 SDK bridge for openFrameworks. 4 | 5 | Includes support for: 6 | * depth, color, and infrared images. 7 | * point clouds. 8 | * post-processing filters. 9 | 10 | ### Compatibility 11 | 12 | Tested on OF 0.10.1 / Windows 10 / Intel RealSense D435. 13 | 14 | Should work on other platforms and using other 400-series devices. -------------------------------------------------------------------------------- /addon_config.mk: -------------------------------------------------------------------------------- 1 | # All variables and this file are optional, if they are not present the PG and the 2 | # makefiles will try to parse the correct values from the file system. 3 | # 4 | # Variables that specify exclusions can use % as a wildcard to specify that anything in 5 | # that position will match. A partial path can also be specified to, for example, exclude 6 | # a whole folder from the parsed paths from the file system 7 | # 8 | # Variables can be specified using = or += 9 | # = will clear the contents of that variable both specified from the file or the ones parsed 10 | # from the file system 11 | # += will add the values to the previous ones in the file or the ones parsed from the file 12 | # system 13 | # 14 | # The PG can be used to detect errors in this file, just create a new project with this addon 15 | # and the PG will write to the console the kind of error and in which line it is 16 | 17 | meta: 18 | ADDON_NAME = ofxRealSense2 19 | ADDON_DESCRIPTION = Intel RealSense 2 SDK bridge 20 | ADDON_AUTHOR = Elie Zananiri 21 | ADDON_TAGS = 22 | ADDON_URL = https://github.com/prisonerjohn/ofxRealSense2 23 | 24 | common: 25 | # dependencies with other addons, a list of them separated by spaces 26 | # or use += in several lines 27 | # ADDON_DEPENDENCIES = 28 | 29 | # include search paths, this will be usually parsed from the file system 30 | # but if the addon or addon libraries need special search paths they can be 31 | # specified here separated by spaces or one per line using += 32 | # ADDON_INCLUDES = 33 | 34 | # any special flag that should be passed to the compiler when using this 35 | # addon 36 | # ADDON_CFLAGS = 37 | 38 | # any special flag that should be passed to the linker when using this 39 | # addon, also used for system libraries with -lname 40 | # ADDON_LDFLAGS = 41 | 42 | # linux only, any library that should be included in the project using 43 | # pkg-config 44 | # ADDON_PKG_CONFIG_LIBRARIES = 45 | 46 | # osx/iOS only, any framework that should be included in the project 47 | # ADDON_FRAMEWORKS = 48 | 49 | # source files, these will be usually parsed from the file system looking 50 | # in the src folders in libs and the root of the addon. if your addon needs 51 | # to include files in different places or a different set of files per platform 52 | # they can be specified here 53 | # ADDON_SOURCES = 54 | 55 | # some addons need resources to be copied to the bin/data folder of the project 56 | # specify here any files that need to be copied, you can use wildcards like * and ? 57 | # ADDON_DATA = 58 | 59 | # when parsing the file system looking for libraries exclude this for all or 60 | # a specific platform 61 | # ADDON_LIBS_EXCLUDE = 62 | 63 | ADDON_DLLS_TO_COPY = 64 | ADDON_DLLS_TO_COPY += "libs/librealsense2/export/x64/realsense2.dll" 65 | ADDON_DLLS_TO_COPY += "libs/librealsense2/export/x64/Intel.Realsense.dll" 66 | 67 | linux64: 68 | # binary libraries, these will be usually parsed from the file system but some 69 | # libraries need to passed to the linker in a specific order/ 70 | # 71 | # For example in the ofxOpenCV addon we do something like this: 72 | # 73 | # ADDON_LIBS = 74 | # ADDON_LIBS += libs/opencv/lib/linuxarmv6l/libopencv_legacy.a 75 | # ADDON_LIBS += libs/opencv/lib/linuxarmv6l/libopencv_calib3d.a 76 | # ... 77 | linux: 78 | win_cb: 79 | linuxarmv6l: 80 | linuxarmv7l: 81 | android/armeabi: 82 | android/armeabi-v7a: -------------------------------------------------------------------------------- /example/Makefile: -------------------------------------------------------------------------------- 1 | # Attempt to load a config.make file. 2 | # If none is found, project defaults in config.project.make will be used. 3 | ifneq ($(wildcard config.make),) 4 | include config.make 5 | endif 6 | 7 | # make sure the the OF_ROOT location is defined 8 | ifndef OF_ROOT 9 | OF_ROOT=$(realpath ../../..) 10 | endif 11 | 12 | # call the project makefile! 13 | include $(OF_ROOT)/libs/openFrameworksCompiled/project/makefileCommon/compile.project.mk 14 | -------------------------------------------------------------------------------- /example/Project.xcconfig: -------------------------------------------------------------------------------- 1 | //THE PATH TO THE ROOT OF OUR OF PATH RELATIVE TO THIS PROJECT. 2 | //THIS NEEDS TO BE DEFINED BEFORE CoreOF.xcconfig IS INCLUDED 3 | OF_PATH = ../../.. 4 | 5 | //THIS HAS ALL THE HEADER AND LIBS FOR OF CORE 6 | #include "../../../libs/openFrameworksCompiled/project/osx/CoreOF.xcconfig" 7 | 8 | //ICONS - NEW IN 0072 9 | ICON_NAME_DEBUG = icon-debug.icns 10 | ICON_NAME_RELEASE = icon.icns 11 | ICON_FILE_PATH = $(OF_PATH)/libs/openFrameworksCompiled/project/osx/ 12 | 13 | //IF YOU WANT AN APP TO HAVE A CUSTOM ICON - PUT THEM IN YOUR DATA FOLDER AND CHANGE ICON_FILE_PATH to: 14 | //ICON_FILE_PATH = bin/data/ 15 | 16 | OTHER_CFLAGS = $(OF_CORE_CFLAGS) 17 | OTHER_LDFLAGS = $(OF_CORE_LIBS) $(OF_CORE_FRAMEWORKS) 18 | HEADER_SEARCH_PATHS = $(OF_CORE_HEADERS) 19 | -------------------------------------------------------------------------------- /example/addons.make: -------------------------------------------------------------------------------- 1 | ofxGui 2 | ofxRealSense2 3 | -------------------------------------------------------------------------------- /example/config.make: -------------------------------------------------------------------------------- 1 | ################################################################################ 2 | # CONFIGURE PROJECT MAKEFILE (optional) 3 | # This file is where we make project specific configurations. 4 | ################################################################################ 5 | 6 | ################################################################################ 7 | # OF ROOT 8 | # The location of your root openFrameworks installation 9 | # (default) OF_ROOT = ../../.. 10 | ################################################################################ 11 | # OF_ROOT = ../../.. 12 | 13 | ################################################################################ 14 | # PROJECT ROOT 15 | # The location of the project - a starting place for searching for files 16 | # (default) PROJECT_ROOT = . (this directory) 17 | # 18 | ################################################################################ 19 | # PROJECT_ROOT = . 20 | 21 | ################################################################################ 22 | # PROJECT SPECIFIC CHECKS 23 | # This is a project defined section to create internal makefile flags to 24 | # conditionally enable or disable the addition of various features within 25 | # this makefile. For instance, if you want to make changes based on whether 26 | # GTK is installed, one might test that here and create a variable to check. 27 | ################################################################################ 28 | # None 29 | 30 | ################################################################################ 31 | # PROJECT EXTERNAL SOURCE PATHS 32 | # These are fully qualified paths that are not within the PROJECT_ROOT folder. 33 | # Like source folders in the PROJECT_ROOT, these paths are subject to 34 | # exlclusion via the PROJECT_EXLCUSIONS list. 35 | # 36 | # (default) PROJECT_EXTERNAL_SOURCE_PATHS = (blank) 37 | # 38 | # Note: Leave a leading space when adding list items with the += operator 39 | ################################################################################ 40 | # PROJECT_EXTERNAL_SOURCE_PATHS = 41 | 42 | ################################################################################ 43 | # PROJECT EXCLUSIONS 44 | # These makefiles assume that all folders in your current project directory 45 | # and any listed in the PROJECT_EXTERNAL_SOURCH_PATHS are are valid locations 46 | # to look for source code. The any folders or files that match any of the 47 | # items in the PROJECT_EXCLUSIONS list below will be ignored. 48 | # 49 | # Each item in the PROJECT_EXCLUSIONS list will be treated as a complete 50 | # string unless teh user adds a wildcard (%) operator to match subdirectories. 51 | # GNU make only allows one wildcard for matching. The second wildcard (%) is 52 | # treated literally. 53 | # 54 | # (default) PROJECT_EXCLUSIONS = (blank) 55 | # 56 | # Will automatically exclude the following: 57 | # 58 | # $(PROJECT_ROOT)/bin% 59 | # $(PROJECT_ROOT)/obj% 60 | # $(PROJECT_ROOT)/%.xcodeproj 61 | # 62 | # Note: Leave a leading space when adding list items with the += operator 63 | ################################################################################ 64 | # PROJECT_EXCLUSIONS = 65 | 66 | ################################################################################ 67 | # PROJECT LINKER FLAGS 68 | # These flags will be sent to the linker when compiling the executable. 69 | # 70 | # (default) PROJECT_LDFLAGS = -Wl,-rpath=./libs 71 | # 72 | # Note: Leave a leading space when adding list items with the += operator 73 | ################################################################################ 74 | 75 | # Currently, shared libraries that are needed are copied to the 76 | # $(PROJECT_ROOT)/bin/libs directory. The following LDFLAGS tell the linker to 77 | # add a runtime path to search for those shared libraries, since they aren't 78 | # incorporated directly into the final executable application binary. 79 | # TODO: should this be a default setting? 80 | # PROJECT_LDFLAGS=-Wl,-rpath=./libs 81 | 82 | ################################################################################ 83 | # PROJECT DEFINES 84 | # Create a space-delimited list of DEFINES. The list will be converted into 85 | # CFLAGS with the "-D" flag later in the makefile. 86 | # 87 | # (default) PROJECT_DEFINES = (blank) 88 | # 89 | # Note: Leave a leading space when adding list items with the += operator 90 | ################################################################################ 91 | # PROJECT_DEFINES = 92 | 93 | ################################################################################ 94 | # PROJECT CFLAGS 95 | # This is a list of fully qualified CFLAGS required when compiling for this 96 | # project. These CFLAGS will be used IN ADDITION TO the PLATFORM_CFLAGS 97 | # defined in your platform specific core configuration files. These flags are 98 | # presented to the compiler BEFORE the PROJECT_OPTIMIZATION_CFLAGS below. 99 | # 100 | # (default) PROJECT_CFLAGS = (blank) 101 | # 102 | # Note: Before adding PROJECT_CFLAGS, note that the PLATFORM_CFLAGS defined in 103 | # your platform specific configuration file will be applied by default and 104 | # further flags here may not be needed. 105 | # 106 | # Note: Leave a leading space when adding list items with the += operator 107 | ################################################################################ 108 | # PROJECT_CFLAGS = 109 | 110 | ################################################################################ 111 | # PROJECT OPTIMIZATION CFLAGS 112 | # These are lists of CFLAGS that are target-specific. While any flags could 113 | # be conditionally added, they are usually limited to optimization flags. 114 | # These flags are added BEFORE the PROJECT_CFLAGS. 115 | # 116 | # PROJECT_OPTIMIZATION_CFLAGS_RELEASE flags are only applied to RELEASE targets. 117 | # 118 | # (default) PROJECT_OPTIMIZATION_CFLAGS_RELEASE = (blank) 119 | # 120 | # PROJECT_OPTIMIZATION_CFLAGS_DEBUG flags are only applied to DEBUG targets. 121 | # 122 | # (default) PROJECT_OPTIMIZATION_CFLAGS_DEBUG = (blank) 123 | # 124 | # Note: Before adding PROJECT_OPTIMIZATION_CFLAGS, please note that the 125 | # PLATFORM_OPTIMIZATION_CFLAGS defined in your platform specific configuration 126 | # file will be applied by default and further optimization flags here may not 127 | # be needed. 128 | # 129 | # Note: Leave a leading space when adding list items with the += operator 130 | ################################################################################ 131 | # PROJECT_OPTIMIZATION_CFLAGS_RELEASE = 132 | # PROJECT_OPTIMIZATION_CFLAGS_DEBUG = 133 | 134 | ################################################################################ 135 | # PROJECT COMPILERS 136 | # Custom compilers can be set for CC and CXX 137 | # (default) PROJECT_CXX = (blank) 138 | # (default) PROJECT_CC = (blank) 139 | # Note: Leave a leading space when adding list items with the += operator 140 | ################################################################################ 141 | # PROJECT_CXX = 142 | # PROJECT_CC = 143 | -------------------------------------------------------------------------------- /example/example.sln: -------------------------------------------------------------------------------- 1 | Microsoft Visual Studio Solution File, Format Version 12.00 2 | # Visual Studio 15 3 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "example", "example.vcxproj", "{7FD42DF7-442E-479A-BA76-D0022F99702A}" 4 | EndProject 5 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "openframeworksLib", "..\..\..\libs\openFrameworksCompiled\project\vs\openframeworksLib.vcxproj", "{5837595D-ACA9-485C-8E76-729040CE4B0B}" 6 | EndProject 7 | Global 8 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 9 | Debug|Win32 = Debug|Win32 10 | Debug|x64 = Debug|x64 11 | Release|Win32 = Release|Win32 12 | Release|x64 = Release|x64 13 | EndGlobalSection 14 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 15 | {7FD42DF7-442E-479A-BA76-D0022F99702A}.Debug|Win32.ActiveCfg = Debug|Win32 16 | {7FD42DF7-442E-479A-BA76-D0022F99702A}.Debug|Win32.Build.0 = Debug|Win32 17 | {7FD42DF7-442E-479A-BA76-D0022F99702A}.Debug|x64.ActiveCfg = Debug|x64 18 | {7FD42DF7-442E-479A-BA76-D0022F99702A}.Debug|x64.Build.0 = Debug|x64 19 | {7FD42DF7-442E-479A-BA76-D0022F99702A}.Release|Win32.ActiveCfg = Release|Win32 20 | {7FD42DF7-442E-479A-BA76-D0022F99702A}.Release|Win32.Build.0 = Release|Win32 21 | {7FD42DF7-442E-479A-BA76-D0022F99702A}.Release|x64.ActiveCfg = Release|x64 22 | {7FD42DF7-442E-479A-BA76-D0022F99702A}.Release|x64.Build.0 = Release|x64 23 | {5837595D-ACA9-485C-8E76-729040CE4B0B}.Debug|Win32.ActiveCfg = Debug|Win32 24 | {5837595D-ACA9-485C-8E76-729040CE4B0B}.Debug|Win32.Build.0 = Debug|Win32 25 | {5837595D-ACA9-485C-8E76-729040CE4B0B}.Debug|x64.ActiveCfg = Debug|x64 26 | {5837595D-ACA9-485C-8E76-729040CE4B0B}.Debug|x64.Build.0 = Debug|x64 27 | {5837595D-ACA9-485C-8E76-729040CE4B0B}.Release|Win32.ActiveCfg = Release|Win32 28 | {5837595D-ACA9-485C-8E76-729040CE4B0B}.Release|Win32.Build.0 = Release|Win32 29 | {5837595D-ACA9-485C-8E76-729040CE4B0B}.Release|x64.ActiveCfg = Release|x64 30 | {5837595D-ACA9-485C-8E76-729040CE4B0B}.Release|x64.Build.0 = Release|x64 31 | EndGlobalSection 32 | GlobalSection(SolutionProperties) = preSolution 33 | HideSolutionNode = FALSE 34 | EndGlobalSection 35 | EndGlobal 36 | -------------------------------------------------------------------------------- /example/example.vcxproj.filters: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | src 6 | 7 | 8 | src 9 | 10 | 11 | src 12 | 13 | 14 | src 15 | 16 | 17 | addons\ofxGui\src 18 | 19 | 20 | addons\ofxGui\src 21 | 22 | 23 | addons\ofxGui\src 24 | 25 | 26 | addons\ofxGui\src 27 | 28 | 29 | addons\ofxGui\src 30 | 31 | 32 | addons\ofxGui\src 33 | 34 | 35 | addons\ofxGui\src 36 | 37 | 38 | addons\ofxGui\src 39 | 40 | 41 | addons\ofxGui\src 42 | 43 | 44 | addons\ofxGui\src 45 | 46 | 47 | addons\ofxRealSense2\src\ofxRealSense2 48 | 49 | 50 | addons\ofxRealSense2\src\ofxRealSense2 51 | 52 | 53 | 54 | 55 | {d8376475-7454-4a24-b08a-aac121d3ad6f} 56 | 57 | 58 | {71834F65-F3A9-211E-73B8-DC85} 59 | 60 | 61 | {4F2A59AF-5F4E-704B-D067-EC13} 62 | 63 | 64 | {645E9533-4DCD-6179-1CDF-CB65} 65 | 66 | 67 | {5E414EC7-938D-B210-1EA5-4B7E} 68 | 69 | 70 | {0AD0D798-2777-D570-3A9E-A47E} 71 | 72 | 73 | {4CD48D47-184F-1E2D-B37F-4A33} 74 | 75 | 76 | {31F61894-F298-D1AC-CA61-3602} 77 | 78 | 79 | {325F962A-28D1-7C54-A17F-044D} 80 | 81 | 82 | {C8A8D209-5674-CAC2-DF79-67F1} 83 | 84 | 85 | {068FD0DD-76A7-5248-0AD6-B638} 86 | 87 | 88 | {30018C1E-0A7B-5554-EBC0-4ED0} 89 | 90 | 91 | {30026F3B-2A45-B0D5-2BC8-8157} 92 | 93 | 94 | 95 | 96 | src 97 | 98 | 99 | src 100 | 101 | 102 | addons\ofxGui\src 103 | 104 | 105 | addons\ofxGui\src 106 | 107 | 108 | addons\ofxGui\src 109 | 110 | 111 | addons\ofxGui\src 112 | 113 | 114 | addons\ofxGui\src 115 | 116 | 117 | addons\ofxGui\src 118 | 119 | 120 | addons\ofxGui\src 121 | 122 | 123 | addons\ofxGui\src 124 | 125 | 126 | addons\ofxGui\src 127 | 128 | 129 | addons\ofxGui\src 130 | 131 | 132 | addons\ofxGui\src 133 | 134 | 135 | addons\ofxRealSense2\src\ofxRealSense2 136 | 137 | 138 | addons\ofxRealSense2\src\ofxRealSense2 139 | 140 | 141 | addons\ofxRealSense2\src 142 | 143 | 144 | addons\ofxRealSense2\libs\librealsense2\include\librealsense2\h 145 | 146 | 147 | addons\ofxRealSense2\libs\librealsense2\include\librealsense2\h 148 | 149 | 150 | addons\ofxRealSense2\libs\librealsense2\include\librealsense2\h 151 | 152 | 153 | addons\ofxRealSense2\libs\librealsense2\include\librealsense2\h 154 | 155 | 156 | addons\ofxRealSense2\libs\librealsense2\include\librealsense2\h 157 | 158 | 159 | addons\ofxRealSense2\libs\librealsense2\include\librealsense2\h 160 | 161 | 162 | addons\ofxRealSense2\libs\librealsense2\include\librealsense2\h 163 | 164 | 165 | addons\ofxRealSense2\libs\librealsense2\include\librealsense2\h 166 | 167 | 168 | addons\ofxRealSense2\libs\librealsense2\include\librealsense2\h 169 | 170 | 171 | addons\ofxRealSense2\libs\librealsense2\include\librealsense2\h 172 | 173 | 174 | addons\ofxRealSense2\libs\librealsense2\include\librealsense2\h 175 | 176 | 177 | addons\ofxRealSense2\libs\librealsense2\include\librealsense2\h 178 | 179 | 180 | addons\ofxRealSense2\libs\librealsense2\include\librealsense2\hpp 181 | 182 | 183 | addons\ofxRealSense2\libs\librealsense2\include\librealsense2\hpp 184 | 185 | 186 | addons\ofxRealSense2\libs\librealsense2\include\librealsense2\hpp 187 | 188 | 189 | addons\ofxRealSense2\libs\librealsense2\include\librealsense2\hpp 190 | 191 | 192 | addons\ofxRealSense2\libs\librealsense2\include\librealsense2\hpp 193 | 194 | 195 | addons\ofxRealSense2\libs\librealsense2\include\librealsense2\hpp 196 | 197 | 198 | addons\ofxRealSense2\libs\librealsense2\include\librealsense2\hpp 199 | 200 | 201 | addons\ofxRealSense2\libs\librealsense2\include\librealsense2\hpp 202 | 203 | 204 | addons\ofxRealSense2\libs\librealsense2\include\librealsense2\hpp 205 | 206 | 207 | addons\ofxRealSense2\libs\librealsense2\include\librealsense2\hpp 208 | 209 | 210 | addons\ofxRealSense2\libs\librealsense2\include\librealsense2\hpp 211 | 212 | 213 | addons\ofxRealSense2\libs\librealsense2\include\librealsense2 214 | 215 | 216 | addons\ofxRealSense2\libs\librealsense2\include\librealsense2 217 | 218 | 219 | addons\ofxRealSense2\libs\librealsense2\include\librealsense2 220 | 221 | 222 | addons\ofxRealSense2\libs\librealsense2\include\librealsense2 223 | 224 | 225 | addons\ofxRealSense2\libs\librealsense2\include\librealsense2 226 | 227 | 228 | 229 | 230 | 231 | 232 | -------------------------------------------------------------------------------- /example/example.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /example/example.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /example/example.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | BuildSystemType 6 | Original 7 | 8 | 9 | -------------------------------------------------------------------------------- /example/example.xcodeproj/xcshareddata/xcschemes/example Debug.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 39 | 40 | 41 | 42 | 51 | 52 | 58 | 59 | 60 | 61 | 62 | 63 | 69 | 70 | 76 | 77 | 78 | 79 | 81 | 82 | 85 | 86 | 87 | -------------------------------------------------------------------------------- /example/example.xcodeproj/xcshareddata/xcschemes/example Release.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 39 | 40 | 41 | 42 | 51 | 52 | 58 | 59 | 60 | 61 | 62 | 63 | 69 | 70 | 76 | 77 | 78 | 79 | 81 | 82 | 85 | 86 | 87 | -------------------------------------------------------------------------------- /example/icon.rc: -------------------------------------------------------------------------------- 1 | // Icon Resource Definition 2 | #define MAIN_ICON 102 3 | 4 | #if defined(_DEBUG) 5 | MAIN_ICON ICON "icon_debug.ico" 6 | #else 7 | MAIN_ICON ICON "icon.ico" 8 | #endif 9 | -------------------------------------------------------------------------------- /example/openFrameworks-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | English 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIdentifier 10 | cc.openFrameworks.${EXECUTABLE_NAME} 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundlePackageType 14 | APPL 15 | CFBundleSignature 16 | ???? 17 | CFBundleVersion 18 | 1.0 19 | CFBundleIconFile 20 | ${ICON} 21 | NSCameraUsageDescription 22 | This app needs to access the camera 23 | NSMicrophoneUsageDescription 24 | This app needs to access the microphone 25 | 26 | 27 | -------------------------------------------------------------------------------- /example/src/main.cpp: -------------------------------------------------------------------------------- 1 | #include "ofMain.h" 2 | #include "ofApp.h" 3 | 4 | //======================================================================== 5 | int main( ){ 6 | ofSetupOpenGL(1280,720,OF_WINDOW); // <-------- setup the GL context 7 | 8 | // this kicks off the running of my app 9 | // can be OF_WINDOW or OF_FULLSCREEN 10 | // pass in width and height too: 11 | ofRunApp(new ofApp()); 12 | 13 | } 14 | -------------------------------------------------------------------------------- /example/src/ofApp.cpp: -------------------------------------------------------------------------------- 1 | #include "ofApp.h" 2 | 3 | void ofApp::setup() 4 | { 5 | ofDisableArbTex(); 6 | 7 | this->guiPanel.setup("settings.xml"); 8 | 9 | this->eventListeners.push(this->context.deviceAddedEvent.newListener([&](std::string serialNumber) 10 | { 11 | ofLogNotice(__FUNCTION__) << "Starting device " << serialNumber; 12 | auto device = this->context.getDevice(serialNumber); 13 | device->enableDepth(); 14 | device->enableColor(); 15 | device->enablePoints(); 16 | device->startPipeline(); 17 | this->guiPanel.add(device->params); 18 | })); 19 | 20 | try 21 | { 22 | this->context.setup(false); 23 | } 24 | catch (std::exception& e) 25 | { 26 | ofLogFatalError(__FUNCTION__) << e.what(); 27 | } 28 | } 29 | 30 | void ofApp::exit() 31 | { 32 | this->context.clear(); 33 | } 34 | 35 | void ofApp::update() 36 | { 37 | this->context.update(); 38 | } 39 | 40 | void ofApp::draw() 41 | { 42 | ofBackground(0); 43 | 44 | int i = 0; 45 | auto it = this->context.getDevices().begin(); 46 | while (it != this->context.getDevices().end()) 47 | { 48 | int x = 640 * i; 49 | it->second->getDepthTex().draw(x, 0); 50 | it->second->getColorTex().draw(x, 360); 51 | 52 | if (ofInRange(ofGetMouseX(), x, x + 640) && 53 | ofInRange(ofGetMouseY(), 0, 360)) 54 | { 55 | float distance = it->second->getDistance(ofMap(ofGetMouseX(), x, x + 640, 0, 640), ofGetMouseY()); 56 | ofDrawBitmapStringHighlight(ofToString(distance, 3) + " m", ofGetMouseX(), ofGetMouseY()); 57 | } 58 | 59 | ++it; 60 | ++i; 61 | } 62 | 63 | this->cam.begin(); 64 | ofEnableDepthTest(); 65 | ofPushMatrix(); 66 | ofScale(100); 67 | { 68 | auto it = this->context.getDevices().begin(); 69 | while (it != this->context.getDevices().end()) 70 | { 71 | it->second->getColorTex().bind(); 72 | it->second->getPointsMesh().draw(); 73 | it->second->getColorTex().unbind(); 74 | 75 | ++it; 76 | } 77 | } 78 | ofPopMatrix(); 79 | ofDisableDepthTest(); 80 | this->cam.end(); 81 | 82 | ofDrawBitmapString(ofToString(ofGetFrameRate()), 10, 10); 83 | 84 | this->guiPanel.draw(); 85 | } 86 | 87 | void ofApp::keyPressed(int key) 88 | { 89 | 90 | } 91 | -------------------------------------------------------------------------------- /example/src/ofApp.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "ofMain.h" 4 | #include "ofxGui.h" 5 | #include "ofxRealSense2.h" 6 | 7 | class ofApp 8 | : public ofBaseApp 9 | { 10 | public: 11 | void setup(); 12 | void exit(); 13 | 14 | void update(); 15 | void draw(); 16 | 17 | void keyPressed(int key); 18 | 19 | ofxRealSense2::Context context; 20 | ofEventListeners eventListeners; 21 | 22 | ofEasyCam cam; 23 | 24 | ofxPanel guiPanel; 25 | }; 26 | -------------------------------------------------------------------------------- /libs/librealsense2/export/Win32/Intel.Realsense.dll: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:58046671bc678854e4d59ee0dc5dd353b9fd43d5450a5af20605a7363637ec06 3 | size 94064 4 | -------------------------------------------------------------------------------- /libs/librealsense2/export/Win32/realsense2.dll: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:011023cc774305ea2931011f39d109316a86ef32fd97db3b4cb97d555c150702 3 | size 18483056 4 | -------------------------------------------------------------------------------- /libs/librealsense2/export/x64/Intel.Realsense.dll: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:0b44333c04b9550368a963144fdba4c3e2eff083929cab8b7305763c9eae496f 3 | size 93552 4 | -------------------------------------------------------------------------------- /libs/librealsense2/export/x64/realsense2.dll: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:03a7dd7da534218a0205a144aa4009205aa28cd76586be50ad2d157ce5a9086a 3 | size 21063536 4 | -------------------------------------------------------------------------------- /libs/librealsense2/include/librealsense2/h/rs_advanced_mode_command.h: -------------------------------------------------------------------------------- 1 | /* License: Apache 2.0. See LICENSE file in root directory. 2 | Copyright(c) 2017 Intel Corporation. All Rights Reserved. */ 3 | 4 | /** 5 | * @file rs_advanced_mode_command.h 6 | * @brief Advanced Mode Commands header file 7 | */ 8 | 9 | #ifndef RS2_ADVANCED_MODE_COMMAND_H 10 | #define RS2_ADVANCED_MODE_COMMAND_H 11 | 12 | #include 13 | 14 | typedef struct 15 | { 16 | uint32_t plusIncrement; 17 | uint32_t minusDecrement; 18 | uint32_t deepSeaMedianThreshold; 19 | uint32_t scoreThreshA; 20 | uint32_t scoreThreshB; 21 | uint32_t textureDifferenceThreshold; 22 | uint32_t textureCountThreshold; 23 | uint32_t deepSeaSecondPeakThreshold; 24 | uint32_t deepSeaNeighborThreshold; 25 | uint32_t lrAgreeThreshold; 26 | }STDepthControlGroup; 27 | 28 | typedef struct 29 | { 30 | uint32_t rsmBypass; 31 | float diffThresh; 32 | float sloRauDiffThresh; 33 | uint32_t removeThresh; 34 | }STRsm; 35 | 36 | typedef struct 37 | { 38 | uint32_t minWest; 39 | uint32_t minEast; 40 | uint32_t minWEsum; 41 | uint32_t minNorth; 42 | uint32_t minSouth; 43 | uint32_t minNSsum; 44 | uint32_t uShrink; 45 | uint32_t vShrink; 46 | }STRauSupportVectorControl; 47 | 48 | typedef struct 49 | { 50 | uint32_t disableSADColor; 51 | uint32_t disableRAUColor; 52 | uint32_t disableSLORightColor; 53 | uint32_t disableSLOLeftColor; 54 | uint32_t disableSADNormalize; 55 | }STColorControl; 56 | 57 | typedef struct 58 | { 59 | uint32_t rauDiffThresholdRed; 60 | uint32_t rauDiffThresholdGreen; 61 | uint32_t rauDiffThresholdBlue; 62 | }STRauColorThresholdsControl; 63 | 64 | typedef struct 65 | { 66 | uint32_t diffThresholdRed; 67 | uint32_t diffThresholdGreen; 68 | uint32_t diffThresholdBlue; 69 | }STSloColorThresholdsControl; 70 | 71 | typedef struct 72 | { 73 | uint32_t sloK1Penalty; 74 | uint32_t sloK2Penalty; 75 | uint32_t sloK1PenaltyMod1; 76 | uint32_t sloK2PenaltyMod1; 77 | uint32_t sloK1PenaltyMod2; 78 | uint32_t sloK2PenaltyMod2; 79 | }STSloPenaltyControl; 80 | 81 | 82 | typedef struct 83 | { 84 | float lambdaCensus; 85 | float lambdaAD; 86 | uint32_t ignoreSAD; 87 | }STHdad; 88 | 89 | typedef struct 90 | { 91 | float colorCorrection1; 92 | float colorCorrection2; 93 | float colorCorrection3; 94 | float colorCorrection4; 95 | float colorCorrection5; 96 | float colorCorrection6; 97 | float colorCorrection7; 98 | float colorCorrection8; 99 | float colorCorrection9; 100 | float colorCorrection10; 101 | float colorCorrection11; 102 | float colorCorrection12; 103 | }STColorCorrection; 104 | 105 | typedef struct 106 | { 107 | uint32_t meanIntensitySetPoint; 108 | }STAEControl; 109 | 110 | typedef struct 111 | { 112 | uint32_t depthUnits; 113 | int32_t depthClampMin; 114 | int32_t depthClampMax; 115 | uint32_t disparityMode; 116 | int32_t disparityShift; 117 | }STDepthTableControl; 118 | 119 | typedef struct 120 | { 121 | uint32_t uDiameter; 122 | uint32_t vDiameter; 123 | }STCensusRadius; 124 | 125 | typedef struct 126 | { 127 | float amplitude; 128 | }STAFactor; 129 | 130 | #ifdef __cplusplus 131 | extern "C"{ 132 | #endif 133 | 134 | 135 | #ifdef __cplusplus 136 | } 137 | #endif 138 | 139 | #endif /*RS2_ADVANCED_MODE_COMMAND_H*/ 140 | -------------------------------------------------------------------------------- /libs/librealsense2/include/librealsense2/h/rs_config.h: -------------------------------------------------------------------------------- 1 | /* License: Apache 2.0. See LICENSE file in root directory. 2 | Copyright(c) 2017 Intel Corporation. All Rights Reserved. */ 3 | 4 | /** \file rs_pipeline.h 5 | * \brief 6 | * Exposes RealSense processing-block functionality for C compilers 7 | */ 8 | 9 | 10 | #ifndef LIBREALSENSE_RS2_CONFIG_H 11 | #define LIBREALSENSE_RS2_CONFIG_H 12 | 13 | #define RS2_DEFAULT_TIMEOUT 15000 14 | 15 | #ifdef __cplusplus 16 | extern "C" { 17 | #endif 18 | 19 | #include "rs_types.h" 20 | #include "rs_sensor.h" 21 | 22 | /** 23 | * Create a config instance 24 | * The config allows pipeline users to request filters for the pipeline streams and device selection and configuration. 25 | * This is an optional step in pipeline creation, as the pipeline resolves its streaming device internally. 26 | * Config provides its users a way to set the filters and test if there is no conflict with the pipeline requirements 27 | * from the device. It also allows the user to find a matching device for the config filters and the pipeline, in order to 28 | * select a device explicitly, and modify its controls before streaming starts. 29 | * 30 | * \param[out] error if non-null, receives any error that occurs during this call, otherwise, errors are ignored 31 | * \return rs2_config* A pointer to a new config instance 32 | */ 33 | rs2_config* rs2_create_config(rs2_error** error); 34 | 35 | /** 36 | * Deletes an instance of a config 37 | * 38 | * \param[in] config A pointer to an instance of a config 39 | */ 40 | void rs2_delete_config(rs2_config* config); 41 | 42 | /** 43 | * Enable a device stream explicitly, with selected stream parameters. 44 | * The method allows the application to request a stream with specific configuration. If no stream is explicitly enabled, the pipeline 45 | * configures the device and its streams according to the attached computer vision modules and processing blocks requirements, or 46 | * default configuration for the first available device. 47 | * The application can configure any of the input stream parameters according to its requirement, or set to 0 for don't care value. 48 | * The config accumulates the application calls for enable configuration methods, until the configuration is applied. Multiple enable 49 | * stream calls for the same stream with conflicting parameters override each other, and the last call is maintained. 50 | * Upon calling \c resolve(), the config checks for conflicts between the application configuration requests and the attached computer 51 | * vision modules and processing blocks requirements, and fails if conflicts are found. Before \c resolve() is called, no conflict 52 | * check is done. 53 | * 54 | * \param[in] config A pointer to an instance of a config 55 | * \param[in] stream Stream type to be enabled 56 | * \param[in] index Stream index, used for multiple streams of the same type. -1 indicates any. 57 | * \param[in] width Stream image width - for images streams. 0 indicates any. 58 | * \param[in] height Stream image height - for images streams. 0 indicates any. 59 | * \param[in] format Stream data format - pixel format for images streams, of data type for other streams. RS2_FORMAT_ANY indicates any. 60 | * \param[in] framerate Stream frames per second. 0 indicates any. 61 | * \param[out] error if non-null, receives any error that occurs during this call, otherwise, errors are ignored 62 | */ 63 | void rs2_config_enable_stream(rs2_config* config, 64 | rs2_stream stream, 65 | int index, 66 | int width, 67 | int height, 68 | rs2_format format, 69 | int framerate, 70 | rs2_error** error); 71 | 72 | /** 73 | * Enable all device streams explicitly. 74 | * The conditions and behavior of this method are similar to those of \c enable_stream(). 75 | * This filter enables all raw streams of the selected device. The device is either selected explicitly by the application, 76 | * or by the pipeline requirements or default. The list of streams is device dependent. 77 | * 78 | * \param[in] config A pointer to an instance of a config 79 | * \param[out] error if non-null, receives any error that occurs during this call, otherwise, errors are ignored 80 | */ 81 | void rs2_config_enable_all_stream(rs2_config* config, rs2_error ** error); 82 | 83 | /** 84 | * Select a specific device explicitly by its serial number, to be used by the pipeline. 85 | * The conditions and behavior of this method are similar to those of \c enable_stream(). 86 | * This method is required if the application needs to set device or sensor settings prior to pipeline streaming, to enforce 87 | * the pipeline to use the configured device. 88 | * 89 | * \param[in] config A pointer to an instance of a config 90 | * \param[in] serial device serial number, as returned by RS2_CAMERA_INFO_SERIAL_NUMBER 91 | * \param[out] error if non-null, receives any error that occurs during this call, otherwise, errors are ignored 92 | */ 93 | void rs2_config_enable_device(rs2_config* config, const char* serial, rs2_error ** error); 94 | 95 | /** 96 | * Select a recorded device from a file, to be used by the pipeline through playback. 97 | * The device available streams are as recorded to the file, and \c resolve() considers only this device and configuration 98 | * as available. 99 | * This request cannot be used if enable_record_to_file() is called for the current config, and vise versa 100 | * By default, playback is repeated once the file ends. To control this, see 'rs2_config_enable_device_from_file_repeat_option'. 101 | * 102 | * \param[in] config A pointer to an instance of a config 103 | * \param[in] file The playback file of the device 104 | * \param[out] error if non-null, receives any error that occurs during this call, otherwise, errors are ignored 105 | */ 106 | void rs2_config_enable_device_from_file(rs2_config* config, const char* file, rs2_error ** error); 107 | 108 | /** 109 | * Select a recorded device from a file, to be used by the pipeline through playback. 110 | * The device available streams are as recorded to the file, and \c resolve() considers only this device and configuration 111 | * as available. 112 | * This request cannot be used if enable_record_to_file() is called for the current config, and vise versa 113 | * 114 | * \param[in] config A pointer to an instance of a config 115 | * \param[in] file The playback file of the device 116 | * \param[in] repeat_playback if true, when file ends the playback starts again, in an infinite loop; 117 | if false, when file ends playback does not start again, and should by stopped manually by the user. 118 | * \param[out] error if non-null, receives any error that occurs during this call, otherwise, errors are ignored 119 | */ 120 | void rs2_config_enable_device_from_file_repeat_option(rs2_config* config, const char* file, int repeat_playback, rs2_error ** error); 121 | 122 | /** 123 | * Requires that the resolved device would be recorded to file 124 | * This request cannot be used if enable_device_from_file() is called for the current config, and vise versa 125 | * 126 | * \param[in] config A pointer to an instance of a config 127 | * \param[in] file The desired file for the output record 128 | * \param[out] error if non-null, receives any error that occurs during this call, otherwise, errors are ignored 129 | */ 130 | void rs2_config_enable_record_to_file(rs2_config* config, const char* file, rs2_error ** error); 131 | 132 | 133 | /** 134 | * Disable a device stream explicitly, to remove any requests on this stream type. 135 | * The stream can still be enabled due to pipeline computer vision module request. This call removes any filter on the 136 | * stream configuration. 137 | * 138 | * \param[in] config A pointer to an instance of a config 139 | * \param[in] stream Stream type, for which the filters are cleared 140 | * \param[out] error if non-null, receives any error that occurs during this call, otherwise, errors are ignored 141 | */ 142 | void rs2_config_disable_stream(rs2_config* config, rs2_stream stream, rs2_error ** error); 143 | 144 | /** 145 | * Disable a device stream explicitly, to remove any requests on this stream profile. 146 | * The stream can still be enabled due to pipeline computer vision module request. This call removes any filter on the 147 | * stream configuration. 148 | * 149 | * \param[in] config A pointer to an instance of a config 150 | * \param[in] stream Stream type, for which the filters are cleared 151 | * \param[in] index Stream index, for which the filters are cleared 152 | * \param[out] error if non-null, receives any error that occurs during this call, otherwise, errors are ignored 153 | */ 154 | void rs2_config_disable_indexed_stream(rs2_config* config, rs2_stream stream, int index, rs2_error ** error); 155 | 156 | /** 157 | * Disable all device stream explicitly, to remove any requests on the streams profiles. 158 | * The streams can still be enabled due to pipeline computer vision module request. This call removes any filter on the 159 | * streams configuration. 160 | * 161 | * \param[in] config A pointer to an instance of a config 162 | * \param[out] error if non-null, receives any error that occurs during this call, otherwise, errors are ignored 163 | */ 164 | void rs2_config_disable_all_streams(rs2_config* config, rs2_error ** error); 165 | 166 | /** 167 | * Resolve the configuration filters, to find a matching device and streams profiles. 168 | * The method resolves the user configuration filters for the device and streams, and combines them with the requirements of 169 | * the computer vision modules and processing blocks attached to the pipeline. If there are no conflicts of requests, it looks 170 | * for an available device, which can satisfy all requests, and selects the first matching streams configuration. In the absence 171 | * of any request, the rs2::config selects the first available device and the first color and depth streams configuration. 172 | * The pipeline profile selection during \c start() follows the same method. Thus, the selected profile is the same, if no 173 | * change occurs to the available devices occurs. 174 | * Resolving the pipeline configuration provides the application access to the pipeline selected device for advanced control. 175 | * The returned configuration is not applied to the device, so the application doesn't own the device sensors. However, the 176 | * application can call \c enable_device(), to enforce the device returned by this method is selected by pipeline \c start(), 177 | * and configure the device and sensors options or extensions before streaming starts. 178 | * 179 | * \param[in] config A pointer to an instance of a config 180 | * \param[in] pipe The pipeline for which the selected filters are applied 181 | * \param[out] error if non-null, receives any error that occurs during this call, otherwise, errors are ignored 182 | * \return A matching device and streams profile, which satisfies the filters and pipeline requests. 183 | */ 184 | rs2_pipeline_profile* rs2_config_resolve(rs2_config* config, rs2_pipeline* pipe, rs2_error ** error); 185 | 186 | /** 187 | * Check if the config can resolve the configuration filters, to find a matching device and streams profiles. 188 | * The resolution conditions are as described in \c resolve(). 189 | * 190 | * \param[in] config A pointer to an instance of a config 191 | * \param[in] pipe The pipeline for which the selected filters are applied 192 | * \param[out] error if non-null, receives any error that occurs during this call, otherwise, errors are ignored 193 | * \return True if a valid profile selection exists, false if no selection can be found under the config filters and the available devices. 194 | */ 195 | int rs2_config_can_resolve(rs2_config* config, rs2_pipeline* pipe, rs2_error ** error); 196 | 197 | #ifdef __cplusplus 198 | } 199 | #endif 200 | #endif 201 | -------------------------------------------------------------------------------- /libs/librealsense2/include/librealsense2/h/rs_context.h: -------------------------------------------------------------------------------- 1 | /* License: Apache 2.0. See LICENSE file in root directory. 2 | Copyright(c) 2017 Intel Corporation. All Rights Reserved. */ 3 | 4 | /** \file rs_context.h 5 | * \brief Exposes RealSense context functionality for C compilers 6 | */ 7 | 8 | 9 | #ifndef LIBREALSENSE_RS2_CONTEXT_H 10 | #define LIBREALSENSE_RS2_CONTEXT_H 11 | 12 | #ifdef __cplusplus 13 | extern "C" { 14 | #endif 15 | #include "rs_types.h" 16 | 17 | /** 18 | * \brief Creates RealSense context that is required for the rest of the API. 19 | * \param[in] api_version Users are expected to pass their version of \c RS2_API_VERSION to make sure they are running the correct librealsense version. 20 | * \param[out] error If non-null, receives any error that occurs during this call, otherwise, errors are ignored. 21 | * \return Context object 22 | */ 23 | rs2_context* rs2_create_context(int api_version, rs2_error** error); 24 | 25 | /** 26 | * \brief Frees the relevant context object. 27 | * \param[in] context Object that is no longer needed 28 | */ 29 | void rs2_delete_context(rs2_context* context); 30 | 31 | /** 32 | * set callback to get devices changed events 33 | * these events will be raised by the context whenever new RealSense device is connected or existing device gets disconnected 34 | * \param context Object representing librealsense session 35 | * \param[in] callback callback object created from c++ application. ownership over the callback object is moved into the context 36 | * \param[out] error if non-null, receives any error that occurs during this call, otherwise, errors are ignored 37 | */ 38 | void rs2_set_devices_changed_callback_cpp(rs2_context* context, rs2_devices_changed_callback* callback, rs2_error** error); 39 | 40 | /** 41 | * set callback to get devices changed events 42 | * these events will be raised by the context whenever new RealSense device is connected or existing device gets disconnected 43 | * \param context Object representing librealsense session 44 | * \param[in] callback function pointer to register as per-notifications callback 45 | * \param[out] error if non-null, receives any error that occurs during this call, otherwise, errors are ignored 46 | */ 47 | void rs2_set_devices_changed_callback(const rs2_context* context, rs2_devices_changed_callback_ptr callback, void* user, rs2_error** error); 48 | 49 | /** 50 | * Create a new device and add it to the context 51 | * \param ctx The context to which the new device will be added 52 | * \param file The file from which the device should be created 53 | * \param[out] error If non-null, receives any error that occurs during this call, otherwise, errors are ignored 54 | * @return A pointer to a device that plays data from the file, or null in case of failure 55 | */ 56 | rs2_device* rs2_context_add_device(rs2_context* ctx, const char* file, rs2_error** error); 57 | 58 | /** 59 | * Add an instance of software device to the context 60 | * \param ctx The context to which the new device will be added 61 | * \param dev Instance of software device to register into the context 62 | * \param[out] error If non-null, receives any error that occurs during this call, otherwise, errors are ignored 63 | */ 64 | void rs2_context_add_software_device(rs2_context* ctx, rs2_device* dev, rs2_error** error); 65 | 66 | /** 67 | * Removes a playback device from the context, if exists 68 | * \param[in] ctx The context from which the device should be removed 69 | * \param[in] file The file name that was used to add the device 70 | * \param[out] error If non-null, receives any error that occurs during this call, otherwise, errors are ignored 71 | */ 72 | void rs2_context_remove_device(rs2_context* ctx, const char* file, rs2_error** error); 73 | 74 | /** 75 | * Removes tracking module. 76 | * function query_devices() locks the tracking module in the tm_context object. 77 | * If the tracking module device is not used it should be removed using this function, so that other applications could find it. 78 | * This function can be used both before the call to query_device() to prevent enabling tracking modules or afterwards to 79 | * release them. 80 | */ 81 | void rs2_context_unload_tracking_module(rs2_context* ctx, rs2_error** error); 82 | 83 | /** 84 | * create a static snapshot of all connected devices at the time of the call 85 | * \param context Object representing librealsense session 86 | * \param[out] error if non-null, receives any error that occurs during this call, otherwise, errors are ignored 87 | * \return the list of devices, should be released by rs2_delete_device_list 88 | */ 89 | rs2_device_list* rs2_query_devices(const rs2_context* context, rs2_error** error); 90 | 91 | #define RS2_PRODUCT_LINE_ANY 0xff 92 | #define RS2_PRODUCT_LINE_ANY_INTEL 0xfe 93 | #define RS2_PRODUCT_LINE_NON_INTEL 0x01 94 | #define RS2_PRODUCT_LINE_D400 0x02 95 | #define RS2_PRODUCT_LINE_SR300 0x04 96 | #define RS2_PRODUCT_LINE_L500 0x08 97 | #define RS2_PRODUCT_LINE_T200 0x10 98 | #define RS2_PRODUCT_LINE_DEPTH (RS2_PRODUCT_LINE_L500 | RS2_PRODUCT_LINE_SR300 | RS2_PRODUCT_LINE_D400) 99 | #define RS2_PRODUCT_LINE_TRACKING RS2_PRODUCT_LINE_T200 100 | 101 | /** 102 | * create a static snapshot of all connected devices at the time of the call 103 | * \param context Object representing librealsense session 104 | * \param product_mask Controls what kind of devices will be returned 105 | * \param[out] error if non-null, receives any error that occurs during this call, otherwise, errors are ignored 106 | * \return the list of devices, should be released by rs2_delete_device_list 107 | */ 108 | rs2_device_list* rs2_query_devices_ex(const rs2_context* context, int product_mask, rs2_error** error); 109 | 110 | /** 111 | * \brief Creates RealSense device_hub . 112 | * \param[in] context The context for the device hub 113 | * \param[out] error If non-null, receives any error that occurs during this call, otherwise, errors are ignored. 114 | * \return Device hub object 115 | */ 116 | rs2_device_hub* rs2_create_device_hub(const rs2_context* context, rs2_error** error); 117 | 118 | /** 119 | * \brief Frees the relevant device hub object. 120 | * \param[in] hub Object that is no longer needed 121 | */ 122 | void rs2_delete_device_hub(const rs2_device_hub* hub); 123 | 124 | /** 125 | * If any device is connected return it, otherwise wait until next RealSense device connects. 126 | * Calling this method multiple times will cycle through connected devices 127 | * \param[in] ctx The context to creat the device 128 | * \param[in] hub The device hub object 129 | * \param[out] error If non-null, receives any error that occurs during this call, otherwise, errors are ignored. 130 | * \return device object 131 | */ 132 | rs2_device* rs2_device_hub_wait_for_device(const rs2_device_hub* hub, rs2_error** error); 133 | 134 | /** 135 | * Checks if device is still connected 136 | * \param[in] hub The device hub object 137 | * \param[in] device The device 138 | * \param[out] error If non-null, receives any error that occurs during this call, otherwise, errors are ignored. 139 | * \return 1 if the device is connected, 0 otherwise 140 | */ 141 | int rs2_device_hub_is_device_connected(const rs2_device_hub* hub, const rs2_device* device, rs2_error** error); 142 | 143 | 144 | #ifdef __cplusplus 145 | } 146 | #endif 147 | #endif 148 | -------------------------------------------------------------------------------- /libs/librealsense2/include/librealsense2/h/rs_device.h: -------------------------------------------------------------------------------- 1 | /* License: Apache 2.0. See LICENSE file in root directory. 2 | Copyright(c) 2017 Intel Corporation. All Rights Reserved. */ 3 | 4 | /** \file rs_device.h 5 | * \brief Exposes RealSense device functionality for C compilers 6 | */ 7 | 8 | 9 | #ifndef LIBREALSENSE_RS2_DEVICE_H 10 | #define LIBREALSENSE_RS2_DEVICE_H 11 | 12 | #ifdef __cplusplus 13 | extern "C" { 14 | #endif 15 | 16 | #include "rs_types.h" 17 | #include "rs_sensor.h" 18 | 19 | /** 20 | * Determines number of devices in a list. 21 | * \param[in] info_list The list of connected devices captured using rs2_query_devices 22 | * \param[out] error If non-null, receives any error that occurs during this call, otherwise, errors are ignored 23 | * \return Device count 24 | */ 25 | int rs2_get_device_count(const rs2_device_list* info_list, rs2_error** error); 26 | 27 | /** 28 | * Deletes device list, any devices created using this list will remain unaffected. 29 | * \param[in] info_list List to delete 30 | */ 31 | void rs2_delete_device_list(rs2_device_list* info_list); 32 | 33 | /** 34 | * Checks if a specific device is contained inside a device list. 35 | * \param[in] info_list The list of devices to check in 36 | * \param[in] device RealSense device to check for 37 | * \param[out] error If non-null, receives any error that occurs during this call, otherwise, errors are ignored 38 | * \return True if the device is in the list and false otherwise 39 | */ 40 | int rs2_device_list_contains(const rs2_device_list* info_list, const rs2_device* device, rs2_error** error); 41 | 42 | /** 43 | * Creates a device by index. The device object represents a physical camera and provides the means to manipulate it. 44 | * \param[in] info_list the list containing the device to retrieve 45 | * \param[in] index The zero based index of device to retrieve 46 | * \param[out] error If non-null, receives any error that occurs during this call, otherwise, errors are ignored 47 | * \return The requested device, should be released by rs2_delete_device 48 | */ 49 | rs2_device* rs2_create_device(const rs2_device_list* info_list, int index, rs2_error** error); 50 | 51 | /** 52 | * Delete RealSense device 53 | * \param[in] device Realsense device to delete 54 | */ 55 | void rs2_delete_device(rs2_device* device); 56 | 57 | /** 58 | * Retrieve camera specific information, like versions of various internal components. 59 | * \param[in] device The RealSense device 60 | * \param[in] info Camera info type to retrieve 61 | * \param[out] error If non-null, receives any error that occurs during this call, otherwise, errors are ignored 62 | * \return The requested camera info string, in a format specific to the device model 63 | */ 64 | const char* rs2_get_device_info(const rs2_device* device, rs2_camera_info info, rs2_error** error); 65 | 66 | /** 67 | * Check if a camera supports a specific camera info type. 68 | * \param[in] device The RealSense device to check 69 | * \param[in] info The parameter to check for support 70 | * \param[out] error If non-null, receives any error that occurs during this call, otherwise, errors are ignored 71 | * \return True if the parameter both exist and well-defined for the specific device 72 | */ 73 | int rs2_supports_device_info(const rs2_device* device, rs2_camera_info info, rs2_error** error); 74 | 75 | /** 76 | * Send hardware reset request to the device. The actual reset is asynchronous. 77 | * Note: Invalidates all handles to this device. 78 | * \param[in] device The RealSense device to reset 79 | * \param[out] error If non-null, receives any error that occurs during this call, otherwise, errors are ignored 80 | */ 81 | void rs2_hardware_reset(const rs2_device * device, rs2_error ** error); 82 | 83 | /** 84 | * Send raw data to device 85 | * \param[in] device RealSense device to send data to 86 | * \param[in] raw_data_to_send Raw data to be sent to device 87 | * \param[in] size_of_raw_data_to_send Size of raw_data_to_send in bytes 88 | * \param[out] error If non-null, receives any error that occurs during this call, otherwise, errors are ignored 89 | * \return Device's response in a rs2_raw_data_buffer, which should be released by rs2_delete_raw_data 90 | */ 91 | const rs2_raw_data_buffer* rs2_send_and_receive_raw_data(rs2_device* device, void* raw_data_to_send, unsigned size_of_raw_data_to_send, rs2_error** error); 92 | 93 | /** 94 | * Test if the given device can be extended to the requested extension. 95 | * \param[in] device Realsense device 96 | * \param[in] extension The extension to which the device should be tested if it is extendable 97 | * \param[out] error If non-null, receives any error that occurs during this call, otherwise, errors are ignored 98 | * \return Non-zero value iff the device can be extended to the given extension 99 | */ 100 | int rs2_is_device_extendable_to(const rs2_device* device, rs2_extension extension, rs2_error ** error); 101 | 102 | /** 103 | * Create a static snapshot of all connected sensors within a specific device. 104 | * \param[in] device Specific RealSense device 105 | * \param[out] error If non-null, receives any error that occurs during this call, otherwise, errors are ignored 106 | * \return The list of sensors, should be released by rs2_delete_sensor_list 107 | */ 108 | rs2_sensor_list* rs2_query_sensors(const rs2_device* device, rs2_error** error); 109 | 110 | /** 111 | * Enter the given device into loopback operation mode that uses the given file as input for raw data 112 | * \param[in] device Device to enter into loopback operation mode 113 | * \param[in] from_file Path to bag file with raw data for loopback 114 | * \param[out] error If non-null, receives any error that occurs during this call, otherwise, errors are ignored 115 | */ 116 | void rs2_loopback_enable(const rs2_device* device, const char* from_file, rs2_error** error); 117 | 118 | /** 119 | * Restores the given device into normal operation mode 120 | * \param[in] device Device to restore to normal operation mode 121 | * \param[out] error If non-null, receives any error that occurs during this call, otherwise, errors are ignored 122 | */ 123 | void rs2_loopback_disable(const rs2_device* device, rs2_error** error); 124 | 125 | /** 126 | * Checks if the device is in loopback mode or not 127 | * \param[in] device Device to check for operation mode 128 | * \param[out] error If non-null, receives any error that occurs during this call, otherwise, errors are ignored 129 | * \return true if the device is in loopback operation mode 130 | */ 131 | int rs2_loopback_is_enabled(const rs2_device* device, rs2_error** error); 132 | 133 | /** 134 | * Connects to a given tm2 controller 135 | * \param[in] device Device to connect to the controller 136 | * \param[in] mac_addr The MAC address of the desired controller 137 | * \param[out] error If non-null, receives any error that occurs during this call, otherwise, errors are ignored 138 | */ 139 | void rs2_connect_tm2_controller(const rs2_device* device, const unsigned char* mac_addr, rs2_error** error); 140 | 141 | /** 142 | * Disconnects a given tm2 controller 143 | * \param[in] device Device to disconnect the controller from 144 | * \param[in] id The ID of the desired controller 145 | * \param[out] error If non-null, receives any error that occurs during this call, otherwise, errors are ignored 146 | */ 147 | void rs2_disconnect_tm2_controller(const rs2_device* device, int id, rs2_error** error); 148 | 149 | /** 150 | * Update device to the provided firmware, the device must be extendable to RS2_EXTENSION_UPDATABLE. 151 | * This call is executed on the caller's thread and it supports progress notifications via the optional callback. 152 | * \param[in] device Device to update 153 | * \param[in] fw_image Firmware image buffer 154 | * \param[in] fw_image_size Firmware image buffer size 155 | * \param[in] callback Optional callback for update progress notifications, the progress value is normailzed to 1 156 | * \param[out] error If non-null, receives any error that occurs during this call, otherwise, errors are ignored 157 | */ 158 | void rs2_update_firmware_cpp(const rs2_device* device, const void* fw_image, int fw_image_size, rs2_update_progress_callback* callback, rs2_error** error); 159 | 160 | /** 161 | * Update device to the provided firmware, the device must be extendable to RS2_EXTENSION_UPDATABLE. 162 | * This call is executed on the caller's thread and it supports progress notifications via the optional callback. 163 | * \param[in] device Device to update 164 | * \param[in] fw_image Firmware image buffer 165 | * \param[in] fw_image_size Firmware image buffer size 166 | * \param[in] callback Optional callback for update progress notifications, the progress value is normailzed to 1 167 | * \param[in] client_data Optional client data for the callback 168 | * \param[out] error If non-null, receives any error that occurs during this call, otherwise, errors are ignored 169 | */ 170 | void rs2_update_firmware(const rs2_device* device, const void* fw_image, int fw_image_size, rs2_update_progress_callback_ptr callback, void* client_data, rs2_error** error); 171 | 172 | /** 173 | * Create backup of camera flash memory. Such backup does not constitute valid firmware image, and cannot be 174 | * loaded back to the device, but it does contain all calibration and device information. 175 | * \param[in] device Device to update 176 | * \param[in] callback Optional callback for update progress notifications, the progress value is normailzed to 1 177 | * \param[out] error If non-null, receives any error that occurs during this call, otherwise, errors are ignored 178 | */ 179 | const rs2_raw_data_buffer* rs2_create_flash_backup_cpp(const rs2_device* device, rs2_update_progress_callback* callback, rs2_error** error); 180 | 181 | /** 182 | * Create backup of camera flash memory. Such backup does not constitute valid firmware image, and cannot be 183 | * loaded back to the device, but it does contain all calibration and device information. 184 | * \param[in] device Device to update 185 | * \param[in] callback Optional callback for update progress notifications, the progress value is normailzed to 1 186 | * \param[in] client_data Optional client data for the callback 187 | * \param[out] error If non-null, receives any error that occurs during this call, otherwise, errors are ignored 188 | */ 189 | const rs2_raw_data_buffer* rs2_create_flash_backup(const rs2_device* device, rs2_update_progress_callback_ptr callback, void* client_data, rs2_error** error); 190 | 191 | /** 192 | * Enter the device to update state, this will cause the updatable device to disconnect and reconnect as update device. 193 | * \param[in] device Device to update 194 | * \param[out] error If non-null, receives any error that occurs during this call, otherwise, errors are ignored 195 | */ 196 | void rs2_enter_update_state(const rs2_device* device, rs2_error** error); 197 | 198 | #ifdef __cplusplus 199 | } 200 | #endif 201 | #endif 202 | -------------------------------------------------------------------------------- /libs/librealsense2/include/librealsense2/h/rs_internal.h: -------------------------------------------------------------------------------- 1 | /* License: Apache 2.0. See LICENSE file in root directory. 2 | Copyright(c) 2017 Intel Corporation. All Rights Reserved. */ 3 | 4 | /** \file rs_internal.h 5 | * \brief 6 | * Exposes RealSense internal functionality for C compilers 7 | */ 8 | 9 | 10 | #ifndef LIBREALSENSE_RS2_INTERNAL_H 11 | #define LIBREALSENSE_RS2_INTERNAL_H 12 | 13 | #ifdef __cplusplus 14 | extern "C" { 15 | #endif 16 | #include "rs_types.h" 17 | #include "rs_context.h" 18 | #include "rs_sensor.h" 19 | #include "rs_frame.h" 20 | #include "rs_option.h" 21 | /** 22 | * librealsense Recorder is intended for effective unit-testing 23 | * Currently supports three modes of operation: 24 | */ 25 | typedef enum rs2_recording_mode 26 | { 27 | RS2_RECORDING_MODE_BLANK_FRAMES, /* frame metadata will be recorded, but pixel data will be replaced with zeros to save space */ 28 | RS2_RECORDING_MODE_COMPRESSED, /* frames will be encoded using a proprietary lossy encoding, aiming at x5 compression at some CPU expense */ 29 | RS2_RECORDING_MODE_BEST_QUALITY, /* frames will not be compressed, but rather stored as-is. This gives best quality and low CPU overhead, but you might run out of memory */ 30 | RS2_RECORDING_MODE_COUNT 31 | } rs2_recording_mode; 32 | 33 | /** \brief All the parameters are required to define video stream*/ 34 | typedef struct rs2_video_stream 35 | { 36 | rs2_stream type; 37 | int index; 38 | int uid; 39 | int width; 40 | int height; 41 | int fps; 42 | int bpp; 43 | rs2_format fmt; 44 | rs2_intrinsics intrinsics; 45 | } rs2_video_stream; 46 | 47 | /** \brief All the parameters are required to define motion stream*/ 48 | typedef struct rs2_motion_stream 49 | { 50 | rs2_stream type; 51 | int index; 52 | int uid; 53 | int fps; 54 | rs2_format fmt; 55 | rs2_motion_device_intrinsic intrinsics; 56 | } rs2_motion_stream; 57 | 58 | /** \brief All the parameters are required to define pose stream*/ 59 | typedef struct rs2_pose_stream 60 | { 61 | rs2_stream type; 62 | int index; 63 | int uid; 64 | int fps; 65 | rs2_format fmt; 66 | } rs2_pose_stream; 67 | 68 | /** \brief All the parameters are required to define video frame*/ 69 | typedef struct rs2_software_video_frame 70 | { 71 | void* pixels; 72 | void(*deleter)(void*); 73 | int stride; 74 | int bpp; 75 | rs2_time_t timestamp; 76 | rs2_timestamp_domain domain; 77 | int frame_number; 78 | const rs2_stream_profile* profile; 79 | } rs2_software_video_frame; 80 | 81 | /** \brief All the parameters are required to define motion frame*/ 82 | typedef struct rs2_software_motion_frame 83 | { 84 | void* data; 85 | void(*deleter)(void*); 86 | rs2_time_t timestamp; 87 | rs2_timestamp_domain domain; 88 | int frame_number; 89 | const rs2_stream_profile* profile; 90 | } rs2_software_motion_frame; 91 | 92 | /** \brief All the parameters are required to define pose frame*/ 93 | typedef struct rs2_software_pose_frame 94 | { 95 | struct pose_frame_info 96 | { 97 | float translation[3]; 98 | float velocity[3]; 99 | float acceleration[3]; 100 | float rotation[4]; 101 | float angular_velocity[3]; 102 | float angular_acceleration[3]; 103 | int tracker_confidence; 104 | int mapper_confidence; 105 | }; 106 | void* data; 107 | void(*deleter)(void*); 108 | rs2_time_t timestamp; 109 | rs2_timestamp_domain domain; 110 | int frame_number; 111 | const rs2_stream_profile* profile; 112 | } rs2_software_pose_frame; 113 | 114 | /** 115 | * Create librealsense context that will try to record all operations over librealsense into a file 116 | * \param[in] api_version realsense API version as provided by RS2_API_VERSION macro 117 | * \param[in] filename string representing the name of the file to record 118 | * \param[in] section string representing the name of the section within existing recording 119 | * \param[out] error if non-null, receives any error that occurs during this call, otherwise, errors are ignored 120 | * \return context object, should be released by rs2_delete_context 121 | */ 122 | rs2_context* rs2_create_recording_context(int api_version, const char* filename, const char* section, rs2_recording_mode mode, rs2_error** error); 123 | 124 | /** 125 | * Create librealsense context that given a file will respond to calls exactly as the recording did 126 | * if the user calls a method that was either not called during recording or violates causality of the recording error will be thrown 127 | * \param[in] api_version realsense API version as provided by RS2_API_VERSION macro 128 | * \param[in] filename string representing the name of the file to play back from 129 | * \param[in] section string representing the name of the section within existing recording 130 | * \param[out] error if non-null, receives any error that occurs during this call, otherwise, errors are ignored 131 | * \return context object, should be released by rs2_delete_context 132 | */ 133 | rs2_context* rs2_create_mock_context(int api_version, const char* filename, const char* section, rs2_error** error); 134 | 135 | /** 136 | * Create librealsense context that given a file will respond to calls exactly as the recording did 137 | * if the user calls a method that was either not called during recording or violates causality of the recording error will be thrown 138 | * \param[in] api_version realsense API version as provided by RS2_API_VERSION macro 139 | * \param[in] filename string representing the name of the file to play back from 140 | * \param[in] section string representing the name of the section within existing recording 141 | * \param[in] min_api_version reject any file that was recorded before this version 142 | * \param[out] error if non-null, receives any error that occurs during this call, otherwise, errors are ignored 143 | * \return context object, should be released by rs2_delete_context 144 | */ 145 | rs2_context* rs2_create_mock_context_versioned(int api_version, const char* filename, const char* section, const char* min_api_version, rs2_error** error); 146 | 147 | /** 148 | * Create software device to enable use librealsense logic without getting data from backend 149 | * but inject the data from outside 150 | * \param[out] error if non-null, receives any error that occurs during this call, otherwise, errors are ignored 151 | * \return software device object, should be released by rs2_delete_device 152 | */ 153 | rs2_device* rs2_create_software_device(rs2_error** error); 154 | 155 | /** 156 | * Add sensor to the software device 157 | * \param[in] dev the software device 158 | * \param[in] sensor_name the name of the sensor 159 | * \param[out] error if non-null, receives any error that occurs during this call, otherwise, errors are ignored 160 | * \return software sensor object, should be released by rs2_delete_sensor 161 | */ 162 | rs2_sensor* rs2_software_device_add_sensor(rs2_device* dev, const char* sensor_name, rs2_error** error); 163 | 164 | /** 165 | * Inject video frame to software sonsor 166 | * \param[in] sensor the software sensor 167 | * \param[in] frame all the frame components 168 | * \param[out] error if non-null, receives any error that occurs during this call, otherwise, errors are ignored 169 | */ 170 | void rs2_software_sensor_on_video_frame(rs2_sensor* sensor, rs2_software_video_frame frame, rs2_error** error); 171 | 172 | /** 173 | * Inject motion frame to software sonsor 174 | * \param[in] sensor the software sensor 175 | * \param[in] frame all the frame components 176 | * \param[out] error if non-null, receives any error that occurs during this call, otherwise, errors are ignored 177 | */ 178 | void rs2_software_sensor_on_motion_frame(rs2_sensor* sensor, rs2_software_motion_frame frame, rs2_error** error); 179 | 180 | /** 181 | * Inject pose frame to software sonsor 182 | * \param[in] sensor the software sensor 183 | * \param[in] frame all the frame components 184 | * \param[out] error if non-null, receives any error that occurs during this call, otherwise, errors are ignored 185 | */ 186 | void rs2_software_sensor_on_pose_frame(rs2_sensor* sensor, rs2_software_pose_frame frame, rs2_error** error); 187 | 188 | /** 189 | * Set frame metadata for the upcoming frames 190 | * \param[in] sensor the software sensor 191 | * \param[in] value metadata key to set 192 | * \param[in] type metadata value 193 | * \param[out] error if non-null, receives any error that occurs during this call, otherwise, errors are ignored 194 | */ 195 | void rs2_software_sensor_set_metadata(rs2_sensor* sensor, rs2_frame_metadata_value value, rs2_metadata_type type, rs2_error** error); 196 | 197 | /** 198 | * Set the wanted matcher type that will be used by the syncer 199 | * \param[in] dev the software device 200 | * \param[in] matcher matcher type 201 | * \param[out] error if non-null, receives any error that occurs during this call, otherwise, errors are ignored 202 | */ 203 | void rs2_software_device_create_matcher(rs2_device* dev, rs2_matchers matcher, rs2_error** error); 204 | 205 | /** 206 | * Add video stream to sensor 207 | * \param[in] sensor the software sensor 208 | * \param[in] video_stream all the stream components 209 | * \param[out] error if non-null, receives any error that occurs during this call, otherwise, errors are ignored 210 | */ 211 | rs2_stream_profile* rs2_software_sensor_add_video_stream(rs2_sensor* sensor, rs2_video_stream video_stream, rs2_error** error); 212 | 213 | /** 214 | * Add motion stream to sensor 215 | * \param[in] sensor the software sensor 216 | * \param[in] video_stream all the stream components 217 | * \param[out] error if non-null, receives any error that occurs during this call, otherwise, errors are ignored 218 | */ 219 | rs2_stream_profile* rs2_software_sensor_add_motion_stream(rs2_sensor* sensor, rs2_motion_stream motion_stream, rs2_error** error); 220 | 221 | /** 222 | * Add pose stream to sensor 223 | * \param[in] sensor the software sensor 224 | * \param[in] video_stream all the stream components 225 | * \param[out] error if non-null, receives any error that occurs during this call, otherwise, errors are ignored 226 | */ 227 | rs2_stream_profile* rs2_software_sensor_add_pose_stream(rs2_sensor* sensor, rs2_pose_stream pose_stream, rs2_error** error); 228 | 229 | /** 230 | * Add read only option to sensor 231 | * \param[in] sensor the software sensor 232 | * \param[in] option the wanted option 233 | * \param[in] val the initial value 234 | * \param[out] error if non-null, receives any error that occurs during this call, otherwise, errors are ignored 235 | */ 236 | void rs2_software_sensor_add_read_only_option(rs2_sensor* sensor, rs2_option option, float val, rs2_error** error); 237 | 238 | /** 239 | * Update the read only option added to sensor 240 | * \param[in] sensor the software sensor 241 | * \param[in] option the wanted option 242 | * \param[in] val the wanted value 243 | * \param[out] error if non-null, receives any error that occurs during this call, otherwise, errors are ignored 244 | */ 245 | void rs2_software_sensor_update_read_only_option(rs2_sensor* sensor, rs2_option option, float val, rs2_error** error); 246 | #ifdef __cplusplus 247 | } 248 | #endif 249 | #endif 250 | -------------------------------------------------------------------------------- /libs/librealsense2/include/librealsense2/h/rs_option.h: -------------------------------------------------------------------------------- 1 | /* License: Apache 2.0. See LICENSE file in root directory. 2 | Copyright(c) 2017 Intel Corporation. All Rights Reserved. */ 3 | 4 | /** \file rs_option.h 5 | * \brief 6 | * Exposes sensor options functionality for C compilers 7 | */ 8 | 9 | 10 | #ifndef LIBREALSENSE_RS2_OPTION_H 11 | #define LIBREALSENSE_RS2_OPTION_H 12 | 13 | #ifdef __cplusplus 14 | extern "C" { 15 | #endif 16 | 17 | #include "rs_types.h" 18 | 19 | /** \brief Defines general configuration controls. 20 | These can generally be mapped to camera UVC controls, and can be set / queried at any time unless stated otherwise. 21 | */ 22 | typedef enum rs2_option 23 | { 24 | RS2_OPTION_BACKLIGHT_COMPENSATION, /**< Enable / disable color backlight compensation*/ 25 | RS2_OPTION_BRIGHTNESS, /**< Color image brightness*/ 26 | RS2_OPTION_CONTRAST, /**< Color image contrast*/ 27 | RS2_OPTION_EXPOSURE, /**< Controls exposure time of color camera. Setting any value will disable auto exposure*/ 28 | RS2_OPTION_GAIN, /**< Color image gain*/ 29 | RS2_OPTION_GAMMA, /**< Color image gamma setting*/ 30 | RS2_OPTION_HUE, /**< Color image hue*/ 31 | RS2_OPTION_SATURATION, /**< Color image saturation setting*/ 32 | RS2_OPTION_SHARPNESS, /**< Color image sharpness setting*/ 33 | RS2_OPTION_WHITE_BALANCE, /**< Controls white balance of color image. Setting any value will disable auto white balance*/ 34 | RS2_OPTION_ENABLE_AUTO_EXPOSURE, /**< Enable / disable color image auto-exposure*/ 35 | RS2_OPTION_ENABLE_AUTO_WHITE_BALANCE, /**< Enable / disable color image auto-white-balance*/ 36 | RS2_OPTION_VISUAL_PRESET, /**< Provide access to several recommend sets of option presets for the depth camera */ 37 | RS2_OPTION_LASER_POWER, /**< Power of the F200 / SR300 projector, with 0 meaning projector off*/ 38 | RS2_OPTION_ACCURACY, /**< Set the number of patterns projected per frame. The higher the accuracy value the more patterns projected. Increasing the number of patterns help to achieve better accuracy. Note that this control is affecting the Depth FPS */ 39 | RS2_OPTION_MOTION_RANGE, /**< Motion vs. Range trade-off, with lower values allowing for better motion sensitivity and higher values allowing for better depth range*/ 40 | RS2_OPTION_FILTER_OPTION, /**< Set the filter to apply to each depth frame. Each one of the filter is optimized per the application requirements*/ 41 | RS2_OPTION_CONFIDENCE_THRESHOLD, /**< The confidence level threshold used by the Depth algorithm pipe to set whether a pixel will get a valid range or will be marked with invalid range*/ 42 | RS2_OPTION_EMITTER_ENABLED, /**< Laser Emitter enabled */ 43 | RS2_OPTION_FRAMES_QUEUE_SIZE, /**< Number of frames the user is allowed to keep per stream. Trying to hold-on to more frames will cause frame-drops.*/ 44 | RS2_OPTION_TOTAL_FRAME_DROPS, /**< Total number of detected frame drops from all streams */ 45 | RS2_OPTION_AUTO_EXPOSURE_MODE, /**< Auto-Exposure modes: Static, Anti-Flicker and Hybrid */ 46 | RS2_OPTION_POWER_LINE_FREQUENCY, /**< Power Line Frequency control for anti-flickering Off/50Hz/60Hz/Auto */ 47 | RS2_OPTION_ASIC_TEMPERATURE, /**< Current Asic Temperature */ 48 | RS2_OPTION_ERROR_POLLING_ENABLED, /**< disable error handling */ 49 | RS2_OPTION_PROJECTOR_TEMPERATURE, /**< Current Projector Temperature */ 50 | RS2_OPTION_OUTPUT_TRIGGER_ENABLED, /**< Enable / disable trigger to be outputed from the camera to any external device on every depth frame */ 51 | RS2_OPTION_MOTION_MODULE_TEMPERATURE, /**< Current Motion-Module Temperature */ 52 | RS2_OPTION_DEPTH_UNITS, /**< Number of meters represented by a single depth unit */ 53 | RS2_OPTION_ENABLE_MOTION_CORRECTION, /**< Enable/Disable automatic correction of the motion data */ 54 | RS2_OPTION_AUTO_EXPOSURE_PRIORITY, /**< Allows sensor to dynamically ajust the frame rate depending on lighting conditions */ 55 | RS2_OPTION_COLOR_SCHEME, /**< Color scheme for data visualization */ 56 | RS2_OPTION_HISTOGRAM_EQUALIZATION_ENABLED, /**< Perform histogram equalization post-processing on the depth data */ 57 | RS2_OPTION_MIN_DISTANCE, /**< Minimal distance to the target */ 58 | RS2_OPTION_MAX_DISTANCE, /**< Maximum distance to the target */ 59 | RS2_OPTION_TEXTURE_SOURCE, /**< Texture mapping stream unique ID */ 60 | RS2_OPTION_FILTER_MAGNITUDE, /**< The 2D-filter effect. The specific interpretation is given within the context of the filter */ 61 | RS2_OPTION_FILTER_SMOOTH_ALPHA, /**< 2D-filter parameter controls the weight/radius for smoothing.*/ 62 | RS2_OPTION_FILTER_SMOOTH_DELTA, /**< 2D-filter range/validity threshold*/ 63 | RS2_OPTION_HOLES_FILL, /**< Enhance depth data post-processing with holes filling where appropriate*/ 64 | RS2_OPTION_STEREO_BASELINE, /**< The distance in mm between the first and the second imagers in stereo-based depth cameras*/ 65 | RS2_OPTION_AUTO_EXPOSURE_CONVERGE_STEP, /**< Allows dynamically ajust the converge step value of the target exposure in Auto-Exposure algorithm*/ 66 | RS2_OPTION_INTER_CAM_SYNC_MODE, /**< Impose Inter-camera HW synchronization mode. Applicable for D400/Rolling Shutter SKUs */ 67 | RS2_OPTION_STREAM_FILTER, /**< Select a stream to process */ 68 | RS2_OPTION_STREAM_FORMAT_FILTER, /**< Select a stream format to process */ 69 | RS2_OPTION_STREAM_INDEX_FILTER, /**< Select a stream index to process */ 70 | RS2_OPTION_EMITTER_ON_OFF, /**< When supported, this option make the camera to switch the emitter state every frame. 0 for disabled, 1 for enabled */ 71 | RS2_OPTION_ZERO_ORDER_POINT_X, /**< Zero order point x*/ 72 | RS2_OPTION_ZERO_ORDER_POINT_Y, /**< Zero order point y*/ 73 | RS2_OPTION_LLD_TEMPERATURE, /**< LLD temperature*/ 74 | RS2_OPTION_MC_TEMPERATURE, /**< MC temperature*/ 75 | RS2_OPTION_MA_TEMPERATURE, /**< MA temperature*/ 76 | RS2_OPTION_HARDWARE_PRESET, /**< Hardware stream configuration */ 77 | RS2_OPTION_GLOBAL_TIME_ENABLED, /**< disable global time */ 78 | RS2_OPTION_APD_TEMPERATURE, /**< APD temperature*/ 79 | RS2_OPTION_ENABLE_MAPPING, /**< Enable an internal map */ 80 | RS2_OPTION_ENABLE_RELOCALIZATION, /**< Enable appearance based relocalization */ 81 | RS2_OPTION_ENABLE_POSE_JUMPING, /**< Enable position jumping */ 82 | RS2_OPTION_ENABLE_DYNAMIC_CALIBRATION, /**< Enable dynamic calibration */ 83 | RS2_OPTION_COUNT /**< Number of enumeration values. Not a valid input: intended to be used in for-loops. */ 84 | } rs2_option; 85 | 86 | // This function is being deprecated. For existing options it will return option name, but for future API additions the user should call rs2_get_option_name instead. 87 | const char* rs2_option_to_string(rs2_option option); 88 | 89 | /** \brief For SR300 devices: provides optimized settings (presets) for specific types of usage. */ 90 | typedef enum rs2_sr300_visual_preset 91 | { 92 | RS2_SR300_VISUAL_PRESET_SHORT_RANGE, /**< Preset for short range */ 93 | RS2_SR300_VISUAL_PRESET_LONG_RANGE, /**< Preset for long range */ 94 | RS2_SR300_VISUAL_PRESET_BACKGROUND_SEGMENTATION, /**< Preset for background segmentation */ 95 | RS2_SR300_VISUAL_PRESET_GESTURE_RECOGNITION, /**< Preset for gesture recognition */ 96 | RS2_SR300_VISUAL_PRESET_OBJECT_SCANNING, /**< Preset for object scanning */ 97 | RS2_SR300_VISUAL_PRESET_FACE_ANALYTICS, /**< Preset for face analytics */ 98 | RS2_SR300_VISUAL_PRESET_FACE_LOGIN, /**< Preset for face login */ 99 | RS2_SR300_VISUAL_PRESET_GR_CURSOR, /**< Preset for GR cursor */ 100 | RS2_SR300_VISUAL_PRESET_DEFAULT, /**< Camera default settings */ 101 | RS2_SR300_VISUAL_PRESET_MID_RANGE, /**< Preset for mid-range */ 102 | RS2_SR300_VISUAL_PRESET_IR_ONLY, /**< Preset for IR only */ 103 | RS2_SR300_VISUAL_PRESET_COUNT /**< Number of enumeration values. Not a valid input: intended to be used in for-loops. */ 104 | } rs2_sr300_visual_preset; 105 | const char* rs2_sr300_visual_preset_to_string(rs2_sr300_visual_preset preset); 106 | 107 | /** \brief For RS400 devices: provides optimized settings (presets) for specific types of usage. */ 108 | typedef enum rs2_rs400_visual_preset 109 | { 110 | RS2_RS400_VISUAL_PRESET_CUSTOM, 111 | RS2_RS400_VISUAL_PRESET_DEFAULT, 112 | RS2_RS400_VISUAL_PRESET_HAND, 113 | RS2_RS400_VISUAL_PRESET_HIGH_ACCURACY, 114 | RS2_RS400_VISUAL_PRESET_HIGH_DENSITY, 115 | RS2_RS400_VISUAL_PRESET_MEDIUM_DENSITY, 116 | RS2_RS400_VISUAL_PRESET_REMOVE_IR_PATTERN, 117 | RS2_RS400_VISUAL_PRESET_COUNT 118 | } rs2_rs400_visual_preset; 119 | const char* rs2_rs400_visual_preset_to_string(rs2_rs400_visual_preset preset); 120 | 121 | /** 122 | * check if an option is read-only 123 | * \param[in] sensor the RealSense sensor 124 | * \param[in] option option id to be checked 125 | * \param[out] error if non-null, receives any error that occurs during this call, otherwise, errors are ignored 126 | * \return true if option is read-only 127 | */ 128 | int rs2_is_option_read_only(const rs2_options* options, rs2_option option, rs2_error** error); 129 | 130 | /** 131 | * read option value from the sensor 132 | * \param[in] sensor the RealSense sensor 133 | * \param[in] option option id to be queried 134 | * \param[out] error if non-null, receives any error that occurs during this call, otherwise, errors are ignored 135 | * \return value of the option 136 | */ 137 | float rs2_get_option(const rs2_options* options, rs2_option option, rs2_error** error); 138 | 139 | /** 140 | * write new value to sensor option 141 | * \param[in] sensor the RealSense sensor 142 | * \param[in] option option id to be queried 143 | * \param[in] value new value for the option 144 | * \param[out] error if non-null, receives any error that occurs during this call, otherwise, errors are ignored 145 | */ 146 | void rs2_set_option(const rs2_options* options, rs2_option option, float value, rs2_error** error); 147 | 148 | /** 149 | * get the list of supported options of options container 150 | * \param[in] options the options container 151 | * \param[out] error if non-null, receives any error that occurs during this call, otherwise, errors are ignored 152 | */ 153 | rs2_options_list* rs2_get_options_list(const rs2_options* options, rs2_error** error); 154 | 155 | /** 156 | * get the size of options list 157 | * \param[in] options the option list 158 | * \param[out] error if non-null, receives any error that occurs during this call, otherwise, errors are ignored 159 | */ 160 | int rs2_get_options_list_size(const rs2_options_list* options, rs2_error** error); 161 | 162 | /** 163 | * get option name 164 | * \param[in] options options object 165 | * \param[in] option option id to be checked 166 | * \param[out] error if non-null, receives any error that occurs during this call, otherwise, errors are ignored 167 | * \return human-readable option name 168 | */ 169 | const char* rs2_get_option_name(const rs2_options* options, rs2_option option, rs2_error** error); 170 | 171 | /** 172 | * get the specific option from options list 173 | * \param[in] i the index of the option 174 | * \param[out] error if non-null, receives any error that occurs during this call, otherwise, errors are ignored 175 | */ 176 | rs2_option rs2_get_option_from_list(const rs2_options_list* options, int i, rs2_error** error); 177 | 178 | /** 179 | * Deletes options list 180 | * \param[in] list list to delete 181 | */ 182 | void rs2_delete_options_list(rs2_options_list* list); 183 | 184 | /** 185 | * check if particular option is supported by a subdevice 186 | * \param[in] sensor the RealSense sensor 187 | * \param[in] option option id to be checked 188 | * \param[out] error if non-null, receives any error that occurs during this call, otherwise, errors are ignored 189 | * \return true if option is supported 190 | */ 191 | int rs2_supports_option(const rs2_options* options, rs2_option option, rs2_error** error); 192 | 193 | /** 194 | * retrieve the available range of values of a supported option 195 | * \param[in] sensor the RealSense device 196 | * \param[in] option the option whose range should be queried 197 | * \param[out] min the minimum value which will be accepted for this option 198 | * \param[out] max the maximum value which will be accepted for this option 199 | * \param[out] step the granularity of options which accept discrete values, or zero if the option accepts continuous values 200 | * \param[out] def the default value of the option 201 | * \param[out] error if non-null, receives any error that occurs during this call, otherwise, errors are ignored 202 | */ 203 | void rs2_get_option_range(const rs2_options* sensor, rs2_option option, float* min, float* max, float* step, float* def, rs2_error** error); 204 | 205 | /** 206 | * get option description 207 | * \param[in] sensor the RealSense sensor 208 | * \param[in] option option id to be checked 209 | * \param[out] error if non-null, receives any error that occurs during this call, otherwise, errors are ignored 210 | * \return human-readable option description 211 | */ 212 | const char* rs2_get_option_description(const rs2_options* options, rs2_option option, rs2_error ** error); 213 | 214 | /** 215 | * get option value description (in case specific option value hold special meaning) 216 | * \param[in] device the RealSense device 217 | * \param[in] option option id to be checked 218 | * \param[in] value value of the option 219 | * \param[out] error if non-null, receives any error that occurs during this call, otherwise, errors are ignored 220 | * \return human-readable description of a specific value of an option or null if no special meaning 221 | */ 222 | const char* rs2_get_option_value_description(const rs2_options* options, rs2_option option, float value, rs2_error ** error); 223 | 224 | #ifdef __cplusplus 225 | } 226 | #endif 227 | #endif 228 | -------------------------------------------------------------------------------- /libs/librealsense2/include/librealsense2/h/rs_record_playback.h: -------------------------------------------------------------------------------- 1 | /* License: Apache 2.0. See LICENSE file in root directory. 2 | Copyright(c) 2017 Intel Corporation. All Rights Reserved. */ 3 | 4 | /** \file rs_record_playback.h 5 | * \brief 6 | * Exposes record and playback functionality for C compilers 7 | */ 8 | 9 | 10 | #ifndef LIBREALSENSE_RS2_RECORD_PLAYBACK_H 11 | #define LIBREALSENSE_RS2_RECORD_PLAYBACK_H 12 | 13 | #ifdef __cplusplus 14 | extern "C" { 15 | #endif 16 | 17 | #include "rs_types.h" 18 | 19 | typedef enum rs2_playback_status 20 | { 21 | RS2_PLAYBACK_STATUS_UNKNOWN, /**< Unknown state */ 22 | RS2_PLAYBACK_STATUS_PLAYING, /**< One or more sensors were started, playback is reading and raising data */ 23 | RS2_PLAYBACK_STATUS_PAUSED, /**< One or more sensors were started, but playback paused reading and paused raising data*/ 24 | RS2_PLAYBACK_STATUS_STOPPED, /**< All sensors were stopped, or playback has ended (all data was read). This is the initial playback status*/ 25 | RS2_PLAYBACK_STATUS_COUNT 26 | } rs2_playback_status; 27 | 28 | const char* rs2_playback_status_to_string(rs2_playback_status status); 29 | 30 | typedef void (*rs2_playback_status_changed_callback_ptr)(rs2_playback_status); 31 | 32 | /** 33 | * Creates a recording device to record the given device and save it to the given file 34 | * \param[in] device The device to record 35 | * \param[in] file The desired path to which the recorder should save the data 36 | * \param[out] error If non-null, receives any error that occurs during this call, otherwise, errors are ignored 37 | * \return A pointer to a device that records its data to file, or null in case of failure 38 | */ 39 | rs2_device* rs2_create_record_device(const rs2_device* device, const char* file, rs2_error** error); 40 | 41 | /** 42 | * Creates a recording device to record the given device and save it to the given file 43 | * \param[in] device The device to record 44 | * \param[in] file The desired path to which the recorder should save the data 45 | * \param[in] compression_enabled Indicates if compression is enabled, 0 means false, otherwise true 46 | * \param[out] error If non-null, receives any error that occurs during this call, otherwise, errors are ignored 47 | * \return A pointer to a device that records its data to file, or null in case of failure 48 | */ 49 | rs2_device* rs2_create_record_device_ex(const rs2_device* device, const char* file, int compression_enabled, rs2_error** error); 50 | 51 | /** 52 | * Pause the recording device without stopping the actual device from streaming. 53 | * Pausing will cause the device to stop writing new data to the file, in particular, frames and changes to extensions 54 | * \param[in] device A recording device 55 | * \param[out] error If non-null, receives any error that occurs during this call, otherwise, errors are ignored 56 | */ 57 | void rs2_record_device_pause(const rs2_device* device, rs2_error** error); 58 | 59 | /** 60 | * Unpause the recording device. Resume will cause the device to continue writing new data to the file, in particular, frames and changes to extensions 61 | * \param[in] device A recording device 62 | * \param[out] error If non-null, receives any error that occurs during this call, otherwise, errors are ignored 63 | */ 64 | void rs2_record_device_resume(const rs2_device* device, rs2_error** error); 65 | 66 | /** 67 | * Gets the name of the file to which the recorder is writing 68 | * \param[in] device A recording device 69 | * \param[out] error If non-null, receives any error that occurs during this call, otherwise, errors are ignored 70 | * \return The name of the file to which the recorder is writing 71 | */ 72 | const char* rs2_record_device_filename(const rs2_device* device, rs2_error** error); 73 | 74 | /** 75 | * Creates a playback device to play the content of the given file 76 | * \param[in] file Path to the file to play 77 | * \param[out] error If non-null, receives any error that occurs during this call, otherwise, errors are ignored 78 | * \return A pointer to a device that plays data from the file, or null in case of failure 79 | */ 80 | rs2_device* rs2_create_playback_device(const char* file, rs2_error** error); 81 | 82 | /** 83 | * Gets the path of the file used by the playback device 84 | * \param[in] device A playback device 85 | * \param[out] error If non-null, receives any error that occurs during this call, otherwise, errors are ignored 86 | * \return Path to the file used by the playback device 87 | */ 88 | const char* rs2_playback_device_get_file_path(const rs2_device* device, rs2_error** error); 89 | 90 | /** 91 | * Gets the total duration of the file in units of nanoseconds 92 | * \param[in] device A playback device 93 | * \param[out] error If non-null, receives any error that occurs during this call, otherwise, errors are ignored 94 | * \return Total duration of the file in units of nanoseconds 95 | */ 96 | unsigned long long int rs2_playback_get_duration(const rs2_device* device, rs2_error** error); 97 | 98 | /** 99 | * Set the playback to a specified time point of the played data 100 | * \param[in] device A playback device. 101 | * \param[in] time The time point to which playback should seek, expressed in units of nanoseconds (zero value = start) 102 | * \param[out] error If non-null, receives any error that occurs during this call, otherwise, errors are ignored 103 | */ 104 | void rs2_playback_seek(const rs2_device* device, long long int time, rs2_error** error); 105 | 106 | /** 107 | * Gets the current position of the playback in the file in terms of time. Units are expressed in nanoseconds 108 | * \param[in] device A playback device 109 | * \param[out] error If non-null, receives any error that occurs during this call, otherwise, errors are ignored 110 | * \return Current position of the playback in the file in terms of time. Units are expressed in nanoseconds 111 | */ 112 | unsigned long long int rs2_playback_get_position(const rs2_device* device, rs2_error** error); 113 | 114 | /** 115 | * Pauses the playback 116 | * Calling pause() in "Paused" status does nothing 117 | * If pause() is called while playback status is "Playing" or "Stopped", the playback will not play until resume() is called 118 | * \param[in] device A playback device 119 | * \param[out] error If non-null, receives any error that occurs during this call, otherwise, errors are ignored 120 | */ 121 | void rs2_playback_device_resume(const rs2_device* device, rs2_error** error); 122 | 123 | /** 124 | * Un-pauses the playback 125 | * Calling resume() while playback status is "Playing" or "Stopped" does nothing 126 | * \param[in] device A playback device 127 | * \param[out] error If non-null, receives any error that occurs during this call, otherwise, errors are ignored 128 | */ 129 | void rs2_playback_device_pause(const rs2_device* device, rs2_error** error); 130 | 131 | /** 132 | * Set the playback to work in real time or non real time 133 | * 134 | * In real time mode, playback will play the same way the file was recorded. 135 | * In real time mode if the application takes too long to handle the callback, frames may be dropped. 136 | * In non real time mode, playback will wait for each callback to finish handling the data before 137 | * reading the next frame. In this mode no frames will be dropped, and the application controls the 138 | * frame rate of the playback (according to the callback handler duration). 139 | * \param[in] device A playback device 140 | * \param[in] real_time Indicates if real time is requested, 0 means false, otherwise true 141 | * \param[out] error If non-null, receives any error that occurs during this call, otherwise, errors are ignored 142 | */ 143 | void rs2_playback_device_set_real_time(const rs2_device* device, int real_time, rs2_error** error); 144 | 145 | /** 146 | * Indicates if playback is in real time mode or non real time 147 | * \param[in] device A playback device 148 | * \param[out] error If non-null, receives any error that occurs during this call, otherwise, errors are ignored 149 | * \return True iff playback is in real time mode. 0 means false, otherwise true 150 | */ 151 | int rs2_playback_device_is_real_time(const rs2_device* device, rs2_error** error); 152 | 153 | /** 154 | * Register to receive callback from playback device upon its status changes 155 | * 156 | * Callbacks are invoked from the reading thread, any heavy processing in the callback handler will affect 157 | * the reading thread and may cause frame drops\ high latency 158 | * \param[in] device A playback device 159 | * \param[in] callback A callback handler that will be invoked when the playback status changes 160 | * \param[out] error If non-null, receives any error that occurs during this call, otherwise, errors are ignored 161 | */ 162 | void rs2_playback_device_set_status_changed_callback(const rs2_device* device, rs2_playback_status_changed_callback* callback, rs2_error** error); 163 | 164 | /** 165 | * Returns the current state of the playback device 166 | * \param[in] device A playback device 167 | * \param[out] error If non-null, receives any error that occurs during this call, otherwise, errors are ignored 168 | * \return Current state of the playback 169 | */ 170 | rs2_playback_status rs2_playback_device_get_current_status(const rs2_device* device, rs2_error** error); 171 | 172 | /** 173 | * Set the playing speed 174 | * 175 | * \param[in] device A playback device 176 | * \param[in] speed Indicates a multiplication of the speed to play (e.g: 1 = normal, 0.5 twice as slow) 177 | * \param[out] error If non-null, receives any error that occurs during this call, otherwise, errors are ignored 178 | */ 179 | void rs2_playback_device_set_playback_speed(const rs2_device* device, float speed, rs2_error** error); 180 | 181 | /** 182 | * Stops the playback 183 | * Calling stop() will stop all streaming playbakc sensors and will reset the playback (returning to beginning of file) 184 | * \param[in] device A playback device 185 | * \param[out] error If non-null, receives any error that occurs during this call, otherwise, errors are ignored 186 | */ 187 | void rs2_playback_device_stop(const rs2_device* device, rs2_error** error); 188 | 189 | #ifdef __cplusplus 190 | } 191 | #endif 192 | #endif 193 | -------------------------------------------------------------------------------- /libs/librealsense2/include/librealsense2/h/rs_types.h: -------------------------------------------------------------------------------- 1 | /* License: Apache 2.0. See LICENSE file in root directory. 2 | Copyright(c) 2017 Intel Corporation. All Rights Reserved. */ 3 | 4 | /** \file rs_types.h 5 | * \brief 6 | * Exposes RealSense structs 7 | */ 8 | 9 | #ifndef LIBREALSENSE_RS2_TYPES_H 10 | #define LIBREALSENSE_RS2_TYPES_H 11 | 12 | #ifdef __cplusplus 13 | extern "C" { 14 | #endif 15 | 16 | /** \brief Category of the librealsense notification. */ 17 | typedef enum rs2_notification_category{ 18 | RS2_NOTIFICATION_CATEGORY_FRAMES_TIMEOUT, /**< Frames didn't arrived within 5 seconds */ 19 | RS2_NOTIFICATION_CATEGORY_FRAME_CORRUPTED, /**< Received partial/incomplete frame */ 20 | RS2_NOTIFICATION_CATEGORY_HARDWARE_ERROR, /**< Error reported from the device */ 21 | RS2_NOTIFICATION_CATEGORY_HARDWARE_EVENT, /**< General Hardeware notification that is not an error */ 22 | RS2_NOTIFICATION_CATEGORY_UNKNOWN_ERROR, /**< Received unknown error from the device */ 23 | RS2_NOTIFICATION_CATEGORY_FIRMWARE_UPDATE_RECOMMENDED, /**< Current firmware version installed is not the latest available */ 24 | RS2_NOTIFICATION_CATEGORY_COUNT /**< Number of enumeration values. Not a valid input: intended to be used in for-loops. */ 25 | } rs2_notification_category; 26 | const char* rs2_notification_category_to_string(rs2_notification_category category); 27 | 28 | /** \brief Exception types are the different categories of errors that RealSense API might return. */ 29 | typedef enum rs2_exception_type 30 | { 31 | RS2_EXCEPTION_TYPE_UNKNOWN, 32 | RS2_EXCEPTION_TYPE_CAMERA_DISCONNECTED, /**< Device was disconnected, this can be caused by outside intervention, by internal firmware error or due to insufficient power */ 33 | RS2_EXCEPTION_TYPE_BACKEND, /**< Error was returned from the underlying OS-specific layer */ 34 | RS2_EXCEPTION_TYPE_INVALID_VALUE, /**< Invalid value was passed to the API */ 35 | RS2_EXCEPTION_TYPE_WRONG_API_CALL_SEQUENCE, /**< Function precondition was violated */ 36 | RS2_EXCEPTION_TYPE_NOT_IMPLEMENTED, /**< The method is not implemented at this point */ 37 | RS2_EXCEPTION_TYPE_DEVICE_IN_RECOVERY_MODE, /**< Device is in recovery mode and might require firmware update */ 38 | RS2_EXCEPTION_TYPE_IO, /**< IO Device failure */ 39 | RS2_EXCEPTION_TYPE_COUNT /**< Number of enumeration values. Not a valid input: intended to be used in for-loops. */ 40 | } rs2_exception_type; 41 | const char* rs2_exception_type_to_string(rs2_exception_type type); 42 | 43 | /** \brief Distortion model: defines how pixel coordinates should be mapped to sensor coordinates. */ 44 | typedef enum rs2_distortion 45 | { 46 | RS2_DISTORTION_NONE , /**< Rectilinear images. No distortion compensation required. */ 47 | RS2_DISTORTION_MODIFIED_BROWN_CONRADY, /**< Equivalent to Brown-Conrady distortion, except that tangential distortion is applied to radially distorted points */ 48 | RS2_DISTORTION_INVERSE_BROWN_CONRADY , /**< Equivalent to Brown-Conrady distortion, except undistorts image instead of distorting it */ 49 | RS2_DISTORTION_FTHETA , /**< F-Theta fish-eye distortion model */ 50 | RS2_DISTORTION_BROWN_CONRADY , /**< Unmodified Brown-Conrady distortion model */ 51 | RS2_DISTORTION_KANNALA_BRANDT4 , /**< Four parameter Kannala Brandt distortion model */ 52 | RS2_DISTORTION_COUNT /**< Number of enumeration values. Not a valid input: intended to be used in for-loops. */ 53 | } rs2_distortion; 54 | const char* rs2_distortion_to_string(rs2_distortion distortion); 55 | 56 | /** \brief Video stream intrinsics. */ 57 | typedef struct rs2_intrinsics 58 | { 59 | int width; /**< Width of the image in pixels */ 60 | int height; /**< Height of the image in pixels */ 61 | float ppx; /**< Horizontal coordinate of the principal point of the image, as a pixel offset from the left edge */ 62 | float ppy; /**< Vertical coordinate of the principal point of the image, as a pixel offset from the top edge */ 63 | float fx; /**< Focal length of the image plane, as a multiple of pixel width */ 64 | float fy; /**< Focal length of the image plane, as a multiple of pixel height */ 65 | rs2_distortion model; /**< Distortion model of the image */ 66 | float coeffs[5]; /**< Distortion coefficients */ 67 | } rs2_intrinsics; 68 | 69 | /** \brief Motion device intrinsics: scale, bias, and variances. */ 70 | typedef struct rs2_motion_device_intrinsic 71 | { 72 | /* \internal 73 | * Scale X cross axis cross axis Bias X \n 74 | * cross axis Scale Y cross axis Bias Y \n 75 | * cross axis cross axis Scale Z Bias Z */ 76 | float data[3][4]; /**< Interpret data array values */ 77 | 78 | float noise_variances[3]; /**< Variance of noise for X, Y, and Z axis */ 79 | float bias_variances[3]; /**< Variance of bias for X, Y, and Z axis */ 80 | } rs2_motion_device_intrinsic; 81 | 82 | /** \brief 3D coordinates with origin at topmost left corner of the lense, 83 | with positive Z pointing away from the camera, positive X pointing camera right and positive Y pointing camera down */ 84 | typedef struct rs2_vertex 85 | { 86 | float xyz[3]; 87 | } rs2_vertex; 88 | 89 | /** \brief Pixel location within 2D image. (0,0) is the topmost, left corner. Positive X is right, positive Y is down */ 90 | typedef struct rs2_pixel 91 | { 92 | int ij[2]; 93 | } rs2_pixel; 94 | 95 | /** \brief 3D vector in Euclidean coordinate space */ 96 | typedef struct rs2_vector 97 | { 98 | float x, y, z; 99 | }rs2_vector; 100 | 101 | /** \brief Quaternion used to represent rotation */ 102 | typedef struct rs2_quaternion 103 | { 104 | float x, y, z, w; 105 | }rs2_quaternion; 106 | 107 | typedef struct rs2_pose 108 | { 109 | rs2_vector translation; /**< X, Y, Z values of translation, in meters (relative to initial position) */ 110 | rs2_vector velocity; /**< X, Y, Z values of velocity, in meters/sec */ 111 | rs2_vector acceleration; /**< X, Y, Z values of acceleration, in meters/sec^2 */ 112 | rs2_quaternion rotation; /**< Qi, Qj, Qk, Qr components of rotation as represented in quaternion rotation (relative to initial position) */ 113 | rs2_vector angular_velocity; /**< X, Y, Z values of angular velocity, in radians/sec */ 114 | rs2_vector angular_acceleration; /**< X, Y, Z values of angular acceleration, in radians/sec^2 */ 115 | unsigned int tracker_confidence; /**< Pose confidence 0x0 - Failed, 0x1 - Low, 0x2 - Medium, 0x3 - High */ 116 | unsigned int mapper_confidence; /**< Pose map confidence 0x0 - Failed, 0x1 - Low, 0x2 - Medium, 0x3 - High */ 117 | } rs2_pose; 118 | 119 | /** \brief Severity of the librealsense logger. */ 120 | typedef enum rs2_log_severity { 121 | RS2_LOG_SEVERITY_DEBUG, /**< Detailed information about ordinary operations */ 122 | RS2_LOG_SEVERITY_INFO , /**< Terse information about ordinary operations */ 123 | RS2_LOG_SEVERITY_WARN , /**< Indication of possible failure */ 124 | RS2_LOG_SEVERITY_ERROR, /**< Indication of definite failure */ 125 | RS2_LOG_SEVERITY_FATAL, /**< Indication of unrecoverable failure */ 126 | RS2_LOG_SEVERITY_NONE , /**< No logging will occur */ 127 | RS2_LOG_SEVERITY_COUNT /**< Number of enumeration values. Not a valid input: intended to be used in for-loops. */ 128 | } rs2_log_severity; 129 | const char* rs2_log_severity_to_string(rs2_log_severity info); 130 | 131 | /** \brief Specifies advanced interfaces (capabilities) objects may implement. */ 132 | typedef enum rs2_extension 133 | { 134 | RS2_EXTENSION_UNKNOWN, 135 | RS2_EXTENSION_DEBUG, 136 | RS2_EXTENSION_INFO, 137 | RS2_EXTENSION_MOTION, 138 | RS2_EXTENSION_OPTIONS, 139 | RS2_EXTENSION_VIDEO, 140 | RS2_EXTENSION_ROI, 141 | RS2_EXTENSION_DEPTH_SENSOR, 142 | RS2_EXTENSION_VIDEO_FRAME, 143 | RS2_EXTENSION_MOTION_FRAME, 144 | RS2_EXTENSION_COMPOSITE_FRAME, 145 | RS2_EXTENSION_POINTS, 146 | RS2_EXTENSION_DEPTH_FRAME, 147 | RS2_EXTENSION_ADVANCED_MODE, 148 | RS2_EXTENSION_RECORD, 149 | RS2_EXTENSION_VIDEO_PROFILE, 150 | RS2_EXTENSION_PLAYBACK, 151 | RS2_EXTENSION_DEPTH_STEREO_SENSOR, 152 | RS2_EXTENSION_DISPARITY_FRAME, 153 | RS2_EXTENSION_MOTION_PROFILE, 154 | RS2_EXTENSION_POSE_FRAME, 155 | RS2_EXTENSION_POSE_PROFILE, 156 | RS2_EXTENSION_TM2, 157 | RS2_EXTENSION_SOFTWARE_DEVICE, 158 | RS2_EXTENSION_SOFTWARE_SENSOR, 159 | RS2_EXTENSION_DECIMATION_FILTER, 160 | RS2_EXTENSION_THRESHOLD_FILTER, 161 | RS2_EXTENSION_DISPARITY_FILTER, 162 | RS2_EXTENSION_SPATIAL_FILTER, 163 | RS2_EXTENSION_TEMPORAL_FILTER, 164 | RS2_EXTENSION_HOLE_FILLING_FILTER, 165 | RS2_EXTENSION_ZERO_ORDER_FILTER, 166 | RS2_EXTENSION_RECOMMENDED_FILTERS, 167 | RS2_EXTENSION_POSE, 168 | RS2_EXTENSION_POSE_SENSOR, 169 | RS2_EXTENSION_WHEEL_ODOMETER, 170 | RS2_EXTENSION_GLOBAL_TIMER, 171 | RS2_EXTENSION_UPDATABLE, 172 | RS2_EXTENSION_UPDATE_DEVICE, 173 | RS2_EXTENSION_COUNT 174 | } rs2_extension; 175 | const char* rs2_extension_type_to_string(rs2_extension type); 176 | const char* rs2_extension_to_string(rs2_extension type); 177 | 178 | /** \brief Specifies types of different matchers */ 179 | typedef enum rs2_matchers 180 | { 181 | RS2_MATCHER_DI, //compare depth and ir based on frame number 182 | 183 | RS2_MATCHER_DI_C, //compare depth and ir based on frame number, 184 | //compare the pair of corresponding depth and ir with color based on closest timestamp, 185 | //commonly used by SR300 186 | 187 | RS2_MATCHER_DLR_C, //compare depth, left and right ir based on frame number, 188 | //compare the set of corresponding depth, left and right with color based on closest timestamp, 189 | //commonly used by RS415, RS435 190 | 191 | RS2_MATCHER_DLR, //compare depth, left and right ir based on frame number, 192 | //commonly used by RS400, RS405, RS410, RS420, RS430 193 | 194 | RS2_MATCHER_DIC, //compare depth, ir and confidence based on frame number used by RS500 195 | 196 | RS2_MATCHER_DIC_C, //compare depth, ir and confidence based on frame number, 197 | //compare the set of corresponding depth, ir and confidence with color based on closest timestamp, 198 | //commonly used by RS515 199 | 200 | RS2_MATCHER_DEFAULT, //the default matcher compare all the streams based on closest timestamp 201 | 202 | RS2_MATCHER_COUNT 203 | }rs2_matchers; 204 | 205 | typedef struct rs2_device_info rs2_device_info; 206 | typedef struct rs2_device rs2_device; 207 | typedef struct rs2_error rs2_error; 208 | typedef struct rs2_raw_data_buffer rs2_raw_data_buffer; 209 | typedef struct rs2_frame rs2_frame; 210 | typedef struct rs2_frame_queue rs2_frame_queue; 211 | typedef struct rs2_pipeline rs2_pipeline; 212 | typedef struct rs2_pipeline_profile rs2_pipeline_profile; 213 | typedef struct rs2_config rs2_config; 214 | typedef struct rs2_device_list rs2_device_list; 215 | typedef struct rs2_stream_profile_list rs2_stream_profile_list; 216 | typedef struct rs2_processing_block_list rs2_processing_block_list; 217 | typedef struct rs2_stream_profile rs2_stream_profile; 218 | typedef struct rs2_frame_callback rs2_frame_callback; 219 | typedef struct rs2_log_callback rs2_log_callback; 220 | typedef struct rs2_syncer rs2_syncer; 221 | typedef struct rs2_device_serializer rs2_device_serializer; 222 | typedef struct rs2_source rs2_source; 223 | typedef struct rs2_processing_block rs2_processing_block; 224 | typedef struct rs2_frame_processor_callback rs2_frame_processor_callback; 225 | typedef struct rs2_playback_status_changed_callback rs2_playback_status_changed_callback; 226 | typedef struct rs2_update_progress_callback rs2_update_progress_callback; 227 | typedef struct rs2_context rs2_context; 228 | typedef struct rs2_device_hub rs2_device_hub; 229 | typedef struct rs2_sensor_list rs2_sensor_list; 230 | typedef struct rs2_sensor rs2_sensor; 231 | typedef struct rs2_options rs2_options; 232 | typedef struct rs2_options_list rs2_options_list; 233 | typedef struct rs2_devices_changed_callback rs2_devices_changed_callback; 234 | typedef struct rs2_notification rs2_notification; 235 | typedef struct rs2_notifications_callback rs2_notifications_callback; 236 | typedef void (*rs2_notification_callback_ptr)(rs2_notification*, void*); 237 | typedef void (*rs2_devices_changed_callback_ptr)(rs2_device_list*, rs2_device_list*, void*); 238 | typedef void (*rs2_frame_callback_ptr)(rs2_frame*, void*); 239 | typedef void (*rs2_frame_processor_callback_ptr)(rs2_frame*, rs2_source*, void*); 240 | typedef void(*rs2_update_progress_callback_ptr)(const float, void*); 241 | 242 | typedef double rs2_time_t; /**< Timestamp format. units are milliseconds */ 243 | typedef long long rs2_metadata_type; /**< Metadata attribute type is defined as 64 bit signed integer*/ 244 | 245 | rs2_error * rs2_create_error(const char* what, const char* name, const char* args, rs2_exception_type type); 246 | rs2_exception_type rs2_get_librealsense_exception_type(const rs2_error* error); 247 | const char* rs2_get_failed_function (const rs2_error* error); 248 | const char* rs2_get_failed_args (const rs2_error* error); 249 | const char* rs2_get_error_message (const rs2_error* error); 250 | void rs2_free_error (rs2_error* error); 251 | 252 | #ifdef __cplusplus 253 | } 254 | #endif 255 | #endif 256 | -------------------------------------------------------------------------------- /libs/librealsense2/include/librealsense2/hpp/rs_context.hpp: -------------------------------------------------------------------------------- 1 | // License: Apache 2.0. See LICENSE file in root directory. 2 | // Copyright(c) 2017 Intel Corporation. All Rights Reserved. 3 | 4 | #ifndef LIBREALSENSE_RS2_CONTEXT_HPP 5 | #define LIBREALSENSE_RS2_CONTEXT_HPP 6 | 7 | #include "rs_types.hpp" 8 | #include "rs_record_playback.hpp" 9 | #include "rs_processing.hpp" 10 | 11 | namespace rs2 12 | { 13 | class event_information 14 | { 15 | public: 16 | event_information(device_list removed, device_list added) 17 | :_removed(removed), _added(added) {} 18 | 19 | /** 20 | * check if a specific device was disconnected 21 | * \return true if device disconnected, false if device connected 22 | */ 23 | bool was_removed(const rs2::device& dev) const 24 | { 25 | rs2_error* e = nullptr; 26 | 27 | if (!dev) 28 | return false; 29 | 30 | auto res = rs2_device_list_contains(_removed.get_list(), dev.get().get(), &e); 31 | error::handle(e); 32 | 33 | return res > 0; 34 | } 35 | 36 | /** 37 | * check if a specific device was added 38 | * \return true if device added, false otherwise 39 | */ 40 | bool was_added(const rs2::device& dev) const 41 | { 42 | rs2_error* e = nullptr; 43 | 44 | if (!dev) 45 | return false; 46 | 47 | auto res = rs2_device_list_contains(_added.get_list(), dev.get().get(), &e); 48 | error::handle(e); 49 | 50 | return res > 0; 51 | } 52 | 53 | /** 54 | * returns a list of all newly connected devices 55 | * \return the list of all new connected devices 56 | */ 57 | device_list get_new_devices() const 58 | { 59 | return _added; 60 | } 61 | 62 | private: 63 | device_list _removed; 64 | device_list _added; 65 | }; 66 | 67 | template 68 | class devices_changed_callback : public rs2_devices_changed_callback 69 | { 70 | T _callback; 71 | 72 | public: 73 | explicit devices_changed_callback(T callback) : _callback(callback) {} 74 | 75 | void on_devices_changed(rs2_device_list* removed, rs2_device_list* added) override 76 | { 77 | std::shared_ptr old(removed, rs2_delete_device_list); 78 | std::shared_ptr news(added, rs2_delete_device_list); 79 | 80 | 81 | event_information info({ device_list(old), device_list(news) }); 82 | _callback(info); 83 | } 84 | 85 | void release() override { delete this; } 86 | }; 87 | 88 | class pipeline; 89 | class device_hub; 90 | class software_device; 91 | 92 | /** 93 | * default librealsense context class 94 | * includes realsense API version as provided by RS2_API_VERSION macro 95 | */ 96 | class context 97 | { 98 | public: 99 | context() 100 | { 101 | rs2_error* e = nullptr; 102 | _context = std::shared_ptr( 103 | rs2_create_context(RS2_API_VERSION, &e), 104 | rs2_delete_context); 105 | error::handle(e); 106 | } 107 | 108 | /** 109 | * create a static snapshot of all connected devices at the time of the call 110 | * \return the list of devices connected devices at the time of the call 111 | */ 112 | device_list query_devices() const 113 | { 114 | rs2_error* e = nullptr; 115 | std::shared_ptr list( 116 | rs2_query_devices(_context.get(), &e), 117 | rs2_delete_device_list); 118 | error::handle(e); 119 | 120 | return device_list(list); 121 | } 122 | 123 | /** 124 | * create a static snapshot of all connected devices at the time of the call 125 | * \return the list of devices connected devices at the time of the call 126 | */ 127 | device_list query_devices(int mask) const 128 | { 129 | rs2_error* e = nullptr; 130 | std::shared_ptr list( 131 | rs2_query_devices_ex(_context.get(), mask, &e), 132 | rs2_delete_device_list); 133 | error::handle(e); 134 | 135 | return device_list(list); 136 | } 137 | 138 | /** 139 | * @brief Generate a flat list of all available sensors from all RealSense devices 140 | * @return List of sensors 141 | */ 142 | std::vector query_all_sensors() const 143 | { 144 | std::vector results; 145 | for (auto&& dev : query_devices()) 146 | { 147 | auto sensors = dev.query_sensors(); 148 | std::copy(sensors.begin(), sensors.end(), std::back_inserter(results)); 149 | } 150 | return results; 151 | } 152 | 153 | 154 | device get_sensor_parent(const sensor& s) const 155 | { 156 | rs2_error* e = nullptr; 157 | std::shared_ptr dev( 158 | rs2_create_device_from_sensor(s._sensor.get(), &e), 159 | rs2_delete_device); 160 | error::handle(e); 161 | return device{ dev }; 162 | } 163 | 164 | /** 165 | * register devices changed callback 166 | * \param[in] callback devices changed callback 167 | */ 168 | template 169 | void set_devices_changed_callback(T callback) 170 | { 171 | rs2_error* e = nullptr; 172 | rs2_set_devices_changed_callback_cpp(_context.get(), 173 | new devices_changed_callback(std::move(callback)), &e); 174 | error::handle(e); 175 | } 176 | 177 | /** 178 | * Creates a device from a RealSense file 179 | * 180 | * On successful load, the device will be appended to the context and a devices_changed event triggered 181 | * @param file Path to a RealSense File 182 | * @return A playback device matching the given file 183 | */ 184 | playback load_device(const std::string& file) 185 | { 186 | rs2_error* e = nullptr; 187 | auto device = std::shared_ptr( 188 | rs2_context_add_device(_context.get(), file.c_str(), &e), 189 | rs2_delete_device); 190 | rs2::error::handle(e); 191 | 192 | return playback { device }; 193 | } 194 | 195 | void unload_device(const std::string& file) 196 | { 197 | rs2_error* e = nullptr; 198 | rs2_context_remove_device(_context.get(), file.c_str(), &e); 199 | rs2::error::handle(e); 200 | } 201 | 202 | void unload_tracking_module() 203 | { 204 | rs2_error* e = nullptr; 205 | rs2_context_unload_tracking_module(_context.get(), &e); 206 | rs2::error::handle(e); 207 | } 208 | 209 | context(std::shared_ptr ctx) 210 | : _context(ctx) 211 | {} 212 | explicit operator std::shared_ptr() { return _context; }; 213 | protected: 214 | friend class rs2::pipeline; 215 | friend class rs2::device_hub; 216 | friend class rs2::software_device; 217 | 218 | std::shared_ptr _context; 219 | }; 220 | 221 | /** 222 | * device_hub class - encapsulate the handling of connect and disconnect events 223 | */ 224 | class device_hub 225 | { 226 | public: 227 | explicit device_hub(context ctx) 228 | { 229 | rs2_error* e = nullptr; 230 | _device_hub = std::shared_ptr( 231 | rs2_create_device_hub(ctx._context.get(), &e), 232 | rs2_delete_device_hub); 233 | error::handle(e); 234 | } 235 | 236 | /** 237 | * If any device is connected return it, otherwise wait until next RealSense device connects. 238 | * Calling this method multiple times will cycle through connected devices 239 | */ 240 | device wait_for_device() const 241 | { 242 | rs2_error* e = nullptr; 243 | std::shared_ptr dev( 244 | rs2_device_hub_wait_for_device(_device_hub.get(), &e), 245 | rs2_delete_device); 246 | 247 | error::handle(e); 248 | 249 | return device(dev); 250 | 251 | } 252 | 253 | /** 254 | * Checks if device is still connected 255 | */ 256 | bool is_connected(const device& dev) const 257 | { 258 | rs2_error* e = nullptr; 259 | auto res = rs2_device_hub_is_device_connected(_device_hub.get(), dev._dev.get(), &e); 260 | error::handle(e); 261 | 262 | return res > 0 ? true : false; 263 | 264 | } 265 | 266 | explicit operator std::shared_ptr() { return _device_hub; } 267 | explicit device_hub(std::shared_ptr hub) : _device_hub(std::move(hub)) {} 268 | private: 269 | std::shared_ptr _device_hub; 270 | }; 271 | 272 | } 273 | #endif // LIBREALSENSE_RS2_CONTEXT_HPP 274 | -------------------------------------------------------------------------------- /libs/librealsense2/include/librealsense2/hpp/rs_export.hpp: -------------------------------------------------------------------------------- 1 | // License: Apache 2.0. See LICENSE file in root directory. 2 | // Copyright(c) 2017 Intel Corporation. All Rights Reserved. 3 | 4 | #ifndef LIBREALSENSE_RS2_EXPORT_HPP 5 | #define LIBREALSENSE_RS2_EXPORT_HPP 6 | 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include "rs_processing.hpp" 13 | #include "rs_internal.hpp" 14 | 15 | namespace rs2 16 | { 17 | class save_to_ply : public filter 18 | { 19 | public: 20 | save_to_ply(std::string filename = "RealSense Pointcloud ", pointcloud pc = pointcloud()) 21 | : filter([this](frame f, frame_source& s) { func(f, s); }), 22 | _pc(std::move(pc)), fname(filename) 23 | { 24 | register_simple_option(OPTION_IGNORE_COLOR, option_range{ 0, 1, 0, 1 }); 25 | } 26 | 27 | 28 | static const auto OPTION_IGNORE_COLOR = rs2_option(RS2_OPTION_COUNT + 1); 29 | private: 30 | void func(frame data, frame_source& source) 31 | { 32 | frame depth, color; 33 | if (auto fs = data.as()) { 34 | for (auto f : fs) { 35 | if (f.is()) depth = f; 36 | else if (!depth && f.is()) depth = f; 37 | else if (!color && f.is()) color = f; 38 | } 39 | } else if (data.is() || data.is()) { 40 | depth = data; 41 | } 42 | 43 | if (!depth) throw std::runtime_error("Need depth data to save PLY"); 44 | if (!depth.is()) { 45 | if (color) _pc.map_to(color); 46 | depth = _pc.calculate(depth); 47 | } 48 | 49 | export_to_ply(depth, color); 50 | source.frame_ready(data); // passthrough filter because processing_block::process doesn't support sinks 51 | } 52 | 53 | void export_to_ply(points p, video_frame color) { 54 | const bool use_texcoords = color && !get_option(OPTION_IGNORE_COLOR); 55 | const auto verts = p.get_vertices(); 56 | const auto texcoords = p.get_texture_coordinates(); 57 | std::vector new_verts; 58 | std::vector> new_tex; 59 | std::map idx_map; 60 | 61 | new_verts.reserve(p.size()); 62 | if (use_texcoords) new_tex.reserve(p.size()); 63 | 64 | static const auto min_distance = 1e-6; 65 | 66 | for (size_t i = 0; i < p.size(); ++i) { 67 | if (fabs(verts[i].x) >= min_distance || fabs(verts[i].y) >= min_distance || 68 | fabs(verts[i].z) >= min_distance) 69 | { 70 | idx_map[i] = new_verts.size(); 71 | new_verts.push_back(verts[i]); 72 | if (use_texcoords) 73 | { 74 | auto rgb = get_texcolor(color, texcoords[i].u, texcoords[i].v); 75 | new_tex.push_back(rgb); 76 | } 77 | } 78 | } 79 | 80 | auto profile = p.get_profile().as(); 81 | auto width = profile.width(), height = profile.height(); 82 | static const auto threshold = 0.05f; 83 | std::vector> faces; 84 | for (int x = 0; x < width - 1; ++x) { 85 | for (int y = 0; y < height - 1; ++y) { 86 | auto a = y * width + x, b = y * width + x + 1, c = (y + 1)*width + x, d = (y + 1)*width + x + 1; 87 | if (verts[a].z && verts[b].z && verts[c].z && verts[d].z 88 | && fabs(verts[a].z - verts[b].z) < threshold && fabs(verts[a].z - verts[c].z) < threshold 89 | && fabs(verts[b].z - verts[d].z) < threshold && fabs(verts[c].z - verts[d].z) < threshold) 90 | { 91 | if (idx_map.count(a) == 0 || idx_map.count(b) == 0 || idx_map.count(c) == 0 || 92 | idx_map.count(d) == 0) 93 | continue; 94 | faces.push_back({ idx_map[a], idx_map[b], idx_map[d] }); 95 | faces.push_back({ idx_map[d], idx_map[c], idx_map[a] }); 96 | } 97 | } 98 | } 99 | 100 | std::stringstream name; 101 | name << fname << p.get_frame_number() << ".ply"; 102 | std::ofstream out(name.str()); 103 | out << "ply\n"; 104 | out << "format binary_little_endian 1.0\n"; 105 | out << "comment pointcloud saved from Realsense Viewer\n"; 106 | out << "element vertex " << new_verts.size() << "\n"; 107 | out << "property float" << sizeof(float) * 8 << " x\n"; 108 | out << "property float" << sizeof(float) * 8 << " y\n"; 109 | out << "property float" << sizeof(float) * 8 << " z\n"; 110 | if (use_texcoords) 111 | { 112 | out << "property uchar red\n"; 113 | out << "property uchar green\n"; 114 | out << "property uchar blue\n"; 115 | } 116 | out << "element face " << faces.size() << "\n"; 117 | out << "property list uchar int vertex_indices\n"; 118 | out << "end_header\n"; 119 | out.close(); 120 | 121 | out.open(name.str(), std::ios_base::app | std::ios_base::binary); 122 | for (int i = 0; i < new_verts.size(); ++i) 123 | { 124 | // we assume little endian architecture on your device 125 | out.write(reinterpret_cast(&(new_verts[i].x)), sizeof(float)); 126 | out.write(reinterpret_cast(&(new_verts[i].y)), sizeof(float)); 127 | out.write(reinterpret_cast(&(new_verts[i].z)), sizeof(float)); 128 | 129 | if (use_texcoords) 130 | { 131 | out.write(reinterpret_cast(&(new_tex[i][0])), sizeof(uint8_t)); 132 | out.write(reinterpret_cast(&(new_tex[i][1])), sizeof(uint8_t)); 133 | out.write(reinterpret_cast(&(new_tex[i][2])), sizeof(uint8_t)); 134 | } 135 | } 136 | auto size = faces.size(); 137 | for (int i = 0; i < size; ++i) { 138 | static const int three = 3; 139 | out.write(reinterpret_cast(&three), sizeof(uint8_t)); 140 | out.write(reinterpret_cast(&(faces[i][0])), sizeof(int)); 141 | out.write(reinterpret_cast(&(faces[i][1])), sizeof(int)); 142 | out.write(reinterpret_cast(&(faces[i][2])), sizeof(int)); 143 | } 144 | } 145 | 146 | // TODO: get_texcolor, options API 147 | std::array get_texcolor(const video_frame& texture, float u, float v) 148 | { 149 | const int w = texture.get_width(), h = texture.get_height(); 150 | int x = std::min(std::max(int(u*w + .5f), 0), w - 1); 151 | int y = std::min(std::max(int(v*h + .5f), 0), h - 1); 152 | int idx = x * texture.get_bytes_per_pixel() + y * texture.get_stride_in_bytes(); 153 | const auto texture_data = reinterpret_cast(texture.get_data()); 154 | return { texture_data[idx], texture_data[idx + 1], texture_data[idx + 2] }; 155 | } 156 | 157 | std::string fname; 158 | pointcloud _pc; 159 | }; 160 | 161 | class save_single_frameset : public filter { 162 | public: 163 | save_single_frameset(std::string filename = "RealSense Frameset ") 164 | : filter([this](frame f, frame_source& s) { save(f, s); }), fname(filename) 165 | {} 166 | 167 | private: 168 | void save(frame data, frame_source& source, bool do_signal=true) 169 | { 170 | software_device dev; 171 | 172 | std::vector> sensors; 173 | if (auto fs = data.as()) { 174 | int uid = 0; 175 | for (int i = 0; i < fs.size(); ++i) { 176 | frame f = fs[i]; 177 | auto profile = f.get_profile(); 178 | std::stringstream sname; 179 | sname << "Sensor (" << uid << ")"; 180 | auto s = dev.add_sensor(sname.str()); 181 | stream_profile software_profile; 182 | 183 | if (auto vf = f.as()) { 184 | auto vp = profile.as(); 185 | rs2_video_stream stream{ vp.stream_type(), vp.stream_index(), uid++, vp.width(), vp.height(), vp.fps(), vf.get_bytes_per_pixel(), vp.format(), vp.get_intrinsics() }; 186 | software_profile = s.add_video_stream(stream); 187 | } else if (f.is()) { 188 | auto mp = profile.as(); 189 | rs2_motion_stream stream{ mp.stream_type(), mp.stream_index(), uid++, mp.fps(), mp.format(), mp.get_motion_intrinsics() }; 190 | software_profile = s.add_motion_stream(stream); 191 | } else if (f.is()) { 192 | rs2_pose_stream stream{ profile.stream_type(), profile.stream_index(), uid++, profile.fps(), profile.format() }; 193 | software_profile = s.add_pose_stream(stream); 194 | } else { 195 | // TODO: How to handle other frame types? (e.g. points) 196 | assert(false); 197 | } 198 | sensors.emplace_back(s, software_profile, i); 199 | } 200 | 201 | // Recorder needs sensors to already exist when its created 202 | std::stringstream name; 203 | name << fname << data.get_frame_number() << ".bag"; 204 | recorder rec(name.str(), dev); 205 | 206 | for (auto group : sensors) { 207 | auto s = std::get<0>(group); 208 | auto profile = std::get<1>(group); 209 | s.open(profile); 210 | s.start([](frame) {}); 211 | frame f = fs[std::get<2>(group)]; 212 | if (auto vf = f.as()) { 213 | s.on_video_frame({ const_cast(vf.get_data()), [](void*) {}, vf.get_stride_in_bytes(), vf.get_bytes_per_pixel(), 214 | vf.get_timestamp(), vf.get_frame_timestamp_domain(), static_cast(vf.get_frame_number()), profile }); 215 | } else if (f.is()) { 216 | s.on_motion_frame({ const_cast(f.get_data()), [](void*) {}, f.get_timestamp(), 217 | f.get_frame_timestamp_domain(), static_cast(f.get_frame_number()), profile }); 218 | } else if (f.is()) { 219 | s.on_pose_frame({ const_cast(f.get_data()), [](void*) {}, f.get_timestamp(), 220 | f.get_frame_timestamp_domain(), static_cast(f.get_frame_number()), profile }); 221 | } 222 | } 223 | } else { 224 | // single frame 225 | auto set = source.allocate_composite_frame({ data }); 226 | save(set, source, false); 227 | } 228 | 229 | if (do_signal) 230 | source.frame_ready(data); 231 | } 232 | 233 | std::string fname; 234 | }; 235 | } 236 | 237 | #endif -------------------------------------------------------------------------------- /libs/librealsense2/include/librealsense2/hpp/rs_internal.hpp: -------------------------------------------------------------------------------- 1 | // License: Apache 2.0. See LICENSE file in root directory. 2 | // Copyright(c) 2017 Intel Corporation. All Rights Reserved. 3 | 4 | #ifndef LIBREALSENSE_RS2_INTERNAL_HPP 5 | #define LIBREALSENSE_RS2_INTERNAL_HPP 6 | 7 | #include "rs_types.hpp" 8 | #include "rs_device.hpp" 9 | #include "rs_context.hpp" 10 | #include "../h/rs_internal.h" 11 | 12 | namespace rs2 13 | { 14 | class recording_context : public context 15 | { 16 | public: 17 | /** 18 | * create librealsense context that will try to record all operations over librealsense into a file 19 | * \param[in] filename string representing the name of the file to record 20 | */ 21 | recording_context(const std::string& filename, 22 | const std::string& section = "", 23 | rs2_recording_mode mode = RS2_RECORDING_MODE_BLANK_FRAMES) 24 | { 25 | rs2_error* e = nullptr; 26 | _context = std::shared_ptr( 27 | rs2_create_recording_context(RS2_API_VERSION, filename.c_str(), section.c_str(), mode, &e), 28 | rs2_delete_context); 29 | error::handle(e); 30 | } 31 | 32 | recording_context() = delete; 33 | }; 34 | 35 | class mock_context : public context 36 | { 37 | public: 38 | /** 39 | * create librealsense context that given a file will respond to calls exactly as the recording did 40 | * if the user calls a method that was either not called during recording or violates causality of the recording error will be thrown 41 | * \param[in] filename string of the name of the file 42 | */ 43 | mock_context(const std::string& filename, 44 | const std::string& section = "", 45 | const std::string& min_api_version = "0.0.0") 46 | { 47 | rs2_error* e = nullptr; 48 | _context = std::shared_ptr( 49 | rs2_create_mock_context_versioned(RS2_API_VERSION, filename.c_str(), section.c_str(), min_api_version.c_str(), &e), 50 | rs2_delete_context); 51 | error::handle(e); 52 | } 53 | 54 | mock_context() = delete; 55 | }; 56 | 57 | namespace internal 58 | { 59 | /** 60 | * \return the time at specific time point, in live and redord contextes it will return the system time and in playback contextes it will return the recorded time 61 | */ 62 | inline double get_time() 63 | { 64 | rs2_error* e = nullptr; 65 | auto time = rs2_get_time( &e); 66 | 67 | error::handle(e); 68 | 69 | return time; 70 | } 71 | } 72 | 73 | class software_sensor : public sensor 74 | { 75 | public: 76 | /** 77 | * Add video stream to software sensor 78 | * 79 | * \param[in] video_stream all the parameters that required to defind video stream 80 | */ 81 | stream_profile add_video_stream(rs2_video_stream video_stream) 82 | { 83 | rs2_error* e = nullptr; 84 | 85 | stream_profile stream(rs2_software_sensor_add_video_stream(_sensor.get(),video_stream, &e)); 86 | error::handle(e); 87 | 88 | return stream; 89 | } 90 | 91 | /** 92 | * Add motion stream to software sensor 93 | * 94 | * \param[in] motion all the parameters that required to defind motion stream 95 | */ 96 | stream_profile add_motion_stream(rs2_motion_stream motion_stream) 97 | { 98 | rs2_error* e = nullptr; 99 | 100 | stream_profile stream(rs2_software_sensor_add_motion_stream(_sensor.get(), motion_stream, &e)); 101 | error::handle(e); 102 | 103 | return stream; 104 | } 105 | 106 | /** 107 | * Add pose stream to software sensor 108 | * 109 | * \param[in] pose all the parameters that required to defind pose stream 110 | */ 111 | stream_profile add_pose_stream(rs2_pose_stream pose_stream) 112 | { 113 | rs2_error* e = nullptr; 114 | 115 | stream_profile stream(rs2_software_sensor_add_pose_stream(_sensor.get(), pose_stream, &e)); 116 | error::handle(e); 117 | 118 | return stream; 119 | } 120 | 121 | /** 122 | * Inject video frame into the sensor 123 | * 124 | * \param[in] frame all the parameters that required to define video frame 125 | */ 126 | void on_video_frame(rs2_software_video_frame frame) 127 | { 128 | rs2_error* e = nullptr; 129 | rs2_software_sensor_on_video_frame(_sensor.get(), frame, &e); 130 | error::handle(e); 131 | } 132 | 133 | /** 134 | * Inject motion frame into the sensor 135 | * 136 | * \param[in] frame all the parameters that required to define motion frame 137 | */ 138 | void on_motion_frame(rs2_software_motion_frame frame) 139 | { 140 | rs2_error* e = nullptr; 141 | rs2_software_sensor_on_motion_frame(_sensor.get(), frame, &e); 142 | error::handle(e); 143 | } 144 | 145 | /** 146 | * Inject pose frame into the sensor 147 | * 148 | * \param[in] frame all the parameters that required to define pose frame 149 | */ 150 | void on_pose_frame(rs2_software_pose_frame frame) 151 | { 152 | rs2_error* e = nullptr; 153 | rs2_software_sensor_on_pose_frame(_sensor.get(), frame, &e); 154 | error::handle(e); 155 | } 156 | 157 | /** 158 | * Set frame metadata for the upcoming frames 159 | * \param[in] value metadata key to set 160 | * \param[in] type metadata value 161 | */ 162 | void set_metadata(rs2_frame_metadata_value value, rs2_metadata_type type) 163 | { 164 | rs2_error* e = nullptr; 165 | rs2_software_sensor_set_metadata(_sensor.get(), value, type, &e); 166 | error::handle(e); 167 | } 168 | 169 | /** 170 | * Register option that will be supported by the sensor 171 | * 172 | * \param[in] option the option 173 | * \param[in] val the initial value 174 | */ 175 | void add_read_only_option(rs2_option option, float val) 176 | { 177 | rs2_error* e = nullptr; 178 | rs2_software_sensor_add_read_only_option(_sensor.get(), option, val, &e); 179 | error::handle(e); 180 | } 181 | 182 | /** 183 | * Update value of registered option 184 | * 185 | * \param[in] option the option 186 | * \param[in] val the initial value 187 | */ 188 | void set_read_only_option(rs2_option option, float val) 189 | { 190 | rs2_error* e = nullptr; 191 | rs2_software_sensor_update_read_only_option(_sensor.get(), option, val, &e); 192 | error::handle(e); 193 | } 194 | private: 195 | friend class software_device; 196 | 197 | software_sensor(std::shared_ptr s) 198 | : rs2::sensor(s) 199 | { 200 | rs2_error* e = nullptr; 201 | if (rs2_is_sensor_extendable_to(_sensor.get(), RS2_EXTENSION_SOFTWARE_SENSOR, &e) == 0 && !e) 202 | { 203 | _sensor = nullptr; 204 | } 205 | rs2::error::handle(e); 206 | } 207 | }; 208 | 209 | 210 | class software_device : public device 211 | { 212 | std::shared_ptr create_device_ptr() 213 | { 214 | rs2_error* e = nullptr; 215 | std::shared_ptr dev( 216 | rs2_create_software_device(&e), 217 | rs2_delete_device); 218 | error::handle(e); 219 | return dev; 220 | } 221 | 222 | public: 223 | software_device() 224 | : device(create_device_ptr()) 225 | {} 226 | 227 | /** 228 | * Add sensor stream to software sensor 229 | * 230 | * \param[in] name the name of the sensor 231 | */ 232 | software_sensor add_sensor(std::string name) 233 | { 234 | rs2_error* e = nullptr; 235 | std::shared_ptr sensor( 236 | rs2_software_device_add_sensor(_dev.get(), name.c_str(), &e), 237 | rs2_delete_sensor); 238 | error::handle(e); 239 | 240 | return software_sensor(sensor); 241 | } 242 | 243 | /** 244 | * Add software device to existing context 245 | * Any future queries on the context 246 | * Will return this device 247 | * This operation cannot be undone (except for destroying the context) 248 | * 249 | * \param[in] ctx context to add the device to 250 | */ 251 | void add_to(context& ctx) 252 | { 253 | rs2_error* e = nullptr; 254 | rs2_context_add_software_device(ctx._context.get(), _dev.get(), &e); 255 | error::handle(e); 256 | } 257 | 258 | /** 259 | * Set the wanted matcher type that will be used by the syncer 260 | * \param[in] matcher matcher type 261 | */ 262 | void create_matcher(rs2_matchers matcher) 263 | { 264 | rs2_error* e = nullptr; 265 | rs2_software_device_create_matcher(_dev.get(), matcher, &e); 266 | error::handle(e); 267 | } 268 | }; 269 | 270 | } 271 | #endif // LIBREALSENSE_RS2_INTERNAL_HPP 272 | -------------------------------------------------------------------------------- /libs/librealsense2/include/librealsense2/hpp/rs_options.hpp: -------------------------------------------------------------------------------- 1 | // License: Apache 2.0. See LICENSE file in root directory. 2 | // Copyright(c) 2019 Intel Corporation. All Rights Reserved. 3 | 4 | #ifndef LIBREALSENSE_RS2_OPTIONS_HPP 5 | #define LIBREALSENSE_RS2_OPTIONS_HPP 6 | 7 | #include "rs_types.hpp" 8 | 9 | namespace rs2 10 | { 11 | class options 12 | { 13 | public: 14 | /** 15 | * check if particular option is supported 16 | * \param[in] option option id to be checked 17 | * \return true if option is supported 18 | */ 19 | bool supports(rs2_option option) const 20 | { 21 | rs2_error* e = nullptr; 22 | auto res = rs2_supports_option(_options, option, &e); 23 | error::handle(e); 24 | return res > 0; 25 | } 26 | 27 | /** 28 | * get option description 29 | * \param[in] option option id to be checked 30 | * \return human-readable option description 31 | */ 32 | const char* get_option_description(rs2_option option) const 33 | { 34 | rs2_error* e = nullptr; 35 | auto res = rs2_get_option_description(_options, option, &e); 36 | error::handle(e); 37 | return res; 38 | } 39 | 40 | /** 41 | * get option name 42 | * \param[in] option option id to be checked 43 | * \return human-readable option name 44 | */ 45 | const char* get_option_name(rs2_option option) const 46 | { 47 | rs2_error* e = nullptr; 48 | auto res = rs2_get_option_name(_options, option, &e); 49 | error::handle(e); 50 | return res; 51 | } 52 | 53 | /** 54 | * get option value description (in case specific option value hold special meaning) 55 | * \param[in] option option id to be checked 56 | * \param[in] val value of the option 57 | * \return human-readable description of a specific value of an option or null if no special meaning 58 | */ 59 | const char* get_option_value_description(rs2_option option, float val) const 60 | { 61 | rs2_error* e = nullptr; 62 | auto res = rs2_get_option_value_description(_options, option, val, &e); 63 | error::handle(e); 64 | return res; 65 | } 66 | 67 | /** 68 | * read option's value 69 | * \param[in] option option id to be queried 70 | * \return value of the option 71 | */ 72 | float get_option(rs2_option option) const 73 | { 74 | rs2_error* e = nullptr; 75 | auto res = rs2_get_option(_options, option, &e); 76 | error::handle(e); 77 | return res; 78 | } 79 | 80 | /** 81 | * retrieve the available range of values of a supported option 82 | * \return option range containing minimum and maximum values, step and default value 83 | */ 84 | option_range get_option_range(rs2_option option) const 85 | { 86 | option_range result; 87 | rs2_error* e = nullptr; 88 | rs2_get_option_range(_options, option, 89 | &result.min, &result.max, &result.step, &result.def, &e); 90 | error::handle(e); 91 | return result; 92 | } 93 | 94 | /** 95 | * write new value to the option 96 | * \param[in] option option id to be queried 97 | * \param[in] value new value for the option 98 | */ 99 | void set_option(rs2_option option, float value) const 100 | { 101 | rs2_error* e = nullptr; 102 | rs2_set_option(_options, option, value, &e); 103 | error::handle(e); 104 | } 105 | 106 | /** 107 | * check if particular option is read-only 108 | * \param[in] option option id to be checked 109 | * \return true if option is read-only 110 | */ 111 | bool is_option_read_only(rs2_option option) const 112 | { 113 | rs2_error* e = nullptr; 114 | auto res = rs2_is_option_read_only(_options, option, &e); 115 | error::handle(e); 116 | return res > 0; 117 | } 118 | 119 | std::vector get_supported_options() 120 | { 121 | std::vector res; 122 | rs2_error* e = nullptr; 123 | std::shared_ptr options_list( 124 | rs2_get_options_list(_options, &e), 125 | rs2_delete_options_list); 126 | 127 | 128 | for (auto opt = 0; opt < rs2_get_options_list_size(options_list.get(), &e);opt++) 129 | { 130 | res.push_back(rs2_get_option_from_list(options_list.get(), opt, &e)); 131 | } 132 | return res; 133 | }; 134 | 135 | options& operator=(const options& other) 136 | { 137 | _options = other._options; 138 | return *this; 139 | } 140 | // if operator= is ok, this should be ok too 141 | options(const options& other) : _options(other._options) {} 142 | 143 | virtual ~options() = default; 144 | protected: 145 | explicit options(rs2_options* o = nullptr) : _options(o) 146 | { 147 | } 148 | 149 | template 150 | options& operator=(const T& dev) 151 | { 152 | _options = (rs2_options*)(dev.get()); 153 | return *this; 154 | } 155 | 156 | private: 157 | rs2_options* _options; 158 | }; 159 | } 160 | #endif // LIBREALSENSE_RS2_OIPTIONS_HPP 161 | -------------------------------------------------------------------------------- /libs/librealsense2/include/librealsense2/hpp/rs_record_playback.hpp: -------------------------------------------------------------------------------- 1 | // License: Apache 2.0. See LICENSE file in root directory. 2 | // Copyright(c) 2017 Intel Corporation. All Rights Reserved. 3 | 4 | #ifndef LIBREALSENSE_RS2_RECORD_PLAYBACK_HPP 5 | #define LIBREALSENSE_RS2_RECORD_PLAYBACK_HPP 6 | 7 | #include "rs_types.hpp" 8 | #include "rs_device.hpp" 9 | 10 | namespace rs2 11 | { 12 | template 13 | class status_changed_callback : public rs2_playback_status_changed_callback 14 | { 15 | T on_status_changed_function; 16 | public: 17 | explicit status_changed_callback(T on_status_changed) : on_status_changed_function(on_status_changed) {} 18 | 19 | void on_playback_status_changed(rs2_playback_status status) override 20 | { 21 | on_status_changed_function(status); 22 | } 23 | 24 | void release() override { delete this; } 25 | }; 26 | 27 | class playback : public device 28 | { 29 | public: 30 | playback(device d) : playback(d.get()) {} 31 | 32 | /** 33 | * Pauses the playback 34 | * Calling pause() in "Paused" status does nothing 35 | * If pause() is called while playback status is "Playing" or "Stopped", the playback will not play until resume() is called 36 | */ 37 | void pause() 38 | { 39 | rs2_error* e = nullptr; 40 | rs2_playback_device_pause(_dev.get(), &e); 41 | error::handle(e); 42 | } 43 | 44 | /** 45 | * Un-pauses the playback 46 | * Calling resume() while playback status is "Playing" or "Stopped" does nothing 47 | */ 48 | void resume() 49 | { 50 | rs2_error* e = nullptr; 51 | rs2_playback_device_resume(_dev.get(), &e); 52 | error::handle(e); 53 | } 54 | 55 | /** 56 | * Retrieves the name of the playback file 57 | * \return Name of the playback file 58 | */ 59 | std::string file_name() const 60 | { 61 | return m_file; //cached in construction 62 | } 63 | 64 | /** 65 | * Retrieves the current position of the playback in the file in terms of time. Units are expressed in nanoseconds 66 | * \return Current position of the playback in the file in terms of time. Units are expressed in nanoseconds 67 | */ 68 | uint64_t get_position() const 69 | { 70 | rs2_error* e = nullptr; 71 | uint64_t pos = rs2_playback_get_position(_dev.get(), &e); 72 | error::handle(e); 73 | return pos; 74 | } 75 | 76 | /** 77 | * Retrieves the total duration of the file 78 | * \return Total duration of the file 79 | */ 80 | std::chrono::nanoseconds get_duration() const 81 | { 82 | rs2_error* e = nullptr; 83 | std::chrono::nanoseconds duration(rs2_playback_get_duration(_dev.get(), &e)); 84 | error::handle(e); 85 | return duration; 86 | } 87 | 88 | /** 89 | * Sets the playback to a specified time point of the played data 90 | * \param[in] time The time point to which playback should seek, expressed in units of nanoseconds (zero value = start) 91 | */ 92 | void seek(std::chrono::nanoseconds time) 93 | { 94 | rs2_error* e = nullptr; 95 | rs2_playback_seek(_dev.get(), time.count(), &e); 96 | error::handle(e); 97 | } 98 | 99 | /** 100 | * Indicates if playback is in real time mode or non real time 101 | * \return True iff playback is in real time mode 102 | */ 103 | bool is_real_time() const 104 | { 105 | rs2_error* e = nullptr; 106 | bool real_time = rs2_playback_device_is_real_time(_dev.get(), &e) != 0; 107 | error::handle(e); 108 | return real_time; 109 | } 110 | 111 | /** 112 | * Set the playback to work in real time or non real time 113 | * 114 | * In real time mode, playback will play the same way the file was recorded. 115 | * In real time mode if the application takes too long to handle the callback, frames may be dropped. 116 | * In non real time mode, playback will wait for each callback to finish handling the data before 117 | * reading the next frame. In this mode no frames will be dropped, and the application controls the 118 | * frame rate of the playback (according to the callback handler duration). 119 | * \param[in] real_time Indicates if real time is requested, 0 means false, otherwise true 120 | * \return True on successfully setting the requested mode 121 | */ 122 | void set_real_time(bool real_time) const 123 | { 124 | rs2_error* e = nullptr; 125 | rs2_playback_device_set_real_time(_dev.get(), (real_time ? 1 : 0), &e); 126 | error::handle(e); 127 | } 128 | 129 | /** 130 | * Set the playing speed 131 | * \param[in] speed Indicates a multiplication of the speed to play (e.g: 1 = normal, 0.5 twice as slow) 132 | */ 133 | void set_playback_speed(float speed) const 134 | { 135 | rs2_error* e = nullptr; 136 | rs2_playback_device_set_playback_speed(_dev.get(), speed, &e); 137 | error::handle(e); 138 | } 139 | 140 | /** 141 | * Start passing frames into user provided callback 142 | * \param[in] callback Stream callback, can be any callable object accepting rs2::frame 143 | */ 144 | 145 | /** 146 | * Register to receive callback from playback device upon its status changes 147 | * 148 | * Callbacks are invoked from the reading thread, and as such any heavy processing in the callback handler will affect 149 | * the reading thread and may cause frame drops\ high latency 150 | * \param[in] callback A callback handler that will be invoked when the playback status changes, can be any callable object accepting rs2_playback_status 151 | */ 152 | template 153 | void set_status_changed_callback(T callback) 154 | { 155 | rs2_error* e = nullptr; 156 | rs2_playback_device_set_status_changed_callback(_dev.get(), new status_changed_callback(std::move(callback)), &e); 157 | error::handle(e); 158 | } 159 | 160 | /** 161 | * Returns the current state of the playback device 162 | * \return Current state of the playback 163 | */ 164 | rs2_playback_status current_status() const 165 | { 166 | rs2_error* e = nullptr; 167 | rs2_playback_status sts = rs2_playback_device_get_current_status(_dev.get(), &e); 168 | error::handle(e); 169 | return sts; 170 | } 171 | 172 | /** 173 | * Stops the playback, effectively stopping all streaming playback sensors, and resetting the playback. 174 | * 175 | */ 176 | void stop() 177 | { 178 | rs2_error* e = nullptr; 179 | rs2_playback_device_stop(_dev.get(), &e); 180 | error::handle(e); 181 | } 182 | protected: 183 | friend context; 184 | explicit playback(std::shared_ptr dev) : device(dev) 185 | { 186 | rs2_error* e = nullptr; 187 | if(rs2_is_device_extendable_to(_dev.get(), RS2_EXTENSION_PLAYBACK, &e) == 0 && !e) 188 | { 189 | _dev.reset(); 190 | } 191 | error::handle(e); 192 | 193 | if(_dev) 194 | { 195 | e = nullptr; 196 | m_file = rs2_playback_device_get_file_path(_dev.get(), &e); 197 | error::handle(e); 198 | } 199 | } 200 | private: 201 | std::string m_file; 202 | }; 203 | class recorder : public device 204 | { 205 | public: 206 | recorder(device d) : recorder(d.get()) {} 207 | 208 | /** 209 | * Creates a recording device to record the given device and save it to the given file as rosbag format 210 | * \param[in] file The desired path to which the recorder should save the data 211 | * \param[in] device The device to record 212 | */ 213 | recorder(const std::string& file, rs2::device dev) 214 | { 215 | rs2_error* e = nullptr; 216 | _dev = std::shared_ptr( 217 | rs2_create_record_device(dev.get().get(), file.c_str(), &e), 218 | rs2_delete_device); 219 | rs2::error::handle(e); 220 | } 221 | 222 | /** 223 | * Creates a recording device to record the given device and save it to the given file as rosbag format 224 | * \param[in] file The desired path to which the recorder should save the data 225 | * \param[in] device The device to record 226 | * \param[in] compression_enabled Indicates if compression is enabled 227 | */ 228 | recorder(const std::string& file, rs2::device dev, bool compression_enabled) 229 | { 230 | rs2_error* e = nullptr; 231 | _dev = std::shared_ptr( 232 | rs2_create_record_device_ex(dev.get().get(), file.c_str(), compression_enabled, &e), 233 | rs2_delete_device); 234 | rs2::error::handle(e); 235 | } 236 | 237 | 238 | /** 239 | * Pause the recording device without stopping the actual device from streaming. 240 | */ 241 | void pause() 242 | { 243 | rs2_error* e = nullptr; 244 | rs2_record_device_pause(_dev.get(), &e); 245 | error::handle(e); 246 | } 247 | 248 | /** 249 | * Unpauses the recording device, making it resume recording. 250 | */ 251 | void resume() 252 | { 253 | rs2_error* e = nullptr; 254 | rs2_record_device_resume(_dev.get(), &e); 255 | error::handle(e); 256 | } 257 | 258 | /** 259 | * Gets the name of the file to which the recorder is writing 260 | * \return The name of the file to which the recorder is writing 261 | */ 262 | std::string filename() const 263 | { 264 | rs2_error* e = nullptr; 265 | std::string filename = rs2_record_device_filename(_dev.get(), &e); 266 | error::handle(e); 267 | return filename; 268 | } 269 | protected: 270 | explicit recorder(std::shared_ptr dev) : device(dev) 271 | { 272 | rs2_error* e = nullptr; 273 | if (rs2_is_device_extendable_to(_dev.get(), RS2_EXTENSION_RECORD, &e) == 0 && !e) 274 | { 275 | _dev.reset(); 276 | } 277 | error::handle(e); 278 | } 279 | }; 280 | } 281 | #endif // LIBREALSENSE_RS2_RECORD_PLAYBACK_HPP 282 | -------------------------------------------------------------------------------- /libs/librealsense2/include/librealsense2/hpp/rs_types.hpp: -------------------------------------------------------------------------------- 1 | // License: Apache 2.0. See LICENSE file in root directory. 2 | // Copyright(c) 2017 Intel Corporation. All Rights Reserved. 3 | 4 | #ifndef LIBREALSENSE_RS2_TYPES_HPP 5 | #define LIBREALSENSE_RS2_TYPES_HPP 6 | 7 | #include "../rs.h" 8 | #include "../h/rs_context.h" 9 | #include "../h/rs_device.h" 10 | #include "../h/rs_frame.h" 11 | #include "../h/rs_processing.h" 12 | #include "../h/rs_record_playback.h" 13 | #include "../h/rs_sensor.h" 14 | #include "../h/rs_pipeline.h" 15 | 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | 25 | struct rs2_frame_callback 26 | { 27 | virtual void on_frame(rs2_frame * f) = 0; 28 | virtual void release() = 0; 29 | virtual ~rs2_frame_callback() {} 30 | }; 31 | 32 | struct rs2_frame_processor_callback 33 | { 34 | virtual void on_frame(rs2_frame * f, rs2_source * source) = 0; 35 | virtual void release() = 0; 36 | virtual ~rs2_frame_processor_callback() {} 37 | }; 38 | 39 | struct rs2_notifications_callback 40 | { 41 | virtual void on_notification(rs2_notification* n) = 0; 42 | virtual void release() = 0; 43 | virtual ~rs2_notifications_callback() {} 44 | }; 45 | 46 | struct rs2_log_callback 47 | { 48 | virtual void on_event(rs2_log_severity severity, const char * message) = 0; 49 | virtual void release() = 0; 50 | virtual ~rs2_log_callback() {} 51 | }; 52 | 53 | struct rs2_devices_changed_callback 54 | { 55 | virtual void on_devices_changed(rs2_device_list* removed, rs2_device_list* added) = 0; 56 | virtual void release() = 0; 57 | virtual ~rs2_devices_changed_callback() {} 58 | }; 59 | 60 | struct rs2_playback_status_changed_callback 61 | { 62 | virtual void on_playback_status_changed(rs2_playback_status status) = 0; 63 | virtual void release() = 0; 64 | virtual ~rs2_playback_status_changed_callback() {} 65 | }; 66 | 67 | struct rs2_update_progress_callback 68 | { 69 | virtual void on_update_progress(const float update_progress) = 0; 70 | virtual void release() = 0; 71 | virtual ~rs2_update_progress_callback() {} 72 | }; 73 | 74 | namespace rs2 75 | { 76 | class error : public std::runtime_error 77 | { 78 | std::string function, args; 79 | rs2_exception_type type; 80 | public: 81 | explicit error(rs2_error* err) : runtime_error(rs2_get_error_message(err)) 82 | { 83 | function = (nullptr != rs2_get_failed_function(err)) ? rs2_get_failed_function(err) : std::string(); 84 | args = (nullptr != rs2_get_failed_args(err)) ? rs2_get_failed_args(err) : std::string(); 85 | type = rs2_get_librealsense_exception_type(err); 86 | rs2_free_error(err); 87 | } 88 | 89 | explicit error(const std::string& message) : runtime_error(message.c_str()) 90 | { 91 | function = ""; 92 | args = ""; 93 | type = RS2_EXCEPTION_TYPE_UNKNOWN; 94 | } 95 | 96 | const std::string& get_failed_function() const 97 | { 98 | return function; 99 | } 100 | 101 | const std::string& get_failed_args() const 102 | { 103 | return args; 104 | } 105 | 106 | rs2_exception_type get_type() const { return type; } 107 | 108 | static void handle(rs2_error* e); 109 | }; 110 | 111 | #define RS2_ERROR_CLASS(name, base) \ 112 | class name : public base\ 113 | {\ 114 | public:\ 115 | explicit name(rs2_error* e) noexcept : base(e) {}\ 116 | } 117 | 118 | RS2_ERROR_CLASS(recoverable_error, error); 119 | RS2_ERROR_CLASS(unrecoverable_error, error); 120 | RS2_ERROR_CLASS(camera_disconnected_error, unrecoverable_error); 121 | RS2_ERROR_CLASS(backend_error, unrecoverable_error); 122 | RS2_ERROR_CLASS(device_in_recovery_mode_error, unrecoverable_error); 123 | RS2_ERROR_CLASS(invalid_value_error, recoverable_error); 124 | RS2_ERROR_CLASS(wrong_api_call_sequence_error, recoverable_error); 125 | RS2_ERROR_CLASS(not_implemented_error, recoverable_error); 126 | #undef RS2_ERROR_CLASS 127 | 128 | inline void error::handle(rs2_error* e) 129 | { 130 | if (e) 131 | { 132 | auto h = rs2_get_librealsense_exception_type(e); 133 | switch (h) { 134 | case RS2_EXCEPTION_TYPE_CAMERA_DISCONNECTED: 135 | throw camera_disconnected_error(e); 136 | case RS2_EXCEPTION_TYPE_BACKEND: 137 | throw backend_error(e); 138 | case RS2_EXCEPTION_TYPE_INVALID_VALUE: 139 | throw invalid_value_error(e); 140 | case RS2_EXCEPTION_TYPE_WRONG_API_CALL_SEQUENCE: 141 | throw wrong_api_call_sequence_error(e); 142 | case RS2_EXCEPTION_TYPE_NOT_IMPLEMENTED: 143 | throw not_implemented_error(e); 144 | case RS2_EXCEPTION_TYPE_DEVICE_IN_RECOVERY_MODE: 145 | throw device_in_recovery_mode_error(e); 146 | default: 147 | throw error(e); 148 | } 149 | } 150 | } 151 | 152 | class context; 153 | class device; 154 | class device_list; 155 | class syncer; 156 | class device_base; 157 | class roi_sensor; 158 | class frame; 159 | 160 | struct option_range 161 | { 162 | float min; 163 | float max; 164 | float def; 165 | float step; 166 | }; 167 | 168 | struct region_of_interest 169 | { 170 | int min_x; 171 | int min_y; 172 | int max_x; 173 | int max_y; 174 | }; 175 | } 176 | 177 | inline std::ostream & operator << (std::ostream & o, rs2_vector v) { return o << v.x << ", " << v.y << ", " << v.z; } 178 | inline std::ostream & operator << (std::ostream & o, rs2_quaternion q) { return o << q.x << ", " << q.y << ", " << q.z << ", " << q.w; } 179 | 180 | #endif // LIBREALSENSE_RS2_TYPES_HPP 181 | -------------------------------------------------------------------------------- /libs/librealsense2/include/librealsense2/rs.h: -------------------------------------------------------------------------------- 1 | /* License: Apache 2.0. See LICENSE file in root directory. 2 | Copyright(c) 2017 Intel Corporation. All Rights Reserved. */ 3 | 4 | /** \file rs.h 5 | * \brief 6 | * Exposes librealsense functionality for C compilers 7 | */ 8 | 9 | #ifndef LIBREALSENSE_RS2_H 10 | #define LIBREALSENSE_RS2_H 11 | 12 | #ifdef __cplusplus 13 | extern "C" { 14 | #endif 15 | 16 | #include "h/rs_types.h" 17 | #include "h/rs_context.h" 18 | #include "h/rs_device.h" 19 | #include "h/rs_frame.h" 20 | #include "h/rs_option.h" 21 | #include "h/rs_processing.h" 22 | #include "h/rs_record_playback.h" 23 | #include "h/rs_sensor.h" 24 | 25 | #define RS2_API_MAJOR_VERSION 2 26 | #define RS2_API_MINOR_VERSION 25 27 | #define RS2_API_PATCH_VERSION 0 28 | #define RS2_API_BUILD_VERSION 993 29 | 30 | #ifndef STRINGIFY 31 | #define STRINGIFY(arg) #arg 32 | #endif 33 | #ifndef VAR_ARG_STRING 34 | #define VAR_ARG_STRING(arg) STRINGIFY(arg) 35 | #endif 36 | 37 | /* Versioning rules : For each release at least one of [MJR/MNR/PTCH] triple is promoted */ 38 | /* : Versions that differ by RS2_API_PATCH_VERSION only are interface-compatible, i.e. no user-code changes required */ 39 | /* : Versions that differ by MAJOR/MINOR VERSION component can introduce API changes */ 40 | /* Version in encoded integer format (1,9,x) -> 01090x. note that each component is limited into [0-99] range by design */ 41 | #define RS2_API_VERSION (((RS2_API_MAJOR_VERSION) * 10000) + ((RS2_API_MINOR_VERSION) * 100) + (RS2_API_PATCH_VERSION)) 42 | /* Return version in "X.Y.Z" format */ 43 | #define RS2_API_VERSION_STR (VAR_ARG_STRING(RS2_API_MAJOR_VERSION.RS2_API_MINOR_VERSION.RS2_API_PATCH_VERSION)) 44 | 45 | /** 46 | * get the size of rs2_raw_data_buffer 47 | * \param[in] buffer pointer to rs2_raw_data_buffer returned by rs2_send_and_receive_raw_data 48 | * \param[out] error if non-null, receives any error that occurs during this call, otherwise, errors are ignored 49 | * \return size of rs2_raw_data_buffer 50 | */ 51 | int rs2_get_raw_data_size(const rs2_raw_data_buffer* buffer, rs2_error** error); 52 | 53 | /** 54 | * Delete rs2_raw_data_buffer 55 | * \param[in] buffer rs2_raw_data_buffer returned by rs2_send_and_receive_raw_data 56 | */ 57 | void rs2_delete_raw_data(const rs2_raw_data_buffer* buffer); 58 | 59 | /** 60 | * Retrieve char array from rs2_raw_data_buffer 61 | * \param[in] buffer rs2_raw_data_buffer returned by rs2_send_and_receive_raw_data 62 | * \param[out] error if non-null, receives any error that occurs during this call, otherwise, errors are ignored 63 | * \return raw data 64 | */ 65 | const unsigned char* rs2_get_raw_data(const rs2_raw_data_buffer* buffer, rs2_error** error); 66 | 67 | /** 68 | * Retrieve the API version from the source code. Evaluate that the value is conformant to the established policies 69 | * \param[out] error if non-null, receives any error that occurs during this call, otherwise, errors are ignored 70 | * \return the version API encoded into integer value "1.9.3" -> 10903 71 | */ 72 | int rs2_get_api_version(rs2_error** error); 73 | 74 | void rs2_log_to_console(rs2_log_severity min_severity, rs2_error ** error); 75 | 76 | void rs2_log_to_file(rs2_log_severity min_severity, const char * file_path, rs2_error ** error); 77 | 78 | /** 79 | * Add custom message into librealsense log 80 | * \param[in] severity The log level for the message to be written under 81 | * \param[in] message Message to be logged 82 | * \param[out] error if non-null, receives any error that occurs during this call, otherwise, errors are ignored 83 | */ 84 | void rs2_log(rs2_log_severity severity, const char * message, rs2_error ** error); 85 | 86 | /** 87 | * Given the 2D depth coordinate (x,y) provide the corresponding depth in metric units 88 | * \param[in] frame_ref 2D depth pixel coordinates (Left-Upper corner origin) 89 | * \param[in] x,y 2D depth pixel coordinates (Left-Upper corner origin) 90 | * \param[out] error if non-null, receives any error that occurs during this call, otherwise, errors are ignored 91 | */ 92 | float rs2_depth_frame_get_distance(const rs2_frame* frame_ref, int x, int y, rs2_error** error); 93 | 94 | /** 95 | * return the time at specific time point 96 | * \param[out] error if non-null, receives any error that occurs during this call, otherwise, errors are ignored 97 | * \return the time at specific time point, in live and record mode it will return the system time and in playback mode it will return the recorded time 98 | */ 99 | rs2_time_t rs2_get_time( rs2_error** error); 100 | 101 | #ifdef __cplusplus 102 | } 103 | #endif 104 | #endif 105 | -------------------------------------------------------------------------------- /libs/librealsense2/include/librealsense2/rs.hpp: -------------------------------------------------------------------------------- 1 | // License: Apache 2.0. See LICENSE file in root directory. 2 | // Copyright(c) 2017 Intel Corporation. All Rights Reserved. 3 | 4 | #ifndef LIBREALSENSE_RS2_HPP 5 | #define LIBREALSENSE_RS2_HPP 6 | 7 | #include "rs.h" 8 | #include "hpp/rs_types.hpp" 9 | #include "hpp/rs_context.hpp" 10 | #include "hpp/rs_device.hpp" 11 | #include "hpp/rs_frame.hpp" 12 | #include "hpp/rs_processing.hpp" 13 | #include "hpp/rs_record_playback.hpp" 14 | #include "hpp/rs_sensor.hpp" 15 | #include "hpp/rs_pipeline.hpp" 16 | 17 | namespace rs2 18 | { 19 | inline void log_to_console(rs2_log_severity min_severity) 20 | { 21 | rs2_error* e = nullptr; 22 | rs2_log_to_console(min_severity, &e); 23 | error::handle(e); 24 | } 25 | 26 | inline void log_to_file(rs2_log_severity min_severity, const char * file_path = nullptr) 27 | { 28 | rs2_error* e = nullptr; 29 | rs2_log_to_file(min_severity, file_path, &e); 30 | error::handle(e); 31 | } 32 | 33 | inline void log(rs2_log_severity severity, const char* message) 34 | { 35 | rs2_error* e = nullptr; 36 | rs2_log(severity, message, &e); 37 | error::handle(e); 38 | } 39 | } 40 | 41 | inline std::ostream & operator << (std::ostream & o, rs2_stream stream) { return o << rs2_stream_to_string(stream); } 42 | inline std::ostream & operator << (std::ostream & o, rs2_format format) { return o << rs2_format_to_string(format); } 43 | inline std::ostream & operator << (std::ostream & o, rs2_distortion distortion) { return o << rs2_distortion_to_string(distortion); } 44 | inline std::ostream & operator << (std::ostream & o, rs2_option option) { return o << rs2_option_to_string(option); } // This function is being deprecated. For existing options it will return option name, but for future API additions the user should call rs2_get_option_name instead. 45 | inline std::ostream & operator << (std::ostream & o, rs2_log_severity severity) { return o << rs2_log_severity_to_string(severity); } 46 | inline std::ostream & operator << (std::ostream & o, rs2_camera_info camera_info) { return o << rs2_camera_info_to_string(camera_info); } 47 | inline std::ostream & operator << (std::ostream & o, rs2_frame_metadata_value metadata) { return o << rs2_frame_metadata_to_string(metadata); } 48 | inline std::ostream & operator << (std::ostream & o, rs2_timestamp_domain domain) { return o << rs2_timestamp_domain_to_string(domain); } 49 | inline std::ostream & operator << (std::ostream & o, rs2_notification_category notificaton) { return o << rs2_notification_category_to_string(notificaton); } 50 | inline std::ostream & operator << (std::ostream & o, rs2_sr300_visual_preset preset) { return o << rs2_sr300_visual_preset_to_string(preset); } 51 | inline std::ostream & operator << (std::ostream & o, rs2_exception_type exception_type) { return o << rs2_exception_type_to_string(exception_type); } 52 | inline std::ostream & operator << (std::ostream & o, rs2_playback_status status) { return o << rs2_playback_status_to_string(status); } 53 | 54 | #endif // LIBREALSENSE_RS2_HPP 55 | -------------------------------------------------------------------------------- /libs/librealsense2/include/librealsense2/rs_advanced_mode.h: -------------------------------------------------------------------------------- 1 | /* License: Apache 2.0. See LICENSE file in root directory. 2 | Copyright(c) 2017 Intel Corporation. All Rights Reserved. */ 3 | 4 | #ifndef RS400_ADVANCED_MODE_H 5 | #define RS400_ADVANCED_MODE_H 6 | 7 | #define RS400_ADVANCED_MODE_HPP 8 | #include "h/rs_advanced_mode_command.h" 9 | #undef RS400_ADVANCED_MODE_HPP 10 | 11 | #include "h/rs_types.h" 12 | 13 | #ifdef __cplusplus 14 | extern "C" { 15 | #endif 16 | 17 | /* Enable/Disable Advanced-Mode */ 18 | void rs2_toggle_advanced_mode(rs2_device* dev, int enable, rs2_error** error); 19 | 20 | /* Check if Advanced-Mode is enabled */ 21 | void rs2_is_enabled(rs2_device* dev, int* enabled, rs2_error** error); 22 | 23 | /* Sets new values for Depth Control Group, returns 0 if success */ 24 | void rs2_set_depth_control(rs2_device* dev, const STDepthControlGroup* group, rs2_error** error); 25 | 26 | /* Gets new values for Depth Control Group, returns 0 if success */ 27 | void rs2_get_depth_control(rs2_device* dev, STDepthControlGroup* group, int mode, rs2_error** error); 28 | 29 | /* Sets new values for RSM Group, returns 0 if success */ 30 | void rs2_set_rsm(rs2_device* dev, const STRsm* group, rs2_error** error); 31 | 32 | /* Gets new values for RSM Group, returns 0 if success */ 33 | void rs2_get_rsm(rs2_device* dev, STRsm* group, int mode, rs2_error** error); 34 | 35 | /* Sets new values for STRauSupportVectorControl, returns 0 if success */ 36 | void rs2_set_rau_support_vector_control(rs2_device* dev, const STRauSupportVectorControl* group, rs2_error** error); 37 | 38 | /* Gets new values for STRauSupportVectorControl, returns 0 if success */ 39 | void rs2_get_rau_support_vector_control(rs2_device* dev, STRauSupportVectorControl* group, int mode, rs2_error** error); 40 | 41 | /* Sets new values for STColorControl, returns 0 if success */ 42 | void rs2_set_color_control(rs2_device* dev, const STColorControl* group, rs2_error** error); 43 | 44 | /* Gets new values for STColorControl, returns 0 if success */ 45 | void rs2_get_color_control(rs2_device* dev, STColorControl* group, int mode, rs2_error** error); 46 | 47 | /* Sets new values for STRauColorThresholdsControl, returns 0 if success */ 48 | void rs2_set_rau_thresholds_control(rs2_device* dev, const STRauColorThresholdsControl* group, rs2_error** error); 49 | 50 | /* Gets new values for STRauColorThresholdsControl, returns 0 if success */ 51 | void rs2_get_rau_thresholds_control(rs2_device* dev, STRauColorThresholdsControl* group, int mode, rs2_error** error); 52 | 53 | /* Sets new values for STSloColorThresholdsControl, returns 0 if success */ 54 | void rs2_set_slo_color_thresholds_control(rs2_device* dev, const STSloColorThresholdsControl* group, rs2_error** error); 55 | 56 | /* Gets new values for STRauColorThresholdsControl, returns 0 if success */ 57 | void rs2_get_slo_color_thresholds_control(rs2_device* dev, STSloColorThresholdsControl* group, int mode, rs2_error** error); 58 | 59 | /* Sets new values for STSloPenaltyControl, returns 0 if success */ 60 | void rs2_set_slo_penalty_control(rs2_device* dev, const STSloPenaltyControl* group, rs2_error** error); 61 | 62 | /* Gets new values for STSloPenaltyControl, returns 0 if success */ 63 | void rs2_get_slo_penalty_control(rs2_device* dev, STSloPenaltyControl* group, int mode, rs2_error** error); 64 | 65 | /* Sets new values for STHdad, returns 0 if success */ 66 | void rs2_set_hdad(rs2_device* dev, const STHdad* group, rs2_error** error); 67 | 68 | /* Gets new values for STHdad, returns 0 if success */ 69 | void rs2_get_hdad(rs2_device* dev, STHdad* group, int mode, rs2_error** error); 70 | 71 | /* Sets new values for STColorCorrection, returns 0 if success */ 72 | void rs2_set_color_correction(rs2_device* dev, const STColorCorrection* group, rs2_error** error); 73 | 74 | /* Gets new values for STColorCorrection, returns 0 if success */ 75 | void rs2_get_color_correction(rs2_device* dev, STColorCorrection* group, int mode, rs2_error** error); 76 | 77 | /* Sets new values for STDepthTableControl, returns 0 if success */ 78 | void rs2_set_depth_table(rs2_device* dev, const STDepthTableControl* group, rs2_error** error); 79 | 80 | /* Gets new values for STDepthTableControl, returns 0 if success */ 81 | void rs2_get_depth_table(rs2_device* dev, STDepthTableControl* group, int mode, rs2_error** error); 82 | 83 | void rs2_set_ae_control(rs2_device* dev, const STAEControl* group, rs2_error** error); 84 | 85 | void rs2_get_ae_control(rs2_device* dev, STAEControl* group, int mode, rs2_error** error); 86 | 87 | void rs2_set_census(rs2_device* dev, const STCensusRadius* group, rs2_error** error); 88 | 89 | void rs2_get_census(rs2_device* dev, STCensusRadius* group, int mode, rs2_error** error); 90 | 91 | void rs2_set_amp_factor(rs2_device* dev, const STAFactor* group, rs2_error** error); 92 | 93 | /* Gets new values for STAFactor, returns 0 if success */ 94 | void rs2_get_amp_factor(rs2_device* dev, STAFactor* group, int mode, rs2_error** error); 95 | 96 | /* Load JSON and apply advanced-mode controls, returns 0 if success */ 97 | void rs2_load_json(rs2_device* dev, const void* json_content, unsigned content_size, rs2_error** error); 98 | 99 | /* Serialize JSON content, returns 0 if success */ 100 | rs2_raw_data_buffer* rs2_serialize_json(rs2_device* dev, rs2_error** error); 101 | 102 | #ifdef __cplusplus 103 | } 104 | #endif 105 | #endif 106 | -------------------------------------------------------------------------------- /libs/librealsense2/include/librealsense2/rsutil.h: -------------------------------------------------------------------------------- 1 | /* License: Apache 2.0. See LICENSE file in root directory. 2 | Copyright(c) 2015 Intel Corporation. All Rights Reserved. */ 3 | 4 | #ifndef LIBREALSENSE_RSUTIL2_H 5 | #define LIBREALSENSE_RSUTIL2_H 6 | 7 | #include "h/rs_types.h" 8 | #include "h/rs_sensor.h" 9 | #include "h/rs_frame.h" 10 | #include "rs.h" 11 | #include "assert.h" 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | 18 | /* Given a point in 3D space, compute the corresponding pixel coordinates in an image with no distortion or forward distortion coefficients produced by the same camera */ 19 | static void rs2_project_point_to_pixel(float pixel[2], const struct rs2_intrinsics * intrin, const float point[3]) 20 | { 21 | float x = point[0] / point[2], y = point[1] / point[2]; 22 | 23 | if ((intrin->model == RS2_DISTORTION_MODIFIED_BROWN_CONRADY) || 24 | (intrin->model == RS2_DISTORTION_INVERSE_BROWN_CONRADY)) 25 | { 26 | 27 | float r2 = x*x + y*y; 28 | float f = 1 + intrin->coeffs[0]*r2 + intrin->coeffs[1]*r2*r2 + intrin->coeffs[4]*r2*r2*r2; 29 | x *= f; 30 | y *= f; 31 | float dx = x + 2*intrin->coeffs[2]*x*y + intrin->coeffs[3]*(r2 + 2*x*x); 32 | float dy = y + 2*intrin->coeffs[3]*x*y + intrin->coeffs[2]*(r2 + 2*y*y); 33 | x = dx; 34 | y = dy; 35 | } 36 | if (intrin->model == RS2_DISTORTION_FTHETA) 37 | { 38 | float r = sqrtf(x*x + y*y); 39 | if (r < FLT_EPSILON) 40 | { 41 | r = FLT_EPSILON; 42 | } 43 | float rd = (float)(1.0f / intrin->coeffs[0] * atan(2 * r* tan(intrin->coeffs[0] / 2.0f))); 44 | x *= rd / r; 45 | y *= rd / r; 46 | } 47 | if (intrin->model == RS2_DISTORTION_KANNALA_BRANDT4) 48 | { 49 | float r = sqrtf(x*x + y*y); 50 | if (r < FLT_EPSILON) 51 | { 52 | r = FLT_EPSILON; 53 | } 54 | float theta = atan(r); 55 | float theta2 = theta*theta; 56 | float series = 1 + theta2*(intrin->coeffs[0] + theta2*(intrin->coeffs[1] + theta2*(intrin->coeffs[2] + theta2*intrin->coeffs[3]))); 57 | float rd = theta*series; 58 | x *= rd / r; 59 | y *= rd / r; 60 | } 61 | 62 | pixel[0] = x * intrin->fx + intrin->ppx; 63 | pixel[1] = y * intrin->fy + intrin->ppy; 64 | } 65 | 66 | /* Given pixel coordinates and depth in an image with no distortion or inverse distortion coefficients, compute the corresponding point in 3D space relative to the same camera */ 67 | static void rs2_deproject_pixel_to_point(float point[3], const struct rs2_intrinsics * intrin, const float pixel[2], float depth) 68 | { 69 | assert(intrin->model != RS2_DISTORTION_MODIFIED_BROWN_CONRADY); // Cannot deproject from a forward-distorted image 70 | //assert(intrin->model != RS2_DISTORTION_BROWN_CONRADY); // Cannot deproject to an brown conrady model 71 | 72 | float x = (pixel[0] - intrin->ppx) / intrin->fx; 73 | float y = (pixel[1] - intrin->ppy) / intrin->fy; 74 | if(intrin->model == RS2_DISTORTION_INVERSE_BROWN_CONRADY) 75 | { 76 | float r2 = x*x + y*y; 77 | float f = 1 + intrin->coeffs[0]*r2 + intrin->coeffs[1]*r2*r2 + intrin->coeffs[4]*r2*r2*r2; 78 | float ux = x*f + 2*intrin->coeffs[2]*x*y + intrin->coeffs[3]*(r2 + 2*x*x); 79 | float uy = y*f + 2*intrin->coeffs[3]*x*y + intrin->coeffs[2]*(r2 + 2*y*y); 80 | x = ux; 81 | y = uy; 82 | } 83 | if (intrin->model == RS2_DISTORTION_KANNALA_BRANDT4) 84 | { 85 | float rd = sqrtf(x*x + y*y); 86 | if (rd < FLT_EPSILON) 87 | { 88 | rd = FLT_EPSILON; 89 | } 90 | 91 | float theta = rd; 92 | float theta2 = rd*rd; 93 | for (int i = 0; i < 4; i++) 94 | { 95 | float f = theta*(1 + theta2*(intrin->coeffs[0] + theta2*(intrin->coeffs[1] + theta2*(intrin->coeffs[2] + theta2*intrin->coeffs[3])))) - rd; 96 | if (abs(f) < FLT_EPSILON) 97 | { 98 | break; 99 | } 100 | float df = 1 + theta2*(3 * intrin->coeffs[0] + theta2*(5 * intrin->coeffs[1] + theta2*(7 * intrin->coeffs[2] + 9 * theta2*intrin->coeffs[3]))); 101 | theta -= f / df; 102 | theta2 = theta*theta; 103 | } 104 | float r = tan(theta); 105 | x *= r / rd; 106 | y *= r / rd; 107 | } 108 | if (intrin->model == RS2_DISTORTION_FTHETA) 109 | { 110 | float rd = sqrtf(x*x + y*y); 111 | if (rd < FLT_EPSILON) 112 | { 113 | rd = FLT_EPSILON; 114 | } 115 | float r = (float)(tan(intrin->coeffs[0] * rd) / atan(2 * tan(intrin->coeffs[0] / 2.0f))); 116 | x *= r / rd; 117 | y *= r / rd; 118 | } 119 | 120 | point[0] = depth * x; 121 | point[1] = depth * y; 122 | point[2] = depth; 123 | } 124 | 125 | /* Transform 3D coordinates relative to one sensor to 3D coordinates relative to another viewpoint */ 126 | static void rs2_transform_point_to_point(float to_point[3], const struct rs2_extrinsics * extrin, const float from_point[3]) 127 | { 128 | to_point[0] = extrin->rotation[0] * from_point[0] + extrin->rotation[3] * from_point[1] + extrin->rotation[6] * from_point[2] + extrin->translation[0]; 129 | to_point[1] = extrin->rotation[1] * from_point[0] + extrin->rotation[4] * from_point[1] + extrin->rotation[7] * from_point[2] + extrin->translation[1]; 130 | to_point[2] = extrin->rotation[2] * from_point[0] + extrin->rotation[5] * from_point[1] + extrin->rotation[8] * from_point[2] + extrin->translation[2]; 131 | } 132 | 133 | /* Calculate horizontal and vertical feild of view, based on video intrinsics */ 134 | static void rs2_fov(const struct rs2_intrinsics * intrin, float to_fov[2]) 135 | { 136 | to_fov[0] = (atan2f(intrin->ppx + 0.5f, intrin->fx) + atan2f(intrin->width - (intrin->ppx + 0.5f), intrin->fx)) * 57.2957795f; 137 | to_fov[1] = (atan2f(intrin->ppy + 0.5f, intrin->fy) + atan2f(intrin->height - (intrin->ppy + 0.5f), intrin->fy)) * 57.2957795f; 138 | } 139 | 140 | static void next_pixel_in_line(float curr[2], const float start[2], const float end[2]) 141 | { 142 | float line_slope = (end[1] - start[1]) / (end[0] - start[0]); 143 | if (fabs(end[0] - curr[0]) > fabs(end[1] - curr[1])) 144 | { 145 | curr[0] = end[0] > curr[0] ? curr[0] + 1 : curr[0] - 1; 146 | curr[1] = end[1] - line_slope * (end[0] - curr[0]); 147 | } 148 | else 149 | { 150 | curr[1] = end[1] > curr[1] ? curr[1] + 1 : curr[1] - 1; 151 | curr[0] = end[0] - ((end[1] + curr[1]) / line_slope); 152 | } 153 | } 154 | 155 | static bool is_pixel_in_line(const float curr[2], const float start[2], const float end[2]) 156 | { 157 | return ((end[0] >= start[0] && end[0] >= curr[0] && curr[0] >= start[0]) || (end[0] <= start[0] && end[0] <= curr[0] && curr[0] <= start[0])) && 158 | ((end[1] >= start[1] && end[1] >= curr[1] && curr[1] >= start[1]) || (end[1] <= start[1] && end[1] <= curr[1] && curr[1] <= start[1])); 159 | } 160 | 161 | static void adjust_2D_point_to_boundary(float p[2], int width, int height) 162 | { 163 | if (p[0] < 0) p[0] = 0; 164 | if (p[0] > width) p[0] = (float)width; 165 | if (p[1] < 0) p[1] = 0; 166 | if (p[1] > height) p[1] = (float)height; 167 | } 168 | 169 | /* Find projected pixel with unknown depth search along line. */ 170 | static void rs2_project_color_pixel_to_depth_pixel(float to_pixel[2], 171 | const uint16_t* data, float depth_scale, 172 | float depth_min, float depth_max, 173 | const struct rs2_intrinsics* depth_intrin, 174 | const struct rs2_intrinsics* color_intrin, 175 | const struct rs2_extrinsics* color_to_depth, 176 | const struct rs2_extrinsics* depth_to_color, 177 | const float from_pixel[2]) 178 | { 179 | //Find line start pixel 180 | float start_pixel[2] = { 0 }, min_point[3] = { 0 }, min_transformed_point[3] = { 0 }; 181 | rs2_deproject_pixel_to_point(min_point, color_intrin, from_pixel, depth_min); 182 | rs2_transform_point_to_point(min_transformed_point, color_to_depth, min_point); 183 | rs2_project_point_to_pixel(start_pixel, depth_intrin, min_transformed_point); 184 | adjust_2D_point_to_boundary(start_pixel, depth_intrin->width, depth_intrin->height); 185 | 186 | //Find line end depth pixel 187 | float end_pixel[2] = { 0 }, max_point[3] = { 0 }, max_transformed_point[3] = { 0 }; 188 | rs2_deproject_pixel_to_point(max_point, color_intrin, from_pixel, depth_max); 189 | rs2_transform_point_to_point(max_transformed_point, color_to_depth, max_point); 190 | rs2_project_point_to_pixel(end_pixel, depth_intrin, max_transformed_point); 191 | adjust_2D_point_to_boundary(end_pixel, depth_intrin->width, depth_intrin->height); 192 | 193 | //search along line for the depth pixel that it's projected pixel is the closest to the input pixel 194 | float min_dist = -1; 195 | for (float p[2] = { start_pixel[0], start_pixel[1] }; is_pixel_in_line(p, start_pixel, end_pixel); next_pixel_in_line(p, start_pixel, end_pixel)) 196 | { 197 | float depth = depth_scale * data[(int)p[1] * depth_intrin->width + (int)p[0]]; 198 | if (depth == 0) 199 | continue; 200 | 201 | float projected_pixel[2] = { 0 }, point[3] = { 0 }, transformed_point[3] = { 0 }; 202 | rs2_deproject_pixel_to_point(point, depth_intrin, p, depth); 203 | rs2_transform_point_to_point(transformed_point, depth_to_color, point); 204 | rs2_project_point_to_pixel(projected_pixel, color_intrin, transformed_point); 205 | 206 | float new_dist = pow((projected_pixel[1] - from_pixel[1]), 2) + pow((projected_pixel[0] - from_pixel[0]), 2); 207 | if (new_dist < min_dist || min_dist < 0) 208 | { 209 | min_dist = new_dist; 210 | to_pixel[0] = p[0]; 211 | to_pixel[1] = p[1]; 212 | } 213 | } 214 | } 215 | 216 | #endif 217 | -------------------------------------------------------------------------------- /libs/librealsense2/lib/osx/libfw.a: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:d013b055a220ca0559ea0109cf87be27b01ba67133601d42638c26063b78522f 3 | size 8400144 4 | -------------------------------------------------------------------------------- /libs/librealsense2/lib/osx/librealsense-file.a: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:59176f0bafe1b105723b950cfe0e1716f33eff3d9fe54c9babce8354a9dfc7ed 3 | size 8413160 4 | -------------------------------------------------------------------------------- /libs/librealsense2/lib/osx/librealsense2-gl.a: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:bb6f4edf7915761545710e2bd3fa32387fd4299373b2a23e867e1aa446099693 3 | size 42006808 4 | -------------------------------------------------------------------------------- /libs/librealsense2/lib/osx/librealsense2.a: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:2b5695de90f9f1f382b5bfb5290dbd70a9450d805883f4acb36a535dce56c058 3 | size 392361448 4 | -------------------------------------------------------------------------------- /libs/librealsense2/lib/osx/libtm.a: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:08134e21abfd624c93728622841f02109ed098a0836feb3e9361fc575501bbb0 3 | size 5595328 4 | -------------------------------------------------------------------------------- /libs/librealsense2/lib/osx/libuvc_fw.a: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:28c204ac4759b30d10fa2166165844a0f8fec3a0ce5f692ca65af1322455e531 3 | size 2366104 4 | -------------------------------------------------------------------------------- /libs/librealsense2/lib/vs/Win32/realsense2.lib: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:f1512fcd73259d3bbfbbbf7a2badba8292e14da7d5583f0066645b04c77e2166 3 | size 216948 4 | -------------------------------------------------------------------------------- /libs/librealsense2/lib/vs/x64/realsense2.lib: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:cb5cfb21b5a9572cf195bdd90d60e019dbf876e436eb8853bd8d56ca482c4958 3 | size 217742 4 | -------------------------------------------------------------------------------- /libs/libusb/lib/osx/libusb-1.0.a: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:a54e61b5c6bb17a2272a109666d1026ae12089fde8903b7005a05b707824ab19 3 | size 108184 4 | -------------------------------------------------------------------------------- /src/ofxRealSense2.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "ofxRealSense2/Context.h" 4 | #include "ofxRealSense2/Device.h" -------------------------------------------------------------------------------- /src/ofxRealSense2/Context.cpp: -------------------------------------------------------------------------------- 1 | #include "Context.h" 2 | 3 | #include "ofLog.h" 4 | 5 | namespace ofxRealSense2 6 | { 7 | Context::Context() 8 | { 9 | 10 | } 11 | 12 | Context::~Context() 13 | { 14 | clear(); 15 | } 16 | 17 | void Context::setup(bool autoStart) 18 | { 19 | this->autoStart = autoStart; 20 | 21 | this->context = std::make_shared(); 22 | 23 | // Register callback for tracking which devices are currently connected. 24 | this->context->set_devices_changed_callback([&](rs2::event_information & info) 25 | { 26 | this->removeDevices(info); 27 | for (auto && dev : info.get_new_devices()) 28 | { 29 | this->addDevice(dev); 30 | } 31 | }); 32 | 33 | // Populate initial device list. 34 | for (auto && dev : this->context->query_devices()) 35 | { 36 | this->addDevice(dev); 37 | } 38 | } 39 | 40 | void Context::clear() 41 | { 42 | auto it = this->devices.begin(); 43 | while (it != this->devices.end()) 44 | { 45 | it->second->stopPipeline(); 46 | ++it; 47 | } 48 | this->devices.clear(); 49 | 50 | this->context.reset(); 51 | } 52 | 53 | void Context::update() 54 | { 55 | std::lock_guard lock(this->mutex); 56 | for (auto it : this->devices) 57 | { 58 | if (it.second->isRunning()) 59 | { 60 | //it.second->pollForFrames(); 61 | //it.second->updateData(); 62 | it.second->update(); 63 | } 64 | } 65 | } 66 | 67 | void Context::addDevice(rs2::device& device) 68 | { 69 | auto serialNumber = std::string(device.get_info(RS2_CAMERA_INFO_SERIAL_NUMBER)); 70 | std::lock_guard lock(this->mutex); 71 | 72 | if (this->devices.find(serialNumber) != this->devices.end()) 73 | { 74 | // Already added, ignore. 75 | return; 76 | } 77 | 78 | static const std::string platformCameraName = "Platform Camera"; 79 | if (platformCameraName == device.get_info(RS2_CAMERA_INFO_NAME)) 80 | { 81 | // Platform camera (webcam, etc), ignore. 82 | return; 83 | } 84 | 85 | // Add the device. 86 | ofLogNotice(__FUNCTION__) << "Add device " << serialNumber; 87 | this->devices.emplace(serialNumber, std::make_shared(*this->context, device)); 88 | this->deviceAddedEvent.notify(serialNumber); 89 | 90 | if (this->autoStart) 91 | { 92 | // Start the device. 93 | ofLogNotice(__FUNCTION__) << "Start device " << serialNumber; 94 | auto device = this->devices.at(serialNumber); 95 | device->enableDepth(); 96 | device->enableColor(); 97 | device->startPipeline(); 98 | } 99 | } 100 | 101 | void Context::removeDevices(const rs2::event_information & info) 102 | { 103 | std::lock_guard lock(this->mutex); 104 | // Go over the list of devices and check if it was disconnected. 105 | auto it = this->devices.begin(); 106 | while (it != this->devices.end()) 107 | { 108 | if (info.was_removed(it->second->getNativeDevice())) 109 | { 110 | auto serialNumber = it->first; 111 | ofLogNotice(__FUNCTION__) << "Remove device " << serialNumber; 112 | this->deviceRemovedEvent.notify(serialNumber); 113 | it = this->devices.erase(it); 114 | } 115 | else 116 | { 117 | ++it; 118 | } 119 | } 120 | } 121 | 122 | const std::map> & Context::getDevices() const 123 | { 124 | return this->devices; 125 | } 126 | 127 | std::shared_ptr Context::getDevice(const std::string & serialNumber) const 128 | { 129 | return this->devices.at(serialNumber); 130 | } 131 | 132 | std::shared_ptr Context::getDevice(int idx) const 133 | { 134 | if (this->devices.size() > idx) 135 | { 136 | auto it = this->devices.begin(); 137 | int i = 0; 138 | while (i < idx) 139 | { 140 | ++it; 141 | ++i; 142 | } 143 | return (*it).second; 144 | } 145 | return nullptr; 146 | } 147 | 148 | size_t Context::getNumDevices() const 149 | { 150 | return this->devices.size(); 151 | } 152 | 153 | const std::shared_ptr Context::getNativeContext() const 154 | { 155 | return this->context; 156 | } 157 | } -------------------------------------------------------------------------------- /src/ofxRealSense2/Context.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "ofConstants.h" 4 | #include "ofEvent.h" 5 | #include "librealsense2/rs.hpp" 6 | #include "Device.h" 7 | 8 | namespace ofxRealSense2 9 | { 10 | class Context 11 | { 12 | public: 13 | Context(); 14 | ~Context(); 15 | 16 | void setup(bool autoStart = true); 17 | void clear(); 18 | 19 | void update(); 20 | 21 | const std::map> & getDevices() const; 22 | std::shared_ptr getDevice(const std::string & serialNumber) const; 23 | std::shared_ptr getDevice(int idx = 0) const; 24 | size_t getNumDevices() const; 25 | 26 | const std::shared_ptr getNativeContext() const; 27 | 28 | public: 29 | ofEvent deviceAddedEvent; 30 | ofEvent deviceRemovedEvent; 31 | 32 | private: 33 | void addDevice(rs2::device& device); 34 | void removeDevices(const rs2::event_information & info); 35 | 36 | private: 37 | std::shared_ptr context; 38 | std::mutex mutex; 39 | std::map> devices; 40 | bool autoStart; 41 | }; 42 | } -------------------------------------------------------------------------------- /src/ofxRealSense2/Device.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "librealsense2/rs.hpp" 4 | 5 | #include "ofParameter.h" 6 | #include "ofPixels.h" 7 | #include "ofTexture.h" 8 | #include "ofThread.h" 9 | #include "ofVboMesh.h" 10 | 11 | namespace ofxRealSense2 12 | { 13 | class Device 14 | : ofThread 15 | { 16 | public: 17 | enum Align 18 | { 19 | None, 20 | Depth, 21 | Color 22 | }; 23 | public: 24 | Device(rs2::context& context, const rs2::device& device); 25 | ~Device(); 26 | 27 | void startPipeline(); 28 | void stopPipeline(); 29 | bool isRunning() const; 30 | 31 | void setupParams(); 32 | void clearParams(); 33 | 34 | void enableDepth(int width = 640, int height = 360, int fps = 30); 35 | void disableDepth(); 36 | 37 | void enableInfrared(int width = 640, int height = 360, int fps = 30); 38 | void disableInfrared(); 39 | 40 | void enableColor(int width = 640, int height = 360, int fps = 30); 41 | void disableColor(); 42 | 43 | void enablePoints(); 44 | void disablePoints(); 45 | 46 | void threadedFunction() override; 47 | void update(); 48 | 49 | const ofPixels& getDepthPix() const; 50 | const ofShortPixels& getRawDepthPix() const; 51 | const ofPixels& getInfraredPix() const; 52 | const ofPixels& getColorPix() const; 53 | 54 | const ofTexture& getDepthTex() const; 55 | const ofTexture& getRawDepthTex() const; 56 | const ofTexture& getInfraredTex() const; 57 | const ofTexture& getColorTex() const; 58 | 59 | const ofVboMesh& getPointsMesh() const; 60 | const size_t getNumPoints() const; 61 | 62 | float getDistance(int x, int y) const; 63 | ofDefaultVertexType getWorldPosition(int x, int y) const; 64 | ofDefaultTexCoordType getTexCoord(int x, int y) const; 65 | 66 | const rs2::device& getNativeDevice() const; 67 | const rs2::pipeline& getNativePipeline() const; 68 | const rs2::pipeline_profile& getNativeProfile() const; 69 | 70 | public: 71 | ofParameterGroup params; 72 | 73 | ofParameter alignMode; 74 | 75 | ofParameter autoExposure; 76 | ofParameter emitterEnabled; 77 | ofParameter irExposure; 78 | 79 | ofParameter depthMin; 80 | ofParameter depthMax; 81 | 82 | ofParameter decimateEnabled; 83 | ofParameter decimateMagnitude; 84 | 85 | ofParameter disparityTransformEnabled; 86 | 87 | ofParameter spatialFilterEnabled; 88 | ofParameter spatialFilterMagnitude; 89 | ofParameter spatialFilterSmoothAlpha; 90 | ofParameter spatialFilterSmoothDelta; 91 | ofParameter spatialFilterHoleFillingMode; 92 | 93 | ofParameter temporalFilterEnabled; 94 | ofParameter temporalFilterSmoothAlpha; 95 | ofParameter temporalFilterSmoothDelta; 96 | ofParameter temporalFilterPersistencyMode; 97 | 98 | ofParameter holeFillingEnabled; 99 | ofParameter holeFillingMode; 100 | 101 | private: 102 | rs2::device device; 103 | rs2::config config; 104 | rs2::pipeline pipeline; 105 | rs2::pipeline_profile profile; 106 | rs2::colorizer colorizer; 107 | 108 | bool running; 109 | 110 | int depthWidth; 111 | int depthHeight; 112 | bool depthEnabled; 113 | rs2::frame_queue depthQueue; 114 | std::shared_ptr depthFrameRef; 115 | ofPixels depthPix; 116 | ofShortPixels rawDepthPix; 117 | ofTexture depthTex; 118 | ofTexture rawDepthTex; 119 | 120 | int infraredWidth; 121 | int infraredHeight; 122 | bool infraredEnabled; 123 | rs2::frame_queue infraredQueue; 124 | ofPixels infraredPix; 125 | ofTexture infraredTex; 126 | 127 | int colorWidth; 128 | int colorHeight; 129 | bool colorEnabled; 130 | rs2::frame_queue colorQueue; 131 | ofPixels colorPix; 132 | ofTexture colorTex; 133 | 134 | rs2::align alignToDepth; 135 | rs2::align alignToColor; 136 | 137 | rs2::pointcloud pointCloud; 138 | rs2::points points; 139 | bool pointsEnabled; 140 | ofVboMesh pointsMesh; 141 | 142 | rs2::decimation_filter decimationFilter; 143 | rs2::disparity_transform disparityTransform; 144 | rs2::disparity_transform depthTransform; 145 | rs2::spatial_filter spatialFilter; 146 | rs2::temporal_filter temporalFilter; 147 | rs2::hole_filling_filter holeFillingFilter; 148 | 149 | ofEventListeners eventListeners; 150 | }; 151 | } --------------------------------------------------------------------------------