From 4d14f51c047f89cdb879f9814f79db68f282469c Mon Sep 17 00:00:00 2001 From: junjiejiangjjj Date: Wed, 1 Feb 2023 16:24:50 +0800 Subject: [PATCH] Update README.md --- README.md | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 0fba965..7f4430f 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ ## Description -An image decode operator implementation with OpenCV. Return BGR image. +An image decode operator implementation with OpenCV. @@ -32,22 +32,31 @@ the src picture: from towhee.dc2 import pipe, ops, DataCollection +# decode image, in bgr channel order p = ( pipe.input('url') .map('url', 'image', ops.image_decode.cv2()) .output('image') ) +# decode image, in rgb channel order +p2 = ( + pipe.input('url') + .map('url', 'image', ops.image_decode.cv2('rgb')) + .output('image') +) + # decode from path DataCollection(p('./src_dog.jpg')).show() # decode from bytes with open('./src_dog.jpg', 'rb') as f: - DataCollection(p(f.read())).show() + DataCollection(p2(f.read())).show() ```
+ @@ -59,8 +68,11 @@ with open('./src_dog.jpg', 'rb') as f: Create the operator via the following factory method: -***image_decode.cv2()*** +***ops.image_decode.cv2()*** + +**mode**: *str* +BGR or RGB, default is BGR
@@ -69,7 +81,7 @@ Create the operator via the following factory method: ## Interface -An image decode operator takes an image path as input. It decodes the image back to ndarray, use BGR channel order. +An image decode operator takes an image path as input. It decodes the image back to ndarray. @@ -77,7 +89,7 @@ An image decode operator takes an image path as input. It decodes the image back **img**: *str* -​ Local file path or http url. +​ Local file path/http url/image bytes.