|
| 1 | +""" |
| 2 | +Author : Robin Singh |
| 3 | +DRS(Decision Review System) Using Python |
| 4 | +
|
| 5 | +""" |
| 6 | + |
| 7 | +import tkinter |
| 8 | +import time |
| 9 | +import cv2 |
| 10 | +import PIL.Image,PIL.ImageTk |
| 11 | +from functools import partial |
| 12 | +import threading |
| 13 | +import imutils |
| 14 | + |
| 15 | +#main window screen lenth and breath |
| 16 | +Screen_width = 650 |
| 17 | +Screen_height = 400 |
| 18 | +Software_Window = tkinter.Tk() |
| 19 | +img = cv2.cvtColor(cv2.imread("welcome2.png"),cv2.COLOR_BGR2RGB) |
| 20 | +Software_Window.title("Decision Review System ") |
| 21 | +canvas = tkinter.Canvas(Software_Window,width = Screen_width,height = Screen_height ) |
| 22 | +pic = PIL.ImageTk.PhotoImage(image=PIL.Image.fromarray(img)) |
| 23 | +screen_img = canvas.create_image(0,0,ancho = tkinter.NW,image=pic) |
| 24 | +canvas.pack() |
| 25 | + |
| 26 | +video = cv2.VideoCapture("clip6.mp4") |
| 27 | +def play_video(speed): |
| 28 | + # print(f"Speed is {speed}") |
| 29 | + |
| 30 | + frames = video.get(cv2.CAP_PROP_POS_FRAMES) |
| 31 | + video.set(cv2.CAP_PROP_POS_FRAMES,frames+speed) |
| 32 | + |
| 33 | + grab ,frame = video.read() |
| 34 | + frame = imutils.resize(frame,width=Screen_width,height=Screen_height) |
| 35 | + frame = PIL.ImageTk.PhotoImage(image=PIL.Image.fromarray(frame)) |
| 36 | + canvas.image = frame |
| 37 | + canvas.create_image(0, 0, image=frame, anchor=tkinter.NW) |
| 38 | + # text() |
| 39 | + |
| 40 | + |
| 41 | + |
| 42 | + |
| 43 | + |
| 44 | +def out(): |
| 45 | + thread = threading.Thread(target=pending , args=("out",)) |
| 46 | + thread.daemon = 1 |
| 47 | + thread.start() |
| 48 | + # print("out") |
| 49 | + |
| 50 | +def notout(): |
| 51 | + thread = threading.Thread(target=pending, args=("not out",)) |
| 52 | + thread.daemon = 1 |
| 53 | + thread.start() |
| 54 | + # print("Not Out") |
| 55 | + |
| 56 | +def text(): |
| 57 | + canvas.create_text(155, 25, fill="yellow", font="Times 30 bold", text="Decision Pending") |
| 58 | + canvas.update() |
| 59 | + |
| 60 | +def exit_function(): |
| 61 | + new_img = cv2.cvtColor(cv2.imread("thank.png"),cv2.COLOR_BGR2RGB) |
| 62 | + decision_img = PIL.ImageTk.PhotoImage(image=PIL.Image.fromarray(new_img)) |
| 63 | + canvas.image = decision_img |
| 64 | + canvas.create_image(0, 0,image=decision_img, anchor=tkinter.NW) |
| 65 | + time.sleep(3) |
| 66 | + exit() |
| 67 | + |
| 68 | +def pending(decision): |
| 69 | + #First we will display Decision Pending Image and will wait for 10 sec and then we will display out or not out depending on decision argument |
| 70 | + |
| 71 | + new_img = cv2.cvtColor(cv2.imread("Decision.png"),cv2.COLOR_BGR2RGB) |
| 72 | + decision_img = PIL.ImageTk.PhotoImage(image=PIL.Image.fromarray(new_img)) |
| 73 | + canvas.image = decision_img |
| 74 | + canvas.create_image(0,0,image = decision_img,anchor = tkinter.NW) |
| 75 | + time.sleep(2) |
| 76 | + |
| 77 | + |
| 78 | + video2 = cv2.VideoCapture("countdown.mp4") |
| 79 | + t_end = time.time() + 10 #using t_end we will use this while loop for 10 secs |
| 80 | + while time.time()<t_end: |
| 81 | + frames = video2.get(cv2.CAP_PROP_POS_FRAMES) |
| 82 | + video2.set(cv2.CAP_PROP_POS_FRAMES,frames+8) |
| 83 | + |
| 84 | + grab ,frame = video2.read() |
| 85 | + frame = imutils.resize(frame,width=Screen_width,height=Screen_height) |
| 86 | + frame = PIL.ImageTk.PhotoImage(image=PIL.Image.fromarray(frame)) |
| 87 | + canvas.image = frame |
| 88 | + canvas.create_image(0, 0, image=frame, anchor=tkinter.NW) |
| 89 | + |
| 90 | + if decision == 'out': |
| 91 | + new_img = cv2.cvtColor(cv2.imread("out.png"), cv2.COLOR_BGR2RGB) |
| 92 | + else: |
| 93 | + new_img = cv2.cvtColor(cv2.imread("not_out.png"), cv2.COLOR_BGR2RGB) |
| 94 | + |
| 95 | + decision_img = PIL.ImageTk.PhotoImage(image=PIL.Image.fromarray(new_img)) |
| 96 | + canvas.image = decision_img |
| 97 | + canvas.create_image(0, 0, image=decision_img, anchor=tkinter.NW) |
| 98 | + |
| 99 | + |
| 100 | + |
| 101 | +button = tkinter.Button(Software_Window,text = " Previous (FAST) ",width = 100, command = partial(play_video ,-15))#partial is used here to pass speed argument alog with function call |
| 102 | +button.pack() |
| 103 | + |
| 104 | +button = tkinter.Button(Software_Window,text = " Previous (SLOW) ",width = 100 , command = partial(play_video , -2)) |
| 105 | +button.pack() |
| 106 | + |
| 107 | +button = tkinter.Button(Software_Window,text = " Next (FAST) ",width = 100 , command = partial(play_video , 15)) |
| 108 | +button.pack() |
| 109 | + |
| 110 | +button = tkinter.Button(Software_Window,text = " NEXT (SLOW) ",width = 100 , command = partial(play_video , 2)) |
| 111 | +button.pack() |
| 112 | + |
| 113 | +button = tkinter.Button(Software_Window,text = " OUT ",width = 100,command = out) |
| 114 | +button.pack() |
| 115 | + |
| 116 | +button = tkinter.Button(Software_Window,text = " NOT OUT ",width = 100,command = notout) |
| 117 | +button.pack() |
| 118 | + |
| 119 | +button = tkinter.Button(Software_Window,text = " EXIT ",width = 100,command = exit_function) |
| 120 | +button.pack() |
| 121 | + |
| 122 | +Software_Window.mainloop() |
| 123 | + |
| 124 | + |
| 125 | + |
| 126 | + |
| 127 | + |
| 128 | + |
| 129 | + |
0 commit comments