logo
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Readme
Files and versions

Updated 3 months ago

image-decode

Image Decode Implementation with CV2

author: Kaiyuan Hu, Rentong Guo


Description

An image decode operator implementation with OpenCV.


Code Example

Load a image from path './src_dog.jpg'.

the src picture:

Write the pipeline in simplified style:

from towhee 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(p2(f.read())).show()



Factory Constructor

Create the operator via the following factory method:

ops.image_decode.cv2()

mode: str

BGR or RGB, default is BGR


Interface

An image decode operator takes an image path as input. It decodes the image back to ndarray.

Parameters:

img: str

​ Local file path/http url/image bytes.

Returns: towhee.types.Image (a sub-class of numpy.ndarray)

​ The decoded image data as numpy.ndarray.

More Resources

Jael Gu 0b81ebb49c Add more resources 26 Commits
file-icon .gitattributes
1.1 KiB
download-icon
Initial commit 3 years ago
file-icon .gitignore
1.2 KiB
download-icon
Add cv2 implementation of image decode 3 years ago
file-icon README.md
3.5 KiB
download-icon
Add more resources 3 months ago
file-icon __init__.py
730 B
download-icon
support decode from bytes 2 years ago
file-icon dog.png
66 KiB
download-icon
update readme 2 years ago
file-icon image_decode_cv2.py
2.6 KiB
download-icon
support decode from bytes 2 years ago
file-icon requirements.txt
36 B
download-icon
fix the requirement. 3 years ago
file-icon show_result.jpg
26 KiB
download-icon
Add show results 3 years ago
file-icon src_dog.jpg
26 KiB
download-icon
update readme 2 years ago