Search Unity

  1. Engage, network and learn at Unite Austin 2017, Oct 3 - 5. Get your ticket today!
    Dismiss Notice
  2. Introducing the Unity Essentials Packs! Find out more.
    Dismiss Notice
  3. Check out all the fixes for 5.6 on the patch releases page.
    Dismiss Notice
  4. Unity 2017.1 is now released.
    Dismiss Notice
  5. Unity 2017.2 beta is now available for download.
    Dismiss Notice

NatCam - WebCam 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. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    835
    This is a bug in the Galaxy S7 graphics driver. The workaround is to disable NatCam's preview data pipeline by putting off the ReadablePreview flag in NatCamAndroid.cs (within the Professional directory).
    We do not support PlayMaker at this time. The API is simple to use. See the many examples and the documentation.
    I will be working to make written tutorials on Medium.
     
  2. Fabien-LG

    Fabien-LG

    Joined:
    Mar 9, 2013
    Posts:
    11
    Hello,

    First of all, thanks for this awesome asset. Working perfectly.
    We have an issue on S7 / Android 7.0 : is seems the app is not asking for permissions at application launch. Is this a known issue ? It works very well on other devices running Android 6.

    Thanks!
     
    Lanre likes this.
  3. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    835
    I am not familiar with this issue. Unity usually asks for all permissions in the manifest on first app launch. See this page.
     
  4. simo90ita

    simo90ita

    Joined:
    May 8, 2017
    Posts:
    3
    Hi everyone, I use Natcam for about a month, I noticed that the focus tap does not work, I read that there was a problem on this, do you know if it was solved and am I mistaken?
     
  5. Fabien-LG

    Fabien-LG

    Joined:
    Mar 9, 2013
    Posts:
    11
    Thanks a lot for your reply. I have more information about the crash, here is what we see in the log file:

    05-14 22:49:07.811: A/DEBUG(17646): *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
    05-14 22:49:07.812: A/DEBUG(17646): Build fingerprint: 'samsung/heroltexx/herolte:7.0/NRD90M/G930FXXU1DQC4:user/release-keys'
    05-14 22:49:07.812: A/DEBUG(17646): Revision: '8'
    05-14 22:49:07.812: A/DEBUG(17646): ABI: 'arm'
    05-14 22:49:07.812: A/DEBUG(17646): pid: 17181, tid: 17273, name: Thread-52 >>> com.theuxagency.lorealsalonemotion <<<
    05-14 22:49:07.812: A/DEBUG(17646): signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x40
    05-14 22:49:07.812: A/DEBUG(17646): r0 00000000 r1 c297e054 r2 000002d0 r3 00000001
    05-14 22:49:07.813: A/DEBUG(17646): r4 00000303 r5 000002d0 r6 00000500 r7 00000500
    05-14 22:49:07.813: A/DEBUG(17646): r8 00000303 r9 bd658844 sl 00000001 fp 00000000
    05-14 22:49:07.813: A/DEBUG(17646): ip c297e010 sp c297e040 lr ea70ff57 pc beca8ec0 cpsr 200f0030
    05-14 22:49:07.816: A/DEBUG(17646): backtrace:
    05-14 22:49:07.817: A/DEBUG(17646): #00 pc 00006ec0 /system/lib/libui.so (_ZN7android22GraphicBufferAllocator5allocEjjijPPK13native_handlePj+83)
    05-14 22:49:07.817: A/DEBUG(17646): #01 pc 0000606f /system/lib/libui.so (_ZN7android13GraphicBuffer8initSizeEjjij+54)
    05-14 22:49:07.817: A/DEBUG(17646): #02 pc 00006017 /system/lib/libui.so (_ZN7android13GraphicBufferC2Ejjij+158)
    05-14 22:49:07.817: A/DEBUG(17646): #03 pc 0000566c /data/app/com.XXXX-1/lib/arm/libNatCamFastRead.so (_ZN19NatCamFastReadGLES210InitializeEv+56)
    05-14 22:49:07.817: A/DEBUG(17646): #04 pc 00005808 /data/app/com.XXXX-1/lib/arm/libNatCamFastRead.so (_ZN19NatCamFastReadGLES2C2Eiii+48)
    05-14 22:49:07.817: A/DEBUG(17646): #05 pc 0000622c /data/app/com.XXXX-1/lib/arm/libNatCamFastRead.so (Java_com_yusufolokoba_natcam_NatCamRenderer_GenerateFastReadContext+48)
    05-14 22:49:07.817: A/DEBUG(17646): #06 pc 00022f83 /data/app/com.XXXX-1/oat/arm/base.odex (offset 0x20000)

    Maybe it helps?
    Thanks!
     
  6. eagleeyez

    eagleeyez

    Joined:
    Mar 21, 2013
    Posts:
    274
    Wow, and that on Sunday! That did the trick, would be a nice If I had not had have to been ripping my hair out for that simple solution, but a dedicated forum would help if there was one..

    Where do I find the zooming methods? I could then grab hold of these with Playmaker get and set properties. In which scripts is that?

    Thanks for your help
    just changing that one bool did the trick.
     
  7. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    835
    Can you be more specific with how you are trying to focus? You must make sure that the FocusMode.TapToFocus bit is set on the camera (DeviceCamera.FocusMode). Also, see the documentation for the NatCamFocuser component.
     
  8. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    835
    Make sure that you are not using OpenGL ES2 on a device that supports ES3+. In Player Settings, make sure that Automatic Graphics API is enabled.
     
    Fabien-LG likes this.
  9. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    835
    Code (CSharp):
    1. DeviceCamera.ZoomRatio
     
  10. Fabien-LG

    Fabien-LG

    Joined:
    Mar 9, 2013
    Posts:
    11
    Thanks a lot for your fast reply. It solved the issue!
     
  11. haha2014

    haha2014

    Joined:
    Feb 19, 2013
    Posts:
    3
    Hi, I updated unity to 5.5.0f3 then get this error. The same code in 5.4.2 works fine. Also tried to open with unity 5.6.1. Still no camera found. Can anyone help?

    NatCam Error: NatCam Behaviour: Active camera is null. Consider changing the facing of the camera
    UnityEngine.Debug:LogWarning(Object)
    NatCamU.Core.Utilities.NatCamUtilities:LogError(String) (at Assets/NatCam/Core/Plugins/Managed/Utilities/NatCamUtilities.cs:33)
    NatCamU.Core.NatCamBehaviour:Start() (at Assets/NatCam/Core/Scripts/NatCamBehaviour.cs:37)
    NatCamU.Examples.Minigram:Start() (at Assets/NatCam/Core/Examples/Minigram/Minigram.cs:30)
     
  12. eagleeyez

    eagleeyez

    Joined:
    Mar 21, 2013
    Posts:
    274
    Thanks, but when i seach in the Unity project windown for
    DeviceCamera.ZoomRatio I just get HTML files. How do I get this to show as a script?
    Sorry I am not very good at this but will start learning now c# Properly.

    Your videos do not help as when I type what you type I get nothing. I type, using NatCamU; and then NatCam.Initialize it dose not exist.

    A small example in text on how to get the camera going, after 10 seconds iit will zoom in and then after another 10 seconds later zoom out again would help me to understand how to grab hold of things.

    In playmaker I can usee get and set property. I just have to place the c# into the field and I can then grab hold of any properties but yours are just html files and playmaker wants c# scripts.

    please help
    Thanks you
     
  13. GalaTyler

    GalaTyler

    Joined:
    May 2, 2017
    Posts:
    3
    Edit: I ran the minicam scene on the iPad and it appears to work, so it's almost certainly something on my end. I'll look into it. If you have any thoughts though, I'd appreciate them regardless!

    Hi there! We're using Natcam for a project and need to capture a screenshot from the camera, but cannot seem to get that working. Can you see if we're doing anything wrong? We're getting a null reference error in Xcode, and I don't think it's anything to do with our code. We are successfully seeing the camera feed before attempting to take the screenshot.

    Unity: 5.5.2p3
    Natcam: Pro 1.5f3
    Device: iPad Pro 12in (iOS 10.3.1)

    Code (CSharp):
    1. void CaptureScreenshotLocal(Action<Texture2D> callback){
    2.         screenshotCallback = callback;
    3.         NatCam.CapturePhoto(FinishedCapturingPhoto);
    4.     }
    5.  
    6.     void FinishedCapturingPhoto(Texture2D textureData, Orientation orientation){
    7.         // Execute orientation changes here later
    8.  
    9.         screenshotCallback(textureData);
    10.     }
    NullReferenceException: A null value was found where an object instance was required.

    at NatCamU.Core.PhotoCallback..ctor (System.Object object, IntPtr method) [0x00000] in <filename unknown>:0

    at UnityEngine.Events.InvokableCallList.Invoke (System.Object[] parameters) [0x00000] in <filename unknown>:0

    at UnityEngine.EventSystems.ExecuteEvents.Execute[T] (UnityEngine.GameObject target, UnityEngine.EventSystems.BaseEventData eventData, UnityEngine.EventSystems.EventFunction`1 functor) [0x00000] in <filename unknown>:0

    at UnityEngine.EventSystems.StandaloneInputModule.ProcessTouchPress (UnityEngine.EventSystems.PointerEventData pointerEvent, Boolean pressed, Boolean released) [0x00000] in <filename unknown>:0

    at UnityEngine.EventSystems.StandaloneInputModule.ProcessTouchEvents () [0x00000] in <filename unknown>:0

    at UnityEngine.EventSystems.StandaloneInputModule.Process () [0x00000] in <filename unknown>:0

    UnityEngine.EventSystems.ExecuteEvents:Execute(GameObject, BaseEventData, EventFunction`1)

    UnityEngine.EventSystems.StandaloneInputModule:processTouchPress(PointerEventData, Boolean, Boolean)

    UnityEngine.EventSystems.StandaloneInputModule:processTouchEvents()

    UnityEngine.EventSystems.StandaloneInputModule:process()



    (Filename: currently not available on il2cpp Line: -1)
     
    Last edited: May 15, 2017
  14. eagleeyez

    eagleeyez

    Joined:
    Mar 21, 2013
    Posts:
    274
    Hi all,

    Could someone please show me how I could just do something very simple, so that I can understand how to use simple functions like Zoom.


    I want to have a live camera preview and then after 10 seconds zoom in and then after 10 seconds zoom out again.

    How difficult must this be? So much code and still not easy for me, It must be easy when you know how. #And using playmaker with scripts get and set I never had so much difficulty in finding a script where I can just get or set properties, here is everything all over the place with no access as when I drop DeviceCamera on a object is will not let me, so how do I access the zoom in and zoom out?

    Please help!

    Is it that hard to just say, zoom in or zoom out?
    An example would help as I find nothing about NatCam other than video that are old.
     
  15. Gustavo-Quiroz

    Gustavo-Quiroz

    Joined:
    Jul 26, 2013
    Posts:
    32
    To all who are looking for samples of how to test some of the features of NatCam there is this repo with test cases of each of the features: https://github.com/olokobayusuf/NatCam-Test-Suite

    Take a look into this script: https://github.com/olokobayusuf/NatCam-Test-Suite/blob/1.5/Assets/Tests/ZoomCam.cs
     
    Lanre likes this.
  16. eagleeyez

    eagleeyez

    Joined:
    Mar 21, 2013
    Posts:
    274

    Thanks but where does it find public class ZoomCam : NatCamTest


    NatCamTest, what is this?
    I made a script called ZoomCam with your code and put this into Natcam/Tests, but it underlines NatCamTest.

    I have just bought 3 tutorials on c# from udemy and maybe I will now learn c#. the Guy is called
    Mosh Hamedani

    I just want to have a live view, zoom in and zoom out, I will then put this to the gearVR

    Thanks all for any help and maybe someday I can also help
     
  17. Gustavo-Quiroz

    Gustavo-Quiroz

    Joined:
    Jul 26, 2013
    Posts:
    32
    NatCamTest is a base class, it's part of the whole repository, I suggest to download the whole repository in order to test it with NatCam Pro so it's gonna be easier to play around with all features.

    NatCam Test Suit is a repository made by @Lanre
     
    Lanre likes this.
  18. eagleeyez

    eagleeyez

    Joined:
    Mar 21, 2013
    Posts:
    274
    OK, thanks. I will go through it later on today. Which is already morning here.
     
    Last edited: May 16, 2017
  19. eagleeyez

    eagleeyez

    Joined:
    Mar 21, 2013
    Posts:
    274
    THANK YOU, THANK YOU AND THANK YOU. It is all working now.
     
    Last edited: May 16, 2017
    Lanre likes this.
  20. haha2014

    haha2014

    Joined:
    Feb 19, 2013
    Posts:
    3
    Hi, NatCam Extended cannot detect the camera of macbook pro 2011 for unity version 5.x.x.
    Anyone else experiencing this problem too?
     
  21. elpuerco63

    elpuerco63

    Joined:
    Jun 26, 2014
    Posts:
    223
    Hi Lanre, I see in the MiniCam example when the device is rotated portrait or landscape the camera preview maintains the correct aspect ratio.

    However in my project even though I have replicated the anchor positions etc of the MiniCam example I get the correct aspect ratio in portrait but when I rotate to landscape the aspect ratio is wrong and so the preview appears stretched?

    My canvas UI elements, buttons etc all rotate and appear correct, just the camera preview is wrong?
     
  22. james14123

    james14123

    Joined:
    Jan 22, 2017
    Posts:
    20
    Hello, i want to use the SavePhoto function to get the path of the photo.
    The script is as below.
    NatCam.SavePhoto (photo, NatCamU.Extended.SaveMode.SaveToAppDocument Orientation.Rotation_90, ???? );

    I have no idea what the ???? part needs, and i saw that the input of savecallback are (mode, path).
    So the next step i tried is " NatCamU.Extended.SaveCallBack callback = new NatCamU.Extended.SaveCallBack callback (NatCamU.Extended.SaveMode.SaveToAppDocument, "filepath") ", and put callback to ???? part.

    But it didn't work , can you give me some tips? Thanks !
     
    Last edited: May 18, 2017
  23. simo90ita

    simo90ita

    Joined:
    May 8, 2017
    Posts:
    3
    Hi, thank you for your answer! now i'm using the exemple project MiniCam, and i'm using his own focuser with selected tap to focus. when i start the apk on the smartphone at the beginning and each time i switch the camera, the Logcut gives me this error:

    " NatCam Error: Failed to set camera 0 focus mode to 1"

    thank you for your help
     
  24. elpuerco63

    elpuerco63

    Joined:
    Jun 26, 2014
    Posts:
    223
    I have found that if I start my app in portrait the NatCamPreview is correct, but when I rotate to landscape the NatCamPreview is distorted/stretched. If I snap a photo however it then appears correct.

    Likewise if I start the app in landscape NatCamPreview appears correct but rotating to portrait NatCamPreview is distorted/stretched. If I snap a photo it then appears correct.

    ?
     
  25. MorphVGX

    MorphVGX

    Joined:
    Jun 21, 2010
    Posts:
    56
    After the last plugin update, NatCamU.Core.NatCam.PreviewFrame (ref _texture) is always returning null. What happened? Also, I was able to test things in the editor but not anymore. I get "NatCam Error: Active camera is null. Consider changing the facing of the camera". but that does not work. Thanks.
     
    Last edited: May 19, 2017
    haha2014 likes this.
  26. elpuerco63

    elpuerco63

    Joined:
    Jun 26, 2014
    Posts:
    223
    I get this too, but being to new to NatCam was concentrating on mobile deploy, so ignored this error....
     
  27. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    835
    What device/platform does this occur on?
     
  28. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    835
    It isn't a script. It is a property of the DeviceCamera class.
    The videos are for an older version of NatCam. We want to move to written tutorials.
     
  29. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    835
    Changing the scripting backend to Mono2x is helpful for finding the cause of exceptions. The Mono backend will usually tell you where exactly the exception is raised from.
     
  30. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    835
    You might need to change the facing of the camera. On my MacBook, I have to change the facing to Front.
     
  31. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    835
    When the orientation is changed, you need to re-scale your UI panel. MiniCam calls NatCamPreview.Apply when this happens (in the OnStart method).
     
  32. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    835
    See the documentation for the NatCam.SavePhoto function. The last parameter is a callback function to be invoked when the photo has been saved. Read into callbacks in C#.
     
  33. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    835
    This means that the camera does not support the TapToFocus focus mode. Try this instead:
    Code (CSharp):
    1. camera.FocusMode = FocusMode.TapToFocus | FocusMode.AutoFocus;
     
  34. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    835
    Do you call NatCamPreview.Apply when the orientation is changed? You must call this when the preview size is changed for any reason (like orientation changes or camera switches).
     
  35. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    835
    What device/platform does this occur on? Can you email me verbose logs?
    I would presume that this is occurring when you deploy to an iOS device. If so, open Player Settings and go to Scripting Define Symbols. Clear the string that is there and then force recompilation of your scripts.
     
  36. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    835
    Hi guys. We are taking yet another look into the lag on the Galaxy S7/S7 Edge with NatCam Professional. If you use NatCam Professional, use an S7/S7 Edge, and have experienced this lag, please email me. I would like to test out an APK that will tell if our new lead will in fact fix the issue.
     
  37. elpuerco63

    elpuerco63

    Joined:
    Jun 26, 2014
    Posts:
    223
    Hi, but MiniCam does not do so and works OK?

    However I have made another discover!

    Recall you said to me that I must include OnStart and leave it empty to prevent the base Start running? This is so I can control when NatCam starts. I have a scene that has various controls and one is to start NatCam to take a photo so for me I dod not want the NatCamPreview running until the user requires it.

    So this is run when the user taps to want to take a photo:

    Code (csharp):
    1.  
    2. public void StartNatCam () {
    3.    
    4.         // only run this block once, very first time user taps for camera
    5.         if (!NatCam.IsPlaying) {
    6.    
    7.             // start base
    8.             base.Start ();
    9.  
    10.             // set the flash icon
    11.             SetFlashButtonImage ();
    12.         }
    13.  
    14.         this.photo.Apply (NatCam.Preview);
    15.  
    16.         Texture2D.Destroy(image);
    17. }
    18.  
    and this is what is run when the user wants to snap a photo which is what you advised:

    Code (csharp):
    1.  
    2. public void CapturePhoto () {
    3.  
    4.         // only if NatCam is not playing
    5.         if (!NatCam.IsPlaying) {
    6.  
    7.             // add our delegate
    8.             NatCam.OnStart += OnStart;
    9.  
    10.             // start it playing again
    11.             NatCam.Play ();
    12.         }
    13.         else {
    14.  
    15.             // snap the photo
    16.             NatCam.CapturePhoto (OnPhoto);  
    17.         }
    18.     }
    19.  
    20.     //
    21.     // delegate set in CapturePhoto ()
    22.     //
    23.     public void OnStart () {
    24.        
    25.         // snap the photo
    26.         NatCam.CapturePhoto (OnPhoto);  
    27.  
    28.         NatCam.OnStart -= OnStart;
    29.     }
    30.  
    But I have found IF I include in my override Start function the call to base.Start() then the weird rotation issue is gone.

    So I dont think this is anything to do with calling NatCamPreview.Apply because like I said your MiniCam example does not do this.

    It looks to me that if base.Start() is not called when the app first starts the issue arises.

    So I am back to square one in how do you in code control when NatCam should start?

    I'm not complaining Lanre, NatCam is great tool I just am having little hiccups that am sure can be resolved with your assistance :)
     
    Last edited: May 19, 2017
  38. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    835
    Do not call NatCamPreview.Apply in your StartNatCam function. NatCam.Preview is null until the OnStart event is invoked. You must call NatCamPreview.Apply in your OnStart delegate.
    I asked that you override Start, not OnStart.
    In your OnStart method, do not unsubscribe the delegate. The delegate will be called in the future if the camera is switched or if the orientation changes (this is how MiniCam handles orientation changes).
     
  39. elpuerco63

    elpuerco63

    Joined:
    Jun 26, 2014
    Posts:
    223
    Hi, you spoke to me about adding OnStart in post #1031 But yes I DID override start and made it empty as you suggested?

    I'm getting totally confused by this :-(

    So are you now saying I should have base.Start() in my override Start method which returns me to my original problem that NatCam is running then when the app starts and not when and only when the user taps to start it to view camera?

    Also recall I am pausing NatCam and the using Play() to start again as the user uses the app
     
    Last edited: May 19, 2017
  40. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    835
    Yes, in order to call NatCamPreview.Apply and perform any other operations when the preview starts running.
    You have to understand the general flow of events:
    - In Start, the user (you) calls NatCam.Play. NatCam will then initialize itself and start the camera preview. Because this process is asynchronous, you must subscribe a delegate to the OnStart event. This is the step that you want to defer till the user clicks a button as I understand it.
    - In the OnStart delegate, the user (you) does any operations they need to do once the preview has actually started. This is usually where you would display the camera preview texture (NatCam.Preview) on a UI panel, or call NatCamPreview.Apply.
    - When you want to stop the preview, the user calls either NatCam.Pause or NatCam.Release.
    - If the user would like to resume the camera preview, the user calls NatCam.Play.
     
  41. Gustavo-Quiroz

    Gustavo-Quiroz

    Joined:
    Jul 26, 2013
    Posts:
    32
    Hello Lanre after the last release I'm getting weird behaviour when I try NatCam Pro with OpenCVForUnity on some Android devices, even the VisionCam example does not work properly and no verbose logs with errors are found.

    When you try to run an OpenCVForUnity + NatCam scene (Like VisionCam) the camera is not being rendered on the screen but you can clearly see the red line crossing the screen, same behavior happens with custom scenes with OpenCV, the OpenCV part works normal, but no camera feed is being seen on the screen, I don't have a list of the devices where this happens but I'm pretty sure there are mainly on Samsung branch of phones and tablets.

    Do you have any idea of what could be happening?
     
  42. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    835
    Hi Gustavo. Can you mention at least one device where this occurs? Also what does NatCam.PreviewMatrix return (true or false)? If false, check that the ReadablePreview flag in NatCamAndroid.cs (in the Professional directory) is enabled.
     
  43. Gustavo-Quiroz

    Gustavo-Quiroz

    Joined:
    Jul 26, 2013
    Posts:
    32
    I know for sure at least one of the devices is a Samsung Galaxy Tab S2 9.7”.
    I also know that NatCam.PreviewMatrix returns true because it does draw the red line in VisionCam and it actually works fine on most Android devices. I will test the ReadablePreview flag next week.

    Here is the code that is actually 99% of the original code of this example, I just renamed the OnFrame and OnStart functions to properly work with NatCamBehaviour.

     

    Attached Files:

  44. garcia-raul

    garcia-raul

    Joined:
    Dec 8, 2014
    Posts:
    10
    Hello,
    In this plugin for iOS is there a way to specify the video file name and or path?
    Thanks in advance
     
  45. haha2014

    haha2014

    Joined:
    Feb 19, 2013
    Posts:
    3
    I added some checking here in NatCamBehaviour to fix the problem:

    // Use this for initialization
    public virtual void Start () {
    DebugManager.Log("------------> NatCam Behaviour Start(1).. facing: " + facing);
    // Set verbose mode
    NatCam.Verbose = verbose;
    // Set the active camera
    NatCam.Camera = facing == Facing.Front ? DeviceCamera.FrontCamera : DeviceCamera.RearCamera;

    //----- Check and switch available camera -----
    if(!NatCam.Camera)
    {
    if(facing == Facing.Front){
    facing = Facing.Rear;
    NatCam.Camera = DeviceCamera.RearCamera;
    }
    else if(facing == Facing.Rear)
    {
    facing = Facing.Front;
    NatCam.Camera = DeviceCamera.FrontCamera;
    }
    }

    //---------------------------------------------

    // Null checking
    if (!NatCam.Camera) {
    // Log
    DebugManager.LogError("Active camera is null. Consider changing the facing of the camera");
    Util.LogError("Active camera is null. Consider changing the facing of the camera");
    return;
    }
    // Set the camera's preview resolution
    NatCam.Camera.SetPreviewResolution(previewResolution);
    // Set the camera's photo resolution
    NatCam.Camera.SetPhotoResolution(photoResolution);
    // Set the camera's framerate
    NatCam.Camera.SetFramerate(framerate);
    // Play
    NatCam.Play();
    // Register callback for when the preview starts //Note that this is a MUST when assigning the preview texture to anything
    NatCam.OnStart += OnStart;
    // Register for preview updates
    NatCam.OnFrame += OnFrame;

    DebugManager.Log("------------> NatCam Behaviour Start(2)..");
    }
     
  46. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    835
    You are correct; the pointer is returned correctly. Can you run the BufferPreview test from the NatCam Test Suite and let me know if it shows the camera preview?
     
    Gustavo-Quiroz likes this.
  47. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    835
    No, but you can rename the video (and move it around) as you wish.
     
  48. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    835
    Looks good.
     
  49. elpuerco63

    elpuerco63

    Joined:
    Jun 26, 2014
    Posts:
    223
    HI Lanre, thanks that cleared it up my app is now working perfect with NatCam :):):)
     
    Lanre likes this.
  50. eagleeyez

    eagleeyez

    Joined:
    Mar 21, 2013
    Posts:
    274
    Hi all again. Great asset I have to say.


    Now take a look at this app SuperVision on the SideloadVR website.

    http://sideloadvr.com/detail.php?id=11312


    Now using NatCam the lag is more than Supervision app, even though the problem in the code was fixed for me for the Galaxy S7.

    #

    I am making an app like supervision, but with options I need and better control.

    Any tips on getting the NatCam to preview as fast as supervision or just faster than it does at the moment?

    Like with setting in Unity to watch out for, Lighting, shaders, graphic modes and so on to get as much performance out of the pass through camera as possible. Without sacrificing min 720p, although 1080p would be the golden dagger.

    I have already got it working with a mini Bluetooth controller and smooth in/out zooming, snap to full zoom and back, step zoom and now I will go onto photo and zoom to look at photo details. Later will come the contrast stuff and also simulations for eye condition, so that others can see what I see or rather don’t see. A movie player is also working for watching films for the partially sighted. Yes even on a big cinema we would still like to zoom in on details

    It’s hard to imagine if you see normally and know no one with an eye condition.


    I just need to ramp up the frame rate of pass through, any help or suggestion would be deeply appreciated.