Main /
Intel RealSenseIntel RealSense is a 3D camera connected via USB See Also
MacInstead of brew install homebrew/core/glfw3 Use brew install glfw3 Set up: brew install libusb pkg-config brew install glfw3 brew install cmake Download, configure for makefiles and build: git clone https://github.com/IntelRealSense/librealsense cd librealsense mkdir build && cd build cmake .. -DBUILD_EXAMPLES=true -DBUILD_WITH_OPENMP=false -DHWM_OVER_XU=false -DBUILD_GRAPHICAL_EXAMPLES=true -DBUILD_PYTHON_BINDINGS=true -DBUILD_PYTHON_DOCS=true -DPYTHON_EXECUTABLE=/opt/local/bin/python3.10 -G "Unix Makefiles" make Mac PythonMac Python 2.xHere's what worked for me under macOS 10.14.4 (Mojave) with /usr/bin/python 2.7.10: git clone https://github.com/IntelRealSense/librealsense brew install cmake libusb pkg-config cd librealsense mkdir build cd build cmake .. -DBUILD_EXAMPLES=true -DBUILD_WITH_OPENMP=false -DHWM_OVER_XU=false -DBUILD_PYTHON_BINDINGS=true -DPYTHON_EXECUTABLE=/System/Library/Frameworks/Python.framework/Versions/2.7/bin/python -DCMAKE_MACOSX_RPATH=ON -DCMAKE_INSTALL_RPATH="/usr/local/lib" -G "Unix Makefiles" rm -f *.dylib wrappers/python/*.so make install cd ../wrappers/python/ cp /usr/local/lib/*realsense* pyrealsense2/ python find_librs_version.py /usr/local/ pyrealsense2 sudo python setup.py install See below for details. Mac Python 2.x problemshttps://github.com/IntelRealSense/librealsense/issues/3260 How can i build the python wrapper from source in mac os environment suggests using PYTHON_EXECUTABLE: cmake ../ -DBUILD_EXAMPLES=true -DBUILD_WITH_OPENMP=false -DHWM_OVER_XU=false -G Xcode -DBUILD_PYTHON_BINDINGS=bool:true -DPYTHON_EXECUTABLE=/Library/Frameworks/Python.framework/Versions/2.7/bin/python2 However, I have no /Library/Frameworks/Python.framework, instead it is at /System/Library/Frameworks/Python.framework bash-3.2$ which python /usr/bin/python bash-3.2$ python Python 2.7.10 (default, Feb 22 2019, 21:17:52) [GCC 4.2.1 Compatible Apple LLVM 10.0.1 (clang-1001.0.37.14)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> import sys >>> sys.path ['', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python27.zip', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-darwin', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac/lib-scriptpackages', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-old', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload', '/Users/cxh/Library/Python/2.7/lib/python/site-packages', '/usr/local/lib/python2.7/site-packages', '/usr/local/lib/python2.7/site-packages/gtk-2.0', '/Library/Python/2.7/site-packages', '/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python', '/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/PyObjC'] >>> sys.prefix '/System/Library/Frameworks/Python.framework/Versions/2.7' >>> sys.exec_prefix sys.exec_prefix '/System/Library/Frameworks/Python.framework/Versions/2.7' So I did: cmake .. -DBUILD_EXAMPLES=true -DBUILD_WITH_OPENMP=false -DHWM_OVER_XU=false -DBUILD_PYTHON_BINDINGS=true -DPYTHON_EXECUTABLE=/System/Library/Frameworks/Python.framework/Versions/2.7/bin/python -G "Unix Makefiles" make (:sourceend) Copying the shared libraries to the current directory does not seem to help: (:source:) bash-3.2% mkdir tmp bash-3.2$ cd tmp bash-3.2$ cp /usr/local/lib/*realsense* . bash-3.2$ python Python 2.7.10 (default, Feb 22 2019, 21:17:52) [GCC 4.2.1 Compatible Apple LLVM 10.0.1 (clang-1001.0.37.14)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> import pyrealsense2 Traceback (most recent call last): File "<stdin>", line 1, in <module> ImportError: dlopen(./pyrealsense2.so, 2): Library not loaded: @rpath/librealsense2.2.35.dylib Referenced from: /Users/cxh/src/librealsense/build/tmp/pyrealsense2.so Reason: image not found >>> -DCMAKE_MACOSX_RPATH=ON -DCMAKE_INSTALL_RPATH="/opt/dev/versions/vtk/vtk-7.1.0-shared/lib" So I tried: cmake .. -DBUILD_EXAMPLES=true -DBUILD_WITH_OPENMP=false -DHWM_OVER_XU=false -DBUILD_PYTHON_BINDINGS=true -DPYTHON_EXECUTABLE=/System/Library/Frameworks/Python.framework/Versions/2.7/bin/python -DCMAKE_MACOSX_RPATH=ON -DCMAKE_INSTALL_RPATH="/usr/local/lib" -G "Unix Makefiles" I want to support both Python 2.x and 3.x. So, I created a /usr/local/realsense/python/2.7.10/ rm *.dylib wrappers/python/*.so cmake .. -DBUILD_EXAMPLES=true -DBUILD_WITH_OPENMP=false -DHWM_OVER_XU=false -DBUILD_PYTHON_BINDINGS=true -DPYTHON_EXECUTABLE=/System/Library/Frameworks/Python.framework/Versions/2.7/bin/python -DCMAKE_MACOSX_RPATH=ON -DCMAKE_INSTALL_RPATH="/usr/local/realsense/python/2.7.10" -DCMAKE_INSTALL_PREFIX="/usr/local/realsense/python/2.7.10" -G "Unix Makefiles" make install However, running (cd ../wrappers/python; cp /usr/local/realsense/python/2.7.10/lib/*.so /usr/local/realsense/python/2.7.10/lib/*.dylib pyrealsense2; python setup.py install) fails: Traceback (most recent call last): File "setup.py", line 5, in <module> from pyrealsense2._version import __version__ File "/Users/cxh/src/librealsense/wrappers/python/pyrealsense2/__init__.py", line 2, in <module> from .pyrealsense2 import * ImportError: dlopen(/Users/cxh/src/librealsense/wrappers/python/pyrealsense2/pyrealsense2.so, 2): Library not loaded: @rpath/librealsense2.2.35.dylib Referenced from: /Users/cxh/src/librealsense/wrappers/python/pyrealsense2/pyrealsense2.so Reason: image not found Switching back to the previous cmake: cmake .. -DBUILD_EXAMPLES=true -DBUILD_WITH_OPENMP=false -DHWM_OVER_XU=false -DBUILD_PYTHON_BINDINGS=true -DPYTHON_EXECUTABLE=/System/Library/Frameworks/Python.framework/Versions/2.7/bin/python -DCMAKE_MACOSX_RPATH=ON -DCMAKE_INSTALL_RPATH="/usr/local/lib" -G "Unix Makefiles" rm *.dylib wrappers/python/*.so make install cd ../wrappers/python/ cp /usr/local/lib/*realsense* pyrealsense2/ bash-3.2$ python setup.py install python setup.py install Traceback (most recent call last): File "setup.py", line 5, in <module> from pyrealsense2._version import __version__ ImportError: No module named _version bash-3.2$ python find_librs_version.py /usr/local/ pyrealsense2 python setup.py install Fails with a permissions problem, but sudo -i and then running that command seems to work! Mac Python 3.xFebruary 2023: pyrealsense2 support for Python 3.11 #11362 is incomplete, so use Python 3.10 export PATH=/usr/local/bin:${PATH} git clone https://github.com/IntelRealSense/librealsense brew install cmake libusb pkg-config cd librealsense mkdir build cd build mkdir -p /usr/local/realsense/python/3.10.8 cmake .. -DBUILD_EXAMPLES=true -DBUILD_WITH_OPENMP=false -DHWM_OVER_XU=false -DBUILD_PYTHON_BINDINGS=true -DPYTHON_EXECUTABLE=/opt\ /local/Library/Frameworks/Python.framework/Versions/3.10/bin/python3.10 -DCMAKE_MACOSX_RPATH=ON -DCMAKE_INSTALL_RPATH="/usr/local/\ realsense/python/3.10.8" -G "Unix Makefiles" make install cd ../wrappers/python/ cp /usr/local/lib/*realsense* pyrealsense2/ python find_librs_version.py /usr/local/ pyrealsense2 sudo /usr/local/opt/python@3.8/bin/python setup.py install export PYTHONPATH=$PYTHONPATH:/usr/local/lib Sample run: bash-3.2$ python Python 3.8.3 (default, May 27 2020, 20:53:40) [Clang 11.0.0 (clang-1100.0.33.17)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> import pyrealsense2 >>> quit() Mac Python3 problemspython2.7: bad interpreter[ 53%] Linking CXX shared library pybackend2.cpython-310-darwin.so ld: warning: directory not found for option '-L/usr/local/opt/ruby/lib' ld: warning: directory not found for option '-L/usr/local/opt/ruby/lib' [ 53%] Built target pybackend2 [ 54%] Building HTML documentation for pyrealsense2 with Sphinx /bin/sh: /usr/local/bin/sphinx-build: /usr/local/opt/python@2/bin/python2.7: bad interpreter: No such file or directory make[2]: *** [wrappers/python/docs/CMakeFiles/pyrealsense2_docs] Error 126 make[1]: *** [wrappers/python/docs/CMakeFiles/pyrealsense2_docs.dir/all] Error 2 make: *** [all] Error 2 Solution: Then pip3 install sphinx Note that I had to be sure that Mac Node.jsnpm install -g jsdoc npm install -g node-gyp cd ../wrappers/nodejs npm install Missing libraryError: SOLINK_MODULE(target) Release/node_librealsense.node clang: error: no such file or directory: '/Users/cxh/src/ptII11.0.devel/librealsense/wrappers/nodejs/../../build/Release/librealsen Solution: bash-3.2$ mkdir ../../build/Release bash-3.2$ (cd ../../build/Release; ln -s ../libreal* .) bash-3.2$ ls ../../build/Release/ librealsense2.2.10.4.dylib librealsense2.dylib librealsense2.2.dylib bash-3.2$ Error: Cannot find module 'node-glfw-3'bash-3.2$ cd examples/ bash-3.2$ ls CMakeLists.txt nodejs-capture.js package-lock.json glfw-window.js nodejs-pointcloud.js package.json nodejs-align.js nodejs-save-to-disk.js sensor_control bash-3.2$ node nodejs-capture.js module.js:472 throw err; ^ Error: Cannot find module 'node-glfw-3' at Function.Module._resolveFilename (module.js:470:15) at Function.Module._load (module.js:418:25) at Module.require (module.js:498:17) at require (internal/module.js:20:19) at Object.<anonymous> (/Users/cxh/src/ptII11.0.devel/librealsense/wrappers/nodejs/examples\ /glfw-window.js:7:14) at Module._compile (module.js:571:32) at Object.Module._extensions..js (module.js:580:10) at Module.load (module.js:488:32) at tryModuleLoad (module.js:447:12) at Function.Module._load (module.js:439:3) bash-3.2$ Solution: npm install node-glfw-3 Also: npm install performance-now Then, this starts up: node nodejs-capture.js node nodejs-capture.js hangsRunning node nodejs-capture.js hangs. Adding logging statements to console.log("before pipeline.start()"); // Start the camera pipeline.start(); console.log("after pipeline.start()"); and then running: bash-3.2$ node nodejs-capture.js before pipeline.start() C-c C-c bash-3.2$ In console.log('test-pipeline.js start:'); let ctx; let pipeline; describe('Pipeline test', function() { before(function() { console.log('test-pipeline.jss before()'); ctx = new rs2.Context(); const devices = ctx.queryDevices().devices; assert(devices.length > 0); // Device must be connected console.log('test-pipeline.jss before() done'); }); Run: bash-3.2$ mocha test-pipeline.js test-pipeline.js start: Pipeline test test-pipeline.jss before() C-c C-cTerminated: 15 bash-3.2 The above was with I installed a new version of node: brew install node export PATH=/usr/local/Cellar/node/9.11.1/bin:/usr/local/Cellar/node/9.11.1//libexec/bin:${PATH} cd librealsense/wrappers/nodejs/ rm -rf node_modules mkdir node_modules npm install -g jsdoc npm i npm npm i npm npm install -g jsdoc npm install -g node-gyp npm install mocha bash-3.2$ which node /usr/local/Cellar/node/9.11.1/bin/node bash-3.2$ node --version v9.11.1 bash-3.2$ which npm /usr/local/Cellar/node/9.11.1//libexec/bin/npm bash-3.2$ npm --version 5.6.0 bash-3.2 Edited describe('DeviceList test', function() { beforeEach(function() { console.log('test-devicelist.js: beforeEach() start'); ctx = new rs2.Context(); devl = ctx.queryDevices(); console.log('test-devicelist.js: beforeEach() end'); }); bash-3.2$ cd test bash-3.2$ ../node_modules/.bin/mocha --version 5.1.1 bash-3.2$ ../node_modules/.bin/mocha test-devicelist.js DeviceList test test-devicelist.js: beforeEach() start test-devicelist.js: beforeEach() end 1) "before each" hook for "Testing constructor" 0 passing (10s) 1 failing 1) DeviceList test "before each" hook for "Testing constructor": Error: Timeout of 2000ms exceeded. For async tests and hooks, ensure "done()" is called; \ if returning a Promise, ensure it resolves. (/Users/cxh/src/librealsense/wrappers/nodejs/test/\ test-devicelist.js) bash-3.2$ Then I tried it('Testing member size', () => { console.log('test-devicelist.js: testing member size start'); assert.equal(typeof devl.size, 'number'); console.log('test-devicelist.js: testing member size end'); }); it('Testing member back', () => { console.log('test-devicelist.js: testing member back start'); let dev = devl.devices; assert(dev.length > 0); // Device must be connected let device = devl.getDevice(dev.length -1); let SN = device.getCameraInfo().serialNumber; assert.doesNotThrow(() => { if (devl.size > 0) { let res = devl.back; assert(devl.back instanceof rs2.Device); assert.equal(typeof res, 'object'); assert.equal(res.getCameraInfo().serialNumber, SN); } }); console.log('test-devicelist.js: testing member back end'); }); bash-3.2$ ../node_modules/.bin/mocha test-devicelist.js test-devicelist.js: before testing member size DeviceList test test-devicelist.js: beforeEach() start test-devicelist.js: beforeEach() end test-devicelist.js: testing constructor ✓ Testing constructor test-devicelist.js: beforeEach() start test-devicelist.js: beforeEach() end ✓ Testing member devices test-devicelist.js: beforeEach() start test-devicelist.js: beforeEach() end test-devicelist.js: testing member size start test-devicelist.js: testing member size end ✓ Testing member size test-devicelist.js: beforeEach() start test-devicelist.js: beforeEach() end test-devicelist.js: testing member back start and then it hangs. See Bug #1592: Mac Node test-devicelist.js hangs Intel RealSense Java interface
How to build the Intel RealSense Java interface
Note about Gradle org.bven.jnipluginbuild.gradle contains id 'org.bven.jniplugin' version '0.0.5' The source for that plugin is at https://github.com/bgorven/JNIBuilder After cloning that repo, run To update the jar file, first find the jar file in your find ~/.gradle JNIBuilder-0.0.5.jar Then update the file. I did: mv build/libs/JNIBuilder-0.0.5.jar /Users/cxh/.gradle/caches/modules-2/files-2.1/gradle.plugin.org.bven.jniplugin/JNIBuilder/0.0.5/d6eb706c958f7bc78752d31f32c60014295f869e/JNIBuilder-0.0.5.jar Your paths will be different. Intel RealSense under VirtualBoxFailed to attach the USB device Intel(R) RealSense(TM) Depth Camera 435 [50C0] to the virtual machine Windows 10 Failed to create a proxy for the USB device. (Error: VER_PDM_NO_USB_PORTS) Result code: NS_ERROR_FAILURE (0x80004005) Component: Console Wrap Interface: IConsole {87...}
However, if I plug it in to another port on my MacBook Pro, then Virtual Box sees the device in its USB menu, but the Intel tools do not see it. |