Skip to content

📄 Awesome OCR multiple programing languages toolkits based on ONNX Runtime, OpenVINO, MNN, PaddlePaddle, TensorRT and PyTorch.

opencv

root07080c7cfd61
diff --git a/CMakeLists.txt b/CMakeLists.txt
index eb7107e..fa1cdd9 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -2,6 +2,8 @@ cmake_minimum_required(VERSION 3.10)
project(BaiPiaoOCR)
include_directories(cpp/BaiPiaoOcrOnnx/include)
+include_directories(include/onnxruntime/core/session)
+include_directories(include/)
if(WIN32)
diff --git a/include/opencv/cv.h b/include/opencv/cv.h
new file mode 100755
index 0000000..19a74e2
--- /dev/null
+++ b/include/opencv/cv.h
@@ -0,0 +1,73 @@
+/*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) 2009, 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*/
+
+#ifndef OPENCV_OLD_CV_H
+#define OPENCV_OLD_CV_H
+
+#if defined(_MSC_VER)
+ #define CV_DO_PRAGMA(x) __pragma(x)
+ #define __CVSTR2__(x) #x
+ #define __CVSTR1__(x) __CVSTR2__(x)
+ #define __CVMSVCLOC__ __FILE__ "("__CVSTR1__(__LINE__)") : "
+ #define CV_MSG_PRAGMA(_msg) CV_DO_PRAGMA(message (__CVMSVCLOC__ _msg))
+#elif defined(__GNUC__)
+ #define CV_DO_PRAGMA(x) _Pragma (#x)
+ #define CV_MSG_PRAGMA(_msg) CV_DO_PRAGMA(message (_msg))
+#else
+ #define CV_DO_PRAGMA(x)
+ #define CV_MSG_PRAGMA(_msg)
+#endif
+#define CV_WARNING(x) CV_MSG_PRAGMA("Warning: " #x)
+
+//CV_WARNING("This is a deprecated opencv header provided for compatibility. Please include a header from a corresponding opencv module")
+
+#include "opencv2/core/core_c.h"
+#include "opencv2/imgproc/imgproc_c.h"
+#include "opencv2/photo/photo_c.h"
+#include "opencv2/video/tracking_c.h"
+#include "opencv2/objdetect/objdetect_c.h"
+
+#if !defined(CV_IMPL)
+#define CV_IMPL extern "C"
+#endif //CV_IMPL
+
+#endif // __OPENCV_OLD_CV_H_
diff --git a/include/opencv/cv.hpp b/include/opencv/cv.hpp
new file mode 100755
index 0000000..8673956
--- /dev/null
+++ b/include/opencv/cv.hpp
@@ -0,0 +1,60 @@
+/*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) 2009, 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*/
+
+#ifndef OPENCV_OLD_CV_HPP
+#define OPENCV_OLD_CV_HPP
+
+//#if defined(__GNUC__)
+//#warning "This is a deprecated opencv header provided for compatibility. Please include a header from a corresponding opencv module"
+//#endif
+
+#include "cv.h"
+#include "opencv2/core.hpp"
+#include "opencv2/imgproc.hpp"
+#include "opencv2/photo.hpp"
+#include "opencv2/video.hpp"
+#include "opencv2/highgui.hpp"
+#include "opencv2/features2d.hpp"
+#include "opencv2/calib3d.hpp"
+#include "opencv2/objdetect.hpp"
+
+#endif
diff --git a/include/opencv/cvaux.h b/include/opencv/cvaux.h
new file mode 100755
index 0000000..c0367cc
--- /dev/null
+++ b/include/opencv/cvaux.h
@@ -0,0 +1,57 @@
+/*M///////////////////////////////////////////////////////////////////////////////////////
+//
+// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
+//
+// By downloading, copying, installing or using the software you agree to this license.
+// If you do not agree to this license, do not download, install,
+// copy or use the software.
+//
+//
+// Intel License Agreement
+// For Open Source Computer Vision Library
+//
+// Copyright (C) 2000, Intel Corporation, all rights reserved.
+// Third party copyrights are property of their respective owners.
+//
+// Redistribution and use in source and binary forms, with or without modification,
+// are permitted provided that the following conditions are met:
+//
+// * Redistribution's of source code must retain the above copyright notice,
+// this list of conditions and the following disclaimer.
+//
+// * Redistribution's in binary form must reproduce the above copyright notice,
+// this list of conditions and the following disclaimer in the documentation
+// and/or other materials provided with the distribution.
+//
+// * The name of Intel Corporation may not be used to endorse or promote products
+// derived from this software without specific prior written permission.
+//
+// This software is provided by the copyright holders and contributors "as is" and
+// any express or implied warranties, including, but not limited to, the implied
+// warranties of merchantability and fitness for a particular purpose are disclaimed.
+// In no event shall the Intel Corporation or contributors be liable for any direct,
+// indirect, incidental, special, exemplary, or consequential damages
+// (including, but not limited to, procurement of substitute goods or services;
+// loss of use, data, or profits; or business interruption) however caused
+// and on any theory of liability, whether in contract, strict liability,
+// or tort (including negligence or otherwise) arising in any way out of
+// the use of this software, even if advised of the possibility of such damage.
+//
+//M*/
+
+#ifndef OPENCV_OLD_AUX_H
+#define OPENCV_OLD_AUX_H
+
+//#if defined(__GNUC__)
+//#warning "This is a deprecated opencv header provided for compatibility. Please include a header from a corresponding opencv module"
+//#endif
+
+#include "opencv2/core/core_c.h"
+#include "opencv2/imgproc/imgproc_c.h"
+#include "opencv2/photo/photo_c.h"
+#include "opencv2/video/tracking_c.h"
+#include "opencv2/objdetect/objdetect_c.h"
+
+#endif
+
+/* End of file. */
diff --git a/include/opencv/cvaux.hpp b/include/opencv/cvaux.hpp
new file mode 100755
index 0000000..4888eef
--- /dev/null
+++ b/include/opencv/cvaux.hpp
@@ -0,0 +1,52 @@
+/*M///////////////////////////////////////////////////////////////////////////////////////
+//
+// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
+//
+// By downloading, copying, installing or using the software you agree to this license.
+// If you do not agree to this license, do not download, install,
+// copy or use the software.
+//
+//
+// Intel License Agreement
+// For Open Source Computer Vision Library
+//
+// Copyright (C) 2000, Intel Corporation, all rights reserved.
+// Third party copyrights are property of their respective owners.
+//
+// Redistribution and use in source and binary forms, with or without modification,
+// are permitted provided that the following conditions are met:
+//
+// * Redistribution's of source code must retain the above copyright notice,
+// this list of conditions and the following disclaimer.
+//
+// * Redistribution's in binary form must reproduce the above copyright notice,
+// this list of conditions and the following disclaimer in the documentation
+// and/or other materials provided with the distribution.
+//
+// * The name of Intel Corporation may not be used to endorse or promote products
+// derived from this software without specific prior written permission.
+//
+// This software is provided by the copyright holders and contributors "as is" and
+// any express or implied warranties, including, but not limited to, the implied
+// warranties of merchantability and fitness for a particular purpose are disclaimed.
+// In no event shall the Intel Corporation or contributors be liable for any direct,
+// indirect, incidental, special, exemplary, or consequential damages
+// (including, but not limited to, procurement of substitute goods or services;
+// loss of use, data, or profits; or business interruption) however caused
+// and on any theory of liability, whether in contract, strict liability,
+// or tort (including negligence or otherwise) arising in any way out of
+// the use of this software, even if advised of the possibility of such damage.
+//
+//M*/
+
+#ifndef OPENCV_OLD_AUX_HPP
+#define OPENCV_OLD_AUX_HPP
+
+//#if defined(__GNUC__)
+//#warning "This is a deprecated opencv header provided for compatibility. Please include a header from a corresponding opencv module"
+//#endif
+
+#include "cvaux.h"
+#include "opencv2/core/utility.hpp"
+
+#endif
diff --git a/include/opencv/cvwimage.h b/include/opencv/cvwimage.h
new file mode 100755
index 0000000..ec0ab14
--- /dev/null
+++ b/include/opencv/cvwimage.h
@@ -0,0 +1,46 @@
+///////////////////////////////////////////////////////////////////////////////
+// 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) 2008, Google, all rights reserved.
+// Third party copyrights are property of their respective owners.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are met:
+//
+// * Redistribution's of source code must retain the above copyright notice,
+// this list of conditions and the following disclaimer.
+//
+// * Redistribution's in binary form must reproduce the above copyright notice,
+// this list of conditions and the following disclaimer in the documentation
+// and/or other materials provided with the distribution.
+//
+// * The name of Intel Corporation or contributors 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.
+
+
+#ifndef OPENCV_OLD_WIMAGE_HPP
+#define OPENCV_OLD_WIMAGE_HPP
+
+#include "opencv2/core/wimage.hpp"
+
+#endif
diff --git a/include/opencv/cxcore.h b/include/opencv/cxcore.h
new file mode 100755
index 0000000..dc070c7
--- /dev/null
+++ b/include/opencv/cxcore.h
@@ -0,0 +1,52 @@
+/*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) 2009, 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*/
+
+#ifndef OPENCV_OLD_CXCORE_H
+#define OPENCV_OLD_CXCORE_H
+
+//#if defined(__GNUC__)
+//#warning "This is a deprecated opencv header provided for compatibility. Please include a header from a corresponding opencv module"
+//#endif
+
+#include "opencv2/core/core_c.h"
+
+#endif
diff --git a/include/opencv/cxcore.hpp b/include/opencv/cxcore.hpp
new file mode 100755
index 0000000..c371677
--- /dev/null
+++ b/include/opencv/cxcore.hpp
@@ -0,0 +1,53 @@
+/*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) 2009, 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*/
+
+#ifndef OPENCV_OLD_CXCORE_HPP
+#define OPENCV_OLD_CXCORE_HPP
+
+//#if defined(__GNUC__)
+//#warning "This is a deprecated opencv header provided for compatibility. Please include a header from a corresponding opencv module"
+//#endif
+
+#include "cxcore.h"
+#include "opencv2/core.hpp"
+
+#endif
diff --git a/include/opencv/cxeigen.hpp b/include/opencv/cxeigen.hpp
new file mode 100755
index 0000000..1d3df91
--- /dev/null
+++ b/include/opencv/cxeigen.hpp
@@ -0,0 +1,48 @@
+/*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) 2009, 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*/
+
+#ifndef OPENCV_OLD_EIGEN_HPP
+#define OPENCV_OLD_EIGEN_HPP
+
+#include "opencv2/core/eigen.hpp"
+
+#endif
diff --git a/include/opencv/cxmisc.h b/include/opencv/cxmisc.h
new file mode 100755
index 0000000..9b9bc82
--- /dev/null
+++ b/include/opencv/cxmisc.h
@@ -0,0 +1,8 @@
+#ifndef OPENCV_OLD_CXMISC_H
+#define OPENCV_OLD_CXMISC_H
+
+#ifdef __cplusplus
+# include "opencv2/core/utility.hpp"
+#endif
+
+#endif
diff --git a/include/opencv/highgui.h b/include/opencv/highgui.h
new file mode 100755
index 0000000..69b394e
--- /dev/null
+++ b/include/opencv/highgui.h
@@ -0,0 +1,48 @@
+/*M///////////////////////////////////////////////////////////////////////////////////////
+//
+// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
+//
+// By downloading, copying, installing or using the software you agree to this license.
+// If you do not agree to this license, do not download, install,
+// copy or use the software.
+//
+//
+// Intel License Agreement
+// For Open Source Computer Vision Library
+//
+// Copyright (C) 2000, Intel Corporation, all rights reserved.
+// Third party copyrights are property of their respective owners.
+//
+// Redistribution and use in source and binary forms, with or without modification,
+// are permitted provided that the following conditions are met:
+//
+// * Redistribution's of source code must retain the above copyright notice,
+// this list of conditions and the following disclaimer.
+//
+// * Redistribution's in binary form must reproduce the above copyright notice,
+// this list of conditions and the following disclaimer in the documentation
+// and/or other materials provided with the distribution.
+//
+// * The name of Intel Corporation may not be used to endorse or promote products
+// derived from this software without specific prior written permission.
+//
+// This software is provided by the copyright holders and contributors "as is" and
+// any express or implied warranties, including, but not limited to, the implied
+// warranties of merchantability and fitness for a particular purpose are disclaimed.
+// In no event shall the Intel Corporation or contributors be liable for any direct,
+// indirect, incidental, special, exemplary, or consequential damages
+// (including, but not limited to, procurement of substitute goods or services;
+// loss of use, data, or profits; or business interruption) however caused
+// and on any theory of liability, whether in contract, strict liability,
+// or tort (including negligence or otherwise) arising in any way out of
+// the use of this software, even if advised of the possibility of such damage.
+//
+//M*/
+
+#ifndef OPENCV_OLD_HIGHGUI_H
+#define OPENCV_OLD_HIGHGUI_H
+
+#include "opencv2/core/core_c.h"
+#include "opencv2/highgui/highgui_c.h"
+
+#endif
diff --git a/include/opencv/ml.h b/include/opencv/ml.h
new file mode 100755
index 0000000..0c376ba
--- /dev/null
+++ b/include/opencv/ml.h
@@ -0,0 +1,47 @@
+/*M///////////////////////////////////////////////////////////////////////////////////////
+//
+// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
+//
+// By downloading, copying, installing or using the software you agree to this license.
+// If you do not agree to this license, do not download, install,
+// copy or use the software.
+//
+//
+// Intel License Agreement
+//
+// Copyright (C) 2000, Intel Corporation, all rights reserved.
+// Third party copyrights are property of their respective owners.
+//
+// Redistribution and use in source and binary forms, with or without modification,
+// are permitted provided that the following conditions are met:
+//
+// * Redistribution's of source code must retain the above copyright notice,
+// this list of conditions and the following disclaimer.
+//
+// * Redistribution's in binary form must reproduce the above copyright notice,
+// this list of conditions and the following disclaimer in the documentation
+// and/or other materials provided with the distribution.
+//
+// * The name of Intel Corporation may not be used to endorse or promote products
+// derived from this software without specific prior written permission.
+//
+// This software is provided by the copyright holders and contributors "as is" and
+// any express or implied warranties, including, but not limited to, the implied
+// warranties of merchantability and fitness for a particular purpose are disclaimed.
+// In no event shall the Intel Corporation or contributors be liable for any direct,
+// indirect, incidental, special, exemplary, or consequential damages
+// (including, but not limited to, procurement of substitute goods or services;
+// loss of use, data, or profits; or business interruption) however caused
+// and on any theory of liability, whether in contract, strict liability,
+// or tort (including negligence or otherwise) arising in any way out of
+// the use of this software, even if advised of the possibility of such damage.
+//
+//M*/
+
+#ifndef OPENCV_OLD_ML_H
+#define OPENCV_OLD_ML_H
+
+#include "opencv2/core/core_c.h"
+#include "opencv2/ml.hpp"
+
+#endif
diff --git a/include/opencv2/objdetect/detection_based_tracker.hpp b/include/opencv2/objdetect/detection_based_tracker.hpp
new file mode 100755
index 0000000..b93c8f5
--- /dev/null
+++ b/include/opencv2/objdetect/detection_based_tracker.hpp
@@ -0,0 +1,225 @@
+/*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) 2009, Willow Garage Inc., all rights reserved.
+// Copyright (C) 2013, OpenCV Foundation, 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*/
+
+#ifndef OPENCV_OBJDETECT_DBT_HPP
+#define OPENCV_OBJDETECT_DBT_HPP
+
+// After this condition removal update blacklist for bindings: modules/python/common.cmake
+#if defined(__linux__) || defined(LINUX) || defined(__APPLE__) || defined(__ANDROID__) || \
+ (defined(__cplusplus) && __cplusplus > 199711L) || (defined(_MSC_VER) && _MSC_VER >= 1700)
+
+#include <vector>
+
+namespace cv
+{
+
+//! @addtogroup objdetect
+//! @{
+
+class CV_EXPORTS DetectionBasedTracker
+{
+ public:
+ struct CV_EXPORTS Parameters
+ {
+ int maxTrackLifetime;
+ int minDetectionPeriod; //the minimal time between run of the big object detector (on the whole frame) in ms (1000 mean 1 sec), default=0
+
+ Parameters();
+ };
+
+ class IDetector
+ {
+ public:
+ IDetector():
+ minObjSize(96, 96),
+ maxObjSize(INT_MAX, INT_MAX),
+ minNeighbours(2),
+ scaleFactor(1.1f)
+ {}
+
+ virtual void detect(const cv::Mat& image, std::vector<cv::Rect>& objects) = 0;
+
+ void setMinObjectSize(const cv::Size& min)
+ {
+ minObjSize = min;
+ }
+ void setMaxObjectSize(const cv::Size& max)
+ {
+ maxObjSize = max;
+ }
+ cv::Size getMinObjectSize() const
+ {
+ return minObjSize;
+ }
+ cv::Size getMaxObjectSize() const
+ {
+ return maxObjSize;
+ }
+ float getScaleFactor()
+ {
+ return scaleFactor;
+ }
+ void setScaleFactor(float value)
+ {
+ scaleFactor = value;
+ }
+ int getMinNeighbours()
+ {
+ return minNeighbours;
+ }
+ void setMinNeighbours(int value)
+ {
+ minNeighbours = value;
+ }
+ virtual ~IDetector() {}
+
+ protected:
+ cv::Size minObjSize;
+ cv::Size maxObjSize;
+ int minNeighbours;
+ float scaleFactor;
+ };
+
+ DetectionBasedTracker(cv::Ptr<IDetector> mainDetector, cv::Ptr<IDetector> trackingDetector, const Parameters& params);
+ virtual ~DetectionBasedTracker();
+
+ virtual bool run();
+ virtual void stop();
+ virtual void resetTracking();
+
+ virtual void process(const cv::Mat& imageGray);
+
+ bool setParameters(const Parameters& params);
+ const Parameters& getParameters() const;
+
+
+ typedef std::pair<cv::Rect, int> Object;
+ virtual void getObjects(std::vector<cv::Rect>& result) const;
+ virtual void getObjects(std::vector<Object>& result) const;
+
+ enum ObjectStatus
+ {
+ DETECTED_NOT_SHOWN_YET,
+ DETECTED,
+ DETECTED_TEMPORARY_LOST,
+ WRONG_OBJECT
+ };
+ struct ExtObject
+ {
+ int id;
+ cv::Rect location;
+ ObjectStatus status;
+ ExtObject(int _id, cv::Rect _location, ObjectStatus _status)
+ :id(_id), location(_location), status(_status)
+ {
+ }
+ };
+ virtual void getObjects(std::vector<ExtObject>& result) const;
+
+
+ virtual int addObject(const cv::Rect& location); //returns id of the new object
+
+ protected:
+ class SeparateDetectionWork;
+ cv::Ptr<SeparateDetectionWork> separateDetectionWork;
+ friend void* workcycleObjectDetectorFunction(void* p);
+
+ struct InnerParameters
+ {
+ int numLastPositionsToTrack;
+ int numStepsToWaitBeforeFirstShow;
+ int numStepsToTrackWithoutDetectingIfObjectHasNotBeenShown;
+ int numStepsToShowWithoutDetecting;
+
+ float coeffTrackingWindowSize;
+ float coeffObjectSizeToTrack;
+ float coeffObjectSpeedUsingInPrediction;
+
+ InnerParameters();
+ };
+ Parameters parameters;
+ InnerParameters innerParameters;
+
+ struct TrackedObject
+ {
+ typedef std::vector<cv::Rect> PositionsVector;
+
+ PositionsVector lastPositions;
+
+ int numDetectedFrames;
+ int numFramesNotDetected;
+ int id;
+
+ TrackedObject(const cv::Rect& rect):numDetectedFrames(1), numFramesNotDetected(0)
+ {
+ lastPositions.push_back(rect);
+ id=getNextId();
+ };
+
+ static int getNextId()
+ {
+ static int _id=0;
+ return _id++;
+ }
+ };
+
+ int numTrackedSteps;
+ std::vector<TrackedObject> trackedObjects;
+
+ std::vector<float> weightsPositionsSmoothing;
+ std::vector<float> weightsSizesSmoothing;
+
+ cv::Ptr<IDetector> cascadeForTracking;
+
+ void updateTrackedObjects(const std::vector<cv::Rect>& detectedObjects);
+ cv::Rect calcTrackedObjectPositionToShow(int i) const;
+ cv::Rect calcTrackedObjectPositionToShow(int i, ObjectStatus& status) const;
+ void detectInRegion(const cv::Mat& img, const cv::Rect& r, std::vector<cv::Rect>& detectedObjectsInRegions);
+};
+
+//! @} objdetect
+
+} //end of cv namespace
+#endif
+
+#endif
diff --git a/include/opencv2/objdetect/objdetect.hpp b/include/opencv2/objdetect/objdetect.hpp
new file mode 100755
index 0000000..3ee284f
--- /dev/null
+++ b/include/opencv2/objdetect/objdetect.hpp
@@ -0,0 +1,48 @@
+/*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) 2009, Willow Garage Inc., all rights reserved.
+// Copyright (C) 2013, OpenCV Foundation, 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*/
+
+#ifdef __OPENCV_BUILD
+#error this is a compatibility header which should not be used inside the OpenCV library
+#endif
+
+#include "opencv2/objdetect.hpp"
diff --git a/include/opencv2/objdetect/objdetect_c.h b/include/opencv2/objdetect/objdetect_c.h
new file mode 100755
index 0000000..b3ee7f4
--- /dev/null
+++ b/include/opencv2/objdetect/objdetect_c.h
@@ -0,0 +1,165 @@
+/*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) 2009, Willow Garage Inc., all rights reserved.
+// Copyright (C) 2013, OpenCV Foundation, 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*/
+
+#ifndef OPENCV_OBJDETECT_C_H
+#define OPENCV_OBJDETECT_C_H
+
+#include "opencv2/core/core_c.h"
+
+#ifdef __cplusplus
+#include <deque>
+#include <vector>
+
+extern "C" {
+#endif
+
+/** @addtogroup objdetect_c
+ @{
+ */
+
+/****************************************************************************************\
+* Haar-like Object Detection functions *
+\****************************************************************************************/
+
+#define CV_HAAR_MAGIC_VAL 0x42500000
+#define CV_TYPE_NAME_HAAR "opencv-haar-classifier"
+
+#define CV_IS_HAAR_CLASSIFIER( haar ) \
+ ((haar) != NULL && \
+ (((const CvHaarClassifierCascade*)(haar))->flags & CV_MAGIC_MASK)==CV_HAAR_MAGIC_VAL)
+
+#define CV_HAAR_FEATURE_MAX 3
+
+typedef struct CvHaarFeature
+{
+ int tilted;
+ struct
+ {
+ CvRect r;
+ float weight;
+ } rect[CV_HAAR_FEATURE_MAX];
+} CvHaarFeature;
+
+typedef struct CvHaarClassifier
+{
+ int count;
+ CvHaarFeature* haar_feature;
+ float* threshold;
+ int* left;
+ int* right;
+ float* alpha;
+} CvHaarClassifier;
+
+typedef struct CvHaarStageClassifier
+{
+ int count;
+ float threshold;
+ CvHaarClassifier* classifier;
+
+ int next;
+ int child;
+ int parent;
+} CvHaarStageClassifier;
+
+typedef struct CvHidHaarClassifierCascade CvHidHaarClassifierCascade;
+
+typedef struct CvHaarClassifierCascade
+{
+ int flags;
+ int count;
+ CvSize orig_window_size;
+ CvSize real_window_size;
+ double scale;
+ CvHaarStageClassifier* stage_classifier;
+ CvHidHaarClassifierCascade* hid_cascade;
+} CvHaarClassifierCascade;
+
+typedef struct CvAvgComp
+{
+ CvRect rect;
+ int neighbors;
+} CvAvgComp;
+
+/* Loads haar classifier cascade from a directory.
+ It is obsolete: convert your cascade to xml and use cvLoad instead */
+CVAPI(CvHaarClassifierCascade*) cvLoadHaarClassifierCascade(
+ const char* directory, CvSize orig_window_size);
+
+CVAPI(void) cvReleaseHaarClassifierCascade( CvHaarClassifierCascade** cascade );
+
+#define CV_HAAR_DO_CANNY_PRUNING 1
+#define CV_HAAR_SCALE_IMAGE 2
+#define CV_HAAR_FIND_BIGGEST_OBJECT 4
+#define CV_HAAR_DO_ROUGH_SEARCH 8
+
+CVAPI(CvSeq*) cvHaarDetectObjects( const CvArr* image,
+ CvHaarClassifierCascade* cascade, CvMemStorage* storage,
+ double scale_factor CV_DEFAULT(1.1),
+ int min_neighbors CV_DEFAULT(3), int flags CV_DEFAULT(0),
+ CvSize min_size CV_DEFAULT(cvSize(0,0)), CvSize max_size CV_DEFAULT(cvSize(0,0)));
+
+/* sets images for haar classifier cascade */
+CVAPI(void) cvSetImagesForHaarClassifierCascade( CvHaarClassifierCascade* cascade,
+ const CvArr* sum, const CvArr* sqsum,
+ const CvArr* tilted_sum, double scale );
+
+/* runs the cascade on the specified window */
+CVAPI(int) cvRunHaarClassifierCascade( const CvHaarClassifierCascade* cascade,
+ CvPoint pt, int start_stage CV_DEFAULT(0));
+
+/** @} objdetect_c */
+
+#ifdef __cplusplus
+}
+
+CV_EXPORTS CvSeq* cvHaarDetectObjectsForROC( const CvArr* image,
+ CvHaarClassifierCascade* cascade, CvMemStorage* storage,
+ std::vector<int>& rejectLevels, std::vector<double>& levelWeightds,
+ double scale_factor = 1.1,
+ int min_neighbors = 3, int flags = 0,
+ CvSize min_size = cvSize(0, 0), CvSize max_size = cvSize(0, 0),
+ bool outputRejectLevels = false );
+
+#endif
+
+#endif /* OPENCV_OBJDETECT_C_H */
diff --git a/include/opencv2/photo.hpp b/include/opencv2/photo.hpp
new file mode 100755
index 0000000..a445dd3
--- /dev/null
+++ b/include/opencv2/photo.hpp
@@ -0,0 +1,870 @@
+/*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*/
+
+#ifndef OPENCV_PHOTO_HPP
+#define OPENCV_PHOTO_HPP
+
+#include "opencv2/core.hpp"
+#include "opencv2/imgproc.hpp"
+
+/**
+@defgroup photo Computational Photography
+@{
+ @defgroup photo_denoise Denoising
+ @defgroup photo_hdr HDR imaging
+
+This section describes high dynamic range imaging algorithms namely tonemapping, exposure alignment,
+camera calibration with multiple exposures and exposure fusion.
+
+ @defgroup photo_clone Seamless Cloning
+ @defgroup photo_render Non-Photorealistic Rendering
+ @defgroup photo_c C API
+@}
+ */
+
+namespace cv
+{
+
+//! @addtogroup photo
+//! @{
+
+//! the inpainting algorithm
+enum
+{
+ INPAINT_NS = 0, // Navier-Stokes algorithm
+ INPAINT_TELEA = 1 // A. Telea algorithm
+};
+
+enum
+{
+ NORMAL_CLONE = 1,
+ MIXED_CLONE = 2,
+ MONOCHROME_TRANSFER = 3
+};
+
+enum
+{
+ RECURS_FILTER = 1,
+ NORMCONV_FILTER = 2
+};
+
+/** @brief Restores the selected region in an image using the region neighborhood.
+
+@param src Input 8-bit 1-channel or 3-channel image.
+@param inpaintMask Inpainting mask, 8-bit 1-channel image. Non-zero pixels indicate the area that
+needs to be inpainted.
+@param dst Output image with the same size and type as src .
+@param inpaintRadius Radius of a circular neighborhood of each point inpainted that is considered
+by the algorithm.
+@param flags Inpainting method that could be one of the following:
+- **INPAINT_NS** Navier-Stokes based method [Navier01]
+- **INPAINT_TELEA** Method by Alexandru Telea @cite Telea04 .
+
+The function reconstructs the selected image area from the pixel near the area boundary. The
+function may be used to remove dust and scratches from a scanned photo, or to remove undesirable
+objects from still images or video. See <http://en.wikipedia.org/wiki/Inpainting> for more details.
+
+@note
+ - An example using the inpainting technique can be found at
+ opencv_source_code/samples/cpp/inpaint.cpp
+ - (Python) An example using the inpainting technique can be found at
+ opencv_source_code/samples/python/inpaint.py
+ */
+CV_EXPORTS_W void inpaint( InputArray src, InputArray inpaintMask,
+ OutputArray dst, double inpaintRadius, int flags );
+
+//! @addtogroup photo_denoise
+//! @{
+
+/** @brief Perform image denoising using Non-local Means Denoising algorithm
+<http://www.ipol.im/pub/algo/bcm_non_local_means_denoising/> with several computational
+optimizations. Noise expected to be a gaussian white noise
+
+@param src Input 8-bit 1-channel, 2-channel, 3-channel or 4-channel image.
+@param dst Output image with the same size and type as src .
+@param templateWindowSize Size in pixels of the template patch that is used to compute weights.
+Should be odd. Recommended value 7 pixels
+@param searchWindowSize Size in pixels of the window that is used to compute weighted average for
+given pixel. Should be odd. Affect performance linearly: greater searchWindowsSize - greater
+denoising time. Recommended value 21 pixels
+@param h Parameter regulating filter strength. Big h value perfectly removes noise but also
+removes image details, smaller h value preserves details but also preserves some noise
+
+This function expected to be applied to grayscale images. For colored images look at
+fastNlMeansDenoisingColored. Advanced usage of this functions can be manual denoising of colored
+image in different colorspaces. Such approach is used in fastNlMeansDenoisingColored by converting
+image to CIELAB colorspace and then separately denoise L and AB components with different h
+parameter.
+ */
+CV_EXPORTS_W void fastNlMeansDenoising( InputArray src, OutputArray dst, float h = 3,
+ int templateWindowSize = 7, int searchWindowSize = 21);
+
+/** @brief Perform image denoising using Non-local Means Denoising algorithm
+<http://www.ipol.im/pub/algo/bcm_non_local_means_denoising/> with several computational
+optimizations. Noise expected to be a gaussian white noise
+
+@param src Input 8-bit or 16-bit (only with NORM_L1) 1-channel,
+2-channel, 3-channel or 4-channel image.
+@param dst Output image with the same size and type as src .
+@param templateWindowSize Size in pixels of the template patch that is used to compute weights.
+Should be odd. Recommended value 7 pixels
+@param searchWindowSize Size in pixels of the window that is used to compute weighted average for
+given pixel. Should be odd. Affect performance linearly: greater searchWindowsSize - greater
+denoising time. Recommended value 21 pixels
+@param h Array of parameters regulating filter strength, either one
+parameter applied to all channels or one per channel in dst. Big h value
+perfectly removes noise but also removes image details, smaller h
+value preserves details but also preserves some noise
+@param normType Type of norm used for weight calculation. Can be either NORM_L2 or NORM_L1
+
+This function expected to be applied to grayscale images. For colored images look at
+fastNlMeansDenoisingColored. Advanced usage of this functions can be manual denoising of colored
+image in different colorspaces. Such approach is used in fastNlMeansDenoisingColored by converting
+image to CIELAB colorspace and then separately denoise L and AB components with different h
+parameter.
+ */
+CV_EXPORTS_W void fastNlMeansDenoising( InputArray src, OutputArray dst,
+ const std::vector<float>& h,
+ int templateWindowSize = 7, int searchWindowSize = 21,
+ int normType = NORM_L2);
+
+/** @brief Modification of fastNlMeansDenoising function for colored images
+
+@param src Input 8-bit 3-channel image.
+@param dst Output image with the same size and type as src .
+@param templateWindowSize Size in pixels of the template patch that is used to compute weights.
+Should be odd. Recommended value 7 pixels
+@param searchWindowSize Size in pixels of the window that is used to compute weighted average for
+given pixel. Should be odd. Affect performance linearly: greater searchWindowsSize - greater
+denoising time. Recommended value 21 pixels
+@param h Parameter regulating filter strength for luminance component. Bigger h value perfectly
+removes noise but also removes image details, smaller h value preserves details but also preserves
+some noise
+@param hColor The same as h but for color components. For most images value equals 10
+will be enough to remove colored noise and do not distort colors
+
+The function converts image to CIELAB colorspace and then separately denoise L and AB components
+with given h parameters using fastNlMeansDenoising function.
+ */
+CV_EXPORTS_W void fastNlMeansDenoisingColored( InputArray src, OutputArray dst,
+ float h = 3, float hColor = 3,
+ int templateWindowSize = 7, int searchWindowSize = 21);
+
+/** @brief Modification of fastNlMeansDenoising function for images sequence where consequtive images have been
+captured in small period of time. For example video. This version of the function is for grayscale
+images or for manual manipulation with colorspaces. For more details see
+<http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.131.6394>
+
+@param srcImgs Input 8-bit 1-channel, 2-channel, 3-channel or
+4-channel images sequence. All images should have the same type and
+size.
+@param imgToDenoiseIndex Target image to denoise index in srcImgs sequence
+@param temporalWindowSize Number of surrounding images to use for target image denoising. Should
+be odd. Images from imgToDenoiseIndex - temporalWindowSize / 2 to
+imgToDenoiseIndex - temporalWindowSize / 2 from srcImgs will be used to denoise
+srcImgs[imgToDenoiseIndex] image.
+@param dst Output image with the same size and type as srcImgs images.
+@param templateWindowSize Size in pixels of the template patch that is used to compute weights.
+Should be odd. Recommended value 7 pixels
+@param searchWindowSize Size in pixels of the window that is used to compute weighted average for
+given pixel. Should be odd. Affect performance linearly: greater searchWindowsSize - greater
+denoising time. Recommended value 21 pixels
+@param h Parameter regulating filter strength. Bigger h value
+perfectly removes noise but also removes image details, smaller h
+value preserves details but also preserves some noise
+ */
+CV_EXPORTS_W void fastNlMeansDenoisingMulti( InputArrayOfArrays srcImgs, OutputArray dst,
+ int imgToDenoiseIndex, int temporalWindowSize,
+ float h = 3, int templateWindowSize = 7, int searchWindowSize = 21);
+
+/** @brief Modification of fastNlMeansDenoising function for images sequence where consequtive images have been
+captured in small period of time. For example video. This version of the function is for grayscale
+images or for manual manipulation with colorspaces. For more details see
+<http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.131.6394>
+
+@param srcImgs Input 8-bit or 16-bit (only with NORM_L1) 1-channel,
+2-channel, 3-channel or 4-channel images sequence. All images should
+have the same type and size.
+@param imgToDenoiseIndex Target image to denoise index in srcImgs sequence
+@param temporalWindowSize Number of surrounding images to use for target image denoising. Should
+be odd. Images from imgToDenoiseIndex - temporalWindowSize / 2 to
+imgToDenoiseIndex - temporalWindowSize / 2 from srcImgs will be used to denoise
+srcImgs[imgToDenoiseIndex] image.
+@param dst Output image with the same size and type as srcImgs images.
+@param templateWindowSize Size in pixels of the template patch that is used to compute weights.
+Should be odd. Recommended value 7 pixels
+@param searchWindowSize Size in pixels of the window that is used to compute weighted average for
+given pixel. Should be odd. Affect performance linearly: greater searchWindowsSize - greater
+denoising time. Recommended value 21 pixels
+@param h Array of parameters regulating filter strength, either one
+parameter applied to all channels or one per channel in dst. Big h value
+perfectly removes noise but also removes image details, smaller h
+value preserves details but also preserves some noise
+@param normType Type of norm used for weight calculation. Can be either NORM_L2 or NORM_L1
+ */
+CV_EXPORTS_W void fastNlMeansDenoisingMulti( InputArrayOfArrays srcImgs, OutputArray dst,
+ int imgToDenoiseIndex, int temporalWindowSize,
+ const std::vector<float>& h,
+ int templateWindowSize = 7, int searchWindowSize = 21,
+ int normType = NORM_L2);
+
+/** @brief Modification of fastNlMeansDenoisingMulti function for colored images sequences
+
+@param srcImgs Input 8-bit 3-channel images sequence. All images should have the same type and
+size.
+@param imgToDenoiseIndex Target image to denoise index in srcImgs sequence
+@param temporalWindowSize Number of surrounding images to use for target image denoising. Should
+be odd. Images from imgToDenoiseIndex - temporalWindowSize / 2 to
+imgToDenoiseIndex - temporalWindowSize / 2 from srcImgs will be used to denoise
+srcImgs[imgToDenoiseIndex] image.
+@param dst Output image with the same size and type as srcImgs images.
+@param templateWindowSize Size in pixels of the template patch that is used to compute weights.
+Should be odd. Recommended value 7 pixels
+@param searchWindowSize Size in pixels of the window that is used to compute weighted average for
+given pixel. Should be odd. Affect performance linearly: greater searchWindowsSize - greater
+denoising time. Recommended value 21 pixels
+@param h Parameter regulating filter strength for luminance component. Bigger h value perfectly
+removes noise but also removes image details, smaller h value preserves details but also preserves
+some noise.
+@param hColor The same as h but for color components.
+
+The function converts images to CIELAB colorspace and then separately denoise L and AB components
+with given h parameters using fastNlMeansDenoisingMulti function.
+ */
+CV_EXPORTS_W void fastNlMeansDenoisingColoredMulti( InputArrayOfArrays srcImgs, OutputArray dst,
+ int imgToDenoiseIndex, int temporalWindowSize,
+ float h = 3, float hColor = 3,
+ int templateWindowSize = 7, int searchWindowSize = 21);
+
+/** @brief Primal-dual algorithm is an algorithm for solving special types of variational problems (that is,
+finding a function to minimize some functional). As the image denoising, in particular, may be seen
+as the variational problem, primal-dual algorithm then can be used to perform denoising and this is
+exactly what is implemented.
+
+It should be noted, that this implementation was taken from the July 2013 blog entry
+@cite MA13 , which also contained (slightly more general) ready-to-use source code on Python.
+Subsequently, that code was rewritten on C++ with the usage of openCV by Vadim Pisarevsky at the end
+of July 2013 and finally it was slightly adapted by later authors.
+
+Although the thorough discussion and justification of the algorithm involved may be found in
+@cite ChambolleEtAl, it might make sense to skim over it here, following @cite MA13 . To begin
+with, we consider the 1-byte gray-level images as the functions from the rectangular domain of
+pixels (it may be seen as set
+\f$\left\{(x,y)\in\mathbb{N}\times\mathbb{N}\mid 1\leq x\leq n,\;1\leq y\leq m\right\}\f$ for some
+\f$m,\;n\in\mathbb{N}\f$) into \f$\{0,1,\dots,255\}\f$. We shall denote the noised images as \f$f_i\f$ and with
+this view, given some image \f$x\f$ of the same size, we may measure how bad it is by the formula
+
+\f[\left\|\left\|\nabla x\right\|\right\| + \lambda\sum_i\left\|\left\|x-f_i\right\|\right\|\f]
+
+\f$\|\|\cdot\|\|\f$ here denotes \f$L_2\f$-norm and as you see, the first addend states that we want our
+image to be smooth (ideally, having zero gradient, thus being constant) and the second states that
+we want our result to be close to the observations we've got. If we treat \f$x\f$ as a function, this is
+exactly the functional what we seek to minimize and here the Primal-Dual algorithm comes into play.
+
+@param observations This array should contain one or more noised versions of the image that is to
+be restored.
+@param result Here the denoised image will be stored. There is no need to do pre-allocation of
+storage space, as it will be automatically allocated, if necessary.
+@param lambda Corresponds to \f$\lambda\f$ in the formulas above. As it is enlarged, the smooth
+(blurred) images are treated more favorably than detailed (but maybe more noised) ones. Roughly
+speaking, as it becomes smaller, the result will be more blur but more sever outliers will be
+removed.
+@param niters Number of iterations that the algorithm will run. Of course, as more iterations as
+better, but it is hard to quantitatively refine this statement, so just use the default and
+increase it if the results are poor.
+ */
+CV_EXPORTS_W void denoise_TVL1(const std::vector<Mat>& observations,Mat& result, double lambda=1.0, int niters=30);
+
+//! @} photo_denoise
+
+//! @addtogroup photo_hdr
+//! @{
+
+enum { LDR_SIZE = 256 };
+
+/** @brief Base class for tonemapping algorithms - tools that are used to map HDR image to 8-bit range.
+ */
+class CV_EXPORTS_W Tonemap : public Algorithm
+{
+public:
+ /** @brief Tonemaps image
+
+ @param src source image - 32-bit 3-channel Mat
+ @param dst destination image - 32-bit 3-channel Mat with values in [0, 1] range
+ */
+ CV_WRAP virtual void process(InputArray src, OutputArray dst) = 0;
+
+ CV_WRAP virtual float getGamma() const = 0;
+ CV_WRAP virtual void setGamma(float gamma) = 0;
+};
+
+/** @brief Creates simple linear mapper with gamma correction
+
+@param gamma positive value for gamma correction. Gamma value of 1.0 implies no correction, gamma
+equal to 2.2f is suitable for most displays.
+Generally gamma \> 1 brightens the image and gamma \< 1 darkens it.
+ */
+CV_EXPORTS_W Ptr<Tonemap> createTonemap(float gamma = 1.0f);
+
+/** @brief Adaptive logarithmic mapping is a fast global tonemapping algorithm that scales the image in
+logarithmic domain.
+
+Since it's a global operator the same function is applied to all the pixels, it is controlled by the
+bias parameter.
+
+Optional saturation enhancement is possible as described in @cite FL02 .
+
+For more information see @cite DM03 .
+ */
+class CV_EXPORTS_W TonemapDrago : public Tonemap
+{
+public:
+
+ CV_WRAP virtual float getSaturation() const = 0;
+ CV_WRAP virtual void setSaturation(float saturation) = 0;
+
+ CV_WRAP virtual float getBias() const = 0;
+ CV_WRAP virtual void setBias(float bias) = 0;
+};
+
+/** @brief Creates TonemapDrago object
+
+@param gamma gamma value for gamma correction. See createTonemap
+@param saturation positive saturation enhancement value. 1.0 preserves saturation, values greater
+than 1 increase saturation and values less than 1 decrease it.
+@param bias value for bias function in [0, 1] range. Values from 0.7 to 0.9 usually give best
+results, default value is 0.85.
+ */
+CV_EXPORTS_W Ptr<TonemapDrago> createTonemapDrago(float gamma = 1.0f, float saturation = 1.0f, float bias = 0.85f);
+
+/** @brief This algorithm decomposes image into two layers: base layer and detail layer using bilateral filter
+and compresses contrast of the base layer thus preserving all the details.
+
+This implementation uses regular bilateral filter from opencv.
+
+Saturation enhancement is possible as in ocvTonemapDrago.
+
+For more information see @cite DD02 .
+ */
+class CV_EXPORTS_W TonemapDurand : public Tonemap
+{
+public:
+
+ CV_WRAP virtual float getSaturation() const = 0;
+ CV_WRAP virtual void setSaturation(float saturation) = 0;
+
+ CV_WRAP virtual float getContrast() const = 0;
+ CV_WRAP virtual void setContrast(float contrast) = 0;
+
+ CV_WRAP virtual float getSigmaSpace() const = 0;
+ CV_WRAP virtual void setSigmaSpace(float sigma_space) = 0;
+
+ CV_WRAP virtual float getSigmaColor() const = 0;
+ CV_WRAP virtual void setSigmaColor(float sigma_color) = 0;
+};
+
+/** @brief Creates TonemapDurand object
+
+@param gamma gamma value for gamma correction. See createTonemap
+@param contrast resulting contrast on logarithmic scale, i. e. log(max / min), where max and min
+are maximum and minimum luminance values of the resulting image.
+@param saturation saturation enhancement value. See createTonemapDrago
+@param sigma_space bilateral filter sigma in color space
+@param sigma_color bilateral filter sigma in coordinate space
+ */
+CV_EXPORTS_W Ptr<TonemapDurand>
+createTonemapDurand(float gamma = 1.0f, float contrast = 4.0f, float saturation = 1.0f, float sigma_space = 2.0f, float sigma_color = 2.0f);
+
+/** @brief This is a global tonemapping operator that models human visual system.
+
+Mapping function is controlled by adaptation parameter, that is computed using light adaptation and
+color adaptation.
+
+For more information see @cite RD05 .
+ */
+class CV_EXPORTS_W TonemapReinhard : public Tonemap
+{
+public:
+ CV_WRAP virtual float getIntensity() const = 0;
+ CV_WRAP virtual void setIntensity(float intensity) = 0;
+
+ CV_WRAP virtual float getLightAdaptation() const = 0;
+ CV_WRAP virtual void setLightAdaptation(float light_adapt) = 0;
+
+ CV_WRAP virtual float getColorAdaptation() const = 0;
+ CV_WRAP virtual void setColorAdaptation(float color_adapt) = 0;
+};
+
+/** @brief Creates TonemapReinhard object
+
+@param gamma gamma value for gamma correction. See createTonemap
+@param intensity result intensity in [-8, 8] range. Greater intensity produces brighter results.
+@param light_adapt light adaptation in [0, 1] range. If 1 adaptation is based only on pixel
+value, if 0 it's global, otherwise it's a weighted mean of this two cases.
+@param color_adapt chromatic adaptation in [0, 1] range. If 1 channels are treated independently,
+if 0 adaptation level is the same for each channel.
+ */
+CV_EXPORTS_W Ptr<TonemapReinhard>
+createTonemapReinhard(float gamma = 1.0f, float intensity = 0.0f, float light_adapt = 1.0f, float color_adapt = 0.0f);
+
+/** @brief This algorithm transforms image to contrast using gradients on all levels of gaussian pyramid,
+transforms contrast values to HVS response and scales the response. After this the image is
+reconstructed from new contrast values.
+
+For more information see @cite MM06 .
+ */
+class CV_EXPORTS_W TonemapMantiuk : public Tonemap
+{
+public:
+ CV_WRAP virtual float getScale() const = 0;
+ CV_WRAP virtual void setScale(float scale) = 0;
+
+ CV_WRAP virtual float getSaturation() const = 0;
+ CV_WRAP virtual void setSaturation(float saturation) = 0;
+};
+
+/** @brief Creates TonemapMantiuk object
+
+@param gamma gamma value for gamma correction. See createTonemap
+@param scale contrast scale factor. HVS response is multiplied by this parameter, thus compressing
+dynamic range. Values from 0.6 to 0.9 produce best results.
+@param saturation saturation enhancement value. See createTonemapDrago
+ */
+CV_EXPORTS_W Ptr<TonemapMantiuk>
+createTonemapMantiuk(float gamma = 1.0f, float scale = 0.7f, float saturation = 1.0f);
+
+/** @brief The base class for algorithms that align images of the same scene with different exposures
+ */
+class CV_EXPORTS_W AlignExposures : public Algorithm
+{
+public:
+ /** @brief Aligns images
+
+ @param src vector of input images
+ @param dst vector of aligned images
+ @param times vector of exposure time values for each image
+ @param response 256x1 matrix with inverse camera response function for each pixel value, it should
+ have the same number of channels as images.
+ */
+ CV_WRAP virtual void process(InputArrayOfArrays src, std::vector<Mat>& dst,
+ InputArray times, InputArray response) = 0;
+};
+
+/** @brief This algorithm converts images to median threshold bitmaps (1 for pixels brighter than median
+luminance and 0 otherwise) and than aligns the resulting bitmaps using bit operations.
+
+It is invariant to exposure, so exposure values and camera response are not necessary.
+
+In this implementation new image regions are filled with zeros.
+
+For more information see @cite GW03 .
+ */
+class CV_EXPORTS_W AlignMTB : public AlignExposures
+{
+public:
+ CV_WRAP virtual void process(InputArrayOfArrays src, std::vector<Mat>& dst,
+ InputArray times, InputArray response) = 0;
+
+ /** @brief Short version of process, that doesn't take extra arguments.
+
+ @param src vector of input images
+ @param dst vector of aligned images
+ */
+ CV_WRAP virtual void process(InputArrayOfArrays src, std::vector<Mat>& dst) = 0;
+
+ /** @brief Calculates shift between two images, i. e. how to shift the second image to correspond it with the
+ first.
+
+ @param img0 first image
+ @param img1 second image
+ */
+ CV_WRAP virtual Point calculateShift(InputArray img0, InputArray img1) = 0;
+ /** @brief Helper function, that shift Mat filling new regions with zeros.
+
+ @param src input image
+ @param dst result image
+ @param shift shift value
+ */
+ CV_WRAP virtual void shiftMat(InputArray src, OutputArray dst, const Point shift) = 0;
+ /** @brief Computes median threshold and exclude bitmaps of given image.
+
+ @param img input image
+ @param tb median threshold bitmap
+ @param eb exclude bitmap
+ */
+ CV_WRAP virtual void computeBitmaps(InputArray img, OutputArray tb, OutputArray eb) = 0;
+
+ CV_WRAP virtual int getMaxBits() const = 0;
+ CV_WRAP virtual void setMaxBits(int max_bits) = 0;
+
+ CV_WRAP virtual int getExcludeRange() const = 0;
+ CV_WRAP virtual void setExcludeRange(int exclude_range) = 0;
+
+ CV_WRAP virtual bool getCut() const = 0;
+ CV_WRAP virtual void setCut(bool value) = 0;
+};
+
+/** @brief Creates AlignMTB object
+
+@param max_bits logarithm to the base 2 of maximal shift in each dimension. Values of 5 and 6 are
+usually good enough (31 and 63 pixels shift respectively).
+@param exclude_range range for exclusion bitmap that is constructed to suppress noise around the
+median value.
+@param cut if true cuts images, otherwise fills the new regions with zeros.
+ */
+CV_EXPORTS_W Ptr<AlignMTB> createAlignMTB(int max_bits = 6, int exclude_range = 4, bool cut = true);
+
+/** @brief The base class for camera response calibration algorithms.
+ */
+class CV_EXPORTS_W CalibrateCRF : public Algorithm
+{
+public:
+ /** @brief Recovers inverse camera response.
+
+ @param src vector of input images
+ @param dst 256x1 matrix with inverse camera response function
+ @param times vector of exposure time values for each image
+ */
+ CV_WRAP virtual void process(InputArrayOfArrays src, OutputArray dst, InputArray times) = 0;
+};
+
+/** @brief Inverse camera response function is extracted for each brightness value by minimizing an objective
+function as linear system. Objective function is constructed using pixel values on the same position
+in all images, extra term is added to make the result smoother.
+
+For more information see @cite DM97 .
+ */
+class CV_EXPORTS_W CalibrateDebevec : public CalibrateCRF
+{
+public:
+ CV_WRAP virtual float getLambda() const = 0;
+ CV_WRAP virtual void setLambda(float lambda) = 0;
+
+ CV_WRAP virtual int getSamples() const = 0;
+ CV_WRAP virtual void setSamples(int samples) = 0;
+
+ CV_WRAP virtual bool getRandom() const = 0;
+ CV_WRAP virtual void setRandom(bool random) = 0;
+};
+
+/** @brief Creates CalibrateDebevec object
+
+@param samples number of pixel locations to use
+@param lambda smoothness term weight. Greater values produce smoother results, but can alter the
+response.
+@param random if true sample pixel locations are chosen at random, otherwise the form a
+rectangular grid.
+ */
+CV_EXPORTS_W Ptr<CalibrateDebevec> createCalibrateDebevec(int samples = 70, float lambda = 10.0f, bool random = false);
+
+/** @brief Inverse camera response function is extracted for each brightness value by minimizing an objective
+function as linear system. This algorithm uses all image pixels.
+
+For more information see @cite RB99 .
+ */
+class CV_EXPORTS_W CalibrateRobertson : public CalibrateCRF
+{
+public:
+ CV_WRAP virtual int getMaxIter() const = 0;
+ CV_WRAP virtual void setMaxIter(int max_iter) = 0;
+
+ CV_WRAP virtual float getThreshold() const = 0;
+ CV_WRAP virtual void setThreshold(float threshold) = 0;
+
+ CV_WRAP virtual Mat getRadiance() const = 0;
+};
+
+/** @brief Creates CalibrateRobertson object
+
+@param max_iter maximal number of Gauss-Seidel solver iterations.
+@param threshold target difference between results of two successive steps of the minimization.
+ */
+CV_EXPORTS_W Ptr<CalibrateRobertson> createCalibrateRobertson(int max_iter = 30, float threshold = 0.01f);
+
+/** @brief The base class algorithms that can merge exposure sequence to a single image.
+ */
+class CV_EXPORTS_W MergeExposures : public Algorithm
+{
+public:
+ /** @brief Merges images.
+
+ @param src vector of input images
+ @param dst result image
+ @param times vector of exposure time values for each image
+ @param response 256x1 matrix with inverse camera response function for each pixel value, it should
+ have the same number of channels as images.
+ */
+ CV_WRAP virtual void process(InputArrayOfArrays src, OutputArray dst,
+ InputArray times, InputArray response) = 0;
+};
+
+/** @brief The resulting HDR image is calculated as weighted average of the exposures considering exposure
+values and camera response.
+
+For more information see @cite DM97 .
+ */
+class CV_EXPORTS_W MergeDebevec : public MergeExposures
+{
+public:
+ CV_WRAP virtual void process(InputArrayOfArrays src, OutputArray dst,
+ InputArray times, InputArray response) = 0;
+ CV_WRAP virtual void process(InputArrayOfArrays src, OutputArray dst, InputArray times) = 0;
+};
+
+/** @brief Creates MergeDebevec object
+ */
+CV_EXPORTS_W Ptr<MergeDebevec> createMergeDebevec();
+
+/** @brief Pixels are weighted using contrast, saturation and well-exposedness measures, than images are
+combined using laplacian pyramids.
+
+The resulting image weight is constructed as weighted average of contrast, saturation and
+well-exposedness measures.
+
+The resulting image doesn't require tonemapping and can be converted to 8-bit image by multiplying
+by 255, but it's recommended to apply gamma correction and/or linear tonemapping.
+
+For more information see @cite MK07 .
+ */
+class CV_EXPORTS_W MergeMertens : public MergeExposures
+{
+public:
+ CV_WRAP virtual void process(InputArrayOfArrays src, OutputArray dst,
+ InputArray times, InputArray response) = 0;
+ /** @brief Short version of process, that doesn't take extra arguments.
+
+ @param src vector of input images
+ @param dst result image
+ */
+ CV_WRAP virtual void process(InputArrayOfArrays src, OutputArray dst) = 0;
+
+ CV_WRAP virtual float getContrastWeight() const = 0;
+ CV_WRAP virtual void setContrastWeight(float contrast_weiht) = 0;
+
+ CV_WRAP virtual float getSaturationWeight() const = 0;
+ CV_WRAP virtual void setSaturationWeight(float saturation_weight) = 0;
+
+ CV_WRAP virtual float getExposureWeight() const = 0;
+ CV_WRAP virtual void setExposureWeight(float exposure_weight) = 0;
+};
+
+/** @brief Creates MergeMertens object
+
+@param contrast_weight contrast measure weight. See MergeMertens.
+@param saturation_weight saturation measure weight
+@param exposure_weight well-exposedness measure weight
+ */
+CV_EXPORTS_W Ptr<MergeMertens>
+createMergeMertens(float contrast_weight = 1.0f, float saturation_weight = 1.0f, float exposure_weight = 0.0f);
+
+/** @brief The resulting HDR image is calculated as weighted average of the exposures considering exposure
+values and camera response.
+
+For more information see @cite RB99 .
+ */
+class CV_EXPORTS_W MergeRobertson : public MergeExposures
+{
+public:
+ CV_WRAP virtual void process(InputArrayOfArrays src, OutputArray dst,
+ InputArray times, InputArray response) = 0;
+ CV_WRAP virtual void process(InputArrayOfArrays src, OutputArray dst, InputArray times) = 0;
+};
+
+/** @brief Creates MergeRobertson object
+ */
+CV_EXPORTS_W Ptr<MergeRobertson> createMergeRobertson();
+
+//! @} photo_hdr
+
+/** @brief Transforms a color image to a grayscale image. It is a basic tool in digital printing, stylized
+black-and-white photograph rendering, and in many single channel image processing applications
+@cite CL12 .
+
+@param src Input 8-bit 3-channel image.
+@param grayscale Output 8-bit 1-channel image.
+@param color_boost Output 8-bit 3-channel image.
+
+This function is to be applied on color images.
+ */
+CV_EXPORTS_W void decolor( InputArray src, OutputArray grayscale, OutputArray color_boost);
+
+//! @addtogroup photo_clone
+//! @{
+
+/** @brief Image editing tasks concern either global changes (color/intensity corrections, filters,
+deformations) or local changes concerned to a selection. Here we are interested in achieving local
+changes, ones that are restricted to a region manually selected (ROI), in a seamless and effortless
+manner. The extent of the changes ranges from slight distortions to complete replacement by novel
+content @cite PM03 .
+
+@param src Input 8-bit 3-channel image.
+@param dst Input 8-bit 3-channel image.
+@param mask Input 8-bit 1 or 3-channel image.
+@param p Point in dst image where object is placed.
+@param blend Output image with the same size and type as dst.
+@param flags Cloning method that could be one of the following:
+- **NORMAL_CLONE** The power of the method is fully expressed when inserting objects with
+complex outlines into a new background
+- **MIXED_CLONE** The classic method, color-based selection and alpha masking might be time
+consuming and often leaves an undesirable halo. Seamless cloning, even averaged with the
+original image, is not effective. Mixed seamless cloning based on a loose selection proves
+effective.
+- **FEATURE_EXCHANGE** Feature exchange allows the user to easily replace certain features of
+one object by alternative features.
+ */
+CV_EXPORTS_W void seamlessClone( InputArray src, InputArray dst, InputArray mask, Point p,
+ OutputArray blend, int flags);
+
+/** @brief Given an original color image, two differently colored versions of this image can be mixed
+seamlessly.
+
+@param src Input 8-bit 3-channel image.
+@param mask Input 8-bit 1 or 3-channel image.
+@param dst Output image with the same size and type as src .
+@param red_mul R-channel multiply factor.
+@param green_mul G-channel multiply factor.
+@param blue_mul B-channel multiply factor.
+
+Multiplication factor is between .5 to 2.5.
+ */
+CV_EXPORTS_W void colorChange(InputArray src, InputArray mask, OutputArray dst, float red_mul = 1.0f,
+ float green_mul = 1.0f, float blue_mul = 1.0f);
+
+/** @brief Applying an appropriate non-linear transformation to the gradient field inside the selection and
+then integrating back with a Poisson solver, modifies locally the apparent illumination of an image.
+
+@param src Input 8-bit 3-channel image.
+@param mask Input 8-bit 1 or 3-channel image.
+@param dst Output image with the same size and type as src.
+@param alpha Value ranges between 0-2.
+@param beta Value ranges between 0-2.
+
+This is useful to highlight under-exposed foreground objects or to reduce specular reflections.
+ */
+CV_EXPORTS_W void illuminationChange(InputArray src, InputArray mask, OutputArray dst,
+ float alpha = 0.2f, float beta = 0.4f);
+
+/** @brief By retaining only the gradients at edge locations, before integrating with the Poisson solver, one
+washes out the texture of the selected region, giving its contents a flat aspect. Here Canny Edge
+Detector is used.
+
+@param src Input 8-bit 3-channel image.
+@param mask Input 8-bit 1 or 3-channel image.
+@param dst Output image with the same size and type as src.
+@param low_threshold Range from 0 to 100.
+@param high_threshold Value \> 100.
+@param kernel_size The size of the Sobel kernel to be used.
+
+**NOTE:**
+
+The algorithm assumes that the color of the source image is close to that of the destination. This
+assumption means that when the colors don't match, the source image color gets tinted toward the
+color of the destination image.
+ */
+CV_EXPORTS_W void textureFlattening(InputArray src, InputArray mask, OutputArray dst,
+ float low_threshold = 30, float high_threshold = 45,
+ int kernel_size = 3);
+
+//! @} photo_clone
+
+//! @addtogroup photo_render
+//! @{
+
+/** @brief Filtering is the fundamental operation in image and video processing. Edge-preserving smoothing
+filters are used in many different applications @cite EM11 .
+
+@param src Input 8-bit 3-channel image.
+@param dst Output 8-bit 3-channel image.
+@param flags Edge preserving filters:
+- **RECURS_FILTER** = 1
+- **NORMCONV_FILTER** = 2
+@param sigma_s Range between 0 to 200.
+@param sigma_r Range between 0 to 1.
+ */
+CV_EXPORTS_W void edgePreservingFilter(InputArray src, OutputArray dst, int flags = 1,
+ float sigma_s = 60, float sigma_r = 0.4f);
+
+/** @brief This filter enhances the details of a particular image.
+
+@param src Input 8-bit 3-channel image.
+@param dst Output image with the same size and type as src.
+@param sigma_s Range between 0 to 200.
+@param sigma_r Range between 0 to 1.
+ */
+CV_EXPORTS_W void detailEnhance(InputArray src, OutputArray dst, float sigma_s = 10,
+ float sigma_r = 0.15f);
+
+/** @brief Pencil-like non-photorealistic line drawing
+
+@param src Input 8-bit 3-channel image.
+@param dst1 Output 8-bit 1-channel image.
+@param dst2 Output image with the same size and type as src.
+@param sigma_s Range between 0 to 200.
+@param sigma_r Range between 0 to 1.
+@param shade_factor Range between 0 to 0.1.
+ */
+CV_EXPORTS_W void pencilSketch(InputArray src, OutputArray dst1, OutputArray dst2,
+ float sigma_s = 60, float sigma_r = 0.07f, float shade_factor = 0.02f);
+
+/** @brief Stylization aims to produce digital imagery with a wide variety of effects not focused on
+photorealism. Edge-aware filters are ideal for stylization, as they can abstract regions of low
+contrast while preserving, or enhancing, high-contrast features.
+
+@param src Input 8-bit 3-channel image.
+@param dst Output image with the same size and type as src.
+@param sigma_s Range between 0 to 200.
+@param sigma_r Range between 0 to 1.
+ */
+CV_EXPORTS_W void stylization(InputArray src, OutputArray dst, float sigma_s = 60,
+ float sigma_r = 0.45f);
+
+//! @} photo_render
+
+//! @} photo
+
+} // cv
+
+#ifndef DISABLE_OPENCV_24_COMPATIBILITY
+#include "opencv2/photo/photo_c.h"
+#endif
+
+#endif
diff --git a/include/opencv2/photo/cuda.hpp b/include/opencv2/photo/cuda.hpp
new file mode 100755
index 0000000..a2f3816
--- /dev/null
+++ b/include/opencv2/photo/cuda.hpp
@@ -0,0 +1,132 @@
+/*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*/
+
+#ifndef OPENCV_PHOTO_CUDA_HPP
+#define OPENCV_PHOTO_CUDA_HPP
+
+#include "opencv2/core/cuda.hpp"
+
+namespace cv { namespace cuda {
+
+//! @addtogroup photo_denoise
+//! @{
+
+/** @brief Performs pure non local means denoising without any simplification, and thus it is not fast.
+
+@param src Source image. Supports only CV_8UC1, CV_8UC2 and CV_8UC3.
+@param dst Destination image.
+@param h Filter sigma regulating filter strength for color.
+@param search_window Size of search window.
+@param block_size Size of block used for computing weights.
+@param borderMode Border type. See borderInterpolate for details. BORDER_REFLECT101 ,
+BORDER_REPLICATE , BORDER_CONSTANT , BORDER_REFLECT and BORDER_WRAP are supported for now.
+@param stream Stream for the asynchronous version.
+
+@sa
+ fastNlMeansDenoising
+ */
+CV_EXPORTS void nonLocalMeans(InputArray src, OutputArray dst,
+ float h,
+ int search_window = 21,
+ int block_size = 7,
+ int borderMode = BORDER_DEFAULT,
+ Stream& stream = Stream::Null());
+
+/** @brief Perform image denoising using Non-local Means Denoising algorithm
+<http://www.ipol.im/pub/algo/bcm_non_local_means_denoising> with several computational
+optimizations. Noise expected to be a gaussian white noise
+
+@param src Input 8-bit 1-channel, 2-channel or 3-channel image.
+@param dst Output image with the same size and type as src .
+@param h Parameter regulating filter strength. Big h value perfectly removes noise but also
+removes image details, smaller h value preserves details but also preserves some noise
+@param search_window Size in pixels of the window that is used to compute weighted average for
+given pixel. Should be odd. Affect performance linearly: greater search_window - greater
+denoising time. Recommended value 21 pixels
+@param block_size Size in pixels of the template patch that is used to compute weights. Should be
+odd. Recommended value 7 pixels
+@param stream Stream for the asynchronous invocations.
+
+This function expected to be applied to grayscale images. For colored images look at
+FastNonLocalMeansDenoising::labMethod.
+
+@sa
+ fastNlMeansDenoising
+ */
+CV_EXPORTS void fastNlMeansDenoising(InputArray src, OutputArray dst,
+ float h,
+ int search_window = 21,
+ int block_size = 7,
+ Stream& stream = Stream::Null());
+
+/** @brief Modification of fastNlMeansDenoising function for colored images
+
+@param src Input 8-bit 3-channel image.
+@param dst Output image with the same size and type as src .
+@param h_luminance Parameter regulating filter strength. Big h value perfectly removes noise but
+also removes image details, smaller h value preserves details but also preserves some noise
+@param photo_render float The same as h but for color components. For most images value equals 10 will be
+enough to remove colored noise and do not distort colors
+@param search_window Size in pixels of the window that is used to compute weighted average for
+given pixel. Should be odd. Affect performance linearly: greater search_window - greater
+denoising time. Recommended value 21 pixels
+@param block_size Size in pixels of the template patch that is used to compute weights. Should be
+odd. Recommended value 7 pixels
+@param stream Stream for the asynchronous invocations.
+
+The function converts image to CIELAB colorspace and then separately denoise L and AB components
+with given h parameters using FastNonLocalMeansDenoising::simpleMethod function.
+
+@sa
+ fastNlMeansDenoisingColored
+ */
+CV_EXPORTS void fastNlMeansDenoisingColored(InputArray src, OutputArray dst,
+ float h_luminance, float photo_render,
+ int search_window = 21,
+ int block_size = 7,
+ Stream& stream = Stream::Null());
+
+//! @} photo
+
+}} // namespace cv { namespace cuda {
+
+#endif /* OPENCV_PHOTO_CUDA_HPP */
diff --git a/include/opencv2/photo/photo.hpp b/include/opencv2/photo/photo.hpp
new file mode 100755
index 0000000..8af5e9f
--- /dev/null
+++ b/include/opencv2/photo/photo.hpp
@@ -0,0 +1,48 @@
+/*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) 2009, Willow Garage Inc., all rights reserved.
+// Copyright (C) 2013, OpenCV Foundation, 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*/
+
+#ifdef __OPENCV_BUILD
+#error this is a compatibility header which should not be used inside the OpenCV library
+#endif
+
+#include "opencv2/photo.hpp"
diff --git a/include/opencv2/photo/photo_c.h b/include/opencv2/photo/photo_c.h
new file mode 100755
index 0000000..cd623c1
--- /dev/null
+++ b/include/opencv2/photo/photo_c.h
@@ -0,0 +1,74 @@
+/*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*/
+
+#ifndef OPENCV_PHOTO_C_H
+#define OPENCV_PHOTO_C_H
+
+#include "opencv2/core/core_c.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/** @addtogroup photo_c
+ @{
+ */
+
+/* Inpainting algorithms */
+enum InpaintingModes
+{
+ CV_INPAINT_NS =0,
+ CV_INPAINT_TELEA =1
+};
+
+
+/* Inpaints the selected region in the image */
+CVAPI(void) cvInpaint( const CvArr* src, const CvArr* inpaint_mask,
+ CvArr* dst, double inpaintRange, int flags );
+
+/** @} */
+
+#ifdef __cplusplus
+} //extern "C"
+#endif
+
+#endif //OPENCV_PHOTO_C_H
diff --git a/include/opencv2/video/background_segm.hpp b/include/opencv2/video/background_segm.hpp
new file mode 100755
index 0000000..2952d57
--- /dev/null
+++ b/include/opencv2/video/background_segm.hpp
@@ -0,0 +1,306 @@
+/*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) 2009, Willow Garage Inc., all rights reserved.
+// Copyright (C) 2013, OpenCV Foundation, 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*/
+
+#ifndef OPENCV_BACKGROUND_SEGM_HPP
+#define OPENCV_BACKGROUND_SEGM_HPP
+
+#include "opencv2/core.hpp"
+
+namespace cv
+{
+
+//! @addtogroup video_motion
+//! @{
+
+/** @brief Base class for background/foreground segmentation. :
+
+The class is only used to define the common interface for the whole family of background/foreground
+segmentation algorithms.
+ */
+class CV_EXPORTS_W BackgroundSubtractor : public Algorithm
+{
+public:
+ /** @brief Computes a foreground mask.
+
+ @param image Next video frame.
+ @param fgmask The output foreground mask as an 8-bit binary image.
+ @param learningRate The value between 0 and 1 that indicates how fast the background model is
+ learnt. Negative parameter value makes the algorithm to use some automatically chosen learning
+ rate. 0 means that the background model is not updated at all, 1 means that the background model
+ is completely reinitialized from the last frame.
+ */
+ CV_WRAP virtual void apply(InputArray image, OutputArray fgmask, double learningRate=-1) = 0;
+
+ /** @brief Computes a background image.
+
+ @param backgroundImage The output background image.
+
+ @note Sometimes the background image can be very blurry, as it contain the average background
+ statistics.
+ */
+ CV_WRAP virtual void getBackgroundImage(OutputArray backgroundImage) const = 0;
+};
+
+
+/** @brief Gaussian Mixture-based Background/Foreground Segmentation Algorithm.
+
+The class implements the Gaussian mixture model background subtraction described in @cite Zivkovic2004
+and @cite Zivkovic2006 .
+ */
+class CV_EXPORTS_W BackgroundSubtractorMOG2 : public BackgroundSubtractor
+{
+public:
+ /** @brief Returns the number of last frames that affect the background model
+ */
+ CV_WRAP virtual int getHistory() const = 0;
+ /** @brief Sets the number of last frames that affect the background model
+ */
+ CV_WRAP virtual void setHistory(int history) = 0;
+
+ /** @brief Returns the number of gaussian components in the background model
+ */
+ CV_WRAP virtual int getNMixtures() const = 0;
+ /** @brief Sets the number of gaussian components in the background model.
+
+ The model needs to be reinitalized to reserve memory.
+ */
+ CV_WRAP virtual void setNMixtures(int nmixtures) = 0;//needs reinitialization!
+
+ /** @brief Returns the "background ratio" parameter of the algorithm
+
+ If a foreground pixel keeps semi-constant value for about backgroundRatio\*history frames, it's
+ considered background and added to the model as a center of a new component. It corresponds to TB
+ parameter in the paper.
+ */
+ CV_WRAP virtual double getBackgroundRatio() const = 0;
+ /** @brief Sets the "background ratio" parameter of the algorithm
+ */
+ CV_WRAP virtual void setBackgroundRatio(double ratio) = 0;
+
+ /** @brief Returns the variance threshold for the pixel-model match
+
+ The main threshold on the squared Mahalanobis distance to decide if the sample is well described by
+ the background model or not. Related to Cthr from the paper.
+ */
+ CV_WRAP virtual double getVarThreshold() const = 0;
+ /** @brief Sets the variance threshold for the pixel-model match
+ */
+ CV_WRAP virtual void setVarThreshold(double varThreshold) = 0;
+
+ /** @brief Returns the variance threshold for the pixel-model match used for new mixture component generation
+
+ Threshold for the squared Mahalanobis distance that helps decide when a sample is close to the
+ existing components (corresponds to Tg in the paper). If a pixel is not close to any component, it
+ is considered foreground or added as a new component. 3 sigma =\> Tg=3\*3=9 is default. A smaller Tg
+ value generates more components. A higher Tg value may result in a small number of components but
+ they can grow too large.
+ */
+ CV_WRAP virtual double getVarThresholdGen() const = 0;
+ /** @brief Sets the variance threshold for the pixel-model match used for new mixture component generation
+ */
+ CV_WRAP virtual void setVarThresholdGen(double varThresholdGen) = 0;
+
+ /** @brief Returns the initial variance of each gaussian component
+ */
+ CV_WRAP virtual double getVarInit() const = 0;
+ /** @brief Sets the initial variance of each gaussian component
+ */
+ CV_WRAP virtual void setVarInit(double varInit) = 0;
+
+ CV_WRAP virtual double getVarMin() const = 0;
+ CV_WRAP virtual void setVarMin(double varMin) = 0;
+
+ CV_WRAP virtual double getVarMax() const = 0;
+ CV_WRAP virtual void setVarMax(double varMax) = 0;
+
+ /** @brief Returns the complexity reduction threshold
+
+ This parameter defines the number of samples needed to accept to prove the component exists. CT=0.05
+ is a default value for all the samples. By setting CT=0 you get an algorithm very similar to the
+ standard Stauffer&Grimson algorithm.
+ */
+ CV_WRAP virtual double getComplexityReductionThreshold() const = 0;
+ /** @brief Sets the complexity reduction threshold
+ */
+ CV_WRAP virtual void setComplexityReductionThreshold(double ct) = 0;
+
+ /** @brief Returns the shadow detection flag
+
+ If true, the algorithm detects shadows and marks them. See createBackgroundSubtractorMOG2 for
+ details.
+ */
+ CV_WRAP virtual bool getDetectShadows() const = 0;
+ /** @brief Enables or disables shadow detection
+ */
+ CV_WRAP virtual void setDetectShadows(bool detectShadows) = 0;
+
+ /** @brief Returns the shadow value
+
+ Shadow value is the value used to mark shadows in the foreground mask. Default value is 127. Value 0
+ in the mask always means background, 255 means foreground.
+ */
+ CV_WRAP virtual int getShadowValue() const = 0;
+ /** @brief Sets the shadow value
+ */
+ CV_WRAP virtual void setShadowValue(int value) = 0;
+
+ /** @brief Returns the shadow threshold
+
+ A shadow is detected if pixel is a darker version of the background. The shadow threshold (Tau in
+ the paper) is a threshold defining how much darker the shadow can be. Tau= 0.5 means that if a pixel
+ is more than twice darker then it is not shadow. See Prati, Mikic, Trivedi and Cucchiarra,
+ *Detecting Moving Shadows...*, IEEE PAMI,2003.
+ */
+ CV_WRAP virtual double getShadowThreshold() const = 0;
+ /** @brief Sets the shadow threshold
+ */
+ CV_WRAP virtual void setShadowThreshold(double threshold) = 0;
+};
+
+/** @brief Creates MOG2 Background Subtractor
+
+@param history Length of the history.
+@param varThreshold Threshold on the squared Mahalanobis distance between the pixel and the model
+to decide whether a pixel is well described by the background model. This parameter does not
+affect the background update.
+@param detectShadows If true, the algorithm will detect shadows and mark them. It decreases the
+speed a bit, so if you do not need this feature, set the parameter to false.
+ */
+CV_EXPORTS_W Ptr<BackgroundSubtractorMOG2>
+ createBackgroundSubtractorMOG2(int history=500, double varThreshold=16,
+ bool detectShadows=true);
+
+/** @brief K-nearest neigbours - based Background/Foreground Segmentation Algorithm.
+
+The class implements the K-nearest neigbours background subtraction described in @cite Zivkovic2006 .
+Very efficient if number of foreground pixels is low.
+ */
+class CV_EXPORTS_W BackgroundSubtractorKNN : public BackgroundSubtractor
+{
+public:
+ /** @brief Returns the number of last frames that affect the background model
+ */
+ CV_WRAP virtual int getHistory() const = 0;
+ /** @brief Sets the number of last frames that affect the background model
+ */
+ CV_WRAP virtual void setHistory(int history) = 0;
+
+ /** @brief Returns the number of data samples in the background model
+ */
+ CV_WRAP virtual int getNSamples() const = 0;
+ /** @brief Sets the number of data samples in the background model.
+
+ The model needs to be reinitalized to reserve memory.
+ */
+ CV_WRAP virtual void setNSamples(int _nN) = 0;//needs reinitialization!
+
+ /** @brief Returns the threshold on the squared distance between the pixel and the sample
+
+ The threshold on the squared distance between the pixel and the sample to decide whether a pixel is
+ close to a data sample.
+ */
+ CV_WRAP virtual double getDist2Threshold() const = 0;
+ /** @brief Sets the threshold on the squared distance
+ */
+ CV_WRAP virtual void setDist2Threshold(double _dist2Threshold) = 0;
+
+ /** @brief Returns the number of neighbours, the k in the kNN.
+
+ K is the number of samples that need to be within dist2Threshold in order to decide that that
+ pixel is matching the kNN background model.
+ */
+ CV_WRAP virtual int getkNNSamples() const = 0;
+ /** @brief Sets the k in the kNN. How many nearest neigbours need to match.
+ */
+ CV_WRAP virtual void setkNNSamples(int _nkNN) = 0;
+
+ /** @brief Returns the shadow detection flag
+
+ If true, the algorithm detects shadows and marks them. See createBackgroundSubtractorKNN for
+ details.
+ */
+ CV_WRAP virtual bool getDetectShadows() const = 0;
+ /** @brief Enables or disables shadow detection
+ */
+ CV_WRAP virtual void setDetectShadows(bool detectShadows) = 0;
+
+ /** @brief Returns the shadow value
+
+ Shadow value is the value used to mark shadows in the foreground mask. Default value is 127. Value 0
+ in the mask always means background, 255 means foreground.
+ */
+ CV_WRAP virtual int getShadowValue() const = 0;
+ /** @brief Sets the shadow value
+ */
+ CV_WRAP virtual void setShadowValue(int value) = 0;
+
+ /** @brief Returns the shadow threshold
+
+ A shadow is detected if pixel is a darker version of the background. The shadow threshold (Tau in
+ the paper) is a threshold defining how much darker the shadow can be. Tau= 0.5 means that if a pixel
+ is more than twice darker then it is not shadow. See Prati, Mikic, Trivedi and Cucchiarra,
+ *Detecting Moving Shadows...*, IEEE PAMI,2003.
+ */
+ CV_WRAP virtual double getShadowThreshold() const = 0;
+ /** @brief Sets the shadow threshold
+ */
+ CV_WRAP virtual void setShadowThreshold(double threshold) = 0;
+};
+
+/** @brief Creates KNN Background Subtractor
+
+@param history Length of the history.
+@param dist2Threshold Threshold on the squared distance between the pixel and the sample to decide
+whether a pixel is close to that sample. This parameter does not affect the background update.
+@param detectShadows If true, the algorithm will detect shadows and mark them. It decreases the
+speed a bit, so if you do not need this feature, set the parameter to false.
+ */
+CV_EXPORTS_W Ptr<BackgroundSubtractorKNN>
+ createBackgroundSubtractorKNN(int history=500, double dist2Threshold=400.0,
+ bool detectShadows=true);
+
+//! @} video_motion
+
+} // cv
+
+#endif
diff --git a/include/opencv2/video/tracking.hpp b/include/opencv2/video/tracking.hpp
new file mode 100755
index 0000000..c6ead3a
--- /dev/null
+++ b/include/opencv2/video/tracking.hpp
@@ -0,0 +1,626 @@
+/*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) 2009, Willow Garage Inc., all rights reserved.
+// Copyright (C) 2013, OpenCV Foundation, 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*/
+
+#ifndef OPENCV_TRACKING_HPP
+#define OPENCV_TRACKING_HPP
+
+#include "opencv2/core.hpp"
+#include "opencv2/imgproc.hpp"
+
+namespace cv
+{
+
+//! @addtogroup video_track
+//! @{
+
+enum { OPTFLOW_USE_INITIAL_FLOW = 4,
+ OPTFLOW_LK_GET_MIN_EIGENVALS = 8,
+ OPTFLOW_FARNEBACK_GAUSSIAN = 256
+ };
+
+/** @brief Finds an object center, size, and orientation.
+
+@param probImage Back projection of the object histogram. See calcBackProject.
+@param window Initial search window.
+@param criteria Stop criteria for the underlying meanShift.
+returns
+(in old interfaces) Number of iterations CAMSHIFT took to converge
+The function implements the CAMSHIFT object tracking algorithm @cite Bradski98 . First, it finds an
+object center using meanShift and then adjusts the window size and finds the optimal rotation. The
+function returns the rotated rectangle structure that includes the object position, size, and
+orientation. The next position of the search window can be obtained with RotatedRect::boundingRect()
+
+See the OpenCV sample camshiftdemo.c that tracks colored objects.
+
+@note
+- (Python) A sample explaining the camshift tracking algorithm can be found at
+ opencv_source_code/samples/python/camshift.py
+ */
+CV_EXPORTS_W RotatedRect CamShift( InputArray probImage, CV_IN_OUT Rect& window,
+ TermCriteria criteria );
+
+/** @brief Finds an object on a back projection image.
+
+@param probImage Back projection of the object histogram. See calcBackProject for details.
+@param window Initial search window.
+@param criteria Stop criteria for the iterative search algorithm.
+returns
+: Number of iterations CAMSHIFT took to converge.
+The function implements the iterative object search algorithm. It takes the input back projection of
+an object and the initial position. The mass center in window of the back projection image is
+computed and the search window center shifts to the mass center. The procedure is repeated until the
+specified number of iterations criteria.maxCount is done or until the window center shifts by less
+than criteria.epsilon. The algorithm is used inside CamShift and, unlike CamShift , the search
+window size or orientation do not change during the search. You can simply pass the output of
+calcBackProject to this function. But better results can be obtained if you pre-filter the back
+projection and remove the noise. For example, you can do this by retrieving connected components
+with findContours , throwing away contours with small area ( contourArea ), and rendering the
+remaining contours with drawContours.
+
+@note
+- A mean-shift tracking sample can be found at opencv_source_code/samples/cpp/camshiftdemo.cpp
+ */
+CV_EXPORTS_W int meanShift( InputArray probImage, CV_IN_OUT Rect& window, TermCriteria criteria );
+
+/** @brief Constructs the image pyramid which can be passed to calcOpticalFlowPyrLK.
+
+@param img 8-bit input image.
+@param pyramid output pyramid.
+@param winSize window size of optical flow algorithm. Must be not less than winSize argument of
+calcOpticalFlowPyrLK. It is needed to calculate required padding for pyramid levels.
+@param maxLevel 0-based maximal pyramid level number.
+@param withDerivatives set to precompute gradients for the every pyramid level. If pyramid is
+constructed without the gradients then calcOpticalFlowPyrLK will calculate them internally.
+@param pyrBorder the border mode for pyramid layers.
+@param derivBorder the border mode for gradients.
+@param tryReuseInputImage put ROI of input image into the pyramid if possible. You can pass false
+to force data copying.
+@return number of levels in constructed pyramid. Can be less than maxLevel.
+ */
+CV_EXPORTS_W int buildOpticalFlowPyramid( InputArray img, OutputArrayOfArrays pyramid,
+ Size winSize, int maxLevel, bool withDerivatives = true,
+ int pyrBorder = BORDER_REFLECT_101,
+ int derivBorder = BORDER_CONSTANT,
+ bool tryReuseInputImage = true );
+
+/** @brief Calculates an optical flow for a sparse feature set using the iterative Lucas-Kanade method with
+pyramids.
+
+@param prevImg first 8-bit input image or pyramid constructed by buildOpticalFlowPyramid.
+@param nextImg second input image or pyramid of the same size and the same type as prevImg.
+@param prevPts vector of 2D points for which the flow needs to be found; point coordinates must be
+single-precision floating-point numbers.
+@param nextPts output vector of 2D points (with single-precision floating-point coordinates)
+containing the calculated new positions of input features in the second image; when
+OPTFLOW_USE_INITIAL_FLOW flag is passed, the vector must have the same size as in the input.
+@param status output status vector (of unsigned chars); each element of the vector is set to 1 if
+the flow for the corresponding features has been found, otherwise, it is set to 0.
+@param err output vector of errors; each element of the vector is set to an error for the
+corresponding feature, type of the error measure can be set in flags parameter; if the flow wasn't
+found then the error is not defined (use the status parameter to find such cases).
+@param winSize size of the search window at each pyramid level.
+@param maxLevel 0-based maximal pyramid level number; if set to 0, pyramids are not used (single
+level), if set to 1, two levels are used, and so on; if pyramids are passed to input then
+algorithm will use as many levels as pyramids have but no more than maxLevel.
+@param criteria parameter, specifying the termination criteria of the iterative search algorithm
+(after the specified maximum number of iterations criteria.maxCount or when the search window
+moves by less than criteria.epsilon.
+@param flags operation flags:
+ - **OPTFLOW_USE_INITIAL_FLOW** uses initial estimations, stored in nextPts; if the flag is
+ not set, then prevPts is copied to nextPts and is considered the initial estimate.
+ - **OPTFLOW_LK_GET_MIN_EIGENVALS** use minimum eigen values as an error measure (see
+ minEigThreshold description); if the flag is not set, then L1 distance between patches
+ around the original and a moved point, divided by number of pixels in a window, is used as a
+ error measure.
+@param minEigThreshold the algorithm calculates the minimum eigen value of a 2x2 normal matrix of
+optical flow equations (this matrix is called a spatial gradient matrix in @cite Bouguet00), divided
+by number of pixels in a window; if this value is less than minEigThreshold, then a corresponding
+feature is filtered out and its flow is not processed, so it allows to remove bad points and get a
+performance boost.
+
+The function implements a sparse iterative version of the Lucas-Kanade optical flow in pyramids. See
+@cite Bouguet00 . The function is parallelized with the TBB library.
+
+@note
+
+- An example using the Lucas-Kanade optical flow algorithm can be found at
+ opencv_source_code/samples/cpp/lkdemo.cpp
+- (Python) An example using the Lucas-Kanade optical flow algorithm can be found at
+ opencv_source_code/samples/python/lk_track.py
+- (Python) An example using the Lucas-Kanade tracker for homography matching can be found at
+ opencv_source_code/samples/python/lk_homography.py
+ */
+CV_EXPORTS_W void calcOpticalFlowPyrLK( InputArray prevImg, InputArray nextImg,
+ InputArray prevPts, InputOutputArray nextPts,
+ OutputArray status, OutputArray err,
+ Size winSize = Size(21,21), int maxLevel = 3,
+ TermCriteria criteria = TermCriteria(TermCriteria::COUNT+TermCriteria::EPS, 30, 0.01),
+ int flags = 0, double minEigThreshold = 1e-4 );
+
+/** @brief Computes a dense optical flow using the Gunnar Farneback's algorithm.
+
+@param prev first 8-bit single-channel input image.
+@param next second input image of the same size and the same type as prev.
+@param flow computed flow image that has the same size as prev and type CV_32FC2.
+@param pyr_scale parameter, specifying the image scale (\<1) to build pyramids for each image;
+pyr_scale=0.5 means a classical pyramid, where each next layer is twice smaller than the previous
+one.
+@param levels number of pyramid layers including the initial image; levels=1 means that no extra
+layers are created and only the original images are used.
+@param winsize averaging window size; larger values increase the algorithm robustness to image
+noise and give more chances for fast motion detection, but yield more blurred motion field.
+@param iterations number of iterations the algorithm does at each pyramid level.
+@param poly_n size of the pixel neighborhood used to find polynomial expansion in each pixel;
+larger values mean that the image will be approximated with smoother surfaces, yielding more
+robust algorithm and more blurred motion field, typically poly_n =5 or 7.
+@param poly_sigma standard deviation of the Gaussian that is used to smooth derivatives used as a
+basis for the polynomial expansion; for poly_n=5, you can set poly_sigma=1.1, for poly_n=7, a
+good value would be poly_sigma=1.5.
+@param flags operation flags that can be a combination of the following:
+ - **OPTFLOW_USE_INITIAL_FLOW** uses the input flow as an initial flow approximation.
+ - **OPTFLOW_FARNEBACK_GAUSSIAN** uses the Gaussian \f$\texttt{winsize}\times\texttt{winsize}\f$
+ filter instead of a box filter of the same size for optical flow estimation; usually, this
+ option gives z more accurate flow than with a box filter, at the cost of lower speed;
+ normally, winsize for a Gaussian window should be set to a larger value to achieve the same
+ level of robustness.
+
+The function finds an optical flow for each prev pixel using the @cite Farneback2003 algorithm so that
+
+\f[\texttt{prev} (y,x) \sim \texttt{next} ( y + \texttt{flow} (y,x)[1], x + \texttt{flow} (y,x)[0])\f]
+
+@note
+
+- An example using the optical flow algorithm described by Gunnar Farneback can be found at
+ opencv_source_code/samples/cpp/fback.cpp
+- (Python) An example using the optical flow algorithm described by Gunnar Farneback can be
+ found at opencv_source_code/samples/python/opt_flow.py
+ */
+CV_EXPORTS_W void calcOpticalFlowFarneback( InputArray prev, InputArray next, InputOutputArray flow,
+ double pyr_scale, int levels, int winsize,
+ int iterations, int poly_n, double poly_sigma,
+ int flags );
+
+/** @brief Computes an optimal affine transformation between two 2D point sets.
+
+@param src First input 2D point set stored in std::vector or Mat, or an image stored in Mat.
+@param dst Second input 2D point set of the same size and the same type as A, or another image.
+@param fullAffine If true, the function finds an optimal affine transformation with no additional
+restrictions (6 degrees of freedom). Otherwise, the class of transformations to choose from is
+limited to combinations of translation, rotation, and uniform scaling (4 degrees of freedom).
+
+The function finds an optimal affine transform *[A|b]* (a 2 x 3 floating-point matrix) that
+approximates best the affine transformation between:
+
+* Two point sets
+* Two raster images. In this case, the function first finds some features in the src image and
+ finds the corresponding features in dst image. After that, the problem is reduced to the first
+ case.
+In case of point sets, the problem is formulated as follows: you need to find a 2x2 matrix *A* and
+2x1 vector *b* so that:
+
+\f[[A^*|b^*] = arg \min _{[A|b]} \sum _i \| \texttt{dst}[i] - A { \texttt{src}[i]}^T - b \| ^2\f]
+where src[i] and dst[i] are the i-th points in src and dst, respectively
+\f$[A|b]\f$ can be either arbitrary (when fullAffine=true ) or have a form of
+\f[\begin{bmatrix} a_{11} & a_{12} & b_1 \\ -a_{12} & a_{11} & b_2 \end{bmatrix}\f]
+when fullAffine=false.
+
+@sa
+estimateAffine2D, estimateAffinePartial2D, getAffineTransform, getPerspectiveTransform, findHomography
+ */
+CV_EXPORTS_W Mat estimateRigidTransform( InputArray src, InputArray dst, bool fullAffine );
+
+
+enum
+{
+ MOTION_TRANSLATION = 0,
+ MOTION_EUCLIDEAN = 1,
+ MOTION_AFFINE = 2,
+ MOTION_HOMOGRAPHY = 3
+};
+
+/** @brief Finds the geometric transform (warp) between two images in terms of the ECC criterion @cite EP08 .
+
+@param templateImage single-channel template image; CV_8U or CV_32F array.
+@param inputImage single-channel input image which should be warped with the final warpMatrix in
+order to provide an image similar to templateImage, same type as temlateImage.
+@param warpMatrix floating-point \f$2\times 3\f$ or \f$3\times 3\f$ mapping matrix (warp).
+@param motionType parameter, specifying the type of motion:
+ - **MOTION_TRANSLATION** sets a translational motion model; warpMatrix is \f$2\times 3\f$ with
+ the first \f$2\times 2\f$ part being the unity matrix and the rest two parameters being
+ estimated.
+ - **MOTION_EUCLIDEAN** sets a Euclidean (rigid) transformation as motion model; three
+ parameters are estimated; warpMatrix is \f$2\times 3\f$.
+ - **MOTION_AFFINE** sets an affine motion model (DEFAULT); six parameters are estimated;
+ warpMatrix is \f$2\times 3\f$.
+ - **MOTION_HOMOGRAPHY** sets a homography as a motion model; eight parameters are
+ estimated;\`warpMatrix\` is \f$3\times 3\f$.
+@param criteria parameter, specifying the termination criteria of the ECC algorithm;
+criteria.epsilon defines the threshold of the increment in the correlation coefficient between two
+iterations (a negative criteria.epsilon makes criteria.maxcount the only termination criterion).
+Default values are shown in the declaration above.
+@param inputMask An optional mask to indicate valid values of inputImage.
+
+The function estimates the optimum transformation (warpMatrix) with respect to ECC criterion
+(@cite EP08), that is
+
+\f[\texttt{warpMatrix} = \texttt{warpMatrix} = \arg\max_{W} \texttt{ECC}(\texttt{templateImage}(x,y),\texttt{inputImage}(x',y'))\f]
+
+where
+
+\f[\begin{bmatrix} x' \\ y' \end{bmatrix} = W \cdot \begin{bmatrix} x \\ y \\ 1 \end{bmatrix}\f]
+
+(the equation holds with homogeneous coordinates for homography). It returns the final enhanced
+correlation coefficient, that is the correlation coefficient between the template image and the
+final warped input image. When a \f$3\times 3\f$ matrix is given with motionType =0, 1 or 2, the third
+row is ignored.
+
+Unlike findHomography and estimateRigidTransform, the function findTransformECC implements an
+area-based alignment that builds on intensity similarities. In essence, the function updates the
+initial transformation that roughly aligns the images. If this information is missing, the identity
+warp (unity matrix) should be given as input. Note that if images undergo strong
+displacements/rotations, an initial transformation that roughly aligns the images is necessary
+(e.g., a simple euclidean/similarity transform that allows for the images showing the same image
+content approximately). Use inverse warping in the second image to take an image close to the first
+one, i.e. use the flag WARP_INVERSE_MAP with warpAffine or warpPerspective. See also the OpenCV
+sample image_alignment.cpp that demonstrates the use of the function. Note that the function throws
+an exception if algorithm does not converges.
+
+@sa
+estimateAffine2D, estimateAffinePartial2D, findHomography
+ */
+CV_EXPORTS_W double findTransformECC( InputArray templateImage, InputArray inputImage,
+ InputOutputArray warpMatrix, int motionType = MOTION_AFFINE,
+ TermCriteria criteria = TermCriteria(TermCriteria::COUNT+TermCriteria::EPS, 50, 0.001),
+ InputArray inputMask = noArray());
+
+/** @brief Kalman filter class.
+
+The class implements a standard Kalman filter <http://en.wikipedia.org/wiki/Kalman_filter>,
+@cite Welch95 . However, you can modify transitionMatrix, controlMatrix, and measurementMatrix to get
+an extended Kalman filter functionality. See the OpenCV sample kalman.cpp.
+
+@note
+
+- An example using the standard Kalman filter can be found at
+ opencv_source_code/samples/cpp/kalman.cpp
+ */
+class CV_EXPORTS_W KalmanFilter
+{
+public:
+ /** @brief The constructors.
+
+ @note In C API when CvKalman\* kalmanFilter structure is not needed anymore, it should be released
+ with cvReleaseKalman(&kalmanFilter)
+ */
+ CV_WRAP KalmanFilter();
+ /** @overload
+ @param dynamParams Dimensionality of the state.
+ @param measureParams Dimensionality of the measurement.
+ @param controlParams Dimensionality of the control vector.
+ @param type Type of the created matrices that should be CV_32F or CV_64F.
+ */
+ CV_WRAP KalmanFilter( int dynamParams, int measureParams, int controlParams = 0, int type = CV_32F );
+
+ /** @brief Re-initializes Kalman filter. The previous content is destroyed.
+
+ @param dynamParams Dimensionality of the state.
+ @param measureParams Dimensionality of the measurement.
+ @param controlParams Dimensionality of the control vector.
+ @param type Type of the created matrices that should be CV_32F or CV_64F.
+ */
+ void init( int dynamParams, int measureParams, int controlParams = 0, int type = CV_32F );
+
+ /** @brief Computes a predicted state.
+
+ @param control The optional input control
+ */
+ CV_WRAP const Mat& predict( const Mat& control = Mat() );
+
+ /** @brief Updates the predicted state from the measurement.
+
+ @param measurement The measured system parameters
+ */
+ CV_WRAP const Mat& correct( const Mat& measurement );
+
+ CV_PROP_RW Mat statePre; //!< predicted state (x'(k)): x(k)=A*x(k-1)+B*u(k)
+ CV_PROP_RW Mat statePost; //!< corrected state (x(k)): x(k)=x'(k)+K(k)*(z(k)-H*x'(k))
+ CV_PROP_RW Mat transitionMatrix; //!< state transition matrix (A)
+ CV_PROP_RW Mat controlMatrix; //!< control matrix (B) (not used if there is no control)
+ CV_PROP_RW Mat measurementMatrix; //!< measurement matrix (H)
+ CV_PROP_RW Mat processNoiseCov; //!< process noise covariance matrix (Q)
+ CV_PROP_RW Mat measurementNoiseCov;//!< measurement noise covariance matrix (R)
+ CV_PROP_RW Mat errorCovPre; //!< priori error estimate covariance matrix (P'(k)): P'(k)=A*P(k-1)*At + Q)*/
+ CV_PROP_RW Mat gain; //!< Kalman gain matrix (K(k)): K(k)=P'(k)*Ht*inv(H*P'(k)*Ht+R)
+ CV_PROP_RW Mat errorCovPost; //!< posteriori error estimate covariance matrix (P(k)): P(k)=(I-K(k)*H)*P'(k)
+
+ // temporary matrices
+ Mat temp1;
+ Mat temp2;
+ Mat temp3;
+ Mat temp4;
+ Mat temp5;
+};
+
+
+class CV_EXPORTS_W DenseOpticalFlow : public Algorithm
+{
+public:
+ /** @brief Calculates an optical flow.
+
+ @param I0 first 8-bit single-channel input image.
+ @param I1 second input image of the same size and the same type as prev.
+ @param flow computed flow image that has the same size as prev and type CV_32FC2.
+ */
+ CV_WRAP virtual void calc( InputArray I0, InputArray I1, InputOutputArray flow ) = 0;
+ /** @brief Releases all inner buffers.
+ */
+ CV_WRAP virtual void collectGarbage() = 0;
+};
+
+/** @brief Base interface for sparse optical flow algorithms.
+ */
+class CV_EXPORTS_W SparseOpticalFlow : public Algorithm
+{
+public:
+ /** @brief Calculates a sparse optical flow.
+
+ @param prevImg First input image.
+ @param nextImg Second input image of the same size and the same type as prevImg.
+ @param prevPts Vector of 2D points for which the flow needs to be found.
+ @param nextPts Output vector of 2D points containing the calculated new positions of input features in the second image.
+ @param status Output status vector. Each element of the vector is set to 1 if the
+ flow for the corresponding features has been found. Otherwise, it is set to 0.
+ @param err Optional output vector that contains error response for each point (inverse confidence).
+ */
+ CV_WRAP virtual void calc(InputArray prevImg, InputArray nextImg,
+ InputArray prevPts, InputOutputArray nextPts,
+ OutputArray status,
+ OutputArray err = cv::noArray()) = 0;
+};
+
+/** @brief "Dual TV L1" Optical Flow Algorithm.
+
+The class implements the "Dual TV L1" optical flow algorithm described in @cite Zach2007 and
+@cite Javier2012 .
+Here are important members of the class that control the algorithm, which you can set after
+constructing the class instance:
+
+- member double tau
+ Time step of the numerical scheme.
+
+- member double lambda
+ Weight parameter for the data term, attachment parameter. This is the most relevant
+ parameter, which determines the smoothness of the output. The smaller this parameter is,
+ the smoother the solutions we obtain. It depends on the range of motions of the images, so
+ its value should be adapted to each image sequence.
+
+- member double theta
+ Weight parameter for (u - v)\^2, tightness parameter. It serves as a link between the
+ attachment and the regularization terms. In theory, it should have a small value in order
+ to maintain both parts in correspondence. The method is stable for a large range of values
+ of this parameter.
+
+- member int nscales
+ Number of scales used to create the pyramid of images.
+
+- member int warps
+ Number of warpings per scale. Represents the number of times that I1(x+u0) and grad(
+ I1(x+u0) ) are computed per scale. This is a parameter that assures the stability of the
+ method. It also affects the running time, so it is a compromise between speed and
+ accuracy.
+
+- member double epsilon
+ Stopping criterion threshold used in the numerical scheme, which is a trade-off between
+ precision and running time. A small value will yield more accurate solutions at the
+ expense of a slower convergence.
+
+- member int iterations
+ Stopping criterion iterations number used in the numerical scheme.
+
+C. Zach, T. Pock and H. Bischof, "A Duality Based Approach for Realtime TV-L1 Optical Flow".
+Javier Sanchez, Enric Meinhardt-Llopis and Gabriele Facciolo. "TV-L1 Optical Flow Estimation".
+*/
+class CV_EXPORTS_W DualTVL1OpticalFlow : public DenseOpticalFlow
+{
+public:
+ //! @brief Time step of the numerical scheme
+ /** @see setTau */
+ CV_WRAP virtual double getTau() const = 0;
+ /** @copybrief getTau @see getTau */
+ CV_WRAP virtual void setTau(double val) = 0;
+ //! @brief Weight parameter for the data term, attachment parameter
+ /** @see setLambda */
+ CV_WRAP virtual double getLambda() const = 0;
+ /** @copybrief getLambda @see getLambda */
+ CV_WRAP virtual void setLambda(double val) = 0;
+ //! @brief Weight parameter for (u - v)^2, tightness parameter
+ /** @see setTheta */
+ CV_WRAP virtual double getTheta() const = 0;
+ /** @copybrief getTheta @see getTheta */
+ CV_WRAP virtual void setTheta(double val) = 0;
+ //! @brief coefficient for additional illumination variation term
+ /** @see setGamma */
+ CV_WRAP virtual double getGamma() const = 0;
+ /** @copybrief getGamma @see getGamma */
+ CV_WRAP virtual void setGamma(double val) = 0;
+ //! @brief Number of scales used to create the pyramid of images
+ /** @see setScalesNumber */
+ CV_WRAP virtual int getScalesNumber() const = 0;
+ /** @copybrief getScalesNumber @see getScalesNumber */
+ CV_WRAP virtual void setScalesNumber(int val) = 0;
+ //! @brief Number of warpings per scale
+ /** @see setWarpingsNumber */
+ CV_WRAP virtual int getWarpingsNumber() const = 0;
+ /** @copybrief getWarpingsNumber @see getWarpingsNumber */
+ CV_WRAP virtual void setWarpingsNumber(int val) = 0;
+ //! @brief Stopping criterion threshold used in the numerical scheme, which is a trade-off between precision and running time
+ /** @see setEpsilon */
+ CV_WRAP virtual double getEpsilon() const = 0;
+ /** @copybrief getEpsilon @see getEpsilon */
+ CV_WRAP virtual void setEpsilon(double val) = 0;
+ //! @brief Inner iterations (between outlier filtering) used in the numerical scheme
+ /** @see setInnerIterations */
+ CV_WRAP virtual int getInnerIterations() const = 0;
+ /** @copybrief getInnerIterations @see getInnerIterations */
+ CV_WRAP virtual void setInnerIterations(int val) = 0;
+ //! @brief Outer iterations (number of inner loops) used in the numerical scheme
+ /** @see setOuterIterations */
+ CV_WRAP virtual int getOuterIterations() const = 0;
+ /** @copybrief getOuterIterations @see getOuterIterations */
+ CV_WRAP virtual void setOuterIterations(int val) = 0;
+ //! @brief Use initial flow
+ /** @see setUseInitialFlow */
+ CV_WRAP virtual bool getUseInitialFlow() const = 0;
+ /** @copybrief getUseInitialFlow @see getUseInitialFlow */
+ CV_WRAP virtual void setUseInitialFlow(bool val) = 0;
+ //! @brief Step between scales (<1)
+ /** @see setScaleStep */
+ CV_WRAP virtual double getScaleStep() const = 0;
+ /** @copybrief getScaleStep @see getScaleStep */
+ CV_WRAP virtual void setScaleStep(double val) = 0;
+ //! @brief Median filter kernel size (1 = no filter) (3 or 5)
+ /** @see setMedianFiltering */
+ CV_WRAP virtual int getMedianFiltering() const = 0;
+ /** @copybrief getMedianFiltering @see getMedianFiltering */
+ CV_WRAP virtual void setMedianFiltering(int val) = 0;
+
+ /** @brief Creates instance of cv::DualTVL1OpticalFlow*/
+ CV_WRAP static Ptr<DualTVL1OpticalFlow> create(
+ double tau = 0.25,
+ double lambda = 0.15,
+ double theta = 0.3,
+ int nscales = 5,
+ int warps = 5,
+ double epsilon = 0.01,
+ int innnerIterations = 30,
+ int outerIterations = 10,
+ double scaleStep = 0.8,
+ double gamma = 0.0,
+ int medianFiltering = 5,
+ bool useInitialFlow = false);
+};
+
+/** @brief Creates instance of cv::DenseOpticalFlow
+*/
+CV_EXPORTS_W Ptr<DualTVL1OpticalFlow> createOptFlow_DualTVL1();
+
+/** @brief Class computing a dense optical flow using the Gunnar Farneback’s algorithm.
+ */
+class CV_EXPORTS_W FarnebackOpticalFlow : public DenseOpticalFlow
+{
+public:
+ CV_WRAP virtual int getNumLevels() const = 0;
+ CV_WRAP virtual void setNumLevels(int numLevels) = 0;
+
+ CV_WRAP virtual double getPyrScale() const = 0;
+ CV_WRAP virtual void setPyrScale(double pyrScale) = 0;
+
+ CV_WRAP virtual bool getFastPyramids() const = 0;
+ CV_WRAP virtual void setFastPyramids(bool fastPyramids) = 0;
+
+ CV_WRAP virtual int getWinSize() const = 0;
+ CV_WRAP virtual void setWinSize(int winSize) = 0;
+
+ CV_WRAP virtual int getNumIters() const = 0;
+ CV_WRAP virtual void setNumIters(int numIters) = 0;
+
+ CV_WRAP virtual int getPolyN() const = 0;
+ CV_WRAP virtual void setPolyN(int polyN) = 0;
+
+ CV_WRAP virtual double getPolySigma() const = 0;
+ CV_WRAP virtual void setPolySigma(double polySigma) = 0;
+
+ CV_WRAP virtual int getFlags() const = 0;
+ CV_WRAP virtual void setFlags(int flags) = 0;
+
+ CV_WRAP static Ptr<FarnebackOpticalFlow> create(
+ int numLevels = 5,
+ double pyrScale = 0.5,
+ bool fastPyramids = false,
+ int winSize = 13,
+ int numIters = 10,
+ int polyN = 5,
+ double polySigma = 1.1,
+ int flags = 0);
+};
+
+
+/** @brief Class used for calculating a sparse optical flow.
+
+The class can calculate an optical flow for a sparse feature set using the
+iterative Lucas-Kanade method with pyramids.
+
+@sa calcOpticalFlowPyrLK
+
+*/
+class CV_EXPORTS_W SparsePyrLKOpticalFlow : public SparseOpticalFlow
+{
+public:
+ CV_WRAP virtual Size getWinSize() const = 0;
+ CV_WRAP virtual void setWinSize(Size winSize) = 0;
+
+ CV_WRAP virtual int getMaxLevel() const = 0;
+ CV_WRAP virtual void setMaxLevel(int maxLevel) = 0;
+
+ CV_WRAP virtual TermCriteria getTermCriteria() const = 0;
+ CV_WRAP virtual void setTermCriteria(TermCriteria& crit) = 0;
+
+ CV_WRAP virtual int getFlags() const = 0;
+ CV_WRAP virtual void setFlags(int flags) = 0;
+
+ CV_WRAP virtual double getMinEigThreshold() const = 0;
+ CV_WRAP virtual void setMinEigThreshold(double minEigThreshold) = 0;
+
+ CV_WRAP static Ptr<SparsePyrLKOpticalFlow> create(
+ Size winSize = Size(21, 21),
+ int maxLevel = 3, TermCriteria crit =
+ TermCriteria(TermCriteria::COUNT+TermCriteria::EPS, 30, 0.01),
+ int flags = 0,
+ double minEigThreshold = 1e-4);
+};
+
+//! @} video_track
+
+} // cv
+
+#endif
diff --git a/include/opencv2/video/tracking_c.h b/include/opencv2/video/tracking_c.h
new file mode 100755
index 0000000..3e32fbd
--- /dev/null
+++ b/include/opencv2/video/tracking_c.h
@@ -0,0 +1,232 @@
+/*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) 2009, Willow Garage Inc., all rights reserved.
+// Copyright (C) 2013, OpenCV Foundation, 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*/
+
+#ifndef OPENCV_TRACKING_C_H
+#define OPENCV_TRACKING_C_H
+
+#include "opencv2/imgproc/types_c.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/** @addtogroup video_c
+ @{
+*/
+
+/****************************************************************************************\
+* Motion Analysis *
+\****************************************************************************************/
+
+/************************************ optical flow ***************************************/
+
+#define CV_LKFLOW_PYR_A_READY 1
+#define CV_LKFLOW_PYR_B_READY 2
+#define CV_LKFLOW_INITIAL_GUESSES 4
+#define CV_LKFLOW_GET_MIN_EIGENVALS 8
+
+/* It is Lucas & Kanade method, modified to use pyramids.
+ Also it does several iterations to get optical flow for
+ every point at every pyramid level.
+ Calculates optical flow between two images for certain set of points (i.e.
+ it is a "sparse" optical flow, which is opposite to the previous 3 methods) */
+CVAPI(void) cvCalcOpticalFlowPyrLK( const CvArr* prev, const CvArr* curr,
+ CvArr* prev_pyr, CvArr* curr_pyr,
+ const CvPoint2D32f* prev_features,
+ CvPoint2D32f* curr_features,
+ int count,
+ CvSize win_size,
+ int level,
+ char* status,
+ float* track_error,
+ CvTermCriteria criteria,
+ int flags );
+
+
+/* Modification of a previous sparse optical flow algorithm to calculate
+ affine flow */
+CVAPI(void) cvCalcAffineFlowPyrLK( const CvArr* prev, const CvArr* curr,
+ CvArr* prev_pyr, CvArr* curr_pyr,
+ const CvPoint2D32f* prev_features,
+ CvPoint2D32f* curr_features,
+ float* matrices, int count,
+ CvSize win_size, int level,
+ char* status, float* track_error,
+ CvTermCriteria criteria, int flags );
+
+/* Estimate rigid transformation between 2 images or 2 point sets */
+CVAPI(int) cvEstimateRigidTransform( const CvArr* A, const CvArr* B,
+ CvMat* M, int full_affine );
+
+/* Estimate optical flow for each pixel using the two-frame G. Farneback algorithm */
+CVAPI(void) cvCalcOpticalFlowFarneback( const CvArr* prev, const CvArr* next,
+ CvArr* flow, double pyr_scale, int levels,
+ int winsize, int iterations, int poly_n,
+ double poly_sigma, int flags );
+
+/********************************* motion templates *************************************/
+
+/****************************************************************************************\
+* All the motion template functions work only with single channel images. *
+* Silhouette image must have depth IPL_DEPTH_8U or IPL_DEPTH_8S *
+* Motion history image must have depth IPL_DEPTH_32F, *
+* Gradient mask - IPL_DEPTH_8U or IPL_DEPTH_8S, *
+* Motion orientation image - IPL_DEPTH_32F *
+* Segmentation mask - IPL_DEPTH_32F *
+* All the angles are in degrees, all the times are in milliseconds *
+\****************************************************************************************/
+
+/* Updates motion history image given motion silhouette */
+CVAPI(void) cvUpdateMotionHistory( const CvArr* silhouette, CvArr* mhi,
+ double timestamp, double duration );
+
+/* Calculates gradient of the motion history image and fills
+ a mask indicating where the gradient is valid */
+CVAPI(void) cvCalcMotionGradient( const CvArr* mhi, CvArr* mask, CvArr* orientation,
+ double delta1, double delta2,
+ int aperture_size CV_DEFAULT(3));
+
+/* Calculates average motion direction within a selected motion region
+ (region can be selected by setting ROIs and/or by composing a valid gradient mask
+ with the region mask) */
+CVAPI(double) cvCalcGlobalOrientation( const CvArr* orientation, const CvArr* mask,
+ const CvArr* mhi, double timestamp,
+ double duration );
+
+/* Splits a motion history image into a few parts corresponding to separate independent motions
+ (e.g. left hand, right hand) */
+CVAPI(CvSeq*) cvSegmentMotion( const CvArr* mhi, CvArr* seg_mask,
+ CvMemStorage* storage,
+ double timestamp, double seg_thresh );
+
+/****************************************************************************************\
+* Tracking *
+\****************************************************************************************/
+
+/* Implements CAMSHIFT algorithm - determines object position, size and orientation
+ from the object histogram back project (extension of meanshift) */
+CVAPI(int) cvCamShift( const CvArr* prob_image, CvRect window,
+ CvTermCriteria criteria, CvConnectedComp* comp,
+ CvBox2D* box CV_DEFAULT(NULL) );
+
+/* Implements MeanShift algorithm - determines object position
+ from the object histogram back project */
+CVAPI(int) cvMeanShift( const CvArr* prob_image, CvRect window,
+ CvTermCriteria criteria, CvConnectedComp* comp );
+
+/*
+standard Kalman filter (in G. Welch' and G. Bishop's notation):
+
+ x(k)=A*x(k-1)+B*u(k)+w(k) p(w)~N(0,Q)
+ z(k)=H*x(k)+v(k), p(v)~N(0,R)
+*/
+typedef struct CvKalman
+{
+ int MP; /* number of measurement vector dimensions */
+ int DP; /* number of state vector dimensions */
+ int CP; /* number of control vector dimensions */
+
+ /* backward compatibility fields */
+#if 1
+ float* PosterState; /* =state_pre->data.fl */
+ float* PriorState; /* =state_post->data.fl */
+ float* DynamMatr; /* =transition_matrix->data.fl */
+ float* MeasurementMatr; /* =measurement_matrix->data.fl */
+ float* MNCovariance; /* =measurement_noise_cov->data.fl */
+ float* PNCovariance; /* =process_noise_cov->data.fl */
+ float* KalmGainMatr; /* =gain->data.fl */
+ float* PriorErrorCovariance;/* =error_cov_pre->data.fl */
+ float* PosterErrorCovariance;/* =error_cov_post->data.fl */
+ float* Temp1; /* temp1->data.fl */
+ float* Temp2; /* temp2->data.fl */
+#endif
+
+ CvMat* state_pre; /* predicted state (x'(k)):
+ x(k)=A*x(k-1)+B*u(k) */
+ CvMat* state_post; /* corrected state (x(k)):
+ x(k)=x'(k)+K(k)*(z(k)-H*x'(k)) */
+ CvMat* transition_matrix; /* state transition matrix (A) */
+ CvMat* control_matrix; /* control matrix (B)
+ (it is not used if there is no control)*/
+ CvMat* measurement_matrix; /* measurement matrix (H) */
+ CvMat* process_noise_cov; /* process noise covariance matrix (Q) */
+ CvMat* measurement_noise_cov; /* measurement noise covariance matrix (R) */
+ CvMat* error_cov_pre; /* priori error estimate covariance matrix (P'(k)):
+ P'(k)=A*P(k-1)*At + Q)*/
+ CvMat* gain; /* Kalman gain matrix (K(k)):
+ K(k)=P'(k)*Ht*inv(H*P'(k)*Ht+R)*/
+ CvMat* error_cov_post; /* posteriori error estimate covariance matrix (P(k)):
+ P(k)=(I-K(k)*H)*P'(k) */
+ CvMat* temp1; /* temporary matrices */
+ CvMat* temp2;
+ CvMat* temp3;
+ CvMat* temp4;
+ CvMat* temp5;
+} CvKalman;
+
+/* Creates Kalman filter and sets A, B, Q, R and state to some initial values */
+CVAPI(CvKalman*) cvCreateKalman( int dynam_params, int measure_params,
+ int control_params CV_DEFAULT(0));
+
+/* Releases Kalman filter state */
+CVAPI(void) cvReleaseKalman( CvKalman** kalman);
+
+/* Updates Kalman filter by time (predicts future state of the system) */
+CVAPI(const CvMat*) cvKalmanPredict( CvKalman* kalman,
+ const CvMat* control CV_DEFAULT(NULL));
+
+/* Updates Kalman filter by measurement
+ (corrects state of the system and internal matrices) */
+CVAPI(const CvMat*) cvKalmanCorrect( CvKalman* kalman, const CvMat* measurement );
+
+#define cvKalmanUpdateByTime cvKalmanPredict
+#define cvKalmanUpdateByMeasurement cvKalmanCorrect
+
+/** @} video_c */
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
+
+
+#endif // OPENCV_TRACKING_C_H
diff --git a/include/opencv2/video/video.hpp b/include/opencv2/video/video.hpp
new file mode 100755
index 0000000..8267b85
--- /dev/null
+++ b/include/opencv2/video/video.hpp
@@ -0,0 +1,48 @@
+/*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) 2009, Willow Garage Inc., all rights reserved.
+// Copyright (C) 2013, OpenCV Foundation, 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*/
+
+#ifdef __OPENCV_BUILD
+#error this is a compatibility header which should not be used inside the OpenCV library
+#endif
+
+#include "opencv2/video.hpp"