minor stitching optimization (improve buffer reuse)

This commit is contained in:
Vladislav Vinogradov
2011-08-09 13:08:54 +00:00
parent b319e7f403
commit c5adaa717b
8 changed files with 95 additions and 23 deletions

View File

@@ -1462,6 +1462,8 @@ namespace cv
void operator()(const GpuMat& img, const GpuMat& mask, std::vector<KeyPoint>& keypoints, std::vector<float>& descriptors,
bool useProvidedKeypoints = false);
void releaseMemory();
//! max keypoints = min(keypointsRatio * img.size().area(), 65535)
float keypointsRatio;

View File

@@ -203,8 +203,8 @@ void cv::gpu::BruteForceMatcher_GPU_base::matchSingle(const GpuMat& queryDescs,
const int nQuery = queryDescs.rows;
trainIdx.create(1, nQuery, CV_32S);
distance.create(1, nQuery, CV_32F);
ensureSizeIsEnough(1, nQuery, CV_32S, trainIdx);
ensureSizeIsEnough(1, nQuery, CV_32F, distance);
match_caller_t func = match_callers[distType][queryDescs.depth()];
CV_Assert(func != 0);
@@ -335,9 +335,9 @@ void cv::gpu::BruteForceMatcher_GPU_base::matchCollection(const GpuMat& queryDes
const int nQuery = queryDescs.rows;
trainIdx.create(1, nQuery, CV_32S);
imgIdx.create(1, nQuery, CV_32S);
distance.create(1, nQuery, CV_32F);
ensureSizeIsEnough(1, nQuery, CV_32S, trainIdx);
ensureSizeIsEnough(1, nQuery, CV_32S, imgIdx);
ensureSizeIsEnough(1, nQuery, CV_32F, distance);
match_caller_t func = match_callers[distType][queryDescs.depth()];
CV_Assert(func != 0);
@@ -435,8 +435,8 @@ void cv::gpu::BruteForceMatcher_GPU_base::knnMatch(const GpuMat& queryDescs, con
const int nQuery = queryDescs.rows;
const int nTrain = trainDescs.rows;
trainIdx.create(nQuery, k, CV_32S);
distance.create(nQuery, k, CV_32F);
ensureSizeIsEnough(nQuery, k, CV_32S, trainIdx);
ensureSizeIsEnough(nQuery, k, CV_32F, distance);
ensureSizeIsEnough(nQuery, nTrain, CV_32FC1, allDist);
if (stream)
@@ -593,8 +593,8 @@ void cv::gpu::BruteForceMatcher_GPU_base::radiusMatch(const GpuMat& queryDescs,
ensureSizeIsEnough(1, nQuery, CV_32SC1, nMatches);
if (trainIdx.empty())
{
trainIdx.create(nQuery, nTrain, CV_32SC1);
distance.create(nQuery, nTrain, CV_32FC1);
ensureSizeIsEnough(nQuery, nTrain, CV_32SC1, trainIdx);
ensureSizeIsEnough(nQuery, nTrain, CV_32FC1, distance);
}
if (stream)

View File

@@ -192,8 +192,8 @@ namespace
Size src_size = src.size();
dst.create(src_size, dstType);
ensureSizeIsEnough(src_size, bufType, dstBuf);
//dstBuf.create(src_size, bufType);
if (stream)
{

View File

@@ -59,6 +59,7 @@ void cv::gpu::SURF_GPU::operator()(const GpuMat&, const GpuMat&, GpuMat&, GpuMat
void cv::gpu::SURF_GPU::operator()(const GpuMat&, const GpuMat&, vector<KeyPoint>&) { throw_nogpu(); }
void cv::gpu::SURF_GPU::operator()(const GpuMat&, const GpuMat&, vector<KeyPoint>&, GpuMat&, bool) { throw_nogpu(); }
void cv::gpu::SURF_GPU::operator()(const GpuMat&, const GpuMat&, vector<KeyPoint>&, vector<float>&, bool) { throw_nogpu(); }
void cv::gpu::SURF_GPU::releaseMemory() { throw_nogpu(); }
#else /* !defined (HAVE_CUDA) */
@@ -201,7 +202,7 @@ namespace
const int nFeatures = keypoints.cols;
if (nFeatures > 0)
{
descriptors.create(nFeatures, descriptorSize, CV_32F);
ensureSizeIsEnough(nFeatures, descriptorSize, CV_32F, descriptors);
compute_descriptors_gpu(descriptors, keypoints.ptr<float>(SURF_GPU::SF_X), keypoints.ptr<float>(SURF_GPU::SF_Y),
keypoints.ptr<float>(SURF_GPU::SF_SIZE), keypoints.ptr<float>(SURF_GPU::SF_DIR), nFeatures);
}
@@ -431,4 +432,15 @@ void cv::gpu::SURF_GPU::operator()(const GpuMat& img, const GpuMat& mask, vector
downloadDescriptors(descriptorsGPU, descriptors);
}
void cv::gpu::SURF_GPU::releaseMemory()
{
sum.release();
mask1.release();
maskSum.release();
intBuffer.release();
det.release();
trace.release();
maxPosBuffer.release();
}
#endif /* !defined (HAVE_CUDA) */