Code example for Camera.Parameters

Methods: getPreviewFormat

0
 
    @Override 
    public void onPreviewFrame(byte[] data, Camera camera)
    { 
        Parameters cameraParameters = camera.getParameters();
        int imageFormat = cameraParameters.getPreviewFormat();
        // we only know how to process NV21 format (the default format) 
        if (imageFormat == ImageFormat.NV21)
        { 
            Size size = camera.getParameters().getPreviewSize();
            // get the input image into a Bitmap  
            Bitmap bmp = Bitmap.createBitmap(size.width, size.height, Bitmap.Config.ALPHA_8);
            Buffer src = ByteBuffer.wrap(data, 0, size.width * size.height);
            bmp.copyPixelsFromBuffer(src);
            if (mnLastWidth != size.width || mnLastHeight != size.height) {
                // recreate the face detector if the image size changed 
                mFd = new FaceDetector(size.width, size.height, 1);
            } 
            FaceDetector.Face[] faces = {null};
            int nFaces = mFd.findFaces(bmp, faces);
            if (nFaces != 0) {