OpenCV/Python - 按边界框区域查找异常值



我有一个使用 TensorFlow 设置的对象检测算法,有没有办法删除框大小方面的异常值?

例如,我检测到 20 个对象。假设其中 17 个大约是 50x50。但是,有几个边界框是 1x1,一个框是 1000x1000。显然,1x1 和 1000x1000 盒子太大了,应该删除。

一种方法是使用z_score。 z_score将检查此数字与平均值相差多少std_devs。

例:

# coding: utf-8
import cv2
import numpy as np

bboxes = [(100,200), (120,210), (114, 195), (2,190), (104, 300), (111, 3), (110, 208), (114,205)]

def z_score(ys):
mean_y = np.mean(ys)
stdev_y = np.std(ys)
z_scores = np.abs([(y - mean_y) / stdev_y for y in ys])
return z_scores
thresh   = 1
outliers = [(t[0]>thresh or t[1]>thresh) for t in z_score(bboxes)]

这将打印: [

假、假、假、真、真、真、假、假]

最新更新