是否可以从 Android 上的 TOF(飞行时间)传感器读取数据?

Is it possible to read data from TOF (time-of-flight) sensor on Android?

最近型号的 Android 手机(Honor View 20、Huawei P30 Pro、Samsung Galaxy 10 5g)具有 TOF(飞行时间)传感器。是否可以通过某些 API 或制造商 SDK 读取它?

目前还不可能。 由于 Android 官方最新的 SDK 中没有包含任何此类 API。

此外,像华为、三星和 OnePlus 等制造商正在使用他们定制的 OS 来源,我认为他们没有开放。

我在搜索同样的东西,我在三星社区看到了这个帖子, https://developer.samsung.com/forum/board/thread/view.do?boardName=SDK&messageId=371359&listLines=40&startId=zzzzz~&searchType=ALL&searchText=tof

华为可能使用AR Engine SDK

https://developer.huawei.com/consumer/en/ar

SDK 文档摘录AREnginesdk-sample-2.0.0.6\HUAWEI AR Engine Function Manual.doc

4.13 Scene mesh
Huawei AR Engine provides real-time output scene mesh capability. The output includes the pose of the mobile phone in space. The 3D mesh of the current camera view only supports the specified Huawei models(Honor V20、P30Pro) that can obtain depth information, and the supported scanning scene is static.

SDK 文档摘录AREnginesdk-sample-2.0.0.6\java\HUAWEI AR Engine SDK Interface Manual.docx

2.2.1.18.   ARSceneMesh
•   Description: The class used to return the tracking result when the environment Mesh is tracked. The result includes the Mesh vertex coordinates, the triangle subscript, and so on.
•   Methods: 
public ShortBuffer getSceneDepth()
        // Get the depth image of current frame(optimized).
public int getSceneDepthHeight()
        // Get the height of the depth image.
public int getSceneDepthWidth()
        // Get the width of the depth image.


可能在华为使用摄像头2 API

https://github.com/google-ar/arcore-android-sdk/issues/120#issuecomment-535413944

ARCore 中的这个问题包含了很多信息!

似乎也可以在 S10 5G 上使用,但目前不能在 Note 10+ 上使用

Night Vision / ToF Viewer app description 的摘录:

This app is currently working only on Huawei P30 Pro, Honor View 20 and Samsung S10 5G. More devices will start working by future device software updates.

New features

  • compatibility for Samsung S10 5G added (and maybe for other devices)
  • resolution dialog removed
  • support for front facing removed

Note: There was done a big research for Samsung Note10+ support, however this device does not seem to support ToF for 3rd party apps.


另一个有趣的应用程序:

使用华为 ToF 传感器的 3D 扫描仪应用 https://play.google.com/store/apps/details?id=com.lvonasek.arcore3dscannerpro

Android 确实包括 OS 级别 API 以与非传统视觉相机交互。以三星S10 5G为例,你可以通过Camera2API访问摄像头,直接得到一个DEPTH16帧。这是一个示例:https://medium.com/swlh/working-with-the-3d-camera-on-the-samsung-s10-5g-4782336783c 这适用于所有三星设备,尽管该示例仅使用 S10 5G 上的前置 ToF 摄像头。 S10 和 Note 10+ 5G 也都有后置 ToF 摄像头。

我不知道华为或一加是否符合相同的API(他们理论上应该和其他答案表明他们在某种程度上这样做)。