Search in sources :

Example 31 with Size

use of android.util.Size in project android_frameworks_base by ResurrectionRemix.

the class Camera2CaptureRequestTest method testAeModeAndLock.

/**
     * Test AE mode and lock.
     *
     * <p>
     * For AE lock, when it is locked, exposure parameters shouldn't be changed.
     * For AE modes, each mode should satisfy the per frame controls defined in
     * API specifications.
     * </p>
     */
public void testAeModeAndLock() throws Exception {
    for (int i = 0; i < mCameraIds.length; i++) {
        try {
            openDevice(mCameraIds[i]);
            if (!mStaticInfo.isColorOutputSupported()) {
                Log.i(TAG, "Camera " + mCameraIds[i] + " does not support color outputs, skipping");
                continue;
            }
            // Max preview size.
            Size maxPreviewSz = mOrderedPreviewSizes.get(0);
            // Update preview surface with given size for all sub-tests.
            updatePreviewSurface(maxPreviewSz);
            // Test iteration starts...
            for (int iteration = 0; iteration < getIterationCount(); ++iteration) {
                Log.v(TAG, String.format("AE mode and lock: %d/%d", iteration + 1, getIterationCount()));
                // Test aeMode and lock
                int[] aeModes = mStaticInfo.getAeAvailableModesChecked();
                for (int mode : aeModes) {
                    aeModeAndLockTestByMode(mode);
                }
                getResultPrinter().printStatus(getIterationCount(), iteration + 1, mCameraIds[i]);
                Thread.sleep(getTestWaitIntervalMs());
            }
        } finally {
            closeDevice();
        }
    }
}
Also used : Size(android.util.Size)

Example 32 with Size

use of android.util.Size in project android_frameworks_base by ResurrectionRemix.

the class Camera2SwitchPreviewTest method updatePreviewSurfaceWithVideo.

/**
     * Update preview size with video size.
     *
     * <p>Preview size will be capped with max preview size.</p>
     *
     * @param videoSize The video size used for preview.
     * @param videoFrameRate The video frame rate
     *
     */
private void updatePreviewSurfaceWithVideo(Size videoSize, int videoFrameRate) throws Exception {
    if (mOrderedPreviewSizes == null) {
        throw new IllegalStateException("supported preview size list is not initialized yet");
    }
    final float FRAME_DURATION_TOLERANCE = 0.01f;
    long videoFrameDuration = (long) (1e9 / videoFrameRate * (1.0 + FRAME_DURATION_TOLERANCE));
    HashMap<Size, Long> minFrameDurationMap = mStaticInfo.getAvailableMinFrameDurationsForFormatChecked(ImageFormat.PRIVATE);
    Size maxPreviewSize = mOrderedPreviewSizes.get(0);
    Size previewSize = null;
    if (videoSize.getWidth() > maxPreviewSize.getWidth() || videoSize.getHeight() > maxPreviewSize.getHeight()) {
        for (Size s : mOrderedPreviewSizes) {
            Long frameDuration = minFrameDurationMap.get(s);
            if (mStaticInfo.isHardwareLevelLegacy()) {
                // Legacy doesn't report min frame duration
                frameDuration = new Long(0);
            }
            assertTrue("Cannot find minimum frame duration for private size" + s, frameDuration != null);
            if (frameDuration <= videoFrameDuration && s.getWidth() <= videoSize.getWidth() && s.getHeight() <= videoSize.getHeight()) {
                Log.w(TAG, "Overwrite preview size from " + videoSize.toString() + " to " + s.toString());
                previewSize = s;
                break;
            // If all preview size doesn't work then we fallback to video size
            }
        }
    }
    if (previewSize == null) {
        previewSize = videoSize;
    }
    updatePreviewSurface(previewSize);
}
Also used : Size(android.util.Size)

Example 33 with Size

use of android.util.Size in project android_frameworks_base by ResurrectionRemix.

the class Camera2SwitchPreviewTest method prepareRecordingWithProfile.

/**
     * Configure MediaRecorder recording session with CamcorderProfile, prepare
     * the recording surface.
     */
private void prepareRecordingWithProfile(CamcorderProfile profile) throws Exception {
    // Prepare MediaRecorder.
    mMediaRecorder.setAudioSource(MediaRecorder.AudioSource.CAMCORDER);
    mMediaRecorder.setVideoSource(MediaRecorder.VideoSource.SURFACE);
    mMediaRecorder.setProfile(profile);
    mMediaRecorder.setOutputFile(mOutMediaFileName);
    if (mPersistentSurface != null) {
        mMediaRecorder.setInputSurface(mPersistentSurface);
        mRecordingSurface = mPersistentSurface;
    }
    mMediaRecorder.prepare();
    if (mPersistentSurface == null) {
        mRecordingSurface = mMediaRecorder.getSurface();
    }
    assertNotNull("Recording surface must be non-null!", mRecordingSurface);
    mVideoFrameRate = profile.videoFrameRate;
    mVideoSize = new Size(profile.videoFrameWidth, profile.videoFrameHeight);
}
Also used : Size(android.util.Size)

Example 34 with Size

