1
0
mirror of https://github.com/opencv/opencv.git synced 2026-07-31 00:03:03 +04:00

Warning fixes continued

This commit is contained in:
Andrey Kamaev
2012-06-09 15:00:04 +00:00
parent f6b451c607
commit f2d3b9b4a1
127 changed files with 6298 additions and 6277 deletions
+2 -4
View File
@@ -5,13 +5,11 @@ ocv_module_include_directories(${ZLIB_INCLUDE_DIR})
if(HAVE_CUDA)
file(GLOB lib_cuda "src/cuda/*.cu")
source_group("Cuda" FILES "${lib_cuda}")
include_directories(AFTER SYSTEM ${CUDA_INCLUDE_DIRS})
ocv_include_directories("${OpenCV_SOURCE_DIR}/modules/gpu/src" "${OpenCV_SOURCE_DIR}/modules/gpu/src/cuda")
ocv_include_directories("${OpenCV_SOURCE_DIR}/modules/gpu/src" "${OpenCV_SOURCE_DIR}/modules/gpu/src/cuda" ${CUDA_INCLUDE_DIRS})
ocv_warnings_disable(CMAKE_CXX_FLAGS -Wundef)
ocv_cuda_compile(cuda_objs ${lib_cuda})
OCV_CUDA_COMPILE(cuda_objs ${lib_cuda})
set(cuda_link_libs ${CUDA_LIBRARIES} ${CUDA_npp_LIBRARY})
else()
set(lib_cuda "")
+5 -5
View File
@@ -366,12 +366,12 @@ namespace cv { namespace gpu
return m;
}
inline void GpuMat::assignTo(GpuMat& m, int type) const
inline void GpuMat::assignTo(GpuMat& m, int _type) const
{
if (type < 0)
if (_type < 0)
m = *this;
else
convertTo(m, type);
convertTo(m, _type);
}
inline size_t GpuMat::step1() const
@@ -434,9 +434,9 @@ namespace cv { namespace gpu
create(size_.height, size_.width, type_);
}
inline GpuMat GpuMat::operator()(Range rowRange, Range colRange) const
inline GpuMat GpuMat::operator()(Range _rowRange, Range _colRange) const
{
return GpuMat(*this, rowRange, colRange);
return GpuMat(*this, _rowRange, _colRange);
}
inline GpuMat GpuMat::operator()(Rect roi) const
File diff suppressed because it is too large Load Diff
@@ -47,282 +47,287 @@
#include "opencv2/core/core.hpp"
namespace cv
namespace cv
{
//! Smart pointer for OpenGL buffer memory with reference counting.
class CV_EXPORTS GlBuffer
//! Smart pointer for OpenGL buffer memory with reference counting.
class CV_EXPORTS GlBuffer
{
public:
enum Usage
{
public:
enum Usage
{
ARRAY_BUFFER = 0x8892, // buffer will use for OpenGL arrays (vertices, colors, normals, etc)
TEXTURE_BUFFER = 0x88EC // buffer will ise for OpenGL textures
};
//! create empty buffer
explicit GlBuffer(Usage usage);
//! create buffer
GlBuffer(int rows, int cols, int type, Usage usage);
GlBuffer(Size size, int type, Usage usage);
//! copy from host/device memory
GlBuffer(InputArray mat, Usage usage);
void create(int rows, int cols, int type, Usage usage);
inline void create(Size size, int type, Usage usage) { create(size.height, size.width, type, usage); }
inline void create(int rows, int cols, int type) { create(rows, cols, type, usage()); }
inline void create(Size size, int type) { create(size.height, size.width, type, usage()); }
void release();
//! copy from host/device memory
void copyFrom(InputArray mat);
void bind() const;
void unbind() const;
//! map to host memory
Mat mapHost();
void unmapHost();
//! map to device memory
gpu::GpuMat mapDevice();
void unmapDevice();
inline int rows() const { return rows_; }
inline int cols() const { return cols_; }
inline Size size() const { return Size(cols_, rows_); }
inline bool empty() const { return rows_ == 0 || cols_ == 0; }
inline int type() const { return type_; }
inline int depth() const { return CV_MAT_DEPTH(type_); }
inline int channels() const { return CV_MAT_CN(type_); }
inline int elemSize() const { return CV_ELEM_SIZE(type_); }
inline int elemSize1() const { return CV_ELEM_SIZE1(type_); }
inline Usage usage() const { return usage_; }
class Impl;
private:
int rows_;
int cols_;
int type_;
Usage usage_;
Ptr<Impl> impl_;
ARRAY_BUFFER = 0x8892, // buffer will use for OpenGL arrays (vertices, colors, normals, etc)
TEXTURE_BUFFER = 0x88EC // buffer will ise for OpenGL textures
};
template <> CV_EXPORTS void Ptr<GlBuffer::Impl>::delete_obj();
//! create empty buffer
explicit GlBuffer(Usage usage);
//! Smart pointer for OpenGL 2d texture memory with reference counting.
class CV_EXPORTS GlTexture
//! create buffer
GlBuffer(int rows, int cols, int type, Usage usage);
GlBuffer(Size size, int type, Usage usage);
//! copy from host/device memory
GlBuffer(InputArray mat, Usage usage);
void create(int rows, int cols, int type, Usage usage);
void create(Size size, int type, Usage usage);
void create(int rows, int cols, int type);
void create(Size size, int type);
void release();
//! copy from host/device memory
void copyFrom(InputArray mat);
void bind() const;
void unbind() const;
//! map to host memory
Mat mapHost();
void unmapHost();
//! map to device memory
gpu::GpuMat mapDevice();
void unmapDevice();
inline int rows() const { return rows_; }
inline int cols() const { return cols_; }
inline Size size() const { return Size(cols_, rows_); }
inline bool empty() const { return rows_ == 0 || cols_ == 0; }
inline int type() const { return type_; }
inline int depth() const { return CV_MAT_DEPTH(type_); }
inline int channels() const { return CV_MAT_CN(type_); }
inline int elemSize() const { return CV_ELEM_SIZE(type_); }
inline int elemSize1() const { return CV_ELEM_SIZE1(type_); }
inline Usage usage() const { return usage_; }
class Impl;
private:
int rows_;
int cols_;
int type_;
Usage usage_;
Ptr<Impl> impl_;
};
template <> CV_EXPORTS void Ptr<GlBuffer::Impl>::delete_obj();
//! Smart pointer for OpenGL 2d texture memory with reference counting.
class CV_EXPORTS GlTexture
{
public:
//! create empty texture
GlTexture();
//! create texture
GlTexture(int rows, int cols, int type);
GlTexture(Size size, int type);
//! copy from host/device memory
explicit GlTexture(InputArray mat, bool bgra = true);
void create(int rows, int cols, int type);
void create(Size size, int type);
void release();
//! copy from host/device memory
void copyFrom(InputArray mat, bool bgra = true);
void bind() const;
void unbind() const;
inline int rows() const { return rows_; }
inline int cols() const { return cols_; }
inline Size size() const { return Size(cols_, rows_); }
inline bool empty() const { return rows_ == 0 || cols_ == 0; }
inline int type() const { return type_; }
inline int depth() const { return CV_MAT_DEPTH(type_); }
inline int channels() const { return CV_MAT_CN(type_); }
inline int elemSize() const { return CV_ELEM_SIZE(type_); }
inline int elemSize1() const { return CV_ELEM_SIZE1(type_); }
class Impl;
private:
int rows_;
int cols_;
int type_;
Ptr<Impl> impl_;
GlBuffer buf_;
};
template <> CV_EXPORTS void Ptr<GlTexture::Impl>::delete_obj();
//! OpenGL Arrays
class CV_EXPORTS GlArrays
{
public:
inline GlArrays()
: vertex_(GlBuffer::ARRAY_BUFFER), color_(GlBuffer::ARRAY_BUFFER), bgra_(true), normal_(GlBuffer::ARRAY_BUFFER), texCoord_(GlBuffer::ARRAY_BUFFER)
{
public:
//! create empty texture
GlTexture();
//! create texture
GlTexture(int rows, int cols, int type);
GlTexture(Size size, int type);
//! copy from host/device memory
explicit GlTexture(InputArray mat, bool bgra = true);
void create(int rows, int cols, int type);
inline void create(Size size, int type) { create(size.height, size.width, type); }
void release();
//! copy from host/device memory
void copyFrom(InputArray mat, bool bgra = true);
void bind() const;
void unbind() const;
inline int rows() const { return rows_; }
inline int cols() const { return cols_; }
inline Size size() const { return Size(cols_, rows_); }
inline bool empty() const { return rows_ == 0 || cols_ == 0; }
inline int type() const { return type_; }
inline int depth() const { return CV_MAT_DEPTH(type_); }
inline int channels() const { return CV_MAT_CN(type_); }
inline int elemSize() const { return CV_ELEM_SIZE(type_); }
inline int elemSize1() const { return CV_ELEM_SIZE1(type_); }
class Impl;
private:
int rows_;
int cols_;
int type_;
Ptr<Impl> impl_;
GlBuffer buf_;
};
template <> CV_EXPORTS void Ptr<GlTexture::Impl>::delete_obj();
//! OpenGL Arrays
class CV_EXPORTS GlArrays
{
public:
inline GlArrays()
: vertex_(GlBuffer::ARRAY_BUFFER), color_(GlBuffer::ARRAY_BUFFER), bgra_(true), normal_(GlBuffer::ARRAY_BUFFER), texCoord_(GlBuffer::ARRAY_BUFFER)
{
}
void setVertexArray(InputArray vertex);
inline void resetVertexArray() { vertex_.release(); }
void setColorArray(InputArray color, bool bgra = true);
inline void resetColorArray() { color_.release(); }
void setNormalArray(InputArray normal);
inline void resetNormalArray() { normal_.release(); }
void setTexCoordArray(InputArray texCoord);
inline void resetTexCoordArray() { texCoord_.release(); }
void bind() const;
void unbind() const;
inline int rows() const { return vertex_.rows(); }
inline int cols() const { return vertex_.cols(); }
inline Size size() const { return vertex_.size(); }
inline bool empty() const { return vertex_.empty(); }
private:
GlBuffer vertex_;
GlBuffer color_;
bool bgra_;
GlBuffer normal_;
GlBuffer texCoord_;
};
//! OpenGL Font
class CV_EXPORTS GlFont
{
public:
enum Weight
{
WEIGHT_LIGHT = 300,
WEIGHT_NORMAL = 400,
WEIGHT_SEMIBOLD = 600,
WEIGHT_BOLD = 700,
WEIGHT_BLACK = 900
};
enum Style
{
STYLE_NORMAL = 0,
STYLE_ITALIC = 1,
STYLE_UNDERLINE = 2
};
static Ptr<GlFont> get(const std::string& family, int height = 12, Weight weight = WEIGHT_NORMAL, Style style = STYLE_NORMAL);
void draw(const char* str, size_t len) const;
inline const std::string& family() const { return family_; }
inline int height() const { return height_; }
inline Weight weight() const { return weight_; }
inline Style style() const { return style_; }
private:
GlFont(const std::string& family, int height, Weight weight, Style style);
std::string family_;
int height_;
Weight weight_;
Style style_;
unsigned int base_;
GlFont(const GlFont&);
GlFont& operator =(const GlFont&);
};
//! render functions
//! render texture rectangle in window
CV_EXPORTS void render(const GlTexture& tex,
Rect_<double> wndRect = Rect_<double>(0.0, 0.0, 1.0, 1.0),
Rect_<double> texRect = Rect_<double>(0.0, 0.0, 1.0, 1.0));
//! render mode
namespace RenderMode {
enum {
POINTS = 0x0000,
LINES = 0x0001,
LINE_LOOP = 0x0002,
LINE_STRIP = 0x0003,
TRIANGLES = 0x0004,
TRIANGLE_STRIP = 0x0005,
TRIANGLE_FAN = 0x0006,
QUADS = 0x0007,
QUAD_STRIP = 0x0008,
POLYGON = 0x0009
};
}
//! render OpenGL arrays
CV_EXPORTS void render(const GlArrays& arr, int mode = RenderMode::POINTS, Scalar color = Scalar::all(255));
void setVertexArray(InputArray vertex);
inline void resetVertexArray() { vertex_.release(); }
CV_EXPORTS void render(const std::string& str, const Ptr<GlFont>& font, Scalar color, Point2d pos);
void setColorArray(InputArray color, bool bgra = true);
inline void resetColorArray() { color_.release(); }
//! OpenGL camera
class CV_EXPORTS GlCamera
void setNormalArray(InputArray normal);
inline void resetNormalArray() { normal_.release(); }
void setTexCoordArray(InputArray texCoord);
inline void resetTexCoordArray() { texCoord_.release(); }
void bind() const;
void unbind() const;
inline int rows() const { return vertex_.rows(); }
inline int cols() const { return vertex_.cols(); }
inline Size size() const { return vertex_.size(); }
inline bool empty() const { return vertex_.empty(); }
private:
GlBuffer vertex_;
GlBuffer color_;
bool bgra_;
GlBuffer normal_;
GlBuffer texCoord_;
};
//! OpenGL Font
class CV_EXPORTS GlFont
{
public:
enum Weight
{
public:
GlCamera();
void lookAt(Point3d eye, Point3d center, Point3d up);
void setCameraPos(Point3d pos, double yaw, double pitch, double roll);
void setScale(Point3d scale);
void setProjectionMatrix(const Mat& projectionMatrix, bool transpose = true);
void setPerspectiveProjection(double fov, double aspect, double zNear, double zFar);
void setOrthoProjection(double left, double right, double bottom, double top, double zNear, double zFar);
void setupProjectionMatrix() const;
void setupModelViewMatrix() const;
private:
Point3d eye_;
Point3d center_;
Point3d up_;
Point3d pos_;
double yaw_;
double pitch_;
double roll_;
bool useLookAtParams_;
Point3d scale_;
Mat projectionMatrix_;
double fov_;
double aspect_;
double left_;
double right_;
double bottom_;
double top_;
double zNear_;
double zFar_;
bool perspectiveProjection_;
WEIGHT_LIGHT = 300,
WEIGHT_NORMAL = 400,
WEIGHT_SEMIBOLD = 600,
WEIGHT_BOLD = 700,
WEIGHT_BLACK = 900
};
namespace gpu
enum Style
{
//! set a CUDA device to use OpenGL interoperability
CV_EXPORTS void setGlDevice(int device = 0);
}
STYLE_NORMAL = 0,
STYLE_ITALIC = 1,
STYLE_UNDERLINE = 2
};
static Ptr<GlFont> get(const std::string& family, int height = 12, Weight weight = WEIGHT_NORMAL, Style style = STYLE_NORMAL);
void draw(const char* str, size_t len) const;
inline const std::string& family() const { return family_; }
inline int height() const { return height_; }
inline Weight weight() const { return weight_; }
inline Style style() const { return style_; }
private:
GlFont(const std::string& family, int height, Weight weight, Style style);
std::string family_;
int height_;
Weight weight_;
Style style_;
unsigned int base_;
GlFont(const GlFont&);
GlFont& operator =(const GlFont&);
};
//! render functions
//! render texture rectangle in window
CV_EXPORTS void render(const GlTexture& tex,
Rect_<double> wndRect = Rect_<double>(0.0, 0.0, 1.0, 1.0),
Rect_<double> texRect = Rect_<double>(0.0, 0.0, 1.0, 1.0));
//! render mode
namespace RenderMode {
enum {
POINTS = 0x0000,
LINES = 0x0001,
LINE_LOOP = 0x0002,
LINE_STRIP = 0x0003,
TRIANGLES = 0x0004,
TRIANGLE_STRIP = 0x0005,
TRIANGLE_FAN = 0x0006,
QUADS = 0x0007,
QUAD_STRIP = 0x0008,
POLYGON = 0x0009
};
}
//! render OpenGL arrays
CV_EXPORTS void render(const GlArrays& arr, int mode = RenderMode::POINTS, Scalar color = Scalar::all(255));
CV_EXPORTS void render(const std::string& str, const Ptr<GlFont>& font, Scalar color, Point2d pos);
//! OpenGL camera
class CV_EXPORTS GlCamera
{
public:
GlCamera();
void lookAt(Point3d eye, Point3d center, Point3d up);
void setCameraPos(Point3d pos, double yaw, double pitch, double roll);
void setScale(Point3d scale);
void setProjectionMatrix(const Mat& projectionMatrix, bool transpose = true);
void setPerspectiveProjection(double fov, double aspect, double zNear, double zFar);
void setOrthoProjection(double left, double right, double bottom, double top, double zNear, double zFar);
void setupProjectionMatrix() const;
void setupModelViewMatrix() const;
private:
Point3d eye_;
Point3d center_;
Point3d up_;
Point3d pos_;
double yaw_;
double pitch_;
double roll_;
bool useLookAtParams_;
Point3d scale_;
Mat projectionMatrix_;
double fov_;
double aspect_;
double left_;
double right_;
double bottom_;
double top_;
double zNear_;
double zFar_;
bool perspectiveProjection_;
};
inline void GlBuffer::create(Size _size, int _type, Usage _usage) { create(_size.height, _size.width, _type, _usage); }
inline void GlBuffer::create(int _rows, int _cols, int _type) { create(_rows, _cols, _type, usage()); }
inline void GlBuffer::create(Size _size, int _type) { create(_size.height, _size.width, _type, usage()); }
inline void GlTexture::create(Size _size, int _type) { create(_size.height, _size.width, _type); }
namespace gpu
{
//! set a CUDA device to use OpenGL interoperability
CV_EXPORTS void setGlDevice(int device = 0);
}
} // namespace cv
#endif // __cplusplus
@@ -2616,20 +2616,20 @@ template<typename _Tp> inline void Ptr<_Tp>::delete_obj()
template<typename _Tp> inline Ptr<_Tp>::~Ptr() { release(); }
template<typename _Tp> inline Ptr<_Tp>::Ptr(const Ptr<_Tp>& ptr)
template<typename _Tp> inline Ptr<_Tp>::Ptr(const Ptr<_Tp>& _ptr)
{
obj = ptr.obj;
refcount = ptr.refcount;
obj = _ptr.obj;
refcount = _ptr.refcount;
addref();
}
template<typename _Tp> inline Ptr<_Tp>& Ptr<_Tp>::operator = (const Ptr<_Tp>& ptr)
template<typename _Tp> inline Ptr<_Tp>& Ptr<_Tp>::operator = (const Ptr<_Tp>& _ptr)
{
int* _refcount = ptr.refcount;
int* _refcount = _ptr.refcount;
if( _refcount )
CV_XADD(_refcount, 1);
release();
obj = ptr.obj;
obj = _ptr.obj;
refcount = _refcount;
return *this;
}
@@ -3593,10 +3593,10 @@ template<typename _Tp> inline Seq<_Tp>::operator vector<_Tp>() const
template<typename _Tp> inline SeqIterator<_Tp>::SeqIterator()
{ memset(this, 0, sizeof(*this)); }
template<typename _Tp> inline SeqIterator<_Tp>::SeqIterator(const Seq<_Tp>& seq, bool seekEnd)
template<typename _Tp> inline SeqIterator<_Tp>::SeqIterator(const Seq<_Tp>& _seq, bool seekEnd)
{
cvStartReadSeq(seq.seq, this);
index = seekEnd ? seq.seq->total : 0;
cvStartReadSeq(_seq.seq, this);
index = seekEnd ? _seq.seq->total : 0;
}
template<typename _Tp> inline void SeqIterator<_Tp>::seek(size_t pos)
@@ -3842,17 +3842,17 @@ template<typename _Tp> inline Ptr<_Tp> Algorithm::create(const string& name)
return _create(name).ptr<_Tp>();
}
template<typename _Tp> inline typename ParamType<_Tp>::member_type Algorithm::get(const string& name) const
template<typename _Tp> inline typename ParamType<_Tp>::member_type Algorithm::get(const string& _name) const
{
typename ParamType<_Tp>::member_type value;
info()->get(this, name.c_str(), ParamType<_Tp>::type, &value);
info()->get(this, _name.c_str(), ParamType<_Tp>::type, &value);
return value;
}
template<typename _Tp> inline typename ParamType<_Tp>::member_type Algorithm::get(const char* name) const
template<typename _Tp> inline typename ParamType<_Tp>::member_type Algorithm::get(const char* _name) const
{
typename ParamType<_Tp>::member_type value;
info()->get(this, name, ParamType<_Tp>::type, &value);
info()->get(this, _name, ParamType<_Tp>::type, &value);
return value;
}
+154 -154
View File
@@ -7,7 +7,7 @@
// copy or use the software.
//
//
// License Agreement
// License Agreement
// For Open Source Computer Vision Library
//
// Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
@@ -46,7 +46,7 @@ namespace cv
{
using std::pair;
template<typename _KeyTp, typename _ValueTp> struct sorted_vector
{
sorted_vector() {}
@@ -54,7 +54,7 @@ template<typename _KeyTp, typename _ValueTp> struct sorted_vector
size_t size() const { return vec.size(); }
_ValueTp& operator [](size_t idx) { return vec[idx]; }
const _ValueTp& operator [](size_t idx) const { return vec[idx]; }
void add(const _KeyTp& k, const _ValueTp& val)
{
pair<_KeyTp, _ValueTp> p(k, val);
@@ -64,7 +64,7 @@ template<typename _KeyTp, typename _ValueTp> struct sorted_vector
std::swap(vec[i-1], vec[i]);
CV_Assert( i == 0 || vec[i].first != vec[i-1].first );
}
bool find(const _KeyTp& key, _ValueTp& value) const
{
size_t a = 0, b = vec.size();
@@ -76,7 +76,7 @@ template<typename _KeyTp, typename _ValueTp> struct sorted_vector
else
b = c;
}
if( a < vec.size() && vec[a].first == key )
{
value = vec[a].second;
@@ -84,26 +84,26 @@ template<typename _KeyTp, typename _ValueTp> struct sorted_vector
}
return false;
}
void get_keys(vector<_KeyTp>& keys) const
{
size_t i = 0, n = vec.size();
keys.resize(n);
for( i = 0; i < n; i++ )
keys[i] = vec[i].first;
}
vector<pair<_KeyTp, _ValueTp> > vec;
};
template<typename _ValueTp> inline const _ValueTp* findstr(const sorted_vector<string, _ValueTp>& vec,
const char* key)
{
if( !key )
return 0;
size_t a = 0, b = vec.vec.size();
while( b > a )
{
@@ -113,13 +113,13 @@ template<typename _ValueTp> inline const _ValueTp* findstr(const sorted_vector<s
else
b = c;
}
if( strcmp(vec.vec[a].first.c_str(), key) == 0 )
return &vec.vec[a].second;
return 0;
}
Param::Param()
{
type = 0;
@@ -129,7 +129,7 @@ Param::Param()
setter = 0;
}
Param::Param(int _type, bool _readonly, int _offset,
Algorithm::Getter _getter, Algorithm::Setter _setter,
const string& _help)
@@ -148,7 +148,7 @@ struct CV_EXPORTS AlgorithmInfoData
string _name;
};
static sorted_vector<string, Algorithm::Constructor>& alglist()
{
static sorted_vector<string, Algorithm::Constructor> alglist_var;
@@ -171,152 +171,152 @@ Ptr<Algorithm> Algorithm::_create(const string& name)
Algorithm::Algorithm()
{
}
Algorithm::~Algorithm()
{
}
string Algorithm::name() const
{
return info()->name();
}
void Algorithm::set(const string& name, int value)
void Algorithm::set(const string& parameter, int value)
{
info()->set(this, name.c_str(), ParamType<int>::type, &value);
info()->set(this, parameter.c_str(), ParamType<int>::type, &value);
}
void Algorithm::set(const string& name, double value)
void Algorithm::set(const string& parameter, double value)
{
info()->set(this, name.c_str(), ParamType<double>::type, &value);
info()->set(this, parameter.c_str(), ParamType<double>::type, &value);
}
void Algorithm::set(const string& name, bool value)
void Algorithm::set(const string& parameter, bool value)
{
info()->set(this, name.c_str(), ParamType<bool>::type, &value);
info()->set(this, parameter.c_str(), ParamType<bool>::type, &value);
}
void Algorithm::set(const string& name, const string& value)
void Algorithm::set(const string& parameter, const string& value)
{
info()->set(this, name.c_str(), ParamType<string>::type, &value);
info()->set(this, parameter.c_str(), ParamType<string>::type, &value);
}
void Algorithm::set(const string& name, const Mat& value)
void Algorithm::set(const string& parameter, const Mat& value)
{
info()->set(this, name.c_str(), ParamType<Mat>::type, &value);
info()->set(this, parameter.c_str(), ParamType<Mat>::type, &value);
}
void Algorithm::set(const string& name, const vector<Mat>& value)
void Algorithm::set(const string& parameter, const vector<Mat>& value)
{
info()->set(this, name.c_str(), ParamType<vector<Mat> >::type, &value);
}
void Algorithm::set(const string& name, const Ptr<Algorithm>& value)
{
info()->set(this, name.c_str(), ParamType<Algorithm>::type, &value);
info()->set(this, parameter.c_str(), ParamType<vector<Mat> >::type, &value);
}
void Algorithm::set(const char* name, int value)
void Algorithm::set(const string& parameter, const Ptr<Algorithm>& value)
{
info()->set(this, name, ParamType<int>::type, &value);
info()->set(this, parameter.c_str(), ParamType<Algorithm>::type, &value);
}
void Algorithm::set(const char* name, double value)
void Algorithm::set(const char* parameter, int value)
{
info()->set(this, name, ParamType<double>::type, &value);
info()->set(this, parameter, ParamType<int>::type, &value);
}
void Algorithm::set(const char* name, bool value)
void Algorithm::set(const char* parameter, double value)
{
info()->set(this, name, ParamType<bool>::type, &value);
info()->set(this, parameter, ParamType<double>::type, &value);
}
void Algorithm::set(const char* name, const string& value)
void Algorithm::set(const char* parameter, bool value)
{
info()->set(this, name, ParamType<string>::type, &value);
info()->set(this, parameter, ParamType<bool>::type, &value);
}
void Algorithm::set(const char* name, const Mat& value)
void Algorithm::set(const char* parameter, const string& value)
{
info()->set(this, name, ParamType<Mat>::type, &value);
info()->set(this, parameter, ParamType<string>::type, &value);
}
void Algorithm::set(const char* name, const vector<Mat>& value)
void Algorithm::set(const char* parameter, const Mat& value)
{
info()->set(this, name, ParamType<vector<Mat> >::type, &value);
}
void Algorithm::set(const char* name, const Ptr<Algorithm>& value)
{
info()->set(this, name, ParamType<Algorithm>::type, &value);
}
int Algorithm::getInt(const string& name) const
{
return get<int>(name);
}
double Algorithm::getDouble(const string& name) const
{
return get<double>(name);
info()->set(this, parameter, ParamType<Mat>::type, &value);
}
bool Algorithm::getBool(const string& name) const
void Algorithm::set(const char* parameter, const vector<Mat>& value)
{
return get<bool>(name);
info()->set(this, parameter, ParamType<vector<Mat> >::type, &value);
}
string Algorithm::getString(const string& name) const
void Algorithm::set(const char* parameter, const Ptr<Algorithm>& value)
{
return get<string>(name);
info()->set(this, parameter, ParamType<Algorithm>::type, &value);
}
Mat Algorithm::getMat(const string& name) const
int Algorithm::getInt(const string& parameter) const
{
return get<Mat>(name);
return get<int>(parameter);
}
vector<Mat> Algorithm::getMatVector(const string& name) const
double Algorithm::getDouble(const string& parameter) const
{
return get<vector<Mat> >(name);
return get<double>(parameter);
}
Ptr<Algorithm> Algorithm::getAlgorithm(const string& name) const
bool Algorithm::getBool(const string& parameter) const
{
return get<Algorithm>(name);
}
string Algorithm::paramHelp(const string& name) const
{
return info()->paramHelp(name.c_str());
}
int Algorithm::paramType(const string& name) const
{
return info()->paramType(name.c_str());
return get<bool>(parameter);
}
int Algorithm::paramType(const char* name) const
string Algorithm::getString(const string& parameter) const
{
return info()->paramType(name);
}
return get<string>(parameter);
}
Mat Algorithm::getMat(const string& parameter) const
{
return get<Mat>(parameter);
}
vector<Mat> Algorithm::getMatVector(const string& parameter) const
{
return get<vector<Mat> >(parameter);
}
Ptr<Algorithm> Algorithm::getAlgorithm(const string& parameter) const
{
return get<Algorithm>(parameter);
}
string Algorithm::paramHelp(const string& parameter) const
{
return info()->paramHelp(parameter.c_str());
}
int Algorithm::paramType(const string& parameter) const
{
return info()->paramType(parameter.c_str());
}
int Algorithm::paramType(const char* parameter) const
{
return info()->paramType(parameter);
}
void Algorithm::getParams(vector<string>& names) const
{
info()->getParams(names);
}
void Algorithm::write(FileStorage& fs) const
{
info()->write(this, fs);
}
void Algorithm::read(const FileNode& fn)
{
info()->read(this, fn);
}
}
AlgorithmInfo::AlgorithmInfo(const string& _name, Algorithm::Constructor create)
{
data = new AlgorithmInfoData;
@@ -327,8 +327,8 @@ AlgorithmInfo::AlgorithmInfo(const string& _name, Algorithm::Constructor create)
AlgorithmInfo::~AlgorithmInfo()
{
delete data;
}
}
void AlgorithmInfo::write(const Algorithm* algo, FileStorage& fs) const
{
size_t i = 0, nparams = data->params.vec.size();
@@ -364,7 +364,7 @@ void AlgorithmInfo::read(Algorithm* algo, const FileNode& fn) const
{
size_t i = 0, nparams = data->params.vec.size();
AlgorithmInfo* info = algo->info();
for( i = 0; i < nparams; i++ )
{
const Param& p = data->params.vec[i].second;
@@ -414,13 +414,13 @@ void AlgorithmInfo::read(Algorithm* algo, const FileNode& fn) const
else
CV_Error( CV_StsUnsupportedFormat, "unknown/unsupported parameter type");
}
}
}
string AlgorithmInfo::name() const
{
return data->_name;
}
union GetSetParam
{
int (Algorithm::*get_int)() const;
@@ -430,7 +430,7 @@ union GetSetParam
Mat (Algorithm::*get_mat)() const;
vector<Mat> (Algorithm::*get_mat_vector)() const;
Ptr<Algorithm> (Algorithm::*get_algo)() const;
void (Algorithm::*set_int)(int);
void (Algorithm::*set_bool)(bool);
void (Algorithm::*set_double)(double);
@@ -440,15 +440,15 @@ union GetSetParam
void (Algorithm::*set_algo)(const Ptr<Algorithm>&);
};
void AlgorithmInfo::set(Algorithm* algo, const char* name, int argType, const void* value, bool force) const
void AlgorithmInfo::set(Algorithm* algo, const char* parameter, int argType, const void* value, bool force) const
{
const Param* p = findstr(data->params, name);
const Param* p = findstr(data->params, parameter);
if( !p )
CV_Error_( CV_StsBadArg, ("No parameter '%s' is found", name ? name : "<NULL>") );
CV_Error_( CV_StsBadArg, ("No parameter '%s' is found", parameter ? parameter : "<NULL>") );
if( !force && p->readonly )
CV_Error_( CV_StsError, ("Parameter '%s' is readonly", name));
CV_Error_( CV_StsError, ("Parameter '%s' is readonly", parameter));
GetSetParam f;
f.set_int = p->setter;
@@ -531,23 +531,23 @@ void AlgorithmInfo::set(Algorithm* algo, const char* name, int argType, const vo
else
CV_Error(CV_StsBadArg, "Unknown/unsupported parameter type");
}
void AlgorithmInfo::get(const Algorithm* algo, const char* name, int argType, void* value) const
void AlgorithmInfo::get(const Algorithm* algo, const char* parameter, int argType, void* value) const
{
const Param* p = findstr(data->params, name);
const Param* p = findstr(data->params, parameter);
if( !p )
CV_Error_( CV_StsBadArg, ("No parameter '%s' is found", name ? name : "<NULL>") );
CV_Error_( CV_StsBadArg, ("No parameter '%s' is found", parameter ? parameter : "<NULL>") );
GetSetParam f;
f.get_int = p->getter;
if( argType == Param::INT || argType == Param::BOOLEAN || argType == Param::REAL )
{
if( p->type == Param::INT )
{
CV_Assert( argType == Param::INT || argType == Param::REAL );
int val = p->getter ? (algo->*f.get_int)() : *(int*)((uchar*)algo + p->offset);
if( argType == Param::INT )
*(int*)value = val;
else
@@ -557,7 +557,7 @@ void AlgorithmInfo::get(const Algorithm* algo, const char* name, int argType, vo
{
CV_Assert( argType == Param::INT || argType == Param::BOOLEAN || argType == Param::REAL );
bool val = p->getter ? (algo->*f.get_bool)() : *(bool*)((uchar*)algo + p->offset);
if( argType == Param::INT )
*(int*)value = (int)val;
else if( argType == Param::BOOLEAN )
@@ -569,35 +569,35 @@ void AlgorithmInfo::get(const Algorithm* algo, const char* name, int argType, vo
{
CV_Assert( argType == Param::REAL );
double val = p->getter ? (algo->*f.get_double)() : *(double*)((uchar*)algo + p->offset);
*(double*)value = val;
}
}
else if( argType == Param::STRING )
{
CV_Assert( p->type == Param::STRING );
*(string*)value = p->getter ? (algo->*f.get_string)() :
*(string*)((uchar*)algo + p->offset);
}
else if( argType == Param::MAT )
{
CV_Assert( p->type == Param::MAT );
*(Mat*)value = p->getter ? (algo->*f.get_mat)() :
*(Mat*)((uchar*)algo + p->offset);
}
else if( argType == Param::MAT_VECTOR )
{
CV_Assert( p->type == Param::MAT_VECTOR );
*(vector<Mat>*)value = p->getter ? (algo->*f.get_mat_vector)() :
*(vector<Mat>*)((uchar*)algo + p->offset);
}
else if( argType == Param::ALGORITHM )
{
CV_Assert( p->type == Param::ALGORITHM );
*(Ptr<Algorithm>*)value = p->getter ? (algo->*f.get_algo)() :
*(Ptr<Algorithm>*)((uchar*)algo + p->offset);
}
@@ -605,21 +605,21 @@ void AlgorithmInfo::get(const Algorithm* algo, const char* name, int argType, vo
CV_Error(CV_StsBadArg, "Unknown/unsupported parameter type");
}
int AlgorithmInfo::paramType(const char* name) const
int AlgorithmInfo::paramType(const char* parameter) const
{
const Param* p = findstr(data->params, name);
const Param* p = findstr(data->params, parameter);
if( !p )
CV_Error_( CV_StsBadArg, ("No parameter '%s' is found", name ? name : "<NULL>") );
CV_Error_( CV_StsBadArg, ("No parameter '%s' is found", parameter ? parameter : "<NULL>") );
return p->type;
}
string AlgorithmInfo::paramHelp(const char* name) const
string AlgorithmInfo::paramHelp(const char* parameter) const
{
const Param* p = findstr(data->params, name);
const Param* p = findstr(data->params, parameter);
if( !p )
CV_Error_( CV_StsBadArg, ("No parameter '%s' is found", name ? name : "<NULL>") );
CV_Error_( CV_StsBadArg, ("No parameter '%s' is found", parameter ? parameter : "<NULL>") );
return p->help;
}
@@ -628,10 +628,10 @@ void AlgorithmInfo::getParams(vector<string>& names) const
{
data->params.get_keys(names);
}
void AlgorithmInfo::addParam_(Algorithm& algo, const char* name, int argType,
void* value, bool readOnly,
void AlgorithmInfo::addParam_(Algorithm& algo, const char* parameter, int argType,
void* value, bool readOnly,
Algorithm::Getter getter, Algorithm::Setter setter,
const string& help)
{
@@ -639,82 +639,82 @@ void AlgorithmInfo::addParam_(Algorithm& algo, const char* name, int argType,
argType == Param::REAL || argType == Param::STRING ||
argType == Param::MAT || argType == Param::MAT_VECTOR ||
argType == Param::ALGORITHM );
data->params.add(string(name), Param(argType, readOnly,
data->params.add(string(parameter), Param(argType, readOnly,
(int)((size_t)value - (size_t)(void*)&algo),
getter, setter, help));
}
void AlgorithmInfo::addParam(Algorithm& algo, const char* name,
int& value, bool readOnly,
void AlgorithmInfo::addParam(Algorithm& algo, const char* parameter,
int& value, bool readOnly,
int (Algorithm::*getter)(),
void (Algorithm::*setter)(int),
const string& help)
{
addParam_(algo, name, ParamType<int>::type, &value, readOnly,
addParam_(algo, parameter, ParamType<int>::type, &value, readOnly,
(Algorithm::Getter)getter, (Algorithm::Setter)setter, help);
}
void AlgorithmInfo::addParam(Algorithm& algo, const char* name,
bool& value, bool readOnly,
void AlgorithmInfo::addParam(Algorithm& algo, const char* parameter,
bool& value, bool readOnly,
int (Algorithm::*getter)(),
void (Algorithm::*setter)(int),
const string& help)
{
addParam_(algo, name, ParamType<bool>::type, &value, readOnly,
addParam_(algo, parameter, ParamType<bool>::type, &value, readOnly,
(Algorithm::Getter)getter, (Algorithm::Setter)setter, help);
}
void AlgorithmInfo::addParam(Algorithm& algo, const char* name,
double& value, bool readOnly,
void AlgorithmInfo::addParam(Algorithm& algo, const char* parameter,
double& value, bool readOnly,
double (Algorithm::*getter)(),
void (Algorithm::*setter)(double),
const string& help)
{
addParam_(algo, name, ParamType<double>::type, &value, readOnly,
addParam_(algo, parameter, ParamType<double>::type, &value, readOnly,
(Algorithm::Getter)getter, (Algorithm::Setter)setter, help);
}
void AlgorithmInfo::addParam(Algorithm& algo, const char* name,
string& value, bool readOnly,
void AlgorithmInfo::addParam(Algorithm& algo, const char* parameter,
string& value, bool readOnly,
string (Algorithm::*getter)(),
void (Algorithm::*setter)(const string&),
const string& help)
{
addParam_(algo, name, ParamType<string>::type, &value, readOnly,
addParam_(algo, parameter, ParamType<string>::type, &value, readOnly,
(Algorithm::Getter)getter, (Algorithm::Setter)setter, help);
}
void AlgorithmInfo::addParam(Algorithm& algo, const char* name,
Mat& value, bool readOnly,
void AlgorithmInfo::addParam(Algorithm& algo, const char* parameter,
Mat& value, bool readOnly,
Mat (Algorithm::*getter)(),
void (Algorithm::*setter)(const Mat&),
const string& help)
{
addParam_(algo, name, ParamType<Mat>::type, &value, readOnly,
addParam_(algo, parameter, ParamType<Mat>::type, &value, readOnly,
(Algorithm::Getter)getter, (Algorithm::Setter)setter, help);
}
void AlgorithmInfo::addParam(Algorithm& algo, const char* name,
vector<Mat>& value, bool readOnly,
void AlgorithmInfo::addParam(Algorithm& algo, const char* parameter,
vector<Mat>& value, bool readOnly,
vector<Mat> (Algorithm::*getter)(),
void (Algorithm::*setter)(const vector<Mat>&),
const string& help)
{
addParam_(algo, name, ParamType<vector<Mat> >::type, &value, readOnly,
addParam_(algo, parameter, ParamType<vector<Mat> >::type, &value, readOnly,
(Algorithm::Getter)getter, (Algorithm::Setter)setter, help);
}
void AlgorithmInfo::addParam(Algorithm& algo, const char* name,
Ptr<Algorithm>& value, bool readOnly,
}
void AlgorithmInfo::addParam(Algorithm& algo, const char* parameter,
Ptr<Algorithm>& value, bool readOnly,
Ptr<Algorithm> (Algorithm::*getter)(),
void (Algorithm::*setter)(const Ptr<Algorithm>&),
const string& help)
{
addParam_(algo, name, ParamType<Algorithm>::type, &value, readOnly,
addParam_(algo, parameter, ParamType<Algorithm>::type, &value, readOnly,
(Algorithm::Getter)getter, (Algorithm::Setter)setter, help);
}
}
}
/* End of file. */
+123 -123
View File
@@ -88,7 +88,7 @@ split_( const T* src, T** dst, int len, int cn )
dst2[i] = src[j+2]; dst3[i] = src[j+3];
}
}
for( ; k < cn; k += 4 )
{
T *dst0 = dst[k], *dst1 = dst[k+1], *dst2 = dst[k+2], *dst3 = dst[k+3];
@@ -99,7 +99,7 @@ split_( const T* src, T** dst, int len, int cn )
}
}
}
template<typename T> static void
merge_( const T** src, T* dst, int len, int cn )
{
@@ -139,7 +139,7 @@ merge_( const T** src, T* dst, int len, int cn )
dst[j+2] = src2[i]; dst[j+3] = src3[i];
}
}
for( ; k < cn; k += 4 )
{
const T *src0 = src[k], *src1 = src[k+1], *src2 = src[k+2], *src3 = src[k+3];
@@ -165,7 +165,7 @@ static void split32s(const int* src, int** dst, int len, int cn )
{
split_(src, dst, len, cn);
}
static void split64s(const int64* src, int64** dst, int len, int cn )
{
split_(src, dst, len, cn);
@@ -189,7 +189,7 @@ static void merge32s(const int** src, int* dst, int len, int cn )
static void merge64s(const int64** src, int64* dst, int len, int cn )
{
merge_(src, dst, len, cn);
}
}
typedef void (*SplitFunc)(const uchar* src, uchar** dst, int len, int cn);
typedef void (*MergeFunc)(const uchar** src, uchar* dst, int len, int cn);
@@ -205,9 +205,9 @@ static MergeFunc mergeTab[] =
(MergeFunc)GET_OPTIMIZED(merge8u), (MergeFunc)GET_OPTIMIZED(merge8u), (MergeFunc)GET_OPTIMIZED(merge16u), (MergeFunc)GET_OPTIMIZED(merge16u),
(MergeFunc)GET_OPTIMIZED(merge32s), (MergeFunc)GET_OPTIMIZED(merge32s), (MergeFunc)GET_OPTIMIZED(merge64s), 0
};
}
void cv::split(const Mat& src, Mat* mv)
{
int k, depth = src.depth(), cn = src.channels();
@@ -219,30 +219,30 @@ void cv::split(const Mat& src, Mat* mv)
SplitFunc func = splitTab[depth];
CV_Assert( func != 0 );
int esz = (int)src.elemSize(), esz1 = (int)src.elemSize1();
int blocksize0 = (BLOCK_SIZE + esz-1)/esz;
AutoBuffer<uchar> _buf((cn+1)*(sizeof(Mat*) + sizeof(uchar*)) + 16);
const Mat** arrays = (const Mat**)(uchar*)_buf;
uchar** ptrs = (uchar**)alignPtr(arrays + cn + 1, 16);
arrays[0] = &src;
for( k = 0; k < cn; k++ )
{
mv[k].create(src.dims, src.size, depth);
arrays[k+1] = &mv[k];
}
NAryMatIterator it(arrays, ptrs, cn+1);
int total = (int)it.size, blocksize = cn <= 4 ? total : std::min(total, blocksize0);
for( size_t i = 0; i < it.nplanes; i++, ++it )
{
for( int j = 0; j < total; j += blocksize )
{
int bsz = std::min(total - j, blocksize);
func( ptrs[0], &ptrs[1], bsz, cn );
if( j + blocksize < total )
{
ptrs[0] += bsz*esz;
@@ -252,7 +252,7 @@ void cv::split(const Mat& src, Mat* mv)
}
}
}
void cv::split(InputArray _m, OutputArrayOfArrays _mv)
{
Mat m = _m.getMat();
@@ -266,38 +266,38 @@ void cv::split(InputArray _m, OutputArrayOfArrays _mv)
Mat* dst = &_mv.getMatRef(0);
split(m, dst);
}
void cv::merge(const Mat* mv, size_t n, OutputArray _dst)
{
CV_Assert( mv && n > 0 );
int depth = mv[0].depth();
bool allch1 = true;
int k, cn = 0;
size_t i;
for( i = 0; i < n; i++ )
{
CV_Assert(mv[i].size == mv[0].size && mv[i].depth() == depth);
allch1 = allch1 && mv[i].channels() == 1;
cn += mv[i].channels();
}
CV_Assert( 0 < cn && cn <= CV_CN_MAX );
_dst.create(mv[0].dims, mv[0].size, CV_MAKETYPE(depth, cn));
Mat dst = _dst.getMat();
if( n == 1 )
{
mv[0].copyTo(dst);
return;
}
if( !allch1 )
{
AutoBuffer<int> pairs(cn*2);
int j, ni=0;
for( i = 0, j = 0; i < n; i++, j += ni )
{
ni = mv[i].channels();
@@ -310,33 +310,33 @@ void cv::merge(const Mat* mv, size_t n, OutputArray _dst)
mixChannels( mv, n, &dst, 1, &pairs[0], cn );
return;
}
size_t esz = dst.elemSize(), esz1 = dst.elemSize1();
int blocksize0 = (int)((BLOCK_SIZE + esz-1)/esz);
AutoBuffer<uchar> _buf((cn+1)*(sizeof(Mat*) + sizeof(uchar*)) + 16);
const Mat** arrays = (const Mat**)(uchar*)_buf;
uchar** ptrs = (uchar**)alignPtr(arrays + cn + 1, 16);
arrays[0] = &dst;
for( k = 0; k < cn; k++ )
arrays[k+1] = &mv[k];
NAryMatIterator it(arrays, ptrs, cn+1);
int total = (int)it.size, blocksize = cn <= 4 ? total : std::min(total, blocksize0);
MergeFunc func = mergeTab[depth];
for( i = 0; i < it.nplanes; i++, ++it )
{
for( int j = 0; j < total; j += blocksize )
{
int bsz = std::min(total - j, blocksize);
func( (const uchar**)&ptrs[1], ptrs[0], bsz, cn );
if( j + blocksize < total )
{
ptrs[0] += bsz*esz;
for( int k = 0; k < cn; k++ )
ptrs[k+1] += bsz*esz1;
for( int t = 0; t < cn; t++ )
ptrs[t+1] += bsz*esz1;
}
}
}
@@ -347,7 +347,7 @@ void cv::merge(InputArrayOfArrays _mv, OutputArray _dst)
vector<Mat> mv;
_mv.getMatVector(mv);
merge(!mv.empty() ? &mv[0] : 0, mv.size(), _dst);
}
}
/****************************************************************************************\
* Generalized split/merge: mixing channels *
@@ -387,7 +387,7 @@ mixChannels_( const T** src, const int* sdelta,
}
}
static void mixChannels8u( const uchar** src, const int* sdelta,
uchar** dst, const int* ddelta,
int len, int npairs )
@@ -408,14 +408,14 @@ static void mixChannels32s( const int** src, const int* sdelta,
{
mixChannels_(src, sdelta, dst, ddelta, len, npairs);
}
static void mixChannels64s( const int64** src, const int* sdelta,
int64** dst, const int* ddelta,
int len, int npairs )
{
mixChannels_(src, sdelta, dst, ddelta, len, npairs);
}
typedef void (*MixChannelsFunc)( const uchar** src, const int* sdelta,
uchar** dst, const int* ddelta, int len, int npairs );
@@ -423,17 +423,17 @@ static MixChannelsFunc mixchTab[] =
{
(MixChannelsFunc)mixChannels8u, (MixChannelsFunc)mixChannels8u, (MixChannelsFunc)mixChannels16u,
(MixChannelsFunc)mixChannels16u, (MixChannelsFunc)mixChannels32s, (MixChannelsFunc)mixChannels32s,
(MixChannelsFunc)mixChannels64s, 0
(MixChannelsFunc)mixChannels64s, 0
};
}
void cv::mixChannels( const Mat* src, size_t nsrcs, Mat* dst, size_t ndsts, const int* fromTo, size_t npairs )
{
if( npairs == 0 )
return;
CV_Assert( src && nsrcs > 0 && dst && ndsts > 0 && fromTo && npairs > 0 );
size_t i, j, k, esz1 = dst[0].elemSize1();
int depth = dst[0].depth();
@@ -444,13 +444,13 @@ void cv::mixChannels( const Mat* src, size_t nsrcs, Mat* dst, size_t ndsts, cons
uchar** dsts = (uchar**)(srcs + npairs);
int* tab = (int*)(dsts + npairs);
int *sdelta = (int*)(tab + npairs*4), *ddelta = sdelta + npairs;
for( i = 0; i < nsrcs; i++ )
arrays[i] = &src[i];
for( i = 0; i < ndsts; i++ )
arrays[i + nsrcs] = &dst[i];
ptrs[nsrcs + ndsts] = 0;
for( i = 0; i < npairs; i++ )
{
int i0 = fromTo[i*2], i1 = fromTo[i*2+1];
@@ -468,7 +468,7 @@ void cv::mixChannels( const Mat* src, size_t nsrcs, Mat* dst, size_t ndsts, cons
tab[i*4] = (int)(nsrcs + ndsts); tab[i*4+1] = 0;
sdelta[i] = 0;
}
for( j = 0; j < ndsts; i1 -= dst[j].channels(), j++ )
if( i1 < dst[j].channels() )
break;
@@ -480,7 +480,7 @@ void cv::mixChannels( const Mat* src, size_t nsrcs, Mat* dst, size_t ndsts, cons
NAryMatIterator it(arrays, ptrs, (int)(nsrcs + ndsts));
int total = (int)it.size, blocksize = std::min(total, (int)((BLOCK_SIZE + esz1-1)/esz1));
MixChannelsFunc func = mixchTab[depth];
for( i = 0; i < it.nplanes; i++, ++it )
{
for( k = 0; k < npairs; k++ )
@@ -488,13 +488,13 @@ void cv::mixChannels( const Mat* src, size_t nsrcs, Mat* dst, size_t ndsts, cons
srcs[k] = ptrs[tab[k*4]] + tab[k*4+1];
dsts[k] = ptrs[tab[k*4+2]] + tab[k*4+3];
}
for( int j = 0; j < total; j += blocksize )
for( int t = 0; t < total; t += blocksize )
{
int bsz = std::min(total - j, blocksize);
int bsz = std::min(total - t, blocksize);
func( srcs, sdelta, dsts, ddelta, bsz, (int)npairs );
if( j + blocksize < total )
if( t + blocksize < total )
for( k = 0; k < npairs; k++ )
{
srcs[k] += blocksize*sdelta[k]*esz1;
@@ -524,7 +524,7 @@ void cv::mixChannels(InputArrayOfArrays src, InputArrayOfArrays dst,
int i;
int nsrc = src_is_mat ? 1 : (int)src.total();
int ndst = dst_is_mat ? 1 : (int)dst.total();
CV_Assert(fromTo.size()%2 == 0 && nsrc > 0 && ndst > 0);
cv::AutoBuffer<Mat> _buf(nsrc + ndst);
Mat* buf = _buf;
@@ -568,7 +568,7 @@ cvtScaleAbs_( const T* src, size_t sstep,
{
sstep /= sizeof(src[0]);
dstep /= sizeof(dst[0]);
for( ; size.height--; src += sstep, dst += dstep )
{
int x = 0;
@@ -583,11 +583,11 @@ cvtScaleAbs_( const T* src, size_t sstep,
t1 = saturate_cast<DT>(std::abs(src[x+3]*scale + shift));
dst[x+2] = t0; dst[x+3] = t1;
}
#endif
#endif
for( ; x < size.width; x++ )
dst[x] = saturate_cast<DT>(std::abs(src[x]*scale + shift));
}
}
}
template<typename T, typename DT, typename WT> static void
@@ -597,7 +597,7 @@ cvtScale_( const T* src, size_t sstep,
{
sstep /= sizeof(src[0]);
dstep /= sizeof(dst[0]);
for( ; size.height--; src += sstep, dst += dstep )
{
int x = 0;
@@ -623,38 +623,38 @@ cvtScale_( const T* src, size_t sstep,
template<> void
cvtScale_<short, short, float>( const short* src, size_t sstep,
short* dst, size_t dstep, Size size,
float scale, float shift )
float scale, float shift )
{
sstep /= sizeof(src[0]);
dstep /= sizeof(dst[0]);
for( ; size.height--; src += sstep, dst += dstep )
for( ; size.height--; src += sstep, dst += dstep )
{
int x = 0;
#if CV_SSE2
if(USE_SSE2)
#if CV_SSE2
if(USE_SSE2)
{
__m128 scale128 = _mm_set1_ps (scale);
__m128 shift128 = _mm_set1_ps (shift);
for(; x <= size.width - 8; x += 8 )
{
__m128i r0 = _mm_loadl_epi64((const __m128i*)(src + x));
for(; x <= size.width - 8; x += 8 )
{
__m128i r0 = _mm_loadl_epi64((const __m128i*)(src + x));
__m128i r1 = _mm_loadl_epi64((const __m128i*)(src + x + 4));
__m128 rf0 =_mm_cvtepi32_ps(_mm_srai_epi32(_mm_unpacklo_epi16(r0, r0), 16));
__m128 rf0 =_mm_cvtepi32_ps(_mm_srai_epi32(_mm_unpacklo_epi16(r0, r0), 16));
__m128 rf1 =_mm_cvtepi32_ps(_mm_srai_epi32(_mm_unpacklo_epi16(r1, r1), 16));
rf0 = _mm_add_ps(_mm_mul_ps(rf0, scale128), shift128);
rf1 = _mm_add_ps(_mm_mul_ps(rf1, scale128), shift128);
r0 = _mm_cvtps_epi32(rf0);
r1 = _mm_cvtps_epi32(rf1);
r0 = _mm_packs_epi32(r0, r1);
_mm_storeu_si128((__m128i*)(dst + x), r0);
}
}
r0 = _mm_cvtps_epi32(rf0);
r1 = _mm_cvtps_epi32(rf1);
r0 = _mm_packs_epi32(r0, r1);
_mm_storeu_si128((__m128i*)(dst + x), r0);
}
}
#endif
for(; x < size.width; x++ )
dst[x] = saturate_cast<short>(src[x]*scale + shift);
}
}
}
@@ -664,21 +664,21 @@ cvt_( const T* src, size_t sstep,
{
sstep /= sizeof(src[0]);
dstep /= sizeof(dst[0]);
for( ; size.height--; src += sstep, dst += dstep )
{
int x = 0;
#if CV_ENABLE_UNROLLED
for( ; x <= size.width - 4; x += 4 )
{
DT t0, t1;
t0 = saturate_cast<DT>(src[x]);
t1 = saturate_cast<DT>(src[x+1]);
dst[x] = t0; dst[x+1] = t1;
t0 = saturate_cast<DT>(src[x+2]);
t1 = saturate_cast<DT>(src[x+3]);
dst[x+2] = t0; dst[x+3] = t1;
}
#if CV_ENABLE_UNROLLED
for( ; x <= size.width - 4; x += 4 )
{
DT t0, t1;
t0 = saturate_cast<DT>(src[x]);
t1 = saturate_cast<DT>(src[x+1]);
dst[x] = t0; dst[x+1] = t1;
t0 = saturate_cast<DT>(src[x+2]);
t1 = saturate_cast<DT>(src[x+3]);
dst[x+2] = t0; dst[x+3] = t1;
}
#endif
for( ; x < size.width; x++ )
dst[x] = saturate_cast<DT>(src[x]);
@@ -692,24 +692,24 @@ cvt_<float, short>( const float* src, size_t sstep,
{
sstep /= sizeof(src[0]);
dstep /= sizeof(dst[0]);
for( ; size.height--; src += sstep, dst += dstep )
{
int x = 0;
#if CV_SSE2
if(USE_SSE2){
for( ; x <= size.width - 8; x += 8 )
{
__m128 src128 = _mm_loadu_ps (src + x);
__m128i src_int128 = _mm_cvtps_epi32 (src128);
src128 = _mm_loadu_ps (src + x + 4);
__m128i src1_int128 = _mm_cvtps_epi32 (src128);
src1_int128 = _mm_packs_epi32(src_int128, src1_int128);
_mm_storeu_si128((__m128i*)(dst + x),src1_int128);
}
}
#if CV_SSE2
if(USE_SSE2){
for( ; x <= size.width - 8; x += 8 )
{
__m128 src128 = _mm_loadu_ps (src + x);
__m128i src_int128 = _mm_cvtps_epi32 (src128);
src128 = _mm_loadu_ps (src + x + 4);
__m128i src1_int128 = _mm_cvtps_epi32 (src128);
src1_int128 = _mm_packs_epi32(src_int128, src1_int128);
_mm_storeu_si128((__m128i*)(dst + x),src1_int128);
}
}
#endif
for( ; x < size.width; x++ )
dst[x] = saturate_cast<short>(src[x]);
@@ -723,11 +723,11 @@ cpy_( const T* src, size_t sstep, T* dst, size_t dstep, Size size )
{
sstep /= sizeof(src[0]);
dstep /= sizeof(dst[0]);
for( ; size.height--; src += sstep, dst += dstep )
memcpy(dst, src, size.width*sizeof(src[0]));
}
#define DEF_CVT_SCALE_ABS_FUNC(suffix, tfunc, stype, dtype, wtype) \
static void cvtScaleAbs##suffix( const stype* src, size_t sstep, const uchar*, size_t, \
dtype* dst, size_t dstep, Size size, double* scale) \
@@ -741,8 +741,8 @@ dtype* dst, size_t dstep, Size size, double* scale) \
{ \
cvtScale_(src, sstep, dst, dstep, size, (wtype)scale[0], (wtype)scale[1]); \
}
#define DEF_CVT_FUNC(suffix, stype, dtype) \
static void cvt##suffix( const stype* src, size_t sstep, const uchar*, size_t, \
dtype* dst, size_t dstep, Size size, double*) \
@@ -756,15 +756,15 @@ stype* dst, size_t dstep, Size size, double*) \
{ \
cpy_(src, sstep, dst, dstep, size); \
}
DEF_CVT_SCALE_ABS_FUNC(8u, cvtScaleAbs_, uchar, uchar, float);
DEF_CVT_SCALE_ABS_FUNC(8s8u, cvtScaleAbs_, schar, uchar, float);
DEF_CVT_SCALE_ABS_FUNC(16u8u, cvtScaleAbs_, ushort, uchar, float);
DEF_CVT_SCALE_ABS_FUNC(16s8u, cvtScaleAbs_, short, uchar, float);
DEF_CVT_SCALE_ABS_FUNC(32s8u, cvtScaleAbs_, int, uchar, float);
DEF_CVT_SCALE_ABS_FUNC(32f8u, cvtScaleAbs_, float, uchar, float);
DEF_CVT_SCALE_ABS_FUNC(64f8u, cvtScaleAbs_, double, uchar, float);
DEF_CVT_SCALE_ABS_FUNC(64f8u, cvtScaleAbs_, double, uchar, float);
DEF_CVT_SCALE_FUNC(8u, uchar, uchar, float);
DEF_CVT_SCALE_FUNC(8s8u, schar, uchar, float);
@@ -772,7 +772,7 @@ DEF_CVT_SCALE_FUNC(16u8u, ushort, uchar, float);
DEF_CVT_SCALE_FUNC(16s8u, short, uchar, float);
DEF_CVT_SCALE_FUNC(32s8u, int, uchar, float);
DEF_CVT_SCALE_FUNC(32f8u, float, uchar, float);
DEF_CVT_SCALE_FUNC(64f8u, double, uchar, float);
DEF_CVT_SCALE_FUNC(64f8u, double, uchar, float);
DEF_CVT_SCALE_FUNC(8u8s, uchar, schar, float);
DEF_CVT_SCALE_FUNC(8s, schar, schar, float);
@@ -780,7 +780,7 @@ DEF_CVT_SCALE_FUNC(16u8s, ushort, schar, float);
DEF_CVT_SCALE_FUNC(16s8s, short, schar, float);
DEF_CVT_SCALE_FUNC(32s8s, int, schar, float);
DEF_CVT_SCALE_FUNC(32f8s, float, schar, float);
DEF_CVT_SCALE_FUNC(64f8s, double, schar, float);
DEF_CVT_SCALE_FUNC(64f8s, double, schar, float);
DEF_CVT_SCALE_FUNC(8u16u, uchar, ushort, float);
DEF_CVT_SCALE_FUNC(8s16u, schar, ushort, float);
@@ -788,7 +788,7 @@ DEF_CVT_SCALE_FUNC(16u, ushort, ushort, float);
DEF_CVT_SCALE_FUNC(16s16u, short, ushort, float);
DEF_CVT_SCALE_FUNC(32s16u, int, ushort, float);
DEF_CVT_SCALE_FUNC(32f16u, float, ushort, float);
DEF_CVT_SCALE_FUNC(64f16u, double, ushort, float);
DEF_CVT_SCALE_FUNC(64f16u, double, ushort, float);
DEF_CVT_SCALE_FUNC(8u16s, uchar, short, float);
DEF_CVT_SCALE_FUNC(8s16s, schar, short, float);
@@ -797,7 +797,7 @@ DEF_CVT_SCALE_FUNC(16s, short, short, float);
DEF_CVT_SCALE_FUNC(32s16s, int, short, float);
DEF_CVT_SCALE_FUNC(32f16s, float, short, float);
DEF_CVT_SCALE_FUNC(64f16s, double, short, float);
DEF_CVT_SCALE_FUNC(8u32s, uchar, int, float);
DEF_CVT_SCALE_FUNC(8s32s, schar, int, float);
DEF_CVT_SCALE_FUNC(16u32s, ushort, int, float);
@@ -874,7 +874,7 @@ DEF_CVT_FUNC(16s64f, short, double);
DEF_CVT_FUNC(32s64f, int, double);
DEF_CVT_FUNC(32f64f, float, double);
DEF_CPY_FUNC(64s, int64);
static BinaryFunc cvtScaleAbsTab[] =
{
(BinaryFunc)cvtScaleAbs8u, (BinaryFunc)cvtScaleAbs8s8u, (BinaryFunc)cvtScaleAbs16u8u,
@@ -965,7 +965,7 @@ static BinaryFunc cvtTab[][8] =
0, 0, 0, 0, 0, 0, 0, 0
}
};
BinaryFunc getConvertFunc(int sdepth, int ddepth)
{
return cvtTab[CV_MAT_DEPTH(ddepth)][CV_MAT_DEPTH(sdepth)];
@@ -974,10 +974,10 @@ BinaryFunc getConvertFunc(int sdepth, int ddepth)
BinaryFunc getConvertScaleFunc(int sdepth, int ddepth)
{
return cvtScaleTab[CV_MAT_DEPTH(ddepth)][CV_MAT_DEPTH(sdepth)];
}
}
}
void cv::convertScaleAbs( InputArray _src, OutputArray _dst, double alpha, double beta )
{
Mat src = _src.getMat();
@@ -987,7 +987,7 @@ void cv::convertScaleAbs( InputArray _src, OutputArray _dst, double alpha, doubl
Mat dst = _dst.getMat();
BinaryFunc func = cvtScaleAbsTab[src.depth()];
CV_Assert( func != 0 );
if( src.dims <= 2 )
{
Size sz = getContinuousSize(src, dst, cn);
@@ -999,7 +999,7 @@ void cv::convertScaleAbs( InputArray _src, OutputArray _dst, double alpha, doubl
uchar* ptrs[2];
NAryMatIterator it(arrays, ptrs);
Size sz((int)it.size*cn, 1);
for( size_t i = 0; i < it.nplanes; i++, ++it )
func( ptrs[0], 0, 0, 0, ptrs[1], 0, sz, scale );
}
@@ -1022,12 +1022,12 @@ void cv::Mat::convertTo(OutputArray _dst, int _type, double alpha, double beta)
}
Mat src = *this;
BinaryFunc func = noScale ? getConvertFunc(sdepth, ddepth) : getConvertScaleFunc(sdepth, ddepth);
double scale[] = {alpha, beta};
int cn = channels();
CV_Assert( func != 0 );
if( dims <= 2 )
{
_dst.create( size(), _type );
@@ -1043,7 +1043,7 @@ void cv::Mat::convertTo(OutputArray _dst, int _type, double alpha, double beta)
uchar* ptrs[2];
NAryMatIterator it(arrays, ptrs);
Size sz((int)(it.size*cn), 1);
for( size_t i = 0; i < it.nplanes; i++, ++it )
func(ptrs[0], 0, 0, 0, ptrs[1], 0, sz, scale);
}
@@ -1105,10 +1105,10 @@ static void LUT8u_32f( const uchar* src, const float* lut, float* dst, int len,
static void LUT8u_64f( const uchar* src, const double* lut, double* dst, int len, int cn, int lutcn )
{
LUT8u_( src, lut, dst, len, cn, lutcn );
}
}
typedef void (*LUTFunc)( const uchar* src, const uchar* lut, uchar* dst, int len, int cn, int lutcn );
static LUTFunc lutTab[] =
{
(LUTFunc)LUT8u_8u, (LUTFunc)LUT8u_8s, (LUTFunc)LUT8u_16u, (LUTFunc)LUT8u_16s,
@@ -1116,7 +1116,7 @@ static LUTFunc lutTab[] =
};
}
void cv::LUT( InputArray _src, InputArray _lut, OutputArray _dst, int interpolation )
{
Mat src = _src.getMat(), lut = _lut.getMat();
@@ -1132,12 +1132,12 @@ void cv::LUT( InputArray _src, InputArray _lut, OutputArray _dst, int interpolat
LUTFunc func = lutTab[lut.depth()];
CV_Assert( func != 0 );
const Mat* arrays[] = {&src, &dst, 0};
uchar* ptrs[2];
NAryMatIterator it(arrays, ptrs);
int len = (int)it.size;
for( size_t i = 0; i < it.nplanes; i++, ++it )
func(ptrs[0], lut.data, ptrs[1], len, cn, lutcn);
}
@@ -1147,7 +1147,7 @@ void cv::normalize( InputArray _src, OutputArray _dst, double a, double b,
int norm_type, int rtype, InputArray _mask )
{
Mat src = _src.getMat(), mask = _mask.getMat();
double scale = 1, shift = 0;
if( norm_type == CV_MINMAX )
{
@@ -1165,13 +1165,13 @@ void cv::normalize( InputArray _src, OutputArray _dst, double a, double b,
}
else
CV_Error( CV_StsBadArg, "Unknown/unsupported norm type" );
if( rtype < 0 )
rtype = _dst.fixedType() ? _dst.depth() : src.depth();
_dst.create(src.dims, src.size, CV_MAKETYPE(rtype, src.channels()));
Mat dst = _dst.getMat();
if( !mask.data )
src.convertTo( dst, rtype, scale, shift );
else
@@ -1282,7 +1282,7 @@ cvConvertScale( const void* srcarr, void* dstarr,
double scale, double shift )
{
cv::Mat src = cv::cvarrToMat(srcarr), dst = cv::cvarrToMat(dstarr);
CV_Assert( src.size == dst.size && src.channels() == dst.channels() );
src.convertTo(dst, dst.type(), scale, shift);
}
+54 -54
View File
@@ -59,7 +59,7 @@ copyMask_(const uchar* _src, size_t sstep, const uchar* mask, size_t mstep, ucha
const T* src = (const T*)_src;
T* dst = (T*)_dst;
int x = 0;
#if CV_ENABLE_UNROLLED
#if CV_ENABLE_UNROLLED
for( ; x <= size.width - 4; x += 4 )
{
if( mask[x] )
@@ -96,16 +96,16 @@ copyMaskGeneric(const uchar* _src, size_t sstep, const uchar* mask, size_t mstep
}
}
}
#define DEF_COPY_MASK(suffix, type) \
static void copyMask##suffix(const uchar* src, size_t sstep, const uchar* mask, size_t mstep, \
uchar* dst, size_t dstep, Size size, void*) \
{ \
copyMask_<type>(src, sstep, mask, mstep, dst, dstep, size); \
}
DEF_COPY_MASK(8u, uchar);
DEF_COPY_MASK(16u, ushort);
DEF_COPY_MASK(8uC3, Vec3b);
@@ -116,7 +116,7 @@ DEF_COPY_MASK(32sC3, Vec3i);
DEF_COPY_MASK(32sC4, Vec4i);
DEF_COPY_MASK(32sC6, Vec6i);
DEF_COPY_MASK(32sC8, Vec8i);
BinaryFunc copyMaskTab[] =
{
0,
@@ -137,7 +137,7 @@ BinaryFunc copyMaskTab[] =
0, 0, 0, 0, 0, 0, 0,
copyMask32sC8
};
BinaryFunc getCopyMaskFunc(size_t esz)
{
return esz <= 32 && copyMaskTab[esz] ? copyMaskTab[esz] : copyMaskGeneric;
@@ -152,51 +152,51 @@ void Mat::copyTo( OutputArray _dst ) const
convertTo( _dst, dtype );
return;
}
if( empty() )
{
_dst.release();
return;
}
if( dims <= 2 )
{
_dst.create( rows, cols, type() );
Mat dst = _dst.getMat();
if( data == dst.data )
return;
if( rows > 0 && cols > 0 )
{
const uchar* sptr = data;
uchar* dptr = dst.data;
// to handle the copying 1xn matrix => nx1 std vector.
Size sz = size() == dst.size() ?
getContinuousSize(*this, dst) :
getContinuousSize(*this);
size_t len = sz.width*elemSize();
for( ; sz.height--; sptr += step, dptr += dst.step )
memcpy( dptr, sptr, len );
}
return;
}
_dst.create( dims, size, type() );
Mat dst = _dst.getMat();
if( data == dst.data )
return;
if( total() != 0 )
{
const Mat* arrays[] = { this, &dst };
uchar* ptrs[2];
NAryMatIterator it(arrays, ptrs, 2);
size_t size = it.size*elemSize();
size_t sz = it.size*elemSize();
for( size_t i = 0; i < it.nplanes; i++, ++it )
memcpy(ptrs[1], ptrs[0], size);
memcpy(ptrs[1], ptrs[0], sz);
}
}
@@ -208,33 +208,33 @@ void Mat::copyTo( OutputArray _dst, InputArray _mask ) const
copyTo(_dst);
return;
}
int cn = channels(), mcn = mask.channels();
CV_Assert( mask.depth() == CV_8U && (mcn == 1 || mcn == cn) );
bool colorMask = mcn > 1;
size_t esz = colorMask ? elemSize1() : elemSize();
BinaryFunc copymask = getCopyMaskFunc(esz);
uchar* data0 = _dst.getMat().data;
_dst.create( dims, size, type() );
Mat dst = _dst.getMat();
if( dst.data != data0 ) // do not leave dst uninitialized
dst = Scalar(0);
if( dims <= 2 )
{
Size sz = getContinuousSize(*this, dst, mask, mcn);
copymask(data, step, mask.data, mask.step, dst.data, dst.step, sz, &esz);
return;
}
const Mat* arrays[] = { this, &dst, &mask, 0 };
uchar* ptrs[3];
NAryMatIterator it(arrays, ptrs);
Size sz((int)(it.size*mcn), 1);
for( size_t i = 0; i < it.nplanes; i++, ++it )
copymask(ptrs[0], 0, ptrs[2], 0, ptrs[1], 0, sz, &esz);
}
@@ -242,14 +242,14 @@ void Mat::copyTo( OutputArray _dst, InputArray _mask ) const
Mat& Mat::operator = (const Scalar& s)
{
const Mat* arrays[] = { this };
uchar* ptr;
NAryMatIterator it(arrays, &ptr, 1);
size_t size = it.size*elemSize();
uchar* dptr;
NAryMatIterator it(arrays, &dptr, 1);
size_t elsize = it.size*elemSize();
if( s[0] == 0 && s[1] == 0 && s[2] == 0 && s[3] == 0 )
{
for( size_t i = 0; i < it.nplanes; i++, ++it )
memset( ptr, 0, size );
memset( dptr, 0, elsize );
}
else
{
@@ -258,50 +258,50 @@ Mat& Mat::operator = (const Scalar& s)
double scalar[12];
scalarToRawData(s, scalar, type(), 12);
size_t blockSize = 12*elemSize1();
for( size_t j = 0; j < size; j += blockSize )
for( size_t j = 0; j < elsize; j += blockSize )
{
size_t sz = MIN(blockSize, size - j);
memcpy( ptr + j, scalar, sz );
size_t sz = MIN(blockSize, elsize - j);
memcpy( dptr + j, scalar, sz );
}
}
for( size_t i = 1; i < it.nplanes; i++ )
{
++it;
memcpy( ptr, data, size );
memcpy( dptr, data, elsize );
}
}
return *this;
}
Mat& Mat::setTo(InputArray _value, InputArray _mask)
{
if( !data )
return *this;
Mat value = _value.getMat(), mask = _mask.getMat();
CV_Assert( checkScalar(value, type(), _value.kind(), _InputArray::MAT ));
CV_Assert( mask.empty() || mask.type() == CV_8U );
size_t esz = elemSize();
BinaryFunc copymask = getCopyMaskFunc(esz);
const Mat* arrays[] = { this, !mask.empty() ? &mask : 0, 0 };
uchar* ptrs[2]={0,0};
NAryMatIterator it(arrays, ptrs);
int total = (int)it.size, blockSize0 = std::min(total, (int)((BLOCK_SIZE + esz-1)/esz));
int totalsz = (int)it.size, blockSize0 = std::min(totalsz, (int)((BLOCK_SIZE + esz-1)/esz));
AutoBuffer<uchar> _scbuf(blockSize0*esz + 32);
uchar* scbuf = alignPtr((uchar*)_scbuf, (int)sizeof(double));
convertAndUnrollScalar( value, type(), scbuf, blockSize0 );
for( size_t i = 0; i < it.nplanes; i++, ++it )
{
for( int j = 0; j < total; j += blockSize0 )
for( int j = 0; j < totalsz; j += blockSize0 )
{
Size sz(std::min(blockSize0, total - j), 1);
Size sz(std::min(blockSize0, totalsz - j), 1);
size_t blockSize = sz.width*esz;
if( ptrs[1] )
{
@@ -323,7 +323,7 @@ flipHoriz( const uchar* src, size_t sstep, uchar* dst, size_t dstep, Size size,
int i, j, limit = (int)(((size.width + 1)/2)*esz);
AutoBuffer<int> _tab(size.width*esz);
int* tab = _tab;
for( i = 0; i < size.width; i++ )
for( size_t k = 0; k < esz; k++ )
tab[i*esz + k] = (int)((size.width - i - 1)*esz + k);
@@ -403,7 +403,7 @@ flipVert( const uchar* src0, size_t sstep, uchar* dst0, size_t dstep, Size size,
void flip( InputArray _src, OutputArray _dst, int flip_mode )
{
Mat src = _src.getMat();
CV_Assert( src.dims <= 2 );
_dst.create( src.size(), src.type() );
Mat dst = _dst.getMat();
@@ -413,7 +413,7 @@ void flip( InputArray _src, OutputArray _dst, int flip_mode )
flipVert( src.data, src.step, dst.data, dst.step, src.size(), esz );
else
flipHoriz( src.data, src.step, dst.data, dst.step, src.size(), esz );
if( flip_mode < 0 )
flipHoriz( dst.data, dst.step, dst.data, dst.step, dst.size(), esz );
}
@@ -423,7 +423,7 @@ void repeat(InputArray _src, int ny, int nx, OutputArray _dst)
{
Mat src = _src.getMat();
CV_Assert( src.dims <= 2 );
_dst.create(src.rows*ny, src.cols*nx, src.type());
Mat dst = _dst.getMat();
Size ssize = src.size(), dsize = dst.size();
@@ -493,25 +493,25 @@ cvCopy( const void* srcarr, void* dstarr, const void* maskarr )
}
cv::Mat src = cv::cvarrToMat(srcarr, false, true, 1), dst = cv::cvarrToMat(dstarr, false, true, 1);
CV_Assert( src.depth() == dst.depth() && src.size == dst.size );
int coi1 = 0, coi2 = 0;
if( CV_IS_IMAGE(srcarr) )
coi1 = cvGetImageCOI((const IplImage*)srcarr);
if( CV_IS_IMAGE(dstarr) )
coi2 = cvGetImageCOI((const IplImage*)dstarr);
if( coi1 || coi2 )
{
CV_Assert( (coi1 != 0 || src.channels() == 1) &&
(coi2 != 0 || dst.channels() == 1) );
int pair[] = { std::max(coi1-1, 0), std::max(coi2-1, 0) };
cv::mixChannels( &src, 1, &dst, 1, pair, 1 );
return;
}
else
CV_Assert( src.channels() == dst.channels() );
if( !maskarr )
src.copyTo(dst);
else
@@ -548,12 +548,12 @@ cvFlip( const CvArr* srcarr, CvArr* dstarr, int flip_mode )
{
cv::Mat src = cv::cvarrToMat(srcarr);
cv::Mat dst;
if (!dstarr)
dst = src;
else
dst = cv::cvarrToMat(dstarr);
CV_Assert( src.type() == dst.type() && src.size() == dst.size() );
cv::flip( src, dst, flip_mode );
}
+46 -46
View File
@@ -3349,7 +3349,7 @@ cvTreeToNodeSeq( const void* first, int header_size, CvMemStorage* storage )
}
}
return allseq;
}
@@ -3531,9 +3531,9 @@ namespace cv
// both cv (CvFeatureTree) and ml (kNN).
// The algorithm is taken from:
// J.S. Beis and D.G. Lowe. Shape indexing using approximate nearest-neighbor search
// in highdimensional spaces. In Proc. IEEE Conf. Comp. Vision Patt. Recog.,
// pages 1000--1006, 1997. http://citeseer.ist.psu.edu/beis97shape.html
// J.S. Beis and D.G. Lowe. Shape indexing using approximate nearest-neighbor search
// in highdimensional spaces. In Proc. IEEE Conf. Comp. Vision Patt. Recog.,
// pages 1000--1006, 1997. http://citeseer.ist.psu.edu/beis97shape.html
const int MAX_TREE_DEPTH = 32;
@@ -3555,8 +3555,8 @@ KDTree::KDTree(InputArray _points, InputArray _labels, bool _copyData)
maxDepth = -1;
normType = NORM_L2;
build(_points, _labels, _copyData);
}
}
struct SubTree
{
SubTree() : first(0), last(0), nodeIdx(0), depth(0) {}
@@ -3596,7 +3596,7 @@ medianPartition( size_t* ofs, int a, int b, const float* vals )
else
a = i0;
}
float pivot = vals[ofs[middle]];
int less = 0, more = 0;
for( k = a0; k < middle; k++ )
@@ -3632,7 +3632,7 @@ computeSums( const Mat& points, const size_t* ofs, int a, int b, double* sums )
}
}
void KDTree::build(InputArray _points, bool _copyData)
{
build(_points, noArray(), _copyData);
@@ -3652,8 +3652,8 @@ void KDTree::build(InputArray __points, InputArray __labels, bool _copyData)
points.release();
points.create(_points.size(), _points.type());
}
int i, j, n = _points.rows, dims = _points.cols, top = 0;
int i, j, n = _points.rows, ptdims = _points.cols, top = 0;
const float* data = _points.ptr<float>(0);
float* dstdata = points.ptr<float>(0);
size_t step = _points.step1();
@@ -3661,7 +3661,7 @@ void KDTree::build(InputArray __points, InputArray __labels, bool _copyData)
int ptpos = 0;
labels.resize(n);
const int* _labels_data = 0;
if( !_labels.empty() )
{
int nlabels = _labels.checkVector(1, CV_32S, true);
@@ -3669,9 +3669,9 @@ void KDTree::build(InputArray __points, InputArray __labels, bool _copyData)
_labels_data = (const int*)_labels.data;
}
Mat sumstack(MAX_TREE_DEPTH*2, dims*2, CV_64F);
Mat sumstack(MAX_TREE_DEPTH*2, ptdims*2, CV_64F);
SubTree stack[MAX_TREE_DEPTH*2];
vector<size_t> _ptofs(n);
size_t* ptofs = &_ptofs[0];
@@ -3682,7 +3682,7 @@ void KDTree::build(InputArray __points, InputArray __labels, bool _copyData)
computeSums(points, ptofs, 0, n-1, sumstack.ptr<double>(top));
stack[top++] = SubTree(0, n-1, 0, 0);
int _maxDepth = 0;
while( --top >= 0 )
{
int first = stack[top].first, last = stack[top].last;
@@ -3700,16 +3700,16 @@ void KDTree::build(InputArray __points, InputArray __labels, bool _copyData)
{
const float* src = data + ptofs[first];
float* dst = dstdata + idx*dstep;
for( j = 0; j < dims; j++ )
for( j = 0; j < ptdims; j++ )
dst[j] = src[j];
}
labels[idx] = _labels_data ? _labels_data[idx0] : idx0;
labels[idx] = _labels_data ? _labels_data[idx0] : idx0;
_maxDepth = std::max(_maxDepth, depth);
continue;
}
// find the dimensionality with the biggest variance
for( j = 0; j < dims; j++ )
for( j = 0; j < ptdims; j++ )
{
double m = sums[j*2]*invCount;
double varj = sums[j*2+1]*invCount - m*m;
@@ -3729,9 +3729,9 @@ void KDTree::build(InputArray __points, InputArray __labels, bool _copyData)
nodes[nidx].boundary = medianPartition(ptofs, first, last, data + dim);
int middle = (first + last)/2;
double *lsums = (double*)sums, *rsums = lsums + dims*2;
double *lsums = (double*)sums, *rsums = lsums + ptdims*2;
computeSums(points, ptofs, middle+1, last, rsums);
for( j = 0; j < dims*2; j++ )
for( j = 0; j < ptdims*2; j++ )
lsums[j] = sums[j] - rsums[j];
stack[top++] = SubTree(first, middle, left, depth+1);
stack[top++] = SubTree(middle+1, last, right, depth+1);
@@ -3752,13 +3752,13 @@ struct PQueueElem
int KDTree::findNearest(InputArray _vec, int K, int emax,
OutputArray _neighborsIdx, OutputArray _neighbors,
OutputArray _dist, OutputArray _labels) const
{
Mat vecmat = _vec.getMat();
CV_Assert( vecmat.isContinuous() && vecmat.type() == CV_32F && vecmat.total() == (size_t)points.cols );
const float* vec = vecmat.ptr<float>();
K = std::min(K, points.rows);
int dims = points.cols;
int ptdims = points.cols;
CV_Assert(K > 0 && (normType == NORM_L2 || normType == NORM_L1));
@@ -3776,7 +3776,7 @@ int KDTree::findNearest(InputArray _vec, int K, int emax,
{
float d, alt_d = 0.f;
int nidx;
if( e == 0 )
nidx = 0;
else
@@ -3803,7 +3803,7 @@ int KDTree::findNearest(InputArray _vec, int K, int emax,
i = left;
}
}
if( ncount == K && alt_d > dist[ncount-1] )
continue;
}
@@ -3813,21 +3813,21 @@ int KDTree::findNearest(InputArray _vec, int K, int emax,
if( nidx < 0 )
break;
const Node& n = nodes[nidx];
if( n.idx < 0 )
{
i = ~n.idx;
const float* row = points.ptr<float>(i);
if( normType == NORM_L2 )
for( j = 0, d = 0.f; j < dims; j++ )
for( j = 0, d = 0.f; j < ptdims; j++ )
{
float t = vec[j] - row[j];
d += t*t;
}
else
for( j = 0, d = 0.f; j < dims; j++ )
for( j = 0, d = 0.f; j < ptdims; j++ )
d += std::abs(vec[j] - row[j]);
dist[ncount] = d;
idx[ncount] = i;
for( i = ncount-1; i >= 0; i-- )
@@ -3839,9 +3839,9 @@ int KDTree::findNearest(InputArray _vec, int K, int emax,
}
ncount += ncount < K;
e++;
break;
break;
}
int alt;
if( vec[n.idx] <= n.boundary )
{
@@ -3853,7 +3853,7 @@ int KDTree::findNearest(InputArray _vec, int K, int emax,
nidx = n.right;
alt = n.left;
}
d = vec[n.idx] - n.boundary;
if( normType == NORM_L2 )
d = d*d + alt_d;
@@ -3898,22 +3898,22 @@ void KDTree::findOrthoRange(InputArray _lowerBound,
OutputArray _neighbors,
OutputArray _labels ) const
{
int dims = points.cols;
int ptdims = points.cols;
Mat lowerBound = _lowerBound.getMat(), upperBound = _upperBound.getMat();
CV_Assert( lowerBound.size == upperBound.size &&
lowerBound.isContinuous() &&
upperBound.isContinuous() &&
lowerBound.type() == upperBound.type() &&
lowerBound.type() == CV_32F &&
lowerBound.total() == (size_t)dims );
lowerBound.total() == (size_t)ptdims );
const float* L = lowerBound.ptr<float>();
const float* R = upperBound.ptr<float>();
vector<int> idx;
AutoBuffer<int> _stack(MAX_TREE_DEPTH*2 + 1);
int* stack = _stack;
int top = 0;
stack[top++] = 0;
while( --top >= 0 )
@@ -3926,10 +3926,10 @@ void KDTree::findOrthoRange(InputArray _lowerBound,
{
int j, i = ~n.idx;
const float* row = points.ptr<float>(i);
for( j = 0; j < dims; j++ )
for( j = 0; j < ptdims; j++ )
if( row[j] < L[j] || row[j] >= R[j] )
break;
if( j == dims )
if( j == ptdims )
idx.push_back(i);
continue;
}
@@ -3948,7 +3948,7 @@ void KDTree::findOrthoRange(InputArray _lowerBound,
getPoints( idx, _neighbors, _labels );
}
void KDTree::getPoints(InputArray _idx, OutputArray _pts, OutputArray _labels) const
{
Mat idxmat = _idx.getMat(), pts, labelsmat;
@@ -3956,8 +3956,8 @@ void KDTree::getPoints(InputArray _idx, OutputArray _pts, OutputArray _labels) c
(idxmat.cols == 1 || idxmat.rows == 1) );
const int* idx = idxmat.ptr<int>();
int* dstlabels = 0;
int dims = points.cols;
int ptdims = points.cols;
int i, nidx = (int)idxmat.total();
if( nidx == 0 )
{
@@ -3965,13 +3965,13 @@ void KDTree::getPoints(InputArray _idx, OutputArray _pts, OutputArray _labels) c
_labels.release();
return;
}
if( _pts.needed() )
{
_pts.create( nidx, dims, points.type());
_pts.create( nidx, ptdims, points.type());
pts = _pts.getMat();
}
if(_labels.needed())
{
_labels.create(nidx, 1, CV_32S, -1, true);
@@ -3980,14 +3980,14 @@ void KDTree::getPoints(InputArray _idx, OutputArray _pts, OutputArray _labels) c
dstlabels = labelsmat.ptr<int>();
}
const int* srclabels = !labels.empty() ? &labels[0] : 0;
for( i = 0; i < nidx; i++ )
{
int k = idx[i];
CV_Assert( (unsigned)k < (unsigned)points.rows );
const float* src = points.ptr<float>(k);
if( pts.data )
std::copy(src, src + dims, pts.ptr<float>(i));
std::copy(src, src + ptdims, pts.ptr<float>(i));
if( dstlabels )
dstlabels[i] = srclabels ? srclabels[k] : k;
}
@@ -4007,9 +4007,9 @@ int KDTree::dims() const
{
return !points.empty() ? points.cols : 0;
}
////////////////////////////////////////////////////////////////////////////////
schar* seqPush( CvSeq* seq, const void* element )
{
return cvSeqPush(seq, element);
+8 -8
View File
@@ -169,7 +169,7 @@ LineIterator::LineIterator(const Mat& img, Point pt1, Point pt2,
}
int bt_pix0 = (int)img.elemSize(), bt_pix = bt_pix0;
size_t step = img.step;
size_t istep = img.step;
int dx = pt2.x - pt1.x;
int dy = pt2.y - pt1.y;
@@ -188,11 +188,11 @@ LineIterator::LineIterator(const Mat& img, Point pt1, Point pt2,
bt_pix = (bt_pix ^ s) - s;
}
ptr = (uchar*)(img.data + pt1.y * step + pt1.x * bt_pix0);
ptr = (uchar*)(img.data + pt1.y * istep + pt1.x * bt_pix0);
s = dy < 0 ? -1 : 0;
dy = (dy ^ s) - s;
step = (step ^ s) - s;
istep = (istep ^ s) - s;
s = dy > dx ? -1 : 0;
@@ -201,9 +201,9 @@ LineIterator::LineIterator(const Mat& img, Point pt1, Point pt2,
dy ^= dx & s;
dx ^= dy & s;
bt_pix ^= step & s;
step ^= bt_pix & s;
bt_pix ^= step & s;
bt_pix ^= istep & s;
istep ^= bt_pix & s;
bt_pix ^= istep & s;
if( connectivity == 8 )
{
@@ -212,7 +212,7 @@ LineIterator::LineIterator(const Mat& img, Point pt1, Point pt2,
err = dx - (dy + dy);
plusDelta = dx + dx;
minusDelta = -(dy + dy);
plusStep = (int)step;
plusStep = (int)istep;
minusStep = bt_pix;
count = dx + 1;
}
@@ -223,7 +223,7 @@ LineIterator::LineIterator(const Mat& img, Point pt1, Point pt2,
err = 0;
plusDelta = (dx + dx) + (dy + dy);
minusDelta = -(dy + dy);
plusStep = (int)step - bt_pix;
plusStep = (int)istep - bt_pix;
minusStep = bt_pix;
count = dx + dy + 1;
}
+9 -9
View File
@@ -524,30 +524,30 @@ cv::gpu::GpuMat::GpuMat(Size size_, int type_, void* data_, size_t step_) :
dataend += step * (rows - 1) + minstep;
}
cv::gpu::GpuMat::GpuMat(const GpuMat& m, Range rowRange, Range colRange)
cv::gpu::GpuMat::GpuMat(const GpuMat& m, Range _rowRange, Range _colRange)
{
flags = m.flags;
step = m.step; refcount = m.refcount;
data = m.data; datastart = m.datastart; dataend = m.dataend;
if (rowRange == Range::all())
if (_rowRange == Range::all())
rows = m.rows;
else
{
CV_Assert(0 <= rowRange.start && rowRange.start <= rowRange.end && rowRange.end <= m.rows);
CV_Assert(0 <= _rowRange.start && _rowRange.start <= _rowRange.end && _rowRange.end <= m.rows);
rows = rowRange.size();
data += step*rowRange.start;
rows = _rowRange.size();
data += step*_rowRange.start;
}
if (colRange == Range::all())
if (_colRange == Range::all())
cols = m.cols;
else
{
CV_Assert(0 <= colRange.start && colRange.start <= colRange.end && colRange.end <= m.cols);
CV_Assert(0 <= _colRange.start && _colRange.start <= _colRange.end && _colRange.end <= m.cols);
cols = colRange.size();
data += colRange.start*elemSize();
cols = _colRange.size();
data += _colRange.start*elemSize();
flags &= cols < m.cols ? ~Mat::CONTINUOUS_FLAG : -1;
}
+29 -29
View File
@@ -63,7 +63,7 @@ GEMM_CopyBlock( const uchar* src, size_t src_step,
for( ; size.height--; src += src_step, dst += dst_step )
{
j=0;
j=0;
#if CV_ENABLE_UNROLLED
for( ; j <= size.width - 4; j += 4 )
{
@@ -345,7 +345,7 @@ GEMMSingleMul( const T* a_data, size_t a_step,
for( k = 0; k < n; k++, b_data += b_step )
{
WT al(a_data[k]);
j=0;
j=0;
#if CV_ENABLE_UNROLLED
for(; j <= m - 4; j += 4 )
{
@@ -513,8 +513,8 @@ GEMMStore( const T* c_data, size_t c_step,
if( _c_data )
{
c_data = _c_data;
j=0;
#if CV_ENABLE_UNROLLED
j=0;
#if CV_ENABLE_UNROLLED
for(; j <= d_size.width - 4; j += 4, c_data += 4*c_step1 )
{
WT t0 = alpha*d_buf[j];
@@ -539,8 +539,8 @@ GEMMStore( const T* c_data, size_t c_step,
}
else
{
j = 0;
#if CV_ENABLE_UNROLLED
j = 0;
#if CV_ENABLE_UNROLLED
for( ; j <= d_size.width - 4; j += 4 )
{
WT t0 = alpha*d_buf[j];
@@ -552,7 +552,7 @@ GEMMStore( const T* c_data, size_t c_step,
d_data[j+2] = T(t0);
d_data[j+3] = T(t1);
}
#endif
#endif
for( ; j < d_size.width; j++ )
d_data[j] = T(alpha*d_buf[j]);
}
@@ -597,7 +597,7 @@ static void GEMMSingleMul_64f( const double* a_data, size_t a_step,
alpha, beta, flags);
}
static void GEMMSingleMul_32fc( const Complexf* a_data, size_t a_step,
const Complexf* b_data, size_t b_step,
const Complexf* c_data, size_t c_step,
@@ -620,7 +620,7 @@ static void GEMMSingleMul_64fc( const Complexd* a_data, size_t a_step,
GEMMSingleMul<Complexd,Complexd>(a_data, a_step, b_data, b_step, c_data,
c_step, d_data, d_step, a_size, d_size,
alpha, beta, flags);
}
}
static void GEMMBlockMul_32f( const float* a_data, size_t a_step,
const float* b_data, size_t b_step,
@@ -696,7 +696,7 @@ static void GEMMStore_64fc( const Complexd* c_data, size_t c_step,
}
void cv::gemm( InputArray matA, InputArray matB, double alpha,
InputArray matC, double beta, OutputArray matD, int flags )
InputArray matC, double beta, OutputArray _matD, int flags )
{
const int block_lin_size = 128;
const int block_size = block_lin_size * block_lin_size;
@@ -741,8 +741,8 @@ void cv::gemm( InputArray matA, InputArray matB, double alpha,
((flags&GEMM_3_T) != 0 && C.rows == d_size.width && C.cols == d_size.height)));
}
matD.create( d_size.height, d_size.width, type );
Mat D = matD.getMat();
_matD.create( d_size.height, d_size.width, type );
Mat D = _matD.getMat();
if( (flags & GEMM_3_T) != 0 && C.data == D.data )
{
transpose( C, C );
@@ -2008,7 +2008,7 @@ static void scaleAdd_32f(const float* src1, const float* src2, float* dst,
t1 = src1[i+3]*alpha + src2[i+3];
dst[i+2] = t0; dst[i+3] = t1;
}
for(; i < len; i++ )
for(; i < len; i++ )
dst[i] = src1[i]*alpha + src2[i];
}
@@ -2035,7 +2035,7 @@ static void scaleAdd_64f(const double* src1, const double* src2, double* dst,
}
else
#endif
//vz why do we need unroll here?
//vz why do we need unroll here?
for( ; i <= len - 4; i += 4 )
{
double t0, t1;
@@ -2046,7 +2046,7 @@ static void scaleAdd_64f(const double* src1, const double* src2, double* dst,
t1 = src1[i+3]*alpha + src2[i+3];
dst[i+2] = t0; dst[i+3] = t1;
}
for(; i < len; i++ )
for(; i < len; i++ )
dst[i] = src1[i]*alpha + src2[i];
}
@@ -2072,7 +2072,7 @@ void cv::scaleAdd( InputArray _src1, double alpha, InputArray _src2, OutputArray
float falpha = (float)alpha;
void* palpha = depth == CV_32F ? (void*)&falpha : (void*)&alpha;
ScaleAddFunc func = depth == CV_32F ? (ScaleAddFunc)scaleAdd_32f : (ScaleAddFunc)scaleAdd_64f;
ScaleAddFunc func = depth == CV_32F ? (ScaleAddFunc)scaleAdd_32f : (ScaleAddFunc)scaleAdd_64f;
if( src1.isContinuous() && src2.isContinuous() && dst.isContinuous() )
{
@@ -2134,12 +2134,12 @@ void cv::calcCovarMatrix( const Mat* data, int nsamples, Mat& covar, Mat& _mean,
_mean = mean.reshape(1, size.height);
}
void cv::calcCovarMatrix( InputArray _data, OutputArray _covar, InputOutputArray _mean, int flags, int ctype )
void cv::calcCovarMatrix( InputArray _src, OutputArray _covar, InputOutputArray _mean, int flags, int ctype )
{
if(_data.kind() == _InputArray::STD_VECTOR_MAT)
if(_src.kind() == _InputArray::STD_VECTOR_MAT)
{
std::vector<cv::Mat> src;
_data.getMatVector(src);
_src.getMatVector(src);
CV_Assert( src.size() > 0 );
@@ -2185,7 +2185,7 @@ void cv::calcCovarMatrix( InputArray _data, OutputArray _covar, InputOutputArray
return;
}
Mat data = _data.getMat(), mean;
Mat data = _src.getMat(), mean;
CV_Assert( ((flags & CV_COVAR_ROWS) != 0) ^ ((flags & CV_COVAR_COLS) != 0) );
bool takeRows = (flags & CV_COVAR_ROWS) != 0;
int type = data.type();
@@ -2209,7 +2209,7 @@ void cv::calcCovarMatrix( InputArray _data, OutputArray _covar, InputOutputArray
else
{
ctype = std::max(CV_MAT_DEPTH(ctype >= 0 ? ctype : type), CV_32F);
reduce( _data, _mean, takeRows ? 0 : 1, CV_REDUCE_AVG, ctype );
reduce( _src, _mean, takeRows ? 0 : 1, CV_REDUCE_AVG, ctype );
mean = _mean.getMat();
}
@@ -2223,7 +2223,7 @@ void cv::calcCovarMatrix( InputArray _data, OutputArray _covar, InputOutputArray
double cv::Mahalanobis( InputArray _v1, InputArray _v2, InputArray _icovar )
{
Mat v1 = _v1.getMat(), v2 = _v2.getMat(), icovar = _icovar.getMat();
Mat v1 = _v1.getMat(), v2 = _v2.getMat(), icovar = _icovar.getMat();
int type = v1.type(), depth = v1.depth();
Size sz = v1.size();
int i, j, len = sz.width*sz.height*v1.channels();
@@ -2261,7 +2261,7 @@ double cv::Mahalanobis( InputArray _v1, InputArray _v2, InputArray _icovar )
{
double row_sum = 0;
j = 0;
#if CV_ENABLE_UNROLLED
#if CV_ENABLE_UNROLLED
for(; j <= len - 4; j += 4 )
row_sum += diff[j]*mat[j] + diff[j+1]*mat[j+1] +
diff[j+2]*mat[j+2] + diff[j+3]*mat[j+3];
@@ -2292,7 +2292,7 @@ double cv::Mahalanobis( InputArray _v1, InputArray _v2, InputArray _icovar )
{
double row_sum = 0;
j = 0;
#if CV_ENABLE_UNROLLED
#if CV_ENABLE_UNROLLED
for(; j <= len - 4; j += 4 )
row_sum += diff[j]*mat[j] + diff[j+1]*mat[j+1] +
diff[j+2]*mat[j+2] + diff[j+3]*mat[j+3];
@@ -2642,7 +2642,7 @@ dotProd_(const T* src1, const T* src2, int len)
{
int i = 0;
double result = 0;
#if CV_ENABLE_UNROLLED
#if CV_ENABLE_UNROLLED
for( ; i <= len - 4; i += 4 )
result += (double)src1[i]*src2[i] + (double)src1[i+1]*src2[i+1] +
(double)src1[i+2]*src2[i+2] + (double)src1[i+3]*src2[i+3];
@@ -2674,7 +2674,7 @@ static double dotProd_8u(const uchar* src1, const uchar* src2, int len)
{
blockSize = std::min(len0 - i, blockSize0);
__m128i s = _mm_setzero_si128();
j = 0;
j = 0;
for( ; j <= blockSize - 16; j += 16 )
{
__m128i b0 = _mm_loadu_si128((const __m128i*)(src1 + j));
@@ -2806,9 +2806,9 @@ double Mat::dot(InputArray _mat) const
PCA::PCA() {}
PCA::PCA(InputArray data, InputArray mean, int flags, int maxComponents)
PCA::PCA(InputArray data, InputArray _mean, int flags, int maxComponents)
{
operator()(data, mean, flags, maxComponents);
operator()(data, _mean, flags, maxComponents);
}
PCA& PCA::operator()(InputArray _data, InputArray __mean, int flags, int maxComponents)
@@ -2964,7 +2964,7 @@ void cv::PCACompute(InputArray data, InputOutputArray mean,
pca.mean.copyTo(mean);
pca.eigenvectors.copyTo(eigenvectors);
}
void cv::PCAProject(InputArray data, InputArray mean,
InputArray eigenvectors, OutputArray result)
{
+193 -193
View File
File diff suppressed because it is too large Load Diff
+61 -61
View File
@@ -210,9 +210,9 @@ void Mat::create(int d, const int* _sizes, int _type)
#endif
if( !allocator )
{
size_t total = alignSize(step.p[0]*size.p[0], (int)sizeof(*refcount));
data = datastart = (uchar*)fastMalloc(total + (int)sizeof(*refcount));
refcount = (int*)(data + total);
size_t totalsize = alignSize(step.p[0]*size.p[0], (int)sizeof(*refcount));
data = datastart = (uchar*)fastMalloc(totalsize + (int)sizeof(*refcount));
refcount = (int*)(data + totalsize);
*refcount = 1;
}
else
@@ -262,15 +262,15 @@ void Mat::deallocate()
}
Mat::Mat(const Mat& m, const Range& rowRange, const Range& colRange) : size(&rows)
Mat::Mat(const Mat& m, const Range& _rowRange, const Range& _colRange) : size(&rows)
{
initEmpty();
CV_Assert( m.dims >= 2 );
if( m.dims > 2 )
{
AutoBuffer<Range> rs(m.dims);
rs[0] = rowRange;
rs[1] = colRange;
rs[0] = _rowRange;
rs[1] = _colRange;
for( int i = 2; i < m.dims; i++ )
rs[i] = Range::all();
*this = m(rs);
@@ -278,19 +278,19 @@ Mat::Mat(const Mat& m, const Range& rowRange, const Range& colRange) : size(&row
}
*this = m;
if( rowRange != Range::all() && rowRange != Range(0,rows) )
if( _rowRange != Range::all() && _rowRange != Range(0,rows) )
{
CV_Assert( 0 <= rowRange.start && rowRange.start <= rowRange.end && rowRange.end <= m.rows );
rows = rowRange.size();
data += step*rowRange.start;
CV_Assert( 0 <= _rowRange.start && _rowRange.start <= _rowRange.end && _rowRange.end <= m.rows );
rows = _rowRange.size();
data += step*_rowRange.start;
flags |= SUBMATRIX_FLAG;
}
if( colRange != Range::all() && colRange != Range(0,cols) )
if( _colRange != Range::all() && _colRange != Range(0,cols) )
{
CV_Assert( 0 <= colRange.start && colRange.start <= colRange.end && colRange.end <= m.cols );
cols = colRange.size();
data += colRange.start*elemSize();
CV_Assert( 0 <= _colRange.start && _colRange.start <= _colRange.end && _colRange.end <= m.cols );
cols = _colRange.size();
data += _colRange.start*elemSize();
flags &= cols < m.cols ? ~CONTINUOUS_FLAG : -1;
flags |= SUBMATRIX_FLAG;
}
@@ -473,14 +473,14 @@ Mat::Mat(const IplImage* img, bool copyData) : size(&rows)
dims = 2;
CV_DbgAssert(CV_IS_IMAGE(img) && img->imageData != 0);
int depth = IPL2CV_DEPTH(img->depth);
int imgdepth = IPL2CV_DEPTH(img->depth);
size_t esz;
step[0] = img->widthStep;
if(!img->roi)
{
CV_Assert(img->dataOrder == IPL_DATA_ORDER_PIXEL);
flags = MAGIC_VAL + CV_MAKETYPE(depth, img->nChannels);
flags = MAGIC_VAL + CV_MAKETYPE(imgdepth, img->nChannels);
rows = img->height; cols = img->width;
datastart = data = (uchar*)img->imageData;
esz = CV_ELEM_SIZE(flags);
@@ -489,7 +489,7 @@ Mat::Mat(const IplImage* img, bool copyData) : size(&rows)
{
CV_Assert(img->dataOrder == IPL_DATA_ORDER_PIXEL || img->roi->coi != 0);
bool selectedPlane = img->roi->coi && img->dataOrder == IPL_DATA_ORDER_PLANE;
flags = MAGIC_VAL + CV_MAKETYPE(depth, selectedPlane ? 1 : img->nChannels);
flags = MAGIC_VAL + CV_MAKETYPE(imgdepth, selectedPlane ? 1 : img->nChannels);
rows = img->roi->height; cols = img->roi->width;
esz = CV_ELEM_SIZE(flags);
data = datastart = (uchar*)img->imageData +
@@ -1299,38 +1299,38 @@ bool _OutputArray::fixedType() const
return (flags & FIXED_TYPE) == FIXED_TYPE;
}
void _OutputArray::create(Size _sz, int type, int i, bool allowTransposed, int fixedDepthMask) const
void _OutputArray::create(Size _sz, int mtype, int i, bool allowTransposed, int fixedDepthMask) const
{
int k = kind();
if( k == MAT && i < 0 && !allowTransposed && fixedDepthMask == 0 )
{
CV_Assert(!fixedSize() || ((Mat*)obj)->size.operator()() == _sz);
CV_Assert(!fixedType() || ((Mat*)obj)->type() == type);
((Mat*)obj)->create(_sz, type);
CV_Assert(!fixedType() || ((Mat*)obj)->type() == mtype);
((Mat*)obj)->create(_sz, mtype);
return;
}
int sz[] = {_sz.height, _sz.width};
create(2, sz, type, i, allowTransposed, fixedDepthMask);
int sizes[] = {_sz.height, _sz.width};
create(2, sizes, mtype, i, allowTransposed, fixedDepthMask);
}
void _OutputArray::create(int rows, int cols, int type, int i, bool allowTransposed, int fixedDepthMask) const
void _OutputArray::create(int rows, int cols, int mtype, int i, bool allowTransposed, int fixedDepthMask) const
{
int k = kind();
if( k == MAT && i < 0 && !allowTransposed && fixedDepthMask == 0 )
{
CV_Assert(!fixedSize() || ((Mat*)obj)->size.operator()() == Size(cols, rows));
CV_Assert(!fixedType() || ((Mat*)obj)->type() == type);
((Mat*)obj)->create(rows, cols, type);
CV_Assert(!fixedType() || ((Mat*)obj)->type() == mtype);
((Mat*)obj)->create(rows, cols, mtype);
return;
}
int sz[] = {rows, cols};
create(2, sz, type, i, allowTransposed, fixedDepthMask);
int sizes[] = {rows, cols};
create(2, sizes, mtype, i, allowTransposed, fixedDepthMask);
}
void _OutputArray::create(int dims, const int* size, int type, int i, bool allowTransposed, int fixedDepthMask) const
void _OutputArray::create(int dims, const int* sizes, int mtype, int i, bool allowTransposed, int fixedDepthMask) const
{
int k = kind();
type = CV_MAT_TYPE(type);
mtype = CV_MAT_TYPE(mtype);
if( k == MAT )
{
@@ -1345,24 +1345,24 @@ void _OutputArray::create(int dims, const int* size, int type, int i, bool allow
}
if( dims == 2 && m.dims == 2 && m.data &&
m.type() == type && m.rows == size[1] && m.cols == size[0] )
m.type() == mtype && m.rows == sizes[1] && m.cols == sizes[0] )
return;
}
if(fixedType())
{
if(CV_MAT_CN(type) == m.channels() && ((1 << CV_MAT_TYPE(flags)) & fixedDepthMask) != 0 )
type = m.type();
if(CV_MAT_CN(mtype) == m.channels() && ((1 << CV_MAT_TYPE(flags)) & fixedDepthMask) != 0 )
mtype = m.type();
else
CV_Assert(CV_MAT_TYPE(type) == m.type());
CV_Assert(CV_MAT_TYPE(mtype) == m.type());
}
if(fixedSize())
{
CV_Assert(m.dims == dims);
for(int j = 0; j < dims; ++j)
CV_Assert(m.size[j] == size[j]);
CV_Assert(m.size[j] == sizes[j]);
}
m.create(dims, size, type);
m.create(dims, sizes, mtype);
return;
}
@@ -1370,16 +1370,16 @@ void _OutputArray::create(int dims, const int* size, int type, int i, bool allow
{
CV_Assert( i < 0 );
int type0 = CV_MAT_TYPE(flags);
CV_Assert( type == type0 || (CV_MAT_CN(type) == 1 && ((1 << type0) & fixedDepthMask) != 0) );
CV_Assert( dims == 2 && ((size[0] == sz.height && size[1] == sz.width) ||
(allowTransposed && size[0] == sz.width && size[1] == sz.height)));
CV_Assert( mtype == type0 || (CV_MAT_CN(mtype) == 1 && ((1 << type0) & fixedDepthMask) != 0) );
CV_Assert( dims == 2 && ((sizes[0] == sz.height && sizes[1] == sz.width) ||
(allowTransposed && sizes[0] == sz.width && sizes[1] == sz.height)));
return;
}
if( k == STD_VECTOR || k == STD_VECTOR_VECTOR )
{
CV_Assert( dims == 2 && (size[0] == 1 || size[1] == 1 || size[0]*size[1] == 0) );
size_t len = size[0]*size[1] > 0 ? size[0] + size[1] - 1 : 0;
CV_Assert( dims == 2 && (sizes[0] == 1 || sizes[1] == 1 || sizes[0]*sizes[1] == 0) );
size_t len = sizes[0]*sizes[1] > 0 ? sizes[0] + sizes[1] - 1 : 0;
vector<uchar>* v = (vector<uchar>*)obj;
if( k == STD_VECTOR_VECTOR )
@@ -1398,7 +1398,7 @@ void _OutputArray::create(int dims, const int* size, int type, int i, bool allow
CV_Assert( i < 0 );
int type0 = CV_MAT_TYPE(flags);
CV_Assert( type == type0 || (CV_MAT_CN(type) == CV_MAT_CN(type0) && ((1 << type0) & fixedDepthMask) != 0) );
CV_Assert( mtype == type0 || (CV_MAT_CN(mtype) == CV_MAT_CN(type0) && ((1 << type0) & fixedDepthMask) != 0) );
int esz = CV_ELEM_SIZE(type0);
CV_Assert(!fixedSize() || len == ((vector<uchar>*)v)->size() / esz);
@@ -1471,20 +1471,20 @@ void _OutputArray::create(int dims, const int* size, int type, int i, bool allow
if( i < 0 )
{
CV_Assert( dims == 2 && (size[0] == 1 || size[1] == 1 || size[0]*size[1] == 0) );
size_t len = size[0]*size[1] > 0 ? size[0] + size[1] - 1 : 0, len0 = v.size();
CV_Assert( dims == 2 && (sizes[0] == 1 || sizes[1] == 1 || sizes[0]*sizes[1] == 0) );
size_t len = sizes[0]*sizes[1] > 0 ? sizes[0] + sizes[1] - 1 : 0, len0 = v.size();
CV_Assert(!fixedSize() || len == len0);
v.resize(len);
if( fixedType() )
{
int type = CV_MAT_TYPE(flags);
int _type = CV_MAT_TYPE(flags);
for( size_t j = len0; j < len; j++ )
{
if( v[i].type() == type )
if( v[i].type() == _type )
continue;
CV_Assert( v[i].empty() );
v[i].flags = (v[i].flags & ~CV_MAT_TYPE_MASK) | type;
v[i].flags = (v[i].flags & ~CV_MAT_TYPE_MASK) | _type;
}
}
return;
@@ -1502,25 +1502,25 @@ void _OutputArray::create(int dims, const int* size, int type, int i, bool allow
}
if( dims == 2 && m.dims == 2 && m.data &&
m.type() == type && m.rows == size[1] && m.cols == size[0] )
m.type() == mtype && m.rows == sizes[1] && m.cols == sizes[0] )
return;
}
if(fixedType())
{
if(CV_MAT_CN(type) == m.channels() && ((1 << CV_MAT_TYPE(flags)) & fixedDepthMask) != 0 )
type = m.type();
if(CV_MAT_CN(mtype) == m.channels() && ((1 << CV_MAT_TYPE(flags)) & fixedDepthMask) != 0 )
mtype = m.type();
else
CV_Assert(!fixedType() || (CV_MAT_CN(type) == m.channels() && ((1 << CV_MAT_TYPE(flags)) & fixedDepthMask) != 0));
CV_Assert(!fixedType() || (CV_MAT_CN(mtype) == m.channels() && ((1 << CV_MAT_TYPE(flags)) & fixedDepthMask) != 0));
}
if(fixedSize())
{
CV_Assert(m.dims == dims);
for(int j = 0; j < dims; ++j)
CV_Assert(m.size[j] == size[j]);
CV_Assert(m.size[j] == sizes[j]);
}
m.create(dims, size, type);
m.create(dims, sizes, mtype);
}
}
@@ -1929,10 +1929,10 @@ void cv::completeSymm( InputOutputArray _m, bool LtoR )
cv::Mat cv::Mat::cross(InputArray _m) const
{
Mat m = _m.getMat();
int t = type(), d = CV_MAT_DEPTH(t);
CV_Assert( dims <= 2 && m.dims <= 2 && size() == m.size() && t == m.type() &&
int tp = type(), d = CV_MAT_DEPTH(tp);
CV_Assert( dims <= 2 && m.dims <= 2 && size() == m.size() && tp == m.type() &&
((rows == 3 && cols == 1) || (cols*channels() == 3 && rows == 1)));
Mat result(rows, cols, t);
Mat result(rows, cols, tp);
if( d == CV_32F )
{
@@ -2845,7 +2845,7 @@ cvRange( CvArr* arr, double start, double end )
CV_IMPL void
cvSort( const CvArr* _src, CvArr* _dst, CvArr* _idx, int flags )
{
cv::Mat src = cv::cvarrToMat(_src), dst, idx;
cv::Mat src = cv::cvarrToMat(_src);
if( _idx )
{
@@ -3410,22 +3410,22 @@ SparseMat::SparseMat(const Mat& m)
int i, idx[CV_MAX_DIM] = {0}, d = m.dims, lastSize = m.size[d - 1];
size_t esz = m.elemSize();
uchar* ptr = m.data;
uchar* dptr = m.data;
for(;;)
{
for( i = 0; i < lastSize; i++, ptr += esz )
for( i = 0; i < lastSize; i++, dptr += esz )
{
if( isZeroElem(ptr, esz) )
if( isZeroElem(dptr, esz) )
continue;
idx[d-1] = i;
uchar* to = newNode(idx, hash(idx));
copyElem( ptr, to, esz );
copyElem( dptr, to, esz );
}
for( i = d - 2; i >= 0; i-- )
{
ptr += m.step[i] - m.size[i+1]*m.step[i+1];
dptr += m.step[i] - m.size[i+1]*m.step[i+1];
if( ++idx[i] < m.size[i] )
break;
idx[i] = 0;
+107 -107
View File
@@ -163,11 +163,11 @@ void icvSetOpenGlFuncTab(const CvOpenGlFuncTab* tab)
void cv::gpu::setGlDevice(int device)
{
#ifndef HAVE_CUDA
(void)device;
(void)device;
throw_nocuda;
#else
#ifndef HAVE_OPENGL
(void)device;
(void)device;
throw_nogl;
#else
if (!glFuncTab()->isGlContextInitialized())
@@ -287,7 +287,7 @@ class cv::GlBuffer::Impl
{
public:
static const Ptr<Impl>& empty();
Impl(int rows, int cols, int type, unsigned int target);
Impl(const Mat& m, unsigned int target);
~Impl();
@@ -311,7 +311,7 @@ public:
private:
Impl();
unsigned int buffer_;
#ifdef HAVE_CUDA
@@ -484,57 +484,57 @@ inline void cv::GlBuffer::Impl::unmapDevice(cudaStream_t stream)
#endif // HAVE_OPENGL
cv::GlBuffer::GlBuffer(Usage usage) : rows_(0), cols_(0), type_(0), usage_(usage)
cv::GlBuffer::GlBuffer(Usage _usage) : rows_(0), cols_(0), type_(0), usage_(_usage)
{
#ifndef HAVE_OPENGL
(void)usage;
(void)_usage;
throw_nogl;
#else
impl_ = Impl::empty();
#endif
}
cv::GlBuffer::GlBuffer(int rows, int cols, int type, Usage usage) : rows_(0), cols_(0), type_(0), usage_(usage)
cv::GlBuffer::GlBuffer(int _rows, int _cols, int _type, Usage _usage) : rows_(0), cols_(0), type_(0), usage_(_usage)
{
#ifndef HAVE_OPENGL
(void)rows;
(void)cols;
(void)type;
(void)usage;
(void)_rows;
(void)_cols;
(void)_type;
(void)_usage;
throw_nogl;
#else
impl_ = new Impl(rows, cols, type, usage);
rows_ = rows;
cols_ = cols;
type_ = type;
impl_ = new Impl(_rows, _cols, _type, _usage);
rows_ = _rows;
cols_ = _cols;
type_ = _type;
#endif
}
cv::GlBuffer::GlBuffer(Size size, int type, Usage usage) : rows_(0), cols_(0), type_(0), usage_(usage)
cv::GlBuffer::GlBuffer(Size _size, int _type, Usage _usage) : rows_(0), cols_(0), type_(0), usage_(_usage)
{
#ifndef HAVE_OPENGL
(void)size;
(void)type;
(void)usage;
(void)_size;
(void)_type;
(void)_usage;
throw_nogl;
#else
impl_ = new Impl(size.height, size.width, type, usage);
rows_ = size.height;
cols_ = size.width;
type_ = type;
impl_ = new Impl(_size.height, _size.width, _type, _usage);
rows_ = _size.height;
cols_ = _size.width;
type_ = _type;
#endif
}
cv::GlBuffer::GlBuffer(InputArray mat_, Usage usage) : rows_(0), cols_(0), type_(0), usage_(usage)
cv::GlBuffer::GlBuffer(InputArray mat_, Usage _usage) : rows_(0), cols_(0), type_(0), usage_(_usage)
{
#ifndef HAVE_OPENGL
(void)mat_;
(void)usage;
(void)mat_;
(void)_usage;
throw_nogl;
#else
int kind = mat_.kind();
Size size = mat_.size();
int type = mat_.type();
Size _size = mat_.size();
int _type = mat_.type();
if (kind == _InputArray::GPU_MAT)
{
@@ -542,38 +542,38 @@ cv::GlBuffer::GlBuffer(InputArray mat_, Usage usage) : rows_(0), cols_(0), type_
throw_nocuda;
#else
GpuMat d_mat = mat_.getGpuMat();
impl_ = new Impl(d_mat.rows, d_mat.cols, d_mat.type(), usage);
impl_ = new Impl(d_mat.rows, d_mat.cols, d_mat.type(), _usage);
impl_->copyFrom(d_mat);
#endif
}
else
{
Mat mat = mat_.getMat();
impl_ = new Impl(mat, usage);
impl_ = new Impl(mat, _usage);
}
rows_ = size.height;
cols_ = size.width;
type_ = type;
rows_ = _size.height;
cols_ = _size.width;
type_ = _type;
#endif
}
void cv::GlBuffer::create(int rows, int cols, int type, Usage usage)
void cv::GlBuffer::create(int _rows, int _cols, int _type, Usage _usage)
{
#ifndef HAVE_OPENGL
(void)rows;
(void)cols;
(void)type;
(void)usage;
(void)_rows;
(void)_cols;
(void)_type;
(void)_usage;
throw_nogl;
#else
if (rows_ != rows || cols_ != cols || type_ != type || usage_ != usage)
if (rows_ != _rows || cols_ != _cols || type_ != _type || usage_ != _usage)
{
impl_ = new Impl(rows, cols, type, usage);
rows_ = rows;
cols_ = cols;
type_ = type;
usage_ = usage;
impl_ = new Impl(_rows, _cols, _type, _usage);
rows_ = _rows;
cols_ = _cols;
type_ = _type;
usage_ = _usage;
}
#endif
}
@@ -590,14 +590,14 @@ void cv::GlBuffer::release()
void cv::GlBuffer::copyFrom(InputArray mat_)
{
#ifndef HAVE_OPENGL
(void)mat_;
(void)mat_;
throw_nogl;
#else
int kind = mat_.kind();
Size size = mat_.size();
int type = mat_.type();
Size _size = mat_.size();
int _type = mat_.type();
create(size, type);
create(_size, _type);
switch (kind)
{
@@ -728,7 +728,7 @@ public:
private:
Impl();
GLuint tex_;
};
@@ -926,45 +926,45 @@ cv::GlTexture::GlTexture() : rows_(0), cols_(0), type_(0), buf_(GlBuffer::TEXTUR
#endif
}
cv::GlTexture::GlTexture(int rows, int cols, int type) : rows_(0), cols_(0), type_(0), buf_(GlBuffer::TEXTURE_BUFFER)
cv::GlTexture::GlTexture(int _rows, int _cols, int _type) : rows_(0), cols_(0), type_(0), buf_(GlBuffer::TEXTURE_BUFFER)
{
#ifndef HAVE_OPENGL
(void)rows;
(void)cols;
(void)type;
(void)_rows;
(void)_cols;
(void)_type;
throw_nogl;
#else
impl_ = new Impl(rows, cols, type);
rows_ = rows;
cols_ = cols;
type_ = type;
impl_ = new Impl(_rows, _cols, _type);
rows_ = _rows;
cols_ = _cols;
type_ = _type;
#endif
}
cv::GlTexture::GlTexture(Size size, int type) : rows_(0), cols_(0), type_(0), buf_(GlBuffer::TEXTURE_BUFFER)
cv::GlTexture::GlTexture(Size _size, int _type) : rows_(0), cols_(0), type_(0), buf_(GlBuffer::TEXTURE_BUFFER)
{
#ifndef HAVE_OPENGL
(void)size;
(void)type;
(void)_size;
(void)_type;
throw_nogl;
#else
impl_ = new Impl(size.height, size.width, type);
rows_ = size.height;
cols_ = size.width;
type_ = type;
impl_ = new Impl(_size.height, _size.width, _type);
rows_ = _size.height;
cols_ = _size.width;
type_ = _type;
#endif
}
cv::GlTexture::GlTexture(InputArray mat_, bool bgra) : rows_(0), cols_(0), type_(0), buf_(GlBuffer::TEXTURE_BUFFER)
{
#ifndef HAVE_OPENGL
(void)mat_;
(void)bgra;
(void)mat_;
(void)bgra;
throw_nogl;
#else
#else
int kind = mat_.kind();
Size size = mat_.size();
int type = mat_.type();
Size _size = mat_.size();
int _type = mat_.type();
switch (kind)
{
@@ -994,26 +994,26 @@ cv::GlTexture::GlTexture(InputArray mat_, bool bgra) : rows_(0), cols_(0), type_
}
}
rows_ = size.height;
cols_ = size.width;
type_ = type;
rows_ = _size.height;
cols_ = _size.width;
type_ = _type;
#endif
}
void cv::GlTexture::create(int rows, int cols, int type)
void cv::GlTexture::create(int _rows, int _cols, int _type)
{
#ifndef HAVE_OPENGL
(void)rows;
(void)cols;
(void)type;
(void)_rows;
(void)_cols;
(void)_type;
throw_nogl;
#else
if (rows_ != rows || cols_ != cols || type_ != type)
if (rows_ != _rows || cols_ != _cols || type_ != _type)
{
impl_ = new Impl(rows, cols, type);
rows_ = rows;
cols_ = cols;
type_ = type;
impl_ = new Impl(_rows, _cols, _type);
rows_ = _rows;
cols_ = _cols;
type_ = _type;
}
#endif
}
@@ -1030,15 +1030,15 @@ void cv::GlTexture::release()
void cv::GlTexture::copyFrom(InputArray mat_, bool bgra)
{
#ifndef HAVE_OPENGL
(void)mat_;
(void)bgra;
(void)mat_;
(void)bgra;
throw_nogl;
#else
int kind = mat_.kind();
Size size = mat_.size();
int type = mat_.type();
Size _size = mat_.size();
int _type = mat_.type();
create(size, type);
create(_size, _type);
switch(kind)
{
@@ -1244,8 +1244,8 @@ void cv::GlArrays::unbind() const
////////////////////////////////////////////////////////////////////////
// GlFont
cv::GlFont::GlFont(const string& family, int height, Weight weight, Style style)
: family_(family), height_(height), weight_(weight), style_(style), base_(0)
cv::GlFont::GlFont(const string& _family, int _height, Weight _weight, Style _style)
: family_(_family), height_(_height), weight_(_weight), style_(_style), base_(0)
{
#ifndef HAVE_OPENGL
throw_nogl;
@@ -1253,7 +1253,7 @@ cv::GlFont::GlFont(const string& family, int height, Weight weight, Style style)
base_ = glGenLists(256);
CV_CheckGlError();
glFuncTab()->generateBitmapFont(family, height, weight, (style & STYLE_ITALIC) != 0, (style & STYLE_UNDERLINE) != 0, 0, 256, base_);
glFuncTab()->generateBitmapFont(family_, height_, weight_, (style_ & STYLE_ITALIC) != 0, (style_ & STYLE_UNDERLINE) != 0, 0, 256, base_);
#endif
}
@@ -1283,7 +1283,7 @@ namespace
class FontCompare : public unary_function<Ptr<GlFont>, bool>
{
public:
inline FontCompare(const string& family, int height, GlFont::Weight weight, GlFont::Style style)
inline FontCompare(const string& family, int height, GlFont::Weight weight, GlFont::Style style)
: family_(family), height_(height), weight_(weight), style_(style)
{
}
@@ -1304,10 +1304,10 @@ namespace
Ptr<GlFont> cv::GlFont::get(const std::string& family, int height, Weight weight, Style style)
{
#ifndef HAVE_OPENGL
(void)family;
(void)height;
(void)weight;
(void)style;
(void)family;
(void)height;
(void)weight;
(void)style;
throw_nogl;
return Ptr<GlFont>();
#else
@@ -1333,9 +1333,9 @@ Ptr<GlFont> cv::GlFont::get(const std::string& family, int height, Weight weight
void cv::render(const GlTexture& tex, Rect_<double> wndRect, Rect_<double> texRect)
{
#ifndef HAVE_OPENGL
(void)tex;
(void)wndRect;
(void)texRect;
(void)tex;
(void)wndRect;
(void)texRect;
throw_nogl;
#else
if (!tex.empty())
@@ -1368,9 +1368,9 @@ void cv::render(const GlTexture& tex, Rect_<double> wndRect, Rect_<double> texRe
void cv::render(const GlArrays& arr, int mode, Scalar color)
{
#ifndef HAVE_OPENGL
(void)arr;
(void)mode;
(void)color;
(void)arr;
(void)mode;
(void)color;
throw_nogl;
#else
glColor3d(color[0] / 255.0, color[1] / 255.0, color[2] / 255.0);
@@ -1386,10 +1386,10 @@ void cv::render(const GlArrays& arr, int mode, Scalar color)
void cv::render(const string& str, const Ptr<GlFont>& font, Scalar color, Point2d pos)
{
#ifndef HAVE_OPENGL
(void)str;
(void)font;
(void)color;
(void)pos;
(void)str;
(void)font;
(void)color;
(void)pos;
throw_nogl;
#else
glPushAttrib(GL_DEPTH_BUFFER_BIT);
@@ -1544,9 +1544,9 @@ void cv::GlCamera::setupModelViewMatrix() const
bool icvCheckGlError(const char* file, const int line, const char* func)
{
#ifndef HAVE_OPENGL
(void)file;
(void)line;
(void)func;
(void)file;
(void)line;
(void)func;
return true;
#else
GLenum err = glGetError();
+4 -4
View File
@@ -1262,7 +1262,7 @@ int Core_SetTest::test_set_ops( int iters )
if( iter > iters/10 && cvtest::randInt(rng)%200 == 0 ) // clear set
{
int prev_count = cvset->total;
prev_count = cvset->total;
cvClearSet( cvset );
cvTsClearSimpleSet( sset );
@@ -1482,19 +1482,19 @@ int Core_GraphTest::test_graph_ops( int iters )
if( cvtest::randInt(rng) % 200 == 0 ) // clear graph
{
int prev_vtx_count = graph->total, prev_edge_count = graph->edges->total;
int prev_vtx_count2 = graph->total, prev_edge_count2 = graph->edges->total;
cvClearGraph( graph );
cvTsClearSimpleGraph( sgraph );
CV_TS_SEQ_CHECK_CONDITION( graph->active_count == 0 && graph->total == 0 &&
graph->first == 0 && graph->free_elems == 0 &&
(graph->free_blocks != 0 || prev_vtx_count == 0),
(graph->free_blocks != 0 || prev_vtx_count2 == 0),
"The graph is not empty after clearing" );
CV_TS_SEQ_CHECK_CONDITION( edges->active_count == 0 && edges->total == 0 &&
edges->first == 0 && edges->free_elems == 0 &&
(edges->free_blocks != 0 || prev_edge_count == 0),
(edges->free_blocks != 0 || prev_edge_count2 == 0),
"The graph is not empty after clearing" );
}
else if( op == 0 ) // add vertex
+83 -83
View File
@@ -22,25 +22,25 @@ void testReduce( const Mat& src, Mat& sum, Mat& avg, Mat& max, Mat& min, int dim
assert( src.channels() == 1 );
if( dim == 0 ) // row
{
sum.create( 1, src.cols, CV_64FC1 );
sum.create( 1, src.cols, CV_64FC1 );
max.create( 1, src.cols, CV_64FC1 );
min.create( 1, src.cols, CV_64FC1 );
}
else
{
sum.create( src.rows, 1, CV_64FC1 );
sum.create( src.rows, 1, CV_64FC1 );
max.create( src.rows, 1, CV_64FC1 );
min.create( src.rows, 1, CV_64FC1 );
}
sum.setTo(Scalar(0));
max.setTo(Scalar(-DBL_MAX));
min.setTo(Scalar(DBL_MAX));
const Mat_<Type>& src_ = src;
Mat_<double>& sum_ = (Mat_<double>&)sum;
Mat_<double>& min_ = (Mat_<double>&)min;
Mat_<double>& max_ = (Mat_<double>&)max;
if( dim == 0 )
{
for( int ri = 0; ri < src.rows; ri++ )
@@ -128,7 +128,7 @@ int Core_ReduceTest::checkOp( const Mat& src, int dstType, int opType, const Mat
else if ( dstType == CV_32S )
eps = 0.6;
}
assert( opRes.type() == CV_64FC1 );
Mat _dst, dst, diff;
reduce( src, _dst, dim, opType, dstType );
@@ -151,7 +151,7 @@ int Core_ReduceTest::checkOp( const Mat& src, int dstType, int opType, const Mat
getMatTypeStr( src.type(), srcTypeStr );
getMatTypeStr( dstType, dstTypeStr );
const char* dimStr = dim == 0 ? "ROWS" : "COLS";
sprintf( msg, "bad accuracy with srcType = %s, dstType = %s, opType = %s, dim = %s",
srcTypeStr.c_str(), dstTypeStr.c_str(), opTypeStr, dimStr );
ts->printf( cvtest::TS::LOG, msg );
@@ -164,10 +164,10 @@ int Core_ReduceTest::checkCase( int srcType, int dstType, int dim, Size sz )
{
int code = cvtest::TS::OK, tempCode;
Mat src, sum, avg, max, min;
src.create( sz, srcType );
randu( src, Scalar(0), Scalar(100) );
if( srcType == CV_8UC1 )
testReduce<uchar>( src, sum, avg, max, min, dim );
else if( srcType == CV_8SC1 )
@@ -182,110 +182,108 @@ int Core_ReduceTest::checkCase( int srcType, int dstType, int dim, Size sz )
testReduce<float>( src, sum, avg, max, min, dim );
else if( srcType == CV_64FC1 )
testReduce<double>( src, sum, avg, max, min, dim );
else
else
assert( 0 );
// 1. sum
tempCode = checkOp( src, dstType, CV_REDUCE_SUM, sum, dim );
code = tempCode != cvtest::TS::OK ? tempCode : code;
// 2. avg
tempCode = checkOp( src, dstType, CV_REDUCE_AVG, avg, dim );
code = tempCode != cvtest::TS::OK ? tempCode : code;
// 3. max
tempCode = checkOp( src, dstType, CV_REDUCE_MAX, max, dim );
code = tempCode != cvtest::TS::OK ? tempCode : code;
// 4. min
tempCode = checkOp( src, dstType, CV_REDUCE_MIN, min, dim );
code = tempCode != cvtest::TS::OK ? tempCode : code;
return code;
}
int Core_ReduceTest::checkDim( int dim, Size sz )
{
int code = cvtest::TS::OK, tempCode;
// CV_8UC1
tempCode = checkCase( CV_8UC1, CV_8UC1, dim, sz );
code = tempCode != cvtest::TS::OK ? tempCode : code;
tempCode = checkCase( CV_8UC1, CV_32SC1, dim, sz );
code = tempCode != cvtest::TS::OK ? tempCode : code;
tempCode = checkCase( CV_8UC1, CV_32FC1, dim, sz );
code = tempCode != cvtest::TS::OK ? tempCode : code;
tempCode = checkCase( CV_8UC1, CV_64FC1, dim, sz );
code = tempCode != cvtest::TS::OK ? tempCode : code;
// CV_16UC1
tempCode = checkCase( CV_16UC1, CV_32FC1, dim, sz );
code = tempCode != cvtest::TS::OK ? tempCode : code;
tempCode = checkCase( CV_16UC1, CV_64FC1, dim, sz );
code = tempCode != cvtest::TS::OK ? tempCode : code;
// CV_16SC1
tempCode = checkCase( CV_16SC1, CV_32FC1, dim, sz );
code = tempCode != cvtest::TS::OK ? tempCode : code;
tempCode = checkCase( CV_16SC1, CV_64FC1, dim, sz );
code = tempCode != cvtest::TS::OK ? tempCode : code;
// CV_32FC1
tempCode = checkCase( CV_32FC1, CV_32FC1, dim, sz );
code = tempCode != cvtest::TS::OK ? tempCode : code;
tempCode = checkCase( CV_32FC1, CV_64FC1, dim, sz );
code = tempCode != cvtest::TS::OK ? tempCode : code;
// CV_64FC1
tempCode = checkCase( CV_64FC1, CV_64FC1, dim, sz );
code = tempCode != cvtest::TS::OK ? tempCode : code;
return code;
}
int Core_ReduceTest::checkSize( Size sz )
{
int code = cvtest::TS::OK, tempCode;
tempCode = checkDim( 0, sz ); // rows
code = tempCode != cvtest::TS::OK ? tempCode : code;
tempCode = checkDim( 1, sz ); // cols
tempCode = checkDim( 1, sz ); // cols
code = tempCode != cvtest::TS::OK ? tempCode : code;
return code;
}
void Core_ReduceTest::run( int )
{
int code = cvtest::TS::OK, tempCode;
tempCode = checkSize( Size(1,1) );
code = tempCode != cvtest::TS::OK ? tempCode : code;
tempCode = checkSize( Size(1,100) );
code = tempCode != cvtest::TS::OK ? tempCode : code;
tempCode = checkSize( Size(100,1) );
code = tempCode != cvtest::TS::OK ? tempCode : code;
tempCode = checkSize( Size(1000,500) );
code = tempCode != cvtest::TS::OK ? tempCode : code;
ts->set_failed_test_info( code );
}
#define CHECK_C
Size sz(200, 500);
class Core_PCATest : public cvtest::BaseTest
{
public:
@@ -293,41 +291,43 @@ public:
protected:
void run(int)
{
const Size sz(200, 500);
double diffPrjEps, diffBackPrjEps,
prjEps, backPrjEps,
evalEps, evecEps;
int maxComponents = 100;
Mat rPoints(sz, CV_32FC1), rTestPoints(sz, CV_32FC1);
RNG& rng = ts->get_rng();
RNG& rng = ts->get_rng();
rng.fill( rPoints, RNG::UNIFORM, Scalar::all(0.0), Scalar::all(1.0) );
rng.fill( rTestPoints, RNG::UNIFORM, Scalar::all(0.0), Scalar::all(1.0) );
PCA rPCA( rPoints, Mat(), CV_PCA_DATA_AS_ROW, maxComponents ), cPCA;
// 1. check C++ PCA & ROW
Mat rPrjTestPoints = rPCA.project( rTestPoints );
Mat rBackPrjTestPoints = rPCA.backProject( rPrjTestPoints );
Mat avg(1, sz.width, CV_32FC1 );
reduce( rPoints, avg, 0, CV_REDUCE_AVG );
Mat Q = rPoints - repeat( avg, rPoints.rows, 1 ), Qt = Q.t(), eval, evec;
Q = Qt * Q;
Q = Q /(float)rPoints.rows;
eigen( Q, eval, evec );
/*SVD svd(Q);
evec = svd.vt;
eval = svd.w;*/
Mat subEval( maxComponents, 1, eval.type(), eval.data ),
subEvec( maxComponents, evec.cols, evec.type(), evec.data );
#ifdef CHECK_C
Mat prjTestPoints, backPrjTestPoints, cPoints = rPoints.t(), cTestPoints = rTestPoints.t();
CvMat _points, _testPoints, _avg, _eval, _evec, _prjTestPoints, _backPrjTestPoints;
#endif
// check eigen()
double eigenEps = 1e-6;
double err;
@@ -335,7 +335,7 @@ protected:
{
Mat v = evec.row(i).t();
Mat Qv = Q * v;
Mat lv = eval.at<float>(i,0) * v;
err = norm( Qv, lv );
if( err > eigenEps )
@@ -370,7 +370,7 @@ protected:
absdiff(rPCA.eigenvectors, subEvec, tmp);
double mval = 0; Point mloc;
minMaxLoc(tmp, 0, &mval, 0, &mloc);
ts->printf( cvtest::TS::LOG, "pca.eigenvectors is incorrect (CV_PCA_DATA_AS_ROW); err = %f\n", err );
ts->printf( cvtest::TS::LOG, "max diff is %g at (i=%d, j=%d) (%g vs %g)\n",
mval, mloc.y, mloc.x, rPCA.eigenvectors.at<float>(mloc.y, mloc.x),
@@ -380,7 +380,7 @@ protected:
}
}
}
prjEps = 1.265, backPrjEps = 1.265;
for( int i = 0; i < rTestPoints.rows; i++ )
{
@@ -404,7 +404,7 @@ protected:
return;
}
}
// 2. check C++ PCA & COL
cPCA( rPoints.t(), Mat(), CV_PCA_DATA_AS_COL, maxComponents );
diffPrjEps = 1, diffBackPrjEps = 1;
@@ -423,7 +423,7 @@ protected:
ts->set_failed_test_info( cvtest::TS::FAIL_BAD_ACCURACY );
return;
}
#ifdef CHECK_C
// 3. check C PCA & ROW
_points = rPoints;
@@ -435,11 +435,11 @@ protected:
backPrjTestPoints.create(rPoints.size(), rPoints.type() );
_prjTestPoints = prjTestPoints;
_backPrjTestPoints = backPrjTestPoints;
cvCalcPCA( &_points, &_avg, &_eval, &_evec, CV_PCA_DATA_AS_ROW );
cvProjectPCA( &_testPoints, &_avg, &_evec, &_prjTestPoints );
cvBackProjectPCA( &_prjTestPoints, &_avg, &_evec, &_backPrjTestPoints );
err = norm(prjTestPoints, rPrjTestPoints, CV_RELATIVE_L2);
if( err > diffPrjEps )
{
@@ -454,7 +454,7 @@ protected:
ts->set_failed_test_info( cvtest::TS::FAIL_BAD_ACCURACY );
return;
}
// 3. check C PCA & COL
_points = cPoints;
_testPoints = cTestPoints;
@@ -463,11 +463,11 @@ protected:
evec = evec.t(); _evec = evec;
prjTestPoints = prjTestPoints.t(); _prjTestPoints = prjTestPoints;
backPrjTestPoints = backPrjTestPoints.t(); _backPrjTestPoints = backPrjTestPoints;
cvCalcPCA( &_points, &_avg, &_eval, &_evec, CV_PCA_DATA_AS_COL );
cvProjectPCA( &_testPoints, &_avg, &_evec, &_prjTestPoints );
cvBackProjectPCA( &_prjTestPoints, &_avg, &_evec, &_backPrjTestPoints );
err = norm(cv::abs(prjTestPoints), cv::abs(rPrjTestPoints.t()), CV_RELATIVE_L2 );
if( err > diffPrjEps )
{
@@ -490,9 +490,9 @@ class Core_ArrayOpTest : public cvtest::BaseTest
{
public:
Core_ArrayOpTest();
~Core_ArrayOpTest();
~Core_ArrayOpTest();
protected:
void run(int);
void run(int);
};
@@ -536,7 +536,7 @@ static double getValue(SparseMat& M, const int* idx, RNG& rng)
d == 3 ? M.hash(idx[0], idx[1], idx[2]) : M.hash(idx);
phv = &hv;
}
const uchar* ptr = d == 2 ? M.ptr(idx[0], idx[1], false, phv) :
d == 3 ? M.ptr(idx[0], idx[1], idx[2], false, phv) :
M.ptr(idx, false, phv);
@@ -560,7 +560,7 @@ static void eraseValue(SparseMat& M, const int* idx, RNG& rng)
d == 3 ? M.hash(idx[0], idx[1], idx[2]) : M.hash(idx);
phv = &hv;
}
if( d == 2 )
M.erase(idx[0], idx[1], phv);
else if( d == 3 )
@@ -584,7 +584,7 @@ static void setValue(SparseMat& M, const int* idx, double value, RNG& rng)
d == 3 ? M.hash(idx[0], idx[1], idx[2]) : M.hash(idx);
phv = &hv;
}
uchar* ptr = d == 2 ? M.ptr(idx[0], idx[1], true, phv) :
d == 3 ? M.ptr(idx[0], idx[1], idx[2], true, phv) :
M.ptr(idx, true, phv);
@@ -599,7 +599,7 @@ static void setValue(SparseMat& M, const int* idx, double value, RNG& rng)
void Core_ArrayOpTest::run( int /* start_from */)
{
int errcount = 0;
// dense matrix operations
{
int sz3[] = {5, 10, 15};
@@ -608,7 +608,7 @@ void Core_ArrayOpTest::run( int /* start_from */)
RNG rng;
rng.fill(A, CV_RAND_UNI, Scalar::all(-10), Scalar::all(10));
rng.fill(B, CV_RAND_UNI, Scalar::all(-10), Scalar::all(10));
int idx0[] = {3,4,5}, idx1[] = {0, 9, 7};
float val0 = 130;
Scalar val1(-1000, 30, 3, 8);
@@ -617,12 +617,12 @@ void Core_ArrayOpTest::run( int /* start_from */)
cvSetND(&matB, idx0, val1);
cvSet3D(&matB, idx1[0], idx1[1], idx1[2], -val1);
Ptr<CvMatND> matC = cvCloneMatND(&matB);
if( A.at<float>(idx0[0], idx0[1], idx0[2]) != val0 ||
A.at<float>(idx1[0], idx1[1], idx1[2]) != -val0 ||
cvGetReal3D(&matA, idx0[0], idx0[1], idx0[2]) != val0 ||
cvGetRealND(&matA, idx1) != -val0 ||
Scalar(B.at<Vec4s>(idx0[0], idx0[1], idx0[2])) != val1 ||
Scalar(B.at<Vec4s>(idx1[0], idx1[1], idx1[2])) != -val1 ||
Scalar(cvGet3D(matC, idx0[0], idx0[1], idx0[2])) != val1 ||
@@ -633,7 +633,7 @@ void Core_ArrayOpTest::run( int /* start_from */)
errcount++;
}
}
RNG rng;
const int MAX_DIM = 5, MAX_DIM_SZ = 10;
// sparse matrix operations
@@ -647,7 +647,7 @@ void Core_ArrayOpTest::run( int /* start_from */)
vector<double> all_vals2;
string sidx, min_sidx, max_sidx;
double min_val=0, max_val=0;
int p = 1;
for( k = 0; k < dims; k++ )
{
@@ -656,7 +656,7 @@ void Core_ArrayOpTest::run( int /* start_from */)
}
SparseMat M( dims, size, depth );
map<string, double> M0;
int nz0 = (unsigned)rng % max(p/5,10);
nz0 = min(max(nz0, 1), p);
all_vals.resize(nz0);
@@ -676,12 +676,12 @@ void Core_ArrayOpTest::run( int /* start_from */)
_all_vals2.convertTo(_all_vals2_f, CV_32F);
_all_vals2_f.convertTo(_all_vals2, CV_64F);
}
minMaxLoc(_all_vals, &min_val, &max_val);
double _norm0 = norm(_all_vals, CV_C);
double _norm1 = norm(_all_vals, CV_L1);
double _norm2 = norm(_all_vals, CV_L2);
for( i = 0; i < nz0; i++ )
{
for(;;)
@@ -708,18 +708,18 @@ void Core_ArrayOpTest::run( int /* start_from */)
break;
}
}
Ptr<CvSparseMat> M2 = (CvSparseMat*)M;
MatND Md;
M.copyTo(Md);
SparseMat M3; SparseMat(Md).convertTo(M3, Md.type(), 2);
int nz1 = (int)M.nzcount(), nz2 = (int)M3.nzcount();
double norm0 = norm(M, CV_C);
double norm1 = norm(M, CV_L1);
double norm2 = norm(M, CV_L2);
double eps = depth == CV_32F ? FLT_EPSILON*100 : DBL_EPSILON*1000;
if( nz1 != nz0 || nz2 != nz0)
{
errcount++;
@@ -727,7 +727,7 @@ void Core_ArrayOpTest::run( int /* start_from */)
si, nz1, nz2, nz0 );
break;
}
if( fabs(norm0 - _norm0) > fabs(_norm0)*eps ||
fabs(norm1 - _norm1) > fabs(_norm1)*eps ||
fabs(norm2 - _norm2) > fabs(_norm2)*eps )
@@ -737,10 +737,10 @@ void Core_ArrayOpTest::run( int /* start_from */)
si, norm0, norm1, norm2, _norm0, _norm1, _norm2 );
break;
}
int n = (unsigned)rng % max(p/5,10);
n = min(max(n, 1), p) + nz0;
for( i = 0; i < n; i++ )
{
double val1, val2, val3, val0;
@@ -760,7 +760,7 @@ void Core_ArrayOpTest::run( int /* start_from */)
val1 = getValue(M, idx, rng);
val2 = getValue(M2, idx);
val3 = getValue(M3, idx, rng);
if( val1 != val0 || val2 != val0 || fabs(val3 - val0*2) > fabs(val0*2)*FLT_EPSILON )
{
errcount++;
@@ -768,7 +768,7 @@ void Core_ArrayOpTest::run( int /* start_from */)
break;
}
}
for( i = 0; i < n; i++ )
{
double val1, val2;
@@ -792,9 +792,9 @@ void Core_ArrayOpTest::run( int /* start_from */)
errcount++;
ts->printf(cvtest::TS::LOG, "SparseMat: after deleting M[%s], it is =%g/%g (while it should be 0)\n", sidx.c_str(), val1, val2 );
break;
}
}
}
int nz = (int)M.nzcount();
if( nz != 0 )
{
@@ -802,7 +802,7 @@ void Core_ArrayOpTest::run( int /* start_from */)
ts->printf(cvtest::TS::LOG, "The number of non-zero elements after removing all the elements = %d (while it should be 0)\n", nz );
break;
}
int idx1[MAX_DIM], idx2[MAX_DIM];
double val1 = 0, val2 = 0;
M3 = SparseMat(Md);
@@ -816,7 +816,7 @@ void Core_ArrayOpTest::run( int /* start_from */)
min_val, max_val, min_sidx.c_str(), max_sidx.c_str());
break;
}
minMaxIdx(Md, &val1, &val2, idx1, idx2);
s1 = idx2string(idx1, dims), s2 = idx2string(idx2, dims);
if( (min_val < 0 && (val1 != min_val || s1 != min_sidx)) ||
@@ -829,7 +829,7 @@ void Core_ArrayOpTest::run( int /* start_from */)
break;
}
}
ts->set_failed_test_info(errcount == 0 ? cvtest::TS::OK : cvtest::TS::FAIL_INVALID_OUTPUT);
}
+36 -36
View File
@@ -27,7 +27,7 @@ static double chi2_p95(int n)
36.42f, 37.65f, 38.89f, 40.11f, 41.34f, 42.56f, 43.77f };
static const double xp = 1.64;
CV_Assert(n >= 1);
if( n <= 30 )
return chi2_tab95[n-1];
return n + sqrt((double)2*n)*xp + 0.6666666666666*(xp*xp - 1);
@@ -40,12 +40,12 @@ bool Core_RandTest::check_pdf(const Mat& hist, double scale,
const int* H = (const int*)hist.data;
float* H0 = ((float*)hist0.data);
int i, hsz = hist.cols;
double sum = 0;
for( i = 0; i < hsz; i++ )
sum += H[i];
CV_Assert( fabs(1./sum - scale) < FLT_EPSILON );
if( dist_type == CV_RAND_UNI )
{
float scale0 = (float)(1./hsz);
@@ -54,19 +54,19 @@ bool Core_RandTest::check_pdf(const Mat& hist, double scale,
}
else
{
double sum = 0, r = (hsz-1.)/2;
double sum2 = 0, r = (hsz-1.)/2;
double alpha = 2*sqrt(2.)/r, beta = -alpha*r;
for( i = 0; i < hsz; i++ )
{
double x = i*alpha + beta;
H0[i] = (float)exp(-x*x);
sum += H0[i];
sum2 += H0[i];
}
sum = 1./sum;
sum2 = 1./sum2;
for( i = 0; i < hsz; i++ )
H0[i] = (float)(H0[i]*sum);
H0[i] = (float)(H0[i]*sum2);
}
double chi2 = 0;
for( i = 0; i < hsz; i++ )
{
@@ -76,7 +76,7 @@ bool Core_RandTest::check_pdf(const Mat& hist, double scale,
chi2 += (a - b)*(a - b)/(a + b);
}
realval = chi2;
double chi2_pval = chi2_p95(hsz - 1 - (dist_type == CV_RAND_NORMAL ? 2 : 0));
refval = chi2_pval*0.01;
return realval <= refval;
@@ -87,22 +87,22 @@ void Core_RandTest::run( int )
static int _ranges[][2] =
{{ 0, 256 }, { -128, 128 }, { 0, 65536 }, { -32768, 32768 },
{ -1000000, 1000000 }, { -1000, 1000 }, { -1000, 1000 }};
const int MAX_SDIM = 10;
const int N = 2000000;
const int maxSlice = 1000;
const int MAX_HIST_SIZE = 1000;
int progress = 0;
RNG& rng = ts->get_rng();
RNG tested_rng = theRNG();
test_case_count = 200;
for( int idx = 0; idx < test_case_count; idx++ )
{
progress = update_progress( progress, idx, test_case_count, 0 );
ts->update_context( this, idx, false );
int depth = cvtest::randInt(rng) % (CV_64F+1);
int c, cn = (cvtest::randInt(rng) % 4) + 1;
int type = CV_MAKETYPE(depth, cn);
@@ -113,15 +113,15 @@ void Core_RandTest::run( int )
double eps = 1.e-4;
if (depth == CV_64F)
eps = 1.e-7;
bool do_sphere_test = dist_type == CV_RAND_UNI;
Mat arr[2], hist[4];
int W[] = {0,0,0,0};
arr[0].create(1, SZ, type);
arr[1].create(1, SZ, type);
bool fast_algo = dist_type == CV_RAND_UNI && depth < CV_32F;
for( c = 0; c < cn; c++ )
{
int a, b, hsz;
@@ -137,7 +137,7 @@ void Core_RandTest::run( int )
while( abs(a-b) <= 1 );
if( a > b )
std::swap(a, b);
unsigned r = (unsigned)(b - a);
fast_algo = fast_algo && r <= 256 && (r & (r-1)) == 0;
hsz = min((unsigned)(b - a), (unsigned)MAX_HIST_SIZE);
@@ -149,7 +149,7 @@ void Core_RandTest::run( int )
int meanrange = vrange/16;
int mindiv = MAX(vrange/20, 5);
int maxdiv = MIN(vrange/8, 10000);
a = cvtest::randInt(rng) % meanrange - meanrange/2 +
(_ranges[depth][0] + _ranges[depth][1])/2;
b = cvtest::randInt(rng) % (maxdiv - mindiv) + mindiv;
@@ -157,9 +157,9 @@ void Core_RandTest::run( int )
}
A[c] = a;
B[c] = b;
hist[c].create(1, hsz, CV_32S);
hist[c].create(1, hsz, CV_32S);
}
cv::RNG saved_rng = tested_rng;
int maxk = fast_algo ? 0 : 1;
for( k = 0; k <= maxk; k++ )
@@ -173,14 +173,14 @@ void Core_RandTest::run( int )
tested_rng.fill(aslice, dist_type, A, B);
}
}
if( maxk >= 1 && norm(arr[0], arr[1], NORM_INF) > eps)
{
ts->printf( cvtest::TS::LOG, "RNG output depends on the array lengths (some generated numbers get lost?)" );
ts->set_failed_test_info( cvtest::TS::FAIL_INVALID_OUTPUT );
return;
}
for( c = 0; c < cn; c++ )
{
const uchar* data = arr[0].data;
@@ -190,9 +190,9 @@ void Core_RandTest::run( int )
double maxVal = dist_type == CV_RAND_UNI ? B[c] : A[c] + B[c]*4;
double scale = HSZ/(maxVal - minVal);
double delta = -minVal*scale;
hist[c] = Scalar::all(0);
for( i = c; i < SZ*cn; i += cn )
{
double val = depth == CV_8U ? ((const uchar*)data)[i] :
@@ -221,7 +221,7 @@ void Core_RandTest::run( int )
}
}
}
if( dist_type == CV_RAND_UNI && W[c] != SZ )
{
ts->printf( cvtest::TS::LOG, "Uniform RNG gave values out of the range [%g,%g) on channel %d/%d\n",
@@ -237,7 +237,7 @@ void Core_RandTest::run( int )
return;
}
double refval = 0, realval = 0;
if( !check_pdf(hist[c], 1./W[c], dist_type, refval, realval) )
{
ts->printf( cvtest::TS::LOG, "RNG failed Chi-square test "
@@ -247,13 +247,13 @@ void Core_RandTest::run( int )
return;
}
}
// Monte-Carlo test. Compute volume of SDIM-dimensional sphere
// inscribed in [-1,1]^SDIM cube.
if( do_sphere_test )
{
int SDIM = cvtest::randInt(rng) % (MAX_SDIM-1) + 2;
int N0 = (SZ*cn/SDIM), N = 0;
int N0 = (SZ*cn/SDIM), n = 0;
double r2 = 0;
const uchar* data = arr[0].data;
double scale[4], delta[4];
@@ -262,7 +262,7 @@ void Core_RandTest::run( int )
scale[c] = 2./(B[c] - A[c]);
delta[c] = -A[c]*scale[c] - 1;
}
for( i = k = c = 0; i <= SZ*cn - SDIM; i++, k++, c++ )
{
double val = depth == CV_8U ? ((const uchar*)data)[i] :
@@ -276,20 +276,20 @@ void Core_RandTest::run( int )
r2 += val*val;
if( k == SDIM-1 )
{
N += r2 <= 1;
n += r2 <= 1;
r2 = 0;
k = -1;
}
}
double V = ((double)N/N0)*(1 << SDIM);
double V = ((double)n/N0)*(1 << SDIM);
// the theoretically computed volume
int sdim = SDIM % 2;
double V0 = sdim + 1;
for( sdim += 2; sdim <= SDIM; sdim += 2 )
V0 *= 2*CV_PI/sdim;
if( fabs(V - V0) > 0.3*fabs(V0) )
{
ts->printf( cvtest::TS::LOG, "RNG failed %d-dim sphere volume test (got %g instead of %g)\n",
@@ -309,7 +309,7 @@ class Core_RandRangeTest : public cvtest::BaseTest
{
public:
Core_RandRangeTest() {}
~Core_RandRangeTest() {}
~Core_RandRangeTest() {}
protected:
void run(int)
{
@@ -319,7 +319,7 @@ protected:
theRNG().fill(af, RNG::UNIFORM, -DBL_MAX, DBL_MAX);
int n0 = 0, n255 = 0, nx = 0;
int nfmin = 0, nfmax = 0, nfx = 0;
for( int i = 0; i < a.rows; i++ )
for( int j = 0; j < a.cols; j++ )
{