Search Unity

  1. Unity 2019.2 is now released.
    Dismiss Notice

Uvc driver help for external camera with vuforia/unity

Discussion in 'Vuforia' started by frizzle101101, May 19, 2019.

  1. frizzle101101

    frizzle101101

    Joined:
    May 19, 2019
    Posts:
    8
    I have been able to get the uvc driver sample to build ask per https://library.vuforia.com/content/vuforia-library/en/articles/Solution/uvc-camera-driver.html

    The issues im having are i cant figure out how to use the library properly and test if it is working. I have a simple uvc device i want to connect to my phone making an ar app using unity external camera functinality. Ive tested this device with several platforms including android and windows and simple uvc apps work fine on those platforms.
     
    nmasotti likes this.
  2. meedabit

    meedabit

    Official Vuforia Employee Vuforia

    Joined:
    Dec 8, 2016
    Posts:
    253
    Hello,

    Per our documentation: https://library.vuforia.com/content/vuforia-library/en/articles/Solution/driver-framework.html

    "The Vuforia Engine Driver must be written in C/C++ and must be implemented as a standalone dynamic library (dll or so file) which Vuforia Engine will load at runtime."

    To clarify, the External Camera works in Unity. It’s the actual driver library implementation that needs to be in C/C++, with the library that is included in the Unity project just like the Engine SDK. The Unity project then specifies using the same style call as used in native in C# giving the name of the driver library.

    HTH.

    Thanks,
    Vuforia Engine Support
     
  3. frizzle101101

    frizzle101101

    Joined:
    May 19, 2019
    Posts:
    8
    Ok ru available on discord?
     
  4. frizzle101101

    frizzle101101

    Joined:
    May 19, 2019
    Posts:
    8
    Im not sure it setup properly end to end. Firstly i just made a script to initilize the vuforia engine after the driver Library change which i used from the uvc sample project driver and this allowed the camera on my device to stop being called so now its just black but with the uvc device im not seeing an image so i imagine there is more to this to change the ar camera video to use that driver properly
     
  5. meedabit

    meedabit

    Official Vuforia Employee Vuforia

    Joined:
    Dec 8, 2016
    Posts:
    253
    Hello,

    If you provide a sample project we can take a look.

    Thanks,
    Vuforia Engine Support
     
  6. frizzle101101

    frizzle101101

    Joined:
    May 19, 2019
    Posts:
    8
    Last edited: May 23, 2019
  7. meedabit

    meedabit

    Official Vuforia Employee Vuforia

    Joined:
    Dec 8, 2016
    Posts:
    253
    Hello,

    OK thanks. Hopefully the team will be able to take a look in the coming week or so.

    Thanks,
    Vuforia Engine Support
     
  8. frizzle101101

    frizzle101101

    Joined:
    May 19, 2019
    Posts:
    8
    SO ive been doing some investigation into the project and I made a few tweaks to the build graddle to include what is instructed and it seems to be building the app with the library files. i go /data/com.testing.appname/libs/ and i can see the 4 lib uvc driver files, so that confirms they are in the project. Now i cant seem to get delayed initialization to work with the driver, using ;
    VuforiaUnity.SetDriverLibrary("libUVCDriver.so");
    VuforiaRuntime.Instance.InitVuforia();
    It just says after the app opens that Vuforia initialization failed which doesnt happen with setting the default driver with "";
    VuforiaUnity.SetDriverLibrary("");
    VuforiaRuntime.Instance.InitVuforia();
    This works with delayed initialization and the onboard camera can be seen as a result just like the default

    So could you help explain why the vuforia engine on android doesn't work with the uvc driver sample project?
     
  9. frizzle101101

    frizzle101101

    Joined:
    May 19, 2019
    Posts:
    8
    Ive just gotten vuforia to initialize by adding an app key, i forgot you need a key for external camera use. Anyways after all it is still just showing black, the driver is loaded and vuforia initialized, here is the newest project files:
    https://www.dropbox.com/sh/w2f0jlax1mtoy5m/AADFbKGf1_v_IQYBr3CNSdWla?dl=0

    ive even added a dummy calibration and its still not showing the uvc cameras video...can you please help? If you need the built sample uvcdriver project as well let me know.
     
  10. frizzle101101

    frizzle101101

    Joined:
    May 19, 2019
    Posts:
    8
    I just figured it out using adb; that the driver is not getting permission to access the usb device. skimming through the java code looks like ther requestUSBPermission function isnt being called anywhere. Might you help point me in the right direction now you have more info
     
  11. frizzle101101

    frizzle101101

    Joined:
    May 19, 2019
    Posts:
    8
    Just got the big ah ha thats why its not working...So the driver works :) gj on you guys for making that with good error messages...but it seems my device is reporting 0 camera modes supported because it has no UVC_VS_FORMAT_UNCOMPRESSED or in other words its using MJPG only, and it seems from the code only Uncompressed is supported as per the continue statement at line 988 or so of the UVCExternalCamera.cpp file. My device shows no UVC_VS_FORMAT_UNCOMPRESSED descriptors so is there any way to make it work with the MJPG format.
     
    meedabit likes this.
  12. meedabit

    meedabit

    Official Vuforia Employee Vuforia

    Joined:
    Dec 8, 2016
    Posts:
    253
    Hello,

    This feature is a bit different from our more mainstream ones in that it will be up to developers to bridge these types of issues with internal implementations.

    That being said, we think that if you use a lower resolution you may get a format that works. We recall that 640x480 should work, but 720p needs enough USB bandwidth to force it to use a compressed format.

    HTH.

    Thanks,
    Vuforia Engine Support
     
  13. unity_Fk_eCPcF-GkGXA

    unity_Fk_eCPcF-GkGXA

    Joined:
    Jul 4, 2019
    Posts:
    2
    Hi, I have the same problem. Then did you manage to solve it? I'm trying to capture video from an external webcam connected to my smartphone via USB cable. Initially the error INIT VUFORIA DRIVER FAILED came out on screen, then I selected the delayed initialization box, and in this way I get a completely black screen.

    I also wrote a post on the Vuforia portal, at the link https://developer.vuforia.com/forum/unity/uvc-camera-driver-explanation, also listing some doubts about how I performed the procedure, but still have to answer me.
     
    nmasotti likes this.
  14. nmasotti

    nmasotti

    Joined:
    Jun 17, 2019
    Posts:
    1
    Hello,

    after successfully building the custom UVCCamera driver and including the driver in a demo Unity project (Vuforia Core Samples project, available on the Asset Store), I am also stuck on a black screen.

    Tested different UVC cameras with dummy calibration profiles, but none is working.

    All of my calibration profiles specify a 640x480 resolution for the external cameras, therefore I don't really get how this failure could be related to automatic compression due to high resolution.

    Could you please clarify your point?

    Thank you