Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

hal/riscv-rvv: implement FAST keypoint detection#27391

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
asmorkalov merged 27 commits intoopencv:4.xfromHaosonn:pr-rvv-hal-fast
Aug 11, 2025
Merged
Show file tree
Hide file tree
Changes from1 commit
Commits
Show all changes
27 commits
Select commitHold shift + click to select a range
e0724db
Empty implementation for FAST function
Mar 20, 2025
a088804
CALL_HAL modification for cv_hal_fast
Apr 17, 2025
8dac44c
basic implementation of fast_9_16 for riscv
Apr 17, 2025
ca88641
debug test modification
Apr 17, 2025
1a1b2e8
Add features2d module in new rvv-hal
May 15, 2025
393ab4c
Merge branch 'github' into rvv-hal-fast
May 15, 2025
2147287
Test FAST.noNMS success
May 15, 2025
8d116fa
weird memory read
May 30, 2025
a15574f
Pass NMS test
May 30, 2025
09e0a44
delete debug messages
May 30, 2025
fa709c3
Add perf tests
Jun 2, 2025
3cfdf0a
Dead code deleted in test_fast.cpp
Jun 2, 2025
77a30d9
Fix requested changes
Jun 3, 2025
835176f
Disable sanity check
Jun 4, 2025
8f20b66
Delete trailing whitespace
Jun 4, 2025
96756ba
Rollback CALL_HAL
Jun 6, 2025
7f77a15
Requested changes in perf_fast.cpp
Jun 9, 2025
08414a4
Requested changes done
Jun 15, 2025
621a65f
Put memset in default branch & keypoint_cnt not initialized bug
Jun 16, 2025
7c40a56
feat: introduce new API for FAST hal
fengyuentauJun 23, 2025
d137e0c
fix: fix bugs in the new API
fengyuentauJun 23, 2025
a41f63b
feat: drop func typedef and use function ptr instead
fengyuentauJun 27, 2025
7f8e331
fix: fix build
fengyuentauJun 27, 2025
390bcf5
doc: add documentation for realloc_func
fengyuentauJun 27, 2025
5f8d2f5
fix: add cv_hal_FASTv2
fengyuentauAug 1, 2025
38bdd05
fix: use different lmul sizes for different specs
fengyuentauAug 7, 2025
3955429
fix: define cv_hal_FASTv2
fengyuentauAug 7, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
PrevPrevious commit
NextNext commit
feat: introduce new API for FAST hal
  • Loading branch information
@fengyuentau
fengyuentau committedJun 23, 2025
commit7c40a56de6bd37d62e7d94ccb2a6e66319bb6013
5 changes: 3 additions & 2 deletionshal/riscv-rvv/include/features2d.hpp
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -11,9 +11,10 @@ namespace cv { namespace rvv_hal { namespace features2d {

#if CV_HAL_RVV_1P0_ENABLED

using realloc_func = void* (*)(void*, size_t);
int 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 detector_type);
uchar** keypoints_data, size_t* keypoints_count,
int threshold, bool nonmax_suppression, int detector_type, realloc_func f);

#undef cv_hal_FAST
#define cv_hal_FAST cv::rvv_hal::features2d::FAST
Expand Down
39 changes: 23 additions & 16 deletionshal/riscv-rvv/src/features2d/fast.cpp
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -97,16 +97,14 @@ inline uint8_t cornerScore(const uint8_t* ptr, const vuint16m2_t& v_offset, int6

inline int fast_16(const uchar* src_data, size_t src_step,
int width, int height,
uchar* keypoints_data, size_t* keypoints_count,
std::vector<cvhalKeyPoint> &keypoints,
int threshold, bool nonmax_suppression)
{

const int patternSize = 16;
const int K = patternSize/2, N = patternSize + K + 1;
const int quarterPatternSize = patternSize/4;

KeyPoint* _keypoints_data = (KeyPoint*)keypoints_data;

int i, j, k;
int16_t pixel[25];
vuint16m2_t v_offset;
Expand DownExpand Up@@ -241,25 +239,25 @@ inline int fast_16(const uchar* src_data, size_t src_step,
score > pprev[j-1] && score > pprev[j] && score > pprev[j+1] &&
score > curr[j-1] && score > curr[j] && score > curr[j+1]) )
{
_keypoints_data[*keypoints_count].pt.x = (float)j;
_keypoints_data[*keypoints_count].pt.y = (float)(i-1);
_keypoints_data[*keypoints_count].size =7.f;
_keypoints_data[*keypoints_count].angle =-1.f;
_keypoints_data[*keypoints_count].response =(float)score;
_keypoints_data[*keypoints_count].octave =0; // Not used in FAST
_keypoints_data[*keypoints_count].class_id =-1; // Not used in FAST

(*keypoints_count)++;
cvhalKeyPoint kp;
kp.x = (float)j;
kp.y =(float)(i-1);
kp.size =7.f;
kp.angle =-1.f;
kp.response =(float)score;
kp.octave =0; // Not used in FAST
kp.class_id = -1; // Not used in FAST
keypoints.push_back(kp);
}
}
}
return CV_HAL_ERROR_OK;
}

