Skip to content

Commit

Permalink
More occluded area tracker settings
Browse files Browse the repository at this point in the history
  • Loading branch information
Timocop committed Dec 21, 2021
1 parent ea2b3d8 commit c090a0e
Show file tree
Hide file tree
Showing 5 changed files with 75 additions and 19 deletions.
49 changes: 44 additions & 5 deletions src/psmoveconfigtool/AppStage_AdvancedSettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,9 @@ TrackerConfig::config2ptree()
pt.put("excluded_opposed_cameras", exclude_opposed_cameras);

pt.put("min_valid_projection_area", min_valid_projection_area);
pt.put("min_occluded_area_on_loss", min_occluded_area_on_loss);
pt.put("occluded_area_on_loss_size", occluded_area_on_loss_size);
pt.put("occluded_area_ignore_trackers", occluded_area_ignore_trackers);
pt.put("occluded_area_regain_projection_size", occluded_area_regain_projection_size);
pt.put("min_points_in_contour", min_points_in_contour);
pt.put("max_tracker_position_deviation", max_tracker_position_deviation);

Expand Down Expand Up @@ -260,7 +262,9 @@ TrackerConfig::ptree2config(const boost::property_tree::ptree &pt)
exclude_opposed_cameras = pt.get<bool>("excluded_opposed_cameras", exclude_opposed_cameras);

min_valid_projection_area = pt.get<float>("min_valid_projection_area", min_valid_projection_area);
min_occluded_area_on_loss = pt.get<float>("min_occluded_area_on_loss", min_occluded_area_on_loss);
occluded_area_on_loss_size = pt.get<float>("occluded_area_on_loss_size", occluded_area_on_loss_size);
occluded_area_ignore_trackers = pt.get<int>("occluded_area_ignore_trackers", occluded_area_ignore_trackers);
occluded_area_regain_projection_size = pt.get<float>("occluded_area_regain_projection_size", occluded_area_regain_projection_size);
min_points_in_contour = pt.get<int>("min_points_in_contour", min_points_in_contour);
max_tracker_position_deviation = pt.get<float>("max_tracker_position_deviation", max_tracker_position_deviation);

Expand Down Expand Up @@ -618,12 +622,12 @@ void AppStage_AdvancedSettings::renderUI()
}

{
ImGui::Text("Minimum occluded area on tracking loss:");
ImGui::Text("Occluded area size on tracking loss:");
ImGui::SameLine(ImGui::GetWindowWidth() - 150.f);
ImGui::PushItemWidth(100.f);
if (ImGui::InputFloat("##MinimumOccludedAreaOnLoss", &cfg_tracker.min_occluded_area_on_loss, 1.f, 4.f, 2))
if (ImGui::InputFloat("##OccludedAreaOnLossSize", &cfg_tracker.occluded_area_on_loss_size, 1.f, 4.f, 2))
{
cfg_tracker.min_occluded_area_on_loss = static_cast<float>(std::fmax(0.f, std::fmin(99999.f, cfg_tracker.min_occluded_area_on_loss)));
cfg_tracker.occluded_area_on_loss_size = static_cast<float>(std::fmax(0.f, std::fmin(99999.f, cfg_tracker.occluded_area_on_loss_size)));
}
ImGui::PopItemWidth();

Expand All @@ -636,6 +640,41 @@ void AppStage_AdvancedSettings::renderUI()
);
}

{
ImGui::Text("Occluded area number of ignored trackers:");
ImGui::SameLine(ImGui::GetWindowWidth() - 150.f);
ImGui::PushItemWidth(100.f);
if (ImGui::InputInt("##OccludedAreaIgnoreTrackers", &cfg_tracker.occluded_area_ignore_trackers, 1, 5))
{
cfg_tracker.occluded_area_ignore_trackers = static_cast<int>(std::fmax(0.f, std::fmin(99999.f, cfg_tracker.occluded_area_ignore_trackers)));
}
ImGui::PopItemWidth();

if (ImGui::IsItemHovered())
ImGui::SetTooltip(
"The number of trackers that will ignore occluded areas (sorted by biggest projection).\n"
"(The default value is 0)"
);
}

