Skip to content

Commit 804c16c

Browse files
committed
Update main.py
1 parent 9084431 commit 804c16c

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

main.py

+9-3
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,17 @@ def update(self, cursor):
4343
rect.update(cursor)
4444

4545
# Draw
46+
imgNew = np.zeros_like(img, np.uint8)
4647
for rect in rectList:
4748
cx, cy = rect.posCenter
4849
w, h = rect.size
49-
cv2.rectangle(img, (cx - w//2, cy - h//2), (cx + w//2, cy + h//2), colorR, cv2.FILLED)
50-
cvzone.cornerRect(img, (cx - w//2, cy - h//2, w, h), 20, rt=0)
50+
cv2.rectangle(imgNew, (cx - w//2, cy - h//2), (cx + w//2, cy + h//2), colorR, cv2.FILLED)
51+
cvzone.cornerRect(imgNew, (cx - w//2, cy - h//2, w, h), 20, rt=0)
5152

52-
cv2.imshow("Image", img)
53+
out = img.copy()
54+
alpha = 0.1
55+
mask = imgNew.astype(bool)
56+
out[mask] = cv2.addWeighted(img, alpha, imgNew, 1-alpha, 0)[mask]
57+
58+
cv2.imshow("Image", out)
5359
cv2.waitKey(1)

0 commit comments

Comments
 (0)