mirror of
https://github.com/zebrajr/opencv.git
synced 2025-12-06 00:19:46 +01:00
update CPU detection on ANDROID patch
This commit is contained in:
parent
bb3a416320
commit
3dee87b697
24
3rdparty/cpufeatures/CMakeLists.txt
vendored
24
3rdparty/cpufeatures/CMakeLists.txt
vendored
|
|
@ -1,15 +1,18 @@
|
||||||
|
if(NOT ANDROID)
|
||||||
|
message("cpufeatures is ANDROID project")
|
||||||
|
endif()
|
||||||
|
|
||||||
ocv_include_directories(${CMAKE_CURRENT_SOURCE_DIR})
|
set(CPUFEATURES_ROOT "${CMAKE_CURRENT_SOURCE_DIR}" CACHE PATH "Android cpufeatures project sources (for example, <android-ndk>/sources/android/cpufeatures)")
|
||||||
file(GLOB cpuf_s *.c)
|
|
||||||
file(GLOB cpuf_h *.h)
|
|
||||||
|
|
||||||
set(lib_srcs ${cpuf_s})
|
set(CPUFEATURES_INCLUDE_DIRS ${CPUFEATURES_ROOT} CACHE INTERNAL "")
|
||||||
set(lib_hdrs ${cpuf_h})
|
set(CPUFEATURES_LIBRARIES cpufeatures CACHE INTERNAL "")
|
||||||
|
|
||||||
set(CPUFEATURES_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR} CACHE INTERNAL "")
|
if(NOT DEFINED CPUFEATURES_SOURCES)
|
||||||
set(CPUFEATURES_LIBRARIES cpufeatures CACHE INTERNAL "")
|
set(CPUFEATURES_SOURCES ${CPUFEATURES_ROOT}/cpu-features.c ${CPUFEATURES_ROOT}/cpu-features.h)
|
||||||
|
endif()
|
||||||
|
|
||||||
add_library(cpufeatures STATIC ${lib_srcs} ${lib_hdrs})
|
include_directories(${CPUFEATURES_INCLUDE_DIRS})
|
||||||
|
add_library(cpufeatures STATIC ${CPUFEATURES_SOURCES})
|
||||||
|
|
||||||
set_target_properties(cpufeatures
|
set_target_properties(cpufeatures
|
||||||
PROPERTIES OUTPUT_NAME cpufeatures
|
PROPERTIES OUTPUT_NAME cpufeatures
|
||||||
|
|
@ -17,8 +20,8 @@ set_target_properties(cpufeatures
|
||||||
COMPILE_PDB_NAME cpufeatures
|
COMPILE_PDB_NAME cpufeatures
|
||||||
COMPILE_PDB_NAME_DEBUG "cpufeatures${OPENCV_DEBUG_POSTFIX}"
|
COMPILE_PDB_NAME_DEBUG "cpufeatures${OPENCV_DEBUG_POSTFIX}"
|
||||||
ARCHIVE_OUTPUT_DIRECTORY ${3P_LIBRARY_OUTPUT_PATH}
|
ARCHIVE_OUTPUT_DIRECTORY ${3P_LIBRARY_OUTPUT_PATH}
|
||||||
)
|
)
|
||||||
|
|
||||||
if(ENABLE_SOLUTION_FOLDERS)
|
if(ENABLE_SOLUTION_FOLDERS)
|
||||||
set_target_properties(cpufeatures PROPERTIES FOLDER "3rdparty")
|
set_target_properties(cpufeatures PROPERTIES FOLDER "3rdparty")
|
||||||
endif()
|
endif()
|
||||||
|
|
@ -26,4 +29,3 @@ endif()
|
||||||
if(NOT BUILD_SHARED_LIBS)
|
if(NOT BUILD_SHARED_LIBS)
|
||||||
ocv_install_target(cpufeatures EXPORT OpenCVModules ARCHIVE DESTINATION ${OPENCV_3P_LIB_INSTALL_PATH} COMPONENT dev)
|
ocv_install_target(cpufeatures EXPORT OpenCVModules ARCHIVE DESTINATION ${OPENCV_3P_LIB_INSTALL_PATH} COMPONENT dev)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
|
|
||||||
13
3rdparty/cpufeatures/LICENSE
vendored
Normal file
13
3rdparty/cpufeatures/LICENSE
vendored
Normal file
|
|
@ -0,0 +1,13 @@
|
||||||
|
Copyright (C) 2016 The Android Open Source Project
|
||||||
|
|
||||||
|
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.
|
||||||
4
3rdparty/cpufeatures/README.md
vendored
Normal file
4
3rdparty/cpufeatures/README.md
vendored
Normal file
|
|
@ -0,0 +1,4 @@
|
||||||
|
The Android NDK provides a small library named cpufeatures that your app can use at runtime to detect the target device's CPU family and the optional features it supports.
|
||||||
|
It is designed to work as-is on all official Android platform versions.
|
||||||
|
|
||||||
|
https://developer.android.com/ndk/guides/cpu-features.html
|
||||||
2
3rdparty/libwebp/CMakeLists.txt
vendored
2
3rdparty/libwebp/CMakeLists.txt
vendored
|
|
@ -5,7 +5,7 @@
|
||||||
project(${WEBP_LIBRARY})
|
project(${WEBP_LIBRARY})
|
||||||
|
|
||||||
ocv_include_directories(${CMAKE_CURRENT_SOURCE_DIR})
|
ocv_include_directories(${CMAKE_CURRENT_SOURCE_DIR})
|
||||||
ocv_include_directories("${CPUFEATURES_INCLUDE_DIR}")
|
ocv_include_directories(${CPUFEATURES_INCLUDE_DIRS})
|
||||||
|
|
||||||
file(GLOB lib_srcs dec/*.c demux/*.c dsp/*.c enc/*.c mux/*.c utils/*.c webp/*.c)
|
file(GLOB lib_srcs dec/*.c demux/*.c dsp/*.c enc/*.c mux/*.c utils/*.c webp/*.c)
|
||||||
file(GLOB lib_hdrs dec/*.h demux/*.h dsp/*.h enc/*.h mux/*.h utils/*.h webp/*.h)
|
file(GLOB lib_hdrs dec/*.h demux/*.h dsp/*.h enc/*.h mux/*.h utils/*.h webp/*.h)
|
||||||
|
|
|
||||||
|
|
@ -98,6 +98,10 @@ if(POLICY CMP0042)
|
||||||
cmake_policy(SET CMP0042 NEW)
|
cmake_policy(SET CMP0042 NEW)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
if(POLICY CMP0046)
|
||||||
|
cmake_policy(SET CMP0046 OLD)
|
||||||
|
endif()
|
||||||
|
|
||||||
if(POLICY CMP0051)
|
if(POLICY CMP0051)
|
||||||
cmake_policy(SET CMP0051 NEW)
|
cmake_policy(SET CMP0051 NEW)
|
||||||
endif()
|
endif()
|
||||||
|
|
|
||||||
|
|
@ -32,10 +32,10 @@ source_group("Src" FILES "${OPENCV_MODULE_opencv_core_BINARY_DIR}/version_string
|
||||||
ocv_glob_module_sources(SOURCES "${OPENCV_MODULE_opencv_core_BINARY_DIR}/version_string.inc"
|
ocv_glob_module_sources(SOURCES "${OPENCV_MODULE_opencv_core_BINARY_DIR}/version_string.inc"
|
||||||
HEADERS ${lib_cuda_hdrs} ${lib_cuda_hdrs_detail})
|
HEADERS ${lib_cuda_hdrs} ${lib_cuda_hdrs_detail})
|
||||||
|
|
||||||
ocv_module_include_directories(${the_module} ${ZLIB_INCLUDE_DIRS} ${OPENCL_INCLUDE_DIRS} ${CPUFEATURES_INCLUDE_DIR})
|
ocv_module_include_directories(${the_module} ${ZLIB_INCLUDE_DIRS} ${OPENCL_INCLUDE_DIRS} ${CPUFEATURES_INCLUDE_DIRS})
|
||||||
ocv_create_module(${extra_libs})
|
ocv_create_module(${extra_libs})
|
||||||
|
|
||||||
ocv_target_link_libraries(${the_module} ${ZLIB_LIBRARIES} "${OPENCL_LIBRARIES}" "${VA_LIBRARIES}" "${LAPACK_LIBRARIES}" "${CPUFEATURES_LIBRARIES}")
|
ocv_target_link_libraries(${the_module} ${ZLIB_LIBRARIES} "${OPENCL_LIBRARIES}" "${VA_LIBRARIES}" "${LAPACK_LIBRARIES}" "${CPUFEATURES_LIBRARIES}")
|
||||||
|
|
||||||
ocv_add_accuracy_tests()
|
ocv_add_accuracy_tests()
|
||||||
ocv_add_perf_tests()
|
ocv_add_perf_tests()
|
||||||
|
|
|
||||||
|
|
@ -447,10 +447,16 @@ struct HWFeatures
|
||||||
CV_UNUSED(cpuid_data_ex);
|
CV_UNUSED(cpuid_data_ex);
|
||||||
#endif // OPENCV_HAVE_X86_CPUID
|
#endif // OPENCV_HAVE_X86_CPUID
|
||||||
|
|
||||||
#if defined ANDROID || defined __linux__
|
#if defined __ANDROID__ || defined __linux__
|
||||||
#ifdef __aarch64__
|
#ifdef __aarch64__
|
||||||
have[CV_CPU_NEON] = true;
|
have[CV_CPU_NEON] = true;
|
||||||
have[CV_CPU_FP16] = true;
|
have[CV_CPU_FP16] = true;
|
||||||
|
#elif defined __arm__ && defined __ANDROID__
|
||||||
|
__android_log_print(ANDROID_LOG_INFO, "OpenCV", "calling android_getCpuFeatures() ...");
|
||||||
|
uint64_t features = android_getCpuFeatures();
|
||||||
|
__android_log_print(ANDROID_LOG_INFO, "OpenCV", "calling android_getCpuFeatures() ... Done (%llx)", features);
|
||||||
|
have[CV_CPU_NEON] = (features & ANDROID_CPU_ARM_FEATURE_NEON) != 0;
|
||||||
|
have[CV_CPU_FP16] = (features & ANDROID_CPU_ARM_FEATURE_VFP_FP16) != 0;
|
||||||
#elif defined __arm__
|
#elif defined __arm__
|
||||||
int cpufile = open("/proc/self/auxv", O_RDONLY);
|
int cpufile = open("/proc/self/auxv", O_RDONLY);
|
||||||
|
|
||||||
|
|
@ -471,11 +477,6 @@ struct HWFeatures
|
||||||
|
|
||||||
close(cpufile);
|
close(cpufile);
|
||||||
}
|
}
|
||||||
#ifdef ANDROID
|
|
||||||
uint64_t features = android_getCpuFeatures();
|
|
||||||
have[CV_CPU_NEON] = (features & ANDROID_CPU_ARM_FEATURE_NEON) != 0;
|
|
||||||
have[CV_CPU_FP16] = (features & ANDROID_CPU_ARM_FEATURE_VFP_FP16) != 0;
|
|
||||||
#endif
|
|
||||||
#endif
|
#endif
|
||||||
#elif (defined __clang__ || defined __APPLE__)
|
#elif (defined __clang__ || defined __APPLE__)
|
||||||
#if (defined __ARM_NEON__ || (defined __ARM_NEON && defined __aarch64__))
|
#if (defined __ARM_NEON__ || (defined __ARM_NEON && defined __aarch64__))
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user