Download glibvision/draw_utils.py from Akjava/mediapipe-face-skin-transform: direct link, hf CLI and curl.
- Browser
- Download file 781 Bytes
-
https://huggingface.co/spaces/Akjava/mediapipe-face-skin-transform/resolve/refs%2Fpr%2F1/glibvision/draw_utils.py
- Command line
-
hf download hf://spaces/Akjava/mediapipe-face-skin-transform@refs/pr/1/glibvision/draw_utils.py
-
curl -L -o draw_utils.py https://huggingface.co/spaces/Akjava/mediapipe-face-skin-transform/resolve/refs%2Fpr%2F1/glibvision/draw_utils.py
781 Bytes
| # DrawUtils | |
| # not PIL,CV2,Numpy drawing method | |
| def points_to_box(points): | |
| x1=float('inf') | |
| x2=0 | |
| y1=float('inf') | |
| y2=0 | |
| for point in points: | |
| if point[0]<x1: | |
| x1=point[0] | |
| if point[0]>x2: | |
| x2=point[0] | |
| if point[1]<y1: | |
| y1=point[1] | |
| if point[1]>y2: | |
| y2=point[1] | |
| return [x1,y1,x2-x1,y2-y1] | |
| def box_to_point(box): | |
| return [ | |
| [box[0],box[1]], | |
| [box[0]+box[2],box[1]], | |
| [box[0]+box[2],box[1]+box[3]], | |
| [box[0],box[1]+box[3]] | |
| ] | |
| def plus_point(base_pt,add_pt): | |
| return [base_pt[0]+add_pt[0],base_pt[1]+add_pt[1]] | |
| def box_to_xy(box): | |
| return [box[0],box[1],box[2]+box[0],box[3]+box[1]] | |
| def to_int_points(points): | |
| int_points=[] | |
| for point in points: | |
| int_points.append([int(point[0]),int(point[1])]) | |
| return int_points |