2024年10月25日 第25讲 获取Physical Camera数据流 极客笔记
本讲是Android Camera专题系列的第25讲,我们介绍Android Camera2 API专题的获取Physical Camera数据流。
更多资源:
资源 | 描述 |
---|---|
在线课程 | 极客笔记在线课程 |
知识星球 | 星球名称:深入浅出Android Camera 星球ID: 17296815 |
极客笔记圈 |
mIsLogicalMultiCamera = mStaticMetadata.isCapabilitySupported(
CameraCharacteristics.REQUEST_AVAILABLE_CAPABILITIES_LOGICAL_MULTI_CAMERA);
Set<String> physicalCameraIds = manager.getCameraCharacteristics(cameraIdS).getPhysicalCameraIds();
private void setupPhysicalCameraStreamImageReader() {
if (mEnableCapturePhysicalStream) {
mPhysical0ImageReader = ImageReader.newInstance(mPhysical0JpegSize.getWidth(),
mPhysical0JpegSize.getHeight(), ImageFormat.JPEG, 2);
mPhysical0ImageReader.setOnImageAvailableListener(
new OnImageAvailableListener(), mCameraBackgroundHandler);
mPhysical1ImageReader = ImageReader.newInstance(mPhysical1JpegSize.getWidth(),
mPhysical1JpegSize.getHeight(), ImageFormat.JPEG, 2);
mPhysical1ImageReader.setOnImageAvailableListener(
new OnImageAvailableListener(), mCameraBackgroundHandler);
}
}
if (mEnableCapturePhysicalStream) {
OutputConfiguration physical0OutputConfiguration = new OutputConfiguration(mPhysical0ImageReader.getSurface());
physical0OutputConfiguration.setPhysicalCameraId(mPhysicalCameraIds[0]);
outputConfigurations.add(physical0OutputConfiguration);
OutputConfiguration physical1OutputConfiguration = new OutputConfiguration(mPhysical1ImageReader.getSurface());
physical1OutputConfiguration.setPhysicalCameraId(mPhysicalCameraIds[1]);
outputConfigurations.add(physical1OutputConfiguration);
mSessionConfiguration = new SessionConfiguration(
is_video_high_speed ?
SessionConfiguration.SESSION_HIGH_SPEED : SessionConfiguration.SESSION_REGULAR,
outputConfigurations,
new CameraTestUtils.HandlerExecutor(mCameraBackgroundHandler),
myStateCallback
);
if (inputConfiguration != null) {
mSessionConfiguration.setInputConfiguration(inputConfiguration);
}
mSessionConfiguration.setSessionParameters(mPreviewBuilder.build());
if (!mCameraDevice.isSessionConfigurationSupported(mSessionConfiguration)) {
outputConfigurations.remove(physical0OutputConfiguration);
outputConfigurations.remove(physical1OutputConfiguration);
Log.i(TAG, "Physical_Camera session configuration not supported!");
mEnableCapturePhysicalStream = false;
}
}
Map<String, CaptureResult> physicalCameraResults = result.getPhysicalCameraResults();
if (mEnableCapturePhysicalStream &&
physicalCameraResults.get(mPhysicalCameraIds[0]) != null &&
physicalCameraResults.get(mPhysicalCameraIds[1]) != null) {
Log.i(TAG, "Physical_Camera" + mPhysicalCameraIds[0] + "'s result timestamp:" +
physicalCameraResults.get(mPhysicalCameraIds[0]).get(CaptureResult.SENSOR_TIMESTAMP));
Log.i(TAG, "Physical_Camera" + mPhysicalCameraIds[1] + "'s result timestamp:" +
physicalCameraResults.get(mPhysicalCameraIds[1]).get(CaptureResult.SENSOR_TIMESTAMP));
}
本文链接:http://so.lmcjl.com/news/16202/