public static Permission TakePicture(CameraCallback callback, int maxSize = -1, bool saveAsJPEG = true, PreferredCamera preferredCamera = PreferredCamera.Default) { Permission result = RequestPermission(); if (result == Permission.Granted && !IsCameraBusy()) { #if UNITY_EDITOR string pickedFile = UnityEditor.EditorUtility.OpenFilePanelWithFilters("Select image", "", new string[] { "Image files", "png,jpg,jpeg", "All files", "*" }); if (callback != null) { callback(pickedFile != "" ? pickedFile : null); } #elif UNITY_ANDROID AJC.CallStatic("TakePicture", Context, new NCCameraCallbackAndroid(callback), (int)preferredCamera); #elif UNITY_IOS if (maxSize <= 0) { maxSize = SystemInfo.maxTextureSize; } NCCameraCallbackiOS.Initialize(callback); _NativeCamera_TakePicture(IOSSelectedImagePath + (saveAsJPEG ? ".jpeg" : ".png"), maxSize, (int)preferredCamera); #else if (callback != null) { callback(null); } #endif } return(result); }
public static Permission RecordVideo(CameraCallback callback, Quality quality = Quality.Default, int maxDuration = 0, long maxSizeBytes = 0L, PreferredCamera preferredCamera = PreferredCamera.Default) { Permission result = RequestPermission(); if (result == Permission.Granted && !IsCameraBusy()) { #if UNITY_EDITOR string pickedFile = UnityEditor.EditorUtility.OpenFilePanelWithFilters("Select video", "", new string[] { "Video files", "mp4,mov,wav,avi", "All files", "*" }); if (callback != null) { callback(pickedFile != "" ? pickedFile : null); } #elif UNITY_ANDROID AJC.CallStatic("RecordVideo", Context, new NCCameraCallbackAndroid(callback), (int)preferredCamera, (int)quality, maxDuration, maxSizeBytes); #elif UNITY_IOS NCCameraCallbackiOS.Initialize(callback); _NativeCamera_RecordVideo((int)quality, maxDuration, (int)preferredCamera); #else if (callback != null) { callback(null); } #endif } return(result); }
public static Permission TakePicture(CameraCallback callback, int maxSize = -1, bool saveAsJPEG = true, PreferredCamera preferredCamera = PreferredCamera.Default) { Permission result = RequestPermission(); if (result == Permission.Granted && !IsCameraBusy()) { #if !UNITY_EDITOR && UNITY_ANDROID AJC.CallStatic("TakePicture", Context, new NCCameraCallbackAndroid(callback), (int)preferredCamera); #elif !UNITY_EDITOR && UNITY_IOS if (maxSize <= 0) { maxSize = SystemInfo.maxTextureSize; } NCCameraCallbackiOS.Initialize(callback); _NativeCamera_TakePicture(IOSSelectedImagePath + (saveAsJPEG ? ".jpeg" : ".png"), maxSize, (int)preferredCamera); #else if (callback != null) { callback(null); } #endif } return(result); }
public static Permission TakePicture(CameraCallback callback, int maxSize = -1) { Permission result = RequestPermission(); if (result == Permission.Granted && !IsCameraBusy()) { #if !UNITY_EDITOR && UNITY_ANDROID AJC.CallStatic("TakePicture", Context, new NCCameraCallbackAndroid(callback)); #elif !UNITY_EDITOR && UNITY_IOS if (maxSize <= 0) { maxSize = SystemInfo.maxTextureSize; } NCCameraCallbackiOS.Initialize(callback); _NativeCamera_TakePicture(IOSSelectedImagePath, maxSize); #else if (callback != null) { callback(null); } #endif } return(result); }
private void CreatePass(ref GameObject pass, string name, int priority, CameraCallback.CameraEvent onPreCull, CameraCallback.CameraEvent onPreRender, CameraCallback.CameraEvent onPostRender, CameraCallback.RenderImageEvent onRenderImage, int cullingMask, bool clearDepth) { if (Object.op_Equality((Object)pass, (Object)null)) { pass = new GameObject(name, new System.Type[2] { typeof(Camera), typeof(CameraCallback) }); ((Object)pass).set_hideFlags((HideFlags)52); pass.get_transform().set_parent(((Component)this).get_transform()); CameraCallback component = (CameraCallback)pass.GetComponent <CameraCallback>(); component.OnCameraPreCull = onPreCull; component.OnCameraPreRender = onPreRender; component.OnCameraPostRender = onPostRender; component.OnCameraRenderImage = onRenderImage; } Camera component1 = (Camera)pass.GetComponent <Camera>(); component1.CopyFrom(this.mCamera); component1.set_depth(this.mCamera.get_depth() + (float)priority); component1.set_cullingMask(cullingMask); component1.set_targetTexture((RenderTexture)null); component1.set_clearFlags(!clearDepth ? (CameraClearFlags)4 : (CameraClearFlags)3); }
public ProfilePicPage() { InitializeComponent(); // Create a bunch of tap gesture recognizers to form the UI for the profile picture page var backButtonGesture = new TapGestureRecognizer(); backButtonGesture.Tapped += (s, e) => { Navigation.PopModalAsync(); }; back_arrow_button.GestureRecognizers.Add(backButtonGesture); var blackoutGesture = new TapGestureRecognizer(); blackoutGesture.Tapped += (s, e) => { switchPopMenu(); }; profile_pic_blackout_box.GestureRecognizers.Add(blackoutGesture); var cancelGesture = new TapGestureRecognizer(); cancelGesture.Tapped += (s, e) => { switchPopMenu(); }; cancel_button.GestureRecognizers.Add(cancelGesture); var picTapGesture = new TapGestureRecognizer(); picTapGesture.Tapped += (s, e) => { switchPopMenu(); }; profile_pic_edit_button.GestureRecognizers.Add(picTapGesture); var takePicGesture = new TapGestureRecognizer(); takePicGesture.Tapped += (s, e) => { CameraCallback callback = new CameraCallback(processImage); DependencyService.Get <ICameraSystem>().TakePicture(callback); profile_pic.Source = image.Source; }; take_pic_button.GestureRecognizers.Add(takePicGesture); var choosePicGesture = new TapGestureRecognizer(); choosePicGesture.Tapped += (s, e) => { CameraCallback callback = new CameraCallback(processImage); DependencyService.Get <ICameraSystem>().GetMediaPicture(callback); }; choose_pic_button.GestureRecognizers.Add(choosePicGesture); }
public static Permission TakePicture(CameraCallback callback, int maxSize = -1) { Permission result = RequestPermission(); if (result == Permission.Granted && !IsCameraBusy()) { #if !UNITY_EDITOR && UNITY_ANDROID object threadLock = new object(); lock ( threadLock ) { NCCameraCallbackAndroid nativeCallback = new NCCameraCallbackAndroid(threadLock); AJC.CallStatic("TakePicture", Context, nativeCallback); if (string.IsNullOrEmpty(nativeCallback.Path)) { System.Threading.Monitor.Wait(threadLock); } string path = nativeCallback.Path; if (string.IsNullOrEmpty(path)) { path = null; } if (callback != null) { callback(path); } } #elif !UNITY_EDITOR && UNITY_IOS if (maxSize <= 0) { maxSize = SystemInfo.maxTextureSize; } NCCameraCallbackiOS.Initialize(callback); _NativeCamera_TakePicture(IOSSelectedImagePath, maxSize); #else if (callback != null) { callback(null); } #endif } return(result); }
public void SetCameraCallbackListener(Action <string>onCaptureImageComplete,Action onCaptureImageCancel,Action onCaptureImageFail) { #if UNITY_ANDROID if(Application.platform == RuntimePlatform.Android){ CameraCallback cameraCallback = new CameraCallback(); cameraCallback.onCaptureImageComplete = onCaptureImageComplete; cameraCallback.onCaptureImageCancel = onCaptureImageCancel; cameraCallback.onCaptureImageFail = onCaptureImageFail; jo.CallStatic("setCameraCallbackListener",cameraCallback); Utils.Message(TAG,"setCameraCallbackListener"); }else{ Utils.Message(TAG,"warning: must run in actual android device"); } #endif }
public static Permission RecordVideo(CameraCallback callback, Quality quality = Quality.Default, int maxDuration = 0, long maxSizeBytes = 0L) { Permission result = RequestPermission(); if (result == Permission.Granted && !IsCameraBusy()) { #if !UNITY_EDITOR && UNITY_ANDROID object threadLock = new object(); lock ( threadLock ) { NCCameraCallbackAndroid nativeCallback = new NCCameraCallbackAndroid(threadLock); AJC.CallStatic("RecordVideo", Context, nativeCallback, (int)quality, maxDuration, maxSizeBytes); if (string.IsNullOrEmpty(nativeCallback.Path)) { System.Threading.Monitor.Wait(threadLock); } string path = nativeCallback.Path; if (string.IsNullOrEmpty(path)) { path = null; } if (callback != null) { callback(path); } } #elif !UNITY_EDITOR && UNITY_IOS NCCameraCallbackiOS.Initialize(callback); _NativeCamera_RecordVideo((int)quality, maxDuration); #else if (callback != null) { callback(null); } #endif } return(result); }
public void SetCameraCallbackListener(Action <string> onCaptureImageComplete, Action onCaptureImageCancel, Action onCaptureImageFail) { #if UNITY_ANDROID if (Application.platform == RuntimePlatform.Android) { CameraCallback cameraCallback = new CameraCallback(); cameraCallback.onCaptureImageComplete = onCaptureImageComplete; cameraCallback.onCaptureImageCancel = onCaptureImageCancel; cameraCallback.onCaptureImageFail = onCaptureImageFail; jo.CallStatic("setCameraCallbackListener", cameraCallback); AUP.Utils.Message(TAG, "setCameraCallbackListener"); } else { AUP.Utils.Message(TAG, "warning: must run in actual android device"); } #endif }
public void TakePicture(CameraCallback callback) { if (UIImagePickerController.IsSourceTypeAvailable(UIImagePickerControllerSourceType.Camera)) { var imagePicker = new UIImagePickerController { SourceType = UIImagePickerControllerSourceType.Camera }; var window = UIApplication.SharedApplication.KeyWindow; var vc = window.RootViewController; while (vc.PresentedViewController != null) { vc = vc.PresentedViewController; } vc.PresentViewController(imagePicker, true, null); imagePicker.Canceled += (sender, e) => vc.DismissViewController(true, null); imagePicker.FinishedPickingMedia += (sender, e) => { var filepath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "profile_pic.jpg"); var image = (UIImage)e.Info.ObjectForKey(new NSString("UIImagePickerControllerOriginalImage")); /* * UIImageView imageView = new UIImageView(new CGRect(0,0,image.Size.Width,image.Size.Height)); * imageView.ContentMode = UIViewContentMode.ScaleAspectFit; * imageView.Image = image; * imageView.Transform = CGAffineTransform.MakeRotation((float)Math.PI / 4); * image = imageView.Image; */ image = ScaleAndRotateImage(image, UIImageOrientation.Right); image.AsJPEG().Save(filepath, false); callback(ShowImage(filepath)); vc.DismissViewController(true, null); }; } else { Console.WriteLine("NO CAMERA"); } }
public static Permission RecordVideo(CameraCallback callback, Quality quality = Quality.Default, int maxDuration = 0, long maxSizeBytes = 0L) { Permission result = RequestPermission(); if (result == Permission.Granted && !IsCameraBusy()) { #if !UNITY_EDITOR && UNITY_ANDROID AJC.CallStatic("RecordVideo", Context, new NCCameraCallbackAndroid(callback), (int)quality, maxDuration, maxSizeBytes); #elif !UNITY_EDITOR && UNITY_IOS NCCameraCallbackiOS.Initialize(callback); _NativeCamera_RecordVideo((int)quality, maxDuration); #else if (callback != null) { callback(null); } #endif } return(result); }
public void GetMediaPicture(CameraCallback callback) { if (UIImagePickerController.IsSourceTypeAvailable(UIImagePickerControllerSourceType.PhotoLibrary)) { var imagePicker = new UIImagePickerController { SourceType = UIImagePickerControllerSourceType.PhotoLibrary }; //imagePicker.Canceled += (sender, e) => UIApplication.SharedApplication.KeyWindow.RootViewController.DismissViewController(true, null); //.SharedApplication.KeyWindow.RootViewController.PresentViewController(imagePicker, true, null); var window = UIApplication.SharedApplication.KeyWindow; var vc = window.RootViewController; while (vc.PresentedViewController != null) { vc = vc.PresentedViewController; } vc.PresentViewController(imagePicker, true, null); imagePicker.Canceled += (sender, e) => vc.DismissViewController(true, null); imagePicker.FinishedPickingMedia += (sender, e) => { var filepath = Path.Combine(Environment.GetFolderPath( Environment.SpecialFolder.MyDocuments), "profile_pic.jpg"); var image = (UIImage)e.Info.ObjectForKey(new NSString("UIImagePickerControllerOriginalImage")); image.AsJPEG().Save(filepath, false); callback(ShowImage(filepath)); vc.DismissViewController(true, null); }; } else { Console.WriteLine("NO CAMERA"); } }
public override void Open() { if (Application.platform != RuntimePlatform.Android && Application.platform != RuntimePlatform.IPhonePlayer) { throw new UIPopupException(typeof(CustomCameraSource) + " not available under " + Application.platform); } willOpen = true; CameraDevice.requestPermissions(EasyARController.Scheduler, (Action <PermissionStatus, string>)((status, msg) => { if (!willOpen) { return; } #if !UNITY_EDITOR && UNITY_ANDROID externalCamera = new AndroidJavaObject("com.example.externalcamera.ExternalCameraSample"); externalCamera.Call <bool>("open"); cameraCallback = new CameraCallback(dataWrapper => { if (sink == null) { return; } var byteArray = dataWrapper.Get <AndroidJavaObject>("Buffer"); var jniByteArray = byteArray.GetRawObject(); var buffer = JniUtility.wrapByteArray(jniByteArray, true, () => { byteArray.Dispose(); }); var format = (PixelFormat)externalCamera.Call <int>("getPixelFormat"); var param = dataWrapper.Get <AndroidJavaObject>("camParams"); int orientation = param.Call <int>("getOrientation"); int cameraType = param.Call <int>("getCameraType"); double timestamp = param.Call <long>("getTimestamp") * 1e-9; var imageWidth = param.Call <int>("getWidth"); var imageHeight = param.Call <int>("getHeight"); var imageSize = new Vector2(imageWidth, imageHeight); HandleSink(buffer, format, imageSize, orientation, cameraType, timestamp); }); #elif !UNITY_EDITOR && UNITY_IOS externalCamera = new ExternalCamera(); externalCamera.open(); cameraCallback = (data, len) => { var buffer = Buffer.wrap(data, len, () => { }); var format = PixelFormat.YUV_NV12; var orientation = externalCamera.getOrientation(); var cameraType = externalCamera.getCameraType(); var imageWidth = externalCamera.getImageWidth(); var imageHeight = externalCamera.getImageHeight(); var timestamp = externalCamera.getTimestamp(); var imageSize = new Vector2(imageWidth, imageHeight); HandleSink(buffer, format, imageSize, orientation, cameraType, timestamp); }; #endif if (enabled) { OnEnable(); } })); }
public MainPage() { BindingContext = this; InitializeComponent(); instance = this; //Set the map to the Current Location setPositionToCurrentLocation(); BindingContext = this; //SET UP SERACHING WEB VIEW var assembly = typeof(FireCore).GetTypeInfo().Assembly; Stream stream = assembly.GetManifestResourceStream("DroverXamarin.iOS.SEARCHING.html"); string text = ""; using (var reader = new System.IO.StreamReader(stream)) { text += reader.ReadToEnd(); } HtmlWebViewSource source = new HtmlWebViewSource(); source.Html = text; searching_web.Source = source; //------------------------------Gesture Recognizer Section -------------------------- //Three bars image tap functionality var drawer_button_gesture_recognizer = new TapGestureRecognizer(); drawer_button_gesture_recognizer.Tapped += (s, e) => { onButtonClicked(s, e); }; drawer_button.GestureRecognizers.Add(drawer_button_gesture_recognizer); //Quarter page filler box tap functionality var view_box_gesture_recognizer = new TapGestureRecognizer(); view_box_gesture_recognizer.Tapped += (s, e) => { onButtonClicked(s, e); }; view_box.GestureRecognizers.Add(view_box_gesture_recognizer); //Payment option tap functionality var paymentGesture = new TapGestureRecognizer(); paymentGesture.Tapped += (s, e) => { Navigation.PushModalAsync(new PaymentPage()); }; payment_button.GestureRecognizers.Add(paymentGesture); payment_picture.GestureRecognizers.Add(paymentGesture); //About option tap functionality var aboutGesture = new TapGestureRecognizer(); aboutGesture.Tapped += (s, e) => { Navigation.PushModalAsync(new AboutPage()); }; about_button.GestureRecognizers.Add(aboutGesture); about_picture.GestureRecognizers.Add(aboutGesture); //Sign out option tab functionality var signOutGesture = new TapGestureRecognizer(); signOutGesture.Tapped += (s, e) => { signOutButtonClicked(s, e); }; sign_out_button.GestureRecognizers.Add(signOutGesture); sign_out_picture.GestureRecognizers.Add(signOutGesture); //Help option tap functionality var helpGesture = new TapGestureRecognizer(); helpGesture.Tapped += (s, e) => { Navigation.PushModalAsync(new HelpPage()); }; help_button.GestureRecognizers.Add(helpGesture); help_picture.GestureRecognizers.Add(helpGesture); //History option tap functionality var historyGesture = new TapGestureRecognizer(); historyGesture.Tapped += (s, e) => { Navigation.PushModalAsync(new CalendarPage()); }; history_button.GestureRecognizers.Add(historyGesture); history_picture.GestureRecognizers.Add(historyGesture); //Search button tap functionality var searchGesture = new TapGestureRecognizer(); searchGesture.Tapped += (s, e) => { input_location_box.IsVisible = true; input_location_blackout_box.IsVisible = true; entered_pickup_location.Focus(); }; search_button.GestureRecognizers.Add(searchGesture); //Input location blackout box tap functionality var blackoutBoxGesture = new TapGestureRecognizer(); blackoutBoxGesture.Tapped += (s, e) => { input_location_box.IsVisible = false; input_location_blackout_box.IsVisible = false; }; input_location_blackout_box.GestureRecognizers.Add(blackoutBoxGesture); //Profile Pic tap functionality var profilePicGesture = new TapGestureRecognizer(); profilePicGesture.Tapped += (s, e) => { switchPopMenu(); //PROFILE PICTURE STUFF }; profile_pic.GestureRecognizers.Add(profilePicGesture); //Compass Image tap functionality var compassGesture = new TapGestureRecognizer(); compassGesture.Tapped += (s, e) => { setPositionToCurrentLocation(); }; compass_image.GestureRecognizers.Add(compassGesture); compass_frame.GestureRecognizers.Add(compassGesture); //Set Pickup Location tap functionality var setPickupGesture = new TapGestureRecognizer(); setPickupGesture.Tapped += (s, e) => { //FireDatabase.write("test/test+test", "test+test"); getPinPosition(); }; set_pickup_button.GestureRecognizers.Add(setPickupGesture); //Confirm Pickup tap functionality var confirmPickupGesture = new TapGestureRecognizer(); confirmPickupGesture.Tapped += (s, e) => { confirmPickup(); }; confirm_location_button.GestureRecognizers.Add(confirmPickupGesture); //Cancel Pickup tap functionality var cancelPickupGesture = new TapGestureRecognizer(); cancelPickupGesture.Tapped += (s, e) => { cancelPickup(); }; cancel_pickup_button.GestureRecognizers.Add(cancelPickupGesture); //Cancel Search tap functionality var cancelSearchGesture = new TapGestureRecognizer(); cancelSearchGesture.Tapped += (s, e) => { input_location_box.IsVisible = false; input_location_blackout_box.IsVisible = false; entered_pickup_location.Text = ""; }; cancel_location_search_button.GestureRecognizers.Add(cancelSearchGesture); //Confirm Search tap functionality var confirmSearchGesture = new TapGestureRecognizer(); confirmSearchGesture.Tapped += (s, e) => { confirmSearch(entered_pickup_location.Text); }; search_for_location_button.GestureRecognizers.Add(confirmSearchGesture); //Dropoff location search tap functionality var dropoffSearchGesture = new TapGestureRecognizer(); dropoffSearchGesture.Tapped += (s, e) => { setDropoffLocation(); }; dropoff_location_search.GestureRecognizers.Add(dropoffSearchGesture); var confirmDropOff = new TapGestureRecognizer(); confirmDropOff.Tapped += (s, e) => { GenericSocket.CONFIRM_DROP_OFF(Settings.LastRideID); }; var confirmArrival = new TapGestureRecognizer(); confirmArrival.Tapped += (s, e) => { GenericSocket.CONFIRM_ARRIVAL(Settings.LastRideID); }; //PROFILE PICTURE STUFF var cancelPictureGesture = new TapGestureRecognizer(); cancelPictureGesture.Tapped += (s, e) => { switchPopMenu(); }; cancel_button.GestureRecognizers.Add(cancelPictureGesture); profile_pic_blackout_box.GestureRecognizers.Add(cancelPictureGesture); var takePicGesture = new TapGestureRecognizer(); takePicGesture.Tapped += (s, e) => { CameraCallback callback = new CameraCallback(processImage); DependencyService.Get <ICameraSystem>().TakePicture(callback); }; take_pic_button.GestureRecognizers.Add(takePicGesture); var choosePicGesture = new TapGestureRecognizer(); choosePicGesture.Tapped += (s, e) => { CameraCallback callback = new CameraCallback(processImage); DependencyService.Get <ICameraSystem>().GetMediaPicture(callback); }; choose_pic_button.GestureRecognizers.Add(choosePicGesture); var cancelDriverSearchGesture = new TapGestureRecognizer(); cancelDriverSearchGesture.Tapped += (s, e) => { cancelDriverSearch(); }; cancel_driver_search_button.GestureRecognizers.Add(cancelDriverSearchGesture); profile_pic_pin = new CircleImage { Source = Settings.GetImageFromDisk().Source }; profile_pic.Source = Settings.GetImageFromDisk().Source; profile_pic_pin.WidthRequest = App.ScreenWidth * 0.12; profile_pic_pin.HeightRequest = App.ScreenWidth * 0.12; double pic_x = App.ScreenWidth * 0.4415; double pic_y = App.ScreenHeight * getPicYPosition(); parentLayout.Children.Add(profile_pic_pin, Constraint.Constant(pic_x), Constraint.Constant(pic_y)); //-----------------------End Gesture Recognizer Section---------------------------- string path = "users/" + FireAuth.auth.User.LocalId + "/personal_info"; //Set the User's name in the slide out menu var user_info = FireDatabase.read(path).Result; if (user_info != null && user_info.ContainsKey("name_first") && user_info.ContainsKey("name_last")) { user_name_label.Text = user_info["name_first"].ToString() + " " + user_info["name_last"].ToString(); } //Set the User's phone number in the slide out menu if (user_info != null && user_info.ContainsKey("phone")) { user_phone_label.Text = String.Format("{0:(###) ###-####}", long.Parse(user_info["phone"].ToString())); } path = "users/" + FireAuth.auth.User.LocalId; var is_driver = FireDatabase.read(path).Result; Console.WriteLine("UPCOMING!"); Console.WriteLine("IS DRIVER: " + is_driver.Values); if (is_driver.ContainsKey("is_driver") && is_driver["is_driver"].Equals(true)) { driver_switch.IsVisible = true; } parentLayout.RaiseChild(map_pin); parentLayout.RaiseChild(input_location_blackout_box); parentLayout.RaiseChild(input_location_box); map.CustomPins = new System.Collections.ObjectModel.ObservableCollection <CustomPin>(); }
public static extern void gambatte_setcameracallback(IntPtr core, CameraCallback callback);
public static extern void requestCameraImage(CameraCallback callback, String filepath, int width, int height);