1
0
mirror of https://github.com/opencv/opencv.git synced 2026-07-31 00:03:03 +04:00

Merge pull request #24136 from komakai:visionos_support

Add experimental support for Apple VisionOS platform #24136

### Pull Request Readiness Checklist

See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request

- [x] I agree to contribute to the project under Apache 2 License.
- [x] To the best of my knowledge, the proposed patch is not based on a code under GPL or another license that is incompatible with OpenCV
- [x] The PR is proposed to the proper branch

This is dependent on cmake support for VisionOs which is currently in progress.
Creating PR now to test that there are no regressions in iOS and macOS builds
This commit is contained in:
Giles Payne
2023-12-20 21:35:10 +09:00
committed by GitHub
parent abbd878eb5
commit 3d9cb5329c
19 changed files with 325 additions and 100 deletions
+5
View File
@@ -9,6 +9,8 @@ file(REMOVE_RECURSE "${OPENCV_OBJC_BINDINGS_DIR}/osx")
file(REMOVE "${OPENCV_DEPHELPER}/gen_opencv_objc_source_osx") # force re-run after CMake
file(REMOVE_RECURSE "${OPENCV_OBJC_BINDINGS_DIR}/ios")
file(REMOVE "${OPENCV_DEPHELPER}/gen_opencv_objc_source_ios") # force re-run after CMake
file(REMOVE_RECURSE "${OPENCV_OBJC_BINDINGS_DIR}/visionos")
file(REMOVE "${OPENCV_DEPHELPER}/gen_opencv_objc_source_visionos") # force re-run after CMake
# This file is included from a subdirectory
set(OBJC_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/..")
@@ -67,6 +69,8 @@ string(REPLACE "opencv_" "" MODULES "${OPENCV_OBJC_MODULES}")
if(NOT DEFINED OPENCV_OBJC_TARGET AND APPLE_FRAMEWORK)
if(IOS)
set(OPENCV_OBJC_TARGET "ios")
elseif(XROS)
set(OPENCV_OBJC_TARGET "visionos")
else()
set(OPENCV_OBJC_TARGET "osx")
endif()
@@ -117,6 +121,7 @@ if(OPENCV_OBJC_TARGET)
else()
ocv_add_objc_generated_target(osx)
ocv_add_objc_generated_target(ios)
ocv_add_objc_generated_target(visionos)
endif()
add_custom_target(gen_opencv_objc_source
+7 -10
View File
@@ -1600,7 +1600,7 @@ if __name__ == "__main__":
arg_parser = argparse.ArgumentParser(description='OpenCV Objective-C Wrapper Generator')
arg_parser.add_argument('-p', '--parser', required=True, help='OpenCV header parser')
arg_parser.add_argument('-c', '--config', required=True, help='OpenCV modules config')
arg_parser.add_argument('-t', '--target', required=True, help='Target (either ios or osx)')
arg_parser.add_argument('-t', '--target', required=True, help='Target (either ios or osx or visionos)')
arg_parser.add_argument('-f', '--framework', required=True, help='Framework name')
args=arg_parser.parse_args()
@@ -1671,6 +1671,7 @@ if __name__ == "__main__":
logging.info("\nCommon headers (%d):\n%s", len(common_headers), pformat(common_headers))
gendict_fname = os.path.join(misc_location, 'gen_dict.json')
module_source_map = {}
if os.path.exists(gendict_fname):
with open(gendict_fname) as f:
gen_type_dict = json.load(f)
@@ -1687,6 +1688,7 @@ if __name__ == "__main__":
header_fix.update(gen_type_dict.get("header_fix", {}))
enum_fix.update(gen_type_dict.get("enum_fix", {}))
const_fix.update(gen_type_dict.get("const_fix", {}))
module_source_map = gen_type_dict.get("SourceMap", {})
namespaces_dict.update(gen_type_dict.get("namespaces_dict", {}))
module_imports += gen_type_dict.get("module_imports", [])
@@ -1695,15 +1697,10 @@ if __name__ == "__main__":
if os.path.exists(objc_files_dir):
copied_files += copy_objc_files(objc_files_dir, objc_base_path, module, True)
if args.target == 'ios':
ios_files_dir = os.path.join(misc_location, 'ios')
if os.path.exists(ios_files_dir):
copied_files += copy_objc_files(ios_files_dir, objc_base_path, module, True)
if args.target == 'osx':
osx_files_dir = os.path.join(misc_location, 'macosx')
if os.path.exists(osx_files_dir):
copied_files += copy_objc_files(osx_files_dir, objc_base_path, module, True)
target_path = 'macosx' if args.target == 'osx' else module_source_map.get(args.target, args.target)
target_files_dir = os.path.join(misc_location, target_path)
if os.path.exists(target_files_dir):
copied_files += copy_objc_files(target_files_dir, objc_base_path, module, True)
objc_test_files_dir = os.path.join(misc_location, 'test')
if os.path.exists(objc_test_files_dir):