Neeraj's Blog

There is always an open source solution..

Retrieving Head Pose Data Using Intel RealSense SDK

I am trying to retrieve the head pose using Intel RealSense. My intention is to find the three angles yaw, pitch and roll of the head. The code is given below.

#include "pxccapturemanager.h"
#include "pxcsensemanager.h"
#include "pxcstatus.h"
#include "pxcfacemodule.h"
#include "pxcfacedata.h"
#include "pxcfaceconfiguration.h"

using namespace std;

const int MAX_FACES = 4;

int main(int argc, char**argv)
    pxcStatus sts;
    PXCSenseManager *sm = PXCSenseManager::CreateInstance();

    if (!sm) {
        printf("Unable to create the PXCSenseManager\n");
        return 1;
//    sm->EnableStream(PXCCapture::STREAM_TYPE_COLOR,0,0,0.0);
    sts = sm->EnableFace();
    if (sts < PXC_STATUS_NO_ERROR) {         printf("Unable to enable Face Analysis\n");         return 2;     }     sm->Init();

//    PXCFaceModule* faceAnalyzer = sm->QueryFace();
//    PXCFaceData* outputData = faceAnalyzer->CreateOutput();

    PXCFaceModule *face=sm->QueryFace();
    PXCFaceData *fdata = face->CreateOutput();
    PXCFaceConfiguration* config = face->CreateActiveConfiguration();
    config->detection.isEnabled = true;
//    config->pose.isEnabled = true;
    config->detection.maxTrackedFaces = MAX_FACES;
    PXCFaceData::PoseEulerAngles angles;
    bool poseDataSts = false;


            if (sts<PXC_STATUS_NO_ERROR) break;         fdata->Update();
        // check if face data is available
        if (face) {
            // working with face data
            pxcI32 numFaces =  fdata->QueryNumberOfDetectedFaces();

            for(pxcI32 i =0; i< numFaces; i++)             {                 PXCFaceData::Face *singleFdata =  fdata->QueryFaceByIndex(i);
                PXCFaceData::PoseData *pose = singleFdata->QueryPose();
                poseDataSts = pose->QueryPoseAngles(&angles);
                    cout<< "Face ID \t" << i<< endl;
                    cout<<"pitch: " << angles.pitch <<"\t";
                    cout<<"roll : "<< angles.roll << "\t";
                    cout<<"yaw: "<< angles.yaw << endl;                 }             }         }         sm->ReleaseFrame();


Single Post Navigation

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: