nareshmlx/opencv-pr huggingface dataset:
**File:** samples/dnn/alpha_matting.py
**Change Type:** added
**Context:** PR #27593: Add Alpha matting samples (C++ and Python)

**Code Changes:**
```diff
@@ -0,0 +1,177 @@
+"""
+This file is part of OpenCV project.
+It is subject to the license terms in the LICENSE file found in the top-level directory of this distribution and at http://opencv.org/license.html.
+
+Copyright (C) 2025, Bigvision LLC.
+
+MODNet Alpha Matting with OpenCV DNN
+
+This sample demonstrates human portrait alpha matting using MODNet model.
```

Review comment:
Moved `draw_label` outside `apply_modnet`.
**File:** samples/dnn/alpha_matting.py
**Change Type:** added
**Context:** PR #27593: Add Alpha matting samples (C++ and Python)

**Code Changes:**
```diff
@@ -0,0 +1,177 @@
+"""
+This file is part of OpenCV project.
+It is subject to the license terms in the LICENSE file found in the top-level directory of this distribution and at http://opencv.org/license.html.
+
+Copyright (C) 2025, Bigvision LLC.
+
+MODNet Alpha Matting with OpenCV DNN
+
+This sample demonstrates human portrait alpha matting using MODNet model.
```

Review comment:
Moved overlay and imshow to `main`; `apply_modnet` now returns `alpha_mask` and `composite`.
**File:** samples/dnn/alpha_matting.py
**Change Type:** added
**Context:** PR #27593: Add Alpha matting samples (C++ and Python)

**Code Changes:**
```diff
@@ -0,0 +1,177 @@
+"""
+This file is part of OpenCV project.
+It is subject to the license terms in the LICENSE file found in the top-level directory of this distribution and at http://opencv.org/license.html.
+
+Copyright (C) 2025, Bigvision LLC.
+
+MODNet Alpha Matting with OpenCV DNN
+
+This sample demonstrates human portrait alpha matting using MODNet model.
```

Review comment:
Moved compositing to `apply_modnet`; now returning only `alpha_mask`.
**File:** samples/dnn/models.yml
**Change Type:** modified
**Context:** PR #27593: Add Alpha matting samples (C++ and Python)
**Review Line:** 523

**Code Changes:**
```diff
+  mean: [0.0, 0.0, 0.0]
+  scale: 0.00784313725
+  width: 512
+  height: 512
+  rgb: true
+  sample: "alpha_matting"
```

Review comment:
Could you add link to the original repo with the model, rather than own fork? If it's not possible, please extend your repo with: - Link to the original model and/or paper. - Command line / pre-requsites to export ONNX - License information and credits.
**File:** samples/dnn/alpha_matting.py
**Change Type:** added
**Context:** PR #27593: Add Alpha matting samples (C++ and Python)

**Code Changes:**
```diff
@@ -0,0 +1,177 @@
+"""
+This file is part of OpenCV project.
+It is subject to the license terms in the LICENSE file found in the top-level directory of this distribution and at http://opencv.org/license.html.
+
+Copyright (C) 2025, Bigvision LLC.
+
+MODNet Alpha Matting with OpenCV DNN
+
+This sample demonstrates human portrait alpha matting using MODNet model.
```

Review comment:
I wound say, it should be inside of `apply_modnet`
**File:** samples/dnn/alpha_matting.cpp
**Change Type:** added
**Context:** PR #27593: Add Alpha matting samples (C++ and Python)

**Code Changes:**
```diff
@@ -0,0 +1,201 @@
+/*
+ * This file is part of OpenCV project.
+ * It is subject to the license terms in the LICENSE file found in the top-level directory of this distribution and at http://opencv.org/license.html.
+ *
+ * Copyright (C) 2025, Bigvision LLC.
+ *
+ * @file alpha_matting.cpp
+ * @brief MODNet Alpha Matting using OpenCV DNN
+ *
```

Review comment:
There is no such step in Python version. Why do you need it?
**File:** samples/dnn/alpha_matting.cpp
**Change Type:** added
**Context:** PR #27593: Add Alpha matting samples (C++ and Python)

**Code Changes:**
```diff
@@ -0,0 +1,201 @@
+/*
+ * This file is part of OpenCV project.
+ * It is subject to the license terms in the LICENSE file found in the top-level directory of this distribution and at http://opencv.org/license.html.
+ *
+ * Copyright (C) 2025, Bigvision LLC.
+ *
+ * @file alpha_matting.cpp
+ * @brief MODNet Alpha Matting using OpenCV DNN
+ *
```

Review comment:
It was intended as an extra normalization, but since the Python version doesn't perform this step and it's not essential, I’ve removed it for consistency.
**File:** samples/dnn/alpha_matting.py
**Change Type:** added
**Context:** PR #27593: Add Alpha matting samples (C++ and Python)

**Code Changes:**
```diff
@@ -0,0 +1,177 @@
+"""
+This file is part of OpenCV project.
+It is subject to the license terms in the LICENSE file found in the top-level directory of this distribution and at http://opencv.org/license.html.
+
+Copyright (C) 2025, Bigvision LLC.
+
+MODNet Alpha Matting with OpenCV DNN
+
+This sample demonstrates human portrait alpha matting using MODNet model.
```

Review comment:
Moved inside of `apply_modnet`.
**File:** samples/dnn/models.yml
**Change Type:** modified
**Context:** PR #27593: Add Alpha matting samples (C++ and Python)
**Review Line:** 523

**Code Changes:**
```diff
+  mean: [0.0, 0.0, 0.0]
+  scale: 0.00784313725
+  width: 512
+  height: 512
+  rgb: true
+  sample: "alpha_matting"
```

Review comment:
Since the original repository does not provide an ONNX model, I have extended my repository based on the referenced comment. https://github.com/HarxSan/Modnet/blob/main/README.md
**File:** modules/features2d/src/hal_replacement.hpp
**Change Type:** modified
**Context:** PR #27391: hal/riscv-rvv: implement FAST keypoint detection

**Code Changes:**
```diff
@@ -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
```

Review comment:
It's dangerous replacement. HAL uses C style API without std::vector on purpose. HAL may be a binary built with own STL. It means that std::vector on HAL side and OpenCV side may be different with different memory layout.
**File:** modules/features2d/src/hal_replacement.hpp
**Change Type:** modified
**Context:** PR #27391: hal/riscv-rvv: implement FAST keypoint detection

**Code Changes:**
```diff
@@ -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
```

Review comment:
Indeed. But I haven't figured out a way to modify the member `size` in `std::vector<cv::KeyPoint>& keypoints` by simply reinterpreting `keypoints.data()` to `uchar*`. The original `CALL_HAL`, causes wrong keypoint count in accuracy test since it compares the member `size` of the output `std::vector<cv::KeyPoint>`. Is there any solution for the problem?
**File:** hal/riscv-rvv/include/features2d.hpp
**Change Type:** added
**Context:** PR #27391: hal/riscv-rvv: implement FAST keypoint detection
**Review Line:** 14

**Code Changes:**
```diff
+
+namespace cv { namespace rvv_hal { namespace features2d {
+
+#if CV_HAL_RVV_1P0_ENABLED
+
+int FAST(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 detector_type, void* (*realloc_func)(void*, size_t));
+
+#undef cv_hal_FASTv2
+#define cv_hal_FASTv2 cv::rvv_hal::features2d::FAST
```

Review comment:
Newline before this line 13.
**File:** hal/riscv-rvv/src/features2d/fast.cpp
**Change Type:** added
**Context:** PR #27391: hal/riscv-rvv: implement FAST keypoint detection

**Code Changes:**
```diff
@@ -0,0 +1,256 @@
+#include "rvv_hal.hpp"
+#include "common.hpp"
+#include <cfloat>
+
+namespace cv { namespace rvv_hal { namespace features2d {
+
+static inline uint8_t cornerScore(const uint8_t* ptr, const int* pixel)
+{
+    constexpr int K = 8, N = 16 + K + 1;
```

Review comment:
Drop this line and the multiple empty lines after that.
**File:** hal/riscv-rvv/src/features2d/fast.cpp
**Change Type:** added
**Context:** PR #27391: hal/riscv-rvv: implement FAST keypoint detection

**Code Changes:**
```diff
@@ -0,0 +1,256 @@
+#include "rvv_hal.hpp"
+#include "common.hpp"
+#include <cfloat>
+
+namespace cv { namespace rvv_hal { namespace features2d {
+
+static inline uint8_t cornerScore(const uint8_t* ptr, const int* pixel)
+{
+    constexpr int K = 8, N = 16 + K + 1;
```

Review comment:
Drop comments if not needed.
**File:** modules/features2d/perf/perf_fast.cpp
**Change Type:** added
**Context:** PR #27391: hal/riscv-rvv: implement FAST keypoint detection

**Code Changes:**
```diff
@@ -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;
```

Review comment:
Comments are not aligned.
**File:** modules/features2d/perf/perf_fast.cpp
**Change Type:** added
**Context:** PR #27391: hal/riscv-rvv: implement FAST keypoint detection

**Code Changes:**
```diff
@@ -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;
```

Review comment:
Second line is not aligned.
**File:** modules/features2d/perf/perf_fast.cpp
**Change Type:** added
**Context:** PR #27391: hal/riscv-rvv: implement FAST keypoint detection

**Code Changes:**
```diff
@@ -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;
```

Review comment:
Newline before end of file
**File:** hal/riscv-rvv/src/features2d/fast.cpp
**Change Type:** added
**Context:** PR #27391: hal/riscv-rvv: implement FAST keypoint detection

**Code Changes:**
```diff
@@ -0,0 +1,256 @@
+#include "rvv_hal.hpp"
+#include "common.hpp"
+#include <cfloat>
+
+namespace cv { namespace rvv_hal { namespace features2d {
+
+static inline uint8_t cornerScore(const uint8_t* ptr, const int* pixel)
+{
+    constexpr int K = 8, N = 16 + K + 1;
```

Review comment:
I suspect that you can also use `std::vector` as buffer container just like carotene does.
**File:** modules/features2d/src/hal_replacement.hpp
**Change Type:** modified
**Context:** PR #27391: hal/riscv-rvv: implement FAST keypoint detection

**Code Changes:**
```diff
@@ -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
```

Review comment:
A simple solution is that you can extract the macro of calling HAL, manually call HAL function and do a resize on the vector before returning. E.g. ```.diff diff --git a/modules/features2d/src/fast.cpp b/modules/features2d/src/fast.cpp index a9615da5bd..b00b80818d 100644 --- a/modules/features2d/src/fast.cpp +++ b/modules/features2d/src/fast.cpp @@ -438,8 +438,12 @@ void FAST(InputArray _img, std::vector<KeyPoint>& keypoints, int threshold, bool size_t keypoints_count = 10000; 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); + int hal_ret = cv_hal_FAST(img.data, img.step, img.cols, img.rows, (uchar *)(keypoints.data()), + &keypoints_count, threshold, nonmax_suppression, type); + if (hal_ret == CV_HAL_ERROR_OK) { + keypoints.resize(keypoints_count); + return; + } switch(type) { case FastFeatureDetector::TYPE_5_8: ```
**File:** hal/riscv-rvv/CMakeLists.txt
**Change Type:** modified
**Context:** PR #27391: hal/riscv-rvv: implement FAST keypoint detection

**Code Changes:**
```diff
@@ -17,7 +17,8 @@ endif()
 target_include_directories(${HAL_LIB_NAME} PRIVATE
   ${CMAKE_CURRENT_SOURCE_DIR}
   ${CMAKE_SOURCE_DIR}/modules/core/include
-  ${CMAKE_SOURCE_DIR}/modules/imgproc/include) #   ${CMAKE_SOURCE_DIR}/modules/features2d/include
+  ${CMAKE_SOURCE_DIR}/modules/imgproc/include
+  ${CMAKE_SOURCE_DIR}/modules/features2d/include)
 
 set(RVV_HAL_FOUND TRUE CACHE INTERNAL "")
 set(RVV_HAL_VERSION "0.0.1" CACHE INTERNAL "")
```

Review comment:
hal/riscv-rvv/CMakeLists.txt:20: trailing whitespace. + ${CMAKE_SOURCE_DIR}/modules/imgproc/include
**File:** modules/features2d/perf/perf_fast.cpp
**Change Type:** added
**Context:** PR #27391: hal/riscv-rvv: implement FAST keypoint detection

**Code Changes:**
```diff
@@ -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;
```

Review comment:
There are warnings: ``` /home/ci/opencv/modules/features2d/perf/perf_fast.cpp: In member function 'virtual void opencv_test::Fast_Params_detect::PerfTestBody()': /home/ci/opencv/modules/features2d/perf/perf_fast.cpp:24:9: warning: declaration of 'threshold' shadows a global declaration [-Wshadow] 24 | int threshold = get<0>(GetParam()); | ^~~~~~~~~ In file included from /home/ci/opencv/modules/features2d/perf/perf_precomp.hpp:4, from /home/ci/opencv/modules/features2d/perf/perf_fast.cpp:1: /home/ci/opencv/modules/ts/include/opencv2/ts.hpp:957:21: note: shadowed declaration is here 957 | CVTEST_GUARD_SYMBOL(threshold) | ^~~~~~~~~ /home/ci/opencv/modules/ts/include/opencv2/ts.hpp:946:11: note: in definition of macro 'CVTEST_GUARD_SYMBOL' 946 | using name = required_namespace_specificatin_here_for_symbol_ ## name; | ^~~~ /home/ci/opencv/modules/features2d/perf/perf_fast.cpp:34:11: warning: unused variable 't1' [-Wunused-variable] 34 | int64 t1 = cv::getTickCount(); | ^~ /home/ci/opencv/modules/features2d/perf/perf_fast.cpp:38:11: warning: unused variable 't2' [-Wunused-variable] 38 | int64 t2 = cv::getTickCount(); | ^~ ```
**File:** modules/features2d/perf/perf_fast.cpp
**Change Type:** added
**Context:** PR #27391: hal/riscv-rvv: implement FAST keypoint detection

**Code Changes:**
```diff
@@ -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;
```

Review comment:
Warnings: Warning: /home/ci/opencv/modules/features2d/perf/perf_fast.cpp:34:11: warning: unused variable 't1' [-Wunused-variable] Warning: /home/ci/opencv/modules/features2d/perf/perf_fast.cpp:38:11: warning: unused variable 't2' [-Wunused-variable]
**File:** modules/features2d/perf/perf_fast.cpp
**Change Type:** added
**Context:** PR #27391: hal/riscv-rvv: implement FAST keypoint detection

**Code Changes:**
```diff
@@ -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;
```

Review comment:
Drop this since `TEST_CYCLE` already does the job.
**File:** modules/features2d/perf/perf_fast.cpp
**Change Type:** added
**Context:** PR #27391: hal/riscv-rvv: implement FAST keypoint detection

**Code Changes:**
```diff
@@ -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;
```

Review comment:
If you do not plan to update data for sanity check, drop the comment.
**File:** modules/features2d/src/fast.cpp
**Change Type:** modified
**Context:** PR #27391: hal/riscv-rvv: implement FAST keypoint detection

**Code Changes:**
```diff
@@ -435,11 +435,23 @@ void FAST(InputArray _img, std::vector<KeyPoint>& keypoints, int threshold, bool
     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);
```

Review comment:
Why they are changed?
**File:** modules/features2d/src/fast.cpp
**Change Type:** modified
**Context:** PR #27391: hal/riscv-rvv: implement FAST keypoint detection

**Code Changes:**
```diff
@@ -435,11 +435,23 @@ void FAST(InputArray _img, std::vector<KeyPoint>& keypoints, int threshold, bool
     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);
```

