title: How to add cartoon face on Camera Preview using Android
body: <p>I have a Module to put cartoon face on eyes or anywhere else on live Camera Preview. I am using Moodme Sdk. I have implemented camera preview. I m getting landmark x and y axis value. But I don't know where do i add those landmark and how to put that image on eyes using landmark. This is code for while getting person face on live camera.</p>
  
  <pre><code> @Override
  public void onImageAvailable(ImageReader reader) {
      Image image = imageReader.acquireLatestImage();
      if (image == null) {
          return;
      }
      ByteBuffer yBuffer = image.getPlanes()[0].getBuffer();
      byte[] yBytes = new byte[yBuffer.remaining()];
      yBuffer.get(yBytes);
      ByteBuffer uBuffer = image.getPlanes()[1].getBuffer();
      byte[] uBytes = new byte[uBuffer.remaining()];
      uBuffer.get(uBytes);
      ByteBuffer vBuffer = image.getPlanes()[2].getBuffer();
      byte[] vBytes = new byte[vBuffer.remaining()];
      vBuffer.get(vBytes);
  
      tracker.processImageBuffer(yBytes, WIDTH, HEIGHT, WIDTH, MDMTrackerManager.FrameFormat.GRAY);
      //renderer.updateTextureImage(yBytes, uBytes, vBytes, image.getPlanes()[1].getPixelStride());
      image.close();
  
      if (tracker.isFaceTracked()) {
      //    renderer.updateVertices();
      }
  
      if (tracker.isFaceTracked()) {
          // translate to opengl coordinates
          float[] landmarks = new float[66*2];
  
  
          for (int i = 0; i &lt; 66; ++i) {
              if(i &gt;=17 &amp;&amp; i &lt;27 || i &gt;=36 &amp;&amp; i &lt;48 ) {
                  landmarks[2 * i] = 1.0f - tracker.getLandmarks()[2 * i] / (HEIGHT / 2);
                  landmarks[2 * i + 1] = 1.0f - tracker.getLandmarks()[2 * i + 1] / (WIDTH / 2);
              }
          }
        // renderer.updateLandmarks(landmarks);
      } else {
        //  renderer.updateLandmarks(null);
      }
  
      long currentTime = System.currentTimeMillis();
      double fps = 1000.0 / (currentTime - lastFrameTime);
  
      updater.update(fps);
  
      lastFrameTime = currentTime;
  }
  </code></pre>
  
  <p>I have also used Face Detection Library But that is not giving me accurate result.Is There any good Library For Face detection and put image or Mask on Camera Preview. Any help will be appreciated. </p>