- Home /
WebcamTexture stretching too much
in my app i m trying to render webcamtexture on to a raw image, but it is always stretching no matter how i code, plus the requstedHeight and requestedWidth are not affecting this problem in any way, plus this is the first time im working with webcamtexture... below is the current code
below is what i m getting when i run it on my android phone
Hi, try this
http://answers.unity3d.com/answers/910020/view.html
and follow through the link there I edited in for the ratio/etc
hope it works!
@Fattie sir i did exactly the same as mentioned above but now i m facing a weird problem, actually my webcamtexture is not using the resolution i m trying to set, for instance if i m setting 1280*720, then i m getting something like 1440*1080, basically i m always getting a resolution which is stretching my texture same as in above image
I guess the problem is that the camera supports only an aspect ration of 4:3 (for example), but you are requesting an aspect ratio of 16:9. So requestedWidth and requestedHeight gives you the closest resolution (of 1280x720) that the camera supports (1280 to 1440 and 720 to 1080, 16:9 to 4:3).
Answer by Fattie · Mar 15, 2016 at 12:47 PM
requestWidth and requestHeight
simply do not work on mobile!!!
that's all there is to it
$$anonymous$$mh, it could be that I'm completely wrong here ... and I don't know if this is the intended behavior of requestWidth and requestHeight, but I can use it like this:
I have a RawImage to display the webcam texture
I want it's size to be around square (for example 600x600)
so I do a requestWidth and requestHeight with this values
the WebCamTexture.width and WebCamTexture.height is now as close as possible to this (that is the 'resolution' the webcam can give me - in this example it's 640x480)
now I set the size of the RawImage RectTransform to these values (640x480), which results in a non-stretched video being displayed
Did I miss something obvious?
EDIT: Ah ok, you edited your answer ('on mobile') ... I didn't test that. Sorry for any confusion.
I beg your pardon, they do not work on mobile! :)
on certain desktop platforms they sometimes work, right.
NOTE points (1) and (2) in huge type,
Weird ... it works on my Xperia Z1 just like on my Desktop (except it delivers some strange resolutions ... but still displaying correctly, no stretches).
Your answer
Follow this Question
Related Questions
Cam texture stopped working in Unity 5/Android Lollipop 0 Answers
problem accessing webcamtexture.videorotation angle on windows phone 8 0 Answers
OpenCVForUnity Core.Flip function not working in Unity Android Build 0 Answers
WebCamTexture resolution and cropping problem on Android 0 Answers
WebCamTexture crashes on android 0 Answers