Items with no label
3335 Discussions

intrinsics, laser power python

ROhle
Novice
2,216 Views

item 1) I cannot find python code to actively manage the laser power or to toggle the emitter. My attempts to translate the C++ code were (as expected:) no good.

item 2) Intrinsic Madness->

Not exactly sure what I am doing wrong here.

The following code is a lightly modified version posted by Intel in answer to a similar question.

I'm using a D435 with most recent updates across the board. Windows 8.1.

# Trying to get intrinsics (fx, etc.)

 

# First import the library

 

import pyrealsense2 as rs

pipe = rs.pipeline()

cfg = rs.config

 

cfg.enable_stream(rs.stream.color, 1920, 1080, rs.format. rgb8, 30)

cfg.enable_stream(rs.stream.infrared, 1,848,480,rs.format.y8,30)

cfg.enable_stream(rs.stream.infrared, 2,848,480,rs.format.y8,30)

cfg.enable_stream(rs.stream.depth,848,480,rs.format.z16,30)

prof = pipe.start(cfg)

ds = prof.get_stream(rs.stream.depth)

intr = ds.as_video_stream_profile().get_intrinsics()

print "depth"

 

print intr

s = prof.get_stream(rs.stream.infrared, 1)

intr = ds.as_video_stream_profile().get_intrinsics()

print"IR1:"

 

print intr

s = prof.get_stream(rs.stream.infrared, 2)

intr = ds.as_video_stream_profile().get_intrinsics()

print"IR2:"

 

print intr

ds = prof.get_stream(rs.stream.color)

intr = ds.as_video_stream_profile().get_intrinsics()

print"color:"

 

print intr

And this gives the following:

depth

 

width: 848, height: 480, ppx: 424.713, ppy: 242.321, fx: 420.367, fy: 420.367, model: Brown Conrady

 

IR1:

 

width: 848, height: 480, ppx: 424.713, ppy: 242.321, fx: 420.367, fy: 420.367, model: Brown Conrady

 

IR2:

 

width: 848, height: 480, ppx: 424.713, ppy: 242.321, fx: 420.367, fy: 420.367, model: Brown Conrady

 

color:

 

width: 1920, height: 1080, ppx: 968.251, ppy: 536.9, fx: 1392.01, fy: 1392.87, model: Brown Conrady

Process finished with exit code 0

BUT:

If I change the order of getting the streams so that the color stream is looked at just after depth and before IR1 and IR2 I get:

depth 

width: 848, height: 480, ppx: 424.713, ppy: 242.321, fx: 420.367, fy: 420.367, model: Brown Conrady

 

color:

 

width: 1920, height: 1080, ppx: 968.251, ppy: 536.9, fx: 1392.01, fy: 1392.87, model: Brown Conrady

 

IR1:

 

width: 1920, height: 1080, ppx: 968.251, ppy: 536.9, fx: 1392.01, fy: 1392.87, model: Brown Conrady

 

IR2:

 

width: 1920, height: 1080, ppx: 968.251, ppy: 536.9, fx: 1392.01, fy: 1392.87, model: Brown Conrady

Process finished with exit code 0

item 3)

I convert from fx(pixel relative) to: fx(mm) = image_width/fx. For the Depth camera I get a reasonable answer(about 2), but for the color camera the answer is about 1.3... way far off.

Thanks,

Rich

0 Kudos
3 Replies
MartyG
Honored Contributor III
858 Views

tem 1

The link below contains a sample script provided by Intel for controlling the laser power with Python.

https://github.com/IntelRealSense/librealsense/issues/1258 How to control the laser with python wrapper · Issue # 1258 · IntelRealSense/librealsense · GitHub

Item 2

RealSense user edgar.altamirano recently posted a script for getting intrinsics with Python.

jb455, whom I have linked into this conversation. JB, rjo's question is "I convert from fx(pixel relative) to fx(mm) = image_width/fx. For the Depth camera I get a reasonable answer(about 2), but for the color camera the answer is about 1.3... way far off."

0 Kudos
jb455
Valued Contributor II
858 Views

Item 2 looks like a bug. I'd suggest posting it on https://github.com/IntelRealSense/librealsense/issues Issues · IntelRealSense/librealsense · GitHub to see what the devs say.

Item 3... I don't really know about converting focal lengths from pixels to mm. The https://www.intel.com/content/dam/support/us/en/documents/emerging-technologies/intel-realsense-technology/Intel-RealSense-D400-Series-Datasheet.pdf datasheet has the specifications for the cameras, including their focal lengths in mm; but if you find the factory intrinsic parameters are wrong you can recalibrate yourself using OpenCV or similar then write to the camera using the https://downloadcenter.intel.com/download/27955/Intel-RealSense-D400-Series-Calibration-Tools-and-API calibration tools.

0 Kudos
ROhle
Novice
858 Views

Thanks guys. Have to wait til tonight to go through it all.

Rich

0 Kudos
Reply