示例#1
0
        /// <summary>
        /// Draw rectangles onto a file
        /// </summary>
        /// <param name="path"></param>
        /// <param name="rects"></param>
        /// <param name="output"></param>
        public static void DrawRects(string path, List <Rectangle> rects, string output)
        {
            using var image = Image.Load <Rgba32>(path);

            foreach (var rect in rects)
            {
                var pen = new Pen(Color.HotPink, 7);

                image.Mutate(x => x.AutoOrient());
                image.Mutate(x => DrawRectangleExtensions.Draw(x, pen, rect));
            }

            image.Save(output);
        }
示例#2
0
        private void DrawRectangle(CognitiveResult face, string imgPath)
        {
            int x0     = face.faceRectangle.left;
            int y0     = face.faceRectangle.top;
            int width  = face.faceRectangle.width;
            int height = face.faceRectangle.height;

            SixLabors.Primitives.RectangleF recc = new SixLabors.Primitives.RectangleF(x0, y0, width, height);
            float thick = 4;

            using (Image <Rgba32> image = Image.Load(imgPath))
            {
                image.Mutate(DrawRectangleExtensions => DrawRectangleExtensions.Draw(
                                 color: boxColor,
                                 thickness: thick,
                                 shape: recc
                                 )
                             );
                image.Save("tmpFace.jpg"); // Automatic encoder selected based on extension.
            }
        }