Minimize usages of legacy C API inside the library

This commit is contained in:
Andrey Kamaev
2013-04-15 15:27:09 +04:00
parent 4223a59497
commit 8f32902ce6
45 changed files with 184 additions and 238 deletions

View File

@@ -1,8 +1,5 @@
#include "opencv2/ts.hpp"
#include "opencv2/core/core_c.h"
#include "opencv2/core/utility.hpp"
#include "opencv2/core/private.hpp"
#ifdef GTEST_LINKED_AS_SHARED_LIBRARY

View File

@@ -40,6 +40,8 @@
//M*/
#include "precomp.hpp"
#include "opencv2/core/core_c.h"
#include <ctype.h>
#include <stdarg.h>
#include <stdlib.h>

View File

@@ -40,6 +40,7 @@
//M*/
#include "precomp.hpp"
#include "opencv2/core/core_c.h"
namespace cvtest
{

View File

@@ -645,7 +645,7 @@ void erode(const Mat& _src, Mat& dst, const Mat& _kernel, Point anchor,
}
if( anchor == Point(-1,-1) )
anchor = Point(kernel.cols/2, kernel.rows/2);
if( borderType == IPL_BORDER_CONSTANT )
if( borderType == BORDER_CONSTANT )
borderValue = getMaxVal(src.depth());
copyMakeBorder(_src, src, anchor.y, kernel.rows - anchor.y - 1,
anchor.x, kernel.cols - anchor.x - 1,
@@ -702,7 +702,7 @@ void dilate(const Mat& _src, Mat& dst, const Mat& _kernel, Point anchor,
}
if( anchor == Point(-1,-1) )
anchor = Point(kernel.cols/2, kernel.rows/2);
if( borderType == IPL_BORDER_CONSTANT )
if( borderType == BORDER_CONSTANT )
borderValue = getMinVal(src.depth());
copyMakeBorder(_src, src, anchor.y, kernel.rows - anchor.y - 1,
anchor.x, kernel.cols - anchor.x - 1,
@@ -778,7 +778,7 @@ void filter2D(const Mat& _src, Mat& dst, int ddepth, const Mat& kernel,
CV_Assert( kernel.type() == CV_32F || kernel.type() == CV_64F );
if( anchor == Point(-1,-1) )
anchor = Point(kernel.cols/2, kernel.rows/2);
if( borderType == IPL_BORDER_CONSTANT )
if( borderType == BORDER_CONSTANT )
borderValue = getMinVal(src.depth());
copyMakeBorder(_src, src, anchor.y, kernel.rows - anchor.y - 1,
anchor.x, kernel.cols - anchor.x - 1,
@@ -830,11 +830,11 @@ static int borderInterpolate( int p, int len, int borderType )
{
if( (unsigned)p < (unsigned)len )
;
else if( borderType == IPL_BORDER_REPLICATE )
else if( borderType == BORDER_REPLICATE )
p = p < 0 ? 0 : len - 1;
else if( borderType == IPL_BORDER_REFLECT || borderType == IPL_BORDER_REFLECT_101 )
else if( borderType == BORDER_REFLECT || borderType == BORDER_REFLECT_101 )
{
int delta = borderType == IPL_BORDER_REFLECT_101;
int delta = borderType == BORDER_REFLECT_101;
if( len == 1 )
return 0;
do
@@ -846,17 +846,17 @@ static int borderInterpolate( int p, int len, int borderType )
}
while( (unsigned)p >= (unsigned)len );
}
else if( borderType == IPL_BORDER_WRAP )
else if( borderType == BORDER_WRAP )
{
if( p < 0 )
p -= ((p-len+1)/len)*len;
if( p >= len )
p %= len;
}
else if( borderType == IPL_BORDER_CONSTANT )
else if( borderType == BORDER_CONSTANT )
p = -1;
else
CV_Error( CV_StsBadArg, "Unknown/unsupported border type" );
CV_Error( Error::StsBadArg, "Unknown/unsupported border type" );
return p;
}
@@ -868,7 +868,7 @@ void copyMakeBorder(const Mat& src, Mat& dst, int top, int bottom, int left, int
int i, j, k, esz = (int)src.elemSize();
int width = src.cols*esz, width1 = dst.cols*esz;
if( borderType == IPL_BORDER_CONSTANT )
if( borderType == BORDER_CONSTANT )
{
vector<uchar> valvec((src.cols + left + right)*esz);
uchar* val = &valvec[0];
@@ -1304,7 +1304,7 @@ double norm(const Mat& src, int normType, const Mat& mask)
result = norm_((const double*)sptr, total, cn, normType, result, mptr);
break;
default:
CV_Error(CV_StsUnsupportedFormat, "");
CV_Error(Error::StsUnsupportedFormat, "");
};
}
if( normType0 == NORM_L2 )
@@ -1382,7 +1382,7 @@ double norm(const Mat& src1, const Mat& src2, int normType, const Mat& mask)
result = norm_((const double*)sptr1, (const double*)sptr2, total, cn, normType, result, mptr);
break;
default:
CV_Error(CV_StsUnsupportedFormat, "");
CV_Error(Error::StsUnsupportedFormat, "");
};
}
if( normType0 == NORM_L2 )
@@ -1441,7 +1441,7 @@ double crossCorr(const Mat& src1, const Mat& src2)
result += crossCorr_((const double*)sptr1, (const double*)sptr2, total);
break;
default:
CV_Error(CV_StsUnsupportedFormat, "");
CV_Error(Error::StsUnsupportedFormat, "");
};
}
return result;
@@ -1574,7 +1574,7 @@ compare_(const _Tp* src1, const _Tp* src2, uchar* dst, size_t total, int cmpop)
dst[i] = src1[i] > src2[i] ? 255 : 0;
break;
default:
CV_Error(CV_StsBadArg, "Unknown comparison operation");
CV_Error(Error::StsBadArg, "Unknown comparison operation");
}
}
@@ -1610,7 +1610,7 @@ compareS_(const _Tp* src1, _WTp value, uchar* dst, size_t total, int cmpop)
dst[i] = src1[i] > value ? 255 : 0;
break;
default:
CV_Error(CV_StsBadArg, "Unknown comparison operation");
CV_Error(Error::StsBadArg, "Unknown comparison operation");
}
}
@@ -1657,7 +1657,7 @@ void compare(const Mat& src1, const Mat& src2, Mat& dst, int cmpop)
compare_((const double*)sptr1, (const double*)sptr2, dptr, total, cmpop);
break;
default:
CV_Error(CV_StsUnsupportedFormat, "");
CV_Error(Error::StsUnsupportedFormat, "");
}
}
}
@@ -1704,7 +1704,7 @@ void compare(const Mat& src, double value, Mat& dst, int cmpop)
compareS_((const double*)sptr, value, dptr, total, cmpop);
break;
default:
CV_Error(CV_StsUnsupportedFormat, "");
CV_Error(Error::StsUnsupportedFormat, "");
}
}
}
@@ -1836,7 +1836,7 @@ bool cmpUlps(const Mat& src1, const Mat& src2, int imaxDiff, double* _realmaxdif
realmaxdiff = cmpUlpsFlt_((const int64*)sptr1, (const int64*)sptr2, total, imaxDiff, startidx, idx);
break;
default:
CV_Error(CV_StsUnsupportedFormat, "");
CV_Error(Error::StsUnsupportedFormat, "");
}
if(_realmaxdiff)
@@ -1925,7 +1925,7 @@ int check( const Mat& a, double fmin, double fmax, vector<int>* _idx )
checkFlt_((const double*)aptr, total, fmin, fmax, startidx, idx);
break;
default:
CV_Error(CV_StsUnsupportedFormat, "");
CV_Error(Error::StsUnsupportedFormat, "");
}
if( idx != 0 )
@@ -2344,7 +2344,7 @@ void transform( const Mat& src, Mat& dst, const Mat& transmat, const Mat& _shift
transform_((const double*)sptr, (double*)dptr, total, scn, dcn, mat);
break;
default:
CV_Error(CV_StsUnsupportedFormat, "");
CV_Error(Error::StsUnsupportedFormat, "");
}
}
}
@@ -2401,7 +2401,7 @@ static void minmax(const Mat& src1, const Mat& src2, Mat& dst, char op)
minmax_((const double*)sptr1, (const double*)sptr2, (double*)dptr, total, op);
break;
default:
CV_Error(CV_StsUnsupportedFormat, "");
CV_Error(Error::StsUnsupportedFormat, "");
}
}
}
@@ -2469,7 +2469,7 @@ static void minmax(const Mat& src1, double val, Mat& dst, char op)
minmax_((const double*)sptr1, saturate_cast<double>(val), (double*)dptr, total, op);
break;
default:
CV_Error(CV_StsUnsupportedFormat, "");
CV_Error(Error::StsUnsupportedFormat, "");
}
}
}
@@ -2541,7 +2541,7 @@ static void muldiv(const Mat& src1, const Mat& src2, Mat& dst, double scale, cha
muldiv_((const double*)sptr1, (const double*)sptr2, (double*)dptr, total, scale, op);
break;
default:
CV_Error(CV_StsUnsupportedFormat, "");
CV_Error(Error::StsUnsupportedFormat, "");
}
}
}
@@ -2626,7 +2626,7 @@ Scalar mean(const Mat& src, const Mat& mask)
mean_((const double*)sptr, mptr, total, cn, sum, nz);
break;
default:
CV_Error(CV_StsUnsupportedFormat, "");
CV_Error(Error::StsUnsupportedFormat, "");
}
}
@@ -2863,7 +2863,7 @@ static void writeElems(std::ostream& out, const void* data, int nelems, int dept
out.precision(pp);
}
else
CV_Error(CV_StsUnsupportedFormat, "");
CV_Error(Error::StsUnsupportedFormat, "");
}