diff --git a/apps/traincascade/old_ml.hpp b/apps/traincascade/old_ml.hpp index 75a5d9fffc..bdfe2b40d5 100644 --- a/apps/traincascade/old_ml.hpp +++ b/apps/traincascade/old_ml.hpp @@ -38,8 +38,8 @@ // //M*/ -#ifndef OPENCV_ML_HPP -#define OPENCV_ML_HPP +#ifndef OPENCV_OLD_ML_HPP +#define OPENCV_OLD_ML_HPP #ifdef __cplusplus # include "opencv2/core.hpp" @@ -2038,6 +2038,6 @@ template<> struct DefaultDeleter{ void operator ()(CvDTreeSplit* o } #endif // __cplusplus -#endif // OPENCV_ML_HPP +#endif // OPENCV_OLD_ML_HPP /* End of file. */ diff --git a/cmake/OpenCVDetectCUDA.cmake b/cmake/OpenCVDetectCUDA.cmake index 27bf79bd8e..f9639f7bd4 100644 --- a/cmake/OpenCVDetectCUDA.cmake +++ b/cmake/OpenCVDetectCUDA.cmake @@ -87,6 +87,8 @@ if(CUDA_FOUND) set(__cuda_arch_bin "6.0 6.1") elseif(CUDA_GENERATION STREQUAL "Volta") set(__cuda_arch_bin "7.0") + elseif(CUDA_GENERATION STREQUAL "Turing") + set(__cuda_arch_bin "7.5") elseif(CUDA_GENERATION STREQUAL "Auto") execute_process( COMMAND ${DETECT_ARCHS_COMMAND} WORKING_DIRECTORY "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/" @@ -113,7 +115,7 @@ if(CUDA_FOUND) string(REGEX REPLACE ".*\n" "" _nvcc_out "${_nvcc_out}") #Strip leading warning messages, if any if(NOT _nvcc_res EQUAL 0) message(STATUS "Automatic detection of CUDA generation failed. Going to build for all known architectures.") - set(__cuda_arch_bin "5.3 6.2 7.0") + set(__cuda_arch_bin "5.3 6.2 7.0 7.5") else() set(__cuda_arch_bin "${_nvcc_out}") string(REPLACE "2.1" "2.1(2.0)" __cuda_arch_bin "${__cuda_arch_bin}") @@ -122,8 +124,10 @@ if(CUDA_FOUND) else() if(${CUDA_VERSION} VERSION_LESS "9.0") set(__cuda_arch_bin "2.0 3.0 3.5 3.7 5.0 5.2 6.0 6.1") - else() + elseif(${CUDA_VERSION} VERSION_LESS "10.0") set(__cuda_arch_bin "3.0 3.5 3.7 5.0 5.2 6.0 6.1 7.0") + else() + set(__cuda_arch_bin "3.0 3.5 3.7 5.0 5.2 6.0 6.1 7.0 7.5") endif() endif() endif() diff --git a/modules/core/include/opencv2/core/types_c.h b/modules/core/include/opencv2/core/types_c.h index f745db93d1..9898d20b8e 100644 --- a/modules/core/include/opencv2/core/types_c.h +++ b/modules/core/include/opencv2/core/types_c.h @@ -1353,7 +1353,7 @@ CvSlice; CV_INLINE CvSlice cvSlice( int start, int end ) { -#if !(defined(CV__ENABLE_C_API_CTORS) && defined(__cplusplus)) +#if !(defined(CV__ENABLE_C_API_CTORS) && defined(__cplusplus) && !defined(__CUDACC__)) CvSlice slice = { start, end }; #else CvSlice slice(start, end); diff --git a/modules/core/src/copy.cpp b/modules/core/src/copy.cpp index 98ab15d4ca..7fb850ee38 100644 --- a/modules/core/src/copy.cpp +++ b/modules/core/src/copy.cpp @@ -729,7 +729,7 @@ static bool ipp_flip(Mat &src, Mat &dst, int flip_mode) CV_INSTRUMENT_FUN_IPP(::ipp::iwiMirror, iwSrc, iwDst, ippMode); } - catch(::ipp::IwException) + catch(const ::ipp::IwException &) { return false; } diff --git a/modules/core/test/test_ds.cpp b/modules/core/test/test_ds.cpp index 3a1a00b8b6..64d54c5966 100644 --- a/modules/core/test/test_ds.cpp +++ b/modules/core/test/test_ds.cpp @@ -1032,7 +1032,7 @@ void Core_SeqBaseTest::run( int ) cvClearMemStorage( storage ); } } - catch(int) + catch(const int &) { } } @@ -1200,7 +1200,7 @@ void Core_SeqSortInvTest::run( int ) storage.release(); } } - catch (int) + catch (const int &) { } } @@ -1416,7 +1416,7 @@ void Core_SetTest::run( int ) storage.release(); } } - catch(int) + catch(const int &) { } } @@ -1859,7 +1859,7 @@ void Core_GraphTest::run( int ) storage.release(); } } - catch(int) + catch(const int &) { } } @@ -2121,7 +2121,7 @@ void Core_GraphScanTest::run( int ) storage.release(); } } - catch(int) + catch(const int &) { } } diff --git a/modules/dnn/src/op_inf_engine.cpp b/modules/dnn/src/op_inf_engine.cpp index 9c49a06596..df44ab2303 100644 --- a/modules/dnn/src/op_inf_engine.cpp +++ b/modules/dnn/src/op_inf_engine.cpp @@ -331,8 +331,18 @@ InferenceEngine::StatusCode InfEngineBackendNet::setBatchSize(size_t size, Infer size_t InfEngineBackendNet::getBatchSize() const CV_NOEXCEPT { - CV_Error(Error::StsNotImplemented, ""); - return 0; + size_t batchSize = 0; + for (const auto& inp : inputs) + { + CV_Assert(inp.second); + std::vector dims = inp.second->getDims(); + CV_Assert(!dims.empty()); + if (batchSize != 0) + CV_Assert(batchSize == dims.back()); + else + batchSize = dims.back(); + } + return batchSize; } #if INF_ENGINE_VER_MAJOR_GT(INF_ENGINE_RELEASE_2018R2) diff --git a/modules/dnn/test/test_torch_importer.cpp b/modules/dnn/test/test_torch_importer.cpp index dd7d975af6..0b844452e2 100644 --- a/modules/dnn/test/test_torch_importer.cpp +++ b/modules/dnn/test/test_torch_importer.cpp @@ -287,6 +287,46 @@ TEST_P(Test_Torch_nets, OpenFace_accuracy) normAssert(out, outRef, "", default_l1, default_lInf); } +static Mat getSegmMask(const Mat& scores) +{ + const int rows = scores.size[2]; + const int cols = scores.size[3]; + const int numClasses = scores.size[1]; + + Mat maxCl = Mat::zeros(rows, cols, CV_8UC1); + Mat maxVal(rows, cols, CV_32FC1, Scalar(0)); + for (int ch = 0; ch < numClasses; ch++) + { + for (int row = 0; row < rows; row++) + { + const float *ptrScore = scores.ptr(0, ch, row); + uint8_t *ptrMaxCl = maxCl.ptr(row); + float *ptrMaxVal = maxVal.ptr(row); + for (int col = 0; col < cols; col++) + { + if (ptrScore[col] > ptrMaxVal[col]) + { + ptrMaxVal[col] = ptrScore[col]; + ptrMaxCl[col] = (uchar)ch; + } + } + } + } + return maxCl; +} + +// Computer per-class intersection over union metric. +static void normAssertSegmentation(const Mat& ref, const Mat& test) +{ + CV_Assert_N(ref.dims == 4, test.dims == 4); + const int numClasses = ref.size[1]; + CV_Assert(numClasses == test.size[1]); + + Mat refMask = getSegmMask(ref); + Mat testMask = getSegmMask(test); + EXPECT_EQ(countNonZero(refMask != testMask), 0); +} + TEST_P(Test_Torch_nets, ENet_accuracy) { checkBackend(); @@ -313,14 +353,16 @@ TEST_P(Test_Torch_nets, ENet_accuracy) // Due to numerical instability in Pooling-Unpooling layers (indexes jittering) // thresholds for ENet must be changed. Accuracy of results was checked on // Cityscapes dataset and difference in mIOU with Torch is 10E-4% - normAssert(ref, out, "", 0.00044, /*target == DNN_TARGET_CPU ? 0.453 : */0.5); + normAssert(ref, out, "", 0.00044, /*target == DNN_TARGET_CPU ? 0.453 : */0.552); + normAssertSegmentation(ref, out); const int N = 3; for (int i = 0; i < N; i++) { net.setInput(inputBlob, ""); Mat out = net.forward(); - normAssert(ref, out, "", 0.00044, /*target == DNN_TARGET_CPU ? 0.453 : */0.5); + normAssert(ref, out, "", 0.00044, /*target == DNN_TARGET_CPU ? 0.453 : */0.552); + normAssertSegmentation(ref, out); } } diff --git a/modules/features2d/src/kaze/KAZEConfig.h b/modules/features2d/src/kaze/KAZEConfig.h index 35f8d54b95..d3b76c73f4 100644 --- a/modules/features2d/src/kaze/KAZEConfig.h +++ b/modules/features2d/src/kaze/KAZEConfig.h @@ -5,8 +5,8 @@ * @author Pablo F. Alcantarilla */ -#ifndef __OPENCV_FEATURES_2D_AKAZE_CONFIG_H__ -#define __OPENCV_FEATURES_2D_AKAZE_CONFIG_H__ +#ifndef __OPENCV_FEATURES_2D_KAZE_CONFIG_H__ +#define __OPENCV_FEATURES_2D_KAZE_CONFIG_H__ // OpenCV Includes #include "../precomp.hpp" diff --git a/modules/flann/include/opencv2/flann.hpp b/modules/flann/include/opencv2/flann.hpp index 22c6ffcf19..fec3d067c8 100644 --- a/modules/flann/include/opencv2/flann.hpp +++ b/modules/flann/include/opencv2/flann.hpp @@ -103,6 +103,58 @@ using ::cvflann::KL_Divergence; /** @brief The FLANN nearest neighbor index class. This class is templated with the type of elements for which the index is built. + +`Distance` functor specifies the metric to be used to calculate the distance between two points. +There are several `Distance` functors that are readily available: + +@link cvflann::L2_Simple cv::flann::L2_Simple @endlink- Squared Euclidean distance functor. +This is the simpler, unrolled version. This is preferable for very low dimensionality data (eg 3D points) + +@link cvflann::L2 cv::flann::L2 @endlink- Squared Euclidean distance functor, optimized version. + +@link cvflann::L1 cv::flann::L1 @endlink - Manhattan distance functor, optimized version. + +@link cvflann::MinkowskiDistance cv::flann::MinkowskiDistance @endlink - The Minkowsky distance functor. +This is highly optimised with loop unrolling. +The computation of squared root at the end is omitted for efficiency. + +@link cvflann::MaxDistance cv::flann::MaxDistance @endlink - The max distance functor. It computes the +maximum distance between two vectors. This distance is not a valid kdtree distance, it's not +dimensionwise additive. + +@link cvflann::HammingLUT cv::flann::HammingLUT @endlink - %Hamming distance functor. It counts the bit +differences between two strings using a lookup table implementation. + +@link cvflann::Hamming cv::flann::Hamming @endlink - %Hamming distance functor. Population count is +performed using library calls, if available. Lookup table implementation is used as a fallback. + +@link cvflann::Hamming2 cv::flann::Hamming2 @endlink- %Hamming distance functor. Population count is +implemented in 12 arithmetic operations (one of which is multiplication). + +@link cvflann::HistIntersectionDistance cv::flann::HistIntersectionDistance @endlink - The histogram +intersection distance functor. + +@link cvflann::HellingerDistance cv::flann::HellingerDistance @endlink - The Hellinger distance functor. + +@link cvflann::ChiSquareDistance cv::flann::ChiSquareDistance @endlink - The chi-square distance functor. + +@link cvflann::KL_Divergence cv::flann::KL_Divergence @endlink - The Kullback-Leibler divergence functor. + +Although the provided implementations cover a vast range of cases, it is also possible to use +a custom implementation. The distance functor is a class whose `operator()` computes the distance +between two features. If the distance is also a kd-tree compatible distance, it should also provide an +`accum_dist()` method that computes the distance between individual feature dimensions. + +In addition to `operator()` and `accum_dist()`, a distance functor should also define the +`ElementType` and the `ResultType` as the types of the elements it operates on and the type of the +result it computes. If a distance functor can be used as a kd-tree distance (meaning that the full +distance between a pair of features can be accumulated from the partial distances between the +individual dimensions) a typedef `is_kdtree_distance` should be present inside the distance functor. +If the distance is not a kd-tree distance, but it's a distance in a vector space (the individual +dimensions of the elements it operates on can be accessed independently) a typedef +`is_vector_space_distance` should be defined inside the functor. If neither typedef is defined, the +distance is assumed to be a metric distance and will only be used with indexes operating on +generic metric distances. */ template class GenericIndex @@ -217,6 +269,17 @@ public: std::vector& dists, int knn, const ::cvflann::SearchParams& params); void knnSearch(const Mat& queries, Mat& indices, Mat& dists, int knn, const ::cvflann::SearchParams& params); + /** @brief Performs a radius nearest neighbor search for a given query point using the index. + + @param query The query point. + @param indices Vector that will contain the indices of the nearest neighbors found. + @param dists Vector that will contain the distances to the nearest neighbors found. It has the same + number of elements as indices. + @param radius The search radius. + @param params SearchParams + + This function returns the number of nearest neighbors found. + */ int radiusSearch(const std::vector& query, std::vector& indices, std::vector& dists, DistanceType radius, const ::cvflann::SearchParams& params); int radiusSearch(const Mat& query, Mat& indices, Mat& dists, diff --git a/modules/imgproc/src/canny.cpp b/modules/imgproc/src/canny.cpp index 6b54807db6..751b893c41 100644 --- a/modules/imgproc/src/canny.cpp +++ b/modules/imgproc/src/canny.cpp @@ -93,7 +93,7 @@ static bool ipp_Canny(const Mat& src , const Mat& dx_, const Mat& dy_, Mat& dst, CV_INSTRUMENT_FUN_IPP(::ipp::iwiFilterCannyDeriv, iwSrcDx, iwSrcDy, iwDst, low, high, ::ipp::IwiFilterCannyDerivParams(norm)); } - catch (::ipp::IwException ex) + catch (const ::ipp::IwException &) { return false; } @@ -119,7 +119,7 @@ static bool ipp_Canny(const Mat& src , const Mat& dx_, const Mat& dy_, Mat& dst, CV_INSTRUMENT_FUN_IPP(::ipp::iwiFilterCanny, iwSrc, iwDst, low, high, ::ipp::IwiFilterCannyParams(ippFilterSobel, kernel, norm), ippBorderRepl); } - catch (::ipp::IwException) + catch (const ::ipp::IwException &) { return false; } diff --git a/modules/imgproc/src/deriv.cpp b/modules/imgproc/src/deriv.cpp index b4c61cad4d..2dc684fb2d 100644 --- a/modules/imgproc/src/deriv.cpp +++ b/modules/imgproc/src/deriv.cpp @@ -337,7 +337,7 @@ static bool ipp_Deriv(InputArray _src, OutputArray _dst, int dx, int dy, int ksi if(useScale) CV_INSTRUMENT_FUN_IPP(::ipp::iwiScale, iwDstProc, iwDst, scale, delta, ::ipp::IwiScaleParams(ippAlgHintFast)); } - catch (::ipp::IwException) + catch (const ::ipp::IwException &) { return false; } @@ -765,7 +765,7 @@ static bool ipp_Laplacian(InputArray _src, OutputArray _dst, int ksize, double s CV_INSTRUMENT_FUN_IPP(::ipp::iwiScale, iwDstProc, iwDst, scale, delta); } - catch (::ipp::IwException ex) + catch (const ::ipp::IwException &) { return false; } diff --git a/modules/imgproc/src/morph.cpp b/modules/imgproc/src/morph.cpp index 66fae07fae..08a9969394 100644 --- a/modules/imgproc/src/morph.cpp +++ b/modules/imgproc/src/morph.cpp @@ -1299,7 +1299,7 @@ static bool ippMorph(int op, int src_type, int dst_type, CV_INSTRUMENT_FUN_IPP(::ipp::iwiFilterMorphology, iwSrc, iwDst, morphType, iwMask, ::ipp::IwDefault(), iwBorderType); } } - catch(::ipp::IwException ex) + catch(const ::ipp::IwException &) { return false; } diff --git a/modules/imgproc/src/resize.cpp b/modules/imgproc/src/resize.cpp index 688f4c7ff0..7eeefc7098 100644 --- a/modules/imgproc/src/resize.cpp +++ b/modules/imgproc/src/resize.cpp @@ -3241,7 +3241,7 @@ public: ::ipp::IwiTile tile = ::ipp::IwiRoi(0, range.start, m_dst.m_size.width, range.end - range.start); CV_INSTRUMENT_FUN_IPP(iwiResize, m_src, m_dst, ippBorderRepl, tile); } - catch(::ipp::IwException) + catch(const ::ipp::IwException &) { m_ok = false; return; @@ -3291,7 +3291,7 @@ public: ::ipp::IwiTile tile = ::ipp::IwiRoi(0, range.start, m_dst.m_size.width, range.end - range.start); CV_INSTRUMENT_FUN_IPP(iwiWarpAffine, m_src, m_dst, tile); } - catch(::ipp::IwException) + catch(const ::ipp::IwException &) { m_ok = false; return; @@ -3387,7 +3387,7 @@ static bool ipp_resize(const uchar * src_data, size_t src_step, int src_width, i if(!ok) return false; } - catch(::ipp::IwException) + catch(const ::ipp::IwException &) { return false; } diff --git a/modules/imgproc/src/smooth.cpp b/modules/imgproc/src/smooth.cpp index bb31c50874..0da6e9431b 100644 --- a/modules/imgproc/src/smooth.cpp +++ b/modules/imgproc/src/smooth.cpp @@ -1510,7 +1510,7 @@ static bool ipp_boxfilter(Mat &src, Mat &dst, Size ksize, Point anchor, bool nor CV_INSTRUMENT_FUN_IPP(::ipp::iwiFilterBox, iwSrc, iwDst, iwKSize, ::ipp::IwDefault(), ippBorder); } - catch (::ipp::IwException) + catch (const ::ipp::IwException &) { return false; } @@ -4000,7 +4000,7 @@ public: ::ipp::IwiTile tile = ::ipp::IwiRoi(0, range.start, m_dst.m_size.width, range.end - range.start); CV_INSTRUMENT_FUN_IPP(::ipp::iwiFilterGaussian, m_src, m_dst, m_kernelSize, m_sigma, ::ipp::IwDefault(), m_border, tile); } - catch(::ipp::IwException e) + catch(const ::ipp::IwException &) { *m_pOk = false; return; @@ -4067,7 +4067,7 @@ static bool ipp_GaussianBlur(InputArray _src, OutputArray _dst, Size ksize, CV_INSTRUMENT_FUN_IPP(::ipp::iwiFilterGaussian, iwSrc, iwDst, ksize.width, sigma1, ::ipp::IwDefault(), ippBorder); } } - catch (::ipp::IwException ex) + catch (const ::ipp::IwException &) { return false; } @@ -5873,7 +5873,7 @@ public: ::ipp::IwiTile tile = ::ipp::IwiRoi(0, range.start, dst.m_size.width, range.end - range.start); CV_INSTRUMENT_FUN_IPP(::ipp::iwiFilterBilateral, src, dst, radius, valSquareSigma, posSquareSigma, ::ipp::IwDefault(), borderType, tile); } - catch(::ipp::IwException) + catch(const ::ipp::IwException &) { *pOk = false; return; @@ -5928,7 +5928,7 @@ static bool ipp_bilateralFilter(Mat &src, Mat &dst, int d, double sigmaColor, do CV_INSTRUMENT_FUN_IPP(::ipp::iwiFilterBilateral, iwSrc, iwDst, radius, valSquareSigma, posSquareSigma, ::ipp::IwDefault(), ippBorder); } } - catch (::ipp::IwException) + catch (const ::ipp::IwException &) { return false; } diff --git a/modules/stitching/perf/perf_matchers.cpp b/modules/stitching/perf/perf_matchers.cpp index 505fe59449..28e19c85f3 100644 --- a/modules/stitching/perf/perf_matchers.cpp +++ b/modules/stitching/perf/perf_matchers.cpp @@ -103,7 +103,7 @@ PERF_TEST_P( match, bestOf2Nearest, TEST_DETECTORS) Mat R (pairwise_matches.H, Range::all(), Range(0, 2)); // separate transform matrix, use lower error on rotations SANITY_CHECK(dist, 1., ERROR_ABSOLUTE); - SANITY_CHECK(R, .015, ERROR_ABSOLUTE); + SANITY_CHECK(R, .06, ERROR_ABSOLUTE); } PERF_TEST_P( matchVector, bestOf2NearestVectorFeatures, testing::Combine( diff --git a/modules/videoio/src/cap_ffmpeg_impl.hpp b/modules/videoio/src/cap_ffmpeg_impl.hpp index fb306c7fc7..26a9369993 100644 --- a/modules/videoio/src/cap_ffmpeg_impl.hpp +++ b/modules/videoio/src/cap_ffmpeg_impl.hpp @@ -1519,8 +1519,6 @@ static AVFrame * icv_alloc_picture_FFMPEG(int pix_fmt, int width, int height, bo _opencv_ffmpeg_av_image_fill_arrays(picture, picture_buf, (AVPixelFormat) pix_fmt, width, height); } - else { - } return picture; }