Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

BodyFrameReader.AcquireLatestFrame always returns null

I'm using the Kinect (v2) plugin for Unity (5.0) to animate a body. I'm using the code below, but BodyFrameReader.AcquireLatestFrame() always returns null:

private KinectSensor _sensor;
private BodyFrameReader _reader;

void Start()
{
    _sensor = KinectSensor.GetDefault();

    if (_sensor != null)
    {
        _reader = _sensor.BodyFrameSource.OpenReader();

        if (!_sensor.IsOpen)
        {
            _sensor.Open();
        }
    }
}

void Update()
{
    if (_reader != null)
    {
        var frame = _reader.AcquireLatestFrame(); //This always returns null

        if (frame == null)
        {
            Debug.Log("No frame available");
            return;
        }
    }
}

I did some debugging, and I can see that I get one frame, and after that AcquireLatestFrame() is always null. In BodyFrameReader.cs it calls the native method Windows_Kinect_BodyFrameReader_AcquireLastestFrame(_pnative). Which returns the nullptr.

like image 778
Simon Verbeke Avatar asked Jul 24 '26 03:07

Simon Verbeke


1 Answers

if you have one image then nothing it means you haven't released resources and it can't overwrite on it. At the end of your update you have to release all resources you used (except your reader I guess) it's easy to release pointers in C++, though I don't know how to do in c#. If I was you i would look in the samples to find where they release resources.

like image 149
poulet Avatar answered Jul 25 '26 16:07

poulet