gpt4 book ai didi

Android - 纵向模式下的 Google 示例 HdrViewFinder

转载 作者:行者123 更新时间:2023-11-29 22:53:37 25 4
gpt4 key购买 nike

有人可以帮我解决以下代码吗?我想从 google 示例 ( https://github.com/googlesamples/android-HdrViewfinder ) 转换 HdrViewFinder 项目,以便它也可以在纵向模式下工作。但该项目仅适用于横向模式。在纵向模式下,相机预览会失真。

所以,这是我从 HdrViewfinderActivity.java 类中提取的方法,我认为它负责将整个 View 设置为横向:

/**
* 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);
if (configs == null) {
throw new RuntimeException("Cannot get available picture/preview sizes.");
}
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);

// Configure processing
mProcessor = new ViewfinderProcessor(mRS, outputSize);
setupProcessor();

// Configure the output view - this will fire surfaceChanged
mPreviewView.setAspectRatio(outputAspect);
mPreviewView.getHolder().setFixedSize(outputSize.getWidth(), outputSize.getHeight());
}

我怎样才能改变这个方法,让它在纵向模式下也能工作?我需要改变什么?仅将 list 文件中的 screenOrientation 属性设置为 portrait 没有帮助。我发现 16:9 用于全横向模式,而 9:16 用于全纵向模式。因此,我将 MAX_WIDTH 更改为 720 并将 TARGET_ASPECT 更改为 9.f/16.f 。但这也没有帮助。

有人可以提供解决方案吗?

这是一个小草图,显示了问题/当我将 list 文件中的 screenOrientation 属性设置为纵向模式时会发生什么: enter image description here

最佳答案

我有一个 experimental fork通过从 SurfaceView 切换到 TextureView 来实现这一点。

在装有 Android Pie

的 Sony G8441 a.k.a Xperia XZ1 Compact 上测试

关于Android - 纵向模式下的 Google 示例 HdrViewFinder,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57645797/

25 4 0
文章推荐: javascript - 通过 ajax 在模态中从