Defer pico face tracking start until stream begins
This commit is contained in:
@@ -1344,12 +1344,7 @@ static const char * get_face_icon(XrTime predicted_display_time)
|
|||||||
{
|
{
|
||||||
static const auto w = face_weights();
|
static const auto w = face_weights();
|
||||||
wivrn::from_headset::tracking::fb_face2 expression;
|
wivrn::from_headset::tracking::fb_face2 expression;
|
||||||
if (application::get_fb_face_tracking2_supported())
|
application::get_fb_face_tracker2().get_weights(predicted_display_time, expression);
|
||||||
application::get_fb_face_tracker2().get_weights(predicted_display_time, expression);
|
|
||||||
else if (application::get_pico_face_tracking_supported())
|
|
||||||
application::get_pico_face_tracker().get_weights(predicted_display_time, expression);
|
|
||||||
else
|
|
||||||
__builtin_unreachable();
|
|
||||||
|
|
||||||
if (not expression.is_valid)
|
if (not expression.is_valid)
|
||||||
return ICON_FA_FACE_MEH;
|
return ICON_FA_FACE_MEH;
|
||||||
@@ -1413,7 +1408,7 @@ void scenes::lobby::draw_features_status(XrTime predicted_display_time)
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (application::get_fb_face_tracking2_supported() or application::get_pico_face_tracking_supported())
|
if (application::get_fb_face_tracking2_supported())
|
||||||
{
|
{
|
||||||
items.push_back({
|
items.push_back({
|
||||||
.f = feature::face_tracking,
|
.f = feature::face_tracking,
|
||||||
@@ -1424,7 +1419,7 @@ void scenes::lobby::draw_features_status(XrTime predicted_display_time)
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (application::get_htc_face_tracking_eye_supported() or application::get_htc_face_tracking_lip_supported())
|
if (application::get_htc_face_tracking_eye_supported() or application::get_htc_face_tracking_lip_supported() or application::get_pico_face_tracking_supported())
|
||||||
{
|
{
|
||||||
items.push_back({
|
items.push_back({
|
||||||
.f = feature::face_tracking,
|
.f = feature::face_tracking,
|
||||||
|
|||||||
@@ -249,7 +249,13 @@ void scenes::stream::tracking()
|
|||||||
else if (application::get_htc_face_tracking_eye_supported() or application::get_htc_face_tracking_lip_supported())
|
else if (application::get_htc_face_tracking_eye_supported() or application::get_htc_face_tracking_lip_supported())
|
||||||
face_tracking = from_headset::face_type::htc;
|
face_tracking = from_headset::face_type::htc;
|
||||||
else if (application::get_pico_face_tracking_supported())
|
else if (application::get_pico_face_tracking_supported())
|
||||||
|
{
|
||||||
face_tracking = from_headset::face_type::pico;
|
face_tracking = from_headset::face_type::pico;
|
||||||
|
// We can't start the face tracking on application initialisation like we do for
|
||||||
|
// other face trackers due to a Pico runtime bug where face tracking freezes when
|
||||||
|
// the headset is taken off or the application is quit.
|
||||||
|
application::get_pico_face_tracker().start();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
on_interaction_profile_changed({});
|
on_interaction_profile_changed({});
|
||||||
@@ -444,6 +450,9 @@ void scenes::stream::tracking()
|
|||||||
exit();
|
exit();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (face_tracking == from_headset::face_type::pico)
|
||||||
|
application::get_pico_face_tracker().stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
void scenes::stream::operator()(to_headset::tracking_control && packet)
|
void scenes::stream::operator()(to_headset::tracking_control && packet)
|
||||||
|
|||||||
@@ -25,7 +25,9 @@
|
|||||||
#include "xr/pico_eye_types.h"
|
#include "xr/pico_eye_types.h"
|
||||||
#include "xr/session.h"
|
#include "xr/session.h"
|
||||||
#include "xr/to_string.h"
|
#include "xr/to_string.h"
|
||||||
|
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
#include <stdexcept>
|
||||||
#include <openxr/openxr.h>
|
#include <openxr/openxr.h>
|
||||||
|
|
||||||
xr::pico_face_tracker::pico_face_tracker(instance & inst, session & s_) :
|
xr::pico_face_tracker::pico_face_tracker(instance & inst, session & s_) :
|
||||||
@@ -36,14 +38,31 @@ xr::pico_face_tracker::pico_face_tracker(instance & inst, session & s_) :
|
|||||||
xrSetTrackingModePICO = inst.get_proc<PFN_xrSetTrackingModePICO>("xrSetTrackingModePICO");
|
xrSetTrackingModePICO = inst.get_proc<PFN_xrSetTrackingModePICO>("xrSetTrackingModePICO");
|
||||||
xrGetFaceTrackingStatePICO = inst.get_proc<PFN_xrGetFaceTrackingStatePICO>("xrGetFaceTrackingStatePICO");
|
xrGetFaceTrackingStatePICO = inst.get_proc<PFN_xrGetFaceTrackingStatePICO>("xrGetFaceTrackingStatePICO");
|
||||||
xrGetFaceTrackingDataPICO = inst.get_proc<PFN_xrGetFaceTrackingDataPICO>("xrGetFaceTrackingDataPICO");
|
xrGetFaceTrackingDataPICO = inst.get_proc<PFN_xrGetFaceTrackingDataPICO>("xrGetFaceTrackingDataPICO");
|
||||||
|
|
||||||
CHECK_XR(xrStartEyeTrackingPICO(s));
|
|
||||||
CHECK_XR(xrSetTrackingModePICO(s, XR_TRACKING_MODE_FACE_BIT_PICO));
|
|
||||||
}
|
}
|
||||||
xr::pico_face_tracker::~pico_face_tracker()
|
xr::pico_face_tracker::~pico_face_tracker()
|
||||||
{
|
{
|
||||||
|
if (started)
|
||||||
|
stop();
|
||||||
|
}
|
||||||
|
|
||||||
|
void xr::pico_face_tracker::start()
|
||||||
|
{
|
||||||
|
if (started)
|
||||||
|
throw std::invalid_argument("face tracking already started");
|
||||||
|
|
||||||
|
CHECK_XR(xrStartEyeTrackingPICO(s));
|
||||||
|
CHECK_XR(xrSetTrackingModePICO(s, XR_TRACKING_MODE_FACE_BIT_PICO));
|
||||||
|
started = true;
|
||||||
|
}
|
||||||
|
void xr::pico_face_tracker::stop()
|
||||||
|
{
|
||||||
|
if (!started)
|
||||||
|
throw std::invalid_argument("face tracking not started");
|
||||||
|
|
||||||
if (auto res = xrStopEyeTrackingPICO(s, XR_TRACKING_MODE_FACE_BIT_PICO); !XR_SUCCEEDED(res))
|
if (auto res = xrStopEyeTrackingPICO(s, XR_TRACKING_MODE_FACE_BIT_PICO); !XR_SUCCEEDED(res))
|
||||||
spdlog::warn("Failed to deactivate face tracking: {}", xr::to_string(res));
|
spdlog::warn("Failed to deactivate face tracking: {}", xr::to_string(res));
|
||||||
|
|
||||||
|
started = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void xr::pico_face_tracker::get_weights(XrTime time, wivrn::from_headset::tracking::fb_face2 & out_expressions)
|
void xr::pico_face_tracker::get_weights(XrTime time, wivrn::from_headset::tracking::fb_face2 & out_expressions)
|
||||||
|
|||||||
@@ -38,12 +38,15 @@ class pico_face_tracker
|
|||||||
PFN_xrGetFaceTrackingDataPICO xrGetFaceTrackingDataPICO{};
|
PFN_xrGetFaceTrackingDataPICO xrGetFaceTrackingDataPICO{};
|
||||||
|
|
||||||
XrSession s;
|
XrSession s;
|
||||||
|
bool started{};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
pico_face_tracker() = default;
|
pico_face_tracker() = default;
|
||||||
pico_face_tracker(instance & inst, session & s);
|
pico_face_tracker(instance & inst, session & s);
|
||||||
~pico_face_tracker();
|
~pico_face_tracker();
|
||||||
|
|
||||||
|
void start();
|
||||||
|
void stop();
|
||||||
void get_weights(XrTime time, struct wivrn::from_headset::tracking::fb_face2 & out_expressions);
|
void get_weights(XrTime time, struct wivrn::from_headset::tracking::fb_face2 & out_expressions);
|
||||||
};
|
};
|
||||||
} // namespace xr
|
} // namespace xr
|
||||||
|
|||||||
Reference in New Issue
Block a user