mirror of
https://github.com/opencv/opencv.git
synced 2024-11-24 03:00:14 +08:00
Move cv::Mat out of core.hpp
This commit is contained in:
parent
135c0b6cb5
commit
715fa3303e
@ -189,13 +189,13 @@ void CV_POSITTest::run( int start_from )
|
||||
rotation->data.fl, translation->data.fl );
|
||||
cvReleasePOSITObject( &object );
|
||||
|
||||
//Mat _rotation = cvarrToMat(rotation), _true_rotation = cvarrToMat(true_rotation);
|
||||
//Mat _translation = cvarrToMat(translation), _true_translation = cvarrToMat(true_translation);
|
||||
code = cvtest::cmpEps2( ts, rotation, true_rotation, flEpsilon, false, "rotation matrix" );
|
||||
Mat _rotation = cvarrToMat(rotation), _true_rotation = cvarrToMat(true_rotation);
|
||||
Mat _translation = cvarrToMat(translation), _true_translation = cvarrToMat(true_translation);
|
||||
code = cvtest::cmpEps2( ts, _rotation, _true_rotation, flEpsilon, false, "rotation matrix" );
|
||||
if( code < 0 )
|
||||
break;
|
||||
|
||||
code = cvtest::cmpEps2( ts, translation, true_translation, flEpsilon, false, "translation vector" );
|
||||
code = cvtest::cmpEps2( ts, _translation, _true_translation, flEpsilon, false, "translation vector" );
|
||||
if( code < 0 )
|
||||
break;
|
||||
}
|
||||
|
@ -855,8 +855,8 @@ void CV_InitUndistortRectifyMapTest::prepare_to_validation(int/* test_case_idx*/
|
||||
//Applying precalculated undistort rectify map
|
||||
if (!useCPlus)
|
||||
{
|
||||
mapx = cv::Mat(_mapx);
|
||||
mapy = cv::Mat(_mapy);
|
||||
mapx = cv::cvarrToMat(_mapx);
|
||||
mapy = cv::cvarrToMat(_mapy);
|
||||
}
|
||||
cv::Mat map1,map2;
|
||||
cv::convertMaps(mapx,mapy,map1,map2,CV_32FC1);
|
||||
|
@ -243,27 +243,27 @@ void CV_UndistortPointsBadArgTest::run(int)
|
||||
//C++ tests
|
||||
useCPlus = true;
|
||||
|
||||
camera_mat = cv::Mat(&_camera_mat_orig);
|
||||
distortion_coeffs = cv::Mat(&_distortion_coeffs_orig);
|
||||
P = cv::Mat(&_P_orig);
|
||||
R = cv::Mat(&_R_orig);
|
||||
src_points = cv::Mat(&_src_points_orig);
|
||||
camera_mat = cv::cvarrToMat(&_camera_mat_orig);
|
||||
distortion_coeffs = cv::cvarrToMat(&_distortion_coeffs_orig);
|
||||
P = cv::cvarrToMat(&_P_orig);
|
||||
R = cv::cvarrToMat(&_R_orig);
|
||||
src_points = cv::cvarrToMat(&_src_points_orig);
|
||||
|
||||
temp = cvCreateMat(2,2,CV_32FC2);
|
||||
src_points = cv::Mat(temp);
|
||||
src_points = cv::cvarrToMat(temp);
|
||||
errcount += run_test_case( CV_StsAssert, "Invalid input data matrix size" );
|
||||
src_points = cv::Mat(&_src_points_orig);
|
||||
src_points = cv::cvarrToMat(&_src_points_orig);
|
||||
cvReleaseMat(&temp);
|
||||
|
||||
temp = cvCreateMat(1,4,CV_64FC2);
|
||||
src_points = cv::Mat(temp);
|
||||
src_points = cv::cvarrToMat(temp);
|
||||
errcount += run_test_case( CV_StsAssert, "Invalid input data matrix type" );
|
||||
src_points = cv::Mat(&_src_points_orig);
|
||||
src_points = cv::cvarrToMat(&_src_points_orig);
|
||||
cvReleaseMat(&temp);
|
||||
|
||||
src_points = cv::Mat();
|
||||
errcount += run_test_case( CV_StsAssert, "Input data matrix is not continuous" );
|
||||
src_points = cv::Mat(&_src_points_orig);
|
||||
src_points = cv::cvarrToMat(&_src_points_orig);
|
||||
cvReleaseMat(&temp);
|
||||
|
||||
|
||||
@ -360,12 +360,12 @@ void CV_InitUndistortRectifyMapBadArgTest::run(int)
|
||||
//C++ tests
|
||||
useCPlus = true;
|
||||
|
||||
camera_mat = cv::Mat(&_camera_mat_orig);
|
||||
distortion_coeffs = cv::Mat(&_distortion_coeffs_orig);
|
||||
new_camera_mat = cv::Mat(&_new_camera_mat_orig);
|
||||
R = cv::Mat(&_R_orig);
|
||||
mapx = cv::Mat(&_mapx_orig);
|
||||
mapy = cv::Mat(&_mapy_orig);
|
||||
camera_mat = cv::cvarrToMat(&_camera_mat_orig);
|
||||
distortion_coeffs = cv::cvarrToMat(&_distortion_coeffs_orig);
|
||||
new_camera_mat = cv::cvarrToMat(&_new_camera_mat_orig);
|
||||
R = cv::cvarrToMat(&_R_orig);
|
||||
mapx = cv::cvarrToMat(&_mapx_orig);
|
||||
mapy = cv::cvarrToMat(&_mapy_orig);
|
||||
|
||||
|
||||
mat_type = CV_64F;
|
||||
@ -373,21 +373,21 @@ void CV_InitUndistortRectifyMapBadArgTest::run(int)
|
||||
mat_type = mat_type_orig;
|
||||
|
||||
temp = cvCreateMat(3,2,CV_32FC1);
|
||||
camera_mat = cv::Mat(temp);
|
||||
camera_mat = cv::cvarrToMat(temp);
|
||||
errcount += run_test_case( CV_StsAssert, "Invalid camera data matrix size" );
|
||||
camera_mat = cv::Mat(&_camera_mat_orig);
|
||||
camera_mat = cv::cvarrToMat(&_camera_mat_orig);
|
||||
cvReleaseMat(&temp);
|
||||
|
||||
temp = cvCreateMat(4,3,CV_32FC1);
|
||||
R = cv::Mat(temp);
|
||||
R = cv::cvarrToMat(temp);
|
||||
errcount += run_test_case( CV_StsAssert, "Invalid R data matrix size" );
|
||||
R = cv::Mat(&_R_orig);
|
||||
R = cv::cvarrToMat(&_R_orig);
|
||||
cvReleaseMat(&temp);
|
||||
|
||||
temp = cvCreateMat(6,1,CV_32FC1);
|
||||
distortion_coeffs = cv::Mat(temp);
|
||||
distortion_coeffs = cv::cvarrToMat(temp);
|
||||
errcount += run_test_case( CV_StsAssert, "Invalid distortion coefficients data matrix size" );
|
||||
distortion_coeffs = cv::Mat(&_distortion_coeffs_orig);
|
||||
distortion_coeffs = cv::cvarrToMat(&_distortion_coeffs_orig);
|
||||
cvReleaseMat(&temp);
|
||||
|
||||
//------------
|
||||
@ -499,11 +499,11 @@ void CV_UndistortBadArgTest::run(int)
|
||||
//C++ tests
|
||||
useCPlus = true;
|
||||
|
||||
camera_mat = cv::Mat(&_camera_mat_orig);
|
||||
distortion_coeffs = cv::Mat(&_distortion_coeffs_orig);
|
||||
new_camera_mat = cv::Mat(&_new_camera_mat_orig);
|
||||
src = cv::Mat(&_src_orig);
|
||||
dst = cv::Mat(&_dst_orig);
|
||||
camera_mat = cv::cvarrToMat(&_camera_mat_orig);
|
||||
distortion_coeffs = cv::cvarrToMat(&_distortion_coeffs_orig);
|
||||
new_camera_mat = cv::cvarrToMat(&_new_camera_mat_orig);
|
||||
src = cv::cvarrToMat(&_src_orig);
|
||||
dst = cv::cvarrToMat(&_dst_orig);
|
||||
|
||||
//------------
|
||||
delete[] arr_src;
|
||||
|
@ -359,7 +359,7 @@ void LevMarqSparse::ask_for_proj(CvMat &/*_vis*/,bool once) {
|
||||
cvGetSubRect( P, &cam_mat, cvRect( 0, j * num_cam_param, 1, num_cam_param ));
|
||||
CvMat measur_mat;
|
||||
cvGetSubRect( hX, &measur_mat, cvRect( 0, ind * num_err_param, 1, num_err_param ));
|
||||
Mat _point_mat(&point_mat), _cam_mat(&cam_mat), _measur_mat(&measur_mat);
|
||||
Mat _point_mat = cv::cvarrToMat(&point_mat), _cam_mat = cv::cvarrToMat(&cam_mat), _measur_mat = cv::cvarrToMat(&measur_mat);
|
||||
func( i, j, _point_mat, _cam_mat, _measur_mat, data);
|
||||
assert( ind*num_err_param == ((int*)(Vis_index->data.ptr + i * Vis_index->step))[j]);
|
||||
ind+=1;
|
||||
@ -398,7 +398,7 @@ void LevMarqSparse::ask_for_projac(CvMat &/*_vis*/) //should be evaluated at p
|
||||
|
||||
//CvMat* Bij = B_line[j];
|
||||
//CvMat* Bij = ((CvMat**)(B->data.ptr + B->step * i))[j];
|
||||
Mat _point_mat(&point_mat), _cam_mat(&cam_mat), _Aij(Aij), _Bij(Bij);
|
||||
Mat _point_mat = cv::cvarrToMat(&point_mat), _cam_mat = cv::cvarrToMat(&cam_mat), _Aij = cv::cvarrToMat(Aij), _Bij = cv::cvarrToMat(Bij);
|
||||
(*fjac)(i, j, _point_mat, _cam_mat, _Aij, _Bij, data);
|
||||
}
|
||||
}
|
||||
@ -1100,16 +1100,17 @@ void LevMarqSparse::bundleAdjust( std::vector<Point3d>& points, //positions of p
|
||||
}
|
||||
//fill camera params
|
||||
//R.clear();T.clear();cameraMatrix.clear();
|
||||
Mat levmarP = cv::cvarrToMat(levmar.P);
|
||||
for( int i = 0; i < num_cameras; i++ ) {
|
||||
//rotation
|
||||
Mat rot_vec = Mat(levmar.P).rowRange(i*num_cam_param, i*num_cam_param+3);
|
||||
Mat rot_vec = levmarP.rowRange(i*num_cam_param, i*num_cam_param+3);
|
||||
Rodrigues( rot_vec, R[i] );
|
||||
//translation
|
||||
T[i] = Mat(levmar.P).rowRange(i*num_cam_param + 3, i*num_cam_param+6);
|
||||
T[i] = levmarP.rowRange(i*num_cam_param + 3, i*num_cam_param+6);
|
||||
|
||||
//intrinsic camera matrix
|
||||
double* intr_data = (double*)cameraMatrix[i].data;
|
||||
double* intr = (double*)(Mat(levmar.P).data + Mat(levmar.P).step * (i*num_cam_param+6));
|
||||
double* intr = (double*)(levmarP.data +levmarP.step * (i*num_cam_param+6));
|
||||
//focals
|
||||
intr_data[0] = intr[0]; //fx
|
||||
intr_data[4] = intr[1]; //fy
|
||||
@ -1119,7 +1120,7 @@ void LevMarqSparse::bundleAdjust( std::vector<Point3d>& points, //positions of p
|
||||
|
||||
//add distortion if exists
|
||||
if( distCoeffs.size() ) {
|
||||
Mat(levmar.P).rowRange(i*num_cam_param + 10, i*num_cam_param+10+numdist).copyTo(distCoeffs[i]);
|
||||
levmarP.rowRange(i*num_cam_param + 10, i*num_cam_param+10+numdist).copyTo(distCoeffs[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -441,9 +441,18 @@ class CV_EXPORTS Mat;
|
||||
class CV_EXPORTS SparseMat;
|
||||
typedef Mat MatND;
|
||||
|
||||
class CV_EXPORTS MatExpr;
|
||||
|
||||
template<typename _Tp> class CV_EXPORTS Mat_;
|
||||
template<typename _Tp> class CV_EXPORTS SparseMat_;
|
||||
|
||||
class CV_EXPORTS MatConstIterator;
|
||||
class CV_EXPORTS SparseMatIterator;
|
||||
class CV_EXPORTS SparseMatConstIterator;
|
||||
template<typename _Tp> class CV_EXPORTS MatIterator_;
|
||||
template<typename _Tp> class CV_EXPORTS MatConstIterator_;
|
||||
template<typename _Tp> class CV_EXPORTS SparseMatIterator_;
|
||||
template<typename _Tp> class CV_EXPORTS SparseMatConstIterator_;
|
||||
|
||||
namespace ogl
|
||||
{
|
||||
|
1428
modules/core/include/opencv2/core/mat.hpp
Normal file
1428
modules/core/include/opencv2/core/mat.hpp
Normal file
File diff suppressed because it is too large
Load Diff
@ -383,15 +383,6 @@ inline Mat Mat::operator()(const Range* ranges) const
|
||||
return Mat(*this, ranges);
|
||||
}
|
||||
|
||||
inline Mat::operator CvMat() const
|
||||
{
|
||||
CV_DbgAssert(dims <= 2);
|
||||
CvMat m = cvMat(rows, dims == 1 ? 1 : cols, type(), data);
|
||||
m.step = (int)step[0];
|
||||
m.type = (m.type & ~CONTINUOUS_FLAG) | (flags & CONTINUOUS_FLAG);
|
||||
return m;
|
||||
}
|
||||
|
||||
inline bool Mat::isContinuous() const { return (flags & CONTINUOUS_FLAG) != 0; }
|
||||
inline bool Mat::isSubmatrix() const { return (flags & SUBMATRIX_FLAG) != 0; }
|
||||
inline size_t Mat::elemSize() const { return dims > 0 ? step.p[dims-1] : 0; }
|
||||
@ -2411,11 +2402,11 @@ template<typename _Tp> inline SparseMat_<_Tp>::SparseMat_(const Mat& m)
|
||||
*this = sm;
|
||||
}
|
||||
|
||||
template<typename _Tp> inline SparseMat_<_Tp>::SparseMat_(const CvSparseMat* m)
|
||||
{
|
||||
SparseMat sm(m);
|
||||
*this = sm;
|
||||
}
|
||||
// template<typename _Tp> inline SparseMat_<_Tp>::SparseMat_(const CvSparseMat* m)
|
||||
// {
|
||||
// SparseMat sm(m);
|
||||
// *this = sm;
|
||||
// }
|
||||
|
||||
template<typename _Tp> inline SparseMat_<_Tp>&
|
||||
SparseMat_<_Tp>::operator = (const SparseMat_<_Tp>& m)
|
||||
@ -2457,11 +2448,11 @@ SparseMat_<_Tp>::create(int _dims, const int* _sizes)
|
||||
SparseMat::create(_dims, _sizes, DataType<_Tp>::type);
|
||||
}
|
||||
|
||||
template<typename _Tp> inline
|
||||
SparseMat_<_Tp>::operator CvSparseMat*() const
|
||||
{
|
||||
return SparseMat::operator CvSparseMat*();
|
||||
}
|
||||
// template<typename _Tp> inline
|
||||
// SparseMat_<_Tp>::operator CvSparseMat*() const
|
||||
// {
|
||||
// return SparseMat::operator CvSparseMat*();
|
||||
// }
|
||||
|
||||
template<typename _Tp> inline int SparseMat_<_Tp>::type() const
|
||||
{ return DataType<_Tp>::type; }
|
||||
|
@ -94,6 +94,7 @@
|
||||
|
||||
#ifdef __cplusplus
|
||||
# include "opencv2/core/types.hpp"
|
||||
# include "opencv2/core/mat.hpp"
|
||||
#endif
|
||||
|
||||
/* CvArr* is used to pass arbitrary
|
||||
@ -307,6 +308,11 @@ typedef struct _IplImage
|
||||
char *imageDataOrigin; /* Pointer to very origin of image data
|
||||
(not necessarily aligned) -
|
||||
needed for correct deallocation */
|
||||
|
||||
#ifdef __cplusplus
|
||||
_IplImage() {}
|
||||
_IplImage(const cv::Mat& m);
|
||||
#endif
|
||||
}
|
||||
IplImage;
|
||||
|
||||
@ -417,6 +423,12 @@ typedef struct CvMat
|
||||
int cols;
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
CvMat() {}
|
||||
CvMat(const cv::Mat& m);
|
||||
#endif
|
||||
|
||||
}
|
||||
CvMat;
|
||||
|
||||
@ -478,6 +490,16 @@ CV_INLINE CvMat cvMat( int rows, int cols, int type, void* data CV_DEFAULT(NULL)
|
||||
return m;
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
inline CvMat::CvMat(const cv::Mat& m)
|
||||
{
|
||||
CV_DbgAssert(m.dims <= 2);
|
||||
*this = cvMat(m.rows, m.dims == 1 ? 1 : m.cols, m.type(), m.data);
|
||||
step = (int)m.step[0];
|
||||
type = (type & ~cv::Mat::CONTINUOUS_FLAG) | (m.flags & cv::Mat::CONTINUOUS_FLAG);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#define CV_MAT_ELEM_PTR_FAST( mat, row, col, pix_size ) \
|
||||
(assert( (unsigned)(row) < (unsigned)(mat).rows && \
|
||||
@ -567,6 +589,11 @@ typedef struct CvMatND
|
||||
int step;
|
||||
}
|
||||
dim[CV_MAX_DIM];
|
||||
|
||||
#ifdef __cplusplus
|
||||
CvMatND() {}
|
||||
CvMatND(const cv::Mat& m);
|
||||
#endif
|
||||
}
|
||||
CvMatND;
|
||||
|
||||
@ -586,7 +613,7 @@ CvMatND;
|
||||
|
||||
struct CvSet;
|
||||
|
||||
typedef struct CvSparseMat
|
||||
typedef struct CV_EXPORTS CvSparseMat
|
||||
{
|
||||
int type;
|
||||
int dims;
|
||||
@ -599,9 +626,17 @@ typedef struct CvSparseMat
|
||||
int valoffset;
|
||||
int idxoffset;
|
||||
int size[CV_MAX_DIM];
|
||||
|
||||
#ifdef __cplusplus
|
||||
void copyToSparseMat(cv::SparseMat& m) const;
|
||||
#endif
|
||||
}
|
||||
CvSparseMat;
|
||||
|
||||
#ifdef __cplusplus
|
||||
CvSparseMat* cvCreateSparseMat(const cv::SparseMat& m);
|
||||
#endif
|
||||
|
||||
#define CV_IS_SPARSE_MAT_HDR(mat) \
|
||||
((mat) != NULL && \
|
||||
(((const CvSparseMat*)(mat))->type & CV_MAGIC_MASK) == CV_SPARSE_MAT_MAGIC_VAL)
|
||||
|
@ -305,7 +305,8 @@ cvCloneMatND( const CvMatND* src )
|
||||
if( src->data.ptr )
|
||||
{
|
||||
cvCreateData( dst );
|
||||
cv::Mat _src(src), _dst(dst);
|
||||
cv::Mat _src = cv::cvarrToMat(src);
|
||||
cv::Mat _dst = cv::cvarrToMat(dst);
|
||||
uchar* data0 = dst->data.ptr;
|
||||
_src.copyTo(_dst);
|
||||
CV_Assert(_dst.data == data0);
|
||||
|
@ -544,7 +544,7 @@ cv::gpu::GpuMat::GpuMat(const GpuMat& m)
|
||||
}
|
||||
|
||||
cv::gpu::GpuMat::GpuMat(int rows_, int cols_, int type_, void* data_, size_t step_) :
|
||||
flags(Mat::MAGIC_VAL + (type_ & TYPE_MASK)), rows(rows_), cols(cols_),
|
||||
flags(Mat::MAGIC_VAL + (type_ & Mat::TYPE_MASK)), rows(rows_), cols(cols_),
|
||||
step(step_), data((uchar*)data_), refcount(0),
|
||||
datastart((uchar*)data_), dataend((uchar*)data_)
|
||||
{
|
||||
@ -568,7 +568,7 @@ cv::gpu::GpuMat::GpuMat(int rows_, int cols_, int type_, void* data_, size_t ste
|
||||
}
|
||||
|
||||
cv::gpu::GpuMat::GpuMat(Size size_, int type_, void* data_, size_t step_) :
|
||||
flags(Mat::MAGIC_VAL + (type_ & TYPE_MASK)), rows(size_.height), cols(size_.width),
|
||||
flags(Mat::MAGIC_VAL + (type_ & Mat::TYPE_MASK)), rows(size_.height), cols(size_.width),
|
||||
step(step_), data((uchar*)data_), refcount(0),
|
||||
datastart((uchar*)data_), dataend((uchar*)data_)
|
||||
{
|
||||
@ -1495,7 +1495,7 @@ GpuMat& cv::gpu::GpuMat::setTo(Scalar s, const GpuMat& mask)
|
||||
|
||||
void cv::gpu::GpuMat::create(int _rows, int _cols, int _type)
|
||||
{
|
||||
_type &= TYPE_MASK;
|
||||
_type &= Mat::TYPE_MASK;
|
||||
|
||||
if (rows == _rows && cols == _cols && type() == _type && data)
|
||||
return;
|
||||
|
@ -1689,7 +1689,6 @@ cvDet( const CvArr* arr )
|
||||
if( rows == 3 )
|
||||
return det3(Md);
|
||||
}
|
||||
return cv::determinant(cv::Mat(mat));
|
||||
}
|
||||
return cv::determinant(cv::cvarrToMat(arr));
|
||||
}
|
||||
|
@ -2350,7 +2350,7 @@ int cv::solveCubic( InputArray _coeffs, OutputArray _roots )
|
||||
coeffs.size() == Size(1, n0) ||
|
||||
coeffs.size() == Size(1, n0+1)) );
|
||||
|
||||
_roots.create(n0, 1, ctype, -1, true, DEPTH_MASK_FLT);
|
||||
_roots.create(n0, 1, ctype, -1, true, _OutputArray::DEPTH_MASK_FLT);
|
||||
Mat roots = _roots.getMat();
|
||||
|
||||
int i = -1, n = 0;
|
||||
@ -2482,7 +2482,7 @@ double cv::solvePoly( InputArray _coeffs0, OutputArray _roots0, int maxIters )
|
||||
|
||||
int n = coeffs0.cols + coeffs0.rows - 2;
|
||||
|
||||
_roots0.create(n, 1, CV_MAKETYPE(cdepth, 2), -1, true, DEPTH_MASK_FLT);
|
||||
_roots0.create(n, 1, CV_MAKETYPE(cdepth, 2), -1, true, _OutputArray::DEPTH_MASK_FLT);
|
||||
Mat roots0 = _roots0.getMat();
|
||||
|
||||
AutoBuffer<C> buf(n*2+2);
|
||||
@ -2550,7 +2550,9 @@ cvSolveCubic( const CvMat* coeffs, CvMat* roots )
|
||||
|
||||
void cvSolvePoly(const CvMat* a, CvMat *r, int maxiter, int)
|
||||
{
|
||||
cv::Mat _a = cv::cvarrToMat(a), _r = cv::cvarrToMat(r), _r0 = r;
|
||||
cv::Mat _a = cv::cvarrToMat(a);
|
||||
cv::Mat _r = cv::cvarrToMat(r);
|
||||
cv::Mat _r0 = _r;
|
||||
cv::solvePoly(_a, _r, maxiter);
|
||||
CV_Assert( _r.data == _r0.data ); // check that the array of roots was not reallocated
|
||||
}
|
||||
|
@ -371,13 +371,14 @@ Mat::Mat(const Mat& m, const Range* ranges) : size(&rows)
|
||||
}
|
||||
|
||||
|
||||
Mat::Mat(const CvMatND* m, bool copyData) : size(&rows)
|
||||
static Mat cvMatNDToMat(const CvMatND* m, bool copyData)
|
||||
{
|
||||
initEmpty();
|
||||
Mat thiz;
|
||||
|
||||
if( !m )
|
||||
return;
|
||||
data = datastart = m->data.ptr;
|
||||
flags |= CV_MAT_TYPE(m->type);
|
||||
return thiz;
|
||||
thiz.data = thiz.datastart = m->data.ptr;
|
||||
thiz.flags |= CV_MAT_TYPE(m->type);
|
||||
int _sizes[CV_MAX_DIM];
|
||||
size_t _steps[CV_MAX_DIM];
|
||||
|
||||
@ -388,16 +389,107 @@ Mat::Mat(const CvMatND* m, bool copyData) : size(&rows)
|
||||
_steps[i] = m->dim[i].step;
|
||||
}
|
||||
|
||||
setSize(*this, d, _sizes, _steps);
|
||||
finalizeHdr(*this);
|
||||
setSize(thiz, d, _sizes, _steps);
|
||||
finalizeHdr(thiz);
|
||||
|
||||
if( copyData )
|
||||
{
|
||||
Mat temp(*this);
|
||||
temp.copyTo(*this);
|
||||
Mat temp(thiz);
|
||||
thiz.release();
|
||||
temp.copyTo(thiz);
|
||||
}
|
||||
|
||||
return thiz;
|
||||
}
|
||||
|
||||
static Mat cvMatToMat(const CvMat* m, bool copyData)
|
||||
{
|
||||
Mat thiz;
|
||||
|
||||
if( !m )
|
||||
return thiz;
|
||||
|
||||
if( !copyData )
|
||||
{
|
||||
thiz.flags = Mat::MAGIC_VAL + (m->type & (CV_MAT_TYPE_MASK|CV_MAT_CONT_FLAG));
|
||||
thiz.dims = 2;
|
||||
thiz.rows = m->rows;
|
||||
thiz.cols = m->cols;
|
||||
thiz.data = thiz.datastart = m->data.ptr;
|
||||
size_t esz = CV_ELEM_SIZE(m->type), minstep = thiz.cols*esz, _step = m->step;
|
||||
if( _step == 0 )
|
||||
_step = minstep;
|
||||
thiz.datalimit = thiz.datastart + _step*thiz.rows;
|
||||
thiz.dataend = thiz.datalimit - _step + minstep;
|
||||
thiz.step[0] = _step; thiz.step[1] = esz;
|
||||
}
|
||||
else
|
||||
{
|
||||
thiz.data = thiz.datastart = thiz.dataend = 0;
|
||||
Mat(m->rows, m->cols, m->type, m->data.ptr, m->step).copyTo(thiz);
|
||||
}
|
||||
|
||||
return thiz;
|
||||
}
|
||||
|
||||
|
||||
static Mat iplImageToMat(const IplImage* img, bool copyData)
|
||||
{
|
||||
Mat m;
|
||||
|
||||
if( !img )
|
||||
return m;
|
||||
|
||||
m.dims = 2;
|
||||
CV_DbgAssert(CV_IS_IMAGE(img) && img->imageData != 0);
|
||||
|
||||
int imgdepth = IPL2CV_DEPTH(img->depth);
|
||||
size_t esz;
|
||||
m.step[0] = img->widthStep;
|
||||
|
||||
if(!img->roi)
|
||||
{
|
||||
CV_Assert(img->dataOrder == IPL_DATA_ORDER_PIXEL);
|
||||
m.flags = Mat::MAGIC_VAL + CV_MAKETYPE(imgdepth, img->nChannels);
|
||||
m.rows = img->height;
|
||||
m.cols = img->width;
|
||||
m.datastart = m.data = (uchar*)img->imageData;
|
||||
esz = CV_ELEM_SIZE(m.flags);
|
||||
}
|
||||
else
|
||||
{
|
||||
CV_Assert(img->dataOrder == IPL_DATA_ORDER_PIXEL || img->roi->coi != 0);
|
||||
bool selectedPlane = img->roi->coi && img->dataOrder == IPL_DATA_ORDER_PLANE;
|
||||
m.flags = Mat::MAGIC_VAL + CV_MAKETYPE(imgdepth, selectedPlane ? 1 : img->nChannels);
|
||||
m.rows = img->roi->height;
|
||||
m.cols = img->roi->width;
|
||||
esz = CV_ELEM_SIZE(m.flags);
|
||||
m.data = m.datastart = (uchar*)img->imageData +
|
||||
(selectedPlane ? (img->roi->coi - 1)*m.step*img->height : 0) +
|
||||
img->roi->yOffset*m.step[0] + img->roi->xOffset*esz;
|
||||
}
|
||||
m.datalimit = m.datastart + m.step.p[0]*m.rows;
|
||||
m.dataend = m.datastart + m.step.p[0]*(m.rows-1) + esz*m.cols;
|
||||
m.flags |= (m.cols*esz == m.step.p[0] || m.rows == 1 ? Mat::CONTINUOUS_FLAG : 0);
|
||||
m.step[1] = esz;
|
||||
|
||||
if( copyData )
|
||||
{
|
||||
Mat m2 = m;
|
||||
m.release();
|
||||
if( !img->roi || !img->roi->coi ||
|
||||
img->dataOrder == IPL_DATA_ORDER_PLANE)
|
||||
m2.copyTo(m);
|
||||
else
|
||||
{
|
||||
int ch[] = {img->roi->coi - 1, 0};
|
||||
m.create(m2.rows, m2.cols, m2.type());
|
||||
mixChannels(&m2, 1, &m, 1, ch, 1);
|
||||
}
|
||||
}
|
||||
|
||||
return m;
|
||||
}
|
||||
|
||||
Mat Mat::diag(int d) const
|
||||
{
|
||||
@ -433,101 +525,6 @@ Mat Mat::diag(int d) const
|
||||
return m;
|
||||
}
|
||||
|
||||
|
||||
Mat::Mat(const CvMat* m, bool copyData) : size(&rows)
|
||||
{
|
||||
initEmpty();
|
||||
|
||||
if( !m )
|
||||
return;
|
||||
|
||||
if( !copyData )
|
||||
{
|
||||
flags = MAGIC_VAL + (m->type & (CV_MAT_TYPE_MASK|CV_MAT_CONT_FLAG));
|
||||
dims = 2;
|
||||
rows = m->rows;
|
||||
cols = m->cols;
|
||||
data = datastart = m->data.ptr;
|
||||
size_t esz = CV_ELEM_SIZE(m->type), minstep = cols*esz, _step = m->step;
|
||||
if( _step == 0 )
|
||||
_step = minstep;
|
||||
datalimit = datastart + _step*rows;
|
||||
dataend = datalimit - _step + minstep;
|
||||
step[0] = _step; step[1] = esz;
|
||||
}
|
||||
else
|
||||
{
|
||||
data = datastart = dataend = 0;
|
||||
Mat(m->rows, m->cols, m->type, m->data.ptr, m->step).copyTo(*this);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Mat::Mat(const IplImage* img, bool copyData) : size(&rows)
|
||||
{
|
||||
initEmpty();
|
||||
|
||||
if( !img )
|
||||
return;
|
||||
|
||||
dims = 2;
|
||||
CV_DbgAssert(CV_IS_IMAGE(img) && img->imageData != 0);
|
||||
|
||||
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(imgdepth, img->nChannels);
|
||||
rows = img->height; cols = img->width;
|
||||
datastart = data = (uchar*)img->imageData;
|
||||
esz = CV_ELEM_SIZE(flags);
|
||||
}
|
||||
else
|
||||
{
|
||||
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(imgdepth, selectedPlane ? 1 : img->nChannels);
|
||||
rows = img->roi->height; cols = img->roi->width;
|
||||
esz = CV_ELEM_SIZE(flags);
|
||||
data = datastart = (uchar*)img->imageData +
|
||||
(selectedPlane ? (img->roi->coi - 1)*step*img->height : 0) +
|
||||
img->roi->yOffset*step[0] + img->roi->xOffset*esz;
|
||||
}
|
||||
datalimit = datastart + step.p[0]*rows;
|
||||
dataend = datastart + step.p[0]*(rows-1) + esz*cols;
|
||||
flags |= (cols*esz == step.p[0] || rows == 1 ? CONTINUOUS_FLAG : 0);
|
||||
step[1] = esz;
|
||||
|
||||
if( copyData )
|
||||
{
|
||||
Mat m = *this;
|
||||
release();
|
||||
if( !img->roi || !img->roi->coi ||
|
||||
img->dataOrder == IPL_DATA_ORDER_PLANE)
|
||||
m.copyTo(*this);
|
||||
else
|
||||
{
|
||||
int ch[] = {img->roi->coi - 1, 0};
|
||||
create(m.rows, m.cols, m.type());
|
||||
mixChannels(&m, 1, this, 1, ch, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Mat::operator IplImage() const
|
||||
{
|
||||
CV_Assert( dims <= 2 );
|
||||
IplImage img;
|
||||
cvInitImageHeader(&img, size(), cvIplDepth(flags), channels());
|
||||
cvSetData(&img, data, (int)step[0]);
|
||||
return img;
|
||||
}
|
||||
|
||||
|
||||
void Mat::pop_back(size_t nelems)
|
||||
{
|
||||
CV_Assert( nelems <= (size_t)size.p[0] );
|
||||
@ -673,16 +670,16 @@ Mat cvarrToMat(const CvArr* arr, bool copyData,
|
||||
{
|
||||
if( !arr )
|
||||
return Mat();
|
||||
if( CV_IS_MAT(arr) )
|
||||
return Mat((const CvMat*)arr, copyData );
|
||||
if( CV_IS_MAT_HDR_Z(arr) )
|
||||
return cvMatToMat((const CvMat*)arr, copyData);
|
||||
if( CV_IS_MATND(arr) )
|
||||
return Mat((const CvMatND*)arr, copyData );
|
||||
return cvMatNDToMat((const CvMatND*)arr, copyData );
|
||||
if( CV_IS_IMAGE(arr) )
|
||||
{
|
||||
const IplImage* iplimg = (const IplImage*)arr;
|
||||
if( coiMode == 0 && iplimg->roi && iplimg->roi->coi > 0 )
|
||||
CV_Error(CV_BadCOI, "COI is not supported by the function");
|
||||
return Mat(iplimg, copyData);
|
||||
return iplImageToMat(iplimg, copyData);
|
||||
}
|
||||
if( CV_IS_SEQ(arr) )
|
||||
{
|
||||
@ -2938,7 +2935,7 @@ CV_IMPL void cvTranspose( const CvArr* srcarr, CvArr* dstarr )
|
||||
|
||||
CV_IMPL void cvCompleteSymm( CvMat* matrix, int LtoR )
|
||||
{
|
||||
cv::Mat m(matrix);
|
||||
cv::Mat m = cv::cvarrToMat(matrix);
|
||||
cv::completeSymm( m, LtoR != 0 );
|
||||
}
|
||||
|
||||
@ -3109,17 +3106,6 @@ Mat Mat::reshape(int _cn, int _newndims, const int* _newsz) const
|
||||
return Mat();
|
||||
}
|
||||
|
||||
Mat::operator CvMatND() const
|
||||
{
|
||||
CvMatND mat;
|
||||
cvInitMatNDHeader( &mat, dims, size, type(), data );
|
||||
int i, d = dims;
|
||||
for( i = 0; i < d; i++ )
|
||||
mat.dim[i].step = (int)step[i];
|
||||
mat.type |= flags & CONTINUOUS_FLAG;
|
||||
return mat;
|
||||
}
|
||||
|
||||
NAryMatIterator::NAryMatIterator()
|
||||
: arrays(0), planes(0), ptrs(0), narrays(0), nplanes(0), size(0), iterdepth(0), idx(0)
|
||||
{
|
||||
@ -3630,24 +3616,6 @@ SparseMat::SparseMat(const Mat& m)
|
||||
}
|
||||
}
|
||||
|
||||
SparseMat::SparseMat(const CvSparseMat* m)
|
||||
: flags(MAGIC_VAL), hdr(0)
|
||||
{
|
||||
CV_Assert(m);
|
||||
create( m->dims, &m->size[0], m->type );
|
||||
|
||||
CvSparseMatIterator it;
|
||||
CvSparseNode* n = cvInitSparseMatIterator(m, &it);
|
||||
size_t esz = elemSize();
|
||||
|
||||
for( ; n != 0; n = cvGetNextSparseNode(&it) )
|
||||
{
|
||||
const int* idx = CV_NODE_IDX(m, n);
|
||||
uchar* to = newNode(idx, hash(idx));
|
||||
copyElem((const uchar*)CV_NODE_VAL(m, n), to, esz);
|
||||
}
|
||||
}
|
||||
|
||||
void SparseMat::create(int d, const int* _sizes, int _type)
|
||||
{
|
||||
int i;
|
||||
@ -3795,24 +3763,6 @@ void SparseMat::clear()
|
||||
hdr->clear();
|
||||
}
|
||||
|
||||
SparseMat::operator CvSparseMat*() const
|
||||
{
|
||||
if( !hdr )
|
||||
return 0;
|
||||
CvSparseMat* m = cvCreateSparseMat(hdr->dims, hdr->size, type());
|
||||
|
||||
SparseMatConstIterator from = begin();
|
||||
size_t i, N = nzcount(), esz = elemSize();
|
||||
|
||||
for( i = 0; i < N; i++, ++from )
|
||||
{
|
||||
const Node* n = from.node();
|
||||
uchar* to = cvPtrND(m, n->idx, 0, -2, 0);
|
||||
copyElem(from.ptr, to, esz);
|
||||
}
|
||||
return m;
|
||||
}
|
||||
|
||||
uchar* SparseMat::ptr(int i0, bool createMissing, size_t* hashval)
|
||||
{
|
||||
CV_Assert( hdr && hdr->dims == 1 );
|
||||
@ -4266,4 +4216,58 @@ Rect RotatedRect::boundingRect() const
|
||||
|
||||
}
|
||||
|
||||
// glue
|
||||
|
||||
CvMatND::CvMatND(const cv::Mat& m)
|
||||
{
|
||||
cvInitMatNDHeader(this, m.dims, m.size, m.type(), m.data );
|
||||
int i, d = m.dims;
|
||||
for( i = 0; i < d; i++ )
|
||||
dim[i].step = (int)m.step[i];
|
||||
type |= m.flags & cv::Mat::CONTINUOUS_FLAG;
|
||||
}
|
||||
|
||||
_IplImage::_IplImage(const cv::Mat& m)
|
||||
{
|
||||
CV_Assert( m.dims <= 2 );
|
||||
cvInitImageHeader(this, m.size(), cvIplDepth(m.flags), m.channels());
|
||||
cvSetData(this, m.data, (int)m.step[0]);
|
||||
}
|
||||
|
||||
CvSparseMat* cvCreateSparseMat(const cv::SparseMat& sm)
|
||||
{
|
||||
if( !sm.hdr )
|
||||
return 0;
|
||||
|
||||
CvSparseMat* m = cvCreateSparseMat(sm.hdr->dims, sm.hdr->size, sm.type());
|
||||
|
||||
cv::SparseMatConstIterator from = sm.begin();
|
||||
size_t i, N = sm.nzcount(), esz = sm.elemSize();
|
||||
|
||||
for( i = 0; i < N; i++, ++from )
|
||||
{
|
||||
const cv::SparseMat::Node* n = from.node();
|
||||
uchar* to = cvPtrND(m, n->idx, 0, -2, 0);
|
||||
cv::copyElem(from.ptr, to, esz);
|
||||
}
|
||||
return m;
|
||||
}
|
||||
|
||||
void CvSparseMat::copyToSparseMat(cv::SparseMat& m) const
|
||||
{
|
||||
m.create( dims, &size[0], type );
|
||||
|
||||
CvSparseMatIterator it;
|
||||
CvSparseNode* n = cvInitSparseMatIterator(this, &it);
|
||||
size_t esz = m.elemSize();
|
||||
|
||||
for( ; n != 0; n = cvGetNextSparseNode(&it) )
|
||||
{
|
||||
const int* idx = CV_NODE_IDX(this, n);
|
||||
uchar* to = m.newNode(idx, m.hash(idx));
|
||||
cv::copyElem((const uchar*)CV_NODE_VAL(this, n), to, esz);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* End of file. */
|
||||
|
@ -5470,7 +5470,7 @@ void write( FileStorage& fs, const String& name, const Mat& value )
|
||||
// TODO: the 4 functions below need to be implemented more efficiently
|
||||
void write( FileStorage& fs, const String& name, const SparseMat& value )
|
||||
{
|
||||
Ptr<CvSparseMat> mat = (CvSparseMat*)value;
|
||||
Ptr<CvSparseMat> mat = cvCreateSparseMat(value);
|
||||
cvWrite( *fs, name.size() ? name.c_str() : 0, mat );
|
||||
}
|
||||
|
||||
@ -5495,12 +5495,12 @@ void read( const FileNode& node, Mat& mat, const Mat& default_mat )
|
||||
void* obj = cvRead((CvFileStorage*)node.fs, (CvFileNode*)*node);
|
||||
if(CV_IS_MAT_HDR_Z(obj))
|
||||
{
|
||||
Mat((const CvMat*)obj).copyTo(mat);
|
||||
cvarrToMat(obj).copyTo(mat);
|
||||
cvReleaseMat((CvMat**)&obj);
|
||||
}
|
||||
else if(CV_IS_MATND_HDR(obj))
|
||||
{
|
||||
Mat((const CvMatND*)obj).copyTo(mat);
|
||||
cvarrToMat(obj).copyTo(mat);
|
||||
cvReleaseMatND((CvMatND**)&obj);
|
||||
}
|
||||
else
|
||||
@ -5519,7 +5519,7 @@ void read( const FileNode& node, SparseMat& mat, const SparseMat& default_mat )
|
||||
}
|
||||
Ptr<CvSparseMat> m = (CvSparseMat*)cvRead((CvFileStorage*)node.fs, (CvFileNode*)*node);
|
||||
CV_Assert(CV_IS_SPARSE_MAT(m.obj));
|
||||
SparseMat(m).copyTo(mat);
|
||||
m->copyToSparseMat(mat);
|
||||
}
|
||||
|
||||
void write(FileStorage& fs, const String& objname, const std::vector<KeyPoint>& keypoints)
|
||||
|
@ -35,7 +35,7 @@ struct BaseElemWiseOp
|
||||
|
||||
virtual int getRandomType(RNG& rng)
|
||||
{
|
||||
return cvtest::randomType(rng, DEPTH_MASK_ALL_BUT_8S, 1,
|
||||
return cvtest::randomType(rng, _OutputArray::DEPTH_MASK_ALL_BUT_8S, 1,
|
||||
ninputs > 1 ? ARITHM_MAX_CHANNELS : 4);
|
||||
}
|
||||
|
||||
@ -425,7 +425,7 @@ struct CmpOp : public BaseElemWiseOp
|
||||
}
|
||||
int getRandomType(RNG& rng)
|
||||
{
|
||||
return cvtest::randomType(rng, DEPTH_MASK_ALL_BUT_8S, 1, 1);
|
||||
return cvtest::randomType(rng, _OutputArray::DEPTH_MASK_ALL_BUT_8S, 1, 1);
|
||||
}
|
||||
|
||||
double getMaxErr(int)
|
||||
@ -455,7 +455,7 @@ struct CmpSOp : public BaseElemWiseOp
|
||||
}
|
||||
int getRandomType(RNG& rng)
|
||||
{
|
||||
return cvtest::randomType(rng, DEPTH_MASK_ALL_BUT_8S, 1, 1);
|
||||
return cvtest::randomType(rng, _OutputArray::DEPTH_MASK_ALL_BUT_8S, 1, 1);
|
||||
}
|
||||
double getMaxErr(int)
|
||||
{
|
||||
@ -478,7 +478,7 @@ struct CopyOp : public BaseElemWiseOp
|
||||
}
|
||||
int getRandomType(RNG& rng)
|
||||
{
|
||||
return cvtest::randomType(rng, DEPTH_MASK_ALL, 1, ARITHM_MAX_CHANNELS);
|
||||
return cvtest::randomType(rng, _OutputArray::DEPTH_MASK_ALL, 1, ARITHM_MAX_CHANNELS);
|
||||
}
|
||||
double getMaxErr(int)
|
||||
{
|
||||
@ -501,7 +501,7 @@ struct SetOp : public BaseElemWiseOp
|
||||
}
|
||||
int getRandomType(RNG& rng)
|
||||
{
|
||||
return cvtest::randomType(rng, DEPTH_MASK_ALL, 1, ARITHM_MAX_CHANNELS);
|
||||
return cvtest::randomType(rng, _OutputArray::DEPTH_MASK_ALL, 1, ARITHM_MAX_CHANNELS);
|
||||
}
|
||||
double getMaxErr(int)
|
||||
{
|
||||
@ -718,8 +718,8 @@ struct ConvertScaleOp : public BaseElemWiseOp
|
||||
}
|
||||
int getRandomType(RNG& rng)
|
||||
{
|
||||
int srctype = cvtest::randomType(rng, DEPTH_MASK_ALL, 1, ARITHM_MAX_CHANNELS);
|
||||
ddepth = cvtest::randomType(rng, DEPTH_MASK_ALL, 1, 1);
|
||||
int srctype = cvtest::randomType(rng, _OutputArray::DEPTH_MASK_ALL, 1, ARITHM_MAX_CHANNELS);
|
||||
ddepth = cvtest::randomType(rng, _OutputArray::DEPTH_MASK_ALL, 1, 1);
|
||||
return srctype;
|
||||
}
|
||||
double getMaxErr(int)
|
||||
@ -957,7 +957,7 @@ struct ExpOp : public BaseElemWiseOp
|
||||
ExpOp() : BaseElemWiseOp(1, FIX_ALPHA+FIX_BETA+FIX_GAMMA, 1, 1, Scalar::all(0)) {};
|
||||
int getRandomType(RNG& rng)
|
||||
{
|
||||
return cvtest::randomType(rng, DEPTH_MASK_FLT, 1, ARITHM_MAX_CHANNELS);
|
||||
return cvtest::randomType(rng, _OutputArray::DEPTH_MASK_FLT, 1, ARITHM_MAX_CHANNELS);
|
||||
}
|
||||
void getValueRange(int depth, double& minval, double& maxval)
|
||||
{
|
||||
@ -984,7 +984,7 @@ struct LogOp : public BaseElemWiseOp
|
||||
LogOp() : BaseElemWiseOp(1, FIX_ALPHA+FIX_BETA+FIX_GAMMA, 1, 1, Scalar::all(0)) {};
|
||||
int getRandomType(RNG& rng)
|
||||
{
|
||||
return cvtest::randomType(rng, DEPTH_MASK_FLT, 1, ARITHM_MAX_CHANNELS);
|
||||
return cvtest::randomType(rng, _OutputArray::DEPTH_MASK_FLT, 1, ARITHM_MAX_CHANNELS);
|
||||
}
|
||||
void getValueRange(int depth, double& minval, double& maxval)
|
||||
{
|
||||
@ -1070,7 +1070,7 @@ struct CartToPolarToCartOp : public BaseElemWiseOp
|
||||
}
|
||||
int getRandomType(RNG& rng)
|
||||
{
|
||||
return cvtest::randomType(rng, DEPTH_MASK_FLT, 1, 1);
|
||||
return cvtest::randomType(rng, _OutputArray::DEPTH_MASK_FLT, 1, 1);
|
||||
}
|
||||
void op(const vector<Mat>& src, Mat& dst, const Mat&)
|
||||
{
|
||||
@ -1157,7 +1157,7 @@ struct CountNonZeroOp : public BaseElemWiseOp
|
||||
{}
|
||||
int getRandomType(RNG& rng)
|
||||
{
|
||||
return cvtest::randomType(rng, DEPTH_MASK_ALL, 1, 1);
|
||||
return cvtest::randomType(rng, _OutputArray::DEPTH_MASK_ALL, 1, 1);
|
||||
}
|
||||
void op(const vector<Mat>& src, Mat& dst, const Mat& mask)
|
||||
{
|
||||
@ -1237,7 +1237,7 @@ struct NormOp : public BaseElemWiseOp
|
||||
};
|
||||
int getRandomType(RNG& rng)
|
||||
{
|
||||
int type = cvtest::randomType(rng, DEPTH_MASK_ALL_BUT_8S, 1, 4);
|
||||
int type = cvtest::randomType(rng, _OutputArray::DEPTH_MASK_ALL_BUT_8S, 1, 4);
|
||||
for(;;)
|
||||
{
|
||||
normType = rng.uniform(1, 8);
|
||||
@ -1283,7 +1283,7 @@ struct MinMaxLocOp : public BaseElemWiseOp
|
||||
};
|
||||
int getRandomType(RNG& rng)
|
||||
{
|
||||
return cvtest::randomType(rng, DEPTH_MASK_ALL_BUT_8S, 1, 1);
|
||||
return cvtest::randomType(rng, _OutputArray::DEPTH_MASK_ALL_BUT_8S, 1, 1);
|
||||
}
|
||||
void saveOutput(const vector<int>& minidx, const vector<int>& maxidx,
|
||||
double minval, double maxval, Mat& dst)
|
||||
|
@ -211,7 +211,7 @@ protected:
|
||||
vector<int> pt;
|
||||
|
||||
if( !m || !CV_IS_MAT(m) || m->rows != test_mat.rows || m->cols != test_mat.cols ||
|
||||
cvtest::cmpEps( Mat(&stub1), Mat(&_test_stub1), &max_diff, 0, &pt, true) < 0 )
|
||||
cvtest::cmpEps( cv::cvarrToMat(&stub1), cv::cvarrToMat(&_test_stub1), &max_diff, 0, &pt, true) < 0 )
|
||||
{
|
||||
ts->printf( cvtest::TS::LOG, "the read matrix is not correct: (%.20g vs %.20g) at (%d,%d)\n",
|
||||
cvGetReal2D(&stub1, pt[0], pt[1]), cvGetReal2D(&_test_stub1, pt[0], pt[1]),
|
||||
@ -241,7 +241,7 @@ protected:
|
||||
if( !CV_ARE_TYPES_EQ(&stub, &_test_stub) ||
|
||||
!CV_ARE_SIZES_EQ(&stub, &_test_stub) ||
|
||||
//cvNorm(&stub, &_test_stub, CV_L2) != 0 )
|
||||
cvtest::cmpEps( Mat(&stub1), Mat(&_test_stub1), &max_diff, 0, &pt, true) < 0 )
|
||||
cvtest::cmpEps( cv::cvarrToMat(&stub1), cv::cvarrToMat(&_test_stub1), &max_diff, 0, &pt, true) < 0 )
|
||||
{
|
||||
ts->printf( cvtest::TS::LOG, "readObj method: the read nd matrix is not correct: (%.20g vs %.20g) vs at (%d,%d)\n",
|
||||
cvGetReal2D(&stub1, pt[0], pt[1]), cvGetReal2D(&_test_stub1, pt[0], pt[1]),
|
||||
@ -259,7 +259,7 @@ protected:
|
||||
if( !CV_ARE_TYPES_EQ(&stub, &_test_stub) ||
|
||||
!CV_ARE_SIZES_EQ(&stub, &_test_stub) ||
|
||||
//cvNorm(&stub, &_test_stub, CV_L2) != 0 )
|
||||
cvtest::cmpEps( Mat(&stub1), Mat(&_test_stub1), &max_diff, 0, &pt, true) < 0 )
|
||||
cvtest::cmpEps( cv::cvarrToMat(&stub1), cv::cvarrToMat(&_test_stub1), &max_diff, 0, &pt, true) < 0 )
|
||||
{
|
||||
ts->printf( cvtest::TS::LOG, "C++ method: the read nd matrix is not correct: (%.20g vs %.20g) vs at (%d,%d)\n",
|
||||
cvGetReal2D(&stub1, pt[0], pt[1]), cvGetReal2D(&_test_stub1, pt[1], pt[0]),
|
||||
@ -271,11 +271,11 @@ protected:
|
||||
cvRelease((void**)&m_nd);
|
||||
|
||||
Ptr<CvSparseMat> m_s = (CvSparseMat*)fs["test_sparse_mat"].readObj();
|
||||
Ptr<CvSparseMat> _test_sparse_ = (CvSparseMat*)test_sparse_mat;
|
||||
Ptr<CvSparseMat> _test_sparse_ = cvCreateSparseMat(test_sparse_mat);
|
||||
Ptr<CvSparseMat> _test_sparse = (CvSparseMat*)cvClone(_test_sparse_);
|
||||
SparseMat m_s2;
|
||||
fs["test_sparse_mat"] >> m_s2;
|
||||
Ptr<CvSparseMat> _m_s2 = (CvSparseMat*)m_s2;
|
||||
Ptr<CvSparseMat> _m_s2 = cvCreateSparseMat(m_s2);
|
||||
|
||||
if( !m_s || !CV_IS_SPARSE_MAT(m_s) ||
|
||||
!cvTsCheckSparse(m_s, _test_sparse,0) ||
|
||||
|
@ -734,7 +734,7 @@ void Core_ArrayOpTest::run( int /* start_from */)
|
||||
}
|
||||
}
|
||||
|
||||
Ptr<CvSparseMat> M2 = (CvSparseMat*)M;
|
||||
Ptr<CvSparseMat> M2 = cvCreateSparseMat(M);
|
||||
MatND Md;
|
||||
M.copyTo(Md);
|
||||
SparseMat M3; SparseMat(Md).convertTo(M3, Md.type(), 2);
|
||||
|
@ -2292,9 +2292,9 @@ void Core_SolvePolyTest::run( int )
|
||||
cvFlip(&amat, &amat, 0);
|
||||
int nr2;
|
||||
if( cubic_case == 0 )
|
||||
nr2 = cv::solveCubic(cv::Mat(&amat),umat2);
|
||||
nr2 = cv::solveCubic(cv::cvarrToMat(&amat),umat2);
|
||||
else
|
||||
nr2 = cv::solveCubic(cv::Mat_<float>(cv::Mat(&amat)), umat2);
|
||||
nr2 = cv::solveCubic(cv::Mat_<float>(cv::cvarrToMat(&amat)), umat2);
|
||||
cvFlip(&amat, &amat, 0);
|
||||
if(nr2 > 0)
|
||||
std::sort(ar2.begin(), ar2.begin()+nr2, pred_double());
|
||||
|
@ -596,8 +596,8 @@ PERF_TEST_P(Video, Video_FGDStatModel,
|
||||
stopTimer();
|
||||
}
|
||||
|
||||
const cv::Mat background = model->background;
|
||||
const cv::Mat foreground = model->foreground;
|
||||
const cv::Mat background = cv::cvarrToMat(model->background);
|
||||
const cv::Mat foreground = cv::cvarrToMat(model->foreground);
|
||||
|
||||
CPU_SANITY_CHECK(background);
|
||||
CPU_SANITY_CHECK(foreground);
|
||||
|
@ -495,10 +495,10 @@ bool VideoCapture::retrieve(Mat& image, int channel)
|
||||
return false;
|
||||
}
|
||||
if(_img->origin == IPL_ORIGIN_TL)
|
||||
image = Mat(_img);
|
||||
image = cv::cvarrToMat(_img);
|
||||
else
|
||||
{
|
||||
Mat temp(_img);
|
||||
Mat temp = cv::cvarrToMat(_img);
|
||||
flip(temp, image, 0);
|
||||
}
|
||||
return true;
|
||||
|
@ -948,7 +948,7 @@ void GuiReceiver::showImage(QString name, void* arr)
|
||||
|
||||
mat = cvGetMat(arr, &stub);
|
||||
|
||||
cv::Mat im(mat);
|
||||
cv::Mat im = cv::cvarrToMat(mat);
|
||||
cv::imshow(name.toUtf8().data(), im);
|
||||
}
|
||||
else
|
||||
|
@ -247,7 +247,7 @@ void CV_HighGuiTest::VideoTest(const string& dir, const cvtest::VideoFormat& fmt
|
||||
if (!img)
|
||||
break;
|
||||
|
||||
frames.push_back(Mat(img).clone());
|
||||
frames.push_back(cv::cvarrToMat(img, true));
|
||||
|
||||
if (writer == 0)
|
||||
{
|
||||
@ -285,7 +285,7 @@ void CV_HighGuiTest::VideoTest(const string& dir, const cvtest::VideoFormat& fmt
|
||||
break;
|
||||
|
||||
Mat img = frames[i];
|
||||
Mat img1(ipl1);
|
||||
Mat img1 = cv::cvarrToMat(ipl1);
|
||||
|
||||
double psnr = PSNR(img1, img);
|
||||
if (psnr < thresDbell)
|
||||
|
@ -2456,7 +2456,8 @@ cvCompareHist( const CvHistogram* hist1,
|
||||
|
||||
if( !CV_IS_SPARSE_MAT(hist1->bins) )
|
||||
{
|
||||
cv::Mat H1((const CvMatND*)hist1->bins), H2((const CvMatND*)hist2->bins);
|
||||
cv::Mat H1 = cv::cvarrToMat(hist1->bins);
|
||||
cv::Mat H2 = cv::cvarrToMat(hist2->bins);
|
||||
return cv::compareHist(H1, H2, method);
|
||||
}
|
||||
|
||||
@ -2758,7 +2759,7 @@ cvCalcArrHist( CvArr** img, CvHistogram* hist, int accumulate, const CvArr* mask
|
||||
|
||||
if( !CV_IS_SPARSE_HIST(hist) )
|
||||
{
|
||||
cv::Mat H((const CvMatND*)hist->bins);
|
||||
cv::Mat H = cv::cvarrToMat(hist->bins);
|
||||
cv::calcHist( &images[0], (int)images.size(), 0, _mask,
|
||||
H, cvGetDims(hist->bins), H.size, ranges, uniform, accumulate != 0 );
|
||||
}
|
||||
@ -2768,7 +2769,8 @@ cvCalcArrHist( CvArr** img, CvHistogram* hist, int accumulate, const CvArr* mask
|
||||
|
||||
if( !accumulate )
|
||||
cvZero( hist->bins );
|
||||
cv::SparseMat sH(sparsemat);
|
||||
cv::SparseMat sH;
|
||||
sparsemat->copyToSparseMat(sH);
|
||||
cv::calcHist( &images[0], (int)images.size(), 0, _mask, sH, sH.dims(),
|
||||
sH.dims() > 0 ? sH.hdr->size : 0, ranges, uniform, accumulate != 0, true );
|
||||
|
||||
@ -2820,13 +2822,14 @@ cvCalcArrBackProject( CvArr** img, CvArr* dst, const CvHistogram* hist )
|
||||
|
||||
if( !CV_IS_SPARSE_HIST(hist) )
|
||||
{
|
||||
cv::Mat H((const CvMatND*)hist->bins);
|
||||
cv::Mat H = cv::cvarrToMat(hist->bins);
|
||||
cv::calcBackProject( &images[0], (int)images.size(),
|
||||
0, H, _dst, ranges, 1, uniform );
|
||||
}
|
||||
else
|
||||
{
|
||||
cv::SparseMat sH((const CvSparseMat*)hist->bins);
|
||||
cv::SparseMat sH;
|
||||
((const CvSparseMat*)hist->bins)->copyToSparseMat(sH);
|
||||
cv::calcBackProject( &images[0], (int)images.size(),
|
||||
0, sH, _dst, ranges, 1, uniform );
|
||||
}
|
||||
|
@ -630,7 +630,8 @@ void CV_MinMaxHistTest::run_func(void)
|
||||
{
|
||||
if( hist_type != CV_HIST_ARRAY && test_cpp )
|
||||
{
|
||||
cv::SparseMat h((CvSparseMat*)hist[0]->bins);
|
||||
cv::SparseMat h;
|
||||
((CvSparseMat*)hist[0]->bins)->copyToSparseMat(h);
|
||||
double _min_val = 0, _max_val = 0;
|
||||
cv::minMaxLoc(h, &_min_val, &_max_val, min_idx, max_idx );
|
||||
min_val = (float)_min_val;
|
||||
@ -727,10 +728,11 @@ void CV_NormHistTest::run_func(void)
|
||||
{
|
||||
if( hist_type != CV_HIST_ARRAY && test_cpp )
|
||||
{
|
||||
cv::SparseMat h((CvSparseMat*)hist[0]->bins);
|
||||
cv::SparseMat h;
|
||||
((CvSparseMat*)hist[0]->bins)->copyToSparseMat(h);
|
||||
cv::normalize(h, h, factor, CV_L1);
|
||||
cvReleaseSparseMat((CvSparseMat**)&hist[0]->bins);
|
||||
hist[0]->bins = (CvSparseMat*)h;
|
||||
hist[0]->bins = cvCreateSparseMat(h);
|
||||
}
|
||||
else
|
||||
cvNormalizeHist( hist[0], factor );
|
||||
@ -978,8 +980,9 @@ void CV_CompareHistTest::run_func(void)
|
||||
int k;
|
||||
if( hist_type != CV_HIST_ARRAY && test_cpp )
|
||||
{
|
||||
cv::SparseMat h0((CvSparseMat*)hist[0]->bins);
|
||||
cv::SparseMat h1((CvSparseMat*)hist[1]->bins);
|
||||
cv::SparseMat h0, h1;
|
||||
((CvSparseMat*)hist[0]->bins)->copyToSparseMat(h0);
|
||||
((CvSparseMat*)hist[1]->bins)->copyToSparseMat(h1);
|
||||
for( k = 0; k < MAX_METHOD; k++ )
|
||||
result[k] = cv::compareHist(h0, h1, k);
|
||||
}
|
||||
|
@ -334,7 +334,7 @@ void RandomizedTree::train(std::vector<BaseKeypoint> const& base_set,
|
||||
Size patchSize(PATCH_SIZE, PATCH_SIZE);
|
||||
for (keypt_it = base_set.begin(); keypt_it != base_set.end(); ++keypt_it, ++class_id) {
|
||||
for (int i = 0; i < views; ++i) {
|
||||
make_patch( Mat(keypt_it->image), Point(keypt_it->x, keypt_it->y ), patch, patchSize, rng );
|
||||
make_patch( cv::cvarrToMat(keypt_it->image), Point(keypt_it->x, keypt_it->y ), patch, patchSize, rng );
|
||||
IplImage iplPatch = patch;
|
||||
addExample(class_id, getData(&iplPatch));
|
||||
}
|
||||
|
@ -139,15 +139,15 @@ void init_params(const CvEMParams& src,
|
||||
Mat& prbs, Mat& weights,
|
||||
Mat& means, std::vector<Mat>& covsHdrs)
|
||||
{
|
||||
prbs = src.probs;
|
||||
weights = src.weights;
|
||||
means = src.means;
|
||||
prbs = cv::cvarrToMat(src.probs);
|
||||
weights = cv::cvarrToMat(src.weights);
|
||||
means = cv::cvarrToMat(src.means);
|
||||
|
||||
if(src.covs)
|
||||
{
|
||||
covsHdrs.resize(src.nclusters);
|
||||
for(size_t i = 0; i < covsHdrs.size(); i++)
|
||||
covsHdrs[i] = src.covs[i];
|
||||
covsHdrs[i] = cv::cvarrToMat(src.covs[i]);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -745,6 +745,7 @@ void icvReconstructPoints4DStatus(CvMat** projPoints, CvMat **projMatrs, CvMat**
|
||||
double* matrW_dat = 0;
|
||||
|
||||
CV_FUNCNAME( "icvReconstructPoints4DStatus" );
|
||||
|
||||
__BEGIN__;
|
||||
|
||||
/* ----- Test input params for errors ----- */
|
||||
@ -770,6 +771,7 @@ void icvReconstructPoints4DStatus(CvMat** projPoints, CvMat **projMatrs, CvMat**
|
||||
CV_ERROR( CV_StsOutOfRange, "Points must have 4 cordinates" );
|
||||
}
|
||||
|
||||
|
||||
/* !!! Not tested all input parameters */
|
||||
/* ----- End test ----- */
|
||||
|
||||
@ -778,75 +780,75 @@ void icvReconstructPoints4DStatus(CvMat** projPoints, CvMat **projMatrs, CvMat**
|
||||
|
||||
/* Allocate maximum data */
|
||||
|
||||
|
||||
CvMat matrV;
|
||||
double matrV_dat[4*4];
|
||||
matrV = cvMat(4,4,CV_64F,matrV_dat);
|
||||
|
||||
CV_CALL(matrA_dat = (double*)cvAlloc(3*numImages * 4 * sizeof(double)));
|
||||
CV_CALL(matrW_dat = (double*)cvAlloc(3*numImages * 4 * sizeof(double)));
|
||||
|
||||
/* reconstruct each point */
|
||||
for( currPoint = 0; currPoint < numPoints; currPoint++ )
|
||||
{
|
||||
/* Reconstruct current point */
|
||||
/* Define number of visible projections */
|
||||
int numVisProj = 0;
|
||||
for( currImage = 0; currImage < numImages; currImage++ )
|
||||
double matrV_dat[4*4];
|
||||
CvMat matrV = cvMat(4,4,CV_64F,matrV_dat);
|
||||
|
||||
CV_CALL(matrA_dat = (double*)cvAlloc(3*numImages * 4 * sizeof(double)));
|
||||
CV_CALL(matrW_dat = (double*)cvAlloc(3*numImages * 4 * sizeof(double)));
|
||||
|
||||
/* reconstruct each point */
|
||||
for( currPoint = 0; currPoint < numPoints; currPoint++ )
|
||||
{
|
||||
if( cvmGet(presPoints[currImage],0,currPoint) > 0 )
|
||||
/* Reconstruct current point */
|
||||
/* Define number of visible projections */
|
||||
int numVisProj = 0;
|
||||
for( currImage = 0; currImage < numImages; currImage++ )
|
||||
{
|
||||
numVisProj++;
|
||||
}
|
||||
}
|
||||
|
||||
if( numVisProj < 2 )
|
||||
{
|
||||
/* This point can't be reconstructed */
|
||||
continue;
|
||||
}
|
||||
|
||||
/* Allocate memory and create matrices */
|
||||
CvMat matrA;
|
||||
matrA = cvMat(3*numVisProj,4,CV_64F,matrA_dat);
|
||||
|
||||
CvMat matrW;
|
||||
matrW = cvMat(3*numVisProj,4,CV_64F,matrW_dat);
|
||||
|
||||
int currVisProj = 0;
|
||||
for( currImage = 0; currImage < numImages; currImage++ )/* For each view */
|
||||
{
|
||||
if( cvmGet(presPoints[currImage],0,currPoint) > 0 )
|
||||
{
|
||||
double x,y;
|
||||
x = cvmGet(projPoints[currImage],0,currPoint);
|
||||
y = cvmGet(projPoints[currImage],1,currPoint);
|
||||
for( int k = 0; k < 4; k++ )
|
||||
if( cvmGet(presPoints[currImage],0,currPoint) > 0 )
|
||||
{
|
||||
matrA_dat[currVisProj*12 + k] =
|
||||
x * cvmGet(projMatrs[currImage],2,k) - cvmGet(projMatrs[currImage],0,k);
|
||||
|
||||
matrA_dat[currVisProj*12+4 + k] =
|
||||
y * cvmGet(projMatrs[currImage],2,k) - cvmGet(projMatrs[currImage],1,k);
|
||||
|
||||
matrA_dat[currVisProj*12+8 + k] =
|
||||
x * cvmGet(projMatrs[currImage],1,k) - y * cvmGet(projMatrs[currImage],0,k);
|
||||
numVisProj++;
|
||||
}
|
||||
currVisProj++;
|
||||
}
|
||||
|
||||
if( numVisProj < 2 )
|
||||
{
|
||||
/* This point can't be reconstructed */
|
||||
continue;
|
||||
}
|
||||
|
||||
/* Allocate memory and create matrices */
|
||||
CvMat matrA;
|
||||
matrA = cvMat(3*numVisProj,4,CV_64F,matrA_dat);
|
||||
|
||||
CvMat matrW;
|
||||
matrW = cvMat(3*numVisProj,4,CV_64F,matrW_dat);
|
||||
|
||||
int currVisProj = 0;
|
||||
for( currImage = 0; currImage < numImages; currImage++ )/* For each view */
|
||||
{
|
||||
if( cvmGet(presPoints[currImage],0,currPoint) > 0 )
|
||||
{
|
||||
double x,y;
|
||||
x = cvmGet(projPoints[currImage],0,currPoint);
|
||||
y = cvmGet(projPoints[currImage],1,currPoint);
|
||||
for( int k = 0; k < 4; k++ )
|
||||
{
|
||||
matrA_dat[currVisProj*12 + k] =
|
||||
x * cvmGet(projMatrs[currImage],2,k) - cvmGet(projMatrs[currImage],0,k);
|
||||
|
||||
matrA_dat[currVisProj*12+4 + k] =
|
||||
y * cvmGet(projMatrs[currImage],2,k) - cvmGet(projMatrs[currImage],1,k);
|
||||
|
||||
matrA_dat[currVisProj*12+8 + k] =
|
||||
x * cvmGet(projMatrs[currImage],1,k) - y * cvmGet(projMatrs[currImage],0,k);
|
||||
}
|
||||
currVisProj++;
|
||||
}
|
||||
}
|
||||
|
||||
/* Solve system for current point */
|
||||
{
|
||||
cvSVD(&matrA,&matrW,0,&matrV,CV_SVD_V_T);
|
||||
|
||||
/* Copy computed point */
|
||||
cvmSet(points4D,0,currPoint,cvmGet(&matrV,3,0));//X
|
||||
cvmSet(points4D,1,currPoint,cvmGet(&matrV,3,1));//Y
|
||||
cvmSet(points4D,2,currPoint,cvmGet(&matrV,3,2));//Z
|
||||
cvmSet(points4D,3,currPoint,cvmGet(&matrV,3,3));//W
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/* Solve system for current point */
|
||||
{
|
||||
cvSVD(&matrA,&matrW,0,&matrV,CV_SVD_V_T);
|
||||
|
||||
/* Copy computed point */
|
||||
cvmSet(points4D,0,currPoint,cvmGet(&matrV,3,0));//X
|
||||
cvmSet(points4D,1,currPoint,cvmGet(&matrV,3,1));//Y
|
||||
cvmSet(points4D,2,currPoint,cvmGet(&matrV,3,2));//Z
|
||||
cvmSet(points4D,3,currPoint,cvmGet(&matrV,3,3));//W
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
{/* Compute projection error */
|
||||
@ -913,7 +915,7 @@ static void icvProjPointsStatusFunc( int numImages, CvMat *points4D, CvMat **pro
|
||||
{
|
||||
CV_ERROR( CV_StsNullPtr, "Some of parameters is a NULL pointer" );
|
||||
}
|
||||
|
||||
{
|
||||
int numPoints;
|
||||
numPoints = points4D->cols;
|
||||
if( numPoints < 1 )
|
||||
@ -994,7 +996,7 @@ static void icvProjPointsStatusFunc( int numImages, CvMat *points4D, CvMat **pro
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
__END__;
|
||||
}
|
||||
|
||||
|
@ -1740,7 +1740,7 @@ namespace cv{
|
||||
CV_Error(CV_StsNotImplemented, "OpenCV was built without SURF support");
|
||||
surf_extractor->set("hessianThreshold", 1.0);
|
||||
//printf("Extracting SURF features...");
|
||||
surf_extractor->detect(Mat(img), features);
|
||||
surf_extractor->detect(cv::cvarrToMat(img), features);
|
||||
//printf("done\n");
|
||||
|
||||
for (int j = 0; j < (int)features.size(); j++)
|
||||
|
@ -223,7 +223,7 @@ int icvComputeProjectMatrices6Points( CvMat* points1,CvMat* points2,CvMat* point
|
||||
CV_ERROR( CV_StsUnmatchedSizes, "Number of coordinates of points4D must be 4" );
|
||||
}
|
||||
#endif
|
||||
|
||||
{
|
||||
/* Find transform matrix for each camera */
|
||||
int i;
|
||||
CvMat* points[3];
|
||||
@ -400,7 +400,7 @@ int icvComputeProjectMatrices6Points( CvMat* points1,CvMat* points2,CvMat* point
|
||||
#endif
|
||||
|
||||
}/* for all sollutions */
|
||||
|
||||
}
|
||||
__END__;
|
||||
return numSol;
|
||||
}
|
||||
@ -1362,7 +1362,7 @@ void icvFindBaseTransform(CvMat* points,CvMat* resultT)
|
||||
/* Function gets four points and compute transformation to e1=(100) e2=(010) e3=(001) e4=(111) */
|
||||
|
||||
/* !!! test each three points not collinear. Need to test */
|
||||
|
||||
{
|
||||
/* Create matrices */
|
||||
CvMat matrA;
|
||||
CvMat vectB;
|
||||
@ -1410,7 +1410,7 @@ void icvFindBaseTransform(CvMat* points,CvMat* resultT)
|
||||
cvInvert(&matrA,&tmpRes);
|
||||
|
||||
cvConvert(&tmpRes,resultT);
|
||||
|
||||
}
|
||||
__END__;
|
||||
|
||||
return;
|
||||
@ -1459,7 +1459,7 @@ void GetGeneratorReduceFundSolution(CvMat* points1,CvMat* points2,CvMat* fundRed
|
||||
}
|
||||
|
||||
/* Using 3 corr. points compute reduce */
|
||||
|
||||
{
|
||||
/* Create matrix */
|
||||
CvMat matrA;
|
||||
double matrA_dat[3*5];
|
||||
@ -1507,7 +1507,7 @@ void GetGeneratorReduceFundSolution(CvMat* points1,CvMat* points2,CvMat* fundRed
|
||||
cvmSet(fundReduceCoef1,0,i,cvmGet(&matrV,3,i));
|
||||
cvmSet(fundReduceCoef2,0,i,cvmGet(&matrV,4,i));
|
||||
}
|
||||
|
||||
}
|
||||
__END__;
|
||||
return;
|
||||
|
||||
@ -1551,7 +1551,7 @@ int GetGoodReduceFundamMatrFromTwo(CvMat* fundReduceCoef1,CvMat* fundReduceCoef2
|
||||
{
|
||||
CV_ERROR( CV_StsUnmatchedSizes, "Size of resFundReduceCoef must be 1x5" );
|
||||
}
|
||||
|
||||
{
|
||||
double p1,q1,r1,s1,t1;
|
||||
double p2,q2,r2,s2,t2;
|
||||
p1 = cvmGet(fundReduceCoef1,0,0);
|
||||
@ -1599,7 +1599,7 @@ int GetGoodReduceFundamMatrFromTwo(CvMat* fundReduceCoef1,CvMat* fundReduceCoef2
|
||||
numRoots++;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
__END__;
|
||||
return numRoots;
|
||||
}
|
||||
@ -1636,7 +1636,7 @@ void GetProjMatrFromReducedFundamental(CvMat* fundReduceCoefs,CvMat* projMatrCoe
|
||||
/* Computes project matrix from given reduced matrix */
|
||||
/* we have p,q,r,s,t and need get a,b,c,d */
|
||||
/* Fill matrix to compute ratio a:b:c as A:B:C */
|
||||
|
||||
{
|
||||
CvMat matrA;
|
||||
double matrA_dat[3*3];
|
||||
matrA = cvMat(3,3,CV_64F,matrA_dat);
|
||||
@ -1752,7 +1752,7 @@ void GetProjMatrFromReducedFundamental(CvMat* fundReduceCoefs,CvMat* projMatrCoe
|
||||
cvmSet(projMatrCoefs,0,3,d);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
__END__;
|
||||
return;
|
||||
}
|
||||
@ -2106,7 +2106,7 @@ void icvReconstructPointsFor3View( CvMat* projMatr1,CvMat* projMatr2,CvMat* proj
|
||||
{
|
||||
CV_ERROR( CV_StsUnmatchedSizes, "Size of projection matrices must be 3x4" );
|
||||
}
|
||||
|
||||
{
|
||||
CvMat matrA;
|
||||
double matrA_dat[36];
|
||||
matrA = cvMat(9,4,CV_64F,matrA_dat);
|
||||
@ -2203,7 +2203,7 @@ void icvReconstructPointsFor3View( CvMat* projMatr1,CvMat* projMatr2,CvMat* proj
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
}
|
||||
__END__;
|
||||
return;
|
||||
}
|
||||
|
@ -1655,10 +1655,10 @@ CvBoost::predict( const CvMat* _sample, const CvMat* _missing,
|
||||
const int* cmap = data->cat_map->data.i;
|
||||
const int* cofs = data->cat_ofs->data.i;
|
||||
|
||||
cv::Mat sample = _sample;
|
||||
cv::Mat sample = cv::cvarrToMat(_sample);
|
||||
cv::Mat missing;
|
||||
if(!_missing)
|
||||
missing = _missing;
|
||||
missing = cv::cvarrToMat(_missing);
|
||||
|
||||
// if need, preprocess the input vector
|
||||
if( !raw_mode )
|
||||
|
@ -861,7 +861,7 @@ float CvRTrees::predict_prob( const Mat& _sample, const Mat& _missing) const
|
||||
|
||||
Mat CvRTrees::getVarImportance()
|
||||
{
|
||||
return Mat(get_var_importance());
|
||||
return cvarrToMat(get_var_importance());
|
||||
}
|
||||
|
||||
// End of file.
|
||||
|
@ -4142,7 +4142,7 @@ void CvDTree::read( CvFileStorage* fs, CvFileNode* node, CvDTreeTrainData* _data
|
||||
|
||||
Mat CvDTree::getVarImportance()
|
||||
{
|
||||
return Mat(get_var_importance());
|
||||
return cvarrToMat(get_var_importance());
|
||||
}
|
||||
|
||||
/* End of file. */
|
||||
|
@ -597,7 +597,7 @@ protected:
|
||||
ts->set_failed_test_info(cvtest::TS::FAIL_INVALID_TEST_DATA);
|
||||
}
|
||||
|
||||
Mat values = data.get_values();
|
||||
Mat values = cv::cvarrToMat(data.get_values());
|
||||
CV_Assert(values.cols == 58);
|
||||
int responseIndex = 57;
|
||||
|
||||
|
@ -528,7 +528,7 @@ void findDataMatrix(InputArray _image,
|
||||
{
|
||||
_dmtx.create(rc_i.original->rows, rc_i.original->cols, rc_i.original->type, i);
|
||||
Mat dst = _dmtx.getMat(i);
|
||||
Mat(rc_i.original).copyTo(dst);
|
||||
cv::cvarrToMat(rc_i.original).copyTo(dst);
|
||||
}
|
||||
cvReleaseMat(&rc_i.original);
|
||||
}
|
||||
|
@ -1611,17 +1611,17 @@ cvHaarDetectObjectsForROC( const CvArr* _img,
|
||||
if( use_ipp )
|
||||
{
|
||||
cv::Mat fsum(sum1.rows, sum1.cols, CV_32F, sum1.data.ptr, sum1.step);
|
||||
cv::Mat(&sum1).convertTo(fsum, CV_32F, 1, -(1<<24));
|
||||
cv::cvarrToMat(&sum1).convertTo(fsum, CV_32F, 1, -(1<<24));
|
||||
}
|
||||
else
|
||||
#endif
|
||||
cvSetImagesForHaarClassifierCascade( cascade, &sum1, &sqsum1, _tilted, 1. );
|
||||
|
||||
cv::Mat _norm1(&norm1), _mask1(&mask1);
|
||||
cv::Mat _norm1 = cv::cvarrToMat(&norm1), _mask1 = cv::cvarrToMat(&mask1);
|
||||
cv::parallel_for_(cv::Range(0, stripCount),
|
||||
cv::HaarDetectObjects_ScaleImage_Invoker(cascade,
|
||||
(((sz1.height + stripCount - 1)/stripCount + ystep-1)/ystep)*ystep,
|
||||
factor, cv::Mat(&sum1), cv::Mat(&sqsum1), &_norm1, &_mask1,
|
||||
factor, cv::cvarrToMat(&sum1), cv::cvarrToMat(&sqsum1), &_norm1, &_mask1,
|
||||
cv::Rect(equRect), allCandidates, rejectLevels, levelWeights, outputRejectLevels, &mtx));
|
||||
}
|
||||
}
|
||||
|
@ -253,7 +253,7 @@ static PyObject *iplimage_tostring(PyObject *self, PyObject *args)
|
||||
return NULL;
|
||||
if (i == NULL)
|
||||
return NULL;
|
||||
cv::Mat img(i);
|
||||
cv::Mat img = cvarrToMat(i);
|
||||
size_t esz = img.elemSize();
|
||||
int nrows = img.rows, ncols = img.cols;
|
||||
|
||||
|
@ -71,7 +71,7 @@ int randomType(RNG& rng, int typeMask, int minChannels, int maxChannels)
|
||||
{
|
||||
int channels = rng.uniform(minChannels, maxChannels+1);
|
||||
int depth = 0;
|
||||
CV_Assert((typeMask & DEPTH_MASK_ALL) != 0);
|
||||
CV_Assert((typeMask & _OutputArray::DEPTH_MASK_ALL) != 0);
|
||||
for(;;)
|
||||
{
|
||||
depth = rng.uniform(CV_8U, CV_64F+1);
|
||||
|
@ -1,6 +1,7 @@
|
||||
#include "opencv2/objdetect/objdetect.hpp"
|
||||
#include "opencv2/highgui/highgui.hpp"
|
||||
#include "opencv2/imgproc/imgproc.hpp"
|
||||
#include "opencv2/core/utility.hpp"
|
||||
|
||||
#include <cctype>
|
||||
#include <iostream>
|
||||
@ -124,7 +125,7 @@ int main( int argc, const char** argv )
|
||||
for(;;)
|
||||
{
|
||||
IplImage* iplImg = cvQueryFrame( capture );
|
||||
frame = iplImg;
|
||||
frame = cv::cvarrToMat(iplImg);
|
||||
if( frame.empty() )
|
||||
break;
|
||||
if( iplImg->origin == IPL_ORIGIN_TL )
|
||||
|
@ -1,6 +1,7 @@
|
||||
#include "opencv2/objdetect/objdetect.hpp"
|
||||
#include "opencv2/highgui/highgui.hpp"
|
||||
#include "opencv2/imgproc/imgproc.hpp"
|
||||
#include "opencv2/core/utility.hpp"
|
||||
|
||||
#include <cctype>
|
||||
#include <iostream>
|
||||
@ -120,7 +121,7 @@ int main( int argc, const char** argv )
|
||||
for(;;)
|
||||
{
|
||||
IplImage* iplImg = cvQueryFrame( capture );
|
||||
frame = iplImg;
|
||||
frame = cv::cvarrToMat(iplImg);
|
||||
if( frame.empty() )
|
||||
break;
|
||||
if( iplImg->origin == IPL_ORIGIN_TL )
|
||||
|
@ -1,5 +1,6 @@
|
||||
#include "opencv2/ml/ml.hpp"
|
||||
#include "opencv2/core/core_c.h"
|
||||
#include "opencv2/core/utility.hpp"
|
||||
#include <stdio.h>
|
||||
#include <map>
|
||||
|
||||
@ -21,7 +22,7 @@ static void help()
|
||||
|
||||
static int count_classes(CvMLData& data)
|
||||
{
|
||||
cv::Mat r(data.get_responses());
|
||||
cv::Mat r = cv::cvarrToMat(data.get_responses());
|
||||
std::map<int, int> rmap;
|
||||
int i, n = (int)r.total();
|
||||
for( i = 0; i < n; i++ )
|
||||
@ -42,7 +43,7 @@ static void print_result(float train_err, float test_err, const CvMat* _var_imp)
|
||||
|
||||
if (_var_imp)
|
||||
{
|
||||
cv::Mat var_imp(_var_imp), sorted_idx;
|
||||
cv::Mat var_imp = cv::cvarrToMat(_var_imp), sorted_idx;
|
||||
cv::sortIdx(var_imp, sorted_idx, CV_SORT_EVERY_ROW + CV_SORT_DESCENDING);
|
||||
|
||||
printf( "variable importance:\n" );
|
||||
|
@ -118,7 +118,7 @@ static void foundCorners(vector<CvPoint2D32f> *srcImagePoints,IplImage* source,
|
||||
cvNormalize(grayImage, grayImage, 0, 255, CV_MINMAX);
|
||||
cvThreshold( grayImage, grayImage, 26, 255, CV_THRESH_BINARY_INV);//25
|
||||
|
||||
Mat MgrayImage = grayImage;
|
||||
Mat MgrayImage = cv::cvarrToMat(grayImage);
|
||||
//For debug
|
||||
//MgrayImage = MgrayImage.clone();//deep copy
|
||||
vector<vector<Point> > contours;
|
||||
@ -184,7 +184,7 @@ static void foundCorners(vector<CvPoint2D32f> *srcImagePoints,IplImage* source,
|
||||
}
|
||||
srcImagePoints->at(3) = srcImagePoints_temp.at(index);
|
||||
|
||||
Mat Msource = source;
|
||||
Mat Msource = cv::cvarrToMat(source);
|
||||
stringstream ss;
|
||||
for(size_t i = 0 ; i<srcImagePoints_temp.size(); i++ )
|
||||
{
|
||||
|
@ -3,6 +3,7 @@
|
||||
#include "opencv2/imgproc/imgproc.hpp"
|
||||
#include "opencv2/highgui/highgui.hpp"
|
||||
#include "opencv2/flann/miniflann.hpp"
|
||||
#include "opencv2/core/utility.hpp"
|
||||
|
||||
using namespace cv; // all the new API is put into "cv" namespace. Export its content
|
||||
using namespace std;
|
||||
@ -32,7 +33,7 @@ int main( int argc, char** argv )
|
||||
fprintf(stderr, "Can not load image %s\n", imagename);
|
||||
return -1;
|
||||
}
|
||||
Mat img(iplimg); // cv::Mat replaces the CvMat and IplImage, but it's easy to convert
|
||||
Mat img = cv::cvarrToMat(iplimg); // cv::Mat replaces the CvMat and IplImage, but it's easy to convert
|
||||
// between the old and the new data structures (by default, only the header
|
||||
// is converted, while the data is shared)
|
||||
#else
|
||||
|
@ -4,6 +4,7 @@
|
||||
#include <opencv2/core/core.hpp>
|
||||
#include <opencv2/imgproc/imgproc.hpp>
|
||||
#include <opencv2/highgui/highgui.hpp>
|
||||
#include <opencv2/core/utility.hpp>"
|
||||
|
||||
using namespace cv; // The new C++ interface API is inside this namespace. Import it.
|
||||
using namespace std;
|
||||
@ -33,7 +34,7 @@ int main( int argc, char** argv )
|
||||
cerr << "Can not load image " << imagename << endl;
|
||||
return -1;
|
||||
}
|
||||
Mat I(IplI); // Convert to the new style container. Only header created. Image not copied.
|
||||
Mat I = cv::cvarrToMat(IplI); // Convert to the new style container. Only header created. Image not copied.
|
||||
#else
|
||||
Mat I = imread(imagename); // the newer cvLoadImage alternative, MATLAB-style function
|
||||
if( I.empty() ) // same as if( !I.data )
|
||||
|
@ -6,6 +6,7 @@
|
||||
#include "opencv2/objdetect/objdetect.hpp"
|
||||
#include "opencv2/highgui/highgui.hpp"
|
||||
#include "opencv2/imgproc/imgproc.hpp"
|
||||
#include "opencv2/core/utility.hpp"
|
||||
|
||||
#include <iostream>
|
||||
#include <stdio.h>
|
||||
@ -43,7 +44,7 @@ int main( void )
|
||||
{
|
||||
for(;;)
|
||||
{
|
||||
frame = cvQueryFrame( capture );
|
||||
frame = cv::cvarrToMat(cvQueryFrame( capture ));
|
||||
|
||||
//-- 3. Apply the classifier to the frame
|
||||
if( !frame.empty() )
|
||||
|
@ -6,6 +6,7 @@
|
||||
#include "opencv2/objdetect/objdetect.hpp"
|
||||
#include "opencv2/highgui/highgui.hpp"
|
||||
#include "opencv2/imgproc/imgproc.hpp"
|
||||
#include "opencv2/core/utility.hpp"
|
||||
|
||||
#include <iostream>
|
||||
#include <stdio.h>
|
||||
@ -43,7 +44,7 @@ int main( void )
|
||||
{
|
||||
for(;;)
|
||||
{
|
||||
frame = cvQueryFrame( capture );
|
||||
frame = cv::cvarrToMat(cvQueryFrame( capture ));
|
||||
|
||||
//-- 3. Apply the classifier to the frame
|
||||
if( !frame.empty() )
|
||||
|
Loading…
Reference in New Issue
Block a user