当前位置: 首页>>代码示例>>Java>>正文


Java StreamConfigurationMap.getOutputSizes方法代码示例

本文整理汇总了Java中android.hardware.camera2.params.StreamConfigurationMap.getOutputSizes方法的典型用法代码示例。如果您正苦于以下问题:Java StreamConfigurationMap.getOutputSizes方法的具体用法?Java StreamConfigurationMap.getOutputSizes怎么用?Java StreamConfigurationMap.getOutputSizes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.hardware.camera2.params.StreamConfigurationMap的用法示例。


在下文中一共展示了StreamConfigurationMap.getOutputSizes方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: collectCameraInfo

import android.hardware.camera2.params.StreamConfigurationMap; //导入方法依赖的package包/类
/**
 * <p>Collects some information from {@link #mCameraCharacteristics}.</p>
 * <p>This rewrites {@link #mPreviewSizes}, {@link #mPictureSizes}, and optionally,
 * {@link #mAspectRatio}.</p>
 */
private void collectCameraInfo() {
    StreamConfigurationMap map = mCameraCharacteristics.get(
            CameraCharacteristics.SCALER_STREAM_CONFIGURATION_MAP);
    if (map == null) {
        throw new IllegalStateException("Failed to get configuration map: " + mCameraId);
    }
    mPreviewSizes.clear();
    for (android.util.Size size : map.getOutputSizes(mPreview.getOutputClass())) {
        mPreviewSizes.add(new Size(size.getWidth(), size.getHeight()));
    }
    mPictureSizes.clear();
    collectPictureSizes(mPictureSizes, map);

    if (!mPreviewSizes.ratios().contains(mAspectRatio)) {
        mAspectRatio = mPreviewSizes.ratios().iterator().next();
    }
}
 
开发者ID:vshkl,项目名称:PXLSRT,代码行数:23,代码来源:Camera2.java

示例2: open

import android.hardware.camera2.params.StreamConfigurationMap; //导入方法依赖的package包/类
public void open() {
    try {
        CameraManager manager = (CameraManager) mActivity.getSystemService(Context.CAMERA_SERVICE);
        for (String cameraId : manager.getCameraIdList()) {
            CameraCharacteristics characteristics = manager.getCameraCharacteristics(cameraId);
            if (characteristics.get(CameraCharacteristics.LENS_FACING) == CameraCharacteristics.LENS_FACING_BACK) {
                StreamConfigurationMap map = characteristics.get(CameraCharacteristics.SCALER_STREAM_CONFIGURATION_MAP);
                mCameraSize = map.getOutputSizes(SurfaceTexture.class)[0];

                HandlerThread thread = new HandlerThread("OpenCamera");
                thread.start();
                Handler backgroundHandler = new Handler(thread.getLooper());

                manager.openCamera(cameraId, mCameraDeviceCallback, null);

                // カメラの物理的な情報を得る
                mCameraCharacteristics = manager.getCameraCharacteristics( cameraId );
                return;
            }
        }
    } catch (CameraAccessException e) {
        e.printStackTrace();
    }
}
 
开发者ID:jphacks,项目名称:TK_1701,代码行数:25,代码来源:Camera2.java

示例3: collectRatioSizes

import android.hardware.camera2.params.StreamConfigurationMap; //导入方法依赖的package包/类
@Override
public void collectRatioSizes() {
    ratioSizeList.clear();
    CameraCharacteristics characteristics;
    StreamConfigurationMap map = null;
    try {
        characteristics = ((CameraManager) getContext().getSystemService(Context.CAMERA_SERVICE)).getCameraCharacteristics(Integer.toString(Integer.parseInt(getCameraId())));
        map = characteristics.get(CameraCharacteristics.SCALER_STREAM_CONFIGURATION_MAP);
    } catch (CameraAccessException e) {
        e.printStackTrace();
    }

    Size[] outputSizes = map.getOutputSizes(SurfaceTexture.class);
    if (outputSizes != null) {
        List<Double> ratioList = new ArrayList<>();
        for (Size size : outputSizes) {
            double ratio = (double) size.getWidth() / (double) size.getHeight();
            if (!ratioList.contains(ratio)) {
                ratioList.add(ratio);
                ratioSizeList.add(new AspectRatio(ratio, size.getWidth(), size.getHeight()));
            }
        }
    }
}
 
