Based on contributions by Bastiaan.
Every vision-guided robot project eventually needs to answer the same question: the camera sees an object at pixel (u, v) — where does the robot need to move? This article explains the building blocks behind that conversion and points you to the concrete how-to for each method, so you don’t have to read all of them to pick one.
What you need
Before choosing a method, know the answers to these:
- Is your camera fixed above the workspace, or mounted on the robot (eye-in-hand)? All the methods below assume a fixed camera looking down at a flat or near-flat workspace, which is the most common student setup.
- Do you need X/Y only, or also Z (height)? Picking from a single known height only needs 2D. Picking objects of varying height needs a real 3D method or a height-correction trick.
- How much accuracy do you need? A few millimetres is fine for most gripper pick-ups; sub-millimetre accuracy for small parts needs more calibration points and a proper camera calibration.
Steps
1. Decide what you’re actually converting
- Converting a distance or size (e.g. “this part is X mm wide”) → you only need lens calibration + a pixel-to-mm scale factor: How to calibrate a camera and convert a pixel distance to a real-world distance.
- Converting a pixel location into a robot pick point → keep reading below.
2. Check what hardware you have
- Cognex smart camera (In-Sight / VisionPro): use the camera’s built-in calibration tool, no Python needed: How to auto-calibrate a Cognex camera using fixed world points.
- Intel RealSense (or other depth camera): you get true per-pixel depth, so you can deproject straight to a 3D point instead of assuming a flat plane: How to convert a RealSense camera pixel to a 3D point and robot coordinates.
- Regular 2D camera (webcam, GigE, USB): pick one of the plane-based methods below.
3. For a 2D camera, pick a plane-based method
All of these assume the object lies on (or a known fixed height above) one reference plane, and turn a pixel into an X/Y coordinate on that plane. They differ in how much setup effort they need and how well they handle rotation between the camera and robot axes.
| Method | Handles rotation between camera & robot axes? | Needs a lens calibration first? | Setup effort | Article |
|---|---|---|---|---|
| Manual offset (axes assumed parallel) | No — only mirrored axes | No | Lowest | see step 4 below |
| Single ArUco marker (scale + offset) | No | No | Low | How to calibrate a fixed camera to a robot with a single ArUco marker |
| Least-squares affine fit (≥3, ideally 7+ point pairs) | Yes | No | Medium | How to map camera coordinates to robot coordinates with a least-squares fit |
| ChArUco board + homography (many points, corrects lens distortion) | Yes | Yes | Medium-high | How to calibrate a camera and map pixels to world coordinates with a ChArUco board |
| Two-stage ArUco + homography + affine (built for high precision) | Yes | Yes | High | How to do high-precision robot-camera calibration with ArUco markers |
As a rule of thumb: start with the least-squares affine fit (How to map camera coordinates to robot coordinates with a least-squares fit) unless you already know you need lens distortion correction (wide-angle lens, or accuracy requirements under a millimetre), in which case go straight to the ChArUco method (How to calibrate a camera and map pixels to world coordinates with a ChArUco board).
4. The manual offset method (no code, good for understanding the problem)
If your camera looks straight down and its X/Y axes are exactly parallel (or exactly mirrored) to the robot’s — no rotation at all — you don’t need a fitted transform. You only need a pixel-to-mm scale and a fixed offset:
- Build (or reuse) a camera matrix and get a pixel-to-mm conversion factor: measure the width of the camera image in millimetres and divide it by the image width in pixels.
x_mm = pixel_x * conversion_factor y_mm = pixel_y * conversion_factor - Pick a reference point that both the camera and the robot can see, and call it StartPos. Measure how far StartPos is from the robot’s own origin — this distance is the offset.
- Check whether the camera’s and robot’s axes point the same way or are mirrored, and write your conversion accordingly, for example:
wherepickupX = deltaX + offsetX + array1[0] pickupY = deltaY + offsetY + array1[1]deltaX/deltaYare the object’s coordinates in mm relative to StartPos,offsetX/offsetYis the offset from step 2, andarray1is the robot’s current position relative to its own starting position (needed if the robot itself moves between captures, e.g. a wrist-mounted camera). - Add the robot’s current position (if it isn’t stationary) to get the final pick coordinate:

Here pickupX/pickupY are the final robot coordinates, deltaX/deltaY are the object’s coordinates in mm (step 1), offsetX/offsetY is the offset from step 2, array1[0]/array1[1] is the robot’s current position relative to its own starting position, and firstposX/firstposY are the StartPos coordinates from step 2.
Check: this method only works if there is zero rotation between the camera frame and the robot frame — it can only handle mirrored axes, not an arbitrary angle. If your camera is mounted even slightly rotated relative to the robot base, use the least-squares fit (How to map camera coordinates to robot coordinates with a least-squares fit) or a homography-based method instead — both fit rotation, scale and translation together instead of assuming a fixed axis relationship.
Related
- How to calibrate a camera and map pixels to world coordinates with a ChArUco board — ChArUco board + homography (full pipeline, corrects lens distortion)
- How to map camera coordinates to robot coordinates with a least-squares fit — least-squares affine fit
- How to calibrate a fixed camera to a robot with a single ArUco marker — single ArUco marker quick calibration
- How to do high-precision robot-camera calibration with ArUco markers — high-precision two-stage calibration
- How to convert a RealSense camera pixel to a 3D point and robot coordinates — RealSense 2D pixel → 3D point
- How to auto-calibrate a Cognex camera using fixed world points — Cognex camera auto-calibration
- How to calibrate a camera and convert a pixel distance to a real-world distance — camera calibration for measuring distances/sizes
Rewritten and consolidated (Sept 2026) from the original student how-to’s: How to go from Camera Pixels to Real-World Coordinates (calibration).