- Home /
High FPS webcam problem
I just noticed (after hours of debugging) that a too high FPS can (and does) actually cause a problem with the web cam. I'm using WebCamTexture
class to get the image from the webcam in my laptop and put it as a texture on an object (real-time). And it works well. But when I run the app (in the Editor) and it has a high FPS (like 900 or more, I'm not sure what's the threshold) the application chokes horribly, freezes, lags and so on... It doesn't complete freeze as it jumps a few frames (literally a few) every couple of seconds then it freezes again and so on... But when I set Application.targetFrameRate
to a low value (like 60) the problem disappeared. Also 100 - 200 seemed to work well. I tested the app also on my mobile phone and it works ok (but I assume it's because it can't get 1000 FPS there :P).
So my conclusion is that too high an FPS causes problems as the web cam can't catch up or something. But why? Has anyone come across this problem before? Should I just fix the FPS in my application or what's the correct solution?
As a side note, or question rather - can I lock the FPS for a moment in my application (only when I actually use the camera) and then unlock it again? Or should Application.targetFrameRate
be used just once at the start and never touched again?
I am using WebCamTexture now and in mobile, my app has a huge lag. every few seconds the image is updated and then it freezes for another few seconds.
did you ever find the reason for lags? I am creating default webcam without specifying the frameRate
I'm having a similar problem. When I maximize the Game window in play mode, my webcam video freezes and the cam light blinks on and off. Turning on VSync makes the problem go away. Note that I don't have this problem on my slower computers, only on my fastest machine (HP Omen 15). It does seem from these reports that a really high frame rate causes problems for some cams.
Answer by CHRISYS · Sep 11, 2014 at 02:18 PM
same problem here...!!!, when i started a project i first tested this code:
**http://answers.unity3d.com/questions/384734/how-to-take-a-photo-from-a-webcam.html**
but at that time i did not used the stats option in game tab when running the app, i just tested fine, after the test i was working with other thing in the app and didn´t even use the webcam, so just yesterday i was testing webcam again with stats on and set all my 3d models and objects in scene to inactive and i noticed my FPS goes from 2000 to 5000...!! the webcam shows that jumps between movement the led that lights when the webcam is on, is blinking like the web cam is turning on and of constantly and i noticed only when the light is on the webcam is able to update the img, I even tested it on a new scene and same problem, i tested it on my personal laptop whit the built-in webcam in another project in a scene with a floor cube, a directional light, a cloth and the cube where the webcam is showing the webcamtexture, fps is 58 to 68, and this problem is not happening...!! what could it be..?
I am using WebCamTexture now and in mobile, my app has a huge lag. every few seconds the image is updated and then it freezes for another few seconds.
did you ever find the reason for lags? I am creating default webcam without specifying the frameRate