Software Archive
Read-only legacy content
17060 Discusiones

Basic Hand Program

HexLord
Principiante
4.186 Vistas

 

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 Respuestas
steve-vink
Principiante
4.186 Vistas

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

 

HexLord
Principiante
4.186 Vistas

hi,

 

Thanks for the reply.

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

 

Thanks,

Shaleen Sharda

steve-vink
Principiante
4.186 Vistas

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.

 

HexLord
Principiante
4.186 Vistas

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

samontab
Colaborador Valioso II
4.186 Vistas

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.

Raditya_U_
Principiante
4.186 Vistas

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

samontab
Colaborador Valioso II
4.186 Vistas

It is in almost every sample in the installed sdk.

Here for example:

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

HexLord
Principiante
4.186 Vistas

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?

Raditya_U_
Principiante
4.186 Vistas

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

James_T_2
Principiante
4.186 Vistas

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());
  }
}

 

MartyG
Colaborador Distinguido III
4.186 Vistas

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

AndreCarlucci
Principiante
4.186 Vistas

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!

 
HexLord
Principiante
4.186 Vistas

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();           
            }

 

 

Responder