Drop outdated definitions from internal.hpp

This also fixes few clang build errors
pull/747/head
Andrey Kamaev 12 years ago
parent 605382562d
commit 3890a74565
  1. 2
      apps/haartraining/cvhaartraining.cpp
  2. 2
      modules/calib3d/src/calibration.cpp
  3. 2
      modules/calib3d/src/stereobm.cpp
  4. 8
      modules/core/include/opencv2/core/base.hpp
  5. 9
      modules/core/include/opencv2/core/core_c.h
  6. 249
      modules/core/include/opencv2/core/internal.hpp
  7. 2
      modules/core/include/opencv2/core/mat.inl.hpp
  8. 2
      modules/core/include/opencv2/core/matx.hpp
  9. 18
      modules/core/src/array.cpp
  10. 4
      modules/core/src/drawing.cpp
  11. 11
      modules/core/src/opengl_interop.cpp
  12. 16
      modules/core/src/persistence.cpp
  13. 4
      modules/core/src/stat.cpp
  14. 2
      modules/highgui/src/cap_dshow.cpp
  15. 12
      modules/highgui/src/cap_gstreamer.cpp
  16. 2
      modules/highgui/src/cap_qt.cpp
  17. 21
      modules/highgui/src/grfmt_exr.cpp
  18. 16
      modules/highgui/src/grfmt_jpeg2000.cpp
  19. 2
      modules/highgui/src/utils.cpp
  20. 3
      modules/highgui/src/window_w32.cpp
  21. 46
      modules/imgproc/src/demosaicing.cpp
  22. 2
      modules/imgproc/src/distransform.cpp
  23. 121
      modules/imgproc/src/geometry.cpp
  24. 2
      modules/imgproc/src/smooth.cpp
  25. 9
      modules/imgproc/src/templmatch.cpp
  26. 2
      modules/legacy/src/createhandmask.cpp
  27. 64
      modules/legacy/src/eigenobjects.cpp
  28. 4
      modules/legacy/src/pyrsegmentation.cpp
  29. 2
      modules/legacy/src/snakes.cpp
  30. 16
      modules/legacy/src/testseq.cpp
  31. 52
      modules/legacy/src/vecfacetracking.cpp
  32. 16
      modules/objdetect/src/linemod.cpp
  33. 146
      modules/video/src/affineflow.cpp
  34. 2
      samples/cpp/kalman.cpp

