-215 opencv assertion_error ai_generated true

cv::error: (-215:断言失败) !_dictionary.empty() 在函数 'detectMarkers' 中

cv::error: (-215:Assertion failed) !_dictionary.empty() in function 'detectMarkers'

ID: opencv/aruco-dictionary-not-found

其他格式: JSON · Markdown 中文 · English
92%修复率
86%置信度
1证据数
2024-01-05首次发现

版本兼容性

版本状态引入弃用备注
4.6.0 active
4.8.1 active
4.9.0 active

根因分析

传递给 cv::aruco::detectMarkers 的 ArUco 字典对象为空或未正确初始化,通常是由于无效的字典 ID 或创建失败。

English

The ArUco dictionary object passed to cv::aruco::detectMarkers is empty or not properly initialized, often due to an invalid dictionary ID or failed creation.

generic

官方文档

https://docs.opencv.org/4.x/d5/dae/tutorial_aruco_detection.html

解决方案

  1. 使用预定义字典:cv::aruco::Dictionary dictionary = cv::aruco::getPredefinedDictionary(cv::aruco::DICT_6X6_250);
  2. 在使用前检查字典是否为空:if (dictionary.empty()) { /* 回退 */ }

无效尝试

常见但无效的做法:

  1. 80% 失败

    The dictionary object may be empty if not populated with marker images; detectMarkers requires a non-empty dictionary with predefined markers.

  2. 85% 失败

    If the dictionary ID is not available in the OpenCV build, the constructor returns an empty dictionary, causing the assertion.