From d5a27283e870a1ecc7e35108ac110f153f26c8b8 Mon Sep 17 00:00:00 2001 From: ZeYi Lin <944270057@qq.com> Date: Sat, 14 Sep 2024 15:44:03 +0800 Subject: [PATCH] style: rgba reminder --- hivision/utils.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/hivision/utils.py b/hivision/utils.py index afef56c0..3d037a87 100644 --- a/hivision/utils.py +++ b/hivision/utils.py @@ -258,7 +258,13 @@ def add_background(input_image, bgr=(0, 0, 0), mode="pure_color"): :return: output: 合成好的输出图像 """ height, width = input_image.shape[0], input_image.shape[1] - b, g, r, a = cv2.split(input_image) + try: + b, g, r, a = cv2.split(input_image) + except ValueError: + raise ValueError( + "The input image must have 4 channels. 输入图像必须有4个通道,即透明图像。" + ) + a_cal = a / 255 if mode == "pure_color": # 纯色填充