Track Mania driving script using python, opencv and java

Опубликовано: 07 Август 2026
на канале: Nick Palmer
18,103
186

Bah, who needs the Kinect!

(Best in HD and full screen)

Using Python, pygame, numpy, opencv, Java and PPJoy (and FlypadJoystick to interface between the java and PPJoy https://github.com/dumbledore/FlypadJ... ) I wrote a couple of scripts to track two coloured objects, figure out their angle and emulate analog joystick movements for steering and also listen to the microphone and tell if you were making a car driving noise or sqeualing breake noise to handle acceleration for TrackMania so I could make silly noises and turn a bit of cardboard to drive.

Python, using opencv, pygame and numpy, tracks the objects and works out the vertical difference between them to figure out direction and magnitude.
That gets passed to a Java app I wrote which interfaces with PPJoy to emulate the joystick movement and also deals with the audio stuff, capturing samples of 0.02s of audio and using frequency analysis to figure out the noise you're making.

Fairly overcomplex and hacky, but it works and it filled a bunch of time when I should have been revising :P

My Source (note, this includes an unsigned joystick driver that AV may flag up. Feel free to ignore and just not install PPJoy unless you want to):
http://www.palmnet.me.uk/uploads/Driv...