Beispiel #1
0
        private async void OnObjectsDetected([NotNull] Task <List <DetectedObject> > detectedObjectsTask)
        {
            if (detectedObjectsTask == null)
            {
                throw new ArgumentNullException(nameof(detectedObjectsTask));
            }
            if (detectedObjectsTask.Result == null)
            {
                return;
            }
            List <DetectedObject> detectedObjects = await detectedObjectsTask;

            if (detectedObjects.Count == 0)
            {
                Debug.Log("No objects detected");
            }
            if (_objectDetectionService.detectOnRepeat)
            {
                List <TrackedObject> trackedObjects = detectedObjectsTask.Result.Select(detectedObject => new TrackedObject(detectedObject)).ToList();
                FPSUtils.TrackTick();
                Vector2 unprojectionOffset = ObjectTrackingService.unprojectionOffset;
                _visualizationManager.UpdateTrackedObjects(trackedObjects, unprojectionOffset);
            }
            else
            {
                ObjectTrackingService.Reset();
                List <TrackedObject> trackedObjects = ObjectTrackingService.InitializeTrackers(detectedObjects);
                if (detectedObjects.Count != trackedObjects.Count)
                {
                    Debug.LogWarning("Could not initialize tracker for all detected objects");
                }
                Vector2 unprojectionOffset = ObjectTrackingService.unprojectionOffset;
                _visualizationManager.UpdateTrackedObjects(trackedObjects, unprojectionOffset);
            }
        }
        public List <TrackedObject> TrackSync(CameraFrame frame)
        {
            if (frame == null)
            {
                throw new ArgumentNullException(nameof(frame));
            }
            stopWatch.Reset();
            stopWatch.Start();
            List <TrackedObject> trackedObjects = ObjectTracker.Update(frame);

            stopWatch.Stop();
            FPSUtils.TrackTick();
            _trackedObjects = trackedObjects;
            return(trackedObjects);
        }