예제 #1
0
    // Use this for initialization
    void Start()
    {
        if (Instance == null)
        {
            Instance = this;
        }

        fpsMonitor = GetComponent <OpenCVForUnityExample.FpsMonitor>();

        webCamTextureToMatHelper = gameObject.GetComponent <WebCamTextureToMatHelper>();


        if (!string.IsNullOrEmpty(classes))
        {
            classes_filepath = Utils.getFilePath("dnn/" + classes);
        }
        if (!string.IsNullOrEmpty(config))
        {
            config_filepath = Utils.getFilePath("dnn/" + config);
        }
        if (!string.IsNullOrEmpty(model))
        {
            model_filepath = Utils.getFilePath("dnn/" + model);
        }
        Run();
    }
예제 #2
0
    // Update is called once per frame
    void Update()
    {
        if (EyeControl.Instance.controlMode == EyeControl.ControlMode.FOLLOW_HUMAN)
        {
            if (faceDetection == null)
            {
                faceDetection = FaceDetectRobust.Instance;
            }


            if (faceDetection.isPresent)
            {
                percentX = faceDetection.posX / 1280.0f;
                percentY = faceDetection.posY / 720.0f;

                if (shyMode)
                {
                    EyeControl.Instance.SetMotorPosition(0, 1.0f - percentX, true);
                    EyeControl.Instance.SetMotorPosition(1, 1.0f - percentY, true);
                }
                else
                {
                    targetX = Mathf.Lerp(targetX, percentX, Time.deltaTime * lerpSpeed);
                    targetY = Mathf.Lerp(targetY, percentY, Time.deltaTime * lerpSpeed);

                    if (Mathf.Abs(targetX - 0.5f) > 0.1f)
                    {
                        EyeControl.Instance.SetMotorPosition(0, 1.0f - targetX, true);
                    }
                    if (Mathf.Abs(targetY - 0.5f) > 0.1f)
                    {
                        EyeControl.Instance.SetMotorPosition(1, targetY, true);
                    }
                }
            }
        }
    }