0

I am trying to develop a simple app using camera preview overlayed by another custom view. My aim is to get the frame data from Camera.PreviewCallback.onPreviewFrame(byte[] data, Camera camera), convert it to Bitmap and call FaceDetector.findFaces(Bitmap bitmap, Face[] faces). I need to detect faces and draw boxes on the detected faces on the overlayed custom view.

I am looking out for a faster way to convert the jpg encoded byte array to Bitmap image. My ImageFormat for camera is JPEG, that I came to know using Camera.Paramaeters.getPictureFormat (). I am expecting the conversion to happen fast otherwise I will have to drop frames for processing to avoid crash.

I did some search to find Getting frames from Video Image in Android to tackle YUV formats, but could not find anything for jpg encoded array to be converted to bitmap.

Community
  • 1
  • 1
Mohitt
  • 2,957
  • 3
  • 29
  • 52

1 Answers1

1

Just in case you didn't spot it:

If you are targeting devices running Android 4.0 or more, the ability to detect faces in the preview is natively included in the Android SDK. That would spare you the (slow and costly) camera frames to Bitmap conversion, which I guess won't be able to offer you the real-time face detection you probably expect...

Have a look at the Camera.FaceDetectionListener class, and how to use it with Camera.setFaceDetectionListener, Camera.startFaceDetection and Camera.stopFaceDetection.

Hope this helps!

mbrenon
  • 4,851
  • 23
  • 25
  • This is actually a prototype. Right now I am using the android's native face detection, but I have to replace the detection with a different algorithm that is server by a remote server. Besides, face detection is just one of the process, there are a further more processing required that will take data feed from other sensors, most of which will be processed at the remote server. I know this architecture sounds very strange, but its merely a proof of concept. – Mohitt Jan 20 '14 at 10:59