I have 2 arrays of points, I also know their location in our world. I need to calculate the total middle of each array and the 2d(x y) coordinate of this middle. As a result, the image with these arrays of points should be input, and the output should be 2 list: return [x1, y1], [x2, y2]. Python 3.x language, OpenCV library. Input image I found some useful code (Python) :

```
enter code here
import numpy as np
import cv2 as cv
from matplotlib import pyplot as plt
X = np.random.randint(25,50,(5,2))
Y = np.random.randint(60,85,(4,2))
Z = np.vstack((X,Y))
# convert to np.float32
Z = np.float32(Z)
# define criteria and apply kmeans()
criteria = (cv.TERM_CRITERIA_EPS + cv.TERM_CRITERIA_MAX_ITER, 10, 1.0)
ret,label,center=cv.kmeans(Z,2,None,criteria,10,cv.KMEANS_RANDOM_CENTERS)
# Now separate the data, Note the flatten()
A = Z[label.ravel()==0]
B = Z[label.ravel()==1]
# Plot the data
plt.scatter(A[:,0],A[:,1])
plt.scatter(B[:,0],B[:,1],c = 'r')
plt.scatter(center[:,0],center[:,1],s = 80,c = 'y', marker = 's')
plt.xlabel('Height'),plt.ylabel('Weight')
plt.show()
```

This code finds the midpoint among the array of points. But the problem is understanding which point belongs to which array.