nareshmlx/opencv-pr huggingface dataset:
**File:** modules/core/include/opencv2/core/mat.hpp
**Change Type:** modified
**Context:** PR #26056: New dnn engine
**Review Line:** 88

**Code Changes:**
```diff
+    DATA_LAYOUT_BLOCK = 7,     //!< Block layout (also referred to as 'NC1HWC0'), which some accelerators need and even on CPU a better performance may be achieved.
+
+    // for compatibility with the old code in DNN
+    DNN_LAYOUT_UNKNOWN = 0,
+    DNN_LAYOUT_ND = 1,        //!< OpenCV data layout for 2D data.
+    DNN_LAYOUT_NCHW = 2,      //!< OpenCV data layout for 4D data.
+    DNN_LAYOUT_NCDHW = 3,     //!< OpenCV data layout for 5D data.
+    DNN_LAYOUT_NHWC = 4,      //!< Tensorflow-like data layout for 4D data.
+    DNN_LAYOUT_NDHWC = 5,     //!< Tensorflow-like data layout for 5D data.
+    DNN_LAYOUT_PLANAR = 6,    //!< Tensorflow-like data layout, it should only be used at tf or tflite model parsing.
+    DNN_LAYOUT_BLOCK = 7,     //!< Block layout (also referred to as 'NC1HWC0'), which some accelerators need and even on CPU a better performance may be achieved.
```

Review comment:
We should not have DNN-specific code in the `core` module.
**File:** modules/core/include/opencv2/core.hpp
**Change Type:** modified
**Context:** PR #26056: New dnn engine
**Review Line:** 1176

**Code Changes:**
```diff
+/** @brief Broadcast the given Mat to the given shape.
+ * @param src input array
+ * @param shape target shape. Note that negative values are not supported.
+ * @param dst output array that has the given shape
+ */
+CV_EXPORTS void broadcast(InputArray src, const MatShape& shape, OutputArray dst);
+
 enum RotateFlags {
     ROTATE_90_CLOCKWISE = 0, //!<Rotate 90 degrees clockwise
     ROTATE_180 = 1, //!<Rotate 180 degrees clockwise
```

Review comment:
shape is overload of InputArray here. I would treat it as InputTensor too.
**File:** samples/dnn/person_reid.cpp
**Change Type:** modified
**Context:** PR #25667: Improved person reid cpp and python sample

**Code Changes:**
```diff
@@ -1,245 +1,372 @@
-//
-// You can download a baseline ReID model and sample input from:
-// https://github.com/ReID-Team/ReID_extra_testdata
-//
-// Authors of samples and Youtu ReID baseline:
-//         Xing Sun <winfredsun@tencent.com>
-//         Feng Zheng <zhengf@sustech.edu.cn>
-//         Xinyang Jiang <sevjiang@tencent.com>
-//         Fufu Yu <fufuyu@tencent.com>
```

Review comment:
OpenCV provides cv::normalize for it.
**File:** samples/dnn/person_reid.cpp
**Change Type:** modified
**Context:** PR #25667: Improved person reid cpp and python sample

**Code Changes:**
```diff
@@ -1,245 +1,372 @@
-//
-// You can download a baseline ReID model and sample input from:
-// https://github.com/ReID-Team/ReID_extra_testdata
-//
-// Authors of samples and Youtu ReID baseline:
-//         Xing Sun <winfredsun@tencent.com>
-//         Feng Zheng <zhengf@sustech.edu.cn>
-//         Xinyang Jiang <sevjiang@tencent.com>
-//         Fufu Yu <fufuyu@tencent.com>
```

Review comment:
You can use blobFromImageWithParams and remove own `preprocess` function.
**File:** samples/dnn/person_reid.cpp
**Change Type:** modified
**Context:** PR #25667: Improved person reid cpp and python sample

**Code Changes:**
```diff
@@ -1,245 +1,372 @@
-//
-// You can download a baseline ReID model and sample input from:
-// https://github.com/ReID-Team/ReID_extra_testdata
-//
-// Authors of samples and Youtu ReID baseline:
-//         Xing Sun <winfredsun@tencent.com>
-//         Feng Zheng <zhengf@sustech.edu.cn>
-//         Xinyang Jiang <sevjiang@tencent.com>
-//         Fufu Yu <fufuyu@tencent.com>
```

Review comment:
`FLT_MIN`?
**File:** samples/dnn/person_reid.cpp
**Change Type:** modified
**Context:** PR #25667: Improved person reid cpp and python sample

**Code Changes:**
```diff
@@ -1,245 +1,372 @@
-//
-// You can download a baseline ReID model and sample input from:
-// https://github.com/ReID-Team/ReID_extra_testdata
-//
-// Authors of samples and Youtu ReID baseline:
-//         Xing Sun <winfredsun@tencent.com>
-//         Feng Zheng <zhengf@sustech.edu.cn>
-//         Xinyang Jiang <sevjiang@tencent.com>
-//         Fufu Yu <fufuyu@tencent.com>
```

Review comment:
It's just dotProduct. You can use OpenCV impl.
**File:** samples/dnn/person_reid.cpp
**Change Type:** modified
**Context:** PR #25667: Improved person reid cpp and python sample

**Code Changes:**
```diff
@@ -1,245 +1,372 @@
-//
-// You can download a baseline ReID model and sample input from:
-// https://github.com/ReID-Team/ReID_extra_testdata
-//
-// Authors of samples and Youtu ReID baseline:
-//         Xing Sun <winfredsun@tencent.com>
-//         Feng Zheng <zhengf@sustech.edu.cn>
-//         Xinyang Jiang <sevjiang@tencent.com>
-//         Fufu Yu <fufuyu@tencent.com>
```

Review comment:
Why TopK? It's just Top1.
**File:** samples/dnn/person_reid.cpp
**Change Type:** modified
**Context:** PR #25667: Improved person reid cpp and python sample

**Code Changes:**
```diff
@@ -1,245 +1,372 @@
-//
-// You can download a baseline ReID model and sample input from:
-// https://github.com/ReID-Team/ReID_extra_testdata
-//
-// Authors of samples and Youtu ReID baseline:
-//         Xing Sun <winfredsun@tencent.com>
-//         Feng Zheng <zhengf@sustech.edu.cn>
-//         Xinyang Jiang <sevjiang@tencent.com>
-//         Fufu Yu <fufuyu@tencent.com>
```

Review comment:
reference is better here.
**File:** samples/dnn/person_reid.cpp
**Change Type:** modified
**Context:** PR #25667: Improved person reid cpp and python sample

**Code Changes:**
```diff
@@ -1,245 +1,372 @@
-//
-// You can download a baseline ReID model and sample input from:
-// https://github.com/ReID-Team/ReID_extra_testdata
-//
-// Authors of samples and Youtu ReID baseline:
-//         Xing Sun <winfredsun@tencent.com>
-//         Feng Zheng <zhengf@sustech.edu.cn>
-//         Xinyang Jiang <sevjiang@tencent.com>
-//         Fufu Yu <fufuyu@tencent.com>
```

Review comment:
The first element is used. I propose to replace the function parameter to `const std::vector<float>&` and check query emptiness on caller side.
**File:** samples/dnn/person_reid.cpp
**Change Type:** modified
**Context:** PR #25667: Improved person reid cpp and python sample

**Code Changes:**
```diff
@@ -1,245 +1,372 @@
-//
-// You can download a baseline ReID model and sample input from:
-// https://github.com/ReID-Team/ReID_extra_testdata
-//
-// Authors of samples and Youtu ReID baseline:
-//         Xing Sun <winfredsun@tencent.com>
-//         Feng Zheng <zhengf@sustech.edu.cn>
-//         Xinyang Jiang <sevjiang@tencent.com>
-//         Fufu Yu <fufuyu@tencent.com>
```

Review comment:
The dedicated function does not make a lot of sense. I propose to merge it inside of main.
**File:** samples/dnn/person_reid.cpp
**Change Type:** modified
**Context:** PR #25667: Improved person reid cpp and python sample

**Code Changes:**
```diff
@@ -1,245 +1,372 @@
-//
-// You can download a baseline ReID model and sample input from:
-// https://github.com/ReID-Team/ReID_extra_testdata
-//
-// Authors of samples and Youtu ReID baseline:
-//         Xing Sun <winfredsun@tencent.com>
-//         Feng Zheng <zhengf@sustech.edu.cn>
-//         Xinyang Jiang <sevjiang@tencent.com>
-//         Fufu Yu <fufuyu@tencent.com>
```

Review comment:
Please refresh description with information about env variables.
**File:** samples/dnn/person_reid.py
**Change Type:** modified
**Context:** PR #25667: Improved person reid cpp and python sample
**Review Line:** 257

**Code Changes:**
```diff
+        label="Tracking"
+        labelSize, _ = cv.getTextSize(label, cv.FONT_HERSHEY_SIMPLEX, fontSize, fontThickness)
+        cv.rectangle(frame, (0, 0), (labelSize[0]+10, labelSize[1]+10), (255,255,255), cv.FILLED)
+        cv.putText(frame, label, (10, int(25*fontSize)), cv.FONT_HERSHEY_SIMPLEX, fontSize, (0, 0, 0), fontThickness)
+        cv.imshow("TRACKING", frame)
+        if cv.waitKey(1) & 0xFF in [ord('q'), 27]:
+            break
+
+    cap.release()
+    cv.destroyAllWindows()
+    return
```

Review comment:
`if cv.waitKey(1) in [ord('q'), 27]:`
**File:** samples/dnn/person_reid.py
**Change Type:** modified
**Context:** PR #25667: Improved person reid cpp and python sample
**Review Line:** 220

**Code Changes:**
```diff
+            cv.rectangle(image, (0, 0), (labelSize[0]+10, labelSize[1]+int(30*fontSize)), (255,255,255), cv.FILLED)
+            cv.putText(image, label, (10, int(25*fontSize)), cv.FONT_HERSHEY_SIMPLEX, fontSize, (0, 0, 0), fontThickness)
+            cv.putText(image, "Press space bar after selecting.", (10, int(50*fontSize)), cv.FONT_HERSHEY_SIMPLEX, fontSize, (0, 0, 0), fontThickness)
+            cv.imshow('TRACKING', image)
+
+            key = cv.waitKey(100) & 0xFF
+            if key == ord(' '):
+                rect = cv.selectROI("TRACKING", image)
+                if rect:
+                    x, y, w, h = rect
+                    query_image = image[y:y + h, x:x + w]
```

Review comment:
`key = cv.waitKey(100)`
**File:** modules/imgproc/src/imgwarp.cpp
**Change Type:** modified
**Context:** PR #26271: imgproc: add optimized warpPerspective linear kernels for inputs of type CV_8U/16U/32F+C1/C3/C4
**Review Line:** 2375

**Code Changes:**
```diff
     const char * const kernelName = op_type == OCL_OP_AFFINE ? "warpAffine" : "warpPerspective";
 
     int scalarcn = cn == 3 ? 4 : cn;
-    bool is32f = !dev.isAMD() && (interpolation == INTER_CUBIC || interpolation == INTER_LINEAR) && op_type == OCL_OP_AFFINE;
+    bool is32f = op_type == OCL_OP_AFFINE ?
+                 /* Affine*/ !dev.isAMD() && (interpolation == INTER_CUBIC || interpolation == INTER_LINEAR) :
+                 /* Perspective*/ interpolation == INTER_LINEAR;
     int wdepth = interpolation == INTER_NEAREST ? depth : std::max(is32f ? CV_32F : CV_32S, depth);
     int sctype = CV_MAKETYPE(wdepth, scalarcn);
 
@@ -2385,8 +2388,7 @@ static bool ocl_warpTransform(InputArray _src, OutputArray _dst, InputArray _M0,
```

Review comment:
do we still have AMD-specific OpenCL kernel for warpAffine? If not, the condition should be updated.
**File:** modules/imgproc/src/imgwarp.cpp
**Change Type:** modified
**Context:** PR #26271: imgproc: add optimized warpPerspective linear kernels for inputs of type CV_8U/16U/32F+C1/C3/C4
**Review Line:** 2375

**Code Changes:**
```diff
     const char * const kernelName = op_type == OCL_OP_AFFINE ? "warpAffine" : "warpPerspective";
 
     int scalarcn = cn == 3 ? 4 : cn;
-    bool is32f = !dev.isAMD() && (interpolation == INTER_CUBIC || interpolation == INTER_LINEAR) && op_type == OCL_OP_AFFINE;
+    bool is32f = op_type == OCL_OP_AFFINE ?
+                 /* Affine*/ !dev.isAMD() && (interpolation == INTER_CUBIC || interpolation == INTER_LINEAR) :
+                 /* Perspective*/ interpolation == INTER_LINEAR;
     int wdepth = interpolation == INTER_NEAREST ? depth : std::max(is32f ? CV_32F : CV_32S, depth);
     int sctype = CV_MAKETYPE(wdepth, scalarcn);
 
@@ -2385,8 +2388,7 @@ static bool ocl_warpTransform(InputArray _src, OutputArray _dst, InputArray _M0,
```

