public void LoadCameraPicker(CameraQuality quality, int maxWidth, int maxHeight, StreamLoadedCallbackMethod streamLoadedCallback)
 {
     if (streamLoadedCallback == null)
     {
         streamLoadedCallback(null, false);
     }
     else
     {
         loadCameraPickerAsync(quality, maxWidth, maxHeight, streamLoadedCallback);
     }
 }
Beispiel #2
0
        void QualityValueChanged(object sender, RoutedPropertyChangedEventArgs <double> e)
        {
            if (!isConnected)
            {
                return;
            }

            CameraQuality cq = new CameraQuality();

            cq.quality = (int)qualitySlider.Value;
            logger.Write(LoggerLevel.Info, "Setting quality to " + cq.quality);

            byte[] buffer = handler.GetSetCameraQualityPacket(cq);
            packetSocket.Send(buffer, buffer.Length, robotPacketEndpoint);
        }
Beispiel #3
0
        public static int GetCameraQualityInfo(CameraQuality item, ref CameraQualityInfo paramInfo)
        {
            int result = (int)Error.FAILED;

            result = SRWorkModule_API.GetCameraStatus((int)item, ref paramInfo.Status);
            if (result != (int)Error.WORK)
            {
                return(result);
            }
            result = SRWorkModule_API.GetCameraDefaultValue((int)item, ref paramInfo.DefaultValue);
            if (result != (int)Error.WORK)
            {
                return(result);
            }
            result = SRWorkModule_API.GetCameraMin((int)item, ref paramInfo.Min);
            if (result != (int)Error.WORK)
            {
                return(result);
            }
            result = SRWorkModule_API.GetCameraMax((int)item, ref paramInfo.Max);
            if (result != (int)Error.WORK)
            {
                return(result);
            }
            result = SRWorkModule_API.GetCameraStep((int)item, ref paramInfo.Step);
            if (result != (int)Error.WORK)
            {
                return(result);
            }
            result = SRWorkModule_API.GetCameraDefaultMode((int)item, ref paramInfo.DefaultMode);
            if (result != (int)Error.WORK)
            {
                return(result);
            }
            result = SRWorkModule_API.GetCameraValue((int)item, ref paramInfo.Value);
            if (result != (int)Error.WORK)
            {
                return(result);
            }
            result = SRWorkModule_API.GetCameraMode((int)item, ref paramInfo.Mode);
            if (result != (int)Error.WORK)
            {
                return(result);
            }

            return(result);
        }
Beispiel #4
0
        /// <summary>
        /// Use to have the user take a picture with there native camera
        /// </summary>
        /// <param name="quality">Camera resolution quality (Has no effect on some defices)</param>
        /// <param name="maxWidth">Image size returned will not be above the Max Width value (set 0 to disable)</param>
        /// <param name="maxHeight">Image size returned will not be above the Max Height value (set 0 to disable)</param>
        /// <param name="streamLoadedCallback">Callback fired when done</param>
        public static void LoadCameraPicker(CameraQuality quality, int maxWidth, int maxHeight, StreamLoadedCallbackMethod streamLoadedCallback)
        {
            if (loadingStream)
            {
                var que = new StreamManagerQue(StreamManagerQueTypes.LoadCameraPicker);
                que.streamLoadedCallback = streamLoadedCallback;
                que.MaxWidth             = maxWidth;
                que.MaxHeight            = maxHeight;
                que.CameraQuality        = quality;
                ques.Add(que);
                return;
            }

            loadingStream = true;
            StreamManager.streamLoadedCallback = streamLoadedCallback;
            plugin.LoadCameraPicker(quality, maxWidth, maxHeight, async_streamLoadedCallback);
        }
		private void loadCameraPickerAsync(CameraQuality quality, int maxWidth, int maxHeight, StreamLoadedCallbackMethod streamLoadedCallback)
		public void LoadCameraPicker(CameraQuality quality, int maxWidth, int maxHeight, StreamLoadedCallbackMethod streamLoadedCallback)
		{
			if (streamLoadedCallback == null) streamLoadedCallback(null, false);
			else loadCameraPickerAsync(quality, maxWidth, maxHeight, streamLoadedCallback);
		}
