PyCon 2012: Militarizing Your Backyard: Computer Vision and the Squirrel Hordes

  • 25,068 views
Uploaded on

 

More in: Sports , Technology
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
  • nice!
    A video clip of squirrels being shot will be super cool addition.
    Are you sure you want to
    Your message goes here
  • really cool
    Are you sure you want to
    Your message goes here
  • cool practice. Never thought about such leveraging with Python.
    Are you sure you want to
    Your message goes here
  • cool
    Are you sure you want to
    Your message goes here
No Downloads

Views

Total Views
25,068
On Slideshare
0
From Embeds
0
Number of Embeds
3

Actions

Shares
Downloads
178
Comments
4
Likes
30

Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide

Transcript

  • 1. Militarizing Your Backyard With Python:Computer Vision and the Squirrel Hordes Kurt Grandis PyCon 2012
  • 2. Overview● Background & Goals● OpenCV ○ Working with Python● Detecting Squirrels ○ SVMs ○ Squirrely features● Shooting Squirrels● Wet Squirrels● Next Steps
  • 3. The Great Backyard Bird Counthttp://www.birdsource.org/gbbc/
  • 4. Squirrels...
  • 5. Sentry Water Gun http://wiki.teamfortress.com/wiki/Sentry_Gun
  • 6. SystemSensor (Camera) Blob Detection Targeting Shoot the Squirrel Squirrel Detection
  • 7. OpenCVOpen Source Computer Vision● Image Processing● Video Analysis● Feature Detectors● Object DetectionC, C++, Python Interfaceshttp://opencv.willowgarage.com/wiki/http://code.opencv.org
  • 8. Python & OpenCV● Support for native Python structures● Works with numpy● Efficient data sharing
  • 9. Sensor : Webcam
  • 10. OpenCV import cv cv.NamedWindow("camera raw", 1) capture = cv.CreateCameraCapture(0) img = cv.QueryFrame(capture) cv.ShowImage("camera raw", img) # Convert to Gray Scale gray = cv.CreateImage(cv.GetSize(img), cv.IPL_DEPTH_8U, 1) cv.CvtColor(img, gray, cv.CV_BGR2GRAY) # Canny Edge Filter cv.Canny(gray, edges, 50, 200, 3)
  • 11. Blob DetectionHow do I find regions of interest (i.e. Blobs)?● Birds● Squirrels● Neighbor ChildrencvBlobsLib http://opencv.willowgarage.com/wiki/cvBlobsLibcvFindContours (OpenCV function)
  • 12. Background SubtractionForeground SegmentationNoisy BackgroundCodebook Approach
  • 13. Squirrel Detection
  • 14. Support Vector Machines (SVMs)Supervised Learning from svm import * ...Classification c = my_trained_model.predict(vector)Featureslibsvm http://www.csie.ntu.edu.tw/~cjlin/libsvm/
  • 15. Squirrely FeaturesWhat is squirrel-ness?● blob size● histogram analysis of blob● entropy of blob (texture)
  • 16. Blob Size
  • 17. Color Histogram
  • 18. Entropy Measure of randomness Calculate entropy for regions of the blob ● Overall Entropy ● Stdev Entropy ● Left Mean Entropy - Right Mean Entropy h_prob = [ h / histo_sum for h in histogram ] entropy = -sum( [p * math.log(p) for p in h_prob if p != 0] )
  • 19. SVM & Classifing Blobs● blob size● color histograms● entropy of blob (texture) Classify!
  • 20. Shoot the Squirrel
  • 21. The Gun
  • 22. The Turret
  • 23. Python and ArduinoArduino Unopyserial import serial arduino = serial.Serial(device, BAUD_RATE) arduino.write("a")Project Sentry Gunhttps://sites.google.com/site/projectsentrygun/Python-On-A-Chiphttp://code.google.com/p/python-on-a-chip/
  • 24. Results● Squirrels get wet● False positives extremely low● More satisfying if it camps the feeder● Need stronger firepower● Need larger water reservoir● Squirrels are extremely persistent...no really
  • 25. Next Steps● Better Optics● Stronger Firepower ○ Laminar water jet ○ Pressurized water pump● Python-On-A-Chip● Bird Classifier & Counter
  • 26. Questions?kgrandis@gmail.com@kgrandishttp://kurtgrandis.com/no animals were harmed in the development ofthis project. Bird seed and other snacks wereprovided to all participants free of charge.