Skip to content

Optimize exposure compensation - #13400

Merged
alalek merged 3 commits into
opencv:3.4from
qchateau:optimize_exposure_compensation
Dec 14, 2018
Merged

alalek merged 3 commits into
opencv:3.4from
qchateau:optimize_exposure_compensation

Conversation

@qchateau

@qchateau qchateau commented Dec 9, 2018

Copy link
Copy Markdown
Contributor

Please read issue #13399 first

First commit adds a performance test. It showcases a panorama-type stitching, using BlocksGainCompensator with different block size. As the block size get smaller, computation time explodes, fast.

The second commit resolves the first part of issue #13399, ignoring blocks that do not overlap with any other.

The third commit leverage Eigen if available to resolve the equation system in a more optimized fashion.

Performance test results: "master" is self-explanatory, "optimized" uses the second commit, "eigen_llt" uses the second and the third.

Geometric mean (ms)

            Name of Test              master   optimized  eigen   optimized    eigen   
                                                           llt        vs        llt    
                                                                    master       vs    
                                                                  (x-factor)   master  
                                                                             (x-factor)
a123::stitchExposureCompensation::8  54711.384 14658.466 2953.676    3.73      18.52   
a123::stitchExposureCompensation::10 15132.388 4515.318  1388.434    3.35      10.90   
a123::stitchExposureCompensation::12 5606.788  2058.821  888.011     2.72       6.31   
a123::stitchExposureCompensation::16 1421.896   843.919  545.014     1.68       2.61   
a123::stitchExposureCompensation::32  605.013   607.440  421.698     1.00       1.43

Note: Please feel free to showcase what you deem unacceptable and I will do my best to correct it.

results.zip

@qchateau
qchateau force-pushed the optimize_exposure_compensation branch from 1e38cb0 to 03fbe4a Compare December 10, 2018 21:37
@alalek

alalek commented Dec 12, 2018 •

Copy link
Copy Markdown
Member

What H/W configuration is used in performance report?

Fedora 28 (GCC 8.2.1) + i7-6700K results:

Name of Test base w/o eigen with eigen w/o eigen (x) with eigen (x)
a123::stitchExposureCompensation::8 3700.044 1482.676 1578.845 2.50 2.34
a123::stitchExposureCompensation::10 1429.693 737.170 681.543 1.94 2.10
a123::stitchExposureCompensation::12 753.157 516.519 403.712 1.46 1.87
a123::stitchExposureCompensation::16 386.386 334.786 242.726 1.15 1.59
a123::stitchExposureCompensation::32 292.752 291.701 181.579 1.00 1.61

base - c4ccc67
w/o eigen - 03fbe4a + WITH_EIGEN=OFF
with eigen - 03fbe4a + Eigen 3.3.5
OpenCL is ON (Intel OpenCL NEO 18.48.11934).

@qchateau

Copy link
Copy Markdown
Contributor Author

I used Ubuntu 18.10 in Virtualbox and GCC 7.3.0 on a laptop with an i5-8250U. Judging by your results, I think we can omit the commit 03fbe4a.