Review comment:
> do we still have AMD-specific OpenCL kernel for warpAffine? There is conditional compilation with `AMD_DEVICE` in the cubic interpolation affine kernel: https://github.com/opencv/opencv/blob/8e5dbc03fe0c8264e667de5bbae4d0ab04dcab6b/modules/imgproc/src/opencl/warp_affine.cl#L233-L245 https://github.com/opencv/opencv/blob/8e5dbc03fe0c8264e667de5bbae4d0ab04dcab6b/modules/imgproc/src/opencl/warp_affine.cl#L264-L283
**File:** modules/core/include/opencv2/core/hal/intrin_wasm.hpp
**Change Type:** modified
**Context:** PR #25909: Update intrin_wasm.hpp
**Review Line:** 20

**Code Changes:**
```diff
+// __EMSCRIPTEN_major__, __EMSCRIPTEN_minor__ and __EMSCRIPTEN_tiny__ are defined via commandline in
+// https://github.com/emscripten-core/emscripten/blob/1690a5802cd1241adc9714fb7fa2f633d38860dc/tools/shared.py#L506-L515
+//
+// See https://github.com/opencv/opencv/pull/25909
+#ifndef __EMSCRIPTEN_major__
+#include <emscripten/version.h>
+#endif
+
 #define CV_SIMD128 1
 #define CV_SIMD128_64F 0 // Now all implementation of f64 use fallback, so disable it.
 #define CV_SIMD128_FP16 0
```

Review comment:
Line 11 do the same (and fail). I triggered `javascript-simd` build configuration. It is based on EMSDK 2.0.13. PR: https://pullrequest.opencv.org/buildbot/builders/precommit_custom_linux/builds/100452 4.x (also fail): https://pullrequest.opencv.org/buildbot/builders/4_x_javascript-simd-emscripten-lin64/builds/100077
**File:** cmake/OpenCVCompilerOptimizations.cmake
**Change Type:** modified
**Context:** PR #25901: RISC-V/AArch64: disable CPU features detection - This PR is the first step in fixing current issues with NEON/RVV, FP16, BF16 and other CPU...

**Code Changes:**
```diff
@@ -104,7 +104,7 @@ ocv_optimization_process_obsolete_option(ENABLE_AVX2 AVX2 ON)
 ocv_optimization_process_obsolete_option(ENABLE_FMA3 FMA3 ON)
 
 ocv_optimization_process_obsolete_option(ENABLE_VFPV3 VFPV3 OFF)
-ocv_optimization_process_obsolete_option(ENABLE_NEON NEON OFF)
+ocv_optimization_process_obsolete_option(ENABLE_NEON NEON ON)
 
 ocv_optimization_process_obsolete_option(ENABLE_VSX VSX ON)
 
@@ -170,7 +170,29 @@ elseif(" ${CMAKE_CXX_FLAGS} " MATCHES " -march=native | -xHost | /QxHost ")
```

Review comment:
I propose to revert changes in this files and use: - https://github.com/opencv/opencv/pull/25930
**File:** platforms/linux/arm.toolchain.cmake
**Change Type:** modified
**Context:** PR #25901: RISC-V/AArch64: disable CPU features detection - This PR is the first step in fixing current issues with NEON/RVV, FP16, BF16 and other CPU...

**Code Changes:**
```diff
@@ -48,32 +48,23 @@ if(NOT DEFINED ARM_LINUX_SYSROOT AND DEFINED GNU_MACHINE)
   set(ARM_LINUX_SYSROOT /usr/${GNU_MACHINE}${FLOAT_ABI_SUFFIX})
 endif()
 
-if(NOT DEFINED CMAKE_CXX_FLAGS)
-  set(CMAKE_CXX_FLAGS           "" CACHE INTERNAL "")
-  set(CMAKE_C_FLAGS             "" CACHE INTERNAL "")
-  set(CMAKE_SHARED_LINKER_FLAGS "" CACHE INTERNAL "")
-  set(CMAKE_MODULE_LINKER_FLAGS "" CACHE INTERNAL "")
-  set(CMAKE_EXE_LINKER_FLAGS    "" CACHE INTERNAL "")
```

