Skip to content

Commit 3d9cb53

Browse files
authored
Merge pull request opencv#24136 from komakai:visionos_support
Add experimental support for Apple VisionOS platform opencv#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
1 parent abbd878 commit 3d9cb53

19 files changed

+324
-99
lines changed

Diff for: CMakeLists.txt

+29-29
Original file line numberDiff line numberDiff line change
@@ -238,9 +238,9 @@ OCV_OPTION(BUILD_ITT "Build Intel ITT from source"
238238
# Optional 3rd party components
239239
# ===================================================
240240
OCV_OPTION(WITH_1394 "Include IEEE1394 support" ON
241-
VISIBLE_IF NOT ANDROID AND NOT IOS AND NOT WINRT
241+
VISIBLE_IF NOT ANDROID AND NOT IOS AND NOT XROS AND NOT WINRT
242242
VERIFY HAVE_DC1394_2)
243-
OCV_OPTION(WITH_AVFOUNDATION "Use AVFoundation for Video I/O (iOS/Mac)" ON
243+
OCV_OPTION(WITH_AVFOUNDATION "Use AVFoundation for Video I/O (iOS/visionOS/Mac)" ON
244244
VISIBLE_IF APPLE
245245
VERIFY HAVE_AVFOUNDATION)
246246
OCV_OPTION(WITH_AVIF "Enable AVIF support" OFF
@@ -249,15 +249,15 @@ OCV_OPTION(WITH_CAP_IOS "Enable iOS video capture" ON
249249
VISIBLE_IF IOS
250250
VERIFY HAVE_CAP_IOS)
251251
OCV_OPTION(WITH_CAROTENE "Use NVidia carotene acceleration library for ARM platform" (NOT CV_DISABLE_OPTIMIZATION)
252-
VISIBLE_IF (ARM OR AARCH64) AND NOT IOS)
252+
VISIBLE_IF (ARM OR AARCH64) AND NOT IOS AND NOT XROS)
253253
OCV_OPTION(WITH_CPUFEATURES "Use cpufeatures Android library" ON
254254
VISIBLE_IF ANDROID
255255
VERIFY HAVE_CPUFEATURES)
256256
OCV_OPTION(WITH_VTK "Include VTK library support (and build opencv_viz module eiher)" ON
257-
VISIBLE_IF NOT ANDROID AND NOT IOS AND NOT WINRT AND NOT CMAKE_CROSSCOMPILING
257+
VISIBLE_IF NOT ANDROID AND NOT IOS AND NOT XROS AND NOT WINRT AND NOT CMAKE_CROSSCOMPILING
258258
VERIFY HAVE_VTK)
259259
OCV_OPTION(WITH_CUDA "Include NVidia Cuda Runtime support" OFF
260-
VISIBLE_IF NOT IOS AND NOT WINRT
260+
VISIBLE_IF NOT IOS AND NOT XROS AND NOT WINRT
261261
VERIFY HAVE_CUDA)
262262
OCV_OPTION(WITH_CUFFT "Include NVidia Cuda Fast Fourier Transform (FFT) library support" WITH_CUDA
263263
VISIBLE_IF WITH_CUDA
@@ -278,10 +278,10 @@ OCV_OPTION(WITH_EIGEN "Include Eigen2/Eigen3 support" (NOT CV_DISABLE_OPTIMIZATI
278278
VISIBLE_IF NOT WINRT
279279
VERIFY HAVE_EIGEN)
280280
OCV_OPTION(WITH_FFMPEG "Include FFMPEG support" (NOT ANDROID)
281-
VISIBLE_IF NOT IOS AND NOT WINRT
281+
VISIBLE_IF NOT IOS AND NOT XROS AND NOT WINRT
282282
VERIFY HAVE_FFMPEG)
283283
OCV_OPTION(WITH_GSTREAMER "Include Gstreamer support" ON
284-
VISIBLE_IF NOT ANDROID AND NOT IOS AND NOT WINRT
284+
VISIBLE_IF NOT ANDROID AND NOT IOS AND NOT XROS AND NOT WINRT
285285
VERIFY HAVE_GSTREAMER AND GSTREAMER_VERSION VERSION_GREATER "0.99")
286286
OCV_OPTION(WITH_GTK "Include GTK support" ON
287287
VISIBLE_IF UNIX AND NOT APPLE AND NOT ANDROID
@@ -293,7 +293,7 @@ OCV_OPTION(WITH_WAYLAND "Include Wayland support" OFF
293293
VISIBLE_IF UNIX AND NOT APPLE AND NOT ANDROID
294294
VERIFY HAVE_WAYLAND)
295295
OCV_OPTION(WITH_IPP "Include Intel IPP support" (NOT MINGW AND NOT CV_DISABLE_OPTIMIZATION)
296-
VISIBLE_IF (X86_64 OR X86) AND NOT WINRT AND NOT IOS
296+
VISIBLE_IF (X86_64 OR X86) AND NOT WINRT AND NOT IOS AND NOT XROS
297297
VERIFY HAVE_IPP)
298298
OCV_OPTION(WITH_HALIDE "Include Halide support" OFF
299299
VISIBLE_IF TRUE
@@ -309,10 +309,10 @@ OCV_OPTION(WITH_WEBNN "Include WebNN support" OFF
309309
VISIBLE_IF TRUE
310310
VERIFY HAVE_WEBNN)
311311
OCV_OPTION(WITH_JASPER "Include JPEG2K support (Jasper)" ON
312-
VISIBLE_IF NOT IOS
312+
VISIBLE_IF NOT IOS AND NOT XROS
313313
VERIFY HAVE_JASPER)
314314
OCV_OPTION(WITH_OPENJPEG "Include JPEG2K support (OpenJPEG)" ON
315-
VISIBLE_IF NOT IOS
315+
VISIBLE_IF NOT IOS AND NOT XROS
316316
VERIFY HAVE_OPENJPEG)
317317
OCV_OPTION(WITH_JPEG "Include JPEG support" ON
318318
VISIBLE_IF TRUE
@@ -330,10 +330,10 @@ OCV_OPTION(WITH_OPENVX "Include OpenVX support" OFF
330330
VISIBLE_IF TRUE
331331
VERIFY HAVE_OPENVX)
332332
OCV_OPTION(WITH_OPENNI "Include OpenNI support" OFF
333-
VISIBLE_IF NOT ANDROID AND NOT IOS AND NOT WINRT
333+
VISIBLE_IF NOT ANDROID AND NOT IOS AND NOT XROS AND NOT WINRT
334334
VERIFY HAVE_OPENNI)
335335
OCV_OPTION(WITH_OPENNI2 "Include OpenNI2 support" OFF
336-
VISIBLE_IF NOT ANDROID AND NOT IOS AND NOT WINRT
336+
VISIBLE_IF NOT ANDROID AND NOT IOS AND NOT XROS AND NOT WINRT
337337
VERIFY HAVE_OPENNI2)
338338
OCV_OPTION(WITH_PNG "Include PNG support" ON
339339
VISIBLE_IF TRUE
@@ -345,19 +345,19 @@ OCV_OPTION(WITH_GDCM "Include DICOM support" OFF
345345
VISIBLE_IF TRUE
346346
VERIFY HAVE_GDCM)
347347
OCV_OPTION(WITH_PVAPI "Include Prosilica GigE support" OFF
348-
VISIBLE_IF NOT ANDROID AND NOT IOS AND NOT WINRT
348+
VISIBLE_IF NOT ANDROID AND NOT IOS AND NOT XROS AND NOT WINRT
349349
VERIFY HAVE_PVAPI)
350350
OCV_OPTION(WITH_ARAVIS "Include Aravis GigE support" OFF
351-
VISIBLE_IF NOT ANDROID AND NOT IOS AND NOT WINRT AND NOT WIN32
351+
VISIBLE_IF NOT ANDROID AND NOT IOS AND NOT XROS AND NOT WINRT AND NOT WIN32
352352
VERIFY HAVE_ARAVIS_API)
353353
OCV_OPTION(WITH_QT "Build with Qt Backend support" OFF
354-
VISIBLE_IF NOT ANDROID AND NOT IOS AND NOT WINRT
354+
VISIBLE_IF NOT ANDROID AND NOT IOS AND NOT XROS AND NOT WINRT
355355
VERIFY HAVE_QT)
356356
OCV_OPTION(WITH_WIN32UI "Build with Win32 UI Backend support" ON
357357
VISIBLE_IF WIN32 AND NOT WINRT
358358
VERIFY HAVE_WIN32UI)
359359
OCV_OPTION(WITH_TBB "Include Intel TBB support" OFF
360-
VISIBLE_IF NOT IOS AND NOT WINRT
360+
VISIBLE_IF NOT IOS AND NOT XROS AND NOT WINRT
361361
VERIFY HAVE_TBB)
362362
OCV_OPTION(WITH_HPX "Include Ste||ar Group HPX support" OFF
363363
VISIBLE_IF TRUE
@@ -369,7 +369,7 @@ OCV_OPTION(WITH_PTHREADS_PF "Use pthreads-based parallel_for" ON
369369
VISIBLE_IF NOT WIN32 OR MINGW
370370
VERIFY HAVE_PTHREADS_PF)
371371
OCV_OPTION(WITH_TIFF "Include TIFF support" ON
372-
VISIBLE_IF NOT IOS
372+
VISIBLE_IF NOT IOS AND NOT XROS
373373
VERIFY HAVE_TIFF)
374374
OCV_OPTION(WITH_V4L "Include Video 4 Linux support" ON
375375
VISIBLE_IF UNIX AND NOT ANDROID AND NOT APPLE
@@ -396,16 +396,16 @@ OCV_OPTION(WITH_CLP "Include Clp support (EPL)" OFF
396396
VISIBLE_IF TRUE
397397
VERIFY HAVE_CLP)
398398
OCV_OPTION(WITH_OPENCL "Include OpenCL Runtime support" (NOT ANDROID AND NOT CV_DISABLE_OPTIMIZATION)
399-
VISIBLE_IF NOT IOS AND NOT WINRT
399+
VISIBLE_IF NOT IOS AND NOT XROS AND NOT WINRT
400400
VERIFY HAVE_OPENCL)
401401
OCV_OPTION(WITH_OPENCL_SVM "Include OpenCL Shared Virtual Memory support" OFF
402402
VISIBLE_IF TRUE
403403
VERIFY HAVE_OPENCL_SVM) # experimental
404404
OCV_OPTION(WITH_OPENCLAMDFFT "Include AMD OpenCL FFT library support" ON
405-
VISIBLE_IF NOT ANDROID AND NOT IOS AND NOT WINRT
405+
VISIBLE_IF NOT ANDROID AND NOT IOS AND NOT XROS AND NOT WINRT
406406
VERIFY HAVE_CLAMDFFT)
407407
OCV_OPTION(WITH_OPENCLAMDBLAS "Include AMD OpenCL BLAS library support" ON
408-
VISIBLE_IF NOT ANDROID AND NOT IOS AND NOT WINRT
408+
VISIBLE_IF NOT ANDROID AND NOT IOS AND NOT XROS AND NOT WINRT
409409
VERIFY HAVE_CLAMDBLAS)
410410
OCV_OPTION(WITH_DIRECTX "Include DirectX support" ON
411411
VISIBLE_IF WIN32 AND NOT WINRT
@@ -429,13 +429,13 @@ OCV_OPTION(WITH_MFX "Include Intel Media SDK support" OFF
429429
VISIBLE_IF (UNIX AND NOT ANDROID) OR (WIN32 AND NOT WINRT AND NOT MINGW)
430430
VERIFY HAVE_MFX)
431431
OCV_OPTION(WITH_GDAL "Include GDAL Support" OFF
432-
VISIBLE_IF NOT ANDROID AND NOT IOS AND NOT WINRT
432+
VISIBLE_IF NOT ANDROID AND NOT IOS AND NOT XROS AND NOT WINRT
433433
VERIFY HAVE_GDAL)
434434
OCV_OPTION(WITH_GPHOTO2 "Include gPhoto2 library support" OFF
435-
VISIBLE_IF UNIX AND NOT ANDROID AND NOT IOS
435+
VISIBLE_IF UNIX AND NOT ANDROID AND NOT IOS AND NOT XROS
436436
VERIFY HAVE_GPHOTO2)
437437
OCV_OPTION(WITH_LAPACK "Include Lapack library support" (NOT CV_DISABLE_OPTIMIZATION)
438-
VISIBLE_IF NOT ANDROID AND NOT IOS
438+
VISIBLE_IF NOT ANDROID AND NOT IOS AND NOT XROS
439439
VERIFY HAVE_LAPACK)
440440
OCV_OPTION(WITH_ITT "Include Intel ITT support" ON
441441
VISIBLE_IF NOT APPLE_FRAMEWORK
@@ -516,7 +516,7 @@ OCV_OPTION(INSTALL_TESTS "Install accuracy and performance test binar
516516
# OpenCV build options
517517
# ===================================================
518518
OCV_OPTION(ENABLE_CCACHE "Use ccache" (UNIX AND (CMAKE_GENERATOR MATCHES "Makefile" OR CMAKE_GENERATOR MATCHES "Ninja" OR CMAKE_GENERATOR MATCHES "Xcode")) )
519-
OCV_OPTION(ENABLE_PRECOMPILED_HEADERS "Use precompiled headers" MSVC IF (MSVC OR (NOT IOS AND NOT CMAKE_CROSSCOMPILING) ) )
519+
OCV_OPTION(ENABLE_PRECOMPILED_HEADERS "Use precompiled headers" MSVC IF (MSVC OR (NOT IOS AND NOT XROS AND NOT CMAKE_CROSSCOMPILING) ) )
520520
OCV_OPTION(ENABLE_DELAYLOAD "Enable delayed loading of OpenCV DLLs" OFF VISIBLE_IF MSVC AND BUILD_SHARED_LIBS)
521521
OCV_OPTION(ENABLE_SOLUTION_FOLDERS "Solution folder in Visual Studio or in other IDEs" (MSVC_IDE OR CMAKE_GENERATOR MATCHES Xcode) )
522522
OCV_OPTION(ENABLE_PROFILING "Enable profiling in the GCC compiler (Add flags: -g -pg)" OFF IF CV_GCC )
@@ -526,8 +526,8 @@ OCV_OPTION(ENABLE_OMIT_FRAME_POINTER "Enable -fomit-frame-pointer for GCC"
526526
OCV_OPTION(ENABLE_POWERPC "Enable PowerPC for GCC" ON IF (CV_GCC AND CMAKE_SYSTEM_PROCESSOR MATCHES powerpc.*) )
527527
OCV_OPTION(ENABLE_FAST_MATH "Enable compiler options for fast math optimizations on FP computations (not recommended)" OFF)
528528
if(NOT IOS AND (NOT ANDROID OR OPENCV_ANDROID_USE_LEGACY_FLAGS) AND CMAKE_CROSSCOMPILING) # Use CPU_BASELINE instead
529-
OCV_OPTION(ENABLE_NEON "Enable NEON instructions" (NEON OR ANDROID_ARM_NEON OR AARCH64) IF (CV_GCC OR CV_CLANG) AND (ARM OR AARCH64 OR IOS) )
530-
OCV_OPTION(ENABLE_VFPV3 "Enable VFPv3-D32 instructions" OFF IF (CV_GCC OR CV_CLANG) AND (ARM OR AARCH64 OR IOS) )
529+
OCV_OPTION(ENABLE_NEON "Enable NEON instructions" (NEON OR ANDROID_ARM_NEON OR AARCH64) IF (CV_GCC OR CV_CLANG) AND (ARM OR AARCH64 OR IOS OR XROS) )
530+
OCV_OPTION(ENABLE_VFPV3 "Enable VFPv3-D32 instructions" OFF IF (CV_GCC OR CV_CLANG) AND (ARM OR AARCH64 OR IOS OR XROS) )
531531
endif()
532532
OCV_OPTION(ENABLE_NOISY_WARNINGS "Show all warnings even if they are too noisy" OFF )
533533
OCV_OPTION(OPENCV_WARNINGS_ARE_ERRORS "Treat warnings as errors" OFF )
@@ -649,7 +649,7 @@ endif()
649649
ocv_cmake_hook(POST_CMAKE_BUILD_OPTIONS)
650650

651651
# --- Python Support ---
652-
if(NOT IOS)
652+
if(NOT IOS AND NOT XROS)
653653
include(cmake/OpenCVDetectPython.cmake)
654654
endif()
655655

@@ -734,7 +734,7 @@ include(cmake/OpenCVModule.cmake)
734734
# Detect endianness of build platform
735735
# ----------------------------------------------------------------------------
736736

737-
if(IOS)
737+
if(IOS OR XROS)
738738
# test_big_endian needs try_compile, which doesn't work for iOS
739739
# http://public.kitware.com/Bug/view.php?id=12288
740740
set(WORDS_BIGENDIAN 0)
@@ -1007,7 +1007,7 @@ include(cmake/OpenCVGenAndroidMK.cmake)
10071007
# Generate OpenCVConfig.cmake and OpenCVConfig-version.cmake for cmake projects
10081008
include(cmake/OpenCVGenConfig.cmake)
10091009

1010-
# Generate Info.plist for the IOS framework
1010+
# Generate Info.plist for the iOS/visionOS framework
10111011
if(APPLE_FRAMEWORK)
10121012
include(cmake/OpenCVGenInfoPlist.cmake)
10131013
endif()

Diff for: cmake/OpenCVDetectPython.cmake

+2-2
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ if(NOT ${found})
175175
endif()
176176
endif()
177177

178-
if(NOT ANDROID AND NOT IOS)
178+
if(NOT ANDROID AND NOT IOS AND NOT XROS)
179179
if(CMAKE_HOST_UNIX)
180180
execute_process(COMMAND ${_executable} -c "from sysconfig import *; print(get_path('purelib'))"
181181
RESULT_VARIABLE _cvpy_process
@@ -240,7 +240,7 @@ if(NOT ${found})
240240
OUTPUT_STRIP_TRAILING_WHITESPACE)
241241
endif()
242242
endif()
243-
endif(NOT ANDROID AND NOT IOS)
243+
endif(NOT ANDROID AND NOT IOS AND NOT XROS)
244244
endif()
245245

246246
# Export return values

Diff for: cmake/OpenCVFindLibsGUI.cmake

+1-1
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ endif(WITH_OPENGL)
7777

7878
# --- Cocoa ---
7979
if(APPLE)
80-
if(NOT IOS AND CV_CLANG)
80+
if(NOT IOS AND NOT XROS AND CV_CLANG)
8181
set(HAVE_COCOA YES)
8282
endif()
8383
endif()

Diff for: cmake/OpenCVGenInfoPlist.cmake

+8
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,14 @@ if(IOS)
1313
configure_file("${OpenCV_SOURCE_DIR}/platforms/ios/Info.plist.in"
1414
"${CMAKE_BINARY_DIR}/ios/Info.plist")
1515
endif()
16+
elseif(XROS)
17+
if(APPLE_FRAMEWORK AND DYNAMIC_PLIST)
18+
configure_file("${OpenCV_SOURCE_DIR}/platforms/ios/Info.Dynamic.plist.in"
19+
"${CMAKE_BINARY_DIR}/visionos/Info.plist")
20+
else()
21+
configure_file("${OpenCV_SOURCE_DIR}/platforms/ios/Info.plist.in"
22+
"${CMAKE_BINARY_DIR}/visionos/Info.plist")
23+
endif()
1624
elseif(APPLE)
1725
configure_file("${OpenCV_SOURCE_DIR}/platforms/osx/Info.plist.in"
1826
"${CMAKE_BINARY_DIR}/osx/Info.plist")

Diff for: cmake/OpenCVGenPkgconfig.cmake

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
if(MSVC OR IOS)
1+
if(MSVC OR IOS OR XROS)
22
return()
33
endif()
44

Diff for: cmake/OpenCVUtils.cmake

+1-1
Original file line numberDiff line numberDiff line change
@@ -1564,7 +1564,7 @@ function(ocv_add_library target)
15641564

15651565
set(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG 1)
15661566

1567-
if(IOS AND NOT MAC_CATALYST)
1567+
if((IOS OR XROS) AND NOT MAC_CATALYST)
15681568
set(OPENCV_APPLE_INFO_PLIST "${CMAKE_BINARY_DIR}/ios/Info.plist")
15691569
else()
15701570
set(OPENCV_APPLE_INFO_PLIST "${CMAKE_BINARY_DIR}/osx/Info.plist")

Diff for: modules/core/CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ ocv_add_dispatched_file_force_all(test_intrin512 TEST AVX512_SKX)
2020

2121

2222
set(PARALLEL_ENABLE_PLUGINS_DEFAULT ON)
23-
if(EMSCRIPTEN OR IOS OR WINRT)
23+
if(EMSCRIPTEN OR IOS OR XROS OR WINRT)
2424
set(PARALLEL_ENABLE_PLUGINS_DEFAULT OFF)
2525
endif()
2626
# parallel backends configuration

Diff for: modules/imgcodecs/CMakeLists.txt

+2-2
Original file line numberDiff line numberDiff line change
@@ -137,11 +137,11 @@ if(APPLE OR APPLE_FRAMEWORK)
137137
list(APPEND imgcodecs_srcs ${CMAKE_CURRENT_LIST_DIR}/src/apple_conversions.h)
138138
list(APPEND imgcodecs_srcs ${CMAKE_CURRENT_LIST_DIR}/src/apple_conversions.mm)
139139
endif()
140-
if(IOS)
140+
if(IOS OR XROS)
141141
list(APPEND imgcodecs_srcs ${CMAKE_CURRENT_LIST_DIR}/src/ios_conversions.mm)
142142
list(APPEND IMGCODECS_LIBRARIES "-framework UIKit")
143143
endif()
144-
if(APPLE AND (NOT IOS))
144+
if(APPLE AND (NOT IOS) AND (NOT XROS))
145145
list(APPEND imgcodecs_srcs ${CMAKE_CURRENT_LIST_DIR}/src/macosx_conversions.mm)
146146
list(APPEND IMGCODECS_LIBRARIES "-framework AppKit")
147147
endif()

Diff for: modules/imgcodecs/misc/objc/gen_dict.json

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"SourceMap" : {
3+
"visionos" : "ios"
4+
}
5+
}

Diff for: modules/objc/generator/CMakeLists.txt

+5
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ file(REMOVE_RECURSE "${OPENCV_OBJC_BINDINGS_DIR}/osx")
99
file(REMOVE "${OPENCV_DEPHELPER}/gen_opencv_objc_source_osx") # force re-run after CMake
1010
file(REMOVE_RECURSE "${OPENCV_OBJC_BINDINGS_DIR}/ios")
1111
file(REMOVE "${OPENCV_DEPHELPER}/gen_opencv_objc_source_ios") # force re-run after CMake
12+
file(REMOVE_RECURSE "${OPENCV_OBJC_BINDINGS_DIR}/visionos")
13+
file(REMOVE "${OPENCV_DEPHELPER}/gen_opencv_objc_source_visionos") # force re-run after CMake
1214

1315
# This file is included from a subdirectory
1416
set(OBJC_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/..")
@@ -67,6 +69,8 @@ string(REPLACE "opencv_" "" MODULES "${OPENCV_OBJC_MODULES}")
6769
if(NOT DEFINED OPENCV_OBJC_TARGET AND APPLE_FRAMEWORK)
6870
if(IOS)
6971
set(OPENCV_OBJC_TARGET "ios")
72+
elseif(XROS)
73+
set(OPENCV_OBJC_TARGET "visionos")
7074
else()
7175
set(OPENCV_OBJC_TARGET "osx")
7276
endif()
@@ -117,6 +121,7 @@ if(OPENCV_OBJC_TARGET)
117121
else()
118122
ocv_add_objc_generated_target(osx)
119123
ocv_add_objc_generated_target(ios)
124+
ocv_add_objc_generated_target(visionos)
120125
endif()
121126

122127
add_custom_target(gen_opencv_objc_source

Diff for: modules/objc/generator/gen_objc.py

+7-10
Original file line numberDiff line numberDiff line change
@@ -1600,7 +1600,7 @@ def sanitize_documentation_string(doc, type):
16001600
arg_parser = argparse.ArgumentParser(description='OpenCV Objective-C Wrapper Generator')
16011601
arg_parser.add_argument('-p', '--parser', required=True, help='OpenCV header parser')
16021602
arg_parser.add_argument('-c', '--config', required=True, help='OpenCV modules config')
1603-
arg_parser.add_argument('-t', '--target', required=True, help='Target (either ios or osx)')
1603+
arg_parser.add_argument('-t', '--target', required=True, help='Target (either ios or osx or visionos)')
16041604
arg_parser.add_argument('-f', '--framework', required=True, help='Framework name')
16051605

16061606
args=arg_parser.parse_args()
@@ -1671,6 +1671,7 @@ def sanitize_documentation_string(doc, type):
16711671
logging.info("\nCommon headers (%d):\n%s", len(common_headers), pformat(common_headers))
16721672

16731673
gendict_fname = os.path.join(misc_location, 'gen_dict.json')
1674+
module_source_map = {}
16741675
if os.path.exists(gendict_fname):
16751676
with open(gendict_fname) as f:
16761677
gen_type_dict = json.load(f)
@@ -1687,6 +1688,7 @@ def sanitize_documentation_string(doc, type):
16871688
header_fix.update(gen_type_dict.get("header_fix", {}))
16881689
enum_fix.update(gen_type_dict.get("enum_fix", {}))
16891690
const_fix.update(gen_type_dict.get("const_fix", {}))
1691+
module_source_map = gen_type_dict.get("SourceMap", {})
16901692
namespaces_dict.update(gen_type_dict.get("namespaces_dict", {}))
16911693
module_imports += gen_type_dict.get("module_imports", [])
16921694

@@ -1695,15 +1697,10 @@ def sanitize_documentation_string(doc, type):
16951697
if os.path.exists(objc_files_dir):
16961698
copied_files += copy_objc_files(objc_files_dir, objc_base_path, module, True)
16971699

1698-
if args.target == 'ios':
1699-
ios_files_dir = os.path.join(misc_location, 'ios')
1700-
if os.path.exists(ios_files_dir):
1701-
copied_files += copy_objc_files(ios_files_dir, objc_base_path, module, True)
1702-
1703-
if args.target == 'osx':
1704-
osx_files_dir = os.path.join(misc_location, 'macosx')
1705-
if os.path.exists(osx_files_dir):
1706-
copied_files += copy_objc_files(osx_files_dir, objc_base_path, module, True)
1700+
target_path = 'macosx' if args.target == 'osx' else module_source_map.get(args.target, args.target)
1701+
target_files_dir = os.path.join(misc_location, target_path)
1702+
if os.path.exists(target_files_dir):
1703+
copied_files += copy_objc_files(target_files_dir, objc_base_path, module, True)
17071704

17081705
objc_test_files_dir = os.path.join(misc_location, 'test')
17091706
if os.path.exists(objc_test_files_dir):

Diff for: modules/videoio/CMakeLists.txt

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
set(VIDEOIO_ENABLE_PLUGINS_DEFAULT ON)
2-
if(EMSCRIPTEN OR IOS OR WINRT)
2+
if(EMSCRIPTEN OR IOS OR XROS OR WINRT)
33
set(VIDEOIO_ENABLE_PLUGINS_DEFAULT OFF)
44
endif()
55

@@ -197,7 +197,7 @@ if(TARGET ocv.3rdparty.aravis)
197197
endif()
198198

199199
if(TARGET ocv.3rdparty.avfoundation)
200-
if(IOS)
200+
if(IOS OR XROS)
201201
list(APPEND videoio_srcs ${CMAKE_CURRENT_LIST_DIR}/src/cap_avfoundation.mm)
202202
else()
203203
list(APPEND videoio_srcs ${CMAKE_CURRENT_LIST_DIR}/src/cap_avfoundation_mac.mm)

0 commit comments

Comments
 (0)