Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

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[1] + trk[3]) / 2,  (trk[0] + trk[2]) / 2, 1)).reshape((3, 1))
    temp_p = H.dot(p)
    sum = np.sum(temp_p, 1)
    px = int(round(sum[0] / sum[2]))
    py = int(round(sum[1] / sum[2]))

    point_lists[trk[4]].append((px, py))
    x = [i[0] for i in point_lists[trk[4]]]
    y = [i[1] for i in point_lists[trk[4]]]
    p = np.polyfit(x, y, deg=1)
    y = p[1] + p[0] * 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[1] + trk[3]) / 2,  (trk[0] + trk[2]) / 2, 1)).reshape((3, 1))
     temp_p = H.dot(p)
     sum = np.sum(temp_p, 1)
     px = int(round(sum[0] / sum[2]))
     py = int(round(sum[1] / sum[2]))
         cv2.circle(img, center = (px, py), radius= 10, color=(255,0,0))

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