Ask Your Question

Revision history [back]

Runtime Error: cv::medianBlur() crush every time in opencv 4.1.2

System information (version)
  • OpenCV => 4.1.2
  • Operating System / Platform => macOS Catalina, Version 10.15.1
  • Compiler => Xcode, Version 11.2.1 (11B500)
Detailed description

I installed opencv4 through homebrew. Unfortunately, cv::medianBlur() crushed every time it runs. I checked the input variable format, kernel size as the doc says. I am sure the problem is not caused by these reasons. I think the problem is from the opencv lib itself. The homebrew installation process summary is as follows:

==> Summary
🍺 /usr/local/Cellar/opencv/4.1.2: 753 files, 228.2MB
==> Caveats
==> cmake
Emacs Lisp files have been installed to:
/usr/local/share/emacs/site-lisp/cmake
==> openblas
openblas is keg-only, which means it was not symlinked into /usr/local,
because macOS provides BLAS and LAPACK in the Accelerate framework.
For compilers to find openblas you may need to set:
export LDFLAGS="-L/usr/local/opt/openblas/lib"
export CPPFLAGS="-I/usr/local/opt/openblas/include"
For pkg-config to find openblas you may need to set:
export PKG_CONFIG_PATH="/usr/local/opt/openblas/lib/pkgconfig"
==> gettext
gettext is keg-only, which means it was not symlinked into /usr/local,
because macOS provides the BSD gettext library & some software gets confused if both are in the library path.
If you need to have gettext first in your PATH run:
echo 'export PATH="/usr/local/opt/gettext/bin:$PATH"' >> ~/.bash_profile
For compilers to find gettext you may need to set:
export LDFLAGS="-L/usr/local/opt/gettext/lib"
export CPPFLAGS="-I/usr/local/opt/gettext/include"
==> [email protected]
A CA file has been bootstrapped using certificates from the system
keychain. To add additional certificates, place .pem files in
/usr/local/etc/[email protected]/certs
and run
/usr/local/opt/[email protected]/bin/c_rehash
[email protected] is keg-only, which means it was not symlinked into /usr/local,
because openssl/libressl is provided by macOS so don't link an incompatible version.
If you need to have [email protected] first in your PATH run:
echo 'export PATH="/usr/local/opt/[email protected]/bin:$PATH"' >> ~/.bash_profile
For compilers to find [email protected] you may need to set:
export LDFLAGS="-L/usr/local/opt/[email protected]/lib"
export CPPFLAGS="-I/usr/local/opt/[email protected]/include"
For pkg-config to find [email protected] you may need to set:
export PKG_CONFIG_PATH="/usr/local/opt/[email protected]/lib/pkgconfig"
==> unbound
To have launchd start unbound now and restart at startup:
sudo brew services start unbound
==> readline
readline is keg-only, which means it was not symlinked into /usr/local,
because macOS provides the BSD libedit library, which shadows libreadline.
In order to prevent conflicts when programs look for libreadline we are
defaulting this GNU Readline installation to keg-only.
For compilers to find readline you may need to set:
export LDFLAGS="-L/usr/local/opt/readline/lib"
export CPPFLAGS="-I/usr/local/opt/readline/include"
For pkg-config to find readline you may need to set:
export PKG_CONFIG_PATH="/usr/local/opt/readline/lib/pkgconfig"
==> sqlite
sqlite is keg-only, which means it was not symlinked into /usr/local,
because macOS provides an older sqlite3.
If you need to have sqlite first in your PATH run:
echo 'export PATH="/usr/local/opt/sqlite/bin:$PATH"' >> ~/.bash_profile
For compilers to find sqlite you may need to set:
export LDFLAGS="-L/usr/local/opt/sqlite/lib"
export CPPFLAGS="-I/usr/local/opt/sqlite/include"
For pkg-config to find sqlite you may need to set:
export PKG_CONFIG_PATH="/usr/local/opt/sqlite/lib/pkgconfig"
==> python
Python has been installed as
/usr/local/bin/python3
Unversioned symlinks python, python-config, pip etc. pointing to
python3, python3-config, pip3 etc., respectively, have been installed into
/usr/local/opt/python/libexec/bin
If you need Homebrew's Python 2.7 run
brew install python@2
You can install Python packages with
pip3 install <package>
They will install into the site-package directory
/usr/local/lib/python3.7/site-packages
See: https://docs.brew.sh/Homebrew-and-Python
==> glib
Bash completion has been installed to:
/usr/local/etc/bash_completion.d
==> icu4c
icu4c is keg-only, which means it was not symlinked into /usr/local,
because macOS provides libicucore.dylib (but nothing else).
If you need to have icu4c first in your PATH run:
echo 'export PATH="/usr/local/opt/icu4c/bin:$PATH"' >> ~/.bash_profile
echo 'export PATH="/usr/local/opt/icu4c/sbin:$PATH"' >> ~/.bash_profile
For compilers to find icu4c you may need to set:
export LDFLAGS="-L/usr/local/opt/icu4c/lib"
export CPPFLAGS="-I/usr/local/opt/icu4c/include"
For pkg-config to find icu4c you may need to set:
export PKG_CONFIG_PATH="/usr/local/opt/icu4c/lib/pkgconfig"
==> tesseract
This formula contains only the "eng", "osd", and "snum" language data files.
If you need all the other supported languages, brew install tesseract-lang.

The test code is as follows:
int main(int argc, const char * argv[])
{
cv::Mat a = cv::Mat::zeros(100, 200, 5);
cv::Mat b;
cv::medianBlur(a, b, 5);
}

The runtime error is "Thread 1: EXC_BAD_ACCESS (code=EXC_I386_GPFLT)". The program stops at cv::medianBlur(a, b, 5) every time.

Steps to reproduce
  • homebrew version
    Homebrew 2.1.16-89-g2a45343
    Homebrew/homebrew-core (git revision 2a800; last commit 2019-11-20)
    Homebrew/homebrew-cask (git revision 981f58; last commit 2019-11-20)
  • opencv4 install
    brew install opencv
  • Test code
    As shown above.