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. blamejane

    blamejane

    Joined:
    Jul 8, 2013
    Posts:
    233
    Thanks, that worked great...

    Landscape Left is the only orientation that works correctly. Landscape right is displaying upside-down. Any suggestions for this?
     
  2. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    3,971
    I need more information. What device and OS are you running on? Are you using auto-rotation? If so, NatCam does not support autorotation for technical reasons.
     
  3. blamejane

    blamejane

    Joined:
    Jul 8, 2013
    Posts:
    233
    After starting with a new project the preview is working as I would expect. Thanks!
     
  4. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    3,971
    Sounds good!
     
  5. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    3,971
    NatCam Pro 1.5f2 is out.

    It contains fixes to all the issues in 1.5f1. Here is the changelog:
    + Added master switches to enable and disable the Extended and Professional spec in NatCamLinker.
    + Added support for getting DeviceCamera.PhotoResolution on NatCamLegacy.
    + Added support for more Android devices by making camera requirement optional.
    + Fixed preview not showing on a large number of Android devices.
    + Fixed memory leak when calling NatCam.Play() when preview is paused on iOS.
    + Fixed crash on start when running on some Android devices running OpenGLES 2.
    + Fixed bug where camera did not switch on Android.
    + Fixed OnPreviewStart not being called when NatCam.Play() is called after NatCam.Pause().
    + Fixed DeviceCamera.PreviewResolution returning wrong values on NatCamLegacy.
    + Fixed iOS 10 crash by adding NSMicrophoneUsageDescription.
    + Fixed endless refresh when using plugins that used custom platform macros like Cross Platform Native Plugins.
    + Fixed 'requested build target group (15) doesn't exist' error in NatCamLinker.
    + Fixed barcode detection not working on NatCamLegacy (WebCamTexture).
    + Added ReplayCam video recording example with recorded video playback.
    + Added flag to specify whether audio permission should be requested and if audio should be recorded.
    + Fixed crash when preview starts on Android devices running on OpenGLES 3.
    + Fixed microphone hardware requirement on Android.
     
    mimminito likes this.
  6. BongoMongo

    BongoMongo

    Joined:
    Dec 12, 2013
    Posts:
    7
    Hi there! I'm using the latest NatCam Pro on Unity 5.5 and would like to feed the camera texture to OpenCV using OpenCV for Unity. Like it says in your example here, I use the #define OPENCV_API to get access to the preview matrix.
    Everything works fine in the editor but as soon as I try running it on iOS it just crashes with a null ref exception. You have any ideas what could cause this behaviour?
     
  7. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    3,971
    Please email me with more information about the crash. What is the stack trace of the crash? Where does it originate from?
     
  8. angelsm85

    angelsm85

    Joined:
    Oct 27, 2015
    Posts:
    63
    Hi @blamejane! I'm working in something similar and I need only the preview cam feature to assign it as a background in my game. Now I'm using unity native WebcamTexture but it doesn't work fine (very lagged). Is natcam a good solution to improve performance in mobile devices? Thanks !!
     
  9. visualjoy

    visualjoy

    Joined:
    Aug 23, 2016
    Posts:
    38
    Hi Larne!

    We did a quick test on a Samsung S6 running Lollipop 5.02
    We built minigram, and StartingOff.

    Here is the result:



    Leo
     
    Dotby likes this.
  10. blamejane

    blamejane

    Joined:
    Jul 8, 2013
    Posts:
    233
    I just PM'd you back. Basically I have removed Vuforia, which is somehow managing lightning fast clock speeds of 60 fps on mobile, and replaced with NatCam preview texture. I don't see any noticeable lag, but I haven't actually tested performance yet. Looks like @visualjoy has done some testing for Android.

    I would love to see iOS testing results! (Edit: nevermind, you can't tell much from the video) Oh and NatCam preview texture out-of-the-box is giving me 30 fps; half of what Vuforia offers and exactly the same as webcamTexture in terms of frame rate.
     
    Last edited: Dec 22, 2016
  11. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    3,971
    I've had reports of this issue. Apparently, it is caused by the canvas render mode. To my knowledge, the Screen Space Overlay mode causes this issue (whereas Screen Space Camera works fine). This bug was reported on Unity 5.5.
     
  12. inCreactive

    inCreactive

    Joined:
    Dec 21, 2016
    Posts:
    9
    Hello Lanre! We would like to know how reliable would NatCam be right now for recording video with audio on iOS and Android? Thanks!
     
  13. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    3,971
    Hi! I recently received a report that video recording didn't work on some Android devices. I am currently working with that developer to investigate and resolve the issue. Once it is resolved, I will let you know.
     
  14. EnoxSoftware

    EnoxSoftware

    Joined:
    Oct 29, 2014
    Posts:
    1,564
    Hello Lanre!
    I tested with Nexus 7 (AndroidOS 6.0.1) and ASUS_Z00AD (AndroidOS 5.0), but the build result with Unity 5.4 also encountered the same bug.
    Since it can be avoided by changing the canvas render mode, they look like the same bug.
    Also, since this bug occurs while NatCam's preview is enabled, I attempted to temporarily suspend preview using NatCam.Pause () or Release () when moving the scene, but due to Play () It looks like it can not be restarted.

    For your information, the video recording function is working normally in my test.
     
  15. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    3,971
    I believe it is the same. I will be testing out a fix today. I will email you my current build of 1.5f3 to test.
    The preview doesn't restart? Please email me logs from your device (not Unity filtered, and have NatCam's verbose mode on).
    Great to hear! I will verify the issue that the developer reported of recording not working on some devices.
     
  16. rattlesnake

    rattlesnake

    Joined:
    Jul 18, 2013
    Posts:
    138
    Hi ! Lanre,
    Same issue as visualjoy :/ on android 5.0 Moreover the photos taken by the minigram exemple are blue/purple (the canvas is in "screen space camera")

    For me the video recording is working but the first seconds are black.

    I will wait for your fix !
     
  17. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    3,971
    This is a bug on Android in 1.5f2. The fix is simple.
    Add this line:
    Code (CSharp):
    1. previewStarted = false;
    At the end of the Pause method in NatCam>Core>Plugins>Managed>Platforms>Android>NatCamAndroid.cs
     
  18. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    3,971
    I'm looking into this issue.
    Please share a screenshot. I haven't faced this issue before.
    What do you mean "the first seconds are black"? Email me verbose logs from your device.
     
  19. EnoxSoftware

    EnoxSoftware

    Joined:
    Oct 29, 2014
    Posts:
    1,564
    I changed the code as you indicated.
    But the bug was not fixed.
    The OnPreviewStart event seems to have occurred immediately after Pause().(Not after Play method)

    #############
    12-25 08:47:40.645: I/Unity(31112): NatCam Logging: Inspected device: Found 2 cameras
    12-25 08:47:41.273: I/Unity(31112): NatCam Logging: Changed camera 1 resolution to 1280x720
    12-25 08:47:41.275: I/Unity(31112): NatCam Logging: Changed camera 1 photo resolution to 1280x768
    12-25 08:47:41.280: I/Unity(31112): NatCam Logging: Changed camera 1 framerate to 30000
    12-25 08:47:41.317: I/Unity(31112): NatCam Logging: Initialized Main Dispatcher
    12-25 08:47:41.425: I/Unity(31112): NatCam Logging: Generated resources
    12-25 08:47:41.425: D/Unity(31112): NatCam Logging: Generated camera texture with error 0
    12-25 08:47:41.427: I/Unity(31112): NatCam Logging: Starting session
    12-25 08:47:42.403: I/Unity(31112): NatCam Logging: Camera 1 started session
    12-25 08:47:42.726: D/Unity(31112): NatCam Logging: Generated preview texture with error 0
    12-25 08:47:42.734: D/Unity(31112): NatCam Logging: Generated render texture with error 0
    12-25 08:47:42.756: I/Unity(31112): OnPreviewStartEvent
    12-25 08:47:42.756: I/Unity(31112):
    12-25 08:47:42.756: I/Unity(31112): (Filename: ./artifacts/generated/common/runtime/UnityEngineDebugBindings.gen.cpp Line: 42)
    12-25 08:47:46.691: I/Unity(31112): OnPauseButtonDown
    12-25 08:47:46.691: I/Unity(31112):
    12-25 08:47:46.691: I/Unity(31112): (Filename: ./artifacts/generated/common/runtime/UnityEngineDebugBindings.gen.cpp Line: 42)
    12-25 08:47:46.729: I/Unity(31112): OnPreviewStartEvent
    12-25 08:47:46.729: I/Unity(31112):
    12-25 08:47:46.729: I/Unity(31112): (Filename: ./artifacts/generated/common/runtime/UnityEngineDebugBindings.gen.cpp Line: 42)
    12-25 08:47:46.999: I/Unity(31112): NatCam Logging: Camera 1 stopped session
    12-25 08:47:51.754: I/Unity(31112): OnPlayButtonDown
    12-25 08:47:51.754: I/Unity(31112):
    12-25 08:47:51.754: I/Unity(31112): (Filename: ./artifacts/generated/common/runtime/UnityEngineDebugBindings.gen.cpp Line: 42)
    12-25 08:47:51.754: I/Unity(31112): NatCam Logging: Starting session
    12-25 08:47:52.938: I/Unity(31112): NatCam Logging: Camera 1 started session
    ...
    #############



    In the test, I found some new bugs.

    1. If Play() is performed after Release() on Android, an error is output to the log.

    #############
    12-25 08:43:53.784: I/Unity(29435): OnReleaseButtonDown
    12-25 08:43:53.784: I/Unity(29435):
    12-25 08:43:53.784: I/Unity(29435): (Filename: ./artifacts/generated/common/runtime/UnityEngineDebugBindings.gen.cpp Line: 42)
    12-25 08:43:54.553: D/Unity(29435): NatCam Logging: Released surface texture with error 0
    12-25 08:43:54.553: D/Unity(29435): NatCam Logging: Released framebuffer with error 0
    12-25 08:43:54.556: D/Unity(29435): NatCam Logging: Released preview texture with error 0
    12-25 08:43:54.557: D/Unity(29435): NatCam Logging: Released resources with error 0
    12-25 08:43:54.569: I/Unity(29435): NatCam Logging: Released renderer
    12-25 08:43:54.571: I/Unity(29435): NatCam Logging: Released Dispatcher
    12-25 08:43:56.603: I/Unity(29435): OnPlayButtonDown
    12-25 08:43:56.603: I/Unity(29435):
    12-25 08:43:56.603: I/Unity(29435): (Filename: ./artifacts/generated/common/runtime/UnityEngineDebugBindings.gen.cpp Line: 42)
    12-25 08:43:56.701: I/Unity(29435): Exception: JNI: Init'd AndroidJavaObject with null ptr!
    12-25 08:43:56.701: I/Unity(29435): at UnityEngine.AndroidJavaObject..ctor (IntPtr jobject) [0x00000] in <filename unknown>:0
    12-25 08:43:56.701: I/Unity(29435): at UnityEngine.AndroidJavaObject.AndroidJavaObjectDeleteLocalRef (IntPtr jobject) [0x00000] in <filename unknown>:0
    12-25 08:43:56.701: I/Unity(29435): at UnityEngine.AndroidJavaObject._CallStatic[AndroidJavaObject] (System.String methodName, System.Object[] args) [0x00000] in <filename unknown>:0
    12-25 08:43:56.701: I/Unity(29435): at UnityEngine.AndroidJavaObject.CallStatic[AndroidJavaObject] (System.String methodName, System.Object[] args) [0x00000] in <filename unknown>:0
    12-25 08:43:56.701: I/Unity(29435): at NatCamU.Core.Platforms.NatCamAndroid.get_Camera () [0x00000] in <filename unknown>:0
    12-25 08:43:56.701: I/Unity(29435): at NatCamU.Core.NatCam.get_Camera () [0x00000] in <filename unknown>:0
    12-25 08:43:56.701: I/Unity(29435): at NatCamU.Examples.ReleaseToPlayTest.OnPlayButton () [0x00000] in <filename unknown>:0
    #############


    2. On the legacy target, if Release() is executed after Pause(), WebCameraTexture can not be released.
    This bug could be fixed by changing one line in the Release method of NatCamLegacy.cs.
    Code (CSharp):
    1. if (preview.isPlaying) preview.Stop();
    change to
    Code (CSharp):
    1. preview.Stop();
     
  20. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    3,971
    You are correct. I tested it and saw the same thing. To fix it, place the 'previewStarted = false' line at the very beginning of Play() (and remove it from the Pause() and Release() methods).
    You must assign a camera before you call Play() after calling Release(). This is because NatCam nullifies everything including the camera when Release() is called. That error is occurs because you seem to get NatCam.Camera while it is null, thus returning a null object inside the AndroidJavaObject container. Here is what I advise:
    Code (CSharp):
    1. // Release
    2. NatCam.Release();
    3. // To play again, do this:
    4. NatCam.Camera = DeviceCamera.RearCamera;
    5. ...
    6. NatCam.Play();
    7. // Or this:
    8. NatCam.Play(0); // DeviceCamera is implicitly typecast to and from an int
    Thank you for this! I have added it into the codebase.
     
  21. EnoxSoftware

    EnoxSoftware

    Joined:
    Oct 29, 2014
    Posts:
    1,564
    Thank you, Lanre
    Behavior when calling Play() after calling Pause() seems to have been fixed.
    However, the behavior when calling Play() after calling the Release() was not improved.

    I tested with this code.
    Code (CSharp):
    1.  
    2. using UnityEngine;
    3. using System;
    4. using NatCamU.Core;
    5. using Util = NatCamU.Core.Utilities.NatCamUtilities;
    6. using UnityEngine.SceneManagement;
    7.  
    8. namespace NatCamU.Examples
    9. {
    10.     public class ReleaseAndPlayTest : NatCamBehaviour
    11.     {
    12.         #if NATCAM_PROFESSIONAL
    13.         public override void OnPreviewStart ()
    14.         {
    15.             Debug.Log ("OnPreviewStart");
    16.             base.OnPreviewStart ();
    17.         }
    18.  
    19.         private void OnDisable ()
    20.         {
    21.             Debug.Log ("OnDisable");
    22.             NatCam.Release ();
    23.             NatCam.OnPreviewStart -= OnPreviewStart;
    24.             NatCam.OnPreviewUpdate -= OnPreviewUpdate;
    25.         }
    26.  
    27.         public void OnRestertButton ()
    28.         {
    29.             Debug.Log ("OnRestertButtonDown");
    30.             SceneManager.LoadScene ("ReleaseAndPlayTest");
    31.         }
    32.  
    33.         public void OnPlayButton ()
    34.         {
    35.             Debug.Log ("OnPlayButtonDown");
    36.             NatCam.Camera = facing == Facing.Front ? DeviceCamera.FrontCamera : DeviceCamera.RearCamera;
    37.             NatCam.Play();
    38.         }
    39.  
    40.         public void OnPauseButton ()
    41.         {
    42.             Debug.Log ("OnPauseButtonDown");
    43.             if (NatCam.IsPlaying)
    44.                 NatCam.Pause ();
    45.         }
    46.  
    47.         public void OnReleaseButton ()
    48.         {
    49.             Debug.Log ("OnReleaseButtonDown");
    50.             NatCam.Release ();
    51.         }
    52.         #endif
    53.     }
    54. }
    55.  
    And this error log was output.
    12-26 03:34:21.284: I/Unity(20021): NatCam Logging: Inspected device: Found 2 cameras
    12-26 03:34:21.582: I/Unity(20021): NatCam Logging: Changed camera 0 resolution to 1280x720
    12-26 03:34:21.585: I/Unity(20021): NatCam Logging: Changed camera 0 photo resolution to 2592x1944
    12-26 03:34:21.591: I/Unity(20021): NatCam Logging: Changed camera 0 framerate to 30000
    12-26 03:34:21.600: I/Unity(20021): NatCam Logging: Initialized Main Dispatcher
    12-26 03:34:21.883: I/Unity(20021): NatCam Logging: Generated resources
    12-26 03:34:21.884: D/Unity(20021): NatCam Logging: Generated camera texture with error 0
    12-26 03:34:21.890: I/Unity(20021): NatCam Logging: Starting session
    12-26 03:34:22.483: I/Unity(20021): NatCam Logging: Camera 0 started session
    12-26 03:34:22.915: D/Unity(20021): NatCam Logging: Generated preview texture with error 0
    12-26 03:34:22.917: D/Unity(20021): NatCam Logging: Generated render texture with error 0
    12-26 03:34:22.930: I/Unity(20021): OnPreviewStart
    12-26 03:34:22.930: I/Unity(20021):
    12-26 03:34:22.930: I/Unity(20021): (Filename: ./artifacts/generated/common/runtime/UnityEngineDebugBindings.gen.cpp Line: 42)
    12-26 03:34:30.265: I/Unity(20021): OnReleaseButtonDown
    12-26 03:34:30.265: I/Unity(20021):
    12-26 03:34:30.265: I/Unity(20021): (Filename: ./artifacts/generated/common/runtime/UnityEngineDebugBindings.gen.cpp Line: 42)
    12-26 03:34:31.081: D/Unity(20021): NatCam Logging: Released surface texture with error 0
    12-26 03:34:31.081: D/Unity(20021): NatCam Logging: Released framebuffer with error 0
    12-26 03:34:31.084: D/Unity(20021): NatCam Logging: Released preview texture with error 0
    12-26 03:34:31.086: D/Unity(20021): NatCam Logging: Released resources with error 0
    12-26 03:34:31.095: I/Unity(20021): NatCam Logging: Released renderer
    12-26 03:34:31.100: I/Unity(20021): NatCam Logging: Released Dispatcher
    12-26 03:34:35.895: I/Unity(20021): OnPlayButtonDown
    12-26 03:34:35.895: I/Unity(20021):
    12-26 03:34:35.895: I/Unity(20021): (Filename: ./artifacts/generated/common/runtime/UnityEngineDebugBindings.gen.cpp Line: 42)
    12-26 03:34:36.225: I/Unity(20021): NatCam Logging: Initialized Main Dispatcher
    12-26 03:34:36.226: I/Unity(20021): NatCam Logging: Starting session
    12-26 03:34:36.226: E/Unity(20021): NatCam Error: Drawing resource generation failed
    12-26 03:34:36.827: I/Unity(20021): NatCam Logging: Camera 0 started session
    12-26 03:34:37.234: D/Unity(20021): NatCam Logging: Generated preview texture with error 0
    12-26 03:34:37.235: D/Unity(20021): NatCam Logging: Generated render texture with error 0
    12-26 03:34:37.235: E/Unity(20021): NatCam Error: Creating GL program failed
    12-26 03:34:37.236: I/Unity(20021): OnPreviewStart
    12-26 03:34:37.236: I/Unity(20021):
    12-26 03:34:37.236: I/Unity(20021): (Filename: ./artifacts/generated/common/runtime/UnityEngineDebugBindings.gen.cpp Line: 42)
    12-26 03:34:37.284: E/Unity(20021): NatCam Error: Creating GL program failed
    12-26 03:34:37.368: E/Unity(20021): NatCam Error: Creating GL program failed
    12-26 03:34:37.403: E/Unity(20021): NatCam Error: Creating GL program failed
    12-26 03:34:37.447: E/Unity(20021): NatCam Error: Creating GL program failed
    ...
    ...
    ...
     

    Attached Files:

  22. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    3,971
    Sounds good.
    The first error you encountered is gone. The error you are encountering now has been reported before. I will fix it and send you the native library to test. Thanks for the logs!

    EDIT: @EnoxSoftware I've emailed you the library. Place the library inside NatCam>Core>Plugins>Android.
     
    Last edited: Dec 25, 2016
  23. inCreactive

    inCreactive

    Joined:
    Dec 21, 2016
    Posts:
    9
    Hello again Lanre,

    We are really interested in buying NatCam because we need to have a demo ready for a client in 2 or 3 weeks. We are eager to start making tests but we need to record video on iOS and Android. If we buy your plugin right now, what are the chances of you fixing the video recording bugs on Android in the near future? Thanks!
     
  24. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    3,971
    I am almost done with 1.5b3 which has all the fixes for bugs in 1.5f2, including the video recording bugs. i intend to complete and distribute the beta in the next 2-3 days. If you become a NatCam developer, you will get access to beta builds for testing (and early access to final releases as the final release is almost always the last beta for that revision).
     
  25. KKANGSUPER

    KKANGSUPER

    Joined:
    Jul 20, 2015
    Posts:
    2
    Where is a description for each NATCAM_CORE, NATCAM_EXTENDED, NATCAM_PROFESSIONAL configuration?
    I just want to use NATCAM Camera Preview only and don't need the other any function.
    Which kind of script define should I use?
     
  26. Carpet_Head

    Carpet_Head

    Joined:
    Nov 27, 2014
    Posts:
    258
    Hey, I'm having some trouble on android using 1.5f2. After successfully using NatCam, and then later calling NatCam.Release(), the next time I go to use NatCam, the preview does not work

    I believe I have the same issue as a few users above
     
  27. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    3,971
    You can delete the extended and professional specs if you wish to. You must first open NatCam>Core>Editor>NatCamLinker.cs and disable these flags:
    Code (CSharp):
    1. private const bool
    2. EnableExtendedSpec = true,
    3. EnableProfessionalSpec = true;
    Open Unity and make sure it compiles successfully. Then you can safely delete the Extended and Professional directories inside NatCam.
     
  28. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    3,971
    Email me and I'll send you the fix.
     
  29. ahn2150

    ahn2150

    Joined:
    Nov 5, 2010
    Posts:
    12
    Hi Lanre,

    I bought your Nat Cam Core.

    I need a preview of the highest resolution. But, maxium resolution is 1920x1080(FHD) on my iPAD Air 2, Does it support 2048x1536 resolution?
    (another plugin support 2048x1536 resolution my iPad Air 2)
     
  30. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    3,971
    Yes it does, but it depends on the preview resolution of the camera. What are you setting your preview resolution to? Try HD and let me know if it works.
     
  31. ahn2150

    ahn2150

    Joined:
    Nov 5, 2010
    Posts:
    12
    Thank you for quickly reply.

    Yes, I tried first NatCam.Camera.SetPreviewResolution(Hightest Resolution); // Output 1920x1080
    Next, tried, NatCam.Camera.SetPreviewResolution(2048, 1536); // Yet, Output 1920x1080

    Ps. SetPreviewResolution(HD) // is output, 1280x720
     
  32. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    3,971
    Sorry, I misread your question. I initially thought you were asking about setting the photo resolution. The preview resolution was intentionally capped to 1920x1080 because a preview resolution that is higher brings a higher processing cost at no visual benefit (users won't be able to see a difference). The reason why iOS allows such high resolutions is not because they are intended for the preview, but because iOS doesn't keep a separate resolution bank for the photo resolutions (taking a high res picture on iOS will simply switch the camera to that high resolution, take a 'screenshot', and revert the resolution).

    TL;DR: To allow setting that preview resolution, open NatCam>Core>Plugins>Managed>NatCamDevice.cs and go to the SetPreviewResolution(ResolutionPreset) overload. Then comment out this line:
    Code (CSharp):
    1. preset = preset == ResolutionPreset.HighestResolution ? ResolutionPreset.FullHD : preset;
    This should work. A foolproof way of setting the highest resolution is doing this:
    Code (CSharp):
    1. DeviceCamera.SetPreviewResolution(9999, 9999);
    This is what ResolutionPreset.HighestResolution does.

    If it still doesn't work, send me an email and I'll look into the issue with you.
     
  33. ahn2150

    ahn2150

    Joined:
    Nov 5, 2010
    Posts:
    12


    Thank you so much.

    It was solved thanks to your support. Happy a new year. :D
     
    Lanre likes this.
  34. blamejane

    blamejane

    Joined:
    Jul 8, 2013
    Posts:
    233
    How do we avoid having users see the Allow Microphone permission on iOS device?
     
    Last edited: Jan 2, 2017
  35. Dotby

    Dotby

    Joined:
    Nov 12, 2013
    Posts:
    32
    Try set [Development build] to OFF
    and then Build & Run your app


    Lanre: Also, check that multithreaded rendering is on.
     
    Last edited: Jan 3, 2017
    Lanre likes this.
  36. Kirk0316

    Kirk0316

    Joined:
    Jul 19, 2015
    Posts:
    2
    Hi Lanre!
    I just got NatCam a few days ago1.5f2. And it works great. Thank you!

    But, since I wish to build a AR game, my issue is:
    when I run the "GreyCam" Scene on my phone(HD Resolution on Galaxy S7), the FPS is really low: maybe 3~5FPS compared to the smooth performance of "Minigram". So:
    1) I think this is caused by the traversal function “ConvertToGrey”. Is this mean that realtime image processing is unrealizable with NatCam? Or is there any advice?
    2) I also have the OpenCVForUnity, but I haven't tried it with NatCam. So if I use NatCam.PreviewMatrix with opencv, will this help and get a high FPS? Have you ever tried it and what is the performance?

    Thank you very much!
    Looking forward to your reply~
     
  37. Carpet_Head

    Carpet_Head

    Joined:
    Nov 27, 2014
    Posts:
    258
    is there any way we can control the orientation of video recordings?
     
  38. inCreactive

    inCreactive

    Joined:
    Dec 21, 2016
    Posts:
    9
    Hello again Lanre,

    We were wondering if you had an APK, or a link to an app on the App Store, demoing the video recording features of NatCam. We would like to test performance before buying.

    Thank you for your time and we hope you have a great new year.
     
  39. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    3,971
    Open NatCam>Professional>Plugins>Managed>Platforms>iOS>NatCamiOS.cs and disable this flag:
    Code (CSharp):
    1. private static readonly bool RecordAudio = true;
     
  40. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    3,971
    The video actually isn't oriented in fact; it is simply gotten from the camera preview. Thus, it is locked to the preview orientation.
     
  41. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    3,971
    Also, check that multithreaded rendering is on. We are working to make an actual fix, not a workaround, so stay tuned. Thank you Dotby!
     
    Dotby likes this.
  42. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    3,971
    GreyCam is only a naive example showcasing working with NatCam's preview data pipeline. Ideally, the processing should be done in a native C layer, and processor instruction sets should be used (like ARM NEON). Also, running a high resolution preview will cause it to be very slow (as a lot of data needs to be processed).
    It depends on what you do. Mobile devices are not the most performant processors out there, so you must squeeze out as much performance as possible. NatCam helps with performance as much as it can: it provides the preview data with very low latency (much unlike WebCamTexture). You can see this in the Minigram example where the preview is liquid smooth, and the preview data is readily accessible. You must optimize your processing to make it as close to realtime as possible. Here are some tips I always suggest for things like this:
    - Native processing. Native C or C++ programming for operations like this is much more efficient mainly because of deterministic memory control. In the CLR, the GC spontaneously halts all threads to perform a cleanup which reduces performance. I believe the bulk of OpenCVForUnity functions are implemented natively.
    - Use GPU acceleration wherever possible. For the GreyCam example, the best way to implement it is to use a GPU shader. But the example's intention was simply to showcase preview data access and processing.
    - Use processor instruction sets. The Accelerate framework on iOS uses NEON to perform convolutions on images in literally no time. On Android, you could also explore RenderScript.
     
  43. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    3,971
    Here's the ReplayCam example APK.
     
  44. inCreactive

    inCreactive

    Joined:
    Dec 21, 2016
    Posts:
    9
    Thanks for replying so fast Lanre,

    We tested the ReplayCam APK with 6 different Android devices and it's working pretty well on most of them, it's definitely reassuring. Funny enough, on a Galaxy S7 Edge is lagging considerably but we already saw your reply up there about the preview resolution not having to be so high, it makes sense.

    We'll be buying pretty soon, thanks!
     
  45. Kirk0316

    Kirk0316

    Joined:
    Jul 19, 2015
    Posts:
    2
    Thank you Lanre! I'll have a try~
     
  46. puzzlekings

    puzzlekings

    Joined:
    Sep 6, 2012
    Posts:
    404
    @Lanre I am trying to upgrade our app from 1.3 to 1.5 and am seeing some problems when taking a photo - testing on an iPhone 6.

    After upgrading our app, the video preview only seems to be in the correct orientation when the device is in Landscape Right orientation (home button to the right), if it is Landscape Left orientation the video preview seems to be rotated by 180 showing it to be upside down. Either way after taking a photo, the photo image seems to be a vertical flip of what was shown in the video preview i.e. upside down.

    I found it difficult to work out what was going on so I built the sample app Minigram in a new project on Unity 5.4.1 with autorotation allowing for Landscape Left & Right and the video preview showed exactly the same issues as above. The only thing I noticed was that after taking a photo the image was rotated by 90 degrees as shown in the two photos below.

    I noted in the release notes: "+ Dropped captured photo correction for app orientation. Now all captured photos are in landscape left orientation." which might explain the incorrect photo orientation, but not sure why the video preview does not now follow the device orientation.

    I've been through the docs but there does not seem to be any advice on how best to upgrade, so if you have any suggestions these would be much appreciated, as would any ideas about the issues I am seeing.

    thanks

    Nalin

    VideoPreview.PNG CameraSnapshot.PNG
     
    Moonlit-Games-Studio likes this.
  47. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    3,971
    Thank you. Regarding the S7 Edge, we will be looking for ways to optimize its speed.
     
  48. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    3,971
    Hi Nalin. It sounds like your app uses autorotation. If so, NatCam currently doesn't support autorotation; this is why the preview becomes stretched. We are working to add this functionality in 1.5f3.
     
  49. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    3,971
    Hi guys. I thought I'd write an update on the current state of the API's:

    1.5f3:
    This release of the API specs will include a lot of bug fixes, a revamp to the metadata detection pipeline, and more. Below is the intended changelog that we wish to bring in each spec:

    Core 1.5f3:
    + Made preview rendering faster on Android.
    + Made NatCam.CapturePhoto provide information about the photo orientation.
    + Added support for autorotation.
    + Added NatCamScaler component for scaling the preview to avoid stretching.
    + Added NatCamZoomer component for zooming the preview with input gestures.
    + Added NatCamFocuser component for focusing the camera at touch points.
    + Added NatCamPhotoView component for displaying orienting captured photos using a GPU shader.
    + Added NatCamView2D shader for GPU-accelerated image transformation.
    + Added Utilities.RotateImage(...) for rotating an image in system memory.
    + Added Orientation enum from Extended.SaveOrientation and added mirroring.
    + Fixed flickering bug on Android when running without multithreaded rendering.
    + Fixed bug on Android where calling Play() after Release() or pausing and suspending the app does not work.
    + Fixed crash when NatCam.Release() is called on Android.
    + Fixed FocusMode.MacroFocus not working on Android.
    + Fixed DeviceCamera.FocusMode getter causing an error.
    + Fixed bug where DeviceCamera.SetFocus(..) ignored focus mode completely.
    + Fixed bug where OnPreviewStart is not called when preview is resumed on Android.
    + Fixed resource leak when NatCam.Release() is called after NatCam.Pause() on NatCamLegacy.
    + Fixed IL2CPP support on Android.
    + Deprecated NatCamTransformation2D shader. Use NatCamView2D instead.
    + Refactored INatCamDispatch to IDispatch.
    + Refactored NatCamUtilities to Utilities.
    + Implemented IDisposable interface for IDispatch.

    Extended 1.5f3:
    + Text detection.
    + Face landmarks.

    + Greatly improved metadata detection speed on Android.
    + Enhanced support for using libraries that depend on Google Play Services by avoiding clashes.
    + Added IMetadata interface with rect and timestamp fields.
    + Added NatCam.OnMetadataDetect.
    + Added overloads for equality, Equals() and GetHashCode() operations to Face struct.
    + Added face detection example.
    + Deprecated NatCamPreview component. Use NatCamU.Core.UI classes instead.
    + Deprecated NatCam.OnBarcodeDetect and NatCam.OnFaceDetect.
    + Deprecated BarcodeCallback struct.
    + Fixed regression where metadata was not detected after the preview was resumed.
    + Fixed crash when switching cameras while NatCam detects metadata on Android.

    Professional 1.5f3:
    + Added NatCam.PreviewMatrix(..) to greatly improve memory efficiency (so as not to allocate each time it is called).
    + Added NatCam.PreviewFrame(..) to greatly improve memory efficiency (so as not to allocate each time it is called).
    + Added NatCamCV example to demonstrate using NatCam with OpenCVForUnity.
    + Deprecated NatCam.PreviewMatrix property.
    + Deprecated NatCam.PreviewFrame property.
    + Fixed NatCam.PreviewMatrix having incorrect dimensions.

    I'm personally most excited about the new IMetadata interface, the Orientation enum (making orienting captured photos much much easier for everyone), and text detection. I'll post when the betas are ready, so make sure you're monitoring this thread.
     
    Dotby likes this.
  50. puzzlekings

    puzzlekings

    Joined:
    Sep 6, 2012
    Posts:
    404
    Thanks @Lanre - yes we use auto rotation to support Landscape Left and Right, not portrait.

    It's great that this will be in 1.5f3, and I *hope* this means that the video preview shows in the correct rotation.

    However I am not sure it explains the bug in the Minigram app, or the vertical flip of the photo taken by the camera. Will these issues also be fixed in 1.5f3?

    Finally do you have an ETA on 1.5f3 at all.

    cheers

    Nalin