Share via


NuiCreateSensorByIndex

Kinect for Windows 1.5, 1.6, 1.7, 1.8

Creates an instance of the Kinect sensor with the specified index so that an application can open and use it.

Syntax

HRESULT NuiCreateSensorByIndex(
         int index,
         INuiSensor **ppNuiSensor
)

Parameters

  • index
    Type: int
    [in] The zero-based index of the Kinect sensor to open. Valid values range from zero to one less than the value returned by the NuiGetSensorCount function.
  • ppNuiSensor
    Type: INuiSensor
    [out] A pointer that receives a reference to the created INuiSensor interface.

Return Value

Type: HRESULT
Returns S_OK if successful; otherwise, returns one of the failure codes in the following table.

Error Description
E_OUTOFMEMORY The allocation failed.
E_POINTER The hNextFrameEvent parameter is an invalid handle.

Remarks

Note

This function supports applications that use more than one Kinect sensor. Applications that use only one sensor do not need an INuiSensor interface, and should use the functions in NuiApi.h, NuiImageCamera.h, and NuiSkeleton.h.

Applications that support more than one Kinect sensor call NuiCreateSensorByIndex to access the second and subsequent devices. This function returns a pointer to an INuiSensor interface, which provides functions that are identical to those in NuiApi.h, NuiImageCamera.h, and NuiSkeleton.h, but operate on a particular device instance.

Requirements

Header: Declared in NuiSensor.h; however, include NuiApi.h in your project.