mirror of
https://github.com/opencv/opencv.git
synced 2025-06-20 01:41:14 +08:00
AVFoundation: fix authorization request not being shown
This commit is contained in:
parent
8609198b05
commit
aaad238c6e
@ -328,10 +328,28 @@ int CvCaptureCAM::startCaptureDevice(int cameraNum) {
|
|||||||
}
|
}
|
||||||
else if (status != AVAuthorizationStatusAuthorized)
|
else if (status != AVAuthorizationStatusAuthorized)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "OpenCV: not authorized to capture video (status %ld), requesting...\n", status);
|
if (!cv::utils::getConfigurationParameterBool("OPENCV_AVFOUNDATION_SKIP_AUTH", false))
|
||||||
// TODO: doesn't work via ssh
|
{
|
||||||
[AVCaptureDevice requestAccessForMediaType:AVMediaTypeVideo completionHandler:^(BOOL) { /* we don't care */}];
|
fprintf(stderr, "OpenCV: not authorized to capture video (status %ld), requesting...\n", status);
|
||||||
// we do not wait for completion
|
[AVCaptureDevice requestAccessForMediaType:AVMediaTypeVideo completionHandler:^(BOOL) { /* we don't care */}];
|
||||||
|
if ([NSThread isMainThread])
|
||||||
|
{
|
||||||
|
// we run the main loop for 0.1 sec to show the message
|
||||||
|
[[NSRunLoop mainRunLoop] runUntilDate:[NSDate dateWithTimeIntervalSinceNow:0.1]];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
fprintf(stderr, "OpenCV: can not spin main run loop from other thread, set "
|
||||||
|
"OPENCV_AVFOUNDATION_SKIP_AUTH=1 to disable authorization request "
|
||||||
|
"and perform it in your application.\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
fprintf(stderr, "OpenCV: not authorized to capture video (status %ld), set "
|
||||||
|
"OPENCV_AVFOUNDATION_SKIP_AUTH=0 to enable authorization request or "
|
||||||
|
"perform it in your application.\n", status);
|
||||||
|
}
|
||||||
[localpool drain];
|
[localpool drain];
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user