Ask Your Question

Facial feature detection with OpenCV with eyes and mouth corners points

asked 2013-05-29 12:59:52 -0600

RossMine gravatar image

updated 2013-05-29 13:01:55 -0600

berak gravatar image

I'm working on a face feature detection project and I do detect the eyes, nose and mouth using OpenCv withHaarcascade xml files. But, I want to have the eyes and mouth corners points and the nose center. The goal is using it to predict emotions. I found this link that shows how it works, and I need to get to this result using JAVA. Could any one help me?

Thanks in advance.

in this part we receve the face image and we drawRect on the face:

 public void drawFaces(BufferedImage image) {  
    final List<PotentialFace> faces =, db);  
    if (faces.isEmpty()) {  
    Graphics2D g2 = image.createGraphics();  
    g2.setStroke(new BasicStroke(2));  
    for (PotentialFace face : faces) {  
      final Rectangle r =;  
      final Color c1, c2;  
      final String msg;  
      if ( == null) {  
        c1 = c2 = new Color(scale(r.x, getWidth(), 255d), scale(r.y, getHeight(), 255d), 0).brighter();  
        msg = "Click to tag";  
      } else {  
        c1 = new Color(;  
        c2 = new Color((int) (c1.getRGB() - 10*face.confidence));  
        msg = String.format("%s: %f",, face.confidence);  
      g2.drawRect(r.x, r.y, r.width, r.height); 
      g2.drawString(msg, r.x + 5, r.y - 5);  
edit retag flag offensive close merge delete


have you found the output, if yes can you please update here..

bunta gravatar imagebunta ( 2013-10-10 03:09:15 -0600 )edit

1 answer

Sort by ยป oldest newest most voted

answered 2013-07-04 03:22:24 -0600

You can call flandmark methods using Java Native Interface (JNI).

For example:

c++ code to initialize flandmark

 // load flandmark model structure and initialize
 FLANDMARK_Model * model = flandmark_init("flandmark_model.dat");

java code to initialize flandmark

    private long mNatModel;
public FlandmarkLandmarkDetector(String modelFilename) {
    this.mNatModel = natInitLandmarkDetector(modelFilename);

    //and the jni code:
    JNIEXPORT jlong JNICALL  Java_org_......_natInitLandmarkDetector(
    JNIEnv * jenv, jobject, jstring jModelFilename) {
         jlong result = 0;
         const char* modelFilename = jenv->GetStringUTFChars(jModelFilename, NULL);
         FLANDMARK_Model * model = flandmark_init(modelFilename);
         result = (jlong) model;

         return result;
edit flag offensive delete link more

Question Tools


Asked: 2013-05-29 12:59:52 -0600

Seen: 4,755 times

Last updated: Jul 04 '13