Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extracting HL2 Hand Pose Data from PSI Server and Sending to Python Over TCP #338

Open
sakibreza opened this issue Nov 30, 2024 · 1 comment

Comments

@sakibreza
Copy link

I have successfully used the PSI documentation to capture RGB frame data from the HoloLens 2 and send it to a Python server over TCP. The approach works well, where I convert the RGB frame data into bytes and transmit it.

Now, I’m attempting to do the same for hand pose data. Specifically, I am trying to extract hand joint coordinates from PSI and send them over TCP to my Python server, but I’m facing difficulty. I’m looking for an equivalent method to the following, which I used for extracting RGB frames:

imageViewer = new ImageViewer(captureServerPipeline, $"Image Viewer: {title}", false);
stream.PipeTo(imageViewer, DeliveryPolicy.LatestMessage);

var webcamBytes =
    stream
        .Sample(TimeSpan.FromMilliseconds(200))
        .EncodeJpeg(90, DeliveryPolicy.LatestMessage)
        .Select(jpg => jpg.Resource.GetBuffer());

var frameWriter = new NetMQWriter<byte[]>(
    captureServerPipeline,
    "frames",
    "tcp://127.0.0.1:30000",
    MessagePackFormat.Instance);
webcamBytes.PipeTo(frameWriter);

N.B.: To make the RGB frame capture work, I modified the code at L449 in HoloLensCaptureServer.cs , and it successfully started sending RGB frames to the server.

This works for capturing the RGB frames. However, I am unable to figure out how to extract the actual hand pose data (specifically the joint coordinates) from PSI. I’ve tried using the Microsoft.Psi.MixedReality.StereoKit.HandsSensor class, but I couldn’t find a way to access the joint coordinates.

Could you please guide me on how to extract the hand pose data from PSI, similar to how I am extracting RGB frames? Any pointers or code examples would be greatly appreciated.

Thank you!

@sandrist
Copy link
Contributor

sandrist commented Dec 3, 2024

The HoleLensCaptureApp sends hand data as a stream of tuples: (Microsoft.Psi.MixedReality.OpenXR.Hand leftHand, Microsoft.Psi.MixedReality.OpenXR.Hand rightHand) with the name "Hands", as you can see on L532. The class for this type of hand is defined here: https://github.com/microsoft/psi/blob/master/Sources/MixedReality/Microsoft.Psi.MixedReality/OpenXR/Hand.cs

You could look at CaptureTcpStream<T> on the server side, which is the generic method for capturing all streams from the HoloLens. One of those streams will have the name "Hands" and T will be (Microsoft.Psi.MixedReality.OpenXR.Hand, Microsoft.Psi.MixedReality.OpenXR.Hand)

Once you have the stream, you can do whatever you want with it. For example, if you name the stream handsStream, you could do something like:

var leftHandJointPositions = handsStream.Select(tuple => tuple.Item1.Joints.Select(coordinateSystem => coordinateSystem.Origin).ToArray());

which would give you a stream of the left hand's joint positions as an array of Point3D (x,y,z).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants