Skip to content

Commit

Permalink
add another test for precise image encapsulation check
Browse files Browse the repository at this point in the history
  • Loading branch information
mmeijerdfki committed Dec 28, 2024
1 parent c3d3910 commit 49629c4
Showing 1 changed file with 57 additions and 9 deletions.
66 changes: 57 additions & 9 deletions tests/python/gRPC/images/test_gRPC_fb_queryImagePrecise.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,13 +113,7 @@ def send_tf(

header = createHeader(builder, ts, frame_id, project_uuid, str(uuid4()))

# make sure the frustum is above the query cube
trans = createVector3(builder, translation)

# this is equivalent to a Euler XYZ rotation with:
# X = 225°
# Y = 0°
# Z = -45°
quat = createQuaternion(builder, create_quat(*quaternion))

tf = createTransform(builder, trans, quat)
Expand All @@ -133,7 +127,7 @@ def send_tf(
return serialized_tf


def test_gRPC_fb_queryImagePrecise(grpc_channel, project_setup):
def test_gRPC_fb_queryImagePreciseIntersect(grpc_channel, project_setup):
_, proj_uuid = project_setup

timestamp_secs = 1661336507
Expand All @@ -147,11 +141,17 @@ def test_gRPC_fb_queryImagePrecise(grpc_channel, project_setup):
grpc_channel,
proj_uuid,
camera_intrinsics_uuid,
gRPC_fb_sendImages.generate_image_ressources(8),
8 * [ts],
gRPC_fb_sendImages.generate_image_ressources(1),
1 * [ts],
)

# make sure the frustum is above the query cube
trans = (-0.5, -0.5, 1.5)

# this is equivalent to a Euler XYZ rotation with:
# X = 225°
# Y = 0°
# Z = -45°
rot = (-0.354, 0.854, -0.354, 0.146)
send_tf(grpc_channel, proj_uuid, ts, trans, rot)

Expand All @@ -178,3 +178,51 @@ def test_gRPC_fb_queryImagePrecise(grpc_channel, project_setup):
assert sorted(
sent_images, key=lambda img: img["header"]["uuid_msgs"]
) == sorted(queried_images, key=lambda img: img["header"]["uuid_msgs"])


# this test should detect no intersection with the precise method
# but would fail with the AABB approximation
def test_gRPC_fb_queryImagePreciseNoIntersect(grpc_channel, project_setup):
_, proj_uuid = project_setup

timestamp_secs = 1661336507
timestamp_nanos = 1245

ts = (timestamp_secs, timestamp_nanos)

camera_intrinsics_uuid = send_simple_camintrinsics(grpc_channel, proj_uuid)

sent_images = gRPC_fb_sendImages.send_images(
grpc_channel,
proj_uuid,
camera_intrinsics_uuid,
gRPC_fb_sendImages.generate_image_ressources(1),
1 * [ts],
)

trans = (-2.3, 2, 1)
rot = (1, 0, 0, 0)
send_tf(grpc_channel, proj_uuid, ts, trans, rot)

builder = flatbuffers.Builder(1024)

verts = [
createPoint2d(builder, *p) for p in [(-1, 1), (-1, 3), (-2, 3), (-2, 1)]
]

polygon = createPolygon2D(builder, height=2, z=-0.5, vertices=verts)

queried_images = gRPC_fb_queryImages.query_images_raw(
builder, grpc_channel, proj_uuid, polygon2d=polygon
)

sent_images = [
fb_flatc_dict(img, SchemaFileNames.IMAGE) for img in sent_images
]

queried_images = [
fb_flatc_dict(img, SchemaFileNames.IMAGE) for img in queried_images
]

assert len(sent_images) > 0
assert len(queried_images) == 0

0 comments on commit 49629c4

Please sign in to comment.