fixed canny test; fixed mhi-global test & implementation (hopefully, for the last time); added sse 4.1 & 4.2 support (not working in Xcode for some reason); moved splineInterpolation to color.cpp; fixed a few bugs in documentation
This commit is contained in:
parent
0e43976259
commit
d366c0b2fa
@ -261,13 +261,14 @@ if(CMAKE_COMPILER_IS_GNUCXX)
|
||||
|
||||
if(X86 OR X86_64)
|
||||
# enable everything, since the available set of instructions is checked at runtime
|
||||
set(USE_O3 ON CACHE BOOL "Enable -O3 for GCC")
|
||||
set(USE_FAST_MATH ON CACHE BOOL "Enable -ffast-math for GCC")
|
||||
set(ENABLE_SSE ON CACHE BOOL "Enable SSE for GCC")
|
||||
set(ENABLE_SSE2 ON CACHE BOOL "Enable SSE2 for GCC")
|
||||
set(ENABLE_SSE3 OFF CACHE BOOL "Enable SSE3 for GCC")
|
||||
set(ENABLE_SSSE3 OFF CACHE BOOL "Enable SSSE3 for GCC")
|
||||
#set(ENABLE_SSE4_1 OFF CACHE BOOL "Enable SSE4.1 for GCC")
|
||||
set(USE_O3 ON CACHE BOOL "Enable -O3")
|
||||
set(USE_FAST_MATH ON CACHE BOOL "Enable -ffast-math")
|
||||
set(ENABLE_SSE ON CACHE BOOL "Enable SSE instructions")
|
||||
set(ENABLE_SSE2 ON CACHE BOOL "Enable SSE2 instructions")
|
||||
set(ENABLE_SSE3 OFF CACHE BOOL "Enable SSE3 instructions")
|
||||
set(ENABLE_SSSE3 OFF CACHE BOOL "Enable SSSE3 instructions")
|
||||
set(ENABLE_SSE41 OFF CACHE BOOL "Enable SSE4.1 instructions")
|
||||
set(ENABLE_SSE42 OFF CACHE BOOL "Enable SSE4.2 instructions")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
@ -883,42 +884,52 @@ if(CMAKE_COMPILER_IS_GNUCXX)
|
||||
|
||||
# Other optimizations
|
||||
if(USE_OMIT_FRAME_POINTER)
|
||||
set(EXTRA_C_FLAGS_RELEASE "${EXTRA_C_FLAGS_RELEASE} -fomit-frame-pointer")
|
||||
set(EXTRA_C_FLAGS_RELEASE "${EXTRA_C_FLAGS_RELEASE} -fomit-frame-pointer")
|
||||
endif()
|
||||
if(USE_O2)
|
||||
set(EXTRA_C_FLAGS_RELEASE "${EXTRA_C_FLAGS_RELEASE} -O2")
|
||||
set(EXTRA_C_FLAGS_RELEASE "${EXTRA_C_FLAGS_RELEASE} -O2")
|
||||
endif()
|
||||
if(USE_O3)
|
||||
set(EXTRA_C_FLAGS_RELEASE "${EXTRA_C_FLAGS_RELEASE} -O3")
|
||||
set(EXTRA_C_FLAGS_RELEASE "${EXTRA_C_FLAGS_RELEASE} -O3")
|
||||
endif()
|
||||
if(USE_FAST_MATH)
|
||||
set(EXTRA_C_FLAGS_RELEASE "${EXTRA_C_FLAGS_RELEASE} -ffast-math")
|
||||
set(EXTRA_C_FLAGS_RELEASE "${EXTRA_C_FLAGS_RELEASE} -ffast-math")
|
||||
endif()
|
||||
if(ENABLE_POWERPC)
|
||||
set(EXTRA_C_FLAGS_RELEASE "${EXTRA_C_FLAGS_RELEASE} -mcpu=G3 -mtune=G5")
|
||||
set(EXTRA_C_FLAGS_RELEASE "${EXTRA_C_FLAGS_RELEASE} -mcpu=G3 -mtune=G5")
|
||||
endif()
|
||||
if(ENABLE_SSE)
|
||||
set(EXTRA_C_FLAGS_RELEASE "${EXTRA_C_FLAGS_RELEASE} -msse")
|
||||
set(EXTRA_C_FLAGS_RELEASE "${EXTRA_C_FLAGS_RELEASE} -msse")
|
||||
endif()
|
||||
if(ENABLE_SSE2)
|
||||
set(EXTRA_C_FLAGS_RELEASE "${EXTRA_C_FLAGS_RELEASE} -msse2")
|
||||
set(EXTRA_C_FLAGS_RELEASE "${EXTRA_C_FLAGS_RELEASE} -msse2")
|
||||
endif()
|
||||
# SSE3 and further should be disabled under MingW because it generates compiler errors
|
||||
if(NOT MINGW)
|
||||
if(ENABLE_SSE3)
|
||||
set(EXTRA_C_FLAGS_RELEASE "${EXTRA_C_FLAGS_RELEASE} -msse3")
|
||||
endif()
|
||||
if(${CMAKE_OPENCV_GCC_VERSION_NUM} GREATER 402)
|
||||
set(HAVE_GCC43_OR_NEWER 1)
|
||||
endif()
|
||||
if(HAVE_GCC43_OR_NEWER OR APPLE)
|
||||
if(ENABLE_SSSE3)
|
||||
set(EXTRA_C_FLAGS_RELEASE "${EXTRA_C_FLAGS_RELEASE} -mssse3")
|
||||
endif()
|
||||
#if(ENABLE_SSE4_1)
|
||||
# set(EXTRA_C_FLAGS_RELEASE "${EXTRA_C_FLAGS_RELEASE} -msse4.1")
|
||||
#endif()
|
||||
endif()
|
||||
if(ENABLE_SSE3)
|
||||
set(EXTRA_C_FLAGS_RELEASE "${EXTRA_C_FLAGS_RELEASE} -msse3")
|
||||
endif()
|
||||
|
||||
if(${CMAKE_OPENCV_GCC_VERSION_NUM} GREATER 402)
|
||||
set(HAVE_GCC43_OR_NEWER 1)
|
||||
endif()
|
||||
if(${CMAKE_OPENCV_GCC_VERSION_NUM} GREATER 401)
|
||||
set(HAVE_GCC42_OR_NEWER 1)
|
||||
endif()
|
||||
|
||||
if(HAVE_GCC43_OR_NEWER OR APPLE)
|
||||
if(ENABLE_SSSE3)
|
||||
set(EXTRA_C_FLAGS_RELEASE "${EXTRA_C_FLAGS_RELEASE} -mssse3")
|
||||
endif()
|
||||
if(HAVE_GCC42_OR_NEWER)
|
||||
if(ENABLE_SSE41)
|
||||
set(EXTRA_C_FLAGS_RELEASE "${EXTRA_C_FLAGS_RELEASE} -msse4.1")
|
||||
endif()
|
||||
if(ENABLE_SSE42)
|
||||
set(EXTRA_C_FLAGS_RELEASE "${EXTRA_C_FLAGS_RELEASE} -msse4.2")
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(X86 OR X86_64)
|
||||
|
@ -1732,7 +1732,8 @@ void undistortPoints( const Mat\& src, Mat\& dst,\par
|
||||
const Mat\& R=Mat(), const Mat\& P=Mat());}
|
||||
|
||||
\begin{description}
|
||||
\cvarg{src}{The observed point coordinates, same format as \texttt{imagePoints} in \cvCross{ProjectPoints2}{projectPoints}}
|
||||
|
||||
\cvarg{src}{The observed point coordinates, 1xN or Nx1 2-channel (CV\_32FC2 or CV\_64FC2).}
|
||||
\cvarg{dst}{The output ideal point coordinates, after undistortion and reverse perspective transformation\cvCPy{, same format as \texttt{src}}.}
|
||||
\cvarg{cameraMatrix}{The camera matrix $\vecthreethree{f_x}{0}{c_x}{0}{f_y}{c_y}{0}{0}{1}$}
|
||||
\cvarg{distCoeffs}{The vector of distortion coefficients, $(k_1^{(j)}, k_2^{(j)}, p_1^{(j)}, p_2^{(j)}[, k_3^{(j)}])$}
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -3206,41 +3206,7 @@ partition( const vector<_Tp>& _vec, vector<int>& labels,
|
||||
return nclasses;
|
||||
}
|
||||
|
||||
// computes cubic spline coefficients for a function: (xi=i, yi=f[i]), i=0..n
|
||||
template<typename _Tp> static void splineBuild(const _Tp* f, int n, _Tp* tab)
|
||||
{
|
||||
_Tp cn = 0;
|
||||
int i;
|
||||
tab[0] = tab[1] = (_Tp)0;
|
||||
|
||||
for(i = 1; i < n-1; i++)
|
||||
{
|
||||
_Tp t = 3*(f[i+1] - 2*f[i] + f[i-1]);
|
||||
_Tp l = 1/(4 - tab[(i-1)*4]);
|
||||
tab[i*4] = l; tab[i*4+1] = (t - tab[(i-1)*4+1])*l;
|
||||
}
|
||||
|
||||
for(i = n-1; i >= 0; i--)
|
||||
{
|
||||
_Tp c = tab[i*4+1] - tab[i*4]*cn;
|
||||
_Tp b = f[i+1] - f[i] - (cn + c*2)*(_Tp)0.3333333333333333;
|
||||
_Tp d = (cn - c)*(_Tp)0.3333333333333333;
|
||||
tab[i*4] = f[i]; tab[i*4+1] = b;
|
||||
tab[i*4+2] = c; tab[i*4+3] = d;
|
||||
cn = c;
|
||||
}
|
||||
}
|
||||
|
||||
// interpolates value of a function at x, 0 <= x <= n using a cubic spline.
|
||||
template<typename _Tp> static inline _Tp splineInterpolate(_Tp x, const _Tp* tab, int n)
|
||||
{
|
||||
int ix = cvFloor(x);
|
||||
ix = std::min(std::max(ix, 0), n-1);
|
||||
x -= ix;
|
||||
tab += ix*4;
|
||||
return ((tab[3]*x + tab[2])*x + tab[1])*x + tab[0];
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// bridge C++ => C Seq API
|
||||
|
@ -94,6 +94,42 @@
|
||||
|
||||
namespace cv
|
||||
{
|
||||
|
||||
// computes cubic spline coefficients for a function: (xi=i, yi=f[i]), i=0..n
|
||||
template<typename _Tp> static void splineBuild(const _Tp* f, int n, _Tp* tab)
|
||||
{
|
||||
_Tp cn = 0;
|
||||
int i;
|
||||
tab[0] = tab[1] = (_Tp)0;
|
||||
|
||||
for(i = 1; i < n-1; i++)
|
||||
{
|
||||
_Tp t = 3*(f[i+1] - 2*f[i] + f[i-1]);
|
||||
_Tp l = 1/(4 - tab[(i-1)*4]);
|
||||
tab[i*4] = l; tab[i*4+1] = (t - tab[(i-1)*4+1])*l;
|
||||
}
|
||||
|
||||
for(i = n-1; i >= 0; i--)
|
||||
{
|
||||
_Tp c = tab[i*4+1] - tab[i*4]*cn;
|
||||
_Tp b = f[i+1] - f[i] - (cn + c*2)*(_Tp)0.3333333333333333;
|
||||
_Tp d = (cn - c)*(_Tp)0.3333333333333333;
|
||||
tab[i*4] = f[i]; tab[i*4+1] = b;
|
||||
tab[i*4+2] = c; tab[i*4+3] = d;
|
||||
cn = c;
|
||||
}
|
||||
}
|
||||
|
||||
// interpolates value of a function at x, 0 <= x <= n using a cubic spline.
|
||||
template<typename _Tp> static inline _Tp splineInterpolate(_Tp x, const _Tp* tab, int n)
|
||||
{
|
||||
int ix = cvFloor(x);
|
||||
ix = std::min(std::max(ix, 0), n-1);
|
||||
x -= ix;
|
||||
tab += ix*4;
|
||||
return ((tab[3]*x + tab[2])*x + tab[1])*x + tab[0];
|
||||
}
|
||||
|
||||
|
||||
template<typename _Tp> struct ColorChannel
|
||||
{
|
||||
|
@ -242,8 +242,8 @@ cvCalcGlobalOrientation( const void* orientation, const void* maskimg, const voi
|
||||
float _ranges[] = { 0, 360 };
|
||||
float* ranges = _ranges;
|
||||
int base_orient;
|
||||
double shift_orient = 0, shift_weight = 0, fbase_orient;
|
||||
double a, b;
|
||||
float shift_orient = 0, shift_weight = 0;
|
||||
float a, b, fbase_orient;
|
||||
float delbound;
|
||||
CvMat mhi_row, mask_row, orient_row;
|
||||
int x, y, mhi_rows, mhi_cols;
|
||||
@ -271,15 +271,14 @@ cvCalcGlobalOrientation( const void* orientation, const void* maskimg, const voi
|
||||
|
||||
// find the maximum index (the dominant orientation)
|
||||
cvGetMinMaxHistValue( hist, 0, 0, 0, &base_orient );
|
||||
base_orient = cvRound(base_orient*360./hist_size);
|
||||
fbase_orient = base_orient*360.f/hist_size;
|
||||
|
||||
// override timestamp with the maximum value in MHI
|
||||
cvMinMaxLoc( mhi, 0, &curr_mhi_timestamp, 0, 0, mask );
|
||||
|
||||
// find the shift relative to the dominant orientation as weighted sum of relative angles
|
||||
a = 254. / 255. / mhi_duration;
|
||||
b = 1. - curr_mhi_timestamp * a;
|
||||
fbase_orient = base_orient;
|
||||
a = (float)(254. / 255. / mhi_duration);
|
||||
b = (float)(1. - curr_mhi_timestamp * a);
|
||||
delbound = (float)(curr_mhi_timestamp - mhi_duration);
|
||||
mhi_rows = mhi->rows;
|
||||
mhi_cols = mhi->cols;
|
||||
@ -319,13 +318,13 @@ cvCalcGlobalOrientation( const void* orientation, const void* maskimg, const voi
|
||||
-> (rel_angle = orient - base_orient) in -360..360.
|
||||
rel_angle is translated to -180..180
|
||||
*/
|
||||
double weight = mhi_row.data.fl[x] * a + b;
|
||||
int rel_angle = cvRound( orient_row.data.fl[x] - fbase_orient );
|
||||
float weight = mhi_row.data.fl[x] * a + b;
|
||||
float rel_angle = orient_row.data.fl[x] - fbase_orient;
|
||||
|
||||
rel_angle += (rel_angle < -180 ? 360 : 0);
|
||||
rel_angle += (rel_angle > 180 ? -360 : 0);
|
||||
|
||||
if( abs(rel_angle) < 45 )
|
||||
if( fabs(rel_angle) < 45 )
|
||||
{
|
||||
shift_orient += weight * rel_angle;
|
||||
shift_weight += weight;
|
||||
@ -337,11 +336,11 @@ cvCalcGlobalOrientation( const void* orientation, const void* maskimg, const voi
|
||||
if( shift_weight == 0 )
|
||||
shift_weight = 0.01;
|
||||
|
||||
base_orient = base_orient + cvRound( shift_orient / shift_weight );
|
||||
base_orient -= (base_orient < 360 ? 0 : 360);
|
||||
base_orient += (base_orient >= 0 ? 0 : 360);
|
||||
fbase_orient += shift_orient / shift_weight;
|
||||
fbase_orient -= (fbase_orient < 360 ? 0 : 360);
|
||||
fbase_orient += (fbase_orient >= 0 ? 0 : 360);
|
||||
|
||||
return base_orient;
|
||||
return fbase_orient;
|
||||
}
|
||||
|
||||
|
||||
|
@ -52,6 +52,7 @@ protected:
|
||||
int prepare_test_case( int test_case_idx );
|
||||
void run_func();
|
||||
void prepare_to_validation( int );
|
||||
int validate_test_results( int /*test_case_idx*/ );
|
||||
|
||||
int aperture_size, use_true_gradient;
|
||||
double threshold1, threshold2;
|
||||
@ -271,8 +272,51 @@ void CV_CannyTest::prepare_to_validation( int )
|
||||
{
|
||||
icvTsCanny( &test_mat[INPUT][0], &test_mat[REF_OUTPUT][0],
|
||||
threshold1, threshold2, aperture_size, use_true_gradient );
|
||||
|
||||
/*cv::Mat output(&test_mat[OUTPUT][0]);
|
||||
cv::Mat ref_output(&test_mat[REF_OUTPUT][0]);
|
||||
|
||||
cv::absdiff(output, ref_output, output);
|
||||
cv::namedWindow("ref test", 0);
|
||||
cv::imshow("ref test", ref_output);
|
||||
cv::namedWindow("test", 0);
|
||||
cv::imshow("test", output);
|
||||
cv::waitKey();*/
|
||||
}
|
||||
|
||||
|
||||
int CV_CannyTest::validate_test_results( int test_case_idx )
|
||||
{
|
||||
int code = CvTS::OK, nz0;
|
||||
prepare_to_validation(test_case_idx);
|
||||
|
||||
double err = cvNorm(&test_mat[OUTPUT][0], &test_mat[REF_OUTPUT][0], CV_L1);
|
||||
if( err == 0 )
|
||||
goto _exit_;
|
||||
|
||||
if( err != cvRound(err) || cvRound(err)%255 != 0 )
|
||||
{
|
||||
ts->printf( CvTS::LOG, "Some of the pixels, produced by Canny, are not 0's or 255's; the difference is %g\n", err );
|
||||
code = CvTS::FAIL_INVALID_OUTPUT;
|
||||
goto _exit_;
|
||||
}
|
||||
|
||||
nz0 = cvCountNonZero(&test_mat[REF_OUTPUT][0]);
|
||||
err = (err/255/MAX(nz0,100))*100;
|
||||
if( err > 1 )
|
||||
{
|
||||
ts->printf( CvTS::LOG, "Too high percentage of non-matching edge pixels = %g%%\n", err);
|
||||
code = CvTS::FAIL_BAD_ACCURACY;
|
||||
goto _exit_;
|
||||
}
|
||||
|
||||
_exit_:
|
||||
if( code < 0 )
|
||||
ts->set_failed_test_info( code );
|
||||
return code;
|
||||
}
|
||||
|
||||
|
||||
CV_CannyTest canny_test;
|
||||
|
||||
/* End of file. */
|
||||
|
@ -484,11 +484,10 @@ cvTsCalcGlobalOrientation( const CvMat* orient, const CvMat* mask, const CvMat*
|
||||
|
||||
for( x = 0; x < orient->cols; x++ )
|
||||
{
|
||||
if( mask_data[x] )
|
||||
if( mask_data[x] && mhi_data[x] > low_time )
|
||||
{
|
||||
double diff = orient_data[x] - base_orientation;
|
||||
double delta_weight = mhi_data[x] >= low_time ?
|
||||
(((mhi_data[x] - low_time)/duration)*254 + 1)/255 : 0;
|
||||
double delta_weight = (((mhi_data[x] - low_time)/duration)*254 + 1)/255;
|
||||
|
||||
if( diff < -180 ) diff += 360;
|
||||
if( diff > 180 ) diff -= 360;
|
||||
@ -506,7 +505,7 @@ cvTsCalcGlobalOrientation( const CvMat* orient, const CvMat* mask, const CvMat*
|
||||
global_orientation = base_orientation;
|
||||
else
|
||||
{
|
||||
global_orientation = base_orientation + cvRound(delta_orientation/weight);
|
||||
global_orientation = base_orientation + delta_orientation/weight;
|
||||
if( global_orientation < 0 ) global_orientation += 360;
|
||||
if( global_orientation > 360 ) global_orientation -= 360;
|
||||
}
|
||||
@ -594,7 +593,7 @@ void CV_MHIGlobalOrientTest::get_minmax_bounds( int i, int j, int type, CvScalar
|
||||
|
||||
double CV_MHIGlobalOrientTest::get_success_error_level( int /*test_case_idx*/, int /*i*/, int /*j*/ )
|
||||
{
|
||||
return 30;
|
||||
return 15;
|
||||
}
|
||||
|
||||
|
||||
|
@ -48,8 +48,8 @@ const char* blacklist[] =
|
||||
"calibrate-camera-artificial", //ticket 472
|
||||
"inpaint", //ticket 570
|
||||
"warp-resize", //ticket 429
|
||||
"mhi-global", //ticket 457
|
||||
"canny", //ticket 702
|
||||
//"mhi-global", //ticket 457
|
||||
//"canny", //ticket 702
|
||||
0
|
||||
};
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user