Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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 /
avatar image
0
Question by oliver-jones · Mar 31, 2013 at 06:44 PM · xmldatacomparegestures

Compare Between Saved Data and Live Data

Hello,

I have some coordinates saved in an XML file (x, y, z), and I want to be able to compare them to live coordinates within Unity, with a give or take (threshold) slack.

Basically, I'm teaching Unity to learn hand gestures from an accelerometer. This data is pre-saved within an XML file. Now I want to forever compare these XML coordinates against the live accelerometer data.

Now, obviously the hand gesture will never be the same as the pre saved gestures, hence why I want a 'give or take' / threshold slack.

When the XML data and the accelerometer data match up, just a simple print("Gestures Match"), would be fine.

 //The array of the loaded XML coordinates of the predefined gesture
 private var recordedX = new Array();
 private var recordedY = new Array();
 private var recordedZ = new Array();

 //Live accelerometer data being fed into Unity
 var X = 0;
 var Y = 0;
 var Z = 0;


---- Just To Be Clear ----

alt text

So in this diagram, I'm only using X and Y as an example. But as you can see, the blue and red lines are live values from the accelerometer. The red values are not consistent, so they are just ignored. Whereas the blue values, although not 'exactly' spot on with the predefined XML gesture values, are very closely inline with the threshold, and so, throws a print.

How would one achieve this? What is this structure called? Is it just a bunch of for and if statements? Or does it require some seriously complex algorithms?

Thanks!

data_xml.png (51.2 kB)
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 whydoidoit · Mar 31, 2013 at 07:22 PM

If it was like hand written gestures you'd do a lot of normalization of the sizes of each sampled movement and store the angle and proportional length between each of the sample points then you'd score the match between the incoming data and sort the gestures in order. Then pick the best and reject it if it was below some minimum good level.

By normalizing you make it the movement that's important not the size of the movement. Though clearly it's easier for the player to reproduce gestures slower and bigger.

To normalize:

  • Take a number of points sampled throughout the gesture, at constant time, to avoid bunching

  • Find the longest movement in the sample set and divide everything else by that.

  • For angles, take the angle between the vector of the previous sample and the new sample - again scale it to be 0..1

  • Then you can choose which is more important by weighting the length or the angle by some factor in your scoring - or leave them the same to have equal weighting.

Comment
Add comment · Show 8 · 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
avatar image oliver-jones · Mar 31, 2013 at 07:27 PM 0
Share

The gestures are not hand written, they are simply 'recorded' directly from Unity. I've made a GUI button that you can push, that then takes the X, Y, Z values from the accelerometer every 0.2 seconds, 10 times, and puts it into an X$$anonymous$$L file.

avatar image whydoidoit · Mar 31, 2013 at 07:30 PM 0
Share

Sorry, I do realise that they are not hand written in X$$anonymous$$L - I meant hand written like in letters written on a page or shapes drawn on a 2D surface.

avatar image whydoidoit · Mar 31, 2013 at 07:32 PM 0
Share

The need for normalization and sampling exists in 2D shapes and would presumably carry over to 3D representations (though with a lot more potential degrees of freedom).

Basically you need to normalize your sampling points by exa$$anonymous$$ing the recorded data and taking a fixed number of points from it spaced over the time the gesture took.

Then as you try to recognise you take do a similar thing but now it's hard to know when the gesture started or ended so that's an added complexity not present in recognising mouse or finger drawn shapes.

avatar image oliver-jones · Mar 31, 2013 at 07:32 PM 0
Share

Correct, the X$$anonymous$$L looks something like this:

 <Recording>
     <x>307</x>
     <y>340</y>
     <z>463</z>
 </Recording>
avatar image whydoidoit · Mar 31, 2013 at 07:34 PM 0
Share

I guess the best idea would be to look for the start of some significant movement and capture until the movement slows again. Then try to recognise- other techniques would run the risk of recognising shorter gestures when a longer gesture was still the players intention.

Show more comments

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

11 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

Related Questions

Is it bad to use csv/xml resource to read data for mobile 1 Answer

Best practice to store levels and highscores etc 2 Answers

Where will those XML files be stored if the platform of this game is Web Player...? 1 Answer

whats the best way to save a large list of variables? 1 Answer

Save player data 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