I'm trying to implement a vision-based "lidar" system as described here: https://hackaday.com/2016/04/04/smartphone-and-ir-line-laser-measure-distance/

the idea is to capture video at 30fps and pulse a laser at 15hz such that the laser appears in odd frames and does not appear in even frames. By taking the difference between odd and even frames we can isolate the laser line.

when I implemented this, the isolated laser phases in and out with a period of ~1 second. Looking at the raw frames, sometimes the laser is full-brightness, sometimes it is not visible, and sometimes it's at 50% brightness.

Given that the laser is either on or off, I'm not sure why the partial-brightness frames occur. My current theory is that CMOS rolling shutter might not just scan top->bottom like I'd expect, but that doesn't make much sense. I checked to make sure that I'm getting video at 30fps and I'm using a usb camera with the ov9712 chip.

1 Answer 1


No matter when the camera shutter is active, if the frequencies of the video vertical timing (the frame rate) and the laser pulse are not congruent, you'll see partial exposures as they drift apart.

The solution is to trigger the laser pulse on every other vertical sync time. The details on extracting the vertical interval will depend on the camera, and how to trigger the laser will depend on the details of that device. But some sort of forced sync is the only way to get exactly what you want.

  • my understanding is that progressive-scan on a cmos camera exposes one row of pixels at a time. So for an un-synced exposure in which the laser is on only half the time, I would expect the laser to appear in the top half but not the bottom. This is fine since in the next frame, the laser will appear in the bottom half, and taking the absolute difference should get the full laser scan. what I'm seeing would make sense if the camera is global-shutter, so that an exposure in which the laser is on half the time would be the full scan at 50% brightness.
    – Jack000
    May 21, 2016 at 13:34
  • I guess my mental model for the sensor scan is wrong? it would make sense if the sensor was exposed all at once but read one pixel at a time.
    – Jack000
    May 21, 2016 at 13:44
  • @Jack000 The exact effect does depend on the type of shutter (global vs rolling and variations of those) but in any case you must synchronize the flash to the video vertical interval to get consistent, repeatable results.
    – Jim Mack
    May 21, 2016 at 13:49
  • The shutter is usually only open for part of a frame period. The most time is spent transferring data. If the laser fires during data transfer, it is missed completely. Feb 27, 2020 at 20:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.