Exemple #1
0
        /// <summary>
        /// update the framework with objects (templates) find in the frame
        /// </summary>
        /// <param name="templPyrs">the list of templates</param>
        /// <param name="videoCapture">the video stream</param>
        /// <param name="pictureBox">the picture box of window form</param>
        /// /// <returns>nothing.</returns>
        public void CaptureFrame(List <TemplatePyramid> templPyrs, ImageStreamReader videoCapture, PictureBox pictureBox)
        {
            DotImaging.Font font = new DotImaging.Font(FontTypes.HERSHEY_DUPLEX, 1, 0.1f);

            videoCapture.ReadTo(ref frame);

            if (frame == null)
            {
                return;
            }

            long preprocessTime, matchTime;
            var  bestRepresentatives = findObjects(frame, templPyrs, out preprocessTime, out matchTime);

            /************************************ drawing ****************************************/
            foreach (var m in bestRepresentatives)
            {
                frame.Draw(m.BoundingRect, Bgr <byte> .Blue, 1);
                frame.Draw(m.Points.Select(x => new Circle(x.X, x.Y, 5)).ToArray(), Bgr <byte> .Blue, -1);

                Console.WriteLine("Best template: " + m.Template.ClassLabel + "  AT  " + m.BoundingRect.X + "  " + m.BoundingRect.Y + " ANGLE: " + m.Template.Angle + " score: " + m.Score);
            }

            frame.Draw(String.Format("Matching {0} templates in: {1} ms", templPyrs.Count, matchTime),
                       font, new DotImaging.Primitives2D.Point(10, 25), Bgr <byte> .Green);
            /************************************ drawing ****************************************/

            pictureBox.Image = frame.ToBitmap(); //it will be just casted (data is shared) 24bpp color

            //frame.Save(String.Format("C:/probaImages/imgMarked_{0}.jpg", i)); b.Save(String.Format("C:/probaImages/img_{0}.jpg", i)); i++;
            //GC.Collect();
        }
Exemple #2
0
 /// <summary>
 /// Draws text on the provided image.
 /// </summary>
 /// <param name="image">Input image.</param>
 /// <param name="text">User text.</param>
 /// <param name="font">Font.</param>
 /// <param name="botomLeftPoint">Bottom-left point.</param>
 /// <param name="color">Text color.</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, string text, Font font, Point botomLeftPoint, Bgr<byte> color, byte opacity = Byte.MaxValue)
 {
     using(var img = image.Lock())
     {
         var iplImage = img.AsCvIplImage();
         CvCoreInvoke.cvPutText(&iplImage, text, botomLeftPoint, ref font, color.ToCvScalar());
     }
 }
Exemple #3
0
        /// <summary>
        /// Draws rectangle with the specified text on top.
        /// </summary>
        /// <param name="image">Image.</param>
        /// <param name="rect">User specified area to annotate.</param>
        /// <param name="text">Label.</param>
        /// <param name="font">Font to use.</param>
        public static void DrawAnnotation(this Bgr<byte>[,] image, Rectangle rect, string text, Font font)
        {
            const int VERTICAL_OFFSET = 5;

            image.Draw(rect, Bgr<byte>.Red, 1);

            var textSize = font.GetTextSize(text, 0);
            var bottomLeftPt = new Point(rect.X + rect.Width / 2 - textSize.Width / 2, rect.Top - VERTICAL_OFFSET);
            image.Draw(text, font, bottomLeftPt, Bgr<byte>.Black);
        }
 public static unsafe extern void cvPutText(IplImage* img, [MarshalAs(UnmanagedType.LPStr)] String text, Point org, ref Font font, CvScalar color);
 public static unsafe extern void cvInitFont(ref Font font, FontTypes fontFace, double hscale, double vscale, double shear,
     int thickness, LineTypes lineType);
 public static extern void cvGetTextSize([MarshalAs(UnmanagedType.LPStr)] String textString, ref Font font, ref Size textSize, ref int baseline);
Exemple #7
0
 public static extern void cvGetTextSize([MarshalAs(UnmanagedType.LPStr)] String textString, ref Font font, ref Size textSize, ref int baseline);
Exemple #8
0
 public unsafe static extern void cvPutText(IplImage *img, [MarshalAs(UnmanagedType.LPStr)] String text, Point org, ref Font font, CvScalar color);
Exemple #9
0
 public unsafe static extern void cvInitFont(ref Font font, FontTypes fontFace, double hscale, double vscale, double shear,
                                             int thickness, LineTypes lineType);