Giter Club home page Giter Club logo

pyrealsense's Introduction

PyRealsense

Cross-platform ctypes/Cython wrapper to the librealsense C-library version 1.x. This wrapper is useful for legacy models such as SR300, F200 and R200.

OBS: there is no plan to support librealsense 2.x, as Intel already provides the Python binding through pyrealsense2.

Prerequisites

  • install librealsense and run the examples.

  • install the dependencies: pyrealsense uses pycparser for extracting necessary enums and structures definitions from the librealsense API, Cython for wrapping the inlined functions in the librealsense API, and Numpy for generic data shuffling.

  • Windows specifics: set the environment variable PYRS_INCLUDES to the rs.h directory location and the environment variable PYRS_LIBS to the librealsense binary location. You might also need to have stdint.h available in your path.

Installation

from PyPI - (OBS: not always the latest):

pip install pyrealsense

from source:

python setup.py install

Online Usage

## setup logging
import logging
logging.basicConfig(level = logging.INFO)

## import the package
import pyrealsense as pyrs

## start the service - also available as context manager
serv = pyrs.Service()

## create a device from device id and streams of interest
cam = serv.Device(device_id = 0, streams = [pyrs.stream.ColorStream(fps = 60)])

## retrieve 60 frames of data
for _ in range(60):
    cam.wait_for_frames()
    print(cam.color)

## stop camera and service
cam.stop()
serv.stop()

The server for Realsense devices is started with pyrs.Service() which will printout the number of devices available. It can also be started as a context with with pyrs.Service():.

Different devices can be created from the service Device factory. They are created as their own class defined by device id, name, serial, firmware as well as enabled streams and camera presets. The default behaviour create a device with id = 0 and setup the color, depth, pointcloud, color_aligned_depth, depth_aligned_color and infrared streams.

The available streams are either native or synthetic, and each one will create a property that exposes the current content of the frame buffer in the form of device.<stream_name>, where <stream_name> is color, depth, points, cad, dac or infrared. To get access to new data, Device.wait_for_frames has to be called once per frame.

Offline Usage

## with connected device cam
from pyrealsense import offline
offline.save_depth_intrinsics(cam)
## previous device cam now offline
from pyrealsense import offline
offline.load_depth_intrinsics('610205001689')  # camera serial number
d = np.linspace(0, 1000, 480*640, dtype=np.uint16)
pc = offline.deproject_depth(d)

The module offline can store the rs_intrinsics and depth_scale of a device to disk by default in the user's home directory in the file .pyrealsense. This can later be loaded and used to deproject depth data into pointcloud, which is useful to store raw video file and save some disk memory.

Examples

The wrapper comes with some examples. You will need to install matplotlib, opencv and VTK to run everything. You can also look at the Jupyter Notebook.

Caveats

To this point, this wrapper has been tested with:

  • librealsense v1.12.1
  • Ubuntu 16.04 LTS, Mac OS X 10.12.2 w/ SR300 camera
  • Mac OS X 10.12.3 w/ R200 camera
  • Windows 10

The offline module only supports a single camera.

Build Status

Ubuntu Trusty, python 2 and 3: Build Status

Possible Pull Requests

Contributions are always welcome. Make sure to push to the dev branch.

Acknowledgements

This project has been developed as part of the E.U. Horizon 2020 research and innovation project Moregrasp (award number 643955).

pyrealsense's People

Contributors

0gm avatar andrewramsay avatar mathijsnl avatar organicirradiation avatar papr avatar toinsson avatar zacstewart avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

pyrealsense's Issues

Allow setting rs.h location with PYRS_INCLUDES var on *nix systems

Required Info
Camera Model n/a
Firmware Version n/a
Operating System & Version macOS, Linux
librealsense version n/a
pyrealsense version 1.4, 2.0

On a Linux system, I needed to build librealsense from scratch and wanted to install it in a local dir in my home directory instead of globally. constants.py has a hard-coded path to rs.h on Linux looking for a global install.

I'd like to set this path with PYRS_INCLUDES.

_apply_ivcam_preset Function Not Found

Hi there,

If I try to set an ivcam_preset like so:
c = pyrs.Device(ivcam_preset = 3)

I'm getting an error:

AttributeError: function '_apply_ivcam_preset' not found.

Librealsense is working otherwise, as are the associated examples.
I can run pyrealsense OpenCV example and the streams are displayed.

Thanks very much!

| Camera Model | SR300 |
| Operating System & Version | Windows 10 |
| pyrealsense version | 1.4 |

librealsense 2.0

What is the plan with respect to the new librealsense python wrapper? The developers at intel released a basic python wrapper in the their development branch recently, however it is in the early stages.
Thanks!

testing for ctypes branch

Hello, I was wondering if anybody could have a go at the ctypes branch.
It is an update to the library that should make it easier to customise the camera streams (which ones as well as parameters). It should also work on Python 2 and 3.

I have been testing on my setup and it works ok so far. Wanted to have some feedback before pushing to master. Especially since some of you are using OsX and Windows, which I have not been trying out so far.

get_stream_ctrl_format_size(...) returned Invalid mode

This is a separate issue to #41 that is explicitly about the invalid mode exception during wait_for_frames()

Required Info
Camera Model R200
Firmware Version 1.0.71.06, 1.0.72.06
Operating System & Version macOS Sierra 10.12.5
librealsense version 1.12.1
pyrealsense version 2.0
python version 3.6.0

I installed librealsense using homebrew and pyrealsense with pip.
Afterwards I tried running the opencv example with python3 show_cv2.py.

ERROR:pyrealsense.utils: get_stream_ctrl_format_size(...) returned Invalid mode

Full terminal output:
https://gist.github.com/papr/f5772772b960a6487fd870569c6b1d35

bad aligment between CAD stream and depth stream

| Required Info | |
| Camera Model | SR300 |
| Firmware Version | 3.15.0.0 |
| Operating System & Version | Ubuntu 14.04 |
| librealsense version | 1.12.1 |
| pyrealsense version | master |

I was trying to visualize the CAD stream which I think means color aligned with depth and depth stream. I am getting pretty bad alignment between the 2 streams. Can somebody point me to the correct way to visualize aligned color to depth or depth to color?
image

There seems to be a naming difference between this and librealsense

Required Info
Camera Model ZR300
Firmware Version 2.0.71.28
Operating System & Version Mac OSX 10.12.4
librealsense version 1.12.1
pyrealsense version 1.4

For example dev.colour and dev.wait_for_frame(). In the librealsense doc it is color and wait_for_frames. With no list of the method names used here it is hard to work with this library. Am I missing something?

Depth map of black pixels in an image is not coming

Camera Model: SR300
Firmware Version: firmware': '3.21.0.0'
Operating System & Version: macOS sierra 10.12.6
librealsense version: 1.12.1
pyrealsense version: 2.1

Required info:

I am trying to get the depth map using intel realsense SR300. However i am not getting the depth map for the black pixels of an image. example: for my hair i am getting 0 value in the depth map.

screen shot 2017-09-13 at 7 09 59 pm

I am wearing a stripes t-shirt having grey and red colour. Depth map for red stripe is generated however the grey colour depth map is not created. How to solve this problem? Even the depth of my hair, beard or anything black is not coming.

CODE:

import os
import sys
import cv2
import pyrealsense as pyrs
import numpy as np

def create_directory(directory):
    if not os.path.exists(directory):
        os.makedirs(directory)
        return 1
    else:
        print(directory, '- already exists')
        return 0


def check_directories():
    try:
        create_directory('./data')
        create_directory('./data/depth')
        create_directory('./data/color')
        create_directory('./data/cad')
        create_directory('./data/dac')
    except:
        print("Unexpected error:", sys.exc_info()[0])
       return -1
    return 0

def main():
    file_structure = check_directories()
    if file_structure == -1:
        print('\nERROR: Directories can\'t be created, error thrown')
        return -1
    else:
        print('\nDirectories created successfully...\nLaunching camera module...')

    # Fire camera & launch streams
    serv = pyrs.Service()
    serv.start()
    cam = serv.Device(device_id = 0, streams = [pyrs.stream.ColorStream(fps=10),
                                            pyrs.stream.DepthStream(fps=10),
                                            pyrs.stream.CADStream(fps=10),
                                            pyrs.stream.DACStream(fps=10),
                                            pyrs.stream.InfraredStream(fps=10),
                                            pyrs.stream.PointStream(fps=10)])
    scale = cam.depth_scale * 1000
    print "scale = ", scale 
    # Some important variables
    flag_save_frames = True
    file_num = 0

    # Start fetching Buffer
    print('Starting Buffer...')
    while(True):
        cam.wait_for_frames()
        current_color = cam.color[:,:,::-1]
        # print current_color.shape
        current_depth = cam.depth * scale
        current_cad = cam.cad[:,:,::-1]
        current_dac = cam.dac * scale
        print "max depth", np.max(current_dac)
        print "print depth val = ",np.max(cam.dac)
    
        cv2.imshow('Color',current_color)
        cv2.imshow('Depth',current_depth/1000)
        cv2.imshow('CAD',current_cad)
        cv2.imshow('DAC',current_dac/1000)

    

        if flag_save_frames:
            num = format(file_num, '08')
            cv2.imwrite('./data/depth/' + str(num) + '.png', cam.depth)
            cv2.imwrite('./data/color/' + str(num) + '.png', current_color)
            cv2.imwrite('./data/dac/' + str(num) + '.png', cam.dac)
            cv2.imwrite('./data/cad/' + str(num) + '.png', current_cad)
            file_num += 1

        k = cv2.waitKey(1)
        if k == ord('q'):
            print('Q Pressed...\nEnding execution')
            break
        if k == ord('f'):
            if flag_save_frames:
                print('F Pressed...\nStopped fetching frames...')
                flag_save_frames = False
            else:
                print('F Pressed...\nStarted fetching frames...')
                flag_save_frames = True

    cam.stop()
    serv.stop()

    return 0


if __name__ == '__main__':
    print(__doc__)
    main()

Can't install the library

When I tried to install (sudo python setup.py install), I got the followings. Do I need to copy rs.h by hand from librealsense?

running install
Checking .pth file support in /Library/Python/2.7/site-packages/
/usr/bin/python -E -c pass
TEST PASSED: /Library/Python/2.7/site-packages/ appears to support .pth files
running bdist_egg
running egg_info
writing pyrealsense.egg-info/PKG-INFO
writing top-level names to pyrealsense.egg-info/top_level.txt
writing dependency_links to pyrealsense.egg-info/dependency_links.txt
reading manifest file 'pyrealsense.egg-info/SOURCES.txt'
writing manifest file 'pyrealsense.egg-info/SOURCES.txt'
installing library code to build/bdist.macosx-10.12-intel/egg
running install_lib
running build_py
copying pyrealsense/constants.py -> build/lib.macosx-10.12-intel-2.7/pyrealsense
running build_ext
building 'pyrealsense.rsutilwrapper' extension
cc -fno-strict-aliasing -fno-common -dynamic -arch x86_64 -arch i386 -g -Os -pipe -fno-common -fno-strict-aliasing -fwrapv -DENABLE_DTRACE -DMACOSX -DNDEBUG -Wall -Wstrict-prototypes -Wshorten-64-to-32 -DNDEBUG -g -fwrapv -Os -Wall -Wstrict-prototypes -DENABLE_DTRACE -arch x86_64 -arch i386 -pipe -I/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/numpy/core/include -I/usr/local/include/librealsense -I/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c pyrealsense/rsutilwrapper.c -o build/temp.macosx-10.12-intel-2.7/pyrealsense/rsutilwrapper.o
pyrealsense/rsutilwrapper.c:1:10: fatal error: 'rs.h' file not found
#include "rs.h"
         ^
1 error generated.
error: command 'cc' failed with exit status 1

I'm using macOS 10.12.2

Any plans for the rectified streams?

This is not an actual issue but do you plan to add the streams such as RS_STREAM_RECTIFIED_COLOR and RS_STREAM_DEPTH_ALIGNED_TO_RECTIFIED_COLOR?

Using pyrealsense with Anaconda3 on Windows 10

Required Info
Camera Model SR300
Firmware Version 3.3.27.5718
Operating System & Version Windows 10 Education
librealsense version 1.12.1
pyrealsense version 2.1

Hello, I'm senior grade student in South Korea and because of that I'm not good at using English well.

First, thank you very much for your support to using Intel RealSense on Python environment.
But, I have a problem in using pyrealsense.

I have librealsense 1.12.1 version and compiled examples successfully on VS2015 Update 3 version.
After compiled librealsense in two platform(Win32, x64), I got library files that named 'realsense-d.dll', 'realsense-d.exp', 'realsense-d.lib', 'realsense-d.lik', 'realsense-d.pdb' in both folders (librealsense's Directory)\bin\Win32, (librealsense's Directory)\bin\x64.

