Prevent eye gaze extrapolation
This commit is contained in:
@@ -100,7 +100,24 @@ public:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sample get_at(XrTime timestamp)
|
std::pair<XrTime, XrTime> get_bounds() const
|
||||||
|
{
|
||||||
|
std::pair<XrTime, XrTime> result{
|
||||||
|
std::numeric_limits<XrTime>::max(),
|
||||||
|
std::numeric_limits<XrTime>::lowest(),
|
||||||
|
};
|
||||||
|
for (const auto & sample: data)
|
||||||
|
{
|
||||||
|
if (sample.y)
|
||||||
|
{
|
||||||
|
result.first = std::min(result.first, sample.timestamp);
|
||||||
|
result.second = std::max(result.second, sample.timestamp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
sample get_at(XrTime timestamp) const
|
||||||
{
|
{
|
||||||
Eigen::Matrix<float, 2 * stored_samples, polynomial_order + 1> A;
|
Eigen::Matrix<float, 2 * stored_samples, polynomial_order + 1> A;
|
||||||
Eigen::Matrix<float, 2 * stored_samples, N> b;
|
Eigen::Matrix<float, 2 * stored_samples, N> b;
|
||||||
|
|||||||
@@ -100,6 +100,11 @@ pose_list::pose_list(wivrn::device_id id) : device(id)
|
|||||||
dumper.emplace(dump);
|
dumper.emplace(dump);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::pair<XrTime, XrTime> pose_list::get_bounds() const
|
||||||
|
{
|
||||||
|
return positions.get_bounds();
|
||||||
|
}
|
||||||
|
|
||||||
void pose_list::update_tracking(const from_headset::tracking & tracking, const clock_offset & offset)
|
void pose_list::update_tracking(const from_headset::tracking & tracking, const clock_offset & offset)
|
||||||
{
|
{
|
||||||
if (source)
|
if (source)
|
||||||
|
|||||||
@@ -63,6 +63,8 @@ public:
|
|||||||
|
|
||||||
pose_list(wivrn::device_id id);
|
pose_list(wivrn::device_id id);
|
||||||
|
|
||||||
|
std::pair<XrTime, XrTime> get_bounds() const;
|
||||||
|
|
||||||
void update_tracking(const wivrn::from_headset::tracking &, const clock_offset & offset);
|
void update_tracking(const wivrn::from_headset::tracking &, const clock_offset & offset);
|
||||||
void set_derived(pose_list * source, xrt_pose offset, bool force = false);
|
void set_derived(pose_list * source, xrt_pose offset, bool force = false);
|
||||||
|
|
||||||
|
|||||||
@@ -72,6 +72,8 @@ xrt_result_t wivrn_eye_tracker::get_tracked_pose(xrt_input_name name, int64_t at
|
|||||||
{
|
{
|
||||||
if (name == XRT_INPUT_GENERIC_EYE_GAZE_POSE)
|
if (name == XRT_INPUT_GENERIC_EYE_GAZE_POSE)
|
||||||
{
|
{
|
||||||
|
if (auto [min, max] = gaze.get_bounds(); min <= max)
|
||||||
|
at_timestamp_ns = std::clamp(at_timestamp_ns, min, max);
|
||||||
auto [production_timestamp, relation] = gaze.get_at(at_timestamp_ns);
|
auto [production_timestamp, relation] = gaze.get_at(at_timestamp_ns);
|
||||||
*out_relation = relation;
|
*out_relation = relation;
|
||||||
cnx.add_tracking_request(device_id::EYE_GAZE, at_timestamp_ns, production_timestamp);
|
cnx.add_tracking_request(device_id::EYE_GAZE, at_timestamp_ns, production_timestamp);
|
||||||
|
|||||||
Reference in New Issue
Block a user