1#cv2 transparent rectnagle
2#answerd by LUBAN MAHFUZ
3import cv2
4
5import numpy as np
6cap = cv2.VideoCapture(1)
7
8while True:
9 success, img = cap.read()
10#transparent rectangle start here_____________
11 bbox = [300,100,200,200]
12 blk = np.zeros(img.shape, np.uint8)
13 cv2.rectangle(blk, (300,100),(500,300),(225,225,225),cv2.FILLED)
14 img = cv2.addWeighted(img, 1.0, blk, 0.50, 1)
15#transparent rectangle stop here______________
16 cv2.imshow("Image", img)
17 cv2.waitKey(1)
18 if cv2.waitKey(100) == ord('q'):
19 break
20
21cv2.destroyAllWindows()