mirror of
https://github.com/opencv/opencv.git
synced 2026-07-31 08:13:04 +04:00
Merge branch 4.x
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
#include "perf_precomp.hpp"
|
||||
#include "perf_feature2d.hpp"
|
||||
|
||||
namespace opencv_test
|
||||
{
|
||||
using namespace perf;
|
||||
|
||||
typedef tuple<int, int, bool, string> Fast_Params_t;
|
||||
typedef perf::TestBaseWithParam<Fast_Params_t> Fast_Params;
|
||||
|
||||
PERF_TEST_P(Fast_Params, detect,
|
||||
testing::Combine(
|
||||
testing::Values(20,30,100), // threshold
|
||||
testing::Values(
|
||||
// (int)FastFeatureDetector::TYPE_5_8,
|
||||
// (int)FastFeatureDetector::TYPE_7_12,
|
||||
(int)FastFeatureDetector::TYPE_9_16 // detector_type
|
||||
),
|
||||
testing::Bool(), // nonmaxSuppression
|
||||
testing::Values("cv/inpaint/orig.png",
|
||||
"cv/cameracalibration/chess9.png")
|
||||
))
|
||||
{
|
||||
int threshold_p = get<0>(GetParam());
|
||||
int type_p = get<1>(GetParam());
|
||||
bool nonmaxSuppression_p = get<2>(GetParam());
|
||||
string filename = getDataPath(get<3>(GetParam()));
|
||||
|
||||
Mat img = imread(filename, IMREAD_GRAYSCALE);
|
||||
ASSERT_FALSE(img.empty()) << "Failed to load image: " << filename;
|
||||
|
||||
vector<KeyPoint> keypoints;
|
||||
|
||||
declare.in(img);
|
||||
TEST_CYCLE()
|
||||
{
|
||||
FAST(img, keypoints, threshold_p, nonmaxSuppression_p, (FastFeatureDetector::DetectorType)type_p);
|
||||
}
|
||||
|
||||
SANITY_CHECK_NOTHING();
|
||||
}
|
||||
|
||||
} // namespace opencv_test
|
||||
@@ -429,17 +429,31 @@ void FAST(InputArray _img, std::vector<KeyPoint>& keypoints, int threshold, bool
|
||||
{
|
||||
CV_INSTRUMENT_REGION();
|
||||
|
||||
const size_t max_fast_features = std::max(_img.total()/100, size_t(1000)); // Simple heuristic that depends on resolution.
|
||||
|
||||
CV_OCL_RUN(_img.isUMat() && type == FastFeatureDetector::TYPE_9_16,
|
||||
ocl_FAST(_img, keypoints, threshold, nonmax_suppression, 10000));
|
||||
ocl_FAST(_img, keypoints, threshold, nonmax_suppression, (int)max_fast_features));
|
||||
|
||||
cv::Mat img = _img.getMat();
|
||||
CALL_HAL(fast_dense, hal_FAST, img, keypoints, threshold, nonmax_suppression, type);
|
||||
|
||||
size_t keypoints_count = 10000;
|
||||
size_t keypoints_count = 1;
|
||||
keypoints.clear();
|
||||
keypoints.resize(keypoints_count);
|
||||
CALL_HAL(fast, cv_hal_FAST, img.data, img.step, img.cols, img.rows,
|
||||
(uchar*)(keypoints.data()), &keypoints_count, threshold, nonmax_suppression, type);
|
||||
KeyPoint* kps = (KeyPoint*)malloc(sizeof(KeyPoint) * keypoints_count);
|
||||
int hal_ret = cv_hal_FASTv2(img.data, img.step, img.cols, img.rows, (void**)&kps,
|
||||
&keypoints_count, threshold, nonmax_suppression, type, realloc);
|
||||
if (hal_ret == CV_HAL_ERROR_OK) {
|
||||
keypoints.assign(kps, kps + keypoints_count);
|
||||
free(kps);
|
||||
return;
|
||||
} else {
|
||||
free(kps);
|
||||
keypoints_count = max_fast_features;
|
||||
keypoints.clear();
|
||||
keypoints.resize(keypoints_count);
|
||||
CALL_HAL(fast, cv_hal_FAST, img.data, img.step, img.cols, img.rows,
|
||||
(uchar*)(keypoints.data()), &keypoints_count, threshold, nonmax_suppression, type);
|
||||
}
|
||||
|
||||
switch(type) {
|
||||
case FastFeatureDetector::TYPE_5_8:
|
||||
|
||||
@@ -104,8 +104,24 @@ inline int hal_ni_FAST_NMS(const uchar* src_data, size_t src_step, uchar* dst_da
|
||||
*/
|
||||
inline int hal_ni_FAST(const uchar* src_data, size_t src_step, int width, int height, uchar* keypoints_data, size_t* keypoints_count, int threshold, bool nonmax_suppression, int /*cv::FastFeatureDetector::DetectorType*/ type) { return CV_HAL_ERROR_NOT_IMPLEMENTED; }
|
||||
|
||||
/**
|
||||
@brief Detects corners using the FAST algorithm.
|
||||
@param src_data Source image data
|
||||
@param src_step Source image step
|
||||
@param width Source image width
|
||||
@param height Source image height
|
||||
@param keypoints_data Pointer to keypoints
|
||||
@param keypoints_count Count of keypoints
|
||||
@param threshold Threshold for keypoint
|
||||
@param nonmax_suppression Indicates if make nonmaxima suppression or not.
|
||||
@param type FAST type
|
||||
@param realloc_func function for reallocation
|
||||
*/
|
||||
inline int hal_ni_FASTv2(const uchar* src_data, size_t src_step, int width, int height, void** keypoints_data, size_t* keypoints_count, int threshold, bool nonmax_suppression, int /*cv::FastFeatureDetector::DetectorType*/ type, void* (*realloc_func)(void*, size_t)) { return CV_HAL_ERROR_NOT_IMPLEMENTED; }
|
||||
|
||||
//! @cond IGNORED
|
||||
#define cv_hal_FAST hal_ni_FAST
|
||||
#define cv_hal_FASTv2 hal_ni_FASTv2
|
||||
//! @endcond
|
||||
|
||||
//! @}
|
||||
|
||||
Reference in New Issue
Block a user