예제 #1
0
def test_user_defined_strands(nlevels, SchedType, execfn, expect):
    s1 = ecto.Strand()
    s2 = s1
    s3 = ecto.Strand()

    print "s1.id ==", s1.id
    print "s2.id ==", s2.id
    print "s3.id ==", s3.id
    assert s1.id == s2.id
    assert s3.id != s2.id
    assert s3.id != s1.id

    plasm = ecto.Plasm()
    # plasm.movie_out("strands_%03d.dot")

    gen = ecto_test.Generate("GENERATE", step=1.0, start=1.0)
    noncurr = ecto_test.DontCallMeFromTwoThreads("ALPHA", strand=s1)
    plasm.connect(gen[:] >> noncurr[:])

    for k in range(nlevels):
        n = ecto_test.DontCallMeFromTwoThreads("BETA_%d" % k, strand=s2)
        plasm.connect(noncurr[:] >> n[:])
        noncurr = n

    printer = ecto_test.Printer("PRINTER")
    plasm.connect(noncurr[:] >> printer[:])

    sched = SchedType(plasm)
    print "sched=", sched
    execfn(sched)

    result = noncurr.outputs.out
    print "result=", result, "expect=", expect
    assert (result == expect)
예제 #2
0
def test_strand_basic_semantics():
    s = ecto.Strand()
    print "s.id =", s.id
    orig_id = s.id

    c = ecto_test.DontCallMeFromTwoThreads("CRASHY", strand=s)
    c2 = ecto_test.DontCallMeFromTwoThreads("CRASHY2", strand=s)
    c3 = ecto_test.DontCallMeFromTwoThreads("CRASHY3", strand=s)
    p = ecto.Plasm()
    gen = ecto_test.Generate("GENERATE", step=1.0, start=1.0)
    p.connect(gen[:] >> c[:])
    p.connect(c[:] >> c2[:])
    p.connect(c2[:] >> c3[:])
    sched = ecto.schedulers.Multithreaded(p)
    sched.execute(10)
예제 #3
0
#!/usr/bin/env python

import ecto, ecto_test

s1 = ecto.Strand()  # No cells that have this strand will run concurrenly

plasm = ecto.Plasm()
gen = ecto_test.Generate("Gen", step=1.0, start=1.0)
noncurr = ecto_test.DontCallMeFromTwoThreads("Unsafe0", strand=s1)
plasm.connect(gen['out'] >> noncurr['in'])

for k in range(3):
    next = ecto_test.DontCallMeFromTwoThreads("Unsafe%u" % (k + 1), strand=s1)
    plasm.connect(noncurr['out'] >> next['in'])
    noncurr = next

printer = ecto_test.Printer()
plasm.connect(noncurr['out'] >> printer['in'])

if __name__ == '__main__':
    sched = ecto.schedulers.Threadpool(plasm)
    sched.execute(niter=2, nthreads=8)
예제 #4
0
#!/usr/bin/env python
import ecto
from ecto_opencv import highgui, calib, imgproc

plasm = ecto.Plasm()
sched = ecto.schedulers.Threadpool(plasm)

video_cap = highgui.VideoCapture(video_device=0)
fps = highgui.FPSDrawer()
rgb2gray = imgproc.cvtColor('rgb -> gray', flag=7)

display_strand = ecto.Strand()

checker_detector = calib.PatternDetector('Checker Detector',
                                         rows=5, cols=4,
                                         pattern_type="chessboard",
                                         square_size=0.03)
circle_detector = calib.PatternDetector('Dot Detector',
                                        rows=7, cols=3, pattern_type="acircles",
                                        square_size=0.03)
circle_drawer = calib.PatternDrawer('Circle Draw',
                                    rows=7, cols=3)
checker_drawer = calib.PatternDrawer('Checker Draw',
                                     rows=5, cols=4)
circle_display = highgui.imshow('Pattern show',
                                name='Pattern', waitKey= 2, maximize=True,
                                strand=display_strand)

plasm.connect(video_cap['image'] >> circle_drawer['input'],
               circle_drawer['out'] >> checker_drawer['input'],
               checker_drawer['out'] >> fps['image'],