From 4d23a5d92d3d6cca73c0aefb616915b99a10fc12 Mon Sep 17 00:00:00 2001 From: Pavel Rojtberg Date: Mon, 6 Aug 2018 01:23:19 +0200 Subject: [PATCH 1/3] core: enable printf format warnings for cv::format --- modules/core/include/opencv2/core/operations.hpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/modules/core/include/opencv2/core/operations.hpp b/modules/core/include/opencv2/core/operations.hpp index 0d28b6c944..8e9d013de6 100644 --- a/modules/core/include/opencv2/core/operations.hpp +++ b/modules/core/include/opencv2/core/operations.hpp @@ -51,6 +51,12 @@ #include +#if defined(__GNUC__) || defined(__clang__) // at least GCC 3.1+, clang 3.5+ +# define CV_FORMAT_PRINTF(string_idx, first_to_check) __attribute__ ((format (printf, string_idx, first_to_check))) +#else +# define CV_FORMAT_PRINTF(A, B) +#endif + //! @cond IGNORED namespace cv @@ -387,7 +393,7 @@ The function acts like sprintf but forms and returns an STL string. It can be us message in the Exception constructor. @param fmt printf-compatible formatting specifiers. */ -CV_EXPORTS String format( const char* fmt, ... ); +CV_EXPORTS String format( const char* fmt, ... ) CV_FORMAT_PRINTF(1, 2); ///////////////////////////////// Formatted output of cv::Mat ///////////////////////////////// From d1c842cf29ae4355865525fe12ed5c5db6eb634f Mon Sep 17 00:00:00 2001 From: Pavel Rojtberg Date: Mon, 6 Aug 2018 17:16:21 +0200 Subject: [PATCH 2/3] core: fix printf warnings by using c++11 format --- modules/core/src/channels.cpp | 10 +++++----- modules/core/src/lda.cpp | 6 +++--- modules/core/src/matrix_operations.cpp | 2 +- modules/core/src/ocl.cpp | 6 +++--- modules/core/test/test_io.cpp | 8 ++++---- modules/imgproc/src/featureselect.cpp | 2 +- modules/imgproc/src/histogram.cpp | 4 ++-- modules/objdetect/src/hog.cpp | 10 +++++----- modules/videoio/src/container_avi.cpp | 2 +- 9 files changed, 25 insertions(+), 25 deletions(-) diff --git a/modules/core/src/channels.cpp b/modules/core/src/channels.cpp index 4e464d910c..11d95ecc72 100644 --- a/modules/core/src/channels.cpp +++ b/modules/core/src/channels.cpp @@ -237,11 +237,11 @@ static bool ocl_mixChannels(InputArrayOfArrays _src, InputOutputArrayOfArrays _d dstargs[i] = dst[dst_idx]; dstargs[i].offset += dst_cnidx * esz; - declsrc += format("DECLARE_INPUT_MAT(%d)", i); - decldst += format("DECLARE_OUTPUT_MAT(%d)", i); - indexdecl += format("DECLARE_INDEX(%d)", i); - declproc += format("PROCESS_ELEM(%d)", i); - declcn += format(" -D scn%d=%d -D dcn%d=%d", i, src[src_idx].channels(), i, dst[dst_idx].channels()); + declsrc += format("DECLARE_INPUT_MAT(%zu)", i); + decldst += format("DECLARE_OUTPUT_MAT(%zu)", i); + indexdecl += format("DECLARE_INDEX(%zu)", i); + declproc += format("PROCESS_ELEM(%zu)", i); + 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, diff --git a/modules/core/src/lda.cpp b/modules/core/src/lda.cpp index a339b39136..618b9bb451 100644 --- a/modules/core/src/lda.cpp +++ b/modules/core/src/lda.cpp @@ -184,7 +184,7 @@ Mat LDA::subspaceProject(InputArray _W, InputArray _mean, InputArray _src) { } // make sure mean is correct if not empty 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); } // create temporary matrices @@ -222,7 +222,7 @@ Mat LDA::subspaceReconstruct(InputArray _W, InputArray _mean, InputArray _src) } // make sure mean is correct if not empty 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); } // initialize temporary matrices @@ -1076,7 +1076,7 @@ void LDA::lda(InputArrayOfArrays _src, InputArray _lbls) { } // throw error if less labels, than samples if (labels.size() != static_cast(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); } // warn if within-classes scatter matrix becomes singular diff --git a/modules/core/src/matrix_operations.cpp b/modules/core/src/matrix_operations.cpp index 6d865a51a9..288f881c21 100644 --- a/modules/core/src/matrix_operations.cpp +++ b/modules/core/src/matrix_operations.cpp @@ -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); } 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 srcT=%s -D bufT=%s -D dstT=%s" " -D convertToWT=%s -D convertToBufT=%s -D convertToDT=%s%s", diff --git a/modules/core/src/ocl.cpp b/modules/core/src/ocl.cpp index 50dd13b533..ed4d143bc1 100644 --- a/modules/core/src/ocl.cpp +++ b/modules/core/src/ocl.cpp @@ -3104,9 +3104,9 @@ bool Kernel::Impl::run(int dims, size_t globalsize[], size_t localsize[], if (retval != CL_SUCCESS) #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), - (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" ); if (retval != CL_SUCCESS) @@ -3317,7 +3317,7 @@ struct ProgramSource::Impl default: CV_Error(Error::StsInternal, "Internal error"); } - sourceHash_ = cv::format("%08llx", hash); + sourceHash_ = cv::format("%08jx", hash); isHashUpdated = true; } diff --git a/modules/core/test/test_io.cpp b/modules/core/test/test_io.cpp index 33583b4d1b..6b75037d8e 100644 --- a/modules/core/test/test_io.cpp +++ b/modules/core/test/test_io.cpp @@ -584,23 +584,23 @@ TEST(Core_InputOutput, FileStorageSpaces) const int valueCount = 5; std::string values[5] = { "", " ", " ", " a", " some string" }; 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); std::string valuesRead[valueCount]; 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()); } std::string fileName = cv::tempfile(".xml"); cv::FileStorage g1(fileName, cv::FileStorage::WRITE); 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(); cv::FileStorage g2(fileName, cv::FileStorage::APPEND); 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(); cv::FileStorage g3(fileName, cv::FileStorage::READ); diff --git a/modules/imgproc/src/featureselect.cpp b/modules/imgproc/src/featureselect.cpp index 7727644145..40d5551667 100644 --- a/modules/imgproc/src/featureselect.cpp +++ b/modules/imgproc/src/featureselect.cpp @@ -126,7 +126,7 @@ static bool ocl_goodFeaturesToTrack( InputArray _image, OutputArray _corners, return false; 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)); if (k2.empty()) return false; diff --git a/modules/imgproc/src/histogram.cpp b/modules/imgproc/src/histogram.cpp index 59384fce7d..c116a988f8 100644 --- a/modules/imgproc/src/histogram.cpp +++ b/modules/imgproc/src/histogram.cpp @@ -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)); 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, kercn == 4 ? "int" : ocl::typeToStr(CV_8UC(kercn)), _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)); 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, kercn == 4 ? "int" : ocl::typeToStr(CV_8UC(kercn)), _src.isContinuous() ? " -D HAVE_SRC_CONT" : "")); diff --git a/modules/objdetect/src/hog.cpp b/modules/objdetect/src/hog.cpp index aec2febaa2..2553d2fa43 100644 --- a/modules/objdetect/src/hog.cpp +++ b/modules/objdetect/src/hog.cpp @@ -1328,7 +1328,7 @@ static bool ocl_compute_hists(int nbins, int block_stride_x, int block_stride_y, if(is_cpu) opts = "-D CPU "; 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); if(k.empty()) return false; @@ -1401,7 +1401,7 @@ static bool ocl_normalize_hists(int nbins, int block_stride_x, int block_stride_ if(is_cpu) opts = "-D CPU "; 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); if(k.empty()) return false; @@ -1420,7 +1420,7 @@ static bool ocl_normalize_hists(int nbins, int block_stride_x, int block_stride_ if(is_cpu) opts = "-D CPU "; 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); if(k.empty()) return false; @@ -1870,7 +1870,7 @@ static bool ocl_classify_hists(int win_height, int win_width, int block_stride_y if(is_cpu) opts = "-D CPU "; 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); if(k.empty()) return false; @@ -1886,7 +1886,7 @@ static bool ocl_classify_hists(int win_height, int win_width, int block_stride_y if(is_cpu) opts = "-D CPU "; 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); if(k.empty()) return false; diff --git a/modules/videoio/src/container_avi.cpp b/modules/videoio/src/container_avi.cpp index d6a7a059e4..208d558482 100644 --- a/modules/videoio/src/container_avi.cpp +++ b/modules/videoio/src/container_avi.cpp @@ -22,7 +22,7 @@ inline D safe_int_cast(S val, const char * msg = 0) if (!in_range_r || !in_range_l) { 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 CV_Error(Error::StsOutOfRange, msg); } From e0f524d3b79a70b7ac14d914bf06c80d2ad7cc10 Mon Sep 17 00:00:00 2001 From: Maksim Shabunin Date: Wed, 19 Sep 2018 15:49:59 +0300 Subject: [PATCH 3/3] Fixed several incorrect printf format specifiers --- apps/interactive-calibration/calibController.cpp | 2 +- apps/interactive-calibration/frameProcessor.cpp | 2 +- modules/core/include/opencv2/core/operations.hpp | 11 +++++++++++ modules/core/src/ocl.cpp | 2 +- modules/core/test/test_io.cpp | 2 +- modules/dnn/src/dnn.cpp | 2 +- modules/dnn/src/layers/permute_layer.cpp | 2 +- modules/dnn/src/torch/THDiskFile.cpp | 6 +++--- modules/objdetect/src/hog.cpp | 2 +- modules/photo/src/fast_nlmeans_denoising_opencl.hpp | 5 +++-- modules/videoio/src/container_avi.cpp | 2 +- samples/dnn/segmentation.cpp | 4 ++-- 12 files changed, 27 insertions(+), 15 deletions(-) diff --git a/apps/interactive-calibration/calibController.cpp b/apps/interactive-calibration/calibController.cpp index f0aa6df36e..efe937bfd9 100644 --- a/apps/interactive-calibration/calibController.cpp +++ b/apps/interactive-calibration/calibController.cpp @@ -210,7 +210,7 @@ void calib::calibDataController::filterFrames() worstElemIndex = i; } } - showOverlayMessage(cv::format("Frame %d is worst", worstElemIndex + 1)); + showOverlayMessage(cv::format("Frame %zu is worst", worstElemIndex + 1)); if(mCalibData->imagePoints.size()) { mCalibData->imagePoints.erase(mCalibData->imagePoints.begin() + worstElemIndex); diff --git a/apps/interactive-calibration/frameProcessor.cpp b/apps/interactive-calibration/frameProcessor.cpp index 9d78271438..aecc2c0770 100644 --- a/apps/interactive-calibration/frameProcessor.cpp +++ b/apps/interactive-calibration/frameProcessor.cpp @@ -318,7 +318,7 @@ cv::Mat CalibProcessor::processFrame(const cv::Mat &frame) saveFrameData(); bool isFrameBad = checkLastFrame(); if (!isFrameBad) { - std::string displayMessage = cv::format("Frame # %d captured", std::max(mCalibData->imagePoints.size(), + std::string displayMessage = cv::format("Frame # %zu captured", std::max(mCalibData->imagePoints.size(), mCalibData->allCharucoCorners.size())); if(!showOverlayMessage(displayMessage)) showCaptureMessage(frame, displayMessage); diff --git a/modules/core/include/opencv2/core/operations.hpp b/modules/core/include/opencv2/core/operations.hpp index 8e9d013de6..a352048a49 100644 --- a/modules/core/include/opencv2/core/operations.hpp +++ b/modules/core/include/opencv2/core/operations.hpp @@ -392,6 +392,17 @@ template static inline _Tp randu() The function acts like sprintf but forms and returns an STL string. It can be used to form an error message in the Exception constructor. @param fmt printf-compatible formatting specifiers. + +**Note**: +|Type|Specifier| +|-|-| +|`const char*`|`%s`| +|`char`|`%c`| +|`float` / `double`|`%f`,`%g`| +|`int`, `long`, `long long`|`%d`, `%ld`, ``%lld`| +|`unsigned`, `unsigned long`, `unsigned long long`|`%u`, `%lu`, `%llu`| +|`uint64` -> `uintmax_t`, `int64` -> `intmax_t`|`%ju`, `%jd`| +|`size_t`|`%zu`| */ CV_EXPORTS String format( const char* fmt, ... ) CV_FORMAT_PRINTF(1, 2); diff --git a/modules/core/src/ocl.cpp b/modules/core/src/ocl.cpp index ed4d143bc1..64a45fa825 100644 --- a/modules/core/src/ocl.cpp +++ b/modules/core/src/ocl.cpp @@ -3317,7 +3317,7 @@ struct ProgramSource::Impl default: CV_Error(Error::StsInternal, "Internal error"); } - sourceHash_ = cv::format("%08jx", hash); + sourceHash_ = cv::format("%08jx", (uintmax_t)hash); isHashUpdated = true; } diff --git a/modules/core/test/test_io.cpp b/modules/core/test/test_io.cpp index 6b75037d8e..07a9648c5d 100644 --- a/modules/core/test/test_io.cpp +++ b/modules/core/test/test_io.cpp @@ -606,7 +606,7 @@ TEST(Core_InputOutput, FileStorageSpaces) cv::FileStorage g3(fileName, cv::FileStorage::READ); std::string valuesReadAppend[valueCount]; for (size_t i = 0; i < valueCount; i++) { - EXPECT_NO_THROW(g3[cv::format("key%d", i)] >> valuesReadAppend[i]); + EXPECT_NO_THROW(g3[cv::format("key%zu", i)] >> valuesReadAppend[i]); ASSERT_STREQ(values[i].c_str(), valuesReadAppend[i].c_str()); } g3.release(); diff --git a/modules/dnn/src/dnn.cpp b/modules/dnn/src/dnn.cpp index 65db785c19..2a323d167f 100644 --- a/modules/dnn/src/dnn.cpp +++ b/modules/dnn/src/dnn.cpp @@ -2347,7 +2347,7 @@ struct Net::Impl LayerData &ld = layers[pin.lid]; if ((size_t)pin.oid >= ld.outputBlobs.size()) { - CV_Error(Error::StsOutOfRange, format("Layer \"%s\" produce only %d outputs, " + CV_Error(Error::StsOutOfRange, format("Layer \"%s\" produce only %zu outputs, " "the #%d was requested", ld.name.c_str(), ld.outputBlobs.size(), pin.oid)); } diff --git a/modules/dnn/src/layers/permute_layer.cpp b/modules/dnn/src/layers/permute_layer.cpp index 65e4f049e3..e7f554ebba 100644 --- a/modules/dnn/src/layers/permute_layer.cpp +++ b/modules/dnn/src/layers/permute_layer.cpp @@ -88,7 +88,7 @@ public: { CV_Error(Error::StsBadArg, format("Orders of dimensions in Permute layer parameter" - "must be in [0...%d]", _numAxes - 1)); + "must be in [0...%zu]", _numAxes - 1)); } if (std::find(_order.begin(), _order.end(), currentOrder) != _order.end()) { diff --git a/modules/dnn/src/torch/THDiskFile.cpp b/modules/dnn/src/torch/THDiskFile.cpp index aad9eccb17..84b6b23e81 100644 --- a/modules/dnn/src/torch/THDiskFile.cpp +++ b/modules/dnn/src/torch/THDiskFile.cpp @@ -69,7 +69,7 @@ static size_t fread__(void *ptr, size_t size, size_t nitems, FILE *stream) { \ dfself->file.hasError = 1; /* shouldn't we put hasError to 0 all the time ? */ \ if(!dfself->file.isQuiet) \ - THError("read error: read %d blocks instead of %d", nread, n); \ + THError("read error: read %ld blocks instead of %ld", nread, n);\ } \ \ return nread; \ @@ -120,7 +120,7 @@ static void THDiskFile_seek(THFile *self, long position) { dfself->file.hasError = 1; if(!dfself->file.isQuiet) - THError("unable to seek at position %d", position); + THError("unable to seek at position %ld", position); } } @@ -351,7 +351,7 @@ static long THDiskFile_readLong(THFile *self, int64 *data, long n) { dfself->file.hasError = 1; /* shouldn't we put hasError to 0 all the time ? */ if(!dfself->file.isQuiet) - THError("read error: read %d blocks instead of %d", nread, n); + THError("read error: read %ld blocks instead of %ld", nread, n); } return nread; diff --git a/modules/objdetect/src/hog.cpp b/modules/objdetect/src/hog.cpp index 2553d2fa43..3192b425ad 100644 --- a/modules/objdetect/src/hog.cpp +++ b/modules/objdetect/src/hog.cpp @@ -1902,7 +1902,7 @@ static bool ocl_classify_hists(int win_height, int win_width, int block_stride_y if(is_cpu) opts = "-D CPU "; else - opts = cv::format("-D WAVE_SIZE=%d", k.preferedWorkGroupSizeMultiple()); + opts = cv::format("-D WAVE_SIZE=%zu", k.preferedWorkGroupSizeMultiple()); k.create("classify_hists_kernel", ocl::objdetect::objdetect_hog_oclsrc, opts); if(k.empty()) return false; diff --git a/modules/photo/src/fast_nlmeans_denoising_opencl.hpp b/modules/photo/src/fast_nlmeans_denoising_opencl.hpp index b19adbda96..cb3327d392 100644 --- a/modules/photo/src/fast_nlmeans_denoising_opencl.hpp +++ b/modules/photo/src/fast_nlmeans_denoising_opencl.hpp @@ -95,12 +95,13 @@ static bool ocl_fastNlMeansDenoising(InputArray _src, OutputArray _dst, const fl int almostTemplateWindowSizeSqBinShift = -1; char buf[4][40]; + const unsigned psz = (depth == CV_8U ? sizeof(uchar) : sizeof(ushort)) * (cn == 3 ? 4 : cn); String opts = format("-D OP_CALC_FASTNLMEANS -D TEMPLATE_SIZE=%d -D SEARCH_SIZE=%d" " -D pixel_t=%s -D int_t=%s -D wlut_t=%s" " -D weight_t=%s -D convert_weight_t=%s -D sum_t=%s -D convert_sum_t=%s" " -D BLOCK_COLS=%d -D BLOCK_ROWS=%d" " -D CTA_SIZE=%d -D TEMPLATE_SIZE2=%d -D SEARCH_SIZE2=%d" - " -D convert_int_t=%s -D cn=%d -D psz=%d -D convert_pixel_t=%s%s", + " -D convert_int_t=%s -D cn=%d -D psz=%u -D convert_pixel_t=%s%s", templateWindowSize, searchWindowSize, ocl::typeToStr(type), ocl::typeToStr(CV_32SC(cn)), ocl::typeToStr(CV_32SC(hn)), @@ -115,7 +116,7 @@ static bool ocl_fastNlMeansDenoising(InputArray _src, OutputArray _dst, const fl BLOCK_COLS, BLOCK_ROWS, ctaSize, templateWindowHalfWize, searchWindowHalfSize, ocl::convertTypeStr(depth, CV_32S, cn, buf[2]), cn, - (depth == CV_8U ? sizeof(uchar) : sizeof(ushort)) * (cn == 3 ? 4 : cn), + psz, ocl::convertTypeStr(CV_32S, depth, cn, buf[3]), normType == NORM_L1 ? " -D ABS" : ""); diff --git a/modules/videoio/src/container_avi.cpp b/modules/videoio/src/container_avi.cpp index 208d558482..547079d578 100644 --- a/modules/videoio/src/container_avi.cpp +++ b/modules/videoio/src/container_avi.cpp @@ -22,7 +22,7 @@ inline D safe_int_cast(S val, const char * msg = 0) if (!in_range_r || !in_range_l) { if (!msg) - 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))); + CV_Error_(Error::StsOutOfRange, ("Can not convert integer values (%s -> %s), value 0x%jx is out of range", typeid(S).name(), typeid(D).name(), (uintmax_t)val)); else CV_Error(Error::StsOutOfRange, msg); } diff --git a/samples/dnn/segmentation.cpp b/samples/dnn/segmentation.cpp index 70e8d7b5b4..b535c50339 100644 --- a/samples/dnn/segmentation.cpp +++ b/samples/dnn/segmentation.cpp @@ -186,7 +186,7 @@ void colorizeSegmentation(const Mat &score, Mat &segm) else if (chns != (int)colors.size()) { CV_Error(Error::StsError, format("Number of output classes does not match " - "number of colors (%d != %d)", chns, colors.size())); + "number of colors (%d != %zu)", chns, colors.size())); } Mat maxCl = Mat::zeros(rows, cols, CV_8UC1); @@ -231,7 +231,7 @@ void showLegend() if ((int)colors.size() != numClasses) { CV_Error(Error::StsError, format("Number of output classes does not match " - "number of labels (%d != %d)", colors.size(), classes.size())); + "number of labels (%zu != %zu)", colors.size(), classes.size())); } legend.create(kBlockHeight * numClasses, 200, CV_8UC3); for (int i = 0; i < numClasses; i++)