Search in sources :

Example 26 with Parameters

use of android.hardware.Camera.Parameters in project KISS by Neamar.

the class CameraHandler method setTorchState.

public void setTorchState(Boolean state) {
    try {
        openCamera();
        Parameters parms = camera.getParameters();
        if (state)
            parms.setFlashMode(Parameters.FLASH_MODE_TORCH);
        else
            parms.setFlashMode(Parameters.FLASH_MODE_OFF);
        camera.setParameters(parms);
        if (state) {
            //enable torch but retain camera
            camera.startPreview();
        } else {
            //disable torch and release camera
            camera.stopPreview();
            releaseCamera();
        }
        torchState = state;
    } catch (Exception ex) {
        releaseCamera();
        torchState = false;
    }
}
Also used : Parameters(android.hardware.Camera.Parameters) IOException(java.io.IOException)

Example 27 with Parameters

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

the class CameraFunctionalTest method testFunctionalCameraExposureCompensation.

/**
     * Functional test iterating on the range of supported exposure compensation levels
     */
@LargeTest
public void testFunctionalCameraExposureCompensation() throws Exception {
    try {
        SurfaceHolder surfaceHolder = MediaFrameworkTest.mSurfaceView.getHolder();
        Parameters params = mCameraTestHelper.getCameraParameters();
        int min = params.getMinExposureCompensation();
        int max = params.getMaxExposureCompensation();
        assertFalse("Adjusting exposure not supported", (max == 0 && min == 0));
        float step = params.getExposureCompensationStep();
        int stepsPerEV = (int) Math.round(Math.pow((double) step, -1));
        // only get integer values for exposure compensation
        for (int i = min; i <= max; i += stepsPerEV) {
            runOnLooper(new Runnable() {

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

Example 28 with Parameters

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

the class CameraFunctionalTest method testFunctionalCameraFocusModes.

/**
     * Functional test iterating on the various focus modes (auto, infinitiy, macro, etc.)
     */
@LargeTest
public void testFunctionalCameraFocusModes() throws Exception {
    try {
        SurfaceHolder surfaceHolder = MediaFrameworkTest.mSurfaceView.getHolder();
        Parameters params = mCameraTestHelper.getCameraParameters();
        List<String> supportedFocusModes = params.getSupportedFocusModes();
        assertNotNull("No focus modes supported", supportedFocusModes);
        for (int i = 0; i < supportedFocusModes.size(); i++) {
            runOnLooper(new Runnable() {

                @Override
                public void run() {
                    mCameraTestHelper.setupCameraTest();
                }
            });
            Log.v(TAG, "Setting focus mode to: " + supportedFocusModes.get(i));
            params.setFocusMode(supportedFocusModes.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 29 with Parameters

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

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 30 with Parameters

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

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)

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