Commit 6de72ea8 authored by Vadim Pisarevsky's avatar Vadim Pisarevsky

resolved tickets #904 (nicer floating-point formatting) and #816 (reduce with…

resolved tickets #904 (nicer floating-point formatting) and #816 (reduce with CV_REDUCE_AVG on 8-bit arrays)
parent 12999416
...@@ -1873,6 +1873,7 @@ void cv::reduce(const InputArray& _src, OutputArray _dst, int dim, int op, int d ...@@ -1873,6 +1873,7 @@ void cv::reduce(const InputArray& _src, OutputArray _dst, int dim, int op, int d
op = CV_REDUCE_SUM; op = CV_REDUCE_SUM;
if( sdepth < CV_32S && ddepth < CV_32S ) if( sdepth < CV_32S && ddepth < CV_32S )
temp.create(dst.rows, dst.cols, CV_32SC(cn)); temp.create(dst.rows, dst.cols, CV_32SC(cn));
ddepth = CV_32S;
} }
ReduceFunc func = 0; ReduceFunc func = 0;
......
...@@ -775,7 +775,7 @@ icvDoubleToString( char* buf, double value ) ...@@ -775,7 +775,7 @@ icvDoubleToString( char* buf, double value )
sprintf( buf, "%d.", ivalue ); sprintf( buf, "%d.", ivalue );
else else
{ {
static const char* fmt = "%.16e"; static const char* fmt = "%.17g";
char* ptr = buf; char* ptr = buf;
sprintf( buf, fmt, value ); sprintf( buf, fmt, value );
if( *ptr == '+' || *ptr == '-' ) if( *ptr == '+' || *ptr == '-' )
...@@ -814,7 +814,7 @@ icvFloatToString( char* buf, float value ) ...@@ -814,7 +814,7 @@ icvFloatToString( char* buf, float value )
sprintf( buf, "%d.", ivalue ); sprintf( buf, "%d.", ivalue );
else else
{ {
static const char* fmt = "%.8e"; static const char* fmt = "%.9g";
char* ptr = buf; char* ptr = buf;
sprintf( buf, fmt, value ); sprintf( buf, fmt, value );
if( *ptr == '+' || *ptr == '-' ) if( *ptr == '+' || *ptr == '-' )
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment