| 155 | |
| 156 | private: |
| 157 | void Run() override { |
| 158 | if (opengl_context_ != nullptr) { |
| 159 | THROW_CHECK(opengl_context_->MakeCurrent()); |
| 160 | } |
| 161 | |
| 162 | std::unique_ptr<FeatureExtractor> extractor = |
| 163 | FeatureExtractor::Create(extraction_options_); |
| 164 | if (extractor == nullptr) { |
| 165 | LOG(ERROR) << "Failed to create feature extractor."; |
| 166 | SignalInvalidSetup(); |
| 167 | return; |
| 168 | } |
| 169 | |
| 170 | SignalValidSetup(); |
| 171 | |
| 172 | while (true) { |
| 173 | if (IsStopped()) { |
| 174 | break; |
| 175 | } |
| 176 | |
| 177 | auto input_job = input_queue_->Pop(); |
| 178 | if (input_job.IsValid()) { |
| 179 | auto& image_data = input_job.Data(); |
| 180 | |
| 181 | if (image_data.status == ImageReader::Status::SUCCESS) { |
| 182 | const int orig_width = image_data.bitmap->Width(); |
| 183 | const int orig_height = image_data.bitmap->Height(); |
| 184 | const int rot90 = |
| 185 | image_data.pose_prior.HasGravity() |
| 186 | ? ComputeRot90FromGravity(image_data.pose_prior.gravity) |
| 187 | : 0; |
| 188 | if (rot90 > 0) { |
| 189 | image_data.bitmap->Rot90(rot90); |
| 190 | } |
| 191 | if (extractor->Extract(*image_data.bitmap, |
| 192 | &image_data.keypoints, |
| 193 | &image_data.descriptors)) { |
| 194 | if (rot90 > 0) { |
| 195 | const int w = image_data.bitmap->Width(); |
| 196 | const int h = image_data.bitmap->Height(); |
| 197 | for (auto& kp : image_data.keypoints) { |
| 198 | kp.Rot90(4 - rot90, w, h); |
| 199 | } |
| 200 | } |
| 201 | ScaleKeypoints(orig_width, |
| 202 | orig_height, |
| 203 | image_data.camera.width, |
| 204 | image_data.camera.height, |
| 205 | &image_data.keypoints); |
| 206 | if (camera_mask_) { |
| 207 | MaskFeatures(*camera_mask_, |
| 208 | &image_data.keypoints, |
| 209 | &image_data.descriptors); |
| 210 | } |
| 211 | if (image_data.mask) { |
| 212 | MaskFeatures(*image_data.mask, |
| 213 | &image_data.keypoints, |
| 214 | &image_data.descriptors); |
nothing calls this directly
no test coverage detected