mirror of
https://github.com/opencv/opencv.git
synced 2026-07-31 08:13:04 +04:00
Merge remote-tracking branch 'upstream/3.4' into merge-3.4
This commit is contained in:
@@ -58,11 +58,13 @@
|
||||
#pragma warning( disable: 4244 ) //conversion from '__int64' to 'int', possible loss of data
|
||||
#endif
|
||||
|
||||
#if !defined(OPENCV_DISABLE_EIGEN_TENSOR_SUPPORT)
|
||||
#if EIGEN_WORLD_VERSION == 3 && EIGEN_MAJOR_VERSION >= 3 \
|
||||
&& defined(CV_CXX11) && defined(CV_CXX_STD_ARRAY)
|
||||
#include <unsupported/Eigen/CXX11/Tensor>
|
||||
#define OPENCV_EIGEN_TENSOR_SUPPORT
|
||||
#endif // EIGEN_WORLD_VERSION == 3 && EIGEN_MAJOR_VERSION >= 3
|
||||
#define OPENCV_EIGEN_TENSOR_SUPPORT 1
|
||||
#endif // EIGEN_WORLD_VERSION == 3 && EIGEN_MAJOR_VERSION >= 3
|
||||
#endif // !defined(OPENCV_DISABLE_EIGEN_TENSOR_SUPPORT)
|
||||
|
||||
namespace cv
|
||||
{
|
||||
|
||||
@@ -237,12 +237,19 @@ void setSize( Mat& m, int _dims, const int* _sz, const size_t* _steps, bool auto
|
||||
|
||||
if( _steps )
|
||||
{
|
||||
if (_steps[i] % esz1 != 0)
|
||||
if (i < _dims-1)
|
||||
{
|
||||
CV_Error(Error::BadStep, "Step must be a multiple of esz1");
|
||||
}
|
||||
if (_steps[i] % esz1 != 0)
|
||||
{
|
||||
CV_Error_(Error::BadStep, ("Step %zu for dimension %d must be a multiple of esz1 %zu", _steps[i], i, esz1));
|
||||
}
|
||||
|
||||
m.step.p[i] = i < _dims-1 ? _steps[i] : esz;
|
||||
m.step.p[i] = _steps[i];
|
||||
}
|
||||
else
|
||||
{
|
||||
m.step.p[i] = esz;
|
||||
}
|
||||
}
|
||||
else if( autoSteps )
|
||||
{
|
||||
|
||||
@@ -54,7 +54,8 @@
|
||||
#endif
|
||||
|
||||
#if defined __linux__ || defined __APPLE__ || defined __GLIBC__ \
|
||||
|| defined __HAIKU__ || defined __EMSCRIPTEN__ || defined __FreeBSD__
|
||||
|| defined __HAIKU__ || defined __EMSCRIPTEN__ || defined __FreeBSD__ \
|
||||
|| defined __OpenBSD__
|
||||
#include <unistd.h>
|
||||
#include <stdio.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
@@ -2175,4 +2175,32 @@ TEST(Mat, empty_iterator_16855)
|
||||
EXPECT_TRUE(m.begin<uchar>() == m.end<uchar>());
|
||||
}
|
||||
|
||||
|
||||
TEST(Mat, regression_18473)
|
||||
{
|
||||
std::vector<int> sizes(3);
|
||||
sizes[0] = 20;
|
||||
sizes[1] = 50;
|
||||
sizes[2] = 100;
|
||||
#if 1 // with the fix
|
||||
std::vector<size_t> steps(2);
|
||||
steps[0] = 50*100*2;
|
||||
steps[1] = 100*2;
|
||||
#else // without the fix
|
||||
std::vector<size_t> steps(3);
|
||||
steps[0] = 50*100*2;
|
||||
steps[1] = 100*2;
|
||||
steps[2] = 2;
|
||||
#endif
|
||||
std::vector<short> data(20*50*100, 0); // 1Mb
|
||||
data[data.size() - 1] = 5;
|
||||
|
||||
// param steps Array of ndims-1 steps
|
||||
Mat m(sizes, CV_16SC1, (void*)data.data(), (const size_t*)steps.data());
|
||||
|
||||
ASSERT_FALSE(m.empty());
|
||||
EXPECT_EQ((int)5, (int)m.at<short>(19, 49, 99));
|
||||
}
|
||||
|
||||
|
||||
}} // namespace
|
||||
|
||||
Reference in New Issue
Block a user