Skip to content

Commit

Permalink
minor changesé
Browse files Browse the repository at this point in the history
  • Loading branch information
basileroth75 committed Jun 14, 2020
1 parent 57c1aa1 commit ccedcf3
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions src/bird_view_transfo.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,26 @@
import cv2


def compute_perspective_transform(corner_points,width,height):
def compute_perspective_transform(corner_points,width,height,image):
""" Compute the transformation matrix
@ p1,p2,p3,p4 : 4 corner points
@ height, width : needed parameter to determinen the matrix
@ corner_points : 4 corner points selected from the image
@ height, width : size of the image
"""
# Create an array out of theses points
# Create an array out of the 4 corner points
corner_points_array = np.float32(corner_points)
# Create an array with the
# Create an array with the parameters (the dimensions) required to build the matrix
img_params = np.float32([[0,0],[width,0],[0,height],[width,height]])
# Compute the transformation matrix
return cv2.getPerspectiveTransform(corner_points_array,img_params)
# Compute and return the transformation matrix
matrix = cv2.getPerspectiveTransform(corner_points_array,img_params)
img_transformed = cv2.warpPerspective(image,matrix,(width,height))
return matrix,img_transformed


def compute_point_perspective_transformation(matrix,list_downoids):
""" Apply the perspective transformation to every poins which have been detected on the main frame.
""" Apply the perspective transformation to every ground point which have been detected on the main frame.
@ matrix : the 3x3 matrix
@ list_downoids : list that contains the points to transform
return : list containing all the new points
"""
# Compute the new coordinates of our points
list_points_to_detect = np.float32(list_downoids).reshape(-1, 1, 2)
Expand All @@ -27,4 +30,4 @@ def compute_point_perspective_transformation(matrix,list_downoids):
transformed_points_list = list()
for i in range(0,transformed_points.shape[0]):
transformed_points_list.append([transformed_points[i][0][0],transformed_points[i][0][1]])
return transformed_points_list
return transformed_points_list

0 comments on commit ccedcf3

Please sign in to comment.