Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@komakai
Copy link
Contributor

@komakai komakai commented Aug 9, 2023

Pull Request Readiness Checklist

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

  • I agree to contribute to the project under Apache 2 License.
  • 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
  • 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

@komakai
Copy link
Contributor Author

komakai commented Aug 9, 2023

Build command for testing visionos support:

./opencv/platforms/apple/build_xcframework.py --out visionostest --visionos_archs arm64 --visionsimulator_archs x86_64 --build_only_specified_archs

@asmorkalov
Copy link
Contributor

@komakai Great job! Thanks a lot for the patch!

CMakeLists.txt Outdated
VERIFY HAVE_JASPER)
OCV_OPTION(WITH_OPENJPEG "Include JPEG2K support (OpenJPEG)" ON
VISIBLE_IF NOT IOS
VISIBLE_IF NOT IOS AND NOT VISIONOS
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see a lot of IOS AND VISIONOS in pair. Is there a united variable for all? Like this:

OCV_OPTION(WITH_OPENJPEG "Include JPEG2K support (OpenJPEG)" ON
  VISIBLE_IF NOT APPLE

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

APPLE also includes macOS
I guess we could make something like APPLE_DEVICE but I feel like the names IOS and VISIONOS are going to be easier to understand for maintainers

@komakai
Copy link
Contributor Author

komakai commented Aug 24, 2023

Converting to draft until the necessary changes to cmake are released

@komakai komakai marked this pull request as draft August 24, 2023 05:07
@VadimLevin VadimLevin removed their assignment Aug 28, 2023
@asmorkalov
Copy link
Contributor

@asmorkalov
Copy link
Contributor

VisionOS support is not complete in CMake for now: https://gitlab.kitware.com/cmake/cmake/-/issues/25266

@komakai
Copy link
Contributor Author

komakai commented Nov 11, 2023

VisionOS support is not complete in CMake for now: https://gitlab.kitware.com/cmake/cmake/-/issues/25266

I will try to build this PR with CMake-3.28.0-rc4 when I have a minute and check if it builds OK

@komakai
Copy link
Contributor Author

komakai commented Nov 12, 2023

Could build with CMake from https://github.com/Kitware/CMake/releases/download/v3.28.0-rc4/cmake-3.28.0-rc4-macos-universal.dmg with the below change:
On iOS we have the following defines

  • IPHONEOS in Toolchain-iPhoneOS_Xcode.cmake (OpenCV file)
  • IPHONESIMULATOR in Toolchain-iPhoneSimulator_Xcode.cmake (OpenCV file)
  • IOS in iOS-Initialize.cmake (CMake file)

However for visionOS CMake does not have an equivalent define in visionOS-Initialize.cmake so I added a define XROS to Toolchain-XROS_Xcode.cmake and Toolchain-XRSimulator_Xcode.cmake which is effectly equal to VISIONOS or VISIONSIMULATOR and updated all the cmake files to use this define instead of VISIONOS

@komakai
Copy link
Contributor Author

komakai commented Nov 12, 2023

To test this I was able to create a VisionOS project and add the OpenCV framework and add some simple calls to create a Mat and do some operations on the Mat. I could see that the code built OK but I don't have a device and the latest VisionOS simulator only runs on Apple Silicon so I could not actually run the code.
Unless there is someone with an Apple Silicon Mac who can test this I suggest to accept this PR as is since I don't know when I'll get a chance to test it more thoroughly

@komakai komakai marked this pull request as ready for review November 12, 2023 09:57
@gdyuldin
Copy link

Hi.
Tested under simulator on Apple Silicon (M1) with applying GaussianBlur - it works, when using framework from visionsimulator

Build command:
./opencv/platforms/apple/build_xcframework.py --out visionostest --visionos_archs arm64 --visionsimulator_archs arm64 --build_only_specified_archs

Tools versions:

  • cmake - 3.28.0-rc4
  • Xcode. -Version 15.1 beta (15C5028h)
  • macOS - 13.5.1 (22G90) (Ventura)

With framework from visionos directory build failed with linker error: ld: framework 'opencv2' not found

@fengyuentau
Copy link
Member

fengyuentau commented Nov 27, 2023

Did I miss something to get a successful build? I tested with:

  • macOS Sonoma 14.1.1
  • Xcode 15.0.1
  • CMake 3.28.0-rc5 (cmake-3.28.0-rc5-macos-universal.tar.gz)

and both commands:

./opencv/platforms/apple/build_xcframework.py --out visionostest --visionos_archs arm64 --visionsimulator_archs arm64 --build_only_specified_archs

./opencv/platforms/apple/build_xcframework.py --out visionostest --visionos_archs arm64 --visionsimulator_archs x86_64 --build_only_specified_archs

but only got errors:

CMake Error at /workspace/cmake-3.28.0-rc5-macos-universal/CMake.app/Contents/share/cmake-3.28/Modules/Platform/visionOS-Initialize.cmake:4 (message):
  xros is not an visionOS SDK
Call Stack (most recent call first):
  /workspace/cmake-3.28.0-rc5-macos-universal/CMake.app/Contents/share/cmake-3.28/Modules/CMakeSystemSpecificInitialize.cmake:34 (include)
  CMakeLists.txt:117 (enable_language)

@gdyuldin
Copy link

Did I miss something to get a successful build? I tested with:

  • macOS Sonoma 14.1.1
  • Xcode 15.0.1
  • CMake 3.28.0-rc5 (cmake-3.28.0-rc5-macos-universal.tar.gz)

and both commands:

./opencv/platforms/apple/build_xcframework.py --out visionostest --visionos_archs arm64 --visionsimulator_archs arm64 --build_only_specified_archs

./opencv/platforms/apple/build_xcframework.py --out visionostest --visionos_archs arm64 --visionsimulator_archs x86_64 --build_only_specified_archs

but only got errors:

CMake Error at /workspace/cmake-3.28.0-rc5-macos-universal/CMake.app/Contents/share/cmake-3.28/Modules/Platform/visionOS-Initialize.cmake:4 (message):
  xros is not an visionOS SDK
Call Stack (most recent call first):
  /workspace/cmake-3.28.0-rc5-macos-universal/CMake.app/Contents/share/cmake-3.28/Modules/CMakeSystemSpecificInitialize.cmake:34 (include)
  CMakeLists.txt:117 (enable_language)

Looks like xcode 15.0.1 doesn't support VisionOS (link)
You should use beta version of xcode (for example - this )

@fengyuentau
Copy link
Member

fengyuentau commented Nov 29, 2023

Looks like xcode 15.0.1 doesn't support VisionOS (link)
You should use beta version of xcode (for example - this )

Ok, thanks. Let me try with xcode beta then.


Do you know how to configure CMake to use Xcode beta? I have installed Xcode 15.1 beta but CMake still complains xros is not an visionOS SDK.

@komakai
Copy link
Contributor Author

komakai commented Nov 30, 2023

Do you know how to configure CMake to use Xcode beta? I have installed Xcode 15.1 beta but CMake still complains xros is not an visionOS SDK.

Use xcode-select to select the beta-version - then CMake will use that version

@fengyuentau
Copy link
Member

Do you know how to configure CMake to use Xcode beta? I have installed Xcode 15.1 beta but CMake still complains xros is not an visionOS SDK.

Use xcode-select to select the beta-version - then CMake will use that version

Thank you for the instructions. I can confirm that build can be done successfully with cmake-3.28.0-rc5 and Xcode-15.1-beta and command ./opencv/platforms/apple/build_xcframework.py --out visionostest --visionos_archs arm64 --visionsimulator_archs arm64 --build_only_specified_archs.

cc @asmorkalov

Copy link
Contributor

@asmorkalov asmorkalov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@asmorkalov asmorkalov changed the title Add support for visionOS platform Add experimental support for visionOS platform Dec 20, 2023
@asmorkalov asmorkalov changed the title Add experimental support for visionOS platform Add experimental support for Apple VisionOS platform Dec 20, 2023
@asmorkalov asmorkalov merged commit 3d9cb53 into opencv:4.x Dec 20, 2023
@asmorkalov asmorkalov mentioned this pull request Jan 19, 2024
@klatism
Copy link
Contributor

klatism commented Feb 26, 2024

@komakai I'm getting:

/Users/klatism/Git/opencv/modules/videoio/src/cap_avfoundation.mm:1314:32: error: unrecognized platform name visionOS
if (@available(iOS 11, visionOS 1, *)) {

with:
MacOS: Ventura 13.6.1
XCode: 14.3.1
CMake: 3.27.0

that if statement seems to be within #if TARGET_OS_VISION block. I'm wondering could the check for visionOS be removed from @available?

@komakai
Copy link
Contributor Author

komakai commented Mar 6, 2024

@klatism

I'm wondering could the check for visionOS be removed from @available?

Yes that sounds completely reasonable. I look forward to your Pull Request

@klatism
Copy link
Contributor

klatism commented Mar 8, 2024

@komakai please take a look: #25189. Thanks!

@komakai
Copy link
Contributor Author

komakai commented Mar 10, 2024

@komakai please take a look: #25189. Thanks!

Thanks - looks good

thewoz pushed a commit to thewoz/opencv that referenced this pull request May 29, 2024
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants