首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >两种检测方法的交叉结合

两种检测方法的交叉结合
EN

Stack Overflow用户
提问于 2015-02-25 16:00:20
回答 4查看 51.2K关注 0票数 25

我正在读报纸:费拉里等人在“亲和力测量”一节。我了解法拉利等人。试图通过以下方式获得亲和力:

  1. 位置亲和力--两种检测方法的交叉结合使用区域
  2. 外观亲和力-使用直方图之间的欧几里德距离
  3. KLT点亲和测度

然而,我有两个主要问题:

  1. 我不明白两个探测之间的交叉相交是什么意思,以及如何计算它。
  2. 我尝试了一种略有不同的外观亲和力测量。将RGB检测转化为HSV..concatenating -- Hue和饱和度为1向量,并与其它检测方法进行比较。然而,使用这一技术失败,因为一个袋子的检测有一个更好的相似性评分比一个人的头部检测(具有不同的方向)。

对上述问题有何建议或解决办法?非常感谢您的帮助。

EN

回答 4

Stack Overflow用户

回答已采纳

发布于 2015-02-25 18:25:34

1)有两个重叠的边框。计算框的交集,这是重叠的区域。计算重叠框的总和,即整个框的面积之和减去重叠区域的面积。然后你把交叉口除以工会。计算机视觉系统工具箱中有一个名为bboxOverlapRatio的函数。

2)一般来说,你不想连接彩色通道。相反,你需要的是一个三维直方图,其中的维数是H、S和V。

票数 28
EN

Stack Overflow用户

发布于 2017-01-15 11:41:04

试着在联合路口交叉路口

在Union上的交集是一种评估指标,用于测量特定数据集上的对象检测器的精度。

更正式地说,为了在Union上应用交集来评估(任意)对象检测器,我们需要:

  1. 地面-真相包围框(即,手标记的边界框从测试集,指定在图像中我们的对象在哪里)。
  2. 从我们的模型中预测的包围盒。

下面我包含了一个地面真相包围框和预测边界框的视觉示例:

预测的包围框用红色绘制,而地面真值(即用手标记的)包围框用绿色绘制。

在上面的图中,我们可以看到我们的目标检测器已经在图像中检测到一个停止标志的存在。

因此,可以通过以下方法确定Union上的计算交叉口:

只要我们有这两组包围框,我们就可以在Union上应用交集。

这里是Python代码

代码语言:javascript
复制
# import the necessary packages
from collections import namedtuple
import numpy as np
import cv2

# define the `Detection` object
Detection = namedtuple("Detection", ["image_path", "gt", "pred"])

def bb_intersection_over_union(boxA, boxB):
    # determine the (x, y)-coordinates of the intersection rectangle
    xA = max(boxA[0], boxB[0])
    yA = max(boxA[1], boxB[1])
    xB = min(boxA[2], boxB[2])
    yB = min(boxA[3], boxB[3])

    # compute the area of intersection rectangle
    interArea = (xB - xA) * (yB - yA)

    # compute the area of both the prediction and ground-truth
    # rectangles
    boxAArea = (boxA[2] - boxA[0]) * (boxA[3] - boxA[1])
    boxBArea = (boxB[2] - boxB[0]) * (boxB[3] - boxB[1])

    # compute the intersection over union by taking the intersection
    # area and dividing it by the sum of prediction + ground-truth
    # areas - the interesection area
    iou = interArea / float(boxAArea + boxBArea - interArea)

    # return the intersection over union value
    return iou

gtpred

  1. gt:地面-真相包围盒.
  2. pred:从我们的模型中预测的包围盒。

有关更多信息,请单击这个职位

票数 43
EN

Stack Overflow用户

发布于 2019-04-26 19:14:31

目前的答案已经清楚地解释了这个问题。因此,在这里,我提供了一个更好的IoU版本,当两个边界框不相交时,它不会中断。

代码语言:javascript
复制
import numpy as np

def IoU(box1: np.ndarray, box2: np.ndarray):
    """
    calculate intersection over union cover percent
    :param box1: box1 with shape (N,4) or (N,2,2) or (2,2) or (4,). first shape is preferred
    :param box2: box2 with shape (N,4) or (N,2,2) or (2,2) or (4,). first shape is preferred
    :return: IoU ratio if intersect, else 0
    """
    # first unify all boxes to shape (N,4)
    if box1.shape[-1] == 2 or len(box1.shape) == 1:
        box1 = box1.reshape(1, 4) if len(box1.shape) <= 2 else box1.reshape(box1.shape[0], 4)
    if box2.shape[-1] == 2 or len(box2.shape) == 1:
        box2 = box2.reshape(1, 4) if len(box2.shape) <= 2 else box2.reshape(box2.shape[0], 4)
    point_num = max(box1.shape[0], box2.shape[0])
    b1p1, b1p2, b2p1, b2p2 = box1[:, :2], box1[:, 2:], box2[:, :2], box2[:, 2:]

    # mask that eliminates non-intersecting matrices
    base_mat = np.ones(shape=(point_num,))
    base_mat *= np.all(np.greater(b1p2 - b2p1, 0), axis=1)
    base_mat *= np.all(np.greater(b2p2 - b1p1, 0), axis=1)

    # I area
    intersect_area = np.prod(np.minimum(b2p2, b1p2) - np.maximum(b1p1, b2p1), axis=1)
    # U area
    union_area = np.prod(b1p2 - b1p1, axis=1) + np.prod(b2p2 - b2p1, axis=1) - intersect_area
    # IoU
    intersect_ratio = intersect_area / union_area

    return base_mat * intersect_ratio
票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/28723670

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档