mirror of
https://github.com/opencv/opencv.git
synced 2025-08-05 14:06:35 +08:00
next: drop CV_CXX11 conditions
define itself is still here for compatibility
This commit is contained in:
parent
2b2fa58f97
commit
98c8584b88
@ -138,13 +138,8 @@ bool CV_Affine3D_EstTest::testNPoints()
|
|||||||
std::transform(fpts.ptr<Point3f>(), fpts.ptr<Point3f>() + n, tpts.ptr<Point3f>(), WrapAff(aff));
|
std::transform(fpts.ptr<Point3f>(), fpts.ptr<Point3f>() + n, tpts.ptr<Point3f>(), WrapAff(aff));
|
||||||
|
|
||||||
/* adding noise*/
|
/* adding noise*/
|
||||||
#ifdef CV_CXX11
|
|
||||||
std::transform(tpts.ptr<Point3f>() + m, tpts.ptr<Point3f>() + n, tpts.ptr<Point3f>() + m,
|
std::transform(tpts.ptr<Point3f>() + m, tpts.ptr<Point3f>() + n, tpts.ptr<Point3f>() + m,
|
||||||
[=] (const Point3f& pt) -> Point3f { return Noise(noise_level)(pt + shift_outl); });
|
[=] (const Point3f& pt) -> Point3f { return Noise(noise_level)(pt + shift_outl); });
|
||||||
#else
|
|
||||||
std::transform(tpts.ptr<Point3f>() + m, tpts.ptr<Point3f>() + n, tpts.ptr<Point3f>() + m, std::bind2nd(std::plus<Point3f>(), shift_outl));
|
|
||||||
std::transform(tpts.ptr<Point3f>() + m, tpts.ptr<Point3f>() + n, tpts.ptr<Point3f>() + m, Noise(noise_level));
|
|
||||||
#endif
|
|
||||||
|
|
||||||
Mat aff_est;
|
Mat aff_est;
|
||||||
vector<uchar> outl;
|
vector<uchar> outl;
|
||||||
|
@ -58,7 +58,6 @@
|
|||||||
namespace cv { namespace cuda { namespace device
|
namespace cv { namespace cuda { namespace device
|
||||||
{
|
{
|
||||||
// Function Objects
|
// Function Objects
|
||||||
#ifdef CV_CXX11
|
|
||||||
template<typename Argument, typename Result> struct unary_function
|
template<typename Argument, typename Result> struct unary_function
|
||||||
{
|
{
|
||||||
typedef Argument argument_type;
|
typedef Argument argument_type;
|
||||||
@ -70,10 +69,6 @@ namespace cv { namespace cuda { namespace device
|
|||||||
typedef Argument2 second_argument_type;
|
typedef Argument2 second_argument_type;
|
||||||
typedef Result result_type;
|
typedef Result result_type;
|
||||||
};
|
};
|
||||||
#else
|
|
||||||
template<typename Argument, typename Result> struct unary_function : public std::unary_function<Argument, Result> {};
|
|
||||||
template<typename Argument1, typename Argument2, typename Result> struct binary_function : public std::binary_function<Argument1, Argument2, Result> {};
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Arithmetic Operations
|
// Arithmetic Operations
|
||||||
template <typename T> struct plus : binary_function<T, T, T>
|
template <typename T> struct plus : binary_function<T, T, T>
|
||||||
|
@ -417,6 +417,9 @@ Cv64suf;
|
|||||||
# undef CV_CXX11
|
# undef CV_CXX11
|
||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
#ifndef CV_CXX11
|
||||||
|
# error "OpenCV 4.x+ requires enabled C++11 support"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/****************************************************************************************\
|
/****************************************************************************************\
|
||||||
|
@ -53,9 +53,7 @@
|
|||||||
|
|
||||||
#include "opencv2/core/bufferpool.hpp"
|
#include "opencv2/core/bufferpool.hpp"
|
||||||
|
|
||||||
#ifdef CV_CXX11
|
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
#endif
|
|
||||||
|
|
||||||
namespace cv
|
namespace cv
|
||||||
{
|
{
|
||||||
@ -984,7 +982,6 @@ public:
|
|||||||
*/
|
*/
|
||||||
template<typename _Tp> explicit Mat(const std::vector<_Tp>& vec, bool copyData=false);
|
template<typename _Tp> explicit Mat(const std::vector<_Tp>& vec, bool copyData=false);
|
||||||
|
|
||||||
#ifdef CV_CXX11
|
|
||||||
/** @overload
|
/** @overload
|
||||||
*/
|
*/
|
||||||
template<typename _Tp, typename = typename std::enable_if<std::is_arithmetic<_Tp>::value>::type>
|
template<typename _Tp, typename = typename std::enable_if<std::is_arithmetic<_Tp>::value>::type>
|
||||||
@ -993,7 +990,6 @@ public:
|
|||||||
/** @overload
|
/** @overload
|
||||||
*/
|
*/
|
||||||
template<typename _Tp> explicit Mat(const std::initializer_list<int> sizes, const std::initializer_list<_Tp> list);
|
template<typename _Tp> explicit Mat(const std::initializer_list<int> sizes, const std::initializer_list<_Tp> list);
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef CV_CXX_STD_ARRAY
|
#ifdef CV_CXX_STD_ARRAY
|
||||||
/** @overload
|
/** @overload
|
||||||
@ -2210,10 +2206,8 @@ public:
|
|||||||
explicit Mat_(const Point3_<typename DataType<_Tp>::channel_type>& pt, bool copyData=true);
|
explicit Mat_(const Point3_<typename DataType<_Tp>::channel_type>& pt, bool copyData=true);
|
||||||
explicit Mat_(const MatCommaInitializer_<_Tp>& commaInitializer);
|
explicit Mat_(const MatCommaInitializer_<_Tp>& commaInitializer);
|
||||||
|
|
||||||
#ifdef CV_CXX11
|
|
||||||
Mat_(std::initializer_list<_Tp> values);
|
Mat_(std::initializer_list<_Tp> values);
|
||||||
explicit Mat_(const std::initializer_list<int> sizes, const std::initializer_list<_Tp> values);
|
explicit Mat_(const std::initializer_list<int> sizes, const std::initializer_list<_Tp> values);
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef CV_CXX_STD_ARRAY
|
#ifdef CV_CXX_STD_ARRAY
|
||||||
template <std::size_t _Nm> explicit Mat_(const std::array<_Tp, _Nm>& arr, bool copyData=false);
|
template <std::size_t _Nm> explicit Mat_(const std::array<_Tp, _Nm>& arr, bool copyData=false);
|
||||||
|
@ -574,7 +574,6 @@ Mat::Mat(const std::vector<_Tp>& vec, bool copyData)
|
|||||||
Mat((int)vec.size(), 1, traits::Type<_Tp>::value, (uchar*)&vec[0]).copyTo(*this);
|
Mat((int)vec.size(), 1, traits::Type<_Tp>::value, (uchar*)&vec[0]).copyTo(*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef CV_CXX11
|
|
||||||
template<typename _Tp, typename> inline
|
template<typename _Tp, typename> inline
|
||||||
Mat::Mat(const std::initializer_list<_Tp> list)
|
Mat::Mat(const std::initializer_list<_Tp> list)
|
||||||
: Mat()
|
: Mat()
|
||||||
@ -594,7 +593,6 @@ Mat::Mat(const std::initializer_list<int> sizes, const std::initializer_list<_Tp
|
|||||||
CV_Assert(size_total == list.size());
|
CV_Assert(size_total == list.size());
|
||||||
Mat((int)sizes.size(), (int*)sizes.begin(), traits::Type<_Tp>::value, (uchar*)list.begin()).copyTo(*this);
|
Mat((int)sizes.size(), (int*)sizes.begin(), traits::Type<_Tp>::value, (uchar*)list.begin()).copyTo(*this);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef CV_CXX_STD_ARRAY
|
#ifdef CV_CXX_STD_ARRAY
|
||||||
template<typename _Tp, std::size_t _Nm> inline
|
template<typename _Tp, std::size_t _Nm> inline
|
||||||
@ -1634,7 +1632,6 @@ Mat_<_Tp>::Mat_(const std::vector<_Tp>& vec, bool copyData)
|
|||||||
: Mat(vec, copyData)
|
: Mat(vec, copyData)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
#ifdef CV_CXX11
|
|
||||||
template<typename _Tp> inline
|
template<typename _Tp> inline
|
||||||
Mat_<_Tp>::Mat_(std::initializer_list<_Tp> list)
|
Mat_<_Tp>::Mat_(std::initializer_list<_Tp> list)
|
||||||
: Mat(list)
|
: Mat(list)
|
||||||
@ -1644,7 +1641,6 @@ template<typename _Tp> inline
|
|||||||
Mat_<_Tp>::Mat_(const std::initializer_list<int> sizes, std::initializer_list<_Tp> list)
|
Mat_<_Tp>::Mat_(const std::initializer_list<int> sizes, std::initializer_list<_Tp> list)
|
||||||
: Mat(sizes, list)
|
: Mat(sizes, list)
|
||||||
{}
|
{}
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef CV_CXX_STD_ARRAY
|
#ifdef CV_CXX_STD_ARRAY
|
||||||
template<typename _Tp> template<std::size_t _Nm> inline
|
template<typename _Tp> template<std::size_t _Nm> inline
|
||||||
|
@ -53,9 +53,7 @@
|
|||||||
#include "opencv2/core/traits.hpp"
|
#include "opencv2/core/traits.hpp"
|
||||||
#include "opencv2/core/saturate.hpp"
|
#include "opencv2/core/saturate.hpp"
|
||||||
|
|
||||||
#ifdef CV_CXX11
|
|
||||||
#include <initializer_list>
|
#include <initializer_list>
|
||||||
#endif
|
|
||||||
|
|
||||||
namespace cv
|
namespace cv
|
||||||
{
|
{
|
||||||
@ -141,9 +139,7 @@ public:
|
|||||||
_Tp v12, _Tp v13, _Tp v14, _Tp v15); //!< 1x16, 4x4 or 16x1 matrix
|
_Tp v12, _Tp v13, _Tp v14, _Tp v15); //!< 1x16, 4x4 or 16x1 matrix
|
||||||
explicit Matx(const _Tp* vals); //!< initialize from a plain array
|
explicit Matx(const _Tp* vals); //!< initialize from a plain array
|
||||||
|
|
||||||
#ifdef CV_CXX11
|
|
||||||
Matx(std::initializer_list<_Tp>); //!< initialize from an initializer list
|
Matx(std::initializer_list<_Tp>); //!< initialize from an initializer list
|
||||||
#endif
|
|
||||||
|
|
||||||
static Matx all(_Tp alpha);
|
static Matx all(_Tp alpha);
|
||||||
static Matx zeros();
|
static Matx zeros();
|
||||||
@ -361,9 +357,7 @@ public:
|
|||||||
Vec(_Tp v0, _Tp v1, _Tp v2, _Tp v3, _Tp v4, _Tp v5, _Tp v6, _Tp v7, _Tp v8, _Tp v9, _Tp v10, _Tp v11, _Tp v12, _Tp v13); //!< 14-element vector constructor
|
Vec(_Tp v0, _Tp v1, _Tp v2, _Tp v3, _Tp v4, _Tp v5, _Tp v6, _Tp v7, _Tp v8, _Tp v9, _Tp v10, _Tp v11, _Tp v12, _Tp v13); //!< 14-element vector constructor
|
||||||
explicit Vec(const _Tp* values);
|
explicit Vec(const _Tp* values);
|
||||||
|
|
||||||
#ifdef CV_CXX11
|
|
||||||
Vec(std::initializer_list<_Tp>);
|
Vec(std::initializer_list<_Tp>);
|
||||||
#endif
|
|
||||||
|
|
||||||
Vec(const Vec<_Tp, cn>& v);
|
Vec(const Vec<_Tp, cn>& v);
|
||||||
|
|
||||||
@ -665,7 +659,6 @@ Matx<_Tp, m, n>::Matx(const _Tp* values)
|
|||||||
for( int i = 0; i < channels; i++ ) val[i] = values[i];
|
for( int i = 0; i < channels; i++ ) val[i] = values[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef CV_CXX11
|
|
||||||
template<typename _Tp, int m, int n> inline
|
template<typename _Tp, int m, int n> inline
|
||||||
Matx<_Tp, m, n>::Matx(std::initializer_list<_Tp> list)
|
Matx<_Tp, m, n>::Matx(std::initializer_list<_Tp> list)
|
||||||
{
|
{
|
||||||
@ -676,7 +669,6 @@ Matx<_Tp, m, n>::Matx(std::initializer_list<_Tp> list)
|
|||||||
val[i++] = elem;
|
val[i++] = elem;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
template<typename _Tp, int m, int n> inline
|
template<typename _Tp, int m, int n> inline
|
||||||
Matx<_Tp, m, n> Matx<_Tp, m, n>::all(_Tp alpha)
|
Matx<_Tp, m, n> Matx<_Tp, m, n>::all(_Tp alpha)
|
||||||
@ -1019,11 +1011,9 @@ template<typename _Tp, int cn> inline
|
|||||||
Vec<_Tp, cn>::Vec(const _Tp* values)
|
Vec<_Tp, cn>::Vec(const _Tp* values)
|
||||||
: Matx<_Tp, cn, 1>(values) {}
|
: Matx<_Tp, cn, 1>(values) {}
|
||||||
|
|
||||||
#ifdef CV_CXX11
|
|
||||||
template<typename _Tp, int cn> inline
|
template<typename _Tp, int cn> inline
|
||||||
Vec<_Tp, cn>::Vec(std::initializer_list<_Tp> list)
|
Vec<_Tp, cn>::Vec(std::initializer_list<_Tp> list)
|
||||||
: Matx<_Tp, cn, 1>(list) {}
|
: Matx<_Tp, cn, 1>(list) {}
|
||||||
#endif
|
|
||||||
|
|
||||||
template<typename _Tp, int cn> inline
|
template<typename _Tp, int cn> inline
|
||||||
Vec<_Tp, cn>::Vec(const Vec<_Tp, cn>& m)
|
Vec<_Tp, cn>::Vec(const Vec<_Tp, cn>& m)
|
||||||
|
@ -56,9 +56,7 @@
|
|||||||
#include "opencv2/core.hpp"
|
#include "opencv2/core.hpp"
|
||||||
#include <ostream>
|
#include <ostream>
|
||||||
|
|
||||||
#ifdef CV_CXX11
|
|
||||||
#include <functional>
|
#include <functional>
|
||||||
#endif
|
|
||||||
|
|
||||||
namespace cv
|
namespace cv
|
||||||
{
|
{
|
||||||
@ -531,7 +529,6 @@ public:
|
|||||||
*/
|
*/
|
||||||
CV_EXPORTS void parallel_for_(const Range& range, const ParallelLoopBody& body, double nstripes=-1.);
|
CV_EXPORTS void parallel_for_(const Range& range, const ParallelLoopBody& body, double nstripes=-1.);
|
||||||
|
|
||||||
#ifdef CV_CXX11
|
|
||||||
class ParallelLoopBodyLambdaWrapper : public ParallelLoopBody
|
class ParallelLoopBodyLambdaWrapper : public ParallelLoopBody
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
@ -551,7 +548,6 @@ inline void parallel_for_(const Range& range, std::function<void(const Range&)>
|
|||||||
{
|
{
|
||||||
parallel_for_(range, ParallelLoopBodyLambdaWrapper(functor), nstripes);
|
parallel_for_(range, ParallelLoopBodyLambdaWrapper(functor), nstripes);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
/////////////////////////////// forEach method of cv::Mat ////////////////////////////
|
/////////////////////////////// forEach method of cv::Mat ////////////////////////////
|
||||||
template<typename _Tp, typename Functor> inline
|
template<typename _Tp, typename Functor> inline
|
||||||
|
@ -21,27 +21,15 @@
|
|||||||
|
|
||||||
//#define CV_USE_GLOBAL_WORKERS_COND_VAR // not effective on many-core systems (10+)
|
//#define CV_USE_GLOBAL_WORKERS_COND_VAR // not effective on many-core systems (10+)
|
||||||
|
|
||||||
#ifdef CV_CXX11
|
|
||||||
#include <atomic>
|
#include <atomic>
|
||||||
#else
|
|
||||||
#include <unistd.h> // _POSIX_PRIORITY_SCHEDULING
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Spin lock's OS-level yield
|
// Spin lock's OS-level yield
|
||||||
#ifdef DECLARE_CV_YIELD
|
#ifdef DECLARE_CV_YIELD
|
||||||
DECLARE_CV_YIELD
|
DECLARE_CV_YIELD
|
||||||
#endif
|
#endif
|
||||||
#ifndef CV_YIELD
|
#ifndef CV_YIELD
|
||||||
# ifdef CV_CXX11
|
# include <thread>
|
||||||
# include <thread>
|
# define CV_YIELD() std::this_thread::yield()
|
||||||
# define CV_YIELD() std::this_thread::yield()
|
|
||||||
# elif defined(_POSIX_PRIORITY_SCHEDULING)
|
|
||||||
# include <sched.h>
|
|
||||||
# define CV_YIELD() sched_yield()
|
|
||||||
# else
|
|
||||||
# warning "Can't detect sched_yield() on the target platform. Specify CV_YIELD() definition via compiler flags."
|
|
||||||
# define CV_YIELD() /* no-op: works, but not effective */
|
|
||||||
# endif
|
|
||||||
#endif // CV_YIELD
|
#endif // CV_YIELD
|
||||||
|
|
||||||
// Spin lock's CPU-level yield (required for Hyper-Threading)
|
// Spin lock's CPU-level yield (required for Hyper-Threading)
|
||||||
@ -290,15 +278,9 @@ public:
|
|||||||
is_completed(false)
|
is_completed(false)
|
||||||
{
|
{
|
||||||
CV_LOG_VERBOSE(NULL, 5, "ParallelJob::ParallelJob(" << (void*)this << ")");
|
CV_LOG_VERBOSE(NULL, 5, "ParallelJob::ParallelJob(" << (void*)this << ")");
|
||||||
#ifdef CV_CXX11
|
|
||||||
current_task.store(0, std::memory_order_relaxed);
|
current_task.store(0, std::memory_order_relaxed);
|
||||||
active_thread_count.store(0, std::memory_order_relaxed);
|
active_thread_count.store(0, std::memory_order_relaxed);
|
||||||
completed_thread_count.store(0, std::memory_order_relaxed);
|
completed_thread_count.store(0, std::memory_order_relaxed);
|
||||||
#else
|
|
||||||
current_task = 0;
|
|
||||||
active_thread_count = 0;
|
|
||||||
completed_thread_count = 0;
|
|
||||||
#endif
|
|
||||||
dummy0_[0] = 0, dummy1_[0] = 0, dummy2_[0] = 0; // compiler warning
|
dummy0_[0] = 0, dummy1_[0] = 0, dummy2_[0] = 0; // compiler warning
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -319,11 +301,7 @@ public:
|
|||||||
for (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
int chunk_size = std::max(1, (task_count - current_task) / remaining_multiplier);
|
int chunk_size = std::max(1, (task_count - current_task) / remaining_multiplier);
|
||||||
#ifdef CV_CXX11
|
|
||||||
int id = current_task.fetch_add(chunk_size, std::memory_order_seq_cst);
|
int id = current_task.fetch_add(chunk_size, std::memory_order_seq_cst);
|
||||||
#else
|
|
||||||
int id = (int)CV_XADD(¤t_task, chunk_size);
|
|
||||||
#endif
|
|
||||||
if (id >= task_count)
|
if (id >= task_count)
|
||||||
break; // no more free tasks
|
break; // no more free tasks
|
||||||
|
|
||||||
@ -349,7 +327,7 @@ public:
|
|||||||
const ParallelLoopBody& body;
|
const ParallelLoopBody& body;
|
||||||
const Range range;
|
const Range range;
|
||||||
const unsigned nstripes;
|
const unsigned nstripes;
|
||||||
#ifdef CV_CXX11
|
|
||||||
std::atomic<int> current_task; // next free part of job
|
std::atomic<int> current_task; // next free part of job
|
||||||
int64 dummy0_[8]; // avoid cache-line reusing for the same atomics
|
int64 dummy0_[8]; // avoid cache-line reusing for the same atomics
|
||||||
|
|
||||||
@ -358,16 +336,6 @@ public:
|
|||||||
|
|
||||||
std::atomic<int> completed_thread_count; // number of threads completed any activities on this job
|
std::atomic<int> completed_thread_count; // number of threads completed any activities on this job
|
||||||
int64 dummy2_[8]; // avoid cache-line reusing for the same atomics
|
int64 dummy2_[8]; // avoid cache-line reusing for the same atomics
|
||||||
#else
|
|
||||||
/*CV_DECL_ALIGNED(64)*/ volatile int current_task; // next free part of job
|
|
||||||
int64 dummy0_[8]; // avoid cache-line reusing for the same atomics
|
|
||||||
|
|
||||||
/*CV_DECL_ALIGNED(64)*/ volatile int active_thread_count; // number of threads worked on this job
|
|
||||||
int64 dummy1_[8]; // avoid cache-line reusing for the same atomics
|
|
||||||
|
|
||||||
/*CV_DECL_ALIGNED(64)*/ volatile int completed_thread_count; // number of threads completed any activities on this job
|
|
||||||
int64 dummy2_[8]; // avoid cache-line reusing for the same atomics
|
|
||||||
#endif
|
|
||||||
|
|
||||||
volatile bool is_completed; // std::atomic_flag ?
|
volatile bool is_completed; // std::atomic_flag ?
|
||||||
|
|
||||||
@ -437,11 +405,7 @@ void WorkerThread::thread_body()
|
|||||||
CV_LOG_VERBOSE(NULL, 5, "Thread: job size=" << j->range.size() << " done=" << j->current_task);
|
CV_LOG_VERBOSE(NULL, 5, "Thread: job size=" << j->range.size() << " done=" << j->current_task);
|
||||||
if (j->current_task < j->range.size())
|
if (j->current_task < j->range.size())
|
||||||
{
|
{
|
||||||
#ifdef CV_CXX11
|
|
||||||
int other = j->active_thread_count.fetch_add(1, std::memory_order_seq_cst);
|
int other = j->active_thread_count.fetch_add(1, std::memory_order_seq_cst);
|
||||||
#else
|
|
||||||
int other = CV_XADD(&j->active_thread_count, 1);
|
|
||||||
#endif
|
|
||||||
CV_LOG_VERBOSE(NULL, 5, "Thread: processing new job (with " << other << " other threads)"); CV_UNUSED(other);
|
CV_LOG_VERBOSE(NULL, 5, "Thread: processing new job (with " << other << " other threads)"); CV_UNUSED(other);
|
||||||
#ifdef CV_PROFILE_THREADS
|
#ifdef CV_PROFILE_THREADS
|
||||||
stat.threadExecuteStart = getTickCount();
|
stat.threadExecuteStart = getTickCount();
|
||||||
@ -450,13 +414,8 @@ void WorkerThread::thread_body()
|
|||||||
#else
|
#else
|
||||||
j->execute(true);
|
j->execute(true);
|
||||||
#endif
|
#endif
|
||||||
#ifdef CV_CXX11
|
|
||||||
int completed = j->completed_thread_count.fetch_add(1, std::memory_order_seq_cst) + 1;
|
int completed = j->completed_thread_count.fetch_add(1, std::memory_order_seq_cst) + 1;
|
||||||
int active = j->active_thread_count.load(std::memory_order_acquire);
|
int active = j->active_thread_count.load(std::memory_order_acquire);
|
||||||
#else
|
|
||||||
int completed = (int)CV_XADD(&j->completed_thread_count, 1) + 1;
|
|
||||||
int active = j->active_thread_count;
|
|
||||||
#endif
|
|
||||||
if (CV_WORKER_ACTIVE_WAIT_THREADS_LIMIT > 0)
|
if (CV_WORKER_ACTIVE_WAIT_THREADS_LIMIT > 0)
|
||||||
{
|
{
|
||||||
allow_active_wait = true;
|
allow_active_wait = true;
|
||||||
|
@ -1344,8 +1344,6 @@ TEST(Core_Matx, fromMat_)
|
|||||||
ASSERT_EQ( cvtest::norm(a, b, NORM_INF), 0.);
|
ASSERT_EQ( cvtest::norm(a, b, NORM_INF), 0.);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef CV_CXX11
|
|
||||||
|
|
||||||
TEST(Core_Matx, from_initializer_list)
|
TEST(Core_Matx, from_initializer_list)
|
||||||
{
|
{
|
||||||
Mat_<double> a = (Mat_<double>(2,2) << 10, 11, 12, 13);
|
Mat_<double> a = (Mat_<double>(2,2) << 10, 11, 12, 13);
|
||||||
@ -1360,8 +1358,6 @@ TEST(Core_Mat, regression_9507)
|
|||||||
EXPECT_EQ(25u, m2.total());
|
EXPECT_EQ(25u, m2.total());
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // CXX11
|
|
||||||
|
|
||||||
TEST(Core_InputArray, empty)
|
TEST(Core_InputArray, empty)
|
||||||
{
|
{
|
||||||
vector<vector<Point> > data;
|
vector<vector<Point> > data;
|
||||||
@ -1711,8 +1707,6 @@ TEST(Mat, regression_8680)
|
|||||||
ASSERT_EQ(mat.channels(), 2);
|
ASSERT_EQ(mat.channels(), 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef CV_CXX11
|
|
||||||
|
|
||||||
TEST(Mat_, range_based_for)
|
TEST(Mat_, range_based_for)
|
||||||
{
|
{
|
||||||
Mat_<uchar> img = Mat_<uchar>::zeros(3, 3);
|
Mat_<uchar> img = Mat_<uchar>::zeros(3, 3);
|
||||||
@ -1774,6 +1768,4 @@ TEST(Mat_, template_based_ptr)
|
|||||||
ASSERT_FLOAT_EQ(66.0f, *(mat.ptr<float>(idx)));
|
ASSERT_FLOAT_EQ(66.0f, *(mat.ptr<float>(idx)));
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
}} // namespace
|
}} // namespace
|
||||||
|
@ -564,12 +564,8 @@ namespace
|
|||||||
|
|
||||||
if (compactResult)
|
if (compactResult)
|
||||||
{
|
{
|
||||||
#ifdef CV_CXX11
|
|
||||||
std::vector< std::vector<DMatch> >::iterator new_end = std::remove_if(matches.begin(), matches.end(),
|
std::vector< std::vector<DMatch> >::iterator new_end = std::remove_if(matches.begin(), matches.end(),
|
||||||
[](const std::vector<DMatch>& e)->bool { return e.empty(); });
|
[](const std::vector<DMatch>& e)->bool { return e.empty(); });
|
||||||
#else
|
|
||||||
std::vector< std::vector<DMatch> >::iterator new_end = std::remove_if(matches.begin(), matches.end(), std::mem_fun_ref(&std::vector<DMatch>::empty));
|
|
||||||
#endif
|
|
||||||
matches.erase(new_end, matches.end());
|
matches.erase(new_end, matches.end());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -52,11 +52,7 @@
|
|||||||
namespace cv
|
namespace cv
|
||||||
{
|
{
|
||||||
|
|
||||||
#ifdef CV_CXX11
|
|
||||||
struct greaterThanPtr
|
struct greaterThanPtr
|
||||||
#else
|
|
||||||
struct greaterThanPtr : public std::binary_function<const float *, const float *, bool>
|
|
||||||
#endif
|
|
||||||
{
|
{
|
||||||
bool operator () (const float * a, const float * b) const
|
bool operator () (const float * a, const float * b) const
|
||||||
// Ensure a fully deterministic result of the sort
|
// Ensure a fully deterministic result of the sort
|
||||||
|
@ -385,11 +385,7 @@ namespace
|
|||||||
const double thetaScale = levels_ / 360.0;
|
const double thetaScale = levels_ / 360.0;
|
||||||
|
|
||||||
r_table_.resize(levels_ + 1);
|
r_table_.resize(levels_ + 1);
|
||||||
#ifdef CV_CXX11
|
|
||||||
std::for_each(r_table_.begin(), r_table_.end(), [](std::vector<Point>& e)->void { e.clear(); });
|
std::for_each(r_table_.begin(), r_table_.end(), [](std::vector<Point>& e)->void { e.clear(); });
|
||||||
#else
|
|
||||||
std::for_each(r_table_.begin(), r_table_.end(), std::mem_fun_ref(&std::vector<Point>::clear));
|
|
||||||
#endif
|
|
||||||
|
|
||||||
for (int y = 0; y < templSize_.height; ++y)
|
for (int y = 0; y < templSize_.height; ++y)
|
||||||
{
|
{
|
||||||
@ -696,12 +692,7 @@ namespace
|
|||||||
getContourPoints(edges, dx, dy, points);
|
getContourPoints(edges, dx, dy, points);
|
||||||
|
|
||||||
features.resize(levels_ + 1);
|
features.resize(levels_ + 1);
|
||||||
#ifdef CV_CXX11
|
|
||||||
std::for_each(features.begin(), features.end(), [=](std::vector<Feature>& e) { e.clear(); e.reserve(maxBufferSize_); });
|
std::for_each(features.begin(), features.end(), [=](std::vector<Feature>& e) { e.clear(); e.reserve(maxBufferSize_); });
|
||||||
#else
|
|
||||||
std::for_each(features.begin(), features.end(), std::mem_fun_ref(&std::vector<Feature>::clear));
|
|
||||||
std::for_each(features.begin(), features.end(), std::bind2nd(std::mem_fun_ref(&std::vector<Feature>::reserve), maxBufferSize_));
|
|
||||||
#endif
|
|
||||||
|
|
||||||
for (size_t i = 0; i < points.size(); ++i)
|
for (size_t i = 0; i < points.size(); ++i)
|
||||||
{
|
{
|
||||||
|
@ -56,11 +56,7 @@ enum { MINEIGENVAL=0, HARRIS=1, EIGENVALSVECS=2 };
|
|||||||
|
|
||||||
/////////////////////ref//////////////////////
|
/////////////////////ref//////////////////////
|
||||||
|
|
||||||
#ifdef CV_CXX11
|
|
||||||
struct greaterThanPtr
|
struct greaterThanPtr
|
||||||
#else
|
|
||||||
struct greaterThanPtr : public std::binary_function<const float *, const float *, bool>
|
|
||||||
#endif
|
|
||||||
{
|
{
|
||||||
bool operator () (const float * a, const float * b) const
|
bool operator () (const float * a, const float * b) const
|
||||||
{ return *a > *b; }
|
{ return *a > *b; }
|
||||||
|
@ -46,10 +46,6 @@
|
|||||||
|
|
||||||
#include <opencv2/core.hpp>
|
#include <opencv2/core.hpp>
|
||||||
|
|
||||||
// After this condition removal update blacklist for bindings: modules/python/common.cmake
|
|
||||||
#if defined(__linux__) || defined(LINUX) || defined(__APPLE__) || defined(__ANDROID__) || \
|
|
||||||
defined(CV_CXX11)
|
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
namespace cv
|
namespace cv
|
||||||
@ -222,6 +218,5 @@ class CV_EXPORTS DetectionBasedTracker
|
|||||||
//! @} objdetect
|
//! @} objdetect
|
||||||
|
|
||||||
} //end of cv namespace
|
} //end of cv namespace
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -53,11 +53,7 @@ namespace opencv_test {
|
|||||||
namespace ocl {
|
namespace ocl {
|
||||||
///////////// HOG////////////////////////
|
///////////// HOG////////////////////////
|
||||||
|
|
||||||
#ifdef CV_CXX11
|
|
||||||
struct RectLess
|
struct RectLess
|
||||||
#else
|
|
||||||
struct RectLess : public std::binary_function<cv::Rect, cv::Rect, bool>
|
|
||||||
#endif
|
|
||||||
{
|
{
|
||||||
bool operator()(const cv::Rect& a,
|
bool operator()(const cv::Rect& a,
|
||||||
const cv::Rect& b) const
|
const cv::Rect& b) const
|
||||||
|
@ -42,23 +42,12 @@
|
|||||||
//M*/
|
//M*/
|
||||||
|
|
||||||
#include "precomp.hpp"
|
#include "precomp.hpp"
|
||||||
#include <cassert>
|
|
||||||
|
|
||||||
#ifdef CV_CXX11
|
|
||||||
#define USE_STD_THREADS
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(__linux__) || defined(LINUX) || defined(__APPLE__) || defined(__ANDROID__) || defined(USE_STD_THREADS)
|
|
||||||
|
|
||||||
#include "opencv2/core/utility.hpp"
|
#include "opencv2/core/utility.hpp"
|
||||||
|
|
||||||
#ifdef USE_STD_THREADS
|
|
||||||
#include <thread>
|
#include <thread>
|
||||||
#include <mutex>
|
#include <mutex>
|
||||||
#include <condition_variable>
|
#include <condition_variable>
|
||||||
#else //USE_STD_THREADS
|
|
||||||
#include <pthread.h>
|
|
||||||
#endif //USE_STD_THREADS
|
|
||||||
|
|
||||||
#if defined(DEBUG) || defined(_DEBUG)
|
#if defined(DEBUG) || defined(_DEBUG)
|
||||||
#undef DEBUGLOGS
|
#undef DEBUGLOGS
|
||||||
@ -139,49 +128,26 @@ class cv::DetectionBasedTracker::SeparateDetectionWork
|
|||||||
}
|
}
|
||||||
void setParameters(const cv::DetectionBasedTracker::Parameters& params)
|
void setParameters(const cv::DetectionBasedTracker::Parameters& params)
|
||||||
{
|
{
|
||||||
#ifdef USE_STD_THREADS
|
|
||||||
std::unique_lock<std::mutex> mtx_lock(mtx);
|
std::unique_lock<std::mutex> mtx_lock(mtx);
|
||||||
#else
|
|
||||||
pthread_mutex_lock(&mutex);
|
|
||||||
#endif
|
|
||||||
parameters = params;
|
parameters = params;
|
||||||
#ifndef USE_STD_THREADS
|
|
||||||
pthread_mutex_unlock(&mutex);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void init()
|
inline void init()
|
||||||
{
|
{
|
||||||
#ifdef USE_STD_THREADS
|
|
||||||
std::unique_lock<std::mutex> mtx_lock(mtx);
|
std::unique_lock<std::mutex> mtx_lock(mtx);
|
||||||
#else
|
|
||||||
pthread_mutex_lock(&mutex);
|
|
||||||
#endif
|
|
||||||
stateThread = STATE_THREAD_STOPPED;
|
stateThread = STATE_THREAD_STOPPED;
|
||||||
isObjectDetectingReady = false;
|
isObjectDetectingReady = false;
|
||||||
shouldObjectDetectingResultsBeForgot = false;
|
shouldObjectDetectingResultsBeForgot = false;
|
||||||
#ifdef USE_STD_THREADS
|
|
||||||
objectDetectorThreadStartStop.notify_one();
|
objectDetectorThreadStartStop.notify_one();
|
||||||
#else
|
|
||||||
pthread_cond_signal(&(objectDetectorThreadStartStop));
|
|
||||||
pthread_mutex_unlock(&mutex);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
DetectionBasedTracker& detectionBasedTracker;
|
DetectionBasedTracker& detectionBasedTracker;
|
||||||
cv::Ptr<DetectionBasedTracker::IDetector> cascadeInThread;
|
cv::Ptr<DetectionBasedTracker::IDetector> cascadeInThread;
|
||||||
#ifdef USE_STD_THREADS
|
|
||||||
std::thread second_workthread;
|
std::thread second_workthread;
|
||||||
std::mutex mtx;
|
std::mutex mtx;
|
||||||
std::condition_variable objectDetectorRun;
|
std::condition_variable objectDetectorRun;
|
||||||
std::condition_variable objectDetectorThreadStartStop;
|
std::condition_variable objectDetectorThreadStartStop;
|
||||||
#else
|
|
||||||
pthread_t second_workthread;
|
|
||||||
pthread_mutex_t mutex;
|
|
||||||
pthread_cond_t objectDetectorRun;
|
|
||||||
pthread_cond_t objectDetectorThreadStartStop;
|
|
||||||
#endif
|
|
||||||
std::vector<cv::Rect> resultDetect;
|
std::vector<cv::Rect> resultDetect;
|
||||||
volatile bool isObjectDetectingReady;
|
volatile bool isObjectDetectingReady;
|
||||||
volatile bool shouldObjectDetectingResultsBeForgot;
|
volatile bool shouldObjectDetectingResultsBeForgot;
|
||||||
@ -217,28 +183,6 @@ cv::DetectionBasedTracker::SeparateDetectionWork::SeparateDetectionWork(Detectio
|
|||||||
CV_Assert(_detector);
|
CV_Assert(_detector);
|
||||||
|
|
||||||
cascadeInThread = _detector;
|
cascadeInThread = _detector;
|
||||||
#ifndef USE_STD_THREADS
|
|
||||||
second_workthread = 0;
|
|
||||||
int res=0;
|
|
||||||
res=pthread_mutex_init(&mutex, NULL);//TODO: should be attributes?
|
|
||||||
if (res) {
|
|
||||||
LOGE("ERROR in DetectionBasedTracker::SeparateDetectionWork::SeparateDetectionWork in pthread_mutex_init(&mutex, NULL) is %d", res);
|
|
||||||
throw(std::exception());
|
|
||||||
}
|
|
||||||
res=pthread_cond_init (&objectDetectorRun, NULL);
|
|
||||||
if (res) {
|
|
||||||
LOGE("ERROR in DetectionBasedTracker::SeparateDetectionWork::SeparateDetectionWork in pthread_cond_init(&objectDetectorRun,, NULL) is %d", res);
|
|
||||||
pthread_mutex_destroy(&mutex);
|
|
||||||
throw(std::exception());
|
|
||||||
}
|
|
||||||
res=pthread_cond_init (&objectDetectorThreadStartStop, NULL);
|
|
||||||
if (res) {
|
|
||||||
LOGE("ERROR in DetectionBasedTracker::SeparateDetectionWork::SeparateDetectionWork in pthread_cond_init(&objectDetectorThreadStartStop,, NULL) is %d", res);
|
|
||||||
pthread_cond_destroy(&objectDetectorRun);
|
|
||||||
pthread_mutex_destroy(&mutex);
|
|
||||||
throw(std::exception());
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
cv::DetectionBasedTracker::SeparateDetectionWork::~SeparateDetectionWork()
|
cv::DetectionBasedTracker::SeparateDetectionWork::~SeparateDetectionWork()
|
||||||
@ -246,39 +190,20 @@ cv::DetectionBasedTracker::SeparateDetectionWork::~SeparateDetectionWork()
|
|||||||
if(stateThread!=STATE_THREAD_STOPPED) {
|
if(stateThread!=STATE_THREAD_STOPPED) {
|
||||||
LOGE("\n\n\nATTENTION!!! dangerous algorithm error: destructor DetectionBasedTracker::DetectionBasedTracker::~SeparateDetectionWork is called before stopping the workthread");
|
LOGE("\n\n\nATTENTION!!! dangerous algorithm error: destructor DetectionBasedTracker::DetectionBasedTracker::~SeparateDetectionWork is called before stopping the workthread");
|
||||||
}
|
}
|
||||||
#ifndef USE_STD_THREADS
|
|
||||||
pthread_cond_destroy(&objectDetectorThreadStartStop);
|
|
||||||
pthread_cond_destroy(&objectDetectorRun);
|
|
||||||
pthread_mutex_destroy(&mutex);
|
|
||||||
#else
|
|
||||||
second_workthread.join();
|
second_workthread.join();
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
bool cv::DetectionBasedTracker::SeparateDetectionWork::run()
|
bool cv::DetectionBasedTracker::SeparateDetectionWork::run()
|
||||||
{
|
{
|
||||||
LOGD("DetectionBasedTracker::SeparateDetectionWork::run() --- start");
|
LOGD("DetectionBasedTracker::SeparateDetectionWork::run() --- start");
|
||||||
#ifdef USE_STD_THREADS
|
|
||||||
std::unique_lock<std::mutex> mtx_lock(mtx);
|
std::unique_lock<std::mutex> mtx_lock(mtx);
|
||||||
// unlocked when leaving scope
|
// unlocked when leaving scope
|
||||||
#else
|
|
||||||
pthread_mutex_lock(&mutex);
|
|
||||||
#endif
|
|
||||||
if (stateThread != STATE_THREAD_STOPPED) {
|
if (stateThread != STATE_THREAD_STOPPED) {
|
||||||
LOGE("DetectionBasedTracker::SeparateDetectionWork::run is called while the previous run is not stopped");
|
LOGE("DetectionBasedTracker::SeparateDetectionWork::run is called while the previous run is not stopped");
|
||||||
#ifndef USE_STD_THREADS
|
|
||||||
pthread_mutex_unlock(&mutex);
|
|
||||||
#endif
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
stateThread=STATE_THREAD_WORKING_SLEEPING;
|
stateThread=STATE_THREAD_WORKING_SLEEPING;
|
||||||
#ifdef USE_STD_THREADS
|
|
||||||
second_workthread = std::thread(workcycleObjectDetectorFunction, (void*)this); //TODO: add attributes?
|
second_workthread = std::thread(workcycleObjectDetectorFunction, (void*)this); //TODO: add attributes?
|
||||||
objectDetectorThreadStartStop.wait(mtx_lock);
|
objectDetectorThreadStartStop.wait(mtx_lock);
|
||||||
#else
|
|
||||||
pthread_create(&second_workthread, NULL, workcycleObjectDetectorFunction, (void*)this); //TODO: add attributes?
|
|
||||||
pthread_cond_wait(&objectDetectorThreadStartStop, &mutex);
|
|
||||||
pthread_mutex_unlock(&mutex);
|
|
||||||
#endif
|
|
||||||
LOGD("DetectionBasedTracker::SeparateDetectionWork::run --- end");
|
LOGD("DetectionBasedTracker::SeparateDetectionWork::run --- end");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -313,34 +238,18 @@ void cv::DetectionBasedTracker::SeparateDetectionWork::workcycleObjectDetector()
|
|||||||
std::vector<Rect> objects;
|
std::vector<Rect> objects;
|
||||||
|
|
||||||
CV_Assert(stateThread==STATE_THREAD_WORKING_SLEEPING);
|
CV_Assert(stateThread==STATE_THREAD_WORKING_SLEEPING);
|
||||||
#ifdef USE_STD_THREADS
|
|
||||||
std::unique_lock<std::mutex> mtx_lock(mtx);
|
std::unique_lock<std::mutex> mtx_lock(mtx);
|
||||||
#else
|
|
||||||
pthread_mutex_lock(&mutex);
|
|
||||||
#endif
|
|
||||||
{
|
{
|
||||||
#ifdef USE_STD_THREADS
|
|
||||||
objectDetectorThreadStartStop.notify_one();
|
objectDetectorThreadStartStop.notify_one();
|
||||||
#else
|
|
||||||
pthread_cond_signal(&objectDetectorThreadStartStop);
|
|
||||||
#endif
|
|
||||||
LOGD("DetectionBasedTracker::SeparateDetectionWork::workcycleObjectDetector() --- before waiting");
|
LOGD("DetectionBasedTracker::SeparateDetectionWork::workcycleObjectDetector() --- before waiting");
|
||||||
CV_Assert(stateThread==STATE_THREAD_WORKING_SLEEPING);
|
CV_Assert(stateThread==STATE_THREAD_WORKING_SLEEPING);
|
||||||
#ifdef USE_STD_THREADS
|
|
||||||
objectDetectorRun.wait(mtx_lock);
|
objectDetectorRun.wait(mtx_lock);
|
||||||
#else
|
|
||||||
pthread_cond_wait(&objectDetectorRun, &mutex);
|
|
||||||
#endif
|
|
||||||
if (isWorking()) {
|
if (isWorking()) {
|
||||||
stateThread=STATE_THREAD_WORKING_WITH_IMAGE;
|
stateThread=STATE_THREAD_WORKING_WITH_IMAGE;
|
||||||
}
|
}
|
||||||
LOGD("DetectionBasedTracker::SeparateDetectionWork::workcycleObjectDetector() --- after waiting");
|
LOGD("DetectionBasedTracker::SeparateDetectionWork::workcycleObjectDetector() --- after waiting");
|
||||||
}
|
}
|
||||||
#ifdef USE_STD_THREADS
|
|
||||||
mtx_lock.unlock();
|
mtx_lock.unlock();
|
||||||
#else
|
|
||||||
pthread_mutex_unlock(&mutex);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
bool isFirstStep=true;
|
bool isFirstStep=true;
|
||||||
|
|
||||||
@ -353,34 +262,18 @@ void cv::DetectionBasedTracker::SeparateDetectionWork::workcycleObjectDetector()
|
|||||||
if (! isFirstStep) {
|
if (! isFirstStep) {
|
||||||
LOGD("DetectionBasedTracker::SeparateDetectionWork::workcycleObjectDetector() --- before waiting");
|
LOGD("DetectionBasedTracker::SeparateDetectionWork::workcycleObjectDetector() --- before waiting");
|
||||||
CV_Assert(stateThread==STATE_THREAD_WORKING_SLEEPING);
|
CV_Assert(stateThread==STATE_THREAD_WORKING_SLEEPING);
|
||||||
#ifdef USE_STD_THREADS
|
|
||||||
mtx_lock.lock();
|
mtx_lock.lock();
|
||||||
#else
|
|
||||||
pthread_mutex_lock(&mutex);
|
|
||||||
#endif
|
|
||||||
if (!isWorking()) {//it is a rare case, but may cause a crash
|
if (!isWorking()) {//it is a rare case, but may cause a crash
|
||||||
LOGD("DetectionBasedTracker::SeparateDetectionWork::workcycleObjectDetector() --- go out from the workcycle from inner part of lock just before waiting");
|
LOGD("DetectionBasedTracker::SeparateDetectionWork::workcycleObjectDetector() --- go out from the workcycle from inner part of lock just before waiting");
|
||||||
#ifdef USE_STD_THREADS
|
|
||||||
mtx_lock.unlock();
|
mtx_lock.unlock();
|
||||||
#else
|
|
||||||
pthread_mutex_unlock(&mutex);
|
|
||||||
#endif
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
CV_Assert(stateThread==STATE_THREAD_WORKING_SLEEPING);
|
CV_Assert(stateThread==STATE_THREAD_WORKING_SLEEPING);
|
||||||
#ifdef USE_STD_THREADS
|
|
||||||
objectDetectorRun.wait(mtx_lock);
|
objectDetectorRun.wait(mtx_lock);
|
||||||
#else
|
|
||||||
pthread_cond_wait(&objectDetectorRun, &mutex);
|
|
||||||
#endif
|
|
||||||
if (isWorking()) {
|
if (isWorking()) {
|
||||||
stateThread=STATE_THREAD_WORKING_WITH_IMAGE;
|
stateThread=STATE_THREAD_WORKING_WITH_IMAGE;
|
||||||
}
|
}
|
||||||
#ifdef USE_STD_THREADS
|
|
||||||
mtx_lock.unlock();
|
mtx_lock.unlock();
|
||||||
#else
|
|
||||||
pthread_mutex_unlock(&mutex);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
LOGD("DetectionBasedTracker::SeparateDetectionWork::workcycleObjectDetector() --- after waiting");
|
LOGD("DetectionBasedTracker::SeparateDetectionWork::workcycleObjectDetector() --- after waiting");
|
||||||
} else {
|
} else {
|
||||||
@ -427,11 +320,7 @@ void cv::DetectionBasedTracker::SeparateDetectionWork::workcycleObjectDetector()
|
|||||||
(void)(dt_detect_ms);
|
(void)(dt_detect_ms);
|
||||||
|
|
||||||
LOGI("DetectionBasedTracker::SeparateDetectionWork::workcycleObjectDetector() --- objects num==%d, t_ms=%.4f", (int)objects.size(), dt_detect_ms);
|
LOGI("DetectionBasedTracker::SeparateDetectionWork::workcycleObjectDetector() --- objects num==%d, t_ms=%.4f", (int)objects.size(), dt_detect_ms);
|
||||||
#ifdef USE_STD_THREADS
|
|
||||||
mtx_lock.lock();
|
mtx_lock.lock();
|
||||||
#else
|
|
||||||
pthread_mutex_lock(&mutex);
|
|
||||||
#endif
|
|
||||||
if (!shouldObjectDetectingResultsBeForgot) {
|
if (!shouldObjectDetectingResultsBeForgot) {
|
||||||
resultDetect=objects;
|
resultDetect=objects;
|
||||||
isObjectDetectingReady=true;
|
isObjectDetectingReady=true;
|
||||||
@ -443,11 +332,7 @@ void cv::DetectionBasedTracker::SeparateDetectionWork::workcycleObjectDetector()
|
|||||||
if(isWorking()) {
|
if(isWorking()) {
|
||||||
stateThread=STATE_THREAD_WORKING_SLEEPING;
|
stateThread=STATE_THREAD_WORKING_SLEEPING;
|
||||||
}
|
}
|
||||||
#ifdef USE_STD_THREADS
|
|
||||||
mtx_lock.unlock();
|
mtx_lock.unlock();
|
||||||
#else
|
|
||||||
pthread_mutex_unlock(&mutex);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
objects.clear();
|
objects.clear();
|
||||||
}// while(isWorking())
|
}// while(isWorking())
|
||||||
@ -458,44 +343,25 @@ void cv::DetectionBasedTracker::SeparateDetectionWork::workcycleObjectDetector()
|
|||||||
void cv::DetectionBasedTracker::SeparateDetectionWork::stop()
|
void cv::DetectionBasedTracker::SeparateDetectionWork::stop()
|
||||||
{
|
{
|
||||||
//FIXME: TODO: should add quickStop functionality
|
//FIXME: TODO: should add quickStop functionality
|
||||||
#ifdef USE_STD_THREADS
|
|
||||||
std::unique_lock<std::mutex> mtx_lock(mtx);
|
std::unique_lock<std::mutex> mtx_lock(mtx);
|
||||||
#else
|
|
||||||
pthread_mutex_lock(&mutex);
|
|
||||||
#endif
|
|
||||||
if (!isWorking()) {
|
if (!isWorking()) {
|
||||||
#ifdef USE_STD_THREADS
|
|
||||||
mtx_lock.unlock();
|
mtx_lock.unlock();
|
||||||
#else
|
|
||||||
pthread_mutex_unlock(&mutex);
|
|
||||||
#endif
|
|
||||||
LOGE("SimpleHighguiDemoCore::stop is called but the SimpleHighguiDemoCore pthread is not active");
|
LOGE("SimpleHighguiDemoCore::stop is called but the SimpleHighguiDemoCore pthread is not active");
|
||||||
stateThread = STATE_THREAD_STOPPING;
|
stateThread = STATE_THREAD_STOPPING;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
stateThread=STATE_THREAD_STOPPING;
|
stateThread=STATE_THREAD_STOPPING;
|
||||||
LOGD("DetectionBasedTracker::SeparateDetectionWork::stop: before going to sleep to wait for the signal from the workthread");
|
LOGD("DetectionBasedTracker::SeparateDetectionWork::stop: before going to sleep to wait for the signal from the workthread");
|
||||||
#ifdef USE_STD_THREADS
|
|
||||||
objectDetectorRun.notify_one();
|
objectDetectorRun.notify_one();
|
||||||
objectDetectorThreadStartStop.wait(mtx_lock);
|
objectDetectorThreadStartStop.wait(mtx_lock);
|
||||||
LOGD("DetectionBasedTracker::SeparateDetectionWork::stop: after receiving the signal from the workthread, stateThread=%d", (int)stateThread);
|
LOGD("DetectionBasedTracker::SeparateDetectionWork::stop: after receiving the signal from the workthread, stateThread=%d", (int)stateThread);
|
||||||
mtx_lock.unlock();
|
mtx_lock.unlock();
|
||||||
#else
|
|
||||||
pthread_cond_signal(&objectDetectorRun);
|
|
||||||
pthread_cond_wait(&objectDetectorThreadStartStop, &mutex);
|
|
||||||
LOGD("DetectionBasedTracker::SeparateDetectionWork::stop: after receiving the signal from the workthread, stateThread=%d", (int)stateThread);
|
|
||||||
pthread_mutex_unlock(&mutex);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void cv::DetectionBasedTracker::SeparateDetectionWork::resetTracking()
|
void cv::DetectionBasedTracker::SeparateDetectionWork::resetTracking()
|
||||||
{
|
{
|
||||||
LOGD("DetectionBasedTracker::SeparateDetectionWork::resetTracking");
|
LOGD("DetectionBasedTracker::SeparateDetectionWork::resetTracking");
|
||||||
#ifdef USE_STD_THREADS
|
|
||||||
std::unique_lock<std::mutex> mtx_lock(mtx);
|
std::unique_lock<std::mutex> mtx_lock(mtx);
|
||||||
#else
|
|
||||||
pthread_mutex_lock(&mutex);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (stateThread == STATE_THREAD_WORKING_WITH_IMAGE) {
|
if (stateThread == STATE_THREAD_WORKING_WITH_IMAGE) {
|
||||||
LOGD("DetectionBasedTracker::SeparateDetectionWork::resetTracking: since workthread is detecting objects at the moment, we should make cascadeInThread stop detecting and forget the detecting results");
|
LOGD("DetectionBasedTracker::SeparateDetectionWork::resetTracking: since workthread is detecting objects at the moment, we should make cascadeInThread stop detecting and forget the detecting results");
|
||||||
@ -508,12 +374,7 @@ void cv::DetectionBasedTracker::SeparateDetectionWork::resetTracking()
|
|||||||
resultDetect.clear();
|
resultDetect.clear();
|
||||||
isObjectDetectingReady=false;
|
isObjectDetectingReady=false;
|
||||||
|
|
||||||
#ifdef USE_STD_THREADS
|
|
||||||
mtx_lock.unlock();
|
mtx_lock.unlock();
|
||||||
#else
|
|
||||||
pthread_mutex_unlock(&mutex);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool cv::DetectionBasedTracker::SeparateDetectionWork::communicateWithDetectingThread(const Mat& imageGray, std::vector<Rect>& rectsWhereRegions)
|
bool cv::DetectionBasedTracker::SeparateDetectionWork::communicateWithDetectingThread(const Mat& imageGray, std::vector<Rect>& rectsWhereRegions)
|
||||||
@ -529,11 +390,7 @@ bool cv::DetectionBasedTracker::SeparateDetectionWork::communicateWithDetectingT
|
|||||||
|
|
||||||
bool shouldHandleResult = false;
|
bool shouldHandleResult = false;
|
||||||
|
|
||||||
#ifdef USE_STD_THREADS
|
|
||||||
std::unique_lock<std::mutex> mtx_lock(mtx);
|
std::unique_lock<std::mutex> mtx_lock(mtx);
|
||||||
#else
|
|
||||||
pthread_mutex_lock(&mutex);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (isObjectDetectingReady) {
|
if (isObjectDetectingReady) {
|
||||||
shouldHandleResult=true;
|
shouldHandleResult=true;
|
||||||
@ -562,18 +419,10 @@ bool cv::DetectionBasedTracker::SeparateDetectionWork::communicateWithDetectingT
|
|||||||
|
|
||||||
timeWhenDetectingThreadStartedWork = getTickCount() ;
|
timeWhenDetectingThreadStartedWork = getTickCount() ;
|
||||||
|
|
||||||
#ifdef USE_STD_THREADS
|
|
||||||
objectDetectorRun.notify_one();
|
objectDetectorRun.notify_one();
|
||||||
#else
|
|
||||||
pthread_cond_signal(&objectDetectorRun);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef USE_STD_THREADS
|
|
||||||
mtx_lock.unlock();
|
mtx_lock.unlock();
|
||||||
#else
|
|
||||||
pthread_mutex_unlock(&mutex);
|
|
||||||
#endif
|
|
||||||
LOGD("DetectionBasedTracker::SeparateDetectionWork::communicateWithDetectingThread: result: shouldHandleResult=%d", (shouldHandleResult?1:0));
|
LOGD("DetectionBasedTracker::SeparateDetectionWork::communicateWithDetectingThread: result: shouldHandleResult=%d", (shouldHandleResult?1:0));
|
||||||
|
|
||||||
return shouldHandleResult;
|
return shouldHandleResult;
|
||||||
@ -1034,5 +883,3 @@ const cv::DetectionBasedTracker::Parameters& DetectionBasedTracker::getParameter
|
|||||||
{
|
{
|
||||||
return parameters;
|
return parameters;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif //defined(__linux__) || defined(LINUX) || defined(__APPLE__) || defined(__ANDROID__) || defined(USE_STD_THREADS)
|
|
||||||
|
@ -706,11 +706,7 @@ namespace comparators
|
|||||||
{
|
{
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
#ifdef CV_CXX11
|
|
||||||
struct RectLess_
|
struct RectLess_
|
||||||
#else
|
|
||||||
struct RectLess_ : public std::binary_function<cv::Rect_<T>, cv::Rect_<T>, bool>
|
|
||||||
#endif
|
|
||||||
{
|
{
|
||||||
bool operator()(const cv::Rect_<T>& r1, const cv::Rect_<T>& r2) const
|
bool operator()(const cv::Rect_<T>& r1, const cv::Rect_<T>& r2) const
|
||||||
{
|
{
|
||||||
@ -723,11 +719,7 @@ struct RectLess_ : public std::binary_function<cv::Rect_<T>, cv::Rect_<T>, bool>
|
|||||||
|
|
||||||
typedef RectLess_<int> RectLess;
|
typedef RectLess_<int> RectLess;
|
||||||
|
|
||||||
#ifdef CV_CXX11
|
|
||||||
struct KeypointGreater
|
struct KeypointGreater
|
||||||
#else
|
|
||||||
struct KeypointGreater : public std::binary_function<cv::KeyPoint, cv::KeyPoint, bool>
|
|
||||||
#endif
|
|
||||||
{
|
{
|
||||||
bool operator()(const cv::KeyPoint& kp1, const cv::KeyPoint& kp2) const
|
bool operator()(const cv::KeyPoint& kp1, const cv::KeyPoint& kp2) const
|
||||||
{
|
{
|
||||||
|
@ -462,11 +462,7 @@ namespace cvtest
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef CV_CXX11
|
|
||||||
struct KeyPointLess
|
struct KeyPointLess
|
||||||
#else
|
|
||||||
struct KeyPointLess : std::binary_function<cv::KeyPoint, cv::KeyPoint, bool>
|
|
||||||
#endif
|
|
||||||
{
|
{
|
||||||
bool operator()(const cv::KeyPoint& kp1, const cv::KeyPoint& kp2) const
|
bool operator()(const cv::KeyPoint& kp1, const cv::KeyPoint& kp2) const
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user