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.
|
|
|
# Image Decode Implementation with CV2
|
|
|
|
|
|
|
|
*author: Kaiyuan Hu, Rentong Guo*
|
|
|
|
|
|
|
|
<br />
|
|
|
|
|
|
|
|
## Description
|
|
|
|
|
|
|
|
An image decode operator implementation with OpenCV.
|
|
|
|
|
|
|
|
<br />
|
|
|
|
|
|
|
|
## Code Example
|
|
|
|
|
|
|
|
Load a image from path './src_dog.jpg'.
|
|
|
|
|
|
|
|
*Write a pipeline with explicit inputs/outputs name specifications:*
|
|
|
|
|
|
|
|
```python
|
|
|
|
from towhee import pipe, ops, DataCollection
|
|
|
|
|
|
|
|
p = (
|
|
|
|
pipe.input('path')
|
|
|
|
.map('path', 'image', ops.image_decode.cv2_rgb())
|
|
|
|
.output('path', 'image')
|
|
|
|
)
|
|
|
|
```
|
|
|
|
|
|
|
|
<img src="./result.png" height="150px"/>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<br />
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
## Factory Constructor
|
|
|
|
|
|
|
|
Create the operator via the following factory method:
|
|
|
|
|
|
|
|
***image_decode.cv2_rgb()***
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<br />
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
## Interface
|
|
|
|
|
|
|
|
An image decode operator takes an image path as input. It decodes the image back to ndarray.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
**Parameters:**
|
|
|
|
|
|
|
|
**img**: *str*
|
|
|
|
|
|
|
|
Image file path.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
**Returns**: *towhee.types.Image (a sub-class of numpy.ndarray)*
|
|
|
|
|
|
|
|
The decoded image data as numpy.ndarray.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|