Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cocoa Application VideoCapture crashes on release() using AVFoundation #7833

Closed
aprowe opened this issue Dec 9, 2016 · 2 comments · Fixed by #8274
Closed

Cocoa Application VideoCapture crashes on release() using AVFoundation #7833

aprowe opened this issue Dec 9, 2016 · 2 comments · Fixed by #8274

Comments

@aprowe
Copy link

aprowe commented Dec 9, 2016

System information (version)
  • OpenCV => Dec 7th HEAD (2341222)
  • Operating System / Platform => Mac 10.11 / 10.12
  • Compiler => Xcode
Detailed description

We are trying to use an AVFoundation build of opencv_videoio in our macOS app.
It is able to open the webcam and read from it, but once release is called, a EXC_BAD_ACCESS Error is thrown. Here are stack traces caught by Zombies. I wasn't sure exactly what is relevant in the zombie report. Here's a screenshot.

screen shot 2016-12-09 at 3 16 07 pm

Stepping through the code, It successfully turns the camera off, exits release(), and continue program flow, and another thread crashes the program each time.

It does NOT crash on a blank c++ command line project, only happens in a cocoa app.

We have tried running both on Sierra and El Capitan.
We chose to use AVFoundation to support Sierra, and chose to not use FFMpeg. Are there any other build options to consider?

Steps to reproduce

Build openCV with

WITH_AVFOUNDATION=YES
WITH_FFMPEG=NO
WITH_QT=NO
WITH_QUICKTIME=NO

Create an empty Cocoa Project,
and in ApplicationDidFinishLaunching put basic VideoIO capture calls in

- (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
  cv::VideoCapture cap(0);
  cap.release();
}
@jbyu
Copy link

jbyu commented Dec 28, 2016

In cap_avfoundation_mac.mm, function CvCaptureCAM::stopCaptureDevice, comment this line [mCaptureDevice release];

@aprowe
Copy link
Author

aprowe commented Jan 10, 2017

This fixed it, thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants