diff --git a/.idea/Filteristic.iml b/.idea/Filteristic.iml
index 4ad56e7..786dd58 100644
--- a/.idea/Filteristic.iml
+++ b/.idea/Filteristic.iml
@@ -2,10 +2,7 @@
-
-
-
-
+
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
index b29c341..13fecf3 100644
--- a/.idea/misc.xml
+++ b/.idea/misc.xml
@@ -1,4 +1,4 @@
-
+
\ No newline at end of file
diff --git a/Tkinter/GUI.py b/Tkinter/GUI.py
index 65e978d..0c6b853 100644
--- a/Tkinter/GUI.py
+++ b/Tkinter/GUI.py
@@ -38,6 +38,7 @@ def videoWindow():
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()
diff --git a/Tkinter/GUI_Image.py b/Tkinter/GUI_Image.py
index 370dd98..8441325 100644
--- a/Tkinter/GUI_Image.py
+++ b/Tkinter/GUI_Image.py
@@ -30,19 +30,17 @@ def browse():
filename = filedialog.askopenfilename(title="select File",
filetypes = (("jpeg files","*.jpg"),("all files","*.*"),('png files', '*.png')))
images.append(filename)
- canvas = Canvas(newWindow)
- canvas.config(width=1000, height=500)
- canvas.pack()
- img = ImageTk.PhotoImage(Image.open(images[0]))
-
- # images[0] = cv2.resize(images[0], (200, 200))
-
- filtering = TkinterCustomButton(master=newWindow,text="Add Filter", corner_radius=5,command=lambda: image_filter(filename, canvas, newWindow),
+ img = Image.open(images[-1])
+ img = img.resize((500, 500))
+ img = ImageTk.PhotoImage(img)
+ img_label = Label(newWindow, image=img)
+ img_label.photo = img
+ img_label.place(x=228, y=40)
+
+ filtering = TkinterCustomButton(master=newWindow,text="Add Filter", corner_radius=5,command=lambda: image_filter(filename, newWindow),
fg_color="#3319CB", hover_color="#005DFE", width=200,cursor="shuttle", text_font=("sans-serif", 20))
- filtering.pack()
+ filtering.place(x=380, y=550)
- test=canvas.create_image(0, 0, anchor="nw", image=img)
- test.pack()
@@ -69,12 +67,18 @@ def on_closing():
newWindow.protocol("WM_DELETE_WINDOW", on_closing)
- def render(image_withfilter, canvas):
+ def render(image_withfilter):
image_withfilter = cv2.cvtColor(image_withfilter, cv2.COLOR_BGR2RGB)
- photo = ImageTk.PhotoImage(image=Image.fromarray(image_withfilter))
- canvas.create_image(0, 0, anchor="nw", image=photo).pack()
-
- def next_fun(path, canvas):
+ img = Image.fromarray(image_withfilter)
+ img = img.resize((500, 500))
+ img = ImageTk.PhotoImage(img)
+ img_label = Label(newWindow, image=img)
+ img_label.photo = img
+ img_label.place(x=228, y=40)
+ # photo = ImageTk.PhotoImage(image=Image.fromarray(image_withfilter))
+ # canvas.create_image(0, 0, anchor="nw", image=photo)
+
+ def next_fun(path):
global count
images.append(image_filtering_face(
@@ -89,8 +93,8 @@ def next_fun(path, canvas):
))
count += 1
if count == len(change_filter) - 1:
- count = -1
- render(images[-1], canvas)
+ count = 0
+ render(images[-1])
def submit(content,top):
global entry
@@ -101,19 +105,20 @@ def submit(content,top):
top.destroy()
def saving(content, newWindow):
pass
- def image_filter(path, canvas, newWindow):
+ def image_filter(path, newWindow):
images.append(
image_filtering_face(["../assest/tongue.png"], path, [57], [0.6], [1.2], [-25], [0],
[0]))
save = TkinterCustomButton(master=newWindow, text="Save", corner_radius=5,
command=lambda: open_popup(images[-1],newWindow), fg_color="#3319CB",
hover_color="#005DFE", width=200, cursor="shuttle", text_font=("sans-serif", 20))
- save.place(x=50, y=544)
+ save.place(x=50, y=550)
next = TkinterCustomButton(master=newWindow, text="Next", corner_radius=5,
- command=lambda: next_fun(path, canvas), fg_color="#3319CB",
+ command=lambda: next_fun(path), fg_color="#3319CB",
hover_color="#005DFE", width=200, cursor="shuttle", text_font=("sans-serif", 20))
- next.place(x=710, y=544)
- render(images[-1], canvas)
+ newWindow.bind("", lambda x: next_fun(path))
+ next.place(x=710, y=550)
+ render(images[-1])
def open_popup(content,newWindow):
top = Toplevel(newWindow)
@@ -127,4 +132,3 @@ def open_popup(content,newWindow):
entry = tk.Entry(top, width=20, bg="white")
entry.place(x=75, y=10)
sub_btn.place(x=75, y=50)
-
diff --git a/Tkinter/GUI_Live.py b/Tkinter/GUI_Live.py
index 042ec35..8eaf614 100644
--- a/Tkinter/GUI_Live.py
+++ b/Tkinter/GUI_Live.py
@@ -18,8 +18,6 @@ def camera(newWindow):
lmain = Label(app)
lmain.grid()
-
-
def printInput():
add_path(inputtxt2.get(1.0, "end-1c"))
@@ -115,9 +113,8 @@ def path_name(frame):
command=lambda: print_path2(inputtxt, frame))
printButton.grid(row=1, column=2)
-
-
-
+ newWindow.bind("", lambda x: nextWindow())
+ newWindow.bind("", lambda x: nextback())
video_stream3()
# newWindow.mainloop()
diff --git a/filters_image/image_filtering_face.py b/filters_image/image_filtering_face.py
index 404d7c4..c8f2207 100644
--- a/filters_image/image_filtering_face.py
+++ b/filters_image/image_filtering_face.py
@@ -20,74 +20,52 @@ def image_filtering_face(path_filter,path_img,center,width,height,up,left,counte
detector = dlib.get_frontal_face_detector()
faces = detector(image)
if faces:
- try:
- for i in range(len(path_filter)):
- return filter(image,gray_image,faces,filter_image[i],center[i],width[i],height[i],up[i],left[i])
- except:
- image = cv2.imread(path_img)
- print("except")
- return image
-
- # key = cv2.waitKey(0)
- # if key == ord('n'):
- # change_image(counte)
- # elif key == ord('q'):
- # cv2.destroyAllWindows()
- #
- # elif key == ord("c"):
- # img_name = "../saved/opencv_frame.png"
- # cv2.imwrite(img_name, image)
- # print("{} written!".format(img_name))
-
- # image = cv2.imread(img_name)
- # cv2.imshow("Frame", image)
- # key = cv2.waitKey(0)
- # os.remove("../saved/opencv_frame.png")
- # if key == ord("s"):
- # user_name = input("enter name")
- # imgdir = f"../saved/{user_name}.png"
- # cv2.imwrite(imgdir, image)
- # image_filtering_face(["../assest/tongue.png"],"../assest/face.jpg",[57],[0.6],[1.2],[-25],[0])
- # if key == ord("e"):
- # image_filtering_face(["../assest/tongue.png"],"../assest/face.jpg",[57],[0.6],[1.2],[-25],[0])
-
+ # try:
+ for i in range(len(path_filter)):
+ return filter(image,gray_image,faces,filter_image[i],center[i],width[i],height[i],up[i],left[i])
+ # except:
+ # image = cv2.imread(path_img)
+ # return image
def filter(image,gray_frame,faces,filter_image1,center,width,height,up=0,left=0):
predictor_path = "../assest/shape_predictor_68_face_landmarks.dat"
predictor = dlib.shape_predictor(predictor_path)
for face in faces:
- landmarks = predictor(gray_frame, face)
-
- center_filter = (landmarks.part(center).x-left, landmarks.part(center).y-up)
- left_filter = (landmarks.part(4).x, landmarks.part(4).y)
- right_filter = (landmarks.part(14).x, landmarks.part(14).y)
-
- filter_width = int(hypot(left_filter[0] - right_filter[0],
- left_filter[1] - right_filter[1]) * width)
- filter_height = int(filter_width * height)
-
- # New filter position
- top_left = (int(center_filter[0] - filter_width / 2),
- int(center_filter[1] - filter_height / 2))
- bottom_right = (int(center_filter[0] + filter_width / 2),
- int(center_filter[1] + filter_height / 2))
-
- # Adding the new filter
- filtery = cv2.resize(filter_image1, (filter_width, filter_height))
- filtery_gray = cv2.cvtColor(filtery, cv2.COLOR_BGR2GRAY)
- _, filter1 = cv2.threshold(filtery_gray, 25, 255, cv2.THRESH_BINARY_INV)
-
- filter_area = image[top_left[1]: top_left[1] + filter_height,
- top_left[0]: top_left[0] + filter_width]
- filter_area_no_filter = cv2.bitwise_and(filter_area, filter_area, mask=filter1)
- final_filter = cv2.add(filter_area_no_filter, filtery)
-
- image[top_left[1]: top_left[1] + filter_height,
- top_left[0]: top_left[0] + filter_width,:] = final_filter
- print("filter1")
- return image
+ try:
+ landmarks = predictor(gray_frame, face)
+
+ center_filter = (landmarks.part(center).x-left, landmarks.part(center).y-up)
+ left_filter = (landmarks.part(4).x, landmarks.part(4).y)
+ right_filter = (landmarks.part(14).x, landmarks.part(14).y)
+
+ filter_width = int(hypot(left_filter[0] - right_filter[0],
+ left_filter[1] - right_filter[1]) * width)
+ filter_height = int(filter_width * height)
+
+ # New filter position
+ top_left = (int(center_filter[0] - filter_width / 2),
+ int(center_filter[1] - filter_height / 2))
+ bottom_right = (int(center_filter[0] + filter_width / 2),
+ int(center_filter[1] + filter_height / 2))
+
+ # Adding the new filter
+ filtery = cv2.resize(filter_image1, (filter_width, filter_height))
+ filtery_gray = cv2.cvtColor(filtery, cv2.COLOR_BGR2GRAY)
+ _, filter1 = cv2.threshold(filtery_gray, 25, 255, cv2.THRESH_BINARY_INV)
+
+ filter_area = image[top_left[1]: top_left[1] + filter_height,
+ top_left[0]: top_left[0] + filter_width]
+ filter_area_no_filter = cv2.bitwise_and(filter_area, filter_area, mask=filter1)
+ final_filter = cv2.add(filter_area_no_filter, filtery)
+
+ image[top_left[1]: top_left[1] + filter_height,
+ top_left[0]: top_left[0] + filter_width,:] = final_filter
+ print("filter1")
+ except:
+ print("except")
+ return image
# cv2.imshow("Frame", image)
# key = cv2.waitKey(0)
diff --git a/filters_live/video_filtering_face.py b/filters_live/video_filtering_face.py
index f35fff4..d57b1ea 100644
--- a/filters_live/video_filtering_face.py
+++ b/filters_live/video_filtering_face.py
@@ -7,9 +7,6 @@
import os
cap = cv2.VideoCapture(0)
-_, frame = cap.read()
-rows, cols, _ = frame.shape
-filter1 = np.zeros((rows, cols), np.uint8)
detector = dlib.get_frontal_face_detector()
predictor = dlib.shape_predictor("../filters_live/shape_predictor_68_face_landmarks.dat")
counte=0
@@ -19,8 +16,10 @@ def video_filtering_face(path,center,width,height,up,left,path_back,blur,filter_
for i in path:
filter_image.append(cv2.imread(i))
#
- filter1 = np.zeros((rows, cols), np.uint8)
_, frame = cap.read()
+ rows, cols, _ = frame.shape
+ filter1 = np.zeros((rows, cols), np.uint8)
+
filter1.fill(0)
gray_frame = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
faces = detector(frame)
@@ -86,7 +85,7 @@ def change_image(i):
)
mp_selfie_segmentation = mp.solutions.selfie_segmentation
-fsize = (520, 720)
+fsize = (480, 640)
def background(frame,path,blur =1):
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