Repository: opencv
Issue: error: reference to 'Point' (+Size, Rect, Ptr) is ambiguous while building for iOS
Labels: bug,platform: ios/osx

### System Information

Python version: 3.12.3
OpenCV version: 4.10.0.82

### Detailed description

I'm trying to build OpenCV Python wheel for iOS using cross-compilation.

Getting the following errors at the last stages of compilation process:

```
SKIP:bool cv::aruco::RefineParameters::writeRefineParameters(FileStorage fs, String name = String())	 due to ARG type FileStorage/I
Objective-C: Processing OpenCV modules: 11
Generated files: 415 (updated 415)
[ 99%] Built target gen_opencv_objc_source_ios
[ 99%] Built target gen_opencv_objc_source
[ 99%] Built target opencv_objc
[ 99%] Generate files for Python bindings and documentation
Note: Class cv::Feature2D has more than 1 base class (not supported by Python C extensions)
Bases:  cv::Algorithm, cv::class, cv::Feature2D, cv::Algorithm
Only the first base class will be used
Note: Class cv::detail::GraphCutSeamFinder has more than 1 base class (not supported by Python C extensions)
Bases:  cv::detail::GraphCutSeamFinderBase, cv::detail::SeamFinder
Only the first base class will be used
[ 99%] Built target gen_opencv_python_source
[ 99%] Building CXX object modules/python3/CMakeFiles/opencv_python3.dir/__/src2/cv2.cpp.o
/Users/user/opencv/4.10.0.82/opencv/modules/python/src2/cv2.cpp:28:21: error: reference to 'Point' is ambiguous
typedef std::vector<Point> vector_Point;
^
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS17.5.sdk/usr/include/MacTypes.h:548:41: note: candidate found by name lookup is 'Point'
typedef struct Point                    Point;
^
/Users/user/opencv/4.10.0.82/opencv/modules/core/include/opencv2/core/types.hpp:209:17: note: candidate found by name lookup is 'cv::Point'
typedef Point2i Point;
^
/Users/user/opencv/4.10.0.82/opencv/modules/python/src2/cv2.cpp:28:21: error: reference to 'Point' is ambiguous
typedef std::vector<Point> vector_Point;
^
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS17.5.sdk/usr/include/MacTypes.h:548:41: note: candidate found by name lookup is 'Point'
typedef struct Point                    Point;
^
/Users/user/opencv/4.10.0.82/opencv/modules/core/include/opencv2/core/types.hpp:209:17: note: candidate found by name lookup is 'cv::Point'
typedef Point2i Point;
^
/Users/user/opencv/4.10.0.82/opencv/modules/python/src2/cv2.cpp:31:21: error: reference to 'Size' is ambiguous
typedef std::vector<Size> vector_Size;
^
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS17.5.sdk/usr/include/MacTypes.h:252:41: note: candidate found by name lookup is 'Size'
typedef long                            Size;
^
/Users/user/opencv/4.10.0.82/opencv/modules/core/include/opencv2/core/types.hpp:370:16: note: candidate found by name lookup is 'cv::Size'
typedef Size2i Size;
^
/Users/user/opencv/4.10.0.82/opencv/modules/python/src2/cv2.cpp:31:21: error: reference to 'Size' is ambiguous
typedef std::vector<Size> vector_Size;
^
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS17.5.sdk/usr/include/MacTypes.h:252:41: note: candidate found by name lookup is 'Size'
typedef long                            Size;
^
/Users/user/opencv/4.10.0.82/opencv/modules/core/include/opencv2/core/types.hpp:370:16: note: candidate found by name lookup is 'cv::Size'
typedef Size2i Size;
^
/Users/user/opencv/4.10.0.82/opencv/modules/python/src2/cv2.cpp:37:21: error: reference to 'Rect' is ambiguous
typedef std::vector<Rect> vector_Rect;
^
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS17.5.sdk/usr/include/MacTypes.h:556:41: note: candidate found by name lookup is 'Rect'
typedef struct Rect                     Rect;
^
/Users/user/opencv/4.10.0.82/opencv/modules/core/include/opencv2/core/types.hpp:489:16: note: candidate found by name lookup is 'cv::Rect'
typedef Rect2i Rect;
^
/Users/user/opencv/4.10.0.82/opencv/modules/python/src2/cv2.cpp:37:21: error: reference to 'Rect' is ambiguous
typedef std::vector<Rect> vector_Rect;
^
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS17.5.sdk/usr/include/MacTypes.h:556:41: note: candidate found by name lookup is 'Rect'
typedef struct Rect                     Rect;
^
/Users/user/opencv/4.10.0.82/opencv/modules/core/include/opencv2/core/types.hpp:489:16: note: candidate found by name lookup is 'cv::Rect'
typedef Rect2i Rect;
^
/Users/user/opencv/4.10.0.82/opencv/modules/python/src2/cv2.cpp:50:33: error: reference to 'Point' is ambiguous
typedef std::vector<std::vector<Point> > vector_vector_Point;
^
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS17.5.sdk/usr/include/MacTypes.h:548:41: note: candidate found by name lookup is 'Point'
typedef struct Point                    Point;
^
/Users/user/opencv/4.10.0.82/opencv/modules/core/include/opencv2/core/types.hpp:209:17: note: candidate found by name lookup is 'cv::Point'
typedef Point2i Point;
^
/Users/user/opencv/4.10.0.82/opencv/modules/python/src2/cv2.cpp:50:33: error: reference to 'Point' is ambiguous
typedef std::vector<std::vector<Point> > vector_vector_Point;
^
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS17.5.sdk/usr/include/MacTypes.h:548:41: note: candidate found by name lookup is 'Point'
typedef struct Point                    Point;
^
/Users/user/opencv/4.10.0.82/opencv/modules/core/include/opencv2/core/types.hpp:209:17: note: candidate found by name lookup is 'cv::Point'
typedef Point2i Point;
^
In file included from /Users/user/opencv/4.10.0.82/opencv/modules/python/src2/cv2.cpp:86:
/Users/user/opencv/4.10.0.82/_skbuild/ios-12.0-arm64-iphoneos-3.12/cmake-build/modules/python_bindings_generator/pyopencv_generated_types.h:1:33: error: reference to 'Ptr' is ambiguous
CVPY_TYPE(Algorithm, Algorithm, Ptr<cv::Algorithm>, Ptr, NoBase, 0, "")
^
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS17.5.sdk/usr/include/MacTypes.h:250:41: note: candidate found by name lookup is 'Ptr'
typedef char *                          Ptr;
^
/Users/user/opencv/4.10.0.82/opencv/modules/core/include/opencv2/core/cvstd_wrapper.hpp:73:8: note: candidate found by name lookup is 'cv::Ptr'
struct Ptr : public std::shared_ptr<T>
^
In file included from /Users/user/opencv/4.10.0.82/opencv/modules/python/src2/cv2.cpp:86:
/Users/user/opencv/4.10.0.82/_skbuild/ios-12.0-arm64-iphoneos-3.12/cmake-build/modules/python_bindings_generator/pyopencv_generated_types.h:1:33: error: reference to 'Ptr' is ambiguous
CVPY_TYPE(Algorithm, Algorithm, Ptr<cv::Algorithm>, Ptr, NoBase, 0, "")
^
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS17.5.sdk/usr/include/MacTypes.h:250:41: note: candidate found by name lookup is 'Ptr'
typedef char *                          Ptr;
^
/Users/user/opencv/4.10.0.82/opencv/modules/core/include/opencv2/core/cvstd_wrapper.hpp:73:8: note: candidate found by name lookup is 'cv::Ptr'
struct Ptr : public std::shared_ptr<T>
^
In file included from /Users/user/opencv/4.10.0.82/opencv/modules/python/src2/cv2.cpp:86:
/Users/user/opencv/4.10.0.82/_skbuild/ios-12.0-arm64-iphoneos-3.12/cmake-build/modules/python_bindings_generator/pyopencv_generated_types.h:1:33: error: reference to 'Ptr' is ambiguous
CVPY_TYPE(Algorithm, Algorithm, Ptr<cv::Algorithm>, Ptr, NoBase, 0, "")
^
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS17.5.sdk/usr/include/MacTypes.h:250:41: note: candidate found by name lookup is 'Ptr'
typedef char *                          Ptr;
^
/Users/user/opencv/4.10.0.82/opencv/modules/core/include/opencv2/core/cvstd_wrapper.hpp:73:8: note: candidate found by name lookup is 'cv::Ptr'
struct Ptr : public std::shared_ptr<T>
^
In file included from /Users/user/opencv/4.10.0.82/opencv/modules/python/src2/cv2.cpp:86:
/Users/user/opencv/4.10.0.82/_skbuild/ios-12.0-arm64-iphoneos-3.12/cmake-build/modules/python_bindings_generator/pyopencv_generated_types.h:1:33: error: reference to 'Ptr' is ambiguous
CVPY_TYPE(Algorithm, Algorithm, Ptr<cv::Algorithm>, Ptr, NoBase, 0, "")
^
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS17.5.sdk/usr/include/MacTypes.h:250:41: note: candidate found by name lookup is 'Ptr'
typedef char *                          Ptr;
^
/Users/user/opencv/4.10.0.82/opencv/modules/core/include/opencv2/core/cvstd_wrapper.hpp:73:8: note: candidate found by name lookup is 'cv::Ptr'
struct Ptr : public std::shared_ptr<T>
^
In file included from /Users/user/opencv/4.10.0.82/opencv/modules/python/src2/cv2.cpp:86:
/Users/user/opencv/4.10.0.82/_skbuild/ios-12.0-arm64-iphoneos-3.12/cmake-build/modules/python_bindings_generator/pyopencv_generated_types.h:1:1: error: no member named '~char *' in 'cv::Ptr<cv::Algorithm>'
CVPY_TYPE(Algorithm, Algorithm, Ptr<cv::Algorithm>, Ptr, NoBase, 0, "")
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/user/opencv/4.10.0.82/opencv/modules/python/src2/cv2.cpp:82:73: note: expanded from macro 'CVPY_TYPE'
#define CVPY_TYPE(EXPORT_NAME, CLASS_ID, STORAGE, SNAME, _1, _2, SCOPE) CVPY_TYPE_DECLARE_DYNAMIC(EXPORT_NAME, CLASS_ID, STORAGE, SNAME, SCOPE)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/user/opencv/4.10.0.82/opencv/modules/python/src2/pycompat.hpp:298:54: note: expanded from macro 'CVPY_TYPE_DECLARE_DYNAMIC'
((pyopencv_##CLASS_ID##_t*)self)->v.STORAGE::~SNAME(); \
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~          ^
In file included from /Users/user/opencv/4.10.0.82/opencv/modules/python/src2/cv2.cpp:86:
/Users/user/opencv/4.10.0.82/_skbuild/ios-12.0-arm64-iphoneos-3.12/cmake-build/modules/python_bindings_generator/pyopencv_generated_types.h:2:35: error: reference to 'Ptr' is ambiguous
CVPY_TYPE(AsyncArray, AsyncArray, Ptr<cv::AsyncArray>, Ptr, NoBase, pyopencv_cv_AsyncArray_AsyncArray, "")
^
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS17.5.sdk/usr/include/MacTypes.h:250:41: note: candidate found by name lookup is 'Ptr'
typedef char *                          Ptr;
^
/Users/user/opencv/4.10.0.82/opencv/modules/core/include/opencv2/core/cvstd_wrapper.hpp:73:8: note: candidate found by name lookup is 'cv::Ptr'
struct Ptr : public std::shared_ptr<T>
^
In file included from /Users/user/opencv/4.10.0.82/opencv/modules/python/src2/cv2.cpp:86:
/Users/user/opencv/4.10.0.82/_skbuild/ios-12.0-arm64-iphoneos-3.12/cmake-build/modules/python_bindings_generator/pyopencv_generated_types.h:2:35: error: reference to 'Ptr' is ambiguous
CVPY_TYPE(AsyncArray, AsyncArray, Ptr<cv::AsyncArray>, Ptr, NoBase, pyopencv_cv_AsyncArray_AsyncArray, "")
^
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS17.5.sdk/usr/include/MacTypes.h:250:41: note: candidate found by name lookup is 'Ptr'
typedef char *                          Ptr;
^
/Users/user/opencv/4.10.0.82/opencv/modules/core/include/opencv2/core/cvstd_wrapper.hpp:73:8: note: candidate found by name lookup is 'cv::Ptr'
struct Ptr : public std::shared_ptr<T>
^
In file included from /Users/user/opencv/4.10.0.82/opencv/modules/python/src2/cv2.cpp:86:
/Users/user/opencv/4.10.0.82/_skbuild/ios-12.0-arm64-iphoneos-3.12/cmake-build/modules/python_bindings_generator/pyopencv_generated_types.h:2:35: error: reference to 'Ptr' is ambiguous
CVPY_TYPE(AsyncArray, AsyncArray, Ptr<cv::AsyncArray>, Ptr, NoBase, pyopencv_cv_AsyncArray_AsyncArray, "")
^
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS17.5.sdk/usr/include/MacTypes.h:250:41: note: candidate found by name lookup is 'Ptr'
typedef char *                          Ptr;
^
/Users/user/opencv/4.10.0.82/opencv/modules/core/include/opencv2/core/cvstd_wrapper.hpp:73:8: note: candidate found by name lookup is 'cv::Ptr'
struct Ptr : public std::shared_ptr<T>
^
In file included from /Users/user/opencv/4.10.0.82/opencv/modules/python/src2/cv2.cpp:86:
/Users/user/opencv/4.10.0.82/_skbuild/ios-12.0-arm64-iphoneos-3.12/cmake-build/modules/python_bindings_generator/pyopencv_generated_types.h:2:35: error: reference to 'Ptr' is ambiguous
CVPY_TYPE(AsyncArray, AsyncArray, Ptr<cv::AsyncArray>, Ptr, NoBase, pyopencv_cv_AsyncArray_AsyncArray, "")
^
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS17.5.sdk/usr/include/MacTypes.h:250:41: note: candidate found by name lookup is 'Ptr'
typedef char *                          Ptr;
^
/Users/user/opencv/4.10.0.82/opencv/modules/core/include/opencv2/core/cvstd_wrapper.hpp:73:8: note: candidate found by name lookup is 'cv::Ptr'
struct Ptr : public std::shared_ptr<T>
^
In file included from /Users/user/opencv/4.10.0.82/opencv/modules/python/src2/cv2.cpp:86:
/Users/user/opencv/4.10.0.82/_skbuild/ios-12.0-arm64-iphoneos-3.12/cmake-build/modules/python_bindings_generator/pyopencv_generated_types.h:2:1: error: no member named '~char *' in 'cv::Ptr<cv::AsyncArray>'
CVPY_TYPE(AsyncArray, AsyncArray, Ptr<cv::AsyncArray>, Ptr, NoBase, pyopencv_cv_AsyncArray_AsyncArray, "")
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/user/opencv/4.10.0.82/opencv/modules/python/src2/cv2.cpp:82:73: note: expanded from macro 'CVPY_TYPE'
#define CVPY_TYPE(EXPORT_NAME, CLASS_ID, STORAGE, SNAME, _1, _2, SCOPE) CVPY_TYPE_DECLARE_DYNAMIC(EXPORT_NAME, CLASS_ID, STORAGE, SNAME, SCOPE)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/user/opencv/4.10.0.82/opencv/modules/python/src2/pycompat.hpp:298:54: note: expanded from macro 'CVPY_TYPE_DECLARE_DYNAMIC'
((pyopencv_##CLASS_ID##_t*)self)->v.STORAGE::~SNAME(); \
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~          ^
In file included from /Users/user/opencv/4.10.0.82/opencv/modules/python/src2/cv2.cpp:86:
/Users/user/opencv/4.10.0.82/_skbuild/ios-12.0-arm64-iphoneos-3.12/cmake-build/modules/python_bindings_generator/pyopencv_generated_types.h:4:60: error: reference to 'Ptr' is ambiguous
CVPY_TYPE(ExportClassName, utils_nested_OriginalClassName, Ptr<cv::utils::nested::OriginalClassName>, Ptr, NoBase, 0, ".utils.nested")
^
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS17.5.sdk/usr/include/MacTypes.h:250:41: note: candidate found by name lookup is 'Ptr'
typedef char *                          Ptr;
^
/Users/user/opencv/4.10.0.82/opencv/modules/core/include/opencv2/core/cvstd_wrapper.hpp:73:8: note: candidate found by name lookup is 'cv::Ptr'
struct Ptr : public std::shared_ptr<T>
^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
20 errors generated.
make[2]: *** [modules/python3/CMakeFiles/opencv_python3.dir/__/src2/cv2.cpp.o] Error 1
make[1]: *** [modules/python3/CMakeFiles/opencv_python3.dir/all] Error 2
make: *** [all] Error 2
Traceback (most recent call last):
File "/Users/user/opencv/4.10.0.82/venv3.12-ios_12_0_arm64_iphoneos/build/lib/python3.12/site-packages/skbuild/setuptools_wrap.py", line 672, in setup
cmkr.make(make_args, install_target=cmake_install_target, env=env)
File "/Users/user/opencv/4.10.0.82/venv3.12-ios_12_0_arm64_iphoneos/build/lib/python3.12/site-packages/skbuild/cmaker.py", line 694, in make
self.make_impl(clargs=clargs, config=config, source_dir=source_dir, install_target=install_target, env=env)
File "/Users/user/opencv/4.10.0.82/venv3.12-ios_12_0_arm64_iphoneos/build/lib/python3.12/site-packages/skbuild/cmaker.py", line 739, in make_impl
raise SKBuildError(msg)

An error occurred while building with CMake.
Command:
/Users/user/opencv/4.10.0.82/venv3.12-ios_12_0_arm64_iphoneos/build/lib/python3.12/site-packages/cmake/data/bin/cmake --build . --target install --config Release --
Install target:
install
Source directory:
/Users/user/opencv/4.10.0.82
Working directory:
/Users/user/opencv/4.10.0.82/_skbuild/ios-12.0-arm64-iphoneos-3.12/cmake-build
Please check the install target is valid and see CMake's output for more information.
```

