From 621a1d3b09942f39c2d23117533543cd1dfc3f5d Mon Sep 17 00:00:00 2001 From: Yaron Inger Date: Thu, 5 Oct 2017 20:22:56 +0300 Subject: [PATCH] videoio: remove AssetsLibrary dependency. The entire AssetsLibrary framework is deprecated since iOS 8.0. The code used in the camera example code can use UIKit to save videos to the camera instead, which allows to avoid linking with PhotoKit instead to prevent increasing the iOS deployment target. --- modules/highgui/CMakeLists.txt | 2 +- modules/highgui/src/cap_ios_video_camera.mm | 8 ++------ 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/modules/highgui/CMakeLists.txt b/modules/highgui/CMakeLists.txt index dc6f777a0e..d59e95ae09 100644 --- a/modules/highgui/CMakeLists.txt +++ b/modules/highgui/CMakeLists.txt @@ -241,7 +241,7 @@ endif(HAVE_INTELPERC) if(IOS) add_definitions(-DHAVE_IOS=1) list(APPEND highgui_srcs src/ios_conversions.mm src/cap_ios_abstract_camera.mm src/cap_ios_photo_camera.mm src/cap_ios_video_camera.mm) - list(APPEND HIGHGUI_LIBRARIES "-framework Accelerate" "-framework AVFoundation" "-framework CoreGraphics" "-framework CoreMedia" "-framework CoreVideo" "-framework QuartzCore" "-framework AssetsLibrary") + list(APPEND HIGHGUI_LIBRARIES "-framework Accelerate" "-framework AVFoundation" "-framework CoreGraphics" "-framework CoreMedia" "-framework CoreVideo" "-framework QuartzCore" "-framework UIKit") endif() if(WIN32) diff --git a/modules/highgui/src/cap_ios_video_camera.mm b/modules/highgui/src/cap_ios_video_camera.mm index 25b652b403..0f72a7c1d7 100644 --- a/modules/highgui/src/cap_ios_video_camera.mm +++ b/modules/highgui/src/cap_ios_video_camera.mm @@ -31,7 +31,7 @@ #import "opencv2/highgui/cap_ios.h" #include "precomp.hpp" -#import +#import static CGFloat DegreesToRadians(CGFloat degrees) {return degrees * M_PI / 180;}; @@ -595,11 +595,7 @@ static CGFloat DegreesToRadians(CGFloat degrees) {return degrees * M_PI / 180;}; return; } - ALAssetsLibrary *library = [[ALAssetsLibrary alloc] init]; - if ([library videoAtPathIsCompatibleWithSavedPhotosAlbum:[self videoFileURL]]) { - [library writeVideoAtPathToSavedPhotosAlbum:[self videoFileURL] - completionBlock:^(NSURL *assetURL, NSError *error){ (void)assetURL; (void)error; }]; - } + UISaveVideoAtPathToSavedPhotosAlbum([self videoFileString], nil, nil, NULL); }