Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
2 captures
12 Jun 22 - 14 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 Bshow · Nov 27, 2015 at 10:23 AM · unity 5crashkinectstreamingassetsgesture

Problems with VisualGestureBuilderFrameSource when adding a gesture

Hi Everyone,

I am working on a project where i have to detect custom gestures from a gesture database made with the Visual Gesture Builder.The code is the following :

 using UnityEngine;
 using System.Collections;
 using System.Collections.Generic;
 using Windows.Kinect;
 using Microsoft.Kinect.VisualGestureBuilder;
 using System.Linq;
 
 public class GestureManager : MonoBehaviour
 {
     Gesture walkInPlace;
     public string databaseName = "OVRGestures.gbd";
     public BodySourceManager bodyManager;
     VisualGestureBuilderDatabase db;
     VisualGestureBuilderFrameSource gestureSource;
     VisualGestureBuilderFrameReader gestureReader;
     KinectSensor sensor= null;
 
     void Start()
     {
         sensor = KinectSensor.GetDefault();
         if (sensor != null)
         {
             
             if (!sensor.IsOpen)
             {
                 Debug.Log("is OPEN");
                 sensor.Open();
             }
         }
         gestureSource = VisualGestureBuilderFrameSource.Create(sensor, 0);
         gestureReader = gestureSource.OpenReader();
         if (gestureReader != null)
         {
             gestureReader.IsPaused = true;
             gestureReader.FrameArrived += GestureFrameArrived;
             Debug.Log("IS PAUSED");
         }
         bodyManager = this.gameObject.GetComponent<BodySourceManager>();
         string path = System.IO.Path.Combine(Application.streamingAssetsPath,databaseName);
         db = VisualGestureBuilderDatabase.Create(path);
         Debug.Log("1");
         walkInPlace = db.AvailableGestures[0];
         Debug.Log("2");
         
         
         gestureSource.AddGesture(walkInPlace);
         Debug.Log("3");
 
     }
 
     // Update Loop, set body if we need one
     void Update()
     {
         if (!gestureSource.IsTrackingIdValid)
         {
             FindValidBody();
         }
     }
     // Check Body Manager, grab first valid body
     void FindValidBody()
     {
 
         if (bodyManager != null)
         {
             Body[] bodies = bodyManager.GetData();
             if (bodies != null)
             {
                 foreach (Body body in bodies)
                 {
                     if (body.IsTracked)
                     {
                         SetBody(body.TrackingId);
                         break;
                     }
                 }
             }
         }
 
     }
 
     // Public setter for Body ID to track
     public void SetBody(ulong id)
     {
         if (id > 0)
         {
             gestureSource.TrackingId = id;
             gestureReader.IsPaused = false;
         }
         else
         {
             gestureSource.TrackingId = 0;
             gestureReader.IsPaused = true;
         }
     }
 
     void GestureFrameArrived(object sender, VisualGestureBuilderFrameArrivedEventArgs e)
     {
         using (var frame = e.FrameReference.AcquireFrame())
         {
             if (frame != null)
             {
                 var discreteResults = frame.DiscreteGestureResults;
                 Debug.Log("FRAME ARRIVED");
 
                 if ((discreteResults != null) &&
                   (discreteResults.ContainsKey(this.walkInPlace)))
                 {
                     var result = discreteResults[this.walkInPlace];
                     if (result.Detected == true)
                     {
                         Debug.Log("working");
                     }
 
 
                 }
             }
 
         }
     }
 
     
 }

The line that creates problems is this one:

 gestureSource.AddGesture(walkInPlace);

after that unity crashes miserably without even showing an error.

I tried to fix it in several kind of ways. One of those is to replace that line with:

 Gesture[] gestures = db.AvailableGestures.ToArray<Gesture>();
 gestureSource.AddGestures(gestures);

With the method AddGestures it doesn't crash but give me this erro on the unity console:

 ArgumentException: Value does not fall within the expected range.
 Rethrow as ArgumentException: This API has returned an exception from an HRESULT: 0x80070057
 Helper.ExceptionHelper.CheckLastError () (at Assets/Standard Assets/ExceptionHelper.cs:39)
 Microsoft.Kinect.VisualGestureBuilder.VisualGestureBuilderFrameSource.AddGestures (Microsoft.Kinect.VisualGestureBuilder.Gesture[] gestures) (at Assets/Standard Assets/Microsoft/Kinect/VisualGestureBuilder/VisualGestureBuilderFrameSource.cs:351)
 GestureManager.Start () (at Assets/KinectView/Scripts/GestureManager.cs:46)
 

If someone knows a way to fix this I would be very thankful.

Thank you in advance

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

2 Replies

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

Answer by Bshow · Nov 27, 2015 at 03:16 PM

The problem solved itself.

I deleted the old progect and started a new one reimporting all the unity assets. I imported the Kinect.VisualGestureBuilder asset before the Kinect asset.

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
avatar image
1

Answer by sebtoun · May 25, 2016 at 09:53 AM

I fixed the problem of having the exception thrown (ArgumentException: Value does not fall within the expected range.) when AddGestures was called by not calling property accessor AvailableGestures more than one time. I instead cached the result and reused it. It may be related with Helper.NativeObjectCache I did not investigate more than that.

Comment
Add comment · Show 1 · 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 thunderdev321 · Jul 04, 2017 at 03:32 PM 0
Share

That solved it for me, thanks

Was doing

 foreach (var gesture in gestureDatabase.AvailableGestures)

Changed it to

 var gestures = gestureDatabase.AvailableGestures;
 foreach (var gesture in gestures)

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

6 People are following this question.

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

Related Questions

Shooting with get joint rotation .eulerAngles kinect 0 Answers

Strange Files Replacing My Game Files? 1 Answer

Is it possible to load a VideoClip at runtime from streaming assets 0 Answers

Unity 5.4.0f3 (64-bit) Crahed on startup! 2 Answers

Rigidbody and forces not working after unity crashed 1 Answer


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