gpt4 book ai didi

python - 这是什么 Python 语法?矩形[:, 2 :] += rects[:, 2]

转载 作者:太空宇宙 更新时间:2023-11-04 10:07:02 24 4
gpt4 key购买 nike

<分区>

在BlackHatPython中,第4章有这个函数:

def face_detect(path,file_name):
img = cv2.imread(path)
cascade = cv2.CascadeClassifier("haarcascade_frontalface_alt.xml")
rects = cascade.detectMultiScale(img, 1.3, 4, cv2.cv.CV_HAAR_SCALE_IMAGE, (20,20))
if len(rects) == 0:
return False
rects[:, 2:] += rects[:, :2]
# highlight the faces in the image
for x1,y1,x2,y2 in rects:
cv2.rectangle(img,(x1,y1),(x2,y2),(127,255,0),2)
cv2.imwrite("%s/%s-%s" % (faces_directory,pcap_file,file_name),img)
return True

什么意思

rect[:, 2:] += rects[:, :2]  

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com