Camera setFaceDetectionListener - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Camera setFaceDetectionListener method.

This code example shows how to use the following methods:getParameters, setFaceDetectionListener, startFaceDetection, startPreview
	} 
 
	public void surfaceChanged(SurfaceHolder holder, int format, int width,
			int height) {
 
		param = camera.getParameters();
		System.out.println("gets parameters");
		System.out.println("Max num faces " + param.getMaxNumDetectedFaces());
		System.out.println("sets size");
		try { 
 
			camera.setParameters(param);
			System.out.println("sets parameters");
		} catch (Exception e) {
			e.printStackTrace();
		} finally { 
			camera.startPreview();
 
			if (param.getMaxNumDetectedFaces() > 0) {
				camera.startFaceDetection();

6
CodeRank
This code example shows how to use the following methods:getParameters, setDisplayOrientation, setFaceDetectionListener, setPreviewDisplay, startFaceDetection
        surfaceHolder.addCallback(this);
        surfaceHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS); // deprecated, but required on Android versions prior to 3.0
    } 
     
    public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) {
		mCamera.stopPreview();
		isPreviewing = false;
		previewWidth = width;
		previewHeight = height;
		 
		// Make any parameter changes here, while camera is not previewing 
		 
		if(mCamera != null) {
    		try { 
    			mCamera.setPreviewDisplay(surfaceHolder);
    			mCamera.setDisplayOrientation(90); // Needed to have camera in correct orientation
    			mCamera.setFaceDetectionListener(new MyFaceDetectionListener());
    		    mCamera.startPreview();
    		    isPreviewing = true;
    		    startFaceDetection(); // start face detection feature 

6
CodeRank
This code example shows how to use the following methods:getParameters, setFaceDetectionListener, setParameters, setPreviewDisplay
    } 
 
    public void setCamera(Camera camera) {
        mCamera = camera;
        if (mCamera != null) {
            mSupportedPreviewSizes = mCamera.getParameters().getSupportedPreviewSizes();
            requestLayout();
            mCamera.setFaceDetectionListener(this);
        } 
        
    } 
 
    public void switchCamera(Camera camera) {
        setCamera(camera);
        try { 
            camera.setPreviewDisplay(mHolder);
        } catch (IOException exception) {
            Log.e(TAG, "IOException caused by setPreviewDisplay()", exception);
        } 
        Camera.Parameters parameters = camera.getParameters();

5
CodeRank
setFaceDetectionListener Method Overview
Registers a listener to be notified about the faces detected in the preview frame.
See Code Examples for other Android Camera Methods: