Revision history [back]

Calculating a trajectory using a homography projection

I have the homography matrix and I projected a scene using that homography matrix. Now I have trajectories in 2D, I want to transform them into the projected scene.

I'm trying to do object detection in one image, and do a homography calculations of trajectories of that image, I don't know how to convert the coordinates from the detected bounding box centers of the first image to converted homography coordinates image

p = np.array(((trk + trk) / 2,  (trk + trk) / 2, 1)).reshape((3, 1))
temp_p = H.dot(p)
sum = np.sum(temp_p, 1)
px = int(round(sum / sum))
py = int(round(sum / sum))

point_lists[trk].append((px, py))
x = [i for i in point_lists[trk]]
y = [i for i in point_lists[trk]]
p = np.polyfit(x, y, deg=1)
y = p + p * np.array(x)
fitted = list(zip(x, y))
cv2.polylines(dst, np.int32([fitted]), False, color=(255, 0, 0))

Calculating a trajectory using a homography projection

I have the homography matrix and I projected a scene using that homography matrix. Now I have trajectories in 2D, I want to transform them into the projected scene.

I'm trying to do object detection in one image, and do a homography calculations of trajectories of that image, I don't know how to convert the coordinates from the detected bounding box centers of the first image to converted homography coordinates image

for trk in car_detections:
trk = trk.astype(np.int32)

p = np.array(((trk + trk) / 2,  (trk + trk) / 2, 1)).reshape((3, 1))
temp_p = H.dot(p)
sum = np.sum(temp_p, 1)
px = int(round(sum / sum))
py = int(round(sum / sum))
cv2.circle(img, center = (px, py), radius= 10, color=(255,0,0))

point_lists[trk].append((px, py))
x = [i for i in point_lists[trk]]
y = [i for i in point_lists[trk]]
p = np.polyfit(x, y, deg=1)
y = p + p * np.array(x)
fitted = list(zip(x, y))
cv2.polylines(dst,     cv2.polylines(img, np.int32([fitted]), False, color=(255, 0, 0))