cv::flip only working around x-axis (MinGW) (Bug #2079)
Description
Flipping function void cv::flip(InputArray src, OutputArray dst, int flipCode)
behaves strange.
When running
cv::Mat image, flipped; image = cv::imread("image.jpg"); cv::flip(image, flipped, 0); cv::imshow("View image", flipped);things are working fine and
image.jpg
is shown upside down.However, when
flipCode
is not equal to 0 (i.e. horizontal flip or both horizontal&vertical flipping), the executable is successfully build, but crashes immediately when executed. Apparently the horizontal flip is not working.
This all occurs using:
- OpenCV 2.4.1 (OpenCV-2.4.1.exe)
- Windows Vista (32 bit)
- Qt Creator 1.2.1, incl. Qt libraries 4.8.1 for Windows (MinGW 4.4)
Other functions appear to work normal.
The weirdest thing is things work perfectly for vertical flipping, but somehow not for horizontal flipping (or when combining both).
History
Updated by Stefan Hahn over 12 years ago
Same effect for
Windows 7 (x64)
QT Creator 2.0.1 based on QT 4.7.1 (Mingw32 4.4.0)
Updated by Erik Timmers over 12 years ago
For completeness, the result of cv::getBuildInformation()
for the Windows Vista build:
General configuration for OpenCV 2.4.1 ===================================== Platform: Host: Windows 6.0 x86 CMake: 2.8.8 CMake generator: MinGW Makefiles CMake build tool: C:/QtSDK/mingw/bin/mingw32-make.exe Configuration: RELEASE C/C++: Built as dynamic libs?: YES C++ Compiler: C:/QtSDK/mingw/bin/g++.exe (ver 4.4.0) C++ flags (Release): -mstackrealign -Wall -march=i686 -fomit-frame-pointer -msse -msse2 -mfpmath=sse -ffunction-sections -O2 -DNDEBUG -DNDEBUG C++ flags (Debug): -mstackrealign -Wall -march=i686 -fomit-frame-pointer -msse -msse2 -mfpmath=sse -ffunction-sections -g -O0 -DDEBUG -D_DEBUG -ggdb3 C Compiler: C:/QtSDK/mingw/bin/gcc.exe C flags (Release): -mstackrealign -Wall -march=i686 -fomit-frame-pointer -msse -msse2 -mfpmath=sse -ffunction-sections -O2 -DNDEBUG -DNDEBUG C flags (Debug): -mstackrealign -Wall -march=i686 -fomit-frame-pointer -msse -msse2 -mfpmath=sse -ffunction-sections -g -O0 -DDEBUG -D_DEBUG -ggdb3 Linker flags (Release): Linker flags (Debug): OpenCV modules: To be built: calib3d contrib core features2d flann gpu highgui imgproc legacy ml nonfree objdetect photo stitching ts video videostab Disabled: - Disabled by dependency: - Unavailable: androidcamera java python GUI: QT 4.x: YES (ver 4.8.1 EDITION = OpenSource) QT OpenGL support: NO OpenGL support: NO Media I/O: ZLib: build (ver 1.2.6) JPEG: build (ver 62) PNG: build (ver 1.5.9) TIFF: build (ver 42) JPEG 2000: build (ver 1.900.1) OpenEXR: NO Video I/O: FFMPEG: YES (prebuilt binaries) codec: YES (ver 53.61.100) format: YES (ver 53.32.100) util: YES (ver 51.35.100) swscale: YES (ver 2.1.100) gentoo-style: YES OpenNI: NO OpenNI PrimeSensor Modules: NO PvAPI: NO DirectShow: YES XIMEA: NO Other third-party libraries: Use IPP: NO Use TBB: NO Use Cuda: NO Use Eigen: NO Python: Interpreter: NO Documentation: Build Documentation: NO Sphinx: NO PdfLaTeX compiler: NO Tests and samples: Tests: YES Performance tests: YES Examples: NO Install path: C:/opencv/install cvconfig.h is in: C:/opencv -----------------------------------------------------------------
Updated by Stefan Hahn over 12 years ago
Addition:
No error when opencv is compiled with debug option.
This seems to be -o3 optimization going astray.
Looking at the generated compiler code for the innermost and last loop in flipHoriz it becomes clear, that this has been optimized into nonsense. There even is no loop on "limit" any more.
Recommendation:
To keep Qt users happy I would propose to return to the flipHoriz implementation from previous releases.
Updated by Andrey Kamaev over 12 years ago
Stefan, flipHoriz was not touched for 11 month. Which means it is the same as was in OpenCV 2.3 release.
Updated by Vadim Pisarevsky over 12 years ago
we actually found MinGW being very buggy and do not recommend to go beyond -O1 with it, which is surprising since GCC on Linux is rock solid. We could try to rewrite this and that function and after multiple attempts find which version is compatible with MinGW broken logic. But it's not best way to spend time. Instead, you could either use -O1, or use newer version of MinGW (MinGW 4.6.x seems to be more stable) or use Visual Studio Express 2010, which is free (as in "beer").
Updated by Vadim Pisarevsky over 12 years ago
the report was cancelled, since this is a known bug in the old version of MinGW
- Status changed from Open to Cancelled
Updated by Aziz Baibabaev over 12 years ago
Vadim Pisarevsky wrote:
we actually found MinGW being very buggy and do not recommend to go beyond -O1 with it, which is surprising since GCC on Linux is rock solid. We could try to rewrite this and that function and after multiple attempts find which version is compatible with MinGW broken logic. But it's not best way to spend time. Instead, you could either use -O1, or use newer version of MinGW (MinGW 4.6.x seems to be more stable) or use Visual Studio Express 2010, which is free (as in "beer").
-O1 does not seem to cut it with GCC 4.4.0, have to turn off optimization completely.