{
ImGui::Text("Occluded area regain projection size:");
ImGui::SameLine(ImGui::GetWindowWidth() - 150.f);
ImGui::PushItemWidth(100.f);
if (ImGui::InputFloat("##OccludedAreaRegainProjectionSize", &cfg_tracker.occluded_area_regain_projection_size, 1.f, 4.f, 2))
{
cfg_tracker.occluded_area_regain_projection_size = static_cast<float>(std::fmax(0.f, std::fmin(99999.f, cfg_tracker.occluded_area_regain_projection_size)));
}
ImGui::PopItemWidth();

if (ImGui::IsItemHovered())
ImGui::SetTooltip(
"The tracker will regain the projection and remove its occlusion\n"
"if the projection size is bigger than the giving value.\n"
"(The default value is 16)"
);
}

{
ImGui::Text("Minimum points in contour:");
ImGui::SameLine(ImGui::GetWindowWidth() - 150.f);
Expand Down
10 changes: 7 additions & 3 deletions src/psmoveconfigtool/AppStage_AdvancedSettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,17 @@ class TrackerConfig : public PSMoveConfig

virtual_tracker_count = 0;
controller_position_smoothing = 0.f;
controller_position_prediction = 0.0f;
controller_position_prediction = 0.f;
controller_position_prediction_history = 5;
ignore_pose_from_one_tracker = true;
optical_tracking_timeout = 100;
tracker_sleep_ms = 1;
use_bgr_to_hsv_lookup_table = true;
exclude_opposed_cameras = false;
min_valid_projection_area = 6;
min_occluded_area_on_loss = 4;
occluded_area_on_loss_size = 4.f;
occluded_area_ignore_trackers = 0;
occluded_area_regain_projection_size = 16.f;
min_points_in_contour = 4;
max_tracker_position_deviation = 12.0f;
disable_roi = false;
Expand All @@ -70,7 +72,9 @@ class TrackerConfig : public PSMoveConfig
bool use_bgr_to_hsv_lookup_table;
bool exclude_opposed_cameras;
float min_valid_projection_area;
float min_occluded_area_on_loss;
float occluded_area_on_loss_size;
int occluded_area_ignore_trackers;
float occluded_area_regain_projection_size;
int min_points_in_contour;
float max_tracker_position_deviation;
bool disable_roi;
Expand Down
12 changes: 9 additions & 3 deletions src/psmoveservice/Device/Manager/TrackerManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ TrackerManagerConfig::TrackerManagerConfig(const std::string &fnamebase)
use_bgr_to_hsv_lookup_table = true;
exclude_opposed_cameras = false;
min_valid_projection_area = 6;
min_occluded_area_on_loss = 4;
occluded_area_on_loss_size = 4.f;
occluded_area_ignore_trackers = 0;
occluded_area_regain_projection_size = 16.f;
min_points_in_contour = 4;
max_tracker_position_deviation = 12.0f;
disable_roi = false;
Expand Down Expand Up @@ -68,7 +70,9 @@ TrackerManagerConfig::config2ptree()
pt.put("excluded_opposed_cameras", exclude_opposed_cameras);

pt.put("min_valid_projection_area", min_valid_projection_area);
pt.put("min_occluded_area_on_loss", min_occluded_area_on_loss);
pt.put("occluded_area_on_loss_size", occluded_area_on_loss_size);
pt.put("occluded_area_ignore_trackers", occluded_area_ignore_trackers);
pt.put("occluded_area_regain_projection_size", occluded_area_regain_projection_size);
pt.put("min_points_in_contour", min_points_in_contour);
pt.put("max_tracker_position_deviation", max_tracker_position_deviation);

Expand Down Expand Up @@ -107,7 +111,9 @@ TrackerManagerConfig::ptree2config(const boost::property_tree::ptree &pt)
exclude_opposed_cameras = pt.get<bool>("excluded_opposed_cameras", exclude_opposed_cameras);

min_valid_projection_area = pt.get<float>("min_valid_projection_area", min_valid_projection_area);
min_occluded_area_on_loss = pt.get<float>("min_occluded_area_on_loss", min_occluded_area_on_loss);
occluded_area_on_loss_size = pt.get<float>("occluded_area_on_loss_size", occluded_area_on_loss_size);
occluded_area_ignore_trackers = pt.get<int>("occluded_area_ignore_trackers", occluded_area_ignore_trackers);
occluded_area_regain_projection_size = pt.get<float>("occluded_area_regain_projection_size", occluded_area_regain_projection_size);
min_points_in_contour = pt.get<int>("min_points_in_contour", min_points_in_contour);
max_tracker_position_deviation = pt.get<float>("max_tracker_position_deviation", max_tracker_position_deviation);

Expand Down
4 changes: 3 additions & 1 deletion src/psmoveservice/Device/Manager/TrackerManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,9 @@ class TrackerManagerConfig : public PSMoveConfig
bool use_bgr_to_hsv_lookup_table;
bool exclude_opposed_cameras;
float min_valid_projection_area;
float min_occluded_area_on_loss;
float occluded_area_on_loss_size;
int occluded_area_ignore_trackers;
float occluded_area_regain_projection_size;
int min_points_in_contour;
float max_tracker_position_deviation;
bool disable_roi;
Expand Down
19 changes: 12 additions & 7 deletions src/psmoveservice/Device/View/ServerControllerView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -555,7 +555,7 @@ void ServerControllerView::updateOpticalPoseEstimation(TrackerManager* tracker_m
//Create an occlusion area at the last seen valid tracked projection.
//If the projection center is near the occluded area it will not mark the projection as valid.
//This will remove jitter when the shape of the controllers is partially visible to the trackers.
if (trackerMgrConfig.min_occluded_area_on_loss >= 0.01)
if (trackerMgrConfig.occluded_area_on_loss_size >= 0.01)
{
int controller_id = this->getDeviceID();

Expand All @@ -577,14 +577,19 @@ void ServerControllerView::updateOpticalPoseEstimation(TrackerManager* tracker_m
{
if (bWasTracking || bIsVisibleThisUpdate)
{
if (abs(trackerPoseEstimateRef.projection.shape.ellipse.center.x - occluded_projection_tracker_ids[tracker_id][controller_id][0])
< trackerMgrConfig.min_occluded_area_on_loss
&& abs(trackerPoseEstimateRef.projection.shape.ellipse.center.y - occluded_projection_tracker_ids[tracker_id][controller_id][1])
< trackerMgrConfig.min_occluded_area_on_loss)
bool bInArea = (abs(trackerPoseEstimateRef.projection.shape.ellipse.center.x - occluded_projection_tracker_ids[tracker_id][controller_id][0])
< trackerMgrConfig.occluded_area_on_loss_size
&& abs(trackerPoseEstimateRef.projection.shape.ellipse.center.y - occluded_projection_tracker_ids[tracker_id][controller_id][1])
< trackerMgrConfig.occluded_area_on_loss_size);

bool bRegain = (fmaxf(trackerPoseEstimateRef.projection.screen_area, trackerMgrConfig.min_valid_projection_area)
> trackerMgrConfig.occluded_area_regain_projection_size);

if (bInArea && !bRegain)
{
bIsOccluded = true;

trackerPoseEstimateRef.occlusionAreaSize = trackerMgrConfig.min_occluded_area_on_loss;
trackerPoseEstimateRef.occlusionAreaSize = trackerMgrConfig.occluded_area_on_loss_size;
trackerPoseEstimateRef.occlusionAreaPos.x = occluded_projection_tracker_ids[tracker_id][controller_id][0];
trackerPoseEstimateRef.occlusionAreaPos.y = occluded_projection_tracker_ids[tracker_id][controller_id][1];
}
Expand All @@ -597,7 +602,7 @@ void ServerControllerView::updateOpticalPoseEstimation(TrackerManager* tracker_m
}

// Ignore projections that are occluded BUT always pass atleast 2 biggest projected trackers.
if (!bIsOccluded || projections_found < 2)
if (!bIsOccluded || projections_found < trackerMgrConfig.occluded_area_ignore_trackers)
{
bOccluded = false;

Expand Down

0 comments on commit c090a0e

Please sign in to comment.