In [34]:
from SimpleCV import *
from time import sleep
#import pytesseract
from bs4 import BeautifulSoup
Here we set up the camera
In [35]:
cam = Camera()
Now we also get a single image from the cam, so mug it up!
In [36]:
img = cam.getImage()
In Ipython Notebook, you can sometimes use TAB autocompletion if the variable is in memory.
Let's see what "sh" brings up.
img.sh
Let's try shrinking beforehand
In [37]:
img.scale(0.5).show()
# Okay, let's keep that
img = img.scale(0.5)
Let's try getting some documentation
In [38]:
img.edges?
Okay, cool - built in documentation. Good.
Let's draw some text on it.
In [39]:
# This draws directly onto the image (in place)
img.drawText('RASPBERRY Pi', 10, 10, color=Color.BLUE, )
img.show()
Out[39]:
In [45]:
#Let's try bigger font
img.drawText('RASPBERRY Pi', 10, 10, color=Color.ORANGE, fontsize=50)
img.show()
Out[45]:
Let's look at some people
Who's there?
This function lists what features we can detect (built in).
In [72]:
ppl.listHaarFeatures()
In [84]:
ppl = Image('group.jpg')
ppl = Image('tng.jpg')
ppl.show()
Out[84]:
In [85]:
#obs = ppl.findHaarFeatures('face.xml')
obs = ppl.findHaarFeatures('upper_body.xml')
for f in obs:
print str(f.coordinates())
f.draw(color=Color.YELLOW, width=4)
ppl.show()
Out[85]:
Look at the image set as a whole
In [90]:
print obs.sortX()
# Highlight the person on the left
obs.sortX()[0].draw(color=Color.RED, width=4)
# reshow the image after drawing in it
ppl.show()
Out[90]:
In [ ]:
#while True:
# Reduce the image size
# img = cam.getImage().scale(0.5)
# faces = img.findHaarFeatures("face.xml")
# for f in faces:
# f.draw(width=3)
#
# img.show()
In [ ]: