berkeley logoProgramming Project #2 (proj2)
CS194-26 (CS294-26): Image Manipulation and Computational Photography

Face Morph Example
Building a Pinhole Camera
Project Due Date: 11:59pm on Friday, September 16, 2016


In this project, you will work in groups of at most 3 to design a pinhole camera. The pinhole camera (also called the "camera obscura") is essentially a dark box with a pinhole on one face, and a screen on the opposite face. Light reflecting off an object is directed through the pinhole to the screen, and an inverted image of the object forms on the screen. The caveat is that it is hard to see the image formed with the naked eye. To be able to see the image, we will use a digital camera with a long exposure time (15-30 seconds) attached to the pinhole camera.

Note: you should start early on this project! The camera will work best when it is sunny (remember, Berkeley gets many foggy days).

Basic Pinhole Camera Design

To design a basic easy-to-use pinhole camera, we recommend the following (as taken from the webpage of James Hays):

  1. Get a cardboard box. Doesn't have to be too big, but it does have to ultimately be "lightproof"; a shoebox will do. The cardboard box should be such that the distance between the pinhole and the screen the focal length) is longer than the minimum focus of the digital camera, so you don't get a blurry image.
  2. Obtain a digital camera through which you can set up a longish exposure time, about 15-30 seconds. In many cameras, there are long exposure setting; in others, you can manipulate exposure by controlling the aperture size and shutter speed. (While forming your teams, you should figure out who has a digital camera with long exposure time).
  3. Determine which face of the box should be your screen. Cover the inside of this face with white paper; printer paper is fine.
  4. Cover the rest of the faces on the inside with black paper. I have tons of black paper if you need some.
  5. On the opposite face, cut a large hole. You will cover this hole with card paper, and punch the pinhole into the card paper. The advantage is that you can create a neat pinhole with a wide field of view, and test pinholes of varying sizes.
  6. Next to the hole for the card paper, cut a hole for the digital camera's aperture. The camera aperture should fit snugly into the hole. The digital camera's hole should not be too far from the pinhole, since the camera's field of view may not be wide enough to capture the screen's image: you may have to angle the digital camera a bit towards the pinhole. If you have one of those flat cameras, then position the camera's lens on top of the hole and cover the entire region around the camera with duct tape so that no light enters from the digital camera's hole. Figure out the appropriate settings for the digital camera (i.e., long exposure time), and make sure it is charged and has a memory stick before you duct tape it.
  7. Duct tape your box all over! You really want to make it light proof.

To capture images:

  1. Take the setup to a nice sunny area.
  2. Point the pinhole in the direction of an object of interest.
  3. Set up the digital camera so that it will capture a long exposure image.
  4. Shoot, and hold still for 15-30 seconds.
If you've done things correctly, you'll capture a beautiful image with your pinhole camera!


For this project, you will use three sizes of the pinhole, for instance, .1 mm diameter (really just a pinprick), 3 mm diameter, and 5 mm diameter. Make your design so that you can easily switch between card papers with different hole sizes. These diameters are suggestions: in reality, your pinhole size should be about 1.9 * sqrt(f * lambda), where f is the distance between the pinhole and the screen, and lambda is the wavelength of light (about 550 nm, If you use this size, then go a few mm up and down as well to have three pinhole sizes in total. Report what sizes you use on your webpage.

Use all three pinhole sizes to capture two scenes (i.e., you will have six images in total). On your webpage, include an explanation of what happens to the images when you use larger versus smaller pinholes. In addition, capture four other images with the diameter you think did best.

Submit a few photos of your camera model itself (you can use a webcam or cell phone camera if you do not have enough digital cameras).

For this project, you can have one person host your web content, but make sure to put everyone's name on the top of the page. Upload all your beautiful creative results to your webpage (zipped up, using the upload utility, just like last time!).

Bells and Whistles


All people in a team get the same grade.