예제 #1
0
def test_create_instances_with_patterns() -> None:
    # A first rig model defined as left/right/top/bottom
    instance1 = [
        "12345_left.jpg",
        "12345_bottom.jpg",
        "12345_top.jpg",
        "12345_right.jpg",
    ]
    instance2 = [
        "1234567_left.jpg",
        "1234567_bottom.jpg",
        "1234567_top.jpg",
        "1234567_right.jpg",
    ]
    patterns_12 = {
        "camera_left": "(left)",
        "camera_right": "(right)",
        "camera_top": "(top)",
        "camera_bottom": "(bottom)",
    }

    # A second one as RED/GREEN/BLUE
    instance3 = [
        "RED_SENSOR_001-12345678.jpg",
        "GREEN_SENSOR_002-12345678.jpg",
        "BLUE_SENSOR_003-12345678.jpg",
    ]
    patterns_3 = {
        "red": "(RED_SENSOR_001)",
        "green": "(GREEN_SENSOR_002)",
        "blue": "(BLUE_SENSOR_003)",
    }

    # Run detection with these two rig model patterns
    rig_patterns = patterns_12
    rig_patterns.update(patterns_3)
    instances = rig.create_instances_with_patterns(
        instance1 + instance2 + instance3, rig_patterns)

    # Ensure we have 2 instance for the first rig, and 1 for the second
    assert len(instances) == 3

    recovered_instance1 = instances["12345_.jpg"]
    assert [x[0] for x in recovered_instance1] == instance1

    recovered_instance2 = instances["1234567_.jpg"]
    assert [x[0] for x in recovered_instance2] == instance2

    recovered_instance3 = instances["-12345678.jpg"]
    assert [x[0] for x in recovered_instance3] == instance3
예제 #2
0
def test_create_instances_with_patterns() -> None:
    # A first rig model defined as left/right/top/bottom
    instance1 = [
        "12345_left.jpg",
        "12345_bottom.jpg",
        "12345_top.jpg",
        "12345_right.jpg",
    ]
    instance2 = [
        "1234567_left.jpg",
        "1234567_bottom.jpg",
        "1234567_top.jpg",
        "1234567_right.jpg",
    ]
    patterns_12 = {
        "camera_left": "(left)",
        "camera_right": "(right)",
        "camera_top": "(top)",
        "camera_bottom": "(bottom)",
    }

    # A second one as RED/GREEN/BLUE
    instance3 = [
        "RED_SENSOR_001-1234567.jpg",
        "GREEN_SENSOR_002-1234567.jpg",
        "BLUE_SENSOR_003-1234567.jpg",
    ]
    patterns_3 = {
        "red": "(RED_SENSOR_001)",
        "green": "(GREEN_SENSOR_002)",
        "blue": "(BLUE_SENSOR_003)",
    }

    # Run detection with these two rig model patterns
    rig_patterns = {"rig_model_1": patterns_12, "rig_model_2": patterns_3}
    instances = rig.create_instances_with_patterns(
        instance1 + instance2 + instance3, rig_patterns)

    # Ensure we have 2 instance for thr first rig, and one for the second
    assert len(instances) == 2

    rig1 = instances["rig_model_1"]
    assert len(rig1) == 2
    assert [x[0] for x in rig1[0]] == instance1
    assert [x[0] for x in rig1[1]] == instance2

    rig2 = instances["rig_model_2"]
    assert len(rig2) == 1
    assert [x[0] for x in rig2[0]] == instance3