我正在尝试在 Python 中创建一个文件资源管理器,它允许我从 Windows 系统上的任何目录中提取图像文件。到目前为止,我一直无法在 Python 中完成这个看似基本的任务。即使是我学校的教授也无法提供帮助。
我正在尝试制作的程序将对图像文件执行面部识别,将图像文件存储为变量,然后执行该文件的分析并将分析打印到一些 tkinter 标签。
我现在咬得比我能嚼的还多。我是一名新程序员,我已经编程了大约 3 个月。我在上人工智能课程,但是,该课程不使用结构化语言。我们学校似乎没有专家级的 Python 程序员,所以我肯定需要一些帮助。
任何有关 GUI 工具和面部识别的建议将不胜感激。以前使用的 API 是来自 Microsoft Azure 的cognitive_face API。寻找与cognitive_face 一样有效的免费开源API。
下面是一些基本代码。寻找任何可用的建议。
import subprocess
from tkinter import *
#Define Functions Here
def Open_File():
subprocess.Popen(r'explorer /select,"C:\path\of\folder\file"')
def main_window(main):
window.title('Facial Recognition')
main.update_idletasks()
width = 1024
height = 768
#find the center point of the width on the screen
x = (main.winfo_screenwidth()//2)-(width//2)
#find the center point of the height on the screen
y = (main.winfo_screenheight()//2)-(height//2)
main.geometry('{}x{}+{}+{}'.format(width,height,x,y))
#Define your Window
window = Tk()
main_window(window)
#Create Frames
topFrame = Frame(window)
topFrame.pack(side=LEFT)
bottomFrame = Frame(window)
bottomFrame.pack(side=RIGHT)
#Add Cascade Dropdown Menus
menu = Menu(window) #Add a Menu to the main window
window.config(menu=menu)
subMenu=Menu(menu)#declare a subMenu for menu
menu.add_cascade(label="File",menu=subMenu)#assign a dropdown for menu
subMenu.add_command(label="Open Image..",command =Open_File)
#Add a separator for your subMenu
subMenu.add_separator()
subMenu.add_command(label="Exit",command=exit)
#Add Buttons
##button1 = Button(topFrame,text="Open File...",fg="Grey",command=Open_File)
##button1.pack()
##button2 = Button(topFrame,text="Open Image...",fg="Dark Grey")
##button2.pack()
#Official Window loop continuously displays to screen
window.mainloop()