mirror of
https://gitlab.freedesktop.org/monado/monado.git
synced 2025-01-16 03:45:24 +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;
|
||||
}
|
||||
|
||||
xrt_hand_masks_sample hand_masks{};
|
||||
{
|
||||
unique_lock lock(t.last_hand_masks_mutex);
|
||||
for (auto &view : t.last_hand_masks.views) {
|
||||
if (!view.enabled) {
|
||||
hand_masks = t.last_hand_masks;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
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) {
|
||||
if (!hand.enabled) {
|
||||
continue;
|
||||
}
|
||||
// TODO@mateosss: add_mask(hand.rect);
|
||||
}
|
||||
};
|
||||
sample.mask_count = masks.size();
|
||||
sample.masks = masks.empty() ? nullptr : masks.data();
|
||||
}
|
||||
|
||||
{
|
||||
|
|
|
@ -391,6 +391,18 @@ struct xrt_rect
|
|||
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.
|
||||
*
|
||||
|
|
|
@ -149,8 +149,8 @@ struct xrt_hand_masks_sample
|
|||
bool enabled; //!< Whether any hand mask for this camera is being reported
|
||||
struct xrt_hand_masks_sample_hand
|
||||
{
|
||||
bool enabled; //!< Whether a mask for this hand is being reported
|
||||
struct xrt_rect rect; //!< The mask itself in pixel coordinates
|
||||
bool enabled; //!< Whether a mask for this hand is being reported
|
||||
struct xrt_rect_f32 rect; //!< The mask itself in pixel coordinates
|
||||
} hands[2];
|
||||
} views[XRT_TRACKING_MAX_SLAM_CAMS];
|
||||
};
|
||||
|
|
|
@ -572,12 +572,10 @@ predict_new_regions_of_interest(struct HandTracking *hgt)
|
|||
hroi.provenance = ROIProvenance::POSE_PREDICTION;
|
||||
hroi.found = true;
|
||||
|
||||
xrt_vec2 ¢er = hroi.center_px;
|
||||
float &size = hroi.size_px;
|
||||
masks_hand.rect.offset.w = int(center.x - size / 2);
|
||||
masks_hand.rect.offset.h = int(center.y - size / 2);
|
||||
masks_hand.rect.extent.w = int(size);
|
||||
masks_hand.rect.extent.h = int(size);
|
||||
const float SCALER = 1.25f;
|
||||
float s = hroi.size_px * SCALER;
|
||||
xrt_vec2 &c = hroi.center_px;
|
||||
masks_hand.rect = xrt_rect_f32{c.x - s / 2, c.y - s / 2, s, s};
|
||||
masks_hand.enabled = true;
|
||||
} else {
|
||||
hroi.found = false;
|
||||
|
|
Loading…
Reference in a new issue