Beispiel #1
0
 def __init__(self, nargs):
     self.args = []
     self.complete = np.ones(nargs, dtype=np.bool)
     self.complete[:] = False
     self.source = ports.EventSource()
     for i in range(nargs):
         self.args.append(None)
Beispiel #2
0
 def __init__(self,
              dist,
              min_neighborhood=1,
              thresh_intensity=50,
              scale_intensity=1,
              debug=False):
     self.algo = DBSCAN(eps=dist, min_samples=min_neighborhood, n_jobs=-1)
     self.sink_image = ports.StateSink()
     self.thresh_intensity = thresh_intensity
     self.scale_intensity = scale_intensity
     self.debug = debug
     self.out_debug_image = ports.EventSource()
     self.data = None
     self.debug_buf = None
 def __init__(self,
              detection_threshold=0.05,
              tracking_threshold=10,
              use_opencv=False):
     self.detector = dlib.get_frontal_face_detector()
     self.tracker = dlib.correlation_tracker()
     model_dir = path.join(path.dirname(path.abspath(__file__)), 'models')
     self.predictor = dlib.shape_predictor(
         path.join(model_dir, 'shape_predictor_68_face_landmarks.dat'))
     self.face_cascade = cv2.CascadeClassifier(
         path.join(model_dir, 'haarcascade_frontalface_alt2.xml'))
     self.good = False
     self.dt = detection_threshold
     self.tt = tracking_threshold
     self.u_cv2 = use_opencv
     self.roi_size = (800, 600)
     self.roi_buffer = np.zeros((self.roi_size[0], self.roi_size[1], 3),
                                np.uint8)
     self.dlib_roi = dlib.rectangle(0, 0, self.roi_size[1],
                                    self.roi_size[0])
     self.source_bounds = ports.EventSource()
     self.source_landmarks = ports.EventSource()
     self.sink_image = ports.EventSink(self.track_face)
Beispiel #4
0
 def __init__(self, thresh_intensity=50, debug=False):
     self.sink_image = ports.StateSink()
     self.thresh_intensity = thresh_intensity
     self.debug = debug
     self.out_debug_image = ports.EventSource()
 def __init__(self):
     BaseVideoSource.__init__(self)
     self.sink_filename = ports.StateSink()
     self.source_eof = ports.EventSource()
     self.source_file_change = ports.EventSource()
     self.cap = None
from __future__ import print_function
from dataflow import ports


def add(x):  # Returns a callable object
    return lambda y: x + y


# Event example code
e_source = ports.EventSource()
e_terminal = ports.EventTerminal()

# 1 shall be added to the value fired from the source, then forwarded to the terminal
e_source >> add(1) >> e_terminal

# 4 shall be added to the value from the terminal, then printed
e_terminal >> add(4) >> print

# the value from the terminal shall be printed
e_terminal >> print

e_source.fire(5)  # fires 5, thereby printing 10 and 6.


# State example code
def s_source():  # Callable object
    return 5


s_sink_1 = ports.StateSink()
s_sink_2 = ports.StateSink()
 def __init__(self):
     self.img = None
     self.source_mask = ports.EventSource()
Beispiel #8
0
 def __init__(self, model):
     self.detector = cv2.CascadeClassifier(model)
     self.source_detection = ports.EventSource()
Beispiel #9
0
 def __init__(self, models):
     self.detectors = []
     for model in models:
         self.detectors.append(cv2.CascadeClassifier(model))
     self.source_detection = ports.EventSource()
Beispiel #10
0
 def __init__(self, n, length):
     self.arr = NpCircularArray(n, length)
     self.source_buf = ports.EventSource()
Beispiel #11
0
 def __init__(self):
     self.sink_control = ports.StateSink()
     self.source = ports.EventSource()
Beispiel #12
0
 def __init__(self):
     self.buf = None
     self.source = ports.EventSource()
Beispiel #13
0
 def __init__(self):
     self.c = 0
     self.out_event = ports.EventSource()
Beispiel #14
0
    def __init__(self):
        self.sink_control = ports.StateSink()
        self.sink = ports.StateSink()

    def __call__(self, *args):
        if self.sink_control.get():
            return self.sink.get(*args)
        else:
            return None


class EventGate:
    def __init__(self):
        self.sink_control = ports.StateSink()
        self.source = ports.EventSource()

    def sink(self, *args):
        if self.sink_control.get():
            self.source.fire(*args)


if __name__ == '__main__':
    es_buf = EventToState()
    so = ports.EventSource()
    si = ports.StateSink()
    so >> es_buf.in_event
    si << es_buf.out_state

    so.fire(5)
    print(si.get())