Revert 4f9c081
authorRoman Donchenko <roman.donchenko@itseez.com>
Fri, 17 Jan 2014 08:51:52 +0000 (12:51 +0400)
committerRoman Donchenko <roman.donchenko@itseez.com>
Fri, 17 Jan 2014 08:51:52 +0000 (12:51 +0400)
That commit introduces problems, as it breaks certain use cases of
OpenCV functions; for example, convertTo of an Nx1 matrix to an
std::vector.

Since vectors can't store separate width and height values, OpenCV
considers them to always be 1xN. So even though the vector is created with
.create(N, 1), the Mat passed to getContinousSize has dimensions 1xN,
and the size comparison fails, even though the operation itself is safe.

This is a use case we probably don't want to break, at the very least
for backwards compatibility. So I'm reverting the commit. This will also
unfix bug #3319; I'll submit a less intrusive solution as a PR to 2.4, which
will also revert 4f9c081 there.

modules/core/src/precomp.hpp

index ad4fd59..3727b2f 100644 (file)
@@ -153,14 +153,12 @@ template<typename T> struct OpMax
 
 inline Size getContinuousSize( const Mat& m1, int widthScale=1 )
 {
-    CV_Assert(m1.dims <= 2);
     return m1.isContinuous() ? Size(m1.cols*m1.rows*widthScale, 1) :
         Size(m1.cols*widthScale, m1.rows);
 }
 
 inline Size getContinuousSize( const Mat& m1, const Mat& m2, int widthScale=1 )
 {
-    CV_Assert(m1.dims <= 2 && m1.size() == m2.size());
     return (m1.flags & m2.flags & Mat::CONTINUOUS_FLAG) != 0 ?
         Size(m1.cols*m1.rows*widthScale, 1) : Size(m1.cols*widthScale, m1.rows);
 }
@@ -168,7 +166,6 @@ inline Size getContinuousSize( const Mat& m1, const Mat& m2, int widthScale=1 )
 inline Size getContinuousSize( const Mat& m1, const Mat& m2,
                                const Mat& m3, int widthScale=1 )
 {
-    CV_Assert(m1.dims <= 2 && m1.size() == m2.size() && m1.size() == m3.size());
     return (m1.flags & m2.flags & m3.flags & Mat::CONTINUOUS_FLAG) != 0 ?
         Size(m1.cols*m1.rows*widthScale, 1) : Size(m1.cols*widthScale, m1.rows);
 }
@@ -177,7 +174,6 @@ inline Size getContinuousSize( const Mat& m1, const Mat& m2,
                                const Mat& m3, const Mat& m4,
                                int widthScale=1 )
 {
-    CV_Assert(m1.dims <= 2 && m1.size() == m2.size() && m1.size() == m3.size() && m1.size() == m4.size());
     return (m1.flags & m2.flags & m3.flags & m4.flags & Mat::CONTINUOUS_FLAG) != 0 ?
         Size(m1.cols*m1.rows*widthScale, 1) : Size(m1.cols*widthScale, m1.rows);
 }
@@ -186,7 +182,6 @@ inline Size getContinuousSize( const Mat& m1, const Mat& m2,
                                const Mat& m3, const Mat& m4,
                                const Mat& m5, int widthScale=1 )
 {
-    CV_Assert(m1.dims <= 2 && m1.size() == m2.size() && m1.size() == m3.size() && m1.size() == m4.size() && m1.size() == m5.size());
     return (m1.flags & m2.flags & m3.flags & m4.flags & m5.flags & Mat::CONTINUOUS_FLAG) != 0 ?
         Size(m1.cols*m1.rows*widthScale, 1) : Size(m1.cols*widthScale, m1.rows);
 }