How to create a GUI or a front-end window for an open cv program

Here is the program for the Image webcam capturing system using OpenCV, I need to integrate a GUI which asks the user the time interval and the path through it.

import cv2
import os
import time
from tkinter import Tk
from tkinter.filedialog import askdirectory
path = askdirectory(title='Select Folder') # shows dialog box and return the path
print('The Path chosen is: ',path)  
t=int(input("Enter the time interval in seconds :"))
capture = cv2.VideoCapture(0)
img_counter = 0
start_time = time.time()

while True:
  ret, frame = capture.read()
  cv2.imshow("Webcam Image Capturing",frame)
  k = cv2.waitKey(1)

  if k%256 == 32:  
    print("Space hit, closing ...")
    break

  if time.time() - start_time >= t:     
    img_name = "image_{}_.png".format(img_counter)
    cv2.imwrite(os.path.join(path,img_name),frame) 
    print("{} Saved!".format(img_counter))
    start_time = time.time()
    img_counter += 1

capture.release()
cv2.destroyAllWindows() 

Please help me with your solutions. Thanks!



Comments

Popular posts from this blog

Today Walkin 14th-Sept

Hibernate Search - Elasticsearch with JSON manipulation

Spring Elasticsearch Operations