Search Unity

Video WebCamTexture for Logitech C922

Discussion in 'Audio & Video' started by Nikovich, Dec 11, 2019.

  1. Nikovich

    Nikovich

    Joined:
    Jul 10, 2010
    Posts:
    69
    I'm currently creating an app that uses the feed from a C922 USB Webcam and I'm having a strange issue when applying it to a WebCamTexture. The C922 has a resolution of 1080p when recording at 30fps and 720p when recording at 60, both at an aspect ratio of 16:9. When I use the Logitech capture software, I get a 1280x720 60fps output.

    However, I've noticed the WebCamTexture looked substantially zoomed in. When I set the native size of the RawImage I'm rendering the WCT to, and when I compared the viewable area of both the native capture with the Unity WCT, that's when I noticed it was actually grabbing a 4:3 capture of the camera, cropping off the rest, and stretching it to my 720 RawImage. For some reason, it wants to create a 640x480 capture, despite the fact that I have an Aspect Ratio Fitter component on it set to 1.778 (16:9) on a 1280x720 raw image. The issue of squashing the video down also occurs when rendering on a plane.

    I've been doing a lot of research into this over the past few days as I'm not very versed in WCTs, and everything seems to boil down to two things.
    1. Just use NatCam
    I have a bit of an issue with just defaulting to "use a plugin" because I'd like to know what the problem actually is and to see if there's anything I can do about it myself before paying for and learning a new plugin. However, I've used a lot of helpful plugins in the past to save a lot of time, so if NatCam does the job, I'll gladly drop the $30-50 on it. I'm not sure if it's the solution though, since it seems to be intended for mobile devices and this is a USB webcam on a desktop/tablet.

    2. Refer to this post: https://answers.unity.com/questions...ratio.html?childToView=1148424#answer-1148424
    Now I did mention I'm relatively new to WCTs, but I'm having a lot of trouble deciphering where the relevance to my issue lies in this. First of all, this answer is years old and referring to "unaddressed issues with Unity" (while also again defaulting to "just use NatCam.") Secondly, it once again seems to be directed at mobile device cameras not giving you the full resolution rather than a completely different aspect ratio. Finally, I did try and implement the tweaks mentioned in the answer, and while I'm finally able to get the texture at a higher res of 720, it's still crunching it to a 4:3 aspect ratio (960x720), and chopping off the extra areas.

    I'm wondering if this is something I'm just not setting up properly, if I really do just need to use NatCam, or if I'm having some issue with my device video drivers that is preventing Unity from being capable of grabbing the camera's actual res/ratio.
     
  2. Nikovich

    Nikovich

    Joined:
    Jul 10, 2010
    Posts:
    69
    Update on this: I emailed the creator of NatCam and asked him about listed Issue 1: "Just Use NatCam."

    He said that NatCam is specifically targeted for iOS and Android devices; on all other platforms, it falls back to WebCamTexture. So #1 is not a viable fix for this issue.
     
  3. Nikovich

    Nikovich

    Joined:
    Jul 10, 2010
    Posts:
    69
    Update on this. I was able to get the camera to play at its proper full resolution by setting the rectTransform to a 2:1 size, applying the webcam texture with size/framerate included in the overload as opposed to just doing "= new WebCamTexture()", then applying my aspectRatioFitter and changing the controlled axis size.

    myVideo = new WebCamTexture(1280, 720, 60);
    - vs -
    myVideo = new WebCamTexture();

    NOW my problem is that my webcam that's supposed to capture 30fps at 1080p and 60fps at 720p is capturing at roughly 4 fps unless I drop the resolution down to 480p or lower.
     
  4. eonline100

    eonline100

    Joined:
    Oct 6, 2020
    Posts:
    1
  5. foundrysixfuel

    foundrysixfuel

    Joined:
    Jan 21, 2020
    Posts:
    2
    Hi Nikovich, did you discover any solution for the Logitech c922 issue? I am running into the exact same issue! FPS is 4FPS when using 1280x720 resolution.