My input is a list of lists like this (about 80,000 in length):
mylist = [['a', 0, 1, 0, 1], ['b', 1, 2, 1, 2], ['c', 3, 4, 3, 4], ...]
Now I want to apply function to this list in an efficient way:
def myFunc(r):
e1, e2, e3, e4, e5 = r
img = cv2.imread(e1)
height, width, channels = img.shape
target_x_center, target_y_center = width/2+e2, height/2+e3
xmax = target_x_center+1000
xmin = target_x_center-1000
ymax = target_y_center+1000
ymin = target_y_center-1000
img_cropped = img[int(ymin):int(ymax), int(xmin):int(xmax)]
return img_cropped
vFunc = np.vectorize(myFunc)
vFunc(mylist)
But I got an error:
ValueError: not enough values to unpack (expected 5, got 1)
How can I solve this problem in efficient way?