v4l2v4l

V4L2 preview with callback instead of polling-loop


I just started looking into V4L2 and all the samples I can find use loops to poll images from the camera. Is there a way to register a callback instead of looping? I can't figure out when to poll images and it does not seem like a good idea to just poll all the time, or is it?

This is the sample I am currently looking at> https://linuxtv.org/downloads/v4l-dvb-apis/capture-example.html Is some part of the mainloop blocking and waits for the next frame?


Solution

  • Well, since nobody seemed to know a possibility to do this, I implemented it myself. The frame polling is indeed blocking and waits for the next frame, so it is enough to start a thread that polls the frame and calls the callback method once a new frame is retrieved.