summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/core/hle/service/hid/irsensor/clustering_processor.cpp32
-rw-r--r--src/yuzu/bootmanager.cpp3
2 files changed, 18 insertions, 17 deletions
diff --git a/src/core/hle/service/hid/irsensor/clustering_processor.cpp b/src/core/hle/service/hid/irsensor/clustering_processor.cpp
index e5b999b9f..e2f4ae876 100644
--- a/src/core/hle/service/hid/irsensor/clustering_processor.cpp
+++ b/src/core/hle/service/hid/irsensor/clustering_processor.cpp
@@ -53,13 +53,11 @@ void ClusteringProcessor::OnControllerUpdate(Core::HID::ControllerTriggerType ty
53 53
54 RemoveLowIntensityData(filtered_image); 54 RemoveLowIntensityData(filtered_image);
55 55
56 const std::size_t window_start_x = 56 const auto window_start_x = static_cast<std::size_t>(current_config.window_of_interest.x);
57 static_cast<std::size_t>(current_config.window_of_interest.x); 57 const auto window_start_y = static_cast<std::size_t>(current_config.window_of_interest.y);
58 const std::size_t window_start_y = 58 const auto window_end_x =
59 static_cast<std::size_t>(current_config.window_of_interest.y);
60 const std::size_t window_end_x =
61 window_start_x + static_cast<std::size_t>(current_config.window_of_interest.width); 59 window_start_x + static_cast<std::size_t>(current_config.window_of_interest.width);
62 const std::size_t window_end_y = 60 const auto window_end_y =
63 window_start_y + static_cast<std::size_t>(current_config.window_of_interest.height); 61 window_start_y + static_cast<std::size_t>(current_config.window_of_interest.height);
64 62
65 for (std::size_t y = window_start_y; y < window_end_y; y++) { 63 for (std::size_t y = window_start_y; y < window_end_y; y++) {
@@ -76,7 +74,7 @@ void ClusteringProcessor::OnControllerUpdate(Core::HID::ControllerTriggerType ty
76 continue; 74 continue;
77 } 75 }
78 // Cluster object limit reached 76 // Cluster object limit reached
79 if (next_state.object_count >= 0x10) { 77 if (next_state.object_count >= next_state.data.size()) {
80 continue; 78 continue;
81 } 79 }
82 next_state.data[next_state.object_count] = cluster; 80 next_state.data[next_state.object_count] = cluster;
@@ -105,10 +103,11 @@ void ClusteringProcessor::RemoveLowIntensityData(std::vector<u8>& data) {
105ClusteringProcessor::ClusteringData ClusteringProcessor::GetClusterProperties(std::vector<u8>& data, 103ClusteringProcessor::ClusteringData ClusteringProcessor::GetClusterProperties(std::vector<u8>& data,
106 std::size_t x, 104 std::size_t x,
107 std::size_t y) { 105 std::size_t y) {
108 std::queue<Common::Point<std::size_t>> search_points{}; 106 using DataPoint = Common::Point<std::size_t>;
107 std::queue<DataPoint> search_points{};
109 ClusteringData current_cluster = GetPixelProperties(data, x, y); 108 ClusteringData current_cluster = GetPixelProperties(data, x, y);
110 SetPixel(data, x, y, 0); 109 SetPixel(data, x, y, 0);
111 search_points.push({x, y}); 110 search_points.emplace<DataPoint>({x, y});
112 111
113 while (!search_points.empty()) { 112 while (!search_points.empty()) {
114 const auto point = search_points.front(); 113 const auto point = search_points.front();
@@ -119,8 +118,8 @@ ClusteringProcessor::ClusteringData ClusteringProcessor::GetClusterProperties(st
119 continue; 118 continue;
120 } 119 }
121 120
122 std::array<Common::Point<std::size_t>, 4> new_points{ 121 std::array<DataPoint, 4> new_points{
123 Common::Point<std::size_t>{point.x - 1, point.y}, 122 DataPoint{point.x - 1, point.y},
124 {point.x, point.y - 1}, 123 {point.x, point.y - 1},
125 {point.x + 1, point.y}, 124 {point.x + 1, point.y},
126 {point.x, point.y + 1}, 125 {point.x, point.y + 1},
@@ -139,7 +138,7 @@ ClusteringProcessor::ClusteringData ClusteringProcessor::GetClusterProperties(st
139 const ClusteringData cluster = GetPixelProperties(data, new_point.x, new_point.y); 138 const ClusteringData cluster = GetPixelProperties(data, new_point.x, new_point.y);
140 current_cluster = MergeCluster(current_cluster, cluster); 139 current_cluster = MergeCluster(current_cluster, cluster);
141 SetPixel(data, new_point.x, new_point.y, 0); 140 SetPixel(data, new_point.x, new_point.y, 0);
142 search_points.push({new_point.x, new_point.y}); 141 search_points.emplace<DataPoint>({new_point.x, new_point.y});
143 } 142 }
144 } 143 }
145 144
@@ -172,7 +171,7 @@ ClusteringProcessor::ClusteringData ClusteringProcessor::MergeCluster(
172 const f32 a_pixel_count = static_cast<f32>(a.pixel_count); 171 const f32 a_pixel_count = static_cast<f32>(a.pixel_count);
173 const f32 b_pixel_count = static_cast<f32>(b.pixel_count); 172 const f32 b_pixel_count = static_cast<f32>(b.pixel_count);
174 const f32 pixel_count = a_pixel_count + b_pixel_count; 173 const f32 pixel_count = a_pixel_count + b_pixel_count;
175 const f32 average_intensitiy = 174 const f32 average_intensity =
176 (a.average_intensity * a_pixel_count + b.average_intensity * b_pixel_count) / pixel_count; 175 (a.average_intensity * a_pixel_count + b.average_intensity * b_pixel_count) / pixel_count;
177 const Core::IrSensor::IrsCentroid centroid = { 176 const Core::IrSensor::IrsCentroid centroid = {
178 .x = (a.centroid.x * a_pixel_count + b.centroid.x * b_pixel_count) / pixel_count, 177 .x = (a.centroid.x * a_pixel_count + b.centroid.x * b_pixel_count) / pixel_count,
@@ -195,7 +194,7 @@ ClusteringProcessor::ClusteringData ClusteringProcessor::MergeCluster(
195 }; 194 };
196 195
197 return { 196 return {
198 .average_intensity = average_intensitiy, 197 .average_intensity = average_intensity,
199 .centroid = centroid, 198 .centroid = centroid,
200 .pixel_count = static_cast<u32>(pixel_count), 199 .pixel_count = static_cast<u32>(pixel_count),
201 .bound = bound, 200 .bound = bound,
@@ -217,7 +216,8 @@ void ClusteringProcessor::SetPixel(std::vector<u8>& data, std::size_t x, std::si
217} 216}
218 217
219void ClusteringProcessor::SetDefaultConfig() { 218void ClusteringProcessor::SetDefaultConfig() {
220 current_config.camera_config.exposure_time = 200000; 219 using namespace std::literals::chrono_literals;
220 current_config.camera_config.exposure_time = std::chrono::microseconds(200ms).count();
221 current_config.camera_config.gain = 2; 221 current_config.camera_config.gain = 2;
222 current_config.camera_config.is_negative_used = false; 222 current_config.camera_config.is_negative_used = false;
223 current_config.camera_config.light_target = Core::IrSensor::CameraLightTarget::BrightLeds; 223 current_config.camera_config.light_target = Core::IrSensor::CameraLightTarget::BrightLeds;
@@ -228,7 +228,7 @@ void ClusteringProcessor::SetDefaultConfig() {
228 .height = height, 228 .height = height,
229 }; 229 };
230 current_config.pixel_count_min = 3; 230 current_config.pixel_count_min = 3;
231 current_config.pixel_count_max = 0x12C00; 231 current_config.pixel_count_max = static_cast<u32>(GetDataSize(format));
232 current_config.is_external_light_filter_enabled = true; 232 current_config.is_external_light_filter_enabled = true;
233 current_config.object_intensity_min = 150; 233 current_config.object_intensity_min = 150;
234 234
diff --git a/src/yuzu/bootmanager.cpp b/src/yuzu/bootmanager.cpp
index 3acb61f03..8feb85b71 100644
--- a/src/yuzu/bootmanager.cpp
+++ b/src/yuzu/bootmanager.cpp
@@ -805,6 +805,7 @@ void GRenderWindow::TouchEndEvent() {
805} 805}
806 806
807void GRenderWindow::InitializeCamera() { 807void GRenderWindow::InitializeCamera() {
808 constexpr auto camera_update_ms = std::chrono::milliseconds{50}; // (50ms, 20Hz)
808 if (!Settings::values.enable_ir_sensor) { 809 if (!Settings::values.enable_ir_sensor) {
809 return; 810 return;
810 } 811 }
@@ -838,7 +839,7 @@ void GRenderWindow::InitializeCamera() {
838 camera_timer = std::make_unique<QTimer>(); 839 camera_timer = std::make_unique<QTimer>();
839 connect(camera_timer.get(), &QTimer::timeout, [this] { RequestCameraCapture(); }); 840 connect(camera_timer.get(), &QTimer::timeout, [this] { RequestCameraCapture(); });
840 // This timer should be dependent of camera resolution 5ms for every 100 pixels 841 // This timer should be dependent of camera resolution 5ms for every 100 pixels
841 camera_timer->start(50); 842 camera_timer->start(camera_update_ms);
842} 843}
843 844
844void GRenderWindow::FinalizeCamera() { 845void GRenderWindow::FinalizeCamera() {