|
|
@@ -10,7 +10,7 @@ N_COLORS = 3 |
|
|
|
|
|
|
|
def draw_rectangle(frame, sp, ep): |
|
|
|
""" Draw a rectangle on the frame """ |
|
|
|
return cv2.rectangle(frame, sp, ep, RED) |
|
|
|
return cv2.rectangle(frame, sp, ep, RED, 1) |
|
|
|
|
|
|
|
|
|
|
|
def analyze_block(frame, index, sp, ep): |
|
|
@@ -20,10 +20,18 @@ def analyze_block(frame, index, sp, ep): |
|
|
|
sp2 = tuple(int(x) for x in (2 * np.array(sp) + np.array(ep)) / 3) |
|
|
|
ep2 = tuple(int(x) for x in (np.array(sp) + 2 * np.array(ep)) / 3) |
|
|
|
average_color = [int(x) for x in average_color] |
|
|
|
frame = cv2.rectangle(frame, sp2, ep2, average_color, 5) |
|
|
|
frame = cv2.rectangle(frame, sp2, ep2, average_color, -1) |
|
|
|
average_color = np.uint8([[average_color]]) |
|
|
|
h, s, v = cv2.cvtColor(average_color, cv2.COLOR_BGR2HSV)[0][0] |
|
|
|
print(index, h, s, v) |
|
|
|
|
|
|
|
for thickness, color in ((3, (0, 0, 0)), (1, (255, 255, 255))): |
|
|
|
frame = cv2.putText(frame, |
|
|
|
text=f"{h:03d} {s:03d} {v:03d}", |
|
|
|
org=(sp[0] + 10, sp[1] + 20), |
|
|
|
fontScale=.5, |
|
|
|
color=color, |
|
|
|
fontFace=2, |
|
|
|
thickness=thickness) |
|
|
|
return frame |
|
|
|
|
|
|
|
|
|
|
|