Closed mahiuchun closed 8 years ago
I can confirm issues with waitkey crashing frequently on OS X.
Please add result of cv::getBuildInformation()
Attached buildInfo.txt
Thanks! QT backend is used here for UI interaction. Are you able to reproduce this problem with Cocoa backend?
I'm seeing a similar problem with a similar program and what I thought was the Cocoa backend. A slightly censored file is attached with the output from cv::getBuildInformation() and the stacktraces.
One thing I noticed is when I step through in a debugger is I get breakpoints triggered at constant locations in cap_qtkit.mm. Line 335 always triggers twice, then line 299 triggers twice, then 435 triggers once, then the program works as intended.
edit: osx 10.10.5, opencv commit version 92387b1ef8fad15196dd5f7fb4931444a68bc93a
@kesinger Thanks for information! QT framework is not used in your build, but problem is still here.
Looks like, both QTKit capture + cv::waitKey are required to reproduce this bug.
Hi,
I am also have the same issue, but I'm not using the QT framework. My program is just plain simple c++ running on Xcode. (Update: Xcode's CoreFoundation uses QTKit Framework by default)
The error occurs after a couple of minutes my video capture c++ program. I even tried on a simple video capture program, and it repeats the same error.
Same install as OP, same stack trace, same problem. I did not see this in OpenCV 3.0. However, I also upgraded to 10.11 (El Capitan) near same time (which now I regret - SIP in OS X complicated the build process for latest versions of OpenCV+CUDA/cuDNN+Caffe w/Python2.7).
I'm using Yosemite 10.10, and I just downgraded to 3.0.0 and works pretty good. I need to run the program for longer period of time to see. But at the moment everything seems fine.
Reverting to 3.0 also solved the problem for me under OSX 10.11.
Also experiencing this problem with OpenCV 3.1.0, OSX version 10.11.2.
Same problem with OpenCV 3.1.0, OSX version 10.11.2. Not using cv::waitKey().
Same problem with OpenCV 3.0.0, OSX version 10.11.2. Not using cv::waitKey(). Should I be? -[CaptureDelegate doFireTimer:]: unrecognized selector sent to instance 0x60800007e980
Found this in: "opencv-3.1.0/modules/videoio/src/cap_qtkit.mm" .... bool CvCaptureCAM::grabFrame(double timeOut) // Create a dummy timer so that runUntilDate does not exit immediately: [NSTimer scheduledTimerWithTimeInterval:100 target:nil selector:@selector(doFireTimer:) userInfo:nil repeats:YES];
This looks like it runs about 100sec then looks for nil and sends it doFireTimer:. I can't find doFilreTimer(), and what happens when the timer target is nil?
on a site called fossies.org, the same line has "capture" as a target. [NSTimer scheduledTimerWithTimeInterval:100 target:capture selector:@selector(doFireTimer:) userInfo:nil repeats:YES];
I can confirm consistent crash exactly 100 seconds after starting my program. I also have OS X 10.11.2 and OpenCV 3.1.0 using the VideoCapture class.
This code doesn't make sense to me: ... [NSTimer scheduledTimerWithTimeInterval:100 target:nil selector:@selector(doFireTimer:) userInfo:nil repeats:YES]; while (![capture updateImage] && (total += sleepTime)<=timeOut) { [[NSRunLoop currentRunLoop] runUntilDate:[NSDate dateWithTimeIntervalSinceNow:sleepTime]]; } ...
The first line : " [NSTimer scheduledTimerWithTimeInterval ... " adds a timer to the current run loop, which isn't created until the while loop is executed. The "while" loop creates run loops to act essentially like sleep(). I don't think run loops act that way. [NSThread sleepForTimeInterval:] might work if there is a separate thread running. Also, if the timer is needed, it should be invalidated when no longer needed, and fixed so it references a valid object.
There is a patch for file cap_qtkit.mm between OpenCV 3.0.0 and OpenCV 3.1.0:
https://github.com/Itseez/opencv/commit/e8bf4417ef7afbebf08283eb50147c12e1bf7b03#diff-2a81486ed8ebf4c35433ebaa5f2c5e75
Could someone revert this fix for cap_qtkit.mm and re-check this problem?
target:capture
--> target:nil
@mron Could you try to use dummy cv::waitKey call (OpenCV 3.0.0):
void main(...)
{
cv::waitKey(1);
... your code without waitKey ...
}
I'm very new to opencv and github, so please bear with me. I did try putting the waitKey() call in. The timer still fires and crashes. Changing "nil" to "capture" will not help unless a "doFireTimer:" method is added to the capture's ( CaptureDelegate? ) class. I'm also new to objc.. sorry.
@rtielking did you fix this? I timed the code, and it crashes in exactly 100 seconds.
yes i was able to fix the crash at 100sec by commenting out the following line
[NSTimer scheduledTimerWithTimeInterval:100 target:capture selector:@selector(doFireTimer:) userInfo:nil repeats:YES];
in the /modules/videoio/src/cap_qtkit.mm file and recompiling
@rtielking I believe I installed OpenCV through Homebrew + Luarocks - how would I recompile it manually?
Download the source at https://github.com/Itseez/opencv/archive/3.1.0.zip and extract the source code. Install XCode from Apple's App Store so you will have the developer tools you need. Find the line I mentioned above and comment it out. Then open a terminal and cd to the directory where you extracted the source code and run the following commands:
brew install cmake mkdir build cd build cmake -D CMAKE_BUILD_TYPE=RELEASE .. make -j4 sudo make install
Then it should work for you on the mac.
@rtielking following these instructions should theoretically allow my program to know which OpenCV version to use right? Should I remove my existing OpenCV installation first?
Might be a good idea to remove existing installation first just to be sure. I always built from source, so don't know where brew puts things when it installs.
@rtielking I compiled it.. commented out the line with the 100
.. Then re-compiled it using the build instructions. However, the crash still happened at the 100 mark =/ I am also not 100% sure if the old installation is gone even though I deleted that folder.
I was able to recompile with the line commented out. The crashes have stopped. I did have the same problem of Xcode using the old framework. I'm not sure exactly how I got Xcode to use the new library. I "make uninstall" on both 3.0 and 3.1, deleted both 3.0 and 3.1 frameworks, "make clean" on both 3.0 and 3.1. In Xcode I did Project->Clean and deleted "Derived Data" folder and removed the framework reference. Rebuilt 3.1, rebuilt the framework, add the framework. The changes were then used and new changes show up as I make them.
Having the same issue
Same issue here. Reverting to 3.0....
Could someone check this fix: #6051?
i'll check
I have verified that 3.1.0 crashes at 100 seconds on El Capitan 10.11.3 and fix #6051 fixed the crash issue. Thanks.
Works for me on OSX Yosemite.
Could someone tell me exactly how to apply this patch ? (sorry for the now question)
I don’t understand github enough to help. I just changed my local copy. Sorry, Ron
I also changed the local copy, but didn't solved the problem. How did you recompile the file ? Or what steps do you took exactly to fix this ? Sorry for all the questions, but I need it for my theses. Thanks anyway !
You have to tell Xcode to delete the cached versions of the library. I'm not sitting at the computer now, so I can't tell you how. It has to do with deleting "derived data". You can look it up. It took me a few tries to get rid of it properly. When I get home I'll look at how I did it. Xcode has so many layers, I don't remember off hand.
Ron
On Feb 26, 2016, at 3:24 AM, MikemanGit notifications@github.com wrote:
I also changed the local copy, but didn't solved the problem. How did you recompile the file ? Or what steps do you took exactly to fix this ? Sorry for all the questions, but I need it for my theses. Thanks anyway !
— Reply to this email directly or view it on GitHub.
@MikemanGit hi Mike, this lovely person made a pretty great tutorial on rebuilding opencv with Make. http://blogs.wcode.org/2014/10/howto-install-build-and-use-opencv-macosx-10-10/
also, make sure you download master at github - https://github.com/Itseez/opencv/archive/master.zip and not the binary linked to from the opencv homepage
like mron said, you will want to make sure your xcode project isn't holding on to any residual libs. inside your project after you install a fresh opencv, go to window -> projects and click delete on your derived data. afterwards you will want to 'clean' your project with product -> clean.
side note, videocapture.read() with webcams has a pretty nasty mem leak on osx 10.11 that seems to still exist in the master branch. if your camera reading needs to happen for a long time, you might want to stick to opencv2
I had a similar problem. If you have previously built OpenCV version 2 you need to deleted the old dylibs (dynamic libraries) before you "make install". 1--Using terminal, go to /usr/local/lib 2-- run ls -la 3-- you should see the older dylibs such as "highgui.2.4..." etc. Remove all the "old" dylibs (anything with version 2...... etc) It's actually easier to remove ALL the OpenCv and libdc1394 dylibs.
CMake will re-install them.
Managed to fix it, thanks guys !
Thank you for your help! this worked perfect
If you use Homebrew, you can also do brew install --HEAD opencv3
to get the newest release from the GitHub repository which consists of the above mentioned fix (probably uninstall the previous version first). Keep in mind though that this is installing the newest code base which is not stable and may introduce other bugs.
Same error and same stack trace here. Did the following: brew remove opencv3 (effectively cleaned everything and Xcode immediately noticed it) brew cleanup brew install --HEAD opencv3 (might be unstable, but hopefully more stable than current 3.1)
thanks mateuszmikusz and LukasKalinski (and everyone) ... i've just updated my SO answer with your better advice
Hi guys. Thank you for all the advices. I reinstall the opencv yet I still have the problem.
Im running Yosemite version 10.10.5 and I also install opencv_contrib. Any suggestions? Or perhaps downgrading is the only way to go. How to downgrade it? Thank you
I’m not familiar with github enough to help. Maybe send a more descriptive message about your install procedure and someone with more understanding can help.
On Mar 31, 2016, at 5:49 AM, Ghifarahadian notifications@github.com wrote:
Hi guys. Thank you for all the advices. I reinstall the opencv yet I still have the problem.
Im running Yosemite version 10.10.5 and I also install opencv_contrib. Any suggestions? Or perhaps downgrading is the only way to go. How to downgrade it? Thank you
— You are receiving this because you were mentioned. Reply to this email directly or view it on GitHub https://github.com/Itseez/opencv/issues/5874#issuecomment-203917888
I am using this (https://github.com/Itseez/opencv_contrib) to install. Oh and initially i use this (https://www.youtube.com/watch?v=U49CVY8yOxw) to install openCV 3.1.0 on Mac. I am not sure whether the openCV installed this way is removed when using brew remove opencv3
hi, is this issue already solved?
Same problem, after a few captures the opencv crashes. I am using python bindings in Mac. This makes video capture unusable. I have to rely on some other frameworks to do the job.
any fixes for python bindings ? Deleting derived data is irrelevant in this case unfortunately.. cheers.
I have same problem in Sierra 10.12. v3.1.0 installed from anaconda
OpenCV 3.1.0 is installed through
brew install opencv3 --with-contirb --with-qt5
and the following program crashes after a while:The stack trace is the following: