mirror of
https://gitlab.freedesktop.org/monado/monado.git
synced 2025-01-29 01:48:31 +00:00
t/slam: Push hand masks to tracker
This commit is contained in:
parent
e79d2d395f
commit
eadc592c04
|
@ -1380,20 +1380,29 @@ receive_frame(TrackerSlam &t, struct xrt_frame *frame, uint32_t cam_index)
|
||||||
default: SLAM_ERROR("Unknown image format"); return;
|
default: SLAM_ERROR("Unknown image format"); return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
xrt_hand_masks_sample hand_masks{};
|
||||||
{
|
{
|
||||||
unique_lock lock(t.last_hand_masks_mutex);
|
unique_lock lock(t.last_hand_masks_mutex);
|
||||||
for (auto &view : t.last_hand_masks.views) {
|
hand_masks = t.last_hand_masks;
|
||||||
if (!view.enabled) {
|
}
|
||||||
|
|
||||||
|
auto &view = hand_masks.views[cam_index];
|
||||||
|
std::vector<vit_mask_t> masks;
|
||||||
|
if (view.enabled) {
|
||||||
|
for (auto &hand : view.hands) {
|
||||||
|
if (!hand.enabled) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
vit_mask_t mask{};
|
||||||
|
mask.x = hand.rect.x;
|
||||||
|
mask.y = hand.rect.y;
|
||||||
|
mask.w = hand.rect.w;
|
||||||
|
mask.h = hand.rect.h;
|
||||||
|
masks.push_back(mask);
|
||||||
|
}
|
||||||
|
|
||||||
for (auto &hand : view.hands) {
|
sample.mask_count = masks.size();
|
||||||
if (!hand.enabled) {
|
sample.masks = masks.empty() ? nullptr : masks.data();
|
||||||
continue;
|
|
||||||
}
|
|
||||||
// TODO@mateosss: add_mask(hand.rect);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
|
|
|
@ -391,6 +391,18 @@ struct xrt_rect
|
||||||
struct xrt_size extent;
|
struct xrt_size extent;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Image rectangle
|
||||||
|
*
|
||||||
|
* @todo Unify xrt_rect and xrt_rect_f32 field names
|
||||||
|
*
|
||||||
|
* @ingroup xrt_iface math
|
||||||
|
*/
|
||||||
|
struct xrt_rect_f32
|
||||||
|
{
|
||||||
|
float x, y, w, h;
|
||||||
|
};
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Normalized image rectangle, coordinates and size in 0 .. 1 range.
|
* Normalized image rectangle, coordinates and size in 0 .. 1 range.
|
||||||
*
|
*
|
||||||
|
|
|
@ -149,8 +149,8 @@ struct xrt_hand_masks_sample
|
||||||
bool enabled; //!< Whether any hand mask for this camera is being reported
|
bool enabled; //!< Whether any hand mask for this camera is being reported
|
||||||
struct xrt_hand_masks_sample_hand
|
struct xrt_hand_masks_sample_hand
|
||||||
{
|
{
|
||||||
bool enabled; //!< Whether a mask for this hand is being reported
|
bool enabled; //!< Whether a mask for this hand is being reported
|
||||||
struct xrt_rect rect; //!< The mask itself in pixel coordinates
|
struct xrt_rect_f32 rect; //!< The mask itself in pixel coordinates
|
||||||
} hands[2];
|
} hands[2];
|
||||||
} views[XRT_TRACKING_MAX_SLAM_CAMS];
|
} views[XRT_TRACKING_MAX_SLAM_CAMS];
|
||||||
};
|
};
|
||||||
|
|
|
@ -572,12 +572,10 @@ predict_new_regions_of_interest(struct HandTracking *hgt)
|
||||||
hroi.provenance = ROIProvenance::POSE_PREDICTION;
|
hroi.provenance = ROIProvenance::POSE_PREDICTION;
|
||||||
hroi.found = true;
|
hroi.found = true;
|
||||||
|
|
||||||
xrt_vec2 ¢er = hroi.center_px;
|
const float SCALER = 1.25f;
|
||||||
float &size = hroi.size_px;
|
float s = hroi.size_px * SCALER;
|
||||||
masks_hand.rect.offset.w = int(center.x - size / 2);
|
xrt_vec2 &c = hroi.center_px;
|
||||||
masks_hand.rect.offset.h = int(center.y - size / 2);
|
masks_hand.rect = xrt_rect_f32{c.x - s / 2, c.y - s / 2, s, s};
|
||||||
masks_hand.rect.extent.w = int(size);
|
|
||||||
masks_hand.rect.extent.h = int(size);
|
|
||||||
masks_hand.enabled = true;
|
masks_hand.enabled = true;
|
||||||
} else {
|
} else {
|
||||||
hroi.found = false;
|
hroi.found = false;
|
||||||
|
|
Loading…
Reference in a new issue