Code Monkey home page Code Monkey logo

raspberrypi-mertracking's Introduction

Detect Motion and Destroy Target!

In this video I show you how to build a DIY motion tracking project with a Raspberry Pi 3. The project is autonomous so it moves and fires the gun when it detects motion. I used laser module for this project, but you can easily change modify this build to use a Nerf instead.This project allows you to detect and track a person with OpenCV and then trigger a device (such as a laser or gun).
Full tutorial for motion tracking: https://youtu.be/iwlfiDtddlg

Demo CountPages alpha

Install Guide

  1. Make sure pip is installed
    https://www.pyimagesearch.com/2018/09/19/pip-install-opencv/

sudo apt-get install python pip

  1. Install OpenCV 3. Follow all steps for python 3 instructions
    https://www.pyimagesearch.com/2016/04/18/install-guide-raspberry-pi-3-raspbian-jessie-opencv-3/

  2. Setup I2C on your Raspberry Pi
    https://learn.adafruit.com/adafruits-raspberry-pi-lesson-4-gpio-setup/configuring-i2c

  3. Install the Adafruit stepper motor HAT library

sudo pip install git+https://github.com/adafruit/Adafruit-Motor-HAT-Python-Library

  1. If you are using a Raspberry Pi Stepper Motor Expansion Board other than the Adafruit Stepper Motor HAT (just like in the video), then update the I2C address or frequency value with the following. (This address is only compatible with the board in the video, default value is blank for Adafruit Stepper Motor HAT)

self.mh = Adafruit_MotorHAT()   to   self.mh = Adafruit_MotorHAT(0x6F)   in the source code (mertracking.py)

  for mor details: http://www.raspberrypiwiki.com/index.php/Robot_Expansion_Board

  1. Make sure to create your virtual environment with the extra flag

mkvirtualenv cv --system-site-packages -p python3

  1. Source your bash profile

source ~/.profile

  1. Open Terminal and Activate your virtual environment

workon cv

  1. Clone this repository

git clone [email protected]:MertArduino/RaspberryPi-Mertracking.git

  1. Navigate to the directory

cd RaspberryPi-Mertracking

  1. Install dependencies to your virtual environment

pip install imutils RPi.GPIO

  1. Run the Code

python mertracking.py

Setting Parameters

mertracking.py has a couple parameters that you can set

MOTOR_X_REVERSED = False
MOTOR_Y_REVERSED = False
MAX_STEPS_X = 20
MAX_STEPS_Y = 10
RELAY_PIN = 22
self.mh = Adafruit_MotorHAT(0x6f)   I2C Address or Frequency
self.sm_x.setSpeed(5)   Speed of the Stepper Motor 1
self.sm_y.setSpeed(5)   Speed of the Stepper Motor 2
self.sm_x = self.mh.getStepper(200, 1)   Steps/Rev of the Stepper Motor 1
self.sm_y = self.mh.getStepper(200, 1)   Steps/Rev of the Stepper Motor 2
time.sleep(1)   Delay Time for the Relay Trigger

Adafruit_MotorHAT.MICROSTEP   You can change the step type with the following commands

MICROSTEP
SINGLE
DOUBLE
INTERLEAVE

raspberrypi-mertracking's People

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.