int FAST(const uchar* src_data, size_t src_step,
int width, int height, uchar* keypoints_data,
int width, int height, uchar** keypoints_data,
size_t* keypoints_count, int threshold,
bool nonmax_suppression, int detector_type)
bool nonmax_suppression, int detector_type, realloc_func f)
{
(*keypoints_count) = 0;
int res = CV_HAL_ERROR_UNKNOWN;
Expand All@@ -268,8 +266,17 @@ int FAST(const uchar* src_data, size_t src_step,
return CV_HAL_ERROR_NOT_IMPLEMENTED;
case CV_HAL_TYPE_7_12:
return CV_HAL_ERROR_NOT_IMPLEMENTED;
case CV_HAL_TYPE_9_16:
return fast_16(src_data, src_step, width, height, keypoints_data, keypoints_count, threshold, nonmax_suppression);
case CV_HAL_TYPE_9_16: {
std::vector<cvhalKeyPoint> keypoints;
res = fast_16(src_data, src_step, width, height, keypoints, threshold, nonmax_suppression);
if (res == CV_HAL_ERROR_OK) {
*keypoints_count = keypoints.size();
uchar *tmp = (uchar*)f(*keypoints_data, sizeof(cvhalKeyPoint)*(*keypoints_count));
memcpy(tmp, (uchar*)keypoints.data(), sizeof(cvhalKeyPoint)*(*keypoints_count));
keypoints_data = &tmp;
}
return res;
}
default:
return res;
}
Expand Down
10 changes: 6 additions & 4 deletionsmodules/features2d/src/fast.cpp
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -437,13 +437,15 @@ void FAST(InputArray _img, std::vector<KeyPoint>& keypoints, int threshold, bool

size_t keypoints_count = 10000;
keypoints.clear();
keypoints.resize(keypoints_count); // reserve space for keypoints
int hal_ret = cv_hal_FAST(img.data, img.step, img.cols, img.rows, (uchar *)(keypoints.data()),
&keypoints_count, threshold, nonmax_suppression, type);
uchar* kps = (uchar*)malloc(sizeof(KeyPoint) * 1);
uchar** _kps = &kps;
int hal_ret = cv_hal_FAST(img.data, img.step, img.cols, img.rows, _kps,
&keypoints_count, threshold, nonmax_suppression, type, realloc);
if (hal_ret == CV_HAL_ERROR_OK) {
keypoints.resize(keypoints_count);
keypoints.assign(reinterpret_cast<KeyPoint*>(kps), reinterpret_cast<KeyPoint*>(kps) +keypoints_count);
return;
}
free(kps);

switch(type) {
case FastFeatureDetector::TYPE_5_8:
Expand Down
3 changes: 2 additions & 1 deletionmodules/features2d/src/hal_replacement.hpp
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -102,7 +102,8 @@ inline int hal_ni_FAST_NMS(const uchar* src_data, size_t src_step, uchar* dst_da
@param nonmax_suppression Indicates if make nonmaxima suppression or not.
@param type FAST type
*/
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; }
using realloc_func = void* (*)(void*, size_t);
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, realloc_func f) { return CV_HAL_ERROR_NOT_IMPLEMENTED; }

//! @cond IGNORED
#define cv_hal_FAST hal_ni_FAST
Expand Down
Loading

[8]ページ先頭

©2009-2026 Movatter.jp