HermannSW
Posts: 1193
Joined: Fri Jul 22, 2016 9:09 pm

Raspberry v1 camera global (external) shutter videos

Sun May 26, 2019 3:08 pm

I wanted to start this thread when I have more stable tools to share, allowing you to capture global shutter videos with any v1 camera (clone). But I started to spread information and captured frames in different postings/threads already, and now it is time to start this thread. The complete tools will be provided later.

This thread is a followup thread on "ArduCam OV5647 Camera Board w/ M12 Mount"
viewtopic.php?f=43&t=235523
where I made global shutter videos with Arducam ov5647 camera. That camera is like v1 camera (both are based on ov5647), but with exposed FREX and STROBE pins, which I used for global shutter videos.

In thread "Re: pigpio C sub µs single pulse generation" I was able to generate 9× multi exposure frame of propeller rotating with 22000rpm (>35.5m/s at blade tips), with strobe pulse duration of 9µs, 116µs apart:
viewtopic.php?f=33&t=241151&p=1472384#p1472786
Image


In old posting "Re: Is there any photo/video of flying rifle bullet done with v2 camera?"
viewtopic.php?f=43&t=234416&p=1443728&h ... e#p1441533
I described my at that point new airsoft pistol and measurements, which led to a potential calculated speed of 92.8m/s.

Today I did capture for the first time flying 6mm diamter yellow bullet in flight after being shot with that pistol. If I would have used the waveform fixed number of flash pulses technique from above posting, I would had to have a synchronization between shoot and video capturing. Instead I used PWM to generate the flashes this time. I moved all equipment from top of plexiglas on my Motor Test Station down to the flow. The camera was directed so that there was no obstacle before big black shelf 4m distant (in order to minimize unwanted light sources). And I switched to 20° lens. Then I calculated (on the wrong assumption of 92.8m/s) what frequency I would need. I ended up with 3kHz, and 2.5% duty cycle, which results in 8.33µs strobe pulse duration. In order to not affect AWB I did emit the PWM signal only for 2 seconds, and after having started the command and the 5000lm led with reflector emitted bright light, I triggered the shot (video was captured with raspivid and "-fps 1"):

Code: Select all

$ pigs hp 13 3000 25000; sleep 2; pigs hp 13 0 0

Below is not perfect, just the first capture of flying bullet, not sharp because lens was not adjusted well, but it is a prove that capturing (rifle) bullets in flight is possible with v1 camera!

Just later I realized that the frame allowed me to roughly estimate the bullet speed while flying through camera view! The bullet diameter is 6mm, and I used gimp to measure diameter of bullet as 357 pixel. The distance from left side of 2nd to left side of 3rd bullet in frame was 563 pixels. It tuned out that the bullet (at least in view of camera) speed was much lower than hoped for:

Code: Select all

(563/357*0.006)*3000 = 28.38m/s

There is no problem to get enough speed, a friend has three air rifles of different speeds, that will be done later, after having provided the needed tools for taking global shutter videos with v1 camera.

Here you can see the 2MP global shutter frame copied into 5MP photo of the setup on floor. I will have to reduced the setup so that it will become mobile and I can take it to friend with air rifles, or later to gun club for higher speed bullet capturing:
Image
Last edited by HermannSW on Mon May 27, 2019 7:35 am, edited 1 time in total.
bookmark list: https://stamm-wilbrandt.de/en/Raspberry_camera.html

https://github.com/Hermann-SW/Raspberry_v1_camera_global_external_shutter
https://github.com/Hermann-SW/fork-raspiraw
https://github.com/Hermann-SW/userland
https://twitter.com/HermannSW

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

Re: Raspberry v1 camera global shutter videos

Sun May 26, 2019 3:50 pm

Global reset, not global shutter.
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.

HermannSW
Posts: 1193
Joined: Fri Jul 22, 2016 9:09 pm

Re: Raspberry v1 camera global (external) shutter videos

Sun May 26, 2019 8:29 pm

6by9 wrote:
Sun May 26, 2019 3:50 pm
Global reset, not global shutter.
Sorry, this is correct:
v1 camera global reset + single digit microsecond strobe pulse duration + dark scene ≡ global shutter

When strobe flash is off after pulse, and scene is dark, then there is no difference to global shutter.
I just close door of room and window shutter completely to get it really dark.
Only during strobe pulse there is very bright light for few microseconds.
When strobe is off there is no light that can accumulate.

The same is true when there are 3000 strobe pulses of length 8.33µs during 1 second frame capturing for 1 fps.


P.S:
The difference to a real global shutter camera as eg. ov7251 camera is that ov7251 can take global shutter videos at daylight, while the technique described in this thread only works for completely dark scene.

This is a single exposure frame (lens is not as nicely focussed ad in previous 9× exposure), no difference to a global shutter camera frame for same scene (very fast rotating propeller):
Image


P.P.S:
In multi airsoft bullet frame the bullets are brighter at bottom than on top. Reason is, that 5000lm led plus reflector send very bright light straigt up. I did shoot the bullet through camera view from right to left, this is captured 2MP frame:
Image
Last edited by HermannSW on Mon May 27, 2019 7:35 am, edited 1 time in total.
bookmark list: https://stamm-wilbrandt.de/en/Raspberry_camera.html

