| 84 | cv2.waitKey() |
| 85 | |
| 86 | def add_blend_img(self, back, fore, img_id='blend', trans=0.7): |
| 87 | if self.theme == 'white': |
| 88 | fore = 255 - fore |
| 89 | if fore.shape[0] != back.shape[0] or fore.shape[0] != back.shape[1]: |
| 90 | fore = cv2.resize(fore, (back.shape[1], back.shape[0])) |
| 91 | if len(fore.shape) == 2: |
| 92 | fore = fore.reshape(fore.shape[0], fore.shape[1], 1) |
| 93 | self.imgs[img_id] = (back * (1. - trans) + fore * trans) |
| 94 | self.imgs[img_id][self.imgs[img_id] > 255] = 255 |
| 95 | self.imgs[img_id][self.imgs[img_id] < 0] = 0 |
| 96 | self.imgs[img_id] = self.imgs[img_id].astype(np.uint8).copy() |
| 97 | |
| 98 | ''' |
| 99 | # slow version |