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

HQ camera capturing inflight airgun bullet

Wed Oct 21, 2020 8:37 pm

Last year I enabled v1 camera (clone) to capture global external shutter frames.
I did capture 100m/s airgun bullet inflight multiple times, this is example with 9KHz flash frequency, with flash durations 8.33µs:
https://github.com/Hermann-SW/Raspberry ... nt-9000eps
Image


Two weeks ago I was able to capture fast rotation (20,000rpm) mini drone propeller with HQ camera with 5 flashes of 19µs duration at 4KHz:
viewtopic.php?f=43&t=284108&p=1738021#p1738021
Image


Today I started to capture airgun bullet inflight with the same method -- obviously global shutter is not needed for short duration flashes capturing fast motion. At the wall is a small cardboard box, filled densly with lots of folded newspapers as bullet catcher. I did shoot several times into it and no bullet has left the catcher on the other side. Just before is HQ camera lying flat and looking up with CStoM12 adapter, a CStoC adapter and M12 20° lense. On the right side is 5000lm led, its 38V/1.5A controlled via Mosfet from Pi4B GPIO13 connected to Mosfet module SIG pin. 9" HDMI display allows to see stuff and control everything when using the airgun. I am shooting above the M12 lense, into the bullet catcher. The depth of view is only a few millimeters, so I placed a small piece of paper with 5 digits (used in this previous posting before) above the lense in distance (hold by soldering 3rd hand), that just below it capture is sharp. That way I can just shoot below the paper to capture bullet sharply:
20201021_192200.15%.jpg
20201021_192200.15%.jpg
20201021_192200.15%.jpg (55.59 KiB) Viewed 1515 times

The camera is having its top directed to the 5000lm led. Therefore the small paper is displayed vertically. If capturing bullet, it will enter from right and leave on the left. The 20° FoV is too small for me to hit with the airgun -- I will change to 50° tomorrow morning. This is 5fps animation created from 80fps video captured. It shows that the bullet missed camera view, but that the passing bullet created air draft that did hit the white paper. It also shows that there seems to be some electrical problem in the setup (partial frames with wrong colors), maybe the 38V/1.5A DC led is too close to HQ camera:
Image


This is the script I use currently:

Code: Select all

$ cat doit80
#!/bin/bash

raspivid -md 4 -w 1012 -h 760 -fps 80 -o tst.h264 -pts tst.pts -t $(($1 * 1000 + 5000)) &
PID1=$!

sleep 2 && ./pwm_ges 9000 75000 $1

wait $PID1
$
It starts raspivid in background capturing mode 4 video at 80fps framerate.
After 2 seconds of delay, pwm_ges tool generates 9KHz PWM signal on GPIO13 with 1/9000*75000=8.33µs duration of pulses, for the time passed to doit80.
Finally script waits until raspivid has ended.


P.S:
With 100m/s speed, bullet moves 100m/s / 80Hz = 1.25m between two frames captured at 80fps framerate.
So in almost all cases bullet will be captured on one frame only.

raspivid overcomes the issue not knowing when bullet flies -- using a sound trigger is another option.

When capturing with v1 camera high PWM frequency was a problem (9KHz/90fps=100 flashes per frame, too bright photo).
With HQ camera this is unlikely to be a problem because of capturing at daylight and lux quadratically decreases with distance.

With flashes at 9KHz, bullet moves 100m/s / 9000Hz = 11.1mm between flashes.
That is fine since bullet length is 8mm, so there is no overlapping as can be seen in v1 camera 1st photo above.
https://github.com/Hermann-SW/memrun
https://stamm-wilbrandt.de/2wheel_balancing_robot
https://stamm-wilbrandt.de/en#raspcatbot
https://github.com/Hermann-SW/Raspberry_v1_camera_global_external_shutter
https://stamm-wilbrandt.de/en/Raspberry_camera.html

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

Re: HQ camera capturing inflight airgun bullet

Thu Oct 22, 2020 1:15 pm

I did rearrange the cabling a bit, made sure that flex ribbon cable is not anywhere near to AC or 38V DC cables, and mostly the electrical problems were gone. Then on first shot captured with "$ doit80 4" not all is fine. Instead of 20° M12 lense today I used 50° M12 lense to make sure that bullet passes camera FoV.

From more than 900 frames captured in tst.h264, this is the 1012x760 frame just before bullet passing FoV, all is fine:
frame.00267.png.jpg
frame.00267.png.jpg
frame.00267.png.jpg (31.86 KiB) Viewed 1431 times
This is the frame after bullet has passed FoV, paper is moving heavily du to bullet air draft:
frame.00269.png.jpg
frame.00269.png.jpg
frame.00269.png.jpg (32.13 KiB) Viewed 1431 times
And this is first frame with multiple exposure of bullet captured with HQ camera:
frame.00268.png.jpg
frame.00268.png.jpg
frame.00268.png.jpg (28.11 KiB) Viewed 1431 times
I need to figure out what electrical(?) problem is responsible for the wrong colors.
5000lm led is too far away from bullet passing FoV, that is reason for not sharply seeing the >10 exposures.
Tuning the setup is needed -- this is the first "is possible to capture inflight bullets with HQ camera at daylight" posting.
https://github.com/Hermann-SW/memrun
https://stamm-wilbrandt.de/2wheel_balancing_robot
https://stamm-wilbrandt.de/en#raspcatbot
https://github.com/Hermann-SW/Raspberry_v1_camera_global_external_shutter
https://stamm-wilbrandt.de/en/Raspberry_camera.html

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

Re: HQ camera capturing inflight airgun bullet

Thu Oct 22, 2020 1:37 pm

I brought the 5000lm led much closer to the paper (and more away from HQ camera):
20201022_152414.15%.jpg
20201022_152414.15%.jpg
20201022_152414.15%.jpg (42.94 KiB) Viewed 1414 times
And got first real multiple exposure capture of inflight bullet with HQ camera:
frame.00197.png.jpg
frame.00197.png.jpg
frame.00197.png.jpg (38.2 KiB) Viewed 1414 times
This is the airgun pointed bullet shot, 8mm long:
Image

Flash light comes from one side only, will add 2nd 5000lm led later lighting from the other side.
The paper did move nearly 180° around soldering 3rd hand by bullet air draft.
Bullet is much longer than I though on previous capture, will need to find HQ camera lens which has sharp view on shorter distance.
Last edited by HermannSW on Thu Oct 22, 2020 7:06 pm, edited 2 times in total.
https://github.com/Hermann-SW/memrun
https://stamm-wilbrandt.de/2wheel_balancing_robot
https://stamm-wilbrandt.de/en#raspcatbot
https://github.com/Hermann-SW/Raspberry_v1_camera_global_external_shutter
https://stamm-wilbrandt.de/en/Raspberry_camera.html

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

Re: HQ camera capturing inflight airgun bullet

Thu Oct 22, 2020 1:50 pm

HermannSW wrote:
Wed Oct 21, 2020 8:37 pm
I need to figure out what electrical(?) problem is responsible for the wrong colors.
That stupidly long CSI2 cable, that's what's wrong.

CSI2 has 1 bit error correction and multi-bit error detection per line. On multi-bit errors it drops the line, and therefore messes with the Bayer order which typically turns everything magenta (red & blue pixels swapped for green).
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: 4829
Joined: Fri Jul 22, 2016 9:09 pm
Location: Eberbach, Germany
Contact: Website Twitter YouTube

Re: HQ camera capturing inflight airgun bullet

Thu Oct 22, 2020 4:07 pm

6by9 wrote:
Thu Oct 22, 2020 1:50 pm
HermannSW wrote:
Wed Oct 21, 2020 8:37 pm
I need to figure out what electrical(?) problem is responsible for the wrong colors.
That stupidly long CSI2 cable, that's what's wrong.
You are right, while the frame I showed was fine, many of the other frames captured have wrong colors.
So I will replace long flex ribbon cable with original 20cm HQ camera cable.


I did use 20° and 50° M12 lenses from Arducam set because they have lowest distortion among the 6 lenses:
viewtopic.php?f=43&t=249483&p=1710529#p1674386
All multiple exposure front points do lie on a straight line.

