1
0
mirror of https://github.com/opencv/opencv.git synced 2026-07-30 07:43:03 +04:00

Merge pull request #26472 from chacha21:gpumatnd_step

More convenient GpuMatND constructor #26472

Closes #26471

For convenience, GpuMatND can now accept a step.size() equal to size.size(), as long as the last step is equal to elemSize()

- [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
- [X] There is a reference to the original bug report and related work
- [ ] 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:
Pierre Chatelier
2024-12-17 15:26:14 +01:00
committed by GitHub
parent e0001903ce
commit d77abeddd0
2 changed files with 7 additions and 4 deletions
+4 -2
View File
@@ -12,7 +12,8 @@ GpuMatND::~GpuMatND() = default;
GpuMatND::GpuMatND(SizeArray _size, int _type, void* _data, StepArray _step) :
flags(0), dims(0), data(static_cast<uchar*>(_data)), offset(0)
{
CV_Assert(_step.empty() || _size.size() == _step.size() + 1);
CV_Assert(_step.empty() || _size.size() == _step.size() + 1 ||
(_size.size() == _step.size() && _step.back() == (size_t)CV_ELEM_SIZE(_type)));
setFields(std::move(_size), _type, std::move(_step));
}
@@ -106,7 +107,8 @@ void GpuMatND::setFields(SizeArray _size, int _type, StepArray _step)
else
{
step = std::move(_step);
step.push_back(elemSize());
if (step.size() < size.size())
step.push_back(elemSize());
flags = cv::updateContinuityFlag(flags, dims, size.data(), step.data());
}