Search in sources :

Example 11 with Parameters

use of android.hardware.Camera.Parameters in project platform_frameworks_base by android.

the class CameraFunctionalTest method testFunctionalCameraWhiteBalance.

/**
     * Functional test iterating on the various white balances (auto, daylight, cloudy, etc.)
     */
@LargeTest
public void testFunctionalCameraWhiteBalance() throws Exception {
    try {
        SurfaceHolder surfaceHolder = MediaFrameworkTest.mSurfaceView.getHolder();
        Parameters params = mCameraTestHelper.getCameraParameters();
        List<String> supportedWhiteBalance = params.getSupportedWhiteBalance();
        assertNotNull("No white balance modes supported", supportedWhiteBalance);
        for (int i = 0; i < supportedWhiteBalance.size(); i++) {
            runOnLooper(new Runnable() {

                @Override
                public void run() {
                    mCameraTestHelper.setupCameraTest();
                }
            });
            Log.v(TAG, "Setting white balance to: " + supportedWhiteBalance.get(i));
            params.setWhiteBalance(supportedWhiteBalance.get(i));
            mCameraTestHelper.setParameters(params);
            mCameraTestHelper.startCameraPreview(surfaceHolder);
            mCameraTestHelper.capturePhoto();
        }
        mCameraTestHelper.cleanupTestImages();
    } catch (Exception e) {
        Log.e(TAG, e.toString());
        fail("Camera focus modes test Exception");
    }
}
Also used : SurfaceHolder(android.view.SurfaceHolder) Parameters(android.hardware.Camera.Parameters) LargeTest(android.test.suitebuilder.annotation.LargeTest)

Example 12 with Parameters

use of android.hardware.Camera.Parameters in project platform_frameworks_base by android.

the class CameraStressTest method testStressCameraZoom.

/**
     * Stress test iterating on the range of supported camera zoom levels
     */
@LargeTest
public void testStressCameraZoom() throws Exception {
    try {
        SurfaceHolder surfaceHolder = MediaFrameworkTest.mSurfaceView.getHolder();
        Parameters params = mCameraTestHelper.getCameraParameters();
        if (!params.isSmoothZoomSupported() && !params.isZoomSupported()) {
            Log.v(TAG, "Device camera does not support zoom");
            fail("Camera zoom stress test failed due to unsupported feature");
        } else {
            Log.v(TAG, "Device camera does support zoom");
            Log.v(TAG, "Start preview");
            mOutput.write("Total number of loops: " + NUMBER_OF_ZOOM_LOOPS + "\n");
            mOutput.write("No of loops: ");
            int nextZoomLevel = 0;
            for (int i = 0; i < NUMBER_OF_ZOOM_LOOPS; i++) {
                runOnLooper(new Runnable() {

                    @Override
                    public void run() {
                        mCameraTestHelper.setupCameraTest();
                    }
                });
                mCameraTestHelper.startCameraPreview(surfaceHolder);
                params = mCameraTestHelper.mCamera.getParameters();
                int currentZoomLevel = params.getZoom();
                if (nextZoomLevel >= params.getMaxZoom()) {
                    nextZoomLevel = 0;
                }
                ++nextZoomLevel;
                if (params.isSmoothZoomSupported()) {
                    mCameraTestHelper.mCamera.startSmoothZoom(nextZoomLevel);
                } else {
                    params.setZoom(nextZoomLevel);
                    mCameraTestHelper.setParameters(params);
                }
                mCameraTestHelper.capturePhoto();
                if (i == 0) {
                    mOutput.write(Integer.toString(i));
                } else {
                    mOutput.write(", " + i);
                }
            }
        }
        mCameraTestHelper.cleanupTestImages();
    } catch (Exception e) {
        Log.e(TAG, e.toString());
        fail("Camera zoom stress test Exception");
    }
}
Also used : SurfaceHolder(android.view.SurfaceHolder) Parameters(android.hardware.Camera.Parameters) LargeTest(android.test.suitebuilder.annotation.LargeTest)

Example 13 with Parameters

use of android.hardware.Camera.Parameters in project platform_frameworks_base by android.

the class CameraStressTest method testStressCameraSceneModes.

/**
     * Stress test iterating on the various scene modes (action, night, party, etc.)
     */
@LargeTest
public void testStressCameraSceneModes() throws Exception {
    try {
        SurfaceHolder surfaceHolder = MediaFrameworkTest.mSurfaceView.getHolder();
        Parameters params = mCameraTestHelper.getCameraParameters();
        List<String> supportedSceneModes = params.getSupportedSceneModes();
        assertNotNull("No scene modes supported", supportedSceneModes);
        mOutput.write("Total number of loops: " + (NUMBER_OF_SCENE_MODE_LOOPS * supportedSceneModes.size()) + "\n");
        Log.v(TAG, "Start preview");
        mOutput.write("No of loop: ");
        for (int i = 0; i < supportedSceneModes.size(); i++) {
            for (int j = 0; j < NUMBER_OF_SCENE_MODE_LOOPS; j++) {
                runOnLooper(new Runnable() {

                    @Override
                    public void run() {
                        mCameraTestHelper.setupCameraTest();
                    }
                });
                Log.v(TAG, "Setting scene mode to " + supportedSceneModes.get(i));
                params.setSceneMode(supportedSceneModes.get(i));
                mCameraTestHelper.setParameters(params);
                mCameraTestHelper.startCameraPreview(surfaceHolder);
                mCameraTestHelper.capturePhoto();
                if (i == 0 && j == 0) {
                    mOutput.write(Integer.toString(j + i * NUMBER_OF_SCENE_MODE_LOOPS));
                } else {
                    mOutput.write(", " + (j + i * NUMBER_OF_SCENE_MODE_LOOPS));
                }
            }
        }
        mCameraTestHelper.cleanupTestImages();
    } catch (Exception e) {
        Log.e(TAG, e.toString());
        fail("Camera scene mode test Exception");
    }
}
Also used : SurfaceHolder(android.view.SurfaceHolder) Parameters(android.hardware.Camera.Parameters) LargeTest(android.test.suitebuilder.annotation.LargeTest)

Example 14 with Parameters

use of android.hardware.Camera.Parameters in project libstreaming by fyhertz.

the class VideoStream method createCamera.

protected synchronized void createCamera() throws RuntimeException {
    if (mSurfaceView == null)
        throw new InvalidSurfaceException("Invalid surface !");
    if (mSurfaceView.getHolder() == null || !mSurfaceReady)
        throw new InvalidSurfaceException("Invalid surface !");
    if (mCamera == null) {
        openCamera();
        mUpdated = false;
        mUnlocked = false;
        mCamera.setErrorCallback(new Camera.ErrorCallback() {

            @Override
            public void onError(int error, Camera camera) {
                // Whether or not this callback may be called really depends on the phone
                if (error == Camera.CAMERA_ERROR_SERVER_DIED) {
                    // In this case the application must release the camera and instantiate a new one
                    Log.e(TAG, "Media server died !");
                    // We don't know in what thread we are so stop needs to be synchronized
                    mCameraOpenedManually = false;
                    stop();
                } else {
                    Log.e(TAG, "Error unknown with the camera: " + error);
                }
            }
        });
        try {
            // If the phone has a flash, we turn it on/off according to mFlashEnabled
            // setRecordingHint(true) is a very nice optimization if you plane to only use the Camera for recording
            Parameters parameters = mCamera.getParameters();
            if (parameters.getFlashMode() != null) {
                parameters.setFlashMode(mFlashEnabled ? Parameters.FLASH_MODE_TORCH : Parameters.FLASH_MODE_OFF);
            }
            parameters.setRecordingHint(true);
            mCamera.setParameters(parameters);
            mCamera.setDisplayOrientation(mOrientation);
            try {
                if (mMode == MODE_MEDIACODEC_API_2) {
                    mSurfaceView.startGLThread();
                    mCamera.setPreviewTexture(mSurfaceView.getSurfaceTexture());
                } else {
                    mCamera.setPreviewDisplay(mSurfaceView.getHolder());
                }
            } catch (IOException e) {
                throw new InvalidSurfaceException("Invalid surface !");
            }
        } catch (RuntimeException e) {
            destroyCamera();
            throw e;
        }
    }
}
Also used : Parameters(android.hardware.Camera.Parameters) Camera(android.hardware.Camera) IOException(java.io.IOException) InvalidSurfaceException(net.majorkernelpanic.streaming.exceptions.InvalidSurfaceException) SuppressLint(android.annotation.SuppressLint)

Example 15 with Parameters

use of android.hardware.Camera.Parameters in project android_frameworks_base by DirtyUnicorns.

the class CameraTestHelper method getCameraParameters.

/**
     * Helper method for getting the available parameters of the default camera
     */
public Parameters getCameraParameters() {
    mCamera = Camera.open(CAMERA_ID);
    Parameters params = mCamera.getParameters();
    mCamera.release();
    return params;
}
Also used : Parameters(android.hardware.Camera.Parameters)

Aggregations

Parameters (android.hardware.Camera.Parameters)72 LargeTest (android.test.suitebuilder.annotation.LargeTest)36 SurfaceHolder (android.view.SurfaceHolder)36 Camera (android.hardware.Camera)16 CameraCharacteristics (android.hardware.camera2.CameraCharacteristics)15 Rect (android.graphics.Rect)10 CaptureRequest (android.hardware.camera2.CaptureRequest)10 CameraMetadataNative (android.hardware.camera2.impl.CameraMetadataNative)10 Size (android.util.Size)10 IOException (java.io.IOException)10 ZoomData (android.hardware.camera2.legacy.ParameterUtils.ZoomData)5 MeteringRectangle (android.hardware.camera2.params.MeteringRectangle)5 Location (android.location.Location)5 Range (android.util.Range)5 ArrayList (java.util.ArrayList)5 List (java.util.List)5 Size (android.hardware.Camera.Size)4 SuppressLint (android.annotation.SuppressLint)1 TargetApi (android.annotation.TargetApi)1 Point (android.graphics.Point)1