https://github.com/Hermann-SW/Raspberry_v1_camera_global_external_shutter
https://github.com/Hermann-SW/fork-raspiraw
https://github.com/Hermann-SW/userland
https://twitter.com/HermannSW

jamesh
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 22049
Joined: Sat Jul 30, 2011 7:41 pm

Re: Raspberry v1 camera global shutter videos

Mon May 27, 2019 6:22 am

The sensors do not have a global shutter, so you are simulating the effects of a global shutter using extra equipment. Title should probably reflect that.
Principal Software Engineer at Raspberry Pi (Trading) Ltd.
Contrary to popular belief, humorous signatures are allowed. Here's an example...
"My grief counseller just died, luckily, he was so good, I didn't care."

HermannSW
Posts: 1193
Joined: Fri Jul 22, 2016 9:09 pm

Re: Raspberry v1 camera global (external) shutter videos

Mon May 27, 2019 7:36 am

jamesh wrote:
Mon May 27, 2019 6:22 am
The sensors do not have a global shutter, so you are simulating the effects of a global shutter using extra equipment. Title should probably reflect that.
Done, thanks for guidance:
v1 camera global reset + single digit microsecond strobe pulse duration + dark scene ≡ global (external) shutter
bookmark list: https://stamm-wilbrandt.de/en/Raspberry_camera.html

https://github.com/Hermann-SW/Raspberry_v1_camera_global_external_shutter
https://github.com/Hermann-SW/fork-raspiraw
https://github.com/Hermann-SW/userland
https://twitter.com/HermannSW

HermannSW
Posts: 1193
Joined: Fri Jul 22, 2016 9:09 pm

Re: Raspberry v1 camera global (external) shutter videos

Mon May 27, 2019 5:06 pm

Essential for global (external) shutter v1 camera videos is that the scene is dark. If you are somewhere where you cannot make everything dark by closing doors and window shutters, a moving box still allows you to do experiments. Of course a complete dark room is better, doing 3000 single digit µs strobe pulses (as done yesterday for capturing airsoft pistol bullet) inside the moving box just captures completely white images. But fixed number multiple exposure works surprisingly good inside moving box.

This is the reduced setup, a Pi3B, v1 camera, 5000lm led with reflector, mini drone propeller, logic analyzer (not used yet), 50W led driver, two 24V IRF520 mosfets in series for driving the led from 38V/1.5A of led driver:
Image


This is same scene, just covered with moving box:
Image


This is a sample 5× multiple exposure frame from inside moving box, I had awaited worse result for capturing 22000rpm rotating propeller:
Image
bookmark list: https://stamm-wilbrandt.de/en/Raspberry_camera.html

https://github.com/Hermann-SW/Raspberry_v1_camera_global_external_shutter
https://github.com/Hermann-SW/fork-raspiraw
https://github.com/Hermann-SW/userland
https://twitter.com/HermannSW

HermannSW
Posts: 1193
Joined: Fri Jul 22, 2016 9:09 pm

Re: Raspberry v1 camera global (external) shutter videos

Wed May 29, 2019 12:16 am

I hope to be able to post the tools with a meaningful README.md tomorrow on github and link here (raspivid_ges/raspividyuv_ges, shot, shots and toFrames). "shots" tools allows to specify how many flashes are done repeatedly, and the last image captured with 5 repeats is just the default if calling "shots" without argumemts. As experiment I did modify "shots" in emitting flashes with 1/3/5/7/9µs strobe duration, this allows nicely to see the different amount of light captured with each strobe pulse length setting (the reflecting black tape behind the rotating propeller sees 1+3+5+7+9=25µs strobe duration in total and shines through brighter because of that longer strobe pulse total time (it is really time for Black 3.0 to arrive, that will eliminate any reflection from behind the propeller):
Image


P.S:
This is nearly final "raspivid_ges", it does three things automatically:
  • starts raspivid in background (with default parameters, or passed parameters)
  • emits 2s duration strobe flash to make "-awb flash" work nicely
  • injects the needed v1 camera I2C register settings (less than needed with Arducam ov5647 camera)
No need to set FREX mode strobe or shutter duration settings as they seem to have no meaning when taking global reset frames with raspivid if not trigging frex_i2c frame generation "manually" but rely on normal raspivid operation:

Code: Select all

#!/bin/bash
args="-md 1 -p 10,10,960,540 -fps 1 -awb flash -o tst.h264 -t 0"
if [ "$*" != "" ]; then args=$*; fi

cmd=raspivid
if [ "$0" = "raspividyuv_gs" ]; then cmd=raspividyuv; fi

if [ ! -f /var/run/pigpio.pid ]; then sudo pigpiod; sleep 0.5; fi

( pigs m 13 w; pigs w 13 1; sleep 2; pigs w 13 0 ) &

$cmd $args &
PID1=$!

sleep 0.4
pigs i2cc 0  2>/dev/null >/dev/null
set -e
h=`pigs i2co 0 0x36 0`
pigs i2cwd $h  0x30 0x02  0xff       # enable frex mode
pigs i2cwd $h  0x3b 0x06  0x10 0x1d  # frex_ctrl+mode

wait $PID1

P.P.S:
Yesterday I did lots of runs, perhaps the led/passive heatsink had different temperature. Today I just powered led driver, started raspivid_ges ("_ges" for "global external shutter") and did run "./5shots" as yesterday. This time the lighting is different (perhaps I did kick the moving box setup accidentally since last recording). Although the 1µs duration strobe pulse blades are hardly to see, they are there (it is easier to see the lower left one of the two 1µs blades, the blade with reflective marker can be seen 5 times):
Image
bookmark list: https://stamm-wilbrandt.de/en/Raspberry_camera.html

https://github.com/Hermann-SW/Raspberry_v1_camera_global_external_shutter
https://github.com/Hermann-SW/fork-raspiraw
https://github.com/Hermann-SW/userland
https://twitter.com/HermannSW

HermannSW
Posts: 1193
Joined: Fri Jul 22, 2016 9:09 pm

Re: Raspberry v1 camera global (external) shutter videos

Wed May 29, 2019 10:31 pm

I had to work late unexpectedly and will not complete github post today.
But I started the setup and used shots tool to create two 9µs width strobe pulses, 0.9s apart.
Since raspivid_ges runs with "-fps 1" by default, most times the first flash happens on one tst.h264 frame captured, and the 2nd flash happens on the next frame. But after 15 attempts I was successful and captured both flashes on same frame (./shots 2 9 900000):
Image


P.S:
If really needed I could use second of Raspberry camera hardware sync pulses (which is short before start of new frame capturing) in order to synchronize starting strobe waveform when new frame just had begun:
viewtopic.php?f=43&t=190314
bookmark list: https://stamm-wilbrandt.de/en/Raspberry_camera.html

https://github.com/Hermann-SW/Raspberry_v1_camera_global_external_shutter
https://github.com/Hermann-SW/fork-raspiraw
https://github.com/Hermann-SW/userland
https://twitter.com/HermannSW

HermannSW
Posts: 1193
Joined: Fri Jul 22, 2016 9:09 pm

Re: Raspberry v1 camera global (external) shutter videos

Thu May 30, 2019 11:43 pm

OK, I did push tools and an initial README.md with many examples to github, will polish README.md later:
https://github.com/Hermann-SW/Raspberry ... al_shutter

Now you have everything to do v1 camera global external shutter videos yourself.

Tool toFrames converts .h264 video recorded by tool raspivid_ges into frames (frame0000.jpg, frame0001.jpg, ...) using ffmpeg:

Code: Select all

#!/bin/bash
V=tst.h264
if [ "$1" != "" ]; then V=$1; fi
rm -f frame*.jpg
ffmpeg -i $V frame%04d.jpg -hide_banner

P.S:
I added old animated .gif taken with (long) 36µs strobe pulse length of propeller rotating with 26000rpm to github repo (1 second from 25fps video, converted into an animated .gif playing at 5fps; this allows to really see each single global shutter frame, as well as to see that the other propellers+motors are heavily shaken by the front propeller wind):
Image
bookmark list: https://stamm-wilbrandt.de/en/Raspberry_camera.html

https://github.com/Hermann-SW/Raspberry_v1_camera_global_external_shutter
https://github.com/Hermann-SW/fork-raspiraw
https://github.com/Hermann-SW/userland
https://twitter.com/HermannSW

HermannSW
Posts: 1193
Joined: Fri Jul 22, 2016 9:09 pm

Re: Raspberry v1 camera global (external) shutter videos

Tue Jun 04, 2019 9:15 am

HermannSW wrote:
Wed May 29, 2019 10:31 pm
P.S:
If really needed I could use second of Raspberry camera hardware sync pulses (which is short before start of new frame capturing) in order to synchronize starting strobe waveform when new frame just had begun:
viewtopic.php?f=43&t=190314
Successfully done:
viewtopic.php?f=43&t=190314&p=1476254#p1476254


Added a lot to github repo over the weekend, this is current table of content:
https://github.com/Hermann-SW/Raspberry ... al_shutter
Image


It is not expensive, from "Setup for global external shutter" section:
Image
bookmark list: https://stamm-wilbrandt.de/en/Raspberry_camera.html

https://github.com/Hermann-SW/Raspberry_v1_camera_global_external_shutter
https://github.com/Hermann-SW/fork-raspiraw
https://github.com/Hermann-SW/userland
https://twitter.com/HermannSW

HermannSW
Posts: 1193
Joined: Fri Jul 22, 2016 9:09 pm

Re: Raspberry v1 camera global (external) shutter videos

Tue Jun 04, 2019 4:16 pm

The smaller the distance from led to object, the more lumens from same 5000lm led.

I did remove the reflector and placed the propeller directly above the 5000lm led.
The Raspberry v1 camera captures from below led level slightly upwards:
Image


Captured frames look brighter than with reflector, nice:
Image


I don't know when my Black 3.0 (the blackest black) 150ml bottle will arrive, but now would be a good time. I hope that the light reflection from black tape behind propeller will be totally eliminated when tape or cardboard painted with Black 3.0 behind the propeller will be used.
bookmark list: https://stamm-wilbrandt.de/en/Raspberry_camera.html

https://github.com/Hermann-SW/Raspberry_v1_camera_global_external_shutter
https://github.com/Hermann-SW/fork-raspiraw
https://github.com/Hermann-SW/userland
https://twitter.com/HermannSW

HermannSW
Posts: 1193
Joined: Fri Jul 22, 2016 9:09 pm

Re: Raspberry v1 camera global (external) shutter videos

Tue Jun 04, 2019 9:15 pm

I did redo the airsoft pistol flying bullet capturing as described before. This time I made sure that camera lens was adjusted to where the bullet would pass. And I increased lumens by shooting directly above the 5000lm led without reflector as described in previous posting. I just used tool "pwm_ges" without arguments (default parameters) and got very impressive 2MP frames. 3000 pulses of 8.33µs length result in a quite bright overall image of the room. And the bullets look really good (I did not move out the propeller used sofar completely from view, you can see part of it top left very bright).

This was the first shot, I will talk on the bullets below. I cannot tell what the interesting curves are made of, perhaps hot air, dust, ... . The 3000 exposures in a single frame cover roughly roughly one second (because of "-fps 1"):
Image


The second shot has less curves, but nicer bullets, and they pass the 5000lm led in less distance:
Image


I did measure the length from left border of 1st to left border of 8th bullet in both images, both are identical 1686 pixels. Then I measured the 6mm diameter bullet's diameter and got 135 pixels. The speed this time is higher than the previous recording, (1686/7)/135*6*3000=32.1m/s. The bullet passes the complete horizontal view in 1920/(1686/7)*8.33=66.4µs.


When Black 3.0 will have arrived I will test to paint some cardboard with it, and place it behind the bullet trajectory. If it really does not reflect, the captured frame will be much darker and only the lighted bullet will be seen.

Now its time to contact friend for experiments with air gun. That should provide much higher muzzle speed (above 100m/s, perhaps even >200m/s) than the airsoft pistol.


P.S:
The bullet passes through view from right to left. I measured the bottom point y-coordinate (top is 0) of each bullet for 2nd frame, from right to left:

Code: Select all

684, 709, 726, 739, 748, 749, 746, 738 
Interesting is that first the y-coordinate increases exposure by exposure, but finally decrease. Can it be that the 0.12g only bullet gets uplift from the warm 5000lm led?
bookmark list: https://stamm-wilbrandt.de/en/Raspberry_camera.html

https://github.com/Hermann-SW/Raspberry_v1_camera_global_external_shutter
https://github.com/Hermann-SW/fork-raspiraw
https://github.com/Hermann-SW/userland
https://twitter.com/HermannSW

HermannSW
Posts: 1193
Joined: Fri Jul 22, 2016 9:09 pm

Re: Raspberry v1 camera global (external) shutter videos

Wed Jun 05, 2019 7:35 am

HermannSW wrote:
Tue Jun 04, 2019 9:15 pm
P.S:
The bullet passes through view from right to left. I measured the bottom point y-coordinate (top is 0) of each bullet for 2nd frame, from right to left:

Code: Select all

684, 709, 726, 739, 748, 749, 746, 738 
Interesting is that first the y-coordinate increases exposure by exposure, but finally decrease. Can it be that the 0.12g only bullet gets uplift from the warm 5000lm led?
I used an online tool and found a nicely fitting 2nd degree polinomial for the y-coordinates:

Code: Select all

f(t) = 655.268 + 31.792 × t - 2.685 × t²
Either there is some kind of force directed upwards (frame y-coordinates are 0 at top), or the bullet leaves the airsoft pistol with some (upward) spin.
Image


Nice, I did cut out just the bullets from captured 2MP frame, scaled vertically by factor 8 and resized proportionally with gimp. Now the quadratic curve can be "seen" for the bullet bottoms as well ...
Image
bookmark list: https://stamm-wilbrandt.de/en/Raspberry_camera.html

https://github.com/Hermann-SW/Raspberry_v1_camera_global_external_shutter
https://github.com/Hermann-SW/fork-raspiraw
https://github.com/Hermann-SW/userland
https://twitter.com/HermannSW

HermannSW
Posts: 1193
Joined: Fri Jul 22, 2016 9:09 pm

Re: Raspberry v1 camera global (external) shutter videos

Wed Jun 05, 2019 3:13 pm

Wow, I found a solution that does not need Black 3.0 and still make the background dark!
I cannot change the PWM frequency because that determines the distance the bullets get captured in.
Therefore there will be 3000 strobe pulses per second.

But there is a simple trick to reduce the total eposure per frame -- increase raspivid_ges framerate to 30fps!
With 30 fps only 100 strobe pulses light the background.
And that is low enough that I was able to capture propeller inside moving box (that results in white frame with 3000 strobe pulses).

The propeller runs with around 20000rpm, that is 20000/60=333 rotations per second.
Capturing video with 30fps results in 11 strobe pulses per frame:

Code: Select all

$ ./raspivid_ges -md 1 -p 10,10,960,540 -fps 30 -awb flash -o tst.h264 -pts tst.pts -t 0

While the propeller image is not that nice, the inside moving box background is dark!
Image


With slight changes in propeller rpm some frames look sharp in addtion to dark background:
Image


As can be seen in command above I did use "-pts" option for generating time stamps.
Only 7 frame skips with 308 frames in total:

Code: Select all

$ ptsanalyze tst.pts 0
creating tstamps.csv
308 frames were captured at 30fps
frame delta time[us] distribution
      1 33305
      1 33307
      7 33308
     17 33309
     44 33310
     74 33311
     84 33312
     37 33313
     21 33314
      8 33315
      2 33316
      2 33317
      1 66620
      2 66623
      2 66625
      1 199869
      1 199870
after skip frame indices (middle column)
> 66623,1765513
> 66625,3297847
> 199869,3497716
> 66625,3564341
> 66620,3630961
> 199870,6962117
> 66623,7028740
7 frame skips (2%)
$

Now it is time to redo airsoft bullet shot from last night with capturing framerate 30fps ...
bookmark list: https://stamm-wilbrandt.de/en/Raspberry_camera.html

https://github.com/Hermann-SW/Raspberry_v1_camera_global_external_shutter
https://github.com/Hermann-SW/fork-raspiraw
https://github.com/Hermann-SW/userland
https://twitter.com/HermannSW

HermannSW
Posts: 1193
Joined: Fri Jul 22, 2016 9:09 pm

Re: Raspberry v1 camera global (external) shutter videos

Wed Jun 05, 2019 5:04 pm

I did redo the airsoft pistol shots, now with 30fps capturing framerate, 100 strobe pulses per frame and (really) dark background (the same as yesterday, wardrobe at end of the room), and I have to say wow!

I did capture 3 shots, in more than 2 minutes, 4261 frames in total. This is the first shot where I intentionally did move small part of the airsoft pistol into view. No need to describe the direction of bullet flight for this frame ;-) and new speed record (measured between left sides of 1st and 2nd bullet near muzzle). This speed should be roughly muzzle velocity. At frame bottom you can see the 5000lm led:

Code: Select all

(236px / 117px) × 6mm × 3000Hz = 36.3m/s
Image


The 2nd shot is an example that a shot might get split onto two frames (probability for that increased by factor 30 caused by framerate increase). Slightly slower with 35.8m/s, but the measurement is done for bullets further away from muzzle:
Image


The 3rd shot is even a little slower with 34.4m/s, but it has a surprise ...
Image


... I did shoot over the 5000lm led without any means to capture the bullets. The bullet from 3rd shot got reflected several times and came back from top left going down direction right. Because of the much slower speed the bullets overlap and draw a trajectory line. The frame does not show complete traversal through camera view, the little part missing can be found on next frame. The shot frame and return frame are 6 frames apart, that is 6/30=0.2s:
Image


Summary:
  • 30fps framerate does wonder in keeping background dark for 3kHz PWM strobe pulses
  • shooting directly above 5000lm led without reflector is best for maximizing lux
  • from today's video I can see that the lines in yesterday's capture were created from dust particles

I am just waiting for call from friend to borrow one of his air guns ...


P.S:
I copied out 3 bullets from 1st shot, copied them together and scaled the image by factor 2. The details are not very nice, but this happens with only 9µs strobe pulse lighting for each:
Image
bookmark list: https://stamm-wilbrandt.de/en/Raspberry_camera.html

https://github.com/Hermann-SW/Raspberry_v1_camera_global_external_shutter
https://github.com/Hermann-SW/fork-raspiraw
https://github.com/Hermann-SW/userland
https://twitter.com/HermannSW

HermannSW
Posts: 1193
Joined: Fri Jul 22, 2016 9:09 pm

Re: Raspberry v1 camera global (external) shutter videos

Thu Jun 06, 2019 4:34 pm

My friend said "nice bullets in capture, but they are dark on top -- why not use a 2nd led from top?".

And I did exactly that now, added 2nd 50W led driver, and 2nd 5000lm led. This is the setup, both 50W led drivers parallel into the IRF520 mosfet chain, and that drives the parallel connected leds which are intentionally not parallel in order to guarantee that no direct light from the leds can hit the v1 camera in the back. The bullet hanging at thin wire so that it has same distance to both leds is only used for testing below:
Image


And this is a frame created with "shot" tool, a single 9µs strobe pulse -- nice:
Image


What you can see in addition to the bullet (wire, lego piece, third hand) will be removed for real shots and background will be dark again.


P.S:
I did two aisoft shots with new two 5000lm led setup just to verify that bullets are lit well when shooting throgh the leds. Unfortunately I moved the long camera cable too near to the cables that deliver 38V/3A to the two 5000lm leds. So not a nice frame, but proof that the bullets are lit well with the new setup:
Image
bookmark list: https://stamm-wilbrandt.de/en/Raspberry_camera.html

https://github.com/Hermann-SW/Raspberry_v1_camera_global_external_shutter
https://github.com/Hermann-SW/fork-raspiraw
https://github.com/Hermann-SW/userland
https://twitter.com/HermannSW

HermannSW
Posts: 1193
Joined: Fri Jul 22, 2016 9:09 pm

Re: Raspberry v1 camera global (external) shutter videos

Thu Jun 06, 2019 9:21 pm

OK, I did capture the first two shots with airgun of friend and flat diabolo pellets.

