I want to build face recognition with python, i follow the tutorial at youtube and then this error appear when i try to run the app.
I exactly follow the tutorial right, but i don’t know if i miss some of library installation.
So this is the code that i write :
import tkinter as tk
import cv2
from PIL import Image, ImageTk
import util
class App:
def __init__(self):
self.main_window = tk.Tk()
self.main_window.geometry("1000x500+350+100")
self.login_button_main_window = util.get_button(self.main_window, "Login", "green", self.login)
self.login_button_main_window.place(x=640, y=300)
self.register_new_user_button_main_window = util.get_button(self.main_window, "Register New User", "gray", self.register_new_user, fg='black')
self.register_new_user_button_main_window.place(x=640, y=400)
self.webcam_label = util.get_img_label(self.main_window)
self.webcam_label.place(x=10, y=0, width=700, height=500)
self.add_webcam(self.webcam_label)
def add_webcam(self, label):
**if 'cap' not in self.__dict__:
self.cap = cv2.VideoCapture(0)**
self._label = label
self.process_webcam()
def process_webcam(self):
ret, frame = self.cap.read()
self.most_recent_capture_arr = frame
img_ = cv2.cvtColor(self.most_recent_capture_arr, cv2.COLOR_BGR2RGB)
self.most_recent_capture_pil Image.fromarray(img_)
imgtk = ImageTk.PhotoImage(image=self.most_recent_capture_pil)
self._label.imgtk = imgtk
self._label.configure(image=imgtk)
self._label.after(20, self.process_webcam)
def login(self):
pass
def register_new_user(self):
pass
def start(self):
self.main_window.mainloop()
if __name__ == "__main__":
app = App()
app.start()
And the error is :
self.cap = cv2.VideoCapture(0)
^
IndentationError: expected an indented block after 'if' statement on line 23
Can someone help me with this problem? because i search for an hour but find nothing.
Fix my face recognition app