updated gpu accuracy tests
added posibility to specify device on which tests will be executed
This commit is contained in:
@@ -46,6 +46,7 @@ using namespace cv;
|
||||
using namespace cv::gpu;
|
||||
using namespace cvtest;
|
||||
using namespace testing;
|
||||
using namespace testing::internal;
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// random generators
|
||||
@@ -108,12 +109,12 @@ GpuMat loadMat(const Mat& m, bool useRoi)
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Image load
|
||||
|
||||
Mat readImage(const string& fileName, int flags)
|
||||
Mat readImage(const std::string& fileName, int flags)
|
||||
{
|
||||
return imread(string(cvtest::TS::ptr()->get_data_path()) + fileName, flags);
|
||||
return imread(TS::ptr()->get_data_path() + fileName, flags);
|
||||
}
|
||||
|
||||
Mat readImageType(const string& fname, int type)
|
||||
Mat readImageType(const std::string& fname, int type)
|
||||
{
|
||||
Mat src = readImage(fname, CV_MAT_CN(type) == 1 ? IMREAD_GRAYSCALE : IMREAD_COLOR);
|
||||
if (CV_MAT_CN(type) == 4)
|
||||
@@ -134,50 +135,150 @@ bool supportFeature(const DeviceInfo& info, FeatureSet feature)
|
||||
return TargetArchs::builtWith(feature) && info.supports(feature);
|
||||
}
|
||||
|
||||
const vector<DeviceInfo>& devices()
|
||||
DeviceManager& DeviceManager::instance()
|
||||
{
|
||||
static vector<DeviceInfo> devs;
|
||||
static bool first = true;
|
||||
|
||||
if (first)
|
||||
{
|
||||
int deviceCount = getCudaEnabledDeviceCount();
|
||||
|
||||
devs.reserve(deviceCount);
|
||||
|
||||
for (int i = 0; i < deviceCount; ++i)
|
||||
{
|
||||
DeviceInfo info(i);
|
||||
if (info.isCompatible())
|
||||
devs.push_back(info);
|
||||
}
|
||||
|
||||
first = false;
|
||||
}
|
||||
|
||||
return devs;
|
||||
static DeviceManager obj;
|
||||
return obj;
|
||||
}
|
||||
|
||||
vector<DeviceInfo> devices(FeatureSet feature)
|
||||
void DeviceManager::load(int i)
|
||||
{
|
||||
const vector<DeviceInfo>& d = devices();
|
||||
devices_.clear();
|
||||
devices_.reserve(1);
|
||||
|
||||
vector<DeviceInfo> devs_filtered;
|
||||
ostringstream msg;
|
||||
|
||||
if (TargetArchs::builtWith(feature))
|
||||
if (i < 0 || i >= getCudaEnabledDeviceCount())
|
||||
{
|
||||
devs_filtered.reserve(d.size());
|
||||
|
||||
for (size_t i = 0, size = d.size(); i < size; ++i)
|
||||
{
|
||||
const DeviceInfo& info = d[i];
|
||||
|
||||
if (info.supports(feature))
|
||||
devs_filtered.push_back(info);
|
||||
}
|
||||
msg << "Incorrect device number - " << i;
|
||||
throw runtime_error(msg.str());
|
||||
}
|
||||
|
||||
return devs_filtered;
|
||||
DeviceInfo info(i);
|
||||
|
||||
if (!info.isCompatible())
|
||||
{
|
||||
msg << "Device " << i << " [" << info.name() << "] is NOT compatible with current GPU module build";
|
||||
throw runtime_error(msg.str());
|
||||
}
|
||||
|
||||
devices_.push_back(info);
|
||||
}
|
||||
|
||||
void DeviceManager::loadAll()
|
||||
{
|
||||
int deviceCount = getCudaEnabledDeviceCount();
|
||||
|
||||
devices_.clear();
|
||||
devices_.reserve(deviceCount);
|
||||
|
||||
for (int i = 0; i < deviceCount; ++i)
|
||||
{
|
||||
DeviceInfo info(i);
|
||||
if (info.isCompatible())
|
||||
{
|
||||
devices_.push_back(info);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class DevicesGenerator : public ParamGeneratorInterface<DeviceInfo>
|
||||
{
|
||||
public:
|
||||
~DevicesGenerator();
|
||||
|
||||
ParamIteratorInterface<DeviceInfo>* Begin() const;
|
||||
ParamIteratorInterface<DeviceInfo>* End() const;
|
||||
|
||||
private:
|
||||
class Iterator : public ParamIteratorInterface<DeviceInfo>
|
||||
{
|
||||
public:
|
||||
Iterator(const ParamGeneratorInterface<DeviceInfo>* base, vector<DeviceInfo>::const_iterator iterator);
|
||||
|
||||
virtual ~Iterator();
|
||||
|
||||
virtual const ParamGeneratorInterface<DeviceInfo>* BaseGenerator() const;
|
||||
|
||||
virtual void Advance();
|
||||
|
||||
virtual ParamIteratorInterface<DeviceInfo>* Clone() const;
|
||||
|
||||
virtual const DeviceInfo* Current() const;
|
||||
|
||||
virtual bool Equals(const ParamIteratorInterface<DeviceInfo>& other) const;
|
||||
|
||||
private:
|
||||
Iterator(const Iterator& other);
|
||||
|
||||
const ParamGeneratorInterface<DeviceInfo>* const base_;
|
||||
vector<DeviceInfo>::const_iterator iterator_;
|
||||
|
||||
mutable DeviceInfo value_;
|
||||
};
|
||||
};
|
||||
|
||||
DevicesGenerator::~DevicesGenerator()
|
||||
{
|
||||
}
|
||||
|
||||
ParamIteratorInterface<DeviceInfo>* DevicesGenerator::Begin() const
|
||||
{
|
||||
return new Iterator(this, DeviceManager::instance().values().begin());
|
||||
}
|
||||
|
||||
ParamIteratorInterface<DeviceInfo>* DevicesGenerator::End() const
|
||||
{
|
||||
return new Iterator(this, DeviceManager::instance().values().end());
|
||||
}
|
||||
|
||||
DevicesGenerator::Iterator::Iterator(const ParamGeneratorInterface<DeviceInfo>* base, vector<DeviceInfo>::const_iterator iterator)
|
||||
: base_(base), iterator_(iterator)
|
||||
{
|
||||
}
|
||||
|
||||
DevicesGenerator::Iterator::~Iterator()
|
||||
{
|
||||
}
|
||||
|
||||
const ParamGeneratorInterface<DeviceInfo>* DevicesGenerator::Iterator::BaseGenerator() const
|
||||
{
|
||||
return base_;
|
||||
}
|
||||
|
||||
void DevicesGenerator::Iterator::Advance()
|
||||
{
|
||||
++iterator_;
|
||||
}
|
||||
|
||||
ParamIteratorInterface<DeviceInfo>* DevicesGenerator::Iterator::Clone() const
|
||||
{
|
||||
return new Iterator(*this);
|
||||
}
|
||||
|
||||
const DeviceInfo* DevicesGenerator::Iterator::Current() const
|
||||
{
|
||||
value_ = *iterator_;
|
||||
return &value_;
|
||||
}
|
||||
|
||||
bool DevicesGenerator::Iterator::Equals(const ParamIteratorInterface<DeviceInfo>& other) const
|
||||
{
|
||||
GTEST_CHECK_(BaseGenerator() == other.BaseGenerator())
|
||||
<< "The program attempted to compare iterators "
|
||||
<< "from different generators." << endl;
|
||||
|
||||
return iterator_ == CheckedDowncastToActualType<const Iterator>(&other)->iterator_;
|
||||
}
|
||||
|
||||
DevicesGenerator::Iterator::Iterator(const Iterator& other) :
|
||||
ParamIteratorInterface<DeviceInfo>(), base_(other.base_), iterator_(other.iterator_)
|
||||
{
|
||||
}
|
||||
|
||||
ParamGenerator<DeviceInfo> DevicesGenerator_()
|
||||
{
|
||||
return ParamGenerator<DeviceInfo>(new DevicesGenerator);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
@@ -250,7 +351,7 @@ void minMaxLocGold(const Mat& src, double* minVal_, double* maxVal_, Point* minL
|
||||
|
||||
namespace
|
||||
{
|
||||
template <typename T, typename OutT> string printMatValImpl(const Mat& m, Point p)
|
||||
template <typename T, typename OutT> std::string printMatValImpl(const Mat& m, Point p)
|
||||
{
|
||||
const int cn = m.channels();
|
||||
|
||||
@@ -269,9 +370,9 @@ namespace
|
||||
return ostr.str();
|
||||
}
|
||||
|
||||
string printMatVal(const Mat& m, Point p)
|
||||
std::string printMatVal(const Mat& m, Point p)
|
||||
{
|
||||
typedef string (*func_t)(const Mat& m, Point p);
|
||||
typedef std::string (*func_t)(const Mat& m, Point p);
|
||||
|
||||
static const func_t funcs[] =
|
||||
{
|
||||
|
Reference in New Issue
Block a user