Rust版Autopilot中find_color函数使用异常求助
autopilot-rs中bitmap::find_color函数屏幕捕获位图查找异常问题
- 基于Rust的autopilot库开发时,遇到bitmap模块的
find_color函数异常:参考同结构的find_bitmap实现逻辑编写代码,但功能无法正常运行。 - 需求是在位图内查找黑色像素,然而只有当起始像素为黑色时才能被检测到,其余位置的黑色像素完全无法识别。实际表现和函数文档描述不符,看起来函数仅检查了起始点像素,而非遍历所有像素:
/// Attempts to find
colorinsiderectinbmpfrom the given
///start_point. Returns coordinates if found, orNoneif not. If
///rectisNone,bmp.bounds()is used instead. Ifstart_pointis
///None, the origin ofrectis used.
///
/// Tolerance is defined as a float in the range from 0 to 1, where 0 is
/// an exact match and 1 matches anything.
- 尝试过多种代码写法和参数组合,输出始终为
None,仅在图像起始位置是黑色像素时能得到结果。 - 已确认屏幕捕获的截图中确实存在黑色像素,
get_color函数可以正常获取指定位置的像素颜色,但find_every_color同样无法找到目标颜色。 - 测试对比发现:加载本地图片时
find_color能正常工作,仅屏幕捕获的位图会出现此异常。
内容的提问来源于stack exchange,提问作者mightymouse2045
相关产品推荐
相关产品推荐

