Ejemplo n.º 1
0
 /// <summary>
 /// Prints tracks information.
 /// </summary>
 /// <param name="tracks">List of tracks.</param>
 /// <param name="imgSource">Input image (depth=IPL_DEPTH_8U and num. channels=3).</param>
 /// <param name="imgDest">Output image (depth=IPL_DEPTH_8U and num. channels=3).</param>
 /// <param name="mode">Render mode. By default is CV_TRACK_RENDER_ID.</param>
 public static void RenderTracks(CvTracks tracks, Mat imgSource, Mat imgDest, RenderTracksModes mode)
 {
     if (tracks == null)
     {
         throw new ArgumentNullException(nameof(tracks));
     }
     tracks.Render(imgSource, imgDest, mode);
 }
Ejemplo n.º 2
0
 /// <summary>
 /// Prints tracks information.
 /// </summary>
 /// <param name="tracks">List of tracks.</param>
 /// <param name="imgSource">Input image (depth=IPL_DEPTH_8U and num. channels=3).</param>
 /// <param name="imgDest">Output image (depth=IPL_DEPTH_8U and num. channels=3).</param>
 /// <param name="mode">Render mode. By default is CV_TRACK_RENDER_ID.</param>
 /// <param name="textColor"></param>
 /// <param name="fontFace"></param>
 /// <param name="fontScale"></param>
 /// <param name="thickness"></param>
 public static void RenderTracks(CvTracks tracks, Mat imgSource, Mat imgDest, RenderTracksModes mode,
                                 Scalar textColor, HersheyFonts fontFace = HersheyFonts.HersheySimplex, double fontScale = 1d, int thickness = 1)
 {
     if (tracks == null)
     {
         throw new ArgumentNullException(nameof(tracks));
     }
     tracks.Render(imgSource, imgDest, mode, textColor, fontFace, fontScale, thickness);
 }
Ejemplo n.º 3
0
        /// <summary>
        /// Prints tracks information.
        /// </summary>
        /// <param name="imgSource">Input image (depth=IPL_DEPTH_8U and num. channels=3).</param>
        /// <param name="imgDest">Output image (depth=IPL_DEPTH_8U and num. channels=3).</param>
        /// <param name="mode">Render mode. By default is CV_TRACK_RENDER_ID.</param>
        /// <param name="textColor"></param>
        /// <param name="fontFace"></param>
        /// <param name="fontScale"></param>
        /// <param name="thickness"></param>
        public void Render(Mat imgSource, Mat imgDest, RenderTracksModes mode, Scalar textColor,
                           HersheyFonts fontFace = HersheyFonts.HersheySimplex, double fontScale = 1d, int thickness = 1)
        {
            if (imgSource == null)
            {
                throw new ArgumentNullException(nameof(imgSource));
            }
            if (imgDest == null)
            {
                throw new ArgumentNullException(nameof(imgDest));
            }
            if (imgDest.Type() != MatType.CV_8UC3)
            {
                throw new ArgumentException("imgDest.Depth != U8 || imgDest.NChannels != 3");
            }

            if (mode != RenderTracksModes.None)
            {
                foreach (KeyValuePair <int, CvTrack> kv in this)
                {
                    int     key   = kv.Key;
                    CvTrack value = kv.Value;

                    if ((mode & RenderTracksModes.Id) == RenderTracksModes.Id)
                    {
                        if (value.Inactive == 0)
                        {
                            Cv2.PutText(imgDest, key.ToString(CultureInfo.InvariantCulture), (Point)value.Centroid,
                                        fontFace, fontScale, textColor, thickness);
                        }
                    }
                    if ((mode & RenderTracksModes.BoundingBox) == RenderTracksModes.BoundingBox)
                    {
                        if (value.Inactive > 0)
                        {
                            Cv2.Rectangle(
                                imgDest,
                                new Point(value.MinX, value.MinY),
                                new Point(value.MaxX - 1, value.MaxY - 1),
                                new Scalar(50, 0, 0));
                        }
                        else
                        {
                            Cv2.Rectangle(
                                imgDest,
                                new Point(value.MinX, value.MinY),
                                new Point(value.MaxX - 1, value.MaxY - 1),
                                new Scalar(255, 0, 0));
                        }
                    }
                }
            }
        }
Ejemplo n.º 4
0
 /// <summary>
 /// Prints tracks information.
 /// </summary>
 /// <param name="imgSource">Input image (depth=IPL_DEPTH_8U and num. channels=3).</param>
 /// <param name="imgDest">Output image (depth=IPL_DEPTH_8U and num. channels=3).</param>
 /// <param name="mode">Render mode. By default is CV_TRACK_RENDER_ID.</param>
 public void Render(Mat imgSource, Mat imgDest, RenderTracksModes mode)
 {
     Render(imgSource, imgDest, mode, Scalar.Green);
 }