diff --git a/src/psmoveconfigtool/AppStage_AdvancedSettings.cpp b/src/psmoveconfigtool/AppStage_AdvancedSettings.cpp index 4394dff4..40e3b07b 100644 --- a/src/psmoveconfigtool/AppStage_AdvancedSettings.cpp +++ b/src/psmoveconfigtool/AppStage_AdvancedSettings.cpp @@ -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); @@ -260,7 +262,9 @@ TrackerConfig::ptree2config(const boost::property_tree::ptree &pt) exclude_opposed_cameras = pt.get("excluded_opposed_cameras", exclude_opposed_cameras); min_valid_projection_area = pt.get("min_valid_projection_area", min_valid_projection_area); - min_occluded_area_on_loss = pt.get("min_occluded_area_on_loss", min_occluded_area_on_loss); + occluded_area_on_loss_size = pt.get("occluded_area_on_loss_size", occluded_area_on_loss_size); + occluded_area_ignore_trackers = pt.get("occluded_area_ignore_trackers", occluded_area_ignore_trackers); + occluded_area_regain_projection_size = pt.get("occluded_area_regain_projection_size", occluded_area_regain_projection_size); min_points_in_contour = pt.get("min_points_in_contour", min_points_in_contour); max_tracker_position_deviation = pt.get("max_tracker_position_deviation", max_tracker_position_deviation); @@ -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(std::fmax(0.f, std::fmin(99999.f, cfg_tracker.min_occluded_area_on_loss))); + cfg_tracker.occluded_area_on_loss_size = static_cast(std::fmax(0.f, std::fmin(99999.f, cfg_tracker.occluded_area_on_loss_size))); } ImGui::PopItemWidth(); @@ -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(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(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); diff --git a/src/psmoveconfigtool/AppStage_AdvancedSettings.h b/src/psmoveconfigtool/AppStage_AdvancedSettings.h index 61183677..7bd8fc12 100644 --- a/src/psmoveconfigtool/AppStage_AdvancedSettings.h +++ b/src/psmoveconfigtool/AppStage_AdvancedSettings.h @@ -39,7 +39,7 @@ 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; @@ -47,7 +47,9 @@ class TrackerConfig : public PSMoveConfig 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; @@ -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; diff --git a/src/psmoveservice/Device/Manager/TrackerManager.cpp b/src/psmoveservice/Device/Manager/TrackerManager.cpp index ec1bfe5f..10591fea 100644 --- a/src/psmoveservice/Device/Manager/TrackerManager.cpp +++ b/src/psmoveservice/Device/Manager/TrackerManager.cpp @@ -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; @@ -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); @@ -107,7 +111,9 @@ TrackerManagerConfig::ptree2config(const boost::property_tree::ptree &pt) exclude_opposed_cameras = pt.get("excluded_opposed_cameras", exclude_opposed_cameras); min_valid_projection_area = pt.get("min_valid_projection_area", min_valid_projection_area); - min_occluded_area_on_loss = pt.get("min_occluded_area_on_loss", min_occluded_area_on_loss); + occluded_area_on_loss_size = pt.get("occluded_area_on_loss_size", occluded_area_on_loss_size); + occluded_area_ignore_trackers = pt.get("occluded_area_ignore_trackers", occluded_area_ignore_trackers); + occluded_area_regain_projection_size = pt.get("occluded_area_regain_projection_size", occluded_area_regain_projection_size); min_points_in_contour = pt.get("min_points_in_contour", min_points_in_contour); max_tracker_position_deviation = pt.get("max_tracker_position_deviation", max_tracker_position_deviation); diff --git a/src/psmoveservice/Device/Manager/TrackerManager.h b/src/psmoveservice/Device/Manager/TrackerManager.h index fe405ccb..3016b8a9 100644 --- a/src/psmoveservice/Device/Manager/TrackerManager.h +++ b/src/psmoveservice/Device/Manager/TrackerManager.h @@ -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; diff --git a/src/psmoveservice/Device/View/ServerControllerView.cpp b/src/psmoveservice/Device/View/ServerControllerView.cpp index e6c75ecf..60c950e2 100644 --- a/src/psmoveservice/Device/View/ServerControllerView.cpp +++ b/src/psmoveservice/Device/View/ServerControllerView.cpp @@ -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(); @@ -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]; } @@ -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;