How robots turn camera images into decisions: choosing cameras and depth sensors, detection and segmentation, pose estimation, calibration, lighting and latency.
A robot arm that repeats the same motion thousands of times does not need eyes. The moment parts arrive in random positions, packaging varies, or the robot has to check its own work, it needs vision. Computer vision is what lets a machine find a part on a conveyor, judge how far away it is, decide how to grip it and confirm that the result is correct.
Vision is also where many robotics projects struggle. A model that works well on a laptop can fail on the shop floor because of glare, dust, vibration or a camera that was nudged by a few millimetres. Understanding the full chain, from sensor to decision, is the best way to avoid surprises.
Cameras and depth sensors
The first decision is what the robot should sense. Common options include:
- 2D cameras (colour or monochrome): inexpensive and well supported. Enough for reading labels, checking presence or absence, and locating flat parts on a known surface. Industrial cameras with global shutters avoid the skew that rolling-shutter sensors produce on moving objects.
- Stereo cameras: two cameras a fixed distance apart, estimating depth from the difference between the images. They work outdoors but need surface texture to match.
- Structured light: a projector casts a known pattern and a camera measures how it deforms. Accurate at short range, well suited to bin picking indoors, but sensitive to strong ambient light.
- Time-of-flight (ToF): measures how long emitted light takes to return. Compact and fast, though it can struggle with very dark or shiny surfaces.
- LiDAR: laser scanning, common on mobile robots for mapping and obstacle detection rather than fine part handling.
Match the sensor to the task: resolution needed to see the smallest defect, working distance, field of view, frame rate and the environment the robot operates in.
From pixels to objects: detection and segmentation
Once you have an image, the robot needs to know what is in it and where. There are three broad levels of detail:
- Classification answers "what is this image?" (for example, good part or defective part).
- Object detection draws a bounding box around each object and labels it.
- Segmentation labels every pixel, giving the exact outline of each object. This matters for grasping irregular items such as food, textiles or mixed parcels.
Not every problem needs deep learning. If parts are dark on a bright, controlled background, classical techniques such as thresholding and contour detection in OpenCV are fast, explainable and need no training data. Here is a minimal example that grabs a frame from a camera and finds the outlines of objects:
import cv2
cap = cv2.VideoCapture(0) # first connected camera
ok, frame = cap.read()
cap.release()
if not ok:
raise RuntimeError("Could not read a frame from the camera")
gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
blur = cv2.GaussianBlur(gray, (5, 5), 0)
_, mask = cv2.threshold(blur, 0, 255, cv2.THRESH_BINARY_INV + cv2.THRESH_OTSU)
# OpenCV 4.x returns (contours, hierarchy)
contours, _ = cv2.findContours(mask, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE)
for c in contours:
if cv2.contourArea(c) < 500: # ignore noise
continue
x, y, w, h = cv2.boundingRect(c)
m = cv2.moments(c)
cx, cy = int(m["m10"] / m["m00"]), int(m["m01"] / m["m00"])
print(f"Object at pixel ({cx}, {cy}), box {w}x{h}")
The centroid gives a pick point in pixel coordinates. When lighting and backgrounds vary, or parts overlap, a trained detection or segmentation model becomes the better choice, often running on an edge device with a GPU or NPU.
Pose estimation: where exactly, and at what angle
Knowing that a part is in the image is not enough for a robot to pick it up. It also needs the part's pose: position and orientation in three dimensions. Approaches include:
- 2D pose on a known plane: if parts lie flat on a conveyor, the centroid plus the angle from
cv2.minAreaRectmay be sufficient. - Fiducial markers: printed markers such as ArUco tags give a reliable 6-DoF pose and are useful for locating fixtures, trays or the robot itself.
- Model-based matching: comparing a 3D point cloud from a depth sensor with the part's CAD model.
- Learned pose estimation: neural networks trained to predict pose directly, useful for cluttered bins.
Calibration: connecting the camera to the robot
Pixels are not millimetres. Two calibrations turn a detection into a robot movement:
- Intrinsic calibration measures the camera's focal length, optical centre and lens distortion, typically by photographing a checkerboard from several angles (OpenCV provides
cv2.calibrateCamerafor this). - Hand-eye calibration finds the transform between the camera and the robot's base or tool, so that a point seen by the camera can be expressed in robot coordinates. OpenCV includes
cv2.calibrateHandEyefor this step.
Calibration is not a one-time task. Re-check it after maintenance, after any change to camera mounting and on a regular schedule. A simple verification routine, where the robot touches a known reference point, catches drift early.
Lighting: the most underrated component
Many vision problems are really lighting problems. Sunlight through a factory window, flickering tube lights or reflections from metal parts can defeat even a good model. Practical measures include:
- Enclosing the inspection area or adding a hood to block ambient light.
- Using dedicated LED lighting: ring lights for general use, backlights for silhouettes and dimensions, low-angle lights to highlight scratches and dents.
- Polarising filters to reduce glare on shiny surfaces.
- Fixing exposure and white balance in the camera settings rather than leaving them on automatic.
Collect test images under real shop-floor conditions, including different shifts and seasons, before you finalise the design.
Latency and the real-time budget
For a robot, a correct answer that arrives late can be wrong. If a conveyor moves at a steady speed, every millisecond of delay shifts the object's position. Add up the full chain: exposure, image transfer, processing, network hops and robot motion planning. Ways to keep it tight include processing on an edge device next to the camera, reducing image resolution to what the task actually needs, cropping to a region of interest, using hardware triggers so the camera captures at a known moment, and using encoder data from the conveyor to predict where the part will be when the gripper arrives.
Log timestamps at each stage. Without measurements, latency problems look like random accuracy problems.
How NextWebGen can help
NextWebGen is a software company, not a robot integrator, so we focus on the software around your vision system: dashboards that show inspection results and defect trends, APIs that connect vision stations to your ERP or MES, and cloud or on-premise servers to store images and data. If you are planning a vision project and need that layer built, contact us to talk it through.



