Set stricter warning rules for gcc
This commit is contained in:
@@ -1299,6 +1299,7 @@ public:
|
||||
GPU_MAT = 9 << KIND_SHIFT
|
||||
};
|
||||
_InputArray();
|
||||
|
||||
_InputArray(const Mat& m);
|
||||
_InputArray(const MatExpr& expr);
|
||||
template<typename _Tp> _InputArray(const _Tp* vec, int n);
|
||||
@@ -1328,6 +1329,8 @@ public:
|
||||
virtual int channels(int i=-1) const;
|
||||
virtual bool empty() const;
|
||||
|
||||
virtual ~_InputArray();
|
||||
|
||||
int flags;
|
||||
void* obj;
|
||||
Size sz;
|
||||
@@ -1384,6 +1387,8 @@ public:
|
||||
virtual void create(int dims, const int* size, int type, int i=-1, bool allowTransposed=false, int fixedDepthMask=0) const;
|
||||
virtual void release() const;
|
||||
virtual void clear() const;
|
||||
|
||||
virtual ~_OutputArray();
|
||||
};
|
||||
|
||||
typedef const _InputArray& InputArray;
|
||||
@@ -3977,7 +3982,7 @@ public:
|
||||
CV_WRAP virtual bool isOpened() const;
|
||||
//! closes the file and releases all the memory buffers
|
||||
CV_WRAP virtual void release();
|
||||
//! closes the file, releases all the memory buffers and returns the text string
|
||||
//! closes the file, releases all the memory buffers and returns the text string
|
||||
CV_WRAP virtual string releaseAndGetString();
|
||||
|
||||
//! returns the first element of the top-level mapping
|
||||
|
@@ -60,34 +60,34 @@
|
||||
#endif
|
||||
|
||||
#if defined WIN32 || defined WINCE
|
||||
#ifndef _WIN32_WINNT // This is needed for the declaration of TryEnterCriticalSection in winbase.h with Visual Studio 2005 (and older?)
|
||||
#define _WIN32_WINNT 0x0400 // http://msdn.microsoft.com/en-us/library/ms686857(VS.85).aspx
|
||||
#endif
|
||||
#include <windows.h>
|
||||
#undef small
|
||||
#undef min
|
||||
#undef max
|
||||
# ifndef _WIN32_WINNT // This is needed for the declaration of TryEnterCriticalSection in winbase.h with Visual Studio 2005 (and older?)
|
||||
# define _WIN32_WINNT 0x0400 // http://msdn.microsoft.com/en-us/library/ms686857(VS.85).aspx
|
||||
# endif
|
||||
# include <windows.h>
|
||||
# undef small
|
||||
# undef min
|
||||
# undef max
|
||||
#else
|
||||
#include <pthread.h>
|
||||
# include <pthread.h>
|
||||
#endif
|
||||
|
||||
#ifdef __BORLANDC__
|
||||
#ifndef WIN32
|
||||
#define WIN32
|
||||
#endif
|
||||
#ifndef _WIN32
|
||||
#define _WIN32
|
||||
#endif
|
||||
#define CV_DLL
|
||||
#undef _CV_ALWAYS_PROFILE_
|
||||
#define _CV_ALWAYS_NO_PROFILE_
|
||||
# ifndef WIN32
|
||||
# define WIN32
|
||||
# endif
|
||||
# ifndef _WIN32
|
||||
# define _WIN32
|
||||
# endif
|
||||
# define CV_DLL
|
||||
# undef _CV_ALWAYS_PROFILE_
|
||||
# define _CV_ALWAYS_NO_PROFILE_
|
||||
#endif
|
||||
|
||||
#ifndef FALSE
|
||||
#define FALSE 0
|
||||
# define FALSE 0
|
||||
#endif
|
||||
#ifndef TRUE
|
||||
#define TRUE 1
|
||||
# define TRUE 1
|
||||
#endif
|
||||
|
||||
#define __BEGIN__ __CV_BEGIN__
|
||||
@@ -95,7 +95,7 @@
|
||||
#define EXIT __CV_EXIT__
|
||||
|
||||
#ifdef HAVE_IPP
|
||||
#include "ipp.h"
|
||||
# include "ipp.h"
|
||||
|
||||
CV_INLINE IppiSize ippiSize(int width, int height)
|
||||
{
|
||||
@@ -104,137 +104,132 @@ CV_INLINE IppiSize ippiSize(int width, int height)
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined __SSE2__ || _MSC_VER >= 1300
|
||||
#include "emmintrin.h"
|
||||
#define CV_SSE 1
|
||||
#define CV_SSE2 1
|
||||
#if defined __SSE3__ || _MSC_VER >= 1500
|
||||
#include "pmmintrin.h"
|
||||
#define CV_SSE3 1
|
||||
#endif
|
||||
#if defined __SSSE3__
|
||||
#include "tmmintrin.h"
|
||||
#define CV_SSSE3 1
|
||||
#endif
|
||||
#if defined __SSE2__ || (defined _MSC_VER && _MSC_VER >= 1300)
|
||||
# include "emmintrin.h"
|
||||
# define CV_SSE 1
|
||||
# define CV_SSE2 1
|
||||
# if defined __SSE3__ || (defined _MSC_VER && _MSC_VER >= 1500)
|
||||
# include "pmmintrin.h"
|
||||
# define CV_SSE3 1
|
||||
# else
|
||||
# define CV_SSE3 0
|
||||
# endif
|
||||
# if defined __SSSE3__
|
||||
# include "tmmintrin.h"
|
||||
# define CV_SSSE3 1
|
||||
# else
|
||||
# define CV_SSSE3 0
|
||||
# endif
|
||||
#else
|
||||
#define CV_SSE 0
|
||||
#define CV_SSE2 0
|
||||
#define CV_SSE3 0
|
||||
#define CV_SSSE3 0
|
||||
# define CV_SSE 0
|
||||
# define CV_SSE2 0
|
||||
# define CV_SSE3 0
|
||||
# define CV_SSSE3 0
|
||||
#endif
|
||||
|
||||
#if defined ANDROID && defined __ARM_NEON__ && defined __GNUC__
|
||||
#include "arm_neon.h"
|
||||
#define CV_NEON 1
|
||||
#if defined ANDROID && defined __ARM_NEON__
|
||||
# include "arm_neon.h"
|
||||
# define CV_NEON 1
|
||||
|
||||
#define CPU_HAS_NEON_FEATURE (true)
|
||||
# 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
|
||||
|
||||
#ifdef CV_ICC
|
||||
#define CV_ENABLE_UNROLLED 0
|
||||
#else
|
||||
#define CV_ENABLE_UNROLLED 1
|
||||
# define CV_NEON 0
|
||||
# define CPU_HAS_NEON_FEATURE (false)
|
||||
#endif
|
||||
|
||||
#ifndef IPPI_CALL
|
||||
#define IPPI_CALL(func) CV_Assert((func) >= 0)
|
||||
# define IPPI_CALL(func) CV_Assert((func) >= 0)
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_TBB
|
||||
#include "tbb/tbb_stddef.h"
|
||||
#if TBB_VERSION_MAJOR*100 + TBB_VERSION_MINOR >= 202
|
||||
#include "tbb/tbb.h"
|
||||
#include "tbb/task.h"
|
||||
#undef min
|
||||
#undef max
|
||||
#else
|
||||
#undef HAVE_TBB
|
||||
#endif
|
||||
# include "tbb/tbb_stddef.h"
|
||||
# if TBB_VERSION_MAJOR*100 + TBB_VERSION_MINOR >= 202
|
||||
# include "tbb/tbb.h"
|
||||
# include "tbb/task.h"
|
||||
# undef min
|
||||
# undef max
|
||||
# else
|
||||
# undef HAVE_TBB
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_EIGEN
|
||||
#include <Eigen/Core>
|
||||
#include "opencv2/core/eigen.hpp"
|
||||
# include <Eigen/Core>
|
||||
# include "opencv2/core/eigen.hpp"
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
namespace cv
|
||||
{
|
||||
#ifdef HAVE_TBB
|
||||
namespace cv
|
||||
{
|
||||
typedef tbb::blocked_range<int> BlockedRange;
|
||||
|
||||
template<typename Body> static inline
|
||||
void parallel_for( const BlockedRange& range, const Body& body )
|
||||
{
|
||||
tbb::parallel_for(range, body);
|
||||
}
|
||||
|
||||
template<typename Iterator, typename Body> static inline
|
||||
void parallel_do( Iterator first, Iterator last, const Body& body )
|
||||
{
|
||||
tbb::parallel_do(first, last, body);
|
||||
}
|
||||
|
||||
typedef tbb::split Split;
|
||||
|
||||
template<typename Body> static inline
|
||||
void parallel_reduce( const BlockedRange& range, Body& body )
|
||||
{
|
||||
tbb::parallel_reduce(range, body);
|
||||
}
|
||||
|
||||
typedef tbb::concurrent_vector<Rect> ConcurrentRectVector;
|
||||
typedef tbb::concurrent_vector<double> ConcurrentDoubleVector;
|
||||
}
|
||||
#else
|
||||
namespace cv
|
||||
{
|
||||
class BlockedRange
|
||||
{
|
||||
public:
|
||||
BlockedRange() : _begin(0), _end(0), _grainsize(0) {}
|
||||
BlockedRange(int b, int e, int g=1) : _begin(b), _end(e), _grainsize(g) {}
|
||||
int begin() const { return _begin; }
|
||||
int end() const { return _end; }
|
||||
int grainsize() const { return _grainsize; }
|
||||
|
||||
protected:
|
||||
int _begin, _end, _grainsize;
|
||||
};
|
||||
|
||||
template<typename Body> static inline
|
||||
void parallel_for( const BlockedRange& range, const Body& body )
|
||||
{
|
||||
body(range);
|
||||
}
|
||||
typedef std::vector<Rect> ConcurrentRectVector;
|
||||
typedef std::vector<double> ConcurrentDoubleVector;
|
||||
|
||||
template<typename Iterator, typename Body> static inline
|
||||
void parallel_do( Iterator first, Iterator last, const Body& body )
|
||||
{
|
||||
for( ; first != last; ++first )
|
||||
body(*first);
|
||||
}
|
||||
|
||||
class Split {};
|
||||
|
||||
template<typename Body> static inline
|
||||
void parallel_reduce( const BlockedRange& range, Body& body )
|
||||
{
|
||||
body(range);
|
||||
}
|
||||
|
||||
typedef tbb::blocked_range<int> BlockedRange;
|
||||
|
||||
template<typename Body> static inline
|
||||
void parallel_for( const BlockedRange& range, const Body& body )
|
||||
{
|
||||
tbb::parallel_for(range, body);
|
||||
}
|
||||
|
||||
template<typename Iterator, typename Body> static inline
|
||||
void parallel_do( Iterator first, Iterator last, const Body& body )
|
||||
{
|
||||
tbb::parallel_do(first, last, body);
|
||||
}
|
||||
|
||||
typedef tbb::split Split;
|
||||
|
||||
template<typename Body> static inline
|
||||
void parallel_reduce( const BlockedRange& range, Body& body )
|
||||
{
|
||||
tbb::parallel_reduce(range, body);
|
||||
}
|
||||
|
||||
typedef tbb::concurrent_vector<Rect> ConcurrentRectVector;
|
||||
typedef tbb::concurrent_vector<double> ConcurrentDoubleVector;
|
||||
#else
|
||||
class BlockedRange
|
||||
{
|
||||
public:
|
||||
BlockedRange() : _begin(0), _end(0), _grainsize(0) {}
|
||||
BlockedRange(int b, int e, int g=1) : _begin(b), _end(e), _grainsize(g) {}
|
||||
int begin() const { return _begin; }
|
||||
int end() const { return _end; }
|
||||
int grainsize() const { return _grainsize; }
|
||||
|
||||
protected:
|
||||
int _begin, _end, _grainsize;
|
||||
};
|
||||
|
||||
template<typename Body> static inline
|
||||
void parallel_for( const BlockedRange& range, const Body& body )
|
||||
{
|
||||
body(range);
|
||||
}
|
||||
typedef std::vector<Rect> ConcurrentRectVector;
|
||||
typedef std::vector<double> ConcurrentDoubleVector;
|
||||
|
||||
template<typename Iterator, typename Body> static inline
|
||||
void parallel_do( Iterator first, Iterator last, const Body& body )
|
||||
{
|
||||
for( ; first != last; ++first )
|
||||
body(*first);
|
||||
}
|
||||
|
||||
class Split {};
|
||||
|
||||
template<typename Body> static inline
|
||||
void parallel_reduce( const BlockedRange& range, Body& body )
|
||||
{
|
||||
body(range);
|
||||
}
|
||||
#endif
|
||||
} //namespace cv
|
||||
|
||||
#define CV_INIT_ALGORITHM(classname, algname, memberinit) \
|
||||
#define CV_INIT_ALGORITHM(classname, algname, memberinit) \
|
||||
static Algorithm* create##classname() \
|
||||
{ \
|
||||
return new classname; \
|
||||
@@ -261,7 +256,7 @@ CV_INLINE IppiSize ippiSize(int width, int height)
|
||||
return &classname##_info(); \
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif //__cplusplus
|
||||
|
||||
/* maximal size of vector to run matrix operations on it inline (i.e. w/o ipp calls) */
|
||||
#define CV_MAX_INLINE_MAT_OP_SIZE 10
|
||||
@@ -305,9 +300,9 @@ CV_INLINE IppiSize ippiSize(int width, int height)
|
||||
#define CV_MAX_STRLEN 1024
|
||||
|
||||
#if 0 /*def CV_CHECK_FOR_NANS*/
|
||||
#define CV_CHECK_NANS( arr ) cvCheckArray((arr))
|
||||
# define CV_CHECK_NANS( arr ) cvCheckArray((arr))
|
||||
#else
|
||||
#define CV_CHECK_NANS( arr )
|
||||
# define CV_CHECK_NANS( arr )
|
||||
#endif
|
||||
|
||||
/****************************************************************************************\
|
||||
@@ -316,38 +311,38 @@ CV_INLINE IppiSize ippiSize(int width, int height)
|
||||
|
||||
/* get alloca declaration */
|
||||
#ifdef __GNUC__
|
||||
#undef alloca
|
||||
#define alloca __builtin_alloca
|
||||
#define CV_HAVE_ALLOCA 1
|
||||
# undef alloca
|
||||
# define alloca __builtin_alloca
|
||||
# define CV_HAVE_ALLOCA 1
|
||||
#elif defined WIN32 || defined _WIN32 || \
|
||||
defined WINCE || defined _MSC_VER || defined __BORLANDC__
|
||||
#include <malloc.h>
|
||||
#define CV_HAVE_ALLOCA 1
|
||||
# include <malloc.h>
|
||||
# define CV_HAVE_ALLOCA 1
|
||||
#elif defined HAVE_ALLOCA_H
|
||||
#include <alloca.h>
|
||||
#define CV_HAVE_ALLOCA 1
|
||||
# include <alloca.h>
|
||||
# define CV_HAVE_ALLOCA 1
|
||||
#elif defined HAVE_ALLOCA
|
||||
#include <stdlib.h>
|
||||
#define CV_HAVE_ALLOCA 1
|
||||
# include <stdlib.h>
|
||||
# define CV_HAVE_ALLOCA 1
|
||||
#else
|
||||
#undef CV_HAVE_ALLOCA
|
||||
# undef CV_HAVE_ALLOCA
|
||||
#endif
|
||||
|
||||
#ifdef __GNUC__
|
||||
#define CV_DECL_ALIGNED(x) __attribute__ ((aligned (x)))
|
||||
# define CV_DECL_ALIGNED(x) __attribute__ ((aligned (x)))
|
||||
#elif defined _MSC_VER
|
||||
#define CV_DECL_ALIGNED(x) __declspec(align(x))
|
||||
# define CV_DECL_ALIGNED(x) __declspec(align(x))
|
||||
#else
|
||||
#define CV_DECL_ALIGNED(x)
|
||||
# define CV_DECL_ALIGNED(x)
|
||||
#endif
|
||||
|
||||
#if CV_HAVE_ALLOCA
|
||||
/* ! DO NOT make it an inline function */
|
||||
#define cvStackAlloc(size) cvAlignPtr( alloca((size) + CV_MALLOC_ALIGN), CV_MALLOC_ALIGN )
|
||||
# define cvStackAlloc(size) cvAlignPtr( alloca((size) + CV_MALLOC_ALIGN), CV_MALLOC_ALIGN )
|
||||
#endif
|
||||
|
||||
#ifndef CV_IMPL
|
||||
#define CV_IMPL CV_EXTERN_C
|
||||
# define CV_IMPL CV_EXTERN_C
|
||||
#endif
|
||||
|
||||
#define CV_DBG_BREAK() { volatile int* crashMe = 0; *crashMe = 0; }
|
||||
@@ -687,25 +682,25 @@ typedef enum CvStatus
|
||||
CV_UNSUPPORTED_DEPTH_ERR = -101,
|
||||
CV_UNSUPPORTED_FORMAT_ERR = -100,
|
||||
|
||||
CV_BADARG_ERR = -49, //ipp comp
|
||||
CV_NOTDEFINED_ERR = -48, //ipp comp
|
||||
CV_BADARG_ERR = -49, //ipp comp
|
||||
CV_NOTDEFINED_ERR = -48, //ipp comp
|
||||
|
||||
CV_BADCHANNELS_ERR = -47, //ipp comp
|
||||
CV_BADRANGE_ERR = -44, //ipp comp
|
||||
CV_BADSTEP_ERR = -29, //ipp comp
|
||||
CV_BADCHANNELS_ERR = -47, //ipp comp
|
||||
CV_BADRANGE_ERR = -44, //ipp comp
|
||||
CV_BADSTEP_ERR = -29, //ipp comp
|
||||
|
||||
CV_BADFLAG_ERR = -12,
|
||||
CV_DIV_BY_ZERO_ERR = -11, //ipp comp
|
||||
CV_BADCOEF_ERR = -10,
|
||||
CV_BADFLAG_ERR = -12,
|
||||
CV_DIV_BY_ZERO_ERR = -11, //ipp comp
|
||||
CV_BADCOEF_ERR = -10,
|
||||
|
||||
CV_BADFACTOR_ERR = -7,
|
||||
CV_BADPOINT_ERR = -6,
|
||||
CV_BADSCALE_ERR = -4,
|
||||
CV_OUTOFMEM_ERR = -3,
|
||||
CV_NULLPTR_ERR = -2,
|
||||
CV_BADSIZE_ERR = -1,
|
||||
CV_NO_ERR = 0,
|
||||
CV_OK = CV_NO_ERR
|
||||
CV_BADFACTOR_ERR = -7,
|
||||
CV_BADPOINT_ERR = -6,
|
||||
CV_BADSCALE_ERR = -4,
|
||||
CV_OUTOFMEM_ERR = -3,
|
||||
CV_NULLPTR_ERR = -2,
|
||||
CV_BADSIZE_ERR = -1,
|
||||
CV_NO_ERR = 0,
|
||||
CV_OK = CV_NO_ERR
|
||||
}
|
||||
CvStatus;
|
||||
|
||||
@@ -720,8 +715,7 @@ CvFuncTable;
|
||||
typedef struct CvBigFuncTable
|
||||
{
|
||||
void* fn_2d[CV_DEPTH_MAX*4];
|
||||
}
|
||||
CvBigFuncTable;
|
||||
} CvBigFuncTable;
|
||||
|
||||
#define CV_INIT_FUNC_TAB( tab, FUNCNAME, FLAG ) \
|
||||
(tab).fn_2d[CV_8U] = (void*)FUNCNAME##_8u##FLAG; \
|
||||
@@ -732,13 +726,14 @@ CvBigFuncTable;
|
||||
(tab).fn_2d[CV_32F] = (void*)FUNCNAME##_32f##FLAG; \
|
||||
(tab).fn_2d[CV_64F] = (void*)FUNCNAME##_64f##FLAG
|
||||
|
||||
#ifdef __cplusplus
|
||||
//! OpenGL extension table
|
||||
class CV_EXPORTS CvOpenGlFuncTab
|
||||
{
|
||||
public:
|
||||
virtual ~CvOpenGlFuncTab();
|
||||
|
||||
virtual void genBuffers(int n, unsigned int* buffers) const = 0;
|
||||
virtual void genBuffers(int n, unsigned int* buffers) const = 0;
|
||||
virtual void deleteBuffers(int n, const unsigned int* buffers) const = 0;
|
||||
|
||||
virtual void bufferData(unsigned int target, ptrdiff_t size, const void* data, unsigned int usage) const = 0;
|
||||
@@ -764,4 +759,6 @@ CV_EXPORTS bool icvCheckGlError(const char* file, const int line, const char* fu
|
||||
#define CV_CheckGlError() CV_DbgAssert( (::icvCheckGlError(__FILE__, __LINE__)) )
|
||||
#endif
|
||||
|
||||
#endif
|
||||
#endif //__cplusplus
|
||||
|
||||
#endif // __OPENCV_CORE_INTERNAL_HPP__
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -43,122 +43,132 @@
|
||||
#ifndef __OPENCV_CORE_TYPES_H__
|
||||
#define __OPENCV_CORE_TYPES_H__
|
||||
|
||||
#if !defined _CRT_SECURE_NO_DEPRECATE && _MSC_VER > 1300
|
||||
#define _CRT_SECURE_NO_DEPRECATE /* to avoid multiple Visual Studio 2005 warnings */
|
||||
#if !defined _CRT_SECURE_NO_DEPRECATE && defined _MSC_VER
|
||||
# if _MSC_VER > 1300
|
||||
# define _CRT_SECURE_NO_DEPRECATE /* to avoid multiple Visual Studio 2005 warnings */
|
||||
# endif
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef SKIP_INCLUDES
|
||||
#include <assert.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <float.h>
|
||||
|
||||
#include <assert.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <float.h>
|
||||
|
||||
#if !defined _MSC_VER && !defined __BORLANDC__
|
||||
#include <stdint.h>
|
||||
# include <stdint.h>
|
||||
#endif
|
||||
|
||||
#if defined __ICL
|
||||
#define CV_ICC __ICL
|
||||
#elif defined __ICC
|
||||
#define CV_ICC __ICC
|
||||
#elif defined __ECL
|
||||
#define CV_ICC __ECL
|
||||
#elif defined __ECC
|
||||
#define CV_ICC __ECC
|
||||
#elif defined __INTEL_COMPILER
|
||||
#define CV_ICC __INTEL_COMPILER
|
||||
#endif
|
||||
#if defined __ICL
|
||||
# define CV_ICC __ICL
|
||||
#elif defined __ICC
|
||||
# define CV_ICC __ICC
|
||||
#elif defined __ECL
|
||||
# define CV_ICC __ECL
|
||||
#elif defined __ECC
|
||||
# define CV_ICC __ECC
|
||||
#elif defined __INTEL_COMPILER
|
||||
# define CV_ICC __INTEL_COMPILER
|
||||
#endif
|
||||
|
||||
#if (_MSC_VER >= 1400 && defined _M_X64) || (__GNUC__ >= 4 && defined __x86_64__)
|
||||
#if defined WIN32
|
||||
#include <intrin.h>
|
||||
#endif
|
||||
#if __SSE2__ || !defined __GNUC__
|
||||
#include <emmintrin.h>
|
||||
#endif
|
||||
#endif
|
||||
#if defined CV_ICC && !defined CV_ENABLE_UNROLLED
|
||||
# define CV_ENABLE_UNROLLED 0
|
||||
#else
|
||||
# define CV_ENABLE_UNROLLED 1
|
||||
#endif
|
||||
|
||||
#if defined __BORLANDC__
|
||||
#include <fastmath.h>
|
||||
#else
|
||||
#include <math.h>
|
||||
#endif
|
||||
#if (defined _M_X64 && _MSC_VER >= 1400) || (__GNUC__ >= 4 && defined __x86_64__)
|
||||
# if defined WIN32
|
||||
# include <intrin.h>
|
||||
# endif
|
||||
# if __SSE2__ || !defined __GNUC__
|
||||
# include <emmintrin.h>
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if defined __BORLANDC__
|
||||
# include <fastmath.h>
|
||||
#else
|
||||
# include <math.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_IPL
|
||||
# ifndef __IPL_H__
|
||||
# if defined WIN32 || defined _WIN32
|
||||
# include <ipl.h>
|
||||
# else
|
||||
# include <ipl/ipl.h>
|
||||
# endif
|
||||
# endif
|
||||
#elif defined __IPL_H__
|
||||
# define HAVE_IPL
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_IPL
|
||||
#ifndef __IPL_H__
|
||||
#if defined WIN32 || defined _WIN32
|
||||
#include <ipl.h>
|
||||
#else
|
||||
#include <ipl/ipl.h>
|
||||
#endif
|
||||
#endif
|
||||
#elif defined __IPL_H__
|
||||
#define HAVE_IPL
|
||||
#endif
|
||||
#endif // SKIP_INCLUDES
|
||||
|
||||
#if defined WIN32 || defined _WIN32
|
||||
#define CV_CDECL __cdecl
|
||||
#define CV_STDCALL __stdcall
|
||||
# define CV_CDECL __cdecl
|
||||
# define CV_STDCALL __stdcall
|
||||
#else
|
||||
#define CV_CDECL
|
||||
#define CV_STDCALL
|
||||
# define CV_CDECL
|
||||
# define CV_STDCALL
|
||||
#endif
|
||||
|
||||
#ifndef CV_EXTERN_C
|
||||
#ifdef __cplusplus
|
||||
#define CV_EXTERN_C extern "C"
|
||||
#define CV_DEFAULT(val) = val
|
||||
#else
|
||||
#define CV_EXTERN_C
|
||||
#define CV_DEFAULT(val)
|
||||
#endif
|
||||
# ifdef __cplusplus
|
||||
# define CV_EXTERN_C extern "C"
|
||||
# define CV_DEFAULT(val) = val
|
||||
# else
|
||||
# define CV_EXTERN_C
|
||||
# define CV_DEFAULT(val)
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef CV_EXTERN_C_FUNCPTR
|
||||
#ifdef __cplusplus
|
||||
#define CV_EXTERN_C_FUNCPTR(x) extern "C" { typedef x; }
|
||||
#else
|
||||
#define CV_EXTERN_C_FUNCPTR(x) typedef x
|
||||
#endif
|
||||
# ifdef __cplusplus
|
||||
# define CV_EXTERN_C_FUNCPTR(x) extern "C" { typedef x; }
|
||||
# else
|
||||
# define CV_EXTERN_C_FUNCPTR(x) typedef x
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef CV_INLINE
|
||||
#if defined __cplusplus
|
||||
#define CV_INLINE inline
|
||||
#elif (defined WIN32 || defined _WIN32 || defined WINCE) && !defined __GNUC__
|
||||
#define CV_INLINE __inline
|
||||
#else
|
||||
#define CV_INLINE static
|
||||
#endif
|
||||
# if defined __cplusplus
|
||||
# define CV_INLINE inline
|
||||
# elif (defined WIN32 || defined _WIN32 || defined WINCE) && !defined __GNUC__
|
||||
# define CV_INLINE __inline
|
||||
# else
|
||||
# define CV_INLINE static
|
||||
# endif
|
||||
#endif /* CV_INLINE */
|
||||
|
||||
#if (defined WIN32 || defined _WIN32 || defined WINCE) && defined CVAPI_EXPORTS
|
||||
#define CV_EXPORTS __declspec(dllexport)
|
||||
# define CV_EXPORTS __declspec(dllexport)
|
||||
#else
|
||||
#define CV_EXPORTS
|
||||
# define CV_EXPORTS
|
||||
#endif
|
||||
|
||||
#ifndef CVAPI
|
||||
#define CVAPI(rettype) CV_EXTERN_C CV_EXPORTS rettype CV_CDECL
|
||||
# define CVAPI(rettype) CV_EXTERN_C CV_EXPORTS rettype CV_CDECL
|
||||
#endif
|
||||
|
||||
#if defined _MSC_VER || defined __BORLANDC__
|
||||
typedef __int64 int64;
|
||||
typedef unsigned __int64 uint64;
|
||||
#define CV_BIG_INT(n) n##I64
|
||||
#define CV_BIG_UINT(n) n##UI64
|
||||
typedef __int64 int64;
|
||||
typedef unsigned __int64 uint64;
|
||||
# define CV_BIG_INT(n) n##I64
|
||||
# define CV_BIG_UINT(n) n##UI64
|
||||
#else
|
||||
typedef int64_t int64;
|
||||
typedef uint64_t uint64;
|
||||
#define CV_BIG_INT(n) n##LL
|
||||
#define CV_BIG_UINT(n) n##ULL
|
||||
typedef int64_t int64;
|
||||
typedef uint64_t uint64;
|
||||
# define CV_BIG_INT(n) n##LL
|
||||
# define CV_BIG_UINT(n) n##ULL
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_IPL
|
||||
typedef unsigned char uchar;
|
||||
typedef unsigned short ushort;
|
||||
typedef unsigned char uchar;
|
||||
typedef unsigned short ushort;
|
||||
#endif
|
||||
|
||||
typedef signed char schar;
|
||||
@@ -203,7 +213,7 @@ Cv64suf;
|
||||
|
||||
typedef int CVStatus;
|
||||
|
||||
enum {
|
||||
enum {
|
||||
CV_StsOk= 0, /* everithing is ok */
|
||||
CV_StsBackTrace= -1, /* pseudo error for back trace */
|
||||
CV_StsError= -2, /* unknown /unspecified error */
|
||||
@@ -241,8 +251,8 @@ enum {
|
||||
CV_StsInplaceNotSupported= -203, /* in-place operation is not supported */
|
||||
CV_StsObjectNotFound= -204, /* request can't be completed */
|
||||
CV_StsUnmatchedFormats= -205, /* formats of input/output arrays differ */
|
||||
CV_StsBadFlag= -206, /* flag is wrong or not supported */
|
||||
CV_StsBadPoint= -207, /* bad CvPoint */
|
||||
CV_StsBadFlag= -206, /* flag is wrong or not supported */
|
||||
CV_StsBadPoint= -207, /* bad CvPoint */
|
||||
CV_StsBadMask= -208, /* bad format of mask (neither 8uC1 nor 8sC1)*/
|
||||
CV_StsUnmatchedSizes= -209, /* sizes of input/output structures do not match */
|
||||
CV_StsUnsupportedFormat= -210, /* the data format/type is not supported by the function*/
|
||||
@@ -250,8 +260,8 @@ enum {
|
||||
CV_StsParseError= -212, /* invalid syntax/structure of the parsed file */
|
||||
CV_StsNotImplemented= -213, /* the requested function/feature is not implemented */
|
||||
CV_StsBadMemBlock= -214, /* an allocated block has been corrupted */
|
||||
CV_StsAssert= -215, /* assertion failed */
|
||||
CV_GpuNotSupported= -216,
|
||||
CV_StsAssert= -215, /* assertion failed */
|
||||
CV_GpuNotSupported= -216,
|
||||
CV_GpuApiCallError= -217,
|
||||
CV_OpenGlNotSupported= -218,
|
||||
CV_OpenGlApiCallError= -219
|
||||
@@ -262,7 +272,7 @@ enum {
|
||||
\****************************************************************************************/
|
||||
|
||||
#ifdef HAVE_TEGRA_OPTIMIZATION
|
||||
# include "tegra_round.hpp"
|
||||
# include "tegra_round.hpp"
|
||||
#endif
|
||||
|
||||
#define CV_PI 3.1415926535897932384626433832795
|
||||
@@ -271,11 +281,11 @@ enum {
|
||||
#define CV_SWAP(a,b,t) ((t) = (a), (a) = (b), (b) = (t))
|
||||
|
||||
#ifndef MIN
|
||||
#define MIN(a,b) ((a) > (b) ? (b) : (a))
|
||||
# define MIN(a,b) ((a) > (b) ? (b) : (a))
|
||||
#endif
|
||||
|
||||
#ifndef MAX
|
||||
#define MAX(a,b) ((a) < (b) ? (b) : (a))
|
||||
# define MAX(a,b) ((a) < (b) ? (b) : (a))
|
||||
#endif
|
||||
|
||||
/* min & max without jumps */
|
||||
@@ -285,9 +295,9 @@ enum {
|
||||
|
||||
/* absolute value without jumps */
|
||||
#ifndef __cplusplus
|
||||
#define CV_IABS(a) (((a) ^ ((a) < 0 ? -1 : 0)) - ((a) < 0 ? -1 : 0))
|
||||
# define CV_IABS(a) (((a) ^ ((a) < 0 ? -1 : 0)) - ((a) < 0 ? -1 : 0))
|
||||
#else
|
||||
#define CV_IABS(a) abs(a)
|
||||
# define CV_IABS(a) abs(a)
|
||||
#endif
|
||||
#define CV_CMP(a,b) (((a) > (b)) - ((a) < (b)))
|
||||
#define CV_SIGN(a) CV_CMP((a),0)
|
||||
@@ -306,11 +316,11 @@ CV_INLINE int cvRound( double value )
|
||||
}
|
||||
return t;
|
||||
#elif defined HAVE_LRINT || defined CV_ICC || defined __GNUC__
|
||||
# ifdef HAVE_TEGRA_OPTIMIZATION
|
||||
# ifdef HAVE_TEGRA_OPTIMIZATION
|
||||
TEGRA_ROUND(value);
|
||||
# else
|
||||
# else
|
||||
return (int)lrint(value);
|
||||
# endif
|
||||
# endif
|
||||
#else
|
||||
// while this is not IEEE754-compliant rounding, it's usually a good enough approximation
|
||||
return (int)(value + (value >= 0 ? 0.5 : -0.5));
|
||||
@@ -318,7 +328,7 @@ CV_INLINE int cvRound( double value )
|
||||
}
|
||||
|
||||
#if defined __SSE2__ || (defined _M_IX86_FP && 2 == _M_IX86_FP)
|
||||
#include "emmintrin.h"
|
||||
# include "emmintrin.h"
|
||||
#endif
|
||||
|
||||
CV_INLINE int cvFloor( double value )
|
||||
@@ -1886,6 +1896,6 @@ typedef struct CvModuleInfo
|
||||
}
|
||||
CvModuleInfo;
|
||||
|
||||
#endif /*_CXCORE_TYPES_H_*/
|
||||
#endif /*__OPENCV_CORE_TYPES_H__*/
|
||||
|
||||
/* End of file. */
|
||||
|
@@ -3,7 +3,7 @@
|
||||
|
||||
#include "opencv2/ts/ts.hpp"
|
||||
|
||||
#if GTEST_CREATE_SHARED_LIBRARY
|
||||
#ifdef GTEST_CREATE_SHARED_LIBRARY
|
||||
#error no modules except ts should have GTEST_CREATE_SHARED_LIBRARY defined
|
||||
#endif
|
||||
|
||||
|
@@ -28,11 +28,11 @@ PERF_TEST_P(Size_MatType, mean, TYPICAL_MATS)
|
||||
|
||||
Mat src(sz, type);
|
||||
Scalar s;
|
||||
|
||||
|
||||
declare.in(src, WARMUP_RNG).out(s);
|
||||
|
||||
|
||||
TEST_CYCLE() s = mean(src);
|
||||
|
||||
|
||||
SANITY_CHECK(s, 1e-6);
|
||||
}
|
||||
|
||||
@@ -44,11 +44,11 @@ PERF_TEST_P(Size_MatType, mean_mask, TYPICAL_MATS)
|
||||
Mat src(sz, type);
|
||||
Mat mask = Mat::ones(src.size(), CV_8U);
|
||||
Scalar s;
|
||||
|
||||
|
||||
declare.in(src, WARMUP_RNG).in(mask).out(s);
|
||||
|
||||
|
||||
TEST_CYCLE() s = mean(src, mask);
|
||||
|
||||
|
||||
SANITY_CHECK(s, 1e-6);
|
||||
}
|
||||
|
||||
@@ -64,7 +64,7 @@ PERF_TEST_P(Size_MatType, meanStdDev, TYPICAL_MATS)
|
||||
declare.in(src, WARMUP_RNG).out(mean, dev);
|
||||
|
||||
TEST_CYCLE() meanStdDev(src, mean, dev);
|
||||
|
||||
|
||||
SANITY_CHECK(mean, 1e-6);
|
||||
SANITY_CHECK(dev, 1e-6);
|
||||
}
|
||||
@@ -80,9 +80,9 @@ PERF_TEST_P(Size_MatType, meanStdDev_mask, TYPICAL_MATS)
|
||||
Scalar dev;
|
||||
|
||||
declare.in(src, WARMUP_RNG).in(mask).out(mean, dev);
|
||||
|
||||
|
||||
TEST_CYCLE() meanStdDev(src, mean, dev, mask);
|
||||
|
||||
|
||||
SANITY_CHECK(mean, 1e-6);
|
||||
SANITY_CHECK(dev, 1e-6);
|
||||
}
|
||||
@@ -96,8 +96,8 @@ PERF_TEST_P(Size_MatType, countNonZero, testing::Combine( testing::Values( TYPIC
|
||||
int cnt = 0;
|
||||
|
||||
declare.in(src, WARMUP_RNG);
|
||||
|
||||
|
||||
TEST_CYCLE() cnt = countNonZero(src);
|
||||
|
||||
|
||||
SANITY_CHECK(cnt);
|
||||
}
|
||||
|
@@ -55,7 +55,9 @@ static void* OutOfMemoryError(size_t size)
|
||||
|
||||
#if CV_USE_SYSTEM_MALLOC
|
||||
|
||||
#if defined WIN32 || defined _WIN32
|
||||
void deleteThreadAllocData() {}
|
||||
#endif
|
||||
|
||||
void* fastMalloc( size_t size )
|
||||
{
|
||||
@@ -66,14 +68,14 @@ void* fastMalloc( size_t size )
|
||||
adata[-1] = udata;
|
||||
return adata;
|
||||
}
|
||||
|
||||
|
||||
void fastFree(void* ptr)
|
||||
{
|
||||
if(ptr)
|
||||
{
|
||||
uchar* udata = ((uchar**)ptr)[-1];
|
||||
CV_DbgAssert(udata < (uchar*)ptr &&
|
||||
((uchar*)ptr - udata) <= (ptrdiff_t)(sizeof(void*)+CV_MALLOC_ALIGN));
|
||||
((uchar*)ptr - udata) <= (ptrdiff_t)(sizeof(void*)+CV_MALLOC_ALIGN));
|
||||
free(udata);
|
||||
}
|
||||
}
|
||||
@@ -388,7 +390,7 @@ struct ThreadData
|
||||
|
||||
#ifdef WIN32
|
||||
#ifdef WINCE
|
||||
# define TLS_OUT_OF_INDEXES ((DWORD)0xFFFFFFFF)
|
||||
# define TLS_OUT_OF_INDEXES ((DWORD)0xFFFFFFFF)
|
||||
#endif //WINCE
|
||||
|
||||
static DWORD tlsKey;
|
||||
@@ -535,7 +537,7 @@ void* fastMalloc( size_t size )
|
||||
freePtr = block;
|
||||
if( !data )
|
||||
{
|
||||
block = gcPtr;
|
||||
block = gcPtr;
|
||||
for( int k = 0; k < 2; k++ )
|
||||
{
|
||||
SANITY_CHECK(block);
|
||||
@@ -620,7 +622,7 @@ void fastFree( void* ptr )
|
||||
Block*& startPtr = tls->bins[idx][START];
|
||||
Block*& freePtr = tls->bins[idx][FREE];
|
||||
Block*& gcPtr = tls->bins[idx][GC];
|
||||
|
||||
|
||||
if( block == block->next )
|
||||
{
|
||||
CV_DbgAssert( startPtr == block && freePtr == block && gcPtr == block );
|
||||
|
@@ -974,7 +974,7 @@ void convertAndUnrollScalar( const Mat& sc, int buftype, uchar* scbuf, size_t bl
|
||||
scbuf[i] = scbuf[i - esz];
|
||||
}
|
||||
|
||||
void binary_op(InputArray _src1, InputArray _src2, OutputArray _dst,
|
||||
static void binary_op(InputArray _src1, InputArray _src2, OutputArray _dst,
|
||||
InputArray _mask, const BinaryFunc* tab, bool bitwise)
|
||||
{
|
||||
int kind1 = _src1.kind(), kind2 = _src2.kind();
|
||||
@@ -1216,7 +1216,7 @@ void cv::min(const Mat& src1, double src2, Mat& dst)
|
||||
namespace cv
|
||||
{
|
||||
|
||||
void arithm_op(InputArray _src1, InputArray _src2, OutputArray _dst,
|
||||
static void arithm_op(InputArray _src1, InputArray _src2, OutputArray _dst,
|
||||
InputArray _mask, int dtype, BinaryFunc* tab, bool muldiv=false, void* usrdata=0)
|
||||
{
|
||||
int kind1 = _src1.kind(), kind2 = _src2.kind();
|
||||
|
@@ -6,6 +6,7 @@
|
||||
using namespace std;
|
||||
using namespace cv;
|
||||
|
||||
namespace {
|
||||
void helpParser()
|
||||
{
|
||||
printf("\nThe CommandLineParser class is designed for command line arguments parsing\n"
|
||||
@@ -89,6 +90,8 @@ string del_space(string name)
|
||||
return name;
|
||||
}
|
||||
|
||||
}//namespace
|
||||
|
||||
CommandLineParser::CommandLineParser(int argc, const char* const argv[], const char* keys)
|
||||
{
|
||||
std::string keys_buffer;
|
||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -116,13 +116,13 @@ static void writeMat(std::ostream& out, const Mat& m, char rowsep, char elembrac
|
||||
{
|
||||
CV_Assert(m.dims <= 2);
|
||||
int type = m.type();
|
||||
|
||||
|
||||
char crowbrace = getCloseBrace(rowsep);
|
||||
char orowbrace = crowbrace ? rowsep : '\0';
|
||||
|
||||
|
||||
if( orowbrace || isspace(rowsep) )
|
||||
rowsep = '\0';
|
||||
|
||||
|
||||
for( int i = 0; i < m.rows; i++ )
|
||||
{
|
||||
if(orowbrace)
|
||||
@@ -151,7 +151,7 @@ public:
|
||||
writeMat(out, m, ';', ' ', m.cols == 1);
|
||||
out << "]";
|
||||
}
|
||||
|
||||
|
||||
void write(std::ostream& out, const void* data, int nelems, int type, const int*, int) const
|
||||
{
|
||||
writeElems(out, data, nelems, type, ' ');
|
||||
@@ -168,7 +168,7 @@ public:
|
||||
writeMat(out, m, m.cols > 1 ? '[' : ' ', '[', m.cols*m.channels() == 1);
|
||||
out << "]";
|
||||
}
|
||||
|
||||
|
||||
void write(std::ostream& out, const void* data, int nelems, int type, const int*, int) const
|
||||
{
|
||||
writeElems(out, data, nelems, type, '[');
|
||||
@@ -190,7 +190,7 @@ public:
|
||||
writeMat(out, m, m.cols > 1 ? '[' : ' ', '[', m.cols*m.channels() == 1);
|
||||
out << "], type='" << numpyTypes[m.depth()] << "')";
|
||||
}
|
||||
|
||||
|
||||
void write(std::ostream& out, const void* data, int nelems, int type, const int*, int) const
|
||||
{
|
||||
writeElems(out, data, nelems, type, '[');
|
||||
@@ -208,7 +208,7 @@ public:
|
||||
if(m.rows > 1)
|
||||
out << "\n";
|
||||
}
|
||||
|
||||
|
||||
void write(std::ostream& out, const void* data, int nelems, int type, const int*, int) const
|
||||
{
|
||||
writeElems(out, data, nelems, type, ' ');
|
||||
@@ -226,7 +226,7 @@ public:
|
||||
writeMat(out, m, ',', ' ', m.cols==1);
|
||||
out << "}";
|
||||
}
|
||||
|
||||
|
||||
void write(std::ostream& out, const void* data, int nelems, int type, const int*, int) const
|
||||
{
|
||||
writeElems(out, data, nelems, type, ' ');
|
||||
@@ -243,7 +243,7 @@ static CFormatter cFormatter;
|
||||
static const Formatter* g_defaultFormatter0 = &matlabFormatter;
|
||||
static const Formatter* g_defaultFormatter = &matlabFormatter;
|
||||
|
||||
bool my_streq(const char* a, const char* b)
|
||||
static bool my_streq(const char* a, const char* b)
|
||||
{
|
||||
size_t i, alen = strlen(a), blen = strlen(b);
|
||||
if( alen != blen )
|
||||
@@ -280,7 +280,7 @@ const Formatter* Formatter::setDefault(const Formatter* fmt)
|
||||
g_defaultFormatter = fmt;
|
||||
return prevFmt;
|
||||
}
|
||||
|
||||
|
||||
Formatted::Formatted(const Mat& _m, const Formatter* _fmt,
|
||||
const vector<int>& _params)
|
||||
{
|
||||
@@ -288,12 +288,12 @@ Formatted::Formatted(const Mat& _m, const Formatter* _fmt,
|
||||
fmt = _fmt ? _fmt : Formatter::get();
|
||||
std::copy(_params.begin(), _params.end(), back_inserter(params));
|
||||
}
|
||||
|
||||
|
||||
Formatted::Formatted(const Mat& _m, const Formatter* _fmt, const int* _params)
|
||||
{
|
||||
mtx = _m;
|
||||
fmt = _fmt ? _fmt : Formatter::get();
|
||||
|
||||
|
||||
if( _params )
|
||||
{
|
||||
int i, maxParams = 100;
|
||||
|
@@ -54,7 +54,7 @@ template<typename T> static inline Scalar rawToScalar(const T& v)
|
||||
for( i = 0; i < n; i++ )
|
||||
s.val[i] = ((T1*)&v)[i];
|
||||
return s;
|
||||
}
|
||||
}
|
||||
|
||||
/****************************************************************************************\
|
||||
* sum *
|
||||
@@ -72,7 +72,7 @@ static int sum_(const T* src0, const uchar* mask, ST* dst, int len, int cn )
|
||||
{
|
||||
ST s0 = dst[0];
|
||||
|
||||
#if CV_ENABLE_UNROLLED
|
||||
#if CV_ENABLE_UNROLLED
|
||||
for(; i <= len - 4; i += 4, src += cn*4 )
|
||||
s0 += src[0] + src[cn] + src[cn*2] + src[cn*3];
|
||||
#endif
|
||||
@@ -104,7 +104,7 @@ static int sum_(const T* src0, const uchar* mask, ST* dst, int len, int cn )
|
||||
dst[1] = s1;
|
||||
dst[2] = s2;
|
||||
}
|
||||
|
||||
|
||||
for( ; k < cn; k += 4 )
|
||||
{
|
||||
src = src0 + k;
|
||||
@@ -121,7 +121,7 @@ static int sum_(const T* src0, const uchar* mask, ST* dst, int len, int cn )
|
||||
}
|
||||
return len;
|
||||
}
|
||||
|
||||
|
||||
int i, nzm = 0;
|
||||
if( cn == 1 )
|
||||
{
|
||||
@@ -155,7 +155,7 @@ static int sum_(const T* src0, const uchar* mask, ST* dst, int len, int cn )
|
||||
if( mask[i] )
|
||||
{
|
||||
int k = 0;
|
||||
#if CV_ENABLE_UNROLLED
|
||||
#if CV_ENABLE_UNROLLED
|
||||
for( ; k <= cn - 4; k += 4 )
|
||||
{
|
||||
ST s0, s1;
|
||||
@@ -212,7 +212,7 @@ template<typename T>
|
||||
static int countNonZero_(const T* src, int len )
|
||||
{
|
||||
int i=0, nz = 0;
|
||||
#if CV_ENABLE_UNROLLED
|
||||
#if CV_ENABLE_UNROLLED
|
||||
for(; i <= len - 4; i += 4 )
|
||||
nz += (src[i] != 0) + (src[i+1] != 0) + (src[i+2] != 0) + (src[i+3] != 0);
|
||||
#endif
|
||||
@@ -251,12 +251,12 @@ template<typename T, typename ST, typename SQT>
|
||||
static int sumsqr_(const T* src0, const uchar* mask, ST* sum, SQT* sqsum, int len, int cn )
|
||||
{
|
||||
const T* src = src0;
|
||||
|
||||
|
||||
if( !mask )
|
||||
{
|
||||
int i;
|
||||
int k = cn % 4;
|
||||
|
||||
|
||||
if( k == 1 )
|
||||
{
|
||||
ST s0 = sum[0];
|
||||
@@ -296,7 +296,7 @@ static int sumsqr_(const T* src0, const uchar* mask, ST* sum, SQT* sqsum, int le
|
||||
sum[0] = s0; sum[1] = s1; sum[2] = s2;
|
||||
sqsum[0] = sq0; sqsum[1] = sq1; sqsum[2] = sq2;
|
||||
}
|
||||
|
||||
|
||||
for( ; k < cn; k += 4 )
|
||||
{
|
||||
src = src0 + k;
|
||||
@@ -319,7 +319,7 @@ static int sumsqr_(const T* src0, const uchar* mask, ST* sum, SQT* sqsum, int le
|
||||
}
|
||||
return len;
|
||||
}
|
||||
|
||||
|
||||
int i, nzm = 0;
|
||||
|
||||
if( cn == 1 )
|
||||
@@ -368,7 +368,7 @@ static int sumsqr_(const T* src0, const uchar* mask, ST* sum, SQT* sqsum, int le
|
||||
}
|
||||
}
|
||||
return nzm;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static int sqsum8u( const uchar* src, const uchar* mask, int* sum, int* sqsum, int len, int cn )
|
||||
@@ -407,9 +407,9 @@ cv::Scalar cv::sum( InputArray _src )
|
||||
Mat src = _src.getMat();
|
||||
int k, cn = src.channels(), depth = src.depth();
|
||||
SumFunc func = sumTab[depth];
|
||||
|
||||
|
||||
CV_Assert( cn <= 4 && func != 0 );
|
||||
|
||||
|
||||
const Mat* arrays[] = {&src, 0};
|
||||
uchar* ptrs[1];
|
||||
NAryMatIterator it(arrays, ptrs);
|
||||
@@ -420,7 +420,7 @@ cv::Scalar cv::sum( InputArray _src )
|
||||
int* buf = (int*)&s[0];
|
||||
size_t esz = 0;
|
||||
bool blockSum = depth < CV_32S;
|
||||
|
||||
|
||||
if( blockSum )
|
||||
{
|
||||
intSumBlockSize = depth <= CV_8S ? (1 << 23) : (1 << 15);
|
||||
@@ -459,30 +459,30 @@ int cv::countNonZero( InputArray _src )
|
||||
{
|
||||
Mat src = _src.getMat();
|
||||
CountNonZeroFunc func = countNonZeroTab[src.depth()];
|
||||
|
||||
|
||||
CV_Assert( src.channels() == 1 && func != 0 );
|
||||
|
||||
|
||||
const Mat* arrays[] = {&src, 0};
|
||||
uchar* ptrs[1];
|
||||
NAryMatIterator it(arrays, ptrs);
|
||||
int total = (int)it.size, nz = 0;
|
||||
|
||||
|
||||
for( size_t i = 0; i < it.nplanes; i++, ++it )
|
||||
nz += func( ptrs[0], total );
|
||||
|
||||
|
||||
return nz;
|
||||
}
|
||||
}
|
||||
|
||||
cv::Scalar cv::mean( InputArray _src, InputArray _mask )
|
||||
{
|
||||
Mat src = _src.getMat(), mask = _mask.getMat();
|
||||
CV_Assert( mask.empty() || mask.type() == CV_8U );
|
||||
|
||||
|
||||
int k, cn = src.channels(), depth = src.depth();
|
||||
SumFunc func = sumTab[depth];
|
||||
|
||||
|
||||
CV_Assert( cn <= 4 && func != 0 );
|
||||
|
||||
|
||||
const Mat* arrays[] = {&src, &mask, 0};
|
||||
uchar* ptrs[2];
|
||||
NAryMatIterator it(arrays, ptrs);
|
||||
@@ -493,19 +493,19 @@ cv::Scalar cv::mean( InputArray _src, InputArray _mask )
|
||||
int* buf = (int*)&s[0];
|
||||
bool blockSum = depth <= CV_16S;
|
||||
size_t esz = 0, nz0 = 0;
|
||||
|
||||
|
||||
if( blockSum )
|
||||
{
|
||||
intSumBlockSize = depth <= CV_8S ? (1 << 23) : (1 << 15);
|
||||
blockSize = std::min(blockSize, intSumBlockSize);
|
||||
_buf.allocate(cn);
|
||||
buf = _buf;
|
||||
|
||||
|
||||
for( k = 0; k < cn; k++ )
|
||||
buf[k] = 0;
|
||||
esz = src.elemSize();
|
||||
}
|
||||
|
||||
|
||||
for( size_t i = 0; i < it.nplanes; i++, ++it )
|
||||
{
|
||||
for( j = 0; j < total; j += blockSize )
|
||||
@@ -529,19 +529,19 @@ cv::Scalar cv::mean( InputArray _src, InputArray _mask )
|
||||
}
|
||||
}
|
||||
return s*(nz0 ? 1./nz0 : 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void cv::meanStdDev( InputArray _src, OutputArray _mean, OutputArray _sdv, InputArray _mask )
|
||||
{
|
||||
Mat src = _src.getMat(), mask = _mask.getMat();
|
||||
CV_Assert( mask.empty() || mask.type() == CV_8U );
|
||||
|
||||
|
||||
int k, cn = src.channels(), depth = src.depth();
|
||||
SumSqrFunc func = sumSqrTab[depth];
|
||||
|
||||
|
||||
CV_Assert( func != 0 );
|
||||
|
||||
|
||||
const Mat* arrays[] = {&src, &mask, 0};
|
||||
uchar* ptrs[2];
|
||||
NAryMatIterator it(arrays, ptrs);
|
||||
@@ -552,10 +552,10 @@ void cv::meanStdDev( InputArray _src, OutputArray _mean, OutputArray _sdv, Input
|
||||
int *sbuf = (int*)s, *sqbuf = (int*)sq;
|
||||
bool blockSum = depth <= CV_16S, blockSqSum = depth <= CV_8S;
|
||||
size_t esz = 0;
|
||||
|
||||
|
||||
for( k = 0; k < cn; k++ )
|
||||
s[k] = sq[k] = 0;
|
||||
|
||||
|
||||
if( blockSum )
|
||||
{
|
||||
intSumBlockSize = 1 << 15;
|
||||
@@ -567,7 +567,7 @@ void cv::meanStdDev( InputArray _src, OutputArray _mean, OutputArray _sdv, Input
|
||||
sbuf[k] = sqbuf[k] = 0;
|
||||
esz = src.elemSize();
|
||||
}
|
||||
|
||||
|
||||
for( size_t i = 0; i < it.nplanes; i++, ++it )
|
||||
{
|
||||
for( j = 0; j < total; j += blockSize )
|
||||
@@ -598,14 +598,14 @@ void cv::meanStdDev( InputArray _src, OutputArray _mean, OutputArray _sdv, Input
|
||||
ptrs[1] += bsz;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
double scale = nz0 ? 1./nz0 : 0.;
|
||||
for( k = 0; k < cn; k++ )
|
||||
{
|
||||
s[k] *= scale;
|
||||
sq[k] = std::sqrt(std::max(sq[k]*scale - s[k]*s[k], 0.));
|
||||
}
|
||||
|
||||
|
||||
for( j = 0; j < 2; j++ )
|
||||
{
|
||||
const double* sptr = j == 0 ? s : sq;
|
||||
@@ -640,7 +640,7 @@ minMaxIdx_( const T* src, const uchar* mask, WT* _minVal, WT* _maxVal,
|
||||
{
|
||||
WT minVal = *_minVal, maxVal = *_maxVal;
|
||||
size_t minIdx = *_minIdx, maxIdx = *_maxIdx;
|
||||
|
||||
|
||||
if( !mask )
|
||||
{
|
||||
for( int i = 0; i < len; i++ )
|
||||
@@ -708,7 +708,7 @@ static void minMaxIdx_32f(const float* src, const uchar* mask, float* minval, fl
|
||||
|
||||
static void minMaxIdx_64f(const double* src, const uchar* mask, double* minval, double* maxval,
|
||||
size_t* minidx, size_t* maxidx, int len, size_t startidx )
|
||||
{ minMaxIdx_(src, mask, minval, maxval, minidx, maxidx, len, startidx ); }
|
||||
{ minMaxIdx_(src, mask, minval, maxval, minidx, maxidx, len, startidx ); }
|
||||
|
||||
typedef void (*MinMaxIdxFunc)(const uchar*, const uchar*, int*, int*, size_t*, size_t*, int, size_t);
|
||||
|
||||
@@ -749,16 +749,16 @@ void cv::minMaxIdx(InputArray _src, double* minVal,
|
||||
{
|
||||
Mat src = _src.getMat(), mask = _mask.getMat();
|
||||
int depth = src.depth(), cn = src.channels();
|
||||
|
||||
|
||||
CV_Assert( (cn == 1 && (mask.empty() || mask.type() == CV_8U)) ||
|
||||
(cn >= 1 && mask.empty() && !minIdx && !maxIdx) );
|
||||
MinMaxIdxFunc func = minmaxTab[depth];
|
||||
CV_Assert( func != 0 );
|
||||
|
||||
|
||||
const Mat* arrays[] = {&src, &mask, 0};
|
||||
uchar* ptrs[2];
|
||||
NAryMatIterator it(arrays, ptrs);
|
||||
|
||||
|
||||
size_t minidx = 0, maxidx = 0;
|
||||
int iminval = INT_MAX, imaxval = INT_MIN;
|
||||
float fminval = FLT_MAX, fmaxval = -FLT_MAX;
|
||||
@@ -766,39 +766,39 @@ void cv::minMaxIdx(InputArray _src, double* minVal,
|
||||
size_t startidx = 1;
|
||||
int *minval = &iminval, *maxval = &imaxval;
|
||||
int planeSize = (int)it.size*cn;
|
||||
|
||||
|
||||
if( depth == CV_32F )
|
||||
minval = (int*)&fminval, maxval = (int*)&fmaxval;
|
||||
else if( depth == CV_64F )
|
||||
minval = (int*)&dminval, maxval = (int*)&dmaxval;
|
||||
|
||||
|
||||
for( size_t i = 0; i < it.nplanes; i++, ++it, startidx += planeSize )
|
||||
func( ptrs[0], ptrs[1], minval, maxval, &minidx, &maxidx, planeSize, startidx );
|
||||
|
||||
|
||||
if( minidx == 0 )
|
||||
dminval = dmaxval = 0;
|
||||
else if( depth == CV_32F )
|
||||
dminval = fminval, dmaxval = fmaxval;
|
||||
else if( depth <= CV_32S )
|
||||
dminval = iminval, dmaxval = imaxval;
|
||||
|
||||
|
||||
if( minVal )
|
||||
*minVal = dminval;
|
||||
if( maxVal )
|
||||
*maxVal = dmaxval;
|
||||
|
||||
|
||||
if( minIdx )
|
||||
ofs2idx(src, minidx, minIdx);
|
||||
if( maxIdx )
|
||||
ofs2idx(src, maxidx, maxIdx);
|
||||
}
|
||||
}
|
||||
|
||||
void cv::minMaxLoc( InputArray _img, double* minVal, double* maxVal,
|
||||
Point* minLoc, Point* maxLoc, InputArray mask )
|
||||
{
|
||||
Mat img = _img.getMat();
|
||||
CV_Assert(img.dims <= 2);
|
||||
|
||||
|
||||
minMaxIdx(_img, minVal, maxVal, (int*)minLoc, (int*)maxLoc, mask);
|
||||
if( minLoc )
|
||||
std::swap(minLoc->x, minLoc->y);
|
||||
@@ -821,7 +821,7 @@ float normL2Sqr_(const float* a, const float* b, int n)
|
||||
{
|
||||
float CV_DECL_ALIGNED(16) buf[4];
|
||||
__m128 d0 = _mm_setzero_ps(), d1 = _mm_setzero_ps();
|
||||
|
||||
|
||||
for( ; j <= n - 8; j += 8 )
|
||||
{
|
||||
__m128 t0 = _mm_sub_ps(_mm_loadu_ps(a + j), _mm_loadu_ps(b + j));
|
||||
@@ -834,14 +834,14 @@ float normL2Sqr_(const float* a, const float* b, int n)
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
{
|
||||
for( ; j <= n - 4; j += 4 )
|
||||
{
|
||||
float t0 = a[j] - b[j], t1 = a[j+1] - b[j+1], t2 = a[j+2] - b[j+2], t3 = a[j+3] - b[j+3];
|
||||
d += t0*t0 + t1*t1 + t2*t2 + t3*t3;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
for( ; j < n; j++ )
|
||||
{
|
||||
float t = a[j] - b[j];
|
||||
@@ -861,7 +861,7 @@ float normL1_(const float* a, const float* b, int n)
|
||||
static const int CV_DECL_ALIGNED(16) absbuf[4] = {0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff};
|
||||
__m128 d0 = _mm_setzero_ps(), d1 = _mm_setzero_ps();
|
||||
__m128 absmask = _mm_load_ps((const float*)absbuf);
|
||||
|
||||
|
||||
for( ; j <= n - 8; j += 8 )
|
||||
{
|
||||
__m128 t0 = _mm_sub_ps(_mm_loadu_ps(a + j), _mm_loadu_ps(b + j));
|
||||
@@ -894,12 +894,12 @@ int normL1_(const uchar* a, const uchar* b, int n)
|
||||
if( USE_SSE2 )
|
||||
{
|
||||
__m128i d0 = _mm_setzero_si128();
|
||||
|
||||
|
||||
for( ; j <= n - 16; j += 16 )
|
||||
{
|
||||
__m128i t0 = _mm_loadu_si128((const __m128i*)(a + j));
|
||||
__m128i t1 = _mm_loadu_si128((const __m128i*)(b + j));
|
||||
|
||||
|
||||
d0 = _mm_add_epi32(d0, _mm_sad_epu8(t0, t1));
|
||||
}
|
||||
|
||||
@@ -907,7 +907,7 @@ int normL1_(const uchar* a, const uchar* b, int n)
|
||||
{
|
||||
__m128i t0 = _mm_cvtsi32_si128(*(const int*)(a + j));
|
||||
__m128i t1 = _mm_cvtsi32_si128(*(const int*)(b + j));
|
||||
|
||||
|
||||
d0 = _mm_add_epi32(d0, _mm_sad_epu8(t0, t1));
|
||||
}
|
||||
d = _mm_cvtsi128_si32(_mm_add_epi32(d0, _mm_unpackhi_epi64(d0, d0)));
|
||||
@@ -926,7 +926,7 @@ int normL1_(const uchar* a, const uchar* b, int n)
|
||||
return d;
|
||||
}
|
||||
|
||||
static const uchar popCountTable[] =
|
||||
static const uchar popCountTable[] =
|
||||
{
|
||||
0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4, 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5,
|
||||
1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
|
||||
@@ -962,7 +962,7 @@ static const uchar popCountTable4[] =
|
||||
1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2
|
||||
};
|
||||
|
||||
int normHamming(const uchar* a, int n)
|
||||
static int normHamming(const uchar* a, int n)
|
||||
{
|
||||
int i = 0, result = 0;
|
||||
#if CV_NEON
|
||||
@@ -989,7 +989,7 @@ int normHamming(const uchar* a, int n)
|
||||
result += popCountTable[a[i]];
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
int normHamming(const uchar* a, const uchar* b, int n)
|
||||
{
|
||||
int i = 0, result = 0;
|
||||
@@ -1020,7 +1020,7 @@ int normHamming(const uchar* a, const uchar* b, int n)
|
||||
return result;
|
||||
}
|
||||
|
||||
int normHamming(const uchar* a, int n, int cellSize)
|
||||
static int normHamming(const uchar* a, int n, int cellSize)
|
||||
{
|
||||
if( cellSize == 1 )
|
||||
return normHamming(a, n);
|
||||
@@ -1039,8 +1039,8 @@ int normHamming(const uchar* a, int n, int cellSize)
|
||||
for( ; i < n; i++ )
|
||||
result += tab[a[i]];
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
int normHamming(const uchar* a, const uchar* b, int n, int cellSize)
|
||||
{
|
||||
if( cellSize == 1 )
|
||||
@@ -1053,7 +1053,7 @@ int normHamming(const uchar* a, const uchar* b, int n, int cellSize)
|
||||
else
|
||||
CV_Error( CV_StsBadSize, "bad cell size (not 1, 2 or 4) in normHamming" );
|
||||
int i = 0, result = 0;
|
||||
#if CV_ENABLE_UNROLLED
|
||||
#if CV_ENABLE_UNROLLED
|
||||
for( ; i <= n - 4; i += 4 )
|
||||
result += tab[a[i] ^ b[i]] + tab[a[i+1] ^ b[i+1]] +
|
||||
tab[a[i+2] ^ b[i+2]] + tab[a[i+3] ^ b[i+3]];
|
||||
@@ -1128,7 +1128,7 @@ normL2_(const T* src, const uchar* mask, ST* _result, int len, int cn)
|
||||
}
|
||||
*_result = result;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
template<typename T, typename ST> int
|
||||
normDiffInf_(const T* src1, const T* src2, const uchar* mask, ST* _result, int len, int cn)
|
||||
@@ -1194,7 +1194,7 @@ normDiffL2_(const T* src1, const T* src2, const uchar* mask, ST* _result, int le
|
||||
}
|
||||
*_result = result;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#define CV_DEF_NORM_FUNC(L, suffix, type, ntype) \
|
||||
@@ -1219,7 +1219,7 @@ CV_DEF_NORM_ALL(64f, double, double, double, double)
|
||||
|
||||
|
||||
typedef int (*NormFunc)(const uchar*, const uchar*, uchar*, int, int);
|
||||
typedef int (*NormDiffFunc)(const uchar*, const uchar*, const uchar*, uchar*, int, int);
|
||||
typedef int (*NormDiffFunc)(const uchar*, const uchar*, const uchar*, uchar*, int, int);
|
||||
|
||||
static NormFunc normTab[3][8] =
|
||||
{
|
||||
@@ -1265,11 +1265,11 @@ double cv::norm( InputArray _src, int normType, InputArray _mask )
|
||||
{
|
||||
Mat src = _src.getMat(), mask = _mask.getMat();
|
||||
int depth = src.depth(), cn = src.channels();
|
||||
|
||||
|
||||
normType &= 7;
|
||||
CV_Assert( normType == NORM_INF || normType == NORM_L1 || normType == NORM_L2 || normType == NORM_L2SQR ||
|
||||
((normType == NORM_HAMMING || normType == NORM_HAMMING2) && src.type() == CV_8U) );
|
||||
|
||||
|
||||
if( src.isContinuous() && mask.empty() )
|
||||
{
|
||||
size_t len = src.total()*cn;
|
||||
@@ -1278,7 +1278,7 @@ double cv::norm( InputArray _src, int normType, InputArray _mask )
|
||||
if( depth == CV_32F )
|
||||
{
|
||||
const float* data = src.ptr<float>();
|
||||
|
||||
|
||||
if( normType == NORM_L2 )
|
||||
{
|
||||
double result = 0;
|
||||
@@ -1307,18 +1307,18 @@ double cv::norm( InputArray _src, int normType, InputArray _mask )
|
||||
if( depth == CV_8U )
|
||||
{
|
||||
const uchar* data = src.ptr<uchar>();
|
||||
|
||||
|
||||
if( normType == NORM_HAMMING )
|
||||
return normHamming(data, (int)len);
|
||||
|
||||
|
||||
if( normType == NORM_HAMMING2 )
|
||||
return normHamming(data, (int)len, 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
CV_Assert( mask.empty() || mask.type() == CV_8U );
|
||||
|
||||
|
||||
if( normType == NORM_HAMMING || normType == NORM_HAMMING2 )
|
||||
{
|
||||
if( !mask.empty() )
|
||||
@@ -1328,22 +1328,22 @@ double cv::norm( InputArray _src, int normType, InputArray _mask )
|
||||
return norm(temp, normType);
|
||||
}
|
||||
int cellSize = normType == NORM_HAMMING ? 1 : 2;
|
||||
|
||||
|
||||
const Mat* arrays[] = {&src, 0};
|
||||
uchar* ptrs[1];
|
||||
NAryMatIterator it(arrays, ptrs);
|
||||
int total = (int)it.size;
|
||||
int result = 0;
|
||||
|
||||
|
||||
for( size_t i = 0; i < it.nplanes; i++, ++it )
|
||||
result += normHamming(ptrs[0], total, cellSize);
|
||||
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
NormFunc func = normTab[normType >> 1][depth];
|
||||
CV_Assert( func != 0 );
|
||||
|
||||
|
||||
const Mat* arrays[] = {&src, &mask, 0};
|
||||
uchar* ptrs[2];
|
||||
union
|
||||
@@ -1361,7 +1361,7 @@ double cv::norm( InputArray _src, int normType, InputArray _mask )
|
||||
int isum = 0;
|
||||
int *ibuf = &result.i;
|
||||
size_t esz = 0;
|
||||
|
||||
|
||||
if( blockSum )
|
||||
{
|
||||
intSumBlockSize = (normType == NORM_L1 && depth <= CV_8S ? (1 << 23) : (1 << 15))/cn;
|
||||
@@ -1369,7 +1369,7 @@ double cv::norm( InputArray _src, int normType, InputArray _mask )
|
||||
ibuf = &isum;
|
||||
esz = src.elemSize();
|
||||
}
|
||||
|
||||
|
||||
for( size_t i = 0; i < it.nplanes; i++, ++it )
|
||||
{
|
||||
for( j = 0; j < total; j += blockSize )
|
||||
@@ -1388,7 +1388,7 @@ double cv::norm( InputArray _src, int normType, InputArray _mask )
|
||||
ptrs[1] += bsz;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if( normType == NORM_INF )
|
||||
{
|
||||
if( depth == CV_64F )
|
||||
@@ -1400,7 +1400,7 @@ double cv::norm( InputArray _src, int normType, InputArray _mask )
|
||||
}
|
||||
else if( normType == NORM_L2 )
|
||||
result.d = std::sqrt(result.d);
|
||||
|
||||
|
||||
return result.d;
|
||||
}
|
||||
|
||||
@@ -1409,16 +1409,16 @@ double cv::norm( InputArray _src1, InputArray _src2, int normType, InputArray _m
|
||||
{
|
||||
if( normType & CV_RELATIVE )
|
||||
return norm(_src1, _src2, normType & ~CV_RELATIVE, _mask)/(norm(_src2, normType, _mask) + DBL_EPSILON);
|
||||
|
||||
|
||||
Mat src1 = _src1.getMat(), src2 = _src2.getMat(), mask = _mask.getMat();
|
||||
int depth = src1.depth(), cn = src1.channels();
|
||||
|
||||
|
||||
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) );
|
||||
|
||||
|
||||
if( src1.isContinuous() && src2.isContinuous() && mask.empty() )
|
||||
{
|
||||
size_t len = src1.total()*src1.channels();
|
||||
@@ -1428,7 +1428,7 @@ double cv::norm( InputArray _src1, InputArray _src2, int normType, InputArray _m
|
||||
{
|
||||
const float* data1 = src1.ptr<float>();
|
||||
const float* data2 = src2.ptr<float>();
|
||||
|
||||
|
||||
if( normType == NORM_L2 )
|
||||
{
|
||||
double result = 0;
|
||||
@@ -1456,9 +1456,9 @@ double cv::norm( InputArray _src1, InputArray _src2, int normType, InputArray _m
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
CV_Assert( mask.empty() || mask.type() == CV_8U );
|
||||
|
||||
|
||||
if( normType == NORM_HAMMING || normType == NORM_HAMMING2 )
|
||||
{
|
||||
if( !mask.empty() )
|
||||
@@ -1469,22 +1469,22 @@ double cv::norm( InputArray _src1, InputArray _src2, int normType, InputArray _m
|
||||
return norm(temp, normType);
|
||||
}
|
||||
int cellSize = normType == NORM_HAMMING ? 1 : 2;
|
||||
|
||||
|
||||
const Mat* arrays[] = {&src1, &src2, 0};
|
||||
uchar* ptrs[2];
|
||||
NAryMatIterator it(arrays, ptrs);
|
||||
int total = (int)it.size;
|
||||
int result = 0;
|
||||
|
||||
|
||||
for( size_t i = 0; i < it.nplanes; i++, ++it )
|
||||
result += normHamming(ptrs[0], ptrs[1], total, cellSize);
|
||||
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
NormDiffFunc func = normDiffTab[normType >> 1][depth];
|
||||
CV_Assert( func != 0 );
|
||||
|
||||
|
||||
const Mat* arrays[] = {&src1, &src2, &mask, 0};
|
||||
uchar* ptrs[3];
|
||||
union
|
||||
@@ -1503,7 +1503,7 @@ double cv::norm( InputArray _src1, InputArray _src2, int normType, InputArray _m
|
||||
unsigned isum = 0;
|
||||
unsigned *ibuf = &result.u;
|
||||
size_t esz = 0;
|
||||
|
||||
|
||||
if( blockSum )
|
||||
{
|
||||
intSumBlockSize = normType == NORM_L1 && depth <= CV_8S ? (1 << 23) : (1 << 15);
|
||||
@@ -1511,7 +1511,7 @@ double cv::norm( InputArray _src1, InputArray _src2, int normType, InputArray _m
|
||||
ibuf = &isum;
|
||||
esz = src1.elemSize();
|
||||
}
|
||||
|
||||
|
||||
for( size_t i = 0; i < it.nplanes; i++, ++it )
|
||||
{
|
||||
for( j = 0; j < total; j += blockSize )
|
||||
@@ -1531,7 +1531,7 @@ double cv::norm( InputArray _src1, InputArray _src2, int normType, InputArray _m
|
||||
ptrs[2] += bsz;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if( normType == NORM_INF )
|
||||
{
|
||||
if( depth == CV_64F )
|
||||
@@ -1543,7 +1543,7 @@ double cv::norm( InputArray _src1, InputArray _src2, int normType, InputArray _m
|
||||
}
|
||||
else if( normType == NORM_L2 )
|
||||
result.d = std::sqrt(result.d);
|
||||
|
||||
|
||||
return result.d;
|
||||
}
|
||||
|
||||
@@ -1692,7 +1692,7 @@ static void batchDistL2_32f(const float* src1, const float* src2, size_t step2,
|
||||
typedef void (*BatchDistFunc)(const uchar* src1, const uchar* src2, size_t step2,
|
||||
int nvecs, int len, uchar* dist, const uchar* mask);
|
||||
|
||||
|
||||
|
||||
struct BatchDistInvoker
|
||||
{
|
||||
BatchDistInvoker( const Mat& _src1, const Mat& _src2,
|
||||
@@ -1709,26 +1709,26 @@ struct BatchDistInvoker
|
||||
update = _update;
|
||||
func = _func;
|
||||
}
|
||||
|
||||
|
||||
void operator()(const BlockedRange& range) const
|
||||
{
|
||||
AutoBuffer<int> buf(src2->rows);
|
||||
int* bufptr = buf;
|
||||
|
||||
|
||||
for( int i = range.begin(); i < range.end(); i++ )
|
||||
{
|
||||
func(src1->ptr(i), src2->ptr(), src2->step, src2->rows, src2->cols,
|
||||
K > 0 ? (uchar*)bufptr : dist->ptr(i), mask->data ? mask->ptr(i) : 0);
|
||||
|
||||
|
||||
if( K > 0 )
|
||||
{
|
||||
int* nidxptr = nidx->ptr<int>(i);
|
||||
// since positive float's can be compared just like int's,
|
||||
// we handle both CV_32S and CV_32F cases with a single branch
|
||||
int* distptr = (int*)dist->ptr(i);
|
||||
|
||||
|
||||
int j, k;
|
||||
|
||||
|
||||
for( j = 0; j < src2->rows; j++ )
|
||||
{
|
||||
int d = bufptr[j];
|
||||
@@ -1746,7 +1746,7 @@ struct BatchDistInvoker
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
const Mat *src1;
|
||||
const Mat *src2;
|
||||
Mat *dist;
|
||||
@@ -1756,9 +1756,9 @@ struct BatchDistInvoker
|
||||
int update;
|
||||
BatchDistFunc func;
|
||||
};
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
void cv::batchDistance( InputArray _src1, InputArray _src2,
|
||||
OutputArray _dist, int dtype, OutputArray _nidx,
|
||||
int normType, int K, InputArray _mask,
|
||||
@@ -1769,7 +1769,7 @@ void cv::batchDistance( InputArray _src1, InputArray _src2,
|
||||
CV_Assert( type == src2.type() && src1.cols == src2.cols &&
|
||||
(type == CV_32F || type == CV_8U));
|
||||
CV_Assert( _nidx.needed() == (K > 0) );
|
||||
|
||||
|
||||
if( dtype == -1 )
|
||||
{
|
||||
dtype = normType == NORM_HAMMING || normType == NORM_HAMMING2 ? CV_32S : CV_32F;
|
||||
@@ -1777,7 +1777,7 @@ void cv::batchDistance( InputArray _src1, InputArray _src2,
|
||||
CV_Assert( (type == CV_8U && dtype == CV_32S) || dtype == CV_32F);
|
||||
|
||||
K = std::min(K, src2.rows);
|
||||
|
||||
|
||||
_dist.create(src1.rows, (K > 0 ? K : src2.rows), dtype);
|
||||
Mat dist = _dist.getMat(), nidx;
|
||||
if( _nidx.needed() )
|
||||
@@ -1785,19 +1785,19 @@ void cv::batchDistance( InputArray _src1, InputArray _src2,
|
||||
_nidx.create(dist.size(), CV_32S);
|
||||
nidx = _nidx.getMat();
|
||||
}
|
||||
|
||||
|
||||
if( update == 0 && K > 0 )
|
||||
{
|
||||
dist = Scalar::all(dtype == CV_32S ? (double)INT_MAX : (double)FLT_MAX);
|
||||
nidx = Scalar::all(-1);
|
||||
}
|
||||
|
||||
|
||||
if( crosscheck )
|
||||
{
|
||||
CV_Assert( K == 1 && update == 0 && mask.empty() );
|
||||
Mat tdist, tidx;
|
||||
batchDistance(src2, src1, tdist, dtype, tidx, normType, K, mask, 0, false);
|
||||
|
||||
|
||||
// if an idx-th element from src1 appeared to be the nearest to i-th element of src2,
|
||||
// we update the minimum mutual distance between idx-th element of src1 and the whole src2 set.
|
||||
// As a result, if nidx[idx] = i*, it means that idx-th element of src1 is the nearest
|
||||
@@ -1832,7 +1832,7 @@ void cv::batchDistance( InputArray _src1, InputArray _src2,
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
BatchDistFunc func = 0;
|
||||
if( type == CV_8U )
|
||||
{
|
||||
@@ -1860,12 +1860,12 @@ void cv::batchDistance( InputArray _src1, InputArray _src2,
|
||||
else if( normType == NORM_L2 )
|
||||
func = (BatchDistFunc)batchDistL2_32f;
|
||||
}
|
||||
|
||||
|
||||
if( func == 0 )
|
||||
CV_Error_(CV_StsUnsupportedFormat,
|
||||
("The combination of type=%d, dtype=%d and normType=%d is not supported",
|
||||
type, dtype, normType));
|
||||
|
||||
|
||||
parallel_for(BlockedRange(0, src1.rows),
|
||||
BatchDistInvoker(src1, src2, dist, nidx, K, mask, update, func));
|
||||
}
|
||||
|
@@ -88,7 +88,7 @@
|
||||
#if defined __linux__ || defined __APPLE__
|
||||
#include <unistd.h>
|
||||
#include <stdio.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/types.h>
|
||||
#if defined ANDROID
|
||||
#include <sys/sysconf.h>
|
||||
#else
|
||||
@@ -111,7 +111,7 @@ Exception::~Exception() throw() {}
|
||||
|
||||
/*!
|
||||
\return the error description and the context as a text string.
|
||||
*/
|
||||
*/
|
||||
const char* Exception::what() const throw() { return msg.c_str(); }
|
||||
|
||||
void Exception::formatMessage()
|
||||
@@ -121,7 +121,7 @@ void Exception::formatMessage()
|
||||
else
|
||||
msg = format("%s:%d: error: (%d) %s\n", file.c_str(), line, code, err.c_str());
|
||||
}
|
||||
|
||||
|
||||
struct HWFeatures
|
||||
{
|
||||
enum { MAX_FEATURE = CV_HARDWARE_MAX_FEATURE };
|
||||
@@ -374,7 +374,7 @@ int getThreadNum(void)
|
||||
#endif
|
||||
}
|
||||
|
||||
#if ANDROID
|
||||
#ifdef ANDROID
|
||||
static inline int getNumberOfCPUsImpl()
|
||||
{
|
||||
FILE* cpuPossible = fopen("/sys/devices/system/cpu/possible", "r");
|
||||
@@ -408,7 +408,7 @@ static inline int getNumberOfCPUsImpl()
|
||||
sscanf(pos, "%d-%d", &rstart, &rend);
|
||||
cpusAvailable += rend - rstart + 1;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
return cpusAvailable ? cpusAvailable : 1;
|
||||
}
|
||||
@@ -419,9 +419,9 @@ int getNumberOfCPUs(void)
|
||||
#if defined WIN32 || defined _WIN32
|
||||
SYSTEM_INFO sysinfo;
|
||||
GetSystemInfo( &sysinfo );
|
||||
|
||||
|
||||
return (int)sysinfo.dwNumberOfProcessors;
|
||||
#elif ANDROID
|
||||
#elif defined ANDROID
|
||||
static int ncpus = getNumberOfCPUsImpl();
|
||||
printf("CPUS= %d\n", ncpus);
|
||||
return ncpus;
|
||||
@@ -430,24 +430,24 @@ int getNumberOfCPUs(void)
|
||||
#elif defined __APPLE__
|
||||
int numCPU=0;
|
||||
int mib[4];
|
||||
size_t len = sizeof(numCPU);
|
||||
|
||||
size_t len = sizeof(numCPU);
|
||||
|
||||
/* set the mib for hw.ncpu */
|
||||
mib[0] = CTL_HW;
|
||||
mib[1] = HW_AVAILCPU; // alternatively, try HW_NCPU;
|
||||
|
||||
|
||||
/* get the number of CPUs from the system */
|
||||
sysctl(mib, 2, &numCPU, &len, NULL, 0);
|
||||
|
||||
if( numCPU < 1 )
|
||||
|
||||
if( numCPU < 1 )
|
||||
{
|
||||
mib[1] = HW_NCPU;
|
||||
sysctl( mib, 2, &numCPU, &len, NULL, 0 );
|
||||
|
||||
|
||||
if( numCPU < 1 )
|
||||
numCPU = 1;
|
||||
}
|
||||
|
||||
|
||||
return (int)numCPU;
|
||||
#else
|
||||
return 1;
|
||||
@@ -475,7 +475,7 @@ string tempfile( const char* suffix )
|
||||
{
|
||||
char buf[L_tmpnam];
|
||||
char* name = 0;
|
||||
#if ANDROID
|
||||
#ifdef ANDROID
|
||||
strcpy(buf, "/sdcard/__opencv_temp_XXXXXX");
|
||||
name = mktemp(buf);
|
||||
#else
|
||||
|
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user