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 1 year ago

towhee

Image Crop Implementation with CV2

author: David Wang


Description

An image crop operator implementation with OpenCV.


Code Example

Crop the face from 'avengers.jpg'.

from towhee import pipe, ops, DataCollection

p = (
    pipe.input('path')
        .map('path', 'img', ops.image_decode())
        .map('img', ('box','score'), ops.face_detection.retinaface())
        .map(('img', 'box'), 'crop', ops.image_crop(clamp = True))
        .output('img', 'crop')
)

DataCollection(p('./avengers.jpg')).show()


Factory Constructor

Create the operator via the following factory method

image_crop(clamp = True)

Parameters:

clamp: bool

​ If set True, coordinates of bounding boxes would be clamped into image size.


Interface

An image crop operator takes an image and bounding boxes as input. It cropes the image into ROIs(region of interest).

Parameters:

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

​ 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 cropped image data as numpy.ndarray.

wxywb bbe33672c1 remove dc2 13 Commits
file-icon .gitattributes
1.1 KiB
download-icon
Initial commit 2 years ago
file-icon README.md
1.3 KiB
download-icon
remove dc2 1 year ago
file-icon __init__.py
719 B
download-icon
update. 2 years ago
file-icon image_crop_cv2.py
1.7 KiB
download-icon
Support input one box 1 year ago
file-icon requirements.txt
7 B
download-icon
add requirement 2 years ago
file-icon result2.png
123 KiB
download-icon
replace the readme image. 2 years ago