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;
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 )
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);
# 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
#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
#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__
# 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
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
}
typedef tbb::concurrent_vector<Rect> ConcurrentRectVector;
- typedef tbb::concurrent_vector<double> ConcurrentDoubleVector;
#else
class BlockedRange
{
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 {};
#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
/* 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
# 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) )
{
}
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__
_OutputArray::_OutputArray(const std::vector<_Tp>& vec)
: _InputArray(vec)
{
- flags |= FIXED_SIZE
+ flags |= FIXED_SIZE;
}
template<typename _Tp> inline
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>();
}
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:
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;
}
}
}
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;
}
}
}
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;
}
}
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;
#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
{
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:
{
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:
{
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) {
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]] +
{
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) {
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]] +
*/
/////////////////////////////////////////////////////////
-#include "precomp.hpp"
-
#if defined _MSC_VER && _MSC_VER >= 100
//'sprintf': name was marked as #pragma deprecated
#pragma warning(disable: 4995)
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);
}
};
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",
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)
{
// 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 );
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
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]);
}
}
}
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 )
{
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);
}
}
}
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;
}
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;
}
{
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 )
#ifdef HAVE_OPENGL
if (window->useGl)
{
- cv::Mat im(image);
- cv::imshow(name, im);
+ cv::imshow(name, cv::cvarrToMat(image));
return;
}
#endif
srcmat(_srcmat), dstmat(_dstmat), Start_with_green(_start_with_green), Blue(_blue), size(_size)
{
}
-
+
virtual void operator() (const Range& range) const
{
SIMDInterpolator vecOp;
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 )
{
}
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 )
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;
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;
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;
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;
}
}
}
-
+
// if skip one pixel at the end of row
if( bayer < bayer_end )
{
bayer++;
dst += dcn;
}
-
+
// fill the last and the first pixels of row accordingly
if (dcn == 3)
{
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;
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;
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;
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;
}
////////////////////// 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);
}
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. */
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);
}
}
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 )
{
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 )
{
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];
}
__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" );
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 )
{
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" );
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;
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" );
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" );
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" );
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" );
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" );
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" );
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" );
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" );
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" );
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" );
comp, storage, level, thresh1, thresh2 ));
break;
default:
- CV_Error( CV_BadNumChannels, cvUnsupportedFormat );
+ CV_Error( CV_BadNumChannels, "Unsupported format" );
}
}
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 );
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;
{ /* 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: */
if ((NULL == imgray) ||
(NULL == imgThresh) ||
(NULL == mstgContours))
- return FALSE;
- return TRUE;
+ return 0;
+ return 1;
};
int InitNextImage(IplImage* img)
{
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.);
else
cvClearMemStorage(mstgContours);
if (NULL == mstgContours)
- return FALSE;
- return TRUE;
+ return 0;
+ return 1;
}
};
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:
(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;
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;
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++)
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;
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)
if (found2 && new_energy < 100000)
{
pFaceTracker->iTrackingFaceType = noel;
- found = TRUE;
+ found = 1;
}
else
{
- restart = TRUE;
+ restart = 1;
goto RESTART;
}
}
{
pFaceTracker->dbRotateDelta = 0;
pFaceTracker->dbRotateAngle = 0;
- found = FALSE;
+ found = 0;
}
if (found)
{
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 );
for (int elem = 0; elem < NUM_FACE_ELEMENTS; elem++)
new_face[elem] = curr_face[elem];
new_energy = curr_energy;
- found = TRUE;
+ found = 1;
}
N++;
}
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 );
for (int elem = 0; elem < NUM_FACE_ELEMENTS; elem++)
new_face[elem] = curr_face[elem];
new_energy = curr_energy;
- found = TRUE;
+ found = 1;
}
N++;
}
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)
{
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);
// Start back at beginning, and relax required distance
i = 0;
distance -= 1.0f;
- distance_sq = CV_SQR(distance);
+ distance_sq = distance * distance;
}
}
}
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)
{
// 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,
// 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);
#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 */
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));