diff --git a/doc/tutorials/introduction/linux_gcc_cmake/linux_gcc_cmake.rst b/doc/tutorials/introduction/linux_gcc_cmake/linux_gcc_cmake.rst index e4c089ca7c..f582d32086 100644 --- a/doc/tutorials/introduction/linux_gcc_cmake/linux_gcc_cmake.rst +++ b/doc/tutorials/introduction/linux_gcc_cmake/linux_gcc_cmake.rst @@ -25,8 +25,8 @@ Let's use a simple program such as DisplayImage.cpp shown below. .. code-block:: cpp - #include - #include + #include + #include using namespace cv; @@ -55,9 +55,10 @@ Now you have to create your CMakeLists.txt file. It should look like this: .. code-block:: cmake + cmake_minimum_required(VERSION 2.8) project( DisplayImage ) find_package( OpenCV REQUIRED ) - add_executable( DisplayImage DisplayImage ) + add_executable( DisplayImage DisplayImage.cpp ) target_link_libraries( DisplayImage ${OpenCV_LIBS} ) Generate the executable diff --git a/modules/calib3d/src/calibration.cpp b/modules/calib3d/src/calibration.cpp index a634485066..e483935028 100644 --- a/modules/calib3d/src/calibration.cpp +++ b/modules/calib3d/src/calibration.cpp @@ -3360,7 +3360,11 @@ void cv::projectPoints( InputArray _opoints, CvMat c_cameraMatrix = cameraMatrix; CvMat c_rvec = rvec, c_tvec = tvec; + double dc0buf[5]={0}; + Mat dc0(5,1,CV_64F,dc0buf); Mat distCoeffs = _distCoeffs.getMat(); + if( distCoeffs.empty() ) + distCoeffs = dc0; CvMat c_distCoeffs = distCoeffs; int ndistCoeffs = distCoeffs.rows + distCoeffs.cols - 1; @@ -3375,8 +3379,7 @@ void cv::projectPoints( InputArray _opoints, pdpddist = &(dpddist = jacobian.colRange(10, 10+ndistCoeffs)); } - cvProjectPoints2( &c_objectPoints, &c_rvec, &c_tvec, &c_cameraMatrix, - (distCoeffs.empty())? 0: &c_distCoeffs, + cvProjectPoints2( &c_objectPoints, &c_rvec, &c_tvec, &c_cameraMatrix, &c_distCoeffs, &c_imagePoints, pdpdrot, pdpdt, pdpdf, pdpdc, pdpddist, aspectRatio ); } diff --git a/modules/calib3d/src/modelest.cpp b/modules/calib3d/src/modelest.cpp index 8cd5049795..d49524b6bd 100644 --- a/modules/calib3d/src/modelest.cpp +++ b/modules/calib3d/src/modelest.cpp @@ -472,23 +472,24 @@ int cv::estimateAffine3D(InputArray _from, InputArray _to, double param1, double param2) { Mat from = _from.getMat(), to = _to.getMat(); - int count = from.checkVector(3, CV_32F); + int count = from.checkVector(3); - CV_Assert( count >= 0 && to.checkVector(3, CV_32F) == count ); + CV_Assert( count >= 0 && to.checkVector(3) == count ); _out.create(3, 4, CV_64F); Mat out = _out.getMat(); - _inliers.create(count, 1, CV_8U, -1, true); - Mat inliers = _inliers.getMat(); + Mat inliers(1, count, CV_8U); inliers = Scalar::all(1); Mat dFrom, dTo; from.convertTo(dFrom, CV_64F); to.convertTo(dTo, CV_64F); + dFrom = dFrom.reshape(3, 1); + dTo = dTo.reshape(3, 1); CvMat F3x4 = out; - CvMat mask = inliers; + CvMat mask = inliers; CvMat m1 = dFrom; CvMat m2 = dTo; @@ -496,5 +497,9 @@ int cv::estimateAffine3D(InputArray _from, InputArray _to, param1 = param1 <= 0 ? 3 : param1; param2 = (param2 < epsilon) ? 0.99 : (param2 > 1 - epsilon) ? 0.99 : param2; - return Affine3DEstimator().runRANSAC(&m1, &m2, &F3x4, &mask, param1, param2 ); + int ok = Affine3DEstimator().runRANSAC(&m1, &m2, &F3x4, &mask, param1, param2 ); + if( _inliers.needed() ) + transpose(inliers, _inliers); + + return ok; } diff --git a/modules/core/doc/basic_structures.rst b/modules/core/doc/basic_structures.rst index bac7194cb4..2e680229ee 100644 --- a/modules/core/doc/basic_structures.rst +++ b/modules/core/doc/basic_structures.rst @@ -219,7 +219,31 @@ TermCriteria ------------ .. ocv:class:: TermCriteria -Template class defining termination criteria for iterative algorithms. + The class defining termination criteria for iterative algorithms. You can initialize it by default constructor and then override any parameters, or the structure may be fully initialized using the advanced variant of the constructor. + +TermCriteria::TermCriteria +-------------------------- +The constructors. + +.. ocv:function:: TermCriteria::TermCriteria() + +.. ocv:function:: TermCriteria::TermCriteria(int type, int maxCount, double epsilon) + +.. ocv:function:: TermCriteria::TermCriteria(const CvTermCriteria& criteria) + + :param type: The type of termination criteria: ``TermCriteria::COUNT``, ``TermCriteria::EPS`` or ``TermCriteria::COUNT`` + ``TermCriteria::EPS``. + + :param maxCount: The maximum number of iterations or elements to compute. + + :param epsilon: The desired accuracy or change in parameters at which the iterative algorithm stops. + + :param criteria: Termination criteria in the deprecated ``CvTermCriteria`` format. + +TermCriteria::operator CvTermCriteria +------------------------------------- +Converts to the deprecated ``CvTermCriteria`` format. + +.. ocv:function:: TermCriteria::operator CvTermCriteria() const Matx ---- diff --git a/modules/core/doc/drawing_functions.rst b/modules/core/doc/drawing_functions.rst index c8b1e58860..8884f19283 100644 --- a/modules/core/doc/drawing_functions.rst +++ b/modules/core/doc/drawing_functions.rst @@ -245,7 +245,6 @@ Calculates the width and height of a text string. The function ``getTextSize`` calculates and returns the size of a box that contains the specified text. That is, the following code renders some text, the tight box surrounding it, and the baseline: :: - // Use "y" to show that the baseLine is about string text = "Funny text inside the box"; int fontFace = FONT_HERSHEY_SCRIPT_SIMPLEX; double fontScale = 2; diff --git a/modules/core/include/opencv2/core/core.hpp b/modules/core/include/opencv2/core/core.hpp index afe7690817..aeba6648d4 100644 --- a/modules/core/include/opencv2/core/core.hpp +++ b/modules/core/include/opencv2/core/core.hpp @@ -2037,10 +2037,10 @@ public: //! default constructor TermCriteria(); //! full constructor - TermCriteria(int _type, int _maxCount, double _epsilon); + TermCriteria(int type, int maxCount, double epsilon); //! conversion from CvTermCriteria TermCriteria(const CvTermCriteria& criteria); - //! conversion from CvTermCriteria + //! conversion to CvTermCriteria operator CvTermCriteria() const; int type; //!< the type of termination criteria: COUNT, EPS or COUNT + EPS diff --git a/modules/core/perf/perf_addWeighted.cpp b/modules/core/perf/perf_addWeighted.cpp index fd1ac1ba13..70720d0ac5 100644 --- a/modules/core/perf/perf_addWeighted.cpp +++ b/modules/core/perf/perf_addWeighted.cpp @@ -6,7 +6,7 @@ using namespace perf; using std::tr1::make_tuple; using std::tr1::get; -#define TYPICAL_MAT_TYPES_ADWEIGHTED CV_8UC1, CV_8UC4, CV_8SC1, CV_16UC1, CV_16SC1, CV_32SC1, CV_32SC4 +#define TYPICAL_MAT_TYPES_ADWEIGHTED CV_8UC1, CV_8UC4, CV_8SC1, CV_16UC1, CV_16SC1, CV_32SC1 #define TYPICAL_MATS_ADWEIGHTED testing::Combine(testing::Values(szVGA, sz720p, sz1080p), testing::Values(TYPICAL_MAT_TYPES_ADWEIGHTED)) PERF_TEST_P(Size_MatType, addWeighted, TYPICAL_MATS_ADWEIGHTED) diff --git a/modules/core/perf/perf_arithm.cpp b/modules/core/perf/perf_arithm.cpp index 962a9e00b1..22d7def2c9 100644 --- a/modules/core/perf/perf_arithm.cpp +++ b/modules/core/perf/perf_arithm.cpp @@ -6,7 +6,7 @@ using namespace perf; using std::tr1::make_tuple; using std::tr1::get; -#define TYPICAL_MAT_SIZES_CORE_ARITHM TYPICAL_MAT_SIZES +#define TYPICAL_MAT_SIZES_CORE_ARITHM ::szVGA, ::sz720p, ::sz1080p #define TYPICAL_MAT_TYPES_CORE_ARITHM CV_8UC1, CV_8SC1, CV_16SC1, CV_16SC2, CV_16SC3, CV_16SC4, CV_8UC4, CV_32SC1, CV_32FC1 #define TYPICAL_MATS_CORE_ARITHM testing::Combine( testing::Values( TYPICAL_MAT_SIZES_CORE_ARITHM ), testing::Values( TYPICAL_MAT_TYPES_CORE_ARITHM ) ) diff --git a/modules/core/perf/perf_bitwise.cpp b/modules/core/perf/perf_bitwise.cpp index d31e019703..64a8dd8bd9 100644 --- a/modules/core/perf/perf_bitwise.cpp +++ b/modules/core/perf/perf_bitwise.cpp @@ -19,7 +19,7 @@ PERF_TEST_P(Size_MatType, bitwise_not, TYPICAL_MATS_BITW_ARITHM) cv::Mat c = Mat(sz, type); declare.in(a, WARMUP_RNG).out(c); - declare.time(100); + declare.iterations(200); TEST_CYCLE() cv::bitwise_not(a, c); diff --git a/modules/core/perf/perf_compare.cpp b/modules/core/perf/perf_compare.cpp index abbd0d020a..32f8ba7682 100644 --- a/modules/core/perf/perf_compare.cpp +++ b/modules/core/perf/perf_compare.cpp @@ -13,7 +13,7 @@ typedef perf::TestBaseWithParam Size_MatType_CmpType; PERF_TEST_P( Size_MatType_CmpType, compare, testing::Combine( - testing::Values(TYPICAL_MAT_SIZES), + testing::Values(::perf::szVGA, ::perf::sz1080p), testing::Values(CV_8UC1, CV_8UC4, CV_8SC1, CV_16UC1, CV_16SC1, CV_32SC1, CV_32FC1), testing::ValuesIn(CmpType::all()) ) diff --git a/modules/core/perf/perf_convertTo.cpp b/modules/core/perf/perf_convertTo.cpp index 77c0eadb77..c4e832f1f7 100644 --- a/modules/core/perf/perf_convertTo.cpp +++ b/modules/core/perf/perf_convertTo.cpp @@ -29,6 +29,7 @@ PERF_TEST_P( Size_DepthSrc_DepthDst_Channels_alpha, convertTo, Mat src(sz, CV_MAKETYPE(depthSrc, channels)); randu(src, 0, 255); Mat dst(sz, CV_MAKETYPE(depthDst, channels)); + declare.iterations(500); TEST_CYCLE() src.convertTo(dst, depthDst, alpha); diff --git a/modules/core/perf/perf_norm.cpp b/modules/core/perf/perf_norm.cpp index 4fb498eb30..2df2d4a1e0 100644 --- a/modules/core/perf/perf_norm.cpp +++ b/modules/core/perf/perf_norm.cpp @@ -131,7 +131,7 @@ PERF_TEST_P(Size_MatType_NormType, normalize, PERF_TEST_P(Size_MatType_NormType, normalize_mask, testing::Combine( - testing::Values(TYPICAL_MAT_SIZES), + testing::Values(::perf::szVGA, ::perf::sz1080p), testing::Values(TYPICAL_MAT_TYPES), testing::Values((int)NORM_INF, (int)NORM_L1, (int)NORM_L2) ) @@ -192,6 +192,7 @@ PERF_TEST_P( Size_MatType, normalize_minmax, TYPICAL_MATS ) Mat dst(sz, matType); declare.in(src, WARMUP_RNG).out(dst); + declare.time(30); TEST_CYCLE() normalize(src, dst, 20., 100., NORM_MINMAX); diff --git a/modules/core/src/matrix.cpp b/modules/core/src/matrix.cpp index 0feae26829..9046dee727 100644 --- a/modules/core/src/matrix.cpp +++ b/modules/core/src/matrix.cpp @@ -1975,6 +1975,14 @@ void cv::transpose( InputArray _src, OutputArray _dst ) _dst.create(src.cols, src.rows, src.type()); Mat dst = _dst.getMat(); + // handle the case of single-column/single-row matrices, stored in STL vectors. + if( src.rows != dst.cols || src.cols != dst.rows ) + { + CV_Assert( src.size() == dst.size() && (src.cols == 1 || src.rows == 1) ); + src.copyTo(dst); + return; + } + if( dst.data == src.data ) { TransposeInplaceFunc func = transposeInplaceTab[esz]; diff --git a/modules/features2d/doc/common_interfaces_of_descriptor_matchers.rst b/modules/features2d/doc/common_interfaces_of_descriptor_matchers.rst index cf1dab63bf..533d2e9cae 100644 --- a/modules/features2d/doc/common_interfaces_of_descriptor_matchers.rst +++ b/modules/features2d/doc/common_interfaces_of_descriptor_matchers.rst @@ -267,7 +267,7 @@ BFMatcher::BFMatcher -------------------- Brute-force matcher constructor. -.. ocv:function:: BFMatcher::BFMatcher( int normType, bool crossCheck=false ) +.. ocv:function:: BFMatcher::BFMatcher( int normType=NORM_L2, bool crossCheck=false ) :param normType: One of ``NORM_L1``, ``NORM_L2``, ``NORM_HAMMING``, ``NORM_HAMMING2``. ``L1`` and ``L2`` norms are preferable choices for SIFT and SURF descriptors, ``NORM_HAMMING`` should be used with ORB and BRIEF, ``NORM_HAMMING2`` should be used with ORB when ``WTA_K==3`` or ``4`` (see ORB::ORB constructor description). diff --git a/modules/features2d/include/opencv2/features2d/features2d.hpp b/modules/features2d/include/opencv2/features2d/features2d.hpp index 3d114254bb..01ef28d063 100644 --- a/modules/features2d/include/opencv2/features2d/features2d.hpp +++ b/modules/features2d/include/opencv2/features2d/features2d.hpp @@ -1199,13 +1199,14 @@ protected: class CV_EXPORTS_W BFMatcher : public DescriptorMatcher { public: - CV_WRAP BFMatcher( int normType, bool crossCheck=false ); + CV_WRAP BFMatcher( int normType=NORM_L2, bool crossCheck=false ); virtual ~BFMatcher() {} virtual bool isMaskSupported() const { return true; } virtual Ptr clone( bool emptyTrainData=false ) const; + AlgorithmInfo* info() const; protected: virtual void knnMatchImpl( const Mat& queryDescriptors, vector >& matches, int k, const vector& masks=vector(), bool compactResult=false ); @@ -1239,6 +1240,7 @@ public: virtual Ptr clone( bool emptyTrainData=false ) const; + AlgorithmInfo* info() const; protected: static void convertToDMatches( const DescriptorCollection& descriptors, const Mat& indices, const Mat& distances, diff --git a/modules/features2d/src/features2d_init.cpp b/modules/features2d/src/features2d_init.cpp index 80d2b1d963..4bfcd65ad9 100644 --- a/modules/features2d/src/features2d_init.cpp +++ b/modules/features2d/src/features2d_init.cpp @@ -161,6 +161,16 @@ CV_INIT_ALGORITHM(GridAdaptedFeatureDetector, "Feature2D.Grid", obj.info()->addParam(obj, "gridRows", obj.gridRows); obj.info()->addParam(obj, "gridCols", obj.gridCols)); +//////////////////////////////////////////////////////////////////////////////////////////////////////////// + +CV_INIT_ALGORITHM(BFMatcher, "DescriptorMatcher.BFMatcher", + obj.info()->addParam(obj, "normType", obj.normType); + obj.info()->addParam(obj, "crossCheck", obj.crossCheck)); + +CV_INIT_ALGORITHM(FlannBasedMatcher, "DescriptorMatcher.FlannBasedMatcher",); + +/////////////////////////////////////////////////////////////////////////////////////////////////////////// + bool cv::initModule_features2d(void) { bool all = true; @@ -175,6 +185,8 @@ bool cv::initModule_features2d(void) all &= !HarrisDetector_info_auto.name().empty(); all &= !DenseFeatureDetector_info_auto.name().empty(); all &= !GridAdaptedFeatureDetector_info_auto.name().empty(); + all &= !BFMatcher_info_auto.name().empty(); + all &= !FlannBasedMatcher_info_auto.name().empty(); return all; } diff --git a/modules/features2d/test/test_matchers_algorithmic.cpp b/modules/features2d/test/test_matchers_algorithmic.cpp index a3a5efeac2..d76715dd95 100644 --- a/modules/features2d/test/test_matchers_algorithmic.cpp +++ b/modules/features2d/test/test_matchers_algorithmic.cpp @@ -532,12 +532,12 @@ void CV_DescriptorMatcherTest::run( int ) TEST( Features2d_DescriptorMatcher_BruteForce, regression ) { - CV_DescriptorMatcherTest test( "descriptor-matcher-brute-force", new BFMatcher(NORM_L2), 0.01f ); + CV_DescriptorMatcherTest test( "descriptor-matcher-brute-force", Algorithm::create("DescriptorMatcher.BFMatcher"), 0.01f ); test.safe_run(); } TEST( Features2d_DescriptorMatcher_FlannBased, regression ) { - CV_DescriptorMatcherTest test( "descriptor-matcher-flann-based", new FlannBasedMatcher, 0.04f ); + CV_DescriptorMatcherTest test( "descriptor-matcher-flann-based", Algorithm::create("DescriptorMatcher.FlannBasedMatcher"), 0.04f ); test.safe_run(); } diff --git a/modules/flann/include/opencv2/flann/lsh_table.h b/modules/flann/include/opencv2/flann/lsh_table.h index 126fb2a992..a30642a480 100644 --- a/modules/flann/include/opencv2/flann/lsh_table.h +++ b/modules/flann/include/opencv2/flann/lsh_table.h @@ -261,6 +261,16 @@ private: */ void initialize(size_t key_size) { + const size_t key_size_lower_bound = 1; + //a value (size_t(1) << key_size) must fit the size_t type so key_size has to be strictly less than size of size_t + const size_t key_size_upper_bound = std::min(sizeof(BucketKey) * CHAR_BIT + 1, sizeof(size_t) * CHAR_BIT); + if (key_size < key_size_lower_bound || key_size >= key_size_upper_bound) + { + std::stringstream errorMessage; + errorMessage << "Invalid key_size (=" << key_size << "). Valid values for your system are " << key_size_lower_bound << " <= key_size < " << key_size_upper_bound << "."; + CV_Error(CV_StsBadArg, errorMessage.str()); + } + speed_level_ = kHash; key_size_ = (unsigned)key_size; } @@ -273,10 +283,10 @@ private: if (speed_level_ == kArray) return; // Use an array if it will be more than half full - if (buckets_space_.size() > (unsigned int)((1 << key_size_) / 2)) { + if (buckets_space_.size() > ((size_t(1) << key_size_) / 2)) { speed_level_ = kArray; // Fill the array version of it - buckets_speed_.resize(1 << key_size_); + buckets_speed_.resize(size_t(1) << key_size_); for (BucketsSpace::const_iterator key_bucket = buckets_space_.begin(); key_bucket != buckets_space_.end(); ++key_bucket) buckets_speed_[key_bucket->first] = key_bucket->second; // Empty the hash table @@ -287,9 +297,9 @@ private: // If the bitset is going to use less than 10% of the RAM of the hash map (at least 1 size_t for the key and two // for the vector) or less than 512MB (key_size_ <= 30) if (((std::max(buckets_space_.size(), buckets_speed_.size()) * CHAR_BIT * 3 * sizeof(BucketKey)) / 10 - >= size_t(1 << key_size_)) || (key_size_ <= 32)) { + >= (size_t(1) << key_size_)) || (key_size_ <= 32)) { speed_level_ = kBitsetHash; - key_bitset_.resize(1 << key_size_); + key_bitset_.resize(size_t(1) << key_size_); key_bitset_.reset(); // Try with the BucketsSpace for (BucketsSpace::const_iterator key_bucket = buckets_space_.begin(); key_bucket != buckets_space_.end(); ++key_bucket) key_bitset_.set(key_bucket->first); diff --git a/modules/flann/test/test_lshtable_badarg.cpp b/modules/flann/test/test_lshtable_badarg.cpp new file mode 100644 index 0000000000..9e42335c2c --- /dev/null +++ b/modules/flann/test/test_lshtable_badarg.cpp @@ -0,0 +1,91 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// Intel License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2000, Intel Corporation, all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of Intel Corporation may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors be liable for any direct, +// indirect, incidental, special, exemplary, or consequential damages +// (including, but not limited to, procurement of substitute goods or services; +// loss of use, data, or profits; or business interruption) however caused +// and on any theory of liability, whether in contract, strict liability, +// or tort (including negligence or otherwise) arising in any way out of +// the use of this software, even if advised of the possibility of such damage. +// +//M*/ + +#include "test_precomp.hpp" + +using namespace cv; + +class CV_LshTableBadArgTest : public cvtest::BadArgTest +{ +protected: + void run(int); + void run_func(void) {}; + + struct Caller + { + int table_number, key_size, multi_probe_level; + Mat features; + + void operator()() const + { + flann::LshIndexParams indexParams(table_number, key_size, multi_probe_level); + flann::Index lsh(features, indexParams); + } + }; +}; + +void CV_LshTableBadArgTest::run( int /* start_from */ ) +{ + RNG &rng = ts->get_rng(); + + Caller caller; + Size featuresSize = cvtest::randomSize(rng, 10.0); + caller.features = cvtest::randomMat(rng, featuresSize, CV_8UC1, 0, 255, false); + caller.table_number = 12; + caller.multi_probe_level = 2; + + int errors = 0; + caller.key_size = 0; + errors += run_test_case(CV_StsBadArg, "key_size is zero", caller); + + caller.key_size = static_cast(sizeof(size_t) * CHAR_BIT); + errors += run_test_case(CV_StsBadArg, "key_size is too big", caller); + + caller.key_size += cvtest::randInt(rng) % 100; + errors += run_test_case(CV_StsBadArg, "key_size is too big", caller); + + if (errors != 0) + ts->set_failed_test_info(cvtest::TS::FAIL_MISMATCH); + else + ts->set_failed_test_info(cvtest::TS::OK); +} + +TEST(Flann_LshTable, badarg) { CV_LshTableBadArgTest test; test.safe_run(); } diff --git a/modules/flann/test/test_main.cpp b/modules/flann/test/test_main.cpp new file mode 100644 index 0000000000..6b24993447 --- /dev/null +++ b/modules/flann/test/test_main.cpp @@ -0,0 +1,3 @@ +#include "test_precomp.hpp" + +CV_TEST_MAIN("cv") diff --git a/modules/flann/test/test_precomp.cpp b/modules/flann/test/test_precomp.cpp new file mode 100644 index 0000000000..5956e13e3e --- /dev/null +++ b/modules/flann/test/test_precomp.cpp @@ -0,0 +1 @@ +#include "test_precomp.hpp" diff --git a/modules/flann/test/test_precomp.hpp b/modules/flann/test/test_precomp.hpp new file mode 100644 index 0000000000..809a97e702 --- /dev/null +++ b/modules/flann/test/test_precomp.hpp @@ -0,0 +1,17 @@ +#ifdef __GNUC__ +# pragma GCC diagnostic ignored "-Wmissing-declarations" +# if defined __clang__ || defined __APPLE__ +# pragma GCC diagnostic ignored "-Wmissing-prototypes" +# pragma GCC diagnostic ignored "-Wextra" +# endif +#endif + +#ifndef __OPENCV_TEST_PRECOMP_HPP__ +#define __OPENCV_TEST_PRECOMP_HPP__ + +#include "opencv2/ts/ts.hpp" +#include "opencv2/core/core.hpp" +#include "opencv2/flann/flann.hpp" +#include + +#endif diff --git a/modules/highgui/doc/reading_and_writing_images_and_video.rst b/modules/highgui/doc/reading_and_writing_images_and_video.rst index 42e3eea807..b0ae2d8b9a 100644 --- a/modules/highgui/doc/reading_and_writing_images_and_video.rst +++ b/modules/highgui/doc/reading_and_writing_images_and_video.rst @@ -487,7 +487,7 @@ VideoWriter constructors :param filename: Name of the output video file. - :param fourcc: 4-character code of codec used to compress the frames. For example, ``CV_FOURCC('P','I','M,'1')`` is a MPEG-1 codec, ``CV_FOURCC('M','J','P','G')`` is a motion-jpeg codec etc. + :param fourcc: 4-character code of codec used to compress the frames. For example, ``CV_FOURCC('P','I','M,'1')`` is a MPEG-1 codec, ``CV_FOURCC('M','J','P','G')`` is a motion-jpeg codec etc. List of codes can be obtained at `Video Codecs by FOURCC `_ page. :param fps: Framerate of the created video stream. diff --git a/modules/highgui/test/test_grfmt.cpp b/modules/highgui/test/test_grfmt.cpp index c408d89a4d..8366fcdffc 100644 --- a/modules/highgui/test/test_grfmt.cpp +++ b/modules/highgui/test/test_grfmt.cpp @@ -304,14 +304,27 @@ TEST(Highgui_Tiff, decode_tile16384x16384) { // see issue #2161 cv::Mat big(16384, 16384, CV_8UC1, cv::Scalar::all(0)); - string file = cv::tempfile(".tiff"); + string file3 = cv::tempfile(".tiff"); + string file4 = cv::tempfile(".tiff"); + std::vector params; params.push_back(TIFFTAG_ROWSPERSTRIP); params.push_back(big.rows); - cv::imwrite(file, big, params); + cv::imwrite(file4, big, params); + cv::imwrite(file3, big.colRange(0, big.cols - 1), params); big.release(); - EXPECT_NO_THROW(cv::imread(file)); - remove(file.c_str()); + try + { + cv::imread(file3); + EXPECT_NO_THROW(cv::imread(file4)); + } + catch(const std::bad_alloc&) + { + // have no enough memory + } + + remove(file3.c_str()); + remove(file4.c_str()); } #endif diff --git a/modules/imgproc/perf/perf_blur.cpp b/modules/imgproc/perf/perf_blur.cpp index a79603f701..6604608b04 100644 --- a/modules/imgproc/perf/perf_blur.cpp +++ b/modules/imgproc/perf/perf_blur.cpp @@ -90,7 +90,7 @@ PERF_TEST_P(Size_MatType_BorderType3x3, blur3x3, PERF_TEST_P(Size_MatType_BorderType, blur16x16, testing::Combine( - testing::Values(szODD, szQVGA, szVGA, sz720p), + testing::Values(szVGA, sz720p), testing::Values(CV_8UC1, CV_8UC4, CV_16UC1, CV_16SC1, CV_32FC1), testing::ValuesIn(BorderType::all()) ) @@ -184,7 +184,7 @@ PERF_TEST_P(Size_MatType_BorderType, gaussianBlur5x5, PERF_TEST_P(Size_MatType_BorderType, blur5x5, testing::Combine( - testing::Values(szODD, szQVGA, szVGA, sz720p), + testing::Values(szVGA, sz720p), testing::Values(CV_8UC1, CV_8UC4, CV_16UC1, CV_16SC1, CV_32FC1, CV_32FC3), testing::ValuesIn(BorderType::all()) ) diff --git a/modules/imgproc/perf/perf_cvt_color.cpp b/modules/imgproc/perf/perf_cvt_color.cpp index 0b882240f9..65f9d5cf82 100644 --- a/modules/imgproc/perf/perf_cvt_color.cpp +++ b/modules/imgproc/perf/perf_cvt_color.cpp @@ -56,11 +56,6 @@ enum }; CV_ENUM(CvtMode, - CV_BayerBG2BGR, CV_BayerBG2BGR_VNG, CV_BayerBG2GRAY, - CV_BayerGB2BGR, CV_BayerGB2BGR_VNG, CV_BayerGB2GRAY, - CV_BayerGR2BGR, CV_BayerGR2BGR_VNG, CV_BayerGR2GRAY, - CV_BayerRG2BGR, CV_BayerRG2BGR_VNG, CV_BayerRG2GRAY, - CV_BGR2BGR555, CV_BGR2BGR565, CV_BGR2BGRA, CV_BGR2GRAY, CV_BGR2HLS, CV_BGR2HLS_FULL, CV_BGR2HSV, CV_BGR2HSV_FULL, CV_BGR2Lab, CV_BGR2Luv, CV_BGR2RGB, CV_BGR2RGBA, CV_BGR2XYZ, @@ -106,6 +101,15 @@ CV_ENUM(CvtMode, CV_YUV2BGR, CV_YUV2RGB, CX_YUV2BGRA, CX_YUV2RGBA ) + +CV_ENUM(CvtModeBayer, + CV_BayerBG2BGR, CV_BayerBG2BGR_VNG, CV_BayerBG2GRAY, + CV_BayerGB2BGR, CV_BayerGB2BGR_VNG, CV_BayerGB2GRAY, + CV_BayerGR2BGR, CV_BayerGR2BGR_VNG, CV_BayerGR2GRAY, + CV_BayerRG2BGR, CV_BayerRG2BGR_VNG, CV_BayerRG2GRAY + ) + + CV_ENUM(CvtMode2, CV_YUV2BGR_NV12, CV_YUV2BGRA_NV12, CV_YUV2RGB_NV12, CV_YUV2RGBA_NV12, CV_YUV2BGR_NV21, CV_YUV2BGRA_NV21, CV_YUV2RGB_NV21, CV_YUV2RGBA_NV21, CV_YUV2BGR_YV12, CV_YUV2BGRA_YV12, CV_YUV2RGB_YV12, CV_YUV2RGBA_YV12, CV_YUV2BGR_IYUV, CV_YUV2BGRA_IYUV, CV_YUV2RGB_IYUV, CV_YUV2RGBA_IYUV, COLOR_YUV2GRAY_420, CV_YUV2RGB_UYVY, CV_YUV2BGR_UYVY, CV_YUV2RGBA_UYVY, CV_YUV2BGRA_UYVY, CV_YUV2RGB_YUY2, CV_YUV2BGR_YUY2, CV_YUV2RGB_YVYU, @@ -231,7 +235,7 @@ typedef perf::TestBaseWithParam Size_CvtMode; PERF_TEST_P(Size_CvtMode, cvtColor8u, testing::Combine( - testing::Values(TYPICAL_MAT_SIZES), + testing::Values(::perf::szODD, ::perf::szVGA, ::perf::sz1080p), testing::ValuesIn(CvtMode::all()) ) ) @@ -252,12 +256,38 @@ PERF_TEST_P(Size_CvtMode, cvtColor8u, SANITY_CHECK(dst, 1); } +typedef std::tr1::tuple Size_CvtMode_Bayer_t; +typedef perf::TestBaseWithParam Size_CvtMode_Bayer; + +PERF_TEST_P(Size_CvtMode_Bayer, cvtColorBayer8u, + testing::Combine( + testing::Values(::perf::szODD, ::perf::szVGA), + testing::ValuesIn(CvtModeBayer::all()) + ) + ) +{ + Size sz = get<0>(GetParam()); + int mode = get<1>(GetParam()); + ChPair ch = getConversionInfo(mode); + mode %= CV_COLORCVT_MAX; + + Mat src(sz, CV_8UC(ch.scn)); + Mat dst(sz, CV_8UC(ch.dcn)); + + declare.time(100); + declare.in(src, WARMUP_RNG).out(dst); + + TEST_CYCLE() cvtColor(src, dst, mode, ch.dcn); + + SANITY_CHECK(dst, 1); +} + typedef std::tr1::tuple Size_CvtMode2_t; typedef perf::TestBaseWithParam Size_CvtMode2; PERF_TEST_P(Size_CvtMode2, cvtColorYUV420, testing::Combine( - testing::Values(szVGA, sz720p, sz1080p, Size(130, 60)), + testing::Values(szVGA, sz1080p, Size(130, 60)), testing::ValuesIn(CvtMode2::all()) ) ) diff --git a/modules/imgproc/perf/perf_filter2d.cpp b/modules/imgproc/perf/perf_filter2d.cpp index 0115399029..297b524f9f 100644 --- a/modules/imgproc/perf/perf_filter2d.cpp +++ b/modules/imgproc/perf/perf_filter2d.cpp @@ -15,7 +15,7 @@ typedef TestBaseWithParam< tr1::tuple > Image_KernelSize; PERF_TEST_P( TestFilter2d, Filter2d, Combine( - Values( Size(320, 240), szVGA, sz720p, sz1080p ), + Values( Size(320, 240), sz1080p ), Values( 3, 5 ), ValuesIn( BorderMode::all() ) ) diff --git a/modules/imgproc/perf/perf_houghLines.cpp b/modules/imgproc/perf/perf_houghLines.cpp index 4e6b5b3fba..1c3ed567dd 100644 --- a/modules/imgproc/perf/perf_houghLines.cpp +++ b/modules/imgproc/perf/perf_houghLines.cpp @@ -32,7 +32,7 @@ PERF_TEST_P(Image_RhoStep_ThetaStep_Threshold, HoughLines, Canny(image, image, 0, 0); Mat lines; - declare.time(40); + declare.time(60); TEST_CYCLE() HoughLines(image, lines, rhoStep, thetaStep, threshold); diff --git a/modules/imgproc/perf/perf_integral.cpp b/modules/imgproc/perf/perf_integral.cpp index 2760d7ad21..b2b65bae1d 100644 --- a/modules/imgproc/perf/perf_integral.cpp +++ b/modules/imgproc/perf/perf_integral.cpp @@ -33,9 +33,9 @@ PERF_TEST_P(Size_MatType_OutMatDepth, integral, PERF_TEST_P(Size_MatType_OutMatDepth, integral_sqsum, testing::Combine( - testing::Values(TYPICAL_MAT_SIZES), + testing::Values(::perf::szVGA, ::perf::sz1080p), testing::Values(CV_8UC1, CV_8UC4), - testing::Values(CV_32S, CV_32F, CV_64F) + testing::Values(CV_32S, CV_32F) ) ) { @@ -58,9 +58,9 @@ PERF_TEST_P(Size_MatType_OutMatDepth, integral_sqsum, PERF_TEST_P( Size_MatType_OutMatDepth, integral_sqsum_tilted, testing::Combine( - testing::Values( TYPICAL_MAT_SIZES ), + testing::Values( ::perf::szVGA, ::perf::szODD , ::perf::sz1080p ), testing::Values( CV_8UC1, CV_8UC4 ), - testing::Values( CV_32S, CV_32F, CV_64F ) + testing::Values( CV_32S, CV_32F ) ) ) { diff --git a/modules/imgproc/perf/perf_resize.cpp b/modules/imgproc/perf/perf_resize.cpp index 12fa13fc95..3e6ecbf1fd 100644 --- a/modules/imgproc/perf/perf_resize.cpp +++ b/modules/imgproc/perf/perf_resize.cpp @@ -97,7 +97,7 @@ typedef TestBaseWithParam > MatInfo_Size_Scale PERF_TEST_P(MatInfo_Size_Scale_Area, ResizeArea, testing::Combine( testing::Values(CV_8UC1, CV_8UC4), - testing::Values(szVGA, szqHD, sz720p, sz1080p), + testing::Values(szVGA, szqHD, sz720p), testing::Values(2.4, 3.4, 1.3) ) ) diff --git a/modules/imgproc/perf/perf_threshold.cpp b/modules/imgproc/perf/perf_threshold.cpp index 65c13a05e2..dd1602cd20 100644 --- a/modules/imgproc/perf/perf_threshold.cpp +++ b/modules/imgproc/perf/perf_threshold.cpp @@ -31,7 +31,7 @@ PERF_TEST_P(Size_MatType_ThreshType, threshold, double maxval = theRNG().uniform(1, 254); declare.in(src, WARMUP_RNG).out(dst); - declare.time(100); + declare.iterations(500); TEST_CYCLE() threshold(src, dst, thresh, maxval, threshType); diff --git a/modules/imgproc/perf/perf_warp.cpp b/modules/imgproc/perf/perf_warp.cpp index f530df12c4..3d90b3e902 100644 --- a/modules/imgproc/perf/perf_warp.cpp +++ b/modules/imgproc/perf/perf_warp.cpp @@ -90,12 +90,7 @@ PERF_TEST_P( TestWarpPerspective, WarpPerspective, PERF_TEST_P( TestWarpPerspectiveNear_t, WarpPerspectiveNear, Combine( - Values( Size(176,144), Size(320,240), Size(352,288), Size(480,480), - Size(640,480), Size(704,576), Size(720,408), Size(720,480), - Size(720,576), Size(768,432), Size(800,448), Size(960,720), - Size(1024,768), Size(1280,720), Size(1280,960), Size(1360,720), - Size(1600,1200), Size(1920,1080), Size(2048,1536), Size(2592,1920), - Size(2592,1944), Size(3264,2448), Size(4096,3072), Size(4208,3120) ), + Values( Size(640,480), Size(1920,1080), Size(2592,1944) ), ValuesIn( InterType::all() ), ValuesIn( BorderMode::all() ), Values( CV_8UC1, CV_8UC4 ) diff --git a/modules/ml/doc/boosting.rst b/modules/ml/doc/boosting.rst index 0bc92ec964..6dd40f7350 100644 --- a/modules/ml/doc/boosting.rst +++ b/modules/ml/doc/boosting.rst @@ -169,11 +169,11 @@ CvBoost::predict ---------------- Predicts a response for an input sample. -.. ocv:function:: float CvBoost::predict( const Mat& sample, const Mat& missing=Mat(), const Range& slice=Range::all(), bool rawMode=false, bool returnSum=false ) const +.. ocv:function:: float CvBoost::predict( const Mat& sample, const Mat& missing=Mat(), const Range& slice=Range::all(), bool raw_mode=false, bool return_sum=false ) const .. ocv:function:: float CvBoost::predict( const CvMat* sample, const CvMat* missing=0, CvMat* weak_responses=0, CvSlice slice=CV_WHOLE_SEQ, bool raw_mode=false, bool return_sum=false ) const -.. ocv:pyfunction:: cv2.Boost.predict(sample[, missing[, slice[, rawMode[, returnSum]]]]) -> retval +.. ocv:pyfunction:: cv2.Boost.predict(sample[, missing[, slice[, raw_mode[, return_sum]]]]) -> retval :param sample: Input sample. diff --git a/modules/nonfree/test/test_rotation_and_scale_invariance.cpp b/modules/nonfree/test/test_rotation_and_scale_invariance.cpp index e0e731eb0b..7ca9e3dd74 100644 --- a/modules/nonfree/test/test_rotation_and_scale_invariance.cpp +++ b/modules/nonfree/test/test_rotation_and_scale_invariance.cpp @@ -621,7 +621,7 @@ TEST(Features2d_RotationInvariance_Detector_SURF, regression) test.safe_run(); } -TEST(Features2d_RotationInvariance_Detector_SIFT, regression) +TEST(Features2d_RotationInvariance_Detector_SIFT, DISABLED_regression) { DetectorRotationInvarianceTest test(Algorithm::create("Feature2D.SIFT"), 0.45f, diff --git a/modules/objdetect/src/haar.cpp b/modules/objdetect/src/haar.cpp index 54133f5f31..aa062c38e0 100644 --- a/modules/objdetect/src/haar.cpp +++ b/modules/objdetect/src/haar.cpp @@ -45,20 +45,20 @@ #include #include "opencv2/core/internal.hpp" -#if CV_SSE2 || CV_SSE3 -# if !CV_SSE4_1 && !CV_SSE4_2 +#if CV_SSE2 +# if 1 /*!CV_SSE4_1 && !CV_SSE4_2*/ # define _mm_blendv_pd(a, b, m) _mm_xor_pd(a, _mm_and_pd(_mm_xor_pd(b, a), m)) # define _mm_blendv_ps(a, b, m) _mm_xor_ps(a, _mm_and_ps(_mm_xor_ps(b, a), m)) # endif #endif -#if CV_AVX +#if 0 /*CV_AVX*/ # define CV_HAAR_USE_AVX 1 # if defined _MSC_VER # pragma warning( disable : 4752 ) # endif #else -# if CV_SSE2 || CV_SSE3 +# if CV_SSE2 # define CV_HAAR_USE_SSE 1 # endif #endif diff --git a/modules/objdetect/test/test_cascadeandhog.cpp b/modules/objdetect/test/test_cascadeandhog.cpp index 3f31a7ec5d..596e646517 100644 --- a/modules/objdetect/test/test_cascadeandhog.cpp +++ b/modules/objdetect/test/test_cascadeandhog.cpp @@ -87,11 +87,15 @@ protected: vector imageFilenames; vector images; string validationFilename; + string configFilename; FileStorage validationFS; + bool write_results; }; CV_DetectorTest::CV_DetectorTest() { + configFilename = "dummy"; + write_results = false; } string& CV_DetectorTest::getValidationFilename() @@ -146,86 +150,99 @@ int CV_DetectorTest::prepareData( FileStorage& _fs ) void CV_DetectorTest::run( int ) { string dataPath = ts->get_data_path(); - validationFS.open( dataPath + getValidationFilename(), FileStorage::READ ); - int code = prepareData( validationFS ); + string vs_filename = dataPath + getValidationFilename(); + + write_results = !validationFS.open( vs_filename, FileStorage::READ ); + + int code; + if( !write_results ) + { + code = prepareData( validationFS ); + } + else + { + FileStorage fs0(dataPath + configFilename, FileStorage::READ ); + code = prepareData(fs0); + } + if( code < 0 ) { ts->set_failed_test_info( code ); return; } -#ifdef GET_STAT - validationFS.release(); - string filename = ts->get_data_path(); - filename += getValidationFilename(); - validationFS.open( filename, FileStorage::WRITE ); - validationFS << FileStorage::getDefaultObjectName(validationFilename) << "{"; - - validationFS << DIST_E << eps.dist; - validationFS << S_E << eps.s; - validationFS << NO_PAIR_E << eps.noPair; -// validationFS << TOTAL_NO_PAIR_E << eps.totalNoPair; - - // write detector names - validationFS << DETECTOR_NAMES << "["; - vector::const_iterator nit = detectorNames.begin(); - for( ; nit != detectorNames.end(); ++nit ) + if( write_results ) { - validationFS << *nit; - } - validationFS << "]"; // DETECTOR_NAMES + validationFS.release(); + validationFS.open( vs_filename, FileStorage::WRITE ); + validationFS << FileStorage::getDefaultObjectName(validationFilename) << "{"; - // write detectors - validationFS << DETECTORS << "{"; - assert( detectorNames.size() == detectorFilenames.size() ); - nit = detectorNames.begin(); - for( int di = 0; di < detectorNames.size(), nit != detectorNames.end(); ++nit, di++ ) - { - validationFS << *nit << "{"; - writeDetector( validationFS, di ); + validationFS << DIST_E << eps.dist; + validationFS << S_E << eps.s; + validationFS << NO_PAIR_E << eps.noPair; + // validationFS << TOTAL_NO_PAIR_E << eps.totalNoPair; + + // write detector names + validationFS << DETECTOR_NAMES << "["; + vector::const_iterator nit = detectorNames.begin(); + for( ; nit != detectorNames.end(); ++nit ) + { + validationFS << *nit; + } + validationFS << "]"; // DETECTOR_NAMES + + // write detectors + validationFS << DETECTORS << "{"; + assert( detectorNames.size() == detectorFilenames.size() ); + nit = detectorNames.begin(); + for( int di = 0; nit != detectorNames.end(); ++nit, di++ ) + { + validationFS << *nit << "{"; + writeDetector( validationFS, di ); + validationFS << "}"; + } validationFS << "}"; - } - validationFS << "}"; - // write image filenames - validationFS << IMAGE_FILENAMES << "["; - vector::const_iterator it = imageFilenames.begin(); - for( int ii = 0; it != imageFilenames.end(); ++it, ii++ ) - { - char buf[10]; - sprintf( buf, "%s%d", "img_", ii ); - cvWriteComment( validationFS.fs, buf, 0 ); - validationFS << *it; - } - validationFS << "]"; // IMAGE_FILENAMES + // write image filenames + validationFS << IMAGE_FILENAMES << "["; + vector::const_iterator it = imageFilenames.begin(); + for( int ii = 0; it != imageFilenames.end(); ++it, ii++ ) + { + char buf[10]; + sprintf( buf, "%s%d", "img_", ii ); + cvWriteComment( validationFS.fs, buf, 0 ); + validationFS << *it; + } + validationFS << "]"; // IMAGE_FILENAMES - validationFS << VALIDATION << "{"; -#endif + validationFS << VALIDATION << "{"; + } int progress = 0; for( int di = 0; di < test_case_count; di++ ) { progress = update_progress( progress, di, test_case_count, 0 ); -#ifdef GET_STAT - validationFS << detectorNames[di] << "{"; -#endif + if( write_results ) + validationFS << detectorNames[di] << "{"; vector > objects; int temp_code = runTestCase( di, objects ); -#ifndef GET_STAT - if (temp_code == cvtest::TS::OK) + + if (!write_results && temp_code == cvtest::TS::OK) temp_code = validate( di, objects ); -#endif + if (temp_code != cvtest::TS::OK) code = temp_code; -#ifdef GET_STAT - validationFS << "}"; // detectorNames[di] -#endif + + if( write_results ) + validationFS << "}"; // detectorNames[di] + } + + if( write_results ) + { + validationFS << "}"; // VALIDATION + validationFS << "}"; // getDefaultObjectName } -#ifdef GET_STAT - validationFS << "}"; // VALIDATION - validationFS << "}"; // getDefaultObjectName -#endif if ( test_case_count <= 0 || imageFilenames.size() <= 0 ) { ts->printf( cvtest::TS::LOG, "validation file is not determined or not correct" ); @@ -257,18 +274,19 @@ int CV_DetectorTest::runTestCase( int detectorIdx, vector >& object objects.push_back( imgObjects ); -#ifdef GET_STAT - char buf[10]; - sprintf( buf, "%s%d", "img_", ii ); - string imageIdxStr = buf; - validationFS << imageIdxStr << "[:"; - for( vector::const_iterator it = imgObjects.begin(); - it != imgObjects.end(); ++it ) + if( write_results ) { - validationFS << it->x << it->y << it->width << it->height; + char buf[10]; + sprintf( buf, "%s%d", "img_", ii ); + string imageIdxStr = buf; + validationFS << imageIdxStr << "[:"; + for( vector::const_iterator it = imgObjects.begin(); + it != imgObjects.end(); ++it ) + { + validationFS << it->x << it->y << it->width << it->height; + } + validationFS << "]"; // imageIdxStr } - validationFS << "]"; // imageIdxStr -#endif } return cvtest::TS::OK; } @@ -374,12 +392,14 @@ protected: virtual void readDetector( const FileNode& fn ); virtual void writeDetector( FileStorage& fs, int di ); virtual int detectMultiScale( int di, const Mat& img, vector& objects ); + virtual int detectMultiScale_C( const string& filename, int di, const Mat& img, vector& objects ); vector flags; }; CV_CascadeDetectorTest::CV_CascadeDetectorTest() { validationFilename = "cascadeandhog/cascade.xml"; + configFilename = "cascadeandhog/_cascade.xml"; } void CV_CascadeDetectorTest::readDetector( const FileNode& fn ) @@ -402,11 +422,48 @@ void CV_CascadeDetectorTest::writeDetector( FileStorage& fs, int di ) fs << C_SCALE_CASCADE << sc; } + +int CV_CascadeDetectorTest::detectMultiScale_C( const string& filename, + int di, const Mat& img, + vector& objects ) +{ + Ptr c_cascade = cvLoadHaarClassifierCascade(filename.c_str(), cvSize(0,0)); + Ptr storage = cvCreateMemStorage(); + + if( c_cascade.empty() ) + { + ts->printf( cvtest::TS::LOG, "cascade %s can not be opened"); + return cvtest::TS::FAIL_INVALID_TEST_DATA; + } + Mat grayImg; + cvtColor( img, grayImg, CV_BGR2GRAY ); + equalizeHist( grayImg, grayImg ); + + CvMat c_gray = grayImg; + CvSeq* rs = cvHaarDetectObjects(&c_gray, c_cascade, storage, 1.1, 3, flags[di] ); + + objects.clear(); + for( int i = 0; i < rs->total; i++ ) + { + Rect r = *(Rect*)cvGetSeqElem(rs, i); + objects.push_back(r); + } + + return cvtest::TS::OK; +} + int CV_CascadeDetectorTest::detectMultiScale( int di, const Mat& img, vector& objects) { string dataPath = ts->get_data_path(), filename; filename = dataPath + detectorFilenames[di]; + const string pattern = "haarcascade_frontalface_default.xml"; + + if( filename.size() >= pattern.size() && + strcmp(filename.c_str() + (filename.size() - pattern.size()), + pattern.c_str()) == 0 ) + return detectMultiScale_C(filename, di, img, objects); + CascadeClassifier cascade( filename ); if( cascade.empty() ) { diff --git a/modules/photo/perf/perf_inpaint.cpp b/modules/photo/perf/perf_inpaint.cpp index ea23bb4032..fdf4ae0692 100644 --- a/modules/photo/perf/perf_inpaint.cpp +++ b/modules/photo/perf/perf_inpaint.cpp @@ -13,7 +13,7 @@ typedef perf::TestBaseWithParam InpaintArea_Inpa PERF_TEST_P(InpaintArea_InpaintingMethod, inpaint, testing::Combine( - SZ_ALL_SMALL, + testing::Values(::perf::szSmall24, ::perf::szSmall32, ::perf::szSmall64), testing::ValuesIn(InpaintingMethod::all()) ) ) diff --git a/modules/python/src2/defs b/modules/python/src2/defs index 38b5753c00..0298e5be0a 100644 --- a/modules/python/src2/defs +++ b/modules/python/src2/defs @@ -323,6 +323,27 @@ #define CV_CAP_PROP_EXPOSURE 15 #define CV_CAP_PROP_CONVERT_RGB 16 #define CV_CAP_PROP_RECTIFICATION 18 +#define CV_CAP_OPENNI 900 +#define CV_CAP_OPENNI_DEPTH_GENERATOR 2147483648 +#define CV_CAP_OPENNI_IMAGE_GENERATOR 1073741824 +#define CV_CAP_OPENNI_DEPTH_MAP 0 +#define CV_CAP_OPENNI_POINT_CLOUD_MAP 1 +#define CV_CAP_OPENNI_DISPARITY_MAP 2 +#define CV_CAP_OPENNI_DISPARITY_MAP_32F 3 +#define CV_CAP_OPENNI_VALID_DEPTH_MASK 4 +#define CV_CAP_OPENNI_BGR_IMAGE 5 +#define CV_CAP_OPENNI_GRAY_IMAGE 6 +#define CV_CAP_PROP_OPENNI_OUTPUT_MODE 100 +#define CV_CAP_OPENNI_VGA_30HZ 0 +#define CV_CAP_OPENNI_SXGA_15HZ 1 +#define CV_CAP_PROP_OPENNI_REGISTRATION 104 +#define CV_CAP_PROP_OPENNI_FRAME_MAX_DEPTH 101 +#define CV_CAP_PROP_OPENNI_BASELINE 102 +#define CV_CAP_PROP_OPENNI_FOCAL_LENGTH 103 +#define CV_CAP_OPENNI_IMAGE_GENERATOR_OUTPUT_MODE 1073741924 +#define CV_CAP_OPENNI_DEPTH_GENERATOR_BASELINE 2147483750 +#define CV_CAP_OPENNI_DEPTH_GENERATOR_FOCAL_LENGTH 2147483751 +#define CV_CAP_OPENNI_DEPTH_GENERATOR_REGISTRATION 2147483752 #define CV_CN_SHIFT 3 #define CV_IMWRITE_JPEG_QUALITY 1 #define CV_IMWRITE_PNG_COMPRESSION 16 diff --git a/modules/python/test/test.py b/modules/python/test/test.py index 924708c483..7c511e4ef7 100755 --- a/modules/python/test/test.py +++ b/modules/python/test/test.py @@ -16,6 +16,8 @@ import functools import cv2.cv as cv +from test2 import * + class OpenCVTests(unittest.TestCase): depths = [ cv.IPL_DEPTH_8U, cv.IPL_DEPTH_8S, cv.IPL_DEPTH_16U, cv.IPL_DEPTH_16S, cv.IPL_DEPTH_32S, cv.IPL_DEPTH_32F, cv.IPL_DEPTH_64F ] @@ -2200,10 +2202,6 @@ class DocumentFragmentTests(OpenCVTests): self.assertEqual(self.hashimg(h1), self.hashimg(h3)) self.assertNotEqual(self.hashimg(h1), self.hashimg(h2)) -class NewTests(OpenCVTests): - - pass - if __name__ == '__main__': print "testing", cv.__version__ random.seed(0) diff --git a/modules/python/test/test2.py b/modules/python/test/test2.py index c7491ad974..6876d3915b 100644 --- a/modules/python/test/test2.py +++ b/modules/python/test/test2.py @@ -41,12 +41,47 @@ class Hackathon244Tests(NewOpenCVTests): absa0 = np.abs(a) self.assert_(cv2.norm(a, cv2.NORM_L1) == 15) absa1 = cv2.absdiff(a, 0) - self.assert_(cv2.norm(absa1, absa0, cv2.NORM_INF) == 0) + self.assertEqual(cv2.norm(absa1, absa0, cv2.NORM_INF), 0) def test_imencode(self): a = np.zeros((480, 640), dtype=np.uint8) flag, ajpg = cv2.imencode("img_q90.jpg", a, [cv2.IMWRITE_JPEG_QUALITY, 90]) - self.assert_(flag == True and ajpg.dtype == np.uint8 and ajpg.shape[0] > 1 and ajpg.shape[1] == 1) + self.assertEqual(flag, True) + self.assertEqual(ajpg.dtype, np.uint8) + self.assertGreater(ajpg.shape[0], 1) + self.assertEqual(ajpg.shape[1], 1) + + def test_projectPoints(self): + objpt = np.float64([[1,2,3]]) + imgpt0, jac0 = cv2.projectPoints(objpt, np.zeros(3), np.zeros(3), np.eye(3), np.float64([])) + imgpt1, jac1 = cv2.projectPoints(objpt, np.zeros(3), np.zeros(3), np.eye(3), None) + self.assertEqual(imgpt0.shape, (objpt.shape[0], 1, 2)) + self.assertEqual(imgpt1.shape, imgpt0.shape) + self.assertEqual(jac0.shape, jac1.shape) + self.assertEqual(jac0.shape[0], 2*objpt.shape[0]) + + def test_estimateAffine3D(self): + pattern_size = (11, 8) + pattern_points = np.zeros((np.prod(pattern_size), 3), np.float32) + pattern_points[:,:2] = np.indices(pattern_size).T.reshape(-1, 2) + pattern_points *= 10 + (retval, out, inliers) = cv2.estimateAffine3D(pattern_points, pattern_points) + self.assertEqual(retval, 1) + if cv2.norm(out[2,:]) < 1e-3: + out[2,2]=1 + self.assertLess(cv2.norm(out, np.float64([[1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 1, 0]])), 1e-3) + self.assertEqual(cv2.countNonZero(inliers), pattern_size[0]*pattern_size[1]) + + def test_fast(self): + fd = cv2.FastFeatureDetector(30, True) + img = self.get_sample("samples/cpp/right02.jpg", 0) + img = cv2.medianBlur(img, 3) + imgc = cv2.cvtColor(img, cv2.COLOR_GRAY2BGR) + keypoints = fd.detect(img) + self.assert_(600 <= len(keypoints) <= 700) + for kpt in keypoints: + self.assertNotEqual(kpt.response, 0) + if __name__ == '__main__': print "testing", cv.__version__ diff --git a/modules/stitching/perf/perf_stich.cpp b/modules/stitching/perf/perf_stich.cpp index 5e3e6778bc..11f52f7617 100644 --- a/modules/stitching/perf/perf_stich.cpp +++ b/modules/stitching/perf/perf_stich.cpp @@ -154,7 +154,7 @@ PERF_TEST_P( match, bestOf2Nearest, TEST_DETECTORS) PERF_TEST_P( matchVector, bestOf2NearestVectorFeatures, testing::Combine( TEST_DETECTORS, - testing::Values(2, 4, 6, 8)) + testing::Values(2, 4, 8)) ) { Mat img1, img1_full = imread( getDataPath("stitching/b1.png") ); diff --git a/modules/ts/src/ts_perf.cpp b/modules/ts/src/ts_perf.cpp index 91d0c1d1f6..f7622c2f3a 100644 --- a/modules/ts/src/ts_perf.cpp +++ b/modules/ts/src/ts_perf.cpp @@ -334,29 +334,21 @@ void Regression::write(cv::Mat m) write() << "val" << getElem(m, y, x, cn) << "}"; } -static double evalEps(double expected, double actual, double _eps, ERROR_TYPE err) -{ - if (err == ERROR_ABSOLUTE) - return _eps; - else if (err == ERROR_RELATIVE) - return std::max(std::abs(expected), std::abs(actual)) * _eps; - return 0; -} - -void Regression::verify(cv::FileNode node, cv::Mat actual, double _eps, std::string argname, ERROR_TYPE err) +void Regression::verify(cv::FileNode node, cv::Mat actual, double eps, std::string argname, ERROR_TYPE err) { if (!actual.empty() && actual.dims < 2) return; + double expect_min = (double)node["min"]; + double expect_max = (double)node["max"]; + + if (err == ERROR_RELATIVE) + eps *= std::max(std::abs(expect_min), std::abs(expect_max)); + double actual_min, actual_max; cv::minMaxIdx(actual, &actual_min, &actual_max); - double expect_min = (double)node["min"]; - double eps = evalEps(expect_min, actual_min, _eps, err); ASSERT_NEAR(expect_min, actual_min, eps) << argname << " has unexpected minimal value" << std::endl; - - double expect_max = (double)node["max"]; - eps = evalEps(expect_max, actual_max, _eps, err); ASSERT_NEAR(expect_max, actual_max, eps) << argname << " has unexpected maximal value" << std::endl; @@ -370,7 +362,6 @@ void Regression::verify(cv::FileNode node, cv::Mat actual, double _eps, std::str << argname << " has unexpected number of rows" << std::endl; double expect_last = (double)last["val"]; - eps = evalEps(expect_last, actual_last, _eps, err); ASSERT_NEAR(expect_last, actual_last, eps) << argname << " has unexpected value of the last element" << std::endl; @@ -384,7 +375,6 @@ void Regression::verify(cv::FileNode node, cv::Mat actual, double _eps, std::str // verified that mat size is the same as recorded double actual_rng1 = getElem(actual, y1, x1, cn1); - eps = evalEps(expect_rng1, actual_rng1, _eps, err); ASSERT_NEAR(expect_rng1, actual_rng1, eps) << argname << " has unexpected value of the ["<< x1 << ":" << y1 << ":" << cn1 <<"] element" << std::endl; @@ -396,7 +386,6 @@ void Regression::verify(cv::FileNode node, cv::Mat actual, double _eps, std::str double expect_rng2 = (double)rng2["val"]; double actual_rng2 = getElem(actual, y2, x2, cn2); - eps = evalEps(expect_rng2, actual_rng2, _eps, err); ASSERT_NEAR(expect_rng2, actual_rng2, eps) << argname << " has unexpected value of the ["<< x2 << ":" << y2 << ":" << cn2 <<"] element" << std::endl; } diff --git a/modules/video/doc/motion_analysis_and_object_tracking.rst b/modules/video/doc/motion_analysis_and_object_tracking.rst index 8824d784b1..3674a5d579 100644 --- a/modules/video/doc/motion_analysis_and_object_tracking.rst +++ b/modules/video/doc/motion_analysis_and_object_tracking.rst @@ -23,7 +23,7 @@ Calculates an optical flow for a sparse feature set using the iterative Lucas-Ka :param nextPts: output vector of 2D points (with single-precision floating-point coordinates) containing the calculated new positions of input features in the second image; when ``OPTFLOW_USE_INITIAL_FLOW`` flag is passed, the vector must have the same size as in the input. - :param status: output status vector; each element of the vector is set to 1 if the flow for the corresponding features has been found, otherwise, it is set to 0. + :param status: output status vector (of unsigned chars); each element of the vector is set to 1 if the flow for the corresponding features has been found, otherwise, it is set to 0. :param err: output vector of errors; each element of the vector is set to an error for the corresponding feature, type of the error measure can be set in ``flags`` parameter; if the flow wasn't found then the error is not defined (use the ``status`` parameter to find such cases). diff --git a/modules/video/perf/perf_optflowpyrlk.cpp b/modules/video/perf/perf_optflowpyrlk.cpp index 1e5cfc25ff..d34bd72150 100644 --- a/modules/video/perf/perf_optflowpyrlk.cpp +++ b/modules/video/perf/perf_optflowpyrlk.cpp @@ -33,7 +33,7 @@ PERF_TEST_P(Path_Idx_Cn_NPoints_WSize, OpticalFlowPyrLK_full, testing::Combine( testing::Range(1, 3), testing::Values(1, 3, 4), testing::Values(make_tuple(9, 9), make_tuple(15, 15)), - testing::Values(7, 11, 25) + testing::Values(7, 11) ) ) { @@ -105,7 +105,7 @@ PERF_TEST_P(Path_Idx_Cn_NPoints_WSize_Deriv, OpticalFlowPyrLK_self, testing::Com testing::Range(1, 3), testing::Values(1, 3, 4), testing::Values(make_tuple(9, 9), make_tuple(15, 15)), - testing::Values(7, 11, 25), + testing::Values(7, 11), testing::Bool() ) )