\cvarg{m}{Destination matrix. Will be only reshaped if it has proper type and area (\texttt{rows} $\times$ \texttt{cols}).}\r
\end{description}\r
\r
-Matrix is called continuous if its elements are stored continuously, i.e. wuthout gaps in the end of each row.
\ No newline at end of file
+Also the following wrappers are available:\r
+\cvdefCpp{GpuMat createContinuous(int rows, int cols, int type);\newline\r
+void createContinuous(Size size, int type, GpuMat\& m);\newline\r
+GpuMat createContinuous(Size size, int type);}\r
+\r
+Matrix is called continuous if its elements are stored continuously, i.e. wuthout gaps in the end of each row.\r
+\r
+\r
+\cvCppFunc{gpu::ensureSizeIsEnough}\r
+Ensures that size of matrix is big enough and matrix has proper type. The function doesn't reallocate memory if matrix has proper attributes already.\r
+\r
+\cvdefCpp{void ensureSizeIsEnough(int rows, int cols, int type, GpuMat\& m);}\r
+\begin{description}\r
+\cvarg{rows}{Minimum desired number of rows.}\r
+\cvarg{cols}{Minimum desired number of cols.}\r
+\cvarg{type}{Desired matrix type.}\r
+\cvarg{m}{Destination matrix.}\r
+\end{description}\r
+\r
+Also the following wrapper is available:\r
+\cvdefCpp{void ensureSizeIsEnough(Size size, int type, GpuMat\& m);}
\ No newline at end of file
#include "GpuMat_BetaDeprecated.hpp"\r
#endif\r
\r
- //! creates continuous GPU matrix\r
+ //! Creates continuous GPU matrix\r
CV_EXPORTS void createContinuous(int rows, int cols, int type, GpuMat& m);\r
\r
+ //! Ensures that size of the given matrix is not less than (rows, cols) size\r
+ //! and matrix type is match specified one too\r
+ CV_EXPORTS void ensureSizeIsEnough(int rows, int cols, int type, GpuMat& m);\r
+\r
//////////////////////////////// CudaMem ////////////////////////////////\r
// CudaMem is limited cv::Mat with page locked memory allocation.\r
// Page locked memory is only needed for async and faster coping to GPU.\r
return m;\r
}\r
\r
+inline void ensureSizeIsEnough(Size size, int type, GpuMat& m)\r
+{\r
+ ensureSizeIsEnough(size.height, size.width, type, m);\r
+}\r
\r
\r
///////////////////////////////////////////////////////////////////////\r
inline CudaMem::~CudaMem()\r
{\r
release();\r
+\r
}\r
\r
inline CudaMem& CudaMem::operator = (const CudaMem& m)\r
m = m.reshape(0, rows);\r
}\r
\r
+void cv::gpu::ensureSizeIsEnough(int rows, int cols, int type, GpuMat& m)\r
+{\r
+ if (m.type() == type && m.rows >= rows && m.cols >= cols)\r
+ return;\r
+ m.create(rows, cols, type);\r
+}\r
+\r
\r
///////////////////////////////////////////////////////////////////////\r
//////////////////////////////// CudaMem //////////////////////////////\r
\r
Size bufSize;\r
sum::get_buf_size_required(src.cols, src.rows, src.channels(), bufSize.width, bufSize.height); \r
- buf.create(bufSize, CV_8U);\r
+ ensureSizeIsEnough(bufSize, CV_8U, buf);\r
\r
Caller caller = callers[hasAtomicsSupport(getDevice())][src.depth()];\r
if (!caller) CV_Error(CV_StsBadArg, "sum: unsupported type");\r
\r
Size bufSize;\r
sum::get_buf_size_required(src.cols, src.rows, src.channels(), bufSize.width, bufSize.height); \r
- buf.create(bufSize, CV_8U);\r
+ ensureSizeIsEnough(bufSize, CV_8U, buf);\r
\r
Caller caller = callers[hasAtomicsSupport(getDevice())][src.depth()];\r
if (!caller) CV_Error(CV_StsBadArg, "sqrSum: unsupported type");\r
\r
Size bufSize;\r
get_buf_size_required(src.cols, src.rows, src.elemSize(), bufSize.width, bufSize.height);\r
- buf.create(bufSize, CV_8U);\r
+ ensureSizeIsEnough(bufSize, CV_8U, buf);\r
\r
if (mask.empty())\r
{\r
\r
template <typename T> \r
void min_max_loc_caller(const DevMem2D src, double* minval, double* maxval, \r
- int minloc[2], int maxloc[2], PtrStep valbuf, PtrStep locbuf);\r
+ int minloc[2], int maxloc[2], PtrStep valBuf, PtrStep locBuf);\r
\r
template <typename T> \r
void min_max_loc_mask_caller(const DevMem2D src, const PtrStep mask, double* minval, double* maxval, \r
- int minloc[2], int maxloc[2], PtrStep valbuf, PtrStep locbuf);\r
+ int minloc[2], int maxloc[2], PtrStep valBuf, PtrStep locBuf);\r
\r
template <typename T> \r
void min_max_loc_multipass_caller(const DevMem2D src, double* minval, double* maxval, \r
- int minloc[2], int maxloc[2], PtrStep valbuf, PtrStep locbuf);\r
+ int minloc[2], int maxloc[2], PtrStep valBuf, PtrStep locBuf);\r
\r
template <typename T> \r
void min_max_loc_mask_multipass_caller(const DevMem2D src, const PtrStep mask, double* minval, double* maxval, \r
- int minloc[2], int maxloc[2], PtrStep valbuf, PtrStep locbuf);\r
+ int minloc[2], int maxloc[2], PtrStep valBuf, PtrStep locBuf);\r
}}}}\r
\r
\r
void cv::gpu::minMaxLoc(const GpuMat& src, double* minVal, double* maxVal, Point* minLoc, Point* maxLoc, const GpuMat& mask)\r
{ \r
- GpuMat valbuf, locbuf;\r
- minMaxLoc(src, minVal, maxVal, minLoc, maxLoc, mask, valbuf, locbuf);\r
+ GpuMat valBuf, locBuf;\r
+ minMaxLoc(src, minVal, maxVal, minLoc, maxLoc, mask, valBuf, locBuf);\r
}\r
\r
\r
void cv::gpu::minMaxLoc(const GpuMat& src, double* minVal, double* maxVal, Point* minLoc, Point* maxLoc,\r
- const GpuMat& mask, GpuMat& valbuf, GpuMat& locbuf)\r
+ const GpuMat& mask, GpuMat& valBuf, GpuMat& locBuf)\r
{\r
using namespace mathfunc::minmaxloc;\r
\r
int minLoc_[2];\r
int maxLoc_[2];\r
\r
- Size valbuf_size, locbuf_size;\r
- get_buf_size_required(src.cols, src.rows, src.elemSize(), valbuf_size.width, \r
- valbuf_size.height, locbuf_size.width, locbuf_size.height);\r
- valbuf.create(valbuf_size, CV_8U);\r
- locbuf.create(locbuf_size, CV_8U);\r
+ Size valBufSize, locBufSize;\r
+ get_buf_size_required(src.cols, src.rows, src.elemSize(), valBufSize.width, \r
+ valBufSize.height, locBufSize.width, locBufSize.height);\r
+ ensureSizeIsEnough(valBufSize, CV_8U, valBuf);\r
+ ensureSizeIsEnough(locBufSize, CV_8U, locBuf);\r
\r
if (mask.empty())\r
{\r
Caller caller = callers[hasAtomicsSupport(getDevice())][src.type()];\r
if (!caller) CV_Error(CV_StsBadArg, "minMaxLoc: unsupported type");\r
- caller(src, minVal, maxVal, minLoc_, maxLoc_, valbuf, locbuf);\r
+ caller(src, minVal, maxVal, minLoc_, maxLoc_, valBuf, locBuf);\r
}\r
else\r
{\r
MaskedCaller caller = masked_callers[hasAtomicsSupport(getDevice())][src.type()];\r
if (!caller) CV_Error(CV_StsBadArg, "minMaxLoc: unsupported type");\r
- caller(src, mask, minVal, maxVal, minLoc_, maxLoc_, valbuf, locbuf);\r
+ caller(src, mask, minVal, maxVal, minLoc_, maxLoc_, valBuf, locBuf);\r
}\r
\r
if (minLoc) { minLoc->x = minLoc_[0]; minLoc->y = minLoc_[1]; }\r
CV_Assert(src.channels() == 1);\r
CV_Assert(src.type() != CV_64F || hasNativeDoubleSupport(getDevice()));\r
\r
- Size buf_size;\r
- get_buf_size_required(src.cols, src.rows, buf_size.width, buf_size.height);\r
- buf.create(buf_size, CV_8U);\r
+ Size bufSize;\r
+ get_buf_size_required(src.cols, src.rows, bufSize.width, bufSize.height);\r
+ ensureSizeIsEnough(bufSize, CV_8U, buf);\r
\r
Caller caller = callers[hasAtomicsSupport(getDevice())][src.type()];\r
if (!caller) CV_Error(CV_StsBadArg, "countNonZero: unsupported type");\r
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-// By downloading, copying, installing or using the software you agree to this license.
-// If you do not agree to this license, do not download, install,
-// copy or use the software.
-//
-//
-// Intel License Agreement
-// For Open Source Computer Vision Library
-//
-// Copyright (C) 2000, Intel Corporation, all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-// * Redistribution's of source code must retain the above copyright notice,
-// this list of conditions and the following disclaimer.
-//
-// * Redistribution's in binary form must reproduce the above copyright notice,
-// this list of conditions and the following disclaimer in the documentation
-// and/or other materials provided with the distribution.
-//
-// * The name of Intel Corporation may not be used to endorse or promote products
-// derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-
-#ifndef _GPU_TEST_H_
-#define _GPU_TEST_H_
-
-#if defined WIN32 || defined _WIN32
-#include <windows.h>
-#undef min
-#undef max
-#endif
-
-#include <opencv2/gpu/gpu.hpp>
-#include <opencv2/highgui/highgui.hpp>
+/*M///////////////////////////////////////////////////////////////////////////////////////\r
+//\r
+// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.\r
+//\r
+// By downloading, copying, installing or using the software you agree to this license.\r
+// If you do not agree to this license, do not download, install,\r
+// copy or use the software.\r
+//\r
+//\r
+// Intel License Agreement\r
+// For Open Source Computer Vision Library\r
+//\r
+// Copyright (C) 2000, Intel Corporation, all rights reserved.\r
+// Third party copyrights are property of their respective owners.\r
+//\r
+// Redistribution and use in source and binary forms, with or without modification,\r
+// are permitted provided that the following conditions are met:\r
+//\r
+// * Redistribution's of source code must retain the above copyright notice,\r
+// this list of conditions and the following disclaimer.\r
+//\r
+// * Redistribution's in binary form must reproduce the above copyright notice,\r
+// this list of conditions and the following disclaimer in the documentation\r
+// and/or other materials provided with the distribution.\r
+//\r
+// * The name of Intel Corporation may not be used to endorse or promote products\r
+// derived from this software without specific prior written permission.\r
+//\r
+// This software is provided by the copyright holders and contributors "as is" and\r
+// any express or implied warranties, including, but not limited to, the implied\r
+// warranties of merchantability and fitness for a particular purpose are disclaimed.\r
+// In no event shall the Intel Corporation or contributors be liable for any direct,\r
+// indirect, incidental, special, exemplary, or consequential damages\r
+// (including, but not limited to, procurement of substitute goods or services;\r
+// loss of use, data, or profits; or business interruption) however caused\r
+// and on any theory of liability, whether in contract, strict liability,\r
+// or tort (including negligence or otherwise) arising in any way out of\r
+// the use of this software, even if advised of the possibility of such damage.\r
+//\r
+//M*/\r
+\r
+#ifndef _GPU_TEST_H_\r
+#define _GPU_TEST_H_\r
+\r
+#if defined WIN32 || defined _WIN32\r
+#include <windows.h>\r
+#undef min\r
+#undef max\r
+#endif\r
+\r
+#include <opencv2/gpu/gpu.hpp>\r
+#include <opencv2/highgui/highgui.hpp>\r
#include <opencv2/imgproc/imgproc.hpp>\r
-#include <opencv2/features2d/features2d.hpp>
-#include "cxts.h"
-
-/****************************************************************************************/
-/* Warnings Disabling */
-/****************************************************************************************/
-#if _MSC_VER > 1000
-#pragma warning(disable : 4514) /* unreferenced inline function has been */
- /* removed */
-#pragma warning(disable : 4127) /* conditional expression is constant */
- /* for no warnings in _ASSERT */
-#pragma warning(disable : 4996) /* deprecated function */
-#endif
-
-
-static inline bool check_and_treat_gpu_exception(const cv::Exception& e, CvTS* ts)
-{
- switch (e.code)
- {
- case CV_GpuNotSupported:
- ts->printf(CvTS::LOG, "\nGpu not supported by the library");
- break;
-
- case CV_GpuApiCallError:
- ts->printf(CvTS::LOG, "\nGPU Error: %s", e.what());
- break;
-
- case CV_GpuNppCallError:
- ts->printf(CvTS::LOG, "\nNPP Error: %s", e.what());
- break;
-
- default:
- return false;
- }
- ts->set_failed_test_info(CvTS::FAIL_GENERIC);
- return true;
-}
-
-#endif
-
-/* End of file. */
+#include <opencv2/features2d/features2d.hpp>\r
+#include "cxts.h"\r
+\r
+/****************************************************************************************/\r
+/* Warnings Disabling */\r
+/****************************************************************************************/\r
+#if _MSC_VER > 1000\r
+#pragma warning(disable : 4514) /* unreferenced inline function has been */\r
+ /* removed */\r
+#pragma warning(disable : 4127) /* conditional expression is constant */\r
+ /* for no warnings in _ASSERT */\r
+#pragma warning(disable : 4996) /* deprecated function */\r
+#endif\r
+\r
+\r
+static inline bool check_and_treat_gpu_exception(const cv::Exception& e, CvTS* ts)\r
+{\r
+ switch (e.code)\r
+ {\r
+ case CV_GpuNotSupported: \r
+ ts->printf(CvTS::LOG, "\nGpu not supported by the library"); \r
+ break;\r
+\r
+ case CV_GpuApiCallError: \r
+ ts->printf(CvTS::LOG, "\nGPU Error: %s", e.what());\r
+ break;\r
+\r
+ case CV_GpuNppCallError: \r
+ ts->printf(CvTS::LOG, "\nNPP Error: %s", e.what());\r
+ break;\r
+\r
+ default:\r
+ return false;\r
+ }\r
+ ts->set_failed_test_info(CvTS::FAIL_GENERIC); \r
+ return true;\r
+}\r
+\r
+#endif \r
+\r
+/* End of file. */\r