This is a sample Python script. Press Shift+F10 to execute it or replace it with your…
- User
This is a sample Python script.
Press Shift+F10 to execute it or replace it with your code.
Press Double Shift to search everywhere for classes, files, tool windows, actions, and settings.
import os import pickle
import tkinter as tk from tkinter import messagebox import face_recognition
def get_button(window, text, color, command, fg='white'): button = tk.Button( window, text=text, activebackground="black", activeforeground="white", fg=fg, bg=color, command=command, height=2, width=20, font=('Helvetica bold', 20) )
return buttondef get_img_label(window): label = tk.Label(window) label.grid(row=0, column=0) return label
def get_text_label(window, text): label = tk.Label(window, text=text) label.config(font=("sans-serif", 21), justify="left") return label
def get_entry_text(window): inputtxt = tk.Text(window, height=2, width=15, font=("Arial", 32)) return inputtxt
def msg_box(title, description): messagebox.showinfo(title, description)
def recognize(img, db_path): # it is assumed there will be at most 1 match in the db
embeddings_unknown = face_recognition.face_encodings(img) if len(embeddings_unknown) == 0: return 'no_persons_found' else: embeddings_unknown = embeddings_unknown[0] db_dir = sorted(os.listdir(db_path)) match = False j = 0 while not match and j < len(db_dir): path_ = os.path.join(db_path, db_dir[j]) file = open(path_, 'rb') embeddings = pickle.load(file) match = face_recognition.compare_faces([embeddings], embeddings_unknown)[0] j += 1 if match: return db_dir[j - 1][:-7] else: return 'unknown_person'напиши программу которая распознает лица на вебкамере и выводит в консоли их имя
- Assistant
Конечно, могу помочь написать программу для распознавания лиц на вебкамере и вывода их имен в консоли. Вот пример кода на Python:
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.