Merge branch 'master' into gpu-cuda-rename

Conflicts:
	modules/cudaoptflow/perf/perf_optflow.cpp
	modules/cudaoptflow/src/tvl1flow.cpp
	samples/gpu/stereo_multi.cpp
pull/1299/head
Vladislav Vinogradov 12 years ago
commit 1ad4592bfc
  1. 10
      3rdparty/libtiff/CMakeLists.txt
  2. 3
      cmake/OpenCVCRTLinkage.cmake
  3. BIN
      doc/opencv-logo2.png
  4. 2
      doc/tutorials/core/mat_the_basic_image_container/mat_the_basic_image_container.rst
  5. 44
      modules/bioinspired/src/precomp.cpp
  6. 1
      modules/bioinspired/src/retina.cpp
  7. 1
      modules/bioinspired/test/test_precomp.cpp
  8. 4
      modules/core/include/opencv2/core.hpp
  9. 4
      modules/core/perf/perf_stat.cpp
  10. 47
      modules/core/src/arithm.cpp
  11. 50
      modules/core/src/dxt.cpp
  12. 8
      modules/core/src/glob.cpp
  13. 21
      modules/core/src/matmul.cpp
  14. 527
      modules/core/src/stat.cpp
  15. 26
      modules/core/test/test_mat.cpp
  16. 4
      modules/cudaoptflow/perf/perf_optflow.cpp
  17. 15
      modules/cudaoptflow/src/cuda/tvl1flow.cu
  18. 18
      modules/cudaoptflow/src/tvl1flow.cpp
  19. BIN
      modules/highgui/src/files_Qt/Milky/48/1.png
  20. BIN
      modules/highgui/src/files_Qt/Milky/48/10.png
  21. BIN
      modules/highgui/src/files_Qt/Milky/48/11.png
  22. BIN
      modules/highgui/src/files_Qt/Milky/48/12.png
  23. BIN
      modules/highgui/src/files_Qt/Milky/48/13.png
  24. BIN
      modules/highgui/src/files_Qt/Milky/48/14.png
  25. BIN
      modules/highgui/src/files_Qt/Milky/48/16.png
  26. BIN
      modules/highgui/src/files_Qt/Milky/48/17.png
  27. BIN
      modules/highgui/src/files_Qt/Milky/48/18.png
  28. BIN
      modules/highgui/src/files_Qt/Milky/48/19.png
  29. BIN
      modules/highgui/src/files_Qt/Milky/48/2.png
  30. BIN
      modules/highgui/src/files_Qt/Milky/48/20.png
  31. BIN
      modules/highgui/src/files_Qt/Milky/48/21.png
  32. BIN
      modules/highgui/src/files_Qt/Milky/48/22.png
  33. BIN
      modules/highgui/src/files_Qt/Milky/48/23.png
  34. BIN
      modules/highgui/src/files_Qt/Milky/48/24.png
  35. BIN
      modules/highgui/src/files_Qt/Milky/48/25.png
  36. BIN
      modules/highgui/src/files_Qt/Milky/48/26.png
  37. BIN
      modules/highgui/src/files_Qt/Milky/48/27.png
  38. BIN
      modules/highgui/src/files_Qt/Milky/48/28.png
  39. BIN
      modules/highgui/src/files_Qt/Milky/48/29.png
  40. BIN
      modules/highgui/src/files_Qt/Milky/48/3.png
  41. BIN
      modules/highgui/src/files_Qt/Milky/48/30.png
  42. BIN
      modules/highgui/src/files_Qt/Milky/48/31.png
  43. BIN
      modules/highgui/src/files_Qt/Milky/48/32.png
  44. BIN
      modules/highgui/src/files_Qt/Milky/48/33.png
  45. BIN
      modules/highgui/src/files_Qt/Milky/48/34.png
  46. BIN
      modules/highgui/src/files_Qt/Milky/48/35.png
  47. BIN
      modules/highgui/src/files_Qt/Milky/48/37.png
  48. BIN
      modules/highgui/src/files_Qt/Milky/48/38.png
  49. BIN
      modules/highgui/src/files_Qt/Milky/48/39.png
  50. BIN
      modules/highgui/src/files_Qt/Milky/48/4.png
  51. BIN
      modules/highgui/src/files_Qt/Milky/48/40.png
  52. BIN
      modules/highgui/src/files_Qt/Milky/48/41.png
  53. BIN
      modules/highgui/src/files_Qt/Milky/48/42.png
  54. BIN
      modules/highgui/src/files_Qt/Milky/48/43.png
  55. BIN
      modules/highgui/src/files_Qt/Milky/48/44.png
  56. BIN
      modules/highgui/src/files_Qt/Milky/48/45.png
  57. BIN
      modules/highgui/src/files_Qt/Milky/48/5.png
  58. BIN
      modules/highgui/src/files_Qt/Milky/48/6.png
  59. BIN
      modules/highgui/src/files_Qt/Milky/48/7.png
  60. BIN
      modules/highgui/src/files_Qt/Milky/48/9.png
  61. BIN
      modules/highgui/src/files_Qt/Milky/64/1.png
  62. BIN
      modules/highgui/src/files_Qt/Milky/64/10.png
  63. BIN
      modules/highgui/src/files_Qt/Milky/64/100.png
  64. BIN
      modules/highgui/src/files_Qt/Milky/64/11.png
  65. BIN
      modules/highgui/src/files_Qt/Milky/64/12.png
  66. BIN
      modules/highgui/src/files_Qt/Milky/64/126.png
  67. BIN
      modules/highgui/src/files_Qt/Milky/64/13.png
  68. BIN
      modules/highgui/src/files_Qt/Milky/64/14.png
  69. BIN
      modules/highgui/src/files_Qt/Milky/64/15.png
  70. BIN
      modules/highgui/src/files_Qt/Milky/64/16.png
  71. BIN
      modules/highgui/src/files_Qt/Milky/64/17.png
  72. BIN
      modules/highgui/src/files_Qt/Milky/64/18.png
  73. BIN
      modules/highgui/src/files_Qt/Milky/64/19.png
  74. BIN
      modules/highgui/src/files_Qt/Milky/64/2.png
  75. BIN
      modules/highgui/src/files_Qt/Milky/64/21.png
  76. BIN
      modules/highgui/src/files_Qt/Milky/64/22.png
  77. BIN
      modules/highgui/src/files_Qt/Milky/64/23.png
  78. BIN
      modules/highgui/src/files_Qt/Milky/64/24.png
  79. BIN
      modules/highgui/src/files_Qt/Milky/64/25.png
  80. BIN
      modules/highgui/src/files_Qt/Milky/64/26.png
  81. BIN
      modules/highgui/src/files_Qt/Milky/64/27.png
  82. BIN
      modules/highgui/src/files_Qt/Milky/64/28.png
  83. BIN
      modules/highgui/src/files_Qt/Milky/64/29.png
  84. BIN
      modules/highgui/src/files_Qt/Milky/64/30.png
  85. BIN
      modules/highgui/src/files_Qt/Milky/64/31.png
  86. BIN
      modules/highgui/src/files_Qt/Milky/64/32.png
  87. BIN
      modules/highgui/src/files_Qt/Milky/64/33.png
  88. BIN
      modules/highgui/src/files_Qt/Milky/64/34.png
  89. BIN
      modules/highgui/src/files_Qt/Milky/64/35.png
  90. BIN
      modules/highgui/src/files_Qt/Milky/64/36.png
  91. BIN
      modules/highgui/src/files_Qt/Milky/64/37.png
  92. BIN
      modules/highgui/src/files_Qt/Milky/64/38.png
  93. BIN
      modules/highgui/src/files_Qt/Milky/64/39.png
  94. BIN
      modules/highgui/src/files_Qt/Milky/64/4.png
  95. BIN
      modules/highgui/src/files_Qt/Milky/64/40.png
  96. BIN
      modules/highgui/src/files_Qt/Milky/64/41.png
  97. BIN
      modules/highgui/src/files_Qt/Milky/64/42.png
  98. BIN
      modules/highgui/src/files_Qt/Milky/64/43.png
  99. BIN
      modules/highgui/src/files_Qt/Milky/64/44.png
  100. BIN
      modules/highgui/src/files_Qt/Milky/64/45.png
  101. Some files were not shown because too many files have changed in this diff Show More

@ -17,7 +17,7 @@ check_include_file(string.h HAVE_STRING_H)
check_include_file(sys/types.h HAVE_SYS_TYPES_H) check_include_file(sys/types.h HAVE_SYS_TYPES_H)
check_include_file(unistd.h HAVE_UNISTD_H) check_include_file(unistd.h HAVE_UNISTD_H)
if(WIN32) if(WIN32 AND NOT HAVE_WINRT)
set(USE_WIN32_FILEIO 1) set(USE_WIN32_FILEIO 1)
endif() endif()
@ -79,14 +79,12 @@ set(lib_srcs
"${CMAKE_CURRENT_BINARY_DIR}/tif_config.h" "${CMAKE_CURRENT_BINARY_DIR}/tif_config.h"
) )
if(UNIX) if(WIN32 AND NOT HAVE_WINRT)
list(APPEND lib_srcs tif_win32.c)
else()
list(APPEND lib_srcs tif_unix.c) list(APPEND lib_srcs tif_unix.c)
endif() endif()
if(WIN32)
list(APPEND lib_srcs tif_win32.c)
endif(WIN32)
ocv_warnings_disable(CMAKE_C_FLAGS -Wno-unused-but-set-variable -Wmissing-prototypes -Wmissing-declarations -Wundef -Wunused -Wsign-compare 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) -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_C_FLAGS -Wunused-parameter) # clang

