Skip to content
bfboarderPublic

About

Camera per lane on a shooting range: after every series a Raspberry Pi shows the new holes, score and group on your phone. ESP32-S3 + OV5640, Flask + OpenCV.

Topics

Resources

Stars

0 stars

Watchers

1 watching

Forks

Repository files navigation

DVS CAM

Never walk 100 metres to check your target again. A small camera per lane sits on the floor in front of the target. After every series you see your card on your phone, with the new holes marked. Built for an indoor 100 m range, for calibres from .177 up.

Status: prototype, being tested. See the roadmap and the test plan.

The name on the site is DVS CAM; the wifi network, the service, the folders and this repository are called DVSCAM / dvscam (without the space).

How it works

Cameras at the cards send photos over wifi to the Raspberry Pi, which shows the new holes on phones and a screen at the firing line

  1. Camera (ESP32-S3 + OV5640, Arduino/C): takes a 5 MP (2560 × 1920) greyscale JPEG on request. 12 mm M12 lens, on the floor ~2.5 m in front of the card, ~3 px/mm. Runs on 4 × AA NiMH, straight on the 5 V pin. The camera is switched off between photos.
  2. Base unit (Raspberry Pi 3B+ or newer, Python): runs its own wifi network (access point on a USB wifi adapter), finds the card automatically, straightens it, compares it with the previous photo and marks the new holes. The black bull is measured for every card; optionally a second, longer exposure is taken for the bull only.
  3. Phone or screen: the shooter opens the Pi's website, picks their lane and taps Series done after every series. The lane page only has Series done, New card, Set up card, the card type and the calibre, which the shooter can change between series (some shoot several calibres on one card). With a card type from the list (server/targets.json: KNSA/ISSF ring sizes, e.g. Woerden 100 m, 10 m air pistol, the 12 m cards with 5 bulls) every hole gets a score: the highest ring the edge of the hole touches, with the inner ten as "10x"; the measured bull corrects the scale. By default New card recognises the card type (server/recognise.py): the camera does not move, so the lane's last set-up gives the scale; the size and number of black bulls and, for one bull, the ring lines around it (as multiples of the black's radius) pick the type, and its corners are found with its size. The shooter can also choose the card, or Other size… for any card without a score. New card checks where the card hangs: a small shift is followed automatically, a big one asks the shooter to tap Set up card (no PIN needed). Each series shows the group size (centre to centre of the two outermost holes) in mm, and in MOA and mrad when the lane's distance is set. With a distance it also gives the scope correction to move the group onto the bull, in clicks of 1/4 MOA, 1/8 MOA or 0.1 mrad (the shooter picks their scope; the phone remembers it). Edit holes fixes a series by hand: tap a false mark to remove it, tap a missed hole to add it. Hide marks shows the photo without the rings, to look at the holes themselves. Invite someone on the start page shows a QR code that puts a phone on the DVSCAM wifi and one that opens the site; a printable poster with the same codes is under Admin (wifi: in config.yaml, see config.example.yaml). Others can follow a lane on their own phone or a screen at /lane/N/watch (linked from the start page and at the bottom of the lane page): read only, it shows each new series by itself. A guide for shooters is at /help (linked from the start and lane pages; printable). The pages for shooters are in English and Dutch (switch at the top right; without a choice the phone's language is used). Adding a language is easy: see Languages.
  4. Camera test (for the range officer or admin; behind a PIN when admin_pin is set in config.yaml): status and signal strength, exposure, test photos, a wifi test, distance to the card, Set up card (automatic corners with a check) and Focus (live view with a sharpness score).

Folders

Folder Contents
server/ Web server (Flask) and image processing (OpenCV) for the Pi
esp32_arduino/ Camera firmware (Arduino/C, PlatformIO)
tools/compare.py Stand-alone test: compare two photos of a card
tools/convert_targets.py Turn a card list with Dutch keys into server/targets.json
tools/check_i18n.py Check the translations in server/i18n/, or start a new language
examples/ Generated example photos to try things right away
testdata/ Put your own test photos here (not committed)
deploy/ Start automatically on the Pi (systemd)
docs/ Test plan, images for this README
docs/reports/ White paper and roadmap (PDF + the Python scripts that make them)
hardware/lens_extender/ 3D-printed lens extender for the M12 lens (OpenSCAD, STL, generator)
hardware/housing/ 3D-printed camera and Pi housing (the STL files are in the release)

Languages

The code and the admin pages (Camera test, Focus) are in English. The pages for shooters (start page, lane page, watch page, guide) can be shown in other languages; Dutch is there now. A translation is one file:

  • server/i18n/<code>.json: the English text of the page -> the translation, plus "_name", the language's own name. Text in {braces} is filled in by the program: keep it as it is.
  • server/templates/help/<code>.html: the guide (optional; without it the English guide is shown).

To add a language, e.g. German:

python tools/check_i18n.py --new de        # server/i18n/de.json with every text, still empty
cp server/templates/help/en.html server/templates/help/de.html

Translate the values and the guide, then restart the server: the language shows up in the switch by itself. A text that is not translated yet is shown in English. python tools/check_i18n.py lists what is missing in every language (also after new features were added to the pages). New text for shooters in the code goes through _("...") in the templates, T("...") in the JavaScript, and tr("...") or abort(code, "...") in server/app.py.

Developing on your PC

python -m venv .venv
# Windows: .venv\Scripts\activate     Linux/macOS: source .venv/bin/activate
pip install -r requirements-dev.txt
cp config.example.yaml config.yaml

By default the config uses the example photos in examples/. To use your own photos, put them in testdata/, sorted by name (01_clean.jpg, 02_series1.jpg, …), and set folder: testdata in config.yaml. Start the server:

python -m server --debug

Open http://localhost:8000, choose Lane 1, go to Camera test → Set up card (the corners are found automatically), then on the lane page tap New card and then Series done. The folder of photos acts as the camera.

To test only the hole detection, without the server:

python tools/compare.py examples/02_series1.jpg examples/03_series2.jpg --corners "700,300 1900,320 2050,1650 560,1620"
# or with your own photos, clicking the corners:
python tools/compare.py testdata/clean.jpg testdata/shot.jpg --pick

On the Raspberry Pi

Raspberry Pi OS 64-bit (Bookworm, Trixie or newer). All packages come from apt, no venv needed:

sudo apt install -y python3-flask python3-opencv python3-numpy python3-yaml python3-requests

Get the code on the Pi:

git clone https://github.com/bfboarder/DVSCAM.git ~/dvscam && cd ~/dvscam
cp config.example.yaml config.yaml   # fill in the camera addresses (nano config.yaml)
python3 -m server                    # test: http://<pi-address>:8000, stop with Ctrl+C

Start automatically at boot (on port 80, so just http://<pi-address>):

sed -i "s/USER/$USER/g" deploy/dvscam.service
sudo cp deploy/dvscam.service /etc/systemd/system/
sudo systemctl enable --now dvscam
systemctl status dvscam          # should say "active (running)"
journalctl -u dvscam -f          # follow the log

Optional, for the Shut down Pi button on the start page: allow the server to switch the Pi off (only that command):

sed "s/USER/$USER/g" deploy/dvscam-shutdown.sudoers | sudo tee /etc/sudoers.d/dvscam-shutdown
sudo chmod 440 /etc/sudoers.d/dvscam-shutdown

To update: git pull && sudo systemctl restart dvscam.

Own wifi network

The Pi runs its own 2.4 GHz network for the cameras and the phones, on a USB wifi adapter (the built-in wifi stays free, e.g. for your home network). With NetworkManager (the default on Raspberry Pi OS); the adapter may have another name than wlan1, see nmcli device:

sudo nmcli con add type wifi ifname wlan1 con-name dvscam-ap autoconnect yes ssid DVSCAM   mode ap wifi.band bg wifi.channel 6   ipv4.method shared ipv4.addresses 192.168.0.1/24 ipv4.shared-dhcp-range 192.168.0.10,192.168.0.99   wifi-sec.key-mgmt wpa-psk wifi-sec.psk "<choose a password>"

The Pi is then http://192.168.0.1. Phones get an address from .10 to .99; the camera of lane N has the fixed address 192.168.0.(100 + N), so lanes 1 to 6 are .101 to .106.

Put the adapter in a USB 2 port (black, not blue on a Pi 4 or 5). In a USB 3 port the Pi 5 said the network was up, but nothing was sent: USB 3 is known to interfere with 2.4 GHz wifi. The built-in wifi also had trouble connecting while the adapter was in a USB 3 port. A USB extension cable helps too: it puts the antenna away from the Pi.

Cameras

How to build, flash and update the camera firmware is in esp32_arduino/README.md. Flash each board once over USB with its lane number; after that, updates go over wifi from the Camera test page.

Hardware (per lane)

Part Choice
Camera ESP32-S3 N16R8 with OV5640, external IPEX antenna (diymore/GoouuuTech)
Lens M12 × 0.5, 12 mm, in a printed lens extender (hardware/lens_extender/)
Power 4 × AA NiMH 2800 mAh, straight on 5 V (no alkaline: the voltage is too high)
Housing 3D print (PETG), STL files in the release, see hardware/housing/; the camera sits turned, see rotate in config.yaml

Base unit: Raspberry Pi 3B+ (1 GB is enough: a series takes ~1.5 s) with Raspberry Pi OS Lite 64-bit, and a USB wifi adapter with antenna as the access point (tested: BrosTrend AXE3000, MT7921AU). A newer Pi works the same.

Safety

  • The cameras sit on the floor, beside the line of fire. Agree on the placement with the range officer.
  • NiMH batteries, no lithium: no fire risk if a camera gets hit.
  • This system does not replace range rules: the range is only safe when the range officer says so.

Licence

DVS CAM is free and open source, and must stay that way.

  • Software (server, website, camera firmware, tools): GNU AGPL v3, see LICENSE. You may use, change and even sell it, but if you pass on a changed version, or run one for others over a network (for example as a website), you must publish its source code under the same licence.
  • 3D print files (hardware/): CC BY-SA 4.0, see hardware/LICENSE. Share and adapt them freely, give credit, and share your changes under the same licence.
  • The club logo is not part of this repository and not covered by these licences.

Copyright © 2026 DVSCAM contributors.

About

Camera per lane on a shooting range: after every series a Raspberry Pi shows the new holes, score and group on your phone. ESP32-S3 + OV5640, Flask + OpenCV.

Topics

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages