• 方案介绍
  • 附件下载
  • 相关推荐
申请入驻 产业图谱

3.4.9-识别形状+颜色+最小变化阈值+增加最大变化阈值+卡尔曼滤波与运动估计

03/20 10:02
266
加入交流群
扫码加入
获取工程师必备礼包
参与热点资讯讨论

联系方式.txt

共1个文件

**非常详细的视频和文字教程,讲解常见的openmv教程包括 巡线、物体识别、圆环识别、阈值自动获取等。非常适合学习openmv、K210、K230等项目
视频合集链接在


openmv教程合集 openmv入门到项目开发 openmv和STM32通信 openmv和opencv区别 openmv巡线 openmv数字识别教程LCD

3.4.9-识别形状+颜色+最小变化阈值+增加最大变化阈值+卡尔曼滤波与运动估计+通过指定区域获得阈值

我们要增加通过指定区域获得阈值的功能,可以把"3.2.4-通过指定区域获得阈值介绍和单独实现"章节的代码移植进 到我们的"3.4.4章节"

先把函数复制过去
在这里插入图片描述

#****************[0]-获取指定位置阈值********************
threshold_calculated = False #控制阈值计算只执行一次的标志
threshold_roi = (70,50,20,20) #会通过这个位置获得追踪阈值
# 封装为函数:识别指定区域的阈值
def get_threshold(roi):
    # 循环多次(默认150次)更新阈值
    threshold = [0, 0, 0, 0, 0, 0]  # LAB色彩通道的阈值 [Lmin, Lmax, Amin, Amax, Bmin, Bmax]
    for _ in range(150):
        img = sensor.snapshot()
        # 获取指定区域的颜色直方图
        hist = img.get_histogram(roi=roi)
        img.draw_rectangle(roi, color=(0, 255, 0), thickness=2)  # 使用绿色(0, 255, 0),厚度为2# 在图像上绘制绿色矩形框标识采集区域
        # 在绿色矩形框上方显示“采集计算阈值中...”并加上省略号
        img.draw_string(roi[0], roi[1] - 10, "Collecting Threshold...", color=(0, 255, 0), scale=1)
        # 获取L、A、B三个通道的5%和95%分位值
        lo = hist.get_percentile(0.05)  # 获取5%分位值,表示颜色分布的下边界
        hi = hist.get_percentile(0.95)  # 获取95%分位值,表示颜色分布的上边界
        print("采集计算阈值中...请等待")  # 打印检查结果,1表示满足,0表示不满足
        # 输出lo和hi的值
#        print(f"5% Percentile (lo): L={lo.l_value()} A={lo.a_value()} B={lo.b_value()}")
#        print(f"95% Percentile (hi): L={hi.l_value()} A={hi.a_value()} B={hi.b_value()}")
        # L通道的最小值和最大值平均后作为新的阈值
        threshold[0] = (threshold[0] + lo.l_value()) // 2  # L通道的最小值
        threshold[1] = (threshold[1] + hi.l_value()) // 2  # L通道的最大值
        # A通道的最小值和最大值平均后作为新的阈值
        threshold[2] = (threshold[2] + lo.a_value()) // 2  # A通道的最小值
        threshold[3] = (threshold[3] + hi.a_value()) // 2  # A通道的最大值
        # B通道的最小值和最大值平均后作为新的阈值
        threshold[4] = (threshold[4] + lo.b_value()) // 2  # B通道的最小值
        threshold[5] = (threshold[5] + hi.b_value()) // 2  # B通道的最大值

    print(f"计算阈值的位置区域是 ROI Info: x={roi[0]}, y={roi[1]}, width={roi[2]}, height={roi[3]}")  # 输出roi区域的信息
    # 打印每个通道的阈值信息
    print("计算出的阈值  Threshold: Lmin={0} Lmax={1}, Amin={2} Amax={3}, Bmin={4} Bmax={5}".format(
        threshold[0], threshold[1], threshold[2], threshold[3], threshold[4], threshold[5]
    ))

    # 返回计算得到的阈值列表,包含L、A、B三个通道的最小值和最大值
    return threshold  # 返回最终的阈值数组

然后主函数执行的前面增加获得计算阈值的函数,函数输入一个要获得区域,然后把计算的阈值输出,后面就会使用到这个阈值
在这里插入图片描述