Beispiel #7
0
 /// <summary>
 /// Use to have the user take a picture with there native camera
 /// </summary>
 /// <param name="quality">Camera resolution quality (Has no effect on some defices)</param>
 /// <param name="streamLoadedCallback">Callback fired when done</param>
 public static void LoadCameraPicker(CameraQuality quality, StreamLoadedCallbackMethod streamLoadedCallback)
 {
     LoadCameraPicker(quality, 0, 0, streamLoadedCallback);
 }
        private async void loadCameraPickerAsync(CameraQuality quality, int maxWidth, int maxHeight, StreamLoadedCallbackMethod streamLoadedCallback)
                #endif
        {
                        #if WINDOWS_PHONE
            WinRTPlugin.Dispatcher.BeginInvoke(delegate()
            {
                loadCameraPicker_streamLoadedCallback = streamLoadedCallback;
                loadCameraPicker_maxWidth             = maxWidth;
                loadCameraPicker_maxHeight            = maxHeight;

                var cameraCaptureTask        = new CameraCaptureTask();
                cameraCaptureTask.Completed += new EventHandler <PhotoResult>(cameraCaptureTask_Completed);
                cameraCaptureTask.Show();
            });
                        #elif UNITY_WP_8_1
            loadFileDialogAsync(FolderLocations.Pictures, maxWidth, maxHeight, new string[] { ".jpg" }, streamLoadedCallback);
                        #else
            await WinRTPlugin.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, async delegate()
            {
                try
                {
                    var cameraUI = new CameraCaptureUI();
                    cameraUI.PhotoSettings.AllowCropping = false;
                    switch (quality)
                    {
                    case CameraQuality.Low: cameraUI.PhotoSettings.MaxResolution = CameraCaptureUIMaxPhotoResolution.SmallVga; break;

                    case CameraQuality.Med: cameraUI.PhotoSettings.MaxResolution = CameraCaptureUIMaxPhotoResolution.MediumXga; break;

                    case CameraQuality.High: cameraUI.PhotoSettings.MaxResolution = CameraCaptureUIMaxPhotoResolution.HighestAvailable; break;
                    }

                    var capturedMedia = await cameraUI.CaptureFileAsync(CameraCaptureUIMode.Photo);
                    if (capturedMedia != null)
                    {
                        using (var cameraStream = await capturedMedia.OpenAsync(FileAccessMode.Read))
                        {
                            if (maxWidth == 0 || maxHeight == 0)
                            {
                                UnityEngine.WSA.Application.InvokeOnAppThread(() =>
                                {
                                    streamLoadedCallback(cameraStream.AsStream(), true);
                                }, false);
                            }
                            else
                            {
                                var stream = await resizeImageStream(cameraStream, maxWidth, maxHeight);
                                UnityEngine.WSA.Application.InvokeOnAppThread(() =>
                                {
                                    streamLoadedCallback(stream, true);
                                }, false);
                            }
                        }
                    }
                    else
                    {
                        UnityEngine.WSA.Application.InvokeOnAppThread(() =>
                        {
                            streamLoadedCallback(null, false);
                        }, false);
                    }
                }
                catch (Exception e)
                {
                    Debug.LogError(e.Message);
                    UnityEngine.WSA.Application.InvokeOnAppThread(() =>
                    {
                        streamLoadedCallback(null, false);
                    }, false);
                }
            });
                        #endif
        }
 private void loadCameraPickerAsync(CameraQuality quality, int maxWidth, int maxHeight, StreamLoadedCallbackMethod streamLoadedCallback)
Beispiel #10
0
 public override void LoadCameraPicker(CameraQuality quality, int maxWidth, int maxHeight, StreamLoadedCallbackMethod streamLoadedCallback)
 {
     streamFileLoadedCallback = streamLoadedCallback;
     LoadCameraPicker(maxWidth, maxHeight);
 }
		public virtual void LoadCameraPicker(CameraQuality quality, int maxWidth, int maxHeight, StreamLoadedCallbackMethod streamLoadedCallback)
		{
			Debug.LogError("LoadCameraPicker not supported on this Platform!");
			if (streamLoadedCallback != null) streamLoadedCallback(null, false);
		}
		public override void LoadCameraPicker (CameraQuality quality, int maxWidth, int maxHeight, StreamLoadedCallbackMethod streamLoadedCallback)
		{
			streamFileLoadedCallback = streamLoadedCallback;
			LoadCameraPicker(maxWidth, maxHeight);
		}
		public override void LoadCameraPicker (CameraQuality quality, int maxWidth, int maxHeight, StreamLoadedCallbackMethod streamLoadedCallback)
		{
			if (Common.navigator_invoke_invocation_create(ref invoke) != 0) return;
			if (Common.navigator_invoke_invocation_set_target(invoke, "sys.camera.card") != 0)
			{
				Common.navigator_invoke_invocation_destroy(invoke);
				return;
			}
		
			if (Common.navigator_invoke_invocation_set_action(invoke, "bb.action.CAPTURE") != 0)
			{
				Common.navigator_invoke_invocation_destroy(invoke);
				return;
			}
		
			if (Common.navigator_invoke_invocation_set_type(invoke, "image/jpeg") != 0)
			{
				Common.navigator_invoke_invocation_destroy(invoke);
				return;
			}

			string name = "photo";
			IntPtr namePtr = Marshal.StringToHGlobalAnsi(name);
			if (Common.navigator_invoke_invocation_set_data(invoke, namePtr, name.Length) != 0)
			{
				Common.navigator_invoke_invocation_destroy(invoke);
				return;
			}
		
			if (Common.navigator_invoke_invocation_send(invoke) != 0)
			{
				Common.navigator_invoke_invocation_destroy(invoke);
				return;
			}

			var fileTypes = new string[]
			{
				".jpg",
				"jpeg",
				".png"
			};
			var dataPathPatterns = new string[]
			{
				@"(/accounts/1000/shared/camera/)([\w|\.|\-]*)",
				@"(/accounts/1000/shared/photos/)([\w|\.|\-]*)"
			};
			waitAndProcessImage(addUppers(fileTypes), dataPathPatterns, maxWidth, maxHeight, streamLoadedCallback);

			Common.navigator_invoke_invocation_destroy(invoke);
			Marshal.FreeHGlobal(namePtr);
		}
		/// <summary>
		/// Use to have the user take a picture with there native camera
		/// </summary>
		/// <param name="quality">Camera resolution quality (Has no effect on some defices)</param>
		/// <param name="maxWidth">Image size returned will not be above the Max Width value (set 0 to disable)</param>
		/// <param name="maxHeight">Image size returned will not be above the Max Height value (set 0 to disable)</param>
		/// <param name="streamLoadedCallback">Callback fired when done</param>
		public static void LoadCameraPicker(CameraQuality quality, int maxWidth, int maxHeight, StreamLoadedCallbackMethod streamLoadedCallback)
		{
			if (loadingStream)
			{
				var que = new StreamManagerQue(StreamManagerQueTypes.LoadCameraPicker);
				que.streamLoadedCallback = streamLoadedCallback;
				que.MaxWidth = maxWidth;
				que.MaxHeight = maxHeight;
				que.CameraQuality = quality;
				ques.Add(que);
				return;
			}

			loadingStream = true;
			StreamManager.streamLoadedCallback = streamLoadedCallback;
			plugin.LoadCameraPicker(quality, maxWidth, maxHeight, async_streamLoadedCallback);
		}
		/// <summary>
		/// Use to have the user take a picture with there native camera
		/// </summary>
		/// <param name="quality">Camera resolution quality (Has no effect on some defices)</param>
		/// <param name="streamLoadedCallback">Callback fired when done</param>
		public static void LoadCameraPicker(CameraQuality quality, StreamLoadedCallbackMethod streamLoadedCallback)
		{
			LoadCameraPicker(quality, 0, 0, streamLoadedCallback);
		}
		private async void loadCameraPickerAsync(CameraQuality quality, int maxWidth, int maxHeight, StreamLoadedCallbackMethod streamLoadedCallback)
		#endif
		{
			#if WINDOWS_PHONE
			WinRTPlugin.Dispatcher.BeginInvoke(delegate()
			{
				loadCameraPicker_streamLoadedCallback = streamLoadedCallback;
				loadCameraPicker_maxWidth = maxWidth;
				loadCameraPicker_maxHeight = maxHeight;

				var cameraCaptureTask = new CameraCaptureTask();
				cameraCaptureTask.Completed += new EventHandler<PhotoResult>(cameraCaptureTask_Completed);
				cameraCaptureTask.Show();
			});
			#elif UNITY_WP_8_1
			loadFileDialogAsync(FolderLocations.Pictures, maxWidth, maxHeight, new string[]{".jpg"}, streamLoadedCallback);
			#else
			await WinRTPlugin.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, async delegate()
			{
				try
				{
					var cameraUI = new CameraCaptureUI();
					cameraUI.PhotoSettings.AllowCropping = false;
					switch (quality)
					{
						case CameraQuality.Low: cameraUI.PhotoSettings.MaxResolution = CameraCaptureUIMaxPhotoResolution.SmallVga; break;
						case CameraQuality.Med: cameraUI.PhotoSettings.MaxResolution = CameraCaptureUIMaxPhotoResolution.MediumXga; break;
						case CameraQuality.High: cameraUI.PhotoSettings.MaxResolution = CameraCaptureUIMaxPhotoResolution.HighestAvailable; break;
					}

					var capturedMedia = await cameraUI.CaptureFileAsync(CameraCaptureUIMode.Photo);
					if (capturedMedia != null)
					{
						using (var cameraStream = await capturedMedia.OpenAsync(FileAccessMode.Read))
						{
							if (maxWidth == 0 || maxHeight == 0)
							{
								ReignServices.InvokeOnUnityThread(delegate
								{
									streamLoadedCallback(cameraStream.AsStream(), true);
								});
							}
							else
							{
								var stream = await resizeImageStream(cameraStream, maxWidth, maxHeight);
								ReignServices.InvokeOnUnityThread(delegate
								{
									streamLoadedCallback(stream, true);
								});
							}
						}
					}
					else
					{
						ReignServices.InvokeOnUnityThread(delegate
						{
							streamLoadedCallback(null, false);
						});
					}
				}
				catch (Exception e)
				{
					Debug.LogError(e.Message);
					ReignServices.InvokeOnUnityThread(delegate
					{
						streamLoadedCallback(null, false);
					});
				}
			});
			#endif
		}
		public void LoadCameraPicker(CameraQuality quality, int maxWidth, int maxHeight, StreamLoadedCallbackMethod streamLoadedCallback)
		{
			Native.LoadCameraPicker(quality, maxWidth, maxHeight, streamLoadedCallback);
		}
Beispiel #18
0
 public static int SetCameraQualityInfo(CameraQuality item, CameraQualityInfo paramInfo)
 {
     return(ViveSR_Framework.SetParameterStruct(ViveSR_Framework.MODULE_ID_SEETHROUGH, (int)item, paramInfo));
 }