added gpu::printCudaDeviceInfo to all samples

This commit is contained in:
Vladislav Vinogradov
2012-01-30 07:20:09 +00:00
parent ed038ef9dc
commit d38ca09738
17 changed files with 213 additions and 1 deletions

View File

@@ -109,6 +109,8 @@ int main(int argc, const char *argv[])
return cerr << "No GPU found or the library is compiled without GPU support" << endl, -1;
}
cv::gpu::printShortCudaDeviceInfo(cv::gpu::getDevice());
string cascadeName;
string inputName;
bool isInputImage = false;

View File

@@ -154,6 +154,8 @@ int main(int argc, const char** argv)
ncvAssertPrintReturn(cv::gpu::getCudaEnabledDeviceCount() != 0, "No GPU found or the library is compiled without GPU support", -1);
ncvAssertPrintReturn(argc == 3, "Invalid number of arguments", -1);
cv::gpu::printShortCudaDeviceInfo(cv::gpu::getDevice());
string cascadeName = argv[1];
string inputName = argv[2];

View File

@@ -71,6 +71,8 @@ int main(int argc, char **argv)
for (int i = 0; i < num_devices; ++i)
{
cv::gpu::printShortCudaDeviceInfo(i);
DeviceInfo dev_info(i);
if (!dev_info.isCompatible())
{

View File

@@ -98,6 +98,8 @@ int main(int argc, char** argv)
for (int i = 0; i < num_devices; ++i)
{
cv::gpu::printShortCudaDeviceInfo(i);
DeviceInfo dev_info(i);
if (!dev_info.isCompatible())
{

View File

@@ -193,6 +193,8 @@ Args Args::read(int argc, char** argv)
App::App(const Args& s)
{
cv::gpu::printShortCudaDeviceInfo(cv::gpu::getDevice());
args = s;
cout << "\nControls:\n"
<< "\tESC - exit\n"

View File

@@ -74,6 +74,8 @@ int main( int argc, char** argv )
return -1;
}
cv::gpu::printShortCudaDeviceInfo(cv::gpu::getDevice());
help();

View File

@@ -46,6 +46,8 @@ int main()
}
for (int i = 0; i < num_devices; ++i)
{
cv::gpu::printShortCudaDeviceInfo(i);
DeviceInfo dev_info(i);
if (!dev_info.isCompatible())
{

View File

@@ -71,6 +71,8 @@ int main(int argc, const char* argv[])
return -1;
}
cv::gpu::printShortCudaDeviceInfo(cv::gpu::getDevice());
cout << "OpenCV / NVIDIA Computer Vision" << endl;
cout << "Optical Flow Demo: Frame Interpolation" << endl;
cout << "=========================================" << endl;

View File

@@ -393,6 +393,8 @@ int main(int argc, char **argv)
return result;
}
cv::gpu::printShortCudaDeviceInfo(cv::gpu::getDevice());
std::cout << "OpenCV / NVIDIA Computer Vision\n";
std::cout << "Optical Flow Demo: Frame Interpolation\n";
std::cout << "=========================================\n";

View File

@@ -5,6 +5,7 @@
using namespace std;
using namespace cv;
using namespace cv::gpu;
void TestSystem::run()
{
@@ -75,6 +76,7 @@ void TestSystem::finishCurrentSubtest()
void TestSystem::printHeading()
{
cout << endl;
cout << setiosflags(ios_base::left);
cout << TAB << setw(10) << "CPU, ms" << setw(10) << "GPU, ms"
<< setw(14) << "SPEEDUP"
@@ -145,13 +147,21 @@ int CV_CDECL cvErrorCallback(int /*status*/, const char* /*func_name*/,
int main(int argc, const char* argv[])
{
int num_devices = getCudaEnabledDeviceCount();
if (num_devices == 0)
{
cerr << "No GPU found or the library was compiled without GPU support";
return -1;
}
redirectError(cvErrorCallback);
const char* keys =
"{ h | help | false | print help message }"
"{ f | filter | | filter for test }"
"{ w | workdir | | set working directory }"
"{ l | list | false | show all tests }";
"{ l | list | false | show all tests }"
"{ d | device | 0 | device id }";
CommandLineParser cmd(argc, argv, keys);
@@ -162,6 +172,21 @@ int main(int argc, const char* argv[])
return 0;
}
int device = cmd.get<int>("device");
if (device < 0 || device >= num_devices)
{
cerr << "Invalid device ID" << endl;
return -1;
}
DeviceInfo dev_info(device);
if (!dev_info.isCompatible())
{
cerr << "GPU module isn't built for GPU #" << device << " " << dev_info.name() << ", CC " << dev_info.majorVersion() << '.' << dev_info.minorVersion() << endl;
return -1;
}
setDevice(device);
printShortCudaDeviceInfo(device);
string filter = cmd.get<string>("filter");
string workdir = cmd.get<string>("workdir");
bool list = cmd.get<bool>("list");

View File

@@ -6,6 +6,7 @@
#include <vector>
#include <string>
#include "opencv2/core/core.hpp"
#include "opencv2/gpu/gpu.hpp"
#define TAB " "

View File

@@ -139,6 +139,8 @@ Params Params::read(int argc, char** argv)
App::App(const Params& p)
: p(p), running(false)
{
cv::gpu::printShortCudaDeviceInfo(cv::gpu::getDevice());
cout << "stereo_match_gpu sample\n";
cout << "\nControls:\n"
<< "\tesc - exit\n"

View File

@@ -68,6 +68,8 @@ int main(int argc, char** argv)
}
for (int i = 0; i < num_devices; ++i)
{
cv::gpu::printShortCudaDeviceInfo(i);
DeviceInfo dev_info(i);
if (!dev_info.isCompatible())
{

View File

@@ -43,6 +43,8 @@ int main(int argc, char* argv[])
}
}
cv::gpu::printShortCudaDeviceInfo(cv::gpu::getDevice());
SURF_GPU surf;
// detecting keypoints & computing descriptors