#*****************[2]-获取指定位置阈值-进行阈值计算的内容********************
    if not threshold_calculated:# 仅在阈值未计算时进行计算
        # 调用函数获取指定区域的阈值
        color_threshold = get_threshold(threshold_roi)

        # 设置阈值计算完成的标志
        threshold_calculated = True

然后这个是所有的代码如下还有如何使用的说明
在这里插入图片描述

import sensor, image, time
#*********************增加卡尔曼滤波*************************************************************************
import sensor, image, time, math
from ulab import numpy as np
#教程作者:好家伙VCC
#欢迎交流群QQ: 771027961 作者邮箱: 1930299709@qq.com
#更多教程B站主页:[好家伙VCC的个人空间-好家伙VCC个人主页-哔哩哔哩视频](https://space.bilibili.com/434192043)
#淘宝主页链接:[首页-好家伙VCC-淘宝网](https://shop415231378.taobao.com)
#更多嵌入式手把手教程-尽在好家伙VCC
# 定义颜色阈值(L, A, B),用于识别红色
# L通道:亮度值,较小表示较暗的颜色
# A通道:绿色与红色的色差,红色偏大
# B通道:蓝色与黄色的色差,红色偏小
color_threshold = (0, 100, 0, 127, 0, 127)  # (L_min, L_max, A_min, A_max, B_min, B_max)

# 初始化摄像头模块
sensor.reset()  # 重置摄像头,确保设备正常工作
sensor.set_pixformat(sensor.RGB565)  # 设置摄像头的像素格式为RGB565,每个像素16位色深
sensor.set_framesize(sensor.QQVGA)  # 设置摄像头的分辨率为QQVGA(160x120),适合快速处理

# *************************** 如果不需要镜像就注释掉以下代码 **************************
# 摄像头镜像和翻转设置,根据摄像头的安装方向调整
sensor.set_vflip(True)  # 设置垂直翻转,适用于摄像头上下安装的情况
sensor.set_hmirror(True)  # 设置水平翻转,适用于摄像头左右安装的情况
# *************************** 如果不需要镜像就注释掉以上代码 **************************

sensor.skip_frames(time = 2000)  # 跳过前几帧的图像,确保图像稳定后再开始处理
sensor.set_auto_gain(False)  # 必须关闭自动增益,防止影响颜色追踪
sensor.set_auto_whitebal(False)  # 必须关闭自动白平衡,防止影响颜色追踪

# 创建一个时钟对象,用于计算和控制帧率
clock = time.clock()

# *************************** 最小变化阈值滤波 **************************
# 位置和半径变化阈值,只有变化大于该阈值时才更新
position_threshold = 4  # 位置变化的最小阈值 两个值越小小球识别更新的越频繁,值越大小球的细微运动越不会更新识别
radius_threshold = 4    # 半径变化的最小阈值 可以根据自己的需求测试调节这个两个阈值
MAX_CHANGE_THRESHOLD = 80  # 最大变化阈值(例如位置或半径变化超过此值时不更新)
# 上一帧的圆心坐标和半径
prev_x, prev_y, prev_r = None, None, None
# *************************** 最小变化阈值滤波 **************************
#****************[0]-获取指定位置阈值********************
threshold_calculated = False #控制阈值计算只执行一次的标志
threshold_roi = (70,50,20,20) #会通过这个位置获得追踪阈值
# 封装为函数:识别指定区域的阈值
def get_threshold(roi):
    # 循环多次(默认150次)更新阈值
    threshold = [0, 0, 0, 0, 0, 0]  # LAB色彩通道的阈值 [Lmin, Lmax, Amin, Amax, Bmin, Bmax]
    for _ in range(150):
        img = sensor.snapshot()
        # 获取指定区域的颜色直方图
        hist = img.get_histogram(roi=roi)
        img.draw_rectangle(roi, color=(0, 255, 0), thickness=2)  # 使用绿色(0, 255, 0),厚度为2# 在图像上绘制绿色矩形框标识采集区域
        # 在绿色矩形框上方显示“采集计算阈值中...”并加上省略号
        img.draw_string(roi[0], roi[1] - 10, "Collecting Threshold...", color=(0, 255, 0), scale=1)
        # 获取L、A、B三个通道的5%和95%分位值
        lo = hist.get_percentile(0.05)  # 获取5%分位值,表示颜色分布的下边界
        hi = hist.get_percentile(0.95)  # 获取95%分位值,表示颜色分布的上边界
        print("采集计算阈值中...请等待")  # 打印检查结果,1表示满足,0表示不满足
        # 输出lo和hi的值
#        print(f"5% Percentile (lo): L={lo.l_value()} A={lo.a_value()} B={lo.b_value()}")
#        print(f"95% Percentile (hi): L={hi.l_value()} A={hi.a_value()} B={hi.b_value()}")
        # L通道的最小值和最大值平均后作为新的阈值
        threshold[0] = (threshold[0] + lo.l_value()) // 2  # L通道的最小值
        threshold[1] = (threshold[1] + hi.l_value()) // 2  # L通道的最大值
        # A通道的最小值和最大值平均后作为新的阈值
        threshold[2] = (threshold[2] + lo.a_value()) // 2  # A通道的最小值
        threshold[3] = (threshold[3] + hi.a_value()) // 2  # A通道的最大值
        # B通道的最小值和最大值平均后作为新的阈值
        threshold[4] = (threshold[4] + lo.b_value()) // 2  # B通道的最小值
        threshold[5] = (threshold[5] + hi.b_value()) // 2  # B通道的最大值

    print(f"计算阈值的位置区域是 ROI Info: x={roi[0]}, y={roi[1]}, width={roi[2]}, height={roi[3]}")  # 输出roi区域的信息
    # 打印每个通道的阈值信息
    print("计算出的阈值  Threshold: Lmin={0} Lmax={1}, Amin={2} Amax={3}, Bmin={4} Bmax={5}".format(
        threshold[0], threshold[1], threshold[2], threshold[3], threshold[4], threshold[5]
    ))

    # 返回计算得到的阈值列表,包含L、A、B三个通道的最小值和最大值
    return threshold  # 返回最终的阈值数组
#*********************增加卡尔曼滤波***************************8
Ts = 1/22 #Ts = 1  帧率的倒数
# 状态空间矩阵定义
 # 状态转移矩阵 A,描述系统的状态变化
#A = np.array([[1,0,0,0,Ts,0],[0,1,0,0,0,Ts],[0,0,1,0,0,0],[0,0,0,1,0,0],[0,0,0,0,1,0],[0,0,0,0,0,1]])
# 改进状态转移矩阵A,将速度部分更明确地包含进来A 是状态转移矩阵,描述了系统状态(位置、速度等)的变化。该矩阵会把当前的状态转换到下一时刻的状态。
A = np.array([[1, 0, 0, 0, Ts, 0],
              [0, 1, 0, 0, 0, Ts],
              [0, 0, 1, 0, 0, 0],
              [0, 0, 0, 1, 0, 0],
              [0, 0, 0, 0, 1, 0],
              [0, 0, 0, 0, 0, 1]])


 # 观测矩阵 C,描述从状态到观测值的映射关系  C 是观测矩阵,它将状态向量(位置、速度)与观测量(图像中的矩形框信息)联系起来。这里假设观测量是位置和速度。
C = np.array([[1,0,0,0,0,0],[0,1,0,0,0,0],[0,0,1,0,0,0],[0,0,0,1,0,0],[0,0,0,0,1,0],[0,0,0,0,0,1]])
# 过程噪声协方差矩阵
# 过程噪声协方差矩阵 Q,用于描述过程的随机噪声
#Q_value = [1e-8 for _ in range(6)]
#Q = np.diag(Q_value) #创建对角矩阵
# 增大过程噪声矩阵Q_value,使得卡尔曼滤波更灵活地应对物体快速运动
#Q 是过程噪声协方差矩阵,用于描述系统过程中的不确定性。矩阵的对角元素表示每个状态变量的噪声水平。
Q_value = [1e-6 for _ in range(6)]  # 调整过程噪声值Q_value = [1e-6 for _ in range(6)]
Q = np.diag(Q_value)  # 更新过程噪声协方差矩阵

# 观测噪声协方差矩阵  R 是观测噪声协方差矩阵,表示观测过程中测量误差的大小。
R_value = [1e-6 for _ in range(6)]
R = np.diag(R_value)
# 定义观测量Z
x = 0 #左顶点x坐标
y = 0 #左顶点y坐标
last_frame_x = x #上一帧左顶点x坐标
last_frame_y = y #上一帧左顶点y坐标
w = 0 #矩形框宽度w
h = 0 #矩形框高度h
dx = 0 #左顶点x坐标移动速度
dy = 0 #左顶点y坐标移动速度
Z = np.array([x,y,w,h,dx,dy])
# 定义卡尔曼滤波函数变量
#x_hat = np.array([80,60,30,30,2,2]) # 初始估计的状态值(位置、速度等)
# 初始状态估计:根据实际应用情况调整位置和速度的初值
x_hat = np.array([80, 60, 30, 30, 2, 2])  # 根据你的应用需要调整这些值

x_hat_minus = np.array([0,0,0,0,0,0]) # 初始预测的状态值
p_value = [10 for _ in range(6)] # 状态误差的初始值 p 是状态误差的初始协方差矩阵。
p = np.diag(p_value)# 创建误差协方差矩阵 p
#*********************增加卡尔曼滤波*************************************************************************

# 卡尔曼滤波函数
#预测阶段:利用状态转移矩阵和上一状态估计预测当前状态。
#校正阶段:通过卡尔曼增益对预测状态进行校正,使得估计值接近真实值。
#输入 Z:观测值(或测量值),通常是来自外部传感器(例如相机、雷达等)的数据。在这个代码中,Z 是一个包含目标的位置信息(如矩形框的四个角坐标)的向量,格式为 [x, y, w, h, dx, dy],其中 x 和 y 是目标的中心位置,w 和 h 是目标的宽度和高度,dx 和 dy 是目标的速度。
#输出 x_hat:更新后的状态估计,包括位置(x, y)、宽度(w, h)、速度(dx, dy)。该值是通过卡尔曼滤波器的预测和校正步骤计算得到的最优估计。
def Kalman_Filter(Z):
    global A,C,Q,R,x_hat,x_hat_minus,p
    # 预测部分
    x_hat_minus = np.dot(A,x_hat)
    p_minus = np.dot(A, np.dot(p, A.T)) + Q
    # 校正部分
    S = np.dot(np.dot(C, p_minus), C.T) + R
    # 选择一个小的正则化项
    regularization_term = 1e-4
    # 正则化 S 矩阵
    S_regularized = S + regularization_term * np.eye(S.shape[0])
    # 计算正则化后的 S 矩阵的逆
    S_inv = np.linalg.inv(S_regularized)
    # 计算卡尔曼增益 K
    K = np.dot(np.dot(p_minus, C.T), S_inv)
    x_hat = x_hat_minus + np.dot(K,(Z - np.dot(C,x_hat_minus)))
    p = np.dot((np.eye(6) - np.dot(K,C)),p_minus)
    return x_hat
last_frame_location = [0 for _ in range(4)] #用于存储上一帧的目标位置,这通常用于目标跟踪和计算目标移动等任务。一个长度为4的列表 last_frame_location,其中每个元素的初始值为 0
last_frame_rect = [0 for _ in range(4)]  #存储上一帧检测到的矩形框坐标 成了一个长度为4的列表 last_frame_rect,并且每个元素的初始值为 0。
box = [0 for _ in range(4)] #生成一个包含四个子列表的列表,存储x1,y1,x2,y2

# 主循环,不断获取摄像头图像并进行处理
while(True):
    clock.tick()  # 计时当前帧的处理时间,计算帧率

    # 获取当前图像并进行镜头畸变校正,纠正因镜头产生的畸变
    img = sensor.snapshot().lens_corr(1.8)  # 1.8是畸变系数,适当调整可以改善图像质量

