diff --git a/.idea/Filteristic.iml b/.idea/Filteristic.iml index 786dd58..4486407 100644 --- a/.idea/Filteristic.iml +++ b/.idea/Filteristic.iml @@ -2,7 +2,8 @@ - + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml index 13fecf3..5005ea2 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -1,4 +1,6 @@ - + + + \ No newline at end of file diff --git a/Tkinter/GUI.py b/Tkinter/GUI.py index acdf4eb..866c16a 100644 --- a/Tkinter/GUI.py +++ b/Tkinter/GUI.py @@ -71,10 +71,7 @@ def videoWindow(): cameraWindow = Toplevel(root) root.withdraw() cameraWindow.title("New Window") - cameraWindow.geometry("700x700") - Label(cameraWindow, - text="This is a new window").grid() - + # cameraWindow.geometry("700x700") camera(cameraWindow) @@ -83,8 +80,12 @@ def on_closing(): cameraWindow.destroy() root.deiconify() - backButton = tk.Button(cameraWindow, text="Previous Page", padx=90, pady=10, fg="white", bg="#2596be", font=('arial', 15), command=on_closing) - backButton.grid() + image= PhotoImage(file ='../assest/back.png') + backButton = TkinterCustomButton(master=cameraWindow, corner_radius=15, + command=on_closing, fg_color="#f1f1f1", hover_color="#c1c1c1", cursor="shuttle", image=image, + width=50) + backButton.place(x=0,y=3) + cameraWindow.protocol("WM_DELETE_WINDOW", on_closing) diff --git a/Tkinter/GUI_Live.py b/Tkinter/GUI_Live.py index 8eaf614..21c9d20 100644 --- a/Tkinter/GUI_Live.py +++ b/Tkinter/GUI_Live.py @@ -2,66 +2,73 @@ from PIL import ImageTk, Image import cv2 from filters_live.video_filtering_face import video_filtering_face,change_filter +from tkinter_custom_button import TkinterCustomButton from tkinter import Tk from tkinter.ttk import Frame, Label from background_live.request_image import add_path,check_image save = False -count_filter = 0 -count_back = 1 +count_filter = -1 +count_back = 0 show_filter_live = False show_background_live = False def camera(newWindow): app = Frame(newWindow) - app.grid() + app.pack() lmain = Label(app) - lmain.grid() + lmain.pack() + + def printInput(): add_path(inputtxt2.get(1.0, "end-1c")) inputtxt2 = tk.Text(newWindow, - height=5, + height=1, width=20) - inputtxt2.grid(row=0, column=1) - printButton = tk.Button(newWindow, - text = "Print", - command = printInput) - printButton.grid(row=0, column=1) + inputtxt2.place(x=400,y=550) + printButton = TkinterCustomButton(master=newWindow,text="Add New Background", corner_radius=5, command=printInput, fg_color="#3319CB", hover_color="#005DFE", + width=150, + cursor="shuttle", text_font=("sans-serif", 10)) + printButton.place(x=408,y=570) def nextback(): - global count_back,show_background_live + global count_back, show_background_live len_image = check_image() if count_back == len_image: show_background_live = False - count_back=1 + count_back = 0 else: + count_back += 1 show_background_live = True - count_back+=1 + def nextWindow(): - global count_filter,show_filter_live - if count_filter == len(change_filter)-1: - show_filter_live = False - count_filter= -1 - else: - show_filter_live = True - count_filter+=1 - - def saveWindow(): - global save - save =True + global count_filter, show_filter_live + if count_filter == len(change_filter) - 1: + show_filter_live = False + count_filter = -1 + else: + count_filter += 1 + show_filter_live = True + # def saveWindow(): - importButton = tk.Button(newWindow,text="Next background", padx=90, pady=10, fg="white", bg="#2596be", font=('arial', 15), - command=nextback) - importButton.grid(row=1, column=0) - importButton = tk.Button(newWindow,text="Next filter", padx=90, pady=10, fg="white", bg="#2596be", font=('arial', 15), - command=nextWindow) - importButton.grid(row=1, column=1) - importButton = tk.Button(newWindow,text='capture and save', padx=90, pady=10, fg="white", bg="#2596be", font=('arial', 15), - command=saveWindow) - importButton.grid(row=2, column=0) + + + importButton = TkinterCustomButton(master=newWindow,text="Next background", corner_radius=5, command=nextback, fg_color="#3319CB", hover_color="#005DFE", + width=300, + cursor="shuttle", text_font=("sans-serif", 20)) + importButton.place(x=500,y=490) + importButton = TkinterCustomButton(master=newWindow,text="Next filter", corner_radius=5, command=nextWindow, fg_color="#3319CB", hover_color="#005DFE", + width=300, cursor="shuttle", text_font=("sans-serif", 20)) + importButton.place(x=160,y=490) + image = tk.PhotoImage(file='../assest/camera.png') + importButton = TkinterCustomButton(master=newWindow, corner_radius=20, + command=lambda:open_popup(newWindow), fg_color="#f1f1f1", hover_color="#c1c1c1", cursor="shuttle", + image=image, + width=50) + importButton.place(x=740,y=431) def video_stream3(): @@ -97,25 +104,33 @@ def save_image(frame): def print_path2(inputtxt, frame): name = inputtxt.get(1.0, "end-1c") - print(name) img_name = f"../saved/{name}.png" cv2.imwrite(img_name, frame) - def path_name(frame): - - inputtxt = tk.Text(newWindow, - height=5, - width=20) - - inputtxt.grid(row=1, column=2) - - printButton = tk.Button(newWindow, - text="save image", - command=lambda: print_path2(inputtxt, frame)) - printButton.grid(row=1, column=2) + inputtxt.delete('1.0', tk.END) + newWindow.geometry("960x630") newWindow.bind("", lambda x: nextWindow()) newWindow.bind("", lambda x: nextback()) video_stream3() + top ='' + def open_popup(newWindow): + global top + top = tk.Toplevel(newWindow) + top.geometry("250x150") + top.title("save") + global save + save = True + def path_name(frame): + global top + inputtxt = tk.Text(top, + height=5, + width=20) + + inputtxt.pack() + printButton = TkinterCustomButton(master=top,text="Save Image", corner_radius=5, command=lambda: print_path2(inputtxt, frame), fg_color="#3319CB", + hover_color="#005DFE", width=300, + cursor="shuttle", text_font=("sans-serif", 20)) + printButton.pack() # newWindow.mainloop() diff --git a/Tkinter/GUI_background.py b/Tkinter/GUI_background.py index bfb4fea..bb6afd2 100644 --- a/Tkinter/GUI_background.py +++ b/Tkinter/GUI_background.py @@ -1,148 +1,149 @@ -import os -from tkinter import * -from tkinter import ttk, filedialog -import requests -from PIL import Image, ImageTk -from background_image.backgorund_image import backgroundImage -from tkinter_custom_button import TkinterCustomButton -images = [] -filter_type = "" -path_name = "" - -def background_window(window_root): - window = Toplevel(window_root) - window_root.withdraw() - window.title("Import Window") - window.geometry("1000x700") - def get_filter_type(): - - global filter_type, path_name - filter_type = type_choosen.get() - if filter_type == "color": - apply() - elif filter_type == "image": - filename = filedialog.askopenfilename(title="select File", - filetypes=( - ("jpeg files", "*.jpg"), ("all files", "*.*"), - ('png files', '*.png'))) - backgroundImage(filter_type, images[-1], 0, filename) - render("../saved/temp.png") - else: - backgroundImage(filter_type, images[-1], 0, '../assest/background/back1.png') - render("../saved/temp.png") - def on_closing(): - window.destroy() - window_root.deiconify() - - window.protocol("WM_DELETE_WINDOW", on_closing) - - def apply(): - def apply_color(): - b = {'Black':(0,0,0),'Green':(0,255,0),'White':(255,255,255),'Blue':(0,0,255),'Red':(255,0,0)} - backgroundImage("color", images[-1], b[color_choosen.get()], '../assest/background/back1.png') - render("../saved/temp.png") - colorButton = TkinterCustomButton(master= window, text="Add color", corner_radius=5, - command=apply_color, fg_color="#3319CB", - hover_color="#005DFE", width=200, - cursor="shuttle", text_font=("sans-serif", 16)) - colorButton.place(x=510, y=550) - m = StringVar() - color_choosen = ttk.Combobox(window, width=20, textvariable=m) - color_choosen['values'] = ('Black', - 'Green', - 'White', - 'Blue', - 'Red') - - color_choosen.place(x=720, y=559) - color_choosen.current(2) - - - def add_from_web(): - img_url = entry.get("1.0","end-1c") - r = requests.get(img_url) - with open("../saved/web.png", 'wb') as f: - f.write(r.content) - images.append("../saved/web.png") - render(images[-1]) - common() - - - def render(image_withfilter): - img = Image.open(image_withfilter) - img = img.resize((720, 480)) - img = ImageTk.PhotoImage(img) - img_label = Label(window, image=img) - img_label.photo = img - img_label.place(x=140, y=60) - - def browse(): - filename = filedialog.askopenfilename(title="select File", - filetypes=( - ("jpeg files", "*.jpg"), ("all files", "*.*"), ('png files', '*.png'))) - images.append(filename) - render(images[-1]) - common() - - def saving(top): - os.rename("../saved/temp.png", f"../saved/{entryy.get()}.png") - entryy.delete(0,END) - on_closing(top) - - def on_closing(top): - top.destroy() - window.deiconify() - - importButton = TkinterCustomButton(master=window, text="Browse", corner_radius=5, - command=browse, fg_color="#3319CB", - hover_color="#005DFE", width=200, - cursor="shuttle", text_font=("sans-serif", 20)) - importButton.place(x=140, y= 10) - - web_link_Button = TkinterCustomButton(master=window, text="Download", corner_radius=5, - command=add_from_web, fg_color="#3319CB", - hover_color="#005DFE", width=200, - cursor="shuttle", text_font=("sans-serif", 20)) - web_link_Button.place(x=660, y= 10) - - entry = Text(window, width=27, height=2, bg="white") - entry.place(x=435, y= 13) - entry.insert(END, 'Enter image link from web') - - - n = StringVar() - type_choosen = ttk.Combobox(window, width=20, textvariable=n) - - def open_popup(newWindow): - top = Toplevel(newWindow) - top.geometry("250x150") - top.title("save") - sub_btn = TkinterCustomButton(master=top, text="Submit", corner_radius=5, command=lambda: saving(top), - fg_color="#3319CB", - hover_color="#005DFE", width=100, - cursor="shuttle", text_font=("sans-serif", 20)) - - global entryy - entryy = Entry(top, width=20, bg="white") - entryy.place(x=65, y=13) - sub_btn.place(x=75, y=50) - - def common(): - typeButton = TkinterCustomButton(master=window, text="Apply Filter", corner_radius=5, - command=get_filter_type, fg_color="#3319CB", - hover_color="#005DFE", width=200, - cursor="shuttle", text_font=("sans-serif", 16)) - typeButton.place(x=140, y=550) - - saveButton = TkinterCustomButton(master=window, text="Save", corner_radius=5, - command=lambda: open_popup(window), fg_color="#3319CB", - hover_color="#005DFE", width=200, - cursor="shuttle", text_font=("sans-serif", 20)) - saveButton.place(x=400, y=600) - type_choosen['values'] = ('image', - 'gray', - 'blur', - 'color',) - - type_choosen.place(x=350, y=559) - type_choosen.current(2) +import os +from tkinter import * +from tkinter import ttk, filedialog +import requests +from PIL import Image, ImageTk +from background_image.backgorund_image import backgroundImage +from tkinter_custom_button import TkinterCustomButton +images = [] +filter_type = "" +path_name = "" + +def background_window(window_root): + window = Toplevel(window_root) + window_root.withdraw() + window.title("Import Window") + window.geometry("1000x700") + def get_filter_type(): + + global filter_type, path_name + filter_type = type_choosen.get() + if filter_type == "color": + apply() + elif filter_type == "image": + filename = filedialog.askopenfilename(title="select File", + filetypes=( + ("jpeg files", "*.jpg"), ("all files", "*.*"), + ('png files', '*.png'))) + backgroundImage(filter_type, images[-1], 0, filename) + render("../saved/temp.png") + else: + backgroundImage(filter_type, images[-1], 0, '../assest/background/back1.png') + render("../saved/temp.png") + def on_closing(): + window.destroy() + window_root.deiconify() + + window.protocol("WM_DELETE_WINDOW", on_closing) + + def apply(): + def apply_color(): + b = {'Black':(0,0,0),'Green':(0,255,0),'White':(255,255,255),'Blue':(0,0,255),'Red':(255,0,0)} + backgroundImage("color", images[-1], b[color_choosen.get()], '../assest/background/back1.png') + render("../saved/temp.png") + colorButton = TkinterCustomButton(master= window, text="Add color", corner_radius=5, + command=apply_color, fg_color="#3319CB", + hover_color="#005DFE", width=200, + cursor="shuttle", text_font=("sans-serif", 16)) + colorButton.place(x=510, y=550) + m = StringVar() + color_choosen = ttk.Combobox(window, width=20, textvariable=m) + color_choosen['values'] = ('Black', + 'Green', + 'White', + 'Blue', + 'Red') + + color_choosen.place(x=720, y=559) + color_choosen.current(2) + + + def add_from_web(): + img_url = entry.get("1.0","end-1c") + r = requests.get(img_url) + with open("../saved/web.png", 'wb') as f: + f.write(r.content) + images.append("../saved/web.png") + render(images[-1]) + common() + + + def render(image_withfilter): + img = Image.open(image_withfilter) + img = img.resize((720, 480)) + img = ImageTk.PhotoImage(img) + img_label = Label(window, image=img) + img_label.photo = img + img_label.place(x=140, y=60) + + def browse(): + filename = filedialog.askopenfilename(title="select File", + filetypes=( + ("jpeg files", "*.jpg"), ("all files", "*.*"), ('png files', '*.png'))) + images.append(filename) + render(images[-1]) + common() + + def saving(top): + os.rename("../saved/temp.png", f"../saved/{entryy.get()}.png") + entryy.delete(0,END) + on_closing(top) + + def on_closing(top): + top.destroy() + window.deiconify() + + importButton = TkinterCustomButton(master=window, text="Browse", corner_radius=5, + command=browse, fg_color="#3319CB", + hover_color="#005DFE", width=200, + cursor="shuttle", text_font=("sans-serif", 20)) + importButton.place(x=140, y= 10) + + web_link_Button = TkinterCustomButton(master=window, text="Download", corner_radius=5, + command=add_from_web, fg_color="#3319CB", + hover_color="#005DFE", width=200, + cursor="shuttle", text_font=("sans-serif", 20)) + web_link_Button.place(x=660, y= 10) + + entry = Text(window, width=27, height=2, bg="white") + entry.place(x=435, y= 13) + entry.insert(END, 'Enter image link from web') + + + n = StringVar() + type_choosen = ttk.Combobox(window, width=20, textvariable=n) + + def open_popup(newWindow): + top = Toplevel(newWindow) + top.geometry("250x150") + top.title("save") + sub_btn = TkinterCustomButton(master=top, text="Submit", corner_radius=5, command=lambda: saving(top), + fg_color="#3319CB", + hover_color="#005DFE", width=100, + cursor="shuttle", text_font=("sans-serif", 20)) + + global entryy + entryy = Entry(top, width=20, bg="white") + entryy.place(x=65, y=13) + sub_btn.place(x=75, y=50) + + def common(): + typeButton = TkinterCustomButton(master=window, text="Apply Filter", corner_radius=5, + command=get_filter_type, fg_color="#3319CB", + hover_color="#005DFE", width=200, + cursor="shuttle", text_font=("sans-serif", 16)) + typeButton.place(x=140, y=550) + + saveButton = TkinterCustomButton(master=window, text="Save", corner_radius=5, + command=lambda: open_popup(window), fg_color="#3319CB", + hover_color="#005DFE", width=200, + cursor="shuttle", text_font=("sans-serif", 20)) + saveButton.place(x=400, y=600) + type_choosen['values'] = ('image', + 'gray', + 'blur', + 'color',) + + type_choosen.place(x=350, y=559) + type_choosen.current(2) + diff --git a/assest/background/back3.png b/assest/background/back3.png index bc5b5f2..215788b 100644 Binary files a/assest/background/back3.png and b/assest/background/back3.png differ diff --git a/assest/background/back4.png b/assest/background/back4.png index 9454d5e..c77959c 100644 Binary files a/assest/background/back4.png and b/assest/background/back4.png differ diff --git a/assest/background/back5.png b/assest/background/back5.png index ee5614d..1c44a35 100644 Binary files a/assest/background/back5.png and b/assest/background/back5.png differ diff --git a/assest/background/back6.png b/assest/background/back6.png deleted file mode 100644 index 4fc8d8b..0000000 Binary files a/assest/background/back6.png and /dev/null differ diff --git a/assest/background/back7.png b/assest/background/back7.png deleted file mode 100644 index 1c44a35..0000000 Binary files a/assest/background/back7.png and /dev/null differ diff --git a/assest/background/back8.png b/assest/background/back8.png deleted file mode 100644 index 9531160..0000000 Binary files a/assest/background/back8.png and /dev/null differ diff --git a/assest/background/back9.png b/assest/background/back9.png deleted file mode 100644 index 32d756c..0000000 Binary files a/assest/background/back9.png and /dev/null differ diff --git a/assest/camera.png b/assest/camera.png new file mode 100644 index 0000000..bdbf825 Binary files /dev/null and b/assest/camera.png differ diff --git a/assest/f01.png b/assest/f01.png new file mode 100644 index 0000000..83a563d Binary files /dev/null and b/assest/f01.png differ diff --git a/assest/f02.png b/assest/f02.png new file mode 100644 index 0000000..f416f3c Binary files /dev/null and b/assest/f02.png differ diff --git a/assest/f03.png b/assest/f03.png new file mode 100644 index 0000000..0054886 Binary files /dev/null and b/assest/f03.png differ diff --git a/assest/f04.png b/assest/f04.png new file mode 100644 index 0000000..4521da4 Binary files /dev/null and b/assest/f04.png differ diff --git a/assest/f05.png b/assest/f05.png new file mode 100644 index 0000000..700be4d Binary files /dev/null and b/assest/f05.png differ diff --git a/assest/f21.png b/assest/f21.png new file mode 100644 index 0000000..db75b5a Binary files /dev/null and b/assest/f21.png differ diff --git a/assest/f22.png b/assest/f22.png new file mode 100644 index 0000000..6c24f0e Binary files /dev/null and b/assest/f22.png differ diff --git a/assest/f31.png b/assest/f31.png new file mode 100644 index 0000000..92a779c Binary files /dev/null and b/assest/f31.png differ diff --git a/assest/f32.png b/assest/f32.png new file mode 100644 index 0000000..09d149c Binary files /dev/null and b/assest/f32.png differ diff --git a/assest/f33.png b/assest/f33.png new file mode 100644 index 0000000..5966d6b Binary files /dev/null and b/assest/f33.png differ diff --git a/assest/f34.png b/assest/f34.png new file mode 100644 index 0000000..ed00613 Binary files /dev/null and b/assest/f34.png differ diff --git a/assest/yas5.png b/assest/yas5.png new file mode 100644 index 0000000..b7fed9d Binary files /dev/null and b/assest/yas5.png differ diff --git a/assest/yas6.png b/assest/yas6.png new file mode 100644 index 0000000..487d052 Binary files /dev/null and b/assest/yas6.png differ diff --git a/assest/yas8.png b/assest/yas8.png new file mode 100644 index 0000000..f7ff4f4 Binary files /dev/null and b/assest/yas8.png differ diff --git a/filters_live/change_filter.py b/filters_live/change_filter.py index 2285361..341f679 100644 --- a/filters_live/change_filter.py +++ b/filters_live/change_filter.py @@ -1,47 +1,12 @@ ## jaso file for adding -change_filter =[{'filter':['../assest/hair9.png','../assest/ghoul2.png','../assest/eye1.png','../assest/eye2.png'], - 'center':[27,66,40,46], - 'width':[1.5,1,0.2,0.2], - 'height':[1,1,0.4,0.4], - 'up':[100,20,5,5], - 'left':[0,0,0,0], +change_filter =[{'filter':['../assest/f02.png','../assest/f04.png'], + 'center':[27,27],#27 + 'width':[1.2,4],#1.5 + 'height':[0.6,0.75],#0.4 + 'up':[20,0],#-7 + 'left':[0,0], 'counte':1}, - {'filter': ["../assest/birthday-hat.png"], - 'center': [27], - 'width': [1.3], - 'height': [1], - 'up': [120], - 'left': [0], - 'counte':2}, - {'filter': ["../assest/gold-crown.png"], - 'center': [27], - 'width': [1.3], - 'height': [1], - 'up': [120], - 'left': [0], - 'counte':3}, - {'filter': ["../assest/queens-crown.png"], - 'center': [27], - 'width': [1.3], - 'height': [1], - 'up': [120], - 'left': [0], - 'counte':4}, - {'filter': ["../assest/flower-crown.png"], - 'center': [27], - 'width': [1.3], - 'height': [1], - 'up': [80], - 'left': [0], - 'counte': 5}, - {'filter': ["../assest/funny-sunglass.png"], - 'center': [27], - 'width': [1.05], - 'height': [0.33], - 'up': [0], - 'left': [0], - 'counte': 6}, {'filter': ['../assest/moustache2.png'], 'center': [51], 'width': [1], @@ -49,13 +14,34 @@ 'up': [1], 'left': [-3], 'counte': 7}, - {'filter': ["../assest/beard.png"], - 'center': [8], - 'width': [1.1], - 'height': [1.5], + {'filter': ["../assest/yas6.png","../assest/yas8.png","../assest/yas5.png",], + 'center': [51,27,51,], + 'width': [0.8,1.2,0.5,], + 'height': [0.5,0.33,1,], + 'up': [5,-5,-15,], + 'left': [0,0.5,-40,], + 'counte':2}, + {'filter': ["../assest/funny-sunglass.png"], + 'center': [27], + 'width': [1.05], + 'height': [0.33], 'up': [0], 'left': [0], - 'counte': 8}, + 'counte': 6}, + {'filter': ['../assest/f21.png',"../assest/beard.png"], + 'center': [27,8], + 'width': [1.2,1.1], + 'height': [0.33,1.5], + 'up': [-5,0], + 'left': [0.5,0], + 'counte': 7}, + {'filter': ['../assest/f31.png',"../assest/f22.png","../assest/f33.png"], + 'center': [27,8,27], + 'width': [1.3,1.1,1], + 'height': [0.9,1,0.33], + 'up': [90,-70,0], + 'left': [0.5,0,0], + 'counte': 7}, {'filter': ["../assest/tongue.png"], 'center': [57], 'width': [0.6], diff --git a/saved/yahiasolved.png b/saved/yahiasolved.png new file mode 100644 index 0000000..a91490d Binary files /dev/null and b/saved/yahiasolved.png differ