mirror of
https://github.com/lubosz/overte.git
synced 2025-04-16 14:16:36 +02:00
Make face tracker mute action start / stop face tracker
This commit is contained in:
parent
35dbb9491c
commit
1c21874f00
9 changed files with 51 additions and 35 deletions
|
@ -934,7 +934,9 @@ void Application::audioMuteToggled() {
|
|||
void Application::faceTrackerMuteToggled() {
|
||||
QAction* muteAction = Menu::getInstance()->getActionForOption(MenuOption::MuteFaceTracking);
|
||||
Q_CHECK_PTR(muteAction);
|
||||
muteAction->setChecked(getActiveFaceTracker()->isMuted());
|
||||
bool isMuted = getSelectedFaceTracker()->isMuted();
|
||||
muteAction->setChecked(isMuted);
|
||||
getSelectedFaceTracker()->setEnabled(!isMuted);
|
||||
}
|
||||
|
||||
void Application::aboutApp() {
|
||||
|
@ -1887,25 +1889,40 @@ FaceTracker* Application::getActiveFaceTracker() {
|
|||
(faceshift->isActive() ? static_cast<FaceTracker*>(faceshift.data()) : NULL));
|
||||
}
|
||||
|
||||
FaceTracker* Application::getSelectedFaceTracker() {
|
||||
FaceTracker* faceTracker = NULL;
|
||||
#ifdef HAVE_FACESHIFT
|
||||
if (Menu::getInstance()->isOptionChecked(MenuOption::Faceshift)) {
|
||||
faceTracker = DependencyManager::get<Faceshift>().data();
|
||||
}
|
||||
#endif
|
||||
#ifdef HAVE_DDE
|
||||
if (Menu::getInstance()->isOptionChecked(MenuOption::UseCamera)) {
|
||||
faceTracker = DependencyManager::get<DdeFaceTracker>().data();
|
||||
}
|
||||
#endif
|
||||
return faceTracker;
|
||||
}
|
||||
|
||||
void Application::setActiveFaceTracker() {
|
||||
bool isMuted = Menu::getInstance()->isOptionChecked(MenuOption::MuteFaceTracking);
|
||||
#ifdef HAVE_FACESHIFT
|
||||
auto faceshiftTracker = DependencyManager::get<Faceshift>();
|
||||
faceshiftTracker->setTCPEnabled(Menu::getInstance()->isOptionChecked(MenuOption::Faceshift));
|
||||
faceshiftTracker->setIsMuted(isMuted);
|
||||
faceshiftTracker->setEnabled(Menu::getInstance()->isOptionChecked(MenuOption::Faceshift) && !isMuted);
|
||||
#endif
|
||||
#ifdef HAVE_DDE
|
||||
bool isUsingDDE = Menu::getInstance()->isOptionChecked(MenuOption::UseCamera);
|
||||
Menu::getInstance()->getActionForOption(MenuOption::UseAudioForMouth)->setVisible(isUsingDDE);
|
||||
Menu::getInstance()->getActionForOption(MenuOption::VelocityFilter)->setVisible(isUsingDDE);
|
||||
auto ddeTracker = DependencyManager::get<DdeFaceTracker>();
|
||||
ddeTracker->setEnabled(isUsingDDE);
|
||||
ddeTracker->setIsMuted(isMuted);
|
||||
ddeTracker->setEnabled(isUsingDDE && !isMuted);
|
||||
#endif
|
||||
}
|
||||
|
||||
void Application::toggleFaceTrackerMute() {
|
||||
FaceTracker* faceTracker = getActiveFaceTracker();
|
||||
FaceTracker* faceTracker = getSelectedFaceTracker();
|
||||
if (faceTracker) {
|
||||
faceTracker->toggleMute();
|
||||
}
|
||||
|
|
|
@ -219,6 +219,7 @@ public:
|
|||
bool getLastMouseMoveWasSimulated() const { return _lastMouseMoveWasSimulated; }
|
||||
|
||||
FaceTracker* getActiveFaceTracker();
|
||||
FaceTracker* getSelectedFaceTracker();
|
||||
|
||||
QSystemTrayIcon* getTrayIcon() { return _trayIcon; }
|
||||
ApplicationOverlay& getApplicationOverlay() { return _applicationOverlay; }
|
||||
|
|
|
@ -65,7 +65,7 @@ void CameraToolBox::toggleMute() {
|
|||
delete _doubleClickTimer;
|
||||
_doubleClickTimer = NULL;
|
||||
|
||||
FaceTracker* faceTracker = Application::getInstance()->getActiveFaceTracker();
|
||||
FaceTracker* faceTracker = Application::getInstance()->getSelectedFaceTracker();
|
||||
if (faceTracker) {
|
||||
faceTracker->toggleMute();
|
||||
}
|
||||
|
|
|
@ -178,9 +178,7 @@ DdeFaceTracker::DdeFaceTracker(const QHostAddress& host, quint16 serverPort, qui
|
|||
_filteredBrowUp(0.0f),
|
||||
_lastEyeBlinks(),
|
||||
_filteredEyeBlinks(),
|
||||
_lastEyeCoefficients(),
|
||||
_isCalculatingFPS(false),
|
||||
_frameCount(0)
|
||||
_lastEyeCoefficients()
|
||||
{
|
||||
_coefficients.resize(NUM_FACESHIFT_BLENDSHAPES);
|
||||
|
||||
|
@ -203,7 +201,16 @@ DdeFaceTracker::~DdeFaceTracker() {
|
|||
#pragma warning(default:4351)
|
||||
#endif
|
||||
|
||||
void DdeFaceTracker::init() {
|
||||
FaceTracker::init();
|
||||
setEnabled(Menu::getInstance()->isOptionChecked(MenuOption::UseCamera) && !_isMuted);
|
||||
}
|
||||
|
||||
void DdeFaceTracker::setEnabled(bool enabled) {
|
||||
if (!_isInitialized) {
|
||||
// Don't enable until have explicitly initialized
|
||||
return;
|
||||
}
|
||||
#ifdef HAVE_DDE
|
||||
// isOpen() does not work as one might expect on QUdpSocket; don't test isOpen() before closing socket.
|
||||
_udpSocket.close();
|
||||
|
@ -316,10 +323,6 @@ float DdeFaceTracker::getBlendshapeCoefficient(int index) const {
|
|||
void DdeFaceTracker::decodePacket(const QByteArray& buffer) {
|
||||
_lastReceiveTimestamp = usecTimestampNow();
|
||||
|
||||
if (_isMuted) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (buffer.size() > MIN_PACKET_SIZE) {
|
||||
bool isFiltering = Menu::getInstance()->isOptionChecked(MenuOption::VelocityFilter);
|
||||
|
||||
|
|
|
@ -28,6 +28,7 @@ class DdeFaceTracker : public FaceTracker, public Dependency {
|
|||
SINGLETON_DEPENDENCY
|
||||
|
||||
public:
|
||||
virtual void init();
|
||||
virtual void reset();
|
||||
|
||||
virtual bool isActive() const;
|
||||
|
@ -120,9 +121,6 @@ private:
|
|||
float _lastEyeBlinks[2];
|
||||
float _filteredEyeBlinks[2];
|
||||
float _lastEyeCoefficients[2];
|
||||
|
||||
bool _isCalculatingFPS;
|
||||
int _frameCount;
|
||||
};
|
||||
|
||||
#endif // hifi_DdeFaceTracker_h
|
||||
|
|
|
@ -20,15 +20,9 @@
|
|||
const int FPS_TIMER_DELAY = 2000; // ms
|
||||
const int FPS_TIMER_DURATION = 2000; // ms
|
||||
|
||||
FaceTracker::FaceTracker() :
|
||||
_isCalculatingFPS(false),
|
||||
_frameCount(0),
|
||||
_isMuted(false)
|
||||
{
|
||||
}
|
||||
|
||||
void FaceTracker::init() {
|
||||
_isMuted = Menu::getInstance()->isOptionChecked(MenuOption::MuteFaceTracking);
|
||||
_isInitialized = true; // FaceTracker can be used now
|
||||
}
|
||||
|
||||
inline float FaceTracker::getBlendshapeCoefficient(int index) const {
|
||||
|
|
|
@ -49,11 +49,16 @@ public:
|
|||
|
||||
signals:
|
||||
void muteToggled();
|
||||
|
||||
|
||||
public slots:
|
||||
virtual void setEnabled(bool enabled) = 0;
|
||||
|
||||
protected:
|
||||
FaceTracker();
|
||||
virtual ~FaceTracker() {};
|
||||
|
||||
bool _isInitialized = false;
|
||||
bool _isMuted = true;
|
||||
|
||||
glm::vec3 _headTranslation = glm::vec3(0.0f);
|
||||
glm::quat _headRotation = glm::quat();
|
||||
float _estimatedEyePitch = 0.0f;
|
||||
|
@ -63,8 +68,6 @@ protected:
|
|||
float _relaxationStatus = 0.0f; // Between 0.0f and 1.0f
|
||||
float _fadeCoefficient = 0.0f; // Between 0.0f and 1.0f
|
||||
|
||||
bool _isMuted;
|
||||
|
||||
void countFrame();
|
||||
|
||||
private slots:
|
||||
|
@ -72,8 +75,8 @@ private slots:
|
|||
void finishFPSTimer();
|
||||
|
||||
private:
|
||||
bool _isCalculatingFPS;
|
||||
int _frameCount;
|
||||
bool _isCalculatingFPS = false;
|
||||
int _frameCount = 0;
|
||||
};
|
||||
|
||||
#endif // hifi_FaceTracker_h
|
||||
|
|
|
@ -49,8 +49,8 @@ Faceshift::Faceshift() :
|
|||
|
||||
#ifdef HAVE_FACESHIFT
|
||||
void Faceshift::init() {
|
||||
setTCPEnabled(Menu::getInstance()->isOptionChecked(MenuOption::Faceshift));
|
||||
FaceTracker::init();
|
||||
setEnabled(Menu::getInstance()->isOptionChecked(MenuOption::Faceshift) && !_isMuted);
|
||||
}
|
||||
|
||||
void Faceshift::update(float deltaTime) {
|
||||
|
@ -128,7 +128,11 @@ void Faceshift::updateFakeCoefficients(float leftBlink, float rightBlink, float
|
|||
coefficients[FUNNEL_BLENDSHAPE] = mouth3;
|
||||
}
|
||||
|
||||
void Faceshift::setTCPEnabled(bool enabled) {
|
||||
void Faceshift::setEnabled(bool enabled) {
|
||||
// Don't enable until have explicitly initialized
|
||||
if (!_isInitialized) {
|
||||
return;
|
||||
}
|
||||
#ifdef HAVE_FACESHIFT
|
||||
if ((_tcpEnabled = enabled)) {
|
||||
connectSocket();
|
||||
|
@ -199,10 +203,6 @@ void Faceshift::receive(const QByteArray& buffer) {
|
|||
#ifdef HAVE_FACESHIFT
|
||||
_lastReceiveTimestamp = usecTimestampNow();
|
||||
|
||||
if (_isMuted) {
|
||||
return;
|
||||
}
|
||||
|
||||
_stream.received(buffer.size(), buffer.constData());
|
||||
fsMsgPtr msg;
|
||||
for (fsMsgPtr msg; (msg = _stream.get_message()); ) {
|
||||
|
|
|
@ -87,7 +87,7 @@ signals:
|
|||
void connectionStateChanged();
|
||||
|
||||
public slots:
|
||||
void setTCPEnabled(bool enabled);
|
||||
void setEnabled(bool enabled);
|
||||
|
||||
private slots:
|
||||
void connectSocket();
|
||||
|
|
Loading…
Reference in a new issue