Review comment:
> ENABLE_BF16 Toolchain files have issue with cached variables (not available to them - just add `message()`),
**File:** platforms/linux/arm.toolchain.cmake
**Change Type:** modified
**Context:** PR #25901: RISC-V/AArch64: disable CPU features detection - This PR is the first step in fixing current issues with NEON/RVV, FP16, BF16 and other CPU...

**Code Changes:**
```diff
@@ -48,32 +48,23 @@ if(NOT DEFINED ARM_LINUX_SYSROOT AND DEFINED GNU_MACHINE)
   set(ARM_LINUX_SYSROOT /usr/${GNU_MACHINE}${FLOAT_ABI_SUFFIX})
 endif()
 
-if(NOT DEFINED CMAKE_CXX_FLAGS)
-  set(CMAKE_CXX_FLAGS           "" CACHE INTERNAL "")
-  set(CMAKE_C_FLAGS             "" CACHE INTERNAL "")
-  set(CMAKE_SHARED_LINKER_FLAGS "" CACHE INTERNAL "")
-  set(CMAKE_MODULE_LINKER_FLAGS "" CACHE INTERNAL "")
-  set(CMAKE_EXE_LINKER_FLAGS    "" CACHE INTERNAL "")
```

Review comment:
Toolchain files are not used for native compilation. We need a robust solution for such cases too, e.g. through `OPENCV_EXTRA_*` flags (currently they are applied after the feature checks)
**File:** cmake/OpenCVCompilerOptimizations.cmake
**Change Type:** modified
**Context:** PR #25901: RISC-V/AArch64: disable CPU features detection - This PR is the first step in fixing current issues with NEON/RVV, FP16, BF16 and other CPU...

**Code Changes:**
```diff
@@ -104,7 +104,7 @@ ocv_optimization_process_obsolete_option(ENABLE_AVX2 AVX2 ON)
 ocv_optimization_process_obsolete_option(ENABLE_FMA3 FMA3 ON)
 
 ocv_optimization_process_obsolete_option(ENABLE_VFPV3 VFPV3 OFF)
-ocv_optimization_process_obsolete_option(ENABLE_NEON NEON OFF)
+ocv_optimization_process_obsolete_option(ENABLE_NEON NEON ON)
 
 ocv_optimization_process_obsolete_option(ENABLE_VSX VSX ON)
 
@@ -170,7 +170,29 @@ elseif(" ${CMAKE_CXX_FLAGS} " MATCHES " -march=native | -xHost | /QxHost ")
```

Review comment:
The main idea here is to avoid modifying _arch_ compiler flags at all. If I understand correctly, changes in #25930 will still try to append custom flags and run compiler checks. For example, with that patch, if we compile OpenCV with `-DCMAKE_CXX_FLAGS="-mcpu=cortex-a72" -DCPU_BASELINE=NEON_FP16` options (`cortex-a72` is [armv8-a CPU](https://gcc.gnu.org/git/?p=gcc.git;a=blob;f=gcc/config/aarch64/aarch64-cores.def;h=e58bc0f27de3d60d39c02d2be2aa15570bd5db4d;hb=refs/heads/master)), then our scripts will silently append `-march=armv8.2-a+fp16` and make this build incompatible with explicitly requested CPU. This behavior can cause compatibility, performance issues and compilation errors.
**File:** platforms/linux/arm.toolchain.cmake
**Change Type:** modified
**Context:** PR #25901: RISC-V/AArch64: disable CPU features detection - This PR is the first step in fixing current issues with NEON/RVV, FP16, BF16 and other CPU...

**Code Changes:**
```diff
@@ -48,32 +48,23 @@ if(NOT DEFINED ARM_LINUX_SYSROOT AND DEFINED GNU_MACHINE)
   set(ARM_LINUX_SYSROOT /usr/${GNU_MACHINE}${FLOAT_ABI_SUFFIX})
 endif()
 
-if(NOT DEFINED CMAKE_CXX_FLAGS)
-  set(CMAKE_CXX_FLAGS           "" CACHE INTERNAL "")
-  set(CMAKE_C_FLAGS             "" CACHE INTERNAL "")
-  set(CMAKE_SHARED_LINKER_FLAGS "" CACHE INTERNAL "")
-  set(CMAKE_MODULE_LINKER_FLAGS "" CACHE INTERNAL "")
-  set(CMAKE_EXE_LINKER_FLAGS    "" CACHE INTERNAL "")
```

Review comment:
For native compilation we assume that toolchain have architecture flags set by default.
**File:** platforms/linux/arm.toolchain.cmake
**Change Type:** modified
**Context:** PR #25901: RISC-V/AArch64: disable CPU features detection - This PR is the first step in fixing current issues with NEON/RVV, FP16, BF16 and other CPU...

**Code Changes:**
```diff
@@ -48,32 +48,23 @@ if(NOT DEFINED ARM_LINUX_SYSROOT AND DEFINED GNU_MACHINE)
   set(ARM_LINUX_SYSROOT /usr/${GNU_MACHINE}${FLOAT_ABI_SUFFIX})
 endif()
 
-if(NOT DEFINED CMAKE_CXX_FLAGS)
-  set(CMAKE_CXX_FLAGS           "" CACHE INTERNAL "")
-  set(CMAKE_C_FLAGS             "" CACHE INTERNAL "")
-  set(CMAKE_SHARED_LINKER_FLAGS "" CACHE INTERNAL "")
-  set(CMAKE_MODULE_LINKER_FLAGS "" CACHE INTERNAL "")
-  set(CMAKE_EXE_LINKER_FLAGS    "" CACHE INTERNAL "")
```

Review comment:
For example on Armbian 12 (OrangePi) I have: ``` g++ -march=native -Q --target-help | grep march -march= armv8.2-a+crypto+fp16+rcpc+dotprod ```
**File:** platforms/linux/arm.toolchain.cmake
**Change Type:** modified
**Context:** PR #25901: RISC-V/AArch64: disable CPU features detection - This PR is the first step in fixing current issues with NEON/RVV, FP16, BF16 and other CPU...

**Code Changes:**
```diff
@@ -48,32 +48,23 @@ if(NOT DEFINED ARM_LINUX_SYSROOT AND DEFINED GNU_MACHINE)
   set(ARM_LINUX_SYSROOT /usr/${GNU_MACHINE}${FLOAT_ABI_SUFFIX})
 endif()
 
-if(NOT DEFINED CMAKE_CXX_FLAGS)
-  set(CMAKE_CXX_FLAGS           "" CACHE INTERNAL "")
-  set(CMAKE_C_FLAGS             "" CACHE INTERNAL "")
-  set(CMAKE_SHARED_LINKER_FLAGS "" CACHE INTERNAL "")
-  set(CMAKE_MODULE_LINKER_FLAGS "" CACHE INTERNAL "")
-  set(CMAKE_EXE_LINKER_FLAGS    "" CACHE INTERNAL "")
```

Review comment:
I've checked this variable, it seem to be working. I build with `-DENABLE_BF16=ON` and got `-march=armv8.6-a` in the compiler string. We use this approach in XuanTie cmake toolchain: https://github.com/opencv/opencv/blob/4.x/platforms/linux/riscv64-071-gcc.toolchain.cmake (`CORE` variable)
**File:** platforms/linux/arm.toolchain.cmake
**Change Type:** modified
**Context:** PR #25901: RISC-V/AArch64: disable CPU features detection - This PR is the first step in fixing current issues with NEON/RVV, FP16, BF16 and other CPU...

**Code Changes:**
```diff
@@ -48,32 +48,23 @@ if(NOT DEFINED ARM_LINUX_SYSROOT AND DEFINED GNU_MACHINE)
   set(ARM_LINUX_SYSROOT /usr/${GNU_MACHINE}${FLOAT_ABI_SUFFIX})
 endif()
 
-if(NOT DEFINED CMAKE_CXX_FLAGS)
-  set(CMAKE_CXX_FLAGS           "" CACHE INTERNAL "")
-  set(CMAKE_C_FLAGS             "" CACHE INTERNAL "")
-  set(CMAKE_SHARED_LINKER_FLAGS "" CACHE INTERNAL "")
-  set(CMAKE_MODULE_LINKER_FLAGS "" CACHE INTERNAL "")
-  set(CMAKE_EXE_LINKER_FLAGS    "" CACHE INTERNAL "")
```

Review comment:
Just add `message()` and run. Also add `message() for modified `CMAKE_CXX_FLAGS` because you got the `else()` branch in case of undefined value.
**File:** platforms/linux/arm.toolchain.cmake
**Change Type:** modified
**Context:** PR #25901: RISC-V/AArch64: disable CPU features detection - This PR is the first step in fixing current issues with NEON/RVV, FP16, BF16 and other CPU...

**Code Changes:**
```diff
@@ -48,32 +48,23 @@ if(NOT DEFINED ARM_LINUX_SYSROOT AND DEFINED GNU_MACHINE)
   set(ARM_LINUX_SYSROOT /usr/${GNU_MACHINE}${FLOAT_ABI_SUFFIX})
 endif()
 
-if(NOT DEFINED CMAKE_CXX_FLAGS)
-  set(CMAKE_CXX_FLAGS           "" CACHE INTERNAL "")
-  set(CMAKE_C_FLAGS             "" CACHE INTERNAL "")
-  set(CMAKE_SHARED_LINKER_FLAGS "" CACHE INTERNAL "")
-  set(CMAKE_MODULE_LINKER_FLAGS "" CACHE INTERNAL "")
-  set(CMAKE_EXE_LINKER_FLAGS    "" CACHE INTERNAL "")
```

Review comment:
> `-march=native` It is not a default actually. "Native" case is already properly handled by the current scripts: https://github.com/opencv/opencv/blob/4.10.0/cmake/OpenCVCompilerOptimizations.cmake#L167
**File:** cmake/OpenCVCompilerOptimizations.cmake
**Change Type:** modified
**Context:** PR #25901: RISC-V/AArch64: disable CPU features detection - This PR is the first step in fixing current issues with NEON/RVV, FP16, BF16 and other CPU...

**Code Changes:**
```diff
@@ -104,7 +104,7 @@ ocv_optimization_process_obsolete_option(ENABLE_AVX2 AVX2 ON)
 ocv_optimization_process_obsolete_option(ENABLE_FMA3 FMA3 ON)
 
 ocv_optimization_process_obsolete_option(ENABLE_VFPV3 VFPV3 OFF)
-ocv_optimization_process_obsolete_option(ENABLE_NEON NEON OFF)
+ocv_optimization_process_obsolete_option(ENABLE_NEON NEON ON)
 
 ocv_optimization_process_obsolete_option(ENABLE_VSX VSX ON)
 
@@ -170,7 +170,29 @@ elseif(" ${CMAKE_CXX_FLAGS} " MATCHES " -march=native | -xHost | /QxHost ")
```

Review comment:
> avoid modifying arch compiler flags at all For dispatched optimization we still need to modify compiler flags anyway. > make this build incompatible with explicitly requested CPU If compiler doesn't fail on `try_compile()` in that case then it could be workaronded through `-DCPU_NEON_FP16_FLAGS_ON=` CMake override.
**File:** cmake/OpenCVCompilerOptimizations.cmake
**Change Type:** modified
**Context:** PR #25901: RISC-V/AArch64: disable CPU features detection - This PR is the first step in fixing current issues with NEON/RVV, FP16, BF16 and other CPU...

**Code Changes:**
```diff
@@ -104,7 +104,7 @@ ocv_optimization_process_obsolete_option(ENABLE_AVX2 AVX2 ON)
 ocv_optimization_process_obsolete_option(ENABLE_FMA3 FMA3 ON)
 
 ocv_optimization_process_obsolete_option(ENABLE_VFPV3 VFPV3 OFF)
-ocv_optimization_process_obsolete_option(ENABLE_NEON NEON OFF)
+ocv_optimization_process_obsolete_option(ENABLE_NEON NEON ON)
 
 ocv_optimization_process_obsolete_option(ENABLE_VSX VSX ON)
 
@@ -170,7 +170,29 @@ elseif(" ${CMAKE_CXX_FLAGS} " MATCHES " -march=native | -xHost | /QxHost ")
```

Review comment:
Besides of DETECT, empty or other values of CPU_BASELINE are used for **limiting** of used features in OpenCV without touching compiler flags.