title: slow face detection android
body: <p>Hi my face detection thread is working too slow,
  I call this thread from onPreviewFrame only if the thread is not working else i just skip the call and after the thread detect face i call onDraw inside the view to draw rectangle </p>
  
  <pre><code>    public void run() {
          FaceDetector faceDetector = new FaceDetector(bitmapImg.getWidth(), bitmapImg.getHeight(), 1);
          numOfFacesDetected = faceDetector.findFaces(bitmapImg, detectedFaces);
  
          if (numOfFacesDetected != 0) {
              detectedFaces.getMidPoint(eyesMidPoint);
              eyesDistance = detectedFaces.eyesDistance();
  
              handler.post(new Runnable() {
                  public void run() {
                      mPrev.invalidate();
                      // turn off thread lock
                  }
              });
  
              mPrev.setEyesDistance(eyesDistance);
              mPrev.setEyesMidPoint(eyesMidPoint);
          }
  
          isThreadWorking = false;
      }
  
  
  public void onPreviewFrame(byte[] yuv, Camera camera) {
  </code></pre>
  
  <p>if (isThreadWorking)
              return;</p>
  
  <pre><code>    isThreadWorking = true;
      ByteBuffer bbuffer = ByteBuffer.wrap(yuv);
      bbuffer.get(grayBuff_, 0, bufflen_);
  
      detectThread = new FaceDetectThread(handler);
      detectThread.setBuffer(grayBuff_);
      detectThread.start();
  </code></pre>
  
  <p>my questions is maybe because am working with bitmap and not gray scale  it's taking too long ? how can i improve the speed ?</p>