opencv/modules/imgproc/src
Dmitry Kurtaev ec97c38ff9
Merge pull request #24535 from dkurt:ipp_distransform_update
Handle huge images in IPP distanceTransform #24535

### Pull Request Readiness Checklist

* Do not use IPP for huge Mat (reproduced with https://github.com/opencv/opencv/issues/23895#issuecomment-1708132367 on `DIST_MASK_5`)

  I have observed two types of errors on the reproducer from the issue:

  1. When `temp` is not allocated:

    ```
    Thread 1 "app" received signal SIGSEGV, Segmentation fault.
    0x00007ffff65dc755 in icv_l9_ownDistanceTransform_5x5_8u32f_C1R_21B_g9e9 () from /home/dkurtaev/opencv_install/bin/../lib/libopencv_imgproc.so.408
    (gdb) bt
    #0  0x00007ffff65dc755 in icv_l9_ownDistanceTransform_5x5_8u32f_C1R_21B_g9e9 () from /home/dkurtaev/opencv_install/bin/../lib/libopencv_imgproc.so.408
    #1  0x00007ffff659e8df in icv_l9_ippiDistanceTransform_5x5_8u32f_C1R () from /home/dkurtaev/opencv_install/bin/../lib/libopencv_imgproc.so.408
    #2  0x00007ffff5c390f0 in cv::distanceTransform (_src=..., _dst=..., _labels=..., distType=2, maskSize=5, labelType=1) at /home/dkurtaev/opencv/modules/imgproc/src/distransform.cpp:854
    #3  0x00007ffff5c396ef in cv::distanceTransform (_src=..., _dst=..., distanceType=2, maskSize=5, dstType=5) at /home/dkurtaev/opencv/modules/imgproc/src/distransform.cpp:903
    #4  0x000055555555669e in main (argc=1, argv=0x7fffffffdef8) at /home/dkurtaev/main.cpp:18
    ```

  2. When we keep `temp` allocated every time:

    ```
    OpenCV(4.8.0-dev) Error: Assertion failed (udata < (uchar*)ptr && ((uchar*)ptr - udata) <= (ptrdiff_t)(sizeof(void*)+64)) in fastFree, file /home/dkurtaev/opencv/modules/core/src/alloc.cpp, line 191
    terminate called after throwing an instance of 'cv::Exception'
      what():  OpenCV(4.8.0-dev) /home/dkurtaev/opencv/modules/core/src/alloc.cpp:191: error: (-215:Assertion failed) udata < (uchar*)ptr && ((uchar*)ptr - udata) <= (ptrdiff_t)(sizeof(void*)+64) in function 'fastFree'
    ```

* Try enable IPP for 3x3 (see https://github.com/opencv/opencv/issues/15904)
* Reduce memory footprint with IPP

See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request

- [x] I agree to contribute to the project under Apache 2 License.
- [x] To the best of my knowledge, the proposed patch is not based on a code under GPL or another license that is incompatible with OpenCV
- [x] The PR is proposed to the proper branch
- [x] There is a reference to the original bug report and related work
- [x] There is accuracy test, performance test and test data in opencv_extra repository, if applicable
      Patch to opencv_extra has the same branch name.
- [x] The feature is well documented and sample code can be built with the project CMake
2023-11-14 11:44:17 +03:00
..
opencl Merge pull request #24333 from definitelyuncertain:CvtRGB2YUV422 2023-10-12 10:18:24 +03:00
_geom.h Backport C-API cleanup (imgproc) from 5.x 2023-01-16 23:29:50 +03:00
accum.cpp Deprecated convertTypeStr and made new variant that also takes the buffer size 2023-04-26 09:48:15 -04:00
accum.dispatch.cpp Merge pull request #23109 from seanm:misc-warnings 2023-10-06 13:33:21 +03:00
accum.simd.hpp Merge pull request #24325 from hanliutong:rewrite 2023-10-05 17:57:25 +03:00
approx.cpp Merge remote-tracking branch 'upstream/3.4' into merge-3.4 2021-12-03 12:32:49 +00:00
bilateral_filter.dispatch.cpp Deprecated convertTypeStr and made new variant that also takes the buffer size 2023-04-26 09:48:15 -04:00
bilateral_filter.simd.hpp Clean up the Universal Intrinsic API. 2023-10-13 19:23:30 +08:00
blend.cpp Merge pull request #24058 from hanliutong:rewrite-imgporc 2023-09-14 20:37:46 +03:00
box_filter.dispatch.cpp Deprecated convertTypeStr and made new variant that also takes the buffer size 2023-04-26 09:48:15 -04:00
box_filter.simd.hpp Clean up the Universal Intrinsic API. 2023-10-13 19:23:30 +08:00
canny.cpp Merge pull request #24058 from hanliutong:rewrite-imgporc 2023-09-14 20:37:46 +03:00
ccl_bolelli_forest_firstline.inc.hpp Merge pull request #19631 from prittt:sota-ccl 2021-02-27 17:27:24 +00:00
ccl_bolelli_forest_lastline.inc.hpp Merge pull request #19631 from prittt:sota-ccl 2021-02-27 17:27:24 +00:00
ccl_bolelli_forest_singleline.inc.hpp Merge pull request #19631 from prittt:sota-ccl 2021-02-27 17:27:24 +00:00
ccl_bolelli_forest.inc.hpp Merge pull request #19631 from prittt:sota-ccl 2021-02-27 17:27:24 +00:00
clahe.cpp Move big objects (>20k) from stack to heap. 2020-12-17 09:36:51 +01:00
color_hsv.dispatch.cpp imgproc: dispatch color* 2019-03-07 15:45:05 +03:00
color_hsv.simd.hpp Merge pull request #24325 from hanliutong:rewrite 2023-10-05 17:57:25 +03:00
color_lab.cpp Clean up the Universal Intrinsic API. 2023-10-13 19:23:30 +08:00
color_rgb.dispatch.cpp imgproc: dispatch color* 2019-03-07 15:45:05 +03:00
color_rgb.simd.hpp Clean up the Universal Intrinsic API. 2023-10-13 19:23:30 +08:00
color_yuv.dispatch.cpp Merge pull request #24333 from definitelyuncertain:CvtRGB2YUV422 2023-10-12 10:18:24 +03:00
color_yuv.simd.hpp Merge pull request #24333 from definitelyuncertain:CvtRGB2YUV422 2023-10-12 10:18:24 +03:00
color.cpp Merge pull request #24333 from definitelyuncertain:CvtRGB2YUV422 2023-10-12 10:18:24 +03:00
color.hpp Merge pull request #24333 from definitelyuncertain:CvtRGB2YUV422 2023-10-12 10:18:24 +03:00
color.simd_helpers.hpp Merge pull request #24333 from definitelyuncertain:CvtRGB2YUV422 2023-10-12 10:18:24 +03:00
colormap.cpp Merge pull request #21645 from chacha21:applyColorMap_8UC1_optimized 2022-03-01 19:55:00 +03:00
connectedcomponents.cpp Update Condition 2022-03-31 21:03:06 +00:00
contours.cpp Merge pull request #23109 from seanm:misc-warnings 2023-10-06 13:33:21 +03:00
convhull.cpp Merge pull request #21107 from take1014:remove_assert_21038 2021-11-27 18:34:52 +00:00
corner.avx.cpp Merge pull request #16236 from alalek:fix_core_simd_emulator 2020-01-10 21:31:02 +03:00
corner.cpp Merge pull request #24058 from hanliutong:rewrite-imgporc 2023-09-14 20:37:46 +03:00
corner.hpp
cornersubpix.cpp Add semicolons after CV_INSTRUMENT macros 2018-09-14 06:45:31 +09:00
demosaicing.cpp Clean up the Universal Intrinsic API. 2023-10-13 19:23:30 +08:00
deriv.cpp Deprecated convertTypeStr and made new variant that also takes the buffer size 2023-04-26 09:48:15 -04:00
distransform.cpp Merge pull request #24535 from dkurt:ipp_distransform_update 2023-11-14 11:44:17 +03:00
drawing.cpp Merge pull request #23109 from seanm:misc-warnings 2023-10-06 13:33:21 +03:00
emd.cpp Merge pull request #21107 from take1014:remove_assert_21038 2021-11-27 18:34:52 +00:00
featureselect.cpp Merge pull request #19392 from amirtu:OCV-165_finalize_goodFeaturesToTrack_returns_also_corner_value_PR 2021-02-15 19:55:57 +00:00
filter.dispatch.cpp Merge pull request #23109 from seanm:misc-warnings 2023-10-06 13:33:21 +03:00
filter.hpp imgproc: align GaussianBlur/sepFilter2D OpenCL with CPU version 2020-07-08 15:13:48 +00:00
filter.simd.hpp Clean up the Universal Intrinsic API. 2023-10-13 19:23:30 +08:00
filterengine.hpp Merge pull request #18073 from vpisarev:apache2_license 2020-08-17 11:49:11 +00:00
fixedpoint.inl.hpp Merge pull request #18167 from Yosshi999:bit-exact-gaussian 2020-09-01 10:28:25 +00:00
floodfill.cpp build: w/a compiler warnings for GCC 11-12 and Clang 13, reduce build output 2023-07-10 11:27:59 +03:00
gabor.cpp
generalized_hough.cpp Merge remote-tracking branch 'upstream/3.4' into merge-3.4 2018-09-14 23:44:35 +00:00
geometry.cpp Merge pull request #24216 from dkurt:inter_lines_less_compute 2023-09-05 10:44:56 +03:00
grabcut.cpp Merge remote-tracking branch 'upstream/3.4' into merge-3.4 2019-06-26 20:19:04 +00:00
hal_replacement.hpp Merge pull request #24333 from definitelyuncertain:CvtRGB2YUV422 2023-10-12 10:18:24 +03:00
hershey_fonts.cpp
histogram.cpp Clean up the Universal Intrinsic API. 2023-10-13 19:23:30 +08:00
hough.cpp Merge pull request #24132 from hanliutong:rewrite-imgproc2 2023-09-19 08:52:42 +03:00
imgwarp.avx2.cpp
imgwarp.cpp Clean up the Universal Intrinsic API. 2023-10-13 19:23:30 +08:00
imgwarp.hpp Fixed most clang -Wextra-semi warnings 2022-09-27 18:06:46 -04:00
imgwarp.lasx.cpp Add Loongson Advanced SIMD Extension support: -DCPU_BASELINE=LASX 2022-09-10 09:39:43 +03:00
imgwarp.sse4_1.cpp Fixed most clang -Wextra-semi warnings 2022-09-27 18:06:46 -04:00
intelligent_scissors.cpp Merge pull request #23109 from seanm:misc-warnings 2023-10-06 13:33:21 +03:00
intersection.cpp Merge pull request #23690 from chacha21:rotatedRectangleIntersection_precision 2023-05-30 17:46:39 +03:00
linefit.cpp Backport C-API cleanup (imgproc) from 5.x 2023-01-16 23:29:50 +03:00
lsd.cpp Merge pull request #23109 from seanm:misc-warnings 2023-10-06 13:33:21 +03:00
main.cpp
matchcontours.cpp Add semicolons after CV_INSTRUMENT macros 2018-09-14 06:45:31 +09:00
median_blur.dispatch.cpp Merge remote-tracking branch 'upstream/3.4' into merge-3.4 2020-03-23 16:54:35 +00:00
median_blur.simd.hpp Clean up the Universal Intrinsic API. 2023-10-13 19:23:30 +08:00
min_enclosing_triangle.cpp fix findMinEnclosingTriangle and add tests 2021-10-21 18:12:51 +03:00
moments.cpp Clean up the Universal Intrinsic API. 2023-10-13 19:23:30 +08:00
morph.dispatch.cpp Deprecated convertTypeStr and made new variant that also takes the buffer size 2023-04-26 09:48:15 -04:00
morph.simd.hpp Merge pull request #24166 from hanliutong:rewrite-remaining 2023-09-19 15:12:52 +03:00
phasecorr.cpp Merge remote-tracking branch 'upstream/3.4' into merge-3.4 2021-05-29 19:00:14 +00:00
precomp.hpp Merge remote-tracking branch 'upstream/3.4' into merge-3.4 2022-06-04 19:10:35 +00:00
pyramids.cpp Clean up the Universal Intrinsic API. 2023-10-13 19:23:30 +08:00
resize.avx2.cpp imgproc(resize): drop unused 'pix_size4' 2020-03-29 02:41:50 +00:00
resize.cpp Merge pull request #24371 from hanliutong:clean-up 2023-10-20 12:50:26 +03:00
resize.hpp Add Loongson Advanced SIMD Extension support: -DCPU_BASELINE=LASX 2022-09-10 09:39:43 +03:00
resize.lasx.cpp Add Loongson Advanced SIMD Extension support: -DCPU_BASELINE=LASX 2022-09-10 09:39:43 +03:00
resize.sse4_1.cpp imgproc(resize): drop unused 'pix_size4' 2020-03-29 02:41:50 +00:00
rotcalipers.cpp fix choose minimum angle in rotatingCalipers 2021-08-11 19:08:52 +03:00
samplers.cpp Merge pull request #21107 from take1014:remove_assert_21038 2021-11-27 18:34:52 +00:00
segmentation.cpp Backport C-API cleanup (imgproc) from 5.x 2023-01-16 23:29:50 +03:00
shapedescr.cpp Merge pull request #24166 from hanliutong:rewrite-remaining 2023-09-19 15:12:52 +03:00
smooth.dispatch.cpp Merge remote-tracking branch 'upstream/3.4' into merge-3.4 2022-11-16 16:54:11 +00:00
smooth.simd.hpp Merge pull request #24058 from hanliutong:rewrite-imgporc 2023-09-14 20:37:46 +03:00
spatialgradient.cpp Merge pull request #24058 from hanliutong:rewrite-imgporc 2023-09-14 20:37:46 +03:00
stackblur.cpp Merge pull request #24132 from hanliutong:rewrite-imgproc2 2023-09-19 08:52:42 +03:00
subdivision2d.cpp Merge remote-tracking branch 'upstream/3.4' into merge-3.4 2021-12-03 12:32:49 +00:00
sumpixels.avx512_skx.hpp Merge pull request #23109 from seanm:misc-warnings 2023-10-06 13:33:21 +03:00
sumpixels.dispatch.cpp fix files permissions 2020-04-13 04:29:55 +00:00
sumpixels.simd.hpp Clean up the Universal Intrinsic API. 2023-10-13 19:23:30 +08:00
tables.cpp
templmatch.cpp Fix mask thresholding 2023-05-26 18:51:33 +03:00
thresh.cpp Merge pull request #24132 from hanliutong:rewrite-imgproc2 2023-09-19 08:52:42 +03:00
utils.cpp