Answers.Body: <p>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.</p>
  
  <p>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.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-05-21T13:34:00.443Z
Answers.Text: 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.
Answers.UserDisplayName: Jack000
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-05-21T13:44:06.980Z
Answers.Text: 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.
Answers.UserDisplayName: Jack000
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-05-21T13:49:17.920Z
Answers.Text: @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.
Answers.UserDisplayName: Jim Mack
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-02-27T20:57:32.190Z
Answers.Text: 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.
Answers.UserDisplayName: artless-noise-bye-due2AI
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-05-21T01:16:37.100Z
Answers.LastActivityDate: 2016-05-21T01:16:37.100Z
Answers.UserDisplayName: Jim Mack
Body: <p>I'm trying to implement a vision-based "lidar" system as described here: <a href="https://hackaday.com/2016/04/04/smartphone-and-ir-line-laser-measure-distance/" rel="nofollow">https://hackaday.com/2016/04/04/smartphone-and-ir-line-laser-measure-distance/</a></p>
  
  <p>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.</p>
  
  <p>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.</p>
  
  <p>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.</p>
  
Tags: <sync><usb>
Title: Rolling shutter strobe pattern
UserDisplayName: Jack000
ThreadText: # Rolling shutter strobe pattern
  
  (Asked by: username_0 on 2016-05-21)
  
  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.
  
  **Tags:** sync, usb
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2016-05-21. Score: 2 | Accepted answer
  
  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.
  
  > **Comments:**
  > **username_0**: 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.  
  > **username_0**: 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.  
  > **username_1**: @username_0  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.  
  > **username_2**: 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.  
  
  ---
  
  