From e45f92a9e12fbd1031280eea01ad76fcbb4612eb Mon Sep 17 00:00:00 2001 From: pengxiao Date: Wed, 4 Sep 2013 16:38:36 +0800 Subject: [PATCH 01/55] Fix a bug of ocl retina on NVIDIA platform. --- .../bioinspired/src/opencl/retina_kernel.cl | 59 ++++++++++++++----- modules/bioinspired/src/retina_ocl.cpp | 2 +- modules/bioinspired/test/test_retina_ocl.cpp | 2 +- 3 files changed, 47 insertions(+), 16 deletions(-) diff --git a/modules/bioinspired/src/opencl/retina_kernel.cl b/modules/bioinspired/src/opencl/retina_kernel.cl index 6da4219d9c..1eac50324a 100644 --- a/modules/bioinspired/src/opencl/retina_kernel.cl +++ b/modules/bioinspired/src/opencl/retina_kernel.cl @@ -114,19 +114,34 @@ kernel void horizontalAnticausalFilter( global float * optr = output + mad24(gid + 1, elements_per_row, - 1 + out_offset / 4); - float4 result = (float4)(0), out_v4; + float4 result_v4 = (float4)(0), out_v4; + float result = 0; // we assume elements_per_row is multple of 4 - for(int i = 0; i < elements_per_row / 4; ++i, optr -= 4) + for(int i = 0; i < 4; ++ i, -- optr) + { + if(i < elements_per_row - cols) + { + *optr = result; + } + else + { + result = *optr + _a * result; + *optr = result; + } + } + result_v4.x = result; + optr -= 3; + for(int i = 1; i < elements_per_row / 4; ++i, optr -= 4) { // shift left, `offset` is type `size_t` so it cannot be negative - out_v4 = vload4(0, optr - 3); + out_v4 = vload4(0, optr); - result.w = out_v4.w + _a * result.x; - result.z = out_v4.z + _a * result.w; - result.y = out_v4.y + _a * result.z; - result.x = out_v4.x + _a * result.y; + result_v4.w = out_v4.w + _a * result_v4.x; + result_v4.z = out_v4.z + _a * result_v4.w; + result_v4.y = out_v4.y + _a * result_v4.z; + result_v4.x = out_v4.x + _a * result_v4.y; - vstore4(result, 0, optr - 3); + vstore4(result_v4, 0, optr); } } @@ -207,18 +222,34 @@ kernel void horizontalAnticausalFilter_Irregular( buffer + mad24(rows - gid, elements_per_row, -1 + buffer_offset / 4); float4 buf_v4, out_v4, res_v4 = (float4)(0); - - for(int i = 0; i < elements_per_row / 4; ++i, optr -= 4, bptr -= 4) - { - buf_v4 = vload4(0, bptr - 3); - out_v4 = vload4(0, optr - 3); + float result = 0; + // we assume elements_per_row is multple of 4 + for(int i = 0; i < 4; ++ i, -- optr, -- bptr) + { + if(i < elements_per_row - cols) + { + *optr = result; + } + else + { + result = *optr + *bptr * result; + *optr = result; + } + } + res_v4.x = result; + optr -= 3; + bptr -= 3; + for(int i = 0; i < elements_per_row / 4 - 1; ++i, optr -= 4, bptr -= 4) + { + buf_v4 = vload4(0, bptr); + out_v4 = vload4(0, optr); res_v4.w = out_v4.w + buf_v4.w * res_v4.x; res_v4.z = out_v4.z + buf_v4.z * res_v4.w; res_v4.y = out_v4.y + buf_v4.y * res_v4.z; res_v4.x = out_v4.x + buf_v4.x * res_v4.y; - vstore4(res_v4, 0, optr - 3); + vstore4(res_v4, 0, optr); } } diff --git a/modules/bioinspired/src/retina_ocl.cpp b/modules/bioinspired/src/retina_ocl.cpp index 8f1f2694ef..ca94bc8fb6 100644 --- a/modules/bioinspired/src/retina_ocl.cpp +++ b/modules/bioinspired/src/retina_ocl.cpp @@ -1149,7 +1149,7 @@ void RetinaColor::_initColorSampling() // computing photoreceptors local density MAKE_OCLMAT_SLICES(_RGBmosaic, 3); MAKE_OCLMAT_SLICES(_colorLocalDensity, 3); - + _colorLocalDensity.setTo(0); _spatiotemporalLPfilter(_RGBmosaic_slices[0], _colorLocalDensity_slices[0]); _spatiotemporalLPfilter(_RGBmosaic_slices[1], _colorLocalDensity_slices[1]); _spatiotemporalLPfilter(_RGBmosaic_slices[2], _colorLocalDensity_slices[2]); diff --git a/modules/bioinspired/test/test_retina_ocl.cpp b/modules/bioinspired/test/test_retina_ocl.cpp index a732d7e37e..b09ce50366 100644 --- a/modules/bioinspired/test/test_retina_ocl.cpp +++ b/modules/bioinspired/test/test_retina_ocl.cpp @@ -49,7 +49,7 @@ #include "opencv2/imgproc.hpp" #include "opencv2/highgui.hpp" -#if defined(HAVE_OPENCV_OCL) && defined(HAVE_OPENCL) +#if defined(HAVE_OPENCV_OCL) #include "opencv2/ocl.hpp" #define RETINA_ITERATIONS 5 From 461c98fa86156a41249ed6c77e859f8d0093abc9 Mon Sep 17 00:00:00 2001 From: Roman Donchenko Date: Tue, 13 Aug 2013 15:18:07 +0400 Subject: [PATCH 02/55] Replaced Ptr with my new implementation. --- modules/core/include/opencv2/core/cvstd.hpp | 365 ++++++++---------- modules/core/include/opencv2/core/ptr.inl.hpp | 338 ++++++++++++++++ 2 files changed, 490 insertions(+), 213 deletions(-) create mode 100644 modules/core/include/opencv2/core/ptr.inl.hpp diff --git a/modules/core/include/opencv2/core/cvstd.hpp b/modules/core/include/opencv2/core/cvstd.hpp index 5014dba0f7..afdeb2549a 100644 --- a/modules/core/include/opencv2/core/cvstd.hpp +++ b/modules/core/include/opencv2/core/cvstd.hpp @@ -158,69 +158,176 @@ public: size_type max_size() const { return cv::max(static_cast<_Tp>(-1)/sizeof(_Tp), 1); } }; +namespace detail +{ +// Metafunction to avoid taking a reference to void. +template +struct RefOrVoid { typedef T& type; }; -//////////////////// generic_type ref-counting pointer class for C/C++ objects //////////////////////// +template<> +struct RefOrVoid{ typedef void type; }; -/*! - Smart pointer to dynamically allocated objects. +template<> +struct RefOrVoid{ typedef const void type; }; - This is template pointer-wrapping class that stores the associated reference counter along with the - object pointer. The class is similar to std::smart_ptr<> from the recent addons to the C++ standard, - but is shorter to write :) and self-contained (i.e. does add any dependency on the compiler or an external library). +template<> +struct RefOrVoid{ typedef volatile void type; }; - Basically, you can use "Ptr ptr" (or faster "const Ptr& ptr" for read-only access) - everywhere instead of "MyObjectType* ptr", where MyObjectType is some C structure or a C++ class. - To make it all work, you need to specialize Ptr<>::delete_obj(), like: +template<> +struct RefOrVoid{ typedef const volatile void type; }; - \code - template<> CV_EXPORTS void Ptr::delete_obj() { call_destructor_func(obj); } - \endcode +// This class would be private to Ptr, if it didn't have to be a non-template. +struct PtrOwner; + +} + +template +struct DefaultDeleter +{ + void operator () (Y* p) const; +}; - \note{if MyObjectType is a C++ class with a destructor, you do not need to specialize delete_obj(), - since the default implementation calls "delete obj;"} +/* + A smart shared pointer class with reference counting. - \note{Another good property of the class is that the operations on the reference counter are atomic, - i.e. it is safe to use the class in multi-threaded applications} + A Ptr stores a pointer and owns a (potentially different) pointer. + The stored pointer has type T and is the one returned by get() et al, + while the owned pointer can have any type and is the one deleted + when there are no more Ptrs that own it. You can't directly obtain the + owned pointer. + + The interface of this class is mostly a subset of that of C++11's + std::shared_ptr. */ -template class Ptr +template +struct Ptr { -public: - //! empty constructor + /* Generic programming support. */ + typedef T element_type; + + /* Ptr that owns NULL and stores NULL. */ Ptr(); - //! take ownership of the pointer. The associated reference counter is allocated and set to 1 - Ptr(_Tp* _obj); - //! calls release() + + /* Ptr that owns p and stores p. The owned pointer will be deleted with + DefaultDeleter. Y must be a complete type and Y* must be + convertible to T*. */ + template + explicit Ptr(Y* p); + + /* Ptr that owns p and stores p. The owned pointer will be deleted by + calling d(p). Y* must be convertible to T*. */ + template + Ptr(Y* p, D d); + + /* Same as the constructor below; it exists to suppress the generation + of the implicit copy constructor. */ + Ptr(const Ptr& o); + + /* Ptr that owns the same pointer as o and stores the same pointer as o, + converted to T*. Naturally, Y* must be convertible to T*. */ + template + Ptr(const Ptr& o); + + /* Ptr that owns same pointer as o, and stores p. Useful for casts and + creating non-owning Ptrs. */ + template + Ptr(const Ptr& o, T* p); + + /* Equivalent to release(). */ ~Ptr(); - //! copy constructor. Copies the members and calls addref() - Ptr(const Ptr& ptr); - template Ptr(const Ptr<_Tp2>& ptr); - //! copy operator. Calls ptr.addref() and release() before copying the members - Ptr& operator = (const Ptr& ptr); - //! increments the reference counter - void addref(); - //! decrements the reference counter. If it reaches 0, delete_obj() is called + + /* Same as assignment below; exists to suppress the generation of the + implicit assignment operator. */ + Ptr& operator = (const Ptr& o); + + template + Ptr& operator = (const Ptr& o); + + /* Resets both the owned and stored pointers to NULL. Deletes the owned + pointer with the associated deleter if it's not owned by any other + Ptr and is non-zero. It's called reset() in std::shared_ptr; here + it is release() for compatibility with old OpenCV versions. */ void release(); - //! deletes the object. Override if needed - void delete_obj(); - //! returns true iff obj==NULL + + /* Equivalent to assigning from Ptr(p). */ + template + void reset(Y* p); + + /* Equivalent to assigning from Ptr(p, d). */ + template + void reset(Y* p, D d); + + /* Swaps the stored and owned pointers of this and o. */ + void swap(Ptr& o); + + /* Returns the stored pointer. */ + T* get() const; + + /* Ordinary pointer emulation. */ + typename detail::RefOrVoid::type operator * () const; + T* operator -> () const; + + /* Equivalent to get(). */ + operator T* () const; + + /* Equivalent to !*this. */ bool empty() const; - //! cast pointer to another type - template Ptr<_Tp2> ptr(); - template const Ptr<_Tp2> ptr() const; + /* Returns a Ptr that owns the same pointer as this, and stores the same + pointer as this, except converted via static_cast to Y*. */ + template + Ptr staticCast() const; + + /* Ditto for const_cast. */ + template + Ptr constCast() const; - //! helper operators making "Ptr ptr" use very similar to "T* ptr". - _Tp* operator -> (); - const _Tp* operator -> () const; + /* Ditto for dynamic_cast. */ + template + Ptr dynamicCast() const; - operator _Tp* (); - operator const _Tp*() const; +private: + detail::PtrOwner* owner; + T* stored; - _Tp* obj; //< the object pointer. - int* refcount; //< the associated reference counter + template + friend struct Ptr; // have to do this for the cross-type copy constructor }; +/* Overload of the generic swap. */ +template +void swap(Ptr& ptr1, Ptr& ptr2); + +/* Obvious comparisons. */ +template +bool operator == (const Ptr& ptr1, const Ptr& ptr2); +template +bool operator != (const Ptr& ptr1, const Ptr& ptr2); + +/* Convenience creation functions. In the far future, there may be variadic templates here. */ +template +Ptr makePtr(); +template +Ptr makePtr(const A1& a1); +template +Ptr makePtr(const A1& a1, const A2& a2); +template +Ptr makePtr(const A1& a1, const A2& a2, const A3& a3); +template +Ptr makePtr(const A1& a1, const A2& a2, const A3& a3, const A4& a4); +template +Ptr makePtr(const A1& a1, const A2& a2, const A3& a3, const A4& a4, const A5& a5); +template +Ptr makePtr(const A1& a1, const A2& a2, const A3& a3, const A4& a4, const A5& a5, const A6& a6); +template +Ptr makePtr(const A1& a1, const A2& a2, const A3& a3, const A4& a4, const A5& a5, const A6& a6, const A7& a7); +template +Ptr makePtr(const A1& a1, const A2& a2, const A3& a3, const A4& a4, const A5& a5, const A6& a6, const A7& a7, const A8& a8); +template +Ptr makePtr(const A1& a1, const A2& a2, const A3& a3, const A4& a4, const A5& a5, const A6& a6, const A7& a7, const A8& a8, const A9& a9); +template +Ptr makePtr(const A1& a1, const A2& a2, const A3& a3, const A4& a4, const A5& a5, const A6& a6, const A7& a7, const A8& a8, const A9& a9, const A10& a10); //////////////////////////////// string class //////////////////////////////// @@ -324,176 +431,6 @@ private: }; - -/////////////////////////// cv::Ptr implementation /////////////////////////// - -template inline -Ptr<_Tp>::Ptr() - : obj(0), refcount(0) {} - -template inline -Ptr<_Tp>::Ptr(_Tp* _obj) - : obj(_obj) -{ - if(obj) - { - refcount = (int*)fastMalloc(sizeof(*refcount)); - *refcount = 1; - } - else - refcount = 0; -} - -template template -Ptr<_Tp>::Ptr(const Ptr<_Tp2>& p) - : obj(0), refcount(0) -{ - if (p.empty()) - return; - - _Tp* p_casted = dynamic_cast<_Tp*>(p.obj); - if (!p_casted) - return; - - obj = p_casted; - refcount = p.refcount; - addref(); -} - -template inline -Ptr<_Tp>::~Ptr() -{ - release(); -} - -template inline -void Ptr<_Tp>::addref() -{ - if( refcount ) - CV_XADD(refcount, 1); -} - -template inline -void Ptr<_Tp>::release() -{ - if( refcount && CV_XADD(refcount, -1) == 1 ) - { - delete_obj(); - fastFree(refcount); - } - refcount = 0; - obj = 0; -} - -template inline -void Ptr<_Tp>::delete_obj() -{ - if( obj ) - delete obj; -} - -template inline -Ptr<_Tp>::Ptr(const Ptr<_Tp>& _ptr) -{ - obj = _ptr.obj; - refcount = _ptr.refcount; - addref(); -} - -template inline -Ptr<_Tp>& Ptr<_Tp>::operator = (const Ptr<_Tp>& _ptr) -{ - int* _refcount = _ptr.refcount; - if( _refcount ) - CV_XADD(_refcount, 1); - release(); - obj = _ptr.obj; - refcount = _refcount; - return *this; -} - -template inline -_Tp* Ptr<_Tp>::operator -> () -{ - return obj; -} - -template inline -const _Tp* Ptr<_Tp>::operator -> () const -{ - return obj; -} - -template inline -Ptr<_Tp>::operator _Tp* () -{ - return obj; -} - -template inline -Ptr<_Tp>::operator const _Tp*() const -{ - return obj; -} - -template inline -bool Ptr<_Tp>::empty() const -{ - return obj == 0; -} - -template template inline -Ptr<_Tp2> Ptr<_Tp>::ptr() -{ - Ptr<_Tp2> p; - if( !obj ) - return p; - - _Tp2* obj_casted = dynamic_cast<_Tp2*>(obj); - if (!obj_casted) - return p; - - if( refcount ) - CV_XADD(refcount, 1); - - p.obj = obj_casted; - p.refcount = refcount; - return p; -} - -template template inline -const Ptr<_Tp2> Ptr<_Tp>::ptr() const -{ - Ptr<_Tp2> p; - if( !obj ) - return p; - - _Tp2* obj_casted = dynamic_cast<_Tp2*>(obj); - if (!obj_casted) - return p; - - if( refcount ) - CV_XADD(refcount, 1); - - p.obj = obj_casted; - p.refcount = refcount; - return p; -} - -template static inline -bool operator == (const Ptr<_Tp>& a, const Ptr<_Tp2>& b) -{ - return a.refcount == b.refcount; -} - -template static inline -bool operator != (const Ptr<_Tp>& a, const Ptr<_Tp2>& b) -{ - return a.refcount != b.refcount; -} - - - ////////////////////////// cv::String implementation ///////////////////////// inline @@ -940,4 +877,6 @@ namespace cv } } +#include "opencv2/core/ptr.inl.hpp" + #endif //__OPENCV_CORE_CVSTD_HPP__ diff --git a/modules/core/include/opencv2/core/ptr.inl.hpp b/modules/core/include/opencv2/core/ptr.inl.hpp new file mode 100644 index 0000000000..989724281f --- /dev/null +++ b/modules/core/include/opencv2/core/ptr.inl.hpp @@ -0,0 +1,338 @@ +/*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. +// +// +// License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2013, NVIDIA 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 the copyright holders 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 copyright holders 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*/ + +#ifndef __OPENCV_CORE_PTR_INL_HPP__ +#define __OPENCV_CORE_PTR_INL_HPP__ + +#include + +namespace cv { + +template +void DefaultDeleter::operator () (Y* p) const +{ + delete p; +} + +namespace detail +{ + +struct PtrOwner +{ + PtrOwner() : refCount(1) + {} + + void incRef() + { + CV_XADD(&refCount, 1); + } + + void decRef() + { + if (CV_XADD(&refCount, -1) == 1) deleteSelf(); + } + +protected: + /* This doesn't really need to be virtual, since PtrOwner is never deleted + directly, but it doesn't hurt and it helps avoid warnings. */ + virtual ~PtrOwner() + {} + + virtual void deleteSelf() = 0; + +private: + unsigned int refCount; + + // noncopyable + PtrOwner(const PtrOwner&); + PtrOwner& operator = (const PtrOwner&); +}; + +template +struct PtrOwnerImpl : PtrOwner +{ + PtrOwnerImpl(Y* p, D d) : owned(p), deleter(d) + {} + + void deleteSelf() + { + deleter(owned); + delete this; + } + +private: + Y* owned; + D deleter; +}; + + +} + +template +Ptr::Ptr() : owner(NULL), stored(NULL) +{} + +template +template +Ptr::Ptr(Y* p) + : owner(p + ? new detail::PtrOwnerImpl >(p, DefaultDeleter()) + : NULL), + stored(p) +{} + +template +template +Ptr::Ptr(Y* p, D d) + : owner(p + ? new detail::PtrOwnerImpl(p, d) + : NULL), + stored(p) +{} + +template +Ptr::Ptr(const Ptr& o) : owner(o.owner), stored(o.stored) +{ + if (owner) owner->incRef(); +} + +template +template +Ptr::Ptr(const Ptr& o) : owner(o.owner), stored(o.stored) +{ + if (owner) owner->incRef(); +} + +template +template +Ptr::Ptr(const Ptr& o, T* p) : owner(o.owner), stored(p) +{ + if (owner) owner->incRef(); +} + +template +Ptr::~Ptr() +{ + release(); +} + +template +Ptr& Ptr::operator = (const Ptr& o) +{ + Ptr(o).swap(*this); + return *this; +} + +template +template +Ptr& Ptr::operator = (const Ptr& o) +{ + Ptr(o).swap(*this); + return *this; +} + +template +void Ptr::release() +{ + if (owner) owner->decRef(); + owner = NULL; + stored = NULL; +} + +template +template +void Ptr::reset(Y* p) +{ + Ptr(p).swap(*this); +} + +template +template +void Ptr::reset(Y* p, D d) +{ + Ptr(p, d).swap(*this); +} + +template +void Ptr::swap(Ptr& o) +{ + std::swap(owner, o.owner); + std::swap(stored, o.stored); +} + +template +T* Ptr::get() const +{ + return stored; +} + +template +typename detail::RefOrVoid::type Ptr::operator * () const +{ + return *stored; +} + +template +T* Ptr::operator -> () const +{ + return stored; +} + +template +Ptr::operator T* () const +{ + return stored; +} + + +template +bool Ptr::empty() const +{ + return !stored; +} + +template +template +Ptr Ptr::staticCast() const +{ + return Ptr(*this, static_cast(stored)); +} + +template +template +Ptr Ptr::constCast() const +{ + return Ptr(*this, const_cast(stored)); +} + +template +template +Ptr Ptr::dynamicCast() const +{ + return Ptr(*this, dynamic_cast(stored)); +} + +template +void swap(Ptr& ptr1, Ptr& ptr2){ + ptr1.swap(ptr2); +} + +template +bool operator == (const Ptr& ptr1, const Ptr& ptr2) +{ + return ptr1.get() == ptr2.get(); +} + +template +bool operator != (const Ptr& ptr1, const Ptr& ptr2) +{ + return ptr1.get() != ptr2.get(); +} + +template +Ptr makePtr() +{ + return Ptr(new T()); +} + +template +Ptr makePtr(const A1& a1) +{ + return Ptr(new T(a1)); +} + +template +Ptr makePtr(const A1& a1, const A2& a2) +{ + return Ptr(new T(a1, a2)); +} + +template +Ptr makePtr(const A1& a1, const A2& a2, const A3& a3) +{ + return Ptr(new T(a1, a2, a3)); +} + +template +Ptr makePtr(const A1& a1, const A2& a2, const A3& a3, const A4& a4) +{ + return Ptr(new T(a1, a2, a3, a4)); +} + +template +Ptr makePtr(const A1& a1, const A2& a2, const A3& a3, const A4& a4, const A5& a5) +{ + return Ptr(new T(a1, a2, a3, a4, a5)); +} + +template +Ptr makePtr(const A1& a1, const A2& a2, const A3& a3, const A4& a4, const A5& a5, const A6& a6) +{ + return Ptr(new T(a1, a2, a3, a4, a5, a6)); +} + +template +Ptr makePtr(const A1& a1, const A2& a2, const A3& a3, const A4& a4, const A5& a5, const A6& a6, const A7& a7) +{ + return Ptr(new T(a1, a2, a3, a4, a5, a6, a7)); +} + +template +Ptr makePtr(const A1& a1, const A2& a2, const A3& a3, const A4& a4, const A5& a5, const A6& a6, const A7& a7, const A8& a8) +{ + return Ptr(new T(a1, a2, a3, a4, a5, a6, a7, a8)); +} + +template +Ptr makePtr(const A1& a1, const A2& a2, const A3& a3, const A4& a4, const A5& a5, const A6& a6, const A7& a7, const A8& a8, const A9& a9) +{ + return Ptr(new T(a1, a2, a3, a4, a5, a6, a7, a8, a9)); +} + +template +Ptr makePtr(const A1& a1, const A2& a2, const A3& a3, const A4& a4, const A5& a5, const A6& a6, const A7& a7, const A8& a8, const A9& a9, const A10& a10) +{ + return Ptr(new T(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10)); +} + +} // namespace cv + +#endif // __OPENCV_CORE_PTR_INL_HPP__ From 8200a95cedfb8c5be20a1a1341dd2fb059e50216 Mon Sep 17 00:00:00 2001 From: Roman Donchenko Date: Tue, 13 Aug 2013 16:22:07 +0400 Subject: [PATCH 03/55] Boring changes - core. This and several following commits contain the "boring" changes required to support the new Ptr. These are changes like: * new T -> makePtr or .reset(new T) or Ptr(new T) (depending on the situation) * p.empty() -> !p * delete_obj -> DefaultDeleter::operator() and similar changes that are numerous, but primitive. --- modules/core/include/opencv2/core/core_c.h | 12 +++++----- modules/core/include/opencv2/core/gpu.hpp | 6 ----- modules/core/include/opencv2/core/opengl.hpp | 6 ----- .../core/include/opencv2/core/operations.hpp | 4 ++-- .../core/include/opencv2/core/persistence.hpp | 6 ++--- modules/core/src/algorithm.cpp | 4 ++-- modules/core/src/array.cpp | 12 +++++----- modules/core/src/gpu_stream.cpp | 15 +++--------- modules/core/src/opengl.cpp | 8 ------- modules/core/src/out.cpp | 24 ++++++++++--------- modules/core/src/persistence.cpp | 16 ++++++------- modules/core/test/test_ds.cpp | 16 ++++++------- modules/core/test/test_io.cpp | 12 +++++----- modules/core/test/test_mat.cpp | 4 ++-- 14 files changed, 58 insertions(+), 87 deletions(-) diff --git a/modules/core/include/opencv2/core/core_c.h b/modules/core/include/opencv2/core/core_c.h index 74a1e403a2..ca8413ee23 100644 --- a/modules/core/include/opencv2/core/core_c.h +++ b/modules/core/include/opencv2/core/core_c.h @@ -1882,13 +1882,13 @@ CV_EXPORTS void insertImageCOI(InputArray coiimg, CvArr* arr, int coi=-1); -//////// specializied implementations of Ptr::delete_obj() for classic OpenCV types //////// +////// specialized implementations of DefaultDeleter::operator() for classic OpenCV types ////// -template<> CV_EXPORTS void Ptr::delete_obj(); -template<> CV_EXPORTS void Ptr::delete_obj(); -template<> CV_EXPORTS void Ptr::delete_obj(); -template<> CV_EXPORTS void Ptr::delete_obj(); -template<> CV_EXPORTS void Ptr::delete_obj(); +template<> CV_EXPORTS void DefaultDeleter::operator ()(CvMat* obj) const; +template<> CV_EXPORTS void DefaultDeleter::operator ()(IplImage* obj) const; +template<> CV_EXPORTS void DefaultDeleter::operator ()(CvMatND* obj) const; +template<> CV_EXPORTS void DefaultDeleter::operator ()(CvSparseMat* obj) const; +template<> CV_EXPORTS void DefaultDeleter::operator ()(CvMemStorage* obj) const; ////////////// convenient wrappers for operating old-style dynamic structures ////////////// diff --git a/modules/core/include/opencv2/core/gpu.hpp b/modules/core/include/opencv2/core/gpu.hpp index 9bacfc1a26..dfd4dd92ac 100644 --- a/modules/core/include/opencv2/core/gpu.hpp +++ b/modules/core/include/opencv2/core/gpu.hpp @@ -666,12 +666,6 @@ CV_EXPORTS void printShortCudaDeviceInfo(int device); }} // namespace cv { namespace gpu { -namespace cv { - -template <> CV_EXPORTS void Ptr::delete_obj(); -template <> CV_EXPORTS void Ptr::delete_obj(); - -} #include "opencv2/core/gpu.inl.hpp" diff --git a/modules/core/include/opencv2/core/opengl.hpp b/modules/core/include/opencv2/core/opengl.hpp index a4ee091f7f..0a4b454c8a 100644 --- a/modules/core/include/opencv2/core/opengl.hpp +++ b/modules/core/include/opencv2/core/opengl.hpp @@ -283,12 +283,6 @@ CV_EXPORTS void setGlDevice(int device = 0); }} -namespace cv { - -template <> CV_EXPORTS void Ptr::delete_obj(); -template <> CV_EXPORTS void Ptr::delete_obj(); - -} //////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////// diff --git a/modules/core/include/opencv2/core/operations.hpp b/modules/core/include/opencv2/core/operations.hpp index 7d39154a16..58be977cae 100644 --- a/modules/core/include/opencv2/core/operations.hpp +++ b/modules/core/include/opencv2/core/operations.hpp @@ -452,7 +452,7 @@ template inline void Algorithm::set(const char* _name, const Ptr<_Tp>& value) { Ptr algo_ptr = value. template ptr(); - if (algo_ptr.empty()) { + if (!algo_ptr) { CV_Error( Error::StsUnsupportedFormat, "unknown/unsupported Ptr type of the second parameter of the method Algorithm::set"); } info()->set(this, _name, ParamType::type, &algo_ptr); @@ -468,7 +468,7 @@ template inline void Algorithm::setAlgorithm(const char* _name, const Ptr<_Tp>& value) { Ptr algo_ptr = value. template ptr(); - if (algo_ptr.empty()) { + if (!algo_ptr) { CV_Error( Error::StsUnsupportedFormat, "unknown/unsupported Ptr type of the second parameter of the method Algorithm::set"); } info()->set(this, _name, ParamType::type, &algo_ptr); diff --git a/modules/core/include/opencv2/core/persistence.hpp b/modules/core/include/opencv2/core/persistence.hpp index 1b2bbf688c..73ba2fcb3e 100644 --- a/modules/core/include/opencv2/core/persistence.hpp +++ b/modules/core/include/opencv2/core/persistence.hpp @@ -209,9 +209,9 @@ public: CV_WRAP FileNode operator[](const char* nodename) const; //! returns pointer to the underlying C FileStorage structure - CvFileStorage* operator *() { return fs; } + CvFileStorage* operator *() { return fs.get(); } //! returns pointer to the underlying C FileStorage structure - const CvFileStorage* operator *() const { return fs; } + const CvFileStorage* operator *() const { return fs.get(); } //! writes one or more numbers of the specified format to the currently written structure void writeRaw( const String& fmt, const uchar* vec, size_t len ); //! writes the registered C structure (CvMat, CvMatND, CvSeq). See cvWrite() @@ -226,7 +226,7 @@ public: int state; //!< the writer state }; -template<> CV_EXPORTS void Ptr::delete_obj(); +template<> CV_EXPORTS void DefaultDeleter::operator ()(CvFileStorage* obj) const; /*! File Storage Node class diff --git a/modules/core/src/algorithm.cpp b/modules/core/src/algorithm.cpp index d0c6f5c924..ff67a5df1e 100644 --- a/modules/core/src/algorithm.cpp +++ b/modules/core/src/algorithm.cpp @@ -163,7 +163,7 @@ Ptr Algorithm::_create(const String& name) Algorithm::Constructor c = 0; if( !alglist().find(name, c) ) return Ptr(); - return c(); + return Ptr(c()); } Algorithm::Algorithm() @@ -490,7 +490,7 @@ void AlgorithmInfo::read(Algorithm* algo, const FileNode& fn) const else if( p.type == Param::ALGORITHM ) { Ptr nestedAlgo = Algorithm::_create((String)n["name"]); - CV_Assert( !nestedAlgo.empty() ); + CV_Assert( nestedAlgo ); nestedAlgo->read(n); info->set(algo, pname.c_str(), p.type, &nestedAlgo, true); } diff --git a/modules/core/src/array.cpp b/modules/core/src/array.cpp index 60ac848651..2ad7b1216c 100644 --- a/modules/core/src/array.cpp +++ b/modules/core/src/array.cpp @@ -3190,22 +3190,22 @@ cvCheckTermCriteria( CvTermCriteria criteria, double default_eps, namespace cv { -template<> void Ptr::delete_obj() +template<> void DefaultDeleter::operator ()(CvMat* obj) const { cvReleaseMat(&obj); } -template<> void Ptr::delete_obj() +template<> void DefaultDeleter::operator ()(IplImage* obj) const { cvReleaseImage(&obj); } -template<> void Ptr::delete_obj() +template<> void DefaultDeleter::operator ()(CvMatND* obj) const { cvReleaseMatND(&obj); } -template<> void Ptr::delete_obj() +template<> void DefaultDeleter::operator ()(CvSparseMat* obj) const { cvReleaseSparseMat(&obj); } -template<> void Ptr::delete_obj() +template<> void DefaultDeleter::operator ()(CvMemStorage* obj) const { cvReleaseMemStorage(&obj); } -template<> void Ptr::delete_obj() +template<> void DefaultDeleter::operator ()(CvFileStorage* obj) const { cvReleaseFileStorage(&obj); } } diff --git a/modules/core/src/gpu_stream.cpp b/modules/core/src/gpu_stream.cpp index 879775355c..fcdf480a91 100644 --- a/modules/core/src/gpu_stream.cpp +++ b/modules/core/src/gpu_stream.cpp @@ -100,7 +100,7 @@ cv::gpu::Stream::Stream() #ifndef HAVE_CUDA throw_no_cuda(); #else - impl_ = new Impl; + impl_ = makePtr(); #endif } @@ -182,7 +182,7 @@ void cv::gpu::Stream::enqueueHostCallback(StreamCallback callback, void* userDat Stream& cv::gpu::Stream::Null() { - static Stream s(new Impl(0)); + static Stream s(Ptr(new Impl(0))); return s; } @@ -195,10 +195,6 @@ cv::gpu::Stream::operator bool_type() const #endif } -template <> void cv::Ptr::delete_obj() -{ - if (obj) delete obj; -} //////////////////////////////////////////////////////////////// // Stream @@ -249,7 +245,7 @@ cv::gpu::Event::Event(CreateFlags flags) (void) flags; throw_no_cuda(); #else - impl_ = new Impl(flags); + impl_ = makePtr(flags); #endif } @@ -301,8 +297,3 @@ float cv::gpu::Event::elapsedTime(const Event& start, const Event& end) return ms; #endif } - -template <> void cv::Ptr::delete_obj() -{ - if (obj) delete obj; -} diff --git a/modules/core/src/opengl.cpp b/modules/core/src/opengl.cpp index f8a647e8ec..827d276f16 100644 --- a/modules/core/src/opengl.cpp +++ b/modules/core/src/opengl.cpp @@ -836,10 +836,6 @@ unsigned int cv::ogl::Buffer::bufId() const #endif } -template <> void cv::Ptr::delete_obj() -{ - if (obj) delete obj; -} ////////////////////////////////////////////////////////////////////////////////////////// // ogl::Texture @@ -1243,10 +1239,6 @@ unsigned int cv::ogl::Texture2D::texId() const #endif } -template <> void cv::Ptr::delete_obj() -{ - if (obj) delete obj; -} //////////////////////////////////////////////////////////////////////// // ogl::Arrays diff --git a/modules/core/src/out.cpp b/modules/core/src/out.cpp index cc2294ded6..3ed454ebfa 100644 --- a/modules/core/src/out.cpp +++ b/modules/core/src/out.cpp @@ -256,7 +256,7 @@ namespace cv::Ptr format(const cv::Mat& mtx) const { char braces[5] = {'\0', '\0', ';', '\0', '\0'}; - return new FormattedImpl("[", "]", mtx, braces, + return cv::makePtr("[", "]", mtx, &*braces, mtx.cols == 1 || !multiline, mtx.depth() == CV_64F ? prec64f : prec32f ); } }; @@ -270,7 +270,7 @@ namespace char braces[5] = {'[', ']', '\0', '[', ']'}; if (mtx.cols == 1) braces[0] = braces[1] = '\0'; - return new FormattedImpl("[", "]", mtx, braces, + return cv::makePtr("[", "]", mtx, &*braces, mtx.cols*mtx.channels() == 1 || !multiline, mtx.depth() == CV_64F ? prec64f : prec32f ); } }; @@ -288,7 +288,8 @@ namespace char braces[5] = {'[', ']', '\0', '[', ']'}; if (mtx.cols == 1) braces[0] = braces[1] = '\0'; - return new FormattedImpl("array([", cv::format("], type='%s')", numpyTypes[mtx.depth()]), mtx, braces, + return cv::makePtr("array([", + cv::format("], type='%s')", numpyTypes[mtx.depth()]), mtx, &*braces, mtx.cols*mtx.channels() == 1 || !multiline, mtx.depth() == CV_64F ? prec64f : prec32f ); } }; @@ -300,7 +301,8 @@ namespace cv::Ptr format(const cv::Mat& mtx) const { char braces[5] = {'\0', '\0', '\0', '\0', '\0'}; - return new FormattedImpl(cv::String(), mtx.rows > 1 ? cv::String("\n") : cv::String(), mtx, braces, + return cv::makePtr(cv::String(), + mtx.rows > 1 ? cv::String("\n") : cv::String(), mtx, &*braces, mtx.cols*mtx.channels() == 1 || !multiline, mtx.depth() == CV_64F ? prec64f : prec32f ); } }; @@ -312,7 +314,7 @@ namespace cv::Ptr format(const cv::Mat& mtx) const { char braces[5] = {'\0', '\0', ',', '\0', '\0'}; - return new FormattedImpl("{", "}", mtx, braces, + return cv::makePtr("{", "}", mtx, &*braces, mtx.cols == 1 || !multiline, mtx.depth() == CV_64F ? prec64f : prec32f ); } }; @@ -330,16 +332,16 @@ namespace cv switch(fmt) { case FMT_MATLAB: - return new MatlabFormatter(); + return makePtr(); case FMT_CSV: - return new CSVFormatter(); + return makePtr(); case FMT_PYTHON: - return new PythonFormatter(); + return makePtr(); case FMT_NUMPY: - return new NumpyFormatter(); + return makePtr(); case FMT_C: - return new CFormatter(); + return makePtr(); } - return new MatlabFormatter(); + return makePtr(); } } // cv diff --git a/modules/core/src/persistence.cpp b/modules/core/src/persistence.cpp index 3a13e6552b..a21ee5a361 100644 --- a/modules/core/src/persistence.cpp +++ b/modules/core/src/persistence.cpp @@ -5147,8 +5147,8 @@ FileStorage::~FileStorage() bool FileStorage::open(const String& filename, int flags, const String& encoding) { release(); - fs = Ptr(cvOpenFileStorage( filename.c_str(), 0, flags, - !encoding.empty() ? encoding.c_str() : 0)); + fs.reset(cvOpenFileStorage( filename.c_str(), 0, flags, + !encoding.empty() ? encoding.c_str() : 0)); bool ok = isOpened(); state = ok ? NAME_EXPECTED + INSIDE_MAP : UNDEFINED; return ok; @@ -5156,7 +5156,7 @@ bool FileStorage::open(const String& filename, int flags, const String& encoding bool FileStorage::isOpened() const { - return !fs.empty() && fs.obj->is_opened; + return fs && fs->is_opened; } void FileStorage::release() @@ -5169,8 +5169,8 @@ void FileStorage::release() String FileStorage::releaseAndGetString() { String buf; - if( fs.obj && fs.obj->outbuf ) - icvClose(fs.obj, &buf); + if( fs && fs->outbuf ) + icvClose(fs, &buf); release(); return buf; @@ -5479,7 +5479,7 @@ void write( FileStorage& fs, const String& name, const Mat& value ) // TODO: the 4 functions below need to be implemented more efficiently void write( FileStorage& fs, const String& name, const SparseMat& value ) { - Ptr mat = cvCreateSparseMat(value); + Ptr mat(cvCreateSparseMat(value)); cvWrite( *fs, name.size() ? name.c_str() : 0, mat ); } @@ -5529,8 +5529,8 @@ void read( const FileNode& node, SparseMat& mat, const SparseMat& default_mat ) default_mat.copyTo(mat); return; } - Ptr m = (CvSparseMat*)cvRead((CvFileStorage*)node.fs, (CvFileNode*)*node); - CV_Assert(CV_IS_SPARSE_MAT(m.obj)); + Ptr m((CvSparseMat*)cvRead((CvFileStorage*)node.fs, (CvFileNode*)*node)); + CV_Assert(CV_IS_SPARSE_MAT(m)); m->copyToSparseMat(mat); } diff --git a/modules/core/test/test_ds.cpp b/modules/core/test/test_ds.cpp index cd76ca2fe9..c71deed06f 100644 --- a/modules/core/test/test_ds.cpp +++ b/modules/core/test/test_ds.cpp @@ -358,8 +358,6 @@ Core_DynStructBaseTest::Core_DynStructBaseTest() iterations = max_struct_size*2; gen = struct_idx = iter = -1; test_progress = -1; - - storage = 0; } @@ -999,7 +997,7 @@ void Core_SeqBaseTest::run( int ) { t = cvtest::randReal(rng)*(max_log_storage_block_size - min_log_storage_block_size) + min_log_storage_block_size; - storage = cvCreateMemStorage( cvRound( exp(t * CV_LOG2) ) ); + storage.reset(cvCreateMemStorage( cvRound( exp(t * CV_LOG2) ) )); } iter = struct_idx = -1; @@ -1083,11 +1081,11 @@ void Core_SeqSortInvTest::run( int ) { struct_idx = iter = -1; - if( storage.empty() ) + if( !storage ) { t = cvtest::randReal(rng)*(max_log_storage_block_size - min_log_storage_block_size) + min_log_storage_block_size; - storage = cvCreateMemStorage( cvRound( exp(t * CV_LOG2) ) ); + storage.reset(cvCreateMemStorage( cvRound( exp(t * CV_LOG2) ) )); } for( iter = 0; iter < iterations/10; iter++ ) @@ -1384,7 +1382,7 @@ void Core_SetTest::run( int ) { struct_idx = iter = -1; t = cvtest::randReal(rng)*(max_log_storage_block_size - min_log_storage_block_size) + min_log_storage_block_size; - storage = cvCreateMemStorage( cvRound( exp(t * CV_LOG2) ) ); + storage.reset(cvCreateMemStorage( cvRound( exp(t * CV_LOG2) ) )); for( int i = 0; i < struct_count; i++ ) { @@ -1398,7 +1396,7 @@ void Core_SetTest::run( int ) cvTsReleaseSimpleSet( (CvTsSimpleSet**)&simple_struct[i] ); simple_struct[i] = cvTsCreateSimpleSet( max_struct_size, pure_elem_size ); - cxcore_struct[i] = cvCreateSet( 0, sizeof(CvSet), elem_size, storage ); + cxcore_struct[i] = cvCreateSet( 0, sizeof(CvSet), elem_size, storage ); } if( test_set_ops( iterations*100 ) < 0 ) @@ -1811,7 +1809,7 @@ void Core_GraphTest::run( int ) int block_size = cvRound( exp(t * CV_LOG2) ); block_size = MAX(block_size, (int)(sizeof(CvGraph) + sizeof(CvMemBlock) + sizeof(CvSeqBlock))); - storage = cvCreateMemStorage(block_size); + storage.reset(cvCreateMemStorage(block_size)); for( i = 0; i < struct_count; i++ ) { @@ -1929,7 +1927,7 @@ void Core_GraphScanTest::run( int ) storage_blocksize = MAX(storage_blocksize, (int)(sizeof(CvGraph) + sizeof(CvMemBlock) + sizeof(CvSeqBlock))); storage_blocksize = MAX(storage_blocksize, (int)(sizeof(CvGraphEdge) + sizeof(CvMemBlock) + sizeof(CvSeqBlock))); storage_blocksize = MAX(storage_blocksize, (int)(sizeof(CvGraphVtx) + sizeof(CvMemBlock) + sizeof(CvSeqBlock))); - storage = cvCreateMemStorage(storage_blocksize); + storage.reset(cvCreateMemStorage(storage_blocksize)); if( gen == 0 ) { diff --git a/modules/core/test/test_io.cpp b/modules/core/test/test_io.cpp index 8644d8eeac..ba66567615 100644 --- a/modules/core/test/test_io.cpp +++ b/modules/core/test/test_io.cpp @@ -270,16 +270,16 @@ protected: cvRelease((void**)&m_nd); - Ptr m_s = (CvSparseMat*)fs["test_sparse_mat"].readObj(); - Ptr _test_sparse_ = cvCreateSparseMat(test_sparse_mat); - Ptr _test_sparse = (CvSparseMat*)cvClone(_test_sparse_); + Ptr m_s((CvSparseMat*)fs["test_sparse_mat"].readObj()); + Ptr _test_sparse_(cvCreateSparseMat(test_sparse_mat)); + Ptr _test_sparse((CvSparseMat*)cvClone(_test_sparse_)); SparseMat m_s2; fs["test_sparse_mat"] >> m_s2; - Ptr _m_s2 = cvCreateSparseMat(m_s2); + Ptr _m_s2(cvCreateSparseMat(m_s2)); if( !m_s || !CV_IS_SPARSE_MAT(m_s) || - !cvTsCheckSparse(m_s, _test_sparse,0) || - !cvTsCheckSparse(_m_s2, _test_sparse,0)) + !cvTsCheckSparse(m_s, _test_sparse, 0) || + !cvTsCheckSparse(_m_s2, _test_sparse, 0)) { ts->printf( cvtest::TS::LOG, "the read sparse matrix is not correct\n" ); ts->set_failed_test_info( cvtest::TS::FAIL_INVALID_OUTPUT ); diff --git a/modules/core/test/test_mat.cpp b/modules/core/test/test_mat.cpp index 6e3ec03dc6..3c8ae8bf9f 100644 --- a/modules/core/test/test_mat.cpp +++ b/modules/core/test/test_mat.cpp @@ -669,7 +669,7 @@ void Core_ArrayOpTest::run( int /* start_from */) cvSetReal3D(&matA, idx1[0], idx1[1], idx1[2], -val0); cvSetND(&matB, idx0, val1); cvSet3D(&matB, idx1[0], idx1[1], idx1[2], -val1); - Ptr matC = cvCloneMatND(&matB); + Ptr matC(cvCloneMatND(&matB)); if( A.at(idx0[0], idx0[1], idx0[2]) != val0 || A.at(idx1[0], idx1[1], idx1[2]) != -val0 || @@ -762,7 +762,7 @@ void Core_ArrayOpTest::run( int /* start_from */) } } - Ptr M2 = cvCreateSparseMat(M); + Ptr M2(cvCreateSparseMat(M)); MatND Md; M.copyTo(Md); SparseMat M3; SparseMat(Md).convertTo(M3, Md.type(), 2); From 254d4ae42960d836e34bebca99e31a5f8b45d723 Mon Sep 17 00:00:00 2001 From: Roman Donchenko Date: Tue, 13 Aug 2013 16:39:58 +0400 Subject: [PATCH 04/55] Boring changes - imgproc. --- modules/imgproc/include/opencv2/imgproc.hpp | 2 +- modules/imgproc/src/clahe.cpp | 2 +- modules/imgproc/src/contours.cpp | 4 +- modules/imgproc/src/filter.cpp | 192 ++++++++++---------- modules/imgproc/src/generalized_hough.cpp | 4 +- modules/imgproc/src/hough.cpp | 14 +- modules/imgproc/src/imgwarp.cpp | 8 +- modules/imgproc/src/lsd.cpp | 4 +- modules/imgproc/src/morph.cpp | 110 +++++------ modules/imgproc/src/smooth.cpp | 48 ++--- modules/imgproc/test/test_convhull.cpp | 2 +- 11 files changed, 195 insertions(+), 195 deletions(-) diff --git a/modules/imgproc/include/opencv2/imgproc.hpp b/modules/imgproc/include/opencv2/imgproc.hpp index 24d9f4463d..55816ccb7e 100644 --- a/modules/imgproc/include/opencv2/imgproc.hpp +++ b/modules/imgproc/include/opencv2/imgproc.hpp @@ -656,7 +656,7 @@ public: Point dstOfs = Point(0,0), bool isolated = false); //! returns true if the filter is separable - bool isSeparable() const { return (const BaseFilter*)filter2D == 0; } + bool isSeparable() const { return !filter2D; } //! returns the number int remainingInputRows() const; int remainingOutputRows() const; diff --git a/modules/imgproc/src/clahe.cpp b/modules/imgproc/src/clahe.cpp index 4ce479713e..89fb62bd01 100644 --- a/modules/imgproc/src/clahe.cpp +++ b/modules/imgproc/src/clahe.cpp @@ -330,5 +330,5 @@ namespace cv::Ptr cv::createCLAHE(double clipLimit, cv::Size tileGridSize) { - return new CLAHE_Impl(clipLimit, tileGridSize.width, tileGridSize.height); + return makePtr(clipLimit, tileGridSize.width, tileGridSize.height); } diff --git a/modules/imgproc/src/contours.cpp b/modules/imgproc/src/contours.cpp index 6f5b0c8ac6..797f8c56c8 100644 --- a/modules/imgproc/src/contours.cpp +++ b/modules/imgproc/src/contours.cpp @@ -1339,8 +1339,8 @@ icvFindContoursInInterval( const CvArr* src, if( contourHeaderSize < (int)sizeof(CvContour)) CV_Error( CV_StsBadSize, "Contour header size must be >= sizeof(CvContour)" ); - storage00 = cvCreateChildMemStorage(storage); - storage01 = cvCreateChildMemStorage(storage); + storage00.reset(cvCreateChildMemStorage(storage)); + storage01.reset(cvCreateChildMemStorage(storage)); CvMat stub, *mat; diff --git a/modules/imgproc/src/filter.cpp b/modules/imgproc/src/filter.cpp index 86322e4ba5..f7e7efa854 100644 --- a/modules/imgproc/src/filter.cpp +++ b/modules/imgproc/src/filter.cpp @@ -117,7 +117,7 @@ void FilterEngine::init( const Ptr& _filter2D, if( isSeparable() ) { - CV_Assert( !rowFilter.empty() && !columnFilter.empty() ); + CV_Assert( rowFilter && columnFilter ); ksize = Size(rowFilter->ksize, columnFilter->ksize); anchor = Point(rowFilter->anchor, columnFilter->anchor); } @@ -244,9 +244,9 @@ int FilterEngine::start(Size _wholeSize, Rect _roi, int _maxBufRows) rowCount = dstY = 0; startY = startY0 = std::max(roi.y - anchor.y, 0); endY = std::min(roi.y + roi.height + ksize.height - anchor.y - 1, wholeSize.height); - if( !columnFilter.empty() ) + if( columnFilter ) columnFilter->reset(); - if( !filter2D.empty() ) + if( filter2D ) filter2D->reset(); return startY; @@ -2735,42 +2735,42 @@ cv::Ptr cv::getLinearRowFilter( int srcType, int bufType, if( (symmetryType & (KERNEL_SYMMETRICAL|KERNEL_ASYMMETRICAL)) != 0 && ksize <= 5 ) { if( sdepth == CV_8U && ddepth == CV_32S ) - return Ptr(new SymmRowSmallFilter - (kernel, anchor, symmetryType, SymmRowSmallVec_8u32s(kernel, symmetryType))); + return makePtr > + (kernel, anchor, symmetryType, SymmRowSmallVec_8u32s(kernel, symmetryType)); if( sdepth == CV_32F && ddepth == CV_32F ) - return Ptr(new SymmRowSmallFilter - (kernel, anchor, symmetryType, SymmRowSmallVec_32f(kernel, symmetryType))); + return makePtr > + (kernel, anchor, symmetryType, SymmRowSmallVec_32f(kernel, symmetryType)); } if( sdepth == CV_8U && ddepth == CV_32S ) - return Ptr(new RowFilter - (kernel, anchor, RowVec_8u32s(kernel))); + return makePtr > + (kernel, anchor, RowVec_8u32s(kernel)); if( sdepth == CV_8U && ddepth == CV_32F ) - return Ptr(new RowFilter(kernel, anchor)); + return makePtr >(kernel, anchor); if( sdepth == CV_8U && ddepth == CV_64F ) - return Ptr(new RowFilter(kernel, anchor)); + return makePtr >(kernel, anchor); if( sdepth == CV_16U && ddepth == CV_32F ) - return Ptr(new RowFilter(kernel, anchor)); + return makePtr >(kernel, anchor); if( sdepth == CV_16U && ddepth == CV_64F ) - return Ptr(new RowFilter(kernel, anchor)); + return makePtr >(kernel, anchor); if( sdepth == CV_16S && ddepth == CV_32F ) - return Ptr(new RowFilter - (kernel, anchor, RowVec_16s32f(kernel))); + return makePtr > + (kernel, anchor, RowVec_16s32f(kernel)); if( sdepth == CV_16S && ddepth == CV_64F ) - return Ptr(new RowFilter(kernel, anchor)); + return makePtr >(kernel, anchor); if( sdepth == CV_32F && ddepth == CV_32F ) - return Ptr(new RowFilter - (kernel, anchor, RowVec_32f(kernel))); + return makePtr > + (kernel, anchor, RowVec_32f(kernel)); if( sdepth == CV_32F && ddepth == CV_64F ) - return Ptr(new RowFilter(kernel, anchor)); + return makePtr >(kernel, anchor); if( sdepth == CV_64F && ddepth == CV_64F ) - return Ptr(new RowFilter(kernel, anchor)); + return makePtr >(kernel, anchor); CV_Error_( CV_StsNotImplemented, ("Unsupported combination of source format (=%d), and buffer format (=%d)", srcType, bufType)); - return Ptr(0); + return Ptr(); } @@ -2789,24 +2789,24 @@ cv::Ptr cv::getLinearColumnFilter( int bufType, int dstTyp if( !(symmetryType & (KERNEL_SYMMETRICAL|KERNEL_ASYMMETRICAL)) ) { if( ddepth == CV_8U && sdepth == CV_32S ) - return Ptr(new ColumnFilter, ColumnNoVec> - (kernel, anchor, delta, FixedPtCastEx(bits))); + return makePtr, ColumnNoVec> > + (kernel, anchor, delta, FixedPtCastEx(bits)); if( ddepth == CV_8U && sdepth == CV_32F ) - return Ptr(new ColumnFilter, ColumnNoVec>(kernel, anchor, delta)); + return makePtr, ColumnNoVec> >(kernel, anchor, delta); if( ddepth == CV_8U && sdepth == CV_64F ) - return Ptr(new ColumnFilter, ColumnNoVec>(kernel, anchor, delta)); + return makePtr, ColumnNoVec> >(kernel, anchor, delta); if( ddepth == CV_16U && sdepth == CV_32F ) - return Ptr(new ColumnFilter, ColumnNoVec>(kernel, anchor, delta)); + return makePtr, ColumnNoVec> >(kernel, anchor, delta); if( ddepth == CV_16U && sdepth == CV_64F ) - return Ptr(new ColumnFilter, ColumnNoVec>(kernel, anchor, delta)); + return makePtr, ColumnNoVec> >(kernel, anchor, delta); if( ddepth == CV_16S && sdepth == CV_32F ) - return Ptr(new ColumnFilter, ColumnNoVec>(kernel, anchor, delta)); + return makePtr, ColumnNoVec> >(kernel, anchor, delta); if( ddepth == CV_16S && sdepth == CV_64F ) - return Ptr(new ColumnFilter, ColumnNoVec>(kernel, anchor, delta)); + return makePtr, ColumnNoVec> >(kernel, anchor, delta); if( ddepth == CV_32F && sdepth == CV_32F ) - return Ptr(new ColumnFilter, ColumnNoVec>(kernel, anchor, delta)); + return makePtr, ColumnNoVec> >(kernel, anchor, delta); if( ddepth == CV_64F && sdepth == CV_64F ) - return Ptr(new ColumnFilter, ColumnNoVec>(kernel, anchor, delta)); + return makePtr, ColumnNoVec> >(kernel, anchor, delta); } else { @@ -2814,60 +2814,60 @@ cv::Ptr cv::getLinearColumnFilter( int bufType, int dstTyp if( ksize == 3 ) { if( ddepth == CV_8U && sdepth == CV_32S ) - return Ptr(new SymmColumnSmallFilter< - FixedPtCastEx, SymmColumnVec_32s8u> + return makePtr, SymmColumnVec_32s8u> > (kernel, anchor, delta, symmetryType, FixedPtCastEx(bits), - SymmColumnVec_32s8u(kernel, symmetryType, bits, delta))); + SymmColumnVec_32s8u(kernel, symmetryType, bits, delta)); if( ddepth == CV_16S && sdepth == CV_32S && bits == 0 ) - return Ptr(new SymmColumnSmallFilter, - SymmColumnSmallVec_32s16s>(kernel, anchor, delta, symmetryType, - Cast(), SymmColumnSmallVec_32s16s(kernel, symmetryType, bits, delta))); + return makePtr, + SymmColumnSmallVec_32s16s> >(kernel, anchor, delta, symmetryType, + Cast(), SymmColumnSmallVec_32s16s(kernel, symmetryType, bits, delta)); if( ddepth == CV_32F && sdepth == CV_32F ) - return Ptr(new SymmColumnSmallFilter< - Cast,SymmColumnSmallVec_32f> + return makePtr,SymmColumnSmallVec_32f> > (kernel, anchor, delta, symmetryType, Cast(), - SymmColumnSmallVec_32f(kernel, symmetryType, 0, delta))); + SymmColumnSmallVec_32f(kernel, symmetryType, 0, delta)); } if( ddepth == CV_8U && sdepth == CV_32S ) - return Ptr(new SymmColumnFilter, SymmColumnVec_32s8u> + return makePtr, SymmColumnVec_32s8u> > (kernel, anchor, delta, symmetryType, FixedPtCastEx(bits), - SymmColumnVec_32s8u(kernel, symmetryType, bits, delta))); + SymmColumnVec_32s8u(kernel, symmetryType, bits, delta)); if( ddepth == CV_8U && sdepth == CV_32F ) - return Ptr(new SymmColumnFilter, ColumnNoVec> - (kernel, anchor, delta, symmetryType)); + return makePtr, ColumnNoVec> > + (kernel, anchor, delta, symmetryType); if( ddepth == CV_8U && sdepth == CV_64F ) - return Ptr(new SymmColumnFilter, ColumnNoVec> - (kernel, anchor, delta, symmetryType)); + return makePtr, ColumnNoVec> > + (kernel, anchor, delta, symmetryType); if( ddepth == CV_16U && sdepth == CV_32F ) - return Ptr(new SymmColumnFilter, ColumnNoVec> - (kernel, anchor, delta, symmetryType)); + return makePtr, ColumnNoVec> > + (kernel, anchor, delta, symmetryType); if( ddepth == CV_16U && sdepth == CV_64F ) - return Ptr(new SymmColumnFilter, ColumnNoVec> - (kernel, anchor, delta, symmetryType)); + return makePtr, ColumnNoVec> > + (kernel, anchor, delta, symmetryType); if( ddepth == CV_16S && sdepth == CV_32S ) - return Ptr(new SymmColumnFilter, ColumnNoVec> - (kernel, anchor, delta, symmetryType)); + return makePtr, ColumnNoVec> > + (kernel, anchor, delta, symmetryType); if( ddepth == CV_16S && sdepth == CV_32F ) - return Ptr(new SymmColumnFilter, SymmColumnVec_32f16s> + return makePtr, SymmColumnVec_32f16s> > (kernel, anchor, delta, symmetryType, Cast(), - SymmColumnVec_32f16s(kernel, symmetryType, 0, delta))); + SymmColumnVec_32f16s(kernel, symmetryType, 0, delta)); if( ddepth == CV_16S && sdepth == CV_64F ) - return Ptr(new SymmColumnFilter, ColumnNoVec> - (kernel, anchor, delta, symmetryType)); + return makePtr, ColumnNoVec> > + (kernel, anchor, delta, symmetryType); if( ddepth == CV_32F && sdepth == CV_32F ) - return Ptr(new SymmColumnFilter, SymmColumnVec_32f> + return makePtr, SymmColumnVec_32f> > (kernel, anchor, delta, symmetryType, Cast(), - SymmColumnVec_32f(kernel, symmetryType, 0, delta))); + SymmColumnVec_32f(kernel, symmetryType, 0, delta)); if( ddepth == CV_64F && sdepth == CV_64F ) - return Ptr(new SymmColumnFilter, ColumnNoVec> - (kernel, anchor, delta, symmetryType)); + return makePtr, ColumnNoVec> > + (kernel, anchor, delta, symmetryType); } CV_Error_( CV_StsNotImplemented, ("Unsupported combination of buffer format (=%d), and destination format (=%d)", bufType, dstType)); - return Ptr(0); + return Ptr(); } @@ -2933,7 +2933,7 @@ cv::Ptr cv::createSeparableLinearFilter( Ptr _columnFilter = getLinearColumnFilter( _bufType, _dstType, columnKernel, _anchor.y, ctype, _delta, bits ); - return Ptr( new FilterEngine(Ptr(0), _rowFilter, _columnFilter, + return Ptr( new FilterEngine(Ptr(), _rowFilter, _columnFilter, _srcType, _dstType, _bufType, _rowBorderType, _columnBorderType, _borderValue )); } @@ -3085,13 +3085,13 @@ cv::Ptr cv::getLinearFilter(int srcType, int dstType, anchor = normalizeAnchor(anchor, _kernel.size()); /*if( sdepth == CV_8U && ddepth == CV_8U && kdepth == CV_32S ) - return Ptr(new Filter2D, FilterVec_8u> + return makePtr, FilterVec_8u> > (_kernel, anchor, delta, FixedPtCastEx(bits), - FilterVec_8u(_kernel, bits, delta))); + FilterVec_8u(_kernel, bits, delta)); if( sdepth == CV_8U && ddepth == CV_16S && kdepth == CV_32S ) - return Ptr(new Filter2D, FilterVec_8u16s> + return makePtr, FilterVec_8u16s> > (_kernel, anchor, delta, FixedPtCastEx(bits), - FilterVec_8u16s(_kernel, bits, delta)));*/ + FilterVec_8u16s(_kernel, bits, delta));*/ kdepth = sdepth == CV_64F || ddepth == CV_64F ? CV_64F : CV_32F; Mat kernel; @@ -3101,53 +3101,53 @@ cv::Ptr cv::getLinearFilter(int srcType, int dstType, _kernel.convertTo(kernel, kdepth, _kernel.type() == CV_32S ? 1./(1 << bits) : 1.); if( sdepth == CV_8U && ddepth == CV_8U ) - return Ptr(new Filter2D, FilterVec_8u> - (kernel, anchor, delta, Cast(), FilterVec_8u(kernel, 0, delta))); + return makePtr, FilterVec_8u> > + (kernel, anchor, delta, Cast(), FilterVec_8u(kernel, 0, delta)); if( sdepth == CV_8U && ddepth == CV_16U ) - return Ptr(new Filter2D, FilterNoVec>(kernel, anchor, delta)); + return makePtr, FilterNoVec> >(kernel, anchor, delta); if( sdepth == CV_8U && ddepth == CV_16S ) - return Ptr(new Filter2D, FilterVec_8u16s> - (kernel, anchor, delta, Cast(), FilterVec_8u16s(kernel, 0, delta))); + return makePtr, FilterVec_8u16s> > + (kernel, anchor, delta, Cast(), FilterVec_8u16s(kernel, 0, delta)); if( sdepth == CV_8U && ddepth == CV_32F ) - return Ptr(new Filter2D, FilterNoVec>(kernel, anchor, delta)); + return makePtr, FilterNoVec> >(kernel, anchor, delta); if( sdepth == CV_8U && ddepth == CV_64F ) - return Ptr(new Filter2D, FilterNoVec>(kernel, anchor, delta)); + return makePtr, FilterNoVec> >(kernel, anchor, delta); if( sdepth == CV_16U && ddepth == CV_16U ) - return Ptr(new Filter2D, FilterNoVec>(kernel, anchor, delta)); + return makePtr, FilterNoVec> >(kernel, anchor, delta); if( sdepth == CV_16U && ddepth == CV_32F ) - return Ptr(new Filter2D, FilterNoVec>(kernel, anchor, delta)); + return makePtr, FilterNoVec> >(kernel, anchor, delta); if( sdepth == CV_16U && ddepth == CV_64F ) - return Ptr(new Filter2D, FilterNoVec>(kernel, anchor, delta)); + return makePtr, FilterNoVec> >(kernel, anchor, delta); if( sdepth == CV_16S && ddepth == CV_16S ) - return Ptr(new Filter2D, FilterNoVec>(kernel, anchor, delta)); + return makePtr, FilterNoVec> >(kernel, anchor, delta); if( sdepth == CV_16S && ddepth == CV_32F ) - return Ptr(new Filter2D, FilterNoVec>(kernel, anchor, delta)); + return makePtr, FilterNoVec> >(kernel, anchor, delta); if( sdepth == CV_16S && ddepth == CV_64F ) - return Ptr(new Filter2D, FilterNoVec>(kernel, anchor, delta)); + return makePtr, FilterNoVec> >(kernel, anchor, delta); if( sdepth == CV_32F && ddepth == CV_32F ) - return Ptr(new Filter2D, FilterVec_32f> - (kernel, anchor, delta, Cast(), FilterVec_32f(kernel, 0, delta))); + return makePtr, FilterVec_32f> > + (kernel, anchor, delta, Cast(), FilterVec_32f(kernel, 0, delta)); if( sdepth == CV_64F && ddepth == CV_64F ) - return Ptr(new Filter2D, FilterNoVec>(kernel, anchor, delta)); + return makePtr, FilterNoVec> >(kernel, anchor, delta); CV_Error_( CV_StsNotImplemented, ("Unsupported combination of source format (=%d), and destination format (=%d)", srcType, dstType)); - return Ptr(0); + return Ptr(); } @@ -3178,9 +3178,9 @@ cv::Ptr cv::createLinearFilter( int _srcType, int _dstType, Ptr _filter2D = getLinearFilter(_srcType, _dstType, kernel, _anchor, _delta, bits); - return Ptr(new FilterEngine(_filter2D, Ptr(0), - Ptr(0), _srcType, _dstType, _srcType, - _rowBorderType, _columnBorderType, _borderValue )); + return makePtr(_filter2D, Ptr(), + Ptr(), _srcType, _dstType, _srcType, + _rowBorderType, _columnBorderType, _borderValue ); } diff --git a/modules/imgproc/src/generalized_hough.cpp b/modules/imgproc/src/generalized_hough.cpp index 7ee3b700da..a261d644b8 100644 --- a/modules/imgproc/src/generalized_hough.cpp +++ b/modules/imgproc/src/generalized_hough.cpp @@ -491,7 +491,7 @@ namespace Ptr cv::createGeneralizedHoughBallard() { - return new GeneralizedHoughBallardImpl; + return makePtr(); } // GeneralizedHoughGuil @@ -940,5 +940,5 @@ namespace Ptr cv::createGeneralizedHoughGuil() { - return new GeneralizedHoughGuilImpl; + return makePtr(); } diff --git a/modules/imgproc/src/hough.cpp b/modules/imgproc/src/hough.cpp index f33c6d2033..9c8eaca8f5 100644 --- a/modules/imgproc/src/hough.cpp +++ b/modules/imgproc/src/hough.cpp @@ -766,21 +766,21 @@ icvHoughCirclesGradient( CvMat* img, float dp, float min_dist, float idp, dr; CvSeqReader reader; - edges = cvCreateMat( img->rows, img->cols, CV_8UC1 ); + edges.reset(cvCreateMat( img->rows, img->cols, CV_8UC1 )); cvCanny( img, edges, MAX(canny_threshold/2,1), canny_threshold, 3 ); - dx = cvCreateMat( img->rows, img->cols, CV_16SC1 ); - dy = cvCreateMat( img->rows, img->cols, CV_16SC1 ); + dx.reset(cvCreateMat( img->rows, img->cols, CV_16SC1 )); + dy.reset(cvCreateMat( img->rows, img->cols, CV_16SC1 )); cvSobel( img, dx, 1, 0, 3 ); cvSobel( img, dy, 0, 1, 3 ); if( dp < 1.f ) dp = 1.f; idp = 1.f/dp; - accum = cvCreateMat( cvCeil(img->rows*idp)+2, cvCeil(img->cols*idp)+2, CV_32SC1 ); + accum.reset(cvCreateMat( cvCeil(img->rows*idp)+2, cvCeil(img->cols*idp)+2, CV_32SC1 )); cvZero(accum); - storage = cvCreateMemStorage(); + storage.reset(cvCreateMemStorage()); nz = cvCreateSeq( CV_32SC2, sizeof(CvSeq), sizeof(CvPoint), storage ); centers = cvCreateSeq( CV_32SC1, sizeof(CvSeq), sizeof(int), storage ); @@ -866,7 +866,7 @@ icvHoughCirclesGradient( CvMat* img, float dp, float min_dist, cvClearSeq( centers ); cvSeqPushMulti( centers, &sort_buf[0], center_count ); - dist_buf = cvCreateMat( 1, nz_count, CV_32FC1 ); + dist_buf.reset(cvCreateMat( 1, nz_count, CV_32FC1 )); ddata = dist_buf->data.fl; dr = dp; @@ -1060,7 +1060,7 @@ void cv::HoughCircles( InputArray _image, OutputArray _circles, double param1, double param2, int minRadius, int maxRadius ) { - Ptr storage = cvCreateMemStorage(STORAGE_SIZE); + Ptr storage(cvCreateMemStorage(STORAGE_SIZE)); Mat image = _image.getMat(); CvMat c_image = image; CvSeq* seq = cvHoughCircles( &c_image, storage, method, diff --git a/modules/imgproc/src/imgwarp.cpp b/modules/imgproc/src/imgwarp.cpp index 05a96300b5..32a1517dbe 100644 --- a/modules/imgproc/src/imgwarp.cpp +++ b/modules/imgproc/src/imgwarp.cpp @@ -3931,8 +3931,8 @@ cvLogPolar( const CvArr* srcarr, CvArr* dstarr, ssize = cvGetMatSize(src); dsize = cvGetMatSize(dst); - mapx = cvCreateMat( dsize.height, dsize.width, CV_32F ); - mapy = cvCreateMat( dsize.height, dsize.width, CV_32F ); + mapx.reset(cvCreateMat( dsize.height, dsize.width, CV_32F )); + mapy.reset(cvCreateMat( dsize.height, dsize.width, CV_32F )); if( !(flags & CV_WARP_INVERSE_MAP) ) { @@ -4049,8 +4049,8 @@ void cvLinearPolar( const CvArr* srcarr, CvArr* dstarr, dsize.width = dst->cols; dsize.height = dst->rows; - mapx = cvCreateMat( dsize.height, dsize.width, CV_32F ); - mapy = cvCreateMat( dsize.height, dsize.width, CV_32F ); + mapx.reset(cvCreateMat( dsize.height, dsize.width, CV_32F )); + mapy.reset(cvCreateMat( dsize.height, dsize.width, CV_32F )); if( !(flags & CV_WARP_INVERSE_MAP) ) { diff --git a/modules/imgproc/src/lsd.cpp b/modules/imgproc/src/lsd.cpp index 58d226f0c4..f468c61873 100644 --- a/modules/imgproc/src/lsd.cpp +++ b/modules/imgproc/src/lsd.cpp @@ -393,9 +393,9 @@ CV_EXPORTS Ptr createLineSegmentDetectorPtr( int _refine, double _scale, double _sigma_scale, double _quant, double _ang_th, double _log_eps, double _density_th, int _n_bins) { - return Ptr(new LineSegmentDetectorImpl( + return makePtr( _refine, _scale, _sigma_scale, _quant, _ang_th, - _log_eps, _density_th, _n_bins)); + _log_eps, _density_th, _n_bins); } ///////////////////////////////////////////////////////////////////////////////////////// diff --git a/modules/imgproc/src/morph.cpp b/modules/imgproc/src/morph.cpp index ef919027ac..33ddcf76c0 100644 --- a/modules/imgproc/src/morph.cpp +++ b/modules/imgproc/src/morph.cpp @@ -857,42 +857,42 @@ cv::Ptr cv::getMorphologyRowFilter(int op, int type, int ksiz if( op == MORPH_ERODE ) { if( depth == CV_8U ) - return Ptr(new MorphRowFilter, - ErodeRowVec8u>(ksize, anchor)); + return makePtr, + ErodeRowVec8u> >(ksize, anchor); if( depth == CV_16U ) - return Ptr(new MorphRowFilter, - ErodeRowVec16u>(ksize, anchor)); + return makePtr, + ErodeRowVec16u> >(ksize, anchor); if( depth == CV_16S ) - return Ptr(new MorphRowFilter, - ErodeRowVec16s>(ksize, anchor)); + return makePtr, + ErodeRowVec16s> >(ksize, anchor); if( depth == CV_32F ) - return Ptr(new MorphRowFilter, - ErodeRowVec32f>(ksize, anchor)); + return makePtr, + ErodeRowVec32f> >(ksize, anchor); if( depth == CV_64F ) - return Ptr(new MorphRowFilter, - ErodeRowVec64f>(ksize, anchor)); + return makePtr, + ErodeRowVec64f> >(ksize, anchor); } else { if( depth == CV_8U ) - return Ptr(new MorphRowFilter, - DilateRowVec8u>(ksize, anchor)); + return makePtr, + DilateRowVec8u> >(ksize, anchor); if( depth == CV_16U ) - return Ptr(new MorphRowFilter, - DilateRowVec16u>(ksize, anchor)); + return makePtr, + DilateRowVec16u> >(ksize, anchor); if( depth == CV_16S ) - return Ptr(new MorphRowFilter, - DilateRowVec16s>(ksize, anchor)); + return makePtr, + DilateRowVec16s> >(ksize, anchor); if( depth == CV_32F ) - return Ptr(new MorphRowFilter, - DilateRowVec32f>(ksize, anchor)); + return makePtr, + DilateRowVec32f> >(ksize, anchor); if( depth == CV_64F ) - return Ptr(new MorphRowFilter, - DilateRowVec64f>(ksize, anchor)); + return makePtr, + DilateRowVec64f> >(ksize, anchor); } CV_Error_( CV_StsNotImplemented, ("Unsupported data type (=%d)", type)); - return Ptr(0); + return Ptr(); } cv::Ptr cv::getMorphologyColumnFilter(int op, int type, int ksize, int anchor) @@ -904,42 +904,42 @@ cv::Ptr cv::getMorphologyColumnFilter(int op, int type, in if( op == MORPH_ERODE ) { if( depth == CV_8U ) - return Ptr(new MorphColumnFilter, - ErodeColumnVec8u>(ksize, anchor)); + return makePtr, + ErodeColumnVec8u> >(ksize, anchor); if( depth == CV_16U ) - return Ptr(new MorphColumnFilter, - ErodeColumnVec16u>(ksize, anchor)); + return makePtr, + ErodeColumnVec16u> >(ksize, anchor); if( depth == CV_16S ) - return Ptr(new MorphColumnFilter, - ErodeColumnVec16s>(ksize, anchor)); + return makePtr, + ErodeColumnVec16s> >(ksize, anchor); if( depth == CV_32F ) - return Ptr(new MorphColumnFilter, - ErodeColumnVec32f>(ksize, anchor)); + return makePtr, + ErodeColumnVec32f> >(ksize, anchor); if( depth == CV_64F ) - return Ptr(new MorphColumnFilter, - ErodeColumnVec64f>(ksize, anchor)); + return makePtr, + ErodeColumnVec64f> >(ksize, anchor); } else { if( depth == CV_8U ) - return Ptr(new MorphColumnFilter, - DilateColumnVec8u>(ksize, anchor)); + return makePtr, + DilateColumnVec8u> >(ksize, anchor); if( depth == CV_16U ) - return Ptr(new MorphColumnFilter, - DilateColumnVec16u>(ksize, anchor)); + return makePtr, + DilateColumnVec16u> >(ksize, anchor); if( depth == CV_16S ) - return Ptr(new MorphColumnFilter, - DilateColumnVec16s>(ksize, anchor)); + return makePtr, + DilateColumnVec16s> >(ksize, anchor); if( depth == CV_32F ) - return Ptr(new MorphColumnFilter, - DilateColumnVec32f>(ksize, anchor)); + return makePtr, + DilateColumnVec32f> >(ksize, anchor); if( depth == CV_64F ) - return Ptr(new MorphColumnFilter, - DilateColumnVec64f>(ksize, anchor)); + return makePtr, + DilateColumnVec64f> >(ksize, anchor); } CV_Error_( CV_StsNotImplemented, ("Unsupported data type (=%d)", type)); - return Ptr(0); + return Ptr(); } @@ -952,32 +952,32 @@ cv::Ptr cv::getMorphologyFilter(int op, int type, InputArray _ke if( op == MORPH_ERODE ) { if( depth == CV_8U ) - return Ptr(new MorphFilter, ErodeVec8u>(kernel, anchor)); + return makePtr, ErodeVec8u> >(kernel, anchor); if( depth == CV_16U ) - return Ptr(new MorphFilter, ErodeVec16u>(kernel, anchor)); + return makePtr, ErodeVec16u> >(kernel, anchor); if( depth == CV_16S ) - return Ptr(new MorphFilter, ErodeVec16s>(kernel, anchor)); + return makePtr, ErodeVec16s> >(kernel, anchor); if( depth == CV_32F ) - return Ptr(new MorphFilter, ErodeVec32f>(kernel, anchor)); + return makePtr, ErodeVec32f> >(kernel, anchor); if( depth == CV_64F ) - return Ptr(new MorphFilter, ErodeVec64f>(kernel, anchor)); + return makePtr, ErodeVec64f> >(kernel, anchor); } else { if( depth == CV_8U ) - return Ptr(new MorphFilter, DilateVec8u>(kernel, anchor)); + return makePtr, DilateVec8u> >(kernel, anchor); if( depth == CV_16U ) - return Ptr(new MorphFilter, DilateVec16u>(kernel, anchor)); + return makePtr, DilateVec16u> >(kernel, anchor); if( depth == CV_16S ) - return Ptr(new MorphFilter, DilateVec16s>(kernel, anchor)); + return makePtr, DilateVec16s> >(kernel, anchor); if( depth == CV_32F ) - return Ptr(new MorphFilter, DilateVec32f>(kernel, anchor)); + return makePtr, DilateVec32f> >(kernel, anchor); if( depth == CV_64F ) - return Ptr(new MorphFilter, DilateVec64f>(kernel, anchor)); + return makePtr, DilateVec64f> >(kernel, anchor); } CV_Error_( CV_StsNotImplemented, ("Unsupported data type (=%d)", type)); - return Ptr(0); + return Ptr(); } @@ -1020,8 +1020,8 @@ cv::Ptr cv::createMorphologyFilter( int op, int type, InputArr depth == CV_32F ? (double)-FLT_MAX : -DBL_MAX); } - return Ptr(new FilterEngine(filter2D, rowFilter, columnFilter, - type, type, type, _rowBorderType, _columnBorderType, borderValue )); + return makePtr(filter2D, rowFilter, columnFilter, + type, type, type, _rowBorderType, _columnBorderType, borderValue ); } diff --git a/modules/imgproc/src/smooth.cpp b/modules/imgproc/src/smooth.cpp index 127a9da363..a4c478a2c9 100644 --- a/modules/imgproc/src/smooth.cpp +++ b/modules/imgproc/src/smooth.cpp @@ -622,29 +622,29 @@ cv::Ptr cv::getRowSumFilter(int srcType, int sumType, int ksi anchor = ksize/2; if( sdepth == CV_8U && ddepth == CV_32S ) - return Ptr(new RowSum(ksize, anchor)); + return makePtr >(ksize, anchor); if( sdepth == CV_8U && ddepth == CV_64F ) - return Ptr(new RowSum(ksize, anchor)); + return makePtr >(ksize, anchor); if( sdepth == CV_16U && ddepth == CV_32S ) - return Ptr(new RowSum(ksize, anchor)); + return makePtr >(ksize, anchor); if( sdepth == CV_16U && ddepth == CV_64F ) - return Ptr(new RowSum(ksize, anchor)); + return makePtr >(ksize, anchor); if( sdepth == CV_16S && ddepth == CV_32S ) - return Ptr(new RowSum(ksize, anchor)); + return makePtr >(ksize, anchor); if( sdepth == CV_32S && ddepth == CV_32S ) - return Ptr(new RowSum(ksize, anchor)); + return makePtr >(ksize, anchor); if( sdepth == CV_16S && ddepth == CV_64F ) - return Ptr(new RowSum(ksize, anchor)); + return makePtr >(ksize, anchor); if( sdepth == CV_32F && ddepth == CV_64F ) - return Ptr(new RowSum(ksize, anchor)); + return makePtr >(ksize, anchor); if( sdepth == CV_64F && ddepth == CV_64F ) - return Ptr(new RowSum(ksize, anchor)); + return makePtr >(ksize, anchor); CV_Error_( CV_StsNotImplemented, ("Unsupported combination of source format (=%d), and buffer format (=%d)", srcType, sumType)); - return Ptr(0); + return Ptr(); } @@ -658,33 +658,33 @@ cv::Ptr cv::getColumnSumFilter(int sumType, int dstType, i anchor = ksize/2; if( ddepth == CV_8U && sdepth == CV_32S ) - return Ptr(new ColumnSum(ksize, anchor, scale)); + return makePtr >(ksize, anchor, scale); if( ddepth == CV_8U && sdepth == CV_64F ) - return Ptr(new ColumnSum(ksize, anchor, scale)); + return makePtr >(ksize, anchor, scale); if( ddepth == CV_16U && sdepth == CV_32S ) - return Ptr(new ColumnSum(ksize, anchor, scale)); + return makePtr >(ksize, anchor, scale); if( ddepth == CV_16U && sdepth == CV_64F ) - return Ptr(new ColumnSum(ksize, anchor, scale)); + return makePtr >(ksize, anchor, scale); if( ddepth == CV_16S && sdepth == CV_32S ) - return Ptr(new ColumnSum(ksize, anchor, scale)); + return makePtr >(ksize, anchor, scale); if( ddepth == CV_16S && sdepth == CV_64F ) - return Ptr(new ColumnSum(ksize, anchor, scale)); + return makePtr >(ksize, anchor, scale); if( ddepth == CV_32S && sdepth == CV_32S ) - return Ptr(new ColumnSum(ksize, anchor, scale)); + return makePtr >(ksize, anchor, scale); if( ddepth == CV_32F && sdepth == CV_32S ) - return Ptr(new ColumnSum(ksize, anchor, scale)); + return makePtr >(ksize, anchor, scale); if( ddepth == CV_32F && sdepth == CV_64F ) - return Ptr(new ColumnSum(ksize, anchor, scale)); + return makePtr >(ksize, anchor, scale); if( ddepth == CV_64F && sdepth == CV_32S ) - return Ptr(new ColumnSum(ksize, anchor, scale)); + return makePtr >(ksize, anchor, scale); if( ddepth == CV_64F && sdepth == CV_64F ) - return Ptr(new ColumnSum(ksize, anchor, scale)); + return makePtr >(ksize, anchor, scale); CV_Error_( CV_StsNotImplemented, ("Unsupported combination of sum format (=%d), and destination format (=%d)", sumType, dstType)); - return Ptr(0); + return Ptr(); } @@ -703,8 +703,8 @@ cv::Ptr cv::createBoxFilter( int srcType, int dstType, Size ks Ptr columnFilter = getColumnSumFilter(sumType, dstType, ksize.height, anchor.y, normalize ? 1./(ksize.width*ksize.height) : 1); - return Ptr(new FilterEngine(Ptr(0), rowFilter, columnFilter, - srcType, dstType, sumType, borderType )); + return makePtr(Ptr(), rowFilter, columnFilter, + srcType, dstType, sumType, borderType ); } diff --git a/modules/imgproc/test/test_convhull.cpp b/modules/imgproc/test/test_convhull.cpp index cae75d0cb0..49456c6cc9 100644 --- a/modules/imgproc/test/test_convhull.cpp +++ b/modules/imgproc/test/test_convhull.cpp @@ -1626,7 +1626,7 @@ CV_PerimeterAreaSliceTest::~CV_PerimeterAreaSliceTest() {} void CV_PerimeterAreaSliceTest::run( int ) { - Ptr storage = cvCreateMemStorage(); + Ptr storage(cvCreateMemStorage()); RNG& rng = theRNG(); const double min_r = 90, max_r = 120; From beeb932d22ba01e641f7eb9a6b0788cc6c7be1ff Mon Sep 17 00:00:00 2001 From: Roman Donchenko Date: Tue, 13 Aug 2013 16:47:18 +0400 Subject: [PATCH 05/55] Boring changes - highgui. --- modules/highgui/include/opencv2/highgui.hpp | 4 +- modules/highgui/src/cap.cpp | 10 ++--- modules/highgui/src/grfmt_bmp.cpp | 4 +- modules/highgui/src/grfmt_exr.cpp | 4 +- modules/highgui/src/grfmt_jpeg.cpp | 4 +- modules/highgui/src/grfmt_jpeg2000.cpp | 4 +- modules/highgui/src/grfmt_png.cpp | 4 +- modules/highgui/src/grfmt_pxm.cpp | 4 +- modules/highgui/src/grfmt_sunras.cpp | 4 +- modules/highgui/src/grfmt_tiff.cpp | 4 +- modules/highgui/src/grfmt_webp.cpp | 4 +- modules/highgui/src/loadsave.cpp | 44 ++++++++++----------- modules/highgui/test/test_framecount.cpp | 4 +- 13 files changed, 49 insertions(+), 49 deletions(-) diff --git a/modules/highgui/include/opencv2/highgui.hpp b/modules/highgui/include/opencv2/highgui.hpp index c20cf883ec..c4fc73a81f 100644 --- a/modules/highgui/include/opencv2/highgui.hpp +++ b/modules/highgui/include/opencv2/highgui.hpp @@ -544,8 +544,8 @@ protected: Ptr writer; }; -template<> CV_EXPORTS void Ptr::delete_obj(); -template<> CV_EXPORTS void Ptr::delete_obj(); +template<> CV_EXPORTS void DefaultDeleter::operator ()(CvCapture* obj) const; +template<> CV_EXPORTS void DefaultDeleter::operator ()(CvVideoWriter* obj) const; } // cv diff --git a/modules/highgui/src/cap.cpp b/modules/highgui/src/cap.cpp index 453f1dd122..be62ce9d38 100644 --- a/modules/highgui/src/cap.cpp +++ b/modules/highgui/src/cap.cpp @@ -49,10 +49,10 @@ namespace cv { -template<> void Ptr::delete_obj() +template<> void DefaultDeleter::operator ()(CvCapture* obj) const { cvReleaseCapture(&obj); } -template<> void Ptr::delete_obj() +template<> void DefaultDeleter::operator ()(CvVideoWriter* obj) const { cvReleaseVideoWriter(&obj); } } @@ -492,14 +492,14 @@ VideoCapture::~VideoCapture() bool VideoCapture::open(const String& filename) { if (isOpened()) release(); - cap = cvCreateFileCapture(filename.c_str()); + cap.reset(cvCreateFileCapture(filename.c_str())); return isOpened(); } bool VideoCapture::open(int device) { if (isOpened()) release(); - cap = cvCreateCameraCapture(device); + cap.reset(cvCreateCameraCapture(device)); return isOpened(); } @@ -578,7 +578,7 @@ VideoWriter::~VideoWriter() bool VideoWriter::open(const String& filename, int _fourcc, double fps, Size frameSize, bool isColor) { - writer = cvCreateVideoWriter(filename.c_str(), _fourcc, fps, frameSize, isColor); + writer.reset(cvCreateVideoWriter(filename.c_str(), _fourcc, fps, frameSize, isColor)); return isOpened(); } diff --git a/modules/highgui/src/grfmt_bmp.cpp b/modules/highgui/src/grfmt_bmp.cpp index 131e84eca5..f7147b5fc1 100644 --- a/modules/highgui/src/grfmt_bmp.cpp +++ b/modules/highgui/src/grfmt_bmp.cpp @@ -70,7 +70,7 @@ void BmpDecoder::close() ImageDecoder BmpDecoder::newDecoder() const { - return new BmpDecoder; + return makePtr(); } bool BmpDecoder::readHeader() @@ -496,7 +496,7 @@ BmpEncoder::~BmpEncoder() ImageEncoder BmpEncoder::newEncoder() const { - return new BmpEncoder; + return makePtr(); } bool BmpEncoder::write( const Mat& img, const std::vector& ) diff --git a/modules/highgui/src/grfmt_exr.cpp b/modules/highgui/src/grfmt_exr.cpp index 33d0ad0f56..079de58340 100644 --- a/modules/highgui/src/grfmt_exr.cpp +++ b/modules/highgui/src/grfmt_exr.cpp @@ -551,7 +551,7 @@ void ExrDecoder::RGBToGray( float *in, float *out ) ImageDecoder ExrDecoder::newDecoder() const { - return new ExrDecoder; + return makePtr(); } /////////////////////// ExrEncoder /////////////////// @@ -726,7 +726,7 @@ bool ExrEncoder::write( const Mat& img, const std::vector& ) ImageEncoder ExrEncoder::newEncoder() const { - return new ExrEncoder; + return makePtr(); } } diff --git a/modules/highgui/src/grfmt_jpeg.cpp b/modules/highgui/src/grfmt_jpeg.cpp index 09db677a43..28c52e8598 100644 --- a/modules/highgui/src/grfmt_jpeg.cpp +++ b/modules/highgui/src/grfmt_jpeg.cpp @@ -208,7 +208,7 @@ void JpegDecoder::close() ImageDecoder JpegDecoder::newDecoder() const { - return new JpegDecoder; + return makePtr(); } bool JpegDecoder::readHeader() @@ -539,7 +539,7 @@ JpegEncoder::~JpegEncoder() ImageEncoder JpegEncoder::newEncoder() const { - return new JpegEncoder; + return makePtr(); } bool JpegEncoder::write( const Mat& img, const std::vector& params ) diff --git a/modules/highgui/src/grfmt_jpeg2000.cpp b/modules/highgui/src/grfmt_jpeg2000.cpp index 4a48e81a65..d711846ce8 100644 --- a/modules/highgui/src/grfmt_jpeg2000.cpp +++ b/modules/highgui/src/grfmt_jpeg2000.cpp @@ -88,7 +88,7 @@ Jpeg2KDecoder::~Jpeg2KDecoder() ImageDecoder Jpeg2KDecoder::newDecoder() const { - return new Jpeg2KDecoder; + return makePtr(); } void Jpeg2KDecoder::close() @@ -403,7 +403,7 @@ Jpeg2KEncoder::~Jpeg2KEncoder() ImageEncoder Jpeg2KEncoder::newEncoder() const { - return new Jpeg2KEncoder; + return makePtr(); } bool Jpeg2KEncoder::isFormatSupported( int depth ) const diff --git a/modules/highgui/src/grfmt_png.cpp b/modules/highgui/src/grfmt_png.cpp index c784d5a5b3..4d5c7793ea 100644 --- a/modules/highgui/src/grfmt_png.cpp +++ b/modules/highgui/src/grfmt_png.cpp @@ -101,7 +101,7 @@ PngDecoder::~PngDecoder() ImageDecoder PngDecoder::newDecoder() const { - return new PngDecoder; + return makePtr(); } void PngDecoder::close() @@ -317,7 +317,7 @@ bool PngEncoder::isFormatSupported( int depth ) const ImageEncoder PngEncoder::newEncoder() const { - return new PngEncoder; + return makePtr(); } diff --git a/modules/highgui/src/grfmt_pxm.cpp b/modules/highgui/src/grfmt_pxm.cpp index 0acf195dd5..425a296cb9 100644 --- a/modules/highgui/src/grfmt_pxm.cpp +++ b/modules/highgui/src/grfmt_pxm.cpp @@ -116,7 +116,7 @@ bool PxMDecoder::checkSignature( const String& signature ) const ImageDecoder PxMDecoder::newDecoder() const { - return new PxMDecoder; + return makePtr(); } void PxMDecoder::close() @@ -357,7 +357,7 @@ PxMEncoder::~PxMEncoder() ImageEncoder PxMEncoder::newEncoder() const { - return new PxMEncoder; + return makePtr(); } diff --git a/modules/highgui/src/grfmt_sunras.cpp b/modules/highgui/src/grfmt_sunras.cpp index a16e5d8004..b67400f337 100644 --- a/modules/highgui/src/grfmt_sunras.cpp +++ b/modules/highgui/src/grfmt_sunras.cpp @@ -63,7 +63,7 @@ SunRasterDecoder::~SunRasterDecoder() ImageDecoder SunRasterDecoder::newDecoder() const { - return new SunRasterDecoder; + return makePtr(); } void SunRasterDecoder::close() @@ -388,7 +388,7 @@ SunRasterEncoder::SunRasterEncoder() ImageEncoder SunRasterEncoder::newEncoder() const { - return new SunRasterEncoder; + return makePtr(); } SunRasterEncoder::~SunRasterEncoder() diff --git a/modules/highgui/src/grfmt_tiff.cpp b/modules/highgui/src/grfmt_tiff.cpp index a0d53f3db8..d8937db251 100644 --- a/modules/highgui/src/grfmt_tiff.cpp +++ b/modules/highgui/src/grfmt_tiff.cpp @@ -108,7 +108,7 @@ int TiffDecoder::normalizeChannelsNumber(int channels) const ImageDecoder TiffDecoder::newDecoder() const { - return new TiffDecoder; + return makePtr(); } bool TiffDecoder::readHeader() @@ -400,7 +400,7 @@ TiffEncoder::~TiffEncoder() ImageEncoder TiffEncoder::newEncoder() const { - return new TiffEncoder; + return makePtr(); } bool TiffEncoder::isFormatSupported( int depth ) const diff --git a/modules/highgui/src/grfmt_webp.cpp b/modules/highgui/src/grfmt_webp.cpp index fd9682a79f..1c64adec60 100644 --- a/modules/highgui/src/grfmt_webp.cpp +++ b/modules/highgui/src/grfmt_webp.cpp @@ -90,7 +90,7 @@ bool WebPDecoder::checkSignature(const String & signature) const ImageDecoder WebPDecoder::newDecoder() const { - return new WebPDecoder; + return makePtr(); } bool WebPDecoder::readHeader() @@ -201,7 +201,7 @@ WebPEncoder::~WebPEncoder() { } ImageEncoder WebPEncoder::newEncoder() const { - return new WebPEncoder(); + return makePtr(); } bool WebPEncoder::write(const Mat& img, const std::vector& params) diff --git a/modules/highgui/src/loadsave.cpp b/modules/highgui/src/loadsave.cpp index a548df54de..58a0a6fbf7 100644 --- a/modules/highgui/src/loadsave.cpp +++ b/modules/highgui/src/loadsave.cpp @@ -58,35 +58,35 @@ struct ImageCodecInitializer { ImageCodecInitializer() { - decoders.push_back( new BmpDecoder ); - encoders.push_back( new BmpEncoder ); + decoders.push_back( makePtr() ); + encoders.push_back( makePtr() ); #ifdef HAVE_JPEG - decoders.push_back( new JpegDecoder ); - encoders.push_back( new JpegEncoder ); + decoders.push_back( makePtr() ); + encoders.push_back( makePtr() ); #endif #ifdef HAVE_WEBP - decoders.push_back( new WebPDecoder ); - encoders.push_back( new WebPEncoder ); + decoders.push_back( makePtr() ); + encoders.push_back( makePtr() ); #endif - decoders.push_back( new SunRasterDecoder ); - encoders.push_back( new SunRasterEncoder ); - decoders.push_back( new PxMDecoder ); - encoders.push_back( new PxMEncoder ); + decoders.push_back( makePtr() ); + encoders.push_back( makePtr() ); + decoders.push_back( makePtr() ); + encoders.push_back( makePtr() ); #ifdef HAVE_TIFF - decoders.push_back( new TiffDecoder ); + decoders.push_back( makePtr() ); #endif - encoders.push_back( new TiffEncoder ); + encoders.push_back( makePtr() ); #ifdef HAVE_PNG - decoders.push_back( new PngDecoder ); - encoders.push_back( new PngEncoder ); + decoders.push_back( makePtr() ); + encoders.push_back( makePtr() ); #endif #ifdef HAVE_JASPER - decoders.push_back( new Jpeg2KDecoder ); - encoders.push_back( new Jpeg2KEncoder ); + decoders.push_back( makePtr() ); + encoders.push_back( makePtr() ); #endif #ifdef HAVE_OPENEXR - decoders.push_back( new ExrDecoder ); - encoders.push_back( new ExrEncoder ); + decoders.push_back( makePtr() ); + encoders.push_back( makePtr() ); #endif } @@ -198,7 +198,7 @@ imread_( const String& filename, int flags, int hdrtype, Mat* mat=0 ) Mat temp, *data = &temp; ImageDecoder decoder = findDecoder(filename); - if( decoder.empty() ) + if( !decoder ) return 0; decoder->setSource(filename); if( !decoder->readHeader() ) @@ -269,7 +269,7 @@ static bool imwrite_( const String& filename, const Mat& image, CV_Assert( image.channels() == 1 || image.channels() == 3 || image.channels() == 4 ); ImageEncoder encoder = findEncoder( filename ); - if( encoder.empty() ) + if( !encoder ) CV_Error( CV_StsError, "could not find a writer for the specified extension" ); if( !encoder->isFormatSupported(image.depth()) ) @@ -309,7 +309,7 @@ imdecode_( const Mat& buf, int flags, int hdrtype, Mat* mat=0 ) String filename; ImageDecoder decoder = findDecoder(buf); - if( decoder.empty() ) + if( !decoder ) return 0; if( !decoder->setSource(buf) ) @@ -409,7 +409,7 @@ bool imencode( const String& ext, InputArray _image, CV_Assert( channels == 1 || channels == 3 || channels == 4 ); ImageEncoder encoder = findEncoder( ext ); - if( encoder.empty() ) + if( !encoder ) CV_Error( CV_StsError, "could not find encoder for the specified extension" ); if( !encoder->isFormatSupported(image.depth()) ) diff --git a/modules/highgui/test/test_framecount.cpp b/modules/highgui/test/test_framecount.cpp index 875ce6aca4..30f6e67ce6 100644 --- a/modules/highgui/test/test_framecount.cpp +++ b/modules/highgui/test/test_framecount.cpp @@ -71,8 +71,8 @@ void CV_FramecountTest::run(int) { string file_path = src_dir+"video/big_buck_bunny."+ext[i]; - cap = cvCreateFileCapture(file_path.c_str()); - if (cap.empty()) + cap.reset(cvCreateFileCapture(file_path.c_str())); + if (!cap) { ts->printf(cvtest::TS::LOG, "\nFile information (video %d): \n\nName: big_buck_bunny.%s\nFAILED\n\n", i+1, ext[i].c_str()); ts->printf(cvtest::TS::LOG, "Error: cannot read source video file.\n"); From 711fb6bd92efbe80e34e5bad6aec1240e5eb1dd1 Mon Sep 17 00:00:00 2001 From: Roman Donchenko Date: Tue, 13 Aug 2013 16:48:54 +0400 Subject: [PATCH 06/55] Boring changes - bioinspired. --- modules/bioinspired/src/retina.cpp | 6 ++++-- modules/bioinspired/src/retina_ocl.cpp | 4 ++-- modules/bioinspired/src/retinafasttonemapping.cpp | 6 +++--- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/modules/bioinspired/src/retina.cpp b/modules/bioinspired/src/retina.cpp index 75e4b841ff..4604331076 100644 --- a/modules/bioinspired/src/retina.cpp +++ b/modules/bioinspired/src/retina.cpp @@ -295,8 +295,10 @@ private: }; // smart pointers allocation : -Ptr createRetina(Size inputSize){ return new RetinaImpl(inputSize); } -Ptr createRetina(Size inputSize, const bool colorMode, int colorSamplingMethod, const bool useRetinaLogSampling, const double reductionFactor, const double samplingStrenght){return new RetinaImpl(inputSize, colorMode, colorSamplingMethod, useRetinaLogSampling, reductionFactor, samplingStrenght);} +Ptr createRetina(Size inputSize){ return makePtr(inputSize); } +Ptr createRetina(Size inputSize, const bool colorMode, int colorSamplingMethod, const bool useRetinaLogSampling, const double reductionFactor, const double samplingStrenght){ + return makePtr(inputSize, colorMode, colorSamplingMethod, useRetinaLogSampling, reductionFactor, samplingStrenght); +} // RetinaImpl code diff --git a/modules/bioinspired/src/retina_ocl.cpp b/modules/bioinspired/src/retina_ocl.cpp index ca94bc8fb6..41169561fb 100644 --- a/modules/bioinspired/src/retina_ocl.cpp +++ b/modules/bioinspired/src/retina_ocl.cpp @@ -1639,10 +1639,10 @@ void RetinaFilter::_processRetinaParvoMagnoMapping() } } /* namespace ocl */ -Ptr createRetina_OCL(Size getInputSize){ return new ocl::RetinaOCLImpl(getInputSize); } +Ptr createRetina_OCL(Size getInputSize){ return makePtr(getInputSize); } Ptr createRetina_OCL(Size getInputSize, const bool colorMode, int colorSamplingMethod, const bool useRetinaLogSampling, const double reductionFactor, const double samplingStrenght) { - return new ocl::RetinaOCLImpl(getInputSize, colorMode, colorSamplingMethod, useRetinaLogSampling, reductionFactor, samplingStrenght); + return makePtr(getInputSize, colorMode, colorSamplingMethod, useRetinaLogSampling, reductionFactor, samplingStrenght); } } /* namespace bioinspired */ diff --git a/modules/bioinspired/src/retinafasttonemapping.cpp b/modules/bioinspired/src/retinafasttonemapping.cpp index 468bedb9a1..2713d7449c 100644 --- a/modules/bioinspired/src/retinafasttonemapping.cpp +++ b/modules/bioinspired/src/retinafasttonemapping.cpp @@ -114,9 +114,9 @@ public: _imageOutput.resize(nbPixels*3); _temp2.resize(nbPixels); // allocate the main filter with 2 setup sets properties (one for each low pass filter - _multiuseFilter = new BasicRetinaFilter(imageInput.height, imageInput.width, 2); + _multiuseFilter = makePtr(imageInput.height, imageInput.width, 2); // allocate the color manager (multiplexer/demultiplexer - _colorEngine = new RetinaColor(imageInput.height, imageInput.width); + _colorEngine = makePtr(imageInput.height, imageInput.width); // setup filter behaviors with default values setup(); } @@ -309,7 +309,7 @@ bool _convertCvMat2ValarrayBuffer(InputArray inputMat, std::valarray &out CV_EXPORTS Ptr createRetinaFastToneMapping(Size inputSize) { - return new RetinaFastToneMappingImpl(inputSize); + return makePtr(inputSize); } }// end of namespace bioinspired From bd70a033fc518f37fb140ccd6e92fd85e23f6a03 Mon Sep 17 00:00:00 2001 From: Roman Donchenko Date: Tue, 13 Aug 2013 17:03:56 +0400 Subject: [PATCH 07/55] Boring changes - calib3d. --- ...mera_calibration_and_3d_reconstruction.rst | 2 +- modules/calib3d/include/opencv2/calib3d.hpp | 2 +- modules/calib3d/src/calibinit.cpp | 18 ++--- modules/calib3d/src/calibration.cpp | 78 +++++++++---------- modules/calib3d/src/compat_ptsetreg.cpp | 24 +++--- modules/calib3d/src/five-point.cpp | 4 +- modules/calib3d/src/fundam.cpp | 6 +- modules/calib3d/src/levmarq.cpp | 4 +- modules/calib3d/src/ptsetreg.cpp | 12 +-- modules/calib3d/src/stereobm.cpp | 2 +- modules/calib3d/src/stereosgbm.cpp | 11 +-- modules/calib3d/src/triangulate.cpp | 28 +++---- 12 files changed, 96 insertions(+), 95 deletions(-) diff --git a/modules/calib3d/doc/camera_calibration_and_3d_reconstruction.rst b/modules/calib3d/doc/camera_calibration_and_3d_reconstruction.rst index 30f3102a7f..cb30dc36d5 100644 --- a/modules/calib3d/doc/camera_calibration_and_3d_reconstruction.rst +++ b/modules/calib3d/doc/camera_calibration_and_3d_reconstruction.rst @@ -515,7 +515,7 @@ findCirclesGrid ------------------- Finds centers in the grid of circles. -.. ocv:function:: bool findCirclesGrid( InputArray image, Size patternSize, OutputArray centers, int flags=CALIB_CB_SYMMETRIC_GRID, const Ptr &blobDetector = new SimpleBlobDetector() ) +.. ocv:function:: bool findCirclesGrid( InputArray image, Size patternSize, OutputArray centers, int flags=CALIB_CB_SYMMETRIC_GRID, const Ptr &blobDetector = makePtr() ) .. ocv:pyfunction:: cv2.findCirclesGrid(image, patternSize[, centers[, flags[, blobDetector]]]) -> retval, centers diff --git a/modules/calib3d/include/opencv2/calib3d.hpp b/modules/calib3d/include/opencv2/calib3d.hpp index 2486eb19a8..f5ccb54a71 100644 --- a/modules/calib3d/include/opencv2/calib3d.hpp +++ b/modules/calib3d/include/opencv2/calib3d.hpp @@ -180,7 +180,7 @@ CV_EXPORTS_W void drawChessboardCorners( InputOutputArray image, Size patternSiz //! finds circles' grid pattern of the specified size in the image CV_EXPORTS_W bool findCirclesGrid( InputArray image, Size patternSize, OutputArray centers, int flags = CALIB_CB_SYMMETRIC_GRID, - const Ptr &blobDetector = new SimpleBlobDetector()); + const Ptr &blobDetector = makePtr()); //! finds intrinsic and extrinsic camera parameters from several fews of a known calibration pattern. CV_EXPORTS_W double calibrateCamera( InputArrayOfArrays objectPoints, diff --git a/modules/calib3d/src/calibinit.cpp b/modules/calib3d/src/calibinit.cpp index b93b4951ed..844fde4999 100644 --- a/modules/calib3d/src/calibinit.cpp +++ b/modules/calib3d/src/calibinit.cpp @@ -271,8 +271,8 @@ int cvFindChessboardCorners( const void* arr, CvSize pattern_size, if( !out_corners ) CV_Error( CV_StsNullPtr, "Null pointer to corners" ); - storage = cvCreateMemStorage(0); - thresh_img = cvCreateMat( img->rows, img->cols, CV_8UC1 ); + storage.reset(cvCreateMemStorage(0)); + thresh_img.reset(cvCreateMat( img->rows, img->cols, CV_8UC1 )); #ifdef DEBUG_CHESSBOARD dbg_img = cvCreateImage(cvGetSize(img), IPL_DEPTH_8U, 3 ); @@ -284,7 +284,7 @@ int cvFindChessboardCorners( const void* arr, CvSize pattern_size, { // equalize the input image histogram - // that should make the contrast between "black" and "white" areas big enough - norm_img = cvCreateMat( img->rows, img->cols, CV_8UC1 ); + norm_img.reset(cvCreateMat( img->rows, img->cols, CV_8UC1 )); if( CV_MAT_CN(img->type) != 1 ) { @@ -541,12 +541,12 @@ int cvFindChessboardCorners( const void* arr, CvSize pattern_size, cv::Ptr gray; if( CV_MAT_CN(img->type) != 1 ) { - gray = cvCreateMat(img->rows, img->cols, CV_8UC1); + gray.reset(cvCreateMat(img->rows, img->cols, CV_8UC1)); cvCvtColor(img, gray, CV_BGR2GRAY); } else { - gray = cvCloneMat(img); + gray.reset(cvCloneMat(img)); } int wsize = 2; cvFindCornerSubPix( gray, out_corners, pattern_size.width*pattern_size.height, @@ -627,7 +627,7 @@ icvOrderFoundConnectedQuads( int quad_count, CvCBQuad **quads, int *all_count, CvCBQuad **all_quads, CvCBCorner **corners, CvSize pattern_size, CvMemStorage* storage ) { - cv::Ptr temp_storage = cvCreateChildMemStorage( storage ); + cv::Ptr temp_storage(cvCreateChildMemStorage( storage )); CvSeq* stack = cvCreateSeq( 0, sizeof(*stack), sizeof(void*), temp_storage ); // first find an interior quad @@ -1109,7 +1109,7 @@ icvCleanFoundConnectedQuads( int quad_count, CvCBQuad **quad_group, CvSize patte // create an array of quadrangle centers cv::AutoBuffer centers( quad_count ); - cv::Ptr temp_storage = cvCreateMemStorage(0); + cv::Ptr temp_storage(cvCreateMemStorage(0)); for( i = 0; i < quad_count; i++ ) { @@ -1205,7 +1205,7 @@ static int icvFindConnectedQuads( CvCBQuad *quad, int quad_count, CvCBQuad **out_group, int group_idx, CvMemStorage* storage ) { - cv::Ptr temp_storage = cvCreateChildMemStorage( storage ); + cv::Ptr temp_storage(cvCreateChildMemStorage( storage )); CvSeq* stack = cvCreateSeq( 0, sizeof(*stack), sizeof(void*), temp_storage ); int i, count = 0; @@ -1674,7 +1674,7 @@ icvGenerateQuads( CvCBQuad **out_quads, CvCBCorner **out_corners, min_size = 25; //cvRound( image->cols * image->rows * .03 * 0.01 * 0.92 ); // create temporary storage for contours and the sequence of pointers to found quadrangles - temp_storage = cvCreateChildMemStorage( storage ); + temp_storage.reset(cvCreateChildMemStorage( storage )); root = cvCreateSeq( 0, sizeof(CvSeq), sizeof(CvSeq*), temp_storage ); // initialize contour retrieving routine diff --git a/modules/calib3d/src/calibration.cpp b/modules/calib3d/src/calibration.cpp index bb78635752..132220d404 100644 --- a/modules/calib3d/src/calibration.cpp +++ b/modules/calib3d/src/calibration.cpp @@ -568,7 +568,7 @@ CV_IMPL void cvProjectPoints2( const CvMat* objectPoints, (objectPoints->rows == count && CV_MAT_CN(objectPoints->type)*objectPoints->cols == 3) || (objectPoints->rows == 3 && CV_MAT_CN(objectPoints->type) == 1 && objectPoints->cols == count))) { - matM = cvCreateMat( objectPoints->rows, objectPoints->cols, CV_MAKETYPE(CV_64F,CV_MAT_CN(objectPoints->type)) ); + matM.reset(cvCreateMat( objectPoints->rows, objectPoints->cols, CV_MAKETYPE(CV_64F,CV_MAT_CN(objectPoints->type)) )); cvConvert(objectPoints, matM); } else @@ -584,7 +584,7 @@ CV_IMPL void cvProjectPoints2( const CvMat* objectPoints, (imagePoints->rows == count && CV_MAT_CN(imagePoints->type)*imagePoints->cols == 2) || (imagePoints->rows == 2 && CV_MAT_CN(imagePoints->type) == 1 && imagePoints->cols == count))) { - _m = cvCreateMat( imagePoints->rows, imagePoints->cols, CV_MAKETYPE(CV_64F,CV_MAT_CN(imagePoints->type)) ); + _m.reset(cvCreateMat( imagePoints->rows, imagePoints->cols, CV_MAKETYPE(CV_64F,CV_MAT_CN(imagePoints->type)) )); cvConvert(imagePoints, _m); } else @@ -664,10 +664,10 @@ CV_IMPL void cvProjectPoints2( const CvMat* objectPoints, if( CV_MAT_TYPE(dpdr->type) == CV_64FC1 ) { - _dpdr = cvCloneMat(dpdr); + _dpdr.reset(cvCloneMat(dpdr)); } else - _dpdr = cvCreateMat( 2*count, 3, CV_64FC1 ); + _dpdr.reset(cvCreateMat( 2*count, 3, CV_64FC1 )); dpdr_p = _dpdr->data.db; dpdr_step = _dpdr->step/sizeof(dpdr_p[0]); } @@ -682,10 +682,10 @@ CV_IMPL void cvProjectPoints2( const CvMat* objectPoints, if( CV_MAT_TYPE(dpdt->type) == CV_64FC1 ) { - _dpdt = cvCloneMat(dpdt); + _dpdt.reset(cvCloneMat(dpdt)); } else - _dpdt = cvCreateMat( 2*count, 3, CV_64FC1 ); + _dpdt.reset(cvCreateMat( 2*count, 3, CV_64FC1 )); dpdt_p = _dpdt->data.db; dpdt_step = _dpdt->step/sizeof(dpdt_p[0]); } @@ -699,10 +699,10 @@ CV_IMPL void cvProjectPoints2( const CvMat* objectPoints, if( CV_MAT_TYPE(dpdf->type) == CV_64FC1 ) { - _dpdf = cvCloneMat(dpdf); + _dpdf.reset(cvCloneMat(dpdf)); } else - _dpdf = cvCreateMat( 2*count, 2, CV_64FC1 ); + _dpdf.reset(cvCreateMat( 2*count, 2, CV_64FC1 )); dpdf_p = _dpdf->data.db; dpdf_step = _dpdf->step/sizeof(dpdf_p[0]); } @@ -716,10 +716,10 @@ CV_IMPL void cvProjectPoints2( const CvMat* objectPoints, if( CV_MAT_TYPE(dpdc->type) == CV_64FC1 ) { - _dpdc = cvCloneMat(dpdc); + _dpdc.reset(cvCloneMat(dpdc)); } else - _dpdc = cvCreateMat( 2*count, 2, CV_64FC1 ); + _dpdc.reset(cvCreateMat( 2*count, 2, CV_64FC1 )); dpdc_p = _dpdc->data.db; dpdc_step = _dpdc->step/sizeof(dpdc_p[0]); } @@ -736,10 +736,10 @@ CV_IMPL void cvProjectPoints2( const CvMat* objectPoints, if( CV_MAT_TYPE(dpdk->type) == CV_64FC1 ) { - _dpdk = cvCloneMat(dpdk); + _dpdk.reset(cvCloneMat(dpdk)); } else - _dpdk = cvCreateMat( dpdk->rows, dpdk->cols, CV_64FC1 ); + _dpdk.reset(cvCreateMat( dpdk->rows, dpdk->cols, CV_64FC1 )); dpdk_p = _dpdk->data.db; dpdk_step = _dpdk->step/sizeof(dpdk_p[0]); } @@ -950,8 +950,8 @@ CV_IMPL void cvFindExtrinsicCameraParams2( const CvMat* objectPoints, CV_IS_MAT(A) && CV_IS_MAT(rvec) && CV_IS_MAT(tvec) ); count = MAX(objectPoints->cols, objectPoints->rows); - matM = cvCreateMat( 1, count, CV_64FC3 ); - _m = cvCreateMat( 1, count, CV_64FC2 ); + matM.reset(cvCreateMat( 1, count, CV_64FC3 )); + _m.reset(cvCreateMat( 1, count, CV_64FC2 )); cvConvertPointsHomogeneous( objectPoints, matM ); cvConvertPointsHomogeneous( imagePoints, _m ); @@ -963,8 +963,8 @@ CV_IMPL void cvFindExtrinsicCameraParams2( const CvMat* objectPoints, CV_Assert( (CV_MAT_DEPTH(tvec->type) == CV_64F || CV_MAT_DEPTH(tvec->type) == CV_32F) && (tvec->rows == 1 || tvec->cols == 1) && tvec->rows*tvec->cols*CV_MAT_CN(tvec->type) == 3 ); - _mn = cvCreateMat( 1, count, CV_64FC2 ); - _Mxy = cvCreateMat( 1, count, CV_64FC2 ); + _mn.reset(cvCreateMat( 1, count, CV_64FC2 )); + _Mxy.reset(cvCreateMat( 1, count, CV_64FC2 )); // normalize image points // (unapply the intrinsic matrix transformation and distortion) @@ -1055,7 +1055,7 @@ CV_IMPL void cvFindExtrinsicCameraParams2( const CvMat* objectPoints, CvPoint3D64f* M = (CvPoint3D64f*)matM->data.db; CvPoint2D64f* mn = (CvPoint2D64f*)_mn->data.db; - matL = cvCreateMat( 2*count, 12, CV_64F ); + matL.reset(cvCreateMat( 2*count, 12, CV_64F )); L = matL->data.db; for( i = 0; i < count; i++, L += 24 ) @@ -1162,11 +1162,11 @@ CV_IMPL void cvInitIntrinsicParams2D( const CvMat* objectPoints, if( objectPoints->rows != 1 || imagePoints->rows != 1 ) CV_Error( CV_StsBadSize, "object points and image points must be a single-row matrices" ); - matA = cvCreateMat( 2*nimages, 2, CV_64F ); - _b = cvCreateMat( 2*nimages, 1, CV_64F ); + matA.reset(cvCreateMat( 2*nimages, 2, CV_64F )); + _b.reset(cvCreateMat( 2*nimages, 1, CV_64F )); a[2] = (imageSize.width - 1)*0.5; a[5] = (imageSize.height - 1)*0.5; - _allH = cvCreateMat( nimages, 9, CV_64F ); + _allH.reset(cvCreateMat( nimages, 9, CV_64F )); // extract vanishing points in order to obtain initial value for the focal length for( i = 0, pos = 0; i < nimages; i++, pos += ni ) @@ -1310,16 +1310,16 @@ CV_IMPL double cvCalibrateCamera2( const CvMat* objectPoints, total += ni; } - matM = cvCreateMat( 1, total, CV_64FC3 ); - _m = cvCreateMat( 1, total, CV_64FC2 ); + matM.reset(cvCreateMat( 1, total, CV_64FC3 )); + _m.reset(cvCreateMat( 1, total, CV_64FC2 )); cvConvertPointsHomogeneous( objectPoints, matM ); cvConvertPointsHomogeneous( imagePoints, _m ); nparams = NINTRINSIC + nimages*6; - _Ji = cvCreateMat( maxPoints*2, NINTRINSIC, CV_64FC1 ); - _Je = cvCreateMat( maxPoints*2, 6, CV_64FC1 ); - _err = cvCreateMat( maxPoints*2, 1, CV_64FC1 ); + _Ji.reset(cvCreateMat( maxPoints*2, NINTRINSIC, CV_64FC1 )); + _Je.reset(cvCreateMat( maxPoints*2, 6, CV_64FC1 )); + _err.reset(cvCreateMat( maxPoints*2, 1, CV_64FC1 )); cvZero( _Ji ); _k = cvMat( distCoeffs->rows, distCoeffs->cols, CV_MAKETYPE(CV_64F,CV_MAT_CN(distCoeffs->type)), k); @@ -1662,7 +1662,7 @@ double cvStereoCalibrate( const CvMat* _objectPoints, const CvMat* _imagePoints1 CV_MAT_TYPE(_npoints->type) == CV_32SC1 ); nimages = _npoints->cols + _npoints->rows - 1; - npoints = cvCreateMat( _npoints->rows, _npoints->cols, _npoints->type ); + npoints.reset(cvCreateMat( _npoints->rows, _npoints->cols, _npoints->type )); cvCopy( _npoints, npoints ); for( i = 0, pointsTotal = 0; i < nimages; i++ ) @@ -1671,8 +1671,8 @@ double cvStereoCalibrate( const CvMat* _objectPoints, const CvMat* _imagePoints1 pointsTotal += npoints->data.i[i]; } - objectPoints = cvCreateMat( _objectPoints->rows, _objectPoints->cols, - CV_64FC(CV_MAT_CN(_objectPoints->type))); + objectPoints.reset(cvCreateMat( _objectPoints->rows, _objectPoints->cols, + CV_64FC(CV_MAT_CN(_objectPoints->type)))); cvConvert( _objectPoints, objectPoints ); cvReshape( objectPoints, objectPoints, 3, 1 ); @@ -1691,7 +1691,7 @@ double cvStereoCalibrate( const CvMat* _objectPoints, const CvMat* _imagePoints1 K[k] = cvMat(3,3,CV_64F,A[k]); Dist[k] = cvMat(1,8,CV_64F,dk[k]); - imagePoints[k] = cvCreateMat( points->rows, points->cols, CV_64FC(CV_MAT_CN(points->type))); + imagePoints[k].reset(cvCreateMat( points->rows, points->cols, CV_64FC(CV_MAT_CN(points->type)))); cvConvert( points, imagePoints[k] ); cvReshape( imagePoints[k], imagePoints[k], 2, 1 ); @@ -1729,10 +1729,10 @@ double cvStereoCalibrate( const CvMat* _objectPoints, const CvMat* _imagePoints1 recomputeIntrinsics = (flags & CV_CALIB_FIX_INTRINSIC) == 0; - err = cvCreateMat( maxPoints*2, 1, CV_64F ); - Je = cvCreateMat( maxPoints*2, 6, CV_64F ); - J_LR = cvCreateMat( maxPoints*2, 6, CV_64F ); - Ji = cvCreateMat( maxPoints*2, NINTRINSIC, CV_64F ); + err.reset(cvCreateMat( maxPoints*2, 1, CV_64F )); + Je.reset(cvCreateMat( maxPoints*2, 6, CV_64F )); + J_LR.reset(cvCreateMat( maxPoints*2, 6, CV_64F )); + Ji.reset(cvCreateMat( maxPoints*2, NINTRINSIC, CV_64F )); cvZero( Ji ); // we optimize for the inter-camera R(3),t(3), then, optionally, @@ -1740,7 +1740,7 @@ double cvStereoCalibrate( const CvMat* _objectPoints, const CvMat* _imagePoints1 nparams = 6*(nimages+1) + (recomputeIntrinsics ? NINTRINSIC*2 : 0); // storage for initial [om(R){i}|t{i}] (in order to compute the median for each component) - RT0 = cvCreateMat( 6, nimages, CV_64F ); + RT0.reset(cvCreateMat( 6, nimages, CV_64F )); solver.init( nparams, 0, termCrit ); if( recomputeIntrinsics ) @@ -2080,7 +2080,7 @@ icvGetRectangles( const CvMat* cameraMatrix, const CvMat* distCoeffs, { const int N = 9; int x, y, k; - cv::Ptr _pts = cvCreateMat(1, N*N, CV_32FC2); + cv::Ptr _pts(cvCreateMat(1, N*N, CV_32FC2)); CvPoint2D32f* pts = (CvPoint2D32f*)(_pts->data.ptr); for( y = k = 0; y < N; y++ ) @@ -2439,10 +2439,10 @@ CV_IMPL int cvStereoRectifyUncalibrated( npoints = _points1->rows * _points1->cols * CV_MAT_CN(_points1->type) / 2; - _m1 = cvCreateMat( _points1->rows, _points1->cols, CV_64FC(CV_MAT_CN(_points1->type)) ); - _m2 = cvCreateMat( _points2->rows, _points2->cols, CV_64FC(CV_MAT_CN(_points2->type)) ); - _lines1 = cvCreateMat( 1, npoints, CV_64FC3 ); - _lines2 = cvCreateMat( 1, npoints, CV_64FC3 ); + _m1.reset(cvCreateMat( _points1->rows, _points1->cols, CV_64FC(CV_MAT_CN(_points1->type)) )); + _m2.reset(cvCreateMat( _points2->rows, _points2->cols, CV_64FC(CV_MAT_CN(_points2->type)) )); + _lines1.reset(cvCreateMat( 1, npoints, CV_64FC3 )); + _lines2.reset(cvCreateMat( 1, npoints, CV_64FC3 )); cvConvert( F0, &F ); diff --git a/modules/calib3d/src/compat_ptsetreg.cpp b/modules/calib3d/src/compat_ptsetreg.cpp index db3fc99561..e8f4108580 100644 --- a/modules/calib3d/src/compat_ptsetreg.cpp +++ b/modules/calib3d/src/compat_ptsetreg.cpp @@ -53,7 +53,6 @@ using cv::Ptr; CvLevMarq::CvLevMarq() { - mask = prevParam = param = J = err = JtJ = JtJN = JtErr = JtJV = JtJW = Ptr(); lambdaLg10 = 0; state = DONE; criteria = cvTermCriteria(0,0,0); iters = 0; @@ -62,7 +61,6 @@ CvLevMarq::CvLevMarq() CvLevMarq::CvLevMarq( int nparams, int nerrs, CvTermCriteria criteria0, bool _completeSymmFlag ) { - mask = prevParam = param = J = err = JtJ = JtJN = JtErr = JtJV = JtJW = Ptr(); init(nparams, nerrs, criteria0, _completeSymmFlag); } @@ -89,19 +87,19 @@ void CvLevMarq::init( int nparams, int nerrs, CvTermCriteria criteria0, bool _co { if( !param || param->rows != nparams || nerrs != (err ? err->rows : 0) ) clear(); - mask = cvCreateMat( nparams, 1, CV_8U ); + mask.reset(cvCreateMat( nparams, 1, CV_8U )); cvSet(mask, cvScalarAll(1)); - prevParam = cvCreateMat( nparams, 1, CV_64F ); - param = cvCreateMat( nparams, 1, CV_64F ); - JtJ = cvCreateMat( nparams, nparams, CV_64F ); - JtJN = cvCreateMat( nparams, nparams, CV_64F ); - JtJV = cvCreateMat( nparams, nparams, CV_64F ); - JtJW = cvCreateMat( nparams, 1, CV_64F ); - JtErr = cvCreateMat( nparams, 1, CV_64F ); + prevParam.reset(cvCreateMat( nparams, 1, CV_64F )); + param.reset(cvCreateMat( nparams, 1, CV_64F )); + JtJ.reset(cvCreateMat( nparams, nparams, CV_64F )); + JtJN.reset(cvCreateMat( nparams, nparams, CV_64F )); + JtJV.reset(cvCreateMat( nparams, nparams, CV_64F )); + JtJW.reset(cvCreateMat( nparams, 1, CV_64F )); + JtErr.reset(cvCreateMat( nparams, 1, CV_64F )); if( nerrs > 0 ) { - J = cvCreateMat( nerrs, nparams, CV_64F ); - err = cvCreateMat( nerrs, 1, CV_64F ); + J.reset(cvCreateMat( nerrs, nparams, CV_64F )); + err.reset(cvCreateMat( nerrs, 1, CV_64F )); } prevErrNorm = DBL_MAX; lambdaLg10 = -3; @@ -196,7 +194,7 @@ bool CvLevMarq::updateAlt( const CvMat*& _param, CvMat*& _JtJ, CvMat*& _JtErr, d { double change; - CV_Assert( err.empty() ); + CV_Assert( !err ); if( state == DONE ) { _param = param; diff --git a/modules/calib3d/src/five-point.cpp b/modules/calib3d/src/five-point.cpp index 88fb402726..9922247008 100644 --- a/modules/calib3d/src/five-point.cpp +++ b/modules/calib3d/src/five-point.cpp @@ -436,9 +436,9 @@ cv::Mat cv::findEssentialMat( InputArray _points1, InputArray _points2, double f Mat E; if( method == RANSAC ) - createRANSACPointSetRegistrator(new EMEstimatorCallback, 5, threshold, prob)->run(points1, points2, E, _mask); + createRANSACPointSetRegistrator(makePtr(), 5, threshold, prob)->run(points1, points2, E, _mask); else - createLMeDSPointSetRegistrator(new EMEstimatorCallback, 5, prob)->run(points1, points2, E, _mask); + createLMeDSPointSetRegistrator(makePtr(), 5, prob)->run(points1, points2, E, _mask); return E; } diff --git a/modules/calib3d/src/fundam.cpp b/modules/calib3d/src/fundam.cpp index 27378c53be..d1c6e8cd0b 100644 --- a/modules/calib3d/src/fundam.cpp +++ b/modules/calib3d/src/fundam.cpp @@ -307,7 +307,7 @@ cv::Mat cv::findHomography( InputArray _points1, InputArray _points2, if( ransacReprojThreshold <= 0 ) ransacReprojThreshold = defaultRANSACReprojThreshold; - Ptr cb = new HomographyEstimatorCallback; + Ptr cb = makePtr(); if( method == 0 || npoints == 4 ) { @@ -334,7 +334,7 @@ cv::Mat cv::findHomography( InputArray _points1, InputArray _points2, if( method == RANSAC || method == LMEDS ) cb->runKernel( src, dst, H ); Mat H8(8, 1, CV_64F, H.ptr()); - createLMSolver(new HomographyRefineCallback(src, dst), 10)->run(H8); + createLMSolver(makePtr(src, dst), 10)->run(H8); } } @@ -686,7 +686,7 @@ cv::Mat cv::findFundamentalMat( InputArray _points1, InputArray _points2, if( npoints < 7 ) return Mat(); - Ptr cb = new FMEstimatorCallback; + Ptr cb = makePtr(); int result; if( npoints == 7 || method == FM_8POINT ) diff --git a/modules/calib3d/src/levmarq.cpp b/modules/calib3d/src/levmarq.cpp index 31b96d098b..55704132cf 100644 --- a/modules/calib3d/src/levmarq.cpp +++ b/modules/calib3d/src/levmarq.cpp @@ -95,7 +95,7 @@ public: int ptype = param0.type(); CV_Assert( (param0.cols == 1 || param0.rows == 1) && (ptype == CV_32F || ptype == CV_64F)); - CV_Assert( !cb.empty() ); + CV_Assert( cb ); int lx = param0.rows + param0.cols - 1; param0.convertTo(x, CV_64F); @@ -220,7 +220,7 @@ CV_INIT_ALGORITHM(LMSolverImpl, "LMSolver", Ptr createLMSolver(const Ptr& cb, int maxIters) { CV_Assert( !LMSolverImpl_info_auto.name().empty() ); - return new LMSolverImpl(cb, maxIters); + return makePtr(cb, maxIters); } } diff --git a/modules/calib3d/src/ptsetreg.cpp b/modules/calib3d/src/ptsetreg.cpp index da2da56c7a..aa361a9118 100644 --- a/modules/calib3d/src/ptsetreg.cpp +++ b/modules/calib3d/src/ptsetreg.cpp @@ -171,7 +171,7 @@ public: RNG rng((uint64)-1); - CV_Assert( !cb.empty() ); + CV_Assert( cb ); CV_Assert( confidence > 0 && confidence < 1 ); CV_Assert( count >= 0 && count2 == count ); @@ -288,7 +288,7 @@ public: RNG rng((uint64)-1); - CV_Assert( !cb.empty() ); + CV_Assert( cb ); CV_Assert( confidence > 0 && confidence < 1 ); CV_Assert( count >= 0 && count2 == count ); @@ -397,7 +397,8 @@ Ptr createRANSACPointSetRegistrator(const Ptr( + new RANSACPointSetRegistrator(_cb, _modelPoints, _threshold, _confidence, _maxIters)); } @@ -405,7 +406,8 @@ Ptr createLMeDSPointSetRegistrator(const Ptr( + new LMeDSPointSetRegistrator(_cb, _modelPoints, _confidence, _maxIters)); } class Affine3DEstimatorCallback : public PointSetRegistrator::Callback @@ -532,5 +534,5 @@ int cv::estimateAffine3D(InputArray _from, InputArray _to, param1 = param1 <= 0 ? 3 : param1; param2 = (param2 < epsilon) ? 0.99 : (param2 > 1 - epsilon) ? 0.99 : param2; - return createRANSACPointSetRegistrator(new Affine3DEstimatorCallback, 4, param1, param2)->run(dFrom, dTo, _out, _inliers); + return createRANSACPointSetRegistrator(makePtr(), 4, param1, param2)->run(dFrom, dTo, _out, _inliers); } diff --git a/modules/calib3d/src/stereobm.cpp b/modules/calib3d/src/stereobm.cpp index 1fc193a0a9..ee131db76d 100644 --- a/modules/calib3d/src/stereobm.cpp +++ b/modules/calib3d/src/stereobm.cpp @@ -991,7 +991,7 @@ const char* StereoBMImpl::name_ = "StereoMatcher.BM"; cv::Ptr cv::createStereoBM(int _numDisparities, int _SADWindowSize) { - return new StereoBMImpl(_numDisparities, _SADWindowSize); + return makePtr(_numDisparities, _SADWindowSize); } /* End of file. */ diff --git a/modules/calib3d/src/stereosgbm.cpp b/modules/calib3d/src/stereosgbm.cpp index 700b70684a..6d75d8f53d 100644 --- a/modules/calib3d/src/stereosgbm.cpp +++ b/modules/calib3d/src/stereosgbm.cpp @@ -947,11 +947,12 @@ Ptr createStereoSGBM(int minDisparity, int numDisparities, int SADWi int speckleWindowSize, int speckleRange, int mode) { - return new StereoSGBMImpl(minDisparity, numDisparities, SADWindowSize, - P1, P2, disp12MaxDiff, - preFilterCap, uniquenessRatio, - speckleWindowSize, speckleRange, - mode); + return Ptr( + new StereoSGBMImpl(minDisparity, numDisparities, SADWindowSize, + P1, P2, disp12MaxDiff, + preFilterCap, uniquenessRatio, + speckleWindowSize, speckleRange, + mode)); } Rect getValidDisparityROI( Rect roi1, Rect roi2, diff --git a/modules/calib3d/src/triangulate.cpp b/modules/calib3d/src/triangulate.cpp index 59c7c0f2be..b0af3dc466 100644 --- a/modules/calib3d/src/triangulate.cpp +++ b/modules/calib3d/src/triangulate.cpp @@ -240,32 +240,32 @@ cvCorrectMatches(CvMat *F_, CvMat *points1_, CvMat *points2_, CvMat *new_points1 } // Make sure F uses double precision - F = cvCreateMat(3,3,CV_64FC1); + F.reset(cvCreateMat(3,3,CV_64FC1)); cvConvert(F_, F); // Make sure points1 uses double precision - points1 = cvCreateMat(points1_->rows,points1_->cols,CV_64FC2); + points1.reset(cvCreateMat(points1_->rows,points1_->cols,CV_64FC2)); cvConvert(points1_, points1); // Make sure points2 uses double precision - points2 = cvCreateMat(points2_->rows,points2_->cols,CV_64FC2); + points2.reset(cvCreateMat(points2_->rows,points2_->cols,CV_64FC2)); cvConvert(points2_, points2); - tmp33 = cvCreateMat(3,3,CV_64FC1); - tmp31 = cvCreateMat(3,1,CV_64FC1), tmp31_2 = cvCreateMat(3,1,CV_64FC1); - T1i = cvCreateMat(3,3,CV_64FC1), T2i = cvCreateMat(3,3,CV_64FC1); - R1 = cvCreateMat(3,3,CV_64FC1), R2 = cvCreateMat(3,3,CV_64FC1); - TFT = cvCreateMat(3,3,CV_64FC1), TFTt = cvCreateMat(3,3,CV_64FC1), RTFTR = cvCreateMat(3,3,CV_64FC1); - U = cvCreateMat(3,3,CV_64FC1); - S = cvCreateMat(3,3,CV_64FC1); - V = cvCreateMat(3,3,CV_64FC1); - e1 = cvCreateMat(3,1,CV_64FC1), e2 = cvCreateMat(3,1,CV_64FC1); + tmp33.reset(cvCreateMat(3,3,CV_64FC1)); + tmp31.reset(cvCreateMat(3,1,CV_64FC1)), tmp31_2.reset(cvCreateMat(3,1,CV_64FC1)); + T1i.reset(cvCreateMat(3,3,CV_64FC1)), T2i.reset(cvCreateMat(3,3,CV_64FC1)); + R1.reset(cvCreateMat(3,3,CV_64FC1)), R2.reset(cvCreateMat(3,3,CV_64FC1)); + TFT.reset(cvCreateMat(3,3,CV_64FC1)), TFTt.reset(cvCreateMat(3,3,CV_64FC1)), RTFTR.reset(cvCreateMat(3,3,CV_64FC1)); + U.reset(cvCreateMat(3,3,CV_64FC1)); + S.reset(cvCreateMat(3,3,CV_64FC1)); + V.reset(cvCreateMat(3,3,CV_64FC1)); + e1.reset(cvCreateMat(3,1,CV_64FC1)), e2.reset(cvCreateMat(3,1,CV_64FC1)); double x1, y1, x2, y2; double scale; double f1, f2, a, b, c, d; - polynomial = cvCreateMat(1,7,CV_64FC1); - result = cvCreateMat(1,6,CV_64FC2); + polynomial.reset(cvCreateMat(1,7,CV_64FC1)); + result.reset(cvCreateMat(1,6,CV_64FC2)); double t_min, s_val, t, s; for (int p = 0; p < points1->cols; ++p) { // Replace F by T2-t * F * T1-t From 1eacb485c57a6451481abaf1e0b4a12d1d818431 Mon Sep 17 00:00:00 2001 From: Roman Donchenko Date: Tue, 13 Aug 2013 17:30:14 +0400 Subject: [PATCH 08/55] Boring changes - features2d. --- .../features2d/include/opencv2/features2d.hpp | 6 +-- modules/features2d/src/brisk.cpp | 4 +- modules/features2d/src/descriptors.cpp | 6 +-- modules/features2d/src/detectors.cpp | 10 ++--- modules/features2d/src/dynamic.cpp | 14 +++--- modules/features2d/src/evaluation.cpp | 4 +- modules/features2d/src/matchers.cpp | 44 +++++++++---------- .../test/test_descriptors_regression.cpp | 6 +-- .../test/test_detectors_regression.cpp | 2 +- modules/features2d/test/test_keypoints.cpp | 2 +- .../test_rotation_and_scale_invariance.cpp | 12 ++--- 11 files changed, 55 insertions(+), 55 deletions(-) diff --git a/modules/features2d/include/opencv2/features2d.hpp b/modules/features2d/include/opencv2/features2d.hpp index 4e3f3b80a6..af687e3085 100644 --- a/modules/features2d/include/opencv2/features2d.hpp +++ b/modules/features2d/include/opencv2/features2d.hpp @@ -646,7 +646,7 @@ public: * gridRows Grid rows count. * gridCols Grid column count. */ - CV_WRAP GridAdaptedFeatureDetector( const Ptr& detector=0, + CV_WRAP GridAdaptedFeatureDetector( const Ptr& detector=Ptr(), int maxTotalKeypoints=1000, int gridRows=4, int gridCols=4 ); @@ -1143,8 +1143,8 @@ protected: class CV_EXPORTS_W FlannBasedMatcher : public DescriptorMatcher { public: - CV_WRAP FlannBasedMatcher( const Ptr& indexParams=new flann::KDTreeIndexParams(), - const Ptr& searchParams=new flann::SearchParams() ); + CV_WRAP FlannBasedMatcher( const Ptr& indexParams=makePtr(), + const Ptr& searchParams=makePtr() ); virtual void add( const std::vector& descriptors ); virtual void clear(); diff --git a/modules/features2d/src/brisk.cpp b/modules/features2d/src/brisk.cpp index 9e017d5253..76bded666b 100644 --- a/modules/features2d/src/brisk.cpp +++ b/modules/features2d/src/brisk.cpp @@ -2003,7 +2003,7 @@ BriskLayer::BriskLayer(const cv::Mat& img_in, float scale_in, float offset_in) scale_ = scale_in; offset_ = offset_in; // create an agast detector - fast_9_16_ = new FastFeatureDetector(1, true, FastFeatureDetector::TYPE_9_16); + fast_9_16_ = makePtr(1, true, FastFeatureDetector::TYPE_9_16); makeOffsets(pixel_5_8_, (int)img_.step, 8); makeOffsets(pixel_9_16_, (int)img_.step, 16); } @@ -2025,7 +2025,7 @@ BriskLayer::BriskLayer(const BriskLayer& layer, int mode) offset_ = 0.5f * scale_ - 0.5f; } scores_ = cv::Mat::zeros(img_.rows, img_.cols, CV_8U); - fast_9_16_ = new FastFeatureDetector(1, false, FastFeatureDetector::TYPE_9_16); + fast_9_16_ = makePtr(1, false, FastFeatureDetector::TYPE_9_16); makeOffsets(pixel_5_8_, (int)img_.step, 8); makeOffsets(pixel_9_16_, (int)img_.step, 16); } diff --git a/modules/features2d/src/descriptors.cpp b/modules/features2d/src/descriptors.cpp index 4f434032ec..b79768ae15 100644 --- a/modules/features2d/src/descriptors.cpp +++ b/modules/features2d/src/descriptors.cpp @@ -99,7 +99,7 @@ Ptr DescriptorExtractor::create(const String& descriptorExt { size_t pos = String("Opponent").size(); String type = descriptorExtractorType.substr(pos); - return new OpponentColorDescriptorExtractor(DescriptorExtractor::create(type)); + return makePtr(DescriptorExtractor::create(type)); } return Algorithm::create("Feature2D." + descriptorExtractorType); @@ -119,7 +119,7 @@ CV_WRAP void Feature2D::compute( const Mat& image, CV_OUT CV_IN_OUT std::vector< OpponentColorDescriptorExtractor::OpponentColorDescriptorExtractor( const Ptr& _descriptorExtractor ) : descriptorExtractor(_descriptorExtractor) { - CV_Assert( !descriptorExtractor.empty() ); + CV_Assert( descriptorExtractor ); } static void convertBGRImageToOpponentColorSpace( const Mat& bgrImage, std::vector& opponentChannels ) @@ -249,7 +249,7 @@ int OpponentColorDescriptorExtractor::descriptorType() const bool OpponentColorDescriptorExtractor::empty() const { - return descriptorExtractor.empty() || (DescriptorExtractor*)(descriptorExtractor)->empty(); + return !descriptorExtractor || descriptorExtractor->empty(); } } diff --git a/modules/features2d/src/detectors.cpp b/modules/features2d/src/detectors.cpp index c20d573552..63a882dd3f 100644 --- a/modules/features2d/src/detectors.cpp +++ b/modules/features2d/src/detectors.cpp @@ -90,19 +90,19 @@ Ptr FeatureDetector::create( const String& detectorType ) { if( detectorType.find("Grid") == 0 ) { - return new GridAdaptedFeatureDetector(FeatureDetector::create( + return makePtr(FeatureDetector::create( detectorType.substr(strlen("Grid")))); } if( detectorType.find("Pyramid") == 0 ) { - return new PyramidAdaptedFeatureDetector(FeatureDetector::create( + return makePtr(FeatureDetector::create( detectorType.substr(strlen("Pyramid")))); } if( detectorType.find("Dynamic") == 0 ) { - return new DynamicAdaptedFeatureDetector(AdjusterAdapter::create( + return makePtr(AdjusterAdapter::create( detectorType.substr(strlen("Dynamic")))); } @@ -190,7 +190,7 @@ GridAdaptedFeatureDetector::GridAdaptedFeatureDetector( const Ptrempty(); + return !detector || detector->empty(); } struct ResponseComparator @@ -295,7 +295,7 @@ PyramidAdaptedFeatureDetector::PyramidAdaptedFeatureDetector( const Ptrempty(); + return !detector || detector->empty(); } void PyramidAdaptedFeatureDetector::detectImpl( const Mat& image, std::vector& keypoints, const Mat& mask ) const diff --git a/modules/features2d/src/dynamic.cpp b/modules/features2d/src/dynamic.cpp index d08434da46..6bd6ab4de8 100644 --- a/modules/features2d/src/dynamic.cpp +++ b/modules/features2d/src/dynamic.cpp @@ -51,7 +51,7 @@ DynamicAdaptedFeatureDetector::DynamicAdaptedFeatureDetector(const Ptrempty(); + return !adjuster_ || adjuster_->empty(); } void DynamicAdaptedFeatureDetector::detectImpl(const Mat& image, std::vector& keypoints, const Mat& mask) const @@ -124,7 +124,7 @@ bool FastAdjuster::good() const Ptr FastAdjuster::clone() const { - Ptr cloned_obj = new FastAdjuster( init_thresh_, nonmax_, min_thresh_, max_thresh_ ); + Ptr cloned_obj(new FastAdjuster( init_thresh_, nonmax_, min_thresh_, max_thresh_ )); return cloned_obj; } @@ -158,7 +158,7 @@ bool StarAdjuster::good() const Ptr StarAdjuster::clone() const { - Ptr cloned_obj = new StarAdjuster( init_thresh_, min_thresh_, max_thresh_ ); + Ptr cloned_obj(new StarAdjuster( init_thresh_, min_thresh_, max_thresh_ )); return cloned_obj; } @@ -195,7 +195,7 @@ bool SurfAdjuster::good() const Ptr SurfAdjuster::clone() const { - Ptr cloned_obj = new SurfAdjuster( init_thresh_, min_thresh_, max_thresh_ ); + Ptr cloned_obj(new SurfAdjuster( init_thresh_, min_thresh_, max_thresh_ )); return cloned_obj; } @@ -205,15 +205,15 @@ Ptr AdjusterAdapter::create( const String& detectorType ) if( !detectorType.compare( "FAST" ) ) { - adapter = new FastAdjuster(); + adapter = makePtr(); } else if( !detectorType.compare( "STAR" ) ) { - adapter = new StarAdjuster(); + adapter = makePtr(); } else if( !detectorType.compare( "SURF" ) ) { - adapter = new SurfAdjuster(); + adapter = makePtr(); } return adapter; diff --git a/modules/features2d/src/evaluation.cpp b/modules/features2d/src/evaluation.cpp index 369ba44c91..5bde951d60 100644 --- a/modules/features2d/src/evaluation.cpp +++ b/modules/features2d/src/evaluation.cpp @@ -461,7 +461,7 @@ void cv::evaluateFeatureDetector( const Mat& img1, const Mat& img2, const Mat& H keypoints1 = _keypoints1 != 0 ? _keypoints1 : &buf1; keypoints2 = _keypoints2 != 0 ? _keypoints2 : &buf2; - if( (keypoints1->empty() || keypoints2->empty()) && fdetector.empty() ) + if( (keypoints1->empty() || keypoints2->empty()) && !fdetector ) CV_Error( Error::StsBadArg, "fdetector must not be empty when keypoints1 or keypoints2 is empty" ); if( keypoints1->empty() ) @@ -575,7 +575,7 @@ void cv::evaluateGenericDescriptorMatcher( const Mat& img1, const Mat& img2, con if( keypoints1.empty() ) CV_Error( Error::StsBadArg, "keypoints1 must not be empty" ); - if( matches1to2->empty() && dmatcher.empty() ) + if( matches1to2->empty() && !dmatcher ) CV_Error( Error::StsBadArg, "dmatch must not be empty when matches1to2 is empty" ); bool computeKeypoints2ByPrj = keypoints2.empty(); diff --git a/modules/features2d/src/matchers.cpp b/modules/features2d/src/matchers.cpp index 54da1833e4..087c6a78bd 100644 --- a/modules/features2d/src/matchers.cpp +++ b/modules/features2d/src/matchers.cpp @@ -326,7 +326,7 @@ BFMatcher::BFMatcher( int _normType, bool _crossCheck ) Ptr BFMatcher::clone( bool emptyTrainData ) const { - BFMatcher* matcher = new BFMatcher(normType, crossCheck); + Ptr matcher = makePtr(normType, crossCheck); if( !emptyTrainData ) { matcher->trainDescCollection.resize(trainDescCollection.size()); @@ -458,31 +458,31 @@ void BFMatcher::radiusMatchImpl( const Mat& queryDescriptors, std::vector DescriptorMatcher::create( const String& descriptorMatcherType ) { - DescriptorMatcher* dm = 0; + Ptr dm; if( !descriptorMatcherType.compare( "FlannBased" ) ) { - dm = new FlannBasedMatcher(); + dm = makePtr(); } else if( !descriptorMatcherType.compare( "BruteForce" ) ) // L2 { - dm = new BFMatcher(NORM_L2); + dm = makePtr(int(NORM_L2)); // anonymous enums can't be template parameters } else if( !descriptorMatcherType.compare( "BruteForce-SL2" ) ) // Squared L2 { - dm = new BFMatcher(NORM_L2SQR); + dm = makePtr(int(NORM_L2SQR)); } else if( !descriptorMatcherType.compare( "BruteForce-L1" ) ) { - dm = new BFMatcher(NORM_L1); + dm = makePtr(int(NORM_L1)); } else if( !descriptorMatcherType.compare("BruteForce-Hamming") || !descriptorMatcherType.compare("BruteForce-HammingLUT") ) { - dm = new BFMatcher(NORM_HAMMING); + dm = makePtr(int(NORM_HAMMING)); } else if( !descriptorMatcherType.compare("BruteForce-Hamming(2)") ) { - dm = new BFMatcher(NORM_HAMMING2); + dm = makePtr(int(NORM_HAMMING2)); } else CV_Error( Error::StsBadArg, "Unknown matcher name" ); @@ -497,8 +497,8 @@ Ptr DescriptorMatcher::create( const String& descriptorMatche FlannBasedMatcher::FlannBasedMatcher( const Ptr& _indexParams, const Ptr& _searchParams ) : indexParams(_indexParams), searchParams(_searchParams), addedDescCount(0) { - CV_Assert( !_indexParams.empty() ); - CV_Assert( !_searchParams.empty() ); + CV_Assert( _indexParams ); + CV_Assert( _searchParams ); } void FlannBasedMatcher::add( const std::vector& descriptors ) @@ -522,17 +522,17 @@ void FlannBasedMatcher::clear() void FlannBasedMatcher::train() { - if( flannIndex.empty() || mergedDescriptors.size() < addedDescCount ) + if( !flannIndex || mergedDescriptors.size() < addedDescCount ) { mergedDescriptors.set( trainDescCollection ); - flannIndex = new flann::Index( mergedDescriptors.getDescriptors(), *indexParams ); + flannIndex = makePtr( mergedDescriptors.getDescriptors(), *indexParams ); } } void FlannBasedMatcher::read( const FileNode& fn) { - if (indexParams.empty()) - indexParams = new flann::IndexParams(); + if (!indexParams) + indexParams = makePtr(); FileNode ip = fn["indexParams"]; CV_Assert(ip.type() == FileNode::SEQ); @@ -570,8 +570,8 @@ void FlannBasedMatcher::read( const FileNode& fn) }; } - if (searchParams.empty()) - searchParams = new flann::SearchParams(); + if (!searchParams) + searchParams = makePtr(); FileNode sp = fn["searchParams"]; CV_Assert(sp.type() == FileNode::SEQ); @@ -725,7 +725,7 @@ bool FlannBasedMatcher::isMaskSupported() const Ptr FlannBasedMatcher::clone( bool emptyTrainData ) const { - FlannBasedMatcher* matcher = new FlannBasedMatcher(indexParams, searchParams); + Ptr matcher = makePtr(indexParams, searchParams); if( !emptyTrainData ) { CV_Error( Error::StsNotImplemented, "deep clone functionality is not implemented, because " @@ -1066,7 +1066,7 @@ Ptr GenericDescriptorMatcher::create( const String& ge Ptr descriptorMatcher = Algorithm::create("DescriptorMatcher." + genericDescritptorMatcherType); - if( !paramsFilename.empty() && !descriptorMatcher.empty() ) + if( !paramsFilename.empty() && descriptorMatcher ) { FileStorage fs = FileStorage( paramsFilename, FileStorage::READ ); if( fs.isOpened() ) @@ -1086,7 +1086,7 @@ VectorDescriptorMatcher::VectorDescriptorMatcher( const Ptr const Ptr& _matcher ) : extractor( _extractor ), matcher( _matcher ) { - CV_Assert( !extractor.empty() && !matcher.empty() ); + CV_Assert( extractor && matcher ); } VectorDescriptorMatcher::~VectorDescriptorMatcher() @@ -1152,14 +1152,14 @@ void VectorDescriptorMatcher::write (FileStorage& fs) const bool VectorDescriptorMatcher::empty() const { - return extractor.empty() || extractor->empty() || - matcher.empty() || matcher->empty(); + return !extractor || extractor->empty() || + !matcher || matcher->empty(); } Ptr VectorDescriptorMatcher::clone( bool emptyTrainData ) const { // TODO clone extractor - return new VectorDescriptorMatcher( extractor, matcher->clone(emptyTrainData) ); + return makePtr( extractor, matcher->clone(emptyTrainData) ); } } diff --git a/modules/features2d/test/test_descriptors_regression.cpp b/modules/features2d/test/test_descriptors_regression.cpp index 548e818840..08eb59eae2 100644 --- a/modules/features2d/test/test_descriptors_regression.cpp +++ b/modules/features2d/test/test_descriptors_regression.cpp @@ -141,7 +141,7 @@ protected: void emptyDataTest() { - assert( !dextractor.empty() ); + assert( dextractor ); // One image. Mat image; @@ -186,7 +186,7 @@ protected: void regressionTest() { - assert( !dextractor.empty() ); + assert( dextractor ); // Read the test image. string imgFilename = string(ts->get_data_path()) + FEATURES2D_DIR + "/" + IMAGE_FILENAME; @@ -267,7 +267,7 @@ protected: void run(int) { createDescriptorExtractor(); - if( dextractor.empty() ) + if( !dextractor ) { ts->printf(cvtest::TS::LOG, "Descriptor extractor is empty.\n"); ts->set_failed_test_info( cvtest::TS::FAIL_INVALID_TEST_DATA ); diff --git a/modules/features2d/test/test_detectors_regression.cpp b/modules/features2d/test/test_detectors_regression.cpp index 9a88c42f7b..8f34913a9a 100644 --- a/modules/features2d/test/test_detectors_regression.cpp +++ b/modules/features2d/test/test_detectors_regression.cpp @@ -230,7 +230,7 @@ void CV_FeatureDetectorTest::regressionTest() void CV_FeatureDetectorTest::run( int /*start_from*/ ) { - if( fdetector.empty() ) + if( !fdetector ) { ts->printf( cvtest::TS::LOG, "Feature detector is empty.\n" ); ts->set_failed_test_info( cvtest::TS::FAIL_INVALID_TEST_DATA ); diff --git a/modules/features2d/test/test_keypoints.cpp b/modules/features2d/test/test_keypoints.cpp index c689cd3722..e15d4fa17f 100644 --- a/modules/features2d/test/test_keypoints.cpp +++ b/modules/features2d/test/test_keypoints.cpp @@ -62,7 +62,7 @@ protected: virtual void run(int) { cv::initModule_features2d(); - CV_Assert(!detector.empty()); + CV_Assert(detector); string imgFilename = string(ts->get_data_path()) + FEATURES2D_DIR + "/" + IMAGE_FILENAME; // Read the test image. diff --git a/modules/features2d/test/test_rotation_and_scale_invariance.cpp b/modules/features2d/test/test_rotation_and_scale_invariance.cpp index dd0e48e7d3..adfe42804b 100644 --- a/modules/features2d/test/test_rotation_and_scale_invariance.cpp +++ b/modules/features2d/test/test_rotation_and_scale_invariance.cpp @@ -196,7 +196,7 @@ public: minKeyPointMatchesRatio(_minKeyPointMatchesRatio), minAngleInliersRatio(_minAngleInliersRatio) { - CV_Assert(!featureDetector.empty()); + CV_Assert(featureDetector); } protected: @@ -307,8 +307,8 @@ public: normType(_normType), minDescInliersRatio(_minDescInliersRatio) { - CV_Assert(!featureDetector.empty()); - CV_Assert(!descriptorExtractor.empty()); + CV_Assert(featureDetector); + CV_Assert(descriptorExtractor); } protected: @@ -392,7 +392,7 @@ public: minKeyPointMatchesRatio(_minKeyPointMatchesRatio), minScaleInliersRatio(_minScaleInliersRatio) { - CV_Assert(!featureDetector.empty()); + CV_Assert(featureDetector); } protected: @@ -510,8 +510,8 @@ public: normType(_normType), minDescInliersRatio(_minDescInliersRatio) { - CV_Assert(!featureDetector.empty()); - CV_Assert(!descriptorExtractor.empty()); + CV_Assert(featureDetector); + CV_Assert(descriptorExtractor); } protected: From 345bc633cc96e0fc650aadd27ecb77f469e9f02e Mon Sep 17 00:00:00 2001 From: Roman Donchenko Date: Tue, 13 Aug 2013 17:35:25 +0400 Subject: [PATCH 09/55] Boring changes - ml. --- modules/ml/include/opencv2/ml.hpp | 2 +- modules/ml/src/rtrees.cpp | 2 +- modules/ml/src/tree.cpp | 22 +++++++++++----------- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/modules/ml/include/opencv2/ml.hpp b/modules/ml/include/opencv2/ml.hpp index 5e7871da3e..2b84d67ca7 100644 --- a/modules/ml/include/opencv2/ml.hpp +++ b/modules/ml/include/opencv2/ml.hpp @@ -2148,7 +2148,7 @@ typedef CvANN_MLP NeuralNet_MLP; typedef CvGBTreesParams GradientBoostingTreeParams; typedef CvGBTrees GradientBoostingTrees; -template<> CV_EXPORTS void Ptr::delete_obj(); +template<> CV_EXPORTS void DefaultDeleter::operator ()(CvDTreeSplit* obj) const; CV_EXPORTS bool initModule_ml(void); } diff --git a/modules/ml/src/rtrees.cpp b/modules/ml/src/rtrees.cpp index fcb1baf6b0..c41b842142 100644 --- a/modules/ml/src/rtrees.cpp +++ b/modules/ml/src/rtrees.cpp @@ -126,7 +126,7 @@ void ForestTreeBestSplitFinder::operator()(const BlockedRange& range) } if( res && bestSplit->quality < split->quality ) - memcpy( (CvDTreeSplit*)bestSplit, (CvDTreeSplit*)split, splitSize ); + memcpy( bestSplit.get(), split.get(), splitSize ); } } } diff --git a/modules/ml/src/tree.cpp b/modules/ml/src/tree.cpp index d195385d71..3a67cdd375 100644 --- a/modules/ml/src/tree.cpp +++ b/modules/ml/src/tree.cpp @@ -1882,7 +1882,7 @@ double CvDTree::calc_node_dir( CvDTreeNode* node ) namespace cv { -template<> CV_EXPORTS void Ptr::delete_obj() +template<> CV_EXPORTS void DefaultDeleter::operator ()(CvDTreeSplit* obj) const { fastFree(obj); } @@ -1893,12 +1893,12 @@ DTreeBestSplitFinder::DTreeBestSplitFinder( CvDTree* _tree, CvDTreeNode* _node) node = _node; splitSize = tree->get_data()->split_heap->elem_size; - bestSplit = (CvDTreeSplit*)fastMalloc(splitSize); - memset((CvDTreeSplit*)bestSplit, 0, splitSize); + bestSplit.reset((CvDTreeSplit*)fastMalloc(splitSize)); + memset(bestSplit.get(), 0, splitSize); bestSplit->quality = -1; bestSplit->condensed_idx = INT_MIN; - split = (CvDTreeSplit*)fastMalloc(splitSize); - memset((CvDTreeSplit*)split, 0, splitSize); + split.reset((CvDTreeSplit*)fastMalloc(splitSize)); + memset(split.get(), 0, splitSize); //haveSplit = false; } @@ -1908,10 +1908,10 @@ DTreeBestSplitFinder::DTreeBestSplitFinder( const DTreeBestSplitFinder& finder, node = finder.node; splitSize = tree->get_data()->split_heap->elem_size; - bestSplit = (CvDTreeSplit*)fastMalloc(splitSize); - memcpy((CvDTreeSplit*)(bestSplit), (const CvDTreeSplit*)finder.bestSplit, splitSize); - split = (CvDTreeSplit*)fastMalloc(splitSize); - memset((CvDTreeSplit*)split, 0, splitSize); + bestSplit.reset((CvDTreeSplit*)fastMalloc(splitSize)); + memcpy(bestSplit.get(), finder.bestSplit.get(), splitSize); + split.reset((CvDTreeSplit*)fastMalloc(splitSize)); + memset(split.get(), 0, splitSize); } void DTreeBestSplitFinder::operator()(const BlockedRange& range) @@ -1944,14 +1944,14 @@ void DTreeBestSplitFinder::operator()(const BlockedRange& range) } if( res && bestSplit->quality < split->quality ) - memcpy( (CvDTreeSplit*)bestSplit, (CvDTreeSplit*)split, splitSize ); + memcpy( bestSplit.get(), split.get(), splitSize ); } } void DTreeBestSplitFinder::join( DTreeBestSplitFinder& rhs ) { if( bestSplit->quality < rhs.bestSplit->quality ) - memcpy( (CvDTreeSplit*)bestSplit, (CvDTreeSplit*)rhs.bestSplit, splitSize ); + memcpy( bestSplit.get(), rhs.bestSplit.get(), splitSize ); } } From de6a934f669c3d5ba8d5d401b693d0fc12eee395 Mon Sep 17 00:00:00 2001 From: Roman Donchenko Date: Tue, 13 Aug 2013 17:36:38 +0400 Subject: [PATCH 10/55] Boring changes - nonfree. --- modules/nonfree/test/test_features2d.cpp | 8 ++++---- modules/nonfree/test/test_keypoints.cpp | 2 +- .../test/test_rotation_and_scale_invariance.cpp | 12 ++++++------ 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/modules/nonfree/test/test_features2d.cpp b/modules/nonfree/test/test_features2d.cpp index bff8a387f4..7c888e261e 100644 --- a/modules/nonfree/test/test_features2d.cpp +++ b/modules/nonfree/test/test_features2d.cpp @@ -231,7 +231,7 @@ void CV_FeatureDetectorTest::regressionTest() void CV_FeatureDetectorTest::run( int /*start_from*/ ) { - if( fdetector.empty() ) + if( !fdetector ) { ts->printf( cvtest::TS::LOG, "Feature detector is empty.\n" ); ts->set_failed_test_info( cvtest::TS::FAIL_INVALID_TEST_DATA ); @@ -464,7 +464,7 @@ protected: void run(int) { createDescriptorExtractor(); - if( dextractor.empty() ) + if( !dextractor ) { ts->printf(cvtest::TS::LOG, "Descriptor extractor is empty.\n"); ts->set_failed_test_info( cvtest::TS::FAIL_INVALID_TEST_DATA ); @@ -1101,7 +1101,7 @@ protected: void run(int) { Ptr f = Algorithm::create("Feature2D." + fname); - if(f.empty()) + if(!f) return; string path = string(ts->get_data_path()) + "detectors_descriptors_evaluation/planar/"; string imgname1 = path + "box.png"; @@ -1156,7 +1156,7 @@ public: FeatureDetectorUsingMaskTest(const Ptr& featureDetector) : featureDetector_(featureDetector) { - CV_Assert(!featureDetector_.empty()); + CV_Assert(featureDetector_); } protected: diff --git a/modules/nonfree/test/test_keypoints.cpp b/modules/nonfree/test/test_keypoints.cpp index 3984f19d89..b046d7534c 100644 --- a/modules/nonfree/test/test_keypoints.cpp +++ b/modules/nonfree/test/test_keypoints.cpp @@ -62,7 +62,7 @@ protected: virtual void run(int) { cv::initModule_features2d(); - CV_Assert(!detector.empty()); + CV_Assert(detector); string imgFilename = string(ts->get_data_path()) + FEATURES2D_DIR + "/" + IMAGE_FILENAME; // Read the test image. diff --git a/modules/nonfree/test/test_rotation_and_scale_invariance.cpp b/modules/nonfree/test/test_rotation_and_scale_invariance.cpp index b63b8b7489..47efc60eb8 100644 --- a/modules/nonfree/test/test_rotation_and_scale_invariance.cpp +++ b/modules/nonfree/test/test_rotation_and_scale_invariance.cpp @@ -210,7 +210,7 @@ public: minKeyPointMatchesRatio(_minKeyPointMatchesRatio), minAngleInliersRatio(_minAngleInliersRatio) { - CV_Assert(!featureDetector.empty()); + CV_Assert(featureDetector); } protected: @@ -323,8 +323,8 @@ public: normType(_normType), minDescInliersRatio(_minDescInliersRatio) { - CV_Assert(!featureDetector.empty()); - CV_Assert(!descriptorExtractor.empty()); + CV_Assert(featureDetector); + CV_Assert(descriptorExtractor); } protected: @@ -410,7 +410,7 @@ public: minKeyPointMatchesRatio(_minKeyPointMatchesRatio), minScaleInliersRatio(_minScaleInliersRatio) { - CV_Assert(!featureDetector.empty()); + CV_Assert(featureDetector); } protected: @@ -530,8 +530,8 @@ public: normType(_normType), minDescInliersRatio(_minDescInliersRatio) { - CV_Assert(!featureDetector.empty()); - CV_Assert(!descriptorExtractor.empty()); + CV_Assert(featureDetector); + CV_Assert(descriptorExtractor); } protected: From b12894d95a409a690c156013f1d658edb57f45f9 Mon Sep 17 00:00:00 2001 From: Roman Donchenko Date: Tue, 13 Aug 2013 17:45:29 +0400 Subject: [PATCH 11/55] Boring changes - objdetect. --- .../objdetect/include/opencv2/objdetect.hpp | 2 +- .../include/opencv2/objdetect/erfilter.hpp | 4 ++-- modules/objdetect/src/cascadedetect.cpp | 24 +++++++++---------- modules/objdetect/src/erfilter.cpp | 9 ++++--- modules/objdetect/src/haar.cpp | 12 +++++----- modules/objdetect/src/linemod.cpp | 22 ++++++++--------- modules/objdetect/test/test_cascadeandhog.cpp | 6 ++--- 7 files changed, 39 insertions(+), 40 deletions(-) diff --git a/modules/objdetect/include/opencv2/objdetect.hpp b/modules/objdetect/include/opencv2/objdetect.hpp index febd3aed57..f1b371610d 100644 --- a/modules/objdetect/include/opencv2/objdetect.hpp +++ b/modules/objdetect/include/opencv2/objdetect.hpp @@ -141,7 +141,7 @@ public: static Ptr create(int type); }; -template<> CV_EXPORTS void Ptr::delete_obj(); +template<> CV_EXPORTS void DefaultDeleter::operator ()(CvHaarClassifierCascade* obj) const; enum { CASCADE_DO_CANNY_PRUNING = 1, CASCADE_SCALE_IMAGE = 2, diff --git a/modules/objdetect/include/opencv2/objdetect/erfilter.hpp b/modules/objdetect/include/opencv2/objdetect/erfilter.hpp index d1bfeaed0f..8a1b580c3a 100644 --- a/modules/objdetect/include/opencv2/objdetect/erfilter.hpp +++ b/modules/objdetect/include/opencv2/objdetect/erfilter.hpp @@ -171,7 +171,7 @@ public: \param nonMaxSuppression Whenever non-maximum suppression is done over the branch probabilities \param minProbability The minimum probability difference between local maxima and local minima ERs */ -CV_EXPORTS Ptr createERFilterNM1(const Ptr& cb = NULL, +CV_EXPORTS Ptr createERFilterNM1(const Ptr& cb = Ptr(), int thresholdDelta = 1, float minArea = 0.000025, float maxArea = 0.13, float minProbability = 0.2, bool nonMaxSuppression = true, @@ -190,7 +190,7 @@ CV_EXPORTS Ptr createERFilterNM1(const Ptr& cb = N if omitted tries to load a default classifier from file trained_classifierNM2.xml \param minProbability The minimum probability P(er|character) allowed for retreived ER's */ -CV_EXPORTS Ptr createERFilterNM2(const Ptr& cb = NULL, +CV_EXPORTS Ptr createERFilterNM2(const Ptr& cb = Ptr(), float minProbability = 0.85); } diff --git a/modules/objdetect/src/cascadedetect.cpp b/modules/objdetect/src/cascadedetect.cpp index 04ec41d24b..88f463faa0 100644 --- a/modules/objdetect/src/cascadedetect.cpp +++ b/modules/objdetect/src/cascadedetect.cpp @@ -467,7 +467,7 @@ bool HaarEvaluator::Feature :: read( const FileNode& node ) HaarEvaluator::HaarEvaluator() { - features = new std::vector(); + features = makePtr >(); } HaarEvaluator::~HaarEvaluator() { @@ -492,7 +492,7 @@ bool HaarEvaluator::read(const FileNode& node) Ptr HaarEvaluator::clone() const { - HaarEvaluator* ret = new HaarEvaluator; + Ptr ret = makePtr(); ret->origWinSize = origWinSize; ret->features = features; ret->featuresPtr = &(*ret->features)[0]; @@ -582,7 +582,7 @@ bool LBPEvaluator::Feature :: read(const FileNode& node ) LBPEvaluator::LBPEvaluator() { - features = new std::vector(); + features = makePtr >(); } LBPEvaluator::~LBPEvaluator() { @@ -603,7 +603,7 @@ bool LBPEvaluator::read( const FileNode& node ) Ptr LBPEvaluator::clone() const { - LBPEvaluator* ret = new LBPEvaluator; + Ptr ret = makePtr(); ret->origWinSize = origWinSize; ret->features = features; ret->featuresPtr = &(*ret->features)[0]; @@ -662,7 +662,7 @@ bool HOGEvaluator::Feature :: read( const FileNode& node ) HOGEvaluator::HOGEvaluator() { - features = new std::vector(); + features = makePtr >(); } HOGEvaluator::~HOGEvaluator() @@ -684,7 +684,7 @@ bool HOGEvaluator::read( const FileNode& node ) Ptr HOGEvaluator::clone() const { - HOGEvaluator* ret = new HOGEvaluator; + Ptr ret = makePtr(); ret->origWinSize = origWinSize; ret->features = features; ret->featuresPtr = &(*ret->features)[0]; @@ -849,7 +849,7 @@ CascadeClassifier::~CascadeClassifier() bool CascadeClassifier::empty() const { - return oldCascade.empty() && data.stages.empty(); + return !oldCascade && data.stages.empty(); } bool CascadeClassifier::load(const String& filename) @@ -867,13 +867,13 @@ bool CascadeClassifier::load(const String& filename) fs.release(); - oldCascade = Ptr((CvHaarClassifierCascade*)cvLoad(filename.c_str(), 0, 0, 0)); + oldCascade.reset((CvHaarClassifierCascade*)cvLoad(filename.c_str(), 0, 0, 0)); return !oldCascade.empty(); } int CascadeClassifier::runAt( Ptr& evaluator, Point pt, double& weight ) { - CV_Assert( oldCascade.empty() ); + CV_Assert( !oldCascade ); assert( data.featureType == FeatureEvaluator::HAAR || data.featureType == FeatureEvaluator::LBP || @@ -1022,7 +1022,7 @@ bool CascadeClassifier::detectSingleScale( const Mat& image, int stripCount, Siz #endif Mat currentMask; - if (!maskGenerator.empty()) { + if (maskGenerator) { currentMask=maskGenerator->generateMask(image); } @@ -1097,7 +1097,7 @@ void CascadeClassifier::detectMultiScaleNoGrouping( const Mat& image, std::vecto { candidates.clear(); - if (!maskGenerator.empty()) + if (maskGenerator) maskGenerator->initializeMask(image); if( maxObjectSize.height == 0 || maxObjectSize.width == 0 ) @@ -1350,7 +1350,7 @@ bool CascadeClassifier::read(const FileNode& root) return featureEvaluator->read(fn); } -template<> void Ptr::delete_obj() +template<> void DefaultDeleter::operator ()(CvHaarClassifierCascade* obj) const { cvReleaseHaarClassifierCascade(&obj); } } // namespace cv diff --git a/modules/objdetect/src/erfilter.cpp b/modules/objdetect/src/erfilter.cpp index ac8fc70e84..b8e964f5d8 100644 --- a/modules/objdetect/src/erfilter.cpp +++ b/modules/objdetect/src/erfilter.cpp @@ -179,7 +179,6 @@ ERFilterNM::ERFilterNM() minProbabilityDiff = 1.; num_accepted_regions = 0; num_rejected_regions = 0; - classifier = NULL; } // the key method. Takes image on input, vector of ERStat is output for the first stage, @@ -1085,10 +1084,10 @@ Ptr createERFilterNM1(const Ptr& cb, int threshold CV_Assert( (thresholdDelta >= 0) && (thresholdDelta <= 128) ); CV_Assert( (minProbabilityDiff >= 0.) && (minProbabilityDiff <= 1.) ); - Ptr filter = new ERFilterNM(); + Ptr filter = makePtr(); if (cb == NULL) - filter->setCallback(new ERClassifierNM1()); + filter->setCallback(makePtr()); else filter->setCallback(cb); @@ -1119,11 +1118,11 @@ Ptr createERFilterNM2(const Ptr& cb, float minProb CV_Assert( (minProbability >= 0.) && (minProbability <= 1.) ); - Ptr filter = new ERFilterNM(); + Ptr filter = makePtr(); if (cb == NULL) - filter->setCallback(new ERClassifierNM2()); + filter->setCallback(makePtr()); else filter->setCallback(cb); diff --git a/modules/objdetect/src/haar.cpp b/modules/objdetect/src/haar.cpp index 2212b6c67a..cbb60b0917 100644 --- a/modules/objdetect/src/haar.cpp +++ b/modules/objdetect/src/haar.cpp @@ -1536,15 +1536,15 @@ cvHaarDetectObjectsForROC( const CvArr* _img, maxSize.width = img->cols; } - temp = cvCreateMat( img->rows, img->cols, CV_8UC1 ); - sum = cvCreateMat( img->rows + 1, img->cols + 1, CV_32SC1 ); - sqsum = cvCreateMat( img->rows + 1, img->cols + 1, CV_64FC1 ); + temp.reset(cvCreateMat( img->rows, img->cols, CV_8UC1 )); + sum.reset(cvCreateMat( img->rows + 1, img->cols + 1, CV_32SC1 )); + sqsum.reset(cvCreateMat( img->rows + 1, img->cols + 1, CV_64FC1 )); if( !cascade->hid_cascade ) icvCreateHidHaarClassifierCascade(cascade); if( cascade->hid_cascade->has_tilted_features ) - tilted = cvCreateMat( img->rows + 1, img->cols + 1, CV_32SC1 ); + tilted.reset(cvCreateMat( img->rows + 1, img->cols + 1, CV_32SC1 )); result_seq = cvCreateSeq( 0, sizeof(CvSeq), sizeof(CvAvgComp), storage ); @@ -1566,7 +1566,7 @@ cvHaarDetectObjectsForROC( const CvArr* _img, if( use_ipp ) normImg = cvCreateMat( img->rows, img->cols, CV_32FC1 ); #endif - imgSmall = cvCreateMat( img->rows + 1, img->cols + 1, CV_8UC1 ); + imgSmall.reset(cvCreateMat( img->rows + 1, img->cols + 1, CV_8UC1 )); for( factor = 1; ; factor *= scaleFactor ) { @@ -1635,7 +1635,7 @@ cvHaarDetectObjectsForROC( const CvArr* _img, if( doCannyPruning ) { - sumcanny = cvCreateMat( img->rows + 1, img->cols + 1, CV_32SC1 ); + sumcanny.reset(cvCreateMat( img->rows + 1, img->cols + 1, CV_32SC1 )); cvCanny( img, temp, 0, 50, 3 ); cvIntegral( temp, sumcanny ); } diff --git a/modules/objdetect/src/linemod.cpp b/modules/objdetect/src/linemod.cpp index 0fd3433a50..e8fc8e4aac 100644 --- a/modules/objdetect/src/linemod.cpp +++ b/modules/objdetect/src/linemod.cpp @@ -204,11 +204,11 @@ void QuantizedPyramid::selectScatteredFeatures(const std::vector& can Ptr Modality::create(const String& modality_type) { if (modality_type == "ColorGradient") - return new ColorGradient(); + return makePtr(); else if (modality_type == "DepthNormal") - return new DepthNormal(); + return makePtr(); else - return NULL; + return Ptr(); } Ptr Modality::create(const FileNode& fn) @@ -574,7 +574,7 @@ String ColorGradient::name() const Ptr ColorGradient::processImpl(const Mat& src, const Mat& mask) const { - return new ColorGradientPyramid(src, mask, weak_threshold, num_features, strong_threshold); + return makePtr(src, mask, weak_threshold, num_features, strong_threshold); } void ColorGradient::read(const FileNode& fn) @@ -889,8 +889,8 @@ String DepthNormal::name() const Ptr DepthNormal::processImpl(const Mat& src, const Mat& mask) const { - return new DepthNormalPyramid(src, mask, distance_threshold, difference_threshold, - num_features, extract_threshold); + return makePtr(src, mask, distance_threshold, difference_threshold, + num_features, extract_threshold); } void DepthNormal::read(const FileNode& fn) @@ -1828,16 +1828,16 @@ static const int T_DEFAULTS[] = {5, 8}; Ptr getDefaultLINE() { std::vector< Ptr > modalities; - modalities.push_back(new ColorGradient); - return new Detector(modalities, std::vector(T_DEFAULTS, T_DEFAULTS + 2)); + modalities.push_back(makePtr()); + return makePtr(modalities, std::vector(T_DEFAULTS, T_DEFAULTS + 2)); } Ptr getDefaultLINEMOD() { std::vector< Ptr > modalities; - modalities.push_back(new ColorGradient); - modalities.push_back(new DepthNormal); - return new Detector(modalities, std::vector(T_DEFAULTS, T_DEFAULTS + 2)); + modalities.push_back(makePtr()); + modalities.push_back(makePtr()); + return makePtr(modalities, std::vector(T_DEFAULTS, T_DEFAULTS + 2)); } } // namespace linemod diff --git a/modules/objdetect/test/test_cascadeandhog.cpp b/modules/objdetect/test/test_cascadeandhog.cpp index b4fd541a18..a301099058 100644 --- a/modules/objdetect/test/test_cascadeandhog.cpp +++ b/modules/objdetect/test/test_cascadeandhog.cpp @@ -426,10 +426,10 @@ 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(); + Ptr c_cascade(cvLoadHaarClassifierCascade(filename.c_str(), cvSize(0,0))); + Ptr storage(cvCreateMemStorage()); - if( c_cascade.empty() ) + if( !c_cascade ) { ts->printf( cvtest::TS::LOG, "cascade %s can not be opened"); return cvtest::TS::FAIL_INVALID_TEST_DATA; From 32205d3c5bf23e245a34272065acd05e66c052db Mon Sep 17 00:00:00 2001 From: Roman Donchenko Date: Tue, 13 Aug 2013 17:46:40 +0400 Subject: [PATCH 12/55] Boring changes - photo. --- modules/photo/src/inpaint.cpp | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/modules/photo/src/inpaint.cpp b/modules/photo/src/inpaint.cpp index ec91e3c1bf..f91db5f545 100644 --- a/modules/photo/src/inpaint.cpp +++ b/modules/photo/src/inpaint.cpp @@ -718,7 +718,7 @@ icvNSInpaintFMM(const CvMat *f, CvMat *t, CvMat *out, int range, CvPriorityQueue } namespace cv { -template<> void cv::Ptr::delete_obj() +template<> void cv::DefaultDeleter::operator ()(IplConvKernel* obj) const { cvReleaseStructuringElement(&obj); } @@ -759,11 +759,11 @@ cvInpaint( const CvArr* _input_img, const CvArr* _inpaint_mask, CvArr* _output_i ecols = input_img->cols + 2; erows = input_img->rows + 2; - f = cvCreateMat(erows, ecols, CV_8UC1); - t = cvCreateMat(erows, ecols, CV_32FC1); - band = cvCreateMat(erows, ecols, CV_8UC1); - mask = cvCreateMat(erows, ecols, CV_8UC1); - el_cross = cvCreateStructuringElementEx(3,3,1,1,CV_SHAPE_CROSS,NULL); + f.reset(cvCreateMat(erows, ecols, CV_8UC1)); + t.reset(cvCreateMat(erows, ecols, CV_32FC1)); + band.reset(cvCreateMat(erows, ecols, CV_8UC1)); + mask.reset(cvCreateMat(erows, ecols, CV_8UC1)); + el_cross.reset(cvCreateStructuringElementEx(3,3,1,1,CV_SHAPE_CROSS,NULL)); cvCopy( input_img, output_img ); cvSet(mask,cvScalar(KNOWN,0,0,0)); @@ -772,7 +772,7 @@ cvInpaint( const CvArr* _input_img, const CvArr* _inpaint_mask, CvArr* _output_i cvSet(f,cvScalar(KNOWN,0,0,0)); cvSet(t,cvScalar(1.0e6f,0,0,0)); cvDilate(mask,band,el_cross,1); // image with narrow band - Heap=new CvPriorityQueueFloat; + Heap=cv::makePtr(); if (!Heap->Init(band)) return; cvSub(band,mask,band,NULL); @@ -785,12 +785,12 @@ cvInpaint( const CvArr* _input_img, const CvArr* _inpaint_mask, CvArr* _output_i if( flags == cv::INPAINT_TELEA ) { - out = cvCreateMat(erows, ecols, CV_8UC1); - el_range = cvCreateStructuringElementEx(2*range+1,2*range+1, - range,range,CV_SHAPE_RECT,NULL); + out.reset(cvCreateMat(erows, ecols, CV_8UC1)); + el_range.reset(cvCreateStructuringElementEx(2*range+1,2*range+1, + range,range,CV_SHAPE_RECT,NULL)); cvDilate(mask,out,el_range,1); cvSub(out,mask,out,NULL); - Out=new CvPriorityQueueFloat; + Out=cv::makePtr(); if (!Out->Init(out)) return; if (!Out->Add(band)) From cce0f48d3eeabf82dc4a8ec0b997a833e2feafc7 Mon Sep 17 00:00:00 2001 From: Roman Donchenko Date: Tue, 13 Aug 2013 17:48:37 +0400 Subject: [PATCH 13/55] Boring changes - softcascade. --- modules/softcascade/src/detector_cuda.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/softcascade/src/detector_cuda.cpp b/modules/softcascade/src/detector_cuda.cpp index a3a1512e24..ef19fad058 100644 --- a/modules/softcascade/src/detector_cuda.cpp +++ b/modules/softcascade/src/detector_cuda.cpp @@ -58,7 +58,7 @@ cv::softcascade::ChannelsProcessor::ChannelsProcessor() { throw_no_cuda(); } cv::softcascade::ChannelsProcessor::~ChannelsProcessor() { throw_no_cuda(); } cv::Ptr cv::softcascade::ChannelsProcessor::create(const int, const int, const int) -{ throw_no_cuda(); return cv::Ptr(0); } +{ throw_no_cuda(); return cv::Ptr(); } #else @@ -594,7 +594,7 @@ private: cv::Ptr cv::softcascade::ChannelsProcessor::create(const int s, const int b, const int m) { CV_Assert((m && SEPARABLE)); - return cv::Ptr(new SeparablePreprocessor(s, b)); + return makePtr(s, b); } cv::softcascade::ChannelsProcessor::ChannelsProcessor() { } From f21851f0f468c98b6ecb1bdb5a37b7066dbc817a Mon Sep 17 00:00:00 2001 From: Roman Donchenko Date: Tue, 13 Aug 2013 17:54:12 +0400 Subject: [PATCH 14/55] Boring changes - stitching. --- .../include/opencv2/stitching/warpers.hpp | 28 +++++++-------- modules/stitching/perf/perf_stich.cpp | 36 +++++++++---------- modules/stitching/src/blenders.cpp | 8 ++--- modules/stitching/src/exposure_compensate.cpp | 8 ++--- modules/stitching/src/matchers.cpp | 16 ++++----- modules/stitching/src/stitcher.cpp | 24 ++++++------- modules/stitching/test/test_matchers.cpp | 2 +- 7 files changed, 61 insertions(+), 61 deletions(-) diff --git a/modules/stitching/include/opencv2/stitching/warpers.hpp b/modules/stitching/include/opencv2/stitching/warpers.hpp index 9d62d356bc..37cf84b7c2 100644 --- a/modules/stitching/include/opencv2/stitching/warpers.hpp +++ b/modules/stitching/include/opencv2/stitching/warpers.hpp @@ -58,33 +58,33 @@ public: class PlaneWarper : public WarperCreator { public: - Ptr create(float scale) const { return new detail::PlaneWarper(scale); } + Ptr create(float scale) const { return makePtr(scale); } }; class CylindricalWarper: public WarperCreator { public: - Ptr create(float scale) const { return new detail::CylindricalWarper(scale); } + Ptr create(float scale) const { return makePtr(scale); } }; class SphericalWarper: public WarperCreator { public: - Ptr create(float scale) const { return new detail::SphericalWarper(scale); } + Ptr create(float scale) const { return makePtr(scale); } }; class FisheyeWarper : public WarperCreator { public: - Ptr create(float scale) const { return new detail::FisheyeWarper(scale); } + Ptr create(float scale) const { return makePtr(scale); } }; class StereographicWarper: public WarperCreator { public: - Ptr create(float scale) const { return new detail::StereographicWarper(scale); } + Ptr create(float scale) const { return makePtr(scale); } }; class CompressedRectilinearWarper: public WarperCreator @@ -95,7 +95,7 @@ public: { a = A; b = B; } - Ptr create(float scale) const { return new detail::CompressedRectilinearWarper(scale, a, b); } + Ptr create(float scale) const { return makePtr(scale, a, b); } }; class CompressedRectilinearPortraitWarper: public WarperCreator @@ -106,7 +106,7 @@ public: { a = A; b = B; } - Ptr create(float scale) const { return new detail::CompressedRectilinearPortraitWarper(scale, a, b); } + Ptr create(float scale) const { return makePtr(scale, a, b); } }; class PaniniWarper: public WarperCreator @@ -117,7 +117,7 @@ public: { a = A; b = B; } - Ptr create(float scale) const { return new detail::PaniniWarper(scale, a, b); } + Ptr create(float scale) const { return makePtr(scale, a, b); } }; class PaniniPortraitWarper: public WarperCreator @@ -128,19 +128,19 @@ public: { a = A; b = B; } - Ptr create(float scale) const { return new detail::PaniniPortraitWarper(scale, a, b); } + Ptr create(float scale) const { return makePtr(scale, a, b); } }; class MercatorWarper: public WarperCreator { public: - Ptr create(float scale) const { return new detail::MercatorWarper(scale); } + Ptr create(float scale) const { return makePtr(scale); } }; class TransverseMercatorWarper: public WarperCreator { public: - Ptr create(float scale) const { return new detail::TransverseMercatorWarper(scale); } + Ptr create(float scale) const { return makePtr(scale); } }; @@ -149,21 +149,21 @@ public: class PlaneWarperGpu: public WarperCreator { public: - Ptr create(float scale) const { return new detail::PlaneWarperGpu(scale); } + Ptr create(float scale) const { return makePtr(scale); } }; class CylindricalWarperGpu: public WarperCreator { public: - Ptr create(float scale) const { return new detail::CylindricalWarperGpu(scale); } + Ptr create(float scale) const { return makePtr(scale); } }; class SphericalWarperGpu: public WarperCreator { public: - Ptr create(float scale) const { return new detail::SphericalWarperGpu(scale); } + Ptr create(float scale) const { return makePtr(scale); } }; #endif diff --git a/modules/stitching/perf/perf_stich.cpp b/modules/stitching/perf/perf_stich.cpp index e42dea968a..8cf89651fe 100644 --- a/modules/stitching/perf/perf_stich.cpp +++ b/modules/stitching/perf/perf_stich.cpp @@ -34,12 +34,12 @@ PERF_TEST_P(stitch, a123, TEST_DETECTORS) imgs.push_back( imread( getDataPath("stitching/a3.png") ) ); Ptr featuresFinder = GetParam() == "orb" - ? (detail::FeaturesFinder*)new detail::OrbFeaturesFinder() - : (detail::FeaturesFinder*)new detail::SurfFeaturesFinder(); + ? Ptr(new detail::OrbFeaturesFinder()) + : Ptr(new detail::SurfFeaturesFinder()); Ptr featuresMatcher = GetParam() == "orb" - ? new detail::BestOf2NearestMatcher(false, ORB_MATCH_CONFIDENCE) - : new detail::BestOf2NearestMatcher(false, SURF_MATCH_CONFIDENCE); + ? makePtr(false, ORB_MATCH_CONFIDENCE) + : makePtr(false, SURF_MATCH_CONFIDENCE); declare.time(30 * 20).iterations(20); @@ -48,7 +48,7 @@ PERF_TEST_P(stitch, a123, TEST_DETECTORS) Stitcher stitcher = Stitcher::createDefault(); stitcher.setFeaturesFinder(featuresFinder); stitcher.setFeaturesMatcher(featuresMatcher); - stitcher.setWarper(new SphericalWarper()); + stitcher.setWarper(makePtr()); stitcher.setRegistrationResol(WORK_MEGAPIX); startTimer(); @@ -72,12 +72,12 @@ PERF_TEST_P(stitch, b12, TEST_DETECTORS) imgs.push_back( imread( getDataPath("stitching/b2.png") ) ); Ptr featuresFinder = GetParam() == "orb" - ? (detail::FeaturesFinder*)new detail::OrbFeaturesFinder() - : (detail::FeaturesFinder*)new detail::SurfFeaturesFinder(); + ? Ptr(new detail::OrbFeaturesFinder()) + : Ptr(new detail::SurfFeaturesFinder()); Ptr featuresMatcher = GetParam() == "orb" - ? new detail::BestOf2NearestMatcher(false, ORB_MATCH_CONFIDENCE) - : new detail::BestOf2NearestMatcher(false, SURF_MATCH_CONFIDENCE); + ? makePtr(false, ORB_MATCH_CONFIDENCE) + : makePtr(false, SURF_MATCH_CONFIDENCE); declare.time(30 * 20).iterations(20); @@ -86,7 +86,7 @@ PERF_TEST_P(stitch, b12, TEST_DETECTORS) Stitcher stitcher = Stitcher::createDefault(); stitcher.setFeaturesFinder(featuresFinder); stitcher.setFeaturesMatcher(featuresMatcher); - stitcher.setWarper(new SphericalWarper()); + stitcher.setWarper(makePtr()); stitcher.setRegistrationResol(WORK_MEGAPIX); startTimer(); @@ -114,13 +114,13 @@ PERF_TEST_P( match, bestOf2Nearest, TEST_DETECTORS) Ptr matcher; if (GetParam() == "surf") { - finder = new detail::SurfFeaturesFinder(); - matcher = new detail::BestOf2NearestMatcher(false, SURF_MATCH_CONFIDENCE); + finder = makePtr(); + matcher = makePtr(false, SURF_MATCH_CONFIDENCE); } else if (GetParam() == "orb") { - finder = new detail::OrbFeaturesFinder(); - matcher = new detail::BestOf2NearestMatcher(false, ORB_MATCH_CONFIDENCE); + finder = makePtr(); + matcher = makePtr(false, ORB_MATCH_CONFIDENCE); } else { @@ -169,13 +169,13 @@ PERF_TEST_P( matchVector, bestOf2NearestVectorFeatures, testing::Combine( int featuresVectorSize = get<1>(GetParam()); if (detectorName == "surf") { - finder = new detail::SurfFeaturesFinder(); - matcher = new detail::BestOf2NearestMatcher(false, SURF_MATCH_CONFIDENCE); + finder = makePtr(); + matcher = makePtr(false, SURF_MATCH_CONFIDENCE); } else if (detectorName == "orb") { - finder = new detail::OrbFeaturesFinder(); - matcher = new detail::BestOf2NearestMatcher(false, ORB_MATCH_CONFIDENCE); + finder = makePtr(); + matcher = makePtr(false, ORB_MATCH_CONFIDENCE); } else { diff --git a/modules/stitching/src/blenders.cpp b/modules/stitching/src/blenders.cpp index 0043b7348a..254c6a1490 100644 --- a/modules/stitching/src/blenders.cpp +++ b/modules/stitching/src/blenders.cpp @@ -50,13 +50,13 @@ static const float WEIGHT_EPS = 1e-5f; Ptr Blender::createDefault(int type, bool try_gpu) { if (type == NO) - return new Blender(); + return makePtr(); if (type == FEATHER) - return new FeatherBlender(); + return makePtr(); if (type == MULTI_BAND) - return new MultiBandBlender(try_gpu); + return makePtr(try_gpu); CV_Error(Error::StsBadArg, "unsupported blending method"); - return NULL; + return Ptr(); } diff --git a/modules/stitching/src/exposure_compensate.cpp b/modules/stitching/src/exposure_compensate.cpp index 0a22daeb7e..78ce6d3714 100644 --- a/modules/stitching/src/exposure_compensate.cpp +++ b/modules/stitching/src/exposure_compensate.cpp @@ -48,13 +48,13 @@ namespace detail { Ptr ExposureCompensator::createDefault(int type) { if (type == NO) - return new NoExposureCompensator(); + return makePtr(); if (type == GAIN) - return new GainCompensator(); + return makePtr(); if (type == GAIN_BLOCKS) - return new BlocksGainCompensator(); + return makePtr(); CV_Error(Error::StsBadArg, "unsupported exposure compensation method"); - return NULL; + return Ptr(); } diff --git a/modules/stitching/src/matchers.cpp b/modules/stitching/src/matchers.cpp index e8b7bf24f9..0ad0c1f1d0 100644 --- a/modules/stitching/src/matchers.cpp +++ b/modules/stitching/src/matchers.cpp @@ -155,8 +155,8 @@ void CpuMatcher::match(const ImageFeatures &features1, const ImageFeatures &feat matches_info.matches.clear(); - Ptr indexParams = new flann::KDTreeIndexParams(); - Ptr searchParams = new flann::SearchParams(); + Ptr indexParams = makePtr(); + Ptr searchParams = makePtr(); if (features2.descriptors.depth() == CV_8U) { @@ -314,7 +314,7 @@ SurfFeaturesFinder::SurfFeaturesFinder(double hess_thresh, int num_octaves, int if (num_octaves_descr == num_octaves && num_layers_descr == num_layers) { surf = Algorithm::create("Feature2D.SURF"); - if( surf.empty() ) + if( !surf ) CV_Error( Error::StsNotImplemented, "OpenCV was built without SURF support" ); surf->set("hessianThreshold", hess_thresh); surf->set("nOctaves", num_octaves); @@ -325,7 +325,7 @@ SurfFeaturesFinder::SurfFeaturesFinder(double hess_thresh, int num_octaves, int detector_ = Algorithm::create("Feature2D.SURF"); extractor_ = Algorithm::create("Feature2D.SURF"); - if( detector_.empty() || extractor_.empty() ) + if( !detector_ || !extractor_ ) CV_Error( Error::StsNotImplemented, "OpenCV was built without SURF support" ); detector_->set("hessianThreshold", hess_thresh); @@ -349,7 +349,7 @@ void SurfFeaturesFinder::find(const Mat &image, ImageFeatures &features) { gray_image = image; } - if (surf.empty()) + if (!surf) { detector_->detect(gray_image, features.keypoints); extractor_->compute(gray_image, features.keypoints, features.descriptors); @@ -365,7 +365,7 @@ void SurfFeaturesFinder::find(const Mat &image, ImageFeatures &features) OrbFeaturesFinder::OrbFeaturesFinder(Size _grid_size, int n_features, float scaleFactor, int nlevels) { grid_size = _grid_size; - orb = new ORB(n_features * (99 + grid_size.area())/100/grid_size.area(), scaleFactor, nlevels); + orb = makePtr(n_features * (99 + grid_size.area())/100/grid_size.area(), scaleFactor, nlevels); } void OrbFeaturesFinder::find(const Mat &image, ImageFeatures &features) @@ -534,12 +534,12 @@ BestOf2NearestMatcher::BestOf2NearestMatcher(bool try_use_gpu, float match_conf, #ifdef HAVE_OPENCV_GPUFEATURES2D if (try_use_gpu && getCudaEnabledDeviceCount() > 0) { - impl_ = new GpuMatcher(match_conf); + impl_ = makePtr(match_conf); } else #endif { - impl_ = new CpuMatcher(match_conf); + impl_ = makePtr(match_conf); } is_thread_safe_ = impl_->isThreadSafe(); diff --git a/modules/stitching/src/stitcher.cpp b/modules/stitching/src/stitcher.cpp index 75307209db..00e02b07cb 100644 --- a/modules/stitching/src/stitcher.cpp +++ b/modules/stitching/src/stitcher.cpp @@ -53,34 +53,34 @@ Stitcher Stitcher::createDefault(bool try_use_gpu) stitcher.setPanoConfidenceThresh(1); stitcher.setWaveCorrection(true); stitcher.setWaveCorrectKind(detail::WAVE_CORRECT_HORIZ); - stitcher.setFeaturesMatcher(new detail::BestOf2NearestMatcher(try_use_gpu)); - stitcher.setBundleAdjuster(new detail::BundleAdjusterRay()); + stitcher.setFeaturesMatcher(makePtr(try_use_gpu)); + stitcher.setBundleAdjuster(makePtr()); #ifdef HAVE_OPENCV_GPU if (try_use_gpu && gpu::getCudaEnabledDeviceCount() > 0) { #ifdef HAVE_OPENCV_NONFREE - stitcher.setFeaturesFinder(new detail::SurfFeaturesFinderGpu()); + stitcher.setFeaturesFinder(makePtr()); #else - stitcher.setFeaturesFinder(new detail::OrbFeaturesFinder()); + stitcher.setFeaturesFinder(makePtr()); #endif - stitcher.setWarper(new SphericalWarperGpu()); - stitcher.setSeamFinder(new detail::GraphCutSeamFinderGpu()); + stitcher.setWarper(makePtr()); + stitcher.setSeamFinder(makePtr()); } else #endif { #ifdef HAVE_OPENCV_NONFREE - stitcher.setFeaturesFinder(new detail::SurfFeaturesFinder()); + stitcher.setFeaturesFinder(makePtr()); #else - stitcher.setFeaturesFinder(new detail::OrbFeaturesFinder()); + stitcher.setFeaturesFinder(makePtr()); #endif - stitcher.setWarper(new SphericalWarper()); - stitcher.setSeamFinder(new detail::GraphCutSeamFinder(detail::GraphCutSeamFinderBase::COST_COLOR)); + stitcher.setWarper(makePtr()); + stitcher.setSeamFinder(makePtr(detail::GraphCutSeamFinderBase::COST_COLOR)); } - stitcher.setExposureCompensator(new detail::BlocksGainCompensator()); - stitcher.setBlender(new detail::MultiBandBlender(try_use_gpu)); + stitcher.setExposureCompensator(makePtr()); + stitcher.setBlender(makePtr(try_use_gpu)); return stitcher; } diff --git a/modules/stitching/test/test_matchers.cpp b/modules/stitching/test/test_matchers.cpp index ba5c43ae22..c7f068b7fe 100644 --- a/modules/stitching/test/test_matchers.cpp +++ b/modules/stitching/test/test_matchers.cpp @@ -49,7 +49,7 @@ using namespace std; TEST(SurfFeaturesFinder, CanFindInROIs) { - Ptr finder = new detail::SurfFeaturesFinder(); + Ptr finder = makePtr(); Mat img = imread(string(cvtest::TS::ptr()->get_data_path()) + "cv/shared/lena.png"); vector rois; From 93f757f8a25ebf7be5eb177bde676b2639acec75 Mon Sep 17 00:00:00 2001 From: Roman Donchenko Date: Tue, 13 Aug 2013 17:57:06 +0400 Subject: [PATCH 15/55] Boring changes - superres. --- modules/superres/perf/perf_superres.cpp | 4 ++-- modules/superres/perf/perf_superres_ocl.cpp | 2 +- modules/superres/src/btv_l1.cpp | 4 ++-- modules/superres/src/btv_l1_gpu.cpp | 2 +- modules/superres/src/btv_l1_ocl.cpp | 2 +- modules/superres/src/frame_source.cpp | 8 ++++---- modules/superres/src/optical_flow.cpp | 20 ++++++++++---------- modules/superres/test/test_superres.cpp | 7 ++++--- 8 files changed, 25 insertions(+), 24 deletions(-) diff --git a/modules/superres/perf/perf_superres.cpp b/modules/superres/perf/perf_superres.cpp index 83fb76e8af..9d83c949d4 100644 --- a/modules/superres/perf/perf_superres.cpp +++ b/modules/superres/perf/perf_superres.cpp @@ -153,7 +153,7 @@ PERF_TEST_P(Size_MatType, SuperResolution_BTVL1, superRes->set("temporalAreaRadius", temporalAreaRadius); superRes->set("opticalFlow", opticalFlow); - superRes->setInput(new OneFrameSource_GPU(GpuMat(frame))); + superRes->setInput(makePtr(GpuMat(frame))); GpuMat dst; superRes->nextFrame(dst); @@ -171,7 +171,7 @@ PERF_TEST_P(Size_MatType, SuperResolution_BTVL1, superRes->set("temporalAreaRadius", temporalAreaRadius); superRes->set("opticalFlow", opticalFlow); - superRes->setInput(new OneFrameSource_CPU(frame)); + superRes->setInput(makePtr(frame)); Mat dst; superRes->nextFrame(dst); diff --git a/modules/superres/perf/perf_superres_ocl.cpp b/modules/superres/perf/perf_superres_ocl.cpp index 1d3fee2a15..ce8f5934e0 100644 --- a/modules/superres/perf/perf_superres_ocl.cpp +++ b/modules/superres/perf/perf_superres_ocl.cpp @@ -134,7 +134,7 @@ PERF_TEST_P(Size_MatType, SuperResolution_BTVL1_OCL, superRes_ocl->set("temporalAreaRadius", temporalAreaRadius); superRes_ocl->set("opticalFlow", opticalFlowOcl); - superRes_ocl->setInput(new OneFrameSource_OCL(frame_ocl)); + superRes_ocl->setInput(makePtr(frame_ocl)); ocl::oclMat dst_ocl; superRes_ocl->nextFrame(dst_ocl); diff --git a/modules/superres/src/btv_l1.cpp b/modules/superres/src/btv_l1.cpp index 178e434ade..e0ee7db63a 100644 --- a/modules/superres/src/btv_l1.cpp +++ b/modules/superres/src/btv_l1.cpp @@ -337,7 +337,7 @@ namespace // update blur filter and btv weights - if (filter_.empty() || blurKernelSize_ != curBlurKernelSize_ || blurSigma_ != curBlurSigma_ || src[0].type() != curSrcType_) + if (!filter_ || blurKernelSize_ != curBlurKernelSize_ || blurSigma_ != curBlurSigma_ || src[0].type() != curSrcType_) { filter_ = createGaussianFilter(src[0].type(), Size(blurKernelSize_, blurKernelSize_), blurSigma_); curBlurKernelSize_ = blurKernelSize_; @@ -614,5 +614,5 @@ namespace Ptr cv::superres::createSuperResolution_BTVL1() { - return new BTVL1; + return makePtr(); } diff --git a/modules/superres/src/btv_l1_gpu.cpp b/modules/superres/src/btv_l1_gpu.cpp index 7b2ad73700..f4268b01bd 100644 --- a/modules/superres/src/btv_l1_gpu.cpp +++ b/modules/superres/src/btv_l1_gpu.cpp @@ -578,7 +578,7 @@ namespace Ptr cv::superres::createSuperResolution_BTVL1_GPU() { - return new BTVL1_GPU; + return makePtr(); } #endif // HAVE_CUDA diff --git a/modules/superres/src/btv_l1_ocl.cpp b/modules/superres/src/btv_l1_ocl.cpp index ff60303e44..9d94e61ceb 100644 --- a/modules/superres/src/btv_l1_ocl.cpp +++ b/modules/superres/src/btv_l1_ocl.cpp @@ -743,6 +743,6 @@ namespace Ptr cv::superres::createSuperResolution_BTVL1_OCL() { - return new BTVL1_OCL; + return makePtr(); } #endif diff --git a/modules/superres/src/frame_source.cpp b/modules/superres/src/frame_source.cpp index 5c6b1231b9..14576d5dd3 100644 --- a/modules/superres/src/frame_source.cpp +++ b/modules/superres/src/frame_source.cpp @@ -74,7 +74,7 @@ namespace Ptr cv::superres::createFrameSource_Empty() { - return new EmptyFrameSource; + return makePtr(); } ////////////////////////////////////////////////////// @@ -186,12 +186,12 @@ namespace Ptr cv::superres::createFrameSource_Video(const String& fileName) { - return new VideoFrameSource(fileName); + return makePtr(fileName); } Ptr cv::superres::createFrameSource_Camera(int deviceId) { - return new CameraFrameSource(deviceId); + return makePtr(deviceId); } #endif // HAVE_OPENCV_HIGHGUI @@ -257,7 +257,7 @@ namespace Ptr cv::superres::createFrameSource_Video_GPU(const String& fileName) { - return new VideoFrameSource(fileName); + return makePtr(fileName); } #endif // HAVE_OPENCV_GPUCODEC diff --git a/modules/superres/src/optical_flow.cpp b/modules/superres/src/optical_flow.cpp index 1779498775..85c74115a8 100644 --- a/modules/superres/src/optical_flow.cpp +++ b/modules/superres/src/optical_flow.cpp @@ -169,7 +169,7 @@ namespace Ptr cv::superres::createOptFlow_Farneback() { - return new Farneback; + return makePtr(); } /////////////////////////////////////////////////////////////////// @@ -258,7 +258,7 @@ namespace Ptr cv::superres::createOptFlow_Simple() { - return new Simple; + return makePtr(); } /////////////////////////////////////////////////////////////////// @@ -337,7 +337,7 @@ namespace Ptr cv::superres::createOptFlow_DualTVL1() { - return new DualTVL1; + return makePtr(); } /////////////////////////////////////////////////////////////////// @@ -503,7 +503,7 @@ namespace Ptr cv::superres::createOptFlow_Brox_GPU() { - return new Brox_GPU; + return makePtr(); } /////////////////////////////////////////////////////////////////// @@ -562,7 +562,7 @@ namespace Ptr cv::superres::createOptFlow_PyrLK_GPU() { - return new PyrLK_GPU; + return makePtr(); } /////////////////////////////////////////////////////////////////// @@ -636,7 +636,7 @@ namespace Ptr cv::superres::createOptFlow_Farneback_GPU() { - return new Farneback_GPU; + return makePtr(); } /////////////////////////////////////////////////////////////////// @@ -714,7 +714,7 @@ namespace Ptr cv::superres::createOptFlow_DualTVL1_GPU() { - return new DualTVL1_GPU; + return makePtr(); } #endif // HAVE_OPENCV_GPUOPTFLOW @@ -827,7 +827,7 @@ namespace Ptr cv::superres::createOptFlow_PyrLK_OCL() { - return new PyrLK_OCL; + return makePtr(); } /////////////////////////////////////////////////////////////////// @@ -906,7 +906,7 @@ namespace Ptr cv::superres::createOptFlow_DualTVL1_OCL() { - return new DualTVL1_OCL; + return makePtr(); } /////////////////////////////////////////////////////////////////// @@ -980,7 +980,7 @@ namespace Ptr cv::superres::createOptFlow_Farneback_OCL() { - return new FarneBack_OCL; + return makePtr(); } #endif diff --git a/modules/superres/test/test_superres.cpp b/modules/superres/test/test_superres.cpp index 2cede096db..d33e182738 100644 --- a/modules/superres/test/test_superres.cpp +++ b/modules/superres/test/test_superres.cpp @@ -59,7 +59,7 @@ private: AllignedFrameSource::AllignedFrameSource(const cv::Ptr& base, int scale) : base_(base), scale_(scale) { - CV_Assert( !base_.empty() ); + CV_Assert( base_ ); } void AllignedFrameSource::nextFrame(cv::OutputArray frame) @@ -101,7 +101,7 @@ private: DegradeFrameSource::DegradeFrameSource(const cv::Ptr& base, int scale) : base_(base), iscale_(1.0 / scale) { - CV_Assert( !base_.empty() ); + CV_Assert( base_ ); } void addGaussNoise(cv::Mat& image, double sigma) @@ -229,7 +229,8 @@ void SuperResolution::RunTest(cv::Ptr superRes) superRes->set("temporalAreaRadius", temporalAreaRadius); cv::Ptr goldSource(new AllignedFrameSource(cv::superres::createFrameSource_Video(inputVideoName), scale)); - cv::Ptr lowResSource(new DegradeFrameSource(new AllignedFrameSource(cv::superres::createFrameSource_Video(inputVideoName), scale), scale)); + cv::Ptr lowResSource(new DegradeFrameSource( + cv::makePtr(cv::superres::createFrameSource_Video(inputVideoName), scale), scale)); // skip first frame cv::Mat frame; From 808e0cf10b43d566dbe38e92b16e6377cdbca460 Mon Sep 17 00:00:00 2001 From: Roman Donchenko Date: Tue, 13 Aug 2013 17:57:49 +0400 Subject: [PATCH 16/55] Boring changes - video. --- modules/video/src/bgfg_gaussmix.cpp | 2 +- modules/video/src/bgfg_gaussmix2.cpp | 2 +- modules/video/src/bgfg_gmg.cpp | 2 +- modules/video/src/tvl1flow.cpp | 2 +- modules/video/test/test_backgroundsubtractor_gbh.cpp | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/modules/video/src/bgfg_gaussmix.cpp b/modules/video/src/bgfg_gaussmix.cpp index a1a224d973..b5ad039e27 100644 --- a/modules/video/src/bgfg_gaussmix.cpp +++ b/modules/video/src/bgfg_gaussmix.cpp @@ -464,7 +464,7 @@ void BackgroundSubtractorMOGImpl::apply(InputArray _image, OutputArray _fgmask, Ptr createBackgroundSubtractorMOG(int history, int nmixtures, double backgroundRatio, double noiseSigma) { - return new BackgroundSubtractorMOGImpl(history, nmixtures, backgroundRatio, noiseSigma); + return makePtr(history, nmixtures, backgroundRatio, noiseSigma); } } diff --git a/modules/video/src/bgfg_gaussmix2.cpp b/modules/video/src/bgfg_gaussmix2.cpp index 2c99c01b05..485e34d26d 100644 --- a/modules/video/src/bgfg_gaussmix2.cpp +++ b/modules/video/src/bgfg_gaussmix2.cpp @@ -769,7 +769,7 @@ void BackgroundSubtractorMOG2Impl::getBackgroundImage(OutputArray backgroundImag Ptr createBackgroundSubtractorMOG2(int _history, double _varThreshold, bool _bShadowDetection) { - return new BackgroundSubtractorMOG2Impl(_history, (float)_varThreshold, _bShadowDetection); + return makePtr(_history, (float)_varThreshold, _bShadowDetection); } } diff --git a/modules/video/src/bgfg_gmg.cpp b/modules/video/src/bgfg_gmg.cpp index e3e4232111..f5b7881a0a 100644 --- a/modules/video/src/bgfg_gmg.cpp +++ b/modules/video/src/bgfg_gmg.cpp @@ -485,7 +485,7 @@ void BackgroundSubtractorGMGImpl::release() Ptr createBackgroundSubtractorGMG(int initializationFrames, double decisionThreshold) { - Ptr bgfg = new BackgroundSubtractorGMGImpl; + Ptr bgfg = makePtr(); bgfg->setNumFrames(initializationFrames); bgfg->setDecisionThreshold(decisionThreshold); diff --git a/modules/video/src/tvl1flow.cpp b/modules/video/src/tvl1flow.cpp index cdf42f91ef..8d59932750 100644 --- a/modules/video/src/tvl1flow.cpp +++ b/modules/video/src/tvl1flow.cpp @@ -953,5 +953,5 @@ CV_INIT_ALGORITHM(OpticalFlowDual_TVL1, "DenseOpticalFlow.DualTVL1", Ptr cv::createOptFlow_DualTVL1() { - return new OpticalFlowDual_TVL1; + return makePtr(); } diff --git a/modules/video/test/test_backgroundsubtractor_gbh.cpp b/modules/video/test/test_backgroundsubtractor_gbh.cpp index a7261516ab..99d53e3d32 100644 --- a/modules/video/test/test_backgroundsubtractor_gbh.cpp +++ b/modules/video/test/test_backgroundsubtractor_gbh.cpp @@ -40,7 +40,7 @@ void CV_BackgroundSubtractorTest::run(int) Ptr fgbg = createBackgroundSubtractorGMG(); Mat fgmask; - if (fgbg.empty()) + if (!fgbg) CV_Error(Error::StsError,"Failed to create Algorithm\n"); /** From 0dcb4f1f661ba4a38973e9781a67cd89c578706f Mon Sep 17 00:00:00 2001 From: Roman Donchenko Date: Tue, 13 Aug 2013 18:01:59 +0400 Subject: [PATCH 17/55] Boring changes - videostab. --- modules/videostab/src/frame_source.cpp | 8 +++---- modules/videostab/src/global_motion.cpp | 12 +++++----- modules/videostab/src/inpainting.cpp | 2 +- modules/videostab/src/motion_stabilizing.cpp | 4 ++-- modules/videostab/src/stabilizer.cpp | 24 ++++++++++---------- modules/videostab/src/wobble_suppression.cpp | 2 +- 6 files changed, 26 insertions(+), 26 deletions(-) diff --git a/modules/videostab/src/frame_source.cpp b/modules/videostab/src/frame_source.cpp index 0032202115..7ca4b73de7 100644 --- a/modules/videostab/src/frame_source.cpp +++ b/modules/videostab/src/frame_source.cpp @@ -111,10 +111,10 @@ VideoFileSource::VideoFileSource(const String &path, bool volatileFrame) void VideoFileSource::reset() { impl->reset(); } Mat VideoFileSource::nextFrame() { return impl->nextFrame(); } -int VideoFileSource::width() { return ((VideoFileSourceImpl*)impl.obj)->width(); } -int VideoFileSource::height() { return ((VideoFileSourceImpl*)impl.obj)->height(); } -int VideoFileSource::count() { return ((VideoFileSourceImpl*)impl.obj)->count(); } -double VideoFileSource::fps() { return ((VideoFileSourceImpl*)impl.obj)->fps(); } +int VideoFileSource::width() { return ((VideoFileSourceImpl*)impl.get())->width(); } +int VideoFileSource::height() { return ((VideoFileSourceImpl*)impl.get())->height(); } +int VideoFileSource::count() { return ((VideoFileSourceImpl*)impl.get())->count(); } +double VideoFileSource::fps() { return ((VideoFileSourceImpl*)impl.get())->fps(); } } // namespace videostab } // namespace cv diff --git a/modules/videostab/src/global_motion.cpp b/modules/videostab/src/global_motion.cpp index 383a10dfd0..c9f15a61cf 100644 --- a/modules/videostab/src/global_motion.cpp +++ b/modules/videostab/src/global_motion.cpp @@ -671,9 +671,9 @@ Mat ToFileMotionWriter::estimate(const Mat &frame0, const Mat &frame1, bool *ok) KeypointBasedMotionEstimator::KeypointBasedMotionEstimator(Ptr estimator) : ImageMotionEstimatorBase(estimator->motionModel()), motionEstimator_(estimator) { - setDetector(new GoodFeaturesToTrackDetector()); - setOpticalFlowEstimator(new SparsePyrLkOptFlowEstimator()); - setOutlierRejector(new NullOutlierRejector()); + setDetector(makePtr()); + setOpticalFlowEstimator(makePtr()); + setOutlierRejector(makePtr()); } @@ -708,7 +708,7 @@ Mat KeypointBasedMotionEstimator::estimate(const Mat &frame0, const Mat &frame1, // perform outlier rejection - IOutlierRejector *outlRejector = static_cast(outlierRejector_); + IOutlierRejector *outlRejector = outlierRejector_.get(); if (!dynamic_cast(outlRejector)) { pointsPrev_.swap(pointsPrevGood_); @@ -745,7 +745,7 @@ KeypointBasedMotionEstimatorGpu::KeypointBasedMotionEstimatorGpu(Ptr 0); - setOutlierRejector(new NullOutlierRejector()); + setOutlierRejector(makePtr()); } @@ -784,7 +784,7 @@ Mat KeypointBasedMotionEstimatorGpu::estimate(const gpu::GpuMat &frame0, const g // perform outlier rejection - IOutlierRejector *rejector = static_cast(outlierRejector_); + IOutlierRejector *rejector = outlierRejector_.get(); if (!dynamic_cast(rejector)) { outlierRejector_->process(frame0.size(), hostPointsPrev_, hostPoints_, rejectionStatus_); diff --git a/modules/videostab/src/inpainting.cpp b/modules/videostab/src/inpainting.cpp index b3092048fa..7f5368cffc 100644 --- a/modules/videostab/src/inpainting.cpp +++ b/modules/videostab/src/inpainting.cpp @@ -324,7 +324,7 @@ public: MotionInpainter::MotionInpainter() { #ifdef HAVE_OPENCV_GPUOPTFLOW - setOptFlowEstimator(new DensePyrLkOptFlowEstimatorGpu()); + setOptFlowEstimator(makePtr()); #else CV_Error(Error::StsNotImplemented, "Current implementation of MotionInpainter requires GPU"); #endif diff --git a/modules/videostab/src/motion_stabilizing.cpp b/modules/videostab/src/motion_stabilizing.cpp index c1f3442e78..65bbd73bd1 100644 --- a/modules/videostab/src/motion_stabilizing.cpp +++ b/modules/videostab/src/motion_stabilizing.cpp @@ -532,9 +532,9 @@ void LpMotionStabilizer::stabilize( model.scaling(1); ClpPresolve presolveInfo; - Ptr presolvedModel = presolveInfo.presolvedModel(model); + Ptr presolvedModel(presolveInfo.presolvedModel(model)); - if (!presolvedModel.empty()) + if (presolvedModel) { presolvedModel->dual(); presolveInfo.postsolve(true); diff --git a/modules/videostab/src/stabilizer.cpp b/modules/videostab/src/stabilizer.cpp index 50ac05c6f7..f9c09ba36c 100644 --- a/modules/videostab/src/stabilizer.cpp +++ b/modules/videostab/src/stabilizer.cpp @@ -54,11 +54,11 @@ namespace videostab StabilizerBase::StabilizerBase() { - setLog(new LogToStdout()); - setFrameSource(new NullFrameSource()); - setMotionEstimator(new KeypointBasedMotionEstimator(new MotionEstimatorRansacL2())); - setDeblurer(new NullDeblurer()); - setInpainter(new NullInpainter()); + setLog(makePtr()); + setFrameSource(makePtr()); + setMotionEstimator(makePtr(makePtr())); + setDeblurer(makePtr()); + setInpainter(makePtr()); setRadius(15); setTrimRatio(0); setCorrectionForInclusion(false); @@ -156,7 +156,7 @@ bool StabilizerBase::doOneIteration() void StabilizerBase::setUp(const Mat &firstFrame) { - InpainterBase *inpaint = static_cast(inpainter_); + InpainterBase *inpaint = inpainter_.get(); doInpainting_ = dynamic_cast(inpaint) == 0; if (doInpainting_) { @@ -167,7 +167,7 @@ void StabilizerBase::setUp(const Mat &firstFrame) inpainter_->setStabilizationMotions(stabilizationMotions_); } - DeblurerBase *deblurer = static_cast(deblurer_); + DeblurerBase *deblurer = deblurer_.get(); doDeblurring_ = dynamic_cast(deblurer) == 0; if (doDeblurring_) { @@ -252,7 +252,7 @@ void StabilizerBase::logProcessingTime() OnePassStabilizer::OnePassStabilizer() { - setMotionFilter(new GaussianMotionFilter()); + setMotionFilter(makePtr()); reset(); } @@ -308,8 +308,8 @@ Mat OnePassStabilizer::postProcessFrame(const Mat &frame) TwoPassStabilizer::TwoPassStabilizer() { - setMotionStabilizer(new GaussianMotionFilter()); - setWobbleSuppressor(new NullWobbleSuppressor()); + setMotionStabilizer(makePtr()); + setWobbleSuppressor(makePtr()); setEstimateTrimRatio(false); reset(); } @@ -371,7 +371,7 @@ void TwoPassStabilizer::runPrePassIfNecessary() { // check if we must do wobble suppression - WobbleSuppressorBase *wobble = static_cast(wobbleSuppressor_); + WobbleSuppressorBase *wobble = wobbleSuppressor_.get(); doWobbleSuppression_ = dynamic_cast(wobble) == 0; // estimate motions @@ -469,7 +469,7 @@ void TwoPassStabilizer::setUp(const Mat &firstFrame) for (int i = -radius_; i <= 0; ++i) at(i, frames_) = firstFrame; - WobbleSuppressorBase *wobble = static_cast(wobbleSuppressor_); + WobbleSuppressorBase *wobble = wobbleSuppressor_.get(); doWobbleSuppression_ = dynamic_cast(wobble) == 0; if (doWobbleSuppression_) { diff --git a/modules/videostab/src/wobble_suppression.cpp b/modules/videostab/src/wobble_suppression.cpp index c9d8ac91f9..0b652b9dbc 100644 --- a/modules/videostab/src/wobble_suppression.cpp +++ b/modules/videostab/src/wobble_suppression.cpp @@ -60,7 +60,7 @@ namespace videostab WobbleSuppressorBase::WobbleSuppressorBase() : motions_(0), stabilizationMotions_(0) { - setMotionEstimator(new KeypointBasedMotionEstimator(new MotionEstimatorRansacL2(MM_HOMOGRAPHY))); + setMotionEstimator(makePtr(makePtr(MM_HOMOGRAPHY))); } From 57595a83083dda4ad70e5e362b637f3fb12a4d2a Mon Sep 17 00:00:00 2001 From: Roman Donchenko Date: Tue, 13 Aug 2013 18:03:13 +0400 Subject: [PATCH 18/55] Boring changes - gpu. --- modules/gpu/src/cascadeclassifier.cpp | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/modules/gpu/src/cascadeclassifier.cpp b/modules/gpu/src/cascadeclassifier.cpp index 74867b48dd..fc5eafbf4d 100644 --- a/modules/gpu/src/cascadeclassifier.cpp +++ b/modules/gpu/src/cascadeclassifier.cpp @@ -207,8 +207,8 @@ private: ncvAssertCUDAReturn(cudaGetDeviceProperties(&devProp, devId), NCV_CUDA_ERROR); // Load the classifier from file (assuming its size is about 1 mb) using a simple allocator - gpuCascadeAllocator = new NCVMemNativeAllocator(NCVMemoryTypeDevice, static_cast(devProp.textureAlignment)); - cpuCascadeAllocator = new NCVMemNativeAllocator(NCVMemoryTypeHostPinned, static_cast(devProp.textureAlignment)); + gpuCascadeAllocator = makePtr(NCVMemoryTypeDevice, static_cast(devProp.textureAlignment)); + cpuCascadeAllocator = makePtr(NCVMemoryTypeHostPinned, static_cast(devProp.textureAlignment)); ncvAssertPrintReturn(gpuCascadeAllocator->isInitialized(), "Error creating cascade GPU allocator", NCV_CUDA_ERROR); ncvAssertPrintReturn(cpuCascadeAllocator->isInitialized(), "Error creating cascade CPU allocator", NCV_CUDA_ERROR); @@ -217,9 +217,9 @@ private: ncvStat = ncvHaarGetClassifierSize(classifierFile, haarNumStages, haarNumNodes, haarNumFeatures); ncvAssertPrintReturn(ncvStat == NCV_SUCCESS, "Error reading classifier size (check the file)", NCV_FILE_ERROR); - h_haarStages = new NCVVectorAlloc(*cpuCascadeAllocator, haarNumStages); - h_haarNodes = new NCVVectorAlloc(*cpuCascadeAllocator, haarNumNodes); - h_haarFeatures = new NCVVectorAlloc(*cpuCascadeAllocator, haarNumFeatures); + h_haarStages.reset (new NCVVectorAlloc(*cpuCascadeAllocator, haarNumStages)); + h_haarNodes.reset (new NCVVectorAlloc(*cpuCascadeAllocator, haarNumNodes)); + h_haarFeatures.reset(new NCVVectorAlloc(*cpuCascadeAllocator, haarNumFeatures)); ncvAssertPrintReturn(h_haarStages->isMemAllocated(), "Error in cascade CPU allocator", NCV_CUDA_ERROR); ncvAssertPrintReturn(h_haarNodes->isMemAllocated(), "Error in cascade CPU allocator", NCV_CUDA_ERROR); @@ -228,9 +228,9 @@ private: ncvStat = ncvHaarLoadFromFile_host(classifierFile, haar, *h_haarStages, *h_haarNodes, *h_haarFeatures); ncvAssertPrintReturn(ncvStat == NCV_SUCCESS, "Error loading classifier", NCV_FILE_ERROR); - d_haarStages = new NCVVectorAlloc(*gpuCascadeAllocator, haarNumStages); - d_haarNodes = new NCVVectorAlloc(*gpuCascadeAllocator, haarNumNodes); - d_haarFeatures = new NCVVectorAlloc(*gpuCascadeAllocator, haarNumFeatures); + d_haarStages.reset (new NCVVectorAlloc(*gpuCascadeAllocator, haarNumStages)); + d_haarNodes.reset (new NCVVectorAlloc(*gpuCascadeAllocator, haarNumNodes)); + d_haarFeatures.reset(new NCVVectorAlloc(*gpuCascadeAllocator, haarNumFeatures)); ncvAssertPrintReturn(d_haarStages->isMemAllocated(), "Error in cascade GPU allocator", NCV_CUDA_ERROR); ncvAssertPrintReturn(d_haarNodes->isMemAllocated(), "Error in cascade GPU allocator", NCV_CUDA_ERROR); @@ -279,8 +279,8 @@ private: ncvAssertReturnNcvStat(ncvStat); ncvAssertCUDAReturn(cudaStreamSynchronize(0), NCV_CUDA_ERROR); - gpuAllocator = new NCVMemStackAllocator(NCVMemoryTypeDevice, gpuCounter.maxSize(), static_cast(devProp.textureAlignment)); - cpuAllocator = new NCVMemStackAllocator(NCVMemoryTypeHostPinned, cpuCounter.maxSize(), static_cast(devProp.textureAlignment)); + gpuAllocator = makePtr(NCVMemoryTypeDevice, gpuCounter.maxSize(), static_cast(devProp.textureAlignment)); + cpuAllocator = makePtr(NCVMemoryTypeHostPinned, cpuCounter.maxSize(), static_cast(devProp.textureAlignment)); ncvAssertPrintReturn(gpuAllocator->isInitialized(), "Error creating GPU memory allocator", NCV_CUDA_ERROR); ncvAssertPrintReturn(cpuAllocator->isInitialized(), "Error creating CPU memory allocator", NCV_CUDA_ERROR); From f8f06853974ea7a1ef54f0db26bb9ea914180f33 Mon Sep 17 00:00:00 2001 From: Roman Donchenko Date: Tue, 13 Aug 2013 18:03:48 +0400 Subject: [PATCH 19/55] Boring changes - gpuarithm. --- modules/gpuarithm/src/arithm.cpp | 2 +- modules/gpuarithm/src/core.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/gpuarithm/src/arithm.cpp b/modules/gpuarithm/src/arithm.cpp index eb7d710e6e..78071ba8a7 100644 --- a/modules/gpuarithm/src/arithm.cpp +++ b/modules/gpuarithm/src/arithm.cpp @@ -629,7 +629,7 @@ Ptr cv::gpu::createConvolution(Size user_block_size) CV_Error(Error::StsNotImplemented, "The library was build without CUFFT"); return Ptr(); #else - return new ConvolutionImpl(user_block_size); + return makePtr(user_block_size); #endif } diff --git a/modules/gpuarithm/src/core.cpp b/modules/gpuarithm/src/core.cpp index 22887796ab..05ea5741d8 100644 --- a/modules/gpuarithm/src/core.cpp +++ b/modules/gpuarithm/src/core.cpp @@ -497,7 +497,7 @@ namespace Ptr cv::gpu::createLookUpTable(InputArray lut) { - return new LookUpTableImpl(lut); + return makePtr(lut); } //////////////////////////////////////////////////////////////////////// From 2c033251dbddf29a0e321f501922426f645662ef Mon Sep 17 00:00:00 2001 From: Roman Donchenko Date: Tue, 13 Aug 2013 18:05:11 +0400 Subject: [PATCH 20/55] Boring changes - gpubgsegm. --- modules/gpubgsegm/perf/perf_bgsegm.cpp | 2 +- modules/gpubgsegm/src/fgd.cpp | 2 +- modules/gpubgsegm/src/gmg.cpp | 2 +- modules/gpubgsegm/src/mog.cpp | 2 +- modules/gpubgsegm/src/mog2.cpp | 2 +- modules/gpubgsegm/test/test_bgsegm.cpp | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/modules/gpubgsegm/perf/perf_bgsegm.cpp b/modules/gpubgsegm/perf/perf_bgsegm.cpp index 6f864fd75c..34b65f6be1 100644 --- a/modules/gpubgsegm/perf/perf_bgsegm.cpp +++ b/modules/gpubgsegm/perf/perf_bgsegm.cpp @@ -76,7 +76,7 @@ using namespace perf; namespace cv { - template<> void Ptr::delete_obj() + template<> void DefaultDeleter::operator ()(CvBGStatModel* obj) const { cvReleaseBGStatModel(&obj); } diff --git a/modules/gpubgsegm/src/fgd.cpp b/modules/gpubgsegm/src/fgd.cpp index ef203e074f..31cf370c16 100644 --- a/modules/gpubgsegm/src/fgd.cpp +++ b/modules/gpubgsegm/src/fgd.cpp @@ -725,7 +725,7 @@ namespace Ptr cv::gpu::createBackgroundSubtractorFGD(const FGDParams& params) { - return new FGDImpl(params); + return makePtr(params); } #endif // HAVE_CUDA diff --git a/modules/gpubgsegm/src/gmg.cpp b/modules/gpubgsegm/src/gmg.cpp index 2cc0f4d574..f8650b2420 100644 --- a/modules/gpubgsegm/src/gmg.cpp +++ b/modules/gpubgsegm/src/gmg.cpp @@ -271,7 +271,7 @@ namespace Ptr cv::gpu::createBackgroundSubtractorGMG(int initializationFrames, double decisionThreshold) { - return new GMGImpl(initializationFrames, decisionThreshold); + return makePtr(initializationFrames, decisionThreshold); } #endif diff --git a/modules/gpubgsegm/src/mog.cpp b/modules/gpubgsegm/src/mog.cpp index 65adb9425c..12e5b32304 100644 --- a/modules/gpubgsegm/src/mog.cpp +++ b/modules/gpubgsegm/src/mog.cpp @@ -203,7 +203,7 @@ namespace Ptr cv::gpu::createBackgroundSubtractorMOG(int history, int nmixtures, double backgroundRatio, double noiseSigma) { - return new MOGImpl(history, nmixtures, backgroundRatio, noiseSigma); + return makePtr(history, nmixtures, backgroundRatio, noiseSigma); } #endif diff --git a/modules/gpubgsegm/src/mog2.cpp b/modules/gpubgsegm/src/mog2.cpp index 5ab731f7e3..5bfb5a1c4f 100644 --- a/modules/gpubgsegm/src/mog2.cpp +++ b/modules/gpubgsegm/src/mog2.cpp @@ -247,7 +247,7 @@ namespace Ptr cv::gpu::createBackgroundSubtractorMOG2(int history, double varThreshold, bool detectShadows) { - return new MOG2Impl(history, varThreshold, detectShadows); + return makePtr(history, varThreshold, detectShadows); } #endif diff --git a/modules/gpubgsegm/test/test_bgsegm.cpp b/modules/gpubgsegm/test/test_bgsegm.cpp index 3b5526b6c6..3a287d1bb8 100644 --- a/modules/gpubgsegm/test/test_bgsegm.cpp +++ b/modules/gpubgsegm/test/test_bgsegm.cpp @@ -70,7 +70,7 @@ using namespace cvtest; namespace cv { - template<> void Ptr::delete_obj() + template<> void DefaultDeleter::operator ()(CvBGStatModel* obj) const { cvReleaseBGStatModel(&obj); } From a57f93ee92d45e10228daa35a5a4007a79bd469f Mon Sep 17 00:00:00 2001 From: Roman Donchenko Date: Tue, 13 Aug 2013 18:06:39 +0400 Subject: [PATCH 21/55] Boring changes - gpucodec. --- modules/gpucodec/src/thread.cpp | 5 ----- modules/gpucodec/src/thread.hpp | 4 ---- 2 files changed, 9 deletions(-) diff --git a/modules/gpucodec/src/thread.cpp b/modules/gpucodec/src/thread.cpp index b936d8e21a..6784a1c8e4 100644 --- a/modules/gpucodec/src/thread.cpp +++ b/modules/gpucodec/src/thread.cpp @@ -167,9 +167,4 @@ void cv::gpucodec::detail::Thread::sleep(int ms) #endif } -template <> void cv::Ptr::delete_obj() -{ - if (obj) delete obj; -} - #endif // HAVE_NVCUVID diff --git a/modules/gpucodec/src/thread.hpp b/modules/gpucodec/src/thread.hpp index ccda5b5c7c..c69367f96f 100644 --- a/modules/gpucodec/src/thread.hpp +++ b/modules/gpucodec/src/thread.hpp @@ -67,8 +67,4 @@ private: }}} -namespace cv { - template <> void Ptr::delete_obj(); -} - #endif // __THREAD_WRAPPERS_HPP__ From b165016ba727f5d4332376fa83ff7bb35e042b64 Mon Sep 17 00:00:00 2001 From: Roman Donchenko Date: Tue, 13 Aug 2013 18:10:26 +0400 Subject: [PATCH 22/55] Boring changes - gpufilters. --- modules/gpufilters/src/filtering.cpp | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/modules/gpufilters/src/filtering.cpp b/modules/gpufilters/src/filtering.cpp index 14917acc33..0043174cba 100644 --- a/modules/gpufilters/src/filtering.cpp +++ b/modules/gpufilters/src/filtering.cpp @@ -169,7 +169,7 @@ Ptr cv::gpu::createBoxFilter(int srcType, int dstType, Size ksize, Point dstType = CV_MAKE_TYPE(CV_MAT_DEPTH(dstType), CV_MAT_CN(srcType)); - return new NPPBoxFilter(srcType, dstType, ksize, anchor, borderMode, borderVal); + return makePtr(srcType, dstType, ksize, anchor, borderMode, borderVal); } //////////////////////////////////////////////////////////////////////////////////////////////////// @@ -277,7 +277,7 @@ Ptr cv::gpu::createLinearFilter(int srcType, int dstType, InputArray ker dstType = CV_MAKE_TYPE(CV_MAT_DEPTH(dstType), CV_MAT_CN(srcType)); - return new LinearFilter(srcType, dstType, kernel, anchor, borderMode, borderVal); + return makePtr(srcType, dstType, kernel, anchor, borderMode, borderVal); } //////////////////////////////////////////////////////////////////////////////////////////////////// @@ -428,7 +428,7 @@ Ptr cv::gpu::createSeparableLinearFilter(int srcType, int dstType, Input if (columnBorderMode < 0) columnBorderMode = rowBorderMode; - return new SeparableLinearFilter(srcType, dstType, rowKernel, columnKernel, anchor, rowBorderMode, columnBorderMode); + return makePtr(srcType, dstType, rowKernel, columnKernel, anchor, rowBorderMode, columnBorderMode); } //////////////////////////////////////////////////////////////////////////////////////////////////// @@ -748,27 +748,27 @@ Ptr cv::gpu::createMorphologyFilter(int op, int srcType, InputArray kern { case MORPH_ERODE: case MORPH_DILATE: - return new MorphologyFilter(op, srcType, kernel, anchor, iterations); + return makePtr(op, srcType, kernel, anchor, iterations); break; case MORPH_OPEN: - return new MorphologyOpenFilter(srcType, kernel, anchor, iterations); + return makePtr(srcType, kernel, anchor, iterations); break; case MORPH_CLOSE: - return new MorphologyCloseFilter(srcType, kernel, anchor, iterations); + return makePtr(srcType, kernel, anchor, iterations); break; case MORPH_GRADIENT: - return new MorphologyGradientFilter(srcType, kernel, anchor, iterations); + return makePtr(srcType, kernel, anchor, iterations); break; case MORPH_TOPHAT: - return new MorphologyTophatFilter(srcType, kernel, anchor, iterations); + return makePtr(srcType, kernel, anchor, iterations); break; case MORPH_BLACKHAT: - return new MorphologyBlackhatFilter(srcType, kernel, anchor, iterations); + return makePtr(srcType, kernel, anchor, iterations); break; default: @@ -782,7 +782,7 @@ Ptr cv::gpu::createMorphologyFilter(int op, int srcType, InputArray kern namespace { - enum + enum RankType { RANK_MAX, RANK_MIN @@ -862,12 +862,12 @@ namespace Ptr cv::gpu::createBoxMaxFilter(int srcType, Size ksize, Point anchor, int borderMode, Scalar borderVal) { - return new NPPRankFilter(RANK_MAX, srcType, ksize, anchor, borderMode, borderVal); + return makePtr(RANK_MAX, srcType, ksize, anchor, borderMode, borderVal); } Ptr cv::gpu::createBoxMinFilter(int srcType, Size ksize, Point anchor, int borderMode, Scalar borderVal) { - return new NPPRankFilter(RANK_MIN, srcType, ksize, anchor, borderMode, borderVal); + return makePtr(RANK_MIN, srcType, ksize, anchor, borderMode, borderVal); } //////////////////////////////////////////////////////////////////////////////////////////////////// @@ -931,7 +931,7 @@ namespace Ptr cv::gpu::createRowSumFilter(int srcType, int dstType, int ksize, int anchor, int borderMode, Scalar borderVal) { - return new NppRowSumFilter(srcType, dstType, ksize, anchor, borderMode, borderVal); + return makePtr(srcType, dstType, ksize, anchor, borderMode, borderVal); } namespace @@ -992,7 +992,7 @@ namespace Ptr cv::gpu::createColumnSumFilter(int srcType, int dstType, int ksize, int anchor, int borderMode, Scalar borderVal) { - return new NppColumnSumFilter(srcType, dstType, ksize, anchor, borderMode, borderVal); + return makePtr(srcType, dstType, ksize, anchor, borderMode, borderVal); } #endif From a007c7b980b2e4ab154d7e94d12e85eba99d90c1 Mon Sep 17 00:00:00 2001 From: Roman Donchenko Date: Tue, 13 Aug 2013 18:15:02 +0400 Subject: [PATCH 23/55] Boring changes - gpuimgproc. --- modules/gpuimgproc/src/canny.cpp | 2 +- modules/gpuimgproc/src/corners.cpp | 4 ++-- modules/gpuimgproc/src/generalized_hough.cpp | 4 ++-- modules/gpuimgproc/src/gftt.cpp | 3 ++- modules/gpuimgproc/src/histogram.cpp | 2 +- modules/gpuimgproc/src/hough_circles.cpp | 2 +- modules/gpuimgproc/src/hough_lines.cpp | 2 +- modules/gpuimgproc/src/hough_segments.cpp | 2 +- modules/gpuimgproc/src/match_template.cpp | 16 ++++++++-------- 9 files changed, 19 insertions(+), 18 deletions(-) diff --git a/modules/gpuimgproc/src/canny.cpp b/modules/gpuimgproc/src/canny.cpp index d6f5e6b032..17f03950f8 100644 --- a/modules/gpuimgproc/src/canny.cpp +++ b/modules/gpuimgproc/src/canny.cpp @@ -228,7 +228,7 @@ namespace Ptr cv::gpu::createCannyEdgeDetector(double low_thresh, double high_thresh, int apperture_size, bool L2gradient) { - return new CannyImpl(low_thresh, high_thresh, apperture_size, L2gradient); + return makePtr(low_thresh, high_thresh, apperture_size, L2gradient); } #endif /* !defined (HAVE_CUDA) */ diff --git a/modules/gpuimgproc/src/corners.cpp b/modules/gpuimgproc/src/corners.cpp index 5df5063274..6b53e6f85c 100644 --- a/modules/gpuimgproc/src/corners.cpp +++ b/modules/gpuimgproc/src/corners.cpp @@ -178,12 +178,12 @@ namespace Ptr cv::gpu::createHarrisCorner(int srcType, int blockSize, int ksize, double k, int borderType) { - return new Harris(srcType, blockSize, ksize, k, borderType); + return makePtr(srcType, blockSize, ksize, k, borderType); } Ptr cv::gpu::createMinEigenValCorner(int srcType, int blockSize, int ksize, int borderType) { - return new MinEigenVal(srcType, blockSize, ksize, borderType); + return makePtr(srcType, blockSize, ksize, borderType); } #endif /* !defined (HAVE_CUDA) */ diff --git a/modules/gpuimgproc/src/generalized_hough.cpp b/modules/gpuimgproc/src/generalized_hough.cpp index 6adfcb7a26..abcd3ef496 100644 --- a/modules/gpuimgproc/src/generalized_hough.cpp +++ b/modules/gpuimgproc/src/generalized_hough.cpp @@ -554,7 +554,7 @@ namespace Ptr cv::gpu::createGeneralizedHoughBallard() { - return new GeneralizedHoughBallardImpl; + return makePtr(); } // GeneralizedHoughGuil @@ -900,7 +900,7 @@ namespace Ptr cv::gpu::createGeneralizedHoughGuil() { - return new GeneralizedHoughGuilImpl; + return makePtr(); } #endif /* !defined (HAVE_CUDA) */ diff --git a/modules/gpuimgproc/src/gftt.cpp b/modules/gpuimgproc/src/gftt.cpp index ff197d84c2..0446b6cdbb 100644 --- a/modules/gpuimgproc/src/gftt.cpp +++ b/modules/gpuimgproc/src/gftt.cpp @@ -209,7 +209,8 @@ namespace Ptr cv::gpu::createGoodFeaturesToTrackDetector(int srcType, int maxCorners, double qualityLevel, double minDistance, int blockSize, bool useHarrisDetector, double harrisK) { - return new GoodFeaturesToTrackDetector(srcType, maxCorners, qualityLevel, minDistance, blockSize, useHarrisDetector, harrisK); + return Ptr( + new GoodFeaturesToTrackDetector(srcType, maxCorners, qualityLevel, minDistance, blockSize, useHarrisDetector, harrisK)); } #endif /* !defined (HAVE_CUDA) */ diff --git a/modules/gpuimgproc/src/histogram.cpp b/modules/gpuimgproc/src/histogram.cpp index 1baa892055..eb78ee0deb 100644 --- a/modules/gpuimgproc/src/histogram.cpp +++ b/modules/gpuimgproc/src/histogram.cpp @@ -257,7 +257,7 @@ namespace cv::Ptr cv::gpu::createCLAHE(double clipLimit, cv::Size tileGridSize) { - return new CLAHE_Impl(clipLimit, tileGridSize.width, tileGridSize.height); + return makePtr(clipLimit, tileGridSize.width, tileGridSize.height); } //////////////////////////////////////////////////////////////////////// diff --git a/modules/gpuimgproc/src/hough_circles.cpp b/modules/gpuimgproc/src/hough_circles.cpp index fa583c09c7..f123cf5795 100644 --- a/modules/gpuimgproc/src/hough_circles.cpp +++ b/modules/gpuimgproc/src/hough_circles.cpp @@ -291,7 +291,7 @@ namespace Ptr cv::gpu::createHoughCirclesDetector(float dp, float minDist, int cannyThreshold, int votesThreshold, int minRadius, int maxRadius, int maxCircles) { - return new HoughCirclesDetectorImpl(dp, minDist, cannyThreshold, votesThreshold, minRadius, maxRadius, maxCircles); + return makePtr(dp, minDist, cannyThreshold, votesThreshold, minRadius, maxRadius, maxCircles); } #endif /* !defined (HAVE_CUDA) */ diff --git a/modules/gpuimgproc/src/hough_lines.cpp b/modules/gpuimgproc/src/hough_lines.cpp index e0dec305d9..e3e03cba73 100644 --- a/modules/gpuimgproc/src/hough_lines.cpp +++ b/modules/gpuimgproc/src/hough_lines.cpp @@ -196,7 +196,7 @@ namespace Ptr cv::gpu::createHoughLinesDetector(float rho, float theta, int threshold, bool doSort, int maxLines) { - return new HoughLinesDetectorImpl(rho, theta, threshold, doSort, maxLines); + return makePtr(rho, theta, threshold, doSort, maxLines); } #endif /* !defined (HAVE_CUDA) */ diff --git a/modules/gpuimgproc/src/hough_segments.cpp b/modules/gpuimgproc/src/hough_segments.cpp index 1f11be68b2..6f888a2c06 100644 --- a/modules/gpuimgproc/src/hough_segments.cpp +++ b/modules/gpuimgproc/src/hough_segments.cpp @@ -177,7 +177,7 @@ namespace Ptr cv::gpu::createHoughSegmentDetector(float rho, float theta, int minLineLength, int maxLineGap, int maxLines) { - return new HoughSegmentDetectorImpl(rho, theta, minLineLength, maxLineGap, maxLines); + return makePtr(rho, theta, minLineLength, maxLineGap, maxLines); } #endif /* !defined (HAVE_CUDA) */ diff --git a/modules/gpuimgproc/src/match_template.cpp b/modules/gpuimgproc/src/match_template.cpp index 2b5d5cb1ca..aeebd01d94 100644 --- a/modules/gpuimgproc/src/match_template.cpp +++ b/modules/gpuimgproc/src/match_template.cpp @@ -607,10 +607,10 @@ Ptr cv::gpu::createTemplateMatching(int srcType, int meth switch (method) { case TM_SQDIFF: - return new Match_SQDIFF_32F; + return makePtr(); case TM_CCORR: - return new Match_CCORR_32F(user_block_size); + return makePtr(user_block_size); default: CV_Error( Error::StsBadFlag, "Unsopported method" ); @@ -622,22 +622,22 @@ Ptr cv::gpu::createTemplateMatching(int srcType, int meth switch (method) { case TM_SQDIFF: - return new Match_SQDIFF_8U(user_block_size); + return makePtr(user_block_size); case TM_SQDIFF_NORMED: - return new Match_SQDIFF_NORMED_8U(user_block_size); + return makePtr(user_block_size); case TM_CCORR: - return new Match_CCORR_8U(user_block_size); + return makePtr(user_block_size); case TM_CCORR_NORMED: - return new Match_CCORR_NORMED_8U(user_block_size); + return makePtr(user_block_size); case TM_CCOEFF: - return new Match_CCOEFF_8U(user_block_size); + return makePtr(user_block_size); case TM_CCOEFF_NORMED: - return new Match_CCOEFF_NORMED_8U(user_block_size); + return makePtr(user_block_size); default: CV_Error( Error::StsBadFlag, "Unsopported method" ); From d6146e95439bc7f33656405643dbbfba27f3bd22 Mon Sep 17 00:00:00 2001 From: Roman Donchenko Date: Tue, 13 Aug 2013 18:16:41 +0400 Subject: [PATCH 24/55] Boring changes - gpulegacy. --- modules/gpulegacy/src/cuda/NCVHaarObjectDetection.cu | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/gpulegacy/src/cuda/NCVHaarObjectDetection.cu b/modules/gpulegacy/src/cuda/NCVHaarObjectDetection.cu index c8aaaeaced..3ac1e9491d 100644 --- a/modules/gpulegacy/src/cuda/NCVHaarObjectDetection.cu +++ b/modules/gpulegacy/src/cuda/NCVHaarObjectDetection.cu @@ -2138,8 +2138,8 @@ static NCVStatus loadFromXML(const cv::String &filename, haarClassifierNodes.resize(0); haarFeatures.resize(0); - cv::Ptr oldCascade = (CvHaarClassifierCascade*)cvLoad(filename.c_str(), 0, 0, 0); - if (oldCascade.empty()) + cv::Ptr oldCascade((CvHaarClassifierCascade*)cvLoad(filename.c_str(), 0, 0, 0)); + if (!oldCascade) { return NCV_HAAR_XML_LOADING_EXCEPTION; } From d33ff4bb117b7e644e60755ca5e916171545b32f Mon Sep 17 00:00:00 2001 From: Roman Donchenko Date: Tue, 13 Aug 2013 18:17:21 +0400 Subject: [PATCH 25/55] Boring changes - gpustereo. --- modules/gpustereo/src/disparity_bilateral_filter.cpp | 2 +- modules/gpustereo/src/stereobm.cpp | 2 +- modules/gpustereo/src/stereobp.cpp | 2 +- modules/gpustereo/src/stereocsbp.cpp | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/modules/gpustereo/src/disparity_bilateral_filter.cpp b/modules/gpustereo/src/disparity_bilateral_filter.cpp index 689a9e76e3..9808b7f66e 100644 --- a/modules/gpustereo/src/disparity_bilateral_filter.cpp +++ b/modules/gpustereo/src/disparity_bilateral_filter.cpp @@ -200,7 +200,7 @@ namespace Ptr cv::gpu::createDisparityBilateralFilter(int ndisp, int radius, int iters) { - return new DispBilateralFilterImpl(ndisp, radius, iters); + return makePtr(ndisp, radius, iters); } #endif /* !defined (HAVE_CUDA) */ diff --git a/modules/gpustereo/src/stereobm.cpp b/modules/gpustereo/src/stereobm.cpp index 30773a6159..2ef896d574 100644 --- a/modules/gpustereo/src/stereobm.cpp +++ b/modules/gpustereo/src/stereobm.cpp @@ -179,7 +179,7 @@ namespace Ptr cv::gpu::createStereoBM(int numDisparities, int blockSize) { - return new StereoBMImpl(numDisparities, blockSize); + return makePtr(numDisparities, blockSize); } #endif /* !defined (HAVE_CUDA) */ diff --git a/modules/gpustereo/src/stereobp.cpp b/modules/gpustereo/src/stereobp.cpp index ac3bcfe339..f1ea9adf41 100644 --- a/modules/gpustereo/src/stereobp.cpp +++ b/modules/gpustereo/src/stereobp.cpp @@ -361,7 +361,7 @@ namespace Ptr cv::gpu::createStereoBeliefPropagation(int ndisp, int iters, int levels, int msg_type) { - return new StereoBPImpl(ndisp, iters, levels, msg_type); + return makePtr(ndisp, iters, levels, msg_type); } void cv::gpu::StereoBeliefPropagation::estimateRecommendedParams(int width, int height, int& ndisp, int& iters, int& levels) diff --git a/modules/gpustereo/src/stereocsbp.cpp b/modules/gpustereo/src/stereocsbp.cpp index 9afd8d14e2..b1135b2765 100644 --- a/modules/gpustereo/src/stereocsbp.cpp +++ b/modules/gpustereo/src/stereocsbp.cpp @@ -366,7 +366,7 @@ namespace Ptr cv::gpu::createStereoConstantSpaceBP(int ndisp, int iters, int levels, int nr_plane, int msg_type) { - return new StereoCSBPImpl(ndisp, iters, levels, nr_plane, msg_type); + return makePtr(ndisp, iters, levels, nr_plane, msg_type); } void cv::gpu::StereoConstantSpaceBP::estimateRecommendedParams(int width, int height, int& ndisp, int& iters, int& levels, int& nr_plane) From fc0e835762825771530b4ab90cace5c52cf7a638 Mon Sep 17 00:00:00 2001 From: Roman Donchenko Date: Tue, 13 Aug 2013 18:58:46 +0400 Subject: [PATCH 26/55] Boring changes - gpuwarping. --- modules/gpuwarping/src/pyramids.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/gpuwarping/src/pyramids.cpp b/modules/gpuwarping/src/pyramids.cpp index 0e8445df2c..aa86e3a40b 100644 --- a/modules/gpuwarping/src/pyramids.cpp +++ b/modules/gpuwarping/src/pyramids.cpp @@ -237,7 +237,7 @@ Ptr cv::gpu::createImagePyramid(InputArray img, int nLayers, Strea throw_no_cuda(); return Ptr(); #else - return new ImagePyramidImpl(img, nLayers, stream); + return Ptr(new ImagePyramidImpl(img, nLayers, stream)); #endif } From 3bca57ac25a6253554d2c3b2fff8b43ca8026c9e Mon Sep 17 00:00:00 2001 From: Roman Donchenko Date: Tue, 13 Aug 2013 18:18:38 +0400 Subject: [PATCH 27/55] Boring changes - ocl. --- modules/ocl/src/filtering.cpp | 22 +++++++++++----------- modules/ocl/src/imgproc.cpp | 2 +- modules/ocl/src/mcwutil.cpp | 2 +- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/modules/ocl/src/filtering.cpp b/modules/ocl/src/filtering.cpp index 713854299d..4c952b8372 100644 --- a/modules/ocl/src/filtering.cpp +++ b/modules/ocl/src/filtering.cpp @@ -163,7 +163,7 @@ public: Ptr cv::ocl::createFilter2D_GPU(const Ptr filter2D) { - return Ptr(new Filter2DEngine_GPU(filter2D)); + return makePtr(filter2D); } //////////////////////////////////////////////////////////////////////////////////////////////////// @@ -452,7 +452,7 @@ Ptr cv::ocl::createMorphologyFilter_GPU(int op, int type, cons Ptr filter2D = getMorphologyFilter_GPU(op, type, kernel, ksize, anchor); - return Ptr(new MorphologyFilterEngine_GPU(filter2D, iterations)); + return makePtr(filter2D, iterations); } namespace @@ -690,8 +690,8 @@ Ptr cv::ocl::getLinearFilter_GPU(int srcType, int dstType, const normalizeKernel(kernel, gpu_krnl, CV_32FC1); normalizeAnchor(norm_archor, ksize); - return Ptr(new LinearFilter_GPU(ksize, anchor, gpu_krnl, GPUFilter2D_callers[CV_MAT_CN(srcType)], - borderType)); + return makePtr(ksize, anchor, gpu_krnl, GPUFilter2D_callers[CV_MAT_CN(srcType)], + borderType); } Ptr cv::ocl::createLinearFilter_GPU(int srcType, int dstType, const Mat &kernel, const Point &anchor, @@ -773,7 +773,7 @@ public: Ptr cv::ocl::createSeparableFilter_GPU(const Ptr &rowFilter, const Ptr &columnFilter) { - return Ptr(new SeparableFilterEngine_GPU(rowFilter, columnFilter)); + return makePtr(rowFilter, columnFilter); } /* @@ -1044,8 +1044,8 @@ Ptr cv::ocl::getBoxFilter_GPU(int srcType, int dstType, normalizeAnchor(anchor, ksize); - return Ptr(new GPUBoxFilter(ksize, anchor, - borderType, FilterBox_callers[(CV_MAT_DEPTH(srcType) == CV_32F)][CV_MAT_CN(srcType)])); + return makePtr(ksize, anchor, + borderType, FilterBox_callers[(CV_MAT_DEPTH(srcType) == CV_32F)][CV_MAT_CN(srcType)]); } Ptr cv::ocl::createBoxFilter_GPU(int srcType, int dstType, @@ -1228,8 +1228,8 @@ Ptr cv::ocl::getLinearRowFilter_GPU(int srcType, int /*bufTyp normalizeAnchor(anchor, ksize); - return Ptr(new GpuLinearRowFilter(ksize, anchor, mat_kernel, - gpuFilter1D_callers[CV_MAT_DEPTH(srcType)], bordertype)); + return makePtr(ksize, anchor, mat_kernel, + gpuFilter1D_callers[CV_MAT_DEPTH(srcType)], bordertype); } namespace @@ -1397,8 +1397,8 @@ Ptr cv::ocl::getLinearColumnFilter_GPU(int /*bufType*/, in normalizeAnchor(anchor, ksize); - return Ptr(new GpuLinearColumnFilter(ksize, anchor, mat_kernel, - gpuFilter1D_callers[CV_MAT_DEPTH(dstType)], bordertype)); + return makePtr(ksize, anchor, mat_kernel, + gpuFilter1D_callers[CV_MAT_DEPTH(dstType)], bordertype); } Ptr cv::ocl::createSeparableLinearFilter_GPU(int srcType, int dstType, diff --git a/modules/ocl/src/imgproc.cpp b/modules/ocl/src/imgproc.cpp index 143e0e8a91..0dc7fe9cea 100644 --- a/modules/ocl/src/imgproc.cpp +++ b/modules/ocl/src/imgproc.cpp @@ -1692,7 +1692,7 @@ namespace cv cv::Ptr createCLAHE(double clipLimit, cv::Size tileGridSize) { - return new CLAHE_Impl(clipLimit, tileGridSize.width, tileGridSize.height); + return makePtr(clipLimit, tileGridSize.width, tileGridSize.height); } //////////////////////////////////bilateralFilter//////////////////////////////////////////////////// diff --git a/modules/ocl/src/mcwutil.cpp b/modules/ocl/src/mcwutil.cpp index 612165165c..c520cb8d48 100644 --- a/modules/ocl/src/mcwutil.cpp +++ b/modules/ocl/src/mcwutil.cpp @@ -246,7 +246,7 @@ namespace cv Ptr bindTexturePtr(const oclMat &mat) { - return Ptr(new TextureCL(bindTexture(mat), mat.rows, mat.cols, mat.type())); + return makePtr(bindTexture(mat), mat.rows, mat.cols, mat.type()); } void releaseTexture(cl_mem& texture) { From 34127ba80f4394457c5121a814a180e66d900d7d Mon Sep 17 00:00:00 2001 From: Roman Donchenko Date: Tue, 13 Aug 2013 18:24:30 +0400 Subject: [PATCH 28/55] Boring changes - contrib. --- .../contrib/src/detection_based_tracker.cpp | 24 +++++++++---------- modules/contrib/src/facerec.cpp | 6 ++--- modules/contrib/src/featuretracker.cpp | 6 ++--- 3 files changed, 18 insertions(+), 18 deletions(-) diff --git a/modules/contrib/src/detection_based_tracker.cpp b/modules/contrib/src/detection_based_tracker.cpp index 91bb0b1710..27807290af 100644 --- a/modules/contrib/src/detection_based_tracker.cpp +++ b/modules/contrib/src/detection_based_tracker.cpp @@ -128,7 +128,7 @@ cv::DetectionBasedTracker::SeparateDetectionWork::SeparateDetectionWork(Detectio stateThread(STATE_THREAD_STOPPED), timeWhenDetectingThreadStartedWork(-1) { - CV_Assert(!_detector.empty()); + CV_Assert(_detector); cascadeInThread = _detector; @@ -462,11 +462,11 @@ cv::DetectionBasedTracker::DetectionBasedTracker(cv::Ptr mainDetector cascadeForTracking(trackingDetector) { CV_Assert( (params.maxTrackLifetime >= 0) -// && (!mainDetector.empty()) - && (!trackingDetector.empty()) ); +// && mainDetector + && trackingDetector ); - if (!mainDetector.empty()) { - separateDetectionWork = new SeparateDetectionWork(*this, mainDetector); + if (mainDetector) { + separateDetectionWork.reset(new SeparateDetectionWork(*this, mainDetector)); } weightsPositionsSmoothing.push_back(1); @@ -483,7 +483,7 @@ void DetectionBasedTracker::process(const Mat& imageGray) { CV_Assert(imageGray.type()==CV_8UC1); - if ( (!separateDetectionWork.empty()) && (!separateDetectionWork->isWorking()) ) { + if ( separateDetectionWork && !separateDetectionWork->isWorking() ) { separateDetectionWork->run(); } @@ -501,7 +501,7 @@ void DetectionBasedTracker::process(const Mat& imageGray) std::vector rectsWhereRegions; bool shouldHandleResult=false; - if (!separateDetectionWork.empty()) { + if (separateDetectionWork) { shouldHandleResult = separateDetectionWork->communicateWithDetectingThread(imageGray, rectsWhereRegions); } @@ -589,7 +589,7 @@ void cv::DetectionBasedTracker::getObjects(std::vector& result) const bool cv::DetectionBasedTracker::run() { - if (!separateDetectionWork.empty()) { + if (separateDetectionWork) { return separateDetectionWork->run(); } return false; @@ -597,14 +597,14 @@ bool cv::DetectionBasedTracker::run() void cv::DetectionBasedTracker::stop() { - if (!separateDetectionWork.empty()) { + if (separateDetectionWork) { separateDetectionWork->stop(); } } void cv::DetectionBasedTracker::resetTracking() { - if (!separateDetectionWork.empty()) { + if (separateDetectionWork) { separateDetectionWork->resetTracking(); } trackedObjects.clear(); @@ -876,11 +876,11 @@ bool cv::DetectionBasedTracker::setParameters(const Parameters& params) return false; } - if (!separateDetectionWork.empty()) { + if (separateDetectionWork) { separateDetectionWork->lock(); } parameters=params; - if (!separateDetectionWork.empty()) { + if (separateDetectionWork) { separateDetectionWork->unlock(); } return true; diff --git a/modules/contrib/src/facerec.cpp b/modules/contrib/src/facerec.cpp index d1050ebb76..c7e432248c 100644 --- a/modules/contrib/src/facerec.cpp +++ b/modules/contrib/src/facerec.cpp @@ -851,18 +851,18 @@ int LBPH::predict(InputArray _src) const { Ptr createEigenFaceRecognizer(int num_components, double threshold) { - return new Eigenfaces(num_components, threshold); + return makePtr(num_components, threshold); } Ptr createFisherFaceRecognizer(int num_components, double threshold) { - return new Fisherfaces(num_components, threshold); + return makePtr(num_components, threshold); } Ptr createLBPHFaceRecognizer(int radius, int neighbors, int grid_x, int grid_y, double threshold) { - return new LBPH(radius, neighbors, grid_x, grid_y, threshold); + return makePtr(radius, neighbors, grid_x, grid_y, threshold); } CV_INIT_ALGORITHM(Eigenfaces, "FaceRecognizer.Eigenfaces", diff --git a/modules/contrib/src/featuretracker.cpp b/modules/contrib/src/featuretracker.cpp index e14c55c23f..795c1a08fa 100644 --- a/modules/contrib/src/featuretracker.cpp +++ b/modules/contrib/src/featuretracker.cpp @@ -54,7 +54,7 @@ CvFeatureTracker::CvFeatureTracker(CvFeatureTrackerParams _params) : { case CvFeatureTrackerParams::SIFT: dd = Algorithm::create("Feature2D.SIFT"); - if( dd.empty() ) + if( !dd ) CV_Error(CV_StsNotImplemented, "OpenCV has been compiled without SIFT support"); dd->set("nOctaveLayers", 5); dd->set("contrastThreshold", 0.04); @@ -62,7 +62,7 @@ CvFeatureTracker::CvFeatureTracker(CvFeatureTrackerParams _params) : break; case CvFeatureTrackerParams::SURF: dd = Algorithm::create("Feature2D.SURF"); - if( dd.empty() ) + if( !dd ) CV_Error(CV_StsNotImplemented, "OpenCV has been compiled without SURF support"); dd->set("hessianThreshold", 400); dd->set("nOctaves", 3); @@ -73,7 +73,7 @@ CvFeatureTracker::CvFeatureTracker(CvFeatureTrackerParams _params) : break; } - matcher = new BFMatcher(NORM_L2); + matcher = makePtr(int(NORM_L2)); } CvFeatureTracker::~CvFeatureTracker() From eaa7fcc3e617c6e11090466d4ebbed0e98bd7c4a Mon Sep 17 00:00:00 2001 From: Roman Donchenko Date: Tue, 13 Aug 2013 18:29:36 +0400 Subject: [PATCH 29/55] Boring changes - legacy. --- modules/legacy/src/features2d.cpp | 10 +++++----- modules/legacy/src/kdtree.cpp | 2 +- modules/legacy/src/oneway.cpp | 22 ++++++++++++---------- modules/legacy/src/planardetect.cpp | 15 ++++++++------- 4 files changed, 26 insertions(+), 23 deletions(-) diff --git a/modules/legacy/src/features2d.cpp b/modules/legacy/src/features2d.cpp index 578b732928..f313875ac4 100644 --- a/modules/legacy/src/features2d.cpp +++ b/modules/legacy/src/features2d.cpp @@ -73,7 +73,7 @@ cvExtractSURF( const CvArr* _img, const CvArr* _mask, Mat descr; Ptr surf = Algorithm::create("Feature2D.SURF"); - if( surf.empty() ) + if( !surf ) CV_Error(CV_StsNotImplemented, "OpenCV was built without SURF support"); surf->set("hessianThreshold", params.hessianThreshold); @@ -107,10 +107,10 @@ CV_IMPL CvSeq* cvGetStarKeypoints( const CvArr* _img, CvMemStorage* storage, CvStarDetectorParams params ) { - Ptr star = new StarDetector(params.maxSize, params.responseThreshold, - params.lineThresholdProjected, - params.lineThresholdBinarized, - params.suppressNonmaxSize); + Ptr star(new StarDetector(params.maxSize, params.responseThreshold, + params.lineThresholdProjected, + params.lineThresholdBinarized, + params.suppressNonmaxSize)); std::vector kpts; star->detect(cvarrToMat(_img), kpts, Mat()); diff --git a/modules/legacy/src/kdtree.cpp b/modules/legacy/src/kdtree.cpp index a32677b79b..4183950759 100644 --- a/modules/legacy/src/kdtree.cpp +++ b/modules/legacy/src/kdtree.cpp @@ -172,7 +172,7 @@ public: CV_Error(CV_StsUnsupportedFormat, "dist must be CV_64FC1"); if (CV_MAT_TYPE(type()) != CV_MAT_TYPE(desc->type)) { - tmp_desc = cvCreateMat(desc->rows, desc->cols, type()); + tmp_desc.reset(cvCreateMat(desc->rows, desc->cols, type())); cvConvert(desc, tmp_desc); desc = tmp_desc; } diff --git a/modules/legacy/src/oneway.cpp b/modules/legacy/src/oneway.cpp index 7fa4bee33e..43ded85939 100644 --- a/modules/legacy/src/oneway.cpp +++ b/modules/legacy/src/oneway.cpp @@ -1736,7 +1736,7 @@ namespace cv{ { std::vector features; Ptr surf_extractor = FeatureDetector::create("SURF"); - if( surf_extractor.empty() ) + if( !surf_extractor ) CV_Error(CV_StsNotImplemented, "OpenCV was built without SURF support"); surf_extractor->set("hessianThreshold", 1.0); //printf("Extracting SURF features..."); @@ -2186,7 +2186,7 @@ namespace cv{ { clear(); - if( _base.empty() ) + if( !_base ) base = _base; params = _params; @@ -2197,16 +2197,17 @@ namespace cv{ GenericDescriptorMatcher::clear(); prevTrainCount = 0; - if( !base.empty() ) + if( base ) base->clear(); } void OneWayDescriptorMatcher::train() { - if( base.empty() || prevTrainCount < (int)trainPointCollection.keypointCount() ) + if( !base || prevTrainCount < (int)trainPointCollection.keypointCount() ) { - base = new OneWayDescriptorObject( params.patchSize, params.poseCount, params.pcaFilename, - params.trainPath, params.trainImagesList, params.minScale, params.maxScale, params.stepScale ); + base.reset( + new OneWayDescriptorObject( params.patchSize, params.poseCount, params.pcaFilename, + params.trainPath, params.trainImagesList, params.minScale, params.maxScale, params.stepScale )); base->Allocate( (int)trainPointCollection.keypointCount() ); prevTrainCount = (int)trainPointCollection.keypointCount(); @@ -2270,8 +2271,9 @@ namespace cv{ void OneWayDescriptorMatcher::read( const FileNode &fn ) { - base = new OneWayDescriptorObject( params.patchSize, params.poseCount, String (), String (), String (), - params.minScale, params.maxScale, params.stepScale ); + base.reset( + new OneWayDescriptorObject( params.patchSize, params.poseCount, String (), String (), String (), + params.minScale, params.maxScale, params.stepScale )); base->Read (fn); } @@ -2282,12 +2284,12 @@ namespace cv{ bool OneWayDescriptorMatcher::empty() const { - return base.empty() || base->empty(); + return !base || base->empty(); } Ptr OneWayDescriptorMatcher::clone( bool emptyTrainData ) const { - OneWayDescriptorMatcher* matcher = new OneWayDescriptorMatcher( params ); + Ptr matcher = makePtr( params ); if( !emptyTrainData ) { diff --git a/modules/legacy/src/planardetect.cpp b/modules/legacy/src/planardetect.cpp index 2bffea0ed7..fa9152d474 100644 --- a/modules/legacy/src/planardetect.cpp +++ b/modules/legacy/src/planardetect.cpp @@ -1240,7 +1240,7 @@ FernDescriptorMatcher::FernDescriptorMatcher( const Params& _params ) params = _params; if( !params.filename.empty() ) { - classifier = new FernClassifier; + classifier = makePtr(); FileStorage fs(params.filename, FileStorage::READ); if( fs.isOpened() ) classifier->read( fs.getFirstTopLevelNode() ); @@ -1260,7 +1260,7 @@ void FernDescriptorMatcher::clear() void FernDescriptorMatcher::train() { - if( classifier.empty() || prevTrainCount < (int)trainPointCollection.keypointCount() ) + if( !classifier || prevTrainCount < (int)trainPointCollection.keypointCount() ) { assert( params.filename.empty() ); @@ -1268,9 +1268,10 @@ void FernDescriptorMatcher::train() for( size_t imgIdx = 0; imgIdx < trainPointCollection.imageCount(); imgIdx++ ) KeyPoint::convert( trainPointCollection.getKeypoints((int)imgIdx), points[imgIdx] ); - classifier = new FernClassifier( points, trainPointCollection.getImages(), std::vector >(), 0, // each points is a class - params.patchSize, params.signatureSize, params.nstructs, params.structSize, - params.nviews, params.compressionMethod, params.patchGenerator ); + classifier.reset( + new FernClassifier( points, trainPointCollection.getImages(), std::vector >(), 0, // each points is a class + params.patchSize, params.signatureSize, params.nstructs, params.structSize, + params.nviews, params.compressionMethod, params.patchGenerator )); } } @@ -1384,12 +1385,12 @@ void FernDescriptorMatcher::write( FileStorage& fs ) const bool FernDescriptorMatcher::empty() const { - return classifier.empty() || classifier->empty(); + return !classifier || classifier->empty(); } Ptr FernDescriptorMatcher::clone( bool emptyTrainData ) const { - FernDescriptorMatcher* matcher = new FernDescriptorMatcher( params ); + Ptr matcher = makePtr( params ); if( !emptyTrainData ) { CV_Error( CV_StsNotImplemented, "deep clone dunctionality is not implemented, because " From 34af7eeb84843c244662e0bca07be88ba566237c Mon Sep 17 00:00:00 2001 From: Roman Donchenko Date: Tue, 13 Aug 2013 18:33:06 +0400 Subject: [PATCH 30/55] Boring changes - apps. --- apps/traincascade/cascadeclassifier.cpp | 34 +++++++++++-------------- apps/traincascade/traincascade.cpp | 6 ++--- 2 files changed, 18 insertions(+), 22 deletions(-) diff --git a/apps/traincascade/cascadeclassifier.cpp b/apps/traincascade/cascadeclassifier.cpp index 3983a614fd..5c96b45f76 100644 --- a/apps/traincascade/cascadeclassifier.cpp +++ b/apps/traincascade/cascadeclassifier.cpp @@ -159,10 +159,10 @@ bool CvCascadeClassifier::train( const string _cascadeDirName, cascadeParams = _cascadeParams; featureParams = CvFeatureParams::create(cascadeParams.featureType); featureParams->init(_featureParams); - stageParams = new CvCascadeBoostParams; + stageParams = makePtr(); *stageParams = _stageParams; featureEvaluator = CvFeatureEvaluator::create(cascadeParams.featureType); - featureEvaluator->init( (CvFeatureParams*)featureParams, numPos + numNeg, cascadeParams.winSize ); + featureEvaluator->init( featureParams, numPos + numNeg, cascadeParams.winSize ); stageClassifiers.reserve( numStages ); } cout << "PARAMETERS:" << endl; @@ -206,10 +206,10 @@ bool CvCascadeClassifier::train( const string _cascadeDirName, break; } - CvCascadeBoost* tempStage = new CvCascadeBoost; - bool isStageTrained = tempStage->train( (CvFeatureEvaluator*)featureEvaluator, + Ptr tempStage = makePtr(); + bool isStageTrained = tempStage->train( featureEvaluator, curNumSamples, _precalcValBufSize, _precalcIdxBufSize, - *((CvCascadeBoostParams*)stageParams) ); + *stageParams ); cout << "END>" << endl; if(!isStageTrained) @@ -325,7 +325,7 @@ void CvCascadeClassifier::writeParams( FileStorage &fs ) const void CvCascadeClassifier::writeFeatures( FileStorage &fs, const Mat& featureMap ) const { - ((CvFeatureEvaluator*)((Ptr)featureEvaluator))->writeFeatures( fs, featureMap ); + featureEvaluator->writeFeatures( fs, featureMap ); } void CvCascadeClassifier::writeStages( FileStorage &fs, const Mat& featureMap ) const @@ -339,7 +339,7 @@ void CvCascadeClassifier::writeStages( FileStorage &fs, const Mat& featureMap ) sprintf( cmnt, "stage %d", i ); cvWriteComment( fs.fs, cmnt, 0 ); fs << "{"; - ((CvCascadeBoost*)((Ptr)*it))->write( fs, featureMap ); + (*it)->write( fs, featureMap ); fs << "}"; } fs << "]"; @@ -350,7 +350,7 @@ bool CvCascadeClassifier::readParams( const FileNode &node ) if ( !node.isMap() || !cascadeParams.read( node ) ) return false; - stageParams = new CvCascadeBoostParams; + stageParams = makePtr(); FileNode rnode = node[CC_STAGE_PARAMS]; if ( !stageParams->read( rnode ) ) return false; @@ -371,12 +371,9 @@ bool CvCascadeClassifier::readStages( const FileNode &node) FileNodeIterator it = rnode.begin(); for( int i = 0; i < min( (int)rnode.size(), numStages ); i++, it++ ) { - CvCascadeBoost* tempStage = new CvCascadeBoost; - if ( !tempStage->read( *it, (CvFeatureEvaluator *)featureEvaluator, *((CvCascadeBoostParams*)stageParams) ) ) - { - delete tempStage; + Ptr tempStage = makePtr(); + if ( !tempStage->read( *it, featureEvaluator, *stageParams) ) return false; - } stageClassifiers.push_back(tempStage); } return true; @@ -453,7 +450,7 @@ void CvCascadeClassifier::save( const string filename, bool baseFormat ) fs << "{"; fs << ICV_HAAR_FEATURE_NAME << "{"; - ((CvHaarEvaluator*)((CvFeatureEvaluator*)featureEvaluator))->writeFeature( fs, tempNode->split->var_idx ); + ((CvHaarEvaluator*)featureEvaluator.get())->writeFeature( fs, tempNode->split->var_idx ); fs << "}"; fs << ICV_HAAR_THRESHOLD_NAME << tempNode->split->ord.c; @@ -499,7 +496,7 @@ bool CvCascadeClassifier::load( const string cascadeDirName ) if ( !readParams( node ) ) return false; featureEvaluator = CvFeatureEvaluator::create(cascadeParams.featureType); - featureEvaluator->init( ((CvFeatureParams*)featureParams), numPos + numNeg, cascadeParams.winSize ); + featureEvaluator->init( featureParams, numPos + numNeg, cascadeParams.winSize ); fs.release(); char buf[10]; @@ -510,11 +507,10 @@ bool CvCascadeClassifier::load( const string cascadeDirName ) node = fs.getFirstTopLevelNode(); if ( !fs.isOpened() ) break; - CvCascadeBoost *tempStage = new CvCascadeBoost; + Ptr tempStage = makePtr(); - if ( !tempStage->read( node, (CvFeatureEvaluator*)featureEvaluator, *((CvCascadeBoostParams*)stageParams )) ) + if ( !tempStage->read( node, featureEvaluator, *stageParams )) { - delete tempStage; fs.release(); break; } @@ -531,7 +527,7 @@ void CvCascadeClassifier::getUsedFeaturesIdxMap( Mat& featureMap ) for( vector< Ptr >::const_iterator it = stageClassifiers.begin(); it != stageClassifiers.end(); it++ ) - ((CvCascadeBoost*)((Ptr)(*it)))->markUsedFeaturesInMap( featureMap ); + (*it)->markUsedFeaturesInMap( featureMap ); for( int fi = 0, idx = 0; fi < varCount; fi++ ) if ( featureMap.at(0, fi) >= 0 ) diff --git a/apps/traincascade/traincascade.cpp b/apps/traincascade/traincascade.cpp index 7b8fcddd84..a896c216c9 100644 --- a/apps/traincascade/traincascade.cpp +++ b/apps/traincascade/traincascade.cpp @@ -18,9 +18,9 @@ int main( int argc, char* argv[] ) CvCascadeParams cascadeParams; CvCascadeBoostParams stageParams; - Ptr featureParams[] = { Ptr(new CvHaarFeatureParams), - Ptr(new CvLBPFeatureParams), - Ptr(new CvHOGFeatureParams) + Ptr featureParams[] = { makePtr(), + makePtr(), + makePtr() }; int fc = sizeof(featureParams)/sizeof(featureParams[0]); if( argc == 1 ) From 62353b7980d438d5cfa63a0a2df75353c91ea300 Mon Sep 17 00:00:00 2001 From: Roman Donchenko Date: Tue, 13 Aug 2013 18:49:29 +0400 Subject: [PATCH 31/55] Boring changes - samples. --- .../jni/DetectionBasedTracker_jni.cpp | 14 +-- samples/cpp/bagofwords_classification.cpp | 6 +- samples/cpp/bgfg_gmg.cpp | 2 +- samples/cpp/dbt_face_detection.cpp | 10 +-- samples/cpp/descriptor_extractor_matcher.cpp | 4 +- .../cpp/detection_based_tracker_sample.cpp | 10 +-- .../cpp/detector_descriptor_evaluation.cpp | 46 +++++----- samples/cpp/fabmap_sample.cpp | 12 +-- samples/cpp/generic_descriptor_match.cpp | 2 +- samples/cpp/image.cpp | 4 +- samples/cpp/linemod.cpp | 2 +- samples/cpp/matching_to_many_images.cpp | 2 +- samples/cpp/stitching_detailed.cpp | 90 +++++++++++-------- .../interoperability_with_OpenCV_1.cpp | 4 +- samples/cpp/video_homography.cpp | 2 +- samples/cpp/videostab.cpp | 70 +++++++-------- samples/gpu/performance/tests.cpp | 2 +- samples/gpu/stereo_multi.cpp | 4 +- samples/gpu/super_resolution.cpp | 8 +- 19 files changed, 158 insertions(+), 136 deletions(-) diff --git a/samples/android/face-detection/jni/DetectionBasedTracker_jni.cpp b/samples/android/face-detection/jni/DetectionBasedTracker_jni.cpp index e0e53e3701..33a8334c6a 100644 --- a/samples/android/face-detection/jni/DetectionBasedTracker_jni.cpp +++ b/samples/android/face-detection/jni/DetectionBasedTracker_jni.cpp @@ -26,7 +26,7 @@ public: Detector(detector) { LOGD("CascadeDetectorAdapter::Detect::Detect"); - CV_Assert(!detector.empty()); + CV_Assert(detector); } void detect(const cv::Mat &Image, std::vector &objects) @@ -57,11 +57,11 @@ struct DetectorAgregator mainDetector(_mainDetector), trackingDetector(_trackingDetector) { - CV_Assert(!_mainDetector.empty()); - CV_Assert(!_trackingDetector.empty()); + CV_Assert(_mainDetector); + CV_Assert(_trackingDetector); DetectionBasedTracker::Parameters DetectorParams; - tracker = new DetectionBasedTracker(mainDetector.ptr(), trackingDetector.ptr(), DetectorParams); + tracker = makePtr(mainDetector, trackingDetector, DetectorParams); } }; @@ -77,8 +77,10 @@ JNIEXPORT jlong JNICALL Java_org_opencv_samples_facedetect_DetectionBasedTracker try { - cv::Ptr mainDetector = new CascadeDetectorAdapter(new CascadeClassifier(stdFileName)); - cv::Ptr trackingDetector = new CascadeDetectorAdapter(new CascadeClassifier(stdFileName)); + cv::Ptr mainDetector = makePtr( + makePtr(stdFileName)); + cv::Ptr trackingDetector = makePtr( + makePtr(stdFileName)); result = (jlong)new DetectorAgregator(mainDetector, trackingDetector); if (faceSize > 0) { diff --git a/samples/cpp/bagofwords_classification.cpp b/samples/cpp/bagofwords_classification.cpp index e24a770f8e..4506e5b9de 100644 --- a/samples/cpp/bagofwords_classification.cpp +++ b/samples/cpp/bagofwords_classification.cpp @@ -2563,19 +2563,19 @@ int main(int argc, char** argv) Ptr featureDetector = FeatureDetector::create( ddmParams.detectorType ); Ptr descExtractor = DescriptorExtractor::create( ddmParams.descriptorType ); Ptr bowExtractor; - if( featureDetector.empty() || descExtractor.empty() ) + if( !featureDetector || !descExtractor ) { cout << "featureDetector or descExtractor was not created" << endl; return -1; } { Ptr descMatcher = DescriptorMatcher::create( ddmParams.matcherType ); - if( featureDetector.empty() || descExtractor.empty() || descMatcher.empty() ) + if( !featureDetector || !descExtractor || !descMatcher ) { cout << "descMatcher was not created" << endl; return -1; } - bowExtractor = new BOWImgDescriptorExtractor( descExtractor, descMatcher ); + bowExtractor = makePtr( descExtractor, descMatcher ); } // Print configuration to screen diff --git a/samples/cpp/bgfg_gmg.cpp b/samples/cpp/bgfg_gmg.cpp index ea1df98d08..226eea4635 100644 --- a/samples/cpp/bgfg_gmg.cpp +++ b/samples/cpp/bgfg_gmg.cpp @@ -35,7 +35,7 @@ int main(int argc, char** argv) setNumThreads(8); Ptr fgbg = createBackgroundSubtractorGMG(20, 0.7); - if (fgbg.empty()) + if (!fgbg) { std::cerr << "Failed to create BackgroundSubtractor.GMG Algorithm." << std::endl; return -1; diff --git a/samples/cpp/dbt_face_detection.cpp b/samples/cpp/dbt_face_detection.cpp index c2e6d0a815..651eaff73f 100644 --- a/samples/cpp/dbt_face_detection.cpp +++ b/samples/cpp/dbt_face_detection.cpp @@ -22,7 +22,7 @@ class CascadeDetectorAdapter: public DetectionBasedTracker::IDetector IDetector(), Detector(detector) { - CV_Assert(!detector.empty()); + CV_Assert(detector); } void detect(const cv::Mat &Image, std::vector &objects) @@ -51,11 +51,11 @@ int main(int , char** ) } std::string cascadeFrontalfilename = "../../data/lbpcascades/lbpcascade_frontalface.xml"; - cv::Ptr cascade = new cv::CascadeClassifier(cascadeFrontalfilename); - cv::Ptr MainDetector = new CascadeDetectorAdapter(cascade); + cv::Ptr cascade = makePtr(cascadeFrontalfilename); + cv::Ptr MainDetector = makePtr(cascade); - cascade = new cv::CascadeClassifier(cascadeFrontalfilename); - cv::Ptr TrackingDetector = new CascadeDetectorAdapter(cascade); + cascade = makePtr(cascadeFrontalfilename); + cv::Ptr TrackingDetector = makePtr(cascade); DetectionBasedTracker::Parameters params; DetectionBasedTracker Detector(MainDetector, TrackingDetector, params); diff --git a/samples/cpp/descriptor_extractor_matcher.cpp b/samples/cpp/descriptor_extractor_matcher.cpp index 43baed2fe5..7df3cd02b0 100644 --- a/samples/cpp/descriptor_extractor_matcher.cpp +++ b/samples/cpp/descriptor_extractor_matcher.cpp @@ -153,7 +153,7 @@ static void doIteration( const Mat& img1, Mat& img2, bool isWarpPerspective, { cout << "< Evaluate descriptor matcher..." << endl; vector curve; - Ptr gdm = new VectorDescriptorMatcher( descriptorExtractor, descriptorMatcher ); + Ptr gdm = makePtr( descriptorExtractor, descriptorMatcher ); evaluateGenericDescriptorMatcher( img1, img2, H12, keypoints1, keypoints2, 0, 0, curve, gdm ); Point2f firstPoint = *curve.begin(); @@ -253,7 +253,7 @@ int main(int argc, char** argv) int mactherFilterType = getMatcherFilterType( argv[4] ); bool eval = !isWarpPerspective ? false : (atoi(argv[6]) == 0 ? false : true); cout << ">" << endl; - if( detector.empty() || descriptorExtractor.empty() || descriptorMatcher.empty() ) + if( !detector || !descriptorExtractor || !descriptorMatcher ) { cout << "Can not create detector or descriptor exstractor or descriptor matcher of given types" << endl; return -1; diff --git a/samples/cpp/detection_based_tracker_sample.cpp b/samples/cpp/detection_based_tracker_sample.cpp index 1debff7e3f..81afa789c3 100644 --- a/samples/cpp/detection_based_tracker_sample.cpp +++ b/samples/cpp/detection_based_tracker_sample.cpp @@ -67,7 +67,7 @@ class CascadeDetectorAdapter: public DetectionBasedTracker::IDetector CascadeDetectorAdapter(cv::Ptr detector): Detector(detector) { - CV_Assert(!detector.empty()); + CV_Assert(detector); } void detect(const cv::Mat &Image, std::vector &objects) @@ -117,11 +117,11 @@ static int test_FaceDetector(int argc, char *argv[]) } std::string cascadeFrontalfilename=cascadefile; - cv::Ptr cascade = new cv::CascadeClassifier(cascadeFrontalfilename); - cv::Ptr MainDetector = new CascadeDetectorAdapter(cascade); + cv::Ptr cascade = makePtr(cascadeFrontalfilename); + cv::Ptr MainDetector = makePtr(cascade); - cascade = new cv::CascadeClassifier(cascadeFrontalfilename); - cv::Ptr TrackingDetector = new CascadeDetectorAdapter(cascade); + cascade = makePtr(cascadeFrontalfilename); + cv::Ptr TrackingDetector = makePtr(cascade); DetectionBasedTracker::Parameters params; DetectionBasedTracker fd(MainDetector, TrackingDetector, params); diff --git a/samples/cpp/detector_descriptor_evaluation.cpp b/samples/cpp/detector_descriptor_evaluation.cpp index ece735a506..dd3cd800e5 100644 --- a/samples/cpp/detector_descriptor_evaluation.cpp +++ b/samples/cpp/detector_descriptor_evaluation.cpp @@ -535,7 +535,7 @@ void DetectorQualityEvaluator::readAlgorithm () { defaultDetector = FeatureDetector::create( algName ); specificDetector = FeatureDetector::create( algName ); - if( defaultDetector.empty() ) + if( !defaultDetector ) { printf( "Algorithm can not be read\n" ); exit(-1); @@ -769,14 +769,14 @@ void DescriptorQualityEvaluator::readAlgorithm( ) defaultDescMatcher = GenericDescriptorMatcher::create( algName ); specificDescMatcher = GenericDescriptorMatcher::create( algName ); - if( defaultDescMatcher.empty() ) + if( !defaultDescMatcher ) { Ptr extractor = DescriptorExtractor::create( algName ); Ptr matcher = DescriptorMatcher::create( matcherName ); - defaultDescMatcher = new VectorDescriptorMatch( extractor, matcher ); - specificDescMatcher = new VectorDescriptorMatch( extractor, matcher ); + defaultDescMatcher = makePtr( extractor, matcher ); + specificDescMatcher = makePtr( extractor, matcher ); - if( extractor.empty() || matcher.empty() ) + if( !extractor || !matcher ) { printf("Algorithm can not be read\n"); exit(-1); @@ -881,8 +881,9 @@ public: virtual void readAlgorithm( ) { string classifierFile = data_path + "/features2d/calonder_classifier.rtc"; - defaultDescMatcher = new VectorDescriptorMatch( new CalonderDescriptorExtractor( classifierFile ), - new BFMatcher(NORM_L2) ); + defaultDescMatcher = makePtr( + makePtr >( classifierFile ), + makePtr(int(NORM_L2))); specificDescMatcher = defaultDescMatcher; } }; @@ -922,10 +923,11 @@ void OneWayDescriptorQualityTest::processRunParamsFile () readAllDatasetsRunParams(); - OneWayDescriptorBase *base = new OneWayDescriptorBase(patchSize, poseCount, pcaFilename, - trainPath, trainImagesList); + Ptr base( + new OneWayDescriptorBase(patchSize, poseCount, pcaFilename, + trainPath, trainImagesList)); - OneWayDescriptorMatch *match = new OneWayDescriptorMatch (); + Ptr match = makePtr(); match->initialize( OneWayDescriptorMatch::Params (), base ); defaultDescMatcher = match; writeAllDatasetsRunParams(); @@ -958,18 +960,18 @@ int main( int argc, char** argv ) Ptr evals[] = { - new DetectorQualityEvaluator( "FAST", "quality-detector-fast" ), - new DetectorQualityEvaluator( "GFTT", "quality-detector-gftt" ), - new DetectorQualityEvaluator( "HARRIS", "quality-detector-harris" ), - new DetectorQualityEvaluator( "MSER", "quality-detector-mser" ), - new DetectorQualityEvaluator( "STAR", "quality-detector-star" ), - new DetectorQualityEvaluator( "SIFT", "quality-detector-sift" ), - new DetectorQualityEvaluator( "SURF", "quality-detector-surf" ), - - new DescriptorQualityEvaluator( "SIFT", "quality-descriptor-sift", "BruteForce" ), - new DescriptorQualityEvaluator( "SURF", "quality-descriptor-surf", "BruteForce" ), - new DescriptorQualityEvaluator( "FERN", "quality-descriptor-fern"), - new CalonderDescriptorQualityEvaluator() + makePtr( "FAST", "quality-detector-fast" ), + makePtr( "GFTT", "quality-detector-gftt" ), + makePtr( "HARRIS", "quality-detector-harris" ), + makePtr( "MSER", "quality-detector-mser" ), + makePtr( "STAR", "quality-detector-star" ), + makePtr( "SIFT", "quality-detector-sift" ), + makePtr( "SURF", "quality-detector-surf" ), + + makePtr( "SIFT", "quality-descriptor-sift", "BruteForce" ), + makePtr( "SURF", "quality-descriptor-surf", "BruteForce" ), + makePtr( "FERN", "quality-descriptor-fern"), + makePtr() }; for( size_t i = 0; i < sizeof(evals)/sizeof(evals[0]); i++ ) diff --git a/samples/cpp/fabmap_sample.cpp b/samples/cpp/fabmap_sample.cpp index 75febb1340..cd06b55cb8 100644 --- a/samples/cpp/fabmap_sample.cpp +++ b/samples/cpp/fabmap_sample.cpp @@ -131,11 +131,11 @@ int main(int argc, char * argv[]) { //generate test data cout << "Extracting Test Data from images" << endl << endl; - Ptr detector = + Ptr detector( new DynamicAdaptedFeatureDetector( - AdjusterAdapter::create("STAR"), 130, 150, 5); - Ptr extractor = - new SurfDescriptorExtractor(1000, 4, 2, false, true); + AdjusterAdapter::create("STAR"), 130, 150, 5)); + Ptr extractor( + new SurfDescriptorExtractor(1000, 4, 2, false, true)); Ptr matcher = DescriptorMatcher::create("FlannBased"); @@ -183,8 +183,8 @@ int main(int argc, char * argv[]) { endl; Ptr fabmap; - fabmap = new of2::FabMap2(tree, 0.39, 0, of2::FabMap::SAMPLED | - of2::FabMap::CHOW_LIU); + fabmap.reset(new of2::FabMap2(tree, 0.39, 0, of2::FabMap::SAMPLED | + of2::FabMap::CHOW_LIU)); fabmap->addTraining(trainData); vector matches; diff --git a/samples/cpp/generic_descriptor_match.cpp b/samples/cpp/generic_descriptor_match.cpp index 888c24f7ec..359f3c08e1 100644 --- a/samples/cpp/generic_descriptor_match.cpp +++ b/samples/cpp/generic_descriptor_match.cpp @@ -33,7 +33,7 @@ int main(int argc, char** argv) std::string params_filename = std::string(argv[4]); Ptr descriptorMatcher = GenericDescriptorMatcher::create(alg_name, params_filename); - if( descriptorMatcher.empty() ) + if( !descriptorMatcher ) { printf ("Cannot create descriptor\n"); return 0; diff --git a/samples/cpp/image.cpp b/samples/cpp/image.cpp index 806926b042..80f80c7aff 100644 --- a/samples/cpp/image.cpp +++ b/samples/cpp/image.cpp @@ -31,8 +31,8 @@ int main( int argc, char** argv ) help(); const char* imagename = argc > 1 ? argv[1] : "lena.jpg"; #if DEMO_MIXED_API_USE - Ptr iplimg = cvLoadImage(imagename); // Ptr is safe ref-conting pointer class - if(iplimg.empty()) + Ptr iplimg(cvLoadImage(imagename)); // Ptr is safe ref-counting pointer class + if(!iplimg) { fprintf(stderr, "Can not load image %s\n", imagename); return -1; diff --git a/samples/cpp/linemod.cpp b/samples/cpp/linemod.cpp index 08d2a00354..4d11da36b5 100644 --- a/samples/cpp/linemod.cpp +++ b/samples/cpp/linemod.cpp @@ -114,7 +114,7 @@ private: // Functions to store detector and templates in single XML/YAML file static cv::Ptr readLinemod(const std::string& filename) { - cv::Ptr detector = new cv::linemod::Detector; + cv::Ptr detector = cv::makePtr(); cv::FileStorage fs(filename, cv::FileStorage::READ); detector->read(fs.root()); diff --git a/samples/cpp/matching_to_many_images.cpp b/samples/cpp/matching_to_many_images.cpp index 7a346e3f49..152b400645 100644 --- a/samples/cpp/matching_to_many_images.cpp +++ b/samples/cpp/matching_to_many_images.cpp @@ -84,7 +84,7 @@ static bool createDetectorDescriptorMatcher( const string& detectorType, const s descriptorMatcher = DescriptorMatcher::create( matcherType ); cout << ">" << endl; - bool isCreated = !( featureDetector.empty() || descriptorExtractor.empty() || descriptorMatcher.empty() ); + bool isCreated = featureDetector && descriptorExtractor && descriptorMatcher; if( !isCreated ) cout << "Can not create feature detector or descriptor extractor or descriptor matcher of given types." << endl << ">" << endl; diff --git a/samples/cpp/stitching_detailed.cpp b/samples/cpp/stitching_detailed.cpp index ecf19b494b..a576816d69 100644 --- a/samples/cpp/stitching_detailed.cpp +++ b/samples/cpp/stitching_detailed.cpp @@ -358,14 +358,14 @@ int main(int argc, char* argv[]) { #ifdef HAVE_OPENCV_NONFREE if (try_gpu && gpu::getCudaEnabledDeviceCount() > 0) - finder = new SurfFeaturesFinderGpu(); + finder = makePtr(); else #endif - finder = new SurfFeaturesFinder(); + finder = makePtr(); } else if (features_type == "orb") { - finder = new OrbFeaturesFinder(); + finder = makePtr(); } else { @@ -484,8 +484,8 @@ int main(int argc, char* argv[]) } Ptr adjuster; - if (ba_cost_func == "reproj") adjuster = new detail::BundleAdjusterReproj(); - else if (ba_cost_func == "ray") adjuster = new detail::BundleAdjusterRay(); + if (ba_cost_func == "reproj") adjuster = makePtr(); + else if (ba_cost_func == "ray") adjuster = makePtr(); else { cout << "Unknown bundle adjustment cost function: '" << ba_cost_func << "'.\n"; @@ -555,31 +555,49 @@ int main(int argc, char* argv[]) #ifdef HAVE_OPENCV_GPUWARPING if (try_gpu && gpu::getCudaEnabledDeviceCount() > 0) { - if (warp_type == "plane") warper_creator = new cv::PlaneWarperGpu(); - else if (warp_type == "cylindrical") warper_creator = new cv::CylindricalWarperGpu(); - else if (warp_type == "spherical") warper_creator = new cv::SphericalWarperGpu(); + if (warp_type == "plane") + warper_creator = makePtr(); + else if (warp_type == "cylindrical") + warper_creator = makePtr(); + else if (warp_type == "spherical") + warper_creator = makePtr(); } else #endif { - if (warp_type == "plane") warper_creator = new cv::PlaneWarper(); - else if (warp_type == "cylindrical") warper_creator = new cv::CylindricalWarper(); - else if (warp_type == "spherical") warper_creator = new cv::SphericalWarper(); - else if (warp_type == "fisheye") warper_creator = new cv::FisheyeWarper(); - else if (warp_type == "stereographic") warper_creator = new cv::StereographicWarper(); - else if (warp_type == "compressedPlaneA2B1") warper_creator = new cv::CompressedRectilinearWarper(2, 1); - else if (warp_type == "compressedPlaneA1.5B1") warper_creator = new cv::CompressedRectilinearWarper(1.5, 1); - else if (warp_type == "compressedPlanePortraitA2B1") warper_creator = new cv::CompressedRectilinearPortraitWarper(2, 1); - else if (warp_type == "compressedPlanePortraitA1.5B1") warper_creator = new cv::CompressedRectilinearPortraitWarper(1.5, 1); - else if (warp_type == "paniniA2B1") warper_creator = new cv::PaniniWarper(2, 1); - else if (warp_type == "paniniA1.5B1") warper_creator = new cv::PaniniWarper(1.5, 1); - else if (warp_type == "paniniPortraitA2B1") warper_creator = new cv::PaniniPortraitWarper(2, 1); - else if (warp_type == "paniniPortraitA1.5B1") warper_creator = new cv::PaniniPortraitWarper(1.5, 1); - else if (warp_type == "mercator") warper_creator = new cv::MercatorWarper(); - else if (warp_type == "transverseMercator") warper_creator = new cv::TransverseMercatorWarper(); + if (warp_type == "plane") + warper_creator = makePtr(); + else if (warp_type == "cylindrical") + warper_creator = makePtr(); + else if (warp_type == "spherical") + warper_creator = makePtr(); + else if (warp_type == "fisheye") + warper_creator = makePtr(); + else if (warp_type == "stereographic") + warper_creator = makePtr(); + else if (warp_type == "compressedPlaneA2B1") + warper_creator = makePtr(2.0f, 1.0f); + else if (warp_type == "compressedPlaneA1.5B1") + warper_creator = makePtr(1.5f, 1.0f); + else if (warp_type == "compressedPlanePortraitA2B1") + warper_creator = makePtr(2.0f, 1.0f); + else if (warp_type == "compressedPlanePortraitA1.5B1") + warper_creator = makePtr(1.5f, 1.0f); + else if (warp_type == "paniniA2B1") + warper_creator = makePtr(2.0f, 1.0f); + else if (warp_type == "paniniA1.5B1") + warper_creator = makePtr(1.5f, 1.0f); + else if (warp_type == "paniniPortraitA2B1") + warper_creator = makePtr(2.0f, 1.0f); + else if (warp_type == "paniniPortraitA1.5B1") + warper_creator = makePtr(1.5f, 1.0f); + else if (warp_type == "mercator") + warper_creator = makePtr(); + else if (warp_type == "transverseMercator") + warper_creator = makePtr(); } - if (warper_creator.empty()) + if (!warper_creator) { cout << "Can't create the following warper '" << warp_type << "'\n"; return 1; @@ -612,32 +630,32 @@ int main(int argc, char* argv[]) Ptr seam_finder; if (seam_find_type == "no") - seam_finder = new detail::NoSeamFinder(); + seam_finder = makePtr(); else if (seam_find_type == "voronoi") - seam_finder = new detail::VoronoiSeamFinder(); + seam_finder = makePtr(); else if (seam_find_type == "gc_color") { #ifdef HAVE_OPENCV_GPU if (try_gpu && gpu::getCudaEnabledDeviceCount() > 0) - seam_finder = new detail::GraphCutSeamFinderGpu(GraphCutSeamFinderBase::COST_COLOR); + seam_finder = makePtr(GraphCutSeamFinderBase::COST_COLOR); else #endif - seam_finder = new detail::GraphCutSeamFinder(GraphCutSeamFinderBase::COST_COLOR); + seam_finder = makePtr(GraphCutSeamFinderBase::COST_COLOR); } else if (seam_find_type == "gc_colorgrad") { #ifdef HAVE_OPENCV_GPU if (try_gpu && gpu::getCudaEnabledDeviceCount() > 0) - seam_finder = new detail::GraphCutSeamFinderGpu(GraphCutSeamFinderBase::COST_COLOR_GRAD); + seam_finder = makePtr(GraphCutSeamFinderBase::COST_COLOR_GRAD); else #endif - seam_finder = new detail::GraphCutSeamFinder(GraphCutSeamFinderBase::COST_COLOR_GRAD); + seam_finder = makePtr(GraphCutSeamFinderBase::COST_COLOR_GRAD); } else if (seam_find_type == "dp_color") - seam_finder = new detail::DpSeamFinder(DpSeamFinder::COLOR); + seam_finder = makePtr(DpSeamFinder::COLOR); else if (seam_find_type == "dp_colorgrad") - seam_finder = new detail::DpSeamFinder(DpSeamFinder::COLOR_GRAD); - if (seam_finder.empty()) + seam_finder = makePtr(DpSeamFinder::COLOR_GRAD); + if (!seam_finder) { cout << "Can't create the following seam finder '" << seam_find_type << "'\n"; return 1; @@ -735,7 +753,7 @@ int main(int argc, char* argv[]) resize(dilated_mask, seam_mask, mask_warped.size()); mask_warped = seam_mask & mask_warped; - if (blender.empty()) + if (!blender) { blender = Blender::createDefault(blend_type, try_gpu); Size dst_sz = resultRoi(corners, sizes).size(); @@ -744,13 +762,13 @@ int main(int argc, char* argv[]) blender = Blender::createDefault(Blender::NO, try_gpu); else if (blend_type == Blender::MULTI_BAND) { - MultiBandBlender* mb = dynamic_cast(static_cast(blender)); + MultiBandBlender* mb = dynamic_cast(blender.get()); mb->setNumBands(static_cast(ceil(log(blend_width)/log(2.)) - 1.)); LOGLN("Multi-band blender, number of bands: " << mb->numBands()); } else if (blend_type == Blender::FEATHER) { - FeatherBlender* fb = dynamic_cast(static_cast(blender)); + FeatherBlender* fb = dynamic_cast(blender.get()); fb->setSharpness(1.f/blend_width); LOGLN("Feather blender, sharpness: " << fb->sharpness()); } diff --git a/samples/cpp/tutorial_code/core/interoperability_with_OpenCV_1/interoperability_with_OpenCV_1.cpp b/samples/cpp/tutorial_code/core/interoperability_with_OpenCV_1/interoperability_with_OpenCV_1.cpp index 6c681d643a..e13f2b6960 100644 --- a/samples/cpp/tutorial_code/core/interoperability_with_OpenCV_1/interoperability_with_OpenCV_1.cpp +++ b/samples/cpp/tutorial_code/core/interoperability_with_OpenCV_1/interoperability_with_OpenCV_1.cpp @@ -32,8 +32,8 @@ int main( int argc, char** argv ) const char* imagename = argc > 1 ? argv[1] : "lena.jpg"; #ifdef DEMO_MIXED_API_USE - Ptr IplI = cvLoadImage(imagename); // Ptr is safe ref-counting pointer class - if(IplI.empty()) + Ptr IplI(cvLoadImage(imagename)); // Ptr is a safe ref-counting pointer class + if(!IplI) { cerr << "Can not load image " << imagename << endl; return -1; diff --git a/samples/cpp/video_homography.cpp b/samples/cpp/video_homography.cpp index c8388007dd..bf2559fbaf 100644 --- a/samples/cpp/video_homography.cpp +++ b/samples/cpp/video_homography.cpp @@ -152,7 +152,7 @@ int main(int ac, char ** av) Mat train_desc, query_desc; const int DESIRED_FTRS = 500; - GridAdaptedFeatureDetector detector(new FastFeatureDetector(10, true), DESIRED_FTRS, 4, 4); + GridAdaptedFeatureDetector detector(makePtr(10, true), DESIRED_FTRS, 4, 4); Mat H_prev = Mat::eye(3, 3, CV_32FC1); for (;;) diff --git a/samples/cpp/videostab.cpp b/samples/cpp/videostab.cpp index 21606d4950..01cdcf37f7 100644 --- a/samples/cpp/videostab.cpp +++ b/samples/cpp/videostab.cpp @@ -193,7 +193,7 @@ public: virtual Ptr build() { - MotionEstimatorRansacL2 *est = new MotionEstimatorRansacL2(motionModel(arg(prefix + "model"))); + Ptr est = makePtr(motionModel(arg(prefix + "model"))); RansacParams ransac = est->ransacParams(); if (arg(prefix + "subset") != "auto") @@ -205,10 +205,10 @@ public: est->setMinInlierRatio(argf(prefix + "min-inlier-ratio")); - Ptr outlierRejector = new NullOutlierRejector(); + Ptr outlierRejector = makePtr(); if (arg(prefix + "local-outlier-rejection") == "yes") { - TranslationBasedLocalOutlierRejector *tblor = new TranslationBasedLocalOutlierRejector(); + Ptr tblor = makePtr(); RansacParams ransacParams = tblor->ransacParams(); if (arg(prefix + "thresh") != "auto") ransacParams.thresh = argf(prefix + "thresh"); @@ -219,14 +219,14 @@ public: #if defined(HAVE_OPENCV_GPUIMGPROC) && defined(HAVE_OPENCV_GPU) && defined(HAVE_OPENCV_GPUOPTFLOW) if (gpu) { - KeypointBasedMotionEstimatorGpu *kbest = new KeypointBasedMotionEstimatorGpu(est); + Ptr kbest = makePtr(est); kbest->setOutlierRejector(outlierRejector); return kbest; } #endif - KeypointBasedMotionEstimator *kbest = new KeypointBasedMotionEstimator(est); - kbest->setDetector(new GoodFeaturesToTrackDetector(argi(prefix + "nkps"))); + Ptr kbest = makePtr(est); + kbest->setDetector(makePtr(argi(prefix + "nkps"))); kbest->setOutlierRejector(outlierRejector); return kbest; } @@ -244,12 +244,12 @@ public: virtual Ptr build() { - MotionEstimatorL1 *est = new MotionEstimatorL1(motionModel(arg(prefix + "model"))); + Ptr est = makePtr(motionModel(arg(prefix + "model"))); - Ptr outlierRejector = new NullOutlierRejector(); + Ptr outlierRejector = makePtr(); if (arg(prefix + "local-outlier-rejection") == "yes") { - TranslationBasedLocalOutlierRejector *tblor = new TranslationBasedLocalOutlierRejector(); + Ptr tblor = makePtr(); RansacParams ransacParams = tblor->ransacParams(); if (arg(prefix + "thresh") != "auto") ransacParams.thresh = argf(prefix + "thresh"); @@ -260,14 +260,14 @@ public: #if defined(HAVE_OPENCV_GPUIMGPROC) && defined(HAVE_OPENCV_GPU) && defined(HAVE_OPENCV_GPUOPTFLOW) if (gpu) { - KeypointBasedMotionEstimatorGpu *kbest = new KeypointBasedMotionEstimatorGpu(est); + Ptr kbest = makePtr(est); kbest->setOutlierRejector(outlierRejector); return kbest; } #endif - KeypointBasedMotionEstimator *kbest = new KeypointBasedMotionEstimator(est); - kbest->setDetector(new GoodFeaturesToTrackDetector(argi(prefix + "nkps"))); + Ptr kbest = makePtr(est); + kbest->setDetector(makePtr(argi(prefix + "nkps"))); kbest->setOutlierRejector(outlierRejector); return kbest; } @@ -363,7 +363,7 @@ int main(int argc, const char **argv) // get source video parameters - VideoFileSource *source = new VideoFileSource(inputPath); + Ptr source = makePtr(inputPath); cout << "frame count (rough): " << source->count() << endl; if (arg("fps") == "auto") outputFps = source->fps(); @@ -374,15 +374,15 @@ int main(int argc, const char **argv) Ptr motionEstBuilder; if (arg("lin-prog-motion-est") == "yes") - motionEstBuilder = new MotionEstimatorL1Builder(cmd, arg("gpu") == "yes"); + motionEstBuilder.reset(new MotionEstimatorL1Builder(cmd, arg("gpu") == "yes")); else - motionEstBuilder = new MotionEstimatorRansacL2Builder(cmd, arg("gpu") == "yes"); + motionEstBuilder.reset(new MotionEstimatorRansacL2Builder(cmd, arg("gpu") == "yes")); Ptr wsMotionEstBuilder; if (arg("ws-lp") == "yes") - wsMotionEstBuilder = new MotionEstimatorL1Builder(cmd, arg("gpu") == "yes", "ws-"); + wsMotionEstBuilder.reset(new MotionEstimatorL1Builder(cmd, arg("gpu") == "yes", "ws-")); else - wsMotionEstBuilder = new MotionEstimatorRansacL2Builder(cmd, arg("gpu") == "yes", "ws-"); + wsMotionEstBuilder.reset(new MotionEstimatorRansacL2Builder(cmd, arg("gpu") == "yes", "ws-")); // determine whether we must use one pass or two pass stabilizer bool isTwoPass = @@ -400,7 +400,7 @@ int main(int argc, const char **argv) if (arg("lin-prog-stab") == "yes") { - LpMotionStabilizer *stab = new LpMotionStabilizer(); + Ptr stab = makePtr(); stab->setFrameSize(Size(source->width(), source->height())); stab->setTrimRatio(arg("lps-trim-ratio") == "auto" ? argf("trim-ratio") : argf("lps-trim-ratio")); stab->setWeight1(argf("lps-w1")); @@ -410,18 +410,18 @@ int main(int argc, const char **argv) twoPassStabilizer->setMotionStabilizer(stab); } else if (arg("stdev") == "auto") - twoPassStabilizer->setMotionStabilizer(new GaussianMotionFilter(argi("radius"))); + twoPassStabilizer->setMotionStabilizer(makePtr(argi("radius"))); else - twoPassStabilizer->setMotionStabilizer(new GaussianMotionFilter(argi("radius"), argf("stdev"))); + twoPassStabilizer->setMotionStabilizer(makePtr(argi("radius"), argf("stdev"))); // init wobble suppressor if necessary if (arg("wobble-suppress") == "yes") { - MoreAccurateMotionWobbleSuppressorBase *ws = new MoreAccurateMotionWobbleSuppressor(); + Ptr ws = makePtr(); if (arg("gpu") == "yes") #ifdef HAVE_OPENCV_GPU - ws = new MoreAccurateMotionWobbleSuppressorGpu(); + ws = makePtr(); #else throw runtime_error("OpenCV is built without GPU support"); #endif @@ -433,12 +433,12 @@ int main(int argc, const char **argv) MotionModel model = ws->motionEstimator()->motionModel(); if (arg("load-motions2") != "no") { - ws->setMotionEstimator(new FromFileMotionReader(arg("load-motions2"))); + ws->setMotionEstimator(makePtr(arg("load-motions2"))); ws->motionEstimator()->setMotionModel(model); } if (arg("save-motions2") != "no") { - ws->setMotionEstimator(new ToFileMotionWriter(arg("save-motions2"), ws->motionEstimator())); + ws->setMotionEstimator(makePtr(arg("save-motions2"), ws->motionEstimator())); ws->motionEstimator()->setMotionModel(model); } } @@ -450,26 +450,26 @@ int main(int argc, const char **argv) OnePassStabilizer *onePassStabilizer = new OnePassStabilizer(); stabilizer = onePassStabilizer; if (arg("stdev") == "auto") - onePassStabilizer->setMotionFilter(new GaussianMotionFilter(argi("radius"))); + onePassStabilizer->setMotionFilter(makePtr(argi("radius"))); else - onePassStabilizer->setMotionFilter(new GaussianMotionFilter(argi("radius"), argf("stdev"))); + onePassStabilizer->setMotionFilter(makePtr(argi("radius"), argf("stdev"))); } stabilizer->setFrameSource(source); stabilizer->setMotionEstimator(motionEstBuilder->build()); // cast stabilizer to simple frame source interface to read stabilized frames - stabilizedFrames = dynamic_cast(stabilizer); + stabilizedFrames.reset(dynamic_cast(stabilizer)); MotionModel model = stabilizer->motionEstimator()->motionModel(); if (arg("load-motions") != "no") { - stabilizer->setMotionEstimator(new FromFileMotionReader(arg("load-motions"))); + stabilizer->setMotionEstimator(makePtr(arg("load-motions"))); stabilizer->motionEstimator()->setMotionModel(model); } if (arg("save-motions") != "no") { - stabilizer->setMotionEstimator(new ToFileMotionWriter(arg("save-motions"), stabilizer->motionEstimator())); + stabilizer->setMotionEstimator(makePtr(arg("save-motions"), stabilizer->motionEstimator())); stabilizer->motionEstimator()->setMotionModel(model); } @@ -478,7 +478,7 @@ int main(int argc, const char **argv) // init deblurer if (arg("deblur") == "yes") { - WeightingDeblurer *deblurer = new WeightingDeblurer(); + Ptr deblurer = makePtr(); deblurer->setRadius(argi("radius")); deblurer->setSensitivity(argf("deblur-sens")); stabilizer->setDeblurer(deblurer); @@ -503,22 +503,22 @@ int main(int argc, const char **argv) Ptr inpainters_(inpainters); if (arg("mosaic") == "yes") { - ConsistentMosaicInpainter *inp = new ConsistentMosaicInpainter(); + Ptr inp = makePtr(); inp->setStdevThresh(argf("mosaic-stdev")); inpainters->pushBack(inp); } if (arg("motion-inpaint") == "yes") { - MotionInpainter *inp = new MotionInpainter(); + Ptr inp = makePtr(); inp->setDistThreshold(argf("mi-dist-thresh")); inpainters->pushBack(inp); } if (arg("color-inpaint") == "average") - inpainters->pushBack(new ColorAverageInpainter()); + inpainters->pushBack(makePtr()); else if (arg("color-inpaint") == "ns") - inpainters->pushBack(new ColorInpainter(INPAINT_NS, argd("ci-radius"))); + inpainters->pushBack(makePtr(int(INPAINT_NS), argd("ci-radius"))); else if (arg("color-inpaint") == "telea") - inpainters->pushBack(new ColorInpainter(INPAINT_TELEA, argd("ci-radius"))); + inpainters->pushBack(makePtr(int(INPAINT_TELEA), argd("ci-radius"))); else if (arg("color-inpaint") != "no") throw runtime_error("unknown color inpainting method: " + arg("color-inpaint")); if (!inpainters->empty()) diff --git a/samples/gpu/performance/tests.cpp b/samples/gpu/performance/tests.cpp index 136a4d52a9..a3df43c6e2 100644 --- a/samples/gpu/performance/tests.cpp +++ b/samples/gpu/performance/tests.cpp @@ -1261,7 +1261,7 @@ TEST(FarnebackOpticalFlow) namespace cv { - template<> void Ptr::delete_obj() + template<> void DefaultDeleter::operator ()(CvBGStatModel* obj) const { cvReleaseBGStatModel(&obj); } diff --git a/samples/gpu/stereo_multi.cpp b/samples/gpu/stereo_multi.cpp index 4ad8b28844..430e15bd7b 100644 --- a/samples/gpu/stereo_multi.cpp +++ b/samples/gpu/stereo_multi.cpp @@ -291,11 +291,11 @@ StereoMultiGpuStream::StereoMultiGpuStream() { gpu::setDevice(0); d_algs[0] = gpu::createStereoBM(256); - streams[0] = new Stream; + streams[0] = makePtr(); gpu::setDevice(1); d_algs[1] = gpu::createStereoBM(256); - streams[1] = new Stream; + streams[1] = makePtr(); } StereoMultiGpuStream::~StereoMultiGpuStream() diff --git a/samples/gpu/super_resolution.cpp b/samples/gpu/super_resolution.cpp index 49b0a63322..e124b375e3 100644 --- a/samples/gpu/super_resolution.cpp +++ b/samples/gpu/super_resolution.cpp @@ -53,7 +53,7 @@ static Ptr createOptFlow(const string& name, bool useGpu) { cerr << "Incorrect Optical Flow algorithm - " << name << endl; } - return 0; + return Ptr(); } #if defined(HAVE_OPENCV_OCL) static Ptr createOptFlow(const string& name) @@ -73,7 +73,7 @@ static Ptr createOptFlow(const string& name) else if (name == "brox") { std::cout<<"brox has not been implemented!\n"; - return NULL; + return Ptr(); } else if (name == "pyrlk") return createOptFlow_PyrLK_OCL(); @@ -81,7 +81,7 @@ static Ptr createOptFlow(const string& name) { cerr << "Incorrect Optical Flow algorithm - " << name << endl; } - return 0; + return Ptr(); } #endif int main(int argc, const char* argv[]) @@ -197,7 +197,7 @@ int main(int argc, const char* argv[]) frameSource.release(); } } - if (frameSource.empty()) + if (!frameSource) frameSource = createFrameSource_Video(inputVideoName); // skip first frame, it is usually corrupted From 2a2c21bb632c4f10cd0c7ca12b575c53f33ed82d Mon Sep 17 00:00:00 2001 From: Roman Donchenko Date: Tue, 13 Aug 2013 18:52:06 +0400 Subject: [PATCH 32/55] Replace an incorrect usage of Ptr with a simple vector. --- apps/traincascade/boost.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/traincascade/boost.cpp b/apps/traincascade/boost.cpp index 29ac4bc9af..732704a4a2 100644 --- a/apps/traincascade/boost.cpp +++ b/apps/traincascade/boost.cpp @@ -957,7 +957,7 @@ void CvCascadeBoostTree::write( FileStorage &fs, const Mat& featureMap ) int subsetN = (maxCatCount + 31)/32; queue internalNodesQueue; int size = (int)pow( 2.f, (float)ensemble->get_params().max_depth); - Ptr leafVals = new float[size]; + std::vector leafVals(size); int leafValIdx = 0; int internalNodeIdx = 1; CvDTreeNode* tempNode; From 2f942efdf72591037b9f1674bb8276469e729a35 Mon Sep 17 00:00:00 2001 From: Roman Donchenko Date: Tue, 13 Aug 2013 19:12:25 +0400 Subject: [PATCH 33/55] Java: removed usages of Ptr::addref(). Now the features2d class wrappers use composition instead of inheritance. --- .../generator/src/cpp/features2d_manual.hpp | 232 +++++++++++------- 1 file changed, 146 insertions(+), 86 deletions(-) diff --git a/modules/java/generator/src/cpp/features2d_manual.hpp b/modules/java/generator/src/cpp/features2d_manual.hpp index a51b1eaa30..723f820e08 100644 --- a/modules/java/generator/src/cpp/features2d_manual.hpp +++ b/modules/java/generator/src/cpp/features2d_manual.hpp @@ -11,15 +11,17 @@ namespace cv { -class CV_EXPORTS_AS(FeatureDetector) javaFeatureDetector : public FeatureDetector +class CV_EXPORTS_AS(FeatureDetector) javaFeatureDetector { public: -#if 0 - //DO NOT REMOVE! The block is required for sources parser - CV_WRAP void detect( const Mat& image, CV_OUT std::vector& keypoints, const Mat& mask=Mat() ) const; - CV_WRAP void detect( const std::vector& images, CV_OUT std::vector >& keypoints, const std::vector& masks=std::vector() ) const; - CV_WRAP virtual bool empty() const; -#endif + CV_WRAP void detect( const Mat& image, CV_OUT std::vector& keypoints, const Mat& mask=Mat() ) const + { return wrapped->detect(image, keypoints, mask); } + + CV_WRAP void detect( const std::vector& images, CV_OUT std::vector >& keypoints, const std::vector& masks=std::vector() ) const + { return wrapped->detect(images, keypoints, masks); } + + CV_WRAP bool empty() const + { return wrapped->empty(); } enum { @@ -141,52 +143,74 @@ public: break; } - Ptr detector = FeatureDetector::create(name); - detector.addref(); - return (javaFeatureDetector*)((FeatureDetector*) detector); + return new javaFeatureDetector(FeatureDetector::create(name)); } CV_WRAP void write( const String& fileName ) const { FileStorage fs(fileName, FileStorage::WRITE); - ((FeatureDetector*)this)->write(fs); - fs.release(); + wrapped->write(fs); } CV_WRAP void read( const String& fileName ) { FileStorage fs(fileName, FileStorage::READ); - ((FeatureDetector*)this)->read(fs.root()); - fs.release(); + wrapped->read(fs.root()); } + +private: + javaFeatureDetector(Ptr _wrapped) : wrapped(_wrapped) + {} + + Ptr wrapped; }; -class CV_EXPORTS_AS(DescriptorMatcher) javaDescriptorMatcher : public DescriptorMatcher +class CV_EXPORTS_AS(DescriptorMatcher) javaDescriptorMatcher { public: -#if 0 - //DO NOT REMOVE! The block is required for sources parser - CV_WRAP virtual bool isMaskSupported() const; - CV_WRAP virtual void add( const std::vector& descriptors ); - CV_WRAP const std::vector& getTrainDescriptors() const; - CV_WRAP virtual void clear(); - CV_WRAP virtual bool empty() const; - CV_WRAP virtual void train(); + CV_WRAP bool isMaskSupported() const + { return wrapped->isMaskSupported(); } + + CV_WRAP void add( const std::vector& descriptors ) + { return wrapped->add(descriptors); } + + CV_WRAP const std::vector& getTrainDescriptors() const + { return wrapped->getTrainDescriptors(); } + + CV_WRAP void clear() + { return wrapped->clear(); } + + CV_WRAP bool empty() const + { return wrapped->empty(); } + + CV_WRAP void train() + { return wrapped->train(); } + CV_WRAP void match( const Mat& queryDescriptors, const Mat& trainDescriptors, - CV_OUT std::vector& matches, const Mat& mask=Mat() ) const; + CV_OUT std::vector& matches, const Mat& mask=Mat() ) const + { return wrapped->match(queryDescriptors, trainDescriptors, matches, mask); } + CV_WRAP void knnMatch( const Mat& queryDescriptors, const Mat& trainDescriptors, CV_OUT std::vector >& matches, int k, - const Mat& mask=Mat(), bool compactResult=false ) const; + const Mat& mask=Mat(), bool compactResult=false ) const + { return wrapped->knnMatch(queryDescriptors, trainDescriptors, matches, k, mask, compactResult); } + CV_WRAP void radiusMatch( const Mat& queryDescriptors, const Mat& trainDescriptors, CV_OUT std::vector >& matches, float maxDistance, - const Mat& mask=Mat(), bool compactResult=false ) const; + const Mat& mask=Mat(), bool compactResult=false ) const + { return wrapped->radiusMatch(queryDescriptors, trainDescriptors, matches, maxDistance, mask, compactResult); } + CV_WRAP void match( const Mat& queryDescriptors, CV_OUT std::vector& matches, - const std::vector& masks=std::vector() ); + const std::vector& masks=std::vector() ) + { return wrapped->match(queryDescriptors, matches, masks); } + CV_WRAP void knnMatch( const Mat& queryDescriptors, CV_OUT std::vector >& matches, int k, - const std::vector& masks=std::vector(), bool compactResult=false ); + const std::vector& masks=std::vector(), bool compactResult=false ) + { return wrapped->knnMatch(queryDescriptors, matches, k, masks, compactResult); } + CV_WRAP void radiusMatch( const Mat& queryDescriptors, CV_OUT std::vector >& matches, float maxDistance, - const std::vector& masks=std::vector(), bool compactResult=false ); -#endif + const std::vector& masks=std::vector(), bool compactResult=false ) + { return wrapped->radiusMatch(queryDescriptors, matches, maxDistance, masks, compactResult); } enum { @@ -200,9 +224,7 @@ public: CV_WRAP_AS(clone) javaDescriptorMatcher* jclone( bool emptyTrainData=false ) const { - Ptr matcher = this->clone(emptyTrainData); - matcher.addref(); - return (javaDescriptorMatcher*)((DescriptorMatcher*) matcher); + return new javaDescriptorMatcher(wrapped->clone(emptyTrainData)); } //supported: FlannBased, BruteForce, BruteForce-L1, BruteForce-Hamming, BruteForce-HammingLUT @@ -235,38 +257,45 @@ public: break; } - Ptr matcher = DescriptorMatcher::create(name); - matcher.addref(); - return (javaDescriptorMatcher*)((DescriptorMatcher*) matcher); + return new javaDescriptorMatcher(DescriptorMatcher::create(name)); } CV_WRAP void write( const String& fileName ) const { FileStorage fs(fileName, FileStorage::WRITE); - ((DescriptorMatcher*)this)->write(fs); - fs.release(); + wrapped->write(fs); } CV_WRAP void read( const String& fileName ) { FileStorage fs(fileName, FileStorage::READ); - ((DescriptorMatcher*)this)->read(fs.root()); - fs.release(); + wrapped->read(fs.root()); } + +private: + javaDescriptorMatcher(Ptr _wrapped) : wrapped(_wrapped) + {} + + Ptr wrapped; }; -class CV_EXPORTS_AS(DescriptorExtractor) javaDescriptorExtractor : public DescriptorExtractor +class CV_EXPORTS_AS(DescriptorExtractor) javaDescriptorExtractor { public: -#if 0 - //DO NOT REMOVE! The block is required for sources parser - CV_WRAP void compute( const Mat& image, CV_IN_OUT std::vector& keypoints, Mat& descriptors ) const; - CV_WRAP void compute( const std::vector& images, CV_IN_OUT std::vector >& keypoints, CV_OUT std::vector& descriptors ) const; - CV_WRAP virtual int descriptorSize() const; - CV_WRAP virtual int descriptorType() const; + CV_WRAP void compute( const Mat& image, CV_IN_OUT std::vector& keypoints, Mat& descriptors ) const + { return wrapped->compute(image, keypoints, descriptors); } - CV_WRAP virtual bool empty() const; -#endif + CV_WRAP void compute( const std::vector& images, CV_IN_OUT std::vector >& keypoints, CV_OUT std::vector& descriptors ) const + { return wrapped->compute(images, keypoints, descriptors); } + + CV_WRAP int descriptorSize() const + { return wrapped->descriptorSize(); } + + CV_WRAP int descriptorType() const + { return wrapped->descriptorType(); } + + CV_WRAP bool empty() const + { return wrapped->empty(); } enum { @@ -327,62 +356,93 @@ public: break; } - Ptr extractor = DescriptorExtractor::create(name); - extractor.addref(); - return (javaDescriptorExtractor*)((DescriptorExtractor*) extractor); + return new javaDescriptorExtractor(DescriptorExtractor::create(name)); } CV_WRAP void write( const String& fileName ) const { FileStorage fs(fileName, FileStorage::WRITE); - ((DescriptorExtractor*)this)->write(fs); - fs.release(); + wrapped->write(fs); } CV_WRAP void read( const String& fileName ) { FileStorage fs(fileName, FileStorage::READ); - ((DescriptorExtractor*)this)->read(fs.root()); - fs.release(); + wrapped->read(fs.root()); } + +private: + javaDescriptorExtractor(Ptr _wrapped) : wrapped(_wrapped) + {} + + Ptr wrapped; }; -class CV_EXPORTS_AS(GenericDescriptorMatcher) javaGenericDescriptorMatcher : public GenericDescriptorMatcher +class CV_EXPORTS_AS(GenericDescriptorMatcher) javaGenericDescriptorMatcher { public: -#if 0 - //DO NOT REMOVE! The block is required for sources parser - CV_WRAP virtual void add( const std::vector& images, - std::vector >& keypoints ); - CV_WRAP const std::vector& getTrainImages() const; - CV_WRAP const std::vector >& getTrainKeypoints() const; - CV_WRAP virtual void clear(); - CV_WRAP virtual bool isMaskSupported(); - CV_WRAP virtual void train(); + CV_WRAP void add( const std::vector& images, + std::vector >& keypoints ) + { return wrapped->add(images, keypoints); } + + CV_WRAP const std::vector& getTrainImages() const + { return wrapped->getTrainImages(); } + + CV_WRAP const std::vector >& getTrainKeypoints() const + { return wrapped->getTrainKeypoints(); } + + CV_WRAP void clear() + { return wrapped->clear(); } + + CV_WRAP bool isMaskSupported() + { return wrapped->isMaskSupported(); } + + CV_WRAP void train() + { return wrapped->train(); } + CV_WRAP void classify( const Mat& queryImage, CV_IN_OUT std::vector& queryKeypoints, - const Mat& trainImage, std::vector& trainKeypoints ) const; - CV_WRAP void classify( const Mat& queryImage, CV_IN_OUT std::vector& queryKeypoints ); + const Mat& trainImage, std::vector& trainKeypoints ) const + { return wrapped->classify(queryImage, queryKeypoints, trainImage, trainKeypoints); } + + CV_WRAP void classify( const Mat& queryImage, CV_IN_OUT std::vector& queryKeypoints ) + { return wrapped->classify(queryImage, queryKeypoints); } + CV_WRAP void match( const Mat& queryImage, std::vector& queryKeypoints, const Mat& trainImage, std::vector& trainKeypoints, - CV_OUT std::vector& matches, const Mat& mask=Mat() ) const; + CV_OUT std::vector& matches, const Mat& mask=Mat() ) const + { return wrapped->match(queryImage, queryKeypoints, trainImage, trainKeypoints, matches, mask); } + CV_WRAP void knnMatch( const Mat& queryImage, std::vector& queryKeypoints, const Mat& trainImage, std::vector& trainKeypoints, CV_OUT std::vector >& matches, int k, - const Mat& mask=Mat(), bool compactResult=false ) const; + const Mat& mask=Mat(), bool compactResult=false ) const + { return wrapped->knnMatch(queryImage, queryKeypoints, trainImage, trainKeypoints, + matches, k, mask, compactResult); } + CV_WRAP void radiusMatch( const Mat& queryImage, std::vector& queryKeypoints, const Mat& trainImage, std::vector& trainKeypoints, CV_OUT std::vector >& matches, float maxDistance, - const Mat& mask=Mat(), bool compactResult=false ) const; + const Mat& mask=Mat(), bool compactResult=false ) const + { return wrapped->radiusMatch(queryImage, queryKeypoints, trainImage, trainKeypoints, + matches, maxDistance, mask, compactResult); } + CV_WRAP void match( const Mat& queryImage, std::vector& queryKeypoints, - CV_OUT std::vector& matches, const std::vector& masks=std::vector() ); + CV_OUT std::vector& matches, const std::vector& masks=std::vector() ) + { return wrapped->match(queryImage, queryKeypoints, matches, masks); } + CV_WRAP void knnMatch( const Mat& queryImage, std::vector& queryKeypoints, CV_OUT std::vector >& matches, int k, - const std::vector& masks=std::vector(), bool compactResult=false ); + const std::vector& masks=std::vector(), bool compactResult=false ) + { return wrapped->knnMatch(queryImage, queryKeypoints, matches, k, masks, compactResult); } + CV_WRAP void radiusMatch( const Mat& queryImage, std::vector& queryKeypoints, CV_OUT std::vector >& matches, float maxDistance, - const std::vector& masks=std::vector(), bool compactResult=false ); - CV_WRAP virtual bool empty() const; -#endif + const std::vector& masks=std::vector(), bool compactResult=false ) + { return wrapped->radiusMatch(queryImage, queryKeypoints, matches, maxDistance, masks, compactResult); } + + CV_WRAP bool empty() const + { return wrapped->empty(); } + enum { @@ -392,9 +452,7 @@ public: CV_WRAP_AS(clone) javaGenericDescriptorMatcher* jclone( bool emptyTrainData=false ) const { - Ptr matcher = this->clone(emptyTrainData); - matcher.addref(); - return (javaGenericDescriptorMatcher*)((GenericDescriptorMatcher*) matcher); + return new javaGenericDescriptorMatcher(wrapped->clone(emptyTrainData)); } //supported: OneWay, Fern @@ -416,24 +474,26 @@ public: break; } - Ptr matcher = GenericDescriptorMatcher::create(name); - matcher.addref(); - return (javaGenericDescriptorMatcher*)((GenericDescriptorMatcher*) matcher); + return new javaGenericDescriptorMatcher(GenericDescriptorMatcher::create(name)); } CV_WRAP void write( const String& fileName ) const { FileStorage fs(fileName, FileStorage::WRITE); - ((GenericDescriptorMatcher*)this)->write(fs); - fs.release(); + wrapped->write(fs); } CV_WRAP void read( const String& fileName ) { FileStorage fs(fileName, FileStorage::READ); - ((GenericDescriptorMatcher*)this)->read(fs.root()); - fs.release(); + wrapped->read(fs.root()); } + +private: + javaGenericDescriptorMatcher(Ptr _wrapped) : wrapped(_wrapped) + {} + + Ptr wrapped; }; #if 0 From dadee3752cdb221aea5c5de2bfdbf2c8b4e9b0a8 Mon Sep 17 00:00:00 2001 From: Roman Donchenko Date: Wed, 14 Aug 2013 12:32:41 +0400 Subject: [PATCH 34/55] Adapt Python bindings to the new Ptr. --- modules/python/src2/cv2.cpp | 2 +- modules/python/src2/gen2.py | 88 +++++++++++++++++++++---------------- 2 files changed, 50 insertions(+), 40 deletions(-) diff --git a/modules/python/src2/cv2.cpp b/modules/python/src2/cv2.cpp index e94da958af..6b50abcc53 100644 --- a/modules/python/src2/cv2.cpp +++ b/modules/python/src2/cv2.cpp @@ -1058,7 +1058,7 @@ bool pyopencv_to(PyObject* obj, cv::flann::SearchParams & value, const char * na template bool pyopencv_to(PyObject *o, Ptr& p, const char *name) { - p = new T(); + p = makePtr(); return pyopencv_to(o, *p, name); } diff --git a/modules/python/src2/gen2.py b/modules/python/src2/gen2.py index 816a386c02..c5df21a399 100755 --- a/modules/python/src2/gen2.py +++ b/modules/python/src2/gen2.py @@ -13,20 +13,24 @@ ignored_arg_types = ["RNG*"] gen_template_check_self = Template(""" if(!PyObject_TypeCheck(self, &pyopencv_${name}_Type)) return failmsgp("Incorrect type of self (must be '${name}' or its derivative)"); - $cname* _self_ = ${amp}((pyopencv_${name}_t*)self)->v; + $cname* _self_ = ${amp}((pyopencv_${name}_t*)self)->v${get}; """) gen_template_check_self_algo = Template(""" if(!PyObject_TypeCheck(self, &pyopencv_${name}_Type)) return failmsgp("Incorrect type of self (must be '${name}' or its derivative)"); - $cname* _self_ = dynamic_cast<$cname*>(${amp}((pyopencv_${name}_t*)self)->v.obj); + $cname* _self_ = dynamic_cast<$cname*>(${amp}((pyopencv_${name}_t*)self)->v.get()); """) -gen_template_call_constructor = Template("""self = PyObject_NEW(pyopencv_${name}_t, &pyopencv_${name}_Type); +gen_template_call_constructor_prelude = Template("""self = PyObject_NEW(pyopencv_${name}_t, &pyopencv_${name}_Type); new (&(self->v)) Ptr<$cname>(); // init Ptr with placement new - if(self) ERRWRAP2(self->v = new $cname""") + if(self) """) -gen_template_simple_call_constructor = Template("""self = PyObject_NEW(pyopencv_${name}_t, &pyopencv_${name}_Type); - if(self) ERRWRAP2(self->v = $cname""") +gen_template_call_constructor = Template("""self->v.reset(new ${cname}${args})""") + +gen_template_simple_call_constructor_prelude = Template("""self = PyObject_NEW(pyopencv_${name}_t, &pyopencv_${name}_Type); + if(self) """) + +gen_template_simple_call_constructor = Template("""self->v = ${cname}${args}""") gen_template_parse_args = Template("""const char* keywords[] = { $kw_list, NULL }; if( PyArg_ParseTupleAndKeywords(args, kw, "$fmtspec", (char**)keywords, $parse_arglist)$code_cvt )""") @@ -34,7 +38,7 @@ gen_template_parse_args = Template("""const char* keywords[] = { $kw_list, NULL gen_template_func_body = Template("""$code_decl $code_parse { - $code_fcall; + ${code_prelude}ERRWRAP2($code_fcall); $code_ret; } """) @@ -124,7 +128,7 @@ template<> bool pyopencv_to(PyObject* src, Ptr<${cname}>& dst, const char* name) failmsg("Expected ${cname} for argument '%%s'", name); return false; } - dst = ((pyopencv_${name}_t*)src)->v; + dst = ((pyopencv_${name}_t*)src)->v.dynamicCast<${cname}>(); return true; } @@ -187,7 +191,7 @@ static PyObject* pyopencv_${name}_get_${member}(pyopencv_${name}_t* p, void *clo gen_template_get_prop_algo = Template(""" static PyObject* pyopencv_${name}_get_${member}(pyopencv_${name}_t* p, void *closure) { - return pyopencv_from(dynamic_cast<$cname*>(p->v.obj)${access}${member}); + return pyopencv_from(dynamic_cast<$cname*>(p->v.get())${access}${member}); } """) @@ -211,7 +215,7 @@ static int pyopencv_${name}_set_${member}(pyopencv_${name}_t* p, PyObject *value PyErr_SetString(PyExc_TypeError, "Cannot delete the ${member} attribute"); return -1; } - return pyopencv_to(value, dynamic_cast<$cname*>(p->v.obj)${access}${member}) ? 0 : -1; + return pyopencv_to(value, dynamic_cast<$cname*>(p->v.get())${access}${member}) ? 0 : -1; } """) @@ -559,39 +563,22 @@ class FuncInfo(object): if self.classname: selfinfo = all_classes[self.classname] if not self.isconstructor: - amp = "" - if selfinfo.issimple: - amp = "&" + amp = "&" if selfinfo.issimple else "" if selfinfo.isalgorithm: code += gen_template_check_self_algo.substitute(name=selfinfo.name, cname=selfinfo.cname, amp=amp) else: - code += gen_template_check_self.substitute(name=selfinfo.name, cname=selfinfo.cname, amp=amp) + get = "" if selfinfo.issimple else ".get()" + code += gen_template_check_self.substitute(name=selfinfo.name, cname=selfinfo.cname, amp=amp, get=get) fullname = selfinfo.wname + "." + fullname all_code_variants = [] declno = -1 for v in self.variants: code_decl = "" - code_fcall = "" code_ret = "" code_cvt_list = [] - if self.isconstructor: - code_decl += " pyopencv_%s_t* self = 0;\n" % selfinfo.name - templ = gen_template_call_constructor - if selfinfo.issimple: - templ = gen_template_simple_call_constructor - code_fcall = templ.substitute(name=selfinfo.name, cname=selfinfo.cname) - else: - code_fcall = "ERRWRAP2( " - if v.rettype: - code_decl += " " + v.rettype + " retval;\n" - code_fcall += "retval = " - if ismethod: - code_fcall += "_self_->" + self.cname - else: - code_fcall += self.cname - code_fcall += "(" + code_args = "(" all_cargs = [] parse_arglist = [] @@ -605,9 +592,9 @@ class FuncInfo(object): if not defval and a.tp.endswith("*"): defval = 0 assert defval - if not code_fcall.endswith("("): - code_fcall += ", " - code_fcall += defval + if not code_args.endswith("("): + code_args += ", " + code_args += defval all_cargs.append([[None, ""], ""]) continue tp1 = tp = a.tp @@ -649,11 +636,34 @@ class FuncInfo(object): else: code_decl += " %s %s;\n" % (amapping[0], a.name) - if not code_fcall.endswith("("): - code_fcall += ", " - code_fcall += amp + a.name + if not code_args.endswith("("): + code_args += ", " + code_args += amp + a.name + + code_args += ")" + + if self.isconstructor: + code_decl += " pyopencv_%s_t* self = 0;\n" % selfinfo.name + if selfinfo.issimple: + templ_prelude = gen_template_simple_call_constructor_prelude + templ = gen_template_simple_call_constructor + else: + templ_prelude = gen_template_call_constructor_prelude + templ = gen_template_call_constructor - code_fcall += "))" + code_prelude = templ_prelude.substitute(name=selfinfo.name, cname=selfinfo.cname) + code_fcall = templ.substitute(name=selfinfo.name, cname=selfinfo.cname, args=code_args) + else: + code_prelude = "" + code_fcall = "" + if v.rettype: + code_decl += " " + v.rettype + " retval;\n" + code_fcall += "retval = " + if ismethod: + code_fcall += "_self_->" + self.cname + else: + code_fcall += self.cname + code_fcall += code_args if code_cvt_list: code_cvt_list = [""] + code_cvt_list @@ -706,7 +716,7 @@ class FuncInfo(object): (fmtspec, ", ".join(["pyopencv_from(" + aname + ")" for aname, argno in v.py_outlist])) all_code_variants.append(gen_template_func_body.substitute(code_decl=code_decl, - code_parse=code_parse, code_fcall=code_fcall, code_ret=code_ret)) + code_parse=code_parse, code_prelude=code_prelude, code_fcall=code_fcall, code_ret=code_ret)) if len(all_code_variants)==1: # if the function/method has only 1 signature, then just put it From 24dee16b12ca4fa0def502af2590cd2d35178505 Mon Sep 17 00:00:00 2001 From: Roman Donchenko Date: Wed, 14 Aug 2013 12:41:58 +0400 Subject: [PATCH 35/55] Added to CV_INIT_ALGORITHM a Ptr creation function, for convenience. Also changed the static functions to inline, to stop GCC complaining about unused functions. --- modules/contrib/src/facerec.cpp | 2 +- modules/core/include/opencv2/core/private.hpp | 9 +++++++-- modules/ml/src/ml_init.cpp | 2 +- modules/nonfree/src/nonfree_init.cpp | 2 +- modules/softcascade/src/softcascade_init.cpp | 4 ++-- 5 files changed, 12 insertions(+), 7 deletions(-) diff --git a/modules/contrib/src/facerec.cpp b/modules/contrib/src/facerec.cpp index c7e432248c..1bea74e89e 100644 --- a/modules/contrib/src/facerec.cpp +++ b/modules/contrib/src/facerec.cpp @@ -894,7 +894,7 @@ CV_INIT_ALGORITHM(LBPH, "FaceRecognizer.LBPH", bool initModule_contrib() { - Ptr efaces = createEigenfaces_hidden(), ffaces = createFisherfaces_hidden(), lbph = createLBPH_hidden(); + Ptr efaces = createEigenfaces_ptr_hidden(), ffaces = createFisherfaces_ptr_hidden(), lbph = createLBPH_ptr_hidden(); return efaces->info() != 0 && ffaces->info() != 0 && lbph->info() != 0; } diff --git a/modules/core/include/opencv2/core/private.hpp b/modules/core/include/opencv2/core/private.hpp index c81efafb1f..a1cc0e5c89 100644 --- a/modules/core/include/opencv2/core/private.hpp +++ b/modules/core/include/opencv2/core/private.hpp @@ -128,12 +128,17 @@ namespace cv } //namespace cv #define CV_INIT_ALGORITHM(classname, algname, memberinit) \ - static ::cv::Algorithm* create##classname##_hidden() \ + static inline ::cv::Algorithm* create##classname##_hidden() \ { \ return new classname; \ } \ \ - static ::cv::AlgorithmInfo& classname##_info() \ + static inline ::cv::Ptr< ::cv::Algorithm> create##classname##_ptr_hidden() \ + { \ + return ::cv::makePtr(); \ + } \ + \ + static inline ::cv::AlgorithmInfo& classname##_info() \ { \ static ::cv::AlgorithmInfo classname##_info_var(algname, create##classname##_hidden); \ return classname##_info_var; \ diff --git a/modules/ml/src/ml_init.cpp b/modules/ml/src/ml_init.cpp index 3d6669c263..3ff7d9baee 100644 --- a/modules/ml/src/ml_init.cpp +++ b/modules/ml/src/ml_init.cpp @@ -56,7 +56,7 @@ CV_INIT_ALGORITHM(EM, "StatModel.EM", bool initModule_ml(void) { - Ptr em = createEM_hidden(); + Ptr em = createEM_ptr_hidden(); return em->info() != 0; } diff --git a/modules/nonfree/src/nonfree_init.cpp b/modules/nonfree/src/nonfree_init.cpp index 827853cfd6..ac804dd9a6 100644 --- a/modules/nonfree/src/nonfree_init.cpp +++ b/modules/nonfree/src/nonfree_init.cpp @@ -67,7 +67,7 @@ CV_INIT_ALGORITHM(SIFT, "Feature2D.SIFT", bool initModule_nonfree(void) { - Ptr sift = createSIFT_hidden(), surf = createSURF_hidden(); + Ptr sift = createSIFT_ptr_hidden(), surf = createSURF_ptr_hidden(); return sift->info() != 0 && surf->info() != 0; } diff --git a/modules/softcascade/src/softcascade_init.cpp b/modules/softcascade/src/softcascade_init.cpp index 6978c4a8a8..6f3c8b6a5d 100644 --- a/modules/softcascade/src/softcascade_init.cpp +++ b/modules/softcascade/src/softcascade_init.cpp @@ -58,8 +58,8 @@ CV_INIT_ALGORITHM(SCascade, "CascadeDetector.SCascade", bool initModule_softcascade(void) { - Ptr sc = createSCascade_hidden(); - Ptr sc1 = createDetector_hidden(); + Ptr sc = createSCascade_ptr_hidden(); + Ptr sc1 = createDetector_ptr_hidden(); return (sc1->info() != 0) && (sc->info() != 0); } From 3e189a2b417bbb3f5c7a616815c65be383bad383 Mon Sep 17 00:00:00 2001 From: Roman Donchenko Date: Wed, 14 Aug 2013 12:44:11 +0400 Subject: [PATCH 36/55] Replaced calls to Ptr::ptr to ::dynamicCast. --- modules/core/include/opencv2/core/operations.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/core/include/opencv2/core/operations.hpp b/modules/core/include/opencv2/core/operations.hpp index 58be977cae..f8aeddfb11 100644 --- a/modules/core/include/opencv2/core/operations.hpp +++ b/modules/core/include/opencv2/core/operations.hpp @@ -445,13 +445,13 @@ int print(const Matx<_Tp, m, n>& matx, FILE* stream = stdout) template inline Ptr<_Tp> Algorithm::create(const String& name) { - return _create(name).ptr<_Tp>(); + return _create(name).dynamicCast<_Tp>(); } template inline void Algorithm::set(const char* _name, const Ptr<_Tp>& value) { - Ptr algo_ptr = value. template ptr(); + Ptr algo_ptr = value. template dynamicCast(); if (!algo_ptr) { CV_Error( Error::StsUnsupportedFormat, "unknown/unsupported Ptr type of the second parameter of the method Algorithm::set"); } From a50d75d3624ffb6005cf3c5dd11adf2cbaabf75a Mon Sep 17 00:00:00 2001 From: Roman Donchenko Date: Wed, 14 Aug 2013 12:44:58 +0400 Subject: [PATCH 37/55] Made Filestorage able to not own its CvFileStorage instance. This allows to get rid of the last remaining Ptr::addref calls. --- modules/core/include/opencv2/core/persistence.hpp | 2 +- modules/core/src/persistence.cpp | 6 ++++-- modules/legacy/src/em.cpp | 3 +-- modules/objdetect/src/hog.cpp | 3 +-- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/modules/core/include/opencv2/core/persistence.hpp b/modules/core/include/opencv2/core/persistence.hpp index 73ba2fcb3e..f5687614bb 100644 --- a/modules/core/include/opencv2/core/persistence.hpp +++ b/modules/core/include/opencv2/core/persistence.hpp @@ -186,7 +186,7 @@ public: //! the full constructor that opens file storage for reading or writing CV_WRAP FileStorage(const String& source, int flags, const String& encoding=String()); //! the constructor that takes pointer to the C FileStorage structure - FileStorage(CvFileStorage* fs); + FileStorage(CvFileStorage* fs, bool owning=true); //! the destructor. calls release() virtual ~FileStorage(); diff --git a/modules/core/src/persistence.cpp b/modules/core/src/persistence.cpp index a21ee5a361..39ce633139 100644 --- a/modules/core/src/persistence.cpp +++ b/modules/core/src/persistence.cpp @@ -5129,9 +5129,11 @@ FileStorage::FileStorage(const String& filename, int flags, const String& encodi open( filename, flags, encoding ); } -FileStorage::FileStorage(CvFileStorage* _fs) +FileStorage::FileStorage(CvFileStorage* _fs, bool owning) { - fs = Ptr(_fs); + if (owning) fs.reset(_fs); + else fs = Ptr(Ptr(), _fs); + state = _fs ? NAME_EXPECTED + INSIDE_MAP : UNDEFINED; } diff --git a/modules/legacy/src/em.cpp b/modules/legacy/src/em.cpp index c11c23598d..b49eb91316 100644 --- a/modules/legacy/src/em.cpp +++ b/modules/legacy/src/em.cpp @@ -85,13 +85,12 @@ void CvEM::read( CvFileStorage* fs, CvFileNode* node ) void CvEM::write( CvFileStorage* _fs, const char* name ) const { - FileStorage fs = _fs; + FileStorage fs(_fs, false); if(name) fs << name << "{"; emObj.write(fs); if(name) fs << "}"; - fs.fs.obj = 0; } double CvEM::calcLikelihood( const Mat &input_sample ) const diff --git a/modules/objdetect/src/hog.cpp b/modules/objdetect/src/hog.cpp index 80b5972597..5cc7f6a61b 100644 --- a/modules/objdetect/src/hog.cpp +++ b/modules/objdetect/src/hog.cpp @@ -1353,8 +1353,7 @@ public: { if(ptr && _fs) { - FileStorage fs(_fs); - fs.fs.addref(); + FileStorage fs(_fs, false); ((const _ClsName*)ptr)->write(fs, String(name)); } } From a97ffe651333778cb57cd0ca88a8d1b8c14fe697 Mon Sep 17 00:00:00 2001 From: Roman Donchenko Date: Thu, 15 Aug 2013 14:44:25 +0400 Subject: [PATCH 38/55] Rewrote the documentation for Ptr to fit the new implementation. --- modules/core/doc/basic_structures.rst | 365 ++++++++++++++++++-------- modules/core/doc/intro.rst | 15 +- 2 files changed, 263 insertions(+), 117 deletions(-) diff --git a/modules/core/doc/basic_structures.rst b/modules/core/doc/basic_structures.rst index b1cf053ab5..93e7ca479c 100644 --- a/modules/core/doc/basic_structures.rst +++ b/modules/core/doc/basic_structures.rst @@ -710,187 +710,328 @@ train descriptor index, train image index, and distance between descriptors. :: }; - -.. _Ptr: - Ptr --- .. ocv:class:: Ptr -Template class for smart reference-counting pointers :: +Template class for smart pointers with shared ownership. :: - template class Ptr + template + struct Ptr { - public: - // default constructor + typedef T element_type; + Ptr(); - // constructor that wraps the object pointer - Ptr(_Tp* _obj); - // destructor: calls release() + + template + explicit Ptr(Y* p); + template + Ptr(Y* p, D d); + + Ptr(const Ptr& o); + template + Ptr(const Ptr& o); + template + Ptr(const Ptr& o, T* p); + ~Ptr(); - // copy constructor; increments ptr's reference counter - Ptr(const Ptr& ptr); - // assignment operator; decrements own reference counter - // (with release()) and increments ptr's reference counter - Ptr& operator = (const Ptr& ptr); - // increments reference counter - void addref(); - // decrements reference counter; when it becomes 0, - // delete_obj() is called + + Ptr& operator = (const Ptr& o); + template + Ptr& operator = (const Ptr& o); + void release(); - // user-specified custom object deletion operation. - // by default, "delete obj;" is called - void delete_obj(); - // returns true if obj == 0; + + template + void reset(Y* p); + template + void reset(Y* p, D d); + + void swap(Ptr& o); + + T* get() const; + + T& operator * () const; + T* operator -> () const; + operator T* () const; + bool empty() const; - // provide access to the object fields and methods - _Tp* operator -> (); - const _Tp* operator -> () const; - - // return the underlying object pointer; - // thanks to the methods, the Ptr<_Tp> can be - // used instead of _Tp* - operator _Tp* (); - operator const _Tp*() const; - protected: - // the encapsulated object pointer - _Tp* obj; - // the associated reference counter - int* refcount; + template + Ptr staticCast() const; + template + Ptr constCast() const; + template + Ptr dynamicCast() const; }; -The ``Ptr<_Tp>`` class is a template class that wraps pointers of the corresponding type. It is -similar to ``shared_ptr`` that is part of the Boost library -(http://www.boost.org/doc/libs/1_40_0/libs/smart_ptr/shared_ptr.htm) and also part of the -`C++0x `_ standard. +A ``Ptr`` pretends to be a pointer to an object of type T. +Unlike an ordinary pointer, however, the object will be automatically +cleaned up once all ``Ptr`` instances pointing to it are destroyed. + +``Ptr`` is similar to ``boost::shared_ptr`` that is part of the Boost library +(http://www.boost.org/doc/libs/release/libs/smart_ptr/shared_ptr.htm) +and ``std::shared_ptr`` from the `C++11 `_ standard. -This class provides the following options: +This class provides the following advantages: * Default constructor, copy constructor, and assignment operator for an arbitrary C++ class - or a C structure. For some objects, like files, windows, mutexes, sockets, and others, a copy + or C structure. For some objects, like files, windows, mutexes, sockets, and others, a copy constructor or an assignment operator are difficult to define. For some other objects, like complex classifiers in OpenCV, copy constructors are absent and not easy to implement. Finally, some of complex OpenCV and your own data structures may be written in C. - However, copy constructors and default constructors can simplify programming a lot.Besides, - they are often required (for example, by STL containers). By wrapping a pointer to such a - complex object ``TObj`` to ``Ptr``, you automatically get all of the necessary + However, copy constructors and default constructors can simplify programming a lot. Besides, + they are often required (for example, by STL containers). By using a ``Ptr`` to such an + object instead of the object itself, you automatically get all of the necessary constructors and the assignment operator. * *O(1)* complexity of the above-mentioned operations. While some structures, like ``std::vector``, provide a copy constructor and an assignment operator, the operations may take a considerable - amount of time if the data structures are large. But if the structures are put into ``Ptr<>``, + amount of time if the data structures are large. But if the structures are put into a ``Ptr``, the overhead is small and independent of the data size. * - Automatic destruction, even for C structures. See the example below with ``FILE*``. + Automatic and customizable cleanup, even for C structures. See the example below with ``FILE*``. * Heterogeneous collections of objects. The standard STL and most other C++ and OpenCV containers can store only objects of the same type and the same size. The classical solution to store objects - of different types in the same container is to store pointers to the base class ``base_class_t*`` - instead but then you loose the automatic memory management. Again, by using ``Ptr()`` - instead of the raw pointers, you can solve the problem. - -The ``Ptr`` class treats the wrapped object as a black box. The reference counter is allocated and -managed separately. The only thing the pointer class needs to know about the object is how to -deallocate it. This knowledge is encapsulated in the ``Ptr::delete_obj()`` method that is called when -the reference counter becomes 0. If the object is a C++ class instance, no additional coding is -needed, because the default implementation of this method calls ``delete obj;``. However, if the -object is deallocated in a different way, the specialized method should be created. For example, -if you want to wrap ``FILE``, the ``delete_obj`` may be implemented as follows: :: - - template<> inline void Ptr::delete_obj() - { - fclose(obj); // no need to clear the pointer afterwards, - // it is done externally. - } - ... - - // now use it: - Ptr f(fopen("myfile.txt", "r")); - if(f.empty()) - throw ...; + of different types in the same container is to store pointers to the base class (``Base*``) + instead but then you lose the automatic memory management. Again, by using ``Ptr`` + instead of raw pointers, you can solve the problem. + +A ``Ptr`` is said to *own* a pointer - that is, for each ``Ptr`` there is a pointer that will be deleted +once all ``Ptr`` instances that own it are destroyed. The owned pointer may be null, in which case nothing is deleted. +Each ``Ptr`` also *stores* a pointer. The stored pointer is the pointer the ``Ptr`` pretends to be; +that is, the one you get when you use :ocv:func:`Ptr::get` or the conversion to ``T*``. It's usually +the same as the owned pointer, but if you use casts or the general shared-ownership constructor, the two may diverge: +the ``Ptr`` will still own the original pointer, but will itself point to something else. + +The owned pointer is treated as a black box. The only thing ``Ptr`` needs to know about it is how to +delete it. This knowledge is encapsulated in the *deleter* - an auxiliary object that is associated +with the owned pointer and shared between all ``Ptr`` instances that own it. The default deleter is +an instance of ``DefaultDeleter``, which uses the standard C++ ``delete`` operator; as such it +will work with any pointer allocated with the standard ``new`` operator. + +However, if the pointer must be deleted in a different way, you must specify a custom deleter upon +``Ptr`` construction. A deleter is simply a callable object that accepts the pointer as its sole argument. +For example, if you want to wrap ``FILE``, you may do so as follows:: + + Ptr f(fopen("myfile.txt", "w"), fclose); + if(!f) throw ...; fprintf(f, ....); ... - // the file will be closed automatically by the Ptr destructor. + // the file will be closed automatically by f's destructor. +Alternatively, if you want all pointers of a particular type to be deleted the same way, +you can specialize ``DefaultDeleter::operator()`` for that type, like this:: -.. note:: The reference increment/decrement operations are implemented as atomic operations, - and therefore it is normally safe to use the classes in multi-threaded applications. - The same is true for :ocv:class:`Mat` and other C++ OpenCV classes that operate on - the reference counters. + namespace cv { + template<> void DefaultDeleter::operator ()(FILE * obj) const + { + fclose(obj); + } + } -Ptr::Ptr --------- -Various Ptr constructors. +For convenience, the following types from the OpenCV C API already have such a specialization +that calls the appropriate release function: + +* ``CvCapture`` +* :ocv:struct:`CvDTreeSplit` +* :ocv:struct:`CvFileStorage` +* ``CvHaarClassifierCascade`` +* :ocv:struct:`CvMat` +* :ocv:struct:`CvMatND` +* :ocv:struct:`CvMemStorage` +* :ocv:struct:`CvSparseMat` +* ``CvVideoWriter`` +* :ocv:struct:`IplImage` + +.. note:: The shared ownership mechanism is implemented with reference counting. As such, + cyclic ownership (e.g. when object ``a`` contains a ``Ptr`` to object ``b``, which + contains a ``Ptr`` to object ``a``) will lead to all involved objects never being + cleaned up. Avoid such situations. + +.. note:: It is safe to concurrently read (but not write) a ``Ptr`` instance from multiple threads + and therefore it is normally safe to use it in multi-threaded applications. + The same is true for :ocv:class:`Mat` and other C++ OpenCV classes that use internal + reference counts. + +Ptr::Ptr (null) +------------------ .. ocv:function:: Ptr::Ptr() -.. ocv:function:: Ptr::Ptr(_Tp* _obj) -.. ocv:function:: Ptr::Ptr(const Ptr& ptr) - :param _obj: Object for copy. - :param ptr: Object for copy. + The default constructor creates a null ``Ptr`` - one that owns and stores a null pointer. + +Ptr::Ptr (assuming ownership) +----------------------------- + +.. ocv:function:: template Ptr::Ptr(Y* p) +.. ocv:function:: template Ptr::Ptr(Y* p, D d) + + :param d: Deleter to use for the owned pointer. + :param p: Pointer to own. + + If ``p`` is null, these are equivalent to the default constructor. + + Otherwise, these constructors assume ownership of ``p`` - that is, the created ``Ptr`` owns + and stores ``p`` and assumes it is the sole owner of it. Don't use them if ``p`` is already + owned by another ``Ptr``, or else ``p`` will get deleted twice. + + With the first constructor, ``DefaultDeleter()`` becomes the associated deleter (so ``p`` + will eventually be deleted with the standard ``delete`` operator). ``Y`` must be a complete + type at the point of invocation. + + With the second constructor, ``d`` becomes the associated deleter. + + ``Y*`` must be convertible to ``T*``. + + .. note:: It is often easier to use :ocv:func:`makePtr` instead. + +Ptr::Ptr (sharing ownership) +---------------------------- + +.. ocv:function:: Ptr::Ptr(const Ptr& o) +.. ocv:function:: template Ptr::Ptr(const Ptr& o) +.. ocv:function:: template Ptr::Ptr(const Ptr& o, T* p) + + :param o: ``Ptr`` to share ownership with. + :param p: Pointer to store. + + These constructors create a ``Ptr`` that shares ownership with another ``Ptr`` - that is, + own the same pointer as ``o``. + + With the first two, the same pointer is stored, as well; for the second, ``Y*`` must be convertible to ``T*``. + + With the third, ``p`` is stored, and ``Y`` may be any type. This constructor allows to have completely + unrelated owned and stored pointers, and should be used with care to avoid confusion. A relatively + benign use is to create a non-owning ``Ptr``, like this:: + + ptr = Ptr(Ptr(), dont_delete_me); // owns nothing; will not delete the pointer. Ptr::~Ptr --------- -The Ptr destructor. .. ocv:function:: Ptr::~Ptr() + The destructor is equivalent to calling :ocv:func:`Ptr::release`. + Ptr::operator = ---------------- -Assignment operator. -.. ocv:function:: Ptr& Ptr::operator = (const Ptr& ptr) +.. ocv:function:: Ptr& Ptr::operator = (const Ptr& o) +.. ocv:function:: template Ptr& Ptr::operator = (const Ptr& o) - :param ptr: Object for assignment. + :param o: ``Ptr`` to share ownership with. -Decrements own reference counter (with ``release()``) and increments ptr's reference counter. - -Ptr::addref ------------ -Increments reference counter. + Assignment replaces the current ``Ptr`` instance with one that owns and stores same + pointers as ``o`` and then destroys the old instance. -.. ocv:function:: void Ptr::addref() Ptr::release ------------ -Decrements reference counter; when it becomes 0, ``delete_obj()`` is called. .. ocv:function:: void Ptr::release() -Ptr::delete_obj ---------------- -User-specified custom object deletion operation. By default, ``delete obj;`` is called. + If no other ``Ptr`` instance owns the owned pointer, deletes it with the associated deleter. + Then sets both the owned and the stored pointers to ``NULL``. + + +Ptr::reset +---------- + +.. ocv:function:: template void Ptr::reset(Y* p) +.. ocv:function:: template void Ptr::reset(Y* p, D d) + + :param d: Deleter to use for the owned pointer. + :param p: Pointer to own. + + ``ptr.reset(...)`` is equivalent to ``ptr = Ptr(...)``. + +Ptr::swap +--------- + +.. ocv:function:: void Ptr::swap(Ptr& o) + + :param o: ``Ptr`` to swap with. + + Swaps the owned and stored pointers (and deleters, if any) of this and ``o``. + +Ptr::get +-------- + +.. ocv:function:: T* Ptr::get() const -.. ocv:function:: void Ptr::delete_obj() + Returns the stored pointer. + +Ptr pointer emulation +--------------------- + +.. ocv:function:: T& Ptr::operator * () const +.. ocv:function:: T* Ptr::operator -> () const +.. ocv:function:: Ptr::operator T* () const + + These operators are what allows ``Ptr`` to pretend to be a pointer. + + If ``ptr`` is a ``Ptr``, then ``*ptr`` is equivalent to ``*ptr.get()`` + and ``ptr->foo`` is equivalent to ``ptr.get()->foo``. In addition, ``ptr`` + is implicitly convertible to ``T*``, and such conversion is equivalent to + ``ptr.get()``. As a corollary, ``if (ptr)`` is equivalent to ``if (ptr.get())``. + In other words, a ``Ptr`` behaves as if it was its own stored pointer. Ptr::empty ---------- -Returns true if obj == 0; -bool empty() const; +.. ocv:function:: bool Ptr::empty() const -Ptr::operator -> ----------------- -Provide access to the object fields and methods. + ``ptr.empty()`` is equivalent to ``!ptr.get()``. -.. ocv:function:: template _Tp* Ptr::operator -> () -.. ocv:function:: template const _Tp* Ptr::operator -> () const +Ptr casts +--------- +.. ocv:function:: template Ptr Ptr::staticCast() const +.. ocv:function:: template Ptr Ptr::constCast() const +.. ocv:function:: template Ptr Ptr::dynamicCast() const -Ptr::operator _Tp* ------------------- -Returns the underlying object pointer. Thanks to the methods, the ``Ptr<_Tp>`` can be used instead -of ``_Tp*``. + If ``ptr`` is a ``Ptr``, then ``ptr.fooCast()`` is equivalent to + ``Ptr(ptr, foo_cast(ptr.get()))``. That is, these functions create + a new ``Ptr`` with the same owned pointer and a cast stored pointer. + +Ptr global swap +--------------- + +.. ocv:function:: template void swap(Ptr& ptr1, Ptr& ptr2) + + Equivalent to ``ptr1.swap(ptr2)``. Provided to help write generic algorithms. + +Ptr comparisons +--------------- + +.. ocv:function:: template bool operator == (const Ptr& ptr1, const Ptr& ptr2) +.. ocv:function:: template bool operator != (const Ptr& ptr1, const Ptr& ptr2) + + Return whether ``ptr1.get()`` and ``ptr2.get()`` are equal and not equal, respectively. + +makePtr +------- + +.. ocv:function:: template Ptr makePtr() +.. ocv:function:: template Ptr makePtr(const A1& a1) +.. ocv:function:: template Ptr makePtr(const A1& a1, const A2& a2) +.. ocv:function:: template Ptr makePtr(const A1& a1, const A2& a2, const A3& a3) + + (and so on...) -.. ocv:function:: template Ptr::operator _Tp* () -.. ocv:function:: template Ptr::operator const _Tp*() const + ``makePtr(...)`` is equivalent to ``Ptr(new T(...))``. It is shorter than the latter, and + it's marginally safer than using a constructor or :ocv:func:`Ptr::reset`, since it ensures that + the owned pointer is new and thus not owned by any other ``Ptr`` instance. + Unfortunately, perfect forwarding is impossible to implement in C++03, and so ``makePtr`` is limited + to constructors of ``T`` that have up to 10 arguments, none of which are non-const references. Mat --- @@ -2967,7 +3108,7 @@ Creates algorithm instance by name :param name: The algorithm name, one of the names returned by ``Algorithm::getList()``. -This static method creates a new instance of the specified algorithm. If there is no such algorithm, the method will silently return null pointer (that can be checked by ``Ptr::empty()`` method). Also, you should specify the particular ``Algorithm`` subclass as ``_Tp`` (or simply ``Algorithm`` if you do not know it at that point). :: +This static method creates a new instance of the specified algorithm. If there is no such algorithm, the method will silently return a null pointer. Also, you should specify the particular ``Algorithm`` subclass as ``_Tp`` (or simply ``Algorithm`` if you do not know it at that point). :: Ptr bgfg = Algorithm::create("BackgroundSubtractor.MOG2"); diff --git a/modules/core/doc/intro.rst b/modules/core/doc/intro.rst index 582f1d00dc..6d9fdfca5e 100644 --- a/modules/core/doc/intro.rst +++ b/modules/core/doc/intro.rst @@ -83,17 +83,22 @@ First of all, ``std::vector``, ``Mat``, and other data structures used by the fu // matrix will be deallocated, since it is not referenced by anyone C = C.clone(); -You see that the use of ``Mat`` and other basic structures is simple. But what about high-level classes or even user data types created without taking automatic memory management into account? For them, OpenCV offers the ``Ptr<>`` template class that is similar to ``std::shared_ptr`` from C++ TR1. So, instead of using plain pointers:: +You see that the use of ``Mat`` and other basic structures is simple. But what about high-level classes or even user +data types created without taking automatic memory management into account? For them, OpenCV offers the :ocv:class:`Ptr` +template class that is similar to ``std::shared_ptr`` from C++11. So, instead of using plain pointers:: T* ptr = new T(...); you can use:: - Ptr ptr = new T(...); + Ptr ptr(new T(...)); -That is, ``Ptr ptr`` encapsulates a pointer to a ``T`` instance and a reference counter associated with the pointer. See the -:ocv:class:`Ptr` -description for details. +or:: + + Ptr ptr = makePtr(...); + +``Ptr`` encapsulates a pointer to a ``T`` instance and a reference counter associated with the pointer. See the +:ocv:class:`Ptr` description for details. .. _AutomaticAllocation: From c7d2fdc4b2628c725cee9ead0a5080a0a729762c Mon Sep 17 00:00:00 2001 From: Roman Donchenko Date: Thu, 15 Aug 2013 19:54:00 +0400 Subject: [PATCH 39/55] Fixed some dubious uses of tbb::task_scheduler_init. --- modules/calib3d/perf/perf_pnp.cpp | 2 +- modules/calib3d/test/test_solvepnp_ransac.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/calib3d/perf/perf_pnp.cpp b/modules/calib3d/perf/perf_pnp.cpp index e881557298..7a7acb052d 100644 --- a/modules/calib3d/perf/perf_pnp.cpp +++ b/modules/calib3d/perf/perf_pnp.cpp @@ -130,7 +130,7 @@ PERF_TEST_P(PointsNum, DISABLED_SolvePnPRansac, testing::Values(4, 3*9, 7*13)) #ifdef HAVE_TBB // limit concurrency to get determenistic result - cv::Ptr one_thread = new tbb::task_scheduler_init(1); + tbb::task_scheduler_init one_thread(1); #endif TEST_CYCLE() diff --git a/modules/calib3d/test/test_solvepnp_ransac.cpp b/modules/calib3d/test/test_solvepnp_ransac.cpp index 4d00d805b5..ae744a4d7e 100644 --- a/modules/calib3d/test/test_solvepnp_ransac.cpp +++ b/modules/calib3d/test/test_solvepnp_ransac.cpp @@ -276,7 +276,7 @@ TEST(DISABLED_Calib3d_SolvePnPRansac, concurrency) { // limit concurrency to get determenistic result cv::theRNG().state = 20121010; - cv::Ptr one_thread = new tbb::task_scheduler_init(1); + tbb::task_scheduler_init one_thread(1); solvePnPRansac(object, image, camera_mat, dist_coef, rvec1, tvec1); } @@ -295,7 +295,7 @@ TEST(DISABLED_Calib3d_SolvePnPRansac, concurrency) { // single thread again cv::theRNG().state = 20121010; - cv::Ptr one_thread = new tbb::task_scheduler_init(1); + tbb::task_scheduler_init one_thread(1); solvePnPRansac(object, image, camera_mat, dist_coef, rvec2, tvec2); } From 86b841563b0582e98c10c40d3fcf3f4dc4c5d1df Mon Sep 17 00:00:00 2001 From: Roman Donchenko Date: Thu, 5 Sep 2013 14:53:21 +0400 Subject: [PATCH 40/55] Added tests for Ptr. --- modules/core/test/test_ptr.cpp | 389 +++++++++++++++++++++++++++++++++ 1 file changed, 389 insertions(+) create mode 100644 modules/core/test/test_ptr.cpp diff --git a/modules/core/test/test_ptr.cpp b/modules/core/test/test_ptr.cpp new file mode 100644 index 0000000000..c6f793ab16 --- /dev/null +++ b/modules/core/test/test_ptr.cpp @@ -0,0 +1,389 @@ +/*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. +// +// +// License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2013, NVIDIA 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 the copyright holders 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 copyright holders 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; + +namespace { + +struct Reporter { + Reporter(bool* deleted) : deleted_(deleted) + { *deleted_ = false; } + + // the destructor is virtual, so that we can test dynamic_cast later + virtual ~Reporter() + { *deleted_ = true; } + +private: + bool* deleted_; + + Reporter(const Reporter&); + Reporter& operator = (const Reporter&); +}; + +struct ReportingDeleter { + ReportingDeleter(bool* deleted) : deleted_(deleted) + { *deleted_ = false; } + + void operator()(void*) + { *deleted_ = true; } + +private: + bool* deleted_; +}; + +int dummyObject; + +} + +TEST(Core_Ptr, default_ctor) +{ + Ptr p; + EXPECT_EQ(NULL, p.get()); +} + +TEST(Core_Ptr, owning_ctor) +{ + bool deleted = false; + + { + Reporter* r = new Reporter(&deleted); + Ptr p(r); + EXPECT_EQ(r, p.get()); + } + + EXPECT_TRUE(deleted); + + { + Ptr p(&dummyObject, ReportingDeleter(&deleted)); + EXPECT_EQ(&dummyObject, p.get()); + } + + EXPECT_TRUE(deleted); + + { + Ptr p((void*)0, ReportingDeleter(&deleted)); + EXPECT_EQ(NULL, p.get()); + } + + EXPECT_FALSE(deleted); +} + +TEST(Core_Ptr, sharing_ctor) +{ + bool deleted = false; + + { + Ptr p1(new Reporter(&deleted)); + Ptr p2(p1); + EXPECT_EQ(p1.get(), p2.get()); + p1.release(); + EXPECT_FALSE(deleted); + } + + EXPECT_TRUE(deleted); + + { + Ptr p1(new Reporter(&deleted)); + Ptr p2(p1); + EXPECT_EQ(p1.get(), p2.get()); + p1.release(); + EXPECT_FALSE(deleted); + } + + EXPECT_TRUE(deleted); + + { + Ptr p1(new Reporter(&deleted)); + Ptr p2(p1, &dummyObject); + EXPECT_EQ(&dummyObject, p2.get()); + p1.release(); + EXPECT_FALSE(deleted); + } + + EXPECT_TRUE(deleted); +} + +TEST(Core_Ptr, assignment) +{ + bool deleted1 = false, deleted2 = false; + + { + Ptr p1(new Reporter(&deleted1)); + p1 = p1; + EXPECT_FALSE(deleted1); + } + + EXPECT_TRUE(deleted1); + + { + Ptr p1(new Reporter(&deleted1)); + Ptr p2(new Reporter(&deleted2)); + p2 = p1; + EXPECT_TRUE(deleted2); + EXPECT_EQ(p1.get(), p2.get()); + p1.release(); + EXPECT_FALSE(deleted1); + } + + EXPECT_TRUE(deleted1); + + { + Ptr p1(new Reporter(&deleted1)); + Ptr p2(new Reporter(&deleted2)); + p2 = p1; + EXPECT_TRUE(deleted2); + EXPECT_EQ(p1.get(), p2.get()); + p1.release(); + EXPECT_FALSE(deleted1); + } + + EXPECT_TRUE(deleted1); +} + +TEST(Core_Ptr, release) +{ + bool deleted = false; + + Ptr p1(new Reporter(&deleted)); + p1.release(); + EXPECT_TRUE(deleted); + EXPECT_EQ(NULL, p1.get()); +} + +TEST(Core_Ptr, reset) +{ + bool deleted_old = false, deleted_new = false; + + { + Ptr p(new Reporter(&deleted_old)); + Reporter* r = new Reporter(&deleted_new); + p.reset(r); + EXPECT_TRUE(deleted_old); + EXPECT_EQ(r, p.get()); + } + + EXPECT_TRUE(deleted_new); + + { + Ptr p(new Reporter(&deleted_old)); + p.reset(&dummyObject, ReportingDeleter(&deleted_new)); + EXPECT_TRUE(deleted_old); + EXPECT_EQ(&dummyObject, p.get()); + } + + EXPECT_TRUE(deleted_new); +} + +TEST(Core_Ptr, swap) +{ + bool deleted1 = false, deleted2 = false; + + { + Reporter* r1 = new Reporter(&deleted1); + Reporter* r2 = new Reporter(&deleted2); + Ptr p1(r1), p2(r2); + p1.swap(p2); + EXPECT_EQ(r1, p2.get()); + EXPECT_EQ(r2, p1.get()); + EXPECT_FALSE(deleted1); + EXPECT_FALSE(deleted2); + p1.release(); + EXPECT_TRUE(deleted2); + } + + EXPECT_TRUE(deleted1); + + { + Reporter* r1 = new Reporter(&deleted1); + Reporter* r2 = new Reporter(&deleted2); + Ptr p1(r1), p2(r2); + swap(p1, p2); + EXPECT_EQ(r1, p2.get()); + EXPECT_EQ(r2, p1.get()); + EXPECT_FALSE(deleted1); + EXPECT_FALSE(deleted2); + p1.release(); + EXPECT_TRUE(deleted2); + } + + EXPECT_TRUE(deleted1); +} + +TEST(Core_Ptr, accessors) +{ + { + Ptr p; + EXPECT_EQ(NULL, static_cast(p)); + EXPECT_TRUE(p.empty()); + } + + { + Size* s = new Size(); + Ptr p(s); + EXPECT_EQ(s, static_cast(p)); + EXPECT_EQ(s, &*p); + EXPECT_EQ(&s->width, &p->width); + EXPECT_FALSE(p.empty()); + } +} + +namespace { + +struct SubReporterBase { + virtual ~SubReporterBase() {} + int padding; +}; + +/* multiple inheritance, so that casts do something interesting */ +struct SubReporter : SubReporterBase, Reporter +{ + SubReporter(bool* deleted) : Reporter(deleted) + {} +}; + +} + +TEST(Core_Ptr, casts) +{ + bool deleted = false; + + { + Ptr p1(new Reporter(&deleted)); + Ptr p2 = p1.constCast(); + EXPECT_EQ(p1.get(), p2.get()); + p1.release(); + EXPECT_FALSE(deleted); + } + + EXPECT_TRUE(deleted); + + { + SubReporter* sr = new SubReporter(&deleted); + Ptr p1(sr); + // This next check isn't really for Ptr itself; it checks that Reporter + // is at a non-zero offset within SubReporter, so that the next + // check will give us more confidence that the cast actually did something. + EXPECT_NE(static_cast(sr), static_cast(p1.get())); + Ptr p2 = p1.staticCast(); + EXPECT_EQ(sr, p2.get()); + p1.release(); + EXPECT_FALSE(deleted); + } + + EXPECT_TRUE(deleted); + + { + SubReporter* sr = new SubReporter(&deleted); + Ptr p1(sr); + EXPECT_NE(static_cast(sr), static_cast(p1.get())); + Ptr p2 = p1.dynamicCast(); + EXPECT_EQ(sr, p2.get()); + p1.release(); + EXPECT_FALSE(deleted); + } + + EXPECT_TRUE(deleted); + + { + Ptr p1(new Reporter(&deleted)); + Ptr p2 = p1.dynamicCast(); + EXPECT_EQ(NULL, p2.get()); + p1.release(); + EXPECT_FALSE(deleted); + } + + EXPECT_TRUE(deleted); +} + +TEST(Core_Ptr, comparisons) +{ + Ptr p1, p2(new int), p3(new int); + Ptr p4(p2, p3.get()); + + // Not using EXPECT_EQ here, since none of them are really "expected" or "actual". + EXPECT_TRUE(p1 == p1); + EXPECT_TRUE(p2 == p2); + EXPECT_TRUE(p2 != p3); + EXPECT_TRUE(p2 != p4); + EXPECT_TRUE(p3 == p4); +} + +TEST(Core_Ptr, make) +{ + bool deleted = true; + + { + Ptr p = makePtr(&deleted); + EXPECT_FALSE(deleted); + } + + EXPECT_TRUE(deleted); +} + +namespace { + +struct SpeciallyDeletable +{ + SpeciallyDeletable() : deleted(false) + {} + bool deleted; +}; + +} + +namespace cv { + +template<> +void DefaultDeleter::operator()(SpeciallyDeletable * obj) const +{ obj->deleted = true; } + +} + +TEST(Core_Ptr, specialized_deleter) +{ + SpeciallyDeletable sd; + + { Ptr p(&sd); } + + ASSERT_TRUE(sd.deleted); +} From af594c8e447d194283f70cedd2ad669093297ff2 Mon Sep 17 00:00:00 2001 From: Roman Donchenko Date: Fri, 6 Sep 2013 12:28:59 +0400 Subject: [PATCH 41/55] retina_ocl.hpp: switched BasicRetinaFilter's members around to fix a -Wreorder warning. --- modules/bioinspired/src/retina_ocl.hpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/modules/bioinspired/src/retina_ocl.hpp b/modules/bioinspired/src/retina_ocl.hpp index 69a833cc42..90df0601c4 100644 --- a/modules/bioinspired/src/retina_ocl.hpp +++ b/modules/bioinspired/src/retina_ocl.hpp @@ -160,14 +160,15 @@ public: }; protected: - cv::ocl::oclMat _filterOutput; - cv::ocl::oclMat _localBuffer; int _NBrows; int _NBcols; unsigned int _halfNBrows; unsigned int _halfNBcolumns; + cv::ocl::oclMat _filterOutput; + cv::ocl::oclMat _localBuffer; + std::valarray _filteringCoeficientsTable; float _v0; float _maxInputValue; From 439e90f4f4a636f6a1d3a22dd04b5926c0ea4bae Mon Sep 17 00:00:00 2001 From: Roman Donchenko Date: Fri, 6 Sep 2013 12:29:29 +0400 Subject: [PATCH 42/55] retina_ocl.cpp: removed two unused arrays. --- modules/bioinspired/src/retina_ocl.cpp | 3 --- 1 file changed, 3 deletions(-) diff --git a/modules/bioinspired/src/retina_ocl.cpp b/modules/bioinspired/src/retina_ocl.cpp index 41169561fb..c294ebfebe 100644 --- a/modules/bioinspired/src/retina_ocl.cpp +++ b/modules/bioinspired/src/retina_ocl.cpp @@ -1040,9 +1040,6 @@ const oclMat &MagnoRetinaFilter::runFilter(const oclMat &OPL_ON, const oclMat &O x##_slices[_SLICE_INDEX_] = x(getROI(_SLICE_INDEX_));\ } -static float _LMStoACr1Cr2[] = {1.0, 1.0, 0.0, 1.0, -1.0, 0.0, -0.5, -0.5, 1.0}; -static float _LMStoLab[] = {0.5774f, 0.5774f, 0.5774f, 0.4082f, 0.4082f, -0.8165f, 0.7071f, -0.7071f, 0.f}; - RetinaColor::RetinaColor(const unsigned int NBrows, const unsigned int NBcolumns, const int samplingMethod) : BasicRetinaFilter(NBrows, NBcolumns, 3), _RGBmosaic(NBrows * 3, NBcolumns, CV_32FC1), From dba336c0e3ae47e5f6965c4bfe53526012b97d29 Mon Sep 17 00:00:00 2001 From: lluis Date: Wed, 4 Sep 2013 20:19:13 +0200 Subject: [PATCH 43/55] fixed a bug in the non-max-suppression filter procedure --- modules/objdetect/src/erfilter.cpp | 60 +++++++++++++++++++++++++----- 1 file changed, 51 insertions(+), 9 deletions(-) diff --git a/modules/objdetect/src/erfilter.cpp b/modules/objdetect/src/erfilter.cpp index b8e964f5d8..00a85d91a7 100644 --- a/modules/objdetect/src/erfilter.cpp +++ b/modules/objdetect/src/erfilter.cpp @@ -631,9 +631,10 @@ void ERFilterNM::er_merge(ERStat *parent, ERStat *child) child->probability = classifier->eval(*child); } - if ( ((classifier!=NULL)?(child->probability >= minProbability):true) && + if ( (((classifier!=NULL)?(child->probability >= minProbability):true)||(nonMaxSuppression)) && ((child->area >= (minArea*region_mask.rows*region_mask.cols)) && - (child->area <= (maxArea*region_mask.rows*region_mask.cols))) ) + (child->area <= (maxArea*region_mask.rows*region_mask.cols)) && + (child->rect.width > 2) && (child->rect.height > 2)) ) { num_accepted_regions++; @@ -699,38 +700,73 @@ ERStat* ERFilterNM::er_save( ERStat *er, ERStat *parent, ERStat *prev ) regions->back().parent = parent; if (prev != NULL) + { prev->next = &(regions->back()); + } else if (parent != NULL) parent->child = &(regions->back()); ERStat *old_prev = NULL; ERStat *this_er = ®ions->back(); + if (this_er->parent == NULL) + { + this_er->probability = 0; + } + if (nonMaxSuppression) { if (this_er->parent == NULL) { - this_er->probability = 0; //TODO this makes sense in order to select at least one region in short tree's but is it really necessary? this_er->max_probability_ancestor = this_er; this_er->min_probability_ancestor = this_er; + //cout << "This is the root so now min_p is " << this_er->probability << " and max_p is " << this_er->probability << endl; } else { this_er->max_probability_ancestor = (this_er->probability > parent->max_probability_ancestor->probability)? this_er : parent->max_probability_ancestor; this_er->min_probability_ancestor = (this_er->probability < parent->min_probability_ancestor->probability)? this_er : parent->min_probability_ancestor; + //cout << "This is NOT the root so now min_p is " << this_er->min_probability_ancestor->probability << " and max_p is " << this_er->max_probability_ancestor->probability << endl; + /* if ( (this_er->max_probability_ancestor->probability > minProbability) && (this_er->max_probability_ancestor->probability - this_er->min_probability_ancestor->probability > minProbabilityDiff)) { - + cout << " local máxima detcected on " << this_er->max_probability_ancestor->probability << endl; this_er->max_probability_ancestor->local_maxima = true; - //TODO check here if the last local_maxima can be also suppressed, is the following correct? - //if (this_er->min_probability_ancestor->local_maxima) - // this_er->min_probability_ancestor->local_maxima = false; - this_er->max_probability_ancestor = this_er; this_er->min_probability_ancestor = this_er; + cout << " so now min_p is " << this_er->min_probability_ancestor->probability << " and max_p is " << this_er->max_probability_ancestor->probability << endl; + } + else if ((this_er->min_probability_ancestor->local_maxima) && (this_er->probability > (this_er->min_probability_ancestor->probability))) { + cout << " NO local máxima detcected on " << this_er->max_probability_ancestor->probability << endl; + cout << " and min_p was local maxima and this_er->p > min_p" << endl; + cout << " so mark as local maxima "<< this_er->max_probability_ancestor << endl; + cout << " and unmark "<< this_er->min_probability_ancestor << endl; + this_er->max_probability_ancestor->local_maxima = true; + this_er->min_probability_ancestor->local_maxima = false; + + }*/ + if ( (this_er->max_probability_ancestor->probability > minProbability) && (this_er->max_probability_ancestor->probability - this_er->min_probability_ancestor->probability > minProbabilityDiff)) + { + //cout << " local máxima detcected on " << this_er->max_probability_ancestor->probability << endl; + this_er->max_probability_ancestor->local_maxima = true; + if ((this_er->max_probability_ancestor == this_er) && (this_er->parent->local_maxima)) + { + //cout << " local máxima undetcected on " << this_er->parent->probability << endl; + this_er->parent->local_maxima = false; + } + } + else if (this_er->probability < this_er->parent->probability) + { + this_er->min_probability_ancestor = this_er; + } + else if (this_er->probability > this_er->parent->probability) + { + this_er->max_probability_ancestor = this_er; } + + } } @@ -769,7 +805,7 @@ ERStat* ERFilterNM::er_tree_filter ( InputArray image, ERStat * stat, ERStat *pa findContours( region, contours, hierarchy, RETR_TREE, CHAIN_APPROX_NONE, Point(0, 0) ); //TODO check epsilon parameter of approxPolyDP (set empirically) : we want more precission // if the region is very small because otherwise we'll loose all the convexities - approxPolyDP( Mat(contours[0]), contour_poly, max(rect.width,rect.height)/25, true ); + approxPolyDP( Mat(contours[0]), contour_poly, min(rect.width,rect.height)/17, true ); bool was_convex = false; @@ -1084,8 +1120,13 @@ Ptr createERFilterNM1(const Ptr& cb, int threshold CV_Assert( (thresholdDelta >= 0) && (thresholdDelta <= 128) ); CV_Assert( (minProbabilityDiff >= 0.) && (minProbabilityDiff <= 1.) ); +<<<<<<< HEAD Ptr filter = makePtr(); +======= + Ptr filter = new ERFilterNM(); + +>>>>>>> fixed a bug in the non-max-suppression filter procedure if (cb == NULL) filter->setCallback(makePtr()); else @@ -1131,3 +1172,4 @@ Ptr createERFilterNM2(const Ptr& cb, float minProb } } + From 765921cc25bdb37a81ca86b8224532dd46fde8c5 Mon Sep 17 00:00:00 2001 From: lluis Date: Wed, 4 Sep 2013 20:20:25 +0200 Subject: [PATCH 44/55] fixed a typo error in the default min_Probability param of CreateERFilterNM2 --- modules/objdetect/include/opencv2/objdetect/erfilter.hpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/modules/objdetect/include/opencv2/objdetect/erfilter.hpp b/modules/objdetect/include/opencv2/objdetect/erfilter.hpp index 8a1b580c3a..2e05996c3e 100644 --- a/modules/objdetect/include/opencv2/objdetect/erfilter.hpp +++ b/modules/objdetect/include/opencv2/objdetect/erfilter.hpp @@ -190,8 +190,13 @@ CV_EXPORTS Ptr createERFilterNM1(const Ptr& cb = P if omitted tries to load a default classifier from file trained_classifierNM2.xml \param minProbability The minimum probability P(er|character) allowed for retreived ER's */ +<<<<<<< HEAD CV_EXPORTS Ptr createERFilterNM2(const Ptr& cb = Ptr(), float minProbability = 0.85); +======= +CV_EXPORTS Ptr createERFilterNM2(const Ptr& cb = NULL, + float minProbability = 0.5); +>>>>>>> fixed a typo error in the default min_Probability param of CreateERFilterNM2 } #endif // _OPENCV_ERFILTER_HPP_ From f4d01175b860e41b20bed7baa339c4b5a1f99163 Mon Sep 17 00:00:00 2001 From: lluis Date: Wed, 4 Sep 2013 20:22:05 +0200 Subject: [PATCH 45/55] fixed a bug in the calculation of the number of inflexion points feature --- modules/objdetect/src/erfilter.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/modules/objdetect/src/erfilter.cpp b/modules/objdetect/src/erfilter.cpp index 00a85d91a7..d3384e2b62 100644 --- a/modules/objdetect/src/erfilter.cpp +++ b/modules/objdetect/src/erfilter.cpp @@ -805,7 +805,11 @@ ERStat* ERFilterNM::er_tree_filter ( InputArray image, ERStat * stat, ERStat *pa findContours( region, contours, hierarchy, RETR_TREE, CHAIN_APPROX_NONE, Point(0, 0) ); //TODO check epsilon parameter of approxPolyDP (set empirically) : we want more precission // if the region is very small because otherwise we'll loose all the convexities +<<<<<<< HEAD approxPolyDP( Mat(contours[0]), contour_poly, min(rect.width,rect.height)/17, true ); +======= + approxPolyDP( Mat(contours[0]), contour_poly, (float)min(rect.width,rect.height)/17, true ); +>>>>>>> fixed a bug in the calculation of the number of inflexion points feature bool was_convex = false; From 15511bff402ea9b6e9ea3f4521809b665db77920 Mon Sep 17 00:00:00 2001 From: lluis Date: Wed, 4 Sep 2013 20:23:37 +0200 Subject: [PATCH 46/55] better classifiers performance by training them with a new dataset of "manually" selected regions --- samples/cpp/trained_classifierNM1.xml | 2038 ++++++++++++------------- samples/cpp/trained_classifierNM2.xml | 2000 ++++++++++++------------ 2 files changed, 2019 insertions(+), 2019 deletions(-) diff --git a/samples/cpp/trained_classifierNM1.xml b/samples/cpp/trained_classifierNM1.xml index afce7951c6..c395a67df7 100644 --- a/samples/cpp/trained_classifierNM1.xml +++ b/samples/cpp/trained_classifierNM1.xml @@ -48,8 +48,8 @@ <_> 0 - 6696 - -4.2738068875125497e-02 + 1859 + -8.7333809708193622e-01 0 0 0 @@ -59,12 +59,12 @@ 0. <_>1 - 6.1327493190765381e-01 - 7.8049004077911377e-02 + 8.9537560939788818e-01 + 8.5429996252059937e-02 <_> 1 - 1344 - 1.4897232658416162e+00 + 281 + 6.7336438045685210e-01 1 0 0 @@ -74,8 +74,8 @@ 0. <_> 1 - 5352 - -2.8797404326299503e-01 + 1578 + -1.6797288877447023e+00 0 0 0 @@ -88,8 +88,8 @@ <_> 0 - 6696 - 4.1522341120979132e-14 + 1859 + 6.8833827526759232e-15 1 0 0 @@ -98,13 +98,13 @@ 0. 0. - <_>1 - 6.4094465970993042e-01 - 1.9897949695587158e-01 + <_>2 + 6.0157060623168945e-01 + 1.5000000000000000e+00 <_> 1 - 5301 - -3.6524083494067622e-01 + 1728 + -2.3830233314576746e-01 0 0 0 @@ -114,8 +114,8 @@ 0. <_> 1 - 1395 - 1.1149576991343251e+00 + 131 + 1.3270520927417431e+00 1 0 0 @@ -128,9 +128,9 @@ <_> 0 - 6696 - -2.2870594307278749e-14 - 0 + 1859 + 1.1546319456101495e-14 + 1 0 0 0. @@ -138,14 +138,14 @@ 0. 0. - <_>2 - 5.6980127096176147e-01 - 1.5000000000000000e+00 + <_>1 + 6.0729509592056274e-01 + 1.0963299870491028e-01 <_> 1 - 5523 - -1.7166415896295562e-01 - 0 + 781 + 2.8488485626451149e-01 + 1 0 0 0. @@ -154,9 +154,9 @@ 0. <_> 1 - 1173 - 1.1605005959787533e+00 - 1 + 1078 + -1.0290340538001230e+00 + 0 0 0 0. @@ -168,9 +168,9 @@ <_> 0 - 6696 - -7.1054273576015067e-14 - 0 + 1859 + 8.8817841970011734e-15 + 1 0 0 0. @@ -179,12 +179,12 @@ 0. <_>0 - 5.4822087287902832e-01 - 8.7975895404815674e-01 + 5.8338499069213867e-01 + 9.5209401845932007e-01 <_> 1 - 2833 - -4.2480176423068461e-01 + 1331 + -4.6437394337436783e-01 0 0 0 @@ -194,8 +194,8 @@ 0. <_> 1 - 3863 - 2.4532852260825078e-01 + 528 + 4.0542316486679569e-01 1 0 0 @@ -208,9 +208,9 @@ <_> 0 - 6696 - 2.9753977059953312e-14 - 1 + 1859 + -1.5931700403371249e-14 + 0 0 0 0. @@ -219,12 +219,12 @@ 0. <_>3 - 5.3140330314636230e-01 + 5.5465269088745117e-01 3. <_> 1 - 3996 - 1.7646926498854212e-01 + 856 + 5.0630658667623052e-01 1 0 0 @@ -234,8 +234,8 @@ 0. <_> 1 - 2700 - -3.7641896870070152e-01 + 1003 + -2.3844591468675169e-01 0 0 0 @@ -248,8 +248,8 @@ <_> 0 - 6696 - -1.5543122344752435e-14 + 1859 + -4.0523140398818379e-15 0 0 0 @@ -258,14 +258,14 @@ 0. 0. - <_>1 - 5.3332197666168213e-01 - 2.2678799927234650e-01 + <_>2 + 5.5272746086120605e-01 + 5.0000000000000000e-01 <_> 1 - 6524 - 7.6426114713215615e-02 - 1 + 1046 + -3.5086409511139033e-01 + 0 0 0 0. @@ -274,9 +274,9 @@ 0. <_> 1 - 172 - -1.3485157356563835e+00 - 0 + 813 + 3.2363636038761090e-01 + 1 0 0 0. @@ -288,8 +288,8 @@ <_> 0 - 6696 - 1.8873791418627305e-14 + 1859 + 3.5527136788004883e-15 1 0 0 @@ -298,14 +298,14 @@ 0. 0. - <_>1 - 5.1992774009704590e-01 - 9.8430499434471130e-02 + <_>0 + 5.4958724975585938e-01 + 1.6267855167388916e+00 <_> 1 - 2081 - 3.1735773403827577e-01 - 1 + 1811 + -1.0723654593445622e-01 + 0 0 0 0. @@ -314,9 +314,9 @@ 0. <_> 1 - 4615 - -1.3050941677698649e-01 - 0 + 48 + 1.6463996332936000e+00 + 1 0 0 0. @@ -328,9 +328,9 @@ <_> 0 - 6696 - 1.0436096431476363e-14 - 1 + 1859 + -1.5543122344752215e-15 + 0 0 0 0. @@ -339,13 +339,13 @@ 0. <_>1 - 5.1678413152694702e-01 - 2.1212799847126007e-01 + 5.5254465341567993e-01 + 7.4758999049663544e-02 <_> 1 - 5467 - -8.5787873301210987e-02 - 0 + 149 + 1.0273978441887677e+00 + 1 0 0 0. @@ -354,9 +354,9 @@ 0. <_> 1 - 1229 - 4.1446003655995284e-01 - 1 + 1710 + -1.3682146780021626e-01 + 0 0 0 0. @@ -368,8 +368,8 @@ <_> 0 - 6696 - 2.6645352591003686e-15 + 1859 + 1.1990408665951547e-14 1 0 0 @@ -378,14 +378,14 @@ 0. 0. - <_>1 - 5.1522570848464966e-01 - 4.8514001071453094e-02 + <_>0 + 5.4537707567214966e-01 + 6.6345453262329102e-01 <_> 1 - 539 - 5.7564577324623896e+00 - 1 + 455 + -1.0072489119231773e+00 + 0 0 0 0. @@ -394,9 +394,9 @@ 0. <_> 1 - 6157 - -3.0460809939285270e-02 - 0 + 1404 + 1.1925375544044788e-01 + 1 0 0 0. @@ -408,9 +408,9 @@ <_> 0 - 6696 - 9.6331636897139381e-05 - 1 + 1859 + -7.1054273576010523e-15 + 0 0 0 0. @@ -418,14 +418,14 @@ 0. 0. - <_>3 - 5.1313066482543945e-01 - 5. + <_>2 + 5.2146106958389282e-01 + 2.5000000000000000e+00 <_> 1 - 5925 - 4.9494433475081236e-02 - 1 + 1791 + -4.7305821386203636e-02 + 0 0 0 0. @@ -434,9 +434,9 @@ 0. <_> 1 - 771 - -5.9287972929575039e-01 - 0 + 68 + 1.5160735804641536e+00 + 1 0 0 0. @@ -448,9 +448,9 @@ <_> 0 - 6696 - -6.1617377866696567e-15 - 0 + 1859 + 3.7747582837255180e-15 + 1 0 0 0. @@ -458,14 +458,14 @@ 0. 0. - <_>2 - 5.1186925172805786e-01 - 4.5000000000000000e+00 + <_>3 + 5.2081108093261719e-01 + 5. <_> 1 - 5993 - -2.9420461509411709e-02 - 0 + 1690 + 9.1796156088740075e-02 + 1 0 0 0. @@ -474,9 +474,9 @@ 0. <_> 1 - 703 - 1.1186642275618490e+00 - 1 + 169 + -4.9059916762377265e-01 + 0 0 0 0. @@ -488,8 +488,8 @@ <_> 0 - 6696 - -9.2703622556201423e-15 + 1859 + -7.1054273576010523e-15 0 0 0 @@ -498,13 +498,13 @@ 0. 0. - <_>3 - 5.0727468729019165e-01 - 9. + <_>1 + 5.2672868967056274e-01 + 1.0963299870491028e-01 <_> 1 - 6456 - 1.6434634269188026e-02 + 781 + 1.0385059515501381e-01 1 0 0 @@ -514,8 +514,8 @@ 0. <_> 1 - 240 - -1.4000712292827926e+00 + 1078 + -5.7169325870124055e-01 0 0 0 @@ -528,9 +528,9 @@ <_> 0 - 6696 - 7.5495165674510077e-15 - 1 + 1859 + -1.1102230246251577e-15 + 0 0 0 0. @@ -538,13 +538,13 @@ 0. 0. - <_>1 - 5.0708127021789551e-01 - 1.1246799677610397e-01 + <_>3 + 5.2609002590179443e-01 + 3. <_> 1 - 2822 - 1.5367268082053392e-01 + 856 + 3.2591023278276837e-01 1 0 0 @@ -554,8 +554,8 @@ 0. <_> 1 - 3874 - -9.3153347245118326e-02 + 1003 + -1.6727738809775036e-01 0 0 0 @@ -568,8 +568,8 @@ <_> 0 - 6696 - 1.5765166949676974e-14 + 1859 + 3.5527136788004883e-15 1 0 0 @@ -578,13 +578,13 @@ 0. 0. - <_>3 - 5.0856590270996094e-01 - 3. + <_>1 + 5.1409310102462769e-01 + 7.1857005357742310e-02 <_> 1 - 3996 - 8.6645581882989806e-02 + 114 + 6.4622038086485267e-01 1 0 0 @@ -594,8 +594,8 @@ 0. <_> 1 - 2700 - -2.0087671007861391e-01 + 1745 + -4.9566471799398701e-02 0 0 0 @@ -608,8 +608,8 @@ <_> 0 - 6696 - -1.6653345369377626e-14 + 1859 + -7.4940054162198634e-15 0 0 0 @@ -618,13 +618,13 @@ 0. 0. - <_>0 - 5.0680923461914062e-01 - 1.1478445529937744e+00 + <_>1 + 5.1351374387741089e-01 + 1.4143149554729462e-01 <_> 1 - 5204 - -7.6986298456679980e-02 + 1571 + -4.6424296372866977e-02 0 0 0 @@ -634,8 +634,8 @@ 0. <_> 1 - 1492 - 1.7913581369068632e-01 + 288 + 6.6639156578772774e-01 1 0 0 @@ -648,8 +648,8 @@ <_> 0 - 6696 - 3.9968028886505478e-15 + 1859 + 2.6645352591003686e-15 1 0 0 @@ -659,12 +659,12 @@ 0. <_>1 - 5.0697994232177734e-01 - 2.3513150215148926e-01 + 5.2261954545974731e-01 + 1.0177600383758545e-01 <_> 1 - 6606 - 1.8205194893492923e-02 + 590 + 1.3091283509473614e-01 1 0 0 @@ -674,8 +674,8 @@ 0. <_> 1 - 90 - -1.0127354329715519e+00 + 1269 + -3.6264100845476954e-01 0 0 0 @@ -688,8 +688,8 @@ <_> 0 - 6696 - -1.6930901125533924e-14 + 1859 + 0. 0 0 0 @@ -699,13 +699,13 @@ 0. <_>1 - 5.0548201799392700e-01 - 6.5295994281768799e-02 + 5.2181720733642578e-01 + 8.9620999991893768e-02 <_> 1 - 1017 - 6.0829163150572041e-01 - 1 + 352 + -2.4183425262980360e-01 + 0 0 0 0. @@ -714,9 +714,9 @@ 0. <_> 1 - 5679 - -2.0197118707513909e-02 - 0 + 1507 + 1.8605210755965146e-01 + 1 0 0 0. @@ -728,8 +728,8 @@ <_> 0 - 6696 - 1.4876988529976877e-14 + 1859 + 1.1102230246251554e-15 1 0 0 @@ -739,13 +739,13 @@ 0. <_>1 - 5.0390088558197021e-01 - 7.7498495578765869e-02 + 5.0836616754531860e-01 + 1.0963299870491028e-01 <_> 1 - 1331 - -2.9288428551454943e-01 - 0 + 781 + 5.1954271677409611e-02 + 1 0 0 0. @@ -754,9 +754,9 @@ 0. <_> 1 - 5365 - 2.7401920556891796e-02 - 1 + 1078 + -3.3426585985028628e-01 + 0 0 0 0. @@ -768,8 +768,8 @@ <_> 0 - 6696 - 1.5987211554601999e-14 + 1859 + 3.7747582837255180e-15 1 0 0 @@ -778,14 +778,14 @@ 0. 0. - <_>1 - 5.0314640998840332e-01 - 8.5879504680633545e-02 + <_>0 + 5.0880891084671021e-01 + 1.1348484754562378e+00 <_> 1 - 1585 - 1.9731826096849678e-01 - 1 + 1664 + -7.4858358240636261e-02 + 0 0 0 0. @@ -794,9 +794,9 @@ 0. <_> 1 - 5111 - -3.2315549250537055e-02 - 0 + 195 + 2.4031047447238377e-01 + 1 0 0 0. @@ -808,8 +808,8 @@ <_> 0 - 6696 - -6.6613381477509432e-16 + 1859 + -1.3322676295501896e-15 0 0 0 @@ -818,13 +818,13 @@ 0. 0. - <_>2 - 5.0262790918350220e-01 - 5.0000000000000000e-01 + <_>0 + 5.1081919670104980e-01 + 1.2661495208740234e+00 <_> 1 - 4065 - 4.9691828670874537e-02 + 1730 + 5.6719022662652843e-02 1 0 0 @@ -834,8 +834,8 @@ 0. <_> 1 - 2631 - -1.0625426423292537e-01 + 129 + -4.0229379476194682e-01 0 0 0 @@ -848,9 +848,9 @@ <_> 0 - 6696 - -1.3267165144270797e-14 - 0 + 1859 + 5.5511151231257519e-15 + 1 0 0 0. @@ -858,13 +858,13 @@ 0. 0. - <_>2 - 5.0338900089263916e-01 - 2.5000000000000000e+00 + <_>0 + 5.0904816389083862e-01 + 2.3689103126525879e+00 <_> 1 - 5768 - -1.7170808915642276e-02 + 1838 + -1.9140961693183144e-02 0 0 0 @@ -874,8 +874,8 @@ 0. <_> 1 - 928 - 4.1744759002228976e-01 + 21 + 1.7878855228391193e+00 1 0 0 @@ -888,8 +888,8 @@ <_> 0 - 6696 - -1.7985612998927861e-14 + 1859 + -9.2703622556201423e-15 0 0 0 @@ -898,13 +898,13 @@ 0. 0. - <_>3 - 5.0293552875518799e-01 - 7. + <_>0 + 5.0664407014846802e-01 + 2.2119045257568359e+00 <_> 1 - 6301 - 1.0888539178029287e-02 + 1836 + 1.8191803445960011e-02 1 0 0 @@ -914,8 +914,8 @@ 0. <_> 1 - 395 - -6.0305085268185177e-01 + 23 + -9.2985231739132745e-01 0 0 0 @@ -928,9 +928,9 @@ <_> 0 - 6696 - 3.4638958368303685e-14 - 1 + 1859 + -1.1102230246251577e-15 + 0 0 0 0. @@ -938,14 +938,14 @@ 0. 0. - <_>1 - 5.0289756059646606e-01 - 5.5853001773357391e-02 + <_>0 + 5.0936371088027954e-01 + 1.2460045814514160e+00 <_> 1 - 718 - 1.2205678809210552e+00 - 1 + 1724 + -5.7918483977216939e-02 + 0 0 0 0. @@ -954,9 +954,9 @@ 0. <_> 1 - 5978 - -6.9005117704737801e-03 - 0 + 135 + 3.3577728337370422e-01 + 1 0 0 0. @@ -968,9 +968,9 @@ <_> 0 - 6696 - -2.4868995751604125e-14 - 0 + 1859 + 2.4424906541753385e-15 + 1 0 0 0. @@ -978,13 +978,13 @@ 0. 0. - <_>1 - 5.0243860483169556e-01 - 2.4084049463272095e-01 + <_>0 + 5.0752711296081543e-01 + 9.5505046844482422e-01 <_> 1 - 6641 - 4.8772808782470770e-03 + 1341 + 1.1992717133073164e-01 1 0 0 @@ -994,8 +994,8 @@ 0. <_> 1 - 55 - -5.7564577324601141e+00 + 518 + -1.2680428752841727e-01 0 0 0 @@ -1008,8 +1008,8 @@ <_> 0 - 6696 - -1.5423216747138017e-05 + 1859 + -4.8849813083507124e-15 0 0 0 @@ -1019,13 +1019,13 @@ 0. <_>0 - 5.0226837396621704e-01 - 2.5287950038909912e-01 + 5.0749230384826660e-01 + 7.8355848789215088e-01 <_> 1 - 102 - 6.3884081938725468e-01 - 1 + 764 + -2.4384603502165489e-01 + 0 0 0 0. @@ -1034,9 +1034,9 @@ 0. <_> 1 - 6594 - -8.0577599144550840e-03 - 0 + 1095 + 6.2746713049518996e-02 + 1 0 0 0. @@ -1048,8 +1048,8 @@ <_> 0 - 6696 - 3.5527136788004883e-15 + 1859 + 1.9984014443252778e-15 1 0 0 @@ -1058,14 +1058,14 @@ 0. 0. - <_>0 - 5.0213474035263062e-01 - 7.7158403396606445e-01 + <_>1 + 5.0703763961791992e-01 + 6.3535496592521667e-02 <_> 1 - 2002 - -1.1284984024243835e-01 - 0 + 59 + 5.7564577324623896e+00 + 1 0 0 0. @@ -1074,9 +1074,9 @@ 0. <_> 1 - 4694 - 3.8011668822737661e-02 - 1 + 1800 + -1.4076159604991374e-02 + 0 0 0 0. @@ -1088,9 +1088,9 @@ <_> 0 - 6696 - -1.6209256159527547e-14 - 0 + 1859 + 4.4512436177016777e-05 + 1 0 0 0. @@ -1098,14 +1098,14 @@ 0. 0. - <_>0 - 5.0280165672302246e-01 - 2.2507858276367188e+00 + <_>1 + 5.0712978839874268e-01 + 6.4906999468803406e-02 <_> 1 - 6293 - 2.4730504036563516e-02 - 1 + 61 + -2.8822016897573164e+00 + 0 0 0 0. @@ -1114,9 +1114,9 @@ 0. <_> 1 - 403 - -2.3062669491245841e-01 - 0 + 1798 + 1.4394134992880541e-02 + 1 0 0 0. @@ -1128,8 +1128,8 @@ <_> 0 - 6696 - 3.8191672047103927e-14 + 1859 + 4.4408920985006242e-16 1 0 0 @@ -1138,14 +1138,14 @@ 0. 0. - <_>0 - 5.0253432989120483e-01 - 3.3653845787048340e+00 + <_>1 + 5.1009607315063477e-01 + 6.9339498877525330e-02 <_> 1 - 6503 - -1.2970930120556381e-02 - 0 + 87 + 1.6547355644710868e+00 + 1 0 0 0. @@ -1154,9 +1154,9 @@ 0. <_> 1 - 193 - 4.1274031243257897e-01 - 1 + 1772 + -2.1726950528099288e-02 + 0 0 0 0. @@ -1168,8 +1168,8 @@ <_> 0 - 6696 - -2.8921309791486167e-14 + 1859 + -1.1102230246251577e-15 0 0 0 @@ -1178,14 +1178,14 @@ 0. 0. - <_>1 - 5.0166010856628418e-01 - 2.1390999853610992e-01 + <_>3 + 5.0710922479629517e-01 + 7. <_> 1 - 5531 - -2.6331896149722072e-02 - 0 + 1823 + 1.7568593940350565e-02 + 1 0 0 0. @@ -1194,9 +1194,9 @@ 0. <_> 1 - 1165 - 1.2679568803286576e-01 - 1 + 36 + -1.1252698341588880e+00 + 0 0 0 0. @@ -1208,9 +1208,9 @@ <_> 0 - 6696 - 8.4376949871511187e-15 - 1 + 1859 + -1.7763568394002536e-15 + 0 0 0 0. @@ -1219,12 +1219,12 @@ 0. <_>1 - 5.0131356716156006e-01 - 1.2306049466133118e-01 + 5.0767201185226440e-01 + 8.0150999128818512e-02 <_> 1 - 3485 - 5.4575202207966189e-02 + 206 + 2.7041738749866351e-01 1 0 0 @@ -1234,8 +1234,8 @@ 0. <_> 1 - 3211 - -4.8223341249251692e-02 + 1653 + -5.8184179168035623e-02 0 0 0 @@ -1248,9 +1248,9 @@ <_> 0 - 6696 - -1.3988810110277168e-14 - 0 + 1859 + 3.3306690738754586e-15 + 1 0 0 0. @@ -1258,13 +1258,13 @@ 0. 0. - <_>1 - 5.0198501348495483e-01 - 7.8255996108055115e-02 + <_>0 + 5.0510478019714355e-01 + 6.2720644474029541e-01 <_> 1 - 1348 - -2.1033914009293908e-01 + 374 + -4.5462988716181019e-01 0 0 0 @@ -1274,8 +1274,8 @@ 0. <_> 1 - 5348 - 1.9154114250964308e-02 + 1485 + 2.3987712659202257e-02 1 0 0 @@ -1288,8 +1288,8 @@ <_> 0 - 6696 - -1.4266365866433467e-14 + 1859 + -4.2188474935756130e-15 0 0 0 @@ -1298,14 +1298,14 @@ 0. 0. - <_>1 - 5.0248610973358154e-01 - 7.1467995643615723e-02 + <_>2 + 5.0439256429672241e-01 + 2.5000000000000000e+00 <_> 1 - 1172 - 3.2968968312473473e-01 - 1 + 1791 + -1.5635519241144060e-02 + 0 0 0 0. @@ -1314,9 +1314,9 @@ 0. <_> 1 - 5524 - -1.5625348431658897e-02 - 0 + 68 + 6.3562787613239691e-01 + 1 0 0 0. @@ -1328,8 +1328,8 @@ <_> 0 - 6696 - 2.7311486405778106e-14 + 1859 + 6.6613381477508951e-15 1 0 0 @@ -1339,12 +1339,12 @@ 0. <_>3 - 5.0194221735000610e-01 + 5.0438237190246582e-01 3. <_> 1 - 3996 - 4.0295610512256365e-02 + 856 + 1.3081676957882793e-01 1 0 0 @@ -1354,8 +1354,8 @@ 0. <_> 1 - 2700 - -9.6752005977083597e-02 + 1003 + -6.7484142743913345e-02 0 0 0 @@ -1368,8 +1368,8 @@ <_> 0 - 6696 - 2.2204460492503126e-16 + 1859 + 1.1102230246251554e-15 1 0 0 @@ -1379,13 +1379,13 @@ 0. <_>1 - 5.0114709138870239e-01 - 2.3718249797821045e-01 + 5.0724387168884277e-01 + 1.1533749848604202e-01 <_> 1 - 6622 - -4.1635503904929108e-03 - 0 + 921 + 4.0250806766256482e-02 + 1 0 0 0. @@ -1394,9 +1394,9 @@ 0. <_> 1 - 74 - 6.1985783533374139e-01 - 1 + 938 + -3.7703668263161400e-01 + 0 0 0 0. @@ -1408,8 +1408,8 @@ <_> 0 - 6696 - -1.5543122344752215e-15 + 1859 + -5.8286708792821058e-15 0 0 0 @@ -1419,13 +1419,13 @@ 0. <_>1 - 5.0172209739685059e-01 - 2.2217050194740295e-01 + 5.0915646553039551e-01 + 1.4143149554729462e-01 <_> 1 - 6227 - 1.8681120427040978e-02 - 1 + 1571 + -3.3928131204983447e-02 + 0 0 0 0. @@ -1434,9 +1434,9 @@ 0. <_> 1 - 469 - -1.8652401242387370e-01 - 0 + 288 + 6.0410410576585261e-01 + 1 0 0 0. @@ -1448,9 +1448,9 @@ <_> 0 - 6696 - -1.8263168755084160e-14 - 0 + 1859 + 4.2188474935755767e-15 + 1 0 0 0. @@ -1459,13 +1459,13 @@ 0. <_>1 - 5.0099056959152222e-01 - 4.9510002136230469e-02 + 5.0659310817718506e-01 + 1.4145749807357788e-01 <_> 1 - 558 - -1.2384335357514746e+00 - 0 + 1572 + 2.0368450770510211e-02 + 1 0 0 0. @@ -1474,9 +1474,9 @@ 0. <_> 1 - 6138 - 2.3445521303984249e-03 - 1 + 287 + -7.7093695859120004e-01 + 0 0 0 0. @@ -1488,9 +1488,9 @@ <_> 0 - 6696 - 9.7699626167012829e-15 - 1 + 1859 + -1.3877787807814476e-15 + 0 0 0 0. @@ -1498,13 +1498,13 @@ 0. 0. - <_>2 - 5.0089961290359497e-01 - 2.6500000000000000e+01 + <_>0 + 5.0616967678070068e-01 + 1.6267855167388916e+00 <_> 1 - 6360 - -1.7992041757429087e-03 + 1811 + -2.4173163361906828e-02 0 0 0 @@ -1514,8 +1514,8 @@ 0. <_> 1 - 336 - 5.7564577324623896e+00 + 48 + 5.6348494257358028e-01 1 0 0 @@ -1528,9 +1528,9 @@ <_> 0 - 6696 - 5.6895823335701191e-06 - 1 + 1859 + -3.8857805861880494e-16 + 0 0 0 0. @@ -1538,13 +1538,13 @@ 0. 0. - <_>2 - 5.0118094682693481e-01 - 2.5500000000000000e+01 + <_>0 + 5.0677150487899780e-01 + 1.2661495208740234e+00 <_> 1 - 6354 - 2.4166608864464967e-03 + 1730 + 4.0402378477571901e-02 1 0 0 @@ -1554,8 +1554,8 @@ 0. <_> 1 - 342 - -2.2888465010954078e+00 + 129 + -3.4888339817180891e-01 0 0 0 @@ -1568,8 +1568,8 @@ <_> 0 - 6696 - 1.2212453270876572e-14 + 1859 + 4.4408920985006242e-16 1 0 0 @@ -1578,14 +1578,14 @@ 0. 0. - <_>1 - 5.0121438503265381e-01 - 5.9582501649856567e-02 + <_>0 + 5.0588327646255493e-01 + 1.0797724723815918e+00 <_> 1 - 840 - 5.8664647966628169e-01 - 1 + 1608 + -6.8287991647037555e-02 + 0 0 0 0. @@ -1594,9 +1594,9 @@ 0. <_> 1 - 5856 - -4.6044963433007156e-03 - 0 + 251 + 1.7431967242459881e-01 + 1 0 0 0. @@ -1608,9 +1608,9 @@ <_> 0 - 6696 - -3.5915714846625102e-14 - 0 + 1859 + 4.6629367034256354e-15 + 1 0 0 0. @@ -1618,14 +1618,14 @@ 0. 0. - <_>1 - 5.0101113319396973e-01 - 1.4623999595642090e-01 + <_>0 + 5.0476020574569702e-01 + 9.2052650451660156e-01 <_> 1 - 4616 - -3.5172502282471305e-02 - 0 + 1253 + 1.0513502662517235e-01 + 1 0 0 0. @@ -1634,9 +1634,9 @@ 0. <_> 1 - 2080 - 5.7583719480068560e-02 - 1 + 606 + -9.1138849679050823e-02 + 0 0 0 0. @@ -1648,8 +1648,8 @@ <_> 0 - 6696 - 1.1990408665951547e-14 + 1859 + 1.5543122344752168e-15 1 0 0 @@ -1658,14 +1658,14 @@ 0. 0. - <_>1 - 5.0141471624374390e-01 - 1.2247450649738312e-01 + <_>0 + 5.0690639019012451e-01 + 9.0829002857208252e-01 <_> 1 - 3452 - 5.8002397978578264e-02 - 1 + 1219 + -1.4636537853223561e-01 + 0 0 0 0. @@ -1674,9 +1674,9 @@ 0. <_> 1 - 3244 - -4.8874279877898136e-02 - 0 + 640 + 9.5332675553986543e-02 + 1 0 0 0. @@ -1688,8 +1688,8 @@ <_> 0 - 6696 - 1.5987211554601999e-14 + 1859 + 4.2188474935755767e-15 1 0 0 @@ -1698,14 +1698,14 @@ 0. 0. - <_>1 - 5.0116842985153198e-01 - 7.7498495578765869e-02 + <_>0 + 5.0534439086914062e-01 + 9.2052650451660156e-01 <_> 1 - 1331 - -1.7188494142274119e-01 - 0 + 1253 + 1.1293790129864213e-01 + 1 0 0 0. @@ -1714,9 +1714,9 @@ 0. <_> 1 - 5365 - 1.3729831506301223e-02 - 1 + 606 + -9.5332675553986113e-02 + 0 0 0 0. @@ -1728,8 +1728,8 @@ <_> 0 - 6696 - -1.4155343563970946e-14 + 1859 + -2.1649348980190600e-15 0 0 0 @@ -1739,12 +1739,12 @@ 0. <_>1 - 5.0121414661407471e-01 - 8.5879504680633545e-02 + 5.0435024499893188e-01 + 9.3664005398750305e-02 <_> 1 - 1585 - 1.2910598338382803e-01 + 411 + 8.4555682036086433e-02 1 0 0 @@ -1754,8 +1754,8 @@ 0. <_> 1 - 5111 - -1.8915572816328115e-02 + 1448 + -1.0351006034230040e-01 0 0 0 @@ -1768,9 +1768,9 @@ <_> 0 - 6696 - -9.8254737679327316e-15 - 0 + 1859 + 2.2204460492503126e-16 + 1 0 0 0. @@ -1779,12 +1779,12 @@ 0. <_>1 - 5.0097846984863281e-01 - 1.4246150851249695e-01 + 5.0704753398895264e-01 + 9.9698998034000397e-02 <_> 1 - 4487 - -3.6309005742797516e-02 + 544 + -8.5042709024257673e-02 0 0 0 @@ -1794,8 +1794,8 @@ 0. <_> 1 - 2209 - 5.3973974005312779e-02 + 1315 + 1.6769533771522532e-01 1 0 0 @@ -1808,9 +1808,9 @@ <_> 0 - 6696 - -3.5527136788005136e-15 - 0 + 1859 + 1.5543122344752168e-15 + 1 0 0 0. @@ -1818,13 +1818,13 @@ 0. 0. - <_>0 - 5.0104773044586182e-01 - 2.2507858276367188e+00 + <_>1 + 5.0574851036071777e-01 + 1.0386450588703156e-01 <_> 1 - 6293 - 1.5347843260515710e-02 + 639 + 5.3643508899729207e-02 1 0 0 @@ -1834,8 +1834,8 @@ 0. <_> 1 - 403 - -1.3739749447098926e-01 + 1220 + -2.1791341988666471e-01 0 0 0 @@ -1848,8 +1848,8 @@ <_> 0 - 6696 - 1.1102230246251442e-14 + 1859 + 0. 1 0 0 @@ -1858,13 +1858,13 @@ 0. 0. - <_>0 - 5.0123411417007446e-01 - 1.5166850090026855e+00 + <_>1 + 5.0597953796386719e-01 + 1.4143149554729462e-01 <_> 1 - 5860 - -2.3701090631262016e-02 + 1571 + -2.3199011211312900e-02 0 0 0 @@ -1874,8 +1874,8 @@ 0. <_> 1 - 836 - 1.0454047746295661e-01 + 288 + 5.7032019870719552e-01 1 0 0 @@ -1888,9 +1888,9 @@ <_> 0 - 6696 - -1.2823075934420722e-14 - 0 + 1859 + 1.5543122344752168e-15 + 1 0 0 0. @@ -1898,13 +1898,13 @@ 0. 0. - <_>0 - 5.0128591060638428e-01 - 9.4609153270721436e-01 + <_>1 + 5.0620901584625244e-01 + 1.1533749848604202e-01 <_> 1 - 4087 - 5.1776557405042833e-02 + 921 + 3.0260573388611104e-02 1 0 0 @@ -1914,8 +1914,8 @@ 0. <_> 1 - 2609 - -4.9756941186903984e-02 + 938 + -4.3620446423872927e-01 0 0 0 @@ -1928,8 +1928,8 @@ <_> 0 - 6696 - -7.3274719625260868e-15 + 1859 + -6.6613381477509432e-16 0 0 0 @@ -1938,13 +1938,13 @@ 0. 0. - <_>0 - 5.0179207324981689e-01 - 9.0595495700836182e-01 + <_>1 + 5.0698792934417725e-01 + 1.0789400339126587e-01 <_> 1 - 3201 - -7.3543589169859577e-02 + 742 + -4.7900146843168623e-02 0 0 0 @@ -1954,8 +1954,8 @@ 0. <_> 1 - 3495 - 4.8861495908556145e-02 + 1117 + 3.0074316296999687e-01 1 0 0 @@ -1968,9 +1968,9 @@ <_> 0 - 6696 - 6.2172489379008380e-15 - 1 + 1859 + -6.6613381477509432e-16 + 0 0 0 0. @@ -1979,13 +1979,13 @@ 0. <_>0 - 5.0125002861022949e-01 - 9.4482445716857910e-01 + 5.0459891557693481e-01 + 9.0829002857208252e-01 <_> 1 - 4054 - 5.1511711137020161e-02 - 1 + 1219 + -1.1779072393798255e-01 + 0 0 0 0. @@ -1994,9 +1994,9 @@ 0. <_> 1 - 2642 - -4.8614381935802115e-02 - 0 + 640 + 7.8608870331688729e-02 + 1 0 0 0. @@ -2008,8 +2008,8 @@ <_> 0 - 6696 - 1.1324274851176469e-14 + 1859 + 1.3322676295501861e-15 1 0 0 @@ -2018,13 +2018,13 @@ 0. 0. - <_>1 - 5.0097835063934326e-01 - 1.9254249334335327e-01 + <_>0 + 5.0399231910705566e-01 + 3.3933651447296143e-01 <_> 1 - 5273 - 2.4249345169349911e-02 + 59 + 1.3770357317310018e+00 1 0 0 @@ -2034,8 +2034,8 @@ 0. <_> 1 - 1423 - -8.0884629261426991e-02 + 1800 + -9.0707243801608061e-03 0 0 0 @@ -2048,8 +2048,8 @@ <_> 0 - 6696 - 0. + 1859 + -2.6090241078691246e-15 0 0 0 @@ -2058,65 +2058,25 @@ 0. 0. - <_>0 - 5.0128620862960815e-01 - 9.0595495700836182e-01 - <_> - 1 - 3201 - -6.1924911935004358e-02 - 0 - 0 - 0 - 0. - 0. - 0. - 0. + <_>1 + 5.0383007526397705e-01 + 1.0386450588703156e-01 <_> 1 - 3495 - 4.1617731368296211e-02 + 639 + 4.0916632352681503e-02 1 0 0 0. 0. 0. - 0. - <_> - -1 - - <_> - 0 - 6696 - -6.8833827526760179e-15 - 0 - 0 - 0 - 0. - 0. - 0. - 0. - - <_>2 - 5.0084191560745239e-01 - 1.0500000000000000e+01 - <_> - 1 - 6225 - -2.3118353841113238e-03 - 0 - 0 - 0 - 0. - 0. - 0. 0. <_> 1 - 471 - 9.2521939431936440e-01 - 1 + 1220 + -1.8955755646648090e-01 + 0 0 0 0. @@ -2128,8 +2088,8 @@ <_> 0 - 6696 - -2.8865798640254153e-15 + 1859 + -6.6613381477509432e-16 0 0 0 @@ -2138,14 +2098,14 @@ 0. 0. - <_>2 - 5.0089126825332642e-01 - 1.5000000000000000e+00 + <_>1 + 5.0380486249923706e-01 + 9.9698998034000397e-02 <_> 1 - 5523 - 1.2785114635458802e-02 - 1 + 544 + -5.8888670701558621e-02 + 0 0 0 0. @@ -2154,9 +2114,9 @@ 0. <_> 1 - 1173 - -1.4034194909765221e-01 - 0 + 1315 + 1.3009980239826119e-01 + 1 0 0 0. @@ -2168,8 +2128,8 @@ <_> 0 - 6696 - 1.4876988529976877e-14 + 1859 + 2.2204460492503083e-15 1 0 0 @@ -2178,13 +2138,13 @@ 0. 0. - <_>0 - 5.0066828727722168e-01 - 9.4609153270721436e-01 + <_>1 + 5.0560057163238525e-01 + 9.4531498849391937e-02 <_> 1 - 4087 - 3.7042053076389733e-02 + 431 + 8.6647133637941770e-02 1 0 0 @@ -2194,8 +2154,8 @@ 0. <_> 1 - 2609 - -3.6115236940030694e-02 + 1428 + -1.3032934253469194e-01 0 0 0 @@ -2208,9 +2168,9 @@ <_> 0 - 6696 - 2.4424906541753385e-15 - 1 + 1859 + -1.3877787807814476e-15 + 0 0 0 0. @@ -2219,12 +2179,12 @@ 0. <_>1 - 5.0070559978485107e-01 - 2.1943551301956177e-01 + 5.0492835044860840e-01 + 8.9620999991893768e-02 <_> 1 - 5937 - -1.3556222624079359e-02 + 352 + -1.0506312397672390e-01 0 0 0 @@ -2234,8 +2194,8 @@ 0. <_> 1 - 759 - 1.0448586331664383e-01 + 1507 + 9.4441739612300818e-02 1 0 0 @@ -2248,9 +2208,9 @@ <_> 0 - 6696 - 2.2204460492503126e-16 - 1 + 1859 + -9.4368957093138405e-16 + 0 0 0 0. @@ -2258,14 +2218,14 @@ 0. 0. - <_>2 - 5.0076895952224731e-01 - 2.5000000000000000e+00 + <_>1 + 5.0368678569793701e-01 + 9.2722505331039429e-02 <_> 1 - 5768 - -7.2706716286118954e-03 - 0 + 392 + 7.6022467408684444e-02 + 1 0 0 0. @@ -2274,9 +2234,9 @@ 0. <_> 1 - 928 - 2.1477157646629505e-01 - 1 + 1467 + -9.7486085972466607e-02 + 0 0 0 0. @@ -2288,8 +2248,8 @@ <_> 0 - 6696 - 3.9968028886505478e-15 + 1859 + 3.1086244689504288e-15 1 0 0 @@ -2298,14 +2258,14 @@ 0. 0. - <_>2 - 5.0089627504348755e-01 - 5.5000000000000000e+00 + <_>1 + 5.0421810150146484e-01 + 9.9444493651390076e-02 <_> 1 - 6059 - 4.7555763245711435e-03 - 1 + 536 + -6.3752797298286562e-02 + 0 0 0 0. @@ -2314,9 +2274,9 @@ 0. <_> 1 - 637 - -3.9649216330408060e-01 - 0 + 1323 + 1.3328967944519532e-01 + 1 0 0 0. @@ -2328,9 +2288,9 @@ <_> 0 - 6696 - -5.1070259132757461e-15 - 0 + 1859 + 4.4408920985006242e-16 + 1 0 0 0. @@ -2338,14 +2298,14 @@ 0. 0. - <_>0 - 5.0070571899414062e-01 - 1.0819125175476074e+00 + <_>1 + 5.0323176383972168e-01 + 1.0177600383758545e-01 <_> 1 - 4995 - -2.7626368121990579e-02 - 0 + 590 + 4.3831310206729070e-02 + 1 0 0 0. @@ -2354,9 +2314,9 @@ 0. <_> 1 - 1701 - 5.1146227808315924e-02 - 1 + 1269 + -1.4864401441489694e-01 + 0 0 0 0. @@ -2368,8 +2328,8 @@ <_> 0 - 6696 - -1.3877787807814476e-15 + 1859 + -8.8817841970012602e-16 0 0 0 @@ -2379,13 +2339,13 @@ 0. <_>1 - 5.0076258182525635e-01 - 2.3045200109481812e-01 + 5.0349098443984985e-01 + 1.0789400339126587e-01 <_> 1 - 6570 - 6.0114816457133369e-03 - 1 + 742 + -3.4075730824220232e-02 + 0 0 0 0. @@ -2394,9 +2354,9 @@ 0. <_> 1 - 126 - -2.5936805626824372e-01 - 0 + 1117 + 2.0791874238488089e-01 + 1 0 0 0. @@ -2408,8 +2368,8 @@ <_> 0 - 6696 - -3.8857805861880494e-16 + 1859 + -4.4408920985006281e-16 0 0 0 @@ -2419,13 +2379,13 @@ 0. <_>1 - 5.0089013576507568e-01 - 2.2690850496292114e-01 + 5.0392138957977295e-01 + 1.0963299870491028e-01 <_> 1 - 6527 - -8.4053681892962469e-03 - 0 + 781 + 2.6986027157566792e-02 + 1 0 0 0. @@ -2434,9 +2394,9 @@ 0. <_> 1 - 169 - 2.1506217431803590e-01 - 1 + 1078 + -2.9932407189155552e-01 + 0 0 0 0. @@ -2448,9 +2408,9 @@ <_> 0 - 6696 - 5.3290705182007230e-15 - 1 + 1859 + -6.6613381477509432e-16 + 0 0 0 0. @@ -2458,14 +2418,14 @@ 0. 0. - <_>1 - 5.0091993808746338e-01 - 1.9974449276924133e-01 + <_>0 + 5.0362765789031982e-01 + 2.3689103126525879e+00 <_> 1 - 5306 - 2.3129710639090150e-02 - 1 + 1838 + -9.2384036977927863e-03 + 0 0 0 0. @@ -2474,9 +2434,9 @@ 0. <_> 1 - 1390 - -7.9729164788981108e-02 - 0 + 21 + 1.0592165467278325e+00 + 1 0 0 0. @@ -2488,8 +2448,8 @@ <_> 0 - 6696 - -6.8833827526760179e-15 + 1859 + -1.9984014443252857e-15 0 0 0 @@ -2498,13 +2458,13 @@ 0. 0. - <_>3 - 5.0070244073867798e-01 - 15. + <_>0 + 5.0543153285980225e-01 + 2.2119045257568359e+00 <_> 1 - 6577 - 1.4519902873964278e-03 + 1836 + 1.5914551618823981e-02 1 0 0 @@ -2514,8 +2474,8 @@ 0. <_> 1 - 119 - -2.0528590518345577e+00 + 23 + -8.3405482949082688e-01 0 0 0 @@ -2528,8 +2488,8 @@ <_> 0 - 6696 - 6.6613381477509353e-16 + 1859 + 3.5527136788004883e-15 1 0 0 @@ -2538,13 +2498,13 @@ 0. 0. - <_>1 - 5.0066137313842773e-01 - 1.5967300534248352e-01 + <_>0 + 5.0523018836975098e-01 + 1.6267855167388916e+00 <_> 1 - 4943 - -2.4632987250352092e-02 + 1811 + -1.9824411253917307e-02 0 0 0 @@ -2554,8 +2514,8 @@ 0. <_> 1 - 1753 - 5.3762047393361698e-02 + 48 + 5.8698394468331438e-01 1 0 0 @@ -2568,8 +2528,8 @@ <_> 0 - 6696 - -1.1601830607333020e-14 + 1859 + -4.2188474935756130e-15 0 0 0 @@ -2578,14 +2538,14 @@ 0. 0. - <_>2 - 5.0063061714172363e-01 - 6.5000000000000000e+00 + <_>0 + 5.0369459390640259e-01 + 1.2661495208740234e+00 <_> 1 - 6108 - -2.7833790336225339e-03 - 0 + 1730 + 2.8318382799977653e-02 + 1 0 0 0. @@ -2594,9 +2554,9 @@ 0. <_> 1 - 588 - 4.8862416747241927e-01 - 1 + 129 + -2.6718445379285333e-01 + 0 0 0 0. @@ -2608,8 +2568,8 @@ <_> 0 - 6696 - 7.3274719625259795e-15 + 1859 + 2.2204460492503126e-16 1 0 0 @@ -2618,14 +2578,14 @@ 0. 0. - <_>2 - 5.0056153535842896e-01 - 2.5500000000000000e+01 + <_>0 + 5.0479084253311157e-01 + 1.2460045814514160e+00 <_> 1 - 6354 - 1.2338724584192815e-03 - 1 + 1724 + -3.7451522137317672e-02 + 0 0 0 0. @@ -2634,9 +2594,9 @@ 0. <_> 1 - 342 - -1.5285879647299458e+00 - 0 + 135 + 2.6178246916992864e-01 + 1 0 0 0. @@ -2648,8 +2608,8 @@ <_> 0 - 6696 - 1.7985612998927211e-14 + 1859 + 6.6613381477509353e-16 1 0 0 @@ -2658,13 +2618,13 @@ 0. 0. - <_>1 - 5.0059783458709717e-01 - 6.9747999310493469e-02 + <_>0 + 5.0358188152313232e-01 + 1.2661495208740234e+00 <_> 1 - 1130 - 1.9080524927748807e-01 + 1730 + 2.7995062956094632e-02 1 0 0 @@ -2674,8 +2634,8 @@ 0. <_> 1 - 5566 - -6.3423198578975272e-03 + 129 + -2.6178246916992898e-01 0 0 0 @@ -2688,8 +2648,8 @@ <_> 0 - 6696 - -1.1990408665951834e-14 + 1859 + -5.5511151231257827e-17 0 0 0 @@ -2698,13 +2658,13 @@ 0. 0. - <_>1 - 5.0096279382705688e-01 - 6.0209497809410095e-02 + <_>2 + 5.0313872098922729e-01 + 5.0000000000000000e-01 <_> 1 - 861 - -4.0817517109117923e-01 + 1046 + -8.7344555737785268e-02 0 0 0 @@ -2714,8 +2674,8 @@ 0. <_> 1 - 5835 - 4.9768691931133605e-03 + 813 + 7.2176940461025546e-02 1 0 0 @@ -2728,9 +2688,9 @@ <_> 0 - 6696 - 2.8865798640253987e-15 - 1 + 1859 + -1.9984014443252857e-15 + 0 0 0 0. @@ -2738,14 +2698,14 @@ 0. 0. - <_>1 - 5.0055110454559326e-01 - 2.2292549908161163e-01 + <_>0 + 5.0293076038360596e-01 + 1.2460045814514160e+00 <_> 1 - 6305 - 9.6745303354929309e-03 - 1 + 1724 + -2.8268637265518849e-02 + 0 0 0 0. @@ -2754,9 +2714,9 @@ 0. <_> 1 - 391 - -1.1442976817312843e-01 - 0 + 135 + 2.1045949672703843e-01 + 1 0 0 0. @@ -2768,8 +2728,8 @@ <_> 0 - 6696 - 4.6629367034256354e-15 + 1859 + 4.2188474935755767e-15 1 0 0 @@ -2778,13 +2738,13 @@ 0. 0. - <_>0 - 5.0055730342864990e-01 - 2.0428659915924072e+00 + <_>3 + 5.0332474708557129e-01 + 3. <_> 1 - 6209 - 1.2165695293698981e-02 + 856 + 1.2230679161917310e-01 1 0 0 @@ -2794,8 +2754,8 @@ 0. <_> 1 - 487 - -9.1881742448303563e-02 + 1003 + -5.4692581535459049e-02 0 0 0 @@ -2808,8 +2768,8 @@ <_> 0 - 6696 - -1.0880185641326652e-14 + 1859 + -1.9984014443252857e-15 0 0 0 @@ -2818,14 +2778,14 @@ 0. 0. - <_>0 - 5.0080114603042603e-01 - 1.7432234287261963e+00 + <_>1 + 5.0446850061416626e-01 + 1.1533749848604202e-01 <_> 1 - 6040 - -1.6635134534456867e-02 - 0 + 921 + 2.3320665865473968e-02 + 1 0 0 0. @@ -2834,9 +2794,9 @@ 0. <_> 1 - 656 - 9.6630407896139747e-02 - 1 + 938 + -4.0391049572091403e-01 + 0 0 0 0. @@ -2848,8 +2808,8 @@ <_> 0 - 6696 - 7.7715611723760358e-15 + 1859 + 1.5543122344752168e-15 1 0 0 @@ -2858,13 +2818,13 @@ 0. 0. - <_>0 - 5.0061732530593872e-01 - 2.0428659915924072e+00 + <_>1 + 5.0324887037277222e-01 + 8.0150999128818512e-02 <_> 1 - 6209 - 1.2816939066706903e-02 + 206 + 1.6178738318585617e-01 1 0 0 @@ -2874,8 +2834,8 @@ 0. <_> 1 - 487 - -9.6630407896139317e-02 + 1653 + -4.0534413064780048e-02 0 0 0 @@ -2888,9 +2848,9 @@ <_> 0 - 6696 - -2.2204460492503136e-16 - 0 + 1859 + 1.5543122344752168e-15 + 1 0 0 0. @@ -2899,12 +2859,12 @@ 0. <_>1 - 5.0048106908798218e-01 - 2.1943551301956177e-01 + 5.0377529859542847e-01 + 1.4143149554729462e-01 <_> 1 - 5937 - -1.1171481463132401e-02 + 1571 + -1.6597530926694307e-02 0 0 0 @@ -2914,8 +2874,8 @@ 0. <_> 1 - 759 - 8.6341268832712953e-02 + 288 + 4.9094014377722600e-01 1 0 0 @@ -2928,8 +2888,8 @@ <_> 0 - 6696 - -9.7699626167014722e-15 + 1859 + -3.1086244689504478e-15 0 0 0 @@ -2939,12 +2899,12 @@ 0. <_>0 - 5.0053101778030396e-01 - 1.7432234287261963e+00 + 5.0313144922256470e-01 + 4.5337548851966858e-01 <_> 1 - 6040 - -1.3543848469927067e-02 + 110 + -8.1199669103862704e-01 0 0 0 @@ -2954,8 +2914,8 @@ 0. <_> 1 - 656 - 7.8582931296741751e-02 + 1749 + 9.3381880402274662e-03 1 0 0 @@ -2968,9 +2928,9 @@ <_> 0 - 6696 - -5.1070259132757461e-15 - 0 + 1859 + 3.7747582837255180e-15 + 1 0 0 0. @@ -2979,12 +2939,12 @@ 0. <_>0 - 5.0048828125000000e-01 - 9.1913700103759766e-01 + 5.0475740432739258e-01 + 4.5797997713088989e-01 <_> 1 - 3647 - 3.4887448910966123e-02 + 113 + 6.8212891092482997e-01 1 0 0 @@ -2994,8 +2954,8 @@ 0. <_> 1 - 3049 - -2.8012044396154241e-02 + 1746 + -1.6049266927207175e-02 0 0 0 @@ -3008,9 +2968,9 @@ <_> 0 - 6696 - 5.5511151231257519e-15 - 1 + 1859 + -6.6613381477509432e-16 + 0 0 0 0. @@ -3018,13 +2978,13 @@ 0. 0. - <_>0 - 5.0055414438247681e-01 - 9.0595495700836182e-01 + <_>1 + 5.0308030843734741e-01 + 6.4906999468803406e-02 <_> 1 - 3201 - -4.0494401261701257e-02 + 61 + -1.8287112564925503e+00 0 0 0 @@ -3034,8 +2994,8 @@ 0. <_> 1 - 3495 - 2.7391089531531652e-02 + 1798 + 6.4869817401182221e-03 1 0 0 @@ -3048,9 +3008,9 @@ <_> 0 - 6696 - -4.2188474935756130e-15 - 0 + 1859 + 6.6613381477509353e-16 + 1 0 0 0. @@ -3059,12 +3019,12 @@ 0. <_>1 - 5.0054299831390381e-01 - 1.9254249334335327e-01 + 5.0292497873306274e-01 + 1.4145749807357788e-01 <_> 1 - 5273 - 1.8114158117713660e-02 + 1572 + 1.1075480383243890e-02 1 0 0 @@ -3074,8 +3034,8 @@ 0. <_> 1 - 1423 - -6.0031734810025980e-02 + 287 + -5.8766713493584966e-01 0 0 0 @@ -3088,9 +3048,9 @@ <_> 0 - 6696 - 8.8817841970012444e-16 - 1 + 1859 + -6.6613381477509432e-16 + 0 0 0 0. @@ -3099,12 +3059,12 @@ 0. <_>1 - 5.0045472383499146e-01 - 2.1390999853610992e-01 + 5.0272303819656372e-01 + 1.0132449865341187e-01 <_> 1 - 5531 - -1.3573468584292573e-02 + 577 + -4.4462051722396978e-02 0 0 0 @@ -3114,8 +3074,8 @@ 0. <_> 1 - 1165 - 6.7110013394457699e-02 + 1282 + 1.2318755109692310e-01 1 0 0 @@ -3128,8 +3088,8 @@ <_> 0 - 6696 - 5.7731597280507809e-15 + 1859 + 1.5543122344752168e-15 1 0 0 @@ -3139,12 +3099,12 @@ 0. <_>1 - 5.0056809186935425e-01 - 2.2181048989295959e-01 + 5.0431984663009644e-01 + 9.4531498849391937e-02 <_> 1 - 6195 - 1.0958949879470268e-02 + 431 + 7.5132879390893734e-02 1 0 0 @@ -3154,8 +3114,8 @@ 0. <_> 1 - 501 - -1.0405905416434932e-01 + 1428 + -1.1572265040778912e-01 0 0 0 @@ -3168,8 +3128,8 @@ <_> 0 - 6696 - -8.8817841970013312e-15 + 1859 + -6.6613381477509432e-16 0 0 0 @@ -3179,12 +3139,12 @@ 0. <_>1 - 5.0050455331802368e-01 - 2.3346549272537231e-01 + 5.0449663400650024e-01 + 8.3246499300003052e-02 <_> 1 - 6598 - -3.7162552864078665e-03 + 254 + -1.3886315377806810e-01 0 0 0 @@ -3194,8 +3154,8 @@ 0. <_> 1 - 98 - 2.7851529107598672e-01 + 1605 + 6.5272198323505989e-02 1 0 0 @@ -3208,8 +3168,8 @@ <_> 0 - 6696 - 5.7731597280507809e-15 + 1859 + 2.2204460492503126e-16 1 0 0 @@ -3219,12 +3179,12 @@ 0. <_>1 - 5.0067859888076782e-01 - 2.2977349162101746e-01 + 5.0269138813018799e-01 + 8.0150999128818512e-02 <_> 1 - 6564 - 5.9841883908755391e-03 + 206 + 1.4709439757444326e-01 1 0 0 @@ -3234,8 +3194,8 @@ 0. <_> 1 - 132 - -2.3081415106275815e-01 + 1653 + -3.6874150180988774e-02 0 0 0 @@ -3248,8 +3208,8 @@ <_> 0 - 6696 - -6.7168492989822420e-15 + 1859 + -6.6613381477509432e-16 0 0 0 @@ -3258,13 +3218,13 @@ 0. 0. - <_>1 - 5.0083827972412109e-01 - 2.2690850496292114e-01 + <_>2 + 5.0234586000442505e-01 + 5.5000000000000000e+00 <_> 1 - 6527 - -8.0783228170665522e-03 + 1819 + -6.0288987564491008e-03 0 0 0 @@ -3274,8 +3234,8 @@ 0. <_> 1 - 169 - 2.1059902875292844e-01 + 40 + 1.0408276196291879e+00 1 0 0 @@ -3288,9 +3248,9 @@ <_> 0 - 6696 - 3.3306690738754586e-15 - 1 + 1859 + -2.2204460492503136e-16 + 0 0 0 0. @@ -3298,13 +3258,13 @@ 0. 0. - <_>1 - 5.0056660175323486e-01 - 2.2977349162101746e-01 + <_>2 + 5.0341212749481201e-01 + 4.5000000000000000e+00 <_> 1 - 6564 - 5.4599483267954918e-03 + 1810 + 1.0137680632639267e-02 1 0 0 @@ -3314,8 +3274,8 @@ 0. <_> 1 - 132 - -2.1059902875292799e-01 + 49 + -8.1653792840371642e-01 0 0 0 @@ -3328,8 +3288,8 @@ <_> 0 - 6696 - -5.5511151231257827e-17 + 1859 + -1.2767564783189316e-15 0 0 0 @@ -3339,12 +3299,12 @@ 0. <_>0 - 5.0044262409210205e-01 - 5.9594953060150146e-01 + 5.0258362293243408e-01 + 9.2052650451660156e-01 <_> 1 - 947 - 7.4434424661432769e-02 + 1253 + 7.8639624293829910e-02 1 0 0 @@ -3354,8 +3314,8 @@ 0. <_> 1 - 5749 - -1.1915844396920790e-02 + 606 + -6.5938476875607277e-02 0 0 0 @@ -3368,8 +3328,8 @@ <_> 0 - 6696 - 8.2156503822260906e-15 + 1859 + 2.8865798640253987e-15 1 0 0 @@ -3378,13 +3338,13 @@ 0. 0. - <_>1 - 5.0045764446258545e-01 - 2.1943551301956177e-01 + <_>0 + 5.0378650426864624e-01 + 6.9388854503631592e-01 <_> 1 - 5937 - -1.0789854032467761e-02 + 533 + -2.7381819728273915e-01 0 0 0 @@ -3394,8 +3354,8 @@ 0. <_> 1 - 759 - 8.5034851941486828e-02 + 1326 + 2.8352394260546955e-02 1 0 0 @@ -3408,8 +3368,8 @@ <_> 0 - 6696 - -1.7763568394002536e-15 + 1859 + -1.1102230246251577e-15 0 0 0 @@ -3418,14 +3378,14 @@ 0. 0. - <_>1 - 5.0045067071914673e-01 - 1.0878099501132965e-01 + <_>2 + 5.0225412845611572e-01 + 2.5000000000000000e+00 <_> 1 - 2616 - 4.3888692055889571e-02 - 1 + 1791 + -1.0029134530916375e-02 + 0 0 0 0. @@ -3434,9 +3394,9 @@ 0. <_> 1 - 4080 - -2.0552208863441928e-02 - 0 + 68 + 4.8411186971158215e-01 + 1 0 0 0. @@ -3448,8 +3408,8 @@ <_> 0 - 6696 - -2.2204460492503136e-16 + 1859 + -2.2204460492503178e-15 0 0 0 @@ -3458,13 +3418,13 @@ 0. 0. - <_>1 - 5.0064951181411743e-01 - 7.8714996576309204e-02 + <_>0 + 5.0205397605895996e-01 + 2.3689103126525879e+00 <_> 1 - 1358 - -1.2807332940239827e-01 + 1838 + -6.5406523866491815e-03 0 0 0 @@ -3474,8 +3434,8 @@ 0. <_> 1 - 5338 - 1.0198923757349111e-02 + 21 + 7.3822507765214740e-01 1 0 0 @@ -3488,9 +3448,9 @@ <_> 0 - 6696 - -4.4964032497319045e-15 - 0 + 1859 + 2.8865798640253987e-15 + 1 0 0 0. @@ -3498,13 +3458,13 @@ 0. 0. - <_>1 - 5.0096720457077026e-01 - 7.1467995643615723e-02 + <_>0 + 5.0392109155654907e-01 + 2.2119045257568359e+00 <_> 1 - 1172 - 2.2610922663354846e-01 + 1836 + 1.2851614092359220e-02 1 0 0 @@ -3514,8 +3474,8 @@ 0. <_> 1 - 5524 - -8.7007112104894625e-03 + 23 + -7.0930664915331199e-01 0 0 0 @@ -3528,9 +3488,9 @@ <_> 0 - 6696 - 6.4392935428258661e-15 - 1 + 1859 + -1.7208456881689956e-15 + 0 0 0 0. @@ -3538,13 +3498,13 @@ 0. 0. - <_>1 - 5.0050342082977295e-01 - 7.7498495578765869e-02 + <_>0 + 5.0325584411621094e-01 + 1.6267855167388916e+00 <_> 1 - 1331 - -1.1596157752301800e-01 + 1811 + -1.4416639629038558e-02 0 0 0 @@ -3554,8 +3514,8 @@ 0. <_> 1 - 5365 - 8.7217073487711374e-03 + 48 + 4.8685109113945280e-01 1 0 0 @@ -3568,9 +3528,9 @@ <_> 0 - 6696 - -3.9968028886505793e-15 - 0 + 1859 + 1.5543122344752168e-15 + 1 0 0 0. @@ -3578,13 +3538,13 @@ 0. 0. - <_>1 - 5.0044137239456177e-01 - 9.2569001019001007e-02 + <_>0 + 5.0334036350250244e-01 + 1.4522725343704224e+00 <_> 1 - 1806 - 6.5049069533991741e-02 + 1776 + 2.1134121503482612e-02 1 0 0 @@ -3594,8 +3554,8 @@ 0. <_> 1 - 4890 - -1.3590045945499412e-02 + 83 + -3.2737254080837347e-01 0 0 0 @@ -3608,8 +3568,8 @@ <_> 0 - 6696 - -6.6613381477509834e-15 + 1859 + -2.2204460492503136e-16 0 0 0 @@ -3618,13 +3578,53 @@ 0. 0. - <_>3 - 5.0045472383499146e-01 - 3. + <_>0 + 5.0246149301528931e-01 + 9.0829002857208252e-01 + <_> + 1 + 1219 + -8.5346673521825803e-02 + 0 + 0 + 0 + 0. + 0. + 0. + 0. + <_> + 1 + 640 + 5.7886290686531831e-02 + 1 + 0 + 0 + 0. + 0. + 0. + 0. + <_> + -1 + + <_> + 0 + 1859 + 4.4408920985006242e-16 + 1 + 0 + 0 + 0. + 0. + 0. + 0. + + <_>0 + 5.0454872846603394e-01 + 7.8601944446563721e-01 <_> 1 - 3996 - 1.9372403332724102e-02 + 774 + 1.8066758954429543e-01 1 0 0 @@ -3634,8 +3634,8 @@ 0. <_> 1 - 2700 - -4.6983655893048516e-02 + 1085 + -5.0945701357667621e-02 0 0 0 @@ -3648,9 +3648,9 @@ <_> 0 - 6696 - -1.9984014443252857e-15 - 0 + 1859 + 3.1086244689504288e-15 + 1 0 0 0. @@ -3659,12 +3659,12 @@ 0. <_>0 - 5.0038576126098633e-01 - 1.6262821197509766e+01 + 5.0212800502777100e-01 + 1.5322914123535156e+00 <_> 1 - 6672 - -7.7151022484104465e-04 + 1796 + -1.4167158667728857e-02 0 0 0 @@ -3674,8 +3674,8 @@ 0. <_> 1 - 24 - 5.7564577324623896e+00 + 63 + 3.0999551339753734e-01 1 0 0 @@ -3688,9 +3688,9 @@ <_> 0 - 6696 - 2.4397360458841918e-06 - 1 + 1859 + -8.8817841970012602e-16 + 0 0 0 0. @@ -3698,13 +3698,13 @@ 0. 0. - <_>0 - 5.0039798021316528e-01 - 4.2022142410278320e+00 + <_>1 + 5.0266414880752563e-01 + 1.0847599804401398e-01 <_> 1 - 6568 - 3.5478094143947562e-03 + 754 + 2.2656461251734570e-02 1 0 0 @@ -3714,8 +3714,8 @@ 0. <_> 1 - 128 - -2.2840957942555040e-01 + 1105 + -2.3970407856964623e-01 0 0 0 @@ -3728,9 +3728,9 @@ <_> 0 - 6696 - -1.3877787807814476e-15 - 0 + 1859 + 8.8817841970012444e-16 + 1 0 0 0. @@ -3738,13 +3738,13 @@ 0. 0. - <_>0 - 5.0070858001708984e-01 - 3.6316020488739014e+00 + <_>1 + 5.0370788574218750e-01 + 1.0789400339126587e-01 <_> 1 - 6533 - -6.0271504793015986e-03 + 742 + -3.1940419009583935e-02 0 0 0 @@ -3754,8 +3754,8 @@ 0. <_> 1 - 163 - 2.3962237729233701e-01 + 1117 + 2.3657134249111228e-01 1 0 0 @@ -3768,9 +3768,9 @@ <_> 0 - 6696 - 5.5511151231257519e-15 - 1 + 1859 + -2.2204460492503136e-16 + 0 0 0 0. @@ -3778,13 +3778,13 @@ 0. 0. - <_>0 - 5.0043815374374390e-01 - 4.2022142410278320e+00 + <_>1 + 5.0368273258209229e-01 + 1.0177600383758545e-01 <_> 1 - 6568 - 3.7270150937976335e-03 + 590 + 4.4494384607886871e-02 1 0 0 @@ -3794,8 +3794,8 @@ 0. <_> 1 - 128 - -2.3962237729233693e-01 + 1269 + -1.6718599716109608e-01 0 0 0 @@ -3808,9 +3808,9 @@ <_> 0 - 6696 - -4.3853809472693873e-15 - 0 + 1859 + 0. + 1 0 0 0. @@ -3818,13 +3818,13 @@ 0. 0. - <_>0 - 5.0041538476943970e-01 - 5.0116462707519531e+00 + <_>1 + 5.0391924381256104e-01 + 1.0132449865341187e-01 <_> 1 - 6605 - -3.0578445307874662e-03 + 577 + -5.2562531380568607e-02 0 0 0 @@ -3834,8 +3834,8 @@ 0. <_> 1 - 91 - 2.7868955243849686e-01 + 1282 + 1.5038797351826086e-01 1 0 0 @@ -3848,8 +3848,8 @@ <_> 0 - 6696 - -6.2727600891321739e-15 + 1859 + -2.1649348980190600e-15 0 0 0 @@ -3858,13 +3858,13 @@ 0. 0. - <_>0 - 5.0037473440170288e-01 - 1.4896666526794434e+01 + <_>1 + 5.0355648994445801e-01 + 9.2722505331039429e-02 <_> 1 - 6670 - 7.5413849870097256e-04 + 392 + 7.2872834808621612e-02 1 0 0 @@ -3874,8 +3874,8 @@ 0. <_> 1 - 26 - -2.8921490337872560e+00 + 1467 + -9.8094551697467572e-02 0 0 0 @@ -3888,9 +3888,9 @@ <_> 0 - 6696 - -5.5511151231257827e-17 - 0 + 1859 + 6.6613381477509353e-16 + 1 0 0 0. @@ -3898,13 +3898,13 @@ 0. 0. - <_>0 - 5.0054270029067993e-01 - 1.2005734443664551e+01 + <_>1 + 5.0229591131210327e-01 + 1.4143149554729462e-01 <_> 1 - 6665 - -1.1638027534938869e-03 + 1571 + -1.1560090798064190e-02 0 0 0 @@ -3914,8 +3914,8 @@ 0. <_> 1 - 31 - 1.6786149859003261e+00 + 288 + 4.2036013274394679e-01 1 0 0 @@ -3928,9 +3928,9 @@ <_> 0 - 6696 - 4.6629367034256354e-15 - 1 + 1859 + -2.2204460492503136e-16 + 0 0 0 0. @@ -3938,13 +3938,13 @@ 0. 0. - <_>0 - 5.0044608116149902e-01 - 4.2022142410278320e+00 + <_>1 + 5.0365710258483887e-01 + 1.0963299870491028e-01 <_> 1 - 6568 - 3.4675087855743224e-03 + 781 + 2.1235893234003624e-02 1 0 0 @@ -3954,8 +3954,8 @@ 0. <_> 1 - 128 - -2.6321539599441751e-01 + 1078 + -3.5916730278930570e-01 0 0 0 @@ -3968,9 +3968,9 @@ <_> 0 - 6696 - 4.2188474935755767e-15 - 1 + 1859 + -2.2204460492503178e-15 + 0 0 0 0. @@ -3978,13 +3978,13 @@ 0. 0. - <_>2 - 5.0035691261291504e-01 - 1.0500000000000000e+01 + <_>1 + 5.0305408239364624e-01 + 9.1055497527122498e-02 <_> 1 - 6225 - -1.0399202570737451e-03 + 376 + -7.5233897759775223e-02 0 0 0 @@ -3994,8 +3994,8 @@ 0. <_> 1 - 471 - 8.4121798274828596e-01 + 1483 + 8.1521687774440590e-02 1 0 0 @@ -4008,9 +4008,9 @@ <_> 0 - 6696 - -3.7747582837255464e-15 - 0 + 1859 + 2.4424906541753385e-15 + 1 0 0 0. @@ -4018,13 +4018,13 @@ 0. 0. - <_>2 - 5.0044542551040649e-01 - 5.5000000000000000e+00 + <_>1 + 5.0231134891510010e-01 + 8.8118501007556915e-02 <_> 1 - 6059 - 3.0397076453332855e-03 + 322 + 7.4755757692778257e-02 1 0 0 @@ -4034,8 +4034,8 @@ 0. <_> 1 - 637 - -3.0190805541684723e-01 + 1537 + -6.2031478956482825e-02 0 0 0 diff --git a/samples/cpp/trained_classifierNM2.xml b/samples/cpp/trained_classifierNM2.xml index 4dc259f635..eae66f01ab 100644 --- a/samples/cpp/trained_classifierNM2.xml +++ b/samples/cpp/trained_classifierNM2.xml @@ -48,8 +48,8 @@ <_> 0 - 85052 - -2.0851517666418171e-01 + 3215 + -2.0078929470944956e-01 0 0 0 @@ -58,13 +58,13 @@ 0. 0. - <_>1 - 8.0945491790771484e-01 - 1.4282399415969849e-01 + <_>6 + 8.7790262699127197e-01 + 8.5000000000000000e+00 <_> 1 - 51211 - -1.1655815615009795e+00 + 2105 + -1.1353035616351272e+00 0 0 0 @@ -74,8 +74,8 @@ 0. <_> 1 - 33841 - 9.2576486302104599e-01 + 1110 + 2.0526971992043412e+00 1 0 0 @@ -88,9 +88,9 @@ <_> 0 - 85052 - -4.0434322556864549e-13 - 0 + 3215 + 2.0428103653102464e-14 + 1 0 0 0. @@ -98,13 +98,13 @@ 0. 0. - <_>0 - 5.5560266971588135e-01 - 1.1992645263671875e+00 + <_>6 + 6.9283843040466309e-01 + 4.5000000000000000e+00 <_> 1 - 53830 - -2.7774940068788956e-01 + 1558 + -1.1814132639953403e+00 0 0 0 @@ -114,8 +114,8 @@ 0. <_> 1 - 31222 - 4.3636095679254611e-01 + 1657 + 5.0475867936025332e-01 1 0 0 @@ -128,8 +128,8 @@ <_> 0 - 85052 - -5.5244697705378314e-13 + 3215 + -2.2259971643734884e-14 0 0 0 @@ -138,13 +138,13 @@ 0. 0. - <_>6 - 5.6166672706604004e-01 - 8.5000000000000000e+00 + <_>4 + 7.1280795335769653e-01 + 1.2044999748468399e-03 <_> 1 - 77849 - -1.9387850902953174e-01 + 1475 + -7.9375129344950335e-01 0 0 0 @@ -154,8 +154,8 @@ 0. <_> 1 - 7203 - 7.6512998048339842e-01 + 1740 + 7.6558743305188104e-01 1 0 0 @@ -168,8 +168,8 @@ <_> 0 - 85052 - 1.1137757383027165e-12 + 3215 + 2.4424906541753385e-15 1 0 0 @@ -179,13 +179,13 @@ 0. <_>5 - 5.3432768583297729e-01 - 1.0000740289688110e+00 + 5.9598809480667114e-01 + 1.6245440244674683e+00 <_> 1 - 9695 - 1.0093966120501190e+00 - 1 + 1385 + -5.4645841888834568e-01 + 0 0 0 0. @@ -194,9 +194,9 @@ 0. <_> 1 - 75357 - -8.9927193923099238e-02 - 0 + 1830 + 4.0662339031566280e-01 + 1 0 0 0. @@ -208,9 +208,9 @@ <_> 0 - 85052 - -5.6671334292023235e-13 - 0 + 3215 + 6.2172489379008380e-15 + 1 0 0 0. @@ -218,13 +218,13 @@ 0. 0. - <_>5 - 5.2853655815124512e-01 - 1.9998995065689087e+00 + <_>2 + 5.5169683694839478e-01 + 1.5000000000000000e+00 <_> 1 - 68496 - -1.3284462220844204e-01 + 2960 + -1.2615933276314473e-01 0 0 0 @@ -234,8 +234,8 @@ 0. <_> 1 - 16556 - 4.6253459906468258e-01 + 255 + 1.1688135468772842e+00 1 0 0 @@ -248,9 +248,9 @@ <_> 0 - 85052 - 1.5987211554599700e-13 - 1 + 3215 + -8.4376949871512607e-15 + 0 0 0 0. @@ -258,14 +258,14 @@ 0. 0. - <_>1 - 5.3614515066146851e-01 - 1.1410850286483765e-01 + <_>3 + 5.4812711477279663e-01 + 5. <_> 1 - 37005 - -4.3322351556582656e-01 - 0 + 2891 + 1.3088588195700304e-01 + 1 0 0 0. @@ -274,9 +274,9 @@ 0. <_> 1 - 48047 - 1.7906662718891103e-01 - 1 + 324 + -9.4959634248367153e-01 + 0 0 0 0. @@ -288,9 +288,9 @@ <_> 0 - 85052 - -2.5979218776229338e-14 - 0 + 3215 + 2.8865798640253987e-15 + 1 0 0 0. @@ -298,13 +298,13 @@ 0. 0. - <_>5 - 5.2565670013427734e-01 - 1.1428444385528564e+00 + <_>0 + 5.9334284067153931e-01 + 9.2769998311996460e-01 <_> 1 - 28123 - -2.9299227512780235e-01 + 1964 + -4.5236837327316332e-01 0 0 0 @@ -314,8 +314,8 @@ 0. <_> 1 - 56929 - 1.8210542749456476e-01 + 1251 + 4.7279968034956410e-01 1 0 0 @@ -328,8 +328,8 @@ <_> 0 - 85052 - -6.6169292267663710e-14 + 3215 + -1.3322676295501896e-15 0 0 0 @@ -338,13 +338,13 @@ 0. 0. - <_>2 - 5.1728218793869019e-01 - 2.5000000000000000e+00 + <_>5 + 5.6080043315887451e-01 + 2.2512035369873047e+00 <_> 1 - 84594 - -3.5132932294418412e-02 + 2464 + -2.1052010276554461e-01 0 0 0 @@ -354,8 +354,8 @@ 0. <_> 1 - 458 - 2.4171615055929991e+00 + 751 + 6.7174941695746326e-01 1 0 0 @@ -368,8 +368,8 @@ <_> 0 - 85052 - -4.4853010194858337e-14 + 3215 + -7.3274719625260868e-15 0 0 0 @@ -378,13 +378,13 @@ 0. 0. - <_>1 - 5.2121073007583618e-01 - 1.7495599389076233e-01 + <_>0 + 5.3896796703338623e-01 + 1.6267855167388916e+00 <_> 1 - 59074 - -1.6093402696177866e-01 + 3041 + -8.1739798958620380e-02 0 0 0 @@ -394,8 +394,8 @@ 0. <_> 1 - 25978 - 2.7241130230718985e-01 + 174 + 1.8924547997011532e+00 1 0 0 @@ -408,8 +408,8 @@ <_> 0 - 85052 - 1.3811174426335039e-13 + 3215 + 3.3306690738754586e-15 1 0 0 @@ -418,13 +418,13 @@ 0. 0. - <_>5 - 5.1690614223480225e-01 - 1.4999510049819946e+00 + <_>6 + 5.3723198175430298e-01 + 2.5000000000000000e+00 <_> 1 - 48787 - -1.5569102806697110e-01 + 851 + -9.3661052654285037e-01 0 0 0 @@ -434,8 +434,8 @@ 0. <_> 1 - 36265 - 2.2252947017737912e-01 + 2364 + 1.0184709367515142e-01 1 0 0 @@ -448,9 +448,9 @@ <_> 0 - 85052 - -8.1934459217343267e-14 - 0 + 3215 + 1.2656542480726624e-14 + 1 0 0 0. @@ -458,14 +458,14 @@ 0. 0. - <_>1 - 5.1266878843307495e-01 - 1.2102149426937103e-01 + <_>3 + 5.4598015546798706e-01 + 3. <_> 1 - 42059 - -2.2672787671659753e-01 - 0 + 1494 + 3.5820791601148183e-01 + 1 0 0 0. @@ -474,9 +474,9 @@ 0. <_> 1 - 42993 - 1.1415487554925473e-01 - 1 + 1721 + -2.7428866405164359e-01 + 0 0 0 0. @@ -488,8 +488,8 @@ <_> 0 - 85052 - -9.1093799170502387e-14 + 3215 + -1.3322676295501896e-15 0 0 0 @@ -499,12 +499,12 @@ 0. <_>4 - 5.1520520448684692e-01 - 1.5279999934136868e-03 + 5.5166077613830566e-01 + 2.9999999242136255e-05 <_> 1 - 68702 - -7.3421607355411075e-02 + 1467 + -3.3467424181887540e-01 0 0 0 @@ -514,8 +514,8 @@ 0. <_> 1 - 16350 - 4.4155451359037357e-01 + 1748 + 3.3182965736372233e-01 1 0 0 @@ -528,8 +528,8 @@ <_> 0 - 85052 - 1.8229862064341748e-13 + 3215 + 1.3322676295501861e-15 1 0 0 @@ -538,13 +538,13 @@ 0. 0. - <_>5 - 5.1154321432113647e-01 - 2.4999566078186035e+00 + <_>6 + 5.4394942522048950e-01 + 6.5000000000000000e+00 <_> 1 - 79214 - -4.8683110415928377e-02 + 1817 + -2.9822080188111177e-01 0 0 0 @@ -554,8 +554,8 @@ 0. <_> 1 - 5838 - 5.1598158925116355e-01 + 1398 + 3.1329368107827943e-01 1 0 0 @@ -568,9 +568,9 @@ <_> 0 - 85052 - -9.2592600253746626e-14 - 0 + 3215 + 2.6645352591003686e-15 + 1 0 0 0. @@ -579,13 +579,13 @@ 0. <_>1 - 5.1093620061874390e-01 - 1.0245949774980545e-01 + 5.3358083963394165e-01 + 1.3833449780941010e-01 <_> 1 - 26510 - -3.0550267219933458e-01 - 0 + 2635 + 8.0265603900023089e-02 + 1 0 0 0. @@ -594,9 +594,9 @@ 0. <_> 1 - 58542 - 7.3942734827146334e-02 - 1 + 580 + -1.2162305066944930e+00 + 0 0 0 0. @@ -608,8 +608,8 @@ <_> 0 - 85052 - -8.9761531540951959e-14 + 3215 + -6.4392935428259497e-15 0 0 0 @@ -618,14 +618,14 @@ 0. 0. - <_>6 - 5.0920587778091431e-01 - 5.0000000000000000e-01 + <_>4 + 5.3098827600479126e-01 + 1.2702149152755737e-01 <_> 1 - 11135 - -3.1755783174672919e-01 - 0 + 2676 + 1.3513810711631610e-01 + 1 0 0 0. @@ -634,9 +634,9 @@ 0. <_> 1 - 73917 - 5.9987198000351898e-02 - 1 + 539 + -4.9909506904561546e-01 + 0 0 0 0. @@ -648,8 +648,8 @@ <_> 0 - 85052 - 1.1635137298070287e-13 + 3215 + 3.7747582837255180e-15 1 0 0 @@ -658,13 +658,13 @@ 0. 0. - <_>5 - 5.1026338338851929e-01 - 9.6662950515747070e-01 + <_>6 + 5.3376436233520508e-01 + 9.5000000000000000e+00 <_> 1 - 2959 - 1.8170860205295931e+00 + 2193 + 1.3117433044170448e-01 1 0 0 @@ -674,8 +674,8 @@ 0. <_> 1 - 82093 - -2.1643576105994013e-02 + 1022 + -5.7326180584233111e-01 0 0 0 @@ -688,9 +688,9 @@ <_> 0 - 85052 - -5.8619775700211698e-14 - 0 + 3215 + 1.7763568394002473e-15 + 1 0 0 0. @@ -698,14 +698,14 @@ 0. 0. - <_>0 - 5.1050859689712524e-01 - 4.2910051345825195e-01 + <_>2 + 5.2698892354965210e-01 + 2.5000000000000000e+00 <_> 1 - 1142 - 6.1481242791051749e-01 - 1 + 3127 + -5.4553392906591960e-02 + 0 0 0 0. @@ -714,9 +714,9 @@ 0. <_> 1 - 83910 - -3.8405933276937039e-02 - 0 + 88 + 2.6688100460888684e+00 + 1 0 0 0. @@ -728,8 +728,8 @@ <_> 0 - 85052 - -3.9968028886507232e-14 + 3215 + -3.0531133177191900e-15 0 0 0 @@ -738,13 +738,13 @@ 0. 0. - <_>0 - 5.1034581661224365e-01 - 3.1224999427795410e+00 + <_>6 + 5.2742463350296021e-01 + 1.2500000000000000e+01 <_> 1 - 83931 - -3.4360295599506332e-02 + 2620 + -5.4904310687255702e-02 0 0 0 @@ -754,8 +754,8 @@ 0. <_> 1 - 1121 - 6.9695853321977042e-01 + 595 + 5.7564577324623896e+00 1 0 0 @@ -768,9 +768,9 @@ <_> 0 - 85052 - -2.2110091535414882e-13 - 0 + 3215 + 1.7368061883308035e-04 + 1 0 0 0. @@ -778,13 +778,13 @@ 0. 0. - <_>1 - 5.0685334205627441e-01 - 1.6315400600433350e-01 + <_>5 + 5.2537131309509277e-01 + 3.7997097969055176e+00 <_> 1 - 56302 - -1.0536507458437382e-01 + 3184 + -5.4291952000757461e-02 0 0 0 @@ -794,8 +794,8 @@ 0. <_> 1 - 28750 - 1.3131876124230615e-01 + 31 + 1.6789882514261603e+00 1 0 0 @@ -808,8 +808,8 @@ <_> 0 - 85052 - 4.2632564145604194e-14 + 3215 + 1.9984014443252778e-15 1 0 0 @@ -818,13 +818,13 @@ 0. 0. - <_>5 - 5.1097369194030762e-01 - 1.3333054780960083e+00 + <_>0 + 5.3548330068588257e-01 + 6.6345453262329102e-01 <_> 1 - 39585 - -1.3980281702427369e-01 + 777 + -9.1576813577644156e-01 0 0 0 @@ -834,8 +834,8 @@ 0. <_> 1 - 45467 - 1.5934471638769365e-01 + 2438 + 9.8351123166090529e-02 1 0 0 @@ -848,8 +848,8 @@ <_> 0 - 85052 - -1.5365486660814527e-13 + 3215 + -6.6613381477509432e-16 0 0 0 @@ -858,13 +858,13 @@ 0. 0. - <_>1 - 5.0712108612060547e-01 - 5.4749999195337296e-02 + <_>3 + 5.2158576250076294e-01 + 5. <_> 1 - 268 - 2.0102810951501930e+00 + 2891 + 8.1007865418959935e-02 1 0 0 @@ -874,8 +874,8 @@ 0. <_> 1 - 84784 - -1.4763722474947673e-02 + 324 + -5.9585687406274601e-01 0 0 0 @@ -888,9 +888,9 @@ <_> 0 - 85052 - 5.3068660577079668e-14 - 1 + 3215 + -6.6613381477509432e-16 + 0 0 0 0. @@ -898,13 +898,13 @@ 0. 0. - <_>1 - 5.0855076313018799e-01 - 1.8632251024246216e-01 + <_>0 + 5.2358013391494751e-01 + 1.0659420490264893e+00 <_> 1 - 62257 - -9.8863683143064443e-02 + 2457 + -1.3607641362335321e-01 0 0 0 @@ -914,8 +914,8 @@ 0. <_> 1 - 22795 - 1.7531854005917147e-01 + 758 + 3.6397269406151606e-01 1 0 0 @@ -928,9 +928,9 @@ <_> 0 - 85052 - -2.1010970741035503e-13 - 0 + 3215 + 3.7747582837255180e-15 + 1 0 0 0. @@ -938,14 +938,14 @@ 0. 0. - <_>6 - 5.0839239358901978e-01 - 2.1500000000000000e+01 + <_>5 + 5.2605414390563965e-01 + 1.3934500217437744e+00 <_> 1 - 84180 - 3.3709711253908758e-02 - 1 + 909 + -4.4217410871376006e-01 + 0 0 0 0. @@ -954,9 +954,9 @@ 0. <_> 1 - 872 - -5.4678827729280677e-01 - 0 + 2306 + 1.2609161734369648e-01 + 1 0 0 0. @@ -968,8 +968,8 @@ <_> 0 - 85052 - 5.1070259132756941e-15 + 3215 + 1.5543122344752168e-15 1 0 0 @@ -978,13 +978,13 @@ 0. 0. - <_>6 - 5.1185333728790283e-01 - 4.5000000000000000e+00 + <_>4 + 5.2353090047836304e-01 + 1.2044999748468399e-03 <_> 1 - 54850 - -1.3957538523591986e-01 + 1475 + -2.0545012432588597e-01 0 0 0 @@ -994,8 +994,8 @@ 0. <_> 1 - 30202 - 1.7264526939599670e-01 + 1740 + 2.3659867388791755e-01 1 0 0 @@ -1008,8 +1008,8 @@ <_> 0 - 85052 - -1.0724754417880162e-13 + 3215 + -1.8318679906315118e-15 0 0 0 @@ -1018,13 +1018,13 @@ 0. 0. - <_>4 - 5.0670981407165527e-01 - 1.5279999934136868e-03 + <_>0 + 5.2399057149887085e-01 + 4.7306199073791504e+00 <_> 1 - 68702 - -4.6140615158621334e-02 + 3204 + -4.8506775757358948e-02 0 0 0 @@ -1034,8 +1034,8 @@ 0. <_> 1 - 16350 - 2.9971095384690405e-01 + 11 + 2.6435685747751951e+00 1 0 0 @@ -1048,8 +1048,8 @@ <_> 0 - 85052 - 5.9729998724829850e-14 + 3215 + 2.2204460492503083e-15 1 0 0 @@ -1058,14 +1058,14 @@ 0. 0. - <_>3 - 5.0741368532180786e-01 - 3. + <_>6 + 5.2452313899993896e-01 + 6.5000000000000000e+00 <_> 1 - 64284 - 5.3257435738342171e-02 - 1 + 1817 + -2.0830922304142732e-01 + 0 0 0 0. @@ -1074,9 +1074,9 @@ 0. <_> 1 - 20768 - -2.8624303413816726e-01 - 0 + 1398 + 2.4354914812770342e-01 + 1 0 0 0. @@ -1088,8 +1088,8 @@ <_> 0 - 85052 - 5.3290705182004674e-14 + 3215 + 3.7747582837255180e-15 1 0 0 @@ -1099,12 +1099,12 @@ 0. <_>1 - 5.0632566213607788e-01 - 2.3696850240230560e-01 + 5.1760864257812500e-01 + 7.4752002954483032e-02 <_> 1 - 84618 - 1.5950331395399531e-02 + 270 + 7.4056582493755241e-01 1 0 0 @@ -1114,8 +1114,8 @@ 0. <_> 1 - 434 - -1.0801049499585134e+00 + 2945 + -5.6004456612259952e-02 0 0 0 @@ -1128,9 +1128,9 @@ <_> 0 - 85052 - -9.1870955287740148e-14 - 0 + 3215 + 1.5543122344752168e-15 + 1 0 0 0. @@ -1138,14 +1138,14 @@ 0. 0. - <_>5 - 5.0532805919647217e-01 - 3.7046184539794922e+00 + <_>3 + 5.1595693826675415e-01 + 5. <_> 1 - 84455 - -1.2273968085806013e-02 - 0 + 2891 + 6.8929447086892887e-02 + 1 0 0 0. @@ -1154,9 +1154,9 @@ 0. <_> 1 - 597 - 1.3258536030843857e+00 - 1 + 324 + -5.0204800200277599e-01 + 0 0 0 0. @@ -1168,8 +1168,8 @@ <_> 0 - 85052 - -2.8421709430404815e-14 + 3215 + -8.8262730457700718e-15 0 0 0 @@ -1178,14 +1178,14 @@ 0. 0. - <_>0 - 5.0496006011962891e-01 - 1.1423504352569580e+00 + <_>4 + 5.1432991027832031e-01 + 2.5954151153564453e-01 <_> 1 - 49633 - -8.4710336395360977e-02 - 0 + 2981 + 3.1556263241584975e-02 + 1 0 0 0. @@ -1194,9 +1194,9 @@ 0. <_> 1 - 35419 - 1.1792957927648873e-01 - 1 + 234 + -1.5189501708336401e+00 + 0 0 0 0. @@ -1208,9 +1208,9 @@ <_> 0 - 85052 - -3.5305092183081228e-14 - 0 + 3215 + 2.2204460492503126e-16 + 1 0 0 0. @@ -1218,14 +1218,14 @@ 0. 0. - <_>0 - 5.0832629203796387e-01 - 1.0025000572204590e+00 + <_>2 + 5.1588785648345947e-01 + 1.5000000000000000e+00 <_> 1 - 38800 - 1.3411668655420397e-01 - 1 + 2960 + -6.0429432019906144e-02 + 0 0 0 0. @@ -1234,9 +1234,9 @@ 0. <_> 1 - 46252 - -1.2556436569616300e-01 - 0 + 255 + 5.8525011139658878e-01 + 1 0 0 0. @@ -1248,8 +1248,8 @@ <_> 0 - 85052 - 1.0880185641326416e-14 + 3215 + 2.4424906541753385e-15 1 0 0 @@ -1258,13 +1258,13 @@ 0. 0. - <_>0 - 5.0588506460189819e-01 - 9.9288249015808105e-01 + <_>5 + 5.2001929283142090e-01 + 1.3934500217437744e+00 <_> 1 - 29974 - -1.5381446520138317e-01 + 909 + -4.6709016373000739e-01 0 0 0 @@ -1274,8 +1274,8 @@ 0. <_> 1 - 55078 - 7.7277560960516981e-02 + 2306 + 9.2123924914545782e-02 1 0 0 @@ -1288,9 +1288,9 @@ <_> 0 - 85052 - -5.0848214527834757e-14 - 0 + 3215 + 2.6645352591003686e-15 + 1 0 0 0. @@ -1299,12 +1299,12 @@ 0. <_>4 - 5.0448471307754517e-01 - 9.2855751514434814e-01 + 5.1656109094619751e-01 + 1.2044999748468399e-03 <_> 1 - 84350 - -1.0398941556026050e-02 + 1475 + -1.6749125053548522e-01 0 0 0 @@ -1314,8 +1314,8 @@ 0. <_> 1 - 702 - 1.3032575620501816e+00 + 1740 + 2.0231653132989663e-01 1 0 0 @@ -1328,9 +1328,9 @@ <_> 0 - 85052 - 1.1457501614130303e-13 - 1 + 3215 + -3.7747582837255464e-15 + 0 0 0 0. @@ -1338,13 +1338,13 @@ 0. 0. - <_>4 - 5.0515556335449219e-01 - 1.5001350641250610e-01 + <_>3 + 5.1900207996368408e-01 + 3. <_> 1 - 73655 - 2.2778889851791131e-02 + 1494 + 2.5948749710951657e-01 1 0 0 @@ -1354,8 +1354,8 @@ 0. <_> 1 - 11397 - -4.8814155956114441e-01 + 1721 + -1.5086548637238759e-01 0 0 0 @@ -1368,8 +1368,8 @@ <_> 0 - 85052 - -4.8017145815040324e-14 + 3215 + -1.3322676295501896e-15 0 0 0 @@ -1379,13 +1379,13 @@ 0. <_>0 - 5.0434845685958862e-01 - 1.0927449911832809e-01 + 5.1032912731170654e-01 + 1.1417410373687744e+00 <_> 1 - 38 - 2.9257485805403145e+00 - 1 + 2628 + -6.3461321700044010e-02 + 0 0 0 0. @@ -1394,9 +1394,9 @@ 0. <_> 1 - 85014 - -8.7472424605780971e-03 - 0 + 587 + 3.3830370061028520e-01 + 1 0 0 0. @@ -1408,8 +1408,8 @@ <_> 0 - 85052 - 9.9920072216263095e-15 + 3215 + 1.1102230246251554e-15 1 0 0 @@ -1419,12 +1419,12 @@ 0. <_>5 - 5.0396436452865601e-01 - 1.1111010313034058e+00 + 5.1085340976715088e-01 + 1.3021064996719360e+00 <_> 1 - 24025 - -1.1425222651510533e-01 + 734 + -3.7065768373801600e-01 0 0 0 @@ -1434,8 +1434,8 @@ 0. <_> 1 - 61027 - 6.9811502406169512e-02 + 2481 + 6.1297280870936215e-02 1 0 0 @@ -1448,8 +1448,8 @@ <_> 0 - 85052 - 3.1752378504278467e-14 + 3215 + 4.4408920985006242e-16 1 0 0 @@ -1458,13 +1458,13 @@ 0. 0. - <_>1 - 5.0685292482376099e-01 - 1.6534850001335144e-01 + <_>2 + 5.1171976327896118e-01 + 1.5000000000000000e+00 <_> 1 - 56789 - -1.0639676270038445e-01 + 2960 + -5.1679907432686661e-02 0 0 0 @@ -1474,8 +1474,8 @@ 0. <_> 1 - 28263 - 1.3003218037837008e-01 + 255 + 4.8967202182224279e-01 1 0 0 @@ -1488,9 +1488,9 @@ <_> 0 - 85052 - 1.1768364061026520e-14 - 1 + 3215 + -3.3306690738754807e-15 + 0 0 0 0. @@ -1499,13 +1499,13 @@ 0. <_>4 - 5.0667446851730347e-01 - 2.5204999838024378e-03 + 5.1276576519012451e-01 + 1.4958450198173523e-01 <_> 1 - 68803 - -4.4902369408092585e-02 - 0 + 2755 + 7.7575074151822049e-02 + 1 0 0 0. @@ -1514,9 +1514,9 @@ 0. <_> 1 - 16249 - 3.0676249251706372e-01 - 1 + 460 + -3.4258234102830631e-01 + 0 0 0 0. @@ -1528,8 +1528,8 @@ <_> 0 - 85052 - 1.0436096431476363e-14 + 3215 + 2.2204460492503126e-16 1 0 0 @@ -1538,13 +1538,13 @@ 0. 0. - <_>5 - 5.0544035434722900e-01 - 1.6999830007553101e+00 + <_>4 + 5.0944852828979492e-01 + 2.5842750072479248e-01 <_> 1 - 58001 - -6.3192712659493902e-02 + 2980 + -2.8188779664253410e-02 0 0 0 @@ -1554,8 +1554,8 @@ 0. <_> 1 - 27051 - 1.7415191131728372e-01 + 235 + 8.1175021374635614e-01 1 0 0 @@ -1568,8 +1568,8 @@ <_> 0 - 85052 - -7.1553873937096463e-14 + 3215 + -5.2735593669695212e-15 0 0 0 @@ -1578,13 +1578,13 @@ 0. 0. - <_>1 - 5.0740957260131836e-01 - 9.0433999896049500e-02 + <_>5 + 5.1038962602615356e-01 + 1.4510664939880371e+00 <_> 1 - 14655 - -3.5563455686562018e-01 + 1007 + -3.3150262977164136e-01 0 0 0 @@ -1594,8 +1594,8 @@ 0. <_> 1 - 70397 - 4.3438834127815081e-02 + 2208 + 6.5052948330937457e-02 1 0 0 @@ -1608,8 +1608,8 @@ <_> 0 - 85052 - 5.3290705182004674e-14 + 3215 + 1.3322676295501861e-15 1 0 0 @@ -1618,13 +1618,13 @@ 0. 0. - <_>0 - 5.0522023439407349e-01 - 7.6169013977050781e+00 + <_>4 + 5.1113504171371460e-01 + 2.4550000671297312e-04 <_> 1 - 84964 - -1.0982105673326964e-02 + 1471 + -1.2860595713867043e-01 0 0 0 @@ -1634,8 +1634,8 @@ 0. <_> 1 - 88 - 1.8392352279970514e+00 + 1744 + 1.7591144586528801e-01 1 0 0 @@ -1648,9 +1648,9 @@ <_> 0 - 85052 - 5.9952043329758090e-15 - 1 + 3215 + -8.8817841970012602e-16 + 0 0 0 0. @@ -1658,14 +1658,14 @@ 0. 0. - <_>2 - 5.0350898504257202e-01 - 1.5000000000000000e+00 + <_>4 + 5.1135826110839844e-01 + 1.9797500967979431e-01 <_> 1 - 83116 - -1.3544875378839269e-02 - 0 + 2857 + 4.5695890739118755e-02 + 1 0 0 0. @@ -1674,9 +1674,9 @@ 0. <_> 1 - 1936 - 5.7382380004662314e-01 - 1 + 358 + -5.4593965595422900e-01 + 0 0 0 0. @@ -1688,8 +1688,8 @@ <_> 0 - 85052 - 1.1324274851176469e-14 + 3215 + 2.8865798640253987e-15 1 0 0 @@ -1698,13 +1698,13 @@ 0. 0. - <_>1 - 5.0382590293884277e-01 - 1.9760949909687042e-01 + <_>5 + 5.0861865282058716e-01 + 4.4535398483276367e+00 <_> 1 - 66636 - -5.8693205183840469e-02 + 3204 + -1.7238960071156845e-02 0 0 0 @@ -1714,8 +1714,8 @@ 0. <_> 1 - 18416 - 1.3126738509498842e-01 + 11 + 5.7564577324623896e+00 1 0 0 @@ -1728,9 +1728,9 @@ <_> 0 - 85052 - -3.9412917374193215e-15 - 0 + 3215 + 5.4514379135116734e-05 + 1 0 0 0. @@ -1739,13 +1739,13 @@ 0. <_>5 - 5.0635123252868652e-01 - 1.1999764442443848e+00 + 5.1613724231719971e-01 + 1.3783290863037109e+01 <_> 1 - 32171 - -1.2031088209549005e-01 - 0 + 3214 + 5.4514379101591658e-05 + 1 0 0 0. @@ -1754,8 +1754,8 @@ 0. <_> 1 - 52881 - 1.0648972918122487e-01 + 1 + 5.7564577324623896e+00 1 0 0 @@ -1768,8 +1768,8 @@ <_> 0 - 85052 - -3.8247183198338107e-14 + 3215 + -4.2188474935756130e-15 0 0 0 @@ -1778,13 +1778,13 @@ 0. 0. - <_>1 - 5.0506365299224854e-01 - 1.5712898969650269e-01 + <_>5 + 5.8550304174423218e-01 + 1.3783290863037109e+01 <_> 1 - 54755 - -1.0068970021652925e-01 + 3214 + -4.2188474935756130e-15 0 0 0 @@ -1794,8 +1794,8 @@ 0. <_> 1 - 30297 - 1.0126393532049692e-01 + 1 + 5.7564577324623896e+00 1 0 0 @@ -1808,9 +1808,9 @@ <_> 0 - 85052 - 4.0412118096354064e-14 - 1 + 3215 + 0. + 0 0 0 0. @@ -1818,14 +1818,14 @@ 0. 0. - <_>6 - 5.0421619415283203e-01 - 1.5500000000000000e+01 + <_>5 + 6.1834394931793213e-01 + 1.3783290863037109e+01 <_> 1 - 83015 - 3.4846015981025179e-02 - 1 + 3214 + 0. + 0 0 0 0. @@ -1834,9 +1834,9 @@ 0. <_> 1 - 2037 - -2.4699253563606235e-01 - 0 + 1 + 5.7564577324623896e+00 + 1 0 0 0. @@ -1848,9 +1848,9 @@ <_> 0 - 85052 - -5.0681681074140965e-14 - 0 + 3215 + 0. + 1 0 0 0. @@ -1859,13 +1859,13 @@ 0. <_>5 - 5.0354343652725220e-01 - 1.7777650356292725e+00 + 6.2149631977081299e-01 + 1.3783290863037109e+01 <_> 1 - 61156 - -4.6966726001940580e-02 - 0 + 3214 + 0. + 1 0 0 0. @@ -1874,8 +1874,8 @@ 0. <_> 1 - 23896 - 1.5216614445371685e-01 + 1 + 5.7564577324623896e+00 1 0 0 @@ -1888,8 +1888,8 @@ <_> 0 - 85052 - -4.2188474935756130e-15 + 3215 + -2.2204460492503136e-16 0 0 0 @@ -1898,13 +1898,13 @@ 0. 0. - <_>4 - 5.0353568792343140e-01 - 6.1677896976470947e-01 + <_>5 + 6.2519973516464233e-01 + 1.3783290863037109e+01 <_> 1 - 82886 - -1.0550569860998281e-02 + 3214 + -2.2204460492503136e-16 0 0 0 @@ -1914,8 +1914,8 @@ 0. <_> 1 - 2166 - 8.1121927736733479e-01 + 1 + 5.7564577324623896e+00 1 0 0 @@ -1928,9 +1928,9 @@ <_> 0 - 85052 - -1.4155343563970946e-14 - 0 + 3215 + 2.2204460492503126e-16 + 1 0 0 0. @@ -1938,14 +1938,14 @@ 0. 0. - <_>1 - 5.0356847047805786e-01 - 7.9045504331588745e-02 + <_>5 + 6.3510566949844360e-01 + 1.3783290863037109e+01 <_> 1 - 6487 - -3.5699349596991936e-01 - 0 + 3214 + 2.2204460492503126e-16 + 1 0 0 0. @@ -1954,8 +1954,8 @@ 0. <_> 1 - 78565 - 2.0836955059488720e-02 + 1 + 5.7564577324623896e+00 1 0 0 @@ -1968,8 +1968,8 @@ <_> 0 - 85052 - 5.9729998724829850e-14 + 3215 + 0. 1 0 0 @@ -1978,13 +1978,13 @@ 0. 0. - <_>0 - 5.0237894058227539e-01 - 1.0025000572204590e+00 + <_>5 + 6.3096535205841064e-01 + 1.3783290863037109e+01 <_> 1 - 38800 - 7.2461344985504356e-02 + 3214 + 0. 1 0 0 @@ -1994,9 +1994,9 @@ 0. <_> 1 - 46252 - -6.5870382159515656e-02 - 0 + 1 + 5.7564577324623896e+00 + 1 0 0 0. @@ -2008,9 +2008,9 @@ <_> 0 - 85052 - 1.1990408665951547e-14 - 1 + 3215 + 0. + 0 0 0 0. @@ -2018,13 +2018,13 @@ 0. 0. - <_>0 - 5.0478190183639526e-01 - 1.1423504352569580e+00 + <_>5 + 6.0966378450393677e-01 + 1.3783290863037109e+01 <_> 1 - 49633 - -8.5161166573258451e-02 + 3214 + 0. 0 0 0 @@ -2034,8 +2034,8 @@ 0. <_> 1 - 35419 - 1.1305297421197989e-01 + 1 + 5.7564577324623896e+00 1 0 0 @@ -2048,9 +2048,9 @@ <_> 0 - 85052 - 1.4876988529976877e-14 - 1 + 3215 + 0. + 0 0 0 0. @@ -2058,14 +2058,14 @@ 0. 0. - <_>0 - 5.0333338975906372e-01 - 1.0025000572204590e+00 + <_>5 + 6.3168644905090332e-01 + 1.3783290863037109e+01 <_> 1 - 38800 - 8.5161166573246114e-02 - 1 + 3214 + 0. + 0 0 0 0. @@ -2074,9 +2074,9 @@ 0. <_> 1 - 46252 - -7.8635547273571457e-02 - 0 + 1 + 5.7564577324623896e+00 + 1 0 0 0. @@ -2088,8 +2088,8 @@ <_> 0 - 85052 - 2.5979218776227988e-14 + 3215 + 0. 1 0 0 @@ -2098,14 +2098,14 @@ 0. 0. - <_>0 - 5.0263774394989014e-01 - 1.1107280254364014e+00 + <_>5 + 6.3053596019744873e-01 + 1.3783290863037109e+01 <_> 1 - 47606 - -6.6027160206561755e-02 - 0 + 3214 + 0. + 1 0 0 0. @@ -2114,8 +2114,8 @@ 0. <_> 1 - 37446 - 8.0186860022252365e-02 + 1 + 5.7564577324623896e+00 1 0 0 @@ -2128,8 +2128,8 @@ <_> 0 - 85052 - -3.7692071686025484e-14 + 3215 + 0. 0 0 0 @@ -2139,12 +2139,12 @@ 0. <_>5 - 5.0207757949829102e-01 - 2.3332970142364502e+00 + 6.1062115430831909e-01 + 1.3783290863037109e+01 <_> 1 - 77151 - -2.0113928185465708e-02 + 3214 + 0. 0 0 0 @@ -2154,8 +2154,8 @@ 0. <_> 1 - 7901 - 2.0962879229306902e-01 + 1 + 5.7564577324623896e+00 1 0 0 @@ -2168,9 +2168,9 @@ <_> 0 - 85052 - 4.7295500849029435e-14 - 1 + 3215 + 0. + 0 0 0 0. @@ -2178,13 +2178,13 @@ 0. 0. - <_>1 - 5.0277924537658691e-01 - 1.8632251024246216e-01 + <_>5 + 6.2805336713790894e-01 + 1.3783290863037109e+01 <_> 1 - 62257 - -5.6181028479834562e-02 + 3214 + 0. 0 0 0 @@ -2194,8 +2194,8 @@ 0. <_> 1 - 22795 - 9.9369395636073957e-02 + 1 + 5.7564577324623896e+00 1 0 0 @@ -2208,8 +2208,8 @@ <_> 0 - 85052 - 5.3068660577079668e-14 + 3215 + 0. 1 0 0 @@ -2219,13 +2219,13 @@ 0. <_>5 - 5.0377154350280762e-01 - 1.0908994674682617e+00 + 6.3325423002243042e-01 + 1.3783290863037109e+01 <_> 1 - 21657 - -1.2235976924685764e-01 - 0 + 3214 + 0. + 1 0 0 0. @@ -2234,8 +2234,8 @@ 0. <_> 1 - 63395 - 6.2033199693086141e-02 + 1 + 5.7564577324623896e+00 1 0 0 @@ -2248,8 +2248,8 @@ <_> 0 - 85052 - -4.2243986086988992e-14 + 3215 + 0. 0 0 0 @@ -2258,13 +2258,13 @@ 0. 0. - <_>4 - 5.0277858972549438e-01 - 1.6349999932572246e-03 + <_>5 + 6.0798364877700806e-01 + 1.3783290863037109e+01 <_> 1 - 68726 - -2.9097883587926674e-02 + 3214 + 0. 0 0 0 @@ -2274,8 +2274,8 @@ 0. <_> 1 - 16326 - 1.9341358661672844e-01 + 1 + 5.7564577324623896e+00 1 0 0 @@ -2288,9 +2288,9 @@ <_> 0 - 85052 - 6.9055872131679966e-14 - 1 + 3215 + 0. + 0 0 0 0. @@ -2298,13 +2298,13 @@ 0. 0. - <_>1 - 5.0421267747879028e-01 - 1.2819899618625641e-01 + <_>5 + 6.2765526771545410e-01 + 1.3783290863037109e+01 <_> 1 - 46067 - -1.2594108243625032e-01 + 3214 + 0. 0 0 0 @@ -2314,8 +2314,8 @@ 0. <_> 1 - 38985 - 6.7353720972212330e-02 + 1 + 5.7564577324623896e+00 1 0 0 @@ -2328,9 +2328,9 @@ <_> 0 - 85052 - -1.9317880628478096e-14 - 0 + 3215 + 0. + 1 0 0 0. @@ -2338,13 +2338,13 @@ 0. 0. - <_>1 - 5.0289511680603027e-01 - 1.4286199212074280e-01 + <_>5 + 6.3239699602127075e-01 + 1.3783290863037109e+01 <_> 1 - 51280 - 8.6671779352972975e-02 + 3214 + 0. 1 0 0 @@ -2354,9 +2354,9 @@ 0. <_> 1 - 33772 - -6.7074073857332259e-02 - 0 + 1 + 5.7564577324623896e+00 + 1 0 0 0. @@ -2368,8 +2368,8 @@ <_> 0 - 85052 - -2.3592239273285132e-14 + 3215 + 0. 0 0 0 @@ -2378,13 +2378,13 @@ 0. 0. - <_>1 - 5.0369596481323242e-01 - 1.7319199442863464e-01 + <_>5 + 6.0819625854492188e-01 + 1.3783290863037109e+01 <_> 1 - 58763 - -7.3006421478824995e-02 + 3214 + 0. 0 0 0 @@ -2394,8 +2394,8 @@ 0. <_> 1 - 26289 - 1.0177967483556853e-01 + 1 + 5.7564577324623896e+00 1 0 0 @@ -2408,8 +2408,8 @@ <_> 0 - 85052 - -1.3100631690577019e-14 + 3215 + 0. 0 0 0 @@ -2419,12 +2419,12 @@ 0. <_>5 - 5.0306421518325806e-01 - 1.2499785423278809e+00 + 6.2792611122131348e-01 + 1.3783290863037109e+01 <_> 1 - 35374 - -7.9979696078564338e-02 + 3214 + 0. 0 0 0 @@ -2434,8 +2434,8 @@ 0. <_> 1 - 49678 - 7.6940071933976520e-02 + 1 + 5.7564577324623896e+00 1 0 0 @@ -2448,9 +2448,9 @@ <_> 0 - 85052 - -7.9936057773011918e-15 - 0 + 3215 + 0. + 1 0 0 0. @@ -2459,12 +2459,12 @@ 0. <_>5 - 5.0323289632797241e-01 - 1.0000740289688110e+00 + 6.3205927610397339e-01 + 1.3783290863037109e+01 <_> 1 - 9695 - 2.5098996930572409e-01 + 3214 + 0. 1 0 0 @@ -2474,9 +2474,9 @@ 0. <_> 1 - 75357 - -2.6306141460250100e-02 - 0 + 1 + 5.7564577324623896e+00 + 1 0 0 0. @@ -2488,8 +2488,8 @@ <_> 0 - 85052 - -3.9412917374193215e-15 + 3215 + 0. 0 0 0 @@ -2498,14 +2498,14 @@ 0. 0. - <_>1 - 5.0252068042755127e-01 - 2.2588250041007996e-01 + <_>5 + 6.0529828071594238e-01 + 1.3783290863037109e+01 <_> 1 - 82565 - 1.5733416991173494e-02 - 1 + 3214 + 0. + 0 0 0 0. @@ -2514,9 +2514,9 @@ 0. <_> 1 - 2487 - -3.3215282405704583e-01 - 0 + 1 + 5.7564577324623896e+00 + 1 0 0 0. @@ -2528,8 +2528,8 @@ <_> 0 - 85052 - -1.1990408665951834e-14 + 3215 + 0. 0 0 0 @@ -2538,14 +2538,14 @@ 0. 0. - <_>0 - 5.0204354524612427e-01 - 2.1103200316429138e-01 + <_>5 + 6.2831163406372070e-01 + 1.3783290863037109e+01 <_> 1 - 160 - 6.4126003896868689e-01 - 1 + 3214 + 0. + 0 0 0 0. @@ -2554,9 +2554,9 @@ 0. <_> 1 - 84892 - -7.2243147271573143e-03 - 0 + 1 + 5.7564577324623896e+00 + 1 0 0 0. @@ -2568,8 +2568,8 @@ <_> 0 - 85052 - 4.0190073491429051e-14 + 3215 + 0. 1 0 0 @@ -2578,14 +2578,14 @@ 0. 0. - <_>1 - 5.0215661525726318e-01 - 1.9760949909687042e-01 + <_>5 + 6.3197416067123413e-01 + 1.3783290863037109e+01 <_> 1 - 66636 - -4.2589838763189808e-02 - 0 + 3214 + 0. + 1 0 0 0. @@ -2594,8 +2594,8 @@ 0. <_> 1 - 18416 - 1.0168498794066831e-01 + 1 + 5.7564577324623896e+00 1 0 0 @@ -2608,8 +2608,8 @@ <_> 0 - 85052 - -6.2172489379009153e-15 + 3215 + 0. 0 0 0 @@ -2618,13 +2618,13 @@ 0. 0. - <_>6 - 5.0249111652374268e-01 - 5.0000000000000000e-01 + <_>5 + 6.0644149780273438e-01 + 1.3783290863037109e+01 <_> 1 - 11135 - -1.6441321811536030e-01 + 3214 + 0. 0 0 0 @@ -2634,8 +2634,8 @@ 0. <_> 1 - 73917 - 3.0585312630211685e-02 + 1 + 5.7564577324623896e+00 1 0 0 @@ -2648,8 +2648,8 @@ <_> 0 - 85052 - -6.6058269965197248e-15 + 3215 + 0. 0 0 0 @@ -2658,13 +2658,13 @@ 0. 0. - <_>4 - 5.0215303897857666e-01 - 1.0776715278625488e+00 + <_>5 + 6.2831127643585205e-01 + 1.3783290863037109e+01 <_> 1 - 84672 - -5.6388275069845758e-03 + 3214 + 0. 0 0 0 @@ -2674,8 +2674,8 @@ 0. <_> 1 - 380 - 1.0049291635506168e+00 + 1 + 5.7564577324623896e+00 1 0 0 @@ -2688,9 +2688,9 @@ <_> 0 - 85052 - -8.2156503822262262e-15 - 0 + 3215 + 0. + 1 0 0 0. @@ -2698,14 +2698,14 @@ 0. 0. - <_>2 - 5.0214546918869019e-01 - 4.5000000000000000e+00 + <_>5 + 6.2990629673004150e-01 + 1.3783290863037109e+01 <_> 1 - 84762 - -4.7074724126887832e-03 - 0 + 3214 + 0. + 1 0 0 0. @@ -2714,8 +2714,8 @@ 0. <_> 1 - 290 - 1.5364953776259493e+00 + 1 + 5.7564577324623896e+00 1 0 0 @@ -2728,9 +2728,9 @@ <_> 0 - 85052 - 4.3964831775154268e-14 - 1 + 3215 + -2.2204460492503136e-16 + 0 0 0 0. @@ -2738,14 +2738,14 @@ 0. 0. - <_>0 - 5.0186127424240112e-01 - 8.0047404766082764e-01 + <_>5 + 6.1229735612869263e-01 + 1.3783290863037109e+01 <_> 1 - 13817 - 1.1296368310029067e-01 - 1 + 3214 + -2.2204460492503136e-16 + 0 0 0 0. @@ -2754,9 +2754,9 @@ 0. <_> 1 - 71235 - -3.3105517731571561e-02 - 0 + 1 + 5.7564577324623896e+00 + 1 0 0 0. @@ -2768,9 +2768,9 @@ <_> 0 - 85052 - -4.0911718457438691e-14 - 0 + 3215 + 2.2204460492503126e-16 + 1 0 0 0. @@ -2778,14 +2778,14 @@ 0. 0. - <_>0 - 5.0217723846435547e-01 - 9.9569547176361084e-01 + <_>5 + 6.2957435846328735e-01 + 1.3783290863037109e+01 <_> 1 - 30092 - -9.1953614829004077e-02 - 0 + 3214 + 2.2204460492503126e-16 + 1 0 0 0. @@ -2794,8 +2794,8 @@ 0. <_> 1 - 54960 - 4.7523977482353826e-02 + 1 + 5.7564577324623896e+00 1 0 0 @@ -2808,9 +2808,9 @@ <_> 0 - 85052 - -1.4266365866433467e-14 - 0 + 3215 + 0. + 1 0 0 0. @@ -2818,13 +2818,13 @@ 0. 0. - <_>0 - 5.0252795219421387e-01 - 1.0025000572204590e+00 + <_>5 + 6.2827998399734497e-01 + 1.3783290863037109e+01 <_> 1 - 38800 - 7.3948472735219248e-02 + 3214 + 0. 1 0 0 @@ -2834,9 +2834,9 @@ 0. <_> 1 - 46252 - -6.8603406682960111e-02 - 0 + 1 + 5.7564577324623896e+00 + 1 0 0 0. @@ -2848,8 +2848,8 @@ <_> 0 - 85052 - -1.6209256159527547e-14 + 3215 + -2.2204460492503136e-16 0 0 0 @@ -2858,13 +2858,13 @@ 0. 0. - <_>0 - 5.0187754631042480e-01 - 1.6649659872055054e+00 + <_>5 + 6.1507642269134521e-01 + 1.3783290863037109e+01 <_> 1 - 76105 - -2.7163854236781887e-02 + 3214 + -2.2204460492503136e-16 0 0 0 @@ -2874,8 +2874,8 @@ 0. <_> 1 - 8947 - 1.3916396934022576e-01 + 1 + 5.7564577324623896e+00 1 0 0 @@ -2888,8 +2888,8 @@ <_> 0 - 85052 - 3.9968028886504039e-14 + 3215 + 4.4408920985006242e-16 1 0 0 @@ -2899,12 +2899,12 @@ 0. <_>5 - 5.0173968076705933e-01 - 9.3725448846817017e-01 + 6.3906562328338623e-01 + 1.3783290863037109e+01 <_> 1 - 2236 - 5.7564577324623896e+00 + 3214 + 4.4408920985006242e-16 1 0 0 @@ -2914,9 +2914,9 @@ 0. <_> 1 - 82816 - -3.4794146453991938e-03 - 0 + 1 + 5.7564577324623896e+00 + 1 0 0 0. @@ -2928,9 +2928,9 @@ <_> 0 - 85052 - 1.1002831319136790e-05 - 1 + 3215 + -4.4408920985006281e-16 + 0 0 0 0. @@ -2939,12 +2939,12 @@ 0. <_>5 - 5.0150018930435181e-01 - 4.4167485237121582e+00 + 6.2384939193725586e-01 + 1.3783290863037109e+01 <_> 1 - 84808 - -3.0631182442574004e-03 + 3214 + -4.4408920985006281e-16 0 0 0 @@ -2954,8 +2954,8 @@ 0. <_> 1 - 244 - 2.2056778285539491e+00 + 1 + 5.7564577324623896e+00 1 0 0 @@ -2968,8 +2968,8 @@ <_> 0 - 85052 - 6.9944050551379965e-14 + 3215 + 2.2204460492503126e-16 1 0 0 @@ -2978,14 +2978,14 @@ 0. 0. - <_>1 - 5.0130033493041992e-01 - 2.4999150633811951e-01 + <_>5 + 6.3710451126098633e-01 + 1.3783290863037109e+01 <_> 1 - 84939 - -3.4716427389281618e-03 - 0 + 3214 + 2.2204460492503126e-16 + 1 0 0 0. @@ -2994,8 +2994,8 @@ 0. <_> 1 - 113 - 9.7093231837124805e-01 + 1 + 5.7564577324623896e+00 1 0 0 @@ -3008,8 +3008,8 @@ <_> 0 - 85052 - -5.8841820305136755e-14 + 3215 + 0. 0 0 0 @@ -3018,13 +3018,13 @@ 0. 0. - <_>6 - 5.0120884180068970e-01 - 4.5000000000000000e+00 + <_>5 + 6.3055968284606934e-01 + 1.3783290863037109e+01 <_> 1 - 54850 - -4.3917603750727487e-02 + 3214 + 0. 0 0 0 @@ -3034,8 +3034,8 @@ 0. <_> 1 - 30202 - 5.5141521118265716e-02 + 1 + 5.7564577324623896e+00 1 0 0 @@ -3048,8 +3048,8 @@ <_> 0 - 85052 - 5.7953641885429814e-14 + 3215 + 2.2204460492503126e-16 1 0 0 @@ -3058,14 +3058,14 @@ 0. 0. - <_>1 - 5.0135135650634766e-01 - 7.7053502202033997e-02 + <_>5 + 6.2932032346725464e-01 + 1.3783290863037109e+01 <_> 1 - 5412 - -2.5104707620991440e-01 - 0 + 3214 + 2.2204460492503126e-16 + 1 0 0 0. @@ -3074,8 +3074,8 @@ 0. <_> 1 - 79640 - 1.0991190965793670e-02 + 1 + 5.7564577324623896e+00 1 0 0 @@ -3088,8 +3088,8 @@ <_> 0 - 85052 - -2.6201263381154382e-14 + 3215 + -2.2204460492503136e-16 0 0 0 @@ -3098,13 +3098,13 @@ 0. 0. - <_>4 - 5.0119042396545410e-01 - 2.4375000502914190e-03 + <_>5 + 6.2085735797882080e-01 + 1.3783290863037109e+01 <_> 1 - 68799 - -1.8447462139746709e-02 + 3214 + -2.2204460492503136e-16 0 0 0 @@ -3114,8 +3114,8 @@ 0. <_> 1 - 16253 - 1.2979697405626092e-01 + 1 + 5.7564577324623896e+00 1 0 0 @@ -3128,9 +3128,9 @@ <_> 0 - 85052 - -2.7311486405779596e-14 - 0 + 3215 + 2.2204460492503126e-16 + 1 0 0 0. @@ -3138,13 +3138,13 @@ 0. 0. - <_>2 - 5.0275564193725586e-01 - 5.0000000000000000e-01 + <_>5 + 6.2932032346725464e-01 + 1.3783290863037109e+01 <_> 1 - 68789 - 2.5887555264941547e-02 + 3214 + 2.2204460492503126e-16 1 0 0 @@ -3154,9 +3154,9 @@ 0. <_> 1 - 16263 - -2.1624936968950229e-01 - 0 + 1 + 5.7564577324623896e+00 + 1 0 0 0. @@ -3168,9 +3168,9 @@ <_> 0 - 85052 - 8.2156503822260906e-15 - 1 + 3215 + -2.2204460492503136e-16 + 0 0 0 0. @@ -3178,13 +3178,13 @@ 0. 0. - <_>4 - 5.0209683179855347e-01 - 2.3050000891089439e-03 + <_>5 + 6.2085735797882080e-01 + 1.3783290863037109e+01 <_> 1 - 68789 - -2.4185695127928449e-02 + 3214 + -2.2204460492503136e-16 0 0 0 @@ -3194,8 +3194,8 @@ 0. <_> 1 - 16263 - 1.7520109539705506e-01 + 1 + 5.7564577324623896e+00 1 0 0 @@ -3208,9 +3208,9 @@ <_> 0 - 85052 - -1.6375789613221327e-14 - 0 + 3215 + 2.2204460492503126e-16 + 1 0 0 0. @@ -3218,13 +3218,13 @@ 0. 0. - <_>2 - 5.0160211324691772e-01 - 5.0000000000000000e-01 + <_>5 + 6.2932032346725464e-01 + 1.3783290863037109e+01 <_> 1 - 68789 - 1.9668790239766646e-02 + 3214 + 2.2204460492503126e-16 1 0 0 @@ -3234,9 +3234,9 @@ 0. <_> 1 - 16263 - -1.6439227878979559e-01 - 0 + 1 + 5.7564577324623896e+00 + 1 0 0 0. @@ -3248,9 +3248,9 @@ <_> 0 - 85052 - 3.3306690738753585e-14 - 1 + 3215 + -2.2204460492503136e-16 + 0 0 0 0. @@ -3258,13 +3258,13 @@ 0. 0. - <_>4 - 5.0134861469268799e-01 - 1.3124999823048711e-03 + <_>5 + 6.2085735797882080e-01 + 1.3783290863037109e+01 <_> 1 - 68658 - -1.9484094067575643e-02 + 3214 + -2.2204460492503136e-16 0 0 0 @@ -3274,8 +3274,8 @@ 0. <_> 1 - 16394 - 1.3934403248888891e-01 + 1 + 5.7564577324623896e+00 1 0 0 @@ -3288,9 +3288,9 @@ <_> 0 - 85052 - -7.1054273576010523e-15 - 0 + 3215 + 2.2204460492503126e-16 + 1 0 0 0. @@ -3298,14 +3298,14 @@ 0. 0. - <_>0 - 5.0120306015014648e-01 - 9.8865385055541992e+00 + <_>5 + 6.2932032346725464e-01 + 1.3783290863037109e+01 <_> 1 - 84993 - -2.6104574450754830e-03 - 0 + 3214 + 2.2204460492503126e-16 + 1 0 0 0. @@ -3314,8 +3314,8 @@ 0. <_> 1 - 59 - 1.6004161066548563e+00 + 1 + 5.7564577324623896e+00 1 0 0 @@ -3328,8 +3328,8 @@ <_> 0 - 85052 - -2.7589042161935900e-14 + 3215 + -2.2204460492503136e-16 0 0 0 @@ -3338,14 +3338,14 @@ 0. 0. - <_>2 - 5.0108444690704346e-01 - 5.0000000000000000e-01 + <_>5 + 6.2085735797882080e-01 + 1.3783290863037109e+01 <_> 1 - 68789 - 1.6151863528992876e-02 - 1 + 3214 + -2.2204460492503136e-16 + 0 0 0 0. @@ -3354,9 +3354,9 @@ 0. <_> 1 - 16263 - -1.3510965487524393e-01 - 0 + 1 + 5.7564577324623896e+00 + 1 0 0 0. @@ -3368,8 +3368,8 @@ <_> 0 - 85052 - 3.1086244689504288e-15 + 3215 + 2.2204460492503126e-16 1 0 0 @@ -3378,14 +3378,14 @@ 0. 0. - <_>2 - 5.0131279230117798e-01 - 1.5000000000000000e+00 + <_>5 + 6.2932032346725464e-01 + 1.3783290863037109e+01 <_> 1 - 83116 - -8.0778572565855487e-03 - 0 + 3214 + 2.2204460492503126e-16 + 1 0 0 0. @@ -3394,8 +3394,8 @@ 0. <_> 1 - 1936 - 3.3727111742802862e-01 + 1 + 5.7564577324623896e+00 1 0 0 @@ -3408,9 +3408,9 @@ <_> 0 - 85052 - 1.8873791418627305e-14 - 1 + 3215 + -2.2204460492503136e-16 + 0 0 0 0. @@ -3418,14 +3418,14 @@ 0. 0. - <_>2 - 5.0103312730789185e-01 - 2.5000000000000000e+00 + <_>5 + 6.2085735797882080e-01 + 1.3783290863037109e+01 <_> 1 - 84594 - 3.8029937513384339e-03 - 1 + 3214 + -2.2204460492503136e-16 + 0 0 0 0. @@ -3434,9 +3434,9 @@ 0. <_> 1 - 458 - -6.0887851298498918e-01 - 0 + 1 + 5.7564577324623896e+00 + 1 0 0 0. @@ -3448,9 +3448,9 @@ <_> 0 - 85052 - -2.3758772726978915e-14 - 0 + 3215 + 2.2204460492503126e-16 + 1 0 0 0. @@ -3459,13 +3459,13 @@ 0. <_>5 - 5.0099849700927734e-01 - 9.7220098972320557e-01 + 6.2932032346725464e-01 + 1.3783290863037109e+01 <_> 1 - 3077 - -5.4351424484613675e-01 - 0 + 3214 + 2.2204460492503126e-16 + 1 0 0 0. @@ -3474,8 +3474,8 @@ 0. <_> 1 - 81975 - 4.0289990820170799e-03 + 1 + 5.7564577324623896e+00 1 0 0 @@ -3488,9 +3488,9 @@ <_> 0 - 85052 - 5.1070259132754594e-14 - 1 + 3215 + -2.2204460492503136e-16 + 0 0 0 0. @@ -3499,13 +3499,13 @@ 0. <_>5 - 5.0115483999252319e-01 - 1.0344899892807007e+00 + 6.2085735797882080e-01 + 1.3783290863037109e+01 <_> 1 - 13889 - 1.0892680124765002e-01 - 1 + 3214 + -2.2204460492503136e-16 + 0 0 0 0. @@ -3514,9 +3514,9 @@ 0. <_> 1 - 71163 - -2.1291274675960266e-02 - 0 + 1 + 5.7564577324623896e+00 + 1 0 0 0. @@ -3528,9 +3528,9 @@ <_> 0 - 85052 - -1.3322676295501896e-15 - 0 + 3215 + 2.2204460492503126e-16 + 1 0 0 0. @@ -3539,13 +3539,13 @@ 0. <_>5 - 5.0145024061203003e-01 - 1.1111010313034058e+00 + 6.2932032346725464e-01 + 1.3783290863037109e+01 <_> 1 - 24025 - -6.8346686898487788e-02 - 0 + 3214 + 2.2204460492503126e-16 + 1 0 0 0. @@ -3554,8 +3554,8 @@ 0. <_> 1 - 61027 - 4.2528805195165366e-02 + 1 + 5.7564577324623896e+00 1 0 0 @@ -3568,8 +3568,8 @@ <_> 0 - 85052 - -2.8421709430404815e-14 + 3215 + -2.2204460492503136e-16 0 0 0 @@ -3578,13 +3578,13 @@ 0. 0. - <_>1 - 5.0177717208862305e-01 - 1.6315400600433350e-01 + <_>5 + 6.2085735797882080e-01 + 1.3783290863037109e+01 <_> 1 - 56302 - -5.6245799309189812e-02 + 3214 + -2.2204460492503136e-16 0 0 0 @@ -3594,8 +3594,8 @@ 0. <_> 1 - 28750 - 6.3343675591851709e-02 + 1 + 5.7564577324623896e+00 1 0 0 @@ -3608,9 +3608,9 @@ <_> 0 - 85052 - -1.2434497875801908e-14 - 0 + 3215 + 2.2204460492503126e-16 + 1 0 0 0. @@ -3618,13 +3618,13 @@ 0. 0. - <_>1 - 5.0208932161331177e-01 - 1.4286199212074280e-01 + <_>5 + 6.2932032346725464e-01 + 1.3783290863037109e+01 <_> 1 - 51280 - 7.5358139474863167e-02 + 3214 + 2.2204460492503126e-16 1 0 0 @@ -3634,9 +3634,9 @@ 0. <_> 1 - 33772 - -5.5612512614143753e-02 - 0 + 1 + 5.7564577324623896e+00 + 1 0 0 0. @@ -3648,9 +3648,9 @@ <_> 0 - 85052 - 9.1038288019262000e-15 - 1 + 3215 + -2.2204460492503136e-16 + 0 0 0 0. @@ -3658,13 +3658,13 @@ 0. 0. - <_>1 - 5.0196045637130737e-01 - 1.2856450676918030e-01 + <_>5 + 6.2085735797882080e-01 + 1.3783290863037109e+01 <_> 1 - 46248 - -8.7022283814818316e-02 + 3214 + -2.2204460492503136e-16 0 0 0 @@ -3674,8 +3674,8 @@ 0. <_> 1 - 38804 - 4.5200684874115597e-02 + 1 + 5.7564577324623896e+00 1 0 0 @@ -3688,9 +3688,9 @@ <_> 0 - 85052 - -1.6042722705833771e-14 - 0 + 3215 + 2.2204460492503126e-16 + 1 0 0 0. @@ -3698,13 +3698,13 @@ 0. 0. - <_>1 - 5.0139349699020386e-01 - 1.4261949062347412e-01 + <_>5 + 6.2932032346725464e-01 + 1.3783290863037109e+01 <_> 1 - 51186 - 6.1859795823686392e-02 + 3214 + 2.2204460492503126e-16 1 0 0 @@ -3714,9 +3714,9 @@ 0. <_> 1 - 33866 - -4.5142273813481217e-02 - 0 + 1 + 5.7564577324623896e+00 + 1 0 0 0. @@ -3728,9 +3728,9 @@ <_> 0 - 85052 - 1.9761969838327395e-14 - 1 + 3215 + -2.2204460492503136e-16 + 0 0 0 0. @@ -3738,13 +3738,13 @@ 0. 0. - <_>1 - 5.0168019533157349e-01 - 1.5712898969650269e-01 + <_>5 + 6.2085735797882080e-01 + 1.3783290863037109e+01 <_> 1 - 54755 - -5.8367092253270893e-02 + 3214 + -2.2204460492503136e-16 0 0 0 @@ -3754,8 +3754,8 @@ 0. <_> 1 - 30297 - 5.7703294804839218e-02 + 1 + 5.7564577324623896e+00 1 0 0 @@ -3768,8 +3768,8 @@ <_> 0 - 85052 - 2.6201263381153006e-14 + 3215 + 2.2204460492503126e-16 1 0 0 @@ -3779,13 +3779,13 @@ 0. <_>5 - 5.0144690275192261e-01 - 1.3999834060668945e+00 + 6.2932032346725464e-01 + 1.3783290863037109e+01 <_> 1 - 43654 - -4.5656675409124443e-02 - 0 + 3214 + 2.2204460492503126e-16 + 1 0 0 0. @@ -3794,8 +3794,8 @@ 0. <_> 1 - 41398 - 6.3510157848739535e-02 + 1 + 5.7564577324623896e+00 1 0 0 @@ -3808,8 +3808,8 @@ <_> 0 - 85052 - -4.1244785364826269e-14 + 3215 + -2.2204460492503136e-16 0 0 0 @@ -3818,13 +3818,13 @@ 0. 0. - <_>4 - 5.0109869241714478e-01 - 1.3124999823048711e-03 + <_>5 + 6.2085735797882080e-01 + 1.3783290863037109e+01 <_> 1 - 68658 - -1.7085179862837221e-02 + 3214 + -2.2204460492503136e-16 0 0 0 @@ -3834,8 +3834,8 @@ 0. <_> 1 - 16394 - 1.2934327532462270e-01 + 1 + 5.7564577324623896e+00 1 0 0 @@ -3848,9 +3848,9 @@ <_> 0 - 85052 - -2.7311486405779596e-14 - 0 + 3215 + 2.2204460492503126e-16 + 1 0 0 0. @@ -3858,14 +3858,14 @@ 0. 0. - <_>1 - 5.0149405002593994e-01 - 1.8632251024246216e-01 + <_>5 + 6.2932032346725464e-01 + 1.3783290863037109e+01 <_> 1 - 62257 - -4.2766528221073324e-02 - 0 + 3214 + 2.2204460492503126e-16 + 1 0 0 0. @@ -3874,8 +3874,8 @@ 0. <_> 1 - 22795 - 7.0027469712770588e-02 + 1 + 5.7564577324623896e+00 1 0 0 @@ -3888,9 +3888,9 @@ <_> 0 - 85052 - 2.9531932455028293e-14 - 1 + 3215 + -2.2204460492503136e-16 + 0 0 0 0. @@ -3899,12 +3899,12 @@ 0. <_>5 - 5.0122207403182983e-01 - 1.1999764442443848e+00 + 6.2085735797882080e-01 + 1.3783290863037109e+01 <_> 1 - 32171 - -5.3124706145868887e-02 + 3214 + -2.2204460492503136e-16 0 0 0 @@ -3914,8 +3914,8 @@ 0. <_> 1 - 52881 - 4.6083691543733984e-02 + 1 + 5.7564577324623896e+00 1 0 0 @@ -3928,9 +3928,9 @@ <_> 0 - 85052 - -4.4908521346089602e-14 - 0 + 3215 + 2.2204460492503126e-16 + 1 0 0 0. @@ -3938,14 +3938,14 @@ 0. 0. - <_>1 - 5.0111490488052368e-01 - 1.3103100657463074e-01 + <_>5 + 6.2932032346725464e-01 + 1.3783290863037109e+01 <_> 1 - 47305 - -6.3576995089739186e-02 - 0 + 3214 + 2.2204460492503126e-16 + 1 0 0 0. @@ -3954,8 +3954,8 @@ 0. <_> 1 - 37747 - 3.5133390876482422e-02 + 1 + 5.7564577324623896e+00 1 0 0 @@ -3968,8 +3968,8 @@ <_> 0 - 85052 - -3.1752378504280487e-14 + 3215 + -2.2204460492503136e-16 0 0 0 @@ -3978,14 +3978,14 @@ 0. 0. - <_>1 - 5.0101691484451294e-01 - 1.4286199212074280e-01 + <_>5 + 6.2085735797882080e-01 + 1.3783290863037109e+01 <_> 1 - 51280 - 5.2824618715263574e-02 - 1 + 3214 + -2.2204460492503136e-16 + 0 0 0 0. @@ -3994,9 +3994,9 @@ 0. <_> 1 - 33772 - -3.8555442653898958e-02 - 0 + 1 + 5.7564577324623896e+00 + 1 0 0 0. @@ -4008,9 +4008,9 @@ <_> 0 - 85052 - -5.2735593669695212e-15 - 0 + 3215 + 2.2204460492503126e-16 + 1 0 0 0. @@ -4018,14 +4018,14 @@ 0. 0. - <_>1 - 5.0127285718917847e-01 - 1.5590050816535950e-01 + <_>5 + 6.2932032346725464e-01 + 1.3783290863037109e+01 <_> 1 - 54453 - -5.1638816859316518e-02 - 0 + 3214 + 2.2204460492503126e-16 + 1 0 0 0. @@ -4034,8 +4034,8 @@ 0. <_> 1 - 30599 - 4.9382797139634914e-02 + 1 + 5.7564577324623896e+00 1 0 0 From b9a5e919e2ef05dfddad13328b821427111a0ce7 Mon Sep 17 00:00:00 2001 From: lluis Date: Wed, 4 Sep 2013 20:25:29 +0200 Subject: [PATCH 47/55] better parameter settings for the ERFilter sample --- samples/cpp/erfilter.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/samples/cpp/erfilter.cpp b/samples/cpp/erfilter.cpp index 8a2a45f9c4..763a966601 100644 --- a/samples/cpp/erfilter.cpp +++ b/samples/cpp/erfilter.cpp @@ -58,7 +58,7 @@ int main(int argc, const char * argv[]) double t = (double)getTickCount(); // Build ER tree and filter with the 1st stage default classifier - Ptr er_filter1 = createERFilterNM1(); + Ptr er_filter1 = createERFilterNM1(NULL,1,0.00025,0.13,0.4,true,0.1); er_filter1->run(grey, regions); @@ -89,7 +89,7 @@ int main(int argc, const char * argv[]) t = (double)getTickCount(); // Default second stage classifier - Ptr er_filter2 = createERFilterNM2(); + Ptr er_filter2 = createERFilterNM2(NULL,0.3); er_filter2->run(grey, regions); t = (double)getTickCount() - t; From 04913f5af7d99d7bd935371609298f001bad889d Mon Sep 17 00:00:00 2001 From: lluis Date: Wed, 4 Sep 2013 21:19:43 +0200 Subject: [PATCH 48/55] removed trailing whitespaces --- modules/objdetect/src/erfilter.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/modules/objdetect/src/erfilter.cpp b/modules/objdetect/src/erfilter.cpp index d3384e2b62..caa8259cb8 100644 --- a/modules/objdetect/src/erfilter.cpp +++ b/modules/objdetect/src/erfilter.cpp @@ -805,11 +805,15 @@ ERStat* ERFilterNM::er_tree_filter ( InputArray image, ERStat * stat, ERStat *pa findContours( region, contours, hierarchy, RETR_TREE, CHAIN_APPROX_NONE, Point(0, 0) ); //TODO check epsilon parameter of approxPolyDP (set empirically) : we want more precission // if the region is very small because otherwise we'll loose all the convexities +<<<<<<< HEAD <<<<<<< HEAD approxPolyDP( Mat(contours[0]), contour_poly, min(rect.width,rect.height)/17, true ); ======= approxPolyDP( Mat(contours[0]), contour_poly, (float)min(rect.width,rect.height)/17, true ); >>>>>>> fixed a bug in the calculation of the number of inflexion points feature +======= + approxPolyDP( Mat(contours[0]), contour_poly, (float)min(rect.width,rect.height)/17, true ); +>>>>>>> removed trailing whitespaces bool was_convex = false; @@ -1130,7 +1134,10 @@ Ptr createERFilterNM1(const Ptr& cb, int threshold ======= Ptr filter = new ERFilterNM(); +<<<<<<< HEAD >>>>>>> fixed a bug in the non-max-suppression filter procedure +======= +>>>>>>> removed trailing whitespaces if (cb == NULL) filter->setCallback(makePtr()); else @@ -1166,6 +1173,10 @@ Ptr createERFilterNM2(const Ptr& cb, float minProb Ptr filter = makePtr(); +<<<<<<< HEAD +======= + +>>>>>>> removed trailing whitespaces if (cb == NULL) filter->setCallback(makePtr()); else From 1cc6502db3430f4456547262e925acd1857af73b Mon Sep 17 00:00:00 2001 From: lluis Date: Wed, 4 Sep 2013 21:23:16 +0200 Subject: [PATCH 49/55] removed unnecessary commented block --- modules/objdetect/src/erfilter.cpp | 22 ---------------------- 1 file changed, 22 deletions(-) diff --git a/modules/objdetect/src/erfilter.cpp b/modules/objdetect/src/erfilter.cpp index caa8259cb8..6651140345 100644 --- a/modules/objdetect/src/erfilter.cpp +++ b/modules/objdetect/src/erfilter.cpp @@ -720,40 +720,18 @@ ERStat* ERFilterNM::er_save( ERStat *er, ERStat *parent, ERStat *prev ) { this_er->max_probability_ancestor = this_er; this_er->min_probability_ancestor = this_er; - //cout << "This is the root so now min_p is " << this_er->probability << " and max_p is " << this_er->probability << endl; } else { this_er->max_probability_ancestor = (this_er->probability > parent->max_probability_ancestor->probability)? this_er : parent->max_probability_ancestor; this_er->min_probability_ancestor = (this_er->probability < parent->min_probability_ancestor->probability)? this_er : parent->min_probability_ancestor; - //cout << "This is NOT the root so now min_p is " << this_er->min_probability_ancestor->probability << " and max_p is " << this_er->max_probability_ancestor->probability << endl; - /* if ( (this_er->max_probability_ancestor->probability > minProbability) && (this_er->max_probability_ancestor->probability - this_er->min_probability_ancestor->probability > minProbabilityDiff)) { - cout << " local máxima detcected on " << this_er->max_probability_ancestor->probability << endl; - this_er->max_probability_ancestor->local_maxima = true; - this_er->max_probability_ancestor = this_er; - this_er->min_probability_ancestor = this_er; - cout << " so now min_p is " << this_er->min_probability_ancestor->probability << " and max_p is " << this_er->max_probability_ancestor->probability << endl; - } - else if ((this_er->min_probability_ancestor->local_maxima) && (this_er->probability > (this_er->min_probability_ancestor->probability))) { - cout << " NO local máxima detcected on " << this_er->max_probability_ancestor->probability << endl; - cout << " and min_p was local maxima and this_er->p > min_p" << endl; - cout << " so mark as local maxima "<< this_er->max_probability_ancestor << endl; - cout << " and unmark "<< this_er->min_probability_ancestor << endl; - this_er->max_probability_ancestor->local_maxima = true; - this_er->min_probability_ancestor->local_maxima = false; - - }*/ - if ( (this_er->max_probability_ancestor->probability > minProbability) && (this_er->max_probability_ancestor->probability - this_er->min_probability_ancestor->probability > minProbabilityDiff)) - { - //cout << " local máxima detcected on " << this_er->max_probability_ancestor->probability << endl; this_er->max_probability_ancestor->local_maxima = true; if ((this_er->max_probability_ancestor == this_er) && (this_er->parent->local_maxima)) { - //cout << " local máxima undetcected on " << this_er->parent->probability << endl; this_er->parent->local_maxima = false; } } From 512111af9cd5056f7400aec62a22d87b2a1f3d77 Mon Sep 17 00:00:00 2001 From: lluis Date: Thu, 5 Sep 2013 06:11:01 +0200 Subject: [PATCH 50/55] removed blank line at EOF --- modules/objdetect/src/erfilter.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/modules/objdetect/src/erfilter.cpp b/modules/objdetect/src/erfilter.cpp index 6651140345..2826819a42 100644 --- a/modules/objdetect/src/erfilter.cpp +++ b/modules/objdetect/src/erfilter.cpp @@ -1163,6 +1163,4 @@ Ptr createERFilterNM2(const Ptr& cb, float minProb filter->setMinProbability(minProbability); return (Ptr)filter; } - } - From b7eff9413704338933e0db3c0d9dea22d74fe270 Mon Sep 17 00:00:00 2001 From: Vladislav Vinogradov Date: Fri, 6 Sep 2013 15:52:07 +0400 Subject: [PATCH 51/55] fixed compilation issues with new Ptr --- modules/core/src/opengl.cpp | 24 ++++++++++-------------- modules/gpucodec/src/video_reader.cpp | 14 +++++++------- modules/gpucodec/src/video_source.cpp | 2 +- modules/gpucodec/src/video_writer.cpp | 4 ++-- 4 files changed, 20 insertions(+), 24 deletions(-) diff --git a/modules/core/src/opengl.cpp b/modules/core/src/opengl.cpp index 827d276f16..7bff69bf62 100644 --- a/modules/core/src/opengl.cpp +++ b/modules/core/src/opengl.cpp @@ -484,7 +484,7 @@ cv::ogl::Buffer::Buffer(int arows, int acols, int atype, unsigned int abufId, bo (void) autoRelease; throw_no_ogl(); #else - impl_ = new Impl(abufId, autoRelease); + impl_.reset(new Impl(abufId, autoRelease)); rows_ = arows; cols_ = acols; type_ = atype; @@ -500,7 +500,7 @@ cv::ogl::Buffer::Buffer(Size asize, int atype, unsigned int abufId, bool autoRel (void) autoRelease; throw_no_ogl(); #else - impl_ = new Impl(abufId, autoRelease); + impl_.reset(new Impl(abufId, autoRelease)); rows_ = asize.height; cols_ = asize.width; type_ = atype; @@ -529,7 +529,7 @@ cv::ogl::Buffer::Buffer(InputArray arr, Target target, bool autoRelease) : rows_ Mat mat = arr.getMat(); CV_Assert( mat.isContinuous() ); const GLsizeiptr asize = mat.rows * mat.cols * mat.elemSize(); - impl_ = new Impl(asize, mat.data, target, autoRelease); + impl_.reset(new Impl(asize, mat.data, target, autoRelease)); rows_ = mat.rows; cols_ = mat.cols; type_ = mat.type(); @@ -552,7 +552,7 @@ void cv::ogl::Buffer::create(int arows, int acols, int atype, Target target, boo if (rows_ != arows || cols_ != acols || type_ != atype) { const GLsizeiptr asize = arows * acols * CV_ELEM_SIZE(atype); - impl_ = new Impl(asize, 0, target, autoRelease); + impl_.reset(new Impl(asize, 0, target, autoRelease)); rows_ = arows; cols_ = acols; type_ = atype; @@ -563,8 +563,6 @@ void cv::ogl::Buffer::create(int arows, int acols, int atype, Target target, boo void cv::ogl::Buffer::release() { #ifdef HAVE_OPENGL - if (*impl_.refcount == 1) - impl_->setAutoRelease(true); impl_ = Impl::empty(); rows_ = 0; cols_ = 0; @@ -968,7 +966,7 @@ cv::ogl::Texture2D::Texture2D(int arows, int acols, Format aformat, unsigned int (void) autoRelease; throw_no_ogl(); #else - impl_ = new Impl(atexId, autoRelease); + impl_.reset(new Impl(atexId, autoRelease)); rows_ = arows; cols_ = acols; format_ = aformat; @@ -984,7 +982,7 @@ cv::ogl::Texture2D::Texture2D(Size asize, Format aformat, unsigned int atexId, b (void) autoRelease; throw_no_ogl(); #else - impl_ = new Impl(atexId, autoRelease); + impl_.reset(new Impl(atexId, autoRelease)); rows_ = asize.height; cols_ = asize.width; format_ = aformat; @@ -1024,7 +1022,7 @@ cv::ogl::Texture2D::Texture2D(InputArray arr, bool autoRelease) : rows_(0), cols { ogl::Buffer buf = arr.getOGlBuffer(); buf.bind(ogl::Buffer::PIXEL_UNPACK_BUFFER); - impl_ = new Impl(internalFormats[cn], asize.width, asize.height, srcFormats[cn], gl_types[depth], 0, autoRelease); + impl_.reset(new Impl(internalFormats[cn], asize.width, asize.height, srcFormats[cn], gl_types[depth], 0, autoRelease)); ogl::Buffer::unbind(ogl::Buffer::PIXEL_UNPACK_BUFFER); break; } @@ -1037,7 +1035,7 @@ cv::ogl::Texture2D::Texture2D(InputArray arr, bool autoRelease) : rows_(0), cols GpuMat dmat = arr.getGpuMat(); ogl::Buffer buf(dmat, ogl::Buffer::PIXEL_UNPACK_BUFFER); buf.bind(ogl::Buffer::PIXEL_UNPACK_BUFFER); - impl_ = new Impl(internalFormats[cn], asize.width, asize.height, srcFormats[cn], gl_types[depth], 0, autoRelease); + impl_.reset(new Impl(internalFormats[cn], asize.width, asize.height, srcFormats[cn], gl_types[depth], 0, autoRelease)); ogl::Buffer::unbind(ogl::Buffer::PIXEL_UNPACK_BUFFER); #endif @@ -1049,7 +1047,7 @@ cv::ogl::Texture2D::Texture2D(InputArray arr, bool autoRelease) : rows_(0), cols Mat mat = arr.getMat(); CV_Assert( mat.isContinuous() ); ogl::Buffer::unbind(ogl::Buffer::PIXEL_UNPACK_BUFFER); - impl_ = new Impl(internalFormats[cn], asize.width, asize.height, srcFormats[cn], gl_types[depth], mat.data, autoRelease); + impl_.reset(new Impl(internalFormats[cn], asize.width, asize.height, srcFormats[cn], gl_types[depth], mat.data, autoRelease)); break; } } @@ -1072,7 +1070,7 @@ void cv::ogl::Texture2D::create(int arows, int acols, Format aformat, bool autoR if (rows_ != arows || cols_ != acols || format_ != aformat) { ogl::Buffer::unbind(ogl::Buffer::PIXEL_UNPACK_BUFFER); - impl_ = new Impl(aformat, acols, arows, aformat, gl::FLOAT, 0, autoRelease); + impl_.reset(new Impl(aformat, acols, arows, aformat, gl::FLOAT, 0, autoRelease)); rows_ = arows; cols_ = acols; format_ = aformat; @@ -1083,8 +1081,6 @@ void cv::ogl::Texture2D::create(int arows, int acols, Format aformat, bool autoR void cv::ogl::Texture2D::release() { #ifdef HAVE_OPENGL - if (*impl_.refcount == 1) - impl_->setAutoRelease(true); impl_ = Impl::empty(); rows_ = 0; cols_ = 0; diff --git a/modules/gpucodec/src/video_reader.cpp b/modules/gpucodec/src/video_reader.cpp index 67e9cd1078..abb0da3a9c 100644 --- a/modules/gpucodec/src/video_reader.cpp +++ b/modules/gpucodec/src/video_reader.cpp @@ -99,9 +99,9 @@ namespace cuSafeCall( cuCtxGetCurrent(&ctx) ); cuSafeCall( cuvidCtxLockCreate(&lock_, ctx) ); - frameQueue_ = new detail::FrameQueue; - videoDecoder_ = new detail::VideoDecoder(videoSource_->format(), lock_); - videoParser_ = new detail::VideoParser(videoDecoder_, frameQueue_); + frameQueue_.reset(new FrameQueue); + videoDecoder_.reset(new VideoDecoder(videoSource_->format(), lock_)); + videoParser_.reset(new VideoParser(videoDecoder_, frameQueue_)); videoSource_->setVideoParser(videoParser_); videoSource_->start(); @@ -216,21 +216,21 @@ Ptr cv::gpucodec::createVideoReader(const String& filename) try { - videoSource = new detail::CuvidVideoSource(filename); + videoSource.reset(new CuvidVideoSource(filename)); } catch (...) { Ptr source(new detail::FFmpegVideoSource(filename)); - videoSource = new detail::RawVideoSourceWrapper(source); + videoSource.reset(new RawVideoSourceWrapper(source)); } - return new VideoReaderImpl(videoSource); + return makePtr(videoSource); } Ptr cv::gpucodec::createVideoReader(const Ptr& source) { Ptr videoSource(new detail::RawVideoSourceWrapper(source)); - return new VideoReaderImpl(videoSource); + return makePtr(videoSource); } #endif // HAVE_NVCUVID diff --git a/modules/gpucodec/src/video_source.cpp b/modules/gpucodec/src/video_source.cpp index ce6a1bd8c0..e4241cf2d5 100644 --- a/modules/gpucodec/src/video_source.cpp +++ b/modules/gpucodec/src/video_source.cpp @@ -69,7 +69,7 @@ void cv::gpucodec::detail::RawVideoSourceWrapper::start() { stop_ = false; hasError_ = false; - thread_ = new Thread(readLoop, this); + thread_.reset(new Thread(readLoop, this)); } void cv::gpucodec::detail::RawVideoSourceWrapper::stop() diff --git a/modules/gpucodec/src/video_writer.cpp b/modules/gpucodec/src/video_writer.cpp index 6ffb7c12d7..a1484c2b20 100644 --- a/modules/gpucodec/src/video_writer.cpp +++ b/modules/gpucodec/src/video_writer.cpp @@ -908,12 +908,12 @@ Ptr cv::gpucodec::createVideoWriter(const String& fileName, Size fr Ptr cv::gpucodec::createVideoWriter(const Ptr& encoderCallback, Size frameSize, double fps, SurfaceFormat format) { - return new VideoWriterImpl(encoderCallback, frameSize, fps, format); + return makePtr(encoderCallback, frameSize, fps, format); } Ptr cv::gpucodec::createVideoWriter(const Ptr& encoderCallback, Size frameSize, double fps, const EncoderParams& params, SurfaceFormat format) { - return new VideoWriterImpl(encoderCallback, frameSize, fps, params, format); + return makePtr(encoderCallback, frameSize, fps, params, format); } #endif // !defined HAVE_CUDA || !defined WIN32 From 6ef1d456dd7d1d830d9d34a7f8775f99e8620b04 Mon Sep 17 00:00:00 2001 From: lluis Date: Fri, 6 Sep 2013 14:00:11 +0200 Subject: [PATCH 52/55] fixed rebase conflicts --- .../include/opencv2/objdetect/erfilter.hpp | 5 ----- modules/objdetect/src/erfilter.cpp | 22 ------------------- 2 files changed, 27 deletions(-) diff --git a/modules/objdetect/include/opencv2/objdetect/erfilter.hpp b/modules/objdetect/include/opencv2/objdetect/erfilter.hpp index 2e05996c3e..3906f14772 100644 --- a/modules/objdetect/include/opencv2/objdetect/erfilter.hpp +++ b/modules/objdetect/include/opencv2/objdetect/erfilter.hpp @@ -190,13 +190,8 @@ CV_EXPORTS Ptr createERFilterNM1(const Ptr& cb = P if omitted tries to load a default classifier from file trained_classifierNM2.xml \param minProbability The minimum probability P(er|character) allowed for retreived ER's */ -<<<<<<< HEAD CV_EXPORTS Ptr createERFilterNM2(const Ptr& cb = Ptr(), - float minProbability = 0.85); -======= -CV_EXPORTS Ptr createERFilterNM2(const Ptr& cb = NULL, float minProbability = 0.5); ->>>>>>> fixed a typo error in the default min_Probability param of CreateERFilterNM2 } #endif // _OPENCV_ERFILTER_HPP_ diff --git a/modules/objdetect/src/erfilter.cpp b/modules/objdetect/src/erfilter.cpp index 2826819a42..76603afd3e 100644 --- a/modules/objdetect/src/erfilter.cpp +++ b/modules/objdetect/src/erfilter.cpp @@ -783,16 +783,7 @@ ERStat* ERFilterNM::er_tree_filter ( InputArray image, ERStat * stat, ERStat *pa findContours( region, contours, hierarchy, RETR_TREE, CHAIN_APPROX_NONE, Point(0, 0) ); //TODO check epsilon parameter of approxPolyDP (set empirically) : we want more precission // if the region is very small because otherwise we'll loose all the convexities -<<<<<<< HEAD -<<<<<<< HEAD - approxPolyDP( Mat(contours[0]), contour_poly, min(rect.width,rect.height)/17, true ); -======= approxPolyDP( Mat(contours[0]), contour_poly, (float)min(rect.width,rect.height)/17, true ); ->>>>>>> fixed a bug in the calculation of the number of inflexion points feature -======= - approxPolyDP( Mat(contours[0]), contour_poly, (float)min(rect.width,rect.height)/17, true ); ->>>>>>> removed trailing whitespaces - bool was_convex = false; int num_inflexion_points = 0; @@ -1106,16 +1097,8 @@ Ptr createERFilterNM1(const Ptr& cb, int threshold CV_Assert( (thresholdDelta >= 0) && (thresholdDelta <= 128) ); CV_Assert( (minProbabilityDiff >= 0.) && (minProbabilityDiff <= 1.) ); -<<<<<<< HEAD Ptr filter = makePtr(); -======= - Ptr filter = new ERFilterNM(); - -<<<<<<< HEAD ->>>>>>> fixed a bug in the non-max-suppression filter procedure -======= ->>>>>>> removed trailing whitespaces if (cb == NULL) filter->setCallback(makePtr()); else @@ -1150,11 +1133,6 @@ Ptr createERFilterNM2(const Ptr& cb, float minProb Ptr filter = makePtr(); - -<<<<<<< HEAD -======= - ->>>>>>> removed trailing whitespaces if (cb == NULL) filter->setCallback(makePtr()); else From cd33ca000903e36beadda352efbb7a159b573543 Mon Sep 17 00:00:00 2001 From: lluis Date: Fri, 6 Sep 2013 19:10:53 +0200 Subject: [PATCH 53/55] changed default parameters in CreateERFiltersNM{1,2} functions. They are not needed now in the sample example. --- modules/objdetect/include/opencv2/objdetect/erfilter.hpp | 6 +++--- samples/cpp/erfilter.cpp | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/modules/objdetect/include/opencv2/objdetect/erfilter.hpp b/modules/objdetect/include/opencv2/objdetect/erfilter.hpp index 3906f14772..275ed422a7 100644 --- a/modules/objdetect/include/opencv2/objdetect/erfilter.hpp +++ b/modules/objdetect/include/opencv2/objdetect/erfilter.hpp @@ -172,8 +172,8 @@ public: \param minProbability The minimum probability difference between local maxima and local minima ERs */ CV_EXPORTS Ptr createERFilterNM1(const Ptr& cb = Ptr(), - int thresholdDelta = 1, float minArea = 0.000025, - float maxArea = 0.13, float minProbability = 0.2, + int thresholdDelta = 1, float minArea = 0.00025, + float maxArea = 0.13, float minProbability = 0.4, bool nonMaxSuppression = true, float minProbabilityDiff = 0.1); @@ -191,7 +191,7 @@ CV_EXPORTS Ptr createERFilterNM1(const Ptr& cb = P \param minProbability The minimum probability P(er|character) allowed for retreived ER's */ CV_EXPORTS Ptr createERFilterNM2(const Ptr& cb = Ptr(), - float minProbability = 0.5); + float minProbability = 0.3); } #endif // _OPENCV_ERFILTER_HPP_ diff --git a/samples/cpp/erfilter.cpp b/samples/cpp/erfilter.cpp index 763a966601..8a2a45f9c4 100644 --- a/samples/cpp/erfilter.cpp +++ b/samples/cpp/erfilter.cpp @@ -58,7 +58,7 @@ int main(int argc, const char * argv[]) double t = (double)getTickCount(); // Build ER tree and filter with the 1st stage default classifier - Ptr er_filter1 = createERFilterNM1(NULL,1,0.00025,0.13,0.4,true,0.1); + Ptr er_filter1 = createERFilterNM1(); er_filter1->run(grey, regions); @@ -89,7 +89,7 @@ int main(int argc, const char * argv[]) t = (double)getTickCount(); // Default second stage classifier - Ptr er_filter2 = createERFilterNM2(NULL,0.3); + Ptr er_filter2 = createERFilterNM2(); er_filter2->run(grey, regions); t = (double)getTickCount() - t; From a0771630b04494f0a8cfb6d1a7b4a0a6458d2659 Mon Sep 17 00:00:00 2001 From: Vladislav Vinogradov Date: Mon, 9 Sep 2013 10:57:45 +0400 Subject: [PATCH 54/55] restored original behaviour or release functions for (Buffer and Texture) --- modules/core/doc/opengl_interop.rst | 4 ++++ modules/core/src/opengl.cpp | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/modules/core/doc/opengl_interop.rst b/modules/core/doc/opengl_interop.rst index 53c58fcdf7..5267c4d451 100644 --- a/modules/core/doc/opengl_interop.rst +++ b/modules/core/doc/opengl_interop.rst @@ -122,6 +122,8 @@ Decrements the reference counter and destroys the buffer object if needed. .. ocv:function:: void ogl::Buffer::release() +The function will call `setAutoRelease(true)` . + ogl::Buffer::setAutoRelease @@ -323,6 +325,8 @@ Decrements the reference counter and destroys the texture object if needed. .. ocv:function:: void ogl::Texture2D::release() +The function will call `setAutoRelease(true)` . + ogl::Texture2D::setAutoRelease diff --git a/modules/core/src/opengl.cpp b/modules/core/src/opengl.cpp index 7bff69bf62..36a437a2d6 100644 --- a/modules/core/src/opengl.cpp +++ b/modules/core/src/opengl.cpp @@ -563,6 +563,8 @@ void cv::ogl::Buffer::create(int arows, int acols, int atype, Target target, boo void cv::ogl::Buffer::release() { #ifdef HAVE_OPENGL + if (impl_) + impl_->setAutoRelease(true); impl_ = Impl::empty(); rows_ = 0; cols_ = 0; @@ -1081,6 +1083,8 @@ void cv::ogl::Texture2D::create(int arows, int acols, Format aformat, bool autoR void cv::ogl::Texture2D::release() { #ifdef HAVE_OPENGL + if (impl_) + impl_->setAutoRelease(true); impl_ = Impl::empty(); rows_ = 0; cols_ = 0; From 6ad72bfcb47a83e18d952024c8513cc7fad7c183 Mon Sep 17 00:00:00 2001 From: Vladislav Vinogradov Date: Fri, 6 Sep 2013 16:48:13 +0400 Subject: [PATCH 55/55] removed detail:: prefix int video_reader it conflicts with cv::detail --- modules/gpucodec/src/video_reader.cpp | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/modules/gpucodec/src/video_reader.cpp b/modules/gpucodec/src/video_reader.cpp index abb0da3a9c..3e758087a1 100644 --- a/modules/gpucodec/src/video_reader.cpp +++ b/modules/gpucodec/src/video_reader.cpp @@ -58,12 +58,14 @@ namespace cv { namespace gpu { namespace cudev void NV12_to_RGB(const PtrStepb decodedFrame, PtrStepSz interopFrame, cudaStream_t stream = 0); }}} +using namespace cv::gpucodec::detail; + namespace { class VideoReaderImpl : public VideoReader { public: - explicit VideoReaderImpl(const Ptr& source); + explicit VideoReaderImpl(const Ptr& source); ~VideoReaderImpl(); bool nextFrame(OutputArray frame); @@ -71,11 +73,11 @@ namespace FormatInfo format() const; private: - Ptr videoSource_; + Ptr videoSource_; - Ptr frameQueue_; - Ptr videoDecoder_; - Ptr videoParser_; + Ptr frameQueue_; + Ptr videoDecoder_; + Ptr videoParser_; CUvideoctxlock lock_; @@ -87,7 +89,7 @@ namespace return videoSource_->format(); } - VideoReaderImpl::VideoReaderImpl(const Ptr& source) : + VideoReaderImpl::VideoReaderImpl(const Ptr& source) : videoSource_(source), lock_(0) { @@ -159,7 +161,7 @@ namespace return false; // Wait a bit - detail::Thread::sleep(1); + Thread::sleep(1); } bool isProgressive = displayInfo.progressive_frame != 0; @@ -212,7 +214,7 @@ Ptr cv::gpucodec::createVideoReader(const String& filename) { CV_Assert( !filename.empty() ); - Ptr videoSource; + Ptr videoSource; try { @@ -220,7 +222,7 @@ Ptr cv::gpucodec::createVideoReader(const String& filename) } catch (...) { - Ptr source(new detail::FFmpegVideoSource(filename)); + Ptr source(new FFmpegVideoSource(filename)); videoSource.reset(new RawVideoSourceWrapper(source)); } @@ -229,7 +231,7 @@ Ptr cv::gpucodec::createVideoReader(const String& filename) Ptr cv::gpucodec::createVideoReader(const Ptr& source) { - Ptr videoSource(new detail::RawVideoSourceWrapper(source)); + Ptr videoSource(new RawVideoSourceWrapper(source)); return makePtr(videoSource); }