Skip to content

Commit

Permalink
CR fixes:
Browse files Browse the repository at this point in the history
- C&P errors, minor text adjustments.
- Adding D400-only guard

Change-Id: I7afbe9faf60db5498f71427d187d4dba273efe95
(cherry picked from commit b92ea3a)
  • Loading branch information
ev-mp committed Nov 9, 2021
1 parent c7bb2a5 commit d66a6a2
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 24 deletions.
44 changes: 21 additions & 23 deletions wrappers/python/examples/depth_auto_calibration_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,27 @@ def main(arguments=None):
print('Device is not connected')
sys.exit(1)

depth_sensor = device.first_depth_sensor()
# Verify Preconditions:
# 1. The script is applicable for D400-series devices only
cam_name = device.get_info(rs.camera_info.name) if device.supports(rs.camera_info.name) else "Unrecognized camera"
if device.supports(rs.camera_info.product_line):
device_product_line = str(device.get_info(rs.camera_info.product_line))
if device_product_line != 'D400':
print(f'The example is intended for RealSense D400 Depth cameras, and is not', end =" ")
print(f'applicable with {cam_name}')
sys.exit(1)
# 2. The routine assumes USB3 connection type
# In case of USB2 connection, the streaming profiles should be readjusted
if device.supports(rs.camera_info.usb_type_descriptor):
usb_type = device.get_info(rs.camera_info.usb_type_descriptor)
if not usb_type.startswith('3.'):
print('The script is designed to run with USB3 connection type.')
print('In order to enable it with USB2.1 mode the fps rates for the Focal Length and Ground Truth calculation stages should be re-adjusted')
sys.exit(1)


# prepare device
depth_sensor = device.first_depth_sensor()
depth_sensor.set_option(rs.option.emitter_enabled, 0)
if depth_sensor.supports(rs.option.thermal_compensation):
depth_sensor.set_option(rs.option.thermal_compensation, 0)
Expand All @@ -65,6 +83,7 @@ def main(arguments=None):

print("Starting UCAL...")
try:
# The recomended sequence of procedures: On-Chip -> Focal Length -> Tare Calibration
run_on_chip_calibration(args.onchip_speed, args.onchip_scan)
run_focal_length_calibration((args.target_width, args.target_height), args.focal_adjustment)
run_tare_calibration(args.tare_accuracy, args.tare_scan, args.tare_gt, (args.target_width, args.target_height))
Expand Down Expand Up @@ -93,11 +112,6 @@ def run_on_chip_calibration(speed, scan):
pp = pipe.start(cfg)
dev = pp.get_device()

# Pre-conditions required by calibration flow
depth_sensor = dev.first_depth_sensor()
if (depth_sensor.supports(rs.option.thermal_compensation)):
depth_sensor.set_option(rs.option.thermal_compensation, 0)

try:

print('Starting On-Chip calibration...')
Expand Down Expand Up @@ -147,13 +161,7 @@ def cb(frame):
pp = pipe.start(cfg, cb)
dev = pp.get_device()

# Pre-conditions required by calibration flow
depth_sensor = dev.first_depth_sensor()
if (depth_sensor.supports(rs.option.thermal_compensation)):
depth_sensor.set_option(rs.option.thermal_compensation, 0)

try:

print('Starting Focal-Length calibration...')
print(f'\tTarget Size:\t{target_size}')
print(f'\tSide Adjustment:\t{adjust_side}')
Expand Down Expand Up @@ -193,13 +201,7 @@ def run_tare_calibration(accuracy, scan, gt, target_size):
pp = pipe.start(cfg)
dev = pp.get_device()

# Pre-conditions required by calibration flow
depth_sensor = dev.first_depth_sensor()
if (depth_sensor.supports(rs.option.thermal_compensation)):
depth_sensor.set_option(rs.option.thermal_compensation, 0)

try:

print(f'\tGround Truth:\t{target_z}')
print(f'\tAccuracy:\t{accuracy}')
print(f'\tScan:\t{scan}')
Expand All @@ -208,6 +210,7 @@ def run_tare_calibration(accuracy, scan, gt, target_size):
print('Tare calibration finished')
adev.set_calibration_table(table)
adev.write_calibration()

finally:
pipe.stop()

Expand Down Expand Up @@ -238,11 +241,6 @@ def cb(frame):
pp = pipe.start(cfg, cb)
dev = pp.get_device()

# Pre-conditions required by calibration flow
depth_sensor = dev.first_depth_sensor()
if (depth_sensor.supports(rs.option.thermal_compensation)):
depth_sensor.set_option(rs.option.thermal_compensation, 0)

try:
stime = time.time()
while counter < number_of_images:
Expand Down
2 changes: 1 addition & 1 deletion wrappers/python/examples/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ These Examples demonstrate how to use the python wrapper of the SDK.
10. [T265 Stereo](./t265_stereo.py) - This example shows how to use T265 intrinsics and extrinsics in OpenCV to asynchronously compute depth maps from T265 fisheye images on the host.
11. [Realsense over Ethernet](./ethernet_client_server/README.md) - This example shows how to stream depth data from RealSense depth cameras over ethernet.
12. [Realsense Network Device Viewer](./net_viewer.py) - Shows how to connect to rs-server over network.
12. [Realsense Network Device Viewer](./depth_auto_calibration_example.py) - Implements D400 Self-Calibration Routines flow. The scripts performs On-Chip Calibration, followed by Focal-Length calibration and finally, the Tare Calibration sub-routines. Follow the [White Paper Link](https://dev.intelrealsense.com/docs/self-calibration-for-depth-cameras) for in-depth description of the provided calibration methods.
13. [D400 self-calibration demo](./depth_auto_calibration_example.py) - Provides a reference implementation for D400 Self-Calibration Routines flow. The scripts performs On-Chip Calibration, followed by Focal-Length calibration and finally, the Tare Calibration sub-routines. Follow the [White Paper Link](https://dev.intelrealsense.com/docs/self-calibration-for-depth-cameras) for in-depth description of the provided calibration methods.

## Pointcloud Visualization

Expand Down

0 comments on commit d66a6a2

Please sign in to comment.