mirror of
https://github.com/opencv/opencv.git
synced 2025-06-08 01:53:19 +08:00
Merge pull request #21555 from cudawarped:fix_gpumat_dataend_bug
This commit is contained in:
commit
46e1560678
@ -184,11 +184,8 @@ void cv::cuda::GpuMat::create(int _rows, int _cols, int _type)
|
|||||||
if (esz * cols == step)
|
if (esz * cols == step)
|
||||||
flags |= Mat::CONTINUOUS_FLAG;
|
flags |= Mat::CONTINUOUS_FLAG;
|
||||||
|
|
||||||
int64 _nettosize = static_cast<int64>(step) * rows;
|
|
||||||
size_t nettosize = static_cast<size_t>(_nettosize);
|
|
||||||
|
|
||||||
datastart = data;
|
datastart = data;
|
||||||
dataend = data + nettosize;
|
dataend = data + step * (rows - 1) + cols * esz;
|
||||||
|
|
||||||
if (refcount)
|
if (refcount)
|
||||||
*refcount = 1;
|
*refcount = 1;
|
||||||
|
@ -63,6 +63,7 @@ namespace cvtest
|
|||||||
// GpuMat create
|
// GpuMat create
|
||||||
|
|
||||||
cv::cuda::GpuMat createMat(cv::Size size, int type, bool useRoi = false);
|
cv::cuda::GpuMat createMat(cv::Size size, int type, bool useRoi = false);
|
||||||
|
cv::cuda::GpuMat createMat(cv::Size size, int type, cv::Size& size0, cv::Point& ofs, bool useRoi = false);
|
||||||
cv::cuda::GpuMat loadMat(const cv::Mat& m, bool useRoi = false);
|
cv::cuda::GpuMat loadMat(const cv::Mat& m, bool useRoi = false);
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
@ -91,7 +91,13 @@ namespace cvtest
|
|||||||
|
|
||||||
GpuMat createMat(Size size, int type, bool useRoi)
|
GpuMat createMat(Size size, int type, bool useRoi)
|
||||||
{
|
{
|
||||||
Size size0 = size;
|
Size size0; Point ofs;
|
||||||
|
return createMat(size, type, size0, ofs, useRoi);
|
||||||
|
}
|
||||||
|
|
||||||
|
GpuMat createMat(Size size, int type, Size& size0, Point& ofs, bool useRoi)
|
||||||
|
{
|
||||||
|
size0 = size;
|
||||||
|
|
||||||
if (useRoi)
|
if (useRoi)
|
||||||
{
|
{
|
||||||
@ -100,9 +106,10 @@ namespace cvtest
|
|||||||
}
|
}
|
||||||
|
|
||||||
GpuMat d_m(size0, type);
|
GpuMat d_m(size0, type);
|
||||||
|
if (size0 != size) {
|
||||||
if (size0 != size)
|
ofs = Point((size0.width - size.width) / 2, (size0.height - size.height) / 2);
|
||||||
d_m = d_m(Rect((size0.width - size.width) / 2, (size0.height - size.height) / 2, size.width, size.height));
|
d_m = d_m(Rect(ofs, size));
|
||||||
|
}
|
||||||
|
|
||||||
return d_m;
|
return d_m;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user