Software Archive
Read-only legacy content
17060 Discussions

Basic Hand Program

HexLord
Beginner
1,873 Views

 

Hi, 

I tried running  the basic hand program. All I wanted to do was print "Hey" if the camera saw a hand.

I copied this code right out of the SDK and added   Console.WriteLine("HEY") .

On execution, the program kept on writing HEY even when there was no hand in front of it.

// Create an instance of the SenseManager.
PXCMSenseManager sm=PXCMSenseManager.CreateInstance();
 
// Enable hand tracking
sm.EnableHand();
 
// Get a hand instance here (or inside the AcquireFrame/ReleaseFrame loop) for querying features
PXCMHandModule hand=sm.QueryHand();
...
 
// Initialize the pipeline
sm.Init();
 
// Stream data
while (sm.AcquireFrame(true)>=pxcmStatus.PXCM_STATUS_NO_ERROR) {
  // retrieve hand tracking results if ready
  PXCMHandModule hand2=sm.QueryHand();
  if (hand2!=null) {
     Console.WriteLine("HEY")
  }
 
  // resume next frame processing
  sm.ReleaseFrame();
}
 
// Clean up
sm.Dispose();

 

Please Help

-Shaleen Sharda

 

0 Kudos
13 Replies
steve-vink
Beginner
1,873 Views

Your code retrieves the instance of the hand module, it is simply acknowledging that the module is active in the pipeline.

You need to dig deeper into the returned data to get the tracking results.

https://software.intel.com/sites/landingpage/realsense/camera-sdk/2014gold/documentation/html/index.html?pxchandmodule.html

 

0 Kudos
HexLord
Beginner
1,873 Views

hi,

 

Thanks for the reply.

what editions can I make to check if the camera sees a hand ?

 

Thanks,

Shaleen Sharda

0 Kudos
steve-vink
Beginner
1,873 Views

I'm not using hand recognition so I haven't looked into it too much. But I highly recommend the demo code that is in the SDK folder. There is a full demo app for each part of the camera, and it's fairly easy to take the class file they have created and modify it for your purposes.

 

0 Kudos
HexLord
Beginner
1,873 Views

Okay...Also I tried the following code , it doesnt execute:

sm.EnableStream(PXCMImage.PixelFormat.PIXEL_FORMAT_RGB32,0,0);

it says it has some invalid arguments

Thanks

Shaleen Sharda

0 Kudos
samontab
Valued Contributor II
1,873 Views

well, it has invalid arguments...

It should be called like this:

sm->EnableStream(PXCCapture::STREAM_TYPE_COLOR, 640, 480 30);

Or just like this:


sm->EnableStream(PXCCapture::STREAM_TYPE_COLOR);

Take a look at the samples, this is thoroughly covered there.

0 Kudos
Raditya_U_
Beginner
1,873 Views

I think I've been trying this sample code, but I forget which one. Can you show me the page for downloading this sample?

0 Kudos
samontab
Valued Contributor II
1,873 Views

It is in almost every sample in the installed sdk.

Here for example:

Intel\RSSDK\sample\raw_streams\src\raw_streams.cpp

0 Kudos
HexLord
Beginner
1,873 Views

hi,

I am trying to get a simple hand detection code to work.

Does anyone have a sample code to show message when a hand appears in front of the camera?

0 Kudos
Raditya_U_
Beginner
1,873 Views

Download the tutorial solution here https://software.intel.com/sites/default/files/managed/e0/5c/Tutorial_VisualStudioProjectSolution.zip

The 3_Hands_Tracking project display an alert when detecting your hand, you can add it in the handtracking_render.cpp in the NotifyAlerts function

0 Kudos
James_T_2
Beginner
1,873 Views

Here is some Java code that I am using that might help give you an idea of the steps required.

In the initialization of the device I do:

senseManager.EnableHand();
PXCHandModule handModule = senseManager.QueryHand();
handData = handModule.CreateOutput();
PXCHandConfiguration handConfig = handModule.CreateActiveConfiguration();
TrackingModeType trackingMode = TrackingModeType.TRACKING_MODE_FULL_HAND;
handConfig.SetTrackingMode(trackingMode);
handConfig.EnableAllGestures();
handConfig.EnableAlert(AlertType.ALERT_HAND_DETECTED);
handConfig.EnableAlert(AlertType.ALERT_HAND_NOT_DETECTED);
handConfig.ApplyChanges();

For each frame:

handData.Update();
for (int i = 0; i < handData.QueryFiredAlertsNumber(); i++) {
  PXCHandData.AlertData alertData = new PXCHandData.AlertData();
  handData.QueryFiredAlertData(i, alertData);
  if (alertData.getLabel() == AlertType.ALERT_HAND_DETECTED) {
	    log("HandTracking", "Detected hand, id: " + alertData.getHandId());
  } else if (alertData.getLabel() == AlertType.ALERT_HAND_NOT_DETECTED) {
    	log("HandTracking", "Hand lost, id: " + alertData.getHandId());
  }
}

 

0 Kudos
MartyG
Honored Contributor III
1,873 Views

This seems like a good opportunity to highlight the method I posted a few days back for converting C# scripts in the SDK manual for use in Unity if anyone is planning on using the scripts in Unity for their project.

https://software.intel.com/en-us/forums/topic/536627

0 Kudos
AndreCarlucci
Beginner
1,873 Views

Hi Shaleen,

For a simple app like this, take a look at my project:

https://github.com/andrecarlucci/SharpSenses

All that code can be replaced by:
            var cam = Camera.Create();
            cam.Start();
            cam.LeftHand.Visible += () => Console.WriteLine("Hi");
Cheers!

 
0 Kudos
HexLord
Beginner
1,873 Views

Thanks for the replies.

I am stuck with another issue now. I am trying to get the no of faces detected. Here;s my code. it always prints 0.

    PXCMSenseManager sm = PXCMSenseManager.CreateInstance();

          sm.EnableFace();
            sm.Init();


            // face is a PXCMFaceModule instance

           


            while (sm.AcquireFrame()>= pxcmStatus.PXCM_STATUS_NO_ERROR )
            {

                PXCMFaceModule face2 = sm.QueryFace();
                 PXCMFaceData fdata= face2.CreateOutput();
                 Int32 no = fdata.QueryNumberOfDetectedFaces();
                 Console.WriteLine(no);
              fdata.Dispose();           
            }

 

 

0 Kudos
Reply