Merge remote-tracking branch 'upstream/3.4' into merge-3.4

pull/12880/head
Alexander Alekhin 6 years ago
commit 9c23f2f1a6
  1. 6
      apps/traincascade/old_ml.hpp
  2. 8
      cmake/OpenCVDetectCUDA.cmake
  3. 2
      modules/core/include/opencv2/core/types_c.h
  4. 2
      modules/core/src/copy.cpp
  5. 10
      modules/core/test/test_ds.cpp
  6. 14
      modules/dnn/src/op_inf_engine.cpp
  7. 46
      modules/dnn/test/test_torch_importer.cpp
  8. 4
      modules/features2d/src/kaze/KAZEConfig.h
  9. 63
      modules/flann/include/opencv2/flann.hpp
  10. 4
      modules/imgproc/src/canny.cpp
  11. 4
      modules/imgproc/src/deriv.cpp
  12. 2
      modules/imgproc/src/morph.cpp
  13. 6
      modules/imgproc/src/resize.cpp
  14. 10
      modules/imgproc/src/smooth.cpp
  15. 2
      modules/stitching/perf/perf_matchers.cpp
  16. 2
      modules/videoio/src/cap_ffmpeg_impl.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<CvDTreeSplit>{ void operator ()(CvDTreeSplit* o
}
#endif // __cplusplus
#endif // OPENCV_ML_HPP
#endif // OPENCV_OLD_ML_HPP
/* End of file. */

@ -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()

@ -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);

@ -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;
}

@ -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 &)
{
}
}

@ -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<size_t> 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)

@ -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<float>(0, ch, row);
uint8_t *ptrMaxCl = maxCl.ptr<uint8_t>(row);
float *ptrMaxVal = maxVal.ptr<float>(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);
}
}

@ -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"

@ -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 <typename Distance>
class GenericIndex
@ -217,6 +269,17 @@ public:
std::vector<DistanceType>& 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<ElementType>& query, std::vector<int>& indices,
std::vector<DistanceType>& dists, DistanceType radius, const ::cvflann::SearchParams& params);
int radiusSearch(const Mat& query, Mat& indices, Mat& dists,

@ -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;
}

@ -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;
}

@ -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;
}

@ -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;
}

@ -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;
}

@ -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(

@ -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;
}

Loading…
Cancel
Save