Sign in to save

Bookmark this page so you can find it later.

Sign in to save

Bookmark this page so you can find it later.

Computer Vision Basics cheat sheet - grade 9-12

Click image to open full size

Computer vision is how a robot uses cameras and algorithms to interpret images and make decisions. This cheat sheet covers the basic ideas students need to understand how robots detect lines, objects, colors, shapes, and motion. It is useful for robotics teams, coding projects, and classroom work with cameras or vision sensors.

The goal is to connect image data to real robot actions like steering, grabbing, sorting, or avoiding obstacles.

The core concepts include pixels, resolution, color models, filtering, thresholding, edge detection, and object tracking. A camera image can be treated as a grid of numbers, where each pixel stores brightness or color values. Vision algorithms often improve the image first, then extract important features such as corners, edges, blobs, or contours.

Robot programs use these measurements to estimate position, distance, direction, or object identity.

Key Facts

  • An image is a grid of pixels, and image size is width x height, such as 640 x 480 pixels.
  • In an RGB image, each pixel usually stores three color values: red, green, and blue, often from 0 to 255.
  • Grayscale brightness can be estimated with gray = 0.299R + 0.587G + 0.114B because human vision is most sensitive to green.
  • Thresholding converts an image to binary using the rule: if pixel value >= threshold, set it to 1, otherwise set it to 0.
  • A simple camera pinhole model uses image size relation: image height / object height = focal length / object distance.
  • Distance to an object can be estimated with distance = real object width x focal length / object width in pixels.
  • Edge detection finds places where brightness changes quickly, which often mark object boundaries or lane lines.
  • A robot vision pipeline usually follows: capture image, preprocess, segment, find features, classify or measure, then control the robot.

Vocabulary

Pixel
A pixel is the smallest picture element in a digital image and stores brightness or color information.
Resolution
Resolution is the number of pixels in an image, usually written as width x height.
Color Space
A color space is a way to represent colors numerically, such as RGB, HSV, or grayscale.
Thresholding
Thresholding is a method that separates pixels into groups by comparing their values to a chosen cutoff.
Contour
A contour is a curve or boundary that outlines a connected shape in an image.
Camera Calibration
Camera calibration is the process of finding camera properties so image measurements can better match real-world measurements.

Common Mistakes to Avoid

  • Confusing image coordinates with graph coordinates is wrong because image y-values usually increase downward from the top-left corner, not upward from the bottom-left.
  • Using RGB for every color detection task can be unreliable because lighting changes often affect red, green, and blue values strongly.
  • Choosing one threshold value without testing is a mistake because shadows, glare, and camera exposure can change pixel brightness.
  • Assuming a larger object in the image always means the object is larger is wrong because nearby objects also appear larger.
  • Skipping camera calibration can cause inaccurate distance or angle estimates because lens distortion and focal length affect image measurements.

Practice Questions

  1. 1 A robot camera captures a 1280 x 720 image. How many pixels are in one frame?
  2. 2 An object is 20 cm wide, the camera focal length is 600 pixels, and the object appears 150 pixels wide in the image. Estimate the distance to the object using distance = real object width x focal length / object width in pixels.
  3. 3 A pixel has RGB values R = 100, G = 150, and B = 200. Estimate its grayscale value using gray = 0.299R + 0.587G + 0.114B.
  4. 4 Why might a robotics team use HSV color space instead of RGB when detecting a colored game piece under changing lighting?

Understanding Computer Vision Basics

A camera does not measure the world directly. It measures light reaching its sensor. The result depends on lighting, exposure time, focus, and the camera angle.

Bright sunlight can wash out a pale object. A dark classroom can make images noisy and blurry. Motion blur happens when the robot or target moves during exposure.

This is why a vision program that works on a desk may fail on a competition field. Good testing uses the real lighting, background, distance, and movement speed expected during use.

Camera calibration connects image measurements to physical space. Real lenses bend light, especially near the edges of the frame. Straight floor lines may appear curved.

Calibration uses known patterns, often a printed checkerboard, to measure lens distortion and determine camera properties such as focal length and optical center. The optical center is the image location that best matches the lens axis.

Calibration matters when a robot must estimate distance, locate a game piece, or line up with a target. A small calibration error can send a robot several centimeters away from its intended path.

Image filtering is a careful tradeoff. A blur filter can reduce random speckles from poor lighting or sensor noise. Too much blur removes thin lines, sharp corners, and small details needed for accurate detection.

A sharpening filter can make boundaries clearer, though it may strengthen noise as well. Students should inspect intermediate images instead of trusting a final result.

Display the original image, the filtered image, the selected regions, and the detected features. This makes debugging much easier because it shows the stage where useful information was lost.

Color is useful, but it is rarely a perfect label for an object. The same red ball can produce very different camera values under warm indoor lamps, cool daylight, or shadows. Many vision systems use hue, saturation, and value because hue can describe a color family while value describes brightness.

Even then, color ranges need tuning. Background objects, reflections, and team uniforms can create false detections.

A stronger method combines several clues. A program may require a certain color range, a minimum size, a roughly circular shape, and a location within part of the frame.

Object recognition has levels of difficulty. Finding a colored blob is simpler than deciding whether an object is a cone, cube, person, or tool. Modern classifiers learn patterns from many labeled images.

Their output is a probability, not certainty. A robot should use that uncertainty safely. It can ignore weak detections, require the same result across several frames, or slow down when confidence is low.

In school robotics, the most reliable solution is often the simplest one that fits the task. Clear targets, controlled lighting, fixed camera mounting, and a well tested fallback behavior can matter more than a complex model.