Commit fc69aa57 authored by Alexander Alekhin's avatar Alexander Alekhin

opencv: use cv::AutoBuffer<>::data()

parent 25a01dc4
...@@ -94,7 +94,7 @@ void ptsort_(struct pt *pts, int sz) ...@@ -94,7 +94,7 @@ void ptsort_(struct pt *pts, int sz)
// Use stack storage if it's not too big. // Use stack storage if it's not too big.
cv::AutoBuffer<struct pt, 1024> _tmp_stack(sz); cv::AutoBuffer<struct pt, 1024> _tmp_stack(sz);
memcpy(_tmp_stack, pts, sizeof(struct pt) * sz); memcpy(_tmp_stack.data(), pts, sizeof(struct pt) * sz);
int asz = sz/2; int asz = sz/2;
int bsz = sz - asz; int bsz = sz - asz;
...@@ -470,11 +470,11 @@ int quad_segment_agg(int sz, struct line_fit_pt *lfps, int indices[4]){ ...@@ -470,11 +470,11 @@ int quad_segment_agg(int sz, struct line_fit_pt *lfps, int indices[4]){
int rvalloc_pos = 0; int rvalloc_pos = 0;
int rvalloc_size = 3*sz; int rvalloc_size = 3*sz;
cv::AutoBuffer<struct remove_vertex, 0> rvalloc_(std::max(1, rvalloc_size)); cv::AutoBuffer<struct remove_vertex, 0> rvalloc_(std::max(1, rvalloc_size));
memset(rvalloc_, 0, sizeof(rvalloc_[0]) * rvalloc_.size()); // TODO Add AutoBuffer zero fill memset(rvalloc_.data(), 0, sizeof(rvalloc_[0]) * rvalloc_.size()); // TODO Add AutoBuffer zero fill
struct remove_vertex *rvalloc = rvalloc_; struct remove_vertex *rvalloc = rvalloc_.data();
cv::AutoBuffer<struct segment, 0> segs_(std::max(1, sz)); // TODO Add AutoBuffer zero fill cv::AutoBuffer<struct segment, 0> segs_(std::max(1, sz)); // TODO Add AutoBuffer zero fill
memset(segs_, 0, sizeof(segs_[0]) * segs_.size()); memset(segs_.data(), 0, sizeof(segs_[0]) * segs_.size());
struct segment *segs = segs_; struct segment *segs = segs_.data();
// populate with initial entries // populate with initial entries
for (int i = 0; i < sz; i++) { for (int i = 0; i < sz; i++) {
...@@ -753,8 +753,8 @@ int fit_quad(const Ptr<DetectorParameters> &_params, const Mat im, zarray_t *clu ...@@ -753,8 +753,8 @@ int fit_quad(const Ptr<DetectorParameters> &_params, const Mat im, zarray_t *clu
// efficiently computed for any contiguous range of indices. // efficiently computed for any contiguous range of indices.
cv::AutoBuffer<struct line_fit_pt, 64> lfps_(sz); cv::AutoBuffer<struct line_fit_pt, 64> lfps_(sz);
memset(lfps_, 0, sizeof(lfps_[0]) * lfps_.size()); // TODO Add AutoBuffer zero fill memset(lfps_.data(), 0, sizeof(lfps_[0]) * lfps_.size()); // TODO Add AutoBuffer zero fill
struct line_fit_pt *lfps = lfps_; struct line_fit_pt *lfps = lfps_.data();
for (int i = 0; i < sz; i++) { for (int i = 0; i < sz; i++) {
struct pt *p; struct pt *p;
......
...@@ -49,9 +49,9 @@ static inline void _swap_default(zmaxheap_t *heap, int a, int b) ...@@ -49,9 +49,9 @@ static inline void _swap_default(zmaxheap_t *heap, int a, int b)
heap->values[b] = t; heap->values[b] = t;
cv::AutoBuffer<char> tmp(heap->el_sz); cv::AutoBuffer<char> tmp(heap->el_sz);
memcpy(tmp, &heap->data[a*heap->el_sz], heap->el_sz); memcpy(tmp.data(), &heap->data[a*heap->el_sz], heap->el_sz);
memcpy(&heap->data[a*heap->el_sz], &heap->data[b*heap->el_sz], heap->el_sz); memcpy(&heap->data[a*heap->el_sz], &heap->data[b*heap->el_sz], heap->el_sz);
memcpy(&heap->data[b*heap->el_sz], tmp, heap->el_sz); memcpy(&heap->data[b*heap->el_sz], tmp.data(), heap->el_sz);
} }
static inline void _swap_pointer(zmaxheap_t *heap, int a, int b) static inline void _swap_pointer(zmaxheap_t *heap, int a, int b)
......
...@@ -380,12 +380,7 @@ void DISOpticalFlowImpl::precomputeStructureTensor(Mat &dst_I0xx, Mat &dst_I0yy, ...@@ -380,12 +380,7 @@ void DISOpticalFlowImpl::precomputeStructureTensor(Mat &dst_I0xx, Mat &dst_I0yy,
} }
} }
AutoBuffer<float> sum_xx_buf(ws), sum_yy_buf(ws), sum_xy_buf(ws), sum_x_buf(ws), sum_y_buf(ws); AutoBuffer<float> sum_xx(ws), sum_yy(ws), sum_xy(ws), sum_x(ws), sum_y(ws);
float *sum_xx = (float *)sum_xx_buf;
float *sum_yy = (float *)sum_yy_buf;
float *sum_xy = (float *)sum_xy_buf;
float *sum_x = (float *)sum_x_buf;
float *sum_y = (float *)sum_y_buf;
for (int j = 0; j < ws; j++) for (int j = 0; j < ws; j++)
{ {
sum_xx[j] = 0.0f; sum_xx[j] = 0.0f;
......
...@@ -290,11 +290,11 @@ static void quantizedOrientations(const Mat& src, Mat& magnitude, ...@@ -290,11 +290,11 @@ static void quantizedOrientations(const Mat& src, Mat& magnitude,
float * ptr0y = (float *)sobel_dy.data; float * ptr0y = (float *)sobel_dy.data;
float * ptrmg = (float *)magnitude.data; float * ptrmg = (float *)magnitude.data;
const int length1 = static_cast<const int>(sobel_3dx.step1()); const int length1 = static_cast<int>(sobel_3dx.step1());
const int length2 = static_cast<const int>(sobel_3dy.step1()); const int length2 = static_cast<int>(sobel_3dy.step1());
const int length3 = static_cast<const int>(sobel_dx.step1()); const int length3 = static_cast<int>(sobel_dx.step1());
const int length4 = static_cast<const int>(sobel_dy.step1()); const int length4 = static_cast<int>(sobel_dy.step1());
const int length5 = static_cast<const int>(magnitude.step1()); const int length5 = static_cast<int>(magnitude.step1());
const int length0 = sobel_3dy.cols * 3; const int length0 = sobel_3dy.cols * 3;
for (int r = 0; r < sobel_3dy.rows; ++r) for (int r = 0; r < sobel_3dy.rows; ++r)
......
...@@ -469,7 +469,7 @@ void computeCorresps(const Mat& K, const Mat& K_inv, const Mat& Rt, ...@@ -469,7 +469,7 @@ void computeCorresps(const Mat& K, const Mat& K_inv, const Mat& Rt,
const double * Kt_ptr = Kt.ptr<const double>(); const double * Kt_ptr = Kt.ptr<const double>();
AutoBuffer<float> buf(3 * (depth1.cols + depth1.rows)); AutoBuffer<float> buf(3 * (depth1.cols + depth1.rows));
float *KRK_inv0_u1 = buf; float *KRK_inv0_u1 = buf.data();
float *KRK_inv1_v1_plus_KRK_inv2 = KRK_inv0_u1 + depth1.cols; float *KRK_inv1_v1_plus_KRK_inv2 = KRK_inv0_u1 + depth1.cols;
float *KRK_inv3_u1 = KRK_inv1_v1_plus_KRK_inv2 + depth1.rows; float *KRK_inv3_u1 = KRK_inv1_v1_plus_KRK_inv2 + depth1.rows;
float *KRK_inv4_v1_plus_KRK_inv5 = KRK_inv3_u1 + depth1.cols; 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, ...@@ -647,7 +647,7 @@ void calcRgbdLsmMatrices(const Mat& image0, const Mat& cloud0, const Mat& Rt,
const double * Rt_ptr = Rt.ptr<const double>(); const double * Rt_ptr = Rt.ptr<const double>();
AutoBuffer<float> diffs(correspsCount); AutoBuffer<float> diffs(correspsCount);
float* diffs_ptr = diffs; float* diffs_ptr = diffs.data();
const Vec4i* corresps_ptr = corresps.ptr<Vec4i>(); const Vec4i* corresps_ptr = corresps.ptr<Vec4i>();
...@@ -720,10 +720,10 @@ void calcICPLsmMatrices(const Mat& cloud0, const Mat& Rt, ...@@ -720,10 +720,10 @@ void calcICPLsmMatrices(const Mat& cloud0, const Mat& Rt,
const double * Rt_ptr = Rt.ptr<const double>(); const double * Rt_ptr = Rt.ptr<const double>();
AutoBuffer<float> diffs(correspsCount); AutoBuffer<float> diffs(correspsCount);
float * diffs_ptr = diffs; float * diffs_ptr = diffs.data();
AutoBuffer<Point3f> transformedPoints0(correspsCount); AutoBuffer<Point3f> transformedPoints0(correspsCount);
Point3f * tps0_ptr = transformedPoints0; Point3f * tps0_ptr = transformedPoints0.data();
const Vec4i* corresps_ptr = corresps.ptr<Vec4i>(); const Vec4i* corresps_ptr = corresps.ptr<Vec4i>();
......
...@@ -925,7 +925,7 @@ void CvHOGEvaluator::integralHistogram( const Mat &img, std::vector<Mat> &histog ...@@ -925,7 +925,7 @@ void CvHOGEvaluator::integralHistogram( const Mat &img, std::vector<Mat> &histog
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;
...@@ -937,7 +937,7 @@ void CvHOGEvaluator::integralHistogram( const Mat &img, std::vector<Mat> &histog ...@@ -937,7 +937,7 @@ void CvHOGEvaluator::integralHistogram( const Mat &img, std::vector<Mat> &histog
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 );
......
...@@ -495,7 +495,7 @@ namespace cv{ ...@@ -495,7 +495,7 @@ namespace cv{
int rows = dst.rows, cols = dst.cols; int rows = dst.rows, cols = dst.cols;
AutoBuffer<float> _wc(cols); AutoBuffer<float> _wc(cols);
float * const wc = (float *)_wc; float * const wc = _wc.data();
const float coeff0 = 2.0f * (float)CV_PI / (cols - 1); const float coeff0 = 2.0f * (float)CV_PI / (cols - 1);
const float coeff1 = 2.0f * (float)CV_PI / (rows - 1); const float coeff1 = 2.0f * (float)CV_PI / (rows - 1);
......
...@@ -339,7 +339,7 @@ namespace { ...@@ -339,7 +339,7 @@ namespace {
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;
......
...@@ -341,7 +341,7 @@ static float calcOrientationHist( const Mat& img, Point pt, int radius, ...@@ -341,7 +341,7 @@ static float calcOrientationHist( const Mat& img, Point pt, int radius,
float expf_scale = -1.f/(2.f * sigma * sigma); float expf_scale = -1.f/(2.f * sigma * sigma);
AutoBuffer<float> buf(len*4 + n+4); AutoBuffer<float> buf(len*4 + n+4);
float *X = buf, *Y = X + len, *Mag = X, *Ori = Y + len, *W = Ori + len; float *X = buf.data(), *Y = X + len, *Mag = X, *Ori = Y + len, *W = Ori + len;
float* temphist = W + len + 2; float* temphist = W + len + 2;
for( i = 0; i < n; i++ ) for( i = 0; i < n; i++ )
...@@ -754,7 +754,7 @@ static void calcSIFTDescriptor( const Mat& img, Point2f ptf, float ori, float sc ...@@ -754,7 +754,7 @@ static void calcSIFTDescriptor( const Mat& img, Point2f ptf, float ori, float sc
int rows = img.rows, cols = img.cols; int rows = img.rows, cols = img.cols;
AutoBuffer<float> buf(len*6 + histlen); AutoBuffer<float> buf(len*6 + histlen);
float *X = buf, *Y = X + len, *Mag = Y, *Ori = Mag + len, *W = Ori + len; float *X = buf.data(), *Y = X + len, *Mag = Y, *Ori = Mag + len, *W = Ori + len;
float *RBin = W + len, *CBin = RBin + len, *hist = CBin + len; float *RBin = W + len, *CBin = RBin + len, *hist = CBin + len;
for( i = 0; i < d+2; i++ ) for( i = 0; i < d+2; i++ )
......
...@@ -676,7 +676,7 @@ struct SURFInvoker : ParallelLoopBody ...@@ -676,7 +676,7 @@ struct SURFInvoker : ParallelLoopBody
/* Extract a window of pixels around the keypoint of size 20s */ /* Extract a window of pixels around the keypoint of size 20s */
int win_size = (int)((PATCH_SZ+1)*s); int win_size = (int)((PATCH_SZ+1)*s);
CV_Assert( imaxSize >= win_size ); CV_Assert( imaxSize >= win_size );
Mat win(win_size, win_size, CV_8U, winbuf); Mat win(win_size, win_size, CV_8U, winbuf.data());
if( !upright ) if( !upright )
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment