Exemple #1
0
        /// <summary>
        /// Draws rectangle.
        /// </summary>
        /// <param name="image">Input image.</param>
        /// <param name="rect">Rectangle.</param>
        /// <param name="color">Object's color.</param>
        /// <param name="thickness">Border thickness (-1 to fill the object).</param>
        /// <param name="opacity">Sets alpha channel where 0 is transparent and 255 is full opaque.</param>
        public unsafe static void Draw(this Bgr <byte>[,] image, Rectangle rect, Bgr <byte> color, int thickness, byte opacity = Byte.MaxValue)
        {
            if (float.IsNaN(rect.X) || float.IsNaN(rect.Y))
            {
                return;
            }

            draw(image, opacity, cvImg =>
            {
                CvCoreInvoke.cvRectangleR(&cvImg, rect, color.ToCvScalar(), thickness, LineTypes.EightConnected, 0);
            });
        }
Exemple #2
0
        /// <summary>
        /// Draws rectangle.
        /// </summary>
        /// <param name="image">Input image.</param>
        /// <param name="rect">Rectangle.</param>
        /// <param name="color">Object's color.</param>
        /// <param name="thickness">Border thickness. If less than zero structure will be filled.</param>
        /// <param name="opacity">Sets alpha channel where 0 is transparent and 255 is full opaque.</param>
        public unsafe static void Draw(this Bgr <byte>[,] image, Rectangle rect, Bgr <byte> color, int thickness, byte opacity = Byte.MaxValue)
        {
            if (float.IsNaN(rect.X) || float.IsNaN(rect.Y))
            {
                return;
            }

            using (var img = image.Lock())
            {
                var iplImage = img.AsCvIplImage();
                CvCoreInvoke.cvRectangleR(&iplImage, rect, color.ToCvScalar(opacity), thickness, LineTypes.EightConnected, 0);
            }
        }