From c3ada3f818294076cecf72b419f9e06d792297f0 Mon Sep 17 00:00:00 2001 From: Timocop Date: Sat, 4 Jun 2022 13:24:27 +1200 Subject: [PATCH] Able to create blacklisted projection areas --- .../AppStage_ColorCalibration.cpp | 374 +++++++++++++----- .../AppStage_ColorCalibration.h | 36 +- src/psmoveprotocol/PSMoveProtocol.proto | 25 ++ .../Device/Interface/DeviceInterface.h | 25 ++ .../Device/View/ServerControllerView.cpp | 71 +++- .../Device/View/ServerControllerView.h | 4 + .../Device/View/ServerTrackerView.cpp | 36 +- .../Device/View/ServerTrackerView.h | 3 + .../PSMoveTracker/PS3EyeTracker.cpp | 61 ++- .../PSMoveTracker/PS3EyeTracker.h | 3 + .../Server/ServerRequestHandler.cpp | 254 +++++++++--- 11 files changed, 708 insertions(+), 184 deletions(-) diff --git a/src/psmoveconfigtool/AppStage_ColorCalibration.cpp b/src/psmoveconfigtool/AppStage_ColorCalibration.cpp index 15256092..49ce69ca 100644 --- a/src/psmoveconfigtool/AppStage_ColorCalibration.cpp +++ b/src/psmoveconfigtool/AppStage_ColorCalibration.cpp @@ -197,8 +197,11 @@ AppStage_ColorCalibration::AppStage_ColorCalibration(App *app) , m_iDetectingAdjustMethod(eDetectionAdjustMethod::adjust_exposure) , m_bDetectingCancel(false) , m_iDetectingFailReason(eDetectionFailReason::failreason_unknown) + , m_bProjectionBlacklistedShow(true) { memset(m_colorPresets, 0, sizeof(m_colorPresets)); + memset(m_blacklisted_projection, 0, sizeof(m_blacklisted_projection)); + m_mAlignPosition[0] = 0.0f; m_mAlignPosition[1] = 0.0f; } @@ -401,6 +404,99 @@ void AppStage_ColorCalibration::update() get_contures_lower(0, 2, m_mDetectedContures); + + if (!m_bAlignDetectColor) + { + if (m_bProjectionBlacklistedShow) + { + for (int i = 0; i < eCommonBlacklistProjection::MAX_BLACKLIST_PROJECTIONS; ++i) + { + float proj_x, proj_y, proj_w, proj_h; + proj_x = m_blacklisted_projection[i].x; + proj_y = m_blacklisted_projection[i].y; + proj_w = m_blacklisted_projection[i].w; + proj_h = m_blacklisted_projection[i].h; + + cv::Rect rect = cv::Rect(proj_x, proj_y, proj_w, proj_h); + + cv::rectangle( + *m_video_buffer_state->bgrBuffer, + rect, + cv::Scalar(0, 255, 255) + ); + } + } + + if (m_bColorCollsionShow || m_bDetectingColors) + { + float align_window_size = 32.f; + + int detect_count = 0; + + for (std::vector item : m_mDetectedContures) + { + ImVec2 dispSize = ImGui::GetIO().DisplaySize; + int img_x = (static_cast(item[0]) * m_video_buffer_state->bgrBuffer->cols) / static_cast(dispSize.x); + int img_y = (static_cast(item[1]) * m_video_buffer_state->bgrBuffer->rows) / static_cast(dispSize.y); + ImVec2 wndCenter = ImVec2(static_cast(img_x), static_cast(img_y)); + + if (detect_count++ == 0) + { + cv::Rect rect = cv::Rect( + wndCenter.x - (align_window_size / 2), + wndCenter.y - (align_window_size / 2), + align_window_size, + align_window_size); + + cv::rectangle( + *m_video_buffer_state->bgrBuffer, + rect, + cv::Scalar(0, 255, 0) + ); + } + else + { + cv::Rect rect = cv::Rect( + wndCenter.x - (align_window_size / 2), + wndCenter.y - (align_window_size / 2), + align_window_size, + align_window_size); + + cv::rectangle( + *m_video_buffer_state->bgrBuffer, + rect, + cv::Scalar(0, 0, 255) + ); + } + } + } + else + { + float align_window_size = 32.f; + + for (std::vector item : m_mDetectedContures) + { + ImVec2 dispSize = ImGui::GetIO().DisplaySize; + int img_x = (static_cast(item[0]) * m_video_buffer_state->bgrBuffer->cols) / static_cast(dispSize.x); + int img_y = (static_cast(item[1]) * m_video_buffer_state->bgrBuffer->rows) / static_cast(dispSize.y); + ImVec2 wndCenter = ImVec2(static_cast(img_x), static_cast(img_y)); + + cv::Rect rect = cv::Rect( + wndCenter.x - (align_window_size / 2), + wndCenter.y - (align_window_size / 2), + align_window_size, + align_window_size); + + cv::rectangle( + *m_video_buffer_state->bgrBuffer, + rect, + cv::Scalar(255, 255, 255) + ); + break; + } + } + } + switch (m_videoDisplayMode) { case AppStage_ColorCalibration::mode_bgr: @@ -534,109 +630,6 @@ void AppStage_ColorCalibration::renderUI() ImGui::GetStyle().WindowRounding = prevRound; } - if ((m_bColorCollsionShow || m_bDetectingColors) && m_video_buffer_state != nullptr) - { - float align_window_size = 32.f; - - int detect_count = 0; - - for (std::vector item : m_mDetectedContures) - { - ImVec2 wndCenter = ImVec2(static_cast(item[0]), static_cast(item[1])); - ImVec2 wndPos = ImVec2(wndCenter.x - align_window_size, wndCenter.y - align_window_size); - ImVec2 wndSize = ImVec2(align_window_size * 2, align_window_size * 2); - - float prevAlpha = ImGui::GetStyle().WindowFillAlphaDefault; - float prevRound = ImGui::GetStyle().WindowRounding; - - ImGui::GetStyle().WindowFillAlphaDefault = 0.f; - - ImGui::SetNextWindowPos(wndPos); - ImGui::SetNextWindowSize(wndSize); - - ImGui::Begin("Collision Rec", nullptr, - ImGuiWindowFlags_NoBringToFrontOnFocus | - ImGuiWindowFlags_NoFocusOnAppearing | - ImGuiWindowFlags_NoTitleBar | - ImGuiWindowFlags_NoResize | - ImGuiWindowFlags_NoMove | - ImGuiWindowFlags_NoScrollbar | - ImGuiWindowFlags_NoCollapse | - ImGuiWindowFlags_NoSavedSettings); - - if (detect_count++ == 0) - { - ImGui::GetWindowDrawList()->AddRect( - ImVec2(wndCenter.x - (align_window_size / 2), wndCenter.y - (align_window_size / 2)), - ImVec2(wndCenter.x + (align_window_size / 2), wndCenter.y + (align_window_size / 2)), - ImColor(0.f, 1.f, 0.f, 1.f), 0.f, 0 - ); - ImGui::GetWindowDrawList()->AddRectFilled( - ImVec2(wndCenter.x - (align_window_size / 2), wndCenter.y - (align_window_size / 2)), - ImVec2(wndCenter.x + (align_window_size / 2), wndCenter.y + (align_window_size / 2)), - ImColor(0.f, 1.f, 0.f, 0.25f), 0.f, 0 - ); - } - else - { - ImGui::GetWindowDrawList()->AddRect( - ImVec2(wndCenter.x - (align_window_size / 2), wndCenter.y - (align_window_size / 2)), - ImVec2(wndCenter.x + (align_window_size / 2), wndCenter.y + (align_window_size / 2)), - ImColor(1.f, 0.f, 0.f, 1.f), 0.f, 0 - ); - ImGui::GetWindowDrawList()->AddRectFilled( - ImVec2(wndCenter.x - (align_window_size / 2), wndCenter.y - (align_window_size / 2)), - ImVec2(wndCenter.x + (align_window_size / 2), wndCenter.y + (align_window_size / 2)), - ImColor(1.f, 0.f, 0.f, 0.25f), 0.f, 0 - ); - } - - - ImGui::End(); - ImGui::GetStyle().WindowFillAlphaDefault = prevAlpha; - } - } - - if (!m_bColorCollsionShow && !m_bDetectingColors && m_video_buffer_state != nullptr) - { - float align_window_size = 32.f; - - for (std::vector item : m_mDetectedContures) - { - ImVec2 wndCenter = ImVec2(static_cast(item[0]), static_cast(item[1])); - ImVec2 wndPos = ImVec2(wndCenter.x - align_window_size, wndCenter.y - align_window_size); - ImVec2 wndSize = ImVec2(align_window_size * 2, align_window_size * 2); - - float prevAlpha = ImGui::GetStyle().WindowFillAlphaDefault; - float prevRound = ImGui::GetStyle().WindowRounding; - - ImGui::GetStyle().WindowFillAlphaDefault = 0.f; - - ImGui::SetNextWindowPos(wndPos); - ImGui::SetNextWindowSize(wndSize); - - ImGui::Begin("Target Controller", nullptr, - ImGuiWindowFlags_NoBringToFrontOnFocus | - ImGuiWindowFlags_NoFocusOnAppearing | - ImGuiWindowFlags_NoTitleBar | - ImGuiWindowFlags_NoResize | - ImGuiWindowFlags_NoMove | - ImGuiWindowFlags_NoScrollbar | - ImGuiWindowFlags_NoCollapse | - ImGuiWindowFlags_NoSavedSettings); - - ImGui::GetWindowDrawList()->AddRect( - ImVec2(wndCenter.x - (align_window_size / 2), wndCenter.y - (align_window_size / 2)), - ImVec2(wndCenter.x + (align_window_size / 2), wndCenter.y + (align_window_size / 2)), - ImColor(1.f, 1.f, 1.f, 1.f), 0.f, 0 - ); - - ImGui::End(); - ImGui::GetStyle().WindowFillAlphaDefault = prevAlpha; - break; - } - } - const float k_panel_width = 300.f; const char *k_window_title = "Color Calibration"; const ImGuiWindowFlags window_flags = @@ -912,6 +905,77 @@ void AppStage_ColorCalibration::renderUI() } } + if (ImGui::CollapsingHeader("Blacklisted Areas", 0, true, false)) + { + ImGui::Indent(); + ImGui::Checkbox("Show Blacklisted Areas", &m_bProjectionBlacklistedShow); + + for (int i = 0; i < eCommonBlacklistProjection::MAX_BLACKLIST_PROJECTIONS; ++i) + { + std::string option_name = std::to_string(i); + + ImGui::PushID(option_name.c_str()); + if (ImGui::CollapsingHeader(option_name.c_str(), 0, true, true)) + { + float val; + + ImGui::Text("X: "); + ImGui::SameLine(ImGui::GetWindowWidth() - 150.f); + ImGui::PushItemWidth(120.f); + val = m_blacklisted_projection[i].x; + if (ImGui::InputFloat("##BlacklistedAreaX", &val, 4.f, 32.f, 2)) + { + m_blacklisted_projection[i].x = fmaxf(0.f, val); + request_tracker_set_projectionblacklist(m_blacklisted_projection); + } + ImGui::PopItemWidth(); + + ImGui::Text("Y: "); + ImGui::SameLine(ImGui::GetWindowWidth() - 150.f); + ImGui::PushItemWidth(120.f); + val = m_blacklisted_projection[i].y; + if (ImGui::InputFloat("##BlacklistedAreaY", &val, 4.f, 32.f, 2)) + { + m_blacklisted_projection[i].y = fmaxf(0.f, val); + request_tracker_set_projectionblacklist(m_blacklisted_projection); + } + ImGui::PopItemWidth(); + + ImGui::Text("Width: "); + ImGui::SameLine(ImGui::GetWindowWidth() - 150.f); + ImGui::PushItemWidth(120.f); + val = m_blacklisted_projection[i].w; + if (ImGui::InputFloat("##BlacklistedAreaW", &val, 4.f, 32.f, 2)) + { + m_blacklisted_projection[i].w = fmaxf(0.f, val); + request_tracker_set_projectionblacklist(m_blacklisted_projection); + } + ImGui::PopItemWidth(); + + ImGui::Text("Height: "); + ImGui::SameLine(ImGui::GetWindowWidth() - 150.f); + ImGui::PushItemWidth(120.f); + val = m_blacklisted_projection[i].h; + if (ImGui::InputFloat("##BlacklistedAreaH", &val, 4.f, 32.f, 2)) + { + m_blacklisted_projection[i].h = fmaxf(0.f, val); + request_tracker_set_projectionblacklist(m_blacklisted_projection); + } + ImGui::PopItemWidth(); + + if (ImGui::Button("Reset")) + { + m_blacklisted_projection[i].x = 0.f; + m_blacklisted_projection[i].y = 0.f; + m_blacklisted_projection[i].w = 0.f; + m_blacklisted_projection[i].h = 0.f; + } + ImGui::PopID(); + } + } + ImGui::Unindent(); + } + if (m_masterControllerView != nullptr) { if (ImGui::Checkbox("Turn on all bulbs", &m_bTurnOnAllControllers)) @@ -1733,6 +1797,7 @@ void AppStage_ColorCalibration::renderUI() m_videoDisplayMode = eVideoDisplayMode::mode_bgr; m_bTurnOnAllControllers = false; m_bColorCollsionShow = false; + m_bProjectionBlacklistedShow = false; request_turn_on_all_tracking_bulbs(false); m_bDetectingCancel = false; @@ -2767,6 +2832,62 @@ void AppStage_ColorCalibration::handle_tracker_set_option_response( } } +void AppStage_ColorCalibration::request_tracker_set_projectionblacklist( + CommonDeviceBlacklistProjection projection_blacklisted[eCommonBlacklistProjection::MAX_BLACKLIST_PROJECTIONS]) +{ + // Tell the psmove service that we want to change gain. + RequestPtr request(new PSMoveProtocol::Request()); + request->set_type(PSMoveProtocol::Request_RequestType_SET_TRACKER_PROJECTIONBLACKLIST); + request->mutable_request_set_tracker_projection_blacklist()->set_tracker_id(m_trackerView->tracker_info.tracker_id); + PSMoveProtocol::ProjectionBlacklistList *proj_blacklist = request->mutable_request_set_tracker_projection_blacklist()->mutable_projection_blacklist(); + + for (int i = 0; i < eCommonBlacklistProjection::MAX_BLACKLIST_PROJECTIONS; ++i) + { + switch (i) + { + case 0: { + proj_blacklist->mutable__1()->set_x(projection_blacklisted[i].x); + proj_blacklist->mutable__1()->set_y(projection_blacklisted[i].y); + proj_blacklist->mutable__1()->set_w(projection_blacklisted[i].w); + proj_blacklist->mutable__1()->set_h(projection_blacklisted[i].h); + break; + } + case 1: { + proj_blacklist->mutable__2()->set_x(projection_blacklisted[i].x); + proj_blacklist->mutable__2()->set_y(projection_blacklisted[i].y); + proj_blacklist->mutable__2()->set_w(projection_blacklisted[i].w); + proj_blacklist->mutable__2()->set_h(projection_blacklisted[i].h); + break; + } + case 2: { + proj_blacklist->mutable__3()->set_x(projection_blacklisted[i].x); + proj_blacklist->mutable__3()->set_y(projection_blacklisted[i].y); + proj_blacklist->mutable__3()->set_w(projection_blacklisted[i].w); + proj_blacklist->mutable__3()->set_h(projection_blacklisted[i].h); + break; + } + case 3: { + proj_blacklist->mutable__4()->set_x(projection_blacklisted[i].x); + proj_blacklist->mutable__4()->set_y(projection_blacklisted[i].y); + proj_blacklist->mutable__4()->set_w(projection_blacklisted[i].w); + proj_blacklist->mutable__4()->set_h(projection_blacklisted[i].h); + break; + } + case 4: { + proj_blacklist->mutable__5()->set_x(projection_blacklisted[i].x); + proj_blacklist->mutable__5()->set_y(projection_blacklisted[i].y); + proj_blacklist->mutable__5()->set_w(projection_blacklisted[i].w); + proj_blacklist->mutable__5()->set_h(projection_blacklisted[i].h); + break; + } + } + } + + PSMRequestID request_id; + PSM_SendOpaqueRequest(&request, &request_id); + PSM_EatResponse(request_id); +} + void AppStage_ColorCalibration::request_tracker_set_color_preset( PSMTrackingColorType color_type, TrackerColorPreset &color_preset) @@ -2880,7 +3001,7 @@ void AppStage_ColorCalibration::handle_tracker_get_settings_response( thisPtr->m_trackerFrameRate = response->result_tracker_settings().frame_rate(); thisPtr->m_trackerExposure = response->result_tracker_settings().exposure(); thisPtr->m_trackerGain = response->result_tracker_settings().gain(); - + thisPtr->m_trackerOptions.clear(); for (auto it = response->result_tracker_settings().option_sets().begin(); it != response->result_tracker_settings().option_sets().end(); @@ -2919,6 +3040,51 @@ void AppStage_ColorCalibration::handle_tracker_get_settings_response( destPreset.value_center = srcPreset.value_center(); destPreset.value_range = srcPreset.value_range(); } + + for (int i = 0; i < eCommonBlacklistProjection::MAX_BLACKLIST_PROJECTIONS; ++i) + { + const PSMoveProtocol::ProjectionBlacklistList proj_blacklist = response->result_tracker_settings().projection_blacklist(); + + switch (i) + { + case 0: { + thisPtr->m_blacklisted_projection[i].x = proj_blacklist._1().x(); + thisPtr->m_blacklisted_projection[i].y = proj_blacklist._1().y(); + thisPtr->m_blacklisted_projection[i].w = proj_blacklist._1().w(); + thisPtr->m_blacklisted_projection[i].h = proj_blacklist._1().h(); + break; + } + case 1: { + thisPtr->m_blacklisted_projection[i].x = proj_blacklist._2().x(); + thisPtr->m_blacklisted_projection[i].y = proj_blacklist._2().y(); + thisPtr->m_blacklisted_projection[i].w = proj_blacklist._2().w(); + thisPtr->m_blacklisted_projection[i].h = proj_blacklist._2().h(); + break; + } + case 2: { + thisPtr->m_blacklisted_projection[i].x = proj_blacklist._3().x(); + thisPtr->m_blacklisted_projection[i].y = proj_blacklist._3().y(); + thisPtr->m_blacklisted_projection[i].w = proj_blacklist._3().w(); + thisPtr->m_blacklisted_projection[i].h = proj_blacklist._3().h(); + break; + } + case 3: { + thisPtr->m_blacklisted_projection[i].x = proj_blacklist._4().x(); + thisPtr->m_blacklisted_projection[i].y = proj_blacklist._4().y(); + thisPtr->m_blacklisted_projection[i].w = proj_blacklist._4().w(); + thisPtr->m_blacklisted_projection[i].h = proj_blacklist._4().h(); + break; + } + case 4: { + thisPtr->m_blacklisted_projection[i].x = proj_blacklist._5().x(); + thisPtr->m_blacklisted_projection[i].y = proj_blacklist._5().y(); + thisPtr->m_blacklisted_projection[i].w = proj_blacklist._5().w(); + thisPtr->m_blacklisted_projection[i].h = proj_blacklist._5().h(); + break; + } + } + } + } break; case PSMResult_Error: case PSMResult_Canceled: diff --git a/src/psmoveconfigtool/AppStage_ColorCalibration.h b/src/psmoveconfigtool/AppStage_ColorCalibration.h index a401b4d0..00d7cc91 100644 --- a/src/psmoveconfigtool/AppStage_ColorCalibration.h +++ b/src/psmoveconfigtool/AppStage_ColorCalibration.h @@ -54,6 +54,11 @@ class AppStage_ColorCalibration : public AppStage } protected: + enum eCommonBlacklistProjection + { + MAX_BLACKLIST_PROJECTIONS = 5 + }; + enum eMenuState { inactive, @@ -147,6 +152,24 @@ class AppStage_ColorCalibration : public AppStage float value_range; }; + struct CommonDeviceBlacklistProjection + { + float x, y, w, h; + + inline void clear() + { + x = y = w = h = 0.f; + } + + inline void set(float _x, float _y, float _w, float _h) + { + x = _x; + y = _y; + w = _w; + h = _h; + } + }; + void setState(eMenuState newState); void request_start_controller_streams(); @@ -186,10 +209,12 @@ class AppStage_ColorCalibration : public AppStage const PSMResponseMessage *response, void *userdata); - void request_tracker_set_option(TrackerOption &option, int new_option_index); - static void handle_tracker_set_option_response( - const PSMResponseMessage *response, - void *userdata); + void request_tracker_set_option(TrackerOption &option, int new_option_index); + static void handle_tracker_set_option_response( + const PSMResponseMessage *response, + void *userdata); + + void request_tracker_set_projectionblacklist(CommonDeviceBlacklistProjection projection_blacklisted[eCommonBlacklistProjection::MAX_BLACKLIST_PROJECTIONS]); void request_tracker_set_color_preset(PSMTrackingColorType color_type, TrackerColorPreset &color_preset); static void handle_tracker_set_color_preset_response( @@ -252,6 +277,8 @@ class AppStage_ColorCalibration : public AppStage double m_trackerGain; std::vector m_trackerOptions; TrackerColorPreset m_colorPresets[PSMTrackingColorType_MaxColorTypes]; + CommonDeviceBlacklistProjection m_blacklisted_projection[eCommonBlacklistProjection::MAX_BLACKLIST_PROJECTIONS]; + int tracker_count; int tracker_index; @@ -277,6 +304,7 @@ class AppStage_ColorCalibration : public AppStage bool m_bColorCollisionPrevent; bool m_bColorCollsionShow; std::vector> m_mDetectedContures; + bool m_bProjectionBlacklistedShow; // Auto detect color bool m_bDetectingColors; diff --git a/src/psmoveprotocol/PSMoveProtocol.proto b/src/psmoveprotocol/PSMoveProtocol.proto index c8c86f92..d537b62d 100644 --- a/src/psmoveprotocol/PSMoveProtocol.proto +++ b/src/psmoveprotocol/PSMoveProtocol.proto @@ -73,6 +73,21 @@ message Pose { Position position= 2; } +message ProjectionBlacklistList { + ProjectionBlacklist _1 = 1; + ProjectionBlacklist _2 = 2; + ProjectionBlacklist _3 = 3; + ProjectionBlacklist _4 = 4; + ProjectionBlacklist _5 = 5; +} + +message ProjectionBlacklist { + float x = 1; + float y = 2; + float w = 3; + float h = 4; +} + enum TrackerType { PS3EYE = 0; } @@ -185,6 +200,7 @@ message Request { SET_CONTROLLER_OPTICAL_TRACKING = 48; SET_CONTROLLER_PSMOVE_EMULATION = 49; + SET_TRACKER_PROJECTIONBLACKLIST = 50; } RequestType type = 2; @@ -561,6 +577,12 @@ message Request { } RequestSetControllerPSmoveEmulation request_set_controller_psmove_emulation = 49; + // Parameters for SET_TRACKER_PROJECTIONBLACKLIST + message RequestSetTrackerProjectionBlacklist { + int32 tracker_id = 1; + ProjectionBlacklistList projection_blacklist = 2; + } + RequestSetTrackerProjectionBlacklist request_set_tracker_projection_blacklist = 50; } // Reliable (TCP) responses to requests @@ -712,6 +734,9 @@ message Response { float frame_rate= 5; float frame_width= 6; float frame_height= 7; + + // Tracker Projection Blacklist + ProjectionBlacklistList projection_blacklist = 8; } ResultTrackerSettings result_tracker_settings = 25; diff --git a/src/psmoveservice/Device/Interface/DeviceInterface.h b/src/psmoveservice/Device/Interface/DeviceInterface.h index 0f51762d..b0e6770c 100644 --- a/src/psmoveservice/Device/Interface/DeviceInterface.h +++ b/src/psmoveservice/Device/Interface/DeviceInterface.h @@ -13,6 +13,11 @@ namespace PSMoveProtocol }; // -- constants ----- +enum eCommonBlacklistProjection +{ + MAX_BLACKLIST_PROJECTIONS = 5 +}; + enum eCommonTrackingColorID { INVALID_COLOR= -1, @@ -158,6 +163,24 @@ struct CommonDeviceScreenLocation } }; +struct CommonDeviceBlacklistProjection +{ + float x, y, w, h; + + inline void clear() + { + x = y = w = h = 0.f; + } + + inline void set(float _x, float _y, float _w, float _h) + { + x = _x; + y = _y; + w = _w; + h = _h; + } +}; + struct CommonDeviceQuaternion { float x, y, z, w; @@ -623,6 +646,8 @@ class ITrackerInterface : public IDeviceInterface virtual void gatherTrackingColorPresets(const std::string &controller_serial, PSMoveProtocol::Response_ResultTrackerSettings* settings) const = 0; virtual void setTrackingColorPreset(const std::string &controller_serial, eCommonTrackingColorID color, const CommonHSVColorRange *preset) = 0; virtual void getTrackingColorPreset(const std::string &controller_serial, eCommonTrackingColorID color, CommonHSVColorRange *out_preset) const = 0; + virtual void setBlacklistProjection(const int index, const float x, const float y, const float w, const float h) = 0; + virtual bool getBlacklistProjection(const int index, float &x, float &y, float &w, float &h) const = 0; }; /// Abstract class for HMD interface. Implemented HMD classes diff --git a/src/psmoveservice/Device/View/ServerControllerView.cpp b/src/psmoveservice/Device/View/ServerControllerView.cpp index dbf9dea0..48e38011 100644 --- a/src/psmoveservice/Device/View/ServerControllerView.cpp +++ b/src/psmoveservice/Device/View/ServerControllerView.cpp @@ -517,6 +517,7 @@ void ServerControllerView::updateOpticalPoseEstimation(TrackerManager* tracker_m // Assume we're going to lose tracking this frame bool bCurrentlyTracking = false; bool bOccluded = false; + bool bBlacklisted = false; if (tracker->getIsOpen()) { @@ -559,6 +560,7 @@ void ServerControllerView::updateOpticalPoseEstimation(TrackerManager* tracker_m } bool bIsOccluded = false; + bool bIsBlacklisted = false; //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. @@ -609,27 +611,65 @@ void ServerControllerView::updateOpticalPoseEstimation(TrackerManager* tracker_m } } - // Ignore projections that are occluded BUT always pass atleast 2 biggest projected trackers. - if (!bIsOccluded || projections_found < trackerMgrConfig.occluded_area_ignore_trackers) + if (bWasTracking || bIsVisibleThisUpdate) { - bOccluded = false; - - // If the projection isn't too old (or updated this tick), - // say we have a valid tracked location - if ((bWasTracking && !tracker->getHasUnpublishedState()) || bIsVisibleThisUpdate) + for (int i = 0; i < eCommonBlacklistProjection::MAX_BLACKLIST_PROJECTIONS; ++i) { - // If this tracker has a valid projection for the controller - // add it to the tracker id list - valid_projection_tracker_ids[projections_found] = tracker_id; - ++projections_found; + float x, y, w, h; + if (tracker->getBlacklistProjection(i, x, y, w, h)) + { + const float tracker_x = trackerPoseEstimateRef.projection.shape.ellipse.center.x; + const float tracker_y = trackerPoseEstimateRef.projection.shape.ellipse.center.y; + + bool bInArea = (tracker_x > x) + && (tracker_y > y) + && (tracker_x < x + w) + && (tracker_y < y + h); + + if (bInArea) + { + trackerPoseEstimateRef.blacklistedAreaRec.x = x; + trackerPoseEstimateRef.blacklistedAreaRec.y = y; + trackerPoseEstimateRef.blacklistedAreaRec.w = w; + trackerPoseEstimateRef.blacklistedAreaRec.h = h; - // Flag this pose estimate as invalid - bCurrentlyTracking = true; + bIsBlacklisted = true; + break; + } + } } } + + // Ignore projections that are occluded BUT always pass atleast 2 biggest projected trackers. + if (bIsBlacklisted) + { + bBlacklisted = true; + } else { - bOccluded = true; + bBlacklisted = false; + + if (!bIsOccluded || projections_found < trackerMgrConfig.occluded_area_ignore_trackers) + { + bOccluded = false; + + // If the projection isn't too old (or updated this tick), + // say we have a valid tracked location + if ((bWasTracking && !tracker->getHasUnpublishedState()) || bIsVisibleThisUpdate) + { + // If this tracker has a valid projection for the controller + // add it to the tracker id list + valid_projection_tracker_ids[projections_found] = tracker_id; + ++projections_found; + + // Flag this pose estimate as invalid + bCurrentlyTracking = true; + } + } + else + { + bOccluded = true; + } } } } @@ -639,6 +679,7 @@ void ServerControllerView::updateOpticalPoseEstimation(TrackerManager* tracker_m trackerPoseEstimateRef.bValidTimestamps = true; trackerPoseEstimateRef.bCurrentlyTracking = bCurrentlyTracking; trackerPoseEstimateRef.bIsOccluded = bOccluded; + trackerPoseEstimateRef.bIsBlacklisted = bBlacklisted; } // How we compute the final world pose estimate varies based on @@ -2926,7 +2967,7 @@ static void computeSpherePoseForControllerFromMultipleTrackers( ServerTrackerView::triangulateWorldPosition( tracker.get(), &screen_location, other_tracker.get(), &other_screen_location); - + // Check how much the trangulation deviates from other trackers. // Ignore its position if it deviates too much and renew its ROI. if (pair_count > 0 && cfg.max_tracker_position_deviation > 0.01f) diff --git a/src/psmoveservice/Device/View/ServerControllerView.h b/src/psmoveservice/Device/View/ServerControllerView.h index 17aa2795..e5c196c3 100644 --- a/src/psmoveservice/Device/View/ServerControllerView.h +++ b/src/psmoveservice/Device/View/ServerControllerView.h @@ -42,8 +42,10 @@ struct ControllerOpticalPoseEstimation bool bEnforceNewROI; bool bIsOccluded; + bool bIsBlacklisted; CommonDeviceScreenLocation occlusionAreaPos; float occlusionAreaSize; + CommonDeviceBlacklistProjection blacklistedAreaRec; inline void clear() { @@ -59,8 +61,10 @@ struct ControllerOpticalPoseEstimation bEnforceNewROI = false; bIsOccluded = false; + bIsBlacklisted = false; occlusionAreaPos.clear(); occlusionAreaSize = 0.f; + blacklistedAreaRec.clear(); memset(&projection, 0, sizeof(CommonDeviceTrackingProjection)); projection.shape_type= eCommonTrackingProjectionType::INVALID_PROJECTION; diff --git a/src/psmoveservice/Device/View/ServerTrackerView.cpp b/src/psmoveservice/Device/View/ServerTrackerView.cpp index 8b2fc97e..03564174 100644 --- a/src/psmoveservice/Device/View/ServerTrackerView.cpp +++ b/src/psmoveservice/Device/View/ServerTrackerView.cpp @@ -754,6 +754,21 @@ class OpenCVBufferState cv::line(*bgrShmemBuffer, cv::Point(rec.x, rec.y + rec.height - 1), cv::Point(rec.x + rec.width - 1, rec.y), cv::Scalar(0, 0, 255)); } + void + draw_pose_blacklist(CommonDeviceBlacklistProjection proj_rec) + { + cv::Rect rec; + rec.x = static_cast(proj_rec.x); + rec.y = static_cast(proj_rec.y); + rec.width = static_cast(proj_rec.w); + rec.height = static_cast(proj_rec.h); + + //Draw occlusion rectangle on bgrShmemBuffer + cv::rectangle(*bgrShmemBuffer, rec, cv::Scalar(0, 0, 255)); + cv::line(*bgrShmemBuffer, cv::Point(rec.x, rec.y), cv::Point(rec.x + rec.width - 1, rec.y + rec.height - 1), cv::Scalar(0, 0, 255)); + cv::line(*bgrShmemBuffer, cv::Point(rec.x, rec.y + rec.height - 1), cv::Point(rec.x + rec.width - 1, rec.y), cv::Scalar(0, 0, 255)); + } + int frameWidth; int frameHeight; @@ -1297,6 +1312,16 @@ void ServerTrackerView::getHMDTrackingColorPreset( return m_device->getTrackingColorPreset(hmd_id, color, out_preset); } +void ServerTrackerView::setBlacklistProjection(const int index, const float x, const float y, const float w, const float h) +{ + m_device->setBlacklistProjection(index, x, y, w, h); +} + +bool ServerTrackerView::getBlacklistProjection(const int index, float &x, float &y, float &w, float &h) +{ + return m_device->getBlacklistProjection(index, x, y, w, h); +} + bool ServerTrackerView::computeProjectionForController( const ServerControllerView* tracked_controller, @@ -1332,16 +1357,18 @@ ServerTrackerView::computeProjectionForController( const bool bIsTracking = priorPoseEst->bCurrentlyTracking; const bool bEnforceNewROI = priorPoseEst->bEnforceNewROI; const bool bIsOccluded = priorPoseEst->bIsOccluded; + const bool bIsBlacklisted = priorPoseEst->bIsBlacklisted; const CommonDeviceScreenLocation mOcclusionAreaPos = priorPoseEst->occlusionAreaPos; const float fOcclusionAreaSize = priorPoseEst->occlusionAreaSize; + const CommonDeviceBlacklistProjection mBlacklistedAreaRec = priorPoseEst->blacklistedAreaRec; cv::Rect2i ROI= computeTrackerROIForPoseProjection( (bRoiOptimized) ? tracked_controller->getDeviceID() : -1, bRoiDisabled, iRoiEdgeOffset, this, - ((bIsTracking || bIsOccluded) && !bEnforceNewROI) ? (tracked_controller->getPoseFilter()) : (nullptr), - ((bIsTracking || bIsOccluded) && !bEnforceNewROI) ? (&priorPoseEst->projection) : (nullptr), + ((bIsTracking || bIsOccluded || bIsBlacklisted) && !bEnforceNewROI) ? (tracked_controller->getPoseFilter()) : (nullptr), + ((bIsTracking || bIsOccluded || bIsBlacklisted) && !bEnforceNewROI) ? (&priorPoseEst->projection) : (nullptr), tracking_shape); m_opencv_buffer_state->applyROI(ROI); @@ -1481,6 +1508,11 @@ ServerTrackerView::computeProjectionForController( m_opencv_buffer_state->draw_pose_occlusion(mOcclusionAreaPos, fOcclusionAreaSize); } + if (bIsBlacklisted) + { + m_opencv_buffer_state->draw_pose_blacklist(mBlacklistedAreaRec); + } + // Throw out the result if the contour we found was too small and // we were using an ROI less that the size of the full screen diff --git a/src/psmoveservice/Device/View/ServerTrackerView.h b/src/psmoveservice/Device/View/ServerTrackerView.h index a069b4b1..8bca3d12 100644 --- a/src/psmoveservice/Device/View/ServerTrackerView.h +++ b/src/psmoveservice/Device/View/ServerTrackerView.h @@ -137,6 +137,9 @@ class ServerTrackerView : public ServerDeviceView void setHMDTrackingColorPreset(const class ServerHMDView *controller, eCommonTrackingColorID color, const CommonHSVColorRange *preset); void getHMDTrackingColorPreset(const class ServerHMDView *controller, eCommonTrackingColorID color, CommonHSVColorRange *out_preset) const; + + void setBlacklistProjection(const int index, const float x, const float y, const float w, const float h); + bool getBlacklistProjection(const int index, float &x, float &y, float &w, float &h); protected: bool allocate_device_interface(const class DeviceEnumerator *enumerator) override; diff --git a/src/psmoveservice/PSMoveTracker/PS3EyeTracker.cpp b/src/psmoveservice/PSMoveTracker/PS3EyeTracker.cpp index a5d94bb3..cf01cb49 100644 --- a/src/psmoveservice/PSMoveTracker/PS3EyeTracker.cpp +++ b/src/psmoveservice/PSMoveTracker/PS3EyeTracker.cpp @@ -57,13 +57,15 @@ PS3EyeTrackerConfig::PS3EyeTrackerConfig(const std::string &fnamebase) , distortionP2(0.00010589254816295579) , fovSetting(BlueDot) { + memset(projection_blacklist, 0, sizeof(projection_blacklist)); + pose.clear(); SharedColorPresets.table_name.clear(); - for (int preset_index = 0; preset_index < eCommonTrackingColorID::MAX_TRACKING_COLOR_TYPES; ++preset_index) - { - SharedColorPresets.color_presets[preset_index] = k_default_color_presets[preset_index]; - } + for (int i = 0; i < eCommonTrackingColorID::MAX_TRACKING_COLOR_TYPES; ++i) + { + SharedColorPresets.color_presets[i] = k_default_color_presets[i]; + } }; const boost::property_tree::ptree @@ -110,6 +112,16 @@ PS3EyeTrackerConfig::config2ptree() writeColorPropertyPresetTable(&controller_preset_table, pt); } + for (int i = 0; i < eCommonBlacklistProjection::MAX_BLACKLIST_PROJECTIONS; ++i) + { + std::string key_name = "blacklist_projections."; + key_name.append(std::to_string(i)); + + pt.put(key_name + std::string(".x"), projection_blacklist[i].x); + pt.put(key_name + std::string(".y"), projection_blacklist[i].y); + pt.put(key_name + std::string(".w"), projection_blacklist[i].w); + pt.put(key_name + std::string(".h"), projection_blacklist[i].h); + } return pt; } @@ -189,6 +201,19 @@ PS3EyeTrackerConfig::ptree2config(const boost::property_tree::ptree &pt) DeviceColorPresets.push_back(table); } } + + for (int i = 0; i < eCommonBlacklistProjection::MAX_BLACKLIST_PROJECTIONS; ++i) + { + std::string key_name = "blacklist_projections."; + key_name.append(std::to_string(i)); + + projection_blacklist[i].clear(); + + projection_blacklist[i].x = pt.get(key_name + std::string(".x"), 0.0); + projection_blacklist[i].y = pt.get(key_name + std::string(".y"), 0.0); + projection_blacklist[i].w = pt.get(key_name + std::string(".w"), 0.0); + projection_blacklist[i].h = pt.get(key_name + std::string(".h"), 0.0); + } } else { @@ -860,3 +885,31 @@ void PS3EyeTracker::getTrackingColorPreset( *out_preset = table->color_presets[color]; } + +void PS3EyeTracker::setBlacklistProjection(const int index, const float x, const float y, const float w, const float h) +{ + if (index < 0 || index > eCommonBlacklistProjection::MAX_BLACKLIST_PROJECTIONS - 1) + { + return; + } + + cfg.projection_blacklist[index].clear(); + cfg.projection_blacklist[index].x = x; + cfg.projection_blacklist[index].y = y; + cfg.projection_blacklist[index].w = w; + cfg.projection_blacklist[index].h = h; +} + +bool PS3EyeTracker::getBlacklistProjection(const int index, float &x, float &y, float &w, float &h) const +{ + if (index < 0 || index > eCommonBlacklistProjection::MAX_BLACKLIST_PROJECTIONS - 1) + { + return false; + } + + x = cfg.projection_blacklist[index].x; + y = cfg.projection_blacklist[index].y; + w = cfg.projection_blacklist[index].w; + h = cfg.projection_blacklist[index].h; + return true; +} diff --git a/src/psmoveservice/PSMoveTracker/PS3EyeTracker.h b/src/psmoveservice/PSMoveTracker/PS3EyeTracker.h index 6e3896bc..f8cfacfb 100644 --- a/src/psmoveservice/PSMoveTracker/PS3EyeTracker.h +++ b/src/psmoveservice/PSMoveTracker/PS3EyeTracker.h @@ -56,6 +56,7 @@ class PS3EyeTrackerConfig : public PSMoveConfig double distortionP1; double distortionP2; + CommonDeviceBlacklistProjection projection_blacklist[eCommonBlacklistProjection::MAX_BLACKLIST_PROJECTIONS]; eFOVSetting fovSetting; CommonDevicePose pose; CommonHSVColorRangeTable SharedColorPresets; @@ -137,6 +138,8 @@ class PS3EyeTracker : public ITrackerInterface { void gatherTrackingColorPresets(const std::string &controller_serial, PSMoveProtocol::Response_ResultTrackerSettings* settings) const override; void setTrackingColorPreset(const std::string &controller_serial, eCommonTrackingColorID color, const CommonHSVColorRange *preset) override; void getTrackingColorPreset(const std::string &controller_serial, eCommonTrackingColorID color, CommonHSVColorRange *out_preset) const override; + void setBlacklistProjection(const int index, const float x, const float y, const float w, const float h) override; + bool getBlacklistProjection(const int index, float &x, float &y, float &w, float &h) const override; // -- Getters inline const PS3EyeTrackerConfig &getConfig() const diff --git a/src/psmoveservice/Server/ServerRequestHandler.cpp b/src/psmoveservice/Server/ServerRequestHandler.cpp index 1b17ee99..9c584cbc 100644 --- a/src/psmoveservice/Server/ServerRequestHandler.cpp +++ b/src/psmoveservice/Server/ServerRequestHandler.cpp @@ -390,6 +390,10 @@ class ServerRequestHandlerImpl response = new PSMoveProtocol::Response; handle_request__set_controller_psmove_emulation(context, response); break; + case PSMoveProtocol::Request_RequestType_SET_TRACKER_PROJECTIONBLACKLIST: + response = new PSMoveProtocol::Response; + handle_request__set_tracker_projectionblacklist(context, response); + break; default: assert(0 && "Whoops, bad request!"); @@ -1885,22 +1889,22 @@ class ServerRequestHandlerImpl } // -- tracker requests ----- - inline void common_device_pose_to_protocol_pose( - const CommonDevicePose &pose, - PSMoveProtocol::Pose *result) - { - PSMoveProtocol::Orientation *orietation = result->mutable_orientation(); - PSMoveProtocol::Position *position = result->mutable_position(); + inline void common_device_pose_to_protocol_pose( + const CommonDevicePose &pose, + PSMoveProtocol::Pose *result) + { + PSMoveProtocol::Orientation *orietation = result->mutable_orientation(); + PSMoveProtocol::Position *position = result->mutable_position(); - orietation->set_w(pose.Orientation.w); - orietation->set_x(pose.Orientation.x); - orietation->set_y(pose.Orientation.y); - orietation->set_z(pose.Orientation.z); + orietation->set_w(pose.Orientation.w); + orietation->set_x(pose.Orientation.x); + orietation->set_y(pose.Orientation.y); + orietation->set_z(pose.Orientation.z); - position->set_x(pose.PositionCm.x); - position->set_y(pose.PositionCm.y); - position->set_z(pose.PositionCm.z); - } + position->set_x(pose.PositionCm.x); + position->set_y(pose.PositionCm.y); + position->set_z(pose.PositionCm.z); + } void handle_request__get_tracker_list( const RequestContext &context, @@ -2001,7 +2005,7 @@ class ServerRequestHandlerImpl CommonDevicePose pose= tracker_view->getTrackerPose(); common_device_pose_to_protocol_pose(pose, tracker_info->mutable_tracker_pose()); - } + } } } @@ -2111,7 +2115,7 @@ class ServerRequestHandlerImpl settings->set_exposure(static_cast(tracker_view->getExposure())); settings->set_gain(static_cast(tracker_view->getGain())); tracker_view->gatherTrackerOptions(settings); - + switch (context.request->request_get_tracker_settings().device_category()) { case PSMoveProtocol::Request_RequestGetTrackerSettings_DeviceCategory_CONTROLLER: @@ -2128,6 +2132,57 @@ class ServerRequestHandlerImpl } break; } + for (int i = 0; i < eCommonBlacklistProjection::MAX_BLACKLIST_PROJECTIONS; ++i) + { + float x, y, w, h; + if (tracker_view->getBlacklistProjection(i, x, y, w, h)) + { + switch (i) + { + case 0: { + PSMoveProtocol::ProjectionBlacklist *proj_blacklist = settings->mutable_projection_blacklist()->mutable__1(); + proj_blacklist->set_x(x); + proj_blacklist->set_y(y); + proj_blacklist->set_w(w); + proj_blacklist->set_h(h); + break; + } + case 1: { + PSMoveProtocol::ProjectionBlacklist *proj_blacklist = settings->mutable_projection_blacklist()->mutable__2(); + proj_blacklist->set_x(x); + proj_blacklist->set_y(y); + proj_blacklist->set_w(w); + proj_blacklist->set_h(h); + break; + } + case 2: { + PSMoveProtocol::ProjectionBlacklist *proj_blacklist = settings->mutable_projection_blacklist()->mutable__3(); + proj_blacklist->set_x(x); + proj_blacklist->set_y(y); + proj_blacklist->set_w(w); + proj_blacklist->set_h(h); + break; + } + case 3: { + PSMoveProtocol::ProjectionBlacklist *proj_blacklist = settings->mutable_projection_blacklist()->mutable__4(); + proj_blacklist->set_x(x); + proj_blacklist->set_y(y); + proj_blacklist->set_w(w); + proj_blacklist->set_h(h); + break; + } + case 4: { + PSMoveProtocol::ProjectionBlacklist *proj_blacklist = settings->mutable_projection_blacklist()->mutable__5(); + proj_blacklist->set_x(x); + proj_blacklist->set_y(y); + proj_blacklist->set_w(w); + proj_blacklist->set_h(h); + break; + } + } + } + } + response->set_result_code(PSMoveProtocol::Response_ResultCode_RESULT_OK); } else @@ -2503,51 +2558,140 @@ class ServerRequestHandlerImpl } } - inline CommonDevicePose protocol_pose_to_common_device_pose(const PSMoveProtocol::Pose &pose) - { - CommonDevicePose result; + inline CommonDevicePose protocol_pose_to_common_device_pose(const PSMoveProtocol::Pose &pose) + { + CommonDevicePose result; - result.Orientation.w = pose.orientation().w(); - result.Orientation.x = pose.orientation().x(); - result.Orientation.y = pose.orientation().y(); - result.Orientation.z = pose.orientation().z(); + result.Orientation.w = pose.orientation().w(); + result.Orientation.x = pose.orientation().x(); + result.Orientation.y = pose.orientation().y(); + result.Orientation.z = pose.orientation().z(); - result.PositionCm.x = pose.position().x(); - result.PositionCm.y = pose.position().y(); - result.PositionCm.z = pose.position().z(); + result.PositionCm.x = pose.position().x(); + result.PositionCm.y = pose.position().y(); + result.PositionCm.z = pose.position().z(); - return result; - } + return result; + } - void handle_request__set_tracker_pose( - const RequestContext &context, - PSMoveProtocol::Response *response) - { - const int tracker_id = context.request->request_set_tracker_pose().tracker_id(); - if (ServerUtility::is_index_valid(tracker_id, m_device_manager.getTrackerViewMaxCount())) - { - ServerTrackerViewPtr tracker_view = m_device_manager.getTrackerViewPtr(tracker_id); - if (tracker_view->getIsOpen()) - { - const PSMoveProtocol::Pose &srcPose = - context.request->request_set_tracker_pose().pose(); - CommonDevicePose destPose = protocol_pose_to_common_device_pose(srcPose); + void handle_request__set_tracker_pose( + const RequestContext &context, + PSMoveProtocol::Response *response) + { + const int tracker_id = context.request->request_set_tracker_pose().tracker_id(); + if (ServerUtility::is_index_valid(tracker_id, m_device_manager.getTrackerViewMaxCount())) + { + ServerTrackerViewPtr tracker_view = m_device_manager.getTrackerViewPtr(tracker_id); + if (tracker_view->getIsOpen()) + { + const PSMoveProtocol::Pose &srcPose = + context.request->request_set_tracker_pose().pose(); + CommonDevicePose destPose = protocol_pose_to_common_device_pose(srcPose); - tracker_view->setTrackerPose(&destPose); - tracker_view->saveSettings(); + tracker_view->setTrackerPose(&destPose); + tracker_view->saveSettings(); - response->set_result_code(PSMoveProtocol::Response_ResultCode_RESULT_OK); - } - else - { - response->set_result_code(PSMoveProtocol::Response_ResultCode_RESULT_ERROR); - } - } - else - { - response->set_result_code(PSMoveProtocol::Response_ResultCode_RESULT_ERROR); - } - } + response->set_result_code(PSMoveProtocol::Response_ResultCode_RESULT_OK); + } + else + { + response->set_result_code(PSMoveProtocol::Response_ResultCode_RESULT_ERROR); + } + } + else + { + response->set_result_code(PSMoveProtocol::Response_ResultCode_RESULT_ERROR); + } + } + + void handle_request__set_tracker_projectionblacklist( + const RequestContext &context, + PSMoveProtocol::Response *response) + { + const int tracker_id = context.request->request_set_tracker_projection_blacklist().tracker_id(); + if (ServerUtility::is_index_valid(tracker_id, m_device_manager.getTrackerViewMaxCount())) + { + ServerTrackerViewPtr tracker_view = m_device_manager.getTrackerViewPtr(tracker_id); + if (tracker_view->getIsOpen()) + { + const PSMoveProtocol::ProjectionBlacklistList &proj_blacklist = + context.request->request_set_tracker_projection_blacklist().projection_blacklist(); + + for (int i = 0; i < eCommonBlacklistProjection::MAX_BLACKLIST_PROJECTIONS; ++i) + { + switch (i) + { + case 0: { + const PSMoveProtocol::ProjectionBlacklist proj_blacklist_2 = proj_blacklist._1(); + + tracker_view->setBlacklistProjection( + i, + proj_blacklist_2.x(), + proj_blacklist_2.y(), + proj_blacklist_2.w(), + proj_blacklist_2.h()); + break; + } + case 1: { + const PSMoveProtocol::ProjectionBlacklist proj_blacklist_2 = proj_blacklist._2(); + + tracker_view->setBlacklistProjection( + i, + proj_blacklist_2.x(), + proj_blacklist_2.y(), + proj_blacklist_2.w(), + proj_blacklist_2.h()); + break; + } + case 2: { + const PSMoveProtocol::ProjectionBlacklist proj_blacklist_2 = proj_blacklist._3(); + + tracker_view->setBlacklistProjection( + i, + proj_blacklist_2.x(), + proj_blacklist_2.y(), + proj_blacklist_2.w(), + proj_blacklist_2.h()); + break; + } + case 3: { + const PSMoveProtocol::ProjectionBlacklist proj_blacklist_2 = proj_blacklist._4(); + + tracker_view->setBlacklistProjection( + i, + proj_blacklist_2.x(), + proj_blacklist_2.y(), + proj_blacklist_2.w(), + proj_blacklist_2.h()); + break; + } + case 4: { + const PSMoveProtocol::ProjectionBlacklist proj_blacklist_2 = proj_blacklist._5(); + + tracker_view->setBlacklistProjection( + i, + proj_blacklist_2.x(), + proj_blacklist_2.y(), + proj_blacklist_2.w(), + proj_blacklist_2.h()); + break; + } + } + } + tracker_view->saveSettings(); + + response->set_result_code(PSMoveProtocol::Response_ResultCode_RESULT_OK); + } + else + { + response->set_result_code(PSMoveProtocol::Response_ResultCode_RESULT_ERROR); + } + } + else + { + response->set_result_code(PSMoveProtocol::Response_ResultCode_RESULT_ERROR); + } + } void handle_request__set_tracker_intrinsics( const RequestContext &context,