Page 1 of 1

Re: Syncing a high power LED array to camera start frame.

Posted: Mon Apr 02, 2018 3:56 pm
by drgeoff
Raspbian is not a real time OS, the OS is doing other things in addition to running your code and python is an interpreted language.

All those latencies mean that things are not happening as soon as you expect.

Re: Syncing a high power LED array to camera start frame.

Posted: Mon Apr 02, 2018 7:44 pm
by 6by9
Two words - rolling shutter.
The sensor has no on board "storage", and the readout to the SoC is bandwidth limited. The way most sensors work around that is that the exposure of each line is delayed by the time the line takes to read out, hence the frame start event is when the SoC receives the first line of the frame/the first line finishes exposing. If taking a still image (full 5 or 8MPix frame readout), then the frame readout time is ~60ms. The other sensor modes have varying readout times, which also dictates the maximum frame rate of each mode.
Setting your exposure time to 1ms means that each line will be exposed for 1ms, but there will still be a temporal difference between the first and last line.
Have a read of waveform80's description at http://picamera.readthedocs.io/en/lates ... -operation

drgeoff is also correct that Linux is not a real-time operating system, so there are no guarantees as to the processing latency (even more so in an interpreted language such as Python). That is one of the main reasons I didn't plumb it through as a callback from the GPU as you could gain an indeterminate latency in processing that event. At least with a GPIO being controlled by the GPU the latency should be minimal.

Re: Syncing a high power LED array to camera start frame.

Posted: Fri Apr 13, 2018 1:40 pm
by Kozuch
Do I understand this correctly that with some sort of setting ("disable_camera_led=3") and a setup described above one can get a GPIO signal when a frame exposure starts? Does this work only with still capture more or also in video (sensor running freely) mode (still/video MMAL ports)?

Re: Syncing a high power LED array to camera start frame.

Posted: Fri Apr 13, 2018 2:08 pm
by 6by9
Kozuch wrote:
Fri Apr 13, 2018 1:40 pm
Do I understand this correctly that with some sort of setting ("disable_camera_led=3") and a setup described above one can get a GPIO signal when a frame exposure starts? Does this work only with still capture more or also in video (sensor running freely) mode (still/video MMAL ports)?
viewtopic.php?t=190314
NB Start/end of frame reception at the SoC ie end of exposure of the first/last line of the image.

Re: Syncing a high power LED array to camera start frame.

Posted: Fri Apr 13, 2018 2:36 pm
by PiGraham
Insurmountable wrote:
Tue Apr 03, 2018 5:41 pm
Yes it seems to work better just using the Camera LED signal to switch the FET directly on and off. When you do as I have done you get a small band at the top of the picture which is the delay in switching on the FET using my python code. I will put a scope on it tomorrow and see what the differences are between the two methods.

The reason I did it this way was I wanted to have better control of the lights on time, if you drive directly from the camera LED signal then you always switch the lights off when the last frame is received regardless of the shutter time but it seems that at high shutter speeds this is practically one and the same.
As 6by9 explained (read the linked info) you can't use strobbed illumination with the rolling shutter at shutter times shorter than the full frame time. If you try you will only illuminate some strip of lines. The scan lines expose at different times. This is nothing like a film camera or gloabl shutter sensor
.

You need to turn the light on from the first line to the last line of the frame + exposure time.

If you need to freeze fast motion with exposures shorter than the frame time use a different camera.

Re: Syncing a high power LED array to camera start frame.

Posted: Sat Apr 14, 2018 8:48 am
by PiGraham
Insurmountable wrote:
Fri Apr 13, 2018 7:15 pm
As 6by9 explained (read the linked info) you can't use strobbed illumination with the rolling shutter at shutter times shorter than the full frame time. If you try you will only illuminate some strip of lines. The scan lines expose at different times. This is nothing like a film camera or gloabl shutter sensor
I am using this for a Computer Vision project, the results I am getting do have banding so you could never use it for film or TV but considering I am capturing images of stuff moving fast in total darkness, the results are great and I have achieved what everyone else said you need a physical shutter to do.

Fair enough, if you can compensate for banding and distortion that results from rolling shutter it can still be useful. You can combine multiple partially-illuminated frames and un-warp and so on.

You shouldn't be surprised that you got the replies explaining rolling shutter since in your OP you didn't seem to understand how it works.
If the exposure time of the camera is 1ms then it should only need the lights to be on for 1ms not 15ms.
And you didn't say anything about how you were using the images or how you were compensating for rolling shutter effects.

Re: Syncing a high power LED array to camera start frame.

Posted: Sun Apr 15, 2018 4:09 pm
by PiGraham
Thanks for posting those images. It's great to see what people are doing with Raspberry Pis. It looks very impressive.
Are you trying to freeze motion? It doesn't look like anything is moving in the image from the Pi camera with LED lighting.

Re: Syncing a high power LED array to camera start frame.

Posted: Sun Apr 15, 2018 8:03 pm
by 6by9
Insurmountable wrote:
Sat Apr 14, 2018 7:54 pm
ooops I nearly forgot with a rolling shutter it's not really exposure time but the amount of gain of the CCD chip, silly me.
??! Neither Pi cameras are CCD, they're both CMOS based. Both have exposure control (time between resetting the line and reading it out) and gain control.

Re: Syncing a high power LED array to camera start frame.

Posted: Sun Apr 15, 2018 8:36 pm
by PiGraham
Insurmountable wrote:
Sat Apr 14, 2018 7:54 pm
ooops I nearly forgot with a rolling shutter it's not really exposure time but the amount of gain of the CCD chip, silly me.
It really is exposure time. It's just that each line of the image exposes at a different time,, one after the other, but each line exposes (gathers light) for the specified exposure time. Gain is something else entirely.

Re: Syncing a high power LED array to camera start frame.

Posted: Mon Apr 16, 2018 7:40 am
by PiGraham
Insurmountable wrote:
Sun Apr 15, 2018 9:29 pm

Also you can get a zillion different hi-quality camera lens on gumtree or craigslist for less than $100 while hi quality CCTV lens are expensive and because of their size don't let in enough light. You want to try and get lens that are NOT full format, if you do use one then your picture will be zoomed in like a 1000 times and you will have a very narrow field of view.
That is a challenge. One limitation in using an SLR lens with a Pi camera is the size of the pixels / the resolution of the projected image. An SLR/DSLR has a large photo sensitive area and doesn't need such high resolution to get nice sharp results. The pixels on the Pi sensors are very small beyond the limit of resolution of most lenses. Any large format lens that is properly matched to those sensors will be relatively expensive.
Not only do you get the magnification problem, you can't get sharp focus.
Fast lenses help with light levels, but also soften the sharpness and reduce depth of field.

You have done a good job there.

Re: Syncing a high power LED array to camera start frame.

Posted: Mon Apr 16, 2018 7:44 am
by PiGraham
Insurmountable wrote:
Sun Apr 15, 2018 11:19 pm
Are you trying to freeze motion? It doesn't look like anything is moving in the image from the Pi camera with LED lighting.
Here is one of my freeze motion shots, taken from the shore.

Great photos.

I was asking about whether you were using strobbed LEDs to freeze motion, which is where rolling shutter gest particularly problematic.
Any motion will result in some distortion but it's not noticeable in most scenes and slow speeds. As you know it gest obvious with fast moving edges like propellers. You can't use a strobe to get a freeze-frame image of a propeller on a rolling shutter sensor.

Re: Syncing a high power LED array to camera start frame.

Posted: Mon Apr 16, 2018 9:13 am
by 6by9
Insurmountable wrote:
Sun Apr 15, 2018 10:48 pm
??! Neither Pi cameras are CCD, they're both CMOS based. Both have exposure control (time between resetting the line and reading it out) and gain control.
And I have a Hoover but it is not actually a Hoover. ;)
I'm no expert on CCDs hence surmised from your comment that there could be a limitation where they couldn't control exposure time. I'd be surprised as exposure time gives a significantly greater degree of control over the amount of light sensed than gain does.
Insurmountable wrote:
It really is exposure time. It's just that each line of the image exposes at a different time,, one after the other, but each line exposes (gathers light) for the specified exposure time. Gain is something else entirely.
Yeah I was wondering how it would be possible to implement using gain, I figured it was something akin to switching the power on then off to achieve. The reason why companies like FaceBook and Apple make so much money is the inability of todays computer engineers to make manuals that make sense. When I had my BBC model B in the 80s there was no Internet, no one to ask, I had a few manuals which explained everything in detail and that was that, never needed to ask anyone anything. Look it up in the manual which would say stuff like this command causes the CPU to first set these registers to this then these lines to that, it literally told you how it worked, these days manuals attempt to simplify stuff and fail miserably.
Have a read through https://picamera.readthedocs.io/en/latest/fov.html for a decent description of how the sensors implement rolling shutter with exposure time.
Insurmountable wrote:A good point is how it is seemingly impossible to set the Pi camera into manual mode, any adjustments are made using whatever the last automatic settings produced, you cant say take a picture with this ISO and then add 2 stops of extra exposure, if you tell it to increase the exposure by 2 stops then it takes the last automatically obtained exposure setting and adds 2 stops to that. like WTF? do these guys even do photography?
Er, try -ag and -dg in raspistill/vid to explicitly set analogue and digital gains, and -ss to set the shutter speed. (NB omit any of those and the automatic algorithm will be adjusting those controls to try and achieve what it sees as correctly exposed).
Add in -awbg to set white balance gains, and there aren't many more controls left. If you want manual control then you take full responsibility for it.

Please rememeber that the Pi camera was aimed at mobile phones, not DSLRs. Two very different markets with different expectations (and price points).

Re: Syncing a high power LED array to camera start frame.

Posted: Mon Apr 16, 2018 4:13 pm
by PiGraham
Insurmountable wrote:
Mon Apr 16, 2018 11:43 am
The maximum speed of what I want to take images of is 15m/sec with an exposure time of 1.5ms that means the object will only have moved 2cm during the exposure time. And objects are traveling towards the camera so it wont be an issue.
Frame rate is more significant than exposure time. The fastest I've seen the current Pi camera run in 665fps which is 5.5ms but unless you are setting the frame rate you will have the standard 60fps 16.7ms or 30fps 33.4ms. Of course frame rate and exposure time are related

The object will have moved 2cm in the time a single line is exposing, but to get an image you need all the lines so it could be a much bigger distance. Look for comb tooth effects on edges.

You can ee it on hermansw's video here
Image
viewtopic.php?t=201568#p1277323

Check out HermanSW who has been exploring high frame rates.

viewtopic.php?t=201568

How significant motion during the frame time is depends a lot on the field of view / distance to target.

The gif above is 'only' 3.3m/s but it's close to the camera so the effect is very obvious.

If you have sample images that show no sign of these effects it would be interesting to understand what's going on.

Re: Syncing a high power LED array to camera start frame.

Posted: Thu Apr 19, 2018 7:34 am
by PiGraham
You have a strange attitude.
If you did want to use a DSLR take a look at gphoto2 which should allow you to download images as they are taken using USB.
Since the issues discussed relate to the sensor changing to another SBC will make no difference.

And to reiterate, you can use rolling shutter sensors with moving scenes if you can deal with the inherent distortion and exposure artifacts. They aren't necessarily noticeable, depending on speeds, field of view, distance to object etc and some compensation may be possible.

Re: Syncing a high power LED array to camera start frame.

Posted: Thu Apr 19, 2018 11:59 am
by 6by9
Insurmountable wrote:
Wed Apr 18, 2018 9:00 pm
Frame rate is more significant than exposure time. The fastest I've seen the current Pi camera run in 665fps which is 5.5ms but unless you are setting the frame rate you will have the standard 60fps 16.7ms or 30fps 33.4ms. Of course frame rate and exposure time are related
There you go, frame rate is not actually frame rate but effective frame rate.
Huh? What's your definition of frame rate vs effective frame rate then?
To me frame rate is the rate at which frames are delivered from the sensor, be that measured at frame start, frame end, or any other common point of two frames.
The relationship between frame rate and exposure time is that the frame period (1/frame rate) has to be greater than the exposure time, as you can't be exposing the same line of pixels for two different frames at the same time.
Insurmountable wrote:
Wed Apr 18, 2018 9:22 pm
Another option would be to use the Asus Tinker SBC instead of a Pi, I see they work with the Pi Camera. Anyone any idea on what the actual frame rate they can read from the camera is? The new updated version is meant to be stupid fast at processing video. Can you overclock the Pi camera? does the camera set the data transfer rate or the Pi ?
The camera board has a 25MHz oscillator on it. The sensor then has PLLs and divsors to increase that to a requested pixel clock rate, as programmed via a large number of I2C writes when you start using it. The sensor manufacturers will specify various maximum values for PLL settings and pixel rates. Feel free to delve into those register sets, but be aware that they frequently defy logic.