Maybe too specific, but if you are using keypoints (by the way, this is just a "pretty" version from @Jota's answer):
def average_keypoint_value(canvas,keypoints):
average_value = []
if canvas.ndim == 2:
nchannels = 1
elif canvas.ndim > 2:
nchannels = canvas.shape[-1]
for keypoint in keypoints:
circle_x = int(keypoint.pt[0])
circle_y = int(keypoint.pt[1])
circle_radius= int(keypoint.size/2)
#copypasta from https://stackoverflow.com/a/43170927/2594947
circle_img = np.zeros((canvas.shape[:2]), np.uint8)
cv2.circle(circle_img,(circle_x,circle_y),circle_radius,(255,255,255),-1)
datos_rgb = cv2.mean(canvas, mask=circle_img)
average_value.append(datos_rgb[:nchannels])
return(average_value)
Just leaving it here in case someone else wants a function for this.