Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
iperov
GitHub Repository: iperov/deepfacelab
Path: blob/master/core/imagelib/draw.py
628 views
1
import numpy as np
2
import cv2
3
4
def draw_polygon (image, points, color, thickness = 1):
5
points_len = len(points)
6
for i in range (0, points_len):
7
p0 = tuple( points[i] )
8
p1 = tuple( points[ (i+1) % points_len] )
9
cv2.line (image, p0, p1, color, thickness=thickness)
10
11
def draw_rect(image, rect, color, thickness=1):
12
l,t,r,b = rect
13
draw_polygon (image, [ (l,t), (r,t), (r,b), (l,b ) ], color, thickness)
14
15