For speed determination I measured length of bullet as well as distance between bullet fronts:
measure_speed.jpg
measure_speed.jpg
measure_speed.jpg (37.17 KiB) Viewed 1366 times
Distance between two exposure pellets is 356.7/138.2*8mm/2 = 10.32mm.
With flash frequency 9KHz that is "only" 92.9m/s speed (334.5km/h).
Most likely slower than a year ago because bullet was captured further away from muzzle this time.
https://github.com/Hermann-SW/memrun
https://stamm-wilbrandt.de/2wheel_balancing_robot
https://stamm-wilbrandt.de/en#raspcatbot
https://github.com/Hermann-SW/Raspberry_v1_camera_global_external_shutter
https://stamm-wilbrandt.de/en/Raspberry_camera.html

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

Re: HQ camera capturing inflight airgun bullet

Thu Oct 22, 2020 6:56 pm

HermannSW wrote:
Thu Oct 22, 2020 4:07 pm
6by9 wrote:
Thu Oct 22, 2020 1:50 pm
That stupidly long CSI2 cable, that's what's wrong.
You are right, while the frame I showed was fine, many of the other frames captured have wrong colors.
So I will replace long flex ribbon cable with original 20cm HQ camera cable.
I did that, moved Pi4B closer to HQ camera and used 20cm flat ribbon cable -- never saw wrong frame colors since then:
https://stamm-wilbrandt.de/en/forum/20201022_200214.jpg
20201022_200214.20%.jpg
20201022_200214.20%.jpg
20201022_200214.20%.jpg (91.51 KiB) Viewed 1330 times

I wanted to shoot bullet closer to lens and looked up the lenses I got from Lee from Arducam:
viewtopic.php?f=43&t=278432&p=1689468&h ... t#p1687207
All lenses stated MOD=0.2m or MOD=0.3m (minimum object distance)
https://www.vision-doctor.com/en/optica ... rings.html
with a single exception:
The 5mm C-mount lens has MOD=0.15m:
https://www.uctronics.com/arducam-65-de ... amera.html

I wanted to go below 15cm distance, and so I screwed out the whole lens a bit from CStoC adapter ring, increasing backfocal length. That allowed me to get 1cm sharp view just below the white paper only 2cm above foremost lens. Not sure whether that is expected, but I did some bullet shots with that setup. Finally I moved the white paper just outside camera view, so that it did not reflect so much light into the camera. This is the 1012x760 frame captured:
frame.0214.png.jpg
frame.0214.png.jpg
frame.0214.png.jpg (53.98 KiB) Viewed 1330 times
https://github.com/Hermann-SW/memrun
https://stamm-wilbrandt.de/2wheel_balancing_robot
https://stamm-wilbrandt.de/en#raspcatbot
https://github.com/Hermann-SW/Raspberry_v1_camera_global_external_shutter
https://stamm-wilbrandt.de/en/Raspberry_camera.html

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

Re: HQ camera capturing inflight airgun bullet

Fri Oct 23, 2020 12:43 pm

The last frame was captured with window shutter closed and few light besides the 9KHz flashes.

Today I did capture at daylight, although evrything further away is out of focus, daylight seems to have a positive effect on the frames captured. Here I nearly missed camera FoV:
frame.0221.png.jpg
frame.0221.png.jpg
frame.0221.png.jpg (28.27 KiB) Viewed 1259 times

Next I tested Fov and which distance to lens is captured clearly. It turned out that shooting just above the middle of the lens is what is needed. In addition the clearly exposed area is just above the lens up to 1cm height. So I completely moved away soldering 3rd hand with paper since now I know where and at which height to shoot above the lens. Just need to be careful to not shoot the lens by accident:
frame.0168.png.jpg
frame.0168.png.jpg
frame.0168.png.jpg (29.26 KiB) Viewed 1259 times

The procedure is always same, run raspivid with mode4 and "-t 0" for preview. If all is fine, stop, do a test run ("doit80 4"), then bring airgun into correct position for shoot, start doit80 again and shoot when led lights up.
Next use "ptsanalyze tst.pts" to confirm that video was captured at 80fps without frameskips.
Then do "ffmpeg -i tst.h264 frame.%04d.png".
Finally do "eog.???.png" and use cursor right key to step through the frames quickly until having noticed frame with bullet, then use cursor left key to go back to the frame with bullet.
Very seldom bullet capture might be split onto two frames, this only happend to me once for >10 shots.

Since the 5000lm led shines from one side only, a 2nd led is needed for the flashing from other side ...
https://github.com/Hermann-SW/memrun
https://stamm-wilbrandt.de/2wheel_balancing_robot
https://stamm-wilbrandt.de/en#raspcatbot
https://github.com/Hermann-SW/Raspberry_v1_camera_global_external_shutter
https://stamm-wilbrandt.de/en/Raspberry_camera.html

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

Re: HQ camera capturing inflight airgun bullet

Sat Oct 24, 2020 2:32 pm

Yesterday I replaced the (broken) 5000lm led with two working 10000lm leds for lighting from both sides. They are powered from four 50W led drivers in parallel with 194.8W:
viewtopic.php?f=43&t=284108&p=1747436#p1747436
Image


Today I did setup airgun bullet capture environment with the two 20000lm leds.
I placed HQ camera on a small construction of Lego pieces for vertical direction capturing.
The 4 parallel 50W led drivers with 100V/10A voltmeter/amperemeter are connected to 100V/9A IFR520 mosfet module.
I use the small paper with some text for lense adjustment -- now 1cm just above 5mm C-mount lense foremost lense has sharp focus:
https://stamm-wilbrandt.de/en/forum/20201024_121855.jpg
20201024_121855.15%.jpg
20201024_121855.15%.jpg
20201024_121855.15%.jpg (77.93 KiB) Viewed 1190 times

First shot was done with lense out of focus.
Second shot showed that there was dirt on the lense -- I cleaned the lense then.
3rd shot looks quite nice, lighted from two sides with 10000lm (8.33µs duration) flashes per exposure:
[with 9KHz 8.33µs duration flashes, leds are "on" for 75ms of a 1 second only, amperemeter shows 0.41A only (48.6V)]:
frame.0137.png.jpg
frame.0137.png.jpg
frame.0137.png.jpg (31.94 KiB) Viewed 1190 times

Then I tried to get bigger frames than 1012x760.
Because of .h264 limitations 4056x3040 is no option.
Maybe for same reason raspivid capturing mode2 2028x1520 just does not work.

So I played with mode2 and raspividyuv.
Result file gets huge quickly, so I stored under /dev/shm.
Because I run on 2GB Pi4B currently, that size is limited, and allows for 20fps only.
But I did 6 shots an never capture bullet, there is too much time between frames compared to mode4 80fps capturing.

I learned that conversion from yuv420p to .png is not lossles, used this ffmpeg command to convert recorded tst.yuv to frames:

Code: Select all

$ ffmpeg -pixel_format yuv420p -video_size 2048x1520 -framerate 2 -i tst.yuv -f image2 image-%3d.png

This is the 2048x1520 frame (next multiple of 32 after 2028) after bullet passed camera FoV, where you can see trajectories of some dust particles, pushed by bullet air draft:
image-067.png.jpg
image-067.png.jpg
image-067.png.jpg (94.05 KiB) Viewed 1190 times

For bigger pictures I need perhaps to go with raspistill and external triggering of sink mode HQ camera in combination with sound trigger as described here:
viewtopic.php?f=43&t=281913&p=1746481#p1746481
https://github.com/Hermann-SW/memrun
https://stamm-wilbrandt.de/2wheel_balancing_robot
https://stamm-wilbrandt.de/en#raspcatbot
https://github.com/Hermann-SW/Raspberry_v1_camera_global_external_shutter
https://stamm-wilbrandt.de/en/Raspberry_camera.html

User avatar
RichShumaker
Posts: 398
Joined: Tue Jul 31, 2012 4:16 pm
Location: Sunny Southern CA near downtown LA
Contact: Website Facebook Twitter YouTube

Re: HQ camera capturing inflight airgun bullet

Sat Oct 24, 2020 5:34 pm

frame.0137.png.jpg with the new lighting is amazing!!!
Simply awesome stuff.

I am about to switch some cameras to HDMI cables for distance runs and to keep my fat fingers from breaking CSI connectors. Not sure if you have used those in your images. I got mine from Arducam & they have a small headphone jack I was thinking of using to send the sync signal for sync'ing future HQ cameras as I only have 1 right now.
Rich Shumaker
http://www.instructables.com/id/Pi-Zero-W-NoIR-8MP-Camera-Build-Overview-Introduct/

Return to “Camera board”