3

I started to work with Hololens (1 gen.) and now I need to recognize, if the glasses are moving (like somebody wears them and e.g. rotates the head or goes forward) or they are staying motionless (e.g. lie on the table). Is there any tool or library for it? Or maybe any access to the sensors data?

EDIT: I took the example app from Microsoft, prebuilt it in Unity and run in VS2017. Then I found the code to get Camera position:

float quaternionX = Camera.main.transform.rotation.x;

but it always throws me System.AccessViolationException

EDIT 2:

Ok, it looks like I call Camera in wrong thread. If I put the same call inside of SpatialMappingObserver.Update()(Part of this Microsoft example), it works fine. I'm wondering, how the exceptions in VS2017 are unclear.

Alexander Tumanin
  • 1,638
  • 2
  • 23
  • 37
  • Are you using Unity? Seeing if the user moved should be as simple as checking if the Camera moved (ie look at it's transform) – Jethro Apr 05 '19 at 21:05

1 Answers1

2

As u didnt provide much information and I don't know what you are using I'm gonna share my idea how I would do it in my project. So I'm using the latest HoloToolkit(some call it just mrtk, not v1 and not v2) and Unity LTS 2017. There I have a camera in the scene, which represents the hololens, so you could just access the transform of it.

Perazim
  • 1,501
  • 3
  • 19
  • 42
  • See my EDIT, it always gives me `System.AccessViolationException` – Alexander Tumanin Apr 09 '19 at 10:24
  • U have to know that the documentation from microsoft is the biggest crap ever. Nothing from there works, its more than outdated. So dont use/read/take something from there. Classes/Functions/Structures they are talking about dont exist anymore. Are u gonna use Unity? If not, I guess you could try this code https://github.com/Microsoft/MixedRealityToolkit .If yes, use this: https://github.com/Microsoft/MixedRealityToolkit-Unity (thats what I use) – Perazim Apr 09 '19 at 10:49
  • Yes, I use `MixedRealityToolkit-Unity`. And the example app works like expected. But if I add `Camera.main.transform.rotation.x`, I get `System.AccessViolationException` – Alexander Tumanin Apr 09 '19 at 11:06