EZKernel
Posts: 19
Joined: Sat May 25, 2019 4:39 pm

Scrolling Horizontal Blur

Fri Jun 14, 2019 1:58 am

Hi all, I am making a device to grow some plants and in the videos it records there is a slow scrolling horizontal black blur which is far more apparent when I do a timelapse as it is not synced up to my capture speed. Any way to remove this?

I am using the 1080p 5MP camera

https://www.youtube.com/watch?v=C-w8q9xvou0
example in the video.

Thank you.

User avatar
HermannSW
Posts: 1393
Joined: Fri Jul 22, 2016 9:09 pm
Location: Eberbach, Germany
Contact: Website Twitter YouTube

Re: Scrolling Horizontal Blur

Fri Jun 14, 2019 6:07 am

EZKernel wrote:
Fri Jun 14, 2019 1:58 am
as it is not synced up to my capture speed.
What is your capture speed?
What mode?
raspivid or raspistill with combining frames afterwards?
(youtube video stats for nerds says the frames are 946x532 ?!?!?)
⇨https://stamm-wilbrandt.de/en/Raspberry_camera.html

https://github.com/Hermann-SW/Raspberry_v1_camera_global_external_shutter
https://gitlab.freedesktop.org/HermannSW/gst-template
https://github.com/Hermann-SW/fork-raspiraw
https://twitter.com/HermannSW

6by9
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 7140
Joined: Wed Dec 04, 2013 11:27 am
Location: ZZ9 Plural Z Alpha, aka just outside Cambridge.

Re: Scrolling Horizontal Blur

Fri Jun 14, 2019 6:26 am

Mains flicker.

Your illumination is most likely fluorescent lights which flash at twice the mains frequency (once for each half cycle).
The sensor is a rolling shutter sensor, therefore not all lines expose at exactly the same moment. If the exposure time is not a multiple of a mains half cycle then some lines will exposed with more illumination than others, leading to dimming.
The solution depends on the base exposure time. If it is less than one half cycle then there is nothing you can ry do except change the lighting. If it is more, then use the -fl -fli option to specify the mains frequency, and ae will choose exposure times that are a multiple of the flicker period.
Software Engineer at Raspberry Pi Trading. Views expressed are still personal views.
I'm not interested in doing contracts for bespoke functionality - please don't ask.

User avatar
HermannSW
Posts: 1393
Joined: Fri Jul 22, 2016 9:09 pm
Location: Eberbach, Germany
Contact: Website Twitter YouTube

Re: Scrolling Horizontal Blur

Fri Jun 14, 2019 7:24 am

6by9 wrote:
Fri Jun 14, 2019 6:26 am
If it is more, then use the -fl option to specify the mains frequency, and ae will choose exposure times that are a multiple of the flicker period.
I had seen mains flicker myself in the past and was not aware how to overcome that with a raspivid option (I bought led drivers that deliver DC to the led to overcome this issue).

I looked up documentation, and that states -fl is "flush" option:
https://www.raspberrypi.org/documentati ... /camera.md
--flush, -fl
Forces a flush of output data buffers as soon as video data is written. This bypasses any OS caching of written data, and can decrease latency.
I did not find an option that does what you mentioned, searching for frequency or multiple.
Which option does what you said?


viewtopic.php?t=209041
Image
⇨https://stamm-wilbrandt.de/en/Raspberry_camera.html

https://github.com/Hermann-SW/Raspberry_v1_camera_global_external_shutter
https://gitlab.freedesktop.org/HermannSW/gst-template
https://github.com/Hermann-SW/fork-raspiraw
https://twitter.com/HermannSW

6by9
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 7140
Joined: Wed Dec 04, 2013 11:27 am
Location: ZZ9 Plural Z Alpha, aka just outside Cambridge.

Re: Scrolling Horizontal Blur

Fri Jun 14, 2019 8:55 am

HermannSW wrote:
Fri Jun 14, 2019 7:24 am
6by9 wrote:
Fri Jun 14, 2019 6:26 am
If it is more, then use the -fl option to specify the mains frequency, and ae will choose exposure times that are a multiple of the flicker period.
I had seen mains flicker myself in the past and was not aware how to overcome that with a raspivid option (I bought led drivers that deliver DC to the led to overcome this issue).
DC drive is one option, as are incadescent bulbs as the filament doesn't cool down enough between cycles.
With fluorescent tubes they fairly closely follow the mains cycle on light output. You can get higher frequency drivers (ballasts) as some people were sensitive to this flicker, causing headaches and/or eyestrain. I don't know whether those are options for what you are growing (on which I'm making no further comment, just hoping it is legal in your jurisdiction!)
HermannSW wrote:I looked up documentation, and that states -fl is "flush" option:
https://www.raspberrypi.org/documentati ... /camera.md
--flush, -fl
Forces a flush of output data buffers as soon as video data is written. This bypasses any OS caching of written data, and can decrease latency.
That's what I get for writing the post without checking.

Code: Select all

