Использовать преобразование цветового пространства в HSV и морфологические операции:
import cv2
img1 = cv2.imread('flys.jpg')
kernel = cv2.getStructuringElement(cv2.MORPH_ELLIPSE, (6,6))
img=cv2.cvtColor(img1, cv2.COLOR_BGR2HSV)
mask=cv2.threshold(img1[:,:,2], 85, 255, cv2.THRESH_BINARY)[1]
mask = cv2.dilate(mask, kernel, iterations = 2)
mask = cv2.erode(mask, kernel, iterations = 7)
mask=cv2.bitwise_not(mask)
output = cv2.connectedComponentsWithStats(mask, 4, cv2.CV_32S)
print('number of flies: ', output[0])
for i in range(1, output[0]):
x,y,w,h,s=output[2][i]
img_crop=img1[y:y+h, x:x+w,:]
cv2.imwrite(str(i)+'_crop_fly.jpg', img_crop)
mask=cv2.cvtColor(mask,cv2.COLOR_GRAY2BGR)
mask[:,:,1]=0
dst = cv2.addWeighted(img1, 0.7, mask, 0.3, 0.0)
cv2.imshow('test', dst)
cv2.imwrite('out_fly.jpg', dst)