Example #1
0
def test_including_pipe_files(cpp_pipeline_dir, py_pipeline_dir):
    from kwiver.vital.types import (
        DetectedObject,
        DetectedObjectSet,
        BoundingBoxD,
    )
    from kwiver.sprokit.adapters import adapter_data_set, embedded_pipeline

    pipeline_fname = "test_includes.pipe"
    path_to_pipe_file = os.path.join(py_pipeline_dir, pipeline_fname)

    ep = embedded_pipeline.EmbeddedPipeline()

    # Note that we include an extra parameter here. This is where
    # to look for included pipe files
    ep.build_pipeline(path_to_pipe_file, py_pipeline_dir)

    ep.start()

    ads_in = adapter_data_set.AdapterDataSet.create()
    ads_in["port1"] = _create_detected_object_set()
    print("Sending ads:", ads_in)
    ep.send(ads_in)
    ep.send_end_of_input()

    while True:
        ods = ep.receive()
        if ods.is_end_of_data():
            break
        print("Recieved detected_object_set:", ods["port1"])

    ep.wait()
Example #2
0
def run_roundtrip_pipeline(py_pipeline_dir, ads_in):
    from kwiver.vital.types import (
        DetectedObject,
        DetectedObjectSet,
        BoundingBoxD,
    )
    from kwiver.sprokit.adapters import adapter_data_set, embedded_pipeline

    pipeline_fname = "py_to_cpp_type_conversion.pipe"
    path_to_pipe_file = os.path.join(py_pipeline_dir, pipeline_fname)

    ep = embedded_pipeline.EmbeddedPipeline()
    ep.build_pipeline(path_to_pipe_file)

    ep.start()

    print("Sending ads:", ads_in)
    ep.send(ads_in)
    ep.send_end_of_input()

    while True:
        ods = ep.receive()
        if ods.is_end_of_data():
            break
        print("Recieved detected_object_set:", ods["detected_object_set"])

    ep.wait()
Example #3
0
# Now load the image as a vital type
from PIL import Image
import numpy as np
import kwiver.vital.types as kvt

np_image = np.array(Image.open(im_loc))
vital_im = kvt.Image(np_image)
im_container = kvt.ImageContainer(vital_im)

# Run the pipeline
from kwiver.sprokit.adapters import adapter_data_set, embedded_pipeline

path_to_pipe_file = "pipelines/hough_detector.pipe"

ep = embedded_pipeline.EmbeddedPipeline()
ep.build_pipeline(path_to_pipe_file)

ep.start()

ads_in = adapter_data_set.AdapterDataSet.create()
ads_in["image"] = im_container
ep.send(ads_in)
ep.send_end_of_input()

while True:
    ads_out = ep.receive()

    if ads_out.is_end_of_data():
        break
Example #4
0
def test_api_calls(cpp_pipeline_dir, py_pipeline_dir):
    from kwiver.sprokit.adapters import embedded_pipeline
    from kwiver.sprokit.adapters import adapter_data_set

    pipeline_fname = "simple_embedded_pipeline.pipe"
    path_to_pipe_file = os.path.join(cpp_pipeline_dir, pipeline_fname)

    ep = embedded_pipeline.EmbeddedPipeline()
    ep.build_pipeline(path_to_pipe_file)

    # Check the input_ports
    input_list = ep.input_port_names()
    if len(input_list) != 3:
        test_error(
            "input_port_list() returned list of length {}, expected {}".format(
                len(input_list), 3))
    for port in input_list:
        print("    " + port)

    # Check the output ports
    output_list = ep.output_port_names()
    if len(output_list) != 3:
        test_error(
            "output_port_list() returned list of length {}, expected {}".
            format(len(output_list), 3))
    for port in output_list:
        print("    " + port)

    # Test that we can't call wait() yet
    try:
        ep.wait()
    except RuntimeError:
        pass
    else:
        test_error("Calling wait() before start() should throw an error")

    ep.start()

    # Now send some data
    for i in range(10):
        ds = adapter_data_set.AdapterDataSet.create()

        for val, port in enumerate(input_list, start=i):
            ds[port] = val

        print("sending set:", i)

        ep.send(ds)

    print("Sending end of input element")
    ep.send_end_of_input()

    print("pipeline is full:", ep.full())
    print("pipeline is empty:", ep.empty())
    while True:
        ods = ep.receive()
        if ods.is_end_of_data():
            if not ep.at_end():
                test_error("at_end() not set correctly")
            break
        for (port, d) in ods:
            print("   port:", port, " value:", d.get_int())

    ep.wait()

    #######
    # Still need to test stop()
    ep = embedded_pipeline.EmbeddedPipeline()
    ep.build_pipeline(path_to_pipe_file)
    ep.start()
    ds = adapter_data_set.AdapterDataSet.create()
    ep.send_end_of_input()
    ods = ep.receive()
    ep.stop()
Example #5
0
def test_create(cpp_pipeline_dir, py_pipeline_dir):
    from kwiver.sprokit.adapters import embedded_pipeline

    embedded_pipeline.EmbeddedPipeline()