コード例 #1
0
        protected override Shared <Image> ProcessImage(Mat image, Envelope envelope)
        {
            var bitmap      = image.ToBitmap();
            var sharedImage = ImagePool.GetOrCreateFromBitmap(bitmap);

            return(sharedImage);
        }
コード例 #2
0
ファイル: SharedTester.cs プロジェクト: yusharth/psi
        public void SharedImagePoolCollisionTest()
        {
            var bmp57 = new System.Drawing.Bitmap(5, 7);
            var bmp75 = new System.Drawing.Bitmap(7, 5);

            Assert.AreEqual <int>(5, bmp57.Width);
            Assert.AreEqual <int>(7, bmp57.Height);
            Assert.AreEqual <int>(7, bmp75.Width);
            Assert.AreEqual <int>(5, bmp75.Height);

            var shared57 = ImagePool.GetOrCreateFromBitmap(bmp57);

            Assert.AreEqual <int>(5, shared57.Resource.Width);
            Assert.AreEqual <int>(7, shared57.Resource.Height);

            // Ensure that the ImagePool is not recycling images based solely on the product of
            // width*height (i.e. the same number of pixels but different dimensions), as the
            // stride and total size of the recycled image could be incorrect.

            shared57.Dispose();                                    // release to be recycled
            var shared75 = ImagePool.GetOrCreateFromBitmap(bmp75); // should *not* get the recycled image

            Assert.AreEqual <int>(7, shared75.Resource.Width);
            Assert.AreEqual <int>(5, shared75.Resource.Height);
        }
コード例 #3
0
        protected override Shared <Image> ProcessImage(SixLabors.ImageSharp.Image image, Envelope envelope)
        {
            using var stream = new MemoryStream();
            image.SaveAsBmp(stream);
            stream.Flush();
            stream.Position = 0;
            var bitmap      = new Bitmap(stream);
            var sharedImage = ImagePool.GetOrCreateFromBitmap(bitmap);

            return(sharedImage);
        }
コード例 #4
0
        public static void TestPersonGroup(string subscriptionKey, string endpoint, string groupId, string directory)
        {
            using var pipeline = Pipeline.Create();
            var files = Generators.Sequence(pipeline, Directory.GetFiles(directory), TimeSpan.FromTicks(1));

            files
            .Select(file => ImagePool.GetOrCreateFromBitmap(new Bitmap(File.OpenRead(file))))
            .RecognizeFace(new FaceRecognizerConfiguration(subscriptionKey, endpoint, groupId))
            .Join(files)
            .Do(x =>
            {
                Console.WriteLine($"File: {Path.GetFileName(x.Item2)}");
                foreach (var candidates in x.Item1)
                {
                    foreach (var(name, confidence) in candidates)
                    {
                        Console.WriteLine($"  Face: {name} {confidence}");
                    }
                }
            });
            pipeline.Run();
        }
コード例 #5
0
        protected override Shared <Image> ProcessImage(Bitmap image, Envelope envelope)
        {
            var sharedImage = ImagePool.GetOrCreateFromBitmap(image);

            return(sharedImage);
        }