开发者ID:team-supercharge,项目名称:SCCameraView,代码行数:25,代码来源:Camera2View.java

示例4: getSupportedSize

import android.hardware.camera2.params.StreamConfigurationMap; //导入方法依赖的package包/类
@Override
protected List<PreviewSize> getSupportedSize() {
    try {
        CameraCharacteristics characteristics = mCameraManager.getCameraCharacteristics(
                getCurrentCameraId());
        StreamConfigurationMap map =
                characteristics.get(CameraCharacteristics.SCALER_STREAM_CONFIGURATION_MAP);
        if (map == null) {
            return Collections.singletonList(new PreviewSize(mPreviewWidth, mPreviewHeight));
        }
        Size[] supportedSize = map.getOutputSizes(SurfaceTexture.class);
        if (supportedSize == null || supportedSize.length == 0) {
            return Collections.singletonList(new PreviewSize(mPreviewWidth, mPreviewHeight));
        }
        List<PreviewSize> results = new ArrayList<>();
        for (Size size : supportedSize) {
            results.add(new PreviewSize(size.getWidth(), size.getHeight()));
        }
        return results;
    } catch (CameraAccessException e) {
        throw new CameraAccessError();
    }
}
 
开发者ID:Piasy,项目名称:CameraCompat,代码行数:24,代码来源:Camera2Helper.java

示例5: getSizes

import android.hardware.camera2.params.StreamConfigurationMap; //导入方法依赖的package包/类
private List<Size> getSizes(StreamConfigurationMap map) {
    Size[] sizes = map.getOutputSizes(MediaRecorder.class);

    // StreamConfigurationMap.getOutputSizes(MediaRecorder.class) only tells us if the
    // camera supports these sizes. It does not tell us if MediaRecorder supports these
    // sizes, odd as that sounds. Therefore, we need to filter ourselves manually.
    List<Size> filtered;
    if (CamcorderProfile.hasProfile(getCameraId(), CamcorderProfile.QUALITY_2160P)) {
        filtered = filter(sizes, SIZE_4K);
        if (!filtered.isEmpty()) {
            return filtered;
        }
    }
    if (CamcorderProfile.hasProfile(getCameraId(), CamcorderProfile.QUALITY_1080P)) {
        filtered = filter(sizes, SIZE_1080P);
        if (!filtered.isEmpty()) {
            return filtered;
        }
    }
    if (CamcorderProfile.hasProfile(getCameraId(), CamcorderProfile.QUALITY_720P)) {
        filtered = filter(sizes, SIZE_720P);
        if (!filtered.isEmpty()) {
            return filtered;
        }
    }
    if (CamcorderProfile.hasProfile(getCameraId(), CamcorderProfile.QUALITY_480P)) {
        filtered = filter(sizes, SIZE_480P);
        if (!filtered.isEmpty()) {
            return filtered;
        }
    }
    return Arrays.asList(sizes);
}
 
开发者ID:Xlythe,项目名称:CameraView,代码行数:34,代码来源:VideoSession.java

示例6: getDefaultPictureSize

import android.hardware.camera2.params.StreamConfigurationMap; //导入方法依赖的package包/类
/**
 * @return The largest supported picture size.
 */
public Size getDefaultPictureSize() {
    StreamConfigurationMap configs = mCharacteristics.get(
            CameraCharacteristics.SCALER_STREAM_CONFIGURATION_MAP);
    android.util.Size[] supportedSizes = configs.getOutputSizes(sCaptureImageFormat);

    // Find the largest supported size.
    android.util.Size largestSupportedSize = supportedSizes[0];
    long largestSupportedSizePixels = largestSupportedSize.getWidth()
            * largestSupportedSize.getHeight();
    for (int i = 0; i < supportedSizes.length; i++) {
        long numPixels = supportedSizes[i].getWidth() * supportedSizes[i].getHeight();
        if (numPixels > largestSupportedSizePixels) {
            largestSupportedSize = supportedSizes[i];
            largestSupportedSizePixels = numPixels;
        }
    }

    return new Size(largestSupportedSize.getWidth(),
            largestSupportedSize.getHeight());
}
 
开发者ID:jameliu,项目名称:Camera2,代码行数:24,代码来源:OneCameraZslImpl.java

示例7: configureSurfaces

