# ArUco marker is not detected: dictionary, size, lighting and camera focus

> Fix undetected ArUco markers: use the same dictionary for printing and detection, a white border, enough pixel size and good light.

Canonical: https://roboticsengineering.in/fix/aruco-marker-not-detected-dictionary-size-lighting/ | Published: 2026-11-03 | Updated: 2026-11-04

**The dictionary used to print the marker must match the dictionary used to detect it.**

## What the message means

Each dictionary has its own patterns. A marker from one will not be found by another. Small, blurred or glossy markers also fail.

## Fix it in this order

1. Print the marker from the dictionary you pass to the detector.
2. Keep a white border around it, and print on matte paper.
3. Make the marker large enough that it covers many pixels in the image.
4. Focus the camera and light the marker evenly.
5. Check the library version, since the detector interface changed between OpenCV versions.
6. Calibrate the camera for pose estimation.

## Why it happens

An ArUco dictionary is a fixed set of bit patterns, named by its grid size and how many markers it holds, such as 4×4 with 50 markers. A marker only matches in the dictionary it came from, and an ID higher than the dictionary holds does not exist. The detector also needs a white border around the marker to find its edges.

OpenCV 4.7 changed the Python interface to an ArucoDetector class, so older tutorials fail with attribute errors on newer installs. Print the marker large and matte, since glare removes the black and white contrast the detector depends on.

## If you see this, do this

| You see | Do this |
| --- | --- |
| Never detected | Dictionary mismatch. |
| Detected only close up | Marker too small or blurred. |

## Related

[ArUco localization](https://roboticsengineering.in/aruco-marker-robot-localization/), [camera calibration](https://roboticsengineering.in/camera-calibration-opencv-python/).

Last reviewed: November 2026. These are the usual causes and the order that finds them fastest. Test on your own board; clones and cables differ.

## Why this happens

A marker detector does not look for a picture; it looks for a square, reads the black and white cells inside it, and checks the resulting bit pattern against a dictionary. If the dictionary you ask for is not the one used to print the marker, the pattern is simply not valid and the marker is rejected. A DICT_4X4_50 marker has a 4 by 4 block of data bits inside a one-cell black border, which makes a 6 by 6 grid of cells; a DICT_6X6_250 marker makes an 8 by 8 grid.

Each cell needs several camera pixels to be read reliably. A marker that is small in the picture, blurred by poor focus, washed out by glare or tilted steeply loses cell boundaries. The white quiet margin around the black border also has to be kept when printing, or the square cannot be found.

## How to confirm the cause

- Print the number of rejected candidates as well as the ids. Many rejected squares with no ids usually means a dictionary mismatch or marker too small.
- Check the marker’s width in pixels in the camera picture. If one cell is only one or two pixels wide, move closer, use a bigger print or raise the resolution.
- Confirm the id exists in your dictionary: id 60 does not exist in a 50-marker dictionary.
- Look at the picture with your own eyes for blur, glare or a missing white margin.
- Check whether the image is mirrored. A flipped image gives a mirrored pattern that does not match.

## Worked example

Detection with the class-based interface of OpenCV 4.7 and later. Older versions used cv2.aruco.detectMarkers.

```
import cv2
aruco = cv2.aruco
dic = aruco.getPredefinedDictionary(aruco.DICT_4X4_50)
det = aruco.ArucoDetector(dic, aruco.DetectorParameters())

gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
corners, ids, rejected = det.detectMarkers(gray)
print(ids, len(rejected))
```

## Common mistakes

- Generating markers from one dictionary and detecting with another.
- Printing without the white border or cropping it away.
- Scaling a printed marker so the edges blur on a low-quality printer.
- Using a glossy surface that reflects a lamp into the camera.
- Leaving autofocus hunting, so the picture is soft.

## If this did not fix it

- The OpenCV build lacks the aruco module (older versions need the contrib package).
- The camera exposure is too long and moving markers smear.
- The viewing angle is too steep, which squashes the cells.
- Detector parameters tuned for another size; try the defaults first.
