Main > Lightguns
Cygun - diy lightgun written in Python
Cynob:
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!
Cynob:
So here is the link to github: https://github.com/Cynobs-repo/cygun
Any suggestions?
Fursphere:
What are the pro/con's of choosing this solution vs. GUNIR / Sinden / RetroShooter / Blamcon / (other lightgun solution I haven't mentioned) ?
You already mentioned that python is non-optimal for cpu performance (con).
Cynob:
Hello @Fursphere
I don't think I have to justify myself to you here. You can read the source code to deduce for yourself what is better or worse than your preferred lightgun.
If a moderator reads this:
The forum is dead and the only thing you can do here is justify yourself to some randoms from the internet. You are welcome to delete this thread. I'm not putting any more work into it.
Thanks for the great forum you offer here.
Fursphere:
-sigh-
You say you need a 3d printer, but you don't provide STLs (or even links to reference STLs in the usual places).
You say you need a webcam, but you don't provide a reference model (this has been tested with blah hardware).
You did provide the Arduino sketch, so that was cool.
Your wiring diagram didn't mention the resistors normally used when connecting buttons to an arduino. So I was left with questions there.
Your solution appears to require running two separate usb cables from the 'gun' to the PC, one for the arduino, the other for the webcam. Little clunky. But since you don't even have a reference build, I guess you hold the camera in one hand, then the ardunio and buttons in the other?
Good luck with your project.
Navigation
[0] Message Index
[#] Next page
Go to full version