Search Unity

  1. We are migrating the Unity Forums to Unity Discussions. On July 12, the Unity Forums will become read-only. On July 15, Unity Discussions will become read-only until July 18, when the new design and the migrated forum contents will go live. Read our full announcement for more information and let us know if you have any questions.

Native Camera for Android & iOS [Open Source]

Discussion in 'Assets and Asset Store' started by yasirkula, May 2, 2018.

  1. yasirkula

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    2,910
    Try saving the downloaded image to a temporary location inside Application.temporaryCachePath and then loading it via NativeCamera.LoadImageAtPath.
     
  2. gaglabs

    gaglabs

    Joined:
    Oct 17, 2019
    Posts:
    185
    Keeps telling me the path is returning empty. Enen though the path is indeed there pulling from the server and uploading in my app.
     
  3. yasirkula

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    2,910
    I'm not really sure, check if System.IO.File.Exists returns true before calling LoadImageAtPath. It it doesn't, then the file is not there "at that moment".
     
  4. gaglabs

    gaglabs

    Joined:
    Oct 17, 2019
    Posts:
    185
    Does it matter that my "URL" doesnt return with an end index of .jpg or .png?
     
  5. yasirkula

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    2,910
    The URL isn't important since you should be passing the filepath of the downloaded image to LoadImageAtPath, not its URL. If possible, include the extension in the filepath, I am not sure if the function will otherwise work properly.
     
  6. gaglabs

    gaglabs

    Joined:
    Oct 17, 2019
    Posts:
    185
    So was able to trim the returned url to result in an ending of .jpg. Now maybe im misuderstanding the function but what gets returned from NativeCamera.LoadImageAtPath(_string);? How will i retrieve the returned texture?
     
  7. yasirkula

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    2,910
  8. gaglabs

    gaglabs

    Joined:
    Oct 17, 2019
    Posts:
    185
    Ok so in the process of taking or upload a pic via native cam, the rotation is fixed using your sample. No the issue still remains when trying to pull from the server. I get this error..

    Which doesnt make any sense caus ethe file is there. You can click the link and see the image is there.
     
  9. yasirkula

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    2,910
    You need to download the file to local storage via WWW or UnityWebRequest, File API doesn't work with files on the internet.
     
  10. gaglabs

    gaglabs

    Joined:
    Oct 17, 2019
    Posts:
    185
    I have. Thats the issue. Heres my code...

    Code (CSharp):
    1. private IEnumerator OnLoadGraphic()
    2.         {
    3.             _url = LoadedFeed.ImageURL;
    4.          
    5.             if (!string.IsNullOrEmpty(_url))
    6.             {
    7.  
    8.                 UnityWebRequest wr = new UnityWebRequest(_url);
    9.                 DownloadHandlerTexture texDl = new DownloadHandlerTexture(true);
    10.                 wr.downloadHandler = texDl;
    11.                 yield return wr.SendWebRequest();
    12.                 if (!(wr.isNetworkError || wr.isHttpError))
    13.                 {
    14.                    // Texture2D t = texDl.texture;
    15.                     Texture2D texture = NativeGallery.LoadImageAtPath(wr.uri.LocalPath, 1024);
    16.                     ImageBody.texture = texture;
    17.  
    18.                     float _bodyWidth = 800;
    19.                     float _imageWidth = ImageBody.texture.width;
    20.                     float _imageHeight = ImageBody.texture.height;
    21.                     float _ratio = _imageWidth / _imageHeight;
    22.                     float _expectedHeight = _imageHeight * _bodyWidth / _imageWidth;
    23.  
    24.                     ImageRect.sizeDelta = new Vector2(_bodyWidth, _expectedHeight);
    25.  
    26.  
    27.                     UpdateUIRect();
    28.  
    29.                 }
    30.              
    31.              
    32.             }
    33.         }

    And its returning this error...

     
  11. gaglabs

    gaglabs

    Joined:
    Oct 17, 2019
    Posts:
    185
    Second Attempt with this code...

    Code (CSharp):
    1. private IEnumerator OnLoadGraphic()
    2.         {
    3.             _url = LoadedFeed.ImageURL;
    4.             using (UnityWebRequest www = UnityWebRequest.Get(_url))
    5.             {
    6.                 yield return www.SendWebRequest();
    7.                 if (www.isNetworkError || www.isHttpError)
    8.                 {
    9.                     Debug.Log(www.error);
    10.                 }
    11.                 else
    12.                 {
    13.                     string savePath = string.Format(www.uri.LocalPath, Application.persistentDataPath, _url);
    14.                     System.IO.File.WriteAllText(savePath, www.downloadHandler.text);
    15.  
    16.                     Texture2D texture = NativeGallery.LoadImageAtPath(savePath, 1024);
    17.                     ImageBody.texture = texture;
    18.  
    19.                     float _bodyWidth = 800;
    20.                     float _imageWidth = ImageBody.texture.width;
    21.                     float _imageHeight = ImageBody.texture.height;
    22.                     float _ratio = _imageWidth / _imageHeight;
    23.                     float _expectedHeight = _imageHeight * _bodyWidth / _imageWidth;
    24.  
    25.                     ImageRect.sizeDelta = new Vector2(_bodyWidth, _expectedHeight);
    26.  
    27.  
    28.                     UpdateUIRect();
    29.                 }
    30.             }
    31.            
    32.         }

    Returns this error...

     
  12. yasirkula

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    2,910
    Please check out DownloadHandlerFile to see how to properly download a file to local storage using UnityWebRequest.
     
  13. gaglabs

    gaglabs

    Joined:
    Oct 17, 2019
    Posts:
    185
    This is where my above sample comes from. That same link. But Ive realized that the issue lies within the TakePicture function. The image is taken in portrait mode from your native cam and is then rotated when applied to my preview texture. If the picture is taken in landscape orientation then it come out fine in my preview window. Then as you can see that when its uploaded to my server it is uploaded rotated as well, then when i fetch the image to load within my chat feed it is also rotated. I need to figure out how to know when the camera is either in portrait or landscape and then rotate it if it needs to be. Ive tried many many code snippets to try this but either they dont rotate or it rotates them all.
     
  14. yasirkula

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    2,910
    Yes, phones' cameras don't actually rotate the captured photos, they rather inject an EXIF property that tells the orientation of the image. It is up to the image viewers to respect that EXIF data. LoadImageAtPath does respect that data an thus, always returns the correctly rotated image. You can read that orientation yourself via NativeCamera.GetImageProperties(path).orientation.

    If you want to get rid of the EXIF data and actually apply that rotation to the image, you can either read the orientation and rotate the image's pixels manually or call LoadImageAtPath to load the correctly rotated image into a Texture and save it to a separate image file via texture.EncodeToPNG. But you should set markTextureNonReadable as false while calling LoadImageAtPath.
     
  15. gaglabs

    gaglabs

    Joined:
    Oct 17, 2019
    Posts:
    185
    And thats the issue i seem to have lol. This is my code that is called after i take a picture.


    Code (CSharp):
    1.  if (_type == FeedType.Image || _type == FeedType.Video)
    2.             {
    3.                 _chooser.SetActive(true);
    4.                 _chooserText.text = "Its an image or vid";
    5.                 Invoke("CloseChooser", 0.5f);
    6.                 _textbutt.SetActive(false);
    7.                 _textureButt.SetActive(true);
    8.                 byte[] fileBytes = System.IO.File.ReadAllBytes(_url);
    9.  
    10.                 if (_type == FeedType.Video)
    11.                 {
    12.  
    13.                     Debug.Log("First Video");
    14.                     if (!CheckVideoSize(fileBytes))
    15.                     {
    16.                         Debug.Log("checing size");
    17.                         AppManager.VIEW_CONTROLLER.ShowPopupMSG(MessageCode.MaxVideoSize);
    18.                         yield break;
    19.                     }
    20.                     PreviewPlayer.url = "file://" + _url;
    21.                    
    22.                     videoBytes = fileBytes;
    23.                     while (PreviewPlayer.frame < 2)
    24.                     {
    25.                         Debug.Log("player frame is < 2");
    26.                         yield return null;
    27.                     }
    28.                     Texture2D _texture = ReadExternalTexture(PreviewPlayer.texture);
    29.  
    30.  
    31.                     ResizeTexture(_texture);
    32.  
    33.                     imageBytes = _texture.EncodeToJPG(AppManager.APP_SETTINGS.UploadImageQuality);
    34.                     _feed.MediaWidth = _texture.width;
    35.                     _feed.MeidaHeight = _texture.height;
    36.                     _feed.VideoFileName = fileName;
    37.  
    38.                     previewTexure = _texture;
    39.  
    40.                 }
    41.  
    42.                 if (_type == FeedType.Image)
    43.                 {
    44.  
    45.                     Texture2D _texture = new Texture2D(2, 2);
    46.                     _texture.LoadImage(fileBytes);
    47.                  
    48.                     yield return new WaitForEndOfFrame();
    49.                    
    50.                     ResizeTexture(_texture);
    51.                     Texture2D _tex = _texture;
    52.                     RotateTexture(_tex);
    53.                  
    54.                     imageBytes = _texture.EncodeToJPG(AppManager.APP_SETTINGS.UploadImageQuality);
    55.                     _feed.MediaWidth = _texture.width;
    56.                     _feed.MeidaHeight = _texture.height;
    57.                    
    58.                     previewTexure = _tex;
    59.                 }
    60.  
    61.             }
    62.  
    63.             if (_type == FeedType.Image || _type == FeedType.Video)
    64.             {
    65.                 if (_showPreview)
    66.                 {
    67.                     AppManager.VIEW_CONTROLLER.HideLoading();
    68.                     if (_type == FeedType.Image)
    69.                     {
    70.                      
    71.                    
    72.                         FeedPreviewRequest _previreRequest = new FeedPreviewRequest();
    73.                      
    74.  
    75.                         _imageImage.texture = previewTexure;
    76.                      
    77.                         float _bodyWidth = 800;
    78.                         float _imageWidth = _imageImage.texture.width;
    79.                         float _imageHeight = _imageImage.texture.height;
    80.                         float _ratio = _imageWidth / _imageHeight;
    81.                         float _expectedHeight = _imageHeight * _bodyWidth / _imageWidth;
    82.                        
    83.                         _imageImage.rectTransform.sizeDelta = new Vector2(_bodyWidth, _expectedHeight);
    84.                         _posterHolder.sizeDelta = _imageImage.rectTransform.sizeDelta;
    85.  
    86.                        
    87.                      
    88.                         AppManager.VIEW_CONTROLLER.FDU = gameObject.GetComponent<FeedDadaUoloader>();
    89.                         AppManager.VIEW_CONTROLLER.GetReq(_previreRequest);
    90.                      
    91.                      
    92.                         while (!_previreRequest.IsComplete)
    93.                         {
    94.                             yield return null;
    95.                         }
    96.                         if (!_previreRequest.IsSuccess)
    97.                         {
    98.                             yield break;
    99.                         }
    100.                         _feed.BodyTXT = _previreRequest.BodyText;
    101.                     }
    102.                     else if (_type == FeedType.Video)
    103.                     {
    104.  
    105.                         Debug.Log("Preview Video");
    106.                         FeedPreviewRequest _previreRequest = new FeedPreviewRequest();
    107.                         _videoImage.texture = PreviewPlayer.texture;
    108.                         float _bodyWidth = 800;
    109.                         float _imageWidth = _videoImage.texture.width;
    110.                         float _imageHeight = _videoImage.texture.height;
    111.                         float _ratio = _imageWidth / _imageHeight;
    112.                         float _expectedHeight = _imageHeight * _bodyWidth / _imageWidth;
    113.                         _videoImage.rectTransform.sizeDelta = new Vector2(_bodyWidth, _expectedHeight);
    114.  
    115.  
    116.  
    117.                         _posterHolder.sizeDelta = _videoImage.rectTransform.sizeDelta;
    118.                         OnLoadVideo(previewTexure);
    119.                         ShowPlayBtn();
    120.  
    121.                         AppManager.VIEW_CONTROLLER.GetReq(_previreRequest);
    122.                         while (!_previreRequest.IsComplete)
    123.                         {
    124.                             Debug.Log("Preview request not complete");
    125.                             yield return null;
    126.                         }
    127.                         if (!_previreRequest.IsSuccess)
    128.                         {
    129.                             Debug.Log("Preview request not success");
    130.                             yield break;
    131.                         }
    132.                         _feed.BodyTXT = _previreRequest.BodyText;
    133.  
    134.                     }
    135.  
    136.  
    137.                 }
    138.             }

    My _url is what is applied after the image is taken. It is the return path. ive tried to use your loadimage at path but it always says the path is not found. I have tried to save it to a temp path like you said and that returns partial path. So i guess ill just have to fiddle with it more and see why this is. I not fetching it from the Server in this just yet. this code just takes the pic and then afterwards it uploads it to a preview texture for the user to look at and add some text to it then once thats done they hit upload and then its sent to the server. So the only path it has is a _url that ive asigned to it. So your loadimage at path isnt reconoing it.
     
  16. gaglabs

    gaglabs

    Joined:
    Oct 17, 2019
    Posts:
    185
    If(showpreview) is what is called after the image is taken. So the user can preview it. Videos work just fine.
     
  17. gaglabs

    gaglabs

    Joined:
    Oct 17, 2019
    Posts:
    185
    Got it.
     
  18. gaglabs

    gaglabs

    Joined:
    Oct 17, 2019
    Posts:
    185
    Code (CSharp):
    1. if (_type == FeedType.Image)
    2.                 {
    3.                     Texture2D _texture = NativeCamera.LoadImageAtPath(_url, 1024, false, true, true);
    4.                    
    5.                  
    6.                  
    7.                     yield return new WaitForEndOfFrame();
    8.                    
    9.                  
    10.                    
    11.                  
    12.                  
    13.                     imageBytes = _texture.EncodeToJPG(AppManager.APP_SETTINGS.UploadImageQuality);
    14.                     _feed.MediaWidth = _texture.width;
    15.                     _feed.MeidaHeight = _texture.height;
    16.                    
    17.                     previewTexure = _texture;
    18.                 }
     
    yasirkula likes this.
  19. yasirkula

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    2,910
    Glad the _url is now working somehow. I don't think you need WaitForEndOfFrame, by the way.
     
  20. thechargedneutron

    thechargedneutron

    Joined:
    Feb 13, 2019
    Posts:
    8
    Hello @yasirkula . Thanks for the asset. I am using this asset for iOS. I am using the following code to take a picture


    Code (CSharp):
    1. private void TakePicture(int maxSize)
    2.         {
    3.             Debug.Log("Started this function");
    4.             NativeCamera.Permission permission = NativeCamera.TakePicture((path) =>
    5.             {
    6.                 if (path != null)
    7.                 {
    8.                     // Create a Texture2D from the captured image
    9.                     Texture2D texture = NativeCamera.LoadImageAtPath(path, maxSize);
    10.                     if (texture == null)
    11.                     {
    12.                         Debug.Log("Couldn't load texture from " + path);
    13.                         return;
    14.                     }
    15.                     else
    16.                     {
    17.                         Texture2D newScreenshot = duplicateTexture(texture);
    18.                         byte[] bytes = newScreenshot.EncodeToPNG();
    19.                         File.WriteAllBytes(Path.Combine(Application.persistentDataPath, "bg.png"), bytes);
    20.                     }
    21.  
    22.                 }
    23.                 Debug.Log("Conversion and Saving successful");
    24.             }, maxSize);
    25.  
    26.             Debug.Log("Permission result: " + permission);
    27.         }
    28.  
    29.         Texture2D duplicateTexture(Texture2D source)
    30.         {
    31.             RenderTexture renderTex = RenderTexture.GetTemporary(
    32.                         source.width,
    33.                         source.height,
    34.                         0,
    35.                         RenderTextureFormat.Default,
    36.                         RenderTextureReadWrite.Linear);
    37.  
    38.             Graphics.Blit(source, renderTex);
    39.             RenderTexture previous = RenderTexture.active;
    40.             RenderTexture.active = renderTex;
    41.             Texture2D readableText = new Texture2D(source.width, source.height);
    42.             readableText.ReadPixels(new Rect(0, 0, renderTex.width, renderTex.height), 0, 0);
    43.             readableText.Apply();
    44.             RenderTexture.active = previous;
    45.             RenderTexture.ReleaseTemporary(renderTex);
    46.             return readableText;
    47.         }
    This is working good on iPhone X but in iPhone XR it is giving a rotated version of the same image. Can you help me with a solution to this? I am using
    duplicateTexture
    just to make the texture readable.
    Thanks

    EDIT: I checked the image saved in the Library/Cache/CameraImg.jpeg using XCode container. The image there is also rotated.
     
    Last edited: Dec 18, 2019
  21. yasirkula

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    2,910
  22. thechargedneutron

    thechargedneutron

    Joined:
    Feb 13, 2019
    Posts:
    8
    yasirkula likes this.
  23. yasirkula

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    2,910
    I'm guessing that the photo is null here since all other variables are used inside
    if(variable != null)
    conditions. You can check if this is the case by calling
    Debug.Log(photo);
     
  24. DoubleUU

    DoubleUU

    Joined:
    Dec 29, 2018
    Posts:
    46
    Yes, I finally just realized that myself and deleted my post before I noticed you had replied. Thanks and sorry for the bother!

    Edit: What is odd though is that even after fixing my null issue with photo I'm still seeing the null reference error in the log. However, my app is working and the image is being loaded so I'm happy at the moment. Thanks again.
     
    Last edited: Jan 8, 2020
    yasirkula likes this.
  25. shahanpower

    shahanpower

    Joined:
    Sep 10, 2018
    Posts:
    3
    Hey @yasirkula
    Thank you for this plugin, I tried it and I was wondering about the ability to take a snapshot automatically instead of manually doing it,
    I have this thing where I need to tell multiple phones to take camera images at the same time.

    Is it possible?
     
  26. yasirkula

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    2,910
    Not with this plugin, sorry.
     
  27. ArnaudM

    ArnaudM

    Joined:
    Jan 24, 2013
    Posts:
    7
    Hi !

    I am trying your plugin but I didn't get it to work yet.
    I want to take a photo a full resolution (the native resolution of the camera).

    Here is my "Shoot" method. It simply tries to save the photo to a PNG file. It looks a lot like your example code :)
    Code (CSharp):
    1. public void Shoot()
    2. {
    3.     if (NativeCamera.IsCameraBusy())
    4.     {
    5.         Debug.Log("Camera busy !");
    6.         return;
    7.     }
    8.  
    9.     int maxSize = -1;
    10.  
    11.     NativeCamera.Permission permission = NativeCamera.TakePicture((path) =>
    12.     {
    13.         Debug.Log("Image path: " + path);
    14.         if (path != null)
    15.         {
    16.             // Create a Texture2D from the captured image
    17.             Texture2D texture = NativeCamera.LoadImageAtPath(path, maxSize);
    18.             if (texture == null)
    19.             {
    20.                 Debug.Log("Couldn't load texture from " + path);
    21.                 return;
    22.             }
    23.  
    24.             // Encode texture into PNG
    25.             var bytes = texture.EncodeToPNG();
    26.             File.WriteAllBytes(Application.persistentDataPath + "/Image_" + Time.time + ".png", bytes);
    27.  
    28.             Destroy(texture, 5f);
    29.         }
    30.     }, maxSize);
    31.  
    32.     Debug.Log("Permission result: " + permission);
    33. }
    From my log I can see that the permission is granted and the camera is not busy, but I only get a null path.

    Do you have any idea of what I might do wrong ?

    I use Unity 2019.2.19 and a Samsung S6 running Android 7.0.

    Thank you !
     
  28. yasirkula

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    2,910
    Your code looks fine but you should set the markTextureNonReadable parameter of LoadImageAtPath to false in order for EncodeToPNG to work. Can you try your code in an empty project (if you have multiple Unity versions, try using an older one, as well) and see if it makes any difference?
     
  29. koradiyashivangi

    koradiyashivangi

    Joined:
    Aug 31, 2018
    Posts:
    1
    Hi, I have a problem with native camera plugin, when i open camera and take a picture then it again open camera and it should not been happened.
    After that my whole game restart.(from made with unity scene)
    This issue happen in some device not all android device.
    Please give me solutions of this ! Thanks!
     
  30. stecavalli

    stecavalli

    Joined:
    Oct 26, 2019
    Posts:
    10
    I recorded a video, and I see it but when I search for it in the smartphone it is not there. Not saved on the phone?
     
  31. stecavalli

    stecavalli

    Joined:
    Oct 26, 2019
    Posts:
    10
    It doesn't matter, I solved it like this:
    File.Move(origin, destination);
     
  32. yasirkula

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    2,910
    @koradiyashivangi If the camera app is reopening immediately after you close it, you might be calling the NativeCamera functions inside an Update loop that gets executed every frame. The restart issue is probably related to RAM usage; old devices that have insufficient RAM may run out of memory when the camera app is opened and in this case, Android OS automatically kills Unity app to free up some memory. Hence why the app restarts after the camera is closed. You shouldn't worry about it much since the majority of the Android users have powerful enough devices and won't be affected by this issue.

    @stecavalliofficial NativeCamera won't save the image/video to Gallery automatically, the file will be stored at Application.temporaryCachePath. If you want to save the image/video to Gallery afterwards, you can give NativeGallery a shot: https://forum.unity.com/threads/native-gallery-for-android-ios-open-source.519619/
     
  33. swpowe

    swpowe

    Joined:
    Mar 20, 2018
    Posts:
    4
    @yasirkula Thanks for the plugin! I'm having trouble getting it working. I'm in Unity 2019.1.5f1 and it doesn't seem to be working. One issue I'm seeing is I'm getting an error in NCPostProcessBuild.cs. It says "The type or namespace name 'Xcode' does not exist in the namespace 'UnityEditor.iOS'" thus PBXProject isn't found.
    I've tried looking around to find a solution but I'm not finding anything. Suggestions?
    Also, when you say to implement for iOS update the
    CAMERA_USAGE_DESCRIPTION, what am I supposed to add or change there? Any help would be greatly appreciated.
     
  34. yasirkula

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    2,910
  35. cibaben5

    cibaben5

    Joined:
    Mar 12, 2020
    Posts:
    6
    Hi ! I am a beginner in unity and I would like to be able to use your application but I do not know what I should do after downloading and importing your package, please need help :(
     
  36. yasirkula

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    2,910
  37. cibaben5

    cibaben5

    Joined:
    Mar 12, 2020
    Posts:
    6
    merci de votre réponse mais je crois que vous m'avez pas compris, je veux dire de ma question commentaire je peux utiliser votre projet j'y ne trouve aucune scène ou un code bien precis merci bien :)
     
  38. cavrnus_dale

    cavrnus_dale

    Joined:
    Mar 30, 2020
    Posts:
    1
    Hi @yasirkula,

    Thanks for making this great plugin and for being so responsive for support.

    I'm running into a minor issue with the iOS version of the plugin: upon calling NativeCamera.TakePicture or NativeCamera.RecordVideo for the first time after my application is open, the iOS camera viewer comes up for about a second, then immediately closes before a picture is properly taken, and calls the CameraCallback with an empty filepath string. Opening the camera afterwards works perfectly fine. I've tested this with a gameobject on the opening scene with the following script:
    Code (CSharp):
    1. public class CameraTest : MonoBehaviour
    2. {
    3.     void Update()
    4.     {
    5.         if (Input.GetMouseButtonDown(0))
    6.         {
    7.             // Don't attempt to use the camera if it is already open
    8.             if (NativeCamera.IsCameraBusy())
    9.                 return;
    10.  
    11.             NativeCamera.Permission permission = NativeCamera.TakePicture((path) =>
    12.             {
    13.                 Debug.Log("Image path: " + path);
    14.             });
    15.            
    16.             Debug.Log("Permission result: " + permission);
    17.         }
    18.     }
    19. }
    I'm testing this with an iPad on iOS 13.3.1. Any help would be greatly appreciated!
     
  39. yasirkula

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    2,910
    I wonder if calling
    enabled = false;
    before NativeCamera.TakePicture fixes this issue. Perhaps the issue is with my example code calling TakePicture in Update. Can you also check Xcode console for any error messages?
     
  40. SHIZAAAAA

    SHIZAAAAA

    Joined:
    Apr 3, 2020
    Posts:
    2
    hello,

    is was able to use the mobile camera using your sample code in github and now i want to use it to take pictures of my ar scene with all the virtual objects placed.

    can you please explain how to do that.

    thank you.
     
  41. kamarayako

    kamarayako

    Joined:
    Apr 3, 2020
    Posts:
    1
    This plugin needs to enable access to the device's camera?
     
  42. yasirkula

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    2,910
    @SHIZAAAAA You are trying to capture a screenshot. You don't need NativeCamera for this, you can use Unity's ScreenCapture API instead.

    @kamarayako Do you mean that the plugin doesn't ask the camera permission automatically?
     
  43. SHIZAAAAA

    SHIZAAAAA

    Joined:
    Apr 3, 2020
    Posts:
    2
    i will check it out
    thank you for your fast reply
     
  44. schashm3

    schashm3

    Joined:
    Oct 9, 2018
    Posts:
    10
    hi everyone..
    first thanks to yasirkula for this amazing asset.
    i want to set some custom filter on recorded video. how can i do that?
     
  45. yasirkula

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    2,910
    If the native camera app doesn't have this functionality, I don't think you can. NativeCamera simply launches the native camera app and fetches the raw picture/video it outputs.
     
  46. stecavalli

    stecavalli

    Joined:
    Oct 26, 2019
    Posts:
    10
    https://assetstore.unity.com/packag...ema-themes-2-color-grading-luts-library-20394

    You can record the video with Native Camera and watch it on a quad object with the Videoplayer component. Use the resource in the link above to apply the filters on the main camera of your scene.
     
  47. schashm3

    schashm3

    Joined:
    Oct 9, 2018
    Posts:
    10
    thank you for fast answer...
    i want apply filter to recorded video completely..not only in the main camera. but let me test it first.
    i'll check it and post result here... also thanks to @yasirkula
     
  48. stecavalli

    stecavalli

    Joined:
    Oct 26, 2019
    Posts:
    10
    you can do it by recording the screen after applying the filter, or even using ARcamera di vuforia combined with the filter and then recording the screen
     
  49. Pointzero

    Pointzero

    Joined:
    Sep 27, 2015
    Posts:
    1
    Hi,
    Have been having an issue with the audio in my app, and I believe I've narrowed it down to your plugin.
    Part of the app involves recording audio from the devices microphone and replaying it - to do this I am using Unity's built in methods.
    Normally this works fine, however if I first use NativeCamera.RecordVideo() (either to record a video or simply cancelling the popup), I am no longer able to record audio within the app and the app fails to play any recorded audio.
    Do you know of anything that could be causing this?
    I also get the following line repeated over and over in the logs on XCode, and I haven't been able to find its cause
    Audio session route changed, reason: 3


    Any help would be greatly appreciated in finding the issue
     
  50. yasirkula

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    2,910