.. currentmodule:: esp_ai .. _esp_ai.color_detection: class color_detection -- 颜色识别 ====================================== color_detection 用于颜色识别。 示例:: import esp_ai c = esp_ai.color_detection( color=0 ) #构建颜色识别对象,识别红色 c.start) #启动 c.read() #获取识别结果 构造函数 ------------ .. class:: color_detection( color=0 ) 构建颜色识别对象。需要初始化摄像头和LCD。 - ``color`` 要识别的颜色: - ``0`` - RED, 红色; - ``1`` - ORANGE,橙色; - ``2`` - RED, 红色; - ``3`` - GREEN,绿色; - ``4`` - CYAN, 青色; - ``5`` - BLUE,蓝色; - ``6`` - PURPLE, 紫色; - ``7`` - WHITE,白色; - ``8`` - GRAV, 灰色; - ``9`` - STUDY,自定义学习; 使用方法 -------------- .. method:: color_detection.start() 启动AI功能。 .. method:: color_detection.read() 识别摄像头图像中的色块并返回数据。 结果说明:返回矩形区域数量和对应的左上角和右下角坐标(4个值)。 无检测结果返回(0) 1个结果,返回(1,A[x0],A[y0],A[x1],A[y1]) 2个结果,返回(2,A[x0],A[y0],A[x1],A[y1],B[x0],B[y0],B[x1],B[y1]) 如此类推,最大支持返回5个结果。