core: fix printf warnings by using c++11 format

pull/12599/head
Pavel Rojtberg 6 years ago committed by Maksim Shabunin
parent 4d23a5d92d
commit d1c842cf29
  1. 10
      modules/core/src/channels.cpp
  2. 6
      modules/core/src/lda.cpp
  3. 2
      modules/core/src/matrix_operations.cpp
  4. 6
      modules/core/src/ocl.cpp
  5. 8
      modules/core/test/test_io.cpp
  6. 2
      modules/imgproc/src/featureselect.cpp
  7. 4
      modules/imgproc/src/histogram.cpp
  8. 10
      modules/objdetect/src/hog.cpp
  9. 2
      modules/videoio/src/container_avi.cpp

@ -237,11 +237,11 @@ static bool ocl_mixChannels(InputArrayOfArrays _src, InputOutputArrayOfArrays _d
dstargs[i] = dst[dst_idx]; dstargs[i] = dst[dst_idx];
dstargs[i].offset += dst_cnidx * esz; dstargs[i].offset += dst_cnidx * esz;
declsrc += format("DECLARE_INPUT_MAT(%d)", i); declsrc += format("DECLARE_INPUT_MAT(%zu)", i);
decldst += format("DECLARE_OUTPUT_MAT(%d)", i); decldst += format("DECLARE_OUTPUT_MAT(%zu)", i);
indexdecl += format("DECLARE_INDEX(%d)", i); indexdecl += format("DECLARE_INDEX(%zu)", i);
declproc += format("PROCESS_ELEM(%d)", i); declproc += format("PROCESS_ELEM(%zu)", i);
declcn += format(" -D scn%d=%d -D dcn%d=%d", i, src[src_idx].channels(), i, dst[dst_idx].channels()); declcn += format(" -D scn%zu=%d -D dcn%zu=%d", i, src[src_idx].channels(), i, dst[dst_idx].channels());
} }
ocl::Kernel k("mixChannels", ocl::core::mixchannels_oclsrc, ocl::Kernel k("mixChannels", ocl::core::mixchannels_oclsrc,

@ -184,7 +184,7 @@ Mat LDA::subspaceProject(InputArray _W, InputArray _mean, InputArray _src) {
} }
// make sure mean is correct if not empty // make sure mean is correct if not empty
if(!mean.empty() && (mean.total() != (size_t) d)) { if(!mean.empty() && (mean.total() != (size_t) d)) {
String error_message = format("Wrong mean shape for the given data matrix. Expected %d, but was %d.", d, mean.total()); String error_message = format("Wrong mean shape for the given data matrix. Expected %d, but was %zu.", d, mean.total());
CV_Error(Error::StsBadArg, error_message); CV_Error(Error::StsBadArg, error_message);
} }
// create temporary matrices // create temporary matrices
@ -222,7 +222,7 @@ Mat LDA::subspaceReconstruct(InputArray _W, InputArray _mean, InputArray _src)
} }
// make sure mean is correct if not empty // make sure mean is correct if not empty
if(!mean.empty() && (mean.total() != (size_t) W.rows)) { if(!mean.empty() && (mean.total() != (size_t) W.rows)) {
String error_message = format("Wrong mean shape for the given eigenvector matrix. Expected %d, but was %d.", W.cols, mean.total()); String error_message = format("Wrong mean shape for the given eigenvector matrix. Expected %d, but was %zu.", W.cols, mean.total());
CV_Error(Error::StsBadArg, error_message); CV_Error(Error::StsBadArg, error_message);
} }
// initialize temporary matrices // initialize temporary matrices
@ -1076,7 +1076,7 @@ void LDA::lda(InputArrayOfArrays _src, InputArray _lbls) {
} }
// throw error if less labels, than samples // throw error if less labels, than samples
if (labels.size() != static_cast<size_t>(N)) { if (labels.size() != static_cast<size_t>(N)) {
String error_message = format("The number of samples must equal the number of labels. Given %d labels, %d samples. ", labels.size(), N); String error_message = format("The number of samples must equal the number of labels. Given %zu labels, %d samples. ", labels.size(), N);
CV_Error(Error::StsBadArg, error_message); CV_Error(Error::StsBadArg, error_message);
} }
// warn if within-classes scatter matrix becomes singular // warn if within-classes scatter matrix becomes singular

@ -892,7 +892,7 @@ static bool ocl_reduce(InputArray _src, OutputArray _dst,
tileHeight = min(tileHeight, defDev.localMemSize() / buf_cols / CV_ELEM_SIZE(CV_MAKETYPE(wdepth, cn)) / maxItemInGroupCount); tileHeight = min(tileHeight, defDev.localMemSize() / buf_cols / CV_ELEM_SIZE(CV_MAKETYPE(wdepth, cn)) / maxItemInGroupCount);
} }
char cvt[3][40]; char cvt[3][40];
cv::String build_opt = format("-D OP_REDUCE_PRE -D BUF_COLS=%d -D TILE_HEIGHT=%d -D %s -D dim=1" cv::String build_opt = format("-D OP_REDUCE_PRE -D BUF_COLS=%d -D TILE_HEIGHT=%zu -D %s -D dim=1"
" -D cn=%d -D ddepth=%d" " -D cn=%d -D ddepth=%d"
" -D srcT=%s -D bufT=%s -D dstT=%s" " -D srcT=%s -D bufT=%s -D dstT=%s"
" -D convertToWT=%s -D convertToBufT=%s -D convertToDT=%s%s", " -D convertToWT=%s -D convertToBufT=%s -D convertToDT=%s%s",

@ -3104,9 +3104,9 @@ bool Kernel::Impl::run(int dims, size_t globalsize[], size_t localsize[],
if (retval != CL_SUCCESS) if (retval != CL_SUCCESS)
#endif #endif
{ {
cv::String msg = cv::format("clEnqueueNDRangeKernel('%s', dims=%d, globalsize=%dx%dx%d, localsize=%s) sync=%s", name.c_str(), (int)dims, cv::String msg = cv::format("clEnqueueNDRangeKernel('%s', dims=%d, globalsize=%zux%zux%zu, localsize=%s) sync=%s", name.c_str(), (int)dims,
globalsize[0], (dims > 1 ? globalsize[1] : 1), (dims > 2 ? globalsize[2] : 1), globalsize[0], (dims > 1 ? globalsize[1] : 1), (dims > 2 ? globalsize[2] : 1),
(localsize ? cv::format("%dx%dx%d", localsize[0], (dims > 1 ? localsize[1] : 1), (dims > 2 ? localsize[2] : 1)) : cv::String("NULL")).c_str(), (localsize ? cv::format("%zux%zux%zu", localsize[0], (dims > 1 ? localsize[1] : 1), (dims > 2 ? localsize[2] : 1)) : cv::String("NULL")).c_str(),
sync ? "true" : "false" sync ? "true" : "false"
); );
if (retval != CL_SUCCESS) if (retval != CL_SUCCESS)
@ -3317,7 +3317,7 @@ struct ProgramSource::Impl
default: default:
CV_Error(Error::StsInternal, "Internal error"); CV_Error(Error::StsInternal, "Internal error");
} }
sourceHash_ = cv::format("%08llx", hash); sourceHash_ = cv::format("%08jx", hash);
isHashUpdated = true; isHashUpdated = true;
} }

@ -584,23 +584,23 @@ TEST(Core_InputOutput, FileStorageSpaces)
const int valueCount = 5; const int valueCount = 5;
std::string values[5] = { "", " ", " ", " a", " some string" }; std::string values[5] = { "", " ", " ", " a", " some string" };
for (size_t i = 0; i < valueCount; i++) { for (size_t i = 0; i < valueCount; i++) {
EXPECT_NO_THROW(f << cv::format("key%d", i) << values[i]); EXPECT_NO_THROW(f << cv::format("key%zu", i) << values[i]);
} }
cv::FileStorage f2(f.releaseAndGetString(), cv::FileStorage::READ | cv::FileStorage::MEMORY); cv::FileStorage f2(f.releaseAndGetString(), cv::FileStorage::READ | cv::FileStorage::MEMORY);
std::string valuesRead[valueCount]; std::string valuesRead[valueCount];
for (size_t i = 0; i < valueCount; i++) { for (size_t i = 0; i < valueCount; i++) {
EXPECT_NO_THROW(f2[cv::format("key%d", i)] >> valuesRead[i]); EXPECT_NO_THROW(f2[cv::format("key%zu", i)] >> valuesRead[i]);
ASSERT_STREQ(values[i].c_str(), valuesRead[i].c_str()); ASSERT_STREQ(values[i].c_str(), valuesRead[i].c_str());
} }
std::string fileName = cv::tempfile(".xml"); std::string fileName = cv::tempfile(".xml");
cv::FileStorage g1(fileName, cv::FileStorage::WRITE); cv::FileStorage g1(fileName, cv::FileStorage::WRITE);
for (size_t i = 0; i < 2; i++) { for (size_t i = 0; i < 2; i++) {
EXPECT_NO_THROW(g1 << cv::format("key%d", i) << values[i]); EXPECT_NO_THROW(g1 << cv::format("key%zu", i) << values[i]);
} }
g1.release(); g1.release();
cv::FileStorage g2(fileName, cv::FileStorage::APPEND); cv::FileStorage g2(fileName, cv::FileStorage::APPEND);
for (size_t i = 2; i < valueCount; i++) { for (size_t i = 2; i < valueCount; i++) {
EXPECT_NO_THROW(g2 << cv::format("key%d", i) << values[i]); EXPECT_NO_THROW(g2 << cv::format("key%zu", i) << values[i]);
} }
g2.release(); g2.release();
cv::FileStorage g3(fileName, cv::FileStorage::READ); cv::FileStorage g3(fileName, cv::FileStorage::READ);

@ -126,7 +126,7 @@ static bool ocl_goodFeaturesToTrack( InputArray _image, OutputArray _corners,
return false; return false;
ocl::Kernel k2("maxEigenValTask", ocl::imgproc::gftt_oclsrc, ocl::Kernel k2("maxEigenValTask", ocl::imgproc::gftt_oclsrc,
format("-D OP_MAX_EIGEN_VAL -D WGS=%d -D WGS2_ALIGNED=%d -D groupnum=%d", format("-D OP_MAX_EIGEN_VAL -D WGS=%zu -D WGS2_ALIGNED=%d -D groupnum=%d",
wgs, wgs2_aligned, dbsize)); wgs, wgs2_aligned, dbsize));
if (k2.empty()) if (k2.empty())
return false; return false;

@ -1123,7 +1123,7 @@ static bool ocl_calcHist1(InputArray _src, OutputArray _hist, int ddepth = CV_32
int kercn = dev.isAMD() && use16 ? 16 : std::min(4, ocl::predictOptimalVectorWidth(_src)); int kercn = dev.isAMD() && use16 ? 16 : std::min(4, ocl::predictOptimalVectorWidth(_src));
ocl::Kernel k1("calculate_histogram", ocl::imgproc::histogram_oclsrc, ocl::Kernel k1("calculate_histogram", ocl::imgproc::histogram_oclsrc,
format("-D BINS=%d -D HISTS_COUNT=%d -D WGS=%d -D kercn=%d -D T=%s%s", format("-D BINS=%d -D HISTS_COUNT=%d -D WGS=%zu -D kercn=%d -D T=%s%s",
BINS, compunits, wgs, kercn, BINS, compunits, wgs, kercn,
kercn == 4 ? "int" : ocl::typeToStr(CV_8UC(kercn)), kercn == 4 ? "int" : ocl::typeToStr(CV_8UC(kercn)),
_src.isContinuous() ? " -D HAVE_SRC_CONT" : "")); _src.isContinuous() ? " -D HAVE_SRC_CONT" : ""));
@ -3253,7 +3253,7 @@ static bool ocl_equalizeHist(InputArray _src, OutputArray _dst)
int kercn = dev.isAMD() && use16 ? 16 : std::min(4, ocl::predictOptimalVectorWidth(_src)); int kercn = dev.isAMD() && use16 ? 16 : std::min(4, ocl::predictOptimalVectorWidth(_src));
ocl::Kernel k1("calculate_histogram", ocl::imgproc::histogram_oclsrc, ocl::Kernel k1("calculate_histogram", ocl::imgproc::histogram_oclsrc,
format("-D BINS=%d -D HISTS_COUNT=%d -D WGS=%d -D kercn=%d -D T=%s%s", format("-D BINS=%d -D HISTS_COUNT=%d -D WGS=%zu -D kercn=%d -D T=%s%s",
BINS, compunits, wgs, kercn, BINS, compunits, wgs, kercn,
kercn == 4 ? "int" : ocl::typeToStr(CV_8UC(kercn)), kercn == 4 ? "int" : ocl::typeToStr(CV_8UC(kercn)),
_src.isContinuous() ? " -D HAVE_SRC_CONT" : "")); _src.isContinuous() ? " -D HAVE_SRC_CONT" : ""));

@ -1328,7 +1328,7 @@ static bool ocl_compute_hists(int nbins, int block_stride_x, int block_stride_y,
if(is_cpu) if(is_cpu)
opts = "-D CPU "; opts = "-D CPU ";
else else
opts = cv::format("-D WAVE_SIZE=%d", k.preferedWorkGroupSizeMultiple()); opts = cv::format("-D WAVE_SIZE=%zu", k.preferedWorkGroupSizeMultiple());
k.create("compute_hists_lut_kernel", ocl::objdetect::objdetect_hog_oclsrc, opts); k.create("compute_hists_lut_kernel", ocl::objdetect::objdetect_hog_oclsrc, opts);
if(k.empty()) if(k.empty())
return false; return false;
@ -1401,7 +1401,7 @@ static bool ocl_normalize_hists(int nbins, int block_stride_x, int block_stride_
if(is_cpu) if(is_cpu)
opts = "-D CPU "; opts = "-D CPU ";
else else
opts = cv::format("-D WAVE_SIZE=%d", k.preferedWorkGroupSizeMultiple()); opts = cv::format("-D WAVE_SIZE=%zu", k.preferedWorkGroupSizeMultiple());
k.create("normalize_hists_36_kernel", ocl::objdetect::objdetect_hog_oclsrc, opts); k.create("normalize_hists_36_kernel", ocl::objdetect::objdetect_hog_oclsrc, opts);
if(k.empty()) if(k.empty())
return false; return false;
@ -1420,7 +1420,7 @@ static bool ocl_normalize_hists(int nbins, int block_stride_x, int block_stride_
if(is_cpu) if(is_cpu)
opts = "-D CPU "; opts = "-D CPU ";
else else
opts = cv::format("-D WAVE_SIZE=%d", k.preferedWorkGroupSizeMultiple()); opts = cv::format("-D WAVE_SIZE=%zu", k.preferedWorkGroupSizeMultiple());
k.create("normalize_hists_kernel", ocl::objdetect::objdetect_hog_oclsrc, opts); k.create("normalize_hists_kernel", ocl::objdetect::objdetect_hog_oclsrc, opts);
if(k.empty()) if(k.empty())
return false; return false;
@ -1870,7 +1870,7 @@ static bool ocl_classify_hists(int win_height, int win_width, int block_stride_y
if(is_cpu) if(is_cpu)
opts = "-D CPU "; opts = "-D CPU ";
else else
opts = cv::format("-D WAVE_SIZE=%d", k.preferedWorkGroupSizeMultiple()); opts = cv::format("-D WAVE_SIZE=%zu", k.preferedWorkGroupSizeMultiple());
k.create("classify_hists_180_kernel", ocl::objdetect::objdetect_hog_oclsrc, opts); k.create("classify_hists_180_kernel", ocl::objdetect::objdetect_hog_oclsrc, opts);
if(k.empty()) if(k.empty())
return false; return false;
@ -1886,7 +1886,7 @@ static bool ocl_classify_hists(int win_height, int win_width, int block_stride_y
if(is_cpu) if(is_cpu)
opts = "-D CPU "; opts = "-D CPU ";
else else
opts = cv::format("-D WAVE_SIZE=%d", k.preferedWorkGroupSizeMultiple()); opts = cv::format("-D WAVE_SIZE=%zu", k.preferedWorkGroupSizeMultiple());
k.create("classify_hists_252_kernel", ocl::objdetect::objdetect_hog_oclsrc, opts); k.create("classify_hists_252_kernel", ocl::objdetect::objdetect_hog_oclsrc, opts);
if(k.empty()) if(k.empty())
return false; return false;

@ -22,7 +22,7 @@ inline D safe_int_cast(S val, const char * msg = 0)
if (!in_range_r || !in_range_l) if (!in_range_r || !in_range_l)
{ {
if (!msg) if (!msg)
CV_Error_(Error::StsOutOfRange, ("Can not convert integer values (%s -> %s), value 0x%llx is out of range", typeid(S).name(), typeid(D).name(), val)); CV_Error_(Error::StsOutOfRange, ("Can not convert integer values (%s -> %s), value 0x%jx is out of range", typeid(S).name(), typeid(D).name(), int64(val)));
else else
CV_Error(Error::StsOutOfRange, msg); CV_Error(Error::StsOutOfRange, msg);
} }

Loading…
Cancel
Save