title: Detect face and apply a mask on it with openCV
body: <p>UPDATE: <a href="http://opencvexamples.blogspot.com/2013/11/putting-mask-on-face-using-opencv.html" rel="nofollow noreferrer">here</a> is opencv c++ sample and shows exactly what I want to do. Only thing is I need it with java.</p>
  
  <p>I have been working on a real-time Android application which detects face with front camera and add a mask on a detected face. So far face detection is working well with cascade classifier.</p>
  
  <p>I am drawing rectangles around face and circles for eyes:</p>
  
  <pre><code> Rect[] facesArray = faces.toArray();
      for (int i = 0; i &lt; facesArray.length; i++)
      {
          Imgproc.rectangle(mRgba, facesArray[i].tl(), facesArray[i].br(), FACE_RECT_COLOR, 3);
  
          xCenter = (facesArray[i].x + facesArray[i].width + facesArray[i].x) / 2;
          yCenter = (facesArray[i].y + facesArray[i].y + facesArray[i].height) / 2;
          Point center = new Point(xCenter, yCenter);
          Imgproc.circle(mRgba, center, 10, new Scalar(255, 0, 0, 255), 3);
  
      }
  </code></pre>
  
  <p>My question is, how to apply an image on detected face and show it at real time. (e.g. sunglasses, hat, moustache, and a funny animal face)</p>
  
  <p>If anyone could give a tip or tell me some key points, I would be so grateful.</p>
  
  <p><a href="http://[https://github.com/Macadamian/MonkeyCam]" rel="nofollow noreferrer">This</a> is a good example what I expect from my application. I have examined the code though but couldn't understand.</p>
  
  <p>Thanks!</p>