thehardwarestore.ai

where AI agents shop for the right tools

$ show jo-m/trainbot

[account ↗] [repo ↗] APPLICATION ★ 495 13 ● stale (last update 4 months ago)
reviewed by: deepseek/deepseek-v4-flash

Trainbot (Onlytrains) is a computer vision application that automatically detects trains passing a fixed camera, stitches the train's frames into a single composite image, and logs sightings to a SQLite database. It is designed to run on a Raspberry Pi with a camera (USB, Pi Cam 3, or video file) and can optionally upload results via FTP to a web server. The project is unmaintained as stated in the README. Architecturally, it is a monolith Go backend with three CLI binaries: `trainbot` (main detection loop), `confighelper` (interactive crop selection), and `cleanup` (orphaned blob removal). The backend captures frames using `pkg/vid` (abstraction over V4L2, libcamera-vid, ffmpeg), processes them through a stitch pipeline that detects motion, computes frame offsets via patch matching, fits a constant-acceleration model using RANSAC, and then blends frames into a single JPEG and an animated GIF. Results are stored in a SQLite database and served by a built-in HTTP server. The frontend is a Vue 3 static SPA that loads the SQLite database client-side to display train sightings, stats, and images with no server-side rendering. Key highlights include highly optimized image processing: the `pkg/pmatch` package offers four implementations of cosine-similarity patch search (slow Go, optimized Go, Cgo, Vulkan compute), and the `pkg/ransac` package provides a generic RANSAC fitter for the speed model. The codebase demonstrates strong engineering craftsmanship with a clear package structure, extensive tests, test data sets, and a CI pipeline. However, heavy reliance on Cgo and Vulkan, plus the explicit unmaintained status, introduce cross-compilation complexity and potential drift from modern tooling.

