Hello,
I was sent over here by reddit to start a thread. They think it would be a good idea.
So I'm in the process of building and programming a lightgun. The whole thing is open source and get published on github.
Before I change my mind, I thought I'd start a thread here to document the whole development and add any tips or other information.
As already mentioned, the whole thing is written in Python. It's not exactly economical with the CPU - but it's fun!
A rough overview of what you need:
- 3D printer for the Lightgun
- a USB webcam that delivers at least 60 FPS at 1280x720. (The more the better)
- Arduino with buttons for the fire and other buttons
I am currently designing the Lightgun in Fusion360 and it is currently nothing more than a frame model. I want to finish designing it before I present it.
A detailed parts list is also still to come.
So far it runs on Windows and comes with its Python environment, so you don't have to install anything.
The plan is to support two players/lightguns later on.
I would like to cover various possibilities for position detection:
- with a frame on the display as like the Sinden Lightgun
- with the help of one or more Aruco markers which you can either display as an overlay or print out and hang up.
But first I'll concentrate on the software solution with the frame on the screen. There are still a few other things to do.
The setup in a nutshell:
All you really need is a USB webcam and an Arduino as well as a few buttons to equip your own gun.
Not everything works automatically yet. But I have created several scripts which help with the setup. You just have to run them one after the other so that you have created all the settings and written them to the configuration file.
First you flash the Arduino with the enclosed code and solder the 5 buttons to it.
Then you can plug the webcam into your PC and start the first script. This recognizes all connected webcams, lets you select the correct one, tests the selection and informs you of the possible FPS at which resolution is possible. Now you can save the values that seem to make the most sense.
The next step is to determine the displayed frame size, or more precisely its circumference. To do this, start the next script which, after it tells you that you should point the cam at the TV in the approximate playing/shooting position that you will take later, starts to draw an increasing rectangle on the screen. When the rectangle covers the entire screen, the value is determined and is also saved in the configuration file.
To align the webcam to the corner points, there is a button that you can assign later to be able to call up the function at any time (also ingame). But that's all you have to do with the camera for now.
Now connect the Arduino to the PC via USB and start another script. This searches for the possible connections and lets you select one. The script then tests the Arduino to see if it is the right one. If everything runs successfully, the necessary settings are also saved.
Since the software still needs to know which buttons should be pressed and when, there is also a script that guides you through the mapping.
And that's it. Once you have chewed through all the scripts, you can start the actual program and the cam takes over the mouse and keyboard.
I'm still working on the Github repo. As soon as it's online I'll attach the link here.
Best regards and see you soon!