Optimized buffers reuse in gpu module:

ensureSizeIsEnough now doesn't reallocate memory, if buffer is small submat of big matrix
fixed createContinous according new changes
This commit is contained in:
Vladislav Vinogradov
2012-10-26 15:49:39 +04:00
parent 810829f32e
commit afff9cf716
3 changed files with 71 additions and 16 deletions

View File

@@ -545,22 +545,6 @@ namespace cv { namespace gpu
ensureSizeIsEnough(size.height, size.width, type, m);
}
inline void createContinuous(int rows, int cols, int type, GpuMat& m)
{
int area = rows * cols;
if (!m.isContinuous() || m.type() != type || m.size().area() != area)
ensureSizeIsEnough(1, area, type, m);
m = m.reshape(0, rows);
}
inline void ensureSizeIsEnough(int rows, int cols, int type, GpuMat& m)
{
if (m.type() == type && m.rows >= rows && m.cols >= cols)
m = m(Rect(0, 0, cols, rows));
else
m.create(rows, cols, type);
}
inline GpuMat allocMatFromBuf(int rows, int cols, int type, GpuMat &mat)
{
if (!mat.empty() && mat.type() == type && mat.rows >= rows && mat.cols >= cols)