Code:
import matplotlib.path as mplPath def check_in_roi(bbox, roi, rw, rh): x1 = bbox[0] y1 = bbox[1] x2 = bbox[2] y2 = bbox[3] feet_dot_x = int((x1+x2)/2) feet_dot_y = y2 temp = [] for c in roi: temp.append([c[0]*rw, c[1]*rh]) roi_path = mplPath.Path(np.array(temp)) if roi_path.contains_point((feet_dot_x, feet_dot_y)): return True else: return False
input roi should be a list of dot [x,y]
No comments:
Post a Comment