def frame_homography(totalPts, homTh):
"""
Filter foreground points i.e. the outlier points found by fitting
homography using RANSAC
Input:
totalPts: (numAllPoints, 4): x0, y0, x1, y1
fgPts: (numAllPoints, 4): x0, y0, x1, y1
"""
if totalPts.ndim != 2 or totalPts.shape[0] < 8 or homTh < 0:
return totalPts
import cv2
p1 = totalPts[:, :2].astype('float')
p2 = totalPts[:, 2:4].astype('float')
_, status = cv2.findHomography(
p1, p2, cv2.RANSAC, ransacReprojThreshold=homTh)
fgPts = totalPts[status[:, 0] == 0, :]
return fgPts
评论列表
文章目录