Community
cancel
Showing results for 
Search instead for 
Did you mean: 
carlos_c_6
Beginner
36 Views

Use Java code to capture landmarks points

Hi guys.

I tried to make some test in relasense camera using the java language.

Below the code. 

I tried to capture de landmaks but the java program return the null points.

Why?

import intel.rssdk.PXCMCaptureManager;
import intel.rssdk.PXCMFaceConfiguration;
import intel.rssdk.PXCMFaceData;
import intel.rssdk.PXCMFaceModule;
import intel.rssdk.PXCMSenseManager;
import intel.rssdk.PXCMSession;
import intel.rssdk.pxcmStatus;

public class TesteLandMark {

	public static void main(String[] args) {
		// Create session
		PXCMSession session = PXCMSession.CreateInstance();
		if (session == null) {
			System.out.print("Failed to create a session instance\n");
			System.exit(3);
		}

		PXCMSenseManager senseMgr = session.CreateSenseManager();
		if (senseMgr == null) {
			System.out.print("Failed to create a SenseManager instance\n");
			System.exit(3);
		}
		
		PXCMCaptureManager captureMgr = senseMgr.QueryCaptureManager();
		captureMgr.FilterByDeviceInfo("RealSense", null, 0);

		pxcmStatus sts = senseMgr.EnableFace(null);
		
		if (sts.compareTo(pxcmStatus.PXCM_STATUS_NO_ERROR) < 0) {
			throw new IllegalStateException("Failed to enable face");
		}

		PXCMFaceModule face = senseMgr.QueryFace();
		PXCMFaceConfiguration cfg = face.CreateActiveConfiguration();
		cfg.EnableAllAlerts();

		cfg.ApplyChanges();
		cfg.close();
		
		sts = senseMgr.Init();
		
		while (senseMgr.AcquireFrame(true) == pxcmStatus.PXCM_STATUS_NO_ERROR) {	
			  PXCMFaceModule face2 = senseMgr.QueryFace();
			  
			  PXCMFaceData faceData = face2.CreateOutput();
			  faceData.Update();
			  int numFaces = faceData.QueryNumberOfDetectedFaces();
			  System.out.println("Saw: " + numFaces + " faces.");
			  for (int i = 0; i < numFaces; i++)  {
				  // Retrieve the face landmark data instance
				   PXCMFaceData.Face face1 = faceData.QueryFaceByIndex(i);
				   PXCMFaceData.LandmarksData ldata = face1.QueryLandmarks();
				   
				   // allocate the array big enough to hold the landmark points.
				   int npoints = ldata.QueryNumPoints();
				   PXCMFaceData.LandmarkPoint[] points = new PXCMFaceData.LandmarkPoint[npoints];
				   
				   // get the landmark data
				   ldata.QueryPoints(points);
				   
				   for(PXCMFaceData.LandmarkPoint p: points){
					   if(p != null){
						   System.out.println("points x: " + p.image.x);
						   System.out.println("points y: " + p.image.y);
					   }
				   }
			  }
			  faceData.close();	
			  senseMgr.ReleaseFrame();
		} 
	}
}

 

0 Kudos
3 Replies
Xusheng_L_Intel
Employee
36 Views

Which camera are you using? Which version release SDK? Where did you get Null? Please provide us detail info so I can help you. Thanks!

0 Kudos
carlos_c_6
Beginner
36 Views

Hi David

Below the information about the SDk. The camera is RealSense F200

  • Intel(R) RealSense(TM) SDK 8.0.24.6528
  • Intel(R) RealSense(TM) SDK Runtime 6.0.21.6598
  • Intel(R) RealSense(TM) Depth Camera Manager 1.4.27.41944
  • Intel(R) RealSense(TM) 3D Camera 2780 

I tryed pick up the landmarks position but the code bring the points null.

// get the landmark data
ldata.QueryPoints(points);
for(PXCMFaceData.LandmarkPoint p: points){
                       if(p != null){
                           System.out.println("points x: " + p.image.x);
                           System.out.println("points y: " + p.image.y);
                       }
                   }
              }

 

Thanks

 

0 Kudos
KKasu
Beginner
36 Views

Hi All, 

I got same Issue ? Any one came up with a solution ? Please share

Cheers

0 Kudos