I am workin on a project that aims to interpret some parts of the finger alphabet. I am using a Kinect v1 to this end and these two projects: Lightbuzz.Vitruvius provides the main funcionality and Lightbuzz.Vitruvius.Fingertracking the ability to detect finger-tips (at least so far is the theory).
Plugging these two together was more tedious than challenging but the real challenge comes from an EventHandler. You see there is a HandController class where the fingers are detected and displayed. In this class is an EventHandler that kicks off the detection.
Having appropately changed every thing Rider now reports this error (I am using the .NET Framework 4.0):
<LightBuzz.Vitruvius>\HandsController.cs:1706 The type 'LightBuzz.Vitruvius.HandCollection' must be convertible to 'System.EventArgs' in order to use it as parameter 'TEventArgs' in the generic delegate 'void System.EventHandler<TEventArgs>(object, TEventArgs)'
The following is the EventHandler and the Code to be executed there on:
public event EventHandler<HandCollection> HandsDetected;
private void HandsController_HandsDetected(object sender, HandCollection e)
{
// Display the results!
if (e.HandLeft != null)
{
// Draw contour.
foreach (var point in e.HandLeft.ContourDepth)
{
kinectViewer.DrawEllipse(point, Brushes.Green, 2.0);
}
// Draw fingers.
foreach (var finger in e.HandLeft.Fingers)
{
kinectViewer.DrawEllipse(finger.DepthPoint, Brushes.White, 4.0);
}
}
if (e.HandRight != null)
{
// Draw contour.
foreach (var point in e.HandRight.ContourDepth)
{
kinectViewer.DrawEllipse(point, Brushes.Blue, 2.0);
}
// Draw fingers.
foreach (var finger in e.HandRight.Fingers)
{
kinectViewer.DrawEllipse(finger.DepthPoint, Brushes.White, 4.0);
}
}
}
// The object HandCollection is a seperate class as follows:
public partial class HandCollection
{
/// <summary>
/// The tracking ID of the current body.
/// </summary>
public int TrackingId { get; set; }
/// <summary>
/// The left hand data of the current body.
/// </summary>
public Hand HandLeft { get; set; }
/// <summary>
/// The right hand data of the current body.
/// </summary>
public Hand HandRight { get; set; }
}
My question would now be what does this error mean and how do I solve it? I have relatively few clues about the how and what of C#, so please be gentle. I have also found out that switching the framework to version 4.5 solves this issue but creates a dozen more.
CodePudding user response:
As the error suggests, your HandCollection
class cannot be used as a parameter in the eventhandler delegate. You might have your reasons for using .Net 4.0, so try making the class inherit from System.EventArgs
and see if this works. Otherwise I would suggest switching framework.