mirror of
https://github.com/opencv/opencv.git
synced 2026-07-21 19:33:03 +04:00
Merge pull request #28907 from chacha21:more_autobuffer
More use of AutoBuffer #28907 When possible, AutoBuffer should be faster than std::vector<>, and should not be worse if it requires a heap allocation rather than a stack allocation. ### Pull Request Readiness Checklist See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request - [x] I agree to contribute to the project under Apache 2 License. - [x] To the best of my knowledge, the proposed patch is not based on a code under GPL or another license that is incompatible with OpenCV - [X] The PR is proposed to the proper branch - [ ] There is a reference to the original bug report and related work - [X] There is accuracy test, performance test and test data in opencv_extra repository, if applicable Patch to opencv_extra has the same branch name. - [ ] The feature is well documented and sample code can be built with the project CMake
This commit is contained in:
@@ -517,7 +517,7 @@ void filterHomographyDecompByVisibleRefpoints(InputArrayOfArrays _rotations,
|
||||
CV_Assert(pointsMask.empty() || pointsMask.checkVector(1, CV_8U) == npoints);
|
||||
const uchar* pointsMaskPtr = pointsMask.data;
|
||||
|
||||
std::vector<uchar> solutionMask(nsolutions, (uchar)1);
|
||||
AutoBuffer<uchar> solutionMask(nsolutions, (uchar)1);
|
||||
std::vector<Mat> normals(nsolutions);
|
||||
std::vector<Mat> rotnorm(nsolutions);
|
||||
Mat R;
|
||||
@@ -559,7 +559,8 @@ void filterHomographyDecompByVisibleRefpoints(InputArrayOfArrays _rotations,
|
||||
if( solutionMask[i] )
|
||||
possibleSolutions.push_back(i);
|
||||
|
||||
Mat(possibleSolutions).copyTo(_possibleSolutions);
|
||||
constexpr int cvType = traits::Type<decltype(possibleSolutions)::value_type>::value;
|
||||
Mat(static_cast<int>(possibleSolutions.size()), 1, cvType, possibleSolutions.data()).copyTo(_possibleSolutions);
|
||||
}
|
||||
|
||||
} //namespace cv
|
||||
|
||||
@@ -558,7 +558,7 @@ void transposeND(InputArray src_, const std::vector<int>& order, OutputArray dst
|
||||
CV_CheckEQ(static_cast<size_t>(order_[i]), i, "New order should be a valid permutation of the old one");
|
||||
}
|
||||
|
||||
std::vector<int> newShape(order.size());
|
||||
AutoBuffer<int> newShape(order.size());
|
||||
for (size_t i = 0; i < order.size(); ++i)
|
||||
{
|
||||
newShape[i] = inp.size[order[i]];
|
||||
@@ -582,7 +582,7 @@ void transposeND(InputArray src_, const std::vector<int>& order, OutputArray dst
|
||||
size_t continuous_size = continuous_idx == 0 ? out.total() : out.step1(continuous_idx - 1);
|
||||
size_t outer_size = out.total() / continuous_size;
|
||||
|
||||
std::vector<size_t> steps(order.size());
|
||||
AutoBuffer<size_t> steps(order.size());
|
||||
for (int i = 0; i < static_cast<int>(steps.size()); ++i)
|
||||
{
|
||||
steps[i] = inp.step1(order[i]);
|
||||
@@ -1229,7 +1229,7 @@ void broadcast(InputArray _src, InputArray _shape, OutputArray _dst) {
|
||||
// impl
|
||||
_dst.create(dims_shape, shape.ptr<int>(), src.type());
|
||||
Mat dst = _dst.getMat();
|
||||
std::vector<int> is_same_shape(dims_shape, 0);
|
||||
AutoBuffer<int> is_same_shape(dims_shape, 0);
|
||||
for (int i = 0; i < static_cast<int>(shape_src.size()); ++i) {
|
||||
if (shape_src[i] == ptr_shape[i]) {
|
||||
is_same_shape[i] = 1;
|
||||
@@ -1328,7 +1328,7 @@ void broadcast(InputArray _src, InputArray _shape, OutputArray _dst) {
|
||||
std::memcpy(p_dst + dst_offset, p_src + src_offset, dst.elemSize());
|
||||
}
|
||||
// broadcast copy (dst inplace)
|
||||
std::vector<int> cumulative_shape(dims_shape, 1);
|
||||
AutoBuffer<int> cumulative_shape(dims_shape, 1);
|
||||
int total = static_cast<int>(dst.total());
|
||||
for (int i = dims_shape - 1; i >= 0; --i) {
|
||||
cumulative_shape[i] = static_cast<int>(total / ptr_shape[i]);
|
||||
|
||||
@@ -1330,7 +1330,7 @@ static void reduceMinMax(cv::InputArray src, cv::OutputArray dst, ReduceMode mod
|
||||
axis = (axis + srcMat.dims) % srcMat.dims;
|
||||
CV_Assert(srcMat.channels() == 1 && axis >= 0 && axis < srcMat.dims);
|
||||
|
||||
std::vector<int> sizes(srcMat.dims);
|
||||
cv::AutoBuffer<int> sizes(srcMat.dims);
|
||||
std::copy(srcMat.size.p, srcMat.size.p + srcMat.dims, sizes.begin());
|
||||
sizes[axis] = 1;
|
||||
|
||||
|
||||
@@ -65,15 +65,15 @@ public:
|
||||
/*
|
||||
* a convertor must provide :
|
||||
* - `operator >> (uchar * & dst)` for writing current binary data to `dst` and moving to next data.
|
||||
* - `operator bool` for checking if current loaction is valid and not the end.
|
||||
* - `operator bool` for checking if current location is valid and not the end.
|
||||
*/
|
||||
template<typename _to_binary_convertor_t> inline
|
||||
Base64ContextEmitter & write(_to_binary_convertor_t & convertor)
|
||||
{
|
||||
static const size_t BUFFER_MAX_LEN = 1024U;
|
||||
constexpr size_t BUFFER_MAX_LEN = 1024U;
|
||||
|
||||
std::vector<uchar> buffer(BUFFER_MAX_LEN);
|
||||
uchar * beg = buffer.data();
|
||||
uchar buffer[BUFFER_MAX_LEN];
|
||||
uchar * beg = buffer;
|
||||
uchar * end = beg;
|
||||
|
||||
while (convertor) {
|
||||
|
||||
@@ -75,7 +75,7 @@ void write( FileStorage& fs, const String& name, const SparseMat& m )
|
||||
fs << "data" << "[:";
|
||||
|
||||
size_t i = 0, n = m.nzcount();
|
||||
std::vector<const SparseMat::Node*> elems(n);
|
||||
AutoBuffer<const SparseMat::Node*> elems(n);
|
||||
SparseMatConstIterator it = m.begin(), it_end = m.end();
|
||||
|
||||
for( ; it != it_end; ++it )
|
||||
|
||||
@@ -332,11 +332,13 @@ void SimpleBlobDetectorImpl::findBlobs(InputArray _image, InputArray _binaryImag
|
||||
|
||||
//compute blob radius
|
||||
{
|
||||
std::vector<double> dists;
|
||||
for (size_t pointIdx = 0; pointIdx < contours[contourIdx].size(); pointIdx++)
|
||||
const std::vector<cv::Point>& contour = contours[contourIdx];
|
||||
const size_t contourSize = contour.size();
|
||||
AutoBuffer<double> dists(contourSize);
|
||||
for (size_t pointIdx = 0; pointIdx < contourSize; pointIdx++)
|
||||
{
|
||||
Point2d pt = contours[contourIdx][pointIdx];
|
||||
dists.push_back(norm(center.location - pt));
|
||||
const Point2d& pt = contour[pointIdx];
|
||||
dists[pointIdx] = norm(center.location - pt);
|
||||
}
|
||||
std::sort(dists.begin(), dists.end());
|
||||
center.radius = (dists[(dists.size() - 1) / 2] + dists[dists.size() / 2]) / 2.;
|
||||
|
||||
@@ -221,8 +221,8 @@ struct KeyPoint_LessThan
|
||||
void KeyPointsFilter::removeDuplicated( std::vector<KeyPoint>& keypoints )
|
||||
{
|
||||
int i, j, n = (int)keypoints.size();
|
||||
std::vector<int> kpidx(n);
|
||||
std::vector<uchar> mask(n, (uchar)1);
|
||||
AutoBuffer<int> kpidx(n);
|
||||
AutoBuffer<uchar> mask(n, (uchar)1);
|
||||
|
||||
for( i = 0; i < n; i++ )
|
||||
kpidx[i] = i;
|
||||
|
||||
@@ -839,7 +839,7 @@ static void computeKeyPoints(const Mat& imagePyramid,
|
||||
#endif
|
||||
|
||||
int i, nkeypoints, level, nlevels = (int)layerInfo.size();
|
||||
std::vector<int> nfeaturesPerLevel(nlevels);
|
||||
AutoBuffer<int> nfeaturesPerLevel(nlevels);
|
||||
|
||||
// fill the extractors and descriptors for the corresponding scales
|
||||
float factor = (float)(1.0 / scaleFactor);
|
||||
@@ -877,7 +877,7 @@ static void computeKeyPoints(const Mat& imagePyramid,
|
||||
|
||||
allKeypoints.clear();
|
||||
std::vector<KeyPoint> keypoints;
|
||||
std::vector<int> counters(nlevels);
|
||||
AutoBuffer<int> counters(nlevels);
|
||||
keypoints.reserve(nfeaturesPerLevel[0]*2);
|
||||
|
||||
for( level = 0; level < nlevels; level++ )
|
||||
|
||||
@@ -225,7 +225,7 @@ void SIFT_Impl::buildGaussianPyramid( const Mat& base, std::vector<Mat>& pyr, in
|
||||
{
|
||||
CV_TRACE_FUNCTION();
|
||||
|
||||
std::vector<double> sig(nOctaveLayers + 3);
|
||||
AutoBuffer<double> sig(nOctaveLayers + 3);
|
||||
pyr.resize(nOctaves*(nOctaveLayers + 3));
|
||||
|
||||
// precompute Gaussian sigmas using the following formula:
|
||||
|
||||
@@ -47,8 +47,8 @@ void find_nearest(const Matrix<typename Distance::ElementType>& dataset, typenam
|
||||
typedef typename Distance::ResultType DistanceType;
|
||||
int n = nn + skip;
|
||||
|
||||
std::vector<int> match(n);
|
||||
std::vector<DistanceType> dists(n);
|
||||
cv::AutoBuffer<int> match(n);
|
||||
cv::AutoBuffer<DistanceType> dists(n);
|
||||
|
||||
dists[0] = distance(dataset[0], query, dataset.cols);
|
||||
match[0] = 0;
|
||||
|
||||
@@ -686,8 +686,8 @@ private:
|
||||
return;
|
||||
}
|
||||
|
||||
std::vector<int> centers(branching);
|
||||
std::vector<int> labels(indices_length);
|
||||
cv::AutoBuffer<int> centers(branching);
|
||||
cv::AutoBuffer<int> labels(indices_length);
|
||||
|
||||
int centers_length;
|
||||
(this->*chooseCenters)(branching, dsindices, indices_length, ¢ers[0], centers_length);
|
||||
|
||||
@@ -99,8 +99,8 @@ float search_with_ground_truth(NNIndex<Distance>& index, const Matrix<typename D
|
||||
KNNResultSet<DistanceType> resultSet(nn+skipMatches);
|
||||
SearchParams searchParams(checks);
|
||||
|
||||
std::vector<int> indices(nn+skipMatches);
|
||||
std::vector<DistanceType> dists(nn+skipMatches);
|
||||
cv::AutoBuffer<int> indices(nn+skipMatches);
|
||||
cv::AutoBuffer<DistanceType> dists(nn+skipMatches);
|
||||
int* neighbors = &indices[skipMatches];
|
||||
|
||||
int correct = 0;
|
||||
|
||||
@@ -490,7 +490,7 @@ inline LshStats LshTable<unsigned char>::getStats() const
|
||||
!= end; )
|
||||
if (*iterator < bin_end) {
|
||||
if (is_new_bin) {
|
||||
stats.size_histogram_.push_back(std::vector<unsigned int>(3, 0));
|
||||
stats.size_histogram_.emplace_back(3, 0);
|
||||
stats.size_histogram_.back()[0] = bin_start;
|
||||
stats.size_histogram_.back()[1] = bin_end - 1;
|
||||
is_new_bin = false;
|
||||
|
||||
@@ -98,8 +98,8 @@ static bool ocl_bilateralFilter_8u(InputArray _src, OutputArray _dst, int d,
|
||||
return false;
|
||||
|
||||
copyMakeBorder(src, temp, radius, radius, radius, radius, borderType);
|
||||
std::vector<float> _space_weight(d * d);
|
||||
std::vector<int> _space_ofs(d * d);
|
||||
AutoBuffer<float> _space_weight(d * d);
|
||||
AutoBuffer<int> _space_ofs(d * d);
|
||||
float * const space_weight = &_space_weight[0];
|
||||
int * const space_ofs = &_space_ofs[0];
|
||||
|
||||
@@ -188,9 +188,9 @@ bilateralFilter_8u( const Mat& src, Mat& dst, int d,
|
||||
Mat temp;
|
||||
copyMakeBorder( src, temp, radius, radius, radius, radius, borderType );
|
||||
|
||||
std::vector<float> _color_weight(cn*256);
|
||||
std::vector<float> _space_weight(d*d);
|
||||
std::vector<int> _space_ofs(d*d);
|
||||
AutoBuffer<float> _color_weight(cn*256);
|
||||
AutoBuffer<float> _space_weight(d*d);
|
||||
AutoBuffer<int> _space_ofs(d*d);
|
||||
float* color_weight = &_color_weight[0];
|
||||
float* space_weight = &_space_weight[0];
|
||||
int* space_ofs = &_space_ofs[0];
|
||||
@@ -283,15 +283,15 @@ bilateralFilter_32f( const Mat& src, Mat& dst, int d,
|
||||
copyMakeBorder( src, temp, radius, radius, radius, radius, borderType );
|
||||
|
||||
// allocate lookup tables
|
||||
std::vector<float> _space_weight(d*d);
|
||||
std::vector<int> _space_ofs(d*d);
|
||||
AutoBuffer<float> _space_weight(d*d);
|
||||
AutoBuffer<int> _space_ofs(d*d);
|
||||
float* space_weight = &_space_weight[0];
|
||||
int* space_ofs = &_space_ofs[0];
|
||||
|
||||
// assign a length which is slightly more than needed
|
||||
len = (float)(maxValSrc - minValSrc) * cn;
|
||||
kExpNumBins = kExpNumBinsPerChannel * cn;
|
||||
std::vector<float> _expLUT(kExpNumBins+2);
|
||||
AutoBuffer<float> _expLUT(kExpNumBins+2);
|
||||
float* expLUT = &_expLUT[0];
|
||||
|
||||
scale_index = kExpNumBins/len;
|
||||
|
||||
@@ -1153,10 +1153,10 @@ namespace cv{
|
||||
//Array used to store info and labeled pixel by each thread.
|
||||
//Different threads affect different memory location of chunksSizeAndLabels
|
||||
const int chunksSizeAndLabelsSize = roundUp(h, 2);
|
||||
std::vector<int> chunksSizeAndLabels(chunksSizeAndLabelsSize);
|
||||
AutoBuffer<int> chunksSizeAndLabels(chunksSizeAndLabelsSize);
|
||||
|
||||
//Tree of labels
|
||||
std::vector<LabelT> P(Plength, 0);
|
||||
AutoBuffer<LabelT> P(Plength, 0);
|
||||
//First label is for background
|
||||
//P[0] = 0;
|
||||
|
||||
@@ -1176,7 +1176,7 @@ namespace cv{
|
||||
}
|
||||
|
||||
//Array for statistics data
|
||||
std::vector<StatsOp> sopArray(h);
|
||||
AutoBuffer<StatsOp> sopArray(h);
|
||||
sop.init(nLabels);
|
||||
|
||||
//Second scan
|
||||
@@ -1218,7 +1218,7 @@ namespace cv{
|
||||
// ............
|
||||
const size_t Plength = size_t(((h + 1) / 2) * size_t((w + 1) / 2)) + 1;
|
||||
|
||||
std::vector<LabelT> P_(Plength, 0);
|
||||
AutoBuffer<LabelT> P_(Plength, 0);
|
||||
LabelT *P = P_.data();
|
||||
//P[0] = 0;
|
||||
LabelT lunique = 1;
|
||||
@@ -1782,10 +1782,10 @@ namespace cv{
|
||||
|
||||
//Array used to store info and labeled pixel by each thread.
|
||||
//Different threads affect different memory location of chunksSizeAndLabels
|
||||
std::vector<int> chunksSizeAndLabels(roundUp(h, 2));
|
||||
AutoBuffer<int> chunksSizeAndLabels(roundUp(h, 2));
|
||||
|
||||
//Tree of labels
|
||||
std::vector<LabelT> P_(Plength, 0);
|
||||
AutoBuffer<LabelT> P_(Plength, 0);
|
||||
LabelT* P = P_.data();
|
||||
//First label is for background
|
||||
//P[0] = 0;
|
||||
@@ -1806,7 +1806,7 @@ namespace cv{
|
||||
}
|
||||
|
||||
//Array for statistics dataof threads
|
||||
std::vector<StatsOp> sopArray(h);
|
||||
AutoBuffer<StatsOp> sopArray(h);
|
||||
|
||||
sop.init(nLabels);
|
||||
//Second scan
|
||||
@@ -1842,7 +1842,7 @@ namespace cv{
|
||||
// ............
|
||||
const size_t Plength = size_t((size_t(h) * size_t(w) + 1) / 2) + 1;
|
||||
|
||||
std::vector<LabelT> P_(Plength, 0);
|
||||
AutoBuffer<LabelT> P_(Plength, 0);
|
||||
LabelT* P = P_.data();
|
||||
P[0] = 0;
|
||||
LabelT lunique = 1;
|
||||
@@ -2315,10 +2315,10 @@ namespace cv{
|
||||
|
||||
//Array used to store info and labeled pixel by each thread.
|
||||
//Different threads affect different memory location of chunksSizeAndLabels
|
||||
std::vector<int> chunksSizeAndLabels(roundUp(h, 2));
|
||||
AutoBuffer<int> chunksSizeAndLabels(roundUp(h, 2));
|
||||
|
||||
//Tree of labels
|
||||
std::vector<LabelT> P_(Plength, 0);
|
||||
AutoBuffer<LabelT> P_(Plength, 0);
|
||||
LabelT *P = P_.data();
|
||||
//First label is for background
|
||||
//P[0] = 0;
|
||||
@@ -2352,7 +2352,7 @@ namespace cv{
|
||||
}
|
||||
|
||||
//Array for statistics dataof threads
|
||||
std::vector<StatsOp> sopArray(h);
|
||||
AutoBuffer<StatsOp> sopArray(h);
|
||||
|
||||
sop.init(nLabels);
|
||||
//Second scan
|
||||
@@ -2387,7 +2387,7 @@ namespace cv{
|
||||
//Obviously, 4-way connectivity upper bound is also good for 8-way connectivity labeling
|
||||
const size_t Plength = (size_t(h) * size_t(w) + 1) / 2 + 1;
|
||||
//array P for equivalences resolution
|
||||
std::vector<LabelT> P_(Plength, 0);
|
||||
AutoBuffer<LabelT> P_(Plength, 0);
|
||||
LabelT *P = P_.data();
|
||||
//first label is for background pixels
|
||||
//P[0] = 0;
|
||||
@@ -4265,10 +4265,10 @@ namespace cv{
|
||||
//Array used to store info and labeled pixel by each thread.
|
||||
//Different threads affect different memory location of chunksSizeAndLabels
|
||||
const int chunksSizeAndLabelsSize = roundUp(h, 2);
|
||||
std::vector<int> chunksSizeAndLabels(chunksSizeAndLabelsSize);
|
||||
AutoBuffer<int> chunksSizeAndLabels(chunksSizeAndLabelsSize);
|
||||
|
||||
//Tree of labels
|
||||
std::vector<LabelT> P(Plength, 0);
|
||||
AutoBuffer<LabelT> P(Plength, 0);
|
||||
//First label is for background
|
||||
//P[0] = 0;
|
||||
|
||||
@@ -4288,7 +4288,7 @@ namespace cv{
|
||||
}
|
||||
|
||||
//Array for statistics data
|
||||
std::vector<StatsOp> sopArray(h);
|
||||
AutoBuffer<StatsOp> sopArray(h);
|
||||
sop.init(nLabels);
|
||||
|
||||
//Second scan
|
||||
@@ -4323,7 +4323,7 @@ namespace cv{
|
||||
//............
|
||||
const size_t Plength = size_t(((h + 1) / 2) * size_t((w + 1) / 2)) + 1;
|
||||
|
||||
std::vector<LabelT> P_(Plength, 0);
|
||||
AutoBuffer<LabelT> P_(Plength, 0);
|
||||
LabelT *P = P_.data();
|
||||
//P[0] = 0;
|
||||
LabelT lunique = 1;
|
||||
|
||||
@@ -101,7 +101,7 @@ static void getSobelKernels( OutputArray _kx, OutputArray _ky,
|
||||
|
||||
if( _ksize % 2 == 0 || _ksize > 31 )
|
||||
CV_Error( cv::Error::StsOutOfRange, "The kernel size must be odd and not larger than 31" );
|
||||
std::vector<int> kerI(std::max(ksizeX, ksizeY) + 1);
|
||||
AutoBuffer<int> kerI(std::max(ksizeX, ksizeY) + 1);
|
||||
|
||||
CV_Assert( dx >= 0 && dy >= 0 && dx+dy > 0 );
|
||||
|
||||
|
||||
@@ -359,13 +359,13 @@ HoughLinesSDiv( InputArray image, OutputArray lines, int type,
|
||||
lst.push_back(hough_index(threshold, -1.f, 0.f));
|
||||
|
||||
// Precalculate sin table
|
||||
std::vector<float> _sinTable( 5 * tn * stn );
|
||||
AutoBuffer<float> _sinTable( 5 * tn * stn );
|
||||
float* sinTable = &_sinTable[0];
|
||||
|
||||
for( index = 0; index < 5 * tn * stn; index++ )
|
||||
sinTable[index] = (float)cos( stheta * index * 0.2f );
|
||||
|
||||
std::vector<uchar> _caccum(rn * tn, (uchar)0);
|
||||
AutoBuffer<uchar> _caccum(rn * tn, (uchar)0);
|
||||
uchar* caccum = &_caccum[0];
|
||||
|
||||
// Counting all feature pixels
|
||||
@@ -373,7 +373,7 @@ HoughLinesSDiv( InputArray image, OutputArray lines, int type,
|
||||
for( col = 0; col < w; col++ )
|
||||
fn += _POINT( row, col ) != 0;
|
||||
|
||||
std::vector<int> _x(fn), _y(fn);
|
||||
AutoBuffer<int> _x(fn), _y(fn);
|
||||
int* x = &_x[0], *y = &_y[0];
|
||||
|
||||
// Full Hough Transform (it's accumulator update part)
|
||||
@@ -445,7 +445,7 @@ HoughLinesSDiv( InputArray image, OutputArray lines, int type,
|
||||
return;
|
||||
}
|
||||
|
||||
std::vector<uchar> _buffer(srn * stn + 2);
|
||||
AutoBuffer<uchar> _buffer(srn * stn + 2);
|
||||
uchar* buffer = &_buffer[0];
|
||||
uchar* mcaccum = buffer + 1;
|
||||
|
||||
@@ -586,7 +586,7 @@ HoughLinesProbabilistic( Mat& image,
|
||||
|
||||
Mat accum = Mat::zeros( numangle, numrho, CV_32SC1 );
|
||||
Mat mask( height, width, CV_8UC1 );
|
||||
std::vector<float> trigtab(numangle*2);
|
||||
AutoBuffer<float> trigtab(numangle*2);
|
||||
|
||||
for( int n = 0; n < numangle; n++ )
|
||||
{
|
||||
@@ -2382,7 +2382,7 @@ static void HoughCircles( InputArray _image, OutputArray _circles,
|
||||
|
||||
if( type == CV_32FC4 )
|
||||
{
|
||||
std::vector<Vec4f> cw(ncircles);
|
||||
AutoBuffer<Vec4f> cw(ncircles);
|
||||
for( i = 0; i < ncircles; i++ )
|
||||
cw[i] = GetCircle4f(circles[i]);
|
||||
if (ncircles > 0)
|
||||
@@ -2390,7 +2390,7 @@ static void HoughCircles( InputArray _image, OutputArray _circles,
|
||||
}
|
||||
else if( type == CV_32FC3 )
|
||||
{
|
||||
std::vector<Vec3f> cwow(ncircles);
|
||||
AutoBuffer<Vec3f> cwow(ncircles);
|
||||
for( i = 0; i < ncircles; i++ )
|
||||
cwow[i] = GetCircle(circles[i]);
|
||||
if (ncircles > 0)
|
||||
|
||||
@@ -128,8 +128,8 @@ medianBlur_8u_O1( const Mat& _src, Mat& _dst, int ksize )
|
||||
# define CV_ALIGNMENT 16
|
||||
#endif
|
||||
|
||||
std::vector<HT> _h_coarse(1 * 16 * (STRIPE_SIZE + 2*r) * cn + CV_ALIGNMENT);
|
||||
std::vector<HT> _h_fine(16 * 16 * (STRIPE_SIZE + 2*r) * cn + CV_ALIGNMENT);
|
||||
AutoBuffer<HT> _h_coarse(1 * 16 * (STRIPE_SIZE + 2*r) * cn + CV_ALIGNMENT);
|
||||
AutoBuffer<HT> _h_fine(16 * 16 * (STRIPE_SIZE + 2*r) * cn + CV_ALIGNMENT);
|
||||
HT* h_coarse = alignPtr(&_h_coarse[0], CV_ALIGNMENT);
|
||||
HT* h_fine = alignPtr(&_h_fine[0], CV_ALIGNMENT);
|
||||
|
||||
|
||||
@@ -887,7 +887,7 @@ static bool ocl_morphOp(InputArray _src, OutputArray _dst, InputArray _kernel,
|
||||
if (actual_op < 0)
|
||||
actual_op = op;
|
||||
|
||||
std::vector<ocl::Kernel> kernels(iterations);
|
||||
AutoBuffer<ocl::Kernel> kernels(iterations);
|
||||
for (int i = 0; i < iterations; i++)
|
||||
{
|
||||
int current_op = iterations == i + 1 ? actual_op : op;
|
||||
|
||||
@@ -793,6 +793,7 @@ void Subdiv2D::getLeadingEdgeList(std::vector<int>& leadingEdgeList) const
|
||||
{
|
||||
leadingEdgeList.clear();
|
||||
int i, total = (int)(qedges.size()*4);
|
||||
//use a std::vector<bool> to benefit from the "bitset size/8" implementation
|
||||
std::vector<bool> edgemask(total, false);
|
||||
|
||||
for( i = 4; i < total; i += 2 )
|
||||
@@ -813,6 +814,7 @@ void Subdiv2D::getTriangleList(std::vector<Vec6f>& triangleList) const
|
||||
{
|
||||
triangleList.clear();
|
||||
int i, total = (int)(qedges.size()*4);
|
||||
//use a std::vector<bool> to benefit from the "bitset size/8" implementation
|
||||
std::vector<bool> edgemask(total, false);
|
||||
Rect2f rect(topLeft.x, topLeft.y, bottomRight.x - topLeft.x, bottomRight.y - topLeft.y);
|
||||
|
||||
|
||||
@@ -568,7 +568,6 @@ void crossCorr( const Mat& img, const Mat& _templ, Mat& corr,
|
||||
{
|
||||
const double blockScale = 4.5;
|
||||
const int minBlockSize = 256;
|
||||
std::vector<uchar> buf;
|
||||
|
||||
Mat templ = _templ;
|
||||
int depth = img.depth(), cn = img.channels();
|
||||
@@ -624,7 +623,7 @@ void crossCorr( const Mat& img, const Mat& _templ, Mat& corr,
|
||||
if( (ccn > 1 || cn > 1) && cdepth != maxDepth )
|
||||
bufSize = std::max( bufSize, blocksize.width*blocksize.height*CV_ELEM_SIZE(cdepth));
|
||||
|
||||
buf.resize(bufSize);
|
||||
AutoBuffer<uchar> buf(bufSize);
|
||||
|
||||
Ptr<hal::DFT2D> c = hal::DFT2D::create(dftsize.width, dftsize.height, dftTempl.depth(), 1, 1, CV_HAL_DFT_IS_INPLACE, templ.rows);
|
||||
|
||||
|
||||
@@ -822,7 +822,7 @@ private:
|
||||
float m_ig[4];
|
||||
void setPolynomialExpansionConsts(int n, double sigma)
|
||||
{
|
||||
std::vector<float> buf(n*6 + 3);
|
||||
AutoBuffer<float> buf(n*6 + 3);
|
||||
float* g = &buf[0] + n;
|
||||
float* xg = g + n*2 + 1;
|
||||
float* xxg = xg + n*2 + 1;
|
||||
|
||||
Reference in New Issue
Block a user