CMAKE variables:

```
-DIOS=1
-DAPPLE_FRAMEWORK=ON
-DOPENCV_INCLUDE_INSTALL_PATH=include
-DOPENCV_3P_LIB_INSTALL_PATH=lib/3rdparty
-DCMAKE_SYSTEM_NAME=iOS
-DCMAKE_SYSTEM_PROCESSOR=aarch64
-DCMAKE_OSX_SYSROOT=iphoneos
-DCMAKE_OSX_ARCHITECTURES=arm64
-DWITH_IPP=OFF
-DWITH_ITT=OFF
-DBUILD_TESTS=OFF
-DBUILD_PERF_TESTS=OFF
-DENABLE_TESTING=OFF
-DBUILD_EXAMPLES=OFF
-DWITH_OPENCL=OFF
-DCMAKE_CXX_COMPILER_WORKS=TRUE
-DCMAKE_C_COMPILER_WORKS=TRUE
-DOPENCV_FORCE_PYTHON_LIBS=ON
-DCMAKE_C_FLAGS=-fembed-bitcode
-DCMAKE_CXX_FLAGS=-fembed-bitcode
-DPYTHON3_INCLUDE_PATH={prefix}/include/python{py_version_short}
-DPYTHON3_LIBRARIES={prefix}/lib/libpython{py_version_short}.so
-DPYTHON3_NUMPY_INCLUDE_DIRS={platlib}/numpy/core/include
```

### Steps to reproduce

I'm running `python -m build -wheel` command with `crossenv` module installed.

### Issue submission checklist

- [X] I report the issue, it's not a question
- [X] I checked the problem with documentation, FAQ, open issues, forum.opencv.org, Stack Overflow, etc and have not found any solution
- [X] I updated to the latest OpenCV version and the issue is still there
- [X] There is reproducer code and related data files (videos, images, onnx, etc)