Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
193 changes: 98 additions & 95 deletions GUI.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,56 +32,53 @@ def update(self, dt):
image_texture.blit_buffer(buf, colorfmt='bgr', bufferfmt='ubyte')
# display image from the texture
self.texture = image_texture


# todo

def newSource(self, command):
self.detector = md.MoveDetector(command)

def newMinBox(self, command):
def newMinBox(self,command):
self.detector.set_box_min_area(command)

def newBlureSize(self, command):
def newBlureSize(self,command):
self.detector.set_blur_size(command)

def newMinTreshold(self, command):
def newMinTreshold(self,command):
self.detector.set_min_threshold(command)

def newAverageAlfa(self, command):
def newAverageAlfa(self,command):
self.detector.set_average_alfa(command)

def newMask(self, command):
def newMask(self,command):
self.detector.add_mask(command)

def removeMask(self):
self.detector.add_mask("no_mask.png")
print("mask removed")

# todo
#todo
def debug1(self):
# do debug
print("debug 1")

# todo
self.detector.set_state(self.detector.state.Normal)

#todo
def debug2(self):
# do debug
self.detector.set_state(md.States.Background)

# todo
self.detector.set_state(self.detector.state.Background)

#todo
def debug3(self):
# do debug
print("debug 3")
self.detector.set_state(self.detector.state.Threshold)

# todo
#todo
def backToStr(self):
# kamera wraca do stanu początkowego
#kamera wraca do stanu początkowego
print("app clean")




class MyGrid(GridLayout):
def __init__(self, **kwargs):
super(MyGrid, self).__init__(**kwargs)

super(MyGrid,self).__init__(**kwargs)
self.controlPanel = GridLayout()
self.buttonsPanel = GridLayout()
self.txtPanel = GridLayout()
Expand All @@ -91,59 +88,58 @@ def __init__(self, **kwargs):
self.buttonsPanel.cols = 4
self.buttonsPanel.rows = 3
self.txtPanel.cols = 2

### inside app

self.add_widget(self.controlPanel)
self.add_widget(self.buttonsPanel)

###

### inside control panel



self.my_camera1 = KivyCamera( fps=30)
self.controlPanel.add_widget(self.my_camera1)
self.controlPanel.add_widget(self.txtPanel)

###

### inside buttons panel
self.Button1 = Button(text="Set \nMin Box \nArea \nSubmit")
self.Button1.bind(on_press=self.pressed1)

self.Button2 = Button(text="Set \nMin Threshold \nSubmit")
self.Button2.bind(on_press=self.pressed2)
self.Button1 = Button(text = "Set \nMin Box \nArea \nSubmit")
self.Button1.bind(on_press = self.pressed1)
self.Button2 = Button(text = "Set \nMin Threshold \nSubmit" )
self.Button2.bind(on_press = self.pressed2)

self.Button3 = Button(text="Debug 1")
self.Button3.bind(on_press=self.pressed3)
self.Button3 = Button(text = "Debug Normal")
self.Button3.bind(on_press = self.pressed3)

self.Button4 = Button(text="Video \nSource \nSubmit")
self.Button4.bind(on_press=self.pressed4)
self.Button4 = Button(text = "Video \nSource \nSubmit")
self.Button4.bind(on_press = self.pressed4)

self.Button5 = Button(text="Set \nAverage Alfa \nSubmit")
self.Button5.bind(on_press=self.pressed5)
self.Button5 = Button(text = "Set \nAverage Alfa \nSubmit")
self.Button5.bind(on_press = self.pressed5)

self.Button6 = Button(text="Set \nBlur Size \nSubmit")
self.Button6.bind(on_press=self.pressed6)
self.Button6 = Button(text = "Set \nBlur Size \nSubmit")
self.Button6.bind(on_press = self.pressed6)

self.Button7 = Button(text="Debug 2")
self.Button7.bind(on_press=self.pressed7)
self.Button7 = Button(text = "Debug Background")
self.Button7.bind(on_press = self.pressed7)

self.Button8 = Button(text="Clean App")
self.Button8.bind(on_press=self.pressed8)
self.Button8 = Button(text = "Clean App")
self.Button8.bind(on_press = self.pressed8)

self.Button9 = Button(text="Add Mask \n Submit")
self.Button9.bind(on_press=self.pressed9)
self.Button9 = Button(text = "Add Mask \n Submit")
self.Button9.bind(on_press = self.pressed9)

self.Button10 = Button(text="Remove Maks")
self.Button10.bind(on_press=self.pressed10)
self.Button10 = Button(text = "Remove Maks")
self.Button10.bind(on_press = self.pressed10)

self.Button11 = Button(text="Debug 3")
self.Button11.bind(on_press=self.pressed11)
self.Button11 = Button(text = "Debug Treshold")
self.Button11.bind(on_press = self.pressed11)

self.Button12 = Button(text="Exit")
self.Button12.bind(on_press=self.pressed12)
self.Button12 = Button(text = "Exit")
self.Button12.bind(on_press = self.pressed12)
###

self.buttonsPanel.add_widget(self.Button1)
Expand All @@ -160,17 +156,17 @@ def __init__(self, **kwargs):
self.buttonsPanel.add_widget(self.Button12)

### inside txt panel
self.inputPanel = TextInput(multiline=False)
self.inputPanel = TextInput(multiline = False)
self.txtPanel.add_widget(self.inputPanel)

self.outputPanel = Label(text="it will be output")
self.outputPanel = Label(text = "it will be output")
self.txtPanel.add_widget(self.outputPanel)
###

def pressed1(self, instance):
# newMinBox
def pressed1(self,instance):
#newMinBox
command = self.inputPanel.text
self.inputPanel.text = ""
self.inputPanel.text =""
self.outputPanel.text = "min box size = \n" + command
if command != '':
a = int(command)
Expand All @@ -180,11 +176,11 @@ def pressed1(self, instance):
self.outputPanel.text = "bad value = " + command
else:
self.outputPanel.text = "no value given" + command

def pressed2(self, instance):
# newMinTreshold DONE
def pressed2(self,instance):
#newMinTreshold DONE
command = self.inputPanel.text
self.inputPanel.text = ""
self.inputPanel.text =""
self.outputPanel.text = "min treshold = \n" + command
if command != '':
a = int(command)
Expand All @@ -195,25 +191,27 @@ def pressed2(self, instance):
else:
self.outputPanel.text = "no value given" + command

def pressed3(self, instance):
# Debug1 JUTRO
self.outputPanel.text = "debug 1 ON"
def pressed3(self,instance):
#Debug1 JUTRO
self.outputPanel.text = "debug normal"
self.my_camera1.debug1()


def pressed4(self, instance):
# newSoure JUTRO
def pressed4(self,instance):
#newSoure JUTRO
command = self.inputPanel.text
self.inputPanel.text = ""
self.inputPanel.text =""
self.outputPanel.text = "video path/link/cam = \n" + command
if (command == '0'):
if(command == '0'):
command = 0
print("Comand:" + str(type(command)))

self.my_camera1.newSource(command)

def pressed5(self, instance):
# newAverageAlfa DONE

def pressed5(self,instance):
#newAverageAlfa DONE
command = self.inputPanel.text
self.inputPanel.text = ""
self.inputPanel.text =""
self.outputPanel.text = "average alfa = \n" + command
if command != '':
a = float(command)
Expand All @@ -224,10 +222,11 @@ def pressed5(self, instance):
else:
self.outputPanel.text = "no value given" + command

def pressed6(self, instance):
# SetBlureSize DONE

def pressed6(self,instance):
#SetBlureSize DONE
command = self.inputPanel.text
self.inputPanel.text = ""
self.inputPanel.text =""
self.outputPanel.text = "blure size = \n" + command
if command != '':
a = int(command)
Expand All @@ -238,40 +237,45 @@ def pressed6(self, instance):
else:
self.outputPanel.text = "no value given" + command

def pressed7(self, instance):
# debug2
self.outputPanel.text = "debug 2 ON"

def pressed7(self,instance):
#debug2
self.outputPanel.text = "debug background"
self.my_camera1.debug2()

# ???
def pressed8(self, instance):
# clean app
#???
def pressed8(self,instance):
#clean app
self.outputPanel.text = "app cleaned"
self.my_camera1.backToStr()

# DONE
def pressed9(self, instance):
# AddMask
#DONE
def pressed9(self,instance):
#AddMask
command = self.inputPanel.text
self.inputPanel.text = ""
self.inputPanel.text =""
self.outputPanel.text = "mask added, path = \n" + command
self.my_camera1.newMask(command)

def pressed10(self, instance):
# RemoveMask
def pressed10(self,instance):
#RemoveMask
self.outputPanel.text = "mask removed"
self.my_camera1.removeMask()

def pressed11(self, instance):
# Debug 3
self.outputPanel.text = "debug 3 ON"
def pressed11(self,instance):
#Debug 3
self.outputPanel.text = "debug treshold"
self.my_camera1.debug3()

def pressed12(self, instance):
# close app
self.my_camera1.detector.captureStream.release()
App.get_running_app().stop()


def loadCam(self,instance):
self.capture = cv2.VideoCapture(self.a)


class MyApp(App):
def build(self):
Expand All @@ -282,12 +286,11 @@ def on_stop(self):
print("Closing")


if __name__ == '__main__':
MyApp().run()



"""
DO ZROBIENIA:
1. 3 debugi
2. wczytanie source
3. podpięcie masek wywala błąd w mask.py (zła wersja pythona???)
"""
"""
6 changes: 5 additions & 1 deletion main.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
import move_detector as md
import GUI as g
if __name__ == '__main__':
g.MyApp().run()
#detector = md.MoveDetector()
#detector.loop()

detector = md.MoveDetector()