Esempio n. 1
0
        // Use this for initialization
        void Start()
        {
            // Load global camera benchmark settings.
            int width, height, fps;

            NatCamWithOpenCVForUnityExample.GetCameraResolution(out width, out height);
            NatCamWithOpenCVForUnityExample.GetCameraFps(out fps);
            requestedWidth  = width;
            requestedHeight = height;
            requestedFPS    = fps;

            fpsMonitor = GetComponent <FpsMonitor> ();
            if (fpsMonitor != null)
            {
                fpsMonitor.Add("Name", "WebCamTextureOnlyExample");
                fpsMonitor.Add("onFrameFPS", onFrameFPS.ToString("F1"));
                fpsMonitor.Add("drawFPS", drawFPS.ToString("F1"));
                fpsMonitor.Add("width", "");
                fpsMonitor.Add("height", "");
                fpsMonitor.Add("orientation", "");
            }

            imageProcessingTypeDropdown.value = (int)imageProcessingType;

            Initialize();
        }
Esempio n. 2
0
        public virtual void Start()
        {
            fpsMonitor = GetComponent <FpsMonitor> ();

            if (!NatCam.Implementation.HasPermissions)
            {
                Debug.LogError("NatCam.Implementation.HasPermissions == false");

                if (fpsMonitor != null)
                {
                    fpsMonitor.consoleText = "NatCam.Implementation.HasPermissions == false";
                }
            }

            // Load global camera benchmark settings.
            int width, height, fps;

            NatCamWithOpenCVForUnityExample.GetCameraResolution(out width, out height);
            NatCamWithOpenCVForUnityExample.GetCameraFps(out fps);
            previewResolution = new NatCamU.Core.CameraResolution(width, height);
            requestedFPS      = fps;

            // Set the active camera
            NatCam.Camera = useFrontCamera ? DeviceCamera.FrontCamera : DeviceCamera.RearCamera;

            // Null checking
            if (!NatCam.Camera)
            {
                Debug.LogError("Camera is null. Consider using " + (useFrontCamera ? "rear" : "front") + " camera");
                return;
            }
            if (!preview)
            {
                Debug.LogError("Preview RawImage has not been set");
                return;
            }

            // Set the camera's preview resolution
            NatCam.Camera.PreviewResolution = previewResolution;
            // Set the camera framerate
            NatCam.Camera.Framerate = requestedFPS;
            NatCam.Play();
            NatCam.OnStart += OnStart;
            NatCam.OnFrame += OnFrame;

            if (fpsMonitor != null)
            {
                fpsMonitor.Add("Name", "NatCamPreviewOnlyExample");
                fpsMonitor.Add("onFrameFPS", onFrameFPS.ToString("F1"));
                fpsMonitor.Add("drawFPS", drawFPS.ToString("F1"));
                fpsMonitor.Add("width", "");
                fpsMonitor.Add("height", "");
                fpsMonitor.Add("orientation", "");
            }

            imageProcessingTypeDropdown.value = (int)imageProcessingType;
        }