Exemplo n.º 1
0
        protected override async void Start()
        {
            base.Start();

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

            NatDeviceWithOpenCVForUnityExample.CameraConfiguration(out width, out height, out framerate);
            // Create camera source
            cameraSource = new WebCamMatSource(width, height, framerate, useFrontCamera);
            if (!cameraSource.activeCamera)
            {
                cameraSource = new WebCamMatSource(width, height, framerate, !useFrontCamera);
            }
            await cameraSource.StartRunning(OnStart, OnFrame);

            fpsMonitor = GetComponent <FpsMonitor>();
            if (fpsMonitor != null)
            {
                fpsMonitor.Add("Name", "WebCamTextureToMatExample");
                fpsMonitor.Add("onFrameFPS", onFrameFPS.ToString("F1"));
                fpsMonitor.Add("drawFPS", drawFPS.ToString("F1"));
                fpsMonitor.Add("width", "");
                fpsMonitor.Add("height", "");
                fpsMonitor.Add("isFrontFacing", "");
                fpsMonitor.Add("orientation", "");
            }
        }
        protected override async void Start()
        {
            base.Start();

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

            NatDeviceWithOpenCVForUnityExample.CameraConfiguration(out width, out height, out framerate);
            // Create camera source
            cameraSource = new NatDeviceCamSource(width, height, framerate, useFrontCamera);
            if (cameraSource.activeCamera == null)
            {
                cameraSource = new NatDeviceCamSource(width, height, framerate, !useFrontCamera);
            }
            await cameraSource.StartRunning(OnStart, OnFrame);

            // Create comic filter
            comicFilter = new ComicFilter();

            exampleTitle      = "[NatDeviceWithOpenCVForUnity Example] (" + NatDeviceWithOpenCVForUnityExample.GetNatDeviceVersion() + ")";
            exampleSceneTitle = "- Integration With NatShare Example";

            fpsMonitor = GetComponent <FpsMonitor>();
            if (fpsMonitor != null)
            {
                fpsMonitor.Add("Name", "IntegrationWithNatShareExample");
                fpsMonitor.Add("onFrameFPS", onFrameFPS.ToString("F1"));
                fpsMonitor.Add("drawFPS", drawFPS.ToString("F1"));
                fpsMonitor.Add("width", "");
                fpsMonitor.Add("height", "");
                fpsMonitor.Add("isFrontFacing", "");
                fpsMonitor.Add("orientation", "");
            }
        }
Exemplo n.º 3
0
        protected override async void Start()
        {
            base.Start();

#if !UNITY_STANDALONE_WIN && !UNITY_EDITOR
            // Request camera permissions
            if (!await MediaDeviceQuery.RequestPermissions <CameraDevice>())
            {
                Debug.LogError("User did not grant camera permissions");
                return;
            }
#endif

            // Load global camera benchmark settings.
            int width, height, framerate;
            NatDeviceWithOpenCVForUnityExample.CameraConfiguration(out width, out height, out framerate);
            // Create camera source
            cameraSource = new NatDeviceCamSource(width, height, framerate, useFrontCamera);
            if (cameraSource.activeCamera == null)
            {
                cameraSource = new NatDeviceCamSource(width, height, framerate, !useFrontCamera);
            }
            await cameraSource.StartRunning(OnStart, OnFrame);

            fpsMonitor = GetComponent <FpsMonitor>();
            if (fpsMonitor != null)
            {
                fpsMonitor.Add("Name", "NatDeviceCamPreviewOnlyExample");
                fpsMonitor.Add("onFrameFPS", onFrameFPS.ToString("F1"));
                fpsMonitor.Add("drawFPS", drawFPS.ToString("F1"));
                fpsMonitor.Add("width", "");
                fpsMonitor.Add("height", "");
                fpsMonitor.Add("orientation", "");
            }
        }
        public async void OnShareButtonClick()
        {
            var mes = "";

#if (UNITY_IOS || UNITY_ANDROID) && !UNITY_EDITOR
            try
            {
                var success = await new SharePayload()
                              .AddText("User shared image! [NatDeviceWithOpenCVForUnity Example](" + NatDeviceWithOpenCVForUnityExample.GetNatDeviceVersion() + ")")
                              .AddImage(texture)
                              .Commit();

                mes = $"Successfully shared items: {success}";
            }
            catch (ApplicationException e)
            {
                mes = e.Message;
            }
#else
            mes = "NatShare Error: SharePayload is not supported on this platform";
#endif

            Debug.Log(mes);

            if (fpsMonitor != null)
            {
                fpsMonitor.consoleText = mes;
                await Task.Delay(2000);

                fpsMonitor.consoleText = "";
            }
        }