urban_management/STDC_YOLO/yolo_stdc_joint.py

21 lines
502 B
Python

import cv2
import numpy as np
def stdc_yolo(stdc_det, yolo_det):
im = np.uint8(stdc_det)
# ret, thresh = cv2.threshold(im, 0.5, 255, cv2.THRESH_BINARY)
# contours = cv2.findContours(thresh, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_NONE)
if not yolo_det.size:
return yolo_det
#
x_c = ((yolo_det[:, 0] + yolo_det[:, 2]) // 2).astype(int)
y_c = ((yolo_det[:, 1] + yolo_det[:, 3]) // 2).astype(int)
yolo_filted = yolo_det[im[y_c, x_c] == 0]
return yolo_filted