Skip to content

Commit

Permalink
Reduce number of SIFT test features to make tests run under WSL (colm…
Browse files Browse the repository at this point in the history
  • Loading branch information
ahojnnes authored Jan 8, 2023
1 parent c36cec3 commit d5b4242
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 49 deletions.
2 changes: 1 addition & 1 deletion src/feature/sift.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1124,7 +1124,7 @@ bool CreateSiftGPUMatcher(const SiftMatchingOptions& match_options,
sift_match_gpu->SetLanguage(SiftMatchGPU::SIFTMATCH_GLSL);
#endif // CUDA_ENABLED

if (sift_match_gpu->VerifyContextGL() == 0) {
if (sift_match_gpu->VerifyContextGL() != SiftGPU::SIFTGPU_FULL_SUPPORTED) {
return false;
}

Expand Down
96 changes: 48 additions & 48 deletions src/feature/sift_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -280,9 +280,9 @@ BOOST_AUTO_TEST_CASE(TestCreateSiftGPUMatcherOpenGL) {
void Run() {
opengl_context_.MakeCurrent();
SiftMatchGPU sift_match_gpu;
SiftMatchingOptions match_options;
match_options.max_num_matches = 1000;
BOOST_CHECK(CreateSiftGPUMatcher(match_options, &sift_match_gpu));
SiftMatchingOptions create_options;
create_options.max_num_matches = 1000;
BOOST_CHECK(CreateSiftGPUMatcher(create_options, &sift_match_gpu));
}
OpenGLContextManager opengl_context_;
};
Expand All @@ -294,10 +294,10 @@ BOOST_AUTO_TEST_CASE(TestCreateSiftGPUMatcherOpenGL) {
BOOST_AUTO_TEST_CASE(TestCreateSiftGPUMatcherCUDA) {
#ifdef CUDA_ENABLED
SiftMatchGPU sift_match_gpu;
SiftMatchingOptions match_options;
match_options.gpu_index = "0";
match_options.max_num_matches = 1000;
BOOST_CHECK(CreateSiftGPUMatcher(match_options, &sift_match_gpu));
SiftMatchingOptions create_options;
create_options.gpu_index = "0";
create_options.max_num_matches = 1000;
BOOST_CHECK(CreateSiftGPUMatcher(create_options, &sift_match_gpu));
#endif
}

Expand Down Expand Up @@ -371,53 +371,53 @@ BOOST_AUTO_TEST_CASE(TestMatchSiftFeaturesCPUFLANNvsBruteForce) {
};

{
const FeatureDescriptors descriptors1 = CreateRandomFeatureDescriptors(100);
const FeatureDescriptors descriptors2 = CreateRandomFeatureDescriptors(100);
const FeatureDescriptors descriptors1 = CreateRandomFeatureDescriptors(50);
const FeatureDescriptors descriptors2 = CreateRandomFeatureDescriptors(50);
SiftMatchingOptions match_options;
TestFLANNvsBruteForce(match_options, descriptors1, descriptors2);
}

{
const FeatureDescriptors descriptors1 = CreateRandomFeatureDescriptors(100);
const FeatureDescriptors descriptors1 = CreateRandomFeatureDescriptors(50);
const FeatureDescriptors descriptors2 = descriptors1.colwise().reverse();
SiftMatchingOptions match_options;
const size_t num_matches =
TestFLANNvsBruteForce(match_options, descriptors1, descriptors2);
BOOST_CHECK_EQUAL(num_matches, 100);
BOOST_CHECK_EQUAL(num_matches, 50);
}

// Check the ratio test.
{
FeatureDescriptors descriptors1 = CreateRandomFeatureDescriptors(100);
FeatureDescriptors descriptors1 = CreateRandomFeatureDescriptors(50);
FeatureDescriptors descriptors2 = descriptors1;

SiftMatchingOptions match_options;
const size_t num_matches1 =
TestFLANNvsBruteForce(match_options, descriptors1, descriptors2);
BOOST_CHECK_EQUAL(num_matches1, 100);
BOOST_CHECK_EQUAL(num_matches1, 50);

descriptors2.row(99) = descriptors2.row(0);
descriptors2.row(49) = descriptors2.row(0);
descriptors2(0, 0) += 50.0f;
descriptors2.row(0) = FeatureDescriptorsToUnsignedByte(
L2NormalizeFeatureDescriptors(descriptors2.row(0).cast<float>()));
descriptors2(99, 0) += 100.0f;
descriptors2.row(99) = FeatureDescriptorsToUnsignedByte(
L2NormalizeFeatureDescriptors(descriptors2.row(99).cast<float>()));
descriptors2(49, 0) += 100.0f;
descriptors2.row(49) = FeatureDescriptorsToUnsignedByte(
L2NormalizeFeatureDescriptors(descriptors2.row(49).cast<float>()));

match_options.max_ratio = 0.4;
const size_t num_matches2 = TestFLANNvsBruteForce(
match_options, descriptors1.topRows(99), descriptors2);
BOOST_CHECK_EQUAL(num_matches2, 98);
match_options, descriptors1.topRows(49), descriptors2);
BOOST_CHECK_EQUAL(num_matches2, 48);

match_options.max_ratio = 0.5;
const size_t num_matches3 =
TestFLANNvsBruteForce(match_options, descriptors1, descriptors2);
BOOST_CHECK_EQUAL(num_matches3, 99);
BOOST_CHECK_EQUAL(num_matches3, 49);
}

// Check the cross check.
{
FeatureDescriptors descriptors1 = CreateRandomFeatureDescriptors(100);
FeatureDescriptors descriptors1 = CreateRandomFeatureDescriptors(50);
FeatureDescriptors descriptors2 = descriptors1;
descriptors1.row(0) = descriptors1.row(1);

Expand All @@ -426,12 +426,12 @@ BOOST_AUTO_TEST_CASE(TestMatchSiftFeaturesCPUFLANNvsBruteForce) {
match_options.cross_check = false;
const size_t num_matches1 =
TestFLANNvsBruteForce(match_options, descriptors1, descriptors2);
BOOST_CHECK_EQUAL(num_matches1, 100);
BOOST_CHECK_EQUAL(num_matches1, 50);

match_options.cross_check = true;
const size_t num_matches2 =
TestFLANNvsBruteForce(match_options, descriptors1, descriptors2);
BOOST_CHECK_EQUAL(num_matches2, 98);
BOOST_CHECK_EQUAL(num_matches2, 48);
}
}

Expand Down Expand Up @@ -496,9 +496,9 @@ BOOST_AUTO_TEST_CASE(TestMatchSiftFeaturesGPU) {
void Run() {
opengl_context_.MakeCurrent();
SiftMatchGPU sift_match_gpu;
SiftMatchingOptions match_options;
match_options.max_num_matches = 1000;
BOOST_CHECK(CreateSiftGPUMatcher(match_options, &sift_match_gpu));
SiftMatchingOptions create_options;
create_options.max_num_matches = 1000;
BOOST_CHECK(CreateSiftGPUMatcher(create_options, &sift_match_gpu));

const FeatureDescriptors empty_descriptors =
CreateRandomFeatureDescriptors(0);
Expand Down Expand Up @@ -571,9 +571,9 @@ BOOST_AUTO_TEST_CASE(TestMatchSiftFeaturesCPUvsGPU) {
void Run() {
opengl_context_.MakeCurrent();
SiftMatchGPU sift_match_gpu;
SiftMatchingOptions match_options;
match_options.max_num_matches = 1000;
BOOST_CHECK(CreateSiftGPUMatcher(match_options, &sift_match_gpu));
SiftMatchingOptions create_options;
create_options.max_num_matches = 1000;
BOOST_CHECK(CreateSiftGPUMatcher(create_options, &sift_match_gpu));

auto TestCPUvsGPU = [&sift_match_gpu](
const SiftMatchingOptions& options,
Expand Down Expand Up @@ -615,56 +615,56 @@ BOOST_AUTO_TEST_CASE(TestMatchSiftFeaturesCPUvsGPU) {

{
const FeatureDescriptors descriptors1 =
CreateRandomFeatureDescriptors(100);
CreateRandomFeatureDescriptors(50);
const FeatureDescriptors descriptors2 =
CreateRandomFeatureDescriptors(100);
CreateRandomFeatureDescriptors(50);
SiftMatchingOptions match_options;
TestCPUvsGPU(match_options, descriptors1, descriptors2);
}

{
const FeatureDescriptors descriptors1 =
CreateRandomFeatureDescriptors(100);
CreateRandomFeatureDescriptors(50);
const FeatureDescriptors descriptors2 =
descriptors1.colwise().reverse();
SiftMatchingOptions match_options;
const size_t num_matches =
TestCPUvsGPU(match_options, descriptors1, descriptors2);
BOOST_CHECK_EQUAL(num_matches, 100);
BOOST_CHECK_EQUAL(num_matches, 50);
}

// Check the ratio test.
{
FeatureDescriptors descriptors1 = CreateRandomFeatureDescriptors(100);
FeatureDescriptors descriptors1 = CreateRandomFeatureDescriptors(50);
FeatureDescriptors descriptors2 = descriptors1;

SiftMatchingOptions match_options;
const size_t num_matches1 =
TestCPUvsGPU(match_options, descriptors1, descriptors2);
BOOST_CHECK_EQUAL(num_matches1, 100);
BOOST_CHECK_EQUAL(num_matches1, 50);

descriptors2.row(99) = descriptors2.row(0);
descriptors2.row(49) = descriptors2.row(0);
descriptors2(0, 0) += 50.0f;
descriptors2.row(0) = FeatureDescriptorsToUnsignedByte(
L2NormalizeFeatureDescriptors(descriptors2.row(0).cast<float>()));
descriptors2(99, 0) += 100.0f;
descriptors2.row(99) = FeatureDescriptorsToUnsignedByte(
L2NormalizeFeatureDescriptors(descriptors2.row(99).cast<float>()));
descriptors2(49, 0) += 100.0f;
descriptors2.row(49) = FeatureDescriptorsToUnsignedByte(
L2NormalizeFeatureDescriptors(descriptors2.row(49).cast<float>()));

match_options.max_ratio = 0.4;
const size_t num_matches2 =
TestCPUvsGPU(match_options, descriptors1.topRows(99), descriptors2);
BOOST_CHECK_EQUAL(num_matches2, 98);
TestCPUvsGPU(match_options, descriptors1.topRows(49), descriptors2);
BOOST_CHECK_EQUAL(num_matches2, 48);

match_options.max_ratio = 0.5;
const size_t num_matches3 =
TestCPUvsGPU(match_options, descriptors1, descriptors2);
BOOST_CHECK_EQUAL(num_matches3, 99);
BOOST_CHECK_EQUAL(num_matches3, 49);
}

// Check the cross check.
{
FeatureDescriptors descriptors1 = CreateRandomFeatureDescriptors(100);
FeatureDescriptors descriptors1 = CreateRandomFeatureDescriptors(50);
FeatureDescriptors descriptors2 = descriptors1;
descriptors1.row(0) = descriptors1.row(1);

Expand All @@ -673,12 +673,12 @@ BOOST_AUTO_TEST_CASE(TestMatchSiftFeaturesCPUvsGPU) {
match_options.cross_check = false;
const size_t num_matches1 =
TestCPUvsGPU(match_options, descriptors1, descriptors2);
BOOST_CHECK_EQUAL(num_matches1, 100);
BOOST_CHECK_EQUAL(num_matches1, 50);

match_options.cross_check = true;
const size_t num_matches2 =
TestCPUvsGPU(match_options, descriptors1, descriptors2);
BOOST_CHECK_EQUAL(num_matches2, 98);
BOOST_CHECK_EQUAL(num_matches2, 48);
}
}
OpenGLContextManager opengl_context_;
Expand All @@ -703,9 +703,9 @@ BOOST_AUTO_TEST_CASE(TestMatchGuidedSiftFeaturesGPU) {
void Run() {
opengl_context_.MakeCurrent();
SiftMatchGPU sift_match_gpu;
SiftMatchingOptions match_options;
match_options.max_num_matches = 1000;
BOOST_CHECK(CreateSiftGPUMatcher(match_options, &sift_match_gpu));
SiftMatchingOptions create_options;
create_options.max_num_matches = 1000;
BOOST_CHECK(CreateSiftGPUMatcher(create_options, &sift_match_gpu));

FeatureKeypoints empty_keypoints(0);
FeatureKeypoints keypoints1(2);
Expand Down

0 comments on commit d5b4242

Please sign in to comment.