Skip to content

Commit

Permalink
Bug: GUI stops working after 1st job (#77)
Browse files Browse the repository at this point in the history
* relative window size

* add min window size

* term logger

* trying stuff

* see if this works

* readme update

* done
  • Loading branch information
suchak1 authored Nov 28, 2019
1 parent 28edcaa commit 82a8288
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 8 deletions.
36 changes: 36 additions & 0 deletions docs/README_iteration2.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,42 @@ Note: Make sure you specify the right python version when you make these command
### (4) Acceptance tests
Note: Multiprocessing does not currently work on Mac OS, only Linux and Windows Subsystem for Linux. This means the GUI will break after pressing start on Mac OS. We are working on a solution. In the meantime, the following works well on Linux (although uses 100% CPU due to multiprocessing).
Here are 3 acceptance tests:
First, run `python src/start.py` to start GUI. Then, choose the test video in `test/COSTA_RICA.mp4` using the `Upload` button. Input each of the following scenarios, and click Start. The output should match the expected outputs below.
1. Test 1
- **Input:**
- *Confidence:* 30%
- *Polling Rate:* 2 sec
- *Anti:* 5 sec (default)
- *Search Terms:* beach
- **Output:**
- 3 clips in `test/` folder all of the beach
2. Test 2
- **Input:**
- *Confidence:* 50%
- *Polling Rate:* 2 sec
- *Anti:* 5 sec (default)
- *Search Terms:* fountain
- **Output:**
- 3 clips in `test/` 1st and 3rd are waterfalls, 2nd clip is beach
3. Test 3
- **Input:**
- *Confidence:* 80%
- *Polling Rate:* 2 sec
- *Anti:* 5 sec (default)
- *Search Terms:* frog
- **Output:**
- 5 clips in `test/` folder first 2 are frogs, middle is komodo dragon, last 2 are snakes
### (5) Text Description of Implementation
- **For the GUI and Input/Output, and local data processing:** We have connected the frontend to the backend of our program. We have also updated the GUI to have a cleaner and easier-to-use interface and to improve user experience. Fundamental testing features like displaying the settings and path as well having a kill window button were improved and implemented. Also, the add and clear buttons were removed from the search bar and instead, whatever is in the search bar at the time of starting the processing will be the terms that are searched for. This allows the user to delete search terms after they have been typed in. The sentence captioning feature has been added to the GUI.
- **For API interaction and Post-API Data Processing:** We have implemented a semantic similarity (matching search terms with related words) to improve/bolster the relevancy of outputted clips. This was implemented in the `get_related_words()` function. The function `classify_img()` leverages this function, which uses a related words API to build a more inclusive classification dictionary which goes to classify_frames. This means a user should be able to search for more than merely the 1000 predefined TestNet classifications/categories. For example, a classification label “sports_car” now will match user search terms for “car,” “roadster,” “ferrari,” “corvette,” etc.
Expand Down
10 changes: 7 additions & 3 deletions src/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def do_the_job(self):
video = cv2.VideoCapture(self.video_path)
video.set(cv2.CAP_PROP_POS_AVI_RATIO, 1)
mRuntime = video.get(cv2.CAP_PROP_POS_MSEC)
self.settings['runtime'] = mRuntime / 1000
self.settings['runtime'] = int(mRuntime // 1000)
data = self.classify_frames()
results = self.interpret_results(data, self.settings['conf'])
self.save_clips(results)
Expand Down Expand Up @@ -71,9 +71,13 @@ def get_frames(self):
return frms

def classify_frame(self, frame):
time = frame [1]
time = frame[1]
img = frame[0]
return (time, self.score(Worker().classify_img(img)) / 100)
classifications = Worker().classify_img(img)
for term in self.settings['search']:
if term in classifications:
print(f'{term} at {time} sec')
return (time, self.score(classifications) / 100)

def classify_frames(self):
frames = self.get_frames()
Expand Down
21 changes: 16 additions & 5 deletions src/view.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def set_settings(self, values, path):
if len(extra) > 0:
self.set_default_settings()
return False

# values['runtime'] = int(values['runtime'])
try:
if not (isinstance(values['conf'], (int,float)) and isinstance(values['poll'], int) and isinstance(values['anti'], int) and isinstance(values['runtime'], int)):
raise TypeError
Expand Down Expand Up @@ -116,14 +116,26 @@ def render(self):

win = Tk()

win.title("Intravideo Search")
win.geometry("960x540")
# get user screen size
width = win.winfo_screenwidth()
height = win.winfo_screenheight()

win.title("IntraVideo Search")
# set relative window size
win_width = int(width // 2.5)
win_height = int(height // 2)
win.geometry(f'{win_width}x{win_height}')
win.minsize(win_width, win_height)

win_header = Frame(win)
win_header.pack()
win_content = Frame(win)
win_content.pack()

lbl1 = Label(win_header, text= "Welcome to Intravideo Search!", font=("Times New Roman", 50), anchor="w")
# print(win.theme_names())
# ttk.theme_use('alt')

lbl1 = Label(win_header, text= "IntraVideo Search", font=("Times New Roman", 50), anchor="w")
lbl1.grid(column=0, row=0, columnspan=3)

lbl2 = Label(win_content, text="Upload a video file", justify=LEFT)
Expand Down Expand Up @@ -319,7 +331,6 @@ def run_the_job():
except e: #capture any errors that may occur
display_errors("Error", e)


start_button = Button(win_content,text="Start", command=run_the_job)
start_button.grid(column=1, row = 93)

Expand Down
Binary file added test/COSTA_RICA.mp4
Binary file not shown.

0 comments on commit 82a8288

Please sign in to comment.