@ -2676,7 +2676,7 @@ void cvCreateTreeCascadeClassifier( const char* dirname,
CvSplit* curSplit;
CV_CALL( curSplit = (CvSplit*) cvAlloc( sizeof( *curSplit ) ) );
CV_ZERO_OBJ( curSplit );
memset(curSplit, 0, sizeof(*curSplit));
if( last_split ) last_split->next = curSplit;
else first_split = curSplit;

@ -2688,7 +2688,7 @@ void cv::reprojectImageTo3D( InputArray _disparity,
for( x = 0; x < cols*3; x++ )
{
int ival = cvRound(dptr[x]);
dptr0[x] = CV_CAST_16S(ival);
dptr0[x] = cv::saturate_cast<short>(ival);
}
}
else if( dtype == CV_32SC3 )

@ -183,7 +183,7 @@ prefilterXSobel( const Mat& src, Mat& dst, int ftzero )
if( useSIMD )
{
__m128i z = _mm_setzero_si128(), ftz = _mm_set1_epi16((short)ftzero),
ftz2 = _mm_set1_epi8(CV_CAST_8U(ftzero*2));
ftz2 = _mm_set1_epi8(cv::saturate_cast<uchar>(ftzero*2));
for( ; x <= size.width-9; x += 8 )
{
__m128i c0 = _mm_unpacklo_epi8(_mm_loadl_epi64((__m128i*)(srow0 + x - 1)), z);

@ -184,11 +184,9 @@ enum { DFT_INVERSE = 1,
# if defined(__GNUC__) && (__GNUC__ > 3) && (__GNUC_MINOR__ > 2)
# define CV_StaticAssert(condition, reason) ({ extern int __attribute__((error("CV_StaticAssert: " reason " " #condition))) CV_StaticAssert(); ((condition) ? 0 : CV_StaticAssert()); })
# else
namespace cv {
template <bool x> struct CV_StaticAssert_failed;
template <> struct CV_StaticAssert_failed<true> { enum { val = 1 }; };
template<int x> struct CV_StaticAssert_test{};
}
template <bool x> struct CV_StaticAssert_failed;
template <> struct CV_StaticAssert_failed<true> { enum { val = 1 }; };
template<int x> struct CV_StaticAssert_test {};
# define CV_StaticAssert(condition, reason)\
typedef cv::CV_StaticAssert_test< sizeof(cv::CV_StaticAssert_failed< static_cast<bool>(condition) >) > CVAUX_CONCAT(CV_StaticAssert_failed_at_, __LINE__)
# endif

@ -47,15 +47,20 @@
#include "opencv2/core/types_c.h"
#ifdef __cplusplus
#ifdef _MSC_VER
# ifdef _MSC_VER
/* disable warning C4190: 'function' has C-linkage specified, but returns UDT 'typename'
which is incompatible with C
It is OK to disable it because we only extend few plain structures with
C++ construrtors for simpler interoperability with C++ API of the library
*/
# pragma warning(disable:4190)
# pragma warning(disable:4190)
# elif defined __clang__ && __clang_major__ >= 3
# pragma GCC diagnostic ignored "-Wreturn-type-c-linkage"
# endif
#endif
#ifdef __cplusplus
extern "C" {
#endif

@ -48,40 +48,6 @@
#ifndef __OPENCV_CORE_INTERNAL_HPP__
#define __OPENCV_CORE_INTERNAL_HPP__
#include <vector>
#if defined WIN32 || defined _WIN32
# ifndef WIN32
# define WIN32
# endif
# ifndef _WIN32
# define _WIN32
# endif
#endif
#if !defined WIN32 && !defined WINCE
# 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_
#endif
#ifndef FALSE
# define FALSE 0
#endif
#ifndef TRUE
# define TRUE 1
#endif
#define __BEGIN__ __CV_BEGIN__
#define __END__ __CV_END__
#define EXIT __CV_EXIT__
@ -100,70 +66,6 @@ CV_INLINE IppiSize ippiSize(int width, int height)
# define IPPI_CALL(func) CV_Assert((func) >= 0)
#endif
#if defined __SSE2__ || defined _M_X64 || (defined _M_IX86_FP && _M_IX86_FP >= 2)
# include "emmintrin.h"
# define CV_SSE 1
# define CV_SSE2 1
# if defined __SSE3__ || (defined _MSC_VER && _MSC_VER >= 1500)
# include "pmmintrin.h"
# define CV_SSE3 1
# endif
# if defined __SSSE3__ || (defined _MSC_VER && _MSC_VER >= 1500)
# include "tmmintrin.h"
# define CV_SSSE3 1
# endif
# if defined __SSE4_1__ || (defined _MSC_VER && _MSC_VER >= 1500)
# include <smmintrin.h>
# define CV_SSE4_1 1
# endif
# if defined __SSE4_2__ || (defined _MSC_VER && _MSC_VER >= 1500)
# include <nmmintrin.h>
# define CV_SSE4_2 1
# endif
# if defined __AVX__ || (defined _MSC_FULL_VER && _MSC_FULL_VER >= 160040219)
// MS Visual Studio 2010 (2012?) has no macro pre-defined to identify the use of /arch:AVX
// See: http://connect.microsoft.com/VisualStudio/feedback/details/605858/arch-avx-should-define-a-predefined-macro-in-x64-and-set-a-unique-value-for-m-ix86-fp-in-win32
# include <immintrin.h>
# define CV_AVX 1
# if defined(_XCR_XFEATURE_ENABLED_MASK)
# define __xgetbv() _xgetbv(_XCR_XFEATURE_ENABLED_MASK)
# else
# define __xgetbv() 0
# endif
# endif
#endif
#ifdef __ARM_NEON__
# include <arm_neon.h>
# define CV_NEON 1
# define CPU_HAS_NEON_FEATURE (true)
#endif
#ifndef CV_SSE
# define CV_SSE 0
#endif
#ifndef CV_SSE2
# define CV_SSE2 0
#endif
#ifndef CV_SSE3
# define CV_SSE3 0
#endif
#ifndef CV_SSSE3
# define CV_SSSE3 0
#endif
#ifndef CV_SSE4_1
# define CV_SSE4_1 0
#endif
#ifndef CV_SSE4_2
# define CV_SSE4_2 0
#endif
#ifndef CV_AVX
# define CV_AVX 0
#endif
#ifndef CV_NEON
# define CV_NEON 0
#endif
#ifdef HAVE_TBB
# include "tbb/tbb_stddef.h"
# if TBB_VERSION_MAJOR*100 + TBB_VERSION_MINOR >= 202
@ -198,12 +100,6 @@ namespace cv
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
@ -213,7 +109,6 @@ namespace cv
}
typedef tbb::concurrent_vector<Rect> ConcurrentRectVector;
typedef tbb::concurrent_vector<double> ConcurrentDoubleVector;
#else
class BlockedRange
{
@ -234,14 +129,6 @@ namespace cv
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 {};
@ -282,26 +169,9 @@ namespace cv
#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
/* maximal linear size of matrix to allocate it on stack. */
#define CV_MAX_LOCAL_MAT_SIZE 32
/* maximal size of local memory storage */
#define CV_MAX_LOCAL_SIZE \
(CV_MAX_LOCAL_MAT_SIZE*CV_MAX_LOCAL_MAT_SIZE*(int)sizeof(double))
/* default image row align (in bytes) */
#define CV_DEFAULT_IMAGE_ROW_ALIGN 4
/* matrices are continuous by default */
#define CV_DEFAULT_MAT_ROW_ALIGN 1
/* maximum size of dynamic memory buffer.
cvAlloc reports an error if a larger block is requested. */
#define CV_MAX_ALLOC_SIZE (((size_t)1 << (sizeof(size_t)*8-2)))
/* the alignment of all the allocated buffers */
#define CV_MALLOC_ALIGN 16
@ -320,38 +190,10 @@ namespace cv
/* maximal average node_count/hash_size ratio beyond which hash table is resized */
#define CV_SPARSE_HASH_RATIO 3
/* max length of strings */
#define CV_MAX_STRLEN 1024
#if 0 /*def CV_CHECK_FOR_NANS*/
# define CV_CHECK_NANS( arr ) cvCheckArray((arr))
#else
# define CV_CHECK_NANS( arr )
#endif
/****************************************************************************************\
* Common declarations *
\****************************************************************************************/
/* get alloca declaration */
#ifdef __GNUC__
# 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
#elif defined HAVE_ALLOCA_H
# include <alloca.h>
# define CV_HAVE_ALLOCA 1
#elif defined HAVE_ALLOCA
# include <stdlib.h>
# define CV_HAVE_ALLOCA 1
#else
# undef CV_HAVE_ALLOCA
#endif
#ifdef __GNUC__
# define CV_DECL_ALIGNED(x) __attribute__ ((aligned (x)))
#elif defined _MSC_VER
@ -360,77 +202,20 @@ namespace cv
# 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 )
#endif
#ifndef CV_IMPL
# define CV_IMPL CV_EXTERN_C
#endif
#define CV_DBG_BREAK() { volatile int* crashMe = 0; *crashMe = 0; }
/* default step, set in case of continuous data
to work around checks for valid step in some ipp functions */
#define CV_STUB_STEP (1 << 30)
#define CV_SIZEOF_FLOAT ((int)sizeof(float))
#define CV_SIZEOF_SHORT ((int)sizeof(short))
#define CV_ORIGIN_TL 0
#define CV_ORIGIN_BL 1
/* IEEE754 constants and macros */
#define CV_POS_INF 0x7f800000
#define CV_NEG_INF 0x807fffff /* CV_TOGGLE_FLT(0xff800000) */
#define CV_1F 0x3f800000
#define CV_TOGGLE_FLT(x) ((x)^((int)(x) < 0 ? 0x7fffffff : 0))
#define CV_TOGGLE_DBL(x) \
((x)^((int64)(x) < 0 ? CV_BIG_INT(0x7fffffffffffffff) : 0))
#define CV_NOP(a) (a)
#define CV_ADD(a, b) ((a) + (b))
#define CV_SUB(a, b) ((a) - (b))
#define CV_MUL(a, b) ((a) * (b))
#define CV_AND(a, b) ((a) & (b))
#define CV_OR(a, b) ((a) | (b))
#define CV_XOR(a, b) ((a) ^ (b))
#define CV_ANDN(a, b) (~(a) & (b))
#define CV_ORN(a, b) (~(a) | (b))
#define CV_SQR(a) ((a) * (a))
//TODO: remove after dropping sorts
#define CV_LT(a, b) ((a) < (b))
#define CV_LE(a, b) ((a) <= (b))
#define CV_EQ(a, b) ((a) == (b))
#define CV_NE(a, b) ((a) != (b))
#define CV_GT(a, b) ((a) > (b))
#define CV_GE(a, b) ((a) >= (b))
#define CV_NONZERO(a) ((a) != 0)
#define CV_NONZERO_FLT(a) (((a)+(a)) != 0)
/* general-purpose saturation macros */
#define CV_CAST_8U(t) (uchar)(!((t) & ~255) ? (t) : (t) > 0 ? 255 : 0)
#define CV_CAST_8S(t) (schar)(!(((t)+128) & ~255) ? (t) : (t) > 0 ? 127 : -128)
#define CV_CAST_16U(t) (ushort)(!((t) & ~65535) ? (t) : (t) > 0 ? 65535 : 0)
#define CV_CAST_16S(t) (short)(!(((t)+32768) & ~65535) ? (t) : (t) > 0 ? 32767 : -32768)
#define CV_CAST_32S(t) (int)(t)
#define CV_CAST_64S(t) (int64)(t)
#define CV_CAST_32F(t) (float)(t)
#define CV_CAST_64F(t) (double)(t)
#define CV_PASTE2(a,b) a##b
#define CV_PASTE(a,b) CV_PASTE2(a,b)
#define CV_EMPTY
#define CV_MAKE_STR(a) #a
#define CV_ZERO_OBJ(x) memset((x), 0, sizeof(*(x)))
#define CV_DIM(static_array) ((int)(sizeof(static_array)/sizeof((static_array)[0])))
#define cvUnsupportedFormat "Unsupported format"
CV_INLINE void* cvAlignPtr( const void* ptr, int align CV_DEFAULT(32) )
{
@ -499,36 +284,4 @@ typedef enum CvStatus
}
CvStatus;
#define CV_NOTHROW throw()
typedef struct CvFuncTable
{
void* fn_2d[CV_DEPTH_MAX];
}
CvFuncTable;
typedef struct CvBigFuncTable
{
void* fn_2d[CV_DEPTH_MAX*4];
} CvBigFuncTable;
#define CV_INIT_FUNC_TAB( tab, FUNCNAME, FLAG ) \
(tab).fn_2d[CV_8U] = (void*)FUNCNAME##_8u##FLAG; \
(tab).fn_2d[CV_8S] = 0; \
(tab).fn_2d[CV_16U] = (void*)FUNCNAME##_16u##FLAG; \
(tab).fn_2d[CV_16S] = (void*)FUNCNAME##_16s##FLAG; \
(tab).fn_2d[CV_32S] = (void*)FUNCNAME##_32s##FLAG; \
(tab).fn_2d[CV_32F] = (void*)FUNCNAME##_32f##FLAG; \
(tab).fn_2d[CV_64F] = (void*)FUNCNAME##_64f##FLAG
namespace cv { namespace ogl {
CV_EXPORTS bool checkError(const char* file, const int line, const char* func = "");
}}
#if defined(__GNUC__)
#define CV_CheckGlError() CV_DbgAssert( (cv::ogl::checkError(__FILE__, __LINE__, __func__)) )
#else
#define CV_CheckGlError() CV_DbgAssert( (cv::ogl::checkError(__FILE__, __LINE__)) )
#endif
#endif // __OPENCV_CORE_INTERNAL_HPP__

@ -122,7 +122,7 @@ template<typename _Tp> inline
_OutputArray::_OutputArray(const std::vector<_Tp>& vec)
: _InputArray(vec)
{
flags |= FIXED_SIZE
flags |= FIXED_SIZE;
}
template<typename _Tp> inline

@ -956,7 +956,7 @@ Vec<double, 4> Vec<double, 4>::conj() const
template<typename _Tp, int cn> inline
Vec<_Tp, cn> Vec<_Tp, cn>::cross(const Vec<_Tp, cn>&) const
{
CV_StaticAssert(false, "for arbitrary-size vector there is no cross-product defined");
CV_StaticAssert(cn == 3, "for arbitrary-size vector there is no cross-product defined");
return Vec<_Tp, cn>();
}

@ -1464,28 +1464,28 @@ cvScalarToRawData( const CvScalar* scalar, void* data, int type, int extend_to_1
while( cn-- )
{
int t = cvRound( scalar->val[cn] );
((uchar*)data)[cn] = CV_CAST_8U(t);
((uchar*)data)[cn] = cv::saturate_cast<uchar>(t);
}
break;
case CV_8SC1:
while( cn-- )
{
int t = cvRound( scalar->val[cn] );
((char*)data)[cn] = CV_CAST_8S(t);
((char*)data)[cn] = cv::saturate_cast<schar>(t);
}
break;
case CV_16UC1:
while( cn-- )
{
int t = cvRound( scalar->val[cn] );
((ushort*)data)[cn] = CV_CAST_16U(t);
((ushort*)data)[cn] = cv::saturate_cast<ushort>(t);
}
break;
case CV_16SC1:
while( cn-- )
{
int t = cvRound( scalar->val[cn] );
((short*)data)[cn] = CV_CAST_16S(t);
((short*)data)[cn] = cv::saturate_cast<short>(t);
}
break;
case CV_32SC1:
@ -1602,19 +1602,19 @@ static void icvSetReal( double value, const void* data, int type )
switch( type )
{
case CV_8U:
*(uchar*)data = CV_CAST_8U(ivalue);
*(uchar*)data = cv::saturate_cast<uchar>(ivalue);
break;
case CV_8S:
*(char*)data = CV_CAST_8S(ivalue);
*(schar*)data = cv::saturate_cast<schar>(ivalue);
break;
case CV_16U:
*(ushort*)data = CV_CAST_16U(ivalue);
*(ushort*)data = cv::saturate_cast<ushort>(ivalue);
break;
case CV_16S:
*(short*)data = CV_CAST_16S(ivalue);
*(short*)data = cv::saturate_cast<short>(ivalue);
break;
case CV_32S:
*(int*)data = CV_CAST_32S(ivalue);
*(int*)data = cv::saturate_cast<int>(ivalue);
break;
}
}

@ -2343,7 +2343,7 @@ cvColorToScalar( double packed_color, int type )
}
else
{
scalar.val[0] = CV_CAST_8U( icolor );
scalar.val[0] = cv::saturate_cast<uchar>( icolor );
scalar.val[1] = scalar.val[2] = scalar.val[3] = 0;
}
}
@ -2359,7 +2359,7 @@ cvColorToScalar( double packed_color, int type )
}
else
{
scalar.val[0] = CV_CAST_8S( icolor );
scalar.val[0] = cv::saturate_cast<schar>( icolor );
scalar.val[1] = scalar.val[2] = scalar.val[3] = 0;
}
}

@ -69,9 +69,8 @@ namespace
void throw_nocuda() { CV_Error(CV_StsNotImplemented, "The called functionality is disabled for current build or platform"); }
#endif
#endif
}
bool cv::ogl::checkError(const char* file, const int line, const char* func)
bool checkError(const char* file, const int line, const char* func = 0)
{
#ifndef HAVE_OPENGL
(void) file;
@ -116,6 +115,14 @@ bool cv::ogl::checkError(const char* file, const int line, const char* func)
#endif
}
#if defined(__GNUC__)
#define CV_CheckGlError() CV_DbgAssert( (checkError(__FILE__, __LINE__, __func__)) )
#else
#define CV_CheckGlError() CV_DbgAssert( (checkError(__FILE__, __LINE__)) )
#endif
} // namespace
#ifdef HAVE_OPENGL
namespace
{

@ -3246,19 +3246,19 @@ cvReadRawDataSlice( const CvFileStorage* fs, CvSeqReader* reader,
switch( elem_type )
{
case CV_8U:
*(uchar*)data = CV_CAST_8U(ival);
*(uchar*)data = cv::saturate_cast<uchar>(ival);
data++;
break;
case CV_8S:
*(char*)data = CV_CAST_8S(ival);
*(char*)data = cv::saturate_cast<schar>(ival);
data++;
break;
case CV_16U:
*(ushort*)data = CV_CAST_16U(ival);
*(ushort*)data = cv::saturate_cast<ushort>(ival);
data += sizeof(ushort);
break;
case CV_16S:
*(short*)data = CV_CAST_16S(ival);
*(short*)data = cv::saturate_cast<short>(ival);
data += sizeof(short);
break;
case CV_32S:
@ -3291,22 +3291,22 @@ cvReadRawDataSlice( const CvFileStorage* fs, CvSeqReader* reader,
{
case CV_8U:
ival = cvRound(fval);
*(uchar*)data = CV_CAST_8U(ival);
*(uchar*)data = cv::saturate_cast<uchar>(ival);
data++;
break;
case CV_8S:
ival = cvRound(fval);
*(char*)data = CV_CAST_8S(ival);
*(char*)data = cv::saturate_cast<schar>(ival);
data++;
break;
case CV_16U:
ival = cvRound(fval);
*(ushort*)data = CV_CAST_16U(ival);
*(ushort*)data = cv::saturate_cast<ushort>(ival);
data += sizeof(ushort);
break;
case CV_16S:
ival = cvRound(fval);
*(short*)data = CV_CAST_16S(ival);
*(short*)data = cv::saturate_cast<short>(ival);
data += sizeof(short);
break;
case CV_32S:

@ -999,7 +999,6 @@ static int normHamming(const uchar* a, int n)
{
int i = 0, result = 0;
#if CV_NEON
if (CPU_HAS_NEON_FEATURE)
{
uint32x4_t bits = vmovq_n_u32(0);
for (; i <= n - 16; i += 16) {
@ -1013,7 +1012,6 @@ static int normHamming(const uchar* a, int n)
result = vgetq_lane_s32 (vreinterpretq_s32_u64(bitSet2),0);
result += vgetq_lane_s32 (vreinterpretq_s32_u64(bitSet2),2);
}
else
#endif
for( ; i <= n - 4; i += 4 )
result += popCountTable[a[i]] + popCountTable[a[i+1]] +
@ -1027,7 +1025,6 @@ int normHamming(const uchar* a, const uchar* b, int n)
{
int i = 0, result = 0;
#if CV_NEON
if (CPU_HAS_NEON_FEATURE)
{
uint32x4_t bits = vmovq_n_u32(0);
for (; i <= n - 16; i += 16) {
@ -1043,7 +1040,6 @@ int normHamming(const uchar* a, const uchar* b, int n)
result = vgetq_lane_s32 (vreinterpretq_s32_u64(bitSet2),0);
result += vgetq_lane_s32 (vreinterpretq_s32_u64(bitSet2),2);
}
else
#endif
for( ; i <= n - 4; i += 4 )
result += popCountTable[a[i] ^ b[i]] + popCountTable[a[i+1] ^ b[i+1]] +

@ -87,8 +87,6 @@ Thanks to:
*/
/////////////////////////////////////////////////////////
#include "precomp.hpp"
#if defined _MSC_VER && _MSC_VER >= 100
//'sprintf': name was marked as #pragma deprecated
#pragma warning(disable: 4995)

@ -103,8 +103,8 @@ private:
gst_initializer()
{
gst_init(NULL, NULL);
// gst_debug_set_active(TRUE);
// gst_debug_set_colored(TRUE);
// gst_debug_set_active(1);
// gst_debug_set_colored(1);
// gst_debug_set_default_threshold(GST_LEVEL_INFO);
}
};
@ -701,7 +701,7 @@ bool CvCapture_GStreamer::open( int type, const char* filename )
gst_app_sink_set_max_buffers (GST_APP_SINK(sink), 1);
gst_app_sink_set_drop (GST_APP_SINK(sink), stream);
//do not emit signals: all calls will be synchronous and blocking
gst_app_sink_set_emit_signals (GST_APP_SINK(sink), FALSE);
gst_app_sink_set_emit_signals (GST_APP_SINK(sink), 0);
#if GST_VERSION_MAJOR == 0
caps = gst_caps_new_simple("video/x-raw-rgb",
@ -1261,9 +1261,9 @@ bool CvVideoWriter_GStreamer::open( const char * filename, int fourcc,
gst_app_src_set_size (GST_APP_SRC(source), -1);
g_object_set(G_OBJECT(source), "format", GST_FORMAT_TIME, NULL);
g_object_set(G_OBJECT(source), "block", TRUE, NULL);
g_object_set(G_OBJECT(source), "is-live", FALSE, NULL);
g_object_set(G_OBJECT(source), "emit-signals", TRUE, NULL);
g_object_set(G_OBJECT(source), "block", 1, NULL);
g_object_set(G_OBJECT(source), "is-live", 0, NULL);
g_object_set(G_OBJECT(source), "emit-signals", 1, NULL);
if(!manualpipeline)
{

@ -1196,7 +1196,7 @@ static void icvReleaseVideoWriter_QT( CvVideoWriter_QT ** writer ) {
// force compression session to complete encoding of outstanding source
// frames
ICMCompressionSessionCompleteFrames(
video_writer->compression_session_ref, TRUE, 0, 0
video_writer->compression_session_ref, 1, 0, 0
);
EndMediaEdits( video_writer->video );

@ -348,8 +348,7 @@ bool ExrDecoder::readData( Mat& img )
float *fi = (float *)buffer;
for( x = 0; x < m_width * 3; x++)
{
int t = cvRound(fi[x]*5);
out[x] = CV_CAST_8U(t);
out[x] = cv::saturate_cast<uchar>(fi[x]*5);
}
}
else
@ -357,8 +356,7 @@ bool ExrDecoder::readData( Mat& img )
unsigned *ui = (unsigned *)buffer;
for( x = 0; x < m_width * 3; x++)
{
unsigned t = ui[x];
out[x] = CV_CAST_8U(t);
out[x] = cv::saturate_cast<uchar>(ui[x]);
}
}
}
@ -487,12 +485,9 @@ void ExrDecoder::ChromaToBGR( float *data, int numlines, int step )
if( !m_native_depth )
{
int t = cvRound(b);
((uchar *)data)[y * step + x * 3] = CV_CAST_8U(t);
t = cvRound(Y);
((uchar *)data)[y * step + x * 3 + 1] = CV_CAST_8U(t);
t = cvRound(r);
((uchar *)data)[y * step + x * 3 + 2] = CV_CAST_8U(t);
((uchar *)data)[y * step + x * 3 + 0] = cv::saturate_cast<uchar>(b);
((uchar *)data)[y * step + x * 3 + 1] = cv::saturate_cast<uchar>(Y);
((uchar *)data)[y * step + x * 3 + 2] = cv::saturate_cast<uchar>(r);
}
else if( m_type == FLOAT )
{
@ -503,11 +498,11 @@ void ExrDecoder::ChromaToBGR( float *data, int numlines, int step )
else
{
int t = cvRound(b);
((unsigned *)data)[y * step + x * 3] = (unsigned)MAX(t,0);
((unsigned *)data)[y * step + x * 3 + 0] = (unsigned)MAX(t, 0);
t = cvRound(Y);
((unsigned *)data)[y * step + x * 3 + 1] = (unsigned)MAX(t,0);
((unsigned *)data)[y * step + x * 3 + 1] = (unsigned)MAX(t, 0);
t = cvRound(r);
((unsigned *)data)[y * step + x * 3 + 2] = (unsigned)MAX(t,0);
((unsigned *)data)[y * step + x * 3 + 2] = (unsigned)MAX(t, 0);
}
}
}

@ -297,26 +297,26 @@ bool Jpeg2KDecoder::readComponent8u( uchar *data, void *_buffer,
for( x = 0; x < xend - xstart; x++ )
{
int pix = pix_row[x];
dst[x*ncmpts] = CV_CAST_8U(pix);
dst[x*ncmpts] = cv::saturate_cast<uchar>(pix);
}
else
for( x = 0; x < xend - xstart; x++ )
{
int pix = ((pix_row[x] + delta) >> rshift) << lshift;
dst[x*ncmpts] = CV_CAST_8U(pix);
dst[x*ncmpts] = cv::saturate_cast<uchar>(pix);
}
}
else if( xstep == 2 && offset == 0 )
for( x = 0, j = 0; x < xend - xstart; x += 2, j++ )
{
int pix = ((pix_row[j] + delta) >> rshift) << lshift;
dst[x*ncmpts] = dst[(x+1)*ncmpts] = CV_CAST_8U(pix);
dst[x*ncmpts] = dst[(x+1)*ncmpts] = cv::saturate_cast<uchar>(pix);
}
else
for( x = 0, j = 0; x < xend - xstart; j++ )
{
int pix = ((pix_row[j] + delta) >> rshift) << lshift;
pix = CV_CAST_8U(pix);
pix = cv::saturate_cast<uchar>(pix);
for( x1 = x + xstep; x < x1; x++ )
dst[x*ncmpts] = (uchar)pix;
}
@ -361,26 +361,26 @@ bool Jpeg2KDecoder::readComponent16u( unsigned short *data, void *_buffer,
for( x = 0; x < xend - xstart; x++ )
{
int pix = pix_row[x];
dst[x*ncmpts] = CV_CAST_16U(pix);
dst[x*ncmpts] = cv::saturate_cast<ushort>(pix);
}
else
for( x = 0; x < xend - xstart; x++ )
{
int pix = ((pix_row[x] + delta) >> rshift) << lshift;
dst[x*ncmpts] = CV_CAST_16U(pix);
dst[x*ncmpts] = cv::saturate_cast<ushort>(pix);
}
}
else if( xstep == 2 && offset == 0 )
for( x = 0, j = 0; x < xend - xstart; x += 2, j++ )
{
int pix = ((pix_row[j] + delta) >> rshift) << lshift;
dst[x*ncmpts] = dst[(x+1)*ncmpts] = CV_CAST_16U(pix);
dst[x*ncmpts] = dst[(x+1)*ncmpts] = cv::saturate_cast<ushort>(pix);
}
else
for( x = 0, j = 0; x < xend - xstart; j++ )
{
int pix = ((pix_row[j] + delta) >> rshift) << lshift;
pix = CV_CAST_16U(pix);
pix = cv::saturate_cast<ushort>(pix);
for( x1 = x + xstep; x < x1; x++ )
dst[x*ncmpts] = (ushort)pix;
}

@ -647,7 +647,7 @@ cvConvertImage( const CvArr* srcarr, CvArr* dstarr, int flags )
{
size.width *= size.height;
size.height = 1;
s_step = d_step = CV_STUB_STEP;
s_step = d_step = /*CV_STUB_STEP*/ (1 << 30);
}
switch( code )

@ -1107,8 +1107,7 @@ cvShowImage( const char* name, const CvArr* arr )
#ifdef HAVE_OPENGL
if (window->useGl)
{
cv::Mat im(image);
cv::imshow(name, im);
cv::imshow(name, cv::cvarrToMat(image));
return;
}
#endif

@ -496,7 +496,7 @@ public:
srcmat(_srcmat), dstmat(_dstmat), Start_with_green(_start_with_green), Blue(_blue), size(_size)
{
}
virtual void operator() (const Range& range) const
{
SIMDInterpolator vecOp;
@ -506,24 +506,24 @@ public:
int bayer_step = (int)(srcmat.step/sizeof(T));
const T* bayer0 = reinterpret_cast<const T*>(srcmat.data) + bayer_step * range.start;
int dst_step = (int)(dstmat.step/sizeof(T));
T* dst0 = reinterpret_cast<T*>(dstmat.data) + (range.start + 1) * dst_step + dcn + 1;
int blue = Blue, start_with_green = Start_with_green;
if (range.start % 2)
{
blue = -blue;
start_with_green = !start_with_green;
}
for (int i = range.start; i < range.end; bayer0 += bayer_step, dst0 += dst_step, ++i )
{
int t0, t1;
const T* bayer = bayer0;
T* dst = dst0;
const T* bayer_end = bayer + size.width;
// in case of when size.width <= 2
if( size.width <= 0 )
{
@ -540,27 +540,27 @@ public:
}
continue;
}
if( start_with_green )
{
t0 = (bayer[1] + bayer[bayer_step*2+1] + 1) >> 1;
t1 = (bayer[bayer_step] + bayer[bayer_step+2] + 1) >> 1;
dst[-blue] = (T)t0;
dst[0] = bayer[bayer_step+1];
dst[blue] = (T)t1;
if (dcn == 4)
dst[2] = alpha; // alpha channel
bayer++;
dst += dcn;
}
// simd optimization only for dcn == 3
int delta = dcn == 4 ? 0 : vecOp.bayer2RGB(bayer, bayer_step, dst, size.width, blue);
bayer += delta;
dst += delta*dcn;
if (dcn == 3) // Bayer to BGR
{
if( blue > 0 )
@ -574,7 +574,7 @@ public:
dst[-1] = (T)t0;
dst[0] = (T)t1;
dst[1] = bayer[bayer_step+1];
t0 = (bayer[2] + bayer[bayer_step*2+2] + 1) >> 1;
t1 = (bayer[bayer_step+1] + bayer[bayer_step+3] + 1) >> 1;
dst[2] = (T)t0;
@ -593,7 +593,7 @@ public:
dst[1] = (T)t0;
dst[0] = (T)t1;
dst[-1] = bayer[bayer_step+1];
t0 = (bayer[2] + bayer[bayer_step*2+2] + 1) >> 1;
t1 = (bayer[bayer_step+1] + bayer[bayer_step+3] + 1) >> 1;
dst[4] = (T)t0;
@ -617,7 +617,7 @@ public:
dst[0] = (T)t1;
dst[1] = bayer[bayer_step+1];
dst[2] = alpha; // alpha channel
t0 = (bayer[2] + bayer[bayer_step*2+2] + 1) >> 1;
t1 = (bayer[bayer_step+1] + bayer[bayer_step+3] + 1) >> 1;
dst[3] = (T)t0;
@ -638,7 +638,7 @@ public:
dst[0] = (T)t1;
dst[1] = (T)t0;
dst[2] = alpha; // alpha channel
t0 = (bayer[2] + bayer[bayer_step*2+2] + 1) >> 1;
t1 = (bayer[bayer_step+1] + bayer[bayer_step+3] + 1) >> 1;
dst[3] = (T)t1;
@ -648,7 +648,7 @@ public:
}
}
}
// if skip one pixel at the end of row
if( bayer < bayer_end )
{
@ -664,7 +664,7 @@ public:
bayer++;
dst += dcn;
}
// fill the last and the first pixels of row accordingly
if (dcn == 3)
{
@ -686,12 +686,12 @@ public:
dst0[size.width*dcn+1] = dst0[size.width*dcn-3];
dst0[size.width*dcn+2] = dst0[size.width*dcn-2]; // alpha channel
}
blue = -blue;
start_with_green = !start_with_green;
}
}
private:
Mat srcmat;
Mat dstmat;
@ -706,7 +706,7 @@ static void Bayer2RGB_( const Mat& srcmat, Mat& dstmat, int code )
Size size = srcmat.size();
int blue = code == CV_BayerBG2BGR || code == CV_BayerGB2BGR ? -1 : 1;
int start_with_green = code == CV_BayerGB2BGR || code == CV_BayerGR2BGR;
int dcn = dstmat.channels();
size.height -= 2;
size.width -= 2;
@ -717,7 +717,7 @@ static void Bayer2RGB_( const Mat& srcmat, Mat& dstmat, int code )
Bayer2RGB_Invoker<T, SIMDInterpolator> invoker(srcmat, dstmat, start_with_green, blue, size);
parallel_for_(range, invoker, dstmat.total()/static_cast<double>(1<<16));
}
// filling the first and the last rows
size = dstmat.size();
T* dst0 = (T*)dstmat.data;
@ -1018,9 +1018,9 @@ static void Bayer2RGB_VNG_8u( const Mat& srcmat, Mat& dstmat, int code )
R = G + cvRound((Rs - Gs)*scale[ng]);
B = G + cvRound((Bs - Gs)*scale[ng]);
}
dstrow[blueIdx] = CV_CAST_8U(B);
dstrow[1] = CV_CAST_8U(G);
dstrow[blueIdx^2] = CV_CAST_8U(R);
dstrow[blueIdx] = cv::saturate_cast<uchar>(B);
dstrow[1] = cv::saturate_cast<uchar>(G);
dstrow[blueIdx^2] = cv::saturate_cast<uchar>(R);
greenCell = !greenCell;
}

@ -619,7 +619,7 @@ distanceATS_L1_8u( const Mat& src, Mat& dst )
////////////////////// forward scan ////////////////////////
for( x = 0; x < 256; x++ )
lut[x] = CV_CAST_8U(x+1);
lut[x] = cv::saturate_cast<uchar>(x+1);
//init first pixel to max (we're going to be skipping it)
dbase[0] = (uchar)(sbase[0] == 0 ? 0 : 255);

@ -589,124 +589,3 @@ float cv::intersectConvexConvex( InputArray _p1, InputArray _p2, OutputArray _p1
}
return (float)fabs(area);
}
/*
static void testConvConv()
{
static const int P1[] =
{
0, 0,
100, 0,
100, 100,
0, 100,
};
static const int Q1[] =
{
100, 80,
50, 80,
50, 50,
100, 50
};
static const int P2[] =
{
0, 0,
200, 0,
200, 100,
100, 200,
0, 100
};
static const int Q2[] =
{
100, 100,
300, 100,
300, 200,
100, 200
};
static const int P3[] =
{
0, 0,
100, 0,
100, 100,
0, 100
};
static const int Q3[] =
{
50, 50,
150, 50,
150, 150,
50, 150
};
static const int P4[] =
{
0, 160,
50, 80,
130, 0,
190, 20,
240, 100,
240, 260,
190, 290,
130, 320,
70, 320,
30, 290
};
static const int Q4[] =
{
160, -30,
280, 160,
160, 320,
0, 220,
30, 100
};
static const void* PQs[] =
{
P1, Q1, P2, Q2, P3, Q3, P4, Q4
};
static const int lens[] =
{
CV_DIM(P1), CV_DIM(Q1),
CV_DIM(P2), CV_DIM(Q2),
CV_DIM(P3), CV_DIM(Q3),
CV_DIM(P4), CV_DIM(Q4)
};
Mat img(800, 800, CV_8UC3);
for( int i = 0; i < CV_DIM(PQs)/2; i++ )
{
Mat Pm = Mat(lens[i*2]/2, 1, CV_32SC2, (void*)PQs[i*2]) + Scalar(100, 100);
Mat Qm = Mat(lens[i*2+1]/2, 1, CV_32SC2, (void*)PQs[i*2+1]) + Scalar(100, 100);
Point* P = Pm.ptr<Point>();
Point* Q = Qm.ptr<Point>();
flip(Pm, Pm, 0);
flip(Qm, Qm, 0);
Mat Rm;
intersectConvexConvex(Pm, Qm, Rm);
std::cout << Rm << std::endl << std::endl;
img = Scalar::all(0);
polylines(img, Pm, true, Scalar(0,255,0), 1, CV_AA, 0);
polylines(img, Qm, true, Scalar(0,0,255), 1, CV_AA, 0);
Mat temp;
Rm.convertTo(temp, CV_32S, 256);
polylines(img, temp, true, Scalar(128, 255, 255), 3, CV_AA, 8);
namedWindow("test", 1);
imshow("test", img);
waitKey();
}
}
*/
/* End of file. */

@ -1772,7 +1772,7 @@ public:
sum += val*w;
wsum += w;
}
// overflow is not possible here => there is no need to use CV_CAST_8U
// overflow is not possible here => there is no need to use cv::saturate_cast
dptr[j] = (uchar)cvRound(sum/wsum);
}
}

