feat: 切换后端至PaddleOCR-NCNN,切换工程为CMake

1.项目后端整体迁移至PaddleOCR-NCNN算法,已通过基本的兼容性测试
2.工程改为使用CMake组织,后续为了更好地兼容第三方库,不再提供QMake工程
3.重整权利声明文件,重整代码工程,确保最小化侵权风险

Log: 切换后端至PaddleOCR-NCNN,切换工程为CMake
Change-Id: I4d5d2c5d37505a4a24b389b1a4c5d12f17bfa38c
This commit is contained in:
wangzhengyang
2022-05-10 09:54:44 +08:00
parent ecdd171c6f
commit 718c41634f
10018 changed files with 3593797 additions and 186748 deletions

File diff suppressed because it is too large Load Diff

18
3rdparty/opencv-mobile/Info.plist vendored Normal file
View File

@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleName</key>
<string>__NAME__</string>
<key>CFBundleIdentifier</key>
<string>__IDENTIFIER__</string>
<key>CFBundleVersion</key>
<string>__VERSION__</string>
<key>CFBundleShortVersionString</key>
<string>__VERSION__</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundlePackageType</key>
<string>FMWK</string>
</dict>
</plist>

201
3rdparty/opencv-mobile/LICENSE vendored Normal file
View File

@ -0,0 +1,201 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright [yyyy] [name of copyright owner]
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

227
3rdparty/opencv-mobile/README.md vendored Normal file
View File

