merged 2.4 into trunk

This commit is contained in:
Vadim Pisarevsky
2012-04-30 14:33:52 +00:00
parent 3f1c6d7357
commit d5a0088bbe
194 changed files with 10158 additions and 8225 deletions

View File

@@ -316,9 +316,11 @@ int BaseTest::update_progress( int progress, int test_case_idx, int count, doubl
BadArgTest::BadArgTest()
{
progress = -1;
test_case_idx = -1;
freq = cv::getTickFrequency();
progress = -1;
test_case_idx = -1;
freq = cv::getTickFrequency();
// oldErrorCbk = 0;
// oldErrorCbkData = 0;
}
BadArgTest::~BadArgTest(void)
@@ -378,7 +380,6 @@ int BadArgTest::run_test_case( int expected_code, const string& _descr )
return errcount;
}
/*****************************************************************************************\
* Base Class for Test System *
\*****************************************************************************************/
@@ -438,6 +439,12 @@ string TS::str_from_code( int code )
return "Generic/Unknown";
}
static int tsErrorCallback( int status, const char* func_name, const char* err_msg, const char* file_name, int line, TS* ts )
{
ts->printf(TS::LOG, "OpenCV Error: %s (%s) in %s, file %s, line %d\n", cvErrorStr(status), err_msg, func_name[0] != 0 ? func_name : "unknown function", file_name, line);
return 0;
}
/************************************** Running tests **********************************/
void TS::init( const string& modulename )
@@ -453,10 +460,10 @@ void TS::init( const string& modulename )
data_path = string(buf);
}
cv::redirectError((cv::ErrorCallback)tsErrorCallback, this);
if( ::testing::GTEST_FLAG(catch_exceptions) )
{
cvSetErrMode( CV_ErrModeParent );
cvRedirectError( cvStdErrReport );
#if defined WIN32 || defined _WIN32
#ifdef _MSC_VER
_set_se_translator( SEHTranslator );
@@ -468,8 +475,6 @@ void TS::init( const string& modulename )
}
else
{
cvSetErrMode( CV_ErrModeLeaf );
cvRedirectError( cvGuiBoxReport );
#if defined WIN32 || defined _WIN32
#ifdef _MSC_VER
_set_se_translator( 0 );

View File

@@ -1100,6 +1100,23 @@ void minMaxLoc(const Mat& src, double* _minval, double* _maxval,
}
static int
normHamming(const uchar* src, size_t total, int cellSize)
{
int result = 0;
int mask = cellSize == 1 ? 1 : cellSize == 2 ? 3 : cellSize == 4 ? 15 : -1;
CV_Assert( mask >= 0 );
for( size_t i = 0; i < total; i++ )
{
unsigned a = src[i];
for( ; a != 0; a >>= cellSize )
result += (a & mask) != 0;
}
return result;
}
template<typename _Tp> static double
norm_(const _Tp* src, size_t total, int cn, int normType, double startval, const uchar* mask)
{
@@ -1216,8 +1233,36 @@ norm_(const _Tp* src1, const _Tp* src2, size_t total, int cn, int normType, doub
double norm(const Mat& src, int normType, const Mat& mask)
{
if( normType == NORM_HAMMING || normType == NORM_HAMMING2 )
{
if( !mask.empty() )
{
Mat temp;
bitwise_and(src, mask, temp);
return norm(temp, normType, Mat());
}
CV_Assert( src.depth() == CV_8U );
const Mat *arrays[]={&src, 0};
Mat planes[1];
NAryMatIterator it(arrays, planes);
size_t total = planes[0].total();
size_t i, nplanes = it.nplanes;
double result = 0;
int cellSize = normType == NORM_HAMMING ? 1 : 2;
for( i = 0; i < nplanes; i++, ++it )
result += normHamming(planes[0].data, total, cellSize);
return result;
}
int normType0 = normType;
normType = normType == NORM_L2SQR ? NORM_L2 : normType;
CV_Assert( mask.empty() || (src.size == mask.size && mask.type() == CV_8U) );
CV_Assert( normType == NORM_INF || normType == NORM_L1 || normType == NORM_L2 );
const Mat *arrays[]={&src, &mask, 0};
Mat planes[2];
@@ -1259,7 +1304,7 @@ double norm(const Mat& src, int normType, const Mat& mask)
CV_Error(CV_StsUnsupportedFormat, "");
};
}
if( normType == NORM_L2 )
if( normType0 == NORM_L2 )
result = sqrt(result);
return result;
}
@@ -1267,6 +1312,31 @@ double norm(const Mat& src, int normType, const Mat& mask)
double norm(const Mat& src1, const Mat& src2, int normType, const Mat& mask)
{
if( normType == NORM_HAMMING || normType == NORM_HAMMING2 )
{
Mat temp;
bitwise_xor(src1, src2, temp);
if( !mask.empty() )
bitwise_and(temp, mask, temp);
CV_Assert( temp.depth() == CV_8U );
const Mat *arrays[]={&temp, 0};
Mat planes[1];
NAryMatIterator it(arrays, planes);
size_t total = planes[0].total();
size_t i, nplanes = it.nplanes;
double result = 0;
int cellSize = normType == NORM_HAMMING ? 1 : 2;
for( i = 0; i < nplanes; i++, ++it )
result += normHamming(planes[0].data, total, cellSize);
return result;
}
int normType0 = normType;
normType = normType == NORM_L2SQR ? NORM_L2 : normType;
CV_Assert( src1.type() == src2.type() && src1.size == src2.size );
CV_Assert( mask.empty() || (src1.size == mask.size && mask.type() == CV_8U) );
CV_Assert( normType == NORM_INF || normType == NORM_L1 || normType == NORM_L2 );
@@ -1312,7 +1382,7 @@ double norm(const Mat& src1, const Mat& src2, int normType, const Mat& mask)
CV_Error(CV_StsUnsupportedFormat, "");
};
}
if( normType == NORM_L2 )
if( normType0 == NORM_L2 )
result = sqrt(result);
return result;
}