Esempio n. 1
0
def main(coef, n_classes, frames, fps, width, height, channels):

    seg1_target = target_generator(lambda x: segmentation1(x, 0.03 * coef))
    seg2_target = target_generator(lambda x: segmentation2(x, 0.04 * coef))

    @target_generator
    def class_target(x):
        return classification(x, 0.05 * coef, n_classes)

    target_list = [seg1_target, seg2_target, class_target]
    queue_list = [(queue.Queue(), queue.Queue()) for target in target_list]
    thread_list = [
        Thread(target=target, args=qio)
        for target, qio in zip(target_list, queue_list)
    ]

    for thread in thread_list:
        thread.start()

    time_recorder = TimeRecord()

    size = (height, width, channels)
    for frame in fake_video(frames=frames, fps=fps, size=size):
        with time_recorder:

            for qi, _ in queue_list:
                qi.put(frame)
            for _, qo in queue_list:
                qo.get()

    time_recorder.report()
Esempio n. 2
0
def do_segmentation1(sleep_time):
    output = segmentation1(G["frame"], sleep_time)
    np.copyto(G["output_segmentation1"],
              output)  # TODO: adapt segmentation1 to use pre-allocated memory
Esempio n. 3
0
def process(frame, base_sleep_time, n_classes):
    rs1 = segmentation1(frame, base_sleep_time * 0.03)
    rs2 = segmentation2(frame, base_sleep_time * 0.04)
    rs3 = classification(frame, base_sleep_time * 0.05, n_classes)
    return rs1, rs2, rs3
Esempio n. 4
0
def seg1_target(x):
    return segmentation1(x, 0.03 * g_dict["coef"])
Esempio n. 5
0
 def process(self, x):
     return segmentation1(x, self.sleep_time)