use of android.util.Size in project android_frameworks_base by ResurrectionRemix.

the class Camera2SwitchPreviewTest method prepareCapturePreview.

protected void prepareCapturePreview(CaptureRequest.Builder previewRequest, CaptureRequest.Builder stillRequest, CaptureCallback resultListener, ImageReader.OnImageAvailableListener imageListener) throws Exception {
    Size captureSz = mOrderedStillSizes.get(0);
    Size previewSz = mOrderedPreviewSizes.get(1);
    if (VERBOSE) {
        Log.v(TAG, String.format("Prepare single capture (%s) and preview (%s)", captureSz.toString(), previewSz.toString()));
    }
    // Update preview size.
    updatePreviewSurface(previewSz);
    // Create ImageReader.
    createImageReader(captureSz, ImageFormat.JPEG, MAX_READER_IMAGES, imageListener);
    // Configure output streams with preview and jpeg streams.
    List<Surface> outputSurfaces = new ArrayList<Surface>();
    outputSurfaces.add(mPreviewSurface);
    outputSurfaces.add(mReaderSurface);
    mSessionListener = new BlockingSessionCallback();
    mSession = configureCameraSession(mCamera, outputSurfaces, mSessionListener, mHandler);
    // Configure the requests.
    previewRequest.addTarget(mPreviewSurface);
    stillRequest.addTarget(mPreviewSurface);
    stillRequest.addTarget(mReaderSurface);
    // Start preview.
    mSession.setRepeatingRequest(previewRequest.build(), resultListener, mHandler);
}
Also used : BlockingSessionCallback(com.android.ex.camera2.blocking.BlockingSessionCallback) Size(android.util.Size) ArrayList(java.util.ArrayList) Surface(android.view.Surface)

Example 35 with Size

use of android.util.Size in project android_frameworks_base by ResurrectionRemix.

the class Camera2RecordingTest method updatePreviewSurfaceWithVideo.

/**
     * Update preview size with video size.
     *
     * <p>Preview size will be capped with max preview size.</p>
     *
     * @param videoSize The video size used for preview.
     * @param videoFrameRate The video frame rate
     *
     */
private void updatePreviewSurfaceWithVideo(Size videoSize, int videoFrameRate) {
    if (mOrderedPreviewSizes == null) {
        throw new IllegalStateException("supported preview size list is not initialized yet");
    }
    final float FRAME_DURATION_TOLERANCE = 0.01f;
    long videoFrameDuration = (long) (1e9 / videoFrameRate * (1.0 + FRAME_DURATION_TOLERANCE));
    HashMap<Size, Long> minFrameDurationMap = mStaticInfo.getAvailableMinFrameDurationsForFormatChecked(ImageFormat.PRIVATE);
    Size maxPreviewSize = mOrderedPreviewSizes.get(0);
    Size previewSize = null;
    if (videoSize.getWidth() > maxPreviewSize.getWidth() || videoSize.getHeight() > maxPreviewSize.getHeight()) {
        for (Size s : mOrderedPreviewSizes) {
            Long frameDuration = minFrameDurationMap.get(s);
            if (mStaticInfo.isHardwareLevelLegacy()) {
                // Legacy doesn't report min frame duration
                frameDuration = new Long(0);
            }
            assertTrue("Cannot find minimum frame duration for private size" + s, frameDuration != null);
            if (frameDuration <= videoFrameDuration && s.getWidth() <= videoSize.getWidth() && s.getHeight() <= videoSize.getHeight()) {
                Log.w(TAG, "Overwrite preview size from " + videoSize.toString() + " to " + s.toString());
                previewSize = s;
                break;
            // If all preview size doesn't work then we fallback to video size
            }
        }
    }
    if (previewSize == null) {
        previewSize = videoSize;
    }
    updatePreviewSurface(previewSize);
}
Also used : Size(android.util.Size)

Aggregations

Size (android.util.Size)320 ArrayList (java.util.ArrayList)66 StreamConfigurationMap (android.hardware.camera2.params.StreamConfigurationMap)41 Rect (android.graphics.Rect)40 CaptureRequest (android.hardware.camera2.CaptureRequest)40 Range (android.util.Range)40 Surface (android.view.Surface)35 SimpleCaptureCallback (com.android.mediaframeworktest.helpers.CameraTestUtils.SimpleCaptureCallback)35 Camera (android.hardware.Camera)30 CameraCharacteristics (android.hardware.camera2.CameraCharacteristics)26 Point (android.graphics.Point)22 Image (android.media.Image)21 SimpleImageReaderListener (com.android.mediaframeworktest.helpers.CameraTestUtils.SimpleImageReaderListener)20 MeteringRectangle (android.hardware.camera2.params.MeteringRectangle)15 CamcorderProfile (android.media.CamcorderProfile)15 Pair (android.util.Pair)15 CameraTestUtils.getDataFromImage (com.android.mediaframeworktest.helpers.CameraTestUtils.getDataFromImage)15 SurfaceTexture (android.graphics.SurfaceTexture)10 Parameters (android.hardware.Camera.Parameters)10 CaptureResult (android.hardware.camera2.CaptureResult)10