Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.

  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

Examples > A Photo Booth Application

A Photo Booth Application

The next example is a simple photo booth application. After all, nothing says, “I’m an aspiring vision system developer” better than getting close with a friend or loved one and taking silly pictures. This application takes a continuous feed of images. When clicking the left mouse button on an image, it saves it to disk as photobooth0.jpg, photobooth1.jpg, and so on.

from SimpleCV import Camera, Display, Color
import time

# Initialize the camera
cam = Camera()

# Initialize the display
display = Display()

# Take an initial picture
img = cam.getImage()  1

# Write a message on the image
img.drawText("Left click to save a photo.",
        color=Color().getRandom())  2

# Show the image on the display
img.save(display)

time.sleep(5)  3

counter = 0
while not display.isDone():
     # Update the display with the latest image
     img = cam.getImage() 4

     img.save(display)

     if display.mouseLeft:
          # Save image to the current directory
          img.save("photobooth" + str(counter) + ".jpg")  5

          img.drawText("Photo saved.", color=Color().getRandom()) 6

          img.save(display)

          time.sleep(5)

          counter = counter + 1

  

You are currently reading a PREVIEW of this book.

                                                                                                                    

Get instant access to over $1 million worth of books and videos.

  

Start a Free Trial


  
  • Safari Books Online
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint