Last reviewed: 3/23/2024 9:01:32 AM
Event Handling
To receive sensor data, status, and error messages, applications receive event notifications.
Event | Event Arguments | Description |
---|---|---|
ApiError | ChantAPIErrorEventArgs | Notifies the application of an API error |
AudioDestinationStart | AudioEventArgs | Notifies the application of the audio output start |
AudioDestinationStop | AudioEventArgs | Notifies the application of the audio output stop |
AudioSourceStart | AudioEventArgs | Notifies the application of the audio input start |
AudioSourceStop | AudioEventArgs | Notifies the application of the audio input stop |
AudioBeamFrameArrived | AudioBeamFrameArrivedEventArgs | Notifies the application when a audio beam frame arrives |
BeamAngleChanged | BeamAngleChangedEventArgs | Notifies the application when the beam angle changes |
BeamAngleConfidenceChanged | BeamAngleConfidenceChangedEventArgs | Notifies the application when the beam angle confidence changes |
BodyFrameArrived | BodyFrameArrivedEventArgs | Notifies the application when a body frame arrives |
BodyIndexFrameArrived | BodyIndexFrameArrivedEventArgs | Notifies the application when a body index frame arrives |
ColorFrameArrived | ColorFrameArrivedEventArgs | Notifies the application when a color frame arrives |
CoordinateMappingChanged | CoordinateMappingChangedEventArgs | Notifies the application the synthesizer has generated a sentence boundary in the current synthesized speech audio |
DepthFrameArrived | DepthFrameArrivedEventArgs | Notifies the application when a depth frame arrives |
FrameCaptured | FrameCapturedEventArgs | Notifies the application when a frame is captured |
InfraredFrameArrived | InfraredFrameArrivedEventArgs | Notifies the application when an infrared frame arrives |
IsAvailableChanged | IsAvailableChangedEventArgs | Notifies the application when a sensor availability changes |
LongExposureInfraredFrameArrived | LongExposureInfraredFrameArrivedEventArgs | Notifies the application when a long exposure infrared frame arrives |
MultiSourceFrameArrived | MultiSourceFrameArrivedEventArgs | Notifies the application when a multi source frame arrives |
PropertyChanged | PropertyChangedEventArgs | Notifies the application when a sensor property value changes |
RelativeTimeChanged | RelativeTimeChangedEventArgs | Notifies the application when relative time changes |
Some events provide data values that are returned in argument objects.
-
AudioBeamFrameArrivedEventArgs
- FrameReference - The reference to the audio beam frame for the FrameArrived event
-
AudioEventArgs
- File - File name
-
BeamAngleChangedEventArgs
- Angle - Beam angle value
-
BeamAngleConfidenceChangedEventArgs
- Confidence - Beam angle confidence value
-
BodyFrameArrivedEventArgs
- FrameReference - The reference to the body frame for the FrameArrived event
-
BodyIndexFrameArrivedEventArgs
- FrameReference - The reference to the body index frame for the FrameArrived event
-
ChantAPIErrorEventArgs
- Function - API funtion name
- Message - API error message
- RC - API error return code
-
ColorFrameArrivedEventArgs
- FrameReference - The reference to the color frame for the FrameArrived event.
-
CoordinateMappingChangedEventArgs
- No arguments
-
DepthFrameArrivedEventArgs
- FrameReference - The reference to the depth frame for the FrameArrived event
-
FrameCapturedEventArgs
- FrameStatus - Frame captured status
- FrameType - Frame source type
- RelativeTime - Relative time
-
InfraredFrameArrivedEventArgs
- FrameReference - The reference to the infrared frame for the FrameArrived event
-
IsAvailableChangedEventArgs
- IsAvailable - Availability value
-
LongExposureInfraredFrameArrived
- FrameReference - The reference to the infrared frame for the FrameArrived event
-
MultiSourceFrameArrived
- FrameReference - The reference to the multi source frame for the FrameArrived event
-
PropertyChanged
- PropertyName - The property name
-
RelativeTimeChanged
- RelativeTime - Relative time
Event notifications are recieved in callback routines as follows:
// Create KinectSensor
_Sensor = _KinesicsKit.CreateKinectSensor();
if (_Sensor != null)
{
// Setup event callback handler
_Sensor.MultiSourceFrameArrived += this.NKinectSensor_MultiSourceFrameArrived;
}
// Static event handler declaration
void CALLBACK MultiSourceFrameArrived(void* Sender, CMultiSourceFrameArrivedEventArgs* Args);
// Create recognizer
_Sensor = _KinesicsKit->CreateKinectSensor();
if (_Sensor != NULL)
{
// Register Event Handlers
_Sensor->SetMultiSourceFrameArrived(MultiSourceFrameArrived);
}
// Static event handler declaration
void CALLBACK MultiSourceFrameArrived(void* Sender, CMultiSourceFrameArrivedEventArgs* Args);
// Create recognizer
_Sensor = _KinesicsKit->CreateKinectSensor();
if (_Sensor != NULL)
{
// Register Event Handlers
_Sensor->SetMultiSourceFrameArrived(MultiSourceFrameArrived);
}
procedure MultiSourceFrameArrived(Sender: TObject; Args: TMultiSourceFrameArrivedEventArgs);
// Create recognizer
_Sensor := _KinesicsKit.CreateKinectSensor();
if (_Sensor <> nil) then
begin
// Register Event Handlers
_Sensor.MultiSourceFrameArrived := MultiSourceFrameArrived;
end;
// Add implements for event handlers
public class Frame1 extends JFrame implements JChantKinesicsKitEvents
// Create KinectSensor
_Sensor = _KinesicsKit.createKinectSensor();
if (_Sensor != null)
{
// Set the callback
_Sensor.setChantKinesicsKitEvents(this);
// Register Callbacks for visual cues.
_Sensor.registerCallback(ChantKinesicsKitCallback.CCKSMultiSourceFrameArrived);
}
_KinesicsKit = New NKinesicsKit()
// Declaring the event handlers routines with Handles clause in VB automatically registers for the event notifications
Public Sub NKinectSensor_MultiSourceFrameArrived(ByVal sender As System.Object, ByVal e As MultiSourceFrameArrivedEventArgs) Handles _Sensor.MultiSourceFrameArrived
The KinectSensor object sends all notifications to the event handlers. All event data is contained in a arguments object.
private void NKinectSensor_MultiSourceFrameArrived(object sender, MultiSourceFrameArrivedEventArgs e)
{
MultiSourceFrameReference multiSourceFrameReference = e.FrameReference;
if (multiSourceFrameReference != null)
{
MultiSourceFrame multiSourceFrame = multiSourceFrameReference.AcquireFrame();
if (multiSourceFrame != null)
{
...
multiSourceFrame.Dispose();
}
multiSourceFrameReference.Dispose();
}
}
void CALLBACK MultiSourceFrameArrived(void* Sender, CMultiSourceFrameArrivedEventArgs* Args)
{
CMultiSourceFrameReference* pMultiSourceFrameReference = Args->GetFrameReference();
if (pMultiSourceFrameReference != NULL)
{
CMultiSourceFrame* pMultiSourceFrame = pMultiSourceFrameReference->AcquireFrame();
if (pMultiSourceFrame != NULL)
{
...
delete pMultiSourceFrame;
}
delete pMultiSourceFrameReference;
}
}
void CALLBACK MultiSourceFrameArrived(void* Sender, CMultiSourceFrameArrivedEventArgs* Args)
{
CMultiSourceFrameReference* pMultiSourceFrameReference = Args->GetFrameReference();
if (pMultiSourceFrameReference != NULL)
{
CMultiSourceFrame* pMultiSourceFrame = pMultiSourceFrameReference->AcquireFrame();
if (pMultiSourceFrame != NULL)
{
...
delete pMultiSourceFrame;
}
delete pMultiSourceFrameReference;
}
}
procedure TForm1.MultiSourceFrameArrived(Sender: TObject; Args: TMultiSourceFrameArrivedEventArgs);
var
multiSourceFrameReference: TMultiSourceFrameReference;
multiSourceFrame: TMultiSourceFrame;
begin
multiSourceFrameReference := Args.FrameReference;
if (multiSourceFrameReference <> nil) then
begin
multiSourceFrame := multiSourceFrameReference.AcquireFrame;
if (multiSourceFrame <> nil) then
begin
...
multiSourceFrame.Destroy;
end;
multiSourceFrameReference.Destroy;
end;
end;
// Notifies the application when a multi source frame arrives.
public void multiSourceFrameArrived(Object sender, MultiSourceFrameArrivedEventArgs args)
{
MultiSourceFrameReference multiSourceFrameReference = args.getFrameReference();
if (multiSourceFrameReference != null)
{
MultiSourceFrame multiSourceFrame = multiSourceFrameReference.acquireFrame();
if (multiSourceFrame != null)
{
...
multiSourceFrame.dispose();
}
multiSourceFrameReference.dispose();
}
}
Public Sub NKinectSensor_MultiSourceFrameArrived(ByVal sender As System.Object, ByVal e As MultiSourceFrameArrivedEventArgs) Handles _Sensor.MultiSourceFrameArrived
Dim multiSourceFrameReference As MultiSourceFrameReference = e.FrameReference
If Not (multiSourceFrameReference Is Nothing) Then
Dim multiSourceFrame As MultiSourceFrame = multiSourceFrameReference.AcquireFrame()
If Not (multiSourceFrame Is Nothing) Then
...
multiSourceFrame.Dispose()
End If
multiSourceFrameReference.Dispose()
End If
End Sub