diff --git a/README.md b/README.md index 085d05d..4049a03 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ -## Desription +## Description An image crop operator implementation with OpenCV. @@ -20,34 +20,22 @@ An image crop operator implementation with OpenCV. ## Code Example -Load a image from path './dog.jpg'. - - *Write the pipeline in simplified style:* +Crop the face from 'einstein.jpg'. ```python -import towhee -towhee.glob('./dog.jpg') \ - .image_decode.cv2() \ - .show() -``` - -*Write a same pipeline with explicit inputs/outputs name specifications:* - -```python import towhee -towhee.glob['path']('./dog.jpg') \ - .image_decode.cv2['path', 'img']() \ - .select['img']() \ +bboxes = towhee.glob['path']('einstein.jpg') \ + .image_decode['path', 'img']() \ + .face_detection.retinaface['img', ('box','score')]()\ + .image_crop[('img', 'box'), 'crop'](clamp = True)\ + .select['img','crop']()\ .show() ``` - - - - +
@@ -57,9 +45,14 @@ towhee.glob['path']('./dog.jpg') \ Create the operator via the following factory method -***image_decode.cv2()*** +***image_crop(clamp = True)*** +**Parameters:** + +**clamp:** *bool* + +​ If set True, coordinates of bounding boxes would be clamped into image size.
@@ -67,21 +60,22 @@ 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. - +An image crop operator takes an image and bounding boxes as input. It cropes the image into ROIs(region of interest). **Parameters:** -**img**: *str* +**img:** *towhee.types.Image (a sub-class of numpy.ndarray)* -​ Image file path. +​ The image need to be cropped. +**bboxes:** *numpy.ndarray* +​ The nx4 numpy tensor for n bounding boxes need to crop, each row is formatted as (x1, y1, x2, y2). **Returns**: *towhee.types.Image (a sub-class of numpy.ndarray)* -​ The decoded image data as numpy.ndarray. +​ The cropped image data as numpy.ndarray. diff --git a/result.png b/result.png new file mode 100644 index 0000000..57ad888 Binary files /dev/null and b/result.png differ