Skip to main content
A calibrated camera has a known focal length, principal point and lens distortion, and a known tilt relative to the floor. You will estimate these for your own laptop webcam by three methods and compare them. The first is Zhang’s checkerboard method, as implemented in OpenCV. It needs a printed target, and it is accurate enough that its focal length serves as the reference for the other two. The second is GeoCalib, a network that estimates the focal length and the direction of gravity from one ordinary photo. You compute part of its prediction by hand before relying on it. The third uses a video of you walking across the room. The lines from your feet to your head meet at the vertical vanishing point, and because your head stays at about the same height, your head and foot positions also trace the horizon. The horizon gives the camera’s tilt. NVIDIA’s AutoMagicCalib starts from the same geometry to calibrate fixed cameras that watch pedestrians.

Grading

Background reading

How the tasks work

Most tasks ask for a function or a few lines of code, followed by a check cell. It prints passed when the code is right and explains the problem when it is not. Later parts call your earlier functions, so get each check to pass before you move on. A few results depend on your camera and your room. When one of these looks unusual, its check prints a warning and you can keep going. The written questions ask you to explain such results with your own numbers. Until your captures are in place, the code runs on a sample recorded on the instructor’s laptop, so you can start on the tasks right away.
The results you hand in must come from your own webcam. Any part answered with the sample data will be heavily penalized.
This is an individual exam, so you cannot collaborate with anyone. You may consult the course material, the textbooks and the documentation of the libraries you use. The code and the written answers must be your own.

What you need

  • Your laptop’s built-in webcam, at the same resolution for every capture.
  • A checkerboard, printed and flat or shown full screen on a phone or tablet. Count its inner corners (a board of 11 by 8 squares has 10 by 7) and measure one square’s side in millimeters.
  • A phone app that reads tilt in degrees, for the angle of the laptop lid. On an iPhone, use the Level tab of the built-in Measure app. On Android, install Bubble Level. Only the changes between readings matter, so the app’s zero does not, but do not tap the screen between readings: in Measure, a tap resets the zero.
  • The capture script. It runs on your laptop and needs Python with opencv-python and numpy. Colab cannot open a local camera.
  • A Google account for Colab and Google Drive. Use a GPU runtime: in Colab, open Runtime, choose Change runtime type, and select a T4 GPU.

What to capture

Run python capture.py list to find the index of your color webcam. Then start the capture with your board’s inner-corner count and square size:
In the preview window, c saves a checkerboard view, s saves a scene, v starts and stops a video, and q quits. The first cells of the midterm describe each capture in detail. You need:
  • About 20 checkerboard views that cover the whole image, with the board tilted in different directions.
  • About 10 scenes without the checkerboard, each from a different view. Add four scenes of one view at four lid angles, and note the phone reading for each.
  • A video of 30 to 60 seconds of you walking across the room. Keep the laptop still and your whole body in view, and note the phone reading on the lid.
Upload the whole captures folder to My Drive/cv-midterm/captures in Google Drive. The setup cell mounts your Drive and reads the captures from there. They survive the end of a Colab session and stay out of your repository.
Keep other people out of your captures, and blur any face that is not yours. The notebook you submit contains images from your captures, and the graders see the folder you share.

What you hand in

  • The notebook, with every cell output saved.
  • A view-only link to your captures folder in Google Drive, pasted in the notebook’s last cell.

Assignment notebook

Open Notebook in Colab

Calibrate Your Own Webcam Notebook

Submitting

Commit the notebook under assignments/midterm in your private clone of the class repo. Save every cell output first: a notebook without outputs is graded as if its cells never ran. Do not commit your captures. Submit the full GitHub URL of that directory to Canvas.
Found an error on this page? Report an issue.