-- General configuration for OpenCV 4.0.0-dev =====================================
--   Version control:               4.0.0-138-g03fbe4aad
-- 
--   Platform:
--     Timestamp:                   2018-12-08T15:52:06Z
--     Host:                        Linux 4.18.0-11-generic x86_64
--     CMake:                       3.12.1
--     CMake generator:             Unix Makefiles
--     CMake build tool:            /usr/bin/make
--     Configuration:               Release
-- 
--   CPU/HW features:
--     Baseline:                    SSE SSE2 SSE3
--       requested:                 SSE3
--     Dispatched code generation:  SSE4_1 SSE4_2 FP16 AVX AVX2 AVX512_SKX
--       requested:                 SSE4_1 SSE4_2 AVX FP16 AVX2 AVX512_SKX
--       SSE4_1 (7 files):          + SSSE3 SSE4_1
--       SSE4_2 (2 files):          + SSSE3 SSE4_1 POPCNT SSE4_2
--       FP16 (1 files):            + SSSE3 SSE4_1 POPCNT SSE4_2 FP16 AVX
--       AVX (5 files):             + SSSE3 SSE4_1 POPCNT SSE4_2 AVX
--       AVX2 (13 files):           + SSSE3 SSE4_1 POPCNT SSE4_2 FP16 FMA3 AVX AVX2
--       AVX512_SKX (1 files):      + SSSE3 SSE4_1 POPCNT SSE4_2 FP16 FMA3 AVX AVX2 AVX_512F AVX512_SKX
-- 
--   C/C++:
--     Built as dynamic libs?:      YES
--     C++ Compiler:                /usr/bin/g++-7  (ver 7.3.0)
--     C++ flags (Release):         -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wuninitialized -Winit-self -Wno-narrowing -Wno-delete-non-virtual-dtor -Wno-comment -Wimplicit-fallthrough=3 -Wno-strict-overflow -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections  -msse -msse2 -msse3 -fvisibility=hidden -fvisibility-inlines-hidden -O3 -DNDEBUG  -DNDEBUG
--     C++ flags (Debug):           -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wuninitialized -Winit-self -Wno-narrowing -Wno-delete-non-virtual-dtor -Wno-comment -Wimplicit-fallthrough=3 -Wno-strict-overflow -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections  -msse -msse2 -msse3 -fvisibility=hidden -fvisibility-inlines-hidden -g  -O0 -DDEBUG -D_DEBUG
--     C Compiler:                  /usr/bin/gcc-7
--     C flags (Release):           -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wuninitialized -Winit-self -Wno-narrowing -Wno-comment -Wimplicit-fallthrough=3 -Wno-strict-overflow -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections  -msse -msse2 -msse3 -fvisibility=hidden -O3 -DNDEBUG  -DNDEBUG
--     C flags (Debug):             -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wuninitialized -Winit-self -Wno-narrowing -Wno-comment -Wimplicit-fallthrough=3 -Wno-strict-overflow -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections  -msse -msse2 -msse3 -fvisibility=hidden -g  -O0 -DDEBUG -D_DEBUG
--     Linker flags (Release):      
--     Linker flags (Debug):        
--     ccache:                      NO
--     Precompiled headers:         YES
--     Extra dependencies:          dl m pthread rt
--     3rdparty dependencies:
-- 
--   OpenCV modules:
--     To be built:                 calib3d core dnn features2d flann gapi highgui imgcodecs imgproc java_bindings_generator ml objdetect photo python_bindings_generator stitching ts video videoio
--     Disabled:                    world
--     Disabled by dependency:      -
--     Unavailable:                 java js python2 python3
--     Applications:                tests perf_tests apps
--     Documentation:               NO
--     Non-free algorithms:         NO
-- 
--   GUI: 
--     GTK+:                        NO
--     VTK support:                 NO
-- 
--   Media I/O: 
--     ZLib:                        /usr/lib/x86_64-linux-gnu/libz.so (ver 1.2.11)
--     JPEG:                        libjpeg-turbo (ver 1.5.3-62)
--     WEBP:                        build (ver encoder: 0x020e)
--     PNG:                         build (ver 1.6.35)
--     TIFF:                        build (ver 42 - 4.0.9)
--     JPEG 2000:                   build (ver 1.900.1)
--     OpenEXR:                     build (ver 1.7.1)
--     HDR:                         YES
--     SUNRASTER:                   YES
--     PXM:                         YES
--     PFM:                         YES
-- 
--   Video I/O:
--     DC1394:                      NO
--     FFMPEG:                      NO
--       avcodec:                   NO
--       avformat:                  NO
--       avutil:                    NO
--       swscale:                   NO
--       avresample:                NO
--     GStreamer:                   NO
--     v4l/v4l2:                    linux/videodev2.h
-- 
--   Parallel framework:            pthreads
-- 
--   Trace:                         YES (with Intel ITT)
-- 
--   Other third-party libraries:
--     Intel IPP:                   2019.0.0 Gold [2019.0.0]
--            at:                   /home/quentin/dev/opencv/build/3rdparty/ippicv/ippicv_lnx/icv
--     Intel IPP IW:                sources (2019.0.0)
--               at:                /home/quentin/dev/opencv/build/3rdparty/ippicv/ippicv_lnx/iw
--     Lapack:                      NO
--     Eigen:                       YES (ver 3.3.4)
--     Custom HAL:                  NO
--     Protobuf:                    build (3.5.1)
-- 
--   OpenCL:                        YES (no extra features)
--     Include path:                /home/quentin/dev/opencv/3rdparty/include/opencl/1.2
--     Link libraries:              Dynamic load
-- 
--   Python (for build):            /usr/bin/python2.7
-- 
--   Java:                          
--     ant:                         NO
--     JNI:                         NO
--     Java wrappers:               NO
--     Java tests:                  NO
-- 
--   Install to:                    /usr/local
-- -----------------------------------------------------------------
-- 
-- Configuring done
-- Generating done
-- Build files have been written to: /home/quentin/dev/opencv/build

@alalek

alalek commented Dec 14, 2018

Copy link
Copy Markdown
Member

Rebased onto 3.4 branch. Patch will be merged into master during regular merge-3.4 process.

@alalek
alalek merged commit ab86f15 into opencv:3.4 Dec 14, 2018
@qchateau
qchateau deleted the optimize_exposure_compensation branch December 21, 2018 20:34
SavyaSanchi-Sharma pushed a commit to SavyaSanchi-Sharma/opencv that referenced this pull request Jul 30, 2026
…tion

Optimize exposure compensation (opencv#13400)

* Added perf test

* Optimized gains computation

* Use Eigen for gains calculation
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants