Merge branch '2.4'

This commit is contained in:
Andrey Kamaev
2012-10-22 16:57:56 +04:00
52 changed files with 2143 additions and 1629 deletions

View File

@@ -3780,23 +3780,6 @@ struct CV_EXPORTS Formatted
vector<int> params;
};
/** Writes a point to an output stream in Matlab notation
*/
template<typename _Tp> inline std::ostream& operator<<(std::ostream& out, const Point_<_Tp>& p)
{
out << "[" << p.x << ", " << p.y << "]";
return out;
}
/** Writes a point to an output stream in Matlab notation
*/
template<typename _Tp> inline std::ostream& operator<<(std::ostream& out, const Point3_<_Tp>& p)
{
out << "[" << p.x << ", " << p.y << ", " << p.z << "]";
return out;
}
static inline Formatted format(const Mat& mtx, const char* fmt,
const vector<int>& params=vector<int>())
{
@@ -3858,6 +3841,60 @@ template<typename _Tp> static inline std::ostream& operator << (std::ostream& ou
}
/** Writes a Matx to an output stream.
*/
template<typename _Tp, int m, int n> inline std::ostream& operator<<(std::ostream& out, const Matx<_Tp, m, n>& matx)
{
out << cv::Mat(matx);
return out;
}
/** Writes a point to an output stream in Matlab notation
*/
template<typename _Tp> inline std::ostream& operator<<(std::ostream& out, const Point_<_Tp>& p)
{
out << "[" << p.x << ", " << p.y << "]";
return out;
}
/** Writes a point to an output stream in Matlab notation
*/
template<typename _Tp> inline std::ostream& operator<<(std::ostream& out, const Point3_<_Tp>& p)
{
out << "[" << p.x << ", " << p.y << ", " << p.z << "]";
return out;
}
/** Writes a Vec to an output stream. Format example : [10, 20, 30]
*/
template<typename _Tp, int n> inline std::ostream& operator<<(std::ostream& out, const Vec<_Tp, n>& vec)
{
out << "[";
for (int i = 0; i < n - 1; ++i) {
out << vec[i] << ", ";
}
out << vec[n-1] << "]";
return out;
}
/** Writes a Size_ to an output stream. Format example : [640 x 480]
*/
template<typename _Tp> inline std::ostream& operator<<(std::ostream& out, const Size_<_Tp>& size)
{
out << "[" << size.width << " x " << size.height << "]";
return out;
}
/** Writes a Rect_ to an output stream. Format example : [640 x 480 from (10, 20)]
*/
template<typename _Tp> inline std::ostream& operator<<(std::ostream& out, const Rect_<_Tp>& rect)
{
out << "[" << rect.width << " x " << rect.height << " from (" << rect.x << ", " << rect.y << ")]";
return out;
}
template<typename _Tp> inline Ptr<_Tp> Algorithm::create(const string& name)
{
return _create(name).ptr<_Tp>();

View File

@@ -1228,10 +1228,10 @@ static int actualScalarDepth(const double* data, int len)
maxval = MAX(maxval, ival);
}
return i < len ? CV_64F :
minval >= 0 && maxval <= UCHAR_MAX ? CV_8U :
minval >= SCHAR_MIN && maxval <= SCHAR_MAX ? CV_8S :
minval >= 0 && maxval <= USHRT_MAX ? CV_16U :
minval >= SHRT_MIN && maxval <= SHRT_MAX ? CV_16S :
minval >= 0 && maxval <= (int)UCHAR_MAX ? CV_8U :
minval >= (int)SCHAR_MIN && maxval <= (int)SCHAR_MAX ? CV_8S :
minval >= 0 && maxval <= (int)USHRT_MAX ? CV_16U :
minval >= (int)SHRT_MIN && maxval <= (int)SHRT_MAX ? CV_16S :
CV_32S;
}
@@ -1281,7 +1281,7 @@ static void arithm_op(InputArray _src1, InputArray _src2, OutputArray _dst,
depth2 = CV_32F;
}
else
depth2 = src1.depth() < CV_32S || src1.depth() == CV_32F ? CV_32F : CV_64F;
depth2 = CV_64F;
}
int cn = src1.channels(), depth1 = src1.depth(), wtype;

View File

@@ -1522,4 +1522,12 @@ protected:
TEST(Core_ArithmMask, uninitialized) { CV_ArithmMaskTest test; test.safe_run(); }
TEST(Multiply, FloatingPointRounding)
{
cv::Mat src(1, 1, CV_8UC1, cv::Scalar::all(110)), dst;
cv::Scalar s(147.286359696927, 1, 1 ,1);
cv::multiply(src, s, dst, 1, CV_16U);
// with CV_32F this produce result 16202
ASSERT_EQ(dst.at<ushort>(0,0), 16201);
}