-fli, --flicker : Set flicker avoid mode (see Notes)
...
Flicker avoid mode options:
off,auto,50hz,60hz
Please note that if your exposure time is below the flicker period then there is nothing you can do on the camera settings.
Software Engineer at Raspberry Pi Trading. Views expressed are still personal views.
I'm not interested in doing contracts for bespoke functionality - please don't ask.

User avatar
HermannSW
Posts: 1393
Joined: Fri Jul 22, 2016 9:09 pm
Location: Eberbach, Germany
Contact: Website Twitter YouTube

Re: Scrolling Horizontal Blur

Fri Jun 14, 2019 9:10 am

6by9 wrote:
Fri Jun 14, 2019 8:55 am
That's what I get for writing the post without checking.

Code: Select all

-fli, --flicker : Set flicker avoid mode (see Notes)
...
Flicker avoid mode options:
off,auto,50hz,60hz
Please note that if your exposure time is below the flicker period then there is nothing you can do on the camera settings.
Thank you for that information:
I am on the train and have no Pi running, and the online documentation does not show "-fli" option:
https://www.raspberrypi.org/documentati ... /camera.md
⇨https://stamm-wilbrandt.de/en/Raspberry_camera.html

https://github.com/Hermann-SW/Raspberry_v1_camera_global_external_shutter
https://gitlab.freedesktop.org/HermannSW/gst-template
https://github.com/Hermann-SW/fork-raspiraw
https://twitter.com/HermannSW

EZKernel
Posts: 19
Joined: Sat May 25, 2019 4:39 pm

Re: Scrolling Horizontal Blur

Sat Jun 15, 2019 2:25 am

thanks boys you spanked this one out for me real quick.
all my lights are LED so it's not that - must be something else from mains.

I'm using picamera with picamera.preview() to achieve this effect with a TV screen - it's really what impresses people the most.
https://imgur.com/EVn9Czt
basically, on boot it displays a live feed from the camera on the TV through HDMI and then snaps a pic every 5 mins, uploads to my windoze computer via sftp and my 64bit i5 4790k with python spanks out 4x 1080p vids with ffmpeg showing a timelapse 2 hours @ 30 mins a sec (4 sec) - 6hrs @ 60, 12 hrs @ 60, 3 days @ 180. I'm then able to access these from anytime on my phone. Forget about doing this on a PI especially at 1080. Rock64 on the other hand is well suited for crunching these vids in under a minute and the eMMC module is perfect for it. FFMPEG is also really good in the fact that it allows you to clip together completed .mp4 files without re-encoding!!! I'll be rewriting my software to take images maybe at 5 or 10, 20 secs apart saving them to ramdisk, combining them into a mp4 every minute, or 10 minutes, whatever, for storage and reassembly later. would also be nice to hit a button to see how the plants have grown in a specific time frame.

since I'm hardheaded and want to continue using picamera I tried setting the fps to 30, no go........

Code: Select all

    
    with picamera.PiCamera() as camera:
      camera.resolution = (1920, 1080)
      camera.rotation = 0
      camera.framerate = 30
      camera.exposure_mode = 'off' 
      camera.exposure_compensation = -25 #this binding doesn't do jack
      
      #this fixes everything - since i'm in north america this is 60hz 
      camera.shutter_speed = 5555 #this number looked lucky... it is 1/180 sec in usec but any number divisible by 20 works 1/120 1/60 1/40 for darker areas
      
      
      camera.start_preview()
      
      
I just finished and it looks like it works. I'll update a new timelapse if it did

6by9
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 7140
Joined: Wed Dec 04, 2013 11:27 am
Location: ZZ9 Plural Z Alpha, aka just outside Cambridge.

Re: Scrolling Horizontal Blur

Sat Jun 15, 2019 7:54 am

LEDs follow the input even faster than the phosphor in fluorescent lights, so it really depends on the driver. If it converts to DC to drive the LEDs (as Hermann's does) then you'll get 0 variation. If it half wave rectifies and then current limits, you'll get significant variation still.

60Hz mains is a flicker period of 8.333ms (1/120). Your 5.555 is going to mask much of the issue, but will have a moderate variation as the frame readout (top line to bottom line) takes 1/30th second (33.3ms). Some parts will get the peak of the rectified sine wave, whilst others will get the zero crossing point.

The Pi will quite happily munch through H264 encoding at 1080p. FFmpeg has the h264_omx plugin to use OpenMax IL to access the hardware acceleration for codecs. It's little different from the Rock64 in that regard. Both are quad A53's, and the boost from 1.4GHz to 1.5GHz will be minimal. eMMC will be a bit faster than an SD card, so use a USB drive instead. 4GB of RAM vs 1GB will have minimal effect for video transcode.

framerate is independent of exposure time, although it does set the maximum exposure time possible (it can't exceed the frame time).

exposure_compensation will do nothing if you've set exposure_mode to off. Same as a heating thermostat will do nothing if you've turned the boiler off at the mains.
Software Engineer at Raspberry Pi Trading. Views expressed are still personal views.
I'm not interested in doing contracts for bespoke functionality - please don't ask.

Return to “Camera board”