void Start()
    {
        string cameraName = WebCamUtil.FindName(new WebCamUtil.PreferSpec()
        {
            isFrontFacing = false,
            kind          = WebCamKind.WideAngle,
        });

        webcamTexture = new WebCamTexture(cameraName, 1280, 720, 30);
        webcamTexture.Play();
        rawInputView.texture = webcamTexture;

        resizer       = new TextureResizer();
        resizeOptions = new TextureResizer.ResizeOptions()
        {
            aspectMode       = TextureResizer.AspectMode.Fill,
            rotationDegree   = 0,
            mirrorHorizontal = false,
            mirrorVertical   = false,
            width            = 720,
            height           = 720,
        };

        // Setup UIs

        // Dropdown
        var modes = Enum.GetValues(typeof(TextureResizer.AspectMode)).Cast <TextureResizer.AspectMode>();

        aspectModeDropdown.ClearOptions();
        aspectModeDropdown.AddOptions(modes.Select(m => new Dropdown.OptionData(m.ToString())).ToList());
        aspectModeDropdown.SetValueWithoutNotify((int)resizeOptions.aspectMode);
        aspectModeDropdown.onValueChanged.AddListener((int index) =>
        {
            resizeOptions.aspectMode = (TextureResizer.AspectMode)index;
        });

        // Mirror
        mirrorHorizontalToggle.SetIsOnWithoutNotify(resizeOptions.mirrorHorizontal);
        mirrorHorizontalToggle.onValueChanged.AddListener((bool isOn) =>
        {
            resizeOptions.mirrorHorizontal = isOn;
        });
        mirrorVerticalToggle.SetIsOnWithoutNotify(resizeOptions.mirrorVertical);
        mirrorVerticalToggle.onValueChanged.AddListener((bool isOn) =>
        {
            resizeOptions.mirrorVertical = isOn;
        });
    }
Пример #2
0
        protected override Matrix4x4 CalcCropMatrix(ref PoseDetect.Result pose, ref TextureResizer.ResizeOptions options)
        {
            float rotation = CalcRotationDegree(pose.keypoints[0], pose.keypoints[1]);
            var   rect     = AlignmentPointsToRect(pose.keypoints[0], pose.keypoints[1]);

            return(RectTransformationCalculator.CalcMatrix(new RectTransformationCalculator.Options()
            {
                rect = rect,
                rotationDegree = rotation,
                shift = PoseShift,
                scale = PoseScale,
                cameraRotationDegree = -options.rotationDegree,
                mirrorHorizontal = options.mirrorHorizontal,
                mirrorVertiacal = options.mirrorVertical,
            }));
        }