@ -280,8 +280,7 @@ void cv::matchTemplate( InputArray _img, InputArray _templ, OutputArray _result,
integral(img, sum, sqsum, CV_64F);
meanStdDev( templ, templMean, templSdv );
templNorm = CV_SQR(templSdv[0]) + CV_SQR(templSdv[1]) +
CV_SQR(templSdv[2]) + CV_SQR(templSdv[3]);
templNorm = templSdv[0]*templSdv[0] + templSdv[1]*templSdv[1] + templSdv[2]*templSdv[2] + templSdv[3]*templSdv[3];
if( templNorm < DBL_EPSILON && method == CV_TM_CCOEFF_NORMED )
{
@ -289,9 +288,7 @@ void cv::matchTemplate( InputArray _img, InputArray _templ, OutputArray _result,
return;
}
templSum2 = templNorm +
CV_SQR(templMean[0]) + CV_SQR(templMean[1]) +
CV_SQR(templMean[2]) + CV_SQR(templMean[3]);
templSum2 = templNorm + templMean[0]*templMean[0] + templMean[1]*templMean[1] + templMean[2]*templMean[2] + templMean[3]*templMean[3];
if( numType != 1 )
{
@ -335,7 +332,7 @@ void cv::matchTemplate( InputArray _img, InputArray _templ, OutputArray _result,
for( k = 0; k < cn; k++ )
{
t = p0[idx+k] - p1[idx+k] - p2[idx+k] + p3[idx+k];
wndMean2 += CV_SQR(t);
wndMean2 += t*t;
num -= t*templMean[k];
}

@ -124,7 +124,7 @@ cvCreateHandMask( CvSeq * numbers, IplImage * img_mask, CvRect * roi )
__BEGIN__;
if( img_mask->depth != IPL_DEPTH_8U )
CV_ERROR( CV_BadDepth, cvUnsupportedFormat );
CV_ERROR( CV_BadDepth, "Unsupported format" );
if( img_mask->nChannels != 1 )
CV_ERROR( CV_BadNumChannels, "output image have wrong number of channels" );

@ -1192,9 +1192,9 @@ cvCalcCovarMatrixEx( int nObjects, void* input, int ioFlags,
cvGetImageRawData( avg, (uchar **) & avg_data, &avg_step, &avg_size );
if( avg->depth != IPL_DEPTH_32F )
CV_ERROR( CV_BadDepth, cvUnsupportedFormat );
CV_ERROR( CV_BadDepth, "Unsupported format" );
if( avg->nChannels != 1 )
CV_ERROR( CV_BadNumChannels, cvUnsupportedFormat );
CV_ERROR( CV_BadNumChannels, "Unsupported format" );
if( ioFlags == CV_EIGOBJ_NO_CALLBACK )
{
@ -1213,11 +1213,11 @@ cvCalcCovarMatrixEx( int nObjects, void* input, int ioFlags,
cvGetImageRawData( img, &img_data, &img_step, &img_size );
if( img->depth != IPL_DEPTH_8U )
CV_ERROR( CV_BadDepth, cvUnsupportedFormat );
CV_ERROR( CV_BadDepth, "Unsupported format" );
if( img_size != avg_size || img_size != old_size )
CV_ERROR( CV_StsBadArg, "Different sizes of objects" );
if( img->nChannels != 1 )
CV_ERROR( CV_BadNumChannels, cvUnsupportedFormat );
CV_ERROR( CV_BadNumChannels, "Unsupported format" );
if( i > 0 && img_step != old_step )
CV_ERROR( CV_StsBadArg, "Different steps of objects" );
@ -1327,9 +1327,9 @@ cvCalcEigenObjects( int nObjects,
cvGetImageRawData( avg, (uchar **) & avg_data, &avg_step, &avg_size );
if( avg->depth != IPL_DEPTH_32F )
CV_ERROR( CV_BadDepth, cvUnsupportedFormat );
CV_ERROR( CV_BadDepth, "Unsupported format" );
if( avg->nChannels != 1 )
CV_ERROR( CV_BadNumChannels, cvUnsupportedFormat );
CV_ERROR( CV_BadNumChannels, "Unsupported format" );
if( nEigens > calcLimit->max_iter && calcLimit->type != CV_TERMCRIT_EPS )
nEigens = calcLimit->max_iter;
@ -1358,11 +1358,11 @@ cvCalcEigenObjects( int nObjects,
cvGetImageRawData( img, &obj_data, &obj_step, &obj_size );
if( img->depth != IPL_DEPTH_8U )
CV_ERROR( CV_BadDepth, cvUnsupportedFormat );
CV_ERROR( CV_BadDepth, "Unsupported format" );
if( obj_size != avg_size || obj_size != old_size )
CV_ERROR( CV_StsBadArg, "Different sizes of objects" );
if( img->nChannels != 1 )
CV_ERROR( CV_BadNumChannels, cvUnsupportedFormat );
CV_ERROR( CV_BadNumChannels, "Unsupported format" );
if( i > 0 && obj_step != old_step )
CV_ERROR( CV_StsBadArg, "Different steps of objects" );
@ -1377,11 +1377,11 @@ cvCalcEigenObjects( int nObjects,
cvGetImageRawData( eig, (uchar **) & eig_data, &eig_step, &eig_size );
if( eig->depth != IPL_DEPTH_32F )
CV_ERROR( CV_BadDepth, cvUnsupportedFormat );
CV_ERROR( CV_BadDepth, "Unsupported format" );
if( eig_size != avg_size || eig_size != oldeig_size )
CV_ERROR( CV_StsBadArg, "Different sizes of objects" );
if( eig->nChannels != 1 )
CV_ERROR( CV_BadNumChannels, cvUnsupportedFormat );
CV_ERROR( CV_BadNumChannels, "Unsupported format" );
if( i > 0 && eig_step != oldeig_step )
CV_ERROR( CV_StsBadArg, "Different steps of objects" );
@ -1415,11 +1415,11 @@ cvCalcEigenObjects( int nObjects,
cvGetImageRawData( img, &obj_data, &obj_step, &obj_size );
if( img->depth != IPL_DEPTH_8U )
CV_ERROR( CV_BadDepth, cvUnsupportedFormat );
CV_ERROR( CV_BadDepth, "Unsupported format" );
if( obj_size != avg_size || obj_size != old_size )
CV_ERROR( CV_StsBadArg, "Different sizes of objects" );
if( img->nChannels != 1 )
CV_ERROR( CV_BadNumChannels, cvUnsupportedFormat );
CV_ERROR( CV_BadNumChannels, "Unsupported format" );
if( i > 0 && obj_step != old_step )
CV_ERROR( CV_StsBadArg, "Different steps of objects" );
@ -1461,11 +1461,11 @@ cvCalcEigenObjects( int nObjects,
cvGetImageRawData( eig, (uchar **) & eig_data, &eig_step, &eig_size );
if( eig->depth != IPL_DEPTH_32F )
CV_ERROR( CV_BadDepth, cvUnsupportedFormat );
CV_ERROR( CV_BadDepth, "Unsupported format" );
if( eig_size != avg_size || eig_size != oldeig_size )
CV_ERROR( CV_StsBadArg, "Different sizes of objects" );
if( eig->nChannels != 1 )
CV_ERROR( CV_BadNumChannels, cvUnsupportedFormat );
CV_ERROR( CV_BadNumChannels, "Unsupported format" );
if( i > 0 && eig_step != oldeig_step )
CV_ERROR( CV_StsBadArg, "Different steps of objects" );
@ -1545,21 +1545,21 @@ cvCalcDecompCoeff( IplImage * obj, IplImage * eigObj, IplImage * avg )
cvGetImageRawData( obj, &obj_data, &obj_step, &obj_size );
if( obj->depth != IPL_DEPTH_8U )
CV_ERROR( CV_BadDepth, cvUnsupportedFormat );
CV_ERROR( CV_BadDepth, "Unsupported format" );
if( obj->nChannels != 1 )
CV_ERROR( CV_BadNumChannels, cvUnsupportedFormat );
CV_ERROR( CV_BadNumChannels, "Unsupported format" );
cvGetImageRawData( eigObj, (uchar **) & eig_data, &eig_step, &eig_size );
if( eigObj->depth != IPL_DEPTH_32F )
CV_ERROR( CV_BadDepth, cvUnsupportedFormat );
CV_ERROR( CV_BadDepth, "Unsupported format" );
if( eigObj->nChannels != 1 )
CV_ERROR( CV_BadNumChannels, cvUnsupportedFormat );
CV_ERROR( CV_BadNumChannels, "Unsupported format" );
cvGetImageRawData( avg, (uchar **) & avg_data, &avg_step, &avg_size );
if( avg->depth != IPL_DEPTH_32F )
CV_ERROR( CV_BadDepth, cvUnsupportedFormat );
CV_ERROR( CV_BadDepth, "Unsupported format" );
if( avg->nChannels != 1 )
CV_ERROR( CV_BadNumChannels, cvUnsupportedFormat );
CV_ERROR( CV_BadNumChannels, "Unsupported format" );
if( obj_size != eig_size || obj_size != avg_size )
CV_ERROR( CV_StsBadArg, "different sizes of images" );
@ -1614,15 +1614,15 @@ cvEigenDecomposite( IplImage* obj,
cvGetImageRawData( avg, (uchar **) & avg_data, &avg_step, &avg_size );
if( avg->depth != IPL_DEPTH_32F )
CV_ERROR( CV_BadDepth, cvUnsupportedFormat );
CV_ERROR( CV_BadDepth, "Unsupported format" );
if( avg->nChannels != 1 )
CV_ERROR( CV_BadNumChannels, cvUnsupportedFormat );
CV_ERROR( CV_BadNumChannels, "Unsupported format" );
cvGetImageRawData( obj, &obj_data, &obj_step, &obj_size );
if( obj->depth != IPL_DEPTH_8U )
CV_ERROR( CV_BadDepth, cvUnsupportedFormat );
CV_ERROR( CV_BadDepth, "Unsupported format" );
if( obj->nChannels != 1 )
CV_ERROR( CV_BadNumChannels, cvUnsupportedFormat );
CV_ERROR( CV_BadNumChannels, "Unsupported format" );
if( obj_size != avg_size )
CV_ERROR( CV_StsBadArg, "Different sizes of objects" );
@ -1644,11 +1644,11 @@ cvEigenDecomposite( IplImage* obj,
cvGetImageRawData( eig, (uchar **) & eig_data, &eig_step, &eig_size );
if( eig->depth != IPL_DEPTH_32F )
CV_ERROR( CV_BadDepth, cvUnsupportedFormat );
CV_ERROR( CV_BadDepth, "Unsupported format" );
if( eig_size != avg_size || eig_size != old_size )
CV_ERROR( CV_StsBadArg, "Different sizes of objects" );
if( eig->nChannels != 1 )
CV_ERROR( CV_BadNumChannels, cvUnsupportedFormat );
CV_ERROR( CV_BadNumChannels, "Unsupported format" );
if( i > 0 && eig_step != old_step )
CV_ERROR( CV_StsBadArg, "Different steps of objects" );
@ -1731,15 +1731,15 @@ cvEigenProjection( void* eigInput,
cvGetImageRawData( avg, (uchar **) & avg_data, &avg_step, &avg_size );
if( avg->depth != IPL_DEPTH_32F )
CV_ERROR( CV_BadDepth, cvUnsupportedFormat );
CV_ERROR( CV_BadDepth, "Unsupported format" );
if( avg->nChannels != 1 )
CV_ERROR( CV_BadNumChannels, cvUnsupportedFormat );
CV_ERROR( CV_BadNumChannels, "Unsupported format" );
cvGetImageRawData( proj, &proj_data, &proj_step, &proj_size );
if( proj->depth != IPL_DEPTH_8U )
CV_ERROR( CV_BadDepth, cvUnsupportedFormat );
CV_ERROR( CV_BadDepth, "Unsupported format" );
if( proj->nChannels != 1 )
CV_ERROR( CV_BadNumChannels, cvUnsupportedFormat );
CV_ERROR( CV_BadNumChannels, "Unsupported format" );
if( proj_size != avg_size )
CV_ERROR( CV_StsBadArg, "Different sizes of projects" );
@ -1761,11 +1761,11 @@ cvEigenProjection( void* eigInput,
cvGetImageRawData( eig, (uchar **) & eig_data, &eig_step, &eig_size );
if( eig->depth != IPL_DEPTH_32F )
CV_ERROR( CV_BadDepth, cvUnsupportedFormat );
CV_ERROR( CV_BadDepth, "Unsupported format" );
if( eig_size != avg_size || eig_size != old_size )
CV_ERROR( CV_StsBadArg, "Different sizes of objects" );
if( eig->nChannels != 1 )
CV_ERROR( CV_BadNumChannels, cvUnsupportedFormat );
CV_ERROR( CV_BadNumChannels, "Unsupported format" );
if( i > 0 && eig_step != old_step )
CV_ERROR( CV_StsBadArg, "Different steps of objects" );

@ -1843,7 +1843,7 @@ cvPyrSegmentation( IplImage * src,
int thresh2 = cvRound( threshold2 );
if( src->depth != IPL_DEPTH_8U )
CV_Error( CV_BadDepth, cvUnsupportedFormat );
CV_Error( CV_BadDepth, "Unsupported format" );
if( src->depth != dst->depth || src->nChannels != dst->nChannels )
CV_Error( CV_StsBadArg, "src and dst have different formats" );
@ -1872,7 +1872,7 @@ cvPyrSegmentation( IplImage * src,
comp, storage, level, thresh1, thresh2 ));
break;
default:
CV_Error( CV_BadNumChannels, cvUnsupportedFormat );
CV_Error( CV_BadNumChannels, "Unsupported format" );
}
}

@ -416,7 +416,7 @@ cvSnakeImage( const IplImage* src, CvPoint* points,
CV_Error( CV_BadNumChannels, "input image has more than one channel" );
if( src->depth != IPL_DEPTH_8U )
CV_Error( CV_BadDepth, cvUnsupportedFormat );
CV_Error( CV_BadDepth, "Unsupported format" );
cvGetRawData( src, &data, &step, &size );

@ -927,7 +927,7 @@ IplImage* cvTestSeqQueryFrame(CvTestSeq* pTestSeq)
for(p=pTS->pElemList; p; p=p->next)
{
int DirectCopy = FALSE;
int DirectCopy = 0;
int frame = pTS->CurFrame - p->FrameBegin;
//float t = p->FrameNum>1?((float)frame/(p->FrameNum-1)):0;
CvTSTrans* pTrans = p->pTrans + frame%p->TransNum;
@ -996,13 +996,13 @@ IplImage* cvTestSeqQueryFrame(CvTestSeq* pTestSeq)
{ /* Check for direct copy: */
DirectCopy = TRUE;
if( fabs(CV_MAT_ELEM(pT[0],float,0,0)-1) > 0.00001) DirectCopy = FALSE;
if( fabs(CV_MAT_ELEM(pT[0],float,1,0)) > 0.00001) DirectCopy = FALSE;
if( fabs(CV_MAT_ELEM(pT[0],float,0,1)) > 0.00001) DirectCopy = FALSE;
if( fabs(CV_MAT_ELEM(pT[0],float,0,1)) > 0.00001) DirectCopy = FALSE;
if( fabs(CV_MAT_ELEM(pT[0],float,0,2)-(pImg->width-1)*0.5) > 0.5) DirectCopy = FALSE;
if( fabs(CV_MAT_ELEM(pT[0],float,1,2)-(pImg->height-1)*0.5) > 0.5) DirectCopy = FALSE;
DirectCopy = 1;
if( fabs(CV_MAT_ELEM(pT[0],float,0,0)-1) > 0.00001) DirectCopy = 0;
if( fabs(CV_MAT_ELEM(pT[0],float,1,0)) > 0.00001) DirectCopy = 0;
if( fabs(CV_MAT_ELEM(pT[0],float,0,1)) > 0.00001) DirectCopy = 0;
if( fabs(CV_MAT_ELEM(pT[0],float,0,1)) > 0.00001) DirectCopy = 0;
if( fabs(CV_MAT_ELEM(pT[0],float,0,2)-(pImg->width-1)*0.5) > 0.5) DirectCopy = 0;
if( fabs(CV_MAT_ELEM(pT[0],float,1,2)-(pImg->height-1)*0.5) > 0.5) DirectCopy = 0;
}
/* Extract image and mask: */

@ -152,8 +152,8 @@ struct CvFaceTracker
if ((NULL == imgray) ||
(NULL == imgThresh) ||
(NULL == mstgContours))
return FALSE;
return TRUE;
return 0;
return 1;
};
int InitNextImage(IplImage* img)
{
@ -165,7 +165,7 @@ struct CvFaceTracker
CvMat mat = cvMat( 2, 3, CV_32FC1, m );
if (NULL == imgGray || NULL == imgThresh)
return FALSE;
return 0;
/*m[0] = (float)cos(-dbRotateAngle*CV_PI/180.);
m[1] = (float)sin(-dbRotateAngle*CV_PI/180.);
@ -181,8 +181,8 @@ struct CvFaceTracker
else
cvClearMemStorage(mstgContours);
if (NULL == mstgContours)
return FALSE;
return TRUE;
return 0;
return 1;
}
};
@ -209,14 +209,14 @@ public:
if (NULL != mstg)
m_mstgRects = mstg;
if (NULL == m_mstgRects)
return FALSE;
return 0;
if (NULL == m_seqRects)
m_seqRects = cvCreateSeq(0, sizeof(CvSeq), sizeof(CvTrackingRect), m_mstgRects);
else
cvClearSeq(m_seqRects);
if (NULL == m_seqRects)
return FALSE;
return TRUE;
return 0;
return 1;
};
void FindRects(IplImage* img, IplImage* thresh, int nLayers, int dMinSize);
protected:
@ -433,14 +433,14 @@ cvInitFaceTracker(CvFaceTracker* pFaceTracker, const IplImage* imgGray, CvRect*
(nRects < NUM_FACE_ELEMENTS))
return NULL;
//int new_face = FALSE;
//int new_face = 0;
CvFaceTracker* pFace = pFaceTracker;
if (NULL == pFace)
{
pFace = new CvFaceTracker;
if (NULL == pFace)
return NULL;
//new_face = TRUE;
//new_face = 1;
}
pFace->Init(pRects, (IplImage*)imgGray);
return pFace;
@ -464,7 +464,7 @@ cvTrackFace(CvFaceTracker* pFaceTracker, IplImage* imgGray, CvRect* pRects, int
assert(NULL != pRects && nRects >= NUM_FACE_ELEMENTS);
if ((NULL == pFaceTracker) ||
(NULL == imgGray))
return FALSE;
return 0;
pFaceTracker->InitNextImage(imgGray);
*ptRotate = pFaceTracker->ptRotate;
*dbAngleRotate = pFaceTracker->dbRotateAngle;
@ -505,7 +505,7 @@ START:
if (r.y + r.height > pFaceTracker->imgGray->height - 2)
r.height = pFaceTracker->imgGray->height - 2 - r.y;
if (!big_face[elem].Init(r, pFaceTracker->face[elem], pFaceTracker->mstgContours))
return FALSE;
return 0;
}
// find contours
for (elem = 0; elem < NUM_FACE_ELEMENTS; elem++)
@ -514,13 +514,13 @@ START:
CvTrackingRect new_face[NUM_FACE_ELEMENTS];
int new_energy = 0;
int found = ChoiceTrackingFace3(pFaceTracker, nElements, big_face, new_face, new_energy);
int restart = FALSE;
int find2 = FALSE;
int restart = 0;
int find2 = 0;
int noel = -1;
if (found)
{
if (new_energy > 100000 && -1 != pFaceTracker->iTrackingFaceType)
find2 = TRUE;
find2 = 1;
else if (new_energy > 150000)
{
int elements = 0;
@ -532,17 +532,17 @@ START:
noel = el;
}
if (2 == elements)
find2 = TRUE;
find2 = 1;
else
restart = TRUE;
restart = 1;
}
}
else
{
if (-1 != pFaceTracker->iTrackingFaceType)
find2 = TRUE;
find2 = 1;
else
restart = TRUE;
restart = 1;
}
RESTART:
if (restart)
@ -561,11 +561,11 @@ RESTART:
if (found2 && new_energy < 100000)
{
pFaceTracker->iTrackingFaceType = noel;
found = TRUE;
found = 1;
}
else
{
restart = TRUE;
restart = 1;
goto RESTART;
}
}
@ -599,7 +599,7 @@ RESTART:
{
pFaceTracker->dbRotateDelta = 0;
pFaceTracker->dbRotateAngle = 0;
found = FALSE;
found = 0;
}
if (found)
{
@ -663,7 +663,7 @@ int ChoiceTrackingFace3(CvFaceTracker* pTF, const int nElements, const CvFaceEle
CvTrackingRect* new_face[NUM_FACE_ELEMENTS] = {NULL};
new_energy = 0x7fffffff;
int curr_energy = 0x7fffffff;
int found = FALSE;
int found = 0;
int N = 0;
CvSeqReader reader_m, reader_l, reader_r;
cvStartReadSeq( big_face[MOUTH].m_seqRects, &reader_m );
@ -689,7 +689,7 @@ int ChoiceTrackingFace3(CvFaceTracker* pTF, const int nElements, const CvFaceEle
for (int elem = 0; elem < NUM_FACE_ELEMENTS; elem++)
new_face[elem] = curr_face[elem];
new_energy = curr_energy;
found = TRUE;
found = 1;
}
N++;
}
@ -722,7 +722,7 @@ int ChoiceTrackingFace2(CvFaceTracker* pTF, const int nElements, const CvFaceEle
CvTrackingRect* new_face[NUM_FACE_ELEMENTS] = {NULL};
new_energy = 0x7fffffff;
int curr_energy = 0x7fffffff;
int found = FALSE;
int found = 0;
int N = 0;
CvSeqReader reader0, reader1;
cvStartReadSeq( big_face[element[0]].m_seqRects, &reader0 );
@ -739,7 +739,7 @@ int ChoiceTrackingFace2(CvFaceTracker* pTF, const int nElements, const CvFaceEle
for (int elem = 0; elem < NUM_FACE_ELEMENTS; elem++)
new_face[elem] = curr_face[elem];
new_energy = curr_energy;
found = TRUE;
found = 1;
}
N++;
}

@ -175,7 +175,7 @@ void QuantizedPyramid::selectScatteredFeatures(const std::vector<Candidate>& can
size_t num_features, float distance)
{
features.clear();
float distance_sq = CV_SQR(distance);
float distance_sq = distance * distance;
int i = 0;
while (features.size() < num_features)
{
@ -186,7 +186,7 @@ void QuantizedPyramid::selectScatteredFeatures(const std::vector<Candidate>& can
for (int j = 0; (j < (int)features.size()) && keep; ++j)
{
Feature f = features[j];
keep = CV_SQR(c.f.x - f.x) + CV_SQR(c.f.y - f.y) >= distance_sq;
keep = (c.f.x - f.x)*(c.f.x - f.x) + (c.f.y - f.y)*(c.f.y - f.y) >= distance_sq;
}
if (keep)
features.push_back(c.f);
@ -196,7 +196,7 @@ void QuantizedPyramid::selectScatteredFeatures(const std::vector<Candidate>& can
// Start back at beginning, and relax required distance
i = 0;
distance -= 1.0f;
distance_sq = CV_SQR(distance);
distance_sq = distance * distance;
}
}
}
@ -306,9 +306,9 @@ static void quantizedOrientations(const Mat& src, Mat& magnitude,
for (int i = 0; i < length0; i += 3)
{
// Use the gradient orientation of the channel whose magnitude is largest
int mag1 = CV_SQR(ptrx[i]) + CV_SQR(ptry[i]);
int mag2 = CV_SQR(ptrx[i + 1]) + CV_SQR(ptry[i + 1]);
int mag3 = CV_SQR(ptrx[i + 2]) + CV_SQR(ptry[i + 2]);
int mag1 = ptrx[i+0] * ptrx[i + 0] + ptry[i + 0] * ptry[i + 0];
int mag2 = ptrx[i+1] * ptrx[i + 1] + ptry[i + 1] * ptry[i + 1];
int mag3 = ptrx[i+2] * ptrx[i + 2] + ptry[i + 2] * ptry[i + 2];
if (mag1 >= mag2 && mag1 >= mag3)
{
@ -339,7 +339,7 @@ static void quantizedOrientations(const Mat& src, Mat& magnitude,
// Calculate the final gradient orientations
phase(sobel_dx, sobel_dy, sobel_ag, true);
hysteresisGradient(magnitude, angle, sobel_ag, CV_SQR(threshold));
hysteresisGradient(magnitude, angle, sobel_ag, threshold * threshold);
}
void hysteresisGradient(Mat& magnitude, Mat& quantized_angle,
@ -509,7 +509,7 @@ bool ColorGradientPyramid::extractTemplate(Template& templ) const
// Create sorted list of all pixels with magnitude greater than a threshold
std::vector<Candidate> candidates;
bool no_mask = local_mask.empty();
float threshold_sq = CV_SQR(strong_threshold);
float threshold_sq = strong_threshold*strong_threshold;
for (int r = 0; r < magnitude.rows; ++r)
{
const uchar* angle_r = angle.ptr<uchar>(r);

@ -397,82 +397,80 @@ static CvStatus CV_STDCALL icvGetRectSubPix_8u32f_C1R
#define ICV_32F8U(x) ((uchar)cvRound(x))
#define ICV_DEF_GET_QUADRANGLE_SUB_PIX_FUNC( flavor, srctype, dsttype, \
worktype, cast_macro, cvt ) \
static CvStatus CV_STDCALL \
icvGetQuadrangleSubPix_##flavor##_C1R \
( const srctype * src, int src_step, CvSize src_size, \
dsttype *dst, int dst_step, CvSize win_size, const float *matrix ) \
{ \
int x, y; \
double dx = (win_size.width - 1)*0.5; \
double dy = (win_size.height - 1)*0.5; \
double A11 = matrix[0], A12 = matrix[1], A13 = matrix[2]-A11*dx-A12*dy; \
double A21 = matrix[3], A22 = matrix[4], A23 = matrix[5]-A21*dx-A22*dy; \
\
src_step /= sizeof(srctype); \
dst_step /= sizeof(dsttype); \
\
for( y = 0; y < win_size.height; y++, dst += dst_step ) \
{ \
double xs = A12*y + A13; \
double ys = A22*y + A23; \
double xe = A11*(win_size.width-1) + A12*y + A13; \
double ye = A21*(win_size.width-1) + A22*y + A23; \
\
if( (unsigned)(cvFloor(xs)-1) < (unsigned)(src_size.width - 3) && \
(unsigned)(cvFloor(ys)-1) < (unsigned)(src_size.height - 3) && \
(unsigned)(cvFloor(xe)-1) < (unsigned)(src_size.width - 3) && \
(unsigned)(cvFloor(ye)-1) < (unsigned)(src_size.height - 3)) \
{ \
for( x = 0; x < win_size.width; x++ ) \
{ \
int ixs = cvFloor( xs ); \
int iys = cvFloor( ys ); \
const srctype *ptr = src + src_step*iys + ixs; \
double a = xs - ixs, b = ys - iys, a1 = 1.f - a; \
worktype p0 = cvt(ptr[0])*a1 + cvt(ptr[1])*a; \
worktype p1 = cvt(ptr[src_step])*a1 + cvt(ptr[src_step+1])*a;\
xs += A11; \
ys += A21; \
\
dst[x] = cast_macro(p0 + b * (p1 - p0)); \
} \
} \
else \
{ \
for( x = 0; x < win_size.width; x++ ) \
{ \
int ixs = cvFloor( xs ), iys = cvFloor( ys ); \
double a = xs - ixs, b = ys - iys, a1 = 1.f - a; \
const srctype *ptr0, *ptr1; \
worktype p0, p1; \
xs += A11; ys += A21; \
\
if( (unsigned)iys < (unsigned)(src_size.height-1) ) \
ptr0 = src + src_step*iys, ptr1 = ptr0 + src_step; \
else \
ptr0 = ptr1 = src + (iys < 0 ? 0 : src_size.height-1)*src_step; \
\
if( (unsigned)ixs < (unsigned)(src_size.width-1) ) \
{ \
p0 = cvt(ptr0[ixs])*a1 + cvt(ptr0[ixs+1])*a; \
p1 = cvt(ptr1[ixs])*a1 + cvt(ptr1[ixs+1])*a; \
} \
else \
{ \
ixs = ixs < 0 ? 0 : src_size.width - 1; \
p0 = cvt(ptr0[ixs]); p1 = cvt(ptr1[ixs]); \
} \
dst[x] = cast_macro(p0 + b * (p1 - p0)); \
} \
} \
} \
\
return CV_OK; \
#define ICV_DEF_GET_QUADRANGLE_SUB_PIX_FUNC( flavor, srctype, dsttype, worktype, cast_macro, cvt ) \
static CvStatus CV_STDCALL icvGetQuadrangleSubPix_##flavor##_C1R \
( const srctype * src, int src_step, CvSize src_size, \
dsttype *dst, int dst_step, CvSize win_size, const float *matrix ) \
{ \
int x, y; \
double dx = (win_size.width - 1)*0.5; \
double dy = (win_size.height - 1)*0.5; \
double A11 = matrix[0], A12 = matrix[1], A13 = matrix[2]-A11*dx-A12*dy; \
double A21 = matrix[3], A22 = matrix[4], A23 = matrix[5]-A21*dx-A22*dy; \
\
src_step /= sizeof(srctype); \
dst_step /= sizeof(dsttype); \
\
for( y = 0; y < win_size.height; y++, dst += dst_step ) \
{ \
double xs = A12*y + A13; \
double ys = A22*y + A23; \
double xe = A11*(win_size.width-1) + A12*y + A13; \
double ye = A21*(win_size.width-1) + A22*y + A23; \
\
if( (unsigned)(cvFloor(xs)-1) < (unsigned)(src_size.width - 3) && \
(unsigned)(cvFloor(ys)-1) < (unsigned)(src_size.height - 3) && \
(unsigned)(cvFloor(xe)-1) < (unsigned)(src_size.width - 3) && \
(unsigned)(cvFloor(ye)-1) < (unsigned)(src_size.height - 3)) \
{ \
for( x = 0; x < win_size.width; x++ ) \
{ \
int ixs = cvFloor( xs ); \
int iys = cvFloor( ys ); \
const srctype *ptr = src + src_step*iys + ixs; \
double a = xs - ixs, b = ys - iys, a1 = 1.f - a; \
worktype p0 = cvt(ptr[0])*a1 + cvt(ptr[1])*a; \
worktype p1 = cvt(ptr[src_step])*a1 + cvt(ptr[src_step+1])*a; \
xs += A11; \
ys += A21; \
\
dst[x] = cast_macro(p0 + b * (p1 - p0)); \
} \
} \
else \
{ \
for( x = 0; x < win_size.width; x++ ) \
{ \
int ixs = cvFloor( xs ), iys = cvFloor( ys ); \
double a = xs - ixs, b = ys - iys, a1 = 1.f - a; \
const srctype *ptr0, *ptr1; \
worktype p0, p1; \
xs += A11; ys += A21; \
\
if( (unsigned)iys < (unsigned)(src_size.height-1) ) \
ptr0 = src + src_step*iys, ptr1 = ptr0 + src_step; \
else \
ptr0 = ptr1 = src + (iys < 0 ? 0 : src_size.height-1)*src_step; \
\
if( (unsigned)ixs < (unsigned)(src_size.width-1) ) \
{ \
p0 = cvt(ptr0[ixs])*a1 + cvt(ptr0[ixs+1])*a; \
p1 = cvt(ptr1[ixs])*a1 + cvt(ptr1[ixs+1])*a; \
} \
else \
{ \
ixs = ixs < 0 ? 0 : src_size.width - 1; \
p0 = cvt(ptr0[ixs]); p1 = cvt(ptr1[ixs]); \
} \
dst[x] = cast_macro(p0 + b * (p1 - p0)); \
} \
} \
} \
\
return CV_OK; \
}
ICV_DEF_GET_QUADRANGLE_SUB_PIX_FUNC( 8u32f, uchar, float, double, CV_CAST_32F, CV_8TO32F )
ICV_DEF_GET_QUADRANGLE_SUB_PIX_FUNC( 8u32f, uchar, float, double, cv::saturate_cast<float>, CV_8TO32F )
/* Affine tracking algorithm */

@ -40,7 +40,7 @@ int main(int, char**)
for(;;)
{
randn( state, Scalar::all(0), Scalar::all(0.1) );
KF.transitionMatrix = *(Mat_<float>(2, 2) << 1, 1, 0, 1);
KF.transitionMatrix = (Mat_<float>(2, 2) << 1, 1, 0, 1);
setIdentity(KF.measurementMatrix);
setIdentity(KF.processNoiseCov, Scalar::all(1e-5));

Loading…
Cancel
Save