Commit 37f4ea6b authored by Vadim Pisarevsky's avatar Vadim Pisarevsky

Merge remote-tracking branch 'origin/master'

parents 7946fcdb e73089bd
This diff is collapsed.
...@@ -124,35 +124,33 @@ if(CMAKE_COMPILER_IS_GNUCXX) ...@@ -124,35 +124,33 @@ if(CMAKE_COMPILER_IS_GNUCXX)
# SSE3 and further should be disabled under MingW because it generates compiler errors # SSE3 and further should be disabled under MingW because it generates compiler errors
if(NOT MINGW) if(NOT MINGW)
if(ENABLE_SSE3) if(ENABLE_AVX)
add_extra_compiler_option(-msse3) add_extra_compiler_option(-mavx)
endif() endif()
if(${CMAKE_OPENCV_GCC_VERSION_NUM} GREATER 402) # GCC depresses SSEx instructions when -mavx is used. Instead, it generates new AVX instructions or AVX equivalence for all SSEx instructions when needed.
set(HAVE_GCC43_OR_NEWER 1) if(NOT OPENCV_EXTRA_CXX_FLAGS MATCHES "-mavx")
endif() if(ENABLE_SSE3)
if(${CMAKE_OPENCV_GCC_VERSION_NUM} GREATER 401) add_extra_compiler_option(-msse3)
set(HAVE_GCC42_OR_NEWER 1) endif()
endif()
if(HAVE_GCC42_OR_NEWER OR APPLE)
if(ENABLE_SSSE3) if(ENABLE_SSSE3)
add_extra_compiler_option(-mssse3) add_extra_compiler_option(-mssse3)
endif() endif()
if(HAVE_GCC43_OR_NEWER OR APPLE)
if(ENABLE_SSE41) if(ENABLE_SSE41)
add_extra_compiler_option(-msse4.1) add_extra_compiler_option(-msse4.1)
endif() endif()
if(ENABLE_SSE42)
add_extra_compiler_option(-msse4.2) if(ENABLE_SSE42)
endif() add_extra_compiler_option(-msse4.2)
endif() endif()
endif() endif()
endif(NOT MINGW) endif(NOT MINGW)
if(X86 OR X86_64) if(X86 OR X86_64)
if(NOT APPLE AND CMAKE_SIZEOF_VOID_P EQUAL 4) if(NOT APPLE AND CMAKE_SIZEOF_VOID_P EQUAL 4)
if(ENABLE_SSE2) if(OPENCV_EXTRA_CXX_FLAGS MATCHES "-m(sse2|avx)")
add_extra_compiler_option(-mfpmath=sse)# !! important - be on the same wave with x64 compilers add_extra_compiler_option(-mfpmath=sse)# !! important - be on the same wave with x64 compilers
else() else()
add_extra_compiler_option(-mfpmath=387) add_extra_compiler_option(-mfpmath=387)
...@@ -201,30 +199,35 @@ if(MSVC) ...@@ -201,30 +199,35 @@ if(MSVC)
set(OPENCV_EXTRA_FLAGS_RELEASE "${OPENCV_EXTRA_FLAGS_RELEASE} /Zi") set(OPENCV_EXTRA_FLAGS_RELEASE "${OPENCV_EXTRA_FLAGS_RELEASE} /Zi")
endif() endif()
if(NOT MSVC64) if(ENABLE_AVX AND NOT MSVC_VERSION LESS 1600)
# 64-bit MSVC compiler uses SSE/SSE2 by default set(OPENCV_EXTRA_FLAGS "${OPENCV_EXTRA_FLAGS} /arch:AVX")
if(ENABLE_SSE)
set(OPENCV_EXTRA_FLAGS "${OPENCV_EXTRA_FLAGS} /arch:SSE")
endif()
if(ENABLE_SSE2)
set(OPENCV_EXTRA_FLAGS "${OPENCV_EXTRA_FLAGS} /arch:SSE2")
endif()
endif() endif()
if(ENABLE_SSE3) if(ENABLE_SSE4_1 AND CV_ICC AND NOT OPENCV_EXTRA_FLAGS MATCHES "/arch:")
set(OPENCV_EXTRA_FLAGS "${OPENCV_EXTRA_FLAGS} /arch:SSE4.1")
endif()
if(ENABLE_SSE3 AND CV_ICC AND NOT OPENCV_EXTRA_FLAGS MATCHES "/arch:")
set(OPENCV_EXTRA_FLAGS "${OPENCV_EXTRA_FLAGS} /arch:SSE3") set(OPENCV_EXTRA_FLAGS "${OPENCV_EXTRA_FLAGS} /arch:SSE3")
endif() endif()
if(ENABLE_SSE4_1)
set(OPENCV_EXTRA_FLAGS "${OPENCV_EXTRA_FLAGS} /arch:SSE4.1") if(NOT MSVC64)
# 64-bit MSVC compiler uses SSE/SSE2 by default
if(ENABLE_SSE2 AND NOT OPENCV_EXTRA_FLAGS MATCHES "/arch:")
set(OPENCV_EXTRA_FLAGS "${OPENCV_EXTRA_FLAGS} /arch:SSE2")
endif()
if(ENABLE_SSE AND NOT OPENCV_EXTRA_FLAGS MATCHES "/arch:")
set(OPENCV_EXTRA_FLAGS "${OPENCV_EXTRA_FLAGS} /arch:SSE")
endif()
endif() endif()
if(ENABLE_SSE OR ENABLE_SSE2 OR ENABLE_SSE3 OR ENABLE_SSE4_1) if(ENABLE_SSE OR ENABLE_SSE2 OR ENABLE_SSE3 OR ENABLE_SSE4_1 OR ENABLE_AVX)
set(OPENCV_EXTRA_FLAGS "${OPENCV_EXTRA_FLAGS} /Oi") set(OPENCV_EXTRA_FLAGS "${OPENCV_EXTRA_FLAGS} /Oi")
endif() endif()
if(X86 OR X86_64) if(X86 OR X86_64)
if(CMAKE_SIZEOF_VOID_P EQUAL 4 AND ENABLE_SSE2) if(CMAKE_SIZEOF_VOID_P EQUAL 4 AND ENABLE_SSE2)
set(OPENCV_EXTRA_FLAGS "${OPENCV_EXTRA_FLAGS} /fp:fast")# !! important - be on the same wave with x64 compilers set(OPENCV_EXTRA_FLAGS "${OPENCV_EXTRA_FLAGS} /fp:fast") # !! important - be on the same wave with x64 compilers
endif() endif()
endif() endif()
endif() endif()
...@@ -238,34 +241,34 @@ endif() ...@@ -238,34 +241,34 @@ endif()
# Add user supplied extra options (optimization, etc...) # Add user supplied extra options (optimization, etc...)
# ========================================================== # ==========================================================
set(OPENCV_EXTRA_FLAGS "${OPENCV_EXTRA_FLAGS}" CACHE INTERNAL "Extra compiler options") set(OPENCV_EXTRA_FLAGS "${OPENCV_EXTRA_FLAGS}" CACHE INTERNAL "Extra compiler options")
set(OPENCV_EXTRA_C_FLAGS "${OPENCV_EXTRA_C_FLAGS}" CACHE INTERNAL "Extra compiler options for C sources") set(OPENCV_EXTRA_C_FLAGS "${OPENCV_EXTRA_C_FLAGS}" CACHE INTERNAL "Extra compiler options for C sources")
set(OPENCV_EXTRA_CXX_FLAGS "${OPENCV_EXTRA_CXX_FLAGS}" CACHE INTERNAL "Extra compiler options for C++ sources") set(OPENCV_EXTRA_CXX_FLAGS "${OPENCV_EXTRA_CXX_FLAGS}" CACHE INTERNAL "Extra compiler options for C++ sources")
set(OPENCV_EXTRA_FLAGS_RELEASE "${OPENCV_EXTRA_FLAGS_RELEASE}" CACHE INTERNAL "Extra compiler options for Release build") set(OPENCV_EXTRA_FLAGS_RELEASE "${OPENCV_EXTRA_FLAGS_RELEASE}" CACHE INTERNAL "Extra compiler options for Release build")
set(OPENCV_EXTRA_FLAGS_DEBUG "${OPENCV_EXTRA_FLAGS_DEBUG}" CACHE INTERNAL "Extra compiler options for Debug build") set(OPENCV_EXTRA_FLAGS_DEBUG "${OPENCV_EXTRA_FLAGS_DEBUG}" CACHE INTERNAL "Extra compiler options for Debug build")
set(OPENCV_EXTRA_EXE_LINKER_FLAGS "${OPENCV_EXTRA_EXE_LINKER_FLAGS}" CACHE INTERNAL "Extra linker flags") set(OPENCV_EXTRA_EXE_LINKER_FLAGS "${OPENCV_EXTRA_EXE_LINKER_FLAGS}" CACHE INTERNAL "Extra linker flags")
set(OPENCV_EXTRA_EXE_LINKER_FLAGS_RELEASE "${OPENCV_EXTRA_EXE_LINKER_FLAGS_RELEASE}" CACHE INTERNAL "Extra linker flags for Release build") set(OPENCV_EXTRA_EXE_LINKER_FLAGS_RELEASE "${OPENCV_EXTRA_EXE_LINKER_FLAGS_RELEASE}" CACHE INTERNAL "Extra linker flags for Release build")
set(OPENCV_EXTRA_EXE_LINKER_FLAGS_DEBUG "${OPENCV_EXTRA_EXE_LINKER_FLAGS_DEBUG}" CACHE INTERNAL "Extra linker flags for Debug build") set(OPENCV_EXTRA_EXE_LINKER_FLAGS_DEBUG "${OPENCV_EXTRA_EXE_LINKER_FLAGS_DEBUG}" CACHE INTERNAL "Extra linker flags for Debug build")
#combine all "extra" options #combine all "extra" options
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OPENCV_EXTRA_FLAGS} ${OPENCV_EXTRA_C_FLAGS}") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OPENCV_EXTRA_FLAGS} ${OPENCV_EXTRA_C_FLAGS}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OPENCV_EXTRA_FLAGS} ${OPENCV_EXTRA_CXX_FLAGS}") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OPENCV_EXTRA_FLAGS} ${OPENCV_EXTRA_CXX_FLAGS}")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} ${OPENCV_EXTRA_FLAGS_RELEASE}") set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} ${OPENCV_EXTRA_FLAGS_RELEASE}")
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} ${OPENCV_EXTRA_FLAGS_RELEASE}") set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} ${OPENCV_EXTRA_FLAGS_RELEASE}")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} ${OPENCV_EXTRA_FLAGS_DEBUG}") set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} ${OPENCV_EXTRA_FLAGS_DEBUG}")
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} ${OPENCV_EXTRA_FLAGS_DEBUG}") set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} ${OPENCV_EXTRA_FLAGS_DEBUG}")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${OPENCV_EXTRA_EXE_LINKER_FLAGS}") set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${OPENCV_EXTRA_EXE_LINKER_FLAGS}")
set(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} ${OPENCV_EXTRA_EXE_LINKER_FLAGS_RELEASE}") set(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} ${OPENCV_EXTRA_EXE_LINKER_FLAGS_RELEASE}")
set(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} ${OPENCV_EXTRA_EXE_LINKER_FLAGS_DEBUG}") set(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} ${OPENCV_EXTRA_EXE_LINKER_FLAGS_DEBUG}")
if(MSVC) if(MSVC)
# avoid warnings from MSVC about overriding the /W* option # avoid warnings from MSVC about overriding the /W* option
# we replace /W3 with /W4 only for C++ files, # we replace /W3 with /W4 only for C++ files,
# since all the 3rd-party libraries OpenCV uses are in C, # since all the 3rd-party libraries OpenCV uses are in C,
# and we do not care about their warnings. # and we do not care about their warnings.
string(REPLACE "/W3" "/W4" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") string(REPLACE "/W3" "/W4" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
string(REPLACE "/W3" "/W4" CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE}") string(REPLACE "/W3" "/W4" CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE}")
string(REPLACE "/W3" "/W4" CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}") string(REPLACE "/W3" "/W4" CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}")
if(NOT ENABLE_NOISY_WARNINGS AND MSVC_VERSION EQUAL 1400) if(NOT ENABLE_NOISY_WARNINGS AND MSVC_VERSION EQUAL 1400)
ocv_warnings_disable(CMAKE_CXX_FLAGS /wd4510 /wd4610 /wd4312 /wd4201 /wd4244 /wd4328 /wd4267) ocv_warnings_disable(CMAKE_CXX_FLAGS /wd4510 /wd4610 /wd4312 /wd4201 /wd4244 /wd4328 /wd4267)
...@@ -274,7 +277,7 @@ if(MSVC) ...@@ -274,7 +277,7 @@ if(MSVC)
# allow extern "C" functions throw exceptions # allow extern "C" functions throw exceptions
foreach(flags CMAKE_C_FLAGS CMAKE_C_FLAGS_RELEASE CMAKE_C_FLAGS_RELEASE CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_RELEASE CMAKE_CXX_FLAGS_DEBUG) foreach(flags CMAKE_C_FLAGS CMAKE_C_FLAGS_RELEASE CMAKE_C_FLAGS_RELEASE CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_RELEASE CMAKE_CXX_FLAGS_DEBUG)
string(REPLACE "/EHsc-" "/EHs" ${flags} "${${flags}}") string(REPLACE "/EHsc-" "/EHs" ${flags} "${${flags}}")
string(REPLACE "/EHsc" "/EHs" ${flags} "${${flags}}") string(REPLACE "/EHsc" "/EHs" ${flags} "${${flags}}")
string(REPLACE "/Zm1000" "" ${flags} "${${flags}}") string(REPLACE "/Zm1000" "" ${flags} "${${flags}}")
endforeach() endforeach()
......
...@@ -89,8 +89,8 @@ if(CMAKE_COMPILER_IS_GNUCXX) ...@@ -89,8 +89,8 @@ if(CMAKE_COMPILER_IS_GNUCXX)
endif() endif()
endif() endif()
if(CMAKE_SYSTEM_PROCESSOR MATCHES amd64.*|x86_64.* OR CMAKE_GENERATOR MATCHES "Visual Studio.*Win64") if(CMAKE_SYSTEM_PROCESSOR MATCHES "amd64.*|x86_64.*|AMD64.*" OR CMAKE_GENERATOR MATCHES "Visual Studio.*Win64")
set(X86_64 1) set(X86_64 1)
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES i686.*|i386.*|x86.*) elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "i686.*|i386.*|x86.*|amd64.*|AMD64.*")
set(X86 1) set(X86 1)
endif() endif()
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
# --- TBB --- # --- TBB ---
if(WITH_TBB) if(WITH_TBB)
include("${OpenCV_SOURCE_DIR}/cmake/OpenCVDetectTBB.cmake" REQUIRED) include("${OpenCV_SOURCE_DIR}/cmake/OpenCVDetectTBB.cmake")
endif(WITH_TBB) endif(WITH_TBB)
# --- IPP --- # --- IPP ---
...@@ -21,7 +21,7 @@ endif(WITH_IPP) ...@@ -21,7 +21,7 @@ endif(WITH_IPP)
# --- CUDA --- # --- CUDA ---
if(WITH_CUDA) if(WITH_CUDA)
include("${OpenCV_SOURCE_DIR}/cmake/OpenCVDetectCUDA.cmake" REQUIRED) include("${OpenCV_SOURCE_DIR}/cmake/OpenCVDetectCUDA.cmake")
endif(WITH_CUDA) endif(WITH_CUDA)
# --- Eigen --- # --- Eigen ---
......
...@@ -98,7 +98,7 @@ endif(WITH_XIMEA) ...@@ -98,7 +98,7 @@ endif(WITH_XIMEA)
ocv_clear_vars(HAVE_FFMPEG HAVE_FFMPEG_CODEC HAVE_FFMPEG_FORMAT HAVE_FFMPEG_UTIL HAVE_FFMPEG_SWSCALE HAVE_GENTOO_FFMPEG HAVE_FFMPEG_FFMPEG) ocv_clear_vars(HAVE_FFMPEG HAVE_FFMPEG_CODEC HAVE_FFMPEG_FORMAT HAVE_FFMPEG_UTIL HAVE_FFMPEG_SWSCALE HAVE_GENTOO_FFMPEG HAVE_FFMPEG_FFMPEG)
if(WITH_FFMPEG) if(WITH_FFMPEG)
if(WIN32) if(WIN32)
include("${OpenCV_SOURCE_DIR}/3rdparty/ffmpeg/ffmpeg_version.cmake" REQUIRED) include("${OpenCV_SOURCE_DIR}/3rdparty/ffmpeg/ffmpeg_version.cmake")
elseif(UNIX) elseif(UNIX)
CHECK_MODULE(libavcodec HAVE_FFMPEG_CODEC) CHECK_MODULE(libavcodec HAVE_FFMPEG_CODEC)
CHECK_MODULE(libavformat HAVE_FFMPEG_FORMAT) CHECK_MODULE(libavformat HAVE_FFMPEG_FORMAT)
......
...@@ -104,69 +104,72 @@ CV_INLINE IppiSize ippiSize(int width, int height) ...@@ -104,69 +104,72 @@ CV_INLINE IppiSize ippiSize(int width, int height)
} }
#endif #endif
#if defined __SSE2__ || (defined _MSC_VER && _MSC_VER >= 1300) #ifndef IPPI_CALL
# define IPPI_CALL(func) CV_Assert((func) >= 0)
#endif
#if defined __SSE2__ || defined _M_X64 || (defined _M_IX86_FP && _M_IX86_FP >= 2)
# include "emmintrin.h" # include "emmintrin.h"
# define CV_SSE 1 # define CV_SSE 1
# define CV_SSE2 1 # define CV_SSE2 1
# if defined __SSE3__ || (defined _MSC_VER && _MSC_VER >= 1500) # if defined __SSE3__ || (defined _MSC_VER && _MSC_VER >= 1500)
# include "pmmintrin.h" # include "pmmintrin.h"
# define CV_SSE3 1 # define CV_SSE3 1
# else
# define CV_SSE3 0
# endif # endif
# if defined __SSSE3__ # if defined __SSSE3__ || (defined _MSC_VER && _MSC_VER >= 1500)
# include "tmmintrin.h" # include "tmmintrin.h"
# define CV_SSSE3 1 # define CV_SSSE3 1
# else
# define CV_SSSE3 0
# endif # endif
# if defined __SSE4_1__ || (defined _MSC_VER && _MSC_VER >= 1500) # if defined __SSE4_1__ || (defined _MSC_VER && _MSC_VER >= 1500)
# include <smmintrin.h> # include <smmintrin.h>
# define CV_SSE4_1 1 # define CV_SSE4_1 1
# else
# define CV_SSE4_1 0
# endif # endif
# if defined __SSE4_2__ || (defined _MSC_VER && _MSC_VER >= 1500) # if defined __SSE4_2__ || (defined _MSC_VER && _MSC_VER >= 1500)
# include <nmmintrin.h> # include <nmmintrin.h>
# define CV_SSE4_2 1 # define CV_SSE4_2 1
# else
# define CV_SSE4_2 0
# endif # endif
# if defined __AVX__ || (defined _MSC_FULL_VER && _MSC_FULL_VER >= 160040219) # if defined __AVX__ || (defined _MSC_FULL_VER && _MSC_FULL_VER >= 160040219)
# include <immintrin.h> // MS Visual Studio 2010 (2012?) has no macro pre-defined to identify the use of /arch:AVX
// See: http://connect.microsoft.com/VisualStudio/feedback/details/605858/arch-avx-should-define-a-predefined-macro-in-x64-and-set-a-unique-value-for-m-ix86-fp-in-win32
# include <immintrin.h>
# define CV_AVX 1 # define CV_AVX 1
# if defined(_XCR_XFEATURE_ENABLED_MASK) # if defined(_XCR_XFEATURE_ENABLED_MASK)
# define __xgetbv() _xgetbv(_XCR_XFEATURE_ENABLED_MASK) # define __xgetbv() _xgetbv(_XCR_XFEATURE_ENABLED_MASK)
# else # else
# define __xgetbv() 0 # define __xgetbv() 0
# endif # endif
# else
# define CV_AVX 0
# endif # endif
# else #endif
#ifdef __ARM_NEON__
# include <arm_neon.h>
# define CV_NEON 1
# define CPU_HAS_NEON_FEATURE (true)
#endif
#ifndef CV_SSE
# define CV_SSE 0 # define CV_SSE 0
#endif
#ifndef CV_SSE2
# define CV_SSE2 0 # define CV_SSE2 0
#endif
#ifndef CV_SSE3
# define CV_SSE3 0 # define CV_SSE3 0
#endif
#ifndef CV_SSSE3
# define CV_SSSE3 0 # define CV_SSSE3 0
#endif
#ifndef CV_SSE4_1
# define CV_SSE4_1 0 # define CV_SSE4_1 0
#endif
#ifndef CV_SSE4_2
# define CV_SSE4_2 0 # define CV_SSE4_2 0
#endif
#ifndef CV_AVX
# define CV_AVX 0 # define CV_AVX 0
# endif
#if defined ANDROID && defined __ARM_NEON__
# include "arm_neon.h"
# define CV_NEON 1
# define CPU_HAS_NEON_FEATURE (true)
//TODO: make real check using stuff from "cpu-features.h"
//((bool)android_getCpuFeatures() & ANDROID_CPU_ARM_FEATURE_NEON)
#else
# define CV_NEON 0
# define CPU_HAS_NEON_FEATURE (false)
#endif #endif
#ifndef CV_NEON
#ifndef IPPI_CALL # define CV_NEON 0
# define IPPI_CALL(func) CV_Assert((func) >= 0)
#endif #endif
#ifdef HAVE_TBB #ifdef HAVE_TBB
......
...@@ -774,7 +774,7 @@ bool CV_OperationsTest::TestTemplateMat() ...@@ -774,7 +774,7 @@ bool CV_OperationsTest::TestTemplateMat()
Mat m2 = Mat::zeros(10, 10, CV_8UC3); Mat m2 = Mat::zeros(10, 10, CV_8UC3);
m1.copyTo(m2.row(1)); m1.copyTo(m2.row(1));
} }
catch(const Exception& e) catch(const Exception&)
{ {
badarg_catched = true; badarg_catched = true;
} }
......
...@@ -1739,7 +1739,7 @@ PERF_TEST_P(Method_Sz, ImgProc_GeneralizedHough, Combine( ...@@ -1739,7 +1739,7 @@ PERF_TEST_P(Method_Sz, ImgProc_GeneralizedHough, Combine(
for (int i = 0; i < objCount; ++i) for (int i = 0; i < objCount; ++i)
{ {
double scale = rng.uniform(0.7, 1.3); double scale = rng.uniform(0.7, 1.3);
bool rotate = rng.uniform(0, 2); bool rotate = 1 == rng.uniform(0, 2);
cv::Mat obj; cv::Mat obj;
cv::resize(templ, obj, cv::Size(), scale, scale); cv::resize(templ, obj, cv::Size(), scale, scale);
......
...@@ -433,7 +433,7 @@ void CV_Resize_Test::run_reference_func() ...@@ -433,7 +433,7 @@ void CV_Resize_Test::run_reference_func()
double CV_Resize_Test::getWeight(double a, double b, int x) double CV_Resize_Test::getWeight(double a, double b, int x)
{ {
float w = std::min(static_cast<double>(x + 1), b) - std::max(static_cast<double>(x), a); double w = std::min(static_cast<double>(x + 1), b) - std::max(static_cast<double>(x), a);
CV_Assert(w >= 0); CV_Assert(w >= 0);
return w; return w;
} }
...@@ -514,7 +514,7 @@ void CV_Resize_Test::resize_1d(const Mat& _src, Mat& _dst, int dy, const dim& _d ...@@ -514,7 +514,7 @@ void CV_Resize_Test::resize_1d(const Mat& _src, Mat& _dst, int dy, const dim& _d
else if (interpolation == INTER_LINEAR || interpolation == INTER_CUBIC || interpolation == INTER_LANCZOS4) else if (interpolation == INTER_LINEAR || interpolation == INTER_CUBIC || interpolation == INTER_LANCZOS4)
{ {
internal::interpolate_method inter_func = internal::inter_array[interpolation - (interpolation == INTER_LANCZOS4 ? 2 : 1)]; internal::interpolate_method inter_func = internal::inter_array[interpolation - (interpolation == INTER_LANCZOS4 ? 2 : 1)];
int elemsize = _src.elemSize(); size_t elemsize = _src.elemSize();
int ofs = 0, ksize = 2; int ofs = 0, ksize = 2;
if (interpolation == INTER_CUBIC) if (interpolation == INTER_CUBIC)
...@@ -557,10 +557,10 @@ void CV_Resize_Test::resize_1d(const Mat& _src, Mat& _dst, int dy, const dim& _d ...@@ -557,10 +557,10 @@ void CV_Resize_Test::resize_1d(const Mat& _src, Mat& _dst, int dy, const dim& _d
void CV_Resize_Test::generate_buffer(double scale, dim& _dim) void CV_Resize_Test::generate_buffer(double scale, dim& _dim)
{ {
int length = _dim.size(); size_t length = _dim.size();
for (int dx = 0; dx < length; ++dx) for (size_t dx = 0; dx < length; ++dx)
{ {
double fsx = scale * (dx + 0.5f) - 0.5f; double fsx = scale * (dx + 0.5) - 0.5;
int isx = cvFloor(fsx); int isx = cvFloor(fsx);
_dim[dx] = std::make_pair(isx, fsx - isx); _dim[dx] = std::make_pair(isx, fsx - isx);
} }
......
# ---------------------------------------------------------------------------- # ----------------------------------------------------------------------------
# CMake file for java support # CMake file for java support
# ---------------------------------------------------------------------------- # ----------------------------------------------------------------------------
if(NOT ANDROID OR NOT PYTHON_EXECUTABLE OR ANDROID_NATIVE_API_LEVEL LESS 8) if(IOS OR NOT PYTHON_EXECUTABLE OR NOT (JNI_FOUND OR (ANDROID AND ANDROID_NATIVE_API_LEVEL GREATER 7)))
ocv_module_disable(java) ocv_module_disable(java)
endif() endif()
if(NOT ANDROID)
# disable java by default because java support on desktop is experimental
set(BUILD_opencv_java_INIT OFF)
endif()
set(the_description "The java bindings") set(the_description "The java bindings")
ocv_add_module(java BINDINGS opencv_core opencv_imgproc OPTIONAL opencv_objdetect opencv_features2d opencv_video opencv_highgui opencv_ml opencv_calib3d opencv_photo opencv_nonfree opencv_contrib) ocv_add_module(java BINDINGS opencv_core opencv_imgproc OPTIONAL opencv_objdetect opencv_features2d opencv_video opencv_highgui opencv_ml opencv_calib3d opencv_photo opencv_nonfree opencv_contrib)
ocv_module_include_directories("${CMAKE_CURRENT_SOURCE_DIR}/generator/src/cpp") ocv_module_include_directories("${CMAKE_CURRENT_SOURCE_DIR}/generator/src/cpp")
if(NOT ANDROID)
include_directories(${JNI_INCLUDE_DIRS})
endif()
# get list of modules to wrap # get list of modules to wrap
string(REPLACE "opencv_" "" OPENCV_JAVA_MODULES "${OPENCV_MODULE_${the_module}_REQ_DEPS};${OPENCV_MODULE_${the_module}_OPT_DEPS}") string(REPLACE "opencv_" "" OPENCV_JAVA_MODULES "${OPENCV_MODULE_${the_module}_REQ_DEPS};${OPENCV_MODULE_${the_module}_OPT_DEPS}")
foreach(module ${OPENCV_JAVA_MODULES}) foreach(module ${OPENCV_JAVA_MODULES})
...@@ -123,7 +132,12 @@ set(JNI_INSTALL_ROOT "sdk/native") ...@@ -123,7 +132,12 @@ set(JNI_INSTALL_ROOT "sdk/native")
# copy each documented header to the final destination # copy each documented header to the final destination
set(java_files "") set(java_files "")
foreach(java_file ${documented_java_files} ${handwrittren_aidl_sources}) set(source_java_files ${documented_java_files} ${handwrittren_aidl_sources})
if(NOT ANDROID)
ocv_list_filterout(source_java_files "/(engine|android)\\\\+")
endif()
foreach(java_file ${source_java_files})
get_filename_component(java_file_name "${java_file}" NAME) get_filename_component(java_file_name "${java_file}" NAME)
string(REPLACE "-jdoc.java" ".java" java_file_name "${java_file_name}") string(REPLACE "-jdoc.java" ".java" java_file_name "${java_file_name}")
string(REPLACE "+" "/" java_file_name "${java_file_name}") string(REPLACE "+" "/" java_file_name "${java_file_name}")
...@@ -173,8 +187,11 @@ set_target_properties(${the_module} PROPERTIES ...@@ -173,8 +187,11 @@ set_target_properties(${the_module} PROPERTIES
LINK_INTERFACE_LIBRARIES "" LINK_INTERFACE_LIBRARIES ""
) )
install(TARGETS ${the_module} LIBRARY DESTINATION ${OPENCV_LIB_INSTALL_PATH} COMPONENT main) install(TARGETS ${the_module}
LIBRARY DESTINATION ${OPENCV_LIB_INSTALL_PATH} COMPONENT main
ARCHIVE DESTINATION ${OPENCV_LIB_INSTALL_PATH} COMPONENT main)
set(lib_target ${the_module}_library)
if(ANDROID) if(ANDROID)
target_link_libraries(${the_module} jnigraphics) # for Mat <=> Bitmap converters target_link_libraries(${the_module} jnigraphics) # for Mat <=> Bitmap converters
...@@ -223,8 +240,6 @@ if(ANDROID) ...@@ -223,8 +240,6 @@ if(ANDROID)
# create Android library project in build folder # create Android library project in build folder
if(ANDROID_EXECUTABLE) if(ANDROID_EXECUTABLE)
set(lib_target ${the_module}_android_library)
set(lib_target_files ${ANDROID_LIB_PROJECT_FILES}) set(lib_target_files ${ANDROID_LIB_PROJECT_FILES})
ocv_list_add_prefix(lib_target_files "${OpenCV_BINARY_DIR}/") ocv_list_add_prefix(lib_target_files "${OpenCV_BINARY_DIR}/")
...@@ -263,12 +278,26 @@ if(ANDROID) ...@@ -263,12 +278,26 @@ if(ANDROID)
endif() endif()
add_custom_target(${lib_target} SOURCES ${lib_proj_files} ${lib_target_files} "${OpenCV_BINARY_DIR}/${ANDROID_MANIFEST_FILE}") add_custom_target(${lib_target} SOURCES ${lib_proj_files} ${lib_target_files} "${OpenCV_BINARY_DIR}/${ANDROID_MANIFEST_FILE}")
add_dependencies(${lib_target} ${api_target})
add_dependencies(${the_module} ${lib_target})
endif() endif()
else(ANDROID)
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/jar/build.xml" "${OpenCV_BINARY_DIR}/build.xml" IMMEDIATE @ONLY)
set(JAR_NAME opencv-${OPENCV_VERSION_MAJOR}.${OPENCV_VERSION_MINOR}.${OPENCV_VERSION_PATCH}.jar)
add_custom_command(
OUTPUT "${OpenCV_BINARY_DIR}/bin/${JAR_NAME}" "${OpenCV_BINARY_DIR}/bin/.${JAR_NAME}.dephelper"
COMMAND ${ANT_EXECUTABLE} -q -noinput -k jar
COMMAND ${CMAKE_COMMAND} -E touch "${OpenCV_BINARY_DIR}/bin/.${JAR_NAME}.dephelper"
WORKING_DIRECTORY "${OpenCV_BINARY_DIR}"
DEPENDS "${OpenCV_BINARY_DIR}/build.xml" ${java_files}
COMMENT "Generating ${JAR_NAME}"
)
add_custom_target(${lib_target} SOURCES "${OpenCV_BINARY_DIR}/bin/${JAR_NAME}")
endif(ANDROID) endif(ANDROID)
add_dependencies(${lib_target} ${api_target})
add_dependencies(${the_module} ${lib_target})
#android test project #android test project
if(ANDROID AND BUILD_TESTS) if(ANDROID AND BUILD_TESTS)
add_subdirectory(android_test) add_subdirectory(android_test)
......
...@@ -462,8 +462,10 @@ JNIEXPORT jdoubleArray JNICALL Java_org_opencv_core_Core_n_1getTextSize ...@@ -462,8 +462,10 @@ JNIEXPORT jdoubleArray JNICALL Java_org_opencv_core_Core_n_1getTextSize
env->SetDoubleArrayRegion(result, 0, 2, fill); env->SetDoubleArrayRegion(result, 0, 2, fill);
if (baseLine != NULL) if (baseLine != NULL) {
env->SetIntArrayRegion(baseLine, 0, 1, pbaseLine); jint jbaseLine = (jint)(*pbaseLine);
env->SetIntArrayRegion(baseLine, 0, 1, &jbaseLine);
}
return result; return result;
...@@ -871,14 +873,18 @@ public class %(jc)s { ...@@ -871,14 +873,18 @@ public class %(jc)s {
#include "converters.h" #include "converters.h"
#ifdef DEBUG #if defined DEBUG && defined ANDROID
#include <android/log.h> # include <android/log.h>
#define MODULE_LOG_TAG "OpenCV.%(m)s" # define MODULE_LOG_TAG "OpenCV.%(m)s"
#define LOGD(...) ((void)__android_log_print(ANDROID_LOG_DEBUG, MODULE_LOG_TAG, __VA_ARGS__)) # define LOGD(...) ((void)__android_log_print(ANDROID_LOG_DEBUG, MODULE_LOG_TAG, __VA_ARGS__))
#else //DEBUG #else //DEBUG
#define LOGD(...) # define LOGD(...)
#endif //DEBUG #endif //DEBUG
#ifdef _MSC_VER
# pragma warning(disable:4800 4244)
#endif
#include "opencv2/%(m)s/%(m)s.hpp" #include "opencv2/%(m)s/%(m)s.hpp"
using namespace cv; using namespace cv;
......
...@@ -2,6 +2,8 @@ ...@@ -2,6 +2,8 @@
#include "converters.h" #include "converters.h"
#ifdef ANDROID
#include <android/log.h> #include <android/log.h>
#define LOG_TAG "org.opencv.core.Mat" #define LOG_TAG "org.opencv.core.Mat"
#define LOGE(...) ((void)__android_log_print(ANDROID_LOG_ERROR, LOG_TAG, __VA_ARGS__)) #define LOGE(...) ((void)__android_log_print(ANDROID_LOG_ERROR, LOG_TAG, __VA_ARGS__))
...@@ -11,6 +13,15 @@ ...@@ -11,6 +13,15 @@
#define LOGD(...) #define LOGD(...)
#endif //DEBUG #endif //DEBUG
#else
#define LOGE(...)
#define LOGD(...)
#endif
#ifdef _MSC_VER
# pragma warning(disable:4800)
#endif
#include "opencv2/core/core.hpp" #include "opencv2/core/core.hpp"
using namespace cv; using namespace cv;
...@@ -2163,7 +2174,7 @@ template<typename T> static int mat_put(cv::Mat* m, int row, int col, int count, ...@@ -2163,7 +2174,7 @@ template<typename T> static int mat_put(cv::Mat* m, int row, int col, int count,
if(! buff) return 0; if(! buff) return 0;
count *= sizeof(T); count *= sizeof(T);
int rest = ((m->rows - row) * m->cols - col) * m->elemSize(); int rest = ((m->rows - row) * m->cols - col) * (int)m->elemSize();
if(count>rest) count = rest; if(count>rest) count = rest;
int res = count; int res = count;
...@@ -2172,14 +2183,14 @@ template<typename T> static int mat_put(cv::Mat* m, int row, int col, int count, ...@@ -2172,14 +2183,14 @@ template<typename T> static int mat_put(cv::Mat* m, int row, int col, int count,
memcpy(m->ptr(row, col), buff, count); memcpy(m->ptr(row, col), buff, count);
} else { } else {
// row by row // row by row
int num = (m->cols - col) * m->elemSize(); // 1st partial row int num = (m->cols - col) * (int)m->elemSize(); // 1st partial row
if(count<num) num = count; if(count<num) num = count;
uchar* data = m->ptr(row++, col); uchar* data = m->ptr(row++, col);
while(count>0){ while(count>0){
memcpy(data, buff, num); memcpy(data, buff, num);
count -= num; count -= num;
buff += num; buff += num;
num = m->cols * m->elemSize(); num = m->cols * (int)m->elemSize();
if(count<num) num = count; if(count<num) num = count;
data = m->ptr(row++, 0); data = m->ptr(row++, 0);
} }
...@@ -2323,7 +2334,7 @@ template<typename T> int mat_get(cv::Mat* m, int row, int col, int count, char* ...@@ -2323,7 +2334,7 @@ template<typename T> int mat_get(cv::Mat* m, int row, int col, int count, char*
if(! buff) return 0; if(! buff) return 0;
int bytesToCopy = count * sizeof(T); int bytesToCopy = count * sizeof(T);
int bytesRestInMat = ((m->rows - row) * m->cols - col) * m->elemSize(); int bytesRestInMat = ((m->rows - row) * m->cols - col) * (int)m->elemSize();
if(bytesToCopy > bytesRestInMat) bytesToCopy = bytesRestInMat; if(bytesToCopy > bytesRestInMat) bytesToCopy = bytesRestInMat;
int res = bytesToCopy; int res = bytesToCopy;
...@@ -2332,7 +2343,7 @@ template<typename T> int mat_get(cv::Mat* m, int row, int col, int count, char* ...@@ -2332,7 +2343,7 @@ template<typename T> int mat_get(cv::Mat* m, int row, int col, int count, char*
memcpy(buff, m->ptr(row, col), bytesToCopy); memcpy(buff, m->ptr(row, col), bytesToCopy);
} else { } else {
// row by row // row by row
int bytesInRow = (m->cols - col) * m->elemSize(); // 1st partial row int bytesInRow = (m->cols - col) * (int)m->elemSize(); // 1st partial row
while(bytesToCopy > 0) while(bytesToCopy > 0)
{ {
int len = std::min(bytesToCopy, bytesInRow); int len = std::min(bytesToCopy, bytesInRow);
...@@ -2341,7 +2352,7 @@ template<typename T> int mat_get(cv::Mat* m, int row, int col, int count, char* ...@@ -2341,7 +2352,7 @@ template<typename T> int mat_get(cv::Mat* m, int row, int col, int count, char*
buff += len; buff += len;
row++; row++;
col = 0; col = 0;
bytesInRow = m->cols * m->elemSize(); bytesInRow = m->cols * (int)m->elemSize();
} }
} }
return res; return res;
...@@ -2518,7 +2529,7 @@ JNIEXPORT jdoubleArray JNICALL Java_org_opencv_core_Mat_nGet ...@@ -2518,7 +2529,7 @@ JNIEXPORT jdoubleArray JNICALL Java_org_opencv_core_Mat_nGet
jdoubleArray res = env->NewDoubleArray(me->channels()); jdoubleArray res = env->NewDoubleArray(me->channels());
if(res){ if(res){
jdouble buff[me->channels()]; jdouble buff[CV_CN_MAX];//me->channels()
int i; int i;
switch(me->depth()){ switch(me->depth()){
case CV_8U: for(i=0; i<me->channels(); i++) buff[i] = *((unsigned char*) me->ptr(row, col) + i); break; case CV_8U: for(i=0; i<me->channels(); i++) buff[i] = *((unsigned char*) me->ptr(row, col) + i); break;
......
...@@ -198,12 +198,12 @@ void Mat_to_vector_KeyPoint(Mat& mat, vector<KeyPoint>& v_kp) ...@@ -198,12 +198,12 @@ void Mat_to_vector_KeyPoint(Mat& mat, vector<KeyPoint>& v_kp)
void vector_KeyPoint_to_Mat(vector<KeyPoint>& v_kp, Mat& mat) void vector_KeyPoint_to_Mat(vector<KeyPoint>& v_kp, Mat& mat)
{ {
int count = v_kp.size(); int count = (int)v_kp.size();
mat.create(count, 1, CV_32FC(7)); mat.create(count, 1, CV_32FC(7));
for(int i=0; i<count; i++) for(int i=0; i<count; i++)
{ {
KeyPoint kp = v_kp[i]; KeyPoint kp = v_kp[i];
mat.at< Vec<float, 7> >(i, 0) = Vec<float, 7>(kp.pt.x, kp.pt.y, kp.size, kp.angle, kp.response, kp.octave, kp.class_id); mat.at< Vec<float, 7> >(i, 0) = Vec<float, 7>(kp.pt.x, kp.pt.y, kp.size, kp.angle, kp.response, (float)kp.octave, (float)kp.class_id);
} }
} }
#endif #endif
...@@ -231,7 +231,7 @@ void Mat_to_vector_Mat(cv::Mat& mat, std::vector<cv::Mat>& v_mat) ...@@ -231,7 +231,7 @@ void Mat_to_vector_Mat(cv::Mat& mat, std::vector<cv::Mat>& v_mat)
void vector_Mat_to_Mat(std::vector<cv::Mat>& v_mat, cv::Mat& mat) void vector_Mat_to_Mat(std::vector<cv::Mat>& v_mat, cv::Mat& mat)
{ {
int count = v_mat.size(); int count = (int)v_mat.size();
mat.create(count, 1, CV_32SC2); mat.create(count, 1, CV_32SC2);
for(int i=0; i<count; i++) for(int i=0; i<count; i++)
{ {
...@@ -258,12 +258,12 @@ void Mat_to_vector_DMatch(Mat& mat, vector<DMatch>& v_dm) ...@@ -258,12 +258,12 @@ void Mat_to_vector_DMatch(Mat& mat, vector<DMatch>& v_dm)
void vector_DMatch_to_Mat(vector<DMatch>& v_dm, Mat& mat) void vector_DMatch_to_Mat(vector<DMatch>& v_dm, Mat& mat)
{ {
int count = v_dm.size(); int count = (int)v_dm.size();
mat.create(count, 1, CV_32FC4); mat.create(count, 1, CV_32FC4);
for(int i=0; i<count; i++) for(int i=0; i<count; i++)
{ {
DMatch dm = v_dm[i]; DMatch dm = v_dm[i];
mat.at< Vec<float, 4> >(i, 0) = Vec<float, 4>(dm.queryIdx, dm.trainIdx, dm.imgIdx, dm.distance); mat.at< Vec<float, 4> >(i, 0) = Vec<float, 4>((float)dm.queryIdx, (float)dm.trainIdx, (float)dm.imgIdx, dm.distance);
} }
} }
#endif #endif
......
...@@ -6,6 +6,8 @@ ...@@ -6,6 +6,8 @@
#ifdef HAVE_OPENCV_FEATURES2D #ifdef HAVE_OPENCV_FEATURES2D
#include "opencv2/features2d/features2d.hpp" #include "opencv2/features2d/features2d.hpp"
#undef SIMPLEBLOB // to solve conflict with wincrypt.h on windows
namespace cv namespace cv
{ {
......
...@@ -3,6 +3,8 @@ ...@@ -3,6 +3,8 @@
#include "opencv2/core/core.hpp" #include "opencv2/core/core.hpp"
#include "opencv2/imgproc/imgproc.hpp" #include "opencv2/imgproc/imgproc.hpp"
#ifdef ANDROID
#include <android/bitmap.h> #include <android/bitmap.h>
#include <android/log.h> #include <android/log.h>
...@@ -165,3 +167,5 @@ JNIEXPORT void JNICALL Java_org_opencv_android_Utils_nMatToBitmap ...@@ -165,3 +167,5 @@ JNIEXPORT void JNICALL Java_org_opencv_android_Utils_nMatToBitmap
} }
} // extern "C" } // extern "C"
#endif //ANDROID
\ No newline at end of file
<!-- This is an Apache Ant build file. As part of the desktop java build -->
<!-- process, this config is used to package the autogenerated .java -->
<!-- interface files into OpenCV.jar -->
<project name="OpenCV">
<target name="jar">
<!-- This is to make a jar with a source attachment, for e.g. easy -->
<!-- navigation in Eclipse. See this question: -->
<!-- http://stackoverflow.com/questions/3584968/ant-how-to-compile-jar-that-includes-source-attachment -->
<javac sourcepath="" srcdir="src" destdir="src" debug="on" includeantruntime="false" >
<include name="**/*.java"/>
</javac>
<jar basedir="src" destfile="bin/opencv-@OPENCV_VERSION_MAJOR@.@OPENCV_VERSION_MINOR@.@OPENCV_VERSION_PATCH@.jar"/>
</target>
</project>
\ No newline at end of file
This diff is collapsed.
...@@ -176,7 +176,7 @@ int main(int argc, char** argv) ...@@ -176,7 +176,7 @@ int main(int argc, char** argv)
// display until user presses q // display until user presses q
imshow(winName, reconstruction); imshow(winName, reconstruction);
char key = 0; int key = 0;
while(key != 'q') while(key != 'q')
key = waitKey(); key = waitKey();
......
...@@ -86,7 +86,7 @@ static void run(int argc, char** argv) { ...@@ -86,7 +86,7 @@ static void run(int argc, char** argv) {
Mat flow; Mat flow;
float start = getTickCount(); float start = (float)getTickCount();
calcOpticalFlowSF(frame1, frame2, calcOpticalFlowSF(frame1, frame2,
flow, flow,
3, 2, 4, 4.1, 25.5, 18, 55.0, 25.5, 0.35, 18, 55.0, 25.5, 10); 3, 2, 4, 4.1, 25.5, 18, 55.0, 25.5, 0.35, 18, 55.0, 25.5, 10);
...@@ -156,7 +156,7 @@ static float calc_rmse(Mat flow1, Mat flow2) { ...@@ -156,7 +156,7 @@ static float calc_rmse(Mat flow1, Mat flow2) {
} }
} }
} }
return sqrt(sum / (1e-9 + counter)); return (float)sqrt(sum / (1e-9 + counter));
} }
static void eval(int argc, char** argv) { static void eval(int argc, char** argv) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment