【问题标题】:Is there a way to extract the coordinates from cv2.rectangle from the opencv object tracker kcf?有没有办法从 opencv 对象跟踪器 kcf 中提取 cv2.rectangle 的坐标?
【发布时间】:2021-02-01 21:17:28
【问题描述】:

我要做的是从 cv2.rectangle 制作的边界框中提取坐标。边界框是使用生成 cv2.rectangle 的 HOG 创建的:

        rects, weights = hog.detectMultiScale(frame, winStride=(8,8))
        rects = np.array([[x, y, x + w, y + h] for (x, y, w, h) in rects])
        for (xA, yA, xB, yB) in rects:
            cv2.rectangle(frame, (xA, yA), (xB, yB), (0, 255, 0), 2)

然后我用KCF tracker来跟踪这个bounding box,有没有办法提取KCF tracker的坐标数据?

【问题讨论】:

    标签: python opencv


    【解决方案1】:

    当然有更新功能

    (success, box) = tracker.update(frame)
    # check to see if the tracking was a success
    if success:
        (x, y, w, h) = [int(v) for v in box]
        cv2.rectangle(frame, (x, y), (x + w, y + h),
            (0, 255, 0), 2)
    

    【讨论】:

    • 每当我得到要打印的 x 和 y 坐标时,它都是一个常数,我相信它是输入边界框坐标。在我的循环中的第一个实例之后,我似乎无法让它更新。
    • 你能告诉我更多你的代码吗,至少是循环部分?
    猜你喜欢
    • 1970-01-01
    • 2021-07-28
    • 1970-01-01
    • 2016-06-23
    • 2021-03-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-06-02
    相关资源
    最近更新 更多