示例#1
0
        private void Create(CameraDevice device)
        {
            CameraDeviceType cameraDeviceType = CameraDeviceType.BuiltIn;

            try
            {
                _cameraDeviceManager = new CameraDeviceManager();
                var deviceInfo = _cameraDeviceManager.GetDeviceInformation();
                Log.Info(CameraLog.Tag, deviceInfo.ToString());

                cameraDeviceType = deviceInfo.First().Type;
            }
            catch (NotSupportedException e)
            {
                Tizen.Log.Info(CameraLog.Tag,
                               $"CameraDeviceManager is not supported. {e.Message}. Not error.");
            }

            if (cameraDeviceType == CameraDeviceType.BuiltIn ||
                cameraDeviceType == CameraDeviceType.Usb)
            {
                Native.Create(device, out _handle).
                ThrowIfFailed($"Failed to create {cameraDeviceType.ToString()} camera");
            }
            else
            {
                Native.CreateNetworkCamera(device, out _handle).
                ThrowIfFailed($"Failed to create {cameraDeviceType.ToString()} camera");
            }
        }
示例#2
0
        private void Create(CameraDevice device)
        {
            CameraDeviceType cameraDeviceType = CameraDeviceType.BuiltIn;

            try
            {
                using (var cameraDeviceManager = new CameraDeviceManager())
                {
                    var deviceInfo = cameraDeviceManager.GetDeviceInformation();
                    if (!deviceInfo.Any())
                    {
                        throw new InvalidOperationException("There's no available camera device.");
                    }

                    cameraDeviceType = deviceInfo.First().Type;
                }
            }
            catch (NotSupportedException e)
            {
                Log.Info(CameraLog.Tag,
                         $"CameraDeviceManager is not supported. {e.Message}. Not error.");
            }

            if (cameraDeviceType == CameraDeviceType.BuiltIn ||
                cameraDeviceType == CameraDeviceType.Usb)
            {
                Native.Create(device, out _handle).
                ThrowIfFailed($"Failed to create {cameraDeviceType.ToString()} camera");
            }
            else
            {
                Native.CreateNetworkCamera(device, out _handle).
                ThrowIfFailed($"Failed to create {cameraDeviceType.ToString()} camera");
            }
        }
示例#3
0
 private void CreateNativeCameraDevice(CameraDeviceType type, CameraDevice device)
 {
     if (type == CameraDeviceType.BuiltIn || type == CameraDeviceType.Usb)
     {
         Native.Create(device, out _handle).
         ThrowIfFailed($"Failed to create {type} camera");
     }
     else
     {
         Native.CreateNetworkCamera(device, out _handle).
         ThrowIfFailed($"Failed to create {type} camera");
     }
 }