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

83 lines
1.0 KiB

2 years ago
# Image Decode Implementation with CV2 and nvjpeg
2 years ago
2 years ago
*author: junjie.jiang*
2 years ago
<br />
## Description
2 years ago
An image decode operator implementation with OpenCV and nvjpeg.
In CPU env, use OpenCV, in GPU env, use nvjpeg to decode jpeg files.
2 years ago
<br />
## Code Example
2 years ago
Load a image from path './src_dog.jpg'.
2 years ago
*Write the pipeline in simplified style:*
```python
from towhee import pipe, ops, DataCollection
2 years ago
2 years ago
p = (
pipe.input('url')
.map('url', 'image', ops.image_decode.nvjpeg())
.output('image')
)
2 years ago
2 years ago
DataCollection(p('./src_dog.jpg')).show()
2 years ago
```
2 years ago
<img src="./dog.jpg" height="150px"/>
2 years ago
<br />
## Factory Constructor
Create the operator via the following factory method:
2 years ago
***ops.image_decode.nvjpeg()***
2 years ago
<br />
## Interface
An image decode operator takes an image path as input. It decodes the image back to ndarray.
**Parameters:**
**img**: *str*
2 years ago
​ Local file path or http url.
2 years ago
**Returns**: *towhee.types.Image (a sub-class of numpy.ndarray)*
​ The decoded image data as numpy.ndarray.
2 years ago