Ejemplo n.º 1
0
def ipm_from_parameters(image, xyz, K, RT, interpolation_fn):
    # Flip y points positive upwards
    xyz[1] = -xyz[1]

    P = K @ RT
    pixel_coords = perspective(xyz, P, TARGET_H, TARGET_W)
    image2 = interpolation_fn(image, pixel_coords)
    return image2.astype(np.uint8)
Ejemplo n.º 2
0
 def getMVP( self ):
     width, height = self.GetGLExtents()
     MVP = perspective(45.0, width / height, self.near_plane, self.far_plane);
     
     MVP = translate( MVP, self.world_pos[0], self.world_pos[1], self.world_pos[2] )
     MVP = rotate( MVP, self.world_rot[1], 0, 1, 0 )
     MVP = rotate( MVP, self.world_rot[0], 1, 0, 0 )
     
     return (1, True, MVP)
Ejemplo n.º 3
0
    def main_first(self, img):
        height = img.shape[0]
        warped, _ = utils.perspective(utils.undistort(img, self.objpoints, self.imgpoints))
        warped_edge = utils.edge(warped)
        left_base, right_base = utils.base(warped_edge)
        left_fit, _ = utils.fit_first(warped_edge, left_base)
        right_fit, _ = utils.fit_first(warped_edge, right_base)

        return left_fit, right_fit
Ejemplo n.º 4
0
def ipm_from_parameters(image, xyz, K, RT):
    P = K @ RT

    print('K.shape', K.shape)
    print('RT.shape', RT.shape)
    print('P.shape', P.shape)

    pixel_coords = perspective(xyz, P, TARGET_H, TARGET_W)
    print('pixel_coords.shape', pixel_coords.shape)
    print('pixel_coords[0,0]', pixel_coords[250, 250])
    image2 = bilinear_sampler(image, pixel_coords)
    return image2.astype(np.uint8)
Ejemplo n.º 5
0
    def main_rest(self, img, prev_left_fit, prev_right_fit):
        height = img.shape[0]
        width = img.shape[1]
        warped, M = utils.perspective(utils.undistort(img, self.objpoints, self.imgpoints))
        warped_edge = utils.edge(warped)
        left_base, right_base = utils.base(warped_edge)
        left_fit, left_fit_m = utils.fit_rest(warped_edge, prev_left_fit)
        right_fit, right_fit_m = utils.fit_rest(warped_edge, prev_right_fit)
        curv = utils.curvature(left_fit_m, right_fit_m, height)
        shif = utils.shift(left_fit_m, right_fit_m, height, width)

        return left_fit, right_fit, curv, shif, M
Ejemplo n.º 6
0
def test_perspective():
    extrinsic, intrinsic = load_camera_params('camera.json')
    P = intrinsic @ extrinsic
    plane = Plane(
        0,
        -1,
        0,  # x, y, z
        0,
        0,
        0,  # roll, pitch, yaw
        3,
        3,
        2)  # col, row, scale

    print(perspective(plane.xyz, P, 3, 3))
Ejemplo n.º 7
0
def ipm_from_parameters(image, xyz, K, RT):
    P = K @ RT
    pixel_coords = perspective(xyz, P, TARGET_H, TARGET_W)
    image2 = bilinear_sampler(image, pixel_coords)
    return image2.astype(np.uint8)