识别激光点
from maix import image, display, camera
import time
blue = [(51, 100, 11, 127, -15, 127)]
# 61, 100, 6, 127, -28, 127
while True:
img = camera.capture()
time.sleep(0.02)
blobs = img.find_blobs(blue, merge=True) #在图片中查找lab阈值内的颜色色块 merge 合并小框。
if blobs:
for i in blobs:
img.draw_rectangle(i["x"], i["y"], i["x"] + i["w"], i["y"] + i["h"],
color=(0, 0, 255), thickness=1) #将找到的颜色区域画出来
img.draw_string(i["x"], i["y"], "x:"+str(i["x"] + i["w"]/2)+" y: "+str(i["y"] + i["h"]/2), color= (255, 0, 0), thickness=2)
display.show(img)