Exemple #1
0
        public async Task StartRunning(Action startCallback, Action frameCallback)
        {
            if (activeCamera == null || isRunning)
            {
                return;
            }

            this.startCallback = startCallback;
            this.frameCallback = frameCallback;

            preview = await activeCamera.StartRunning();

            width      = preview.width;
            height     = preview.height;
            isRunning  = true;
            firstFrame = true;

            attachment           = new GameObject("NatDeviceWithOpenCVForUnityExample NatDeviceCamSource Helper").AddComponent <NatDeviceCamSourceAttachment>();
            attachment.@delegate = () => {
                if (firstFrame)
                {
                    startCallback();
                    firstFrame = false;
                }
                else
                {
                    frameCallback();
                }
            };
        }
Exemple #2
0
        public void StopRunning()
        {
            if (activeCamera == null || !isRunning)
            {
                return;
            }

            if (attachment != null)
            {
                attachment.@delegate = default;
                NatDeviceCamSourceAttachment.Destroy(attachment.gameObject);
                attachment = default;
            }

            activeCamera.StopRunning();
            isRunning = false;
        }