Merge branch '2.4'

This commit is contained in:
Andrey Kamaev 2013-02-01 14:58:52 +04:00
commit 61079547f0
44 changed files with 475 additions and 159 deletions

View File

@ -25,8 +25,8 @@ Let's use a simple program such as DisplayImage.cpp shown below.
.. code-block:: cpp .. code-block:: cpp
#include <cv.h> #include <stdio.h>
#include <highgui.h> #include <opencv2/opencv.hpp>
using namespace cv; using namespace cv;
@ -55,9 +55,10 @@ Now you have to create your CMakeLists.txt file. It should look like this:
.. code-block:: cmake .. code-block:: cmake
cmake_minimum_required(VERSION 2.8)
project( DisplayImage ) project( DisplayImage )
find_package( OpenCV REQUIRED ) find_package( OpenCV REQUIRED )
add_executable( DisplayImage DisplayImage ) add_executable( DisplayImage DisplayImage.cpp )
target_link_libraries( DisplayImage ${OpenCV_LIBS} ) target_link_libraries( DisplayImage ${OpenCV_LIBS} )
Generate the executable Generate the executable

View File

@ -3360,7 +3360,11 @@ void cv::projectPoints( InputArray _opoints,
CvMat c_cameraMatrix = cameraMatrix; CvMat c_cameraMatrix = cameraMatrix;
CvMat c_rvec = rvec, c_tvec = tvec; CvMat c_rvec = rvec, c_tvec = tvec;
double dc0buf[5]={0};
Mat dc0(5,1,CV_64F,dc0buf);
Mat distCoeffs = _distCoeffs.getMat(); Mat distCoeffs = _distCoeffs.getMat();
if( distCoeffs.empty() )
distCoeffs = dc0;
CvMat c_distCoeffs = distCoeffs; CvMat c_distCoeffs = distCoeffs;
int ndistCoeffs = distCoeffs.rows + distCoeffs.cols - 1; int ndistCoeffs = distCoeffs.rows + distCoeffs.cols - 1;
@ -3375,8 +3379,7 @@ void cv::projectPoints( InputArray _opoints,
pdpddist = &(dpddist = jacobian.colRange(10, 10+ndistCoeffs)); pdpddist = &(dpddist = jacobian.colRange(10, 10+ndistCoeffs));
} }
cvProjectPoints2( &c_objectPoints, &c_rvec, &c_tvec, &c_cameraMatrix, cvProjectPoints2( &c_objectPoints, &c_rvec, &c_tvec, &c_cameraMatrix, &c_distCoeffs,
(distCoeffs.empty())? 0: &c_distCoeffs,
&c_imagePoints, pdpdrot, pdpdt, pdpdf, pdpdc, pdpddist, aspectRatio ); &c_imagePoints, pdpdrot, pdpdt, pdpdf, pdpdc, pdpddist, aspectRatio );
} }

View File

@ -472,23 +472,24 @@ int cv::estimateAffine3D(InputArray _from, InputArray _to,
double param1, double param2) double param1, double param2)
{ {
Mat from = _from.getMat(), to = _to.getMat(); 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); _out.create(3, 4, CV_64F);
Mat out = _out.getMat(); Mat out = _out.getMat();
_inliers.create(count, 1, CV_8U, -1, true); Mat inliers(1, count, CV_8U);
Mat inliers = _inliers.getMat();
inliers = Scalar::all(1); inliers = Scalar::all(1);
Mat dFrom, dTo; Mat dFrom, dTo;
from.convertTo(dFrom, CV_64F); from.convertTo(dFrom, CV_64F);
to.convertTo(dTo, CV_64F); to.convertTo(dTo, CV_64F);
dFrom = dFrom.reshape(3, 1);
dTo = dTo.reshape(3, 1);
CvMat F3x4 = out; CvMat F3x4 = out;
CvMat mask = inliers; CvMat mask = inliers;
CvMat m1 = dFrom; CvMat m1 = dFrom;
CvMat m2 = dTo; CvMat m2 = dTo;
@ -496,5 +497,9 @@ int cv::estimateAffine3D(InputArray _from, InputArray _to,
param1 = param1 <= 0 ? 3 : param1; param1 = param1 <= 0 ? 3 : param1;
param2 = (param2 < epsilon) ? 0.99 : (param2 > 1 - epsilon) ? 0.99 : param2; 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;
} }

View File

@ -219,7 +219,31 @@ TermCriteria
------------ ------------
.. ocv:class:: 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 Matx
---- ----

View File

@ -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. 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: :: 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"; string text = "Funny text inside the box";
int fontFace = FONT_HERSHEY_SCRIPT_SIMPLEX; int fontFace = FONT_HERSHEY_SCRIPT_SIMPLEX;
double fontScale = 2; double fontScale = 2;

