From d771091c0643bb6b54c46d96e25e6eb18f496148 Mon Sep 17 00:00:00 2001 From: zhouchengrong Date: Wed, 24 Jul 2024 15:18:49 +0800 Subject: [PATCH] =?UTF-8?q?feat=20fix=20=20=20=E5=9B=BE=E7=89=87=E6=A0=BC?= =?UTF-8?q?=E5=BC=8F=E7=BB=9F=E4=B8=80=EF=BC=8C=E5=8F=AF=E8=83=BD=E4=B8=BA?= =?UTF-8?q?uint16=EF=BC=8C=E6=96=B0=E5=A2=9E=E5=88=A4=E6=96=AD=E8=BD=AC?= =?UTF-8?q?=E7=BD=AE=E4=B8=BAuint8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/service/utils/oss_client.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/service/utils/oss_client.py b/app/service/utils/oss_client.py index c2bb82c..370cd7c 100644 --- a/app/service/utils/oss_client.py +++ b/app/service/utils/oss_client.py @@ -28,6 +28,8 @@ def oss_get_image(bucket, object_name, data_type): image_bytes = image_data.read() image_array = np.frombuffer(image_bytes, np.uint8) # 转成8位无符号整型 image_object = cv2.imdecode(image_array, cv2.IMREAD_UNCHANGED) + if image_object.dtype == np.uint16: + image_object = (image_object / 256).astype('uint8') else: data_bytes = BytesIO(image_data.read()) image_object = Image.open(data_bytes) @@ -63,8 +65,8 @@ if __name__ == '__main__': # url = "aida-users/87/print/956614a2-7e75-4fbe-9ed0-c1831e37a2c9-4-87.png" # url = "aida-users/89/single_logo/123-89.png" # url = "aida-users/89/product_image/string-89.png" - url = "aida-results/result_c6520ce7-33a1-11ef-a8d3-b0dcefbff887.png" - read_type = "PIL" + url = "aida-collection-element/12148/Sketchboard/95ea577b-305b-4a62-b30a-39c0dd3ddb3f.png" + read_type = "cv2" if read_type == "cv2": img = oss_get_image(bucket=url.split('/')[0], object_name=url[url.find('/') + 1:], data_type=read_type) cv2.imshow("", img)