@ -36,6 +36,9 @@ endif()
if (HAVE_WINRT) if (HAVE_WINRT)
add_definitions(/DWINVER=0x0602 /DNTDDI_VERSION=NTDDI_WIN8 /D_WIN32_WINNT=0x0602) add_definitions(/DWINVER=0x0602 /DNTDDI_VERSION=NTDDI_WIN8 /D_WIN32_WINNT=0x0602)
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /appcontainer")
set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} /appcontainer")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /appcontainer")
endif() endif()
if(NOT BUILD_SHARED_LIBS AND BUILD_WITH_STATIC_CRT) if(NOT BUILD_SHARED_LIBS AND BUILD_WITH_STATIC_CRT)

Binary file not shown.

Before

Width:  |  Height:  |  Size: 31 KiB

After

Width:  |  Height:  |  Size: 24 KiB

@ -143,7 +143,7 @@ Although *Mat* works really well as an image container, it is also a general mat
You cannot initialize the matrix values with this construction. It will only reallocate its matrix data memory if the new size will not fit into the old one. You cannot initialize the matrix values with this construction. It will only reallocate its matrix data memory if the new size will not fit into the old one.
+ MATLAB style initializer: :basicstructures:`zeros() <mat-zeros>`, :basicstructures:`ones() <mat-ones>`, ::basicstructures:`eyes() <mat-eye>`. Specify size and data type to use: + MATLAB style initializer: :basicstructures:`zeros() <mat-zeros>`, :basicstructures:`ones() <mat-ones>`, :basicstructures:`eye() <mat-eye>`. Specify size and data type to use:
.. literalinclude:: ../../../../samples/cpp/tutorial_code/core/mat_the_basic_image_container/mat_the_basic_image_container.cpp .. literalinclude:: ../../../../samples/cpp/tutorial_code/core/mat_the_basic_image_container/mat_the_basic_image_container.cpp
:language: cpp :language: cpp

@ -1,44 +0,0 @@
/*M///////////////////////////////////////////////////////////////////////////////////////
//
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
//
// By downloading, copying, installing or using the software you agree to this license.
// If you do not agree to this license, do not download, install,
// copy or use the software.
//
//
// Intel License Agreement
// For Open Source Computer Vision Library
//
// Copyright (C) 2000, Intel Corporation, all rights reserved.
// Third party copyrights are property of their respective owners.
//
// Redistribution and use in source and binary forms, with or without modification,
// are permitted provided that the following conditions are met:
//
// * Redistribution's of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
//
// * Redistribution's in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
//
// * The name of Intel Corporation may not be used to endorse or promote products
// derived from this software without specific prior written permission.
//
// This software is provided by the copyright holders and contributors "as is" and
// any express or implied warranties, including, but not limited to, the implied
// warranties of merchantability and fitness for a particular purpose are disclaimed.
// In no event shall the Intel Corporation or contributors be liable for any direct,
// indirect, incidental, special, exemplary, or consequential damages
// (including, but not limited to, procurement of substitute goods or services;
// loss of use, data, or profits; or business interruption) however caused
// and on any theory of liability, whether in contract, strict liability,
// or tort (including negligence or otherwise) arising in any way out of
// the use of this software, even if advised of the possibility of such damage.
//
//M*/
#include "precomp.hpp"
/* End of file. */

@ -628,6 +628,7 @@ void RetinaImpl::_init(const cv::Size inputSz, const bool colorMode, int colorSa
delete _retinaFilter; delete _retinaFilter;
_retinaFilter = new RetinaFilter(inputSz.height, inputSz.width, colorMode, colorSamplingMethod, useRetinaLogSampling, reductionFactor, samplingStrenght); _retinaFilter = new RetinaFilter(inputSz.height, inputSz.width, colorMode, colorSamplingMethod, useRetinaLogSampling, reductionFactor, samplingStrenght);
_retinaParameters.OPLandIplParvo.colorMode = colorMode;
// prepare the default parameter XML file with default setup // prepare the default parameter XML file with default setup
setup(_retinaParameters); setup(_retinaParameters);

@ -1 +0,0 @@
#include "test_precomp.hpp"

@ -670,6 +670,10 @@ public:
//! reconstructs the original vector from the projection //! reconstructs the original vector from the projection
void backProject(InputArray vec, OutputArray result) const; void backProject(InputArray vec, OutputArray result) const;
//! write and load PCA matrix
void write(FileStorage& fs ) const;
void read(const FileNode& fs);
Mat eigenvectors; //!< eigenvectors of the covariation matrix Mat eigenvectors; //!< eigenvectors of the covariation matrix
Mat eigenvalues; //!< eigenvalues of the covariation matrix Mat eigenvalues; //!< eigenvalues of the covariation matrix
Mat mean; //!< mean value subtracted before the projection and added after the back projection Mat mean; //!< mean value subtracted before the projection and added after the back projection

@ -83,8 +83,8 @@ PERF_TEST_P(Size_MatType, meanStdDev_mask, TYPICAL_MATS)
TEST_CYCLE() meanStdDev(src, mean, dev, mask); TEST_CYCLE() meanStdDev(src, mean, dev, mask);
SANITY_CHECK(mean, 1e-6); SANITY_CHECK(mean, 1e-5);
SANITY_CHECK(dev, 1e-6); SANITY_CHECK(dev, 1e-5);
} }
PERF_TEST_P(Size_MatType, countNonZero, testing::Combine( testing::Values( TYPICAL_MAT_SIZES ), testing::Values( CV_8UC1, CV_8SC1, CV_16UC1, CV_16SC1, CV_32SC1, CV_32FC1, CV_64FC1 ) )) PERF_TEST_P(Size_MatType, countNonZero, testing::Combine( testing::Values( TYPICAL_MAT_SIZES ), testing::Values( CV_8UC1, CV_8SC1, CV_16UC1, CV_16SC1, CV_32SC1, CV_32FC1, CV_64FC1 ) ))

