some more fixes towards binary compatibility

This commit is contained in:
Vadim Pisarevsky 2012-10-09 15:56:16 +04:00
parent e2ff0ed1fb
commit a8c5e35619
7 changed files with 104 additions and 90 deletions

View File

@ -1388,7 +1388,7 @@ public:
virtual bool fixedType() const;
virtual bool needed() const;
virtual Mat& getMatRef(int i=-1) const;
virtual gpu::GpuMat& getGpuMatRef() const;
/*virtual*/ gpu::GpuMat& getGpuMatRef() const;
virtual void create(Size sz, int type, int i=-1, bool allowTransposed=false, int fixedDepthMask=0) const;
virtual void create(int rows, int cols, int type, int i=-1, bool allowTransposed=false, int fixedDepthMask=0) const;
virtual void create(int dims, const int* size, int type, int i=-1, bool allowTransposed=false, int fixedDepthMask=0) const;
@ -2131,7 +2131,7 @@ CV_EXPORTS_W void merge(InputArrayOfArrays mv, OutputArray dst);
//! copies each plane of a multi-channel array to a dedicated array
CV_EXPORTS void split(const Mat& src, Mat* mvbegin);
CV_EXPORTS void split(const Mat& src, vector<Mat>& mv );
CV_EXPORTS void split(const Mat& m, vector<Mat>& mv );
//! copies each plane of a multi-channel array to a dedicated array
CV_EXPORTS_W void split(InputArray m, OutputArrayOfArrays mv);
@ -4392,6 +4392,11 @@ public:
int (Algorithm::*getter)()=0,
void (Algorithm::*setter)(int)=0,
const string& help=string());
void addParam(Algorithm& algo, const char* name,
short& value, bool readOnly=false,
int (Algorithm::*getter)()=0,
void (Algorithm::*setter)(int)=0,
const string& help=string());
void addParam(Algorithm& algo, const char* name,
bool& value, bool readOnly=false,
int (Algorithm::*getter)()=0,
@ -4441,7 +4446,7 @@ protected:
struct CV_EXPORTS Param
{
enum { INT=0, BOOLEAN=1, REAL=2, STRING=3, MAT=4, MAT_VECTOR=5, ALGORITHM=6, FLOAT=7, UNSIGNED_INT=8, UINT64=9 };
enum { INT=0, BOOLEAN=1, REAL=2, STRING=3, MAT=4, MAT_VECTOR=5, ALGORITHM=6, FLOAT=7, UNSIGNED_INT=8, UINT64=9, SHORT=10 };
Param();
Param(int _type, bool _readonly, int _offset,
@ -4472,6 +4477,14 @@ template<> struct ParamType<int>
enum { type = Param::INT };
};
template<> struct ParamType<short>
{
typedef int const_param_type;
typedef int member_type;
enum { type = Param::SHORT };
};
template<> struct ParamType<double>
{
typedef double const_param_type;
@ -4542,8 +4555,8 @@ template<> struct ParamType<uint64>
class CV_EXPORTS CommandLineParser
{
public:
CommandLineParser(int argc, const char* const argv[], const char* keys);
CommandLineParser(int argc, const char* const argv[], const string& keys);
CommandLineParser(int argc, const char* const argv[], const char* key_map);
CommandLineParser(int argc, const char* const argv[], const string& key_map);
CommandLineParser(const CommandLineParser& parser);
CommandLineParser& operator = (const CommandLineParser& parser);
@ -4565,7 +4578,7 @@ public:
return val;
}
bool has(const string& name);
bool has(const string& keys);
bool check() const;
void about(const string& message);

View File

@ -456,18 +456,27 @@ void AlgorithmInfo::set(Algorithm* algo, const char* parameter, int argType, con
if( argType == Param::INT || argType == Param::BOOLEAN || argType == Param::REAL )
{
CV_Assert( p->type == Param::INT || p->type == Param::REAL || p->type == Param::BOOLEAN );
CV_Assert( p->type == Param::INT || p->type == Param::REAL || p->type == Param::BOOLEAN ||
(p->type == Param::SHORT && argType == Param::INT) );
if( p->type == Param::INT )
{
int val = argType == Param::INT ? *(const int*)value :
argType == Param::BOOLEAN ? (int)*(const bool*)value :
saturate_cast<int>(*(const double*)value);
argType == Param::BOOLEAN ? (int)*(const bool*)value :
saturate_cast<int>(*(const double*)value);
if( p->setter )
(algo->*f.set_int)(val);
else
*(int*)((uchar*)algo + p->offset) = val;
}
else if( p->type == Param::SHORT )
{
int val = *(const int*)value;
if( p->setter )
(algo->*f.set_int)(val);
else
*(short*)((uchar*)algo + p->offset) = (short)val;
}
else if( p->type == Param::BOOLEAN )
{
bool val = argType == Param::INT ? *(const int*)value != 0 :
@ -554,6 +563,13 @@ void AlgorithmInfo::get(const Algorithm* algo, const char* parameter, int argTyp
else
*(double*)value = val;
}
else if( p->type == Param::SHORT )
{
CV_Assert( argType == Param::INT );
int val = p->getter ? (algo->*f.get_int)() : *(short*)((uchar*)algo + p->offset);
*(int*)value = val;
}
else if( p->type == Param::BOOLEAN )
{
CV_Assert( argType == Param::INT || argType == Param::BOOLEAN || argType == Param::REAL );
@ -639,7 +655,7 @@ void AlgorithmInfo::addParam_(Algorithm& algo, const char* parameter, int argTyp
CV_Assert( argType == Param::INT || argType == Param::BOOLEAN ||
argType == Param::REAL || argType == Param::STRING ||
argType == Param::MAT || argType == Param::MAT_VECTOR ||
argType == Param::ALGORITHM );
argType == Param::ALGORITHM || argType == Param::SHORT );
data->params.add(string(parameter), Param(argType, readOnly,
(int)((size_t)value - (size_t)(void*)&algo),
getter, setter, help));
@ -656,6 +672,16 @@ void AlgorithmInfo::addParam(Algorithm& algo, const char* parameter,
(Algorithm::Getter)getter, (Algorithm::Setter)setter, help);
}
void AlgorithmInfo::addParam(Algorithm& algo, const char* parameter,
short& value, bool readOnly,
int (Algorithm::*getter)(),
void (Algorithm::*setter)(int),
const string& help)
{
addParam_(algo, parameter, ParamType<int>::type, &value, readOnly,
(Algorithm::Getter)getter, (Algorithm::Setter)setter, help);
}
void AlgorithmInfo::addParam(Algorithm& algo, const char* parameter,
bool& value, bool readOnly,
int (Algorithm::*getter)(),

View File

@ -586,7 +586,7 @@ protected:
int threshold;
bool nonmaxSuppression;
int type;
short type;
};

View File

@ -1192,15 +1192,12 @@ public:
}
private:
const Mat src;
Mat src;
Mat dst;
const int* xofs, *yofs;
const AT* alpha, *_beta;
const Size ssize, dsize;
const int ksize, xmin, xmax;
resizeGeneric_Invoker(const resizeGeneric_Invoker&);
resizeGeneric_Invoker& operator=(const resizeGeneric_Invoker&);
Size ssize, dsize;
int ksize, xmin, xmax;
};
template<class HResize, class VResize>
@ -1236,10 +1233,10 @@ struct ResizeAreaFastNoVec
int operator() (const T* /*S*/, T* /*D*/, int /*w*/) const { return 0; }
};
template <typename T, typename WT>
struct ResizeAreaFast_2x2_8u
template<typename T>
struct ResizeAreaFastVec
{
ResizeAreaFast_2x2_8u(int _scale_x, int _scale_y, int _cn, int _step/*, const int* _ofs*/) :
ResizeAreaFastVec(int _scale_x, int _scale_y, int _cn, int _step/*, const int* _ofs*/) :
scale_x(_scale_x), scale_y(_scale_y), cn(_cn), step(_step)/*, ofs(_ofs)*/
{
fast_mode = scale_x == 2 && scale_y == 2 && (cn == 1 || cn == 3 || cn == 4);
@ -1250,47 +1247,44 @@ struct ResizeAreaFast_2x2_8u
if( !fast_mode )
return 0;
const T* nextS = S + step;
const T* nextS = (const T*)((const uchar*)S + step);
int dx = 0;
if (cn == 1)
for( ; dx < w; ++dx )
{
int index = dx*2;
D[dx] = (S[index] + S[index+1] + nextS[index] + nextS[index+1] + 2) >> 2;
}
else if (cn == 3)
for( ; dx < w; dx += 3 )
{
int index = dx*2;
D[dx] = (S[index] + S[index+3] + nextS[index] + nextS[index+3] + 2) >> 2;
D[dx+1] = (S[index+1] + S[index+4] + nextS[index+1] + nextS[index+4] + 2) >> 2;
D[dx+2] = (S[index+2] + S[index+5] + nextS[index+2] + nextS[index+5] + 2) >> 2;
}
else
{
assert(cn == 4);
for( ; dx < w; dx += 4 )
for( ; dx < w; ++dx )
{
int index = dx*2;
D[dx] = (S[index] + S[index+4] + nextS[index] + nextS[index+4] + 2) >> 2;
D[dx+1] = (S[index+1] + S[index+5] + nextS[index+1] + nextS[index+5] + 2) >> 2;
D[dx+2] = (S[index+2] + S[index+6] + nextS[index+2] + nextS[index+6] + 2) >> 2;
D[dx+3] = (S[index+3] + S[index+7] + nextS[index+3] + nextS[index+7] + 2) >> 2;
D[dx] = (T)((S[index] + S[index+1] + nextS[index] + nextS[index+1] + 2) >> 2);
}
else if (cn == 3)
for( ; dx < w; dx += 3 )
{
int index = dx*2;
D[dx] = (T)((S[index] + S[index+3] + nextS[index] + nextS[index+3] + 2) >> 2);
D[dx+1] = (T)((S[index+1] + S[index+4] + nextS[index+1] + nextS[index+4] + 2) >> 2);
D[dx+2] = (T)((S[index+2] + S[index+5] + nextS[index+2] + nextS[index+5] + 2) >> 2);
}
else
{
assert(cn == 4);
for( ; dx < w; dx += 4 )
{
int index = dx*2;
D[dx] = (T)((S[index] + S[index+4] + nextS[index] + nextS[index+4] + 2) >> 2);
D[dx+1] = (T)((S[index+1] + S[index+5] + nextS[index+1] + nextS[index+5] + 2) >> 2);
D[dx+2] = (T)((S[index+2] + S[index+6] + nextS[index+2] + nextS[index+6] + 2) >> 2);
D[dx+3] = (T)((S[index+3] + S[index+7] + nextS[index+3] + nextS[index+7] + 2) >> 2);
}
}
}
return dx;
}
private:
const int scale_x, scale_y;
const int cn;
int scale_x, scale_y;
int cn;
bool fast_mode;
const int step;
ResizeAreaFast_2x2_8u(const ResizeAreaFast_2x2_8u&);
ResizeAreaFast_2x2_8u& operator=(const ResizeAreaFast_2x2_8u&);
int step;
};
template <typename T, typename WT, typename VecOp>
@ -1376,11 +1370,8 @@ public:
private:
const Mat src;
Mat dst;
const int scale_x, scale_y;
int scale_x, scale_y;
const int *ofs, *xofs;
resizeAreaFast_Invoker(const resizeAreaFast_Invoker&);
resizeAreaFast_Invoker& operator=(const resizeAreaFast_Invoker&);
};
template<typename T, typename WT, typename VecOp>
@ -1413,7 +1404,7 @@ public:
{
}
void resize_signle_band(const Range& range) const
void resize_single_band(const Range& range) const
{
Size ssize = src.size(), dsize = dst.size();
int cn = src.channels();
@ -1520,21 +1511,18 @@ public:
for (int i = range.start; i < range.end; ++i)
{
Range band_range(bands[i].first, bands[i].second);
resize_signle_band(band_range);
resize_single_band(band_range);
}
}
private:
const Mat src;
Mat src;
Mat dst;
const DecimateAlpha* xofs;
const int xofs_count;
const double scale_y_;
int xofs_count;
double scale_y_;
const int *cur_dy_ofs;
std::vector<std::pair<int, int> > bands;
resizeArea_Invoker(const resizeArea_Invoker&);
resizeArea_Invoker& operator=(const resizeArea_Invoker&);
};
template <typename T, typename WT>
@ -1566,7 +1554,8 @@ static void resizeArea_( const Mat& src, Mat& dst, const DecimateAlpha* xofs, in
Range range(0, bands.size());
resizeArea_Invoker<T, WT> invoker(src, dst, xofs, xofs_count, scale_y_, cur_dy_ofs, bands);
parallel_for_(range, invoker);
//parallel_for_(range, invoker);
invoker(Range(range.start, range.end));
}
@ -1678,10 +1667,10 @@ void cv::resize( InputArray _src, OutputArray _dst, Size dsize,
static ResizeAreaFastFunc areafast_tab[] =
{
resizeAreaFast_<uchar, int, ResizeAreaFast_2x2_8u<uchar, int> >,
resizeAreaFast_<uchar, int, ResizeAreaFastVec<uchar> >,
0,
resizeAreaFast_<ushort, float, ResizeAreaFastNoVec<ushort, float> >,
resizeAreaFast_<short, float, ResizeAreaFastNoVec<short, float> >,
resizeAreaFast_<ushort, float, ResizeAreaFastVec<ushort> >,
resizeAreaFast_<short, float, ResizeAreaFastVec<short> >,
0,
resizeAreaFast_<float, float, ResizeAreaFastNoVec<float, float> >,
resizeAreaFast_<double, double, ResizeAreaFastNoVec<double, double> >,
@ -1739,11 +1728,9 @@ void cv::resize( InputArray _src, OutputArray _dst, Size dsize,
// in case of scale_x && scale_y is equal to 2
// INTER_AREA (fast) also is equal to INTER_LINEAR
if ( interpolation == INTER_LINEAR && std::abs(scale_x - 2.0) < DBL_EPSILON &&
std::abs(scale_y - 2.0) < DBL_EPSILON)
if( interpolation == INTER_LINEAR && is_area_fast && iscale_x == 2 && iscale_y == 2 )
{
interpolation = INTER_AREA;
is_area_fast = true;
}
// true "area" interpolation is only implemented for the case (scale_x <= 1 && scale_y <= 1).
@ -2882,18 +2869,16 @@ public:
}
private:
const Mat src;
Mat src;
Mat dst;
const Mat map1, map2, *m1, *m2;
Mat map1, map2;
const Mat *m1, *m2;
int interpolation, borderType;
const Scalar borderValue;
Scalar borderValue;
int planar_input;
RemapNNFunc nnfunc;
RemapFunc ifunc;
const void *ctab;
remapInvoker(const remapInvoker&);
remapInvoker& operator=(const remapInvoker&);
};
}
@ -3252,15 +3237,12 @@ public:
}
private:
const Mat src;
Mat src;
Mat dst;
int interpolation, borderType;
const Scalar borderValue;
Scalar borderValue;
int *adelta, *bdelta;
double *M;
warpAffineInvoker(const warpAffineInvoker&);
warpAffineInvoker& operator=(const warpAffineInvoker&);
};
}
@ -3409,13 +3391,11 @@ public:
}
private:
const Mat src;
Mat src;
Mat dst;
double* M;
int interpolation, borderType;
const Scalar borderValue;
warpPerspectiveInvoker(const warpPerspectiveInvoker&);
warpPerspectiveInvoker& operator=(const warpPerspectiveInvoker&);
Scalar borderValue;
};
}

View File

@ -2069,6 +2069,7 @@ protected:
char delimiter;
char miss_ch;
short header_lines_number;
//char flt_separator;
CvMat* values;
@ -2093,8 +2094,6 @@ protected:
int* sample_idx; // data of train_sample_idx and test_sample_idx
cv::RNG* rng;
int header_lines_number;
};

View File

@ -121,7 +121,7 @@ void CvMLData::clear()
void CvMLData::set_header_lines_number( int idx )
{
header_lines_number = std::max(0, idx);
header_lines_number = (short)std::max(0, idx);
}
int CvMLData::get_header_lines_number() const

View File

@ -1572,13 +1572,9 @@ cvHaarDetectObjectsForROC( const CvArr* _img,
cvIntegral( &img1, &sum1, &sqsum1, _tilted );
int ystep = factor > 2 ? 1 : 2;
#ifdef HAVE_TBB
const int LOCS_PER_THREAD = 1000;
int stripCount = ((sz1.width/ystep)*(sz1.height + ystep-1)/ystep + LOCS_PER_THREAD/2)/LOCS_PER_THREAD;
stripCount = std::min(std::max(stripCount, 1), 100);
#else
const int stripCount = 1;
#endif
#ifdef HAVE_IPP
if( use_ipp )