QOJ.ac

QOJ

Límite de tiempo: 15.0 s Límite de memoria: 256 MB Puntuación total: 100 Hackeable ✓

#11218. 非极大值抑制

Estadísticas

非极大值抑制(Non-Maximum Suppression, NMS)已广泛应用于计算机视觉的多个方面,是许多目标检测算法中不可或缺的一部分。目标检测中最常见的问题之一是同一个物体可能会被检测多次。NMS 技术确保了每个物体只保留一个检测结果。

对于每个类别,算法会提出一系列边界框。每个框都关联一个分数,表示算法认为该框内存在给定类别物体的置信度。现在让我们看看 NMS 过程是如何工作的。最初,所有的框都是未选中且未被抑制的。

  1. 首先,在所有未选中且未被抑制的框中,选择置信度分数最高的框。
  2. 然后,查看图像中所有未选中的框。如果某个未选中的框与已选中的框之间的 IoU 严格大于给定的阈值,则该未选中的框将被抑制(丢弃)。

我们通过交并比(Intersection over Union, IoU)的概念来衡量两个框的重叠程度。

IoU = \frac{\text{Area of Overlap}}{\text{Area of Union}}

  1. 重复上述过程,直到所有非抑制框都被选中。

在本题中,我们假设只有一个类别,并通过仅提出相同大小的正方形框来简化目标检测算法。给定 IoU 阈值和算法提出的一系列全等正方形框,你能报告经过 NMS 过程后所有被选中的框吗?

输入格式

输入的第一行给出一个整数 $T$ ($1 \le T \le 10$),表示测试用例的数量。接下来是 $T$ 个测试用例。

对于每个测试用例,第一行包含两个整数 $n, S$ ($1 \le n \le 10^5, 1 \le S \le 10^7$) 和一个浮点数 $threshold$ ($0.300 \le threshold \le 0.700$),分别表示检测算法提出的正方形边界框数量、正方形的边长以及 IoU 阈值。$threshold$ 是精确的,并给出到小数点后三位。

接下来的 $n$ 行,每行包含两个整数 $x, y$ ($0 \le x < x + S \le 10^7, 0 \le y < y + S \le 10^7$),表示正方形框左下角的坐标,随后是一个浮点数 $score$ ($0.0 \le score \le 1.0$),表示该框的得分。得分是精确的,最多有六位小数。此外,得分各不相同。

输出格式

对于每个测试用例,输出以一行 “Case #x: y” 开头,其中 $x$ 是测试用例编号(从 1 开始),$y$ 是经过 NMS 过程后选中的边界框数量。 下一行包含 $y$ 个整数,按升序排列,表示选中框的索引(从 1 开始)。

样例

输入格式 1

1
3 4 0.390
0 0 0.9
1 1 0.8
2 2 0.7

输出格式 1

Case #1: 2
1 3

说明

示例中有 3 个框:$[0, 4] \times [0, 4]$,$[1, 5] \times [1, 5]$ 和 $[2, 6] \times [2, 6]$,它们已经按分数降序排列。第二个框被抑制,因为第一个框和第二个框的 IoU 为 $\frac{9}{23}$,这严格大于 $0.390$(IoU 阈值)。第三个框被选中,因为第一个框和第三个框的 IoU 为 $\frac{1}{7}$,这小于 IoU 阈值。

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.