Пример #1
0
 public static void DrawTrack(Image<Bgr, Byte> image, TrackedObject trackedObject)
 {
     image.Draw(trackedObject.CurrentFrame.SourceRectangle, White, 1);
     if (string.IsNullOrEmpty(trackedObject.Identity)) return;
     image.Draw(trackedObject.Identity, ref _font, trackedObject.CurrentFrame.SourceRectangle.Location, White);
 }
Пример #2
0
 private void SetTrackedImage(CvTrack track, Image<Bgr, byte> image, TrackedObject myTrack)
 {
     var windowSize = _settings.SubImageMultiplier.Value > 1
         ? _settings.SubImageMultiplier.Value * (1 + (myTrack.MaxSize / _settings.SubImageMultiplier.Value))
         : myTrack.MaxSize;
     var x = Math.Max(0, Convert.ToInt32(track.Centroid.x) - windowSize / 2);
     x = Math.Min(_imageWidth - windowSize, x);
     var y = Math.Max(0, Convert.ToInt32(track.Centroid.y) - windowSize / 2);
     y = Math.Min(_imageHeight - windowSize, y);
     var sourceRect = new Rectangle(x, y, windowSize, windowSize);
     var subImage = image.Copy(sourceRect);
     myTrack.ProcessTrackerResult(sourceRect, subImage);
 }
Пример #3
0
        /// <summary>
        /// Here: mark active as active, set crop, public enumerable
        /// UI thread: iterate observable - throw out any not active, mark all active inactive, add any new, send new images for id, create imagesource
        /// </summary>
        /// <param name="track"></param>
        /// <param name="image"></param>
        private void ProcessTrack(CvTrack track, Image<Bgr, Byte> image)
        {
            // can this happen for tracks that later resume?
            if (track.Active <= 0) return;

            // get the tracked object currently using this id, if any
            TrackedObject myTrack;
            _trackedObjectIdentities.TryGetValue(track.Id, out myTrack);

            if (track.Lifetime <= 1 && myTrack != null && myTrack.TrackingState == TrackingState.Dead)
            {
                _trackedObjectIdentities.Remove(track.Id);
                myTrack = null;
            }

            if (track.Lifetime < _settings.MinFramesToStartIdentifying.Value)
            {
                return;
            }

            if (myTrack == null)
            {
                myTrack = new TrackedObject{Id = _nextTrackId++, TrackingState = TrackingState.New};
            }
            else
            {
                myTrack.TrackingState = TrackingState.Current;
            }
            try
            {
                myTrack.MaxSize = Math.Max(myTrack.MaxSize,
                    Math.Max(track.BoundingBox.Height, track.BoundingBox.Width));
                if (myTrack.MaxSize < _settings.MinSizeToIdentify.Value) return;
                if (myTrack.TrackingState == TrackingState.New)
                    _trackedObjectIdentities[track.Id] = myTrack;
                SetTrackedImage(track, image, myTrack);
            }
            catch (Exception ex)
            {
                Log.Error("Exception processing track", ex);
            }
        }
Пример #4
0
 public TrackDetailView(TrackedObject trackedObject)
 {
     InitializeComponent();
     DataContext = new TrackDetailViewModel {TrackedObject = trackedObject};
 }
 public void Identify(TrackedObject trackedObject)
 {
     _queue.Enqueue(trackedObject.Id, new Tuple<TrackedObject, TrackedObjectFrame>(trackedObject, trackedObject.CurrentFrame));
 }
Пример #6
0
 public IdentificationContext(TrackedObject trackedObject)
 {
     TrackedObject = trackedObject;
     Frame = trackedObject.CurrentFrame;
 }