Exemple #1
0
        void OnRaiseDetectionEvent(DetectionEventArgs e)
        {
            EventHandler <DetectionEventArgs> handler = RaiseDetectionEvent;

            if (handler != null)
            {
                handler(this, e);
            }
        }
Exemple #2
0
        private const int IntervalInMilliseconds = 200; // throttle requests

        public ClientManager(HiResScreenShots screenShotService)
        {
            this._screenShotService = screenShotService;
            _channel = new Channel("127.0.0.1:50052", ChannelCredentials.Insecure);
            _client  = new ClientWrapper(new YoloService.YoloServiceClient(_channel));

            _result        = new YoloResult();
            _detectionArgs = new DetectionEventArgs(_result);

            _timer = new Stopwatch();
            _timer.Start();
        }
Exemple #3
0
        public ClientManager(ref Texture2D texture)
        {
            channel = new Channel("127.0.0.1:50052", ChannelCredentials.Insecure);
            client  = new ClientWrapper(new YoloService.YoloServiceClient(channel));

            this.texture       = texture;
            result             = new YoloResult();
            detectionEventArgs = new DetectionEventArgs(result);

            timer = new Stopwatch();
            timer.Start();
        }
Exemple #4
0
        void OnDetection(object sender, DetectionEventArgs e)
        {
            var yoloItems         = e.Result.ToList(confidenceThreshold);
            var yoloAeroplaneItem = yoloItems.FirstOrDefault(x => x.Type.StartsWith("aero"));

            if (yoloAeroplaneItem != null)
            {
                var xRatio = (float)Camera.main.scaledPixelWidth / _size.x;
                var yRatio = (float)Camera.main.scaledPixelHeight / _size.y;
                var yoloPlanePositionOnScreen = yoloAeroplaneItem.Rect.center;
                var yoloGuessedPosition       = Camera.main.ScreenToWorldPoint(new Vector3(yoloPlanePositionOnScreen.x * 2 * xRatio, yoloPlanePositionOnScreen.y * yRatio, yoloAeroplaneItem.Depth + 4));

                // Set the red target sphere to recognized plane coordinates.
                // Y coordinate is flipped because canvas starts at top
                // Depth (Z) is -4 so it is displayed in front of the plane, not potentially inside it
                _targetIndicatorObject.transform.position = new Vector3(yoloGuessedPosition.x, -yoloGuessedPosition.y, yoloGuessedPosition.z - 4);
            }

            monitor.UpdateLabels(yoloItems, warningDistance);
        }
Exemple #5
0
 void OnRaiseDetectionEvent(DetectionEventArgs e)
 {
     RaiseDetectionEvent?.Invoke(this, e);
 }
Exemple #6
0
 void OnDetection(object sender, DetectionEventArgs e)
 {
     monitor.UpdateLabels(e.Result.ToList(confidenceThreshold));
 }