feat
fix 图片格式统一,可能为uint16,新增判断转置为uint8
This commit is contained in:
@@ -28,6 +28,8 @@ def oss_get_image(bucket, object_name, data_type):
|
|||||||
image_bytes = image_data.read()
|
image_bytes = image_data.read()
|
||||||
image_array = np.frombuffer(image_bytes, np.uint8) # 转成8位无符号整型
|
image_array = np.frombuffer(image_bytes, np.uint8) # 转成8位无符号整型
|
||||||
image_object = cv2.imdecode(image_array, cv2.IMREAD_UNCHANGED)
|
image_object = cv2.imdecode(image_array, cv2.IMREAD_UNCHANGED)
|
||||||
|
if image_object.dtype == np.uint16:
|
||||||
|
image_object = (image_object / 256).astype('uint8')
|
||||||
else:
|
else:
|
||||||
data_bytes = BytesIO(image_data.read())
|
data_bytes = BytesIO(image_data.read())
|
||||||
image_object = Image.open(data_bytes)
|
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/87/print/956614a2-7e75-4fbe-9ed0-c1831e37a2c9-4-87.png"
|
||||||
# url = "aida-users/89/single_logo/123-89.png"
|
# url = "aida-users/89/single_logo/123-89.png"
|
||||||
# url = "aida-users/89/product_image/string-89.png"
|
# url = "aida-users/89/product_image/string-89.png"
|
||||||
url = "aida-results/result_c6520ce7-33a1-11ef-a8d3-b0dcefbff887.png"
|
url = "aida-collection-element/12148/Sketchboard/95ea577b-305b-4a62-b30a-39c0dd3ddb3f.png"
|
||||||
read_type = "PIL"
|
read_type = "cv2"
|
||||||
if 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)
|
img = oss_get_image(bucket=url.split('/')[0], object_name=url[url.find('/') + 1:], data_type=read_type)
|
||||||
cv2.imshow("", img)
|
cv2.imshow("", img)
|
||||||
|
|||||||
Reference in New Issue
Block a user