#*****************[2]-获取指定位置阈值-进行阈值计算的内容********************
    if not threshold_calculated:# 仅在阈值未计算时进行计算
        # 调用函数获取指定区域的阈值
        color_threshold = get_threshold(threshold_roi)

        # 设置阈值计算完成的标志
        threshold_calculated = True

    # 使用霍夫变换查找圆形,并返回找到的圆的信息
    for c in img.find_circles(
        threshold = 2500,  # 设置圆形检测的阈值。较高的值意味着需要更明显的圆形才能被检测到
        x_margin = 10,     # 圆心的X坐标允许的误差范围
        y_margin = 10,     # 圆心的Y坐标允许的误差范围
        r_margin = 10,     # 圆半径的允许误差范围
        r_min = 2,         # 圆的最小半径 单位为像素。
        r_max = 100,       # 圆的最大半径 单位为像素。100 像素对应多少毫米是一个动态计算的问题,需要根据具体的摄像头视场角、分辨率和物体距离来调整。
        r_step = 2         # 圆半径变化的步长 单位为像素。
    ):
        # 计算圆形的外接矩形区域,这样可以方便获取圆的统计信息
        area = (c.x() - c.r(), c.y() - c.r(), 2 * c.r(), 2 * c.r())  # (x, y, width, height)
        # 获取该区域内的像素颜色统计信息
        statistics = img.get_statistics(roi=area)  # 获取外接矩形区域的像素统计信息(颜色分布)

        # 打印该区域的颜色统计数据,用于调试
        #print(statistics)

        # 判断该区域是否为红色圆
        # 使用L、A、B通道的众数来判断颜色是否符合红色范围
        if (
            color_threshold[0] < statistics.l_mode() < color_threshold[1] and  # L通道的众数应小于100,表示较暗的颜色
            color_threshold[2] < statistics.a_mode() < color_threshold[3] and  # A通道的众数应小于127,表示偏红色
            color_threshold[4] < statistics.b_mode() < color_threshold[5]      # B通道的众数应小于127,表示偏蓝色
        ):
            # 获取当前圆心和半径
            x, y, r = c.x(), c.y(), c.r()


            # 如果是第一次检测,更新值
            if prev_x is None or prev_y is None or prev_r is None:
                prev_x, prev_y, prev_r = x, y, r  #更新上次的位置值
                # 绘制圆形
                img.draw_circle(x, y, r, color=(192, 255, 0)) #绘制圆为绿色
                # 输出圆心坐标和半径
                print("第一次检测       First detection: center_x = {}, center_y = {}, radius = {}".format(x, y, r))
                circle_center_x = x
                circle_center_y = y
                circle_radius = r

            else:
                # 判断位置和半径变化是否大于阈值
                x_change = abs(x - prev_x)#计算这次值和上次值 的绝对值
                y_change = abs(y - prev_y)
                r_change = abs(r - prev_r)

                # 判断变化是否大于最小阈值,并且变化小于最大阈值
                if (
                    (x_change > position_threshold or y_change > position_threshold or r_change > radius_threshold) and
                    (x_change <= MAX_CHANGE_THRESHOLD and y_change <= MAX_CHANGE_THRESHOLD and r_change <= MAX_CHANGE_THRESHOLD)
                ):
                    # 变化大于阈值,更新值
                    prev_x, prev_y, prev_r = x, y, r
                    # 绘制更新后的圆形
                    img.draw_circle(x, y, r, color=(192, 255, 0))
                    # 输出圆心坐标和半径
                    print("更新检测       Updated detection: center_x = {}, center_y = {}, radius = {}".format(x, y, r))
                    circle_center_x = x
                    circle_center_y = y
                    circle_radius = r

                else :
                    # 变化小于阈值,绘制上次的坐标和半径
                    img.draw_circle(prev_x, prev_y, prev_r, color=(192, 255, 0))
                    # 输出圆心坐标和半径(使用上次的坐标和半径)
                    print("没有显著变化 No significant change: center_x = {}, center_y = {}, radius = {}".format(prev_x, prev_y, prev_r))
                    circle_center_x = prev_x
                    circle_center_y = prev_y
                    circle_radius = prev_r


            # 假设圆的中心 (c.x(), c.y()) 和半径 c.r()


            # 计算矩形框的左上角坐标和宽高
            rect_x = int(circle_center_x - circle_radius)  # 矩形框左上角的 x 坐标
            rect_y = int(circle_center_y - circle_radius)  # 矩形框左上角的 y 坐标
            rect_w = int(2 * circle_radius)  # 矩形框的宽度,等于圆的直径
            rect_h = int(2 * circle_radius)  # 矩形框的高度,等于圆的直径

            # 将矩形框的四个参数存储到 rect 数组中
            rect = [rect_x, rect_y, rect_w, rect_h]


            box = [rect[0], rect[1], rect[0] + rect[2], rect[1] + rect[3]] # 计算标记框的四个角坐标(左上角和右下角)
            x, y, w, h = rect[0], rect[1], rect[2], rect[3]# 获取新的矩形框的坐标 识别成功的时候这个值是识别值的数据赋值
            dx = (x - last_frame_x) / Ts# 计算x方向的速度,假设 Ts 为时间步长
            dy = (y - last_frame_y) / Ts# 计算y方向的速度
            Z = np.array([x, y, w, h, dx, dy]) # 构造测量向量 Z,包括位置和速度
            x_hat = Kalman_Filter(Z)# 使用卡尔曼滤波器进行状态估计
            last_frame_x, last_frame_y = x, y # 更新上一帧的x, y坐标
            #img.draw_rectangle(last_frame_rect, color = (0, 0, 255))
            #img.draw_rectangle(rect, color = (255, 0, 0)) # 用红色矩形框绘制目标位置
            last_frame_rect = rect# 更新上一帧的矩形框 识别成功的时候
            last_frame_location = box# 更新上一帧的位置 识别成功的时候




        else:
            # 如果不是红色圆形,用白色矩形框标记该区域
            #img.draw_circle(c.x(), c.y(), c.r(), color=(255, 255, 255))  # 白色



            # 如果不是红色圆形,用白色矩形框标记该区域
            #img.draw_circle(c.x(), c.y(), c.r(), color=(255, 255, 255))  # 白色
            #解释:根据卡尔曼滤波的预测值和目标的速度来更新目标的位置:
            #x_hat[0] 和 x_hat[1] 是预测的位置,x_hat[4] 和 x_hat[5] 是目标的速度(速度分别对应 dx 和 dy)。
            #Ts 是时间步长。更新后的 x, y 位置是通过加入速度(dx 和 dy)的影响来计算的。
            #w 和 h 是目标的宽度和高度,这些信息没有改变,仍然使用 x_hat[2] 和 x_hat[3]。
            x,y,w,h = (x_hat[0] + (x_hat[4] * Ts)),(x_hat[1] + (x_hat[5] * Ts)),x_hat[2],x_hat[3]
            #解释:计算目标在 X 方向的速度(dx),通过当前帧的 x 位置与上一帧的 last_frame_x 位置之差来计算,除以时间步长 Ts
            dx = (x - last_frame_x) / Ts
            #解释:计算目标在 Y 方向的速度(dy),通过当前帧的 y 位置与上一帧的 last_frame_y 位置之差来计算,除以时间步长 Ts
            dy = (y - last_frame_y) / Ts
            #解释:将目标的位置、宽高、速度(dx 和 dy)组合成一个状态向量 Z,这个向量将作为卡尔曼滤波器的输入
            Z = np.array([x, y, w, h, dx, dy])
            #解释:将状态向量 Z 传递给卡尔曼滤波器 Kalman_Filter,以获得更新后的预测状态 x_hat
            x_hat = Kalman_Filter(Z)
            #更新上一帧的目标位置 last_frame_x 和 last_frame_y 为当前帧的目标位置 x 和 y,以便在下一帧计算速度时使用
            last_frame_x, last_frame_y = x, y
            #更新上一帧的目标矩形框 last_frame_rect 为当前帧的矩形框 x, y, w, h。
            last_frame_rect = [x,y,w,h]
            #更新上一帧的目标位置 last_frame_location 为当前帧的目标位置。这是一个矩形框的坐标,包括左上角 (x, y) 和右下角 (x + w, y + h)
            last_frame_location = [x,y,(x + w),(y + h)]

    predicted_rect = [ # 使用卡尔曼滤波的预测值绘制预测的矩形框
        int(x_hat[0]),# 预测的矩形框左上角x坐标
        int(x_hat[1]),# 预测的矩形框左上角y坐标
        int(x_hat[2]), # 预测的矩形框宽度
        int(x_hat[3]) # 预测的矩形框高度
    ]
    # 绘制矩形框
    img.draw_rectangle(predicted_rect, color=(100, 100, 100))  # 使用灰色绘制矩形框
    #下面是把矩形转化会园绘制的,我们不需要
#    # 计算圆心坐标和半径
    center_x = int(x_hat[0] + x_hat[2] / 2)  # 圆心x坐标(矩形框左上角x + 宽度的一半)
    center_y = int(x_hat[1] + x_hat[3] / 2)  # 圆心y坐标(矩形框左上角y + 高度的一半)
    radius = int(min(x_hat[2], x_hat[3]) / 2)  # 半径取矩形框宽度和高度的最小值的一半
    # 输出圆心坐标和半径信息
    print("卡尔曼计算       Predicted Circle: center_x = {}, center_y = {}, radius = {}".format(center_x, center_y, radius))

    # 打印当前帧率(每秒帧数),便于调试性能
    print("FPS %f" % clock.fps())  # 输出当前的帧率

  • 联系方式.txt
    下载
点赞
收藏
评论
分享
加入交流群
举报

相关推荐

方案定制

去合作
方案开发定制化,2000+方案商即时响应!