MCPcopy Create free account
hub / github.com/colmap/colmap / MaskFeatures

Function MaskFeatures

src/colmap/controllers/feature_extraction.cc:60–84  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

58}
59
60void MaskFeatures(const Bitmap& mask,
61 FeatureKeypoints* keypoints,
62 FeatureDescriptors* descriptors) {
63 size_t out_index = 0;
64 for (size_t i = 0; i < keypoints->size(); ++i) {
65 const auto color = mask.GetPixel(static_cast<int>(keypoints->at(i).x),
66 static_cast<int>(keypoints->at(i).y));
67 if (!color || color->r == 0) {
68 // Delete this keypoint by not copying it to the output.
69 } else {
70 // Retain this keypoint by copying it to the output index (in case this
71 // index differs from its current position).
72 if (out_index != i) {
73 keypoints->at(out_index) = keypoints->at(i);
74 for (int col = 0; col < descriptors->data.cols(); ++col) {
75 descriptors->data(out_index, col) = descriptors->data(i, col);
76 }
77 }
78 out_index += 1;
79 }
80 }
81
82 keypoints->resize(out_index);
83 descriptors->data.conservativeResize(out_index, descriptors->data.cols());
84}
85
86struct ImageData {
87 ImageReader::Status status = ImageReader::Status::FAILURE;

Callers 1

RunMethod · 0.85

Calls 2

sizeMethod · 0.80
GetPixelMethod · 0.80

Tested by

no test coverage detected