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

webcam Capture from webcam encountered: IndexOutOfRangeException: Array index is out of range

$
0
0
I 'm trying to call the webcam from the plane object, and planning to capture the image from there. But my class library encountered an error> "IndexOutOfRangeException: Array index> is out of range." Just a simple code, yet I failed to figure out why. public class CameraCapture : MonoBehaviour { private WebCamTexture webcamTexture; private Texture2D textureImg; private int imgWidth = 640; private int imgHeight = 480; private GameObject plane; private Texture2D videoTexture; private Texture2D tmp; void Start () { WebCamDevice[] devices = WebCamTexture.devices; Debug.Log("devices"+ devices.Length); videoTexture = new Texture2D(imgWidth, imgHeight, TextureFormat.RGB24, false); tmp = new Texture2D(imgWidth, imgHeight, TextureFormat.RGB24, false); textureImg = new Texture2D(imgWidth, imgHeight, TextureFormat.RGB24, false); webcamTexture = new WebCamTexture(devices[1].name, imgWidth, imgHeight, 60); webcamTexture.Play(); plane = GameObject.Find("Plane"); } } Any advice ? thanks in advance.

Viewing all articles
Browse latest Browse all 256


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