Comments (1)
After a lot of test I success to make it work! Just copy these dlls to same folder of exe file:
And, I also install "Microsoft.Windows.MixedReality.DotNetWinRT" package from nuget. Then change some code of SpatialGraphCoordinateSystem.cs so that the tracking can work in editor and standalone build:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Microsoft.Windows.Perception.Spatial;
using Microsoft.MixedReality.Toolkit.Utilities;
namespace QRTracking
{
public class SpatialGraphCoordinateSystem : MonoBehaviour
{
private SpatialCoordinateSystem CoordinateSystem = null;
private System.Guid id;
public System.Guid Id
{
get
{
return id;
}
set
{
id = value;
CoordinateSystem = Microsoft.Windows.Perception.Spatial.Preview.SpatialGraphInteropPreview.CreateCoordinateSystemForNode(id);
if (CoordinateSystem == null)
{
Debug.Log("Id= " + id + " Failed to acquire coordinate system");
}
}
}
void Awake()
{
}
// Use this for initialization
void Start()
{
if (CoordinateSystem == null)
{
CoordinateSystem = Microsoft.Windows.Perception.Spatial.Preview.SpatialGraphInteropPreview.CreateCoordinateSystemForNode(id);
if (CoordinateSystem == null)
{
Debug.Log("Id= " + id + " Failed to acquire coordinate system");
}
}
}
private void UpdateLocation()
{
{
if (CoordinateSystem == null)
{
CoordinateSystem = Microsoft.Windows.Perception.Spatial.Preview.SpatialGraphInteropPreview.CreateCoordinateSystemForNode(id);
if (CoordinateSystem == null)
{
Debug.Log("Id= " + id + " Failed to acquire coordinate system");
}
}
if (CoordinateSystem != null)
{
Quaternion rotation = Quaternion.identity;
Vector3 translation = new Vector3(0.0f, 0.0f, 0.0f);
System.IntPtr rootCoordnateSystemPtr = UnityEngine.XR.WindowsMR.WindowsMREnvironment.OriginSpatialCoordinateSystem;
if (rootCoordnateSystemPtr != System.IntPtr.Zero)
{
var rootSpatialCoordinateSystem = SpatialCoordinateSystem.FromNativePtr(rootCoordnateSystemPtr);
// Get the relative transform from the unity origin
System.Numerics.Matrix4x4? relativePose = CoordinateSystem.TryGetTransformTo(rootSpatialCoordinateSystem);
if (relativePose != null)
{
System.Numerics.Vector3 scale;
System.Numerics.Quaternion rotation1;
System.Numerics.Vector3 translation1;
System.Numerics.Matrix4x4 newMatrix = relativePose.Value;
// Platform coordinates are all right handed and unity uses left handed matrices. so we convert the matrix
// from rhs-rhs to lhs-lhs
// Convert from right to left coordinate system
newMatrix.M13 = -newMatrix.M13;
newMatrix.M23 = -newMatrix.M23;
newMatrix.M43 = -newMatrix.M43;
newMatrix.M31 = -newMatrix.M31;
newMatrix.M32 = -newMatrix.M32;
newMatrix.M34 = -newMatrix.M34;
System.Numerics.Matrix4x4.Decompose(newMatrix, out scale, out rotation1, out translation1);
translation = new Vector3(translation1.X, translation1.Y, translation1.Z);
rotation = new Quaternion(rotation1.X, rotation1.Y, rotation1.Z, rotation1.W);
Pose pose = new Pose(translation, rotation);
// If there is a parent to the camera that means we are using teleport and we should not apply the teleport
// to these objects so apply the inverse
if (CameraCache.Main.transform.parent != null)
{
pose = pose.GetTransformedBy(CameraCache.Main.transform.parent);
}
gameObject.transform.SetPositionAndRotation(pose.position, pose.rotation);
//Debug.Log("Id= " + id + " QRPose = " + pose.position.ToString("F7") + " QRRot = " + pose.rotation.ToString("F7"));
}
else
{
// Debug.Log("Id= " + id + " Unable to locate qrcode" );
}
}
}
else
{
gameObject.SetActive(false);
}
}
}
// Update is called once per frame
void Update()
{
UpdateLocation();
}
}
}
from mixedreality-qrcode-sample.
Related Issues (18)
- Prefab Missing Issue HOT 2
- QRCodeManager spawn old QRCode HOT 9
- Update to MRTK3 HOT 1
- The sample doesnt work with standalone remoting app with Hololens 2 HOT 12
- MRTK3 Sample HOT 1
- Not QR pops up HOT 7
- Scanning the two-dimensional code (qrCode.Data) of the Chinese content shows garbled characters
- Does not build to Windows IL2CPP
- I have met some problems about this project HOT 1
- QR-Codes are not recognized on digital displays
- Hello, I've encountered an issue at runtime where the editor isn't reporting any errors, but the recognition process isn't successful. Upon checking for errors, I found that QRCodeManager.isSupported() is returning false. This issue persists whether it's the Windows XR branch or the OpenXR branch. Additionally, during testing, the QR code prefab wasn't successfully added, and the script on the QR code didn't run as expected. I've checked settings like the Webcam, but haven't found any issues. Has anyone faced a similar problem, and if so, how was it resolved?
- OpenXR - Meta Quest (Android) support
- Unity .meta files missing in repo HOT 18
- Packages folder doesnt exists! HOT 3
- Crashes On Restarting The Tracking
- Cannot Build or Run due to missing references HOT 4
- Possible to get pose of QR code with Holographic Remoting? HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mixedreality-qrcode-sample.