Skip to content

Instantly share code, notes, and snippets.

@gourneau
Created November 14, 2011 00:09
Show Gist options
  • Select an option

  • Save gourneau/1362950 to your computer and use it in GitHub Desktop.

Select an option

Save gourneau/1362950 to your computer and use it in GitHub Desktop.
BeardDetector using SimpleCV
import SimpleCV
import time
c = SimpleCV.Camera(1)
js = SimpleCV.JpegStreamer()
while(1):
img = c.getImage()
img = img.smooth()
img = img.dilate()
img = img.erode()
lines = img.findLines(threshold=25,minlinelength=20,maxlinegap=20)
[line.draw(color=(255,0,0)) for line in lines]
sum = 0
for line in lines:
sum = line.length() + sum
if sum:
print sum / len(lines)
else:
print "No beard found!"
img.save(js.framebuffer)
time.sleep(0.1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment