void Update() { // Check if the webcam is ready (needed for macOS support) if (_webcamRaw.width <= 16) { return; } // Input buffer update with aspect ratio correction var vflip = _webcamRaw.videoVerticallyMirrored; var scale = new Vector2(1, vflip ? -1 : 1); var offset = new Vector2(0, vflip ? 1 : 0); Graphics.Blit(_webcamRaw, _webcamBuffer, scale, offset); // Run the object detector with the webcam input. _detector.ProcessImage (_webcamBuffer, _scoreThreshold, _overlapThreshold); }
void Start() { using var detector = new FaceDetector(_resources); detector.ProcessImage(_image, _scoreThreshold, _overlapThreshold); var w = _markerParent.rect.width; var h = _markerParent.rect.height; foreach (var box in detector.DetectedFaces) { var x1 = box.x1 * w; var y1 = box.y1 * h; var x2 = box.x2 * w; var y2 = box.y2 * h; var marker = Instantiate(_markerPrefab, _markerParent); marker.anchoredPosition = new Vector2(x1, h - y2); marker.SetSizeWithCurrentAnchors(Axis.Horizontal, x2 - x1); marker.SetSizeWithCurrentAnchors(Axis.Vertical, y2 - y1); } }