系统迁移中,暂时无法访问,所有数据会迁移到新的网站。
OpenMV VSCode 扩展发布了,在插件市场直接搜索OpenMV就可以安装
如果有产品硬件故障问题,比如无法开机,论坛很难解决。可以直接找售后维修。
发帖子之前,请确认看过所有的视频教程,https://singtown.com/learn/ 和所有的上手教程http://book.openmv.cc/
每一个新的提问,单独发一个新帖子
帖子需要目的,你要做什么?
如果涉及代码,需要报错提示与全部代码文本,请注意不要贴代码图片
必看:玩转星瞳论坛了解一下图片上传,代码格式等问题。
你好,这个find_feature这个函数阈值为啥越高越容易检测出来
-
import sensor
import time
import image重置传感器
sensor.reset()
传感器设置优化
sensor.set_contrast(1) # 对比度设置
sensor.set_gainceiling(16) # 增益上限
sensor.set_framesize(sensor.HQVGA) # 320x240分辨率
sensor.set_pixformat(sensor.GRAYSCALE) # 灰度图像加载内置Haar级联
face_cascade = image.HaarCascade("/rom/haarcascade_frontalface.cascade", stages=25)
eyes_cascade = image.HaarCascade("/rom/haarcascade_eye.cascade", stages=24)
print("使用内置级联器:", eyes_cascade)FPS时钟
clock = time.clock()
参数调试变量
current_eye_threshold = 0.2 # 眼睛检测阈值
current_eye_scale = 1.1 # 眼睛检测缩放因子
current_face_threshold = 0.1 # 人脸检测阈值
current_face_scale = 1.5 # 人脸检测缩放因子while True:
clock.tick()
img = sensor.snapshot()# 图像预处理 - 增强眼睛特征 # 1. 自适应直方图均衡化 - 增强对比度 img = img.histeq(adaptive=True, clip_limit=2.0) # 2. 高斯模糊 - 减少噪声 img = img.gaussian(1) # 人脸检测 faces = img.find_features( face_cascade, threshold=current_face_threshold, scale_factor=current_face_scale ) detected_eyes = 0 for face in faces: img.draw_rectangle(face) # 优化眼睛检测区域 - 适应眼镜情况 eye_roi = ( face[0] + int(face[2]*0.1), # 左右各留10%边界 face[1] + int(face[3]*0.25), # 从顶部25%开始(避开眼镜上框) int(face[2]*0.8), # 宽度减少20% int(face[3]*0.35) # 高度为面部的35%(聚焦眼睛区域) ) # 绘制眼睛ROI区域(调试用) img.draw_rectangle(eye_roi, color=(0, 255, 0)) # 眼睛检测参数优化 eyes = img.find_features( eyes_cascade, threshold=current_eye_threshold, scale_factor=current_eye_scale, roi=eye_roi, #step_size=1, # 更精细的搜索 # min_size=(10, 10) # 最小眼睛尺寸 ) # 绘制眼睛并添加标签 for e in eyes: img.draw_rectangle(e, color=(255, 0, 0)) img.draw_string(e[0], e[1]-10, "Eye", color=(255,0,0)) detected_eyes += 1 # 显示调试信息 img.draw_string(0, 0, "FPS:%.1f" % clock.fps(), color=(255,0,0)) img.draw_string(0, 15, "EyeTh:%.2f EyeSc:%.2f" % (current_eye_threshold, current_eye_scale), color=(255,0,0)) img.draw_string(0, 30, "FaceTh:%.2f FaceSc:%.2f" % (current_face_threshold, current_face_scale), color=(255,0,0)) img.draw_string(0, 45, "Eyes:%d" % detected_eyes, color=(255,0,0))
-
详细可以查看官方的api定义:https://docs.singtown.com/micropython/zh/latest/openmvcam/library/omv.image.html#image.Image.find_features