- Home /
Question by
n2k · Dec 11, 2015 at 01:57 PM ·
not workingwebcamtexturegetpixel
WebCamTexture GetPixel(s) not working (RGB values are 0)
I am not able to get valid RGB values from the camera using WebCamTexture.
Playing the live stream of the camera using a RawImage just works fine.
But if I try to get the pixels out of a frame I always get RGB(0,0,0):
cam = new WebCamTexture(devices[0].name, 640, 480, 25);
rawImageSrc.texture = cam; // works fine: Image in GUI will render the live stream
rawImageSrc.material.mainTexture = cam;
cam.Play();
if (cam.isPlaying)
{
Color col = cam.GetPixel(0, 0); // rgb: 0,0,0
Color[] cols = cam.GetPixels(); // rgb: 0,0,0
Color32[] cols32 = cam.GetPixels32(); // rgb: 0,0,0
}
I found several posts where people have the same issue. Unfortunately, there are no solutions about how to fix the issue in the posts.
Anybody an idea what I am doing wrong?
Or is there a way to get the pixel data from RawImage?
I am using Unity 5.2.1f1 Personal.
Thanks in advance.
Comment