public static void DeserializeCameraImage(bool p_saveToGallery)
 {
     FixInstanceName();
     NativeCamera.CameraCallback v_cameraCallback =
         (path) =>
     {
         Instance.NativeCameraPickedEnd(path, p_saveToGallery);
     };
     NativeCamera.TakePicture(v_cameraCallback, CrossPickerServices.MaxImageLoadSize);
 }
 private void TakePicture()
 {
     NativeCamera.Permission permission = NativeCamera.TakePicture((path) =>
     {
         if (!string.IsNullOrEmpty(path) && !string.IsNullOrWhiteSpace(path))
         {
             ApplyMediaTreatment(path, true);
         }
     }, PICTURE_MAX_SIZE);
 }
 public void RequestCameraPermission(Action callback)
 {
     if (HaveCameraPermission())
     {
         callback?.Invoke();
         return;
     }
     NativeCamera.RequestPermission();
     callback?.Invoke();
 }
예제 #4
0
    /// <summary>
    /// Android call contains 2 requests:
    /// Camera, Storage.
    /// </summary>
    private bool CheckPermissionOrRequestBase()
    {
        NativeCamera.Permission resultOfCheckPermission =
            NativeCamera.CheckPermission();

        DebugPrinter.Print("CheckCameraPermissionOrRequest");

        switch (resultOfCheckPermission)
        {
        case NativeCamera.Permission.Granted:

            DebugPrinter.Print("Camera Permission Granted");

            return(true);

        case NativeCamera.Permission.ShouldAsk:

            NativeCamera.Permission resultOfRequestPermission;

            do
            {
                resultOfRequestPermission =
                    NativeCamera.RequestPermission();

                DebugPrinter.Print(2);
            }while (resultOfRequestPermission
                    == NativeCamera.Permission.ShouldAsk);

            if (resultOfRequestPermission
                == NativeCamera.Permission.Granted)
            {
                DebugPrinter.Print(3.1f);

                return(true);
            }
            else
            {
                DebugPrinter.Print(3.2f);

                return(false);
            }

        case NativeCamera.Permission.Denied:

            DebugPrinter.Print(4);

            return(false);

        default:

            DebugPrinter.Print(5);

            return(false);
        }
    }
    private bool CheckIfDeviceHasCamera()
    {
        bool hasCamera = NativeCamera.DeviceHasCamera();

        if (!hasCamera)
        {
            messageText.text = "Your device doesn't have a camera!";
        }

        return(hasCamera);
    }
        public MainViewModel(INavigation navigation)
        {
            this._navigation           = navigation;
            LaunchStartButtonCommand   = new Command(StartButtonClicked);
            SettingsTappedCommand      = new Command(SetingsButtonTapped);
            CheckConnectionCommand     = new Command(CheckConnection);
            CheckConfigurationsCommand = new Command(CheckConfigurations);
            CheckAppVersionCommand     = new Command(CheckAppVersion);

            NativeCamera.InitCamera();
        }
예제 #7
0
    /// <summary>
    /// uses NativeCamera lib
    /// </summary>
    /// <param name="maxSize"></param>
    public void TakePictureWithNativeCameraAndShowIt(int maxSize = 512)
    {
        NativeCamera.Permission permission = NativeCamera.TakePicture((path) =>
        {
            Debug.Log("Image path: " + path);


            PresentPhotoFromPathOnPhone(path, maxSize);
        }, maxSize);

        Debug.Log("Permission result: " + permission);
    }
예제 #8
0
    private void TakePicture(int maxSize)
    {
        NativeCamera.Permission permission = NativeCamera.TakePicture((path) =>
        {
            Debug.Log("Image path: " + path);
            if (path != null)
            {
                texture = NativeCamera.LoadImageAtPath(path, maxSize);
                if (texture == null)
                {
                    Debug.Log("Couldn't load texture from " + path);
                    return;
                }

                if (_PcdebugMode == false)
                {
                    photoTaken.gameObject.SetActive(true);
                    photoTaken.texture = texture;
                    //Sending the image which user has taken in 64bit format to the backend
                    byte[] currenBytes = DeCompress(texture).EncodeToJPG();
                    //bytes = _testTexture.EncodeToPNG();
                    string currentImage64     = "data:image/jpeg;base64," + Convert.ToBase64String(currenBytes);
                    GameNetworkImage captured = new GameNetworkImage(_localUser.userID, currentImage64, _locationStatus.GetLocationLat(), _locationStatus.GetLocationLon());
                    StartCoroutine(_gameNetwork.PostAddObject("https://harryspotter.eu.ngrok.io/addObject", captured.Serialize().ToString(), GetObjectIds));
                }

                /*
                 *              // Assign texture to a temporary quad and destroy it after 5 seconds
                 *              GameObject quad = GameObject.CreatePrimitive(PrimitiveType.Quad);
                 *              quad.transform.position = Camera.main.transform.position + Camera.main.transform.forward * 2.5f;
                 *              quad.transform.forward = Camera.main.transform.forward;
                 *              quad.transform.localScale = new Vector3(1f, texture.height / (float)texture.width, 1f);
                 *
                 *              Material material = quad.GetComponent<Renderer>().material;
                 *              if (!material.shader.isSupported) // happens when Standard shader is not included in the build
                 *                      material.shader = Shader.Find("Legacy Shaders/Diffuse");
                 *
                 *              material.mainTexture = texture;
                 *
                 *              Destroy(quad, 5f);
                 *
                 *              // If a procedural texture is not destroyed manually,
                 *              // it will only be freed after a scene change
                 *              Destroy(texture, 5f);
                 */
            }
            else
            {
                _uIManagerMap.DisplayMapPanel();
            }
        }, maxSize);
        Debug.Log("Permission result: " + permission);
    }
예제 #9
0
        private void LoadNextPage()
        {
            AddToFeedbackCart();

            if (FeedbackCart._guestImage == null)
            {
                NativeCamera.UploadImage();
            }

            PageLoadHandler.LoadNextPage(_navigation, _currQuestionindex, _selectedValue);
            //_canLoadNext = true;
        }
예제 #10
0
    private void RecordVideo()
    {
        NativeCamera.Permission permission = NativeCamera.RecordVideo((path) =>
        {
            Debug.Log("Video path: " + path);
            if (path != null)
            {
                StartCoroutine(LoadVideo(path));
            }
        });

        Debug.Log("Permission result: " + permission);
    }
예제 #11
0
    void Update()
    {
        if (Input.GetMouseButtonDown(0))
        {
            // Don't attempt to use the camera if it is already open
            if (NativeCamera.IsCameraBusy())
            {
                return;
            }

            TakePicture(512);
        }
    }
예제 #12
0
    private void RecordVideo()
    {
        NativeCamera.Permission permission = NativeCamera.RecordVideo((path) =>
        {
            UnityEngine.Debug.Log("Video path: " + path + " is the path");
            if (path != null)
            {
                // Play the recorded video
                //Handheld.PlayFullScreenMovie("file://" + path);
            }
        });//, NativeCamera.Quality.Medium, 100, 100L, NativeCamera.PreferredCamera.Front);

        UnityEngine.Debug.Log("Permission result: " + permission);
    }
예제 #13
0
    private void RecordVideo()
    {
        NativeCamera.Permission permission = NativeCamera.RecordVideo((path) =>
        {
            Debug.Log("Video path: " + path);
            if (path != null)
            {
                // Play the recorded video
                Handheld.PlayFullScreenMovie("file://" + path);
            }
        });

        Debug.Log("Permission result: " + permission);
    }
예제 #14
0
    // Records a video, using https://github.com/yasirkula/UnityNativeCamera
    private void RecordVideo()
    {
        gameObject.transform.Find("Explanation").gameObject.SetActive(false);
        if (NativeCamera.IsCameraBusy())
        {
            output.text = ("Camera Busy");
            return;
        }
        vidTime = DateTime.Now + new TimeSpan(0, 0, 4); // TODO can we do better than just "it'll start in 4 seconds"?

        NativeCamera.Permission permission = NativeCamera.RecordVideo(HandleVideo, NativeCamera.Quality.Low);

        Debug.Log("Permission result: " + permission);
    }
예제 #15
0
    private void VideoKaydet()
    {
        NativeCamera.Permission izin = NativeCamera.RecordVideo((konum) =>
        {
            Debug.Log("Kaydedilen videonun konumu: " + konum);
            if (konum != null)
            {
                // Videoyu oynat
                Handheld.PlayFullScreenMovie("file://" + konum);
            }
        });

        Debug.Log("İzin durumu: " + izin);
    }
    public void ProcessInfo()
    {
        byte[] imgData = null;

        if (!string.IsNullOrEmpty(imgPath))
        {
            Texture2D img = NativeCamera.LoadImageAtPath(imgPath, 512, false);
            imgData = img.EncodeToPNG();
        }

        UIManager.Instance.activeCase.photoNotes = photoNotesInput.text;
        UIManager.Instance.activeCase.photoTaken = imgData;
        overviewPanel.SetActive(true);
    }
예제 #17
0
    public static Sprite LoadNewSprite(string filePath, float pixelsPerUnit = 100.0f)
    {
        // Load a PNG or JPG image from disk to a Texture2D, assign this texture to a new sprite and return its reference

        Sprite NewSprite;

#if (UNITY_ANDROID || UNITY_IOS) && !UNITY_EDITOR
        Texture2D SpriteTexture = NativeCamera.LoadImageAtPath(filePath, 500, false);
#elif UNITY_EDITOR || UNITY_STANDALONE
        Texture2D SpriteTexture = LoadTexture(filePath);
#endif
        NewSprite = Sprite.Create(SpriteTexture, new Rect(0, 0, SpriteTexture.width, SpriteTexture.height), new Vector2(0, 0), pixelsPerUnit);

        return(NewSprite);
    }
예제 #18
0
        private static void State()
        {
            CameraContext cameraContext = GetCameraContext();

            if (cameraContext != null)
            {
                string friendlyName = cameraContext.FriendlyName;
                var    nativeCamera = new NativeCamera();
                int    currentState = 0;

                nativeCamera.GetPrivacy(friendlyName, ref currentState);

                Console.WriteLine($"Current state of {friendlyName} is {CoreRuntimeDefs.StateOnOff[currentState]}");
            }
        }
    public void ProcessInfo()
    {
        //Create a 2D texture
        //Apply the texture to image patth
        //encode to PNG
        //store bytes to PhotoTaken
        if (string.IsNullOrEmpty(imgPath) == false)
        {
            Texture2D img     = NativeCamera.LoadImageAtPath(imgPath, 512, false);
            byte[]    imgData = img.EncodeToPNG();
            UIManager.Instance.activeCase.photoTaken = imgData;
        }

        UIManager.Instance.activeCase.photoNotes = photoNotes.text;
        OverviewPanel.Instance.SetOverviewPanel();
    }
예제 #20
0
        /// <summary>
        /// Initializes all general modules.
        /// Modules that need manual initialization: IAPManager
        /// It's recommended to manually initialize the modules you only need.
        /// </summary>
        public static void Initialize(bool includePluginModules)
        {
            NyanPath.CreateRenkoDirectories();

            Netko.Initialize();
            RenQL.Initialize();
            UnityThread.Initialize();
            Easing.Initialize();

            if (includePluginModules)
            {
                GalleryPicker.Initialize();
                NativeCamera.Initialize();
                PluginTools.Initialize();
            }
        }
예제 #21
0
    public void ProcessInfo()
    {
        //convert it to byte array and store it
        byte[] imgData = null;

        if (!string.IsNullOrEmpty(_imgPath))
        {
            Texture2D img = NativeCamera.LoadImageAtPath(_imgPath, 512, false);
            imgData = img.EncodeToPNG();
        }

        UIManager.Instance.ActiveCase.PhotoTaken = imgData;
        UIManager.Instance.ActiveCase.PhotoNotes = _photoNotes.text;

        _overviewPanel.SetActive(true);
    }
        public void /*IEnumerator*/ OnPressShowCamera()
        {
            /*yield return Application.RequestUserAuthorization(UserAuthorization.WebCam);
             * WebCamTexture webCamTexture = new WebCamTexture();
             * imageRenderer.material.mainTexture = webCamTexture;
             * webCamTexture.Play();
             * //imageCamera.Show("Capture Image", "unimgpicker", 1024);
             */
            int maxSize = 1024;

            NativeCamera.Permission permission = NativeCamera.TakePicture((path) =>
            {
                Debug.Log("Image path: " + path);
                if (path != null)
                {
                    // Create a Texture2D from the captured image
                    Texture2D texture = NativeCamera.LoadImageAtPath(path, maxSize);
                    if (texture == null)
                    {
                        Debug.Log("Couldn't load texture from " + path);
                        return;
                    }

                    // Assign texture to a temporary quad and destroy it after 5 seconds
                    GameObject quad           = GameObject.CreatePrimitive(PrimitiveType.Quad);
                    quad.transform.position   = Camera.main.transform.position + Camera.main.transform.forward * 2.5f;
                    quad.transform.forward    = Camera.main.transform.forward;
                    quad.transform.localScale = new Vector3(1f, texture.height / (float)texture.width, 1f);

                    Material material = quad.GetComponent <Renderer>().material;
                    if (!material.shader.isSupported) // happens when Standard shader is not included in the build
                    {
                        material.shader = Shader.Find("Legacy Shaders/Diffuse");
                    }

                    material.mainTexture = texture;

                    Destroy(quad, 5f);

                    // If a procedural texture is not destroyed manually,
                    // it will only be freed after a scene change
                    Destroy(texture, 5f);
                }
            }, maxSize);

            Debug.Log("Permission result: " + permission);
        }
예제 #23
0
    public void TakePictureOnClick(int maxSize = -1)
    {
        NativeCamera.TakePicture((path) => {
            if (path == null)
            {
                return;
            }

            Texture2D texture = NativeCamera.LoadImageAtPath(path, 700, false);
            if (texture != null)
            {
                HandlePictureAddition(new List <Texture2D> {
                    texture
                });
            }
        }, maxSize);
    }
예제 #24
0
        public static void TakePictureMission(int MaxSize, string MissionID, string Local)
        {
            NativeCamera.Permission Permission = NativeCamera.TakePicture((Path) =>
            {
                Debug.Log("Path: " + Path);

                if (Path != null)
                {
                    // string Format = System.IO.Path.GetExtension(Path);

                    Texture2D Texture = DuplicateTexture(NativeCamera.LoadImageAtPath(Path, 1024));

                    if (Texture != null)
                    {
                        string PhotoName = FirebaseDatabase.DefaultInstance.GetReference("galeria-privada").Push().Key;
                        string CloudPath = "galeria/" + PhotoName + ".png";

                        string DatabaseReference = "/galeria-privada/" + PhotoName;

                        FirebaseController.WriteDataString(DatabaseReference, "usuario", FirebaseController.UserId);
                        FirebaseController.WriteDataString(DatabaseReference, "email", FirebaseController.UserEmail);
                        FirebaseController.WriteDataString(DatabaseReference, "nivel", TecWolf.Player.PlayerMission.Level.ToString());
                        FirebaseController.WriteDataString(DatabaseReference, "local", Local);
                        FirebaseController.WriteDataString(DatabaseReference, "missao", MissionID);
                        FirebaseController.WriteDataString(DatabaseReference, "formato", ".png");

                        // FirebaseStart.UploadFile(Path, CloudPath, Format, DownloadURL);
                        FirebaseController.UploadByte(Texture.EncodeToPNG(), CloudPath, ".png", DatabaseReference);

                        FirebaseController.WriteDataBool("/usuarios/" + FirebaseController.UserId + "/missoes/" + MissionID, "concluida", true);

                        TecWolf.System.SystemSound.Effect.PlayOneShot(TecWolf.System.SystemSound.SoundsStatic[0]);

                        FindObjectOfType <QuestInterface>().Refresh();
                    }

                    Destroy(Texture);
                }
            }, MaxSize);

#if UNITY_EDITOR
            FirebaseController.UploadFile(Application.dataPath + "/Test.jpg", "galeria/Test.jpg", ".jpg", "/galeria-privada/Test");
#endif

            Debug.Log("Permissão: " + Permission);
        }
예제 #25
0
        private void TakePicture(int maxSize)
        {
            NativeCamera.Permission permission = NativeCamera.TakePicture((path) =>
            {
                if (path != null)
                {
                    Texture2D tex = NativeCamera.LoadImageAtPath(path, maxSize);
                    if (tex == null)
                    {
                        Debug.Log("Couldn't load texture from " + path);
                        return;
                    }

                    NativeGallery.SaveImageToGallery(tex, "GalleryTest", "My img {0}.png");
                    texturePhoto = tex;
                }
            }, maxSize);
        }
