예제 #1
0
        /// <summary>
        /// Start camera preview
        /// </summary>
        public ResultCode Start()
        {
#if PLATFORM_ANDROID
#if UNITY_2018_3_OR_NEWER
            if (!Permission.HasUserAuthorizedPermission(Permission.Camera))
            {
                Permission.RequestUserPermission(Permission.Camera);
            }
#endif
#endif
            int cameraType = 0;
            if (Application.platform == RuntimePlatform.OSXEditor || Application.platform == RuntimePlatform.WindowsEditor)
            {
                cameraType = AbstractConfigurationScriptableObject.GetInstance().WebcamType;
            }
            else
            {
                cameraType = (int)AbstractConfigurationScriptableObject.GetInstance().CameraType;
            }

            CameraDevice.CameraResolution cameraResolution = AbstractConfigurationScriptableObject.GetInstance().CameraResolution;
            switch (cameraResolution)
            {
            case CameraDevice.CameraResolution.Resolution640x480:
                preferredWidth  = 640;
                preferredHeight = 480;
                break;

            case CameraDevice.CameraResolution.Resolution1280x720:
                preferredWidth  = 1280;
                preferredHeight = 720;
                break;

            case CameraDevice.CameraResolution.Resolution1920x1080:
                preferredWidth  = 1920;
                preferredHeight = 1080;
                break;

            default:
                preferredWidth  = 640;
                preferredHeight = 480;
                break;
            }

            Debug.Log("Camera id : " + cameraId);

            return((ResultCode)NativeAPI.CameraDevice_start(cameraType, preferredWidth, preferredHeight));
        }
        /// <summary>
        /// Start camera preview
        /// </summary>
        public ResultCode Start()
        {
            int cameraType = 0;

            if (Application.platform == RuntimePlatform.OSXEditor || Application.platform == RuntimePlatform.WindowsEditor)
            {
                cameraType = AbstractConfigurationScriptableObject.GetInstance().WebcamType;
            }
            else
            {
                cameraType = (int)AbstractConfigurationScriptableObject.GetInstance().CameraType;
            }

            CameraDevice.CameraResolution cameraResolution = AbstractConfigurationScriptableObject.GetInstance().CameraResolution;
            switch (cameraResolution)
            {
            case CameraDevice.CameraResolution.Resolution640x480:
                preferredWidth  = 640;
                preferredHeight = 480;
                break;

            case CameraDevice.CameraResolution.Resolution1280x720:
                preferredWidth  = 1280;
                preferredHeight = 720;
                break;

            case CameraDevice.CameraResolution.Resolution1920x1080:
                preferredWidth  = 1920;
                preferredHeight = 1080;
                break;

            default:
                preferredWidth  = 640;
                preferredHeight = 480;
                break;
            }

            Debug.Log("Camera id : " + cameraId);

            return((ResultCode)NativeAPI.CameraDevice_start(cameraType, preferredWidth, preferredHeight));
        }