none
Programming Kinect v2 Sensor using Kinect for Windows SDK 2.0 Public Preview and VB.NET RRS feed

  • Question

  • Hello folks,

    I am programming with a Kinect v2 Sensor and the Kinect for Windows SDK 2.0 Public Preview (managed code library). I am using VB.NET which was going OK up until a stumbling block I hit today. Let me explain...I am doing the VB equivalent of the following C# code from one of the samples provided in the SDK:

    // Array for the bodies (Kinect will track up to 6 people
    private Microsoft.Kinect.Body[] bodies = null;
    //
    // And later on using a BodyFrame object from the active sensor
    this.bodies = new Microsoft.Kinect.Body[bodyFrame.BodyCount];
    // Works OK - Body object supports "new" in C#

    All well and good. However, the following equivalent in VB.NET fails:

    ' Bodies array
    Private bodies As Microsoft.Kinect.Body()
    
    ' And later on...
    bodies = New Microsoft.Kinect.Body(bodyFrame.BodyCount)

    The VB version generates the error Type 'Microsoft.Kinect.Body' has no constructors. Can anyone shed some light on this (or even a solution or workaround). My next course of action was to make my own "KinectBody" C# class wrapping up the managed code Microsoft.Kinect.Body and compile it as a DLL to be re-used in my VB.NET code, a bit of an overkill if it can be avoided!

    I appreciate the SDK is a preview but any help would be much appreciated.


    Martyn Atkins (Senior Technician / Programmer) Plymouth University School of Psychology LinkedIn: http://lnkd.in/V3dRi7 Twitter: @Martyn_JA

    Thursday, October 2, 2014 1:43 PM

Answers

  • I think you have to do something like  

    Redim bodies(bodyFrame.BodyCount)

    • Marked as answer by Martyn Atkins Thursday, October 2, 2014 3:43 PM
    Thursday, October 2, 2014 1:52 PM
  • Very close thanks - actually, the following works (I forgot that C# and VB.NET have different ways of initialising array lengths).

    ReDim bodies(bodyFrame.BodyCount - 1)
    That solves the problem. I'll credit you with the answer though, many thanks.


    Martyn Atkins (Senior Technician / Programmer) Plymouth University School of Psychology LinkedIn: http://lnkd.in/V3dRi7 Twitter: @Martyn_JA

    • Marked as answer by Martyn Atkins Thursday, October 2, 2014 3:43 PM
    Thursday, October 2, 2014 3:43 PM

All replies

  • I think you have to do something like  

    Redim bodies(bodyFrame.BodyCount)

    • Marked as answer by Martyn Atkins Thursday, October 2, 2014 3:43 PM
    Thursday, October 2, 2014 1:52 PM
  • Very close thanks - actually, the following works (I forgot that C# and VB.NET have different ways of initialising array lengths).

    ReDim bodies(bodyFrame.BodyCount - 1)
    That solves the problem. I'll credit you with the answer though, many thanks.


    Martyn Atkins (Senior Technician / Programmer) Plymouth University School of Psychology LinkedIn: http://lnkd.in/V3dRi7 Twitter: @Martyn_JA

    • Marked as answer by Martyn Atkins Thursday, October 2, 2014 3:43 PM
    Thursday, October 2, 2014 3:43 PM
  • Very close thanks - actually, the following works (I forgot that C# and VB.NET have different ways of initialising array lengths).

    ReDim bodies(bodyFrame.BodyCount - 1)
    That solves the problem. I'll credit you with the answer though, many thanks.


    Martyn Atkins (Senior Technician / Programmer) Plymouth University School of Psychology LinkedIn: http://lnkd.in/V3dRi7 Twitter: @Martyn_JA

    I now have a working Visual Studio project code sample available at Kinect v2 SDK Sample Code re-worked in VB.NET (skeleton & gestures)

    Martyn Atkins (Senior Technician / Programmer) Plymouth University School of Psychology LinkedIn: http://lnkd.in/V3dRi7 Twitter: @Martyn_JA

    Tuesday, October 7, 2014 4:00 PM