feat(calibrate): integrate multi-frame depth pooling with --depth-pool-size flag
This commit is contained in:
@@ -67,7 +67,7 @@ def test_benchmark_matrix(mock_dependencies):
|
||||
"frame_index": 100,
|
||||
}
|
||||
|
||||
verification_frames = {serial_int: vf}
|
||||
verification_frames = {serial_int: [vf]}
|
||||
first_frames = {serial_int: vf}
|
||||
marker_geometry = {1: np.zeros((4, 3))}
|
||||
camera_matrices = {serial_int: np.eye(3)}
|
||||
@@ -100,6 +100,7 @@ def test_verify_only(mock_dependencies, tmp_path):
|
||||
|
||||
# Setup inputs
|
||||
serial = "123456"
|
||||
serial_int = int(serial)
|
||||
results = {
|
||||
serial: {
|
||||
"pose": "1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1", # Identity matrix flattened
|
||||
@@ -107,16 +108,18 @@ def test_verify_only(mock_dependencies, tmp_path):
|
||||
}
|
||||
}
|
||||
verification_frames = {
|
||||
serial: {
|
||||
"frame": MagicMock(
|
||||
depth_map=np.zeros((10, 10)), confidence_map=np.zeros((10, 10))
|
||||
),
|
||||
"ids": np.array([[1]]),
|
||||
"corners": np.zeros((1, 4, 2)),
|
||||
}
|
||||
serial_int: [
|
||||
{
|
||||
"frame": MagicMock(
|
||||
depth_map=np.zeros((10, 10)), confidence_map=np.zeros((10, 10))
|
||||
),
|
||||
"ids": np.array([[1]]),
|
||||
"corners": np.zeros((1, 4, 2)),
|
||||
}
|
||||
]
|
||||
}
|
||||
marker_geometry = {1: np.zeros((4, 3))}
|
||||
camera_matrices = {serial: np.eye(3)}
|
||||
camera_matrices = {serial_int: np.eye(3)}
|
||||
|
||||
updated_results, csv_rows = apply_depth_verify_refine_postprocess(
|
||||
results=results,
|
||||
@@ -146,18 +149,21 @@ def test_refine_depth(mock_dependencies):
|
||||
|
||||
# Setup inputs
|
||||
serial = "123456"
|
||||
serial_int = int(serial)
|
||||
results = {serial: {"pose": "1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1", "stats": {}}}
|
||||
verification_frames = {
|
||||
serial: {
|
||||
"frame": MagicMock(
|
||||
depth_map=np.zeros((10, 10)), confidence_map=np.zeros((10, 10))
|
||||
),
|
||||
"ids": np.array([[1]]),
|
||||
"corners": np.zeros((1, 4, 2)),
|
||||
}
|
||||
serial_int: [
|
||||
{
|
||||
"frame": MagicMock(
|
||||
depth_map=np.zeros((10, 10)), confidence_map=np.zeros((10, 10))
|
||||
),
|
||||
"ids": np.array([[1]]),
|
||||
"corners": np.zeros((1, 4, 2)),
|
||||
}
|
||||
]
|
||||
}
|
||||
marker_geometry = {1: np.zeros((4, 3))}
|
||||
camera_matrices = {serial: np.eye(3)}
|
||||
camera_matrices = {serial_int: np.eye(3)}
|
||||
|
||||
# Mock verify to return different values for pre and post
|
||||
# First call (pre-refine)
|
||||
@@ -199,15 +205,18 @@ def test_refine_depth_warning_negligible_improvement(mock_dependencies):
|
||||
mock_verify, mock_refine, mock_echo = mock_dependencies
|
||||
|
||||
serial = "123456"
|
||||
serial_int = int(serial)
|
||||
results = {serial: {"pose": "1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1", "stats": {}}}
|
||||
verification_frames = {
|
||||
serial: {
|
||||
"frame": MagicMock(depth_map=np.zeros((10, 10))),
|
||||
"ids": np.array([[1]]),
|
||||
}
|
||||
serial_int: [
|
||||
{
|
||||
"frame": MagicMock(depth_map=np.zeros((10, 10))),
|
||||
"ids": np.array([[1]]),
|
||||
}
|
||||
]
|
||||
}
|
||||
marker_geometry = {1: np.zeros((4, 3))}
|
||||
camera_matrices = {serial: np.eye(3)}
|
||||
camera_matrices = {serial_int: np.eye(3)}
|
||||
|
||||
# RMSE stays almost same
|
||||
res_pre = MagicMock(rmse=0.1, n_valid=10, residuals=[])
|
||||
@@ -249,15 +258,18 @@ def test_refine_depth_warning_failed_or_stalled(mock_dependencies):
|
||||
mock_verify, mock_refine, mock_echo = mock_dependencies
|
||||
|
||||
serial = "123456"
|
||||
serial_int = int(serial)
|
||||
results = {serial: {"pose": "1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1", "stats": {}}}
|
||||
verification_frames = {
|
||||
serial: {
|
||||
"frame": MagicMock(depth_map=np.zeros((10, 10))),
|
||||
"ids": np.array([[1]]),
|
||||
}
|
||||
serial_int: [
|
||||
{
|
||||
"frame": MagicMock(depth_map=np.zeros((10, 10))),
|
||||
"ids": np.array([[1]]),
|
||||
}
|
||||
]
|
||||
}
|
||||
marker_geometry = {1: np.zeros((4, 3))}
|
||||
camera_matrices = {serial: np.eye(3)}
|
||||
camera_matrices = {serial_int: np.eye(3)}
|
||||
|
||||
res_pre = MagicMock(rmse=0.1, n_valid=10, residuals=[])
|
||||
res_post = MagicMock(rmse=0.1, n_valid=10, residuals=[])
|
||||
@@ -298,18 +310,21 @@ def test_csv_output(mock_dependencies, tmp_path):
|
||||
csv_path = tmp_path / "report.csv"
|
||||
|
||||
serial = "123456"
|
||||
serial_int = int(serial)
|
||||
results = {serial: {"pose": "1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1", "stats": {}}}
|
||||
verification_frames = {
|
||||
serial: {
|
||||
"frame": MagicMock(
|
||||
depth_map=np.zeros((10, 10)), confidence_map=np.zeros((10, 10))
|
||||
),
|
||||
"ids": np.array([[1]]),
|
||||
"corners": np.zeros((1, 4, 2)),
|
||||
}
|
||||
serial_int: [
|
||||
{
|
||||
"frame": MagicMock(
|
||||
depth_map=np.zeros((10, 10)), confidence_map=np.zeros((10, 10))
|
||||
),
|
||||
"ids": np.array([[1]]),
|
||||
"corners": np.zeros((1, 4, 2)),
|
||||
}
|
||||
]
|
||||
}
|
||||
marker_geometry = {1: np.zeros((4, 3))}
|
||||
camera_matrices = {serial: np.eye(3)}
|
||||
camera_matrices = {serial_int: np.eye(3)}
|
||||
|
||||
updated_results, csv_rows = apply_depth_verify_refine_postprocess(
|
||||
results=results,
|
||||
@@ -324,11 +339,11 @@ def test_csv_output(mock_dependencies, tmp_path):
|
||||
)
|
||||
|
||||
assert len(csv_rows) == 2 # From mock_verify_res.residuals
|
||||
assert csv_rows[0] == [serial, 1, 0, 0.01]
|
||||
assert csv_rows[0] == [serial_int, 1, 0, 0.01]
|
||||
|
||||
# Verify file content
|
||||
assert csv_path.exists()
|
||||
content = csv_path.read_text().splitlines()
|
||||
assert len(content) == 3 # Header + 2 rows
|
||||
assert content[0] == "serial,marker_id,corner_idx,residual"
|
||||
assert content[1] == f"{serial},1,0,0.01"
|
||||
assert content[1] == f"{serial_int},1,0,0.01"
|
||||
|
||||
Reference in New Issue
Block a user