Items with no label
3335 Discussions

Intel D415 & Python 3.5

MTont
Beginner
3,709 Views

Hi everyone!

 

I'm trying to use this camera with opencv. I'm using Xubuntu 16.04 and Python 3.5 with opencv and pyrealsense2 installed.

If I try another camera it works (an old intel...I don't rimember the name but is a depth camera older than the ZR300) but if I plug the D415 pyrealsense2 can't find any realsense camera.

What do I need to install? is there a documentation about this?

Thank you!

0 Kudos
21 Replies
MartyG
Honored Contributor III
1,076 Views

Hi Lab! The documentation for SDK 2.0's Python wrapper is here:

https://github.com/IntelRealSense/librealsense/tree/master/wrappers/python librealsense/wrappers/python at master · IntelRealSense/librealsense · GitHub

0 Kudos
MTont
Beginner
1,076 Views

Hi Marty!

thank you for the answer! Later I'll take a look and I'll let you know!

0 Kudos
MTont
Beginner
1,076 Views

HI!

I tried to follow the guide but when I try to launch the examples I've this error:

INFO:pyrealsense.core:There are 0 connected RealSense devices.

ERROR:pyrealsense.utils:rs_error was raised when calling rs_get_device(context:0x1fe6c40, index:0)

ERROR:pyrealsense.utils: out of range value for argument "index"

Traceback (most recent call last):

File "show_depth.py", line 39, in

with serv.Device(streams=(depth_stream,)) as dev:

File "/usr/local/lib/python3.5/dist-packages/pyrealsense-2.2-py3.5-linux-x86_64.egg/pyrealsense/core.py", line 125, in Device

return Device(self, *args, **kwargs)

File "/usr/local/lib/python3.5/dist-packages/pyrealsense-2.2-py3.5-linux-x86_64.egg/pyrealsense/core.py", line 170, in Device

_check_error(e)

File "/usr/local/lib/python3.5/dist-packages/pyrealsense-2.2-py3.5-linux-x86_64.egg/pyrealsense/utils.py", line 46, in _check_error

pp(lrs.rs_get_error_message, e))

pyrealsense.utils.RealsenseError: rs_get_device(context:0x1fe6c40, index:0) crashed with: out of range value for argument "index"

If I run "sudo lsusb" I've this:

Bus 002 Device 004: ID 8086:0ad3 Intel Corp.

Bus 002 Device 005: ID 8086:0ad3 Intel Corp.

Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub

Bus 001 Device 002: ID 8087:0a2b Intel Corp.

Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

(there are actually 2 D415 connected with my NUC with Xubuntu 16.04)

Any idea? Thank you!

0 Kudos
MartyG
Honored Contributor III
1,076 Views

The closest example I could find to your problem (camera is not detected but lsusb can find it) is the case below.

https://github.com/IntelRealSense/librealsense/issues/195 R200 Realsense not detected on Linux Ubuntu · Issue # 195 · IntelRealSense/librealsense · GitHub

In that case, the users fixed their problem temporarily with a chmod permissions change, and permanently by adding their username to a 'dialout group'.

sudo usermod -a -G dialout [put your username here without the brackets]

0 Kudos
MTont
Beginner
1,076 Views

I tried but the problem remains...

0 Kudos
MartyG
Honored Contributor III
1,076 Views

I have analysed the problem many times. It is a hard one, for sure. I noticed though that the log makes reference to 'pyrealsense_2_2'. This makes me wonder if you have installed a branch of 'pyrealsense 2.0', which works with old RealSense cameras such as the R200 but not with the new cameras, which need 'pyrealsense2' (which is different from the similarly named pyrealsense 2.0 for the older cameras).

0 Kudos
MTont
Beginner
1,076 Views

Yes that's because I used old intel camera with my software but now I installed pyrealsense 2.0 and it doesn't work anymore with old camera.

What do you suggest? Should I make a clean installation?

0 Kudos
MartyG
Honored Contributor III
1,076 Views

It sounds like you would benefit from a clean installation with pyrealsense2 (the new one for the 400 Series cameras) to make sure there aren't crossed wires between programs. At this point, it's certainly worth trying.

0 Kudos
MTont
Beginner
1,076 Views

Thank you for your time...

I uninstalled librealsense and pyrealsense and reinstalled everything.

now the error of the example (show_cv2.py) is this:

INFO:pyrealsense.core:There are 0 connected RealSense devices.

ERROR:pyrealsense.utils:rs_error was raised when calling rs_get_device(context:0x269d470, index:0)

ERROR:pyrealsense.utils: out of range value for argument "index"

Traceback (most recent call last):

File "show_cv2.py", line 12, in

with serv.Device() as dev:

File "/home/stark/.local/lib/python3.5/site-packages/pyrealsense/core.py", line 125, in Device

return Device(self, *args, **kwargs)

