Пример #1
0
def main():
    stage = mpipe.OrderedStage(echo)
    pipe = mpipe.Pipeline(stage)

    for val in (0, 1, 2, 3):
        pipe.put(val)

    pipe.put(None)  # Stop the pipeline.
Пример #2
0
def main(watched_path, mountpoint, logfile="test_log.csv"):
    oh = OutputHandler.OutputHandler(logfile)

    def signal_handler(sig, frame):  # TODO maybe bug - needs two Ctrl+C to exit
        oh.close()

    signal.signal(signal.SIGINT, signal_handler)

    stage1 = mpipe.UnorderedStage(scanner.scan_file, size=3, max_backlog=3)
    stage2 = mpipe.OrderedStage(oh.write, size=1)
    pipeline = mpipe.Pipeline(stage1.link(stage2))

    watcher = Watcher(watched_path, pipeline)
    watcher.main([sys.argv[0], mountpoint], foreground=True)
Пример #3
0
import mpipe


def echo(value):
    print(value)


stage = mpipe.OrderedStage(echo)
pipe = mpipe.Pipeline(stage)

for val in (0, 1, 2, 3):
    pipe.put(val)

pipe.put(None)  # Stop the pipeline.
Пример #4
0
    
    


if __name__ == "__main__":
    
    
    
    for f in range(2):
        frame = camera.capture(encoding="raw")
        ls[f] = np.ctypeslib.as_array(frame.buffer_ptr[0].data,shape=(800,1280))
        del frame
    i = 2
    cont = True
    while cont:
        stage1 = mpipe.OrderedStage(cap, 1)
        stage2 = mpipe.OrderedStage(processing, 1)
        pipe = mpipe.Pipeline(stage1.link(stage2))
        
        pipe.put(i,camera,ls)
        
        if(i==100):
            i=0
        else:
            i+=1
        for result in pipe.results():
            counter = result
            if counter >pix_threshold:
                cont = False
        
    for i in range(100):
Пример #5
0
# Create the output window.
cv2.namedWindow('diff average 4', cv2.cv.CV_WINDOW_NORMAL)

def step2(tstamp):
    """Display the image, stamped with framerate."""
    fps_text = '{:.2f}, {:.2f}, {:.2f} fps'.format(*framerate2.tick())
    util.writeOSD(common[tstamp]['image_diff'], (fps_text,))
    cv2.imshow('diff average 4', common[tstamp]['image_diff'])
    cv2.waitKey(1)  # Allow HighGUI to process event.
    return tstamp

# Assemble the pipeline.
stage1 = mpipe.Stage(Step1)
stage2 = mpipe.FilterStage(
    (mpipe.OrderedStage(step2),),
    max_tasks=2,  # Allow maximum 2 tasks in the viewer stage.
    drop_results=True,
    )
stage1.link(stage2)
pipe = mpipe.Pipeline(
    mpipe.FilterStage(
        (stage1,),
        max_tasks=3,  # Allow maximum 3 tasks in pipeline.
        drop_results=True,
        )
    )

# Create an auxiliary process (modeled as a one-task pipeline)
# that simply pulls results from the image processing pipeline, 
# and deallocates associated shared memory after allowing
Пример #6
0
# Create the output window.
cv2.namedWindow('diff average 3', cv2.cv.CV_WINDOW_NORMAL)


def step2(tstamp):
    """Display the image, stamped with framerate."""
    fps_text = '{:.2f}, {:.2f}, {:.2f} fps'.format(*framerate.tick())
    util.writeOSD(common[tstamp]['image_diff'], (fps_text, ))
    cv2.imshow('diff average 3', common[tstamp]['image_diff'])
    cv2.waitKey(1)  # Allow HighGUI to process event.
    return tstamp


# Assemble the pipeline.
stage1 = mpipe.Stage(Step1)
stage2 = mpipe.OrderedStage(step2)
stage1.link(stage2)
pipe = mpipe.Pipeline(stage1)


# Create an auxiliary process (modeled as a one-task pipeline)
# that simply pulls results from the image processing pipeline,
# and deallocates associated shared memory after allowing
# the designated amount of time to pass.
def deallocate(age):
    for tstamp in pipe.results():
        delta = datetime.datetime.now() - tstamp
        duration = datetime.timedelta(seconds=age) - delta
        if duration > datetime.timedelta():
            time.sleep(duration.total_seconds())
        del common[tstamp]