void OnRaiseDetectionEvent(DetectionEventArgs e) { EventHandler <DetectionEventArgs> handler = RaiseDetectionEvent; if (handler != null) { handler(this, e); } }
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(); }
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(); }
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); }
void OnRaiseDetectionEvent(DetectionEventArgs e) { RaiseDetectionEvent?.Invoke(this, e); }
void OnDetection(object sender, DetectionEventArgs e) { monitor.UpdateLabels(e.Result.ToList(confidenceThreshold)); }