简体   繁体   English

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

[英]OpenCV/Python - Finding Outliers by Area of Bounding Box

I have an object detection algorithm set up using TensorFlow, is there a way to remove the outliers in terms of the size of the boxes? 我有一个使用TensorFlow设置的对象检测算法,有没有一种方法可以消除盒子尺寸方面的异常值?

For example, I have 20 objects detected. 例如,我检测到20个对象。 Let's say 17 of them are around 50x50. 假设其中17个尺寸约为50x50。 But, there are a few bounding boxes that are 1x1 and one box that is 1000x1000. 但是,有一些边界框是1x1,一个边界框是1000x1000。 Obviously the 1x1 and 1000x1000 boxes are way too big and should be removed. 显然1x1和1000x1000盒子太大了,应该将其删除。

One way you can do that is to use the z_score. 一种方法是使用z_score。 The z_score will check how many std_devs does this number differs from the mean. z_score将检查此std_devs与平均值有多少不同。

Example: 例:

# 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)]

This will print: [False, False, False, True, True, True, False, False] 这将打印:[False,False,False,True,True,True,False,False]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM