Closed
Description
System information (version)
- OpenCV => 3.1.0
- Operating System / Platform => Mac OSX El Capitan 10.11.6 (Also in Mac OSX Sierra)
- Compiler => clang
Detailed description
Running a C++ program using OpenCV3 throws out the following message:
BUG: The current event queue and the main event queue are not the same. Events will not be handled correctly. This is probably because _TSGetMainThread was called for the first time off the main thread.
The OpenCV3 is installed thru homebrew
Steps to reproduce
- First the installation of opencv3 is done using homebrew, to zero-in the bug, I've also tried to uninstall all other dependencies first:
brew uninstall --force tbb
brew uninstall --force ffmpeg
brew uninstall --force python3
brew uninstall --force libtiff
brew uninstall --force libpng
brew uninstall --force opencv3
brew install opencv3 --HEAD --c++11
brew link --overwrite --force opencv3
- Second after compiling my C++ program using CMake and Make, I try to run it, which leads to the
following message:BUG: The current event queue and the main event queue are not the same. Events will not be handled correctly. This is probably because _TSGetMainThread was called for the first time off the main thread.
Here's the simple C++ program:
int main(int argc, const char * argv[]) {
string video_filename = "./IMG_0879.m4v";
VideoCapture capture = VideoCapture(video_filename);
string image_filename = "./IMG_0879.jpg";
Mat image = imread(image_filename);
namedWindow("");
imshow("", image);
waitKey(10);
return 0;
}
Activity
subokita commentedon Oct 18, 2016
Seems to be fixed by reinstalling opencv3 with --with-ffmpeg flag.
mshabunin commentedon Oct 18, 2016
Looks like there is no problem in OpenCV. Feel free to reopen if you have more information.
KleinYuan commentedon Oct 23, 2016
Run into similar issue when working with openCV (2.4.13) and python (2.7.12) on fresh new Mac (macOS 10.12).
Use pycharm community IDE to run an algorithm I developed (same code running without no problem on another mac OS X10.11.6, python 2.7.12, openCV 2.4.13).
here's the error:
Also, same solution.
It's because ffmpeg was not installed together with OpenCV. Reinstalled with that flag solved this issue.
relikd commentedon Jan 22, 2017
Same issue here. Can you give me a quick walkthrough on how to reinstall OpenCV with mentioned flag?
I have tried an install with CMake GUI and with this instructions.
However I get:
( ffmpeg Mac package is installed)
bharath063 commentedon Feb 22, 2017
@subokita Can you provide us with the steps to compile with ffmpeg on Sierra?
relikd commentedon Feb 22, 2017
@bharath063 It worked for me with homebrew:
brew install ffmpeg
brew tap homebrew/science
brew install --HEAD opencv --with-ffmpeg
bharath063 commentedon Feb 22, 2017
@relikd Thanks! But I had faced an issue when installing opencv through homebrew on sierra because of the QTKit deprecation. So I had followed this -> http://www.pyimagesearch.com/2016/11/28/macos-install-opencv-3-and-python-2-7/ tutorial to compile from source.
abdullahselek commentedon Jun 11, 2017
Thanks @relikd this also worked for me.
tpmeyer1 commentedon Nov 25, 2017
@relikd
It didn't work for me! I have Mac OS X El Capitan. Running python 3.6.3
When I tried using the --HEAD flag, it failed, so I ran without the flag. cut-and-paste below:
Thomass-iMac:bin tpmeyer$ brew install ffmpeg
==> Downloading https://homebrew.bintray.com/bottles/ffmpeg-3.4.el_capitan.bottle.tar.gz
Already downloaded: /Users/tpmeyer/Library/Caches/Homebrew/ffmpeg-3.4.el_capitan.bottle.tar.gz
==> Pouring ffmpeg-3.4.el_capitan.bottle.tar.gz
🍺 /usr/local/Cellar/ffmpeg/3.4: 248 files, 51.6MB
Thomass-iMac:bin tpmeyer$ brew tap homebrew/science
Thomass-iMac:bin tpmeyer$ brew install --HEAD opencv3 --with-ffmpeg
Error: No head is defined for opencv
Thomass-iMac:bin tpmeyer$ brew install opencv3 --with-ffmpeg
Warning: opencv: this formula has no --with-ffmpeg option so it will be ignored!
==> Downloading https://homebrew.bintray.com/bottles/opencv-3.3.1_1.el_capitan.bottle.1.tar.gz
Already downloaded: /Users/tpmeyer/Library/Caches/Homebrew/opencv-3.3.1_1.el_capitan.bottle.1.tar.gz
==> Pouring opencv-3.3.1_1.el_capitan.bottle.1.tar.gz
🍺 /usr/local/Cellar/opencv/3.3.1_1: 519 files, 97.9MB
Then when I run my image detection code, it works (sort of, except I can't detect keyboard or mouse) and I still get this error:
GVA info: Successfully connected to the Intel plugin, offline Gen75
2017-11-25 07:28:10.897 Python[24977:913156] !!! BUG: The current event queue and the main event queue are not the same. Events will not be handled correctly. This is probably because _TSGetMainThread was called for the first time off the main thread.
relikd commentedon Nov 25, 2017
I noticed you typed
opencv3
instead of justopencv
(I think both will install v3 anyway but I'm not sure about that).If this isn't working you can also try the following:
myBrewfile.txt
:brew bundle --file="~/Desktop/myBrewfile.txt"
At least thats what my
brew bundle dump
command will return (and I have v3 installed). Don't know if it saved all the parameters during install. Also don't know if you have ffmpeg to be installed before or not. (btw. I am currently running El Capitain too)tpmeyer1 commentedon Nov 25, 2017
relikd commentedon Nov 25, 2017
Try delete the brew tap line if you already tapped into science manually.
If you still get an error search google for the problem
tpmeyer1 commentedon Nov 25, 2017
When I removed the tap line as instructed, the command worked as intended, and reported that the Brewfile dependency was installed, but It did not solve the event queue error.
I tried it with and without ffmpeg installed beforehand.
In /usr/local/Cellar, I have
ffmpeg version 3.4
opencv version 3.3.1_1
python3 version 3.6.3
Are those the same versions that are working for you?
relikd commentedon Nov 25, 2017
Haven't used OpenCV in months. I have two ffmpeg versions installed v3.2.2 and v3.4.
OpenCV is at v3.2.0. Python3 is v3.6.3.
Beyond my first comment I can't even tell you how I installed it.
Good luck finding a solution