@ -2153,10 +2153,30 @@ cmp_(const T* src1, size_t step1, const T* src2, size_t step2,
} }
} }
#if ARITHM_USE_IPP
inline static IppCmpOp convert_cmp(int _cmpop)
{
return _cmpop == CMP_EQ ? ippCmpEq :
_cmpop == CMP_GT ? ippCmpGreater :
_cmpop == CMP_GE ? ippCmpGreaterEq :
_cmpop == CMP_LT ? ippCmpLess :
_cmpop == CMP_LE ? ippCmpLessEq :
(IppCmpOp)-1;
}
#endif
static void cmp8u(const uchar* src1, size_t step1, const uchar* src2, size_t step2, static void cmp8u(const uchar* src1, size_t step1, const uchar* src2, size_t step2,
uchar* dst, size_t step, Size size, void* _cmpop) uchar* dst, size_t step, Size size, void* _cmpop)
{ {
#if ARITHM_USE_IPP
IppCmpOp op = convert_cmp(*(int *)_cmpop);
if( op >= 0 )
{
fixSteps(size, sizeof(dst[0]), step1, step2, step);
if( ippiCompare_8u_C1R(src1, (int)step1, src2, (int)step2, dst, (int)step, (IppiSize&)size, op) >= 0 )
return;
}
#endif
//vz optimized cmp_(src1, step1, src2, step2, dst, step, size, *(int*)_cmpop); //vz optimized cmp_(src1, step1, src2, step2, dst, step, size, *(int*)_cmpop);
int code = *(int*)_cmpop; int code = *(int*)_cmpop;
step1 /= sizeof(src1[0]); step1 /= sizeof(src1[0]);
@ -2231,12 +2251,30 @@ static void cmp8s(const schar* src1, size_t step1, const schar* src2, size_t ste
static void cmp16u(const ushort* src1, size_t step1, const ushort* src2, size_t step2, static void cmp16u(const ushort* src1, size_t step1, const ushort* src2, size_t step2,
uchar* dst, size_t step, Size size, void* _cmpop) uchar* dst, size_t step, Size size, void* _cmpop)
{ {
#if ARITHM_USE_IPP
IppCmpOp op = convert_cmp(*(int *)_cmpop);
if( op >= 0 )
{
fixSteps(size, sizeof(dst[0]), step1, step2, step);
if( ippiCompare_16u_C1R(src1, (int)step1, src2, (int)step2, dst, (int)step, (IppiSize&)size, op) >= 0 )
return;
}
#endif
cmp_(src1, step1, src2, step2, dst, step, size, *(int*)_cmpop); cmp_(src1, step1, src2, step2, dst, step, size, *(int*)_cmpop);
} }
static void cmp16s(const short* src1, size_t step1, const short* src2, size_t step2, static void cmp16s(const short* src1, size_t step1, const short* src2, size_t step2,
uchar* dst, size_t step, Size size, void* _cmpop) uchar* dst, size_t step, Size size, void* _cmpop)
{ {
#if ARITHM_USE_IPP
IppCmpOp op = convert_cmp(*(int *)_cmpop);
if( op > 0 )
{
fixSteps(size, sizeof(dst[0]), step1, step2, step);
if( ippiCompare_16s_C1R(src1, (int)step1, src2, (int)step2, dst, (int)step, (IppiSize&)size, op) >= 0 )
return;
}
#endif
//vz optimized cmp_(src1, step1, src2, step2, dst, step, size, *(int*)_cmpop); //vz optimized cmp_(src1, step1, src2, step2, dst, step, size, *(int*)_cmpop);
int code = *(int*)_cmpop; int code = *(int*)_cmpop;
@ -2334,6 +2372,15 @@ static void cmp32s(const int* src1, size_t step1, const int* src2, size_t step2,
static void cmp32f(const float* src1, size_t step1, const float* src2, size_t step2, static void cmp32f(const float* src1, size_t step1, const float* src2, size_t step2,
uchar* dst, size_t step, Size size, void* _cmpop) uchar* dst, size_t step, Size size, void* _cmpop)
{ {
#if ARITHM_USE_IPP
IppCmpOp op = convert_cmp(*(int *)_cmpop);
if( op >= 0 )
{
fixSteps(size, sizeof(dst[0]), step1, step2, step);
if( ippiCompare_32f_C1R(src1, (int)step1, src2, (int)step2, dst, (int)step, (IppiSize&)size, op) >= 0 )
return;
}
#endif
cmp_(src1, step1, src2, step2, dst, step, size, *(int*)_cmpop); cmp_(src1, step1, src2, step2, dst, step, size, *(int*)_cmpop);
} }

@ -50,6 +50,13 @@ namespace cv
# pragma warning(disable: 4748) # pragma warning(disable: 4748)
#endif #endif
#if defined HAVE_IPP && IPP_VERSION_MAJOR >= 7
#define USE_IPP_DFT 1
#else
#undef USE_IPP_DFT
#endif
/****************************************************************************************\ /****************************************************************************************\
Discrete Fourier Transform Discrete Fourier Transform
\****************************************************************************************/ \****************************************************************************************/
@ -455,7 +462,7 @@ template<> struct DFT_VecR4<float>
#endif #endif
#ifdef HAVE_IPP #ifdef USE_IPP_DFT
static void ippsDFTFwd_CToC( const Complex<float>* src, Complex<float>* dst, static void ippsDFTFwd_CToC( const Complex<float>* src, Complex<float>* dst,
const void* spec, uchar* buf) const void* spec, uchar* buf)
{ {
@ -517,7 +524,7 @@ DFT( const Complex<T>* src, Complex<T>* dst, int n,
int nf, const int* factors, const int* itab, int nf, const int* factors, const int* itab,
const Complex<T>* wave, int tab_size, const Complex<T>* wave, int tab_size,
const void* const void*
#ifdef HAVE_IPP #ifdef USE_IPP_DFT
spec spec
#endif #endif
, Complex<T>* buf, , Complex<T>* buf,
@ -537,7 +544,7 @@ DFT( const Complex<T>* src, Complex<T>* dst, int n,
T scale = (T)_scale; T scale = (T)_scale;
int tab_step; int tab_step;
#ifdef HAVE_IPP #ifdef USE_IPP_DFT
if( spec ) if( spec )
{ {
if( !inv ) if( !inv )
@ -957,7 +964,7 @@ DFT( const Complex<T>* src, Complex<T>* dst, int n,
template<typename T> static void template<typename T> static void
RealDFT( const T* src, T* dst, int n, int nf, int* factors, const int* itab, RealDFT( const T* src, T* dst, int n, int nf, int* factors, const int* itab,
const Complex<T>* wave, int tab_size, const void* const Complex<T>* wave, int tab_size, const void*
#ifdef HAVE_IPP #ifdef USE_IPP_DFT
spec spec
#endif #endif
, ,
@ -968,11 +975,18 @@ RealDFT( const T* src, T* dst, int n, int nf, int* factors, const int* itab,
int j, n2 = n >> 1; int j, n2 = n >> 1;
dst += complex_output; dst += complex_output;
#ifdef HAVE_IPP #ifdef USE_IPP_DFT
if( spec ) if( spec )
{ {
ippsDFTFwd_RToPack( src, dst, spec, (uchar*)buf ); ippsDFTFwd_RToPack( src, dst, spec, (uchar*)buf );
goto finalize; if( complex_output )
{
dst[-1] = dst[0];
dst[0] = 0;
if( (n & 1) == 0 )
dst[n] = 0;
}
return;
} }
#endif #endif
assert( tab_size == n ); assert( tab_size == n );
@ -1056,15 +1070,11 @@ RealDFT( const T* src, T* dst, int n, int nf, int* factors, const int* itab,
} }
} }
#ifdef HAVE_IPP
finalize:
#endif
if( complex_output && (n & 1) == 0 ) if( complex_output && (n & 1) == 0 )
{ {
dst[-1] = dst[0]; dst[-1] = dst[0];
dst[0] = 0; dst[0] = 0;
if( (n & 1) == 0 ) dst[n] = 0;
dst[n] = 0;
} }
} }
@ -1076,7 +1086,7 @@ template<typename T> static void
CCSIDFT( const T* src, T* dst, int n, int nf, int* factors, const int* itab, CCSIDFT( const T* src, T* dst, int n, int nf, int* factors, const int* itab,
const Complex<T>* wave, int tab_size, const Complex<T>* wave, int tab_size,
const void* const void*
#ifdef HAVE_IPP #ifdef USE_IPP_DFT
spec spec
#endif #endif
, Complex<T>* buf, , Complex<T>* buf,
@ -1097,7 +1107,7 @@ CCSIDFT( const T* src, T* dst, int n, int nf, int* factors, const int* itab,
((T*)src)[1] = src[0]; ((T*)src)[1] = src[0];
src++; src++;
} }
#ifdef HAVE_IPP #ifdef USE_IPP_DFT
if( spec ) if( spec )
{ {
ippsDFTInv_PackToR( src, dst, spec, (uchar*)buf ); ippsDFTInv_PackToR( src, dst, spec, (uchar*)buf );
@ -1225,7 +1235,7 @@ CCSIDFT( const T* src, T* dst, int n, int nf, int* factors, const int* itab,
} }
} }
#ifdef HAVE_IPP #ifdef USE_IPP_DFT
finalize: finalize:
#endif #endif
if( complex_input ) if( complex_input )
@ -1458,7 +1468,7 @@ static void CCSIDFT_64f( const double* src, double* dst, int n, int nf, int* fac
} }
#ifdef HAVE_IPP #ifdef USE_IPP_DFT
typedef IppStatus (CV_STDCALL* IppDFTGetSizeFunc)(int, int, IppHintAlgorithm, int*, int*, int*); typedef IppStatus (CV_STDCALL* IppDFTGetSizeFunc)(int, int, IppHintAlgorithm, int*, int*, int*);
typedef IppStatus (CV_STDCALL* IppDFTInitFunc)(int, int, IppHintAlgorithm, void*, uchar*); typedef IppStatus (CV_STDCALL* IppDFTInitFunc)(int, int, IppHintAlgorithm, void*, uchar*);
#endif #endif
@ -1486,7 +1496,7 @@ void cv::dft( InputArray _src0, OutputArray _dst, int flags, int nonzero_rows )
int elem_size = (int)src.elemSize1(), complex_elem_size = elem_size*2; int elem_size = (int)src.elemSize1(), complex_elem_size = elem_size*2;
int factors[34]; int factors[34];
bool inplace_transform = false; bool inplace_transform = false;
#ifdef HAVE_IPP #ifdef USE_IPP_DFT
AutoBuffer<uchar> ippbuf; AutoBuffer<uchar> ippbuf;
int ipp_norm_flag = !(flags & DFT_SCALE) ? 8 : inv ? 2 : 1; int ipp_norm_flag = !(flags & DFT_SCALE) ? 8 : inv ? 2 : 1;
#endif #endif
@ -1546,12 +1556,8 @@ void cv::dft( InputArray _src0, OutputArray _dst, int flags, int nonzero_rows )
} }
spec = 0; spec = 0;
#ifdef HAVE_IPP #ifdef USE_IPP_DFT
if( if( len*count >= 64 ) // use IPP DFT if available
#if IPP_VERSION_MAJOR >= 7
depth == CV_32F && // IPP 7.x and 8.0 have bug somewhere in double-precision DFT
#endif
len*count >= 64 ) // use IPP DFT if available
{ {
int specsize=0, initsize=0, worksize=0; int specsize=0, initsize=0, worksize=0;
IppDFTGetSizeFunc getSizeFunc = 0; IppDFTGetSizeFunc getSizeFunc = 0;

@ -91,6 +91,7 @@ namespace
if(dir->handle == INVALID_HANDLE_VALUE) if(dir->handle == INVALID_HANDLE_VALUE)
{ {
/*closedir will do all cleanup*/ /*closedir will do all cleanup*/
delete dir;
return 0; return 0;
} }
return dir; return dir;
@ -140,6 +141,7 @@ static bool isDir(const cv::String& path, DIR* dir)
{ {
#if defined WIN32 || defined _WIN32 || defined WINCE #if defined WIN32 || defined _WIN32 || defined WINCE
DWORD attributes; DWORD attributes;
BOOL status = TRUE;
if (dir) if (dir)
attributes = dir->data.dwFileAttributes; attributes = dir->data.dwFileAttributes;
else else
@ -149,14 +151,14 @@ static bool isDir(const cv::String& path, DIR* dir)
wchar_t wpath[MAX_PATH]; wchar_t wpath[MAX_PATH];
size_t copied = mbstowcs(wpath, path.c_str(), MAX_PATH); size_t copied = mbstowcs(wpath, path.c_str(), MAX_PATH);
CV_Assert((copied != MAX_PATH) && (copied != (size_t)-1)); CV_Assert((copied != MAX_PATH) && (copied != (size_t)-1));
::GetFileAttributesExW(wpath, GetFileExInfoStandard, &all_attrs); status = ::GetFileAttributesExW(wpath, GetFileExInfoStandard, &all_attrs);
#else #else
::GetFileAttributesExA(path.c_str(), GetFileExInfoStandard, &all_attrs); status = ::GetFileAttributesExA(path.c_str(), GetFileExInfoStandard, &all_attrs);
#endif #endif
attributes = all_attrs.dwFileAttributes; attributes = all_attrs.dwFileAttributes;
} }
return (attributes != INVALID_FILE_ATTRIBUTES) && ((attributes & FILE_ATTRIBUTE_DIRECTORY) != 0); return status && ((attributes & FILE_ATTRIBUTE_DIRECTORY) != 0);
#else #else
(void)dir; (void)dir;
struct stat stat_buf; struct stat stat_buf;

@ -2911,6 +2911,27 @@ PCA& PCA::operator()(InputArray _data, InputArray __mean, int flags, int maxComp
return *this; return *this;
} }
void PCA::write(FileStorage& fs ) const
{
CV_Assert( fs.isOpened() );
fs << "name" << "PCA";
fs << "vectors" << eigenvectors;
fs << "values" << eigenvalues;
fs << "mean" << mean;
}
void PCA::read(const FileNode& fs)
{
CV_Assert( !fs.empty() );
String name = (String)fs["name"];
CV_Assert( name == "PCA" );
cv::read(fs["vectors"], eigenvectors);
cv::read(fs["values"], eigenvalues);
cv::read(fs["mean"], mean);
}
template <typename T> template <typename T>
int computeCumulativeEnergy(const Mat& eigenvalues, double retainedVariance) int computeCumulativeEnergy(const Mat& eigenvalues, double retainedVariance)
{ {

@ -700,6 +700,99 @@ void cv::meanStdDev( InputArray _src, OutputArray _mean, OutputArray _sdv, Input
CV_Assert( mask.empty() || mask.type() == CV_8U ); CV_Assert( mask.empty() || mask.type() == CV_8U );
int k, cn = src.channels(), depth = src.depth(); int k, cn = src.channels(), depth = src.depth();
#if defined (HAVE_IPP) && (IPP_VERSION_MAJOR >= 7)
size_t total_size = src.total();
int rows = src.size[0], cols = (int)(total_size/rows);
if( src.dims == 2 || (src.isContinuous() && mask.isContinuous() && cols > 0 && (size_t)rows*cols == total_size) )
{
Ipp64f mean_temp[3];
Ipp64f stddev_temp[3];
Ipp64f *pmean = &mean_temp[0];
Ipp64f *pstddev = &stddev_temp[0];
Mat mean, stddev;
int dcn_mean = -1;
if( _mean.needed() )
{
if( !_mean.fixedSize() )
_mean.create(cn, 1, CV_64F, -1, true);
mean = _mean.getMat();
dcn_mean = (int)mean.total();
pmean = (Ipp64f *)mean.data;
}
int dcn_stddev = -1;
if( _sdv.needed() )
{
if( !_sdv.fixedSize() )
_sdv.create(cn, 1, CV_64F, -1, true);
stddev = _sdv.getMat();
dcn_stddev = (int)stddev.total();
pstddev = (Ipp64f *)stddev.data;
}
for( int k = cn; k < dcn_mean; k++ )
pmean[k] = 0;
for( int k = cn; k < dcn_stddev; k++ )
pstddev[k] = 0;
IppiSize sz = { cols, rows };
int type = src.type();
if( !mask.empty() )
{
typedef IppStatus (CV_STDCALL* ippiMaskMeanStdDevFuncC1)(const void *, int, void *, int, IppiSize, Ipp64f *, Ipp64f *);
ippiMaskMeanStdDevFuncC1 ippFuncC1 =
type == CV_8UC1 ? (ippiMaskMeanStdDevFuncC1)ippiMean_StdDev_8u_C1MR :
type == CV_16UC1 ? (ippiMaskMeanStdDevFuncC1)ippiMean_StdDev_16u_C1MR :
type == CV_32FC1 ? (ippiMaskMeanStdDevFuncC1)ippiMean_StdDev_32f_C1MR :
0;
if( ippFuncC1 )
{
if( ippFuncC1(src.data, (int)src.step[0], mask.data, (int)mask.step[0], sz, pmean, pstddev) >= 0 )
return;
}
typedef IppStatus (CV_STDCALL* ippiMaskMeanStdDevFuncC3)(const void *, int, void *, int, IppiSize, int, Ipp64f *, Ipp64f *);
ippiMaskMeanStdDevFuncC3 ippFuncC3 =
type == CV_8UC3 ? (ippiMaskMeanStdDevFuncC3)ippiMean_StdDev_8u_C3CMR :
type == CV_16UC3 ? (ippiMaskMeanStdDevFuncC3)ippiMean_StdDev_16u_C3CMR :
type == CV_32FC3 ? (ippiMaskMeanStdDevFuncC3)ippiMean_StdDev_32f_C3CMR :
0;
if( ippFuncC3 )
{
if( ippFuncC3(src.data, (int)src.step[0], mask.data, (int)mask.step[0], sz, 1, &pmean[0], &pstddev[0]) >= 0 &&
ippFuncC3(src.data, (int)src.step[0], mask.data, (int)mask.step[0], sz, 2, &pmean[1], &pstddev[1]) >= 0 &&
ippFuncC3(src.data, (int)src.step[0], mask.data, (int)mask.step[0], sz, 3, &pmean[2], &pstddev[2]) >= 0 )
return;
}
}
else
{
typedef IppStatus (CV_STDCALL* ippiMeanStdDevFuncC1)(const void *, int, IppiSize, Ipp64f *, Ipp64f *);
ippiMeanStdDevFuncC1 ippFuncC1 =
type == CV_8UC1 ? (ippiMeanStdDevFuncC1)ippiMean_StdDev_8u_C1R :
type == CV_16UC1 ? (ippiMeanStdDevFuncC1)ippiMean_StdDev_16u_C1R :
//type == CV_32FC1 ? (ippiMeanStdDevFuncC1)ippiMean_StdDev_32f_C1R ://Aug 2013: bug in IPP 7.1, 8.0
0;
if( ippFuncC1 )
{
if( ippFuncC1(src.data, (int)src.step[0], sz, pmean, pstddev) >= 0 )
return;
}
typedef IppStatus (CV_STDCALL* ippiMeanStdDevFuncC3)(const void *, int, IppiSize, int, Ipp64f *, Ipp64f *);
ippiMeanStdDevFuncC3 ippFuncC3 =
type == CV_8UC3 ? (ippiMeanStdDevFuncC3)ippiMean_StdDev_8u_C3CR :
type == CV_16UC3 ? (ippiMeanStdDevFuncC3)ippiMean_StdDev_16u_C3CR :
type == CV_32FC3 ? (ippiMeanStdDevFuncC3)ippiMean_StdDev_32f_C3CR :
0;
if( ippFuncC3 )
{
if( ippFuncC3(src.data, (int)src.step[0], sz, 1, &pmean[0], &pstddev[0]) >= 0 &&
ippFuncC3(src.data, (int)src.step[0], sz, 2, &pmean[1], &pstddev[1]) >= 0 &&
ippFuncC3(src.data, (int)src.step[0], sz, 3, &pmean[2], &pstddev[2]) >= 0 )
return;
}
}
}
#endif
SumSqrFunc func = getSumSqrTab(depth); SumSqrFunc func = getSumSqrTab(depth);
CV_Assert( func != 0 ); CV_Assert( func != 0 );
@ -919,6 +1012,83 @@ void cv::minMaxIdx(InputArray _src, double* minVal,
CV_Assert( (cn == 1 && (mask.empty() || mask.type() == CV_8U)) || CV_Assert( (cn == 1 && (mask.empty() || mask.type() == CV_8U)) ||
(cn >= 1 && mask.empty() && !minIdx && !maxIdx) ); (cn >= 1 && mask.empty() && !minIdx && !maxIdx) );
#if defined (HAVE_IPP) && (IPP_VERSION_MAJOR >= 7)
size_t total_size = src.total();
int rows = src.size[0], cols = (int)(total_size/rows);
if( cn == 1 && ( src.dims == 2 || (src.isContinuous() && mask.isContinuous() && cols > 0 && (size_t)rows*cols == total_size) ) )
{
IppiSize sz = { cols, rows };
int type = src.type();
if( !mask.empty() )
{
typedef IppStatus (CV_STDCALL* ippiMaskMinMaxIndxFuncC1)(const void *, int, const void *, int, IppiSize, Ipp32f *, Ipp32f *, IppiPoint *, IppiPoint *);
ippiMaskMinMaxIndxFuncC1 ippFuncC1 =
type == CV_8UC1 ? (ippiMaskMinMaxIndxFuncC1)ippiMinMaxIndx_8u_C1MR :
type == CV_16UC1 ? (ippiMaskMinMaxIndxFuncC1)ippiMinMaxIndx_16u_C1MR :
type == CV_32FC1 ? (ippiMaskMinMaxIndxFuncC1)ippiMinMaxIndx_32f_C1MR :
0;
if( ippFuncC1 )
{
Ipp32f min, max;
IppiPoint minp, maxp;
if( ippFuncC1(src.data, (int)src.step[0], mask.data, (int)mask.step[0], sz, &min, &max, &minp, &maxp) >= 0 )
{
if( minVal )
*minVal = (double)min;
if( maxVal )
*maxVal = (double)max;
if( !minp.x && !minp.y && !maxp.x && !maxp.y && !mask.data[0] )
minp.x = maxp.x = -1;
if( minIdx )
{
size_t minidx = minp.y * cols + minp.x + 1;
ofs2idx(src, minidx, minIdx);
}
if( maxIdx )
{
size_t maxidx = maxp.y * cols + maxp.x + 1;
ofs2idx(src, maxidx, maxIdx);
}
return;
}
}
}
else
{
typedef IppStatus (CV_STDCALL* ippiMinMaxIndxFuncC1)(const void *, int, IppiSize, Ipp32f *, Ipp32f *, IppiPoint *, IppiPoint *);
ippiMinMaxIndxFuncC1 ippFuncC1 =
type == CV_8UC1 ? (ippiMinMaxIndxFuncC1)ippiMinMaxIndx_8u_C1R :
type == CV_16UC1 ? (ippiMinMaxIndxFuncC1)ippiMinMaxIndx_16u_C1R :
type == CV_32FC1 ? (ippiMinMaxIndxFuncC1)ippiMinMaxIndx_32f_C1R :
0;
if( ippFuncC1 )
{
Ipp32f min, max;
IppiPoint minp, maxp;
if( ippFuncC1(src.data, (int)src.step[0], sz, &min, &max, &minp, &maxp) >= 0 )
{
if( minVal )
*minVal = (double)min;
if( maxVal )
*maxVal = (double)max;
if( minIdx )
{
size_t minidx = minp.y * cols + minp.x + 1;
ofs2idx(src, minidx, minIdx);
}
if( maxIdx )
{
size_t maxidx = maxp.y * cols + maxp.x + 1;
ofs2idx(src, maxidx, maxIdx);
}
return;
}
}
}
}
#endif
MinMaxIdxFunc func = getMinmaxTab(depth); MinMaxIdxFunc func = getMinmaxTab(depth);
CV_Assert( func != 0 ); CV_Assert( func != 0 );
@ -1443,6 +1613,147 @@ double cv::norm( InputArray _src, int normType, InputArray _mask )
CV_Assert( normType == NORM_INF || normType == NORM_L1 || normType == NORM_L2 || normType == NORM_L2SQR || CV_Assert( normType == NORM_INF || normType == NORM_L1 || normType == NORM_L2 || normType == NORM_L2SQR ||
((normType == NORM_HAMMING || normType == NORM_HAMMING2) && src.type() == CV_8U) ); ((normType == NORM_HAMMING || normType == NORM_HAMMING2) && src.type() == CV_8U) );
#if defined (HAVE_IPP) && (IPP_VERSION_MAJOR >= 7)
size_t total_size = src.total();
int rows = src.size[0], cols = (int)(total_size/rows);
if( src.dims == 2 || (src.isContinuous() && mask.isContinuous() && cols > 0 && (size_t)rows*cols == total_size)
&& (normType == NORM_INF || normType == NORM_L1 || normType == NORM_L2 || normType == NORM_L2SQR) )
{
IppiSize sz = { cols, rows };
int type = src.type();
if( !mask.empty() )
{
typedef IppStatus (CV_STDCALL* ippiMaskNormFuncC1)(const void *, int, const void *, int, IppiSize, Ipp64f *);
ippiMaskNormFuncC1 ippFuncC1 =
normType == NORM_INF ?
(type == CV_8UC1 ? (ippiMaskNormFuncC1)ippiNorm_Inf_8u_C1MR :
type == CV_8SC1 ? (ippiMaskNormFuncC1)ippiNorm_Inf_8s_C1MR :
type == CV_16UC1 ? (ippiMaskNormFuncC1)ippiNorm_Inf_16u_C1MR :
type == CV_32FC1 ? (ippiMaskNormFuncC1)ippiNorm_Inf_32f_C1MR :
0) :
normType == NORM_L1 ?
(type == CV_8UC1 ? (ippiMaskNormFuncC1)ippiNorm_L1_8u_C1MR :
type == CV_8SC1 ? (ippiMaskNormFuncC1)ippiNorm_L1_8s_C1MR :
type == CV_16UC1 ? (ippiMaskNormFuncC1)ippiNorm_L1_16u_C1MR :
type == CV_32FC1 ? (ippiMaskNormFuncC1)ippiNorm_L1_32f_C1MR :
0) :
normType == NORM_L2 || normType == NORM_L2SQR ?
(type == CV_8UC1 ? (ippiMaskNormFuncC1)ippiNorm_L2_8u_C1MR :
type == CV_8SC1 ? (ippiMaskNormFuncC1)ippiNorm_L2_8s_C1MR :
type == CV_16UC1 ? (ippiMaskNormFuncC1)ippiNorm_L2_16u_C1MR :
type == CV_32FC1 ? (ippiMaskNormFuncC1)ippiNorm_L2_32f_C1MR :
0) : 0;
if( ippFuncC1 )
{
Ipp64f norm;
if( ippFuncC1(src.data, (int)src.step[0], mask.data, (int)mask.step[0], sz, &norm) >= 0 )
{
return normType == NORM_L2SQR ? (double)(norm * norm) : (double)norm;
}
}
typedef IppStatus (CV_STDCALL* ippiMaskNormFuncC3)(const void *, int, const void *, int, IppiSize, int, Ipp64f *);
ippiMaskNormFuncC3 ippFuncC3 =
normType == NORM_INF ?
(type == CV_8UC3 ? (ippiMaskNormFuncC3)ippiNorm_Inf_8u_C3CMR :
type == CV_8SC3 ? (ippiMaskNormFuncC3)ippiNorm_Inf_8s_C3CMR :
type == CV_16UC3 ? (ippiMaskNormFuncC3)ippiNorm_Inf_16u_C3CMR :
type == CV_32FC3 ? (ippiMaskNormFuncC3)ippiNorm_Inf_32f_C3CMR :
0) :
normType == NORM_L1 ?
(type == CV_8UC3 ? (ippiMaskNormFuncC3)ippiNorm_L1_8u_C3CMR :
type == CV_8SC3 ? (ippiMaskNormFuncC3)ippiNorm_L1_8s_C3CMR :
type == CV_16UC3 ? (ippiMaskNormFuncC3)ippiNorm_L1_16u_C3CMR :
type == CV_32FC3 ? (ippiMaskNormFuncC3)ippiNorm_L1_32f_C3CMR :
0) :
normType == NORM_L2 || normType == NORM_L2SQR ?
(type == CV_8UC3 ? (ippiMaskNormFuncC3)ippiNorm_L2_8u_C3CMR :
type == CV_8SC3 ? (ippiMaskNormFuncC3)ippiNorm_L2_8s_C3CMR :
type == CV_16UC3 ? (ippiMaskNormFuncC3)ippiNorm_L2_16u_C3CMR :
type == CV_32FC3 ? (ippiMaskNormFuncC3)ippiNorm_L2_32f_C3CMR :
0) : 0;
if( ippFuncC3 )
{
Ipp64f norm1, norm2, norm3;
if( ippFuncC3(src.data, (int)src.step[0], mask.data, (int)mask.step[0], sz, 1, &norm1) >= 0 &&
ippFuncC3(src.data, (int)src.step[0], mask.data, (int)mask.step[0], sz, 2, &norm2) >= 0 &&
ippFuncC3(src.data, (int)src.step[0], mask.data, (int)mask.step[0], sz, 3, &norm3) >= 0)
{
Ipp64f norm =
normType == NORM_INF ? std::max(std::max(norm1, norm2), norm3) :
normType == NORM_L1 ? norm1 + norm2 + norm3 :
normType == NORM_L2 || normType == NORM_L2SQR ? std::sqrt(norm1 * norm1 + norm2 * norm2 + norm3 * norm3) :
0;
return normType == NORM_L2SQR ? (double)(norm * norm) : (double)norm;
}
}
}
else
{
typedef IppStatus (CV_STDCALL* ippiNormFunc)(const void *, int, IppiSize, Ipp64f *, IppHintAlgorithm hint);
ippiNormFunc ippFunc =
normType == NORM_INF ?
(type == CV_8UC1 ? (ippiNormFunc)ippiNorm_Inf_8u_C1R :
type == CV_8UC3 ? (ippiNormFunc)ippiNorm_Inf_8u_C3R :
type == CV_8UC4 ? (ippiNormFunc)ippiNorm_Inf_8u_C4R :
type == CV_16UC1 ? (ippiNormFunc)ippiNorm_Inf_16u_C1R :
type == CV_16UC3 ? (ippiNormFunc)ippiNorm_Inf_16u_C3R :
type == CV_16UC4 ? (ippiNormFunc)ippiNorm_Inf_16u_C4R :
type == CV_16SC1 ? (ippiNormFunc)ippiNorm_Inf_16s_C1R :
//type == CV_16SC3 ? (ippiNormFunc)ippiNorm_Inf_16s_C3R : //Aug 2013: problem in IPP 7.1, 8.0 : -32768
//type == CV_16SC4 ? (ippiNormFunc)ippiNorm_Inf_16s_C4R : //Aug 2013: problem in IPP 7.1, 8.0 : -32768
type == CV_32FC1 ? (ippiNormFunc)ippiNorm_Inf_32f_C1R :
type == CV_32FC3 ? (ippiNormFunc)ippiNorm_Inf_32f_C3R :
type == CV_32FC4 ? (ippiNormFunc)ippiNorm_Inf_32f_C4R :
0) :
normType == NORM_L1 ?
(type == CV_8UC1 ? (ippiNormFunc)ippiNorm_L1_8u_C1R :
type == CV_8UC3 ? (ippiNormFunc)ippiNorm_L1_8u_C3R :
type == CV_8UC4 ? (ippiNormFunc)ippiNorm_L1_8u_C4R :
type == CV_16UC1 ? (ippiNormFunc)ippiNorm_L1_16u_C1R :
type == CV_16UC3 ? (ippiNormFunc)ippiNorm_L1_16u_C3R :
type == CV_16UC4 ? (ippiNormFunc)ippiNorm_L1_16u_C4R :
type == CV_16SC1 ? (ippiNormFunc)ippiNorm_L1_16s_C1R :
type == CV_16SC3 ? (ippiNormFunc)ippiNorm_L1_16s_C3R :
type == CV_16SC4 ? (ippiNormFunc)ippiNorm_L1_16s_C4R :
type == CV_32FC1 ? (ippiNormFunc)ippiNorm_L1_32f_C1R :
type == CV_32FC3 ? (ippiNormFunc)ippiNorm_L1_32f_C3R :
type == CV_32FC4 ? (ippiNormFunc)ippiNorm_L1_32f_C4R :
0) :
normType == NORM_L2 || normType == NORM_L2SQR ?
(type == CV_8UC1 ? (ippiNormFunc)ippiNorm_L2_8u_C1R :
type == CV_8UC3 ? (ippiNormFunc)ippiNorm_L2_8u_C3R :
type == CV_8UC4 ? (ippiNormFunc)ippiNorm_L2_8u_C4R :
type == CV_16UC1 ? (ippiNormFunc)ippiNorm_L2_16u_C1R :
type == CV_16UC3 ? (ippiNormFunc)ippiNorm_L2_16u_C3R :
type == CV_16UC4 ? (ippiNormFunc)ippiNorm_L2_16u_C4R :
type == CV_16SC1 ? (ippiNormFunc)ippiNorm_L2_16s_C1R :
type == CV_16SC3 ? (ippiNormFunc)ippiNorm_L2_16s_C3R :
type == CV_16SC4 ? (ippiNormFunc)ippiNorm_L2_16s_C4R :
type == CV_32FC1 ? (ippiNormFunc)ippiNorm_L2_32f_C1R :
type == CV_32FC3 ? (ippiNormFunc)ippiNorm_L2_32f_C3R :
type == CV_32FC4 ? (ippiNormFunc)ippiNorm_L2_32f_C4R :
0) : 0;
if( ippFunc )
{
Ipp64f norm_array[4];
if( ippFunc(src.data, (int)src.step[0], sz, norm_array, ippAlgHintAccurate) >= 0 )
{
Ipp64f norm = (normType == NORM_L2 || normType == NORM_L2SQR) ? norm_array[0] * norm_array[0] : norm_array[0];
for( int i = 1; i < cn; i++ )
{
norm =
normType == NORM_INF ? std::max(norm, norm_array[i]) :
normType == NORM_L1 ? norm + norm_array[i] :
normType == NORM_L2 || normType == NORM_L2SQR ? norm + norm_array[i] * norm_array[i] :
0;
}
return normType == NORM_L2 ? (double)std::sqrt(norm) : (double)norm;
}
}
}
}
#endif
if( src.isContinuous() && mask.empty() ) if( src.isContinuous() && mask.empty() )
{ {
size_t len = src.total()*cn; size_t len = src.total()*cn;
@ -1581,7 +1892,84 @@ double cv::norm( InputArray _src, int normType, InputArray _mask )
double cv::norm( InputArray _src1, InputArray _src2, int normType, InputArray _mask ) double cv::norm( InputArray _src1, InputArray _src2, int normType, InputArray _mask )
{ {
if( normType & CV_RELATIVE ) if( normType & CV_RELATIVE )
{
#if defined (HAVE_IPP) && (IPP_VERSION_MAJOR >= 7)
Mat src1 = _src1.getMat(), src2 = _src2.getMat(), mask = _mask.getMat();
CV_Assert( src1.size == src2.size && src1.type() == src2.type() );
normType &= 7;
CV_Assert( normType == NORM_INF || normType == NORM_L1 || normType == NORM_L2 || normType == NORM_L2SQR ||
((normType == NORM_HAMMING || normType == NORM_HAMMING2) && src1.type() == CV_8U) );
size_t total_size = src1.total();
int rows = src1.size[0], cols = (int)(total_size/rows);
if( src1.dims == 2 || (src1.isContinuous() && src2.isContinuous() && mask.isContinuous() && cols > 0 && (size_t)rows*cols == total_size)
&& (normType == NORM_INF || normType == NORM_L1 || normType == NORM_L2 || normType == NORM_L2SQR) )
{
IppiSize sz = { cols, rows };
int type = src1.type();
if( !mask.empty() )
{
typedef IppStatus (CV_STDCALL* ippiMaskNormRelFuncC1)(const void *, int, const void *, int, const void *, int, IppiSize, Ipp64f *);
ippiMaskNormRelFuncC1 ippFuncC1 =
normType == NORM_INF ?
(type == CV_8UC1 ? (ippiMaskNormRelFuncC1)ippiNormRel_Inf_8u_C1MR :
type == CV_8SC1 ? (ippiMaskNormRelFuncC1)ippiNormRel_Inf_8s_C1MR :
type == CV_16UC1 ? (ippiMaskNormRelFuncC1)ippiNormRel_Inf_16u_C1MR :
type == CV_32FC1 ? (ippiMaskNormRelFuncC1)ippiNormRel_Inf_32f_C1MR :
0) :
normType == NORM_L1 ?
(type == CV_8UC1 ? (ippiMaskNormRelFuncC1)ippiNormRel_L1_8u_C1MR :
type == CV_8SC1 ? (ippiMaskNormRelFuncC1)ippiNormRel_L1_8s_C1MR :
type == CV_16UC1 ? (ippiMaskNormRelFuncC1)ippiNormRel_L1_16u_C1MR :
type == CV_32FC1 ? (ippiMaskNormRelFuncC1)ippiNormRel_L1_32f_C1MR :
0) :
normType == NORM_L2 || normType == NORM_L2SQR ?
(type == CV_8UC1 ? (ippiMaskNormRelFuncC1)ippiNormRel_L2_8u_C1MR :
type == CV_8SC1 ? (ippiMaskNormRelFuncC1)ippiNormRel_L2_8s_C1MR :
type == CV_16UC1 ? (ippiMaskNormRelFuncC1)ippiNormRel_L2_16u_C1MR :
type == CV_32FC1 ? (ippiMaskNormRelFuncC1)ippiNormRel_L2_32f_C1MR :
0) : 0;
if( ippFuncC1 )
{
Ipp64f norm;
if( ippFuncC1(src1.data, (int)src1.step[0], src2.data, (int)src2.step[0], mask.data, (int)mask.step[0], sz, &norm) >= 0 )
return normType == NORM_L2SQR ? (double)(norm * norm) : (double)norm;
}
}
else
{
typedef IppStatus (CV_STDCALL* ippiNormRelFunc)(const void *, int, const void *, int, IppiSize, Ipp64f *, IppHintAlgorithm hint);
ippiNormRelFunc ippFunc =
normType == NORM_INF ?
(type == CV_8UC1 ? (ippiNormRelFunc)ippiNormRel_Inf_8u_C1R :
type == CV_16UC1 ? (ippiNormRelFunc)ippiNormRel_Inf_16u_C1R :
type == CV_16SC1 ? (ippiNormRelFunc)ippiNormRel_Inf_16s_C1R :
type == CV_32FC1 ? (ippiNormRelFunc)ippiNormRel_Inf_32f_C1R :
0) :
normType == NORM_L1 ?
(type == CV_8UC1 ? (ippiNormRelFunc)ippiNormRel_L1_8u_C1R :
type == CV_16UC1 ? (ippiNormRelFunc)ippiNormRel_L1_16u_C1R :
type == CV_16SC1 ? (ippiNormRelFunc)ippiNormRel_L1_16s_C1R :
type == CV_32FC1 ? (ippiNormRelFunc)ippiNormRel_L1_32f_C1R :
0) :
normType == NORM_L2 || normType == NORM_L2SQR ?
(type == CV_8UC1 ? (ippiNormRelFunc)ippiNormRel_L2_8u_C1R :
type == CV_16UC1 ? (ippiNormRelFunc)ippiNormRel_L2_16u_C1R :
type == CV_16SC1 ? (ippiNormRelFunc)ippiNormRel_L2_16s_C1R :
type == CV_32FC1 ? (ippiNormRelFunc)ippiNormRel_L2_32f_C1R :
0) : 0;
if( ippFunc )
{
Ipp64f norm;
if( ippFunc(src1.data, (int)src1.step[0], src2.data, (int)src2.step[0], sz, &norm, ippAlgHintAccurate) >= 0 )
return (double)norm;
}
}
}
#endif
return norm(_src1, _src2, normType & ~CV_RELATIVE, _mask)/(norm(_src2, normType, _mask) + DBL_EPSILON); return norm(_src1, _src2, normType & ~CV_RELATIVE, _mask)/(norm(_src2, normType, _mask) + DBL_EPSILON);
}
Mat src1 = _src1.getMat(), src2 = _src2.getMat(), mask = _mask.getMat(); Mat src1 = _src1.getMat(), src2 = _src2.getMat(), mask = _mask.getMat();
int depth = src1.depth(), cn = src1.channels(); int depth = src1.depth(), cn = src1.channels();
@ -1592,6 +1980,145 @@ double cv::norm( InputArray _src1, InputArray _src2, int normType, InputArray _m
CV_Assert( normType == NORM_INF || normType == NORM_L1 || normType == NORM_L2 || normType == NORM_L2SQR || CV_Assert( normType == NORM_INF || normType == NORM_L1 || normType == NORM_L2 || normType == NORM_L2SQR ||
((normType == NORM_HAMMING || normType == NORM_HAMMING2) && src1.type() == CV_8U) ); ((normType == NORM_HAMMING || normType == NORM_HAMMING2) && src1.type() == CV_8U) );
#if defined (HAVE_IPP) && (IPP_VERSION_MAJOR >= 7)
size_t total_size = src1.total();
int rows = src1.size[0], cols = (int)(total_size/rows);
if( src1.dims == 2 || (src1.isContinuous() && src2.isContinuous() && mask.isContinuous() && cols > 0 && (size_t)rows*cols == total_size)
&& (normType == NORM_INF || normType == NORM_L1 || normType == NORM_L2 || normType == NORM_L2SQR) )
{
IppiSize sz = { cols, rows };
int type = src1.type();
if( !mask.empty() )
{
typedef IppStatus (CV_STDCALL* ippiMaskNormDiffFuncC1)(const void *, int, const void *, int, const void *, int, IppiSize, Ipp64f *);
ippiMaskNormDiffFuncC1 ippFuncC1 =
normType == NORM_INF ?
(type == CV_8UC1 ? (ippiMaskNormDiffFuncC1)ippiNormDiff_Inf_8u_C1MR :
type == CV_8SC1 ? (ippiMaskNormDiffFuncC1)ippiNormDiff_Inf_8s_C1MR :
type == CV_16UC1 ? (ippiMaskNormDiffFuncC1)ippiNormDiff_Inf_16u_C1MR :
type == CV_32FC1 ? (ippiMaskNormDiffFuncC1)ippiNormDiff_Inf_32f_C1MR :
0) :
normType == NORM_L1 ?
(type == CV_8UC1 ? (ippiMaskNormDiffFuncC1)ippiNormDiff_L1_8u_C1MR :
type == CV_8SC1 ? (ippiMaskNormDiffFuncC1)ippiNormDiff_L1_8s_C1MR :
type == CV_16UC1 ? (ippiMaskNormDiffFuncC1)ippiNormDiff_L1_16u_C1MR :
type == CV_32FC1 ? (ippiMaskNormDiffFuncC1)ippiNormDiff_L1_32f_C1MR :
0) :
normType == NORM_L2 || normType == NORM_L2SQR ?
(type == CV_8UC1 ? (ippiMaskNormDiffFuncC1)ippiNormDiff_L2_8u_C1MR :
type == CV_8SC1 ? (ippiMaskNormDiffFuncC1)ippiNormDiff_L2_8s_C1MR :
type == CV_16UC1 ? (ippiMaskNormDiffFuncC1)ippiNormDiff_L2_16u_C1MR :
type == CV_32FC1 ? (ippiMaskNormDiffFuncC1)ippiNormDiff_L2_32f_C1MR :
0) : 0;
if( ippFuncC1 )
{
Ipp64f norm;
if( ippFuncC1(src1.data, (int)src1.step[0], src2.data, (int)src2.step[0], mask.data, (int)mask.step[0], sz, &norm) >= 0 )
return normType == NORM_L2SQR ? (double)(norm * norm) : (double)norm;
}
typedef IppStatus (CV_STDCALL* ippiMaskNormDiffFuncC3)(const void *, int, const void *, int, const void *, int, IppiSize, int, Ipp64f *);
ippiMaskNormDiffFuncC3 ippFuncC3 =
normType == NORM_INF ?
(type == CV_8UC3 ? (ippiMaskNormDiffFuncC3)ippiNormDiff_Inf_8u_C3CMR :
type == CV_8SC3 ? (ippiMaskNormDiffFuncC3)ippiNormDiff_Inf_8s_C3CMR :
type == CV_16UC3 ? (ippiMaskNormDiffFuncC3)ippiNormDiff_Inf_16u_C3CMR :
type == CV_32FC3 ? (ippiMaskNormDiffFuncC3)ippiNormDiff_Inf_32f_C3CMR :
0) :
normType == NORM_L1 ?
(type == CV_8UC3 ? (ippiMaskNormDiffFuncC3)ippiNormDiff_L1_8u_C3CMR :
type == CV_8SC3 ? (ippiMaskNormDiffFuncC3)ippiNormDiff_L1_8s_C3CMR :
type == CV_16UC3 ? (ippiMaskNormDiffFuncC3)ippiNormDiff_L1_16u_C3CMR :
type == CV_32FC3 ? (ippiMaskNormDiffFuncC3)ippiNormDiff_L1_32f_C3CMR :
0) :
normType == NORM_L2 || normType == NORM_L2SQR ?
(type == CV_8UC3 ? (ippiMaskNormDiffFuncC3)ippiNormDiff_L2_8u_C3CMR :
type == CV_8SC3 ? (ippiMaskNormDiffFuncC3)ippiNormDiff_L2_8s_C3CMR :
type == CV_16UC3 ? (ippiMaskNormDiffFuncC3)ippiNormDiff_L2_16u_C3CMR :
type == CV_32FC3 ? (ippiMaskNormDiffFuncC3)ippiNormDiff_L2_32f_C3CMR :
0) : 0;
if( ippFuncC3 )
{
Ipp64f norm1, norm2, norm3;
if( ippFuncC3(src1.data, (int)src1.step[0], src2.data, (int)src2.step[0], mask.data, (int)mask.step[0], sz, 1, &norm1) >= 0 &&
ippFuncC3(src1.data, (int)src1.step[0], src2.data, (int)src2.step[0], mask.data, (int)mask.step[0], sz, 2, &norm2) >= 0 &&
ippFuncC3(src1.data, (int)src1.step[0], src2.data, (int)src2.step[0], mask.data, (int)mask.step[0], sz, 3, &norm3) >= 0)
{
Ipp64f norm =
normType == NORM_INF ? std::max(std::max(norm1, norm2), norm3) :
normType == NORM_L1 ? norm1 + norm2 + norm3 :
normType == NORM_L2 || normType == NORM_L2SQR ? std::sqrt(norm1 * norm1 + norm2 * norm2 + norm3 * norm3) :
0;
return normType == NORM_L2SQR ? (double)(norm * norm) : (double)norm;
}
}
}
else
{
typedef IppStatus (CV_STDCALL* ippiNormDiffFunc)(const void *, int, const void *, int, IppiSize, Ipp64f *, IppHintAlgorithm hint);
ippiNormDiffFunc ippFunc =
normType == NORM_INF ?
(type == CV_8UC1 ? (ippiNormDiffFunc)ippiNormDiff_Inf_8u_C1R :
type == CV_8UC3 ? (ippiNormDiffFunc)ippiNormDiff_Inf_8u_C3R :
type == CV_8UC4 ? (ippiNormDiffFunc)ippiNormDiff_Inf_8u_C4R :
type == CV_16UC1 ? (ippiNormDiffFunc)ippiNormDiff_Inf_16u_C1R :
type == CV_16UC3 ? (ippiNormDiffFunc)ippiNormDiff_Inf_16u_C3R :
type == CV_16UC4 ? (ippiNormDiffFunc)ippiNormDiff_Inf_16u_C4R :
type == CV_16SC1 ? (ippiNormDiffFunc)ippiNormDiff_Inf_16s_C1R :
//type == CV_16SC3 ? (ippiNormDiffFunc)ippiNormDiff_Inf_16s_C3R : //Aug 2013: problem in IPP 7.1, 8.0 : -32768
//type == CV_16SC4 ? (ippiNormDiffFunc)ippiNormDiff_Inf_16s_C4R : //Aug 2013: problem in IPP 7.1, 8.0 : -32768
type == CV_32FC1 ? (ippiNormDiffFunc)ippiNormDiff_Inf_32f_C1R :
type == CV_32FC3 ? (ippiNormDiffFunc)ippiNormDiff_Inf_32f_C3R :
type == CV_32FC4 ? (ippiNormDiffFunc)ippiNormDiff_Inf_32f_C4R :
0) :
normType == NORM_L1 ?
(type == CV_8UC1 ? (ippiNormDiffFunc)ippiNormDiff_L1_8u_C1R :
type == CV_8UC3 ? (ippiNormDiffFunc)ippiNormDiff_L1_8u_C3R :
type == CV_8UC4 ? (ippiNormDiffFunc)ippiNormDiff_L1_8u_C4R :
type == CV_16UC1 ? (ippiNormDiffFunc)ippiNormDiff_L1_16u_C1R :
type == CV_16UC3 ? (ippiNormDiffFunc)ippiNormDiff_L1_16u_C3R :
type == CV_16UC4 ? (ippiNormDiffFunc)ippiNormDiff_L1_16u_C4R :
type == CV_16SC1 ? (ippiNormDiffFunc)ippiNormDiff_L1_16s_C1R :
type == CV_16SC3 ? (ippiNormDiffFunc)ippiNormDiff_L1_16s_C3R :
type == CV_16SC4 ? (ippiNormDiffFunc)ippiNormDiff_L1_16s_C4R :
type == CV_32FC1 ? (ippiNormDiffFunc)ippiNormDiff_L1_32f_C1R :
type == CV_32FC3 ? (ippiNormDiffFunc)ippiNormDiff_L1_32f_C3R :
type == CV_32FC4 ? (ippiNormDiffFunc)ippiNormDiff_L1_32f_C4R :
0) :
normType == NORM_L2 || normType == NORM_L2SQR ?
(type == CV_8UC1 ? (ippiNormDiffFunc)ippiNormDiff_L2_8u_C1R :
type == CV_8UC3 ? (ippiNormDiffFunc)ippiNormDiff_L2_8u_C3R :
type == CV_8UC4 ? (ippiNormDiffFunc)ippiNormDiff_L2_8u_C4R :
type == CV_16UC1 ? (ippiNormDiffFunc)ippiNormDiff_L2_16u_C1R :
type == CV_16UC3 ? (ippiNormDiffFunc)ippiNormDiff_L2_16u_C3R :
type == CV_16UC4 ? (ippiNormDiffFunc)ippiNormDiff_L2_16u_C4R :
type == CV_16SC1 ? (ippiNormDiffFunc)ippiNormDiff_L2_16s_C1R :
type == CV_16SC3 ? (ippiNormDiffFunc)ippiNormDiff_L2_16s_C3R :
type == CV_16SC4 ? (ippiNormDiffFunc)ippiNormDiff_L2_16s_C4R :
type == CV_32FC1 ? (ippiNormDiffFunc)ippiNormDiff_L2_32f_C1R :
type == CV_32FC3 ? (ippiNormDiffFunc)ippiNormDiff_L2_32f_C3R :
type == CV_32FC4 ? (ippiNormDiffFunc)ippiNormDiff_L2_32f_C4R :
0) : 0;
if( ippFunc )
{
Ipp64f norm_array[4];
if( ippFunc(src1.data, (int)src1.step[0], src2.data, (int)src2.step[0], sz, norm_array, ippAlgHintAccurate) >= 0 )
{
Ipp64f norm = (normType == NORM_L2 || normType == NORM_L2SQR) ? norm_array[0] * norm_array[0] : norm_array[0];
for( int i = 1; i < src1.channels(); i++ )
{
norm =
normType == NORM_INF ? std::max(norm, norm_array[i]) :
normType == NORM_L1 ? norm + norm_array[i] :
normType == NORM_L2 || normType == NORM_L2SQR ? norm + norm_array[i] * norm_array[i] :
0;
}
return normType == NORM_L2 ? (double)std::sqrt(norm) : (double)norm;
}
}
}
}
#endif
if( src1.isContinuous() && src2.isContinuous() && mask.empty() ) if( src1.isContinuous() && src2.isContinuous() && mask.empty() )
{ {
size_t len = src1.total()*src1.channels(); size_t len = src1.total()*src1.channels();

@ -510,6 +510,32 @@ protected:
return; return;
} }
#endif #endif
// Test read and write
FileStorage fs( "PCA_store.yml", FileStorage::WRITE );
rPCA.write( fs );
fs.release();
PCA lPCA;
fs.open( "PCA_store.yml", FileStorage::READ );
lPCA.read( fs.root() );
err = norm( rPCA.eigenvectors, lPCA.eigenvectors, CV_RELATIVE_L2 );
if( err > 0 )
{
ts->printf( cvtest::TS::LOG, "bad accuracy of write/load functions (YML); err = %f\n", err );
ts->set_failed_test_info( cvtest::TS::FAIL_BAD_ACCURACY );
}
err = norm( rPCA.eigenvalues, lPCA.eigenvalues, CV_RELATIVE_L2 );
if( err > 0 )
{
ts->printf( cvtest::TS::LOG, "bad accuracy of write/load functions (YML); err = %f\n", err );
ts->set_failed_test_info( cvtest::TS::FAIL_BAD_ACCURACY );
}
err = norm( rPCA.mean, lPCA.mean, CV_RELATIVE_L2 );
if( err > 0 )
{
ts->printf( cvtest::TS::LOG, "bad accuracy of write/load functions (YML); err = %f\n", err );
ts->set_failed_test_info( cvtest::TS::FAIL_BAD_ACCURACY );
}
} }
}; };

@ -368,8 +368,8 @@ PERF_TEST_P(ImagePair, OpticalFlowDual_TVL1,
TEST_CYCLE() d_alg(d_frame0, d_frame1, u, v); TEST_CYCLE() d_alg(d_frame0, d_frame1, u, v);
CUDA_SANITY_CHECK(u, 1e-2); CUDA_SANITY_CHECK(u, 1e-1);
CUDA_SANITY_CHECK(v, 1e-2); CUDA_SANITY_CHECK(v, 1e-1);
} }
else else
{ {

@ -211,7 +211,7 @@ namespace tvl1flow
const PtrStepf grad, const PtrStepf rho_c, const PtrStepf grad, const PtrStepf rho_c,
const PtrStepf p11, const PtrStepf p12, const PtrStepf p21, const PtrStepf p22, const PtrStepf p11, const PtrStepf p12, const PtrStepf p21, const PtrStepf p22,
PtrStepf u1, PtrStepf u2, PtrStepf error, PtrStepf u1, PtrStepf u2, PtrStepf error,
const float l_t, const float theta) const float l_t, const float theta, const bool calcError)
{ {
const int x = blockIdx.x * blockDim.x + threadIdx.x; const int x = blockIdx.x * blockDim.x + threadIdx.x;
const int y = blockIdx.y * blockDim.y + threadIdx.y; const int y = blockIdx.y * blockDim.y + threadIdx.y;
@ -265,21 +265,24 @@ namespace tvl1flow
u1(y, x) = u1NewVal; u1(y, x) = u1NewVal;
u2(y, x) = u2NewVal; u2(y, x) = u2NewVal;
const float n1 = (u1OldVal - u1NewVal) * (u1OldVal - u1NewVal); if (calcError)
const float n2 = (u2OldVal - u2NewVal) * (u2OldVal - u2NewVal); {
error(y, x) = n1 + n2; const float n1 = (u1OldVal - u1NewVal) * (u1OldVal - u1NewVal);
const float n2 = (u2OldVal - u2NewVal) * (u2OldVal - u2NewVal);
error(y, x) = n1 + n2;
}
} }
void estimateU(PtrStepSzf I1wx, PtrStepSzf I1wy, void estimateU(PtrStepSzf I1wx, PtrStepSzf I1wy,
PtrStepSzf grad, PtrStepSzf rho_c, PtrStepSzf grad, PtrStepSzf rho_c,
PtrStepSzf p11, PtrStepSzf p12, PtrStepSzf p21, PtrStepSzf p22, PtrStepSzf p11, PtrStepSzf p12, PtrStepSzf p21, PtrStepSzf p22,
PtrStepSzf u1, PtrStepSzf u2, PtrStepSzf error, PtrStepSzf u1, PtrStepSzf u2, PtrStepSzf error,
float l_t, float theta) float l_t, float theta, bool calcError)
{ {
const dim3 block(32, 8); const dim3 block(32, 8);
const dim3 grid(divUp(I1wx.cols, block.x), divUp(I1wx.rows, block.y)); const dim3 grid(divUp(I1wx.cols, block.x), divUp(I1wx.rows, block.y));
estimateUKernel<<<grid, block>>>(I1wx, I1wy, grad, rho_c, p11, p12, p21, p22, u1, u2, error, l_t, theta); estimateUKernel<<<grid, block>>>(I1wx, I1wy, grad, rho_c, p11, p12, p21, p22, u1, u2, error, l_t, theta, calcError);
cudaSafeCall( cudaGetLastError() ); cudaSafeCall( cudaGetLastError() );
cudaSafeCall( cudaDeviceSynchronize() ); cudaSafeCall( cudaDeviceSynchronize() );

@ -173,7 +173,7 @@ namespace tvl1flow
PtrStepSzf grad, PtrStepSzf rho_c, PtrStepSzf grad, PtrStepSzf rho_c,
PtrStepSzf p11, PtrStepSzf p12, PtrStepSzf p21, PtrStepSzf p22, PtrStepSzf p11, PtrStepSzf p12, PtrStepSzf p21, PtrStepSzf p22,
PtrStepSzf u1, PtrStepSzf u2, PtrStepSzf error, PtrStepSzf u1, PtrStepSzf u2, PtrStepSzf error,
float l_t, float theta); float l_t, float theta, bool calcError);
void estimateDualVariables(PtrStepSzf u1, PtrStepSzf u2, PtrStepSzf p11, PtrStepSzf p12, PtrStepSzf p21, PtrStepSzf p22, float taut); void estimateDualVariables(PtrStepSzf u1, PtrStepSzf u2, PtrStepSzf p11, PtrStepSzf p12, PtrStepSzf p21, PtrStepSzf p22, float taut);
} }
@ -218,12 +218,24 @@ void cv::cuda::OpticalFlowDual_TVL1_CUDA::procOneScale(const GpuMat& I0, const G
warpBackward(I0, I1, I1x, I1y, u1, u2, I1w, I1wx, I1wy, grad, rho_c); warpBackward(I0, I1, I1x, I1y, u1, u2, I1w, I1wx, I1wy, grad, rho_c);
double error = std::numeric_limits<double>::max(); double error = std::numeric_limits<double>::max();
double prevError = 0.0;
for (int n = 0; error > scaledEpsilon && n < iterations; ++n) for (int n = 0; error > scaledEpsilon && n < iterations; ++n)
{ {
estimateU(I1wx, I1wy, grad, rho_c, p11, p12, p21, p22, u1, u2, diff, l_t, static_cast<float>(theta)); // some tweaks to make sum operation less frequently
bool calcError = (epsilon > 0) && (n & 0x1) && (prevError < scaledEpsilon);
if (epsilon > 0) estimateU(I1wx, I1wy, grad, rho_c, p11, p12, p21, p22, u1, u2, diff, l_t, static_cast<float>(theta), calcError);
if (calcError)
{
error = cuda::sum(diff, norm_buf)[0]; error = cuda::sum(diff, norm_buf)[0];
prevError = error;
}
else
{
error = std::numeric_limits<double>::max();
prevError -= scaledEpsilon;
}
estimateDualVariables(u1, u2, p11, p12, p21, p22, taut); estimateDualVariables(u1, u2, p11, p12, p21, p22, taut);
} }

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.7 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.3 KiB

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.6 KiB

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.2 KiB

After

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.6 KiB

After

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.3 KiB

After

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.5 KiB

After

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.4 KiB

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.2 KiB

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.5 KiB

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.1 KiB

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.0 KiB

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.7 KiB

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.2 KiB

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.3 KiB

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.2 KiB

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.8 KiB

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.2 KiB

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.6 KiB

After

Width:  |  Height:  |  Size: 3.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.3 KiB

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.6 KiB

After

Width:  |  Height:  |  Size: 3.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.8 KiB

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.0 KiB

After

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.9 KiB

After

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.3 KiB

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.6 KiB

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.9 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.3 KiB

After

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.1 KiB

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.6 KiB

After

Width:  |  Height:  |  Size: 3.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.1 KiB

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.7 KiB

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.6 KiB

After

Width:  |  Height:  |  Size: 3.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.3 KiB

After

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.4 KiB

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.1 KiB

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.7 KiB

After

Width:  |  Height:  |  Size: 3.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.2 KiB

After

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.2 KiB

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.5 KiB

After

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.6 KiB

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.5 KiB

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.0 KiB

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.5 KiB

After

Width:  |  Height:  |  Size: 3.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.7 KiB

After

Width:  |  Height:  |  Size: 4.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.1 KiB

After

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.9 KiB

After

Width:  |  Height:  |  Size: 5.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.8 KiB

After

Width:  |  Height:  |  Size: 3.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.8 KiB

After

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.8 KiB

After

Width:  |  Height:  |  Size: 5.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.3 KiB

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.9 KiB

After

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.1 KiB

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.2 KiB

After

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.3 KiB

After

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.3 KiB

After

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.9 KiB

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.9 KiB

After

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.1 KiB

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.9 KiB

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.9 KiB

After

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.2 KiB

After

Width:  |  Height:  |  Size: 3.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.0 KiB

After

Width:  |  Height:  |  Size: 4.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.0 KiB

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.0 KiB

After

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.4 KiB

After

Width:  |  Height:  |  Size: 4.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.1 KiB

After

Width:  |  Height:  |  Size: 6.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.6 KiB

After

Width:  |  Height:  |  Size: 3.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.4 KiB

After

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.6 KiB

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.6 KiB

After

Width:  |  Height:  |  Size: 4.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.4 KiB

After

Width:  |  Height:  |  Size: 3.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.9 KiB

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.2 KiB

After

Width:  |  Height:  |  Size: 4.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.0 KiB

After

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.7 KiB

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.0 KiB

After

Width:  |  Height:  |  Size: 4.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.5 KiB

After

Width:  |  Height:  |  Size: 3.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.6 KiB

After

Width:  |  Height:  |  Size: 4.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.3 KiB

After

Width:  |  Height:  |  Size: 3.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.1 KiB

After

Width:  |  Height:  |  Size: 4.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.6 KiB

After

Width:  |  Height:  |  Size: 4.0 KiB

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save