File "/home/stark/.local/lib/python3.5/site-packages/pyrealsense/core.py", line 170, in Device

_check_error(e)

File "/home/stark/.local/lib/python3.5/site-packages/pyrealsense/utils.py", line 46, in _check_error

pp(lrs.rs_get_error_message, e))

pyrealsense.utils.RealsenseError: rs_get_device(context:0x269d470, index:0) crashed with: out of range value for argument "index"

0 Kudos
MartyG
Honored Contributor III
1,076 Views

Are you able to run a RealSense program such as the RealSense Viewer and confirm that the camera is working, even though it is detected? In particular, you could check in the RealSense Viewer program whether the camera is listed as "Intel RealSense D415" (showing it is fully functioning) or listed as 'Intel RealSense USB2' (indicating that it is only functioning in a very limited USB 2.0 mode).

0 Kudos
MTont
Beginner
1,076 Views

Yes, I tried it with windows 10 (in another machine) with RealSense Viewer and it is listed as Intel Realsense D415 (usb symbol) 2.1

I also updated the firmware

0 Kudos
MartyG
Honored Contributor III
1,076 Views

The USB2 status is related to the USB ports on a particular machine, not to the camera hardware. So the camera may work fine on one machine but have the function-limiting USB2 problem on another machine. That's why it is important to establish whether the USB2 problem is present on the machine you are using for Python.

0 Kudos
MTont
Beginner
1,076 Views

Ok I tried on xubuntu too and Intel RealSense Viewer it works.

The camera is listed as Intel RealSense D415 (usb symbol) 3.1

0 Kudos
MTont
Beginner
1,076 Views

is it possible that D415 cameras don't work with python3.5 but only with python3.6?

0 Kudos
MartyG
Honored Contributor III
1,076 Views

I have not heard of an incompatibility with Python 3.5. The 400 Series cameras do work with Python 3. It is good though to confirm that your camera is working normally outside of Python. It's also good that you have a clean installation, as it means that there is less things to go wrong.

The next thing I would do is go back to the Python installation instructions for Ubuntu, look at steps 1 to 4 (step 5 is optional) and confirm that everything has been done. For example, in Step 3, did you "Run the top level CMake command".

https://github.com/IntelRealSense/librealsense/tree/master/wrappers/python librealsense/wrappers/python at master · IntelRealSense/librealsense · GitHub

0 Kudos
MTont
Beginner
1,076 Views

Ok, I've some news:

I tried to follow that guide but with one problem:

if I write:

- python3

-import pyrealsense2

it says "no module named pyrealsense2"

 

If I write the same thing in the folder "\usr\local\lib" it works.

So I think that the error is in the number 3 of the guide. When I run cmake, I think that I need to add "-DPYTHON_EXECUTABLE=[full path to the exact python executable]" but what should I use as path of python?

I tried: I tried to use "-DPYTHON_EXECUTABLE=[/usr/local/lib]", "-DPYTHON_EXECUTABLE=[/usr/local/lib/Python3.5]", "-DPYTHON_EXECUTABLE=[/usr/lib]" and "-DPYTHON_EXECUTABLE=[/usr/lib/Python3]"

but nothing worked

 

I used "whereis python3" and this is the answer:

python3: /usr/bin/python3.5m-config /usr/bin/python3.5m /usr/bin/python3.5 /usr/bin/python3 /usr/bin/python3.5-config /usr/lib/python3.5 /usr/lib/python3 /etc/python3.5 /etc/python3 /usr/local/lib/python3.5 /usr/include/python3.5m /usr/include/python3.5 /usr/share/python3 /usr/share/man/man1/python3.1.gz

What should I put there? thank you

0 Kudos
MartyG
Honored Contributor III
1,076 Views

In the instructions, I believe the DPYTHON command should not have square brackets in it and should look like:

-DPYTHON_EXECUTABLE= /usr/local/lib

As for the actual path, it apparently needs to go to an .exe (executable) file, such as python.exe

0 Kudos
MTont
Beginner
1,076 Views

Ok I did it!

I didn't use the square brackets, it was just an error reporting everything here in the forum.

The right instruction was: -DPYTHON_EXECUTABLE= /usr/bin/python3.5

 

 

In the end I needed to copy from the folder "/usr/local/lib/" librealsense2.so and pyrealsense2.cpython-35m-x86_64-linux-gnu.so.

 

The instruction "export PYTHONPATH=$PYTHONPATH:/usr/local/lib" didn't work for mebut it's ok...

Thank you for everything!

0 Kudos
MartyG
Honored Contributor III
1,076 Views

Awesome news! I'm very glad I could help. Best of luck with the rest of your work!

0 Kudos
MTont
Beginner
922 Views

Thank you!

 

One last thing: Do you confirm that there are only the documentation in the installer folder and the examples in the "examples" folder?

Do I need to mark this post as solved?

0 Kudos
Reply