The open source OpenXR runtime
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

t/slam: Push hand masks to tracker

authored by

Mateo de Mayo and committed by
Simon Zeni
eadc592c e79d2d39

+36 -17
+18 -9
src/xrt/auxiliary/tracking/t_tracker_slam.cpp
··· 1380 1380 default: SLAM_ERROR("Unknown image format"); return; 1381 1381 } 1382 1382 1383 + xrt_hand_masks_sample hand_masks{}; 1383 1384 { 1384 1385 unique_lock lock(t.last_hand_masks_mutex); 1385 - for (auto &view : t.last_hand_masks.views) { 1386 - if (!view.enabled) { 1386 + hand_masks = t.last_hand_masks; 1387 + } 1388 + 1389 + auto &view = hand_masks.views[cam_index]; 1390 + std::vector<vit_mask_t> masks; 1391 + if (view.enabled) { 1392 + for (auto &hand : view.hands) { 1393 + if (!hand.enabled) { 1387 1394 continue; 1388 1395 } 1396 + vit_mask_t mask{}; 1397 + mask.x = hand.rect.x; 1398 + mask.y = hand.rect.y; 1399 + mask.w = hand.rect.w; 1400 + mask.h = hand.rect.h; 1401 + masks.push_back(mask); 1402 + } 1389 1403 1390 - for (auto &hand : view.hands) { 1391 - if (!hand.enabled) { 1392 - continue; 1393 - } 1394 - // TODO@mateosss: add_mask(hand.rect); 1395 - } 1396 - }; 1404 + sample.mask_count = masks.size(); 1405 + sample.masks = masks.empty() ? nullptr : masks.data(); 1397 1406 } 1398 1407 1399 1408 {
+12
src/xrt/include/xrt/xrt_defines.h
··· 392 392 }; 393 393 394 394 /*! 395 + * Image rectangle 396 + * 397 + * @todo Unify xrt_rect and xrt_rect_f32 field names 398 + * 399 + * @ingroup xrt_iface math 400 + */ 401 + struct xrt_rect_f32 402 + { 403 + float x, y, w, h; 404 + }; 405 + 406 + /*! 395 407 * Normalized image rectangle, coordinates and size in 0 .. 1 range. 396 408 * 397 409 * @ingroup xrt_iface math
+2 -2
src/xrt/include/xrt/xrt_tracking.h
··· 149 149 bool enabled; //!< Whether any hand mask for this camera is being reported 150 150 struct xrt_hand_masks_sample_hand 151 151 { 152 - bool enabled; //!< Whether a mask for this hand is being reported 153 - struct xrt_rect rect; //!< The mask itself in pixel coordinates 152 + bool enabled; //!< Whether a mask for this hand is being reported 153 + struct xrt_rect_f32 rect; //!< The mask itself in pixel coordinates 154 154 } hands[2]; 155 155 } views[XRT_TRACKING_MAX_SLAM_CAMS]; 156 156 };
+4 -6
src/xrt/tracking/hand/mercury/hg_sync.cpp
··· 572 572 hroi.provenance = ROIProvenance::POSE_PREDICTION; 573 573 hroi.found = true; 574 574 575 - xrt_vec2 &center = hroi.center_px; 576 - float &size = hroi.size_px; 577 - masks_hand.rect.offset.w = int(center.x - size / 2); 578 - masks_hand.rect.offset.h = int(center.y - size / 2); 579 - masks_hand.rect.extent.w = int(size); 580 - masks_hand.rect.extent.h = int(size); 575 + const float SCALER = 1.25f; 576 + float s = hroi.size_px * SCALER; 577 + xrt_vec2 &c = hroi.center_px; 578 + masks_hand.rect = xrt_rect_f32{c.x - s / 2, c.y - s / 2, s, s}; 581 579 masks_hand.enabled = true; 582 580 } else { 583 581 hroi.found = false;