Commit 6426debb authored by Kieran Hymas's avatar Kieran Hymas

Added colour palette menu

parent 0a793d2b
...@@ -21,7 +21,7 @@ class Application: ...@@ -21,7 +21,7 @@ class Application:
self.availableStreams = self.getPossibleVideoStreams() self.availableStreams = self.getPossibleVideoStreams()
self.delay = 10 self.delay = 10
#Image options #Image options
self.options = {'BnW' : False, \ self.options = {'bnw' : BooleanVar(), \
'vMirror' : False, \ 'vMirror' : False, \
'hMirror' : False, \ 'hMirror' : False, \
'Rotate' : 0, \ 'Rotate' : 0, \
...@@ -50,6 +50,9 @@ class Application: ...@@ -50,6 +50,9 @@ class Application:
#Blur options #Blur options
self.blurOptionsExists = False self.blurOptionsExists = False
#Colour options
self.colourOptionsExists = False
#INIT #INIT
self.initApp() self.initApp()
self.window.mainloop() self.window.mainloop()
...@@ -69,10 +72,10 @@ class Application: ...@@ -69,10 +72,10 @@ class Application:
filemenu = Menu(menubar, tearoff=0) filemenu = Menu(menubar, tearoff=0)
menubar.add_cascade(label="File", menu=filemenu) menubar.add_cascade(label="File", menu=filemenu)
sessionmenu = Menu(filemenu, tearoff=0) sessionmenu = Menu(filemenu, tearoff=0)
filemenu.add_cascade(label="New session", menu=sessionmenu) filemenu.add_cascade(label="New stream", menu=sessionmenu)
for ind in self.availableStreams: for ind in self.availableStreams:
sessionmenu.add_command(label=str(ind), command=lambda stream=ind : self.launchVideo(stream)) sessionmenu.add_command(label=str(ind), command=lambda stream=ind : self.launchVideo(stream))
filemenu.add_command(label="Exit Pycroscope", command=self.onExit) filemenu.add_command(label="Exit", command=self.onExit)
editmenu = Menu(menubar, tearoff=0) editmenu = Menu(menubar, tearoff=0)
editmenu.add_command(label="Preferences", command=self.onPreferences) editmenu.add_command(label="Preferences", command=self.onPreferences)
...@@ -150,6 +153,7 @@ class Application: ...@@ -150,6 +153,7 @@ class Application:
self.blurOptionsExists = True self.blurOptionsExists = True
blurOptions = Toplevel(self.window, bd=1) blurOptions = Toplevel(self.window, bd=1)
blurOptions.title("Pycroscope: blur options")
blurcheck = Checkbutton(blurOptions, text="Apply Guassian blur", variable=self.options['Blur']) blurcheck = Checkbutton(blurOptions, text="Apply Guassian blur", variable=self.options['Blur'])
blurcheck.pack(side=TOP) blurcheck.pack(side=TOP)
...@@ -172,6 +176,23 @@ class Application: ...@@ -172,6 +176,23 @@ class Application:
self.blurOptionsExists = False self.blurOptionsExists = False
widget.destroy() widget.destroy()
def initColourOptionsWindow(self):
if self.colourOptionsExists:
return
self.colourOptionsExists = True
colourOptions = Toplevel(self.window, bd=1)
colourOptions.title("Pycroscope: colour options")
bnwcheck = Checkbutton(colourOptions, text="Apply black and white filter", variable=self.options['bnw'])
bnwcheck.pack(side=TOP)
colourOptions.protocol("WM_DELETE_WINDOW", lambda arg=colourOptions : self.onClosingColourOptions(arg))
def onClosingColourOptions(self, widget):
self.colourOptionsExists = False
widget.destroy()
#Menubar options #Menubar options
#File #File
def onExit(self): def onExit(self):
...@@ -210,12 +231,10 @@ class Application: ...@@ -210,12 +231,10 @@ class Application:
print("hMirror") print("hMirror")
def onBlur(self): def onBlur(self):
#self.options['Blur'] = not self.options['Blur']
self.initBlurOptionsWindow() self.initBlurOptionsWindow()
def onColour(self): def onColour(self):
self.options['BnW'] = not self.options['BnW'] self.initColourOptionsWindow()
print("Colour")
def onBrush(self): def onBrush(self):
print("Brush") print("Brush")
......
...@@ -19,7 +19,7 @@ class VideoStream: ...@@ -19,7 +19,7 @@ class VideoStream:
ret, frame = self.vidcap.read() ret, frame = self.vidcap.read()
frame = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB) frame = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)
#Apply options #Apply options
if options['BnW']: if options['bnw'].get():
frame = cv2.cvtColor(frame, cv2.COLOR_RGB2GRAY) frame = cv2.cvtColor(frame, cv2.COLOR_RGB2GRAY)
if options['vMirror']: if options['vMirror']:
frame = cv2.flip(frame, 0) frame = cv2.flip(frame, 0)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment