class CV_EXPORTS DescriptorMatcher
{
public:
+ virtual ~DescriptorMatcher() {}
/*
* Add descriptors to the training set
* descriptors Descriptors to add to the training set
for( int i = 0; i < descriptors_1.rows; i++ )
{
- const ValueType* d1 = descriptors_1.ptr<ValueType>(i);
+ const ValueType* d1 = (const ValueType*)(descriptors_1.data + descriptors_1.step*i);
int matchIndex = -1;
DistanceType matchDistance = std::numeric_limits<DistanceType>::max();
{
if( possibleMatch(mask, i, j) )
{
- const ValueType* d2 = descriptors_2.ptr<ValueType>(j);
+ const ValueType* d2 = (const ValueType*)(descriptors_2.data + descriptors_2.step*j);
DistanceType curDistance = distance(d1, d2, dimension);
if( curDistance < matchDistance )
{
for( int i = 0; i < descriptors_1.rows; i++ )
{
- const ValueType* d1 = descriptors_1.ptr<ValueType>(i);
+ const ValueType* d1 = (const ValueType*)(descriptors_1.data + descriptors_1.step*i);
for( int j = 0; j < descriptors_2.rows; j++ )
{
if( possibleMatch(mask, i, j) )
{
- const ValueType* d2 = descriptors_2.ptr<ValueType>(j);
+ const ValueType* d2 = (const ValueType*)(descriptors_2.data + descriptors_2.step*j);
DistanceType curDistance = distance(d1, d2, dimension);
if( curDistance < threshold )
{
sum.setTo(Scalar(0));\r
max.setTo(Scalar(-DBL_MAX));\r
min.setTo(Scalar(DBL_MAX));\r
+ \r
+ const Mat_<Type>& src_ = src;\r
+ Mat_<double>& sum_ = (Mat_<double>&)sum;\r
+ Mat_<double>& min_ = (Mat_<double>&)min;\r
+ Mat_<double>& max_ = (Mat_<double>&)max;\r
\r
if( dim == 0 )\r
{\r
{\r
for( int ci = 0; ci < src.cols; ci++ )\r
{\r
- sum.at<double>(0, ci) += src.at<Type>(ri, ci);\r
- max.at<double>(0, ci) = std::max( max.at<double>(0, ci), (double)src.at<Type>(ri, ci) );\r
- min.at<double>(0, ci) = std::min( min.at<double>(0, ci), (double)src.at<Type>(ri, ci) );\r
+ sum_(0, ci) += src_(ri, ci);\r
+ max_(0, ci) = std::max( max_(0, ci), (double)src_(ri, ci) );\r
+ min_(0, ci) = std::min( min_(0, ci), (double)src_(ri, ci) );\r
}\r
}\r
}\r
{\r
for( int ri = 0; ri < src.rows; ri++ )\r
{\r
- sum.at<double>(ri, 0) += src.at<Type>(ri, ci);\r
- max.at<double>(ri, 0) = std::max( max.at<double>(ri, 0), (double)src.at<Type>(ri, ci) );\r
- min.at<double>(ri, 0) = std::min( min.at<double>(ri, 0), (double)src.at<Type>(ri, ci) );\r
+ sum_(ri, 0) += src_(ri, ci);\r
+ max_(ri, 0) = std::max( max_(ri, 0), (double)src_(ri, ci) );\r
+ min_(ri, 0) = std::min( min_(ri, 0), (double)src_(ri, ci) );\r
}\r
}\r
}\r
{\r
int srcType = src.type();\r
bool support = false;\r
- if( opType == CV_REDUCE_SUM || opType == CV_REDUCE_AVG )
- {
- if( srcType == CV_8U && (dstType == CV_32S || dstType == CV_32F || dstType == CV_64F) )
- support = true;
- if( srcType == CV_16U && (dstType == CV_32F || dstType == CV_64F) )
- support = true;
- if( srcType == CV_16S && (dstType == CV_32F || dstType == CV_64F) )
- support = true;
- if( srcType == CV_32F && (dstType == CV_32F || dstType == CV_64F) )
- support = true;
- if( srcType == CV_64F && dstType == CV_64F)
- support = true;
- }
- else if( opType == CV_REDUCE_MAX )
- {
- if( srcType == CV_8U && dstType == CV_8U )
- support = true;
- if( srcType == CV_32F && dstType == CV_32F )
- support = true;
- if( srcType == CV_64F && dstType == CV_64F )
- support = true;
- }
- else if( opType == CV_REDUCE_MIN )
- {
- if( srcType == CV_8U && dstType == CV_8U)
- support = true;
- if( srcType == CV_32F && dstType == CV_32F)
- support = true;
- if( srcType == CV_64F && dstType == CV_64F)
- support = true;
- }
+ if( opType == CV_REDUCE_SUM || opType == CV_REDUCE_AVG )\r
+ {\r
+ if( srcType == CV_8U && (dstType == CV_32S || dstType == CV_32F || dstType == CV_64F) )\r
+ support = true;\r
+ if( srcType == CV_16U && (dstType == CV_32F || dstType == CV_64F) )\r
+ support = true;\r
+ if( srcType == CV_16S && (dstType == CV_32F || dstType == CV_64F) )\r
+ support = true;\r
+ if( srcType == CV_32F && (dstType == CV_32F || dstType == CV_64F) )\r
+ support = true;\r
+ if( srcType == CV_64F && dstType == CV_64F)\r
+ support = true;\r
+ }\r
+ else if( opType == CV_REDUCE_MAX )\r
+ {\r
+ if( srcType == CV_8U && dstType == CV_8U )\r
+ support = true;\r
+ if( srcType == CV_32F && dstType == CV_32F )\r
+ support = true;\r
+ if( srcType == CV_64F && dstType == CV_64F )\r
+ support = true;\r
+ }\r
+ else if( opType == CV_REDUCE_MIN )\r
+ {\r
+ if( srcType == CV_8U && dstType == CV_8U)\r
+ support = true;\r
+ if( srcType == CV_32F && dstType == CV_32F)\r
+ support = true;\r
+ if( srcType == CV_64F && dstType == CV_64F)\r
+ support = true;\r
+ }\r
if( !support )\r
return CvTS::OK;\r
\r
reduce( src, _dst, dim, opType, dstType );\r
_dst.convertTo( dst, CV_64FC1 );\r
if( norm( opRes, dst, NORM_INF ) > eps )\r
- {
+ {\r
char msg[100];\r
const char* opTypeStr = opType == CV_REDUCE_SUM ? "CV_REDUCE_SUM" :\r
opType == CV_REDUCE_AVG ? "CV_REDUCE_AVG" :\r
getMatTypeStr( src.type(), srcTypeStr );\r
getMatTypeStr( dstType, dstTypeStr );\r
const char* dimStr = dim == 0 ? "ROWS" : "COLS";\r
-
- sprintf( msg, "bad accuracy with srcType = %s, dstType = %s, opType = %s, dim = %s",
- srcTypeStr.c_str(), dstTypeStr.c_str(), opTypeStr, dimStr );
- ts->printf( CvTS::LOG, msg );
- return CvTS::FAIL_BAD_ACCURACY;
+\r
+ sprintf( msg, "bad accuracy with srcType = %s, dstType = %s, opType = %s, dim = %s",\r
+ srcTypeStr.c_str(), dstTypeStr.c_str(), opTypeStr, dimStr );\r
+ ts->printf( CvTS::LOG, msg );\r
+ return CvTS::FAIL_BAD_ACCURACY;\r
}\r
return CvTS::OK;\r
}\r