Skip to content

Commit bcddb16

Browse files
committed
Merge pull request #1662 from alalek:update_autobuffer_api
2 parents d4e0286 + fc69aa5 commit bcddb16

File tree

10 files changed

+26
-31
lines changed

10 files changed

+26
-31
lines changed

modules/aruco/src/apriltag_quad_thresh.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ void ptsort_(struct pt *pts, int sz)
9494

9595
// Use stack storage if it's not too big.
9696
cv::AutoBuffer<struct pt, 1024> _tmp_stack(sz);
97-
memcpy(_tmp_stack, pts, sizeof(struct pt) * sz);
97+
memcpy(_tmp_stack.data(), pts, sizeof(struct pt) * sz);
9898

9999
int asz = sz/2;
100100
int bsz = sz - asz;
@@ -470,11 +470,11 @@ int quad_segment_agg(int sz, struct line_fit_pt *lfps, int indices[4]){
470470
int rvalloc_pos = 0;
471471
int rvalloc_size = 3*sz;
472472
cv::AutoBuffer<struct remove_vertex, 0> rvalloc_(std::max(1, rvalloc_size));
473-
memset(rvalloc_, 0, sizeof(rvalloc_[0]) * rvalloc_.size()); // TODO Add AutoBuffer zero fill
474-
struct remove_vertex *rvalloc = rvalloc_;
473+
memset(rvalloc_.data(), 0, sizeof(rvalloc_[0]) * rvalloc_.size()); // TODO Add AutoBuffer zero fill
474+
struct remove_vertex *rvalloc = rvalloc_.data();
475475
cv::AutoBuffer<struct segment, 0> segs_(std::max(1, sz)); // TODO Add AutoBuffer zero fill
476-
memset(segs_, 0, sizeof(segs_[0]) * segs_.size());
477-
struct segment *segs = segs_;
476+
memset(segs_.data(), 0, sizeof(segs_[0]) * segs_.size());
477+
struct segment *segs = segs_.data();
478478

479479
// populate with initial entries
480480
for (int i = 0; i < sz; i++) {
@@ -753,8 +753,8 @@ int fit_quad(const Ptr<DetectorParameters> &_params, const Mat im, zarray_t *clu
753753
// efficiently computed for any contiguous range of indices.
754754

755755
cv::AutoBuffer<struct line_fit_pt, 64> lfps_(sz);
756-
memset(lfps_, 0, sizeof(lfps_[0]) * lfps_.size()); // TODO Add AutoBuffer zero fill
757-
struct line_fit_pt *lfps = lfps_;
756+
memset(lfps_.data(), 0, sizeof(lfps_[0]) * lfps_.size()); // TODO Add AutoBuffer zero fill
757+
struct line_fit_pt *lfps = lfps_.data();
758758

759759
for (int i = 0; i < sz; i++) {
760760
struct pt *p;

modules/aruco/src/zmaxheap.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,9 @@ static inline void _swap_default(zmaxheap_t *heap, int a, int b)
4949
heap->values[b] = t;
5050

5151
cv::AutoBuffer<char> tmp(heap->el_sz);
52-
memcpy(tmp, &heap->data[a*heap->el_sz], heap->el_sz);
52+
memcpy(tmp.data(), &heap->data[a*heap->el_sz], heap->el_sz);
5353
memcpy(&heap->data[a*heap->el_sz], &heap->data[b*heap->el_sz], heap->el_sz);
54-
memcpy(&heap->data[b*heap->el_sz], tmp, heap->el_sz);
54+
memcpy(&heap->data[b*heap->el_sz], tmp.data(), heap->el_sz);
5555
}
5656

5757
static inline void _swap_pointer(zmaxheap_t *heap, int a, int b)

modules/optflow/src/dis_flow.cpp

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -380,12 +380,7 @@ void DISOpticalFlowImpl::precomputeStructureTensor(Mat &dst_I0xx, Mat &dst_I0yy,
380380
}
381381
}
382382

383-
AutoBuffer<float> sum_xx_buf(ws), sum_yy_buf(ws), sum_xy_buf(ws), sum_x_buf(ws), sum_y_buf(ws);
384-
float *sum_xx = (float *)sum_xx_buf;
385-
float *sum_yy = (float *)sum_yy_buf;
386-
float *sum_xy = (float *)sum_xy_buf;
387-
float *sum_x = (float *)sum_x_buf;
388-
float *sum_y = (float *)sum_y_buf;
383+
AutoBuffer<float> sum_xx(ws), sum_yy(ws), sum_xy(ws), sum_x(ws), sum_y(ws);
389384
for (int j = 0; j < ws; j++)
390385
{
391386
sum_xx[j] = 0.0f;

modules/rgbd/src/linemod.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -290,11 +290,11 @@ static void quantizedOrientations(const Mat& src, Mat& magnitude,
290290
float * ptr0y = (float *)sobel_dy.data;
291291
float * ptrmg = (float *)magnitude.data;
292292

293-
const int length1 = static_cast<const int>(sobel_3dx.step1());
294-
const int length2 = static_cast<const int>(sobel_3dy.step1());
295-
const int length3 = static_cast<const int>(sobel_dx.step1());
296-
const int length4 = static_cast<const int>(sobel_dy.step1());
297-
const int length5 = static_cast<const int>(magnitude.step1());
293+
const int length1 = static_cast<int>(sobel_3dx.step1());
294+
const int length2 = static_cast<int>(sobel_3dy.step1());
295+
const int length3 = static_cast<int>(sobel_dx.step1());
296+
const int length4 = static_cast<int>(sobel_dy.step1());
297+
const int length5 = static_cast<int>(magnitude.step1());
298298
const int length0 = sobel_3dy.cols * 3;
299299

300300
for (int r = 0; r < sobel_3dy.rows; ++r)

modules/rgbd/src/odometry.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -469,7 +469,7 @@ void computeCorresps(const Mat& K, const Mat& K_inv, const Mat& Rt,
469469
const double * Kt_ptr = Kt.ptr<const double>();
470470

471471
AutoBuffer<float> buf(3 * (depth1.cols + depth1.rows));
472-
float *KRK_inv0_u1 = buf;
472+
float *KRK_inv0_u1 = buf.data();
473473
float *KRK_inv1_v1_plus_KRK_inv2 = KRK_inv0_u1 + depth1.cols;
474474
float *KRK_inv3_u1 = KRK_inv1_v1_plus_KRK_inv2 + depth1.rows;
475475
float *KRK_inv4_v1_plus_KRK_inv5 = KRK_inv3_u1 + depth1.cols;
@@ -647,7 +647,7 @@ void calcRgbdLsmMatrices(const Mat& image0, const Mat& cloud0, const Mat& Rt,
647647
const double * Rt_ptr = Rt.ptr<const double>();
648648

649649
AutoBuffer<float> diffs(correspsCount);
650-
float* diffs_ptr = diffs;
650+
float* diffs_ptr = diffs.data();
651651

652652
const Vec4i* corresps_ptr = corresps.ptr<Vec4i>();
653653

@@ -720,10 +720,10 @@ void calcICPLsmMatrices(const Mat& cloud0, const Mat& Rt,
720720
const double * Rt_ptr = Rt.ptr<const double>();
721721

722722
AutoBuffer<float> diffs(correspsCount);
723-
float * diffs_ptr = diffs;
723+
float * diffs_ptr = diffs.data();
724724

725725
AutoBuffer<Point3f> transformedPoints0(correspsCount);
726-
Point3f * tps0_ptr = transformedPoints0;
726+
Point3f * tps0_ptr = transformedPoints0.data();
727727

728728
const Vec4i* corresps_ptr = corresps.ptr<Vec4i>();
729729

modules/tracking/src/feature.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -925,7 +925,7 @@ void CvHOGEvaluator::integralHistogram( const Mat &img, std::vector<Mat> &histog
925925
Mat qangle( gradSize, CV_8U );
926926

927927
AutoBuffer<int> mapbuf( gradSize.width + gradSize.height + 4 );
928-
int* xmap = (int*) mapbuf + 1;
928+
int* xmap = mapbuf.data() + 1;
929929
int* ymap = xmap + gradSize.width + 2;
930930

931931
const int borderType = (int) BORDER_REPLICATE;
@@ -937,7 +937,7 @@ void CvHOGEvaluator::integralHistogram( const Mat &img, std::vector<Mat> &histog
937937

938938
int width = gradSize.width;
939939
AutoBuffer<float> _dbuf( width * 4 );
940-
float* dbuf = _dbuf;
940+
float* dbuf = _dbuf.data();
941941
Mat Dx( 1, width, CV_32F, dbuf );
942942
Mat Dy( 1, width, CV_32F, dbuf + width );
943943
Mat Mag( 1, width, CV_32F, dbuf + width * 2 );

modules/tracking/src/trackerKCF.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -495,7 +495,7 @@ namespace cv{
495495
int rows = dst.rows, cols = dst.cols;
496496

497497
AutoBuffer<float> _wc(cols);
498-
float * const wc = (float *)_wc;
498+
float * const wc = _wc.data();
499499

500500
const float coeff0 = 2.0f * (float)CV_PI / (cols - 1);
501501
const float coeff1 = 2.0f * (float)CV_PI / (rows - 1);

modules/xfeatures2d/src/fast.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,7 @@ namespace {
339339

340340
AutoBuffer<uchar> _buf((img.cols+16)*3*(sizeof(int) + sizeof(uchar)) + 128);
341341
uchar* buf[3];
342-
buf[0] = _buf; buf[1] = buf[0] + img.cols; buf[2] = buf[1] + img.cols;
342+
buf[0] = _buf.data(); buf[1] = buf[0] + img.cols; buf[2] = buf[1] + img.cols;
343343
int* cpbuf[3];
344344
cpbuf[0] = (int*)alignPtr(buf[2] + img.cols, sizeof(int)) + 1;
345345
cpbuf[1] = cpbuf[0] + img.cols + 1;

modules/xfeatures2d/src/sift.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,7 @@ static float calcOrientationHist( const Mat& img, Point pt, int radius,
341341

342342
float expf_scale = -1.f/(2.f * sigma * sigma);
343343
AutoBuffer<float> buf(len*4 + n+4);
344-
float *X = buf, *Y = X + len, *Mag = X, *Ori = Y + len, *W = Ori + len;
344+
float *X = buf.data(), *Y = X + len, *Mag = X, *Ori = Y + len, *W = Ori + len;
345345
float* temphist = W + len + 2;
346346

347347
for( i = 0; i < n; i++ )
@@ -754,7 +754,7 @@ static void calcSIFTDescriptor( const Mat& img, Point2f ptf, float ori, float sc
754754
int rows = img.rows, cols = img.cols;
755755

756756
AutoBuffer<float> buf(len*6 + histlen);
757-
float *X = buf, *Y = X + len, *Mag = Y, *Ori = Mag + len, *W = Ori + len;
757+
float *X = buf.data(), *Y = X + len, *Mag = Y, *Ori = Mag + len, *W = Ori + len;
758758
float *RBin = W + len, *CBin = RBin + len, *hist = CBin + len;
759759

760760
for( i = 0; i < d+2; i++ )

modules/xfeatures2d/src/surf.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -676,7 +676,7 @@ struct SURFInvoker : ParallelLoopBody
676676
/* Extract a window of pixels around the keypoint of size 20s */
677677
int win_size = (int)((PATCH_SZ+1)*s);
678678
CV_Assert( imaxSize >= win_size );
679-
Mat win(win_size, win_size, CV_8U, winbuf);
679+
Mat win(win_size, win_size, CV_8U, winbuf.data());
680680

681681
if( !upright )
682682
{

0 commit comments

Comments
 (0)