Saturday, September 24, 2022
HomeiOS DevelopmentiOS digital camera preview is unstable

iOS digital camera preview is unstable


Apple supplies a pattern iOS venture referred to as AVCamFilter the place they use an MTKView to render the digital camera preview to the display screen. The issue is that the body length – the period of time every particular person digital camera body spends being displayed on the display screen – will not be steady. The digital camera stream is working at 30 FPS, that’s one body delivered each 33.3 milliseconds, so it stands to purpose that we should always have the ability to show these frames one after one other with a body length of 33.3 ms. In actuality the body length is unstable – more often than not it’s about 33.3 ms however generally it’s roughly 16.7 or 50.1 ms.

Based on documentation the default conduct for MTKView is to attract to the display screen at 60 FPS, that’s one body each 16.7 ms, so every digital camera body can be drawn twice earlier than it’s changed by the following one. The truth that MTKView’s draw loop and the digital camera’s seize loop aren’t synchronized explains the issue – the time elapsed between a draw and a seize will progressively drift inflicting frames to go from being captured simply earlier than a draw to only after a draw and so forth and so forth leading to some frames being displayed for 3 attracts or one draw as a substitute of the anticipated two. The MTKView draw loop will be synchronized with the digital camera by disabling the default conduct and manually calling draw each time a brand new digital camera body arrives, however all of that is nonetheless not synchronized with the machine show itself which is rendering at 60 FPS in its personal loop. So, we nonetheless have the identical elementary timing drawback. I do know CADisplayLink is supposed for synchronizing issues to the show however there isn’t any means for the seize stream to make use of it.

So how can we render the digital camera preview with a steady 33.3 ms body length? Is the instability an anticipated conduct with no workaround?

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments