- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我在专为 Google Pixel 3 XL 设计的相机应用程序中使用了 camera2 api。该设备有两个前置摄像头(广角和普通)。由于多摄像头功能,我可以同时访问两个物理摄像头设备,并且我的应用程序具有在这两个摄像头之间切换的功能。在我最近升级到 Android 10 之前,我可以准确地看到两个不同的结果,但现在我的广角捕捉帧具有与普通相机几乎相同的 FOV(视野)。因此,Android 9 广角捕获结果中的相同代码、相同 apk 与预期一样宽,并且在 Andoird 10 升级后 - 广角和普通相机显示几乎相同的 FOV。
这是一个代码 fragment ,用于演示我如何初始化相机和捕获预览:
MainActivity.kt
private val surfaceReadyCallback = object: SurfaceHolder.Callback {
override fun surfaceChanged(p0: SurfaceHolder?, p1: Int, p2: Int, p3: Int) { }
override fun surfaceDestroyed(p0: SurfaceHolder?) { }
override fun surfaceCreated(p0: SurfaceHolder?) {
// Get the two output targets from the activity / fragment
val surface1 = surfaceView1.holder.surface
val surface2 = surfaceView2.holder.surface
val dualCamera = findShortLongCameraPair(cameraManager)!!
val outputTargets = DualCameraOutputs(
null, mutableListOf(surface1), mutableListOf(surface2))
//Open the logical camera, configure the outputs and create a session
createDualCameraSession(cameraManager, dualCamera, targets = outputTargets) { session ->
val requestTemplate = CameraDevice.TEMPLATE_PREVIEW
val captureRequest = session.device.createCaptureRequest(requestTemplate).apply {
arrayOf(surface1, surface2).forEach { addTarget(it) }
}.build()
session.setRepeatingRequest(captureRequest, null, null)
}
}
}
fun openDualCamera(cameraManager: CameraManager,
dualCamera: DualCamera,
executor: Executor = SERIAL_EXECUTOR,
callback: (CameraDevice) -> Unit) {
cameraManager.openCamera(
dualCamera.logicalId, executor, object : CameraDevice.StateCallback() {
override fun onOpened(device: CameraDevice) { callback(device) }
override fun onError(device: CameraDevice, error: Int) = onDisconnected(device)
override fun onDisconnected(device: CameraDevice) = device.close()
})
}
fun createDualCameraSession(cameraManager: CameraManager,
dualCamera: DualCamera,
targets: DualCameraOutputs,
executor: Executor = SERIAL_EXECUTOR,
callback: (CameraCaptureSession) -> Unit) {
// Create 3 sets of output configurations: one for the logical camera, and
// one for each of the physical cameras.
val outputConfigsLogical = targets.first?.map { OutputConfiguration(it) }
val outputConfigsPhysical1 = targets.second?.map {
OutputConfiguration(it).apply { setPhysicalCameraId(dualCamera.physicalId1) } }
val outputConfigsPhysical2 = targets.third?.map {
OutputConfiguration(it).apply { setPhysicalCameraId(dualCamera.physicalId2) } }
val outputConfigsAll = arrayOf(
outputConfigsLogical, outputConfigsPhysical1, outputConfigsPhysical2)
.filterNotNull().flatten()
val sessionConfiguration = SessionConfiguration(SessionConfiguration.SESSION_REGULAR,
outputConfigsAll, executor, object : CameraCaptureSession.StateCallback() {
override fun onConfigured(session: CameraCaptureSession) = callback(session)
override fun onConfigureFailed(session: CameraCaptureSession) = session.device.close()
})
openDualCamera(cameraManager, dualCamera, executor = executor) {
it.createCaptureSession(sessionConfiguration)
}
}
data class DualCamera(val logicalId: String, val physicalId1: String, val physicalId2: String)
fun findDualCameras(manager: CameraManager, facing: Int? = null): Array<DualCamera> {
val dualCameras = ArrayList<DualCamera>()
manager.cameraIdList.map {
Pair(manager.getCameraCharacteristics(it), it)
}.filter {
facing == null || it.first.get(CameraCharacteristics.LENS_FACING) == facing
}.filter {
it.first.get(CameraCharacteristics.REQUEST_AVAILABLE_CAPABILITIES)!!.contains(
CameraCharacteristics.REQUEST_AVAILABLE_CAPABILITIES_LOGICAL_MULTI_CAMERA)
}.forEach {
val physicalCameras = it.first.physicalCameraIds.toTypedArray()
for (idx1 in 0 until physicalCameras.size) {
for (idx2 in (idx1 + 1) until physicalCameras.size) {
dualCameras.add(DualCamera(
it.second, physicalCameras[idx1], physicalCameras[idx2]))
}
}
}
return dualCameras.toTypedArray()
}
fun findShortLongCameraPair(manager: CameraManager, facing: Int? = null): DualCamera? {
return findDualCameras(manager, facing).map {
val characteristics1 = manager.getCameraCharacteristics(it.physicalId1)
val characteristics2 = manager.getCameraCharacteristics(it.physicalId2)
val focalLengths1 = characteristics1.get(
CameraCharacteristics.LENS_INFO_AVAILABLE_FOCAL_LENGTHS) ?: floatArrayOf(0F)
val focalLengths2 = characteristics2.get(
CameraCharacteristics.LENS_INFO_AVAILABLE_FOCAL_LENGTHS) ?: floatArrayOf(0F)
val focalLengthsDiff1 = focalLengths2.max()!! - focalLengths1.min()!!
val focalLengthsDiff2 = focalLengths1.max()!! - focalLengths2.min()!!
if (focalLengthsDiff1 < focalLengthsDiff2) {
Pair(DualCamera(it.logicalId, it.physicalId1, it.physicalId2), focalLengthsDiff1)
} else {
Pair(DualCamera(it.logicalId, it.physicalId2, it.physicalId1), focalLengthsDiff2)
}
// Return only the pair with the largest difference, or null if no pairs are found
}.sortedBy { it.second }.reversed().lastOrNull()?.first
}
最佳答案
我的理解:
我在我的 Pixel 3 上遇到了同样的问题。似乎广角相机的帧在组合之前已在 HAL 层中裁剪。实际上,FOV 并不完全相同,因为左右相机之间存在一些差异。但是,广角相机的默认缩放级别似乎会根据焦距而变化。
但我找不到任何关于它的官方文档。在 Android 10 中,它声称改进了物理相机的融合:
https://developer.android.com/about/versions/10/features#multi-camera
解决方案:
如果您希望从广角前置摄像头访问原始数据,您可以为两个物理摄像头创建 2 个摄像头 session ,而不是为逻辑摄像头创建一个 session 。
更新:
您可以使用 setPhysicalCameraKey 重置缩放级别
https://developer.android.com/reference/android/hardware/camera2/CaptureRequest.Builder#setPhysicalCameraKey(android.hardware.camera2.CaptureRequest.Key%3CT%3E,%20T,%20java.lang.String)
关于Android 10(api 29)camera2 api回归与广角相机,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59806590/
[在此处输入图像描述][1]我正在努力弄清楚回归是否是我需要走的路线,以便解决我当前使用 Python 的挑战。这是我的场景: 我有一个 195 行 x 25 列的 Pandas Dataframe
我想训练回归模型(不是分类),其输出是连续数字。 假设我有输入变量 X,其范围在 -70 到 70 之间。我有输出变量 Y,其范围在 -5 到 5 之间。X 有 39 个特征,Y 有 16 个特征,每
我想使用神经网络逼近 sinc 函数。这是我的代码: import tensorflow as tf from keras.layers import Dense from keras.models
我对 postgres 表做了一些更改,我想将其恢复到以前的状态。没有数据库的备份。有办法吗?比如,postgres 会自动拍摄快照并将其存储在某个地方,还是原始数据会永远丢失? 最佳答案 默认情况下
我有大约 100 个 7x7 因变量矩阵(所以有 49 个因变量)。我的自变量是时间。我正在做一个物理项目,我应该通过求解 ODE 得到一个矩阵函数(矩阵的每个元素都是时间的函数)。我使用了 nump
我之前曾被告知——出于完全合理的原因——当结果变量为二元变量时(即是/否、真/假、赢/输等),不应运行 OLS 回归。但是,我经常阅读经济学/其他社会科学方面的论文,其中研究人员对二元变量运行 OLS
您好,我正在使用生命线包进行 Cox 回归。我想检查非二元分类变量的影响。有内置的方法吗?或者我应该将每个类别因子转换为一个数字?或者,在生命线中使用 kmf fitter,是否可以对每个因素执行此操
作为后续 this question ,我拟合了具有定量和定性解释变量之间相互作用的多元 Logistic 回归。 MWE如下: Type |z|) (Intercept) -0.65518
我想在单个动物园对象中的多对数据系列上使用 lm 执行滚动回归。 虽然我能够通过以下代码对动物园对象中的一对数据系列执行滚动回归: FunLm seat time(seat) seat fm
是否有一种简单的方法可以在 R 中拟合多元回归,其中因变量根据 Skellam distribution 分布? (两个泊松分布计数之间的差异)?比如: myskellam <- glm(A ~ B
包含各种特征和回归目标(称为 qval)的数据集用于训练 XGBoost 回归器。该值 qval 介于 0 和 1 之间,应具有以下分布: 到目前为止,还不错。但是,当我使用 xgb.save_mod
这有效: felm(y ~ x1 + x2 | fe1 + fe2 | 0 | , data = data) 我想要: fixedeffects = "fe1 + fe2" felm(y ~ x1
这有效: felm(y ~ x1 + x2 | fe1 + fe2 | 0 | , data = data) 我想要: fixedeffects = "fe1 + fe2" felm(y ~ x1
关闭。这个问题不符合Stack Overflow guidelines .它目前不接受答案。 我们不允许提问寻求书籍、工具、软件库等的推荐。您可以编辑问题,以便用事实和引用来回答。 关闭 7 年前。
我刚刚开始使用 R 进行统计分析,而且我还在学习。我在 R 中创建循环时遇到问题。我有以下案例,我想知道是否有人可以帮助我。对我来说,这似乎是不可能的,但对你们中的一些人来说,这只是小菜一碟。我有不同
是否可以在 sklearn 中使用或不使用(即仅使用截距)预测器来运行回归(例如逻辑回归)?这似乎是一个相当标准的类型分析,也许这些信息已经在输出中可用。 我发现的唯一相关的东西是sklearn.sv
假设我对一些倾斜的数据分布执行 DNN 回归任务。现在我使用平均绝对误差作为损失函数。 机器学习中的所有典型方法都是最小化平均损失,但对于倾斜来说这是不恰当的。从实际角度来看,最好尽量减少中值损失。我
我正在对公寓特征进行线性回归分析,然后预测公寓的价格。目前,我已经收集了我所在城市 13000 套公寓的特征。我有 23-25 个特征,我不确定在公寓价格预测中拥有如此多的特征是否正常。 我有以下功能
我是 ML 新手,对 catboost 有疑问。所以,我想预测函数值(例如 cos | sin 等)。我回顾了一切,但我的预测始终是直线 是否可能,如果可能,我该如何解决我的问题 我很高兴收到任何评论
我目前已经为二进制类实现了概率(至少我这么认为)。现在我想扩展这种回归方法,并尝试将其用于波士顿数据集。不幸的是,我的算法似乎被卡住了,我当前运行的代码如下所示: from sklearn impor
我是一名优秀的程序员,十分优秀!