<참조: https://pypi.python.org/pypi/pyrealsense/2.0>
<참조: https://pypi.org/project/pyrealsense/>
환경: ubuntu 16.04, SR300
1. windows에 realsense를 누른 후, Firmware update함.
2. 설치
* 현재 python wrapper는 pyrealsense 2.x를 지원하지 않음. pyrealsense 1.x만 지원함.
혹시 2.x가 설치되었다면 아래를 참고하여 삭제할 것.
*. 삭제를 원한다면
dpkg -l | grep "realsense" | cut -d " " -f 3 | xargs sudo dpkg --purge
2.1. 설치 (librealsense 1.x)
https://github.com/IntelRealSense/librealsense/tree/v1.12.1
https://github.com/IntelRealSense/librealsense/blob/v1.12.1/doc/installation.mdsudo
에서 download zip파일(우상단 다운로드 클릭)
관련 library설치
apt-get update
sudo apt-get install libusb-1.0-0-dev pkg-config
sudo apt-get install libglfw3-dev
librealsense 설치
cd librealsense-1.12.1
mkdir build
cd build
cmake ..
make && sudo make install
cd ..
sudo cp config/99-realsense-libusb.rules /etc/udev/rules.d/
sudo udevadm control --reload-rules && udevadm trigger
./scripts/patch-uvcvideo-16.04.simple.sh
sudo modprobe uvcvideo
sudo dmesg | tail -n 50
을 통해서 새 usbcore: registered ~~~인지 확인
sudo apt-get update
sudo apt-get install python-pycparser
sudo apt-get install cython
sudo apt-get install python-numpy
sudo pip install pyrealsense
설치실패시 아래 사이트 참조.
https://github.com/toinsson/pyrealsense/issues/66 참조
pyrealsense는 librealsense2를 지원못함.
순서1을 통해 v1을 설치후 실행하면 됨.
3. 소스코드 사용
import pyrealsense as pyrs
serv = pyrs.Service() serv.start() '''pyrc.stream.color.depth.cad (color aligned on depth).dac (depth aligned on color)''' cam = serv.Device(device_id=0, streams=[pyrs.stream.ColorStream(fps=60), pyrs.stream.DepthStream(fps=60) # pyrs.stream.CADStream(fps=60), # pyrs.stream.DACStream(fps=60) ]) scale = cam.depth_scale * 1000 while (True): cam.wait_for_frames() # print(cam.color) current_color = cam.color[:, :, ::-1] current_depth = cam.depth * scale # current_cad = cam.cad[:, :, ::-1] # current_dac = cam.dac * scale cv2.imshow('color', current_color) cv2.imshow('depth', current_depth / 1000) # cv2.imshow('CAD', current_cad) # cv2.imshow('DAC', current_dac / 1000) cv2.waitKey(10)