Path: blob/master/modules/features2d/test/test_akaze.cpp
16354 views
// This file is part of OpenCV project.1// It is subject to the license terms in the LICENSE file found in the top-level directory2// of this distribution and at http://opencv.org/license.html34#include "test_precomp.hpp"56namespace opencv_test { namespace {78TEST(Features2d_AKAZE, detect_and_compute_split)9{10Mat testImg(100, 100, CV_8U);11RNG rng(101);12rng.fill(testImg, RNG::UNIFORM, Scalar(0), Scalar(255), true);1314Ptr<Feature2D> ext = AKAZE::create(AKAZE::DESCRIPTOR_MLDB, 0, 3, 0.001f, 1, 1, KAZE::DIFF_PM_G2);15vector<KeyPoint> detAndCompKps;16Mat desc;17ext->detectAndCompute(testImg, noArray(), detAndCompKps, desc);1819vector<KeyPoint> detKps;20ext->detect(testImg, detKps);2122ASSERT_EQ(detKps.size(), detAndCompKps.size());2324for(size_t i = 0; i < detKps.size(); i++)25ASSERT_EQ(detKps[i].hash(), detAndCompKps[i].hash());26}2728/**29* This test is here to guard propagation of NaNs that happens on this image. NaNs are guarded30* by debug asserts in AKAZE, which should fire for you if you are lucky.31*32* This test also reveals problems with uninitialized memory that happens only on this image.33* This is very hard to hit and depends a lot on particular allocator. Run this test in valgrind and check34* for uninitialized values if you think you are hitting this problem again.35*/36TEST(Features2d_AKAZE, uninitialized_and_nans)37{38Mat b1 = imread(cvtest::TS::ptr()->get_data_path() + "../stitching/b1.png");39ASSERT_FALSE(b1.empty());4041vector<KeyPoint> keypoints;42Mat desc;43Ptr<Feature2D> akaze = AKAZE::create();44akaze->detectAndCompute(b1, noArray(), keypoints, desc);45}4647}} // namespace484950