本文整理汇总了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();
}
}
示例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();
}
}
示例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()));
}
}
}
}
示例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();
}
}
示例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);
}
示例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());
}
示例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);
}
示例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];
}
}
示例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];
}
}
示例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;
}
}
示例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();
}
}
示例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;
}
示例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);
}
示例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()));
}
}
示例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;
}