103 Commits

Autor SHA1 Mensagem Data
Andrey Kamaev f6ca38a579 Adjust Android Manager version from 2.2 to 2.3 2012-11-30 17:09:30 +04:00
Andrey Kamaev f12d945712 Remove compiled pdf files from source control
The documentation is available online at http://opencv.org/documentation.html
2012-11-30 14:56:00 +04:00
Andrey Kamaev 49c35fafc0 Adjust OpenCV version to 2.4.3.1 2012-11-30 14:33:28 +04:00
Andrey Kamaev 60a98aa5f7 Merge pull request #199 from apavlenko/remove_android_tutorial0
removing Android tutorial 0
2012-11-30 01:20:07 -08:00
Andrey Kamaev 677443f3ef Merge pull request #191 from asmorkalov:custom_cam_init 2012-11-30 12:53:26 +04:00
Andrey Pavlenko ea83d384c1 removing Android tutorial 0 since it has become irrelevant after moving to the new application framework 2012-11-30 12:32:16 +04:00
Andrey Kamaev bbfccb61f3 Merge pull request #198 from asmorkalov:disable_warp_tests 2012-11-29 20:29:22 +04:00
Alexander Smorkalov d36f8b9eb3 Code review comments applied
Sample renamed to CameraControl;
Picture taking added to show camera preview restart.
2012-11-29 18:26:57 +04:00
Alexander Smorkalov f6ff2b87fa Some perf tests on warping and resize disabled on Android
MatInfo_Size_Size.resizeDownLinear
MatInfo_Size_Size.resizeUpLinear
TestWarpPerspectiveNear_t.WarpPerspectiveNear
TestWarpPerspective.WarpPerspective
2012-11-29 18:21:22 +04:00
Andrey Kamaev 64bed2060a Merge pull request #194 from asmorkalov/v4l_fix
Patch #2323 applied
2012-11-29 01:27:34 -08:00
Andrey Kamaev 7e8fab0747 Merge pull request #195 from vpisarev/inv3x3_fix
now invert 3x3 on "bad" matrices works well on Windows
2012-11-29 01:27:27 -08:00
Andrey Kamaev c646bd4b7a Merge pull request #196 from jet47/gpu-bug-2581
fixed Bug #2581
2012-11-29 01:27:14 -08:00
Vladislav Vinogradov 362655b02a fixed Bug #2581
GoodFeaturesToTrackDetector_GPU fails when no corners found
2012-11-29 11:19:30 +04:00
Vadim Pisarevsky b57e801c04 now invert 3x3 on "bad" matrices works well on Windows 2012-11-28 23:05:51 +04:00
Alexander Smorkalov bb3d14e1a0 Patch #2323 "cap_libv4l.cpp clears default width and height after setting them" applied. 2012-11-28 21:53:39 +04:00
Andrey Kamaev 5047b3fba2 Merge pull request #193 from AnnaKogan8/perf-tests-increase-time-limits
Increased time limits for perf tests
2012-11-28 07:18:11 -08:00
Andrey Kamaev e1a4d22da6 Merge pull request #192 from taka-no-me/ndk_selection_fix
Android: always sort list of NDK toolchains
2012-11-28 07:17:49 -08:00
Anna Kogan 4e21f42714 increased time-limits 2012-11-28 18:17:33 +04:00
Anna Kogan 8877066846 increased time-limits 2012-11-28 18:17:33 +04:00
Andrey Kamaev 157cdeb443 Merge pull request #175 from taka-no-me:run_py 2012-11-28 12:44:05 +04:00
Andrey Kamaev ae149adb29 Merge pull request #190 from asmorkalov:ninja_fix 2012-11-27 23:41:30 +04:00
Andrey Kamaev cbe22fb5d1 Android: always sort list of NDK toolchains
Order returned by CMake is unreliable but we need clang to go after gcc for
automatic toolchain selection.
2012-11-27 18:16:36 +04:00
Alexander Smorkalov 86f7a357ae Tutorial-5 functionality implemented. 2012-11-27 18:06:43 +04:00
Alexander Smorkalov 24c920a33a Base for new sample added. 2012-11-27 18:06:43 +04:00
Andrey Kamaev 03f402892d Merge pull request #188 from asmorkalov:app_framework 2012-11-27 17:50:39 +04:00
Andrey Kamaev 930b580e0d Merge pull request #189 from wswld:2.4 2012-11-27 17:48:55 +04:00
Alexander Smorkalov 383e04d9e4 OpenCV Manager build via ninja (Bug #2575) fixed. 2012-11-27 17:30:05 +04:00
Vsevolod Glumov 0711e65972 Added a note to the android_dev_intro.rst. 2012-11-27 15:10:57 +04:00
Alexander Smorkalov 2e5a7284d2 Code review comments applied. 2012-11-27 14:55:49 +04:00
Alexander Smorkalov e95fc27490 Samples updated
In tutorial-1 fps meter enabled via layout.xml. Camera id is set to "any" via lauout.xml;
In tutorial-2 message moved ion the bottom of the screen.
2012-11-27 12:47:41 +04:00
Alexander Smorkalov 0efc32fc21 Attribure loading from layout improved.
OpenCV namespace added;
Default values for camera_id added;
Aditional constructor with cameraId added.
Resolution added to FPS message.
2012-11-27 12:47:41 +04:00
Alexander Smorkalov 8266eab8b4 OpenCV app framework improved
FPS meter added;
Camera switching posibility added;
Attributes loading for layout filed implemented.
2012-11-27 12:47:41 +04:00
Andrey Kamaev 214629b220 Merge pull request #187 from vpisarev:doc_fixes_2.4 2012-11-26 22:33:01 +04:00
Andrey Kamaev dc3aa27be4 Merge pull request #183 from apavlenko:perf/android_filters_accuracy 2012-11-26 22:32:38 +04:00
Andrey Kamaev 8286e1a5f7 Merge pull request #185 from apavlenko:bug2569/simplify_samples_jni_code 2012-11-26 22:32:22 +04:00
Andrey Pavlenko c36dcbcada Increase accuracy interval for image filters on Android and other platforms when sensible 2012-11-26 22:29:05 +04:00
Vadim Pisarevsky db965353f4 fixed a few compile errors/warnings in 2.4 branch of the docs 2012-11-26 18:48:23 +04:00
marina.kolpakova 39da17a02a Merge pull requst #177 from cuda-geek/another-one-integral-fix 2012-11-26 18:10:21 +04:00
marina.kolpakova a22edb037f fixed typo 2012-11-26 17:57:56 +04:00
Andrey Pavlenko b19f672843 (#2569) simplifying code to avoid Eclipse CDT editor confusion, removing warnings and typos in comments 2012-11-26 17:32:10 +04:00
marina.kolpakova 7df45c0dcc remove unnecessary copying in SURF 2012-11-25 03:26:50 +04:00
marina.kolpakova 91913364d6 reintegrate warp shuffle based integral 2012-11-25 03:21:51 +04:00
marina.kolpakova 5460cee9e9 fix cascade classifier GFF NMS for empty candidates vector 2012-11-25 03:19:24 +04:00
Andrey Kamaev 23011ffd81 Merge pull request #179 from cuda-geek:usr-bin-env-python 2012-11-24 19:24:01 +04:00
Andrey Kamaev 6eed90e5e8 Merge pull request #180 from mdim:fix_compile_error 2012-11-24 19:22:02 +04:00
Andrey Kamaev 901c0d80c3 Merge pull request #178 from cuda-geek:fix-2504 2012-11-24 19:20:53 +04:00
Maria Dimashova 97e36b9375 fix a compile error in case of building without highgui 2012-11-24 18:10:29 +04:00
marina.kolpakova 68d04d28b6 replace offsets in surf to simple copy for better speed 2012-11-24 16:50:29 +04:00
Andrey Kamaev 8daebeac8a run.py: add --check option for easy run of sanity checks 2012-11-24 14:12:32 +04:00
Andrey Kamaev 9db1d9ba13 run.py: improve handling of multiple Android devices
* do not lose auto-selected device while running several tests
* reduce output noise
* list available devices if unable to auto-select device
* fix error message when no devices connected
2012-11-24 14:11:07 +04:00
marina.kolpakova be0c20b758 align grid by 4 2012-11-24 01:55:03 +04:00
marina.kolpakova fceb62386d fix for 2504: WITH_CUDA disabled with OSX in 2.4.3. 2012-11-23 23:11:44 +04:00
marina.kolpakova 285d6320be add #/usr/bin/env python to all python files 2012-11-23 22:57:22 +04:00
Andrey Kamaev f45b5b13f1 Merge pull request #172 from asmorkalov:default_cam_lib_path 2012-11-23 14:31:04 +04:00
Andrey Kamaev 081887ee16 Merge pull request #174 from asmorkalov:full_sreen_fix 2012-11-23 14:30:48 +04:00
Alexander Smorkalov 2c67731a7b Issue #2549 OpenCV Samples does not expand on full screen fixed.
All samples use application style in android manifest instead of system calls in onCreate event now.
2012-11-23 13:12:11 +04:00
Alexander Smorkalov 3282e08f55 Default native library path for native camera updated.
New versions tries to search library in arm-v7a and Manager packages only.
2012-11-22 12:40:25 +04:00
Alexander Smorkalov 845e52b676 OpenCV Manager headers refactoring.
All constants moved to android independent header file.
2012-11-22 12:39:06 +04:00
Andrey Kamaev 8579666b03 Merge pull request #171 from asmorkalov:android_8_neon_fix 2012-11-21 14:55:38 +04:00
Andrey Kamaev 24af691843 Merge pull request #168 from asmorkalov:android_42_camera_fix 2012-11-21 14:50:53 +04:00
Alexander Smorkalov 8ecd22ba48 Automatic minsdkversion setup added;
Linker problems on armeabi-v7a+NEON with Android 2.2 fixed;
2012-11-21 14:03:11 +04:00
Vadim Pisarevsky c31f106012 Merge branch 'ParallelVideoStreams' of https://github.com/ilya-lavrenov/opencv into 2.4 2012-11-21 11:43:18 +04:00
Alexander Smorkalov aa4e6a8a83 Issue #2547 Native camera does not work on Google Nexus 7 with Android 4.2 fixed;
Issue #2506 Unnecessary log printouts in OpenCV::camera fixed;
Native camera for MIPS Android 4.1.1 added.
Build script for camera updated.
2012-11-21 11:37:29 +04:00
Andrey Kamaev d559c18ee5 Merge pull request #161 from apavlenko:fix/sdk_r21 2012-11-20 19:07:08 +04:00
Andrey Pavlenko cfd634ca3e Improving compatibility with the latest Android SDK (r21) and NDK (r8c).
- Adding Android SDK/ADT r21 compatibility;
- fixing stl headers path for new ndk;
- fixing native API level for Android projects
2012-11-20 18:40:22 +04:00
Andrey Kamaev 4fce5a5e83 Merge pull request #170 from asmorkalov:engine_build_fix 2012-11-20 18:27:43 +04:00
Andrey Kamaev 934b623fa9 Merging pull request #169 from taka-no-me:android-ndk-r8c 2012-11-20 17:56:12 +04:00
Andrey Kamaev d3397a1d6d Merging pull request #167 from asmorkalov:java_api_manager_test 2012-11-20 17:53:06 +04:00
Alexander Smorkalov 5b148083fe Libinfo build fix;
Libinfo revision formating fix;
HW dependent VersionCode for Manager implemented.
2012-11-20 17:39:45 +04:00
Andrey Kamaev f172947ed5 Merging pull request #162 from taka-no-me/opencv 2012-11-20 17:33:34 +04:00
Andrey Kamaev 5527fc62f4 'Merging pull request 163 from asmorkalov/opencv' 2012-11-20 17:23:02 +04:00
Andrey Kamaev 04481d9ef4 Fix Android build with clang compiler 2012-11-20 15:20:04 +04:00
Andrey Kamaev ab9311947a Update Android CMake toolchain for NDK r8c 2012-11-20 15:20:04 +04:00
Alexander Smorkalov 66a1ea7604 Test execution inside Eclipse fixed;
OpenCV testing via OpenCV Manager implemented.
2012-11-20 10:45:46 +04:00
Ilya Lavrenov 4abf0b3193 thread-safe VideoWriter and VideoCapture 2012-11-19 16:44:23 +04:00
Alexander Smorkalov 1f1d43fc88 Issue #2548 Missing static library libtbb.a for armeabi and mips build fixed. 2012-11-19 12:58:17 +04:00
Andrey Kamaev 9ca1162be8 Update URL for TBB download. Update to TBB 4.1 update 1 2012-11-19 11:43:28 +04:00
Andrey Kamaev 6cd70c83fb Merge pull request #160 from asmorkalov/android_4_2_manager_fix 2012-11-16 17:44:34 +04:00
Andrey Kamaev f6f1861a2f Merge pull request #159 from asmorkalov/libinfo_install_fix 2012-11-16 17:44:02 +04:00
Andrey Kamaev 590d1d8118 Merge pull request #157 from vpisarev/bug_fixes5 2012-11-16 17:43:21 +04:00
Alexander Smorkalov 759863d95c Issue #2537 OpenCV Manager doesn't work on Android 4.2 fixed. 2012-11-16 17:01:25 +04:00
Alexander Smorkalov 1e0bff3268 Issue #2541 make install does not work for Android build fixed. 2012-11-15 11:24:41 +04:00
Alexander Mordvintsev 9cfa51a483 added CV_OUT to StereoVar output paramiter 2012-11-13 23:17:54 +04:00
Andrey Kamaev 72a63922d2 Merge pull request #156 from jet47/gpu-hough-lines-fix 2012-11-13 18:24:36 +04:00
Andrey Kamaev e4fb680566 Merge pull request #155 from jet47/gpu-test-fix 2012-11-13 18:23:52 +04:00
Andrey Kamaev 5bc66ec8e4 Merge pull request #149 from taka-no-me/osx_warnings 2012-11-13 18:21:40 +04:00
Andrey Kamaev a218507586 Merge pull request #148 from taka-no-me/tutorial_codes 2012-11-13 18:20:49 +04:00
Andrey Kamaev 8ba9289a2c Merge pull request #146 from taka-no-me/win_opengl 2012-11-13 18:19:42 +04:00
Andrey Kamaev 4d6bdc1533 Merge pull request #145 from taka-no-me/vec_print 2012-11-13 18:18:48 +04:00
Andrey Kamaev c803cbb93b Merge pull request #143 from vpisarev/bug_fixes4 2012-11-13 18:17:33 +04:00
Andrey Kamaev 7e301c5c0e Merge pull request #141 from jet47/gpu-pyrlk-fix 2012-11-13 18:16:19 +04:00
Andrey Kamaev b5e009eb87 Merge pull request #144 from asmorkalov/fd_package_fix_2.4 2012-11-13 18:13:33 +04:00
Vladislav Vinogradov a9919e01d0 fixed bug in gpu::HoughLines 2012-11-13 17:54:17 +04:00
Vladislav Vinogradov 606c23b9aa fixed gpu module tests
uses old CommandLineParser class
2012-11-13 17:50:29 +04:00
Andrey Kamaev a126532cb7 Fix OS X build warnings 2012-11-09 11:29:52 +04:00
Andrey Kamaev dad56e202f Rename sample & tutorial executables 2012-11-09 10:15:48 +04:00
Andrey Kamaev b131dfeecd Build tutorial codes together with other samples
These codes should be included into regular builds.
2012-11-09 10:15:48 +04:00
Andrey Kamaev 8c9c2b3a03 Fix build on Windows with OpenGl enabled
There was missing windows.h include in OpenGL interop code.
2012-11-09 10:00:24 +04:00
Andrey Kamaev e5ffbf9498 Fix stream output operator for Vec<uchar,n>
This fixes output for 8U and 8S vector depths.
They were mistakenly printed as characters instead of numbers.
2012-11-09 09:54:43 +04:00
Alexander Smorkalov 91a9923dcf Face detection package name replaced on org.opencv.facedetect for consistency with Google Play package. 2012-11-09 09:40:19 +04:00
Vadim Pisarevsky 2e54e2a586 fixed problem with LBPHFaceRecognizer::update() without breaking binary compatibility. 2012-11-08 16:15:04 +04:00
Vadim Pisarevsky 9163471987 improved accuracy of 3x3 invert on poorly-conditioned matrices (bug #2525) 2012-11-08 14:09:43 +04:00
Vladislav Vinogradov a0be7b57f5 fixed bug in gpu::PyrLKOpticalFlow::dense
vector index out of range
2012-11-07 17:13:19 +04:00
329 arquivos alterados com 2403 adições e 147839 exclusões
externo Arquivo normal → Arquivo executável
Ver Arquivo
externo Arquivo normal → Arquivo executável
Ver Arquivo
BIN
Ver Arquivo
Arquivo binário não exibido.
externo Arquivo normal → Arquivo executável
Ver Arquivo
BIN
Ver Arquivo
Arquivo binário não exibido.
externo Arquivo normal → Arquivo executável
Ver Arquivo
BIN
Ver Arquivo
Arquivo binário não exibido.
BIN
Ver Arquivo
Arquivo binário não exibido.
externo Arquivo normal → Arquivo executável
Ver Arquivo
BIN
Ver Arquivo
Arquivo binário não exibido.
+1
Ver Arquivo
@@ -24,6 +24,7 @@ if(WIN32 AND NOT MINGW)
endif(WIN32 AND NOT MINGW)
ocv_warnings_disable(CMAKE_C_FLAGS -Wno-implicit-function-declaration -Wno-uninitialized -Wmissing-prototypes -Wmissing-declarations -Wunused -Wshadow -Wsign-compare)
ocv_warnings_disable(CMAKE_C_FLAGS -Wunused-parameter) # clang
ocv_warnings_disable(CMAKE_C_FLAGS /wd4013 /wd4018 /wd4101 /wd4244 /wd4267 /wd4715) # vs2005
if(UNIX)
+1
Ver Arquivo
@@ -26,6 +26,7 @@ if(CMAKE_COMPILER_IS_GNUCXX)
endif()
ocv_warnings_disable(CMAKE_C_FLAGS -Wcast-align -Wshadow -Wunused)
ocv_warnings_disable(CMAKE_C_FLAGS -Wunused-parameter) # clang
set_target_properties(${JPEG_LIBRARY}
PROPERTIES OUTPUT_NAME ${JPEG_LIBRARY}
+1
Ver Arquivo
@@ -89,6 +89,7 @@ endif(WIN32)
ocv_warnings_disable(CMAKE_C_FLAGS -Wno-unused-but-set-variable -Wmissing-prototypes -Wmissing-declarations -Wundef -Wunused -Wsign-compare
-Wcast-align -Wshadow -Wno-maybe-uninitialized -Wno-pointer-to-int-cast -Wno-int-to-pointer-cast)
ocv_warnings_disable(CMAKE_C_FLAGS -Wunused-parameter) # clang
ocv_warnings_disable(CMAKE_CXX_FLAGS -Wmissing-declarations -Wunused-parameter)
ocv_warnings_disable(CMAKE_CXX_FLAGS /wd4018 /wd4100 /wd4127 /wd4311 /wd4701 /wd4706) # vs2005
ocv_warnings_disable(CMAKE_CXX_FLAGS /wd4244) # vs2008
+20 -9
Ver Arquivo
@@ -5,40 +5,46 @@ endif()
project(tbb)
# 4.1 - works fine
set(tbb_ver "tbb41_20120718oss")
set(tbb_url "http://threadingbuildingblocks.org/uploads/77/188/4.1/tbb41_20120718oss_src.tgz")
set(tbb_md5 "31b9ec300f3d09da2504d5d882788dd4")
# 4.1 update 1 - works fine
set(tbb_ver "tbb41_20121003oss")
set(tbb_url "http://threadingbuildingblocks.org/sites/default/files/software_releases/source/tbb41_20121003oss_src.tgz")
set(tbb_md5 "2a684fefb855d2d0318d1ef09afa75ff")
set(tbb_version_file "version_string.ver")
# 4.1 - works fine
#set(tbb_ver "tbb41_20120718oss")
#set(tbb_url "http://threadingbuildingblocks.org/sites/default/files/software_releases/source/tbb41_20120718oss_src.tgz")
#set(tbb_md5 "31b9ec300f3d09da2504d5d882788dd4")
#set(tbb_version_file "version_string.ver")
# 4.0 update 5 - works fine
#set(tbb_ver "tbb40_20120613oss")
#set(tbb_url "http://threadingbuildingblocks.org/uploads/77/187/4.0%20update%205/tbb40_20120613oss_src.tgz")
#set(tbb_url "http://threadingbuildingblocks.org/sites/default/files/software_releases/source/tbb40_20120613oss_src.tgz")
#set(tbb_md5 "da01ed74944ec5950cfae3476901a172")
#set(tbb_version_file "version_string.ver")
# 4.0 update 4 - works fine
#set(tbb_ver "tbb40_20120408oss")
#set(tbb_url "http://threadingbuildingblocks.org/uploads/77/185/4.0%20update%204/tbb40_20120408oss_src.tgz")
#set(tbb_url "http://threadingbuildingblocks.org/sites/default/files/software_releases/source/tbb40_20120408oss_src.tgz")
#set(tbb_md5 "734b356da7fe0ed308741f3e6018251e")
#set(tbb_version_file "version_string.ver")
# 4.0 update 3 - build broken
#set(tbb_ver "tbb40_20120201oss")
#set(tbb_url "http://threadingbuildingblocks.org/uploads/77/182/4.0%20update%203/tbb40_20120201oss_src.tgz")
#set(tbb_url "http://threadingbuildingblocks.org/sites/default/files/software_releases/source/tbb40_20120201oss_src.tgz")
#set(tbb_md5 "4669e7d4adee018de7a7b8b972987218")
#set(tbb_version_file "version_string.tmp")
# 4.0 update 2 - works fine
#set(tbb_ver "tbb40_20111130oss")
#set(tbb_url "http://threadingbuildingblocks.org/uploads/77/180/4.0%20update%202/tbb40_20111130oss_src.tgz")
#set(tbb_url "http://threadingbuildingblocks.org/sites/default/files/software_releases/source/tbb40_20111130oss_src.tgz")
#set(tbb_md5 "1e6926b21e865e79772119cd44fc3ad8")
#set(tbb_version_file "version_string.tmp")
#set(tbb_need_GENERIC_DWORD_LOAD_STORE TRUE)
# 4.0 update 1 - works fine
#set(tbb_ver "tbb40_20111003oss")
#set(tbb_url "http://threadingbuildingblocks.org/uploads/77/177/4.0%20update%201/tbb40_20111003oss_src.tgz")
#set(tbb_url "http://threadingbuildingblocks.org/sites/default/files/software_releases/source/tbb40_20111003oss_src.tgz")
#set(tbb_md5 "7b5d94eb35a563b29ef402e0fd8f15c9")
#set(tbb_version_file "version_string.tmp")
#set(tbb_need_GENERIC_DWORD_LOAD_STORE TRUE)
@@ -123,6 +129,11 @@ add_definitions(-D__TBB_DYNAMIC_LOAD_ENABLED=0 #required
-DDO_ITT_NOTIFY=0 #it seems that we don't need these notifications
)
if(ANDROID_COMPILER_IS_CLANG)
add_definitions(-D__TBB_GCC_BUILTIN_ATOMICS_PRESENT=1)
ocv_warnings_disable(CMAKE_CXX_FLAGS -Wmissing-prototypes)
endif()
if(tbb_need_GENERIC_DWORD_LOAD_STORE)
#needed by TBB 4.0 update 1,2; fixed in TBB 4.0 update 3 but it has 2 new problems
add_definitions(-D__TBB_USE_GENERIC_DWORD_LOAD_STORE=1)
+1 -1
Ver Arquivo
@@ -467,7 +467,7 @@ if(BUILD_ANDROID_PACKAGE)
add_subdirectory(android/package)
endif()
if (ANDROID AND NOT BUILD_ANDROID_SERVICE AND NOT BUILD_ANDROID_PACKAGE AND NOT BUILD_CAMERA_WRAPER)
if (ANDROID)
add_subdirectory(android/libinfo)
endif()
+311 -162
Ver Arquivo
@@ -1,7 +1,37 @@
# Copyright (c) 2010-2011, Ethan Rublee
# Copyright (c) 2011-2012, Andrey Kamaev
# 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. The name of the copyright holders 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.
# ------------------------------------------------------------------------------
# Android CMake toolchain file, for use with the Android NDK r5-r8
# Requires cmake 2.6.3 or newer (2.8.5 or newer is recommended).
# See home page: http://code.google.com/p/android-cmake/
# See home page: https://github.com/taka-no-me/android-cmake
#
# The file is mantained by the OpenCV project. The latest version can be get at
# http://code.opencv.org/projects/opencv/repository/revisions/master/changes/android/android.toolchain.cmake
@@ -64,6 +94,20 @@
# ANDROID_NATIVE_API_LEVEL=android-8 - level of Android API compile for.
# Option is read-only when standalone toolchain is used.
#
# ANDROID_TOOLCHAIN_NAME=arm-linux-androideabi-4.6 - the name of compiler
# toolchain to be used. The list of possible values depends on the NDK
# version. For NDK r8c the possible values are:
#
# * arm-linux-androideabi-4.4.3
# * arm-linux-androideabi-4.6
# * arm-linux-androideabi-clang3.1
# * mipsel-linux-android-4.4.3
# * mipsel-linux-android-4.6
# * mipsel-linux-android-clang3.1
# * x86-4.4.3
# * x86-4.6
# * x86-clang3.1
#
# ANDROID_FORCE_ARM_BUILD=OFF - set ON to generate 32-bit ARM instructions
# instead of Thumb. Is not available for "x86" (inapplicable) and
# "armeabi-v6 with VFP" (is forced to be ON) ABIs.
@@ -147,13 +191,9 @@
# under the ${LIBRARY_OUTPUT_PATH_ROOT}/libs/${ANDROID_NDK_ABI_NAME}
# (depending on the target ABI). This is convenient for Android packaging.
#
# Authors:
# Ethan Rublee ethan.ruble@gmail.com
# Andrey Kamaev andrey.kamaev@itseez.com
#
# Change Log:
# - initial version December 2010
# - modified April 2011
# - April 2011
# [+] added possibility to build with NDK (without standalone toolchain)
# [+] support cross-compilation on Windows (native, no cygwin support)
# [+] added compiler option to force "char" type to be signed
@@ -164,13 +204,13 @@
# [+] EXECUTABLE_OUTPUT_PATH is set by toolchain (required on Windows)
# [~] Fixed bug with ANDROID_API_LEVEL variable
# [~] turn off SWIG search if it is not found first time
# - modified May 2011
# - May 2011
# [~] ANDROID_LEVEL is renamed to ANDROID_API_LEVEL
# [+] ANDROID_API_LEVEL is detected by toolchain if not specified
# [~] added guard to prevent changing of output directories on the first
# cmake pass
# [~] toolchain exits with error if ARM_TARGET is not recognized
# - modified June 2011
# - June 2011
# [~] default NDK path is updated for version r5c
# [+] variable CMAKE_SYSTEM_PROCESSOR is set based on ARM_TARGET
# [~] toolchain install directory is added to linker paths
@@ -178,13 +218,13 @@
# [+] added macro find_host_package, find_host_program to search
# packages/programs on the host system
# [~] fixed path to STL library
# - modified July 2011
# - July 2011
# [~] fixed options caching
# [~] search for all supported NDK versions
# [~] allowed spaces in NDK path
# - modified September 2011
# - September 2011
# [~] updated for NDK r6b
# - modified November 2011
# - November 2011
# [*] rewritten for NDK r7
# [+] x86 toolchain support (experimental)
# [+] added "armeabi-v6 with VFP" ABI for ARMv6 processors.
@@ -197,37 +237,37 @@
# [~] ARM_TARGET is renamed to ANDROID_ABI
# [~] ARMEABI_NDK_NAME is renamed to ANDROID_NDK_ABI_NAME
# [~] ANDROID_API_LEVEL is renamed to ANDROID_NATIVE_API_LEVEL
# - modified January 2012
# - January 2012
# [+] added stlport_static support (experimental)
# [+] added special check for cygwin
# [+] filtered out hidden files (starting with .) while globbing inside NDK
# [+] automatically applied GLESv2 linkage fix for NDK revisions 5-6
# [+] added ANDROID_GET_ABI_RAWNAME to get NDK ABI names by CMake flags
# - modified February 2012
# - February 2012
# [+] updated for NDK r7b
# [~] fixed cmake try_compile() command
# [~] Fix for missing install_name_tool on OS X
# - modified March 2012
# - March 2012
# [~] fixed incorrect C compiler flags
# [~] fixed CMAKE_SYSTEM_PROCESSOR change on ANDROID_ABI change
# [+] improved toolchain loading speed
# [+] added assembler language support (.S)
# [+] allowed preset search paths and extra search suffixes
# - modified April 2012
# - April 2012
# [+] updated for NDK r7c
# [~] fixed most of problems with compiler/linker flags and caching
# [+] added option ANDROID_FUNCTION_LEVEL_LINKING
# - modified May 2012
# - May 2012
# [+] updated for NDK r8
# [+] added mips architecture support
# - modified August 2012
# - August 2012
# [+] updated for NDK r8b
# [~] all intermediate files generated by toolchain are moved to CMakeFiles
# [~] libstdc++ and libsupc are removed from explicit link libraries
# [+] added CCache support (via NDK_CCACHE environment or cmake variable)
# [+] added gold linker support for NDK r8b
# [~] fixed mips linker flags for NDK r8b
# - modified September 2012
# - September 2012
# [+] added NDK release name detection (see ANDROID_NDK_RELEASE)
# [+] added support for all C++ runtimes from NDK
# (system, gabi++, stlport, gnustl)
@@ -235,8 +275,11 @@
# [~] use gold linker as default if available (NDK r8b)
# [~] globally turned off rpath
# [~] compiler options are aligned with NDK r8b
# - modified October 2012
# - October 2012
# [~] fixed C++ linking: explicitly link with math library (OpenCV #2426)
# - November 2012
# [+] updated for NDK r8c
# [+] added support for clang compiler
# ------------------------------------------------------------------------------
cmake_minimum_required( VERSION 2.6.3 )
@@ -259,7 +302,7 @@ set( CMAKE_SYSTEM_VERSION 1 )
# rpath makes low sence for Android
set( CMAKE_SKIP_RPATH TRUE CACHE BOOL "If set, runtime paths are not added when using shared libraries." )
set( ANDROID_SUPPORTED_NDK_VERSIONS ${ANDROID_EXTRA_NDK_VERSIONS} -r8b -r8 -r7c -r7b -r7 -r6b -r6 -r5c -r5b -r5 "" )
set( ANDROID_SUPPORTED_NDK_VERSIONS ${ANDROID_EXTRA_NDK_VERSIONS} -r8c -r8b -r8 -r7c -r7b -r7 -r6b -r6 -r5c -r5b -r5 "" )
if(NOT DEFINED ANDROID_NDK_SEARCH_PATHS)
if( CMAKE_HOST_WIN32 )
file( TO_CMAKE_PATH "$ENV{PROGRAMFILES}" ANDROID_NDK_SEARCH_PATHS )
@@ -367,8 +410,8 @@ endmacro()
macro( __DETECT_TOOLCHAIN_MACHINE_NAME _var _root )
if( EXISTS "${_root}" )
file( GLOB __gccExePath "${_root}/bin/*-gcc${TOOL_OS_SUFFIX}" )
__LIST_FILTER( __gccExePath "bin/[.].*-gcc${TOOL_OS_SUFFIX}$" )
file( GLOB __gccExePath RELATIVE "${_root}/bin/" "${_root}/bin/*-gcc${TOOL_OS_SUFFIX}" )
__LIST_FILTER( __gccExePath "^[.].*" )
list( LENGTH __gccExePath __gccExePathsCount )
if( NOT __gccExePathsCount EQUAL 1 AND NOT _CMAKE_IN_TRY_COMPILE )
message( WARNING "Could not determine machine name for compiler from ${_root}" )
@@ -506,55 +549,76 @@ if( BUILD_WITH_STANDALONE_TOOLCHAIN )
elseif( __availableToolchainMachines MATCHES mipsel )
set( __availableToolchainArchs "mipsel" )
endif()
if( ANDROID_COMPILER_VERSION )
# do not run gcc every time because it is relatevely expencive
set( __availableToolchainCompilerVersions "${ANDROID_COMPILER_VERSION}" )
else()
execute_process( COMMAND "${ANDROID_STANDALONE_TOOLCHAIN}/bin/${__availableToolchainMachines}-gcc${TOOL_OS_SUFFIX}" --version
OUTPUT_VARIABLE __availableToolchainCompilerVersions OUTPUT_STRIP_TRAILING_WHITESPACE )
string( REGEX MATCH "[0-9]+[.][0-9]+([.][0-9]+)?" __availableToolchainCompilerVersions "${__availableToolchainCompilerVersions}" )
execute_process( COMMAND "${ANDROID_STANDALONE_TOOLCHAIN}/bin/${__availableToolchainMachines}-gcc${TOOL_OS_SUFFIX}" -dumpversion
OUTPUT_VARIABLE __availableToolchainCompilerVersions OUTPUT_STRIP_TRAILING_WHITESPACE )
string( REGEX MATCH "[0-9]+[.][0-9]+([.][0-9]+)?" __availableToolchainCompilerVersions "${__availableToolchainCompilerVersions}" )
if( EXISTS "${ANDROID_STANDALONE_TOOLCHAIN}/bin/clang${TOOL_OS_SUFFIX}" )
list( APPEND __availableToolchains "standalone-clang" )
list( APPEND __availableToolchainMachines ${__availableToolchainMachines} )
list( APPEND __availableToolchainArchs ${__availableToolchainArchs} )
list( APPEND __availableToolchainCompilerVersions ${__availableToolchainCompilerVersions} )
endif()
endif()
macro( __GLOB_NDK_TOOLCHAINS __availableToolchainsVar )
foreach( __toolchain ${${__availableToolchainsVar}} )
if( "${__toolchain}" MATCHES "-clang3[.][0-9]$" AND NOT EXISTS "${ANDROID_NDK}/toolchains/${__toolchain}/prebuilt/" )
string( REGEX REPLACE "-clang3[.][0-9]$" "-4.6" __gcc_toolchain "${__toolchain}" )
else()
set( __gcc_toolchain "${__toolchain}" )
endif()
__DETECT_TOOLCHAIN_MACHINE_NAME( __machine "${ANDROID_NDK}/toolchains/${__gcc_toolchain}/prebuilt/${ANDROID_NDK_HOST_SYSTEM_NAME}" )
if( __machine )
string( REGEX MATCH "[0-9]+[.][0-9]+([.][0-9]+)?$" __version "${__gcc_toolchain}" )
string( REGEX MATCH "^[^-]+" __arch "${__gcc_toolchain}" )
list( APPEND __availableToolchainMachines "${__machine}" )
list( APPEND __availableToolchainArchs "${__arch}" )
list( APPEND __availableToolchainCompilerVersions "${__version}" )
else()
list( REMOVE_ITEM ${__availableToolchainsVar} "${__toolchain}" )
endif()
unset( __gcc_toolchain )
endforeach()
endmacro()
# get all the details about NDK
if( BUILD_WITH_ANDROID_NDK )
file( GLOB ANDROID_SUPPORTED_NATIVE_API_LEVELS RELATIVE "${ANDROID_NDK}/platforms" "${ANDROID_NDK}/platforms/android-*" )
string( REPLACE "android-" "" ANDROID_SUPPORTED_NATIVE_API_LEVELS "${ANDROID_SUPPORTED_NATIVE_API_LEVELS}" )
file( GLOB __availableToolchains RELATIVE "${ANDROID_NDK}/toolchains" "${ANDROID_NDK}/toolchains/*" )
__LIST_FILTER( __availableToolchains "^[.]" )
set( __availableToolchains "" )
set( __availableToolchainMachines "" )
set( __availableToolchainArchs "" )
set( __availableToolchainCompilerVersions "" )
foreach( __toolchain ${__availableToolchains} )
__DETECT_TOOLCHAIN_MACHINE_NAME( __machine "${ANDROID_NDK}/toolchains/${__toolchain}/prebuilt/${ANDROID_NDK_HOST_SYSTEM_NAME}" )
if( __machine )
string( REGEX MATCH "[0-9]+[.][0-9]+([.][0-9]+)?$" __version "${__toolchain}" )
string( REGEX MATCH "^[^-]+" __arch "${__toolchain}" )
list( APPEND __availableToolchainMachines "${__machine}" )
list( APPEND __availableToolchainArchs "${__arch}" )
list( APPEND __availableToolchainCompilerVersions "${__version}" )
else()
list( REMOVE_ITEM __availableToolchains "${__toolchain}" )
endif()
endforeach()
if( ANDROID_TOOLCHAIN_NAME AND EXISTS "${ANDROID_NDK}/toolchains/${ANDROID_TOOLCHAIN_NAME}/" )
# do not go through all toolchains if we know the name
set( __availableToolchains "${ANDROID_TOOLCHAIN_NAME}" )
__GLOB_NDK_TOOLCHAINS( __availableToolchains )
endif()
if( NOT __availableToolchains )
message( FATAL_ERROR "Could not any working toolchain in the NDK. Probably your Android NDK is broken." )
file( GLOB __availableToolchains RELATIVE "${ANDROID_NDK}/toolchains" "${ANDROID_NDK}/toolchains/*" )
if( __availableToolchains )
list(SORT __availableToolchains) # we need clang to go after gcc
endif()
__LIST_FILTER( __availableToolchains "^[.]" )
__LIST_FILTER( __availableToolchains "llvm" )
__GLOB_NDK_TOOLCHAINS( __availableToolchains )
endif()
if( NOT __availableToolchains )
message( FATAL_ERROR "Could not find any working toolchain in the NDK. Probably your Android NDK is broken." )
endif()
endif()
# build list of available ABIs
set( ANDROID_SUPPORTED_ABIS "" )
set( __uniqToolchainArchNames ${__availableToolchainArchs} )
list( REMOVE_DUPLICATES __uniqToolchainArchNames )
list( SORT __uniqToolchainArchNames )
foreach( __arch ${__uniqToolchainArchNames} )
list( APPEND ANDROID_SUPPORTED_ABIS ${ANDROID_SUPPORTED_ABIS_${__arch}} )
endforeach()
unset( __uniqToolchainArchNames )
if( NOT ANDROID_SUPPORTED_ABIS )
set( ANDROID_SUPPORTED_ABIS "" )
set( __uniqToolchainArchNames ${__availableToolchainArchs} )
list( REMOVE_DUPLICATES __uniqToolchainArchNames )
list( SORT __uniqToolchainArchNames )
foreach( __arch ${__uniqToolchainArchNames} )
list( APPEND ANDROID_SUPPORTED_ABIS ${ANDROID_SUPPORTED_ABIS_${__arch}} )
endforeach()
unset( __uniqToolchainArchNames )
if( NOT ANDROID_SUPPORTED_ABIS )
message( FATAL_ERROR "No one of known Android ABIs is supported by this cmake toolchain." )
endif()
message( FATAL_ERROR "No one of known Android ABIs is supported by this cmake toolchain." )
endif()
# choose target ABI
@@ -569,33 +633,34 @@ if( __androidAbiIdx EQUAL -1 )
endif()
unset( __androidAbiIdx )
# remember target ABI
set( ANDROID_ABI "${ANDROID_ABI}" CACHE STRING "The target ABI for Android. If arm, then armeabi-v7a is recommended for hardware floating point." FORCE )
# set target ABI options
if( ANDROID_ABI STREQUAL "x86" )
set( X86 true )
set( ANDROID_NDK_ABI_NAME "x86" )
set( ANDROID_ARCH_NAME "x86" )
set( ANDROID_ARCH_FULLNAME "x86" )
set( ANDROID_LLVM_TRIPLE "i686-none-linux-android" )
set( CMAKE_SYSTEM_PROCESSOR "i686" )
elseif( ANDROID_ABI STREQUAL "mips" )
set( MIPS true )
set( ANDROID_NDK_ABI_NAME "mips" )
set( ANDROID_ARCH_NAME "mips" )
set( ANDROID_ARCH_FULLNAME "mipsel" )
set( ANDROID_LLVM_TRIPLE "mipsel-none-linux-android" )
set( CMAKE_SYSTEM_PROCESSOR "mips" )
elseif( ANDROID_ABI STREQUAL "armeabi" )
set( ARMEABI true )
set( ANDROID_NDK_ABI_NAME "armeabi" )
set( ANDROID_ARCH_NAME "arm" )
set( ANDROID_ARCH_FULLNAME "arm" )
set( ANDROID_LLVM_TRIPLE "armv5te-none-linux-androideabi" )
set( CMAKE_SYSTEM_PROCESSOR "armv5te" )
elseif( ANDROID_ABI STREQUAL "armeabi-v6 with VFP" )
set( ARMEABI_V6 true )
set( ANDROID_NDK_ABI_NAME "armeabi" )
set( ANDROID_ARCH_NAME "arm" )
set( ANDROID_ARCH_FULLNAME "arm" )
set( ANDROID_LLVM_TRIPLE "armv5te-none-linux-androideabi" )
set( CMAKE_SYSTEM_PROCESSOR "armv6" )
# need always fallback to older platform
set( ARMEABI true )
@@ -604,12 +669,14 @@ elseif( ANDROID_ABI STREQUAL "armeabi-v7a")
set( ANDROID_NDK_ABI_NAME "armeabi-v7a" )
set( ANDROID_ARCH_NAME "arm" )
set( ANDROID_ARCH_FULLNAME "arm" )
set( ANDROID_LLVM_TRIPLE "armv7-none-linux-androideabi" )
set( CMAKE_SYSTEM_PROCESSOR "armv7-a" )
elseif( ANDROID_ABI STREQUAL "armeabi-v7a with VFPV3" )
set( ARMEABI_V7A true )
set( ANDROID_NDK_ABI_NAME "armeabi-v7a" )
set( ANDROID_ARCH_NAME "arm" )
set( ANDROID_ARCH_FULLNAME "arm" )
set( ANDROID_LLVM_TRIPLE "armv7-none-linux-androideabi" )
set( CMAKE_SYSTEM_PROCESSOR "armv7-a" )
set( VFPV3 true )
elseif( ANDROID_ABI STREQUAL "armeabi-v7a with NEON" )
@@ -617,6 +684,7 @@ elseif( ANDROID_ABI STREQUAL "armeabi-v7a with NEON" )
set( ANDROID_NDK_ABI_NAME "armeabi-v7a" )
set( ANDROID_ARCH_NAME "arm" )
set( ANDROID_ARCH_FULLNAME "arm" )
set( ANDROID_LLVM_TRIPLE "armv7-none-linux-androideabi" )
set( CMAKE_SYSTEM_PROCESSOR "armv7-a" )
set( VFPV3 true )
set( NEON true )
@@ -630,12 +698,6 @@ if( CMAKE_BINARY_DIR AND EXISTS "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMa
file( APPEND "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeSystem.cmake" "SET(CMAKE_SYSTEM_PROCESSOR \"${CMAKE_SYSTEM_PROCESSOR}\")\n" )
endif()
set( ANDROID_SUPPORTED_ABIS ${ANDROID_SUPPORTED_ABIS_${ANDROID_ARCH_FULLNAME}} CACHE INTERNAL "ANDROID_ABI can be changed only to one of these ABIs. Changing to any other ABI requires to reset cmake cache." FORCE )
if( CMAKE_VERSION VERSION_GREATER "2.8" )
list( SORT ANDROID_SUPPORTED_ABIS_${ANDROID_ARCH_FULLNAME} )
set_property( CACHE ANDROID_ABI PROPERTY STRINGS ${ANDROID_SUPPORTED_ABIS_${ANDROID_ARCH_FULLNAME}} )
endif()
if( ANDROID_ARCH_NAME STREQUAL "arm" AND NOT ARMEABI_V6 )
__INIT_VARIABLE( ANDROID_FORCE_ARM_BUILD OBSOLETE_FORCE_ARM VALUES OFF )
set( ANDROID_FORCE_ARM_BUILD ${ANDROID_FORCE_ARM_BUILD} CACHE BOOL "Use 32-bit ARM instructions instead of Thumb-1" FORCE )
@@ -648,11 +710,15 @@ endif()
if( ANDROID_TOOLCHAIN_NAME )
list( FIND __availableToolchains "${ANDROID_TOOLCHAIN_NAME}" __toolchainIdx )
if( __toolchainIdx EQUAL -1 )
message( FATAL_ERROR "Previously selected toolchain \"${ANDROID_TOOLCHAIN_NAME}\" is missing. You need to remove CMakeCache.txt and rerun cmake manually to change the toolchain" )
list( SORT __availableToolchains )
string( REPLACE ";" "\n * " toolchains_list "${__availableToolchains}" )
set( toolchains_list " * ${toolchains_list}")
message( FATAL_ERROR "Specified toolchain \"${ANDROID_TOOLCHAIN_NAME}\" is missing in your NDK or broken. Please verify that your NDK is working or select another compiler toolchain.
To configure the toolchain set CMake variable ANDROID_TOOLCHAIN_NAME to one of the following values:\n${toolchains_list}\n" )
endif()
list( GET __availableToolchainArchs ${__toolchainIdx} __toolchainArch )
if( NOT __toolchainArch STREQUAL ANDROID_ARCH_FULLNAME )
message( SEND_ERROR "Previously selected toolchain \"${ANDROID_TOOLCHAIN_NAME}\" is not able to compile binaries for the \"${ANDROID_ARCH_NAME}\" platform." )
message( SEND_ERROR "Selected toolchain \"${ANDROID_TOOLCHAIN_NAME}\" is not able to compile binaries for the \"${ANDROID_ARCH_NAME}\" platform." )
endif()
else()
set( __toolchainIdx -1 )
@@ -681,8 +747,7 @@ endif()
list( GET __availableToolchains ${__toolchainIdx} ANDROID_TOOLCHAIN_NAME )
list( GET __availableToolchainMachines ${__toolchainIdx} ANDROID_TOOLCHAIN_MACHINE_NAME )
list( GET __availableToolchainCompilerVersions ${__toolchainIdx} ANDROID_COMPILER_VERSION )
set( ANDROID_TOOLCHAIN_NAME "${ANDROID_TOOLCHAIN_NAME}" CACHE INTERNAL "Name of toolchain used" FORCE )
set( ANDROID_COMPILER_VERSION "${ANDROID_COMPILER_VERSION}" CACHE INTERNAL "compiler version from selected toolchain" FORCE )
unset( __toolchainIdx )
unset( __availableToolchains )
unset( __availableToolchainMachines )
@@ -692,37 +757,35 @@ unset( __availableToolchainCompilerVersions )
# choose native API level
__INIT_VARIABLE( ANDROID_NATIVE_API_LEVEL ENV_ANDROID_NATIVE_API_LEVEL ANDROID_API_LEVEL ENV_ANDROID_API_LEVEL ANDROID_STANDALONE_TOOLCHAIN_API_LEVEL ANDROID_DEFAULT_NDK_API_LEVEL_${ANDROID_ARCH_NAME} ANDROID_DEFAULT_NDK_API_LEVEL )
string( REGEX MATCH "[0-9]+" ANDROID_NATIVE_API_LEVEL "${ANDROID_NATIVE_API_LEVEL}" )
# TODO: filter out unsupported levels
# validate
list( FIND ANDROID_SUPPORTED_NATIVE_API_LEVELS "${ANDROID_NATIVE_API_LEVEL}" __levelIdx )
if( __levelIdx EQUAL -1 )
message( SEND_ERROR "Specified Android native API level (${ANDROID_NATIVE_API_LEVEL}) is not supported by your NDK/toolchain." )
else()
if( BUILD_WITH_ANDROID_NDK )
__DETECT_NATIVE_API_LEVEL( __realApiLevel "${ANDROID_NDK}/platforms/android-${ANDROID_NATIVE_API_LEVEL}/arch-${ANDROID_ARCH_NAME}/usr/include/android/api-level.h" )
if( NOT __realApiLevel EQUAL ANDROID_NATIVE_API_LEVEL )
message( SEND_ERROR "Specified Android API level (${ANDROID_NATIVE_API_LEVEL}) does not match to the level found (${__realApiLevel}). Probably your copy of NDK is broken." )
endif()
unset( __realApiLevel )
endif()
set( ANDROID_NATIVE_API_LEVEL "${ANDROID_NATIVE_API_LEVEL}" CACHE STRING "Android API level for native code" FORCE )
if( CMAKE_VERSION VERSION_GREATER "2.8" )
list( SORT ANDROID_SUPPORTED_NATIVE_API_LEVELS )
set_property( CACHE ANDROID_NATIVE_API_LEVEL PROPERTY STRINGS ${ANDROID_SUPPORTED_NATIVE_API_LEVELS} )
endif()
endif()
unset( __levelIdx )
if( BUILD_WITH_ANDROID_NDK )
__DETECT_NATIVE_API_LEVEL( __realApiLevel "${ANDROID_NDK}/platforms/android-${ANDROID_NATIVE_API_LEVEL}/arch-${ANDROID_ARCH_NAME}/usr/include/android/api-level.h" )
if( NOT __realApiLevel EQUAL ANDROID_NATIVE_API_LEVEL )
message( SEND_ERROR "Specified Android API level (${ANDROID_NATIVE_API_LEVEL}) does not match to the level found (${__realApiLevel}). Probably your copy of NDK is broken." )
endif()
unset( __realApiLevel )
endif()
set( ANDROID_NATIVE_API_LEVEL "${ANDROID_NATIVE_API_LEVEL}" CACHE STRING "Android API level for native code" FORCE )
# remember target ABI
set( ANDROID_ABI "${ANDROID_ABI}" CACHE STRING "The target ABI for Android. If arm, then armeabi-v7a is recommended for hardware floating point." FORCE )
if( CMAKE_VERSION VERSION_GREATER "2.8" )
list( SORT ANDROID_SUPPORTED_NATIVE_API_LEVELS )
set_property( CACHE ANDROID_NATIVE_API_LEVEL PROPERTY STRINGS ${ANDROID_SUPPORTED_NATIVE_API_LEVELS} )
list( SORT ANDROID_SUPPORTED_ABIS_${ANDROID_ARCH_FULLNAME} )
set_property( CACHE ANDROID_ABI PROPERTY STRINGS ${ANDROID_SUPPORTED_ABIS_${ANDROID_ARCH_FULLNAME}} )
endif()
# setup output directories
set( LIBRARY_OUTPUT_PATH_ROOT ${CMAKE_SOURCE_DIR} CACHE PATH "root for library output, set this to change where android libs are installed to" )
set( CMAKE_INSTALL_PREFIX "${ANDROID_TOOLCHAIN_ROOT}/user" CACHE STRING "path for installing" )
if(NOT _CMAKE_IN_TRY_COMPILE)
if( EXISTS "${CMAKE_SOURCE_DIR}/jni/CMakeLists.txt" )
set( EXECUTABLE_OUTPUT_PATH "${LIBRARY_OUTPUT_PATH_ROOT}/bin/${ANDROID_NDK_ABI_NAME}" CACHE PATH "Output directory for applications" )
else()
set( EXECUTABLE_OUTPUT_PATH "${LIBRARY_OUTPUT_PATH_ROOT}/bin" CACHE PATH "Output directory for applications" )
endif()
set( LIBRARY_OUTPUT_PATH "${LIBRARY_OUTPUT_PATH_ROOT}/libs/${ANDROID_NDK_ABI_NAME}" CACHE PATH "path for android libs" )
endif()
# runtime choice (STL, rtti, exceptions)
if( NOT ANDROID_STL )
@@ -800,9 +863,84 @@ See https://android.googlesource.com/platform/development.git f907f4f9d4e56ccc80
" )
endif()
# setup paths and STL for standalone toolchain
if( BUILD_WITH_STANDALONE_TOOLCHAIN )
set( ANDROID_TOOLCHAIN_ROOT "${ANDROID_STANDALONE_TOOLCHAIN}" )
set( ANDROID_CLANG_TOOLCHAIN_ROOT "${ANDROID_STANDALONE_TOOLCHAIN}" )
set( ANDROID_SYSROOT "${ANDROID_STANDALONE_TOOLCHAIN}/sysroot" )
if( NOT ANDROID_STL STREQUAL "none" )
set( ANDROID_STL_INCLUDE_DIRS "${ANDROID_STANDALONE_TOOLCHAIN}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/include/c++/${ANDROID_COMPILER_VERSION}" )
if( ARMEABI_V7A AND EXISTS "${ANDROID_STL_INCLUDE_DIRS}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/${CMAKE_SYSTEM_PROCESSOR}/bits" )
list( APPEND ANDROID_STL_INCLUDE_DIRS "${ANDROID_STL_INCLUDE_DIRS}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/${CMAKE_SYSTEM_PROCESSOR}" )
elseif( ARMEABI AND NOT ANDROID_FORCE_ARM_BUILD AND EXISTS "${ANDROID_STL_INCLUDE_DIRS}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/thumb/bits" )
list( APPEND ANDROID_STL_INCLUDE_DIRS "${ANDROID_STL_INCLUDE_DIRS}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/thumb" )
else()
list( APPEND ANDROID_STL_INCLUDE_DIRS "${ANDROID_STL_INCLUDE_DIRS}/${ANDROID_TOOLCHAIN_MACHINE_NAME}" )
endif()
# always search static GNU STL to get the location of libsupc++.a
if( ARMEABI_V7A AND NOT ANDROID_FORCE_ARM_BUILD AND EXISTS "${ANDROID_STANDALONE_TOOLCHAIN}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/lib/${CMAKE_SYSTEM_PROCESSOR}/thumb/libstdc++.a" )
set( __libstl "${ANDROID_STANDALONE_TOOLCHAIN}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/lib/${CMAKE_SYSTEM_PROCESSOR}/thumb" )
elseif( ARMEABI_V7A AND EXISTS "${ANDROID_STANDALONE_TOOLCHAIN}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/lib/${CMAKE_SYSTEM_PROCESSOR}/libstdc++.a" )
set( __libstl "${ANDROID_STANDALONE_TOOLCHAIN}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/lib/${CMAKE_SYSTEM_PROCESSOR}" )
elseif( ARMEABI AND NOT ANDROID_FORCE_ARM_BUILD AND EXISTS "${ANDROID_STANDALONE_TOOLCHAIN}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/lib/thumb/libstdc++.a" )
set( __libstl "${ANDROID_STANDALONE_TOOLCHAIN}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/lib/thumb" )
elseif( EXISTS "${ANDROID_STANDALONE_TOOLCHAIN}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/lib/libstdc++.a" )
set( __libstl "${ANDROID_STANDALONE_TOOLCHAIN}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/lib" )
endif()
if( __libstl )
set( __libsupcxx "${__libstl}/libsupc++.a" )
set( __libstl "${__libstl}/libstdc++.a" )
endif()
if( NOT EXISTS "${__libsupcxx}" )
message( FATAL_ERROR "The required libstdsupc++.a is missing in your standalone toolchain.
Usually it happens because of bug in make-standalone-toolchain.sh script from NDK r7, r7b and r7c.
You need to either upgrade to newer NDK or manually copy
$ANDROID_NDK/sources/cxx-stl/gnu-libstdc++/libs/${ANDROID_NDK_ABI_NAME}/libsupc++.a
to
${__libsupcxx}
" )
endif()
if( ANDROID_STL STREQUAL "gnustl_shared" )
if( ARMEABI_V7A AND EXISTS "${ANDROID_STANDALONE_TOOLCHAIN}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/lib/${CMAKE_SYSTEM_PROCESSOR}/libgnustl_shared.so" )
set( __libstl "${ANDROID_STANDALONE_TOOLCHAIN}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/lib/${CMAKE_SYSTEM_PROCESSOR}/libgnustl_shared.so" )
elseif( ARMEABI AND NOT ANDROID_FORCE_ARM_BUILD AND EXISTS "${ANDROID_STANDALONE_TOOLCHAIN}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/lib/thumb/libgnustl_shared.so" )
set( __libstl "${ANDROID_STANDALONE_TOOLCHAIN}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/lib/thumb/libgnustl_shared.so" )
elseif( EXISTS "${ANDROID_STANDALONE_TOOLCHAIN}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/lib/libgnustl_shared.so" )
set( __libstl "${ANDROID_STANDALONE_TOOLCHAIN}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/lib/libgnustl_shared.so" )
endif()
endif()
endif()
endif()
# clang
if( "${ANDROID_TOOLCHAIN_NAME}" STREQUAL "standalone-clang" )
set( ANDROID_COMPILER_IS_CLANG 1 )
execute_process( COMMAND "${ANDROID_CLANG_TOOLCHAIN_ROOT}/bin/clang${TOOL_OS_SUFFIX}" --version OUTPUT_VARIABLE ANDROID_CLANG_VERSION OUTPUT_STRIP_TRAILING_WHITESPACE )
string( REGEX MATCH "[0-9]+[.][0-9]+" ANDROID_CLANG_VERSION "${ANDROID_CLANG_VERSION}")
elseif( "${ANDROID_TOOLCHAIN_NAME}" MATCHES "-clang3[.][0-9]?$" )
string( REGEX MATCH "3[.][0-9]$" ANDROID_CLANG_VERSION "${ANDROID_TOOLCHAIN_NAME}")
string( REGEX REPLACE "-clang${ANDROID_CLANG_VERSION}$" "-4.6" ANDROID_GCC_TOOLCHAIN_NAME "${ANDROID_TOOLCHAIN_NAME}" )
if( NOT EXISTS "${ANDROID_NDK}/toolchains/llvm-${ANDROID_CLANG_VERSION}/prebuilt/${ANDROID_NDK_HOST_SYSTEM_NAME}/bin/clang${TOOL_OS_SUFFIX}" )
message( FATAL_ERROR "Could not find the " )
endif()
set( ANDROID_COMPILER_IS_CLANG 1 )
set( ANDROID_CLANG_TOOLCHAIN_ROOT "${ANDROID_NDK}/toolchains/llvm-${ANDROID_CLANG_VERSION}/prebuilt/${ANDROID_NDK_HOST_SYSTEM_NAME}" )
else()
set( ANDROID_GCC_TOOLCHAIN_NAME "${ANDROID_TOOLCHAIN_NAME}" )
unset( ANDROID_COMPILER_IS_CLANG CACHE )
endif()
string( REPLACE "." "" _clang_name "clang${ANDROID_CLANG_VERSION}" )
if( NOT EXISTS "${ANDROID_CLANG_TOOLCHAIN_ROOT}/bin/${_clang_name}${TOOL_OS_SUFFIX}" )
set( _clang_name "clang" )
endif()
# setup paths and STL for NDK
if( BUILD_WITH_ANDROID_NDK )
set( ANDROID_TOOLCHAIN_ROOT "${ANDROID_NDK}/toolchains/${ANDROID_TOOLCHAIN_NAME}/prebuilt/${ANDROID_NDK_HOST_SYSTEM_NAME}" )
set( ANDROID_TOOLCHAIN_ROOT "${ANDROID_NDK}/toolchains/${ANDROID_GCC_TOOLCHAIN_NAME}/prebuilt/${ANDROID_NDK_HOST_SYSTEM_NAME}" )
set( ANDROID_SYSROOT "${ANDROID_NDK}/platforms/android-${ANDROID_NATIVE_API_LEVEL}/arch-${ANDROID_ARCH_NAME}" )
if( ANDROID_STL STREQUAL "none" )
@@ -874,54 +1012,6 @@ if( BUILD_WITH_ANDROID_NDK )
endif()
endif()
# setup paths and STL for standalone toolchain
if( BUILD_WITH_STANDALONE_TOOLCHAIN )
set( ANDROID_TOOLCHAIN_ROOT "${ANDROID_STANDALONE_TOOLCHAIN}" )
set( ANDROID_SYSROOT "${ANDROID_STANDALONE_TOOLCHAIN}/sysroot" )
if( NOT ANDROID_STL STREQUAL "none" )
set( ANDROID_STL_INCLUDE_DIRS "${ANDROID_STANDALONE_TOOLCHAIN}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/include/c++/${ANDROID_COMPILER_VERSION}" )
if( ARMEABI_V7A AND EXISTS "${ANDROID_STL_INCLUDE_DIRS}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/${CMAKE_SYSTEM_PROCESSOR}/bits" )
list( APPEND ANDROID_STL_INCLUDE_DIRS "${ANDROID_STL_INCLUDE_DIRS}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/${CMAKE_SYSTEM_PROCESSOR}" )
elseif( ARMEABI AND NOT ANDROID_FORCE_ARM_BUILD AND EXISTS "${ANDROID_STL_INCLUDE_DIRS}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/thumb/bits" )
list( APPEND ANDROID_STL_INCLUDE_DIRS "${ANDROID_STL_INCLUDE_DIRS}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/thumb" )
else()
list( APPEND ANDROID_STL_INCLUDE_DIRS "${ANDROID_STL_INCLUDE_DIRS}/${ANDROID_TOOLCHAIN_MACHINE_NAME}" )
endif()
# always search static GNU STL to get the location of libsupc++.a
if( ARMEABI_V7A AND NOT ANDROID_FORCE_ARM_BUILD AND EXISTS "${ANDROID_STANDALONE_TOOLCHAIN}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/lib/${CMAKE_SYSTEM_PROCESSOR}/thumb/libstdc++.a" )
set( __libstl "${ANDROID_STANDALONE_TOOLCHAIN}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/lib/${CMAKE_SYSTEM_PROCESSOR}/thumb" )
elseif( ARMEABI_V7A AND EXISTS "${ANDROID_STANDALONE_TOOLCHAIN}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/lib/${CMAKE_SYSTEM_PROCESSOR}/libstdc++.a" )
set( __libstl "${ANDROID_STANDALONE_TOOLCHAIN}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/lib/${CMAKE_SYSTEM_PROCESSOR}" )
elseif( ARMEABI AND NOT ANDROID_FORCE_ARM_BUILD AND EXISTS "${ANDROID_STANDALONE_TOOLCHAIN}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/lib/thumb/libstdc++.a" )
set( __libstl "${ANDROID_STANDALONE_TOOLCHAIN}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/lib/thumb" )
elseif( EXISTS "${ANDROID_STANDALONE_TOOLCHAIN}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/lib/libstdc++.a" )
set( __libstl "${ANDROID_STANDALONE_TOOLCHAIN}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/lib" )
endif()
if( __libstl )
set( __libsupcxx "${__libstl}/libsupc++.a" )
set( __libstl "${__libstl}/libstdc++.a" )
endif()
if( NOT EXISTS "${__libsupcxx}" )
message( FATAL_ERROR "The required libstdsupc++.a is missing in your standalone toolchain.
Usually it happens because of bug in make-standalone-toolchain.sh script from NDK r7, r7b and r7c.
You need to either upgrade to newer NDK or manually copy
$ANDROID_NDK/sources/cxx-stl/gnu-libstdc++/libs/${ANDROID_NDK_ABI_NAME}/libsupc++.a
to
${__libsupcxx}
" )
endif()
if( ANDROID_STL STREQUAL "gnustl_shared" )
if( ARMEABI_V7A AND EXISTS "${ANDROID_STANDALONE_TOOLCHAIN}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/lib/${CMAKE_SYSTEM_PROCESSOR}/libgnustl_shared.so" )
set( __libstl "${ANDROID_STANDALONE_TOOLCHAIN}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/lib/${CMAKE_SYSTEM_PROCESSOR}/libgnustl_shared.so" )
elseif( ARMEABI AND NOT ANDROID_FORCE_ARM_BUILD AND EXISTS "${ANDROID_STANDALONE_TOOLCHAIN}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/lib/thumb/libgnustl_shared.so" )
set( __libstl "${ANDROID_STANDALONE_TOOLCHAIN}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/lib/thumb/libgnustl_shared.so" )
elseif( EXISTS "${ANDROID_STANDALONE_TOOLCHAIN}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/lib/libgnustl_shared.so" )
set( __libstl "${ANDROID_STANDALONE_TOOLCHAIN}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/lib/libgnustl_shared.so" )
endif()
endif()
endif()
endif()
# case of shared STL linkage
if( ANDROID_STL MATCHES "shared" AND DEFINED __libstl )
@@ -937,6 +1027,7 @@ if( ANDROID_STL MATCHES "shared" AND DEFINED __libstl )
endif()
endif()
# ccache support
__INIT_VARIABLE( _ndk_ccache NDK_CCACHE ENV_NDK_CCACHE )
if( _ndk_ccache )
@@ -946,16 +1037,27 @@ else()
endif()
unset( _ndk_ccache )
# setup the cross-compiler
if( NOT CMAKE_C_COMPILER )
if( NDK_CCACHE )
set( CMAKE_C_COMPILER "${NDK_CCACHE}" CACHE PATH "ccache as C compiler" )
set( CMAKE_CXX_COMPILER "${NDK_CCACHE}" CACHE PATH "ccache as C++ compiler" )
set( CMAKE_C_COMPILER_ARG1 "${ANDROID_TOOLCHAIN_ROOT}/bin/${ANDROID_TOOLCHAIN_MACHINE_NAME}-gcc${TOOL_OS_SUFFIX}" CACHE PATH "gcc")
set( CMAKE_CXX_COMPILER_ARG1 "${ANDROID_TOOLCHAIN_ROOT}/bin/${ANDROID_TOOLCHAIN_MACHINE_NAME}-g++${TOOL_OS_SUFFIX}" CACHE PATH "g++")
if( ANDROID_COMPILER_IS_CLANG )
set( CMAKE_C_COMPILER_ARG1 "${ANDROID_CLANG_TOOLCHAIN_ROOT}/bin/${_clang_name}${TOOL_OS_SUFFIX}" CACHE PATH "C compiler")
set( CMAKE_CXX_COMPILER_ARG1 "${ANDROID_CLANG_TOOLCHAIN_ROOT}/bin/${_clang_name}++${TOOL_OS_SUFFIX}" CACHE PATH "C++ compiler")
else()
set( CMAKE_C_COMPILER_ARG1 "${ANDROID_TOOLCHAIN_ROOT}/bin/${ANDROID_TOOLCHAIN_MACHINE_NAME}-gcc${TOOL_OS_SUFFIX}" CACHE PATH "C compiler")
set( CMAKE_CXX_COMPILER_ARG1 "${ANDROID_TOOLCHAIN_ROOT}/bin/${ANDROID_TOOLCHAIN_MACHINE_NAME}-g++${TOOL_OS_SUFFIX}" CACHE PATH "C++ compiler")
endif()
else()
set( CMAKE_C_COMPILER "${ANDROID_TOOLCHAIN_ROOT}/bin/${ANDROID_TOOLCHAIN_MACHINE_NAME}-gcc${TOOL_OS_SUFFIX}" CACHE PATH "gcc" )
set( CMAKE_CXX_COMPILER "${ANDROID_TOOLCHAIN_ROOT}/bin/${ANDROID_TOOLCHAIN_MACHINE_NAME}-g++${TOOL_OS_SUFFIX}" CACHE PATH "g++" )
if( ANDROID_COMPILER_IS_CLANG )
set( CMAKE_C_COMPILER "${ANDROID_CLANG_TOOLCHAIN_ROOT}/bin/${_clang_name}${TOOL_OS_SUFFIX}" CACHE PATH "C compiler")
set( CMAKE_CXX_COMPILER "${ANDROID_CLANG_TOOLCHAIN_ROOT}/bin/${_clang_name}++${TOOL_OS_SUFFIX}" CACHE PATH "C++ compiler")
else()
set( CMAKE_C_COMPILER "${ANDROID_TOOLCHAIN_ROOT}/bin/${ANDROID_TOOLCHAIN_MACHINE_NAME}-gcc${TOOL_OS_SUFFIX}" CACHE PATH "C compiler" )
set( CMAKE_CXX_COMPILER "${ANDROID_TOOLCHAIN_ROOT}/bin/${ANDROID_TOOLCHAIN_MACHINE_NAME}-g++${TOOL_OS_SUFFIX}" CACHE PATH "C++ compiler" )
endif()
endif()
set( CMAKE_ASM_COMPILER "${ANDROID_TOOLCHAIN_ROOT}/bin/${ANDROID_TOOLCHAIN_MACHINE_NAME}-gcc${TOOL_OS_SUFFIX}" CACHE PATH "assembler" )
set( CMAKE_STRIP "${ANDROID_TOOLCHAIN_ROOT}/bin/${ANDROID_TOOLCHAIN_MACHINE_NAME}-strip${TOOL_OS_SUFFIX}" CACHE PATH "strip" )
@@ -982,15 +1084,22 @@ endif()
# Force set compilers because standard identification works badly for us
include( CMakeForceCompiler )
CMAKE_FORCE_C_COMPILER( "${CMAKE_C_COMPILER}" GNU )
if( ANDROID_COMPILER_IS_CLANG )
set( CMAKE_C_COMPILER_ID Clang)
endif()
set( CMAKE_C_PLATFORM_ID Linux )
set( CMAKE_C_SIZEOF_DATA_PTR 4 )
set( CMAKE_C_HAS_ISYSROOT 1 )
set( CMAKE_C_COMPILER_ABI ELF )
CMAKE_FORCE_CXX_COMPILER( "${CMAKE_CXX_COMPILER}" GNU )
if( ANDROID_COMPILER_IS_CLANG )
set( CMAKE_CXX_COMPILER_ID Clang)
endif()
set( CMAKE_CXX_PLATFORM_ID Linux )
set( CMAKE_CXX_SIZEOF_DATA_PTR 4 )
set( CMAKE_CXX_HAS_ISYSROOT 1 )
set( CMAKE_CXX_COMPILER_ABI ELF )
set( CMAKE_CXX_SOURCE_FILE_EXTENSIONS cc cp cxx cpp CPP c++ C )
# force ASM compiler (required for CMake < 2.8.5)
set( CMAKE_ASM_COMPILER_ID_RUN TRUE )
set( CMAKE_ASM_COMPILER_ID GNU )
@@ -1056,10 +1165,10 @@ if( ARMEABI_V7A )
elseif( VFPV3 )
set( ANDROID_CXX_FLAGS "${ANDROID_CXX_FLAGS} -mfpu=vfpv3" )
else()
set( ANDROID_CXX_FLAGS "${ANDROID_CXX_FLAGS} -mfpu=vfp" )
set( ANDROID_CXX_FLAGS "${ANDROID_CXX_FLAGS} -mfpu=vfpv3-d16" )
endif()
elseif( ARMEABI_V6 )
set( ANDROID_CXX_FLAGS "${ANDROID_CXX_FLAGS} -march=armv6 -mfloat-abi=softfp -mfpu=vfp" )
set( ANDROID_CXX_FLAGS "${ANDROID_CXX_FLAGS} -march=armv6 -mfloat-abi=softfp -mfpu=vfp" ) # vfp == vfpv2
elseif( ARMEABI )
set( ANDROID_CXX_FLAGS "${ANDROID_CXX_FLAGS} -march=armv5te -mtune=xscale -msoft-float" )
endif()
@@ -1148,17 +1257,25 @@ if( ANDROID_FUNCTION_LEVEL_LINKING )
set( ANDROID_LINKER_FLAGS "${ANDROID_LINKER_FLAGS} -Wl,--gc-sections" )
endif()
if( ANDROID_GOLD_LINKER AND CMAKE_HOST_UNIX AND (ARMEABI OR ARMEABI_V7A OR X86) AND ANDROID_COMPILER_VERSION VERSION_EQUAL "4.6" )
set( ANDROID_LINKER_FLAGS "${ANDROID_LINKER_FLAGS} -fuse-ld=gold" )
elseif( ANDROID_NDK_RELEASE STREQUAL "r8b" AND ARMEABI AND ANDROID_COMPILER_VERSION VERSION_EQUAL "4.6" AND NOT _CMAKE_IN_TRY_COMPILE )
message( WARNING "The default bfd linker from arm GCC 4.6 toolchain can fail with 'unresolvable R_ARM_THM_CALL relocation' error message. See https://code.google.com/p/android/issues/detail?id=35342
if( ANDROID_COMPILER_VERSION VERSION_EQUAL "4.6" )
if( ANDROID_GOLD_LINKER AND (CMAKE_HOST_UNIX OR ANDROID_NDK_RELEASE STRGREATER "r8b") AND (ARMEABI OR ARMEABI_V7A OR X86) )
set( ANDROID_LINKER_FLAGS "${ANDROID_LINKER_FLAGS} -fuse-ld=gold" )
elseif( ANDROID_NDK_RELEASE STREQUAL "r8c")
set( ANDROID_LINKER_FLAGS "${ANDROID_LINKER_FLAGS} -fuse-ld=bfd" )
elseif( ANDROID_NDK_RELEASE STREQUAL "r8b" AND ARMEABI AND NOT _CMAKE_IN_TRY_COMPILE )
message( WARNING "The default bfd linker from arm GCC 4.6 toolchain can fail with 'unresolvable R_ARM_THM_CALL relocation' error message. See https://code.google.com/p/android/issues/detail?id=35342
On Linux and OS X host platform you can workaround this problem using gold linker (default).
Rerun cmake with -DANDROID_GOLD_LINKER=ON option.
Rerun cmake with -DANDROID_GOLD_LINKER=ON option in case of problems.
" )
endif()
endif()
endif() # version 4.6
if( ANDROID_NOEXECSTACK )
set( ANDROID_CXX_FLAGS "${ANDROID_CXX_FLAGS} -Wa,--noexecstack" )
if( ANDROID_COMPILER_IS_CLANG )
set( ANDROID_CXX_FLAGS "${ANDROID_CXX_FLAGS} -Xclang -mnoexecstack" )
else()
set( ANDROID_CXX_FLAGS "${ANDROID_CXX_FLAGS} -Wa,--noexecstack" )
endif()
set( ANDROID_LINKER_FLAGS "${ANDROID_LINKER_FLAGS} -Wl,-z,noexecstack" )
endif()
@@ -1166,6 +1283,22 @@ if( ANDROID_RELRO )
set( ANDROID_LINKER_FLAGS "${ANDROID_LINKER_FLAGS} -Wl,-z,relro -Wl,-z,now" )
endif()
if( ANDROID_COMPILER_IS_CLANG )
set( ANDROID_CXX_FLAGS "-Qunused-arguments ${ANDROID_CXX_FLAGS}" )
if( ARMEABI_V7A AND NOT ANDROID_FORCE_ARM_BUILD )
set( ANDROID_CXX_FLAGS_RELEASE "-target thumbv7-none-linux-androideabi ${ANDROID_CXX_FLAGS_RELEASE}" )
set( ANDROID_CXX_FLAGS_DEBUG "-target ${ANDROID_LLVM_TRIPLE} ${ANDROID_CXX_FLAGS_DEBUG}" )
else()
set( ANDROID_CXX_FLAGS "-target ${ANDROID_LLVM_TRIPLE} ${ANDROID_CXX_FLAGS}" )
endif()
if( BUILD_WITH_ANDROID_NDK )
if(ANDROID_ARCH_NAME STREQUAL "arm" )
set( ANDROID_CXX_FLAGS "-isystem ${ANDROID_CLANG_TOOLCHAIN_ROOT}/lib/clang/${ANDROID_CLANG_VERSION}/include ${ANDROID_CXX_FLAGS}" )
endif()
set( ANDROID_CXX_FLAGS "-gcc-toolchain ${ANDROID_TOOLCHAIN_ROOT} ${ANDROID_CXX_FLAGS}" )
endif()
endif()
# cache flags
set( CMAKE_CXX_FLAGS "" CACHE STRING "c++ flags" )
set( CMAKE_C_FLAGS "" CACHE STRING "c flags" )
@@ -1189,9 +1322,9 @@ set( CMAKE_MODULE_LINKER_FLAGS "${ANDROID_LINKER_FLAGS} ${CMAKE_MODULE_LINKER_FL
set( CMAKE_EXE_LINKER_FLAGS "${ANDROID_LINKER_FLAGS} ${CMAKE_EXE_LINKER_FLAGS}" )
if( MIPS AND BUILD_WITH_ANDROID_NDK AND ANDROID_NDK_RELEASE STREQUAL "r8" )
set( CMAKE_SHARED_LINKER_FLAGS "-Wl,-T,${ANDROID_NDK}/toolchains/${ANDROID_TOOLCHAIN_NAME}/mipself.xsc ${CMAKE_SHARED_LINKER_FLAGS}" )
set( CMAKE_MODULE_LINKER_FLAGS "-Wl,-T,${ANDROID_NDK}/toolchains/${ANDROID_TOOLCHAIN_NAME}/mipself.xsc ${CMAKE_MODULE_LINKER_FLAGS}" )
set( CMAKE_EXE_LINKER_FLAGS "-Wl,-T,${ANDROID_NDK}/toolchains/${ANDROID_TOOLCHAIN_NAME}/mipself.x ${CMAKE_EXE_LINKER_FLAGS}" )
set( CMAKE_SHARED_LINKER_FLAGS "-Wl,-T,${ANDROID_NDK}/toolchains/${ANDROID_GCC_TOOLCHAIN_NAME}/mipself.xsc ${CMAKE_SHARED_LINKER_FLAGS}" )
set( CMAKE_MODULE_LINKER_FLAGS "-Wl,-T,${ANDROID_NDK}/toolchains/${ANDROID_GCC_TOOLCHAIN_NAME}/mipself.xsc ${CMAKE_MODULE_LINKER_FLAGS}" )
set( CMAKE_EXE_LINKER_FLAGS "-Wl,-T,${ANDROID_NDK}/toolchains/${ANDROID_GCC_TOOLCHAIN_NAME}/mipself.x ${CMAKE_EXE_LINKER_FLAGS}" )
endif()
# configure rtti
@@ -1218,6 +1351,19 @@ endif()
include_directories( SYSTEM "${ANDROID_SYSROOT}/usr/include" ${ANDROID_STL_INCLUDE_DIRS} )
link_directories( "${CMAKE_INSTALL_PREFIX}/libs/${ANDROID_NDK_ABI_NAME}" )
# setup output directories
set( LIBRARY_OUTPUT_PATH_ROOT ${CMAKE_SOURCE_DIR} CACHE PATH "root for library output, set this to change where android libs are installed to" )
set( CMAKE_INSTALL_PREFIX "${ANDROID_TOOLCHAIN_ROOT}/user" CACHE STRING "path for installing" )
if(NOT _CMAKE_IN_TRY_COMPILE)
if( EXISTS "${CMAKE_SOURCE_DIR}/jni/CMakeLists.txt" )
set( EXECUTABLE_OUTPUT_PATH "${LIBRARY_OUTPUT_PATH_ROOT}/bin/${ANDROID_NDK_ABI_NAME}" CACHE PATH "Output directory for applications" )
else()
set( EXECUTABLE_OUTPUT_PATH "${LIBRARY_OUTPUT_PATH_ROOT}/bin" CACHE PATH "Output directory for applications" )
endif()
set( LIBRARY_OUTPUT_PATH "${LIBRARY_OUTPUT_PATH_ROOT}/libs/${ANDROID_NDK_ABI_NAME}" CACHE PATH "path for android libs" )
endif()
# set these global flags for cmake client scripts to change behavior
set( ANDROID True )
set( BUILD_ANDROID True )
@@ -1335,7 +1481,7 @@ endif()
# Variables controlling behavior or set by cmake toolchain:
# ANDROID_ABI : "armeabi-v7a" (default), "armeabi", "armeabi-v7a with NEON", "armeabi-v7a with VFPV3", "armeabi-v6 with VFP", "x86", "mips"
# ANDROID_NATIVE_API_LEVEL : 3,4,5,8,9,14 (depends on NDK version)
# ANDROID_SET_OBSOLETE_VARIABLES : ON/OFF
# ANDROID_STL : gnustl_static/gnustl_shared/stlport_static/stlport_shared/gabi++_static/gabi++_shared/system_re/system/none
# ANDROID_FORBID_SYGWIN : ON/OFF
# ANDROID_NO_UNDEFINED : ON/OFF
# ANDROID_SO_UNDEFINED : OFF/ON (default depends on NDK version)
@@ -1343,16 +1489,15 @@ endif()
# ANDROID_GOLD_LINKER : ON/OFF
# ANDROID_NOEXECSTACK : ON/OFF
# ANDROID_RELRO : ON/OFF
# Variables that takes effect only at first run:
# ANDROID_FORCE_ARM_BUILD : ON/OFF
# ANDROID_STL : gnustl_static/gnustl_shared/stlport_static/stlport_shared/gabi++_static/gabi++_shared/system_re/system/none
# ANDROID_STL_FORCE_FEATURES : ON/OFF
# LIBRARY_OUTPUT_PATH_ROOT : <any valid path>
# NDK_CCACHE : <path to your ccache executable>
# ANDROID_SET_OBSOLETE_VARIABLES : ON/OFF
# Can be set only at the first run:
# ANDROID_NDK
# ANDROID_STANDALONE_TOOLCHAIN
# ANDROID_TOOLCHAIN_NAME : "arm-linux-androideabi-4.4.3" or "arm-linux-androideabi-4.6" or "mipsel-linux-android-4.4.3" or "mipsel-linux-android-4.6" or "x86-4.4.3" or "x86-4.6"
# ANDROID_TOOLCHAIN_NAME : the NDK name of compiler toolchain
# LIBRARY_OUTPUT_PATH_ROOT : <any valid path>
# NDK_CCACHE : <path to your ccache executable>
# Obsolete:
# ANDROID_API_LEVEL : superseded by ANDROID_NATIVE_API_LEVEL
# ARM_TARGET : superseded by ANDROID_ABI
@@ -1375,10 +1520,11 @@ endif()
# BUILD_WITH_STANDALONE_TOOLCHAIN : TRUE if standalone toolchain is used
# ANDROID_NDK_HOST_SYSTEM_NAME : "windows", "linux-x86" or "darwin-x86" depending on host platform
# ANDROID_NDK_ABI_NAME : "armeabi", "armeabi-v7a", "x86" or "mips" depending on ANDROID_ABI
# ANDROID_NDK_RELEASE : one of r5, r5b, r5c, r6, r6b, r7, r7b, r7c, r8, r8b; set only for NDK
# ANDROID_NDK_RELEASE : one of r5, r5b, r5c, r6, r6b, r7, r7b, r7c, r8, r8b, r8c; set only for NDK
# ANDROID_ARCH_NAME : "arm" or "x86" or "mips" depending on ANDROID_ABI
# ANDROID_SYSROOT : path to the compiler sysroot
# TOOL_OS_SUFFIX : "" or ".exe" depending on host platform
# ANDROID_COMPILER_IS_CLANG : TRUE if clang compiler is used
# Obsolete:
# ARMEABI_NDK_NAME : superseded by ANDROID_NDK_ABI_NAME
#
@@ -1388,10 +1534,13 @@ endif()
# ANDROID_SUPPORTED_ABIS : list of currently allowed values for ANDROID_ABI
# ANDROID_TOOLCHAIN_MACHINE_NAME : "arm-linux-androideabi", "arm-eabi" or "i686-android-linux"
# ANDROID_TOOLCHAIN_ROOT : path to the top level of toolchain (standalone or placed inside NDK)
# ANDROID_CLANG_TOOLCHAIN_ROOT : path to clang tools
# ANDROID_SUPPORTED_NATIVE_API_LEVELS : list of native API levels found inside NDK
# ANDROID_STL_INCLUDE_DIRS : stl include paths
# ANDROID_RTTI : if rtti is enabled by the runtime
# ANDROID_EXCEPTIONS : if exceptions are enabled by the runtime
# ANDROID_GCC_TOOLCHAIN_NAME : read-only, differs from ANDROID_TOOLCHAIN_NAME only if clang is used
# ANDROID_CLANG_VERSION : version of clang compiler if clang is used
#
# Defaults:
# ANDROID_DEFAULT_NDK_API_LEVEL
+2 -2
Ver Arquivo
@@ -35,5 +35,5 @@ set_target_properties(${the_module} PROPERTIES
INSTALL_NAME_DIR lib
)
get_filename_component(lib_name "opencv_info" NAME)
install(FILES "${LIBRARY_OUTPUT_PATH}/${lib_name}" DESTINATION ${OPENCV_LIB_INSTALL_PATH} COMPONENT main)
get_filename_component(lib_name "libopencv_info.so" NAME)
install(FILES "${LIBRARY_OUTPUT_PATH}/${lib_name}" DESTINATION ${OPENCV_LIB_INSTALL_PATH} COMPONENT main)
+1 -1
Ver Arquivo
@@ -7,7 +7,7 @@ const char* GetLibraryList(void);
JNIEXPORT jstring JNICALL Java_org_opencv_android_StaticHelper_getLibraryList(JNIEnv *, jclass);
#define PACKAGE_NAME "org.opencv.lib_v" CVAUX_STR(CV_MAJOR_VERSION) CVAUX_STR(CV_MINOR_VERSION) "_" ANDROID_PACKAGE_PLATFORM
#define PACKAGE_REVISION CVAUX_STR(CV_SUBMINOR_VERSION) CVAUX_STR(ANDROID_PACKAGE_RELEASE)
#define PACKAGE_REVISION CVAUX_STR(CV_SUBMINOR_VERSION) "." CVAUX_STR(ANDROID_PACKAGE_RELEASE)
const char* GetPackageName(void)
{
+5
Ver Arquivo
@@ -16,3 +16,8 @@ native_camera_r4.0.0; armeabi-v7a; 14; /home/alexander/Projects/AndroidSource/4.
native_camera_r4.1.1; armeabi; 14; /home/alexander/Projects/AndroidSource/4.1.1
native_camera_r4.1.1; armeabi-v7a; 14; /home/alexander/Projects/AndroidSource/4.1.1
native_camera_r4.1.1; x86; 14; /home/alexander/Projects/AndroidSource/4.1.1
native_camera_r4.1.1; mips; 14; /home/alexander/Projects/AndroidSource/4.1.1_mips
native_camera_r4.2.0; armeabi-v7a; 14; /home/alexander/Projects/AndroidSource/4.2
native_camera_r4.2.0; armeabi; 14; /home/alexander/Projects/AndroidSource/4.2
native_camera_r4.2.0; x86; 14; /home/alexander/Projects/AndroidSource/4.2
native_camera_r4.2.0; mips; 14; /home/alexander/Projects/AndroidSource/4.2
+13 -6
Ver Arquivo
@@ -33,20 +33,27 @@ for s in ConfFile.readlines():
continue
shutil.rmtree(os.path.join(AndroidTreeRoot, "out", "target", "product", "generic", "system"), ignore_errors=True)
LinkerLibs = os.path.join(AndroidTreeRoot, "bin_arm", "system")
if (Arch == "x86"):
shutil.copytree(os.path.join(AndroidTreeRoot, "bin_x86", "system"), os.path.join(AndroidTreeRoot, "out", "target", "product", "generic", "system"))
LinkerLibs = os.path.join(AndroidTreeRoot, "bin_x86", "system")
elif (Arch == "mips"):
shutil.copytree(os.path.join(AndroidTreeRoot, "bin_mips", "system"), os.path.join(AndroidTreeRoot, "out", "target", "product", "generic", "system"))
else:
shutil.copytree(os.path.join(AndroidTreeRoot, "bin_arm", "system"), os.path.join(AndroidTreeRoot, "out", "target", "product", "generic", "system"))
LinkerLibs = os.path.join(AndroidTreeRoot, "bin_mips", "system")
if (not os.path.exists(LinkerLibs)):
print("Error: Paltform libs for linker in path \"%s\" not found" % LinkerLibs)
print("Building %s for %s\t[\033[91mFAILED\033[0m]" % (MakeTarget, Arch))
continue
shutil.copytree(LinkerLibs, os.path.join(AndroidTreeRoot, "out", "target", "product", "generic", "system"))
os.chdir(BuildDir)
BuildLog = os.path.join(BuildDir, "build.log")
CmakeCmdLine = "cmake -DCMAKE_TOOLCHAIN_FILE=../android.toolchain.cmake -DANDROID_SOURCE_TREE=\"%s\" -DANDROID_NATIVE_API_LEVEL=\"%s\" -DANDROID_ABI=\"%s\" -DANDROID_STL=stlport_static ../../ > \"%s\" 2>&1" % (AndroidTreeRoot, NativeApiLevel, Arch, BuildLog)
MakeCmdLine = "make %s >> \"%s\" 2>&1" % (MakeTarget, BuildLog);
print(CmakeCmdLine)
#print(CmakeCmdLine)
os.system(CmakeCmdLine)
print(MakeCmdLine)
#print(MakeCmdLine)
os.system(MakeCmdLine)
os.chdir(HomeDir)
CameraLib = os.path.join(BuildDir, "lib", Arch, "lib" + MakeTarget + ".so")
+1 -1
Ver Arquivo
@@ -4,5 +4,5 @@ cd `dirname $0`/..
mkdir -p build_service
cd build_service
cmake -DCMAKE_TOOLCHAIN_FILE=../android.toolchain.cmake -DANDROID_STL=stlport_static -DANDROID_STL_FORCE_FEATURES=OFF -DBUILD_ANDROID_SERVICE=ON -DANDROID_SOURCE_TREE=~/Projects/AndroidSource/ServiceStub/ $@ ../..
cmake -DCMAKE_TOOLCHAIN_FILE=../android.toolchain.cmake -DANDROID_TOOLCHAIN_NAME="arm-linux-androideabi-4.4.3" -DANDROID_STL=stlport_static -DANDROID_STL_FORCE_FEATURES=OFF -DBUILD_ANDROID_SERVICE=ON -DANDROID_SOURCE_TREE=~/Projects/AndroidSource/ServiceStub/ $@ ../..
+3 -3
Ver Arquivo
@@ -1,10 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.opencv.engine"
android:versionCode="20"
android:versionName="2.0" >
android:versionCode="23@ANDROID_PLATFORM_VERSION_CODE@"
android:versionName="2.3" >
<uses-sdk android:minSdkVersion="8" />
<uses-sdk android:minSdkVersion="@ANDROID_NATIVE_API_LEVEL@" />
<uses-feature android:name="android.hardware.touchscreen" android:required="false"/>
<application
+23 -1
Ver Arquivo
@@ -2,7 +2,29 @@ set(engine OpenCVEngine)
set(JNI_LIB_NAME ${engine} ${engine}_jni)
unset(__android_project_chain CACHE)
add_android_project(opencv_engine "${CMAKE_CURRENT_SOURCE_DIR}" SDK_TARGET 8 ${ANDROID_SDK_TARGET} IGNORE_JAVA ON)
add_android_project(opencv_engine "${CMAKE_CURRENT_SOURCE_DIR}" SDK_TARGET 8 ${ANDROID_SDK_TARGET} IGNORE_JAVA ON IGNORE_MANIFEST ON )
set(ANDROID_PLATFORM_VERSION_CODE "0")
if(ARMEABI_V7A)
if (ANDROID_NATIVE_API_LEVEL LESS 9)
set(ANDROID_PLATFORM_VERSION_CODE "2")
else()
set(ANDROID_PLATFORM_VERSION_CODE "3")
endif()
elseif(ARMEABI_V6)
set(ANDROID_PLATFORM_VERSION_CODE "1")
elseif(ARMEABI)
set(ANDROID_PLATFORM_VERSION_CODE "1")
elseif(X86)
set(ANDROID_PLATFORM_VERSION_CODE "4")
elseif(MIPS)
set(ANDROID_PLATFORM_VERSION_CODE "5")
else()
message(WARNING "Can not automatically determine the value for ANDROID_PLATFORM_VERSION_CODE")
endif()
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/${ANDROID_MANIFEST_FILE}" "${OpenCV_BINARY_DIR}/android/service/engine/.build/${ANDROID_MANIFEST_FILE}" @ONLY)
link_directories("${ANDROID_SOURCE_TREE}/out/target/product/generic/system/lib" "${ANDROID_SOURCE_TREE}/out/target/product/${ANDROID_PRODUCT}/system/lib" "${ANDROID_SOURCE_TREE}/bin/${ANDROID_ARCH_NAME}")
+2 -3
Ver Arquivo
@@ -35,7 +35,7 @@ LOCAL_MODULE := libOpenCVEngine
LOCAL_LDLIBS += -lz -lbinder -llog -lutils
LOCAL_LDFLAGS += -Wl,-allow-shlib-undefine
LOCAL_LDFLAGS += -Wl,-allow-shlib-undefined
include $(BUILD_SHARED_LIBRARY)
@@ -74,7 +74,6 @@ LOCAL_CFLAGS += -D__SUPPORT_MIPS
LOCAL_MODULE := libOpenCVEngine_jni
LOCAL_LDLIBS += -lz -lbinder -llog -lutils -landroid_runtime
LOCAL_SHARED_LIBRARIES = libOpenCVEngine
include $(BUILD_SHARED_LIBRARY)
@@ -83,4 +82,4 @@ include $(BUILD_SHARED_LIBRARY)
# Native test application
#---------------------------------------------------------------------
include $(LOCAL_PATH)/Tests/Tests.mk
#include $(LOCAL_PATH)/Tests/Tests.mk
+1
Ver Arquivo
@@ -2,4 +2,5 @@ APP_ABI := armeabi x86 mips
APP_PLATFORM := android-8
APP_STL := stlport_static
APP_CPPFLAGS := -fno-rtti -fno-exceptions
NDK_TOOLCHAIN_VERSION=4.4.3
#APP_OPTIM := debug
+1 -1
Ver Arquivo
@@ -36,7 +36,7 @@ LOCAL_CFLAGS += -D__SUPPORT_TEGRA3
LOCAL_CFLAGS += -D__SUPPORT_MIPS
#LOCAL_CFLAGS += -D__SUPPORT_ARMEABI_FEATURES
LOCAL_LDFLAGS = -Wl,-allow-shlib-undefined
#LOCAL_LDFLAGS = -Wl,-allow-shlib-undefined
LOCAL_MODULE := OpenCVEngineTestApp
@@ -5,10 +5,16 @@
#undef LOG_TAG
#define LOG_TAG "OpenCVEngine"
// OpenCV Engine API version
#ifndef OPEN_CV_ENGINE_VERSION
#define OPEN_CV_ENGINE_VERSION 2
#endif
#define LIB_OPENCV_INFO_NAME "libopencv_info.so"
// OpenCV Manager package name
#define OPENCV_ENGINE_PACKAGE "org.opencv.engine"
// Class name of OpenCV engine binder object. Is needned for connection to service
#define OPECV_ENGINE_CLASSNAME "org.opencv.engine.OpenCVEngineInterface"
#endif
@@ -4,11 +4,7 @@
#include <binder/IInterface.h>
#include <binder/Parcel.h>
#include <utils/String16.h>
// OpenCV Manager package name
#define OPENCV_ENGINE_PACKAGE "org.opencv.engine"
// Class name of OpenCV engine binder object. Is needned for connection to service
#define OPECV_ENGINE_CLASSNAME "org.opencv.engine.OpenCVEngineInterface"
#include "EngineCommon.h"
enum EngineMethonID
{
+7 -2
Ver Arquivo
@@ -179,7 +179,7 @@ unset(__android_project_chain CACHE)
#add_android_project(target_name ${path} NATIVE_DEPS opencv_core LIBRARY_DEPS ${OpenCV_BINARY_DIR} SDK_TARGET 11)
macro(add_android_project target path)
# parse arguments
set(android_proj_arglist NATIVE_DEPS LIBRARY_DEPS SDK_TARGET IGNORE_JAVA)
set(android_proj_arglist NATIVE_DEPS LIBRARY_DEPS SDK_TARGET IGNORE_JAVA IGNORE_MANIFEST)
set(__varname "android_proj_")
foreach(v ${android_proj_arglist})
set(${__varname}${v} "")
@@ -220,9 +220,13 @@ macro(add_android_project target path)
# get project sources
file(GLOB_RECURSE android_proj_files RELATIVE "${path}" "${path}/res/*" "${path}/src/*")
if(NOT android_proj_IGNORE_MANIFEST)
list(APPEND android_proj_files ${ANDROID_MANIFEST_FILE})
endif()
# copy sources out from the build tree
set(android_proj_file_deps "")
foreach(f ${android_proj_files} ${ANDROID_MANIFEST_FILE})
foreach(f ${android_proj_files})
add_custom_command(
OUTPUT "${android_proj_bin_dir}/${f}"
COMMAND ${CMAKE_COMMAND} -E copy "${path}/${f}" "${android_proj_bin_dir}/${f}"
@@ -324,6 +328,7 @@ macro(add_android_project target path)
install(FILES "${OpenCV_BINARY_DIR}/bin/${target}.apk" DESTINATION "samples" COMPONENT main)
get_filename_component(sample_dir "${path}" NAME)
#java part
list(REMOVE_ITEM android_proj_files ${ANDROID_MANIFEST_FILE})
foreach(f ${android_proj_files} ${ANDROID_MANIFEST_FILE})
get_filename_component(install_subdir "${f}" PATH)
install(FILES "${android_proj_bin_dir}/${f}" DESTINATION "samples/${sample_dir}/${install_subdir}" COMPONENT main)
+7 -2
Ver Arquivo
@@ -3,8 +3,13 @@ if(${CMAKE_VERSION} VERSION_LESS "2.8.3")
return()
endif()
if (NOT MSVC AND NOT CMAKE_COMPILER_IS_GNUCXX OR MINGW)
message(STATUS "CUDA compilation was disabled (due to unsuppoted host compiler).")
if (WIN32 AND NOT MSVC)
message(STATUS "CUDA compilation is disabled (due to only Visual Studio compiler suppoted on your platform).")
return()
endif()
if (CMAKE_COMPILER_IS_GNUCXX AND NOT APPLE AND CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
message(STATUS "CUDA compilation is disabled (due to Clang unsuppoted on your platform).")
return()
endif()
+1 -1
Ver Arquivo
@@ -54,7 +54,7 @@ endif()
# Detect GNU version:
# ----------------------------------------------------------------------------
if(CMAKE_COMPILER_IS_GNUCXX)
execute_process(COMMAND ${CMAKE_CXX_COMPILER} ${CMAKE_CXX_COMPILER_ARG1} --version
execute_process(COMMAND ${CMAKE_CXX_COMPILER} ${CMAKE_CXX_COMPILER_ARG1} -dumpversion
OUTPUT_VARIABLE CMAKE_OPENCV_GCC_VERSION_FULL
OUTPUT_STRIP_TRAILING_WHITESPACE)
+6
Ver Arquivo
@@ -71,6 +71,12 @@ if(ANDROID)
endforeach()
string(REPLACE "opencv_" "" OPENCV_MODULES_CONFIGMAKE "${OPENCV_MODULES_CONFIGMAKE}")
# prepare 3rd-party component list without TBB for armeabi and mips platforms. TBB is useless there.
set(OPENCV_3RDPARTY_COMPONENTS_CONFIGMAKE_NO_TBB ${OPENCV_3RDPARTY_COMPONENTS_CONFIGMAKE})
foreach(mod ${OPENCV_3RDPARTY_COMPONENTS_CONFIGMAKE_NO_TBB})
string(REPLACE "tbb" "" OPENCV_3RDPARTY_COMPONENTS_CONFIGMAKE_NO_TBB "${OPENCV_3RDPARTY_COMPONENTS_CONFIGMAKE_NO_TBB}")
endforeach()
if(BUILD_FAT_JAVA_LIB)
set(OPENCV_LIBS_CONFIGMAKE java)
else()
+1 -1
Ver Arquivo
@@ -5,7 +5,7 @@ string(REGEX REPLACE ".+CV_MAJOR_VERSION[ ]+([0-9]+).*" "\\1" OPENCV_VERSION_MAJ
string(REGEX REPLACE ".+CV_MINOR_VERSION[ ]+([0-9]+).*" "\\1" OPENCV_VERSION_MINOR "${OPENCV_VERSION_PARTS}")
string(REGEX REPLACE ".+CV_SUBMINOR_VERSION[ ]+([0-9]+).*" "\\1" OPENCV_VERSION_PATCH "${OPENCV_VERSION_PARTS}")
set(OPENCV_VERSION "${OPENCV_VERSION_MAJOR}.${OPENCV_VERSION_MINOR}.${OPENCV_VERSION_PATCH}")
set(OPENCV_VERSION "${OPENCV_VERSION_MAJOR}.${OPENCV_VERSION_MINOR}.${OPENCV_VERSION_PATCH}.1")
set(OPENCV_SOVERSION "${OPENCV_VERSION_MAJOR}.${OPENCV_VERSION_MINOR}")
# create a dependency on version file
+16 -2
Ver Arquivo
@@ -29,8 +29,22 @@ ifeq ($(OPENCV_LIB_TYPE),SHARED)
OPENCV_3RDPARTY_COMPONENTS:=
OPENCV_EXTRA_COMPONENTS:=
else
OPENCV_3RDPARTY_COMPONENTS:=@OPENCV_3RDPARTY_COMPONENTS_CONFIGMAKE@
OPENCV_EXTRA_COMPONENTS:=@OPENCV_EXTRA_COMPONENTS_CONFIGMAKE@
ifeq ($(TARGET_ARCH_ABI),armeabi-v7a)
OPENCV_3RDPARTY_COMPONENTS:=@OPENCV_3RDPARTY_COMPONENTS_CONFIGMAKE@
OPENCV_EXTRA_COMPONENTS:=@OPENCV_EXTRA_COMPONENTS_CONFIGMAKE@
endif
ifeq ($(TARGET_ARCH_ABI),x86)
OPENCV_3RDPARTY_COMPONENTS:=@OPENCV_3RDPARTY_COMPONENTS_CONFIGMAKE@
OPENCV_EXTRA_COMPONENTS:=@OPENCV_EXTRA_COMPONENTS_CONFIGMAKE@
endif
ifeq ($(TARGET_ARCH_ABI),armeabi)
OPENCV_3RDPARTY_COMPONENTS:=@OPENCV_3RDPARTY_COMPONENTS_CONFIGMAKE_NO_TBB@
OPENCV_EXTRA_COMPONENTS:=@OPENCV_EXTRA_COMPONENTS_CONFIGMAKE@
endif
ifeq ($(TARGET_ARCH_ABI),mips)
OPENCV_3RDPARTY_COMPONENTS:=@OPENCV_3RDPARTY_COMPONENTS_CONFIGMAKE_NO_TBB@
OPENCV_EXTRA_COMPONENTS:=@OPENCV_EXTRA_COMPONENTS_CONFIGMAKE@
endif
endif
ifeq (${OPENCV_CAMERA_MODULES},on)
+2
Ver Arquivo
@@ -1,3 +1,5 @@
#/usr/bin/env python
import sys, glob
sys.path.append("../modules/python/src2/")
+2
Ver Arquivo
@@ -1,3 +1,5 @@
#/usr/bin/env python
import os, sys, fnmatch, re
sys.path.append("../modules/python/src2/")
+2
Ver Arquivo
@@ -1,3 +1,5 @@
#/usr/bin/env python
# -*- coding: utf-8 -*-
#
# opencvstd documentation build configuration file, created by
+1
Ver Arquivo
@@ -1,3 +1,4 @@
#/usr/bin/env python
# -*- coding: utf-8 -*-
"""
ocv domain, a modified copy of sphinx.domains.cpp + shpinx.domains.python.
Arquivo binário não exibido.
Diferenças do arquivo suprimidas por serem muito extensas Carregar Diff
Arquivo binário não exibido.
Diferenças do arquivo suprimidas por serem muito extensas Carregar Diff
Arquivo binário não exibido.
+2
Ver Arquivo
@@ -1,3 +1,5 @@
#/usr/bin/env python
import sys
f=open(sys.argv[1], "rt")
+2
Ver Arquivo
@@ -1,3 +1,5 @@
#/usr/bin/env python
"""gen_pattern.py
To run:
-c 10 -r 12 -o out.svg
+2
Ver Arquivo
@@ -1,3 +1,5 @@
#/usr/bin/env python
# svgfig.py copyright (C) 2008 Jim Pivarski <jpivarski@gmail.com>
#
# This program is free software; you can redistribute it and/or
+2
Ver Arquivo
@@ -1,3 +1,5 @@
#/usr/bin/env python
import os, sys, re
finput=open(sys.argv[1], "rt")
@@ -334,7 +334,11 @@ and exceptions are used in C++, it also should be created. Example of the file :
APP_STL := gnustl_static
APP_CPPFLAGS := -frtti -fexceptions
APP_ABI := armeabi-v7a
APP_ABI := all
.. note:: We recommend setting ``APP_ABI := all`` for all targets. If you want to specify the
target explicitly, use ``armeabi`` for ARMv5/ARMv6, ``armeabi-v7a`` for ARMv7, ``x86``
for Intel Atom or ``mips`` for MIPS.
.. _NDK_build_cli:
+1 -1
Ver Arquivo
@@ -6,7 +6,7 @@ set(the_description "Auxiliary module for Android native camera support")
set(OPENCV_MODULE_TYPE STATIC)
ocv_define_module(androidcamera INTERNAL opencv_core log dl)
ocv_include_directories("${CMAKE_CURRENT_SOURCE_DIR}/camera_wrapper")
ocv_include_directories("${CMAKE_CURRENT_SOURCE_DIR}/camera_wrapper" "${OpenCV_SOURCE_DIR}/android/service/engine/jni/include")
# Android source tree for native camera
SET (ANDROID_SOURCE_TREE "ANDROID_SOURCE_TREE-NOTFOUND" CACHE PATH
@@ -1,4 +1,4 @@
#if !defined(ANDROID_r2_2_0) && !defined(ANDROID_r2_3_3) && !defined(ANDROID_r3_0_1) && !defined(ANDROID_r4_0_0) && !defined(ANDROID_r4_0_3) && !defined(ANDROID_r4_1_1)
#if !defined(ANDROID_r2_2_0) && !defined(ANDROID_r2_3_3) && !defined(ANDROID_r3_0_1) && !defined(ANDROID_r4_0_0) && !defined(ANDROID_r4_0_3) && !defined(ANDROID_r4_1_1) && !defined(ANDROID_r4_2_0)
# error Building camera wrapper for your version of Android is not supported by OpenCV. You need to modify OpenCV sources in order to compile camera wrapper for your version of Android.
#endif
@@ -18,7 +18,7 @@
# define MAGIC_OPENCV_TEXTURE_ID (0x10)
#else // defined(ANDROID_r3_0_1) || defined(ANDROID_r4_0_0) || defined(ANDROID_r4_0_3)
//TODO: This is either 2.2 or 2.3. Include the headers for ISurface.h access
#if defined(ANDROID_r4_1_1)
#if defined(ANDROID_r4_1_1) || defined(ANDROID_r4_2_0)
#include <gui/ISurface.h>
#include <gui/BufferQueue.h>
#else
@@ -60,7 +60,7 @@ using namespace android;
void debugShowFPS();
#if defined(ANDROID_r4_1_1)
#if defined(ANDROID_r4_1_1) || defined(ANDROID_r4_2_0)
class ConsumerListenerStub: public BufferQueue::ConsumerListener
{
public:
@@ -280,7 +280,7 @@ public:
}
virtual void postData(int32_t msgType, const sp<IMemory>& dataPtr
#if defined(ANDROID_r4_0_0) || defined(ANDROID_r4_0_3) || defined(ANDROID_r4_1_1)
#if defined(ANDROID_r4_0_0) || defined(ANDROID_r4_0_3) || defined(ANDROID_r4_1_1) || defined(ANDROID_r4_2_0)
,camera_frame_metadata_t*
#endif
)
@@ -526,7 +526,7 @@ CameraHandler* CameraHandler::initCameraConnect(const CameraCallback& callback,
pdstatus = camera->setPreviewTexture(surfaceTexture);
if (pdstatus != 0)
LOGE("initCameraConnect: failed setPreviewTexture call; camera migth not work correctly");
#elif defined(ANDROID_r4_1_1)
#elif defined(ANDROID_r4_1_1) || defined(ANDROID_r4_2_0)
sp<BufferQueue> bufferQueue = new BufferQueue();
sp<BufferQueue::ConsumerListener> queueListener = new ConsumerListenerStub();
bufferQueue->consumerConnect(queueListener);
+6 -6
Ver Arquivo
@@ -9,6 +9,7 @@
#include <opencv2/core/version.hpp>
#include "camera_activity.hpp"
#include "camera_wrapper.h"
#include "EngineCommon.h"
#undef LOG_TAG
#undef LOGE
@@ -267,12 +268,13 @@ void CameraWrapperConnector::fillListWrapperLibs(const string& folderPath, vecto
std::string CameraWrapperConnector::getDefaultPathLibFolder()
{
const string packageList[] = {"tegra3", "armv7a_neon", "armv7a", "armv5", "x86"};
for (size_t i = 0; i < 5; i++)
#define BIN_PACKAGE_NAME(x) "org.opencv.lib_v" CVAUX_STR(CV_MAJOR_VERSION) CVAUX_STR(CV_MINOR_VERSION) "_" x
const char* const packageList[] = {BIN_PACKAGE_NAME("armv7a"), OPENCV_ENGINE_PACKAGE};
for (size_t i = 0; i < sizeof(packageList)/sizeof(packageList[0]); i++)
{
char path[128];
sprintf(path, "/data/data/org.opencv.lib_v%d%d_%s/lib/", CV_MAJOR_VERSION, CV_MINOR_VERSION, packageList[i].c_str());
LOGD("Trying package \"%s\" (\"%s\")", packageList[i].c_str(), path);
sprintf(path, "/data/data/%s/lib/", packageList[i]);
LOGD("Trying package \"%s\" (\"%s\")", packageList[i], path);
DIR* dir = opendir(path);
if (!dir)
@@ -427,7 +429,6 @@ void CameraActivity::applyProperties()
int CameraActivity::getFrameWidth()
{
LOGD("CameraActivity::getFrameWidth()");
if (frameWidth <= 0)
frameWidth = getProperty(ANDROID_CAMERA_PROPERTY_FRAMEWIDTH);
return frameWidth;
@@ -435,7 +436,6 @@ int CameraActivity::getFrameWidth()
int CameraActivity::getFrameHeight()
{
LOGD("CameraActivity::getFrameHeight()");
if (frameHeight <= 0)
frameHeight = getProperty(ANDROID_CAMERA_PROPERTY_FRAMEHEIGHT);
return frameHeight;
+1
Ver Arquivo
@@ -86,6 +86,7 @@ PERF_TEST(PointsNum_Algo, solveP3P)
add(points2d, noise, points2d);
declare.in(points3d, points2d);
declare.time(100);
TEST_CYCLE_N(1000)
{
+1 -1
Ver Arquivo
@@ -1,6 +1,6 @@
#ifdef __GNUC__
# pragma GCC diagnostic ignored "-Wmissing-declarations"
# ifdef __clang__
# if defined __clang__ || defined __APPLE__
# pragma GCC diagnostic ignored "-Wmissing-prototypes"
# pragma GCC diagnostic ignored "-Wextra"
# endif
+1 -1
Ver Arquivo
@@ -1,6 +1,6 @@
#ifdef __GNUC__
# pragma GCC diagnostic ignored "-Wmissing-declarations"
# ifdef __clang__
# if defined __clang__ || defined __APPLE__
# pragma GCC diagnostic ignored "-Wmissing-prototypes"
# pragma GCC diagnostic ignored "-Wextra"
# endif
@@ -1,3 +1,5 @@
#/usr/bin/env python
import sys
import os.path
+3 -2
Ver Arquivo
@@ -208,7 +208,7 @@ Retina::getMagno
Retina::getParameters
+++++++++++++++++++++
.. ocv:function:: struct Retina::RetinaParameters Retina::getParameters()
.. ocv:function:: Retina::RetinaParameters Retina::getParameters()
Retrieve the current parameters values in a *Retina::RetinaParameters* structure
@@ -323,7 +323,8 @@ Retina::RetinaParameters
========================
.. ocv:struct:: Retina::RetinaParameters
This structure merges all the parameters that can be adjusted threw the **Retina::setup()**, **Retina::setupOPLandIPLParvoChannel** and **Retina::setupIPLMagnoChannel** setup methods
This structure merges all the parameters that can be adjusted threw the **Retina::setup()**, **Retina::setupOPLandIPLParvoChannel** and **Retina::setupIPLMagnoChannel** setup methods
Parameters structure for better clarity, check explenations on the comments of methods : setupOPLandIPLParvoChannel and setupIPLMagnoChannel. ::
class RetinaParameters{
@@ -583,7 +583,7 @@ namespace cv
virtual ~StereoVar();
//! the stereo correspondence operator that computes disparity map for the specified rectified stereo pair
CV_WRAP_AS(compute) virtual void operator()(const Mat& left, const Mat& right, Mat& disp);
CV_WRAP_AS(compute) virtual void operator()(const Mat& left, const Mat& right, CV_OUT Mat& disp);
CV_PROP_RW int levels;
CV_PROP_RW double pyrScale;
@@ -1,6 +1,8 @@
#if defined(__linux__) || defined(LINUX) || defined(__APPLE__) || defined(ANDROID)
#include "opencv2/contrib/detection_based_tracker.hpp"
#include <pthread.h>
#define DEBUGLOGS 1
#ifdef ANDROID
+7 -1
Ver Arquivo
@@ -300,7 +300,13 @@ public:
//------------------------------------------------------------------------------
// FaceRecognizer
//------------------------------------------------------------------------------
void FaceRecognizer::update(InputArrayOfArrays, InputArray) {
void FaceRecognizer::update(InputArrayOfArrays src, InputArray labels ) {
if( dynamic_cast<LBPH*>(this) != 0 )
{
dynamic_cast<LBPH*>(this)->update( src, labels );
return;
}
string error_msg = format("This FaceRecognizer (%s) does not support updating, you have to use FaceRecognizer::train to update it.", this->name().c_str());
CV_Error(CV_StsNotImplemented, error_msg);
}
+1 -1
Ver Arquivo
@@ -1,6 +1,6 @@
#ifdef __GNUC__
# pragma GCC diagnostic ignored "-Wmissing-declarations"
# ifdef __clang__
# if defined __clang__ || defined __APPLE__
# pragma GCC diagnostic ignored "-Wmissing-prototypes"
# pragma GCC diagnostic ignored "-Wextra"
# endif
+2 -2
Ver Arquivo
@@ -204,11 +204,11 @@ CV_EXPORTS ErrorCallback redirectError( ErrorCallback errCallback,
#ifdef __GNUC__
#define CV_Error( code, msg ) cv::error( cv::Exception(code, msg, __func__, __FILE__, __LINE__) )
#define CV_Error_( code, args ) cv::error( cv::Exception(code, cv::format args, __func__, __FILE__, __LINE__) )
#define CV_Assert( expr ) if((expr)) ; else cv::error( cv::Exception(CV_StsAssert, #expr, __func__, __FILE__, __LINE__) )
#define CV_Assert( expr ) if(!!(expr)) ; else cv::error( cv::Exception(CV_StsAssert, #expr, __func__, __FILE__, __LINE__) )
#else
#define CV_Error( code, msg ) cv::error( cv::Exception(code, msg, "", __FILE__, __LINE__) )
#define CV_Error_( code, args ) cv::error( cv::Exception(code, cv::format args, "", __FILE__, __LINE__) )
#define CV_Assert( expr ) if((expr)) ; else cv::error( cv::Exception(CV_StsAssert, #expr, "", __FILE__, __LINE__) )
#define CV_Assert( expr ) if(!!(expr)) ; else cv::error( cv::Exception(CV_StsAssert, #expr, "", __FILE__, __LINE__) )
#endif
#ifdef _DEBUG
+15 -4
Ver Arquivo
@@ -56,7 +56,7 @@
#define CV_XADD(addr,delta) _InterlockedExchangeAdd(const_cast<void*>(reinterpret_cast<volatile void*>(addr)), delta)
#elif defined __GNUC__
#if defined __clang__ && __clang_major__ >= 3
#if defined __clang__ && __clang_major__ >= 3 && !defined __ANDROID__
#ifdef __ATOMIC_SEQ_CST
#define CV_XADD(addr, delta) __c11_atomic_fetch_add((_Atomic(int)*)(addr), (delta), __ATOMIC_SEQ_CST)
#else
@@ -3873,10 +3873,21 @@ template<typename _Tp> inline std::ostream& operator<<(std::ostream& out, const
template<typename _Tp, int n> inline std::ostream& operator<<(std::ostream& out, const Vec<_Tp, n>& vec)
{
out << "[";
for (int i = 0; i < n - 1; ++i) {
out << vec[i] << ", ";
if(Vec<_Tp, n>::depth < CV_32F)
{
for (int i = 0; i < n - 1; ++i) {
out << (int)vec[i] << ", ";
}
out << (int)vec[n-1] << "]";
}
else
{
for (int i = 0; i < n - 1; ++i) {
out << vec[i] << ", ";
}
out << vec[n-1] << "]";
}
out << vec[n-1] << "]";
return out;
}
+1 -1
Ver Arquivo
@@ -53,6 +53,6 @@
#define CVAUX_STR_EXP(__A) #__A
#define CVAUX_STR(__A) CVAUX_STR_EXP(__A)
#define CV_VERSION CVAUX_STR(CV_MAJOR_VERSION) "." CVAUX_STR(CV_MINOR_VERSION) "." CVAUX_STR(CV_SUBMINOR_VERSION)
#define CV_VERSION CVAUX_STR(CV_MAJOR_VERSION) "." CVAUX_STR(CV_MINOR_VERSION) "." CVAUX_STR(CV_SUBMINOR_VERSION) ".1"
#endif
+1
Ver Arquivo
@@ -123,6 +123,7 @@ PERF_TEST_P(Size_MatType, add, TYPICAL_MATS_CORE_ARITHM)
cv::Mat c = Mat(sz, type);
declare.in(a, b, WARMUP_RNG).out(c);
declare.time(50);
if (CV_MAT_DEPTH(type) == CV_32S)
{
+4
Ver Arquivo
@@ -19,6 +19,7 @@ PERF_TEST_P(Size_MatType, bitwise_not, TYPICAL_MATS_BITW_ARITHM)
cv::Mat c = Mat(sz, type);
declare.in(a, WARMUP_RNG).out(c);
declare.time(100);
TEST_CYCLE() cv::bitwise_not(a, c);
@@ -34,6 +35,7 @@ PERF_TEST_P(Size_MatType, bitwise_and, TYPICAL_MATS_BITW_ARITHM)
cv::Mat c = Mat(sz, type);
declare.in(a, b, WARMUP_RNG).out(c);
declare.time(100);
TEST_CYCLE() bitwise_and(a, b, c);
@@ -49,6 +51,7 @@ PERF_TEST_P(Size_MatType, bitwise_or, TYPICAL_MATS_BITW_ARITHM)
cv::Mat c = Mat(sz, type);
declare.in(a, b, WARMUP_RNG).out(c);
declare.time(100);
TEST_CYCLE() bitwise_or(a, b, c);
@@ -64,6 +67,7 @@ PERF_TEST_P(Size_MatType, bitwise_xor, TYPICAL_MATS_BITW_ARITHM)
cv::Mat c = Mat(sz, type);
declare.in(a, b, WARMUP_RNG).out(c);
declare.time(100);
TEST_CYCLE() bitwise_xor(a, b, c);
+1
Ver Arquivo
@@ -21,6 +21,7 @@ PERF_TEST_P( MatType_Length, dot,
Mat b(size, size, type);
declare.in(a, b, WARMUP_RNG);
declare.time(100);
double product;
+1
Ver Arquivo
@@ -150,6 +150,7 @@ PERF_TEST_P(Size_MatType_NormType, normalize_mask,
if(normType==NORM_L2) alpha = (double)src.total()/10;
declare.in(src, WARMUP_RNG).in(mask).out(dst);
declare.time(100);
TEST_CYCLE() normalize(src, dst, alpha, 0., normType, -1, mask);
+1 -1
Ver Arquivo
@@ -1,6 +1,6 @@
#ifdef __GNUC__
# pragma GCC diagnostic ignored "-Wmissing-declarations"
# ifdef __clang__
# if defined __clang__ || defined __APPLE__
# pragma GCC diagnostic ignored "-Wmissing-prototypes"
# pragma GCC diagnostic ignored "-Wextra"
# endif
+2
Ver Arquivo
@@ -32,6 +32,7 @@ PERF_TEST_P(Size_MatType_ROp, reduceR,
Mat vec(1, sz.width, ddepth < 0 ? matType : ddepth);
declare.in(src, WARMUP_RNG).out(vec);
declare.time(100);
TEST_CYCLE() reduce(src, vec, 0, reduceOp, ddepth);
@@ -58,6 +59,7 @@ PERF_TEST_P(Size_MatType_ROp, reduceC,
Mat vec(sz.height, 1, ddepth < 0 ? matType : ddepth);
declare.in(src, WARMUP_RNG).out(vec);
declare.time(100);
TEST_CYCLE() reduce(src, vec, 1, reduceOp, ddepth);
+14 -55
Ver Arquivo
@@ -954,7 +954,7 @@ double cv::invert( InputArray _src, OutputArray _dst, int method )
size_t esz = CV_ELEM_SIZE(type);
int m = src.rows, n = src.cols;
if( method == DECOMP_SVD )
if( method == DECOMP_SVD )
{
int nm = std::min(m, n);
@@ -1097,66 +1097,25 @@ double cv::invert( InputArray _src, OutputArray _dst, int method )
double d = det3(Sf);
if( d != 0. )
{
float CV_DECL_ALIGNED(16) t[12];
double t[12];
result = true;
d = 1./d;
#if CV_SSE2
if(USE_SSE2)
{
__m128 det =_mm_set1_ps((float)d);
__m128 s0 = _mm_loadu_ps((const float*)srcdata);//s0 = Sf(0,0) Sf(0,1) Sf(0,2) ***
__m128 s1 = _mm_loadu_ps((const float*)(srcdata+srcstep));//s1 = Sf(1,0) Sf(1,1) Sf(1,2) ***
__m128 s2 = _mm_set_ps(0.f, Sf(2,2), Sf(2,1), Sf(2,0)); //s2 = Sf(2,0) Sf(2,1) Sf(2,2) ***
t[0] = (((double)Sf(1,1) * Sf(2,2) - (double)Sf(1,2) * Sf(2,1)) * d);
t[1] = (((double)Sf(0,2) * Sf(2,1) - (double)Sf(0,1) * Sf(2,2)) * d);
t[2] = (((double)Sf(0,1) * Sf(1,2) - (double)Sf(0,2) * Sf(1,1)) * d);
__m128 r0 = _mm_shuffle_ps(s1,s1,_MM_SHUFFLE(3,0,2,1)); //r0 = Sf(1,1) Sf(1,2) Sf(1,0) ***
__m128 r1 = _mm_shuffle_ps(s2,s2,_MM_SHUFFLE(3,1,0,2)); //r1 = Sf(2,2) Sf(2,0) Sf(2,1) ***
__m128 r2 = _mm_shuffle_ps(s2,s2,_MM_SHUFFLE(3,0,2,1)); //r2 = Sf(2,1) Sf(2,2) Sf(2,0) ***
t[3] = (((double)Sf(1,2) * Sf(2,0) - (double)Sf(1,0) * Sf(2,2)) * d);
t[4] = (((double)Sf(0,0) * Sf(2,2) - (double)Sf(0,2) * Sf(2,0)) * d);
t[5] = (((double)Sf(0,2) * Sf(1,0) - (double)Sf(0,0) * Sf(1,2)) * d);
__m128 t0 = _mm_mul_ps(s0, r0);//t0 = Sf(0,0)*Sf(1,1) Sf(0,1)*Sf(1,2) Sf(0,2)*Sf(1,0) ***
__m128 t1 = _mm_mul_ps(s0, r1);//t1 = Sf(0,0)*Sf(2,2) Sf(0,1)*Sf(2,0) Sf(0,2)*Sf(2,1) ***
__m128 t2 = _mm_mul_ps(s1, r2);//t2 = Sf(1,0)*Sf(2,1) Sf(1,1)*Sf(2,2) Sf(1,2)*Sf(2,0) ***
t[6] = (((double)Sf(1,0) * Sf(2,1) - (double)Sf(1,1) * Sf(2,0)) * d);
t[7] = (((double)Sf(0,1) * Sf(2,0) - (double)Sf(0,0) * Sf(2,1)) * d);
t[8] = (((double)Sf(0,0) * Sf(1,1) - (double)Sf(0,1) * Sf(1,0)) * d);
__m128 r3 = _mm_shuffle_ps(s0,s0,_MM_SHUFFLE(3,0,2,1));//r3 = Sf(0,1) Sf(0,2) Sf(0,0) ***
__m128 r4 = _mm_shuffle_ps(s0,s0,_MM_SHUFFLE(3,1,0,2));//r4 = Sf(0,2) Sf(0,0) Sf(0,1) ***
__m128 t00 = _mm_mul_ps(s1, r3);//t00 = Sf(1,0)*Sf(0,1) Sf(1,1)*Sf(0,2) Sf(1,2)*Sf(0,0) ***
__m128 t11 = _mm_mul_ps(s2, r4);//t11 = Sf(2,0)*Sf(0,2) Sf(2,1)*Sf(0,0) Sf(2,2)*Sf(0,1) ***
__m128 t22 = _mm_mul_ps(s2, r0);//t22 = Sf(2,0)*Sf(1,1) Sf(2,1)*Sf(1,2) Sf(2,2)*Sf(1,0) ***
t0 = _mm_mul_ps(_mm_sub_ps(t0,t00), det);//Sf(0,0)*Sf(1,1) Sf(0,1)*Sf(1,2) Sf(0,2)*Sf(1,0) ***
//-Sf(1,0)*Sf(0,1) -Sf(1,1)*Sf(0,2) -Sf(1,2)*Sf(0,0)
t1 = _mm_mul_ps(_mm_sub_ps(t1,t11), det);//Sf(0,0)*Sf(2,2) Sf(0,1)*Sf(2,0) Sf(0,2)*Sf(2,1) ***
//-Sf(2,0)*Sf(0,2) -Sf(2,1)*Sf(0,0) -Sf(2,2)*Sf(0,1)
t2 = _mm_mul_ps(_mm_sub_ps(t2,t22), det);//Sf(1,0)*Sf(2,1) Sf(1,1)*Sf(2,2) Sf(1,2)*Sf(2,0) ***
//-Sf(2,0)*Sf(1,1) -Sf(2,1)*Sf(1,2) -Sf(2,2)*Sf(1,0)
_mm_store_ps(t, t0);
_mm_store_ps(t+4, t1);
_mm_store_ps(t+8, t2);
Df(0,0) = t[9]; Df(0,1) = t[6]; Df(0,2) = t[1];
Df(1,0) = t[10]; Df(1,1) = t[4]; Df(1,2) = t[2];
Df(2,0) = t[8]; Df(2,1) = t[5]; Df(2,2) = t[0];
}
else
#endif
{
t[0] = (float)(((double)Sf(1,1) * Sf(2,2) - (double)Sf(1,2) * Sf(2,1)) * d);
t[1] = (float)(((double)Sf(0,2) * Sf(2,1) - (double)Sf(0,1) * Sf(2,2)) * d);
t[2] = (float)(((double)Sf(0,1) * Sf(1,2) - (double)Sf(0,2) * Sf(1,1)) * d);
t[3] = (float)(((double)Sf(1,2) * Sf(2,0) - (double)Sf(1,0) * Sf(2,2)) * d);
t[4] = (float)(((double)Sf(0,0) * Sf(2,2) - (double)Sf(0,2) * Sf(2,0)) * d);
t[5] = (float)(((double)Sf(0,2) * Sf(1,0) - (double)Sf(0,0) * Sf(1,2)) * d);
t[6] = (float)(((double)Sf(1,0) * Sf(2,1) - (double)Sf(1,1) * Sf(2,0)) * d);
t[7] = (float)(((double)Sf(0,1) * Sf(2,0) - (double)Sf(0,0) * Sf(2,1)) * d);
t[8] = (float)(((double)Sf(0,0) * Sf(1,1) - (double)Sf(0,1) * Sf(1,0)) * d);
Df(0,0) = t[0]; Df(0,1) = t[1]; Df(0,2) = t[2];
Df(1,0) = t[3]; Df(1,1) = t[4]; Df(1,2) = t[5];
Df(2,0) = t[6]; Df(2,1) = t[7]; Df(2,2) = t[8];
}
Df(0,0) = (float)t[0]; Df(0,1) = (float)t[1]; Df(0,2) = (float)t[2];
Df(1,0) = (float)t[3]; Df(1,1) = (float)t[4]; Df(1,2) = (float)t[5];
Df(2,0) = (float)t[6]; Df(2,1) = (float)t[7]; Df(2,2) = (float)t[8];
}
}
else
+8
Ver Arquivo
@@ -45,6 +45,14 @@
#include "opencv2/core/opengl_interop.hpp"
#include "opencv2/core/gpumat.hpp"
#if defined WIN32 || defined _WIN32 || defined WINCE
#include <windows.h>
#undef small
#undef min
#undef max
#undef abs
#endif
#ifdef HAVE_OPENGL
#ifdef __APPLE__
#include <OpenGL/gl.h>
+15
Ver Arquivo
@@ -2453,6 +2453,21 @@ REGISTER_TYPED_TEST_CASE_P(Core_CheckRange, Negative, Positive, Bounds, Zero);
typedef ::testing::Types<signed char,unsigned char, signed short, unsigned short, signed int> mat_data_types;
INSTANTIATE_TYPED_TEST_CASE_P(Negative_Test, Core_CheckRange, mat_data_types);
TEST(Core_Invert, small)
{
cv::Mat a = (cv::Mat_<float>(3,3) << 2.42104644730331, 1.81444796521479, -3.98072565304758, 0, 7.08389214348967e-3, 5.55326770986007e-3, 0,0, 7.44556154284261e-3);
//cv::randu(a, -1, 1);
cv::Mat b = a.t()*a;
cv::Mat c, i = Mat_<float>::eye(3, 3);
cv::invert(b, c, cv::DECOMP_LU); //std::cout << b*c << std::endl;
ASSERT_LT( cv::norm(b*c, i, CV_C), 0.1 );
cv::invert(b, c, cv::DECOMP_SVD); //std::cout << b*c << std::endl;
ASSERT_LT( cv::norm(b*c, i, CV_C), 0.1 );
cv::invert(b, c, cv::DECOMP_CHOLESKY); //std::cout << b*c << std::endl;
ASSERT_LT( cv::norm(b*c, i, CV_C), 0.1 );
}
/////////////////////////////////////////////////////////////////////////////////////////////////////
TEST(Core_CovarMatrix, accuracy) { Core_CovarMatrixTest test; test.safe_run(); }
+1 -1
Ver Arquivo
@@ -1,6 +1,6 @@
#ifdef __GNUC__
# pragma GCC diagnostic ignored "-Wmissing-declarations"
# ifdef __clang__
# if defined __clang__ || defined __APPLE__
# pragma GCC diagnostic ignored "-Wmissing-prototypes"
# pragma GCC diagnostic ignored "-Wextra"
# endif
@@ -92,6 +92,7 @@ PERF_TEST_P(Source_CrossCheck, batchDistance_L2,
generateData(queryDescriptors, trainDescriptors, sourceType);
declare.time(50);
TEST_CYCLE()
{
batchDistance(queryDescriptors, trainDescriptors, dist, CV_32F, (isCrossCheck) ? ndix : noArray(),
@@ -118,6 +119,7 @@ PERF_TEST_P(Norm_CrossCheck, batchDistance_32F,
Mat ndix;
generateData(queryDescriptors, trainDescriptors, CV_32F);
declare.time(100);
TEST_CYCLE()
{
+1 -1
Ver Arquivo
@@ -1,6 +1,6 @@
#ifdef __GNUC__
# pragma GCC diagnostic ignored "-Wmissing-declarations"
# ifdef __clang__
# if defined __clang__ || defined __APPLE__
# pragma GCC diagnostic ignored "-Wmissing-prototypes"
# pragma GCC diagnostic ignored "-Wextra"
# endif
+1 -1
Ver Arquivo
@@ -1,6 +1,6 @@
#ifdef __GNUC__
# pragma GCC diagnostic ignored "-Wmissing-declarations"
# ifdef __clang__
# if defined __clang__ || defined __APPLE__
# pragma GCC diagnostic ignored "-Wmissing-prototypes"
# pragma GCC diagnostic ignored "-Wextra"
# endif
+9 -8
Ver Arquivo
@@ -873,15 +873,16 @@ gpu::FastNonLocalMeansDenoising
-------------------------------
.. ocv:class:: gpu::FastNonLocalMeansDenoising
class FastNonLocalMeansDenoising
{
public:
//! Simple method, recommended for grayscale images (though it supports multichannel images)
void simpleMethod(const GpuMat& src, GpuMat& dst, float h, int search_window = 21, int block_size = 7, Stream& s = Stream::Null())
::
//! Processes luminance and color components separatelly
void labMethod(const GpuMat& src, GpuMat& dst, float h_luminance, float h_color, int search_window = 21, int block_size = 7, Stream& s = Stream::Null())
};
class FastNonLocalMeansDenoising
{
public:
//! Simple method, recommended for grayscale images (though it supports multichannel images)
void simpleMethod(const GpuMat& src, GpuMat& dst, float h, int search_window = 21, int block_size = 7, Stream& s = Stream::Null())
//! Processes luminance and color components separatelly
void labMethod(const GpuMat& src, GpuMat& dst, float h_luminance, float h_color, int search_window = 21, int block_size = 7, Stream& s = Stream::Null())
};
The class implements fast approximate Non Local Means Denoising algorithm.
@@ -150,7 +150,7 @@ namespace cv { namespace gpu { namespace device
return true;
}
static __device__ __forceinline__ bool check(int, int, int, uint offset = 0)
static __device__ __forceinline__ bool check(int, int, int)
{
return true;
}
+2
Ver Arquivo
@@ -1,3 +1,5 @@
#/usr/bin/env python
import sys, re
spaces = '[\s]*'
+1 -1
Ver Arquivo
@@ -1,6 +1,6 @@
#ifdef __GNUC__
# pragma GCC diagnostic ignored "-Wmissing-declarations"
# ifdef __clang__
# if defined __clang__ || defined __APPLE__
# pragma GCC diagnostic ignored "-Wmissing-prototypes"
# pragma GCC diagnostic ignored "-Wextra"
# endif
+1 -1
Ver Arquivo
@@ -236,7 +236,7 @@ namespace cv { namespace gpu { namespace device
const int r = blockIdx.x * blockDim.x + threadIdx.x;
const int n = blockIdx.y * blockDim.y + threadIdx.y;
if (r >= accum.cols - 2 && n >= accum.rows - 2)
if (r >= accum.cols - 2 || n >= accum.rows - 2)
return;
const int curVotes = accum(n + 1, r + 1);
+4 -3
Ver Arquivo
@@ -357,18 +357,19 @@ namespace cv { namespace gpu { namespace device
#endif
}
void shfl_integral_gpu(PtrStepSzb img, PtrStepSz<unsigned int> integral, cudaStream_t stream)
void shfl_integral_gpu(const PtrStepSzb& img, PtrStepSz<unsigned int> integral, cudaStream_t stream)
{
{
// each thread handles 16 values, use 1 block/row
const int block = img.cols / 16;
// save, becouse step is actually can't be less 512 bytes
int block = integral.cols / 16;
// launch 1 block / row
const int grid = img.rows;
cudaSafeCall( cudaFuncSetCacheConfig(shfl_integral_horizontal, cudaFuncCachePreferL1) );
shfl_integral_horizontal<<<grid, block, 0, stream>>>((PtrStepSz<uint4>) img, (PtrStepSz<uint4>) integral);
shfl_integral_horizontal<<<grid, block, 0, stream>>>((const PtrStepSz<uint4>) img, (PtrStepSz<uint4>) integral);
cudaSafeCall( cudaGetLastError() );
}
+1
Ver Arquivo
@@ -185,6 +185,7 @@ namespace cv { namespace gpu { namespace device
void connectedConmonents(PtrStepSz<int4> candidates, int ncandidates, PtrStepSz<int4> objects, int groupThreshold, float grouping_eps, unsigned int* nclasses)
{
if (!ncandidates) return;
int block = ncandidates;
int smem = block * ( sizeof(int) + sizeof(int4) );
disjoin<InSameComponint><<<1, block, smem>>>(candidates, objects, ncandidates, groupThreshold, grouping_eps, nclasses);
+16 -16
Ver Arquivo
@@ -177,7 +177,7 @@ namespace cv { namespace gpu { namespace device
return (HAAR_SIZE0 + HAAR_SIZE_INC * layer) << octave;
}
__global__ void icvCalcLayerDetAndTrace(PtrStepf det, PtrStepf trace, uint sumOffset)
__global__ void icvCalcLayerDetAndTrace(PtrStepf det, PtrStepf trace)
{
// Determine the indices
const int gridDim_y = gridDim.y / (c_nOctaveLayers + 2);
@@ -198,9 +198,9 @@ namespace cv { namespace gpu { namespace device
if (size <= c_img_rows && size <= c_img_cols && i < samples_i && j < samples_j)
{
const float dx = icvCalcHaarPatternSum<3>(c_DX , 9, size, (i << c_octave), sumOffset + (j << c_octave));
const float dy = icvCalcHaarPatternSum<3>(c_DY , 9, size, (i << c_octave), sumOffset + (j << c_octave));
const float dxy = icvCalcHaarPatternSum<4>(c_DXY, 9, size, (i << c_octave), sumOffset + (j << c_octave));
const float dx = icvCalcHaarPatternSum<3>(c_DX , 9, size, (i << c_octave), (j << c_octave));
const float dy = icvCalcHaarPatternSum<3>(c_DY , 9, size, (i << c_octave), (j << c_octave));
const float dxy = icvCalcHaarPatternSum<4>(c_DXY, 9, size, (i << c_octave), (j << c_octave));
det.ptr(layer * c_layer_rows + i + margin)[j + margin] = dx * dy - 0.81f * dxy * dxy;
trace.ptr(layer * c_layer_rows + i + margin)[j + margin] = dx + dy;
@@ -208,7 +208,7 @@ namespace cv { namespace gpu { namespace device
}
void icvCalcLayerDetAndTrace_gpu(const PtrStepf& det, const PtrStepf& trace, int img_rows, int img_cols,
int octave, int nOctaveLayers, const size_t sumOffset)
int octave, int nOctaveLayers)
{
const int min_size = calcSize(octave, 0);
const int max_samples_i = 1 + ((img_rows - min_size) >> octave);
@@ -220,7 +220,7 @@ namespace cv { namespace gpu { namespace device
grid.x = divUp(max_samples_j, threads.x);
grid.y = divUp(max_samples_i, threads.y) * (nOctaveLayers + 2);
icvCalcLayerDetAndTrace<<<grid, threads>>>(det, trace, (uint)sumOffset);
icvCalcLayerDetAndTrace<<<grid, threads>>>(det, trace);
cudaSafeCall( cudaGetLastError() );
cudaSafeCall( cudaDeviceSynchronize() );
@@ -233,7 +233,7 @@ namespace cv { namespace gpu { namespace device
struct WithMask
{
static __device__ bool check(int sum_i, int sum_j, int size, const uint offset)
static __device__ bool check(int sum_i, int sum_j, int size)
{
float ratio = (float)size / 9.0f;
@@ -245,10 +245,10 @@ namespace cv { namespace gpu { namespace device
int dy2 = __float2int_rn(ratio * c_DM[3]);
float t = 0;
t += tex2D(maskSumTex, offset + sum_j + dx1, sum_i + dy1);
t -= tex2D(maskSumTex, offset + sum_j + dx1, sum_i + dy2);
t -= tex2D(maskSumTex, offset + sum_j + dx2, sum_i + dy1);
t += tex2D(maskSumTex, offset + sum_j + dx2, sum_i + dy2);
t += tex2D(maskSumTex, sum_j + dx1, sum_i + dy1);
t -= tex2D(maskSumTex, sum_j + dx1, sum_i + dy2);
t -= tex2D(maskSumTex, sum_j + dx2, sum_i + dy1);
t += tex2D(maskSumTex, sum_j + dx2, sum_i + dy2);
d += t * c_DM[4] / ((dx2 - dx1) * (dy2 - dy1));
@@ -258,7 +258,7 @@ namespace cv { namespace gpu { namespace device
template <typename Mask>
__global__ void icvFindMaximaInLayer(const PtrStepf det, const PtrStepf trace, int4* maxPosBuffer,
unsigned int* maxCounter, const uint maskOffset)
unsigned int* maxCounter)
{
#if __CUDA_ARCH__ && __CUDA_ARCH__ >= 110
@@ -299,7 +299,7 @@ namespace cv { namespace gpu { namespace device
const int sum_i = (i - ((size >> 1) >> c_octave)) << c_octave;
const int sum_j = (j - ((size >> 1) >> c_octave)) << c_octave;
if (Mask::check(sum_i, sum_j, size, maskOffset))
if (Mask::check(sum_i, sum_j, size))
{
// Check to see if we have a max (in its 26 neighbours)
const bool condmax = val0 > N9[localLin - 1 - blockDim.x - zoff]
@@ -351,7 +351,7 @@ namespace cv { namespace gpu { namespace device
}
void icvFindMaximaInLayer_gpu(const PtrStepf& det, const PtrStepf& trace, int4* maxPosBuffer, unsigned int* maxCounter,
int img_rows, int img_cols, int octave, bool use_mask, int nOctaveLayers, const size_t maskOffset)
int img_rows, int img_cols, int octave, bool use_mask, int nOctaveLayers)
{
const int layer_rows = img_rows >> octave;
const int layer_cols = img_cols >> octave;
@@ -367,9 +367,9 @@ namespace cv { namespace gpu { namespace device
const size_t smem_size = threads.x * threads.y * 3 * sizeof(float);
if (use_mask)
icvFindMaximaInLayer<WithMask><<<grid, threads, smem_size>>>(det, trace, maxPosBuffer, maxCounter, (uint)maskOffset);
icvFindMaximaInLayer<WithMask><<<grid, threads, smem_size>>>(det, trace, maxPosBuffer, maxCounter);
else
icvFindMaximaInLayer<WithOutMask><<<grid, threads, smem_size>>>(det, trace, maxPosBuffer, maxCounter, 0);
icvFindMaximaInLayer<WithOutMask><<<grid, threads, smem_size>>>(det, trace, maxPosBuffer, maxCounter);
cudaSafeCall( cudaGetLastError() );
+6
Ver Arquivo
@@ -85,6 +85,12 @@ void cv::gpu::GoodFeaturesToTrackDetector_GPU::operator ()(const GpuMat& image,
int total = findCorners_gpu(eig_, static_cast<float>(maxVal * qualityLevel), mask, tmpCorners_.ptr<float2>(), tmpCorners_.cols);
if (total == 0)
{
corners.release();
return;
}
sortCorners_gpu(eig_, tmpCorners_.ptr<float2>(), total);
if (minDistance < 1)
+12 -30
Ver Arquivo
@@ -537,7 +537,7 @@ namespace cv { namespace gpu { namespace device
{
namespace imgproc
{
void shfl_integral_gpu(PtrStepSzb img, PtrStepSz<unsigned int> integral, cudaStream_t stream);
void shfl_integral_gpu(const PtrStepSzb& img, PtrStepSz<unsigned int> integral, cudaStream_t stream);
}
}}}
@@ -553,44 +553,26 @@ void cv::gpu::integralBuffered(const GpuMat& src, GpuMat& sum, GpuMat& buffer, S
src.locateROI(whole, offset);
if (info.supports(WARP_SHUFFLE_FUNCTIONS) && src.cols <= 2048)
if (info.supports(WARP_SHUFFLE_FUNCTIONS) && src.cols <= 2048
&& offset.x % 16 == 0 && ((src.cols + 63) / 64) * 64 <= (src.step - offset.x))
{
GpuMat srcAlligned;
ensureSizeIsEnough(((src.rows + 7) / 8) * 8, ((src.cols + 63) / 64) * 64, CV_32SC1, buffer);
if (src.cols % 16 == 0 && src.rows % 8 == 0 && offset.x % 16 == 0 && offset.y % 8 == 0)
srcAlligned = src;
else
{
ensureSizeIsEnough(((src.rows + 7) / 8) * 8, ((src.cols + 15) / 16) * 16, src.type(), buffer);
GpuMat inner = buffer(Rect(0, 0, src.cols, src.rows));
if (s)
{
s.enqueueMemSet(buffer, Scalar::all(0));
s.enqueueCopy(src, inner);
}
else
{
buffer.setTo(Scalar::all(0));
src.copyTo(inner);
}
srcAlligned = buffer;
}
sum.create(srcAlligned.rows + 1, srcAlligned.cols + 4, CV_32SC1);
cv::gpu::device::imgproc::shfl_integral_gpu(src, buffer, stream);
sum.create(src.rows + 1, src.cols + 1, CV_32SC1);
if (s)
s.enqueueMemSet(sum, Scalar::all(0));
else
sum.setTo(Scalar::all(0));
GpuMat inner = sum(Rect(4, 1, srcAlligned.cols, srcAlligned.rows));
GpuMat inner = sum(Rect(1, 1, src.cols, src.rows));
GpuMat res = buffer(Rect(0, 0, src.cols, src.rows));
cv::gpu::device::imgproc::shfl_integral_gpu(srcAlligned, inner, stream);
sum = sum(Rect(3, 0, src.cols + 1, src.rows + 1));
if (s)
s.enqueueCopy(res, inner);
else
res.copyTo(inner);
}
else
{
+3
Ver Arquivo
@@ -200,6 +200,9 @@ void cv::gpu::PyrLKOpticalFlow::dense(const GpuMat& prevImg, const GpuMat& nextI
pyrDown(nextPyr_[level - 1], nextPyr_[level]);
}
uPyr_.resize(2);
vPyr_.resize(2);
ensureSizeIsEnough(prevImg.size(), CV_32FC1, uPyr_[0]);
ensureSizeIsEnough(prevImg.size(), CV_32FC1, vPyr_[0]);
ensureSizeIsEnough(prevImg.size(), CV_32FC1, uPyr_[1]);
+5 -5
Ver Arquivo
@@ -75,10 +75,10 @@ namespace cv { namespace gpu { namespace device
size_t bindMaskSumTex(PtrStepSz<unsigned int> maskSum);
void icvCalcLayerDetAndTrace_gpu(const PtrStepf& det, const PtrStepf& trace, int img_rows, int img_cols,
int octave, int nOctaveLayers, const size_t sumOffset);
int octave, int nOctaveLayer);
void icvFindMaximaInLayer_gpu(const PtrStepf& det, const PtrStepf& trace, int4* maxPosBuffer, unsigned int* maxCounter,
int img_rows, int img_cols, int octave, bool use_mask, int nLayers, const size_t maskOffset);
int img_rows, int img_cols, int octave, bool use_mask, int nLayers);
void icvInterpolateKeypoint_gpu(const PtrStepf& det, const int4* maxPosBuffer, unsigned int maxCounter,
float* featureX, float* featureY, int* featureLaplacian, int* featureOctave, float* featureSize, float* featureHessian,
@@ -146,8 +146,8 @@ namespace
loadGlobalConstants(maxCandidates, maxFeatures, img_rows, img_cols, surf_.nOctaveLayers, static_cast<float>(surf_.hessianThreshold));
bindImgTex(img);
integralBuffered(img, surf_.sum, surf_.intBuffer);
integralBuffered(img, surf_.sum, surf_.intBuffer);
sumOffset = bindSumTex(surf_.sum);
if (use_mask)
@@ -174,10 +174,10 @@ namespace
loadOctaveConstants(octave, layer_rows, layer_cols);
icvCalcLayerDetAndTrace_gpu(surf_.det, surf_.trace, img_rows, img_cols, octave, surf_.nOctaveLayers, sumOffset);
icvCalcLayerDetAndTrace_gpu(surf_.det, surf_.trace, img_rows, img_cols, octave, surf_.nOctaveLayers);
icvFindMaximaInLayer_gpu(surf_.det, surf_.trace, surf_.maxPosBuffer.ptr<int4>(), counters.ptr<unsigned int>() + 1 + octave,
img_rows, img_cols, octave, use_mask, surf_.nOctaveLayers, maskOffset);
img_rows, img_cols, octave, use_mask, surf_.nOctaveLayers);
unsigned int maxCounter;
cudaSafeCall( cudaMemcpy(&maxCounter, counters.ptr<unsigned int>() + 1 + octave, sizeof(unsigned int), cudaMemcpyDeviceToHost) );
+4 -4
Ver Arquivo
@@ -119,10 +119,10 @@ int main(int argc, char** argv)
try
{
const char* keys =
"{ h help ? | | Print help}"
"{ i info | | Print information about system and exit }"
"{ device | -1 | Device on which tests will be executed (-1 means all devices) }"
"{ nvtest_output_level | none | NVidia test verbosity level (none, compact, full) }"
"{ h | help ? | false | Print help}"
"{ i | info | false | Print information about system and exit }"
"{ d | device | -1 | Device on which tests will be executed (-1 means all devices) }"
"{ nvtest_output_level | nvtest_output_level | none | NVidia test verbosity level (none, compact, full) }"
;
CommandLineParser cmd(argc, (const char**)argv, keys);
+1 -1
Ver Arquivo
@@ -41,7 +41,7 @@
#ifdef __GNUC__
# pragma GCC diagnostic ignored "-Wmissing-declarations"
# ifdef __clang__
# if defined __clang__ || defined __APPLE__
# pragma GCC diagnostic ignored "-Wmissing-prototypes"
# pragma GCC diagnostic ignored "-Wextra"
# endif
+15
Ver Arquivo
@@ -203,6 +203,21 @@ TEST_P(GoodFeaturesToTrack, Accuracy)
}
}
TEST_P(GoodFeaturesToTrack, EmptyCorners)
{
int maxCorners = 1000;
double qualityLevel = 0.01;
cv::gpu::GoodFeaturesToTrackDetector_GPU detector(maxCorners, qualityLevel, minDistance);
cv::gpu::GpuMat src(100, 100, CV_8UC1, cv::Scalar::all(0));
cv::gpu::GpuMat corners(1, maxCorners, CV_32FC2);
detector(src, corners);
ASSERT_TRUE( corners.empty() );
}
INSTANTIATE_TEST_CASE_P(GPU_Video, GoodFeaturesToTrack, testing::Combine(
ALL_DEVICES,
testing::Values(MinDistance(0.0), MinDistance(3.0))));
+1 -1
Ver Arquivo
@@ -1,6 +1,6 @@
#ifdef __GNUC__
# pragma GCC diagnostic ignored "-Wmissing-declarations"
# ifdef __clang__
# if defined __clang__ || defined __APPLE__
# pragma GCC diagnostic ignored "-Wmissing-prototypes"
# pragma GCC diagnostic ignored "-Wextra"
# endif
-1
Ver Arquivo
@@ -424,7 +424,6 @@ CV_IMPL CvVideoWriter* cvCreateVideoWriter( const char* filename, int fourcc,
CV_IMPL int cvWriteFrame( CvVideoWriter* writer, const IplImage* image )
{
return writer ? writer->writeFrame(image) : 0;
}
+29 -11
Ver Arquivo
@@ -57,11 +57,32 @@ static CvCreateVideoWriter_Plugin icvCreateVideoWriter_FFMPEG_p = 0;
static CvReleaseVideoWriter_Plugin icvReleaseVideoWriter_FFMPEG_p = 0;
static CvWriteFrame_Plugin icvWriteFrame_FFMPEG_p = 0;
static void
icvInitFFMPEG(void)
static cv::Mutex _icvInitFFMPEG_mutex;
class icvInitFFMPEG
{
static int ffmpegInitialized = 0;
if( !ffmpegInitialized )
public:
static void Init()
{
cv::AutoLock al(_icvInitFFMPEG_mutex);
static icvInitFFMPEG init;
}
private:
#if defined WIN32 || defined _WIN32
HMODULE icvFFOpenCV;
~icvInitFFMPEG()
{
if (icvFFOpenCV)
{
FreeLibrary(icvFFOpenCV);
icvFFOpenCV = 0;
}
}
#endif
icvInitFFMPEG()
{
#if defined WIN32 || defined _WIN32
const char* module_name = "opencv_ffmpeg"
@@ -71,7 +92,7 @@ icvInitFFMPEG(void)
#endif
".dll";
static HMODULE icvFFOpenCV = LoadLibrary( module_name );
icvFFOpenCV = LoadLibrary( module_name );
if( icvFFOpenCV )
{
icvCreateFileCapture_FFMPEG_p =
@@ -123,10 +144,8 @@ icvInitFFMPEG(void)
icvReleaseVideoWriter_FFMPEG_p = (CvReleaseVideoWriter_Plugin)cvReleaseVideoWriter_FFMPEG;
icvWriteFrame_FFMPEG_p = (CvWriteFrame_Plugin)cvWriteFrame_FFMPEG;
#endif
ffmpegInitialized = 1;
}
}
};
class CvCapture_FFMPEG_proxy : public CvCapture
@@ -161,9 +180,9 @@ public:
}
virtual bool open( const char* filename )
{
icvInitFFMPEG::Init();
close();
icvInitFFMPEG();
if( !icvCreateFileCapture_FFMPEG_p )
return false;
ffmpegCapture = icvCreateFileCapture_FFMPEG_p( filename );
@@ -196,7 +215,6 @@ CvCapture* cvCreateFileCapture_FFMPEG_proxy(const char * filename)
#endif
}
class CvVideoWriter_FFMPEG_proxy : public CvVideoWriter
{
public:
@@ -214,8 +232,8 @@ public:
}
virtual bool open( const char* filename, int fourcc, double fps, CvSize frameSize, bool isColor )
{
icvInitFFMPEG::Init();
close();
icvInitFFMPEG();
if( !icvCreateVideoWriter_FFMPEG_p )
return false;
ffmpegWriter = icvCreateVideoWriter_FFMPEG_p( filename, fourcc, fps, frameSize.width, frameSize.height, isColor );
+177 -27
Ver Arquivo
@@ -328,28 +328,179 @@ void CvCapture_FFMPEG::close()
#define AVSEEK_FLAG_ANY 1
#endif
static void icvInitFFMPEG_internal()
class ImplMutex
{
static volatile bool initialized = false;
if( !initialized )
public:
ImplMutex();
~ImplMutex();
void lock();
bool trylock();
void unlock();
struct Impl;
protected:
Impl* impl;
private:
ImplMutex(const ImplMutex&);
ImplMutex& operator = (const ImplMutex& m);
};
#if defined WIN32 || defined _WIN32 || defined WINCE
struct ImplMutex::Impl
{
Impl() { InitializeCriticalSection(&cs); refcount = 1; }
~Impl() { DeleteCriticalSection(&cs); }
void lock() { EnterCriticalSection(&cs); }
bool trylock() { return TryEnterCriticalSection(&cs) != 0; }
void unlock() { LeaveCriticalSection(&cs); }
CRITICAL_SECTION cs;
int refcount;
};
#ifndef __GNUC__
static int _interlockedExchangeAdd(int* addr, int delta)
{
#if defined _MSC_VER && _MSC_VER >= 1500
return (int)_InterlockedExchangeAdd((long volatile*)addr, delta);
#else
return (int)InterlockedExchangeAdd((long volatile*)addr, delta);
#endif
}
#endif // __GNUC__
#elif defined __APPLE__
#include <libkern/OSAtomic.h>
struct ImplMutex::Impl
{
Impl() { sl = OS_SPINLOCK_INIT; refcount = 1; }
~Impl() {}
void lock() { OSSpinLockLock(&sl); }
bool trylock() { return OSSpinLockTry(&sl); }
void unlock() { OSSpinLockUnlock(&sl); }
OSSpinLock sl;
int refcount;
};
#elif defined __linux__ && !defined ANDROID
struct ImplMutex::Impl
{
Impl() { pthread_spin_init(&sl, 0); refcount = 1; }
~Impl() { pthread_spin_destroy(&sl); }
void lock() { pthread_spin_lock(&sl); }
bool trylock() { return pthread_spin_trylock(&sl) == 0; }
void unlock() { pthread_spin_unlock(&sl); }
pthread_spinlock_t sl;
int refcount;
};
#else
struct ImplMutex::Impl
{
Impl() { pthread_mutex_init(&sl, 0); refcount = 1; }
~Impl() { pthread_mutex_destroy(&sl); }
void lock() { pthread_mutex_lock(&sl); }
bool trylock() { return pthread_mutex_trylock(&sl) == 0; }
void unlock() { pthread_mutex_unlock(&sl); }
pthread_mutex_t sl;
int refcount;
};
#endif
ImplMutex::ImplMutex()
{
impl = new ImplMutex::Impl;
}
ImplMutex::~ImplMutex()
{
delete impl;
impl = 0;
}
void ImplMutex::lock() { impl->lock(); }
void ImplMutex::unlock() { impl->unlock(); }
bool ImplMutex::trylock() { return impl->trylock(); }
static int LockCallBack(void **mutex, AVLockOp op)
{
switch (op)
{
#if LIBAVFORMAT_BUILD >= CALC_FFMPEG_VERSION(53, 13, 0)
case AV_LOCK_CREATE:
*mutex = reinterpret_cast<void*>(new ImplMutex());
if (!*mutex)
return 1;
break;
case AV_LOCK_OBTAIN:
reinterpret_cast<ImplMutex*>(*mutex)->lock();
break;
case AV_LOCK_RELEASE:
reinterpret_cast<ImplMutex*>(*mutex)->unlock();
break;
case AV_LOCK_DESTROY:
ImplMutex* cv_mutex = reinterpret_cast<ImplMutex*>(*mutex);
delete cv_mutex;
cv_mutex = NULL;
break;
}
return 0;
}
static ImplMutex _InternalFFMpegRegister_mutex;
class InternalFFMpegRegister
{
public:
static void Register()
{
_InternalFFMpegRegister_mutex.lock();
static InternalFFMpegRegister init;
_InternalFFMpegRegister_mutex.unlock();
}
~InternalFFMpegRegister()
{
av_lockmgr_register(NULL);
}
private:
InternalFFMpegRegister()
{
#if LIBAVFORMAT_BUILD >= CALC_FFMPEG_VERSION(53, 13, 0)
avformat_network_init();
#endif
#endif
/* register all codecs, demux and protocols */
av_register_all();
av_log_set_level(AV_LOG_ERROR);
/* register a callback function for synchronization */
av_lockmgr_register(&LockCallBack);
initialized = true;
av_log_set_level(AV_LOG_ERROR);
}
}
};
bool CvCapture_FFMPEG::open( const char* _filename )
{
icvInitFFMPEG_internal();
InternalFFMpegRegister::Register();
unsigned i;
bool valid = false;
@@ -361,7 +512,8 @@ bool CvCapture_FFMPEG::open( const char* _filename )
int err = av_open_input_file(&ic, _filename, NULL, 0, NULL);
#endif
if (err < 0) {
if (err < 0)
{
CV_WARN("Error opening file");
goto exit_func;
}
@@ -371,7 +523,8 @@ bool CvCapture_FFMPEG::open( const char* _filename )
#else
av_find_stream_info(ic);
#endif
if (err < 0) {
if (err < 0)
{
CV_WARN("Could not find codec parameters");
goto exit_func;
}
@@ -393,7 +546,8 @@ bool CvCapture_FFMPEG::open( const char* _filename )
#define AVMEDIA_TYPE_VIDEO CODEC_TYPE_VIDEO
#endif
if( AVMEDIA_TYPE_VIDEO == enc->codec_type && video_stream < 0) {
if( AVMEDIA_TYPE_VIDEO == enc->codec_type && video_stream < 0)
{
AVCodec *codec = avcodec_find_decoder(enc->codec_id);
if (!codec ||
#if LIBAVCODEC_VERSION_INT >= ((53<<16)+(8<<8)+0)
@@ -401,7 +555,8 @@ bool CvCapture_FFMPEG::open( const char* _filename )
#else
avcodec_open(enc, codec)
#endif
< 0) goto exit_func;
< 0)
goto exit_func;
video_stream = i;
video_st = ic->streams[i];
@@ -1275,7 +1430,7 @@ void CvVideoWriter_FFMPEG::close()
bool CvVideoWriter_FFMPEG::open( const char * filename, int fourcc,
double fps, int width, int height, bool is_color )
{
icvInitFFMPEG_internal();
InternalFFMpegRegister::Register();
CodecID codec_id = CODEC_ID_NONE;
int err, codec_pix_fmt;
@@ -1495,6 +1650,7 @@ bool CvVideoWriter_FFMPEG::open( const char * filename, int fourcc,
frame_width = width;
frame_height = height;
ok = true;
return true;
}
@@ -1506,6 +1662,7 @@ CvCapture_FFMPEG* cvCreateFileCapture_FFMPEG( const char* filename )
capture->init();
if( capture->open( filename ))
return capture;
capture->close();
free(capture);
return 0;
@@ -1554,7 +1711,6 @@ CvVideoWriter_FFMPEG* cvCreateVideoWriter_FFMPEG( const char* filename, int four
return 0;
}
void cvReleaseVideoWriter_FFMPEG( CvVideoWriter_FFMPEG** writer )
{
if( writer && *writer )
@@ -1741,15 +1897,12 @@ AVStream* OutputMediaStream_FFMPEG::addVideoStream(AVFormatContext *oc, CodecID
bool OutputMediaStream_FFMPEG::open(const char* fileName, int width, int height, double fps)
{
InternalFFMpegRegister::Register();
fmt_ = 0;
oc_ = 0;
video_st_ = 0;
// tell FFMPEG to register codecs
av_register_all();
av_log_set_level(AV_LOG_ERROR);
// auto detect the output format from the name and fourcc code
#if LIBAVFORMAT_BUILD >= CALC_FFMPEG_VERSION(53, 2, 0)
fmt_ = av_guess_format(NULL, fileName, NULL);
@@ -1920,6 +2073,8 @@ private:
bool InputMediaStream_FFMPEG::open(const char* fileName, int* codec, int* chroma_format, int* width, int* height)
{
InternalFFMpegRegister::Register();
int err;
ctx_ = 0;
@@ -1930,11 +2085,6 @@ bool InputMediaStream_FFMPEG::open(const char* fileName, int* codec, int* chroma
avformat_network_init();
#endif
// register all codecs, demux and protocols
av_register_all();
av_log_set_level(AV_LOG_ERROR);
#if LIBAVFORMAT_BUILD >= CALC_FFMPEG_VERSION(53, 6, 0)
err = avformat_open_input(&ctx_, fileName, 0, 0);
#else
@@ -2054,7 +2204,7 @@ bool InputMediaStream_FFMPEG::read(unsigned char** data, int* size, int* endOfFi
if (ret < 0)
{
if (ret == AVERROR_EOF)
if (ret == (int)AVERROR_EOF)
*endOfFile = true;
return false;
}
+29 -9
Ver Arquivo
@@ -65,7 +65,24 @@
#define CV_WARN(message) fprintf(stderr, "warning: %s (%s:%d)\n", message, __FILE__, __LINE__)
#endif
static bool isInited = false;
static cv::Mutex gst_initializer_mutex;
class gst_initializer
{
public:
static void init()
{
gst_initializer_mutex.lock();
static gst_initializer init;
gst_initializer_mutex.unlock();
}
private:
gst_initializer()
{
gst_init(NULL, NULL);
}
};
class CvCapture_GStreamer : public CvCapture
{
public:
@@ -298,16 +315,18 @@ bool CvCapture_GStreamer::open( int type, const char* filename )
__BEGIN__;
if(!isInited) {
gst_initializer::init();
// if(!isInited) {
// printf("gst_init\n");
gst_init (NULL, NULL);
// gst_init (NULL, NULL);
// gst_debug_set_active(TRUE);
// gst_debug_set_colored(TRUE);
// gst_debug_set_default_threshold(GST_LEVEL_WARNING);
isInited = true;
}
// isInited = true;
// }
bool stream = false;
bool manualpipeline = false;
char *uri = NULL;
@@ -477,10 +496,11 @@ bool CvVideoWriter_GStreamer::open( const char * filename, int fourcc,
encit=encs.find(fourcc);
if (encit==encs.end())
CV_ERROR( CV_StsUnsupportedFormat,"Gstreamer Opencv backend doesn't support this codec acutally.");
if(!isInited) {
gst_init (NULL, NULL);
isInited = true;
}
// if(!isInited) {
// gst_init (NULL, NULL);
// isInited = true;
// }
gst_initializer::init();
close();
source=gst_element_factory_make("appsrc",NULL);
file=gst_element_factory_make("filesink", NULL);
+3 -4
Ver Arquivo
@@ -1008,10 +1008,6 @@ static CvCaptureCAM_V4L * icvCaptureFromCAM_V4L (int index)
return NULL;
}
/* set the default size */
capture->width = DEFAULT_V4L_WIDTH;
capture->height = DEFAULT_V4L_HEIGHT;
#ifdef USE_TEMP_BUFFER
capture->buffers[MAX_V4L_BUFFERS].start = NULL;
#endif
@@ -1035,6 +1031,9 @@ static CvCaptureCAM_V4L * icvCaptureFromCAM_V4L (int index)
the standard set of cv calls promoting transparency. "Vector Table" insertion. */
capture->FirstCapture = 1;
/* set the default size */
capture->width = DEFAULT_V4L_WIDTH;
capture->height = DEFAULT_V4L_HEIGHT;
if (_capture_V4L2 (capture, deviceName) == -1) {
icvCloseCAM_V4L(capture);
+50
Ver Arquivo
@@ -571,6 +571,56 @@ int cv::createButton(const string& button_name, ButtonCallback on_change, void*
return cvCreateButton(button_name.c_str(), on_change, userdata, button_type , initial_button_state );
}
#else
CvFont cv::fontQt(const string&, int, Scalar, int, int, int)
{
CV_Error(CV_StsNotImplemented, "The library is compiled without QT support");
return CvFont();
}
void cv::addText( const Mat&, const string&, Point, CvFont)
{
CV_Error(CV_StsNotImplemented, "The library is compiled without QT support");
}
void cv::displayStatusBar(const string&, const string&, int)
{
CV_Error(CV_StsNotImplemented, "The library is compiled without QT support");
}
void cv::displayOverlay(const string&, const string&, int )
{
CV_Error(CV_StsNotImplemented, "The library is compiled without QT support");
}
int cv::startLoop(int (*)(int argc, char *argv[]), int , char**)
{
CV_Error(CV_StsNotImplemented, "The library is compiled without QT support");
return 0;
}
void cv::stopLoop()
{
CV_Error(CV_StsNotImplemented, "The library is compiled without QT support");
}
void cv::saveWindowParameters(const string&)
{
CV_Error(CV_StsNotImplemented, "The library is compiled without QT support");
}
void cv::loadWindowParameters(const string&)
{
CV_Error(CV_StsNotImplemented, "The library is compiled without QT support");
}
int cv::createButton(const string&, ButtonCallback, void*, int , bool )
{
CV_Error(CV_StsNotImplemented, "The library is compiled without QT support");
return 0;
}
#endif
#if defined WIN32 || defined _WIN32 // see window_w32.cpp
+222 -3
Ver Arquivo
@@ -43,11 +43,12 @@
#include "test_precomp.hpp"
#include "opencv2/highgui/highgui.hpp"
using namespace cv;
#ifdef HAVE_FFMPEG
#include "ffmpeg_codecs.hpp"
using namespace cv;
using namespace std;
class CV_FFmpegWriteBigVideoTest : public cvtest::BaseTest
@@ -118,11 +119,11 @@ public:
else
{
Mat img(frame_s, CV_8UC3, Scalar::all(0));
const int coeff = cvRound(cv::min(frame_s.width, frame_s.height)/(fps0 * time_sec));
const int coeff = cvRound(min(frame_s.width, frame_s.height)/(fps0 * time_sec));
for (int i = 0 ; i < static_cast<int>(fps * time_sec); i++ )
{
//circle(img, Point2i(img_c / 2, img_r / 2), cv::min(img_r, img_c) / 2 * (i + 1), Scalar(255, 0, 0, 0), 2);
//circle(img, Point2i(img_c / 2, img_r / 2), min(img_r, img_c) / 2 * (i + 1), Scalar(255, 0, 0, 0), 2);
rectangle(img, Point2i(coeff * i, coeff * i), Point2i(coeff * (i + 1), coeff * (i + 1)),
Scalar::all(255 * (1.0 - static_cast<double>(i) / (fps * time_sec * 2) )), -1);
writer << img;
@@ -174,3 +175,221 @@ public:
TEST(Highgui_Video, ffmpeg_image) { CV_FFmpegReadImageTest test; test.safe_run(); }
#endif
#if defined(HAVE_FFMPEG) || defined(WIN32) || defined(_WIN32)
//////////////////////////////// Parallel VideoWriters and VideoCaptures ////////////////////////////////////
class CreateVideoWriterInvoker :
public ParallelLoopBody
{
public:
const static Size FrameSize;
static std::string TmpDirectory;
CreateVideoWriterInvoker(std::vector<VideoWriter*>& _writers, std::vector<std::string>& _files) :
ParallelLoopBody(), writers(&_writers), files(&_files)
{
}
virtual void operator() (const Range& range) const
{
for (int i = range.start; i != range.end; ++i)
{
std::ostringstream stream;
stream << i << ".avi";
std::string fileName = tempfile(stream.str().c_str());
files->operator[](i) = fileName;
writers->operator[](i) = new VideoWriter(fileName, CV_FOURCC('X','V','I','D'), 25.0f, FrameSize);
CV_Assert(writers->operator[](i)->isOpened());
}
}
private:
std::vector<VideoWriter*>* writers;
std::vector<std::string>* files;
};
std::string CreateVideoWriterInvoker::TmpDirectory;
const Size CreateVideoWriterInvoker::FrameSize(1020, 900);
class WriteVideo_Invoker :
public ParallelLoopBody
{
public:
enum { FrameCount = 300 };
static const Scalar ObjectColor;
static const Point Center;
WriteVideo_Invoker(const std::vector<VideoWriter*>& _writers) :
ParallelLoopBody(), writers(&_writers)
{
}
static void GenerateFrame(Mat& frame, unsigned int i)
{
frame = Scalar::all(i % 255);
std::string text = to_string(i);
putText(frame, text, Point(50, Center.y), FONT_HERSHEY_SIMPLEX, 5.0, ObjectColor, 5, CV_AA);
circle(frame, Center, i + 2, ObjectColor, 2, CV_AA);
}
virtual void operator() (const Range& range) const
{
CV_Assert((range.start + 1) == range.end);
VideoWriter* writer = writers->operator[](range.start);
CV_Assert(writer != NULL);
CV_Assert(writer->isOpened());
Mat frame(CreateVideoWriterInvoker::FrameSize, CV_8UC3);
for (unsigned int i = 0; i < FrameCount; ++i)
{
GenerateFrame(frame, i);
writer->operator<< (frame);
}
}
protected:
static std::string to_string(unsigned int i)
{
std::stringstream stream(std::ios::out);
stream << "frame #" << i;
return stream.str();
}
private:
const std::vector<VideoWriter*>* writers;
};
const Scalar WriteVideo_Invoker::ObjectColor(Scalar::all(0));
const Point WriteVideo_Invoker::Center(CreateVideoWriterInvoker::FrameSize.height / 2,
CreateVideoWriterInvoker::FrameSize.width / 2);
class CreateVideoCaptureInvoker :
public ParallelLoopBody
{
public:
CreateVideoCaptureInvoker(std::vector<VideoCapture*>& _readers, const std::vector<std::string>& _files) :
ParallelLoopBody(), readers(&_readers), files(&_files)
{
}
virtual void operator() (const Range& range) const
{
for (int i = range.start; i != range.end; ++i)
{
readers->operator[](i) = new VideoCapture(files->operator[](i));
CV_Assert(readers->operator[](i)->isOpened());
}
}
private:
std::vector<VideoCapture*>* readers;
const std::vector<std::string>* files;
};
class ReadImageAndTest :
public ParallelLoopBody
{
public:
ReadImageAndTest(const std::vector<VideoCapture*>& _readers, cvtest::TS* _ts) :
ParallelLoopBody(), readers(&_readers), ts(_ts)
{
}
virtual void operator() (const Range& range) const
{
CV_Assert(range.start + 1 == range.end);
VideoCapture* capture = readers->operator[](range.start);
CV_Assert(capture != NULL);
CV_Assert(capture->isOpened());
const static double eps = 23.0;
unsigned int frameCount = static_cast<unsigned int>(capture->get(CV_CAP_PROP_FRAME_COUNT));
CV_Assert(frameCount == WriteVideo_Invoker::FrameCount);
Mat reference(CreateVideoWriterInvoker::FrameSize, CV_8UC3);
for (unsigned int i = 0; i < frameCount && next; ++i)
{
Mat actual;
(*capture) >> actual;
WriteVideo_Invoker::GenerateFrame(reference, i);
EXPECT_EQ(reference.cols, actual.cols);
EXPECT_EQ(reference.rows, actual.rows);
EXPECT_EQ(reference.depth(), actual.depth());
EXPECT_EQ(reference.channels(), actual.channels());
double psnr = PSNR(actual, reference);
if (psnr < eps)
{
#define SUM cvtest::TS::SUMMARY
ts->printf(SUM, "\nPSNR: %lf\n", psnr);
ts->printf(SUM, "Video #: %d\n", range.start);
ts->printf(SUM, "Frame #: %d\n", i);
#undef SUM
ts->set_failed_test_info(cvtest::TS::FAIL_BAD_ACCURACY);
ts->set_gtest_status();
Mat diff;
absdiff(actual, reference, diff);
EXPECT_EQ(countNonZero(diff.reshape(1) > 1), 0);
next = false;
}
}
}
static bool next;
private:
const std::vector<VideoCapture*>* readers;
cvtest::TS* ts;
};
bool ReadImageAndTest::next;
TEST(Highgui_Video_parallel_writers_and_readers, accuracy)
{
const unsigned int threadsCount = 4;
cvtest::TS* ts = cvtest::TS::ptr();
// creating VideoWriters
std::vector<VideoWriter*> writers(threadsCount);
Range range(0, threadsCount);
std::vector<std::string> files(threadsCount);
CreateVideoWriterInvoker invoker1(writers, files);
parallel_for_(range, invoker1);
// write a video
parallel_for_(range, WriteVideo_Invoker(writers));
// deleting the writers
for (std::vector<VideoWriter*>::iterator i = writers.begin(), end = writers.end(); i != end; ++i)
delete *i;
writers.clear();
std::vector<VideoCapture*> readers(threadsCount);
CreateVideoCaptureInvoker invoker2(readers, files);
parallel_for_(range, invoker2);
ReadImageAndTest::next = true;
parallel_for_(range, ReadImageAndTest(readers, ts));
// deleting tmp video files
for (std::vector<std::string>::const_iterator i = files.begin(), end = files.end(); i != end; ++i)
{
int code = remove(i->c_str());
if (code == 1)
std::cerr << "Couldn't delete " << *i << std::endl;
}
}
#endif
+1 -1
Ver Arquivo
@@ -1,6 +1,6 @@
#ifdef __GNUC__
# pragma GCC diagnostic ignored "-Wmissing-declarations"
# ifdef __clang__
# if defined __clang__ || defined __APPLE__
# pragma GCC diagnostic ignored "-Wmissing-prototypes"
# pragma GCC diagnostic ignored "-Wextra"
# endif

Alguns arquivos não foram exibidos porque demasiados arquivos foram alterados neste diff Mostrar Mais