Merge pull request #706 from taka-no-me:str_gpumat

This commit is contained in:
Andrey Kamaev 2013-03-26 14:36:09 +04:00 committed by OpenCV Buildbot
commit 0e58853be3

View File

@ -42,7 +42,7 @@
#include "precomp.hpp" #include "precomp.hpp"
#include "opencv2/core/gpumat.hpp" #include "opencv2/core/gpumat.hpp"
#include <iostream> #include <cctype>
#ifdef HAVE_CUDA #ifdef HAVE_CUDA
#include <cuda_runtime.h> #include <cuda_runtime.h>
@ -81,9 +81,8 @@ namespace
{ {
if (err < 0) if (err < 0)
{ {
std::ostringstream msg; String msg = cv::format("NPP API Call Error: %d", err);
msg << "NPP API Call Error: " << err; cv::gpu::error(msg.c_str(), file, line, func);
cv::gpu::error(msg.str().c_str(), file, line, func);
} }
} }
} }
@ -220,16 +219,25 @@ namespace
void CudaArch::fromStr(const String& set_as_str, std::vector<int>& arr) void CudaArch::fromStr(const String& set_as_str, std::vector<int>& arr)
{ {
if (set_as_str.find_first_not_of(" ") == String::npos) arr.clear();
return;
std::istringstream stream(set_as_str); size_t pos = 0;
int cur_value; while (pos < set_as_str.size())
while (!stream.eof())
{ {
stream >> cur_value; if (isspace(set_as_str[pos]))
arr.push_back(cur_value); {
++pos;
}
else
{
int cur_value;
int chars_read;
int args_read = sscanf(set_as_str.c_str() + pos, "%d%n", &cur_value, &chars_read);
CV_Assert(args_read == 2);
arr.push_back(cur_value);
pos += chars_read;
}
} }
std::sort(arr.begin(), arr.end()); std::sort(arr.begin(), arr.end());
@ -1570,8 +1578,8 @@ void cv::gpu::error(const char *error_string, const char *file, const int line,
const char* errorStr = cvErrorStr(code); const char* errorStr = cvErrorStr(code);
const char* function = func ? func : "unknown function"; const char* function = func ? func : "unknown function";
std::cerr << "OpenCV Error: " << errorStr << "(" << error_string << ") in " << function << ", file " << file << ", line " << line; fprintf(stderr, "OpenCV Error: %s(%s) in %s, file %s, line %d", errorStr, error_string, function, file, line);
std::cerr.flush(); fflush(stderr);
} }
else else
cv::error( cv::Exception(code, error_string, func, file, line) ); cv::error( cv::Exception(code, error_string, func, file, line) );