Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
  • Help Room /
avatar image
0
Question by char1997 · Feb 05, 2018 at 08:18 PM · arrayjsondatakinect

How to reliably send Kinect v2 data over MQTT?

I am trying to send Microsoft's Kinect v2 body data over MQTT to effectively map skeletal data without direct connection to the Kinect, but I can't seem to deserialize a Body[] correctly. Essentially, the Kinect is connected to Computer A and processes the data and publishes it over MQTT, where Computer B listens and retrieves the data, then maps joints to its screen. I am just having trouble sending the Body[] over MQTT. I am publishing the Body[] every frame in Update().

My current setup is using Newtonsoft's JSON.Net to serialize a List taken from Body[] and publish it to MQTT (using https://github.com/vovacooper/Unity3d_MQTT). I used this since the Body class isn't serializable (so I can't use JSONUtility?). My current set up:

Computer A

 void Update() {
     ...
     //trackedBodies is a List<Body> that contains the tracked Bodys
     //client is MQTTClient that is connected
     string bodyData = JsonConvert.SerializeObject(trackedBodies);
     client.Publish("test", System.Text.Encoding.UTF8.GetBytes(bodyData));
     ...
 }


Computer B

 void client_MqttMsgPublishReceived(object sender, MqttMsgPublishEventArgs e) {
         //Check MQTT for data, then deserialize
        List<Body> bodyData = JsonConvert.DeserializeObject<List<Body>>(System.Text.Encoding.UTF8.GetString(e.Message));
         Debug.Log(bodyData);
 }

When there are no bodies being tracked, I get an empty Body[].

 System.Collections.Generic.List`1[Windows.Kinect.Body]

When there are bodies being tracked, MQTT seems to halt and stop working on the JsonConvert.DeserializeObject() line. I am not getting errors, and Update() is still being called.

My limitations are that I need to use Unity and MQTT.

I know that was a lot but I would appreciate it if anybody knows how to help with what I currently have, or suggest a better alternative to my problem.

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by char1997 · Feb 16, 2018 at 01:14 AM

I see that some people also may have the same question. I have finally gotten a working solution for myself. I personally just exposed the Body object by creating a custom 'pseudo' class to represent the body and hold the Joint and JointOrientation arrays. I was able to send a list of these custom objects through MQTT by serializing them with Json.NET

Cheers.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

138 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Deserialize JSON data for android via WWW (JsonUtility / JsonFX) 2 Answers

save one big json string vs multi seperate json strings in playerprefs 0 Answers

Getting array from Json suddenly doesnt work. 1 Answer

JSON weird deserialization 1 Answer

Can JSON contain any object except text/number ? 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges