Quantcast
Channel: Questions in topic: "webcam"
Viewing all articles
Browse latest Browse all 256

Set webcam image format to MJPG

$
0
0
Hi, I have a webcam (Logitech C930e) that I want to use in a project (this will only run on a dedicated computer, with this exact webcam). I'm having some problems with the FPS. First of all, here's the script I'm running right now: using System; using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; public class WebcamHandler : MonoBehaviour { private WebCamTexture webCamTexture; public RawImage webcamView; public int selectedWebcam; public int requestedWebcamWidth, requestedWebcamHeight, requestedWebcamFPS; void Start () { PrintAvailableWebcams(); SetupWebcam(); } private void SetupWebcam(){ webCamTexture = new WebCamTexture(WebCamTexture.devices[selectedWebcam].name, requestedWebcamWidth, requestedWebcamHeight, requestedWebcamFPS); webCamTexture.Play(); webcamView.texture = webCamTexture; } private void PrintAvailableWebcams(){ WebCamDevice[] devices = WebCamTexture.devices; for (int i = 0; i < devices.Length; i++){ Debug.Log("Webcam[" + i + "]: " + devices[i].name); } } } It works, I get the live image from the webcam, but the FPS is stuck at 5 FPS, no matter what I enter as requested frame rate (even if I enter something lower, like 1 fps). I downloaded the free version of [AVPro Live Camera][1], just to see what's going on. And I notice that the webcam format is initialized as YUV_YUV2, and when I select a resolution of 1920x1080, the fps is stuck at 5. BUT, when I change the video format to MJPG, I can select an FPS of 30, and everything is running smoothly. So, my question is, how would I change the format setting of a webcam, using Unity's built-in WebCamTexture? Is it possible? Seems a bit silly to pay the full price of AVPro Live camera (€179) just for this single setting. Thank you! [1]: https://assetstore.unity.com/packages/tools/video/avpro-live-camera-3683

Viewing all articles
Browse latest Browse all 256

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>