Realsense provided by Intel is a camera device with a depth perception function. It doesn't officially support mac, but it can be run with an unofficial library called librealsense.
Open a terminal and execute the following command line by line in your home directory
Terminal
$ brew install python
$ brew install libusb pkg-config
$ brew install homebrew/core/glfw3
$ brew install cmake
$ brew install boost
$ brew install flann
$ brew install vtk5 –with-qt
$ git clone https://github.com/PointCloudLibrary/pcl
$ cd pcl
$ mkdir build && cd build
$ cmake ..
$ make
$ sudo make install
Return to your home directory with the cd
command and install the main body of librealsense.
Replace the absolute path of Python you are using
on the third line with the path output by which python
.
Terminal
$ git clone https://github.com/IntelRealSense/librealsense.git
$ cd librealsense
$ mkdir build && cd build
$ cmake .. -DBUILD_EXAMPLES=true -DBUILD_WITH_OPENMP=false -DHWM_OVER_XU=false -DBUILD_PYTHON_BINDINGS=true -DPYTHON_EXECUTABLE:FILEPATH=Absolute path of Pyhton you are using-G "Unix Makefiles"
$ make -j2
$ sudo make install
In my environment, the Python version did not work on 3.8 series, so change the version to 3.6 series in advance (this time I will use python 3.6.7)
Return to the / libresense
directory
Terminal
$ pyenv install 3.6.7
$ pyenv local 3.6.7
Use the pyenv versions
command to check that the area under the/libresense
directory is python3.6.7.
Also, I think that it will not work as it is, so check the location where the so file is stored (hereinafter A) by the following procedure.
librealsense/build/CMakeCache.txt
with VS Code etc.command + F
and search for PYTHON_INSTALL_DIR: PATH
PYTHON_INSTALL_DIR: PATH: PATH = xxx
, is the so file (A)Check where to put the symbolic (B)
Terminal
$ python3
>>>import site; site.getsitepackages()
After that, move to the confirmed location (B) and create a symbolic
Terminal
$Absolute path to cd B
$ ln -s Confirmed so file path(A)/pyrealsense2.cpython-36m-darwin.so pyrealsense2.so
$ ln -s Confirmed so file path(A)/pybackend2.cpython-36m-darwin.so pybackend2.so
Check if the import of pyrealsense2
passes
Terminal
$ python
>>> import pyrealsense2
>>>
If import
passes like this, it's OK
Connect mac and Realsense via USB, move to the directory where the sample files are located, and execute
Terminal
$ cd ~/librealsense/wrappers/python/examples
$python File name you want to run
reference (Reference Qiita1) [https://qiita.com/mizumasa/items/c6ca2c73fa86c9a5a39c]
(Reference Qiita2) [https://qiita.com/comachi/items/14b358568365bc5ee474]
Recommended Posts