none
CollectFaceDataAsync doesn't invoke delegates RRS feed

  • Question

  • FaceModelBuilder in Unity Pro plugin doesn't have BeginFaceDataCollection() or GetFaceData() or CollectionCompleted event.

    so ColectFaceDataAsync is the only option.

    my code is like :

    public void StartCapture()
    	{
    		this.StopFaceCapture();
    		
    		this.faceModelBuilder = null;
    		
    		this.faceModelBuilder = this.highDefinitionFaceFrameSource.OpenModelBuilder(FaceModelBuilderAttributes.None);
    		
    		this.faceModelBuilder.CollectFaceDataAsync ((Action<Microsoft.Kinect.Face.FaceModelData>)CollectionSuccess, (Action<int>)CollectionFailure);	   //BeginFaceDataCollection();
    	}

    void CollectionSuccess(FaceModelData modelData)
    	{		
    		this.currentFaceModel = modelData.ProduceFaceModel();
    		
    		this.faceModelBuilder.Dispose();
    		this.faceModelBuilder = null;
    		
    		this.CurrentBuilderStatus = "Capture Complete";
    		this.UpdateMesh();
    	}

    but CollectionSuccess() is never called, even CheckOnBuilderStatus() gives a "Complete"

    Wednesday, December 10, 2014 7:34 AM

All replies

  • It will never be called immediately as it needs different views of the face. If you review the WPF sample, you will see that you need to get left/right/up/down views until it can succeed.

    You may want to put in your update loop a check to see what the state is:

    if(faceModelBulder != null)
    {
       var captureStatus = faceModelBuilder.CaptureStatus;
       
       // provide some feedback to user.
    }


    Carmine Sirignano - MSFT

    Wednesday, December 10, 2014 7:19 PM
  • I check it, use the CheckOnBuilderStatus() from the WPF sample, i call it in a HDFaceFrameArrived event handler. the problem is even it gives a "Complete", the Succeess delegate is still not called.

    also FaceModelBuilder doesn't have GetModelData() in unity add-in, i can't get it myself when CollectionStatus is a Complete


    • Edited by Clones1201 Wednesday, December 10, 2014 11:42 PM
    Wednesday, December 10, 2014 11:40 PM
  • use FaceModelData.ProduceFaceModel()

    Are you using the callback method or polling for reconstruction?


    Carmine Sirignano - MSFT

    Thursday, December 11, 2014 8:22 PM
  • I'm having the same issue.

    Microsoft_Kinect_Face_FaceModelData_Delegate_Success is not called in KinectFaceSpecialCases.cs

    After capturing all the necessary views, the capture status becomes 7. This may possibly indicate some sort of system error, but it's not clear what. The fail delegate is not called either at this point.

    Stopping the Capture manually does call the failure delegate.

    I have also tried to implement my own GetFaceData method, but it crashes unity immediately when i try to producefacemodel with the return value.

    public void GetFaceData(Action<Microsoft.Kinect.Face.FaceModelData> callback)
    {
        var faceModelData = Helper.NativeObjectCache.CreateOrGetObject<Microsoft.Kinect.Face.FaceModelData>(_pNative, n => new Microsoft.Kinect.Face.FaceModelData(n));
        Helper.EventPump.Instance.Enqueue(() => callback(faceModelData));
    }

    Can we get a working unity sample that calls back to the delegate and does

    ProduceFaceModel ?

    Thanks!



    • Edited by PandaChuZero Tuesday, December 30, 2014 11:40 PM
    Tuesday, December 30, 2014 11:03 PM
  • I can provide my sample project if that helps - its just the dll's for the kinect stuff are rather large so i'd have to put it on dropbox or something.
    Wednesday, January 7, 2015 7:02 PM
  • Have the same problem as both Clones1201 and PandaChuZero.

    Having got HDFace tracking working including displaying the default face mesh, I wanted to add the ability to capture actual users face data. Independently I came up with the exact same code as Clone1201 posted having used the 'HDFaceBasics-WPF' example project and discovered that several methods were missing/changed from the Unity add-on.

    As far as I can tell this is the correct way to do it, it just doesn't work, the Success callback method (supplied to CollectFaceDataAsync() ) is never called. Like PandaChuZero I also noticed that CaptureStatus becomes a value of '7' once all views are captured, which is not a defined enum value.

    Tried various alternatives and workarounds but all end up locking up Unity.

    Would love to see a working example of this, at the moment I can only assume its broken either in the dll or something in the c# wrapper.

    Monday, March 16, 2015 8:07 AM
  • There is a bug in the current plug-in where the event doesn't fire when the state of capture is completed. The only workaround would be to implement your own plug-in if you cannot wait for a fix.

    Carmine Sirignano - MSFT

    Monday, March 16, 2015 6:03 PM
  • There is a bug in the current plug-in where the event doesn't fire when the state of capture is completed. The only workaround would be to implement your own plug-in if you cannot wait for a fix.

    Carmine Sirignano - MSFT

    Thanks for the prompt reply.

    Disappointing to hear that, pretty much kills a potential project I was working on. Do we have any eta on when it might be fixed?

    Its a bit worrying that this bug has been around for so long, 3 months since the issue was mentioned in this post. What is Microsoft's position on fixing issues with and supporting the Unity add-on?

    However that said it brings up a question i've had on my mind, and thats why is the add-on dll not open sourced itself to allow developers to fix issues like this themselves? Sure a developer could as you suggest write their own plug-in, but for many that is beyond their experience and knowledge. Besides why should they when you have a great framework already made if it could just be open sourced to the community?

    I can understand wanting to maintain some control over the dll's, but many companies are now finding the advantage to open sourcing such things, (e.g. Unity with there UI, the entire UE4 etc). Its especially important when it appears the owner of the dll's are unable to promptly fix issues themsevles. For me its either MS promptly fixes the bugs and updates the Unity add-on, or they should open source it, allow the community to fix problems then build off those periodically with official dll releases.

    Indeed this goes for both the dll's and the Unity wrapper which whilst great as a learning tool, is rather inefficient. It generates huge amounts of memory garbage every frame, fetches unmanaged data for every call (even though the data has not changed), uses foreach on lists/dictionary which cause large amounts of garbage collection etc. It could easily be improved for the community, by the community with a proper version control set up, such as github, bitbucket. Does MS have their own system for this sort of stuff?


    • Edited by noisecrime Monday, March 16, 2015 6:39 PM
    • Proposed as answer by Jashengmato Tuesday, August 4, 2015 6:15 PM
    Monday, March 16, 2015 6:34 PM
  • Still no fix on this, maybe in next few years? haha 
    Tuesday, August 4, 2015 6:16 PM
  • There is a solution? After 5 years Im having the same issue, lol.
    Thursday, April 18, 2019 3:28 PM
  • Don't wait for it. SDK last update was in 2014 I think. Or sometime after that. Kinect v2 has been discontinued officially so definitely no fixes in the future. You should see if you can upgrade to Kinect for Azure instead when it comes out(assuming it covers the functionality you need).
    Thursday, April 18, 2019 6:36 PM