Rolling Shutter Simulation in C
nullprogram.com
nullprogram.com
http://danielwalsh.tumblr.com/post/54400376441/playing-detec...
I've seen some code (don't remember the website now) that gets you the non-rolled shuttered (sic) image from the rolling shutter one.
(It works to reconstruct a scene, but has issues at edges etc, so it's not really usable to fix a photo/video 100% -- but there are commercial NLE plugins that do reduce rolling shutter in post).
#define F for(i=0;i<l*3;i++)
main(n){int i,j,w=640,h=480,l
=w*h,o[]={~w,-w,-w+1,-1,1,w-1
,w,w+1},b[l*5];F b[i]=rand();
for(puts("YUV4MPEG2 W640 H48"
"0 F30 C444");puts("FRAME");)
{F{for(n=j=8;j;n-=b[i+o[--j]]
&1);b[i+l]=(n^5&&!b[i]|n^6)-1
;}F putchar(b[i]=b[i+l]);}}
(You can pipe the output to mpv or a similar media player.)For those of us who don't enjoy visual self-flagellation, here's an attempt at untying the above ball of yarn:
#define F for(i=0;i<l3;i++)
main(n)
{
int i,j,
w=640, h=480,
l=w*h,
o[] = {
~w, -w, -w+1,
-1, 1,
w-1, w, w+1
},
b[l*5];
F
b[i]=rand();
for( puts("YUV4MPEG2 W640 H48" "0 F30 C444");
puts("FRAME");
)
{
F
{
for( n=j=8; j; n-=b[ i + o[--j] ]&1 );
b[i+l] = (n^5 && !b[i] | n^6) - 1;
}
F
putchar( b[i]=b[i+l] );
}
}
EDIT: I had no idea you could italicize code blocks! This was an accident, but I'm going to leave it because it looks pretty. Has this always been a feature? I've never seen italicized monospace before. That first line is supposed to read "for(i=0; i < l times three ..." but the asterisk is somehow causing HN to italicize the code block. There's no matching closing asterisk, so this is pretty amusing.I've seen it before so I think it's always been a bug :)
baz
See? No italicization.Now I'm curious what triggers it...
baz*quux
Aha. HN's parser is matching with the asterisk in the code snippet.Take a look: http://antidom.com/fan.webm
[1] https://www.youtube.com/watch?v=dNVtMmLlnoE&feature=youtu.be
[2] https://www.reddit.com/r/rust/comments/6kl0vj/i_made_a_progr...
Cool research into RS effects: "Direct Semi-dense SLAM for Rolling Shutter Cameras". https://www.youtube.com/watch?v=OLD1eeu1EUI https://github.com/jaehak/rrd_slam
This only tries to reverse adverse effect of RS (at best as good as global shutter), but in theory it would be possible to exploit RS effect to boost accuracy above GS.
Afaik Jeri Ellsworth CastAR (shutdown, because Rubin invested only to sell to google, and that didnt happen) IR tracker took advantage of cheap cellphone camera rolling shutter to boost both spatial and temporal tracking resolution.
It’s a c++ multimedia Swiss Army knife with a pretty strong community and repo of addons.
Libcinder is another option, though only for Mac/Win
Sampling the entire CMOS sensor at once is not really possible when you stop to consider the sheer magnitude of bits required to represent a single still image. The CMOS sensor only has a finite number of pins connecting it to the logic board responsible for polling its state, so it makes sense to use an addressing system to read the sensor data. This addressing system uses a small number of addressing bits (each pin is usually just one bit) to move a sliding window over a much larger amount of data. Regular computer memory works the same way. This enables that data to be passed through to the camera in small pieces. While this can be made rather fast with good engineering, it is not instant, and the non-instantaneous nature produces the rolling shutter effect.
It's the physical limitation on the number of pins that creates the need for the rolling shutter in modern CMOS design. Creating speedier memory access routines can reduce the effect of the shutter, but not eliminate it.
A possible alternative approach would be to build some memory into the image sensor, so that you can ask it to "lock" all the bits in place, and then read those bits out at your logic board's leisure. That should effectively eliminate the rolling shutter effect, (More or less, assuming your "freeze" signal arrives at all the pixels more or less at the same time) at the engineering expense of needing to add per-pixel memory to your image sensor, and additional electronics to perform the lock. I'm no expert on the subject, but I would not be surprised if more modern image sensors have some feature for this purpose, especially those used in high speed cameras.
Numerous CMOS, CCD, and other types of focal plane / 2D detectors have global shutters where all pixels 'integrate photons or energetic particles' at the same time for a set amount of time.
Read-out is performed in a rolling fashion... the data generally has to be serialized for analog to digital conversion (although not always) and/or transmission over a communication protocol or write to file.
A global shutter detector at the hardware level has settings for framerate and light integration time (among other things). Readout time is more or less constant for a particular camera sensor. So if integration requires say 20ms, and readout takes 30 ms... you're looking at about 20 FPS image acquisition speed.
Good overview: http://www.red.com/learn/red-101/global-rolling-shutter
Canon, for example, announced a global shutter CMOS sensor last year. The problem here is that those extra components come at a cost. Either they crowd out existing components on the sensor, which would dramatically reduce light sensitivity. Or, they require additional layers in the CMOS die, which significantly increases fabrication cost due to design costs, fabrication time, lower yield, etc. Additionally, the extra step in digitization reduces effective frame rate.
Not so sure. Phone cameras are big selling points for phones, and have some hardware innovations (and access to much faster processors than the average "high end" DSLR/mirrorless), that , if we ignore the smaller by necessity optics, are in the same or even better league tech-wise to the average Sony/Canon/etc. Talking of course for flagship iOS/Android phones, not the average phone.
Only a few use cases would benefit, so the there's no economic incentive to change how it works.
Edit: technical details based on dpreview claims it's actually not a global shutter, just a very quick rolling one. "...this capability stems from a stacked CMOS image sensor, which includes processing circuitry nearer the pixels and features built-in memory to deliver all this data to the off-board processors at a rate they can cope with. It's this structure that enables the camera to shoot at 20 frames per second and do so with an electronic shutter that's fast enough to minimize the rolling shutter effect."
Don't CMOS sensors increase in pixel density (from a few megapixels to 30 and even 50 mp in some Sony full frame cameras today)?
If the camera sensors were made as just 4K resolution sensors it might be easier to scan it all at once in fast enough time (though we also increasingly ask for more slow-motion capabilities, which requires even faster frame rates).