예제 #26
0
    private void ResimCek(int maksimumBuyukluk)
    {
        NativeCamera.Permission izin = NativeCamera.TakePicture((konum) =>
        {
            Debug.Log("Çekilen resmin konumu: " + konum);
            if (konum != null)
            {
                // Çekilen resmi bir Texture2D'ye çevir
                Texture2D texture = NativeCamera.LoadImageAtPath(konum, maksimumBuyukluk);
                if (texture == null)
                {
                    Debug.Log(konum + " konumundaki resimden bir texture oluşturulamadı.");
                    return;
                }

                // Texture'u geçici bir küp objesine ver
                //GameObject kup = GameObject.CreatePrimitive(PrimitiveType.Quad);
                //kup.transform.position = Camera.main.transform.position + Camera.main.transform.forward * 5f;
                //kup.transform.forward = -Camera.main.transform.forward;
                //kup.transform.localScale = new Vector3(1f, texture.height / (float)texture.width, 1f);

                //Material material = kup.GetComponent<Renderer>().material;
                //if (!material.shader.isSupported) // eğer Standard shader desteklenmiyorsa Diffuse shader'ı kullan
                //    material.shader = Shader.Find("Legacy Shaders/Diffuse");

                RectTransform rectTransform = outputImage.GetComponent <RectTransform>();
                rectTransform.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical,
                                                        rectTransform.rect.width * texture.height / texture.width);
                outputImage.texture = texture;

                //material.mainTexture = texture;
                // 5 saniye sonra küp objesini yok et
                //Destroy(kup, 5f);

                // Küp objesi ile birlikte Texture2D objesini de yok et
                // Eğer prosedürel bir objeyi (Texture2D) işiniz bitince yok etmezseniz,
                // mevcut scene'i değiştirene kadar obje hafızada kalmaya devam eder
                Destroy(texture, 5f);
            }
        }, maksimumBuyukluk);

        Debug.Log("İzin durumu: " + izin);
    }
예제 #27
0
 /// <summary>
 /// 打开相机录像
 /// </summary>
 public static void OpenCameraVideo(Action <string> callBack)
 {
     NativeCamera.Permission permission = NativeCamera.RecordVideo((string path) =>
     {
         if (!string.IsNullOrEmpty(path) && callBack != null)
         {
             callBack(path);
         }
     });
     if (permission != NativeCamera.Permission.Granted)
     {
         ShowToast("当前没有相机访问权限,请在设置中打开");
         //打开应用程序设置
         if (NativeCamera.CanOpenSettings())
         {
             NativeCamera.OpenSettings();
         }
     }
 }
예제 #28
0
 /// <summary>
 /// 打开相机拍照
 /// </summary>
 public static void OpenCamera(Action <Texture2D> callBack)
 {
     NativeCamera.Permission permission = NativeCamera.TakePicture((string path) =>
     {
         if (!string.IsNullOrEmpty(path) && callBack != null)
         {
             callBack(NativeCamera.LoadImageAtPath(path));
         }
     });
     if (permission != NativeCamera.Permission.Granted)
     {
         ShowToast("当前没有相机访问权限,请在设置中打开");
         //打开应用程序设置
         if (NativeCamera.CanOpenSettings())
         {
             NativeCamera.OpenSettings();
         }
     }
 }
예제 #29
0
    public void ProcessInfo()
    {
        //UIManager.Instance.activeCase.photoTaken = photoTaken.texture;
        //Texture2D convertedPhoto = photoTaken.texture as Texture2D; // convert texture to texture2d
        //byte[] imgData = convertedPhoto.EncodeToPNG(); // convert to bytes

        byte[] imgData = null;

        if (string.IsNullOrEmpty(imgPath) == false)
        {
            Texture2D img = NativeCamera.LoadImageAtPath(imgPath, 512, false); // create 2D Texture + apply texture from image path
            imgData = img.EncodeToPNG();                                       // convert to bytes the encoded image
        }

        UIManager.Instance.activeCase.photoTaken = imgData;

        UIManager.Instance.activeCase.photoNotes = photoNotes.text;
        overviewPanel.SetActive(true);
    }
예제 #30
0
        private static void Toggle()
        {
            CameraContext cameraContext = GetCameraContext();

            if (cameraContext != null)
            {
                string friendlyName = cameraContext.FriendlyName;
                var    nativeCamera = new NativeCamera();
                int    currentState = 0;

                nativeCamera.GetPrivacy(friendlyName, ref currentState);

                var newState = ToggleState(currentState);

                Console.WriteLine($"Toggling {friendlyName} from {CoreRuntimeDefs.StateOnOff[currentState]} to {newState}");

                nativeCamera.SetPrivacy(friendlyName, CoreRuntimeDefs.State01[newState]);
            }
        }