(librealsense's Directory)\bin\Win32

01 win32 library

(librealsense's Directory)\bin\x64

02 x64 library

And I added (librealsense's Directory)\include\librealsense in user environment named 'PYRS_INCLUDES' and I thought that the pyrealsense needs 'realsense.dll', 'realsense.lib', … . So I copied and changed name of that files and added bin's directory in user environment named 'PYRS_LIBS' too.

PYRS_INCLUDES

04 pyrs_includes
03 include

PYRS_LIBS

05 pyrs_libs

After that, I've installed pyrealsense successfully using Anaconda Prompt. But when I try to run example code(Online Usage), some errors occur like below.

Running Online Usage code on Spyder 3

06 spyder error

I've tried to fix this problem all day long but I couldn't fix it. Please help me anyone..

unresolved external symbol PyInit_rsutilwrapper

Hi,
thank you for your work. I am trying to compile this for windows 10, but I am stuck at this error.
I compiled librealsense lib with Visual Studio for Windows in 32 bit.

C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\x86_amd64\link.exe /nologo /INCREMENTAL:NO /LTCG /DLL /MANIFEST:EMBED,ID=2 /MANIFESTUAC:NO /LIBPATH:C:/Users/user/Projects/librealsense/bin/Win32 "/LIBPATH:C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\LIB\amd64" "/LIBPATH:C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\ATLMFC\LIB\amd64" "/LIBPATH:C:\Program Files (x86)\Windows Kits\10\lib\10.0.10240.0\ucrt\x64" "/LIBPATH:C:\Program Files (x86)\Windows Kits\NETFXSDK\4.6.1\lib\um\x64" "/LIBPATH:C:\Program Files (x86)\Windows Kits\8.1\lib\winv6.3\um\x64" realsense.lib /EXPORT:PyInit_rsutilwrapper build\temp.win-amd64-3.5\Release\pyrealsense/rsutilwrapper.obj /OUT:build\lib.win-amd64-3.5\pyrealsense\rsutilwrapper.cp35-win_amd64.pyd /IMPLIB:build\temp.win-amd64-3.5\Release\pyrealsense\rsutilwrapper.cp35-win_amd64.lib LINK : error LNK2001: unresolved external symbol PyInit_rsutilwrapper build\temp.win-amd64-3.5\Release\pyrealsense\rsutilwrapper.cp35-win_amd64.lib : fatal error LNK1120: 1 unresolved externals error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\BIN\\x86_amd64\\link.exe' failed with exit status 1120

Do you have an idea how to fix it?

Thanks!

AttributeError: 'Service' object has no attribute 'Device'

Required Info
Camera Model SR300
Firmware Version 3.21.0.0
Operating System & Version inux 4.11.9-1-ARCH
librealsense version librealsense.so.1.12.1
pyrealsense version 2.0

When running the "Online Usage" script from the Readme.md I get following error:

Traceback (most recent call last):
  File "test.py", line 12, in <module>
    cam = serv.Device(device_id = 0, streams = [pyrs.stream.ColorStream(fps = 60)])
AttributeError: 'Service' object has no attribute 'Device'

After looking into the code of pyrealsense to see if there was any renaming or the sample is not up to date I tried in a REPL to see what the problem is:

Python 3.6.2 (default, Jul 20 2017, 03:52:27)
[GCC 7.1.1 20170630] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import pyrealsense as pyrs
>>> pyrs.Service
<class 'pyrealsense.core.Service'>
>>> serv = pyrs.Service()
>>> serv
<pyrealsense.core.Service object at 0x7f8e29121160>
>>> serv.get_devices
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'Service' object has no attribute 'get_devices'

And it looks thats somehow the Service object is not a real Service object or is not initialized.

The librealsense SDK works and all their sample applications too, so I can rule that error-source out.

Any thoughts / ideas on this ?

How to adjust exposure time of the Color camera of R200 sensor?

Hi,

I was wondering how can I create a color stream with the RGB camera's auto exposure disabled. I know that it is possible from the Intel realsense's SDK, but does librealsense allow it. If yes, what API calls need to be made from Pyrealsense.

Required Info
Camera Model R200
Firmware Version 1.0.72.10
Operating System & Version Windows 10 64-bit
librealsense version
pyrealsense version 2.0

LIBUSB error while using SR300 camera

Camera Model: SR300
Firmware Version: firmware': '3.21.0.0'
Operating System & Version: macOS sierra 10.12.6
librealsense version: 1.12.1
pyrealsense version: 2.1

required info:

error: returned LIBUSB_ERROR_PIPE

CODE:

import logging
logging.basicConfig(level=logging.INFO)

import time
import numpy as np
import cv2
import pyrealsense as pyrs

with pyrs.Service() as serv:
    with serv.Device() as dev:
```
        
```
        dev.apply_ivcam_preset(0)
        for k in dev.get_available_options():
            print k
        
        while True:
            dev.wait_for_frames()

            c = dev.color
            c = cv2.cvtColor(c, cv2.COLOR_RGB2BGR)

            d = dev.depth * dev.depth_scale * 100
            d = d.astype(np.uint8)

            cv2.imwrite("test.png",d)
            d = cv2.imread("test.png")
            cd = np.concatenate((c, d), axis=1)

            cv2.imshow('', cd)
            if cv2.waitKey(1) & 0xFF == ord('q'):
                break
        print dev.depth_scale`


I am trying to print all available options that are available for the device. However i am getting this strange error. It was working fine for 2-3 times.

**error log** 

`ERROR:pyrealsense.utils:    uvc_get_ctrl(...) returned LIBUSB_ERROR_PIPE
Traceback (most recent call last):
  File "/Users/i325692/Desktop/depth/intel_realSR300/video_stream.py", line 31, in <module>
    for k in dev.get_available_options():
  File "//anaconda/lib/python2.7/site-packages/pyrealsense/core.py", line 373, in get_available_options
    return six.moves.zip(avail_opt_ranges, self.get_device_options(avail_opt))
  File "//anaconda/lib/python2.7/site-packages/pyrealsense/core.py", line 395, in get_device_options
    _check_error(e)
  File "//anaconda/lib/python2.7/site-packages/pyrealsense/utils.py", line 46, in _check_error
    pp(lrs.rs_get_error_message, e))
pyrealsense.utils.RealsenseError: rs_get_device_options(device:0x100800620, options:0x104e365c0, count:29, values:0x104e33640) crashed with: uvc_get_ctrl(...) returned LIBUSB_ERROR_PIPE`

"cannot stop device without first starting device" exception during exception handling

Required Info
Camera Model R200
Firmware Version 1.0.71.06, 1.0.72.06
Operating System & Version macOS Sierra 10.12.5
librealsense version 1.12.1
pyrealsense version 2.0
python version 3.6.0

I installed librealsense using homebrew and pyrealsense with pip.
Afterwards I tried running the opencv example with python3 show_cv2.py.

Full terminal output:
https://gist.github.com/papr/f5772772b960a6487fd870569c6b1d35

Trouble installing pyrealsense from source

Required Info
Camera Model R200
Firmware Version 1.0.72.06
Operating System & Version macOS Sierra Version 10.12.4 (16E195)
librealsense version 1.12.1
pyrealsense version 1.4

I'm trying to install pyrealsense from source. I run python setup.py install and that works fine.

Using /Users/scaldara/.virtualenvs/pyrs2.7-steve/lib/python2.7/site-packages
Finished processing dependencies for pyrealsense==1.4

I then start up python and do an import pyrealsense as pyrs

It comes up with this error.

(pyrs2.7-steve) 7831c1c083a2:pyrealsense scaldara$ python
Python 2.7.13 (default, Dec 18 2016, 07:03:39)
[GCC 4.2.1 Compatible Apple LLVM 8.0.0 (clang-800.0.42.1)] on darwin
Type "help", "copyright", "credits" or "license" for more information.

import pyrealsense as pyrs
Traceback (most recent call last):
File "", line 1, in
File "pyrealsense/init.py", line 11, in
from .utils import pp, _check_error
File "pyrealsense/utils.py", line 7, in
from .importlib import lrs
File "pyrealsense/importlib.py", line 25, in
rsutilwrapper = ctypes.CDLL(_find_extension_name())
File "pyrealsense/importlib.py", line 23, in _find_extension_name
return os.path.join(dirname, f_name)
UnboundLocalError: local variable 'f_name' referenced before assignment

With a little bit of poking around the failure. It's looking for a filename that ends in ".so" and the directory that it is looking in is "pyrealsense"

Occasional segfault when calling pyrs.stop

Required Info
Camera Model SR300 (model VF0810)
Firmware Version 3.15.0.0
Operating System & Version macOS Sierra 10.12.3
librealsense version 1.12.1
pyrealsense version 1.4

Occasionally, my program crashes when stopping the device.

python(73262,0x7fffcfb4a3c0) malloc: *** error for object 0x7ffc237b89a8: incorrect checksum for freed object - object was probably modified after being freed.
*** set a breakpoint in malloc_error_break to debug
Abort trap: 6

Here's a stack trace from crash report:

Thread 11 Crashed:: org.libusb.device-hotplug
0   libsystem_c.dylib             	0x00007fffc6d914db __abort + 172
1   libsystem_c.dylib             	0x00007fffc6d9142f abort + 144
2   libsystem_malloc.dylib        	0x00007fffc6e8bf21 szone_error + 626
3   libsystem_malloc.dylib        	0x00007fffc6e80c44 tiny_malloc_from_free_list + 1148
4   libsystem_malloc.dylib        	0x00007fffc6e7f4ca szone_malloc_should_clear + 400
5   libsystem_malloc.dylib        	0x00007fffc6e7f2da malloc_zone_malloc + 107
6   com.apple.CoreFoundation      	0x00007fffb175f1d3 CFBasicHashCreateCopy + 131
7   com.apple.CoreFoundation      	0x00007fffb177404b CFSetCreateCopy + 123
8   com.apple.CoreFoundation      	0x00007fffb17ea17e __CFRunLoopRemoveAllSources + 142
9   com.apple.CoreFoundation      	0x00007fffb17741f2 __CFSetApplyFunction_block_invoke + 18
10  com.apple.CoreFoundation      	0x00007fffb17604ba CFBasicHashApply + 122
11  com.apple.CoreFoundation      	0x00007fffb1774199 CFSetApplyFunction + 185
12  com.apple.CoreFoundation      	0x00007fffb17ea23f __CFRunLoopRemoveAllSources + 335
13  com.apple.CoreFoundation      	0x00007fffb17e803f __CFFinalizeRunLoop + 303
14  com.apple.CoreFoundation      	0x00007fffb17e7c64 __CFTSDFinalize + 116
15  libsystem_pthread.dylib       	0x00007fffc6f1650f _pthread_tsd_cleanup + 544
16  libsystem_pthread.dylib       	0x00007fffc6f16249 _pthread_exit + 152
17  libsystem_pthread.dylib       	0x00007fffc6f16da8 pthread_exit + 30
18  libusb-1.0.0.dylib            	0x00000001109112d5 darwin_event_thread_main + 549
19  libsystem_pthread.dylib       	0x00007fffc6f14aab _pthread_body + 180
20  libsystem_pthread.dylib       	0x00007fffc6f149f7 _pthread_start + 286
21  libsystem_pthread.dylib       	0x00007fffc6f141fd thread_start + 13

Thread 11 crashed with X86 Thread State (64-bit):
  rax: 0x0000000000000000  rbx: 0x000070000f219810  rcx: 0x00007fffc6e2d652  rdx: 0x0000000000000000
  rdi: 0x0000000000000003  rsi: 0x000070000f219810  rbp: 0x000070000f219820  rsp: 0x000070000f219800
   r8: 0x0000000000000000   r9: 0x0000000000989680  r10: 0x000070000f21a048  r11: 0x0000000000000246
  r12: 0x0000000000000001  r13: 0x000000010f0a9000  r14: 0x0000000000000000  r15: 0x000000010ee77000
  rip: 0x00007fffc6d914db  rfl: 0x0000000000010246  cr2: 0xffffff81c2f71004
  
Logical CPU:     2
Error Code:      0x00000000
Trap Number:     6

pyrealsense installation problem on ubuntu 16.04

Required Info
Camera Model \SR300
Firmware Version lenovo X1
Operating System & Version ubuntu 16.04
librealsense version latest on github
pyrealsense version latest on github

running install
running bdist_egg
running egg_info
writing requirements to pyrealsense.egg-info/requires.txt
writing pyrealsense.egg-info/PKG-INFO
writing top-level names to pyrealsense.egg-info/top_level.txt
writing dependency_links to pyrealsense.egg-info/dependency_links.txt
reading manifest file 'pyrealsense.egg-info/SOURCES.txt'
reading manifest template 'MANIFEST.in'
writing manifest file 'pyrealsense.egg-info/SOURCES.txt'
installing library code to build/bdist.linux-x86_64/egg
running install_lib
running build_py
running build_ext
building 'pyrealsense.rsutilwrapper' extension
x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -Wdate-time -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -fPIC -I/usr/local/lib/python2.7/dist-packages/numpy/core/include -I/usr/local/include/librealsense -I/usr/include/python2.7 -c pyrealsense/rsutilwrapper.cpp -o build/temp.linux-x86_64-2.7/pyrealsense/rsutilwrapper.o
cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++
In file included from /usr/local/lib/python2.7/dist-packages/numpy/core/include/numpy/ndarraytypes.h:1816:0,
from /usr/local/lib/python2.7/dist-packages/numpy/core/include/numpy/ndarrayobject.h:18,
from /usr/local/lib/python2.7/dist-packages/numpy/core/include/numpy/arrayobject.h:4,
from pyrealsense/rsutilwrapper.cpp:473:
/usr/local/lib/python2.7/dist-packages/numpy/core/include/numpy/npy_1_7_deprecated_api.h:15:2: warning: #warning "Using deprecated NumPy API, disable it by " "#defining NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION" [-Wcpp]
#warning "Using deprecated NumPy API, disable it by "
^
pyrealsense/rsutilwrapper.cpp:476:16: fatal error: rs.h: No such file or directory
compilation terminated.
error: command 'x86_64-linux-gnu-gcc' failed with exit status 1

I am unable to perform import pyrealsense in Windows 10 64-bit with Python 2.7 in Anaconda

Required Info
Camera Model R200
I don't know
Windows 10, 64-bit
librealsense version is the latest from the source taken yesterday
pyrealsense version -- I can't find out because I can't import pyrealsense

Hi,

I am unable to import pyrealsense. I get the following error from the pycparser module.
RuntimeError: Unable to invoke 'cpp'. Make sure its path was passed correctly Original error: [Error 2] The system cannot find the file specified

I don't get this problem in Ubuntu 16.04 LTS. Please help, I need to make it work in Windows system

Question on presets and static values

There are two arrays for presets (ivcam_presets and depth_control_presets).

  1. Where did you get the values for these presets?
  2. What is "ivcam"?
  3. Ivcam option ENUMs reference two sensors (SR300, F200). Does it also apply to R200?
  4. Near the end of real sense.c there are a number of values pertaining to translation, rotation, and intrinsics for color and depth. Where did these values come from and will the values be different for the different sensors.

Seems to be an issue with vc

Required Info
Camera Model R200, F200 or SR300
Firmware Version NO IDEA
Operating System & Version WINDOWS 10
librealsense version NONE
pyrealsense version NONE

Trying to install this using both the setup.py and through the pip way.

Here is the output from the setup.py way (yes, I already downloaded dependencies):

C:\Users\XXXX\Downloads\pyrealsense-master>python setup.py install
running install
running bdist_egg
running egg_info
creating pyrealsense.egg-info
writing requirements to pyrealsense.egg-info\requires.txt
writing pyrealsense.egg-info\PKG-INFO
writing top-level names to pyrealsense.egg-info\top_level.txt
writing dependency_links to pyrealsense.egg-info\dependency_links.txt
writing manifest file 'pyrealsense.egg-info\SOURCES.txt'
reading manifest file 'pyrealsense.egg-info\SOURCES.txt'
reading manifest template 'MANIFEST.in'
writing manifest file 'pyrealsense.egg-info\SOURCES.txt'
installing library code to build\bdist.win-amd64\egg
running install_lib
running build_py
creating build
creating build\lib.win-amd64-2.7
creating build\lib.win-amd64-2.7\pyrealsense
copying pyrealsense\constants.py -> build\lib.win-amd64-2.7\pyrealsense
copying pyrealsense\importlib.py -> build\lib.win-amd64-2.7\pyrealsense
copying pyrealsense\offline.py -> build\lib.win-amd64-2.7\pyrealsense
copying pyrealsense\stream.py -> build\lib.win-amd64-2.7\pyrealsense
copying pyrealsense\to_wrap.py -> build\lib.win-amd64-2.7\pyrealsense
copying pyrealsense\utils.py -> build\lib.win-amd64-2.7\pyrealsense
copying pyrealsense\__init__.py -> build\lib.win-amd64-2.7\pyrealsense
running build_ext
building 'pyrealsense.rsutilwrapper' extension
creating build\temp.win-amd64-2.7
creating build\temp.win-amd64-2.7\Release
creating build\temp.win-amd64-2.7\Release\pyrealsense
C:\Users\XXXX\AppData\Local\Programs\Common\Microsoft\Visual C++ for Python\9.0\VC\Bin\amd64\cl.exe /c /nologo /Ox /MD /W3 /GS- /DNDEBUG -IC:\Python27\lib\site-packages\numpy\core\include -I/usr/local/include/librealsense -IC:\Python27\include -IC:\Python27\PC /Tcpyrealsense/rsutilwrapper.c /Fobuild\temp.win-amd64-2.7\Release\pyrealsense/rsutilwrapper.obj
rsutilwrapper.c
pyrealsense/rsutilwrapper.c(1) : fatal error C1083: Cannot open include file: 'rs.h': No such file or directory
error: command 'C:\\Users\\XXXX\\AppData\\Local\\Programs\\Common\\Microsoft\\Visual C++ for Python\\9.0\\VC\\Bin\\amd64\\cl.exe' failed with exit status 2

Evidently, a file known as rs.h is missing, but I have no idea how to fix that. Maybe microsoft updated something recently that doesn't work with this installer?

About pyrealsense.Device.pointcloud

Hello ^^ may I ask some question
when I use the following code:


pyrs.start()
dev = pyrs.Device()

dev.wait_for_frame()

array1 = dev.pointcloud


I got the array1
what's the structure of array1.
I am using the package from pcl to save this array to .pcd files,
but the dimension seems to be different, so I would like to ask what each elements in the array1 stands for.

access to extrinsics

Required Info
Camera Model SR300
Firmware Version 3.10.10.0
Operating System & Version Ubuntu 16.04.1 LTS

Silly question. How do I access rs_get_device_extrinsics from the librealsense C API? It seems like this was directly possible at one point. Thanks for making this nifty wrapper!

Add YUVColorStream class

Tags: Enhancement, Feature Request

I would like to have a YUV color stream class but I do not know the appropriate parameters (ndarray.dtype, ndarray.shape, etc) to read out the data from librealsense.

@toinsson Would you be so kind and add an appropriate YUVColorStream to streams.py?

LR200 is not found

When I connect RealSense LR200 camera, no device is found. A RealSense error will be thrown with index out of range (see below). I am aware that LR200 is not supported with this library. However, as far as I understand, the difference to R200 is minimal. Is there a quick solution to get it to work?


File "realsense.py", line 11, in <module>
    pyrealsense.stream.DepthStream(fps=60)])
  File "/Users/vinkoo/.virtualenvs/cv30r/lib/python2.7/site-packages/pyrealsense/core.py", line 80, in Device
    _check_error(e)
  File "/Users/vinkoo/.virtualenvs/cv30r/lib/python2.7/site-packages/pyrealsense/utils.py", line 34, in _check_error
    pp(lrs.rs_get_error_message, e))
pyrealsense.utils.RealsenseError: rs_get_device(context:0x7fea0e222d40, index:0) crashed with: out of range value for argument "index"
Required Info
Camera Model LR200
Firmware Version ?
Operating System & Version OS X El Capitan 10.11.6
librealsense version 1.12.1
pyrealsense version 2.0

can't install the libreary

when I tried to install the libreary, I got a error compiling message, as shown below. My linux is 14.04, my numpy version is 1.8.2

running install
running build
running build_ext
building 'pyrealsense' extension
creating build
creating build/temp.linux-armv7l-2.7
creating build/temp.linux-armv7l-2.7/src
arm-linux-gnueabihf-gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -I/usr/lib/python2.7/dist-packages/numpy/core/include -I/usr/local/include/librealsense -I/usr/include/python2.7 -c src/realsense.c -o build/temp.linux-armv7l-2.7/src/realsense.o
In file included from /usr/lib/python2.7/dist-packages/numpy/core/include/numpy/ndarraytypes.h:1761:0,
from /usr/lib/python2.7/dist-packages/numpy/core/include/numpy/ndarrayobject.h:17,
from /usr/lib/python2.7/dist-packages/numpy/core/include/numpy/arrayobject.h:4,
from src/realsense.c:8:
/usr/lib/python2.7/dist-packages/numpy/core/include/numpy/npy_1_7_deprecated_api.h:15:2: warning: #warning "Using deprecated NumPy API, disable it by " "#defining NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION" [-Wcpp]
#warning "Using deprecated NumPy API, disable it by "
^
src/realsense.c: In function ‘apply_ivcam_preset’:
src/realsense.c:544:5: error: ‘for’ loop initial declarations are only allowed in C99 mode
for (int i=0; i<15; i++)
^
src/realsense.c:544:5: note: use option -std=c99 or -std=gnu99 to compile your code
In file included from src/realsense.c:11:0:
src/realsense.c: At top level:
/usr/local/include/librealsense/rsutil.h:61:13: warning: ‘rs_apply_depth_control_preset’ defined but not used [-Wunused-function]
static void rs_apply_depth_control_preset(rs_device * device, int preset)
^
/usr/local/include/librealsense/rsutil.h:87:13: warning: ‘rs_apply_ivcam_preset’ defined but not used [-Wunused-function]
static void rs_apply_ivcam_preset(rs_device * device, int preset)
^
error: command 'arm-linux-gnueabihf-gcc' failed with exit status 1

Accessing Multiple Cameras

Hi,

I'm encountering an issue where if I try to access multiple cameras at the same time, I can only get frames from one of the units.

My system has two cameras attached, both are SR300 units. I'm using librealsense v 1.9.7.

I modified one of the example files as follows:

import logging
logging.basicConfig(level=logging.INFO)
import numpy as np
import cv2
import pyrealsense as pyrs

pyrs.start()
dev0 = pyrs.Device(device_id = 0, streams = [pyrs.ColourStream(fps=30)])
dev1 = pyrs.Device(device_id = 1, streams = [pyrs.ColourStream(fps=30)])

cnt = 0

while cnt < 30:
        dev0.wait_for_frame()
        dev1.wait_for_frame()
        cnt += 1

c0 = dev0.colour
c0 = cv2.cvtColor(c0, cv2.COLOR_RGB2BGR)

img_str = cv2.imencode('.jpg', c0)[1].tobytes()
file0 = open("file0.jpg", "wb")
file0.write(img_str)
file0.close()

c1 = dev1.colour
c1 = cv2.cvtColor(c1, cv2.COLOR_RGB2BGR)

img_str1= cv2.imencode('.jpg', c1)[1].tobytes()
file1 = open("file1.jpg", "wb")
file1.write(img_str1)
file1.close()

After executing this code, I see the same image in both files.

Am I using the python wrapper incorrectly? If so, what is the proper way to access two cameras?

Thanks,
Joe

SR300 cannot import point cloud based on pyrealsense

Required Info
Camera Model SR300
Firmware Version
Operating System & Version ubuntu 16.04
librealsense version v1.12.1
pyrealsense version 2.2

I plan to visualize the data from the demo code from "pyrealsense/examples/show_vtk.py" but it seems the camera cannot read the pointcloud and depth data. Thanks.

Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/IPython/core/interactiveshell.py", line 2882, in run_code
exec(code_obj, self.user_global_ns, self.user_ns)
File "", line 1, in
pc = cam._get_pointcloud()
File "build/bdist.linux-x86_64/egg/pyrealsense/core.py", line 537, in _get_pointcloud
rsutilwrapper.deproject_depth(pointcloud, self.depth_intrinsics, depth, self.depth_scale)
AttributeError: 'SR300-617206002764' object has no attribute 'depth_intrinsics'

build for windows

Required Info
Camera Model R200
Firmware Version
Operating System & Version Windows 10
librealsense version
pyrealsense version

pyrealsense/rsutilwrapper.cpp(477): fatal error C1083: Cannot open include file: 'rs.h':

C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\x86_amd64\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -IP:\Prince\Anaconda3\envs\tensorflow-gpu\lib\site-packages\numpy\core\include -I/usr/local/include/librealsense -IP:\Prince\Anaconda3\envs\tensorflow-gpu\include -IP:\Prince\Anaconda3\envs\tensorflow-gpu\include "-IC:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\INCLUDE" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\shared" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\um" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\winrt" /EHsc /Tppyrealsense/rsutilwrapper.cpp /Fobuild\temp.win-amd64-3.5\Release\pyrealsense/rsutilwrapper.obj
rsutilwrapper.cpp
p:\prince\anaconda3\envs\tensorflow-gpu\lib\site-packages\numpy\core\include\numpy\npy_1_7_deprecated_api.h(12) : Warning Msg: Using deprecated NumPy API, disable it by #defining NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION
pyrealsense/rsutilwrapper.cpp(477): fatal error C1083: Cannot open include file: 'rs.h': No such file or directory
error: command 'C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\x86_amd64\cl.exe' failed with exit status 2

"failed to fetch an unpakcer" for non-native stream types

Required Info
Camera Model R200
Firmware Version 1.0.72.06
Operating System & Version macOS Sierra 10.12.5
librealsense version 1.12.1
pyrealsense version 2.0
python version 3.6.0

I get an RealsenseError: rs_start_device(): failed to fetch an unpakcer, most likely because enable_stream was not called! when enabling only one non-native stream (e.g. PointStream). I need to enable at least one other native stream such that the non-native streams work.

Traceback:

Traceback (most recent call last):
  File "/Users/pabloprietz/work/test_scripts/realsense.py", line 6, in <module>
    with RS.Device(device_id=d['id'], streams=(s,)) as dev:
  File "/Users/pabloprietz/.virtualenvs/py3.6/lib/python3.6/site-packages/pyrealsense/core.py", line 136, in Device
    _check_error(e)
  File "/Users/pabloprietz/.virtualenvs/py3.6/lib/python3.6/site-packages/pyrealsense/utils.py", line 34, in _check_error
    pp(lrs.rs_get_error_message, e))
pyrealsense.utils.RealsenseError: rs_start_device(device:0x7fb80b18c620) crashed with: failed to fetch an unpakcer, most likely because enable_stream was not called!

Script to reproduce the error:

import pyrealsense as RS
RS.start()
try:
    s = RS.stream.PointStream()
    for d in RS.core.get_devices():
        with RS.Device(device_id=d['id'], streams=(s,)) as dev:
            print(dev)
finally:
    RS.stop()

ImportError: No module named 'Cython'

Installing pyrealsense as a dependency to my own package is harder than it needs to be. Right now, I have to tell my users to do

pip install cython numpy
pip install .

Otherwise, when setup.py for pyrealsense is run, you get the following error:

Collecting pyrealsense==2.0 (from capture-tool==0.0.1)
  Using cached pyrealsense-2.0.tar.gz
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/tmp/pip-build-_f4lmzo6/pyrealsense/setup.py", line 7, in <module>
        from Cython.Build import cythonize
    ImportError: No module named 'Cython'

It makes sense. Your setup.py imports from Cython first thing, but if the dependencies haven't been satisfied that won't work, and you can't satisfy the dependencies unless you can get past this import!

I did some digging on this issue, and it appears to be a well known problem that was solved with the release of distutils 18.0

Another option is to stub the cythonize function until it's available for import, but this is hacky and probably not necessary unless we have to support distutils < 18.0.

Windows Installation

I've been trying to install this on Windows, which I know is not officially supported, but was hoping if I could receive some guidance or advice. I'm somewhat of a beginner but I'd love to help any way I can.

I notice there is currently a branch for Windows development that solved some of the initial issues I was having (namely, not being able to force C++ compilation due to .c extension, etc). I cloned that branch as is and am trying to work from there. I'm currently stuck here:

LINK : fatal error LNK1181: cannot open input file 'realsense.lib'
error: command '"C:\Users\XXXX\AppData\Local\Programs\Common\Microsoft\Visual C++ for Python\9.0\VC\Bin\link.exe"' failed with exit status 1181

librealsense is installed and I verified it is working by going to the bin folder and running the .exe examples.
I've moved the complete librealsense folder (as downloaded and extracted from zip) to C:\RealSense and changed the setup.py file to point to "C:\RealSense\include\librealsense" which contains the .h files.

| Camera Model | R200 |
| Operating System & Version | Windows 10 |
| pyrealsense version | 1.4 |

Thank you very much!

ImportError: cannot import name rs_stream

Required Info
Camera Model R200
Firmware Version
Operating System & Version Windows 10 Education 1607
librealsense version 10.0.26.0396
pyrealsense version 2.1

Believe computer is set up correctly but when I try to import pyrealsense I get the following error:

Traceback (most recent call last):
File "\st-james.ecs.vuw.ac.nz\lelievchri\Engr 489\python\unnumbered\pyrealsense_show_cv2.py", line 7, in
import pyrealsense as pyrs
File "C:\Python27\lib\site-packages\pyrealsense_init_.py", line 8, in
from .core import Service
File "C:\Python27\lib\site-packages\pyrealsense\core.py", line 15, in
from .constants import RS_API_VERSION, rs_stream, rs_option
ImportError: cannot import name rs_stream

This is weird because pyrealsense works fine on a different identical computer. Any clues?

The script I ran is your show_cv2.py example but it also does this simply entering import pyrealsense in a command prompt.

Thanks heaps

Different depth results between mac and windows

Required Info
Camera Model R200
Firmware Version
Operating System & Version Mac OS X 10.12.6
librealsense version
pyrealsense version

Hey, thanks for providing this amazing library!
However, when I use demo program (show_depth.py) on Mac, the depth result is not as good as result from realsense SDK on Windows.
How can I solve this problem? Thanks!

Data type checking

| Camera Model | SR300 |
| Firmware Version | 3.15.0 |
| Ubuntu 16.04 |
| librealsense version | 1.12.1 |
| pyrealsense version | 2.1 |

Thank you for the great library! Can I suggest adding data type checking for functions like project_pixel_to_point and deproject_point_to_pixel. When I used np.int and np.float64 data types for arguments, results are garbled. I had to convert my data types to np.float32.
Thanks!

Can't install from source on Windows

Required Info
Camera Model SR300
Firmware Version
Operating System & Version Windows 10
librealsense version 2.8
pyrealsense version 2.2

Hi there, I have been trying to install pyrealsense 2.2 from source and pip but keep getting following error. Followed the installation guide and added all required paths (I think, at least).

Getting following error:

building 'pyrealsense.rsutilwrapper' extension
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\x86_amd64\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -Ipyrealsense -IC:\ProgramData\Miniconda2\envs\tf_gpu\lib\site-packages\numpy\core\include -I/usr/local/include/librealsense "-IC:\Program Files (x86)\Intel RealSense SDK 2.0\include\librealsense2" -IC:\ProgramData\Miniconda2\envs\tf_gpu\include -IC:\ProgramData\Miniconda2\envs\tf_gpu\include "-IC:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\INCLUDE" "-IC:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\ATLMFC\INCLUDE" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\NETFXSDK\4.6.1\include\um" "-IC:\Program Files (x86)\Windows Kits\8.1\include\\shared" "-IC:\Program Files (x86)\Windows Kits\8.1\include\\um" "-IC:\Program Files (x86)\Windows Kits\8.1\include\\winrt" /EHsc /Tppyrealsense/rsutilwrapper.cpp /Fobuild\temp.win-amd64-3.5\Release\pyrealsense/rsutilwrapper.obj
rsutilwrapper.cpp
c:\programdata\miniconda2\envs\tf_gpu\lib\site-packages\numpy\core\include\numpy\npy_1_7_deprecated_api.h(12) : Warning Msg: Using deprecated NumPy API, disable it by #defining NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION
c:\users\aland_000\google drive\python\cards\pyrealsense-2.2\pyrealsense\rsutilwrapper.h(3): error C2065: 'rs_device': undeclared identifier
c:\users\aland_000\google drive\python\cards\pyrealsense-2.2\pyrealsense\rsutilwrapper.h(3): error C2065: 'device': undeclared identifier
c:\users\aland_000\google drive\python\cards\pyrealsense-2.2\pyrealsense\rsutilwrapper.h(3): error C2062: type 'int' unexpected
c:\users\aland_000\google drive\python\cards\pyrealsense-2.2\pyrealsense\rsutilwrapper.h(4): error C2065: 'rs_device': undeclared identifier
c:\users\aland_000\google drive\python\cards\pyrealsense-2.2\pyrealsense\rsutilwrapper.h(4): error C2065: 'device': undeclared identifier
c:\users\aland_000\google drive\python\cards\pyrealsense-2.2\pyrealsense\rsutilwrapper.h(4): error C2065: 'rs_ivcam_preset': undeclared identifier
c:\users\aland_000\google drive\python\cards\pyrealsense-2.2\pyrealsense\rsutilwrapper.h(4): error C2146: syntax error: missing ')' before identifier 'preset'
c:\users\aland_000\google drive\python\cards\pyrealsense-2.2\pyrealsense\rsutilwrapper.h(6): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
c:\users\aland_000\google drive\python\cards\pyrealsense-2.2\pyrealsense\rsutilwrapper.h(6): error C2143: syntax error: missing ',' before '*'
pyrealsense/rsutilwrapper.cpp(1774): error C3861: '_apply_ivcam_preset': identifier not found
pyrealsense/rsutilwrapper.cpp(1956): error C3861: '_apply_ivcam_preset': identifier not found
pyrealsense/rsutilwrapper.cpp(2147): error C2660: '_project_point_to_pixel': function does not take 3 arguments
error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\BIN\\x86_amd64\\cl.exe' failed with exit status 2

What am I missing here?

Thanks

Include PyYAML in requirements.txt

When I try to run tests, the following error occurs:

======================================================================
ERROR: offline (unittest.loader._FailedTest)
----------------------------------------------------------------------
ImportError: Failed to import test module: offline
Traceback (most recent call last):
  File "/usr/local/Cellar/python3/3.6.1/Frameworks/Python.framework/Versions/3.6/lib/python3.6/unittest/loader.py", line 153, in loadTestsFromName
    module = __import__(module_name)
  File "/Users/zacstewart/Code/HopServices/loom.ai/pyrealsense/pyrealsense/offline.py", line 4, in <module>
    import yaml
ModuleNotFoundError: No module named 'yaml'


----------------------------------------------------------------------
Ran 1 test in 0.000s

FAILED (errors=1)
Test failed: <unittest.runner.TextTestResult run=1 errors=1 failures=0>
error: Test failed: <unittest.runner.TextTestResult run=1 errors=1 failures=0>

Installing pyyaml fixes it

$ pip install pyyaml
Collecting pyyaml
Installing collected packages: pyyaml
Successfully installed pyyaml-3.12
$ python setup.py test
running test
running egg_info
writing pyrealsense.egg-info/PKG-INFO
writing dependency_links to pyrealsense.egg-info/dependency_links.txt
writing requirements to pyrealsense.egg-info/requires.txt
writing top-level names to pyrealsense.egg-info/top_level.txt
reading manifest file 'pyrealsense.egg-info/SOURCES.txt'
reading manifest template 'MANIFEST.in'
writing manifest file 'pyrealsense.egg-info/SOURCES.txt'
running build_ext
copying build/lib.macosx-10.12-x86_64-3.6/pyrealsense/rsutilwrapper.cpython-36m-darwin.so -> pyrealsense

----------------------------------------------------------------------
Ran 0 tests in 0.000s

OK

Can't use on Linux kernel version after 4.4

Required Info
Camera Model SR300
Firmware Version
Operating System & Version Ubuntu 16.04 LTS (kernel version 4.10)
librealsense version v1.12.1
pyrealsense version 2.2

When I tried to install pyrealsense with the legacy librealsense (v1.12.1, the latest version that we can use with pyrealsense) based on the manual (https://github.com/IntelRealSense/librealsense/blob/v1.12.1/doc/installation.md), the installation fails when patching uvcvideo module (when running ./scripts/patch-uvcvideo-16.04.simple.sh). This is because this patch isn't applicable for the kernel after 4.4 version.

I think this is a known issue, but what is the recommendation when having this issue? Use the old kernel version or use pyrealsense2 from the latest librealsense?

Uncaught c++ exception: VIDIOC_DQBUF error

Required Info
Camera Model R200
Firmware Version 1.0.72.06
Operating System & Version Ubuntu 16.04 LTS
librealsense version 1.12.1
pyrealsense version 2.0
python version 3.5.2

If the USB connection fails I get the following output and my Python thread dies:

terminate called after throwing an instance of 'std::runtime_error'
  what():  VIDIOC_DQBUF error 19, No such device

Any idea how to catch this exception? Or should this be actually be caught by librealsense?

Support for R200 camera. [Compatibility with librealsense 1.9.7]

I had a working version of pyrealsense/librealsense. I noticed changes to both repositories and decided to pull and rebuild the latest librealsense and pull and rebuild pyrealsense. When I go to run a prior python script that was working, it crashes the python kernel when doing the pyrs.start().

Have you tried it with the librealsense 1.9.7?

Memory leak: application memory grows continuously

Hi, i'm trying to optimize my code, but application memory grows at each cycle. Is there any function or way to optimize memory?
Thanks

Info
Camera Model R200
Firmware Version 1.0.71.06
Operating System & Version ubuntu 16.04
librealsense version 1.12.1
pyrealsense version 1.4

newbie questions...

Hi there, not an issue but a question:
Since I'm thinking about getting me a SR300 and develop a Python app for Windows, I wonder why your wrapper shouldn't work under Windows.
librealsense supports Windows 10 and Python is platform independent. So chances are good that it works, right? Your opinion on this would be very much appreciated. Or maybe you've heard of someone using the wrapper under Windows?

rs.h not found

Required Info
Camera Model R200, F200 or SR300
Firmware Version
Operating System & Version MacOS Sierra 10.12.4
librealsense version No idea
pyrealsense version No idea

So I get this error while installing pyrealsense via pip.

  running install
    running build
    running build_py
    creating build
    creating build/lib.macosx-10.5-x86_64-3.5
    creating build/lib.macosx-10.5-x86_64-3.5/pyrealsense
    copying pyrealsense/__init__.py -> build/lib.macosx-10.5-x86_64-3.5/pyrealsense
    copying pyrealsense/constants.py -> build/lib.macosx-10.5-x86_64-3.5/pyrealsense
    copying pyrealsense/importlib.py -> build/lib.macosx-10.5-x86_64-3.5/pyrealsense
    copying pyrealsense/offline.py -> build/lib.macosx-10.5-x86_64-3.5/pyrealsense
    copying pyrealsense/stream.py -> build/lib.macosx-10.5-x86_64-3.5/pyrealsense
    copying pyrealsense/to_wrap.py -> build/lib.macosx-10.5-x86_64-3.5/pyrealsense
    copying pyrealsense/utils.py -> build/lib.macosx-10.5-x86_64-3.5/pyrealsense
    running build_ext
    building 'pyrealsense.rsutilwrapper' extension
    creating build/temp.macosx-10.5-x86_64-3.5
    creating build/temp.macosx-10.5-x86_64-3.5/pyrealsense
    gcc -fno-strict-aliasing -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/Users/prashanth/code/anaconda3/envs/roboy/include -arch x86_64 -I/Users/prashanth/code/anaconda3/envs/roboy/lib/python3.5/site-packages/numpy/core/include -I/usr/local/include/librealsense -I/Users/prashanth/code/anaconda3/envs/roboy/include/python3.5m -c pyrealsense/rsutilwrapper.c -o build/temp.macosx-10.5-x86_64-3.5/pyrealsense/rsutilwrapper.o
    pyrealsense/rsutilwrapper.c:1:10: fatal error: 'rs.h' file not found
    #include "rs.h"
             ^
    1 error generated.
    error: command 'gcc' failed with exit status 1

Depth Image not working

Required Info
Camera Model SR300
Firmware Version librealsense from source
Operating System & Version Ubuntu 16.04

Hi,
I was trying your test/show_cv2.py, and I get the image for the colour image, however, the depth image is just red.
When I print the data, the array has the correct depth image size, but only two values are set (first two values)
array([[ 8288, 17669, 0, ..., 0, 0, 0],
[ 0, 0, 0, ..., 0, 0, 0],
[ 0, 0, 0, ..., 0, 0, 0],
...,
[ 0, 0, 0, ..., 0, 0, 0],
[ 0, 0, 0, ..., 0, 0, 0],
[ 0, 0, 0, ..., 0, 0, 0]], dtype=uint16)

Thanks

PS: I had opened an issue regarding pyrealsense on windows, I was not able to solve it and switched to ubuntu. There seems to be a general problem regarding the compilation of plugins for python3 on windows.

OSError: librealsense.so: cannot open shared object file: No such file or directory

When I installed pyrealsense on Ubuntu 16.04 LTS and tried to run it, I had the following error. Have you ever had this error before? Am I missing something?

>>> import pyrealsense as pyrs
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "pyrealsense/__init__.py", line 14, in <module>
    from pyrealsense.utils import pp, _check_error
  File "pyrealsense/utils.py", line 8, in <module>
    lrs = ctypes.CDLL('librealsense.so')
  File "/home/username/anaconda2/lib/python2.7/ctypes/__init__.py", line 362, in __init__
    self._handle = _dlopen(self._name, mode)
OSError: librealsense.so: cannot open shared object file: No such file or directory

Just for your information, the followings are the log I got during the installation. It looks fine though I had some warnings. If the above error is because of the installation mistake, please let me know.

running install
running bdist_egg
running egg_info
creating pyrealsense.egg-info
writing pyrealsense.egg-info/PKG-INFO
writing top-level names to pyrealsense.egg-info/top_level.txt
writing dependency_links to pyrealsense.egg-info/dependency_links.txt
writing manifest file 'pyrealsense.egg-info/SOURCES.txt'
reading manifest file 'pyrealsense.egg-info/SOURCES.txt'
writing manifest file 'pyrealsense.egg-info/SOURCES.txt'
installing library code to build/bdist.linux-x86_64/egg
running install_lib
running build_py
creating build
creating build/lib.linux-x86_64-2.7
creating build/lib.linux-x86_64-2.7/pyrealsense
copying pyrealsense/__init__.py -> build/lib.linux-x86_64-2.7/pyrealsense
copying pyrealsense/stream.py -> build/lib.linux-x86_64-2.7/pyrealsense
copying pyrealsense/offline.py -> build/lib.linux-x86_64-2.7/pyrealsense
copying pyrealsense/utils.py -> build/lib.linux-x86_64-2.7/pyrealsense
copying pyrealsense/to_wrap.py -> build/lib.linux-x86_64-2.7/pyrealsense
copying pyrealsense/constants.py -> build/lib.linux-x86_64-2.7/pyrealsense
running build_ext
building 'pyrealsense.rsutilwrapper' extension
creating build/temp.linux-x86_64-2.7
creating build/temp.linux-x86_64-2.7/pyrealsense
gcc -pthread -fno-strict-aliasing -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/home/username/anaconda2/lib/python2.7/site-packages/numpy/core/include -I/usr/local/include/librealsense -I/home/username/anaconda2/include/python2.7 -c pyrealsense/rsutilwrapper.c -o build/temp.linux-x86_64-2.7/pyrealsense/rsutilwrapper.o
In file included from pyrealsense/rsutilwrapper.c:2:0:
/usr/local/include/librealsense/rsutil.h:11:13: warning: ‘rs_project_point_to_pixel’ defined but not used [-Wunused-function]
 static void rs_project_point_to_pixel(float pixel[2], const struct rs_intrinsic
             ^
/usr/local/include/librealsense/rsutil.h:55:13: warning: ‘rs_transform_point_to_point’ defined but not used [-Wunused-function]
 static void rs_transform_point_to_point(float to_point[3], const struct rs_extr
             ^
gcc -pthread -shared -L/home/username/anaconda2/lib -Wl,-rpath=/home/username/anaconda2/lib,--no-as-needed build/temp.linux-x86_64-2.7/pyrealsense/rsutilwrapper.o -L/usr/local/lib -L/home/username/anaconda2/lib -lrealsense -lpython2.7 -o build/lib.linux-x86_64-2.7/pyrealsense/rsutilwrapper.so
creating build/bdist.linux-x86_64
creating build/bdist.linux-x86_64/egg
creating build/bdist.linux-x86_64/egg/pyrealsense
copying build/lib.linux-x86_64-2.7/pyrealsense/__init__.py -> build/bdist.linux-x86_64/egg/pyrealsense
copying build/lib.linux-x86_64-2.7/pyrealsense/rsutilwrapper.so -> build/bdist.linux-x86_64/egg/pyrealsense
copying build/lib.linux-x86_64-2.7/pyrealsense/stream.py -> build/bdist.linux-x86_64/egg/pyrealsense
copying build/lib.linux-x86_64-2.7/pyrealsense/offline.py -> build/bdist.linux-x86_64/egg/pyrealsense
copying build/lib.linux-x86_64-2.7/pyrealsense/utils.py -> build/bdist.linux-x86_64/egg/pyrealsense
copying build/lib.linux-x86_64-2.7/pyrealsense/to_wrap.py -> build/bdist.linux-x86_64/egg/pyrealsense
copying build/lib.linux-x86_64-2.7/pyrealsense/constants.py -> build/bdist.linux-x86_64/egg/pyrealsense
byte-compiling build/bdist.linux-x86_64/egg/pyrealsense/__init__.py to __init__.pyc
byte-compiling build/bdist.linux-x86_64/egg/pyrealsense/stream.py to stream.pyc
byte-compiling build/bdist.linux-x86_64/egg/pyrealsense/offline.py to offline.pyc
byte-compiling build/bdist.linux-x86_64/egg/pyrealsense/utils.py to utils.pyc
byte-compiling build/bdist.linux-x86_64/egg/pyrealsense/to_wrap.py to to_wrap.pyc
byte-compiling build/bdist.linux-x86_64/egg/pyrealsense/constants.py to constants.pyc
creating stub loader for pyrealsense/rsutilwrapper.so
byte-compiling build/bdist.linux-x86_64/egg/pyrealsense/rsutilwrapper.py to rsutilwrapper.pyc
creating build/bdist.linux-x86_64/egg/EGG-INFO
copying pyrealsense.egg-info/PKG-INFO -> build/bdist.linux-x86_64/egg/EGG-INFO
copying pyrealsense.egg-info/SOURCES.txt -> build/bdist.linux-x86_64/egg/EGG-INFO
copying pyrealsense.egg-info/dependency_links.txt -> build/bdist.linux-x86_64/egg/EGG-INFO
copying pyrealsense.egg-info/top_level.txt -> build/bdist.linux-x86_64/egg/EGG-INFO
writing build/bdist.linux-x86_64/egg/EGG-INFO/native_libs.txt
zip_safe flag not set; analyzing archive contents...
pyrealsense.offline: module references __file__
pyrealsense.__init__: module references __file__
creating dist
creating 'dist/pyrealsense-1.2-py2.7-linux-x86_64.egg' and adding 'build/bdist.linux-x86_64/egg' to it
removing 'build/bdist.linux-x86_64/egg' (and everything under it)
Processing pyrealsense-1.2-py2.7-linux-x86_64.egg
creating /home/username/anaconda2/lib/python2.7/site-packages/pyrealsense-1.2-py2.7-linux-x86_64.egg
Extracting pyrealsense-1.2-py2.7-linux-x86_64.egg to /home/username/anaconda2/lib/python2.7/site-packages
Adding pyrealsense 1.2 to easy-install.pth file

Installed /home/username/anaconda2/lib/python2.7/site-packages/pyrealsense-1.2-py2.7-linux-x86_64.egg
Processing dependencies for pyrealsense==1.2
Finished processing dependencies for pyrealsense==1.2

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.