blind_watermark icon indicating copy to clipboard operation
blind_watermark copied to clipboard

补白边和去除白边的代码会直接卡死

Open TaceyWong opened this issue 1 month ago • 0 comments

https://github.com/guofei9987/blind_watermark/blob/b68b14b6bd7da0ea33391183b62094a6463a2034/blind_watermark/bwm_core.py#L52

self.img_YUV = cv2.copyMakeBorder(cv2.cvtColor(self.img, cv2.COLOR_BGR2YUV),
                                   0, self.img.shape[0] % 2, 0, self.img.shape[1] % 2,                                   
                                  cv2.BORDER_CONSTANT, value=(0, 0, 0))

https://github.com/guofei9987/blind_watermark/blob/b68b14b6bd7da0ea33391183b62094a6463a2034/blind_watermark/bwm_core.py#L131

# 之前如果不是2的整数,增加了白边,这里去除掉
embed_img_YUV = embed_img_YUV[:self.img_shape[0], :self.img_shape[1]]
embed_img = cv2.cvtColor(embed_img_YUV, cv2.COLOR_YUV2BGR)
embed_img = np.clip(embed_img, a_min=0, a_max=255)

追踪到了这两处代码有严重问题(用1100 × 732的图像测试),对cv2这块儿的代码不熟悉,不知道啥情况。

TaceyWong avatar May 16 '24 17:05 TaceyWong