Learn Before
Concept

Drawing Corners

Once we are given the numpy array of floating point coordinates for the corners, we would want o convert it from floating points to ints. The ravel method will flatten the array. Flattening an array will remove the interior arrays, [[0,1][2,3]] -> [0,1,2,3].

corners = np.int0(corners) for corner in corners: x,y = corner.ravel() cv2,circle(img, (x,y), 5, (255, 0, 0), -1)

Remember that if your img file is still in gray scaled the color parameter will not be able to display correctly when drawing the corners.

We can also make these corners more obvious by drawing lines between the corners.

for i in range(len(corners)): for j in range(i+1, len(corners)): corner1 = tuple(corners[i][0]) corner2 = tuple(corners[j][0]) cv2.line(img, corner1, corner2, (255, 0, 0), 1)

We will only need the [0] indexing if we don't flatten the array.

0

1

Updated 2021-07-06

Tags

Python Programming Language

Data Science

Related
Learn After