Raspberry Working With Webcam [part1]



Tutorial ini blm gw uji. gw dapet dari buku ” Getting Started with Raspberry PI | O’REILLY” dan siap menguji nya dalam tempo yang sesingkat-singkat nya.


  • Raspberry ready OS. Raspbian
  • Webcam

How to cook:

  1. Make sure your webcam support check dimari–> elinux.org/RPi_VerifiedPeripherals#USB_Webcams
  2. pi@raspberrypi ~ $ sudo apt-get install luvcview //ni aplikasi untuk testing webcam work or not!
  3. pi@raspberrypi ~ $ luvcview -s 320×240

Klo kata di buku keterangan nya tuh.

If you don’t see video coming through, you’ll want to troubleshoot here before
moving on. One way to see what’s wrong is by disconnecting the webcam,
reconnecting it, and running the command dmesg, which will output diagnostic
messages that might give you some clues.

  • pi@raspberrypi ~ $ sudo apt-get install python-opencv python-scipy pythonnumpy
  • pi@raspberrypi ~ $ sudo pip install https://github.com/ingenuitas/SimpleCV/
  • When it’s done, check that the installation worked by going into the Python
    interactive interpreter and importing the library:
    pi@raspberrypi ~ $ python
    Python 2.7.3rc2 (default, May 6 2012, 20:02:25)
    [GCC 4.6.3] on linux2
    Type “help”, “copyright”, “credits” or “license” for more information.
    >>> import SimpleCV
  • We’re going to start you off with some SimpleCV basics using image files,
    and then you’ll work your way up to reading images from the webcam. Once
    you’ve got images coming in from the webcam, it will be time to try some
    face detection.
    1. Create a new directory within your home directory called simplecv-test.
    2. Open Midori, search for an image that interests you. We decided to use
    a photograph of raspberries from Wikipedia.and renamed it to raspberries.
    3. Right-click on the image and click “Save Image.”
    4. Save the image within the simplecv-test folder.
    5. In the file manager (on the Accessories menu), open the simplecv-test
    folder and right-click in the folder. Choose Create New → Blank File.
    6. Name the file image-display.py.
    7. Double click on the newly created image-display.py file to open it in Leafpad.
    8. Enter the code in Example 9-1.
  • Example 9-1. Source code for image-display.pyfrom SimpleCV import Image, Displayfrom time import sleepmyDisplay = Display()raspberryImage = Image(“raspberries.jpg”)raspberryImage.save(myDisplay)while not myDisplay.isDone():sleep(0.1) .

  • Import SimpleCV’s image and display functions

  • Creates a new window object

  • Loads the image file raspberries.jpg into memory as the object image

  • Display the image in the window

  • Prevent the script from ending immediately after displaying the image

    9. Save the image-display.py file and run it from the terminal window. If
    you’ve got everything right, you’ll see a photo in a new window as in
    Figure 9-4. You can close the window itself, or type Control-C in the terminal

    to end the script.


..to be continue 🙂 source: Getting Started with Raspberry PI | O’REILLY