Question

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.

Was it helpful?

Solution

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!

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top