def generate( self ):
# Create black background image and fill it up with random polygons
img = np.zeros((self.height, self.width, 3), np.uint8)
overlay = img.copy()
output = img.copy()
for i in range(self.size):
info = self.genes[i].getInfo()
if self.type == 1:
cv2.circle(overlay,info[0], info[1], info[2], -1)
cv2.addWeighted(overlay, info[3], output, 1 - info[3], 0, output)
elif self.type == 2:
cv2.ellipse(overlay,info[0],info[1],info[2],0,360,info[3],-1)
cv2.addWeighted(overlay, info[4], output, 1 - info[4], 0, output)
elif self.type == 3:
cv2.fillConvexPoly(overlay,np.asarray(info[0]), info[1])
cv2.addWeighted(overlay, info[2], output, 1 - info[2], 0, output)
elif self.type == 4:
cv2.fillConvexPoly(overlay, np.asarray(info[0]), info[1])
cv2.addWeighted(overlay, info[2], output, 1 - info[2], 0, output )
return output
评论列表
文章目录