- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
As my post title implement , I could not be able to set to work properly the hand gesture.I am writing in C#.I have F200 camera.
This is my code:
// Create a PXCMSenseManager instance PXCMSenseManager sm = PXCMSenseManager.CreateInstance(); // Select the depth stream sm.EnableHand(); // Get an instance of PXCMHandModule PXCMHandModule handModule = sm.QueryHand(); sm.Init(); // Create the hand data instance PXCMHandData handData = handModule.CreateOutput(); // Get an instance of PXCMHandConfiguration PXCMHandConfiguration handConfig = handModule.CreateActiveConfiguration(); // Make configuration changes and apply them handConfig.EnableJointSpeed(PXCMHandData.JointType.JOINT_INDEX_BASE, PXCMHandData.JointSpeedType.JOINT_SPEED_ABSOLUTE, 3); handConfig.EnableAllGestures(); handConfig.EnableAllAlerts(); // set other configuration options handConfig.ApplyChanges(); // Changes only take effect when you call ApplyChanges PXCMHandData.IHand ihand; PXCMHandData.FingerData fingerData; PXCMHandData.ExtremityData extremitydata; int i = 0; int currentAstricX = 0; int currentAstricY = 0; Console.SetCursorPosition(currentAstricX, currentAstricY); Console.WriteLine("#"); // Main processing loop while (sm.AcquireFrame(true).IsSuccessful()) { // handData is a PXCMHandData instance // Update hand data handData.Update(); Int32 handId; handData.QueryHandData(PXCMHandData.AccessOrderType.ACCESS_ORDER_BY_ID, 0, out ihand); handData.QueryHandId(PXCMHandData.AccessOrderType.ACCESS_ORDER_NEAR_TO_FAR, 0, out handId); PXCMHandData.GestureData gestureData; if (handData.QueryFiredGestureData(i, out gestureData) == pxcmStatus.PXCM_STATUS_NO_ERROR) { Console.WriteLine("beseder"); } PXCMHandData.GestureData data; if(handData.IsGestureFired("swipe_down", out data)) { Console.SetCursorPosition(currentAstricX, currentAstricY + 1); Console.Clear(); Console.WriteLine("#"); } if (handData.IsGestureFired("fist", out data)) { Console.SetCursorPosition(currentAstricX, currentAstricY + 1); Console.Clear(); Console.WriteLine("#"); } if (handData.IsGestureFired("v_sign", out data)) { Console.SetCursorPosition(currentAstricX, currentAstricY + 1); Console.Clear(); Console.WriteLine("#"); } } }
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Please look at our RealSense SDK sample code @C:\Program Files (x86)\Intel\RSSDK\framework\CSharp\FF_HandsViewer.cs. Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I look at the sample code and it does not help me.
I try to move a character (#) on console screen on gesture fire event.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Leonid,
I think the main problem is that you're not releasing the frame after an acquire (i.e., sm.ReleaseFrame();). The code below doesn't do exactly what you want, but it comes pretty close and should help you with your project.
Hope this helps, Bryan
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
// Instantiate and initialize the SenseManager
string gesture = "";
PXCMSenseManager sm = PXCMSenseManager.CreateInstance();
PXCMHandData handData;
PXCMHandData.GestureData data;
sm.EnableHand();
sm.Init();
// Configure the Hand Module
PXCMHandModule hand = sm.QueryHand();
PXCMHandConfiguration handConfig = hand.CreateActiveConfiguration();
handConfig.EnableAllGestures();
handConfig.EnableAllAlerts();
handConfig.ApplyChanges();
int currentAstricX = 0;
int currentAstricY = 0;
Console.SetCursorPosition(currentAstricX, currentAstricY);
Console.WriteLine("#");
// Main processing loop
while (sm.AcquireFrame(true).IsSuccessful())
{
// Retrieve gesture data
hand = sm.QueryHand();
if (hand != null)
{
// Retrieve the most recent processed data
handData = hand.CreateOutput();
handData.Update();
if (handData.IsGestureFired("spreadfingers", out data))
{
gesture = "Spread Fingers";
}
else if (handData.IsGestureFired("fist", out data))
{
gesture = "Fist";
}
else if (handData.IsGestureFired("tap", out data))
{
gesture = "Tap";
}
else if (handData.IsGestureFired("thumb_down", out data))
{
gesture = "Thumb Down";
}
else if (handData.IsGestureFired("thumb_up", out data))
{
gesture = "Thumb Up";
}
else if (handData.IsGestureFired("two_fingers_pinch_open", out data))
{
gesture = "Two Fingers Pinch Open";
}
else if (handData.IsGestureFired("v_sign", out data))
{
gesture = "V-Sign";
}
else if (handData.IsGestureFired("wave", out data))
{
gesture = "Wave";
}
else if (handData.IsGestureFired("swipe_down", out data))
{
gesture = "Swipe Down";
}
Console.WriteLine(gesture);
sm.ReleaseFrame();
}
}
}
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
As Bryan said, the biggest issue you face there is that you don't release your frame when you're finished with it. This leads to memory ramping up very quickly as you're finding. Something to remember, as well, is that you could well be coping with an exception inside your processing so you need to make sure that you always release the frame if possible. To do that, I would tend to write my loop a bit more like this:
while (true) { if (!sm.AcquireFrame(true).IsSuccessful()) return; try { } finally { sm.ReleaseFrame(); } }
I hope that helps.
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page