├── librealsense.xc ├── .gitignore ├── cpp-capture.xcodeproj │ ├── project.xcworkspace │ │ └── contents.xcworkspacedata │ └── xcshareddata │ │ └── xcschemes │ │ └── cpp-capture.xcscheme ├── cpp-headless.xcodeproj │ ├── project.xcworkspace │ │ └── contents.xcworkspacedata │ └── xcshareddata │ │ └── xcschemes │ │ └── cpp-headless.xcscheme ├── librealsense.xcodeproj │ ├── project.xcworkspace │ │ └── contents.xcworkspacedata │ └── xcshareddata │ │ └── xcschemes │ │ └── librealsense.xcscheme ├── c-tutorial-1-depth.xcodeproj │ ├── project.xcworkspace │ │ └── contents.xcworkspacedata │ └── xcshareddata │ │ └── xcschemes │ │ └── c-tutorial-1-depth.xcscheme ├── cpp-alignimages.xcodeproj │ ├── project.xcworkspace │ │ └── contents.xcworkspacedata │ └── xcshareddata │ │ └── xcschemes │ │ └── cpp-alignimages.xcscheme ├── unit-tests-offline.xcodeproj │ ├── project.xcworkspace │ │ └── contents.xcworkspacedata │ └── xcshareddata │ │ └── xcschemes │ │ └── unit-tests-offline.xcscheme ├── c-tutorial-2-streams.xcodeproj │ ├── project.xcworkspace │ │ └── contents.xcworkspacedata │ └── xcshareddata │ │ └── xcschemes │ │ └── c-tutorial-2-streams.xcscheme ├── c-tutorial-3-pointcloud.xcodeproj │ ├── project.xcworkspace │ │ └── contents.xcworkspacedata │ └── xcshareddata │ │ └── xcschemes │ │ └── c-tutorial-3-pointcloud.xcscheme ├── cpp-enumerate-devices.xcodeproj │ ├── project.xcworkspace │ │ └── contents.xcworkspacedata │ └── xcshareddata │ │ └── xcschemes │ │ └── cpp-enumerate-devices.xcscheme ├── cpp-tutorial-1-depth.xcodeproj │ ├── project.xcworkspace │ │ └── contents.xcworkspacedata │ └── xcshareddata │ │ └── xcschemes │ │ └── cpp-tutorial-1-depth.xcscheme ├── cpp-tutorial-2-streams.xcodeproj │ ├── project.xcworkspace │ │ └── contents.xcworkspacedata │ └── xcshareddata │ │ └── xcschemes │ │ └── cpp-tutorial-2-streams.xcscheme ├── unit-tests-live-f200.xcodeproj │ ├── project.xcworkspace │ │ └── contents.xcworkspacedata │ └── xcshareddata │ │ └── xcschemes │ │ └── unit-tests-live-f200.xcscheme ├── unit-tests-live-r200.xcodeproj │ ├── project.xcworkspace │ │ └── contents.xcworkspacedata │ └── xcshareddata │ │ └── xcschemes │ │ └── unit-tests-live-r200.xcscheme ├── unit-tests-live-sr300.xcodeproj │ ├── project.xcworkspace │ │ └── contents.xcworkspacedata │ └── xcshareddata │ │ └── xcschemes │ │ └── unit-tests-live-sr300.xcscheme ├── cpp-tutorial-3-pointcloud.xcodeproj │ ├── project.xcworkspace │ │ └── contents.xcworkspacedata │ └── xcshareddata │ │ └── xcschemes │ │ └── cpp-tutorial-3-pointcloud.xcscheme ├── no-tests.xcworkspace │ └── contents.xcworkspacedata ├── librealsense.xcworkspace │ └── contents.xcworkspacedata ├── cpp-multicam.xcodeproj │ └── xcshareddata │ │ └── xcschemes │ │ └── cpp-multicam.xcscheme ├── cpp-config-ui.xcodeproj │ └── xcshareddata │ │ └── xcschemes │ │ └── cpp-config-ui.xcscheme └── cpp-pointcloud.xcodeproj │ └── xcshareddata │ └── xcschemes │ └── cpp-pointcloud.xcscheme ├── librealsense.vc12 ├── cpp-headless │ ├── .gitignore │ └── cpp-headless.vcxproj.filters ├── .gitignore ├── cpp-capture │ ├── packages.config │ └── cpp-capture.vcxproj.filters ├── cpp-restart │ ├── packages.config │ └── cpp-restart.vcxproj.filters ├── cpp-alignimages │ ├── packages.config │ └── cpp-alignimages.vcxproj.filters ├── cpp-config-ui │ ├── packages.config │ └── cpp-config-ui.vcxproj.filters ├── cpp-multicam │ ├── packages.config │ └── cpp-multicam.vcxproj.filters ├── cpp-pointcloud │ ├── packages.config │ └── cpp-pointcloud.vcxproj.filters ├── c-tutorial-2-streams │ ├── packages.config │ └── c-tutorial-2-streams.vcxproj.filters ├── c-tutorial-3-pointcloud │ ├── packages.config │ └── c-tutorial-3-pointcloud.vcxproj.filters ├── cpp-tutorial-2-streams │ ├── packages.config │ └── cpp-tutorial-2-streams.vcxproj.filters ├── cpp-tutorial-3-pointcloud │ ├── packages.config │ └── cpp-tutorial-3-pointcloud.vcxproj.filters ├── c-tutorial-1-depth │ └── c-tutorial-1-depth.vcxproj.filters ├── cpp-enumerate-devices │ └── cpp-enumerate-devices.vcxproj.filters ├── cpp-tutorial-1-depth │ └── cpp-tutorial-1-depth.vcxproj.filters ├── unit-tests-offline │ └── unit-tests-offline.vcxproj.filters ├── unit-tests-live-f200 │ └── unit-tests-live-f200.vcxproj.filters ├── unit-tests-live-r200 │ └── unit-tests-live-ds4.vcxproj.filters ├── unit-tests-live-sr300 │ └── unit-tests-live-sr300.vcxproj.filters ├── realsense │ ├── realsense.def │ └── realsense.vcxproj.filters ├── sample.props └── librealsense.props ├── config ├── uvc.conf ├── usb-R200-in_udev ├── 99-realsense-libusb.rules └── usb-R200-in ├── doc ├── f200_module.png ├── r200_module.png ├── dev_log.md ├── camera_specs.md └── installation.md ├── AUTHORS ├── librealsense.qtcreator ├── include.pri ├── v4l2-test.pro ├── cpp-tutorial-1-depth.pro ├── c-tutorial-1-depth.pro ├── cpp-tutorial-2-streams.pro ├── c-tutorial-2-streams.pro ├── c-tutorial-3-pointcloud.pro ├── cpp-multicam.pro ├── cpp-restart.pro ├── cpp-tutorial-3-pointcloud.pro ├── cpp-capture.pro ├── cpp-config-ui.pro ├── cpp-headless.pro ├── cpp-alignimages.pro ├── unit-tests-offline.pro ├── cpp-enumerate-devices.pro ├── cpp-pointcloud.pro ├── realsense.pro ├── unit-tests-live-f200.pro ├── unit-tests-live-r200.pro ├── unit-tests-live-sr300.pro ├── all.pro └── uvc.pro ├── src ├── verify.c ├── libuvc │ ├── libuvc_config.h │ ├── frame.c │ ├── utlist.h │ ├── init.c │ └── ctrl.c ├── context.h ├── uvc.cpp ├── r200.h ├── context.cpp ├── f200.h ├── log.cpp ├── image.h ├── uvc.h └── device.h ├── appveyor.yml ├── scripts ├── untabify.sh ├── install-r200-udev-fix.sh ├── install_qt.sh ├── install_glfw3.sh ├── install_dependencies-4.4.sh ├── patch-uvcvideo-3.19.sh ├── patch-uvcvideo-4.4.sh └── realsense-camera-formats.patch ├── .gitignore ├── .travis.yml ├── Makefile └── examples ├── cpp-alignimages.cpp ├── cpp-tutorial-1-depth.cpp ├── cpp-multicam.cpp ├── cpp-enumerate-devices.cpp ├── c-tutorial-1-depth.c ├── cpp-headless.cpp ├── cpp-tutorial-2-streams.cpp ├── c-tutorial-2-streams.c └── cpp-capture.cpp /librealsense.xc/.gitignore: -------------------------------------------------------------------------------- 1 | *.png -------------------------------------------------------------------------------- /librealsense.vc12/cpp-headless/.gitignore: -------------------------------------------------------------------------------- 1 | *.png -------------------------------------------------------------------------------- /config/uvc.conf: -------------------------------------------------------------------------------- 1 | blacklist uvcvideo 2 | blacklist snd-usb-audio 3 | -------------------------------------------------------------------------------- /config/usb-R200-in_udev: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | /usr/local/bin/usb-R200-in & -------------------------------------------------------------------------------- /doc/f200_module.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/royshil/librealsense/master/doc/f200_module.png -------------------------------------------------------------------------------- /doc/r200_module.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/royshil/librealsense/master/doc/r200_module.png -------------------------------------------------------------------------------- /librealsense.vc12/.gitignore: -------------------------------------------------------------------------------- 1 | ipch/ 2 | packages/ 3 | */obj/ 4 | *.opensdf 5 | *.sdf 6 | *.suo 7 | *.user -------------------------------------------------------------------------------- /AUTHORS: -------------------------------------------------------------------------------- 1 | Sterling Orsten, sterling.g.orsten@intel.com 2 | Dimitri Diakopoulos, dimitri.diakopoulos@intel.com -------------------------------------------------------------------------------- /librealsense.qtcreator/include.pri: -------------------------------------------------------------------------------- 1 | release: DESTDIR = $$PWD/../bin/release 2 | debug: DESTDIR = $$PWD/../bin/debug 3 | 4 | OBJECTS_DIR = $$DESTDIR/obj 5 | MOC_DIR = $$DESTDIR/.moc 6 | RCC_DIR = $$DESTDIR/.qrc 7 | UI_DIR = $$DESTDIR/.ui 8 | -------------------------------------------------------------------------------- /librealsense.xc/cpp-capture.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /librealsense.xc/cpp-headless.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /librealsense.xc/librealsense.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /librealsense.xc/c-tutorial-1-depth.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /librealsense.xc/cpp-alignimages.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /librealsense.xc/unit-tests-offline.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /librealsense.xc/c-tutorial-2-streams.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /librealsense.xc/c-tutorial-3-pointcloud.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /librealsense.xc/cpp-enumerate-devices.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /librealsense.xc/cpp-tutorial-1-depth.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /librealsense.xc/cpp-tutorial-2-streams.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /librealsense.xc/unit-tests-live-f200.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /librealsense.xc/unit-tests-live-r200.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /librealsense.xc/unit-tests-live-sr300.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /librealsense.vc12/cpp-capture/packages.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /librealsense.vc12/cpp-restart/packages.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /librealsense.xc/cpp-tutorial-3-pointcloud.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /librealsense.vc12/cpp-alignimages/packages.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /librealsense.vc12/cpp-config-ui/packages.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /librealsense.vc12/cpp-multicam/packages.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /librealsense.vc12/cpp-pointcloud/packages.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /librealsense.vc12/c-tutorial-2-streams/packages.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /src/verify.c: -------------------------------------------------------------------------------- 1 | /* License: Apache 2.0. See LICENSE file in root directory. 2 | Copyright(c) 2015 Intel Corporation. All Rights Reserved. */ 3 | 4 | /* This file simply verifies that rs.h can be correctly included by a C compiler */ 5 | #include 6 | -------------------------------------------------------------------------------- /librealsense.vc12/c-tutorial-3-pointcloud/packages.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /librealsense.vc12/cpp-tutorial-2-streams/packages.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /librealsense.vc12/cpp-tutorial-3-pointcloud/packages.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /librealsense.vc12/cpp-headless/cpp-headless.vcxproj.filters: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /librealsense.vc12/c-tutorial-1-depth/c-tutorial-1-depth.vcxproj.filters: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /librealsense.vc12/cpp-enumerate-devices/cpp-enumerate-devices.vcxproj.filters: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /librealsense.vc12/cpp-tutorial-1-depth/cpp-tutorial-1-depth.vcxproj.filters: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /appveyor.yml: -------------------------------------------------------------------------------- 1 | # appveyor file 2 | # http://www.appveyor.com/docs/appveyor-yml 3 | 4 | os: Visual Studio 2013 5 | 6 | before_build: 7 | - cmd: nuget restore librealsense.vc12/realsense.sln -Verbosity detailed 8 | 9 | build: 10 | verbosity: minimal 11 | project: librealsense.vc12/realsense.sln 12 | 13 | cache: 14 | - librealsense.vc12/packages -------------------------------------------------------------------------------- /librealsense.qtcreator/v4l2-test.pro: -------------------------------------------------------------------------------- 1 | include(include.pri) 2 | 3 | TEMPLATE = app 4 | CONFIG += console 5 | CONFIG -= app_bundle 6 | CONFIG -= qt 7 | QMAKE_CXXFLAGS += -std=c++11 8 | PKGCONFIG += glfw3 gl libusb-1.0 9 | CONFIG += link_pkgconfig 10 | INCLUDEPATH += ../include 11 | LIBS += -pthread 12 | 13 | SOURCES += ../src/hack/v4l2-test.cpp 14 | -------------------------------------------------------------------------------- /librealsense.vc12/cpp-capture/cpp-capture.vcxproj.filters: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /librealsense.vc12/cpp-restart/cpp-restart.vcxproj.filters: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /librealsense.vc12/cpp-multicam/cpp-multicam.vcxproj.filters: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /librealsense.vc12/cpp-config-ui/cpp-config-ui.vcxproj.filters: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /librealsense.vc12/cpp-pointcloud/cpp-pointcloud.vcxproj.filters: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /librealsense.vc12/cpp-alignimages/cpp-alignimages.vcxproj.filters: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /librealsense.vc12/c-tutorial-2-streams/c-tutorial-2-streams.vcxproj.filters: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /librealsense.vc12/c-tutorial-3-pointcloud/c-tutorial-3-pointcloud.vcxproj.filters: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /librealsense.vc12/cpp-tutorial-2-streams/cpp-tutorial-2-streams.vcxproj.filters: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /scripts/untabify.sh: -------------------------------------------------------------------------------- 1 | find . -name '*.c' ! -type d -exec bash -c 'expand -t 4 "$0" > /tmp/e && mv /tmp/e "$0"' {} \; 2 | find . -name '*.cpp' ! -type d -exec bash -c 'expand -t 4 "$0" > /tmp/e && mv /tmp/e "$0"' {} \; 3 | find . -name '*.h' ! -type d -exec bash -c 'expand -t 4 "$0" > /tmp/e && mv /tmp/e "$0"' {} \; 4 | find . -name '*.hpp' ! -type d -exec bash -c 'expand -t 4 "$0" > /tmp/e && mv /tmp/e "$0"' {} \; 5 | -------------------------------------------------------------------------------- /librealsense.vc12/cpp-tutorial-3-pointcloud/cpp-tutorial-3-pointcloud.vcxproj.filters: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /librealsense.vc12/unit-tests-offline/unit-tests-offline.vcxproj.filters: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /scripts/install-r200-udev-fix.sh: -------------------------------------------------------------------------------- 1 | echo "Installing R200 connectivity workaround. Unplug any R200 connected to your machine." 2 | echo "Press Enter to continue..." 3 | 4 | read p 5 | 6 | echo "Copying scripts" 7 | sudo cp ../config/usb-R200-in /usr/local/bin/ 8 | sudo cp ../config/usb-R200-in_udev /usr/local/bin/ 9 | 10 | sudo chmod 755 /usr/local/bin/usb-R200-in 11 | sudo chmod 755 /usr/local/bin/usb-R200-in_udev 12 | 13 | echo "Done." 14 | -------------------------------------------------------------------------------- /librealsense.qtcreator/cpp-tutorial-1-depth.pro: -------------------------------------------------------------------------------- 1 | include(include.pri) 2 | 3 | TEMPLATE = app 4 | CONFIG += console 5 | CONFIG -= app_bundle 6 | CONFIG -= qt 7 | QMAKE_CXXFLAGS += -std=c++11 8 | PKGCONFIG += glfw3 gl libusb-1.0 9 | CONFIG += link_pkgconfig 10 | INCLUDEPATH += ../include 11 | LIBS += -pthread 12 | 13 | SOURCES += ../examples/cpp-tutorial-1-depth.cpp 14 | 15 | LIBS += -L$$DESTDIR/ -lrealsense 16 | 17 | PRE_TARGETDEPS += $$DESTDIR/librealsense.a 18 | 19 | -------------------------------------------------------------------------------- /librealsense.qtcreator/c-tutorial-1-depth.pro: -------------------------------------------------------------------------------- 1 | include(include.pri) 2 | 3 | TEMPLATE = app 4 | CONFIG += console 5 | CONFIG -= app_bundle 6 | CONFIG -= qt 7 | QMAKE_CXXFLAGS += -std=c++11 -fpermissive 8 | PKGCONFIG += glfw3 gl glu libusb-1.0 9 | CONFIG += link_pkgconfig 10 | INCLUDEPATH += ../include 11 | LIBS += -pthread 12 | 13 | SOURCES += ../examples/c-tutorial-1-depth.c 14 | 15 | LIBS += -L$$DESTDIR/ -lrealsense 16 | 17 | PRE_TARGETDEPS += $$DESTDIR/librealsense.a 18 | -------------------------------------------------------------------------------- /librealsense.qtcreator/cpp-tutorial-2-streams.pro: -------------------------------------------------------------------------------- 1 | include(include.pri) 2 | 3 | TEMPLATE = app 4 | CONFIG += console 5 | CONFIG -= app_bundle 6 | CONFIG -= qt 7 | QMAKE_CXXFLAGS += -std=c++11 8 | PKGCONFIG += glfw3 gl libusb-1.0 9 | CONFIG += link_pkgconfig 10 | INCLUDEPATH += ../include 11 | LIBS += -pthread 12 | 13 | SOURCES += ../examples/cpp-tutorial-2-streams.cpp 14 | 15 | LIBS += -L$$DESTDIR/ -lrealsense 16 | 17 | PRE_TARGETDEPS += $$DESTDIR/librealsense.a 18 | 19 | -------------------------------------------------------------------------------- /librealsense.qtcreator/c-tutorial-2-streams.pro: -------------------------------------------------------------------------------- 1 | include(include.pri) 2 | 3 | TEMPLATE = app 4 | CONFIG += console 5 | CONFIG -= app_bundle 6 | CONFIG -= qt 7 | QMAKE_CXXFLAGS += -std=c++11 -fpermissive 8 | PKGCONFIG += glfw3 gl glu libusb-1.0 9 | CONFIG += link_pkgconfig 10 | INCLUDEPATH += ../include 11 | LIBS += -pthread 12 | 13 | SOURCES += ../examples/c-tutorial-2-streams.c 14 | 15 | LIBS += -L$$DESTDIR/ -lrealsense 16 | 17 | PRE_TARGETDEPS += $$DESTDIR/librealsense.a 18 | -------------------------------------------------------------------------------- /librealsense.qtcreator/c-tutorial-3-pointcloud.pro: -------------------------------------------------------------------------------- 1 | include(include.pri) 2 | 3 | TEMPLATE = app 4 | CONFIG += console 5 | CONFIG -= app_bundle 6 | CONFIG -= qt 7 | QMAKE_CXXFLAGS += -std=c++11 -fpermissive 8 | PKGCONFIG += glfw3 gl glu libusb-1.0 9 | CONFIG += link_pkgconfig 10 | INCLUDEPATH += ../include 11 | LIBS += -pthread 12 | 13 | SOURCES += ../examples/c-tutorial-3-pointcloud.c 14 | 15 | LIBS += -L$$DESTDIR/ -lrealsense 16 | 17 | PRE_TARGETDEPS += $$DESTDIR/librealsense.a 18 | -------------------------------------------------------------------------------- /librealsense.qtcreator/cpp-multicam.pro: -------------------------------------------------------------------------------- 1 | include(include.pri) 2 | 3 | TEMPLATE = app 4 | CONFIG += console 5 | CONFIG -= app_bundle 6 | CONFIG -= qt 7 | QMAKE_CXXFLAGS += -std=c++11 8 | PKGCONFIG += glfw3 gl libusb-1.0 9 | CONFIG += link_pkgconfig 10 | INCLUDEPATH += ../include 11 | LIBS += -pthread 12 | 13 | SOURCES += ../examples/cpp-multicam.cpp 14 | HEADERS += ../examples/example.hpp 15 | 16 | LIBS += -L$$DESTDIR/ -lrealsense 17 | 18 | PRE_TARGETDEPS += $$DESTDIR/librealsense.a 19 | -------------------------------------------------------------------------------- /librealsense.qtcreator/cpp-restart.pro: -------------------------------------------------------------------------------- 1 | include(include.pri) 2 | 3 | TEMPLATE = app 4 | CONFIG += console 5 | CONFIG -= app_bundle 6 | CONFIG -= qt 7 | QMAKE_CXXFLAGS += -std=c++11 8 | PKGCONFIG += glfw3 gl libusb-1.0 9 | CONFIG += link_pkgconfig 10 | INCLUDEPATH += ../include 11 | LIBS += -pthread 12 | 13 | SOURCES += ../examples/cpp-restart.cpp 14 | HEADERS += ../examples/example.hpp 15 | 16 | LIBS += -L$$DESTDIR/ -lrealsense 17 | 18 | PRE_TARGETDEPS += $$DESTDIR/librealsense.a 19 | -------------------------------------------------------------------------------- /librealsense.qtcreator/cpp-tutorial-3-pointcloud.pro: -------------------------------------------------------------------------------- 1 | include(include.pri) 2 | 3 | TEMPLATE = app 4 | CONFIG += console 5 | CONFIG -= app_bundle 6 | CONFIG -= qt 7 | QMAKE_CXXFLAGS += -std=c++11 8 | PKGCONFIG += glfw3 gl glu libusb-1.0 9 | CONFIG += link_pkgconfig 10 | INCLUDEPATH += ../include 11 | LIBS += -pthread 12 | 13 | SOURCES += ../examples/cpp-tutorial-3-pointcloud.cpp 14 | 15 | LIBS += -L$$DESTDIR/ -lrealsense 16 | 17 | PRE_TARGETDEPS += $$DESTDIR/librealsense.a 18 | 19 | -------------------------------------------------------------------------------- /librealsense.qtcreator/cpp-capture.pro: -------------------------------------------------------------------------------- 1 | include(include.pri) 2 | 3 | TEMPLATE = app 4 | CONFIG += console 5 | CONFIG -= app_bundle 6 | CONFIG -= qt 7 | QMAKE_CXXFLAGS += -std=c++11 8 | PKGCONFIG += glfw3 gl libusb-1.0 9 | CONFIG += link_pkgconfig 10 | INCLUDEPATH += ../include 11 | LIBS += -pthread 12 | 13 | SOURCES += ../examples/cpp-capture.cpp 14 | HEADERS += ../examples/example.hpp 15 | 16 | LIBS += -L$$DESTDIR/ -lrealsense 17 | 18 | PRE_TARGETDEPS += $$DESTDIR/librealsense.a 19 | 20 | -------------------------------------------------------------------------------- /config/99-realsense-libusb.rules: -------------------------------------------------------------------------------- 1 | # RealSense UVC cameras (R200, F200, SR300) 2 | SUBSYSTEMS=="usb", ENV{DEVTYPE}=="usb_device", ATTRS{idVendor}=="8086", ATTRS{idProduct}=="0a80", MODE="0666", GROUP="plugdev", RUN+="/usr/local/bin/usb-R200-in_udev" 3 | SUBSYSTEMS=="usb", ENV{DEVTYPE}=="usb_device", ATTRS{idVendor}=="8086", ATTRS{idProduct}=="0a66", MODE="0666", GROUP="plugdev" 4 | SUBSYSTEMS=="usb", ENV{DEVTYPE}=="usb_device", ATTRS{idVendor}=="8086", ATTRS{idProduct}=="0aa5", MODE="0666", GROUP="plugdev" 5 | -------------------------------------------------------------------------------- /librealsense.qtcreator/cpp-config-ui.pro: -------------------------------------------------------------------------------- 1 | include(include.pri) 2 | 3 | TEMPLATE = app 4 | CONFIG += console 5 | CONFIG -= app_bundle 6 | CONFIG -= qt 7 | QMAKE_CXXFLAGS += -std=c++11 8 | PKGCONFIG += glfw3 gl libusb-1.0 9 | CONFIG += link_pkgconfig 10 | INCLUDEPATH += ../include 11 | LIBS += -pthread 12 | 13 | SOURCES += ../examples/cpp-config-ui.cpp 14 | HEADERS += ../examples/example.hpp 15 | 16 | LIBS += -L$$DESTDIR/ -lrealsense 17 | 18 | PRE_TARGETDEPS += $$DESTDIR/librealsense.a 19 | 20 | -------------------------------------------------------------------------------- /librealsense.qtcreator/cpp-headless.pro: -------------------------------------------------------------------------------- 1 | include(include.pri) 2 | 3 | TEMPLATE = app 4 | CONFIG += console 5 | CONFIG -= app_bundle 6 | CONFIG -= qt 7 | QMAKE_CXXFLAGS += -std=c++11 8 | PKGCONFIG += glfw3 gl libusb-1.0 9 | CONFIG += link_pkgconfig 10 | INCLUDEPATH += ../include 11 | LIBS += -pthread 12 | 13 | SOURCES += ../examples/cpp-headless.cpp 14 | HEADERS += ../examples/example.hpp 15 | 16 | LIBS += -L$$DESTDIR/ -lrealsense 17 | 18 | PRE_TARGETDEPS += $$DESTDIR/librealsense.a 19 | 20 | -------------------------------------------------------------------------------- /librealsense.qtcreator/cpp-alignimages.pro: -------------------------------------------------------------------------------- 1 | include(include.pri) 2 | 3 | TEMPLATE = app 4 | CONFIG += console 5 | CONFIG -= app_bundle 6 | CONFIG -= qt 7 | QMAKE_CXXFLAGS += -std=c++11 8 | PKGCONFIG += glfw3 gl libusb-1.0 9 | CONFIG += link_pkgconfig 10 | INCLUDEPATH += ../include 11 | LIBS += -pthread 12 | 13 | SOURCES += ../examples/cpp-alignimages.cpp 14 | HEADERS += ../examples/example.hpp 15 | 16 | LIBS += -L$$DESTDIR/ -lrealsense 17 | 18 | PRE_TARGETDEPS += $$DESTDIR/librealsense.a 19 | 20 | -------------------------------------------------------------------------------- /librealsense.qtcreator/unit-tests-offline.pro: -------------------------------------------------------------------------------- 1 | include(include.pri) 2 | 3 | TEMPLATE = app 4 | CONFIG += console 5 | CONFIG -= app_bundle 6 | CONFIG -= qt 7 | QMAKE_CXXFLAGS += -std=c++11 8 | PKGCONFIG += libusb-1.0 9 | CONFIG += link_pkgconfig 10 | INCLUDEPATH += ../include 11 | LIBS += -pthread 12 | 13 | SOURCES += ../unit-tests/unit-tests-offline.cpp 14 | SOURCES += ../unit-tests/unit-tests-common.h 15 | 16 | LIBS += -L$$DESTDIR/ -lrealsense 17 | 18 | PRE_TARGETDEPS += $$DESTDIR/librealsense.a 19 | -------------------------------------------------------------------------------- /librealsense.vc12/unit-tests-live-f200/unit-tests-live-f200.vcxproj.filters: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /librealsense.vc12/unit-tests-live-r200/unit-tests-live-ds4.vcxproj.filters: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /librealsense.vc12/unit-tests-live-sr300/unit-tests-live-sr300.vcxproj.filters: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /librealsense.qtcreator/cpp-enumerate-devices.pro: -------------------------------------------------------------------------------- 1 | include(include.pri) 2 | 3 | TEMPLATE = app 4 | CONFIG += console 5 | CONFIG -= app_bundle 6 | CONFIG -= qt 7 | QMAKE_CXXFLAGS += -std=c++11 8 | PKGCONFIG += glfw3 gl libusb-1.0 9 | CONFIG += link_pkgconfig 10 | INCLUDEPATH += ../include 11 | LIBS += -pthread 12 | 13 | SOURCES += ../examples/cpp-enumerate-devices.cpp 14 | HEADERS += ../examples/example.hpp 15 | 16 | LIBS += -L$$DESTDIR/ -lrealsense 17 | 18 | PRE_TARGETDEPS += $$DESTDIR/librealsense.a 19 | 20 | -------------------------------------------------------------------------------- /librealsense.qtcreator/cpp-pointcloud.pro: -------------------------------------------------------------------------------- 1 | include(include.pri) 2 | 3 | TEMPLATE = app 4 | CONFIG += console 5 | CONFIG -= app_bundle 6 | CONFIG -= qt 7 | QMAKE_CXXFLAGS += -std=c++11 -fpermissive 8 | PKGCONFIG += glfw3 gl glu libusb-1.0 9 | CONFIG += link_pkgconfig 10 | INCLUDEPATH += ../include 11 | LIBS += -pthread 12 | 13 | SOURCES += ../examples/cpp-pointcloud.cpp 14 | HEADERS += ../examples/example.hpp 15 | 16 | LIBS += -L$$DESTDIR/ -lrealsense 17 | 18 | PRE_TARGETDEPS += $$DESTDIR/librealsense.a 19 | -------------------------------------------------------------------------------- /scripts/install_qt.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | # Installs qt5 for Ubuntu 14.04 3 | 4 | sudo add-apt-repository "deb http://archive.ubuntu.com/ubuntu trusty universe" 5 | sudo add-apt-repository "deb http://archive.ubuntu.com/ubuntu trusty main" 6 | sudo apt-get update 7 | sudo apt-get install qdbus qmlscene qt5-default qt5-qmake qtbase5-dev-tools qtchooser qtdeclarative5-dev xbitmaps xterm libqt5svg5-dev qttools5-dev qtscript5-dev qtdeclarative5-folderlistmodel-plugin qtdeclarative5-controls-plugin -y 8 | 9 | echo "Done installing qt5!" -------------------------------------------------------------------------------- /config/usb-R200-in: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | lockdir="/dswork.lock" 3 | if mkdir "$lockdir" 4 | then 5 | # Successfully acquired lock 6 | for i in $(ls /sys/bus/usb/drivers/uvcvideo/|grep :) ; do 7 | echo $i >/sys/bus/usb/drivers/uvcvideo/unbind 8 | echo $i >/sys/bus/usb/drivers/uvcvideo/bind 9 | echo "Reseting" $i 10 | done 11 | 12 | sleep 2 13 | rm -rf "$lockdir" 14 | else 15 | # Cannot acquire lock. Aborting. 16 | exit 0 17 | fi -------------------------------------------------------------------------------- /librealsense.qtcreator/realsense.pro: -------------------------------------------------------------------------------- 1 | include(include.pri) 2 | 3 | TEMPLATE = lib 4 | CONFIG += staticlib 5 | CONFIG -= qt 6 | 7 | INCLUDEPATH += ../include 8 | 9 | CONFIG += link_pkgconfig 10 | PKGCONFIG += libusb-1.0 11 | LIBS += -pthread 12 | QMAKE_CXXFLAGS += -std=c++11 -fPIC -pedantic -mssse3 13 | QMAKE_CXXFLAGS += -Wno-missing-field-initializers -Wno-switch -Wno-multichar 14 | QMAKE_CXXFLAGS += -DRS_USE_V4L2_BACKEND 15 | 16 | HEADERS += ../include/librealsense/* ../src/*.h 17 | SOURCES += ../src/*.cpp ../src/verify.c 18 | -------------------------------------------------------------------------------- /librealsense.qtcreator/unit-tests-live-f200.pro: -------------------------------------------------------------------------------- 1 | include(include.pri) 2 | 3 | TEMPLATE = app 4 | CONFIG += console 5 | CONFIG -= app_bundle 6 | CONFIG -= qt 7 | QMAKE_CXXFLAGS += -std=c++11 8 | PKGCONFIG += libusb-1.0 9 | CONFIG += link_pkgconfig 10 | INCLUDEPATH += ../include 11 | LIBS += -pthread 12 | 13 | SOURCES += ../unit-tests/unit-tests-live-f200.cpp 14 | SOURCES += ../unit-tests/unit-tests-live.cpp 15 | SOURCES += ../unit-tests/unit-tests-common.h 16 | 17 | LIBS += -L$$DESTDIR/ -lrealsense 18 | 19 | PRE_TARGETDEPS += $$DESTDIR/librealsense.a 20 | -------------------------------------------------------------------------------- /librealsense.qtcreator/unit-tests-live-r200.pro: -------------------------------------------------------------------------------- 1 | include(include.pri) 2 | 3 | TEMPLATE = app 4 | CONFIG += console 5 | CONFIG -= app_bundle 6 | CONFIG -= qt 7 | QMAKE_CXXFLAGS += -std=c++11 8 | PKGCONFIG += libusb-1.0 9 | CONFIG += link_pkgconfig 10 | INCLUDEPATH += ../include 11 | LIBS += -pthread 12 | 13 | SOURCES += ../unit-tests/unit-tests-live-r200.cpp 14 | SOURCES += ../unit-tests/unit-tests-live.cpp 15 | SOURCES += ../unit-tests/unit-tests-common.h 16 | 17 | LIBS += -L$$DESTDIR/ -lrealsense 18 | 19 | PRE_TARGETDEPS += $$DESTDIR/librealsense.a 20 | -------------------------------------------------------------------------------- /librealsense.qtcreator/unit-tests-live-sr300.pro: -------------------------------------------------------------------------------- 1 | include(include.pri) 2 | 3 | TEMPLATE = app 4 | CONFIG += console 5 | CONFIG -= app_bundle 6 | CONFIG -= qt 7 | QMAKE_CXXFLAGS += -std=c++11 8 | PKGCONFIG += libusb-1.0 9 | CONFIG += link_pkgconfig 10 | INCLUDEPATH += ../include 11 | LIBS += -pthread 12 | 13 | SOURCES += ../unit-tests/unit-tests-live-sr300.cpp 14 | SOURCES += ../unit-tests/unit-tests-live.cpp 15 | SOURCES += ../unit-tests/unit-tests-common.h 16 | 17 | LIBS += -L$$DESTDIR/ -lrealsense 18 | 19 | PRE_TARGETDEPS += $$DESTDIR/librealsense.a 20 | -------------------------------------------------------------------------------- /scripts/install_glfw3.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | # Installs glfw3 from source as a shared lib 3 | 4 | # Make sure glfw (or any previous version) is not already installed 5 | sudo apt-get update 6 | 7 | sudo apt-get install build-essential cmake git xorg-dev libglu1-mesa-dev 8 | 9 | git clone https://github.com/glfw/glfw.git /tmp/glfw 10 | 11 | cd /tmp/glfw 12 | 13 | git checkout latest 14 | 15 | cmake . -DBUILD_SHARED_LIBS=ON 16 | 17 | make 18 | 19 | sudo make install 20 | 21 | sudo ldconfig 22 | 23 | rm -rf /tmp/glfw 24 | 25 | echo "Done installing glfw3!" -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | bin/ 2 | lib/ 3 | 4 | # XCode 5 | .DS_Store 6 | *.pbxuser 7 | !default.pbxuser 8 | *.mode1v3 9 | !default.mode1v3 10 | *.mode2v3 11 | !default.mode2v3 12 | *.perspectivev3 13 | !default.perspectivev3 14 | xcuserdata 15 | *.xccheckout 16 | *.moved-aside 17 | DerivedData 18 | *.xcuserstate 19 | librealsense.xc/build 20 | 21 | *~ 22 | *.a 23 | *.o 24 | *.pyc 25 | *.class 26 | 27 | local_ignore/ 28 | 29 | # QTCreator Project 30 | /.qmake.cache 31 | /.qmake.stash 32 | *.pro.user 33 | *.pro.user.* 34 | *.qbs.user 35 | *.qbs.user.* 36 | *.moc 37 | moc_*.cpp 38 | qrc_*.cpp 39 | ui_*.h 40 | Makefile* 41 | *-build-* 42 | librealsense-log.txt 43 | -------------------------------------------------------------------------------- /librealsense.qtcreator/all.pro: -------------------------------------------------------------------------------- 1 | TEMPLATE = subdirs 2 | 3 | SUBDIRS += \ 4 | ./realsense.pro \ 5 | ./c-tutorial-1-depth.pro \ 6 | ./c-tutorial-2-streams.pro \ 7 | ./c-tutorial-3-pointcloud.pro \ 8 | ./cpp-tutorial-1-depth.pro \ 9 | ./cpp-tutorial-2-streams.pro \ 10 | ./cpp-tutorial-3-pointcloud.pro \ 11 | ./cpp-capture.pro \ 12 | ./cpp-alignimages.pro \ 13 | ./cpp-config-ui.pro \ 14 | ./cpp-multicam.pro \ 15 | ./cpp-pointcloud.pro \ 16 | ./cpp-restart.pro \ 17 | ./cpp-enumerate-devices.pro \ 18 | ./cpp-headless.pro \ 19 | ./unit-tests-live-r200.pro \ 20 | ./unit-tests-live-f200.pro \ 21 | ./unit-tests-live-sr300.pro \ 22 | ./unit-tests-offline.pro 23 | -------------------------------------------------------------------------------- /src/libuvc/libuvc_config.h: -------------------------------------------------------------------------------- 1 | #ifndef LIBUVC_CONFIG_H 2 | #define LIBUVC_CONFIG_H 3 | 4 | #define LIBUVC_VERSION_MAJOR 0 5 | #define LIBUVC_VERSION_MINOR 0 6 | #define LIBUVC_VERSION_PATCH 5 7 | #define LIBUVC_VERSION_STR "0.0.5" 8 | #define LIBUVC_VERSION_INT \ 9 | ((0 << 16) | \ 10 | (0 << 8) | \ 11 | (5)) 12 | 13 | /** @brief Test whether libuvc is new enough 14 | * This macro evaluates true iff the current version is 15 | * at least as new as the version specified. 16 | */ 17 | #define LIBUVC_VERSION_GTE(major, minor, patch) \ 18 | (LIBUVC_VERSION_INT >= (((major) << 16) | ((minor) << 8) | (patch))) 19 | 20 | #define LIBUVC_HAS_JPEG 1 21 | 22 | #endif // !def(LIBUVC_CONFIG_H) 23 | -------------------------------------------------------------------------------- /src/context.h: -------------------------------------------------------------------------------- 1 | // License: Apache 2.0. See LICENSE file in root directory. 2 | // Copyright(c) 2015 Intel Corporation. All Rights Reserved. 3 | 4 | #pragma once 5 | #ifndef LIBREALSENSE_CONTEXT_H 6 | #define LIBREALSENSE_CONTEXT_H 7 | 8 | #include "types.h" 9 | #include "uvc.h" 10 | 11 | struct rs_context 12 | { 13 | std::shared_ptr context; 14 | std::vector> devices; 15 | 16 | rs_context(); 17 | ~rs_context(); 18 | private: 19 | rs_context(int); 20 | static bool singleton_alive; 21 | }; 22 | 23 | #endif 24 | -------------------------------------------------------------------------------- /src/uvc.cpp: -------------------------------------------------------------------------------- 1 | // License: Apache 2.0. See LICENSE file in root directory. 2 | // Copyright(c) 2015 Intel Corporation. All Rights Reserved. 3 | 4 | #if defined(RS_USE_LIBUVC_BACKEND) && !defined(RS_USE_WMF_BACKEND) && !defined(RS_USE_V4L2_BACKEND) 5 | // UVC support will be provided via libuvc / libusb backend 6 | #elif !defined(RS_USE_LIBUVC_BACKEND) && defined(RS_USE_WMF_BACKEND) && !defined(RS_USE_V4L2_BACKEND) 7 | // UVC support will be provided via Windows Media Foundation / WinUSB backend 8 | #elif !defined(RS_USE_LIBUVC_BACKEND) && !defined(RS_USE_WMF_BACKEND) && defined(RS_USE_V4L2_BACKEND) 9 | // UVC support will be provided via Video 4 Linux 2 / libusb backend 10 | #else 11 | #error No UVC backend selected. Please #define exactly one of RS_USE_LIBUVC_BACKEND, RS_USE_WMF_BACKEND, or RS_USE_V4L2_BACKEND 12 | #endif -------------------------------------------------------------------------------- /librealsense.qtcreator/uvc.pro: -------------------------------------------------------------------------------- 1 | include(LRS.pri) 2 | 3 | TEMPLATE = lib 4 | CONFIG += staticlib 5 | CONFIG -= qt 6 | 7 | INCLUDEPATH += ../third_party/libuvc/include/ 8 | SOURCES += \ 9 | ../third_party/libuvc/src/ctrl.c \ 10 | ../third_party/libuvc/src/device.c \ 11 | ../third_party/libuvc/src/diag.c \ 12 | ../third_party/libuvc/src/frame.c \ 13 | ../third_party/libuvc/src/init.c \ 14 | ../third_party/libuvc/src/misc.c \ 15 | ../third_party/libuvc/src/stream.c 16 | 17 | HEADERS += \ 18 | ../third_party/libuvc/include/libuvc/libuvc.h \ 19 | ../third_party/libuvc/include/libuvc/libuvc_config.h \ 20 | ../third_party/libuvc/include/libuvc/libuvc_internal.h \ 21 | ../third_party/libuvc/include/utlist.h 22 | 23 | CONFIG += link_pkgconfig 24 | PKGCONFIG += libusb-1.0 25 | LIBS += -pthread -ljpeg 26 | QMAKE_CFLAGS += -fPIC -DUVC_DEBUGGING 27 | -------------------------------------------------------------------------------- /scripts/install_dependencies-4.4.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | 3 | # Install gcc 4 | echo && echo Installing gcc-4.9 && echo 5 | add-apt-repository ppa:ubuntu-toolchain-r/test 6 | apt-get update 7 | apt-get install gcc-4.9 g++-4.9 8 | update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.9 60 --slave /usr/bin/g++ g++ /usr/bin/g++-4.9 9 | 10 | # Some dependency on openssl to compile UVC module 11 | apt-get install libssl-dev 12 | 13 | # Update the kernel to v4.4-wily 14 | echo && echo Upgrading kernel to v4.4-wily, will reboot upon completion... && echo 15 | # Get headers and images 16 | wget http://kernel.ubuntu.com/~kernel-ppa/mainline/v4.4-wily/linux-headers-4.4.0-040400_4.4.0-040400.201601101930_all.deb -P /tmp/ 17 | wget http://kernel.ubuntu.com/~kernel-ppa/mainline/v4.4-wily/linux-headers-4.4.0-040400-generic_4.4.0-040400.201601101930_amd64.deb -P /tmp/ 18 | wget http://kernel.ubuntu.com/~kernel-ppa/mainline/v4.4-wily/linux-image-4.4.0-040400-generic_4.4.0-040400.201601101930_amd64.deb -P /tmp/ 19 | 20 | # Install 21 | dpkg -i /tmp/*.deb 22 | 23 | # Update grub 24 | update-grub 25 | 26 | echo "Finished! In order to complete the Kernel upgrade you must reboot." -------------------------------------------------------------------------------- /librealsense.vc12/realsense/realsense.def: -------------------------------------------------------------------------------- 1 | LIBRARY 2 | 3 | EXPORTS 4 | rs_create_context 5 | rs_delete_context 6 | rs_get_device_count 7 | rs_get_device 8 | 9 | rs_get_device_name 10 | rs_get_device_serial 11 | rs_get_device_firmware_version 12 | rs_get_device_extrinsics 13 | rs_get_device_depth_scale 14 | rs_device_supports_option 15 | rs_get_stream_mode_count 16 | rs_get_stream_mode 17 | 18 | rs_enable_stream 19 | rs_enable_stream_preset 20 | rs_disable_stream 21 | rs_is_stream_enabled 22 | rs_get_stream_width 23 | rs_get_stream_height 24 | rs_get_stream_format 25 | rs_get_stream_framerate 26 | rs_get_stream_intrinsics 27 | 28 | rs_start_device 29 | rs_stop_device 30 | rs_is_device_streaming 31 | 32 | rs_get_device_option_range 33 | rs_get_device_options 34 | rs_set_device_options 35 | rs_get_device_option 36 | rs_set_device_option 37 | 38 | rs_wait_for_frames 39 | rs_get_frame_timestamp 40 | rs_get_frame_data 41 | 42 | rs_get_failed_function 43 | rs_get_failed_args 44 | rs_get_error_message 45 | rs_free_error 46 | 47 | rs_stream_to_string 48 | rs_format_to_string 49 | rs_preset_to_string 50 | rs_distortion_to_string 51 | rs_option_to_string 52 | 53 | rs_log_to_console 54 | rs_log_to_file -------------------------------------------------------------------------------- /scripts/patch-uvcvideo-3.19.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | 3 | # Set working dir 4 | DIR="$( cd "$( dirname "$0" )" && pwd )" 5 | 6 | # Dpkg dev 7 | sudo apt-get install dpkg-dev 8 | 9 | # Cleanup from possibly failed installations 10 | rm -fr ~/uvc_patch 11 | mkdir -p ~/uvc_patch 12 | cd ~/uvc_patch 13 | 14 | # Get the Linux sources and headers for this kernel version 15 | apt-get source linux-image-$(uname -r) 16 | sudo apt-get build-dep linux-image-$(uname -r) 17 | sudo apt-get install linux-headers-$(uname -r) 18 | 19 | # Enter linux dir 20 | cd linux-* 21 | 22 | KBASE=`pwd` 23 | 24 | # Apply our RealSense specific patch 25 | patch -p1 < $DIR/realsense-camera-formats.patch 26 | 27 | # Prepare and compile newly patched uvcvideo kernel object 28 | cp /boot/config-`uname -r` .config 29 | cp /usr/src/linux-headers-`uname -r`/Module.symvers . 30 | make scripts oldconfig modules_prepare 31 | cd drivers/media/usb/uvc 32 | cp $KBASE/Module.symvers . 33 | make -C $KBASE M=$KBASE/drivers/media/usb/uvc/ modules 34 | 35 | # Install newly compiled UVC video module 36 | sudo modprobe -r uvcvideo 37 | sudo rm /lib/modules/`uname -r`/kernel/drivers/media/usb/uvc/uvcvideo.ko 38 | sudo cp $KBASE/drivers/media/usb/uvc/uvcvideo.ko /lib/modules/`uname -r`/kernel/drivers/media/usb/uvc/uvcvideo.ko 39 | 40 | -------------------------------------------------------------------------------- /doc/dev_log.md: -------------------------------------------------------------------------------- 1 | # Developer Log 2 | 3 | ### October 20th, 2015 4 | 5 | 1. (R200) ALL of 640x480, 628x468, 492x372, 480x360, 332x252, 320x240 are now available for DEPTH and INFRARED streams. 6 | 2. (All) It is safe to hardcode 640x480 or 320x240 as DEPTH or INFRARED resolutions. 7 | 3. (R200) For the resolutions which are 12 pixels larger than the native depth resolution, the depth image is centered and padded. 8 | 4. (R200) For the resolutions which are 12 pixels smaller than the native infrared resolution, the IR image is cropped and centered. 9 | 5. (All) If the same resolution is requested for DEPTH and INFRARED streams, they will be pixel-for-pixel aligned and have the same intrinsics. 10 | 6. New stream mode: RECTIFIED_COLOR – Equivalent to DSAPI’s rectified third modes, removes COLOR image distortion and cancels out rotation relative to DEPTH stream. 11 | * Suitable for use as a background for augmented reality rendering, images produced via rectilinear perspective projection will overlay RECTIFIED_COLOR images correctly. 12 | 7. New stream mode: DEPTH_ALIGNED_TO_RECTIFIED_COLOR – Maps data coming from the DEPTH stream to match the intrinsic and extrinsic camera properties of the DEPTH stream. 13 | * Suitable for pre-loading the depth map for augmented reality rendering, or performing tracking that needs to be pixel accurate with the RECTIFIED_COLOR image. -------------------------------------------------------------------------------- /src/r200.h: -------------------------------------------------------------------------------- 1 | // License: Apache 2.0. See LICENSE file in root directory. 2 | // Copyright(c) 2015 Intel Corporation. All Rights Reserved. 3 | 4 | #pragma once 5 | #ifndef LIBREALSENSE_R200_H 6 | #define LIBREALSENSE_R200_H 7 | 8 | #include "device.h" 9 | 10 | namespace rsimpl 11 | { 12 | class r200_camera final : public rs_device 13 | { 14 | bool is_disparity_mode_enabled() const; 15 | void on_update_depth_units(uint32_t units); 16 | void on_update_disparity_multiplier(double multiplier); 17 | uint32_t get_lr_framerate() const; 18 | public: 19 | r200_camera(std::shared_ptr device, const static_device_info & info); 20 | ~r200_camera(); 21 | 22 | bool supports_option(rs_option option) const override; 23 | void get_option_range(rs_option option, double & min, double & max, double & step) override; 24 | void set_options(const rs_option options[], int count, const double values[]) override; 25 | void get_options(const rs_option options[], int count, double values[]) override; 26 | 27 | void on_before_start(const std::vector & selected_modes) override; 28 | int convert_timestamp(int64_t timestamp) const override; 29 | }; 30 | 31 | std::shared_ptr make_r200_device(std::shared_ptr device); 32 | } 33 | 34 | #endif 35 | -------------------------------------------------------------------------------- /src/context.cpp: -------------------------------------------------------------------------------- 1 | // License: Apache 2.0. See LICENSE file in root directory. 2 | // Copyright(c) 2015 Intel Corporation. All Rights Reserved. 3 | 4 | #include "context.h" 5 | #include "uvc.h" 6 | #include "r200.h" 7 | #include "f200.h" 8 | 9 | rs_context::rs_context() : rs_context(0) 10 | { 11 | context = rsimpl::uvc::create_context(); 12 | 13 | for(auto device : query_devices(context)) 14 | { 15 | LOG_INFO("UVC device detected with VID = 0x" << std::hex << get_vendor_id(*device) << " PID = 0x" << get_product_id(*device)); 16 | 17 | if (get_vendor_id(*device) != 32902) 18 | continue; 19 | 20 | switch(get_product_id(*device)) 21 | { 22 | case 2688: devices.push_back(rsimpl::make_r200_device(device)); break; 23 | case 2662: devices.push_back(rsimpl::make_f200_device(device)); break; 24 | case 2725: devices.push_back(rsimpl::make_sr300_device(device)); break; 25 | } 26 | } 27 | } 28 | 29 | // Enforce singleton semantics on rs_context 30 | 31 | bool rs_context::singleton_alive = false; 32 | 33 | rs_context::rs_context(int) 34 | { 35 | if(singleton_alive) throw std::runtime_error("rs_context has singleton semantics, only one may exist at a time"); 36 | singleton_alive = true; 37 | } 38 | 39 | rs_context::~rs_context() 40 | { 41 | assert(singleton_alive); 42 | singleton_alive = false; 43 | } 44 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | os: 2 | - linux 3 | - osx 4 | 5 | language: cpp 6 | 7 | sudo: required 8 | dist: trusty 9 | osx_image: xcode7 10 | 11 | before_install: 12 | - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then 13 | sudo add-apt-repository --yes ppa:ubuntu-toolchain-r/test; 14 | wget https://github.com/glfw/glfw/releases/download/3.1.1/glfw-3.1.1.zip; 15 | sudo apt-get update; 16 | fi 17 | - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then 18 | brew uninstall xctool; 19 | brew install xctool --HEAD; 20 | brew install homebrew/versions/glfw3; 21 | brew install libusb; 22 | fi 23 | 24 | install: 25 | - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then 26 | sudo apt-get install -qq build-essential xorg-dev libglu1-mesa-dev libglew-dev libglm-dev; 27 | sudo apt-get install -qq cmake; 28 | sudo apt-get install -qq libusb-1.0-0-dev ; 29 | 30 | cmake --version; 31 | 32 | unzip glfw-3.1.1.zip; 33 | cd glfw-3.1.1; 34 | sudo cmake -G "Unix Makefiles" -DBUILD_SHARED_LIBS=ON; 35 | sudo make; 36 | sudo make install; 37 | cd ..; 38 | fi 39 | script: 40 | - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then 41 | uname -a; 42 | make; 43 | fi 44 | - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then 45 | xctool -workspace librealsense.xc/librealsense.xcworkspace -scheme librealsense ONLY_ACTIVE_ARCH=NO; 46 | fi -------------------------------------------------------------------------------- /librealsense.vc12/sample.props: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | ..\..\bin\$(Platform)\ 7 | obj\$(Configuration)-$(Platform)\ 8 | 9 | 10 | $(ProjectName)-d 11 | 12 | 13 | 14 | ../../include;%(AdditionalIncludeDirectories) 15 | _CRT_SECURE_NO_WARNINGS;NOMINMAX;%(PreprocessorDefinitions) 16 | 17 | 18 | ..\..\bin\$(Platform)\ 19 | 20 | 21 | 22 | 23 | realsense.lib;%(AdditionalDependencies) 24 | 25 | 26 | 27 | 28 | realsense-d.lib;%(AdditionalDependencies) 29 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /librealsense.xc/no-tests.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 7 | 9 | 10 | 12 | 13 | 15 | 16 | 18 | 19 | 21 | 22 | 24 | 25 | 27 | 28 | 29 | 32 | 34 | 35 | 37 | 38 | 40 | 41 | 42 | 45 | 47 | 48 | 50 | 51 | 53 | 54 | 55 | 57 | 58 | 59 | -------------------------------------------------------------------------------- /src/f200.h: -------------------------------------------------------------------------------- 1 | // License: Apache 2.0. See LICENSE file in root directory. 2 | // Copyright(c) 2015 Intel Corporation. All Rights Reserved. 3 | 4 | #pragma once 5 | #ifndef LIBREALSENSE_F200_H 6 | #define LIBREALSENSE_F200_H 7 | 8 | #include "device.h" 9 | #include "f200-private.h" // todo - refactor so we don't need this here 10 | 11 | #include 12 | #include 13 | #include 14 | 15 | namespace rsimpl 16 | { 17 | namespace f200 { class IVCAMHardwareIO; } 18 | 19 | class f200_camera final : public rs_device 20 | { 21 | std::timed_mutex usbMutex; 22 | 23 | f200::CameraCalibrationParameters base_calibration; 24 | f200::IVCAMTemperatureData base_temperature_data; 25 | f200::IVCAMThermalLoopParams thermal_loop_params; 26 | f200::IVCAMAutoRangeRequest arr; 27 | 28 | float last_temperature_delta; 29 | 30 | std::thread temperatureThread; 31 | std::atomic runTemperatureThread; 32 | std::mutex temperatureMutex; 33 | std::condition_variable temperatureCv; 34 | 35 | void temperature_control_loop(); 36 | public: 37 | f200_camera(std::shared_ptr device, const static_device_info & info, const f200::CameraCalibrationParameters & calib, const f200::IVCAMTemperatureData & temp, const f200::IVCAMThermalLoopParams & params); 38 | ~f200_camera(); 39 | 40 | void on_before_start(const std::vector & selected_modes) override; 41 | int convert_timestamp(int64_t timestamp) const override { return static_cast(timestamp / 100000); } 42 | 43 | void set_options(const rs_option options[], int count, const double values[]) override; 44 | void get_options(const rs_option options[], int count, double values[]) override; 45 | }; 46 | 47 | std::shared_ptr make_f200_device(std::shared_ptr device); 48 | std::shared_ptr make_sr300_device(std::shared_ptr device); 49 | } 50 | 51 | #endif 52 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | # Specify BACKEND=V4L2 or BACKEND=LIBUVC to build a specific backend 2 | BACKEND := V4L2 3 | 4 | LIBUSB_FLAGS := `pkg-config --cflags --libs libusb-1.0` 5 | 6 | CFLAGS := -std=c11 -fPIC -pedantic -DRS_USE_$(BACKEND)_BACKEND $(LIBUSB_FLAGS) 7 | CXXFLAGS := -std=c++11 -fPIC -pedantic -mssse3 -O3 -Wno-missing-field-initializers 8 | CXXFLAGS += -Wno-switch -Wno-multichar -DRS_USE_$(BACKEND)_BACKEND $(LIBUSB_FLAGS) 9 | 10 | # Compute list of all *.o files that participate in librealsense.so 11 | OBJECTS = verify 12 | OBJECTS += $(notdir $(basename $(wildcard src/*.cpp))) 13 | OBJECTS += $(addprefix libuvc/, $(notdir $(basename $(wildcard src/libuvc/*.c)))) 14 | OBJECTS := $(addprefix obj/, $(addsuffix .o, $(OBJECTS))) 15 | 16 | # Sets of flags used by the example programs 17 | REALSENSE_FLAGS := -Iinclude -Llib -lrealsense -lm 18 | GLFW3_FLAGS := `pkg-config --cflags --libs glfw3 gl glu` 19 | 20 | # Compute a list of all example program binaries 21 | EXAMPLES := $(wildcard examples/*.c) 22 | EXAMPLES += $(wildcard examples/*.cpp) 23 | EXAMPLES := $(addprefix bin/, $(notdir $(basename $(EXAMPLES)))) 24 | 25 | # Aliases for convenience 26 | all: examples $(EXAMPLES) 27 | 28 | install: library 29 | cp lib/librealsense.so /usr/local/lib 30 | ldconfig 31 | 32 | clean: 33 | rm -rf obj 34 | rm -rf lib 35 | rm -rf bin 36 | 37 | library: lib/librealsense.so 38 | 39 | prepare: 40 | mkdir -p obj/libuvc 41 | mkdir -p lib 42 | mkdir -p bin 43 | 44 | # Rules for building the sample programs 45 | bin/c-%: examples/c-%.c library 46 | $(CC) $< $(REALSENSE_FLAGS) $(GLFW3_FLAGS) -o $@ 47 | 48 | bin/cpp-%: examples/cpp-%.cpp library 49 | $(CXX) $< -std=c++11 $(REALSENSE_FLAGS) $(GLFW3_FLAGS) -o $@ 50 | 51 | # Rules for building the library itself 52 | lib/librealsense.so: prepare $(OBJECTS) 53 | $(CXX) -std=c++11 -shared $(OBJECTS) $(LIBUSB_FLAGS) -o $@ 54 | 55 | # Rules for compiling librealsense source 56 | obj/%.o: src/%.cpp 57 | $(CXX) $< $(CXXFLAGS) -c -o $@ 58 | 59 | # Rules for compiling libuvc source 60 | obj/libuvc/%.o: src/libuvc/%.c 61 | $(CC) $< $(CFLAGS) -c -o $@ 62 | 63 | # Special rule to verify that rs.h can be included by a C89 compiler 64 | obj/verify.o: src/verify.c 65 | $(CC) $< -std=c89 -Iinclude -c -o $@ 66 | -------------------------------------------------------------------------------- /librealsense.xc/librealsense.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 7 | 9 | 10 | 12 | 13 | 15 | 16 | 18 | 19 | 21 | 22 | 24 | 25 | 27 | 28 | 29 | 32 | 34 | 35 | 37 | 38 | 40 | 41 | 42 | 45 | 47 | 48 | 50 | 51 | 53 | 54 | 55 | 58 | 60 | 61 | 63 | 64 | 66 | 67 | 69 | 70 | 71 | 73 | 74 | 75 | -------------------------------------------------------------------------------- /doc/camera_specs.md: -------------------------------------------------------------------------------- 1 | # Camera Specifications 2 | 3 | | R200 | F200 | SR300 | 4 | ---- | ---- | ---- | ----- | 5 | Indoor Range | 0.7m - 3.5m | 0.2m – 1.0m | 0.2m – 1.5m 6 | Outdoor Range | 10m | N/A | N/A 7 | Depth FoV (DxWxH) | 70x59x46 | 80x68x54 | 80x68x54 8 | Depth FPS | 30, 60, 90 | 30, 60 | 30, 60 9 | IR FPS | 30, 60, 90 | 30 - 300 | 30 - 300 10 | Depth Method | Active Stereo IR | Coded Light IR | Coded Light IR 11 | Minimum F/W | 1.0.72.04 | 2.60.0.0 | - | 12 | 13 | ## R200 Notes 14 | 15 | ![r200-module](./r200_module.png) 16 | 17 | The R200 is an active stereo camera with a 70mm baseline. Indoors, the R200 uses a class-1 laser device to project additional texture into a scene for better stereo performance. The R200 works in disparity space and has a maximum search range of 63 pixels horizontally, the result of which is a 72cm minimum depth distance at the nominal 628x468 resolution. At 320x240, the minimum depth distance reduces to 32cm. The laser texture from multiple R200 devices produces constructive interference, resulting in the ability for many R200s to be collocated in the same environment. The dual IR cameras are global shutter, while 1080p RGB imager is rolling shutter. An internal clock triggers all 3 imagers as a group and librealsense provides matched frame sets. 18 | 19 | Outdoors, the laser has no effect over ambient infrared from the sun. Furthermore, at default settings, IR sensors can become oversaturated in a fully sunlit environment so gain/exposure/fps tuning might be required. With a 70mm baseline and 640x480 IR imagers, R200 faces a classic stereo problem where depth accuracy has a strong falloff starting around 4m. 20 | 21 | ## F200 & SR300 Notes 22 | 23 | ![f200-module](./f200_module.png) 24 | 25 | The F200 is Intel's first-generation coded light camera using a high-frequency MEMS mirror to project a 2D greycode pattern. This pattern causes destructive interference with other F200 and SR300 cameras and performance is dramatically degraded when multiple cameras are pointed at the same subject. Both F200 and SR300 do not work outside due to ambient IR. For indoor usage, a specific camera control ('motion vs range tradeoff') has an ability to extend range (longer exposure) at the expense of framerate -- with aggressive settings enabled, FPS may drop as low as 2 FPS. The second generation SR300 is backwards compatible with the F200 and includes a number of on-chip improvements to increase performance and accuracy. In both generations, the IR sensor is global shutter, while the 1080p RGB imager is rolling shutter. 26 | 27 | -------------------------------------------------------------------------------- /src/log.cpp: -------------------------------------------------------------------------------- 1 | #include "types.h" 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | rs_log_severity rsimpl::minimum_log_severity = RS_LOG_SEVERITY_NONE; 9 | static rs_log_severity minimum_console_severity = RS_LOG_SEVERITY_NONE; 10 | static rs_log_severity minimum_file_severity = RS_LOG_SEVERITY_NONE; 11 | static std::ofstream log_file; 12 | 13 | void rsimpl::log(rs_log_severity severity, const std::string & message) 14 | { 15 | if(static_cast(severity) < minimum_log_severity) return; 16 | 17 | std::time_t t = std::time(nullptr); char buffer[20]; 18 | std::strftime(buffer, sizeof(buffer), "%Y-%m-%d %H:%M:%S", std::localtime(&t)); 19 | 20 | if(severity >= minimum_file_severity) 21 | { 22 | switch(severity) 23 | { 24 | case RS_LOG_SEVERITY_DEBUG: log_file << buffer << " DEBUG: " << message << std::endl; break; 25 | case RS_LOG_SEVERITY_INFO: log_file << buffer << " INFO: " << message << std::endl; break; 26 | case RS_LOG_SEVERITY_WARN: log_file << buffer << " WARN: " << message << std::endl; break; 27 | case RS_LOG_SEVERITY_ERROR: log_file << buffer << " ERROR: " << message << std::endl; break; 28 | case RS_LOG_SEVERITY_FATAL: log_file << buffer << " FATAL: " << message << std::endl; break; 29 | default: throw std::logic_error("not a valid severity for log message"); 30 | } 31 | } 32 | 33 | if(severity >= minimum_console_severity) 34 | { 35 | switch(severity) 36 | { 37 | case RS_LOG_SEVERITY_DEBUG: std::cout << "rs.debug: " << message << std::endl; break; 38 | case RS_LOG_SEVERITY_INFO: std::cout << "rs.info: " << message << std::endl; break; 39 | case RS_LOG_SEVERITY_WARN: std::cout << "rs.warn: " << message << std::endl; break; 40 | case RS_LOG_SEVERITY_ERROR: std::cout << "rs.error: " << message << std::endl; break; 41 | case RS_LOG_SEVERITY_FATAL: std::cout << "rs.fatal: " << message << std::endl; break; 42 | default: throw std::logic_error("not a valid severity for log message"); 43 | } 44 | } 45 | } 46 | 47 | void rsimpl::log_to_console(rs_log_severity min_severity) 48 | { 49 | minimum_console_severity = min_severity; 50 | rsimpl::minimum_log_severity = std::min(minimum_console_severity, minimum_file_severity); 51 | } 52 | 53 | void rsimpl::log_to_file(rs_log_severity min_severity, const char * file_path) 54 | { 55 | minimum_file_severity = min_severity; 56 | log_file.open(file_path, std::ostream::out | std::ostream::app); 57 | rsimpl::minimum_log_severity = std::min(minimum_console_severity, minimum_file_severity); 58 | } 59 | -------------------------------------------------------------------------------- /scripts/patch-uvcvideo-4.4.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | 3 | LINUX_BRANCH=$1 4 | 5 | # Obtain and apply Ubuntu patches 6 | wget http://kernel.ubuntu.com/~kernel-ppa/mainline/$LINUX_BRANCH/SOURCES 7 | 8 | THE_BRANCH=`echo $a | awk 'NF>1{print $(NF-1)}' SOURCES` 9 | 10 | # Obtain Linux Kernel sources 11 | echo "Shallow cloning Linux source repository... (~100GB, make take a while)" 12 | git clone --verbose git://git.launchpad.net/~ubuntu-kernel-test/ubuntu/+source/linux/+git/mainline-crack linux-$LINUX_BRANCH --branch $THE_BRANCH --depth 1 13 | cd linux-$LINUX_BRANCH 14 | 15 | # Produce index.html 16 | wget http://kernel.ubuntu.com/~kernel-ppa/mainline/$LINUX_BRANCH/ 17 | 18 | # Get the debian package 19 | 20 | wget http://kernel.ubuntu.com/~kernel-ppa/mainline/$LINUX_BRANCH/`grep 'linux-headers-[^"]*_all.deb' index.html -o | sed -n '1P'` 21 | 22 | wget http://kernel.ubuntu.com/~kernel-ppa/mainline/$LINUX_BRANCH/`grep 'linux-headers-[^"]*-generic[^"]*_amd64.deb' index.html -o | sed -n '1P'` 23 | 24 | # Install the package 25 | sudo dpkg -i linux-headers-*.deb 26 | 27 | RAW_TAG=`echo $THE_BRANCH | cut -c 2-` 28 | CONFIG_LOCATION=/usr/src/linux-headers-$RAW_TAG*-generic/ 29 | 30 | # Now can get symvers from /usr/src/.... 31 | 32 | PATCH_A=`echo $a | sed -n '2p' < ../SOURCES` 33 | PATCH_B=`echo $a | sed -n '3p' < ../SOURCES` 34 | PATCH_C=`echo $a | sed -n '4p' < ../SOURCES` 35 | 36 | echo "The Branch Is: " $THE_BRANCH 37 | 38 | git checkout $THE_BRANCH 39 | 40 | wget http://kernel.ubuntu.com/~kernel-ppa/mainline/$LINUX_BRANCH/$PATCH_A 41 | wget http://kernel.ubuntu.com/~kernel-ppa/mainline/$LINUX_BRANCH/$PATCH_B 42 | wget http://kernel.ubuntu.com/~kernel-ppa/mainline/$LINUX_BRANCH/$PATCH_C 43 | 44 | patch -p1 < $PATCH_A 45 | patch -p1 < $PATCH_B 46 | patch -p1 < $PATCH_C 47 | 48 | # Apply our RealSense specific patch 49 | patch -p1 < ../scripts/realsense-camera-formats.patch 50 | 51 | # Prepare to compile modules 52 | cp $CONFIG_LOCATION/.config . 53 | cp $CONFIG_LOCATION/Module.symvers . 54 | 55 | make scripts oldconfig modules_prepare 56 | 57 | # Compile UVC modules 58 | echo "Beginning compilation of uvc..." 59 | #make modules 60 | KBASE=`pwd` 61 | cd drivers/media/usb/uvc 62 | cp $KBASE/Module.symvers . 63 | make -C $KBASE M=$KBASE/drivers/media/usb/uvc/ modules 64 | 65 | # Copy to sane location 66 | sudo cp $KBASE/drivers/media/usb/uvc/uvcvideo.ko ~/$LINUX_BRANCH-uvcvideo.ko 67 | 68 | # Unload existing module if installed 69 | sudo modprobe -r uvcvideo 70 | 71 | # Delete existing module 72 | sudo rm /lib/modules/`uname -r`/kernel/drivers/media/usb/uvc/uvcvideo.ko 73 | 74 | # Copy out to module directory 75 | sudo cp ~/$LINUX_BRANCH-uvcvideo.ko /lib/modules/`uname -r`/kernel/drivers/media/usb/uvc/uvcvideo.ko 76 | -------------------------------------------------------------------------------- /examples/cpp-alignimages.cpp: -------------------------------------------------------------------------------- 1 | // License: Apache 2.0. See LICENSE file in root directory. 2 | // Copyright(c) 2015 Intel Corporation. All Rights Reserved. 3 | 4 | #include 5 | #include "example.hpp" 6 | 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | texture_buffer buffers[6]; 13 | 14 | #pragma pack(push, 1) 15 | struct rgb_pixel 16 | { 17 | uint8_t r,g,b; 18 | }; 19 | #pragma pack(pop) 20 | 21 | int main(int argc, char * argv[]) try 22 | { 23 | rs::log_to_console(rs::log_severity::warn); 24 | //rs::log_to_file(rs::log_severity::debug, "librealsense.log"); 25 | 26 | rs::context ctx; 27 | if(ctx.get_device_count() == 0) throw std::runtime_error("No device detected. Is it plugged in?"); 28 | rs::device & dev = *ctx.get_device(0); 29 | 30 | dev.enable_stream(rs::stream::depth, rs::preset::best_quality); 31 | dev.enable_stream(rs::stream::color, rs::preset::best_quality); 32 | try { dev.enable_stream(rs::stream::infrared2, rs::preset::best_quality); } catch(...) {} 33 | dev.start(); 34 | 35 | // Open a GLFW window 36 | glfwInit(); 37 | std::ostringstream ss; ss << "CPP Image Alignment Example (" << dev.get_name() << ")"; 38 | GLFWwindow * win = glfwCreateWindow(dev.is_stream_enabled(rs::stream::infrared2) ? 1920 : 1280, 960, ss.str().c_str(), 0, 0); 39 | glfwMakeContextCurrent(win); 40 | 41 | while (!glfwWindowShouldClose(win)) 42 | { 43 | // Wait for new images 44 | glfwPollEvents(); 45 | dev.wait_for_frames(); 46 | 47 | // Clear the framebuffer 48 | int w,h; 49 | glfwGetFramebufferSize(win, &w, &h); 50 | glViewport(0, 0, w, h); 51 | glClear(GL_COLOR_BUFFER_BIT); 52 | 53 | // Draw the images 54 | glPushMatrix(); 55 | glfwGetWindowSize(win, &w, &h); 56 | glOrtho(0, w, h, 0, -1, +1); 57 | int s = w / (dev.is_stream_enabled(rs::stream::infrared2) ? 3 : 2); 58 | buffers[0].show(dev, rs::stream::color, 0, 0, s, h-h/2); 59 | buffers[1].show(dev, rs::stream::color_aligned_to_depth, s, 0, s, h-h/2); 60 | buffers[2].show(dev, rs::stream::depth_aligned_to_color, 0, h/2, s, h-h/2); 61 | buffers[3].show(dev, rs::stream::depth, s, h/2, s, h-h/2); 62 | if(dev.is_stream_enabled(rs::stream::infrared2)) 63 | { 64 | buffers[4].show(dev, rs::stream::infrared2_aligned_to_depth, 2*s, 0, s, h-h/2); 65 | buffers[5].show(dev, rs::stream::depth_aligned_to_infrared2, 2*s, h/2, s, h-h/2); 66 | } 67 | glPopMatrix(); 68 | glfwSwapBuffers(win); 69 | } 70 | 71 | glfwDestroyWindow(win); 72 | glfwTerminate(); 73 | return EXIT_SUCCESS; 74 | } 75 | catch(const rs::error & e) 76 | { 77 | std::cerr << "RealSense error calling " << e.get_failed_function() << "(" << e.get_failed_args() << "):\n " << e.what() << std::endl; 78 | return EXIT_FAILURE; 79 | } 80 | catch(const std::exception & e) 81 | { 82 | std::cerr << e.what() << std::endl; 83 | return EXIT_FAILURE; 84 | } -------------------------------------------------------------------------------- /librealsense.xc/librealsense.xcodeproj/xcshareddata/xcschemes/librealsense.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 42 | 43 | 49 | 50 | 51 | 52 | 53 | 54 | 60 | 61 | 67 | 68 | 69 | 70 | 72 | 73 | 76 | 77 | 78 | -------------------------------------------------------------------------------- /examples/cpp-tutorial-1-depth.cpp: -------------------------------------------------------------------------------- 1 | // License: Apache 2.0. See LICENSE file in root directory. 2 | // Copyright(c) 2015 Intel Corporation. All Rights Reserved. 3 | 4 | ///////////////////////////////////////////////////// 5 | // librealsense tutorial #1 - Accessing depth data // 6 | ///////////////////////////////////////////////////// 7 | 8 | // First include the librealsense C++ header file 9 | #include 10 | #include 11 | 12 | int main() try 13 | { 14 | // Create a context object. This object owns the handles to all connected realsense devices. 15 | rs::context ctx; 16 | printf("There are %d connected RealSense devices.\n", ctx.get_device_count()); 17 | if(ctx.get_device_count() == 0) return EXIT_FAILURE; 18 | 19 | // This tutorial will access only a single device, but it is trivial to extend to multiple devices 20 | rs::device * dev = ctx.get_device(0); 21 | printf("\nUsing device 0, an %s\n", dev->get_name()); 22 | printf(" Serial number: %s\n", dev->get_serial()); 23 | printf(" Firmware version: %s\n", dev->get_firmware_version()); 24 | 25 | // Configure depth to run at VGA resolution at 30 frames per second 26 | dev->enable_stream(rs::stream::depth, 640, 480, rs::format::z16, 30); 27 | dev->start(); 28 | 29 | // Determine depth value corresponding to one meter 30 | const uint16_t one_meter = static_cast(1.0f / dev->get_depth_scale()); 31 | 32 | while(true) 33 | { 34 | // This call waits until a new coherent set of frames is available on a device 35 | // Calls to get_frame_data(...) and get_frame_timestamp(...) on a device will return stable values until wait_for_frames(...) is called 36 | dev->wait_for_frames(); 37 | 38 | // Retrieve depth data, which was previously configured as a 640 x 480 image of 16-bit depth values 39 | const uint16_t * depth_frame = reinterpret_cast(dev->get_frame_data(rs::stream::depth)); 40 | 41 | // Print a simple text-based representation of the image, by breaking it into 10x20 pixel regions and and approximating the coverage of pixels within one meter 42 | char buffer[(640/10+1)*(480/20)+1]; 43 | char * out = buffer; 44 | int coverage[64] = {}; 45 | for(int y=0; y<480; ++y) 46 | { 47 | for(int x=0; x<640; ++x) 48 | { 49 | int depth = *depth_frame++; 50 | if(depth > 0 && depth < one_meter) ++coverage[x/10]; 51 | } 52 | 53 | if(y%20 == 19) 54 | { 55 | for(int & c : coverage) 56 | { 57 | *out++ = " .:nhBXWW"[c/25]; 58 | c = 0; 59 | } 60 | *out++ = '\n'; 61 | } 62 | } 63 | *out++ = 0; 64 | printf("\n%s", buffer); 65 | } 66 | 67 | return EXIT_SUCCESS; 68 | } 69 | catch(const rs::error & e) 70 | { 71 | // Method calls against librealsense objects may throw exceptions of type rs::error 72 | printf("rs::error was thrown when calling %s(%s):\n", e.get_failed_function().c_str(), e.get_failed_args().c_str()); 73 | printf(" %s\n", e.what()); 74 | return EXIT_FAILURE; 75 | } 76 | -------------------------------------------------------------------------------- /examples/cpp-multicam.cpp: -------------------------------------------------------------------------------- 1 | // License: Apache 2.0. See LICENSE file in root directory. 2 | // Copyright(c) 2015 Intel Corporation. All Rights Reserved. 3 | 4 | #include 5 | #include "example.hpp" 6 | 7 | #include 8 | #include 9 | 10 | std::vector buffers; 11 | 12 | int main(int argc, char * argv[]) try 13 | { 14 | rs::log_to_console(rs::log_severity::warn); 15 | //rs::log_to_file(rs::log_severity::debug, "librealsense.log"); 16 | 17 | rs::context ctx; 18 | if(ctx.get_device_count() == 0) throw std::runtime_error("No device detected. Is it plugged in?"); 19 | 20 | // Enumerate all devices 21 | std::vector devices; 22 | for(int i=0; iget_name() << "... "; 31 | dev->enable_stream(rs::stream::depth, rs::preset::best_quality); 32 | dev->enable_stream(rs::stream::color, rs::preset::best_quality); 33 | dev->start(); 34 | std::cout << "done." << std::endl; 35 | } 36 | 37 | // Depth and color 38 | buffers.resize(ctx.get_device_count() * 2); 39 | 40 | // Open a GLFW window 41 | glfwInit(); 42 | std::ostringstream ss; ss << "CPP Multi-Camera Example"; 43 | GLFWwindow * win = glfwCreateWindow(1280, 960, ss.str().c_str(), 0, 0); 44 | glfwMakeContextCurrent(win); 45 | 46 | int windowWidth, windowHeight; 47 | glfwGetWindowSize(win, &windowWidth, &windowHeight); 48 | 49 | // Does not account for correct aspect ratios 50 | auto perTextureWidth = windowWidth / devices.size(); 51 | auto perTextureHeight = 480; 52 | 53 | while (!glfwWindowShouldClose(win)) 54 | { 55 | // Wait for new images 56 | glfwPollEvents(); 57 | for(auto dev : devices) dev->wait_for_frames(); 58 | 59 | // Draw the images 60 | int w,h; 61 | glfwGetFramebufferSize(win, &w, &h); 62 | glViewport(0, 0, w, h); 63 | glClear(GL_COLOR_BUFFER_BIT); 64 | 65 | glfwGetWindowSize(win, &w, &h); 66 | glPushMatrix(); 67 | glOrtho(0, w, h, 0, -1, +1); 68 | glPixelZoom(1, -1); 69 | int i=0, x=0; 70 | for(auto dev : devices) 71 | { 72 | const auto c = dev->get_stream_intrinsics(rs::stream::color), d = dev->get_stream_intrinsics(rs::stream::depth); 73 | buffers[i++].show(*dev, rs::stream::color, x, 0, perTextureWidth, perTextureHeight); 74 | buffers[i++].show(*dev, rs::stream::depth, x, perTextureHeight, perTextureWidth, perTextureHeight); 75 | x += perTextureWidth; 76 | } 77 | 78 | glPopMatrix(); 79 | glfwSwapBuffers(win); 80 | } 81 | 82 | glfwDestroyWindow(win); 83 | glfwTerminate(); 84 | return EXIT_SUCCESS; 85 | } 86 | catch(const rs::error & e) 87 | { 88 | std::cerr << "RealSense error calling " << e.get_failed_function() << "(" << e.get_failed_args() << "):\n " << e.what() << std::endl; 89 | return EXIT_FAILURE; 90 | } 91 | catch(const std::exception & e) 92 | { 93 | std::cerr << e.what() << std::endl; 94 | return EXIT_FAILURE; 95 | } -------------------------------------------------------------------------------- /src/image.h: -------------------------------------------------------------------------------- 1 | // License: Apache 2.0. See LICENSE file in root directory. 2 | // Copyright(c) 2015 Intel Corporation. All Rights Reserved. 3 | 4 | #pragma once 5 | #ifndef LIBREALSENSE_IMAGE_H 6 | #define LIBREALSENSE_IMAGE_H 7 | 8 | #include "types.h" 9 | 10 | namespace rsimpl 11 | { 12 | size_t get_image_size (int width, int height, rs_format format); 13 | 14 | void deproject_z(float * points, const rs_intrinsics & z_intrin, const uint16_t * z_pixels, float z_scale); 15 | void deproject_disparity(float * points, const rs_intrinsics & disparity_intrin, const uint16_t * disparity_pixels, float disparity_scale); 16 | 17 | void align_z_to_other (byte * z_aligned_to_other, const uint16_t * z_pixels, float z_scale, const rs_intrinsics & z_intrin, 18 | const rs_extrinsics & z_to_other, const rs_intrinsics & other_intrin); 19 | void align_disparity_to_other (byte * disparity_aligned_to_other, const uint16_t * disparity_pixels, float disparity_scale, const rs_intrinsics & disparity_intrin, 20 | const rs_extrinsics & disparity_to_other, const rs_intrinsics & other_intrin); 21 | void align_other_to_z (byte * other_aligned_to_z, const uint16_t * z_pixels, float z_scale, const rs_intrinsics & z_intrin, 22 | const rs_extrinsics & z_to_other, const rs_intrinsics & other_intrin, const byte * other_pixels, rs_format other_format); 23 | void align_other_to_disparity (byte * other_aligned_to_disparity, const uint16_t * disparity_pixels, float disparity_scale, const rs_intrinsics & disparity_intrin, 24 | const rs_extrinsics & disparity_to_other, const rs_intrinsics & other_intrin, const byte * other_pixels, rs_format other_format); 25 | 26 | std::vector compute_rectification_table (const rs_intrinsics & rect_intrin, const rs_extrinsics & rect_to_unrect, const rs_intrinsics & unrect_intrin); 27 | void rectify_image (byte * rect_pixels, const std::vector & rectification_table, const byte * unrect_pixels, rs_format format); 28 | 29 | extern const native_pixel_format pf_rw10; // Four 10 bit luminance values in one 40 bit macropixel 30 | extern const native_pixel_format pf_yuy2; // Y0 U Y1 V ordered chroma subsampled macropixel 31 | extern const native_pixel_format pf_y8; // 8 bit (left) IR image 32 | extern const native_pixel_format pf_y8i; // 8 bits left IR + 8 bits right IR per pixel 33 | extern const native_pixel_format pf_y16; // 16 bit (left) IR image 34 | extern const native_pixel_format pf_y12i; // 12 bits left IR + 12 bits right IR per pixel 35 | extern const native_pixel_format pf_z16; // 16 bit Z image 36 | extern const native_pixel_format pf_invz; // 16 bit Z image 37 | extern const native_pixel_format pf_f200_invi; // 8-bit IR image 38 | extern const native_pixel_format pf_f200_inzi; // 16-bit Z + 8 bit IR per pixel 39 | extern const native_pixel_format pf_sr300_invi; // 16-bit IR image 40 | extern const native_pixel_format pf_sr300_inzi; // Planar 16-bit IR image followed by 16-bit Z image 41 | } 42 | 43 | #endif 44 | -------------------------------------------------------------------------------- /examples/cpp-enumerate-devices.cpp: -------------------------------------------------------------------------------- 1 | // License: Apache 2.0. See LICENSE file in root directory. 2 | // Copyright(c) 2015 Intel Corporation. All Rights Reserved. 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | int main() try 9 | { 10 | rs::log_to_console(rs::log_severity::warn); 11 | //rs::log_to_file(rs::log_severity::debug, "librealsense.log"); 12 | 13 | // Obtain a list of devices currently present on the system 14 | rs::context ctx; 15 | int device_count = ctx.get_device_count(); 16 | if (!device_count) printf("No device detected. Is it plugged in?\n"); 17 | 18 | for(int i = 0; i < device_count; ++i) 19 | { 20 | // Show the device name and information 21 | rs::device * dev = ctx.get_device(i); 22 | std::cout << "Device " << i << " - " << dev->get_name() << ":\n"; 23 | std::cout << " Serial number: " << dev->get_serial() << "\n"; 24 | std::cout << " Firmware version: " << dev->get_firmware_version() << "\n"; 25 | 26 | // Show which options are supported by this device 27 | std::cout << " Supported options:\n"; 28 | for(int j = 0; j < RS_OPTION_COUNT; ++j) 29 | { 30 | rs::option opt = (rs::option)j; 31 | if(dev->supports_option(opt)) 32 | { 33 | double min, max, step; 34 | dev->get_option_range(opt, min, max, step); 35 | std::cout << " " << opt << " : " << min << " .. " << max << ", " << step << "\n"; 36 | } 37 | } 38 | 39 | // Show which streams are supported by this device 40 | for(int j = 0; j < RS_STREAM_COUNT; ++j) 41 | { 42 | // Determine number of available streaming modes (zero means stream is unavailable) 43 | rs::stream strm = (rs::stream)j; 44 | int mode_count = dev->get_stream_mode_count(strm); 45 | if(mode_count == 0) continue; 46 | 47 | // Show each available mode for this stream 48 | std::cout << " Stream " << strm << " - " << mode_count << " modes:\n"; 49 | for(int k = 0; k < mode_count; ++k) 50 | { 51 | // Show width, height, format, and framerate, the settings required to enable the stream in this mode 52 | int width, height, framerate; 53 | rs::format format; 54 | dev->get_stream_mode(strm, k, width, height, format, framerate); 55 | std::cout << " " << width << "\tx " << height << "\t@ " << framerate << "Hz\t" << format; 56 | 57 | // Enable the stream in this mode so that we can retrieve its intrinsics 58 | dev->enable_stream(strm, width, height, format, framerate); 59 | rs::intrinsics intrin = dev->get_stream_intrinsics(strm); 60 | 61 | // Show horizontal and vertical field of view, in degrees 62 | std::cout << "\t" << std::setprecision(3) << intrin.hfov() << " x " << intrin.vfov() << " degrees\n"; 63 | } 64 | 65 | // Some stream mode combinations are invalid, so disable this stream before moving on to the next one 66 | dev->disable_stream(strm); 67 | } 68 | } 69 | 70 | return EXIT_SUCCESS; 71 | } 72 | catch(const rs::error & e) 73 | { 74 | std::cerr << "RealSense error calling " << e.get_failed_function() << "(" << e.get_failed_args() << "):\n " << e.what() << std::endl; 75 | return EXIT_FAILURE; 76 | } 77 | -------------------------------------------------------------------------------- /examples/c-tutorial-1-depth.c: -------------------------------------------------------------------------------- 1 | /* License: Apache 2.0. See LICENSE file in root directory. 2 | Copyright(c) 2015 Intel Corporation. All Rights Reserved. */ 3 | 4 | /*************************************************\ 5 | * librealsense tutorial #1 - Accessing depth data * 6 | \*************************************************/ 7 | 8 | /* First include the librealsense C header file */ 9 | #include 10 | #include 11 | #include 12 | #include 13 | 14 | /* Function calls to librealsense may raise errors of type rs_error */ 15 | rs_error * e = 0; 16 | void check_error() 17 | { 18 | if(e) 19 | { 20 | printf("rs_error was raised when calling %s(%s):\n", rs_get_failed_function(e), rs_get_failed_args(e)); 21 | printf(" %s\n", rs_get_error_message(e)); 22 | exit(EXIT_FAILURE); 23 | } 24 | } 25 | 26 | int main() 27 | { 28 | /* Create a context object. This object owns the handles to all connected realsense devices. */ 29 | rs_context * ctx = rs_create_context(RS_API_VERSION, &e); 30 | check_error(); 31 | printf("There are %d connected RealSense devices.\n", rs_get_device_count(ctx, &e)); 32 | check_error(); 33 | if(rs_get_device_count(ctx, &e) == 0) return EXIT_FAILURE; 34 | 35 | /* This tutorial will access only a single device, but it is trivial to extend to multiple devices */ 36 | rs_device * dev = rs_get_device(ctx, 0, &e); 37 | check_error(); 38 | printf("\nUsing device 0, an %s\n", rs_get_device_name(dev, &e)); 39 | check_error(); 40 | printf(" Serial number: %s\n", rs_get_device_serial(dev, &e)); 41 | check_error(); 42 | printf(" Firmware version: %s\n", rs_get_device_firmware_version(dev, &e)); 43 | check_error(); 44 | 45 | /* Configure depth to run at VGA resolution at 30 frames per second */ 46 | rs_enable_stream(dev, RS_STREAM_DEPTH, 640, 480, RS_FORMAT_Z16, 30, &e); 47 | check_error(); 48 | rs_start_device(dev, &e); 49 | check_error(); 50 | 51 | /* Determine depth value corresponding to one meter */ 52 | const uint16_t one_meter = (uint16_t)(1.0f / rs_get_device_depth_scale(dev, &e)); 53 | check_error(); 54 | 55 | while(1) 56 | { 57 | /* This call waits until a new coherent set of frames is available on a device 58 | Calls to get_frame_data(...) and get_frame_timestamp(...) on a device will return stable values until wait_for_frames(...) is called */ 59 | rs_wait_for_frames(dev, &e); 60 | 61 | /* Retrieve depth data, which was previously configured as a 640 x 480 image of 16-bit depth values */ 62 | const uint16_t * depth_frame = (const uint16_t *)(rs_get_frame_data(dev, RS_STREAM_DEPTH, &e)); 63 | 64 | /* Print a simple text-based representation of the image, by breaking it into 10x20 pixel regions and and approximating the coverage of pixels within one meter */ 65 | char buffer[(640/10+1)*(480/20)+1]; 66 | char * out = buffer; 67 | int coverage[64] = {0}, x,y,i; 68 | for(y=0; y<480; ++y) 69 | { 70 | for(x=0; x<640; ++x) 71 | { 72 | int depth = *depth_frame++; 73 | if(depth > 0 && depth < one_meter) ++coverage[x/10]; 74 | } 75 | 76 | if(y%20 == 19) 77 | { 78 | for(i=0; i<64; ++i) 79 | { 80 | *out++ = " .:nhBXWW"[coverage[i]/25]; 81 | coverage[i] = 0; 82 | } 83 | *out++ = '\n'; 84 | } 85 | } 86 | *out++ = 0; 87 | printf("\n%s", buffer); 88 | } 89 | 90 | return EXIT_SUCCESS; 91 | } 92 | -------------------------------------------------------------------------------- /examples/cpp-headless.cpp: -------------------------------------------------------------------------------- 1 | // License: Apache 2.0. See LICENSE file in root directory. 2 | // Copyright(c) 2015 Intel Corporation. All Rights Reserved. 3 | 4 | /////////////////// 5 | // cpp-headless // 6 | /////////////////// 7 | 8 | // This sample captures 30 frames and writes the last frame to disk. 9 | // It can be useful for debugging an embedded system with no display. 10 | 11 | #include 12 | 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | 19 | #define STB_IMAGE_WRITE_IMPLEMENTATION 20 | #include "third_party/stb_image_write.h" 21 | 22 | void normalize_depth_to_rgb(uint8_t rgb_image[640*480*3], const uint16_t depth_image[], int width, int height) 23 | { 24 | for (int i = 0; i < width * height; ++i) 25 | { 26 | if (auto d = depth_image[i]) 27 | { 28 | uint8_t v = d * 255 / std::numeric_limits::max(); 29 | rgb_image[i*3 + 0] = 255 - v; 30 | rgb_image[i*3 + 1] = 255 - v; 31 | rgb_image[i*3 + 2] = 255 - v; 32 | } 33 | else 34 | { 35 | rgb_image[i*3 + 0] = 0; 36 | rgb_image[i*3 + 1] = 0; 37 | rgb_image[i*3 + 2] = 0; 38 | } 39 | } 40 | } 41 | 42 | int main() try 43 | { 44 | rs::log_to_console(rs::log_severity::warn); 45 | //rs::log_to_file(rs::log_severity::debug, "librealsense.log"); 46 | 47 | rs::context ctx; 48 | printf("There are %d connected RealSense devices.\n", ctx.get_device_count()); 49 | if(ctx.get_device_count() == 0) return EXIT_FAILURE; 50 | 51 | rs::device * dev = ctx.get_device(0); 52 | printf("\nUsing device 0, an %s\n", dev->get_name()); 53 | printf(" Serial number: %s\n", dev->get_serial()); 54 | printf(" Firmware version: %s\n", dev->get_firmware_version()); 55 | 56 | // Configure depth to run at VGA resolution at 30 frames per second 57 | dev->enable_stream(rs::stream::depth, 640, 480, rs::format::z16, 30); 58 | dev->enable_stream(rs::stream::color, 640, 480, rs::format::rgb8, 30); 59 | dev->enable_stream(rs::stream::infrared, 640, 480, rs::format::y8, 30); 60 | 61 | const int width = 640; 62 | const int height = 480; 63 | 64 | dev->start(); 65 | 66 | // Capture 30 frames to give autoexposure, etc. a chance to settle 67 | for (int i = 0; i < 30; ++i) dev->wait_for_frames(); 68 | 69 | // Retrieve depth data, which was previously configured as a 640 x 480 image of 16-bit depth values 70 | const uint16_t * depth_frame = reinterpret_cast(dev->get_frame_data(rs::stream::depth)); 71 | const uint8_t * color_frame = reinterpret_cast(dev->get_frame_data(rs::stream::color)); 72 | const uint8_t * ir_frame = reinterpret_cast(dev->get_frame_data(rs::stream::infrared)); 73 | 74 | std::vector coloredDepth(width * height * 3); 75 | normalize_depth_to_rgb(coloredDepth.data(), depth_frame, width, height); 76 | stbi_write_png("cpp-headless-output-depth.png", width, height, 3, coloredDepth.data(), 3 * width); 77 | stbi_write_png("cpp-headless-output-rgb.png", width, height, 3, color_frame, 3 * width); 78 | stbi_write_png("cpp-headless-output-ir.png", width, height, 1, ir_frame, width); 79 | 80 | printf("wrote frames to current working directory.\n"); 81 | return EXIT_SUCCESS; 82 | } 83 | catch(const rs::error & e) 84 | { 85 | std::cerr << "RealSense error calling " << e.get_failed_function() << "(" << e.get_failed_args() << "):\n " << e.what() << std::endl; 86 | return EXIT_FAILURE; 87 | } 88 | catch(const std::exception & e) 89 | { 90 | std::cerr << e.what() << std::endl; 91 | return EXIT_FAILURE; 92 | } 93 | -------------------------------------------------------------------------------- /librealsense.xc/cpp-capture.xcodeproj/xcshareddata/xcschemes/cpp-capture.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 39 | 40 | 41 | 42 | 52 | 54 | 60 | 61 | 62 | 63 | 64 | 65 | 71 | 73 | 79 | 80 | 81 | 82 | 84 | 85 | 88 | 89 | 90 | -------------------------------------------------------------------------------- /librealsense.xc/cpp-headless.xcodeproj/xcshareddata/xcschemes/cpp-headless.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 39 | 40 | 41 | 42 | 52 | 54 | 60 | 61 | 62 | 63 | 64 | 65 | 71 | 73 | 79 | 80 | 81 | 82 | 84 | 85 | 88 | 89 | 90 | -------------------------------------------------------------------------------- /librealsense.xc/cpp-multicam.xcodeproj/xcshareddata/xcschemes/cpp-multicam.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 39 | 40 | 41 | 42 | 52 | 54 | 60 | 61 | 62 | 63 | 64 | 65 | 71 | 73 | 79 | 80 | 81 | 82 | 84 | 85 | 88 | 89 | 90 | -------------------------------------------------------------------------------- /examples/cpp-tutorial-2-streams.cpp: -------------------------------------------------------------------------------- 1 | // License: Apache 2.0. See LICENSE file in root directory. 2 | // Copyright(c) 2015 Intel Corporation. All Rights Reserved. 3 | 4 | /////////////////////////////////////////////////////////// 5 | // librealsense tutorial #2 - Accessing multiple streams // 6 | /////////////////////////////////////////////////////////// 7 | 8 | // First include the librealsense C++ header file 9 | #include 10 | #include 11 | 12 | // Also include GLFW to allow for graphical display 13 | #include 14 | 15 | int main() try 16 | { 17 | // Create a context object. This object owns the handles to all connected realsense devices. 18 | rs::context ctx; 19 | printf("There are %d connected RealSense devices.\n", ctx.get_device_count()); 20 | if(ctx.get_device_count() == 0) return EXIT_FAILURE; 21 | 22 | // This tutorial will access only a single device, but it is trivial to extend to multiple devices 23 | rs::device * dev = ctx.get_device(0); 24 | printf("\nUsing device 0, an %s\n", dev->get_name()); 25 | printf(" Serial number: %s\n", dev->get_serial()); 26 | printf(" Firmware version: %s\n", dev->get_firmware_version()); 27 | 28 | // Configure all streams to run at VGA resolution at 60 frames per second 29 | dev->enable_stream(rs::stream::depth, 640, 480, rs::format::z16, 60); 30 | dev->enable_stream(rs::stream::color, 640, 480, rs::format::rgb8, 60); 31 | dev->enable_stream(rs::stream::infrared, 640, 480, rs::format::y8, 60); 32 | try { dev->enable_stream(rs::stream::infrared2, 640, 480, rs::format::y8, 60); } 33 | catch(...) { printf("Device does not provide infrared2 stream.\n"); } 34 | dev->start(); 35 | 36 | // Open a GLFW window to display our output 37 | glfwInit(); 38 | GLFWwindow * win = glfwCreateWindow(1280, 960, "librealsense tutorial #2", nullptr, nullptr); 39 | glfwMakeContextCurrent(win); 40 | while(!glfwWindowShouldClose(win)) 41 | { 42 | // Wait for new frame data 43 | glfwPollEvents(); 44 | dev->wait_for_frames(); 45 | 46 | glClear(GL_COLOR_BUFFER_BIT); 47 | glPixelZoom(1, -1); 48 | 49 | // Display depth data by linearly mapping depth between 0 and 2 meters to the red channel 50 | glRasterPos2f(-1, 1); 51 | glPixelTransferf(GL_RED_SCALE, 0xFFFF * dev->get_depth_scale() / 2.0f); 52 | glDrawPixels(640, 480, GL_RED, GL_UNSIGNED_SHORT, dev->get_frame_data(rs::stream::depth)); 53 | glPixelTransferf(GL_RED_SCALE, 1.0f); 54 | 55 | // Display color image as RGB triples 56 | glRasterPos2f(0, 1); 57 | glDrawPixels(640, 480, GL_RGB, GL_UNSIGNED_BYTE, dev->get_frame_data(rs::stream::color)); 58 | 59 | // Display infrared image by mapping IR intensity to visible luminance 60 | glRasterPos2f(-1, 0); 61 | glDrawPixels(640, 480, GL_LUMINANCE, GL_UNSIGNED_BYTE, dev->get_frame_data(rs::stream::infrared)); 62 | 63 | // Display second infrared image by mapping IR intensity to visible luminance 64 | if(dev->is_stream_enabled(rs::stream::infrared2)) 65 | { 66 | glRasterPos2f(0, 0); 67 | glDrawPixels(640, 480, GL_LUMINANCE, GL_UNSIGNED_BYTE, dev->get_frame_data(rs::stream::infrared2)); 68 | } 69 | 70 | glfwSwapBuffers(win); 71 | } 72 | 73 | return EXIT_SUCCESS; 74 | } 75 | catch(const rs::error & e) 76 | { 77 | // Method calls against librealsense objects may throw exceptions of type rs::error 78 | printf("rs::error was thrown when calling %s(%s):\n", e.get_failed_function().c_str(), e.get_failed_args().c_str()); 79 | printf(" %s\n", e.what()); 80 | return EXIT_FAILURE; 81 | } 82 | -------------------------------------------------------------------------------- /librealsense.xc/cpp-config-ui.xcodeproj/xcshareddata/xcschemes/cpp-config-ui.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 39 | 40 | 41 | 42 | 52 | 54 | 60 | 61 | 62 | 63 | 64 | 65 | 71 | 73 | 79 | 80 | 81 | 82 | 84 | 85 | 88 | 89 | 90 | -------------------------------------------------------------------------------- /librealsense.xc/cpp-pointcloud.xcodeproj/xcshareddata/xcschemes/cpp-pointcloud.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 39 | 40 | 41 | 42 | 52 | 54 | 60 | 61 | 62 | 63 | 64 | 65 | 71 | 73 | 79 | 80 | 81 | 82 | 84 | 85 | 88 | 89 | 90 | -------------------------------------------------------------------------------- /librealsense.xc/cpp-alignimages.xcodeproj/xcshareddata/xcschemes/cpp-alignimages.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 39 | 40 | 41 | 42 | 52 | 54 | 60 | 61 | 62 | 63 | 64 | 65 | 71 | 73 | 79 | 80 | 81 | 82 | 84 | 85 | 88 | 89 | 90 | -------------------------------------------------------------------------------- /librealsense.xc/cpp-enumerate-devices.xcodeproj/xcshareddata/xcschemes/cpp-enumerate-devices.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 39 | 40 | 41 | 42 | 52 | 54 | 60 | 61 | 62 | 63 | 64 | 65 | 71 | 73 | 79 | 80 | 81 | 82 | 84 | 85 | 88 | 89 | 90 | -------------------------------------------------------------------------------- /librealsense.vc12/realsense/realsense.vcxproj.filters: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | src 6 | 7 | 8 | src 9 | 10 | 11 | src 12 | 13 | 14 | src 15 | 16 | 17 | src 18 | 19 | 20 | src 21 | 22 | 23 | src 24 | 25 | 26 | src 27 | 28 | 29 | src 30 | 31 | 32 | src 33 | 34 | 35 | src 36 | 37 | 38 | src 39 | 40 | 41 | src 42 | 43 | 44 | src 45 | 46 | 47 | src 48 | 49 | 50 | src 51 | 52 | 53 | 54 | 55 | src 56 | 57 | 58 | src 59 | 60 | 61 | src 62 | 63 | 64 | src 65 | 66 | 67 | src 68 | 69 | 70 | src 71 | 72 | 73 | src 74 | 75 | 76 | src 77 | 78 | 79 | include 80 | 81 | 82 | include 83 | 84 | 85 | include 86 | 87 | 88 | src 89 | 90 | 91 | src 92 | 93 | 94 | 95 | 96 | {721d8d00-41ef-4bfe-8fa4-b68747402b13} 97 | 98 | 99 | {48f5de69-6c59-4274-a83a-46a55366ddec} 100 | 101 | 102 | 103 | 104 | 105 | -------------------------------------------------------------------------------- /librealsense.xc/c-tutorial-1-depth.xcodeproj/xcshareddata/xcschemes/c-tutorial-1-depth.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 39 | 40 | 41 | 42 | 52 | 54 | 60 | 61 | 62 | 63 | 64 | 65 | 71 | 73 | 79 | 80 | 81 | 82 | 84 | 85 | 88 | 89 | 90 | -------------------------------------------------------------------------------- /librealsense.xc/unit-tests-offline.xcodeproj/xcshareddata/xcschemes/unit-tests-offline.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 39 | 40 | 41 | 42 | 52 | 54 | 60 | 61 | 62 | 63 | 64 | 65 | 71 | 73 | 79 | 80 | 81 | 82 | 84 | 85 | 88 | 89 | 90 | -------------------------------------------------------------------------------- /librealsense.xc/c-tutorial-2-streams.xcodeproj/xcshareddata/xcschemes/c-tutorial-2-streams.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 39 | 40 | 41 | 42 | 52 | 54 | 60 | 61 | 62 | 63 | 64 | 65 | 71 | 73 | 79 | 80 | 81 | 82 | 84 | 85 | 88 | 89 | 90 | -------------------------------------------------------------------------------- /librealsense.xc/cpp-tutorial-1-depth.xcodeproj/xcshareddata/xcschemes/cpp-tutorial-1-depth.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 39 | 40 | 41 | 42 | 52 | 54 | 60 | 61 | 62 | 63 | 64 | 65 | 71 | 73 | 79 | 80 | 81 | 82 | 84 | 85 | 88 | 89 | 90 | -------------------------------------------------------------------------------- /librealsense.xc/unit-tests-live-f200.xcodeproj/xcshareddata/xcschemes/unit-tests-live-f200.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 39 | 40 | 41 | 42 | 52 | 54 | 60 | 61 | 62 | 63 | 64 | 65 | 71 | 73 | 79 | 80 | 81 | 82 | 84 | 85 | 88 | 89 | 90 | -------------------------------------------------------------------------------- /librealsense.xc/unit-tests-live-r200.xcodeproj/xcshareddata/xcschemes/unit-tests-live-r200.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 39 | 40 | 41 | 42 | 52 | 54 | 60 | 61 | 62 | 63 | 64 | 65 | 71 | 73 | 79 | 80 | 81 | 82 | 84 | 85 | 88 | 89 | 90 | -------------------------------------------------------------------------------- /librealsense.xc/unit-tests-live-sr300.xcodeproj/xcshareddata/xcschemes/unit-tests-live-sr300.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 39 | 40 | 41 | 42 | 52 | 54 | 60 | 61 | 62 | 63 | 64 | 65 | 71 | 73 | 79 | 80 | 81 | 82 | 84 | 85 | 88 | 89 | 90 | -------------------------------------------------------------------------------- /librealsense.xc/cpp-tutorial-2-streams.xcodeproj/xcshareddata/xcschemes/cpp-tutorial-2-streams.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 39 | 40 | 41 | 42 | 52 | 54 | 60 | 61 | 62 | 63 | 64 | 65 | 71 | 73 | 79 | 80 | 81 | 82 | 84 | 85 | 88 | 89 | 90 | -------------------------------------------------------------------------------- /librealsense.xc/c-tutorial-3-pointcloud.xcodeproj/xcshareddata/xcschemes/c-tutorial-3-pointcloud.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 39 | 40 | 41 | 42 | 52 | 54 | 60 | 61 | 62 | 63 | 64 | 65 | 71 | 73 | 79 | 80 | 81 | 82 | 84 | 85 | 88 | 89 | 90 | -------------------------------------------------------------------------------- /librealsense.xc/cpp-tutorial-3-pointcloud.xcodeproj/xcshareddata/xcschemes/cpp-tutorial-3-pointcloud.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 39 | 40 | 41 | 42 | 52 | 54 | 60 | 61 | 62 | 63 | 64 | 65 | 71 | 73 | 79 | 80 | 81 | 82 | 84 | 85 | 88 | 89 | 90 | -------------------------------------------------------------------------------- /librealsense.vc12/librealsense.props: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | $(MSBuildThisFileDirectory)/../ 10 | 11 | 12 | 13 | 14 | 15 | 16 | $(LIBRS_ROOT)/include;%(AdditionalIncludeDirectories) 17 | 18 | 19 | $(LIBRS_ROOT)/bin/Win32;%(AdditionalLibraryDirectories) 20 | realsense-d.lib;%(AdditionalDependencies) 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | $(LIBRS_ROOT)/include;%(AdditionalIncludeDirectories) 29 | 30 | 31 | $(LIBRS_ROOT)/bin/Win32;%(AdditionalLibraryDirectories) 32 | realsense.lib;%(AdditionalDependencies) 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | $(LIBRS_ROOT)/include;%(AdditionalIncludeDirectories) 41 | 42 | 43 | $(LIBRS_ROOT)/bin/x64;%(AdditionalLibraryDirectories) 44 | realsense-d.lib;%(AdditionalDependencies) 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | $(LIBRS_ROOT)/include;%(AdditionalIncludeDirectories) 54 | 55 | 56 | $(LIBRS_ROOT)/bin/x64;%(AdditionalLibraryDirectories) 57 | realsense.lib;%(AdditionalDependencies) 58 | 59 | 60 | 61 | 62 | PreserveNewest 63 | 64 | 65 | 66 | 67 | PreserveNewest 68 | 69 | 70 | 71 | 72 | PreserveNewest 73 | 74 | 75 | 76 | 77 | PreserveNewest 78 | 79 | 80 | -------------------------------------------------------------------------------- /examples/c-tutorial-2-streams.c: -------------------------------------------------------------------------------- 1 | /* License: Apache 2.0. See LICENSE file in root directory. 2 | Copyright(c) 2015 Intel Corporation. All Rights Reserved. */ 3 | 4 | /*******************************************************\ 5 | * librealsense tutorial #2 - Accessing multiple streams * 6 | \*******************************************************/ 7 | 8 | /* First include the librealsense C header file */ 9 | #include 10 | #include 11 | #include 12 | #include 13 | 14 | /* Also include GLFW to allow for graphical display */ 15 | #include 16 | 17 | /* Function calls to librealsense may raise errors of type rs_error */ 18 | rs_error * e = 0; 19 | void check_error() 20 | { 21 | if(e) 22 | { 23 | printf("rs_error was raised when calling %s(%s):\n", rs_get_failed_function(e), rs_get_failed_args(e)); 24 | printf(" %s\n", rs_get_error_message(e)); 25 | exit(EXIT_FAILURE); 26 | } 27 | } 28 | 29 | int main() 30 | { 31 | /* Create a context object. This object owns the handles to all connected realsense devices. */ 32 | rs_context * ctx = rs_create_context(RS_API_VERSION, &e); 33 | check_error(); 34 | printf("There are %d connected RealSense devices.\n", rs_get_device_count(ctx, &e)); 35 | check_error(); 36 | if(rs_get_device_count(ctx, &e) == 0) return EXIT_FAILURE; 37 | 38 | /* This tutorial will access only a single device, but it is trivial to extend to multiple devices */ 39 | rs_device * dev = rs_get_device(ctx, 0, &e); 40 | check_error(); 41 | printf("\nUsing device 0, an %s\n", rs_get_device_name(dev, &e)); 42 | check_error(); 43 | printf(" Serial number: %s\n", rs_get_device_serial(dev, &e)); 44 | check_error(); 45 | printf(" Firmware version: %s\n", rs_get_device_firmware_version(dev, &e)); 46 | check_error(); 47 | 48 | /* Configure all streams to run at VGA resolution at 60 frames per second */ 49 | rs_enable_stream(dev, RS_STREAM_DEPTH, 640, 480, RS_FORMAT_Z16, 60, &e); 50 | check_error(); 51 | rs_enable_stream(dev, RS_STREAM_COLOR, 640, 480, RS_FORMAT_RGB8, 60, &e); 52 | check_error(); 53 | rs_enable_stream(dev, RS_STREAM_INFRARED, 640, 480, RS_FORMAT_Y8, 60, &e); 54 | check_error(); 55 | rs_enable_stream(dev, RS_STREAM_INFRARED2, 640, 480, RS_FORMAT_Y8, 60, NULL); /* Pass NULL to ignore errors */ 56 | rs_start_device(dev, &e); 57 | check_error(); 58 | 59 | /* Open a GLFW window to display our output */ 60 | glfwInit(); 61 | GLFWwindow * win = glfwCreateWindow(1280, 960, "librealsense tutorial #2", NULL, NULL); 62 | glfwMakeContextCurrent(win); 63 | while(!glfwWindowShouldClose(win)) 64 | { 65 | /* Wait for new frame data */ 66 | glfwPollEvents(); 67 | rs_wait_for_frames(dev, &e); 68 | check_error(); 69 | 70 | glClear(GL_COLOR_BUFFER_BIT); 71 | glPixelZoom(1, -1); 72 | 73 | /* Display depth data by linearly mapping depth between 0 and 2 meters to the red channel */ 74 | glRasterPos2f(-1, 1); 75 | glPixelTransferf(GL_RED_SCALE, 0xFFFF * rs_get_device_depth_scale(dev, &e) / 2.0f); 76 | check_error(); 77 | glDrawPixels(640, 480, GL_RED, GL_UNSIGNED_SHORT, rs_get_frame_data(dev, RS_STREAM_DEPTH, &e)); 78 | check_error(); 79 | glPixelTransferf(GL_RED_SCALE, 1.0f); 80 | 81 | /* Display color image as RGB triples */ 82 | glRasterPos2f(0, 1); 83 | glDrawPixels(640, 480, GL_RGB, GL_UNSIGNED_BYTE, rs_get_frame_data(dev, RS_STREAM_COLOR, &e)); 84 | check_error(); 85 | 86 | /* Display infrared image by mapping IR intensity to visible luminance */ 87 | glRasterPos2f(-1, 0); 88 | glDrawPixels(640, 480, GL_LUMINANCE, GL_UNSIGNED_BYTE, rs_get_frame_data(dev, RS_STREAM_INFRARED, &e)); 89 | check_error(); 90 | 91 | /* Display second infrared image by mapping IR intensity to visible luminance */ 92 | if(rs_is_stream_enabled(dev, RS_STREAM_INFRARED2, NULL)) 93 | { 94 | glRasterPos2f(0, 0); 95 | glDrawPixels(640, 480, GL_LUMINANCE, GL_UNSIGNED_BYTE, rs_get_frame_data(dev, RS_STREAM_INFRARED2, &e)); 96 | } 97 | 98 | glfwSwapBuffers(win); 99 | } 100 | 101 | return EXIT_SUCCESS; 102 | } -------------------------------------------------------------------------------- /src/libuvc/frame.c: -------------------------------------------------------------------------------- 1 | /********************************************************************* 2 | * Software License Agreement (BSD License) 3 | * 4 | * Copyright (C) 2010-2012 Ken Tossell 5 | * All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions 9 | * are met: 10 | * 11 | * * Redistributions of source code must retain the above copyright 12 | * notice, this list of conditions and the following disclaimer. 13 | * * Redistributions in binary form must reproduce the above 14 | * copyright notice, this list of conditions and the following 15 | * disclaimer in the documentation and/or other materials provided 16 | * with the distribution. 17 | * * Neither the name of the author nor other contributors may be 18 | * used to endorse or promote products derived from this software 19 | * without specific prior written permission. 20 | * 21 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 22 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 23 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 24 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 25 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 26 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 27 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 28 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 29 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 30 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 31 | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 32 | * POSSIBILITY OF SUCH DAMAGE. 33 | *********************************************************************/ 34 | /** 35 | * @defgroup frame Frame processing 36 | * @brief Tools for managing frame buffers and converting between image formats 37 | */ 38 | #include "libuvc.h" 39 | #include "libuvc_internal.h" 40 | 41 | /** @internal */ 42 | uvc_error_t uvc_ensure_frame_size(uvc_frame_t *frame, size_t need_bytes) { 43 | if (frame->library_owns_data) { 44 | if (!frame->data || frame->data_bytes != need_bytes) { 45 | frame->data_bytes = need_bytes; 46 | frame->data = realloc(frame->data, frame->data_bytes); 47 | } 48 | if (!frame->data) 49 | return UVC_ERROR_NO_MEM; 50 | return UVC_SUCCESS; 51 | } else { 52 | if (!frame->data || frame->data_bytes < need_bytes) 53 | return UVC_ERROR_NO_MEM; 54 | return UVC_SUCCESS; 55 | } 56 | } 57 | 58 | /** @brief Allocate a frame structure 59 | * @ingroup frame 60 | * 61 | * @param data_bytes Number of bytes to allocate, or zero 62 | * @return New frame, or NULL on error 63 | */ 64 | uvc_frame_t *uvc_allocate_frame(size_t data_bytes) { 65 | uvc_frame_t *frame = malloc(sizeof(*frame)); 66 | 67 | if (!frame) 68 | return NULL; 69 | 70 | memset(frame, 0, sizeof(*frame)); 71 | 72 | frame->library_owns_data = 1; 73 | 74 | if (data_bytes > 0) { 75 | frame->data_bytes = data_bytes; 76 | frame->data = malloc(data_bytes); 77 | 78 | if (!frame->data) { 79 | free(frame); 80 | return NULL; 81 | } 82 | } 83 | 84 | return frame; 85 | } 86 | 87 | /** @brief Free a frame structure 88 | * @ingroup frame 89 | * 90 | * @param frame Frame to destroy 91 | */ 92 | void uvc_free_frame(uvc_frame_t *frame) { 93 | if (frame->data_bytes > 0 && frame->library_owns_data) 94 | free(frame->data); 95 | 96 | free(frame); 97 | } 98 | 99 | static inline unsigned char sat(int i) { 100 | return (unsigned char)( i >= 255 ? 255 : (i < 0 ? 0 : i)); 101 | } 102 | 103 | /** @brief Duplicate a frame, preserving color format 104 | * @ingroup frame 105 | * 106 | * @param in Original frame 107 | * @param out Duplicate frame 108 | */ 109 | uvc_error_t uvc_duplicate_frame(uvc_frame_t *in, uvc_frame_t *out) { 110 | if (uvc_ensure_frame_size(out, in->data_bytes) < 0) 111 | return UVC_ERROR_NO_MEM; 112 | 113 | out->width = in->width; 114 | out->height = in->height; 115 | out->fourcc = in->fourcc; 116 | out->step = in->step; 117 | out->sequence = in->sequence; 118 | out->capture_time = in->capture_time; 119 | out->source = in->source; 120 | 121 | memcpy(out->data, in->data, in->data_bytes); 122 | 123 | return UVC_SUCCESS; 124 | } 125 | -------------------------------------------------------------------------------- /src/uvc.h: -------------------------------------------------------------------------------- 1 | // License: Apache 2.0. See LICENSE file in root directory. 2 | // Copyright(c) 2015 Intel Corporation. All Rights Reserved. 3 | 4 | #pragma once 5 | #ifndef LIBREALSENSE_UVC_H 6 | #define LIBREALSENSE_UVC_H 7 | 8 | #include "types.h" 9 | 10 | #include 11 | #include 12 | 13 | namespace rsimpl 14 | { 15 | namespace uvc 16 | { 17 | struct guid { uint32_t data1; uint16_t data2, data3; uint8_t data4[8]; }; 18 | struct context; // Opaque type representing access to the underlying UVC implementation 19 | struct device; // Opaque type representing access to a specific UVC device 20 | 21 | // Enumerate devices 22 | std::shared_ptr create_context(); 23 | std::vector> query_devices(std::shared_ptr context); 24 | 25 | // Static device properties 26 | int get_vendor_id(const device & device); 27 | int get_product_id(const device & device); 28 | 29 | // Direct USB controls 30 | void claim_interface(device & device, const guid & interface_guid, int interface_number); 31 | void bulk_transfer(device & device, unsigned char endpoint, void * data, int length, int *actual_length, unsigned int timeout); 32 | 33 | // Access CT and PU controls 34 | inline bool is_pu_control(rs_option option) { return option >= RS_OPTION_COLOR_BACKLIGHT_COMPENSATION && option <= RS_OPTION_COLOR_ENABLE_AUTO_WHITE_BALANCE; } 35 | void get_pu_control_range(const device & device, int subdevice, rs_option option, int * min, int * max); 36 | void set_pu_control(device & device, int subdevice, rs_option option, int value); 37 | int get_pu_control(const device & device, int subdevice, rs_option option); 38 | 39 | // Access XU controls 40 | void init_controls(device & device, int subdevice, const guid & xu_guid); 41 | void set_control(device & device, int subdevice, uint8_t ctrl, void * data, int len); 42 | void get_control(const device & device, int subdevice, uint8_t ctrl, void * data, int len); 43 | 44 | // Control streaming 45 | void set_subdevice_mode(device & device, int subdevice_index, int width, int height, uint32_t fourcc, int fps, std::function callback); 46 | void start_streaming(device & device, int num_transfer_bufs); 47 | void stop_streaming(device & device); 48 | 49 | // Access CT, PU, and XU controls, and retry if failure occurs 50 | inline void set_pu_control_with_retry(device & device, int subdevice, rs_option option, int value) 51 | { 52 | // Try writing a control, if it fails, retry several times 53 | // TODO: We may wish to tune the retry counts and sleep times based on camera, platform, firmware, etc. 54 | for(int i=0; i<20; ++i) 55 | { 56 | try { set_pu_control(device, subdevice, option, value); return; } 57 | catch(...) { std::this_thread::sleep_for(std::chrono::milliseconds(50)); } 58 | } 59 | set_pu_control(device, subdevice, option, value); 60 | } 61 | 62 | inline int get_pu_control_with_retry(const device & device, int subdevice, rs_option option) 63 | { 64 | // Try reading a control, if it fails, retry several times 65 | for(int i=0; i<20; ++i) 66 | { 67 | try { return get_pu_control(device, subdevice, option); } 68 | catch(...) { std::this_thread::sleep_for(std::chrono::milliseconds(50)); } 69 | } 70 | return get_pu_control(device, subdevice, option); 71 | } 72 | 73 | inline void set_control_with_retry(device & device, int subdevice, uint8_t ctrl, void * data, int len) 74 | { 75 | // Try writing a control, if it fails, retry several times 76 | for(int i=0; i<20; ++i) 77 | { 78 | try { set_control(device, subdevice, ctrl, data, len); return; } 79 | catch(...) { std::this_thread::sleep_for(std::chrono::milliseconds(50)); } 80 | } 81 | set_control(device, subdevice, ctrl, data, len); 82 | } 83 | 84 | inline void get_control_with_retry(const device & device, int subdevice, uint8_t ctrl, void * data, int len) 85 | { 86 | // Try reading a control, if it fails, retry several times 87 | for(int i=0; i<20; ++i) 88 | { 89 | try { get_control(device, subdevice, ctrl, data, len); return; } 90 | catch(...) { std::this_thread::sleep_for(std::chrono::milliseconds(50)); } 91 | } 92 | get_control(device, subdevice, ctrl, data, len); 93 | } 94 | } 95 | } 96 | 97 | #endif 98 | -------------------------------------------------------------------------------- /src/device.h: -------------------------------------------------------------------------------- 1 | // License: Apache 2.0. See LICENSE file in root directory. 2 | // Copyright(c) 2015 Intel Corporation. All Rights Reserved. 3 | 4 | #pragma once 5 | #ifndef LIBREALSENSE_DEVICE_H 6 | #define LIBREALSENSE_DEVICE_H 7 | 8 | #include "uvc.h" 9 | #include "stream.h" 10 | #include 11 | 12 | struct rs_device 13 | { 14 | private: 15 | const std::shared_ptr device; 16 | protected: 17 | rsimpl::device_config config; 18 | private: 19 | rsimpl::native_stream depth, color, infrared, infrared2; 20 | rsimpl::point_stream points; 21 | rsimpl::rectified_stream rect_color; 22 | rsimpl::aligned_stream color_to_depth, depth_to_color, depth_to_rect_color, infrared2_to_depth, depth_to_infrared2; 23 | rsimpl::native_stream * native_streams[RS_STREAM_NATIVE_COUNT]; 24 | rsimpl::stream_interface * streams[RS_STREAM_COUNT]; 25 | 26 | bool capturing; 27 | std::chrono::high_resolution_clock::time_point capture_started; 28 | 29 | int64_t base_timestamp; 30 | int last_stream_timestamp; 31 | protected: 32 | const rsimpl::uvc::device & get_device() const { return *device; } 33 | rsimpl::uvc::device & get_device() { return *device; } 34 | public: 35 | rs_device(std::shared_ptr device, const rsimpl::static_device_info & info); 36 | ~rs_device(); 37 | 38 | const rsimpl::stream_interface & get_stream_interface(rs_stream stream) const { return *streams[stream]; } 39 | 40 | const char * get_name() const { return config.info.name.c_str(); } 41 | const char * get_serial() const { return config.info.serial.c_str(); } 42 | const char * get_firmware_version() const { return config.info.firmware_version.c_str(); } 43 | float get_depth_scale() const { return config.depth_scale; } 44 | 45 | void enable_stream(rs_stream stream, int width, int height, rs_format format, int fps); 46 | void enable_stream_preset(rs_stream stream, rs_preset preset); 47 | void disable_stream(rs_stream stream); 48 | 49 | void start(); 50 | void stop(); 51 | bool is_capturing() const { return capturing; } 52 | 53 | void wait_all_streams(); 54 | int get_frame_timestamp(rs_stream stream) const; 55 | const rsimpl::byte * get_frame_data(rs_stream stream) const; 56 | 57 | virtual bool supports_option(rs_option option) const; 58 | virtual void get_option_range(rs_option option, double & min, double & max, double & step); 59 | virtual void set_options(const rs_option options[], int count, const double values[]) {} 60 | virtual void get_options(const rs_option options[], int count, double values[]) {} 61 | 62 | virtual void on_before_start(const std::vector & selected_modes) {} 63 | virtual int convert_timestamp(int64_t timestamp) const = 0; 64 | }; 65 | 66 | namespace rsimpl 67 | { 68 | // This class is used to buffer up several writes to a structure-valued XU control, and send the entire structure all at once 69 | // Additionally, it will ensure that any fields not set in a given struct will retain their original values 70 | template struct struct_interface 71 | { 72 | T struct_; 73 | R reader; 74 | W writer; 75 | bool active; 76 | 77 | struct_interface(R r, W w) : reader(r), writer(w), active(false) {} 78 | 79 | void activate() { if(!active) { struct_ = reader(); active = true; } } 80 | template double get(U T::* field) { activate(); return struct_.*field; } 81 | template void set(U T::* field, double value) { activate(); struct_.*field = static_cast(value); } 82 | void commit() { if(active) writer(struct_); } 83 | }; 84 | 85 | template struct_interface make_struct_interface(R r, W w) { return {r,w}; } 86 | } 87 | 88 | #endif 89 | -------------------------------------------------------------------------------- /doc/installation.md: -------------------------------------------------------------------------------- 1 | # Table of Contents 2 | * [Ubuntu 14.04 LTS Installation](#ubuntu-1404-lts-installation) 3 | * [Apple OSX Installation](#apple-osx-installation) 4 | * [Windows 8.1 Installation](#windows-81-installation) 5 | 6 | # Ubuntu 14.04 LTS Installation 7 | 8 | Installation of devices on Linux is lengthy compared to Windows or OSX due to the fact an updated kernel must be installed and the core uvcvideo driver patched with support for additional pixel formats provided by RealSense™ cameras. 9 | 10 | **Note:** Several scripts below invoke `wget, git, add-apt-repository` which may be blocked by your IT firewall resulting in timeouts and errors. Add necessary proxy settings to config files or append scripts with appropriate switches. 11 | 12 | 1. Ensure apt-get is up to date 13 | * `sudo apt-get update && sudo apt-get upgrade` 14 | 2. Install libusb-1.0 via apt-get 15 | * `sudo apt-get install libusb-1.0-0-dev` 16 | 3. glfw3 is not available in apt-get on Ubuntu 14.04. Use included installer script: 17 | * `scripts/install_glfw3.sh` 18 | 4. **Follow the installation instructions for your desired backend (see below)** 19 | 5. We use QtCreator as an IDE for Linux development on Ubuntu 20 | * **Note:** QtCreator is presently configured to use the V4L2 backend by default 21 | * `sudo apt-get install qtcreator` 22 | * `sudo scripts/install_qt.sh` (we also need qmake from the full qt5 distribution) 23 | * `all.pro` contains librealsense and all example applications 24 | * From the QtCreator top menu: Clean => Run QMake => Build 25 | * Built QtCreator projects will be placed into `./bin/debug` or `./bin/release` 26 | 6. We also provide a makefile if you'd prefer to use your own favorite text editor 27 | * `make && sudo make install` 28 | * The example executables will build into `./bin` 29 | 30 | ## Video4Linux backend 31 | 32 | 1. Ensure no cameras are presently plugged into the system. 33 | 2. Install udev rules 34 | * `sudo cp config/99-realsense-libusb.rules /etc/udev/rules.d/` 35 | * Reboot or run `sudo udevadm control --reload-rules && udevadm trigger` to enforce the new udev rules 36 | 3. Next, choose one of the following subheadings based on desired machine configuration / kernel version (and remember to complete step 4 after). **Note: ** Multi-camera support is currently NOT supported on 3.19.xx kernels. Please update to 4.4 stable. 37 | * **Updated 4.4 Stable Kernel** (recommended) 38 | * Run the following script to install necessary dependencies (GCC 4.9 compiler and openssl) and update kernel to v4.4-wily 39 | * `./scripts/install_dependencies-4.4.sh` 40 | * Run the following script to patch uvcvideo.ko 41 | * `./scripts/patch-uvcvideo-4.4.sh v4.4-wily` (note the argument provided to this version of the script) 42 | * This script involves shallow cloning the Linux source repository (100mb), and may take a while 43 | * **(OR) Stock 3.19.xx Kernel in 14.04.xx** 44 | * Run the following script to patch uvcvideo.ko 45 | * `./scripts/patch-uvcvideo-3.19.sh` 46 | * (R200 Only) Install connectivity workaround 47 | * `./scripts/install-r200-udev-fix.sh` 48 | * This udev fix is not necessary for kernels >= 4.2.3 49 | 4. Reload the uvcvideo driver 50 | * `sudo modprobe uvcvideo` 51 | 52 | ## LibUVC backend 53 | 54 | **Note:** This backend has been deprecated on Linux. 55 | 56 | The libuvc backend requires that the default linux uvcvideo.ko driver be unloaded before libusb can touch the device. This is because uvcvideo will own a UVC device the moment is is plugged in; user-space applications do not have permission to access the devie handle. See below regarding the udev rule workaround. 57 | 58 | The libuvc backend has known incompatibilities with some versions of SR300 and R200 firmware (1.0.71.xx series of firmwares are problematic). 59 | 60 | 1. Grant appropriate permissions to detach the kernel UVC driver when a device is plugged in: 61 | * `sudo cp config/99-realsense-libusb.rules /etc/udev/rules.d/` 62 | * `sudo cp config/uvc.conf /etc/modprobe.d/` 63 | * Either reboot or run `sudo udevadm control --reload-rules && udevadm trigger` to enforce the new udev rules 64 | 2. Use the makefile to build the LibUVC backend 65 | * `make BACKEND=LIBUVC` 66 | * `sudo make install` 67 | 68 | --- 69 | 70 | # Apple OSX Installation 71 | 72 | 1. Install XCode 6.0+ via the AppStore 73 | 2. Install the Homebrew package manager via terminal - [link](http://brew.sh/) 74 | 3. Install libusb via brew: 75 | * `brew install libusb` 76 | 4. Install glfw3 via brew: 77 | * `brew install homebrew/versions/glfw3` 78 | 79 | --- 80 | 81 | # Windows 8.1 Installation 82 | 83 | librealsense should compile out of the box with Visual Studio 2013 Release 5. Particular C++11 features are known to be incompatible with earlier VS2013 releases due to internal compiler errors. GLFW is provided in the solution as a NuGet package. 84 | 85 | librealsense has not been tested with Visual Studio Community Edition. 86 | -------------------------------------------------------------------------------- /src/libuvc/utlist.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2007-2010, Troy D. Hanson http://uthash.sourceforge.net 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | 8 | * Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | 11 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS 12 | IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 13 | TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 14 | PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER 15 | OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 16 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 17 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 18 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 19 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 20 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 21 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 22 | */ 23 | 24 | #ifndef UTLIST_H 25 | #define UTLIST_H 26 | 27 | #define UTLIST_VERSION 1.9.1 28 | 29 | /****************************************************************************** 30 | * doubly linked list macros (non-circular) * 31 | *****************************************************************************/ 32 | #define DL_PREPEND(head,add) \ 33 | do { \ 34 | (add)->next = head; \ 35 | if (head) { \ 36 | (add)->prev = (head)->prev; \ 37 | (head)->prev = (add); \ 38 | } else { \ 39 | (add)->prev = (add); \ 40 | } \ 41 | (head) = (add); \ 42 | } while (0) 43 | 44 | #define DL_APPEND(head,add) \ 45 | do { \ 46 | if (head) { \ 47 | (add)->prev = (head)->prev; \ 48 | (head)->prev->next = (add); \ 49 | (head)->prev = (add); \ 50 | (add)->next = NULL; \ 51 | } else { \ 52 | (head)=(add); \ 53 | (head)->prev = (head); \ 54 | (head)->next = NULL; \ 55 | } \ 56 | } while (0); 57 | 58 | #define DL_DELETE(head,del) \ 59 | do { \ 60 | if ((del)->prev == (del)) { \ 61 | (head)=NULL; \ 62 | } else if ((del)==(head)) { \ 63 | (del)->next->prev = (del)->prev; \ 64 | (head) = (del)->next; \ 65 | } else { \ 66 | (del)->prev->next = (del)->next; \ 67 | if ((del)->next) { \ 68 | (del)->next->prev = (del)->prev; \ 69 | } else { \ 70 | (head)->prev = (del)->prev; \ 71 | } \ 72 | } \ 73 | } while (0); 74 | 75 | 76 | #define DL_FOREACH(head,el) \ 77 | for(el=head;el;el=el->next) 78 | 79 | /* this version is safe for deleting the elements during iteration */ 80 | #define DL_FOREACH_SAFE(head,el,tmp) \ 81 | for((el)=(head);(el) && (tmp = (el)->next, 1); (el) = tmp) 82 | 83 | /* these are identical to their singly-linked list counterparts */ 84 | #define DL_SEARCH_SCALAR LL_SEARCH_SCALAR 85 | #define DL_SEARCH LL_SEARCH 86 | 87 | #endif -------------------------------------------------------------------------------- /scripts/realsense-camera-formats.patch: -------------------------------------------------------------------------------- 1 | diff --git a/drivers/media/usb/uvc/uvc_driver.c b/drivers/media/usb/uvc/uvc_driver.c 2 | index 4b5b3e8..b1ef8a5 100644 3 | --- a/drivers/media/usb/uvc/uvc_driver.c 4 | +++ b/drivers/media/usb/uvc/uvc_driver.c 5 | @@ -108,6 +108,56 @@ static struct uvc_format_desc uvc_fmts[] = { 6 | .fcc = V4L2_PIX_FMT_Y16, 7 | }, 8 | { 9 | + .name = "Greyscale 8 L/R (Y8I)", 10 | + .guid = UVC_GUID_FORMAT_Y8I, 11 | + .fcc = V4L2_PIX_FMT_Y8I, 12 | + }, 13 | + { 14 | + .name = "Greyscale 12 L/R (Y12I)", 15 | + .guid = UVC_GUID_FORMAT_Y12I, 16 | + .fcc = V4L2_PIX_FMT_Y12I, 17 | + }, 18 | + { 19 | + .name = "Depth data 16-bit (Z16)", 20 | + .guid = UVC_GUID_FORMAT_Z16, 21 | + .fcc = V4L2_PIX_FMT_Z16, 22 | + }, 23 | + { 24 | + .name = "Raw data 10-bit (RW10)", 25 | + .guid = UVC_GUID_FORMAT_RW10, 26 | + .fcc = V4L2_PIX_FMT_RW10, 27 | + }, 28 | + { 29 | + .name = "Depth 16-bit (INVZ)", 30 | + .guid = UVC_GUID_FORMAT_INVZ, 31 | + .fcc = V4L2_PIX_FMT_INVZ, 32 | + }, 33 | + { 34 | + .name = "Depth:IR 16:8 24-bit (INZI)", 35 | + .guid = UVC_GUID_FORMAT_INZI, 36 | + .fcc = V4L2_PIX_FMT_INZI, 37 | + }, 38 | + { 39 | + .name = "Depth 16-bit (INVR)", 40 | + .guid = UVC_GUID_FORMAT_INVR, 41 | + .fcc = V4L2_PIX_FMT_INVR, 42 | + }, 43 | + { 44 | + .name = "Depth:IR 16:8 24-bit (INRI)", 45 | + .guid = UVC_GUID_FORMAT_INRI, 46 | + .fcc = V4L2_PIX_FMT_INRI, 47 | + }, 48 | + { 49 | + .name = "Infrared 8-bit (INVI)", 50 | + .guid = UVC_GUID_FORMAT_INVI, 51 | + .fcc = V4L2_PIX_FMT_INVI, 52 | + }, 53 | + { 54 | + .name = "FlickerIR 8-bit (RELI)", 55 | + .guid = UVC_GUID_FORMAT_RELI, 56 | + .fcc = V4L2_PIX_FMT_RELI, 57 | + }, 58 | + { 59 | .name = "BGGR Bayer (BY8 )", 60 | .guid = UVC_GUID_FORMAT_BY8, 61 | .fcc = V4L2_PIX_FMT_SBGGR8, 62 | diff --git a/drivers/media/usb/uvc/uvcvideo.h b/drivers/media/usb/uvc/uvcvideo.h 63 | index 816dd1a..52a25c5 100644 64 | --- a/drivers/media/usb/uvc/uvcvideo.h 65 | +++ b/drivers/media/usb/uvc/uvcvideo.h 66 | @@ -91,6 +91,36 @@ 67 | #define UVC_GUID_FORMAT_Y16 \ 68 | { 'Y', '1', '6', ' ', 0x00, 0x00, 0x10, 0x00, \ 69 | 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71} 70 | +#define UVC_GUID_FORMAT_Y8I \ 71 | + { 'Y', '8', 'I', ' ', 0x00, 0x00, 0x10, 0x00, \ 72 | + 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71} 73 | +#define UVC_GUID_FORMAT_Y12I \ 74 | + { 'Y', '1', '2', 'I', 0x00, 0x00, 0x10, 0x00, \ 75 | + 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71} 76 | +#define UVC_GUID_FORMAT_Z16 \ 77 | + { 'Z', '1', '6', ' ', 0x00, 0x00, 0x10, 0x00, \ 78 | + 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71} 79 | +#define UVC_GUID_FORMAT_RW10 \ 80 | + { 'R', 'W', '1', '0', 0x00, 0x00, 0x10, 0x00, \ 81 | + 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71} 82 | +#define UVC_GUID_FORMAT_INVZ \ 83 | + { 'I', 'N', 'V', 'Z', 0x90, 0x2d, 0x58, 0x4a, \ 84 | + 0x92, 0x0b, 0x77, 0x3f, 0x1f, 0x2c, 0x55, 0x6b} 85 | +#define UVC_GUID_FORMAT_INZI \ 86 | + { 'I', 'N', 'Z', 'I', 0x66, 0x1a, 0x42, 0xa2, \ 87 | + 0x90, 0x65, 0xd0, 0x18, 0x14, 0xa8, 0xef, 0x8a} 88 | +#define UVC_GUID_FORMAT_INVR \ 89 | + { 'I', 'N', 'V', 'R', 0x90, 0x2d, 0x58, 0x4a, \ 90 | + 0x92, 0x0b, 0x77, 0x3f, 0x1f, 0x2c, 0x55, 0x6b} 91 | +#define UVC_GUID_FORMAT_INRI \ 92 | + { 'I', 'N', 'R', 'I', 0x90, 0x2d, 0x58, 0x4a, \ 93 | + 0x92, 0x0b, 0x77, 0x3f, 0x1f, 0x2c, 0x55, 0x6b} 94 | +#define UVC_GUID_FORMAT_INVI \ 95 | + { 'I', 'N', 'V', 'I', 0xdb, 0x57, 0x49, 0x5e, \ 96 | + 0x8e, 0x3f, 0xf4, 0x79, 0x53, 0x2b, 0x94, 0x6f} 97 | +#define UVC_GUID_FORMAT_RELI \ 98 | + { 'R', 'E', 'L', 'I', 0x14, 0x13, 0x43, 0xf9, \ 99 | + 0xa7, 0x5a, 0xee, 0x6b, 0xbf, 0x01, 0x2e, 0x23} 100 | #define UVC_GUID_FORMAT_BY8 \ 101 | { 'B', 'Y', '8', ' ', 0x00, 0x00, 0x10, 0x00, \ 102 | 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71} 103 | @@ -115,7 +145,6 @@ 104 | #define UVC_GUID_FORMAT_M420 \ 105 | { 'M', '4', '2', '0', 0x00, 0x00, 0x10, 0x00, \ 106 | 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71} 107 | - 108 | #define UVC_GUID_FORMAT_H264 \ 109 | { 'H', '2', '6', '4', 0x00, 0x00, 0x10, 0x00, \ 110 | 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71} 111 | diff --git a/include/uapi/linux/videodev2.h b/include/uapi/linux/videodev2.h 112 | index 3228fbe..e08130f 100644 113 | --- a/include/uapi/linux/videodev2.h 114 | +++ b/include/uapi/linux/videodev2.h 115 | @@ -579,6 +579,18 @@ struct v4l2_pix_format { 116 | #define V4L2_PIX_FMT_VC1_ANNEX_L v4l2_fourcc('V', 'C', '1', 'L') /* SMPTE 421M Annex L compliant stream */ 117 | #define V4L2_PIX_FMT_VP8 v4l2_fourcc('V', 'P', '8', '0') /* VP8 */ 118 | 119 | +/* Intel RealSense-specific formats */ 120 | +#define V4L2_PIX_FMT_Y8I v4l2_fourcc('Y', '8', 'I', ' ') /* Greyscale 8-bit L/R interleaved */ 121 | +#define V4L2_PIX_FMT_Y12I v4l2_fourcc('Y', '1', '2', 'I') /* Greyscale 12-bit L/R interleaved */ 122 | +#define V4L2_PIX_FMT_Z16 v4l2_fourcc('Z', '1', '6', ' ') /* Depth data 16-bit */ 123 | +#define V4L2_PIX_FMT_RW10 v4l2_fourcc('R', 'W', '1', '0') /* Raw data 10-bit */ 124 | +#define V4L2_PIX_FMT_INVZ v4l2_fourcc('I', 'N', 'V', 'Z') /* 16 Depth */ 125 | +#define V4L2_PIX_FMT_INZI v4l2_fourcc('I', 'N', 'Z', 'I') /* 24 Depth/IR 16:8 */ 126 | +#define V4L2_PIX_FMT_INVR v4l2_fourcc('I', 'N', 'V', 'R') /* 16 Depth */ 127 | +#define V4L2_PIX_FMT_INRI v4l2_fourcc('I', 'N', 'R', 'I') /* 24 Depth/IR 16:8 */ 128 | +#define V4L2_PIX_FMT_INVI v4l2_fourcc('I', 'N', 'V', 'I') /* 8 IR */ 129 | +#define V4L2_PIX_FMT_RELI v4l2_fourcc('R', 'E', 'L', 'I') /* 8 IR alternating on off illumination */ 130 | + 131 | /* Vendor-specific formats */ 132 | #define V4L2_PIX_FMT_CPIA1 v4l2_fourcc('C', 'P', 'I', 'A') /* cpia1 YUV */ 133 | #define V4L2_PIX_FMT_WNVA v4l2_fourcc('W', 'N', 'V', 'A') /* Winnov hw compress */ 134 | -------------------------------------------------------------------------------- /examples/cpp-capture.cpp: -------------------------------------------------------------------------------- 1 | // License: Apache 2.0. See LICENSE file in root directory. 2 | // Copyright(c) 2015 Intel Corporation. All Rights Reserved. 3 | 4 | #include 5 | #include "example.hpp" 6 | 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | 13 | texture_buffer buffers[RS_STREAM_COUNT]; 14 | bool align_depth_to_color = false; 15 | bool align_color_to_depth = false; 16 | bool color_rectification_enabled = false; 17 | 18 | #include 19 | 20 | int main(int argc, char * argv[]) try 21 | { 22 | rs::log_to_console(rs::log_severity::warn); 23 | //rs::log_to_file(rs::log_severity::debug, "librealsense.log"); 24 | 25 | rs::context ctx; 26 | if(ctx.get_device_count() == 0) throw std::runtime_error("No device detected. Is it plugged in?"); 27 | rs::device & dev = *ctx.get_device(0); 28 | 29 | dev.enable_stream(rs::stream::depth, rs::preset::best_quality); 30 | dev.enable_stream(rs::stream::color, rs::preset::best_quality); 31 | dev.enable_stream(rs::stream::infrared, rs::preset::best_quality); 32 | try { dev.enable_stream(rs::stream::infrared2, 0, 0, rs::format::any, 0); } catch(...) {} 33 | 34 | // Compute field of view for each enabled stream 35 | for(int i = 0; i < 4; ++i) 36 | { 37 | auto stream = rs::stream(i); 38 | if(!dev.is_stream_enabled(stream)) continue; 39 | auto intrin = dev.get_stream_intrinsics(stream); 40 | std::cout << "Capturing " << stream << " at " << intrin.width << " x " << intrin.height; 41 | std::cout << std::setprecision(1) << std::fixed << ", fov = " << intrin.hfov() << " x " << intrin.vfov() << ", distortion = " << intrin.model() << std::endl; 42 | } 43 | 44 | // Start our device 45 | dev.start(); 46 | 47 | // For the libuvc backend, this sleep is required before touching any of the camera 48 | // options after a device has been .start()'d 49 | std::this_thread::sleep_for(std::chrono::milliseconds(1000)); 50 | 51 | // Report the status of each supported option 52 | /*for(int i = 0; i < RS_OPTION_COUNT; ++i) 53 | { 54 | auto option = rs::option(i); 55 | if(dev.supports_option(option)) 56 | { 57 | std::cout << "Option " << option << ": "; 58 | try { std::cout << dev.get_option(option) << std::endl; } 59 | catch(const std::exception & e) { std::cout << e.what() << std::endl; } 60 | } 61 | }*/ 62 | 63 | // Open a GLFW window 64 | glfwInit(); 65 | std::ostringstream ss; ss << "CPP Capture Example (" << dev.get_name() << ")"; 66 | GLFWwindow * win = glfwCreateWindow(1280, 960, ss.str().c_str(), 0, 0); 67 | glfwSetWindowUserPointer(win, &dev); 68 | glfwSetKeyCallback(win, [](GLFWwindow * win, int key, int scancode, int action, int mods) 69 | { 70 | auto dev = reinterpret_cast(glfwGetWindowUserPointer(win)); 71 | if(action != GLFW_RELEASE) switch(key) 72 | { 73 | case GLFW_KEY_R: color_rectification_enabled = !color_rectification_enabled; break; 74 | case GLFW_KEY_C: align_color_to_depth = !align_color_to_depth; break; 75 | case GLFW_KEY_D: align_depth_to_color = !align_depth_to_color; break; 76 | case GLFW_KEY_E: 77 | if(dev->supports_option(rs::option::r200_emitter_enabled)) 78 | { 79 | int value = !dev->get_option(rs::option::r200_emitter_enabled); 80 | std::cout << "Setting emitter to " << value << std::endl; 81 | dev->set_option(rs::option::r200_emitter_enabled, value); 82 | } 83 | break; 84 | case GLFW_KEY_A: 85 | if(dev->supports_option(rs::option::r200_lr_auto_exposure_enabled)) 86 | { 87 | int value = !dev->get_option(rs::option::r200_lr_auto_exposure_enabled); 88 | std::cout << "Setting auto exposure to " << value << std::endl; 89 | dev->set_option(rs::option::r200_lr_auto_exposure_enabled, value); 90 | } 91 | break; 92 | } 93 | }); 94 | glfwMakeContextCurrent(win); 95 | 96 | while (!glfwWindowShouldClose(win)) 97 | { 98 | // Wait for new images 99 | glfwPollEvents(); 100 | dev.wait_for_frames(); 101 | 102 | // Clear the framebuffer 103 | int w,h; 104 | glfwGetFramebufferSize(win, &w, &h); 105 | glViewport(0, 0, w, h); 106 | glClear(GL_COLOR_BUFFER_BIT); 107 | 108 | // Draw the images 109 | glPushMatrix(); 110 | glfwGetWindowSize(win, &w, &h); 111 | glOrtho(0, w, h, 0, -1, +1); 112 | buffers[0].show(dev, align_color_to_depth ? rs::stream::color_aligned_to_depth : (color_rectification_enabled ? rs::stream::rectified_color : rs::stream::color), 0, 0, w/2, h/2); 113 | buffers[1].show(dev, align_depth_to_color ? (color_rectification_enabled ? rs::stream::depth_aligned_to_rectified_color : rs::stream::depth_aligned_to_color) : rs::stream::depth, w/2, 0, w-w/2, h/2); 114 | buffers[2].show(dev, rs::stream::infrared, 0, h/2, w/2, h-h/2); 115 | buffers[3].show(dev, rs::stream::infrared2, w/2, h/2, w-w/2, h-h/2); 116 | glPopMatrix(); 117 | glfwSwapBuffers(win); 118 | } 119 | 120 | glfwDestroyWindow(win); 121 | glfwTerminate(); 122 | return EXIT_SUCCESS; 123 | } 124 | catch(const rs::error & e) 125 | { 126 | std::cerr << "RealSense error calling " << e.get_failed_function() << "(" << e.get_failed_args() << "):\n " << e.what() << std::endl; 127 | return EXIT_FAILURE; 128 | } 129 | catch(const std::exception & e) 130 | { 131 | std::cerr << e.what() << std::endl; 132 | return EXIT_FAILURE; 133 | } 134 | -------------------------------------------------------------------------------- /src/libuvc/init.c: -------------------------------------------------------------------------------- 1 | /********************************************************************* 2 | * Software License Agreement (BSD License) 3 | * 4 | * Copyright (C) 2010-2012 Ken Tossell 5 | * All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions 9 | * are met: 10 | * 11 | * * Redistributions of source code must retain the above copyright 12 | * notice, this list of conditions and the following disclaimer. 13 | * * Redistributions in binary form must reproduce the above 14 | * copyright notice, this list of conditions and the following 15 | * disclaimer in the documentation and/or other materials provided 16 | * with the distribution. 17 | * * Neither the name of the author nor other contributors may be 18 | * used to endorse or promote products derived from this software 19 | * without specific prior written permission. 20 | * 21 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 22 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 23 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 24 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 25 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 26 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 27 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 28 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 29 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 30 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 31 | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 32 | * POSSIBILITY OF SUCH DAMAGE. 33 | *********************************************************************/ 34 | /** 35 | \mainpage libuvc: a cross-platform library for USB video devices 36 | 37 | \b libuvc is a library that supports enumeration, control and streaming 38 | for USB Video Class (UVC) devices, such as consumer webcams. 39 | 40 | \section features Features 41 | \li UVC device \ref device "discovery and management" API 42 | \li \ref streaming "Video streaming" (device to host) with asynchronous/callback and synchronous/polling modes 43 | \li Read/write access to standard \ref ctrl "device settings" 44 | \li \ref frame "Conversion" between various formats: RGB, YUV, JPEG, etc. 45 | \li Tested on Mac and Linux, portable to Windows and some BSDs 46 | 47 | \section roadmap Roadmap 48 | \li Bulk-mode image capture 49 | \li One-shot image capture 50 | \li Improved support for standard settings 51 | \li Support for "extended" (vendor-defined) settings 52 | 53 | \section misc Misc. 54 | \p The source code can be found at https://github.com/ktossell/libuvc. To build 55 | the library, install libusb 1.0+ and run: 56 | 57 | \code 58 | $ git clone https://github.com/ktossell/libuvc.git 59 | $ cd libuvc 60 | $ mkdir build 61 | $ cd build 62 | $ cmake -DCMAKE_BUILD_TYPE=Release .. 63 | $ make && make install 64 | \endcode 65 | 66 | \section Example 67 | In this example, libuvc is used to acquire images in a 30 fps, 640x480 68 | YUV stream from a UVC device such as a standard webcam. 69 | 70 | \include example.c 71 | 72 | */ 73 | 74 | /** 75 | * @defgroup init Library initialization/deinitialization 76 | * @brief Setup routines used to construct UVC access contexts 77 | */ 78 | #include "libuvc.h" 79 | #include "libuvc_internal.h" 80 | 81 | /** @internal 82 | * @brief Event handler thread 83 | * There's one of these per UVC context. 84 | * @todo We shouldn't run this if we don't own the USB context 85 | */ 86 | void *_uvc_handle_events(void *arg) { 87 | uvc_context_t *ctx = (uvc_context_t *) arg; 88 | 89 | while (!ctx->kill_handler_thread) 90 | { 91 | if (ctx->usb_ctx) libusb_handle_events(ctx->usb_ctx); 92 | else break; 93 | } 94 | 95 | return NULL; 96 | } 97 | 98 | /** @brief Initializes the UVC context 99 | * @ingroup init 100 | * 101 | * @note If you provide your own USB context, you must handle 102 | * libusb event processing using a function such as libusb_handle_events. 103 | * 104 | * @param[out] pctx The location where the context reference should be stored. 105 | * @param[in] usb_ctx Optional USB context to use 106 | * @return Error opening context or UVC_SUCCESS 107 | */ 108 | uvc_error_t uvc_init(uvc_context_t **pctx, struct libusb_context *usb_ctx) { 109 | uvc_error_t ret = UVC_SUCCESS; 110 | uvc_context_t *ctx = calloc(1, sizeof(*ctx)); 111 | 112 | if (usb_ctx == NULL) { 113 | ret = libusb_init(&ctx->usb_ctx); 114 | ctx->own_usb_ctx = 1; 115 | if (ret != UVC_SUCCESS) { 116 | free(ctx); 117 | ctx = NULL; 118 | } 119 | } else { 120 | ctx->own_usb_ctx = 0; 121 | ctx->usb_ctx = usb_ctx; 122 | } 123 | 124 | if (ctx != NULL) 125 | *pctx = ctx; 126 | 127 | return ret; 128 | } 129 | 130 | /** 131 | * @brief Closes the UVC context, shutting down any active cameras. 132 | * @ingroup init 133 | * 134 | * @note This function invalides any existing references to the context's 135 | * cameras. 136 | * 137 | * If no USB context was provided to #uvc_init, the UVC-specific USB 138 | * context will be destroyed. 139 | * 140 | * @param ctx UVC context to shut down 141 | */ 142 | void uvc_exit(uvc_context_t *ctx) { 143 | uvc_device_handle_t *devh; 144 | 145 | DL_FOREACH(ctx->open_devices, devh) { 146 | uvc_close(devh); 147 | } 148 | 149 | if (ctx->own_usb_ctx) 150 | libusb_exit(ctx->usb_ctx); 151 | 152 | free(ctx); 153 | } 154 | 155 | /** 156 | * @internal 157 | * @brief Spawns a handler thread for the context 158 | * @ingroup init 159 | * 160 | * This should be called at the end of a successful uvc_open if no devices 161 | * are already open (and being handled). 162 | */ 163 | void uvc_start_handler_thread(uvc_context_t *ctx) { 164 | if (ctx->own_usb_ctx) 165 | pthread_create(&ctx->handler_thread, NULL, _uvc_handle_events, (void*) ctx); 166 | } 167 | 168 | -------------------------------------------------------------------------------- /src/libuvc/ctrl.c: -------------------------------------------------------------------------------- 1 | /********************************************************************* 2 | * Software License Agreement (BSD License) 3 | * 4 | * Copyright (C) 2010-2012 Ken Tossell 5 | * All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions 9 | * are met: 10 | * 11 | * * Redistributions of source code must retain the above copyright 12 | * notice, this list of conditions and the following disclaimer. 13 | * * Redistributions in binary form must reproduce the above 14 | * copyright notice, this list of conditions and the following 15 | * disclaimer in the documentation and/or other materials provided 16 | * with the distribution. 17 | * * Neither the name of the author nor other contributors may be 18 | * used to endorse or promote products derived from this software 19 | * without specific prior written permission. 20 | * 21 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 22 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 23 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 24 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 25 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 26 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 27 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 28 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 29 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 30 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 31 | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 32 | * POSSIBILITY OF SUCH DAMAGE. 33 | *********************************************************************/ 34 | /** 35 | * @defgroup ctrl Video capture and processing controls 36 | * @brief Functions for manipulating device settings and stream parameters 37 | * 38 | * The `uvc_get_*` and `uvc_set_*` functions are used to read and write the settings associated 39 | * with the device's input, processing and output units. 40 | */ 41 | 42 | #include "libuvc.h" 43 | #include "libuvc_internal.h" 44 | 45 | static const int REQ_TYPE_SET = 0x21; 46 | static const int REQ_TYPE_GET = 0xa1; 47 | 48 | /***** GENERIC CONTROLS *****/ 49 | /** 50 | * @brief Get the length of a control on a terminal or unit. 51 | * 52 | * @param devh UVC device handle 53 | * @param unit Unit or Terminal ID; obtain this from the uvc_extension_unit_t describing the extension unit 54 | * @param ctrl Vendor-specific control number to query 55 | * @return On success, the length of the control as reported by the device. Otherwise, 56 | * a uvc_error_t error describing the error encountered. 57 | * @ingroup ctrl 58 | */ 59 | int uvc_get_ctrl_len(uvc_device_handle_t *devh, uint8_t unit, uint8_t ctrl) { 60 | unsigned char buf[2]; 61 | 62 | int ret = libusb_control_transfer( 63 | devh->usb_devh, 64 | REQ_TYPE_GET, UVC_GET_LEN, 65 | ctrl << 8, 66 | unit << 8, 67 | buf, 68 | 2, 69 | 0 /* timeout */); 70 | 71 | if (ret < 0) 72 | return ret; 73 | else 74 | return (unsigned short)SW_TO_SHORT(buf); 75 | } 76 | 77 | /** 78 | * @brief Perform a GET_* request from an extension unit. 79 | * 80 | * @param devh UVC device handle 81 | * @param unit Unit ID; obtain this from the uvc_extension_unit_t describing the extension unit 82 | * @param ctrl Control number to query 83 | * @param data Data buffer to be filled by the device 84 | * @param len Size of data buffer 85 | * @param req_code GET_* request to execute 86 | * @return On success, the number of bytes actually transferred. Otherwise, 87 | * a uvc_error_t error describing the error encountered. 88 | * @ingroup ctrl 89 | */ 90 | int uvc_get_ctrl(uvc_device_handle_t *devh, uint8_t unit, uint8_t ctrl, void *data, int len, enum uvc_req_code req_code) { 91 | return libusb_control_transfer( 92 | devh->usb_devh, 93 | REQ_TYPE_GET, req_code, 94 | ctrl << 8, 95 | unit << 8, 96 | data, 97 | len, 98 | 0 /* timeout */); 99 | } 100 | 101 | /** 102 | * @brief Perform a SET_CUR request to a terminal or unit. 103 | * 104 | * @param devh UVC device handle 105 | * @param unit Unit or Terminal ID 106 | * @param ctrl Control number to set 107 | * @param data Data buffer to be sent to the device 108 | * @param len Size of data buffer 109 | * @return On success, the number of bytes actually transferred. Otherwise, 110 | * a uvc_error_t error describing the error encountered. 111 | * @ingroup ctrl 112 | */ 113 | int uvc_set_ctrl(uvc_device_handle_t *devh, uint8_t unit, uint8_t ctrl, void *data, int len) { 114 | return libusb_control_transfer( 115 | devh->usb_devh, 116 | REQ_TYPE_SET, UVC_SET_CUR, 117 | ctrl << 8, 118 | unit << 8, 119 | data, 120 | len, 121 | 0 /* timeout */); 122 | } 123 | 124 | /***** INTERFACE CONTROLS *****/ 125 | uvc_error_t uvc_get_power_mode(uvc_device_handle_t *devh, enum uvc_device_power_mode *mode, enum uvc_req_code req_code) { 126 | uint8_t mode_char; 127 | uvc_error_t ret; 128 | 129 | ret = libusb_control_transfer( 130 | devh->usb_devh, 131 | REQ_TYPE_GET, req_code, 132 | UVC_VC_VIDEO_POWER_MODE_CONTROL << 8, 133 | 0, 134 | &mode_char, 135 | sizeof(mode_char), 136 | 0); 137 | 138 | if (ret == 1) { 139 | *mode = mode_char; 140 | return UVC_SUCCESS; 141 | } else { 142 | return ret; 143 | } 144 | } 145 | 146 | uvc_error_t uvc_set_power_mode(uvc_device_handle_t *devh, enum uvc_device_power_mode mode) { 147 | uint8_t mode_char = mode; 148 | uvc_error_t ret; 149 | 150 | ret = libusb_control_transfer( 151 | devh->usb_devh, 152 | REQ_TYPE_SET, UVC_SET_CUR, 153 | UVC_VC_VIDEO_POWER_MODE_CONTROL << 8, 154 | 0, 155 | &mode_char, 156 | sizeof(mode_char), 157 | 0); 158 | 159 | if (ret == 1) 160 | return UVC_SUCCESS; 161 | else 162 | return ret; 163 | } 164 | 165 | /** @todo Request Error Code Control (UVC 1.5, 4.2.1.2) */ 166 | --------------------------------------------------------------------------------