示例#1
0
        public void OpenCamera(bool isBack)
        {
            if (easyarCamera == null)
            {
                return;
            }
            easyarCamera.close();
            easyarCamera.Dispose();
            easyarCamera = CameraDeviceSelector.createCameraDevice(CameraDevicePreference.PreferObjectSensing);
            easyarCamera.setFocusMode(CameraFocusMode);
            bool openResult = false;

            if (isBack)
            {
                openResult = easyarCamera.openWithType(CameraDeviceType.Back);
                Debug.Log("[EasyAR] open camera back result " + openResult);
                if (openResult)
                {
                    GL.invertCulling = false;
                }
            }
            else
            {
                openResult = easyarCamera.openWithType(CameraDeviceType.Front);
                Debug.Log("[EasyAR] open camera front result " + openResult);
                if (openResult)
                {
                    GL.invertCulling = true;
                }
            }

            easyarCamera.setSize(new Vec2I((int)CameraSize.x, (int)CameraSize.y));
            easyarCamera.start();
            easyarCamera.inputFrameSource().connect(iFrameThrottler.input());
        }
示例#2
0
        public void Dispose()
        {
            _cameraOpenCloseLock?.Dispose();
            _cameraDevice?.Dispose();

            _stateCallback.Opened -= OnOpened;
            _stateCallback?.Dispose();

            _captureListener.CaptureResultAvailable -= CaptureListenerOnCaptureResultAvailable;
            _captureListener?.Dispose();
        }
示例#3
0
        private void SetLensFacing(LensFacing lenseFacing)
        {
            bool shouldRestartCamera = currentLensFacing != lenseFacing;

            currentLensFacing = lenseFacing;
            string cameraId = string.Empty;

            characteristics = null;

            foreach (var id in manager.GetCameraIdList())
            {
                cameraId        = id;
                characteristics = manager.GetCameraCharacteristics(id);

                var face = (int)characteristics.Get(CameraCharacteristics.LensFacing);
                if (face == (int)currentLensFacing)
                {
                    break;
                }
            }

            if (characteristics == null)
            {
                return;
            }

            if (cameraDevice != null)
            {
                try
                {
                    if (!shouldRestartCamera)
                    {
                        return;
                    }
                    if (cameraDevice.Handle != IntPtr.Zero)
                    {
                        cameraDevice.Close();
                        cameraDevice.Dispose();
                        cameraDevice = null;
                    }
                }
                catch (Exception e)
                {
                    //Ignored
                    System.Diagnostics.Debug.WriteLine(e);
                }
            }

            SetUpCameraOutputs(cameraId);
            ConfigureTransform(surfaceTextureView.Width, surfaceTextureView.Height);
            manager.OpenCamera(cameraId, cameraStateCallback, null);
        }
示例#4
0
        /// <summary>
        /// Release all the EasyAR resources
        /// </summary>
        void DestroyEasyAr()
        {
            foreach (ImageTracker tracker in trackers)
            {
                tracker.Dispose();
            }
            trackers.Clear();

            if (camera != null)
            {
                camera.Dispose();
                camera = null;
            }
        }