import android.hardware.camera2.params.StreamConfigurationMap; //导入方法依赖的package包/类
/**
 * Configure the surfaceview and RS processing.
 */
private void configureSurfaces() {
    // Find a good size for output - largest 16:9 aspect ratio that's less than 720p
    final int MAX_WIDTH = 1280;
    final float TARGET_ASPECT = 16.f / 9.f;
    final float ASPECT_TOLERANCE = 0.1f;

    StreamConfigurationMap configs =
            mCameraInfo.get(CameraCharacteristics.SCALER_STREAM_CONFIGURATION_MAP);

    Size[] outputSizes = configs.getOutputSizes(SurfaceHolder.class);

    Size outputSize = outputSizes[0];
    float outputAspect = (float) outputSize.getWidth() / outputSize.getHeight();
    for (Size candidateSize : outputSizes) {
        if (candidateSize.getWidth() > MAX_WIDTH)
            continue;
        float candidateAspect = (float) candidateSize.getWidth() / candidateSize.getHeight();
        boolean goodCandidateAspect =
                Math.abs(candidateAspect - TARGET_ASPECT) < ASPECT_TOLERANCE;
        boolean goodOutputAspect = Math.abs(outputAspect - TARGET_ASPECT) < ASPECT_TOLERANCE;
        if ((goodCandidateAspect && !goodOutputAspect) ||
                candidateSize.getWidth() > outputSize.getWidth()) {
            outputSize = candidateSize;
            outputAspect = candidateAspect;
        }
    }
    Log.i(TAG, "Resolution chosen: " + outputSize);

    setupProcessing(outputSize);

    // this will trigger onSurfaceChanged()
    getViewfinderSurfaceView().getHolder()
            .setFixedSize(outputSize.getWidth(), outputSize.getHeight());
    getViewfinderSurfaceView().setAspectRatio(outputAspect);
}
 
开发者ID:lydia-schiff,项目名称:hella-renderscript,代码行数:39,代码来源:BaseViewfinderActivity.java

示例8: getCameraResolutionsBack

import android.hardware.camera2.params.StreamConfigurationMap; //导入方法依赖的package包/类
public Size[] getCameraResolutionsBack() {
  try {
    CameraCharacteristics cameraCharacteristics = cameraManager.getCameraCharacteristics("0");
    if (cameraCharacteristics.get(CameraCharacteristics.LENS_FACING)
        != CameraCharacteristics.LENS_FACING_BACK) {
      cameraCharacteristics = cameraManager.getCameraCharacteristics("1");
    }
    StreamConfigurationMap streamConfigurationMap =
        cameraCharacteristics.get(CameraCharacteristics.SCALER_STREAM_CONFIGURATION_MAP);
    return streamConfigurationMap.getOutputSizes(SurfaceTexture.class);
  } catch (CameraAccessException e) {
    Log.e(TAG, e.getMessage());
    return new Size[0];
  }
}
 
开发者ID:pedroSG94,项目名称:rtmp-rtsp-stream-client-java,代码行数:16,代码来源:Camera2ApiManager.java

示例9: getCameraResolutionsFront

import android.hardware.camera2.params.StreamConfigurationMap; //导入方法依赖的package包/类
public Size[] getCameraResolutionsFront() {
  try {
    CameraCharacteristics cameraCharacteristics = cameraManager.getCameraCharacteristics("0");
    if (cameraCharacteristics.get(CameraCharacteristics.LENS_FACING)
        != CameraCharacteristics.LENS_FACING_FRONT) {
      cameraCharacteristics = cameraManager.getCameraCharacteristics("1");
    }
    StreamConfigurationMap streamConfigurationMap =
        cameraCharacteristics.get(CameraCharacteristics.SCALER_STREAM_CONFIGURATION_MAP);
    return streamConfigurationMap.getOutputSizes(SurfaceTexture.class);
  } catch (CameraAccessException e) {
    Log.e(TAG, e.getMessage());
    return new Size[0];
  }
}
 
开发者ID:pedroSG94,项目名称:rtmp-rtsp-stream-client-java,代码行数:16,代码来源:Camera2ApiManager.java

示例10: getSupportedSizes

import android.hardware.camera2.params.StreamConfigurationMap; //导入方法依赖的package包/类
static List<Size> getSupportedSizes(CameraCharacteristics cameraCharacteristics) {
  final StreamConfigurationMap streamMap =
      cameraCharacteristics.get(CameraCharacteristics.SCALER_STREAM_CONFIGURATION_MAP);
  final int supportLevel =
      cameraCharacteristics.get(CameraCharacteristics.INFO_SUPPORTED_HARDWARE_LEVEL);

  final android.util.Size[] nativeSizes = streamMap.getOutputSizes(SurfaceTexture.class);
  final List<Size> sizes = convertSizes(nativeSizes);

  // Video may be stretched pre LMR1 on legacy implementations.
  // Filter out formats that have different aspect ratio than the sensor array.
  if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP_MR1
      && supportLevel == CameraCharacteristics.INFO_SUPPORTED_HARDWARE_LEVEL_LEGACY) {
    final Rect activeArraySize =
        cameraCharacteristics.get(CameraCharacteristics.SENSOR_INFO_ACTIVE_ARRAY_SIZE);
    final ArrayList<Size> filteredSizes = new ArrayList<Size>();

    for (Size size : sizes) {
      if (activeArraySize.width() * size.height == activeArraySize.height() * size.width) {
        filteredSizes.add(size);
      }
    }

    return filteredSizes;
  } else {
    return sizes;
  }
}
 
开发者ID:Piasy,项目名称:AppRTC-Android,代码行数:29,代码来源:Camera2Enumerator.java

示例11: collectCameraInfo

import android.hardware.camera2.params.StreamConfigurationMap; //导入方法依赖的package包/类
/**
 * <p>Collects some information from {@link #mCameraCharacteristics}.</p>
 * <p>This rewrites {@link #mPreviewSizes}, {@link #mPictureSizes}, and optionally,
 * {@link #mAspectRatio}.</p>
 */
private void collectCameraInfo() {
    StreamConfigurationMap map = mCameraCharacteristics.get(
            CameraCharacteristics.SCALER_STREAM_CONFIGURATION_MAP);
    if (map == null) {
        throw new IllegalStateException("Failed to get configuration map: " + mCameraId);
    }
    mPreviewSizes.clear();
    for (android.util.Size size : map.getOutputSizes(mPreview.getOutputClass())) {
        int width = size.getWidth();
        int height = size.getHeight();
        if (width <= MAX_PREVIEW_WIDTH && height <= MAX_PREVIEW_HEIGHT) {
            mPreviewSizes.add(new Size(width, height));
        }
    }
    mPictureSizes.clear();
    collectPictureSizes(mPictureSizes, map);
    for (AspectRatio ratio : mPreviewSizes.ratios()) {
        if (!mPictureSizes.ratios().contains(ratio)) {
            mPreviewSizes.remove(ratio);
        }
    }

    if (!mPreviewSizes.ratios().contains(mAspectRatio)) {
        mAspectRatio = mPreviewSizes.ratios().iterator().next();
    }
}
 
开发者ID:wajahatkarim3,项目名称:LongImageCamera,代码行数:32,代码来源:Camera2.java

示例12: start

import android.hardware.camera2.params.StreamConfigurationMap; //导入方法依赖的package包/类
@Override
public boolean start() {
    if (!super.start()) {
        return false;
    }
    deviceOrientationListener.enable();
    cameraManager = (CameraManager) activity.get().getSystemService(Context.CAMERA_SERVICE);
    // choose camera id by lens
    if (!chooseCameraIdByLensFacing()) {
        return false;
    }
    // collect preview and picture sizes based on the query aspect ratio
    StreamConfigurationMap info = cameraCharacteristics.get(CameraCharacteristics.SCALER_STREAM_CONFIGURATION_MAP);
    if (info == null) {
        throw new IllegalStateException("Failed to get configuration map: " + cameraId);
    }
    android.util.Size[] sizes = info.getOutputSizes(viewFinderPreview.gePreviewType());
    AspectRatio desiredAspectRatio = AspectRatio.of(aspectRatio.getWidth(), aspectRatio.getHeight());
    List<Size> availableSizes = convertSizes(sizes);
    previewImageSize = chooseOptimalSize(availableSizes);
    cameraStatusCallback.onAspectRatioAvailable(desiredAspectRatio, aspectRatio, availableSizes);
    sizes = info.getOutputSizes(ImageFormat.JPEG);
    capturedPictureSize = chooseOptimalSize(convertSizes(sizes));
    // prepare image reader
    prepareImageReader(capturedPictureSize);
    // open the camera and relayout the surface based on the chosen size
    startOpeningCamera();
    return true;
}
 
开发者ID:spinaki,项目名称:android-camera,代码行数:30,代码来源:Camera2.java

示例13: getSizes

import android.hardware.camera2.params.StreamConfigurationMap; //导入方法依赖的package包/类
private List<Size> getSizes(StreamConfigurationMap map) {
    Size[] sizes = map.getOutputSizes(getImageFormat(getQuality()));

    // Special case for high resolution images (assuming, of course, quality was set to high)
    if (Build.VERSION.SDK_INT >= 23) {
        Size[] highResSizes = map.getHighResolutionOutputSizes(getImageFormat(getQuality()));
        if (highResSizes != null) {
            sizes = concat(sizes, highResSizes);
        }
    }

    return Arrays.asList(sizes);
}
 
开发者ID:Xlythe,项目名称:CameraView,代码行数:14,代码来源:PictureSession.java

示例14: collectPictureSizes

import android.hardware.camera2.params.StreamConfigurationMap; //导入方法依赖的package包/类
protected void collectPictureSizes(SizeMap sizes, StreamConfigurationMap map) {
    for (android.util.Size size : map.getOutputSizes(ImageFormat.JPEG)) {
        mPictureSizes.add(new Size(size.getWidth(), size.getHeight()));
    }
}
 
开发者ID:vshkl,项目名称:PXLSRT,代码行数:6,代码来源:Camera2.java

示例15: CreateFromCameraCharacteristics

import android.hardware.camera2.params.StreamConfigurationMap; //导入方法依赖的package包/类
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
public static MyCameraInfo CreateFromCameraCharacteristics(String cameraId,
                                                           CameraCharacteristics characteristics) {
    StreamConfigurationMap configMap =
            characteristics.get(CameraCharacteristics.SCALER_STREAM_CONFIGURATION_MAP);
    Size[] outputSizes = configMap.getOutputSizes(ImageFormat.JPEG);
    List<int[]> outputResolutions = new ArrayList<>();
    for (Size outputSize : outputSizes) {
        outputResolutions.add(new int[]{outputSize.getWidth(), outputSize.getHeight()});
    }

    MyCameraInfo cameraInfo = new MyCameraInfo(cameraId, outputResolutions);

    // supported functionality depends on the supported hardware level
    switch (characteristics.get(CameraCharacteristics.INFO_SUPPORTED_HARDWARE_LEVEL)) {
        case CameraCharacteristics.INFO_SUPPORTED_HARDWARE_LEVEL_3:

        case CameraCharacteristics.INFO_SUPPORTED_HARDWARE_LEVEL_FULL:
        case CameraCharacteristics.INFO_SUPPORTED_HARDWARE_LEVEL_LIMITED:
            cameraInfo.setAutofocusSupport(true);
        case CameraCharacteristics.INFO_SUPPORTED_HARDWARE_LEVEL_LEGACY:
            // only supports camera 1 api features
            break;
    }

    int[] ints = characteristics.get(CameraCharacteristics.CONTROL_AE_AVAILABLE_MODES);

    if (characteristics.get(CameraCharacteristics.FLASH_INFO_AVAILABLE))
        cameraInfo.setFlashlightSupport(true);

    Integer lensFacing = characteristics.get(CameraCharacteristics.LENS_FACING);
    if (lensFacing != null) {
        if (lensFacing == CameraCharacteristics.LENS_FACING_BACK)
            cameraInfo.setLensFacing(LensFacing.BACK);
        else if (lensFacing == CameraCharacteristics.LENS_FACING_FRONT)
            cameraInfo.setLensFacing(LensFacing.FRONT);
        else if (lensFacing == CameraCharacteristics.LENS_FACING_EXTERNAL)
            cameraInfo.setLensFacing(LensFacing.EXTERNAL);
    }

    /*
    jpeg is always supported
    boolean isSupported = configMap.isOutputSupportedFor(0x100);
    */


    //TODO add more info

    return cameraInfo;
}
 
开发者ID:tranquvis,项目名称:SimpleSmsRemote,代码行数:51,代码来源:CameraUtils.java


注:本文中的android.hardware.camera2.params.StreamConfigurationMap.getOutputSizes方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。