1
0
mirror of https://github.com/opencv/opencv.git synced 2026-07-31 00:03:03 +04:00

implemented saturate_cast on gpu; updated GpuMat::convertTo implementation with saturate_cast; minor fix of convert_to test

This commit is contained in:
Vladislav Vinogradov
2010-07-27 07:05:39 +00:00
parent 4999024894
commit dc0f313924
3 changed files with 153 additions and 65 deletions
+31 -35
View File
@@ -32,51 +32,47 @@ void CV_GpuMatOpConvertTo::run( int /* start_from */)
const char* types_str[] = {"CV_8U", "CV_8S", "CV_16U", "CV_16S", "CV_32S", "CV_32F", "CV_64F"};
bool passed = true;
for (int i = 0; i < types_num && passed; ++i)
try
{
for (int j = 0; j < types_num && passed; ++j)
for (int i = 0; i < types_num && passed; ++i)
{
for (int c = 1; c < 2 && passed; ++c)
for (int j = 0; j < types_num && passed; ++j)
{
const int src_type = CV_MAKETYPE(types[i], c);
const int dst_type = types[j];
const double alpha = (double)rand() / RAND_MAX * 10.0;
const double beta = (double)rand() / RAND_MAX * 10.0;
cv::RNG rng(*ts->get_rng());
Mat cpumatsrc(img_size, src_type);
rng.fill(cpumatsrc, RNG::UNIFORM, Scalar::all(0), Scalar::all(10));
GpuMat gpumatsrc(cpumatsrc);
Mat cpumatdst;
GpuMat gpumatdst;
cpumatsrc.convertTo(cpumatdst, dst_type, alpha, beta);
try
for (int c = 1; c < 2 && passed; ++c)
{
const int src_type = CV_MAKETYPE(types[i], c);
const int dst_type = types[j];
const double alpha = (double)rand() / RAND_MAX * 2.0;
const double beta = (double)rand() / RAND_MAX * 150.0 - 75;
cv::RNG rng(*ts->get_rng());
Mat cpumatsrc(img_size, src_type);
rng.fill(cpumatsrc, RNG::UNIFORM, Scalar::all(0), Scalar::all(300));
GpuMat gpumatsrc(cpumatsrc);
Mat cpumatdst;
GpuMat gpumatdst;
cpumatsrc.convertTo(cpumatdst, dst_type, alpha, beta);
gpumatsrc.convertTo(gpumatdst, dst_type, alpha, beta);
}
catch(cv::Exception& e)
{
cout << "ERROR: " << e.err << endl;
passed = false;
break;
}
double r = norm(cpumatdst, gpumatdst, NORM_INF);
if (r > 1)
{
cout << "FAILED: " << "SRC_TYPE=" << types_str[i] << "C" << c << " DST_TYPE=" << types_str[j] << " NORM = " << r << endl;
double r = norm(cpumatdst, gpumatdst, NORM_INF);
if (r > 1)
{
cout << "FAILED: " << "SRC_TYPE=" << types_str[i] << "C" << c << " DST_TYPE=" << types_str[j] << " NORM = " << r << endl;
passed = false;
passed = false;
}
}
}
}
}
catch(cv::Exception& e)
{
cout << "ERROR: " << e.err << endl;
}
ts->set_failed_test_info(passed ? CvTS::OK : CvTS::FAIL_GENERIC);
}