hacksider / Deep-Live-Cam

real time face swap and one-click video deepfake with only a single image
GNU Affero General Public License v3.0
34.92k stars 4.93k forks source link

Could someone more advanced please improve the program? #390

Closed Enchante503 closed 3 weeks ago

Enchante503 commented 3 weeks ago

I added a field to input a URL.

However, I'm a beginner at programming,

so it doesn't work properly.

Currently, the URL is written directly in the code.

Could someone more advanced please improve the program?

I'm using ctk.CTkEntry, but if I could be greedy, it would be nice if the entered address could be saved as a history, like in a combo box.

2024-08-18_02h46_54

### def create_root ###

    ipcam_value = ctk.BooleanVar(value=modules.globals.ipcam)
    ipcam_switch = ctk.CTkSwitch(root, text='IP Camera', variable=ipcam_value, cursor='hand2', command=lambda: setattr(modules.globals, 'ipcam', ipcam_value.get()))
    ipcam_switch.place(relx=0.1, rely=0.75)

    ipcam_url_value = modules.globals.ipcam_url
    ipcam_url_textbox = ctk.CTkEntry(root, placeholder_text="URL", width=340 )
    ipcam_url_textbox.place(relx=0.35, rely=0.75)

### def webcam_preview ###
    if modules.globals.source_path is None:
        # No image selected
        return

    global preview_label, PREVIEW

    # If ipcam_switch is ON, set the value of ipcam_url_textbox to webcam_url
    if modules.globals.ipcam:
        #webcam_url = ipcam_url_textbox.get() 
        webcam_url = 'http://192.168.1.10:8888/video'
    else:
        webcam_url = 0 

    cap = cv2.VideoCapture(webcam_url)  # Use index for the webcam (adjust the index accordingly if necessary) 

webcam_url = ipcam_url_textbox.get()

This is the part that should receive the text you entered, but it doesn't work properly.