added: noise filtering to reduce rotation jitter

This commit is contained in:
Zu 2014-07-25 17:32:04 +08:00
parent 2d921924bf
commit 98bb995aba
2 changed files with 26 additions and 6 deletions

View file

@ -1,5 +1,5 @@
//
// CaraManager.cpp
// CaraFaceTracker.cpp
// interface/src/devices
//
// Created by Li Zuwei on 7/22/14.
@ -376,6 +376,7 @@ void CaraFaceTracker::decodePacket(const QByteArray& buffer)
QElapsedTimer timer;
timer.start();
//decode the incoming udp packet
QJsonParseError jsonError;
CaraPerson person = CaraPacketDecoder::extractOne(buffer, &jsonError);
@ -402,6 +403,22 @@ void CaraFaceTracker::decodePacket(const QByteArray& buffer)
float AVERAGE_CARA_FRAME_TIME = 0.033f;
_headAngularVelocity = theta / AVERAGE_CARA_FRAME_TIME * glm::vec3(r.x, r.y, r.z) / rMag;
if(glm::abs(_headAngularVelocity.x) < 1.0f)
{
person.pose.pitch = _previousPitch;
//qDebug() << "NO change in pitch";
}
if(glm::abs(person.pose.yaw - _previousYaw) < 2.5f)
{
qDebug() << "Yaw Diff: " << glm::abs(person.pose.yaw - _previousYaw);
person.pose.yaw = _previousYaw;
}
if(glm::abs(_headAngularVelocity.z) < 1.0f)
{
//qDebug() << "NO change in roll";
person.pose.roll = _previousRoll;
}
_previousPitch = person.pose.pitch;
_previousYaw = person.pose.yaw;
_previousRoll = person.pose.roll;

View file

@ -1,5 +1,5 @@
//
// CaraManager.h
// CaraFaceTracker.h
// interface/src/devices
//
// Created by Li Zuwei on 7/22/14.
@ -9,18 +9,21 @@
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
//
#ifndef hi_fi_Cara_h
#define hi_fi_Cara_h
#ifndef hi_fi_CaraFaceTracker_h
#define hi_fi_CaraFaceTracker_h
#include <QUdpSocket>
#include "FaceTracker.h"
/*!
* \class CaraManager
* \class CaraFaceTracker
*
* \brief Handles interaction with the Cara software,
* which provides head position/orientation and facial features.
* \details By default, opens a udp socket with IPV4_ANY_ADDR with port 36555.
* User needs to run the Cara Face Detection UDP Client with the destination
* host address (eg: 127.0.0.1 for localhost) and destination port 36555.
**/
class CaraFaceTracker : public FaceTracker
@ -118,4 +121,4 @@ private:
int _jawOpenIndex;
};
#endif //endif hi_fi_CaraManager_h
#endif //endif hi_fi_CaraFaceTracker_h