diff --git a/modules/core/src/arithm.cpp b/modules/core/src/arithm.cpp index 07a1894613..fc9f6685d3 100644 --- a/modules/core/src/arithm.cpp +++ b/modules/core/src/arithm.cpp @@ -988,9 +988,14 @@ void binary_op(InputArray _src1, InputArray _src2, OutputArray _dst, c = src1.channels(); } - Size sz = getContinuousSize(src1, src2, dst, c); - func(src1.data, src1.step, src2.data, src2.step, dst.data, dst.step, sz, 0); - return; + Size sz = getContinuousSize(src1, src2, dst); + size_t len = sz.width*(size_t)c; + if( len == (size_t)(int)len ) + { + sz.width = (int)len; + func(src1.data, src1.step, src2.data, src2.step, dst.data, dst.step, sz, 0); + return; + } } if( (kind1 == _InputArray::MATX) + (kind2 == _InputArray::MATX) == 1 || @@ -1045,6 +1050,9 @@ void binary_op(InputArray _src1, InputArray _src2, OutputArray _dst, NAryMatIterator it(arrays, ptrs); size_t total = it.size, blocksize = total; + if( blocksize*c > INT_MAX ) + blocksize = INT_MAX/c; + if( haveMask ) { blocksize = std::min(blocksize, blocksize0); diff --git a/modules/core/test/test_arithm.cpp b/modules/core/test/test_arithm.cpp index aa638cf69b..b20747085c 100644 --- a/modules/core/test/test_arithm.cpp +++ b/modules/core/test/test_arithm.cpp @@ -195,6 +195,13 @@ struct AddWeightedOp : public BaseAddOp struct MulOp : public BaseElemWiseOp { MulOp() : BaseElemWiseOp(2, FIX_BETA+FIX_GAMMA, 1, 1, Scalar::all(0)) {}; + void getValueRange(int depth, double& minval, double& maxval) + { + minval = depth < CV_32S ? cvtest::getMinVal(depth) : depth == CV_32S ? -1000000 : -1000.; + maxval = depth < CV_32S ? cvtest::getMaxVal(depth) : depth == CV_32S ? 1000000 : 1000.; + minval = std::max(minval, -30000.); + maxval = std::min(maxval, 30000.); + } void op(const vector& src, Mat& dst, const Mat&) { cv::multiply(src[0], src[1], dst, alpha); diff --git a/modules/python/test/test.py b/modules/python/test/test.py index e8d592c5f6..9271aa33a4 100644 --- a/modules/python/test/test.py +++ b/modules/python/test/test.py @@ -659,7 +659,7 @@ class FunctionTests(OpenCVTests): self.assert_(li[0] != None) def test_InPaint(self): - src = self.get_sample("doc/pics/building.jpg") + src = self.get_sample("samples/cpp/building.jpg") msk = cv.CreateImage(cv.GetSize(src), cv.IPL_DEPTH_8U, 1) damaged = cv.CloneMat(src) repaired = cv.CreateImage(cv.GetSize(src), cv.IPL_DEPTH_8U, 3) @@ -866,7 +866,7 @@ class FunctionTests(OpenCVTests): def yield_line_image(self): """ Needed by HoughLines tests """ - src = self.get_sample("doc/pics/building.jpg", 0) + src = self.get_sample("samples/cpp/building.jpg", 0) dst = cv.CreateImage(cv.GetSize(src), 8, 1) cv.Canny(src, dst, 50, 200, 3) return dst @@ -2104,7 +2104,7 @@ class DocumentFragmentTests(OpenCVTests): """ Test the fragments of code that are included in the documentation """ def setUp(self): OpenCVTests.setUp(self) - sys.path.append("../doc/python_fragments") + sys.path.append(".") def test_precornerdetect(self): from precornerdetect import precornerdetect @@ -2118,7 +2118,7 @@ class DocumentFragmentTests(OpenCVTests): def test_findstereocorrespondence(self): from findstereocorrespondence import findstereocorrespondence - (l,r) = [self.get_sample("doc/pics/tsukuba_%s.png" % c, cv.CV_LOAD_IMAGE_GRAYSCALE) for c in "lr"] + (l,r) = [self.get_sample("samples/cpp/tsukuba_%s.png" % c, cv.CV_LOAD_IMAGE_GRAYSCALE) for c in "lr"] (disparity_left, disparity_right) = findstereocorrespondence(l, r) @@ -2129,7 +2129,7 @@ class DocumentFragmentTests(OpenCVTests): def test_calchist(self): from calchist import hs_histogram i1 = self.get_sample("samples/c/lena.jpg") - i2 = self.get_sample("doc/pics/building.jpg") + i2 = self.get_sample("samples/cpp/building.jpg") i3 = cv.CloneMat(i1) cv.Flip(i3, i3, 1) h1 = hs_histogram(i1) diff --git a/samples/cpp/building.jpg b/samples/cpp/building.jpg new file mode 100644 index 0000000000..6056492f2f Binary files /dev/null and b/samples/cpp/building.jpg differ diff --git a/samples/cpp/tsukuba_l.png b/samples/cpp/tsukuba_l.png new file mode 100644 index 0000000000..be22fd6942 Binary files /dev/null and b/samples/cpp/tsukuba_l.png differ diff --git a/samples/cpp/tsukuba_r.png b/samples/cpp/tsukuba_r.png new file mode 100644 index 0000000000..c4acf61bbb Binary files /dev/null and b/samples/cpp/tsukuba_r.png differ