I am having some issue while printing the output. I am getting below output
array([[336.34305, 214.00804]], dtype=float32)
instead of just
[[336.34305, 214.00804]]
Code:
import cv2
import numpy as np
chess_img = cv2.imread('board.jpeg')
kernel = np.ones((5,5), np.uint8)
gray = cv2.cvtColor(chess_img,cv2.COLOR_BGR2GRAY)
corners = []
ret , corners = cv2.findChessboardCorners(gray,(7,7), None)
if ret == False:
print('Did not find')
cv2.drawChessboardCorners(chess_img,(7,7),corners,ret)
def sortFirst(val):
return val[0][0]
cornersort = corners
print('Corners:')
print(cornersort)
cornersort = sorted(cornersort, key = sortFirst)
print(cornersort)
When I wrote another code it worked fine:
import numpy as np
arr = [[[2,3]],[[3,7]],[[5,1]]]
def sortSecond(val):
return val[0][1]
arr = sorted(arr , key = sortSecond)
print(arr)
The output of the first code is
[array([[336.34305, 214.00804]], dtype=float32), array([[337.23248,78.57056]], dtype=float32)]
The output of the second code is
[[[5, 1]], [[2, 3]], [[3, 7]]]
I want the output of the first code to be as the output as the second code. Please help!