如何在OpenCV中检测未知用户?该代码无法在面部识别代码中检测到未知用户。

时间:2018-10-06 04:12:54

标签: python opencv detection face-recognition face

我的代码无法检测到未知人员。 即使该人不在数据库中,我的recogniser.py仍会显示该人在数据库中。例如,在数据集文件中,只有一个人名James。但是,即使是身份不明的人,例如.. jenny或Kevin(不在数据库中),代码也会将它们显示给James。

我的Recogniser.py代码位于下面

data = pickle.loads(open(args["encodings"], "rb").read())
vs = VideoStream(src=0).start()


for encoding in encodings:
    matches = face_recognition.compare_faces(data["encodings"], encoding)
    name = "Unknown"
    if True in matches:
        matchedIdxs = [i for (i, b) in enumerate(matches) if b]
        counts = {}

        for i in matchedIdxs:
            name = data["names"][i]
            counts[name] = counts.get(name, 0) + 1

            name = max(counts, key=counts.get)

        names.append(name)

    for ((top, right, bottom, left), name) in zip(boxes, names):
        # rescale the face coordinates
        top = int(top * r)
        right = int(right * r)
        bottom = int(bottom * r)
        left = int(left * r)

        cv2.rectangle(frame, (left, top), (right, bottom),
            (0, 255, 0), 2)
        y = top - 15 if top - 15 > 15 else top + 15
        cv2.putText(frame, name, (left, y), cv2.FONT_HERSHEY_SIMPLEX,
            0.75, (0, 255, 0), 2)

并且代码继续向詹姆斯展示詹妮。甚至珍妮也没有在数据库集中。如何更准确地提高人脸检测率?

0 个答案:

没有答案
相关问题