cap_qtkit does not work when the capture is run outside of the main
thread.
If the capture is launched in a separate thread, then [NSRunLoop
currentRunLoop] is not the same as in the main thread, and has no timer.
see
https://developer.apple.com/library/mac/#documentation/Cocoa/Reference/F
oundation/Classes/nsrunloop_Class/Reference/Reference.html
"If no input sources or timers are attached to the run loop, this
method exits immediately"
Using usleep() (which I previously proposed, and was reverted) is not a
good alternative, because it may block the GUI.
Here is the new proposed solution:
- create a dummy timer so that runUntilDate does not exit immediately
- simplify the loop by using runUntilDate instead of runMode:beforeDate
- fix potential memory leaks (pointed out by Xcode's static analysis)
- fix init to follow Objective-C guidelines
- fax warnings about conversions from size_t to int
VideoCapture didn't call release method and just ignored the new capture sources.
OpenCV documentation:
bool VideoCapture::open(const string& filename);
bool VideoCapture::open(int device);
The methods first call VideoCapture::release() to close the already opened file or camera.
Now the HAVE_* macros are set using cvconfig.h. Previously most
of them already were there, but were always undefined. One,
HAVE_COCOA, I had to add.
This also makes the CMake code more consistent; now, WITH_* variables
are always checked in cmake/*, while HAVE_* variables are checked in
modules/highgui/CMakeLists.txt.
I've left HAVE_LIBPTHREAD as a CMake variable, since TBB's build depends on it.
Some macros in internal.hpp depended on HAVE_ALLOCA_H, but they were, in turn,
unused, so I've just deleted them all.
VideoCapture didn't call release method and just ignored the new capture sources.
OpenCV documentation:
bool VideoCapture::open(const string& filename);
bool VideoCapture::open(int device);
The methods first call VideoCapture::release() to close the already opened file or camera.
[NSRunLoop currentRunLoop] is not the same as in the main thread.
see
https://developer.apple.com/library/mac/#documentation/Cocoa/Reference/F
oundation/Classes/nsrunloop_Class/Reference/Reference.html
"If no input sources or timers are attached to the run loop, this
method exits immediately"
The old code caused grabFrame() to return immediately if the capture
was not done in the main thread.
This code works correctly, even in secondary threads, provided that all
capture functions are called in the *same* thread
Video i/o tests enabled for media foundation;
Negative stride support added to VideoCapture;
Error handling improved, dead lock in case of playback error fixed;
Some code refacotring done.