Software Archive
Read-only legacy content
Announcements
FPGA community forums and blogs have moved to the Altera Community. Existing Intel Community members can sign in with their current credentials.
17060 Discussions

Hand Gesture not recognized...

Fadi_H_
Beginner
995 Views
Hello Guys, i am writing here for the 3rd time, i hope that someone will finally answer my question...
The following java code is working, the hands are recognized BUT the gestures arent!! did i forget anything in the code?
for any helpful hints i would be thankful! 

public class handgecogni  {
	
	public static void main(String s[]) {
	System.out.println("Starting hand tracker.");
	
	PXCMSenseManager senseManager =PXCMSenseManager.CreateInstance();
	senseManager.EnableStream(PXCMCapture.StreamType.STREAM_TYPE_COLOR,640,480,30);
	senseManager.EnableHand(null);
	PXCMHandModule handModule = senseManager.QueryHand();
	senseManager.Init();
	PXCMHandData handData = handModule.CreateOutput();
	PXCMHandConfiguration handConfig = handModule.CreateActiveConfiguration();
	
	handConfig.DisableAllGestures();
	// i want to make only thumbs up recognized
	handConfig.EnableGesture("thumbs_up");
	handConfig.EnableAllAlerts();	
	handConfig.ApplyChanges();
	

	PXCMCaptureManager captureMgr = senseManager.QueryCaptureManager();
	captureMgr.FilterByDeviceInfo("RealSense",null, 0);
	pxcmStatus sts = senseManager.EnableHand(null);
	sts = senseManager.Init();				 
	handConfig.Update();
	
		if (sts.compareTo(pxcmStatus.PXCM_STATUS_NO_ERROR) >= 0) {
			senseManager.Init();
							
			for (int nframes = 0; nframes < 3000; nframes++) {
		//	System.out.println("Frame # " + );
			sts = senseManager.AcquireFrame(true);
			if (sts.compareTo(pxcmStatus.PXCM_STATUS_NO_ERROR) < 0)
			break;
	
				while (senseManager.AcquireFrame(true).isSuccessful()) {
					
				// Retrieve current hand tracking results
				handData = handModule.CreateOutput();
				handData.Update();
				PXCMHandData.GestureData gestureData = new PXCMHandData.GestureData();
				PXCMHandData.IHand hand = new PXCMHandData.IHand();
				sts = handData.QueryHandData(PXCMHandData.AccessOrderType.ACCESS_ORDER_NEAR_TO_FAR,0, hand);
				
				
				if (sts.compareTo(pxcmStatus.PXCM_STATUS_NO_ERROR) >= 0) {
					
					
					PXCMPointF32 image = hand.QueryMassCenterImage();
					PXCMPoint3DF32 world = hand.QueryMassCenterWorld();
					boolean result = handData.IsGestureFired("thumbs_up", gestureData);
					System.out.print("  Is Thumbs up : (" + result+ ")\n");
					System.out.print("   Image Position: (" + image.x + ","+ image.y + ")");
					System.out.println("   World Position: (" + world.x + ","+ world.y + "," + world.z + ")");
					
				}
				int ngestures = handData.QueryNumberOfHands();
				System.out.println("# of hands is "+ ngestures);
		
				senseManager.ReleaseFrame();
				}	
			}
		senseManager.close();
		
		}
	}
	
}

 

0 Kudos
7 Replies
Bryan_B_Intel1
Employee
995 Views

Hello Fadi,

Have you tried "thumb_up" instead of "thumbs_up"? There might be a typo here.

-Bryan

0 Kudos
Fadi_H_
Beginner
995 Views

Hello Bryan, thanx for your comment, i changed it but no difference.  in consloe still showing:   " Is Thumbs up : (false)" also when  place my hand in front of the camera "thumb up"

 

0 Kudos
Bryan_B_Intel1
Employee
995 Views

Just to make sure, did you change it in both places?

handConfig.EnableGesture("thumbs_up");

.

.

.

boolean result = handData.IsGestureFired("thumbs_up", gestureData);

-Bryan

0 Kudos
Fadi_H_
Beginner
995 Views

oops! i changed both now, it seems to work!! thaanks a alot , but its working a weird way, it shows one time true and 10 times false. 

its not showing "true" one after the other. 

any way i have made this boolean, to check if the gesture recognition is working. 

the main purpose of my program is to enable "thumb_up" and "thumb_down" and "swipe"

i will try to make some changes sothat it shows those up written gestures in the console.

thank you again :)

0 Kudos
Bryan_B_Intel1
Employee
995 Views

Glad to hear it's moving forward! You may want to refer to para. 4.5.6 on page 1220 in sdkmanuals.pdf (C:\Program Files (x86)\Intel\RSSDK\doc\PDF) for the naming conventions used for the other gestures (e.g., "swipe_left", etc.) 

-Bryan

0 Kudos
Fadi_H_
Beginner
995 Views

now i got it, one last question, i wanted to show in the console the name of the gesture instead of true and false, 

i used this    System.out.print("Gesture is \n" +gestureData.name);

it didnt work and showed only "Gesture is" repeatedly

0 Kudos
Fadi_H_
Beginner
995 Views

Dear Bryan, i found it! i wrote this code and thumb up and down are working now,

PXCMHandData.GestureData gestureData = new PXCMHandData.GestureData();
				if (handData.IsGestureFired("thumb_up", gestureData)) {
				System.out.println("thumb up!!");	
				}
				
				else if (handData.IsGestureFired("thumb_down", gestureData)) {
					System.out.println("thumb down!!");	
					}
				else if (handData.IsGestureFired("wave", gestureData)) {
					System.out.println("wave!!");	
					}

 

for waving im going to use swipe_right and swipe_left because it didnt recognize it 

0 Kudos
Reply