From 6de72ea8eec3969e0168bf034f0b3f54b4444adb Mon Sep 17 00:00:00 2001 From: Vadim Pisarevsky Date: Tue, 31 May 2011 14:01:21 +0000 Subject: [PATCH] resolved tickets #904 (nicer floating-point formatting) and #816 (reduce with CV_REDUCE_AVG on 8-bit arrays) --- modules/core/src/matrix.cpp | 1 + modules/core/src/persistence.cpp | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/modules/core/src/matrix.cpp b/modules/core/src/matrix.cpp index 25bc918118..177ff1b14f 100644 --- a/modules/core/src/matrix.cpp +++ b/modules/core/src/matrix.cpp @@ -1873,6 +1873,7 @@ void cv::reduce(const InputArray& _src, OutputArray _dst, int dim, int op, int d op = CV_REDUCE_SUM; if( sdepth < CV_32S && ddepth < CV_32S ) temp.create(dst.rows, dst.cols, CV_32SC(cn)); + ddepth = CV_32S; } ReduceFunc func = 0; diff --git a/modules/core/src/persistence.cpp b/modules/core/src/persistence.cpp index 6558b42f00..96b3dfeb02 100644 --- a/modules/core/src/persistence.cpp +++ b/modules/core/src/persistence.cpp @@ -775,7 +775,7 @@ icvDoubleToString( char* buf, double value ) sprintf( buf, "%d.", ivalue ); else { - static const char* fmt = "%.16e"; + static const char* fmt = "%.17g"; char* ptr = buf; sprintf( buf, fmt, value ); if( *ptr == '+' || *ptr == '-' ) @@ -814,7 +814,7 @@ icvFloatToString( char* buf, float value ) sprintf( buf, "%d.", ivalue ); else { - static const char* fmt = "%.8e"; + static const char* fmt = "%.9g"; char* ptr = buf; sprintf( buf, fmt, value ); if( *ptr == '+' || *ptr == '-' )