Last active
December 26, 2015 15:29
-
-
Save Sitin/7172726 to your computer and use it in GitHub Desktop.
Fixes iSight camera capture issue for OpenCV 2.4.6.1
https://trac.macports.org/browser/trunk/dports/graphics/opencv/files/patch-issue-3156.diff
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/modules/highgui/src/cap_qtkit.mm b/modules/highgui/src/cap_qtkit.mm | |
index 207f01b..4f7b188 100644 | |
--- a/modules/highgui/src/cap_qtkit.mm | |
+++ b/modules/highgui/src/cap_qtkit.mm | |
@@ -277,8 +277,11 @@ bool CvCaptureCAM::grabFrame(double timeOut) { | |
double sleepTime = 0.005; | |
double total = 0; | |
- while (![capture updateImage] && (total += sleepTime)<=timeOut) | |
- usleep((int)(sleepTime*1000)); | |
+ NSDate *loopUntil = [NSDate dateWithTimeIntervalSinceNow:sleepTime]; | |
+ while (![capture updateImage] && (total += sleepTime)<=timeOut && | |
+ [[NSRunLoop currentRunLoop] runMode: NSDefaultRunLoopMode | |
+ beforeDate:loopUntil]) | |
+ loopUntil = [NSDate dateWithTimeIntervalSinceNow:sleepTime]; | |
[localpool drain]; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment