ximgproc: move accumulate functions from imgproc - #4155
Open
JArmandoAnaya wants to merge 2 commits into
Open
Conversation
accumulate, accumulateSquare, accumulateProduct and accumulateWeighted move out of imgproc into the ximgproc module of opencv_contrib as part of the imgproc cleanup (opencv/opencv#25001). These accumulator functions are rarely used and are largely covered by core arithmetic: accumulate and accumulateWeighted by add and addWeighted, the other two by a combination of multiply and add. No other module depends on them. This is a faithful move of the implementation (including the dispatched SIMD kernel, the OpenCL kernel and the IPP paths), the public declarations, and the accuracy and performance tests. The only change to the code is the namespace (cv::ximgproc) and the OpenCL kernel source reference (ocl::ximgproc::accumulate_oclsrc). The CPU accuracy test, previously housed in the video module, and the OpenCL accuracy test from imgproc are combined into a single ximgproc test.
6 tasks
There was a problem hiding this comment.
Pull request overview
Moves OpenCV’s accumulator routines (accumulate*) out of the base imgproc module into opencv_contrib’s ximgproc as part of the ongoing imgproc cleanup (linked to opencv/opencv#25001), preserving CPU SIMD dispatch, OpenCL, and IPP fast paths while updating tests/perf coverage under the new namespace.
Changes:
- Adds
cv::ximgproc::{accumulate, accumulateSquare, accumulateProduct, accumulateWeighted}implementation with CPU dispatch + OpenCL kernels. - Introduces a new public header (
opencv2/ximgproc/accumulate.hpp) and wires it intoopencv2/ximgproc.hpp. - Moves/creates accuracy + performance tests for both CPU and OpenCL in the ximgproc module.
Reviewed changes
Copilot reviewed 8 out of 9 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| modules/ximgproc/test/test_accumulate.cpp | Adds combined CPU + OpenCL accuracy tests for the moved accumulator functions. |
| modules/ximgproc/src/opencl/accumulate.cl | Adds OpenCL kernels for all four accumulation operations (incl. masked variants). |
| modules/ximgproc/src/accum.simd.hpp | Adds SIMD + portable CPU implementations and dispatch glue declarations. |
| modules/ximgproc/src/accum.dispatch.cpp | Adds the CPU dispatch entry points for the dispatched SIMD implementations. |
| modules/ximgproc/src/accum.cpp | Adds the main ximgproc implementations, including OpenCL + IPP paths and dispatch tables. |
| modules/ximgproc/perf/perf_accumulate.cpp | Adds CPU + OpenCL perf coverage for the accumulator functions under ximgproc. |
| modules/ximgproc/include/opencv2/ximgproc/accumulate.hpp | Adds the public API declarations and documentation for the moved functions. |
| modules/ximgproc/include/opencv2/ximgproc.hpp | Exposes the new accumulate header from the umbrella ximgproc header. |
| modules/ximgproc/CMakeLists.txt | Registers the new dispatched “accum” compilation unit for SIMD dispatch builds. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Apply C++17 style to the portable code paths of the moved accumulate implementation: replace the function-pointer typedefs with using-aliases, use reinterpret_cast for the dispatch-table entries instead of C-style casts, and use nullptr in place of the 0 and NULL pointer literals. Behavior is unchanged. The IPP integration paths are left in their original form. Also fix two small issues carried over with the move: the closing namespace comment in accum.dispatch.cpp read cv::hal although the file opens namespace cv, and the OpenCL accumulateWeighted mask test did not pass the mask, so it duplicated the non-masked case; it now exercises the masked path.
JArmandoAnaya
force-pushed
the
move-accumulate-to-ximgproc
branch
from
June 20, 2026 05:24
3cc82b1 to
d396b24
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This adds accumulate, accumulateSquare, accumulateProduct and accumulateWeighted to the ximgproc module, as part of the imgproc cleanup in opencv/opencv#25001. These accumulator functions are rarely used and are largely covered by core arithmetic (accumulate and accumulateWeighted by add and addWeighted, the other two by multiply and add), so they are a good fit for opencv_contrib rather than the base imgproc module.
The change comes in two commits. The first is a faithful move of the implementation from imgproc, keeping the dispatched SIMD kernel, the OpenCL kernel and the IPP paths intact; the only differences are the namespace
(cv::ximgproc) and the OpenCL kernel source reference (ocl::ximgproc::accumulate_oclsrc). The second commit applies C++17 style to the portable code paths (using-aliases instead of function-pointer typedefs, reinterpret_cast for the dispatch tables, and nullptr), leaving the IPP integration untouched.
The functions keep their existing signatures and behavior under the new cv::ximgproc namespace. The accuracy and performance tests move with them: the CPU accuracy test that previously lived in the opencv video module and the OpenCL accuracy test from imgproc are combined into a single ximgproc test, and the CPU and OpenCL performance tests are brought over as well. The tests are self-contained and generate their own input, so no opencv_extra data is required.
Part of opencv/opencv#25001.
This is one half of a linked pair and is meant to be merged together with the opencv PR that removes the functions from imgproc, so they are never defined in both modules at once:
Pull Request Readiness Checklist
See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request
Patch to opencv_extra has the same branch name.