|
import numpy as np |
|
import cv2 |
|
import sys |
|
|
|
|
|
def draw_main_menu(img1): |
|
cv2.rectangle(img1, (1,0) , (100,25), (80,80,80), thickness=-1) |
|
cv2.rectangle(img1, (102,0) , (200,25), (80,80,80), thickness=-1) |
|
cv2.rectangle(img1, (202,0) , (300,25), (80,80,80), thickness=-1) |
|
cv2.putText(img1, "Button1", (15, 20), cv2.FONT_HERSHEY_SIMPLEX, 0.7, (200,200,200), 1) |
|
cv2.putText(img1, "Button2", (110, 20), cv2.FONT_HERSHEY_SIMPLEX, 0.7, (200,200,200), 1) |
|
cv2.putText(img1, "Exit", (225, 20), cv2.FONT_HERSHEY_SIMPLEX, 0.7, (200,200,200), 1) |
|
|
|
|
|
|
|
def menu_mouse_click(event, x, y, flags, param): |
|
if event == cv2.EVENT_LBUTTONDOWN: |
|
if y>=0 and y<=25: |
|
if x>=1 and x<=100: |
|
print("Button1") |
|
elif x>=102 and x<=200: |
|
print("Button2") |
|
elif x>=202 and x<=300: |
|
print("Exit") |
|
cv2.destroyAllWindows() |
|
sys.exit() |
|
|
|
video_path = "/home/pavlo/Projects/VirtualCam/pano1.mp4" |
|
cap = cv2.VideoCapture(video_path) |
|
|
|
cv2.namedWindow("frame", cv2.WINDOW_NORMAL) |
|
cv2.setMouseCallback("frame", menu_mouse_click) |
|
while(cap.isOpened()): |
|
ret, frame = cap.read() |
|
draw_main_menu(frame) |
|
cv2.imshow("frame",frame) |
|
k = cv2.waitKey(1) & 0xff |
|
if k == 27: |
|
cv2.destroyAllWindows() |
|
sys.exit() |