Пример #1
0
def test_mix_new_and_get():
    from kwiver.sprokit.pipeline import datum
    from kwiver.vital import types as kvt

    # Try creating with generic constructor first, retrieving with
    # type specific get function
    datum_inst = datum.new("string_value")
    check_same_type(datum_inst.get_string(), "string_value")

    datum_inst = datum.new(kvt.Timestamp(1000000000, 10))
    check_same_type(datum_inst.get_timestamp(), kvt.Timestamp(1000000000, 10))

    datum_inst = datum.new(datum.VectorString(["element1", "element2"]))
    check_same_type(datum_inst.get_string_vector(),
                    datum.VectorString(["element1", "element2"]))

    # Now try the opposite
    datum_inst = datum.new_string("string_value")
    check_same_type(datum_inst.get_datum(), "string_value")

    datum_inst = datum.new_timestamp(kvt.Timestamp(1000000000, 10))
    check_same_type(datum_inst.get_datum(), kvt.Timestamp(1000000000, 10))

    datum_inst = datum.new_string_vector(
        datum.VectorString(["element1", "element2"]))
    check_same_type(datum_inst.get_datum(),
                    datum.VectorString(["element1", "element2"]))
Пример #2
0
def test_overwrite():
    from kwiver.vital import types as kvt
    from kwiver.sprokit.adapters import adapter_data_set

    OVERWRITE_PORT = "test_overwrite_port"
    ads = adapter_data_set.AdapterDataSet.create()

    # Overwriting with same datum
    ads.add_datum(OVERWRITE_PORT, datum.new("d2"))
    overwrite_helper(
        ads.add_datum,
        ads.get_port_data,
        datum.new("d3"),
        "datum_string",
        OVERWRITE_PORT,
    )

    # Overwriting with completely different types
    overwrite_helper(
        ads.add_datum, ads.get_port_data, datum.new(12), "datum_int", OVERWRITE_PORT
    )
    overwrite_helper(
        ads._add_string_vector,
        ads._get_port_data_string_vector,
        adapter_data_set.VectorString(["baz", "qux"]),
        "string_vector",
        OVERWRITE_PORT,
    )
    overwrite_helper(
        ads._add_timestamp,
        ads._get_port_data_timestamp,
        kvt.Timestamp(100, 10),
        "timestamp",
        OVERWRITE_PORT,
    )
    overwrite_helper(ads.add_value, ads.get_port_data, 15, "int", OVERWRITE_PORT)
    overwrite_helper(
        ads._add_double_vector,
        ads._get_port_data_double_vector,
        adapter_data_set.VectorDouble([4, 8]),
        "double_vector",
        OVERWRITE_PORT,
    )
Пример #3
0
def test_new():
    from kwiver.sprokit.pipeline import datum

    d = datum.new('test_datum')

    if not d.type() == datum.DatumType.data:
        test_error("Datum type mismatch")

    if len(d.get_error()):
        test_error("A data datum has an error string")

    p = d.get_datum()

    if p is None:
        test_error("A data datum has None as its data")
Пример #4
0
def test_cpp_conversion(cpp_pipeline_dir, py_pipeline_dir):
    from kwiver.vital.types import DetectedObject, DetectedObjectSet, BoundingBox
    from kwiver.sprokit.adapters import adapter_data_set, embedded_pipeline
    from kwiver.sprokit.pipeline import datum

    ads_in = adapter_data_set.AdapterDataSet.create()
    ads_in["detected_object_set"] = _create_detected_object_set()

    print("Starting roundtrip pipeline with a detected_object_set")
    run_roundtrip_pipeline(py_pipeline_dir, ads_in)

    # Create fresh objects. Make sure that this also works with adding datums directly
    ads_in = adapter_data_set.AdapterDataSet.create()
    ads_in["detected_object_set"] = datum.new(_create_detected_object_set())
    print(
        "Starting roundtrip pipeline with a datum containing a detected_object_set"
    )
    run_roundtrip_pipeline(py_pipeline_dir, ads_in)
Пример #5
0
def check_automatic_conversion(val):
    from kwiver.sprokit.pipeline import datum

    datum_inst = datum.new(val)
    retrieved_val = datum_inst.get_datum()
    check_same_type(retrieved_val, val)
Пример #6
0
def test_add_get_datum():
    from kwiver.sprokit.adapters import adapter_data_set

    ads = adapter_data_set.AdapterDataSet.create()
    add_get_helper(ads, ads.add_datum, ads.get_port_data, datum.new("d1"), "datum")