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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With