HTTPS SSH

PyOfSauron

This started off as an experiment to detect a face and point a 3D eyeball at the user.

The new version has been re-factored to enable modular development and the ability too use different Haar detectors (Face, Body, Profile, actually what ever you like if you have the files) with the ability to pipe detection to custom modules from the command line.

Usage

To use, make sure you have a webcam, usage from the command line is through watch_me.py:

Usage:  watch_me.py [-v -f -b -p] -c <CALLBACK_MODULE> -g [[CALLBACK,CALLBACK]]

Optional Params
---------------
-v | --video_only       Displays video window (redundant, but could be handy)
-f | --face_only        Only detect faces
-b | --body_only        Only detect upper body area
-p | --profile_only     Only detect face in profile

Required Params
---------------
-c | --callback <CALLBACK_MODULE> OR
-g | --callback_group [CALLBACK,CALLBACK] (no spaces)

Callback modules are basic python modules with a pre-defined structure, to get started take a look at the BoxingCallback module.

A quick intro into module development:

  1. Create a new python module in the Callbacks sub directory
  2. Make sure you have a init.py in the directory
  3. Create CallbackModule.py in your module directory
  4. Create the class

The class looks like this:

class Callback:
    def __init__(self, cv):
        #This is the OpenCV object from the detector
        self.cv = cv


    def callback(self, params):
        # This function will get called every frame, params will
        # have the relevant data.

        faces = params['faces'] # Detected item coords
        img = params['img']     # image frame

        if faces:
            for face in faces:
                (x,y,w,h),n = face  # top left, top right coordinates and width & height of bounding box

        # Your code here...

Requirements to run this code:

  1. OpenCV library (and all set up in your path with python bindings installed)
  2. VPython for the rendering
  3. You will also require a webcam

Get in touch