Merge origin/master into cuda-dev
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
#ifdef __GNUC__
|
||||
# pragma GCC diagnostic ignored "-Wmissing-declarations"
|
||||
# ifdef __clang__
|
||||
# if defined __clang__ || defined __APPLE__
|
||||
# pragma GCC diagnostic ignored "-Wmissing-prototypes"
|
||||
# pragma GCC diagnostic ignored "-Wextra"
|
||||
# endif
|
||||
|
@@ -1,6 +1,6 @@
|
||||
#ifdef __GNUC__
|
||||
# pragma GCC diagnostic ignored "-Wmissing-declarations"
|
||||
# ifdef __clang__
|
||||
# if defined __clang__ || defined __APPLE__
|
||||
# pragma GCC diagnostic ignored "-Wmissing-prototypes"
|
||||
# pragma GCC diagnostic ignored "-Wextra"
|
||||
# endif
|
||||
|
@@ -583,7 +583,7 @@ namespace cv
|
||||
virtual ~StereoVar();
|
||||
|
||||
//! the stereo correspondence operator that computes disparity map for the specified rectified stereo pair
|
||||
CV_WRAP_AS(compute) virtual void operator()(const Mat& left, const Mat& right, Mat& disp);
|
||||
CV_WRAP_AS(compute) virtual void operator()(const Mat& left, const Mat& right, CV_OUT Mat& disp);
|
||||
|
||||
CV_PROP_RW int levels;
|
||||
CV_PROP_RW double pyrScale;
|
||||
|
@@ -1,6 +1,8 @@
|
||||
#if defined(__linux__) || defined(LINUX) || defined(__APPLE__) || defined(ANDROID)
|
||||
#include "opencv2/contrib/detection_based_tracker.hpp"
|
||||
|
||||
#include <pthread.h>
|
||||
|
||||
#if defined(DEBUG) || defined(_DEBUG)
|
||||
#undef DEBUGLOGS
|
||||
#define DEBUGLOGS 1
|
||||
@@ -12,7 +14,6 @@
|
||||
|
||||
#ifdef ANDROID
|
||||
#include <android/log.h>
|
||||
#include <pthread.h>
|
||||
#define LOG_TAG "OBJECT_DETECTOR"
|
||||
#define LOGD0(...) ((void)__android_log_print(ANDROID_LOG_DEBUG, LOG_TAG, __VA_ARGS__))
|
||||
#define LOGI0(...) ((void)__android_log_print(ANDROID_LOG_INFO, LOG_TAG, __VA_ARGS__))
|
||||
|
@@ -300,7 +300,13 @@ public:
|
||||
//------------------------------------------------------------------------------
|
||||
// FaceRecognizer
|
||||
//------------------------------------------------------------------------------
|
||||
void FaceRecognizer::update(InputArrayOfArrays, InputArray) {
|
||||
void FaceRecognizer::update(InputArrayOfArrays src, InputArray labels ) {
|
||||
if( dynamic_cast<LBPH*>(this) != 0 )
|
||||
{
|
||||
dynamic_cast<LBPH*>(this)->update( src, labels );
|
||||
return;
|
||||
}
|
||||
|
||||
string error_msg = format("This FaceRecognizer (%s) does not support updating, you have to use FaceRecognizer::train to update it.", this->name().c_str());
|
||||
CV_Error(CV_StsNotImplemented, error_msg);
|
||||
}
|
||||
|
@@ -1,6 +1,6 @@
|
||||
#ifdef __GNUC__
|
||||
# pragma GCC diagnostic ignored "-Wmissing-declarations"
|
||||
# ifdef __clang__
|
||||
# if defined __clang__ || defined __APPLE__
|
||||
# pragma GCC diagnostic ignored "-Wmissing-prototypes"
|
||||
# pragma GCC diagnostic ignored "-Wextra"
|
||||
# endif
|
||||
|
@@ -204,11 +204,11 @@ CV_EXPORTS ErrorCallback redirectError( ErrorCallback errCallback,
|
||||
#ifdef __GNUC__
|
||||
#define CV_Error( code, msg ) cv::error( cv::Exception(code, msg, __func__, __FILE__, __LINE__) )
|
||||
#define CV_Error_( code, args ) cv::error( cv::Exception(code, cv::format args, __func__, __FILE__, __LINE__) )
|
||||
#define CV_Assert( expr ) if((expr)) ; else cv::error( cv::Exception(CV_StsAssert, #expr, __func__, __FILE__, __LINE__) )
|
||||
#define CV_Assert( expr ) if(!!(expr)) ; else cv::error( cv::Exception(CV_StsAssert, #expr, __func__, __FILE__, __LINE__) )
|
||||
#else
|
||||
#define CV_Error( code, msg ) cv::error( cv::Exception(code, msg, "", __FILE__, __LINE__) )
|
||||
#define CV_Error_( code, args ) cv::error( cv::Exception(code, cv::format args, "", __FILE__, __LINE__) )
|
||||
#define CV_Assert( expr ) if((expr)) ; else cv::error( cv::Exception(CV_StsAssert, #expr, "", __FILE__, __LINE__) )
|
||||
#define CV_Assert( expr ) if(!!(expr)) ; else cv::error( cv::Exception(CV_StsAssert, #expr, "", __FILE__, __LINE__) )
|
||||
#endif
|
||||
|
||||
#ifdef _DEBUG
|
||||
|
@@ -56,7 +56,7 @@
|
||||
#define CV_XADD(addr,delta) _InterlockedExchangeAdd(const_cast<void*>(reinterpret_cast<volatile void*>(addr)), delta)
|
||||
#elif defined __GNUC__
|
||||
|
||||
#if defined __clang__ && __clang_major__ >= 3
|
||||
#if defined __clang__ && __clang_major__ >= 3 && !defined __ANDROID__
|
||||
#ifdef __ATOMIC_SEQ_CST
|
||||
#define CV_XADD(addr, delta) __c11_atomic_fetch_add((_Atomic(int)*)(addr), (delta), __ATOMIC_SEQ_CST)
|
||||
#else
|
||||
@@ -3873,10 +3873,21 @@ template<typename _Tp> inline std::ostream& operator<<(std::ostream& out, const
|
||||
template<typename _Tp, int n> inline std::ostream& operator<<(std::ostream& out, const Vec<_Tp, n>& vec)
|
||||
{
|
||||
out << "[";
|
||||
for (int i = 0; i < n - 1; ++i) {
|
||||
out << vec[i] << ", ";
|
||||
|
||||
if(Vec<_Tp, n>::depth < CV_32F)
|
||||
{
|
||||
for (int i = 0; i < n - 1; ++i) {
|
||||
out << (int)vec[i] << ", ";
|
||||
}
|
||||
out << (int)vec[n-1] << "]";
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int i = 0; i < n - 1; ++i) {
|
||||
out << vec[i] << ", ";
|
||||
}
|
||||
out << vec[n-1] << "]";
|
||||
}
|
||||
out << vec[n-1] << "]";
|
||||
|
||||
return out;
|
||||
}
|
||||
|
@@ -1,6 +1,6 @@
|
||||
#ifdef __GNUC__
|
||||
# pragma GCC diagnostic ignored "-Wmissing-declarations"
|
||||
# ifdef __clang__
|
||||
# if defined __clang__ || defined __APPLE__
|
||||
# pragma GCC diagnostic ignored "-Wmissing-prototypes"
|
||||
# pragma GCC diagnostic ignored "-Wextra"
|
||||
# endif
|
||||
|
@@ -954,7 +954,7 @@ double cv::invert( InputArray _src, OutputArray _dst, int method )
|
||||
size_t esz = CV_ELEM_SIZE(type);
|
||||
int m = src.rows, n = src.cols;
|
||||
|
||||
if( method == DECOMP_SVD )
|
||||
if( method == DECOMP_SVD )
|
||||
{
|
||||
int nm = std::min(m, n);
|
||||
|
||||
@@ -1101,62 +1101,21 @@ double cv::invert( InputArray _src, OutputArray _dst, int method )
|
||||
|
||||
result = true;
|
||||
d = 1./d;
|
||||
#if CV_SSE2
|
||||
if(USE_SSE2)
|
||||
{
|
||||
__m128 det =_mm_set1_ps((float)d);
|
||||
__m128 s0 = _mm_loadu_ps((const float*)srcdata);//s0 = Sf(0,0) Sf(0,1) Sf(0,2) ***
|
||||
__m128 s1 = _mm_loadu_ps((const float*)(srcdata+srcstep));//s1 = Sf(1,0) Sf(1,1) Sf(1,2) ***
|
||||
__m128 s2 = _mm_set_ps(0.f, Sf(2,2), Sf(2,1), Sf(2,0)); //s2 = Sf(2,0) Sf(2,1) Sf(2,2) ***
|
||||
t[0] = (float)(((double)Sf(1,1) * Sf(2,2) - (double)Sf(1,2) * Sf(2,1)) * d);
|
||||
t[1] = (float)(((double)Sf(0,2) * Sf(2,1) - (double)Sf(0,1) * Sf(2,2)) * d);
|
||||
t[2] = (float)(((double)Sf(0,1) * Sf(1,2) - (double)Sf(0,2) * Sf(1,1)) * d);
|
||||
|
||||
__m128 r0 = _mm_shuffle_ps(s1,s1,_MM_SHUFFLE(3,0,2,1)); //r0 = Sf(1,1) Sf(1,2) Sf(1,0) ***
|
||||
__m128 r1 = _mm_shuffle_ps(s2,s2,_MM_SHUFFLE(3,1,0,2)); //r1 = Sf(2,2) Sf(2,0) Sf(2,1) ***
|
||||
__m128 r2 = _mm_shuffle_ps(s2,s2,_MM_SHUFFLE(3,0,2,1)); //r2 = Sf(2,1) Sf(2,2) Sf(2,0) ***
|
||||
t[3] = (float)(((double)Sf(1,2) * Sf(2,0) - (double)Sf(1,0) * Sf(2,2)) * d);
|
||||
t[4] = (float)(((double)Sf(0,0) * Sf(2,2) - (double)Sf(0,2) * Sf(2,0)) * d);
|
||||
t[5] = (float)(((double)Sf(0,2) * Sf(1,0) - (double)Sf(0,0) * Sf(1,2)) * d);
|
||||
|
||||
__m128 t0 = _mm_mul_ps(s0, r0);//t0 = Sf(0,0)*Sf(1,1) Sf(0,1)*Sf(1,2) Sf(0,2)*Sf(1,0) ***
|
||||
__m128 t1 = _mm_mul_ps(s0, r1);//t1 = Sf(0,0)*Sf(2,2) Sf(0,1)*Sf(2,0) Sf(0,2)*Sf(2,1) ***
|
||||
__m128 t2 = _mm_mul_ps(s1, r2);//t2 = Sf(1,0)*Sf(2,1) Sf(1,1)*Sf(2,2) Sf(1,2)*Sf(2,0) ***
|
||||
t[6] = (float)(((double)Sf(1,0) * Sf(2,1) - (double)Sf(1,1) * Sf(2,0)) * d);
|
||||
t[7] = (float)(((double)Sf(0,1) * Sf(2,0) - (double)Sf(0,0) * Sf(2,1)) * d);
|
||||
t[8] = (float)(((double)Sf(0,0) * Sf(1,1) - (double)Sf(0,1) * Sf(1,0)) * d);
|
||||
|
||||
__m128 r3 = _mm_shuffle_ps(s0,s0,_MM_SHUFFLE(3,0,2,1));//r3 = Sf(0,1) Sf(0,2) Sf(0,0) ***
|
||||
__m128 r4 = _mm_shuffle_ps(s0,s0,_MM_SHUFFLE(3,1,0,2));//r4 = Sf(0,2) Sf(0,0) Sf(0,1) ***
|
||||
|
||||
__m128 t00 = _mm_mul_ps(s1, r3);//t00 = Sf(1,0)*Sf(0,1) Sf(1,1)*Sf(0,2) Sf(1,2)*Sf(0,0) ***
|
||||
__m128 t11 = _mm_mul_ps(s2, r4);//t11 = Sf(2,0)*Sf(0,2) Sf(2,1)*Sf(0,0) Sf(2,2)*Sf(0,1) ***
|
||||
__m128 t22 = _mm_mul_ps(s2, r0);//t22 = Sf(2,0)*Sf(1,1) Sf(2,1)*Sf(1,2) Sf(2,2)*Sf(1,0) ***
|
||||
|
||||
t0 = _mm_mul_ps(_mm_sub_ps(t0,t00), det);//Sf(0,0)*Sf(1,1) Sf(0,1)*Sf(1,2) Sf(0,2)*Sf(1,0) ***
|
||||
//-Sf(1,0)*Sf(0,1) -Sf(1,1)*Sf(0,2) -Sf(1,2)*Sf(0,0)
|
||||
t1 = _mm_mul_ps(_mm_sub_ps(t1,t11), det);//Sf(0,0)*Sf(2,2) Sf(0,1)*Sf(2,0) Sf(0,2)*Sf(2,1) ***
|
||||
//-Sf(2,0)*Sf(0,2) -Sf(2,1)*Sf(0,0) -Sf(2,2)*Sf(0,1)
|
||||
t2 = _mm_mul_ps(_mm_sub_ps(t2,t22), det);//Sf(1,0)*Sf(2,1) Sf(1,1)*Sf(2,2) Sf(1,2)*Sf(2,0) ***
|
||||
//-Sf(2,0)*Sf(1,1) -Sf(2,1)*Sf(1,2) -Sf(2,2)*Sf(1,0)
|
||||
_mm_store_ps(t, t0);
|
||||
_mm_store_ps(t+4, t1);
|
||||
_mm_store_ps(t+8, t2);
|
||||
|
||||
Df(0,0) = t[9]; Df(0,1) = t[6]; Df(0,2) = t[1];
|
||||
Df(1,0) = t[10]; Df(1,1) = t[4]; Df(1,2) = t[2];
|
||||
Df(2,0) = t[8]; Df(2,1) = t[5]; Df(2,2) = t[0];
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
t[0] = (float)(((double)Sf(1,1) * Sf(2,2) - (double)Sf(1,2) * Sf(2,1)) * d);
|
||||
t[1] = (float)(((double)Sf(0,2) * Sf(2,1) - (double)Sf(0,1) * Sf(2,2)) * d);
|
||||
t[2] = (float)(((double)Sf(0,1) * Sf(1,2) - (double)Sf(0,2) * Sf(1,1)) * d);
|
||||
|
||||
t[3] = (float)(((double)Sf(1,2) * Sf(2,0) - (double)Sf(1,0) * Sf(2,2)) * d);
|
||||
t[4] = (float)(((double)Sf(0,0) * Sf(2,2) - (double)Sf(0,2) * Sf(2,0)) * d);
|
||||
t[5] = (float)(((double)Sf(0,2) * Sf(1,0) - (double)Sf(0,0) * Sf(1,2)) * d);
|
||||
|
||||
t[6] = (float)(((double)Sf(1,0) * Sf(2,1) - (double)Sf(1,1) * Sf(2,0)) * d);
|
||||
t[7] = (float)(((double)Sf(0,1) * Sf(2,0) - (double)Sf(0,0) * Sf(2,1)) * d);
|
||||
t[8] = (float)(((double)Sf(0,0) * Sf(1,1) - (double)Sf(0,1) * Sf(1,0)) * d);
|
||||
|
||||
Df(0,0) = t[0]; Df(0,1) = t[1]; Df(0,2) = t[2];
|
||||
Df(1,0) = t[3]; Df(1,1) = t[4]; Df(1,2) = t[5];
|
||||
Df(2,0) = t[6]; Df(2,1) = t[7]; Df(2,2) = t[8];
|
||||
}
|
||||
Df(0,0) = t[0]; Df(0,1) = t[1]; Df(0,2) = t[2];
|
||||
Df(1,0) = t[3]; Df(1,1) = t[4]; Df(1,2) = t[5];
|
||||
Df(2,0) = t[6]; Df(2,1) = t[7]; Df(2,2) = t[8];
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@@ -45,6 +45,14 @@
|
||||
#include "opencv2/core/opengl_interop.hpp"
|
||||
#include "opencv2/core/gpumat.hpp"
|
||||
|
||||
#if defined WIN32 || defined _WIN32 || defined WINCE
|
||||
#include <windows.h>
|
||||
#undef small
|
||||
#undef min
|
||||
#undef max
|
||||
#undef abs
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_OPENGL
|
||||
#ifdef __APPLE__
|
||||
#include <OpenGL/gl.h>
|
||||
|
@@ -863,17 +863,17 @@ template <class ElemType>
|
||||
int calcDiffElemCountImpl(const vector<Mat>& mv, const Mat& m)
|
||||
{
|
||||
int diffElemCount = 0;
|
||||
const size_t mChannels = m.channels();
|
||||
const int mChannels = m.channels();
|
||||
for(int y = 0; y < m.rows; y++)
|
||||
{
|
||||
for(int x = 0; x < m.cols; x++)
|
||||
{
|
||||
const ElemType* mElem = &m.at<ElemType>(y,x*mChannels);
|
||||
size_t loc = 0;
|
||||
int loc = 0;
|
||||
for(size_t i = 0; i < mv.size(); i++)
|
||||
{
|
||||
const size_t mvChannel = mv[i].channels();
|
||||
const ElemType* mvElem = &mv[i].at<ElemType>(y,x*mvChannel);
|
||||
const ElemType* mvElem = &mv[i].at<ElemType>(y,x*(int)mvChannel);
|
||||
for(size_t li = 0; li < mvChannel; li++)
|
||||
if(mElem[loc + li] != mvElem[li])
|
||||
diffElemCount++;
|
||||
@@ -1020,7 +1020,7 @@ public:
|
||||
protected:
|
||||
virtual int run_case(int depth, size_t channels, const Size& size, RNG& rng)
|
||||
{
|
||||
Mat src(size, CV_MAKETYPE(depth, channels));
|
||||
Mat src(size, CV_MAKETYPE(depth, (int)channels));
|
||||
rng.fill(src, RNG::UNIFORM, 0, 100, true);
|
||||
|
||||
vector<Mat> dst;
|
||||
|
@@ -2421,7 +2421,7 @@ protected:
|
||||
}
|
||||
|
||||
Mat diff = abs(anglesInDegrees - resInDeg);
|
||||
int errDegCount = diff.total() - countNonZero((diff < maxAngleDiff) | ((360 - diff) < maxAngleDiff));
|
||||
size_t errDegCount = diff.total() - countNonZero((diff < maxAngleDiff) | ((360 - diff) < maxAngleDiff));
|
||||
if(errDegCount > 0)
|
||||
{
|
||||
ts->printf(cvtest::TS::LOG, "There are incorrect result angles (in degrees) (part of them is %f)\n",
|
||||
@@ -2546,6 +2546,21 @@ REGISTER_TYPED_TEST_CASE_P(Core_CheckRange, Negative, Positive, Bounds, Zero);
|
||||
typedef ::testing::Types<signed char,unsigned char, signed short, unsigned short, signed int> mat_data_types;
|
||||
INSTANTIATE_TYPED_TEST_CASE_P(Negative_Test, Core_CheckRange, mat_data_types);
|
||||
|
||||
TEST(Core_Invert, small)
|
||||
{
|
||||
cv::Mat a = (cv::Mat_<float>(3,3) << 2.42104644730331, 1.81444796521479, -3.98072565304758, 0, 7.08389214348967e-3, 5.55326770986007e-3, 0,0, 7.44556154284261e-3);
|
||||
//cv::randu(a, -1, 1);
|
||||
|
||||
cv::Mat b = a.t()*a;
|
||||
cv::Mat c, i = Mat_<float>::eye(3, 3);
|
||||
cv::invert(b, c, cv::DECOMP_LU); //std::cout << b*c << std::endl;
|
||||
ASSERT_LT( cv::norm(b*c, i, CV_C), 0.1 );
|
||||
cv::invert(b, c, cv::DECOMP_SVD); //std::cout << b*c << std::endl;
|
||||
ASSERT_LT( cv::norm(b*c, i, CV_C), 0.1 );
|
||||
cv::invert(b, c, cv::DECOMP_CHOLESKY); //std::cout << b*c << std::endl;
|
||||
ASSERT_LT( cv::norm(b*c, i, CV_C), 0.1 );
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
TEST(Core_CovarMatrix, accuracy) { Core_CovarMatrixTest test; test.safe_run(); }
|
||||
|
@@ -1,6 +1,6 @@
|
||||
#ifdef __GNUC__
|
||||
# pragma GCC diagnostic ignored "-Wmissing-declarations"
|
||||
# ifdef __clang__
|
||||
# if defined __clang__ || defined __APPLE__
|
||||
# pragma GCC diagnostic ignored "-Wmissing-prototypes"
|
||||
# pragma GCC diagnostic ignored "-Wextra"
|
||||
# endif
|
||||
|
@@ -1,6 +1,6 @@
|
||||
#ifdef __GNUC__
|
||||
# pragma GCC diagnostic ignored "-Wmissing-declarations"
|
||||
# ifdef __clang__
|
||||
# if defined __clang__ || defined __APPLE__
|
||||
# pragma GCC diagnostic ignored "-Wmissing-prototypes"
|
||||
# pragma GCC diagnostic ignored "-Wextra"
|
||||
# endif
|
||||
|
@@ -1,6 +1,6 @@
|
||||
#ifdef __GNUC__
|
||||
# pragma GCC diagnostic ignored "-Wmissing-declarations"
|
||||
# ifdef __clang__
|
||||
# if defined __clang__ || defined __APPLE__
|
||||
# pragma GCC diagnostic ignored "-Wmissing-prototypes"
|
||||
# pragma GCC diagnostic ignored "-Wextra"
|
||||
# endif
|
||||
|
@@ -15,10 +15,10 @@ file(GLOB lib_cuda_hdrs "src/cuda/*.hpp" "src/cuda/*.h")
|
||||
file(GLOB lib_srcs "src/*.cpp")
|
||||
file(GLOB lib_cuda "src/cuda/*.cu*")
|
||||
|
||||
source_group("Include" FILES ${lib_hdrs})
|
||||
source_group("Src\\Host" FILES ${lib_srcs} ${lib_int_hdrs})
|
||||
source_group("Src\\Cuda" FILES ${lib_cuda} ${lib_cuda_hdrs})
|
||||
source_group("Device" FILES ${lib_device_hdrs})
|
||||
source_group("Include" FILES ${lib_hdrs})
|
||||
source_group("Src\\Host" FILES ${lib_srcs} ${lib_int_hdrs})
|
||||
source_group("Src\\Cuda" FILES ${lib_cuda} ${lib_cuda_hdrs})
|
||||
source_group("Device" FILES ${lib_device_hdrs})
|
||||
source_group("Device\\Detail" FILES ${lib_device_hdrs_detail})
|
||||
|
||||
if (HAVE_CUDA)
|
||||
|
@@ -1,6 +1,6 @@
|
||||
#ifdef __GNUC__
|
||||
# pragma GCC diagnostic ignored "-Wmissing-declarations"
|
||||
# ifdef __clang__
|
||||
# if defined __clang__ || defined __APPLE__
|
||||
# pragma GCC diagnostic ignored "-Wmissing-prototypes"
|
||||
# pragma GCC diagnostic ignored "-Wextra"
|
||||
# endif
|
||||
|
@@ -236,7 +236,7 @@ namespace cv { namespace gpu { namespace device
|
||||
const int r = blockIdx.x * blockDim.x + threadIdx.x;
|
||||
const int n = blockIdx.y * blockDim.y + threadIdx.y;
|
||||
|
||||
if (r >= accum.cols - 2 && n >= accum.rows - 2)
|
||||
if (r >= accum.cols - 2 || n >= accum.rows - 2)
|
||||
return;
|
||||
|
||||
const int curVotes = accum(n + 1, r + 1);
|
||||
|
@@ -41,7 +41,7 @@
|
||||
|
||||
#ifdef __GNUC__
|
||||
# pragma GCC diagnostic ignored "-Wmissing-declarations"
|
||||
# ifdef __clang__
|
||||
# if defined __clang__ || defined __APPLE__
|
||||
# pragma GCC diagnostic ignored "-Wmissing-prototypes"
|
||||
# pragma GCC diagnostic ignored "-Wextra"
|
||||
# endif
|
||||
|
@@ -1,6 +1,6 @@
|
||||
#ifdef __GNUC__
|
||||
# pragma GCC diagnostic ignored "-Wmissing-declarations"
|
||||
# ifdef __clang__
|
||||
# if defined __clang__ || defined __APPLE__
|
||||
# pragma GCC diagnostic ignored "-Wmissing-prototypes"
|
||||
# pragma GCC diagnostic ignored "-Wextra"
|
||||
# endif
|
||||
|
@@ -571,6 +571,56 @@ int cv::createButton(const string& button_name, ButtonCallback on_change, void*
|
||||
return cvCreateButton(button_name.c_str(), on_change, userdata, button_type , initial_button_state );
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
CvFont cv::fontQt(const string&, int, Scalar, int, int, int)
|
||||
{
|
||||
CV_Error(CV_StsNotImplemented, "The library is compiled without QT support");
|
||||
return CvFont();
|
||||
}
|
||||
|
||||
void cv::addText( const Mat&, const string&, Point, CvFont)
|
||||
{
|
||||
CV_Error(CV_StsNotImplemented, "The library is compiled without QT support");
|
||||
}
|
||||
|
||||
void cv::displayStatusBar(const string&, const string&, int)
|
||||
{
|
||||
CV_Error(CV_StsNotImplemented, "The library is compiled without QT support");
|
||||
}
|
||||
|
||||
void cv::displayOverlay(const string&, const string&, int )
|
||||
{
|
||||
CV_Error(CV_StsNotImplemented, "The library is compiled without QT support");
|
||||
}
|
||||
|
||||
int cv::startLoop(int (*)(int argc, char *argv[]), int , char**)
|
||||
{
|
||||
CV_Error(CV_StsNotImplemented, "The library is compiled without QT support");
|
||||
return 0;
|
||||
}
|
||||
|
||||
void cv::stopLoop()
|
||||
{
|
||||
CV_Error(CV_StsNotImplemented, "The library is compiled without QT support");
|
||||
}
|
||||
|
||||
void cv::saveWindowParameters(const string&)
|
||||
{
|
||||
CV_Error(CV_StsNotImplemented, "The library is compiled without QT support");
|
||||
}
|
||||
|
||||
void cv::loadWindowParameters(const string&)
|
||||
{
|
||||
CV_Error(CV_StsNotImplemented, "The library is compiled without QT support");
|
||||
}
|
||||
|
||||
int cv::createButton(const string&, ButtonCallback, void*, int , bool )
|
||||
{
|
||||
CV_Error(CV_StsNotImplemented, "The library is compiled without QT support");
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#if defined WIN32 || defined _WIN32 // see window_w32.cpp
|
||||
|
@@ -1,6 +1,6 @@
|
||||
#ifdef __GNUC__
|
||||
# pragma GCC diagnostic ignored "-Wmissing-declarations"
|
||||
# ifdef __clang__
|
||||
# if defined __clang__ || defined __APPLE__
|
||||
# pragma GCC diagnostic ignored "-Wmissing-prototypes"
|
||||
# pragma GCC diagnostic ignored "-Wextra"
|
||||
# endif
|
||||
|
@@ -1,6 +1,6 @@
|
||||
#ifdef __GNUC__
|
||||
# pragma GCC diagnostic ignored "-Wmissing-declarations"
|
||||
# ifdef __clang__
|
||||
# if defined __clang__ || defined __APPLE__
|
||||
# pragma GCC diagnostic ignored "-Wmissing-prototypes"
|
||||
# pragma GCC diagnostic ignored "-Wextra"
|
||||
# endif
|
||||
|
@@ -1,6 +1,6 @@
|
||||
#ifdef __GNUC__
|
||||
# pragma GCC diagnostic ignored "-Wmissing-declarations"
|
||||
# ifdef __clang__
|
||||
# if defined __clang__ || defined __APPLE__
|
||||
# pragma GCC diagnostic ignored "-Wmissing-prototypes"
|
||||
# pragma GCC diagnostic ignored "-Wextra"
|
||||
# endif
|
||||
|
@@ -1,5 +0,0 @@
|
||||
#Wed Jun 29 04:36:40 MSD 2011
|
||||
eclipse.preferences.version=1
|
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
|
||||
org.eclipse.jdt.core.compiler.compliance=1.5
|
||||
org.eclipse.jdt.core.compiler.source=1.5
|
@@ -1,5 +1,4 @@
|
||||
#Wed Jun 29 04:36:40 MSD 2011
|
||||
eclipse.preferences.version=1
|
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
|
||||
org.eclipse.jdt.core.compiler.compliance=1.5
|
||||
org.eclipse.jdt.core.compiler.source=1.5
|
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
|
||||
org.eclipse.jdt.core.compiler.compliance=1.6
|
||||
org.eclipse.jdt.core.compiler.source=1.6
|
||||
|
@@ -23,15 +23,20 @@ import org.opencv.features2d.DMatch;
|
||||
import org.opencv.features2d.KeyPoint;
|
||||
import org.opencv.highgui.Highgui;
|
||||
|
||||
public class OpenCVTestCase extends TestCase {
|
||||
import android.util.Log;
|
||||
|
||||
public class OpenCVTestCase extends TestCase {
|
||||
//change to 'true' to unblock fail on fail("Not yet implemented")
|
||||
public static final boolean passNYI = true;
|
||||
|
||||
protected static boolean isTestCaseEnabled = true;
|
||||
|
||||
protected static final int matSize = 10;
|
||||
protected static final double EPS = 0.001;
|
||||
protected static final double weakEPS = 0.5;
|
||||
|
||||
private static final String TAG = "OpenCVTestCase";
|
||||
|
||||
protected Mat dst;
|
||||
protected Mat truth;
|
||||
|
||||
@@ -173,6 +178,16 @@ public class OpenCVTestCase extends TestCase {
|
||||
super.tearDown();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void runTest() throws Throwable {
|
||||
// Do nothing if the precondition does not hold.
|
||||
if (isTestCaseEnabled) {
|
||||
super.runTest();
|
||||
} else {
|
||||
Log.e(TAG, "Test case \"" + this.getClass().getName() + "\" disabled!");
|
||||
}
|
||||
}
|
||||
|
||||
protected Mat getMat(int type, double... vals)
|
||||
{
|
||||
return new Mat(matSize, matSize, type, new Scalar(vals));
|
||||
|
@@ -2,11 +2,11 @@ package org.opencv.test;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.Iterator;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
import junit.framework.Assert;
|
||||
|
||||
import org.opencv.android.BaseLoaderCallback;
|
||||
import org.opencv.android.LoaderCallbackInterface;
|
||||
import org.opencv.android.OpenCVLoader;
|
||||
import org.opencv.android.Utils;
|
||||
import org.opencv.core.Mat;
|
||||
|
||||
@@ -23,8 +23,7 @@ import android.util.Log;
|
||||
|
||||
public class OpenCVTestRunner extends InstrumentationTestRunner {
|
||||
|
||||
static { System.loadLibrary("opencv_java"); }
|
||||
|
||||
private static final long MANAGER_TIMEOUT = 3000;
|
||||
public static String LENA_PATH;
|
||||
public static String CHESS_PATH;
|
||||
public static String LBPCASCADE_FRONTALFACE_PATH;
|
||||
@@ -33,6 +32,26 @@ public class OpenCVTestRunner extends InstrumentationTestRunner {
|
||||
private AndroidTestRunner androidTestRunner;
|
||||
private static String TAG = "opencv_test_java";
|
||||
|
||||
private BaseLoaderCallback mLoaderCallback = new BaseLoaderCallback(getContext()) {
|
||||
|
||||
@Override
|
||||
public void onManagerConnected(int status) {
|
||||
switch (status) {
|
||||
case LoaderCallbackInterface.SUCCESS:
|
||||
{
|
||||
Log("OpenCV loaded successfully");
|
||||
synchronized (this) {
|
||||
notify();
|
||||
}
|
||||
} break;
|
||||
default:
|
||||
{
|
||||
super.onManagerConnected(status);
|
||||
} break;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
public static String getTempFileName(String extension)
|
||||
{
|
||||
File cache = context.getCacheDir();
|
||||
@@ -59,6 +78,25 @@ public class OpenCVTestRunner extends InstrumentationTestRunner {
|
||||
|
||||
@Override
|
||||
public void onStart() {
|
||||
// try to load internal libs
|
||||
if (!OpenCVLoader.initDebug()) {
|
||||
// There is no internal OpenCV libs
|
||||
// Using OpenCV Manager for initialization;
|
||||
|
||||
Log("Internal OpenCV library not found. Using OpenCV Manager for initialization");
|
||||
OpenCVLoader.initAsync(OpenCVLoader.OPENCV_VERSION_2_4_3, getContext(), mLoaderCallback);
|
||||
|
||||
synchronized (this) {
|
||||
try {
|
||||
wait(MANAGER_TIMEOUT);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
Log("OpenCV library found inside test package. Using it!");
|
||||
}
|
||||
|
||||
context = getContext();
|
||||
Assert.assertTrue("Context can't be 'null'", context != null);
|
||||
LENA_PATH = Utils.exportResource(context, R.drawable.lena);
|
||||
@@ -72,17 +110,6 @@ public class OpenCVTestRunner extends InstrumentationTestRunner {
|
||||
//List<TestCase> testCases = androidTestRunner.getTestCases();
|
||||
//Collections.shuffle(testCases); //shuffle the tests order
|
||||
|
||||
if(OpenCVTestCase.passNYI) {
|
||||
// turn off problematic camera tests
|
||||
Iterator<TestCase> it = androidTestRunner.getTestCases().iterator();
|
||||
while (it.hasNext()) {
|
||||
String name = it.next().toString();
|
||||
if (name.contains("VideoCaptureTest"))
|
||||
it.remove();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
super.onStart();
|
||||
}
|
||||
|
||||
|
@@ -13,6 +13,8 @@ import org.opencv.features2d.KeyPoint;
|
||||
import org.opencv.test.OpenCVTestCase;
|
||||
import org.opencv.test.OpenCVTestRunner;
|
||||
|
||||
import android.util.Log;
|
||||
|
||||
public class FASTFeatureDetectorTest extends OpenCVTestCase {
|
||||
|
||||
FeatureDetector detector;
|
||||
@@ -127,9 +129,9 @@ public class FASTFeatureDetectorTest extends OpenCVTestCase {
|
||||
|
||||
detector.write(filename);
|
||||
|
||||
String truth = "<?xml version=\"1.0\"?>\n<opencv_storage>\n<name>Feature2D.FAST</name>\n<nonmaxSuppression>1</nonmaxSuppression>\n<threshold>10</threshold>\n</opencv_storage>\n";
|
||||
String truth = "<?xml version=\"1.0\"?>\n<opencv_storage>\n<name>Feature2D.FAST</name>\n<nonmaxSuppression>1</nonmaxSuppression>\n<threshold>10</threshold>\n<type>2</type>\n</opencv_storage>\n";
|
||||
String data = readFile(filename);
|
||||
|
||||
Log.d("qqq", "\"" + data + "\"");
|
||||
assertEquals(truth, data);
|
||||
}
|
||||
|
||||
@@ -138,9 +140,10 @@ public class FASTFeatureDetectorTest extends OpenCVTestCase {
|
||||
|
||||
detector.write(filename);
|
||||
|
||||
String truth = "%YAML:1.0\nname: \"Feature2D.FAST\"\nnonmaxSuppression: 1\nthreshold: 10\n";
|
||||
String truth = "%YAML:1.0\nname: \"Feature2D.FAST\"\nnonmaxSuppression: 1\nthreshold: 10\ntype: 2\n";
|
||||
String data = readFile(filename);
|
||||
|
||||
Log.d("qqq", "\"" + data + "\"");
|
||||
assertEquals(truth, data);
|
||||
}
|
||||
}
|
||||
|
@@ -22,10 +22,10 @@ public class HighguiTest extends OpenCVTestCase {
|
||||
public void testImencodeStringMatListOfByteListOfInteger() {
|
||||
MatOfInt params40 = new MatOfInt(Highgui.IMWRITE_JPEG_QUALITY, 40);
|
||||
MatOfInt params90 = new MatOfInt(Highgui.IMWRITE_JPEG_QUALITY, 90);
|
||||
/* or
|
||||
/* or
|
||||
MatOfInt params = new MatOfInt();
|
||||
params.fromArray(Highgui.IMWRITE_JPEG_QUALITY, 40);
|
||||
*/
|
||||
params.fromArray(Highgui.IMWRITE_JPEG_QUALITY, 40);
|
||||
*/
|
||||
MatOfByte buff40 = new MatOfByte();
|
||||
MatOfByte buff90 = new MatOfByte();
|
||||
|
||||
|
@@ -19,13 +19,13 @@ public class VideoCaptureTest extends OpenCVTestCase {
|
||||
super.setUp();
|
||||
|
||||
capture = null;
|
||||
isTestCaseEnabled = false;
|
||||
isSucceed = false;
|
||||
isOpened = false;
|
||||
}
|
||||
|
||||
public void testGet() {
|
||||
try
|
||||
{
|
||||
try {
|
||||
capture = new VideoCapture(Highgui.CV_CAP_ANDROID);
|
||||
double frameWidth = capture.get(Highgui.CV_CAP_PROP_FRAME_WIDTH);
|
||||
assertTrue(0 != frameWidth);
|
||||
@@ -35,8 +35,7 @@ public class VideoCaptureTest extends OpenCVTestCase {
|
||||
}
|
||||
|
||||
public void testGetSupportedPreviewSizes() {
|
||||
try
|
||||
{
|
||||
try {
|
||||
capture = new VideoCapture(Highgui.CV_CAP_ANDROID);
|
||||
List<Size> sizes = capture.getSupportedPreviewSizes();
|
||||
assertNotNull(sizes);
|
||||
@@ -68,8 +67,7 @@ public class VideoCaptureTest extends OpenCVTestCase {
|
||||
}
|
||||
|
||||
public void testIsOpenedRealCamera() {
|
||||
try
|
||||
{
|
||||
try {
|
||||
capture = new VideoCapture(Highgui.CV_CAP_ANDROID);
|
||||
isOpened = capture.isOpened();
|
||||
assertTrue(isOpened);
|
||||
@@ -79,8 +77,7 @@ public class VideoCaptureTest extends OpenCVTestCase {
|
||||
}
|
||||
|
||||
public void testOpen() {
|
||||
try
|
||||
{
|
||||
try {
|
||||
capture = new VideoCapture();
|
||||
capture.open(Highgui.CV_CAP_ANDROID);
|
||||
isOpened = capture.isOpened();
|
||||
@@ -91,8 +88,7 @@ public class VideoCaptureTest extends OpenCVTestCase {
|
||||
}
|
||||
|
||||
public void testRead() {
|
||||
try
|
||||
{
|
||||
try {
|
||||
capture = new VideoCapture(Highgui.CV_CAP_ANDROID);
|
||||
isSucceed = capture.read(dst);
|
||||
assertTrue(isSucceed);
|
||||
@@ -104,8 +100,7 @@ public class VideoCaptureTest extends OpenCVTestCase {
|
||||
}
|
||||
|
||||
public void testRelease() {
|
||||
try
|
||||
{
|
||||
try {
|
||||
capture = new VideoCapture(Highgui.CV_CAP_ANDROID);
|
||||
capture.release();
|
||||
assertFalse(capture.isOpened());
|
||||
@@ -116,8 +111,7 @@ public class VideoCaptureTest extends OpenCVTestCase {
|
||||
}
|
||||
|
||||
public void testRetrieveMat() {
|
||||
try
|
||||
{
|
||||
try {
|
||||
capture = new VideoCapture(Highgui.CV_CAP_ANDROID);
|
||||
capture.grab();
|
||||
isSucceed = capture.retrieve(dst);
|
||||
@@ -130,8 +124,7 @@ public class VideoCaptureTest extends OpenCVTestCase {
|
||||
}
|
||||
|
||||
public void testRetrieveMatInt() {
|
||||
try
|
||||
{
|
||||
try {
|
||||
capture = new VideoCapture(Highgui.CV_CAP_ANDROID);
|
||||
capture.grab();
|
||||
isSucceed = capture.retrieve(dst, Highgui.CV_CAP_ANDROID_GREY_FRAME);
|
||||
@@ -144,8 +137,7 @@ public class VideoCaptureTest extends OpenCVTestCase {
|
||||
}
|
||||
|
||||
public void testSet() {
|
||||
try
|
||||
{
|
||||
try {
|
||||
capture = new VideoCapture(Highgui.CV_CAP_ANDROID);
|
||||
capture.set(Highgui.CV_CAP_PROP_FRAME_WIDTH, 640);
|
||||
capture.set(Highgui.CV_CAP_PROP_FRAME_HEIGHT, 480);
|
||||
@@ -165,8 +157,7 @@ public class VideoCaptureTest extends OpenCVTestCase {
|
||||
}
|
||||
|
||||
public void testVideoCaptureInt() {
|
||||
try
|
||||
{
|
||||
try {
|
||||
capture = new VideoCapture(Highgui.CV_CAP_ANDROID);
|
||||
assertNotNull(capture);
|
||||
assertTrue(capture.isOpened());
|
||||
|
@@ -1,6 +1,6 @@
|
||||
#ifdef __GNUC__
|
||||
# pragma GCC diagnostic ignored "-Wmissing-declarations"
|
||||
# ifdef __clang__
|
||||
# if defined __clang__ || defined __APPLE__
|
||||
# pragma GCC diagnostic ignored "-Wmissing-prototypes"
|
||||
# pragma GCC diagnostic ignored "-Wextra"
|
||||
# endif
|
||||
|
@@ -1,6 +1,6 @@
|
||||
#ifdef __GNUC__
|
||||
# pragma GCC diagnostic ignored "-Wmissing-declarations"
|
||||
# ifdef __clang__
|
||||
# if defined __clang__ || defined __APPLE__
|
||||
# pragma GCC diagnostic ignored "-Wmissing-prototypes"
|
||||
# pragma GCC diagnostic ignored "-Wextra"
|
||||
# endif
|
||||
|
@@ -1,6 +1,6 @@
|
||||
#ifdef __GNUC__
|
||||
# pragma GCC diagnostic ignored "-Wmissing-declarations"
|
||||
# ifdef __clang__
|
||||
# if defined __clang__ || defined __APPLE__
|
||||
# pragma GCC diagnostic ignored "-Wmissing-prototypes"
|
||||
# pragma GCC diagnostic ignored "-Wextra"
|
||||
# endif
|
||||
|
@@ -1,6 +1,6 @@
|
||||
#ifdef __GNUC__
|
||||
# pragma GCC diagnostic ignored "-Wmissing-declarations"
|
||||
# ifdef __clang__
|
||||
# if defined __clang__ || defined __APPLE__
|
||||
# pragma GCC diagnostic ignored "-Wmissing-prototypes"
|
||||
# pragma GCC diagnostic ignored "-Wextra"
|
||||
# endif
|
||||
|
@@ -8,4 +8,5 @@ objdetect. Object Detection
|
||||
:maxdepth: 2
|
||||
|
||||
cascade_classification
|
||||
soft_cascade
|
||||
latent_svm
|
||||
|
96
modules/objdetect/doc/soft_cascade.rst
Normal file
96
modules/objdetect/doc/soft_cascade.rst
Normal file
@@ -0,0 +1,96 @@
|
||||
Soft Cascade Classifier
|
||||
======================
|
||||
|
||||
.. highlight:: cpp
|
||||
|
||||
Soft Cascade Classifier for Object Detection
|
||||
----------------------------------------------------------
|
||||
|
||||
Cascade detectors have been shown to operate extremely rapidly, with high accuracy, and have important applications in different spheres. The initial goal for this cascade implementation was the fast and accurate pedestrian detector but it also useful in general. Soft cascade is trained with AdaBoost. But instead of training sequence of stages, the soft cascade is trained as a one long stage of T weak classifiers. Soft cascade is formulated as follows:
|
||||
|
||||
.. math::
|
||||
\texttt{H}(x) = \sum _{\texttt{t}=1..\texttt{T}} {\texttt{s}_t(x)}
|
||||
|
||||
where :math:`\texttt{s}_t(x) = \alpha_t\texttt{h}_t(x)` are the set of thresholded weak classifiers selected during AdaBoost training scaled by the associated weights. Let
|
||||
|
||||
.. math::
|
||||
\texttt{H}_t(x) = \sum _{\texttt{i}=1..\texttt{t}} {\texttt{s}_i(x)}
|
||||
|
||||
be the partial sum of sample responses before :math:`t`-the weak classifier will be applied. The funtcion :math:`\texttt{H}_t(x)` of :math:`t` for sample :math:`x` named *sample trace*.
|
||||
After each weak classifier evaluation, the sample trace at the point :math:`t` is compared with the rejection threshold :math:`r_t`. The sequence of :math:`r_t` named *rejection trace*.
|
||||
|
||||
The sample has been rejected if it fall rejection threshold. So stageless cascade allows to reject not-object sample as soon as possible. Another meaning of the sample trace is a confidence with that sample recognized as desired object. At each :math:`t` that confidence depend on all previous weak classifier. This feature of soft cascade is resulted in more accurate detection. The original formulation of soft cascade can be found in [BJ05]_.
|
||||
|
||||
.. [BJ05] Lubomir Bourdev and Jonathan Brandt. tRobust Object Detection Via Soft Cascade. IEEE CVPR, 2005.
|
||||
.. [BMTG12] Rodrigo Benenson, Markus Mathias, Radu Timofte and Luc Van Gool. Pedestrian detection at 100 frames per second. IEEE CVPR, 2012.
|
||||
|
||||
|
||||
SCascade
|
||||
----------------
|
||||
.. ocv:class:: SCascade
|
||||
|
||||
Implementation of soft (stageless) cascaded detector. ::
|
||||
|
||||
class CV_EXPORTS SCascade : public Algorithm
|
||||
{
|
||||
public:
|
||||
SCascade(const float minScale = 0.4f, const float maxScale = 5.f, const int scales = 55, const int rejfactor = 1);
|
||||
virtual ~SCascade();
|
||||
cv::AlgorithmInfo* info() const;
|
||||
virtual bool load(const FileNode& fn);
|
||||
virtual void detect(InputArray image, InputArray rois, std::vector<Detection>& objects) const;
|
||||
virtual void detect(InputArray image, InputArray rois, OutputArray rects, OutputArray confs) const;
|
||||
};
|
||||
|
||||
|
||||
SCascade::SCascade
|
||||
--------------------------
|
||||
An empty cascade will be created.
|
||||
|
||||
.. ocv:function:: bool SCascade::SCascade(const float minScale = 0.4f, const float maxScale = 5.f, const int scales = 55, const int rejfactor = 1)
|
||||
|
||||
:param minScale: a minimum scale relative to the original size of the image on which cascade will be applyed.
|
||||
|
||||
:param maxScale: a maximum scale relative to the original size of the image on which cascade will be applyed.
|
||||
|
||||
:param scales: a number of scales from minScale to maxScale.
|
||||
|
||||
:param rejfactor: used for non maximum suppression.
|
||||
|
||||
|
||||
|
||||
SCascade::~SCascade
|
||||
---------------------------
|
||||
Destructor for SCascade.
|
||||
|
||||
.. ocv:function:: SCascade::~SCascade()
|
||||
|
||||
|
||||
|
||||
SCascade::load
|
||||
--------------------------
|
||||
Load cascade from FileNode.
|
||||
|
||||
.. ocv:function:: bool SCascade::load(const FileNode& fn)
|
||||
|
||||
:param fn: File node from which the soft cascade are read.
|
||||
|
||||
|
||||
|
||||
SCascade::detect
|
||||
--------------------------
|
||||
Apply cascade to an input frame and return the vector of Decection objcts.
|
||||
|
||||
.. ocv:function:: void SCascade::detect(InputArray image, InputArray rois, std::vector<Detection>& objects) const
|
||||
|
||||
.. ocv:function:: void SCascade::detect(InputArray image, InputArray rois, OutputArray rects, OutputArray confs) const
|
||||
|
||||
:param image: a frame on which detector will be applied.
|
||||
|
||||
:param rois: a vector of regions of interest. Only the objects that fall into one of the regions will be returned.
|
||||
|
||||
:param objects: an output array of Detections.
|
||||
|
||||
:param rects: an output array of bounding rectangles for detected objects.
|
||||
|
||||
:param confs: an output array of confidence for detected objects. i-th bounding rectangle corresponds i-th configence.
|
@@ -489,6 +489,93 @@ protected:
|
||||
};
|
||||
|
||||
|
||||
// Implementation of soft (stageless) cascaded detector.
|
||||
class CV_EXPORTS_W SCascade : public Algorithm
|
||||
{
|
||||
public:
|
||||
|
||||
// Representation of detectors result.
|
||||
struct CV_EXPORTS Detection
|
||||
{
|
||||
// Default object type.
|
||||
enum {PEDESTRIAN = 1};
|
||||
|
||||
// Creates Detection from an object bounding box and confidence.
|
||||
// Param b is a bounding box
|
||||
// Param c is a confidence that object belongs to class k
|
||||
// Paral k is an object class
|
||||
Detection(const cv::Rect& b, const float c, int k = PEDESTRIAN) : bb(b), confidence(c), kind(k) {}
|
||||
|
||||
cv::Rect bb;
|
||||
float confidence;
|
||||
int kind;
|
||||
};
|
||||
|
||||
// Create channel integrals for Soft Cascade detector.
|
||||
class CV_EXPORTS Channels
|
||||
{
|
||||
public:
|
||||
// constrictor form resizing factor.
|
||||
// Param shr is a resizing factor. Resize is applied before the computing integral sum
|
||||
Channels(const int shrinkage);
|
||||
|
||||
// Appends specified number of HOG first-order features integrals into given vector.
|
||||
// Param gray is an input 1-channel gray image.
|
||||
// Param integrals is a vector of integrals. Hog-channels will be appended to it.
|
||||
// Param bins is a number of hog-bins
|
||||
void appendHogBins(const cv::Mat& gray, std::vector<cv::Mat>& integrals, int bins) const;
|
||||
|
||||
// Converts 3-channel BGR input frame in Luv and appends each channel to the integrals.
|
||||
// Param frame is an input 3-channel BGR colored image.
|
||||
// Param integrals is a vector of integrals. Computed from the frame luv-channels will be appended to it.
|
||||
void appendLuvBins(const cv::Mat& frame, std::vector<cv::Mat>& integrals) const;
|
||||
|
||||
private:
|
||||
int shrinkage;
|
||||
};
|
||||
|
||||
// An empty cascade will be created.
|
||||
// Param minScale is a minimum scale relative to the original size of the image on which cascade will be applyed.
|
||||
// Param minScale is a maximum scale relative to the original size of the image on which cascade will be applyed.
|
||||
// Param scales is a number of scales from minScale to maxScale.
|
||||
// Param rejfactor is used for NMS.
|
||||
CV_WRAP SCascade(const double minScale = 0.4, const double maxScale = 5., const int scales = 55, const int rejfactor = 1);
|
||||
|
||||
CV_WRAP virtual ~SCascade();
|
||||
|
||||
cv::AlgorithmInfo* info() const;
|
||||
|
||||
// Load cascade from FileNode.
|
||||
// Param fn is a root node for cascade. Should be <cascade>.
|
||||
CV_WRAP virtual bool load(const FileNode& fn);
|
||||
|
||||
// Load cascade config.
|
||||
CV_WRAP virtual void read(const FileNode& fn);
|
||||
|
||||
// Return the vector of Decection objcts.
|
||||
// Param image is a frame on which detector will be applied.
|
||||
// Param rois is a vector of regions of interest. Only the objects that fall into one of the regions will be returned.
|
||||
// Param objects is an output array of Detections
|
||||
virtual void detect(InputArray image, InputArray rois, std::vector<Detection>& objects) const;
|
||||
// Param rects is an output array of bounding rectangles for detected objects.
|
||||
// Param confs is an output array of confidence for detected objects. i-th bounding rectangle corresponds i-th configence.
|
||||
CV_WRAP virtual void detect(InputArray image, InputArray rois, OutputArray rects, OutputArray confs) const;
|
||||
|
||||
private:
|
||||
void detectNoRoi(const Mat& image, std::vector<Detection>& objects) const;
|
||||
|
||||
struct Fields;
|
||||
Fields* fields;
|
||||
|
||||
double minScale;
|
||||
double maxScale;
|
||||
|
||||
int scales;
|
||||
int rejfactor;
|
||||
};
|
||||
|
||||
CV_EXPORTS bool initModule_objdetect(void);
|
||||
|
||||
//////////////// HOG (Histogram-of-Oriented-Gradients) Descriptor and Object Detector //////////////
|
||||
|
||||
// struct for detection region of interest (ROI)
|
||||
|
@@ -52,3 +52,45 @@ PERF_TEST_P(ImageName_MinSize, CascadeClassifierLBPFrontalFace,
|
||||
std::sort(faces.begin(), faces.end(), comparators::RectLess());
|
||||
SANITY_CHECK(faces, 3.001 * faces.size());
|
||||
}
|
||||
|
||||
typedef std::tr1::tuple<std::string, std::string> fixture;
|
||||
typedef perf::TestBaseWithParam<fixture> detect;
|
||||
|
||||
|
||||
namespace {
|
||||
typedef cv::SCascade::Detection detection_t;
|
||||
|
||||
void extractRacts(std::vector<detection_t> objectBoxes, vector<Rect> rects)
|
||||
{
|
||||
rects.clear();
|
||||
for (int i = 0; i < (int)objectBoxes.size(); ++i)
|
||||
rects.push_back(objectBoxes[i].bb);
|
||||
}
|
||||
}
|
||||
|
||||
PERF_TEST_P(detect, SCascade,
|
||||
testing::Combine(testing::Values(std::string("cv/cascadeandhog/sc_cvpr_2012_to_opencv.xml")),
|
||||
testing::Values(std::string("cv/cascadeandhog/bahnhof/image_00000000_0.png"))))
|
||||
{
|
||||
typedef cv::SCascade::Detection Detection;
|
||||
cv::Mat colored = imread(getDataPath(get<1>(GetParam())));
|
||||
ASSERT_FALSE(colored.empty());
|
||||
|
||||
cv::SCascade cascade;
|
||||
cv::FileStorage fs(getDataPath(get<0>(GetParam())), cv::FileStorage::READ);
|
||||
ASSERT_TRUE(fs.isOpened());
|
||||
ASSERT_TRUE(cascade.load(fs.getFirstTopLevelNode()));
|
||||
|
||||
std::vector<detection_t> objectBoxes;
|
||||
cascade.detect(colored, cv::noArray(), objectBoxes);
|
||||
|
||||
TEST_CYCLE()
|
||||
{
|
||||
cascade.detect(colored, cv::noArray(), objectBoxes);
|
||||
}
|
||||
|
||||
vector<Rect> rects;
|
||||
extractRacts(objectBoxes, rects);
|
||||
std::sort(rects.begin(), rects.end(), comparators::RectLess());
|
||||
SANITY_CHECK(rects);
|
||||
}
|
||||
|
@@ -1,6 +1,6 @@
|
||||
#ifdef __GNUC__
|
||||
# pragma GCC diagnostic ignored "-Wmissing-declarations"
|
||||
# ifdef __clang__
|
||||
# if defined __clang__ || defined __APPLE__
|
||||
# pragma GCC diagnostic ignored "-Wmissing-prototypes"
|
||||
# pragma GCC diagnostic ignored "-Wextra"
|
||||
# endif
|
||||
|
113
modules/objdetect/src/icf.cpp
Normal file
113
modules/objdetect/src/icf.cpp
Normal file
@@ -0,0 +1,113 @@
|
||||
/*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) 2000-2008, Intel Corporation, all rights reserved.
|
||||
// Copyright (C) 2008-2012, Willow Garage Inc., 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 Intel Corporation or contributors be liable for any direct,
|
||||
// indirect, incidental, special, exemplary, or consequential damages
|
||||
// (including, but not limited to, procurement of substitute goods or services;
|
||||
// loss of use, data, or profits; or business interruption) however caused
|
||||
// and on any theory of liability, whether in contract, strict liability,
|
||||
// or tort (including negligence or otherwise) arising in any way out of
|
||||
// the use of this software, even if advised of the possibility of such damage.
|
||||
//
|
||||
//M*/
|
||||
|
||||
#include <precomp.hpp>
|
||||
|
||||
cv::SCascade::Channels::Channels(int shr) : shrinkage(shr) {}
|
||||
|
||||
void cv::SCascade::Channels::appendHogBins(const cv::Mat& gray, std::vector<cv::Mat>& integrals, int bins) const
|
||||
{
|
||||
CV_Assert(gray.type() == CV_8UC1);
|
||||
int h = gray.rows;
|
||||
int w = gray.cols;
|
||||
CV_Assert(!(w % shrinkage) && !(h % shrinkage));
|
||||
|
||||
cv::Mat df_dx, df_dy, mag, angle;
|
||||
cv::Sobel(gray, df_dx, CV_32F, 1, 0);
|
||||
cv::Sobel(gray, df_dy, CV_32F, 0, 1);
|
||||
|
||||
cv::cartToPolar(df_dx, df_dy, mag, angle, true);
|
||||
mag *= (1.f / (8 * sqrt(2.f)));
|
||||
|
||||
cv::Mat nmag;
|
||||
mag.convertTo(nmag, CV_8UC1);
|
||||
|
||||
angle *= bins/360.f;
|
||||
|
||||
std::vector<cv::Mat> hist;
|
||||
for (int bin = 0; bin < bins; ++bin)
|
||||
hist.push_back(cv::Mat::zeros(h, w, CV_8UC1));
|
||||
|
||||
for (int y = 0; y < h; ++y)
|
||||
{
|
||||
uchar* magnitude = nmag.ptr<uchar>(y);
|
||||
float* ang = angle.ptr<float>(y);
|
||||
|
||||
for (int x = 0; x < w; ++x)
|
||||
{
|
||||
hist[ (int)ang[x] ].ptr<uchar>(y)[x] = magnitude[x];
|
||||
}
|
||||
}
|
||||
|
||||
for(int i = 0; i < bins; ++i)
|
||||
{
|
||||
cv::Mat shrunk, sum;
|
||||
cv::resize(hist[i], shrunk, cv::Size(), 1.0 / shrinkage, 1.0 / shrinkage, CV_INTER_AREA);
|
||||
cv::integral(shrunk, sum, cv::noArray(), CV_32S);
|
||||
integrals.push_back(sum);
|
||||
}
|
||||
|
||||
cv::Mat shrMag;
|
||||
cv::resize(nmag, shrMag, cv::Size(), 1.0 / shrinkage, 1.0 / shrinkage, CV_INTER_AREA);
|
||||
cv::integral(shrMag, mag, cv::noArray(), CV_32S);
|
||||
integrals.push_back(mag);
|
||||
}
|
||||
|
||||
void cv::SCascade::Channels::appendLuvBins(const cv::Mat& frame, std::vector<cv::Mat>& integrals) const
|
||||
{
|
||||
CV_Assert(frame.type() == CV_8UC3);
|
||||
CV_Assert(!(frame.cols % shrinkage) && !(frame.rows % shrinkage));
|
||||
|
||||
cv::Mat luv, shrunk;
|
||||
cv::cvtColor(frame, luv, CV_BGR2Luv);
|
||||
cv::resize(luv, shrunk, cv::Size(), 1.0 / shrinkage, 1.0 / shrinkage, CV_INTER_AREA);
|
||||
|
||||
std::vector<cv::Mat> splited;
|
||||
split(shrunk, splited);
|
||||
|
||||
for (size_t i = 0; i < splited.size(); ++i)
|
||||
{
|
||||
cv::Mat sum;
|
||||
cv::integral(splited[i], sum, cv::noArray(), CV_32S);
|
||||
integrals.push_back(sum);
|
||||
}
|
||||
}
|
@@ -7,11 +7,11 @@
|
||||
// copy or use the software.
|
||||
//
|
||||
//
|
||||
// License Agreement
|
||||
// License Agreement
|
||||
// For Open Source Computer Vision Library
|
||||
//
|
||||
// Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
|
||||
// Copyright (C) 2009, Willow Garage Inc., all rights reserved.
|
||||
// Copyright (C) 2008-2012, Willow Garage Inc., all rights reserved.
|
||||
// Third party copyrights are property of their respective owners.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
@@ -40,4 +40,21 @@
|
||||
//
|
||||
//M*/
|
||||
|
||||
#include "precomp.hpp"
|
||||
#include <precomp.hpp>
|
||||
|
||||
namespace cv
|
||||
{
|
||||
|
||||
CV_INIT_ALGORITHM(SCascade, "CascadeDetector.SCascade",
|
||||
obj.info()->addParam(obj, "minScale", obj.minScale);
|
||||
obj.info()->addParam(obj, "maxScale", obj.maxScale);
|
||||
obj.info()->addParam(obj, "scales", obj.scales);
|
||||
obj.info()->addParam(obj, "rejfactor", obj.rejfactor));
|
||||
|
||||
bool initModule_objdetect(void)
|
||||
{
|
||||
Ptr<Algorithm> sc = createSCascade();
|
||||
return sc->info() != 0;
|
||||
}
|
||||
|
||||
}
|
532
modules/objdetect/src/softcascade.cpp
Normal file
532
modules/objdetect/src/softcascade.cpp
Normal file
@@ -0,0 +1,532 @@
|
||||
/*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) 2000-2008, Intel Corporation, all rights reserved.
|
||||
// Copyright (C) 2008-2012, Willow Garage Inc., 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 Intel Corporation or contributors be liable for any direct,
|
||||
// indirect, incidental, special, exemplary, or consequential damages
|
||||
// (including, but not limited to, procurement of substitute goods or services;
|
||||
// loss of use, data, or profits; or business interruption) however caused
|
||||
// and on any theory of liability, whether in contract, strict liability,
|
||||
// or tort (including negligence or otherwise) arising in any way out of
|
||||
// the use of this software, even if advised of the possibility of such damage.
|
||||
//
|
||||
//M*/
|
||||
|
||||
#include <precomp.hpp>
|
||||
|
||||
namespace {
|
||||
|
||||
struct Octave
|
||||
{
|
||||
Octave(const int i, const cv::Size& origObjSize, const cv::FileNode& fn)
|
||||
: index(i), scale((float)fn[SC_OCT_SCALE]), stages((int)fn[SC_OCT_STAGES]),
|
||||
size(cvRound(origObjSize.width * scale), cvRound(origObjSize.height * scale)),
|
||||
shrinkage((int)fn[SC_OCT_SHRINKAGE]) {}
|
||||
|
||||
int index;
|
||||
float scale;
|
||||
int stages;
|
||||
cv::Size size;
|
||||
int shrinkage;
|
||||
|
||||
static const char *const SC_OCT_SCALE;
|
||||
static const char *const SC_OCT_STAGES;
|
||||
static const char *const SC_OCT_SHRINKAGE;
|
||||
};
|
||||
|
||||
|
||||
struct Weak
|
||||
{
|
||||
Weak(){}
|
||||
Weak(const cv::FileNode& fn) : threshold((float)fn[SC_STAGE_THRESHOLD]){}
|
||||
|
||||
float threshold;
|
||||
|
||||
static const char *const SC_STAGE_THRESHOLD;
|
||||
};
|
||||
|
||||
|
||||
struct Node
|
||||
{
|
||||
Node(){}
|
||||
Node(const int offset, cv::FileNodeIterator& fIt)
|
||||
: feature((int)(*(fIt +=2)++) + offset), threshold((float)(*(fIt++))){}
|
||||
|
||||
int feature;
|
||||
float threshold;
|
||||
};
|
||||
|
||||
struct Feature
|
||||
{
|
||||
Feature() {}
|
||||
Feature(const cv::FileNode& fn) : channel((int)fn[SC_F_CHANNEL])
|
||||
{
|
||||
cv::FileNode rn = fn[SC_F_RECT];
|
||||
cv::FileNodeIterator r_it = rn.begin();
|
||||
|
||||
int x = *r_it++;
|
||||
int y = *r_it++;
|
||||
int w = *r_it++;
|
||||
int h = *r_it++;
|
||||
rect = cv::Rect(x, y, w, h);
|
||||
|
||||
// 1 / area
|
||||
rarea = 1.f / ((rect.width - rect.x) * (rect.height - rect.y));
|
||||
}
|
||||
|
||||
int channel;
|
||||
cv::Rect rect;
|
||||
float rarea;
|
||||
|
||||
static const char *const SC_F_CHANNEL;
|
||||
static const char *const SC_F_RECT;
|
||||
|
||||
};
|
||||
|
||||
const char *const Octave::SC_OCT_SCALE = "scale";
|
||||
const char *const Octave::SC_OCT_STAGES = "stageNum";
|
||||
const char *const Octave::SC_OCT_SHRINKAGE = "shrinkingFactor";
|
||||
const char *const Weak::SC_STAGE_THRESHOLD = "stageThreshold";
|
||||
const char *const Feature::SC_F_CHANNEL = "channel";
|
||||
const char *const Feature::SC_F_RECT = "rect";
|
||||
|
||||
struct Level
|
||||
{
|
||||
const Octave* octave;
|
||||
|
||||
float origScale;
|
||||
float relScale;
|
||||
int scaleshift;
|
||||
|
||||
cv::Size workRect;
|
||||
cv::Size objSize;
|
||||
|
||||
float scaling[2]; // 0-th for channels <= 6, 1-st otherwise
|
||||
typedef cv::SCascade::Detection Detection;
|
||||
|
||||
Level(const Octave& oct, const float scale, const int shrinkage, const int w, const int h)
|
||||
: octave(&oct), origScale(scale), relScale(scale / oct.scale),
|
||||
workRect(cv::Size(cvRound(w / (float)shrinkage),cvRound(h / (float)shrinkage))),
|
||||
objSize(cv::Size(cvRound(oct.size.width * relScale), cvRound(oct.size.height * relScale)))
|
||||
{
|
||||
scaling[0] = ((relScale >= 1.f)? 1.f : (0.89f * pow(relScale, 1.099f / log(2.f)))) / (relScale * relScale);
|
||||
scaling[1] = 1.f;
|
||||
scaleshift = static_cast<int>(relScale * (1 << 16));
|
||||
}
|
||||
|
||||
void addDetection(const int x, const int y, float confidence, std::vector<Detection>& detections) const
|
||||
{
|
||||
int shrinkage = (*octave).shrinkage;
|
||||
cv::Rect rect(cvRound(x * shrinkage), cvRound(y * shrinkage), objSize.width, objSize.height);
|
||||
|
||||
detections.push_back(Detection(rect, confidence));
|
||||
}
|
||||
|
||||
float rescale(cv::Rect& scaledRect, const float threshold, int idx) const
|
||||
{
|
||||
#define SSHIFT(a) ((a) + (1 << 15)) >> 16
|
||||
// rescale
|
||||
scaledRect.x = SSHIFT(scaleshift * scaledRect.x);
|
||||
scaledRect.y = SSHIFT(scaleshift * scaledRect.y);
|
||||
scaledRect.width = SSHIFT(scaleshift * scaledRect.width);
|
||||
scaledRect.height = SSHIFT(scaleshift * scaledRect.height);
|
||||
#undef SSHIFT
|
||||
float sarea = static_cast<float>((scaledRect.width - scaledRect.x) * (scaledRect.height - scaledRect.y));
|
||||
|
||||
// compensation areas rounding
|
||||
return (sarea == 0.0f)? threshold : (threshold * scaling[idx] * sarea);
|
||||
}
|
||||
};
|
||||
|
||||
struct ChannelStorage
|
||||
{
|
||||
std::vector<cv::Mat> hog;
|
||||
int shrinkage;
|
||||
int offset;
|
||||
int step;
|
||||
|
||||
enum {HOG_BINS = 6, HOG_LUV_BINS = 10};
|
||||
|
||||
ChannelStorage(const cv::Mat& colored, int shr) : shrinkage(shr)
|
||||
{
|
||||
hog.clear();
|
||||
hog.reserve(10);
|
||||
cv::SCascade::Channels ints(shr);
|
||||
|
||||
// convert to grey
|
||||
cv::Mat grey;
|
||||
cv::cvtColor(colored, grey, CV_BGR2GRAY);
|
||||
|
||||
ints.appendHogBins(grey, hog, 6);
|
||||
ints.appendLuvBins(colored, hog);
|
||||
|
||||
step = hog[0].cols;
|
||||
}
|
||||
|
||||
float get(const int channel, const cv::Rect& area) const
|
||||
{
|
||||
// CV_Assert(channel < HOG_LUV_BINS);
|
||||
const cv::Mat& m = hog[channel];
|
||||
int *ptr = ((int*)(m.data)) + offset;
|
||||
|
||||
int a = ptr[area.y * step + area.x];
|
||||
int b = ptr[area.y * step + area.width];
|
||||
int c = ptr[area.height * step + area.width];
|
||||
int d = ptr[area.height * step + area.x];
|
||||
|
||||
return static_cast<float>(a - b + c - d);
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
struct cv::SCascade::Fields
|
||||
{
|
||||
float minScale;
|
||||
float maxScale;
|
||||
int scales;
|
||||
|
||||
int origObjWidth;
|
||||
int origObjHeight;
|
||||
|
||||
int shrinkage;
|
||||
|
||||
std::vector<Octave> octaves;
|
||||
std::vector<Weak> stages;
|
||||
std::vector<Node> nodes;
|
||||
std::vector<float> leaves;
|
||||
std::vector<Feature> features;
|
||||
|
||||
std::vector<Level> levels;
|
||||
|
||||
cv::Size frameSize;
|
||||
|
||||
typedef std::vector<Octave>::iterator octIt_t;
|
||||
|
||||
void detectAt(const int dx, const int dy, const Level& level, const ChannelStorage& storage,
|
||||
std::vector<Detection>& detections) const
|
||||
{
|
||||
float detectionScore = 0.f;
|
||||
|
||||
const Octave& octave = *(level.octave);
|
||||
int stBegin = octave.index * octave.stages, stEnd = stBegin + octave.stages;
|
||||
|
||||
int st = stBegin;
|
||||
for(; st < stEnd; ++st)
|
||||
{
|
||||
const Weak& stage = stages[st];
|
||||
{
|
||||
int nId = st * 3;
|
||||
|
||||
// work with root node
|
||||
const Node& node = nodes[nId];
|
||||
const Feature& feature = features[node.feature];
|
||||
cv::Rect scaledRect(feature.rect);
|
||||
|
||||
float threshold = level.rescale(scaledRect, node.threshold,(int)(feature.channel > 6)) * feature.rarea;
|
||||
|
||||
float sum = storage.get(feature.channel, scaledRect);
|
||||
|
||||
int next = (sum >= threshold)? 2 : 1;
|
||||
|
||||
// leaves
|
||||
const Node& leaf = nodes[nId + next];
|
||||
const Feature& fLeaf = features[leaf.feature];
|
||||
|
||||
scaledRect = fLeaf.rect;
|
||||
threshold = level.rescale(scaledRect, leaf.threshold, (int)(fLeaf.channel > 6)) * fLeaf.rarea;
|
||||
|
||||
sum = storage.get(fLeaf.channel, scaledRect);
|
||||
|
||||
int lShift = (next - 1) * 2 + ((sum >= threshold) ? 1 : 0);
|
||||
float impact = leaves[(st * 4) + lShift];
|
||||
|
||||
detectionScore += impact;
|
||||
}
|
||||
|
||||
if (detectionScore <= stage.threshold) return;
|
||||
}
|
||||
|
||||
if (detectionScore > 0)
|
||||
level.addDetection(dx, dy, detectionScore, detections);
|
||||
}
|
||||
|
||||
octIt_t fitOctave(const float& logFactor)
|
||||
{
|
||||
float minAbsLog = FLT_MAX;
|
||||
octIt_t res = octaves.begin();
|
||||
for (octIt_t oct = octaves.begin(); oct < octaves.end(); ++oct)
|
||||
{
|
||||
const Octave& octave =*oct;
|
||||
float logOctave = log(octave.scale);
|
||||
float logAbsScale = fabs(logFactor - logOctave);
|
||||
|
||||
if(logAbsScale < minAbsLog)
|
||||
{
|
||||
res = oct;
|
||||
minAbsLog = logAbsScale;
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
// compute levels of full pyramid
|
||||
void calcLevels(const cv::Size& curr, float mins, float maxs, int total)
|
||||
{
|
||||
if (frameSize == curr && maxs == maxScale && mins == minScale && total == scales) return;
|
||||
|
||||
frameSize = curr;
|
||||
maxScale = maxs; minScale = mins; scales = total;
|
||||
CV_Assert(scales > 1);
|
||||
|
||||
levels.clear();
|
||||
float logFactor = (log(maxScale) - log(minScale)) / (scales -1);
|
||||
|
||||
float scale = minScale;
|
||||
for (int sc = 0; sc < scales; ++sc)
|
||||
{
|
||||
int width = static_cast<int>(std::max(0.0f, frameSize.width - (origObjWidth * scale)));
|
||||
int height = static_cast<int>(std::max(0.0f, frameSize.height - (origObjHeight * scale)));
|
||||
|
||||
float logScale = log(scale);
|
||||
octIt_t fit = fitOctave(logScale);
|
||||
|
||||
|
||||
Level level(*fit, scale, shrinkage, width, height);
|
||||
|
||||
if (!width || !height)
|
||||
break;
|
||||
else
|
||||
levels.push_back(level);
|
||||
|
||||
if (fabs(scale - maxScale) < FLT_EPSILON) break;
|
||||
scale = std::min(maxScale, expf(log(scale) + logFactor));
|
||||
}
|
||||
}
|
||||
|
||||
bool fill(const FileNode &root)
|
||||
{
|
||||
// cascade properties
|
||||
static const char *const SC_STAGE_TYPE = "stageType";
|
||||
static const char *const SC_BOOST = "BOOST";
|
||||
|
||||
static const char *const SC_FEATURE_TYPE = "featureType";
|
||||
static const char *const SC_ICF = "ICF";
|
||||
|
||||
static const char *const SC_ORIG_W = "width";
|
||||
static const char *const SC_ORIG_H = "height";
|
||||
|
||||
static const char *const SC_OCTAVES = "octaves";
|
||||
static const char *const SC_STAGES = "stages";
|
||||
static const char *const SC_FEATURES = "features";
|
||||
|
||||
static const char *const SC_WEEK = "weakClassifiers";
|
||||
static const char *const SC_INTERNAL = "internalNodes";
|
||||
static const char *const SC_LEAF = "leafValues";
|
||||
|
||||
|
||||
// only Ada Boost supported
|
||||
std::string stageTypeStr = (string)root[SC_STAGE_TYPE];
|
||||
CV_Assert(stageTypeStr == SC_BOOST);
|
||||
|
||||
// only HOG-like integral channel features cupported
|
||||
string featureTypeStr = (string)root[SC_FEATURE_TYPE];
|
||||
CV_Assert(featureTypeStr == SC_ICF);
|
||||
|
||||
origObjWidth = (int)root[SC_ORIG_W];
|
||||
origObjHeight = (int)root[SC_ORIG_H];
|
||||
|
||||
// for each octave (~ one cascade in classic OpenCV xml)
|
||||
FileNode fn = root[SC_OCTAVES];
|
||||
if (fn.empty()) return false;
|
||||
|
||||
// octaves.reserve(noctaves);
|
||||
FileNodeIterator it = fn.begin(), it_end = fn.end();
|
||||
int feature_offset = 0;
|
||||
int octIndex = 0;
|
||||
for (; it != it_end; ++it)
|
||||
{
|
||||
FileNode fns = *it;
|
||||
Octave octave(octIndex, cv::Size(origObjWidth, origObjHeight), fns);
|
||||
CV_Assert(octave.stages > 0);
|
||||
octaves.push_back(octave);
|
||||
|
||||
FileNode ffs = fns[SC_FEATURES];
|
||||
if (ffs.empty()) return false;
|
||||
|
||||
fns = fns[SC_STAGES];
|
||||
if (fn.empty()) return false;
|
||||
|
||||
// for each stage (~ decision tree with H = 2)
|
||||
FileNodeIterator st = fns.begin(), st_end = fns.end();
|
||||
for (; st != st_end; ++st )
|
||||
{
|
||||
fns = *st;
|
||||
stages.push_back(Weak(fns));
|
||||
|
||||
fns = fns[SC_WEEK];
|
||||
FileNodeIterator ftr = fns.begin(), ft_end = fns.end();
|
||||
for (; ftr != ft_end; ++ftr)
|
||||
{
|
||||
fns = (*ftr)[SC_INTERNAL];
|
||||
FileNodeIterator inIt = fns.begin(), inIt_end = fns.end();
|
||||
for (; inIt != inIt_end;)
|
||||
nodes.push_back(Node(feature_offset, inIt));
|
||||
|
||||
fns = (*ftr)[SC_LEAF];
|
||||
inIt = fns.begin(), inIt_end = fns.end();
|
||||
for (; inIt != inIt_end; ++inIt)
|
||||
leaves.push_back((float)(*inIt));
|
||||
}
|
||||
}
|
||||
|
||||
st = ffs.begin(), st_end = ffs.end();
|
||||
for (; st != st_end; ++st )
|
||||
features.push_back(Feature(*st));
|
||||
|
||||
feature_offset += octave.stages * 3;
|
||||
++octIndex;
|
||||
}
|
||||
|
||||
shrinkage = octaves[0].shrinkage;
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
cv::SCascade::SCascade(const double mins, const double maxs, const int nsc, const int rej)
|
||||
: fields(0), minScale(mins), maxScale(maxs), scales(nsc), rejfactor(rej) {}
|
||||
|
||||
cv::SCascade::~SCascade() { delete fields;}
|
||||
|
||||
void cv::SCascade::read(const FileNode& fn)
|
||||
{
|
||||
Algorithm::read(fn);
|
||||
}
|
||||
|
||||
bool cv::SCascade::load(const FileNode& fn)
|
||||
{
|
||||
if (fields) delete fields;
|
||||
|
||||
fields = new Fields;
|
||||
return fields->fill(fn);
|
||||
}
|
||||
|
||||
void cv::SCascade::detectNoRoi(const cv::Mat& image, std::vector<Detection>& objects) const
|
||||
{
|
||||
Fields& fld = *fields;
|
||||
// create integrals
|
||||
ChannelStorage storage(image, fld.shrinkage);
|
||||
|
||||
typedef std::vector<Level>::const_iterator lIt;
|
||||
for (lIt it = fld.levels.begin(); it != fld.levels.end(); ++it)
|
||||
{
|
||||
const Level& level = *it;
|
||||
|
||||
for (int dy = 0; dy < level.workRect.height; ++dy)
|
||||
{
|
||||
for (int dx = 0; dx < level.workRect.width; ++dx)
|
||||
{
|
||||
storage.offset = dy * storage.step + dx;
|
||||
fld.detectAt(dx, dy, level, storage, objects);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void cv::SCascade::detect(cv::InputArray _image, cv::InputArray _rois, std::vector<Detection>& objects) const
|
||||
{
|
||||
// only color images are supperted
|
||||
cv::Mat image = _image.getMat();
|
||||
CV_Assert(image.type() == CV_8UC3);
|
||||
|
||||
Fields& fld = *fields;
|
||||
fld.calcLevels(image.size(),(float) minScale, (float)maxScale, scales);
|
||||
|
||||
objects.clear();
|
||||
|
||||
if (_rois.kind() == cv::_InputArray::NONE)
|
||||
return detectNoRoi(image, objects);
|
||||
|
||||
int shr = fld.shrinkage;
|
||||
|
||||
cv::Mat roi = _rois.getMat();
|
||||
cv::Mat mask(image.rows / shr, image.cols / shr, CV_8UC1);
|
||||
|
||||
mask.setTo(cv::Scalar::all(0));
|
||||
cv::Rect* r = roi.ptr<cv::Rect>(0);
|
||||
for (int i = 0; i < (int)roi.cols; ++i)
|
||||
cv::Mat(mask, cv::Rect(r[i].x / shr, r[i].y / shr, r[i].width / shr , r[i].height / shr)).setTo(cv::Scalar::all(1));
|
||||
|
||||
// create integrals
|
||||
ChannelStorage storage(image, shr);
|
||||
|
||||
typedef std::vector<Level>::const_iterator lIt;
|
||||
for (lIt it = fld.levels.begin(); it != fld.levels.end(); ++it)
|
||||
{
|
||||
const Level& level = *it;
|
||||
|
||||
for (int dy = 0; dy < level.workRect.height; ++dy)
|
||||
{
|
||||
uchar* m = mask.ptr<uchar>(dy);
|
||||
for (int dx = 0; dx < level.workRect.width; ++dx)
|
||||
{
|
||||
if (m[dx])
|
||||
{
|
||||
storage.offset = dy * storage.step + dx;
|
||||
fld.detectAt(dx, dy, level, storage, objects);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void cv::SCascade::detect(InputArray _image, InputArray _rois, OutputArray _rects, OutputArray _confs) const
|
||||
{
|
||||
std::vector<Detection> objects;
|
||||
detect( _image, _rois, objects);
|
||||
|
||||
_rects.create(1, objects.size(), CV_32SC4);
|
||||
cv::Mat_<cv::Rect> rects = (cv::Mat_<cv::Rect>)_rects.getMat();
|
||||
cv::Rect* rectPtr = rects.ptr<cv::Rect>(0);
|
||||
|
||||
_confs.create(1, objects.size(), CV_32F);
|
||||
cv::Mat confs = _confs.getMat();
|
||||
float* confPtr = rects.ptr<float>(0);
|
||||
|
||||
typedef std::vector<Detection>::const_iterator IDet;
|
||||
|
||||
int i = 0;
|
||||
for (IDet it = objects.begin(); it != objects.end(); ++it, ++i)
|
||||
{
|
||||
rectPtr[i] = (*it).bb;
|
||||
confPtr[i] = (*it).confidence;
|
||||
}
|
||||
}
|
@@ -1,6 +1,6 @@
|
||||
#ifdef __GNUC__
|
||||
# pragma GCC diagnostic ignored "-Wmissing-declarations"
|
||||
# ifdef __clang__
|
||||
# if defined __clang__ || defined __APPLE__
|
||||
# pragma GCC diagnostic ignored "-Wmissing-prototypes"
|
||||
# pragma GCC diagnostic ignored "-Wextra"
|
||||
# endif
|
||||
|
125
modules/objdetect/test/test_softcascade.cpp
Normal file
125
modules/objdetect/test/test_softcascade.cpp
Normal file
@@ -0,0 +1,125 @@
|
||||
/*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) 2000-2008, Intel Corporation, all rights reserved.
|
||||
// Copyright (C) 2008-2012, Willow Garage Inc., 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 Intel Corporation or contributors be liable for any direct,
|
||||
// indirect, incidental, special, exemplary, or consequential damages
|
||||
// (including, but not limited to, procurement of substitute goods or services;
|
||||
// loss of use, data, or profits; or business interruption) however caused
|
||||
// and on any theory of liability, whether in contract, strict liability,
|
||||
// or tort (including negligence or otherwise) arising in any way out of
|
||||
// the use of this software, even if advised of the possibility of such damage.
|
||||
//
|
||||
//M*/
|
||||
|
||||
#include "test_precomp.hpp"
|
||||
|
||||
TEST(SCascade, readCascade)
|
||||
{
|
||||
std::string xml = cvtest::TS::ptr()->get_data_path() + "cascadeandhog/icf-template.xml";
|
||||
cv::SCascade cascade;
|
||||
cv::FileStorage fs(xml, cv::FileStorage::READ);
|
||||
ASSERT_TRUE(fs.isOpened());
|
||||
ASSERT_TRUE(cascade.load(fs.getFirstTopLevelNode()));
|
||||
|
||||
}
|
||||
|
||||
TEST(SCascade, detect)
|
||||
{
|
||||
typedef cv::SCascade::Detection Detection;
|
||||
std::string xml = cvtest::TS::ptr()->get_data_path() + "cascadeandhog/sc_cvpr_2012_to_opencv.xml";
|
||||
cv::SCascade cascade;
|
||||
cv::FileStorage fs(xml, cv::FileStorage::READ);
|
||||
ASSERT_TRUE(cascade.load(fs.getFirstTopLevelNode()));
|
||||
|
||||
cv::Mat colored = cv::imread(cvtest::TS::ptr()->get_data_path() + "cascadeandhog/bahnhof/image_00000000_0.png");
|
||||
ASSERT_FALSE(colored.empty());
|
||||
|
||||
std::vector<Detection> objects;
|
||||
|
||||
cascade.detect(colored, cv::noArray(), objects);
|
||||
ASSERT_EQ(1459, (int)objects.size());
|
||||
}
|
||||
|
||||
TEST(SCascade, detectSeparate)
|
||||
{
|
||||
typedef cv::SCascade::Detection Detection;
|
||||
std::string xml = cvtest::TS::ptr()->get_data_path() + "cascadeandhog/sc_cvpr_2012_to_opencv.xml";
|
||||
cv::SCascade cascade;
|
||||
cv::FileStorage fs(xml, cv::FileStorage::READ);
|
||||
ASSERT_TRUE(cascade.load(fs.getFirstTopLevelNode()));
|
||||
|
||||
cv::Mat colored = cv::imread(cvtest::TS::ptr()->get_data_path() + "cascadeandhog/bahnhof/image_00000000_0.png");
|
||||
ASSERT_FALSE(colored.empty());
|
||||
|
||||
cv::Mat rects, confs;
|
||||
|
||||
cascade.detect(colored, cv::noArray(), rects, confs);
|
||||
ASSERT_EQ(1459, confs.cols);
|
||||
}
|
||||
|
||||
TEST(SCascade, detectRoi)
|
||||
{
|
||||
typedef cv::SCascade::Detection Detection;
|
||||
std::string xml = cvtest::TS::ptr()->get_data_path() + "cascadeandhog/sc_cvpr_2012_to_opencv.xml";
|
||||
cv::SCascade cascade;
|
||||
cv::FileStorage fs(xml, cv::FileStorage::READ);
|
||||
ASSERT_TRUE(cascade.load(fs.getFirstTopLevelNode()));
|
||||
|
||||
cv::Mat colored = cv::imread(cvtest::TS::ptr()->get_data_path() + "cascadeandhog/bahnhof/image_00000000_0.png");
|
||||
ASSERT_FALSE(colored.empty());
|
||||
|
||||
std::vector<Detection> objects;
|
||||
std::vector<cv::Rect> rois;
|
||||
rois.push_back(cv::Rect(0, 0, 640, 480));
|
||||
|
||||
cascade.detect(colored, rois, objects);
|
||||
ASSERT_EQ(1459, (int)objects.size());
|
||||
}
|
||||
|
||||
TEST(SCascade, detectNoRoi)
|
||||
{
|
||||
typedef cv::SCascade::Detection Detection;
|
||||
std::string xml = cvtest::TS::ptr()->get_data_path() + "cascadeandhog/sc_cvpr_2012_to_opencv.xml";
|
||||
cv::SCascade cascade;
|
||||
cv::FileStorage fs(xml, cv::FileStorage::READ);
|
||||
ASSERT_TRUE(cascade.load(fs.getFirstTopLevelNode()));
|
||||
|
||||
cv::Mat colored = cv::imread(cvtest::TS::ptr()->get_data_path() + "cascadeandhog/bahnhof/image_00000000_0.png");
|
||||
ASSERT_FALSE(colored.empty());
|
||||
|
||||
std::vector<Detection> objects;
|
||||
std::vector<cv::Rect> rois;
|
||||
|
||||
cascade.detect(colored, rois, objects);
|
||||
|
||||
ASSERT_EQ(0, (int)objects.size());
|
||||
}
|
@@ -79,77 +79,47 @@ int main(int argc, char **argv)
|
||||
TS::ptr()->init("ocl");
|
||||
InitGoogleTest(&argc, argv);
|
||||
const char *keys =
|
||||
|
||||
"{ h | help | false | print help message }"
|
||||
|
||||
"{ w | workdir | ../../../samples/c/| set working directory }"
|
||||
|
||||
"{ t | type | gpu | set device type:cpu or gpu}"
|
||||
|
||||
"{ p | platform | 0 | set platform id }"
|
||||
|
||||
"{ d | device | 0 | set device id }";
|
||||
|
||||
|
||||
"{ h | false | print help message }"
|
||||
"{ w | ../../../samples/c/| set working directory i.e. -w=C:\\}"
|
||||
"{ t | gpu | set device type:i.e. -t=cpu or gpu}"
|
||||
"{ p | 0 | set platform id i.e. -p=0}"
|
||||
"{ d | 0 | set device id i.e. -d=0}";
|
||||
|
||||
CommandLineParser cmd(argc, argv, keys);
|
||||
|
||||
if (cmd.get<bool>("help"))
|
||||
|
||||
if (cmd.get<string>("h")=="true")
|
||||
{
|
||||
|
||||
cout << "Avaible options besides goole test option:" << endl;
|
||||
|
||||
cmd.printParams();
|
||||
cmd.printMessage();
|
||||
return 0;
|
||||
}
|
||||
|
||||
workdir = cmd.get<string>("workdir");
|
||||
|
||||
string type = cmd.get<string>("type");
|
||||
|
||||
unsigned int pid = cmd.get<unsigned int>("platform");
|
||||
|
||||
int device = cmd.get<int>("device");
|
||||
|
||||
|
||||
workdir = cmd.get<string>("w");
|
||||
string type = cmd.get<string>("t");
|
||||
unsigned int pid = cmd.get<unsigned int>("p");
|
||||
int device = cmd.get<int>("d");
|
||||
print_info();
|
||||
int flag = CVCL_DEVICE_TYPE_GPU;
|
||||
|
||||
if(type == "cpu")
|
||||
|
||||
{
|
||||
|
||||
flag = CVCL_DEVICE_TYPE_CPU;
|
||||
|
||||
}
|
||||
std::vector<cv::ocl::Info> oclinfo;
|
||||
int devnums = getDevice(oclinfo);
|
||||
if(devnums <= device || device < 0)
|
||||
|
||||
{
|
||||
|
||||
std::cout << "device invalid\n";
|
||||
|
||||
return -1;
|
||||
|
||||
}
|
||||
|
||||
if(pid >= oclinfo.size())
|
||||
|
||||
{
|
||||
|
||||
std::cout << "platform invalid\n";
|
||||
|
||||
return -1;
|
||||
|
||||
}
|
||||
|
||||
if(pid != 0 || device != 0)
|
||||
|
||||
{
|
||||
|
||||
setDevice(oclinfo[pid], device);
|
||||
|
||||
}
|
||||
|
||||
cout << "Device type:" << type << endl << "Device name:" << oclinfo[pid].DeviceName[device] << endl;
|
||||
|
@@ -79,23 +79,23 @@ int main(int argc, char **argv)
|
||||
TS::ptr()->init("ocl");
|
||||
InitGoogleTest(&argc, argv);
|
||||
const char *keys =
|
||||
"{ h | help | false | print help message }"
|
||||
"{ w | workdir | ../../../samples/c/| set working directory }"
|
||||
"{ t | type | gpu | set device type:cpu or gpu}"
|
||||
"{ p | platform | 0 | set platform id }"
|
||||
"{ d | device | 0 | set device id }";
|
||||
"{ h | false | print help message }"
|
||||
"{ w | ../../../samples/c/| set working directory i.e. -w=C:\\}"
|
||||
"{ t | gpu | set device type:i.e. -t=cpu or gpu}"
|
||||
"{ p | 0 | set platform id i.e. -p=0}"
|
||||
"{ d | 0 | set device id i.e. -d=0}";
|
||||
|
||||
CommandLineParser cmd(argc, argv, keys);
|
||||
if (cmd.get<bool>("help"))
|
||||
if (cmd.get<string>("h")=="true")
|
||||
{
|
||||
cout << "Avaible options besides goole test option:" << endl;
|
||||
cmd.printParams();
|
||||
cmd.printMessage();
|
||||
return 0;
|
||||
}
|
||||
workdir = cmd.get<string>("workdir");
|
||||
string type = cmd.get<string>("type");
|
||||
unsigned int pid = cmd.get<unsigned int>("platform");
|
||||
int device = cmd.get<int>("device");
|
||||
workdir = cmd.get<string>("w");
|
||||
string type = cmd.get<string>("t");
|
||||
unsigned int pid = cmd.get<unsigned int>("p");
|
||||
int device = cmd.get<int>("d");
|
||||
|
||||
print_info();
|
||||
int flag = CVCL_DEVICE_TYPE_GPU;
|
||||
|
@@ -1,6 +1,6 @@
|
||||
#ifdef __GNUC__
|
||||
# pragma GCC diagnostic ignored "-Wmissing-declarations"
|
||||
# ifdef __clang__
|
||||
# if defined __clang__ || defined __APPLE__
|
||||
# pragma GCC diagnostic ignored "-Wmissing-prototypes"
|
||||
# pragma GCC diagnostic ignored "-Wextra"
|
||||
# endif
|
||||
|
@@ -1,6 +1,6 @@
|
||||
#ifdef __GNUC__
|
||||
# pragma GCC diagnostic ignored "-Wmissing-declarations"
|
||||
# ifdef __clang__
|
||||
# if defined __clang__ || defined __APPLE__
|
||||
# pragma GCC diagnostic ignored "-Wmissing-prototypes"
|
||||
# pragma GCC diagnostic ignored "-Wextra"
|
||||
# endif
|
||||
|
@@ -1,6 +1,6 @@
|
||||
#ifdef __GNUC__
|
||||
# pragma GCC diagnostic ignored "-Wmissing-declarations"
|
||||
# ifdef __clang__
|
||||
# if defined __clang__ || defined __APPLE__
|
||||
# pragma GCC diagnostic ignored "-Wmissing-prototypes"
|
||||
# pragma GCC diagnostic ignored "-Wextra"
|
||||
# endif
|
||||
|
@@ -1,6 +1,6 @@
|
||||
#ifdef __GNUC__
|
||||
# pragma GCC diagnostic ignored "-Wmissing-declarations"
|
||||
# ifdef __clang__
|
||||
# if defined __clang__ || defined __APPLE__
|
||||
# pragma GCC diagnostic ignored "-Wmissing-prototypes"
|
||||
# pragma GCC diagnostic ignored "-Wextra"
|
||||
# endif
|
||||
|
@@ -601,17 +601,15 @@ calcOpticalFlowSF
|
||||
-----------------
|
||||
Calculate an optical flow using "SimpleFlow" algorithm.
|
||||
|
||||
.. ocv:function:: void calcOpticalFlowSF( Mat& from, Mat& to, Mat& flow, int layers, int averaging_block_size, int max_flow )
|
||||
.. ocv:function:: void calcOpticalFlowSF( InputArray from, InputArray to, OutputArray flow, int layers, int averaging_block_size, int max_flow )
|
||||
|
||||
.. ocv:function:: calcOpticalFlowSF( Mat& from, Mat& to, Mat& flow, int layers, int averaging_block_size, int max_flow, double sigma_dist, double sigma_color, int postprocess_window, double sigma_dist_fix, double sigma_color_fix, double occ_thr, int upscale_averaging_radius, double upscale_sigma_dist, double upscale_sigma_color, double speed_up_thr )
|
||||
.. ocv:function:: calcOpticalFlowSF( InputArray from, InputArray to, OutputArray flow, int layers, int averaging_block_size, int max_flow, double sigma_dist, double sigma_color, int postprocess_window, double sigma_dist_fix, double sigma_color_fix, double occ_thr, int upscale_averaging_radius, double upscale_sigma_dist, double upscale_sigma_color, double speed_up_thr )
|
||||
|
||||
:param prev: First 8-bit 3-channel image.
|
||||
|
||||
:param next: Second 8-bit 3-channel image
|
||||
:param next: Second 8-bit 3-channel image of the same size as ``prev``
|
||||
|
||||
:param flowX: X-coordinate of estimated flow
|
||||
|
||||
:param flowY: Y-coordinate of estimated flow
|
||||
:param flow: computed flow image that has the same size as ``prev`` and type ``CV_32FC2``
|
||||
|
||||
:param layers: Number of layers
|
||||
|
||||
@@ -631,7 +629,7 @@ Calculate an optical flow using "SimpleFlow" algorithm.
|
||||
|
||||
:param occ_thr: threshold for detecting occlusions
|
||||
|
||||
:param upscale_averaging_radiud: window size for bilateral upscale operation
|
||||
:param upscale_averaging_radius: window size for bilateral upscale operation
|
||||
|
||||
:param upscale_sigma_dist: spatial sigma for bilateral upscale operation
|
||||
|
||||
|
@@ -328,16 +328,16 @@ CV_EXPORTS_W Mat estimateRigidTransform( InputArray src, InputArray dst,
|
||||
bool fullAffine);
|
||||
|
||||
//! computes dense optical flow using Simple Flow algorithm
|
||||
CV_EXPORTS_W void calcOpticalFlowSF(Mat& from,
|
||||
Mat& to,
|
||||
Mat& flow,
|
||||
CV_EXPORTS_W void calcOpticalFlowSF(InputArray from,
|
||||
InputArray to,
|
||||
OutputArray flow,
|
||||
int layers,
|
||||
int averaging_block_size,
|
||||
int max_flow);
|
||||
|
||||
CV_EXPORTS_W void calcOpticalFlowSF(Mat& from,
|
||||
Mat& to,
|
||||
Mat& flow,
|
||||
CV_EXPORTS_W void calcOpticalFlowSF(InputArray from,
|
||||
InputArray to,
|
||||
OutputArray flow,
|
||||
int layers,
|
||||
int averaging_block_size,
|
||||
int max_flow,
|
||||
|
@@ -1,6 +1,6 @@
|
||||
#ifdef __GNUC__
|
||||
# pragma GCC diagnostic ignored "-Wmissing-declarations"
|
||||
# ifdef __clang__
|
||||
# if defined __clang__ || defined __APPLE__
|
||||
# pragma GCC diagnostic ignored "-Wmissing-prototypes"
|
||||
# pragma GCC diagnostic ignored "-Wextra"
|
||||
# endif
|
||||
|
@@ -447,7 +447,7 @@ static void extrapolateFlow(Mat& flow,
|
||||
}
|
||||
}
|
||||
|
||||
static void buildPyramidWithResizeMethod(Mat& src,
|
||||
static void buildPyramidWithResizeMethod(const Mat& src,
|
||||
vector<Mat>& pyramid,
|
||||
int layers,
|
||||
int interpolation_type) {
|
||||
@@ -464,9 +464,9 @@ static void buildPyramidWithResizeMethod(Mat& src,
|
||||
}
|
||||
}
|
||||
|
||||
CV_EXPORTS_W void calcOpticalFlowSF(Mat& from,
|
||||
Mat& to,
|
||||
Mat& resulted_flow,
|
||||
CV_EXPORTS_W void calcOpticalFlowSF(InputArray _from,
|
||||
InputArray _to,
|
||||
OutputArray _resulted_flow,
|
||||
int layers,
|
||||
int averaging_radius,
|
||||
int max_flow,
|
||||
@@ -479,7 +479,11 @@ CV_EXPORTS_W void calcOpticalFlowSF(Mat& from,
|
||||
int upscale_averaging_radius,
|
||||
double upscale_sigma_dist,
|
||||
double upscale_sigma_color,
|
||||
double speed_up_thr) {
|
||||
double speed_up_thr)
|
||||
{
|
||||
Mat from = _from.getMat();
|
||||
Mat to = _to.getMat();
|
||||
|
||||
vector<Mat> pyr_from_images;
|
||||
vector<Mat> pyr_to_images;
|
||||
|
||||
@@ -632,14 +636,15 @@ CV_EXPORTS_W void calcOpticalFlowSF(Mat& from,
|
||||
|
||||
GaussianBlur(flow, flow, Size(3, 3), 5);
|
||||
|
||||
resulted_flow = Mat(flow.size(), CV_32FC2);
|
||||
_resulted_flow.create(flow.size(), CV_32FC2);
|
||||
Mat resulted_flow = _resulted_flow.getMat();
|
||||
int from_to[] = {0,1 , 1,0};
|
||||
mixChannels(&flow, 1, &resulted_flow, 1, from_to, 2);
|
||||
}
|
||||
|
||||
CV_EXPORTS_W void calcOpticalFlowSF(Mat& from,
|
||||
Mat& to,
|
||||
Mat& flow,
|
||||
CV_EXPORTS_W void calcOpticalFlowSF(InputArray from,
|
||||
InputArray to,
|
||||
OutputArray flow,
|
||||
int layers,
|
||||
int averaging_block_size,
|
||||
int max_flow) {
|
||||
|
@@ -1,6 +1,6 @@
|
||||
#ifdef __GNUC__
|
||||
# pragma GCC diagnostic ignored "-Wmissing-declarations"
|
||||
# ifdef __clang__
|
||||
# if defined __clang__ || defined __APPLE__
|
||||
# pragma GCC diagnostic ignored "-Wmissing-prototypes"
|
||||
# pragma GCC diagnostic ignored "-Wextra"
|
||||
# endif
|
||||
|
Reference in New Issue
Block a user