View File

@ -2037,10 +2037,10 @@ public:
//! default constructor //! default constructor
TermCriteria(); TermCriteria();
//! full constructor //! full constructor
TermCriteria(int _type, int _maxCount, double _epsilon); TermCriteria(int type, int maxCount, double epsilon);
//! conversion from CvTermCriteria //! conversion from CvTermCriteria
TermCriteria(const CvTermCriteria& criteria); TermCriteria(const CvTermCriteria& criteria);
//! conversion from CvTermCriteria //! conversion to CvTermCriteria
operator CvTermCriteria() const; operator CvTermCriteria() const;
int type; //!< the type of termination criteria: COUNT, EPS or COUNT + EPS int type; //!< the type of termination criteria: COUNT, EPS or COUNT + EPS

View File

@ -6,7 +6,7 @@ using namespace perf;
using std::tr1::make_tuple; using std::tr1::make_tuple;
using std::tr1::get; 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)) #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) PERF_TEST_P(Size_MatType, addWeighted, TYPICAL_MATS_ADWEIGHTED)

View File

@ -6,7 +6,7 @@ using namespace perf;
using std::tr1::make_tuple; using std::tr1::make_tuple;
using std::tr1::get; 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_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 ) ) #define TYPICAL_MATS_CORE_ARITHM testing::Combine( testing::Values( TYPICAL_MAT_SIZES_CORE_ARITHM ), testing::Values( TYPICAL_MAT_TYPES_CORE_ARITHM ) )

View File

@ -19,7 +19,7 @@ PERF_TEST_P(Size_MatType, bitwise_not, TYPICAL_MATS_BITW_ARITHM)
cv::Mat c = Mat(sz, type); cv::Mat c = Mat(sz, type);
declare.in(a, WARMUP_RNG).out(c); declare.in(a, WARMUP_RNG).out(c);
declare.time(100); declare.iterations(200);
TEST_CYCLE() cv::bitwise_not(a, c); TEST_CYCLE() cv::bitwise_not(a, c);

View File

@ -13,7 +13,7 @@ typedef perf::TestBaseWithParam<Size_MatType_CmpType_t> Size_MatType_CmpType;
PERF_TEST_P( Size_MatType_CmpType, compare, PERF_TEST_P( Size_MatType_CmpType, compare,
testing::Combine( 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::Values(CV_8UC1, CV_8UC4, CV_8SC1, CV_16UC1, CV_16SC1, CV_32SC1, CV_32FC1),
testing::ValuesIn(CmpType::all()) testing::ValuesIn(CmpType::all())
) )

View File

@ -29,6 +29,7 @@ PERF_TEST_P( Size_DepthSrc_DepthDst_Channels_alpha, convertTo,
Mat src(sz, CV_MAKETYPE(depthSrc, channels)); Mat src(sz, CV_MAKETYPE(depthSrc, channels));
randu(src, 0, 255); randu(src, 0, 255);
Mat dst(sz, CV_MAKETYPE(depthDst, channels)); Mat dst(sz, CV_MAKETYPE(depthDst, channels));
declare.iterations(500);
TEST_CYCLE() src.convertTo(dst, depthDst, alpha); TEST_CYCLE() src.convertTo(dst, depthDst, alpha);

View File

@ -131,7 +131,7 @@ PERF_TEST_P(Size_MatType_NormType, normalize,
PERF_TEST_P(Size_MatType_NormType, normalize_mask, PERF_TEST_P(Size_MatType_NormType, normalize_mask,
testing::Combine( testing::Combine(
testing::Values(TYPICAL_MAT_SIZES), testing::Values(::perf::szVGA, ::perf::sz1080p),
testing::Values(TYPICAL_MAT_TYPES), testing::Values(TYPICAL_MAT_TYPES),
testing::Values((int)NORM_INF, (int)NORM_L1, (int)NORM_L2) 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); Mat dst(sz, matType);
declare.in(src, WARMUP_RNG).out(dst); declare.in(src, WARMUP_RNG).out(dst);
declare.time(30);
TEST_CYCLE() normalize(src, dst, 20., 100., NORM_MINMAX); TEST_CYCLE() normalize(src, dst, 20., 100., NORM_MINMAX);

View File

@ -1975,6 +1975,14 @@ void cv::transpose( InputArray _src, OutputArray _dst )
_dst.create(src.cols, src.rows, src.type()); _dst.create(src.cols, src.rows, src.type());
Mat dst = _dst.getMat(); 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 ) if( dst.data == src.data )
{ {
TransposeInplaceFunc func = transposeInplaceTab[esz]; TransposeInplaceFunc func = transposeInplaceTab[esz];

View File

@ -267,7 +267,7 @@ BFMatcher::BFMatcher
-------------------- --------------------
Brute-force matcher constructor. 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). :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).

View File

@ -1199,13 +1199,14 @@ protected:
class CV_EXPORTS_W BFMatcher : public DescriptorMatcher class CV_EXPORTS_W BFMatcher : public DescriptorMatcher
{ {
public: public:
CV_WRAP BFMatcher( int normType, bool crossCheck=false ); CV_WRAP BFMatcher( int normType=NORM_L2, bool crossCheck=false );
virtual ~BFMatcher() {} virtual ~BFMatcher() {}
virtual bool isMaskSupported() const { return true; } virtual bool isMaskSupported() const { return true; }
virtual Ptr<DescriptorMatcher> clone( bool emptyTrainData=false ) const; virtual Ptr<DescriptorMatcher> clone( bool emptyTrainData=false ) const;
AlgorithmInfo* info() const;
protected: protected:
virtual void knnMatchImpl( const Mat& queryDescriptors, vector<vector<DMatch> >& matches, int k, virtual void knnMatchImpl( const Mat& queryDescriptors, vector<vector<DMatch> >& matches, int k,
const vector<Mat>& masks=vector<Mat>(), bool compactResult=false ); const vector<Mat>& masks=vector<Mat>(), bool compactResult=false );
@ -1239,6 +1240,7 @@ public:
virtual Ptr<DescriptorMatcher> clone( bool emptyTrainData=false ) const; virtual Ptr<DescriptorMatcher> clone( bool emptyTrainData=false ) const;
AlgorithmInfo* info() const;
protected: protected:
static void convertToDMatches( const DescriptorCollection& descriptors, static void convertToDMatches( const DescriptorCollection& descriptors,
const Mat& indices, const Mat& distances, const Mat& indices, const Mat& distances,

View File

@ -161,6 +161,16 @@ CV_INIT_ALGORITHM(GridAdaptedFeatureDetector, "Feature2D.Grid",
obj.info()->addParam(obj, "gridRows", obj.gridRows); obj.info()->addParam(obj, "gridRows", obj.gridRows);
obj.info()->addParam(obj, "gridCols", obj.gridCols)); 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 cv::initModule_features2d(void)
{ {
bool all = true; bool all = true;
@ -175,6 +185,8 @@ bool cv::initModule_features2d(void)
all &= !HarrisDetector_info_auto.name().empty(); all &= !HarrisDetector_info_auto.name().empty();
all &= !DenseFeatureDetector_info_auto.name().empty(); all &= !DenseFeatureDetector_info_auto.name().empty();
all &= !GridAdaptedFeatureDetector_info_auto.name().empty(); all &= !GridAdaptedFeatureDetector_info_auto.name().empty();
all &= !BFMatcher_info_auto.name().empty();
all &= !FlannBasedMatcher_info_auto.name().empty();
return all; return all;
} }

View File

@ -532,12 +532,12 @@ void CV_DescriptorMatcherTest::run( int )
TEST( Features2d_DescriptorMatcher_BruteForce, regression ) 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>("DescriptorMatcher.BFMatcher"), 0.01f );
test.safe_run(); test.safe_run();
} }
TEST( Features2d_DescriptorMatcher_FlannBased, regression ) 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>("DescriptorMatcher.FlannBasedMatcher"), 0.04f );
test.safe_run(); test.safe_run();
} }

View File

@ -261,6 +261,16 @@ private:
*/ */
void initialize(size_t key_size) 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; speed_level_ = kHash;
key_size_ = (unsigned)key_size; key_size_ = (unsigned)key_size;
} }
@ -273,10 +283,10 @@ private:
if (speed_level_ == kArray) return; if (speed_level_ == kArray) return;
// Use an array if it will be more than half full // 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; speed_level_ = kArray;
// Fill the array version of it // 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; 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 // 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 // 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) // 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 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; speed_level_ = kBitsetHash;
key_bitset_.resize(1 << key_size_); key_bitset_.resize(size_t(1) << key_size_);
key_bitset_.reset(); key_bitset_.reset();
// Try with the BucketsSpace // 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); for (BucketsSpace::const_iterator key_bucket = buckets_space_.begin(); key_bucket != buckets_space_.end(); ++key_bucket) key_bitset_.set(key_bucket->first);

View File

@ -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<int>(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(); }

View File

@ -0,0 +1,3 @@
#include "test_precomp.hpp"
CV_TEST_MAIN("cv")

View File

@ -0,0 +1 @@
#include "test_precomp.hpp"

View File

@ -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 <iostream>
#endif

View File

@ -487,7 +487,7 @@ VideoWriter constructors
:param filename: Name of the output video file. :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 <http://www.fourcc.org/codecs.php>`_ page.
:param fps: Framerate of the created video stream. :param fps: Framerate of the created video stream.

View File

@ -304,14 +304,27 @@ TEST(Highgui_Tiff, decode_tile16384x16384)
{ {
// see issue #2161 // see issue #2161
cv::Mat big(16384, 16384, CV_8UC1, cv::Scalar::all(0)); 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<int> params; std::vector<int> params;
params.push_back(TIFFTAG_ROWSPERSTRIP); params.push_back(TIFFTAG_ROWSPERSTRIP);
params.push_back(big.rows); 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(); big.release();
EXPECT_NO_THROW(cv::imread(file)); try
remove(file.c_str()); {
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 #endif

View File

@ -90,7 +90,7 @@ PERF_TEST_P(Size_MatType_BorderType3x3, blur3x3,
PERF_TEST_P(Size_MatType_BorderType, blur16x16, PERF_TEST_P(Size_MatType_BorderType, blur16x16,
testing::Combine( 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::Values(CV_8UC1, CV_8UC4, CV_16UC1, CV_16SC1, CV_32FC1),
testing::ValuesIn(BorderType::all()) testing::ValuesIn(BorderType::all())
) )
@ -184,7 +184,7 @@ PERF_TEST_P(Size_MatType_BorderType, gaussianBlur5x5,
PERF_TEST_P(Size_MatType_BorderType, blur5x5, PERF_TEST_P(Size_MatType_BorderType, blur5x5,
testing::Combine( 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::Values(CV_8UC1, CV_8UC4, CV_16UC1, CV_16SC1, CV_32FC1, CV_32FC3),
testing::ValuesIn(BorderType::all()) testing::ValuesIn(BorderType::all())
) )

View File

@ -56,11 +56,6 @@ enum
}; };
CV_ENUM(CvtMode, 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_BGR2BGR555, CV_BGR2BGR565, CV_BGR2BGRA, CV_BGR2GRAY,
CV_BGR2HLS, CV_BGR2HLS_FULL, CV_BGR2HSV, CV_BGR2HSV_FULL, CV_BGR2HLS, CV_BGR2HLS_FULL, CV_BGR2HSV, CV_BGR2HSV_FULL,
CV_BGR2Lab, CV_BGR2Luv, CV_BGR2RGB, CV_BGR2RGBA, CV_BGR2XYZ, 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_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_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, 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, 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_t> Size_CvtMode;
PERF_TEST_P(Size_CvtMode, cvtColor8u, PERF_TEST_P(Size_CvtMode, cvtColor8u,
testing::Combine( testing::Combine(
testing::Values(TYPICAL_MAT_SIZES), testing::Values(::perf::szODD, ::perf::szVGA, ::perf::sz1080p),
testing::ValuesIn(CvtMode::all()) testing::ValuesIn(CvtMode::all())
) )
) )
@ -252,12 +256,38 @@ PERF_TEST_P(Size_CvtMode, cvtColor8u,
SANITY_CHECK(dst, 1); SANITY_CHECK(dst, 1);
} }
typedef std::tr1::tuple<Size, CvtModeBayer> Size_CvtMode_Bayer_t;
typedef perf::TestBaseWithParam<Size_CvtMode_Bayer_t> 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> Size_CvtMode2_t; typedef std::tr1::tuple<Size, CvtMode2> Size_CvtMode2_t;
typedef perf::TestBaseWithParam<Size_CvtMode2_t> Size_CvtMode2; typedef perf::TestBaseWithParam<Size_CvtMode2_t> Size_CvtMode2;
PERF_TEST_P(Size_CvtMode2, cvtColorYUV420, PERF_TEST_P(Size_CvtMode2, cvtColorYUV420,
testing::Combine( testing::Combine(
testing::Values(szVGA, sz720p, sz1080p, Size(130, 60)), testing::Values(szVGA, sz1080p, Size(130, 60)),
testing::ValuesIn(CvtMode2::all()) testing::ValuesIn(CvtMode2::all())
) )
) )

View File

@ -15,7 +15,7 @@ typedef TestBaseWithParam< tr1::tuple<String, int> > Image_KernelSize;
PERF_TEST_P( TestFilter2d, Filter2d, PERF_TEST_P( TestFilter2d, Filter2d,
Combine( Combine(
Values( Size(320, 240), szVGA, sz720p, sz1080p ), Values( Size(320, 240), sz1080p ),
Values( 3, 5 ), Values( 3, 5 ),
ValuesIn( BorderMode::all() ) ValuesIn( BorderMode::all() )
) )

View File

@ -32,7 +32,7 @@ PERF_TEST_P(Image_RhoStep_ThetaStep_Threshold, HoughLines,
Canny(image, image, 0, 0); Canny(image, image, 0, 0);
Mat lines; Mat lines;
declare.time(40); declare.time(60);
TEST_CYCLE() HoughLines(image, lines, rhoStep, thetaStep, threshold); TEST_CYCLE() HoughLines(image, lines, rhoStep, thetaStep, threshold);

View File

@ -33,9 +33,9 @@ PERF_TEST_P(Size_MatType_OutMatDepth, integral,
PERF_TEST_P(Size_MatType_OutMatDepth, integral_sqsum, PERF_TEST_P(Size_MatType_OutMatDepth, integral_sqsum,
testing::Combine( testing::Combine(
testing::Values(TYPICAL_MAT_SIZES), testing::Values(::perf::szVGA, ::perf::sz1080p),
testing::Values(CV_8UC1, CV_8UC4), 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, PERF_TEST_P( Size_MatType_OutMatDepth, integral_sqsum_tilted,
testing::Combine( testing::Combine(
testing::Values( TYPICAL_MAT_SIZES ), testing::Values( ::perf::szVGA, ::perf::szODD , ::perf::sz1080p ),
testing::Values( CV_8UC1, CV_8UC4 ), testing::Values( CV_8UC1, CV_8UC4 ),
testing::Values( CV_32S, CV_32F, CV_64F ) testing::Values( CV_32S, CV_32F )
) )
) )
{ {

View File

@ -97,7 +97,7 @@ typedef TestBaseWithParam<tr1::tuple<MatType, Size, double> > MatInfo_Size_Scale
PERF_TEST_P(MatInfo_Size_Scale_Area, ResizeArea, PERF_TEST_P(MatInfo_Size_Scale_Area, ResizeArea,
testing::Combine( testing::Combine(
testing::Values(CV_8UC1, CV_8UC4), 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) testing::Values(2.4, 3.4, 1.3)
) )
) )

View File

@ -31,7 +31,7 @@ PERF_TEST_P(Size_MatType_ThreshType, threshold,
double maxval = theRNG().uniform(1, 254); double maxval = theRNG().uniform(1, 254);
declare.in(src, WARMUP_RNG).out(dst); declare.in(src, WARMUP_RNG).out(dst);
declare.time(100); declare.iterations(500);
TEST_CYCLE() threshold(src, dst, thresh, maxval, threshType); TEST_CYCLE() threshold(src, dst, thresh, maxval, threshType);

View File

@ -90,12 +90,7 @@ PERF_TEST_P( TestWarpPerspective, WarpPerspective,
PERF_TEST_P( TestWarpPerspectiveNear_t, WarpPerspectiveNear, PERF_TEST_P( TestWarpPerspectiveNear_t, WarpPerspectiveNear,
Combine( Combine(
Values( Size(176,144), Size(320,240), Size(352,288), Size(480,480), Values( Size(640,480), Size(1920,1080), Size(2592,1944) ),
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) ),
ValuesIn( InterType::all() ), ValuesIn( InterType::all() ),
ValuesIn( BorderMode::all() ), ValuesIn( BorderMode::all() ),
Values( CV_8UC1, CV_8UC4 ) Values( CV_8UC1, CV_8UC4 )

View File

@ -169,11 +169,11 @@ CvBoost::predict
---------------- ----------------
Predicts a response for an input sample. 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: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. :param sample: Input sample.

View File

@ -621,7 +621,7 @@ TEST(Features2d_RotationInvariance_Detector_SURF, regression)
test.safe_run(); test.safe_run();
} }
TEST(Features2d_RotationInvariance_Detector_SIFT, regression) TEST(Features2d_RotationInvariance_Detector_SIFT, DISABLED_regression)
{ {
DetectorRotationInvarianceTest test(Algorithm::create<FeatureDetector>("Feature2D.SIFT"), DetectorRotationInvarianceTest test(Algorithm::create<FeatureDetector>("Feature2D.SIFT"),
0.45f, 0.45f,

View File

@ -45,20 +45,20 @@
#include <stdio.h> #include <stdio.h>
#include "opencv2/core/internal.hpp" #include "opencv2/core/internal.hpp"
#if CV_SSE2 || CV_SSE3 #if CV_SSE2
# if !CV_SSE4_1 && !CV_SSE4_2 # 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_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)) # define _mm_blendv_ps(a, b, m) _mm_xor_ps(a, _mm_and_ps(_mm_xor_ps(b, a), m))
# endif # endif
#endif #endif
#if CV_AVX #if 0 /*CV_AVX*/
# define CV_HAAR_USE_AVX 1 # define CV_HAAR_USE_AVX 1
# if defined _MSC_VER # if defined _MSC_VER
# pragma warning( disable : 4752 ) # pragma warning( disable : 4752 )
# endif # endif
#else #else
# if CV_SSE2 || CV_SSE3 # if CV_SSE2
# define CV_HAAR_USE_SSE 1 # define CV_HAAR_USE_SSE 1
# endif # endif
#endif #endif

View File

@ -87,11 +87,15 @@ protected:
vector<string> imageFilenames; vector<string> imageFilenames;
vector<Mat> images; vector<Mat> images;
string validationFilename; string validationFilename;
string configFilename;
FileStorage validationFS; FileStorage validationFS;
bool write_results;
}; };
CV_DetectorTest::CV_DetectorTest() CV_DetectorTest::CV_DetectorTest()
{ {
configFilename = "dummy";
write_results = false;
} }
string& CV_DetectorTest::getValidationFilename() string& CV_DetectorTest::getValidationFilename()
@ -146,86 +150,99 @@ int CV_DetectorTest::prepareData( FileStorage& _fs )
void CV_DetectorTest::run( int ) void CV_DetectorTest::run( int )
{ {
string dataPath = ts->get_data_path(); string dataPath = ts->get_data_path();
validationFS.open( dataPath + getValidationFilename(), FileStorage::READ ); string vs_filename = dataPath + getValidationFilename();
int code = prepareData( validationFS );
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 ) if( code < 0 )
{ {
ts->set_failed_test_info( code ); ts->set_failed_test_info( code );
return; return;
} }
#ifdef GET_STAT if( write_results )
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<string>::const_iterator nit = detectorNames.begin();
for( ; nit != detectorNames.end(); ++nit )
{ {
validationFS << *nit; validationFS.release();
} validationFS.open( vs_filename, FileStorage::WRITE );
validationFS << "]"; // DETECTOR_NAMES validationFS << FileStorage::getDefaultObjectName(validationFilename) << "{";
// write detectors validationFS << DIST_E << eps.dist;
validationFS << DETECTORS << "{"; validationFS << S_E << eps.s;
assert( detectorNames.size() == detectorFilenames.size() ); validationFS << NO_PAIR_E << eps.noPair;
nit = detectorNames.begin(); // validationFS << TOTAL_NO_PAIR_E << eps.totalNoPair;
for( int di = 0; di < detectorNames.size(), nit != detectorNames.end(); ++nit, di++ )
{ // write detector names
validationFS << *nit << "{"; validationFS << DETECTOR_NAMES << "[";
writeDetector( validationFS, di ); vector<string>::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 << "}";
}
validationFS << "}";
// write image filenames // write image filenames
validationFS << IMAGE_FILENAMES << "["; validationFS << IMAGE_FILENAMES << "[";
vector<string>::const_iterator it = imageFilenames.begin(); vector<string>::const_iterator it = imageFilenames.begin();
for( int ii = 0; it != imageFilenames.end(); ++it, ii++ ) for( int ii = 0; it != imageFilenames.end(); ++it, ii++ )
{ {
char buf[10]; char buf[10];
sprintf( buf, "%s%d", "img_", ii ); sprintf( buf, "%s%d", "img_", ii );
cvWriteComment( validationFS.fs, buf, 0 ); cvWriteComment( validationFS.fs, buf, 0 );
validationFS << *it; validationFS << *it;
} }
validationFS << "]"; // IMAGE_FILENAMES validationFS << "]"; // IMAGE_FILENAMES
validationFS << VALIDATION << "{"; validationFS << VALIDATION << "{";
#endif }
int progress = 0; int progress = 0;
for( int di = 0; di < test_case_count; di++ ) for( int di = 0; di < test_case_count; di++ )
{ {
progress = update_progress( progress, di, test_case_count, 0 ); progress = update_progress( progress, di, test_case_count, 0 );
#ifdef GET_STAT if( write_results )
validationFS << detectorNames[di] << "{"; validationFS << detectorNames[di] << "{";
#endif
vector<vector<Rect> > objects; vector<vector<Rect> > objects;
int temp_code = runTestCase( di, 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 ); temp_code = validate( di, objects );
#endif
if (temp_code != cvtest::TS::OK) if (temp_code != cvtest::TS::OK)
code = temp_code; code = temp_code;
#ifdef GET_STAT
validationFS << "}"; // detectorNames[di] if( write_results )
#endif 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 ) if ( test_case_count <= 0 || imageFilenames.size() <= 0 )
{ {
ts->printf( cvtest::TS::LOG, "validation file is not determined or not correct" ); ts->printf( cvtest::TS::LOG, "validation file is not determined or not correct" );
@ -257,18 +274,19 @@ int CV_DetectorTest::runTestCase( int detectorIdx, vector<vector<Rect> >& object
objects.push_back( imgObjects ); objects.push_back( imgObjects );
#ifdef GET_STAT if( write_results )
char buf[10];
sprintf( buf, "%s%d", "img_", ii );
string imageIdxStr = buf;
validationFS << imageIdxStr << "[:";
for( vector<Rect>::const_iterator it = imgObjects.begin();
it != imgObjects.end(); ++it )
{ {
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<Rect>::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; return cvtest::TS::OK;
} }
@ -374,12 +392,14 @@ protected:
virtual void readDetector( const FileNode& fn ); virtual void readDetector( const FileNode& fn );
virtual void writeDetector( FileStorage& fs, int di ); virtual void writeDetector( FileStorage& fs, int di );
virtual int detectMultiScale( int di, const Mat& img, vector<Rect>& objects ); virtual int detectMultiScale( int di, const Mat& img, vector<Rect>& objects );
virtual int detectMultiScale_C( const string& filename, int di, const Mat& img, vector<Rect>& objects );
vector<int> flags; vector<int> flags;
}; };
CV_CascadeDetectorTest::CV_CascadeDetectorTest() CV_CascadeDetectorTest::CV_CascadeDetectorTest()
{ {
validationFilename = "cascadeandhog/cascade.xml"; validationFilename = "cascadeandhog/cascade.xml";
configFilename = "cascadeandhog/_cascade.xml";
} }
void CV_CascadeDetectorTest::readDetector( const FileNode& fn ) void CV_CascadeDetectorTest::readDetector( const FileNode& fn )
@ -402,11 +422,48 @@ void CV_CascadeDetectorTest::writeDetector( FileStorage& fs, int di )
fs << C_SCALE_CASCADE << sc; fs << C_SCALE_CASCADE << sc;
} }
int CV_CascadeDetectorTest::detectMultiScale_C( const string& filename,
int di, const Mat& img,
vector<Rect>& objects )
{
Ptr<CvHaarClassifierCascade> c_cascade = cvLoadHaarClassifierCascade(filename.c_str(), cvSize(0,0));
Ptr<CvMemStorage> 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, int CV_CascadeDetectorTest::detectMultiScale( int di, const Mat& img,
vector<Rect>& objects) vector<Rect>& objects)
{ {
string dataPath = ts->get_data_path(), filename; string dataPath = ts->get_data_path(), filename;
filename = dataPath + detectorFilenames[di]; 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 ); CascadeClassifier cascade( filename );
if( cascade.empty() ) if( cascade.empty() )
{ {

View File

@ -13,7 +13,7 @@ typedef perf::TestBaseWithParam<InpaintArea_InpaintingMethod_t> InpaintArea_Inpa
PERF_TEST_P(InpaintArea_InpaintingMethod, inpaint, PERF_TEST_P(InpaintArea_InpaintingMethod, inpaint,
testing::Combine( testing::Combine(
SZ_ALL_SMALL, testing::Values(::perf::szSmall24, ::perf::szSmall32, ::perf::szSmall64),
testing::ValuesIn(InpaintingMethod::all()) testing::ValuesIn(InpaintingMethod::all())
) )
) )

View File

@ -323,6 +323,27 @@
#define CV_CAP_PROP_EXPOSURE 15 #define CV_CAP_PROP_EXPOSURE 15
#define CV_CAP_PROP_CONVERT_RGB 16 #define CV_CAP_PROP_CONVERT_RGB 16
#define CV_CAP_PROP_RECTIFICATION 18 #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_CN_SHIFT 3
#define CV_IMWRITE_JPEG_QUALITY 1 #define CV_IMWRITE_JPEG_QUALITY 1
#define CV_IMWRITE_PNG_COMPRESSION 16 #define CV_IMWRITE_PNG_COMPRESSION 16

View File

@ -16,6 +16,8 @@ import functools
import cv2.cv as cv import cv2.cv as cv
from test2 import *
class OpenCVTests(unittest.TestCase): 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 ] 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.assertEqual(self.hashimg(h1), self.hashimg(h3))
self.assertNotEqual(self.hashimg(h1), self.hashimg(h2)) self.assertNotEqual(self.hashimg(h1), self.hashimg(h2))
class NewTests(OpenCVTests):
pass
if __name__ == '__main__': if __name__ == '__main__':
print "testing", cv.__version__ print "testing", cv.__version__
random.seed(0) random.seed(0)

View File

@ -41,12 +41,47 @@ class Hackathon244Tests(NewOpenCVTests):
absa0 = np.abs(a) absa0 = np.abs(a)
self.assert_(cv2.norm(a, cv2.NORM_L1) == 15) self.assert_(cv2.norm(a, cv2.NORM_L1) == 15)
absa1 = cv2.absdiff(a, 0) 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): def test_imencode(self):
a = np.zeros((480, 640), dtype=np.uint8) a = np.zeros((480, 640), dtype=np.uint8)
flag, ajpg = cv2.imencode("img_q90.jpg", a, [cv2.IMWRITE_JPEG_QUALITY, 90]) 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__': if __name__ == '__main__':
print "testing", cv.__version__ print "testing", cv.__version__

View File

@ -154,7 +154,7 @@ PERF_TEST_P( match, bestOf2Nearest, TEST_DETECTORS)
PERF_TEST_P( matchVector, bestOf2NearestVectorFeatures, testing::Combine( PERF_TEST_P( matchVector, bestOf2NearestVectorFeatures, testing::Combine(
TEST_DETECTORS, TEST_DETECTORS,
testing::Values(2, 4, 6, 8)) testing::Values(2, 4, 8))
) )
{ {
Mat img1, img1_full = imread( getDataPath("stitching/b1.png") ); Mat img1, img1_full = imread( getDataPath("stitching/b1.png") );

View File

@ -334,29 +334,21 @@ void Regression::write(cv::Mat m)
write() << "val" << getElem(m, y, x, cn) << "}"; write() << "val" << getElem(m, y, x, cn) << "}";
} }
static double evalEps(double expected, double actual, double _eps, ERROR_TYPE err) void Regression::verify(cv::FileNode node, cv::Mat actual, double eps, std::string argname, 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)
{ {
if (!actual.empty() && actual.dims < 2) return; 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; double actual_min, actual_max;
cv::minMaxIdx(actual, &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) ASSERT_NEAR(expect_min, actual_min, eps)
<< argname << " has unexpected minimal value" << std::endl; << 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) ASSERT_NEAR(expect_max, actual_max, eps)
<< argname << " has unexpected maximal value" << std::endl; << 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; << argname << " has unexpected number of rows" << std::endl;
double expect_last = (double)last["val"]; double expect_last = (double)last["val"];
eps = evalEps(expect_last, actual_last, _eps, err);
ASSERT_NEAR(expect_last, actual_last, eps) ASSERT_NEAR(expect_last, actual_last, eps)
<< argname << " has unexpected value of the last element" << std::endl; << 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 // verified that mat size is the same as recorded
double actual_rng1 = getElem(actual, y1, x1, cn1); double actual_rng1 = getElem(actual, y1, x1, cn1);
eps = evalEps(expect_rng1, actual_rng1, _eps, err);
ASSERT_NEAR(expect_rng1, actual_rng1, eps) ASSERT_NEAR(expect_rng1, actual_rng1, eps)
<< argname << " has unexpected value of the ["<< x1 << ":" << y1 << ":" << cn1 <<"] element" << std::endl; << 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 expect_rng2 = (double)rng2["val"];
double actual_rng2 = getElem(actual, y2, x2, cn2); double actual_rng2 = getElem(actual, y2, x2, cn2);
eps = evalEps(expect_rng2, actual_rng2, _eps, err);
ASSERT_NEAR(expect_rng2, actual_rng2, eps) ASSERT_NEAR(expect_rng2, actual_rng2, eps)
<< argname << " has unexpected value of the ["<< x2 << ":" << y2 << ":" << cn2 <<"] element" << std::endl; << argname << " has unexpected value of the ["<< x2 << ":" << y2 << ":" << cn2 <<"] element" << std::endl;
} }

View File

@ -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 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). :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).

View File

@ -33,7 +33,7 @@ PERF_TEST_P(Path_Idx_Cn_NPoints_WSize, OpticalFlowPyrLK_full, testing::Combine(
testing::Range(1, 3), testing::Range(1, 3),
testing::Values(1, 3, 4), testing::Values(1, 3, 4),
testing::Values(make_tuple(9, 9), make_tuple(15, 15)), 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::Range(1, 3),
testing::Values(1, 3, 4), testing::Values(1, 3, 4),
testing::Values(make_tuple(9, 9), make_tuple(15, 15)), testing::Values(make_tuple(9, 9), make_tuple(15, 15)),
testing::Values(7, 11, 25), testing::Values(7, 11),
testing::Bool() testing::Bool()
) )
) )