简体   繁体   English

Google Cardboard VR传感器

[英]Google Cardboard VR sensors

I'm using the Google Cardboard (its HeadTracker class) to detect certain things about device rotation in an AR application. 我正在使用Google Cardboard (其HeadTracker类)来检测AR应用程序中有关设备旋转的某些事情。 It works very well. 它工作得很好。

However, on some devices, it doesn't work (nothing happens). 但是,在某些设备上,它不起作用(没有任何反应)。 I assume this is because they don't have the necessary sensors. 我认为这是因为他们没有必要的传感器。 My questions: 我的问题:

1) I want to detect at runtime whether the current device supports the HeadTracker, ie it has the necessary sensors available. 1)我想在运行时检测当前设备是否支持HeadTracker,即它是否具有必要的传感器。 For this, I need to know which sensors are used by HeadTracker, so that I can query if those sensors are present. 为此,我需要知道HeadTracker使用哪些传感器,以便我可以查询这些传感器是否存在。 What are these sensors? 这些传感器是什么?

2) Is there a way to specify the necessary sensors in AndroidManifest? 2)有没有办法在AndroidManifest中指定必要的传感器? As far as I can see, there is no way. 据我所知,没有办法。 Therefore, if a user downloads my app, the app will have to inform the user at runtime that his device is not supported. 因此,如果用户下载我的应用程序,则应用程序必须在运行时通知用户他的设备不受支持。 This is not nice. 这不好。 Any thoughts? 有什么想法吗?

Google cardboard's website has a device compatibility list : It seems somewhat incomplete, so I tried taking a look into Cardboard.jar's source code . Google cardboard的网站有一个设备兼容性列表 :它似乎有点不完整,所以我试着看看Cardboard.jar的源代码 HeadTracker.java seems to have the following logic: HeadTracker.java似乎有以下逻辑:

SensorManager sensorManager = (SensorManager)HeadTracker.this.mContext.getSystemService("sensor");

for (int sensorType : HeadTracker.INPUT_SENSORS) {
  Sensor sensor = sensorManager.getDefaultSensor(sensorType);
  sensorManager.registerListener(HeadTracker.this.mSensorEventListener, sensor, 0, handler);
}

With INPUT_SENSORS defined in the same file as 与INPUT_SENSORS定义在同一个文件中

{TYPE_ACCELEROMETER, TYPE_GYROSCOPE}; {TYPE_ACCELEROMETER,TYPE_GYROSCOPE};

I'm not sure if HeadTracker can work on phones with only one of those sensors. 我不确定HeadTracker是否可以在只有其中一个传感器的手机上工作。 My guess is that both are necessary. 我的猜测是两者都是必要的。

your app can require certain censors in order to run (or even be visible on the android market) with the following lines in your manifest: 您的应用可能需要某些审查,以便在您的清单中使用以下行运行(或甚至在Android市场上可见):

<uses-feature android:name="android.hardware.sensor.accelerometer" android:required="true" />
<uses-feature android:name="android.hardware.sensor.gyroscope" android:required="true" />

you can also check if the sensors are available to your app at runtime using SensorManager's public Sensor getDefaultSensor (int type) function. 您还可以使用SensorManager的public Sensor getDefaultSensor (int type)功能检查传感器是否在运行时可用于您的应用程序。

The google Cardboard headset won't work with just the accelerometer, it needs the gyro. 谷歌纸板耳机不适用于加速度计,它需要陀螺仪。

The accelerometer can detect forces applied to the phone. 加速度计可以检测施加到手机的力。 That includes reading the Earth's gravitational pull, so the phone can estimate where "down" is. 这包括读取地球的引力,因此手机可以估计“向下”的位置。 But the accelerometer can't tell you percisely what your orientation in 3d space is, it can only approximate that basing on the forces it read. 但加速度计无法准确地告诉您在3d空间中的方向是什么,它只能基于它所读取的力来近似。

That's far too low accuracy for VR, so that's why you need a gyroscope. 这对于VR的精度来说太低了,所以这就是你需要陀螺仪的原因。

If you are dead set on making it work on your non-gyro phone, you can write a piece of your own code approximating phone orientation basing on accelerometer data, but keep in mind it will be very far from a really satisfying VR experience. 如果您已经准备好在非陀螺仪手机上工作,您可以根据加速度计数据编写一段近似于手机方向的代码,但请记住,它与真正令人满意的VR体验相差甚远。

Use Fibrum SDK if you want your game working with no gyro phones 如果您希望您的游戏不使用陀螺仪手机,请使用Fibrum SDK

for example try 例如试试

Space X Hunter VR : 太空X猎人VR:

https://play.google.com/store/apps/details?id=com.creation3d.spacexhuntervr https://play.google.com/store/apps/details?id=com.creation3d.spacexhuntervr

VR Bowl : VR碗:

https://play.google.com/store/apps/details?id=com.creation3d.vrbowl https://play.google.com/store/apps/details?id=com.creation3d.vrbowl

and the games from Fibrum 来自Fibrum的游戏

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Google VR视图-头部跟踪 - Google VR View - Head Tracking Google VR Java和C ++? - Google VR Java and C++? 导入和运行Google Cardboard示例项目时遇到问题 - Trouble importing and running the Google Cardboard sample project 无法解析示例Google VR Project中的依赖项 - Cannot resolve dependencies in sample Google VR Project 更改活动时,Android Google Cardboard getLastHeadView返回NAN矩阵 - android google cardboard getLastHeadView returns NAN matrix when changing activity 如何将条形码条形码的Vision API与Google纸板集成在一起? - How do I integrate Vision API for barcode with google cardboard? 如何使用Google Cardboard的HeadTracker类? - How Do I Use Google Cardboard's HeadTracker Class? Android InflateException-膨胀类com.google.vr.sdk.base.GvrView时出错 - Android InflateException - Error inflating class com.google.vr.sdk.base.GvrView java.lang.NoClassDefFoundError:com.google.vr.sdk.widgets.video.nano.SphericalMetadataOuterClass $ SphericalMetadata - java.lang.NoClassDefFoundError: com.google.vr.sdk.widgets.video.nano.SphericalMetadataOuterClass$SphericalMetadata 使用VR android.view.InflateException时出现错误:二进制XML文件第44行:膨胀类com.google.vr.sdk.widgets.video.VrVideoView的错误 - I get error while using VR android.view.InflateException: Binary XML file line #44: Error inflating class com.google.vr.sdk.widgets.video.VrVideoView
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM