122121145151456165165456151653怎么用openmv识别红绿激光笔
尝试一下运行下面的代码, 如有帮助给个采纳谢谢
import sensor, image, time
red_threshold = (30, 100, 15, 127, 15, 127) # 红色激光笔的阈值范围
green_threshold = (30, 100, -64, -8, -32, 32) # 绿色激光笔的阈值范围
sensor.reset() # 重置OpenMV相机
sensor.set_pixformat(sensor.RGB565) # 设置像素格式为RGB565
sensor.set_framesize(sensor.QVGA) # 设置帧大小为QVGA (320x240)
sensor.skip_frames(time = 2000) # 跳过一些帧以使摄像头稳定
while(True):
img = sensor.snapshot() # 获取一帧图像
red_blobs = img.find_blobs([red_threshold]) # 在图像中查找红色区域
green_blobs = img.find_blobs([green_threshold]) # 在图像中查找绿色区域
if red_blobs:
for blob in red_blobs:
img.draw_rectangle(blob.rect()) # 在图像上绘制红色区域的矩形框
img.draw_cross(blob.cx(), blob.cy()) # 在图像上绘制红色区域的中心点
if green_blobs:
for blob in green_blobs:
img.draw_rectangle(blob.rect()) # 在图像上绘制绿色区域的矩形框
img.draw_cross(blob.cx(), blob.cy()) # 在图像上绘制绿色区域的中心点
time.sleep(10) # 等待一段时间
将代码上传到OpenMV相机上并运行,看效果
https://blog.csdn.net/weixin_42703735/article/details/100940125
不知道你这个问题是否已经解决, 如果还没有解决的话:![]() | ![]() |