First I used "pwm_ges" tool without arguments, the default values are 8.33µs strobe pulses at 3kHz PWM frequency.
Only two diabolos got captured -- that is good because it means the airgun is much faster than my airsoft pistol:
Image


The capture was lucky in that only part of the (most likely oil cloud) got captured only half and the diabolos show nicely. The next frame shows the other half of the cloud:
Image


I did measure distance between head middle of both pellets as 881px, and length of (5mm long) pellet as 121px (with gimp). That allows to determine muzzle speed as 109.2m/s(!):

Code: Select all

(881px / 121px) × 5mm × 3000Hz = 109.2m/s (393km/h)

I took a second shot, again without airgun being fixed. I was lucky that pellet did miss the lower 5000lm led. This time I used 12kHz PWM frequency and increased duty cycle to 10% for keeping 8.33µs strobe pulses as before. Because now 400 strobe pulses happen per (30fps) frame, the background is not dark anymore. There are much more pellets in this frame, unfortunately some of them are hidden by oil cloud:
Image


The oil cloud did hit the lower led and the effect was impressive, although none of the two leds got damaged. This youtube video played at 1fps instead 30fps shows the "bright explosion":
https://www.youtube.com/watch?v=7czphp_ ... e=youtu.be


In order to keep leds safe, next shots will have to be done with airgun fixed at desk or somewhere else.
bookmark list: https://stamm-wilbrandt.de/en/Raspberry_camera.html

https://github.com/Hermann-SW/Raspberry_v1_camera_global_external_shutter
https://github.com/Hermann-SW/fork-raspiraw
https://github.com/Hermann-SW/userland
https://twitter.com/HermannSW

HermannSW
Posts: 1193
Joined: Fri Jul 22, 2016 9:09 pm

Re: Raspberry v1 camera global (external) shutter videos

Fri Jun 07, 2019 1:22 pm

I did use cardboard box of a toaster for catching the pellets after they flew through camera area of view. I did put some newspapers inside, in addition to the remainder stuff from toaster. From all test shots done yesterday (the first ones without v1 camera capturing) only one flat pellet (middle) made it through the back of the box, but then just fall to ground immediately after the box. Traversing the box cardboard and newspapers deformed the pellet (left). I did not use the pointed pellet (right) sofar:
Image


I don't see stretching in the pellets of 1st frame in previous posting. But if the lighting of the strobe pulse length 8.33µs would really make the pellet look longer, since pellet does fly roughly 0.1mm per µs, its length would be 5mm + 8.33µs × 0.1mm/µs = 5.833mm, and the speed would be even higher (I am happy with >100m/s already):

Code: Select all

(881px / 121px) × 5.833mm × 3000Hz = 127.4m/s (458km/h)


My friend proposed to shoot through a stretched piece of paper and capture the pellet with v1 camera behind the paper. Of course that will reduce pellet speed, but since the pellet will create a hole that just allows the pellet to fly through, most of the oil cloud should remain behind the paper, and what comes through the hole should stay behind the pellet. That is worth a try to get clear multiple pellets capture frame.


Wikipedia shows a 4.5mm pellet exiting an air pistol, photographed with a high speed air-gap flash. As far as I understand such a flash cannot be reloaded in sub millisecond range. Therefore you get "a" brighter and shorter strobe pulse than with the self made 5000lm led flash I use, but that does not allow for the PWM multiple exposure possible with the self made flash (100 strobe pulses for the first pellet capture frame, 400 for the second):
https://en.wikipedia.org/wiki/Pellet_(air_gun)
bookmark list: https://stamm-wilbrandt.de/en/Raspberry_camera.html

https://github.com/Hermann-SW/Raspberry_v1_camera_global_external_shutter
https://github.com/Hermann-SW/fork-raspiraw
https://github.com/Hermann-SW/userland
https://twitter.com/HermannSW

HermannSW
Posts: 1193
Joined: Fri Jul 22, 2016 9:09 pm

Re: Raspberry v1 camera global (external) shutter videos

Fri Jun 07, 2019 11:55 pm

HermannSW wrote:
Thu Jun 06, 2019 9:21 pm
In order to keep leds safe, next shots will have to be done with airgun fixed at desk or somewhere else.
Since I am not experienced with airgun recoil, I looked at the frames captured for 1st airgun shot and created a youtube video played at 1fps, 30× slowed down compared to original. It shows only minimal recoil although I did not hold the airgun but let it lie with muzzle on some boxes with some sheets of paper on top for the needed height, and triggered the shot with just 1 hand and airgun not at shoulder. Should be no problem to fix the airgun to desk given that small recoil seen:
https://www.youtube.com/watch?v=sANnt-o ... e=youtu.be


I created the .ogg file uploaded to youtube with gstreamer as in the last lines of raw2ogg2anim tool, just for jpeg instead of png:
https://github.com/6by9/raspiraw/blob/m ... w2ogg2anim

Code: Select all

$ gst-launch-1.0 multifilesrc location="frame%04d.jpg" index=1560 caps="image/jpeg,framerate=\(fraction\)1/1" ! jpegdec ! videorate ! videoconvert ! videorate ! theoraenc ! oggmux ! filesink location="l.ogg"

I used modified gifenc.sh from that tool to create this animated gif scaled down 3× at 1fps from the .ogg video:

Code: Select all

$ diff ~/fork-raspiraw/tools/gifenc.sh gifenc.sh 
9c9
< filters="fps=25,scale=640:-1:flags=lanczos"
---
> filters="fps=1,scale=640:-1:flags=lanczos"
$ 
Image
bookmark list: https://stamm-wilbrandt.de/en/Raspberry_camera.html

https://github.com/Hermann-SW/Raspberry_v1_camera_global_external_shutter
https://github.com/Hermann-SW/fork-raspiraw
https://github.com/Hermann-SW/userland
https://twitter.com/HermannSW

HermannSW
Posts: 1193
Joined: Fri Jul 22, 2016 9:09 pm

Re: Raspberry v1 camera global (external) shutter videos

Sun Jun 09, 2019 1:02 pm

My friend told me, that his friend who is member of a gun club had another explanation for the fog seen (instead of oil):
condensation by negative pressure or pressure relief of the air in the pipe
bookmark list: https://stamm-wilbrandt.de/en/Raspberry_camera.html

https://github.com/Hermann-SW/Raspberry_v1_camera_global_external_shutter
https://github.com/Hermann-SW/fork-raspiraw
https://github.com/Hermann-SW/userland
https://twitter.com/HermannSW

HermannSW
Posts: 1193
Joined: Fri Jul 22, 2016 9:09 pm

Re: Raspberry v1 camera global (external) shutter videos

Mon Jun 10, 2019 8:12 pm

Quite some time ago I described somewhere to use two PIs, the first Pi0 using high framerate raspivid to detect bullet in frame, and that Pi0 signalling the 2nd Pi to trigger a single global external shutter shot.

I thought about a visual trigger for capturing bullets again, this time with just one Pi and one camera. I wanted to do high framerate capturing with raspiraw for determining when bullet hits the camera view the first time, and then capture the bullet with 2MP in next frame. Unfortunately I found no way to have both, raspiraw and raspivid together (and starting anything is way too slow for next frame capture of bullet). So I wanted to do bullet detection and final global external reset capture both with raspiraw.
So the 1st question to answer was whether v1 camera global reset mode works with raspiraw.
I modified raspiraw and added "-gr" option for global reset. I had to add registers 0x3b0[67] to ov5647.h mode 7 because they were not present. I made raspiraw "-gr" write the same 3 registers that set global reset mode for "raspivid_ges" tool:
https://github.com/Hermann-SW/Raspberry ... id_ges#L21

Then I modified 640x128 tool (350fps) and added "-eus 800" and "-gr", and captured a closing mouse trap.
Unfortunately the animated .gif generated from mouse trap bar closing still shows the extreme rolling shutter effect (diagonal bar), which shows that at least with these three register settings (unlike raspivid_ges tool) do not enable global reset mode for raspiraw:
Image


Summary:
raspiraw does not allow for v1 camera global reset mode.
Visual trigger of single global external shutter shot requires a 2nd Pi and a second v1 or v2 camera for high framerate bullet detection and triggering.
One advantage of 2nd camera is that it could trigger bullet quite some distance before the global external reset camera so that the 2MP frame captured with global external reset could have a frame filling picture of the bullet if camera is focused for that.

P.S:
This visual triggering is only needed if eg. shooting through an apple and the global external shutter capture should happen with bullet a fixed distance after passing the apple. For just capturing bullet leaving apple PWM multiple exposure is good enough. If frequency is chosen so that distance of two bullet capturings is greater than 1080px, only one bullet will show up in frame.
bookmark list: https://stamm-wilbrandt.de/en/Raspberry_camera.html

https://github.com/Hermann-SW/Raspberry_v1_camera_global_external_shutter
https://github.com/Hermann-SW/fork-raspiraw
https://github.com/Hermann-SW/userland
https://twitter.com/HermannSW

HermannSW
Posts: 1193
Joined: Fri Jul 22, 2016 9:09 pm

Re: Raspberry v1 camera global (external) shutter videos

Sat Jun 15, 2019 1:41 am

HermannSW wrote:
Fri Jun 07, 2019 1:22 pm
My friend proposed to shoot through a stretched piece of paper and capture the pellet with v1 camera behind the paper. Of course that will reduce pellet speed, but since the pellet will create a hole that just allows the pellet to fly through, most of the oil cloud should remain behind the paper, and what comes through the hole should stay behind the pellet. That is worth a try to get clear multiple pellets capture frame.
As preparation I did just test clamping airgun to desk, and to shoot through stretched paper.
After loading airgun I used a screw clamp to fixate the airgun barrel on some long wooden stick onto desk.
Then I placed paper directly in front of muzzle and fixated it with one handed clamp directly at barrel.

The shots were fine, I did one with flat pellet (top), you can see quite some damage to paper from both sides.
The second shot with pointed pellet leaves much less damage to the paper.
The next global external shutter captures will show whether both or only the pointed bullet will stop the cloud seen in previous captures:
Image
bookmark list: https://stamm-wilbrandt.de/en/Raspberry_camera.html

https://github.com/Hermann-SW/Raspberry_v1_camera_global_external_shutter
https://github.com/Hermann-SW/fork-raspiraw
https://github.com/Hermann-SW/userland
https://twitter.com/HermannSW

HermannSW
Posts: 1193
Joined: Fri Jul 22, 2016 9:09 pm

Re: Raspberry v1 camera global (external) shutter videos

Sat Jun 15, 2019 1:17 pm

I did a second look at 2nd global external shutter capture of pellet a 12kHz PWM frequency.
I would have expected that the pellets (there are 4× more than in 1st capture with 3kHz PWM frequency) all are located on blue line because the pellet moved very fast (109.2m/s determined by 1st global external shutter capture):
Image


I have two possible explanations for this, not knowing what is the real explanation:
  1. The pellets missing on left side do not show up because frame transfer was at end before pellet reached there, But in that case the pellets left should be captured in next frame, but they are not.
  2. The pellet was kicked out of the blue line by the oil cloud and/or dust "explosion" just starting at that frame. On the other hand, can a 109.2m/s pellet be kicked out of linear trajectory that easily (in that case pallet can be the bright stuff above blue line left of bright cloud):
    Image
bookmark list: https://stamm-wilbrandt.de/en/Raspberry_camera.html

https://github.com/Hermann-SW/Raspberry_v1_camera_global_external_shutter
https://github.com/Hermann-SW/fork-raspiraw
https://github.com/Hermann-SW/userland
https://twitter.com/HermannSW

HermannSW
Posts: 1193
Joined: Fri Jul 22, 2016 9:09 pm

Re: Raspberry v1 camera global (external) shutter videos

Mon Jun 17, 2019 9:08 am

Family was out yesterday forenoon and I used our living room for new airgun pellet captures. All window shutters in living room and that in kitchen were closed, as well as room door and room doors upstairs for real darkness. After 1 hour of setting up the scene, testing, adjustment, just before new shots and global external shutter video captures. Airgun clamped at living room desk, paper clamped in front of muzzle in order to avoid the cloud emitting with pellet seen before. Distance from camera to grand piano is 5m, to wall behind that 7m:
Image


First I tried flat pellet, as was seen in posting showing the holes produced in paper by flat and pointed pellet, the cloud is not reduced much by the paper in front of muzzle. Paper dropped muzzle velocity by 10% (876px/132px*5mm*3000Hz=99.5m/s):
Image


This is same 3kHz PWM 8.33µs strobe pulse length setup with pointed bullet (length 8mm), the reddish seems to be some image transfer issue. Pellet appears three times (only middle full), speed this time is slower (708px/202px*8mm*3000Hz=84.1m/s):
Image


Quite some detail, this is copied out middle bullet with 1:1 display:
Image


I used this script as part of the capture procedure:

Code: Select all

$ cat doit
#!/bin/bash

./raspivid_ges -md 1 -p 10,10,640,480 -fps 30 -awb flash -o tst.h264 -t 6000 &
PID1=$!

sleep 3 && ./pwm_ges

wait $PID1
$
  • unclamp airgun
  • replace paper clamped before muzzle with new paper
  • load airgun with new pellet
  • clamp to desk
  • readjust camera view with much light on in room
  • turn off all lights
  • start script
  • during 2nd 2s phase of PWM triggered light, trigger shot

Unlike the 2MP captures before, the next captures were done with 90fps 640x480 video. The first was taken with 8.33µs strobe pulse length, the 2nd with 5.55µs. This is script diff for 2nd:

Code: Select all

$ diff doit doit90
3c3
< ./raspivid_ges -md 1 -p 10,10,640,480 -fps 30 -awb flash -o tst.h264 -t 6000 &
---
> ./raspivid_ges -md 7 -p 10,10,640,480 -fps 90 -w 640 -h 480 -awb flash -o tst.h264 -t 6000 &
6c6
< sleep 3 && ./pwm_ges
---
> sleep 3 && ./pwm_ges 9000 50000
$

Because frequency was tripled as well as framerate, background keeps dark because number of strobe pulses hitting frame remained the same (100). Much more pellets depicted, and the frame answers previous posting trajectory question and disproved the airpistol bullet upward spin assumption. The curve is not linear because of lens distortion. That can be determined/corrected with OpenCV and a chessboard. Pellet quicker this time (70px/52px*8mm*9000Hz=96.9m/s). The paper clamed at airgun muzzle reduced the cloud effect, but did not remove it completely. This is a 9000eps frame (exposures per second):
Image


In order to get less distortion I did same shot readjusted so that pellet goes more through the center, and this frame proves that this reduced distortion. As with airsoft bullet calculation done for the upward spin hypothesis, I used the pellet point coordinates and was able to get a nicely fitting 2nd degree polynopmial. Again, blueisch seems to be result of frame transmission problem. Pellets in this frame look less bright than in previous frame, so 5.55µs vs 8.33µs strobe pulse length seems to make a difference:
Image
bookmark list: https://stamm-wilbrandt.de/en/Raspberry_camera.html

https://github.com/Hermann-SW/Raspberry_v1_camera_global_external_shutter
https://github.com/Hermann-SW/fork-raspiraw
https://github.com/Hermann-SW/userland
https://twitter.com/HermannSW

Return to “Camera board”