大佬教程收集整理的这篇文章主要介绍了如何提供文件和文件夹的正确地址?,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我一整天都在尝试这段代码,但我不明白为什么 DIR 在打开的 CV 模块中显示错误。 我需要解决这个问题 '''
import os
import cv2 as cv
import numpy as np
people=['emily','emma','jim parson']
haar_cas=cv.CascadeClassifIEr('haar_face.xml')
#
DIR=r'C:\Users\DELL\Desktop\New folder\faces'
features=[]
labels=[]
def Train_face():
for person in people:
paths=os.path.join(path=DIR,peoplE)
label=people.index(person)
for img in os.Listdir(paths):
img_path=os.path.join(path,img)
img_array=cv.imread(img_path)
gray=cv.cvtcolor(src=img_array,code=cv.color_BGR2GRAY)
faces_rect=haar_cas.detectMultiScale(gray,scalefactor=1.1,minNeighbor=1)
for(x,y,w,h) in faces_rect:
faces_roi=graY[x:x+w,y:y+h]
features.append(faces_roi)
labels.append(label)
Train_face()
print(f'length of the feature={len(features)}')
print(f'lenght of the labels={len(labels)}')
''' 这样的输出显示
'''
file "g:\opencv\face_reconization.py",line 14
paths=os.path.join(path=DIR,peoplE)
^
SyntaxError: positional argument follows keyword argument
'''
以上是大佬教程为你收集整理的如何提供文件和文件夹的正确地址?全部内容,希望文章能够帮你解决如何提供文件和文件夹的正确地址?所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。