Skip to content

Commit

Permalink
test-dds-librs-intrinsics uses two devices to avoid race condition
Browse files Browse the repository at this point in the history
  • Loading branch information
OhadMeir committed Jan 16, 2025
1 parent 829a932 commit 12d9131
Show file tree
Hide file tree
Showing 2 changed files with 94 additions and 11 deletions.
84 changes: 83 additions & 1 deletion unit-tests/dds/d455.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,7 @@ def color_stream():
stream = dds.color_stream_server( "Color", "RGB Camera" )
stream.init_profiles( color_stream_profiles(), 10 )
stream.init_options( rgb_camera_options() )
stream.set_intrinsics( color_stream_intrinsics() )
return stream


Expand Down Expand Up @@ -398,4 +399,85 @@ def get_extrinsics():
extrinsics[("Infrared_2","Infrared_1")] = extr

return extrinsics


def color_stream_intrinsics():
intrinsics = []

intr = dds.video_intrinsics();
intr.width = 1280
intr.height = 800
intr.principal_point.x = 648.580993652344
intr.principal_point.y = 398.820983886719
intr.focal_length.x = 636.450012207031
intr.focal_length.y = 635.621948242188
intr.distortion.model = dds.distortion_model.inverse_brown
intr.distortion.coeffs = [-0.0569772012531757,0.0660239011049271,0.000211432998185046,0.00068545201793313,-0.0208512991666794]
intrinsics.append( intr )

intr = dds.video_intrinsics();
intr.width = 1280
intr.height = 720
intr.principal_point.x = 648.580993652344
intr.principal_point.y = 358.821014404297
intr.focal_length.x = 636.450012207031
intr.focal_length.y = 635.622009277344
intr.distortion.model = dds.distortion_model.inverse_brown
intr.distortion.coeffs = [-0.0569772012531757,0.0660239011049271,0.000211432998185046,0.00068545201793313,-0.0208512991666794]
intrinsics.append( intr )

intr = dds.video_intrinsics();
intr.width = 848
intr.height = 480
intr.principal_point.x = 429.684906005859
intr.principal_point.y = 239.21891784668
intr.focal_length.x = 421.648132324219
intr.focal_length.y = 421.099578857422
intr.distortion.model = dds.distortion_model.inverse_brown
intr.distortion.coeffs = [-0.0569772012531757,0.0660239011049271,0.000211432998185046,0.00068545201793313,-0.0208512991666794]
intrinsics.append( intr )

intr = dds.video_intrinsics();
intr.width = 640
intr.height = 480
intr.principal_point.x = 325.148590087891
intr.principal_point.y = 239.292602539062
intr.focal_length.x = 381.869995117188
intr.focal_length.y = 381.373199462891
intr.distortion.model = dds.distortion_model.inverse_brown
intr.distortion.coeffs = [-0.0569772012531757,0.0660239011049271,0.000211432998185046,0.00068545201793313,-0.0208512991666794]
intrinsics.append( intr )

intr = dds.video_intrinsics();
intr.width = 640
intr.height = 360
intr.principal_point.x = 324.290496826172
intr.principal_point.y = 179.410507202148
intr.focal_length.x = 318.225006103516
intr.focal_length.y = 317.811004638672
intr.distortion.model = dds.distortion_model.inverse_brown
intr.distortion.coeffs = [-0.0569772012531757,0.0660239011049271,0.000211432998185046,0.00068545201793313,-0.0208512991666794]
intrinsics.append( intr )

intr = dds.video_intrinsics();
intr.width = 480
intr.height = 270
intr.principal_point.x = 243.217880249023
intr.principal_point.y = 134.557876586914
intr.focal_length.x = 238.668746948242
intr.focal_length.y = 238.358245849609
intr.distortion.model = dds.distortion_model.inverse_brown
intr.distortion.coeffs = [-0.0569772012531757,0.0660239011049271,0.000211432998185046,0.00068545201793313,-0.0208512991666794]
intrinsics.append( intr )

intr = dds.video_intrinsics();
intr.width = 424
intr.height = 240
intr.principal_point.x = 214.84245300293
intr.principal_point.y = 119.60945892334
intr.focal_length.x = 210.824066162109
intr.focal_length.y = 210.549789428711
intr.distortion.model = dds.distortion_model.inverse_brown
intr.distortion.coeffs = [-0.0569772012531757,0.0660239011049271,0.000211432998185046,0.00068545201793313,-0.0208512991666794]
intrinsics.append( intr )

return set( intrinsics )
21 changes: 11 additions & 10 deletions unit-tests/dds/test-librs-intrinsics.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

import pyrealdds as dds
import d435i
import d455

dds.debug( log.is_debug_on(), log.nested )

Expand All @@ -34,22 +35,22 @@ def broadcast_device( server, device_info ):

def build_scaled_intrinsics_server():
color = dds.color_stream_server( 'Color', 'RGB Camera' )
color.init_profiles( d435i.color_stream_profiles(), 8 )
color.init_profiles( d455.color_stream_profiles(), 5 )
color.init_options( [] )

# Add only a single set of intrinsics for 1920x1080, from which we expect to scale to all resolutions:
i = dds.video_intrinsics();
i.width = 1920
i.height = 1080
i.principal_point.x = 970.4506225585938
i.principal_point.y = 542.8473510742188
i.focal_length.x = 1362.133056640625
i.focal_length.y = 1362.629638671875
i.width = 1280
i.height = 720
i.principal_point.x = 648.580993652344
i.principal_point.y = 358.821014404297
i.focal_length.x = 636.450012207031
i.focal_length.y = 635.622009277344
i.distortion.model = dds.distortion_model.inverse_brown
i.distortion.coeffs = [0.0,0.0,0.0,0.0,0.0]
i.distortion.coeffs = [-0.0569772012531757,0.0660239011049271,0.000211432998185046,0.00068545201793313,-0.0208512991666794]
color.set_intrinsics( set( [i] ) )

dev = dds.device_server( participant, d435i.device_info.topic_root )
dev = dds.device_server( participant, d455.device_info.topic_root )
dev.init( [color], [], {} )
return dev

Expand Down Expand Up @@ -167,7 +168,7 @@ def close_server( instance ):
dev = None

with test.closure( 'Scaled intrinsics' ):
remote.run( 'instance = broadcast_device( build_scaled_intrinsics_server(), d435i.device_info )' )
remote.run( 'instance = broadcast_device( build_scaled_intrinsics_server(), d455.device_info )' )
dev = rs.wait_for_devices( context, rs.only_sw_devices, n=1. )
sensors = dev.query_sensors()
test.check_equal( len(sensors), 1 )
Expand Down

0 comments on commit 12d9131

Please sign in to comment.