The beginning of a demo


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]:
<SimpleCV.Display Object resolution:((320, 240)), Image Resolution: (320, 240) at memory location: (0x6ab28eb8)>

In [45]:
#Let's try bigger font
img.drawText('RASPBERRY Pi', 10, 10, color=Color.ORANGE, fontsize=50)
img.show()


Out[45]:
<SimpleCV.Display Object resolution:((640, 480)), Image Resolution: (640, 480) at memory location: (0x697ecda0)>

Let's look at some people

Who's there?

This function lists what features we can detect (built in).


In [72]:
ppl.listHaarFeatures()


['face3.xml', 'mouth.xml', 'glasses.xml', 'fullbody.xml', 'face.xml', 'nose.xml', 'lower_body.xml', 'right_eye2.xml', 'upper_body.xml', 'face2.xml', 'face_cv2.xml', 'right_ear.xml', 'left_ear.xml', 'left_eye2.xml', 'face4.xml', 'right_eye.xml', 'upper_body2.xml', 'two_eyes_big.xml', 'lefteye.xml', 'two_eyes_small.xml', 'eye.xml', 'profile.xml']

In [84]:
ppl = Image('group.jpg')
ppl = Image('tng.jpg')
ppl.show()


Out[84]:
<SimpleCV.Display Object resolution:((275, 183)), Image Resolution: (275, 183) at memory location: (0x6ab77210)>

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()


[227  36]
[58 37]
[178  40]
[94 49]
[36 65]
[210  78]
[125  39]
Out[85]:
<SimpleCV.Display Object resolution:((275, 183)), Image Resolution: (275, 183) at memory location: (0x6985f800)>

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()


[SimpleCV.Features.Detection.HaarFeature at (36,65), SimpleCV.Features.Detection.HaarFeature at (58,37), SimpleCV.Features.Detection.HaarFeature at (94,49), SimpleCV.Features.Detection.HaarFeature at (125,39), SimpleCV.Features.Detection.HaarFeature at (178,40), SimpleCV.Features.Detection.HaarFeature at (210,78), SimpleCV.Features.Detection.HaarFeature at (227,36)]
Out[90]:
<SimpleCV.Display Object resolution:((275, 183)), Image Resolution: (275, 183) at memory location: (0x6985fda0)>

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 [ ]: