# How to intimate face not found in real time face detection project using opencv

**URL:** <https://forum.opencv.org/t/how-to-intimate-face-not-found-in-real-time-face-detection-project-using-opencv/1634>\
**Category:** Python\
**Created:** [February 18, 2021, 8:31am UTC](https://forum.opencv.org/t/how-to-intimate-face-not-found-in-real-time-face-detection-project-using-opencv/1634 "2021-02-18T08:31:27Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![revathi](https://avatars.discourse-cdn.com/v4/letter/r/e274bd/32.png) [@revathi](https://forum.opencv.org/u/revathi)\
**Post date:** [February 18, 2021, 8:31am UTC](https://forum.opencv.org/t/how-to-intimate-face-not-found-in-real-time-face-detection-project-using-opencv/1634/1 "2021-02-18T08:31:27Z")

</div>

```
while True:
   
    frames = pipeline.wait_for_frames()
    color_frame = frames.get_color_frame()

    # Convert depth_frame to numpy array to render image in opencv
    img = np.asanyarray(color_frame.get_data())
    gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
    faces = face_cascade.detectMultiScale(gray, 1.3, 5)
    for (x, y, w, h) in faces:
        print(x, y, w, h)
        cv2.rectangle(img, (x, y), (x + w, y + h), (255, 0, 0), 2)
        try:
            id, confidence = model.predict(gray[y :y + h, x :x + w])
            if confidence < 100:
                id = names[id]
                confidence = " {0}%".format(round(100 - confidence))
            else:
                id = "unknown"
                confidence = " {0}%".format(round(100 - confidence))
            cv2.putText(img, str(id), (x + 5, y - 5), cv2.FONT_HERSHEY_SIMPLEX, 1, (0, 0, 255), 2)
            cv2.putText(img,
                        str(confidence),
                        (x + 5, y + h - 5),
                        cv2.FONT_HERSHEY_SIMPLEX,
                        1, (0, 0, 255), 2)
        except:
            cv2.putText(img, "Face not Found", (40, 40), cv2.FONT_HERSHEY_COMPLEX, 1, (0, 255, 0), 2)
            pass

    cv2.imshow(window_name, img);
    key = cv2.waitKey(1)
    # if pressed escape exit program
    if key == 27:
        cv2.destroyAllWindows()
        break
```

---

<div class="post-metadata">

**Author:** ![kbarni](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opencv.org/kbarni/32/26_2.png) [@kbarni](https://forum.opencv.org/u/kbarni)\
**Post date:** [February 18, 2021, 3:04pm UTC](https://forum.opencv.org/t/how-to-intimate-face-not-found-in-real-time-face-detection-project-using-opencv/1634/2 "2021-02-18T15:04:28Z")

</div>

```
if len(faces)==0:
    cv2.putText(img, "Not found", (40, 40), cv2.FONT_HERSHEY_COMPLEX, 1, (0, 255, 0), 2)
else:
    for (x, y, w, h) in faces:
        ...
```

---

<div class="post-metadata">

**Author:** ![revathi](https://avatars.discourse-cdn.com/v4/letter/r/e274bd/32.png) [@revathi](https://forum.opencv.org/u/revathi)\
**Post date:** [March 17, 2021, 6:06am UTC](https://forum.opencv.org/t/how-to-intimate-face-not-found-in-real-time-face-detection-project-using-opencv/1634/3 "2021-03-17T06:06:59Z")

</div>

thanks for your reply.

---

<div class="post-metadata">

**Author:** ![revathi](https://avatars.discourse-cdn.com/v4/letter/r/e274bd/32.png) [@revathi](https://forum.opencv.org/u/revathi)\
**Post date:** [April 20, 2021, 11:06am UTC](https://forum.opencv.org/t/how-to-intimate-face-not-found-in-real-time-face-detection-project-using-opencv/1634/4 "2021-04-20T11:06:24Z")

</div>

how to restrict duplicate face or fake face recognition at the same time intimate the face not found.

---

<div class="post-metadata">

**Author:** ![berak](https://avatars.discourse-cdn.com/v4/letter/b/85f322/32.png) [@berak](https://forum.opencv.org/u/berak)\
**Post date:** [April 20, 2021, 11:27am UTC](https://forum.opencv.org/t/how-to-intimate-face-not-found-in-real-time-face-detection-project-using-opencv/1634/5 "2021-04-20T11:27:38Z")

</div>

> [@revathi](#):
>
> intimate

did you mean: _imitate_ ?

---

<div class="post-metadata">

**Author:** ![revathi](https://avatars.discourse-cdn.com/v4/letter/r/e274bd/32.png) [@revathi](https://forum.opencv.org/u/revathi)\
**Post date:** [April 21, 2021, 1:08pm UTC](https://forum.opencv.org/t/how-to-intimate-face-not-found-in-real-time-face-detection-project-using-opencv/1634/6 "2021-04-21T13:08:29Z")

</div>

Intimate means the duplicate face enter in inside of camera it should intimate as **the face not found** in the real time face recognition.

---

<div class="post-metadata">

**Author:** ![berak](https://avatars.discourse-cdn.com/v4/letter/b/85f322/32.png) [@berak](https://forum.opencv.org/u/berak)\
**Post date:** [April 22, 2021, 8:09am UTC](https://forum.opencv.org/t/how-to-intimate-face-not-found-in-real-time-face-detection-project-using-opencv/1634/7 "2021-04-22T08:09:12Z")

</div>

if the question was: _how to inprove the face recognition_, then:

- have enough images (20+ per person)
- control the lighting in the images, make it as similar as possible to the test situation
- proper cropping, the less background, the better
- proper alignment (e.g. from facial landmarks)
- try a different recognition mechanism, e.g. the OpenFace dnn
