Current if statements checks if centroid coordinates (x, y) are inside the red rectangle and outputs the coordinates. Instead of getting coordinates of each centroid inside the red rectangle how can I get the the total number of centroids inside the red rectangle?
If statement:
if ((x > box_one.top[0]) and (x < box.bottom[0]) and (y > box.top[1]) and (y < box.bottom[1])):
print(x, y)
Output picture:

Current output:
111 237
532 247
307 249
Desired output:
3
↧