Merge pull request #11719 from alalek:update_autobuffer_api

This commit is contained in:
Alexander Alekhin 2018-07-05 10:01:15 +00:00
commit 0bb2c115aa
93 changed files with 379 additions and 351 deletions

View File

@ -1372,7 +1372,7 @@ int icvGetTraininDataFromVec( Mat& img, CvVecFile& userdata )
size_t elements_read = fread( &tmp, sizeof( tmp ), 1, userdata.input ); size_t elements_read = fread( &tmp, sizeof( tmp ), 1, userdata.input );
CV_Assert(elements_read == 1); CV_Assert(elements_read == 1);
elements_read = fread( vector, sizeof( short ), userdata.vecsize, userdata.input ); elements_read = fread(vector.data(), sizeof(short), userdata.vecsize, userdata.input);
CV_Assert(elements_read == (size_t)userdata.vecsize); CV_Assert(elements_read == (size_t)userdata.vecsize);
if( feof( userdata.input ) || userdata.last++ >= userdata.count ) if( feof( userdata.input ) || userdata.last++ >= userdata.count )

View File

@ -165,7 +165,7 @@ void CvHOGEvaluator::integralHistogram(const Mat &img, vector<Mat> &histogram, M
Mat qangle(gradSize, CV_8U); Mat qangle(gradSize, CV_8U);
AutoBuffer<int> mapbuf(gradSize.width + gradSize.height + 4); AutoBuffer<int> mapbuf(gradSize.width + gradSize.height + 4);
int* xmap = (int*)mapbuf + 1; int* xmap = mapbuf.data() + 1;
int* ymap = xmap + gradSize.width + 2; int* ymap = xmap + gradSize.width + 2;
const int borderType = (int)BORDER_REPLICATE; const int borderType = (int)BORDER_REPLICATE;
@ -177,7 +177,7 @@ void CvHOGEvaluator::integralHistogram(const Mat &img, vector<Mat> &histogram, M
int width = gradSize.width; int width = gradSize.width;
AutoBuffer<float> _dbuf(width*4); AutoBuffer<float> _dbuf(width*4);
float* dbuf = _dbuf; float* dbuf = _dbuf.data();
Mat Dx(1, width, CV_32F, dbuf); Mat Dx(1, width, CV_32F, dbuf);
Mat Dy(1, width, CV_32F, dbuf + width); Mat Dy(1, width, CV_32F, dbuf + width);
Mat Mag(1, width, CV_32F, dbuf + width*2); Mat Mag(1, width, CV_32F, dbuf + width*2);

View File

@ -383,7 +383,7 @@ CvDTreeNode* CvCascadeBoostTrainData::subsample_data( const CvMat* _subsample_id
int ci = get_var_type(vi); int ci = get_var_type(vi);
CV_Assert( ci < 0 ); CV_Assert( ci < 0 );
int *src_idx_buf = (int*)(uchar*)inn_buf; int *src_idx_buf = (int*)inn_buf.data();
float *src_val_buf = (float*)(src_idx_buf + sample_count); float *src_val_buf = (float*)(src_idx_buf + sample_count);
int* sample_indices_buf = (int*)(src_val_buf + sample_count); int* sample_indices_buf = (int*)(src_val_buf + sample_count);
const int* src_idx = 0; const int* src_idx = 0;
@ -423,7 +423,7 @@ CvDTreeNode* CvCascadeBoostTrainData::subsample_data( const CvMat* _subsample_id
} }
// subsample cv_lables // subsample cv_lables
const int* src_lbls = get_cv_labels(data_root, (int*)(uchar*)inn_buf); const int* src_lbls = get_cv_labels(data_root, (int*)inn_buf.data());
if (is_buf_16u) if (is_buf_16u)
{ {
unsigned short* udst = (unsigned short*)(buf->data.s + root->buf_idx*get_length_subbuf() + unsigned short* udst = (unsigned short*)(buf->data.s + root->buf_idx*get_length_subbuf() +
@ -440,7 +440,7 @@ CvDTreeNode* CvCascadeBoostTrainData::subsample_data( const CvMat* _subsample_id
} }
// subsample sample_indices // subsample sample_indices
const int* sample_idx_src = get_sample_indices(data_root, (int*)(uchar*)inn_buf); const int* sample_idx_src = get_sample_indices(data_root, (int*)inn_buf.data());
if (is_buf_16u) if (is_buf_16u)
{ {
unsigned short* sample_idx_dst = (unsigned short*)(buf->data.s + root->buf_idx*get_length_subbuf() + unsigned short* sample_idx_dst = (unsigned short*)(buf->data.s + root->buf_idx*get_length_subbuf() +
@ -815,7 +815,7 @@ struct FeatureIdxOnlyPrecalc : ParallelLoopBody
void operator()( const Range& range ) const void operator()( const Range& range ) const
{ {
cv::AutoBuffer<float> valCache(sample_count); cv::AutoBuffer<float> valCache(sample_count);
float* valCachePtr = (float*)valCache; float* valCachePtr = valCache.data();
for ( int fi = range.start; fi < range.end; fi++) for ( int fi = range.start; fi < range.end; fi++)
{ {
for( int si = 0; si < sample_count; si++ ) for( int si = 0; si < sample_count; si++ )
@ -1084,7 +1084,7 @@ void CvCascadeBoostTree::split_node_data( CvDTreeNode* node )
CvMat* buf = data->buf; CvMat* buf = data->buf;
size_t length_buf_row = data->get_length_subbuf(); size_t length_buf_row = data->get_length_subbuf();
cv::AutoBuffer<uchar> inn_buf(n*(3*sizeof(int)+sizeof(float))); cv::AutoBuffer<uchar> inn_buf(n*(3*sizeof(int)+sizeof(float)));
int* tempBuf = (int*)(uchar*)inn_buf; int* tempBuf = (int*)inn_buf.data();
bool splitInputData; bool splitInputData;
complete_node_dir(node); complete_node_dir(node);
@ -1398,7 +1398,7 @@ void CvCascadeBoost::update_weights( CvBoostTree* tree )
int inn_buf_size = ((params.boost_type == LOGIT) || (params.boost_type == GENTLE) ? n*sizeof(int) : 0) + int inn_buf_size = ((params.boost_type == LOGIT) || (params.boost_type == GENTLE) ? n*sizeof(int) : 0) +
( !tree ? n*sizeof(int) : 0 ); ( !tree ? n*sizeof(int) : 0 );
cv::AutoBuffer<uchar> inn_buf(inn_buf_size); cv::AutoBuffer<uchar> inn_buf(inn_buf_size);
uchar* cur_inn_buf_pos = (uchar*)inn_buf; uchar* cur_inn_buf_pos = inn_buf.data();
if ( (params.boost_type == LOGIT) || (params.boost_type == GENTLE) ) if ( (params.boost_type == LOGIT) || (params.boost_type == GENTLE) )
{ {
step = CV_IS_MAT_CONT(data->responses_copy->type) ? step = CV_IS_MAT_CONT(data->responses_copy->type) ?

View File

@ -168,7 +168,7 @@ CvBoostTree::try_split_node( CvDTreeNode* node )
// store the responses for the corresponding training samples // store the responses for the corresponding training samples
double* weak_eval = ensemble->get_weak_response()->data.db; double* weak_eval = ensemble->get_weak_response()->data.db;
cv::AutoBuffer<int> inn_buf(node->sample_count); cv::AutoBuffer<int> inn_buf(node->sample_count);
const int* labels = data->get_cv_labels( node, (int*)inn_buf ); const int* labels = data->get_cv_labels(node, inn_buf.data());
int i, count = node->sample_count; int i, count = node->sample_count;
double value = node->value; double value = node->value;
@ -191,7 +191,7 @@ CvBoostTree::calc_node_dir( CvDTreeNode* node )
if( data->get_var_type(vi) >= 0 ) // split on categorical var if( data->get_var_type(vi) >= 0 ) // split on categorical var
{ {
cv::AutoBuffer<int> inn_buf(n); cv::AutoBuffer<int> inn_buf(n);
const int* cat_labels = data->get_cat_var_data( node, vi, (int*)inn_buf ); const int* cat_labels = data->get_cat_var_data(node, vi, inn_buf.data());
const int* subset = node->split->subset; const int* subset = node->split->subset;
double sum = 0, sum_abs = 0; double sum = 0, sum_abs = 0;
@ -210,7 +210,7 @@ CvBoostTree::calc_node_dir( CvDTreeNode* node )
else // split on ordered var else // split on ordered var
{ {
cv::AutoBuffer<uchar> inn_buf(2*n*sizeof(int)+n*sizeof(float)); cv::AutoBuffer<uchar> inn_buf(2*n*sizeof(int)+n*sizeof(float));
float* values_buf = (float*)(uchar*)inn_buf; float* values_buf = (float*)inn_buf.data();
int* sorted_indices_buf = (int*)(values_buf + n); int* sorted_indices_buf = (int*)(values_buf + n);
int* sample_indices_buf = sorted_indices_buf + n; int* sample_indices_buf = sorted_indices_buf + n;
const float* values = 0; const float* values = 0;
@ -260,7 +260,7 @@ CvBoostTree::find_split_ord_class( CvDTreeNode* node, int vi, float init_quality
cv::AutoBuffer<uchar> inn_buf; cv::AutoBuffer<uchar> inn_buf;
if( !_ext_buf ) if( !_ext_buf )
inn_buf.allocate(n*(3*sizeof(int)+sizeof(float))); inn_buf.allocate(n*(3*sizeof(int)+sizeof(float)));
uchar* ext_buf = _ext_buf ? _ext_buf : (uchar*)inn_buf; uchar* ext_buf = _ext_buf ? _ext_buf : inn_buf.data();
float* values_buf = (float*)ext_buf; float* values_buf = (float*)ext_buf;
int* sorted_indices_buf = (int*)(values_buf + n); int* sorted_indices_buf = (int*)(values_buf + n);
int* sample_indices_buf = sorted_indices_buf + n; int* sample_indices_buf = sorted_indices_buf + n;
@ -369,7 +369,7 @@ CvBoostTree::find_split_cat_class( CvDTreeNode* node, int vi, float init_quality
cv::AutoBuffer<uchar> inn_buf((2*mi+3)*sizeof(double) + mi*sizeof(double*)); cv::AutoBuffer<uchar> inn_buf((2*mi+3)*sizeof(double) + mi*sizeof(double*));
if( !_ext_buf) if( !_ext_buf)
inn_buf.allocate( base_size + 2*n*sizeof(int) ); inn_buf.allocate( base_size + 2*n*sizeof(int) );
uchar* base_buf = (uchar*)inn_buf; uchar* base_buf = inn_buf.data();
uchar* ext_buf = _ext_buf ? _ext_buf : base_buf + base_size; uchar* ext_buf = _ext_buf ? _ext_buf : base_buf + base_size;
int* cat_labels_buf = (int*)ext_buf; int* cat_labels_buf = (int*)ext_buf;
@ -490,7 +490,7 @@ CvBoostTree::find_split_ord_reg( CvDTreeNode* node, int vi, float init_quality,
cv::AutoBuffer<uchar> inn_buf; cv::AutoBuffer<uchar> inn_buf;
if( !_ext_buf ) if( !_ext_buf )
inn_buf.allocate(2*n*(sizeof(int)+sizeof(float))); inn_buf.allocate(2*n*(sizeof(int)+sizeof(float)));
uchar* ext_buf = _ext_buf ? _ext_buf : (uchar*)inn_buf; uchar* ext_buf = _ext_buf ? _ext_buf : inn_buf.data();
float* values_buf = (float*)ext_buf; float* values_buf = (float*)ext_buf;
int* indices_buf = (int*)(values_buf + n); int* indices_buf = (int*)(values_buf + n);
@ -559,7 +559,7 @@ CvBoostTree::find_split_cat_reg( CvDTreeNode* node, int vi, float init_quality,
cv::AutoBuffer<uchar> inn_buf(base_size); cv::AutoBuffer<uchar> inn_buf(base_size);
if( !_ext_buf ) if( !_ext_buf )
inn_buf.allocate(base_size + n*(2*sizeof(int) + sizeof(float))); inn_buf.allocate(base_size + n*(2*sizeof(int) + sizeof(float)));
uchar* base_buf = (uchar*)inn_buf; uchar* base_buf = inn_buf.data();
uchar* ext_buf = _ext_buf ? _ext_buf : base_buf + base_size; uchar* ext_buf = _ext_buf ? _ext_buf : base_buf + base_size;
int* cat_labels_buf = (int*)ext_buf; int* cat_labels_buf = (int*)ext_buf;
@ -652,7 +652,7 @@ CvBoostTree::find_surrogate_split_ord( CvDTreeNode* node, int vi, uchar* _ext_bu
cv::AutoBuffer<uchar> inn_buf; cv::AutoBuffer<uchar> inn_buf;
if( !_ext_buf ) if( !_ext_buf )
inn_buf.allocate(n*(2*sizeof(int)+sizeof(float))); inn_buf.allocate(n*(2*sizeof(int)+sizeof(float)));
uchar* ext_buf = _ext_buf ? _ext_buf : (uchar*)inn_buf; uchar* ext_buf = _ext_buf ? _ext_buf : inn_buf.data();
float* values_buf = (float*)ext_buf; float* values_buf = (float*)ext_buf;
int* indices_buf = (int*)(values_buf + n); int* indices_buf = (int*)(values_buf + n);
int* sample_indices_buf = indices_buf + n; int* sample_indices_buf = indices_buf + n;
@ -733,7 +733,7 @@ CvBoostTree::find_surrogate_split_cat( CvDTreeNode* node, int vi, uchar* _ext_bu
cv::AutoBuffer<uchar> inn_buf(base_size); cv::AutoBuffer<uchar> inn_buf(base_size);
if( !_ext_buf ) if( !_ext_buf )
inn_buf.allocate(base_size + n*sizeof(int)); inn_buf.allocate(base_size + n*sizeof(int));
uchar* ext_buf = _ext_buf ? _ext_buf : (uchar*)inn_buf; uchar* ext_buf = _ext_buf ? _ext_buf : inn_buf.data();
int* cat_labels_buf = (int*)ext_buf; int* cat_labels_buf = (int*)ext_buf;
const int* cat_labels = data->get_cat_var_data(node, vi, cat_labels_buf); const int* cat_labels = data->get_cat_var_data(node, vi, cat_labels_buf);
@ -797,7 +797,7 @@ CvBoostTree::calc_node_value( CvDTreeNode* node )
int i, n = node->sample_count; int i, n = node->sample_count;
const double* weights = ensemble->get_weights()->data.db; const double* weights = ensemble->get_weights()->data.db;
cv::AutoBuffer<uchar> inn_buf(n*(sizeof(int) + ( data->is_classifier ? sizeof(int) : sizeof(int) + sizeof(float)))); cv::AutoBuffer<uchar> inn_buf(n*(sizeof(int) + ( data->is_classifier ? sizeof(int) : sizeof(int) + sizeof(float))));
int* labels_buf = (int*)(uchar*)inn_buf; int* labels_buf = (int*)inn_buf.data();
const int* labels = data->get_cv_labels(node, labels_buf); const int* labels = data->get_cv_labels(node, labels_buf);
double* subtree_weights = ensemble->get_subtree_weights()->data.db; double* subtree_weights = ensemble->get_subtree_weights()->data.db;
double rcw[2] = {0,0}; double rcw[2] = {0,0};
@ -1147,7 +1147,7 @@ CvBoost::update_weights( CvBoostTree* tree )
_buf_size += data->get_length_subbuf()*(sizeof(float)+sizeof(uchar)); _buf_size += data->get_length_subbuf()*(sizeof(float)+sizeof(uchar));
} }
inn_buf.allocate(_buf_size); inn_buf.allocate(_buf_size);
uchar* cur_buf_pos = (uchar*)inn_buf; uchar* cur_buf_pos = inn_buf.data();
if ( (params.boost_type == LOGIT) || (params.boost_type == GENTLE) ) if ( (params.boost_type == LOGIT) || (params.boost_type == GENTLE) )
{ {

View File

@ -780,7 +780,7 @@ CvDTreeNode* CvDTreeTrainData::subsample_data( const CvMat* _subsample_idx )
if( ci >= 0 || vi >= var_count ) if( ci >= 0 || vi >= var_count )
{ {
int num_valid = 0; int num_valid = 0;
const int* src = CvDTreeTrainData::get_cat_var_data( data_root, vi, (int*)(uchar*)inn_buf ); const int* src = CvDTreeTrainData::get_cat_var_data(data_root, vi, (int*)inn_buf.data());
if (is_buf_16u) if (is_buf_16u)
{ {
@ -810,7 +810,7 @@ CvDTreeNode* CvDTreeTrainData::subsample_data( const CvMat* _subsample_idx )
} }
else else
{ {
int *src_idx_buf = (int*)(uchar*)inn_buf; int *src_idx_buf = (int*)inn_buf.data();
float *src_val_buf = (float*)(src_idx_buf + sample_count); float *src_val_buf = (float*)(src_idx_buf + sample_count);
int* sample_indices_buf = (int*)(src_val_buf + sample_count); int* sample_indices_buf = (int*)(src_val_buf + sample_count);
const int* src_idx = 0; const int* src_idx = 0;
@ -870,7 +870,7 @@ CvDTreeNode* CvDTreeTrainData::subsample_data( const CvMat* _subsample_idx )
} }
} }
// sample indices subsampling // sample indices subsampling
const int* sample_idx_src = get_sample_indices(data_root, (int*)(uchar*)inn_buf); const int* sample_idx_src = get_sample_indices(data_root, (int*)inn_buf.data());
if (is_buf_16u) if (is_buf_16u)
{ {
unsigned short* sample_idx_dst = (unsigned short*)(buf->data.s + root->buf_idx*get_length_subbuf() + unsigned short* sample_idx_dst = (unsigned short*)(buf->data.s + root->buf_idx*get_length_subbuf() +
@ -943,7 +943,7 @@ void CvDTreeTrainData::get_vectors( const CvMat* _subsample_idx,
{ {
float* dst = values + vi; float* dst = values + vi;
uchar* m = missing ? missing + vi : 0; uchar* m = missing ? missing + vi : 0;
const int* src = get_cat_var_data(data_root, vi, (int*)(uchar*)inn_buf); const int* src = get_cat_var_data(data_root, vi, (int*)inn_buf.data());
for( i = 0; i < count; i++, dst += var_count ) for( i = 0; i < count; i++, dst += var_count )
{ {
@ -962,7 +962,7 @@ void CvDTreeTrainData::get_vectors( const CvMat* _subsample_idx,
float* dst = values + vi; float* dst = values + vi;
uchar* m = missing ? missing + vi : 0; uchar* m = missing ? missing + vi : 0;
int count1 = data_root->get_num_valid(vi); int count1 = data_root->get_num_valid(vi);
float *src_val_buf = (float*)(uchar*)inn_buf; float *src_val_buf = (float*)inn_buf.data();
int* src_idx_buf = (int*)(src_val_buf + sample_count); int* src_idx_buf = (int*)(src_val_buf + sample_count);
int* sample_indices_buf = src_idx_buf + sample_count; int* sample_indices_buf = src_idx_buf + sample_count;
const float *src_val = 0; const float *src_val = 0;
@ -999,7 +999,7 @@ void CvDTreeTrainData::get_vectors( const CvMat* _subsample_idx,
{ {
if( is_classifier ) if( is_classifier )
{ {
const int* src = get_class_labels(data_root, (int*)(uchar*)inn_buf); const int* src = get_class_labels(data_root, (int*)inn_buf.data());
for( i = 0; i < count; i++ ) for( i = 0; i < count; i++ )
{ {
int idx = sidx ? sidx[i] : i; int idx = sidx ? sidx[i] : i;
@ -1010,7 +1010,7 @@ void CvDTreeTrainData::get_vectors( const CvMat* _subsample_idx,
} }
else else
{ {
float* val_buf = (float*)(uchar*)inn_buf; float* val_buf = (float*)inn_buf.data();
int* sample_idx_buf = (int*)(val_buf + sample_count); int* sample_idx_buf = (int*)(val_buf + sample_count);
const float* _values = get_ord_responses(data_root, val_buf, sample_idx_buf); const float* _values = get_ord_responses(data_root, val_buf, sample_idx_buf);
for( i = 0; i < count; i++ ) for( i = 0; i < count; i++ )
@ -1780,7 +1780,7 @@ double CvDTree::calc_node_dir( CvDTreeNode* node )
if( data->get_var_type(vi) >= 0 ) // split on categorical var if( data->get_var_type(vi) >= 0 ) // split on categorical var
{ {
cv::AutoBuffer<int> inn_buf(n*(!data->have_priors ? 1 : 2)); cv::AutoBuffer<int> inn_buf(n*(!data->have_priors ? 1 : 2));
int* labels_buf = (int*)inn_buf; int* labels_buf = inn_buf.data();
const int* labels = data->get_cat_var_data( node, vi, labels_buf ); const int* labels = data->get_cat_var_data( node, vi, labels_buf );
const int* subset = node->split->subset; const int* subset = node->split->subset;
if( !data->have_priors ) if( !data->have_priors )
@ -1824,7 +1824,7 @@ double CvDTree::calc_node_dir( CvDTreeNode* node )
int split_point = node->split->ord.split_point; int split_point = node->split->ord.split_point;
int n1 = node->get_num_valid(vi); int n1 = node->get_num_valid(vi);
cv::AutoBuffer<uchar> inn_buf(n*(sizeof(int)*(data->have_priors ? 3 : 2) + sizeof(float))); cv::AutoBuffer<uchar> inn_buf(n*(sizeof(int)*(data->have_priors ? 3 : 2) + sizeof(float)));
float* val_buf = (float*)(uchar*)inn_buf; float* val_buf = (float*)inn_buf.data();
int* sorted_buf = (int*)(val_buf + n); int* sorted_buf = (int*)(val_buf + n);
int* sample_idx_buf = sorted_buf + n; int* sample_idx_buf = sorted_buf + n;
const float* val = 0; const float* val = 0;
@ -1929,16 +1929,16 @@ void DTreeBestSplitFinder::operator()(const BlockedRange& range)
if( data->is_classifier ) if( data->is_classifier )
{ {
if( ci >= 0 ) if( ci >= 0 )
res = tree->find_split_cat_class( node, vi, bestSplit->quality, split, (uchar*)inn_buf ); res = tree->find_split_cat_class( node, vi, bestSplit->quality, split, inn_buf.data() );
else else
res = tree->find_split_ord_class( node, vi, bestSplit->quality, split, (uchar*)inn_buf ); res = tree->find_split_ord_class( node, vi, bestSplit->quality, split, inn_buf.data() );
} }
else else
{ {
if( ci >= 0 ) if( ci >= 0 )
res = tree->find_split_cat_reg( node, vi, bestSplit->quality, split, (uchar*)inn_buf ); res = tree->find_split_cat_reg( node, vi, bestSplit->quality, split, inn_buf.data() );
else else
res = tree->find_split_ord_reg( node, vi, bestSplit->quality, split, (uchar*)inn_buf ); res = tree->find_split_ord_reg( node, vi, bestSplit->quality, split, inn_buf.data() );
} }
if( res && bestSplit->quality < split->quality ) if( res && bestSplit->quality < split->quality )
@ -1982,7 +1982,7 @@ CvDTreeSplit* CvDTree::find_split_ord_class( CvDTreeNode* node, int vi,
cv::AutoBuffer<uchar> inn_buf(base_size); cv::AutoBuffer<uchar> inn_buf(base_size);
if( !_ext_buf ) if( !_ext_buf )
inn_buf.allocate(base_size + n*(3*sizeof(int)+sizeof(float))); inn_buf.allocate(base_size + n*(3*sizeof(int)+sizeof(float)));
uchar* base_buf = (uchar*)inn_buf; uchar* base_buf = inn_buf.data();
uchar* ext_buf = _ext_buf ? _ext_buf : base_buf + base_size; uchar* ext_buf = _ext_buf ? _ext_buf : base_buf + base_size;
float* values_buf = (float*)ext_buf; float* values_buf = (float*)ext_buf;
int* sorted_indices_buf = (int*)(values_buf + n); int* sorted_indices_buf = (int*)(values_buf + n);
@ -2096,7 +2096,7 @@ void CvDTree::cluster_categories( const int* vectors, int n, int m,
int iters = 0, max_iters = 100; int iters = 0, max_iters = 100;
int i, j, idx; int i, j, idx;
cv::AutoBuffer<double> buf(n + k); cv::AutoBuffer<double> buf(n + k);
double *v_weights = buf, *c_weights = buf + n; double *v_weights = buf.data(), *c_weights = buf.data() + n;
bool modified = true; bool modified = true;
RNG* r = data->rng; RNG* r = data->rng;
@ -2201,7 +2201,7 @@ CvDTreeSplit* CvDTree::find_split_cat_class( CvDTreeNode* node, int vi, float in
cv::AutoBuffer<uchar> inn_buf(base_size); cv::AutoBuffer<uchar> inn_buf(base_size);
if( !_ext_buf ) if( !_ext_buf )
inn_buf.allocate(base_size + 2*n*sizeof(int)); inn_buf.allocate(base_size + 2*n*sizeof(int));
uchar* base_buf = (uchar*)inn_buf; uchar* base_buf = inn_buf.data();
uchar* ext_buf = _ext_buf ? _ext_buf : base_buf + base_size; uchar* ext_buf = _ext_buf ? _ext_buf : base_buf + base_size;
int* lc = (int*)base_buf; int* lc = (int*)base_buf;
@ -2383,7 +2383,7 @@ CvDTreeSplit* CvDTree::find_split_ord_reg( CvDTreeNode* node, int vi, float init
cv::AutoBuffer<uchar> inn_buf; cv::AutoBuffer<uchar> inn_buf;
if( !_ext_buf ) if( !_ext_buf )
inn_buf.allocate(2*n*(sizeof(int) + sizeof(float))); inn_buf.allocate(2*n*(sizeof(int) + sizeof(float)));
uchar* ext_buf = _ext_buf ? _ext_buf : (uchar*)inn_buf; uchar* ext_buf = _ext_buf ? _ext_buf : inn_buf.data();
float* values_buf = (float*)ext_buf; float* values_buf = (float*)ext_buf;
int* sorted_indices_buf = (int*)(values_buf + n); int* sorted_indices_buf = (int*)(values_buf + n);
int* sample_indices_buf = sorted_indices_buf + n; int* sample_indices_buf = sorted_indices_buf + n;
@ -2443,7 +2443,7 @@ CvDTreeSplit* CvDTree::find_split_cat_reg( CvDTreeNode* node, int vi, float init
cv::AutoBuffer<uchar> inn_buf(base_size); cv::AutoBuffer<uchar> inn_buf(base_size);
if( !_ext_buf ) if( !_ext_buf )
inn_buf.allocate(base_size + n*(2*sizeof(int) + sizeof(float))); inn_buf.allocate(base_size + n*(2*sizeof(int) + sizeof(float)));
uchar* base_buf = (uchar*)inn_buf; uchar* base_buf = inn_buf.data();
uchar* ext_buf = _ext_buf ? _ext_buf : base_buf + base_size; uchar* ext_buf = _ext_buf ? _ext_buf : base_buf + base_size;
int* labels_buf = (int*)ext_buf; int* labels_buf = (int*)ext_buf;
const int* labels = data->get_cat_var_data(node, vi, labels_buf); const int* labels = data->get_cat_var_data(node, vi, labels_buf);
@ -2534,7 +2534,7 @@ CvDTreeSplit* CvDTree::find_surrogate_split_ord( CvDTreeNode* node, int vi, ucha
cv::AutoBuffer<uchar> inn_buf; cv::AutoBuffer<uchar> inn_buf;
if( !_ext_buf ) if( !_ext_buf )
inn_buf.allocate( n*(sizeof(int)*(data->have_priors ? 3 : 2) + sizeof(float)) ); inn_buf.allocate( n*(sizeof(int)*(data->have_priors ? 3 : 2) + sizeof(float)) );
uchar* ext_buf = _ext_buf ? _ext_buf : (uchar*)inn_buf; uchar* ext_buf = _ext_buf ? _ext_buf : inn_buf.data();
float* values_buf = (float*)ext_buf; float* values_buf = (float*)ext_buf;
int* sorted_indices_buf = (int*)(values_buf + n); int* sorted_indices_buf = (int*)(values_buf + n);
int* sample_indices_buf = sorted_indices_buf + n; int* sample_indices_buf = sorted_indices_buf + n;
@ -2658,7 +2658,7 @@ CvDTreeSplit* CvDTree::find_surrogate_split_cat( CvDTreeNode* node, int vi, ucha
cv::AutoBuffer<uchar> inn_buf(base_size); cv::AutoBuffer<uchar> inn_buf(base_size);
if( !_ext_buf ) if( !_ext_buf )
inn_buf.allocate(base_size + n*(sizeof(int) + (data->have_priors ? sizeof(int) : 0))); inn_buf.allocate(base_size + n*(sizeof(int) + (data->have_priors ? sizeof(int) : 0)));
uchar* base_buf = (uchar*)inn_buf; uchar* base_buf = inn_buf.data();
uchar* ext_buf = _ext_buf ? _ext_buf : base_buf + base_size; uchar* ext_buf = _ext_buf ? _ext_buf : base_buf + base_size;
int* labels_buf = (int*)ext_buf; int* labels_buf = (int*)ext_buf;
@ -2758,7 +2758,7 @@ void CvDTree::calc_node_value( CvDTreeNode* node )
int base_size = data->is_classifier ? m*cv_n*sizeof(int) : 2*cv_n*sizeof(double)+cv_n*sizeof(int); int base_size = data->is_classifier ? m*cv_n*sizeof(int) : 2*cv_n*sizeof(double)+cv_n*sizeof(int);
int ext_size = n*(sizeof(int) + (data->is_classifier ? sizeof(int) : sizeof(int)+sizeof(float))); int ext_size = n*(sizeof(int) + (data->is_classifier ? sizeof(int) : sizeof(int)+sizeof(float)));
cv::AutoBuffer<uchar> inn_buf(base_size + ext_size); cv::AutoBuffer<uchar> inn_buf(base_size + ext_size);
uchar* base_buf = (uchar*)inn_buf; uchar* base_buf = inn_buf.data();
uchar* ext_buf = base_buf + base_size; uchar* ext_buf = base_buf + base_size;
int* cv_labels_buf = (int*)ext_buf; int* cv_labels_buf = (int*)ext_buf;
@ -2961,7 +2961,7 @@ void CvDTree::complete_node_dir( CvDTreeNode* node )
if( data->get_var_type(vi) >= 0 ) // split on categorical var if( data->get_var_type(vi) >= 0 ) // split on categorical var
{ {
int* labels_buf = (int*)(uchar*)inn_buf; int* labels_buf = (int*)inn_buf.data();
const int* labels = data->get_cat_var_data(node, vi, labels_buf); const int* labels = data->get_cat_var_data(node, vi, labels_buf);
const int* subset = split->subset; const int* subset = split->subset;
@ -2980,7 +2980,7 @@ void CvDTree::complete_node_dir( CvDTreeNode* node )
} }
else // split on ordered var else // split on ordered var
{ {
float* values_buf = (float*)(uchar*)inn_buf; float* values_buf = (float*)inn_buf.data();
int* sorted_indices_buf = (int*)(values_buf + n); int* sorted_indices_buf = (int*)(values_buf + n);
int* sample_indices_buf = sorted_indices_buf + n; int* sample_indices_buf = sorted_indices_buf + n;
const float* values = 0; const float* values = 0;
@ -3042,7 +3042,7 @@ void CvDTree::split_node_data( CvDTreeNode* node )
CvMat* buf = data->buf; CvMat* buf = data->buf;
size_t length_buf_row = data->get_length_subbuf(); size_t length_buf_row = data->get_length_subbuf();
cv::AutoBuffer<uchar> inn_buf(n*(3*sizeof(int) + sizeof(float))); cv::AutoBuffer<uchar> inn_buf(n*(3*sizeof(int) + sizeof(float)));
int* temp_buf = (int*)(uchar*)inn_buf; int* temp_buf = (int*)inn_buf.data();
complete_node_dir(node); complete_node_dir(node);

View File

@ -1264,7 +1264,7 @@ icvCleanFoundConnectedQuads( int quad_count, CvCBQuad **quad_group, CvSize patte
// get bounding rectangle // get bounding rectangle
CvPoint2D32f temp = centers[skip]; // temporarily make index 'skip' the same as CvPoint2D32f temp = centers[skip]; // temporarily make index 'skip' the same as
centers[skip] = center; // pattern center (so it is not counted for convex hull) centers[skip] = center; // pattern center (so it is not counted for convex hull)
CvMat pointMat = cvMat(1, quad_count, CV_32FC2, centers); CvMat pointMat = cvMat(1, quad_count, CV_32FC2, centers.data());
CvSeq *hull = cvConvexHull2( &pointMat, temp_storage, CV_CLOCKWISE, 1 ); CvSeq *hull = cvConvexHull2( &pointMat, temp_storage, CV_CLOCKWISE, 1 );
centers[skip] = temp; centers[skip] = temp;
double hull_area = fabs(cvContourArea(hull, CV_WHOLE_SEQ)); double hull_area = fabs(cvContourArea(hull, CV_WHOLE_SEQ));

View File

@ -104,7 +104,7 @@ public:
int maxAttempts=1000 ) const int maxAttempts=1000 ) const
{ {
cv::AutoBuffer<int> _idx(modelPoints); cv::AutoBuffer<int> _idx(modelPoints);
int* idx = _idx; int* idx = _idx.data();
int i = 0, j, k, iters = 0; int i = 0, j, k, iters = 0;
int d1 = m1.channels() > 1 ? m1.channels() : m1.cols; int d1 = m1.channels() > 1 ? m1.channels() : m1.cols;
int d2 = m2.channels() > 1 ? m2.channels() : m2.cols; int d2 = m2.channels() > 1 ? m2.channels() : m2.cols;

View File

@ -2451,7 +2451,7 @@ void cv::validateDisparity( InputOutputArray _disp, InputArray _cost, int minDis
int minD = minDisparity, maxD = minDisparity + numberOfDisparities; int minD = minDisparity, maxD = minDisparity + numberOfDisparities;
int x, minX1 = std::max(maxD, 0), maxX1 = cols + std::min(minD, 0); int x, minX1 = std::max(maxD, 0), maxX1 = cols + std::min(minD, 0);
AutoBuffer<int> _disp2buf(cols*2); AutoBuffer<int> _disp2buf(cols*2);
int* disp2buf = _disp2buf; int* disp2buf = _disp2buf.data();
int* disp2cost = disp2buf + cols; int* disp2cost = disp2buf + cols;
const int DISP_SHIFT = 4, DISP_SCALE = 1 << DISP_SHIFT; const int DISP_SHIFT = 4, DISP_SCALE = 1 << DISP_SHIFT;
int INVALID_DISP = minD - 1, INVALID_DISP_SCALED = INVALID_DISP*DISP_SCALE; int INVALID_DISP = minD - 1, INVALID_DISP_SCALED = INVALID_DISP*DISP_SCALE;

View File

@ -66,6 +66,7 @@ struct CheckContext {
{ CV__CHECK_FUNCTION, CV__CHECK_FILENAME, __LINE__, testOp, message, p1_str, p2_str } { CV__CHECK_FUNCTION, CV__CHECK_FILENAME, __LINE__, testOp, message, p1_str, p2_str }
CV_EXPORTS void CV_NORETURN check_failed_auto(const int v1, const int v2, const CheckContext& ctx); CV_EXPORTS void CV_NORETURN check_failed_auto(const int v1, const int v2, const CheckContext& ctx);
CV_EXPORTS void CV_NORETURN check_failed_auto(const size_t v1, const size_t v2, const CheckContext& ctx);
CV_EXPORTS void CV_NORETURN check_failed_auto(const float v1, const float v2, const CheckContext& ctx); CV_EXPORTS void CV_NORETURN check_failed_auto(const float v1, const float v2, const CheckContext& ctx);
CV_EXPORTS void CV_NORETURN check_failed_auto(const double v1, const double v2, const CheckContext& ctx); CV_EXPORTS void CV_NORETURN check_failed_auto(const double v1, const double v2, const CheckContext& ctx);
CV_EXPORTS void CV_NORETURN check_failed_MatDepth(const int v1, const int v2, const CheckContext& ctx); CV_EXPORTS void CV_NORETURN check_failed_MatDepth(const int v1, const int v2, const CheckContext& ctx);
@ -73,6 +74,7 @@ CV_EXPORTS void CV_NORETURN check_failed_MatType(const int v1, const int v2, con
CV_EXPORTS void CV_NORETURN check_failed_MatChannels(const int v1, const int v2, const CheckContext& ctx); CV_EXPORTS void CV_NORETURN check_failed_MatChannels(const int v1, const int v2, const CheckContext& ctx);
CV_EXPORTS void CV_NORETURN check_failed_auto(const int v, const CheckContext& ctx); CV_EXPORTS void CV_NORETURN check_failed_auto(const int v, const CheckContext& ctx);
CV_EXPORTS void CV_NORETURN check_failed_auto(const size_t v, const CheckContext& ctx);
CV_EXPORTS void CV_NORETURN check_failed_auto(const float v, const CheckContext& ctx); CV_EXPORTS void CV_NORETURN check_failed_auto(const float v, const CheckContext& ctx);
CV_EXPORTS void CV_NORETURN check_failed_auto(const double v, const CheckContext& ctx); CV_EXPORTS void CV_NORETURN check_failed_auto(const double v, const CheckContext& ctx);
CV_EXPORTS void CV_NORETURN check_failed_MatDepth(const int v, const CheckContext& ctx); CV_EXPORTS void CV_NORETURN check_failed_MatDepth(const int v, const CheckContext& ctx);
@ -120,15 +122,35 @@ CV_EXPORTS void CV_NORETURN check_failed_MatChannels(const int v, const CheckCon
#define CV_CheckChannelsEQ(c1, c2, msg) CV__CHECK(_, EQ, MatChannels, c1, c2, #c1, #c2, msg) #define CV_CheckChannelsEQ(c1, c2, msg) CV__CHECK(_, EQ, MatChannels, c1, c2, #c1, #c2, msg)
/// Example: type == CV_8UC1 || type == CV_8UC3 /// Example: type == CV_8UC1 || type == CV_8UC3
#define CV_CheckType(t, test_expr, msg) CV__CHECK_CUSTOM_TEST(_, MatType, t, (test_expr), #t, #test_expr, msg) #define CV_CheckType(t, test_expr, msg) CV__CHECK_CUSTOM_TEST(_, MatType, t, (test_expr), #t, #test_expr, msg)
/// Example: depth == CV_32F || depth == CV_64F /// Example: depth == CV_32F || depth == CV_64F
#define CV_CheckDepth(t, test_expr, msg) CV__CHECK_CUSTOM_TEST(_, MatDepth, t, (test_expr), #t, #test_expr, msg) #define CV_CheckDepth(t, test_expr, msg) CV__CHECK_CUSTOM_TEST(_, MatDepth, t, (test_expr), #t, #test_expr, msg)
/// Example: v == A || v == B
#define CV_Check(v, test_expr, msg) CV__CHECK_CUSTOM_TEST(_, auto, v, (test_expr), #v, #test_expr, msg)
/// Some complex conditions: CV_Check(src2, src2.empty() || (src2.type() == src1.type() && src2.size() == src1.size()), "src2 should have same size/type as src1") /// Some complex conditions: CV_Check(src2, src2.empty() || (src2.type() == src1.type() && src2.size() == src1.size()), "src2 should have same size/type as src1")
// TODO define pretty-printers: #define CV_Check(v, test_expr, msg) CV__CHECK_CUSTOM_TEST(_, auto, v, (test_expr), #v, #test_expr, msg) // TODO define pretty-printers
#ifndef NDEBUG
#define CV_DbgCheck(v, test_expr, msg) CV__CHECK_CUSTOM_TEST(_, auto, v, (test_expr), #v, #test_expr, msg)
#define CV_DbgCheckEQ(v1, v2, msg) CV__CHECK(_, EQ, auto, v1, v2, #v1, #v2, msg)
#define CV_DbgCheckNE(v1, v2, msg) CV__CHECK(_, NE, auto, v1, v2, #v1, #v2, msg)
#define CV_DbgCheckLE(v1, v2, msg) CV__CHECK(_, LE, auto, v1, v2, #v1, #v2, msg)
#define CV_DbgCheckLT(v1, v2, msg) CV__CHECK(_, LT, auto, v1, v2, #v1, #v2, msg)
#define CV_DbgCheckGE(v1, v2, msg) CV__CHECK(_, GE, auto, v1, v2, #v1, #v2, msg)
#define CV_DbgCheckGT(v1, v2, msg) CV__CHECK(_, GT, auto, v1, v2, #v1, #v2, msg)
#else
#define CV_DbgCheck(v, test_expr, msg) do { } while (0)
#define CV_DbgCheckEQ(v1, v2, msg) do { } while (0)
#define CV_DbgCheckNE(v1, v2, msg) do { } while (0)
#define CV_DbgCheckLE(v1, v2, msg) do { } while (0)
#define CV_DbgCheckLT(v1, v2, msg) do { } while (0)
#define CV_DbgCheckGE(v1, v2, msg) do { } while (0)
#define CV_DbgCheckGT(v1, v2, msg) do { } while (0)
#endif
} // namespace } // namespace

View File

@ -255,6 +255,7 @@ Cv64suf;
#ifdef __OPENCV_BUILD #ifdef __OPENCV_BUILD
# define DISABLE_OPENCV_24_COMPATIBILITY # define DISABLE_OPENCV_24_COMPATIBILITY
# define OPENCV_DISABLE_DEPRECATED_COMPATIBILITY
#endif #endif
#ifdef CVAPI_EXPORTS #ifdef CVAPI_EXPORTS

View File

@ -143,9 +143,21 @@ public:
//! returns the current buffer size //! returns the current buffer size
size_t size() const; size_t size() const;
//! returns pointer to the real buffer, stack-allocated or heap-allocated //! returns pointer to the real buffer, stack-allocated or heap-allocated
operator _Tp* (); inline _Tp* data() { return ptr; }
//! returns read-only pointer to the real buffer, stack-allocated or heap-allocated //! returns read-only pointer to the real buffer, stack-allocated or heap-allocated
operator const _Tp* () const; inline const _Tp* data() const { return ptr; }
#if !defined(OPENCV_DISABLE_DEPRECATED_COMPATIBILITY) // use to .data() calls instead
//! returns pointer to the real buffer, stack-allocated or heap-allocated
operator _Tp* () { return ptr; }
//! returns read-only pointer to the real buffer, stack-allocated or heap-allocated
operator const _Tp* () const { return ptr; }
#else
//! returns a reference to the element at specified location. No bounds checking is performed in Release builds.
inline _Tp& operator[] (size_t i) { CV_DbgCheckLT(i, sz, "out of range"); return ptr[i]; }
//! returns a reference to the element at specified location. No bounds checking is performed in Release builds.
inline const _Tp& operator[] (size_t i) const { CV_DbgCheckLT(i, sz, "out of range"); return ptr[i]; }
#endif
protected: protected:
//! pointer to the real buffer, can point to buf if the buffer is small enough //! pointer to the real buffer, can point to buf if the buffer is small enough
@ -1064,14 +1076,6 @@ template<typename _Tp, size_t fixed_size> inline size_t
AutoBuffer<_Tp, fixed_size>::size() const AutoBuffer<_Tp, fixed_size>::size() const
{ return sz; } { return sz; }
template<typename _Tp, size_t fixed_size> inline
AutoBuffer<_Tp, fixed_size>::operator _Tp* ()
{ return ptr; }
template<typename _Tp, size_t fixed_size> inline
AutoBuffer<_Tp, fixed_size>::operator const _Tp* () const
{ return ptr; }
template<> inline std::string CommandLineParser::get<std::string>(int index, bool space_delete) const template<> inline std::string CommandLineParser::get<std::string>(int index, bool space_delete) const
{ {
return get<String>(index, space_delete); return get<String>(index, space_delete);

View File

@ -282,7 +282,7 @@ static void binary_op( InputArray _src1, InputArray _src2, OutputArray _dst,
{ {
blocksize = std::min(blocksize, blocksize0); blocksize = std::min(blocksize, blocksize0);
_buf.allocate(blocksize*esz); _buf.allocate(blocksize*esz);
maskbuf = _buf; maskbuf = _buf.data();
} }
for( size_t i = 0; i < it.nplanes; i++, ++it ) for( size_t i = 0; i < it.nplanes; i++, ++it )
@ -312,7 +312,7 @@ static void binary_op( InputArray _src1, InputArray _src2, OutputArray _dst,
size_t total = it.size, blocksize = std::min(total, blocksize0); size_t total = it.size, blocksize = std::min(total, blocksize0);
_buf.allocate(blocksize*(haveMask ? 2 : 1)*esz + 32); _buf.allocate(blocksize*(haveMask ? 2 : 1)*esz + 32);
scbuf = _buf; scbuf = _buf.data();
maskbuf = alignPtr(scbuf + blocksize*esz, 16); maskbuf = alignPtr(scbuf + blocksize*esz, 16);
convertAndUnrollScalar( src2, src1.type(), scbuf, blocksize); convertAndUnrollScalar( src2, src1.type(), scbuf, blocksize);
@ -754,7 +754,7 @@ static void arithm_op(InputArray _src1, InputArray _src2, OutputArray _dst,
blocksize = std::min(blocksize, blocksize0); blocksize = std::min(blocksize, blocksize0);
_buf.allocate(bufesz*blocksize + 64); _buf.allocate(bufesz*blocksize + 64);
buf = _buf; buf = _buf.data();
if( cvtsrc1 ) if( cvtsrc1 )
buf1 = buf, buf = alignPtr(buf + blocksize*wsz, 16); buf1 = buf, buf = alignPtr(buf + blocksize*wsz, 16);
if( cvtsrc2 ) if( cvtsrc2 )
@ -818,7 +818,7 @@ static void arithm_op(InputArray _src1, InputArray _src2, OutputArray _dst,
size_t total = it.size, blocksize = std::min(total, blocksize0); size_t total = it.size, blocksize = std::min(total, blocksize0);
_buf.allocate(bufesz*blocksize + 64); _buf.allocate(bufesz*blocksize + 64);
buf = _buf; buf = _buf.data();
if( cvtsrc1 ) if( cvtsrc1 )
buf1 = buf, buf = alignPtr(buf + blocksize*wsz, 16); buf1 = buf, buf = alignPtr(buf + blocksize*wsz, 16);
buf2 = buf; buf = alignPtr(buf + blocksize*wsz, 16); buf2 = buf; buf = alignPtr(buf + blocksize*wsz, 16);
@ -1309,7 +1309,7 @@ void cv::compare(InputArray _src1, InputArray _src2, OutputArray _dst, int op)
size_t total = it.size, blocksize = std::min(total, blocksize0); size_t total = it.size, blocksize = std::min(total, blocksize0);
AutoBuffer<uchar> _buf(blocksize*esz); AutoBuffer<uchar> _buf(blocksize*esz);
uchar *buf = _buf; uchar *buf = _buf.data();
if( depth1 > CV_32S ) if( depth1 > CV_32S )
convertAndUnrollScalar( src2, depth1, buf, blocksize ); convertAndUnrollScalar( src2, depth1, buf, blocksize );
@ -1700,7 +1700,7 @@ static bool ocl_inRange( InputArray _src, InputArray _lowerb,
size_t blocksize = 36; size_t blocksize = 36;
AutoBuffer<uchar> _buf(blocksize*(((int)lbScalar + (int)ubScalar)*esz + cn) + 2*cn*sizeof(int) + 128); AutoBuffer<uchar> _buf(blocksize*(((int)lbScalar + (int)ubScalar)*esz + cn) + 2*cn*sizeof(int) + 128);
uchar *buf = alignPtr(_buf + blocksize*cn, 16); uchar *buf = alignPtr(_buf.data() + blocksize*cn, 16);
if( ldepth != sdepth && sdepth < CV_32S ) if( ldepth != sdepth && sdepth < CV_32S )
{ {
@ -1806,7 +1806,7 @@ void cv::inRange(InputArray _src, InputArray _lowerb,
size_t total = it.size, blocksize = std::min(total, blocksize0); size_t total = it.size, blocksize = std::min(total, blocksize0);
AutoBuffer<uchar> _buf(blocksize*(((int)lbScalar + (int)ubScalar)*esz + cn) + 2*cn*sizeof(int) + 128); AutoBuffer<uchar> _buf(blocksize*(((int)lbScalar + (int)ubScalar)*esz + cn) + 2*cn*sizeof(int) + 128);
uchar *buf = _buf, *mbuf = buf, *lbuf = 0, *ubuf = 0; uchar *buf = _buf.data(), *mbuf = buf, *lbuf = 0, *ubuf = 0;
buf = alignPtr(buf + blocksize*cn, 16); buf = alignPtr(buf + blocksize*cn, 16);
if( lbScalar && ubScalar ) if( lbScalar && ubScalar )

View File

@ -179,7 +179,7 @@ struct BatchDistInvoker : public ParallelLoopBody
void operator()(const Range& range) const CV_OVERRIDE void operator()(const Range& range) const CV_OVERRIDE
{ {
AutoBuffer<int> buf(src2->rows); AutoBuffer<int> buf(src2->rows);
int* bufptr = buf; int* bufptr = buf.data();
for( int i = range.start; i < range.end; i++ ) for( int i = range.start; i < range.end; i++ )
{ {

View File

@ -104,7 +104,7 @@ void cv::mixChannels( const Mat* src, size_t nsrcs, Mat* dst, size_t ndsts, cons
int depth = dst[0].depth(); int depth = dst[0].depth();
AutoBuffer<uchar> buf((nsrcs + ndsts + 1)*(sizeof(Mat*) + sizeof(uchar*)) + npairs*(sizeof(uchar*)*2 + sizeof(int)*6)); AutoBuffer<uchar> buf((nsrcs + ndsts + 1)*(sizeof(Mat*) + sizeof(uchar*)) + npairs*(sizeof(uchar*)*2 + sizeof(int)*6));
const Mat** arrays = (const Mat**)(uchar*)buf; const Mat** arrays = (const Mat**)(uchar*)buf.data();
uchar** ptrs = (uchar**)(arrays + nsrcs + ndsts); uchar** ptrs = (uchar**)(arrays + nsrcs + ndsts);
const uchar** srcs = (const uchar**)(ptrs + nsrcs + ndsts + 1); const uchar** srcs = (const uchar**)(ptrs + nsrcs + ndsts + 1);
uchar** dsts = (uchar**)(srcs + npairs); uchar** dsts = (uchar**)(srcs + npairs);
@ -294,7 +294,7 @@ void cv::mixChannels(InputArrayOfArrays src, InputOutputArrayOfArrays dst,
CV_Assert(nsrc > 0 && ndst > 0); CV_Assert(nsrc > 0 && ndst > 0);
cv::AutoBuffer<Mat> _buf(nsrc + ndst); cv::AutoBuffer<Mat> _buf(nsrc + ndst);
Mat* buf = _buf; Mat* buf = _buf.data();
for( i = 0; i < nsrc; i++ ) for( i = 0; i < nsrc; i++ )
buf[i] = src.getMat(src_is_mat ? -1 : i); buf[i] = src.getMat(src_is_mat ? -1 : i);
for( i = 0; i < ndst; i++ ) for( i = 0; i < ndst; i++ )
@ -327,7 +327,7 @@ void cv::mixChannels(InputArrayOfArrays src, InputOutputArrayOfArrays dst,
CV_Assert(fromTo.size()%2 == 0 && nsrc > 0 && ndst > 0); CV_Assert(fromTo.size()%2 == 0 && nsrc > 0 && ndst > 0);
cv::AutoBuffer<Mat> _buf(nsrc + ndst); cv::AutoBuffer<Mat> _buf(nsrc + ndst);
Mat* buf = _buf; Mat* buf = _buf.data();
for( i = 0; i < nsrc; i++ ) for( i = 0; i < nsrc; i++ )
buf[i] = src.getMat(src_is_mat ? -1 : i); buf[i] = src.getMat(src_is_mat ? -1 : i);
for( i = 0; i < ndst; i++ ) for( i = 0; i < ndst; i++ )

View File

@ -101,6 +101,10 @@ void check_failed_auto(const int v1, const int v2, const CheckContext& ctx)
{ {
check_failed_auto_<int>(v1, v2, ctx); check_failed_auto_<int>(v1, v2, ctx);
} }
void check_failed_auto(const size_t v1, const size_t v2, const CheckContext& ctx)
{
check_failed_auto_<size_t>(v1, v2, ctx);
}
void check_failed_auto(const float v1, const float v2, const CheckContext& ctx) void check_failed_auto(const float v1, const float v2, const CheckContext& ctx)
{ {
check_failed_auto_<float>(v1, v2, ctx); check_failed_auto_<float>(v1, v2, ctx);
@ -147,6 +151,10 @@ void check_failed_auto(const int v, const CheckContext& ctx)
{ {
check_failed_auto_<int>(v, ctx); check_failed_auto_<int>(v, ctx);
} }
void check_failed_auto(const size_t v, const CheckContext& ctx)
{
check_failed_auto_<size_t>(v, ctx);
}
void check_failed_auto(const float v, const CheckContext& ctx) void check_failed_auto(const float v, const CheckContext& ctx)
{ {
check_failed_auto_<float>(v, ctx); check_failed_auto_<float>(v, ctx);

View File

@ -52,7 +52,7 @@ namespace cv
double eps = getGradientEps(); double eps = getGradientEps();
int i, n = getDims(); int i, n = getDims();
AutoBuffer<double> x_buf(n); AutoBuffer<double> x_buf(n);
double* x_ = x_buf; double* x_ = x_buf.data();
for( i = 0; i < n; i++ ) for( i = 0; i < n; i++ )
x_[i] = x[i]; x_[i] = x[i];
for( i = 0; i < n; i++ ) for( i = 0; i < n; i++ )

View File

@ -531,7 +531,7 @@ Mat& Mat::setTo(InputArray _value, InputArray _mask)
int blockSize0 = std::min(totalsz, (int)((BLOCK_SIZE + esz-1)/esz)); int blockSize0 = std::min(totalsz, (int)((BLOCK_SIZE + esz-1)/esz));
blockSize0 -= blockSize0 % mcn; // must be divisible without remainder for unrolling and advancing blockSize0 -= blockSize0 % mcn; // must be divisible without remainder for unrolling and advancing
AutoBuffer<uchar> _scbuf(blockSize0*esz + 32); AutoBuffer<uchar> _scbuf(blockSize0*esz + 32);
uchar* scbuf = alignPtr((uchar*)_scbuf, (int)sizeof(double)); uchar* scbuf = alignPtr((uchar*)_scbuf.data(), (int)sizeof(double));
convertAndUnrollScalar( value, type(), scbuf, blockSize0/mcn ); convertAndUnrollScalar( value, type(), scbuf, blockSize0/mcn );
for( size_t i = 0; i < it.nplanes; i++, ++it ) for( size_t i = 0; i < it.nplanes; i++, ++it )
@ -559,7 +559,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); int i, j, limit = (int)(((size.width + 1)/2)*esz);
AutoBuffer<int> _tab(size.width*esz); AutoBuffer<int> _tab(size.width*esz);
int* tab = _tab; int* tab = _tab.data();
for( i = 0; i < size.width; i++ ) for( i = 0; i < size.width; i++ )
for( size_t k = 0; k < esz; k++ ) for( size_t k = 0; k < esz; k++ )
@ -960,7 +960,7 @@ void copyMakeBorder_8u( const uchar* src, size_t srcstep, cv::Size srcroi,
} }
cv::AutoBuffer<int> _tab((dstroi.width - srcroi.width)*cn); cv::AutoBuffer<int> _tab((dstroi.width - srcroi.width)*cn);
int* tab = _tab; int* tab = _tab.data();
int right = dstroi.width - srcroi.width - left; int right = dstroi.width - srcroi.width - left;
int bottom = dstroi.height - srcroi.height - top; int bottom = dstroi.height - srcroi.height - top;
@ -1031,7 +1031,7 @@ void copyMakeConstBorder_8u( const uchar* src, size_t srcstep, cv::Size srcroi,
{ {
int i, j; int i, j;
cv::AutoBuffer<uchar> _constBuf(dstroi.width*cn); cv::AutoBuffer<uchar> _constBuf(dstroi.width*cn);
uchar* constBuf = _constBuf; uchar* constBuf = _constBuf.data();
int right = dstroi.width - srcroi.width - left; int right = dstroi.width - srcroi.width - left;
int bottom = dstroi.height - srcroi.height - top; int bottom = dstroi.height - srcroi.height - top;
@ -1224,10 +1224,10 @@ void cv::copyMakeBorder( InputArray _src, OutputArray _dst, int top, int bottom,
CV_Assert( value[0] == value[1] && value[0] == value[2] && value[0] == value[3] ); CV_Assert( value[0] == value[1] && value[0] == value[2] && value[0] == value[3] );
cn1 = 1; cn1 = 1;
} }
scalarToRawData(value, buf, CV_MAKETYPE(src.depth(), cn1), cn); scalarToRawData(value, buf.data(), CV_MAKETYPE(src.depth(), cn1), cn);
copyMakeConstBorder_8u( src.ptr(), src.step, src.size(), copyMakeConstBorder_8u( src.ptr(), src.step, src.size(),
dst.ptr(), dst.step, dst.size(), dst.ptr(), dst.step, dst.size(),
top, left, (int)src.elemSize(), (uchar*)(double*)buf ); top, left, (int)src.elemSize(), (uchar*)buf.data() );
} }
} }

View File

@ -908,7 +908,7 @@ DFT(const OcvDftOptions & c, const Complex<T>* src, Complex<T>* dst)
int p, q, factor2 = (factor - 1)/2; int p, q, factor2 = (factor - 1)/2;
int d, dd, dw_f = c.tab_size/factor; int d, dd, dw_f = c.tab_size/factor;
AutoBuffer<Complex<T> > buf(factor2 * 2); AutoBuffer<Complex<T> > buf(factor2 * 2);
Complex<T>* a = buf; Complex<T>* a = buf.data();
Complex<T>* b = a + factor2; Complex<T>* b = a + factor2;
for( i = 0; i < c.n; i += n ) for( i = 0; i < c.n; i += n )
@ -2895,7 +2895,7 @@ protected:
uchar* dptr = dptr0; uchar* dptr = dptr0;
if( needBufferA ) if( needBufferA )
dptr = tmp_bufA; dptr = tmp_bufA.data();
contextA->apply(sptr, dptr); contextA->apply(sptr, dptr);
@ -2921,12 +2921,12 @@ protected:
const uchar* sptr0 = src_data; const uchar* sptr0 = src_data;
uchar* dptr0 = dst_data; uchar* dptr0 = dst_data;
dbuf0 = buf0, dbuf1 = buf1; dbuf0 = buf0.data(), dbuf1 = buf1.data();
if( needBufferB ) if( needBufferB )
{ {
dbuf1 = tmp_bufB; dbuf1 = tmp_bufB.data();
dbuf0 = buf1; dbuf0 = buf1.data();
} }
if( real_transform ) if( real_transform )
@ -2937,42 +2937,42 @@ protected:
b = (count+1)/2; b = (count+1)/2;
if( !inv ) if( !inv )
{ {
memset( buf0, 0, len*complex_elem_size ); memset( buf0.data(), 0, len*complex_elem_size );
CopyColumn( sptr0, src_step, buf0, complex_elem_size, len, elem_size ); CopyColumn( sptr0, src_step, buf0.data(), complex_elem_size, len, elem_size );
sptr0 += stage_dst_channels*elem_size; sptr0 += stage_dst_channels*elem_size;
if( even ) if( even )
{ {
memset( buf1, 0, len*complex_elem_size ); memset( buf1.data(), 0, len*complex_elem_size );
CopyColumn( sptr0 + (count-2)*elem_size, src_step, CopyColumn( sptr0 + (count-2)*elem_size, src_step,
buf1, complex_elem_size, len, elem_size ); buf1.data(), complex_elem_size, len, elem_size );
} }
} }
else if( stage_src_channels == 1 ) else if( stage_src_channels == 1 )
{ {
CopyColumn( sptr0, src_step, buf0, elem_size, len, elem_size ); CopyColumn( sptr0, src_step, buf0.data(), elem_size, len, elem_size );
ExpandCCS( buf0, len, elem_size ); ExpandCCS( buf0.data(), len, elem_size );
if( even ) if( even )
{ {
CopyColumn( sptr0 + (count-1)*elem_size, src_step, CopyColumn( sptr0 + (count-1)*elem_size, src_step,
buf1, elem_size, len, elem_size ); buf1.data(), elem_size, len, elem_size );
ExpandCCS( buf1, len, elem_size ); ExpandCCS( buf1.data(), len, elem_size );
} }
sptr0 += elem_size; sptr0 += elem_size;
} }
else else
{ {
CopyColumn( sptr0, src_step, buf0, complex_elem_size, len, complex_elem_size ); CopyColumn( sptr0, src_step, buf0.data(), complex_elem_size, len, complex_elem_size );
if( even ) if( even )
{ {
CopyColumn( sptr0 + b*complex_elem_size, src_step, CopyColumn( sptr0 + b*complex_elem_size, src_step,
buf1, complex_elem_size, len, complex_elem_size ); buf1.data(), complex_elem_size, len, complex_elem_size );
} }
sptr0 += complex_elem_size; sptr0 += complex_elem_size;
} }
if( even ) if( even )
contextB->apply(buf1, dbuf1); contextB->apply(buf1.data(), dbuf1);
contextB->apply(buf0, dbuf0); contextB->apply(buf0.data(), dbuf0);
if( stage_dst_channels == 1 ) if( stage_dst_channels == 1 )
{ {
@ -3019,13 +3019,13 @@ protected:
{ {
if( i+1 < b ) if( i+1 < b )
{ {
CopyFrom2Columns( sptr0, src_step, buf0, buf1, len, complex_elem_size ); CopyFrom2Columns( sptr0, src_step, buf0.data(), buf1.data(), len, complex_elem_size );
contextB->apply(buf1, dbuf1); contextB->apply(buf1.data(), dbuf1);
} }
else else
CopyColumn( sptr0, src_step, buf0, complex_elem_size, len, complex_elem_size ); CopyColumn( sptr0, src_step, buf0.data(), complex_elem_size, len, complex_elem_size );
contextB->apply(buf0, dbuf0); contextB->apply(buf0.data(), dbuf0);
if( i+1 < b ) if( i+1 < b )
CopyTo2Columns( dbuf0, dbuf1, dptr0, dst_step, len, complex_elem_size ); CopyTo2Columns( dbuf0, dbuf1, dptr0, dst_step, len, complex_elem_size );
@ -3134,9 +3134,9 @@ public:
if (len != prev_len || (!inplace_transform && opt.isInverse && real_transform)) if (len != prev_len || (!inplace_transform && opt.isInverse && real_transform))
{ {
wave_buf.allocate(opt.n*complex_elem_size); wave_buf.allocate(opt.n*complex_elem_size);
opt.wave = wave_buf; opt.wave = wave_buf.data();
itab_buf.allocate(opt.n); itab_buf.allocate(opt.n);
opt.itab = itab_buf; opt.itab = itab_buf.data();
DFTInit( opt.n, opt.nf, opt.factors, opt.itab, complex_elem_size, DFTInit( opt.n, opt.nf, opt.factors, opt.itab, complex_elem_size,
opt.wave, stage == 0 && opt.isInverse && real_transform ); opt.wave, stage == 0 && opt.isInverse && real_transform );
} }
@ -4152,31 +4152,31 @@ public:
bool inplace_transform = opt.factors[0] == opt.factors[opt.nf-1]; bool inplace_transform = opt.factors[0] == opt.factors[opt.nf-1];
wave_buf.allocate(len*complex_elem_size); wave_buf.allocate(len*complex_elem_size);
opt.wave = wave_buf; opt.wave = wave_buf.data();
itab_buf.allocate(len); itab_buf.allocate(len);
opt.itab = itab_buf; opt.itab = itab_buf.data();
DFTInit( len, opt.nf, opt.factors, opt.itab, complex_elem_size, opt.wave, isInverse ); DFTInit( len, opt.nf, opt.factors, opt.itab, complex_elem_size, opt.wave, isInverse );
dct_wave.allocate((len/2 + 1)*complex_elem_size); dct_wave.allocate((len/2 + 1)*complex_elem_size);
src_buf.allocate(len*elem_size); src_buf.allocate(len*elem_size);
src_dft_buf = src_buf; src_dft_buf = src_buf.data();
if(!inplace_transform) if(!inplace_transform)
{ {
dst_buf.allocate(len*elem_size); dst_buf.allocate(len*elem_size);
dst_dft_buf = dst_buf; dst_dft_buf = dst_buf.data();
} }
else else
{ {
dst_dft_buf = src_buf; dst_dft_buf = src_buf.data();
} }
DCTInit( len, complex_elem_size, dct_wave, isInverse); DCTInit( len, complex_elem_size, dct_wave.data(), isInverse);
prev_len = len; prev_len = len;
} }
// otherwise reuse the tables calculated on the previous stage // otherwise reuse the tables calculated on the previous stage
for(unsigned i = 0; i < static_cast<unsigned>(count); i++ ) for(unsigned i = 0; i < static_cast<unsigned>(count); i++ )
{ {
dct_func( opt, sptr + i*sstep0, sstep1, src_dft_buf, dst_dft_buf, dct_func( opt, sptr + i*sstep0, sstep1, src_dft_buf, dst_dft_buf,
dptr + i*dstep0, dstep1, dct_wave); dptr + i*dstep0, dstep1, dct_wave.data());
} }
src = dst; src = dst;
src_step = dst_step; src_step = dst_step;

View File

@ -330,7 +330,7 @@ double cv::kmeans( InputArray _data, int K,
else else
{ {
for (int k = 0; k < K; k++) for (int k = 0; k < K; k++)
generateRandomCenter(dims, box, centers.ptr<float>(k), rng); generateRandomCenter(dims, box.data(), centers.ptr<float>(k), rng);
} }
} }
else else
@ -429,14 +429,14 @@ double cv::kmeans( InputArray _data, int K,
if (isLastIter) if (isLastIter)
{ {
// don't re-assign labels to avoid creation of empty clusters // don't re-assign labels to avoid creation of empty clusters
parallel_for_(Range(0, N), KMeansDistanceComputer<true>(dists, labels, data, centers), (double)divUp((size_t)(dims * N), CV_KMEANS_PARALLEL_GRANULARITY)); parallel_for_(Range(0, N), KMeansDistanceComputer<true>(dists.data(), labels, data, centers), (double)divUp((size_t)(dims * N), CV_KMEANS_PARALLEL_GRANULARITY));
compactness = sum(Mat(Size(N, 1), CV_64F, &dists[0]))[0]; compactness = sum(Mat(Size(N, 1), CV_64F, &dists[0]))[0];
break; break;
} }
else else
{ {
// assign labels // assign labels
parallel_for_(Range(0, N), KMeansDistanceComputer<false>(dists, labels, data, centers), (double)divUp((size_t)(dims * N * K), CV_KMEANS_PARALLEL_GRANULARITY)); parallel_for_(Range(0, N), KMeansDistanceComputer<false>(dists.data(), labels, data, centers), (double)divUp((size_t)(dims * N * K), CV_KMEANS_PARALLEL_GRANULARITY));
} }
} }

View File

@ -401,7 +401,7 @@ JacobiSVDImpl_(_Tp* At, size_t astep, _Tp* _W, _Tp* Vt, size_t vstep,
{ {
VBLAS<_Tp> vblas; VBLAS<_Tp> vblas;
AutoBuffer<double> Wbuf(n); AutoBuffer<double> Wbuf(n);
double* W = Wbuf; double* W = Wbuf.data();
int i, j, k, iter, max_iter = std::max(m, 30); int i, j, k, iter, max_iter = std::max(m, 30);
_Tp c, s; _Tp c, s;
double sd; double sd;
@ -778,7 +778,7 @@ double cv::determinant( InputArray _mat )
{ {
size_t bufSize = rows*rows*sizeof(float); size_t bufSize = rows*rows*sizeof(float);
AutoBuffer<uchar> buffer(bufSize); AutoBuffer<uchar> buffer(bufSize);
Mat a(rows, rows, CV_32F, (uchar*)buffer); Mat a(rows, rows, CV_32F, buffer.data());
mat.copyTo(a); mat.copyTo(a);
result = hal::LU32f(a.ptr<float>(), a.step, rows, 0, 0, 0); result = hal::LU32f(a.ptr<float>(), a.step, rows, 0, 0, 0);
@ -801,7 +801,7 @@ double cv::determinant( InputArray _mat )
{ {
size_t bufSize = rows*rows*sizeof(double); size_t bufSize = rows*rows*sizeof(double);
AutoBuffer<uchar> buffer(bufSize); AutoBuffer<uchar> buffer(bufSize);
Mat a(rows, rows, CV_64F, (uchar*)buffer); Mat a(rows, rows, CV_64F, buffer.data());
mat.copyTo(a); mat.copyTo(a);
result = hal::LU64f(a.ptr<double>(), a.step, rows, 0, 0, 0); result = hal::LU64f(a.ptr<double>(), a.step, rows, 0, 0, 0);
@ -846,7 +846,7 @@ double cv::invert( InputArray _src, OutputArray _dst, int method )
int nm = std::min(m, n); int nm = std::min(m, n);
AutoBuffer<uchar> _buf((m*nm + nm + nm*n)*esz + sizeof(double)); AutoBuffer<uchar> _buf((m*nm + nm + nm*n)*esz + sizeof(double));
uchar* buf = alignPtr((uchar*)_buf, (int)esz); uchar* buf = alignPtr((uchar*)_buf.data(), (int)esz);
Mat u(m, nm, type, buf); Mat u(m, nm, type, buf);
Mat w(nm, 1, type, u.ptr() + m*nm*esz); Mat w(nm, 1, type, u.ptr() + m*nm*esz);
Mat vt(nm, n, type, w.ptr() + nm*esz); Mat vt(nm, n, type, w.ptr() + nm*esz);
@ -865,7 +865,7 @@ double cv::invert( InputArray _src, OutputArray _dst, int method )
if( method == DECOMP_EIG ) if( method == DECOMP_EIG )
{ {
AutoBuffer<uchar> _buf((n*n*2 + n)*esz + sizeof(double)); AutoBuffer<uchar> _buf((n*n*2 + n)*esz + sizeof(double));
uchar* buf = alignPtr((uchar*)_buf, (int)esz); uchar* buf = alignPtr((uchar*)_buf.data(), (int)esz);
Mat u(n, n, type, buf); Mat u(n, n, type, buf);
Mat w(n, 1, type, u.ptr() + n*n*esz); Mat w(n, 1, type, u.ptr() + n*n*esz);
Mat vt(n, n, type, w.ptr() + n*esz); Mat vt(n, n, type, w.ptr() + n*esz);
@ -1063,7 +1063,7 @@ double cv::invert( InputArray _src, OutputArray _dst, int method )
int elem_size = CV_ELEM_SIZE(type); int elem_size = CV_ELEM_SIZE(type);
AutoBuffer<uchar> buf(n*n*elem_size); AutoBuffer<uchar> buf(n*n*elem_size);
Mat src1(n, n, type, (uchar*)buf); Mat src1(n, n, type, buf.data());
src.copyTo(src1); src.copyTo(src1);
setIdentity(dst); setIdentity(dst);
@ -1267,7 +1267,7 @@ bool cv::solve( InputArray _src, InputArray _src2arg, OutputArray _dst, int meth
bufsize += n*5*esz + n*vstep + nb*sizeof(double) + 32; bufsize += n*5*esz + n*vstep + nb*sizeof(double) + 32;
buffer.allocate(bufsize); buffer.allocate(bufsize);
uchar* ptr = alignPtr((uchar*)buffer, 16); uchar* ptr = alignPtr(buffer.data(), 16);
Mat a(m_, n, type, ptr, astep); Mat a(m_, n, type, ptr, astep);
@ -1445,7 +1445,7 @@ bool cv::eigen( InputArray _src, OutputArray _evals, OutputArray _evects )
size_t elemSize = src.elemSize(), astep = alignSize(n*elemSize, 16); size_t elemSize = src.elemSize(), astep = alignSize(n*elemSize, 16);
AutoBuffer<uchar> buf(n*astep + n*5*elemSize + 32); AutoBuffer<uchar> buf(n*astep + n*5*elemSize + 32);
uchar* ptr = alignPtr((uchar*)buf, 16); uchar* ptr = alignPtr(buf.data(), 16);
Mat a(n, n, type, ptr, astep), w(n, 1, type, ptr + astep*n); Mat a(n, n, type, ptr, astep), w(n, 1, type, ptr + astep*n);
ptr += astep*n + elemSize*n; ptr += astep*n + elemSize*n;
src.copyTo(a); src.copyTo(a);
@ -1489,7 +1489,7 @@ static void _SVDcompute( InputArray _aarr, OutputArray _w,
int urows = full_uv ? m : n; int urows = full_uv ? m : n;
size_t esz = src.elemSize(), astep = alignSize(m*esz, 16), vstep = alignSize(n*esz, 16); size_t esz = src.elemSize(), astep = alignSize(m*esz, 16), vstep = alignSize(n*esz, 16);
AutoBuffer<uchar> _buf(urows*astep + n*vstep + n*esz + 32); AutoBuffer<uchar> _buf(urows*astep + n*vstep + n*esz + 32);
uchar* buf = alignPtr((uchar*)_buf, 16); uchar* buf = alignPtr(_buf.data(), 16);
Mat temp_a(n, m, type, buf, astep); Mat temp_a(n, m, type, buf, astep);
Mat temp_w(n, 1, type, buf + urows*astep); Mat temp_w(n, 1, type, buf + urows*astep);
Mat temp_u(urows, m, type, buf, astep), temp_v; Mat temp_u(urows, m, type, buf, astep), temp_v;
@ -1568,11 +1568,11 @@ void SVD::backSubst( InputArray _w, InputArray _u, InputArray _vt,
if( type == CV_32F ) if( type == CV_32F )
SVBkSb(m, n, w.ptr<float>(), wstep, u.ptr<float>(), u.step, false, SVBkSb(m, n, w.ptr<float>(), wstep, u.ptr<float>(), u.step, false,
vt.ptr<float>(), vt.step, true, rhs.ptr<float>(), rhs.step, nb, vt.ptr<float>(), vt.step, true, rhs.ptr<float>(), rhs.step, nb,
dst.ptr<float>(), dst.step, buffer); dst.ptr<float>(), dst.step, buffer.data());
else if( type == CV_64F ) else if( type == CV_64F )
SVBkSb(m, n, w.ptr<double>(), wstep, u.ptr<double>(), u.step, false, SVBkSb(m, n, w.ptr<double>(), wstep, u.ptr<double>(), u.step, false,
vt.ptr<double>(), vt.step, true, rhs.ptr<double>(), rhs.step, nb, vt.ptr<double>(), vt.step, true, rhs.ptr<double>(), rhs.step, nb,
dst.ptr<double>(), dst.step, buffer); dst.ptr<double>(), dst.step, buffer.data());
else else
CV_Error( CV_StsUnsupportedFormat, "" ); CV_Error( CV_StsUnsupportedFormat, "" );
} }

View File

@ -586,7 +586,7 @@ void polarToCart( InputArray src1, InputArray src2,
if( depth == CV_64F ) if( depth == CV_64F )
{ {
_buf.allocate(blockSize*2); _buf.allocate(blockSize*2);
buf[0] = _buf; buf[0] = _buf.data();
buf[1] = buf[0] + blockSize; buf[1] = buf[0] + blockSize;
} }
@ -1278,8 +1278,8 @@ void pow( InputArray _src, double power, OutputArray _dst )
if( src.ptr() == dst.ptr() ) if( src.ptr() == dst.ptr() )
{ {
buf.allocate(blockSize*esz1); buf.allocate(blockSize*esz1);
fbuf = (float*)(uchar*)buf; fbuf = (float*)buf.data();
dbuf = (double*)(uchar*)buf; dbuf = (double*)buf.data();
} }
for( size_t i = 0; i < it.nplanes; i++, ++it ) for( size_t i = 0; i < it.nplanes; i++, ++it )
@ -1901,7 +1901,7 @@ double cv::solvePoly( InputArray _coeffs0, OutputArray _roots0, int maxIters )
Mat roots0 = _roots0.getMat(); Mat roots0 = _roots0.getMat();
AutoBuffer<C> buf(n*2+2); AutoBuffer<C> buf(n*2+2);
C *coeffs = buf, *roots = coeffs + n + 1; C *coeffs = buf.data(), *roots = coeffs + n + 1;
Mat coeffs1(coeffs0.size(), CV_MAKETYPE(CV_64F, coeffs0.channels()), coeffs0.channels() == 2 ? coeffs : roots); Mat coeffs1(coeffs0.size(), CV_MAKETYPE(CV_64F, coeffs0.channels()), coeffs0.channels() == 2 ? coeffs : roots);
coeffs0.convertTo(coeffs1, coeffs1.type()); coeffs0.convertTo(coeffs1, coeffs1.type());
if( coeffs0.channels() == 1 ) if( coeffs0.channels() == 1 )

View File

@ -165,7 +165,7 @@ GEMMSingleMul( const T* a_data, size_t a_step,
if( a_step > 1 && n > 1 ) if( a_step > 1 && n > 1 )
{ {
_a_buf.allocate(n); _a_buf.allocate(n);
a_buf = _a_buf; a_buf = _a_buf.data();
} }
} }
@ -177,7 +177,7 @@ GEMMSingleMul( const T* a_data, size_t a_step,
if( a_step > 1 && a_size.height > 1 ) if( a_step > 1 && a_size.height > 1 )
{ {
_a_buf.allocate(drows); _a_buf.allocate(drows);
a_buf = _a_buf; a_buf = _a_buf.data();
for( k = 0; k < drows; k++ ) for( k = 0; k < drows; k++ )
a_buf[k] = a_data[a_step*k]; a_buf[k] = a_data[a_step*k];
a_data = a_buf; a_data = a_buf;
@ -186,7 +186,7 @@ GEMMSingleMul( const T* a_data, size_t a_step,
if( b_step > 1 ) if( b_step > 1 )
{ {
_b_buf.allocate(d_size.width); _b_buf.allocate(d_size.width);
b_buf = _b_buf; b_buf = _b_buf.data();
for( j = 0; j < d_size.width; j++ ) for( j = 0; j < d_size.width; j++ )
b_buf[j] = b_data[j*b_step]; b_buf[j] = b_data[j*b_step];
b_data = b_buf; b_data = b_buf;
@ -326,7 +326,7 @@ GEMMSingleMul( const T* a_data, size_t a_step,
else else
{ {
cv::AutoBuffer<WT> _d_buf(m); cv::AutoBuffer<WT> _d_buf(m);
WT* d_buf = _d_buf; WT* d_buf = _d_buf.data();
for( i = 0; i < drows; i++, _a_data += a_step0, _c_data += c_step0, d_data += d_step ) for( i = 0; i < drows; i++, _a_data += a_step0, _c_data += c_step0, d_data += d_step )
{ {
@ -404,7 +404,7 @@ GEMMBlockMul( const T* a_data, size_t a_step,
CV_SWAP( a_step0, a_step1, t_step ); CV_SWAP( a_step0, a_step1, t_step );
n = a_size.height; n = a_size.height;
_a_buf.allocate(n); _a_buf.allocate(n);
a_buf = _a_buf; a_buf = _a_buf.data();
} }
if( flags & GEMM_2_T ) if( flags & GEMM_2_T )
@ -1354,7 +1354,7 @@ static void gemmImpl( Mat A, Mat B, double alpha,
} }
buf.allocate(d_buf_size + b_buf_size + a_buf_size); buf.allocate(d_buf_size + b_buf_size + a_buf_size);
d_buf = (uchar*)buf; d_buf = buf.data();
b_buf = d_buf + d_buf_size; b_buf = d_buf + d_buf_size;
if( is_a_t ) if( is_a_t )
@ -2098,7 +2098,7 @@ void cv::transform( InputArray _src, OutputArray _dst, InputArray _mtx )
if( !m.isContinuous() || m.type() != mtype || m.cols != scn + 1 ) if( !m.isContinuous() || m.type() != mtype || m.cols != scn + 1 )
{ {
_mbuf.allocate(dcn*(scn+1)); _mbuf.allocate(dcn*(scn+1));
mbuf = (double*)_mbuf; mbuf = _mbuf.data();
Mat tmp(dcn, scn+1, mtype, mbuf); Mat tmp(dcn, scn+1, mtype, mbuf);
memset(tmp.ptr(), 0, tmp.total()*tmp.elemSize()); memset(tmp.ptr(), 0, tmp.total()*tmp.elemSize());
if( m.cols == scn+1 ) if( m.cols == scn+1 )
@ -2273,17 +2273,16 @@ void cv::perspectiveTransform( InputArray _src, OutputArray _dst, InputArray _mt
const int mtype = CV_64F; const int mtype = CV_64F;
AutoBuffer<double> _mbuf; AutoBuffer<double> _mbuf;
double* mbuf = _mbuf; double* mbuf = m.ptr<double>();
if( !m.isContinuous() || m.type() != mtype ) if( !m.isContinuous() || m.type() != mtype )
{ {
_mbuf.allocate((dcn+1)*(scn+1)); _mbuf.allocate((dcn+1)*(scn+1));
Mat tmp(dcn+1, scn+1, mtype, (double*)_mbuf); mbuf = _mbuf.data();
Mat tmp(dcn+1, scn+1, mtype, mbuf);
m.convertTo(tmp, mtype); m.convertTo(tmp, mtype);
m = tmp; m = tmp;
} }
else
mbuf = m.ptr<double>();
TransformFunc func = depth == CV_32F ? TransformFunc func = depth == CV_32F ?
(TransformFunc)perspectiveTransform_32f : (TransformFunc)perspectiveTransform_32f :
@ -2612,7 +2611,7 @@ double cv::Mahalanobis( InputArray _v1, InputArray _v2, InputArray _icovar )
const float* src2 = v2.ptr<float>(); const float* src2 = v2.ptr<float>();
size_t step1 = v1.step/sizeof(src1[0]); size_t step1 = v1.step/sizeof(src1[0]);
size_t step2 = v2.step/sizeof(src2[0]); size_t step2 = v2.step/sizeof(src2[0]);
double* diff = buf; double* diff = buf.data();
const float* mat = icovar.ptr<float>(); const float* mat = icovar.ptr<float>();
size_t matstep = icovar.step/sizeof(mat[0]); size_t matstep = icovar.step/sizeof(mat[0]);
@ -2622,7 +2621,7 @@ double cv::Mahalanobis( InputArray _v1, InputArray _v2, InputArray _icovar )
diff[i] = src1[i] - src2[i]; diff[i] = src1[i] - src2[i];
} }
diff = buf; diff = buf.data();
for( i = 0; i < len; i++, mat += matstep ) for( i = 0; i < len; i++, mat += matstep )
{ {
double row_sum = 0; double row_sum = 0;
@ -2643,7 +2642,7 @@ double cv::Mahalanobis( InputArray _v1, InputArray _v2, InputArray _icovar )
const double* src2 = v2.ptr<double>(); const double* src2 = v2.ptr<double>();
size_t step1 = v1.step/sizeof(src1[0]); size_t step1 = v1.step/sizeof(src1[0]);
size_t step2 = v2.step/sizeof(src2[0]); size_t step2 = v2.step/sizeof(src2[0]);
double* diff = buf; double* diff = buf.data();
const double* mat = icovar.ptr<double>(); const double* mat = icovar.ptr<double>();
size_t matstep = icovar.step/sizeof(mat[0]); size_t matstep = icovar.step/sizeof(mat[0]);
@ -2653,7 +2652,7 @@ double cv::Mahalanobis( InputArray _v1, InputArray _v2, InputArray _icovar )
diff[i] = src1[i] - src2[i]; diff[i] = src1[i] - src2[i];
} }
diff = buf; diff = buf.data();
for( i = 0; i < len; i++, mat += matstep ) for( i = 0; i < len; i++, mat += matstep )
{ {
double row_sum = 0; double row_sum = 0;
@ -2705,7 +2704,7 @@ MulTransposedR( const Mat& srcmat, Mat& dstmat, const Mat& deltamat, double scal
buf_size *= 5; buf_size *= 5;
} }
buf.allocate(buf_size); buf.allocate(buf_size);
col_buf = (dT*)(uchar*)buf; col_buf = (dT*)buf.data();
if( delta && delta_cols < size.width ) if( delta && delta_cols < size.width )
{ {
@ -2834,7 +2833,7 @@ MulTransposedL( const Mat& srcmat, Mat& dstmat, const Mat& deltamat, double scal
dT delta_buf[4]; dT delta_buf[4];
int delta_shift = delta_cols == size.width ? 4 : 0; int delta_shift = delta_cols == size.width ? 4 : 0;
AutoBuffer<uchar> buf(size.width*sizeof(dT)); AutoBuffer<uchar> buf(size.width*sizeof(dT));
dT* row_buf = (dT*)(uchar*)buf; dT* row_buf = (dT*)buf.data();
for( i = 0; i < size.height; i++, tdst += dststep ) for( i = 0; i < size.height; i++, tdst += dststep )
{ {

View File

@ -410,7 +410,7 @@ Mat::Mat(const Mat& m, const Range& _rowRange, const Range& _colRange)
rs[1] = _colRange; rs[1] = _colRange;
for( int i = 2; i < m.dims; i++ ) for( int i = 2; i < m.dims; i++ )
rs[i] = Range::all(); rs[i] = Range::all();
*this = m(rs); *this = m(rs.data());
return; return;
} }
@ -897,7 +897,7 @@ Mat Mat::reshape(int _cn, int _newndims, const int* _newsz) const
Mat hdr = *this; Mat hdr = *this;
hdr.flags = (hdr.flags & ~CV_MAT_CN_MASK) | ((_cn-1) << CV_CN_SHIFT); hdr.flags = (hdr.flags & ~CV_MAT_CN_MASK) | ((_cn-1) << CV_CN_SHIFT);
setSize(hdr, _newndims, (int*)newsz_buf, NULL, true); setSize(hdr, _newndims, newsz_buf.data(), NULL, true);
return hdr; return hdr;
} }

View File

@ -169,7 +169,7 @@ Mat cvarrToMat(const CvArr* arr, bool copyData,
if( abuf ) if( abuf )
{ {
abuf->allocate(((size_t)total*esz + sizeof(double)-1)/sizeof(double)); abuf->allocate(((size_t)total*esz + sizeof(double)-1)/sizeof(double));
double* bufdata = *abuf; double* bufdata = abuf->data();
cvCvtSeqToArray(seq, bufdata, CV_WHOLE_SEQ); cvCvtSeqToArray(seq, bufdata, CV_WHOLE_SEQ);
return Mat(total, 1, type, bufdata); return Mat(total, 1, type, bufdata);
} }

View File

@ -206,7 +206,7 @@ QRImpl(_Tp* A, size_t astep, int m, int n, int k, _Tp* b, size_t bstep, _Tp* hFa
cv::AutoBuffer<_Tp> buffer; cv::AutoBuffer<_Tp> buffer;
size_t buf_size = m ? m + n : hFactors != NULL; size_t buf_size = m ? m + n : hFactors != NULL;
buffer.allocate(buf_size); buffer.allocate(buf_size);
_Tp* vl = buffer; _Tp* vl = buffer.data();
if (hFactors == NULL) if (hFactors == NULL)
hFactors = vl + m; hFactors = vl + m;

View File

@ -606,7 +606,7 @@ reduceR_( const Mat& srcmat, Mat& dstmat )
Size size = srcmat.size(); Size size = srcmat.size();
size.width *= srcmat.channels(); size.width *= srcmat.channels();
AutoBuffer<WT> buffer(size.width); AutoBuffer<WT> buffer(size.width);
WT* buf = buffer; WT* buf = buffer.data();
ST* dst = dstmat.ptr<ST>(); ST* dst = dstmat.ptr<ST>();
const T* src = srcmat.ptr<T>(); const T* src = srcmat.ptr<T>();
size_t srcstep = srcmat.step/sizeof(src[0]); size_t srcstep = srcmat.step/sizeof(src[0]);
@ -1125,7 +1125,6 @@ namespace cv
template<typename T> static void sort_( const Mat& src, Mat& dst, int flags ) template<typename T> static void sort_( const Mat& src, Mat& dst, int flags )
{ {
AutoBuffer<T> buf; AutoBuffer<T> buf;
T* bptr;
int n, len; int n, len;
bool sortRows = (flags & 1) == CV_SORT_EVERY_ROW; bool sortRows = (flags & 1) == CV_SORT_EVERY_ROW;
bool inplace = src.data == dst.data; bool inplace = src.data == dst.data;
@ -1138,7 +1137,7 @@ template<typename T> static void sort_( const Mat& src, Mat& dst, int flags )
n = src.cols, len = src.rows; n = src.cols, len = src.rows;
buf.allocate(len); buf.allocate(len);
} }
bptr = (T*)buf; T* bptr = buf.data();
for( int i = 0; i < n; i++ ) for( int i = 0; i < n; i++ )
{ {
@ -1223,7 +1222,7 @@ static bool ipp_sort(const Mat& src, Mat& dst, int flags)
for(int i = 0; i < dst.rows; i++) for(int i = 0; i < dst.rows; i++)
{ {
if(CV_INSTRUMENT_FUN_IPP(ippsSortRadix_I, (void*)dst.ptr(i), dst.cols, buffer) < 0) if(CV_INSTRUMENT_FUN_IPP(ippsSortRadix_I, (void*)dst.ptr(i), dst.cols, buffer.data()) < 0)
return false; return false;
} }
} }
@ -1248,7 +1247,7 @@ static bool ipp_sort(const Mat& src, Mat& dst, int flags)
dstSub = Mat(dst, subRect); dstSub = Mat(dst, subRect);
srcSub.copyTo(row); srcSub.copyTo(row);
if(CV_INSTRUMENT_FUN_IPP(ippsSortRadix_I, (void*)row.ptr(), dst.rows, buffer) < 0) if(CV_INSTRUMENT_FUN_IPP(ippsSortRadix_I, (void*)row.ptr(), dst.rows, buffer.data()) < 0)
return false; return false;
row = row.reshape(1, dstSub.rows); row = row.reshape(1, dstSub.rows);
@ -1286,8 +1285,8 @@ template<typename T> static void sortIdx_( const Mat& src, Mat& dst, int flags )
buf.allocate(len); buf.allocate(len);
ibuf.allocate(len); ibuf.allocate(len);
} }
T* bptr = (T*)buf; T* bptr = buf.data();
int* _iptr = (int*)ibuf; int* _iptr = ibuf.data();
for( int i = 0; i < n; i++ ) for( int i = 0; i < n; i++ )
{ {
@ -1365,7 +1364,7 @@ static bool ipp_sortIdx( const Mat& src, Mat& dst, int flags )
for(int i = 0; i < src.rows; i++) for(int i = 0; i < src.rows; i++)
{ {
if(CV_INSTRUMENT_FUN_IPP(ippsSortRadixIndex, (const void*)src.ptr(i), (Ipp32s)src.step[1], (Ipp32s*)dst.ptr(i), src.cols, buffer) < 0) if(CV_INSTRUMENT_FUN_IPP(ippsSortRadixIndex, (const void*)src.ptr(i), (Ipp32s)src.step[1], (Ipp32s*)dst.ptr(i), src.cols, buffer.data()) < 0)
return false; return false;
} }
} }
@ -1388,7 +1387,7 @@ static bool ipp_sortIdx( const Mat& src, Mat& dst, int flags )
subRect.x = i; subRect.x = i;
dstSub = Mat(dst, subRect); dstSub = Mat(dst, subRect);
if(CV_INSTRUMENT_FUN_IPP(ippsSortRadixIndex, (const void*)src.ptr(0, i), srcStep, (Ipp32s*)dstRow.ptr(), src.rows, buffer) < 0) if(CV_INSTRUMENT_FUN_IPP(ippsSortRadixIndex, (const void*)src.ptr(0, i), srcStep, (Ipp32s*)dstRow.ptr(), src.rows, buffer.data()) < 0)
return false; return false;
dstRow = dstRow.reshape(1, dstSub.rows); dstRow = dstRow.reshape(1, dstSub.rows);

View File

@ -135,7 +135,7 @@ cv::Scalar cv::mean( InputArray _src, InputArray _mask )
intSumBlockSize = depth <= CV_8S ? (1 << 23) : (1 << 15); intSumBlockSize = depth <= CV_8S ? (1 << 23) : (1 << 15);
blockSize = std::min(blockSize, intSumBlockSize); blockSize = std::min(blockSize, intSumBlockSize);
_buf.allocate(cn); _buf.allocate(cn);
buf = _buf; buf = _buf.data();
for( k = 0; k < cn; k++ ) for( k = 0; k < cn; k++ )
buf[k] = 0; buf[k] = 0;
@ -789,7 +789,7 @@ void cv::meanStdDev( InputArray _src, OutputArray _mean, OutputArray _sdv, Input
int total = (int)it.size, blockSize = total, intSumBlockSize = 0; int total = (int)it.size, blockSize = total, intSumBlockSize = 0;
int j, count = 0, nz0 = 0; int j, count = 0, nz0 = 0;
AutoBuffer<double> _buf(cn*4); AutoBuffer<double> _buf(cn*4);
double *s = (double*)_buf, *sq = s + cn; double *s = (double*)_buf.data(), *sq = s + cn;
int *sbuf = (int*)s, *sqbuf = (int*)sq; int *sbuf = (int*)s, *sqbuf = (int*)sq;
bool blockSum = depth <= CV_16S, blockSqSum = depth <= CV_8S; bool blockSum = depth <= CV_16S, blockSqSum = depth <= CV_8S;
size_t esz = 0; size_t esz = 0;

View File

@ -496,7 +496,7 @@ void cv::merge(const Mat* mv, size_t n, OutputArray _dst)
size_t esz = dst.elemSize(), esz1 = dst.elemSize1(); size_t esz = dst.elemSize(), esz1 = dst.elemSize1();
size_t blocksize0 = (int)((BLOCK_SIZE + esz-1)/esz); size_t blocksize0 = (int)((BLOCK_SIZE + esz-1)/esz);
AutoBuffer<uchar> _buf((cn+1)*(sizeof(Mat*) + sizeof(uchar*)) + 16); AutoBuffer<uchar> _buf((cn+1)*(sizeof(Mat*) + sizeof(uchar*)) + 16);
const Mat** arrays = (const Mat**)(uchar*)_buf; const Mat** arrays = (const Mat**)_buf.data();
uchar** ptrs = (uchar**)alignPtr(arrays + cn + 1, 16); uchar** ptrs = (uchar**)alignPtr(arrays + cn + 1, 16);
arrays[0] = &dst; arrays[0] = &dst;

View File

@ -617,12 +617,12 @@ public:
if (fileSourceSignatureSize == sourceSignatureSize_) if (fileSourceSignatureSize == sourceSignatureSize_)
{ {
cv::AutoBuffer<char> fileSourceSignature(fileSourceSignatureSize + 1); cv::AutoBuffer<char> fileSourceSignature(fileSourceSignatureSize + 1);
f.read((char*)fileSourceSignature, fileSourceSignatureSize); f.read(fileSourceSignature.data(), fileSourceSignatureSize);
if (f.eof()) if (f.eof())
{ {
CV_LOG_ERROR(NULL, "Unexpected EOF"); CV_LOG_ERROR(NULL, "Unexpected EOF");
} }
else if (memcmp(sourceSignature, (const char*)fileSourceSignature, fileSourceSignatureSize) == 0) else if (memcmp(sourceSignature, fileSourceSignature.data(), fileSourceSignatureSize) == 0)
{ {
isValid = true; isValid = true;
} }
@ -696,10 +696,10 @@ public:
{ {
if (entry.keySize > 0) if (entry.keySize > 0)
{ {
f.read((char*)fileKey, entry.keySize); f.read(fileKey.data(), entry.keySize);
CV_Assert(!f.fail()); CV_Assert(!f.fail());
} }
if (memcmp((const char*)fileKey, key.c_str(), entry.keySize) == 0) if (memcmp(fileKey.data(), key.c_str(), entry.keySize) == 0)
{ {
buf.resize(entry.dataSize); buf.resize(entry.dataSize);
f.read(&buf[0], entry.dataSize); f.read(&buf[0], entry.dataSize);
@ -786,10 +786,10 @@ public:
{ {
if (entry.keySize > 0) if (entry.keySize > 0)
{ {
f.read((char*)fileKey, entry.keySize); f.read(fileKey.data(), entry.keySize);
CV_Assert(!f.fail()); CV_Assert(!f.fail());
} }
if (0 == memcmp((const char*)fileKey, key.c_str(), entry.keySize)) if (0 == memcmp(fileKey.data(), key.c_str(), entry.keySize))
{ {
// duplicate // duplicate
CV_LOG_VERBOSE(NULL, 0, "Duplicate key ignored: " << fileName_); CV_LOG_VERBOSE(NULL, 0, "Duplicate key ignored: " << fileName_);
@ -1634,7 +1634,7 @@ inline cl_int getStringInfo(Functor f, ObjectType obj, cl_uint name, std::string
if (required > 0) if (required > 0)
{ {
AutoBuffer<char> buf(required + 1); AutoBuffer<char> buf(required + 1);
char* ptr = (char*)buf; // cleanup is not needed char* ptr = buf.data(); // cleanup is not needed
err = f(obj, name, required, ptr, NULL); err = f(obj, name, required, ptr, NULL);
if (err != CL_SUCCESS) if (err != CL_SUCCESS)
return err; return err;
@ -2002,7 +2002,7 @@ struct Context::Impl
CV_OCL_DBG_CHECK(clGetDeviceIDs(pl, dtype, 0, 0, &nd0)); CV_OCL_DBG_CHECK(clGetDeviceIDs(pl, dtype, 0, 0, &nd0));
AutoBuffer<void*> dlistbuf(nd0*2+1); AutoBuffer<void*> dlistbuf(nd0*2+1);
cl_device_id* dlist = (cl_device_id*)(void**)dlistbuf; cl_device_id* dlist = (cl_device_id*)dlistbuf.data();
cl_device_id* dlist_new = dlist + nd0; cl_device_id* dlist_new = dlist + nd0;
CV_OCL_DBG_CHECK(clGetDeviceIDs(pl, dtype, nd0, dlist, &nd0)); CV_OCL_DBG_CHECK(clGetDeviceIDs(pl, dtype, nd0, dlist, &nd0));
String name0; String name0;
@ -2465,12 +2465,12 @@ static void get_platform_name(cl_platform_id id, String& name)
// get platform name string // get platform name string
AutoBuffer<char> buf(sz + 1); AutoBuffer<char> buf(sz + 1);
CV_OCL_CHECK(clGetPlatformInfo(id, CL_PLATFORM_NAME, sz, buf, 0)); CV_OCL_CHECK(clGetPlatformInfo(id, CL_PLATFORM_NAME, sz, buf.data(), 0));
// just in case, ensure trailing zero for ASCIIZ string // just in case, ensure trailing zero for ASCIIZ string
buf[sz] = 0; buf[sz] = 0;
name = (const char*)buf; name = buf.data();
} }
/* /*
@ -3654,7 +3654,7 @@ struct Program::Impl
{ {
buffer.resize(retsz + 16); buffer.resize(retsz + 16);
log_retval = clGetProgramBuildInfo(handle, deviceList[0], log_retval = clGetProgramBuildInfo(handle, deviceList[0],
CL_PROGRAM_BUILD_LOG, retsz+1, (char*)buffer, &retsz); CL_PROGRAM_BUILD_LOG, retsz+1, buffer.data(), &retsz);
if (log_retval == CL_SUCCESS) if (log_retval == CL_SUCCESS)
{ {
if (retsz < buffer.size()) if (retsz < buffer.size())
@ -3668,7 +3668,7 @@ struct Program::Impl
} }
} }
errmsg = String(buffer); errmsg = String(buffer.data());
printf("OpenCL program build log: %s/%s\nStatus %d: %s\n%s\n%s\n", printf("OpenCL program build log: %s/%s\nStatus %d: %s\n%s\n%s\n",
sourceModule_.c_str(), sourceName_.c_str(), sourceModule_.c_str(), sourceName_.c_str(),
result, getOpenCLErrorString(result), result, getOpenCLErrorString(result),
@ -3701,7 +3701,7 @@ struct Program::Impl
{ {
size_t n = ctx.ndevices(); size_t n = ctx.ndevices();
AutoBuffer<cl_device_id, 4> deviceListBuf(n + 1); AutoBuffer<cl_device_id, 4> deviceListBuf(n + 1);
cl_device_id* deviceList = deviceListBuf; cl_device_id* deviceList = deviceListBuf.data();
for (size_t i = 0; i < n; i++) for (size_t i = 0; i < n; i++)
{ {
deviceList[i] = (cl_device_id)(ctx.device(i).ptr()); deviceList[i] = (cl_device_id)(ctx.device(i).ptr());
@ -3770,9 +3770,9 @@ struct Program::Impl
AutoBuffer<const uchar*> binaryPtrs_(ndevices); AutoBuffer<const uchar*> binaryPtrs_(ndevices);
AutoBuffer<size_t> binarySizes_(ndevices); AutoBuffer<size_t> binarySizes_(ndevices);
cl_device_id* devices = devices_; cl_device_id* devices = devices_.data();
const uchar** binaryPtrs = binaryPtrs_; const uchar** binaryPtrs = binaryPtrs_.data();
size_t* binarySizes = binarySizes_; size_t* binarySizes = binarySizes_.data();
for (size_t i = 0; i < ndevices; i++) for (size_t i = 0; i < ndevices; i++)
{ {
devices[i] = (cl_device_id)ctx.device(i).ptr(); devices[i] = (cl_device_id)ctx.device(i).ptr();
@ -3781,7 +3781,7 @@ struct Program::Impl
} }
cl_int result = 0; cl_int result = 0;
handle = clCreateProgramWithBinary((cl_context)ctx.ptr(), (cl_uint)ndevices, (cl_device_id*)devices_, handle = clCreateProgramWithBinary((cl_context)ctx.ptr(), (cl_uint)ndevices, devices_.data(),
binarySizes, binaryPtrs, NULL, &result); binarySizes, binaryPtrs, NULL, &result);
if (result != CL_SUCCESS) if (result != CL_SUCCESS)
{ {
@ -3798,7 +3798,7 @@ struct Program::Impl
} }
// call clBuildProgram() // call clBuildProgram()
{ {
result = clBuildProgram(handle, (cl_uint)ndevices, (cl_device_id*)devices_, buildflags.c_str(), 0, 0); result = clBuildProgram(handle, (cl_uint)ndevices, devices_.data(), buildflags.c_str(), 0, 0);
CV_OCL_DBG_CHECK_RESULT(result, cv::format("clBuildProgram(binary: %s/%s)", sourceModule_.c_str(), sourceName_.c_str()).c_str()); CV_OCL_DBG_CHECK_RESULT(result, cv::format("clBuildProgram(binary: %s/%s)", sourceModule_.c_str(), sourceName_.c_str()).c_str());
if (result != CL_SUCCESS) if (result != CL_SUCCESS)
{ {
@ -6318,7 +6318,7 @@ struct Image2D::Impl
AutoBuffer<cl_image_format> formats(numFormats); AutoBuffer<cl_image_format> formats(numFormats);
err = clGetSupportedImageFormats(context, CL_MEM_READ_WRITE, err = clGetSupportedImageFormats(context, CL_MEM_READ_WRITE,
CL_MEM_OBJECT_IMAGE2D, numFormats, CL_MEM_OBJECT_IMAGE2D, numFormats,
formats, NULL); formats.data(), NULL);
CV_OCL_DBG_CHECK_RESULT(err, "clGetSupportedImageFormats(CL_MEM_OBJECT_IMAGE2D, formats)"); CV_OCL_DBG_CHECK_RESULT(err, "clGetSupportedImageFormats(CL_MEM_OBJECT_IMAGE2D, formats)");
for (cl_uint i = 0; i < numFormats; ++i) for (cl_uint i = 0; i < numFormats; ++i)
{ {

View File

@ -222,7 +222,7 @@ String FileStorage::getDefaultObjectName(const String& _filename)
if( ptr == ptr2 ) if( ptr == ptr2 )
CV_Error( CV_StsBadArg, "Invalid filename" ); CV_Error( CV_StsBadArg, "Invalid filename" );
char* name = name_buf; char* name = name_buf.data();
// name must start with letter or '_' // name must start with letter or '_'
if( !cv_isalpha(*ptr) && *ptr!= '_' ){ if( !cv_isalpha(*ptr) && *ptr!= '_' ){
@ -237,7 +237,7 @@ String FileStorage::getDefaultObjectName(const String& _filename)
*name++ = c; *name++ = c;
} }
*name = '\0'; *name = '\0';
name = name_buf; name = name_buf.data();
if( strcmp( name, "_" ) == 0 ) if( strcmp( name, "_" ) == 0 )
strcpy( name, stubname ); strcpy( name, stubname );
return String(name); return String(name);

View File

@ -542,7 +542,7 @@ void RNG::fill( InputOutputArray _mat, int disttype,
if( disttype == UNIFORM ) if( disttype == UNIFORM )
{ {
_parambuf.allocate(cn*8 + n1 + n2); _parambuf.allocate(cn*8 + n1 + n2);
double* parambuf = _parambuf; double* parambuf = _parambuf.data();
double* p1 = _param1.ptr<double>(); double* p1 = _param1.ptr<double>();
double* p2 = _param2.ptr<double>(); double* p2 = _param2.ptr<double>();
@ -651,7 +651,7 @@ void RNG::fill( InputOutputArray _mat, int disttype,
else if( disttype == CV_RAND_NORMAL ) else if( disttype == CV_RAND_NORMAL )
{ {
_parambuf.allocate(MAX(n1, cn) + MAX(n2, cn)); _parambuf.allocate(MAX(n1, cn) + MAX(n2, cn));
double* parambuf = _parambuf; double* parambuf = _parambuf.data();
int ptype = depth == CV_64F ? CV_64F : CV_32F; int ptype = depth == CV_64F ? CV_64F : CV_32F;
int esz = (int)CV_ELEM_SIZE(ptype); int esz = (int)CV_ELEM_SIZE(ptype);
@ -701,7 +701,7 @@ void RNG::fill( InputOutputArray _mat, int disttype,
if( disttype == UNIFORM ) if( disttype == UNIFORM )
{ {
buf.allocate(blockSize*cn*4); buf.allocate(blockSize*cn*4);
param = (uchar*)(double*)buf; param = (uchar*)(double*)buf.data();
if( depth <= CV_32S ) if( depth <= CV_32S )
{ {
@ -738,7 +738,7 @@ void RNG::fill( InputOutputArray _mat, int disttype,
else else
{ {
buf.allocate((blockSize*cn+1)/2); buf.allocate((blockSize*cn+1)/2);
nbuf = (float*)(double*)buf; nbuf = (float*)(double*)buf.data();
} }
for( size_t i = 0; i < it.nplanes; i++, ++it ) for( size_t i = 0; i < it.nplanes; i++, ++it )

View File

@ -485,7 +485,7 @@ void cv::split(const Mat& src, Mat* mv)
size_t esz = src.elemSize(), esz1 = src.elemSize1(); size_t esz = src.elemSize(), esz1 = src.elemSize1();
size_t blocksize0 = (BLOCK_SIZE + esz-1)/esz; size_t blocksize0 = (BLOCK_SIZE + esz-1)/esz;
AutoBuffer<uchar> _buf((cn+1)*(sizeof(Mat*) + sizeof(uchar*)) + 16); AutoBuffer<uchar> _buf((cn+1)*(sizeof(Mat*) + sizeof(uchar*)) + 16);
const Mat** arrays = (const Mat**)(uchar*)_buf; const Mat** arrays = (const Mat**)_buf.data();
uchar** ptrs = (uchar**)alignPtr(arrays + cn + 1, 16); uchar** ptrs = (uchar**)alignPtr(arrays + cn + 1, 16);
arrays[0] = &src; arrays[0] = &src;

View File

@ -617,7 +617,7 @@ cv::Scalar cv::sum( InputArray _src )
intSumBlockSize = depth <= CV_8S ? (1 << 23) : (1 << 15); intSumBlockSize = depth <= CV_8S ? (1 << 23) : (1 << 15);
blockSize = std::min(blockSize, intSumBlockSize); blockSize = std::min(blockSize, intSumBlockSize);
_buf.allocate(cn); _buf.allocate(cn);
buf = _buf; buf = _buf.data();
for( k = 0; k < cn; k++ ) for( k = 0; k < cn; k++ )
buf[k] = 0; buf[k] = 0;

View File

@ -807,7 +807,7 @@ String format( const char* fmt, ... )
va_list va; va_list va;
va_start(va, fmt); va_start(va, fmt);
int bsize = static_cast<int>(buf.size()); int bsize = static_cast<int>(buf.size());
int len = cv_vsnprintf((char *)buf, bsize, fmt, va); int len = cv_vsnprintf(buf.data(), bsize, fmt, va);
va_end(va); va_end(va);
CV_Assert(len >= 0 && "Check format string for errors"); CV_Assert(len >= 0 && "Check format string for errors");
@ -817,7 +817,7 @@ String format( const char* fmt, ... )
continue; continue;
} }
buf[bsize - 1] = 0; buf[bsize - 1] = 0;
return String((char *)buf, len); return String(buf.data(), len);
} }
} }

View File

@ -502,7 +502,7 @@ UMat::UMat(const UMat& m, const Range& _rowRange, const Range& _colRange)
rs[1] = _colRange; rs[1] = _colRange;
for( int i = 2; i < m.dims; i++ ) for( int i = 2; i < m.dims; i++ )
rs[i] = Range::all(); rs[i] = Range::all();
*this = m(rs); *this = m(rs.data());
return; return;
} }
@ -805,7 +805,7 @@ UMat UMat::reshape(int _cn, int _newndims, const int* _newsz) const
UMat hdr = *this; UMat hdr = *this;
hdr.flags = (hdr.flags & ~CV_MAT_CN_MASK) | ((_cn-1) << CV_CN_SHIFT); hdr.flags = (hdr.flags & ~CV_MAT_CN_MASK) | ((_cn-1) << CV_CN_SHIFT);
setSize(hdr, _newndims, (int*)newsz_buf, NULL, true); setSize(hdr, _newndims, newsz_buf.data(), NULL, true);
return hdr; return hdr;
} }

View File

@ -158,13 +158,13 @@ cv::String getcwd()
#else #else
DWORD sz = GetCurrentDirectoryA(0, NULL); DWORD sz = GetCurrentDirectoryA(0, NULL);
buf.allocate((size_t)sz); buf.allocate((size_t)sz);
sz = GetCurrentDirectoryA((DWORD)buf.size(), (char*)buf); sz = GetCurrentDirectoryA((DWORD)buf.size(), buf.data());
return cv::String((char*)buf, (size_t)sz); return cv::String(buf.data(), (size_t)sz);
#endif #endif
#elif defined __linux__ || defined __APPLE__ || defined __HAIKU__ #elif defined __linux__ || defined __APPLE__ || defined __HAIKU__
for(;;) for(;;)
{ {
char* p = ::getcwd((char*)buf, buf.size()); char* p = ::getcwd(buf.data(), buf.size());
if (p == NULL) if (p == NULL)
{ {
if (errno == ERANGE) if (errno == ERANGE)
@ -176,7 +176,7 @@ cv::String getcwd()
} }
break; break;
} }
return cv::String((char*)buf, (size_t)strlen((char*)buf)); return cv::String(buf.data(), (size_t)strlen(buf.data()));
#else #else
return cv::String(); return cv::String();
#endif #endif

View File

@ -374,9 +374,9 @@ TEST(Core_Rand, Regression_Stack_Corruption)
int bufsz = 128; //enough for 14 doubles int bufsz = 128; //enough for 14 doubles
AutoBuffer<uchar> buffer(bufsz); AutoBuffer<uchar> buffer(bufsz);
size_t offset = 0; size_t offset = 0;
cv::Mat_<cv::Point2d> x(2, 3, (cv::Point2d*)(buffer+offset)); offset += x.total()*x.elemSize(); cv::Mat_<cv::Point2d> x(2, 3, (cv::Point2d*)(buffer.data()+offset)); offset += x.total()*x.elemSize();
double& param1 = *(double*)(buffer+offset); offset += sizeof(double); double& param1 = *(double*)(buffer.data()+offset); offset += sizeof(double);
double& param2 = *(double*)(buffer+offset); offset += sizeof(double); double& param2 = *(double*)(buffer.data()+offset); offset += sizeof(double);
param1 = -9; param2 = 2; param1 = -9; param2 = 2;
cv::theRNG().fill(x, cv::RNG::NORMAL, param1, param2); cv::theRNG().fill(x, cv::RNG::NORMAL, param1, param2);

View File

@ -586,7 +586,7 @@ public:
float* data_out0_ = output_->ptr<float>(); float* data_out0_ = output_->ptr<float>();
size_t rowbufsz = (size_t)karea*BLK_SIZE_CN*BLK_SIZE; size_t rowbufsz = (size_t)karea*BLK_SIZE_CN*BLK_SIZE;
AutoBuffer<float> rowbuf0_(rowbufsz + valign); AutoBuffer<float> rowbuf0_(rowbufsz + valign);
float* rowbuf0 = alignPtr((float*)rowbuf0_, (int)(valign*sizeof(float))); float* rowbuf0 = alignPtr(rowbuf0_.data(), (int)(valign*sizeof(float)));
// we clear the buffer once; ultimately, it lets us to avoid // we clear the buffer once; ultimately, it lets us to avoid
// tail processing after running the unrolled/vectorized loop. // tail processing after running the unrolled/vectorized loop.

View File

@ -182,7 +182,7 @@ public:
size_t stripeEnd = r.end == nstripes ? total : std::min(r.end*stripeSize, total); size_t stripeEnd = r.end == nstripes ? total : std::min(r.end*stripeSize, total);
size_t wstep = weights->step1(); size_t wstep = weights->step1();
AutoBuffer<float> srcbuf(vecsize_aligned + valign); AutoBuffer<float> srcbuf(vecsize_aligned + valign);
float* sptr = alignPtr((float*)srcbuf, (int)(valign*sizeof(float))); float* sptr = alignPtr(srcbuf.data(), (int)(valign*sizeof(float)));
for( k = vecsize; k < vecsize_aligned; k++ ) for( k = vecsize; k < vecsize_aligned; k++ )
sptr[k] = 0.f; sptr[k] = 0.f;

View File

@ -211,7 +211,7 @@ public:
int k, channels = channels_, ksize = ksize_; int k, channels = channels_, ksize = ksize_;
AutoBuffer<float> buf_((channels + ksize + 1)*2); AutoBuffer<float> buf_((channels + ksize + 1)*2);
float* acc = (float*)buf_; float* acc = buf_.data();
float* buf = acc + channels + ksize + 1; float* buf = acc + channels + ksize + 1;
for( k = 0; k <= ksize; k++ ) for( k = 0; k <= ksize; k++ )
buf[-k-1] = buf[channels + k] = 0.f; buf[-k-1] = buf[channels + k] = 0.f;

View File

@ -370,8 +370,8 @@ struct TorchImporter
int ndims = readInt(); int ndims = readInt();
AutoBuffer<int64, 4> sizes(ndims); AutoBuffer<int64, 4> sizes(ndims);
AutoBuffer<int64, 4> steps(ndims); AutoBuffer<int64, 4> steps(ndims);
THFile_readLongRaw(file, sizes, ndims); THFile_readLongRaw(file, sizes.data(), ndims);
THFile_readLongRaw(file, steps, ndims); THFile_readLongRaw(file, steps.data(), ndims);
long offset = readLong() - 1; long offset = readLong() - 1;
//read Storage //read Storage
@ -411,7 +411,7 @@ struct TorchImporter
} }
//allocate Blob //allocate Blob
Mat srcMat(ndims, (int*)isizes, typeTensor , storages[indexStorage].ptr() + offset*CV_ELEM_SIZE(typeTensor), (size_t*)ssteps); Mat srcMat(ndims, isizes.data(), typeTensor , storages[indexStorage].ptr() + offset*CV_ELEM_SIZE(typeTensor), ssteps.data());
int dstType = CV_32F; int dstType = CV_32F;
Mat blob; Mat blob;

View File

@ -83,7 +83,7 @@ void FAST_t(InputArray _img, std::vector<KeyPoint>& keypoints, int threshold, bo
AutoBuffer<uchar> _buf((img.cols+16)*3*(sizeof(int) + sizeof(uchar)) + 128); AutoBuffer<uchar> _buf((img.cols+16)*3*(sizeof(int) + sizeof(uchar)) + 128);
uchar* buf[3]; uchar* buf[3];
buf[0] = _buf; buf[1] = buf[0] + img.cols; buf[2] = buf[1] + img.cols; buf[0] = _buf.data(); buf[1] = buf[0] + img.cols; buf[2] = buf[1] + img.cols;
int* cpbuf[3]; int* cpbuf[3];
cpbuf[0] = (int*)alignPtr(buf[2] + img.cols, sizeof(int)) + 1; cpbuf[0] = (int*)alignPtr(buf[2] + img.cols, sizeof(int)) + 1;
cpbuf[1] = cpbuf[0] + img.cols + 1; cpbuf[1] = cpbuf[0] + img.cols + 1;

View File

@ -143,7 +143,7 @@ HarrisResponses(const Mat& img, const std::vector<Rect>& layerinfo,
float scale_sq_sq = scale * scale * scale * scale; float scale_sq_sq = scale * scale * scale * scale;
AutoBuffer<int> ofsbuf(blockSize*blockSize); AutoBuffer<int> ofsbuf(blockSize*blockSize);
int* ofs = ofsbuf; int* ofs = ofsbuf.data();
for( int i = 0; i < blockSize; i++ ) for( int i = 0; i < blockSize; i++ )
for( int j = 0; j < blockSize; j++ ) for( int j = 0; j < blockSize; j++ )
ofs[i*blockSize + j] = (int)(i*step + j); ofs[i*blockSize + j] = (int)(i*step + j);

View File

@ -726,7 +726,7 @@ private:
} }
cv::AutoBuffer<int> centers_idx_buf(branching); cv::AutoBuffer<int> centers_idx_buf(branching);
int* centers_idx = (int*)centers_idx_buf; int* centers_idx = centers_idx_buf.data();
int centers_length; int centers_length;
(this->*chooseCenters)(branching, indices, indices_length, centers_idx, centers_length); (this->*chooseCenters)(branching, indices, indices_length, centers_idx, centers_length);
@ -739,7 +739,7 @@ private:
cv::AutoBuffer<double> dcenters_buf(branching*veclen_); cv::AutoBuffer<double> dcenters_buf(branching*veclen_);
Matrix<double> dcenters((double*)dcenters_buf,branching,veclen_); Matrix<double> dcenters(dcenters_buf.data(), branching, veclen_);
for (int i=0; i<centers_length; ++i) { for (int i=0; i<centers_length; ++i) {
ElementType* vec = dataset_[centers_idx[i]]; ElementType* vec = dataset_[centers_idx[i]];
for (size_t k=0; k<veclen_; ++k) { for (size_t k=0; k<veclen_; ++k) {
@ -749,7 +749,7 @@ private:
std::vector<DistanceType> radiuses(branching); std::vector<DistanceType> radiuses(branching);
cv::AutoBuffer<int> count_buf(branching); cv::AutoBuffer<int> count_buf(branching);
int* count = (int*)count_buf; int* count = count_buf.data();
for (int i=0; i<branching; ++i) { for (int i=0; i<branching; ++i) {
radiuses[i] = 0; radiuses[i] = 0;
count[i] = 0; count[i] = 0;
@ -757,7 +757,7 @@ private:
// assign points to clusters // assign points to clusters
cv::AutoBuffer<int> belongs_to_buf(indices_length); cv::AutoBuffer<int> belongs_to_buf(indices_length);
int* belongs_to = (int*)belongs_to_buf; int* belongs_to = belongs_to_buf.data();
for (int i=0; i<indices_length; ++i) { for (int i=0; i<indices_length; ++i) {
DistanceType sq_dist = distance_(dataset_[indices[i]], dcenters[0], veclen_); DistanceType sq_dist = distance_(dataset_[indices[i]], dcenters[0], veclen_);

View File

@ -223,7 +223,7 @@ bool BmpDecoder::readData( Mat& img )
} }
_bgr.allocate(m_width*3 + 32); _bgr.allocate(m_width*3 + 32);
} }
uchar *src = _src, *bgr = _bgr; uchar *src = _src.data(), *bgr = _bgr.data();
CV_TRY CV_TRY
{ {

View File

@ -199,7 +199,7 @@ bool ExrDecoder::readData( Mat& img )
if( !justcopy ) if( !justcopy )
{ {
copy_buffer.allocate(sizeof(float) * m_width * 3); copy_buffer.allocate(sizeof(float) * m_width * 3);
buffer = copy_buffer; buffer = copy_buffer.data();
ystep = 0; ystep = 0;
} }
else else

View File

@ -681,7 +681,7 @@ bool JpegEncoder::write( const Mat& img, const std::vector<int>& params )
if( channels > 1 ) if( channels > 1 )
_buffer.allocate(width*channels); _buffer.allocate(width*channels);
buffer = _buffer; buffer = _buffer.data();
for( int y = 0; y < height; y++ ) for( int y = 0; y < height; y++ )
{ {

View File

@ -496,9 +496,7 @@ bool PAMDecoder::readData( Mat& img )
/* setting buffer to max data size so scaling up is possible */ /* setting buffer to max data size so scaling up is possible */
AutoBuffer<uchar> _src(src_elems_per_row * 2); AutoBuffer<uchar> _src(src_elems_per_row * 2);
uchar* src = _src; uchar* src = _src.data();
AutoBuffer<uchar> _gray_palette;
uchar* gray_palette = _gray_palette;
if( m_offset < 0 || !m_strm.isOpened()) if( m_offset < 0 || !m_strm.isOpened())
return false; return false;
@ -544,10 +542,7 @@ bool PAMDecoder::readData( Mat& img )
if (bit_mode) { if (bit_mode) {
if( target_channels == 1 ) if( target_channels == 1 )
{ {
_gray_palette.allocate(2); uchar gray_palette[2] = {0, 255};
gray_palette = _gray_palette;
gray_palette[0] = 0;
gray_palette[1] = 255;
for( y = 0; y < m_height; y++, data += imp_stride ) for( y = 0; y < m_height; y++, data += imp_stride )
{ {
m_strm.getBytes( src, src_stride ); m_strm.getBytes( src, src_stride );
@ -683,7 +678,7 @@ bool PAMEncoder::write( const Mat& img, const std::vector<int>& params )
bufsize = tmp; bufsize = tmp;
AutoBuffer<char> _buffer(bufsize); AutoBuffer<char> _buffer(bufsize);
char* buffer = _buffer; char* buffer = _buffer.data();
/* write header */ /* write header */
tmp = 0; tmp = 0;

View File

@ -225,7 +225,7 @@ bool PngDecoder::readData( Mat& img )
{ {
volatile bool result = false; volatile bool result = false;
AutoBuffer<uchar*> _buffer(m_height); AutoBuffer<uchar*> _buffer(m_height);
uchar** buffer = _buffer; uchar** buffer = _buffer.data();
int color = img.channels() > 1; int color = img.channels() > 1;
png_structp png_ptr = (png_structp)m_png_ptr; png_structp png_ptr = (png_structp)m_png_ptr;
@ -426,7 +426,7 @@ bool PngEncoder::write( const Mat& img, const std::vector<int>& params )
for( y = 0; y < height; y++ ) for( y = 0; y < height; y++ )
buffer[y] = img.data + y*img.step; buffer[y] = img.data + y*img.step;
png_write_image( png_ptr, buffer ); png_write_image( png_ptr, buffer.data() );
png_write_end( png_ptr, info_ptr ); png_write_end( png_ptr, info_ptr );
result = true; result = true;

View File

@ -245,7 +245,7 @@ bool PxMDecoder::readData( Mat& img )
if( !m_binary ) if( !m_binary )
{ {
AutoBuffer<uchar> _src(m_width); AutoBuffer<uchar> _src(m_width);
uchar* src = _src; uchar* src = _src.data();
for (int y = 0; y < m_height; y++, data += img.step) for (int y = 0; y < m_height; y++, data += img.step)
{ {
@ -261,7 +261,7 @@ bool PxMDecoder::readData( Mat& img )
else else
{ {
AutoBuffer<uchar> _src(src_pitch); AutoBuffer<uchar> _src(src_pitch);
uchar* src = _src; uchar* src = _src.data();
for (int y = 0; y < m_height; y++, data += img.step) for (int y = 0; y < m_height; y++, data += img.step)
{ {
@ -281,7 +281,7 @@ bool PxMDecoder::readData( Mat& img )
case 24: case 24:
{ {
AutoBuffer<uchar> _src(std::max<size_t>(width3*2, src_pitch)); AutoBuffer<uchar> _src(std::max<size_t>(width3*2, src_pitch));
uchar* src = _src; uchar* src = _src.data();
for (int y = 0; y < m_height; y++, data += img.step) for (int y = 0; y < m_height; y++, data += img.step)
{ {
@ -463,7 +463,7 @@ bool PxMEncoder::write(const Mat& img, const std::vector<int>& params)
bufferSize = lineLength; bufferSize = lineLength;
AutoBuffer<char> _buffer(bufferSize); AutoBuffer<char> _buffer(bufferSize);
char* buffer = _buffer; char* buffer = _buffer.data();
// write header; // write header;
const int code = ((mode == PXM_TYPE_PBM) ? 1 : (mode == PXM_TYPE_PGM) ? 2 : 3) const int code = ((mode == PXM_TYPE_PBM) ? 1 : (mode == PXM_TYPE_PGM) ? 2 : 3)

View File

@ -174,7 +174,7 @@ bool SunRasterDecoder::readData( Mat& img )
return false; return false;
AutoBuffer<uchar> _src(src_pitch + 32); AutoBuffer<uchar> _src(src_pitch + 32);
uchar* src = _src; uchar* src = _src.data();
if( !color && m_maptype == RMT_EQUAL_RGB ) if( !color && m_maptype == RMT_EQUAL_RGB )
CvtPaletteToGray( m_palette, gray_palette, 1 << m_bpp ); CvtPaletteToGray( m_palette, gray_palette, 1 << m_bpp );

View File

@ -355,7 +355,7 @@ bool TiffDecoder::readData( Mat& img )
} }
const size_t buffer_size = (bpp/bitsPerByte) * ncn * tile_height0 * tile_width0; const size_t buffer_size = (bpp/bitsPerByte) * ncn * tile_height0 * tile_width0;
AutoBuffer<uchar> _buffer( buffer_size ); AutoBuffer<uchar> _buffer( buffer_size );
uchar* buffer = _buffer; uchar* buffer = _buffer.data();
ushort* buffer16 = (ushort*)buffer; ushort* buffer16 = (ushort*)buffer;
float* buffer32 = (float*)buffer; float* buffer32 = (float*)buffer;
double* buffer64 = (double*)buffer; double* buffer64 = (double*)buffer;
@ -834,7 +834,7 @@ bool TiffEncoder::writeLibTiff( const std::vector<Mat>& img_vec, const std::vect
// row buffer, because TIFFWriteScanline modifies the original data! // row buffer, because TIFFWriteScanline modifies the original data!
size_t scanlineSize = TIFFScanlineSize(pTiffHandle); size_t scanlineSize = TIFFScanlineSize(pTiffHandle);
AutoBuffer<uchar> _buffer(scanlineSize + 32); AutoBuffer<uchar> _buffer(scanlineSize + 32);
uchar* buffer = _buffer; uchar* buffer = _buffer.data();
if (!buffer) if (!buffer)
{ {
TIFFClose(pTiffHandle); TIFFClose(pTiffHandle);

View File

@ -63,7 +63,7 @@ CvSeq* icvApproximateChainTC89( CvChain* chain, int header_size,
cv::AutoBuffer<_CvPtInfo> buf(chain->total + 8); cv::AutoBuffer<_CvPtInfo> buf(chain->total + 8);
_CvPtInfo temp; _CvPtInfo temp;
_CvPtInfo *array = buf, *first = 0, *current = 0, *prev_current = 0; _CvPtInfo *array = buf.data(), *first = 0, *current = 0, *prev_current = 0;
int i, j, i1, i2, s, len; int i, j, i1, i2, s, len;
int count = chain->total; int count = chain->total;
@ -475,14 +475,14 @@ namespace cv
template<typename T> static int template<typename T> static int
approxPolyDP_( const Point_<T>* src_contour, int count0, Point_<T>* dst_contour, approxPolyDP_( const Point_<T>* src_contour, int count0, Point_<T>* dst_contour,
bool is_closed0, double eps, AutoBuffer<Range>* _stack ) bool is_closed0, double eps, AutoBuffer<Range>& _stack )
{ {
#define PUSH_SLICE(slice) \ #define PUSH_SLICE(slice) \
if( top >= stacksz ) \ if( top >= stacksz ) \
{ \ { \
_stack->resize(stacksz*3/2); \ _stack.resize(stacksz*3/2); \
stack = *_stack; \ stack = _stack.data(); \
stacksz = _stack->size(); \ stacksz = _stack.size(); \
} \ } \
stack[top++] = slice stack[top++] = slice
@ -504,8 +504,8 @@ approxPolyDP_( const Point_<T>* src_contour, int count0, Point_<T>* dst_contour,
int i = 0, j, pos = 0, wpos, count = count0, new_count=0; int i = 0, j, pos = 0, wpos, count = count0, new_count=0;
int is_closed = is_closed0; int is_closed = is_closed0;
bool le_eps = false; bool le_eps = false;
size_t top = 0, stacksz = _stack->size(); size_t top = 0, stacksz = _stack.size();
Range* stack = *_stack; Range* stack = _stack.data();
if( count == 0 ) if( count == 0 )
return 0; return 0;
@ -689,13 +689,13 @@ void cv::approxPolyDP( InputArray _curve, OutputArray _approxCurve,
AutoBuffer<Point> _buf(npoints); AutoBuffer<Point> _buf(npoints);
AutoBuffer<Range> _stack(npoints); AutoBuffer<Range> _stack(npoints);
Point* buf = _buf; Point* buf = _buf.data();
int nout = 0; int nout = 0;
if( depth == CV_32S ) if( depth == CV_32S )
nout = approxPolyDP_(curve.ptr<Point>(), npoints, buf, closed, epsilon, &_stack); nout = approxPolyDP_(curve.ptr<Point>(), npoints, buf, closed, epsilon, _stack);
else if( depth == CV_32F ) else if( depth == CV_32F )
nout = approxPolyDP_(curve.ptr<Point2f>(), npoints, (Point2f*)buf, closed, epsilon, &_stack); nout = approxPolyDP_(curve.ptr<Point2f>(), npoints, (Point2f*)buf, closed, epsilon, _stack);
else else
CV_Error( CV_StsUnsupportedFormat, "" ); CV_Error( CV_StsUnsupportedFormat, "" );
@ -783,7 +783,7 @@ cvApproxPoly( const void* array, int header_size,
{ {
int npoints = src_seq->total, nout = 0; int npoints = src_seq->total, nout = 0;
_buf.allocate(npoints*2); _buf.allocate(npoints*2);
cv::Point *src = _buf, *dst = src + npoints; cv::Point *src = _buf.data(), *dst = src + npoints;
bool closed = CV_IS_SEQ_CLOSED(src_seq); bool closed = CV_IS_SEQ_CLOSED(src_seq);
if( src_seq->first->next == src_seq->first ) if( src_seq->first->next == src_seq->first )
@ -792,10 +792,10 @@ cvApproxPoly( const void* array, int header_size,
cvCvtSeqToArray(src_seq, src); cvCvtSeqToArray(src_seq, src);
if( CV_SEQ_ELTYPE(src_seq) == CV_32SC2 ) if( CV_SEQ_ELTYPE(src_seq) == CV_32SC2 )
nout = cv::approxPolyDP_(src, npoints, dst, closed, parameter, &stack); nout = cv::approxPolyDP_(src, npoints, dst, closed, parameter, stack);
else if( CV_SEQ_ELTYPE(src_seq) == CV_32FC2 ) else if( CV_SEQ_ELTYPE(src_seq) == CV_32FC2 )
nout = cv::approxPolyDP_((cv::Point2f*)src, npoints, nout = cv::approxPolyDP_((cv::Point2f*)src, npoints,
(cv::Point2f*)dst, closed, parameter, &stack); (cv::Point2f*)dst, closed, parameter, stack);
else else
CV_Error( CV_StsUnsupportedFormat, "" ); CV_Error( CV_StsUnsupportedFormat, "" );

View File

@ -390,21 +390,21 @@ public:
{ {
dxMax.allocate(2 * dx.cols); dxMax.allocate(2 * dx.cols);
dyMax.allocate(2 * dy.cols); dyMax.allocate(2 * dy.cols);
_dx_a = (short*)dxMax; _dx_a = dxMax.data();
_dx_n = _dx_a + dx.cols; _dx_n = _dx_a + dx.cols;
_dy_a = (short*)dyMax; _dy_a = dyMax.data();
_dy_n = _dy_a + dy.cols; _dy_n = _dy_a + dy.cols;
} }
// _mag_p: previous row, _mag_a: actual row, _mag_n: next row // _mag_p: previous row, _mag_a: actual row, _mag_n: next row
#if CV_SIMD128 #if CV_SIMD128
AutoBuffer<int> buffer(3 * (mapstep * cn + CV_MALLOC_SIMD128)); AutoBuffer<int> buffer(3 * (mapstep * cn + CV_MALLOC_SIMD128));
_mag_p = alignPtr((int*)buffer + 1, CV_MALLOC_SIMD128); _mag_p = alignPtr(buffer.data() + 1, CV_MALLOC_SIMD128);
_mag_a = alignPtr(_mag_p + mapstep * cn, CV_MALLOC_SIMD128); _mag_a = alignPtr(_mag_p + mapstep * cn, CV_MALLOC_SIMD128);
_mag_n = alignPtr(_mag_a + mapstep * cn, CV_MALLOC_SIMD128); _mag_n = alignPtr(_mag_a + mapstep * cn, CV_MALLOC_SIMD128);
#else #else
AutoBuffer<int> buffer(3 * (mapstep * cn)); AutoBuffer<int> buffer(3 * (mapstep * cn));
_mag_p = (int*)buffer + 1; _mag_p = buffer.data() + 1;
_mag_a = _mag_p + mapstep * cn; _mag_a = _mag_p + mapstep * cn;
_mag_n = _mag_a + mapstep * cn; _mag_n = _mag_a + mapstep * cn;
#endif #endif

View File

@ -230,7 +230,7 @@ namespace
src_(src), dst_(dst), lut_(lut), tileSize_(tileSize), tilesX_(tilesX), tilesY_(tilesY) src_(src), dst_(dst), lut_(lut), tileSize_(tileSize), tilesX_(tilesX), tilesY_(tilesY)
{ {
buf.allocate(src.cols << 2); buf.allocate(src.cols << 2);
ind1_p = (int *)buf; ind1_p = buf.data();
ind2_p = ind1_p + src.cols; ind2_p = ind1_p + src.cols;
xa_p = (float *)(ind2_p + src.cols); xa_p = (float *)(ind2_p + src.cols);
xa1_p = xa_p + src.cols; xa1_p = xa_p + src.cols;

View File

@ -1398,7 +1398,7 @@ static LABLUVLUT_s16_t initLUTforLABLUVs16(const softfloat & un, const softfloat
for (int p_ = 0; p_ < 2; ++p_) for (int p_ = 0; p_ < 2; ++p_)
for (int q_ = 0; q_ < 2; ++q_) for (int q_ = 0; q_ < 2; ++q_)
for (int r_ = 0; r_ < 2; ++r_) for (int r_ = 0; r_ < 2; ++r_)
fill_one(RGB2LabLUT_s16, RGB2Labprev, RGB2LuvLUT_s16, RGB2Luvprev, p, q, r, p_, q_, r_); fill_one(RGB2LabLUT_s16, RGB2Labprev.data(), RGB2LuvLUT_s16, RGB2Luvprev.data(), p, q, r, p_, q_, r_);
LABLUVLUT_s16_t res; LABLUVLUT_s16_t res;
res.RGB2LabLUT_s16 = RGB2LabLUT_s16; res.RGB2LabLUT_s16 = RGB2LabLUT_s16;
res.RGB2LuvLUT_s16 = RGB2LuvLUT_s16; res.RGB2LuvLUT_s16 = RGB2LuvLUT_s16;

View File

@ -147,11 +147,11 @@ void convexHull( InputArray _points, OutputArray _hull, bool clockwise, bool ret
bool is_float = depth == CV_32F; bool is_float = depth == CV_32F;
AutoBuffer<Point*> _pointer(total); AutoBuffer<Point*> _pointer(total);
AutoBuffer<int> _stack(total + 2), _hullbuf(total); AutoBuffer<int> _stack(total + 2), _hullbuf(total);
Point** pointer = _pointer; Point** pointer = _pointer.data();
Point2f** pointerf = (Point2f**)pointer; Point2f** pointerf = (Point2f**)pointer;
Point* data0 = points.ptr<Point>(); Point* data0 = points.ptr<Point>();
int* stack = _stack; int* stack = _stack.data();
int* hullbuf = _hullbuf; int* hullbuf = _hullbuf.data();
CV_Assert(points.isContinuous()); CV_Assert(points.isContinuous());

View File

@ -542,7 +542,7 @@ static bool ipp_cornerMinEigenVal( InputArray _src, OutputArray _dst, int blockS
if (ok >= 0) if (ok >= 0)
{ {
AutoBuffer<uchar> buffer(bufferSize); AutoBuffer<uchar> buffer(bufferSize);
ok = CV_INSTRUMENT_FUN_IPP(ippiMinEigenVal_C1R, src.ptr(), (int) src.step, dst.ptr<Ipp32f>(), (int) dst.step, srcRoi, kerType, kerSize, blockSize, buffer); ok = CV_INSTRUMENT_FUN_IPP(ippiMinEigenVal_C1R, src.ptr(), (int) src.step, dst.ptr<Ipp32f>(), (int) dst.step, srcRoi, kerType, kerSize, blockSize, buffer.data());
CV_SUPPRESS_DEPRECATED_START CV_SUPPRESS_DEPRECATED_START
if (ok >= 0) ok = CV_INSTRUMENT_FUN_IPP(ippiMulC_32f_C1IR, norm_coef, dst.ptr<Ipp32f>(), (int) dst.step, srcRoi); if (ok >= 0) ok = CV_INSTRUMENT_FUN_IPP(ippiMulC_32f_C1IR, norm_coef, dst.ptr<Ipp32f>(), (int) dst.step, srcRoi);
CV_SUPPRESS_DEPRECATED_END CV_SUPPRESS_DEPRECATED_END

View File

@ -976,7 +976,7 @@ static void Bayer2RGB_VNG_8u( const Mat& srcmat, Mat& dstmat, int code )
int N = size.width, N2 = N*2, N3 = N*3, N4 = N*4, N5 = N*5, N6 = N*6, N7 = N*7; int N = size.width, N2 = N*2, N3 = N*3, N4 = N*4, N5 = N*5, N6 = N*6, N7 = N*7;
int i, bufstep = N7*bcn; int i, bufstep = N7*bcn;
cv::AutoBuffer<ushort> _buf(bufstep*brows); cv::AutoBuffer<ushort> _buf(bufstep*brows);
ushort* buf = (ushort*)_buf; ushort* buf = _buf.data();
bayer += bstep*2; bayer += bstep*2;

View File

@ -458,7 +458,7 @@ struct DTColumnInvoker : ParallelLoopBody
int m = src->rows; int m = src->rows;
size_t sstep = src->step, dstep = dst->step/sizeof(float); size_t sstep = src->step, dstep = dst->step/sizeof(float);
AutoBuffer<int> _d(m); AutoBuffer<int> _d(m);
int* d = _d; int* d = _d.data();
for( i = i1; i < i2; i++ ) for( i = i1; i < i2; i++ )
{ {
@ -503,7 +503,7 @@ struct DTRowInvoker : ParallelLoopBody
int i, i1 = range.start, i2 = range.end; int i, i1 = range.start, i2 = range.end;
int n = dst->cols; int n = dst->cols;
AutoBuffer<uchar> _buf((n+2)*2*sizeof(float) + (n+2)*sizeof(int)); AutoBuffer<uchar> _buf((n+2)*2*sizeof(float) + (n+2)*sizeof(int));
float* f = (float*)(uchar*)_buf; float* f = (float*)_buf.data();
float* z = f + n; float* z = f + n;
int* v = alignPtr((int*)(z + n + 1), sizeof(int)); int* v = alignPtr((int*)(z + n + 1), sizeof(int));
@ -564,7 +564,7 @@ trueDistTrans( const Mat& src, Mat& dst )
cv::AutoBuffer<uchar> _buf(std::max(m*2*sizeof(float) + (m*3+1)*sizeof(int), n*2*sizeof(float))); cv::AutoBuffer<uchar> _buf(std::max(m*2*sizeof(float) + (m*3+1)*sizeof(int), n*2*sizeof(float)));
// stage 1: compute 1d distance transform of each column // stage 1: compute 1d distance transform of each column
float* sqr_tab = (float*)(uchar*)_buf; float* sqr_tab = (float*)_buf.data();
int* sat_tab = cv::alignPtr((int*)(sqr_tab + m*2), sizeof(int)); int* sat_tab = cv::alignPtr((int*)(sqr_tab + m*2), sizeof(int));
int shift = m*2; int shift = m*2;

View File

@ -2398,8 +2398,8 @@ void cv::fillPoly(InputOutputArray _img, InputArrayOfArrays pts,
return; return;
AutoBuffer<Point*> _ptsptr(ncontours); AutoBuffer<Point*> _ptsptr(ncontours);
AutoBuffer<int> _npts(ncontours); AutoBuffer<int> _npts(ncontours);
Point** ptsptr = _ptsptr; Point** ptsptr = _ptsptr.data();
int* npts = _npts; int* npts = _npts.data();
for( i = 0; i < ncontours; i++ ) for( i = 0; i < ncontours; i++ )
{ {
@ -2426,8 +2426,8 @@ void cv::polylines(InputOutputArray _img, InputArrayOfArrays pts,
return; return;
AutoBuffer<Point*> _ptsptr(ncontours); AutoBuffer<Point*> _ptsptr(ncontours);
AutoBuffer<int> _npts(ncontours); AutoBuffer<int> _npts(ncontours);
Point** ptsptr = _ptsptr; Point** ptsptr = _ptsptr.data();
int* npts = _npts; int* npts = _npts.data();
for( i = 0; i < ncontours; i++ ) for( i = 0; i < ncontours; i++ )
{ {

View File

@ -359,7 +359,7 @@ static int icvInitEMD( const float* signature1, int size1,
/* allocate buffers */ /* allocate buffers */
_buffer.allocate(buffer_size); _buffer.allocate(buffer_size);
state->buffer = buffer = _buffer; state->buffer = buffer = _buffer.data();
buffer_end = buffer + buffer_size; buffer_end = buffer + buffer_size;
state->idx1 = (int*) buffer; state->idx1 = (int*) buffer;

View File

@ -1444,7 +1444,7 @@ private:
return 0; return 0;
} }
AutoBuffer<uchar> buf(bufsz + 64); AutoBuffer<uchar> buf(bufsz + 64);
uchar* bufptr = alignPtr((uchar*)buf, 32); uchar* bufptr = alignPtr(buf.data(), 32);
int step = (int)(width*sizeof(dst[0])*cn); int step = (int)(width*sizeof(dst[0])*cn);
float borderValue[] = {0.f, 0.f, 0.f}; float borderValue[] = {0.f, 0.f, 0.f};
// here is the trick. IPP needs border type and extrapolates the row. We did it already. // here is the trick. IPP needs border type and extrapolates the row. We did it already.

View File

@ -524,7 +524,7 @@ float cv::intersectConvexConvex( InputArray _p1, InputArray _p2, OutputArray _p1
} }
AutoBuffer<Point2f> _result(n*2 + m*2 + 1); AutoBuffer<Point2f> _result(n*2 + m*2 + 1);
Point2f *fp1 = _result, *fp2 = fp1 + n; Point2f *fp1 = _result.data(), *fp2 = fp1 + n;
Point2f* result = fp2 + m; Point2f* result = fp2 + m;
int orientation = 0; int orientation = 0;

View File

@ -165,7 +165,7 @@ HoughLinesStandard( InputArray src, OutputArray lines, int type,
AutoBuffer<float> _tabSin(numangle); AutoBuffer<float> _tabSin(numangle);
AutoBuffer<float> _tabCos(numangle); AutoBuffer<float> _tabCos(numangle);
int *accum = _accum.ptr<int>(); int *accum = _accum.ptr<int>();
float *tabSin = _tabSin, *tabCos = _tabCos; float *tabSin = _tabSin.data(), *tabCos = _tabCos.data();
// create sin and cos table // create sin and cos table
createTrigTable( numangle, min_theta, theta, createTrigTable( numangle, min_theta, theta,
@ -963,7 +963,7 @@ void HoughLinesPointSet( InputArray _point, OutputArray _lines, int lines_max, i
AutoBuffer<float> _tabSin(numangle); AutoBuffer<float> _tabSin(numangle);
AutoBuffer<float> _tabCos(numangle); AutoBuffer<float> _tabCos(numangle);
int *accum = _accum.ptr<int>(); int *accum = _accum.ptr<int>();
float *tabSin = _tabSin, *tabCos = _tabCos; float *tabSin = _tabSin.data(), *tabCos = _tabCos.data();
// create sin and cos table // create sin and cos table
createTrigTable( numangle, min_theta, theta_step, createTrigTable( numangle, min_theta, theta_step,
@ -1408,8 +1408,8 @@ protected:
int nBins = cvRound((maxRadius - minRadius)/dr*nBinsPerDr); int nBins = cvRound((maxRadius - minRadius)/dr*nBinsPerDr);
AutoBuffer<int> bins(nBins); AutoBuffer<int> bins(nBins);
AutoBuffer<float> distBuf(nzSz), distSqrtBuf(nzSz); AutoBuffer<float> distBuf(nzSz), distSqrtBuf(nzSz);
float *ddata = distBuf; float *ddata = distBuf.data();
float *dSqrtData = distSqrtBuf; float *dSqrtData = distSqrtBuf.data();
bool singleThread = (boundaries == Range(0, centerSz)); bool singleThread = (boundaries == Range(0, centerSz));
int i = boundaries.start; int i = boundaries.start;
@ -1434,7 +1434,7 @@ protected:
Mat_<float> distSqrtMat(1, nzCount, dSqrtData); Mat_<float> distSqrtMat(1, nzCount, dSqrtData);
sqrt(distMat, distSqrtMat); sqrt(distMat, distSqrtMat);
memset(bins, 0, sizeof(bins[0])*bins.size()); memset(bins.data(), 0, sizeof(bins[0])*bins.size());
for(int k = 0; k < nzCount; k++) for(int k = 0; k < nzCount; k++)
{ {
int bin = std::max(0, std::min(nBins-1, cvRound((dSqrtData[k] - minRadius)/dr*nBinsPerDr))); int bin = std::max(0, std::min(nBins-1, cvRound((dSqrtData[k] - minRadius)/dr*nBinsPerDr)));

View File

@ -228,7 +228,7 @@ static const void* initInterTab2D( int method, bool fixpt )
{ {
AutoBuffer<float> _tab(8*INTER_TAB_SIZE); AutoBuffer<float> _tab(8*INTER_TAB_SIZE);
int i, j, k1, k2; int i, j, k1, k2;
initInterTab1D(method, _tab, INTER_TAB_SIZE); initInterTab1D(method, _tab.data(), INTER_TAB_SIZE);
for( i = 0; i < INTER_TAB_SIZE; i++ ) for( i = 0; i < INTER_TAB_SIZE; i++ )
for( j = 0; j < INTER_TAB_SIZE; j++, tab += ksize*ksize, itab += ksize*ksize ) for( j = 0; j < INTER_TAB_SIZE; j++, tab += ksize*ksize, itab += ksize*ksize )
{ {

View File

@ -360,7 +360,7 @@ static void fitLine2D( const Point2f * points, int count, int dist,
} }
AutoBuffer<float> wr(count*2); AutoBuffer<float> wr(count*2);
float *w = wr, *r = w + count; float *w = wr.data(), *r = w + count;
for( k = 0; k < 20; k++ ) for( k = 0; k < 20; k++ )
{ {
@ -495,7 +495,7 @@ static void fitLine3D( Point3f * points, int count, int dist,
} }
AutoBuffer<float> buf(count*2); AutoBuffer<float> buf(count*2);
float *w = buf, *r = w + count; float *w = buf.data(), *r = w + count;
for( k = 0; k < 20; k++ ) for( k = 0; k < 20; k++ )
{ {

View File

@ -607,7 +607,7 @@ void cv::createHanningWindow(OutputArray _dst, cv::Size winSize, int type)
int rows = dst.rows, cols = dst.cols; int rows = dst.rows, cols = dst.cols;
AutoBuffer<double> _wc(cols); AutoBuffer<double> _wc(cols);
double * const wc = (double *)_wc; double* const wc = _wc.data();
double coeff0 = 2.0 * CV_PI / (double)(cols - 1), coeff1 = 2.0f * CV_PI / (double)(rows - 1); double coeff0 = 2.0 * CV_PI / (double)(cols - 1), coeff1 = 2.0f * CV_PI / (double)(rows - 1);
for(int j = 0; j < cols; j++) for(int j = 0; j < cols; j++)

View File

@ -860,10 +860,10 @@ pyrDown_( const Mat& _src, Mat& _dst, int borderType )
int cn = _src.channels(); int cn = _src.channels();
int bufstep = (int)alignSize(dsize.width*cn, 16); int bufstep = (int)alignSize(dsize.width*cn, 16);
AutoBuffer<WT> _buf(bufstep*PD_SZ + 16); AutoBuffer<WT> _buf(bufstep*PD_SZ + 16);
WT* buf = alignPtr((WT*)_buf, 16); WT* buf = alignPtr((WT*)_buf.data(), 16);
int tabL[CV_CN_MAX*(PD_SZ+2)], tabR[CV_CN_MAX*(PD_SZ+2)]; int tabL[CV_CN_MAX*(PD_SZ+2)], tabR[CV_CN_MAX*(PD_SZ+2)];
AutoBuffer<int> _tabM(dsize.width*cn); AutoBuffer<int> _tabM(dsize.width*cn);
int* tabM = _tabM; int* tabM = _tabM.data();
WT* rows[PD_SZ]; WT* rows[PD_SZ];
CastOp castOp; CastOp castOp;
VecOp vecOp; VecOp vecOp;
@ -984,9 +984,9 @@ pyrUp_( const Mat& _src, Mat& _dst, int)
int cn = _src.channels(); int cn = _src.channels();
int bufstep = (int)alignSize((dsize.width+1)*cn, 16); int bufstep = (int)alignSize((dsize.width+1)*cn, 16);
AutoBuffer<WT> _buf(bufstep*PU_SZ + 16); AutoBuffer<WT> _buf(bufstep*PU_SZ + 16);
WT* buf = alignPtr((WT*)_buf, 16); WT* buf = alignPtr((WT*)_buf.data(), 16);
AutoBuffer<int> _dtab(ssize.width*cn); AutoBuffer<int> _dtab(ssize.width*cn);
int* dtab = _dtab; int* dtab = _dtab.data();
WT* rows[PU_SZ]; WT* rows[PU_SZ];
T* dsts[2]; T* dsts[2];
CastOp castOp; CastOp castOp;

View File

@ -686,18 +686,18 @@ public:
{ {
last_eval = 1 - interp_y_len; last_eval = 1 - interp_y_len;
evalbuf_start = 1; evalbuf_start = 1;
hResize((ET*)src, cn, xoffsets, xcoeffs, (fixedpoint*)linebuf, min_x, max_x, dst_width); hResize((ET*)src, cn, xoffsets, xcoeffs, linebuf.data(), min_x, max_x, dst_width);
} }
int dy = range.start; int dy = range.start;
for (; dy < rmin_y; dy++) for (; dy < rmin_y; dy++)
vlineSet<ET, FT>((fixedpoint*)linebuf, (ET*)(dst + dst_step * dy), dst_width*cn); vlineSet<ET, FT>(linebuf.data(), (ET*)(dst + dst_step * dy), dst_width*cn);
for (; dy < rmax_y; dy++) for (; dy < rmax_y; dy++)
{ {
int &iy = yoffsets[dy]; int &iy = yoffsets[dy];
int i; int i;
for (i = max(iy, last_eval + interp_y_len); i < min(iy + interp_y_len, src_height); i++, evalbuf_start = (evalbuf_start + 1) % interp_y_len) for (i = max(iy, last_eval + interp_y_len); i < min(iy + interp_y_len, src_height); i++, evalbuf_start = (evalbuf_start + 1) % interp_y_len)
hResize((ET*)(src + i * src_step), cn, xoffsets, xcoeffs, (fixedpoint*)linebuf + evalbuf_start*(dst_width * cn), min_x, max_x, dst_width); hResize((ET*)(src + i * src_step), cn, xoffsets, xcoeffs, linebuf.data() + evalbuf_start*(dst_width * cn), min_x, max_x, dst_width);
evalbuf_start = (evalbuf_start + max(iy, src_height - interp_y_len) - max(last_eval, src_height - interp_y_len)) % interp_y_len; evalbuf_start = (evalbuf_start + max(iy, src_height - interp_y_len) - max(last_eval, src_height - interp_y_len)) % interp_y_len;
last_eval = iy; last_eval = iy;
@ -707,9 +707,9 @@ public:
for (; i < interp_y_len; i++) for (; i < interp_y_len; i++)
curcoeffs[i] = ycoeffs[ dy*interp_y_len - evalbuf_start + i]; curcoeffs[i] = ycoeffs[ dy*interp_y_len - evalbuf_start + i];
vlineResize<ET, FT, interp_y_len>((fixedpoint*)linebuf, dst_width*cn, curcoeffs, (ET*)(dst + dst_step * dy), dst_width*cn); vlineResize<ET, FT, interp_y_len>(linebuf.data(), dst_width*cn, curcoeffs, (ET*)(dst + dst_step * dy), dst_width*cn);
} }
fixedpoint *endline = (fixedpoint*)linebuf; fixedpoint *endline = linebuf.data();
if (last_eval + interp_y_len > src_height) if (last_eval + interp_y_len > src_height)
endline += dst_width*cn*((evalbuf_start + src_height - 1 - last_eval) % interp_y_len); endline += dst_width*cn*((evalbuf_start + src_height - 1 - last_eval) % interp_y_len);
else else
@ -757,7 +757,7 @@ void resize_bitExact(const uchar* src, size_t src_step, int src_width, int src_h
dst_height * sizeof(int) + dst_height * sizeof(int) +
dst_width * interp_x.len*sizeof(fixedpoint) + dst_width * interp_x.len*sizeof(fixedpoint) +
dst_height * interp_y.len * sizeof(fixedpoint) ); dst_height * interp_y.len * sizeof(fixedpoint) );
int* xoffsets = (int*)((uchar*)buf); int* xoffsets = (int*)buf.data();
int* yoffsets = xoffsets + dst_width; int* yoffsets = xoffsets + dst_width;
fixedpoint* xcoeffs = (fixedpoint*)(yoffsets + dst_height); fixedpoint* xcoeffs = (fixedpoint*)(yoffsets + dst_height);
fixedpoint* ycoeffs = xcoeffs + dst_width * interp_x.len; fixedpoint* ycoeffs = xcoeffs + dst_width * interp_x.len;
@ -950,7 +950,7 @@ resizeNN( const Mat& src, Mat& dst, double fx, double fy )
{ {
Size ssize = src.size(), dsize = dst.size(); Size ssize = src.size(), dsize = dst.size();
AutoBuffer<int> _x_ofs(dsize.width); AutoBuffer<int> _x_ofs(dsize.width);
int* x_ofs = _x_ofs; int* x_ofs = _x_ofs.data();
int pix_size = (int)src.elemSize(); int pix_size = (int)src.elemSize();
int pix_size4 = (int)(pix_size / sizeof(int)); int pix_size4 = (int)(pix_size / sizeof(int));
double ifx = 1./fx, ify = 1./fy; double ifx = 1./fx, ify = 1./fy;
@ -2226,7 +2226,7 @@ public:
for(int k = 0; k < ksize; k++ ) for(int k = 0; k < ksize; k++ )
{ {
prev_sy[k] = -1; prev_sy[k] = -1;
rows[k] = (WT*)_buffer + bufstep*k; rows[k] = _buffer.data() + bufstep*k;
} }
const AT* beta = _beta + ksize * range.start; const AT* beta = _beta + ksize * range.start;
@ -3039,7 +3039,7 @@ public:
AutoBuffer<WT> _buffer(dsize.width*2); AutoBuffer<WT> _buffer(dsize.width*2);
const DecimateAlpha* xtab = xtab0; const DecimateAlpha* xtab = xtab0;
int xtab_size = xtab_size0; int xtab_size = xtab_size0;
WT *buf = _buffer, *sum = buf + dsize.width; WT *buf = _buffer.data(), *sum = buf + dsize.width;
int j_start = tabofs[range.start], j_end = tabofs[range.end], j, k, dx, prev_dy = ytab[j_start].di; int j_start = tabofs[range.start], j_end = tabofs[range.end], j, k, dx, prev_dy = ytab[j_start].di;
for( dx = 0; dx < dsize.width; dx++ ) for( dx = 0; dx < dsize.width; dx++ )
@ -3322,7 +3322,7 @@ static bool ocl_resize( InputArray _src, OutputArray _dst, Size dsize,
if (depth == CV_8U && ((void)0, 0)) if (depth == CV_8U && ((void)0, 0))
{ {
AutoBuffer<uchar> _buffer((dsize.width + dsize.height)*(sizeof(int) + sizeof(short)*2)); AutoBuffer<uchar> _buffer((dsize.width + dsize.height)*(sizeof(int) + sizeof(short)*2));
int* xofs = (int*)(uchar*)_buffer, * yofs = xofs + dsize.width; int* xofs = (int*)_buffer.data(), * yofs = xofs + dsize.width;
short* ialpha = (short*)(yofs + dsize.height), * ibeta = ialpha + dsize.width*2; short* ialpha = (short*)(yofs + dsize.height), * ibeta = ialpha + dsize.width*2;
float fxx, fyy; float fxx, fyy;
int sx, sy; int sx, sy;
@ -3357,7 +3357,7 @@ static bool ocl_resize( InputArray _src, OutputArray _dst, Size dsize,
int wdepth = std::max(depth, CV_32S), wtype = CV_MAKETYPE(wdepth, cn); int wdepth = std::max(depth, CV_32S), wtype = CV_MAKETYPE(wdepth, cn);
UMat coeffs; UMat coeffs;
Mat(1, static_cast<int>(_buffer.size()), CV_8UC1, (uchar *)_buffer).copyTo(coeffs); Mat(1, static_cast<int>(_buffer.size()), CV_8UC1, _buffer.data()).copyTo(coeffs);
k.create("resizeLN", ocl::imgproc::resize_oclsrc, k.create("resizeLN", ocl::imgproc::resize_oclsrc,
format("-D INTER_LINEAR_INTEGER -D depth=%d -D T=%s -D T1=%s " format("-D INTER_LINEAR_INTEGER -D depth=%d -D T=%s -D T1=%s "
@ -3440,17 +3440,17 @@ static bool ocl_resize( InputArray _src, OutputArray _dst, Size dsize,
AutoBuffer<int> _xymap_tab(xytab_size), _xyofs_tab(tabofs_size); AutoBuffer<int> _xymap_tab(xytab_size), _xyofs_tab(tabofs_size);
AutoBuffer<float> _xyalpha_tab(xytab_size); AutoBuffer<float> _xyalpha_tab(xytab_size);
int * xmap_tab = _xymap_tab, * ymap_tab = _xymap_tab + (ssize.width << 1); int * xmap_tab = _xymap_tab.data(), * ymap_tab = _xymap_tab.data() + (ssize.width << 1);
float * xalpha_tab = _xyalpha_tab, * yalpha_tab = _xyalpha_tab + (ssize.width << 1); float * xalpha_tab = _xyalpha_tab.data(), * yalpha_tab = _xyalpha_tab.data() + (ssize.width << 1);
int * xofs_tab = _xyofs_tab, * yofs_tab = _xyofs_tab + dsize.width + 1; int * xofs_tab = _xyofs_tab.data(), * yofs_tab = _xyofs_tab.data() + dsize.width + 1;
ocl_computeResizeAreaTabs(ssize.width, dsize.width, inv_fx, xmap_tab, xalpha_tab, xofs_tab); ocl_computeResizeAreaTabs(ssize.width, dsize.width, inv_fx, xmap_tab, xalpha_tab, xofs_tab);
ocl_computeResizeAreaTabs(ssize.height, dsize.height, inv_fy, ymap_tab, yalpha_tab, yofs_tab); ocl_computeResizeAreaTabs(ssize.height, dsize.height, inv_fy, ymap_tab, yalpha_tab, yofs_tab);
// loading precomputed arrays to GPU // loading precomputed arrays to GPU
Mat(1, xytab_size, CV_32FC1, (void *)_xyalpha_tab).copyTo(alphaOcl); Mat(1, xytab_size, CV_32FC1, _xyalpha_tab.data()).copyTo(alphaOcl);
Mat(1, xytab_size, CV_32SC1, (void *)_xymap_tab).copyTo(mapOcl); Mat(1, xytab_size, CV_32SC1, _xymap_tab.data()).copyTo(mapOcl);
Mat(1, tabofs_size, CV_32SC1, (void *)_xyofs_tab).copyTo(tabofsOcl); Mat(1, tabofs_size, CV_32SC1, _xyofs_tab.data()).copyTo(tabofsOcl);
} }
ocl::KernelArg srcarg = ocl::KernelArg::ReadOnly(src), dstarg = ocl::KernelArg::WriteOnly(dst); ocl::KernelArg srcarg = ocl::KernelArg::ReadOnly(src), dstarg = ocl::KernelArg::WriteOnly(dst);
@ -3856,7 +3856,7 @@ void resize(int src_type,
int area = iscale_x*iscale_y; int area = iscale_x*iscale_y;
size_t srcstep = src_step / src.elemSize1(); size_t srcstep = src_step / src.elemSize1();
AutoBuffer<int> _ofs(area + dsize.width*cn); AutoBuffer<int> _ofs(area + dsize.width*cn);
int* ofs = _ofs; int* ofs = _ofs.data();
int* xofs = ofs + area; int* xofs = ofs + area;
ResizeAreaFastFunc func = areafast_tab[depth]; ResizeAreaFastFunc func = areafast_tab[depth];
CV_Assert( func != 0 ); CV_Assert( func != 0 );
@ -3881,13 +3881,13 @@ void resize(int src_type,
CV_Assert( func != 0 && cn <= 4 ); CV_Assert( func != 0 && cn <= 4 );
AutoBuffer<DecimateAlpha> _xytab((src_width + src_height)*2); AutoBuffer<DecimateAlpha> _xytab((src_width + src_height)*2);
DecimateAlpha* xtab = _xytab, *ytab = xtab + src_width*2; DecimateAlpha* xtab = _xytab.data(), *ytab = xtab + src_width*2;
int xtab_size = computeResizeAreaTab(src_width, dsize.width, cn, scale_x, xtab); int xtab_size = computeResizeAreaTab(src_width, dsize.width, cn, scale_x, xtab);
int ytab_size = computeResizeAreaTab(src_height, dsize.height, 1, scale_y, ytab); int ytab_size = computeResizeAreaTab(src_height, dsize.height, 1, scale_y, ytab);
AutoBuffer<int> _tabofs(dsize.height + 1); AutoBuffer<int> _tabofs(dsize.height + 1);
int* tabofs = _tabofs; int* tabofs = _tabofs.data();
for( k = 0, dy = 0; k < ytab_size; k++ ) for( k = 0, dy = 0; k < ytab_size; k++ )
{ {
if( k == 0 || ytab[k].di != ytab[k-1].di ) if( k == 0 || ytab[k].di != ytab[k-1].di )
@ -3922,7 +3922,7 @@ void resize(int src_type,
CV_Assert( func != 0 ); CV_Assert( func != 0 );
AutoBuffer<uchar> _buffer((width + dsize.height)*(sizeof(int) + sizeof(float)*ksize)); AutoBuffer<uchar> _buffer((width + dsize.height)*(sizeof(int) + sizeof(float)*ksize));
int* xofs = (int*)(uchar*)_buffer; int* xofs = (int*)_buffer.data();
int* yofs = xofs + width; int* yofs = xofs + width;
float* alpha = (float*)(yofs + dsize.height); float* alpha = (float*)(yofs + dsize.height);
short* ialpha = (short*)alpha; short* ialpha = (short*)alpha;

View File

@ -96,7 +96,7 @@ static void rotatingCalipers( const Point2f* points, int n, int mode, float* out
char buffer[32] = {}; char buffer[32] = {};
int i, k; int i, k;
AutoBuffer<float> abuf(n*3); AutoBuffer<float> abuf(n*3);
float* inv_vect_length = abuf; float* inv_vect_length = abuf.data();
Point2f* vect = (Point2f*)(inv_vect_length + n); Point2f* vect = (Point2f*)(inv_vect_length + n);
int left = 0, bottom = 0, right = 0, top = 0; int left = 0, bottom = 0, right = 0, top = 0;
int seq[4] = { -1, -1, -1, -1 }; int seq[4] = { -1, -1, -1, -1 };

View File

@ -318,7 +318,7 @@ cv::RotatedRect cv::fitEllipse( InputArray _points )
const Point2f* ptsf = points.ptr<Point2f>(); const Point2f* ptsf = points.ptr<Point2f>();
AutoBuffer<double> _Ad(n*5), _bd(n); AutoBuffer<double> _Ad(n*5), _bd(n);
double *Ad = _Ad, *bd = _bd; double *Ad = _Ad.data(), *bd = _bd.data();
// first fit for parameters A - E // first fit for parameters A - E
Mat A( n, 5, CV_64F, Ad ); Mat A( n, 5, CV_64F, Ad );

View File

@ -3614,9 +3614,9 @@ public:
virtual void operator() (const Range& range) const CV_OVERRIDE virtual void operator() (const Range& range) const CV_OVERRIDE
{ {
AutoBuffer<FT> _buf(width*cn*kylen); AutoBuffer<FT> _buf(width*cn*kylen);
FT* buf = _buf; FT* buf = _buf.data();
AutoBuffer<FT*> _ptrs(kylen*2); AutoBuffer<FT*> _ptrs(kylen*2);
FT** ptrs = _ptrs; FT** ptrs = _ptrs.data();
if (kylen == 1) if (kylen == 1)
{ {

View File

@ -216,7 +216,7 @@ void integral_( const T* src, size_t _srcstep, ST* sum, size_t _sumstep,
else else
{ {
AutoBuffer<ST> _buf(width+cn); AutoBuffer<ST> _buf(width+cn);
ST* buf = _buf; ST* buf = _buf.data();
ST s; ST s;
QT sq; QT sq;
for( k = 0; k < cn; k++, src++, sum++, tilted++, buf++ ) for( k = 0; k < cn; k++, src++, sum++, tilted++, buf++ )

View File

@ -1584,7 +1584,7 @@ int CV_FitLineTest::prepare_test_case( int test_case_idx )
void CV_FitLineTest::run_func() void CV_FitLineTest::run_func()
{ {
if(!test_cpp) if(!test_cpp)
cvFitLine( points, dist_type, 0, reps, aeps, line ); cvFitLine( points, dist_type, 0, reps, aeps, line.data());
else if(dims == 2) else if(dims == 2)
cv::fitLine(cv::cvarrToMat(points), (cv::Vec4f&)line[0], dist_type, 0, reps, aeps); cv::fitLine(cv::cvarrToMat(points), (cv::Vec4f&)line[0], dist_type, 0, reps, aeps);
else else

View File

@ -434,7 +434,7 @@ public:
} }
cv::AutoBuffer<double> _buf(buf_sz+noutputs); cv::AutoBuffer<double> _buf(buf_sz+noutputs);
double* buf = _buf; double* buf = _buf.data();
if( !_outputs.needed() ) if( !_outputs.needed() )
{ {
@ -996,7 +996,7 @@ public:
_idx[i] = i; _idx[i] = i;
AutoBuffer<double> _buf(max_lsize*2); AutoBuffer<double> _buf(max_lsize*2);
double* buf[] = { _buf, (double*)_buf + max_lsize }; double* buf[] = { _buf.data(), _buf.data() + max_lsize };
const double* sw = _sw.empty() ? 0 : _sw.ptr<double>(); const double* sw = _sw.empty() ? 0 : _sw.ptr<double>();

View File

@ -205,7 +205,7 @@ public:
int nvars = (int)varIdx.size(); int nvars = (int)varIdx.size();
double sumw = 0., C = 1.; double sumw = 0., C = 1.;
cv::AutoBuffer<double> buf(n + nvars); cv::AutoBuffer<double> buf(n + nvars);
double* result = buf; double* result = buf.data();
float* sbuf = (float*)(result + n); float* sbuf = (float*)(result + n);
Mat sample(1, nvars, CV_32F, sbuf); Mat sample(1, nvars, CV_32F, sbuf);
int predictFlags = bparams.boostType == Boost::DISCRETE ? (PREDICT_MAX_VOTE | RAW_OUTPUT) : PREDICT_SUM; int predictFlags = bparams.boostType == Boost::DISCRETE ? (PREDICT_MAX_VOTE | RAW_OUTPUT) : PREDICT_SUM;

View File

@ -335,7 +335,7 @@ public:
CatMapHash ofshash; CatMapHash ofshash;
AutoBuffer<uchar> buf(nsamples); AutoBuffer<uchar> buf(nsamples);
Mat non_missing(layout == ROW_SAMPLE ? Size(1, nsamples) : Size(nsamples, 1), CV_8U, (uchar*)buf); Mat non_missing(layout == ROW_SAMPLE ? Size(1, nsamples) : Size(nsamples, 1), CV_8U, buf.data());
bool haveMissing = !missing.empty(); bool haveMissing = !missing.empty();
if( haveMissing ) if( haveMissing )
{ {

View File

@ -285,13 +285,13 @@ int KDTree::findNearest(InputArray _vec, int K, int emax,
CV_Assert(K > 0 && (normType == NORM_L2 || normType == NORM_L1)); CV_Assert(K > 0 && (normType == NORM_L2 || normType == NORM_L1));
AutoBuffer<uchar> _buf((K+1)*(sizeof(float) + sizeof(int))); AutoBuffer<uchar> _buf((K+1)*(sizeof(float) + sizeof(int)));
int* idx = (int*)(uchar*)_buf; int* idx = (int*)_buf.data();
float* dist = (float*)(idx + K + 1); float* dist = (float*)(idx + K + 1);
int i, j, ncount = 0, e = 0; int i, j, ncount = 0, e = 0;
int qsize = 0, maxqsize = 1 << 10; int qsize = 0, maxqsize = 1 << 10;
AutoBuffer<uchar> _pqueue(maxqsize*sizeof(PQueueElem)); AutoBuffer<uchar> _pqueue(maxqsize*sizeof(PQueueElem));
PQueueElem* pqueue = (PQueueElem*)(uchar*)_pqueue; PQueueElem* pqueue = (PQueueElem*)_pqueue.data();
emax = std::max(emax, 1); emax = std::max(emax, 1);
for( e = 0; e < emax; ) for( e = 0; e < emax; )
@ -433,7 +433,7 @@ void KDTree::findOrthoRange(InputArray _lowerBound,
std::vector<int> idx; std::vector<int> idx;
AutoBuffer<int> _stack(MAX_TREE_DEPTH*2 + 1); AutoBuffer<int> _stack(MAX_TREE_DEPTH*2 + 1);
int* stack = _stack; int* stack = _stack.data();
int top = 0; int top = 0;
stack[top++] = 0; stack[top++] = 0;

View File

@ -149,7 +149,7 @@ public:
int k = std::min(k0, nsamples); int k = std::min(k0, nsamples);
AutoBuffer<float> buf(testcount*k*2); AutoBuffer<float> buf(testcount*k*2);
float* dbuf = buf; float* dbuf = buf.data();
float* rbuf = dbuf + testcount*k; float* rbuf = dbuf + testcount*k;
const float* rptr = responses.ptr<float>(); const float* rptr = responses.ptr<float>();

View File

@ -241,8 +241,8 @@ public:
} }
// allocate memory and initializing headers for calculating // allocate memory and initializing headers for calculating
cv::AutoBuffer<double> _buffer(nvars*2); cv::AutoBuffer<double> _buffer(nvars*2);
double* _diffin = _buffer; double* _diffin = _buffer.data();
double* _diffout = _buffer + nvars; double* _diffout = _buffer.data() + nvars;
Mat diffin( 1, nvars, CV_64FC1, _diffin ); Mat diffin( 1, nvars, CV_64FC1, _diffin );
Mat diffout( 1, nvars, CV_64FC1, _diffout ); Mat diffout( 1, nvars, CV_64FC1, _diffout );

View File

@ -1579,7 +1579,7 @@ public:
return; return;
AutoBuffer<double> vbuf(var_count); AutoBuffer<double> vbuf(var_count);
double* v = vbuf; double* v = vbuf.data();
Mat new_sv(df_count, var_count, CV_32F); Mat new_sv(df_count, var_count, CV_32F);
vector<DecisionFunc> new_df; vector<DecisionFunc> new_df;
@ -1914,7 +1914,7 @@ public:
int class_count = !svm->class_labels.empty() ? (int)svm->class_labels.total() : svmType == ONE_CLASS ? 1 : 0; int class_count = !svm->class_labels.empty() ? (int)svm->class_labels.total() : svmType == ONE_CLASS ? 1 : 0;
AutoBuffer<float> _buffer(sv_total + (class_count+1)*2); AutoBuffer<float> _buffer(sv_total + (class_count+1)*2);
float* buffer = _buffer; float* buffer = _buffer.data();
int i, j, dfi, k, si; int i, j, dfi, k, si;

View File

@ -417,7 +417,7 @@ int DTreesImpl::findBestSplit( const vector<int>& _sidx )
int splitidx = -1; int splitidx = -1;
int vi_, nv = (int)activeVars.size(); int vi_, nv = (int)activeVars.size();
AutoBuffer<int> buf(w->maxSubsetSize*2); AutoBuffer<int> buf(w->maxSubsetSize*2);
int *subset = buf, *best_subset = subset + w->maxSubsetSize; int *subset = buf.data(), *best_subset = subset + w->maxSubsetSize;
WSplit split, best_split; WSplit split, best_split;
best_split.quality = 0.; best_split.quality = 0.;
@ -488,7 +488,7 @@ void DTreesImpl::calcValue( int nidx, const vector<int>& _sidx )
// misclassified samples with cv_labels(*)==j. // misclassified samples with cv_labels(*)==j.
// compute the number of instances of each class // compute the number of instances of each class
double* cls_count = buf; double* cls_count = buf.data();
double* cv_cls_count = cls_count + m; double* cv_cls_count = cls_count + m;
double max_val = -1, total_weight = 0; double max_val = -1, total_weight = 0;
@ -592,7 +592,7 @@ void DTreesImpl::calcValue( int nidx, const vector<int>& _sidx )
} }
else else
{ {
double *cv_sum = buf, *cv_sum2 = cv_sum + cv_n; double *cv_sum = buf.data(), *cv_sum2 = cv_sum + cv_n;
double* cv_count = (double*)(cv_sum2 + cv_n); double* cv_count = (double*)(cv_sum2 + cv_n);
for( j = 0; j < cv_n; j++ ) for( j = 0; j < cv_n; j++ )
@ -646,7 +646,7 @@ DTreesImpl::WSplit DTreesImpl::findSplitOrdClass( int vi, const vector<int>& _si
const int* sidx = &_sidx[0]; const int* sidx = &_sidx[0];
const int* responses = &w->cat_responses[0]; const int* responses = &w->cat_responses[0];
const double* weights = &w->sample_weights[0]; const double* weights = &w->sample_weights[0];
double* lcw = (double*)(uchar*)buf; double* lcw = (double*)buf.data();
double* rcw = lcw + m; double* rcw = lcw + m;
float* values = (float*)(rcw + m); float* values = (float*)(rcw + m);
int* sorted_idx = (int*)(values + n); int* sorted_idx = (int*)(values + n);
@ -717,7 +717,7 @@ void DTreesImpl::clusterCategories( const double* vectors, int n, int m, double*
int iters = 0, max_iters = 100; int iters = 0, max_iters = 100;
int i, j, idx; int i, j, idx;
cv::AutoBuffer<double> buf(n + k); cv::AutoBuffer<double> buf(n + k);
double *v_weights = buf, *c_weights = buf + n; double *v_weights = buf.data(), *c_weights = buf.data() + n;
bool modified = true; bool modified = true;
RNG r((uint64)-1); RNG r((uint64)-1);
@ -819,12 +819,12 @@ DTreesImpl::WSplit DTreesImpl::findSplitCatClass( int vi, const vector<int>& _si
base_size += mi; base_size += mi;
AutoBuffer<double> buf(base_size + n); AutoBuffer<double> buf(base_size + n);
double* lc = (double*)buf; double* lc = buf.data();
double* rc = lc + m; double* rc = lc + m;
double* _cjk = rc + m*2, *cjk = _cjk; double* _cjk = rc + m*2, *cjk = _cjk;
double* c_weights = cjk + m*mi; double* c_weights = cjk + m*mi;
int* labels = (int*)(buf + base_size); int* labels = (int*)(buf.data() + base_size);
w->data->getNormCatValues(vi, _sidx, labels); w->data->getNormCatValues(vi, _sidx, labels);
const int* responses = &w->cat_responses[0]; const int* responses = &w->cat_responses[0];
const double* weights = &w->sample_weights[0]; const double* weights = &w->sample_weights[0];
@ -991,7 +991,7 @@ DTreesImpl::WSplit DTreesImpl::findSplitOrdReg( int vi, const vector<int>& _sidx
AutoBuffer<uchar> buf(n*(sizeof(int) + sizeof(float))); AutoBuffer<uchar> buf(n*(sizeof(int) + sizeof(float)));
float* values = (float*)(uchar*)buf; float* values = (float*)buf.data();
int* sorted_idx = (int*)(values + n); int* sorted_idx = (int*)(values + n);
w->data->getValues(vi, _sidx, values); w->data->getValues(vi, _sidx, values);
const double* responses = &w->ord_responses[0]; const double* responses = &w->ord_responses[0];
@ -1053,7 +1053,7 @@ DTreesImpl::WSplit DTreesImpl::findSplitCatReg( int vi, const vector<int>& _sidx
int mi = getCatCount(vi); int mi = getCatCount(vi);
AutoBuffer<double> buf(3*mi + 3 + n); AutoBuffer<double> buf(3*mi + 3 + n);
double* sum = (double*)buf + 1; double* sum = buf.data() + 1;
double* counts = sum + mi + 1; double* counts = sum + mi + 1;
double** sum_ptr = (double**)(counts + mi); double** sum_ptr = (double**)(counts + mi);
int* cat_labels = (int*)(sum_ptr + mi); int* cat_labels = (int*)(sum_ptr + mi);
@ -1148,7 +1148,7 @@ int DTreesImpl::calcDir( int splitidx, const vector<int>& _sidx,
if( mi <= 0 ) // split on an ordered variable if( mi <= 0 ) // split on an ordered variable
{ {
float c = split.c; float c = split.c;
float* values = buf; float* values = buf.data();
w->data->getValues(vi, _sidx, values); w->data->getValues(vi, _sidx, values);
for( i = 0; i < n; i++ ) for( i = 0; i < n; i++ )
@ -1169,7 +1169,7 @@ int DTreesImpl::calcDir( int splitidx, const vector<int>& _sidx,
else else
{ {
const int* subset = &w->wsubsets[split.subsetOfs]; const int* subset = &w->wsubsets[split.subsetOfs];
int* cat_labels = (int*)(float*)buf; int* cat_labels = (int*)buf.data();
w->data->getNormCatValues(vi, _sidx, cat_labels); w->data->getNormCatValues(vi, _sidx, cat_labels);
for( i = 0; i < n; i++ ) for( i = 0; i < n; i++ )
@ -1372,7 +1372,7 @@ float DTreesImpl::predictTrees( const Range& range, const Mat& sample, int flags
int i, ncats = (int)catOfs.size(), nclasses = (int)classLabels.size(); int i, ncats = (int)catOfs.size(), nclasses = (int)classLabels.size();
int catbufsize = ncats > 0 ? nvars : 0; int catbufsize = ncats > 0 ? nvars : 0;
AutoBuffer<int> buf(nclasses + catbufsize + 1); AutoBuffer<int> buf(nclasses + catbufsize + 1);
int* votes = buf; int* votes = buf.data();
int* catbuf = votes + nclasses; int* catbuf = votes + nclasses;
const int* cvidx = (flags & (COMPRESSED_INPUT|PREPROCESSED_INPUT)) == 0 && !varIdx.empty() ? &compVarIdx[0] : 0; const int* cvidx = (flags & (COMPRESSED_INPUT|PREPROCESSED_INPUT)) == 0 && !varIdx.empty() ? &compVarIdx[0] : 0;
const uchar* vtype = &varType[0]; const uchar* vtype = &varType[0];

View File

@ -1346,7 +1346,7 @@ void CascadeClassifierImpl::detectMultiScaleNoGrouping( InputArray _image, std::
size_t i, nscales = scales.size(); size_t i, nscales = scales.size();
cv::AutoBuffer<int> stripeSizeBuf(nscales); cv::AutoBuffer<int> stripeSizeBuf(nscales);
int* stripeSizes = stripeSizeBuf; int* stripeSizes = stripeSizeBuf.data();
const FeatureEvaluator::ScaleData* s = &featureEvaluator->getScaleData(0); const FeatureEvaluator::ScaleData* s = &featureEvaluator->getScaleData(0);
Size szw = s->getWorkingSize(data.origWinSize); Size szw = s->getWorkingSize(data.origWinSize);
int nstripes = cvCeil(szw.width/32.); int nstripes = cvCeil(szw.width/32.);

View File

@ -297,7 +297,7 @@ void HOGDescriptor::computeGradient(const Mat& img, Mat& grad, Mat& qangle,
#endif #endif
AutoBuffer<int> mapbuf(gradsize.width + gradsize.height + 4); AutoBuffer<int> mapbuf(gradsize.width + gradsize.height + 4);
int* xmap = (int*)mapbuf + 1; int* xmap = mapbuf.data() + 1;
int* ymap = xmap + gradsize.width + 2; int* ymap = xmap + gradsize.width + 2;
const int borderType = (int)BORDER_REFLECT_101; const int borderType = (int)BORDER_REFLECT_101;
@ -312,7 +312,7 @@ void HOGDescriptor::computeGradient(const Mat& img, Mat& grad, Mat& qangle,
// x- & y- derivatives for the whole row // x- & y- derivatives for the whole row
int width = gradsize.width; int width = gradsize.width;
AutoBuffer<float> _dbuf(width*4); AutoBuffer<float> _dbuf(width*4);
float* const dbuf = _dbuf; float* const dbuf = _dbuf.data();
Mat Dx(1, width, CV_32F, dbuf); Mat Dx(1, width, CV_32F, dbuf);
Mat Dy(1, width, CV_32F, dbuf + width); Mat Dy(1, width, CV_32F, dbuf + width);
Mat Mag(1, width, CV_32F, dbuf + width*2); Mat Mag(1, width, CV_32F, dbuf + width*2);
@ -656,7 +656,7 @@ void HOGCache::init(const HOGDescriptor* _descriptor,
{ {
AutoBuffer<float> di(blockSize.height), dj(blockSize.width); AutoBuffer<float> di(blockSize.height), dj(blockSize.width);
float* _di = (float*)di, *_dj = (float*)dj; float* _di = di.data(), *_dj = dj.data();
float bh = blockSize.height * 0.5f, bw = blockSize.width * 0.5f; float bh = blockSize.height * 0.5f, bw = blockSize.width * 0.5f;
i = 0; i = 0;

View File

@ -1193,7 +1193,7 @@ void HOGDescriptorTester::computeGradient(const Mat& img, Mat& grad, Mat& qangle
_lut(0,i) = (float)i; _lut(0,i) = (float)i;
AutoBuffer<int> mapbuf(gradsize.width + gradsize.height + 4); AutoBuffer<int> mapbuf(gradsize.width + gradsize.height + 4);
int* xmap = (int*)mapbuf + 1; int* xmap = mapbuf.data() + 1;
int* ymap = xmap + gradsize.width + 2; int* ymap = xmap + gradsize.width + 2;
const int borderType = (int)BORDER_REFLECT_101; const int borderType = (int)BORDER_REFLECT_101;
@ -1208,7 +1208,7 @@ void HOGDescriptorTester::computeGradient(const Mat& img, Mat& grad, Mat& qangle
// x- & y- derivatives for the whole row // x- & y- derivatives for the whole row
int width = gradsize.width; int width = gradsize.width;
AutoBuffer<float> _dbuf(width*4); AutoBuffer<float> _dbuf(width*4);
float* dbuf = _dbuf; float* dbuf = _dbuf.data();
Mat Dx(1, width, CV_32F, dbuf); Mat Dx(1, width, CV_32F, dbuf);
Mat Dy(1, width, CV_32F, dbuf + width); Mat Dy(1, width, CV_32F, dbuf + width);
Mat Mag(1, width, CV_32F, dbuf + width*2); Mat Mag(1, width, CV_32F, dbuf + width*2);

View File

@ -189,7 +189,7 @@ public:
_sizes[i] = sizes[i]; _sizes[i] = sizes[i];
if( cn > 1 ) if( cn > 1 )
_sizes[dims++] = cn; _sizes[dims++] = cn;
PyObject* o = PyArray_SimpleNew(dims, _sizes, typenum); PyObject* o = PyArray_SimpleNew(dims, _sizes.data(), typenum);
if(!o) if(!o)
CV_Error_(Error::StsError, ("The numpy array of typenum=%d, ndims=%d can not be created", typenum, dims)); CV_Error_(Error::StsError, ("The numpy array of typenum=%d, ndims=%d can not be created", typenum, dims));
return allocate(o, dims0, sizes, type, step); return allocate(o, dims0, sizes, type, step);

View File

@ -2166,7 +2166,7 @@ void perf::sort(std::vector<cv::KeyPoint>& pts, cv::InputOutputArray descriptors
for (int i = 0; i < desc.rows; ++i) for (int i = 0; i < desc.rows; ++i)
idxs[i] = i; idxs[i] = i;
std::sort((int*)idxs, (int*)idxs + desc.rows, KeypointComparator(pts)); std::sort(idxs.data(), idxs.data() + desc.rows, KeypointComparator(pts));
std::vector<cv::KeyPoint> spts(pts.size()); std::vector<cv::KeyPoint> spts(pts.size());
cv::Mat sdesc(desc.size(), desc.type()); cv::Mat sdesc(desc.size(), desc.type());

View File

@ -575,7 +575,7 @@ public:
for( int y = y0; y < y1; y++ ) for( int y = y0; y < y1; y++ )
{ {
const float* data = buf; const float* data = buf.data();
if( src->depth() != CV_32F ) if( src->depth() != CV_32F )
src->row(y).convertTo(Mat(1, ncols, CV_32FC(nchannels), (void*)data), CV_32F); src->row(y).convertTo(Mat(1, ncols, CV_32FC(nchannels), (void*)data), CV_32F);
else else

View File

@ -67,7 +67,7 @@ static void calcSharrDeriv(const cv::Mat& src, cv::Mat& dst)
int x, y, delta = (int)alignSize((cols + 2)*cn, 16); int x, y, delta = (int)alignSize((cols + 2)*cn, 16);
AutoBuffer<deriv_type> _tempBuf(delta*2 + 64); AutoBuffer<deriv_type> _tempBuf(delta*2 + 64);
deriv_type *trow0 = alignPtr(_tempBuf + cn, 16), *trow1 = alignPtr(trow0 + delta, 16); deriv_type *trow0 = alignPtr(_tempBuf.data() + cn, 16), *trow1 = alignPtr(trow0 + delta, 16);
#if CV_SIMD128 #if CV_SIMD128
v_int16x8 c3 = v_setall_s16(3), c10 = v_setall_s16(10); v_int16x8 c3 = v_setall_s16(3), c10 = v_setall_s16(10);
@ -191,8 +191,8 @@ void cv::detail::LKTrackerInvoker::operator()(const Range& range) const
cv::AutoBuffer<deriv_type> _buf(winSize.area()*(cn + cn2)); cv::AutoBuffer<deriv_type> _buf(winSize.area()*(cn + cn2));
int derivDepth = DataType<deriv_type>::depth; int derivDepth = DataType<deriv_type>::depth;
Mat IWinBuf(winSize, CV_MAKETYPE(derivDepth, cn), (deriv_type*)_buf); Mat IWinBuf(winSize, CV_MAKETYPE(derivDepth, cn), _buf.data());
Mat derivIWinBuf(winSize, CV_MAKETYPE(derivDepth, cn2), (deriv_type*)_buf + winSize.area()*cn); Mat derivIWinBuf(winSize, CV_MAKETYPE(derivDepth, cn2), _buf.data() + winSize.area()*cn);
for( int ptidx = range.start; ptidx < range.end; ptidx++ ) for( int ptidx = range.start; ptidx < range.end; ptidx++ )
{ {

View File

@ -121,10 +121,10 @@ FarnebackPolyExp( const Mat& src, Mat& dst, int n, double sigma )
int width = src.cols; int width = src.cols;
int height = src.rows; int height = src.rows;
AutoBuffer<float> kbuf(n*6 + 3), _row((width + n*2)*3); AutoBuffer<float> kbuf(n*6 + 3), _row((width + n*2)*3);
float* g = kbuf + n; float* g = kbuf.data() + n;
float* xg = g + n*2 + 1; float* xg = g + n*2 + 1;
float* xxg = xg + n*2 + 1; float* xxg = xg + n*2 + 1;
float *row = (float*)_row + n*3; float *row = _row.data() + n*3;
double ig11, ig03, ig33, ig55; double ig11, ig03, ig33, ig55;
FarnebackPrepareGaussian(n, sigma, g, xg, xxg, ig11, ig03, ig33, ig55); FarnebackPrepareGaussian(n, sigma, g, xg, xxg, ig11, ig03, ig33, ig55);
@ -322,7 +322,7 @@ FarnebackUpdateFlow_Blur( const Mat& _R0, const Mat& _R1,
double scale = 1./(block_size*block_size); double scale = 1./(block_size*block_size);
AutoBuffer<double> _vsum((width+m*2+2)*5); AutoBuffer<double> _vsum((width+m*2+2)*5);
double* vsum = _vsum + (m+1)*5; double* vsum = _vsum.data() + (m+1)*5;
// init vsum // init vsum
const float* srow0 = matM.ptr<float>(); const float* srow0 = matM.ptr<float>();
@ -416,10 +416,10 @@ FarnebackUpdateFlow_GaussianBlur( const Mat& _R0, const Mat& _R1,
AutoBuffer<float> _vsum((width+m*2+2)*5 + 16), _hsum(width*5 + 16); AutoBuffer<float> _vsum((width+m*2+2)*5 + 16), _hsum(width*5 + 16);
AutoBuffer<float> _kernel((m+1)*5 + 16); AutoBuffer<float> _kernel((m+1)*5 + 16);
AutoBuffer<float*> _srow(m*2+1); AutoBuffer<const float*> _srow(m*2+1);
float *vsum = alignPtr((float*)_vsum + (m+1)*5, 16), *hsum = alignPtr((float*)_hsum, 16); float *vsum = alignPtr(_vsum.data() + (m+1)*5, 16), *hsum = alignPtr(_hsum.data(), 16);
float* kernel = (float*)_kernel; float* kernel = _kernel.data();
const float** srow = (const float**)&_srow[0]; const float** srow = _srow.data();
kernel[0] = (float)s; kernel[0] = (float)s;
for( i = 1; i <= m; i++ ) for( i = 1; i <= m; i++ )

View File

@ -96,7 +96,7 @@ SurfacePool::SurfacePool(ushort width_, ushort height_, ushort count, const mfxF
for(int i = 0; i < count; ++i) for(int i = 0; i < count; ++i)
{ {
mfxFrameSurface1 &surface = surfaces[i]; mfxFrameSurface1 &surface = surfaces[i];
uint8_t * dataPtr = buffers + oneSize * i; uint8_t * dataPtr = buffers.data() + oneSize * i;
memset(&surface, 0, sizeof(mfxFrameSurface1)); memset(&surface, 0, sizeof(mfxFrameSurface1));
surface.Info = frameInfo; surface.Info = frameInfo;
surface.Data.Y = dataPtr; surface.Data.Y = dataPtr;

View File

@ -1029,8 +1029,8 @@ bool CvCapture_MSMF::open(const cv::String& _filename)
srAttr->SetUnknown(MF_SOURCE_READER_D3D_MANAGER, D3DMgr.Get()); srAttr->SetUnknown(MF_SOURCE_READER_D3D_MANAGER, D3DMgr.Get());
#endif #endif
cv::AutoBuffer<wchar_t> unicodeFileName(_filename.length() + 1); cv::AutoBuffer<wchar_t> unicodeFileName(_filename.length() + 1);
MultiByteToWideChar(CP_ACP, 0, _filename.c_str(), -1, unicodeFileName, (int)_filename.length() + 1); MultiByteToWideChar(CP_ACP, 0, _filename.c_str(), -1, unicodeFileName.data(), (int)_filename.length() + 1);
if (SUCCEEDED(MFCreateSourceReaderFromURL(unicodeFileName, srAttr.Get(), &videoFileSource))) if (SUCCEEDED(MFCreateSourceReaderFromURL(unicodeFileName.data(), srAttr.Get(), &videoFileSource)))
{ {
isOpen = true; isOpen = true;
sampleTime = 0; sampleTime = 0;
@ -2081,8 +2081,8 @@ bool CvVideoWriter_MSMF::open( const cv::String& filename, int fourcc,
{ {
// Create the sink writer // Create the sink writer
cv::AutoBuffer<wchar_t> unicodeFileName(filename.length() + 1); cv::AutoBuffer<wchar_t> unicodeFileName(filename.length() + 1);
MultiByteToWideChar(CP_ACP, 0, filename.c_str(), -1, unicodeFileName, (int)filename.length() + 1); MultiByteToWideChar(CP_ACP, 0, filename.c_str(), -1, unicodeFileName.data(), (int)filename.length() + 1);
HRESULT hr = MFCreateSinkWriterFromURL(unicodeFileName, NULL, spAttr.Get(), &sinkWriter); HRESULT hr = MFCreateSinkWriterFromURL(unicodeFileName.data(), NULL, spAttr.Get(), &sinkWriter);
if (SUCCEEDED(hr)) if (SUCCEEDED(hr))
{ {
// Configure the sink writer and tell it start to start accepting data // Configure the sink writer and tell it start to start accepting data