@ -0,0 +1,227 @@
# opencv-mobile
![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)
![release](https://github.com/nihui/opencv-mobile/workflows/release/badge.svg)
![download](https://img.shields.io/github/downloads/nihui/opencv-mobile/total.svg)
✔️ This project provides the minimal build of opencv library for the **Android**, **iOS** and **ARM Linux** platforms.
✔️ Packages for **Windows**, **Linux**, **MacOS** and **WebAssembly** are available now.
✔️ We provide prebuild binary packages for opencv **2.4.13.7**, **3.4.16** and **4.5.4**.
✔️ We also provide prebuild binary package for **iOS with bitcode enabled**, that the official package lacks.
✔️ All the binaries are compiled from source on github action, **no virus**, **no backdoor**, **no secret code**.
|opencv 4.5.4 android|package size|
|---|---|
|The official opencv|235MB|
|opencv-mobile|16.1MB|
|opencv 4.5.4 ios|package size|
|---|---|
|The official opencv|183MB|
|opencv-mobile|15.4MB|
|opencv 4.5.4 ios with bitcode|package size|
|---|---|
|The official opencv|missing :(|
|opencv-mobile|53.7MB|
# Download
## Android
(armeabi-v7a, arm64-v8a, x86, x86_64) build with ndk r21d and android api 24.
* [opencv-mobile-2.4.13.7-android.zip (7.87MB)](https://github.com/nihui/opencv-mobile/releases/download/v14/opencv-mobile-2.4.13.7-android.zip)
* [opencv-mobile-3.4.16-android.zip (15.3MB)](https://github.com/nihui/opencv-mobile/releases/download/v14/opencv-mobile-3.4.16-android.zip)
* [opencv-mobile-4.5.4-android.zip (16.1MB)](https://github.com/nihui/opencv-mobile/releases/download/v14/opencv-mobile-4.5.4-android.zip)
## iOS
(armv7, arm64, arm64e, i386, x86_64) build with Xcode 12.4.
* [opencv-mobile-2.4.13.7-ios.zip (9.88MB)](https://github.com/nihui/opencv-mobile/releases/download/v14/opencv-mobile-2.4.13.7-ios.zip)
* [opencv-mobile-3.4.16-ios.zip (14.7MB)](https://github.com/nihui/opencv-mobile/releases/download/v14/opencv-mobile-3.4.16-ios.zip)
* [opencv-mobile-4.5.4-ios.zip (15.4MB)](https://github.com/nihui/opencv-mobile/releases/download/v14/opencv-mobile-4.5.4-ios.zip)
## iOS with bitcode
(armv7, arm64, arm64e, i386, x86_64) build with Xcode 12.4.
* [opencv-mobile-2.4.13.7-ios-bitcode.zip (35.5MB)](https://github.com/nihui/opencv-mobile/releases/download/v14/opencv-mobile-2.4.13.7-ios-bitcode.zip)
* [opencv-mobile-3.4.16-ios-bitcode.zip (51.3MB)](https://github.com/nihui/opencv-mobile/releases/download/v14/opencv-mobile-3.4.16-ios-bitcode.zip)
* [opencv-mobile-4.5.4-ios-bitcode.zip (53.7MB)](https://github.com/nihui/opencv-mobile/releases/download/v14/opencv-mobile-4.5.4-ios-bitcode.zip)
## ARM Linux
(arm-linux-gnueabi, arm-linux-gnueabihf, aarch64-linux-gnu) build with ubuntu cross compiler.
* [opencv-mobile-2.4.13.7-armlinux.zip (8.01MB)](https://github.com/nihui/opencv-mobile/releases/download/v14/opencv-mobile-2.4.13.7-armlinux.zip)
* [opencv-mobile-3.4.16-armlinux.zip (14.3MB)](https://github.com/nihui/opencv-mobile/releases/download/v14/opencv-mobile-3.4.16-armlinux.zip)
* [opencv-mobile-4.5.4-armlinux.zip (15.3MB)](https://github.com/nihui/opencv-mobile/releases/download/v14/opencv-mobile-4.5.4-armlinux.zip)
## Windows
(x86, x64) build with VS2015, VS2017 and VS2019.
* [opencv-mobile-2.4.13.7-windows-vs2015.zip](https://github.com/nihui/opencv-mobile/releases/download/v14/opencv-mobile-2.4.13.7-windows-vs2015.zip)
* [opencv-mobile-2.4.13.7-windows-vs2017.zip](https://github.com/nihui/opencv-mobile/releases/download/v14/opencv-mobile-2.4.13.7-windows-vs2017.zip)
* [opencv-mobile-2.4.13.7-windows-vs2019.zip](https://github.com/nihui/opencv-mobile/releases/download/v14/opencv-mobile-2.4.13.7-windows-vs2019.zip)
* [opencv-mobile-3.4.16-windows-vs2015.zip](https://github.com/nihui/opencv-mobile/releases/download/v14/opencv-mobile-3.4.16-windows-vs2015.zip)
* [opencv-mobile-3.4.16-windows-vs2017.zip](https://github.com/nihui/opencv-mobile/releases/download/v14/opencv-mobile-3.4.16-windows-vs2017.zip)
* [opencv-mobile-3.4.16-windows-vs2019.zip](https://github.com/nihui/opencv-mobile/releases/download/v14/opencv-mobile-3.4.16-windows-vs2019.zip)
* [opencv-mobile-4.5.4-windows-vs2015.zip](https://github.com/nihui/opencv-mobile/releases/download/v14/opencv-mobile-4.5.4-windows-vs2015.zip)
* [opencv-mobile-4.5.4-windows-vs2017.zip](https://github.com/nihui/opencv-mobile/releases/download/v14/opencv-mobile-4.5.4-windows-vs2017.zip)
* [opencv-mobile-4.5.4-windows-vs2019.zip](https://github.com/nihui/opencv-mobile/releases/download/v14/opencv-mobile-4.5.4-windows-vs2019.zip)
## Linux
(x86_64) build on Ubuntu-18.04 and 20.04.
* [opencv-mobile-2.4.13.7-ubuntu-1804.zip](https://github.com/nihui/opencv-mobile/releases/download/v14/opencv-mobile-2.4.13.7-ubuntu-1804.zip)
* [opencv-mobile-2.4.13.7-ubuntu-2004.zip](https://github.com/nihui/opencv-mobile/releases/download/v14/opencv-mobile-2.4.13.7-ubuntu-2004.zip)
* [opencv-mobile-3.4.16-ubuntu-1804.zip](https://github.com/nihui/opencv-mobile/releases/download/v14/opencv-mobile-3.4.16-ubuntu-1804.zip)
* [opencv-mobile-3.4.16-ubuntu-2004.zip](https://github.com/nihui/opencv-mobile/releases/download/v14/opencv-mobile-3.4.16-ubuntu-2004.zip)
* [opencv-mobile-4.5.4-ubuntu-1804.zip](https://github.com/nihui/opencv-mobile/releases/download/v14/opencv-mobile-4.5.4-ubuntu-1804.zip)
* [opencv-mobile-4.5.4-ubuntu-2004.zip](https://github.com/nihui/opencv-mobile/releases/download/v14/opencv-mobile-4.5.4-ubuntu-2004.zip)
## MacOS
(x86_64, arm64) build with Xcode 12.4.
* [opencv-mobile-2.4.13.7-macos.zip](https://github.com/nihui/opencv-mobile/releases/download/v14/opencv-mobile-2.4.13.7-macos.zip)
* [opencv-mobile-3.4.16-macos.zip](https://github.com/nihui/opencv-mobile/releases/download/v14/opencv-mobile-3.4.16-macos.zip)
* [opencv-mobile-4.5.4-macos.zip](https://github.com/nihui/opencv-mobile/releases/download/v14/opencv-mobile-4.5.4-macos.zip)
## WebAssembly
(basic, simd, threads, simd+threads) build with Emscripten 2.0.8.
* [opencv-mobile-2.4.13.7-webassembly.zip](https://github.com/nihui/opencv-mobile/releases/download/v14/opencv-mobile-2.4.13.7-webassembly.zip)
* [opencv-mobile-3.4.16-webassembly.zip](https://github.com/nihui/opencv-mobile/releases/download/v14/opencv-mobile-3.4.16-webassembly.zip)
* [opencv-mobile-4.5.4-webassembly.zip](https://github.com/nihui/opencv-mobile/releases/download/v14/opencv-mobile-4.5.4-webassembly.zip)
# Usage Android
1. Extract archive to ```<project dir>/app/src/main/jni/```
2. Modify ```<project dir>/app/src/main/jni/CMakeListst.txt``` to find and link opencv
```cmake
set(OpenCV_DIR ${CMAKE_SOURCE_DIR}/opencv-mobile-4.5.4-android/sdk/native/jni)
find_package(OpenCV REQUIRED)
target_link_libraries(your_jni_target ${OpenCV_LIBS})
```
# Usage iOS and MacOS
1. Extract archive, and drag ```opencv2.framework``` into your project
# Usage ARM Linux, Windows, Linux, WebAssembly
1. Extract archive to ```<project dir>/```
2. Modify ```<project dir>/CMakeListst.txt``` to find and link opencv
```cmake
set(OpenCV_DIR ${CMAKE_SOURCE_DIR}/opencv-mobile-4.5.4-armlinux/arm-linux-gnueabihf/lib/cmake/opencv4)
find_package(OpenCV REQUIRED)
target_link_libraries(your_target ${OpenCV_LIBS})
```
# How-to-build your custom package
**step 1. download opencv source**
```shell
wget -q https://github.com/opencv/opencv/archive/4.5.4.zip -O opencv-4.5.4.zip
unzip -q opencv-4.5.4.zip
cd opencv-4.5.4
```
**step 2. strip zlib dependency and use stb-based highgui implementation (optional)**
```shell
patch -p1 -i ../opencv-4.5.4-no-zlib.patch
truncate -s 0 cmake/OpenCVFindLibsGrfmt.cmake
rm -rf modules/gapi
rm -rf modules/highgui
cp -r ../highgui modules/
```
**step 3. patch opencv source for no-rtti build (optional)**
```shell
patch -p1 -i ../opencv-4.5.4-no-rtti.patch
```
**step 4. apply your opencv options to opencv4_cmake_options.txt**
**step 5. build your opencv package with cmake**
```shell
mkdir -p build
cd build
cmake -DCMAKE_INSTALL_PREFIX=install \
-DCMAKE_BUILD_TYPE=Release \
`cat ../../opencv4_cmake_options.txt` \
-DBUILD_opencv_world=OFF ..
```
**step 6. make a package**
```shell
zip -r -9 opencv-mobile-4.5.4.zip install
```
# Some notes
* The minimal opencv build contains most basic opencv operators and common image processing functions, with some handy additions like keypoint feature extraction and matching, image inpainting and opticalflow estimation.
* Many computer vision algorithms that reside in dedicated modules are discarded, such as face detection etc. [You could try deep-learning based algorithms with nerual network inference library optimized for mobile.](https://github.com/Tencent/ncnn)
* Image IO functions in highgui module, like ```cv::imread``` and ```cv::imwrite```, are re-implemented using [stb](https://github.com/nothings/stb) for smaller code size. GUI functions, like ```cv::imshow```, are discarded.
* cuda and opencl are disabled because there is no cuda on mobile, no opencl on ios, and opencl on android is slow. opencv on gpu is not suitable for real productions. Write metal on ios and opengles/vulkan on android if you need good gpu acceleration.
* C++ RTTI and exceptions are disabled for minimal build on mobile platforms and webassembly build. Be careful when you write ```cv::Mat roi = image(roirect);``` :P
# opencv modules included
|module|comment|
|---|---|
|opencv_core|Mat, matrix operations, etc|
|opencv_imgproc|resize, cvtColor, warpAffine, etc|
|opencv_highgui|imread, imwrite|
|opencv_features2d|keypoint feature and matcher, etc (not included in opencv 2.x package)|
|opencv_photo|inpaint, etc|
|opencv_video|opticalflow, etc|
# opencv modules discarded
|module|comment|
|---|---|
|opencv_androidcamera|use android Camera api instead|
|opencv_calib3d|camera calibration, rare uses on mobile|
|opencv_contrib|experimental functions, build part of the source externally if you need|
|opencv_dnn|very slow on mobile, try ncnn for nerual network inference on mobile|
|opencv_dynamicuda|no cuda on mobile|
|opencv_flann|feature matching, rare uses on mobile, build the source externally if you need|
|opencv_gapi|graph based image processing, little gain on mobile|
|opencv_gpu|no cuda/opencl on mobile|
|opencv_imgcodecs|link with opencv_highgui instead|
|opencv_java|wrap your c++ code with jni|
|opencv_js|write native code on mobile|
|opencv_lagacy|various good-old cv routines, build part of the source externally if you need|
|opencv_ml|train your ML algorithm on powerful pc or server|
|opencv_nonfree|the SIFT and SURF, use ORB which is faster and better|
|opencv_objdetect|HOG, cascade detector, use deep learning detector which is faster and better|
|opencv_ocl|no opencl on mobile|
|opencv_python|no python on mobile|
|opencv_shape|shape matching, rare uses on mobile, build the source externally if you need|
|opencv_stitching|image stitching, rare uses on mobile, build the source externally if you need|
|opencv_superres|do video super-resolution on powerful pc or server|
|opencv_ts|test modules, useless in production anyway|
|opencv_videoio|use android MediaCodec or ios AVFoundation api instead|
|opencv_videostab|do video stablization on powerful pc or server|
|opencv_viz|vtk is not available on mobile, write your own data visualization routines|

View File

@ -0,0 +1,58 @@
set(the_description "High-level GUI")
ocv_add_module(highgui opencv_imgproc)
set(highgui_srcs
${CMAKE_CURRENT_LIST_DIR}/src/exif.cpp
${CMAKE_CURRENT_LIST_DIR}/src/highgui.cpp
)
file(GLOB highgui_ext_hdrs
"${CMAKE_CURRENT_LIST_DIR}/include/opencv2/*.hpp"
"${CMAKE_CURRENT_LIST_DIR}/include/opencv2/${name}/*.hpp"
"${CMAKE_CURRENT_LIST_DIR}/include/opencv2/${name}/*.h")
if(UNIX OR OPENCV_VERSION_MAJOR GREATER_EQUAL 3)
#these variables are set by CHECK_MODULE macro
foreach(P ${HIGHGUI_INCLUDE_DIRS})
ocv_include_directories(${P})
endforeach()
foreach(P ${HIGHGUI_LIBRARY_DIRS})
link_directories(${P})
endforeach()
endif()
source_group("Src" FILES ${highgui_srcs})
source_group("Include" FILES ${highgui_ext_hdrs})
ocv_set_module_sources(HEADERS ${highgui_ext_hdrs} SOURCES ${highgui_srcs})
ocv_module_include_directories()
ocv_create_module(${HIGHGUI_LIBRARIES})
if(OPENCV_VERSION_MAJOR EQUAL 2)
if(BUILD_SHARED_LIBS)
add_definitions(-DHIGHGUI_EXPORTS)
endif()
if(MSVC)
set_target_properties(${the_module} PROPERTIES LINK_FLAGS "/NODEFAULTLIB:atlthunk.lib /NODEFAULTLIB:atlsd.lib /NODEFAULTLIB:libcmt.lib /DEBUG")
endif()
ocv_warnings_disable(CMAKE_CXX_FLAGS -Wno-deprecated-declarations -Wno-clobbered)
else()
macro(ocv_highgui_configure_target)
if(APPLE)
add_apple_compiler_options(the_module)
endif()
if(MSVC)
set_target_properties(${the_module} PROPERTIES LINK_FLAGS "/NODEFAULTLIB:atlthunk.lib /NODEFAULTLIB:atlsd.lib /NODEFAULTLIB:libcmt.lib /DEBUG")
endif()
ocv_warnings_disable(CMAKE_CXX_FLAGS -Wno-deprecated-declarations)
endmacro()
if(NOT BUILD_opencv_world)
ocv_highgui_configure_target()
endif()
endif()

View File

@ -0,0 +1,17 @@
//
// Copyright (C) 2021 nihui
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
#include "opencv2/highgui/highgui.hpp"

View File

@ -0,0 +1,62 @@
//
// Copyright (C) 2021 nihui
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
#ifndef OPENCV_HIGHGUI_HPP
#define OPENCV_HIGHGUI_HPP
#include "opencv2/core.hpp"
enum
{
CV_LOAD_IMAGE_UNCHANGED = -1,
CV_LOAD_IMAGE_GRAYSCALE = 0,
CV_LOAD_IMAGE_COLOR = 1,
};
enum
{
CV_IMWRITE_JPEG_QUALITY = 1
};
namespace cv {
enum ImreadModes
{
IMREAD_UNCHANGED = -1,
IMREAD_GRAYSCALE = 0,
IMREAD_COLOR = 1
};
enum ImwriteFlags
{
IMWRITE_JPEG_QUALITY = 1
};
CV_EXPORTS_W Mat imread(const String& filename, int flags = IMREAD_COLOR);
CV_EXPORTS_W bool imwrite(const String& filename, InputArray img, const std::vector<int>& params = std::vector<int>());
CV_EXPORTS_W Mat imdecode(InputArray buf, int flags);
CV_EXPORTS_W bool imencode(const String& ext, InputArray img, CV_OUT std::vector<uchar>& buf, const std::vector<int>& params = std::vector<int>());
CV_EXPORTS_W void imshow(const String& winname, InputArray mat);
CV_EXPORTS_W int waitKey(int delay = 0);
} // namespace cv
#endif // OPENCV_HIGHGUI_HPP

View File

@ -0,0 +1,612 @@
/*M///////////////////////////////////////////////////////////////////////////////////////
//
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
//
// By downloading, copying, installing or using the software you agree to this license.
// If you do not agree to this license, do not download, install,
// copy or use the software.
//
//
// License Agreement
// For Open Source Computer Vision Library
//
// Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
// Copyright (C) 2009, Willow Garage Inc., all rights reserved.
// Third party copyrights are property of their respective owners.
//
// Redistribution and use in source and binary forms, with or without modification,
// are permitted provided that the following conditions are met:
//
// * Redistribution's of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
//
// * Redistribution's in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
//
// * The name of the copyright holders may not be used to endorse or promote products
// derived from this software without specific prior written permission.
//
// This software is provided by the copyright holders and contributors "as is" and
// any express or implied warranties, including, but not limited to, the implied
// warranties of merchantability and fitness for a particular purpose are disclaimed.
// In no event shall the Intel Corporation or contributors be liable for any direct,
// indirect, incidental, special, exemplary, or consequential damages
// (including, but not limited to, procurement of substitute goods or services;
// loss of use, data, or profits; or business interruption) however caused
// and on any theory of liability, whether in contract, strict liability,
// or tort (including negligence or otherwise) arising in any way out of
// the use of this software, even if advised of the possibility of such damage.
//
//M*/
#include "exif.hpp"
namespace {
class ExifParsingError {
};
}
namespace cv
{
ExifEntry_t::ExifEntry_t() :
field_float(0), field_double(0), field_u32(0), field_s32(0),
tag(INVALID_TAG), field_u16(0), field_s16(0), field_u8(0), field_s8(0)
{
}
/**
* @brief ExifReader constructor
*/
ExifReader::ExifReader(std::istream& stream) : m_stream(stream), m_format(NONE)
{
}
/**
* @brief ExifReader destructor
*/
ExifReader::~ExifReader()
{
}
/**
* @brief Parsing the file and prepare (internally) exif directory structure
* @return true if parsing was successful and exif information exists in JpegReader object
* false in case of unsuccessful parsing
*/
bool ExifReader::parse()
{
m_exif = getExif();
if( !m_exif.empty() )
{
return true;
}
return false;
}
/**
* @brief Get tag value by tag number
*
* @param [in] tag The tag number
*
* @return ExifEntru_t structure. Caller has to know what tag it calls in order to extract proper field from the structure ExifEntry_t
*
*/
ExifEntry_t ExifReader::getTag(const ExifTagName tag)
{
ExifEntry_t entry;
std::map<int, ExifEntry_t>::iterator it = m_exif.find(tag);
if( it != m_exif.end() )
{
entry = it->second;
}
return entry;
}
/**
* @brief Get exif directory structure contained in file (if any)
* This is internal function and is not exposed to client
*
* @return Map where key is tag number and value is ExifEntry_t structure
*/
std::map<int, ExifEntry_t > ExifReader::getExif()
{
const std::streamsize markerSize = 2;
const std::streamsize offsetToTiffHeader = 6; //bytes from Exif size field to the first TIFF header
unsigned char appMarker[markerSize];
m_exif.erase( m_exif.begin(), m_exif.end() );
std::streamsize count;
bool exifFound = false, stopSearch = false;
while( ( !m_stream.eof() ) && !exifFound && !stopSearch )
{
m_stream.read( reinterpret_cast<char*>(appMarker), markerSize );
count = m_stream.gcount();
if( count < markerSize )
{
break;
}
unsigned char marker = appMarker[1];
size_t bytesToSkip;
size_t exifSize;
switch( marker )
{
//For all the markers just skip bytes in file pointed by followed two bytes (field size)
case SOF0: case SOF2: case DHT: case DQT: case DRI: case SOS:
case RST0: case RST1: case RST2: case RST3: case RST4: case RST5: case RST6: case RST7:
case APP0: case APP2: case APP3: case APP4: case APP5: case APP6: case APP7: case APP8:
case APP9: case APP10: case APP11: case APP12: case APP13: case APP14: case APP15:
case COM:
bytesToSkip = getFieldSize();
if (bytesToSkip < markerSize) {
return std::map<int, ExifEntry_t >();
}
m_stream.seekg( static_cast<long>( bytesToSkip - markerSize ), m_stream.cur );
if ( m_stream.fail() ) {
return std::map<int, ExifEntry_t >();
}
break;
//SOI and EOI don't have the size field after the marker
case SOI: case EOI:
break;
case APP1: //actual Exif Marker
exifSize = getFieldSize();
if (exifSize <= offsetToTiffHeader) {
return std::map<int, ExifEntry_t >();
}
m_data.resize( exifSize - offsetToTiffHeader );
m_stream.seekg( static_cast<long>( offsetToTiffHeader ), m_stream.cur );
if ( m_stream.fail() ) {
return std::map<int, ExifEntry_t >();
}
m_stream.read( reinterpret_cast<char*>(&m_data[0]), exifSize - offsetToTiffHeader );
exifFound = true;
break;
default: //No other markers are expected according to standard. May be a signal of error
stopSearch = true;
break;
}
}
if( !exifFound )
{
return m_exif;
}
parseExif();
return m_exif;
}
/**
* @brief Get the size of exif field (required to properly ready whole exif from the file)
* This is internal function and is not exposed to client
*
* @return size of exif field in the file
*/
size_t ExifReader::getFieldSize ()
{
unsigned char fieldSize[2];
m_stream.read( reinterpret_cast<char*>(fieldSize), 2 );
std::streamsize count = m_stream.gcount();
if (count < 2)
{
return 0;
}
return ( fieldSize[0] << 8 ) + fieldSize[1];
}
/**
* @brief Filling m_exif member with exif directory elements
* This is internal function and is not exposed to client
*
* @return The function doesn't return any value. In case of unsuccessful parsing
* the m_exif member is not filled up
*/
void ExifReader::parseExif()
{
m_format = getFormat();
if( !checkTagMark() )
{
return;
}
uint32_t offset = getStartOffset();
size_t numEntry = getNumDirEntry( offset );
offset += 2; //go to start of tag fields
for( size_t entry = 0; entry < numEntry; entry++ )
{
ExifEntry_t exifEntry = parseExifEntry( offset );
m_exif.insert( std::make_pair( exifEntry.tag, exifEntry ) );
offset += tiffFieldSize;
}
}
/**
* @brief Get endianness of exif information
* This is internal function and is not exposed to client
*
* @return INTEL, MOTO or NONE
*/
Endianess_t ExifReader::getFormat() const
{
if (m_data.size() < 1)
return NONE;
if( m_data.size() > 1 && m_data[0] != m_data[1] )
{
return NONE;
}
if( m_data[0] == 'I' )
{
return INTEL;
}
if( m_data[0] == 'M' )
{
return MOTO;
}
return NONE;
}
/**
* @brief Checking whether Tag Mark (0x002A) correspond to one contained in the Jpeg file
* This is internal function and is not exposed to client
*
* @return true if tag mark equals 0x002A, false otherwise
*/
bool ExifReader::checkTagMark() const
{
uint16_t tagMark = getU16( 2 );
if( tagMark != tagMarkRequired )
{
return false;
}
return true;
}
/**
* @brief The utility function for extracting actual offset exif IFD0 info is started from
* This is internal function and is not exposed to client
*
* @return offset of IFD0 field
*/
uint32_t ExifReader::getStartOffset() const
{
return getU32( 4 );
}
/**
* @brief Get the number of Directory Entries in Jpeg file
*
* @return The number of directory entries
*/
size_t ExifReader::getNumDirEntry(const size_t offsetNumDir) const
{
return getU16( offsetNumDir );
}
/**
* @brief Parsing particular entry in exif directory
* This is internal function and is not exposed to client
*
* Entries are divided into 12-bytes blocks each
* Each block corresponds the following structure:
*
* +------+-------------+-------------------+------------------------+
* | Type | Data format | Num of components | Data or offset to data |
* +======+=============+===================+========================+
* | TTTT | ffff | NNNNNNNN | DDDDDDDD |
* +------+-------------+-------------------+------------------------+
*
* Details can be found here: http://www.media.mit.edu/pia/Research/deepview/exif.html
*
* @param [in] offset Offset to entry in bytes inside raw exif data
* @return ExifEntry_t structure which corresponds to particular entry
*
*/
ExifEntry_t ExifReader::parseExifEntry(const size_t offset)
{
ExifEntry_t entry;
uint16_t tagNum = getExifTag( offset );
entry.tag = tagNum;
switch( tagNum )
{
case IMAGE_DESCRIPTION:
entry.field_str = getString( offset );
break;
case MAKE:
entry.field_str = getString( offset );
break;
case MODEL:
entry.field_str = getString( offset );
break;
case ORIENTATION:
entry.field_u16 = getOrientation( offset );
break;
case XRESOLUTION:
entry.field_u_rational = getResolution( offset );
break;
case YRESOLUTION:
entry.field_u_rational = getResolution( offset );
break;
case RESOLUTION_UNIT:
entry.field_u16 = getResolutionUnit( offset );
break;
case SOFTWARE:
entry.field_str = getString( offset );
break;
case DATE_TIME:
entry.field_str = getString( offset );
break;
case WHITE_POINT:
entry.field_u_rational = getWhitePoint( offset );
break;
case PRIMARY_CHROMATICIES:
entry.field_u_rational = getPrimaryChromaticies( offset );
break;
case Y_CB_CR_COEFFICIENTS:
entry.field_u_rational = getYCbCrCoeffs( offset );
break;
case Y_CB_CR_POSITIONING:
entry.field_u16 = getYCbCrPos( offset );
break;
case REFERENCE_BLACK_WHITE:
entry.field_u_rational = getRefBW( offset );
break;
case COPYRIGHT:
entry.field_str = getString( offset );
break;
case EXIF_OFFSET:
break;
default:
entry.tag = INVALID_TAG;
break;
}
return entry;
}
/**
* @brief Get tag number from raw exif data
* This is internal function and is not exposed to client
* @param [in] offset Offset to entry in bytes inside raw exif data
* @return tag number
*/
uint16_t ExifReader::getExifTag(const size_t offset) const
{
return getU16( offset );
}
/**
* @brief Get string information from raw exif data
* This is internal function and is not exposed to client
* @param [in] offset Offset to entry in bytes inside raw exif data
* @return string value
*/
std::string ExifReader::getString(const size_t offset) const
{
size_t size = getU32( offset + 4 );
size_t dataOffset = 8; // position of data in the field
if( size > maxDataSize )
{
dataOffset = getU32( offset + 8 );
}
if (dataOffset > m_data.size() || dataOffset + size > m_data.size()) {
return std::string();
}
std::vector<uint8_t>::const_iterator it = m_data.begin() + dataOffset;
std::string result( it, it + size ); //copy vector content into result
return result;
}
/**
* @brief Get unsigned short data from raw exif data
* This is internal function and is not exposed to client
* @param [in] offset Offset to entry in bytes inside raw exif data
* @return Unsigned short data
*/
uint16_t ExifReader::getU16(const size_t offset) const
{
if (offset + 1 >= m_data.size())
return 0;
if( m_format == INTEL )
{
return m_data[offset] + ( m_data[offset + 1] << 8 );
}
return ( m_data[offset] << 8 ) + m_data[offset + 1];
}
/**
* @brief Get unsigned 32-bit data from raw exif data
* This is internal function and is not exposed to client
* @param [in] offset Offset to entry in bytes inside raw exif data
* @return Unsigned 32-bit data
*/
uint32_t ExifReader::getU32(const size_t offset) const
{
if (offset + 3 >= m_data.size())
return 0;
if( m_format == INTEL )
{
return m_data[offset] +
( m_data[offset + 1] << 8 ) +
( m_data[offset + 2] << 16 ) +
( m_data[offset + 3] << 24 );
}
return ( m_data[offset] << 24 ) +
( m_data[offset + 1] << 16 ) +
( m_data[offset + 2] << 8 ) +
m_data[offset + 3];
}
/**
* @brief Get unsigned rational data from raw exif data
* This is internal function and is not exposed to client
* @param [in] offset Offset to entry in bytes inside raw exif data
* @return Unsigned rational data
*
* "rational" means a fractional value, it contains 2 signed/unsigned long integer value,
* and the first represents the numerator, the second, the denominator.
*/
u_rational_t ExifReader::getURational(const size_t offset) const
{
uint32_t numerator = getU32( offset );
uint32_t denominator = getU32( offset + 4 );
return std::make_pair( numerator, denominator );
}
/**
* @brief Get orientation information from raw exif data
* This is internal function and is not exposed to client
* @param [in] offset Offset to entry in bytes inside raw exif data
* @return orientation number
*/
uint16_t ExifReader::getOrientation(const size_t offset) const
{
return getU16( offset + 8 );
}
/**
* @brief Get resolution information from raw exif data
* This is internal function and is not exposed to client
* @param [in] offset Offset to entry in bytes inside raw exif data
* @return resolution value
*/
std::vector<u_rational_t> ExifReader::getResolution(const size_t offset) const
{
std::vector<u_rational_t> result;
uint32_t rationalOffset = getU32( offset + 8 );
result.push_back( getURational( rationalOffset ) );
return result;
}
/**
* @brief Get resolution unit from raw exif data
* This is internal function and is not exposed to client
* @param [in] offset Offset to entry in bytes inside raw exif data
* @return resolution unit value
*/
uint16_t ExifReader::getResolutionUnit(const size_t offset) const
{
return getU16( offset + 8 );
}
/**
* @brief Get White Point information from raw exif data
* This is internal function and is not exposed to client
* @param [in] offset Offset to entry in bytes inside raw exif data
* @return White Point value
*
* If the image uses CIE Standard Illumination D65(known as international
* standard of 'daylight'), the values are '3127/10000,3290/10000'.
*/
std::vector<u_rational_t> ExifReader::getWhitePoint(const size_t offset) const
{
std::vector<u_rational_t> result;
uint32_t rationalOffset = getU32( offset + 8 );
result.push_back( getURational( rationalOffset ) );
result.push_back( getURational( rationalOffset + 8 ) );
return result;
}
/**
* @brief Get Primary Chromaticies information from raw exif data
* This is internal function and is not exposed to client
* @param [in] offset Offset to entry in bytes inside raw exif data
* @return vector with primary chromaticies values
*
*/
std::vector<u_rational_t> ExifReader::getPrimaryChromaticies(const size_t offset) const
{
std::vector<u_rational_t> result;
uint32_t rationalOffset = getU32( offset + 8 );
for( size_t i = 0; i < primaryChromaticiesComponents; i++ )
{
result.push_back( getURational( rationalOffset ) );
rationalOffset += 8;
}
return result;
}
/**
* @brief Get YCbCr Coefficients information from raw exif data
* This is internal function and is not exposed to client
* @param [in] offset Offset to entry in bytes inside raw exif data
* @return vector with YCbCr coefficients values
*
*/
std::vector<u_rational_t> ExifReader::getYCbCrCoeffs(const size_t offset) const
{
std::vector<u_rational_t> result;
uint32_t rationalOffset = getU32( offset + 8 );
for( size_t i = 0; i < ycbcrCoeffs; i++ )
{
result.push_back( getURational( rationalOffset ) );
rationalOffset += 8;
}
return result;
}
/**
* @brief Get YCbCr Positioning information from raw exif data
* This is internal function and is not exposed to client
* @param [in] offset Offset to entry in bytes inside raw exif data
* @return vector with YCbCr positioning value
*
*/
uint16_t ExifReader::getYCbCrPos(const size_t offset) const
{
return getU16( offset + 8 );
}
/**
* @brief Get Reference Black&White point information from raw exif data
* This is internal function and is not exposed to client
* @param [in] offset Offset to entry in bytes inside raw exif data
* @return vector with reference BW points
*
* In case of YCbCr format, first 2 show black/white of Y, next 2 are Cb,
* last 2 are Cr. In case of RGB format, first 2 show black/white of R,
* next 2 are G, last 2 are B.
*
*/
std::vector<u_rational_t> ExifReader::getRefBW(const size_t offset) const
{
const size_t rationalFieldSize = 8;
std::vector<u_rational_t> result;
uint32_t rationalOffset = getU32( offset + rationalFieldSize );
for( size_t i = 0; i < refBWComponents; i++ )
{
result.push_back( getURational( rationalOffset ) );
rationalOffset += rationalFieldSize;
}
return result;
}
} //namespace cv

View File

@ -0,0 +1,251 @@
/*M///////////////////////////////////////////////////////////////////////////////////////
//
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
//
// By downloading, copying, installing or using the software you agree to this license.
// If you do not agree to this license, do not download, install,
// copy or use the software.
//
//
// License Agreement
// For Open Source Computer Vision Library
//
// Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
// Copyright (C) 2009, Willow Garage Inc., all rights reserved.
// Third party copyrights are property of their respective owners.
//
// Redistribution and use in source and binary forms, with or without modification,
// are permitted provided that the following conditions are met:
//
// * Redistribution's of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
//
// * Redistribution's in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
//
// * The name of the copyright holders may not be used to endorse or promote products
// derived from this software without specific prior written permission.
//
// This software is provided by the copyright holders and contributors "as is" and
// any express or implied warranties, including, but not limited to, the implied
// warranties of merchantability and fitness for a particular purpose are disclaimed.
// In no event shall the Intel Corporation or contributors be liable for any direct,
// indirect, incidental, special, exemplary, or consequential damages
// (including, but not limited to, procurement of substitute goods or services;
// loss of use, data, or profits; or business interruption) however caused
// and on any theory of liability, whether in contract, strict liability,
// or tort (including negligence or otherwise) arising in any way out of
// the use of this software, even if advised of the possibility of such damage.
//
//M*/
#ifndef _OPENCV_EXIF_HPP_
#define _OPENCV_EXIF_HPP_
#include <stdint.h>
#include <cstdio>
#include <map>
#include <utility>
#include <algorithm>
#include <string>
#include <vector>
#include <iostream>
namespace cv
{
/**
* @brief Jpeg markers that can encounter in Jpeg file
*/
enum AppMarkerTypes
{
SOI = 0xD8, SOF0 = 0xC0, SOF2 = 0xC2, DHT = 0xC4,
DQT = 0xDB, DRI = 0xDD, SOS = 0xDA,
RST0 = 0xD0, RST1 = 0xD1, RST2 = 0xD2, RST3 = 0xD3,
RST4 = 0xD4, RST5 = 0xD5, RST6 = 0xD6, RST7 = 0xD7,
APP0 = 0xE0, APP1 = 0xE1, APP2 = 0xE2, APP3 = 0xE3,
APP4 = 0xE4, APP5 = 0xE5, APP6 = 0xE6, APP7 = 0xE7,
APP8 = 0xE8, APP9 = 0xE9, APP10 = 0xEA, APP11 = 0xEB,
APP12 = 0xEC, APP13 = 0xED, APP14 = 0xEE, APP15 = 0xEF,
COM = 0xFE, EOI = 0xD9
};
/**
* @brief Base Exif tags used by IFD0 (main image)
*/
enum ExifTagName
{
IMAGE_DESCRIPTION = 0x010E, ///< Image Description: ASCII string
MAKE = 0x010F, ///< Description of manufacturer: ASCII string
MODEL = 0x0110, ///< Description of camera model: ASCII string
ORIENTATION = 0x0112, ///< Orientation of the image: unsigned short
XRESOLUTION = 0x011A, ///< Resolution of the image across X axis: unsigned rational
YRESOLUTION = 0x011B, ///< Resolution of the image across Y axis: unsigned rational
RESOLUTION_UNIT = 0x0128, ///< Resolution units. '1' no-unit, '2' inch, '3' centimeter
SOFTWARE = 0x0131, ///< Shows firmware(internal software of digicam) version number
DATE_TIME = 0x0132, ///< Date/Time of image was last modified
WHITE_POINT = 0x013E, ///< Chromaticity of white point of the image
PRIMARY_CHROMATICIES = 0x013F, ///< Chromaticity of the primaries of the image
Y_CB_CR_COEFFICIENTS = 0x0211, ///< constant to translate an image from YCbCr to RGB format
Y_CB_CR_POSITIONING = 0x0213, ///< Chroma sample point of subsampling pixel array
REFERENCE_BLACK_WHITE = 0x0214, ///< Reference value of black point/white point
COPYRIGHT = 0x8298, ///< Copyright information
EXIF_OFFSET = 0x8769, ///< Offset to Exif Sub IFD
INVALID_TAG = 0xFFFF ///< Shows that the tag was not recognized
};
enum Endianess_t
{
INTEL = 0x49,
MOTO = 0x4D,
NONE = 0x00
};
typedef std::pair<uint32_t, uint32_t> u_rational_t;
/**
* @brief Entry which contains possible values for different exif tags
*/
struct ExifEntry_t
{
ExifEntry_t();
std::vector<u_rational_t> field_u_rational; ///< vector of rational fields
std::string field_str; ///< any kind of textual information
float field_float; ///< Currently is not used
double field_double; ///< Currently is not used
uint32_t field_u32; ///< Unsigned 32-bit value
int32_t field_s32; ///< Signed 32-bit value
uint16_t tag; ///< Tag number
uint16_t field_u16; ///< Unsigned 16-bit value
int16_t field_s16; ///< Signed 16-bit value
uint8_t field_u8; ///< Unsigned 8-bit value
int8_t field_s8; ///< Signed 8-bit value
};
/**
* @brief Picture orientation which may be taken from EXIF
* Orientation usually matters when the picture is taken by
* smartphone or other camera with orientation sensor support
* Corresponds to EXIF 2.3 Specification
*/
enum ImageOrientation
{
IMAGE_ORIENTATION_TL = 1, ///< Horizontal (normal)
IMAGE_ORIENTATION_TR = 2, ///< Mirrored horizontal
IMAGE_ORIENTATION_BR = 3, ///< Rotate 180
IMAGE_ORIENTATION_BL = 4, ///< Mirrored vertical
IMAGE_ORIENTATION_LT = 5, ///< Mirrored horizontal & rotate 270 CW
IMAGE_ORIENTATION_RT = 6, ///< Rotate 90 CW
IMAGE_ORIENTATION_RB = 7, ///< Mirrored horizontal & rotate 90 CW
IMAGE_ORIENTATION_LB = 8 ///< Rotate 270 CW
};
/**
* @brief Reading exif information from Jpeg file
*
* Usage example for getting the orientation of the image:
*
* @code
* std::ifstream stream(filename,std::ios_base::in | std::ios_base::binary);
* ExifReader reader(stream);
* if( reader.parse() )
* {
* int orientation = reader.getTag(Orientation).field_u16;
* }
* @endcode
*
*/
class ExifReader
{
public:
/**
* @brief ExifReader constructor. Constructs an object of exif reader
*
* @param [in]stream An istream to look for EXIF bytes from
*/
explicit ExifReader( std::istream& stream );
~ExifReader();
/**
* @brief Parse the file with exif info
*
* @return true if parsing was successful and exif information exists in JpegReader object
*/
bool parse();
/**
* @brief Get tag info by tag number
*
* @param [in] tag The tag number
* @return ExifEntru_t structure. Caller has to know what tag it calls in order to extract proper field from the structure ExifEntry_t
*/
ExifEntry_t getTag( const ExifTagName tag );
private:
std::istream& m_stream;
std::vector<unsigned char> m_data;
std::map<int, ExifEntry_t > m_exif;
Endianess_t m_format;
void parseExif();
bool checkTagMark() const;
size_t getFieldSize ();
size_t getNumDirEntry( const size_t offsetNumDir ) const;
uint32_t getStartOffset() const;
uint16_t getExifTag( const size_t offset ) const;
uint16_t getU16( const size_t offset ) const;
uint32_t getU32( const size_t offset ) const;
uint16_t getOrientation( const size_t offset ) const;
uint16_t getResolutionUnit( const size_t offset ) const;
uint16_t getYCbCrPos( const size_t offset ) const;
Endianess_t getFormat() const;
ExifEntry_t parseExifEntry( const size_t offset );
u_rational_t getURational( const size_t offset ) const;
std::map<int, ExifEntry_t > getExif();
std::string getString( const size_t offset ) const;
std::vector<u_rational_t> getResolution( const size_t offset ) const;
std::vector<u_rational_t> getWhitePoint( const size_t offset ) const;
std::vector<u_rational_t> getPrimaryChromaticies( const size_t offset ) const;
std::vector<u_rational_t> getYCbCrCoeffs( const size_t offset ) const;
std::vector<u_rational_t> getRefBW( const size_t offset ) const;
private:
static const uint16_t tagMarkRequired = 0x2A;
//max size of data in tag.
//'DDDDDDDD' contains the value of that Tag. If its size is over 4bytes,
//'DDDDDDDD' contains the offset to data stored address.
static const size_t maxDataSize = 4;
//bytes per tag field
static const size_t tiffFieldSize = 12;
//number of primary chromaticies components
static const size_t primaryChromaticiesComponents = 6;
//number of YCbCr coefficients in field
static const size_t ycbcrCoeffs = 3;
//number of Reference Black&White components
static const size_t refBWComponents = 6;
};
}
#endif /* _OPENCV_EXIF_HPP_ */

View File

@ -0,0 +1,434 @@
//
// Copyright (C) 2021 nihui
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
#include <opencv2/core.hpp>
#include <opencv2/highgui.hpp>
#include <opencv2/imgproc.hpp>
#include <string.h>
#include <fstream>
#include <sstream>
#include "exif.hpp"
#define STB_IMAGE_IMPLEMENTATION
#define STBI_NO_THREAD_LOCALS
#define STBI_ONLY_JPEG
#define STBI_ONLY_PNG
#define STBI_ONLY_BMP
#define STBI_ONLY_PNM
#include "stb_image.h"
#define STB_IMAGE_WRITE_IMPLEMENTATION
#include "stb_image_write.h"
namespace cv {
//
// 1 2 3 4 5 6 7 8
//
// 888888 888888 88 88 8888888888 88 88 8888888888
// 88 88 88 88 88 88 88 88 88 88 88 88
// 8888 8888 8888 8888 88 8888888888 8888888888 88
// 88 88 88 88
// 88 88 888888 888888
//
// ref http://sylvana.net/jpegcrop/exif_orientation.html
static void rotate_by_orientation(const Mat& src, Mat& dst, int orientation)
{
if (orientation == 1)
{
dst = src;
}
if (orientation == 2)
{
cv::flip(src, dst, 1);
}
if (orientation == 3)
{
cv::flip(src, dst, -1);
}
if (orientation == 4)
{
cv::flip(src, dst, 0);
}
if (orientation == 5)
{
cv::transpose(src, dst);
}
if (orientation == 6)
{
Mat tmp;
cv::flip(src, tmp, 0);
cv::transpose(tmp, dst);
}
if (orientation == 7)
{
Mat tmp;
cv::flip(src, tmp, -1);
cv::transpose(tmp, dst);
}
if (orientation == 8)
{
Mat tmp;
cv::flip(src, tmp, 1);
cv::transpose(tmp, dst);
}
}
Mat imread(const String& filename, int flags)
{
int desired_channels = 0;
if (flags == IMREAD_UNCHANGED)
{
desired_channels = 0;
}
else if (flags == IMREAD_GRAYSCALE)
{
desired_channels = 1;
}
else if (flags == IMREAD_COLOR)
{
desired_channels = 3;
}
else
{
// unknown flags
return Mat();
}
int w;
int h;
int c;
unsigned char* pixeldata = stbi_load(filename.c_str(), &w, &h, &c, desired_channels);
if (!pixeldata)
{
// load failed
return Mat();
}
if (desired_channels)
{
c = desired_channels;
}
// copy pixeldata to Mat
Mat img;
if (c == 1)
{
img.create(h, w, CV_8UC1);
}
else if (c == 3)
{
img.create(h, w, CV_8UC3);
}
else if (c == 4)
{
img.create(h, w, CV_8UC4);
}
else
{
// unexpected channels
stbi_image_free(pixeldata);
return Mat();
}
memcpy(img.data, pixeldata, w * h * c);
stbi_image_free(pixeldata);
// resolve exif orientation
{
std::ifstream ifs;
ifs.open(filename.c_str(), std::ifstream::in);
if (ifs.good())
{
ExifReader exif_reader(ifs);
if (exif_reader.parse())
{
ExifEntry_t e = exif_reader.getTag(ORIENTATION);
int orientation = e.field_u16;
if (orientation >= 1 && orientation <= 8)
rotate_by_orientation(img, img, orientation);
}
}
ifs.close();
}
// rgb to bgr
if (c == 3)
{
cvtColor(img, img, COLOR_RGB2BGR);
}
if (c == 4)
{
cvtColor(img, img, COLOR_RGBA2BGRA);
}
return img;
}
bool imwrite(const String& filename, InputArray _img, const std::vector<int>& params)
{
const char* _ext = strrchr(filename.c_str(), '.');
if (!_ext)
{
// missing extension
return false;
}
String ext = _ext;
Mat img = _img.getMat();
// bgr to rgb
int c = 0;
if (img.type() == CV_8UC1)
{
c = 1;
}
else if (img.type() == CV_8UC3)
{
c = 3;
cvtColor(img, img, COLOR_BGR2RGB);
}
else if (img.type() == CV_8UC4)
{
c = 4;
cvtColor(img, img, COLOR_BGRA2RGBA);
}
else
{
// unexpected image channels
return false;
}
if (!img.isContinuous())
{
img = img.clone();
}
bool success = false;
if (ext == ".jpg" || ext == ".jpeg" || ext == ".JPG" || ext == ".JPEG")
{
int quality = 95;
for (size_t i = 0; i < params.size(); i += 2)
{
if (params[i] == IMWRITE_JPEG_QUALITY)
{
quality = params[i + 1];
break;
}
}
success = stbi_write_jpg(filename.c_str(), img.cols, img.rows, c, img.data, quality);
}
else if (ext == ".png" || ext == ".PNG")
{
success = stbi_write_png(filename.c_str(), img.cols, img.rows, c, img.data, 0);
}
else if (ext == ".bmp" || ext == ".BMP")
{
success = stbi_write_bmp(filename.c_str(), img.cols, img.rows, c, img.data);
}
else
{
// unknown extension type
return false;
}
return success;
}
Mat imdecode(InputArray _buf, int flags)
{
int desired_channels = 0;
if (flags == IMREAD_UNCHANGED)
{
desired_channels = 0;
}
else if (flags == IMREAD_GRAYSCALE)
{
desired_channels = 1;
}
else if (flags == IMREAD_COLOR)
{
desired_channels = 3;
}
else
{
// unknown flags
return Mat();
}
Mat buf = _buf.getMat();
if (!buf.isContinuous())
{
buf = buf.clone();
}
size_t buf_size = buf.cols * buf.rows * buf.elemSize();
int w;
int h;
int c;
unsigned char* pixeldata = stbi_load_from_memory((const unsigned char*)buf.data, buf_size, &w, &h, &c, desired_channels);
if (!pixeldata)
{
// load failed
return Mat();
}
if (desired_channels)
{
c = desired_channels;
}
// copy pixeldata to Mat
Mat img;
if (c == 1)
{
img.create(h, w, CV_8UC1);
}
else if (c == 3)
{
img.create(h, w, CV_8UC3);
}
else if (c == 4)
{
img.create(h, w, CV_8UC4);
}
else
{
// unexpected channels
stbi_image_free(pixeldata);
return Mat();
}
memcpy(img.data, pixeldata, w * h * c);
stbi_image_free(pixeldata);
// resolve exif orientation
{
std::string s((const char*)buf.data, buf_size);
std::istringstream iss(s);
ExifReader exif_reader(iss);
if (exif_reader.parse())
{
ExifEntry_t e = exif_reader.getTag(ORIENTATION);
int orientation = e.field_u16;
if (orientation >= 1 && orientation <= 8)
rotate_by_orientation(img, img, orientation);
}
}
// rgb to bgr
if (c == 3)
{
cvtColor(img, img, COLOR_RGB2BGR);
}
if (c == 4)
{
cvtColor(img, img, COLOR_RGBA2BGRA);
}
return img;
}
static void imencode_write_func(void *context, void *data, int size)
{
std::vector<uchar>* buf = (std::vector<uchar>*)context;
buf->insert(buf->end(), (uchar*)data, (uchar*)data + size);
}
bool imencode(const String& ext, InputArray _img, std::vector<uchar>& buf, const std::vector<int>& params)
{
Mat img = _img.getMat();
// bgr to rgb
int c = 0;
if (img.type() == CV_8UC1)
{
c = 1;
}
else if (img.type() == CV_8UC3)
{
c = 3;
cvtColor(img, img, COLOR_BGR2RGB);
}
else if (img.type() == CV_8UC4)
{
c = 4;
cvtColor(img, img, COLOR_BGRA2RGBA);
}
else
{
// unexpected image channels
return false;
}
if (!img.isContinuous())
{
img = img.clone();
}
bool success = false;
if (ext == ".jpg" || ext == ".jpeg" || ext == ".JPG" || ext == ".JPEG")
{
int quality = 95;
for (size_t i = 0; i < params.size(); i += 2)
{
if (params[i] == IMWRITE_JPEG_QUALITY)
{
quality = params[i + 1];
break;
}
}
success = stbi_write_jpg_to_func(imencode_write_func, (void*)&buf, img.cols, img.rows, c, img.data, quality);
}
else if (ext == ".png" || ext == ".PNG")
{
success = stbi_write_png_to_func(imencode_write_func, (void*)&buf, img.cols, img.rows, c, img.data, 0);
}
else if (ext == ".bmp" || ext == ".BMP")
{
success = stbi_write_bmp_to_func(imencode_write_func, (void*)&buf, img.cols, img.rows, c, img.data);
}
else
{
// unknown extension type
return false;
}
return success;
}
void imshow(const String& winname, InputArray mat)
{
fprintf(stderr, "imshow save image to %s.png", winname.c_str());
imwrite(winname + ".png", mat);
}
int waitKey(int delay)
{
(void)delay;
fprintf(stderr, "waitKey stub");
return -1;
}
} // namespace cv

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,11 @@
diff -Nuarp opencv-2.4.13.7.orig/include/opencv2/opencv.hpp opencv-2.4.13.7/include/opencv2/opencv.hpp
--- opencv-2.4.13.7.orig/include/opencv2/opencv.hpp 2021-03-12 10:34:37.813906930 +0800
+++ opencv-2.4.13.7/include/opencv2/opencv.hpp 2018-07-02 05:41:56.000000000 +0800
@@ -73,7 +73,6 @@
#include "opencv2/ml/ml.hpp"
#endif
#ifdef HAVE_OPENCV_HIGHGUI
-#include "opencv2/highgui/highgui_c.h"
#include "opencv2/highgui/highgui.hpp"
#endif
#ifdef HAVE_OPENCV_CONTRIB

View File

@ -0,0 +1,11 @@
diff -Nuarp opencv-2.4.13.7/cmake/OpenCVCompilerOptions.cmake opencv-2.4.13.7.no-link-stdc++/cmake/OpenCVCompilerOptions.cmake
--- opencv-2.4.13.7/cmake/OpenCVCompilerOptions.cmake 2018-07-02 05:41:56.000000000 +0800
+++ opencv-2.4.13.7.no-link-stdc++/cmake/OpenCVCompilerOptions.cmake 2021-05-11 15:57:17.159970391 +0800
@@ -313,7 +313,6 @@ endif()
# Extra link libs if the user selects building static libs:
if(NOT BUILD_SHARED_LIBS AND ((CMAKE_COMPILER_IS_GNUCXX AND NOT ANDROID) OR QNX))
# Android does not need these settings because they are already set by toolchain file
- set(OPENCV_LINKER_LIBS ${OPENCV_LINKER_LIBS} stdc++)
set(OPENCV_EXTRA_FLAGS "-fPIC ${OPENCV_EXTRA_FLAGS}")
endif()

View File

@ -0,0 +1,80 @@
diff -Nuarp opencv-2.4.13.7.orig/modules/core/src/gpumat.cpp opencv-2.4.13.7/modules/core/src/gpumat.cpp
--- opencv-2.4.13.7.orig/modules/core/src/gpumat.cpp 2018-07-02 05:41:56.000000000 +0800
+++ opencv-2.4.13.7/modules/core/src/gpumat.cpp 2021-05-12 13:05:39.939811441 +0800
@@ -222,40 +222,40 @@ static bool loadCudaSupportLib()
#endif
-static GpuFuncTable* gpuFuncTable()
-{
#ifdef DYNAMIC_CUDA_SUPPORT
- static EmptyFuncTable stub;
- static GpuFuncTable* libFuncTable = loadCudaSupportLib() ? gpuFactory(): (GpuFuncTable*)&stub;
- static GpuFuncTable *funcTable = libFuncTable ? libFuncTable : (GpuFuncTable*)&stub;
+static EmptyFuncTable g_GpuFuncTable_stub;
+static GpuFuncTable* g_GpuFuncTable_libFuncTable = loadCudaSupportLib() ? gpuFactory(): (GpuFuncTable*)&g_GpuFuncTable_stub;
+static GpuFuncTable *g_GpuFuncTable_funcTable = g_GpuFuncTable_libFuncTable ? g_GpuFuncTable_libFuncTable : (GpuFuncTable*)&g_GpuFuncTable_stub;
#else
# ifdef USE_CUDA
- static CudaFuncTable impl;
- static GpuFuncTable* funcTable = &impl;
+static CudaFuncTable g_GpuFuncTable_impl;
+static GpuFuncTable* g_GpuFuncTable_funcTable = &g_GpuFuncTable_impl;
#else
- static EmptyFuncTable stub;
- static GpuFuncTable* funcTable = &stub;
+static EmptyFuncTable g_GpuFuncTable_stub;
+static GpuFuncTable* g_GpuFuncTable_funcTable = &g_GpuFuncTable_stub;
#endif
#endif
- return funcTable;
+static GpuFuncTable* gpuFuncTable()
+{
+ return g_GpuFuncTable_funcTable;
}
-static DeviceInfoFuncTable* deviceInfoFuncTable()
-{
#ifdef DYNAMIC_CUDA_SUPPORT
- static EmptyDeviceInfoFuncTable stub;
- static DeviceInfoFuncTable* libFuncTable = loadCudaSupportLib() ? deviceInfoFactory(): (DeviceInfoFuncTable*)&stub;
- static DeviceInfoFuncTable* funcTable = libFuncTable ? libFuncTable : (DeviceInfoFuncTable*)&stub;
+static EmptyDeviceInfoFuncTable g_DeviceInfoFuncTable_stub;
+static DeviceInfoFuncTable* g_DeviceInfoFuncTable_libFuncTable = loadCudaSupportLib() ? deviceInfoFactory(): (DeviceInfoFuncTable*)&g_DeviceInfoFuncTable_stub;
+static DeviceInfoFuncTable* g_DeviceInfoFuncTable_funcTable = g_DeviceInfoFuncTable_libFuncTable ? g_DeviceInfoFuncTable_libFuncTable : (DeviceInfoFuncTable*)&g_DeviceInfoFuncTable_stub;
#else
# ifdef USE_CUDA
- static CudaDeviceInfoFuncTable impl;
- static DeviceInfoFuncTable* funcTable = &impl;
+static CudaDeviceInfoFuncTable g_DeviceInfoFuncTable_impl;
+static DeviceInfoFuncTable* g_DeviceInfoFuncTable_funcTable = &g_DeviceInfoFuncTable_impl;
#else
- static EmptyDeviceInfoFuncTable stub;
- static DeviceInfoFuncTable* funcTable = &stub;
+static EmptyDeviceInfoFuncTable g_DeviceInfoFuncTable_stub;
+static DeviceInfoFuncTable* g_DeviceInfoFuncTable_funcTable = &g_DeviceInfoFuncTable_stub;
#endif
#endif
- return funcTable;
+static DeviceInfoFuncTable* deviceInfoFuncTable()
+{
+ return g_DeviceInfoFuncTable_funcTable;
}
diff -Nuarp opencv-2.4.13.7.orig/modules/core/src/matop.cpp opencv-2.4.13.7/modules/core/src/matop.cpp
--- opencv-2.4.13.7.orig/modules/core/src/matop.cpp 2018-07-02 05:41:56.000000000 +0800
+++ opencv-2.4.13.7/modules/core/src/matop.cpp 2021-05-12 14:09:01.821745993 +0800
@@ -203,10 +203,10 @@ public:
static void makeExpr(MatExpr& res, int method, int ndims, const int* sizes, int type, double alpha=1);
};
+static MatOp_Initializer g_MatOp_initializer;
static MatOp_Initializer* getGlobalMatOpInitializer()
{
- static MatOp_Initializer initializer;
- return &initializer;
+ return &g_MatOp_initializer;
}
static inline bool isIdentity(const MatExpr& e) { return e.op == &g_MatOp_Identity; }

View File

@ -0,0 +1,144 @@
diff -Nuarp opencv-2.4.13.7/modules/core/src/glob.cpp opencv-2.4.13.7.nortti/modules/core/src/glob.cpp
--- opencv-2.4.13.7/modules/core/src/glob.cpp 2018-07-02 05:41:56.000000000 +0800
+++ opencv-2.4.13.7.nortti/modules/core/src/glob.cpp 2021-01-08 23:24:46.371298637 +0800
@@ -225,7 +225,6 @@ static void glob_rec(const cv::String& d
if ((dir = opendir (directory.c_str())) != 0)
{
/* find all the files and directories within directory */
- try
{
while ((ent = readdir (dir)) != 0)
{
@@ -247,11 +246,6 @@ static void glob_rec(const cv::String& d
}
}
}
- catch (...)
- {
- closedir(dir);
- throw;
- }
closedir(dir);
}
else CV_Error(CV_StsObjectNotFound, cv::format("could not open directory: %s", directory.c_str()));
diff -Nuarp opencv-2.4.13.7/modules/core/src/matrix.cpp opencv-2.4.13.7.nortti/modules/core/src/matrix.cpp
--- opencv-2.4.13.7/modules/core/src/matrix.cpp 2018-07-02 05:41:56.000000000 +0800
+++ opencv-2.4.13.7.nortti/modules/core/src/matrix.cpp 2021-01-08 23:24:59.991085589 +0800
@@ -279,7 +279,6 @@ Mat::Mat(const Mat& m, const Range& _row
}
*this = m;
- try
{
if( _rowRange != Range::all() && _rowRange != Range(0,rows) )
{
@@ -300,11 +299,6 @@ Mat::Mat(const Mat& m, const Range& _row
flags |= SUBMATRIX_FLAG;
}
}
- catch(...)
- {
- release();
- throw;
- }
if( rows == 1 )
flags |= CONTINUOUS_FLAG;
diff -Nuarp opencv-2.4.13.7/modules/core/src/persistence.cpp opencv-2.4.13.7.nortti/modules/core/src/persistence.cpp
--- opencv-2.4.13.7/modules/core/src/persistence.cpp 2018-07-02 05:41:56.000000000 +0800
+++ opencv-2.4.13.7.nortti/modules/core/src/persistence.cpp 2021-01-08 23:25:39.470468027 +0800
@@ -2918,18 +2918,12 @@ cvOpenFileStorage( const char* filename,
//mode = cvGetErrMode();
//cvSetErrMode( CV_ErrModeSilent );
- try
{
if( fs->fmt == CV_STORAGE_FORMAT_XML )
icvXMLParse( fs );
else
icvYMLParse( fs );
}
- catch (...)
- {
- cvReleaseFileStorage( &fs );
- throw;
- }
//cvSetErrMode( mode );
// release resources that we do not need anymore
@@ -4285,13 +4279,9 @@ icvReadSeq( CvFileStorage* fs, CvFileNod
flags |= CV_SEQ_FLAG_HOLE;
if( !strstr(flags_str, "untyped") )
{
- try
{
flags |= icvDecodeSimpleFormat(dt);
}
- catch(...)
- {
- }
}
}
diff -Nuarp opencv-2.4.13.7/modules/core/src/system.cpp opencv-2.4.13.7.nortti/modules/core/src/system.cpp
--- opencv-2.4.13.7/modules/core/src/system.cpp 2018-07-02 05:41:56.000000000 +0800
+++ opencv-2.4.13.7.nortti/modules/core/src/system.cpp 2021-01-08 23:25:56.543200966 +0800
@@ -571,8 +571,6 @@ void error( const Exception& exc )
static volatile int* p = 0;
*p = 0;
}
-
- throw exc;
}
CvErrorCallback
@@ -1160,14 +1158,9 @@ public:
TLSDataContainer* k = tlsContainers_[key];
if (!k)
return;
- try
{
k->deleteDataInstance(data);
}
- catch (...)
- {
- CV_DbgAssert(k == NULL); // Debug this!
- }
}
};
diff -Nuarp opencv-2.4.13.7/modules/imgproc/src/contours.cpp opencv-2.4.13.7.nortti/modules/imgproc/src/contours.cpp
--- opencv-2.4.13.7/modules/imgproc/src/contours.cpp 2018-07-02 05:41:56.000000000 +0800
+++ opencv-2.4.13.7.nortti/modules/imgproc/src/contours.cpp 2021-01-08 23:26:22.223799256 +0800
@@ -1681,7 +1681,6 @@ cvFindContours( void* img, CvMemStorag
}
else
{
- try
{
scanner = cvStartFindContours( img, storage, cntHeaderSize, mode, method, offset );
@@ -1692,12 +1691,6 @@ cvFindContours( void* img, CvMemStorag
}
while( contour != 0 );
}
- catch(...)
- {
- if( scanner )
- cvEndFindContours(&scanner);
- throw;
- }
*firstContour = cvEndFindContours( &scanner );
}
diff -Nuarp opencv-2.4.13.7/modules/photo/src/arrays.hpp opencv-2.4.13.7.nortti/modules/photo/src/arrays.hpp
--- opencv-2.4.13.7/modules/photo/src/arrays.hpp 2018-07-02 05:41:56.000000000 +0800
+++ opencv-2.4.13.7.nortti/modules/photo/src/arrays.hpp 2021-01-08 23:26:50.440357875 +0800
@@ -52,7 +52,6 @@ template <class T> struct Array2d {
{
if (array2d.needToDeallocArray) {
// copy constructor for self allocating arrays not supported
- throw new exception();
}
}

View File

@ -0,0 +1,31 @@
diff -Nuarp opencv-2.4.13.7.orig/modules/core/src/persistence.cpp opencv-2.4.13.7/modules/core/src/persistence.cpp
--- opencv-2.4.13.7.orig/modules/core/src/persistence.cpp 2018-07-02 05:41:56.000000000 +0800
+++ opencv-2.4.13.7/modules/core/src/persistence.cpp 2021-02-25 00:07:23.031002590 +0800
@@ -47,17 +47,7 @@
#include <iterator>
#include <wchar.h>
-#define USE_ZLIB 1
-
-#ifdef __APPLE__
-# include "TargetConditionals.h"
-# if (defined TARGET_OS_IPHONE && TARGET_OS_IPHONE) || (defined TARGET_IPHONE_SIMULATOR && TARGET_IPHONE_SIMULATOR)
-# undef USE_ZLIB
-# define USE_ZLIB 0
- typedef void* gzFile;
-# endif
-#endif
-
+#define USE_ZLIB 0
#if USE_ZLIB
# ifndef _LFS64_LARGEFILE
# define _LFS64_LARGEFILE 0
@@ -66,6 +56,8 @@
# define _FILE_OFFSET_BITS 0
# endif
# include <zlib.h>
+#else
+typedef void* gzFile;
#endif
/****************************************************************************************\

View File

@ -0,0 +1,52 @@
diff -Nuarp opencv-2.4.13.7/modules/core/include/opencv2/core/operations.hpp opencv-2.4.13.7.unsafe_xadd/modules/core/include/opencv2/core/operations.hpp
--- opencv-2.4.13.7/modules/core/include/opencv2/core/operations.hpp 2018-07-02 05:41:56.000000000 +0800
+++ opencv-2.4.13.7.unsafe_xadd/modules/core/include/opencv2/core/operations.hpp 2021-05-11 15:43:01.953963662 +0800
@@ -52,46 +52,8 @@
#ifdef __cplusplus
/////// exchange-add operation for atomic operations on reference counters ///////
-#ifdef CV_XADD
- // allow to use user-defined macro
-#elif defined __GNUC__
-
- #if defined __clang__ && __clang_major__ >= 3 && !defined __ANDROID__ && !defined __EMSCRIPTEN__ && !defined(__CUDACC__)
- #ifdef __ATOMIC_SEQ_CST
- #define CV_XADD(addr, delta) __c11_atomic_fetch_add((_Atomic(int)*)(addr), (delta), __ATOMIC_SEQ_CST)
- #else
- #define CV_XADD(addr, delta) __atomic_fetch_add((_Atomic(int)*)(addr), (delta), 5)
- #endif
- #elif __GNUC__*10 + __GNUC_MINOR__ >= 42
-
- #if !(defined WIN32 || defined _WIN32) && (defined __i486__ || defined __i586__ || \
- defined __i686__ || defined __MMX__ || defined __SSE__ || defined __ppc__) || \
- defined _STLPORT_MAJOR || defined _LIBCPP_VERSION || \
- defined __EMSCRIPTEN__
-
- #define CV_XADD __sync_fetch_and_add
- #else
- #include <ext/atomicity.h>
- #define CV_XADD __gnu_cxx::__exchange_and_add
- #endif
-
- #else
- #include <bits/atomicity.h>
- #if __GNUC__*10 + __GNUC_MINOR__ >= 34
- #define CV_XADD __gnu_cxx::__exchange_and_add
- #else
- #define CV_XADD __exchange_and_add
- #endif
- #endif
-
-#elif defined WIN32 || defined _WIN32 || defined WINCE
- namespace cv { CV_EXPORTS int _interlockedExchangeAdd(int* addr, int delta); }
- #define CV_XADD cv::_interlockedExchangeAdd
-
-#else
- static inline int CV_XADD(int* addr, int delta)
- { int tmp = *addr; *addr += delta; return tmp; }
-#endif
+static inline int CV_XADD(int* addr, int delta)
+{ int tmp = *addr; *addr += delta; return tmp; }
#include <limits>

View File

@ -0,0 +1,547 @@
diff -Nuarp opencv-3.4.16/modules/core/include/opencv2/core/bindings_utils.hpp opencv-3.4.16.nortti/modules/core/include/opencv2/core/bindings_utils.hpp
--- opencv-3.4.16/modules/core/include/opencv2/core/bindings_utils.hpp 2021-10-08 11:31:56.000000000 +0800
+++ opencv-3.4.16.nortti/modules/core/include/opencv2/core/bindings_utils.hpp 2021-11-24 11:12:28.954452496 +0800
@@ -170,12 +170,6 @@ void generateVectorOfMat(size_t len, int
}
CV_WRAP static inline
-void testRaiseGeneralException()
-{
- throw std::runtime_error("exception text");
-}
-
-CV_WRAP static inline
AsyncArray testAsyncArray(InputArray argument)
{
AsyncPromise p;
@@ -187,14 +181,6 @@ CV_WRAP static inline
AsyncArray testAsyncException()
{
AsyncPromise p;
- try
- {
- CV_Error(Error::StsOk, "Test: Generated async error");
- }
- catch (const cv::Exception& e)
- {
- p.setException(e);
- }
return p.getArrayResult();
}
diff -Nuarp opencv-3.4.16/modules/core/src/async.cpp opencv-3.4.16.nortti/modules/core/src/async.cpp
--- opencv-3.4.16/modules/core/src/async.cpp 2021-10-08 11:31:56.000000000 +0800
+++ opencv-3.4.16.nortti/modules/core/src/async.cpp 2021-11-24 11:12:28.955452496 +0800
@@ -118,7 +118,6 @@ struct AsyncArray::Impl
if (has_exception)
{
result_is_fetched = true;
- throw cv_exception;
}
CV_Error(Error::StsInternal, "AsyncArray: invalid state of 'has_result = true'");
}
diff -Nuarp opencv-3.4.16/modules/core/src/bindings_utils.cpp opencv-3.4.16.nortti/modules/core/src/bindings_utils.cpp
--- opencv-3.4.16/modules/core/src/bindings_utils.cpp 2021-10-08 11:31:56.000000000 +0800
+++ opencv-3.4.16.nortti/modules/core/src/bindings_utils.cpp 2021-11-24 11:12:28.955452496 +0800
@@ -15,7 +15,7 @@ String dumpInputArray(InputArray argumen
return "InputArray: noArray()";
std::ostringstream ss;
ss << "InputArray:";
- try {
+ {
do {
ss << (argument.empty() ? " empty()=true" : " empty()=false");
ss << cv::format(" kind=0x%08llx", (long long int)argument.kind());
@@ -49,10 +49,6 @@ String dumpInputArray(InputArray argumen
ss << " type(-1)=" << cv::typeToString(argument.type(-1));
} while (0);
}
- catch (...)
- {
- ss << " ERROR: exception occurred, dump is non-complete"; // need to properly support different kinds
- }
return ss.str();
}
@@ -62,7 +58,7 @@ CV_EXPORTS_W String dumpInputArrayOfArra
return "InputArrayOfArrays: noArray()";
std::ostringstream ss;
ss << "InputArrayOfArrays:";
- try {
+ {
do {
ss << (argument.empty() ? " empty()=true" : " empty()=false");
ss << cv::format(" kind=0x%08llx", (long long int)argument.kind());
@@ -102,10 +98,6 @@ CV_EXPORTS_W String dumpInputArrayOfArra
}
} while (0);
}
- catch (...)
- {
- ss << " ERROR: exception occurred, dump is non-complete"; // need to properly support different kinds
- }
return ss.str();
}
@@ -115,7 +107,7 @@ CV_EXPORTS_W String dumpInputOutputArray
return "InputOutputArray: noArray()";
std::ostringstream ss;
ss << "InputOutputArray:";
- try {
+ {
do {
ss << (argument.empty() ? " empty()=true" : " empty()=false");
ss << cv::format(" kind=0x%08llx", (long long int)argument.kind());
@@ -149,10 +141,6 @@ CV_EXPORTS_W String dumpInputOutputArray
ss << " type(-1)=" << cv::typeToString(argument.type(-1));
} while (0);
}
- catch (...)
- {
- ss << " ERROR: exception occurred, dump is non-complete"; // need to properly support different kinds
- }
return ss.str();
}
@@ -162,7 +150,7 @@ CV_EXPORTS_W String dumpInputOutputArray
return "InputOutputArrayOfArrays: noArray()";
std::ostringstream ss;
ss << "InputOutputArrayOfArrays:";
- try {
+ {
do {
ss << (argument.empty() ? " empty()=true" : " empty()=false");
ss << cv::format(" kind=0x%08llx", (long long int)argument.kind());
@@ -202,10 +190,6 @@ CV_EXPORTS_W String dumpInputOutputArray
}
} while (0);
}
- catch (...)
- {
- ss << " ERROR: exception occurred, dump is non-complete"; // need to properly support different kinds
- }
return ss.str();
}
diff -Nuarp opencv-3.4.16/modules/core/src/command_line_parser.cpp opencv-3.4.16.nortti/modules/core/src/command_line_parser.cpp
--- opencv-3.4.16/modules/core/src/command_line_parser.cpp 2021-10-08 11:31:56.000000000 +0800
+++ opencv-3.4.16.nortti/modules/core/src/command_line_parser.cpp 2021-11-24 11:12:28.956452496 +0800
@@ -124,7 +124,6 @@ static void from_str(const String& str,
void CommandLineParser::getByName(const String& name, bool space_delete, int type, void* dst) const
{
- try
{
for (size_t i = 0; i < impl->data.size(); i++)
{
@@ -149,12 +148,6 @@ void CommandLineParser::getByName(const
}
}
}
- catch (const Exception& e)
- {
- impl->error = true;
- impl->error_message = impl->error_message + "Parameter '"+ name + "': " + e.err + "\n";
- return;
- }
CV_Error_(Error::StsBadArg, ("undeclared key '%s' requested", name.c_str()));
}
@@ -162,7 +155,6 @@ void CommandLineParser::getByName(const
void CommandLineParser::getByIndex(int index, bool space_delete, int type, void* dst) const
{
- try
{
for (size_t i = 0; i < impl->data.size(); i++)
{
@@ -182,12 +174,6 @@ void CommandLineParser::getByIndex(int i
}
}
}
- catch (const Exception& e)
- {
- impl->error = true;
- impl->error_message = impl->error_message + format("Parameter #%d: ", index) + e.err + "\n";
- return;
- }
CV_Error_(Error::StsBadArg, ("undeclared position %d requested", index));
}
@@ -469,16 +455,7 @@ std::vector<String> CommandLineParser::I
{
if (begin == true)
{
- throw cv::Exception(CV_StsParseError,
- String("error in split_range_string(")
- + str
- + String(", ")
- + String(1, fs)
- + String(", ")
- + String(1, ss)
- + String(")"),
- "", __FILE__, __LINE__
- );
+ return vec;
}
begin = true;
word = "";
@@ -489,16 +466,7 @@ std::vector<String> CommandLineParser::I
{
if (begin == false)
{
- throw cv::Exception(CV_StsParseError,
- String("error in split_range_string(")
- + str
- + String(", ")
- + String(1, fs)
- + String(", ")
- + String(1, ss)
- + String(")"),
- "", __FILE__, __LINE__
- );
+ return vec;
}
begin = false;
vec.push_back(word);
@@ -513,16 +481,7 @@ std::vector<String> CommandLineParser::I
if (begin == true)
{
- throw cv::Exception(CV_StsParseError,
- String("error in split_range_string(")
- + str
- + String(", ")
- + String(1, fs)
- + String(", ")
- + String(1, ss)
- + String(")"),
- "", __FILE__, __LINE__
- );
+ return vec;
}
return vec;
diff -Nuarp opencv-3.4.16/modules/core/src/glob.cpp opencv-3.4.16.nortti/modules/core/src/glob.cpp
--- opencv-3.4.16/modules/core/src/glob.cpp 2021-10-08 11:31:56.000000000 +0800
+++ opencv-3.4.16.nortti/modules/core/src/glob.cpp 2021-11-24 11:12:28.957452496 +0800
@@ -231,7 +231,6 @@ static void glob_rec(const cv::String& d
if ((dir = opendir (directory.c_str())) != 0)
{
/* find all the files and directories within directory */
- try
{
struct dirent *ent;
while ((ent = readdir (dir)) != 0)
@@ -255,11 +254,6 @@ static void glob_rec(const cv::String& d
result.push_back(entry);
}
}
- catch (...)
- {
- closedir(dir);
- throw;
- }
closedir(dir);
}
else
diff -Nuarp opencv-3.4.16/modules/core/src/matrix.cpp opencv-3.4.16.nortti/modules/core/src/matrix.cpp
--- opencv-3.4.16/modules/core/src/matrix.cpp 2021-10-08 11:31:56.000000000 +0800
+++ opencv-3.4.16.nortti/modules/core/src/matrix.cpp 2021-11-24 11:12:28.957452496 +0800
@@ -640,18 +640,10 @@ void Mat::create(int d, const int* _size
#endif
if(!a)
a = a0;
- try
{
u = a->allocate(dims, size, _type, 0, step.p, 0, USAGE_DEFAULT);
CV_Assert(u != 0);
}
- catch (...)
- {
- if (a == a0)
- throw;
- u = a0->allocate(dims, size, _type, 0, step.p, 0, USAGE_DEFAULT);
- CV_Assert(u != 0);
- }
CV_Assert( step[dims-1] == (size_t)CV_ELEM_SIZE(flags) );
}
@@ -701,7 +693,6 @@ Mat::Mat(const Mat& m, const Range& _row
}
*this = m;
- try
{
if( _rowRange != Range::all() && _rowRange != Range(0,rows) )
{
@@ -721,11 +712,6 @@ Mat::Mat(const Mat& m, const Range& _row
flags |= SUBMATRIX_FLAG;
}
}
- catch(...)
- {
- release();
- throw;
- }
updateContinuityFlag();
diff -Nuarp opencv-3.4.16/modules/core/src/parallel.cpp opencv-3.4.16.nortti/modules/core/src/parallel.cpp
--- opencv-3.4.16/modules/core/src/parallel.cpp 2021-10-08 11:31:56.000000000 +0800
+++ opencv-3.4.16.nortti/modules/core/src/parallel.cpp 2021-11-24 11:12:28.957452496 +0800
@@ -321,29 +321,9 @@ namespace {
CV_TRACE_ARG_VALUE(range_end, "range.end", (int64)r.end);
#endif
- try
{
(*ctx.body)(r);
}
-#if CV__EXCEPTION_PTR
- catch (...)
- {
- ctx.recordException();
- }
-#else
- catch (const cv::Exception& e)
- {
- ctx.recordException(e.what());
- }
- catch (const std::exception& e)
- {
- ctx.recordException(e.what());
- }
- catch (...)
- {
- ctx.recordException("Unknown exception");
- }
-#endif
if (!ctx.is_rng_used && !(cv::theRNG() == ctx.rng))
ctx.is_rng_used = true;
@@ -476,16 +456,10 @@ void parallel_for_(const cv::Range& rang
isNotNestedRegion = CV_XADD(&flagNestedParallelFor, 1) == 0;
if (isNotNestedRegion)
{
- try
{
parallel_for_impl(range, body, nstripes);
flagNestedParallelFor = 0;
}
- catch (...)
- {
- flagNestedParallelFor = 0;
- throw;
- }
}
else // nested parallel_for_() calls are not parallelized
#endif // CV_PARALLEL_FRAMEWORK
diff -Nuarp opencv-3.4.16/modules/core/src/persistence_c.cpp opencv-3.4.16.nortti/modules/core/src/persistence_c.cpp
--- opencv-3.4.16/modules/core/src/persistence_c.cpp 2021-10-08 11:31:56.000000000 +0800
+++ opencv-3.4.16.nortti/modules/core/src/persistence_c.cpp 2021-11-24 11:12:28.958452496 +0800
@@ -456,17 +456,10 @@ cvOpenFileStorage(const char* query, CvM
CV_Assert(fs);
memset( fs, 0, sizeof(*fs));
- try
{
cvOpenFileStorage_(fs, query, dststorage, flags, encoding);
return fs;
}
- catch (...)
- {
- if (fs)
- cvReleaseFileStorage(&fs);
- throw;
- }
}
/* closes file storage and deallocates buffers */
diff -Nuarp opencv-3.4.16/modules/core/src/persistence_types.cpp opencv-3.4.16.nortti/modules/core/src/persistence_types.cpp
--- opencv-3.4.16/modules/core/src/persistence_types.cpp 2021-10-08 11:31:56.000000000 +0800
+++ opencv-3.4.16.nortti/modules/core/src/persistence_types.cpp 2021-11-24 11:12:28.958452496 +0800
@@ -756,13 +756,9 @@ static void* icvReadSeq( CvFileStorage*
flags |= CV_SEQ_FLAG_HOLE;
if( !strstr(flags_str, "untyped") )
{
- try
{
flags |= icvDecodeSimpleFormat(dt);
}
- catch (...)
- {
- }
}
}
diff -Nuarp opencv-3.4.16/modules/core/src/system.cpp opencv-3.4.16.nortti/modules/core/src/system.cpp
--- opencv-3.4.16/modules/core/src/system.cpp 2021-10-08 11:31:56.000000000 +0800
+++ opencv-3.4.16.nortti/modules/core/src/system.cpp 2021-11-24 11:12:28.958452496 +0800
@@ -1152,8 +1152,6 @@ void error( const Exception& exc )
static volatile int* p = 0;
*p = 0;
}
-
- throw exc;
}
void error(int _code, const String& _err, const char* _func, const char* _file, int _line)
@@ -2032,7 +2030,7 @@ inline bool parseOption(const std::strin
{
return false;
}
- throw ParseError(value);
+ return false;
}
template<>
@@ -2057,7 +2055,7 @@ inline size_t parseOption(const std::str
return v * 1024 * 1024;
else if (suffixStr == "KB" || suffixStr == "Kb" || suffixStr == "kb")
return v * 1024;
- throw ParseError(value);
+ return v;
}
template<>
@@ -2100,16 +2098,11 @@ static inline const char * envRead(const
template<typename T>
inline T read(const std::string & k, const T & defaultValue)
{
- try
{
const char * res = envRead(k.c_str());
if (res)
return parseOption<T>(std::string(res));
}
- catch (const ParseError &err)
- {
- CV_Error(cv::Error::StsBadArg, err.toString(k));
- }
return defaultValue;
}
diff -Nuarp opencv-3.4.16/modules/core/src/umatrix.cpp opencv-3.4.16.nortti/modules/core/src/umatrix.cpp
--- opencv-3.4.16/modules/core/src/umatrix.cpp 2021-10-08 11:31:56.000000000 +0800
+++ opencv-3.4.16.nortti/modules/core/src/umatrix.cpp 2021-11-24 11:14:01.073451067 +0800
@@ -516,14 +516,9 @@ UMat Mat::getUMat(int accessFlags, UMatU
new_u->originalUMatData = u;
}
bool allocated = false;
- try
{
allocated = UMat::getStdAllocator()->allocate(new_u, accessFlags, usageFlags);
}
- catch (const cv::Exception& e)
- {
- fprintf(stderr, "Exception: %s\n", e.what());
- }
if (!allocated)
{
allocated = getDefaultAllocator()->allocate(new_u, accessFlags, usageFlags);
@@ -540,7 +535,6 @@ UMat Mat::getUMat(int accessFlags, UMatU
CV_XADD(&(u->refcount), 1);
CV_XADD(&(u->urefcount), 1);
}
- try
{
hdr.flags = flags;
setSize(hdr, dims, size.p, step.p);
@@ -550,16 +544,6 @@ UMat Mat::getUMat(int accessFlags, UMatU
hdr.addref();
return hdr;
}
- catch(...)
- {
- if (u != NULL)
- {
- CV_XADD(&(u->refcount), -1);
- CV_XADD(&(u->urefcount), -1);
- }
- new_u->currAllocator->deallocate(new_u);
- throw;
- }
}
void UMat::create(int d, const int* _sizes, int _type, UMatUsageFlags _usageFlags)
@@ -604,17 +588,10 @@ void UMat::create(int d, const int* _siz
a = a0;
a0 = Mat::getDefaultAllocator();
}
- try
{
u = a->allocate(dims, size, _type, 0, step.p, 0, usageFlags);
CV_Assert(u != 0);
}
- catch(...)
- {
- if(a != a0)
- u = a0->allocate(dims, size, _type, 0, step.p, 0, usageFlags);
- CV_Assert(u != 0);
- }
CV_Assert( step[dims-1] == (size_t)CV_ELEM_SIZE(flags) );
}
@@ -981,7 +958,6 @@ Mat UMat::getMat(int accessFlags) const
// TODO Support ACCESS_READ (ACCESS_WRITE) without unnecessary data transfers
accessFlags |= ACCESS_RW;
UMatDataAutoLock autolock(u);
- try
{
if(CV_XADD(&u->refcount, 1) == 0)
u->currAllocator->map(u, accessFlags);
@@ -996,11 +972,6 @@ Mat UMat::getMat(int accessFlags) const
return hdr;
}
}
- catch(...)
- {
- CV_XADD(&u->refcount, -1);
- throw;
- }
CV_XADD(&u->refcount, -1);
CV_Assert(u->data != 0 && "Error mapping of UMat to host memory.");
return Mat();
diff -Nuarp opencv-3.4.16/modules/core/src/utils/filesystem.cpp opencv-3.4.16.nortti/modules/core/src/utils/filesystem.cpp
--- opencv-3.4.16/modules/core/src/utils/filesystem.cpp 2021-10-08 11:31:56.000000000 +0800
+++ opencv-3.4.16.nortti/modules/core/src/utils/filesystem.cpp 2021-11-24 11:12:28.958452496 +0800
@@ -492,14 +492,9 @@ cv::String getCacheDirectory(const char*
&& !utils::fs::isDirectory(default_cache_path))
{
std::vector<cv::String> existedCacheDirs;
- try
{
utils::fs::glob_relative(default_cache_path_base, "*", existedCacheDirs, false, true);
}
- catch (...)
- {
- // ignore
- }
if (!existedCacheDirs.empty())
{
CV_LOG_WARNING(NULL, "Creating new OpenCV cache directory: " << default_cache_path);
diff -Nuarp opencv-3.4.16/modules/imgproc/src/contours.cpp opencv-3.4.16.nortti/modules/imgproc/src/contours.cpp
--- opencv-3.4.16/modules/imgproc/src/contours.cpp 2021-10-08 11:31:56.000000000 +0800
+++ opencv-3.4.16.nortti/modules/imgproc/src/contours.cpp 2021-11-24 11:12:28.959452496 +0800
@@ -1761,7 +1761,6 @@ cvFindContours_Impl( void* img, CvMemS
}
else
{
- try
{
scanner = cvStartFindContours_Impl( img, storage, cntHeaderSize, mode, method, offset,
needFillBorder);
@@ -1773,12 +1772,6 @@ cvFindContours_Impl( void* img, CvMemS
}
while( contour != 0 );
}
- catch(...)
- {
- if( scanner )
- cvEndFindContours(&scanner);
- throw;
- }
*firstContour = cvEndFindContours( &scanner );
}

View File

@ -0,0 +1,12 @@
diff -Nuarp opencv-3.4.16/modules/core/src/persistence.hpp opencv-3.4.16.nozlib/modules/core/src/persistence.hpp
--- opencv-3.4.16/modules/core/src/persistence.hpp 2021-10-08 11:31:56.000000000 +0800
+++ opencv-3.4.16.nozlib/modules/core/src/persistence.hpp 2021-11-24 10:58:06.142465885 +0800
@@ -12,7 +12,7 @@
#include <string>
#include <iterator>
-#define USE_ZLIB 1
+#define USE_ZLIB 0
#if USE_ZLIB
# ifndef _LFS64_LARGEFILE
# define _LFS64_LARGEFILE 0

View File

@ -0,0 +1,38 @@
diff -Nuarp opencv-3.4.16/modules/core/include/opencv2/core/cvdef.h opencv-3.4.16.unsafe_xadd/modules/core/include/opencv2/core/cvdef.h
--- opencv-3.4.16/modules/core/include/opencv2/core/cvdef.h 2021-10-08 11:31:56.000000000 +0800
+++ opencv-3.4.16.unsafe_xadd/modules/core/include/opencv2/core/cvdef.h 2021-11-24 10:59:23.713464681 +0800
@@ -532,33 +532,7 @@ Cv64suf;
* exchange-add operation for atomic operations on reference counters *
\****************************************************************************************/
-#ifdef CV_XADD
- // allow to use user-defined macro
-#elif defined __GNUC__ || defined __clang__
-# if defined __clang__ && __clang_major__ >= 3 && !defined __ANDROID__ && !defined __EMSCRIPTEN__ && !defined(__CUDACC__) && !defined __INTEL_COMPILER
-# ifdef __ATOMIC_ACQ_REL
-# define CV_XADD(addr, delta) __c11_atomic_fetch_add((_Atomic(int)*)(addr), delta, __ATOMIC_ACQ_REL)
-# else
-# define CV_XADD(addr, delta) __atomic_fetch_add((_Atomic(int)*)(addr), delta, 4)
-# endif
-# else
-# if defined __ATOMIC_ACQ_REL && !defined __clang__
- // version for gcc >= 4.7
-# define CV_XADD(addr, delta) (int)__atomic_fetch_add((unsigned*)(addr), (unsigned)(delta), __ATOMIC_ACQ_REL)
-# else
-# define CV_XADD(addr, delta) (int)__sync_fetch_and_add((unsigned*)(addr), (unsigned)(delta))
-# endif
-# endif
-#elif defined _MSC_VER && !defined RC_INVOKED
-# include <intrin.h>
-# define CV_XADD(addr, delta) (int)_InterlockedExchangeAdd((long volatile*)addr, delta)
-#else
- #ifdef OPENCV_FORCE_UNSAFE_XADD
- CV_INLINE int CV_XADD(int* addr, int delta) { int tmp = *addr; *addr += delta; return tmp; }
- #else
- #error "OpenCV: can't define safe CV_XADD macro for current platform (unsupported). Define CV_XADD macro through custom port header (see OPENCV_INCLUDE_PORT_FILE)"
- #endif
-#endif
+CV_INLINE int CV_XADD(void* addr, int delta) { int tmp = *(int*)addr; *(int*)addr += delta; return tmp; }
/****************************************************************************************\

View File

@ -0,0 +1,690 @@
diff -Nuarp opencv-4.5.4/modules/core/include/opencv2/core/bindings_utils.hpp opencv-4.5.4.nortti/modules/core/include/opencv2/core/bindings_utils.hpp
--- opencv-4.5.4/modules/core/include/opencv2/core/bindings_utils.hpp 2021-10-09 08:48:26.000000000 +0800
+++ opencv-4.5.4.nortti/modules/core/include/opencv2/core/bindings_utils.hpp 2021-11-24 11:00:30.806463640 +0800
@@ -176,12 +176,6 @@ void generateVectorOfMat(size_t len, int
}
CV_WRAP static inline
-void testRaiseGeneralException()
-{
- throw std::runtime_error("exception text");
-}
-
-CV_WRAP static inline
AsyncArray testAsyncArray(InputArray argument)
{
AsyncPromise p;
@@ -193,14 +187,6 @@ CV_WRAP static inline
AsyncArray testAsyncException()
{
AsyncPromise p;
- try
- {
- CV_Error(Error::StsOk, "Test: Generated async error");
- }
- catch (const cv::Exception& e)
- {
- p.setException(e);
- }
return p.getArrayResult();
}
diff -Nuarp opencv-4.5.4/modules/core/include/opencv2/core/ocl.hpp opencv-4.5.4.nortti/modules/core/include/opencv2/core/ocl.hpp
--- opencv-4.5.4/modules/core/include/opencv2/core/ocl.hpp 2021-10-09 08:48:26.000000000 +0800
+++ opencv-4.5.4.nortti/modules/core/include/opencv2/core/ocl.hpp 2021-11-24 11:00:30.807463640 +0800
@@ -302,21 +302,6 @@ public:
void release();
- class CV_EXPORTS UserContext {
- public:
- virtual ~UserContext();
- };
- template <typename T>
- inline void setUserContext(const std::shared_ptr<T>& userContext) {
- setUserContext(typeid(T), userContext);
- }
- template <typename T>
- inline std::shared_ptr<T> getUserContext() {
- return std::dynamic_pointer_cast<T>(getUserContext(typeid(T)));
- }
- void setUserContext(std::type_index typeId, const std::shared_ptr<UserContext>& userContext);
- std::shared_ptr<UserContext> getUserContext(std::type_index typeId);
-
struct Impl;
inline Impl* getImpl() const { return (Impl*)p; }
inline bool empty() const { return !p; }
diff -Nuarp opencv-4.5.4/modules/core/src/async.cpp opencv-4.5.4.nortti/modules/core/src/async.cpp
--- opencv-4.5.4/modules/core/src/async.cpp 2021-10-09 08:48:26.000000000 +0800
+++ opencv-4.5.4.nortti/modules/core/src/async.cpp 2021-11-24 11:00:30.808463640 +0800
@@ -119,7 +119,6 @@ struct AsyncArray::Impl
if (has_exception)
{
result_is_fetched = true;
- throw cv_exception;
}
CV_Error(Error::StsInternal, "AsyncArray: invalid state of 'has_result = true'");
}
diff -Nuarp opencv-4.5.4/modules/core/src/bindings_utils.cpp opencv-4.5.4.nortti/modules/core/src/bindings_utils.cpp
--- opencv-4.5.4/modules/core/src/bindings_utils.cpp 2021-10-09 08:48:26.000000000 +0800
+++ opencv-4.5.4.nortti/modules/core/src/bindings_utils.cpp 2021-11-24 11:00:30.809463640 +0800
@@ -17,7 +17,7 @@ String dumpInputArray(InputArray argumen
return "InputArray: noArray()";
std::ostringstream ss;
ss << "InputArray:";
- try {
+ {
do {
ss << (argument.empty() ? " empty()=true" : " empty()=false");
ss << cv::format(" kind=0x%08llx", (long long int)argument.kind());
@@ -51,10 +51,6 @@ String dumpInputArray(InputArray argumen
ss << " type(-1)=" << cv::typeToString(argument.type(-1));
} while (0);
}
- catch (...)
- {
- ss << " ERROR: exception occurred, dump is non-complete"; // need to properly support different kinds
- }
return ss.str();
}
@@ -64,7 +60,7 @@ CV_EXPORTS_W String dumpInputArrayOfArra
return "InputArrayOfArrays: noArray()";
std::ostringstream ss;
ss << "InputArrayOfArrays:";
- try {
+ {
do {
ss << (argument.empty() ? " empty()=true" : " empty()=false");
ss << cv::format(" kind=0x%08llx", (long long int)argument.kind());
@@ -104,10 +100,6 @@ CV_EXPORTS_W String dumpInputArrayOfArra
}
} while (0);
}
- catch (...)
- {
- ss << " ERROR: exception occurred, dump is non-complete"; // need to properly support different kinds
- }
return ss.str();
}
@@ -117,7 +109,7 @@ CV_EXPORTS_W String dumpInputOutputArray
return "InputOutputArray: noArray()";
std::ostringstream ss;
ss << "InputOutputArray:";
- try {
+ {
do {
ss << (argument.empty() ? " empty()=true" : " empty()=false");
ss << cv::format(" kind=0x%08llx", (long long int)argument.kind());
@@ -151,10 +143,6 @@ CV_EXPORTS_W String dumpInputOutputArray
ss << " type(-1)=" << cv::typeToString(argument.type(-1));
} while (0);
}
- catch (...)
- {
- ss << " ERROR: exception occurred, dump is non-complete"; // need to properly support different kinds
- }
return ss.str();
}
@@ -164,7 +152,7 @@ CV_EXPORTS_W String dumpInputOutputArray
return "InputOutputArrayOfArrays: noArray()";
std::ostringstream ss;
ss << "InputOutputArrayOfArrays:";
- try {
+ {
do {
ss << (argument.empty() ? " empty()=true" : " empty()=false");
ss << cv::format(" kind=0x%08llx", (long long int)argument.kind());
@@ -204,10 +192,6 @@ CV_EXPORTS_W String dumpInputOutputArray
}
} while (0);
}
- catch (...)
- {
- ss << " ERROR: exception occurred, dump is non-complete"; // need to properly support different kinds
- }
return ss.str();
}
diff -Nuarp opencv-4.5.4/modules/core/src/command_line_parser.cpp opencv-4.5.4.nortti/modules/core/src/command_line_parser.cpp
--- opencv-4.5.4/modules/core/src/command_line_parser.cpp 2021-10-09 08:48:26.000000000 +0800
+++ opencv-4.5.4.nortti/modules/core/src/command_line_parser.cpp 2021-11-24 11:00:30.809463640 +0800
@@ -119,7 +119,6 @@ static void from_str(const String& str,
void CommandLineParser::getByName(const String& name, bool space_delete, Param type, void* dst) const
{
- try
{
for (size_t i = 0; i < impl->data.size(); i++)
{
@@ -144,12 +143,6 @@ void CommandLineParser::getByName(const
}
}
}
- catch (const Exception& e)
- {
- impl->error = true;
- impl->error_message = impl->error_message + "Parameter '"+ name + "': " + e.err + "\n";
- return;
- }
CV_Error_(Error::StsBadArg, ("undeclared key '%s' requested", name.c_str()));
}
@@ -157,7 +150,6 @@ void CommandLineParser::getByName(const
void CommandLineParser::getByIndex(int index, bool space_delete, Param type, void* dst) const
{
- try
{
for (size_t i = 0; i < impl->data.size(); i++)
{
@@ -177,12 +169,6 @@ void CommandLineParser::getByIndex(int i
}
}
}
- catch (const Exception& e)
- {
- impl->error = true;
- impl->error_message = impl->error_message + format("Parameter #%d: ", index) + e.err + "\n";
- return;
- }
CV_Error_(Error::StsBadArg, ("undeclared position %d requested", index));
}
@@ -464,16 +450,7 @@ std::vector<String> CommandLineParser::I
{
if (begin == true)
{
- throw cv::Exception(CV_StsParseError,
- String("error in split_range_string(")
- + str
- + String(", ")
- + String(1, fs)
- + String(", ")
- + String(1, ss)
- + String(")"),
- "", __FILE__, __LINE__
- );
+ return vec;
}
begin = true;
word = "";
@@ -484,16 +461,7 @@ std::vector<String> CommandLineParser::I
{
if (begin == false)
{
- throw cv::Exception(CV_StsParseError,
- String("error in split_range_string(")
- + str
- + String(", ")
- + String(1, fs)
- + String(", ")
- + String(1, ss)
- + String(")"),
- "", __FILE__, __LINE__
- );
+ return vec;
}
begin = false;
vec.push_back(word);
@@ -508,16 +476,7 @@ std::vector<String> CommandLineParser::I
if (begin == true)
{
- throw cv::Exception(CV_StsParseError,
- String("error in split_range_string(")
- + str
- + String(", ")
- + String(1, fs)
- + String(", ")
- + String(1, ss)
- + String(")"),
- "", __FILE__, __LINE__
- );
+ return vec;
}
return vec;
diff -Nuarp opencv-4.5.4/modules/core/src/glob.cpp opencv-4.5.4.nortti/modules/core/src/glob.cpp
--- opencv-4.5.4/modules/core/src/glob.cpp 2021-10-09 08:48:26.000000000 +0800
+++ opencv-4.5.4.nortti/modules/core/src/glob.cpp 2021-11-24 11:00:30.809463640 +0800
@@ -243,7 +243,6 @@ static void glob_rec(const cv::String& d
if ((dir = opendir (directory.c_str())) != 0)
{
/* find all the files and directories within directory */
- try
{
struct dirent *ent;
while ((ent = readdir (dir)) != 0)
@@ -267,11 +266,6 @@ static void glob_rec(const cv::String& d
result.push_back(entry);
}
}
- catch (...)
- {
- closedir(dir);
- throw;
- }
closedir(dir);
}
else
diff -Nuarp opencv-4.5.4/modules/core/src/matrix.cpp opencv-4.5.4.nortti/modules/core/src/matrix.cpp
--- opencv-4.5.4/modules/core/src/matrix.cpp 2021-10-09 08:48:26.000000000 +0800
+++ opencv-4.5.4.nortti/modules/core/src/matrix.cpp 2021-11-24 11:00:30.809463640 +0800
@@ -700,18 +700,10 @@ void Mat::create(int d, const int* _size
#endif
if(!a)
a = a0;
- try
{
u = a->allocate(dims, size, _type, 0, step.p, ACCESS_RW /* ignored */, USAGE_DEFAULT);
CV_Assert(u != 0);
}
- catch (...)
- {
- if (a == a0)
- throw;
- u = a0->allocate(dims, size, _type, 0, step.p, ACCESS_RW /* ignored */, USAGE_DEFAULT);
- CV_Assert(u != 0);
- }
CV_Assert( step[dims-1] == (size_t)CV_ELEM_SIZE(flags) );
}
@@ -761,7 +753,6 @@ Mat::Mat(const Mat& m, const Range& _row
}
*this = m;
- try
{
if( _rowRange != Range::all() && _rowRange != Range(0,rows) )
{
@@ -781,11 +772,6 @@ Mat::Mat(const Mat& m, const Range& _row
flags |= SUBMATRIX_FLAG;
}
}
- catch(...)
- {
- release();
- throw;
- }
updateContinuityFlag();
diff -Nuarp opencv-4.5.4/modules/core/src/ocl_disabled.impl.hpp opencv-4.5.4.nortti/modules/core/src/ocl_disabled.impl.hpp
--- opencv-4.5.4/modules/core/src/ocl_disabled.impl.hpp 2021-10-09 08:48:26.000000000 +0800
+++ opencv-4.5.4.nortti/modules/core/src/ocl_disabled.impl.hpp 2021-11-24 11:00:30.810463640 +0800
@@ -177,11 +177,6 @@ void* Context::getOpenCLContextProperty(
bool Context::useSVM() const { return false; }
void Context::setUseSVM(bool enabled) { }
-Context::UserContext::~UserContext() { }
-
-void Context::setUserContext(std::type_index /*typeId*/, const std::shared_ptr<Context::UserContext>& /*userContext*/) { OCL_NOT_AVAILABLE(); }
-std::shared_ptr<Context::UserContext> Context::getUserContext(std::type_index /*typeId*/) { OCL_NOT_AVAILABLE(); }
-
/* static */ Context Context::fromHandle(void* context) { OCL_NOT_AVAILABLE(); }
/* static */ Context Context::fromDevice(const ocl::Device& device) { OCL_NOT_AVAILABLE(); }
/* static */ Context Context::create(const std::string& configuration) { OCL_NOT_AVAILABLE(); }
diff -Nuarp opencv-4.5.4/modules/core/src/parallel/parallel.cpp opencv-4.5.4.nortti/modules/core/src/parallel/parallel.cpp
--- opencv-4.5.4/modules/core/src/parallel/parallel.cpp 2021-10-09 08:48:26.000000000 +0800
+++ opencv-4.5.4.nortti/modules/core/src/parallel/parallel.cpp 2021-11-24 11:00:30.810463640 +0800
@@ -60,7 +60,6 @@ std::shared_ptr<ParallelForAPI> createPa
}
isKnown = true;
}
- try
{
CV_LOG_DEBUG(NULL, "core(parallel): trying backend: " << info.name << " (priority=" << info.priority << ")");
if (!info.backendFactory)
@@ -79,14 +78,6 @@ std::shared_ptr<ParallelForAPI> createPa
getParallelBackendName() = info.name;
return backend;
}
- catch (const std::exception& e)
- {
- CV_LOG_WARNING(NULL, "core(parallel): can't initialize " << info.name << " backend: " << e.what());
- }
- catch (...)
- {
- CV_LOG_WARNING(NULL, "core(parallel): can't initialize " << info.name << " backend: Unknown C++ exception");
- }
}
if (name.empty())
{
diff -Nuarp opencv-4.5.4/modules/core/src/parallel/plugin_parallel_wrapper.impl.hpp opencv-4.5.4.nortti/modules/core/src/parallel/plugin_parallel_wrapper.impl.hpp
--- opencv-4.5.4/modules/core/src/parallel/plugin_parallel_wrapper.impl.hpp 2021-10-09 08:48:26.000000000 +0800
+++ opencv-4.5.4.nortti/modules/core/src/parallel/plugin_parallel_wrapper.impl.hpp 2021-11-24 11:00:30.810463640 +0800
@@ -155,15 +155,10 @@ protected:
void initBackend()
{
AutoLock lock(getInitializationMutex());
- try
{
if (!initialized)
loadPlugin();
}
- catch (...)
- {
- CV_LOG_INFO(NULL, "core(parallel): exception during plugin loading: " << baseName_ << ". SKIP");
- }
initialized = true;
}
void loadPlugin();
@@ -243,7 +238,6 @@ void PluginParallelBackendFactory::loadP
{
continue;
}
- try
{
auto pluginBackend = std::make_shared<PluginParallelBackend>(lib);
if (!pluginBackend)
@@ -264,10 +258,6 @@ void PluginParallelBackendFactory::loadP
backend = pluginBackend;
return;
}
- catch (...)
- {
- CV_LOG_WARNING(NULL, "core(parallel): exception during plugin initialization: " << toPrintablePath(plugin) << ". SKIP");
- }
}
}
diff -Nuarp opencv-4.5.4/modules/core/src/parallel.cpp opencv-4.5.4.nortti/modules/core/src/parallel.cpp
--- opencv-4.5.4/modules/core/src/parallel.cpp 2021-10-09 08:48:26.000000000 +0800
+++ opencv-4.5.4.nortti/modules/core/src/parallel.cpp 2021-11-24 11:00:30.810463640 +0800
@@ -333,29 +333,9 @@ namespace {
CV_TRACE_ARG_VALUE(range_end, "range.end", (int64)r.end);
#endif
- try
{
(*ctx.body)(r);
}
-#if CV__EXCEPTION_PTR
- catch (...)
- {
- ctx.recordException();
- }
-#else
- catch (const cv::Exception& e)
- {
- ctx.recordException(e.what());
- }
- catch (const std::exception& e)
- {
- ctx.recordException(e.what());
- }
- catch (...)
- {
- ctx.recordException("Unknown exception");
- }
-#endif
if (!ctx.is_rng_used && !(cv::theRNG() == ctx.rng))
ctx.is_rng_used = true;
@@ -501,16 +481,10 @@ void parallel_for_(const cv::Range& rang
isNotNestedRegion = !flagNestedParallelFor.exchange(true);
if (isNotNestedRegion)
{
- try
{
parallel_for_impl(range, body, nstripes);
flagNestedParallelFor = false;
}
- catch (...)
- {
- flagNestedParallelFor = false;
- throw;
- }
}
else // nested parallel_for_() calls are not parallelized
{
diff -Nuarp opencv-4.5.4/modules/core/src/persistence.cpp opencv-4.5.4.nortti/modules/core/src/persistence.cpp
--- opencv-4.5.4/modules/core/src/persistence.cpp 2021-10-09 08:48:26.000000000 +0800
+++ opencv-4.5.4.nortti/modules/core/src/persistence.cpp 2021-11-24 11:05:14.808459233 +0800
@@ -687,7 +687,7 @@ bool FileStorage::Impl::open(const char
strbufpos = bufOffset;
bufofs = 0;
- try {
+ {
char *ptr = bufferStart();
ptr[0] = ptr[1] = ptr[2] = '\0';
FileNode root_nodes(fs_ext, 0, 0);
@@ -728,11 +728,6 @@ bool FileStorage::Impl::open(const char
}
}
}
- catch (...) {
- is_opened = true;
- release();
- throw;
- }
// release resources that we do not need anymore
closeFile();
@@ -1865,18 +1860,12 @@ FileStorage::~FileStorage()
bool FileStorage::open(const String& filename, int flags, const String& encoding)
{
- try
{
bool ok = p->open(filename.c_str(), flags, encoding.c_str());
if(ok)
state = FileStorage::NAME_EXPECTED + FileStorage::INSIDE_MAP;
return ok;
}
- catch (...)
- {
- release();
- throw; // re-throw
- }
}
bool FileStorage::isOpened() const { return p->is_opened; }
diff -Nuarp opencv-4.5.4/modules/core/src/system.cpp opencv-4.5.4.nortti/modules/core/src/system.cpp
--- opencv-4.5.4/modules/core/src/system.cpp 2021-10-09 08:48:26.000000000 +0800
+++ opencv-4.5.4.nortti/modules/core/src/system.cpp 2021-11-24 11:00:30.811463640 +0800
@@ -1175,7 +1175,6 @@ void error( const Exception& exc )
*p = 0;
}
- throw exc;
#ifdef __GNUC__
# if !defined __clang__ && !defined __APPLE__
// this suppresses this warning: "noreturn" function does return [enabled by default]
@@ -1981,15 +1980,9 @@ void* TLSDataContainer::getData() const
{
// Create new data instance and save it to TLS storage
pData = createDataInstance();
- try
{
getTlsStorage().setData(key_, pData);
}
- catch (...)
- {
- deleteDataInstance(pData);
- throw;
- }
}
return pData;
}
@@ -2093,7 +2086,7 @@ inline bool parseOption(const std::strin
{
return false;
}
- throw ParseError(value);
+ return false;
}
template<>
@@ -2114,7 +2107,7 @@ inline size_t parseOption(const std::str
return v * 1024 * 1024;
else if (suffixStr == "KB" || suffixStr == "Kb" || suffixStr == "kb")
return v * 1024;
- throw ParseError(value);
+ return v;
}
template<>
@@ -2157,16 +2150,11 @@ static inline const char * envRead(const
template<typename T>
inline T read(const std::string & k, const T & defaultValue)
{
- try
{
const char * res = envRead(k.c_str());
if (res)
return parseOption<T>(std::string(res));
}
- catch (const ParseError &err)
- {
- CV_Error(cv::Error::StsBadArg, err.toString(k));
- }
return defaultValue;
}
diff -Nuarp opencv-4.5.4/modules/core/src/umatrix.cpp opencv-4.5.4.nortti/modules/core/src/umatrix.cpp
--- opencv-4.5.4/modules/core/src/umatrix.cpp 2021-10-09 08:48:26.000000000 +0800
+++ opencv-4.5.4.nortti/modules/core/src/umatrix.cpp 2021-11-24 11:06:55.772457666 +0800
@@ -602,14 +602,9 @@ UMat Mat::getUMat(AccessFlag accessFlags
new_u->originalUMatData = u;
}
bool allocated = false;
- try
{
allocated = UMat::getStdAllocator()->allocate(new_u, accessFlags, usageFlags);
}
- catch (const cv::Exception& e)
- {
- fprintf(stderr, "Exception: %s\n", e.what());
- }
if (!allocated)
{
allocated = getDefaultAllocator()->allocate(new_u, accessFlags, usageFlags);
@@ -626,7 +621,6 @@ UMat Mat::getUMat(AccessFlag accessFlags
CV_XADD(&(u->refcount), 1);
CV_XADD(&(u->urefcount), 1);
}
- try
{
hdr.flags = flags;
hdr.usageFlags = usageFlags;
@@ -637,16 +631,6 @@ UMat Mat::getUMat(AccessFlag accessFlags
hdr.addref();
return hdr;
}
- catch(...)
- {
- if (u != NULL)
- {
- CV_XADD(&(u->refcount), -1);
- CV_XADD(&(u->urefcount), -1);
- }
- new_u->currAllocator->deallocate(new_u);
- throw;
- }
}
@@ -698,17 +682,10 @@ void UMat::create(int d, const int* _siz
a = a0;
a0 = Mat::getDefaultAllocator();
}
- try
{
u = a->allocate(dims, size, _type, 0, step.p, ACCESS_RW /* ignored */, usageFlags);
CV_Assert(u != 0);
}
- catch(...)
- {
- if(a != a0)
- u = a0->allocate(dims, size, _type, 0, step.p, ACCESS_RW /* ignored */, usageFlags);
- CV_Assert(u != 0);
- }
CV_Assert( step[dims-1] == (size_t)CV_ELEM_SIZE(flags) );
}
@@ -1075,7 +1052,6 @@ Mat UMat::getMat(AccessFlag accessFlags)
// TODO Support ACCESS_READ (ACCESS_WRITE) without unnecessary data transfers
accessFlags |= ACCESS_RW;
UMatDataAutoLock autolock(u);
- try
{
if(CV_XADD(&u->refcount, 1) == 0)
u->currAllocator->map(u, accessFlags);
@@ -1090,11 +1066,6 @@ Mat UMat::getMat(AccessFlag accessFlags)
return hdr;
}
}
- catch(...)
- {
- CV_XADD(&u->refcount, -1);
- throw;
- }
CV_XADD(&u->refcount, -1);
CV_Assert(u->data != 0 && "Error mapping of UMat to host memory.");
return Mat();
diff -Nuarp opencv-4.5.4/modules/core/src/utils/filesystem.cpp opencv-4.5.4.nortti/modules/core/src/utils/filesystem.cpp
--- opencv-4.5.4/modules/core/src/utils/filesystem.cpp 2021-10-09 08:48:26.000000000 +0800
+++ opencv-4.5.4.nortti/modules/core/src/utils/filesystem.cpp 2021-11-24 11:00:30.811463640 +0800
@@ -508,14 +508,9 @@ cv::String getCacheDirectory(const char*
&& !utils::fs::isDirectory(default_cache_path))
{
std::vector<cv::String> existedCacheDirs;
- try
{
utils::fs::glob_relative(default_cache_path_base, "*", existedCacheDirs, false, true);
}
- catch (...)
- {
- // ignore
- }
if (!existedCacheDirs.empty())
{
CV_LOG_WARNING(NULL, "Creating new OpenCV cache directory: " << default_cache_path);
diff -Nuarp opencv-4.5.4/modules/imgproc/src/contours.cpp opencv-4.5.4.nortti/modules/imgproc/src/contours.cpp
--- opencv-4.5.4/modules/imgproc/src/contours.cpp 2021-10-09 08:48:26.000000000 +0800
+++ opencv-4.5.4.nortti/modules/imgproc/src/contours.cpp 2021-11-24 11:00:30.812463640 +0800
@@ -1762,7 +1762,6 @@ cvFindContours_Impl( void* img, CvMemS
}
else
{
- try
{
scanner = cvStartFindContours_Impl( img, storage, cntHeaderSize, mode, method, offset,
needFillBorder);
@@ -1774,12 +1773,6 @@ cvFindContours_Impl( void* img, CvMemS
}
while( contour != 0 );
}
- catch(...)
- {
- if( scanner )
- cvEndFindContours(&scanner);
- throw;
- }
*firstContour = cvEndFindContours( &scanner );
}
diff -Nuarp opencv-4.5.4/modules/video/src/tracking/detail/tracking_feature.cpp opencv-4.5.4.nortti/modules/video/src/tracking/detail/tracking_feature.cpp
--- opencv-4.5.4/modules/video/src/tracking/detail/tracking_feature.cpp 2021-10-09 08:48:26.000000000 +0800
+++ opencv-4.5.4.nortti/modules/video/src/tracking/detail/tracking_feature.cpp 2021-11-24 11:00:30.812463640 +0800
@@ -107,15 +107,9 @@ void CvHaarEvaluator::generateFeatures(i
CvHaarEvaluator::FeatureHaar::FeatureHaar(Size patchSize)
{
- try
{
generateRandomFeature(patchSize);
}
- catch (...)
- {
- // FIXIT
- throw;
- }
}
void CvHaarEvaluator::FeatureHaar::generateRandomFeature(Size patchSize)

View File

@ -0,0 +1,12 @@
diff -Nuarp opencv-4.5.4/modules/core/src/persistence.hpp opencv-4.5.4.nozlib/modules/core/src/persistence.hpp
--- opencv-4.5.4/modules/core/src/persistence.hpp 2021-10-09 08:48:26.000000000 +0800
+++ opencv-4.5.4.nozlib/modules/core/src/persistence.hpp 2021-11-24 11:10:47.321454073 +0800
@@ -12,7 +12,7 @@
#include <string>
#include <iterator>
-#define USE_ZLIB 1
+#define USE_ZLIB 0
#if USE_ZLIB
# ifndef _LFS64_LARGEFILE
# define _LFS64_LARGEFILE 0

View File

@ -0,0 +1,38 @@
diff -Nuarp opencv-4.5.4/modules/core/include/opencv2/core/cvdef.h opencv-4.5.4.unsafe_xadd/modules/core/include/opencv2/core/cvdef.h
--- opencv-4.5.4/modules/core/include/opencv2/core/cvdef.h 2021-10-09 08:48:26.000000000 +0800
+++ opencv-4.5.4.unsafe_xadd/modules/core/include/opencv2/core/cvdef.h 2021-11-24 11:11:42.005453225 +0800
@@ -662,33 +662,7 @@ __CV_ENUM_FLAGS_BITWISE_XOR_EQ (EnumTy
* exchange-add operation for atomic operations on reference counters *
\****************************************************************************************/
-#ifdef CV_XADD
- // allow to use user-defined macro
-#elif defined __GNUC__ || defined __clang__
-# if defined __clang__ && __clang_major__ >= 3 && !defined __ANDROID__ && !defined __EMSCRIPTEN__ && !defined(__CUDACC__) && !defined __INTEL_COMPILER
-# ifdef __ATOMIC_ACQ_REL
-# define CV_XADD(addr, delta) __c11_atomic_fetch_add((_Atomic(int)*)(addr), delta, __ATOMIC_ACQ_REL)
-# else
-# define CV_XADD(addr, delta) __atomic_fetch_add((_Atomic(int)*)(addr), delta, 4)
-# endif
-# else
-# if defined __ATOMIC_ACQ_REL && !defined __clang__
- // version for gcc >= 4.7
-# define CV_XADD(addr, delta) (int)__atomic_fetch_add((unsigned*)(addr), (unsigned)(delta), __ATOMIC_ACQ_REL)
-# else
-# define CV_XADD(addr, delta) (int)__sync_fetch_and_add((unsigned*)(addr), (unsigned)(delta))
-# endif
-# endif
-#elif defined _MSC_VER && !defined RC_INVOKED
-# include <intrin.h>
-# define CV_XADD(addr, delta) (int)_InterlockedExchangeAdd((long volatile*)addr, delta)
-#else
- #ifdef OPENCV_FORCE_UNSAFE_XADD
- CV_INLINE int CV_XADD(int* addr, int delta) { int tmp = *addr; *addr += delta; return tmp; }
- #else
- #error "OpenCV: can't define safe CV_XADD macro for current platform (unsupported). Define CV_XADD macro through custom port header (see OPENCV_INCLUDE_PORT_FILE)"
- #endif
-#endif
+CV_INLINE int CV_XADD(void* addr, int delta) { int tmp = *(int*)addr; *(int*)addr += delta; return tmp; }
/****************************************************************************************\

View File

@ -0,0 +1,69 @@
-DWITH_AVFOUNDATION=OFF
-DWITH_CARBON=OFF
-DWITH_CUDA=OFF
-DWITH_VTK=OFF
-DWITH_CUFFT=OFF
-DWITH_CUBLAS=OFF
-DWITH_EIGEN=OFF
-DWITH_FFMPEG=OFF
-DWITH_GSTREAMER=OFF
-DWITH_GTK=OFF
-DWITH_IMAGEIO=OFF
-DWITH_IPP=OFF
-DWITH_JASPER=OFF
-DWITH_JPEG=OFF
-DWITH_OPENEXR=OFF
-DWITH_PNG=OFF
-DWITH_TIFF=OFF
-DWITH_QUICKTIME=OFF
-DWITH_QTKIT=OFF
-DWITH_TBB=OFF
-DWITH_OPENMP=ON
-DWITH_V4L=OFF
-DWITH_LIBV4L=OFF
-DWITH_OPENCL=OFF
-DBUILD_SHARED_LIBS=OFF
-DBUILD_opencv_apps=OFF
-DBUILD_ANDROID_EXAMPLES=OFF
-DBUILD_DOCS=OFF
-DBUILD_EXAMPLES=OFF
-DBUILD_PACKAGE=OFF
-DBUILD_PERF_TESTS=OFF
-DBUILD_TESTS=OFF
-DBUILD_WITH_DEBUG_INFO=OFF
-DBUILD_WITH_STATIC_CRT=OFF
-DBUILD_FAT_JAVA_LIB=OFF
-DBUILD_ANDROID_SERVICE=OFF
-DBUILD_ANDROID_PACKAGE=OFF
-DBUILD_TINY_GPU_MODULE=OFF
-DBUILD_ZLIB=OFF
-DBUILD_TIFF=OFF
-DBUILD_JASPER=OFF
-DBUILD_JPEG=OFF
-DBUILD_PNG=OFF
-DBUILD_OPENEXR=OFF
-DBUILD_TBB=OFF
-DENABLE_DYNAMIC_CUDA=OFF
-DENABLE_PRECOMPILED_HEADERS=OFF
-DBUILD_opencv_java=OFF
-DBUILD_opencv_androidcamera=OFF
-DBUILD_opencv_ts=OFF
-DBUILD_opencv_python2=OFF
-DBUILD_opencv_python3=OFF
-DBUILD_opencv_gpu=OFF
-DBUILD_opencv_dynamicuda=OFF
-DBUILD_opencv_ocl=OFF
-DBUILD_opencv_imgcodecs=OFF
-DBUILD_opencv_videoio=OFF
-DBUILD_opencv_calib3d=OFF
-DBUILD_opencv_flann=OFF
-DBUILD_opencv_objdetect=OFF
-DBUILD_opencv_stitching=OFF
-DBUILD_opencv_ml=OFF
-DBUILD_opencv_superres=OFF
-DBUILD_opencv_videostab=OFF
-DBUILD_opencv_viz=OFF
-DBUILD_opencv_contrib=OFF
-DBUILD_opencv_features2d=OFF
-DBUILD_opencv_legacy=OFF
-DBUILD_opencv_nonfree=OFF

View File

@ -0,0 +1,78 @@
-DENABLE_CXX11=OFF
-DBUILD_ZLIB=OFF
-DBUILD_TIFF=OFF
-DBUILD_JASPER=OFF
-DBUILD_JPEG=OFF
-DBUILD_PNG=OFF
-DBUILD_OPENEXR=OFF
-DBUILD_WEBP=OFF
-DBUILD_TBB=OFF
-DBUILD_IPP_IW=OFF
-DBUILD_ITT=OFF
-DWITH_AVFOUNDATION=OFF
-DWITH_CAP_IOS=OFF
-DWITH_CAROTENE=OFF
-DWITH_CPUFEATURES=OFF
-DWITH_EIGEN=OFF
-DWITH_FFMPEG=OFF
-DWITH_GSTREAMER=OFF
-DWITH_GTK=OFF
-DWITH_IPP=OFF
-DWITH_HALIDE=OFF
-DWITH_INF_ENGINE=OFF
-DWITH_NGRAPH=OFF
-DWITH_JASPER=OFF
-DWITH_JPEG=OFF
-DWITH_WEBP=OFF
-DWITH_OPENEXR=OFF
-DWITH_PNG=OFF
-DWITH_TIFF=OFF
-DWITH_OPENVX=OFF
-DWITH_GDCM=OFF
-DWITH_TBB=OFF
-DWITH_HPX=OFF
-DWITH_OPENMP=ON
-DWITH_PTHREADS_PF=OFF
-DWITH_V4L=OFF
-DWITH_CLP=OFF
-DWITH_OPENCL=OFF
-DWITH_OPENCL_SVM=OFF
-DWITH_ITT=OFF
-DWITH_PROTOBUF=OFF
-DWITH_IMGCODEC_HDR=OFF
-DWITH_IMGCODEC_SUNRASTER=OFF
-DWITH_IMGCODEC_PXM=OFF
-DWITH_QUIRC=OFF
-DWITH_TENGINE=OFF
-DBUILD_SHARED_LIBS=OFF
-DBUILD_opencv_apps=OFF
-DBUILD_ANDROID_PROJECTS=OFF
-DBUILD_ANDROID_EXAMPLES=OFF
-DBUILD_DOCS=OFF
-DBUILD_EXAMPLES=OFF
-DBUILD_PACKAGE=OFF
-DBUILD_PERF_TESTS=OFF
-DBUILD_TESTS=OFF
-DBUILD_WITH_STATIC_CRT=OFF
-DBUILD_FAT_JAVA_LIB=OFF
-DBUILD_ANDROID_SERVICE=OFF
-DBUILD_JAVA=OFF
-DENABLE_PRECOMPILED_HEADERS=OFF
-DENABLE_FAST_MATH=OFF
-DCV_TRACE=OFF
-DBUILD_opencv_java=OFF
-DBUILD_opencv_js=OFF
-DBUILD_opencv_ts=OFF
-DBUILD_opencv_python2=OFF
-DBUILD_opencv_python3=OFF
-DBUILD_opencv_dnn=OFF
-DBUILD_opencv_imgcodecs=OFF
-DBUILD_opencv_videoio=OFF
-DBUILD_opencv_calib3d=OFF
-DBUILD_opencv_flann=OFF
-DBUILD_opencv_objdetect=OFF
-DBUILD_opencv_stitching=OFF
-DBUILD_opencv_ml=OFF
-DBUILD_opencv_shape=OFF
-DBUILD_opencv_superres=OFF
-DBUILD_opencv_videostab=OFF

View File

@ -0,0 +1,83 @@
-DBUILD_ZLIB=OFF
-DBUILD_TIFF=OFF
-DBUILD_OPENJPEG=OFF
-DBUILD_JASPER=OFF
-DBUILD_JPEG=OFF
-DBUILD_PNG=OFF
-DBUILD_OPENEXR=OFF
-DBUILD_WEBP=OFF
-DBUILD_TBB=OFF
-DBUILD_IPP_IW=OFF
-DBUILD_ITT=OFF
-DWITH_AVFOUNDATION=OFF
-DWITH_CAP_IOS=OFF
-DWITH_CAROTENE=OFF
-DWITH_CPUFEATURES=OFF
-DWITH_EIGEN=OFF
-DWITH_FFMPEG=OFF
-DWITH_GSTREAMER=OFF
-DWITH_GTK=OFF
-DWITH_IPP=OFF
-DWITH_HALIDE=OFF
-DWITH_VULKAN=OFF
-DWITH_INF_ENGINE=OFF
-DWITH_NGRAPH=OFF
-DWITH_JASPER=OFF
-DWITH_OPENJPEG=OFF
-DWITH_JPEG=OFF
-DWITH_WEBP=OFF
-DWITH_OPENEXR=OFF
-DWITH_PNG=OFF
-DWITH_TIFF=OFF
-DWITH_OPENVX=OFF
-DWITH_GDCM=OFF
-DWITH_TBB=OFF
-DWITH_HPX=OFF
-DWITH_OPENMP=ON
-DWITH_PTHREADS_PF=OFF
-DWITH_V4L=OFF
-DWITH_CLP=OFF
-DWITH_OPENCL=OFF
-DWITH_OPENCL_SVM=OFF
-DWITH_ITT=OFF
-DWITH_PROTOBUF=OFF
-DWITH_IMGCODEC_HDR=OFF
-DWITH_IMGCODEC_SUNRASTER=OFF
-DWITH_IMGCODEC_PXM=OFF
-DWITH_IMGCODEC_PFM=OFF
-DWITH_QUIRC=OFF
-DWITH_ANDROID_MEDIANDK=OFF
-DWITH_TENGINE=OFF
-DWITH_ONNX=OFF
-DBUILD_SHARED_LIBS=OFF
-DBUILD_opencv_apps=OFF
-DBUILD_ANDROID_PROJECTS=OFF
-DBUILD_ANDROID_EXAMPLES=OFF
-DBUILD_DOCS=OFF
-DBUILD_EXAMPLES=OFF
-DBUILD_PACKAGE=OFF
-DBUILD_PERF_TESTS=OFF
-DBUILD_TESTS=OFF
-DBUILD_WITH_STATIC_CRT=OFF
-DBUILD_FAT_JAVA_LIB=OFF
-DBUILD_ANDROID_SERVICE=OFF
-DBUILD_JAVA=OFF
-DBUILD_OBJC=OFF
-DENABLE_PRECOMPILED_HEADERS=OFF
-DENABLE_FAST_MATH=OFF
-DCV_TRACE=OFF
-DBUILD_opencv_java=OFF
-DBUILD_opencv_gapi=OFF
-DBUILD_opencv_objc=OFF
-DBUILD_opencv_js=OFF
-DBUILD_opencv_ts=OFF
-DBUILD_opencv_python2=OFF
-DBUILD_opencv_python3=OFF
-DBUILD_opencv_dnn=OFF
-DBUILD_opencv_imgcodecs=OFF
-DBUILD_opencv_videoio=OFF
-DBUILD_opencv_calib3d=OFF
-DBUILD_opencv_flann=OFF
-DBUILD_opencv_objdetect=OFF
-DBUILD_opencv_stitching=OFF
-DBUILD_opencv_ml=OFF

View File

@ -0,0 +1,16 @@
set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_SYSTEM_PROCESSOR aarch64)
set(CMAKE_C_COMPILER "aarch64-linux-gnu-gcc")
set(CMAKE_CXX_COMPILER "aarch64-linux-gnu-g++")
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
set(CMAKE_C_FLAGS "-march=armv8-a")
set(CMAKE_CXX_FLAGS "-march=armv8-a")
# cache flags
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS}" CACHE STRING "c flags")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}" CACHE STRING "c++ flags")

View File

@ -0,0 +1,16 @@
set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_SYSTEM_PROCESSOR arm)
set(CMAKE_C_COMPILER "arm-linux-gnueabi-gcc")
set(CMAKE_CXX_COMPILER "arm-linux-gnueabi-g++")
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
set(CMAKE_C_FLAGS "-march=armv7-a -mfloat-abi=softfp -mfpu=neon-vfpv4")
set(CMAKE_CXX_FLAGS "-march=armv7-a -mfloat-abi=softfp -mfpu=neon-vfpv4")
# cache flags
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS}" CACHE STRING "c flags")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}" CACHE STRING "c++ flags")

View File

@ -0,0 +1,16 @@
set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_SYSTEM_PROCESSOR arm)
set(CMAKE_C_COMPILER "arm-linux-gnueabihf-gcc")
set(CMAKE_CXX_COMPILER "arm-linux-gnueabihf-g++")
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
set(CMAKE_C_FLAGS "-march=armv7-a -mfloat-abi=hard -mfpu=neon")
set(CMAKE_CXX_FLAGS "-march=armv7-a -mfloat-abi=hard -mfpu=neon")
# cache flags
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS}" CACHE STRING "c flags")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}" CACHE STRING "c++ flags")

View File

@ -0,0 +1,486 @@
# This file is part of the ios-cmake project. It was retrieved from
# https://github.com/cristeab/ios-cmake.git, which is a fork of
# https://code.google.com/p/ios-cmake/. Which in turn is based off of
# the Platform/Darwin.cmake and Platform/UnixPaths.cmake files which
# are included with CMake 2.8.4
#
# The ios-cmake project is licensed under the new BSD license.
#
# Copyright (c) 2014, Bogdan Cristea and LTE Engineering Software,
# Kitware, Inc., Insight Software Consortium. All rights reserved.
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
#
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
# 3. Neither the name of the copyright holder nor the names of its
# contributors may be used to endorse or promote products derived from
# this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
# COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#
# This file is based off of the Platform/Darwin.cmake and
# Platform/UnixPaths.cmake files which are included with CMake 2.8.4
# It has been altered for iOS development.
#
# Updated by Alex Stewart (alexs.mac@gmail.com)
#
# *****************************************************************************
# Now maintained by Alexander Widerberg (widerbergaren [at] gmail.com)
# under the BSD-3-Clause license
# https://github.com/leetal/ios-cmake
# *****************************************************************************
#
# INFORMATION / HELP
#
# The following variables control the behaviour of this toolchain:
#
# IOS_PLATFORM: OS (default) or SIMULATOR or SIMULATOR64 or TVOS or SIMULATOR_TVOS or WATCHOS or SIMULATOR_WATCHOS
# OS = Build for iPhoneOS.
# OS64 = Build for arm64 arm64e iPhoneOS.
# SIMULATOR = Build for x86 i386 iPhone Simulator.
# SIMULATOR64 = Build for x86_64 iPhone Simulator.
# TVOS = Build for AppleTVOS.
# SIMULATOR_TVOS = Build for x86_64 AppleTV Simulator.
# WATCHOS = Build for armv7k arm64_32 for WatchOS.
# SIMULATOR_WATCHOS = Build for x86_64 for Watch Simulator.
# CMAKE_OSX_SYSROOT: Path to the iOS SDK to use. By default this is
# automatically determined from IOS_PLATFORM and xcodebuild, but
# can also be manually specified (although this should not be required).
# CMAKE_IOS_DEVELOPER_ROOT: Path to the Developer directory for the iOS platform
# being compiled for. By default this is automatically determined from
# CMAKE_OSX_SYSROOT, but can also be manually specified (although this should
# not be required).
# ENABLE_BITCODE: (1|0) Enables or disables bitcode support. Default 1 (true)
# ENABLE_ARC: (1|0) Enables or disables ARC support. Default 1 (true, ARC enabled by default)
# ENABLE_VISIBILITY: (1|0) Enables or disables symbol visibility support. Default 0 (false, visibility hidden by default)
# IOS_ARCH: (armv7 armv7s armv7k arm64 arm64e arm64_32 i386 x86_64) If specified, will override the default architectures for the given IOS_PLATFORM
# OS = armv7 armv7s arm64 arm64e (if applicable)
# OS64 = arm64 arm64e (if applicable)
# SIMULATOR = i386 x86_64
# SIMULATOR64 = x86_64
# TVOS = arm64
# SIMULATOR_TVOS = x86_64 (i386 has since long been deprecated)
# WATCHOS = armv7k arm64_32 (if applicable)
# SIMULATOR_WATCHOS = x86_64 (i386 has since long been deprecated)
#
# This toolchain defines the following variables for use externally:
#
# XCODE_VERSION: Version number (not including Build version) of Xcode detected.
# IOS_SDK_VERSION: Version of iOS SDK being used.
# CMAKE_OSX_ARCHITECTURES: Architectures being compiled for (generated from
# IOS_PLATFORM).
#
# This toolchain defines the following macros for use externally:
#
# set_xcode_property (TARGET XCODE_PROPERTY XCODE_VALUE XCODE_VARIANT)
# A convenience macro for setting xcode specific properties on targets.
# Available variants are: All, Release, RelWithDebInfo, Debug, MinSizeRel
# example: set_xcode_property (myioslib IPHONEOS_DEPLOYMENT_TARGET "3.1" "all").
#
# find_host_package (PROGRAM ARGS)
# A macro used to find executable programs on the host system, not within the
# iOS environment. Thanks to the android-cmake project for providing the
# command.
# Fix for PThread library not in path
set(CMAKE_THREAD_LIBS_INIT "-lpthread")
set(CMAKE_HAVE_THREADS_LIBRARY 1)
set(CMAKE_USE_WIN32_THREADS_INIT 0)
set(CMAKE_USE_PTHREADS_INIT 1)
# Get the Xcode version being used.
execute_process(COMMAND xcodebuild -version
OUTPUT_VARIABLE XCODE_VERSION
ERROR_QUIET
OUTPUT_STRIP_TRAILING_WHITESPACE)
string(REGEX MATCH "Xcode [0-9\\.]+" XCODE_VERSION "${XCODE_VERSION}")
string(REGEX REPLACE "Xcode ([0-9\\.]+)" "\\1" XCODE_VERSION "${XCODE_VERSION}")
message(STATUS "Building with Xcode version: ${XCODE_VERSION}")
# Default to building for iPhoneOS if not specified otherwise, and we cannot
# determine the platform from the CMAKE_OSX_ARCHITECTURES variable. The use
# of CMAKE_OSX_ARCHITECTURES is such that try_compile() projects can correctly
# determine the value of IOS_PLATFORM from the root project, as
# CMAKE_OSX_ARCHITECTURES is propagated to them by CMake.
if (NOT DEFINED IOS_PLATFORM)
if (CMAKE_OSX_ARCHITECTURES)
if (CMAKE_OSX_ARCHITECTURES MATCHES ".*arm.*")
set(IOS_PLATFORM "OS")
elseif (CMAKE_OSX_ARCHITECTURES MATCHES "i386")
set(IOS_PLATFORM "SIMULATOR")
elseif (CMAKE_OSX_ARCHITECTURES MATCHES "x86_64")
set(IOS_PLATFORM "SIMULATOR64")
elseif (CMAKE_OSX_ARCHITECTURES MATCHES "armv7k")
set(IOS_PLATFORM "WATCHOS")
endif()
endif()
if (NOT IOS_PLATFORM)
set(IOS_PLATFORM "OS")
endif()
endif()
set(IOS_PLATFORM ${IOS_PLATFORM} CACHE STRING
"Type of iOS platform for which to build.")
# Determine the platform name and architectures for use in xcodebuild commands
# from the specified IOS_PLATFORM name.
if (IOS_PLATFORM STREQUAL "OS")
set(XCODE_IOS_PLATFORM iphoneos)
if(NOT IOS_ARCH)
if (XCODE_VERSION VERSION_GREATER 10.0)
set(IOS_ARCH armv7 armv7s arm64 arm64e)
else()
set(IOS_ARCH armv7 armv7s arm64)
endif()
endif()
elseif (IOS_PLATFORM STREQUAL "OS64")
set(XCODE_IOS_PLATFORM iphoneos)
if(NOT IOS_ARCH)
if (XCODE_VERSION VERSION_GREATER 10.0)
set(IOS_ARCH arm64 arm64e)
else()
set(IOS_ARCH arm64)
endif()
endif()
elseif (IOS_PLATFORM STREQUAL "SIMULATOR")
set(XCODE_IOS_PLATFORM iphonesimulator)
if(NOT IOS_ARCH)
set(IOS_ARCH i386 x86_64)
endif()
elseif(IOS_PLATFORM STREQUAL "SIMULATOR64")
set(XCODE_IOS_PLATFORM iphonesimulator)
if(NOT IOS_ARCH)
set(IOS_ARCH x86_64)
endif()
elseif (IOS_PLATFORM STREQUAL "TVOS")
set(XCODE_IOS_PLATFORM appletvos)
if(NOT IOS_ARCH)
set(IOS_ARCH arm64)
endif()
elseif (IOS_PLATFORM STREQUAL "SIMULATOR_TVOS")
set(XCODE_IOS_PLATFORM appletvsimulator)
if(NOT IOS_ARCH)
set(IOS_ARCH x86_64)
endif()
elseif (IOS_PLATFORM STREQUAL "WATCHOS")
set(XCODE_IOS_PLATFORM watchos)
if(NOT IOS_ARCH)
if (XCODE_VERSION VERSION_GREATER 10.0)
set(IOS_ARCH armv7k arm64_32)
else()
set(IOS_ARCH armv7k)
endif()
endif()
elseif (IOS_PLATFORM STREQUAL "SIMULATOR_WATCHOS")
set(XCODE_IOS_PLATFORM watchsimulator)
if(NOT IOS_ARCH)
set(IOS_ARCH x86_64)
endif()
else()
message(FATAL_ERROR "Invalid IOS_PLATFORM: ${IOS_PLATFORM}")
endif()
message(STATUS "Configuring iOS build for platform: ${IOS_PLATFORM}, "
"architecture(s): ${IOS_ARCH}")
# If user did not specify the SDK root to use, then query xcodebuild for it.
execute_process(COMMAND xcodebuild -version -sdk ${XCODE_IOS_PLATFORM} Path
OUTPUT_VARIABLE CMAKE_OSX_SYSROOT_INT
OUTPUT_QUIET ERROR_QUIET
OUTPUT_STRIP_TRAILING_WHITESPACE)
# If user did not specify the SDK root to use, then query xcodebuild for it.
if (NOT DEFINED CMAKE_OSX_SYSROOT OR (NOT CMAKE_OSX_SYSROOT STREQUAL CMAKE_OSX_SYSROOT_INT))
execute_process(COMMAND xcodebuild -version -sdk ${XCODE_IOS_PLATFORM} Path
OUTPUT_VARIABLE CMAKE_OSX_SYSROOT
ERROR_QUIET
OUTPUT_STRIP_TRAILING_WHITESPACE)
endif()
if (NOT EXISTS ${CMAKE_OSX_SYSROOT})
message(SEND_ERROR "Please make sure that Xcode is installed and that the toolchain"
"is pointing to the correct path. Please run:"
"sudo xcode-select -s /Applications/Xcode.app/Contents/Developer"
"and see if that fixes the problem for you.")
message(FATAL_ERROR "Invalid CMAKE_OSX_SYSROOT: ${CMAKE_OSX_SYSROOT} "
"does not exist.")
elseif(DEFINED CMAKE_OSX_SYSROOT)
message(STATUS "Using manually set SDK path: ${CMAKE_OSX_SYSROOT} for platform: ${IOS_PLATFORM}")
else()
message(STATUS "Using SDK: ${CMAKE_OSX_SYSROOT} for platform: ${IOS_PLATFORM}")
endif()
# Specify minimum version of deployment target.
if (NOT DEFINED IOS_DEPLOYMENT_TARGET)
if (IOS_PLATFORM STREQUAL "WATCHOS" OR IOS_PLATFORM STREQUAL "SIMULATOR_WATCHOS")
# Unless specified, SDK version 2.0 is used by default as minimum target version (watchOS).
set(IOS_DEPLOYMENT_TARGET "2.0"
CACHE STRING "Minimum iOS version to build for." )
else()
# Unless specified, SDK version 9.0 is used by default as minimum target version (iOS, tvOS).
set(IOS_DEPLOYMENT_TARGET "9.0"
CACHE STRING "Minimum iOS version to build for." )
endif()
message(STATUS "Using the default min-version since IOS_DEPLOYMENT_TARGET not provided!")
endif()
# Use bitcode or not
if (NOT DEFINED ENABLE_BITCODE AND NOT IOS_ARCH MATCHES "((^|, )(i386|x86_64))+")
# Unless specified, enable bitcode support by default
set(ENABLE_BITCODE TRUE CACHE BOOL "Whether or not to enable bitcode")
message(STATUS "Enabling bitcode support by default. ENABLE_BITCODE not provided!")
endif()
if (NOT DEFINED ENABLE_BITCODE)
message(STATUS "Disabling bitcode support by default on simulators. ENABLE_BITCODE not provided for override!")
endif()
# Use ARC or not
if (NOT DEFINED ENABLE_ARC)
# Unless specified, enable ARC support by default
set(ENABLE_ARC TRUE CACHE BOOL "Whether or not to enable ARC")
message(STATUS "Enabling ARC support by default. ENABLE_ARC not provided!")
endif()
# Use hidden visibility or not
if (NOT DEFINED ENABLE_VISIBILITY)
# Unless specified, disable symbols visibility by default
set(ENABLE_VISIBILITY FALSE CACHE BOOL "Whether or not to hide symbols (-fvisibility=hidden)")
message(STATUS "Hiding symbols visibility by default. ENABLE_VISIBILITY not provided!")
endif()
# Get the SDK version information.
execute_process(COMMAND xcodebuild -sdk ${CMAKE_OSX_SYSROOT} -version SDKVersion
OUTPUT_VARIABLE IOS_SDK_VERSION
ERROR_QUIET
OUTPUT_STRIP_TRAILING_WHITESPACE)
# Find the Developer root for the specific iOS platform being compiled for
# from CMAKE_OSX_SYSROOT. Should be ../../ from SDK specified in
# CMAKE_OSX_SYSROOT. There does not appear to be a direct way to obtain
# this information from xcrun or xcodebuild.
if (NOT CMAKE_IOS_DEVELOPER_ROOT)
get_filename_component(IOS_PLATFORM_SDK_DIR ${CMAKE_OSX_SYSROOT} PATH)
get_filename_component(CMAKE_IOS_DEVELOPER_ROOT ${IOS_PLATFORM_SDK_DIR} PATH)
endif()
if (NOT EXISTS ${CMAKE_IOS_DEVELOPER_ROOT})
message(FATAL_ERROR "Invalid CMAKE_IOS_DEVELOPER_ROOT: "
"${CMAKE_IOS_DEVELOPER_ROOT} does not exist.")
endif()
# Find the C & C++ compilers for the specified SDK.
if (NOT CMAKE_C_COMPILER)
execute_process(COMMAND xcrun -sdk ${CMAKE_OSX_SYSROOT} -find clang
OUTPUT_VARIABLE CMAKE_C_COMPILER
ERROR_QUIET
OUTPUT_STRIP_TRAILING_WHITESPACE)
message(STATUS "Using C compiler: ${CMAKE_C_COMPILER}")
endif()
if (NOT CMAKE_CXX_COMPILER)
execute_process(COMMAND xcrun -sdk ${CMAKE_OSX_SYSROOT} -find clang++
OUTPUT_VARIABLE CMAKE_CXX_COMPILER
ERROR_QUIET
OUTPUT_STRIP_TRAILING_WHITESPACE)
message(STATUS "Using CXX compiler: ${CMAKE_CXX_COMPILER}")
endif()
# Find (Apple's) libtool.
execute_process(COMMAND xcrun -sdk ${CMAKE_OSX_SYSROOT} -find libtool
OUTPUT_VARIABLE IOS_LIBTOOL
ERROR_QUIET
OUTPUT_STRIP_TRAILING_WHITESPACE)
message(STATUS "Using libtool: ${IOS_LIBTOOL}")
# Configure libtool to be used instead of ar + ranlib to build static libraries.
# This is required on Xcode 7+, but should also work on previous versions of
# Xcode.
set(CMAKE_C_CREATE_STATIC_LIBRARY
"${IOS_LIBTOOL} -static -o <TARGET> <LINK_FLAGS> <OBJECTS> ")
set(CMAKE_CXX_CREATE_STATIC_LIBRARY
"${IOS_LIBTOOL} -static -o <TARGET> <LINK_FLAGS> <OBJECTS> ")
# Get the version of Darwin (OS X) of the host.
execute_process(COMMAND uname -r
OUTPUT_VARIABLE CMAKE_HOST_SYSTEM_VERSION
ERROR_QUIET
OUTPUT_STRIP_TRAILING_WHITESPACE)
# Standard settings.
set(CMAKE_SYSTEM_NAME Darwin CACHE INTERNAL "")
set(CMAKE_SYSTEM_VERSION ${IOS_SDK_VERSION} CACHE INTERNAL "")
set(UNIX TRUE CACHE BOOL "")
set(APPLE TRUE CACHE BOOL "")
set(IOS TRUE CACHE BOOL "")
set(CMAKE_AR ar CACHE FILEPATH "" FORCE)
set(CMAKE_RANLIB ranlib CACHE FILEPATH "" FORCE)
# Force unset of OS X-specific deployment target (otherwise autopopulated),
# required as of cmake 2.8.10.
set(CMAKE_OSX_DEPLOYMENT_TARGET "" CACHE STRING
"Must be empty for iOS builds." FORCE)
# Set the architectures for which to build.
set(CMAKE_OSX_ARCHITECTURES ${IOS_ARCH} CACHE STRING "Build architecture for iOS")
# Change the type of target generated for try_compile() so it'll work when cross-compiling
set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY)
# All iOS/Darwin specific settings - some may be redundant.
set(CMAKE_SHARED_LIBRARY_PREFIX "lib")
set(CMAKE_SHARED_LIBRARY_SUFFIX ".dylib")
set(CMAKE_SHARED_MODULE_PREFIX "lib")
set(CMAKE_SHARED_MODULE_SUFFIX ".so")
set(CMAKE_C_COMPILER_ABI ELF)
set(CMAKE_CXX_COMPILER_ABI ELF)
set(CMAKE_C_HAS_ISYSROOT 1)
set(CMAKE_CXX_HAS_ISYSROOT 1)
set(CMAKE_MODULE_EXISTS 1)
set(CMAKE_DL_LIBS "")
set(CMAKE_C_OSX_COMPATIBILITY_VERSION_FLAG "-compatibility_version ")
set(CMAKE_C_OSX_CURRENT_VERSION_FLAG "-current_version ")
set(CMAKE_CXX_OSX_COMPATIBILITY_VERSION_FLAG "${CMAKE_C_OSX_COMPATIBILITY_VERSION_FLAG}")
set(CMAKE_CXX_OSX_CURRENT_VERSION_FLAG "${CMAKE_C_OSX_CURRENT_VERSION_FLAG}")
if(IOS_ARCH MATCHES "((^|, )(arm64|arm64e|x86_64))+")
set(CMAKE_C_SIZEOF_DATA_PTR 8)
set(CMAKE_CXX_SIZEOF_DATA_PTR 8)
message(STATUS "Using a data_ptr size of 8")
else()
set(CMAKE_C_SIZEOF_DATA_PTR 4)
set(CMAKE_CXX_SIZEOF_DATA_PTR 4)
message(STATUS "Using a data_ptr size of 4")
endif()
message(STATUS "Building for minimum iOS version: ${IOS_DEPLOYMENT_TARGET}"
" (SDK version: ${IOS_SDK_VERSION})")
# Note that only Xcode 7+ supports the newer more specific:
# -m${XCODE_IOS_PLATFORM}-version-min flags, older versions of Xcode use:
# -m(ios/ios-simulator)-version-min instead.
if (IOS_PLATFORM STREQUAL "OS" OR IOS_PLATFORM STREQUAL "OS64")
if (XCODE_VERSION VERSION_LESS 7.0)
set(XCODE_IOS_PLATFORM_VERSION_FLAGS
"-mios-version-min=${IOS_DEPLOYMENT_TARGET}")
else()
# Xcode 7.0+ uses flags we can build directly from XCODE_IOS_PLATFORM.
set(XCODE_IOS_PLATFORM_VERSION_FLAGS
"-m${XCODE_IOS_PLATFORM}-version-min=${IOS_DEPLOYMENT_TARGET}")
endif()
elseif (IOS_PLATFORM STREQUAL "TVOS")
set(XCODE_IOS_PLATFORM_VERSION_FLAGS
"-mtvos-version-min=${IOS_DEPLOYMENT_TARGET}")
elseif (IOS_PLATFORM STREQUAL "SIMULATOR_TVOS")
set(XCODE_IOS_PLATFORM_VERSION_FLAGS
"-mtvos-simulator-version-min=${IOS_DEPLOYMENT_TARGET}")
elseif (IOS_PLATFORM STREQUAL "WATCHOS")
set(XCODE_IOS_PLATFORM_VERSION_FLAGS
"-mwatchos-version-min=${IOS_DEPLOYMENT_TARGET}")
elseif (IOS_PLATFORM STREQUAL "SIMULATOR_WATCHOS")
set(XCODE_IOS_PLATFORM_VERSION_FLAGS
"-mwatchos-simulator-version-min=${IOS_DEPLOYMENT_TARGET}")
else()
# SIMULATOR or SIMULATOR64 both use -mios-simulator-version-min.
set(XCODE_IOS_PLATFORM_VERSION_FLAGS
"-mios-simulator-version-min=${IOS_DEPLOYMENT_TARGET}")
endif()
message(STATUS "Version flags set to: ${XCODE_IOS_PLATFORM_VERSION_FLAGS}")
if (ENABLE_BITCODE)
set(BITCODE "-fembed-bitcode")
set(HEADER_PAD "")
message(STATUS "Enabling bitcode support.")
else()
set(BITCODE "")
set(HEADER_PAD "-headerpad_max_install_names")
message(STATUS "Disabling bitcode support.")
endif()
if (ENABLE_ARC)
set(FOBJC_ARC "-fobjc-arc")
message(STATUS "Enabling ARC support.")
else()
set(FOBJC_ARC "-fno-objc-arc")
message(STATUS "Disabling ARC support.")
endif()
if (NOT ENABLE_VISIBILITY)
set(VISIBILITY "-fvisibility=hidden")
message(STATUS "Hiding symbols (-fvisibility=hidden).")
else()
set(VISIBILITY "")
endif()
set(CMAKE_C_FLAGS
"${XCODE_IOS_PLATFORM_VERSION_FLAGS} ${BITCODE} -fobjc-abi-version=2 ${FOBJC_ARC} ${CMAKE_C_FLAGS}")
# Hidden visibilty is required for C++ on iOS.
set(CMAKE_CXX_FLAGS
"${XCODE_IOS_PLATFORM_VERSION_FLAGS} ${BITCODE} ${VISIBILITY} -fvisibility-inlines-hidden -fobjc-abi-version=2 ${FOBJC_ARC} ${CMAKE_CXX_FLAGS}")
set(CMAKE_CXX_FLAGS_MINSIZEREL "${CMAKE_CXX_FLAGS} -DNDEBUG -Os -ffast-math ${BITCODE} ${CMAKE_CXX_FLAGS_MINSIZEREL}")
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS} -DNDEBUG -O2 -g -ffast-math ${BITCODE} ${CMAKE_CXX_FLAGS_RELWITHDEBINFO}")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS} -DNDEBUG -O3 -ffast-math ${BITCODE} ${CMAKE_CXX_FLAGS_RELEASE}")
set(CMAKE_C_LINK_FLAGS "${XCODE_IOS_PLATFORM_VERSION_FLAGS} -Wl,-search_paths_first ${CMAKE_C_LINK_FLAGS}")
set(CMAKE_CXX_LINK_FLAGS "${XCODE_IOS_PLATFORM_VERSION_FLAGS} -Wl,-search_paths_first ${CMAKE_CXX_LINK_FLAGS}")
# In order to ensure that the updated compiler flags are used in try_compile()
# tests, we have to forcibly set them in the CMake cache, not merely set them
# in the local scope.
list(APPEND VARS_TO_FORCE_IN_CACHE
CMAKE_C_FLAGS
CMAKE_CXX_FLAGS
CMAKE_CXX_FLAGS_RELWITHDEBINFO
CMAKE_CXX_FLAGS_MINSIZEREL
CMAKE_CXX_FLAGS_RELEASE
CMAKE_C_LINK_FLAGS
CMAKE_CXX_LINK_FLAGS)
foreach(VAR_TO_FORCE ${VARS_TO_FORCE_IN_CACHE})
set(${VAR_TO_FORCE} "${${VAR_TO_FORCE}}" CACHE STRING "")
endforeach()
set(CMAKE_PLATFORM_HAS_INSTALLNAME 1)
set (CMAKE_SHARED_LINKER_FLAGS "-rpath @executable_path/Frameworks -rpath @loader_path/Frameworks")
set(CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS "-dynamiclib ${HEADER_PAD}")
set(CMAKE_SHARED_MODULE_CREATE_C_FLAGS "-bundle ${HEADER_PAD}")
set(CMAKE_SHARED_MODULE_LOADER_C_FLAG "-Wl,-bundle_loader,")
set(CMAKE_SHARED_MODULE_LOADER_CXX_FLAG "-Wl,-bundle_loader,")
set(CMAKE_FIND_LIBRARY_SUFFIXES ".dylib" ".so" ".a")
# Hack: if a new cmake (which uses CMAKE_INSTALL_NAME_TOOL) runs on an old
# build tree (where install_name_tool was hardcoded) and where
# CMAKE_INSTALL_NAME_TOOL isn't in the cache and still cmake didn't fail in
# CMakeFindBinUtils.cmake (because it isn't rerun) hardcode
# CMAKE_INSTALL_NAME_TOOL here to install_name_tool, so it behaves as it did
# before, Alex.
if (NOT DEFINED CMAKE_INSTALL_NAME_TOOL)
find_program(CMAKE_INSTALL_NAME_TOOL install_name_tool)
endif (NOT DEFINED CMAKE_INSTALL_NAME_TOOL)
# Set the find root to the iOS developer roots and to user defined paths.
set(CMAKE_FIND_ROOT_PATH ${CMAKE_IOS_DEVELOPER_ROOT} ${CMAKE_OSX_SYSROOT}
${CMAKE_PREFIX_PATH} CACHE STRING "iOS find search path root" FORCE)
# Default to searching for frameworks first.
set(CMAKE_FIND_FRAMEWORK FIRST)
# Set up the default search directories for frameworks.
set(CMAKE_SYSTEM_FRAMEWORK_PATH
${CMAKE_OSX_SYSROOT}/System/Library/Frameworks
${CMAKE_OSX_SYSROOT}/System/Library/PrivateFrameworks
${CMAKE_OSX_SYSROOT}/Developer/Library/Frameworks)
# Only search the specified iOS SDK, not the remainder of the host filesystem.
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
# This little macro lets you set any XCode specific property.
macro(set_xcode_property TARGET XCODE_PROPERTY XCODE_VALUE XCODE_RELVERSION)
set(XCODE_RELVERSION_I "${XCODE_RELVERSION}")
if (XCODE_RELVERSION_I STREQUAL "All")
set_property(TARGET ${TARGET} PROPERTY
XCODE_ATTRIBUTE_${XCODE_PROPERTY} "${XCODE_VALUE}")
else()
set_property(TARGET ${TARGET} PROPERTY
XCODE_ATTRIBUTE_${XCODE_PROPERTY}[variant=${XCODE_RELVERSION_I}] "${XCODE_VALUE}")
endif()
endmacro(set_xcode_property)
# This macro lets you find executable programs on the host system.
macro(find_host_package)
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE NEVER)
set(IOS FALSE)
find_package(${ARGN})
set(IOS TRUE)
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
endmacro(find_host_package)

View File

@ -0,0 +1,29 @@
set(CMAKE_SYSTEM_NAME Darwin)
set(CMAKE_SYSTEM_PROCESSOR arm64)
set(UNIX TRUE)
set(APPLE TRUE)
set(CMAKE_AR ar CACHE FILEPATH "" FORCE)
set(CMAKE_RANLIB ranlib CACHE FILEPATH "" FORCE)
set(CMAKE_OSX_ARCHITECTURES "arm64" CACHE STRING "Build architecture")
# query xcodebuild for SDK root
execute_process(COMMAND xcodebuild -version -sdk macosx Path
OUTPUT_VARIABLE CMAKE_OSX_SYSROOT
ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE)
message(STATUS "Using SDK: ${CMAKE_OSX_SYSROOT}")
set(CMAKE_FIND_ROOT_PATH ${CMAKE_OSX_SYSROOT} CACHE STRING "find search path root" FORCE)
set(CMAKE_FIND_FRAMEWORK FIRST)
set(CMAKE_SYSTEM_FRAMEWORK_PATH
${CMAKE_OSX_SYSROOT}/System/Library/Frameworks
${CMAKE_OSX_SYSROOT}/System/Library/PrivateFrameworks
${CMAKE_OSX_SYSROOT}/Developer/Library/Frameworks
)
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)