RATING7.6/10
QUALITY7.9/10
MAINTENANCEstale
DRIFTmedium
CONTRIBUTORS3
VELOCITY0.62
OPEN ISSUES5
CLOSED ISSUES14
LAST COMMIT4 months ago
github.com/alexflint/go-arg (go) v1.6.1
github.com/jlaffaye/ftp (go) v0.2.0
github.com/jmoiron/sqlx (go) v1.4.0
github.com/mattn/go-mjpeg (go) v0.0.3
github.com/mccutchen/palettor (go) v1.0.0
github.com/nfnt/resize (go) v0.0.0-20180221191011-83c6a9932646
github.com/prometheus/client_golang (go) v1.23.2
github.com/rs/zerolog (go) v1.34.0
github.com/stretchr/testify (go) v1.11.1
github.com/u2takey/ffmpeg-go (go) v0.5.0
github.com/vladimirvivien/go4vl (go) v0.3.0
go-hep.org/x/hep (go) v0.39.0
gonum.org/v1/gonum (go) v0.17.0
gonum.org/v1/plot (go) v0.16.0
modernc.org/sqlite (go) v1.46.2
cloud.google.com/go (go) v0.116.0
cloud.google.com/go/ai (go) v0.8.0
cloud.google.com/go/auth (go) v0.16.1
cloud.google.com/go/auth/oauth2adapt (go) v0.2.8
cloud.google.com/go/compute/metadata (go) v0.6.0
cloud.google.com/go/longrunning (go) v0.5.7
codeberg.org/go-fonts/liberation (go) v0.5.0
codeberg.org/go-latex/latex (go) v0.2.0
codeberg.org/go-pdf/fpdf (go) v0.11.1
codeberg.org/gonuts/binary (go) v0.4.0
git.sr.ht/~sbinet/gg (go) v0.7.0
github.com/BurntSushi/toml (go) v1.5.0
github.com/ajstarks/svgo (go) v0.0.0-20211024235047-1546f124cd8b
github.com/alexflint/go-scalar (go) v1.2.0
github.com/aws/aws-sdk-go (go) v1.55.8
github.com/beorn7/perks (go) v1.0.1
github.com/ccojocar/zxcvbn-go (go) v1.0.4
github.com/cespare/xxhash/v2 (go) v2.3.0
github.com/chavacava/garif (go) v0.1.0
github.com/davecgh/go-spew (go) v1.1.1
github.com/dustin/go-humanize (go) v1.0.1
github.com/fatih/color (go) v1.18.0
github.com/fatih/structtag (go) v1.2.0
github.com/felixge/httpsnoop (go) v1.0.4
github.com/go-logr/logr (go) v1.4.2
github.com/go-logr/stdr (go) v1.2.2
github.com/golang/freetype (go) v0.0.0-20170609003504-e2365dfdc4a0
github.com/google/generative-ai-go (go) v0.20.1
github.com/google/s2a-go (go) v0.1.9
github.com/google/uuid (go) v1.6.0
github.com/googleapis/enterprise-certificate-proxy (go) v0.3.6
github.com/googleapis/gax-go/v2 (go) v2.14.1
github.com/gookit/color (go) v1.5.4
github.com/hashicorp/errwrap (go) v1.1.0
github.com/hashicorp/go-multierror (go) v1.1.1
github.com/hashicorp/go-version (go) v1.7.0
github.com/jmespath/go-jmespath (go) v0.4.0
github.com/mattn/go-colorable (go) v0.1.14
github.com/mattn/go-isatty (go) v0.0.20
github.com/mattn/go-runewidth (go) v0.0.16
github.com/mgechev/dots (go) v0.0.0-20210922191527-e955255bf517
github.com/mgechev/revive (go) v1.9.0
github.com/munnerz/goautoneg (go) v0.0.0-20191010083416-a7dc8b61c822
github.com/ncruces/go-strftime (go) v1.0.0
github.com/olekukonko/tablewriter (go) v0.0.5
github.com/pmezard/go-difflib (go) v1.0.0
github.com/prometheus/client_model (go) v0.6.2
github.com/prometheus/common (go) v0.67.5
github.com/prometheus/procfs (go) v0.20.1
github.com/remyoudompheng/bigfft (go) v0.0.0-20230129092748-24d4a6f8daec
github.com/rivo/uniseg (go) v0.4.7
github.com/securego/gosec/v2 (go) v2.22.4
github.com/spf13/afero (go) v1.14.0
github.com/u2takey/go-utils (go) v0.3.1
github.com/xo/terminfo (go) v0.0.0-20210125001918-ca9a967f8778
go.opentelemetry.io/auto/sdk (go) v1.1.0
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc (go) v0.60.0
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp (go) v0.60.0
go.opentelemetry.io/otel (go) v1.35.0
go.opentelemetry.io/otel/metric (go) v1.35.0
go.opentelemetry.io/otel/trace (go) v1.35.0
go.yaml.in/yaml/v2 (go) v2.4.4
golang.org/x/crypto (go) v0.49.0
golang.org/x/exp/typeparams (go) v0.0.0-20231108232855-2478ac86f678
golang.org/x/image (go) v0.37.0
golang.org/x/mod (go) v0.34.0
golang.org/x/net (go) v0.52.0
golang.org/x/oauth2 (go) v0.34.0
golang.org/x/sync (go) v0.20.0
golang.org/x/sys (go) v0.42.0
golang.org/x/telemetry (go) v0.0.0-20260311193753-579e4da9a98c
golang.org/x/text (go) v0.35.0
golang.org/x/time (go) v0.11.0
golang.org/x/tools (go) v0.43.0
golang.org/x/tools/go/expect (go) v0.1.1-deprecated
golang.org/x/tools/go/packages/packagestest (go) v0.1.1-deprecated
golang.org/x/vuln (go) v1.1.4
google.golang.org/api (go) v0.231.0
google.golang.org/genproto/googleapis/api (go) v0.0.0-20250218202821-56aae31c358a
google.golang.org/genproto/googleapis/rpc (go) v0.0.0-20250425173222-7b384671a197
google.golang.org/grpc (go) v1.72.0
google.golang.org/protobuf (go) v1.36.11
gopkg.in/yaml.v3 (go) v3.0.1
honnef.co/go/tools (go) v0.6.1
modernc.org/libc (go) v1.70.0
Files by Type (count)
Go
77
Vue
17
Other (.jpg)
14
TypeScript
13
Other (no ext)
8
Other (.png)
8
Git Ignore
6
JSON
6
Other (.mp4)
4
C
3
C/C++ Header
3
Other (.comp)
3
Files by Type (size)
Other (.jpg)
4MB
Other (.mp4)
1MB
Other (.png)
1MB
Other (.gif)
846KB
JSON
230KB
Other (.data)
192KB
Go
179KB
Other (.sum)
32KB
Other (.ico)
29KB
Vue
28KB
Other (.svg)
27KB
C
26KB

The LLM identified 3 files worth highlighting for reuse:

A reusable image patch matching library that finds the best match of a template in a larger image using cosine similarity. Provides four implementations (slow Go, optimized Go, Cgo, Vulkan compute) selected at compile time via build tags, making it adaptable to various performance needs. Self-contained, with own test data and no internal imports beyond standard libraries and `pkg/imutil`. Can be extracted for any image matching task.

file: pkg/pmatch ↗ | tags: #image-processing #patch-matching #cgo #vulkan

A generic RANSAC (Random Sample Consensus) implementation that fits a user-supplied model function to noisy data. In Trainbot it fits a quadratic velocity model to frame displacement points, but the algorithm is completely decoupled from any domain logic. The code is concise, well-tested, and can be reused for any regression or model fitting problem where outliers are present.

file: pkg/ransac ↗ | tags: #ransac #curve-fitting #model-fitting

A thin Cgo wrapper around Vulkan compute pipelines that abstracts shader loading, buffer creation, descriptor sets, and pipeline dispatch. Simplifies running GPU compute shaders from Go without exposing the full Vulkan API. Self-contained and can be extracted for other compute-intensive tasks requiring GPU acceleration via Vulkan.

file: pkg/vk ↗ | tags: #vulkan-compute #gpu #cgo
Last analyzed: 2026-07-30 23:16:42.504373
Next check: 2026-10-28 23:16:42.451495
$ submit: