From d13ecd0d76910ce62def8fcd51ad2c29fd856820 Mon Sep 17 00:00:00 2001 From: Vladislav Vinogradov Date: Fri, 2 Aug 2013 17:31:34 +0400 Subject: [PATCH 01/11] increase epsilon for GEMM & Convolve sanity tests for CUDA 5.5 --- modules/gpu/perf/perf_core.cpp | 2 +- modules/gpu/perf/perf_imgproc.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/gpu/perf/perf_core.cpp b/modules/gpu/perf/perf_core.cpp index 3042beadc2..e38196b994 100644 --- a/modules/gpu/perf/perf_core.cpp +++ b/modules/gpu/perf/perf_core.cpp @@ -1337,7 +1337,7 @@ PERF_TEST_P(Sz_Type_Flags, Core_GEMM, TEST_CYCLE() cv::gpu::gemm(d_src1, d_src2, 1.0, d_src3, 1.0, dst, flags); - GPU_SANITY_CHECK(dst, 1e-6); + GPU_SANITY_CHECK(dst, 1e-6, ERROR_RELATIVE); } else { diff --git a/modules/gpu/perf/perf_imgproc.cpp b/modules/gpu/perf/perf_imgproc.cpp index c7fb2a17c0..d942bed612 100644 --- a/modules/gpu/perf/perf_imgproc.cpp +++ b/modules/gpu/perf/perf_imgproc.cpp @@ -884,7 +884,7 @@ PERF_TEST_P(Sz_KernelSz_Ccorr, ImgProc_Convolve, TEST_CYCLE() cv::gpu::convolve(d_image, d_templ, dst, ccorr, d_buf); - GPU_SANITY_CHECK(dst); + GPU_SANITY_CHECK(dst, 1e-6, ERROR_RELATIVE); } else { From cfbd791465dc03f5ed07c7287d91c4cdf671d49f Mon Sep 17 00:00:00 2001 From: Vladislav Vinogradov Date: Mon, 19 Aug 2013 11:56:58 +0400 Subject: [PATCH 02/11] fixed gpu cvtColor for BGR <-> YUV --- .../gpu/include/opencv2/gpu/device/color.hpp | 32 +++++++++---------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/modules/gpu/include/opencv2/gpu/device/color.hpp b/modules/gpu/include/opencv2/gpu/device/color.hpp index c087d179b8..5af64bf614 100644 --- a/modules/gpu/include/opencv2/gpu/device/color.hpp +++ b/modules/gpu/include/opencv2/gpu/device/color.hpp @@ -107,25 +107,25 @@ namespace cv { namespace gpu { namespace device #undef OPENCV_GPU_IMPLEMENT_RGB2GRAY_TRAITS - OPENCV_GPU_IMPLEMENT_RGB2YUV_TRAITS(rgb_to_yuv, 3, 3, 0) - OPENCV_GPU_IMPLEMENT_RGB2YUV_TRAITS(rgba_to_yuv, 4, 3, 0) - OPENCV_GPU_IMPLEMENT_RGB2YUV_TRAITS(rgb_to_yuv4, 3, 4, 0) - OPENCV_GPU_IMPLEMENT_RGB2YUV_TRAITS(rgba_to_yuv4, 4, 4, 0) - OPENCV_GPU_IMPLEMENT_RGB2YUV_TRAITS(bgr_to_yuv, 3, 3, 2) - OPENCV_GPU_IMPLEMENT_RGB2YUV_TRAITS(bgra_to_yuv, 4, 3, 2) - OPENCV_GPU_IMPLEMENT_RGB2YUV_TRAITS(bgr_to_yuv4, 3, 4, 2) - OPENCV_GPU_IMPLEMENT_RGB2YUV_TRAITS(bgra_to_yuv4, 4, 4, 2) + OPENCV_GPU_IMPLEMENT_RGB2YUV_TRAITS(rgb_to_yuv, 3, 3, 2) + OPENCV_GPU_IMPLEMENT_RGB2YUV_TRAITS(rgba_to_yuv, 4, 3, 2) + OPENCV_GPU_IMPLEMENT_RGB2YUV_TRAITS(rgb_to_yuv4, 3, 4, 2) + OPENCV_GPU_IMPLEMENT_RGB2YUV_TRAITS(rgba_to_yuv4, 4, 4, 2) + OPENCV_GPU_IMPLEMENT_RGB2YUV_TRAITS(bgr_to_yuv, 3, 3, 0) + OPENCV_GPU_IMPLEMENT_RGB2YUV_TRAITS(bgra_to_yuv, 4, 3, 0) + OPENCV_GPU_IMPLEMENT_RGB2YUV_TRAITS(bgr_to_yuv4, 3, 4, 0) + OPENCV_GPU_IMPLEMENT_RGB2YUV_TRAITS(bgra_to_yuv4, 4, 4, 0) #undef OPENCV_GPU_IMPLEMENT_RGB2YUV_TRAITS - OPENCV_GPU_IMPLEMENT_YUV2RGB_TRAITS(yuv_to_rgb, 3, 3, 0) - OPENCV_GPU_IMPLEMENT_YUV2RGB_TRAITS(yuv_to_rgba, 3, 4, 0) - OPENCV_GPU_IMPLEMENT_YUV2RGB_TRAITS(yuv4_to_rgb, 4, 3, 0) - OPENCV_GPU_IMPLEMENT_YUV2RGB_TRAITS(yuv4_to_rgba, 4, 4, 0) - OPENCV_GPU_IMPLEMENT_YUV2RGB_TRAITS(yuv_to_bgr, 3, 3, 2) - OPENCV_GPU_IMPLEMENT_YUV2RGB_TRAITS(yuv_to_bgra, 3, 4, 2) - OPENCV_GPU_IMPLEMENT_YUV2RGB_TRAITS(yuv4_to_bgr, 4, 3, 2) - OPENCV_GPU_IMPLEMENT_YUV2RGB_TRAITS(yuv4_to_bgra, 4, 4, 2) + OPENCV_GPU_IMPLEMENT_YUV2RGB_TRAITS(yuv_to_rgb, 3, 3, 2) + OPENCV_GPU_IMPLEMENT_YUV2RGB_TRAITS(yuv_to_rgba, 3, 4, 2) + OPENCV_GPU_IMPLEMENT_YUV2RGB_TRAITS(yuv4_to_rgb, 4, 3, 2) + OPENCV_GPU_IMPLEMENT_YUV2RGB_TRAITS(yuv4_to_rgba, 4, 4, 2) + OPENCV_GPU_IMPLEMENT_YUV2RGB_TRAITS(yuv_to_bgr, 3, 3, 0) + OPENCV_GPU_IMPLEMENT_YUV2RGB_TRAITS(yuv_to_bgra, 3, 4, 0) + OPENCV_GPU_IMPLEMENT_YUV2RGB_TRAITS(yuv4_to_bgr, 4, 3, 0) + OPENCV_GPU_IMPLEMENT_YUV2RGB_TRAITS(yuv4_to_bgra, 4, 4, 0) #undef OPENCV_GPU_IMPLEMENT_YUV2RGB_TRAITS From abf372d75921df4036d181e087beceda95380fb5 Mon Sep 17 00:00:00 2001 From: Roman Donchenko Date: Mon, 19 Aug 2013 15:00:36 +0400 Subject: [PATCH 03/11] Fixed incorrect extension on 3rdparty/libpng/opencv-libpng.patch. --- 3rdparty/libpng/{opencv-libpng.path => opencv-libpng.patch} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename 3rdparty/libpng/{opencv-libpng.path => opencv-libpng.patch} (100%) diff --git a/3rdparty/libpng/opencv-libpng.path b/3rdparty/libpng/opencv-libpng.patch similarity index 100% rename from 3rdparty/libpng/opencv-libpng.path rename to 3rdparty/libpng/opencv-libpng.patch From e37f7a4c73cde25f19c9cc636afca79c8d32c8b0 Mon Sep 17 00:00:00 2001 From: Alexander Smorkalov Date: Mon, 19 Aug 2013 16:27:06 +0400 Subject: [PATCH 04/11] Typo in Java generator fixed. Typo breaks debug build for Android platform. --- modules/java/generator/gen_java.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/java/generator/gen_java.py b/modules/java/generator/gen_java.py index 254298d8b0..d82a593bfa 100755 --- a/modules/java/generator/gen_java.py +++ b/modules/java/generator/gen_java.py @@ -544,7 +544,7 @@ JNIEXPORT jstring JNICALL Java_org_opencv_highgui_VideoCapture_getSupportedPrevi { static const char method_name[] = "highgui::VideoCapture_getSupportedPreviewSizes_10()"; try { - LOGD(%s, method_name); + LOGD("%s", method_name); VideoCapture* me = (VideoCapture*) self; //TODO: check for NULL union {double prop; const char* name;} u; u.prop = me->get(CV_CAP_PROP_SUPPORTED_PREVIEW_SIZES_STRING); From 9667a8a1aef0af79c9e42a0bd312b555806d6b0c Mon Sep 17 00:00:00 2001 From: Roman Donchenko Date: Tue, 20 Aug 2013 12:51:33 +0400 Subject: [PATCH 05/11] Fix the name of perf tests' precompiled header. (cherry picked from commit aa96d8d053c3d0c367da7c1c1f9c73ed376b3bfa) --- cmake/OpenCVModule.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmake/OpenCVModule.cmake b/cmake/OpenCVModule.cmake index 44e43fc2b2..80c07bda36 100644 --- a/cmake/OpenCVModule.cmake +++ b/cmake/OpenCVModule.cmake @@ -645,7 +645,7 @@ function(ocv_add_perf_tests) set(OPENCV_PERF_${the_module}_SOURCES ${perf_srcs} ${perf_hdrs}) endif() - get_native_precompiled_header(${the_target} test_precomp.hpp) + get_native_precompiled_header(${the_target} perf_precomp.hpp) add_executable(${the_target} ${OPENCV_PERF_${the_module}_SOURCES} ${${the_target}_pch}) target_link_libraries(${the_target} ${OPENCV_MODULE_${the_module}_DEPS} ${perf_deps} ${OPENCV_LINKER_LIBS}) From cb2985c52669bc91ce278c6acd4bcf23a52f757e Mon Sep 17 00:00:00 2001 From: Vladislav Vinogradov Date: Tue, 20 Aug 2013 16:28:45 +0400 Subject: [PATCH 06/11] fixed gpu bitwize operation: incorrect types for template instantiation --- modules/gpu/src/element_operations.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/modules/gpu/src/element_operations.cpp b/modules/gpu/src/element_operations.cpp index a9b003937a..356b50aa09 100644 --- a/modules/gpu/src/element_operations.cpp +++ b/modules/gpu/src/element_operations.cpp @@ -1993,7 +1993,7 @@ void cv::gpu::bitwise_not(const GpuMat& src, GpuMat& dst, const GpuMat& mask, St } else { - bitMatNot( + bitMatNot( PtrStepSzb(src.rows, bcols, src.data, src.step), PtrStepSzb(src.rows, bcols, dst.data, dst.step), mask, stream); @@ -2040,7 +2040,7 @@ void cv::gpu::bitwise_and(const GpuMat& src1, const GpuMat& src2, GpuMat& dst, c { const int vcols = bcols >> 1; - bitMatAnd( + bitMatAnd( PtrStepSzb(src1.rows, vcols, src1.data, src1.step), PtrStepSzb(src1.rows, vcols, src2.data, src2.step), PtrStepSzb(src1.rows, vcols, dst.data, dst.step), @@ -2049,7 +2049,7 @@ void cv::gpu::bitwise_and(const GpuMat& src1, const GpuMat& src2, GpuMat& dst, c else { - bitMatAnd( + bitMatAnd( PtrStepSzb(src1.rows, bcols, src1.data, src1.step), PtrStepSzb(src1.rows, bcols, src2.data, src2.step), PtrStepSzb(src1.rows, bcols, dst.data, dst.step), @@ -2087,7 +2087,7 @@ void cv::gpu::bitwise_or(const GpuMat& src1, const GpuMat& src2, GpuMat& dst, co { const int vcols = bcols >> 1; - bitMatOr( + bitMatOr( PtrStepSzb(src1.rows, vcols, src1.data, src1.step), PtrStepSzb(src1.rows, vcols, src2.data, src2.step), PtrStepSzb(src1.rows, vcols, dst.data, dst.step), @@ -2096,7 +2096,7 @@ void cv::gpu::bitwise_or(const GpuMat& src1, const GpuMat& src2, GpuMat& dst, co else { - bitMatOr( + bitMatOr( PtrStepSzb(src1.rows, bcols, src1.data, src1.step), PtrStepSzb(src1.rows, bcols, src2.data, src2.step), PtrStepSzb(src1.rows, bcols, dst.data, dst.step), @@ -2134,7 +2134,7 @@ void cv::gpu::bitwise_xor(const GpuMat& src1, const GpuMat& src2, GpuMat& dst, c { const int vcols = bcols >> 1; - bitMatXor( + bitMatXor( PtrStepSzb(src1.rows, vcols, src1.data, src1.step), PtrStepSzb(src1.rows, vcols, src2.data, src2.step), PtrStepSzb(src1.rows, vcols, dst.data, dst.step), @@ -2143,7 +2143,7 @@ void cv::gpu::bitwise_xor(const GpuMat& src1, const GpuMat& src2, GpuMat& dst, c else { - bitMatXor( + bitMatXor( PtrStepSzb(src1.rows, bcols, src1.data, src1.step), PtrStepSzb(src1.rows, bcols, src2.data, src2.step), PtrStepSzb(src1.rows, bcols, dst.data, dst.step), From b7ec673001731dd07789a2fdcce8f79c9134ac56 Mon Sep 17 00:00:00 2001 From: Vladislav Vinogradov Date: Wed, 21 Aug 2013 10:00:40 +0400 Subject: [PATCH 07/11] added cvconfig.h header, because ts_perf.cpp uses HAVE_CUDA macros --- modules/ts/src/precomp.hpp | 1 + 1 file changed, 1 insertion(+) diff --git a/modules/ts/src/precomp.hpp b/modules/ts/src/precomp.hpp index a74417da47..1133978f95 100644 --- a/modules/ts/src/precomp.hpp +++ b/modules/ts/src/precomp.hpp @@ -1,6 +1,7 @@ #include "opencv2/core/core_c.h" #include "opencv2/core/internal.hpp" #include "opencv2/ts/ts.hpp" +#include "cvconfig.h" #ifdef GTEST_LINKED_AS_SHARED_LIBRARY #error ts module should not have GTEST_LINKED_AS_SHARED_LIBRARY defined From 2899d558acfe861569ee5cb6766f56b82667701a Mon Sep 17 00:00:00 2001 From: Vladislav Vinogradov Date: Wed, 21 Aug 2013 10:12:44 +0400 Subject: [PATCH 08/11] record cuda gpu name to output report --- modules/ts/src/ts_perf.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/modules/ts/src/ts_perf.cpp b/modules/ts/src/ts_perf.cpp index d84db18866..f36ff09dfe 100644 --- a/modules/ts/src/ts_perf.cpp +++ b/modules/ts/src/ts_perf.cpp @@ -741,6 +741,14 @@ void TestBase::RecordRunParameters() { ::testing::Test::RecordProperty("cv_implementation", param_impl); ::testing::Test::RecordProperty("cv_num_threads", param_threads); + +#ifdef HAVE_CUDA + if (param_impl == "cuda") + { + cv::gpu::DeviceInfo info(param_cuda_device); + ::testing::Test::RecordProperty("cv_cuda_gpu", info.name()); + } +#endif } std::string TestBase::getSelectedImpl() From ea5dd74af1e2924be4c7776e1e80ccf211701054 Mon Sep 17 00:00:00 2001 From: kdrobnyh Date: Wed, 14 Aug 2013 13:33:17 +0400 Subject: [PATCH 09/11] Add IPP 8.0 support in FindIPP script --- cmake/OpenCVFindIPP.cmake | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/cmake/OpenCVFindIPP.cmake b/cmake/OpenCVFindIPP.cmake index 9921d2503c..9f74d941fa 100644 --- a/cmake/OpenCVFindIPP.cmake +++ b/cmake/OpenCVFindIPP.cmake @@ -136,17 +136,20 @@ endfunction() # ------------------------------------------------------------------------ # This is auxiliary function called from set_ipp_variables() -# to set IPP_LIBRARIES variable in IPP 7.x style +# to set IPP_LIBRARIES variable in IPP 7.x and 8.x style # ------------------------------------------------------------------------ function(set_ipp_new_libraries _LATEST_VERSION) set(IPP_PREFIX "ipp") if(${_LATEST_VERSION} VERSION_LESS "8.0") - set(IPP_SUFFIX "_l") # static not threaded libs suffix + set(IPP_SUFFIX "_l") # static not threaded libs suffix IPP 7.x else() - set(IPP_SUFFIX "") # static not threaded libs suffix + if(WIN32) + set(IPP_SUFFIX "mt") # static not threaded libs suffix IPP 8.x for Windows + else() + set(IPP_SUFFIX "") # static not threaded libs suffix IPP 8.x for Linux/OS X + endif() endif() - set(IPP_THRD "_t") # static threaded libs suffix set(IPPCORE "core") # core functionality set(IPPSP "s") # signal processing set(IPPIP "i") # image processing @@ -218,7 +221,7 @@ function(set_ipp_variables _LATEST_VERSION) set(IPP_LIBRARY_DIRS ${IPP_ROOT_DIR}/lib/ia32 PARENT_SCOPE) endif() - # set IPP_LIBRARIES variable (7.x lib names) + # set IPP_LIBRARIES variable (7.x or 8.x lib names) set_ipp_new_libraries(${_LATEST_VERSION}) set(IPP_LIBRARIES ${IPP_LIBRARIES} PARENT_SCOPE) message(STATUS "IPP libs: ${IPP_LIBRARIES}") From d62c98527a8634774ae49fbe3ff8f3776d5d7cd0 Mon Sep 17 00:00:00 2001 From: Alexander Smorkalov Date: Mon, 19 Aug 2013 01:25:53 -0700 Subject: [PATCH 10/11] Invalid usage of cv::Ptr for arrays fixed. --- modules/contrib/src/inputoutput.cpp | 37 ++++++++++++++--------------- modules/core/src/glob.cpp | 15 ++++++------ modules/core/src/system.cpp | 11 ++++----- 3 files changed, 30 insertions(+), 33 deletions(-) diff --git a/modules/contrib/src/inputoutput.cpp b/modules/contrib/src/inputoutput.cpp index e04740faee..d6d514f5b8 100644 --- a/modules/contrib/src/inputoutput.cpp +++ b/modules/contrib/src/inputoutput.cpp @@ -11,7 +11,7 @@ namespace cv { - std::vector Directory::GetListFiles( const std::string& path, const std::string & exten, bool addPath ) + std::vector Directory::GetListFiles( const std::string& path, const std::string & exten, bool addPath ) { std::vector list; list.clear(); @@ -25,10 +25,9 @@ namespace cv HANDLE hFind; #ifdef HAVE_WINRT - size_t size = mbstowcs(NULL, path_f.c_str(), path_f.size()); - Ptr wpath = new wchar_t[size+1]; - wpath[size] = 0; - mbstowcs(wpath, path_f.c_str(), path_f.size()); + wchar_t wpath[MAX_PATH]; + size_t copied = mbstowcs(wpath, path_f.c_str(), MAX_PATH); + CV_Assert((copied != MAX_PATH) && (copied != (size_t)-1)); hFind = FindFirstFileExW(wpath, FindExInfoStandard, &FindFileData, FindExSearchNameMatch, NULL, 0); #else hFind = FindFirstFileA((LPCSTR)path_f.c_str(), &FindFileData); @@ -47,12 +46,12 @@ namespace cv FindFileData.dwFileAttributes == FILE_ATTRIBUTE_SYSTEM || FindFileData.dwFileAttributes == FILE_ATTRIBUTE_READONLY) { - cv::Ptr fname; + char* fname; #ifdef HAVE_WINRT - size_t asize = wcstombs(NULL, FindFileData.cFileName, 0); - fname = new char[asize+1]; - fname[asize] = 0; - wcstombs(fname, FindFileData.cFileName, asize); + char fname_tmp[MAX_PATH] = {0}; + size_t copied = wcstombs(fname_tmp, FindFileData.cFileName, MAX_PATH); + CV_Assert((copied != MAX_PATH) && (copied != (size_t)-1)); + fname = fname_tmp; #else fname = FindFileData.cFileName; #endif @@ -109,10 +108,10 @@ namespace cv HANDLE hFind; #ifdef HAVE_WINRT - size_t size = mbstowcs(NULL, path_f.c_str(), path_f.size()); - Ptr wpath = new wchar_t[size+1]; - wpath[size] = 0; - mbstowcs(wpath, path_f.c_str(), path_f.size()); + wchar_t wpath [MAX_PATH]; + size_t copied = mbstowcs(wpath, path_f.c_str(), path_f.size()); + CV_Assert((copied != MAX_PATH) && (copied != (size_t)-1)); + hFind = FindFirstFileExW(wpath, FindExInfoStandard, &FindFileData, FindExSearchNameMatch, NULL, 0); #else hFind = FindFirstFileA((LPCSTR)path_f.c_str(), &FindFileData); @@ -135,12 +134,12 @@ namespace cv strcmp(FindFileData.cFileName, "..") != 0) #endif { - cv::Ptr fname; + char* fname; #ifdef HAVE_WINRT - size_t asize = wcstombs(NULL, FindFileData.cFileName, 0); - fname = new char[asize+1]; - fname[asize] = 0; - wcstombs(fname, FindFileData.cFileName, asize); + char fname_tmp[MAX_PATH]; + size_t copied = wcstombs(fname, FindFileData.cFileName, MAX_PATH); + CV_Assert((copied != MAX_PATH) && (copied != (size_t)-1)); + fname = fname_tmp; #else fname = FindFileData.cFileName; #endif diff --git a/modules/core/src/glob.cpp b/modules/core/src/glob.cpp index e39cba0163..208b4e05cf 100644 --- a/modules/core/src/glob.cpp +++ b/modules/core/src/glob.cpp @@ -79,10 +79,9 @@ namespace dir->ent.d_name = 0; #ifdef HAVE_WINRT cv::String full_path = cv::String(path) + "\\*"; - size_t size = mbstowcs(NULL, full_path.c_str(), full_path.size()); - cv::Ptr wfull_path = new wchar_t[size+1]; - wfull_path[size] = 0; - mbstowcs(wfull_path, full_path.c_str(), full_path.size()); + wchar_t wfull_path[MAX_PATH]; + size_t copied = mbstowcs(wfull_path, full_path.c_str(), MAX_PATH); + CV_Assert((copied != MAX_PATH) && (copied != (size_t)-1)); dir->handle = ::FindFirstFileExW(wfull_path, FindExInfoStandard, &dir->data, FindExSearchNameMatch, NULL, 0); #else @@ -106,6 +105,7 @@ namespace return 0; } size_t asize = wcstombs(NULL, dir->data.cFileName, 0); + CV_Assert((asize != 0) && (asize != (size_t)-1)); char* aname = new char[asize+1]; aname[asize] = 0; wcstombs(aname, dir->data.cFileName, asize); @@ -146,10 +146,9 @@ static bool isDir(const cv::String& path, DIR* dir) { WIN32_FILE_ATTRIBUTE_DATA all_attrs; #ifdef HAVE_WINRT - size_t size = mbstowcs(NULL, path.c_str(), path.size()); - cv::Ptr wpath = new wchar_t[size+1]; - wpath[size] = 0; - mbstowcs(wpath, path.c_str(), path.size()); + wchar_t wpath[MAX_PATH]; + size_t copied = mbstowcs(wpath, path.c_str(), MAX_PATH); + CV_Assert((copied != MAX_PATH) && (copied != (size_t)-1)); ::GetFileAttributesExW(wpath, GetFileExInfoStandard, &all_attrs); #else ::GetFileAttributesExA(path.c_str(), GetFileExInfoStandard, &all_attrs); diff --git a/modules/core/src/system.cpp b/modules/core/src/system.cpp index 7e01ca5ea4..685b5b756d 100644 --- a/modules/core/src/system.cpp +++ b/modules/core/src/system.cpp @@ -411,15 +411,14 @@ string tempfile( const char* suffix ) temp_file = temp_dir + std::wstring(L"\\") + temp_file; DeleteFileW(temp_file.c_str()); - size_t asize = wcstombs(NULL, temp_file.c_str(), 0); - Ptr aname = new char[asize+1]; - aname[asize] = 0; - wcstombs(aname, temp_file.c_str(), asize); + char aname[MAX_PATH]; + size_t copied = wcstombs(aname, temp_file.c_str(), MAX_PATH); + CV_Assert((copied != MAX_PATH) && (copied != (size_t)-1)); fname = std::string(aname); RoUninitialize(); #else - char temp_dir2[MAX_PATH + 1] = { 0 }; - char temp_file[MAX_PATH + 1] = { 0 }; + char temp_dir2[MAX_PATH] = { 0 }; + char temp_file[MAX_PATH] = { 0 }; if (temp_dir == 0 || temp_dir[0] == 0) { From b15addec7066c055849214c544f0c2f02adc7184 Mon Sep 17 00:00:00 2001 From: Alexander Smorkalov Date: Wed, 21 Aug 2013 03:38:20 -0700 Subject: [PATCH 11/11] C4447 warning about main function format suppressed. --- modules/core/perf/perf_main.cpp | 5 +++++ modules/core/src/system.cpp | 6 ++++++ modules/core/test/test_main.cpp | 7 +++++-- 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/modules/core/perf/perf_main.cpp b/modules/core/perf/perf_main.cpp index 79c28a645c..7c899c2446 100644 --- a/modules/core/perf/perf_main.cpp +++ b/modules/core/perf/perf_main.cpp @@ -1,3 +1,8 @@ #include "perf_precomp.hpp" +#ifdef _MSC_VER +# if _MSC_VER >= 1700 +# pragma warning(disable:4447) // Disable warning 'main' signature found without threading model +# endif +#endif CV_PERF_TEST_MAIN(core) diff --git a/modules/core/src/system.cpp b/modules/core/src/system.cpp index 7e01ca5ea4..4257665957 100644 --- a/modules/core/src/system.cpp +++ b/modules/core/src/system.cpp @@ -42,6 +42,12 @@ #include "precomp.hpp" +#ifdef _MSC_VER +# if _MSC_VER >= 1700 +# pragma warning(disable:4447) // Disable warning 'main' signature found without threading model +# endif +#endif + #if defined WIN32 || defined _WIN32 || defined WINCE #ifndef _WIN32_WINNT // This is needed for the declaration of TryEnterCriticalSection in winbase.h with Visual Studio 2005 (and older?) #define _WIN32_WINNT 0x0400 // http://msdn.microsoft.com/en-us/library/ms686857(VS.85).aspx diff --git a/modules/core/test/test_main.cpp b/modules/core/test/test_main.cpp index 3294fab2b0..d5400e20fd 100644 --- a/modules/core/test/test_main.cpp +++ b/modules/core/test/test_main.cpp @@ -1,7 +1,10 @@ -#ifdef HAVE_WINRT - #pragma warning(disable:4447) // Disable warning 'main' signature found without threading model +#ifdef _MSC_VER +# if _MSC_VER >= 1700 +# pragma warning(disable:4447) // Disable warning 'main' signature found without threading model +# endif #endif + #include "test_precomp.hpp" CV_TEST_MAIN("cv")