private void InitializePipeline() { pipeline = Pipeline.Create(); var webcamConfig = MediaCaptureConfiguration.Default; webcamConfig.DeviceId = WebcamSymbolicLink; webcamConfig.Width = WebcamWidth; webcamConfig.Height = WebcamHeight; webcamConfig.Framerate = 30; webcamConfig.UseInSharedMode = true; var source = new MediaCapture(pipeline, webcamConfig); var flip = new FlipColorVideo(pipeline) { FlipHorizontal = FlipX, FlipVertical = FlipY }; source.PipeTo(flip.In, DeliveryPolicy.SynchronousOrThrottle); var openface = new OpenFace(pipeline) { CameraCalibFx = WebcamFx, CameraCalibFy = WebcamFy, CameraCalibCx = WebcamCx, CameraCalibCy = WebcamCy }; flip.PipeTo(openface.In, DeliveryPolicy.SynchronousOrThrottle); generator = new DisplayCoordianteGenerator(pipeline); var record = openface.Out.Join(generator.Out, Reproducible.Nearest <Vector2>(), (gp, display) => new GazeToDisplayCoordinateMappingRecord(gp, display), DeliveryPolicy.SynchronousOrThrottle, DeliveryPolicy.SynchronousOrThrottle); record.Do((d, e) => { AddRecord(d, e); }, DeliveryPolicy.SynchronousOrThrottle); }
public void Image_CropViaJoinOperator() { // Test that the pipeline's operator Crop() works on a stream of images and random rectangles using (var pipeline = Pipeline.Create("CropViaOperator")) { using (var sharedImage = ImagePool.GetOrCreate(this.testImage.Width, this.testImage.Height, this.testImage.PixelFormat)) { this.testImage.CopyTo(sharedImage.Resource); // Use a non-insignificant interval for both Sequences to ensure that the Join processes all // messages from both streams (default interval of 1-tick is too small to guarantee this). var images = Generators.Sequence(pipeline, sharedImage, x => sharedImage, 100, TimeSpan.FromMilliseconds(1)); var rects = Generators.Sequence( pipeline, new System.Drawing.Rectangle(0, 0, 1, 1), x => { Random r = new Random(); System.Drawing.Rectangle rect = default(System.Drawing.Rectangle); rect.X = r.Next(0, this.testImage.Width); rect.Y = r.Next(0, this.testImage.Height); rect.Width = r.Next(1, this.testImage.Width - rect.X); rect.Height = r.Next(1, this.testImage.Height - rect.Y); return(rect); }, 100, TimeSpan.FromMilliseconds(1)); images.Join(rects, Reproducible.Nearest <System.Drawing.Rectangle>()).Crop(); pipeline.Run(); } } }
public OpenPoseVisualizer(Pipeline pipeline) : base(pipeline) { DataInConnector = CreateInputConnectorFrom <OpenPoseDatum>(pipeline, nameof(DataIn)); ImageInConnector = CreateInputConnectorFrom <Shared <Image> >(pipeline, nameof(ImageIn)); Out = pipeline.CreateEmitter <Shared <Image> >(this, nameof(Out)); var joined = DataInConnector.Out.Join(ImageInConnector.Out, Reproducible.Nearest <Shared <Image> >()); joined.Do(Process); pipeline.PipelineCompleted += OnPipelineCompleted; display.PropertyChanged += (sender, e) => { if (e.PropertyName == nameof(display.VideoImage)) { PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(Image))); } }; display.ReceivedFrames.PropertyChanged += (sender, e) => { if (e.PropertyName == nameof(display.RenderedFrames.Rate)) { PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(FrameRate))); } }; }
public DeepSpeechRecognizer(Pipeline pipeline) : base(pipeline, nameof(DeepSpeechRecognizer)) { // Create connector this.audioIn = this.CreateInputConnectorFrom <AudioBuffer>(pipeline, nameof(this.AudioIn)); // Define the outputs var textOut = this.CreateOutputConnectorTo <String>(pipeline, nameof(this.TextOut)); this.TextOut = textOut.Out; // sub-recognizer var recognizer = new DeepSpeechSubRecognizer(this); // voice activity detector var voiceDet = new SystemVoiceActivityDetector(this); this.audioIn.Out.PipeTo(voiceDet); //this.audioIn.Do(x => //{ // Console.Write('.'); //}); var voiceAudio = this.audioIn.Out.Join(voiceDet.Out, Reproducible.Nearest <bool>(RelativeTimeInterval.Future())); voiceAudio.PipeTo(recognizer.In); recognizer.PipeTo(textOut); }
public void SparseJoin() { var results = new List <Dictionary <string, int> >(); using (var p = Pipeline.Create()) { var sourceA = Generators.Sequence(p, 100, i => i + 1, 30, TimeSpan.FromTicks(10)); var sourceB = Generators.Sequence(p, 100, i => i + 1, 10, TimeSpan.FromTicks(30)); var sourceC = Generators.Sequence(p, 100, i => i + 1, 3, TimeSpan.FromTicks(100)); var keyMapping = sourceA.Select(i => (i % 10 != 0) ? new Dictionary <string, int> { { "zero", 0 }, { "one", 1 } } : new Dictionary <string, int> { { "zero", 0 }, { "two", 2 } }); Operators .Join(keyMapping, new[] { sourceA, sourceB, sourceC }, Reproducible.Nearest <int>(TimeSpan.FromTicks(5))) .Do(t => results.Add(t.DeepClone())); p.Run(new ReplayDescriptor(DateTime.Now, DateTime.MaxValue)); } Assert.AreEqual(12, results.Count); CollectionAssert.AreEqual(new Dictionary <string, int> { { "zero", 100 }, { "two", 100 } }, results[0]); CollectionAssert.AreEqual(new Dictionary <string, int> { { "zero", 103 }, { "one", 101 } }, results[1]); CollectionAssert.AreEqual(new Dictionary <string, int> { { "zero", 106 }, { "one", 102 } }, results[2]); CollectionAssert.AreEqual(new Dictionary <string, int> { { "zero", 109 }, { "one", 103 } }, results[3]); CollectionAssert.AreEqual(new Dictionary <string, int> { { "zero", 110 }, { "two", 101 } }, results[4]); CollectionAssert.AreEqual(new Dictionary <string, int> { { "zero", 112 }, { "one", 104 } }, results[5]); CollectionAssert.AreEqual(new Dictionary <string, int> { { "zero", 115 }, { "one", 105 } }, results[6]); CollectionAssert.AreEqual(new Dictionary <string, int> { { "zero", 118 }, { "one", 106 } }, results[7]); CollectionAssert.AreEqual(new Dictionary <string, int> { { "zero", 120 }, { "two", 102 } }, results[8]); CollectionAssert.AreEqual(new Dictionary <string, int> { { "zero", 121 }, { "one", 107 } }, results[9]); CollectionAssert.AreEqual(new Dictionary <string, int> { { "zero", 124 }, { "one", 108 } }, results[10]); CollectionAssert.AreEqual(new Dictionary <string, int> { { "zero", 127 }, { "one", 109 } }, results[11]); }
public void TupleCollapsingJoin() { using (var pipeline = Pipeline.Create()) { var range = Generators.Range(pipeline, 0, 10, TimeSpan.FromMilliseconds(10)); var sourceA = range.Select(x => $"A{x}"); var sourceB = range.Select(x => $"B{x}"); var sourceC = range.Select(x => $"C{x}"); var sourceD = range.Select(x => $"D{x}"); var sourceE = range.Select(x => $"E{x}"); var sourceF = range.Select(x => $"F{x}"); var sourceG = range.Select(x => $"G{x}"); var tuples = sourceA .Join(sourceB, Reproducible.Nearest <string>()) .Join(sourceC, Reproducible.Nearest <string>()) .Join(sourceD, Reproducible.Nearest <string>()) .Join(sourceE, Reproducible.Nearest <string>()) .Join(sourceF, Reproducible.Nearest <string>()) .Join(sourceG, Reproducible.Nearest <string>()) .ToObservable().ToListObservable(); pipeline.Run(); var results = tuples.AsEnumerable().ToArray(); Assert.IsTrue(Enumerable.SequenceEqual( new ValueTuple <string, string, string, string, string, string, string>[] { ValueTuple.Create("A0", "B0", "C0", "D0", "E0", "F0", "G0"), ValueTuple.Create("A1", "B1", "C1", "D1", "E1", "F1", "G1"), ValueTuple.Create("A2", "B2", "C2", "D2", "E2", "F2", "G2"), ValueTuple.Create("A3", "B3", "C3", "D3", "E3", "F3", "G3"), ValueTuple.Create("A4", "B4", "C4", "D4", "E4", "F4", "G4"), ValueTuple.Create("A5", "B5", "C5", "D5", "E5", "F5", "G5"), ValueTuple.Create("A6", "B6", "C6", "D6", "E6", "F6", "G6"), ValueTuple.Create("A7", "B7", "C7", "D7", "E7", "F7", "G7"), ValueTuple.Create("A8", "B8", "C8", "D8", "E8", "F8", "G8"), ValueTuple.Create("A9", "B9", "C9", "D9", "E9", "F9", "G9"), }, results)); } }