コード例 #1
0
    void Update()
    {
        if (CoreXT.IsDevice)
        {
            if (_isDetecting && _cameraVideo.webCamTexture.didUpdateThisFrame)
            {
                // detect every x frames
                _frameCount++;
                if (_frameCount % detectEveryXFrames == 0)
                {
                    CGImageOrientation orientation = _cameraVideo.cameraOrientationForFaceDetector;

                    _faceDetector.isMirrored     = _cameraVideo.isMirrored;
                    _faceDetector.projectedScale = _cameraVideo.videoToCameraScale;

                    // detect
                    _faces = _faceDetector.DetectInPixels32(_cameraVideo.webCamTexture.GetPixels32(),
                                                            _cameraVideo.webCamTexture.width, _cameraVideo.webCamTexture.height, orientation);

                    foreach (var face in _faces)
                    {
                        Log("face: " + face.bounds + ", " + face.hasMouthPosition + ", " + face.leftEyePosition + ", " + face.rightEyePosition);
                    }
                }
            }
        }
    }