| 170 | } |
| 171 | |
| 172 | void FeatureImageViewerWidget::ReadAndShowWithKeypoints( |
| 173 | const std::filesystem::path& path, |
| 174 | const FeatureKeypoints& keypoints, |
| 175 | const std::vector<char>& tri_mask) { |
| 176 | Bitmap bitmap; |
| 177 | if (!bitmap.Read(path, /*as_rgb=*/true)) { |
| 178 | LOG(ERROR) << "Cannot read image at path " << path; |
| 179 | return; |
| 180 | } |
| 181 | |
| 182 | image1_ = QPixmap::fromImage(BitmapToQImageRGB(bitmap)); |
| 183 | image2_ = image1_; |
| 184 | |
| 185 | const size_t num_tri_keypoints = std::count_if( |
| 186 | tri_mask.begin(), tri_mask.end(), [](const bool tri) { return tri; }); |
| 187 | |
| 188 | FeatureKeypoints keypoints_tri(num_tri_keypoints); |
| 189 | FeatureKeypoints keypoints_not_tri(keypoints.size() - num_tri_keypoints); |
| 190 | size_t idx_tri = 0; |
| 191 | size_t idx_not_tri = 0; |
| 192 | for (size_t i = 0; i < tri_mask.size(); ++i) { |
| 193 | if (tri_mask[i]) { |
| 194 | keypoints_tri[idx_tri++] = keypoints[i]; |
| 195 | } else { |
| 196 | keypoints_not_tri[idx_not_tri++] = keypoints[i]; |
| 197 | } |
| 198 | } |
| 199 | |
| 200 | DrawKeypoints(&image2_, keypoints_tri, Qt::magenta); |
| 201 | DrawKeypoints(&image2_, keypoints_not_tri, Qt::red); |
| 202 | |
| 203 | if (switch_state_) { |
| 204 | ShowPixmap(image2_); |
| 205 | } else { |
| 206 | ShowPixmap(image1_); |
| 207 | } |
| 208 | } |
| 209 | |
| 210 | void FeatureImageViewerWidget::ReadAndShowWithMatches( |
| 211 | const std::filesystem::path& path1, |
no test coverage detected