Search Tom's Pi Adventures

Friday, May 9, 2014

Sentry

Sentry Project for the Pi

I did some tests last night. I found that the Motion app for Linux natively outputs that pixels that have changed in an X and Y value. There is also a section in the config that allows you to run a script when motion is detected.

I wrote a bash script which receives input from the motion app %K for x and %L for y to calculate the pulse length to drive my servos using servoblaster and some calculations to convert the x value into a value between 80 and 220 for the pulse width of the servo.

For example with the x value %K I fed that into my batch script, times it by 140 (difference between 80 and 220) and divided it by 1024 (numbers of x pixels in the image) and add 80 onto the end of it to get the starting point of the pulse width to send to the servos (remember range 80 --> 220).

The response time is impressive. Now to connect it to my prototype and see how it responds in real life.

------------------------------------------------------------------------------------------------------------

Hmmmmmmm, interesting read for CSI camera integration with Motion (Linux motion detection software) and MMAL use with some custom Python code:
http://www.maketecheasier.com/raspberry-pi-as-surveillance-camera/

------------------------------------------------------------------------------------------------------------

I was working on a sentry using the CSI Camera module that came out for the Raspberry Pi. But at the moment the response time using Python and OpenCV was rubbish. I need to do some more research into MMAL programming first.

What I was using:

  • Automatic NERF gun
  • External power supply connected to the NERF gun (instead of batteries)
  • 3 x 5V servos to move:
    • Tilt the gun to aim only for the torso
    • X Axis to swivel 180 degrees only
    • Trigger mechanism to pull the trigger once a warning to retreat has been given
  • I used the same external power supply for the NERF gun to power the servos
  • Cut up some MDF to make a box to store the Pi in and house the cabling and also to make a mount for the gun and a disc for it to swivel on the X Axis
  • CSI Camera module connected to the Pi directly (not USB) to utilise the GPU instead of the RAM and CPU
  • Hours and Hours and Hours of programming to no success. Well limited success, it was working, just the response time to act and send the signal to the servos was around 1.5 seconds which was good enough for the Zombie Apocolypse.
Once my programming skill evolve and I learn more about MMAL and facial recognition I will return to this project.

No comments:

Post a Comment