WIP: Pico 4 Pro face tracking

This commit is contained in:
Sapphire
2025-06-01 10:21:47 +02:00
committed by xytovl
parent 5130bdeda5
commit 908d21ffec
23 changed files with 655 additions and 3 deletions
+13
View File
@@ -30,6 +30,7 @@
#include "wifi_lock.h"
#include "xr/actionset.h"
#include "xr/check.h"
#include "xr/pico_eye_types.h"
#include "xr/xr.h"
#include <algorithm>
#include <boost/locale.hpp>
@@ -1039,6 +1040,7 @@ void application::initialize()
opt_extensions.push_back(XR_HTC_PASSTHROUGH_EXTENSION_NAME);
opt_extensions.push_back(XR_HTC_FACIAL_TRACKING_EXTENSION_NAME);
opt_extensions.push_back(XR_FB_FACE_TRACKING2_EXTENSION_NAME);
opt_extensions.push_back(XR_PICO_EYE_TRACKING_EXTENSION_NAME);
opt_extensions.push_back(XR_EXT_PALM_POSE_EXTENSION_NAME);
opt_extensions.push_back(XR_KHR_COMPOSITION_LAYER_DEPTH_EXTENSION_NAME);
opt_extensions.push_back(XR_FB_COMPOSITION_LAYER_DEPTH_TEST_EXTENSION_NAME);
@@ -1121,6 +1123,12 @@ void application::initialize()
htc_face_tracking_lip_supported = htc_face_properties.supportLipFacialTracking;
}
if (utils::contains(xr_extensions, XR_PICO_EYE_TRACKING_EXTENSION_NAME))
{
spdlog::info(" PICO face tracking support: true");
pico_face_tracking_supported = true;
}
if (utils::contains(xr_extensions, XR_FB_COMPOSITION_LAYER_SETTINGS_EXTENSION_NAME))
{
spdlog::info(" OpenXR post-processing extension support: true");
@@ -1180,6 +1188,11 @@ void application::initialize()
htc_face_tracker_lip = xr_session.create_htc_face_tracker(XR_FACIAL_TRACKING_TYPE_LIP_DEFAULT_HTC);
}
if (pico_face_tracking_supported)
{
pico_face_tracker = xr_session.create_pico_face_tracker();
}
vk::CommandPoolCreateInfo cmdpool_create_info;
cmdpool_create_info.queueFamilyIndex = vk_queue_family_index;
cmdpool_create_info.flags = vk::CommandPoolCreateFlagBits::eResetCommandBuffer;
+14
View File
@@ -24,6 +24,7 @@
#include "xr/fb_face_tracker2.h"
#include "xr/hand_tracker.h"
#include "xr/htc_face_tracker.h"
#include "xr/pico_face_tracker.h"
#ifdef __ANDROID__
#include <android_native_app_glue.h>
#endif
@@ -133,6 +134,9 @@ class application : public singleton<application>
bool htc_face_tracking_lip_supported = false;
xr::htc_face_tracker htc_face_tracker_lip;
bool pico_face_tracking_supported = false;
xr::pico_face_tracker pico_face_tracker;
bool eye_gaze_supported = false;
bool openxr_post_processing_supported = false;
@@ -436,6 +440,11 @@ public:
return instance().htc_face_tracking_lip_supported;
}
static bool get_pico_face_tracking_supported()
{
return instance().pico_face_tracking_supported;
}
static bool get_eye_gaze_supported()
{
return instance().eye_gaze_supported;
@@ -471,6 +480,11 @@ public:
return instance().htc_face_tracker_lip;
}
static xr::pico_face_tracker & get_pico_face_tracker()
{
return instance().pico_face_tracker;
}
static const std::vector<std::string> & get_xr_extensions()
{
return instance().xr_extensions;
+4
View File
@@ -111,6 +111,10 @@ bool configuration::check_feature(feature f) const
if (not(application::get_htc_face_tracking_eye_supported() or application::get_htc_face_tracking_lip_supported()))
return false;
break;
case model::pico_4_pro:
if (not application::get_pico_face_tracking_supported())
return false;
break;
default:
if (not application::get_fb_face_tracking2_supported())
return false;
+9
View File
@@ -77,6 +77,9 @@ static model guess_model_()
if (model == "A9210")
return model::pico_4s;
if (model == "A8110")
return model::pico_4_pro;
spdlog::info("manufacturer={}, model={}, device={} assuming Pico 4", manufacturer, model, device);
return model::pico_4;
}
@@ -145,6 +148,7 @@ XrViewConfigurationView override_view(XrViewConfigurationView view, model m)
return scale_view(view, 1832);
case model::pico_4:
case model::pico_4s:
case model::pico_4_pro:
return scale_view(view, 2160);
case model::htc_vive_focus_3:
case model::htc_vive_focus_vision:
@@ -172,6 +176,7 @@ bool need_srgb_conversion(model m)
case model::pico_neo_3:
case model::pico_4:
case model::pico_4s:
case model::pico_4_pro:
case model::htc_vive_focus_3:
case model::htc_vive_focus_vision:
case model::htc_vive_xr_elite:
@@ -201,6 +206,7 @@ const char * permission_name(feature f)
case model::pico_neo_3:
case model::pico_4:
case model::pico_4s:
case model::pico_4_pro:
return "com.picovr.permission.EYE_TRACKING";
case model::htc_vive_focus_3:
case model::htc_vive_focus_vision:
@@ -222,6 +228,8 @@ const char * permission_name(feature f)
case model::pico_neo_3:
case model::pico_4:
case model::pico_4s:
case model::pico_4_pro:
return "com.picovr.permission.FACE_TRACKING";
case model::htc_vive_focus_3:
case model::htc_vive_focus_vision:
case model::htc_vive_xr_elite:
@@ -257,6 +265,7 @@ std::string controller_name()
return "pico-neo3";
case model::pico_4:
case model::pico_4s: // TODO: split when we have the pico-4s 3d model
case model::pico_4_pro:
return "pico-4";
case model::htc_vive_focus_3:
case model::htc_vive_focus_vision:
+1
View File
@@ -35,6 +35,7 @@ enum class model
pico_neo_3,
pico_4,
pico_4s,
pico_4_pro,
htc_vive_focus_3,
htc_vive_xr_elite,
htc_vive_focus_vision,
+2 -2
View File
@@ -727,7 +727,7 @@ void scenes::lobby::gui_settings()
ImGui::EndDisabled();
}
{
ImGui::BeginDisabled(not(application::get_fb_face_tracking2_supported() or application::get_htc_face_tracking_eye_supported() or application::get_htc_face_tracking_lip_supported()));
ImGui::BeginDisabled(not(application::get_fb_face_tracking2_supported() or application::get_htc_face_tracking_eye_supported() or application::get_htc_face_tracking_lip_supported() or application::get_pico_face_tracking_supported()));
bool enabled = config.check_feature(feature::face_tracking);
if (ImGui::Checkbox(_S("Enable face tracking"), &enabled))
{
@@ -1419,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({
.f = feature::face_tracking,
+2
View File
@@ -220,6 +220,8 @@ std::shared_ptr<scenes::stream> scenes::stream::create(std::unique_ptr<wivrn_ses
info.face_tracking = from_headset::face_type::fb2;
else if (application::get_htc_face_tracking_eye_supported() or application::get_htc_face_tracking_lip_supported())
info.face_tracking = from_headset::face_type::htc;
else if (application::get_pico_face_tracking_supported())
info.face_tracking = from_headset::face_type::pico;
}
info.palm_pose = application::space(xr::spaces::palm_left) or application::space(xr::spaces::palm_right);
+7 -1
View File
@@ -248,6 +248,8 @@ void scenes::stream::tracking()
face_tracking = from_headset::face_type::fb2;
else if (application::get_htc_face_tracking_eye_supported() or application::get_htc_face_tracking_lip_supported())
face_tracking = from_headset::face_type::htc;
else if (application::get_pico_face_tracking_supported())
face_tracking = from_headset::face_type::pico;
}
on_interaction_profile_changed({});
@@ -336,7 +338,7 @@ void scenes::stream::tracking()
case wivrn::from_headset::face_type::fb2:
application::get_fb_face_tracker2().get_weights(t0 + Δt, packet.face.emplace());
break;
case wivrn::from_headset::face_type::htc:
case wivrn::from_headset::face_type::htc: {
auto & face_htc = packet.face_htc.emplace();
face_htc.eye_active = false;
face_htc.lip_active = false;
@@ -345,6 +347,10 @@ void scenes::stream::tracking()
if (application::get_htc_face_tracking_lip_supported())
application::get_htc_face_tracker_lip().get_weights(t0 + Δt, face_htc);
break;
}
case wivrn::from_headset::face_type::pico:
application::get_pico_face_tracker().get_weights(t0 + Δt, packet.face_pico.emplace());
break;
}
}
}
+69
View File
@@ -0,0 +1,69 @@
/*
* WiVRn VR streaming
* Copyright (C) 2024 galister <galister@librevr.org>
* Copyright (C) 2025 Sapphire <imsapphire0@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#include "pico_face_tracker.h"
#include "spdlog/common.h"
#include "spdlog/spdlog.h"
#include "wivrn_packets.h"
#include "xr/instance.h"
#include "xr/session.h"
#include "xr/xr.h"
#include <openxr/openxr.h>
xr::pico_face_tracker::pico_face_tracker(instance & inst, session & s_) :
s(s_)
{
xrStartEyeTrackingPICO = inst.get_proc<PFN_xrStartEyeTrackingPICO>("xrStartEyeTrackingPICO");
xrStopEyeTrackingPICO = inst.get_proc<PFN_xrStopEyeTrackingPICO>("xrStopEyeTrackingPICO");
xrSetTrackingModePICO = inst.get_proc<PFN_xrSetTrackingModePICO>("xrSetTrackingModePICO");
xrGetFaceTrackingStatePICO = inst.get_proc<PFN_xrGetFaceTrackingStatePICO>("xrGetFaceTrackingStatePICO");
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()
{
if (auto res = xrStopEyeTrackingPICO(s, XR_TRACKING_MODE_FACE_BIT_PICO); res != XR_SUCCESS)
spdlog::warn("Failed to deactivate face tracking: {}", xr::to_string(res));
}
void xr::pico_face_tracker::get_weights(XrTime time, wivrn::from_headset::tracking::pico_face & out_expressions)
{
if (!xrGetFaceTrackingDataPICO)
return;
XrFaceTrackingDataPICO face_tracking{.time = 0};
if (auto res = xrGetFaceTrackingDataPICO(s, time, XR_GET_FACE_DATA_DEFAULT_PICO, &face_tracking); res != XR_SUCCESS)
{
XrTrackingModeFlagsPICO mode;
XrTrackingStateCodePICO code;
if (xrGetFaceTrackingStatePICO(s, &mode, &code) == XR_SUCCESS)
spdlog::warn("Unable to get face tracking data: xrGetFaceTrackingDataPICO returned {}, tracking mode state {}, flags {}", xr::to_string(res), xr::to_string(code), mode);
else
spdlog::warn("Unable to get face tracking data: xrGetFaceTrackingDataPICO returned {}", xr::to_string(res));
out_expressions.is_valid = false;
return;
}
std::copy_n(face_tracking.blendShapeWeight, std::size(face_tracking.blendShapeWeight), out_expressions.weights.data());
out_expressions.is_valid = face_tracking.time != 0;
}
+49
View File
@@ -0,0 +1,49 @@
/*
* WiVRn VR streaming
* Copyright (C) 2024 galister <galister@librevr.org>
* Copyright (C) 2025 Sapphire <imsapphire0@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#pragma once
#include "wivrn_packets.h"
#include "xr/pico_eye_types.h"
#include "xr/pico_eye_types_reflection.h"
#include <openxr/openxr.h>
namespace xr
{
class instance;
class session;
class pico_face_tracker
{
PFN_xrStartEyeTrackingPICO xrStartEyeTrackingPICO{};
PFN_xrStopEyeTrackingPICO xrStopEyeTrackingPICO{};
PFN_xrSetTrackingModePICO xrSetTrackingModePICO{};
PFN_xrGetFaceTrackingStatePICO xrGetFaceTrackingStatePICO{};
PFN_xrGetFaceTrackingDataPICO xrGetFaceTrackingDataPICO{};
XrSession s;
public:
pico_face_tracker() = default;
pico_face_tracker(instance & inst, session & s);
~pico_face_tracker();
void get_weights(XrTime time, struct wivrn::from_headset::tracking::pico_face & out_expressions);
};
} // namespace xr
+6
View File
@@ -136,6 +136,12 @@ xr::htc_face_tracker xr::session::create_htc_face_tracker(XrFacialTrackingTypeHT
CHECK_XR(xrCreateFacialTrackerHTC(id, &create_info, &ft));
return {*inst, ft, facialTrackingType};
}
xr::pico_face_tracker xr::session::create_pico_face_tracker()
{
return {*inst, *this};
}
std::vector<vk::Format> xr::session::get_swapchain_formats() const
{
std::vector<vk::Format> formats;
+2
View File
@@ -30,6 +30,7 @@
#include "hand_tracker.h"
#include "htc_face_tracker.h"
#include "passthrough.h"
#include "pico_face_tracker.h"
#include "space.h"
namespace xr
@@ -52,6 +53,7 @@ public:
hand_tracker create_hand_tracker(XrHandEXT hand, XrHandJointSetEXT hand_joint_set = XR_HAND_JOINT_SET_DEFAULT_EXT);
fb_face_tracker2 create_fb_face_tracker2();
htc_face_tracker create_htc_face_tracker(XrFacialTrackingTypeHTC);
pico_face_tracker create_pico_face_tracker();
std::vector<vk::Format> get_swapchain_formats() const;
+4
View File
@@ -26,6 +26,8 @@
#include "swapchain.h"
#include "system.h"
#include "xr/check.h"
#include "xr/pico_eye_types.h"
#include "xr/pico_eye_types_reflection.h"
#include <cstddef>
#include <string>
@@ -56,6 +58,8 @@ XR_ENUM_STR(XrSessionState);
XR_ENUM_STR(XrObjectType);
XR_ENUM_STR(XrStructureType);
XR_ENUM_STR(XrTrackingStateCodePICO);
std::string to_string(XrVersion version);
} // namespace xr