You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Rust版Autopilot中find_color函数使用异常求助

autopilot-rs中bitmap::find_color函数屏幕捕获位图查找异常问题
  • 基于Rust的autopilot库开发时,遇到bitmap模块的find_color函数异常:参考同结构的find_bitmap实现逻辑编写代码,但功能无法正常运行。
  • 需求是在位图内查找黑色像素,然而只有当起始像素为黑色时才能被检测到,其余位置的黑色像素完全无法识别。实际表现和函数文档描述不符,看起来函数仅检查了起始点像素,而非遍历所有像素:

/// Attempts to find color inside rect in bmp from the given
/// start_point. Returns coordinates if found, or None if not. If
/// rect is None, bmp.bounds() is used instead. If start_point is
/// None, the origin of rect is 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

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.18 07:17:36