# Alternatives for OpenCV at recognizing facial parts? (eyes, nose, mouth)

**URL:** https://discourse.processing.org/t/alternatives-for-opencv-at-recognizing-facial-parts-eyes-nose-mouth/34003
**Category:** Libraries
**Created:** [December 8, 2021, 1:46pm UTC](https://discourse.processing.org/t/alternatives-for-opencv-at-recognizing-facial-parts-eyes-nose-mouth/34003 "2021-12-08T13:46:25Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![badbatman](https://avatars.discourse-cdn.com/v4/letter/b/da6949/32.png) [@badbatman](https://discourse.processing.org/u/badbatman)
#### Post date: [December 8, 2021, 1:46pm UTC](https://discourse.processing.org/t/alternatives-for-opencv-at-recognizing-facial-parts-eyes-nose-mouth/34003/1 "2021-12-08T13:46:25Z")

</div>

After using OpenCv for a while I figured out it does recognize the face very well but not the eyes, nose and mouth. When applying this the detection isn’t stable enough and will create rectangles everywhere. Especially when I want to detect the mouth…

So I was wondering if there was a way to stabilize this or if there is any alternative for OpenCV? I’ve been looking online but it seems like theres not a lot of options… So I’m trying my last shot here, please feel free to come with any type of advice. Thank you.

```auto
opencv.loadCascade(OpenCV.CASCADE_FRONTALFACE);

```

![face](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/5/567c267db6a22c1045e4cb96ff2b737ec1d76561.jpeg)

```auto
opencv.loadCascade(OpenCV.CASCADE_EYE); 

```

![eyes](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/2/22916892a29ae4381a8ec79f453d98092b2680e0.jpeg)

```auto
opencv.loadCascade(OpenCV.CASCADE_NOSE);

```

![nose](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/2/2e5d8ee4fb78b5d27d3c6e8e5a55fd81d197139a.jpeg)

```auto
opencv.loadCascade(OpenCV.CASCADE_MOUTH); 

```

![mouth](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/9/958dc1cb1829eb2479b132ff0d0dda06342e72eb.jpeg)

Full Code:

```auto
import java.awt.*;
import processing.video.*;
import gab.opencv.*;

Capture video;

OpenCV opencv;

void setup() {
  size(640, 480, P3D);
  video = new Capture(this, 640, 480, "pipeline:autovideosrc");
  opencv = new OpenCV(this, 640, 480);
  video.start();
}

void draw() {
  opencv.loadImage(video);
  image(video, 0, 0 );

  noFill();
  stroke(0, 0, 0);
  strokeWeight(3);
  
  opencv.loadCascade(OpenCV.CASCADE_FRONTALFACE);
  Rectangle[] faces = opencv.detect();
  
  for (int i = 0; i < faces.length; i++) {
    rect(faces[i].x, faces[i].y, faces[i].width, faces[i].height);
  }
  
  noFill();
  stroke(0, 55, 0);
  strokeWeight(3);
  
  opencv.loadCascade(OpenCV.CASCADE_EYE); 
   Rectangle[] eye = opencv.detect();
  
  for (int i = 0; i < eye.length; i++) {
    rect(eye[i].x, eye[i].y, eye[i].width, eye[i].height);
  }
 
  noFill();
  stroke(0, 155, 0);
  strokeWeight(3);
  
  opencv.loadCascade(OpenCV.CASCADE_NOSE); 
   Rectangle[] nose = opencv.detect();
  
  for (int i = 0; i < nose.length; i++) {
    rect(nose[i].x, nose[i].y, nose[i].width, nose[i].height);
  }

  noFill();
  stroke(0, 255, 0);
  strokeWeight(3);
  
  opencv.loadCascade(OpenCV.CASCADE_MOUTH); 
   Rectangle[] mouth = opencv.detect();
  
  for (int i = 0; i < mouth.length; i++) {
    rect(mouth[i].x, mouth[i].y, mouth[i].width, mouth[i].height);
  }
}

void captureEvent(Capture c) {
  c.read();
}

```
