mirror of
https://github.com/opencv/opencv.git
synced 2024-11-30 22:40:17 +08:00
Merge pull request #26443 from mshabunin:cleanup-core-test
C-API cleanup: core module tests
This commit is contained in:
commit
a4ab68f9f4
@ -220,8 +220,6 @@ allocated using cvCreateData or set explicitly to user-allocated data via cvSetD
|
||||
*/
|
||||
CVAPI(CvMat*) cvCreateMatHeader( int rows, int cols, int type );
|
||||
|
||||
#define CV_AUTOSTEP 0x7fffffff
|
||||
|
||||
/** @brief Initializes a pre-allocated matrix header.
|
||||
|
||||
This function is often used to process raw data with OpenCV matrix functions. For example, the
|
||||
|
@ -521,6 +521,8 @@ Cv64suf;
|
||||
|
||||
#define CV_ELEM_SIZE(type) (CV_MAT_CN(type)*CV_ELEM_SIZE1(type))
|
||||
|
||||
#define CV_AUTOSTEP 0x7fffffff
|
||||
|
||||
#ifndef MIN
|
||||
# define MIN(a,b) ((a) > (b) ? (b) : (a))
|
||||
#endif
|
||||
|
@ -1,5 +1,4 @@
|
||||
#include "perf_precomp.hpp"
|
||||
#include "opencv2/core/core_c.h"
|
||||
|
||||
namespace opencv_test
|
||||
{
|
||||
|
@ -2,7 +2,6 @@
|
||||
// It is subject to the license terms in the LICENSE file found in the top-level directory
|
||||
// of this distribution and at http://opencv.org/license.html.
|
||||
#include "test_precomp.hpp"
|
||||
#include "opencv2/core/core_c.h" // needed for CV_AUTOSTEP
|
||||
|
||||
namespace opencv_test { namespace {
|
||||
|
||||
|
@ -3,8 +3,6 @@
|
||||
// of this distribution and at http://opencv.org/license.html.
|
||||
#include "test_precomp.hpp"
|
||||
#include "ref_reduce_arg.impl.hpp"
|
||||
#include "opencv2/core/core_c.h"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
namespace opencv_test { namespace {
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -2,7 +2,8 @@
|
||||
// It is subject to the license terms in the LICENSE file found in the top-level directory
|
||||
// of this distribution and at http://opencv.org/license.html.
|
||||
#include "test_precomp.hpp"
|
||||
#include "opencv2/core/core_c.h"
|
||||
|
||||
#define CV_TEST_DXT_MUL_CONJ 8 /**< conjugate the second argument of cvMulSpectrums */
|
||||
|
||||
namespace opencv_test { namespace {
|
||||
|
||||
@ -450,7 +451,7 @@ static void mulComplex( const Mat& src1, const Mat& src2, Mat& dst, int flags )
|
||||
const float* b = src2_->ptr<float>(i);
|
||||
float* c = dst.ptr<float>(i);
|
||||
|
||||
if( !(flags & CV_DXT_MUL_CONJ) )
|
||||
if( !(flags & CV_TEST_DXT_MUL_CONJ) )
|
||||
for( j = 0; j < cols; j += 2 )
|
||||
{
|
||||
double re = (double)a[j]*(double)b[j] - (double)a[j+1]*(double)b[j+1];
|
||||
@ -475,7 +476,7 @@ static void mulComplex( const Mat& src1, const Mat& src2, Mat& dst, int flags )
|
||||
const double* b = src2_->ptr<double>(i);
|
||||
double* c = dst.ptr<double>(i);
|
||||
|
||||
if( !(flags & CV_DXT_MUL_CONJ) )
|
||||
if( !(flags & CV_TEST_DXT_MUL_CONJ) )
|
||||
for( j = 0; j < cols; j += 2 )
|
||||
{
|
||||
double re = a[j]*b[j] - a[j+1]*b[j+1];
|
||||
@ -547,22 +548,22 @@ void CxCore_DXTBaseTest::get_test_array_types_and_sizes( int test_case_idx,
|
||||
Size size;
|
||||
Base::get_test_array_types_and_sizes( test_case_idx, sizes, types );
|
||||
|
||||
flags = bits & (CV_DXT_INVERSE | CV_DXT_SCALE | CV_DXT_ROWS | CV_DXT_MUL_CONJ);
|
||||
flags = bits & (cv::DFT_INVERSE | cv::DFT_SCALE | cv::DFT_ROWS | CV_TEST_DXT_MUL_CONJ);
|
||||
if( spectrum_mode )
|
||||
flags &= ~CV_DXT_INVERSE;
|
||||
flags &= ~cv::DFT_INVERSE;
|
||||
types[TEMP][0] = types[TEMP][1] = types[INPUT][0] =
|
||||
types[OUTPUT][0] = CV_MAKETYPE(depth, cn);
|
||||
size = sizes[INPUT][0];
|
||||
|
||||
temp_dst = false;
|
||||
|
||||
if( flags & CV_DXT_ROWS && (bits&1024) )
|
||||
if( flags & cv::DFT_ROWS && (bits&1024) )
|
||||
{
|
||||
if( bits&16 )
|
||||
size.width = 1;
|
||||
else
|
||||
size.height = 1;
|
||||
flags &= ~CV_DXT_ROWS;
|
||||
flags &= ~cv::DFT_ROWS;
|
||||
}
|
||||
|
||||
const int P2_MIN_SIZE = 32;
|
||||
@ -579,12 +580,12 @@ void CxCore_DXTBaseTest::get_test_array_types_and_sizes( int test_case_idx,
|
||||
if( size.width > 1 && (size.width&1) != 0 )
|
||||
size.width = (size.width + 1) & -2;
|
||||
|
||||
if( size.height > 1 && (size.height&1) != 0 && !(flags & CV_DXT_ROWS) )
|
||||
if( size.height > 1 && (size.height&1) != 0 && !(flags & cv::DFT_ROWS) )
|
||||
size.height = (size.height + 1) & -2;
|
||||
}
|
||||
|
||||
sizes[INPUT][0] = sizes[OUTPUT][0] = size;
|
||||
sizes[TEMP][0] = sizes[TEMP][1] = cvSize(0,0);
|
||||
sizes[TEMP][0] = sizes[TEMP][1] = cv::Size(0,0);
|
||||
|
||||
if( spectrum_mode )
|
||||
{
|
||||
@ -600,9 +601,9 @@ void CxCore_DXTBaseTest::get_test_array_types_and_sizes( int test_case_idx,
|
||||
{
|
||||
types[TEMP][0] = CV_MAKETYPE(depth, 2); // CV_??FC2
|
||||
sizes[TEMP][0] = size;
|
||||
size = cvSize(size.width/2+1, size.height);
|
||||
size = cv::Size(size.width/2+1, size.height);
|
||||
|
||||
if( flags & CV_DXT_INVERSE )
|
||||
if( flags & cv::DFT_INVERSE )
|
||||
{
|
||||
if( cn == 2 )
|
||||
{
|
||||
@ -692,10 +693,10 @@ void CxCore_DFTTest::run_func()
|
||||
Mat& dst = temp_dst ? test_mat[TEMP][1] : test_mat[OUTPUT][0];
|
||||
const Mat& src = inplace ? dst : test_mat[INPUT][0];
|
||||
|
||||
if(!(flags & CV_DXT_INVERSE))
|
||||
if(!(flags & cv::DFT_INVERSE))
|
||||
cv::dft( src, dst, flags );
|
||||
else
|
||||
cv::idft(src, dst, flags & ~CV_DXT_INVERSE);
|
||||
cv::idft(src, dst, flags & ~cv::DFT_INVERSE);
|
||||
}
|
||||
|
||||
|
||||
@ -712,7 +713,7 @@ void CxCore_DFTTest::prepare_to_validation( int /*test_case_idx*/ )
|
||||
{
|
||||
tmp_src = &test_mat[TEMP][0];
|
||||
|
||||
if( !(flags & CV_DXT_INVERSE ) )
|
||||
if( !(flags & cv::DFT_INVERSE ) )
|
||||
{
|
||||
Mat& cvdft_dst = test_mat[TEMP][1];
|
||||
convertFromCCS( cvdft_dst, cvdft_dst,
|
||||
@ -727,7 +728,7 @@ void CxCore_DFTTest::prepare_to_validation( int /*test_case_idx*/ )
|
||||
}
|
||||
}
|
||||
|
||||
if( src.rows == 1 || (src.cols == 1 && !(flags & CV_DXT_ROWS)) )
|
||||
if( src.rows == 1 || (src.cols == 1 && !(flags & cv::DFT_ROWS)) )
|
||||
DFT_1D( *tmp_src, *tmp_dst, flags );
|
||||
else
|
||||
DFT_2D( *tmp_src, *tmp_dst, flags );
|
||||
@ -757,10 +758,10 @@ void CxCore_DCTTest::run_func()
|
||||
Mat& dst = test_mat[OUTPUT][0];
|
||||
const Mat& src = inplace ? dst : test_mat[INPUT][0];
|
||||
|
||||
if(!(flags & CV_DXT_INVERSE))
|
||||
if(!(flags & cv::DFT_INVERSE))
|
||||
cv::dct( src, dst, flags );
|
||||
else
|
||||
cv::idct( src, dst, flags & ~CV_DXT_INVERSE);
|
||||
cv::idct( src, dst, flags & ~cv::DFT_INVERSE);
|
||||
}
|
||||
|
||||
|
||||
@ -769,7 +770,7 @@ void CxCore_DCTTest::prepare_to_validation( int /*test_case_idx*/ )
|
||||
const Mat& src = test_mat[INPUT][0];
|
||||
Mat& dst = test_mat[REF_OUTPUT][0];
|
||||
|
||||
if( src.rows == 1 || (src.cols == 1 && !(flags & CV_DXT_ROWS)) )
|
||||
if( src.rows == 1 || (src.cols == 1 && !(flags & cv::DFT_ROWS)) )
|
||||
DCT_1D( src, dst, flags );
|
||||
else
|
||||
DCT_2D( src, dst, flags );
|
||||
@ -820,7 +821,7 @@ void CxCore_MulSpectrumsTest::run_func()
|
||||
src1 = &dst;
|
||||
}
|
||||
|
||||
cv::mulSpectrums( *src1, *src2, dst, flags, (flags & CV_DXT_MUL_CONJ) != 0 );
|
||||
cv::mulSpectrums( *src1, *src2, dst, flags, (flags & CV_TEST_DXT_MUL_CONJ) != 0 );
|
||||
}
|
||||
|
||||
|
||||
|
@ -2,7 +2,6 @@
|
||||
// It is subject to the license terms in the LICENSE file found in the top-level directory
|
||||
// of this distribution and at http://opencv.org/license.html.
|
||||
#include "test_precomp.hpp"
|
||||
#include "opencv2/core/core_c.h"
|
||||
#include <fstream>
|
||||
|
||||
namespace opencv_test { namespace {
|
||||
@ -94,7 +93,6 @@ protected:
|
||||
RNG& rng = ts->get_rng();
|
||||
RNG rng0;
|
||||
int progress = 0;
|
||||
MemStorage storage(cvCreateMemStorage(0));
|
||||
const char * suffixs[3] = {".yml", ".xml", ".json" };
|
||||
test_case_count = 6;
|
||||
|
||||
@ -103,8 +101,6 @@ protected:
|
||||
ts->update_context( this, idx, false );
|
||||
progress = update_progress( progress, idx, test_case_count, 0 );
|
||||
|
||||
cvClearMemStorage(storage);
|
||||
|
||||
bool mem = (idx % test_case_count) >= (test_case_count >> 1);
|
||||
string filename = tempfile(suffixs[idx % (test_case_count >> 1)]);
|
||||
|
||||
@ -611,14 +607,14 @@ static void test_filestorage_basic(int write_flags, const char* suffix_name, boo
|
||||
{ /* init */
|
||||
|
||||
/* a normal mat */
|
||||
_2d_out = cv::Mat(10, 20, CV_8UC3, cvScalar(1U, 2U, 127U));
|
||||
_2d_out = cv::Mat(10, 20, CV_8UC3, cv::Scalar(1U, 2U, 127U));
|
||||
for (int i = 0; i < _2d_out.rows; ++i)
|
||||
for (int j = 0; j < _2d_out.cols; ++j)
|
||||
_2d_out.at<cv::Vec3b>(i, j)[1] = (i + j) % 256;
|
||||
|
||||
/* a 4d mat */
|
||||
const int Size[] = {4, 4, 4, 4};
|
||||
cv::Mat _4d(4, Size, CV_64FC4, cvScalar(0.888, 0.111, 0.666, 0.444));
|
||||
cv::Mat _4d(4, Size, CV_64FC4, cv::Scalar(0.888, 0.111, 0.666, 0.444));
|
||||
const cv::Range ranges[] = {
|
||||
cv::Range(0, 2),
|
||||
cv::Range(0, 2),
|
||||
|
@ -11,7 +11,6 @@
|
||||
|
||||
#include "opencv2/core/cuda.hpp"
|
||||
#include "opencv2/core/bindings_utils.hpp"
|
||||
#include "opencv2/core/core_c.h"
|
||||
|
||||
namespace opencv_test { namespace {
|
||||
|
||||
@ -305,9 +304,6 @@ void Core_ReduceTest::run( int )
|
||||
ts->set_failed_test_info( code );
|
||||
}
|
||||
|
||||
|
||||
#define CHECK_C
|
||||
|
||||
TEST(Core_PCA, accuracy)
|
||||
{
|
||||
const Size sz(200, 500);
|
||||
@ -343,11 +339,6 @@ TEST(Core_PCA, accuracy)
|
||||
Mat subEval( maxComponents, 1, eval.type(), eval.ptr() ),
|
||||
subEvec( maxComponents, evec.cols, evec.type(), evec.ptr() );
|
||||
|
||||
#ifdef CHECK_C
|
||||
Mat prjTestPoints, backPrjTestPoints, cPoints = rPoints.t(), cTestPoints = rTestPoints.t();
|
||||
CvMat _points, _testPoints, _avg, _eval, _evec, _prjTestPoints, _backPrjTestPoints;
|
||||
#endif
|
||||
|
||||
// check eigen()
|
||||
double eigenEps = 1e-4;
|
||||
double err;
|
||||
@ -436,45 +427,6 @@ TEST(Core_PCA, accuracy)
|
||||
err = cvtest::norm(cPCA.backProject(rvPrjTestPoints), rBackPrjTestPoints.t(), NORM_L2 | NORM_RELATIVE);
|
||||
ASSERT_LE(err, diffBackPrjEps) << "bad accuracy of backProject() (PCA::DATA_AS_COL); retainedVariance=" << retainedVariance;
|
||||
|
||||
#ifdef CHECK_C
|
||||
// 4. check C PCA & ROW
|
||||
_points = cvMat(rPoints);
|
||||
_testPoints = cvMat(rTestPoints);
|
||||
_avg = cvMat(avg);
|
||||
_eval = cvMat(eval);
|
||||
_evec = cvMat(evec);
|
||||
prjTestPoints.create(rTestPoints.rows, maxComponents, rTestPoints.type() );
|
||||
backPrjTestPoints.create(rPoints.size(), rPoints.type() );
|
||||
_prjTestPoints = cvMat(prjTestPoints);
|
||||
_backPrjTestPoints = cvMat(backPrjTestPoints);
|
||||
|
||||
cvCalcPCA( &_points, &_avg, &_eval, &_evec, PCA::DATA_AS_ROW );
|
||||
cvProjectPCA( &_testPoints, &_avg, &_evec, &_prjTestPoints );
|
||||
cvBackProjectPCA( &_prjTestPoints, &_avg, &_evec, &_backPrjTestPoints );
|
||||
|
||||
err = cvtest::norm(prjTestPoints, rPrjTestPoints, NORM_L2 | NORM_RELATIVE);
|
||||
ASSERT_LE(err, diffPrjEps) << "bad accuracy of cvProjectPCA() (PCA::DATA_AS_ROW)";
|
||||
err = cvtest::norm(backPrjTestPoints, rBackPrjTestPoints, NORM_L2 | NORM_RELATIVE);
|
||||
ASSERT_LE(err, diffBackPrjEps) << "bad accuracy of cvBackProjectPCA() (PCA::DATA_AS_ROW)";
|
||||
|
||||
// 5. check C PCA & COL
|
||||
_points = cvMat(cPoints);
|
||||
_testPoints = cvMat(cTestPoints);
|
||||
avg = avg.t(); _avg = cvMat(avg);
|
||||
eval = eval.t(); _eval = cvMat(eval);
|
||||
evec = evec.t(); _evec = cvMat(evec);
|
||||
prjTestPoints = prjTestPoints.t(); _prjTestPoints = cvMat(prjTestPoints);
|
||||
backPrjTestPoints = backPrjTestPoints.t(); _backPrjTestPoints = cvMat(backPrjTestPoints);
|
||||
|
||||
cvCalcPCA( &_points, &_avg, &_eval, &_evec, PCA::DATA_AS_COL );
|
||||
cvProjectPCA( &_testPoints, &_avg, &_evec, &_prjTestPoints );
|
||||
cvBackProjectPCA( &_prjTestPoints, &_avg, &_evec, &_backPrjTestPoints );
|
||||
|
||||
err = cvtest::norm(cv::abs(prjTestPoints), cv::abs(rPrjTestPoints.t()), NORM_L2 | NORM_RELATIVE);
|
||||
ASSERT_LE(err, diffPrjEps) << "bad accuracy of cvProjectPCA() (PCA::DATA_AS_COL)";
|
||||
err = cvtest::norm(backPrjTestPoints, rBackPrjTestPoints.t(), NORM_L2 | NORM_RELATIVE);
|
||||
ASSERT_LE(err, diffBackPrjEps) << "bad accuracy of cvBackProjectPCA() (PCA::DATA_AS_COL)";
|
||||
#endif
|
||||
// Test read and write
|
||||
const std::string filename = cv::tempfile("PCA_store.yml");
|
||||
FileStorage fs( filename, FileStorage::WRITE );
|
||||
@ -550,13 +502,6 @@ static double getValue(SparseMat& M, const int* idx, RNG& rng)
|
||||
return !ptr ? 0 : M.type() == CV_32F ? *(float*)ptr : M.type() == CV_64F ? *(double*)ptr : 0;
|
||||
}
|
||||
|
||||
static double getValue(const CvSparseMat* M, const int* idx)
|
||||
{
|
||||
int type = 0;
|
||||
const uchar* ptr = cvPtrND(M, idx, &type, 0);
|
||||
return !ptr ? 0 : type == CV_32F ? *(float*)ptr : type == CV_64F ? *(double*)ptr : 0;
|
||||
}
|
||||
|
||||
static void eraseValue(SparseMat& M, const int* idx, RNG& rng)
|
||||
{
|
||||
int d = M.dims();
|
||||
@ -576,11 +521,6 @@ static void eraseValue(SparseMat& M, const int* idx, RNG& rng)
|
||||
M.erase(idx, phv);
|
||||
}
|
||||
|
||||
static void eraseValue(CvSparseMat* M, const int* idx)
|
||||
{
|
||||
cvClearND(M, idx);
|
||||
}
|
||||
|
||||
static void setValue(SparseMat& M, const int* idx, double value, RNG& rng)
|
||||
{
|
||||
int d = M.dims();
|
||||
@ -646,39 +586,6 @@ void Core_ArrayOpTest::run( int /* start_from */)
|
||||
{
|
||||
int errcount = 0;
|
||||
|
||||
// dense matrix operations
|
||||
{
|
||||
int sz3[] = {5, 10, 15};
|
||||
MatND A(3, sz3, CV_32F), B(3, sz3, CV_16SC4);
|
||||
CvMatND matA = cvMatND(A), matB = cvMatND(B);
|
||||
RNG rng;
|
||||
rng.fill(A, RNG::UNIFORM, Scalar::all(-10), Scalar::all(10));
|
||||
rng.fill(B, RNG::UNIFORM, Scalar::all(-10), Scalar::all(10));
|
||||
|
||||
int idx0[] = {3,4,5}, idx1[] = {0, 9, 7};
|
||||
float val0 = 130;
|
||||
Scalar val1(-1000, 30, 3, 8);
|
||||
cvSetRealND(&matA, idx0, val0);
|
||||
cvSetReal3D(&matA, idx1[0], idx1[1], idx1[2], -val0);
|
||||
cvSetND(&matB, idx0, cvScalar(val1));
|
||||
cvSet3D(&matB, idx1[0], idx1[1], idx1[2], cvScalar(-val1));
|
||||
Ptr<CvMatND> matC(cvCloneMatND(&matB));
|
||||
|
||||
if( A.at<float>(idx0[0], idx0[1], idx0[2]) != val0 ||
|
||||
A.at<float>(idx1[0], idx1[1], idx1[2]) != -val0 ||
|
||||
cvGetReal3D(&matA, idx0[0], idx0[1], idx0[2]) != val0 ||
|
||||
cvGetRealND(&matA, idx1) != -val0 ||
|
||||
|
||||
Scalar(B.at<Vec4s>(idx0[0], idx0[1], idx0[2])) != val1 ||
|
||||
Scalar(B.at<Vec4s>(idx1[0], idx1[1], idx1[2])) != -val1 ||
|
||||
Scalar(cvGet3D(matC, idx0[0], idx0[1], idx0[2])) != val1 ||
|
||||
Scalar(cvGetND(matC, idx1)) != -val1 )
|
||||
{
|
||||
ts->printf(cvtest::TS::LOG, "one of cvSetReal3D, cvSetRealND, cvSet3D, cvSetND "
|
||||
"or the corresponding *Get* functions is not correct\n");
|
||||
errcount++;
|
||||
}
|
||||
}
|
||||
// test cv::Mat::forEach
|
||||
{
|
||||
const int dims[3] = { 101, 107, 7 };
|
||||
@ -856,7 +763,6 @@ void Core_ArrayOpTest::run( int /* start_from */)
|
||||
}
|
||||
}
|
||||
|
||||
Ptr<CvSparseMat> M2(cvCreateSparseMat(M));
|
||||
MatND Md;
|
||||
M.copyTo(Md);
|
||||
SparseMat M3; SparseMat(Md).convertTo(M3, Md.type(), 2);
|
||||
@ -890,7 +796,7 @@ void Core_ArrayOpTest::run( int /* start_from */)
|
||||
|
||||
for( i = 0; i < n; i++ )
|
||||
{
|
||||
double val1, val2, val3, val0;
|
||||
double val1, val3, val0;
|
||||
if(i < nz0)
|
||||
{
|
||||
sidx = all_idxs[i];
|
||||
@ -905,20 +811,19 @@ void Core_ArrayOpTest::run( int /* start_from */)
|
||||
val0 = M0[sidx];
|
||||
}
|
||||
val1 = getValue(M, idx, rng);
|
||||
val2 = getValue(M2, idx);
|
||||
val3 = getValue(M3, idx, rng);
|
||||
|
||||
if( val1 != val0 || val2 != val0 || fabs(val3 - val0*2) > fabs(val0*2)*FLT_EPSILON )
|
||||
if( val1 != val0 || fabs(val3 - val0*2) > fabs(val0*2)*FLT_EPSILON )
|
||||
{
|
||||
errcount++;
|
||||
ts->printf(cvtest::TS::LOG, "SparseMat M[%s] = %g/%g/%g (while it should be %g)\n", sidx.c_str(), val1, val2, val3, val0 );
|
||||
ts->printf(cvtest::TS::LOG, "SparseMat M[%s] = %g/%g (while it should be %g)\n", sidx.c_str(), val1, val3, val0 );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
for( i = 0; i < n; i++ )
|
||||
{
|
||||
double val1, val2;
|
||||
double val1;
|
||||
if(i < nz0)
|
||||
{
|
||||
sidx = all_idxs[i];
|
||||
@ -931,13 +836,11 @@ void Core_ArrayOpTest::run( int /* start_from */)
|
||||
sidx = idx2string(idx, dims);
|
||||
}
|
||||
eraseValue(M, idx, rng);
|
||||
eraseValue(M2, idx);
|
||||
val1 = getValue(M, idx, rng);
|
||||
val2 = getValue(M2, idx);
|
||||
if( val1 != 0 || val2 != 0 )
|
||||
if( val1 != 0 )
|
||||
{
|
||||
errcount++;
|
||||
ts->printf(cvtest::TS::LOG, "SparseMat: after deleting M[%s], it is =%g/%g (while it should be 0)\n", sidx.c_str(), val1, val2 );
|
||||
ts->printf(cvtest::TS::LOG, "SparseMat: after deleting M[%s], it is = %g (while it should be 0)\n", sidx.c_str(), val1 );
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -2493,21 +2396,6 @@ TEST(Mat1D, basic)
|
||||
EXPECT_NO_THROW(m1.convertTo(row2D, CV_32FC1));
|
||||
}
|
||||
|
||||
{
|
||||
SCOPED_TRACE("CvMat");
|
||||
CvMat c_mat = cvMat(m1);
|
||||
EXPECT_EQ(100, c_mat.cols);
|
||||
EXPECT_EQ(1, c_mat.rows);
|
||||
}
|
||||
|
||||
{
|
||||
SCOPED_TRACE("CvMatND");
|
||||
CvMatND c_mat = cvMatND(m1);
|
||||
EXPECT_EQ(2, c_mat.dims);
|
||||
EXPECT_EQ(1, c_mat.dim[0].size);
|
||||
EXPECT_EQ(100, c_mat.dim[1].size);
|
||||
}
|
||||
|
||||
{
|
||||
SCOPED_TRACE("minMaxLoc");
|
||||
Point pt;
|
||||
|
@ -10,7 +10,6 @@
|
||||
#include <float.h>
|
||||
#include <math.h>
|
||||
#include "opencv2/core/softfloat.hpp"
|
||||
#include "opencv2/core/core_c.h"
|
||||
#include "opencv2/core/hal/intrin.hpp"
|
||||
|
||||
namespace opencv_test { namespace {
|
||||
@ -604,24 +603,24 @@ void Core_GEMMTest::get_test_array_types_and_sizes( int test_case_idx, vector<ve
|
||||
|
||||
tabc_flag = cvtest::randInt(rng) & 7;
|
||||
|
||||
switch( tabc_flag & (CV_GEMM_A_T|CV_GEMM_B_T) )
|
||||
switch( tabc_flag & (cv::GEMM_1_T|cv::GEMM_2_T) )
|
||||
{
|
||||
case 0:
|
||||
sizes[INPUT][1].height = sizes[INPUT][0].width;
|
||||
sizes[OUTPUT][0].height = sizes[INPUT][0].height;
|
||||
sizes[OUTPUT][0].width = sizes[INPUT][1].width;
|
||||
break;
|
||||
case CV_GEMM_B_T:
|
||||
case cv::GEMM_2_T:
|
||||
sizes[INPUT][1].width = sizes[INPUT][0].width;
|
||||
sizes[OUTPUT][0].height = sizes[INPUT][0].height;
|
||||
sizes[OUTPUT][0].width = sizes[INPUT][1].height;
|
||||
break;
|
||||
case CV_GEMM_A_T:
|
||||
case cv::GEMM_1_T:
|
||||
sizes[INPUT][1].height = sizes[INPUT][0].height;
|
||||
sizes[OUTPUT][0].height = sizes[INPUT][0].width;
|
||||
sizes[OUTPUT][0].width = sizes[INPUT][1].width;
|
||||
break;
|
||||
case CV_GEMM_A_T | CV_GEMM_B_T:
|
||||
case cv::GEMM_1_T | cv::GEMM_2_T:
|
||||
sizes[INPUT][1].width = sizes[INPUT][0].height;
|
||||
sizes[OUTPUT][0].height = sizes[INPUT][0].width;
|
||||
sizes[OUTPUT][0].width = sizes[INPUT][1].height;
|
||||
@ -632,7 +631,7 @@ void Core_GEMMTest::get_test_array_types_and_sizes( int test_case_idx, vector<ve
|
||||
|
||||
if( cvtest::randInt(rng) & 1 )
|
||||
sizes[INPUT][4] = Size(0,0);
|
||||
else if( !(tabc_flag & CV_GEMM_C_T) )
|
||||
else if( !(tabc_flag & cv::GEMM_3_T) )
|
||||
sizes[INPUT][4] = sizes[OUTPUT][0];
|
||||
else
|
||||
{
|
||||
@ -742,8 +741,8 @@ void Core_MulTransposedTest::get_test_array_types_and_sizes( int test_case_idx,
|
||||
|
||||
void Core_MulTransposedTest::get_minmax_bounds( int /*i*/, int /*j*/, int /*type*/, Scalar& low, Scalar& high )
|
||||
{
|
||||
low = cvScalarAll(-10.);
|
||||
high = cvScalarAll(10.);
|
||||
low = cv::Scalar::all(-10.);
|
||||
high = cv::Scalar::all(10.);
|
||||
}
|
||||
|
||||
|
||||
@ -1126,7 +1125,7 @@ void Core_MahalanobisTest::prepare_to_validation( int )
|
||||
cvtest::gemm( test_mat[INPUT][2], test_mat[TEMP][0], 1.,
|
||||
Mat(), 0., test_mat[TEMP][1], 0 );
|
||||
|
||||
test_mat[REF_OUTPUT][0].at<Scalar>(0,0) = cvRealScalar(sqrt(cvtest::crossCorr(test_mat[TEMP][0], test_mat[TEMP][1])));
|
||||
test_mat[REF_OUTPUT][0].at<Scalar>(0,0) = cv::Scalar(sqrt(cvtest::crossCorr(test_mat[TEMP][0], test_mat[TEMP][1])));
|
||||
}
|
||||
|
||||
|
||||
@ -1186,8 +1185,8 @@ void Core_DetTest::get_test_array_types_and_sizes( int test_case_idx, vector<vec
|
||||
|
||||
void Core_DetTest::get_minmax_bounds( int /*i*/, int /*j*/, int /*type*/, Scalar& low, Scalar& high )
|
||||
{
|
||||
low = cvScalarAll(-2.);
|
||||
high = cvScalarAll(2.);
|
||||
low = cv::Scalar::all(-2.);
|
||||
high = cv::Scalar::all(2.);
|
||||
}
|
||||
|
||||
|
||||
@ -1214,21 +1213,17 @@ void Core_DetTest::run_func()
|
||||
|
||||
|
||||
// LU method that chooses the optimal in a column pivot element
|
||||
static double cvTsLU( CvMat* a, CvMat* b=NULL, CvMat* x=NULL, int* rank=0 )
|
||||
static double cvTsLU( cv::Mat a )
|
||||
{
|
||||
int i, j, k, N = a->rows, N1 = a->cols, Nm = MIN(N, N1), step = a->step/sizeof(double);
|
||||
int M = b ? b->cols : 0, b_step = b ? b->step/sizeof(double) : 0;
|
||||
int x_step = x ? x->step/sizeof(double) : 0;
|
||||
double *a0 = a->data.db, *b0 = b ? b->data.db : 0;
|
||||
double *x0 = x ? x->data.db : 0;
|
||||
CV_Assert(a.type() == CV_64FC1);
|
||||
int i, j, k, N = a.rows, N1 = a.cols, Nm = MIN(N, N1), step = (int)(a.step/sizeof(double));
|
||||
double *a0 = a.ptr<double>();
|
||||
double t, det = 1.;
|
||||
CV_Assert( CV_MAT_TYPE(a->type) == CV_64FC1 &&
|
||||
(!b || CV_ARE_TYPES_EQ(a,b)) && (!x || CV_ARE_TYPES_EQ(a,x)));
|
||||
|
||||
for( i = 0; i < Nm; i++ )
|
||||
{
|
||||
double max_val = fabs(a0[i*step + i]);
|
||||
double *a1, *a2, *b1 = 0, *b2 = 0;
|
||||
double *a1, *a2;
|
||||
k = i;
|
||||
|
||||
for( j = i+1; j < N; j++ )
|
||||
@ -1245,57 +1240,27 @@ static double cvTsLU( CvMat* a, CvMat* b=NULL, CvMat* x=NULL, int* rank=0 )
|
||||
{
|
||||
for( j = i; j < N1; j++ )
|
||||
CV_SWAP( a0[i*step + j], a0[k*step + j], t );
|
||||
|
||||
for( j = 0; j < M; j++ )
|
||||
CV_SWAP( b0[i*b_step + j], b0[k*b_step + j], t );
|
||||
det = -det;
|
||||
}
|
||||
|
||||
if( max_val == 0 )
|
||||
{
|
||||
if( rank )
|
||||
*rank = i;
|
||||
return 0.;
|
||||
}
|
||||
|
||||
a1 = a0 + i*step;
|
||||
a2 = a1 + step;
|
||||
b1 = b0 + i*b_step;
|
||||
b2 = b1 + b_step;
|
||||
|
||||
for( j = i+1; j < N; j++, a2 += step, b2 += b_step )
|
||||
for( j = i+1; j < N; j++, a2 += step )
|
||||
{
|
||||
t = a2[i]/a1[i];
|
||||
for( k = i+1; k < N1; k++ )
|
||||
a2[k] -= t*a1[k];
|
||||
|
||||
for( k = 0; k < M; k++ )
|
||||
b2[k] -= t*b1[k];
|
||||
}
|
||||
|
||||
det *= a1[i];
|
||||
}
|
||||
|
||||
if( x )
|
||||
{
|
||||
CV_Assert( b );
|
||||
|
||||
for( i = N-1; i >= 0; i-- )
|
||||
{
|
||||
double* a1 = a0 + i*step;
|
||||
double* b1 = b0 + i*b_step;
|
||||
for( j = 0; j < M; j++ )
|
||||
{
|
||||
t = b1[j];
|
||||
for( k = i+1; k < N1; k++ )
|
||||
t -= a1[k]*x0[k*x_step + j];
|
||||
x0[i*x_step + j] = t/a1[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if( rank )
|
||||
*rank = i;
|
||||
return det;
|
||||
}
|
||||
|
||||
@ -1303,8 +1268,7 @@ static double cvTsLU( CvMat* a, CvMat* b=NULL, CvMat* x=NULL, int* rank=0 )
|
||||
void Core_DetTest::prepare_to_validation( int )
|
||||
{
|
||||
test_mat[INPUT][0].convertTo(test_mat[TEMP][0], test_mat[TEMP][0].type());
|
||||
CvMat temp0 = cvMat(test_mat[TEMP][0]);
|
||||
test_mat[REF_OUTPUT][0].at<Scalar>(0,0) = cvRealScalar(cvTsLU(&temp0, 0, 0));
|
||||
test_mat[REF_OUTPUT][0].at<Scalar>(0,0) = cv::Scalar(cvTsLU(test_mat[TEMP][0]));
|
||||
}
|
||||
|
||||
|
||||
@ -1384,7 +1348,7 @@ int Core_InvertTest::prepare_test_case( int test_case_idx )
|
||||
if( method == cv::DECOMP_CHOLESKY )
|
||||
{
|
||||
cvtest::gemm( test_mat[INPUT][0], test_mat[INPUT][0], 1.,
|
||||
Mat(), 0., test_mat[TEMP][0], CV_GEMM_B_T );
|
||||
Mat(), 0., test_mat[TEMP][0], cv::GEMM_2_T );
|
||||
cvtest::copy( test_mat[TEMP][0], test_mat[INPUT][0] );
|
||||
}
|
||||
}
|
||||
@ -1396,8 +1360,8 @@ int Core_InvertTest::prepare_test_case( int test_case_idx )
|
||||
|
||||
void Core_InvertTest::get_minmax_bounds( int /*i*/, int /*j*/, int /*type*/, Scalar& low, Scalar& high )
|
||||
{
|
||||
low = cvScalarAll(-1.);
|
||||
high = cvScalarAll(1.);
|
||||
low = cv::Scalar::all(-1.);
|
||||
high = cv::Scalar::all(1.);
|
||||
}
|
||||
|
||||
void Core_InvertTest::run_func()
|
||||
@ -1493,9 +1457,9 @@ void Core_SolveTest::get_test_array_types_and_sizes( int test_case_idx, vector<v
|
||||
RNG& rng = cv::theRNG();
|
||||
int bits = cvtest::randInt(rng);
|
||||
Base::get_test_array_types_and_sizes( test_case_idx, sizes, types );
|
||||
CvSize in_sz = cvSize(sizes[INPUT][0]);
|
||||
cv::Size in_sz = cv::Size(sizes[INPUT][0]);
|
||||
if( in_sz.width > in_sz.height )
|
||||
in_sz = cvSize(in_sz.height, in_sz.width);
|
||||
in_sz = cv::Size(in_sz.height, in_sz.width);
|
||||
Base::get_test_array_types_and_sizes( test_case_idx, sizes, types );
|
||||
sizes[INPUT][0] = in_sz;
|
||||
int min_size = MIN( sizes[INPUT][0].width, sizes[INPUT][0].height );
|
||||
@ -1534,8 +1498,8 @@ int Core_SolveTest::prepare_test_case( int test_case_idx )
|
||||
|
||||
void Core_SolveTest::get_minmax_bounds( int /*i*/, int /*j*/, int /*type*/, Scalar& low, Scalar& high )
|
||||
{
|
||||
low = cvScalarAll(-1.);
|
||||
high = cvScalarAll(1.);
|
||||
low = cv::Scalar::all(-1.);
|
||||
high = cv::Scalar::all(1.);
|
||||
}
|
||||
|
||||
|
||||
@ -1564,8 +1528,7 @@ void Core_SolveTest::prepare_to_validation( int )
|
||||
Mat& temp1 = test_mat[TEMP][1];
|
||||
cvtest::convert(input, temp1, temp1.type());
|
||||
dst = Scalar::all(0);
|
||||
CvMat _temp1 = cvMat(temp1);
|
||||
double det = cvTsLU( &_temp1, 0, 0 );
|
||||
double det = cvTsLU( temp1 );
|
||||
dst0 = Scalar::all(det != 0);
|
||||
return;
|
||||
}
|
||||
@ -1584,7 +1547,7 @@ void Core_SolveTest::prepare_to_validation( int )
|
||||
|
||||
cvtest::gemm( input, test_mat[TEMP][0], 1., test_mat[INPUT][1], -1., *pdst, 0 );
|
||||
if( pdst != &dst )
|
||||
cvtest::gemm( input, *pdst, 1., Mat(), 0., dst, CV_GEMM_A_T );
|
||||
cvtest::gemm( input, *pdst, 1., Mat(), 0., dst, cv::GEMM_1_T );
|
||||
dst0 = Scalar::all(0);
|
||||
}
|
||||
|
||||
@ -1624,7 +1587,6 @@ Core_SolvePolyTest::~Core_SolvePolyTest() {}
|
||||
void Core_SolvePolyTest::run( int )
|
||||
{
|
||||
RNG& rng = cv::theRNG();
|
||||
int fig = 100;
|
||||
double range = 50;
|
||||
double err_eps = 1e-4;
|
||||
|
||||
@ -1673,10 +1635,8 @@ void Core_SolvePolyTest::run( int )
|
||||
for (int j = 0; j < n + 1; ++j)
|
||||
a[j] = c[j].real();
|
||||
|
||||
CvMat amat, umat;
|
||||
cvInitMatHeader(&amat, n + 1, 1, CV_64FC1, &a[0]);
|
||||
cvInitMatHeader(&umat, n, 1, CV_64FC2, &u[0]);
|
||||
cvSolvePoly(&amat, &umat, maxiter, fig);
|
||||
Mat amat(n + 1, 1, CV_64FC1, &a[0]), umat(n, 1, CV_64FC2, &u[0]);
|
||||
cv::solvePoly(amat, umat, maxiter);
|
||||
|
||||
for (int j = 0; j < n; ++j)
|
||||
ar[j] = complex_type(u[j * 2], u[j * 2 + 1]);
|
||||
@ -1689,13 +1649,13 @@ void Core_SolvePolyTest::run( int )
|
||||
{
|
||||
ar2.resize(n);
|
||||
cv::Mat _umat2(3, 1, CV_64F, &ar2[0]), umat2 = _umat2;
|
||||
cvFlip(&amat, &amat, 0);
|
||||
cv::flip(amat, amat, 0);
|
||||
int nr2;
|
||||
if( cubic_case == 0 )
|
||||
nr2 = cv::solveCubic(cv::cvarrToMat(&amat),umat2);
|
||||
nr2 = cv::solveCubic(amat,umat2);
|
||||
else
|
||||
nr2 = cv::solveCubic(cv::Mat_<float>(cv::cvarrToMat(&amat)), umat2);
|
||||
cvFlip(&amat, &amat, 0);
|
||||
nr2 = cv::solveCubic(cv::Mat_<float>(amat), umat2);
|
||||
cv::flip(amat, amat, 0);
|
||||
if(nr2 > 0)
|
||||
std::sort(ar2.begin(), ar2.begin()+nr2, pred_double());
|
||||
ar2.resize(nr2);
|
||||
@ -2317,7 +2277,7 @@ TEST(CovariationMatrixVectorOfMat, accuracy)
|
||||
{
|
||||
unsigned int col_problem_size = 8, row_problem_size = 8, vector_size = 16;
|
||||
cv::Mat src(vector_size, col_problem_size * row_problem_size, CV_32F);
|
||||
int singleMatFlags = CV_COVAR_ROWS;
|
||||
int singleMatFlags = cv::COVAR_ROWS;
|
||||
|
||||
cv::Mat gold;
|
||||
cv::Mat goldMean;
|
||||
@ -2348,7 +2308,7 @@ TEST(CovariationMatrixVectorOfMatWithMean, accuracy)
|
||||
{
|
||||
unsigned int col_problem_size = 8, row_problem_size = 8, vector_size = 16;
|
||||
cv::Mat src(vector_size, col_problem_size * row_problem_size, CV_32F);
|
||||
int singleMatFlags = CV_COVAR_ROWS | CV_COVAR_USE_AVG;
|
||||
int singleMatFlags = cv::COVAR_ROWS | cv::COVAR_USE_AVG;
|
||||
|
||||
cv::Mat gold;
|
||||
cv::randu(src,cv::Scalar(-128), cv::Scalar(128));
|
||||
@ -2448,7 +2408,7 @@ TEST(Core_Cholesky, accuracy64f)
|
||||
for (int i = 0; i < A.rows; i++)
|
||||
for (int j = i + 1; j < A.cols; j++)
|
||||
A.at<double>(i, j) = 0.0;
|
||||
EXPECT_LE(cvtest::norm(refA, A*A.t(), CV_RELATIVE_L2), FLT_EPSILON);
|
||||
EXPECT_LE(cvtest::norm(refA, A*A.t(), cv::NORM_L2 | cv::NORM_RELATIVE), FLT_EPSILON);
|
||||
}
|
||||
|
||||
TEST(Core_QR_Solver, accuracy64f)
|
||||
@ -2468,7 +2428,7 @@ TEST(Core_QR_Solver, accuracy64f)
|
||||
|
||||
//solve system with square matrix
|
||||
solve(A, B, solutionQR, DECOMP_QR);
|
||||
EXPECT_LE(cvtest::norm(A*solutionQR, B, CV_RELATIVE_L2), FLT_EPSILON);
|
||||
EXPECT_LE(cvtest::norm(A*solutionQR, B, cv::NORM_L2 | cv::NORM_RELATIVE), FLT_EPSILON);
|
||||
|
||||
A = Mat(m, n, CV_64F);
|
||||
B = Mat(m, n, CV_64F);
|
||||
@ -2477,13 +2437,13 @@ TEST(Core_QR_Solver, accuracy64f)
|
||||
|
||||
//solve normal system
|
||||
solve(A, B, solutionQR, DECOMP_QR | DECOMP_NORMAL);
|
||||
EXPECT_LE(cvtest::norm(A.t()*(A*solutionQR), A.t()*B, CV_RELATIVE_L2), FLT_EPSILON);
|
||||
EXPECT_LE(cvtest::norm(A.t()*(A*solutionQR), A.t()*B, cv::NORM_L2 | cv::NORM_RELATIVE), FLT_EPSILON);
|
||||
|
||||
//solve overdeterminated system as a least squares problem
|
||||
Mat solutionSVD;
|
||||
solve(A, B, solutionQR, DECOMP_QR);
|
||||
solve(A, B, solutionSVD, DECOMP_SVD);
|
||||
EXPECT_LE(cvtest::norm(solutionQR, solutionSVD, CV_RELATIVE_L2), FLT_EPSILON);
|
||||
EXPECT_LE(cvtest::norm(solutionQR, solutionSVD, cv::NORM_L2 | cv::NORM_RELATIVE), FLT_EPSILON);
|
||||
|
||||
//solve system with singular matrix
|
||||
A = Mat(10, 10, CV_64F);
|
||||
|
@ -41,7 +41,6 @@
|
||||
|
||||
#include "test_precomp.hpp"
|
||||
#include "opencv2/ts/ocl_test.hpp"
|
||||
#include "opencv2/core/core_c.h"
|
||||
|
||||
using namespace opencv_test;
|
||||
using namespace testing;
|
||||
|
@ -42,7 +42,7 @@
|
||||
|
||||
#include "test_precomp.hpp"
|
||||
|
||||
#define CV_DXT_MUL_CONJ 8
|
||||
#define CV_TEST_DXT_MUL_CONJ 8
|
||||
|
||||
namespace opencv_test { namespace {
|
||||
|
||||
@ -183,7 +183,7 @@ void CV_DivSpectrumsTest::get_test_array_types_and_sizes( int test_case_idx, vec
|
||||
|
||||
// Get the flag of the input.
|
||||
const int rand_int_flags = cvtest::randInt(rng);
|
||||
flags = rand_int_flags & (CV_DXT_MUL_CONJ | DFT_ROWS);
|
||||
flags = rand_int_flags & (CV_TEST_DXT_MUL_CONJ | DFT_ROWS);
|
||||
|
||||
// Get input type.
|
||||
const int rand_int_type = cvtest::randInt(rng);
|
||||
@ -354,7 +354,7 @@ static void div_complex_helper( const Mat& src1, const Mat& src2, Mat& dst, int
|
||||
std::pair<double, double> result =
|
||||
divide_complex_numbers( src1_data[j], src1_data[j + 1],
|
||||
src2_data[j], src2_data[j + 1],
|
||||
(flags & CV_DXT_MUL_CONJ) != 0 );
|
||||
(flags & CV_TEST_DXT_MUL_CONJ) != 0 );
|
||||
dst_data[j] = (depth_t)result.first;
|
||||
dst_data[j + 1] = (depth_t)result.second;
|
||||
}
|
||||
@ -411,7 +411,7 @@ void CV_DivSpectrumsTest::run_func()
|
||||
if ( cn == 1 )
|
||||
{
|
||||
Mat &dst = test_mat[TEMP][2];
|
||||
cv::divSpectrums( src1, src2, dst, flags, (flags & CV_DXT_MUL_CONJ) != 0 );
|
||||
cv::divSpectrums( src1, src2, dst, flags, (flags & CV_TEST_DXT_MUL_CONJ) != 0 );
|
||||
Mat &converted_dst = test_mat[OUTPUT][0];
|
||||
convert_from_ccs( dst, dst, converted_dst, flags );
|
||||
}
|
||||
@ -419,7 +419,7 @@ void CV_DivSpectrumsTest::run_func()
|
||||
else
|
||||
{
|
||||
Mat &dst = test_mat[OUTPUT][0];
|
||||
cv::divSpectrums( src1, src2, dst, flags, (flags & CV_DXT_MUL_CONJ) != 0 );
|
||||
cv::divSpectrums( src1, src2, dst, flags, (flags & CV_TEST_DXT_MUL_CONJ) != 0 );
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user