mirror of
https://gitlab.freedesktop.org/monado/monado.git
synced 2025-01-29 09:58:32 +00:00
d/ht: use new ht_model API
This commit is contained in:
parent
0e53b3b87f
commit
ee45be6f7b
|
@ -17,6 +17,7 @@
|
||||||
#include "ht_driver.hpp"
|
#include "ht_driver.hpp"
|
||||||
#include "ht_hand_math.hpp"
|
#include "ht_hand_math.hpp"
|
||||||
#include "ht_image_math.hpp"
|
#include "ht_image_math.hpp"
|
||||||
|
#include "ht_model.hpp"
|
||||||
#include "templates/NaivePermutationSort.hpp"
|
#include "templates/NaivePermutationSort.hpp"
|
||||||
|
|
||||||
// Flags to tell state tracker that these are indeed valid joints
|
// Flags to tell state tracker that these are indeed valid joints
|
||||||
|
@ -59,15 +60,15 @@ errHistory2D(HandHistory2DBBox *past, Palm7KP *present)
|
||||||
static std::vector<Hand2D>
|
static std::vector<Hand2D>
|
||||||
htImageToKeypoints(struct ht_view *htv)
|
htImageToKeypoints(struct ht_view *htv)
|
||||||
{
|
{
|
||||||
int view = htv->view;
|
|
||||||
struct ht_device *htd = htv->htd;
|
struct ht_device *htd = htv->htd;
|
||||||
|
ht_model *htm = htv->htm;
|
||||||
|
|
||||||
cv::Mat raw_input = htv->run_model_on_this;
|
cv::Mat raw_input = htv->run_model_on_this;
|
||||||
|
|
||||||
// Get a list of palms - drop confidences and ssd bounding boxes, just keypoints.
|
// Get a list of palms - drop confidences and ssd bounding boxes, just keypoints.
|
||||||
|
|
||||||
std::vector<Palm7KP> hand_detections = htv->run_detection_model(htv, raw_input);
|
|
||||||
|
std::vector<Palm7KP> hand_detections = htm->palm_detection(htv, raw_input);
|
||||||
|
|
||||||
std::vector<bool> used_histories;
|
std::vector<bool> used_histories;
|
||||||
std::vector<bool> used_detections;
|
std::vector<bool> used_detections;
|
||||||
|
@ -131,11 +132,6 @@ htImageToKeypoints(struct ht_view *htv)
|
||||||
return {}; // bail early
|
return {}; // bail early
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
std::vector<Hand2D> list_of_hands_in_bbox(
|
|
||||||
htv->bbox_histories.size()); // all of these are same size as htv->bbox_histories
|
|
||||||
|
|
||||||
std::vector<std::future<Hand2D>> await_list_of_hand_in_bbox; //(htv->bbox_histories.size());
|
std::vector<std::future<Hand2D>> await_list_of_hand_in_bbox; //(htv->bbox_histories.size());
|
||||||
|
|
||||||
std::vector<DetectionModelOutput> blah(htv->bbox_histories.size());
|
std::vector<DetectionModelOutput> blah(htv->bbox_histories.size());
|
||||||
|
@ -146,14 +142,12 @@ htImageToKeypoints(struct ht_view *htv)
|
||||||
HT_DEBUG(htd, "More than two hands (%zu) in 2D view %i", htv->bbox_histories.size(), htv->view);
|
HT_DEBUG(htd, "More than two hands (%zu) in 2D view %i", htv->bbox_histories.size(), htv->view);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
for (size_t i = 0; i < htv->bbox_histories.size(); i++) { //(BBoxHistory * entry : htv->bbox_histories) {
|
for (size_t i = 0; i < htv->bbox_histories.size(); i++) { //(BBoxHistory * entry : htv->bbox_histories) {
|
||||||
HandHistory2DBBox *entry = &htv->bbox_histories[i];
|
HandHistory2DBBox *entry = &htv->bbox_histories[i];
|
||||||
cv::Mat hand_rect = cv::Mat(224, 224, CV_8UC3);
|
cv::Mat hand_rect = cv::Mat(224, 224, CV_8UC3);
|
||||||
xrt_vec2 unfiltered_middle;
|
xrt_vec2 unfiltered_middle;
|
||||||
xrt_vec2 unfiltered_direction;
|
xrt_vec2 unfiltered_direction;
|
||||||
|
|
||||||
|
|
||||||
centerAndRotationFromJoints(htv, entry->wrist_unfiltered[0], entry->index_unfiltered[0],
|
centerAndRotationFromJoints(htv, entry->wrist_unfiltered[0], entry->index_unfiltered[0],
|
||||||
entry->middle_unfiltered[0], entry->pinky_unfiltered[0], &unfiltered_middle,
|
entry->middle_unfiltered[0], entry->pinky_unfiltered[0], &unfiltered_middle,
|
||||||
&unfiltered_direction);
|
&unfiltered_direction);
|
||||||
|
@ -171,13 +165,10 @@ htImageToKeypoints(struct ht_view *htv)
|
||||||
warpAffine(raw_input, hand_rect, blah[i].warp_there, hand_rect.size());
|
warpAffine(raw_input, hand_rect, blah[i].warp_there, hand_rect.size());
|
||||||
|
|
||||||
await_list_of_hand_in_bbox.push_back(
|
await_list_of_hand_in_bbox.push_back(
|
||||||
std::async(std::launch::async, htd->views[view].run_keypoint_model, &htd->views[view], hand_rect));
|
std::async(std::launch::async, std::bind(&ht_model::hand_landmark, htm, hand_rect)));
|
||||||
}
|
}
|
||||||
|
|
||||||
// cut here
|
|
||||||
|
|
||||||
for (size_t i = 0; i < htv->bbox_histories.size(); i++) {
|
for (size_t i = 0; i < htv->bbox_histories.size(); i++) {
|
||||||
|
|
||||||
Hand2D in_bbox = await_list_of_hand_in_bbox[i].get();
|
Hand2D in_bbox = await_list_of_hand_in_bbox[i].get();
|
||||||
|
|
||||||
cv::Matx23f warp_back = blah[i].warp_back;
|
cv::Matx23f warp_back = blah[i].warp_back;
|
||||||
|
@ -212,7 +203,6 @@ htImageToKeypoints(struct ht_view *htv)
|
||||||
xrt_vec2 dontuse;
|
xrt_vec2 dontuse;
|
||||||
|
|
||||||
xrt_vec2 unfiltered_middle, unfiltered_direction;
|
xrt_vec2 unfiltered_middle, unfiltered_direction;
|
||||||
|
|
||||||
centerAndRotationFromJoints(htv, &wrist_in_px_coords, &index_in_px_coords, &middle_in_px_coords,
|
centerAndRotationFromJoints(htv, &wrist_in_px_coords, &index_in_px_coords, &middle_in_px_coords,
|
||||||
&little_in_px_coords, &unfiltered_middle, &unfiltered_direction);
|
&little_in_px_coords, &unfiltered_middle, &unfiltered_direction);
|
||||||
|
|
||||||
|
|
|
@ -40,6 +40,7 @@
|
||||||
#include "tracking/t_calibration_opencv.hpp"
|
#include "tracking/t_calibration_opencv.hpp"
|
||||||
|
|
||||||
#include "ht_algorithm.hpp"
|
#include "ht_algorithm.hpp"
|
||||||
|
#include "ht_model.hpp"
|
||||||
#include "ht_models.hpp"
|
#include "ht_models.hpp"
|
||||||
|
|
||||||
#include <cjson/cJSON.h>
|
#include <cjson/cJSON.h>
|
||||||
|
@ -618,6 +619,9 @@ ht_device_destroy(struct xrt_device *xdev)
|
||||||
// constructor/destructor for ht_device), so we just manually call the destructors for things like std::vector's
|
// constructor/destructor for ht_device), so we just manually call the destructors for things like std::vector's
|
||||||
// that need their destructors to be called to not leak.
|
// that need their destructors to be called to not leak.
|
||||||
|
|
||||||
|
delete htd->views[0].htm;
|
||||||
|
delete htd->views[1].htm;
|
||||||
|
|
||||||
u_device_free(&htd->base);
|
u_device_free(&htd->base);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -674,10 +678,12 @@ ht_device_create(struct xrt_prober *xp, struct t_stereo_camera_calibration *cali
|
||||||
htd->views[0].htd = htd;
|
htd->views[0].htd = htd;
|
||||||
htd->views[1].htd = htd; // :)
|
htd->views[1].htd = htd; // :)
|
||||||
|
|
||||||
|
htd->views[0].htm = new ht_model(htd);
|
||||||
|
htd->views[1].htm = new ht_model(htd);
|
||||||
|
|
||||||
htd->views[0].view = 0;
|
htd->views[0].view = 0;
|
||||||
htd->views[1].view = 1;
|
htd->views[1].view = 1;
|
||||||
|
|
||||||
|
|
||||||
initOnnx(htd);
|
initOnnx(htd);
|
||||||
|
|
||||||
htd->base.tracking_origin = &htd->tracking_origin;
|
htd->base.tracking_origin = &htd->tracking_origin;
|
||||||
|
|
|
@ -80,6 +80,8 @@ using namespace xrt::auxiliary::util;
|
||||||
#define FCMIN_D_HAND 12.0f
|
#define FCMIN_D_HAND 12.0f
|
||||||
#define BETA_HAND 0.05f
|
#define BETA_HAND 0.05f
|
||||||
|
|
||||||
|
class ht_model;
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
@ -220,6 +222,7 @@ struct ht_device;
|
||||||
struct ht_view
|
struct ht_view
|
||||||
{
|
{
|
||||||
ht_device *htd;
|
ht_device *htd;
|
||||||
|
ht_model *htm;
|
||||||
int view; // :)))
|
int view; // :)))
|
||||||
|
|
||||||
// Loaded from config file
|
// Loaded from config file
|
||||||
|
|
Loading…
Reference in a new issue