Skip to content

neelsani/OpenCV-Turret

Repository files navigation

OpenCV-Turret

This project implements an object detection model to detect and track humans with a servo motor and nerf gun.

Setup (python)

First use the package manager pip (python 3.8.0) to install the requirements.

python3 -m pip install -r requirements.txt

Next you will need to install torch for python and optionally gpu. Note: This project was run on a CUDA environment. See personEngine.py

Setup (arduino)

Parts

You will need three MG996R servos, one laser diode, one small nerf gun, an arduino, a 36W power supply at 6v, and a 30fps webcam I used but really any webcam thats 30fps.

Mounting

Put one servo upright and mount another servo sideways on the gear of the first to create a pitch and yaw setup. Here is a video of that base mount. Mount the webcam on the top and the laser diode on the top of the webcam. Then hot glue the nerf gun to the side of the setup so it moves with the webcam. Then Finally mount the third servo to the trigger of the nerf gun. Here is a photo:

Pinout

Part Pinout
Yaw Servo gnd to arduino ground and negative of power supply, vcc to positive of power supply, signal to pin 9
Pitch Servo gnd to arduino ground and negative of power supply, vcc to positive of power supply, signal to pin 10
Trigger Servo gnd to arduino ground and negative of power supply, vcc to positive of power supply, signal to pin 11
Laser Diode gnd to arduino ground, signal to pin 13

Arduino Sketch

This project makes use of the pyfirmata library in arduino and python. For this project in the arduino ide simply upload the Standard Firmata sketch and that will be all. Here is a guide

Usage

For human tracking

python3 humanTrack.py:

For color tracking after you run colorTrack.py simply drag and select a portion of the screen with somewhat uniform color. Then the program will start to track the biggest contour of that color.

python3 colorTrack.py

Demo

Demo video coming soon!

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.

License

MIT

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published