Review comment:
The first `resize(10000)` is used for initial memory allocation. Otherwise if this is not done, `resize(keypoints_count)` after `CALL_HAL` may cause unexpected outcome in the vector
**File:** modules/features2d/src/fast.cpp
**Change Type:** modified
**Context:** PR #27391: hal/riscv-rvv: implement FAST keypoint detection

**Code Changes:**
```diff
@@ -435,11 +435,23 @@ void FAST(InputArray _img, std::vector<KeyPoint>& keypoints, int threshold, bool
     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);
```

Review comment:
I mean you don't have to change keypoints and keypoints_count and it is still calling resize before entering hal, right?
**File:** hal/riscv-rvv/src/features2d/fast.cpp
**Change Type:** added
**Context:** PR #27391: hal/riscv-rvv: implement FAST keypoint detection

**Code Changes:**
```diff
@@ -0,0 +1,256 @@
+#include "rvv_hal.hpp"
+#include "common.hpp"
+#include <cfloat>
+
+namespace cv { namespace rvv_hal { namespace features2d {
+
+static inline uint8_t cornerScore(const uint8_t* ptr, const int* pixel)
+{
+    constexpr int K = 8, N = 16 + K + 1;
```

Review comment:
Memset is redundant if patternSize == 16. I propose to move to `default` branch.
**File:** modules/features2d/src/fast.cpp
**Change Type:** modified
**Context:** PR #27391: hal/riscv-rvv: implement FAST keypoint detection

**Code Changes:**
```diff
@@ -435,11 +435,23 @@ void FAST(InputArray _img, std::vector<KeyPoint>& keypoints, int threshold, bool
     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);
```

Review comment:
you don't need extra variable. Use the following code instead: ``` KeyPoint* kps = (KeyPoint*)malloc(sizeof(kps[0]) * keypoints_count); int hal_ret = cv_hal_FAST(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); if (hal_ret == CV_HAL_ERROR_OK) { return; } ```
**File:** modules/features2d/src/hal_replacement.hpp
**Change Type:** modified
**Context:** PR #27391: hal/riscv-rvv: implement FAST keypoint detection

**Code Changes:**
```diff
@@ -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
```

Review comment:
We usually presume backward compatibility in HAL. I propose to presume the original API and add new entrypoint with realloc, e.g. `hal_ni_FAST_withRealloc`. On caller side you need to try the new one, then the old one and then default impl.
**File:** hal/riscv-rvv/src/features2d/fast.cpp
**Change Type:** added
**Context:** PR #27391: hal/riscv-rvv: implement FAST keypoint detection

**Code Changes:**
```diff
@@ -0,0 +1,256 @@
+#include "rvv_hal.hpp"
+#include "common.hpp"
+#include <cfloat>
+
+namespace cv { namespace rvv_hal { namespace features2d {
+
+static inline uint8_t cornerScore(const uint8_t* ptr, const int* pixel)
+{
+    constexpr int K = 8, N = 16 + K + 1;
```

Review comment:
CI node has 128x2-bit width of register, so max number of uint16_t elements in a lane is 16. 25 is just wrong.
**File:** modules/features2d/src/fast.cpp
**Change Type:** modified
**Context:** PR #27391: hal/riscv-rvv: implement FAST keypoint detection
**Review Line:** 438

**Code Changes:**
```diff
@@ -435,11 +435,23 @@ void FAST(InputArray _img, std::vector<KeyPoint>& keypoints, int threshold, bool
     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);
```

Review comment:
Need to revert back for HAL version 1.
**File:** modules/features2d/src/fast.cpp
**Change Type:** modified
**Context:** PR #27391: hal/riscv-rvv: implement FAST keypoint detection
**Review Line:** 438

**Code Changes:**
```diff
@@ -435,11 +435,23 @@ void FAST(InputArray _img, std::vector<KeyPoint>& keypoints, int threshold, bool
     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);
```

Review comment:
HAL v2 is called first. when calling HAL v1, it is set back to 10k at line 449.