Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
O
opencv
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
opencv
Commits
70c88a20
Commit
70c88a20
authored
Sep 16, 2019
by
Alexander Alekhin
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #15517 from mshabunin:fix-osx-avfoundation-auth
parents
7770ba1f
f10fce9a
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
38 additions
and
17 deletions
+38
-17
cap_avfoundation_mac.mm
modules/videoio/src/cap_avfoundation_mac.mm
+38
-17
No files found.
modules/videoio/src/cap_avfoundation_mac.mm
View file @
70c88a20
...
...
@@ -316,24 +316,45 @@ int CvCaptureCAM::startCaptureDevice(int cameraNum) {
NSAutoreleasePool *localpool = [[NSAutoreleasePool alloc] init];
#if defined(__MAC_OS_X_VERSION_MAX_ALLOWED) && __MAC_OS_X_VERSION_MAX_ALLOWED >= 101400
AVAuthorizationStatus status = [AVCaptureDevice authorizationStatusForMediaType:AVMediaTypeVideo];
if (status == AVAuthorizationStatusDenied)
if (@available(macOS 10.14, *))
{
fprintf(stderr, "OpenCV: camera access has been denied. Either run 'tccutil reset Camera' "
"command in same terminal to reset application authorization status, "
"either modify 'System Preferences -> Security & Privacy -> Camera' "
"settings for your application.\n");
[localpool drain];
return 0;
}
else if (status != AVAuthorizationStatusAuthorized)
{
fprintf(stderr, "OpenCV: not authorized to capture video (status %ld), requesting...\n", status);
// TODO: doesn't work via ssh
[AVCaptureDevice requestAccessForMediaType:AVMediaTypeVideo completionHandler:^(BOOL) { /* we don't care */}];
// we do not wait for completion
[localpool drain];
return 0;
AVAuthorizationStatus status = [AVCaptureDevice authorizationStatusForMediaType:AVMediaTypeVideo];
if (status == AVAuthorizationStatusDenied)
{
fprintf(stderr, "OpenCV: camera access has been denied. Either run 'tccutil reset Camera' "
"command in same terminal to reset application authorization status, "
"either modify 'System Preferences -> Security & Privacy -> Camera' "
"settings for your application.\n");
[localpool drain];
return 0;
}
else if (status != AVAuthorizationStatusAuthorized)
{
if (!cv::utils::getConfigurationParameterBool("OPENCV_AVFOUNDATION_SKIP_AUTH", false))
{
fprintf(stderr, "OpenCV: not authorized to capture video (status %ld), requesting...\n", status);
[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];
return 0;
}
}
#endif
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment