Search Unity

NatDevice - Media Device API

Discussion in 'Assets and Asset Store' started by Lanre, Dec 17, 2015.

?

Should we add exposure controls in v1.3? This means dropping support for iOS 7

Poll closed Jun 10, 2016.
  1. Yes

    9 vote(s)
    75.0%
  2. No

    3 vote(s)
    25.0%
  1. tiffanybailey24124

    tiffanybailey24124

    Joined:
    Sep 22, 2019
    Posts:
    4
    Is the flash still gonna be fixed? I would need to have a working flash for my app. Is it somehow possible to help fixing this issue?
     
  2. resilio

    resilio

    Joined:
    Sep 7, 2017
    Posts:
    12
    Heya!
    Not sure if this has been asked before (I couldn't find any hit searching the thread) but I have a question about the new iPhone 11 with 3 back-cameras.
    How is (or will) that handled by NatCam? Will we need to do some changes to be able to still use the "normal" camera or will everything remain the same?
     
  3. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    3,973
    I'll try to implement some new code and post here if I have a build that works.
     
  4. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    3,973
    I haven't tested on the iPhone 11 yet. Things should mostly be the same. The only difference should be that there are more camera devices returned by CameraDevice.GetDevices.
     
  5. nctw

    nctw

    Joined:
    Oct 8, 2019
    Posts:
    4
    Is it possible to get the exposure time used to capture a photo?

    And changing the zoom ratio has no effect on my s10. Any idea why that could be?
     
    Last edited: Oct 22, 2019
  6. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    3,973
    This isn't supported.
    Not sure. Can you upload the full logs from logcat in a .txt attachment?
     
  7. Mojo-Game-Studio

    Mojo-Game-Studio

    Joined:
    Sep 18, 2015
    Posts:
    111
    upload_2019-10-24_22-3-55.png

    Hi getting this error when switching from a scene using the minicam, can you help to solve it. thanks
     
  8. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    3,973
    There seems to be a null reference exception, likely because you are switching scenes so the references to objects in the scene are invalidated. You have to take special precautions when running the camera preview across scenes.
     
  9. Mojo-Game-Studio

    Mojo-Game-Studio

    Joined:
    Sep 18, 2015
    Posts:
    111
    The error is to do with natcam, if I disable minicam and run the same scenes, no errors no warnings, how to fix?

    In reality like other assets it should just work
     
  10. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    3,973
    The MiniCam example is not designed to work across multiple scenes. Write your own code that pays attention to these subtle details instead of lifting example code and expecting it to just work with your scenario.
     
  11. Mojo-Game-Studio

    Mojo-Game-Studio

    Joined:
    Sep 18, 2015
    Posts:
    111
    seriously, wtf kind of support is that! "Write your own code", the reason I bought the asset is so I didn't have too.

    I've another question for you, When I build for Iphone it compiles and builds to the phone ok, but when I need to archive the build in ios to make a releasable version for the app store, I get a host of undefined symbols _NCCapturePhoto/_NCStartPreview etc etc, I guess I'll need to figure that out myself too.
     
  12. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    3,973
    If you haven't noticed, all our products are API's, which mean that they are all-code. Developers use our products by calling into our code. Nowhere in our marketing materials do we say it is drag-n-drop, or plug-n-play. "Write your own code" is the entire point.
    You are likely trying to archive for armv7. Our API's all target iOS 11, which does not support armv7. Archive for arm64 only.
     
    AppsWithLove likes this.
  13. YutaMiura-Moguai

    YutaMiura-Moguai

    Joined:
    Feb 13, 2019
    Posts:
    4
    Hi,
    I installed NatCam.
    and build and run MiniCam scene on Android.
    but CameraDevice.StartPreview is not working.
    CapturePhoto is worked correctly.

    logcat shows error below.

    NatRender Error: Performed blit with error 1286

    • Unity version: 2019.1.4f1
    • Android
      • version 8.0
      • model ASUS_X00RD
     
  14. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    3,973
    Make sure your app is not using Vulkan.
     
    DrSharky likes this.
  15. YutaMiura

    YutaMiura

    Joined:
    Jan 30, 2017
    Posts:
    1
    I think not use Vulkan.
    (I'm sorry I don't know Vulkan...)
    Because I imported from AssetStore NatCam to empty Unity Projects.
     
  16. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    3,973
    In Player Settings, make sure that 'Auto Graphics API' is not selected, then remove Vulkan from the list.
     
  17. unitystefan

    unitystefan

    Joined:
    Mar 16, 2018
    Posts:
    9
    Hello @Lanre
    I'm testing NatCam in past 10days and so far its doing a job, I am managing to save photos using Application.persistentDataPath and its all fine. But, can you provide us how can we save photos directly to Android and iOS gallery?
    Thank you in advance!

    Edit: I forgot to mention, @yasirkula UnityNativeGallery works great with this, but I was wondering if missed something in NatCam.
     
  18. AppsWithLove

    AppsWithLove

    Joined:
    Jan 31, 2018
    Posts:
    1
    We're having the same issue that we get 41 Undefined symbol errors while building the xcode project. However, we have set everything to arm64. Is there anything that we are missing out? Tried to build the project with unity 2019.1.14f1 and 2019.2.10f1.

    Fix: We deleted the NatCam folder and reimported all the Assets. After that it worked. Might have had some old files in that folder that made the errors. happen
     
    Last edited: Nov 4, 2019
    Lanre likes this.
  19. nctw

    nctw

    Joined:
    Oct 8, 2019
    Posts:
    4
    Any updates on this issue?
     
  20. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    3,973
    Yup, UnityNativeGallery works. You could also use NatShare.
     
  21. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    3,973
    This has been fixed in 2.3.0.
     
  22. blamejane

    blamejane

    Joined:
    Jul 8, 2013
    Posts:
    233
    I've been attempting to build my app for the Android platform. I just updated to the latest NatCam core/pro version. I'm using Unity 2019.2.9f1 on a mac. I couldn't find any specific instructions for the upgrade on my NatCam asset so I just downloaded the new version and imported it into my existing project. Only thing I did do was delete the assets\plugins folder.

    I am getting this error from the build (il2cpp):

    java.lang.RuntimeException: java.lang.RuntimeException: Duplicate class com.yusufolokoba.natcam.BuildConfig found in modules classes.jar :)NatCam:) and classes.jar :)NatCamCore:)

    How should I solve this?

    Thanks.

    EDIT: Solved this by deleting the outdated .aar files
     
    Last edited: Nov 9, 2019
    Lanre likes this.
  23. blamejane

    blamejane

    Joined:
    Jul 8, 2013
    Posts:
    233
    I have a problem with the Define Symbols for my project. If I remove NATCAM_16, etc. from the string, they eventually end up back in the string. Can you tell me how to remove these?
     
  24. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    3,973
    Delete and reimport NatCam into your project. You probably have old NatCam files in your project.
     
  25. blamejane

    blamejane

    Joined:
    Jul 8, 2013
    Posts:
    233
    Still working out the changes after upgrading from 1.6.

    My app no longer requests camera permissions after upgrading.

    So I used to have libs = libnatcampro, libnatcamcore. I used to have NatCamEditor which had camera permissions info.
    Now all I have is libnatcam. Not sure if this helps, but any thoughts?
     
  26. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    3,973
    NatCam doesn't handle permissions because Unity has API's to do so. See the Android Permissions and Application Permissions classes.
     
  27. tantanix

    tantanix

    Joined:
    Nov 20, 2013
    Posts:
    10
    Hi,

    We're getting some crashes reported in Crashlytics. I hope you can shed some light on this.

    Code (CSharp):
    1. Caused by java.lang.NullPointerException: Attempt to invoke virtual method 'void android.hardware.camera2.CaptureRequest$Builder.set(android.hardware.camera2.CaptureRequest$Key, java.lang.Object)' on a null object reference
    2.        at com.olokobayusuf.natcam.CameraDevice$1.onCaptureCompleted(CameraDevice.java:326)
    3.        at java.lang.reflect.Method.invoke(Method.java)
    4.        at java.lang.reflect.Method.invoke(Method.java:372)
    5.        at android.hardware.camera2.dispatch.InvokeDispatcher.dispatch(InvokeDispatcher.java:39)
    6.        at android.hardware.camera2.dispatch.HandlerDispatcher$1.run(HandlerDispatcher.java:65)
    7.        at android.os.Handler.handleCallback(Handler.java:739)
    8.        at android.os.Handler.dispatchMessage(Handler.java:95)
    9.        at android.os.Looper.loop(Looper.java:211)
    10.        at com.unity3d.player.UnityPlayer$e.run()

    Code (CSharp):
    1. Device
    2. Brand: Sony
    3. Model: Xperia Z1 Compact
    4. Orientation: Portrait
    5. RAM free: 375.38 MB
    6. Disk free: 422.71 MB
    7.  
    8. Operating System
    9. Version: 5.1.1
    10. Orientation: Portrait
    11. Rooted: No
     
  28. tantanix

    tantanix

    Joined:
    Nov 20, 2013
    Posts:
    10
    And here's another one

    Code (CSharp):
    1. Fatal Exception: java.lang.Error: FATAL EXCEPTION [NatRender GLRenderContext]
    2. Unity version     : 2019.2.3f1
    3. Device model      : HUAWEI EVA-L09
    4.  
    5. Caused by java.lang.RuntimeException: Error during updateTexImage (see logcat for details)
    6.        at android.graphics.SurfaceTexture.nativeUpdateTexImage(SurfaceTexture.java)
    7.        at android.graphics.SurfaceTexture.updateTexImage(SurfaceTexture.java:240)
    8.        at com.olokobayusuf.natcam.FrameRenderer$3.onFrameAvailable(FrameRenderer.java:106)
    9.        at android.graphics.SurfaceTexture$1.handleMessage(SurfaceTexture.java:203)
    10.        at android.os.Handler.dispatchMessage(Handler.java:105)
    11.        at android.os.Looper.loop(Looper.java:156)
    12.        at android.os.HandlerThread.run(HandlerThread.java:61)

    Code (CSharp):
    1. Device
    2. Brand: HUAWEI
    3. Model: P9
    4. Orientation: Portrait
    5. RAM free: 730.95 MB
    6. Disk free: 8.31 GB
    7.  
    8. Operating System
    9. Version: 7.0
    10. Orientation: Portrait
    11. Rooted: No
     
  29. tantanix

    tantanix

    Joined:
    Nov 20, 2013
    Posts:
    10
    And the last crash:

    Code (CSharp):
    1. Fatal Exception: java.lang.Error: FATAL EXCEPTION [NatCam Operations Thread]
    2. Unity version     : 2019.2.3f1
    3. Device model      : samsung SM-A310F
    4.  
    5. Caused by java.lang.IllegalStateException: Session has been closed; further changes are illegal.
    6.        at android.hardware.camera2.impl.CameraCaptureSessionImpl.checkNotClosed(CameraCaptureSessionImpl.java:606)
    7.        at android.hardware.camera2.impl.CameraCaptureSessionImpl.setRepeatingRequest(CameraCaptureSessionImpl.java:227)
    8.        at com.olokobayusuf.natcam.CameraDevice$4$1.onConfigured(CameraDevice.java:489)
    9.        at java.lang.reflect.Method.invoke(Method.java)
    10.        at android.hardware.camera2.dispatch.InvokeDispatcher.dispatch(InvokeDispatcher.java:39)
    11.        at android.hardware.camera2.dispatch.HandlerDispatcher$1.run(HandlerDispatcher.java:65)
    12.        at android.os.Handler.handleCallback(Handler.java:751)
    13.        at android.os.Handler.dispatchMessage(Handler.java:95)
    14.        at android.os.Looper.loop(Looper.java:154)
    15.        at android.os.HandlerThread.run(HandlerThread.java:61)
    Code (CSharp):
    1. Device
    2. Brand: samsung
    3. Model: Galaxy A3(2016)
    4. Orientation: Portrait
    5. RAM free: 196.44 MB
    6. Disk free: 1.43 GB
    7.  
    8. Operating System
    9. Version: 7.0
    10. Orientation: Portrait
    11. Rooted: No
     
  30. tantanix

    tantanix

    Joined:
    Nov 20, 2013
    Posts:
    10
    Forgot there's one more:

    Code (CSharp):
    1. Fatal Exception: java.lang.Error: FATAL EXCEPTION [NatCam Preview Thread]
    2. Unity version     : 2019.2.3f1
    3. Device model      : samsung GT-I9500
    4.  
    5. Caused by java.lang.UnsupportedOperationException: The producer output buffer format 0x5 doesn't match the ImageReader's configured buffer format 0x1.
    6.        at android.media.ImageReader.nativeImageSetup(ImageReader.java)
    7.        at android.media.ImageReader.acquireNextSurfaceImage(ImageReader.java:297)
    8.        at android.media.ImageReader.acquireNextImage(ImageReader.java:343)
    9.        at android.media.ImageReader.acquireLatestImage(ImageReader.java:247)
    10.        at com.olokobayusuf.natcam.FrameRenderer$4.onImageAvailable(FrameRenderer.java:128)
    11.        at android.media.ImageReader$ListenerHandler.handleMessage(ImageReader.java:547)
    12.        at android.os.Handler.dispatchMessage(Handler.java:102)
    13.        at android.os.Looper.loop(Looper.java:145)
    14.        at android.os.HandlerThread.run(HandlerThread.java:61)
    Code (CSharp):
    1. Device
    2. Brand: samsung
    3. Model: Galaxy S4
    4. Orientation: Portrait
    5. RAM free: 299.93 MB
    6. Disk free: 767.46 MB
    7.  
    8. Operating System
    9. Version: 5.0.1
    10. Orientation: Portrait
    11. Rooted: No
     
  31. nctw

    nctw

    Joined:
    Oct 8, 2019
    Posts:
    4
    I'm still getting similar issues on an iPad. The reported photo resolution is 3264x1836. But the actual resolution of the captured photo is 1920x1080, the resolution of the camera preview.
     
  32. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    3,973
    Can you share your NatCam code?
    These look to be device-specific. I'll see if I can find anything useful, but no guarantees.
     
  33. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    3,973
    I'll try to reproduce this. In the meantime, can you share your NatCam code?
     
  34. DW-Games

    DW-Games

    Joined:
    Feb 19, 2013
    Posts:
    5
    Hi, we just updated NatCam from 1.6 to 2.3 and experiencing some strange issues:
    (1) NatCam preview texture incorrectly gets the pixels of other textures in the scene, making the preview texture the same as the texture being "copied". This issue happens on Android(iOS not tested), in the Editor it works correctly as it uses the legacy API (WebcamTexture). This issue does not happen in 1.6.
    (2) Another issue, just like someone has mentioned here. Black preview texture after the on application pause event. This does not happen in 1.6.

    Any idea?
    Hope these issues can be fixed shortly.
    Or, do you consider to provide the 1.6 package with 64bit .aar and support for Android API Level 28, before fixing these issues, is it possible?
    Thank you for your work.
     
  35. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    3,973
    Can you explain this? How does the preview texture 'get pixels of other textures in the scene'? Can you share a screenshot?
    Can you share the logs? I haven't had any reports of this.
     
  36. jose_pedro_didimo

    jose_pedro_didimo

    Joined:
    May 2, 2018
    Posts:
    15
    Hi I have recently updated a Unity project to version 2019.2.6f1 and there were issues switching/using the back camera (tested on Android only) so I tested newer versions of the plugins:
    - NatShare v11f3
    - NatCam v2.2.1 --> v2.3.0
    - NatCorder v1.6.1 -> v1.6.4

    Then, I noticed a conflict with NatRender between NatCam and NatCorder:
    • if NatRender from NatCam is used, then the app can't use NatCorder: can't find class GpuFence
    • if NatRender from NatCorder is used, then the app can't use Natcam: Didn't find class "com/olokobayusuf/natrender/Unmanaged"
    On the other hand, although it seems to switch better to the back camera, It still is unable to capture a photo in decent time. i.e. the app hangs for minutes, and the callback is not properly executed, etc.

    Device: Sony Xperia XZ1 (Android 8.0.0)

    I will revert the upgrade to the previous plugin version, and probably disable the back camera feature, but is there anything you can add about these issues?
     
  37. nctv

    nctv

    Joined:
    Nov 26, 2019
    Posts:
    2
    I started with the MiniCam example, removed everything except the preview and the photo button. Then i added three Text components to show the preview resolution, the photo resolution and the size of the captured photo.

    I get a preview resolution of 1920x1080 and a photo resolution of 3264x1836, which is what i want. But the actual captured phot only has a resolution of 1920x1080.
     

    Attached Files:

    Lanre likes this.
  38. DW-Games

    DW-Games

    Joined:
    Feb 19, 2013
    Posts:
    5

    Thank you for your reply!

    My scene has some texture players playing textures (Texture2D), on each texture player object there are UGUI RawImage, Button components, and the texture player script which is an Update to loop the textures. The error sometimes happens when the user clicks on the RawImage to select it, or when the player is being cleared. The Clear method doing something like destroying textures and call the UnloadUnusedAssets method as well.


    For the black preview issue, I added the below method in MiniCam script:
    public void UnloadUnusedAssets()
    {
    Resources.UnloadUnusedAssets();
    }

    Build the MiniCam example scene, start the MiniCam example on my Samsung Note5, switch camera for twice, and call the UnloadUnusedAssets method, the NatCam preview texture becomes black. And, the other way that will produce the black preview texture error is OnApplicationPause event.


    I am thinking if the Unity texture Destroy or UnloadUnusedAssets method may clear the texture data in the memory, but the NatCam preview data pointer is not updated.

    Logs included in the zip file.
    Thanks!

     

    Attached Files:

  39. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    3,973
    Make sure you are on the latest version of NatCorder. NatCorder does not need GPUFence any longer. The latest versions of NatCorder and NatCam work properly; they use the same build of NatRender. As for the photo capture taking a long time, on NatCam 2.3 it should be very fast and should never hang the calling thread. Can you upload the logs from logcat in a .txt file?
     
  40. atulva

    atulva

    Joined:
    Jan 9, 2019
    Posts:
    2
    NatCam won't work in Android 10 (Tested in Google Pixel)

    Code (CSharp):
    1.   (Filename: ./Runtime/Export/Debug.bindings.h Line: 45)
    2. 2019-12-10 12:12:55.816 17900-18169/xxxx.xxxxxx.xxxxxx E/Unity: AndroidJavaException: java.lang.NoSuchMethodError: no non-static method with name='address' signature='()J' in class Ljava.lang.Object;
    3.     java.lang.NoSuchMethodError: no non-static method with name='address' signature='()J' in class Ljava.lang.Object;
    4.         at com.unity3d.player.ReflectionHelper.getMethodID(Unknown Source:167)
    5.         at com.unity3d.player.ReflectionHelper.nativeProxyInvoke(Native Method)
    6.         at com.unity3d.player.ReflectionHelper.a(Unknown Source:0)
    7.         at com.unity3d.player.ReflectionHelper$1.invoke(Unknown Source:6)
    8.         at java.lang.reflect.Proxy.invoke(Proxy.java:1006)
    9.         at $Proxy7.onFrame(Unknown Source)
    10.         at com.yusufolokoba.natcam.DeviceCamera$2.onFrame(DeviceCamera.java:443)
    11.         at com.yusufolokoba.natcam.FrameRenderer$4$1.onReadback(FrameRenderer.java:114)
    12.         at com.yusufolokoba.natrender.AsyncGPUReadback.dispose(AsyncGPUReadback.java:90)
    13.         at com.yusufolokoba.natrender.AsyncGPUReadback.access$300(AsyncGPUReadback.java:13)
    14.         at com.yusufolokoba.natrender.AsyncGPUReadback$1.run(AsyncGPUReadback.java:108)
    15.         at androi
     
  41. ClayBudin

    ClayBudin

    Joined:
    May 10, 2017
    Posts:
    6
    Hi!

    We are using the NatCam Unity plugin for iOS work (iPad) and we are
    really liking it! Nice work!

    We are wondering if it would be possible to support the exposure mode
    of the iPad camera a little more fully. Right now, you have ExposureLock
    as a boolean value, but accoring to the Apple developer docs, there are
    actually 4 exposure mode settings:

    https://developer.apple.com/documentation/avfoundation/avcapturedevice/1388858-exposuremode
    https://developer.apple.com/documentation/avfoundation/avcaptureexposuremode

    AVCaptureExposureModeLocked
    The exposure setting is locked.

    AVCaptureExposureModeAutoExpose
    The device automatically adjusts the exposure once and then changes the exposure mode to AVCaptureExposureModeLocked.

    AVCaptureExposureModeContinuousAutoExposure
    The device continuously monitors exposure levels and auto exposes when necessary.

    AVCaptureExposureModeCustom
    The device should only adjust exposure according to user provided ISO and exposureDuration property values.

    It would be great if you could support both one-time and continuous auto-exposure
    modes.

    Thanks,
    Clay Budin
    New York City
     
  42. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    3,973
    Upgrade to NatCam 2.3 on the Asset Store. This issue should be implicitly fixed by the update.
     
  43. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    3,973
    I responded to your email, but for anyone else who might be curious, setting CameraDevice.ExposurePoint implicitly sets the exposure mode to auto expose.
     
  44. ClayBudin

    ClayBudin

    Joined:
    May 10, 2017
    Posts:
    6
    Here is Lanre's full response, which I found very helpful:

    NatCam supports three of those four modes already:
    • CameraDevice.ExposureLock = true corresponds to AVCaptureExposureModeLocked
    • CameraDevice.ExposurePoint will set AVCaptureModeAutoExpose
    • CameraDevice.ExposureLock = false (which is default) corresponds to AVCaptureModeContinuousAutoExposure
    Custom isn't supported.
     
    Lanre likes this.
  45. xharkx

    xharkx

    Joined:
    May 17, 2017
    Posts:
    26
    Hi,I tested iPhone 11.
    I got 4 objects from CameraDevice.GetDevices API.

    [0] -> Normal
    [1] -> Selfie
    [2] -> Zoom
    [3] -> Normal

    [3] should return Wide angle.

    I know Lanre haven't tested on the iPhone 11 yet.
    But Any idea to fix the issue?
    My client wants wide angle camera.

    Thank you.
     
    Last edited: Dec 12, 2019
  46. Kruemelchen

    Kruemelchen

    Joined:
    Aug 26, 2019
    Posts:
    27
    Hello @Lanre,

    Is there a best practice how I can react on screen orientation change? As far as I can see this is currently not supported by natcam, is it? Also when I start the preview with orientation set to landscape then the captured photo is upside down. Do I have to rotate the texture by myself?
     
  47. nctv

    nctv

    Joined:
    Nov 26, 2019
    Posts:
    2
    Hello, is it possible to mute the camera shutter sound on iOS?
     
  48. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    3,973
    Support for this is coming in the 2.3.1 update.
     
  49. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    3,973
    UI best practice is to lock the orientation of the app when the camera is enabled. You'll notice that this is what every camera app out there does.

    As for the photo being upside down, this sounds like a bug. What device and OS version?
     
  50. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    3,973
    As far as I know this is not possible.