diff --git a/.gitignore b/.gitignore
index 856505c..36920cd 100644
--- a/.gitignore
+++ b/.gitignore
@@ -50,3 +50,8 @@ _doc/
_bin/
.settings/
ImagePlay.VC.db
+
+# release-related dirs
+IPL/release/
+IPL/debug/
+IPL/lib/
diff --git a/IPL/.qmake.stash b/IPL/.qmake.stash
deleted file mode 100644
index 1b8387c..0000000
--- a/IPL/.qmake.stash
+++ /dev/null
@@ -1,67 +0,0 @@
-QMAKE_XCODE_DEVELOPER_PATH = /Applications/Xcode.app/Contents/Developer
-QMAKE_XCODE_VERSION = 6.1.1
-QMAKE_MAC_SDK.macosx.path = /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk
-QMAKE_MAC_SDK.macx-clang.macosx.QMAKE_CC = /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang
-QMAKE_MAC_SDK.macx-clang.macosx.QMAKE_CXX = /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++
-QMAKE_MAC_SDK.macx-clang.macosx.QMAKE_FIX_RPATH = \
- /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/install_name_tool \
- -id
-QMAKE_MAC_SDK.macx-clang.macosx.QMAKE_AR = \
- /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ar \
- cq
-QMAKE_MAC_SDK.macx-clang.macosx.QMAKE_RANLIB = \
- /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib \
- -s
-QMAKE_MAC_SDK.macx-clang.macosx.QMAKE_LINK = /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++
-QMAKE_MAC_SDK.macx-clang.macosx.QMAKE_LINK_SHLIB = /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++
-QMAKE_MAC_SDK.macosx.platform_name = macosx
-QMAKE_MAC_SDK.macosx.version = 10.10
-QMAKE_MAC_SDK.macosx.platform_path = /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform
-QMAKE_MAC_SDK.macosx10.11.path = /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk
-QMAKE_MAC_SDK.macosx10.11.platform_path = /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform
-QMAKE_MAC_SDK.macosx10.11.version = 10.11
-QMAKE_MAC_SDK.macx-clang.macosx10.11.QMAKE_CC = /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang
-QMAKE_MAC_SDK.macx-clang.macosx10.11.QMAKE_CXX = /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++
-QMAKE_MAC_SDK.macx-clang.macosx10.11.QMAKE_FIX_RPATH = \
- /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/install_name_tool \
- -id
-QMAKE_MAC_SDK.macx-clang.macosx10.11.QMAKE_AR = \
- /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ar \
- cq
-QMAKE_MAC_SDK.macx-clang.macosx10.11.QMAKE_RANLIB = \
- /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib \
- -s
-QMAKE_MAC_SDK.macx-clang.macosx10.11.QMAKE_LINK = /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++
-QMAKE_MAC_SDK.macx-clang.macosx10.11.QMAKE_LINK_SHLIB = /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++
-QMAKE_MAC_SDK.macosx10.11.platform_name = macosx
-QMAKE_MAC_SDK.macosx10.12.path = /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk
-QMAKE_MAC_SDK.macosx10.12.platform_path = /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform
-QMAKE_MAC_SDK.macosx10.12.version = 10.12
-QMAKE_MAC_SDK.macx-clang.macosx10.12.QMAKE_CC = /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang
-QMAKE_MAC_SDK.macx-clang.macosx10.12.QMAKE_CXX = /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++
-QMAKE_MAC_SDK.macx-clang.macosx10.12.QMAKE_FIX_RPATH = \
- /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/install_name_tool \
- -id
-QMAKE_MAC_SDK.macx-clang.macosx10.12.QMAKE_AR = \
- /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ar \
- cq
-QMAKE_MAC_SDK.macx-clang.macosx10.12.QMAKE_RANLIB = \
- /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib \
- -s
-QMAKE_MAC_SDK.macx-clang.macosx10.12.QMAKE_LINK = /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++
-QMAKE_MAC_SDK.macx-clang.macosx10.12.QMAKE_LINK_SHLIB = /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++
-QMAKE_MAC_SDK.macosx10.12.platform_name = macosx
-QMAKE_DEFAULT_INCDIRS = \
- /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1 \
- /usr/local/include \
- /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/8.0.0/include \
- /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include \
- /usr/include \
- "/System/Library/Frameworks (framework directory)" \
- "/Library/Frameworks (framework directory)"
-QMAKE_DEFAULT_LIBDIRS = \
- /lib \
- /usr/lib
-QMAKE_MAC_SDK.macosx10.12.Path = /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk
-QMAKE_MAC_SDK.macosx10.12.PlatformPath = /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform
-QMAKE_MAC_SDK.macosx10.12.SDKVersion = 10.12
diff --git a/IPL/IPL.pro b/IPL/IPL.pro
index 0a656ba..e38c58b 100644
--- a/IPL/IPL.pro
+++ b/IPL/IPL.pro
@@ -1,166 +1,166 @@
-#############################################################################
-#
-# This file is part of ImagePlay.
-#
-# ImagePlay is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# ImagePlay is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with ImagePlay. If not, see .
-#
-##############################################################################
-
-CONFIG -= qt
-
-TARGET = IPL
-CONFIG(debug, debug|release): DESTDIR = ../ImagePlay/debug
-else: DESTDIR = ../ImagePlay/release
-
-#define platform variable for folder name
-win32 {contains(QMAKE_TARGET.arch, x86_64) {PLATFORM = x64} else {PLATFORM = Win32}}
-macx {PLATFORM = macx}
-unix:!macx:!android {PLATFORM = linux}
-
-#define configuration variable for folder name
-CONFIG(debug, debug|release) {CONFIGURATION = Debug} else {CONFIGURATION = Release}
-
-DESTDIR = ../_bin/$$CONFIGURATION/$$PLATFORM
-OBJECTS_DIR = ../intermediate/$$TARGET/$$CONFIGURATION/$$PLATFORM
-MOC_DIR = ../intermediate/$$TARGET/$$CONFIGURATION/$$PLATFORM
-RCC_DIR = ../intermediate/$$TARGET/$$CONFIGURATION/$$PLATFORM
-UI_DIR = ../intermediate/$$TARGET/$$CONFIGURATION/$$PLATFORM
-
-#TEMPLATE = vclib
-TEMPLATE = lib
-#CONFIG += lib_bundle
-
-
-DEFINES += IPL_LIBRARY
-
-HEADERS += $$files(*.h,true)
-SOURCES += $$files(*.cpp,true)
-OTHER_FILES += $$files(*,true)
-
-#win32: LIBS += -L$$PWD/lib/FreeImage/ -lFreeImage
-
-#INCLUDEPATH += $$PWD/lib/FreeImage/
-#DEPENDPATH += $$PWD/lib/FreeImage/
-
-#win32: PRE_TARGETDEPS += $$PWD/lib/FreeImage/FreeImage.lib
-
-win32 {
- # dirent
- INCLUDEPATH += $$PWD/lib/
- SOURCES += include/dirent/dirent.c
- HEADERS += include/dirent/dirent.h
-
- # freeimage
- LIBS += -L$$PWD/../_lib/freeimage/ -lFreeImage
- INCLUDEPATH += $$PWD/../_lib/freeimage
- DEPENDPATH += $$PWD/../_lib/freeimage
-
- # opencv
- CONFIG(release, debug|release) {
- LIBS += -L$$PWD/../_lib/opencv/x64/vc14/lib/ -lopencv_core310
- LIBS += -L$$PWD/../_lib/opencv/x64/vc14/lib/ -lopencv_imgproc310
- LIBS += -L$$PWD/../_lib/opencv/x64/vc14/lib/ -lopencv_highgui310
- LIBS += -L$$PWD/../_lib/opencv/x64/vc14/lib/ -lopencv_videoio310
- LIBS += -L$$PWD/../_lib/opencv/x64/vc14/lib/ -lopencv_calib3d310
- LIBS += -L$$PWD/../_lib/opencv/x64/vc14/lib/ -lopencv_optflow310
- LIBS += -L$$PWD/../_lib/opencv/x64/vc14/lib/ -lopencv_features2d310
- LIBS += -L$$PWD/../_lib/opencv/x64/vc14/lib/ -lopencv_xfeatures2d310
- LIBS += -L$$PWD/../_lib/opencv/x64/vc14/lib/ -lopencv_photo310
- LIBS += -L$$PWD/../_lib/opencv/x64/vc14/lib/ -lopencv_xphoto310
- } else {
- LIBS += -L$$PWD/../_lib/opencv/x64/vc14/lib/ -lopencv_core310d
- LIBS += -L$$PWD/../_lib/opencv/x64/vc14/lib/ -lopencv_imgproc310d
- LIBS += -L$$PWD/../_lib/opencv/x64/vc14/lib/ -lopencv_highgui310d
- LIBS += -L$$PWD/../_lib/opencv/x64/vc14/lib/ -lopencv_videoio310d
- LIBS += -L$$PWD/../_lib/opencv/x64/vc14/lib/ -lopencv_calib3d310d
- LIBS += -L$$PWD/../_lib/opencv/x64/vc14/lib/ -lopencv_optflow310d
- LIBS += -L$$PWD/../_lib/opencv/x64/vc14/lib/ -lopencv_features2d310d
- LIBS += -L$$PWD/../_lib/opencv/x64/vc14/lib/ -lopencv_xfeatures2d310d
- LIBS += -L$$PWD/../_lib/opencv/x64/vc14/lib/ -lopencv_photo310d
- LIBS += -L$$PWD/../_lib/opencv/x64/vc14/lib/ -lopencv_xphoto310d
- }
-}
-
-
-
-macx {
- QMAKE_MAC_SDK = macosx10.12
- LIBS += -L$$PWD/../_lib/freeimage/ -lfreeimage-3.16.0
-
- INCLUDEPATH += $$PWD/../_lib/freeimage
- DEPENDPATH += $$PWD/../_lib/freeimage
-
- #DESTDIR = ../_bin/$$CONFIGURATION/$$PLATFORM/ImagePlay.app/Contents/Frameworks/
- DESTDIR = ../_lib/
-
- LIBS += -L$$PWD/../_lib/opencv/x64/clang/lib/ -lopencv_core.3.1.0
- LIBS += -L$$PWD/../_lib/opencv/x64/clang/lib/ -lopencv_imgproc.3.1.0
- LIBS += -L$$PWD/../_lib/opencv/x64/clang/lib/ -lopencv_highgui.3.1.0
- LIBS += -L$$PWD/../_lib/opencv/x64/clang/lib/ -lopencv_videoio.3.1.0
- LIBS += -L$$PWD/../_lib/opencv/x64/clang/lib/ -lopencv_calib3d.3.1.0
- LIBS += -L$$PWD/../_lib/opencv/x64/clang/lib/ -lopencv_optflow.3.1.0
- LIBS += -L$$PWD/../_lib/opencv/x64/clang/lib/ -lopencv_features2d.3.1.0
- LIBS += -L$$PWD/../_lib/opencv/x64/clang/lib/ -lopencv_xfeatures2d.3.1.0
- LIBS += -L$$PWD/../_lib/opencv/x64/clang/lib/ -lopencv_photo.3.1.0
- LIBS += -L$$PWD/../_lib/opencv/x64/clang/lib/ -lopencv_xphoto.3.1.0
-
-}
-
-linux {
- CONFIG += staticlib
-
- LIBS += -lfreeimage
- LIBS += -lopencv_core
- LIBS += -lopencv_imgproc
- LIBS += -lopencv_highgui
- LIBS += -lopencv_videoio
- LIBS += -lopencv_calib3d
- LIBS += -lopencv_optflow
- LIBS += -lopencv_features2d
- LIBS += -lopencv_xfeatures2d
- LIBS += -lopencv_photo
- LIBS += -lopencv_xphoto
-
- DESTDIR = ../_bin/$$CONFIGURATION/$$PLATFORM/
-}
-
-msvc {
- QMAKE_CXXFLAGS += -openmp
- QMAKE_LFLAGS += -openmp
-
- #QMAKE_CXXFLAGS_RELEASE -= -O1
- #QMAKE_CXXFLAGS_RELEASE -= -O2
- #QMAKE_CXXFLAGS_RELEASE *= -O3
-}
-
-clang {
- CONFIG +=c++11
- QMAKE_CXXFLAGS += -openmp
- QMAKE_LFLAGS += -openmp
-}
-
-gcc:!clang {
- CONFIG +=c++11
- QMAKE_CXXFLAGS += -fopenmp
- QMAKE_LFLAGS += -fopenmp
- LIBS += -lgomp
-}
-
-
-# IPL
-INCLUDEPATH += $$PWD/include/
-INCLUDEPATH += $$PWD/include/processes/
-
-# OpenCV
-INCLUDEPATH += $$PWD/include/opencv/
+#############################################################################
+#
+# This file is part of ImagePlay.
+#
+# ImagePlay is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# ImagePlay is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with ImagePlay. If not, see .
+#
+##############################################################################
+
+CONFIG -= qt
+
+TARGET = IPL
+CONFIG(debug, debug|release): DESTDIR = ../ImagePlay/debug
+else: DESTDIR = ../ImagePlay/release
+
+#define platform variable for folder name
+win32 {contains(QMAKE_TARGET.arch, x86_64) {PLATFORM = x64} else {PLATFORM = Win32}}
+macx {PLATFORM = macx}
+unix:!macx:!android {PLATFORM = linux}
+
+#define configuration variable for folder name
+CONFIG(debug, debug|release) {CONFIGURATION = Debug} else {CONFIGURATION = Release}
+
+DESTDIR = ../_bin/$$CONFIGURATION/$$PLATFORM
+OBJECTS_DIR = ../intermediate/$$TARGET/$$CONFIGURATION/$$PLATFORM
+MOC_DIR = ../intermediate/$$TARGET/$$CONFIGURATION/$$PLATFORM
+RCC_DIR = ../intermediate/$$TARGET/$$CONFIGURATION/$$PLATFORM
+UI_DIR = ../intermediate/$$TARGET/$$CONFIGURATION/$$PLATFORM
+
+#TEMPLATE = vclib
+TEMPLATE = lib
+#CONFIG += lib_bundle
+
+
+DEFINES += IPL_LIBRARY
+
+HEADERS += $$files(*.h,true)
+SOURCES += $$files(*.cpp,true)
+OTHER_FILES += $$files(*,true)
+
+win32: LIBS += -L$$PWD/lib/FreeImage/ -lFreeImage
+
+INCLUDEPATH += $$PWD/lib/FreeImage/
+DEPENDPATH += $$PWD/lib/FreeImage/
+
+win32: PRE_TARGETDEPS += $$PWD/lib/FreeImage/FreeImage.lib
+
+win32 {
+ # dirent
+ INCLUDEPATH += $$PWD/lib/
+ SOURCES += include/dirent/dirent.c
+ HEADERS += include/dirent/dirent.h
+
+ # freeimage
+ LIBS += -L$$PWD/../_lib/freeimage/ -lFreeImage
+ INCLUDEPATH += $$PWD/../_lib/freeimage
+ DEPENDPATH += $$PWD/../_lib/freeimage
+
+ # opencv
+ CONFIG(release, debug|release) {
+ LIBS += -L$$PWD/../_lib/opencv/x64/vc16/lib/ -lopencv_core430
+ LIBS += -L$$PWD/../_lib/opencv/x64/vc16/lib/ -lopencv_imgproc430
+ LIBS += -L$$PWD/../_lib/opencv/x64/vc16/lib/ -lopencv_highgui430
+ LIBS += -L$$PWD/../_lib/opencv/x64/vc16/lib/ -lopencv_videoio430
+ LIBS += -L$$PWD/../_lib/opencv/x64/vc16/lib/ -lopencv_calib3d430
+ LIBS += -L$$PWD/../_lib/opencv/x64/vc16/lib/ -lopencv_optflow430
+ LIBS += -L$$PWD/../_lib/opencv/x64/vc16/lib/ -lopencv_features2d430
+ LIBS += -L$$PWD/../_lib/opencv/x64/vc16/lib/ -lopencv_xfeatures2d430
+ LIBS += -L$$PWD/../_lib/opencv/x64/vc16/lib/ -lopencv_photo430
+ LIBS += -L$$PWD/../_lib/opencv/x64/vc16/lib/ -lopencv_xphoto430
+ } else {
+ LIBS += -L$$PWD/../_lib/opencv/x64/vc16/lib/ -lopencv_core430d
+ LIBS += -L$$PWD/../_lib/opencv/x64/vc16/lib/ -lopencv_imgproc430d
+ LIBS += -L$$PWD/../_lib/opencv/x64/vc16/lib/ -lopencv_highgui430d
+ LIBS += -L$$PWD/../_lib/opencv/x64/vc16/lib/ -lopencv_videoio430d
+ LIBS += -L$$PWD/../_lib/opencv/x64/vc16/lib/ -lopencv_calib3d430d
+ LIBS += -L$$PWD/../_lib/opencv/x64/vc16/lib/ -lopencv_optflow430d
+ LIBS += -L$$PWD/../_lib/opencv/x64/vc16/lib/ -lopencv_features2d430d
+ LIBS += -L$$PWD/../_lib/opencv/x64/vc16/lib/ -lopencv_xfeatures2d430d
+ LIBS += -L$$PWD/../_lib/opencv/x64/vc16/lib/ -lopencv_photo430d
+ LIBS += -L$$PWD/../_lib/opencv/x64/vc16/lib/ -lopencv_xphoto430d
+ }
+}
+
+
+
+macx {
+ QMAKE_MAC_SDK = macosx10.12
+ LIBS += -L$$PWD/../_lib/freeimage/ -lfreeimage-3.16.0
+
+ INCLUDEPATH += $$PWD/../_lib/freeimage
+ DEPENDPATH += $$PWD/../_lib/freeimage
+
+ #DESTDIR = ../_bin/$$CONFIGURATION/$$PLATFORM/ImagePlay.app/Contents/Frameworks/
+ DESTDIR = ../_lib/
+
+ LIBS += -L$$PWD/../_lib/opencv/x64/clang/lib/ -lopencv_core.3.1.0
+ LIBS += -L$$PWD/../_lib/opencv/x64/clang/lib/ -lopencv_imgproc.3.1.0
+ LIBS += -L$$PWD/../_lib/opencv/x64/clang/lib/ -lopencv_highgui.3.1.0
+ LIBS += -L$$PWD/../_lib/opencv/x64/clang/lib/ -lopencv_videoio.3.1.0
+ LIBS += -L$$PWD/../_lib/opencv/x64/clang/lib/ -lopencv_calib3d.3.1.0
+ LIBS += -L$$PWD/../_lib/opencv/x64/clang/lib/ -lopencv_optflow.3.1.0
+ LIBS += -L$$PWD/../_lib/opencv/x64/clang/lib/ -lopencv_features2d.3.1.0
+ LIBS += -L$$PWD/../_lib/opencv/x64/clang/lib/ -lopencv_xfeatures2d.3.1.0
+ LIBS += -L$$PWD/../_lib/opencv/x64/clang/lib/ -lopencv_photo.3.1.0
+ LIBS += -L$$PWD/../_lib/opencv/x64/clang/lib/ -lopencv_xphoto.3.1.0
+
+}
+
+linux {
+ CONFIG += staticlib
+
+ LIBS += -lfreeimage
+ LIBS += -lopencv_core
+ LIBS += -lopencv_imgproc
+ LIBS += -lopencv_highgui
+ LIBS += -lopencv_videoio
+ LIBS += -lopencv_calib3d
+ LIBS += -lopencv_optflow
+ LIBS += -lopencv_features2d
+ LIBS += -lopencv_xfeatures2d
+ LIBS += -lopencv_photo
+ LIBS += -lopencv_xphoto
+
+ DESTDIR = ../_bin/$$CONFIGURATION/$$PLATFORM/
+}
+
+msvc {
+ QMAKE_CXXFLAGS += -openmp
+ QMAKE_LFLAGS += -openmp
+
+ #QMAKE_CXXFLAGS_RELEASE -= -O1
+ #QMAKE_CXXFLAGS_RELEASE -= -O2
+ #QMAKE_CXXFLAGS_RELEASE *= -O3
+}
+
+clang {
+ CONFIG +=c++11
+ QMAKE_CXXFLAGS += -openmp
+ QMAKE_LFLAGS += -openmp
+}
+
+gcc:!clang {
+ CONFIG +=c++11
+ QMAKE_CXXFLAGS += -fopenmp
+ QMAKE_LFLAGS += -fopenmp
+ LIBS += -lgomp
+}
+
+
+# IPL
+INCLUDEPATH += $$PWD/include/
+INCLUDEPATH += $$PWD/include/processes/
+
+# OpenCV
+INCLUDEPATH += $$PWD/include/opencv/
diff --git a/IPL/include/opencv/opencv/cv.hpp b/IPL/include/opencv/opencv/cv.hpp
deleted file mode 100644
index e498d7a..0000000
--- a/IPL/include/opencv/opencv/cv.hpp
+++ /dev/null
@@ -1,60 +0,0 @@
-/*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/IPL/include/opencv/opencv/cvaux.h b/IPL/include/opencv/opencv/cvaux.h
deleted file mode 100644
index fe86c5d..0000000
--- a/IPL/include/opencv/opencv/cvaux.h
+++ /dev/null
@@ -1,57 +0,0 @@
-/*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/IPL/include/opencv/opencv/cvwimage.h b/IPL/include/opencv/opencv/cvwimage.h
deleted file mode 100644
index de89c92..0000000
--- a/IPL/include/opencv/opencv/cvwimage.h
+++ /dev/null
@@ -1,46 +0,0 @@
-///////////////////////////////////////////////////////////////////////////////
-// 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/IPL/include/opencv/opencv/cxmisc.h b/IPL/include/opencv/opencv/cxmisc.h
deleted file mode 100644
index 6c93a0c..0000000
--- a/IPL/include/opencv/opencv/cxmisc.h
+++ /dev/null
@@ -1,8 +0,0 @@
-#ifndef __OPENCV_OLD_CXMISC_H__
-#define __OPENCV_OLD_CXMISC_H__
-
-#ifdef __cplusplus
-# include "opencv2/core/utility.hpp"
-#endif
-
-#endif
diff --git a/IPL/include/opencv/opencv/ml.h b/IPL/include/opencv/opencv/ml.h
deleted file mode 100644
index d8e967f..0000000
--- a/IPL/include/opencv/opencv/ml.h
+++ /dev/null
@@ -1,47 +0,0 @@
-/*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/IPL/include/opencv/opencv2/aruco.hpp b/IPL/include/opencv/opencv2/aruco.hpp
index 3f45dc1..3cf62d2 100644
--- a/IPL/include/opencv/opencv2/aruco.hpp
+++ b/IPL/include/opencv/opencv2/aruco.hpp
@@ -49,14 +49,16 @@ the use of this software, even if advised of the possibility of such damage.
* These markers are useful for easy, fast and robust camera pose estimation.ç
*
* The main functionalities are:
- * - Detection of markers in a image
+ * - Detection of markers in an image
* - Pose estimation from a single marker or from a board/set of markers
* - Detection of ChArUco board for high subpixel accuracy
* - Camera calibration from both, ArUco boards and ChArUco boards.
* - Detection of ChArUco diamond markers
* The samples directory includes easy examples of how to use the module.
*
- * The implementation is based on the ArUco Library by R. Muñoz-Salinas and S. Garrido-Jurado.
+ * The implementation is based on the ArUco Library by R. Muñoz-Salinas and S. Garrido-Jurado @cite Aruco2014.
+ *
+ * Markers can also be detected based on the AprilTag 2 @cite wang2016iros fiducial detection method.
*
* @sa S. Garrido-Jurado, R. Muñoz-Salinas, F. J. Madrid-Cuevas, and M. J. Marín-Jiménez. 2014.
* "Automatic generation and detection of highly reliable fiducial markers under occlusion".
@@ -76,7 +78,12 @@ namespace aruco {
//! @addtogroup aruco
//! @{
-
+enum CornerRefineMethod{
+ CORNER_REFINE_NONE, ///< Tag and corners detection based on the ArUco approach
+ CORNER_REFINE_SUBPIX, ///< ArUco approach and refine the corners locations using corner subpixel accuracy
+ CORNER_REFINE_CONTOUR, ///< ArUco approach and refine the corners locations using the contour-points line fitting
+ CORNER_REFINE_APRILTAG, ///< Tag and corners detection based on the AprilTag 2 approach @cite wang2016iros
+};
/**
* @brief Parameters for the detectMarker process:
@@ -100,18 +107,20 @@ namespace aruco {
* - minMarkerDistanceRate: minimum mean distance beetween two marker corners to be considered
* similar, so that the smaller one is removed. The rate is relative to the smaller perimeter
* of the two markers (default 0.05).
- * - doCornerRefinement: do subpixel refinement or not
+ * - cornerRefinementMethod: corner refinement method. (CORNER_REFINE_NONE, no refinement.
+ * CORNER_REFINE_SUBPIX, do subpixel refinement. CORNER_REFINE_CONTOUR use contour-Points,
+ * CORNER_REFINE_APRILTAG use the AprilTag2 approach)
* - cornerRefinementWinSize: window size for the corner refinement process (in pixels) (default 5).
* - cornerRefinementMaxIterations: maximum number of iterations for stop criteria of the corner
* refinement process (default 30).
* - cornerRefinementMinAccuracy: minimum error for the stop cristeria of the corner refinement
* process (default: 0.1)
* - markerBorderBits: number of bits of the marker border, i.e. marker border width (default 1).
- * - perpectiveRemovePixelPerCell: number of bits (per dimension) for each cell of the marker
+ * - perspectiveRemovePixelPerCell: number of bits (per dimension) for each cell of the marker
* when removing the perspective (default 8).
* - perspectiveRemoveIgnoredMarginPerCell: width of the margin of pixels on each cell not
* considered for the determination of the cell bit. Represents the rate respect to the total
- * size of the cell, i.e. perpectiveRemovePixelPerCell (default 0.13)
+ * size of the cell, i.e. perspectiveRemovePixelPerCell (default 0.13)
* - maxErroneousBitsInBorderRate: maximum number of accepted erroneous bits in the border (i.e.
* number of allowed white bits in the border). Represented as a rate respect to the total
* number of bits per marker (default 0.35).
@@ -120,6 +129,23 @@ namespace aruco {
* than 128 or not) (default 5.0)
* - errorCorrectionRate error correction rate respect to the maximun error correction capability
* for each dictionary. (default 0.6).
+ * - aprilTagMinClusterPixels: reject quads containing too few pixels.
+ * - aprilTagMaxNmaxima: how many corner candidates to consider when segmenting a group of pixels into a quad.
+ * - aprilTagCriticalRad: Reject quads where pairs of edges have angles that are close to straight or close to
+ * 180 degrees. Zero means that no quads are rejected. (In radians).
+ * - aprilTagMaxLineFitMse: When fitting lines to the contours, what is the maximum mean squared error
+ * allowed? This is useful in rejecting contours that are far from being quad shaped; rejecting
+ * these quads "early" saves expensive decoding processing.
+ * - aprilTagMinWhiteBlackDiff: When we build our model of black & white pixels, we add an extra check that
+ * the white model must be (overall) brighter than the black model. How much brighter? (in pixel values, [0,255]).
+ * - aprilTagDeglitch: should the thresholded image be deglitched? Only useful for very noisy images
+ * - aprilTagQuadDecimate: Detection of quads can be done on a lower-resolution image, improving speed at a
+ * cost of pose accuracy and a slight decrease in detection rate. Decoding the binary payload is still
+ * done at full resolution.
+ * - aprilTagQuadSigma: What Gaussian blur should be applied to the segmented image (used for quad detection?)
+ * Parameter is the standard deviation in pixels. Very noisy images benefit from non-zero values (e.g. 0.8).
+ * - detectInvertedMarker: to check if there is a white marker. In order to generate a "white" marker just
+ * invert a normal marker by using a tilde, ~markerImage. (default false)
*/
struct CV_EXPORTS_W DetectorParameters {
@@ -137,7 +163,7 @@ struct CV_EXPORTS_W DetectorParameters {
CV_PROP_RW double minCornerDistanceRate;
CV_PROP_RW int minDistanceToBorder;
CV_PROP_RW double minMarkerDistanceRate;
- CV_PROP_RW bool doCornerRefinement;
+ CV_PROP_RW int cornerRefinementMethod;
CV_PROP_RW int cornerRefinementWinSize;
CV_PROP_RW int cornerRefinementMaxIterations;
CV_PROP_RW double cornerRefinementMinAccuracy;
@@ -147,6 +173,21 @@ struct CV_EXPORTS_W DetectorParameters {
CV_PROP_RW double maxErroneousBitsInBorderRate;
CV_PROP_RW double minOtsuStdDev;
CV_PROP_RW double errorCorrectionRate;
+
+ // April :: User-configurable parameters.
+ CV_PROP_RW float aprilTagQuadDecimate;
+ CV_PROP_RW float aprilTagQuadSigma;
+
+ // April :: Internal variables
+ CV_PROP_RW int aprilTagMinClusterPixels;
+ CV_PROP_RW int aprilTagMaxNmaxima;
+ CV_PROP_RW float aprilTagCriticalRad;
+ CV_PROP_RW float aprilTagMaxLineFitMse;
+ CV_PROP_RW int aprilTagMinWhiteBlackDiff;
+ CV_PROP_RW int aprilTagDeglitch;
+
+ // to detect white (inverted) markers
+ CV_PROP_RW bool detectInvertedMarker;
};
@@ -165,6 +206,10 @@ struct CV_EXPORTS_W DetectorParameters {
* @param parameters marker detection parameters
* @param rejectedImgPoints contains the imgPoints of those squares whose inner code has not a
* correct codification. Useful for debugging purposes.
+ * @param cameraMatrix optional input 3x3 floating-point camera matrix
+ * \f$A = \vecthreethree{f_x}{0}{c_x}{0}{f_y}{c_y}{0}{0}{1}\f$
+ * @param distCoeff optional vector of distortion coefficients
+ * \f$(k_1, k_2, p_1, p_2[, k_3[, k_4, k_5, k_6],[s_1, s_2, s_3, s_4]])\f$ of 4, 5, 8 or 12 elements
*
* Performs marker detection in the input image. Only markers included in the specific dictionary
* are searched. For each detected marker, it returns the 2D position of its corner in the image
@@ -173,9 +218,9 @@ struct CV_EXPORTS_W DetectorParameters {
* @sa estimatePoseSingleMarkers, estimatePoseBoard
*
*/
-CV_EXPORTS_W void detectMarkers(InputArray image, Ptr &dictionary, OutputArrayOfArrays corners,
+CV_EXPORTS_W void detectMarkers(InputArray image, const Ptr &dictionary, OutputArrayOfArrays corners,
OutputArray ids, const Ptr ¶meters = DetectorParameters::create(),
- OutputArrayOfArrays rejectedImgPoints = noArray());
+ OutputArrayOfArrays rejectedImgPoints = noArray(), InputArray cameraMatrix= noArray(), InputArray distCoeff= noArray());
@@ -192,10 +237,11 @@ CV_EXPORTS_W void detectMarkers(InputArray image, Ptr &dictionary, O
* \f$A = \vecthreethree{f_x}{0}{c_x}{0}{f_y}{c_y}{0}{0}{1}\f$
* @param distCoeffs vector of distortion coefficients
* \f$(k_1, k_2, p_1, p_2[, k_3[, k_4, k_5, k_6],[s_1, s_2, s_3, s_4]])\f$ of 4, 5, 8 or 12 elements
- * @param rvecs array of output rotation vectors (@sa Rodrigues) (e.g. std::vector>).
+ * @param rvecs array of output rotation vectors (@sa Rodrigues) (e.g. std::vector).
* Each element in rvecs corresponds to the specific marker in imgPoints.
- * @param tvecs array of output translation vectors (e.g. std::vector>).
+ * @param tvecs array of output translation vectors (e.g. std::vector).
* Each element in tvecs corresponds to the specific marker in imgPoints.
+ * @param _objPoints array of object points of all the marker corners
*
* This function receives the detected markers and returns their pose estimation respect to
* the camera individually. So for each marker, one rotation and translation vector is returned.
@@ -209,14 +255,14 @@ CV_EXPORTS_W void detectMarkers(InputArray image, Ptr &dictionary, O
*/
CV_EXPORTS_W void estimatePoseSingleMarkers(InputArrayOfArrays corners, float markerLength,
InputArray cameraMatrix, InputArray distCoeffs,
- OutputArrayOfArrays rvecs, OutputArrayOfArrays tvecs);
+ OutputArray rvecs, OutputArray tvecs, OutputArray _objPoints = noArray());
/**
* @brief Board of markers
*
- * A board is a set of markers in the 3D space with a common cordinate system.
+ * A board is a set of markers in the 3D space with a common coordinate system.
* The common form of a board of marker is a planar (2D) board, however any 3D layout can be used.
* A Board object is composed by:
* - The object points of the marker corners, i.e. their coordinates respect to the board system.
@@ -226,23 +272,32 @@ CV_EXPORTS_W void estimatePoseSingleMarkers(InputArrayOfArrays corners, float ma
class CV_EXPORTS_W Board {
public:
- // array of object points of all the marker corners in the board
- // each marker include its 4 corners, i.e. for M markers, the size is Mx4
- std::vector< std::vector< Point3f > > objPoints;
-
- // the dictionary of markers employed for this board
- Ptr dictionary;
-
- // vector of the identifiers of the markers in the board (same size than objPoints)
- // The identifiers refers to the board dictionary
- std::vector< int > ids;
+ /**
+ * @brief Provide way to create Board by passing necessary data. Specially needed in Python.
+ *
+ * @param objPoints array of object points of all the marker corners in the board
+ * @param dictionary the dictionary of markers employed for this board
+ * @param ids vector of the identifiers of the markers in the board
+ *
+ */
+ CV_WRAP static Ptr create(InputArrayOfArrays objPoints, const Ptr &dictionary, InputArray ids);
+ /// array of object points of all the marker corners in the board
+ /// each marker include its 4 corners in CCW order. For M markers, the size is Mx4.
+ CV_PROP std::vector< std::vector< Point3f > > objPoints;
+
+ /// the dictionary of markers employed for this board
+ CV_PROP Ptr dictionary;
+
+ /// vector of the identifiers of the markers in the board (same size than objPoints)
+ /// The identifiers refers to the board dictionary
+ CV_PROP std::vector< int > ids;
};
/**
* @brief Planar board with grid arrangement of markers
- * More common type of board. All markers are placed in the same plane in a grid arrangment.
+ * More common type of board. All markers are placed in the same plane in a grid arrangement.
* The board can be drawn using drawPlanarBoard() function (@sa drawPlanarBoard)
*/
class CV_EXPORTS_W GridBoard : public Board {
@@ -259,7 +314,7 @@ class CV_EXPORTS_W GridBoard : public Board {
*
* This function return the image of the GridBoard, ready to be printed.
*/
- void draw(Size outSize, OutputArray img, int marginSize = 0, int borderBits = 1);
+ CV_WRAP void draw(Size outSize, OutputArray img, int marginSize = 0, int borderBits = 1);
/**
@@ -277,29 +332,29 @@ class CV_EXPORTS_W GridBoard : public Board {
* the marker size and marker separation.
*/
CV_WRAP static Ptr create(int markersX, int markersY, float markerLength,
- float markerSeparation, Ptr &dictionary, int firstMarker = 0);
+ float markerSeparation, const Ptr &dictionary, int firstMarker = 0);
/**
*
*/
- Size getGridSize() const { return Size(_markersX, _markersY); }
+ CV_WRAP Size getGridSize() const { return Size(_markersX, _markersY); }
/**
*
*/
- float getMarkerLength() const { return _markerLength; }
+ CV_WRAP float getMarkerLength() const { return _markerLength; }
/**
*
*/
- float getMarkerSeparation() const { return _markerSeparation; }
+ CV_WRAP float getMarkerSeparation() const { return _markerSeparation; }
private:
// number of markers in X and Y directions
int _markersX, _markersY;
- // marker side lenght (normally in meters)
+ // marker side length (normally in meters)
float _markerLength;
// separation between markers in the grid
@@ -322,8 +377,10 @@ class CV_EXPORTS_W GridBoard : public Board {
* @param distCoeffs vector of distortion coefficients
* \f$(k_1, k_2, p_1, p_2[, k_3[, k_4, k_5, k_6],[s_1, s_2, s_3, s_4]])\f$ of 4, 5, 8 or 12 elements
* @param rvec Output vector (e.g. cv::Mat) corresponding to the rotation vector of the board
- * (@sa Rodrigues).
+ * (see cv::Rodrigues). Used as initial guess if not empty.
* @param tvec Output vector (e.g. cv::Mat) corresponding to the translation vector of the board.
+ * @param useExtrinsicGuess defines whether initial guess for \b rvec and \b tvec will be used or not.
+ * Used as initial guess if not empty.
*
* This function receives the detected markers and returns the pose of a marker board composed
* by those markers.
@@ -334,9 +391,9 @@ class CV_EXPORTS_W GridBoard : public Board {
* The function returns the number of markers from the input employed for the board pose estimation.
* Note that returning a 0 means the pose has not been estimated.
*/
-CV_EXPORTS_W int estimatePoseBoard(InputArrayOfArrays corners, InputArray ids, Ptr &board,
- InputArray cameraMatrix, InputArray distCoeffs, OutputArray rvec,
- OutputArray tvec);
+CV_EXPORTS_W int estimatePoseBoard(InputArrayOfArrays corners, InputArray ids, const Ptr &board,
+ InputArray cameraMatrix, InputArray distCoeffs, InputOutputArray rvec,
+ InputOutputArray tvec, bool useExtrinsicGuess = false);
@@ -373,8 +430,8 @@ CV_EXPORTS_W int estimatePoseBoard(InputArrayOfArrays corners, InputArray ids, P
* homography, and all the marker corners in the board must have the same Z coordinate.
*/
CV_EXPORTS_W void refineDetectedMarkers(
- InputArray image, Ptr &board, InputOutputArrayOfArrays detectedCorners,
- InputOutputArray detectedIds, InputOutputArray rejectedCorners,
+ InputArray image,const Ptr &board, InputOutputArrayOfArrays detectedCorners,
+ InputOutputArray detectedIds, InputOutputArrayOfArrays rejectedCorners,
InputArray cameraMatrix = noArray(), InputArray distCoeffs = noArray(),
float minRepDistance = 10.f, float errorCorrectionRate = 3.f, bool checkAllOrders = true,
OutputArray recoveredIdxs = noArray(), const Ptr ¶meters = DetectorParameters::create());
@@ -419,6 +476,8 @@ CV_EXPORTS_W void drawDetectedMarkers(InputOutputArray image, InputArrayOfArrays
*
* Given the pose estimation of a marker or board, this function draws the axis of the world
* coordinate system, i.e. the system centered on the marker/board. Useful for debugging purposes.
+ *
+ * @deprecated use cv::drawFrameAxes
*/
CV_EXPORTS_W void drawAxis(InputOutputArray image, InputArray cameraMatrix, InputArray distCoeffs,
InputArray rvec, InputArray tvec, float length);
@@ -437,7 +496,7 @@ CV_EXPORTS_W void drawAxis(InputOutputArray image, InputArray cameraMatrix, Inpu
*
* This function returns a marker image in its canonical form (i.e. ready to be printed)
*/
-CV_EXPORTS_W void drawMarker(Ptr &dictionary, int id, int sidePixels, OutputArray img,
+CV_EXPORTS_W void drawMarker(const Ptr &dictionary, int id, int sidePixels, OutputArray img,
int borderBits = 1);
@@ -457,7 +516,7 @@ CV_EXPORTS_W void drawMarker(Ptr &dictionary, int id, int sidePixels
* This function return the image of a planar board, ready to be printed. It assumes
* the Board layout specified is planar by ignoring the z coordinates of the object points.
*/
-CV_EXPORTS_W void drawPlanarBoard(Ptr &board, Size outSize, OutputArray img,
+CV_EXPORTS_W void drawPlanarBoard(const Ptr &board, Size outSize, OutputArray img,
int marginSize = 0, int borderBits = 1);
@@ -474,7 +533,7 @@ void _drawPlanarBoardImpl(Board *board, Size outSize, OutputArray img,
* @brief Calibrate a camera using aruco markers
*
* @param corners vector of detected marker corners in all frames.
- * The corners should have the same format returned by detectMarkers (@sa detectMarkers).
+ * The corners should have the same format returned by detectMarkers (see #detectMarkers).
* @param ids list of identifiers for each marker in corners
* @param counter number of markers in each frame so that corners and ids can be split
* @param board Marker Board layout
@@ -491,20 +550,52 @@ void _drawPlanarBoardImpl(Board *board, Size outSize, OutputArray img,
* from the model coordinate space (in which object points are specified) to the world coordinate
* space, that is, a real position of the board pattern in the k-th pattern view (k=0.. *M* -1).
* @param tvecs Output vector of translation vectors estimated for each pattern view.
- * @param flags flags Different flags for the calibration process (@sa calibrateCamera)
+ * @param stdDeviationsIntrinsics Output vector of standard deviations estimated for intrinsic parameters.
+ * Order of deviations values:
+ * \f$(f_x, f_y, c_x, c_y, k_1, k_2, p_1, p_2, k_3, k_4, k_5, k_6 , s_1, s_2, s_3,
+ * s_4, \tau_x, \tau_y)\f$ If one of parameters is not estimated, it's deviation is equals to zero.
+ * @param stdDeviationsExtrinsics Output vector of standard deviations estimated for extrinsic parameters.
+ * Order of deviations values: \f$(R_1, T_1, \dotsc , R_M, T_M)\f$ where M is number of pattern views,
+ * \f$R_i, T_i\f$ are concatenated 1x3 vectors.
+ * @param perViewErrors Output vector of average re-projection errors estimated for each pattern view.
+ * @param flags flags Different flags for the calibration process (see #calibrateCamera for details).
* @param criteria Termination criteria for the iterative optimization algorithm.
*
* This function calibrates a camera using an Aruco Board. The function receives a list of
* detected markers from several views of the Board. The process is similar to the chessboard
* calibration in calibrateCamera(). The function returns the final re-projection error.
*/
-CV_EXPORTS_W double calibrateCameraAruco(
- InputArrayOfArrays corners, InputArray ids, InputArray counter, Ptr &board,
+CV_EXPORTS_AS(calibrateCameraArucoExtended) double calibrateCameraAruco(
+ InputArrayOfArrays corners, InputArray ids, InputArray counter, const Ptr &board,
Size imageSize, InputOutputArray cameraMatrix, InputOutputArray distCoeffs,
- OutputArrayOfArrays rvecs = noArray(), OutputArrayOfArrays tvecs = noArray(), int flags = 0,
+ OutputArrayOfArrays rvecs, OutputArrayOfArrays tvecs,
+ OutputArray stdDeviationsIntrinsics, OutputArray stdDeviationsExtrinsics,
+ OutputArray perViewErrors, int flags = 0,
TermCriteria criteria = TermCriteria(TermCriteria::COUNT + TermCriteria::EPS, 30, DBL_EPSILON));
+/** @brief It's the same function as #calibrateCameraAruco but without calibration error estimation.
+ */
+CV_EXPORTS_W double calibrateCameraAruco(
+ InputArrayOfArrays corners, InputArray ids, InputArray counter, const Ptr &board,
+ Size imageSize, InputOutputArray cameraMatrix, InputOutputArray distCoeffs,
+ OutputArrayOfArrays rvecs = noArray(), OutputArrayOfArrays tvecs = noArray(), int flags = 0,
+ TermCriteria criteria = TermCriteria(TermCriteria::COUNT + TermCriteria::EPS, 30, DBL_EPSILON));
+
+
+/**
+ * @brief Given a board configuration and a set of detected markers, returns the corresponding
+ * image points and object points to call solvePnP
+ *
+ * @param board Marker board layout.
+ * @param detectedCorners List of detected marker corners of the board.
+ * @param detectedIds List of identifiers for each marker.
+ * @param objPoints Vector of vectors of board marker points in the board coordinate space.
+ * @param imgPoints Vector of vectors of the projections of board marker corner points.
+*/
+CV_EXPORTS_W void getBoardObjectAndImagePoints(const Ptr &board, InputArrayOfArrays detectedCorners,
+ InputArray detectedIds, OutputArray objPoints, OutputArray imgPoints);
+
//! @}
}
diff --git a/IPL/include/opencv/opencv2/aruco/charuco.hpp b/IPL/include/opencv/opencv2/aruco/charuco.hpp
index ff448ce..2e6ae62 100644
--- a/IPL/include/opencv/opencv2/aruco/charuco.hpp
+++ b/IPL/include/opencv/opencv2/aruco/charuco.hpp
@@ -63,11 +63,11 @@ class CV_EXPORTS_W CharucoBoard : public Board {
public:
// vector of chessboard 3D corners precalculated
- std::vector< Point3f > chessboardCorners;
+ CV_PROP std::vector< Point3f > chessboardCorners;
// for each charuco corner, nearest marker id and nearest marker corner id of each marker
- std::vector< std::vector< int > > nearestMarkerIdx;
- std::vector< std::vector< int > > nearestMarkerCorners;
+ CV_PROP std::vector< std::vector< int > > nearestMarkerIdx;
+ CV_PROP std::vector< std::vector< int > > nearestMarkerCorners;
/**
* @brief Draw a ChArUco board
@@ -80,7 +80,7 @@ class CV_EXPORTS_W CharucoBoard : public Board {
*
* This function return the image of the ChArUco board, ready to be printed.
*/
- void draw(Size outSize, OutputArray img, int marginSize = 0, int borderBits = 1);
+ CV_WRAP void draw(Size outSize, OutputArray img, int marginSize = 0, int borderBits = 1);
/**
@@ -98,22 +98,22 @@ class CV_EXPORTS_W CharucoBoard : public Board {
* and the size of the markers and chessboard squares.
*/
CV_WRAP static Ptr create(int squaresX, int squaresY, float squareLength,
- float markerLength, Ptr &dictionary);
+ float markerLength, const Ptr &dictionary);
/**
*
*/
- Size getChessboardSize() const { return Size(_squaresX, _squaresY); }
+ CV_WRAP Size getChessboardSize() const { return Size(_squaresX, _squaresY); }
/**
*
*/
- float getSquareLength() const { return _squareLength; }
+ CV_WRAP float getSquareLength() const { return _squareLength; }
/**
*
*/
- float getMarkerLength() const { return _markerLength; }
+ CV_WRAP float getMarkerLength() const { return _markerLength; }
private:
void _getNearestMarkerCorners();
@@ -124,7 +124,7 @@ class CV_EXPORTS_W CharucoBoard : public Board {
// size of chessboard squares side (normally in meters)
float _squareLength;
- // marker side lenght (normally in meters)
+ // marker side length (normally in meters)
float _markerLength;
};
@@ -146,6 +146,7 @@ class CV_EXPORTS_W CharucoBoard : public Board {
* \f$A = \vecthreethree{f_x}{0}{c_x}{0}{f_y}{c_y}{0}{0}{1}\f$
* @param distCoeffs optional vector of distortion coefficients
* \f$(k_1, k_2, p_1, p_2[, k_3[, k_4, k_5, k_6],[s_1, s_2, s_3, s_4]])\f$ of 4, 5, 8 or 12 elements
+ * @param minMarkers number of adjacent markers that must be detected to return a charuco corner
*
* This function receives the detected markers and returns the 2D position of the chessboard corners
* from a ChArUco board using the detected Aruco markers. If camera parameters are provided,
@@ -155,10 +156,10 @@ class CV_EXPORTS_W CharucoBoard : public Board {
* The function returns the number of interpolated corners.
*/
CV_EXPORTS_W int interpolateCornersCharuco(InputArrayOfArrays markerCorners, InputArray markerIds,
- InputArray image, Ptr &board,
+ InputArray image, const Ptr &board,
OutputArray charucoCorners, OutputArray charucoIds,
InputArray cameraMatrix = noArray(),
- InputArray distCoeffs = noArray());
+ InputArray distCoeffs = noArray(), int minMarkers = 2);
@@ -173,16 +174,18 @@ CV_EXPORTS_W int interpolateCornersCharuco(InputArrayOfArrays markerCorners, Inp
* @param distCoeffs vector of distortion coefficients
* \f$(k_1, k_2, p_1, p_2[, k_3[, k_4, k_5, k_6],[s_1, s_2, s_3, s_4]])\f$ of 4, 5, 8 or 12 elements
* @param rvec Output vector (e.g. cv::Mat) corresponding to the rotation vector of the board
- * (@sa Rodrigues).
+ * (see cv::Rodrigues).
* @param tvec Output vector (e.g. cv::Mat) corresponding to the translation vector of the board.
+ * @param useExtrinsicGuess defines whether initial guess for \b rvec and \b tvec will be used or not.
*
* This function estimates a Charuco board pose from some detected corners.
* The function checks if the input corners are enough and valid to perform pose estimation.
* If pose estimation is valid, returns true, else returns false.
*/
CV_EXPORTS_W bool estimatePoseCharucoBoard(InputArray charucoCorners, InputArray charucoIds,
- Ptr &board, InputArray cameraMatrix,
- InputArray distCoeffs, OutputArray rvec, OutputArray tvec);
+ const Ptr &board, InputArray cameraMatrix,
+ InputArray distCoeffs, InputOutputArray rvec,
+ InputOutputArray tvec, bool useExtrinsicGuess = false);
@@ -223,19 +226,36 @@ CV_EXPORTS_W void drawDetectedCornersCharuco(InputOutputArray image, InputArray
* from the model coordinate space (in which object points are specified) to the world coordinate
* space, that is, a real position of the board pattern in the k-th pattern view (k=0.. *M* -1).
* @param tvecs Output vector of translation vectors estimated for each pattern view.
- * @param flags flags Different flags for the calibration process (@sa calibrateCamera)
+ * @param stdDeviationsIntrinsics Output vector of standard deviations estimated for intrinsic parameters.
+ * Order of deviations values:
+ * \f$(f_x, f_y, c_x, c_y, k_1, k_2, p_1, p_2, k_3, k_4, k_5, k_6 , s_1, s_2, s_3,
+ * s_4, \tau_x, \tau_y)\f$ If one of parameters is not estimated, it's deviation is equals to zero.
+ * @param stdDeviationsExtrinsics Output vector of standard deviations estimated for extrinsic parameters.
+ * Order of deviations values: \f$(R_1, T_1, \dotsc , R_M, T_M)\f$ where M is number of pattern views,
+ * \f$R_i, T_i\f$ are concatenated 1x3 vectors.
+ * @param perViewErrors Output vector of average re-projection errors estimated for each pattern view.
+ * @param flags flags Different flags for the calibration process (see #calibrateCamera for details).
* @param criteria Termination criteria for the iterative optimization algorithm.
*
* This function calibrates a camera using a set of corners of a Charuco Board. The function
* receives a list of detected corners and its identifiers from several views of the Board.
* The function returns the final re-projection error.
*/
-CV_EXPORTS_W double calibrateCameraCharuco(
- InputArrayOfArrays charucoCorners, InputArrayOfArrays charucoIds, Ptr &board,
+CV_EXPORTS_AS(calibrateCameraCharucoExtended) double calibrateCameraCharuco(
+ InputArrayOfArrays charucoCorners, InputArrayOfArrays charucoIds, const Ptr &board,
Size imageSize, InputOutputArray cameraMatrix, InputOutputArray distCoeffs,
- OutputArrayOfArrays rvecs = noArray(), OutputArrayOfArrays tvecs = noArray(), int flags = 0,
+ OutputArrayOfArrays rvecs, OutputArrayOfArrays tvecs,
+ OutputArray stdDeviationsIntrinsics, OutputArray stdDeviationsExtrinsics,
+ OutputArray perViewErrors, int flags = 0,
TermCriteria criteria = TermCriteria(TermCriteria::COUNT + TermCriteria::EPS, 30, DBL_EPSILON));
+/** @brief It's the same function as #calibrateCameraCharuco but without calibration error estimation.
+*/
+CV_EXPORTS_W double calibrateCameraCharuco(
+ InputArrayOfArrays charucoCorners, InputArrayOfArrays charucoIds, const Ptr &board,
+ Size imageSize, InputOutputArray cameraMatrix, InputOutputArray distCoeffs,
+ OutputArrayOfArrays rvecs = noArray(), OutputArrayOfArrays tvecs = noArray(), int flags = 0,
+ TermCriteria criteria = TermCriteria(TermCriteria::COUNT + TermCriteria::EPS, 30, DBL_EPSILON));
@@ -309,7 +329,7 @@ CV_EXPORTS_W void drawDetectedDiamonds(InputOutputArray image, InputArrayOfArray
* This function return the image of a ChArUco marker, ready to be printed.
*/
// TODO cannot be exported yet; conversion from/to Vec4i is not wrapped in core
-CV_EXPORTS void drawCharucoDiamond(Ptr &dictionary, Vec4i ids, int squareLength,
+CV_EXPORTS void drawCharucoDiamond(const Ptr &dictionary, Vec4i ids, int squareLength,
int markerLength, OutputArray img, int marginSize = 0,
int borderBits = 1);
diff --git a/IPL/include/opencv/opencv2/aruco/dictionary.hpp b/IPL/include/opencv/opencv2/aruco/dictionary.hpp
index 3ef1a82..27c7e5d 100644
--- a/IPL/include/opencv/opencv2/aruco/dictionary.hpp
+++ b/IPL/include/opencv/opencv2/aruco/dictionary.hpp
@@ -84,14 +84,14 @@ class CV_EXPORTS_W Dictionary {
/**
* @see generateCustomDictionary
*/
- CV_WRAP_AS(create) static Ptr create(int nMarkers, int markerSize);
+ CV_WRAP_AS(create) static Ptr create(int nMarkers, int markerSize, int randomSeed=0);
/**
* @see generateCustomDictionary
*/
CV_WRAP_AS(create_from) static Ptr create(int nMarkers, int markerSize,
- Ptr &baseDictionary);
+ const Ptr &baseDictionary, int randomSeed=0);
/**
* @see getPredefinedDictionary
@@ -114,19 +114,19 @@ class CV_EXPORTS_W Dictionary {
/**
* @brief Draw a canonical marker image
*/
- void drawMarker(int id, int sidePixels, OutputArray _img, int borderBits = 1) const;
+ CV_WRAP void drawMarker(int id, int sidePixels, OutputArray _img, int borderBits = 1) const;
/**
* @brief Transform matrix of bits to list of bytes in the 4 rotations
*/
- static Mat getByteListFromBits(const Mat &bits);
+ CV_WRAP static Mat getByteListFromBits(const Mat &bits);
/**
* @brief Transform list of bytes to matrix of bits
*/
- static Mat getBitsFromByteList(const Mat &byteList, int markerSize);
+ CV_WRAP static Mat getBitsFromByteList(const Mat &byteList, int markerSize);
};
@@ -138,7 +138,7 @@ class CV_EXPORTS_W Dictionary {
* - DICT_ARUCO_ORIGINAL: standard ArUco Library Markers. 1024 markers, 5x5 bits, 0 minimum
distance
*/
-enum CV_EXPORTS_W_SIMPLE PREDEFINED_DICTIONARY_NAME {
+enum PREDEFINED_DICTIONARY_NAME {
DICT_4X4_50 = 0,
DICT_4X4_100,
DICT_4X4_250,
@@ -155,7 +155,11 @@ enum CV_EXPORTS_W_SIMPLE PREDEFINED_DICTIONARY_NAME {
DICT_7X7_100,
DICT_7X7_250,
DICT_7X7_1000,
- DICT_ARUCO_ORIGINAL
+ DICT_ARUCO_ORIGINAL,
+ DICT_APRILTAG_16h5, ///< 4x4 bits, minimum hamming distance between any two codes = 5, 30 codes
+ DICT_APRILTAG_25h9, ///< 5x5 bits, minimum hamming distance between any two codes = 9, 35 codes
+ DICT_APRILTAG_36h10, ///< 6x6 bits, minimum hamming distance between any two codes = 10, 2320 codes
+ DICT_APRILTAG_36h11 ///< 6x6 bits, minimum hamming distance between any two codes = 11, 587 codes
};
@@ -176,7 +180,8 @@ CV_EXPORTS_W Ptr getPredefinedDictionary(int dict);
*/
CV_EXPORTS_AS(custom_dictionary) Ptr generateCustomDictionary(
int nMarkers,
- int markerSize);
+ int markerSize,
+ int randomSeed=0);
/**
@@ -185,6 +190,7 @@ CV_EXPORTS_AS(custom_dictionary) Ptr generateCustomDictionary(
* @param nMarkers number of markers in the dictionary
* @param markerSize number of bits per dimension of each markers
* @param baseDictionary Include the markers in this dictionary at the beginning (optional)
+ * @param randomSeed a user supplied seed for theRNG()
*
* This function creates a new dictionary composed by nMarkers markers and each markers composed
* by markerSize x markerSize bits. If baseDictionary is provided, its markers are directly
@@ -194,7 +200,8 @@ CV_EXPORTS_AS(custom_dictionary) Ptr generateCustomDictionary(
CV_EXPORTS_AS(custom_dictionary_from) Ptr generateCustomDictionary(
int nMarkers,
int markerSize,
- Ptr &baseDictionary);
+ const Ptr &baseDictionary,
+ int randomSeed=0);
diff --git a/IPL/include/opencv/opencv2/bgsegm.hpp b/IPL/include/opencv/opencv2/bgsegm.hpp
index 5a4ae3f..8ace5d9 100644
--- a/IPL/include/opencv/opencv2/bgsegm.hpp
+++ b/IPL/include/opencv/opencv2/bgsegm.hpp
@@ -183,7 +183,193 @@ class CV_EXPORTS_W BackgroundSubtractorGMG : public BackgroundSubtractor
@param decisionThreshold Threshold value, above which it is marked foreground, else background.
*/
CV_EXPORTS_W Ptr createBackgroundSubtractorGMG(int initializationFrames=120,
- double decisionThreshold=0.8);
+ double decisionThreshold=0.8);
+
+/** @brief Background subtraction based on counting.
+
+ About as fast as MOG2 on a high end system.
+ More than twice faster than MOG2 on cheap hardware (benchmarked on Raspberry Pi3).
+
+ %Algorithm by Sagi Zeevi ( https://github.com/sagi-z/BackgroundSubtractorCNT )
+*/
+class CV_EXPORTS_W BackgroundSubtractorCNT : public BackgroundSubtractor
+{
+public:
+ // BackgroundSubtractor interface
+ CV_WRAP virtual void apply(InputArray image, OutputArray fgmask, double learningRate=-1) CV_OVERRIDE = 0;
+ CV_WRAP virtual void getBackgroundImage(OutputArray backgroundImage) const CV_OVERRIDE = 0;
+
+ /** @brief Returns number of frames with same pixel color to consider stable.
+ */
+ CV_WRAP virtual int getMinPixelStability() const = 0;
+ /** @brief Sets the number of frames with same pixel color to consider stable.
+ */
+ CV_WRAP virtual void setMinPixelStability(int value) = 0;
+
+ /** @brief Returns maximum allowed credit for a pixel in history.
+ */
+ CV_WRAP virtual int getMaxPixelStability() const = 0;
+ /** @brief Sets the maximum allowed credit for a pixel in history.
+ */
+ CV_WRAP virtual void setMaxPixelStability(int value) = 0;
+
+ /** @brief Returns if we're giving a pixel credit for being stable for a long time.
+ */
+ CV_WRAP virtual bool getUseHistory() const = 0;
+ /** @brief Sets if we're giving a pixel credit for being stable for a long time.
+ */
+ CV_WRAP virtual void setUseHistory(bool value) = 0;
+
+ /** @brief Returns if we're parallelizing the algorithm.
+ */
+ CV_WRAP virtual bool getIsParallel() const = 0;
+ /** @brief Sets if we're parallelizing the algorithm.
+ */
+ CV_WRAP virtual void setIsParallel(bool value) = 0;
+};
+
+/** @brief Creates a CNT Background Subtractor
+
+@param minPixelStability number of frames with same pixel color to consider stable
+@param useHistory determines if we're giving a pixel credit for being stable for a long time
+@param maxPixelStability maximum allowed credit for a pixel in history
+@param isParallel determines if we're parallelizing the algorithm
+ */
+
+CV_EXPORTS_W Ptr
+createBackgroundSubtractorCNT(int minPixelStability = 15,
+ bool useHistory = true,
+ int maxPixelStability = 15*60,
+ bool isParallel = true);
+
+enum LSBPCameraMotionCompensation {
+ LSBP_CAMERA_MOTION_COMPENSATION_NONE = 0,
+ LSBP_CAMERA_MOTION_COMPENSATION_LK
+};
+
+/** @brief Implementation of the different yet better algorithm which is called GSOC, as it was implemented during GSOC and was not originated from any paper.
+
+This algorithm demonstrates better performance on CDNET 2014 dataset compared to other algorithms in OpenCV.
+ */
+class CV_EXPORTS_W BackgroundSubtractorGSOC : public BackgroundSubtractor
+{
+public:
+ // BackgroundSubtractor interface
+ CV_WRAP virtual void apply(InputArray image, OutputArray fgmask, double learningRate=-1) CV_OVERRIDE = 0;
+
+ CV_WRAP virtual void getBackgroundImage(OutputArray backgroundImage) const CV_OVERRIDE = 0;
+};
+
+/** @brief Background Subtraction using Local SVD Binary Pattern. More details about the algorithm can be found at @cite LGuo2016
+ */
+class CV_EXPORTS_W BackgroundSubtractorLSBP : public BackgroundSubtractor
+{
+public:
+ // BackgroundSubtractor interface
+ CV_WRAP virtual void apply(InputArray image, OutputArray fgmask, double learningRate=-1) CV_OVERRIDE = 0;
+
+ CV_WRAP virtual void getBackgroundImage(OutputArray backgroundImage) const CV_OVERRIDE = 0;
+};
+
+/** @brief This is for calculation of the LSBP descriptors.
+ */
+class CV_EXPORTS_W BackgroundSubtractorLSBPDesc
+{
+public:
+ static void calcLocalSVDValues(OutputArray localSVDValues, const Mat& frame);
+
+ static void computeFromLocalSVDValues(OutputArray desc, const Mat& localSVDValues, const Point2i* LSBPSamplePoints);
+
+ static void compute(OutputArray desc, const Mat& frame, const Point2i* LSBPSamplePoints);
+};
+
+/** @brief Creates an instance of BackgroundSubtractorGSOC algorithm.
+
+Implementation of the different yet better algorithm which is called GSOC, as it was implemented during GSOC and was not originated from any paper.
+
+@param mc Whether to use camera motion compensation.
+@param nSamples Number of samples to maintain at each point of the frame.
+@param replaceRate Probability of replacing the old sample - how fast the model will update itself.
+@param propagationRate Probability of propagating to neighbors.
+@param hitsThreshold How many positives the sample must get before it will be considered as a possible replacement.
+@param alpha Scale coefficient for threshold.
+@param beta Bias coefficient for threshold.
+@param blinkingSupressionDecay Blinking supression decay factor.
+@param blinkingSupressionMultiplier Blinking supression multiplier.
+@param noiseRemovalThresholdFacBG Strength of the noise removal for background points.
+@param noiseRemovalThresholdFacFG Strength of the noise removal for foreground points.
+ */
+CV_EXPORTS_W Ptr createBackgroundSubtractorGSOC(int mc = LSBP_CAMERA_MOTION_COMPENSATION_NONE, int nSamples = 20, float replaceRate = 0.003f, float propagationRate = 0.01f, int hitsThreshold = 32, float alpha = 0.01f, float beta = 0.0022f, float blinkingSupressionDecay = 0.1f, float blinkingSupressionMultiplier = 0.1f, float noiseRemovalThresholdFacBG = 0.0004f, float noiseRemovalThresholdFacFG = 0.0008f);
+
+/** @brief Creates an instance of BackgroundSubtractorLSBP algorithm.
+
+Background Subtraction using Local SVD Binary Pattern. More details about the algorithm can be found at @cite LGuo2016
+
+@param mc Whether to use camera motion compensation.
+@param nSamples Number of samples to maintain at each point of the frame.
+@param LSBPRadius LSBP descriptor radius.
+@param Tlower Lower bound for T-values. See @cite LGuo2016 for details.
+@param Tupper Upper bound for T-values. See @cite LGuo2016 for details.
+@param Tinc Increase step for T-values. See @cite LGuo2016 for details.
+@param Tdec Decrease step for T-values. See @cite LGuo2016 for details.
+@param Rscale Scale coefficient for threshold values.
+@param Rincdec Increase/Decrease step for threshold values.
+@param noiseRemovalThresholdFacBG Strength of the noise removal for background points.
+@param noiseRemovalThresholdFacFG Strength of the noise removal for foreground points.
+@param LSBPthreshold Threshold for LSBP binary string.
+@param minCount Minimal number of matches for sample to be considered as foreground.
+ */
+CV_EXPORTS_W Ptr createBackgroundSubtractorLSBP(int mc = LSBP_CAMERA_MOTION_COMPENSATION_NONE, int nSamples = 20, int LSBPRadius = 16, float Tlower = 2.0f, float Tupper = 32.0f, float Tinc = 1.0f, float Tdec = 0.05f, float Rscale = 10.0f, float Rincdec = 0.005f, float noiseRemovalThresholdFacBG = 0.0004f, float noiseRemovalThresholdFacFG = 0.0008f, int LSBPthreshold = 8, int minCount = 2);
+
+/** @brief Synthetic frame sequence generator for testing background subtraction algorithms.
+
+ It will generate the moving object on top of the background.
+ It will apply some distortion to the background to make the test more complex.
+ */
+class CV_EXPORTS_W SyntheticSequenceGenerator : public Algorithm
+{
+private:
+ const double amplitude;
+ const double wavelength;
+ const double wavespeed;
+ const double objspeed;
+ unsigned timeStep;
+ Point2d pos;
+ Point2d dir;
+ Mat background;
+ Mat object;
+ RNG rng;
+
+public:
+ /** @brief Creates an instance of SyntheticSequenceGenerator.
+
+ @param background Background image for object.
+ @param object Object image which will move slowly over the background.
+ @param amplitude Amplitude of wave distortion applied to background.
+ @param wavelength Length of waves in distortion applied to background.
+ @param wavespeed How fast waves will move.
+ @param objspeed How fast object will fly over background.
+ */
+ CV_WRAP SyntheticSequenceGenerator(InputArray background, InputArray object, double amplitude, double wavelength, double wavespeed, double objspeed);
+
+ /** @brief Obtain the next frame in the sequence.
+
+ @param frame Output frame.
+ @param gtMask Output ground-truth (reference) segmentation mask object/background.
+ */
+ CV_WRAP void getNextFrame(OutputArray frame, OutputArray gtMask);
+};
+
+/** @brief Creates an instance of SyntheticSequenceGenerator.
+
+@param background Background image for object.
+@param object Object image which will move slowly over the background.
+@param amplitude Amplitude of wave distortion applied to background.
+@param wavelength Length of waves in distortion applied to background.
+@param wavespeed How fast waves will move.
+@param objspeed How fast object will fly over background.
+ */
+CV_EXPORTS_W Ptr createSyntheticSequenceGenerator(InputArray background, InputArray object, double amplitude = 2.0, double wavelength = 20.0, double wavespeed = 0.2, double objspeed = 6.0);
//! @}
diff --git a/IPL/include/opencv/opencv2/bioinspired/retina.hpp b/IPL/include/opencv/opencv2/bioinspired/retina.hpp
index 4ed6f3a..91c8148 100644
--- a/IPL/include/opencv/opencv2/bioinspired/retina.hpp
+++ b/IPL/include/opencv/opencv2/bioinspired/retina.hpp
@@ -146,7 +146,7 @@ enum {
@endcode
*/
- struct RetinaParameters{
+ struct RetinaParameters{
//! Outer Plexiform Layer (OPL) and Inner Plexiform Layer Parvocellular (IplParvo) parameters
struct OPLandIplParvoParameters{
OPLandIplParvoParameters():colorMode(true),
@@ -208,7 +208,7 @@ class CV_EXPORTS_W Retina : public Algorithm {
public:
-
+
/** @brief Retreive retina input buffer size
@return the retina input buffer size
*/
@@ -226,8 +226,9 @@ class CV_EXPORTS_W Retina : public Algorithm {
- warning, Exceptions are thrown if read XML file is not valid
@param retinaParameterFile the parameters filename
@param applyDefaultSetupOnFailure set to true if an error must be thrown on error
- You can retreive the current parameers structure using method Retina::getParameters and update
- it before running method Retina::setup
+
+ You can retrieve the current parameters structure using the method Retina::getParameters and update
+ it before running method Retina::setup.
*/
CV_WRAP virtual void setup(String retinaParameterFile="", const bool applyDefaultSetupOnFailure=true)=0;
@@ -259,7 +260,7 @@ class CV_EXPORTS_W Retina : public Algorithm {
CV_WRAP virtual void write( String fs ) const=0;
/** @overload */
- virtual void write( FileStorage& fs ) const=0;
+ virtual void write( FileStorage& fs ) const CV_OVERRIDE = 0;
/** @brief Setup the OPL and IPL parvo channels (see biologocal model)
@@ -421,37 +422,30 @@ class CV_EXPORTS_W Retina : public Algorithm {
Retina::getParvo methods
*/
CV_WRAP virtual void activateContoursProcessing(const bool activate)=0;
-};
-
-//! @relates bioinspired::Retina
-//! @{
-
-/** @overload */
-CV_EXPORTS_W Ptr createRetina(Size inputSize);
-/** @brief Constructors from standardized interfaces : retreive a smart pointer to a Retina instance
-
-@param inputSize the input frame size
-@param colorMode the chosen processing mode : with or without color processing
-@param colorSamplingMethod specifies which kind of color sampling will be used :
-- cv::bioinspired::RETINA_COLOR_RANDOM: each pixel position is either R, G or B in a random choice
-- cv::bioinspired::RETINA_COLOR_DIAGONAL: color sampling is RGBRGBRGB..., line 2 BRGBRGBRG..., line 3, GBRGBRGBR...
-- cv::bioinspired::RETINA_COLOR_BAYER: standard bayer sampling
-@param useRetinaLogSampling activate retina log sampling, if true, the 2 following parameters can
-be used
-@param reductionFactor only usefull if param useRetinaLogSampling=true, specifies the reduction
-factor of the output frame (as the center (fovea) is high resolution and corners can be
-underscaled, then a reduction of the output is allowed without precision leak
-@param samplingStrenght only usefull if param useRetinaLogSampling=true, specifies the strenght of
-the log scale that is applied
- */
-CV_EXPORTS_W Ptr createRetina(Size inputSize, const bool colorMode, int colorSamplingMethod=RETINA_COLOR_BAYER, const bool useRetinaLogSampling=false, const float reductionFactor=1.0f, const float samplingStrenght=10.0f);
-
-#ifdef HAVE_OPENCV_OCL
-Ptr createRetina_OCL(Size inputSize);
-Ptr createRetina_OCL(Size inputSize, const bool colorMode, int colorSamplingMethod=RETINA_COLOR_BAYER, const bool useRetinaLogSampling=false, const float reductionFactor=1.0f, const float samplingStrenght=10.0f);
-#endif
-//! @}
+ /** @overload */
+ CV_WRAP static Ptr create(Size inputSize);
+ /** @brief Constructors from standardized interfaces : retreive a smart pointer to a Retina instance
+
+ @param inputSize the input frame size
+ @param colorMode the chosen processing mode : with or without color processing
+ @param colorSamplingMethod specifies which kind of color sampling will be used :
+ - cv::bioinspired::RETINA_COLOR_RANDOM: each pixel position is either R, G or B in a random choice
+ - cv::bioinspired::RETINA_COLOR_DIAGONAL: color sampling is RGBRGBRGB..., line 2 BRGBRGBRG..., line 3, GBRGBRGBR...
+ - cv::bioinspired::RETINA_COLOR_BAYER: standard bayer sampling
+ @param useRetinaLogSampling activate retina log sampling, if true, the 2 following parameters can
+ be used
+ @param reductionFactor only usefull if param useRetinaLogSampling=true, specifies the reduction
+ factor of the output frame (as the center (fovea) is high resolution and corners can be
+ underscaled, then a reduction of the output is allowed without precision leak
+ @param samplingStrength only usefull if param useRetinaLogSampling=true, specifies the strength of
+ the log scale that is applied
+ */
+ CV_WRAP static Ptr create(Size inputSize, const bool colorMode,
+ int colorSamplingMethod=RETINA_COLOR_BAYER,
+ const bool useRetinaLogSampling=false,
+ const float reductionFactor=1.0f, const float samplingStrength=10.0f);
+};
//! @}
diff --git a/IPL/include/opencv/opencv2/bioinspired/retinafasttonemapping.hpp b/IPL/include/opencv/opencv2/bioinspired/retinafasttonemapping.hpp
index c65709d..ba1a872 100644
--- a/IPL/include/opencv/opencv2/bioinspired/retinafasttonemapping.hpp
+++ b/IPL/include/opencv/opencv2/bioinspired/retinafasttonemapping.hpp
@@ -126,10 +126,10 @@ class CV_EXPORTS_W RetinaFastToneMapping : public Algorithm
(default is 1, see reference paper)
*/
CV_WRAP virtual void setup(const float photoreceptorsNeighborhoodRadius=3.f, const float ganglioncellsNeighborhoodRadius=1.f, const float meanLuminanceModulatorK=1.f)=0;
+
+ CV_WRAP static Ptr create(Size inputSize);
};
-//! @relates bioinspired::RetinaFastToneMapping
-CV_EXPORTS_W Ptr createRetinaFastToneMapping(Size inputSize);
//! @}
diff --git a/IPL/include/opencv/opencv2/bioinspired/transientareassegmentationmodule.hpp b/IPL/include/opencv/opencv2/bioinspired/transientareassegmentationmodule.hpp
index b11b61d..d5f5b2f 100644
--- a/IPL/include/opencv/opencv2/bioinspired/transientareassegmentationmodule.hpp
+++ b/IPL/include/opencv/opencv2/bioinspired/transientareassegmentationmodule.hpp
@@ -80,7 +80,7 @@ namespace bioinspired
/** @brief parameter structure that stores the transient events detector setup parameters
*/
struct SegmentationParameters{ // CV_EXPORTS_W_MAP to export to python native dictionnaries
- // default structure instance construction with default values
+ // default structure instance construction with default values
SegmentationParameters():
thresholdON(100),
thresholdOFF(100),
@@ -171,7 +171,7 @@ class CV_EXPORTS_W TransientAreasSegmentationModule: public Algorithm
/** @brief write xml/yml formated parameters information
@param fs : a cv::Filestorage object ready to be filled
*/
- virtual void write( cv::FileStorage& fs ) const=0;
+ virtual void write( cv::FileStorage& fs ) const CV_OVERRIDE = 0;
/** @brief main processing method, get result using methods getSegmentationPicture()
@param inputToSegment : the image to process, it must match the instance buffer size !
@@ -180,20 +180,19 @@ class CV_EXPORTS_W TransientAreasSegmentationModule: public Algorithm
CV_WRAP virtual void run(InputArray inputToSegment, const int channelIndex=0)=0;
/** @brief access function
- @return the last segmentation result: a boolean picture which is resampled between 0 and 255 for a display purpose
- */
+ return the last segmentation result: a boolean picture which is resampled between 0 and 255 for a display purpose
+ */
CV_WRAP virtual void getSegmentationPicture(OutputArray transientAreas)=0;
/** @brief cleans all the buffers of the instance
*/
CV_WRAP virtual void clearAllBuffers()=0;
-};
-/** @brief allocator
-@param inputSize : size of the images input to segment (output will be the same size)
-@relates bioinspired::TransientAreasSegmentationModule
- */
-CV_EXPORTS_W Ptr createTransientAreasSegmentationModule(Size inputSize);
+ /** @brief allocator
+ @param inputSize : size of the images input to segment (output will be the same size)
+ */
+ CV_WRAP static Ptr create(Size inputSize);
+};
//! @}
diff --git a/IPL/include/opencv/opencv2/calib3d.hpp b/IPL/include/opencv/opencv2/calib3d.hpp
index e26e8c1..517c4cd 100644
--- a/IPL/include/opencv/opencv2/calib3d.hpp
+++ b/IPL/include/opencv/opencv2/calib3d.hpp
@@ -41,8 +41,8 @@
//
//M*/
-#ifndef __OPENCV_CALIB3D_HPP__
-#define __OPENCV_CALIB3D_HPP__
+#ifndef OPENCV_CALIB3D_HPP
+#define OPENCV_CALIB3D_HPP
#include "opencv2/core.hpp"
#include "opencv2/features2d.hpp"
@@ -51,85 +51,254 @@
/**
@defgroup calib3d Camera Calibration and 3D Reconstruction
-The functions in this section use a so-called pinhole camera model. In this model, a scene view is
-formed by projecting 3D points into the image plane using a perspective transformation.
+The functions in this section use a so-called pinhole camera model. The view of a scene
+is obtained by projecting a scene's 3D point \f$P_w\f$ into the image plane using a perspective
+transformation which forms the corresponding pixel \f$p\f$. Both \f$P_w\f$ and \f$p\f$ are
+represented in homogeneous coordinates, i.e. as 3D and 2D homogeneous vector respectively. You will
+find a brief introduction to projective geometry, homogeneous vectors and homogeneous
+transformations at the end of this section's introduction. For more succinct notation, we often drop
+the 'homogeneous' and say vector instead of homogeneous vector.
-\f[s \; m' = A [R|t] M'\f]
+The distortion-free projective transformation given by a pinhole camera model is shown below.
-or
+\f[s \; p = A \begin{bmatrix} R|t \end{bmatrix} P_w,\f]
-\f[s \vecthree{u}{v}{1} = \vecthreethree{f_x}{0}{c_x}{0}{f_y}{c_y}{0}{0}{1}
+where \f$P_w\f$ is a 3D point expressed with respect to the world coordinate system,
+\f$p\f$ is a 2D pixel in the image plane, \f$A\f$ is the intrinsic camera matrix,
+\f$R\f$ and \f$t\f$ are the rotation and translation that describe the change of coordinates from
+world to camera coordinate systems (or camera frame) and \f$s\f$ is the projective transformation's
+arbitrary scaling and not part of the camera model.
+
+The intrinsic camera matrix \f$A\f$ (notation used as in @cite Zhang2000 and also generally notated
+as \f$K\f$) projects 3D points given in the camera coordinate system to 2D pixel coordinates, i.e.
+
+\f[p = A P_c.\f]
+
+The camera matrix \f$A\f$ is composed of the focal lengths \f$f_x\f$ and \f$f_y\f$, which are
+expressed in pixel units, and the principal point \f$(c_x, c_y)\f$, that is usually close to the
+image center:
+
+\f[A = \vecthreethree{f_x}{0}{c_x}{0}{f_y}{c_y}{0}{0}{1},\f]
+
+and thus
+
+\f[s \vecthree{u}{v}{1} = \vecthreethree{f_x}{0}{c_x}{0}{f_y}{c_y}{0}{0}{1} \vecthree{X_c}{Y_c}{Z_c}.\f]
+
+The matrix of intrinsic parameters does not depend on the scene viewed. So, once estimated, it can
+be re-used as long as the focal length is fixed (in case of a zoom lens). Thus, if an image from the
+camera is scaled by a factor, all of these parameters need to be scaled (multiplied/divided,
+respectively) by the same factor.
+
+The joint rotation-translation matrix \f$[R|t]\f$ is the matrix product of a projective
+transformation and a homogeneous transformation. The 3-by-4 projective transformation maps 3D points
+represented in camera coordinates to 2D poins in the image plane and represented in normalized
+camera coordinates \f$x' = X_c / Z_c\f$ and \f$y' = Y_c / Z_c\f$:
+
+\f[Z_c \begin{bmatrix}
+x' \\
+y' \\
+1
+\end{bmatrix} = \begin{bmatrix}
+1 & 0 & 0 & 0 \\
+0 & 1 & 0 & 0 \\
+0 & 0 & 1 & 0
+\end{bmatrix}
\begin{bmatrix}
-r_{11} & r_{12} & r_{13} & t_1 \\
-r_{21} & r_{22} & r_{23} & t_2 \\
-r_{31} & r_{32} & r_{33} & t_3
+X_c \\
+Y_c \\
+Z_c \\
+1
+\end{bmatrix}.\f]
+
+The homogeneous transformation is encoded by the extrinsic parameters \f$R\f$ and \f$t\f$ and
+represents the change of basis from world coordinate system \f$w\f$ to the camera coordinate sytem
+\f$c\f$. Thus, given the representation of the point \f$P\f$ in world coordinates, \f$P_w\f$, we
+obtain \f$P\f$'s representation in the camera coordinate system, \f$P_c\f$, by
+
+\f[P_c = \begin{bmatrix}
+R & t \\
+0 & 1
+\end{bmatrix} P_w,\f]
+
+This homogeneous transformation is composed out of \f$R\f$, a 3-by-3 rotation matrix, and \f$t\f$, a
+3-by-1 translation vector:
+
+\f[\begin{bmatrix}
+R & t \\
+0 & 1
+\end{bmatrix} = \begin{bmatrix}
+r_{11} & r_{12} & r_{13} & t_x \\
+r_{21} & r_{22} & r_{23} & t_y \\
+r_{31} & r_{32} & r_{33} & t_z \\
+0 & 0 & 0 & 1
+\end{bmatrix},
+\f]
+
+and therefore
+
+\f[\begin{bmatrix}
+X_c \\
+Y_c \\
+Z_c \\
+1
+\end{bmatrix} = \begin{bmatrix}
+r_{11} & r_{12} & r_{13} & t_x \\
+r_{21} & r_{22} & r_{23} & t_y \\
+r_{31} & r_{32} & r_{33} & t_z \\
+0 & 0 & 0 & 1
\end{bmatrix}
\begin{bmatrix}
-X \\
-Y \\
-Z \\
+X_w \\
+Y_w \\
+Z_w \\
+1
+\end{bmatrix}.\f]
+
+Combining the projective transformation and the homogeneous transformation, we obtain the projective
+transformation that maps 3D points in world coordinates into 2D points in the image plane and in
+normalized camera coordinates:
+
+\f[Z_c \begin{bmatrix}
+x' \\
+y' \\
+1
+\end{bmatrix} = \begin{bmatrix} R|t \end{bmatrix} \begin{bmatrix}
+X_w \\
+Y_w \\
+Z_w \\
+1
+\end{bmatrix} = \begin{bmatrix}
+r_{11} & r_{12} & r_{13} & t_x \\
+r_{21} & r_{22} & r_{23} & t_y \\
+r_{31} & r_{32} & r_{33} & t_z
+\end{bmatrix}
+\begin{bmatrix}
+X_w \\
+Y_w \\
+Z_w \\
+1
+\end{bmatrix},\f]
+
+with \f$x' = X_c / Z_c\f$ and \f$y' = Y_c / Z_c\f$. Putting the equations for instrincs and extrinsics together, we can write out
+\f$s \; p = A \begin{bmatrix} R|t \end{bmatrix} P_w\f$ as
+
+\f[s \vecthree{u}{v}{1} = \vecthreethree{f_x}{0}{c_x}{0}{f_y}{c_y}{0}{0}{1}
+\begin{bmatrix}
+r_{11} & r_{12} & r_{13} & t_x \\
+r_{21} & r_{22} & r_{23} & t_y \\
+r_{31} & r_{32} & r_{33} & t_z
+\end{bmatrix}
+\begin{bmatrix}
+X_w \\
+Y_w \\
+Z_w \\
1
+\end{bmatrix}.\f]
+
+If \f$Z_c \ne 0\f$, the transformation above is equivalent to the following,
+
+\f[\begin{bmatrix}
+u \\
+v
+\end{bmatrix} = \begin{bmatrix}
+f_x X_c/Z_c + c_x \\
+f_y Y_c/Z_c + c_y
\end{bmatrix}\f]
-where:
-
-- \f$(X, Y, Z)\f$ are the coordinates of a 3D point in the world coordinate space
-- \f$(u, v)\f$ are the coordinates of the projection point in pixels
-- \f$A\f$ is a camera matrix, or a matrix of intrinsic parameters
-- \f$(cx, cy)\f$ is a principal point that is usually at the image center
-- \f$fx, fy\f$ are the focal lengths expressed in pixel units.
-
-Thus, if an image from the camera is scaled by a factor, all of these parameters should be scaled
-(multiplied/divided, respectively) by the same factor. The matrix of intrinsic parameters does not
-depend on the scene viewed. So, once estimated, it can be re-used as long as the focal length is
-fixed (in case of zoom lens). The joint rotation-translation matrix \f$[R|t]\f$ is called a matrix of
-extrinsic parameters. It is used to describe the camera motion around a static scene, or vice versa,
-rigid motion of an object in front of a still camera. That is, \f$[R|t]\f$ translates coordinates of a
-point \f$(X, Y, Z)\f$ to a coordinate system, fixed with respect to the camera. The transformation above
-is equivalent to the following (when \f$z \ne 0\f$ ):
-
-\f[\begin{array}{l}
-\vecthree{x}{y}{z} = R \vecthree{X}{Y}{Z} + t \\
-x' = x/z \\
-y' = y/z \\
-u = f_x*x' + c_x \\
-v = f_y*y' + c_y
-\end{array}\f]
-
-Real lenses usually have some distortion, mostly radial distortion and slight tangential distortion.
+with
+
+\f[\vecthree{X_c}{Y_c}{Z_c} = \begin{bmatrix}
+R|t
+\end{bmatrix} \begin{bmatrix}
+X_w \\
+Y_w \\
+Z_w \\
+1
+\end{bmatrix}.\f]
+
+The following figure illustrates the pinhole camera model.
+
+
+
+Real lenses usually have some distortion, mostly radial distortion, and slight tangential distortion.
So, the above model is extended as:
-\f[\begin{array}{l}
-\vecthree{x}{y}{z} = R \vecthree{X}{Y}{Z} + t \\
-x' = x/z \\
-y' = y/z \\
-x'' = x' \frac{1 + k_1 r^2 + k_2 r^4 + k_3 r^6}{1 + k_4 r^2 + k_5 r^4 + k_6 r^6} + 2 p_1 x' y' + p_2(r^2 + 2 x'^2) + s_1 r^2 + s_2 r^4 \\
-y'' = y' \frac{1 + k_1 r^2 + k_2 r^4 + k_3 r^6}{1 + k_4 r^2 + k_5 r^4 + k_6 r^6} + p_1 (r^2 + 2 y'^2) + 2 p_2 x' y' + s_3 r^2 + s_4 r^4 \\
-\text{where} \quad r^2 = x'^2 + y'^2 \\
-u = f_x*x'' + c_x \\
-v = f_y*y'' + c_y
-\end{array}\f]
-
-\f$k_1\f$, \f$k_2\f$, \f$k_3\f$, \f$k_4\f$, \f$k_5\f$, and \f$k_6\f$ are radial distortion coefficients. \f$p_1\f$ and \f$p_2\f$ are
-tangential distortion coefficients. \f$s_1\f$, \f$s_2\f$, \f$s_3\f$, and \f$s_4\f$, are the thin prism distortion
-coefficients. Higher-order coefficients are not considered in OpenCV.
-
-In some cases the image sensor may be tilted in order to focus an oblique plane in front of the
-camera (Scheimpfug condition). This can be useful for particle image velocimetry (PIV) or
+\f[\begin{bmatrix}
+u \\
+v
+\end{bmatrix} = \begin{bmatrix}
+f_x x'' + c_x \\
+f_y y'' + c_y
+\end{bmatrix}\f]
+
+where
+
+\f[\begin{bmatrix}
+x'' \\
+y''
+\end{bmatrix} = \begin{bmatrix}
+x' \frac{1 + k_1 r^2 + k_2 r^4 + k_3 r^6}{1 + k_4 r^2 + k_5 r^4 + k_6 r^6} + 2 p_1 x' y' + p_2(r^2 + 2 x'^2) + s_1 r^2 + s_2 r^4 \\
+y' \frac{1 + k_1 r^2 + k_2 r^4 + k_3 r^6}{1 + k_4 r^2 + k_5 r^4 + k_6 r^6} + p_1 (r^2 + 2 y'^2) + 2 p_2 x' y' + s_3 r^2 + s_4 r^4 \\
+\end{bmatrix}\f]
+
+with
+
+\f[r^2 = x'^2 + y'^2\f]
+
+and
+
+\f[\begin{bmatrix}
+x'\\
+y'
+\end{bmatrix} = \begin{bmatrix}
+X_c/Z_c \\
+Y_c/Z_c
+\end{bmatrix},\f]
+
+if \f$Z_c \ne 0\f$.
+
+The distortion parameters are the radial coefficients \f$k_1\f$, \f$k_2\f$, \f$k_3\f$, \f$k_4\f$, \f$k_5\f$, and \f$k_6\f$
+,\f$p_1\f$ and \f$p_2\f$ are the tangential distortion coefficients, and \f$s_1\f$, \f$s_2\f$, \f$s_3\f$, and \f$s_4\f$,
+are the thin prism distortion coefficients. Higher-order coefficients are not considered in OpenCV.
+
+The next figures show two common types of radial distortion: barrel distortion
+(\f$ 1 + k_1 r^2 + k_2 r^4 + k_3 r^6 \f$ monotonically decreasing)
+and pincushion distortion (\f$ 1 + k_1 r^2 + k_2 r^4 + k_3 r^6 \f$ monotonically increasing).
+Radial distortion is always monotonic for real lenses,
+and if the estimator produces a non-monotonic result,
+this should be considered a calibration failure.
+More generally, radial distortion must be monotonic and the distortion function must be bijective.
+A failed estimation result may look deceptively good near the image center
+but will work poorly in e.g. AR/SFM applications.
+The optimization method used in OpenCV camera calibration does not include these constraints as
+the framework does not support the required integer programming and polynomial inequalities.
+See [issue #15992](https://github.com/opencv/opencv/issues/15992) for additional information.
+
+
+
+
+In some cases, the image sensor may be tilted in order to focus an oblique plane in front of the
+camera (Scheimpflug principle). This can be useful for particle image velocimetry (PIV) or
triangulation with a laser fan. The tilt causes a perspective distortion of \f$x''\f$ and
-\f$y''\f$. This distortion can be modelled in the following way, see e.g. @cite Louhichi07.
+\f$y''\f$. This distortion can be modeled in the following way, see e.g. @cite Louhichi07.
-\f[\begin{array}{l}
-s\vecthree{x'''}{y'''}{1} =
+\f[\begin{bmatrix}
+u \\
+v
+\end{bmatrix} = \begin{bmatrix}
+f_x x''' + c_x \\
+f_y y''' + c_y
+\end{bmatrix},\f]
+
+where
+
+\f[s\vecthree{x'''}{y'''}{1} =
\vecthreethree{R_{33}(\tau_x, \tau_y)}{0}{-R_{13}(\tau_x, \tau_y)}
{0}{R_{33}(\tau_x, \tau_y)}{-R_{23}(\tau_x, \tau_y)}
-{0}{0}{1} R(\tau_x, \tau_y) \vecthree{x''}{y''}{1}\\
-u = f_x*x''' + c_x \\
-v = f_y*y''' + c_y
-\end{array}\f]
+{0}{0}{1} R(\tau_x, \tau_y) \vecthree{x''}{y''}{1}\f]
-where the matrix \f$R(\tau_x, \tau_y)\f$ is defined by two rotations with angular parameter \f$\tau_x\f$
-and \f$\tau_y\f$, respectively,
+and the matrix \f$R(\tau_x, \tau_y)\f$ is defined by two rotations with angular parameter
+\f$\tau_x\f$ and \f$\tau_y\f$, respectively,
\f[
R(\tau_x, \tau_y) =
@@ -148,8 +317,8 @@ vector. That is, if the vector contains four elements, it means that \f$k_3=0\f$
coefficients do not depend on the scene viewed. Thus, they also belong to the intrinsic camera
parameters. And they remain the same regardless of the captured image resolution. If, for example, a
camera has been calibrated on images of 320 x 240 resolution, absolutely the same distortion
-coefficients can be used for 640 x 480 images from the same camera while \f$f_x\f$, \f$f_y\f$, \f$c_x\f$, and
-\f$c_y\f$ need to be scaled appropriately.
+coefficients can be used for 640 x 480 images from the same camera while \f$f_x\f$, \f$f_y\f$,
+\f$c_x\f$, and \f$c_y\f$ need to be scaled appropriately.
The functions below use the above model to do the following:
@@ -161,15 +330,68 @@ pattern (every view is described by several 3D-2D point correspondences).
- Estimate the relative position and orientation of the stereo camera "heads" and compute the
*rectification* transformation that makes the camera optical axes parallel.
+ Homogeneous Coordinates
+Homogeneous Coordinates are a system of coordinates that are used in projective geometry. Their use
+allows to represent points at infinity by finite coordinates and simplifies formulas when compared
+to the cartesian counterparts, e.g. they have the advantage that affine transformations can be
+expressed as linear homogeneous transformation.
+
+One obtains the homogeneous vector \f$P_h\f$ by appending a 1 along an n-dimensional cartesian
+vector \f$P\f$ e.g. for a 3D cartesian vector the mapping \f$P \rightarrow P_h\f$ is:
+
+\f[\begin{bmatrix}
+X \\
+Y \\
+Z
+\end{bmatrix} \rightarrow \begin{bmatrix}
+X \\
+Y \\
+Z \\
+1
+\end{bmatrix}.\f]
+
+For the inverse mapping \f$P_h \rightarrow P\f$, one divides all elements of the homogeneous vector
+by its last element, e.g. for a 3D homogeneous vector one gets its 2D cartesian counterpart by:
+
+\f[\begin{bmatrix}
+X \\
+Y \\
+W
+\end{bmatrix} \rightarrow \begin{bmatrix}
+X / W \\
+Y / W
+\end{bmatrix},\f]
+
+if \f$W \ne 0\f$.
+
+Due to this mapping, all multiples \f$k P_h\f$, for \f$k \ne 0\f$, of a homogeneous point represent
+the same point \f$P_h\f$. An intuitive understanding of this property is that under a projective
+transformation, all multiples of \f$P_h\f$ are mapped to the same point. This is the physical
+observation one does for pinhole cameras, as all points along a ray through the camera's pinhole are
+projected to the same image point, e.g. all points along the red ray in the image of the pinhole
+camera model above would be mapped to the same image coordinate. This property is also the source
+for the scale ambiguity s in the equation of the pinhole camera model.
+
+As mentioned, by using homogeneous coordinates we can express any change of basis parameterized by
+\f$R\f$ and \f$t\f$ as a linear transformation, e.g. for the change of basis from coordinate system
+0 to coordinate system 1 becomes:
+
+\f[P_1 = R P_0 + t \rightarrow P_{h_1} = \begin{bmatrix}
+R & t \\
+0 & 1
+\end{bmatrix} P_{h_0}.\f]
+
@note
- - A calibration sample for 3 cameras in horizontal position can be found at
+ - Many functions in this module take a camera matrix as an input parameter. Although all
+ functions assume the same structure of this parameter, they may name it differently. The
+ parameter's description, however, will be clear in that a camera matrix with the structure
+ shown above is required.
+ - A calibration sample for 3 cameras in a horizontal position can be found at
opencv_source_code/samples/cpp/3calibration.cpp
- A calibration sample based on a sequence of images can be found at
opencv_source_code/samples/cpp/calibration.cpp
- A calibration sample in order to do 3D reconstruction can be found at
opencv_source_code/samples/cpp/build3dmodel.cpp
- - A calibration sample of an artificially generated camera and chessboard patterns can be
- found at opencv_source_code/samples/cpp/calibration_artificial.cpp
- A calibration example on stereo calibration can be found at
opencv_source_code/samples/cpp/stereo_calib.cpp
- A calibration example on stereo matching can be found at
@@ -190,7 +412,7 @@ pattern (every view is described by several 3D-2D point correspondences).
\f[x = Xc_1 \\ y = Xc_2 \\ z = Xc_3\f]
- The pinehole projection coordinates of P is [a; b] where
+ The pinhole projection coordinates of P is [a; b] where
\f[a = x / z \ and \ b = y / z \\ r^2 = a^2 + b^2 \\ \theta = atan(r)\f]
@@ -219,23 +441,40 @@ namespace cv
//! @{
//! type of the robust estimation algorithm
-enum { LMEDS = 4, //!< least-median algorithm
+enum { LMEDS = 4, //!< least-median of squares algorithm
RANSAC = 8, //!< RANSAC algorithm
RHO = 16 //!< RHO algorithm
};
-enum { SOLVEPNP_ITERATIVE = 0,
- SOLVEPNP_EPNP = 1, //!< EPnP: Efficient Perspective-n-Point Camera Pose Estimation @cite lepetit2009epnp
- SOLVEPNP_P3P = 2, //!< Complete Solution Classification for the Perspective-Three-Point Problem @cite gao2003complete
- SOLVEPNP_DLS = 3, //!< A Direct Least-Squares (DLS) Method for PnP @cite hesch2011direct
- SOLVEPNP_UPNP = 4 //!< Exhaustive Linearization for Robust Camera Pose and Focal Length Estimation @cite penate2013exhaustive
-
+enum SolvePnPMethod {
+ SOLVEPNP_ITERATIVE = 0,
+ SOLVEPNP_EPNP = 1, //!< EPnP: Efficient Perspective-n-Point Camera Pose Estimation @cite lepetit2009epnp
+ SOLVEPNP_P3P = 2, //!< Complete Solution Classification for the Perspective-Three-Point Problem @cite gao2003complete
+ SOLVEPNP_DLS = 3, //!< A Direct Least-Squares (DLS) Method for PnP @cite hesch2011direct
+ SOLVEPNP_UPNP = 4, //!< Exhaustive Linearization for Robust Camera Pose and Focal Length Estimation @cite penate2013exhaustive
+ SOLVEPNP_AP3P = 5, //!< An Efficient Algebraic Solution to the Perspective-Three-Point Problem @cite Ke17
+ SOLVEPNP_IPPE = 6, //!< Infinitesimal Plane-Based Pose Estimation @cite Collins14 \n
+ //!< Object points must be coplanar.
+ SOLVEPNP_IPPE_SQUARE = 7, //!< Infinitesimal Plane-Based Pose Estimation @cite Collins14 \n
+ //!< This is a special case suitable for marker pose estimation.\n
+ //!< 4 coplanar object points must be defined in the following order:
+ //!< - point 0: [-squareLength / 2, squareLength / 2, 0]
+ //!< - point 1: [ squareLength / 2, squareLength / 2, 0]
+ //!< - point 2: [ squareLength / 2, -squareLength / 2, 0]
+ //!< - point 3: [-squareLength / 2, -squareLength / 2, 0]
+#ifndef CV_DOXYGEN
+ SOLVEPNP_MAX_COUNT //!< Used for count
+#endif
};
enum { CALIB_CB_ADAPTIVE_THRESH = 1,
CALIB_CB_NORMALIZE_IMAGE = 2,
CALIB_CB_FILTER_QUADS = 4,
- CALIB_CB_FAST_CHECK = 8
+ CALIB_CB_FAST_CHECK = 8,
+ CALIB_CB_EXHAUSTIVE = 16,
+ CALIB_CB_ACCURACY = 32,
+ CALIB_CB_LARGER = 64,
+ CALIB_CB_MARKER = 128
};
enum { CALIB_CB_SYMMETRIC_GRID = 1,
@@ -243,7 +482,8 @@ enum { CALIB_CB_SYMMETRIC_GRID = 1,
CALIB_CB_CLUSTERING = 4
};
-enum { CALIB_USE_INTRINSIC_GUESS = 0x00001,
+enum { CALIB_NINTRINSIC = 18,
+ CALIB_USE_INTRINSIC_GUESS = 0x00001,
CALIB_FIX_ASPECT_RATIO = 0x00002,
CALIB_FIX_PRINCIPAL_POINT = 0x00004,
CALIB_ZERO_TANGENT_DIST = 0x00008,
@@ -259,21 +499,32 @@ enum { CALIB_USE_INTRINSIC_GUESS = 0x00001,
CALIB_FIX_S1_S2_S3_S4 = 0x10000,
CALIB_TILTED_MODEL = 0x40000,
CALIB_FIX_TAUX_TAUY = 0x80000,
+ CALIB_USE_QR = 0x100000, //!< use QR instead of SVD decomposition for solving. Faster but potentially less precise
+ CALIB_FIX_TANGENT_DIST = 0x200000,
// only for stereo
CALIB_FIX_INTRINSIC = 0x00100,
CALIB_SAME_FOCAL_LENGTH = 0x00200,
// for stereo rectification
CALIB_ZERO_DISPARITY = 0x00400,
CALIB_USE_LU = (1 << 17), //!< use LU instead of SVD decomposition for solving. much faster but potentially less precise
+ CALIB_USE_EXTRINSIC_GUESS = (1 << 22) //!< for stereoCalibrate
};
//! the algorithm for finding fundamental matrix
enum { FM_7POINT = 1, //!< 7-point algorithm
FM_8POINT = 2, //!< 8-point algorithm
- FM_LMEDS = 4, //!< least-median algorithm
- FM_RANSAC = 8 //!< RANSAC algorithm
+ FM_LMEDS = 4, //!< least-median algorithm. 7-point algorithm is used.
+ FM_RANSAC = 8 //!< RANSAC algorithm. It needs at least 15 points. 7-point algorithm is used.
};
+enum HandEyeCalibrationMethod
+{
+ CALIB_HAND_EYE_TSAI = 0, //!< A New Technique for Fully Autonomous and Efficient 3D Robotics Hand/Eye Calibration @cite Tsai89
+ CALIB_HAND_EYE_PARK = 1, //!< Robot Sensor Calibration: Solving AX = XB on the Euclidean Group @cite Park94
+ CALIB_HAND_EYE_HORAUD = 2, //!< Hand-eye Calibration @cite Horaud95
+ CALIB_HAND_EYE_ANDREFF = 3, //!< On-line Hand-Eye Calibration @cite Andreff99
+ CALIB_HAND_EYE_DANIILIDIS = 4 //!< Hand-Eye Calibration Using Dual Quaternions @cite Daniilidis98
+};
/** @brief Converts a rotation matrix to a rotation vector or vice versa.
@@ -283,7 +534,7 @@ enum { FM_7POINT = 1, //!< 7-point algorithm
@param jacobian Optional output Jacobian matrix, 3x9 or 9x3, which is a matrix of partial
derivatives of the output array components with respect to the input array components.
-\f[\begin{array}{l} \theta \leftarrow norm(r) \\ r \leftarrow r/ \theta \\ R = \cos{\theta} I + (1- \cos{\theta} ) r r^T + \sin{\theta} \vecthreethree{0}{-r_z}{r_y}{r_z}{0}{-r_x}{-r_y}{r_x}{0} \end{array}\f]
+\f[\begin{array}{l} \theta \leftarrow norm(r) \\ r \leftarrow r/ \theta \\ R = \cos(\theta) I + (1- \cos{\theta} ) r r^T + \sin(\theta) \vecthreethree{0}{-r_z}{r_y}{r_z}{0}{-r_x}{-r_y}{r_x}{0} \end{array}\f]
Inverse transformation can be also done easily, since
@@ -291,32 +542,114 @@ Inverse transformation can be also done easily, since
A rotation vector is a convenient and most compact representation of a rotation matrix (since any
rotation matrix has just 3 degrees of freedom). The representation is used in the global 3D geometry
-optimization procedures like calibrateCamera, stereoCalibrate, or solvePnP .
+optimization procedures like @ref calibrateCamera, @ref stereoCalibrate, or @ref solvePnP .
+
+@note More information about the computation of the derivative of a 3D rotation matrix with respect to its exponential coordinate
+can be found in:
+ - A Compact Formula for the Derivative of a 3-D Rotation in Exponential Coordinates, Guillermo Gallego, Anthony J. Yezzi @cite Gallego2014ACF
+
+@note Useful information on SE(3) and Lie Groups can be found in:
+ - A tutorial on SE(3) transformation parameterizations and on-manifold optimization, Jose-Luis Blanco @cite blanco2010tutorial
+ - Lie Groups for 2D and 3D Transformation, Ethan Eade @cite Eade17
+ - A micro Lie theory for state estimation in robotics, Joan Solà, Jérémie Deray, Dinesh Atchuthan @cite Sol2018AML
*/
CV_EXPORTS_W void Rodrigues( InputArray src, OutputArray dst, OutputArray jacobian = noArray() );
+
+
+/** Levenberg-Marquardt solver. Starting with the specified vector of parameters it
+ optimizes the target vector criteria "err"
+ (finds local minima of each target vector component absolute value).
+
+ When needed, it calls user-provided callback.
+*/
+class CV_EXPORTS LMSolver : public Algorithm
+{
+public:
+ class CV_EXPORTS Callback
+ {
+ public:
+ virtual ~Callback() {}
+ /**
+ computes error and Jacobian for the specified vector of parameters
+
+ @param param the current vector of parameters
+ @param err output vector of errors: err_i = actual_f_i - ideal_f_i
+ @param J output Jacobian: J_ij = d(err_i)/d(param_j)
+
+ when J=noArray(), it means that it does not need to be computed.
+ Dimensionality of error vector and param vector can be different.
+ The callback should explicitly allocate (with "create" method) each output array
+ (unless it's noArray()).
+ */
+ virtual bool compute(InputArray param, OutputArray err, OutputArray J) const = 0;
+ };
+
+ /**
+ Runs Levenberg-Marquardt algorithm using the passed vector of parameters as the start point.
+ The final vector of parameters (whether the algorithm converged or not) is stored at the same
+ vector. The method returns the number of iterations used. If it's equal to the previously specified
+ maxIters, there is a big chance the algorithm did not converge.
+
+ @param param initial/final vector of parameters.
+
+ Note that the dimensionality of parameter space is defined by the size of param vector,
+ and the dimensionality of optimized criteria is defined by the size of err vector
+ computed by the callback.
+ */
+ virtual int run(InputOutputArray param) const = 0;
+
+ /**
+ Sets the maximum number of iterations
+ @param maxIters the number of iterations
+ */
+ virtual void setMaxIters(int maxIters) = 0;
+ /**
+ Retrieves the current maximum number of iterations
+ */
+ virtual int getMaxIters() const = 0;
+
+ /**
+ Creates Levenberg-Marquard solver
+
+ @param cb callback
+ @param maxIters maximum number of iterations that can be further
+ modified using setMaxIters() method.
+ */
+ static Ptr create(const Ptr& cb, int maxIters);
+ static Ptr create(const Ptr& cb, int maxIters, double eps);
+};
+
+
+
+/** @example samples/cpp/tutorial_code/features2D/Homography/pose_from_homography.cpp
+An example program about pose estimation from coplanar points
+
+Check @ref tutorial_homography "the corresponding tutorial" for more details
+*/
+
/** @brief Finds a perspective transformation between two planes.
@param srcPoints Coordinates of the points in the original plane, a matrix of the type CV_32FC2
or vector\ .
@param dstPoints Coordinates of the points in the target plane, a matrix of the type CV_32FC2 or
a vector\ .
-@param method Method used to computed a homography matrix. The following methods are possible:
-- **0** - a regular method using all the points
+@param method Method used to compute a homography matrix. The following methods are possible:
+- **0** - a regular method using all the points, i.e., the least squares method
- **RANSAC** - RANSAC-based robust method
- **LMEDS** - Least-Median robust method
-- **RHO** - PROSAC-based robust method
+- **RHO** - PROSAC-based robust method
@param ransacReprojThreshold Maximum allowed reprojection error to treat a point pair as an inlier
(used in the RANSAC and RHO methods only). That is, if
-\f[\| \texttt{dstPoints} _i - \texttt{convertPointsHomogeneous} ( \texttt{H} * \texttt{srcPoints} _i) \| > \texttt{ransacReprojThreshold}\f]
-then the point \f$i\f$ is considered an outlier. If srcPoints and dstPoints are measured in pixels,
+\f[\| \texttt{dstPoints} _i - \texttt{convertPointsHomogeneous} ( \texttt{H} * \texttt{srcPoints} _i) \|_2 > \texttt{ransacReprojThreshold}\f]
+then the point \f$i\f$ is considered as an outlier. If srcPoints and dstPoints are measured in pixels,
it usually makes sense to set this parameter somewhere in the range of 1 to 10.
@param mask Optional output mask set by a robust method ( RANSAC or LMEDS ). Note that the input
mask values are ignored.
-@param maxIters The maximum number of RANSAC iterations, 2000 is the maximum it can be.
+@param maxIters The maximum number of RANSAC iterations.
@param confidence Confidence level, between 0 and 1.
-The functions find and return the perspective transformation \f$H\f$ between the source and the
+The function finds and returns the perspective transformation \f$H\f$ between the source and the
destination planes:
\f[s_i \vecthree{x'_i}{y'_i}{1} \sim H \vecthree{x_i}{y_i}{1}\f]
@@ -331,10 +664,10 @@ pairs to compute an initial homography estimate with a simple least-squares sche
However, if not all of the point pairs ( \f$srcPoints_i\f$, \f$dstPoints_i\f$ ) fit the rigid perspective
transformation (that is, there are some outliers), this initial estimate will be poor. In this case,
you can use one of the three robust methods. The methods RANSAC, LMeDS and RHO try many different
-random subsets of the corresponding point pairs (of four pairs each), estimate the homography matrix
-using this subset and a simple least-square algorithm, and then compute the quality/goodness of the
-computed homography (which is the number of inliers for RANSAC or the median re-projection error for
-LMeDs). The best subset is then used to produce the initial estimate of the homography matrix and
+random subsets of the corresponding point pairs (of four pairs each, collinear pairs are discarded), estimate the homography matrix
+using this subset and a simple least-squares algorithm, and then compute the quality/goodness of the
+computed homography (which is the number of inliers for RANSAC or the least median re-projection error for
+LMeDS). The best subset is then used to produce the initial estimate of the homography matrix and
the mask of inliers/outliers.
Regardless of the method, robust or not, the computed homography matrix is refined further (using
@@ -347,17 +680,12 @@ correctly only when there are more than 50% of inliers. Finally, if there are no
noise is rather small, use the default method (method=0).
The function is used to find initial intrinsic and extrinsic matrices. Homography matrix is
-determined up to a scale. Thus, it is normalized so that \f$h_{33}=1\f$. Note that whenever an H matrix
+determined up to a scale. Thus, it is normalized so that \f$h_{33}=1\f$. Note that whenever an \f$H\f$ matrix
cannot be estimated, an empty one will be returned.
@sa
- getAffineTransform, getPerspectiveTransform, estimateRigidTransform, warpPerspective,
- perspectiveTransform
-
-@note
- - A example on calculating a homography for image matching can be found at
- opencv_source_code/samples/cpp/video_homography.cpp
-
+getAffineTransform, estimateAffine2D, estimateAffinePartial2D, getPerspectiveTransform, warpPerspective,
+perspectiveTransform
*/
CV_EXPORTS_W Mat findHomography( InputArray srcPoints, InputArray dstPoints,
int method = 0, double ransacReprojThreshold = 3,
@@ -383,8 +711,8 @@ and a rotation matrix.
It optionally returns three rotation matrices, one for each axis, and the three Euler angles in
degrees (as the return value) that could be used in OpenGL. Note, there is always more than one
-sequence of rotations about the three principle axes that results in the same orientation of an
-object, eg. see @cite Slabaugh . Returned tree rotation matrices and corresponding three Euler angules
+sequence of rotations about the three principal axes that results in the same orientation of an
+object, e.g. see @cite Slabaugh . Returned tree rotation matrices and corresponding three Euler angles
are only one of the possible solutions.
*/
CV_EXPORTS_W Vec3d RQDecomp3x3( InputArray src, OutputArray mtxR, OutputArray mtxQ,
@@ -409,8 +737,8 @@ matrix and the position of a camera.
It optionally returns three rotation matrices, one for each axis, and three Euler angles that could
be used in OpenGL. Note, there is always more than one sequence of rotations about the three
-principle axes that results in the same orientation of an object, eg. see @cite Slabaugh . Returned
-tree rotation matrices and corresponding three Euler angules are only one of the possible solutions.
+principal axes that results in the same orientation of an object, e.g. see @cite Slabaugh . Returned
+tree rotation matrices and corresponding three Euler angles are only one of the possible solutions.
The function is based on RQDecomp3x3 .
*/
@@ -444,15 +772,14 @@ CV_EXPORTS_W void matMulDeriv( InputArray A, InputArray B, OutputArray dABdA, Ou
@param tvec2 Second translation vector.
@param rvec3 Output rotation vector of the superposition.
@param tvec3 Output translation vector of the superposition.
-@param dr3dr1
-@param dr3dt1
-@param dr3dr2
-@param dr3dt2
-@param dt3dr1
-@param dt3dt1
-@param dt3dr2
-@param dt3dt2 Optional output derivatives of rvec3 or tvec3 with regard to rvec1, rvec2, tvec1 and
-tvec2, respectively.
+@param dr3dr1 Optional output derivative of rvec3 with regard to rvec1
+@param dr3dt1 Optional output derivative of rvec3 with regard to tvec1
+@param dr3dr2 Optional output derivative of rvec3 with regard to rvec2
+@param dr3dt2 Optional output derivative of rvec3 with regard to tvec2
+@param dt3dr1 Optional output derivative of tvec3 with regard to rvec1
+@param dt3dt1 Optional output derivative of tvec3 with regard to tvec1
+@param dt3dr2 Optional output derivative of tvec3 with regard to rvec2
+@param dt3dt2 Optional output derivative of tvec3 with regard to tvec2
The functions compute:
@@ -476,35 +803,37 @@ CV_EXPORTS_W void composeRT( InputArray rvec1, InputArray tvec1,
/** @brief Projects 3D points to an image plane.
-@param objectPoints Array of object points, 3xN/Nx3 1-channel or 1xN/Nx1 3-channel (or
-vector\ ), where N is the number of points in the view.
-@param rvec Rotation vector. See Rodrigues for details.
-@param tvec Translation vector.
+@param objectPoints Array of object points expressed wrt. the world coordinate frame. A 3xN/Nx3
+1-channel or 1xN/Nx1 3-channel (or vector\ ), where N is the number of points in the view.
+@param rvec The rotation vector (@ref Rodrigues) that, together with tvec, performs a change of
+basis from world to camera coordinate system, see @ref calibrateCamera for details.
+@param tvec The translation vector, see parameter description above.
@param cameraMatrix Camera matrix \f$A = \vecthreethree{f_x}{0}{c_x}{0}{f_y}{c_y}{0}{0}{_1}\f$ .
@param distCoeffs Input vector of distortion coefficients
\f$(k_1, k_2, p_1, p_2[, k_3[, k_4, k_5, k_6 [, s_1, s_2, s_3, s_4[, \tau_x, \tau_y]]]])\f$ of
4, 5, 8, 12 or 14 elements. If the vector is empty, the zero distortion coefficients are assumed.
-@param imagePoints Output array of image points, 2xN/Nx2 1-channel or 1xN/Nx1 2-channel, or
+@param imagePoints Output array of image points, 1xN/Nx1 2-channel, or
vector\ .
@param jacobian Optional output 2Nx(10+\) jacobian matrix of derivatives of image
points with respect to components of the rotation vector, translation vector, focal lengths,
coordinates of the principal point and the distortion coefficients. In the old interface different
components of the jacobian are returned via different output parameters.
@param aspectRatio Optional "fixed aspect ratio" parameter. If the parameter is not 0, the
-function assumes that the aspect ratio (*fx/fy*) is fixed and correspondingly adjusts the jacobian
-matrix.
-
-The function computes projections of 3D points to the image plane given intrinsic and extrinsic
-camera parameters. Optionally, the function computes Jacobians - matrices of partial derivatives of
-image points coordinates (as functions of all the input parameters) with respect to the particular
-parameters, intrinsic and/or extrinsic. The Jacobians are used during the global optimization in
-calibrateCamera, solvePnP, and stereoCalibrate . The function itself can also be used to compute a
-re-projection error given the current intrinsic and extrinsic parameters.
-
-@note By setting rvec=tvec=(0,0,0) or by setting cameraMatrix to a 3x3 identity matrix, or by
-passing zero distortion coefficients, you can get various useful partial cases of the function. This
-means that you can compute the distorted coordinates for a sparse set of points or apply a
-perspective transformation (and also compute the derivatives) in the ideal zero-distortion setup.
+function assumes that the aspect ratio (\f$f_x / f_y\f$) is fixed and correspondingly adjusts the
+jacobian matrix.
+
+The function computes the 2D projections of 3D points to the image plane, given intrinsic and
+extrinsic camera parameters. Optionally, the function computes Jacobians -matrices of partial
+derivatives of image points coordinates (as functions of all the input parameters) with respect to
+the particular parameters, intrinsic and/or extrinsic. The Jacobians are used during the global
+optimization in @ref calibrateCamera, @ref solvePnP, and @ref stereoCalibrate. The function itself
+can also be used to compute a re-projection error, given the current intrinsic and extrinsic
+parameters.
+
+@note By setting rvec = tvec = \f$[0, 0, 0]\f$, or by setting cameraMatrix to a 3x3 identity matrix,
+or by passing zero distortion coefficients, one can get various useful partial cases of the
+function. This means, one can compute the distorted coordinates for a sparse set of points or apply
+a perspective transformation (and also compute the derivatives) in the ideal zero-distortion setup.
*/
CV_EXPORTS_W void projectPoints( InputArray objectPoints,
InputArray rvec, InputArray tvec,
@@ -513,43 +842,162 @@ CV_EXPORTS_W void projectPoints( InputArray objectPoints,
OutputArray jacobian = noArray(),
double aspectRatio = 0 );
+/** @example samples/cpp/tutorial_code/features2D/Homography/homography_from_camera_displacement.cpp
+An example program about homography from the camera displacement
+
+Check @ref tutorial_homography "the corresponding tutorial" for more details
+*/
+
/** @brief Finds an object pose from 3D-2D point correspondences.
+This function returns the rotation and the translation vectors that transform a 3D point expressed in the object
+coordinate frame to the camera coordinate frame, using different methods:
+- P3P methods (@ref SOLVEPNP_P3P, @ref SOLVEPNP_AP3P): need 4 input points to return a unique solution.
+- @ref SOLVEPNP_IPPE Input points must be >= 4 and object points must be coplanar.
+- @ref SOLVEPNP_IPPE_SQUARE Special case suitable for marker pose estimation.
+Number of input points must be 4. Object points must be defined in the following order:
+ - point 0: [-squareLength / 2, squareLength / 2, 0]
+ - point 1: [ squareLength / 2, squareLength / 2, 0]
+ - point 2: [ squareLength / 2, -squareLength / 2, 0]
+ - point 3: [-squareLength / 2, -squareLength / 2, 0]
+- for all the other flags, number of input points must be >= 4 and object points can be in any configuration.
@param objectPoints Array of object points in the object coordinate space, Nx3 1-channel or
-1xN/Nx1 3-channel, where N is the number of points. vector\ can be also passed here.
+1xN/Nx1 3-channel, where N is the number of points. vector\ can be also passed here.
@param imagePoints Array of corresponding image points, Nx2 1-channel or 1xN/Nx1 2-channel,
-where N is the number of points. vector\ can be also passed here.
-@param cameraMatrix Input camera matrix \f$A = \vecthreethree{fx}{0}{cx}{0}{fy}{cy}{0}{0}{1}\f$ .
+where N is the number of points. vector\ can be also passed here.
+@param cameraMatrix Input camera matrix \f$A = \vecthreethree{f_x}{0}{c_x}{0}{f_y}{c_y}{0}{0}{1}\f$ .
@param distCoeffs Input vector of distortion coefficients
\f$(k_1, k_2, p_1, p_2[, k_3[, k_4, k_5, k_6 [, s_1, s_2, s_3, s_4[, \tau_x, \tau_y]]]])\f$ of
4, 5, 8, 12 or 14 elements. If the vector is NULL/empty, the zero distortion coefficients are
assumed.
-@param rvec Output rotation vector (see Rodrigues ) that, together with tvec , brings points from
+@param rvec Output rotation vector (see @ref Rodrigues ) that, together with tvec, brings points from
the model coordinate system to the camera coordinate system.
@param tvec Output translation vector.
-@param useExtrinsicGuess Parameter used for SOLVEPNP_ITERATIVE. If true (1), the function uses
+@param useExtrinsicGuess Parameter used for #SOLVEPNP_ITERATIVE. If true (1), the function uses
the provided rvec and tvec values as initial approximations of the rotation and translation
vectors, respectively, and further optimizes them.
@param flags Method for solving a PnP problem:
-- **SOLVEPNP_ITERATIVE** Iterative method is based on Levenberg-Marquardt optimization. In
+- **SOLVEPNP_ITERATIVE** Iterative method is based on a Levenberg-Marquardt optimization. In
this case the function finds such a pose that minimizes reprojection error, that is the sum
of squared distances between the observed projections imagePoints and the projected (using
projectPoints ) objectPoints .
- **SOLVEPNP_P3P** Method is based on the paper of X.S. Gao, X.-R. Hou, J. Tang, H.-F. Chang
-"Complete Solution Classification for the Perspective-Three-Point Problem". In this case the
-function requires exactly four object and image points.
-- **SOLVEPNP_EPNP** Method has been introduced by F.Moreno-Noguer, V.Lepetit and P.Fua in the
-paper "EPnP: Efficient Perspective-n-Point Camera Pose Estimation".
-- **SOLVEPNP_DLS** Method is based on the paper of Joel A. Hesch and Stergios I. Roumeliotis.
-"A Direct Least-Squares (DLS) Method for PnP".
-- **SOLVEPNP_UPNP** Method is based on the paper of A.Penate-Sanchez, J.Andrade-Cetto,
-F.Moreno-Noguer. "Exhaustive Linearization for Robust Camera Pose and Focal Length
-Estimation". In this case the function also estimates the parameters \f$f_x\f$ and \f$f_y\f$
+"Complete Solution Classification for the Perspective-Three-Point Problem" (@cite gao2003complete).
+In this case the function requires exactly four object and image points.
+- **SOLVEPNP_AP3P** Method is based on the paper of T. Ke, S. Roumeliotis
+"An Efficient Algebraic Solution to the Perspective-Three-Point Problem" (@cite Ke17).
+In this case the function requires exactly four object and image points.
+- **SOLVEPNP_EPNP** Method has been introduced by F. Moreno-Noguer, V. Lepetit and P. Fua in the
+paper "EPnP: Efficient Perspective-n-Point Camera Pose Estimation" (@cite lepetit2009epnp).
+- **SOLVEPNP_DLS** Method is based on the paper of J. Hesch and S. Roumeliotis.
+"A Direct Least-Squares (DLS) Method for PnP" (@cite hesch2011direct).
+- **SOLVEPNP_UPNP** Method is based on the paper of A. Penate-Sanchez, J. Andrade-Cetto,
+F. Moreno-Noguer. "Exhaustive Linearization for Robust Camera Pose and Focal Length
+Estimation" (@cite penate2013exhaustive). In this case the function also estimates the parameters \f$f_x\f$ and \f$f_y\f$
assuming that both have the same value. Then the cameraMatrix is updated with the estimated
focal length.
+- **SOLVEPNP_IPPE** Method is based on the paper of T. Collins and A. Bartoli.
+"Infinitesimal Plane-Based Pose Estimation" (@cite Collins14). This method requires coplanar object points.
+- **SOLVEPNP_IPPE_SQUARE** Method is based on the paper of Toby Collins and Adrien Bartoli.
+"Infinitesimal Plane-Based Pose Estimation" (@cite Collins14). This method is suitable for marker pose estimation.
+It requires 4 coplanar object points defined in the following order:
+ - point 0: [-squareLength / 2, squareLength / 2, 0]
+ - point 1: [ squareLength / 2, squareLength / 2, 0]
+ - point 2: [ squareLength / 2, -squareLength / 2, 0]
+ - point 3: [-squareLength / 2, -squareLength / 2, 0]
The function estimates the object pose given a set of object points, their corresponding image
-projections, as well as the camera matrix and the distortion coefficients.
+projections, as well as the camera matrix and the distortion coefficients, see the figure below
+(more precisely, the X-axis of the camera frame is pointing to the right, the Y-axis downward
+and the Z-axis forward).
+
+
+
+Points expressed in the world frame \f$ \bf{X}_w \f$ are projected into the image plane \f$ \left[ u, v \right] \f$
+using the perspective projection model \f$ \Pi \f$ and the camera intrinsic parameters matrix \f$ \bf{A} \f$:
+
+\f[
+ \begin{align*}
+ \begin{bmatrix}
+ u \\
+ v \\
+ 1
+ \end{bmatrix} &=
+ \bf{A} \hspace{0.1em} \Pi \hspace{0.2em} ^{c}\bf{T}_w
+ \begin{bmatrix}
+ X_{w} \\
+ Y_{w} \\
+ Z_{w} \\
+ 1
+ \end{bmatrix} \\
+ \begin{bmatrix}
+ u \\
+ v \\
+ 1
+ \end{bmatrix} &=
+ \begin{bmatrix}
+ f_x & 0 & c_x \\
+ 0 & f_y & c_y \\
+ 0 & 0 & 1
+ \end{bmatrix}
+ \begin{bmatrix}
+ 1 & 0 & 0 & 0 \\
+ 0 & 1 & 0 & 0 \\
+ 0 & 0 & 1 & 0
+ \end{bmatrix}
+ \begin{bmatrix}
+ r_{11} & r_{12} & r_{13} & t_x \\
+ r_{21} & r_{22} & r_{23} & t_y \\
+ r_{31} & r_{32} & r_{33} & t_z \\
+ 0 & 0 & 0 & 1
+ \end{bmatrix}
+ \begin{bmatrix}
+ X_{w} \\
+ Y_{w} \\
+ Z_{w} \\
+ 1
+ \end{bmatrix}
+ \end{align*}
+\f]
+
+The estimated pose is thus the rotation (`rvec`) and the translation (`tvec`) vectors that allow transforming
+a 3D point expressed in the world frame into the camera frame:
+
+\f[
+ \begin{align*}
+ \begin{bmatrix}
+ X_c \\
+ Y_c \\
+ Z_c \\
+ 1
+ \end{bmatrix} &=
+ \hspace{0.2em} ^{c}\bf{T}_w
+ \begin{bmatrix}
+ X_{w} \\
+ Y_{w} \\
+ Z_{w} \\
+ 1
+ \end{bmatrix} \\
+ \begin{bmatrix}
+ X_c \\
+ Y_c \\
+ Z_c \\
+ 1
+ \end{bmatrix} &=
+ \begin{bmatrix}
+ r_{11} & r_{12} & r_{13} & t_x \\
+ r_{21} & r_{22} & r_{23} & t_y \\
+ r_{31} & r_{32} & r_{33} & t_z \\
+ 0 & 0 & 0 & 1
+ \end{bmatrix}
+ \begin{bmatrix}
+ X_{w} \\
+ Y_{w} \\
+ Z_{w} \\
+ 1
+ \end{bmatrix}
+ \end{align*}
+\f]
@note
- An example of how to use solvePnP for planar augmented reality can be found at
@@ -564,6 +1012,22 @@ projections, as well as the camera matrix and the distortion coefficients.
- Thus, given some data D = np.array(...) where D.shape = (N,M), in order to use a subset of
it as, e.g., imagePoints, one must effectively copy it into a new array: imagePoints =
np.ascontiguousarray(D[:,:2]).reshape((N,1,2))
+ - The methods **SOLVEPNP_DLS** and **SOLVEPNP_UPNP** cannot be used as the current implementations are
+ unstable and sometimes give completely wrong results. If you pass one of these two
+ flags, **SOLVEPNP_EPNP** method will be used instead.
+ - The minimum number of points is 4 in the general case. In the case of **SOLVEPNP_P3P** and **SOLVEPNP_AP3P**
+ methods, it is required to use exactly 4 points (the first 3 points are used to estimate all the solutions
+ of the P3P problem, the last one is used to retain the best solution that minimizes the reprojection error).
+ - With **SOLVEPNP_ITERATIVE** method and `useExtrinsicGuess=true`, the minimum number of points is 3 (3 points
+ are sufficient to compute a pose but there are up to 4 solutions). The initial solution should be close to the
+ global solution to converge.
+ - With **SOLVEPNP_IPPE** input points must be >= 4 and object points must be coplanar.
+ - With **SOLVEPNP_IPPE_SQUARE** this is a special case suitable for marker pose estimation.
+ Number of input points must be 4. Object points must be defined in the following order:
+ - point 0: [-squareLength / 2, squareLength / 2, 0]
+ - point 1: [ squareLength / 2, squareLength / 2, 0]
+ - point 2: [ squareLength / 2, -squareLength / 2, 0]
+ - point 3: [-squareLength / 2, -squareLength / 2, 0]
*/
CV_EXPORTS_W bool solvePnP( InputArray objectPoints, InputArray imagePoints,
InputArray cameraMatrix, InputArray distCoeffs,
@@ -573,18 +1037,18 @@ CV_EXPORTS_W bool solvePnP( InputArray objectPoints, InputArray imagePoints,
/** @brief Finds an object pose from 3D-2D point correspondences using the RANSAC scheme.
@param objectPoints Array of object points in the object coordinate space, Nx3 1-channel or
-1xN/Nx1 3-channel, where N is the number of points. vector\ can be also passed here.
+1xN/Nx1 3-channel, where N is the number of points. vector\ can be also passed here.
@param imagePoints Array of corresponding image points, Nx2 1-channel or 1xN/Nx1 2-channel,
-where N is the number of points. vector\ can be also passed here.
+where N is the number of points. vector\ can be also passed here.
@param cameraMatrix Input camera matrix \f$A = \vecthreethree{fx}{0}{cx}{0}{fy}{cy}{0}{0}{1}\f$ .
@param distCoeffs Input vector of distortion coefficients
\f$(k_1, k_2, p_1, p_2[, k_3[, k_4, k_5, k_6 [, s_1, s_2, s_3, s_4[, \tau_x, \tau_y]]]])\f$ of
4, 5, 8, 12 or 14 elements. If the vector is NULL/empty, the zero distortion coefficients are
assumed.
-@param rvec Output rotation vector (see Rodrigues ) that, together with tvec , brings points from
+@param rvec Output rotation vector (see @ref Rodrigues ) that, together with tvec, brings points from
the model coordinate system to the camera coordinate system.
@param tvec Output translation vector.
-@param useExtrinsicGuess Parameter used for SOLVEPNP_ITERATIVE. If true (1), the function uses
+@param useExtrinsicGuess Parameter used for @ref SOLVEPNP_ITERATIVE. If true (1), the function uses
the provided rvec and tvec values as initial approximations of the rotation and translation
vectors, respectively, and further optimizes them.
@param iterationsCount Number of iterations.
@@ -593,17 +1057,24 @@ is the maximum allowed distance between the observed and computed point projecti
an inlier.
@param confidence The probability that the algorithm produces a useful result.
@param inliers Output vector that contains indices of inliers in objectPoints and imagePoints .
-@param flags Method for solving a PnP problem (see solvePnP ).
+@param flags Method for solving a PnP problem (see @ref solvePnP ).
The function estimates an object pose given a set of object points, their corresponding image
projections, as well as the camera matrix and the distortion coefficients. This function finds such
a pose that minimizes reprojection error, that is, the sum of squared distances between the observed
-projections imagePoints and the projected (using projectPoints ) objectPoints. The use of RANSAC
+projections imagePoints and the projected (using @ref projectPoints ) objectPoints. The use of RANSAC
makes the function resistant to outliers.
@note
- An example of how to use solvePNPRansac for object detection can be found at
opencv_source_code/samples/cpp/tutorial_code/calib3d/real_time_pose_estimation/
+ - The default method used to estimate the camera pose for the Minimal Sample Sets step
+ is #SOLVEPNP_EPNP. Exceptions are:
+ - if you choose #SOLVEPNP_P3P or #SOLVEPNP_AP3P, these methods will be used.
+ - if the number of input points is equal to 4, #SOLVEPNP_P3P is used.
+ - The method used to estimate the camera pose using all the inliers is defined by the
+ flags parameters unless it is equal to #SOLVEPNP_P3P or #SOLVEPNP_AP3P. In this case,
+ the method #SOLVEPNP_EPNP will be used instead.
*/
CV_EXPORTS_W bool solvePnPRansac( InputArray objectPoints, InputArray imagePoints,
InputArray cameraMatrix, InputArray distCoeffs,
@@ -612,6 +1083,292 @@ CV_EXPORTS_W bool solvePnPRansac( InputArray objectPoints, InputArray imagePoint
float reprojectionError = 8.0, double confidence = 0.99,
OutputArray inliers = noArray(), int flags = SOLVEPNP_ITERATIVE );
+/** @brief Finds an object pose from 3 3D-2D point correspondences.
+
+@param objectPoints Array of object points in the object coordinate space, 3x3 1-channel or
+1x3/3x1 3-channel. vector\ can be also passed here.
+@param imagePoints Array of corresponding image points, 3x2 1-channel or 1x3/3x1 2-channel.
+ vector\ can be also passed here.
+@param cameraMatrix Input camera matrix \f$A = \vecthreethree{f_x}{0}{c_x}{0}{f_y}{c_y}{0}{0}{1}\f$ .
+@param distCoeffs Input vector of distortion coefficients
+\f$(k_1, k_2, p_1, p_2[, k_3[, k_4, k_5, k_6 [, s_1, s_2, s_3, s_4[, \tau_x, \tau_y]]]])\f$ of
+4, 5, 8, 12 or 14 elements. If the vector is NULL/empty, the zero distortion coefficients are
+assumed.
+@param rvecs Output rotation vectors (see @ref Rodrigues ) that, together with tvecs, brings points from
+the model coordinate system to the camera coordinate system. A P3P problem has up to 4 solutions.
+@param tvecs Output translation vectors.
+@param flags Method for solving a P3P problem:
+- **SOLVEPNP_P3P** Method is based on the paper of X.S. Gao, X.-R. Hou, J. Tang, H.-F. Chang
+"Complete Solution Classification for the Perspective-Three-Point Problem" (@cite gao2003complete).
+- **SOLVEPNP_AP3P** Method is based on the paper of T. Ke and S. Roumeliotis.
+"An Efficient Algebraic Solution to the Perspective-Three-Point Problem" (@cite Ke17).
+
+The function estimates the object pose given 3 object points, their corresponding image
+projections, as well as the camera matrix and the distortion coefficients.
+
+@note
+The solutions are sorted by reprojection errors (lowest to highest).
+ */
+CV_EXPORTS_W int solveP3P( InputArray objectPoints, InputArray imagePoints,
+ InputArray cameraMatrix, InputArray distCoeffs,
+ OutputArrayOfArrays rvecs, OutputArrayOfArrays tvecs,
+ int flags );
+
+/** @brief Refine a pose (the translation and the rotation that transform a 3D point expressed in the object coordinate frame
+to the camera coordinate frame) from a 3D-2D point correspondences and starting from an initial solution.
+
+@param objectPoints Array of object points in the object coordinate space, Nx3 1-channel or 1xN/Nx1 3-channel,
+where N is the number of points. vector\ can also be passed here.
+@param imagePoints Array of corresponding image points, Nx2 1-channel or 1xN/Nx1 2-channel,
+where N is the number of points. vector\ can also be passed here.
+@param cameraMatrix Input camera matrix \f$A = \vecthreethree{f_x}{0}{c_x}{0}{f_y}{c_y}{0}{0}{1}\f$ .
+@param distCoeffs Input vector of distortion coefficients
+\f$(k_1, k_2, p_1, p_2[, k_3[, k_4, k_5, k_6 [, s_1, s_2, s_3, s_4[, \tau_x, \tau_y]]]])\f$ of
+4, 5, 8, 12 or 14 elements. If the vector is NULL/empty, the zero distortion coefficients are
+assumed.
+@param rvec Input/Output rotation vector (see @ref Rodrigues ) that, together with tvec, brings points from
+the model coordinate system to the camera coordinate system. Input values are used as an initial solution.
+@param tvec Input/Output translation vector. Input values are used as an initial solution.
+@param criteria Criteria when to stop the Levenberg-Marquard iterative algorithm.
+
+The function refines the object pose given at least 3 object points, their corresponding image
+projections, an initial solution for the rotation and translation vector,
+as well as the camera matrix and the distortion coefficients.
+The function minimizes the projection error with respect to the rotation and the translation vectors, according
+to a Levenberg-Marquardt iterative minimization @cite Madsen04 @cite Eade13 process.
+ */
+CV_EXPORTS_W void solvePnPRefineLM( InputArray objectPoints, InputArray imagePoints,
+ InputArray cameraMatrix, InputArray distCoeffs,
+ InputOutputArray rvec, InputOutputArray tvec,
+ TermCriteria criteria = TermCriteria(TermCriteria::EPS + TermCriteria::COUNT, 20, FLT_EPSILON));
+
+/** @brief Refine a pose (the translation and the rotation that transform a 3D point expressed in the object coordinate frame
+to the camera coordinate frame) from a 3D-2D point correspondences and starting from an initial solution.
+
+@param objectPoints Array of object points in the object coordinate space, Nx3 1-channel or 1xN/Nx1 3-channel,
+where N is the number of points. vector\ can also be passed here.
+@param imagePoints Array of corresponding image points, Nx2 1-channel or 1xN/Nx1 2-channel,
+where N is the number of points. vector\ can also be passed here.
+@param cameraMatrix Input camera matrix \f$A = \vecthreethree{f_x}{0}{c_x}{0}{f_y}{c_y}{0}{0}{1}\f$ .
+@param distCoeffs Input vector of distortion coefficients
+\f$(k_1, k_2, p_1, p_2[, k_3[, k_4, k_5, k_6 [, s_1, s_2, s_3, s_4[, \tau_x, \tau_y]]]])\f$ of
+4, 5, 8, 12 or 14 elements. If the vector is NULL/empty, the zero distortion coefficients are
+assumed.
+@param rvec Input/Output rotation vector (see @ref Rodrigues ) that, together with tvec, brings points from
+the model coordinate system to the camera coordinate system. Input values are used as an initial solution.
+@param tvec Input/Output translation vector. Input values are used as an initial solution.
+@param criteria Criteria when to stop the Levenberg-Marquard iterative algorithm.
+@param VVSlambda Gain for the virtual visual servoing control law, equivalent to the \f$\alpha\f$
+gain in the Damped Gauss-Newton formulation.
+
+The function refines the object pose given at least 3 object points, their corresponding image
+projections, an initial solution for the rotation and translation vector,
+as well as the camera matrix and the distortion coefficients.
+The function minimizes the projection error with respect to the rotation and the translation vectors, using a
+virtual visual servoing (VVS) @cite Chaumette06 @cite Marchand16 scheme.
+ */
+CV_EXPORTS_W void solvePnPRefineVVS( InputArray objectPoints, InputArray imagePoints,
+ InputArray cameraMatrix, InputArray distCoeffs,
+ InputOutputArray rvec, InputOutputArray tvec,
+ TermCriteria criteria = TermCriteria(TermCriteria::EPS + TermCriteria::COUNT, 20, FLT_EPSILON),
+ double VVSlambda = 1);
+
+/** @brief Finds an object pose from 3D-2D point correspondences.
+This function returns a list of all the possible solutions (a solution is a
+couple), depending on the number of input points and the chosen method:
+- P3P methods (@ref SOLVEPNP_P3P, @ref SOLVEPNP_AP3P): 3 or 4 input points. Number of returned solutions can be between 0 and 4 with 3 input points.
+- @ref SOLVEPNP_IPPE Input points must be >= 4 and object points must be coplanar. Returns 2 solutions.
+- @ref SOLVEPNP_IPPE_SQUARE Special case suitable for marker pose estimation.
+Number of input points must be 4 and 2 solutions are returned. Object points must be defined in the following order:
+ - point 0: [-squareLength / 2, squareLength / 2, 0]
+ - point 1: [ squareLength / 2, squareLength / 2, 0]
+ - point 2: [ squareLength / 2, -squareLength / 2, 0]
+ - point 3: [-squareLength / 2, -squareLength / 2, 0]
+- for all the other flags, number of input points must be >= 4 and object points can be in any configuration.
+Only 1 solution is returned.
+
+@param objectPoints Array of object points in the object coordinate space, Nx3 1-channel or
+1xN/Nx1 3-channel, where N is the number of points. vector\ can be also passed here.
+@param imagePoints Array of corresponding image points, Nx2 1-channel or 1xN/Nx1 2-channel,
+where N is the number of points. vector\ can be also passed here.
+@param cameraMatrix Input camera matrix \f$A = \vecthreethree{f_x}{0}{c_x}{0}{f_y}{c_y}{0}{0}{1}\f$ .
+@param distCoeffs Input vector of distortion coefficients
+\f$(k_1, k_2, p_1, p_2[, k_3[, k_4, k_5, k_6 [, s_1, s_2, s_3, s_4[, \tau_x, \tau_y]]]])\f$ of
+4, 5, 8, 12 or 14 elements. If the vector is NULL/empty, the zero distortion coefficients are
+assumed.
+@param rvecs Vector of output rotation vectors (see @ref Rodrigues ) that, together with tvecs, brings points from
+the model coordinate system to the camera coordinate system.
+@param tvecs Vector of output translation vectors.
+@param useExtrinsicGuess Parameter used for #SOLVEPNP_ITERATIVE. If true (1), the function uses
+the provided rvec and tvec values as initial approximations of the rotation and translation
+vectors, respectively, and further optimizes them.
+@param flags Method for solving a PnP problem:
+- **SOLVEPNP_ITERATIVE** Iterative method is based on a Levenberg-Marquardt optimization. In
+this case the function finds such a pose that minimizes reprojection error, that is the sum
+of squared distances between the observed projections imagePoints and the projected (using
+projectPoints ) objectPoints .
+- **SOLVEPNP_P3P** Method is based on the paper of X.S. Gao, X.-R. Hou, J. Tang, H.-F. Chang
+"Complete Solution Classification for the Perspective-Three-Point Problem" (@cite gao2003complete).
+In this case the function requires exactly four object and image points.
+- **SOLVEPNP_AP3P** Method is based on the paper of T. Ke, S. Roumeliotis
+"An Efficient Algebraic Solution to the Perspective-Three-Point Problem" (@cite Ke17).
+In this case the function requires exactly four object and image points.
+- **SOLVEPNP_EPNP** Method has been introduced by F.Moreno-Noguer, V.Lepetit and P.Fua in the
+paper "EPnP: Efficient Perspective-n-Point Camera Pose Estimation" (@cite lepetit2009epnp).
+- **SOLVEPNP_DLS** Method is based on the paper of Joel A. Hesch and Stergios I. Roumeliotis.
+"A Direct Least-Squares (DLS) Method for PnP" (@cite hesch2011direct).
+- **SOLVEPNP_UPNP** Method is based on the paper of A.Penate-Sanchez, J.Andrade-Cetto,
+F.Moreno-Noguer. "Exhaustive Linearization for Robust Camera Pose and Focal Length
+Estimation" (@cite penate2013exhaustive). In this case the function also estimates the parameters \f$f_x\f$ and \f$f_y\f$
+assuming that both have the same value. Then the cameraMatrix is updated with the estimated
+focal length.
+- **SOLVEPNP_IPPE** Method is based on the paper of T. Collins and A. Bartoli.
+"Infinitesimal Plane-Based Pose Estimation" (@cite Collins14). This method requires coplanar object points.
+- **SOLVEPNP_IPPE_SQUARE** Method is based on the paper of Toby Collins and Adrien Bartoli.
+"Infinitesimal Plane-Based Pose Estimation" (@cite Collins14). This method is suitable for marker pose estimation.
+It requires 4 coplanar object points defined in the following order:
+ - point 0: [-squareLength / 2, squareLength / 2, 0]
+ - point 1: [ squareLength / 2, squareLength / 2, 0]
+ - point 2: [ squareLength / 2, -squareLength / 2, 0]
+ - point 3: [-squareLength / 2, -squareLength / 2, 0]
+@param rvec Rotation vector used to initialize an iterative PnP refinement algorithm, when flag is SOLVEPNP_ITERATIVE
+and useExtrinsicGuess is set to true.
+@param tvec Translation vector used to initialize an iterative PnP refinement algorithm, when flag is SOLVEPNP_ITERATIVE
+and useExtrinsicGuess is set to true.
+@param reprojectionError Optional vector of reprojection error, that is the RMS error
+(\f$ \text{RMSE} = \sqrt{\frac{\sum_{i}^{N} \left ( \hat{y_i} - y_i \right )^2}{N}} \f$) between the input image points
+and the 3D object points projected with the estimated pose.
+
+The function estimates the object pose given a set of object points, their corresponding image
+projections, as well as the camera matrix and the distortion coefficients, see the figure below
+(more precisely, the X-axis of the camera frame is pointing to the right, the Y-axis downward
+and the Z-axis forward).
+
+
+
+Points expressed in the world frame \f$ \bf{X}_w \f$ are projected into the image plane \f$ \left[ u, v \right] \f$
+using the perspective projection model \f$ \Pi \f$ and the camera intrinsic parameters matrix \f$ \bf{A} \f$:
+
+\f[
+ \begin{align*}
+ \begin{bmatrix}
+ u \\
+ v \\
+ 1
+ \end{bmatrix} &=
+ \bf{A} \hspace{0.1em} \Pi \hspace{0.2em} ^{c}\bf{T}_w
+ \begin{bmatrix}
+ X_{w} \\
+ Y_{w} \\
+ Z_{w} \\
+ 1
+ \end{bmatrix} \\
+ \begin{bmatrix}
+ u \\
+ v \\
+ 1
+ \end{bmatrix} &=
+ \begin{bmatrix}
+ f_x & 0 & c_x \\
+ 0 & f_y & c_y \\
+ 0 & 0 & 1
+ \end{bmatrix}
+ \begin{bmatrix}
+ 1 & 0 & 0 & 0 \\
+ 0 & 1 & 0 & 0 \\
+ 0 & 0 & 1 & 0
+ \end{bmatrix}
+ \begin{bmatrix}
+ r_{11} & r_{12} & r_{13} & t_x \\
+ r_{21} & r_{22} & r_{23} & t_y \\
+ r_{31} & r_{32} & r_{33} & t_z \\
+ 0 & 0 & 0 & 1
+ \end{bmatrix}
+ \begin{bmatrix}
+ X_{w} \\
+ Y_{w} \\
+ Z_{w} \\
+ 1
+ \end{bmatrix}
+ \end{align*}
+\f]
+
+The estimated pose is thus the rotation (`rvec`) and the translation (`tvec`) vectors that allow transforming
+a 3D point expressed in the world frame into the camera frame:
+
+\f[
+ \begin{align*}
+ \begin{bmatrix}
+ X_c \\
+ Y_c \\
+ Z_c \\
+ 1
+ \end{bmatrix} &=
+ \hspace{0.2em} ^{c}\bf{T}_w
+ \begin{bmatrix}
+ X_{w} \\
+ Y_{w} \\
+ Z_{w} \\
+ 1
+ \end{bmatrix} \\
+ \begin{bmatrix}
+ X_c \\
+ Y_c \\
+ Z_c \\
+ 1
+ \end{bmatrix} &=
+ \begin{bmatrix}
+ r_{11} & r_{12} & r_{13} & t_x \\
+ r_{21} & r_{22} & r_{23} & t_y \\
+ r_{31} & r_{32} & r_{33} & t_z \\
+ 0 & 0 & 0 & 1
+ \end{bmatrix}
+ \begin{bmatrix}
+ X_{w} \\
+ Y_{w} \\
+ Z_{w} \\
+ 1
+ \end{bmatrix}
+ \end{align*}
+\f]
+
+@note
+ - An example of how to use solvePnP for planar augmented reality can be found at
+ opencv_source_code/samples/python/plane_ar.py
+ - If you are using Python:
+ - Numpy array slices won't work as input because solvePnP requires contiguous
+ arrays (enforced by the assertion using cv::Mat::checkVector() around line 55 of
+ modules/calib3d/src/solvepnp.cpp version 2.4.9)
+ - The P3P algorithm requires image points to be in an array of shape (N,1,2) due
+ to its calling of cv::undistortPoints (around line 75 of modules/calib3d/src/solvepnp.cpp version 2.4.9)
+ which requires 2-channel information.
+ - Thus, given some data D = np.array(...) where D.shape = (N,M), in order to use a subset of
+ it as, e.g., imagePoints, one must effectively copy it into a new array: imagePoints =
+ np.ascontiguousarray(D[:,:2]).reshape((N,1,2))
+ - The methods **SOLVEPNP_DLS** and **SOLVEPNP_UPNP** cannot be used as the current implementations are
+ unstable and sometimes give completely wrong results. If you pass one of these two
+ flags, **SOLVEPNP_EPNP** method will be used instead.
+ - The minimum number of points is 4 in the general case. In the case of **SOLVEPNP_P3P** and **SOLVEPNP_AP3P**
+ methods, it is required to use exactly 4 points (the first 3 points are used to estimate all the solutions
+ of the P3P problem, the last one is used to retain the best solution that minimizes the reprojection error).
+ - With **SOLVEPNP_ITERATIVE** method and `useExtrinsicGuess=true`, the minimum number of points is 3 (3 points
+ are sufficient to compute a pose but there are up to 4 solutions). The initial solution should be close to the
+ global solution to converge.
+ - With **SOLVEPNP_IPPE** input points must be >= 4 and object points must be coplanar.
+ - With **SOLVEPNP_IPPE_SQUARE** this is a special case suitable for marker pose estimation.
+ Number of input points must be 4. Object points must be defined in the following order:
+ - point 0: [-squareLength / 2, squareLength / 2, 0]
+ - point 1: [ squareLength / 2, squareLength / 2, 0]
+ - point 2: [ squareLength / 2, -squareLength / 2, 0]
+ - point 3: [-squareLength / 2, -squareLength / 2, 0]
+ */
+CV_EXPORTS_W int solvePnPGeneric( InputArray objectPoints, InputArray imagePoints,
+ InputArray cameraMatrix, InputArray distCoeffs,
+ OutputArrayOfArrays rvecs, OutputArrayOfArrays tvecs,
+ bool useExtrinsicGuess = false, SolvePnPMethod flags = SOLVEPNP_ITERATIVE,
+ InputArray rvec = noArray(), InputArray tvec = noArray(),
+ OutputArray reprojectionError = noArray() );
+
/** @brief Finds an initial camera matrix from 3D-2D point correspondences.
@param objectPoints Vector of vectors of the calibration pattern points in the calibration pattern
@@ -635,14 +1392,14 @@ CV_EXPORTS_W Mat initCameraMatrix2D( InputArrayOfArrays objectPoints,
@param image Source chessboard view. It must be an 8-bit grayscale or color image.
@param patternSize Number of inner corners per a chessboard row and column
-( patternSize = cvSize(points_per_row,points_per_colum) = cvSize(columns,rows) ).
+( patternSize = cv::Size(points_per_row,points_per_colum) = cv::Size(columns,rows) ).
@param corners Output array of detected corners.
@param flags Various operation flags that can be zero or a combination of the following values:
-- **CV_CALIB_CB_ADAPTIVE_THRESH** Use adaptive thresholding to convert the image to black
+- **CALIB_CB_ADAPTIVE_THRESH** Use adaptive thresholding to convert the image to black
and white, rather than a fixed threshold level (computed from the average image brightness).
-- **CV_CALIB_CB_NORMALIZE_IMAGE** Normalize the image gamma with equalizeHist before
+- **CALIB_CB_NORMALIZE_IMAGE** Normalize the image gamma with equalizeHist before
applying fixed or adaptive thresholding.
-- **CV_CALIB_CB_FILTER_QUADS** Use additional criteria (like contour area, perimeter,
+- **CALIB_CB_FILTER_QUADS** Use additional criteria (like contour area, perimeter,
square-like shape) to filter out false quads extracted at the contour retrieval stage.
- **CALIB_CB_FAST_CHECK** Run a fast check on the image that looks for chessboard corners,
and shortcut the call if none is found. This can drastically speed up the call in the
@@ -671,7 +1428,7 @@ Sample usage of detecting and drawing chessboard corners: :
if(patternfound)
cornerSubPix(gray, corners, Size(11, 11), Size(-1, -1),
- TermCriteria(CV_TERMCRIT_EPS + CV_TERMCRIT_ITER, 30, 0.1));
+ TermCriteria(cv::TermCriteria::EPS + cv::TermCriteria::MAX_ITER, 30, 0.1));
drawChessboardCorners(img, patternsize, Mat(corners), patternfound);
@endcode
@@ -683,8 +1440,105 @@ square grouping and ordering algorithm fails.
CV_EXPORTS_W bool findChessboardCorners( InputArray image, Size patternSize, OutputArray corners,
int flags = CALIB_CB_ADAPTIVE_THRESH + CALIB_CB_NORMALIZE_IMAGE );
+/*
+ Checks whether the image contains chessboard of the specific size or not.
+ If yes, nonzero value is returned.
+*/
+CV_EXPORTS_W bool checkChessboard(InputArray img, Size size);
+
+/** @brief Finds the positions of internal corners of the chessboard using a sector based approach.
+
+@param image Source chessboard view. It must be an 8-bit grayscale or color image.
+@param patternSize Number of inner corners per a chessboard row and column
+( patternSize = cv::Size(points_per_row,points_per_colum) = cv::Size(columns,rows) ).
+@param corners Output array of detected corners.
+@param flags Various operation flags that can be zero or a combination of the following values:
+- **CALIB_CB_NORMALIZE_IMAGE** Normalize the image gamma with equalizeHist before detection.
+- **CALIB_CB_EXHAUSTIVE** Run an exhaustive search to improve detection rate.
+- **CALIB_CB_ACCURACY** Up sample input image to improve sub-pixel accuracy due to aliasing effects.
+- **CALIB_CB_LARGER** The detected pattern is allowed to be larger than patternSize (see description).
+- **CALIB_CB_MARKER** The detected pattern must have a marker (see description).
+This should be used if an accurate camera calibration is required.
+@param meta Optional output arrray of detected corners (CV_8UC1 and size = cv::Size(columns,rows)).
+Each entry stands for one corner of the pattern and can have one of the following values:
+- 0 = no meta data attached
+- 1 = left-top corner of a black cell
+- 2 = left-top corner of a white cell
+- 3 = left-top corner of a black cell with a white marker dot
+- 4 = left-top corner of a white cell with a black marker dot (pattern origin in case of markers otherwise first corner)
+
+The function is analog to findchessboardCorners but uses a localized radon
+transformation approximated by box filters being more robust to all sort of
+noise, faster on larger images and is able to directly return the sub-pixel
+position of the internal chessboard corners. The Method is based on the paper
+@cite duda2018 "Accurate Detection and Localization of Checkerboard Corners for
+Calibration" demonstrating that the returned sub-pixel positions are more
+accurate than the one returned by cornerSubPix allowing a precise camera
+calibration for demanding applications.
+
+In the case, the flags **CALIB_CB_LARGER** or **CALIB_CB_MARKER** are given,
+the result can be recovered from the optional meta array. Both flags are
+helpful to use calibration patterns exceeding the field of view of the camera.
+These oversized patterns allow more accurate calibrations as corners can be
+utilized, which are as close as possible to the image borders. For a
+consistent coordinate system across all images, the optional marker (see image
+below) can be used to move the origin of the board to the location where the
+black circle is located.
+
+@note The function requires a white boarder with roughly the same width as one
+of the checkerboard fields around the whole board to improve the detection in
+various environments. In addition, because of the localized radon
+transformation it is beneficial to use round corners for the field corners
+which are located on the outside of the board. The following figure illustrates
+a sample checkerboard optimized for the detection. However, any other checkerboard
+can be used as well.
+
+ */
+CV_EXPORTS_AS(findChessboardCornersSBWithMeta)
+bool findChessboardCornersSB(InputArray image,Size patternSize, OutputArray corners,
+ int flags,OutputArray meta);
+/** @overload */
+CV_EXPORTS_W inline
+bool findChessboardCornersSB(InputArray image, Size patternSize, OutputArray corners,
+ int flags = 0)
+{
+ return findChessboardCornersSB(image, patternSize, corners, flags, noArray());
+}
+
+/** @brief Estimates the sharpness of a detected chessboard.
+
+Image sharpness, as well as brightness, are a critical parameter for accuracte
+camera calibration. For accessing these parameters for filtering out
+problematic calibraiton images, this method calculates edge profiles by traveling from
+black to white chessboard cell centers. Based on this, the number of pixels is
+calculated required to transit from black to white. This width of the
+transition area is a good indication of how sharp the chessboard is imaged
+and should be below ~3.0 pixels.
+
+@param image Gray image used to find chessboard corners
+@param patternSize Size of a found chessboard pattern
+@param corners Corners found by findChessboardCorners(SB)
+@param rise_distance Rise distance 0.8 means 10% ... 90% of the final signal strength
+@param vertical By default edge responses for horizontal lines are calculated
+@param sharpness Optional output array with a sharpness value for calculated edge responses (see description)
+
+The optional sharpness array is of type CV_32FC1 and has for each calculated
+profile one row with the following five entries:
+* 0 = x coordinate of the underlying edge in the image
+* 1 = y coordinate of the underlying edge in the image
+* 2 = width of the transition area (sharpness)
+* 3 = signal strength in the black cell (min brightness)
+* 4 = signal strength in the white cell (max brightness)
+
+@return Scalar(average sharpness, average min brightness, average max brightness,0)
+*/
+CV_EXPORTS_W Scalar estimateChessboardSharpness(InputArray image, Size patternSize, InputArray corners,
+ float rise_distance=0.8F,bool vertical=false,
+ OutputArray sharpness=noArray());
+
+
//! finds subpixel-accurate positions of the chessboard corners
-CV_EXPORTS bool find4QuadCornerSubpix( InputArray img, InputOutputArray corners, Size region_size );
+CV_EXPORTS_W bool find4QuadCornerSubpix( InputArray img, InputOutputArray corners, Size region_size );
/** @brief Renders the detected chessboard corners.
@@ -701,6 +1555,57 @@ found, or as colored corners connected with lines if the board was found.
CV_EXPORTS_W void drawChessboardCorners( InputOutputArray image, Size patternSize,
InputArray corners, bool patternWasFound );
+/** @brief Draw axes of the world/object coordinate system from pose estimation. @sa solvePnP
+
+@param image Input/output image. It must have 1 or 3 channels. The number of channels is not altered.
+@param cameraMatrix Input 3x3 floating-point matrix of camera intrinsic parameters.
+\f$A = \vecthreethree{f_x}{0}{c_x}{0}{f_y}{c_y}{0}{0}{1}\f$
+@param distCoeffs Input vector of distortion coefficients
+\f$(k_1, k_2, p_1, p_2[, k_3[, k_4, k_5, k_6 [, s_1, s_2, s_3, s_4[, \tau_x, \tau_y]]]])\f$ of
+4, 5, 8, 12 or 14 elements. If the vector is empty, the zero distortion coefficients are assumed.
+@param rvec Rotation vector (see @ref Rodrigues ) that, together with tvec, brings points from
+the model coordinate system to the camera coordinate system.
+@param tvec Translation vector.
+@param length Length of the painted axes in the same unit than tvec (usually in meters).
+@param thickness Line thickness of the painted axes.
+
+This function draws the axes of the world/object coordinate system w.r.t. to the camera frame.
+OX is drawn in red, OY in green and OZ in blue.
+ */
+CV_EXPORTS_W void drawFrameAxes(InputOutputArray image, InputArray cameraMatrix, InputArray distCoeffs,
+ InputArray rvec, InputArray tvec, float length, int thickness=3);
+
+struct CV_EXPORTS_W_SIMPLE CirclesGridFinderParameters
+{
+ CV_WRAP CirclesGridFinderParameters();
+ CV_PROP_RW cv::Size2f densityNeighborhoodSize;
+ CV_PROP_RW float minDensity;
+ CV_PROP_RW int kmeansAttempts;
+ CV_PROP_RW int minDistanceToAddKeypoint;
+ CV_PROP_RW int keypointScale;
+ CV_PROP_RW float minGraphConfidence;
+ CV_PROP_RW float vertexGain;
+ CV_PROP_RW float vertexPenalty;
+ CV_PROP_RW float existingVertexGain;
+ CV_PROP_RW float edgeGain;
+ CV_PROP_RW float edgePenalty;
+ CV_PROP_RW float convexHullFactor;
+ CV_PROP_RW float minRNGEdgeSwitchDist;
+
+ enum GridType
+ {
+ SYMMETRIC_GRID, ASYMMETRIC_GRID
+ };
+ GridType gridType;
+
+ CV_PROP_RW float squareSize; //!< Distance between two adjacent points. Used by CALIB_CB_CLUSTERING.
+ CV_PROP_RW float maxRectifiedDistance; //!< Max deviation from prediction. Used by CALIB_CB_CLUSTERING.
+};
+
+#ifndef DISABLE_OPENCV_3_COMPATIBILITY
+typedef CirclesGridFinderParameters CirclesGridFinderParameters2;
+#endif
+
/** @brief Finds centers in the grid of circles.
@param image grid view of input circles; it must be an 8-bit grayscale or color image.
@@ -713,6 +1618,7 @@ CV_EXPORTS_W void drawChessboardCorners( InputOutputArray image, Size patternSiz
- **CALIB_CB_CLUSTERING** uses a special algorithm for grid detection. It is more robust to
perspective distortions but much more sensitive to background clutter.
@param blobDetector feature detector that finds blobs like dark circles on light background.
+@param parameters struct for finding circles in a grid pattern.
The function attempts to determine whether the input image contains a grid of circles. If it is, the
function locates centers of the circles. The function returns a non-zero value if all of the centers
@@ -732,60 +1638,78 @@ Sample usage of detecting and drawing the centers of circles: :
@note The function requires white space (like a square-thick border, the wider the better) around
the board to make the detection more robust in various environments.
*/
+CV_EXPORTS_W bool findCirclesGrid( InputArray image, Size patternSize,
+ OutputArray centers, int flags,
+ const Ptr &blobDetector,
+ const CirclesGridFinderParameters& parameters);
+
+/** @overload */
CV_EXPORTS_W bool findCirclesGrid( InputArray image, Size patternSize,
OutputArray centers, int flags = CALIB_CB_SYMMETRIC_GRID,
const Ptr &blobDetector = SimpleBlobDetector::create());
-/** @brief Finds the camera intrinsic and extrinsic parameters from several views of a calibration pattern.
+/** @brief Finds the camera intrinsic and extrinsic parameters from several views of a calibration
+pattern.
@param objectPoints In the new interface it is a vector of vectors of calibration pattern points in
the calibration pattern coordinate space (e.g. std::vector>). The outer
-vector contains as many elements as the number of the pattern views. If the same calibration pattern
+vector contains as many elements as the number of pattern views. If the same calibration pattern
is shown in each view and it is fully visible, all the vectors will be the same. Although, it is
-possible to use partially occluded patterns, or even different patterns in different views. Then,
-the vectors will be different. The points are 3D, but since they are in a pattern coordinate system,
-then, if the rig is planar, it may make sense to put the model to a XY coordinate plane so that
-Z-coordinate of each input object point is 0.
+possible to use partially occluded patterns or even different patterns in different views. Then,
+the vectors will be different. Although the points are 3D, they all lie in the calibration pattern's
+XY coordinate plane (thus 0 in the Z-coordinate), if the used calibration pattern is a planar rig.
In the old interface all the vectors of object points from different views are concatenated
together.
@param imagePoints In the new interface it is a vector of vectors of the projections of calibration
pattern points (e.g. std::vector>). imagePoints.size() and
-objectPoints.size() and imagePoints[i].size() must be equal to objectPoints[i].size() for each i.
-In the old interface all the vectors of object points from different views are concatenated
-together.
+objectPoints.size(), and imagePoints[i].size() and objectPoints[i].size() for each i, must be equal,
+respectively. In the old interface all the vectors of object points from different views are
+concatenated together.
@param imageSize Size of the image used only to initialize the intrinsic camera matrix.
-@param cameraMatrix Output 3x3 floating-point camera matrix
+@param cameraMatrix Input/output 3x3 floating-point camera matrix
\f$A = \vecthreethree{f_x}{0}{c_x}{0}{f_y}{c_y}{0}{0}{1}\f$ . If CV\_CALIB\_USE\_INTRINSIC\_GUESS
-and/or CV_CALIB_FIX_ASPECT_RATIO are specified, some or all of fx, fy, cx, cy must be
+and/or CALIB_FIX_ASPECT_RATIO are specified, some or all of fx, fy, cx, cy must be
initialized before calling the function.
-@param distCoeffs Output vector of distortion coefficients
+@param distCoeffs Input/output vector of distortion coefficients
\f$(k_1, k_2, p_1, p_2[, k_3[, k_4, k_5, k_6 [, s_1, s_2, s_3, s_4[, \tau_x, \tau_y]]]])\f$ of
4, 5, 8, 12 or 14 elements.
-@param rvecs Output vector of rotation vectors (see Rodrigues ) estimated for each pattern view
-(e.g. std::vector>). That is, each k-th rotation vector together with the corresponding
-k-th translation vector (see the next output parameter description) brings the calibration pattern
-from the model coordinate space (in which object points are specified) to the world coordinate
-space, that is, a real position of the calibration pattern in the k-th pattern view (k=0.. *M* -1).
-@param tvecs Output vector of translation vectors estimated for each pattern view.
+@param rvecs Output vector of rotation vectors (@ref Rodrigues ) estimated for each pattern view
+(e.g. std::vector>). That is, each i-th rotation vector together with the corresponding
+i-th translation vector (see the next output parameter description) brings the calibration pattern
+from the object coordinate space (in which object points are specified) to the camera coordinate
+space. In more technical terms, the tuple of the i-th rotation and translation vector performs
+a change of basis from object coordinate space to camera coordinate space. Due to its duality, this
+tuple is equivalent to the position of the calibration pattern with respect to the camera coordinate
+space.
+@param tvecs Output vector of translation vectors estimated for each pattern view, see parameter
+describtion above.
+@param stdDeviationsIntrinsics Output vector of standard deviations estimated for intrinsic
+parameters. Order of deviations values:
+\f$(f_x, f_y, c_x, c_y, k_1, k_2, p_1, p_2, k_3, k_4, k_5, k_6 , s_1, s_2, s_3,
+ s_4, \tau_x, \tau_y)\f$ If one of parameters is not estimated, it's deviation is equals to zero.
+@param stdDeviationsExtrinsics Output vector of standard deviations estimated for extrinsic
+parameters. Order of deviations values: \f$(R_0, T_0, \dotsc , R_{M - 1}, T_{M - 1})\f$ where M is
+the number of pattern views. \f$R_i, T_i\f$ are concatenated 1x3 vectors.
+ @param perViewErrors Output vector of the RMS re-projection error estimated for each pattern view.
@param flags Different flags that may be zero or a combination of the following values:
-- **CV_CALIB_USE_INTRINSIC_GUESS** cameraMatrix contains valid initial values of
+- **CALIB_USE_INTRINSIC_GUESS** cameraMatrix contains valid initial values of
fx, fy, cx, cy that are optimized further. Otherwise, (cx, cy) is initially set to the image
center ( imageSize is used), and focal distances are computed in a least-squares fashion.
Note, that if intrinsic parameters are known, there is no need to use this function just to
estimate extrinsic parameters. Use solvePnP instead.
-- **CV_CALIB_FIX_PRINCIPAL_POINT** The principal point is not changed during the global
+- **CALIB_FIX_PRINCIPAL_POINT** The principal point is not changed during the global
optimization. It stays at the center or at a different location specified when
-CV_CALIB_USE_INTRINSIC_GUESS is set too.
-- **CV_CALIB_FIX_ASPECT_RATIO** The functions considers only fy as a free parameter. The
+CALIB_USE_INTRINSIC_GUESS is set too.
+- **CALIB_FIX_ASPECT_RATIO** The functions consider only fy as a free parameter. The
ratio fx/fy stays the same as in the input cameraMatrix . When
-CV_CALIB_USE_INTRINSIC_GUESS is not set, the actual input values of fx and fy are
+CALIB_USE_INTRINSIC_GUESS is not set, the actual input values of fx and fy are
ignored, only their ratio is computed and used further.
-- **CV_CALIB_ZERO_TANGENT_DIST** Tangential distortion coefficients \f$(p_1, p_2)\f$ are set
+- **CALIB_ZERO_TANGENT_DIST** Tangential distortion coefficients \f$(p_1, p_2)\f$ are set
to zeros and stay zero.
-- **CV_CALIB_FIX_K1,...,CV_CALIB_FIX_K6** The corresponding radial distortion
-coefficient is not changed during the optimization. If CV_CALIB_USE_INTRINSIC_GUESS is
+- **CALIB_FIX_K1,...,CALIB_FIX_K6** The corresponding radial distortion
+coefficient is not changed during the optimization. If CALIB_USE_INTRINSIC_GUESS is
set, the coefficient from the supplied distCoeffs matrix is used. Otherwise, it is set to 0.
-- **CV_CALIB_RATIONAL_MODEL** Coefficients k4, k5, and k6 are enabled. To provide the
+- **CALIB_RATIONAL_MODEL** Coefficients k4, k5, and k6 are enabled. To provide the
backward compatibility, this extra flag should be explicitly specified to make the
calibration function use the rational model and return 8 coefficients. If the flag is not
set, the function computes and returns only 5 distortion coefficients.
@@ -794,24 +1718,26 @@ backward compatibility, this extra flag should be explicitly specified to make t
calibration function use the thin prism model and return 12 coefficients. If the flag is not
set, the function computes and returns only 5 distortion coefficients.
- **CALIB_FIX_S1_S2_S3_S4** The thin prism distortion coefficients are not changed during
-the optimization. If CV_CALIB_USE_INTRINSIC_GUESS is set, the coefficient from the
+the optimization. If CALIB_USE_INTRINSIC_GUESS is set, the coefficient from the
supplied distCoeffs matrix is used. Otherwise, it is set to 0.
- **CALIB_TILTED_MODEL** Coefficients tauX and tauY are enabled. To provide the
backward compatibility, this extra flag should be explicitly specified to make the
calibration function use the tilted sensor model and return 14 coefficients. If the flag is not
set, the function computes and returns only 5 distortion coefficients.
- **CALIB_FIX_TAUX_TAUY** The coefficients of the tilted sensor model are not changed during
-the optimization. If CV_CALIB_USE_INTRINSIC_GUESS is set, the coefficient from the
+the optimization. If CALIB_USE_INTRINSIC_GUESS is set, the coefficient from the
supplied distCoeffs matrix is used. Otherwise, it is set to 0.
@param criteria Termination criteria for the iterative optimization algorithm.
+@return the overall RMS re-projection error.
+
The function estimates the intrinsic camera parameters and extrinsic parameters for each of the
views. The algorithm is based on @cite Zhang2000 and @cite BouguetMCT . The coordinates of 3D object
points and their corresponding 2D projections in each view must be specified. That may be achieved
-by using an object with a known geometry and easily detectable feature points. Such an object is
+by using an object with known geometry and easily detectable feature points. Such an object is
called a calibration rig or calibration pattern, and OpenCV has built-in support for a chessboard as
-a calibration rig (see findChessboardCorners ). Currently, initialization of intrinsic parameters
-(when CV_CALIB_USE_INTRINSIC_GUESS is not set) is only implemented for planar calibration
+a calibration rig (see @ref findChessboardCorners). Currently, initialization of intrinsic
+parameters (when CALIB_USE_INTRINSIC_GUESS is not set) is only implemented for planar calibration
patterns (where Z-coordinates of the object points must be all zeros). 3D calibration rigs can also
be used as long as initial cameraMatrix is provided.
@@ -819,7 +1745,7 @@ The algorithm performs the following steps:
- Compute the initial intrinsic parameters (the option only available for planar calibration
patterns) or read them from the input parameters. The distortion coefficients are all set to
- zeros initially unless some of CV_CALIB_FIX_K? are specified.
+ zeros initially unless some of CALIB_FIX_K? are specified.
- Estimate the initial camera pose as if the intrinsic parameters have been already known. This is
done using solvePnP .
@@ -829,18 +1755,28 @@ The algorithm performs the following steps:
the projected (using the current estimates for camera parameters and the poses) object points
objectPoints. See projectPoints for details.
-The function returns the final re-projection error.
-
@note
- If you use a non-square (=non-NxN) grid and findChessboardCorners for calibration, and
- calibrateCamera returns bad values (zero distortion coefficients, an image center very far from
- (w/2-0.5,h/2-0.5), and/or large differences between \f$f_x\f$ and \f$f_y\f$ (ratios of 10:1 or more)),
- then you have probably used patternSize=cvSize(rows,cols) instead of using
- patternSize=cvSize(cols,rows) in findChessboardCorners .
+ If you use a non-square (i.e. non-N-by-N) grid and @ref findChessboardCorners for calibration,
+ and @ref calibrateCamera returns bad values (zero distortion coefficients, \f$c_x\f$ and
+ \f$c_y\f$ very far from the image center, and/or large differences between \f$f_x\f$ and
+ \f$f_y\f$ (ratios of 10:1 or more)), then you are probably using patternSize=cvSize(rows,cols)
+ instead of using patternSize=cvSize(cols,rows) in @ref findChessboardCorners.
@sa
- findChessboardCorners, solvePnP, initCameraMatrix2D, stereoCalibrate, undistort
+ calibrateCameraRO, findChessboardCorners, solvePnP, initCameraMatrix2D, stereoCalibrate,
+ undistort
*/
+CV_EXPORTS_AS(calibrateCameraExtended) double calibrateCamera( InputArrayOfArrays objectPoints,
+ InputArrayOfArrays imagePoints, Size imageSize,
+ InputOutputArray cameraMatrix, InputOutputArray distCoeffs,
+ OutputArrayOfArrays rvecs, OutputArrayOfArrays tvecs,
+ OutputArray stdDeviationsIntrinsics,
+ OutputArray stdDeviationsExtrinsics,
+ OutputArray perViewErrors,
+ int flags = 0, TermCriteria criteria = TermCriteria(
+ TermCriteria::COUNT + TermCriteria::EPS, 30, DBL_EPSILON) );
+
+/** @overload */
CV_EXPORTS_W double calibrateCamera( InputArrayOfArrays objectPoints,
InputArrayOfArrays imagePoints, Size imageSize,
InputOutputArray cameraMatrix, InputOutputArray distCoeffs,
@@ -848,6 +1784,84 @@ CV_EXPORTS_W double calibrateCamera( InputArrayOfArrays objectPoints,
int flags = 0, TermCriteria criteria = TermCriteria(
TermCriteria::COUNT + TermCriteria::EPS, 30, DBL_EPSILON) );
+/** @brief Finds the camera intrinsic and extrinsic parameters from several views of a calibration pattern.
+
+This function is an extension of calibrateCamera() with the method of releasing object which was
+proposed in @cite strobl2011iccv. In many common cases with inaccurate, unmeasured, roughly planar
+targets (calibration plates), this method can dramatically improve the precision of the estimated
+camera parameters. Both the object-releasing method and standard method are supported by this
+function. Use the parameter **iFixedPoint** for method selection. In the internal implementation,
+calibrateCamera() is a wrapper for this function.
+
+@param objectPoints Vector of vectors of calibration pattern points in the calibration pattern
+coordinate space. See calibrateCamera() for details. If the method of releasing object to be used,
+the identical calibration board must be used in each view and it must be fully visible, and all
+objectPoints[i] must be the same and all points should be roughly close to a plane. **The calibration
+target has to be rigid, or at least static if the camera (rather than the calibration target) is
+shifted for grabbing images.**
+@param imagePoints Vector of vectors of the projections of calibration pattern points. See
+calibrateCamera() for details.
+@param imageSize Size of the image used only to initialize the intrinsic camera matrix.
+@param iFixedPoint The index of the 3D object point in objectPoints[0] to be fixed. It also acts as
+a switch for calibration method selection. If object-releasing method to be used, pass in the
+parameter in the range of [1, objectPoints[0].size()-2], otherwise a value out of this range will
+make standard calibration method selected. Usually the top-right corner point of the calibration
+board grid is recommended to be fixed when object-releasing method being utilized. According to
+\cite strobl2011iccv, two other points are also fixed. In this implementation, objectPoints[0].front
+and objectPoints[0].back.z are used. With object-releasing method, accurate rvecs, tvecs and
+newObjPoints are only possible if coordinates of these three fixed points are accurate enough.
+@param cameraMatrix Output 3x3 floating-point camera matrix. See calibrateCamera() for details.
+@param distCoeffs Output vector of distortion coefficients. See calibrateCamera() for details.
+@param rvecs Output vector of rotation vectors estimated for each pattern view. See calibrateCamera()
+for details.
+@param tvecs Output vector of translation vectors estimated for each pattern view.
+@param newObjPoints The updated output vector of calibration pattern points. The coordinates might
+be scaled based on three fixed points. The returned coordinates are accurate only if the above
+mentioned three fixed points are accurate. If not needed, noArray() can be passed in. This parameter
+is ignored with standard calibration method.
+@param stdDeviationsIntrinsics Output vector of standard deviations estimated for intrinsic parameters.
+See calibrateCamera() for details.
+@param stdDeviationsExtrinsics Output vector of standard deviations estimated for extrinsic parameters.
+See calibrateCamera() for details.
+@param stdDeviationsObjPoints Output vector of standard deviations estimated for refined coordinates
+of calibration pattern points. It has the same size and order as objectPoints[0] vector. This
+parameter is ignored with standard calibration method.
+ @param perViewErrors Output vector of the RMS re-projection error estimated for each pattern view.
+@param flags Different flags that may be zero or a combination of some predefined values. See
+calibrateCamera() for details. If the method of releasing object is used, the calibration time may
+be much longer. CALIB_USE_QR or CALIB_USE_LU could be used for faster calibration with potentially
+less precise and less stable in some rare cases.
+@param criteria Termination criteria for the iterative optimization algorithm.
+
+@return the overall RMS re-projection error.
+
+The function estimates the intrinsic camera parameters and extrinsic parameters for each of the
+views. The algorithm is based on @cite Zhang2000, @cite BouguetMCT and @cite strobl2011iccv. See
+calibrateCamera() for other detailed explanations.
+@sa
+ calibrateCamera, findChessboardCorners, solvePnP, initCameraMatrix2D, stereoCalibrate, undistort
+ */
+CV_EXPORTS_AS(calibrateCameraROExtended) double calibrateCameraRO( InputArrayOfArrays objectPoints,
+ InputArrayOfArrays imagePoints, Size imageSize, int iFixedPoint,
+ InputOutputArray cameraMatrix, InputOutputArray distCoeffs,
+ OutputArrayOfArrays rvecs, OutputArrayOfArrays tvecs,
+ OutputArray newObjPoints,
+ OutputArray stdDeviationsIntrinsics,
+ OutputArray stdDeviationsExtrinsics,
+ OutputArray stdDeviationsObjPoints,
+ OutputArray perViewErrors,
+ int flags = 0, TermCriteria criteria = TermCriteria(
+ TermCriteria::COUNT + TermCriteria::EPS, 30, DBL_EPSILON) );
+
+/** @overload */
+CV_EXPORTS_W double calibrateCameraRO( InputArrayOfArrays objectPoints,
+ InputArrayOfArrays imagePoints, Size imageSize, int iFixedPoint,
+ InputOutputArray cameraMatrix, InputOutputArray distCoeffs,
+ OutputArrayOfArrays rvecs, OutputArrayOfArrays tvecs,
+ OutputArray newObjPoints,
+ int flags = 0, TermCriteria criteria = TermCriteria(
+ TermCriteria::COUNT + TermCriteria::EPS, 30, DBL_EPSILON) );
+
/** @brief Computes useful camera characteristics from the camera matrix.
@param cameraMatrix Input camera matrix that can be estimated by calibrateCamera or
@@ -874,45 +1888,55 @@ CV_EXPORTS_W void calibrationMatrixValues( InputArray cameraMatrix, Size imageSi
CV_OUT double& focalLength, CV_OUT Point2d& principalPoint,
CV_OUT double& aspectRatio );
-/** @brief Calibrates the stereo camera.
+/** @brief Calibrates a stereo camera set up. This function finds the intrinsic parameters
+for each of the two cameras and the extrinsic parameters between the two cameras.
-@param objectPoints Vector of vectors of the calibration pattern points.
+@param objectPoints Vector of vectors of the calibration pattern points. The same structure as
+in @ref calibrateCamera. For each pattern view, both cameras need to see the same object
+points. Therefore, objectPoints.size(), imagePoints1.size(), and imagePoints2.size() need to be
+equal as well as objectPoints[i].size(), imagePoints1[i].size(), and imagePoints2[i].size() need to
+be equal for each i.
@param imagePoints1 Vector of vectors of the projections of the calibration pattern points,
-observed by the first camera.
+observed by the first camera. The same structure as in @ref calibrateCamera.
@param imagePoints2 Vector of vectors of the projections of the calibration pattern points,
-observed by the second camera.
-@param cameraMatrix1 Input/output first camera matrix:
-\f$\vecthreethree{f_x^{(j)}}{0}{c_x^{(j)}}{0}{f_y^{(j)}}{c_y^{(j)}}{0}{0}{1}\f$ , \f$j = 0,\, 1\f$ . If
-any of CV_CALIB_USE_INTRINSIC_GUESS , CV_CALIB_FIX_ASPECT_RATIO ,
-CV_CALIB_FIX_INTRINSIC , or CV_CALIB_FIX_FOCAL_LENGTH are specified, some or all of the
-matrix components must be initialized. See the flags description for details.
-@param distCoeffs1 Input/output vector of distortion coefficients
-\f$(k_1, k_2, p_1, p_2[, k_3[, k_4, k_5, k_6 [, s_1, s_2, s_3, s_4[, \tau_x, \tau_y]]]])\f$ of
-4, 5, 8, 12 or 14 elements. The output vector length depends on the flags.
-@param cameraMatrix2 Input/output second camera matrix. The parameter is similar to cameraMatrix1
-@param distCoeffs2 Input/output lens distortion coefficients for the second camera. The parameter
-is similar to distCoeffs1 .
-@param imageSize Size of the image used only to initialize intrinsic camera matrix.
-@param R Output rotation matrix between the 1st and the 2nd camera coordinate systems.
-@param T Output translation vector between the coordinate systems of the cameras.
+observed by the second camera. The same structure as in @ref calibrateCamera.
+@param cameraMatrix1 Input/output camera matrix for the first camera, the same as in
+@ref calibrateCamera. Furthermore, for the stereo case, additional flags may be used, see below.
+@param distCoeffs1 Input/output vector of distortion coefficients, the same as in
+@ref calibrateCamera.
+@param cameraMatrix2 Input/output second camera matrix for the second camera. See description for
+cameraMatrix1.
+@param distCoeffs2 Input/output lens distortion coefficients for the second camera. See
+description for distCoeffs1.
+@param imageSize Size of the image used only to initialize the intrinsic camera matrices.
+@param R Output rotation matrix. Together with the translation vector T, this matrix brings
+points given in the first camera's coordinate system to points in the second camera's
+coordinate system. In more technical terms, the tuple of R and T performs a change of basis
+from the first camera's coordinate system to the second camera's coordinate system. Due to its
+duality, this tuple is equivalent to the position of the first camera with respect to the
+second camera coordinate system.
+@param T Output translation vector, see description above.
@param E Output essential matrix.
@param F Output fundamental matrix.
+@param perViewErrors Output vector of the RMS re-projection error estimated for each pattern view.
@param flags Different flags that may be zero or a combination of the following values:
-- **CV_CALIB_FIX_INTRINSIC** Fix cameraMatrix? and distCoeffs? so that only R, T, E , and F
+- **CALIB_FIX_INTRINSIC** Fix cameraMatrix? and distCoeffs? so that only R, T, E, and F
matrices are estimated.
-- **CV_CALIB_USE_INTRINSIC_GUESS** Optimize some or all of the intrinsic parameters
+- **CALIB_USE_INTRINSIC_GUESS** Optimize some or all of the intrinsic parameters
according to the specified flags. Initial values are provided by the user.
-- **CV_CALIB_FIX_PRINCIPAL_POINT** Fix the principal points during the optimization.
-- **CV_CALIB_FIX_FOCAL_LENGTH** Fix \f$f^{(j)}_x\f$ and \f$f^{(j)}_y\f$ .
-- **CV_CALIB_FIX_ASPECT_RATIO** Optimize \f$f^{(j)}_y\f$ . Fix the ratio \f$f^{(j)}_x/f^{(j)}_y\f$
+- **CALIB_USE_EXTRINSIC_GUESS** R and T contain valid initial values that are optimized further.
+Otherwise R and T are initialized to the median value of the pattern views (each dimension separately).
+- **CALIB_FIX_PRINCIPAL_POINT** Fix the principal points during the optimization.
+- **CALIB_FIX_FOCAL_LENGTH** Fix \f$f^{(j)}_x\f$ and \f$f^{(j)}_y\f$ .
+- **CALIB_FIX_ASPECT_RATIO** Optimize \f$f^{(j)}_y\f$ . Fix the ratio \f$f^{(j)}_x/f^{(j)}_y\f$
.
-- **CV_CALIB_SAME_FOCAL_LENGTH** Enforce \f$f^{(0)}_x=f^{(1)}_x\f$ and \f$f^{(0)}_y=f^{(1)}_y\f$ .
-- **CV_CALIB_ZERO_TANGENT_DIST** Set tangential distortion coefficients for each camera to
+- **CALIB_SAME_FOCAL_LENGTH** Enforce \f$f^{(0)}_x=f^{(1)}_x\f$ and \f$f^{(0)}_y=f^{(1)}_y\f$ .
+- **CALIB_ZERO_TANGENT_DIST** Set tangential distortion coefficients for each camera to
zeros and fix there.
-- **CV_CALIB_FIX_K1,...,CV_CALIB_FIX_K6** Do not change the corresponding radial
-distortion coefficient during the optimization. If CV_CALIB_USE_INTRINSIC_GUESS is set,
+- **CALIB_FIX_K1,...,CALIB_FIX_K6** Do not change the corresponding radial
+distortion coefficient during the optimization. If CALIB_USE_INTRINSIC_GUESS is set,
the coefficient from the supplied distCoeffs matrix is used. Otherwise, it is set to 0.
-- **CV_CALIB_RATIONAL_MODEL** Enable coefficients k4, k5, and k6. To provide the backward
+- **CALIB_RATIONAL_MODEL** Enable coefficients k4, k5, and k6. To provide the backward
compatibility, this extra flag should be explicitly specified to make the calibration
function use the rational model and return 8 coefficients. If the flag is not set, the
function computes and returns only 5 distortion coefficients.
@@ -921,51 +1945,80 @@ backward compatibility, this extra flag should be explicitly specified to make t
calibration function use the thin prism model and return 12 coefficients. If the flag is not
set, the function computes and returns only 5 distortion coefficients.
- **CALIB_FIX_S1_S2_S3_S4** The thin prism distortion coefficients are not changed during
-the optimization. If CV_CALIB_USE_INTRINSIC_GUESS is set, the coefficient from the
+the optimization. If CALIB_USE_INTRINSIC_GUESS is set, the coefficient from the
supplied distCoeffs matrix is used. Otherwise, it is set to 0.
- **CALIB_TILTED_MODEL** Coefficients tauX and tauY are enabled. To provide the
backward compatibility, this extra flag should be explicitly specified to make the
calibration function use the tilted sensor model and return 14 coefficients. If the flag is not
set, the function computes and returns only 5 distortion coefficients.
- **CALIB_FIX_TAUX_TAUY** The coefficients of the tilted sensor model are not changed during
-the optimization. If CV_CALIB_USE_INTRINSIC_GUESS is set, the coefficient from the
+the optimization. If CALIB_USE_INTRINSIC_GUESS is set, the coefficient from the
supplied distCoeffs matrix is used. Otherwise, it is set to 0.
@param criteria Termination criteria for the iterative optimization algorithm.
-The function estimates transformation between two cameras making a stereo pair. If you have a stereo
-camera where the relative position and orientation of two cameras is fixed, and if you computed
-poses of an object relative to the first camera and to the second camera, (R1, T1) and (R2, T2),
-respectively (this can be done with solvePnP ), then those poses definitely relate to each other.
-This means that, given ( \f$R_1\f$,\f$T_1\f$ ), it should be possible to compute ( \f$R_2\f$,\f$T_2\f$ ). You only
-need to know the position and orientation of the second camera relative to the first camera. This is
-what the described function does. It computes ( \f$R\f$,\f$T\f$ ) so that:
+The function estimates the transformation between two cameras making a stereo pair. If one computes
+the poses of an object relative to the first camera and to the second camera,
+( \f$R_1\f$,\f$T_1\f$ ) and (\f$R_2\f$,\f$T_2\f$), respectively, for a stereo camera where the
+relative position and orientation between the two cameras are fixed, then those poses definitely
+relate to each other. This means, if the relative position and orientation (\f$R\f$,\f$T\f$) of the
+two cameras is known, it is possible to compute (\f$R_2\f$,\f$T_2\f$) when (\f$R_1\f$,\f$T_1\f$) is
+given. This is what the described function does. It computes (\f$R\f$,\f$T\f$) such that:
+
+\f[R_2=R R_1\f]
+\f[T_2=R T_1 + T.\f]
+
+Therefore, one can compute the coordinate representation of a 3D point for the second camera's
+coordinate system when given the point's coordinate representation in the first camera's coordinate
+system:
+
+\f[\begin{bmatrix}
+X_2 \\
+Y_2 \\
+Z_2 \\
+1
+\end{bmatrix} = \begin{bmatrix}
+R & T \\
+0 & 1
+\end{bmatrix} \begin{bmatrix}
+X_1 \\
+Y_1 \\
+Z_1 \\
+1
+\end{bmatrix}.\f]
-\f[R_2=R*R_1
-T_2=R*T_1 + T,\f]
Optionally, it computes the essential matrix E:
-\f[E= \vecthreethree{0}{-T_2}{T_1}{T_2}{0}{-T_0}{-T_1}{T_0}{0} *R\f]
+\f[E= \vecthreethree{0}{-T_2}{T_1}{T_2}{0}{-T_0}{-T_1}{T_0}{0} R\f]
-where \f$T_i\f$ are components of the translation vector \f$T\f$ : \f$T=[T_0, T_1, T_2]^T\f$ . And the function
-can also compute the fundamental matrix F:
+where \f$T_i\f$ are components of the translation vector \f$T\f$ : \f$T=[T_0, T_1, T_2]^T\f$ .
+And the function can also compute the fundamental matrix F:
\f[F = cameraMatrix2^{-T} E cameraMatrix1^{-1}\f]
Besides the stereo-related information, the function can also perform a full calibration of each of
-two cameras. However, due to the high dimensionality of the parameter space and noise in the input
-data, the function can diverge from the correct solution. If the intrinsic parameters can be
+the two cameras. However, due to the high dimensionality of the parameter space and noise in the
+input data, the function can diverge from the correct solution. If the intrinsic parameters can be
estimated with high accuracy for each of the cameras individually (for example, using
-calibrateCamera ), you are recommended to do so and then pass CV_CALIB_FIX_INTRINSIC flag to the
+calibrateCamera ), you are recommended to do so and then pass CALIB_FIX_INTRINSIC flag to the
function along with the computed intrinsic parameters. Otherwise, if all the parameters are
estimated at once, it makes sense to restrict some parameters, for example, pass
-CV_CALIB_SAME_FOCAL_LENGTH and CV_CALIB_ZERO_TANGENT_DIST flags, which is usually a
+CALIB_SAME_FOCAL_LENGTH and CALIB_ZERO_TANGENT_DIST flags, which is usually a
reasonable assumption.
-Similarly to calibrateCamera , the function minimizes the total re-projection error for all the
+Similarly to calibrateCamera, the function minimizes the total re-projection error for all the
points in all the available views from both cameras. The function returns the final value of the
re-projection error.
*/
+CV_EXPORTS_AS(stereoCalibrateExtended) double stereoCalibrate( InputArrayOfArrays objectPoints,
+ InputArrayOfArrays imagePoints1, InputArrayOfArrays imagePoints2,
+ InputOutputArray cameraMatrix1, InputOutputArray distCoeffs1,
+ InputOutputArray cameraMatrix2, InputOutputArray distCoeffs2,
+ Size imageSize, InputOutputArray R,InputOutputArray T, OutputArray E, OutputArray F,
+ OutputArray perViewErrors, int flags = CALIB_FIX_INTRINSIC,
+ TermCriteria criteria = TermCriteria(TermCriteria::COUNT+TermCriteria::EPS, 30, 1e-6) );
+
+/// @overload
CV_EXPORTS_W double stereoCalibrate( InputArrayOfArrays objectPoints,
InputArrayOfArrays imagePoints1, InputArrayOfArrays imagePoints2,
InputOutputArray cameraMatrix1, InputOutputArray distCoeffs1,
@@ -974,7 +2027,6 @@ CV_EXPORTS_W double stereoCalibrate( InputArrayOfArrays objectPoints,
int flags = CALIB_FIX_INTRINSIC,
TermCriteria criteria = TermCriteria(TermCriteria::COUNT+TermCriteria::EPS, 30, 1e-6) );
-
/** @brief Computes rectification transforms for each head of a calibrated stereo camera.
@param cameraMatrix1 First camera matrix.
@@ -982,16 +2034,26 @@ CV_EXPORTS_W double stereoCalibrate( InputArrayOfArrays objectPoints,
@param cameraMatrix2 Second camera matrix.
@param distCoeffs2 Second camera distortion parameters.
@param imageSize Size of the image used for stereo calibration.
-@param R Rotation matrix between the coordinate systems of the first and the second cameras.
-@param T Translation vector between coordinate systems of the cameras.
-@param R1 Output 3x3 rectification transform (rotation matrix) for the first camera.
-@param R2 Output 3x3 rectification transform (rotation matrix) for the second camera.
+@param R Rotation matrix from the coordinate system of the first camera to the second camera,
+see @ref stereoCalibrate.
+@param T Translation vector from the coordinate system of the first camera to the second camera,
+see @ref stereoCalibrate.
+@param R1 Output 3x3 rectification transform (rotation matrix) for the first camera. This matrix
+brings points given in the unrectified first camera's coordinate system to points in the rectified
+first camera's coordinate system. In more technical terms, it performs a change of basis from the
+unrectified first camera's coordinate system to the rectified first camera's coordinate system.
+@param R2 Output 3x3 rectification transform (rotation matrix) for the second camera. This matrix
+brings points given in the unrectified second camera's coordinate system to points in the rectified
+second camera's coordinate system. In more technical terms, it performs a change of basis from the
+unrectified second camera's coordinate system to the rectified second camera's coordinate system.
@param P1 Output 3x4 projection matrix in the new (rectified) coordinate systems for the first
-camera.
+camera, i.e. it projects points given in the rectified first camera coordinate system into the
+rectified first camera's image.
@param P2 Output 3x4 projection matrix in the new (rectified) coordinate systems for the second
-camera.
-@param Q Output \f$4 \times 4\f$ disparity-to-depth mapping matrix (see reprojectImageTo3D ).
-@param flags Operation flags that may be zero or CV_CALIB_ZERO_DISPARITY . If the flag is set,
+camera, i.e. it projects points given in the rectified first camera coordinate system into the
+rectified second camera's image.
+@param Q Output \f$4 \times 4\f$ disparity-to-depth mapping matrix (see @ref reprojectImageTo3D).
+@param flags Operation flags that may be zero or CALIB_ZERO_DISPARITY . If the flag is set,
the function makes the principal points of each camera have the same pixel coordinates in the
rectified views. And if the flag is not set, the function may still shift the images in the
horizontal or vertical direction (depending on the orientation of epipolar lines) to maximize the
@@ -1001,11 +2063,11 @@ scaling. Otherwise, the parameter should be between 0 and 1. alpha=0 means that
images are zoomed and shifted so that only valid pixels are visible (no black areas after
rectification). alpha=1 means that the rectified image is decimated and shifted so that all the
pixels from the original images from the cameras are retained in the rectified images (no source
-image pixels are lost). Obviously, any intermediate value yields an intermediate result between
+image pixels are lost). Any intermediate value yields an intermediate result between
those two extreme cases.
@param newImageSize New image resolution after rectification. The same size should be passed to
initUndistortRectifyMap (see the stereo_calib.cpp sample in OpenCV samples directory). When (0,0)
-is passed (default), it is set to the original imageSize . Setting it to larger value can help you
+is passed (default), it is set to the original imageSize . Setting it to a larger value can help you
preserve details in the original image, especially when there is a big radial distortion.
@param validPixROI1 Optional output rectangles inside the rectified images where all the pixels
are valid. If alpha=0 , the ROIs cover the whole images. Otherwise, they are likely to be smaller
@@ -1021,27 +2083,43 @@ as input. As output, it provides two rotation matrices and also two projection m
coordinates. The function distinguishes the following two cases:
- **Horizontal stereo**: the first and the second camera views are shifted relative to each other
- mainly along the x axis (with possible small vertical shift). In the rectified images, the
+ mainly along the x-axis (with possible small vertical shift). In the rectified images, the
corresponding epipolar lines in the left and right cameras are horizontal and have the same
y-coordinate. P1 and P2 look like:
- \f[\texttt{P1} = \begin{bmatrix} f & 0 & cx_1 & 0 \\ 0 & f & cy & 0 \\ 0 & 0 & 1 & 0 \end{bmatrix}\f]
+ \f[\texttt{P1} = \begin{bmatrix}
+ f & 0 & cx_1 & 0 \\
+ 0 & f & cy & 0 \\
+ 0 & 0 & 1 & 0
+ \end{bmatrix}\f]
- \f[\texttt{P2} = \begin{bmatrix} f & 0 & cx_2 & T_x*f \\ 0 & f & cy & 0 \\ 0 & 0 & 1 & 0 \end{bmatrix} ,\f]
+ \f[\texttt{P2} = \begin{bmatrix}
+ f & 0 & cx_2 & T_x*f \\
+ 0 & f & cy & 0 \\
+ 0 & 0 & 1 & 0
+ \end{bmatrix} ,\f]
where \f$T_x\f$ is a horizontal shift between the cameras and \f$cx_1=cx_2\f$ if
- CV_CALIB_ZERO_DISPARITY is set.
+ CALIB_ZERO_DISPARITY is set.
- **Vertical stereo**: the first and the second camera views are shifted relative to each other
- mainly in vertical direction (and probably a bit in the horizontal direction too). The epipolar
+ mainly in the vertical direction (and probably a bit in the horizontal direction too). The epipolar
lines in the rectified images are vertical and have the same x-coordinate. P1 and P2 look like:
- \f[\texttt{P1} = \begin{bmatrix} f & 0 & cx & 0 \\ 0 & f & cy_1 & 0 \\ 0 & 0 & 1 & 0 \end{bmatrix}\f]
+ \f[\texttt{P1} = \begin{bmatrix}
+ f & 0 & cx & 0 \\
+ 0 & f & cy_1 & 0 \\
+ 0 & 0 & 1 & 0
+ \end{bmatrix}\f]
- \f[\texttt{P2} = \begin{bmatrix} f & 0 & cx & 0 \\ 0 & f & cy_2 & T_y*f \\ 0 & 0 & 1 & 0 \end{bmatrix} ,\f]
+ \f[\texttt{P2} = \begin{bmatrix}
+ f & 0 & cx & 0 \\
+ 0 & f & cy_2 & T_y*f \\
+ 0 & 0 & 1 & 0
+ \end{bmatrix},\f]
- where \f$T_y\f$ is a vertical shift between the cameras and \f$cy_1=cy_2\f$ if CALIB_ZERO_DISPARITY is
- set.
+ where \f$T_y\f$ is a vertical shift between the cameras and \f$cy_1=cy_2\f$ if
+ CALIB_ZERO_DISPARITY is set.
As you can see, the first three columns of P1 and P2 will effectively be the new "rectified" camera
matrices. The matrices, together with R1 and R2 , can then be passed to initUndistortRectifyMap to
@@ -1076,7 +2154,7 @@ findFundamentalMat .
@param threshold Optional threshold used to filter out the outliers. If the parameter is greater
than zero, all the point pairs that do not comply with the epipolar geometry (that is, the points
for which \f$|\texttt{points2[i]}^T*\texttt{F}*\texttt{points1[i]}|>\texttt{threshold}\f$ ) are
-rejected prior to computing the homographies. Otherwise,all the points are considered inliers.
+rejected prior to computing the homographies. Otherwise, all the points are considered inliers.
The function computes the rectification transformations without knowing intrinsic parameters of the
cameras and their relative position in the space, which explains the suffix "uncalibrated". Another
@@ -1120,7 +2198,7 @@ assumed.
@param alpha Free scaling parameter between 0 (when all the pixels in the undistorted image are
valid) and 1 (when all the source image pixels are retained in the undistorted image). See
stereoRectify for details.
-@param newImgSize Image size after rectification. By default,it is set to imageSize .
+@param newImgSize Image size after rectification. By default, it is set to imageSize .
@param validPixROI Optional output rectangle that outlines all-good-pixels region in the
undistorted image. See roi1, roi2 description in stereoRectify .
@param centerPrincipalPoint Optional flag that indicates whether in the new camera matrix the
@@ -1131,7 +2209,7 @@ best fit a subset of the source image (determined by alpha) to the corrected ima
The function computes and returns the optimal new camera matrix based on the free scaling parameter.
By varying this parameter, you may retrieve only sensible pixels alpha=0 , keep all the original
image pixels if there is valuable information in the corners alpha=1 , or get something in between.
-When alpha\>0 , the undistortion result is likely to have some black pixels corresponding to
+When alpha\>0 , the undistorted result is likely to have some black pixels corresponding to
"virtual" pixels outside of the captured distorted image. The original camera matrix, distortion
coefficients, the computed new camera matrix, and newImageSize should be passed to
initUndistortRectifyMap to produce the maps for remap .
@@ -1141,6 +2219,139 @@ CV_EXPORTS_W Mat getOptimalNewCameraMatrix( InputArray cameraMatrix, InputArray
CV_OUT Rect* validPixROI = 0,
bool centerPrincipalPoint = false);
+/** @brief Computes Hand-Eye calibration: \f$_{}^{g}\textrm{T}_c\f$
+
+@param[in] R_gripper2base Rotation part extracted from the homogeneous matrix that transforms a point
+expressed in the gripper frame to the robot base frame (\f$_{}^{b}\textrm{T}_g\f$).
+This is a vector (`vector`) that contains the rotation matrices for all the transformations
+from gripper frame to robot base frame.
+@param[in] t_gripper2base Translation part extracted from the homogeneous matrix that transforms a point
+expressed in the gripper frame to the robot base frame (\f$_{}^{b}\textrm{T}_g\f$).
+This is a vector (`vector`) that contains the translation vectors for all the transformations
+from gripper frame to robot base frame.
+@param[in] R_target2cam Rotation part extracted from the homogeneous matrix that transforms a point
+expressed in the target frame to the camera frame (\f$_{}^{c}\textrm{T}_t\f$).
+This is a vector (`vector`) that contains the rotation matrices for all the transformations
+from calibration target frame to camera frame.
+@param[in] t_target2cam Rotation part extracted from the homogeneous matrix that transforms a point
+expressed in the target frame to the camera frame (\f$_{}^{c}\textrm{T}_t\f$).
+This is a vector (`vector`) that contains the translation vectors for all the transformations
+from calibration target frame to camera frame.
+@param[out] R_cam2gripper Estimated rotation part extracted from the homogeneous matrix that transforms a point
+expressed in the camera frame to the gripper frame (\f$_{}^{g}\textrm{T}_c\f$).
+@param[out] t_cam2gripper Estimated translation part extracted from the homogeneous matrix that transforms a point
+expressed in the camera frame to the gripper frame (\f$_{}^{g}\textrm{T}_c\f$).
+@param[in] method One of the implemented Hand-Eye calibration method, see cv::HandEyeCalibrationMethod
+
+The function performs the Hand-Eye calibration using various methods. One approach consists in estimating the
+rotation then the translation (separable solutions) and the following methods are implemented:
+ - R. Tsai, R. Lenz A New Technique for Fully Autonomous and Efficient 3D Robotics Hand/EyeCalibration \cite Tsai89
+ - F. Park, B. Martin Robot Sensor Calibration: Solving AX = XB on the Euclidean Group \cite Park94
+ - R. Horaud, F. Dornaika Hand-Eye Calibration \cite Horaud95
+
+Another approach consists in estimating simultaneously the rotation and the translation (simultaneous solutions),
+with the following implemented method:
+ - N. Andreff, R. Horaud, B. Espiau On-line Hand-Eye Calibration \cite Andreff99
+ - K. Daniilidis Hand-Eye Calibration Using Dual Quaternions \cite Daniilidis98
+
+The following picture describes the Hand-Eye calibration problem where the transformation between a camera ("eye")
+mounted on a robot gripper ("hand") has to be estimated.
+
+
+
+The calibration procedure is the following:
+ - a static calibration pattern is used to estimate the transformation between the target frame
+ and the camera frame
+ - the robot gripper is moved in order to acquire several poses
+ - for each pose, the homogeneous transformation between the gripper frame and the robot base frame is recorded using for
+ instance the robot kinematics
+\f[
+ \begin{bmatrix}
+ X_b\\
+ Y_b\\
+ Z_b\\
+ 1
+ \end{bmatrix}
+ =
+ \begin{bmatrix}
+ _{}^{b}\textrm{R}_g & _{}^{b}\textrm{t}_g \\
+ 0_{1 \times 3} & 1
+ \end{bmatrix}
+ \begin{bmatrix}
+ X_g\\
+ Y_g\\
+ Z_g\\
+ 1
+ \end{bmatrix}
+\f]
+ - for each pose, the homogeneous transformation between the calibration target frame and the camera frame is recorded using
+ for instance a pose estimation method (PnP) from 2D-3D point correspondences
+\f[
+ \begin{bmatrix}
+ X_c\\
+ Y_c\\
+ Z_c\\
+ 1
+ \end{bmatrix}
+ =
+ \begin{bmatrix}
+ _{}^{c}\textrm{R}_t & _{}^{c}\textrm{t}_t \\
+ 0_{1 \times 3} & 1
+ \end{bmatrix}
+ \begin{bmatrix}
+ X_t\\
+ Y_t\\
+ Z_t\\
+ 1
+ \end{bmatrix}
+\f]
+
+The Hand-Eye calibration procedure returns the following homogeneous transformation
+\f[
+ \begin{bmatrix}
+ X_g\\
+ Y_g\\
+ Z_g\\
+ 1
+ \end{bmatrix}
+ =
+ \begin{bmatrix}
+ _{}^{g}\textrm{R}_c & _{}^{g}\textrm{t}_c \\
+ 0_{1 \times 3} & 1
+ \end{bmatrix}
+ \begin{bmatrix}
+ X_c\\
+ Y_c\\
+ Z_c\\
+ 1
+ \end{bmatrix}
+\f]
+
+This problem is also known as solving the \f$\mathbf{A}\mathbf{X}=\mathbf{X}\mathbf{B}\f$ equation:
+\f[
+ \begin{align*}
+ ^{b}{\textrm{T}_g}^{(1)} \hspace{0.2em} ^{g}\textrm{T}_c \hspace{0.2em} ^{c}{\textrm{T}_t}^{(1)} &=
+ \hspace{0.1em} ^{b}{\textrm{T}_g}^{(2)} \hspace{0.2em} ^{g}\textrm{T}_c \hspace{0.2em} ^{c}{\textrm{T}_t}^{(2)} \\
+
+ (^{b}{\textrm{T}_g}^{(2)})^{-1} \hspace{0.2em} ^{b}{\textrm{T}_g}^{(1)} \hspace{0.2em} ^{g}\textrm{T}_c &=
+ \hspace{0.1em} ^{g}\textrm{T}_c \hspace{0.2em} ^{c}{\textrm{T}_t}^{(2)} (^{c}{\textrm{T}_t}^{(1)})^{-1} \\
+
+ \textrm{A}_i \textrm{X} &= \textrm{X} \textrm{B}_i \\
+ \end{align*}
+\f]
+
+\note
+Additional information can be found on this [website](http://campar.in.tum.de/Chair/HandEyeCalibration).
+\note
+A minimum of 2 motions with non parallel rotation axes are necessary to determine the hand-eye transformation.
+So at least 3 different poses are required, but it is strongly recommended to use many more poses.
+
+ */
+CV_EXPORTS_W void calibrateHandEye( InputArrayOfArrays R_gripper2base, InputArrayOfArrays t_gripper2base,
+ InputArrayOfArrays R_target2cam, InputArrayOfArrays t_target2cam,
+ OutputArray R_cam2gripper, OutputArray t_cam2gripper,
+ HandEyeCalibrationMethod method=CALIB_HAND_EYE_TSAI );
+
/** @brief Converts points from Euclidean to homogeneous space.
@param src Input vector of N-dimensional points.
@@ -1184,13 +2395,14 @@ floating-point (single or double precision).
- **CV_FM_8POINT** for an 8-point algorithm. \f$N \ge 8\f$
- **CV_FM_RANSAC** for the RANSAC algorithm. \f$N \ge 8\f$
- **CV_FM_LMEDS** for the LMedS algorithm. \f$N \ge 8\f$
-@param param1 Parameter used for RANSAC. It is the maximum distance from a point to an epipolar
+@param ransacReprojThreshold Parameter used only for RANSAC. It is the maximum distance from a point to an epipolar
line in pixels, beyond which the point is considered an outlier and is not used for computing the
final fundamental matrix. It can be set to something like 1-3, depending on the accuracy of the
point localization, image resolution, and the image noise.
-@param param2 Parameter used for the RANSAC or LMedS methods only. It specifies a desirable level
+@param confidence Parameter used for the RANSAC and LMedS methods only. It specifies a desirable level
of confidence (probability) that the estimated matrix is correct.
@param mask
+@param maxIters The maximum number of robust method iterations.
The epipolar geometry is described by the following equation:
@@ -1224,15 +2436,20 @@ stereoRectifyUncalibrated to compute the rectification transformation. :
findFundamentalMat(points1, points2, FM_RANSAC, 3, 0.99);
@endcode
*/
+CV_EXPORTS_W Mat findFundamentalMat( InputArray points1, InputArray points2,
+ int method, double ransacReprojThreshold, double confidence,
+ int maxIters, OutputArray mask = noArray() );
+
+/** @overload */
CV_EXPORTS_W Mat findFundamentalMat( InputArray points1, InputArray points2,
int method = FM_RANSAC,
- double param1 = 3., double param2 = 0.99,
+ double ransacReprojThreshold = 3., double confidence = 0.99,
OutputArray mask = noArray() );
/** @overload */
CV_EXPORTS Mat findFundamentalMat( InputArray points1, InputArray points2,
OutputArray mask, int method = FM_RANSAC,
- double param1 = 3., double param2 = 0.99 );
+ double ransacReprojThreshold = 3., double confidence = 0.99 );
/** @brief Calculates an essential matrix from the corresponding points in two images.
@@ -1242,9 +2459,9 @@ be floating-point (single or double precision).
@param cameraMatrix Camera matrix \f$K = \vecthreethree{f_x}{0}{c_x}{0}{f_y}{c_y}{0}{0}{1}\f$ .
Note that this function assumes that points1 and points2 are feature points from cameras with the
same camera matrix.
-@param method Method for computing a fundamental matrix.
+@param method Method for computing an essential matrix.
- **RANSAC** for the RANSAC algorithm.
-- **MEDS** for the LMedS algorithm.
+- **LMEDS** for the LMedS algorithm.
@param prob Parameter used for the RANSAC or LMedS methods only. It specifies a desirable level of
confidence (probability) that the estimated matrix is correct.
@param threshold Parameter used for RANSAC. It is the maximum distance from a point to an epipolar
@@ -1273,8 +2490,8 @@ CV_EXPORTS_W Mat findEssentialMat( InputArray points1, InputArray points2,
be floating-point (single or double precision).
@param points2 Array of the second image points of the same size and format as points1 .
@param focal focal length of the camera. Note that this function assumes that points1 and points2
-are feature points from cameras with same focal length and principle point.
-@param pp principle point of the camera.
+are feature points from cameras with same focal length and principal point.
+@param pp principal point of the camera.
@param method Method for computing a fundamental matrix.
- **RANSAC** for the RANSAC algorithm.
- **LMEDS** for the LMedS algorithm.
@@ -1309,35 +2526,47 @@ CV_EXPORTS_W Mat findEssentialMat( InputArray points1, InputArray points2,
@param R2 Another possible rotation matrix.
@param t One possible translation.
-This function decompose an essential matrix E using svd decomposition @cite HartleyZ00 . Generally 4
-possible poses exists for a given E. They are \f$[R_1, t]\f$, \f$[R_1, -t]\f$, \f$[R_2, t]\f$, \f$[R_2, -t]\f$. By
-decomposing E, you can only get the direction of the translation, so the function returns unit t.
+This function decomposes the essential matrix E using svd decomposition @cite HartleyZ00. In
+general, four possible poses exist for the decomposition of E. They are \f$[R_1, t]\f$,
+\f$[R_1, -t]\f$, \f$[R_2, t]\f$, \f$[R_2, -t]\f$.
+
+If E gives the epipolar constraint \f$[p_2; 1]^T A^{-T} E A^{-1} [p_1; 1] = 0\f$ between the image
+points \f$p_1\f$ in the first image and \f$p_2\f$ in second image, then any of the tuples
+\f$[R_1, t]\f$, \f$[R_1, -t]\f$, \f$[R_2, t]\f$, \f$[R_2, -t]\f$ is a change of basis from the first
+camera's coordinate system to the second camera's coordinate system. However, by decomposing E, one
+can only get the direction of the translation. For this reason, the translation t is returned with
+unit length.
*/
CV_EXPORTS_W void decomposeEssentialMat( InputArray E, OutputArray R1, OutputArray R2, OutputArray t );
-/** @brief Recover relative camera rotation and translation from an estimated essential matrix and the
-corresponding points in two images, using cheirality check. Returns the number of inliers which pass
-the check.
+/** @brief Recovers the relative camera rotation and the translation from an estimated essential
+matrix and the corresponding points in two images, using cheirality check. Returns the number of
+inliers that pass the check.
@param E The input essential matrix.
@param points1 Array of N 2D points from the first image. The point coordinates should be
floating-point (single or double precision).
@param points2 Array of the second image points of the same size and format as points1 .
-@param cameraMatrix Camera matrix \f$K = \vecthreethree{f_x}{0}{c_x}{0}{f_y}{c_y}{0}{0}{1}\f$ .
+@param cameraMatrix Camera matrix \f$A = \vecthreethree{f_x}{0}{c_x}{0}{f_y}{c_y}{0}{0}{1}\f$ .
Note that this function assumes that points1 and points2 are feature points from cameras with the
same camera matrix.
-@param R Recovered relative rotation.
-@param t Recoverd relative translation.
-@param mask Input/output mask for inliers in points1 and points2.
-: If it is not empty, then it marks inliers in points1 and points2 for then given essential
-matrix E. Only these inliers will be used to recover pose. In the output mask only inliers
-which pass the cheirality check.
-This function decomposes an essential matrix using decomposeEssentialMat and then verifies possible
-pose hypotheses by doing cheirality check. The cheirality check basically means that the
-triangulated 3D points should have positive depth. Some details can be found in @cite Nister03 .
-
-This function can be used to process output E and mask from findEssentialMat. In this scenario,
-points1 and points2 are the same input for findEssentialMat. :
+@param R Output rotation matrix. Together with the translation vector, this matrix makes up a tuple
+that performs a change of basis from the first camera's coordinate system to the second camera's
+coordinate system. Note that, in general, t can not be used for this tuple, see the parameter
+described below.
+@param t Output translation vector. This vector is obtained by @ref decomposeEssentialMat and
+therefore is only known up to scale, i.e. t is the direction of the translation vector and has unit
+length.
+@param mask Input/output mask for inliers in points1 and points2. If it is not empty, then it marks
+inliers in points1 and points2 for then given essential matrix E. Only these inliers will be used to
+recover pose. In the output mask only inliers which pass the cheirality check.
+
+This function decomposes an essential matrix using @ref decomposeEssentialMat and then verifies
+possible pose hypotheses by doing cheirality check. The cheirality check means that the
+triangulated 3D points should have positive depth. Some details can be found in @cite Nister03.
+
+This function can be used to process the output E and mask from @ref findEssentialMat. In this
+scenario, points1 and points2 are the same input for findEssentialMat.:
@code
// Example. Estimation of fundamental matrix using the RANSAC algorithm
int point_count = 100;
@@ -1369,20 +2598,24 @@ CV_EXPORTS_W int recoverPose( InputArray E, InputArray points1, InputArray point
@param points1 Array of N 2D points from the first image. The point coordinates should be
floating-point (single or double precision).
@param points2 Array of the second image points of the same size and format as points1 .
-@param R Recovered relative rotation.
-@param t Recoverd relative translation.
+@param R Output rotation matrix. Together with the translation vector, this matrix makes up a tuple
+that performs a change of basis from the first camera's coordinate system to the second camera's
+coordinate system. Note that, in general, t can not be used for this tuple, see the parameter
+description below.
+@param t Output translation vector. This vector is obtained by @ref decomposeEssentialMat and
+therefore is only known up to scale, i.e. t is the direction of the translation vector and has unit
+length.
@param focal Focal length of the camera. Note that this function assumes that points1 and points2
-are feature points from cameras with same focal length and principle point.
-@param pp Principle point of the camera.
-@param mask Input/output mask for inliers in points1 and points2.
-: If it is not empty, then it marks inliers in points1 and points2 for then given essential
-matrix E. Only these inliers will be used to recover pose. In the output mask only inliers
-which pass the cheirality check.
+are feature points from cameras with same focal length and principal point.
+@param pp principal point of the camera.
+@param mask Input/output mask for inliers in points1 and points2. If it is not empty, then it marks
+inliers in points1 and points2 for then given essential matrix E. Only these inliers will be used to
+recover pose. In the output mask only inliers which pass the cheirality check.
This function differs from the one above that it computes camera matrix from focal length and
principal point:
-\f[K =
+\f[A =
\begin{bmatrix}
f & 0 & x_{pp} \\
0 & f & y_{pp} \\
@@ -1394,6 +2627,35 @@ CV_EXPORTS_W int recoverPose( InputArray E, InputArray points1, InputArray point
double focal = 1.0, Point2d pp = Point2d(0, 0),
InputOutputArray mask = noArray() );
+/** @overload
+@param E The input essential matrix.
+@param points1 Array of N 2D points from the first image. The point coordinates should be
+floating-point (single or double precision).
+@param points2 Array of the second image points of the same size and format as points1.
+@param cameraMatrix Camera matrix \f$A = \vecthreethree{f_x}{0}{c_x}{0}{f_y}{c_y}{0}{0}{1}\f$ .
+Note that this function assumes that points1 and points2 are feature points from cameras with the
+same camera matrix.
+@param R Output rotation matrix. Together with the translation vector, this matrix makes up a tuple
+that performs a change of basis from the first camera's coordinate system to the second camera's
+coordinate system. Note that, in general, t can not be used for this tuple, see the parameter
+description below.
+@param t Output translation vector. This vector is obtained by @ref decomposeEssentialMat and
+therefore is only known up to scale, i.e. t is the direction of the translation vector and has unit
+length.
+@param distanceThresh threshold distance which is used to filter out far away points (i.e. infinite
+points).
+@param mask Input/output mask for inliers in points1 and points2. If it is not empty, then it marks
+inliers in points1 and points2 for then given essential matrix E. Only these inliers will be used to
+recover pose. In the output mask only inliers which pass the cheirality check.
+@param triangulatedPoints 3D points which were reconstructed by triangulation.
+
+This function differs from the one above that it outputs the triangulated 3D point that are used for
+the cheirality check.
+ */
+CV_EXPORTS_W int recoverPose( InputArray E, InputArray points1, InputArray points2,
+ InputArray cameraMatrix, OutputArray R, OutputArray t, double distanceThresh, InputOutputArray mask = noArray(),
+ OutputArray triangulatedPoints = noArray());
+
/** @brief For points in an image of a stereo pair, computes the corresponding epilines in the other image.
@param points Input points. \f$N \times 1\f$ or \f$1 \times N\f$ matrix of type CV_32FC2 or
@@ -1420,22 +2682,27 @@ Line coefficients are defined up to a scale. They are normalized so that \f$a_i^
CV_EXPORTS_W void computeCorrespondEpilines( InputArray points, int whichImage,
InputArray F, OutputArray lines );
-/** @brief Reconstructs points by triangulation.
+/** @brief This function reconstructs 3-dimensional points (in homogeneous coordinates) by using
+their observations with a stereo camera.
-@param projMatr1 3x4 projection matrix of the first camera.
-@param projMatr2 3x4 projection matrix of the second camera.
-@param projPoints1 2xN array of feature points in the first image. In case of c++ version it can
-be also a vector of feature points or two-channel matrix of size 1xN or Nx1.
-@param projPoints2 2xN array of corresponding points in the second image. In case of c++ version
+@param projMatr1 3x4 projection matrix of the first camera, i.e. this matrix projects 3D points
+given in the world's coordinate system into the first image.
+@param projMatr2 3x4 projection matrix of the second camera, i.e. this matrix projects 3D points
+given in the world's coordinate system into the second image.
+@param projPoints1 2xN array of feature points in the first image. In the case of the c++ version,
it can be also a vector of feature points or two-channel matrix of size 1xN or Nx1.
-@param points4D 4xN array of reconstructed points in homogeneous coordinates.
-
-The function reconstructs 3-dimensional points (in homogeneous coordinates) by using their
-observations with a stereo camera. Projections matrices can be obtained from stereoRectify.
+@param projPoints2 2xN array of corresponding points in the second image. In the case of the c++
+version, it can be also a vector of feature points or two-channel matrix of size 1xN or Nx1.
+@param points4D 4xN array of reconstructed points in homogeneous coordinates. These points are
+returned in the world's coordinate system.
@note
Keep in mind that all input data should be of float type in order for this function to work.
+@note
+ If the projection matrices from @ref stereoRectify are used, then the returned points are
+ represented in the first camera's rectified coordinate system.
+
@sa
reprojectImageTo3D
*/
@@ -1480,7 +2747,7 @@ CV_EXPORTS_W void filterSpeckles( InputOutputArray img, double newVal,
//! computes valid disparity ROI from the valid ROIs of the rectified images (that are returned by cv::stereoRectify())
CV_EXPORTS_W Rect getValidDisparityROI( Rect roi1, Rect roi2,
int minDisparity, int numberOfDisparities,
- int SADWindowSize );
+ int blockSize );
//! validates disparity using the left-right check. The matrix "cost" should be computed by the stereo correspondence algorithm
CV_EXPORTS_W void validateDisparity( InputOutputArray disparity, InputArray cost,
@@ -1490,12 +2757,16 @@ CV_EXPORTS_W void validateDisparity( InputOutputArray disparity, InputArray cost
/** @brief Reprojects a disparity image to 3D space.
@param disparity Input single-channel 8-bit unsigned, 16-bit signed, 32-bit signed or 32-bit
-floating-point disparity image. If 16-bit signed format is used, the values are assumed to have no
-fractional bits.
-@param _3dImage Output 3-channel floating-point image of the same size as disparity . Each
-element of _3dImage(x,y) contains 3D coordinates of the point (x,y) computed from the disparity
-map.
-@param Q \f$4 \times 4\f$ perspective transformation matrix that can be obtained with stereoRectify.
+floating-point disparity image. The values of 8-bit / 16-bit signed formats are assumed to have no
+fractional bits. If the disparity is 16-bit signed format, as computed by @ref StereoBM or
+@ref StereoSGBM and maybe other algorithms, it should be divided by 16 (and scaled to float) before
+being used here.
+@param _3dImage Output 3-channel floating-point image of the same size as disparity. Each element of
+_3dImage(x,y) contains 3D coordinates of the point (x,y) computed from the disparity map. If one
+uses Q obtained by @ref stereoRectify, then the returned points are represented in the first
+camera's rectified coordinate system.
+@param Q \f$4 \times 4\f$ perspective transformation matrix that can be obtained with
+@ref stereoRectify.
@param handleMissingValues Indicates, whether the function should handle missing values (i.e.
points where the disparity was not computed). If handleMissingValues=true, then pixels with the
minimal disparity that corresponds to the outliers (see StereoMatcher::compute ) are transformed
@@ -1504,14 +2775,23 @@ to 3D points with a very large Z value (currently set to 10000).
depth. ddepth can also be set to CV_16S, CV_32S or CV_32F.
The function transforms a single-channel disparity map to a 3-channel image representing a 3D
-surface. That is, for each pixel (x,y) andthe corresponding disparity d=disparity(x,y) , it
+surface. That is, for each pixel (x,y) and the corresponding disparity d=disparity(x,y) , it
computes:
-\f[\begin{array}{l} [X \; Y \; Z \; W]^T = \texttt{Q} *[x \; y \; \texttt{disparity} (x,y) \; 1]^T \\ \texttt{\_3dImage} (x,y) = (X/W, \; Y/W, \; Z/W) \end{array}\f]
+\f[\begin{bmatrix}
+X \\
+Y \\
+Z \\
+W
+\end{bmatrix} = Q \begin{bmatrix}
+x \\
+y \\
+\texttt{disparity} (x,y) \\
+z
+\end{bmatrix}.\f]
-The matrix Q can be an arbitrary \f$4 \times 4\f$ matrix (for example, the one computed by
-stereoRectify). To reproject a sparse set of points {(x,y,d),...} to 3D space, use
-perspectiveTransform .
+@sa
+ To reproject a sparse set of points {(x,y,d),...} to 3D space, use perspectiveTransform.
*/
CV_EXPORTS_W void reprojectImageTo3D( InputArray disparity,
OutputArray _3dImage, InputArray Q,
@@ -1520,21 +2800,62 @@ CV_EXPORTS_W void reprojectImageTo3D( InputArray disparity,
/** @brief Calculates the Sampson Distance between two points.
-The function sampsonDistance calculates and returns the first order approximation of the geometric error as:
-\f[sd( \texttt{pt1} , \texttt{pt2} )= \frac{(\texttt{pt2}^t \cdot \texttt{F} \cdot \texttt{pt1})^2}{(\texttt{F} \cdot \texttt{pt1})(0) + (\texttt{F} \cdot \texttt{pt1})(1) + (\texttt{F}^t \cdot \texttt{pt2})(0) + (\texttt{F}^t \cdot \texttt{pt2})(1)}\f]
-The fundamental matrix may be calculated using the cv::findFundamentalMat function. See HZ 11.4.3 for details.
+The function cv::sampsonDistance calculates and returns the first order approximation of the geometric error as:
+\f[
+sd( \texttt{pt1} , \texttt{pt2} )=
+\frac{(\texttt{pt2}^t \cdot \texttt{F} \cdot \texttt{pt1})^2}
+{((\texttt{F} \cdot \texttt{pt1})(0))^2 +
+((\texttt{F} \cdot \texttt{pt1})(1))^2 +
+((\texttt{F}^t \cdot \texttt{pt2})(0))^2 +
+((\texttt{F}^t \cdot \texttt{pt2})(1))^2}
+\f]
+The fundamental matrix may be calculated using the cv::findFundamentalMat function. See @cite HartleyZ00 11.4.3 for details.
@param pt1 first homogeneous 2d point
@param pt2 second homogeneous 2d point
@param F fundamental matrix
+@return The computed Sampson distance.
*/
CV_EXPORTS_W double sampsonDistance(InputArray pt1, InputArray pt2, InputArray F);
/** @brief Computes an optimal affine transformation between two 3D point sets.
-@param src First input 3D point set.
-@param dst Second input 3D point set.
-@param out Output 3D affine transformation matrix \f$3 \times 4\f$ .
-@param inliers Output vector indicating which points are inliers.
+It computes
+\f[
+\begin{bmatrix}
+x\\
+y\\
+z\\
+\end{bmatrix}
+=
+\begin{bmatrix}
+a_{11} & a_{12} & a_{13}\\
+a_{21} & a_{22} & a_{23}\\
+a_{31} & a_{32} & a_{33}\\
+\end{bmatrix}
+\begin{bmatrix}
+X\\
+Y\\
+Z\\
+\end{bmatrix}
++
+\begin{bmatrix}
+b_1\\
+b_2\\
+b_3\\
+\end{bmatrix}
+\f]
+
+@param src First input 3D point set containing \f$(X,Y,Z)\f$.
+@param dst Second input 3D point set containing \f$(x,y,z)\f$.
+@param out Output 3D affine transformation matrix \f$3 \times 4\f$ of the form
+\f[
+\begin{bmatrix}
+a_{11} & a_{12} & a_{13} & b_1\\
+a_{21} & a_{22} & a_{23} & b_2\\
+a_{31} & a_{32} & a_{33} & b_3\\
+\end{bmatrix}
+\f]
+@param inliers Output vector indicating which points are inliers (1-inlier, 0-outlier).
@param ransacThreshold Maximum reprojection error in the RANSAC algorithm to consider a point as
an inlier.
@param confidence Confidence level, between 0 and 1, for the estimated transformation. Anything
@@ -1548,6 +2869,174 @@ CV_EXPORTS_W int estimateAffine3D(InputArray src, InputArray dst,
OutputArray out, OutputArray inliers,
double ransacThreshold = 3, double confidence = 0.99);
+/** @brief Computes an optimal translation between two 3D point sets.
+ *
+ * It computes
+ * \f[
+ * \begin{bmatrix}
+ * x\\
+ * y\\
+ * z\\
+ * \end{bmatrix}
+ * =
+ * \begin{bmatrix}
+ * X\\
+ * Y\\
+ * Z\\
+ * \end{bmatrix}
+ * +
+ * \begin{bmatrix}
+ * b_1\\
+ * b_2\\
+ * b_3\\
+ * \end{bmatrix}
+ * \f]
+ *
+ * @param src First input 3D point set containing \f$(X,Y,Z)\f$.
+ * @param dst Second input 3D point set containing \f$(x,y,z)\f$.
+ * @param out Output 3D translation vector \f$3 \times 1\f$ of the form
+ * \f[
+ * \begin{bmatrix}
+ * b_1 \\
+ * b_2 \\
+ * b_3 \\
+ * \end{bmatrix}
+ * \f]
+ * @param inliers Output vector indicating which points are inliers (1-inlier, 0-outlier).
+ * @param ransacThreshold Maximum reprojection error in the RANSAC algorithm to consider a point as
+ * an inlier.
+ * @param confidence Confidence level, between 0 and 1, for the estimated transformation. Anything
+ * between 0.95 and 0.99 is usually good enough. Values too close to 1 can slow down the estimation
+ * significantly. Values lower than 0.8-0.9 can result in an incorrectly estimated transformation.
+ *
+ * The function estimates an optimal 3D translation between two 3D point sets using the
+ * RANSAC algorithm.
+ * */
+CV_EXPORTS_W int estimateTranslation3D(InputArray src, InputArray dst,
+ OutputArray out, OutputArray inliers,
+ double ransacThreshold = 3, double confidence = 0.99);
+
+/** @brief Computes an optimal affine transformation between two 2D point sets.
+
+It computes
+\f[
+\begin{bmatrix}
+x\\
+y\\
+\end{bmatrix}
+=
+\begin{bmatrix}
+a_{11} & a_{12}\\
+a_{21} & a_{22}\\
+\end{bmatrix}
+\begin{bmatrix}
+X\\
+Y\\
+\end{bmatrix}
++
+\begin{bmatrix}
+b_1\\
+b_2\\
+\end{bmatrix}
+\f]
+
+@param from First input 2D point set containing \f$(X,Y)\f$.
+@param to Second input 2D point set containing \f$(x,y)\f$.
+@param inliers Output vector indicating which points are inliers (1-inlier, 0-outlier).
+@param method Robust method used to compute transformation. The following methods are possible:
+- cv::RANSAC - RANSAC-based robust method
+- cv::LMEDS - Least-Median robust method
+RANSAC is the default method.
+@param ransacReprojThreshold Maximum reprojection error in the RANSAC algorithm to consider
+a point as an inlier. Applies only to RANSAC.
+@param maxIters The maximum number of robust method iterations.
+@param confidence Confidence level, between 0 and 1, for the estimated transformation. Anything
+between 0.95 and 0.99 is usually good enough. Values too close to 1 can slow down the estimation
+significantly. Values lower than 0.8-0.9 can result in an incorrectly estimated transformation.
+@param refineIters Maximum number of iterations of refining algorithm (Levenberg-Marquardt).
+Passing 0 will disable refining, so the output matrix will be output of robust method.
+
+@return Output 2D affine transformation matrix \f$2 \times 3\f$ or empty matrix if transformation
+could not be estimated. The returned matrix has the following form:
+\f[
+\begin{bmatrix}
+a_{11} & a_{12} & b_1\\
+a_{21} & a_{22} & b_2\\
+\end{bmatrix}
+\f]
+
+The function estimates an optimal 2D affine transformation between two 2D point sets using the
+selected robust algorithm.
+
+The computed transformation is then refined further (using only inliers) with the
+Levenberg-Marquardt method to reduce the re-projection error even more.
+
+@note
+The RANSAC method can handle practically any ratio of outliers but needs a threshold to
+distinguish inliers from outliers. The method LMeDS does not need any threshold but it works
+correctly only when there are more than 50% of inliers.
+
+@sa estimateAffinePartial2D, getAffineTransform
+*/
+CV_EXPORTS_W cv::Mat estimateAffine2D(InputArray from, InputArray to, OutputArray inliers = noArray(),
+ int method = RANSAC, double ransacReprojThreshold = 3,
+ size_t maxIters = 2000, double confidence = 0.99,
+ size_t refineIters = 10);
+
+/** @brief Computes an optimal limited affine transformation with 4 degrees of freedom between
+two 2D point sets.
+
+@param from First input 2D point set.
+@param to Second input 2D point set.
+@param inliers Output vector indicating which points are inliers.
+@param method Robust method used to compute transformation. The following methods are possible:
+- cv::RANSAC - RANSAC-based robust method
+- cv::LMEDS - Least-Median robust method
+RANSAC is the default method.
+@param ransacReprojThreshold Maximum reprojection error in the RANSAC algorithm to consider
+a point as an inlier. Applies only to RANSAC.
+@param maxIters The maximum number of robust method iterations.
+@param confidence Confidence level, between 0 and 1, for the estimated transformation. Anything
+between 0.95 and 0.99 is usually good enough. Values too close to 1 can slow down the estimation
+significantly. Values lower than 0.8-0.9 can result in an incorrectly estimated transformation.
+@param refineIters Maximum number of iterations of refining algorithm (Levenberg-Marquardt).
+Passing 0 will disable refining, so the output matrix will be output of robust method.
+
+@return Output 2D affine transformation (4 degrees of freedom) matrix \f$2 \times 3\f$ or
+empty matrix if transformation could not be estimated.
+
+The function estimates an optimal 2D affine transformation with 4 degrees of freedom limited to
+combinations of translation, rotation, and uniform scaling. Uses the selected algorithm for robust
+estimation.
+
+The computed transformation is then refined further (using only inliers) with the
+Levenberg-Marquardt method to reduce the re-projection error even more.
+
+Estimated transformation matrix is:
+\f[ \begin{bmatrix} \cos(\theta) \cdot s & -\sin(\theta) \cdot s & t_x \\
+ \sin(\theta) \cdot s & \cos(\theta) \cdot s & t_y
+\end{bmatrix} \f]
+Where \f$ \theta \f$ is the rotation angle, \f$ s \f$ the scaling factor and \f$ t_x, t_y \f$ are
+translations in \f$ x, y \f$ axes respectively.
+
+@note
+The RANSAC method can handle practically any ratio of outliers but need a threshold to
+distinguish inliers from outliers. The method LMeDS does not need any threshold but it works
+correctly only when there are more than 50% of inliers.
+
+@sa estimateAffine2D, getAffineTransform
+*/
+CV_EXPORTS_W cv::Mat estimateAffinePartial2D(InputArray from, InputArray to, OutputArray inliers = noArray(),
+ int method = RANSAC, double ransacReprojThreshold = 3,
+ size_t maxIters = 2000, double confidence = 0.99,
+ size_t refineIters = 10);
+
+/** @example samples/cpp/tutorial_code/features2D/Homography/decompose_homography.cpp
+An example program with homography decomposition.
+
+Check @ref tutorial_homography "the corresponding tutorial" for more details.
+*/
+
/** @brief Decompose a homography matrix to rotation(s), translation(s) and plane normal(s).
@param H The input homography matrix between two images.
@@ -1556,11 +3045,19 @@ CV_EXPORTS_W int estimateAffine3D(InputArray src, InputArray dst,
@param translations Array of translation matrices.
@param normals Array of plane normal matrices.
-This function extracts relative camera motion between two views observing a planar object from the
-homography H induced by the plane. The intrinsic camera matrix K must also be provided. The function
-may return up to four mathematical solution sets. At least two of the solutions may further be
-invalidated if point correspondences are available by applying positive depth constraint (all points
-must be in front of the camera). The decomposition method is described in detail in @cite Malis .
+This function extracts relative camera motion between two views of a planar object and returns up to
+four mathematical solution tuples of rotation, translation, and plane normal. The decomposition of
+the homography matrix H is described in detail in @cite Malis.
+
+If the homography H, induced by the plane, gives the constraint
+\f[s_i \vecthree{x'_i}{y'_i}{1} \sim H \vecthree{x_i}{y_i}{1}\f] on the source image points
+\f$p_i\f$ and the destination image points \f$p'_i\f$, then the tuple of rotations[k] and
+translations[k] is a change of basis from the source camera's coordinate system to the destination
+camera's coordinate system. However, by decomposing H, one can only get the translation normalized
+by the (typically unknown) depth of the scene, i.e. its direction but with normalized length.
+
+If point correspondences are available, at least two solutions may further be invalidated, by
+applying positive depth constraint, i.e. all points must be in front of the camera.
*/
CV_EXPORTS_W int decomposeHomographyMat(InputArray H,
InputArray K,
@@ -1568,6 +3065,31 @@ CV_EXPORTS_W int decomposeHomographyMat(InputArray H,
OutputArrayOfArrays translations,
OutputArrayOfArrays normals);
+/** @brief Filters homography decompositions based on additional information.
+
+@param rotations Vector of rotation matrices.
+@param normals Vector of plane normal matrices.
+@param beforePoints Vector of (rectified) visible reference points before the homography is applied
+@param afterPoints Vector of (rectified) visible reference points after the homography is applied
+@param possibleSolutions Vector of int indices representing the viable solution set after filtering
+@param pointsMask optional Mat/Vector of 8u type representing the mask for the inliers as given by the findHomography function
+
+This function is intended to filter the output of the decomposeHomographyMat based on additional
+information as described in @cite Malis . The summary of the method: the decomposeHomographyMat function
+returns 2 unique solutions and their "opposites" for a total of 4 solutions. If we have access to the
+sets of points visible in the camera frame before and after the homography transformation is applied,
+we can determine which are the true potential solutions and which are the opposites by verifying which
+homographies are consistent with all visible reference points being in front of the camera. The inputs
+are left unchanged; the filtered solution set is returned as indices into the existing one.
+
+*/
+CV_EXPORTS_W void filterHomographyDecompByVisibleRefpoints(InputArrayOfArrays rotations,
+ InputArrayOfArrays normals,
+ InputArray beforePoints,
+ InputArray afterPoints,
+ OutputArray possibleSolutions,
+ InputArray pointsMask = noArray());
+
/** @brief The base class for stereo correspondence algorithms.
*/
class CV_EXPORTS_W StereoMatcher : public Algorithm
@@ -1683,7 +3205,8 @@ class CV_EXPORTS_W StereoSGBM : public StereoMatcher
{
MODE_SGBM = 0,
MODE_HH = 1,
- MODE_SGBM_3WAY = 2
+ MODE_SGBM_3WAY = 2,
+ MODE_HH4 = 3
};
CV_WRAP virtual int getPreFilterCap() const = 0;
@@ -1714,8 +3237,8 @@ class CV_EXPORTS_W StereoSGBM : public StereoMatcher
the smoother the disparity is. P1 is the penalty on the disparity change by plus or minus 1
between neighbor pixels. P2 is the penalty on the disparity change by more than 1 between neighbor
pixels. The algorithm requires P2 \> P1 . See stereo_match.cpp sample where some reasonably good
- P1 and P2 values are shown (like 8\*number_of_image_channels\*SADWindowSize\*SADWindowSize and
- 32\*number_of_image_channels\*SADWindowSize\*SADWindowSize , respectively).
+ P1 and P2 values are shown (like 8\*number_of_image_channels\*blockSize\*blockSize and
+ 32\*number_of_image_channels\*blockSize\*blockSize , respectively).
@param disp12MaxDiff Maximum allowed difference (in integer pixel units) in the left-right
disparity check. Set it to a non-positive value to disable the check.
@param preFilterCap Truncation value for the prefiltered image pixels. The algorithm first
@@ -1738,13 +3261,216 @@ class CV_EXPORTS_W StereoSGBM : public StereoMatcher
set StereoSGBM::numDisparities at minimum. The second constructor enables you to set each parameter
to a custom value.
*/
- CV_WRAP static Ptr create(int minDisparity, int numDisparities, int blockSize,
+ CV_WRAP static Ptr create(int minDisparity = 0, int numDisparities = 16, int blockSize = 3,
int P1 = 0, int P2 = 0, int disp12MaxDiff = 0,
int preFilterCap = 0, int uniquenessRatio = 0,
int speckleWindowSize = 0, int speckleRange = 0,
int mode = StereoSGBM::MODE_SGBM);
};
+
+//! cv::undistort mode
+enum UndistortTypes
+{
+ PROJ_SPHERICAL_ORTHO = 0,
+ PROJ_SPHERICAL_EQRECT = 1
+};
+
+/** @brief Transforms an image to compensate for lens distortion.
+
+The function transforms an image to compensate radial and tangential lens distortion.
+
+The function is simply a combination of #initUndistortRectifyMap (with unity R ) and #remap
+(with bilinear interpolation). See the former function for details of the transformation being
+performed.
+
+Those pixels in the destination image, for which there is no correspondent pixels in the source
+image, are filled with zeros (black color).
+
+A particular subset of the source image that will be visible in the corrected image can be regulated
+by newCameraMatrix. You can use #getOptimalNewCameraMatrix to compute the appropriate
+newCameraMatrix depending on your requirements.
+
+The camera matrix and the distortion parameters can be determined using #calibrateCamera. If
+the resolution of images is different from the resolution used at the calibration stage, \f$f_x,
+f_y, c_x\f$ and \f$c_y\f$ need to be scaled accordingly, while the distortion coefficients remain
+the same.
+
+@param src Input (distorted) image.
+@param dst Output (corrected) image that has the same size and type as src .
+@param cameraMatrix Input camera matrix \f$A = \vecthreethree{f_x}{0}{c_x}{0}{f_y}{c_y}{0}{0}{1}\f$ .
+@param distCoeffs Input vector of distortion coefficients
+\f$(k_1, k_2, p_1, p_2[, k_3[, k_4, k_5, k_6[, s_1, s_2, s_3, s_4[, \tau_x, \tau_y]]]])\f$
+of 4, 5, 8, 12 or 14 elements. If the vector is NULL/empty, the zero distortion coefficients are assumed.
+@param newCameraMatrix Camera matrix of the distorted image. By default, it is the same as
+cameraMatrix but you may additionally scale and shift the result by using a different matrix.
+ */
+CV_EXPORTS_W void undistort( InputArray src, OutputArray dst,
+ InputArray cameraMatrix,
+ InputArray distCoeffs,
+ InputArray newCameraMatrix = noArray() );
+
+/** @brief Computes the undistortion and rectification transformation map.
+
+The function computes the joint undistortion and rectification transformation and represents the
+result in the form of maps for remap. The undistorted image looks like original, as if it is
+captured with a camera using the camera matrix =newCameraMatrix and zero distortion. In case of a
+monocular camera, newCameraMatrix is usually equal to cameraMatrix, or it can be computed by
+#getOptimalNewCameraMatrix for a better control over scaling. In case of a stereo camera,
+newCameraMatrix is normally set to P1 or P2 computed by #stereoRectify .
+
+Also, this new camera is oriented differently in the coordinate space, according to R. That, for
+example, helps to align two heads of a stereo camera so that the epipolar lines on both images
+become horizontal and have the same y- coordinate (in case of a horizontally aligned stereo camera).
+
+The function actually builds the maps for the inverse mapping algorithm that is used by remap. That
+is, for each pixel \f$(u, v)\f$ in the destination (corrected and rectified) image, the function
+computes the corresponding coordinates in the source image (that is, in the original image from
+camera). The following process is applied:
+\f[
+\begin{array}{l}
+x \leftarrow (u - {c'}_x)/{f'}_x \\
+y \leftarrow (v - {c'}_y)/{f'}_y \\
+{[X\,Y\,W]} ^T \leftarrow R^{-1}*[x \, y \, 1]^T \\
+x' \leftarrow X/W \\
+y' \leftarrow Y/W \\
+r^2 \leftarrow x'^2 + y'^2 \\
+x'' \leftarrow x' \frac{1 + k_1 r^2 + k_2 r^4 + k_3 r^6}{1 + k_4 r^2 + k_5 r^4 + k_6 r^6}
++ 2p_1 x' y' + p_2(r^2 + 2 x'^2) + s_1 r^2 + s_2 r^4\\
+y'' \leftarrow y' \frac{1 + k_1 r^2 + k_2 r^4 + k_3 r^6}{1 + k_4 r^2 + k_5 r^4 + k_6 r^6}
++ p_1 (r^2 + 2 y'^2) + 2 p_2 x' y' + s_3 r^2 + s_4 r^4 \\
+s\vecthree{x'''}{y'''}{1} =
+\vecthreethree{R_{33}(\tau_x, \tau_y)}{0}{-R_{13}((\tau_x, \tau_y)}
+{0}{R_{33}(\tau_x, \tau_y)}{-R_{23}(\tau_x, \tau_y)}
+{0}{0}{1} R(\tau_x, \tau_y) \vecthree{x''}{y''}{1}\\
+map_x(u,v) \leftarrow x''' f_x + c_x \\
+map_y(u,v) \leftarrow y''' f_y + c_y
+\end{array}
+\f]
+where \f$(k_1, k_2, p_1, p_2[, k_3[, k_4, k_5, k_6[, s_1, s_2, s_3, s_4[, \tau_x, \tau_y]]]])\f$
+are the distortion coefficients.
+
+In case of a stereo camera, this function is called twice: once for each camera head, after
+stereoRectify, which in its turn is called after #stereoCalibrate. But if the stereo camera
+was not calibrated, it is still possible to compute the rectification transformations directly from
+the fundamental matrix using #stereoRectifyUncalibrated. For each camera, the function computes
+homography H as the rectification transformation in a pixel domain, not a rotation matrix R in 3D
+space. R can be computed from H as
+\f[\texttt{R} = \texttt{cameraMatrix} ^{-1} \cdot \texttt{H} \cdot \texttt{cameraMatrix}\f]
+where cameraMatrix can be chosen arbitrarily.
+
+@param cameraMatrix Input camera matrix \f$A=\vecthreethree{f_x}{0}{c_x}{0}{f_y}{c_y}{0}{0}{1}\f$ .
+@param distCoeffs Input vector of distortion coefficients
+\f$(k_1, k_2, p_1, p_2[, k_3[, k_4, k_5, k_6[, s_1, s_2, s_3, s_4[, \tau_x, \tau_y]]]])\f$
+of 4, 5, 8, 12 or 14 elements. If the vector is NULL/empty, the zero distortion coefficients are assumed.
+@param R Optional rectification transformation in the object space (3x3 matrix). R1 or R2 ,
+computed by #stereoRectify can be passed here. If the matrix is empty, the identity transformation
+is assumed. In cvInitUndistortMap R assumed to be an identity matrix.
+@param newCameraMatrix New camera matrix \f$A'=\vecthreethree{f_x'}{0}{c_x'}{0}{f_y'}{c_y'}{0}{0}{1}\f$.
+@param size Undistorted image size.
+@param m1type Type of the first output map that can be CV_32FC1, CV_32FC2 or CV_16SC2, see #convertMaps
+@param map1 The first output map.
+@param map2 The second output map.
+ */
+CV_EXPORTS_W
+void initUndistortRectifyMap(InputArray cameraMatrix, InputArray distCoeffs,
+ InputArray R, InputArray newCameraMatrix,
+ Size size, int m1type, OutputArray map1, OutputArray map2);
+
+//! initializes maps for #remap for wide-angle
+CV_EXPORTS
+float initWideAngleProjMap(InputArray cameraMatrix, InputArray distCoeffs,
+ Size imageSize, int destImageWidth,
+ int m1type, OutputArray map1, OutputArray map2,
+ enum UndistortTypes projType = PROJ_SPHERICAL_EQRECT, double alpha = 0);
+static inline
+float initWideAngleProjMap(InputArray cameraMatrix, InputArray distCoeffs,
+ Size imageSize, int destImageWidth,
+ int m1type, OutputArray map1, OutputArray map2,
+ int projType, double alpha = 0)
+{
+ return initWideAngleProjMap(cameraMatrix, distCoeffs, imageSize, destImageWidth,
+ m1type, map1, map2, (UndistortTypes)projType, alpha);
+}
+
+/** @brief Returns the default new camera matrix.
+
+The function returns the camera matrix that is either an exact copy of the input cameraMatrix (when
+centerPrinicipalPoint=false ), or the modified one (when centerPrincipalPoint=true).
+
+In the latter case, the new camera matrix will be:
+
+\f[\begin{bmatrix} f_x && 0 && ( \texttt{imgSize.width} -1)*0.5 \\ 0 && f_y && ( \texttt{imgSize.height} -1)*0.5 \\ 0 && 0 && 1 \end{bmatrix} ,\f]
+
+where \f$f_x\f$ and \f$f_y\f$ are \f$(0,0)\f$ and \f$(1,1)\f$ elements of cameraMatrix, respectively.
+
+By default, the undistortion functions in OpenCV (see #initUndistortRectifyMap, #undistort) do not
+move the principal point. However, when you work with stereo, it is important to move the principal
+points in both views to the same y-coordinate (which is required by most of stereo correspondence
+algorithms), and may be to the same x-coordinate too. So, you can form the new camera matrix for
+each view where the principal points are located at the center.
+
+@param cameraMatrix Input camera matrix.
+@param imgsize Camera view image size in pixels.
+@param centerPrincipalPoint Location of the principal point in the new camera matrix. The
+parameter indicates whether this location should be at the image center or not.
+ */
+CV_EXPORTS_W
+Mat getDefaultNewCameraMatrix(InputArray cameraMatrix, Size imgsize = Size(),
+ bool centerPrincipalPoint = false);
+
+/** @brief Computes the ideal point coordinates from the observed point coordinates.
+
+The function is similar to #undistort and #initUndistortRectifyMap but it operates on a
+sparse set of points instead of a raster image. Also the function performs a reverse transformation
+to projectPoints. In case of a 3D object, it does not reconstruct its 3D coordinates, but for a
+planar object, it does, up to a translation vector, if the proper R is specified.
+
+For each observed point coordinate \f$(u, v)\f$ the function computes:
+\f[
+\begin{array}{l}
+x^{"} \leftarrow (u - c_x)/f_x \\
+y^{"} \leftarrow (v - c_y)/f_y \\
+(x',y') = undistort(x^{"},y^{"}, \texttt{distCoeffs}) \\
+{[X\,Y\,W]} ^T \leftarrow R*[x' \, y' \, 1]^T \\
+x \leftarrow X/W \\
+y \leftarrow Y/W \\
+\text{only performed if P is specified:} \\
+u' \leftarrow x {f'}_x + {c'}_x \\
+v' \leftarrow y {f'}_y + {c'}_y
+\end{array}
+\f]
+
+where *undistort* is an approximate iterative algorithm that estimates the normalized original
+point coordinates out of the normalized distorted point coordinates ("normalized" means that the
+coordinates do not depend on the camera matrix).
+
+The function can be used for both a stereo camera head or a monocular camera (when R is empty).
+@param src Observed point coordinates, 2xN/Nx2 1-channel or 1xN/Nx1 2-channel (CV_32FC2 or CV_64FC2) (or
+vector\ ).
+@param dst Output ideal point coordinates (1xN/Nx1 2-channel or vector\ ) after undistortion and reverse perspective
+transformation. If matrix P is identity or omitted, dst will contain normalized point coordinates.
+@param cameraMatrix Camera matrix \f$\vecthreethree{f_x}{0}{c_x}{0}{f_y}{c_y}{0}{0}{1}\f$ .
+@param distCoeffs Input vector of distortion coefficients
+\f$(k_1, k_2, p_1, p_2[, k_3[, k_4, k_5, k_6[, s_1, s_2, s_3, s_4[, \tau_x, \tau_y]]]])\f$
+of 4, 5, 8, 12 or 14 elements. If the vector is NULL/empty, the zero distortion coefficients are assumed.
+@param R Rectification transformation in the object space (3x3 matrix). R1 or R2 computed by
+#stereoRectify can be passed here. If the matrix is empty, the identity transformation is used.
+@param P New camera matrix (3x3) or new projection matrix (3x4) \f$\begin{bmatrix} {f'}_x & 0 & {c'}_x & t_x \\ 0 & {f'}_y & {c'}_y & t_y \\ 0 & 0 & 1 & t_z \end{bmatrix}\f$. P1 or P2 computed by
+#stereoRectify can be passed here. If the matrix is empty, the identity new camera matrix is used.
+ */
+CV_EXPORTS_W
+void undistortPoints(InputArray src, OutputArray dst,
+ InputArray cameraMatrix, InputArray distCoeffs,
+ InputArray R = noArray(), InputArray P = noArray());
+/** @overload
+ @note Default version of #undistortPoints does 5 iterations to compute undistorted points.
+ */
+CV_EXPORTS_AS(undistortPointsIter)
+void undistortPoints(InputArray src, OutputArray dst,
+ InputArray cameraMatrix, InputArray distCoeffs,
+ InputArray R, InputArray P, TermCriteria criteria);
+
//! @} calib3d
/** @brief The methods in this namespace use a so-called fisheye camera model.
@@ -1756,15 +3482,16 @@ namespace fisheye
//! @{
enum{
- CALIB_USE_INTRINSIC_GUESS = 1,
- CALIB_RECOMPUTE_EXTRINSIC = 2,
- CALIB_CHECK_COND = 4,
- CALIB_FIX_SKEW = 8,
- CALIB_FIX_K1 = 16,
- CALIB_FIX_K2 = 32,
- CALIB_FIX_K3 = 64,
- CALIB_FIX_K4 = 128,
- CALIB_FIX_INTRINSIC = 256
+ CALIB_USE_INTRINSIC_GUESS = 1 << 0,
+ CALIB_RECOMPUTE_EXTRINSIC = 1 << 1,
+ CALIB_CHECK_COND = 1 << 2,
+ CALIB_FIX_SKEW = 1 << 3,
+ CALIB_FIX_K1 = 1 << 4,
+ CALIB_FIX_K2 = 1 << 5,
+ CALIB_FIX_K3 = 1 << 6,
+ CALIB_FIX_K4 = 1 << 7,
+ CALIB_FIX_INTRINSIC = 1 << 8,
+ CALIB_FIX_PRINCIPAL_POINT = 1 << 9
};
/** @brief Projects points using fisheye model
@@ -1803,7 +3530,7 @@ namespace fisheye
@param alpha The skew coefficient.
@param distorted Output array of image points, 1xN/Nx1 2-channel, or vector\ .
- Note that the function assumes the camera matrix of the undistorted points to be indentity.
+ Note that the function assumes the camera matrix of the undistorted points to be identity.
This means if you want to transform back points undistorted with undistortPoints() you have to
multiply them with \f$P^{-1}\f$.
*/
@@ -1848,7 +3575,7 @@ namespace fisheye
@param D Input vector of distortion coefficients \f$(k_1, k_2, k_3, k_4)\f$.
@param Knew Camera matrix of the distorted image. By default, it is the identity matrix but you
may additionally scale and shift the result by using a different matrix.
- @param new_size
+ @param new_size the new size
The function transforms an image to compensate radial and tangential lens distortion.
@@ -1874,14 +3601,14 @@ namespace fisheye
/** @brief Estimates new camera matrix for undistortion or rectification.
@param K Camera matrix \f$K = \vecthreethree{f_x}{0}{c_x}{0}{f_y}{c_y}{0}{0}{_1}\f$.
- @param image_size
+ @param image_size Size of the image
@param D Input vector of distortion coefficients \f$(k_1, k_2, k_3, k_4)\f$.
@param R Rectification transformation in the object space: 3x3 1-channel, or vector: 3x1/1x3
1-channel or 1x1 3-channel
@param P New camera matrix (3x3) or new projection matrix (3x4)
@param balance Sets the new focal length in range between the min focal length and the max focal
length. Balance is in range of [0, 1].
- @param new_size
+ @param new_size the new size
@param fov_scale Divisor for new focal length.
*/
CV_EXPORTS_W void estimateNewCameraMatrixForUndistortRectify(InputArray K, InputArray D, const Size &image_size, InputArray R,
@@ -1914,8 +3641,10 @@ namespace fisheye
of intrinsic optimization.
- **fisheye::CALIB_CHECK_COND** The functions will check validity of condition number.
- **fisheye::CALIB_FIX_SKEW** Skew coefficient (alpha) is set to zero and stay zero.
- - **fisheye::CALIB_FIX_K1..4** Selected distortion coefficients are set to zeros and stay
- zero.
+ - **fisheye::CALIB_FIX_K1..fisheye::CALIB_FIX_K4** Selected distortion coefficients
+ are set to zeros and stay zero.
+ - **fisheye::CALIB_FIX_PRINCIPAL_POINT** The principal point is not changed during the global
+optimization. It stays at the center or at a different location specified when CALIB_USE_INTRINSIC_GUESS is set too.
@param criteria Termination criteria for the iterative optimization algorithm.
*/
CV_EXPORTS_W double calibrate(InputArrayOfArrays objectPoints, InputArrayOfArrays imagePoints, const Size& image_size,
@@ -1939,7 +3668,7 @@ namespace fisheye
@param P2 Output 3x4 projection matrix in the new (rectified) coordinate systems for the second
camera.
@param Q Output \f$4 \times 4\f$ disparity-to-depth mapping matrix (see reprojectImageTo3D ).
- @param flags Operation flags that may be zero or CV_CALIB_ZERO_DISPARITY . If the flag is set,
+ @param flags Operation flags that may be zero or CALIB_ZERO_DISPARITY . If the flag is set,
the function makes the principal points of each camera have the same pixel coordinates in the
rectified views. And if the flag is not set, the function may still shift the images in the
horizontal or vertical direction (depending on the orientation of epipolar lines) to maximize the
@@ -1965,7 +3694,7 @@ namespace fisheye
observed by the second camera.
@param K1 Input/output first camera matrix:
\f$\vecthreethree{f_x^{(j)}}{0}{c_x^{(j)}}{0}{f_y^{(j)}}{c_y^{(j)}}{0}{0}{1}\f$ , \f$j = 0,\, 1\f$ . If
- any of fisheye::CALIB_USE_INTRINSIC_GUESS , fisheye::CV_CALIB_FIX_INTRINSIC are specified,
+ any of fisheye::CALIB_USE_INTRINSIC_GUESS , fisheye::CALIB_FIX_INTRINSIC are specified,
some or all of the matrix components must be initialized.
@param D1 Input/output vector of distortion coefficients \f$(k_1, k_2, k_3, k_4)\f$ of 4 elements.
@param K2 Input/output second camera matrix. The parameter is similar to K1 .
@@ -1975,7 +3704,7 @@ namespace fisheye
@param R Output rotation matrix between the 1st and the 2nd camera coordinate systems.
@param T Output translation vector between the coordinate systems of the cameras.
@param flags Different flags that may be zero or a combination of the following values:
- - **fisheye::CV_CALIB_FIX_INTRINSIC** Fix K1, K2? and D1, D2? so that only R, T matrices
+ - **fisheye::CALIB_FIX_INTRINSIC** Fix K1, K2? and D1, D2? so that only R, T matrices
are estimated.
- **fisheye::CALIB_USE_INTRINSIC_GUESS** K1, K2 contains valid initial values of
fx, fy, cx, cy that are optimized further. Otherwise, (cx, cy) is initially set to the image
@@ -1994,12 +3723,48 @@ namespace fisheye
TermCriteria criteria = TermCriteria(TermCriteria::COUNT + TermCriteria::EPS, 100, DBL_EPSILON));
//! @} calib3d_fisheye
-}
+} // end namespace fisheye
-} // cv
+} //end namespace cv
-#ifndef DISABLE_OPENCV_24_COMPATIBILITY
-#include "opencv2/calib3d/calib3d_c.h"
+#if 0 //def __cplusplus
+//////////////////////////////////////////////////////////////////////////////////////////
+class CV_EXPORTS CvLevMarq
+{
+public:
+ CvLevMarq();
+ CvLevMarq( int nparams, int nerrs, CvTermCriteria criteria=
+ cvTermCriteria(cv::TermCriteria::EPS+cv::TermCriteria::MAX_ITER,30,DBL_EPSILON),
+ bool completeSymmFlag=false );
+ ~CvLevMarq();
+ void init( int nparams, int nerrs, CvTermCriteria criteria=
+ cvTermCriteria(cv::TermCriteria::EPS+cv::TermCriteria::MAX_ITER,30,DBL_EPSILON),
+ bool completeSymmFlag=false );
+ bool update( const CvMat*& param, CvMat*& J, CvMat*& err );
+ bool updateAlt( const CvMat*& param, CvMat*& JtJ, CvMat*& JtErr, double*& errNorm );
+
+ void clear();
+ void step();
+ enum { DONE=0, STARTED=1, CALC_J=2, CHECK_ERR=3 };
+
+ cv::Ptr mask;
+ cv::Ptr prevParam;
+ cv::Ptr param;
+ cv::Ptr J;
+ cv::Ptr err;
+ cv::Ptr JtJ;
+ cv::Ptr JtJN;
+ cv::Ptr JtErr;
+ cv::Ptr JtJV;
+ cv::Ptr JtJW;
+ double prevErrNorm, errNorm;
+ int lambdaLg10;
+ CvTermCriteria criteria;
+ int state;
+ int iters;
+ bool completeSymmFlag;
+ int solveMethod;
+};
#endif
#endif
diff --git a/IPL/include/opencv/opencv2/calib3d/calib3d_c.h b/IPL/include/opencv/opencv2/calib3d/calib3d_c.h
index 0e77aa8..959579c 100644
--- a/IPL/include/opencv/opencv2/calib3d/calib3d_c.h
+++ b/IPL/include/opencv/opencv2/calib3d/calib3d_c.h
@@ -41,44 +41,15 @@
//
//M*/
-#ifndef __OPENCV_CALIB3D_C_H__
-#define __OPENCV_CALIB3D_C_H__
+#ifndef OPENCV_CALIB3D_C_H
+#define OPENCV_CALIB3D_C_H
-#include "opencv2/core/core_c.h"
+#include "opencv2/core/types_c.h"
#ifdef __cplusplus
extern "C" {
#endif
-/** @addtogroup calib3d_c
- @{
- */
-
-/****************************************************************************************\
-* Camera Calibration, Pose Estimation and Stereo *
-\****************************************************************************************/
-
-typedef struct CvPOSITObject CvPOSITObject;
-
-/* Allocates and initializes CvPOSITObject structure before doing cvPOSIT */
-CVAPI(CvPOSITObject*) cvCreatePOSITObject( CvPoint3D32f* points, int point_count );
-
-
-/* Runs POSIT (POSe from ITeration) algorithm for determining 3d position of
- an object given its model and projection in a weak-perspective case */
-CVAPI(void) cvPOSIT( CvPOSITObject* posit_object, CvPoint2D32f* image_points,
- double focal_length, CvTermCriteria criteria,
- float* rotation_matrix, float* translation_vector);
-
-/* Releases CvPOSITObject structure */
-CVAPI(void) cvReleasePOSITObject( CvPOSITObject** posit_object );
-
-/* updates the number of RANSAC iterations */
-CVAPI(int) cvRANSACUpdateNumIters( double p, double err_prob,
- int model_points, int max_iters );
-
-CVAPI(void) cvConvertPointsHomogeneous( const CvMat* src, CvMat* dst );
-
/* Calculates fundamental matrix given a set of corresponding points */
#define CV_FM_7POINT 1
#define CV_FM_8POINT 2
@@ -99,136 +70,11 @@ enum
CV_DLS = 3 // Joel A. Hesch and Stergios I. Roumeliotis. "A Direct Least-Squares (DLS) Method for PnP"
};
-CVAPI(int) cvFindFundamentalMat( const CvMat* points1, const CvMat* points2,
- CvMat* fundamental_matrix,
- int method CV_DEFAULT(CV_FM_RANSAC),
- double param1 CV_DEFAULT(3.), double param2 CV_DEFAULT(0.99),
- CvMat* status CV_DEFAULT(NULL) );
-
-/* For each input point on one of images
- computes parameters of the corresponding
- epipolar line on the other image */
-CVAPI(void) cvComputeCorrespondEpilines( const CvMat* points,
- int which_image,
- const CvMat* fundamental_matrix,
- CvMat* correspondent_lines );
-
-/* Triangulation functions */
-
-CVAPI(void) cvTriangulatePoints(CvMat* projMatr1, CvMat* projMatr2,
- CvMat* projPoints1, CvMat* projPoints2,
- CvMat* points4D);
-
-CVAPI(void) cvCorrectMatches(CvMat* F, CvMat* points1, CvMat* points2,
- CvMat* new_points1, CvMat* new_points2);
-
-
-/* Computes the optimal new camera matrix according to the free scaling parameter alpha:
- alpha=0 - only valid pixels will be retained in the undistorted image
- alpha=1 - all the source image pixels will be retained in the undistorted image
-*/
-CVAPI(void) cvGetOptimalNewCameraMatrix( const CvMat* camera_matrix,
- const CvMat* dist_coeffs,
- CvSize image_size, double alpha,
- CvMat* new_camera_matrix,
- CvSize new_imag_size CV_DEFAULT(cvSize(0,0)),
- CvRect* valid_pixel_ROI CV_DEFAULT(0),
- int center_principal_point CV_DEFAULT(0));
-
-/* Converts rotation vector to rotation matrix or vice versa */
-CVAPI(int) cvRodrigues2( const CvMat* src, CvMat* dst,
- CvMat* jacobian CV_DEFAULT(0) );
-
-/* Finds perspective transformation between the object plane and image (view) plane */
-CVAPI(int) cvFindHomography( const CvMat* src_points,
- const CvMat* dst_points,
- CvMat* homography,
- int method CV_DEFAULT(0),
- double ransacReprojThreshold CV_DEFAULT(3),
- CvMat* mask CV_DEFAULT(0),
- int maxIters CV_DEFAULT(2000),
- double confidence CV_DEFAULT(0.995));
-
-/* Computes RQ decomposition for 3x3 matrices */
-CVAPI(void) cvRQDecomp3x3( const CvMat *matrixM, CvMat *matrixR, CvMat *matrixQ,
- CvMat *matrixQx CV_DEFAULT(NULL),
- CvMat *matrixQy CV_DEFAULT(NULL),
- CvMat *matrixQz CV_DEFAULT(NULL),
- CvPoint3D64f *eulerAngles CV_DEFAULT(NULL));
-
-/* Computes projection matrix decomposition */
-CVAPI(void) cvDecomposeProjectionMatrix( const CvMat *projMatr, CvMat *calibMatr,
- CvMat *rotMatr, CvMat *posVect,
- CvMat *rotMatrX CV_DEFAULT(NULL),
- CvMat *rotMatrY CV_DEFAULT(NULL),
- CvMat *rotMatrZ CV_DEFAULT(NULL),
- CvPoint3D64f *eulerAngles CV_DEFAULT(NULL));
-
-/* Computes d(AB)/dA and d(AB)/dB */
-CVAPI(void) cvCalcMatMulDeriv( const CvMat* A, const CvMat* B, CvMat* dABdA, CvMat* dABdB );
-
-/* Computes r3 = rodrigues(rodrigues(r2)*rodrigues(r1)),
- t3 = rodrigues(r2)*t1 + t2 and the respective derivatives */
-CVAPI(void) cvComposeRT( const CvMat* _rvec1, const CvMat* _tvec1,
- const CvMat* _rvec2, const CvMat* _tvec2,
- CvMat* _rvec3, CvMat* _tvec3,
- CvMat* dr3dr1 CV_DEFAULT(0), CvMat* dr3dt1 CV_DEFAULT(0),
- CvMat* dr3dr2 CV_DEFAULT(0), CvMat* dr3dt2 CV_DEFAULT(0),
- CvMat* dt3dr1 CV_DEFAULT(0), CvMat* dt3dt1 CV_DEFAULT(0),
- CvMat* dt3dr2 CV_DEFAULT(0), CvMat* dt3dt2 CV_DEFAULT(0) );
-
-/* Projects object points to the view plane using
- the specified extrinsic and intrinsic camera parameters */
-CVAPI(void) cvProjectPoints2( const CvMat* object_points, const CvMat* rotation_vector,
- const CvMat* translation_vector, const CvMat* camera_matrix,
- const CvMat* distortion_coeffs, CvMat* image_points,
- CvMat* dpdrot CV_DEFAULT(NULL), CvMat* dpdt CV_DEFAULT(NULL),
- CvMat* dpdf CV_DEFAULT(NULL), CvMat* dpdc CV_DEFAULT(NULL),
- CvMat* dpddist CV_DEFAULT(NULL),
- double aspect_ratio CV_DEFAULT(0));
-
-/* Finds extrinsic camera parameters from
- a few known corresponding point pairs and intrinsic parameters */
-CVAPI(void) cvFindExtrinsicCameraParams2( const CvMat* object_points,
- const CvMat* image_points,
- const CvMat* camera_matrix,
- const CvMat* distortion_coeffs,
- CvMat* rotation_vector,
- CvMat* translation_vector,
- int use_extrinsic_guess CV_DEFAULT(0) );
-
-/* Computes initial estimate of the intrinsic camera parameters
- in case of planar calibration target (e.g. chessboard) */
-CVAPI(void) cvInitIntrinsicParams2D( const CvMat* object_points,
- const CvMat* image_points,
- const CvMat* npoints, CvSize image_size,
- CvMat* camera_matrix,
- double aspect_ratio CV_DEFAULT(1.) );
-
#define CV_CALIB_CB_ADAPTIVE_THRESH 1
#define CV_CALIB_CB_NORMALIZE_IMAGE 2
#define CV_CALIB_CB_FILTER_QUADS 4
#define CV_CALIB_CB_FAST_CHECK 8
-// Performs a fast check if a chessboard is in the input image. This is a workaround to
-// a problem of cvFindChessboardCorners being slow on images with no chessboard
-// - src: input image
-// - size: chessboard size
-// Returns 1 if a chessboard can be in this image and findChessboardCorners should be called,
-// 0 if there is no chessboard, -1 in case of error
-CVAPI(int) cvCheckChessboard(IplImage* src, CvSize size);
-
- /* Detects corners on a chessboard calibration pattern */
-CVAPI(int) cvFindChessboardCorners( const void* image, CvSize pattern_size,
- CvPoint2D32f* corners,
- int* corner_count CV_DEFAULT(NULL),
- int flags CV_DEFAULT(CV_CALIB_CB_ADAPTIVE_THRESH+CV_CALIB_CB_NORMALIZE_IMAGE) );
-
-/* Draws individual chessboard corners or the whole chessboard detected */
-CVAPI(void) cvDrawChessboardCorners( CvArr* image, CvSize pattern_size,
- CvPoint2D32f* corners,
- int count, int pattern_was_found );
-
#define CV_CALIB_USE_INTRINSIC_GUESS 1
#define CV_CALIB_FIX_ASPECT_RATIO 2
#define CV_CALIB_FIX_PRINCIPAL_POINT 4
@@ -245,140 +91,19 @@ CVAPI(void) cvDrawChessboardCorners( CvArr* image, CvSize pattern_size,
#define CV_CALIB_FIX_S1_S2_S3_S4 65536
#define CV_CALIB_TILTED_MODEL 262144
#define CV_CALIB_FIX_TAUX_TAUY 524288
+#define CV_CALIB_FIX_TANGENT_DIST 2097152
-
-/* Finds intrinsic and extrinsic camera parameters
- from a few views of known calibration pattern */
-CVAPI(double) cvCalibrateCamera2( const CvMat* object_points,
- const CvMat* image_points,
- const CvMat* point_counts,
- CvSize image_size,
- CvMat* camera_matrix,
- CvMat* distortion_coeffs,
- CvMat* rotation_vectors CV_DEFAULT(NULL),
- CvMat* translation_vectors CV_DEFAULT(NULL),
- int flags CV_DEFAULT(0),
- CvTermCriteria term_crit CV_DEFAULT(cvTermCriteria(
- CV_TERMCRIT_ITER+CV_TERMCRIT_EPS,30,DBL_EPSILON)) );
-
-/* Computes various useful characteristics of the camera from the data computed by
- cvCalibrateCamera2 */
-CVAPI(void) cvCalibrationMatrixValues( const CvMat *camera_matrix,
- CvSize image_size,
- double aperture_width CV_DEFAULT(0),
- double aperture_height CV_DEFAULT(0),
- double *fovx CV_DEFAULT(NULL),
- double *fovy CV_DEFAULT(NULL),
- double *focal_length CV_DEFAULT(NULL),
- CvPoint2D64f *principal_point CV_DEFAULT(NULL),
- double *pixel_aspect_ratio CV_DEFAULT(NULL));
+#define CV_CALIB_NINTRINSIC 18
#define CV_CALIB_FIX_INTRINSIC 256
#define CV_CALIB_SAME_FOCAL_LENGTH 512
-/* Computes the transformation from one camera coordinate system to another one
- from a few correspondent views of the same calibration target. Optionally, calibrates
- both cameras */
-CVAPI(double) cvStereoCalibrate( const CvMat* object_points, const CvMat* image_points1,
- const CvMat* image_points2, const CvMat* npoints,
- CvMat* camera_matrix1, CvMat* dist_coeffs1,
- CvMat* camera_matrix2, CvMat* dist_coeffs2,
- CvSize image_size, CvMat* R, CvMat* T,
- CvMat* E CV_DEFAULT(0), CvMat* F CV_DEFAULT(0),
- int flags CV_DEFAULT(CV_CALIB_FIX_INTRINSIC),
- CvTermCriteria term_crit CV_DEFAULT(cvTermCriteria(
- CV_TERMCRIT_ITER+CV_TERMCRIT_EPS,30,1e-6)) );
-
#define CV_CALIB_ZERO_DISPARITY 1024
-/* Computes 3D rotations (+ optional shift) for each camera coordinate system to make both
- views parallel (=> to make all the epipolar lines horizontal or vertical) */
-CVAPI(void) cvStereoRectify( const CvMat* camera_matrix1, const CvMat* camera_matrix2,
- const CvMat* dist_coeffs1, const CvMat* dist_coeffs2,
- CvSize image_size, const CvMat* R, const CvMat* T,
- CvMat* R1, CvMat* R2, CvMat* P1, CvMat* P2,
- CvMat* Q CV_DEFAULT(0),
- int flags CV_DEFAULT(CV_CALIB_ZERO_DISPARITY),
- double alpha CV_DEFAULT(-1),
- CvSize new_image_size CV_DEFAULT(cvSize(0,0)),
- CvRect* valid_pix_ROI1 CV_DEFAULT(0),
- CvRect* valid_pix_ROI2 CV_DEFAULT(0));
-
-/* Computes rectification transformations for uncalibrated pair of images using a set
- of point correspondences */
-CVAPI(int) cvStereoRectifyUncalibrated( const CvMat* points1, const CvMat* points2,
- const CvMat* F, CvSize img_size,
- CvMat* H1, CvMat* H2,
- double threshold CV_DEFAULT(5));
-
-
-
/* stereo correspondence parameters and functions */
-
#define CV_STEREO_BM_NORMALIZED_RESPONSE 0
#define CV_STEREO_BM_XSOBEL 1
-/* Block matching algorithm structure */
-typedef struct CvStereoBMState
-{
- // pre-filtering (normalization of input images)
- int preFilterType; // =CV_STEREO_BM_NORMALIZED_RESPONSE now
- int preFilterSize; // averaging window size: ~5x5..21x21
- int preFilterCap; // the output of pre-filtering is clipped by [-preFilterCap,preFilterCap]
-
- // correspondence using Sum of Absolute Difference (SAD)
- int SADWindowSize; // ~5x5..21x21
- int minDisparity; // minimum disparity (can be negative)
- int numberOfDisparities; // maximum disparity - minimum disparity (> 0)
-
- // post-filtering
- int textureThreshold; // the disparity is only computed for pixels
- // with textured enough neighborhood
- int uniquenessRatio; // accept the computed disparity d* only if
- // SAD(d) >= SAD(d*)*(1 + uniquenessRatio/100.)
- // for any d != d*+/-1 within the search range.
- int speckleWindowSize; // disparity variation window
- int speckleRange; // acceptable range of variation in window
-
- int trySmallerWindows; // if 1, the results may be more accurate,
- // at the expense of slower processing
- CvRect roi1, roi2;
- int disp12MaxDiff;
-
- // temporary buffers
- CvMat* preFilteredImg0;
- CvMat* preFilteredImg1;
- CvMat* slidingSumBuf;
- CvMat* cost;
- CvMat* disp;
-} CvStereoBMState;
-
-#define CV_STEREO_BM_BASIC 0
-#define CV_STEREO_BM_FISH_EYE 1
-#define CV_STEREO_BM_NARROW 2
-
-CVAPI(CvStereoBMState*) cvCreateStereoBMState(int preset CV_DEFAULT(CV_STEREO_BM_BASIC),
- int numberOfDisparities CV_DEFAULT(0));
-
-CVAPI(void) cvReleaseStereoBMState( CvStereoBMState** state );
-
-CVAPI(void) cvFindStereoCorrespondenceBM( const CvArr* left, const CvArr* right,
- CvArr* disparity, CvStereoBMState* state );
-
-CVAPI(CvRect) cvGetValidDisparityROI( CvRect roi1, CvRect roi2, int minDisparity,
- int numberOfDisparities, int SADWindowSize );
-
-CVAPI(void) cvValidateDisparity( CvArr* disparity, const CvArr* cost,
- int minDisparity, int numberOfDisparities,
- int disp12MaxDiff CV_DEFAULT(1) );
-
-/* Reprojects the computed disparity image to the 3D space using the specified 4x4 matrix */
-CVAPI(void) cvReprojectImageTo3D( const CvArr* disparityImage,
- CvArr* _3dImage, const CvMat* Q,
- int handleMissingValues CV_DEFAULT(0) );
-
-/** @} calib3d_c */
-
#ifdef __cplusplus
} // extern "C"
@@ -388,11 +113,11 @@ class CV_EXPORTS CvLevMarq
public:
CvLevMarq();
CvLevMarq( int nparams, int nerrs, CvTermCriteria criteria=
- cvTermCriteria(CV_TERMCRIT_EPS+CV_TERMCRIT_ITER,30,DBL_EPSILON),
+ cvTermCriteria(cv::TermCriteria::EPS+cv::TermCriteria::MAX_ITER,30,DBL_EPSILON),
bool completeSymmFlag=false );
~CvLevMarq();
void init( int nparams, int nerrs, CvTermCriteria criteria=
- cvTermCriteria(CV_TERMCRIT_EPS+CV_TERMCRIT_ITER,30,DBL_EPSILON),
+ cvTermCriteria(cv::TermCriteria::EPS+cv::TermCriteria::MAX_ITER,30,DBL_EPSILON),
bool completeSymmFlag=false );
bool update( const CvMat*& param, CvMat*& J, CvMat*& err );
bool updateAlt( const CvMat*& param, CvMat*& JtJ, CvMat*& JtErr, double*& errNorm );
@@ -422,4 +147,4 @@ class CV_EXPORTS CvLevMarq
#endif
-#endif /* __OPENCV_CALIB3D_C_H__ */
+#endif /* OPENCV_CALIB3D_C_H */
diff --git a/IPL/include/opencv/opencv2/ccalib.hpp b/IPL/include/opencv/opencv2/ccalib.hpp
index 79df598..538ec0f 100644
--- a/IPL/include/opencv/opencv2/ccalib.hpp
+++ b/IPL/include/opencv/opencv2/ccalib.hpp
@@ -71,7 +71,7 @@ class CV_EXPORTS CustomPattern : public Algorithm
bool isInitialized();
- void getPatternPoints(OutputArray original_points);
+ void getPatternPoints(std::vector& original_points);
/**<
Returns a vector of the original points.
*/
@@ -96,21 +96,21 @@ class CV_EXPORTS CustomPattern : public Algorithm
Calls the calirateCamera function with the same inputs.
*/
- bool findRt(InputArray objectPoints, InputArray imagePoints, InputArray cameraMatrix, InputArray distCoeffs,
- OutputArray rvec, OutputArray tvec, bool useExtrinsicGuess = false, int flags = SOLVEPNP_ITERATIVE);
- bool findRt(InputArray image, InputArray cameraMatrix, InputArray distCoeffs,
- OutputArray rvec, OutputArray tvec, bool useExtrinsicGuess = false, int flags = SOLVEPNP_ITERATIVE);
+ bool findRt(InputArray objectPoints, InputArray imagePoints, InputArray cameraMatrix, InputArray distCoeffs,
+ InputOutputArray rvec, InputOutputArray tvec, bool useExtrinsicGuess = false, int flags = SOLVEPNP_ITERATIVE);
+ bool findRt(InputArray image, InputArray cameraMatrix, InputArray distCoeffs,
+ InputOutputArray rvec, InputOutputArray tvec, bool useExtrinsicGuess = false, int flags = SOLVEPNP_ITERATIVE);
/**<
Uses solvePnP to find the rotation and translation of the pattern
with respect to the camera frame.
*/
- bool findRtRANSAC(InputArray objectPoints, InputArray imagePoints, InputArray cameraMatrix, InputArray distCoeffs,
- OutputArray rvec, OutputArray tvec, bool useExtrinsicGuess = false, int iterationsCount = 100,
- float reprojectionError = 8.0, int minInliersCount = 100, OutputArray inliers = noArray(), int flags = SOLVEPNP_ITERATIVE);
- bool findRtRANSAC(InputArray image, InputArray cameraMatrix, InputArray distCoeffs,
- OutputArray rvec, OutputArray tvec, bool useExtrinsicGuess = false, int iterationsCount = 100,
- float reprojectionError = 8.0, int minInliersCount = 100, OutputArray inliers = noArray(), int flags = SOLVEPNP_ITERATIVE);
+ bool findRtRANSAC(InputArray objectPoints, InputArray imagePoints, InputArray cameraMatrix, InputArray distCoeffs,
+ InputOutputArray rvec, InputOutputArray tvec, bool useExtrinsicGuess = false, int iterationsCount = 100,
+ float reprojectionError = 8.0, int minInliersCount = 100, OutputArray inliers = noArray(), int flags = SOLVEPNP_ITERATIVE);
+ bool findRtRANSAC(InputArray image, InputArray cameraMatrix, InputArray distCoeffs,
+ InputOutputArray rvec, InputOutputArray tvec, bool useExtrinsicGuess = false, int iterationsCount = 100,
+ float reprojectionError = 8.0, int minInliersCount = 100, OutputArray inliers = noArray(), int flags = SOLVEPNP_ITERATIVE);
/**<
Uses solvePnPRansac()
*/
diff --git a/IPL/include/opencv/opencv2/ccalib/omnidir.hpp b/IPL/include/opencv/opencv2/ccalib/omnidir.hpp
index 25c41bf..d3132b3 100644
--- a/IPL/include/opencv/opencv2/ccalib/omnidir.hpp
+++ b/IPL/include/opencv/opencv2/ccalib/omnidir.hpp
@@ -39,12 +39,13 @@
//
//M*/
-#include
-#include
-
#ifndef __OPENCV_OMNIDIR_HPP__
#define __OPENCV_OMNIDIR_HPP__
+#include "opencv2/core.hpp"
+#include "opencv2/core/affine.hpp"
+#include
+
namespace cv
{
namespace omnidir
@@ -102,6 +103,10 @@ namespace omnidir
CV_EXPORTS_W void projectPoints(InputArray objectPoints, OutputArray imagePoints, InputArray rvec, InputArray tvec,
InputArray K, double xi, InputArray D, OutputArray jacobian = noArray());
+ /** @overload */
+ CV_EXPORTS void projectPoints(InputArray objectPoints, OutputArray imagePoints, const Affine3d& affine,
+ InputArray K, double xi, InputArray D, OutputArray jacobian = noArray());
+
/** @brief Undistort 2D image points for omnidirectional camera using CMei's model
@param distorted Array of distorted image points, vector of Vec2f
@@ -126,7 +131,7 @@ namespace omnidir
@param R Rotation transform between the original and object space : 3x3 1-channel, or vector: 3x1/1x3, with depth CV_32F or CV_64F
@param P New camera matrix (3x3) or new projection matrix (3x4)
@param size Undistorted image size.
- @param mltype Type of the first output map that can be CV_32FC1 or CV_16SC2 . See convertMaps()
+ @param m1type Type of the first output map that can be CV_32FC1 or CV_16SC2 . See convertMaps()
for details.
@param map1 The first output map.
@param map2 The second output map.
@@ -134,7 +139,7 @@ namespace omnidir
are supported.
*/
CV_EXPORTS_W void initUndistortRectifyMap(InputArray K, InputArray D, InputArray xi, InputArray R, InputArray P, const cv::Size& size,
- int mltype, OutputArray map1, OutputArray map2, int flags);
+ int m1type, OutputArray map1, OutputArray map2, int flags);
/** @brief Undistort omnidirectional images to perspective images
@@ -168,7 +173,7 @@ namespace omnidir
@param idx Indices of images that pass initialization, which are really used in calibration. So the size of rvecs is the
same as idx.total().
*/
- CV_EXPORTS_W double calibrate(InputArray objectPoints, InputArray imagePoints, Size size,
+ CV_EXPORTS_W double calibrate(InputArrayOfArrays objectPoints, InputArrayOfArrays imagePoints, Size size,
InputOutputArray K, InputOutputArray xi, InputOutputArray D, OutputArrayOfArrays rvecs, OutputArrayOfArrays tvecs,
int flags, TermCriteria criteria, OutputArray idx=noArray());
@@ -278,8 +283,6 @@ namespace internal
double computeMeanReproErrStereo(InputArrayOfArrays objectPoints, InputArrayOfArrays imagePoints1, InputArrayOfArrays imagePoints2, InputArray K1, InputArray K2,
InputArray D1, InputArray D2, double xi1, double xi2, InputArray om, InputArray T, InputArrayOfArrays omL, InputArrayOfArrays TL);
- void checkFixed(Mat &G, int flags, int n);
-
void subMatrix(const Mat& src, Mat& dst, const std::vector& cols, const std::vector& rows);
void flags2idx(int flags, std::vector& idx, int n);
@@ -309,4 +312,4 @@ namespace internal
} // omnidir
} //cv
-#endif
\ No newline at end of file
+#endif
diff --git a/IPL/include/opencv/opencv2/ccalib/randpattern.hpp b/IPL/include/opencv/opencv2/ccalib/randpattern.hpp
index 9fc08f8..fb362bd 100644
--- a/IPL/include/opencv/opencv2/ccalib/randpattern.hpp
+++ b/IPL/include/opencv/opencv2/ccalib/randpattern.hpp
@@ -86,7 +86,14 @@ class CV_EXPORTS RandomPatternCornerFinder
/* @brief Load pattern image and compute features for pattern
@param patternImage image for "random" pattern generated by RandomPatternGenerator, run it first.
*/
- void loadPattern(cv::Mat patternImage);
+ void loadPattern(const cv::Mat &patternImage);
+
+ /* @brief Load pattern and features
+ @param patternImage image for "random" pattern generated by RandomPatternGenerator, run it first.
+ @param patternKeyPoints keyPoints created from a FeatureDetector.
+ @param patternDescriptors descriptors created from a DescriptorExtractor.
+ */
+ void loadPattern(const cv::Mat &patternImage, const std::vector &patternKeyPoints, const cv::Mat &patternDescriptors);
/* @brief Compute matched object points and image points which are used for calibration
The objectPoints (3D) and imagePoints (2D) are stored inside the class. Run getObjectPoints()
@@ -108,11 +115,11 @@ class CV_EXPORTS RandomPatternCornerFinder
/* @brief Get object(3D) points
*/
- std::vector getObjectPoints();
+ const std::vector &getObjectPoints();
/* @brief and image(2D) points
*/
- std::vector getImagePoints();
+ const std::vector &getImagePoints();
private:
diff --git a/IPL/include/opencv/opencv2/core.hpp b/IPL/include/opencv/opencv2/core.hpp
index 2e47658..ff9fa36 100644
--- a/IPL/include/opencv/opencv2/core.hpp
+++ b/IPL/include/opencv/opencv2/core.hpp
@@ -42,8 +42,8 @@
//
//M*/
-#ifndef __OPENCV_CORE_HPP__
-#define __OPENCV_CORE_HPP__
+#ifndef OPENCV_CORE_HPP
+#define OPENCV_CORE_HPP
#ifndef __cplusplus
# error core.hpp header must be compiled as C++
@@ -68,12 +68,17 @@
@defgroup core_c_glue Connections with C++
@}
@defgroup core_array Operations on arrays
+ @defgroup core_async Asynchronous API
@defgroup core_xml XML/YAML Persistence
@defgroup core_cluster Clustering
@defgroup core_utils Utility and system functions and macros
@{
+ @defgroup core_logging Logging facilities
@defgroup core_utils_sse SSE utilities
@defgroup core_utils_neon NEON utilities
+ @defgroup core_utils_vsx VSX utilities
+ @defgroup core_utils_softfloat Softfloat support
+ @defgroup core_utils_samples Utility functions for OpenCV samples
@}
@defgroup core_opengl OpenGL interoperability
@defgroup core_ipp Intel IPP Asynchronous C/C++ Converters
@@ -90,6 +95,7 @@
@{
@defgroup core_hal_intrin_impl Private implementation helpers
@}
+ @defgroup core_lowlevel_api Low-level API for external libraries / plugins
@}
@}
*/
@@ -114,7 +120,7 @@ class CV_EXPORTS Exception : public std::exception
*/
Exception();
/*!
- Full constructor. Normally the constuctor is not called explicitly.
+ Full constructor. Normally the constructor is not called explicitly.
Instead, the macros CV_Error(), CV_Error_() and CV_Assert() are used.
*/
Exception(int _code, const String& _err, const String& _func, const String& _file, int _line);
@@ -123,7 +129,7 @@ class CV_EXPORTS Exception : public std::exception
/*!
\return the error description and the context as a text string.
*/
- virtual const char *what() const throw();
+ virtual const char *what() const throw() CV_OVERRIDE;
void formatMessage();
String msg; ///< the formatted error message
@@ -131,19 +137,19 @@ class CV_EXPORTS Exception : public std::exception
int code; ///< error code @see CVStatus
String err; ///< error description
String func; ///< function name. Available only when the compiler supports getting it
- String file; ///< source file name where the error has occured
- int line; ///< line number in the source file where the error has occured
+ String file; ///< source file name where the error has occurred
+ int line; ///< line number in the source file where the error has occurred
};
/*! @brief Signals an error and raises the exception.
By default the function prints information about the error to stderr,
then it either stops if cv::setBreakOnError() had been called before or raises the exception.
-It is possible to alternate error processing by using cv::redirectError().
+It is possible to alternate error processing by using #redirectError().
@param exc the exception raisen.
@deprecated drop this version
*/
-CV_EXPORTS void error( const Exception& exc );
+CV_EXPORTS CV_NORETURN void error(const Exception& exc);
enum SortFlags { SORT_EVERY_ROW = 0, //!< each matrix row is sorted independently
SORT_EVERY_COLUMN = 1, //!< each matrix column is sorted
@@ -174,7 +180,7 @@ enum CovarFlags {
/**The output covariance matrix is calculated as:
\f[\texttt{scale} \cdot [ \texttt{vects} [0]- \texttt{mean} , \texttt{vects} [1]- \texttt{mean} ,...] \cdot [ \texttt{vects} [0]- \texttt{mean} , \texttt{vects} [1]- \texttt{mean} ,...]^T,\f]
covar will be a square matrix of the same size as the total number of elements in each input
- vector. One and only one of COVAR_SCRAMBLED and COVAR_NORMAL must be specified.*/
+ vector. One and only one of #COVAR_SCRAMBLED and #COVAR_NORMAL must be specified.*/
COVAR_NORMAL = 1,
/** If the flag is specified, the function does not calculate mean from
the input vectors but, instead, uses the passed mean vector. This is useful if mean has been
@@ -210,28 +216,6 @@ enum KmeansFlags {
KMEANS_USE_INITIAL_LABELS = 1
};
-//! type of line
-enum LineTypes {
- FILLED = -1,
- LINE_4 = 4, //!< 4-connected line
- LINE_8 = 8, //!< 8-connected line
- LINE_AA = 16 //!< antialiased line
-};
-
-//! Only a subset of Hershey fonts
-//! are supported
-enum HersheyFonts {
- FONT_HERSHEY_SIMPLEX = 0, //!< normal size sans-serif font
- FONT_HERSHEY_PLAIN = 1, //!< small size sans-serif font
- FONT_HERSHEY_DUPLEX = 2, //!< normal size sans-serif font (more complex than FONT_HERSHEY_SIMPLEX)
- FONT_HERSHEY_COMPLEX = 3, //!< normal size serif font
- FONT_HERSHEY_TRIPLEX = 4, //!< normal size serif font (more complex than FONT_HERSHEY_COMPLEX)
- FONT_HERSHEY_COMPLEX_SMALL = 5, //!< smaller version of FONT_HERSHEY_COMPLEX
- FONT_HERSHEY_SCRIPT_SIMPLEX = 6, //!< hand-writing style font
- FONT_HERSHEY_SCRIPT_COMPLEX = 7, //!< more complex variant of FONT_HERSHEY_SCRIPT_SIMPLEX
- FONT_ITALIC = 16 //!< flag for italic font
-};
-
enum ReduceTypes { REDUCE_SUM = 0, //!< the output is the sum of all rows/columns of the matrix.
REDUCE_AVG = 1, //!< the output is the mean vector of all rows/columns of the matrix.
REDUCE_MAX = 2, //!< the output is the maximum (column/row-wise) of all rows/columns of the matrix.
@@ -265,14 +249,19 @@ Normally, the function is not called directly. It is used inside filtering funct
copyMakeBorder.
@param p 0-based coordinate of the extrapolated pixel along one of the axes, likely \<0 or \>= len
@param len Length of the array along the corresponding axis.
-@param borderType Border type, one of the cv::BorderTypes, except for cv::BORDER_TRANSPARENT and
-cv::BORDER_ISOLATED . When borderType==cv::BORDER_CONSTANT , the function always returns -1, regardless
+@param borderType Border type, one of the #BorderTypes, except for #BORDER_TRANSPARENT and
+#BORDER_ISOLATED . When borderType==#BORDER_CONSTANT , the function always returns -1, regardless
of p and len.
@sa copyMakeBorder
*/
CV_EXPORTS_W int borderInterpolate(int p, int len, int borderType);
+/** @example samples/cpp/tutorial_code/ImgTrans/copyMakeBorder_demo.cpp
+An example using copyMakeBorder function.
+Check @ref tutorial_copyMakeBorder "the corresponding tutorial" for more details
+*/
+
/** @brief Forms a border around an image.
The function copies the source image into the middle of the destination image. The areas to the
@@ -300,14 +289,14 @@ function does not copy src itself but simply constructs the border, for example:
@endcode
@note When the source image is a part (ROI) of a bigger image, the function will try to use the
pixels outside of the ROI to form a border. To disable this feature and always do extrapolation, as
-if src was not a ROI, use borderType | BORDER_ISOLATED.
+if src was not a ROI, use borderType | #BORDER_ISOLATED.
@param src Source image.
@param dst Destination image of the same type as src and the size Size(src.cols+left+right,
src.rows+top+bottom) .
-@param top
-@param bottom
-@param left
+@param top the top pixels
+@param bottom the bottom pixels
+@param left the left pixels
@param right Parameter specifying how many pixels in each direction from the source image rectangle
to extrapolate. For example, top=1, bottom=1, left=1, right=1 mean that 1 pixel-wide border needs
to be built.
@@ -426,13 +415,18 @@ CV_EXPORTS_W void multiply(InputArray src1, InputArray src2,
/** @brief Performs per-element division of two arrays or a scalar by an array.
-The functions divide divide one array by another:
+The function cv::divide divides one array by another:
\f[\texttt{dst(I) = saturate(src1(I)*scale/src2(I))}\f]
or a scalar by an array when there is no src1 :
\f[\texttt{dst(I) = saturate(scale/src2(I))}\f]
-When src2(I) is zero, dst(I) will also be zero. Different channels of
-multi-channel arrays are processed independently.
+Different channels of multi-channel arrays are processed independently.
+
+For integer types when src2(I) is zero, dst(I) will also be zero.
+
+@note In case of floating point data there is no special defined behavior for zero src2(I) values.
+Regular floating-point division is used.
+Expect correct IEEE-754 behaviour for floating-point data (with NaN, Inf result values).
@note Saturation is not applied when the output array has the depth CV_32S. You may even get
result of an incorrect sign in the case of overflow.
@@ -471,6 +465,10 @@ The function can also be emulated with a matrix expression, for example:
*/
CV_EXPORTS_W void scaleAdd(InputArray src1, double alpha, InputArray src2, OutputArray dst);
+/** @example samples/cpp/tutorial_code/HighGUI/AddingImagesTrackbar.cpp
+Check @ref tutorial_trackbar "the corresponding tutorial" for more details
+*/
+
/** @brief Calculates the weighted sum of two arrays.
The function addWeighted calculates the weighted sum of two arrays as follows:
@@ -524,6 +522,18 @@ For example:
CV_EXPORTS_W void convertScaleAbs(InputArray src, OutputArray dst,
double alpha = 1, double beta = 0);
+/** @brief Converts an array to half precision floating number.
+
+This function converts FP32 (single precision floating point) from/to FP16 (half precision floating point). CV_16S format is used to represent FP16 data.
+There are two use modes (src -> dst): CV_32F -> CV_16S and CV_16S -> CV_32F. The input array has to have type of CV_32F or
+CV_16S to represent the bit depth. If the input array is neither of them, the function will raise an error.
+The format of half precision floating point is defined in IEEE 754-2008.
+
+@param src input array.
+@param dst output array.
+*/
+CV_EXPORTS_W void convertFp16(InputArray src, OutputArray dst);
+
/** @brief Performs a look-up table transform of an array.
The function LUT fills the output array with values from the look-up table. Indices of the entries
@@ -542,7 +552,7 @@ CV_EXPORTS_W void LUT(InputArray src, InputArray lut, OutputArray dst);
/** @brief Calculates the sum of array elements.
-The functions sum calculate and return the sum of array elements,
+The function cv::sum calculates and returns the sum of array elements,
independently for each channel.
@param src input array that must have from 1 to 4 channels.
@sa countNonZero, mean, meanStdDev, norm, minMaxLoc, reduce
@@ -581,17 +591,17 @@ or
// access pixel coordinates
Point pnt = locations[i];
@endcode
-@param src single-channel array (type CV_8UC1)
+@param src single-channel array
@param idx the output array, type of cv::Mat or std::vector, corresponding to non-zero indices in the input
*/
CV_EXPORTS_W void findNonZero( InputArray src, OutputArray idx );
/** @brief Calculates an average (mean) of array elements.
-The function mean calculates the mean value M of array elements,
+The function cv::mean calculates the mean value M of array elements,
independently for each channel, and return it:
\f[\begin{array}{l} N = \sum _{I: \; \texttt{mask} (I) \ne 0} 1 \\ M_c = \left ( \sum _{I: \; \texttt{mask} (I) \ne 0}{ \texttt{mtx} (I)_c} \right )/N \end{array}\f]
-When all the mask elements are 0's, the functions return Scalar::all(0)
+When all the mask elements are 0's, the function returns Scalar::all(0)
@param src input array that should have from 1 to 4 channels so that the result can be stored in
Scalar_ .
@param mask optional operation mask.
@@ -601,11 +611,11 @@ CV_EXPORTS_W Scalar mean(InputArray src, InputArray mask = noArray());
/** Calculates a mean and standard deviation of array elements.
-The function meanStdDev calculates the mean and the standard deviation M
+The function cv::meanStdDev calculates the mean and the standard deviation M
of array elements independently for each channel and returns it via the
output parameters:
\f[\begin{array}{l} N = \sum _{I, \texttt{mask} (I) \ne 0} 1 \\ \texttt{mean} _c = \frac{\sum_{ I: \; \texttt{mask}(I) \ne 0} \texttt{src} (I)_c}{N} \\ \texttt{stddev} _c = \sqrt{\frac{\sum_{ I: \; \texttt{mask}(I) \ne 0} \left ( \texttt{src} (I)_c - \texttt{mean} _c \right )^2}{N}} \end{array}\f]
-When all the mask elements are 0's, the functions return
+When all the mask elements are 0's, the function returns
mean=stddev=Scalar::all(0).
@note The calculated standard deviation is only the diagonal of the
complete normalized covariance matrix. If the full matrix is needed, you
@@ -615,69 +625,90 @@ then pass the matrix to calcCovarMatrix .
@param src input array that should have from 1 to 4 channels so that the results can be stored in
Scalar_ 's.
@param mean output parameter: calculated mean value.
-@param stddev output parameter: calculateded standard deviation.
+@param stddev output parameter: calculated standard deviation.
@param mask optional operation mask.
@sa countNonZero, mean, norm, minMaxLoc, calcCovarMatrix
*/
CV_EXPORTS_W void meanStdDev(InputArray src, OutputArray mean, OutputArray stddev,
InputArray mask=noArray());
-/** @brief Calculates an absolute array norm, an absolute difference norm, or a
-relative difference norm.
-
-The functions norm calculate an absolute norm of src1 (when there is no
-src2 ):
-
-\f[norm = \forkthree{\|\texttt{src1}\|_{L_{\infty}} = \max _I | \texttt{src1} (I)|}{if \(\texttt{normType} = \texttt{NORM_INF}\) }
-{ \| \texttt{src1} \| _{L_1} = \sum _I | \texttt{src1} (I)|}{if \(\texttt{normType} = \texttt{NORM_L1}\) }
-{ \| \texttt{src1} \| _{L_2} = \sqrt{\sum_I \texttt{src1}(I)^2} }{if \(\texttt{normType} = \texttt{NORM_L2}\) }\f]
-
-or an absolute or relative difference norm if src2 is there:
-
-\f[norm = \forkthree{\|\texttt{src1}-\texttt{src2}\|_{L_{\infty}} = \max _I | \texttt{src1} (I) - \texttt{src2} (I)|}{if \(\texttt{normType} = \texttt{NORM_INF}\) }
-{ \| \texttt{src1} - \texttt{src2} \| _{L_1} = \sum _I | \texttt{src1} (I) - \texttt{src2} (I)|}{if \(\texttt{normType} = \texttt{NORM_L1}\) }
-{ \| \texttt{src1} - \texttt{src2} \| _{L_2} = \sqrt{\sum_I (\texttt{src1}(I) - \texttt{src2}(I))^2} }{if \(\texttt{normType} = \texttt{NORM_L2}\) }\f]
-
-or
-
-\f[norm = \forkthree{\frac{\|\texttt{src1}-\texttt{src2}\|_{L_{\infty}} }{\|\texttt{src2}\|_{L_{\infty}} }}{if \(\texttt{normType} = \texttt{NORM_RELATIVE_INF}\) }
-{ \frac{\|\texttt{src1}-\texttt{src2}\|_{L_1} }{\|\texttt{src2}\|_{L_1}} }{if \(\texttt{normType} = \texttt{NORM_RELATIVE_L1}\) }
-{ \frac{\|\texttt{src1}-\texttt{src2}\|_{L_2} }{\|\texttt{src2}\|_{L_2}} }{if \(\texttt{normType} = \texttt{NORM_RELATIVE_L2}\) }\f]
-
-The functions norm return the calculated norm.
+/** @brief Calculates the absolute norm of an array.
+
+This version of #norm calculates the absolute norm of src1. The type of norm to calculate is specified using #NormTypes.
+
+As example for one array consider the function \f$r(x)= \begin{pmatrix} x \\ 1-x \end{pmatrix}, x \in [-1;1]\f$.
+The \f$ L_{1}, L_{2} \f$ and \f$ L_{\infty} \f$ norm for the sample value \f$r(-1) = \begin{pmatrix} -1 \\ 2 \end{pmatrix}\f$
+is calculated as follows
+\f{align*}
+ \| r(-1) \|_{L_1} &= |-1| + |2| = 3 \\
+ \| r(-1) \|_{L_2} &= \sqrt{(-1)^{2} + (2)^{2}} = \sqrt{5} \\
+ \| r(-1) \|_{L_\infty} &= \max(|-1|,|2|) = 2
+\f}
+and for \f$r(0.5) = \begin{pmatrix} 0.5 \\ 0.5 \end{pmatrix}\f$ the calculation is
+\f{align*}
+ \| r(0.5) \|_{L_1} &= |0.5| + |0.5| = 1 \\
+ \| r(0.5) \|_{L_2} &= \sqrt{(0.5)^{2} + (0.5)^{2}} = \sqrt{0.5} \\
+ \| r(0.5) \|_{L_\infty} &= \max(|0.5|,|0.5|) = 0.5.
+\f}
+The following graphic shows all values for the three norm functions \f$\| r(x) \|_{L_1}, \| r(x) \|_{L_2}\f$ and \f$\| r(x) \|_{L_\infty}\f$.
+It is notable that the \f$ L_{1} \f$ norm forms the upper and the \f$ L_{\infty} \f$ norm forms the lower border for the example function \f$ r(x) \f$.
+
When the mask parameter is specified and it is not empty, the norm is
+
+If normType is not specified, #NORM_L2 is used.
calculated only over the region specified by the mask.
-A multi-channel input arrays are treated as a single-channel, that is,
+Multi-channel input arrays are treated as single-channel arrays, that is,
the results for all channels are combined.
+Hamming norms can only be calculated with CV_8U depth arrays.
+
@param src1 first input array.
-@param normType type of the norm (see cv::NormTypes).
+@param normType type of the norm (see #NormTypes).
@param mask optional operation mask; it must have the same size as src1 and CV_8UC1 type.
*/
CV_EXPORTS_W double norm(InputArray src1, int normType = NORM_L2, InputArray mask = noArray());
-/** @overload
+/** @brief Calculates an absolute difference norm or a relative difference norm.
+
+This version of cv::norm calculates the absolute difference norm
+or the relative difference norm of arrays src1 and src2.
+The type of norm to calculate is specified using #NormTypes.
+
@param src1 first input array.
@param src2 second input array of the same size and the same type as src1.
-@param normType type of the norm (cv::NormTypes).
+@param normType type of the norm (see #NormTypes).
@param mask optional operation mask; it must have the same size as src1 and CV_8UC1 type.
*/
CV_EXPORTS_W double norm(InputArray src1, InputArray src2,
int normType = NORM_L2, InputArray mask = noArray());
/** @overload
@param src first input array.
-@param normType type of the norm (see cv::NormTypes).
+@param normType type of the norm (see #NormTypes).
*/
CV_EXPORTS double norm( const SparseMat& src, int normType );
-/** @brief computes PSNR image/video quality metric
+/** @brief Computes the Peak Signal-to-Noise Ratio (PSNR) image quality metric.
+
+This function calculates the Peak Signal-to-Noise Ratio (PSNR) image quality metric in decibels (dB),
+between two input arrays src1 and src2. The arrays must have the same type.
+
+The PSNR is calculated as follows:
+
+\f[
+\texttt{PSNR} = 10 \cdot \log_{10}{\left( \frac{R^2}{MSE} \right) }
+\f]
+
+where R is the maximum integer value of depth (e.g. 255 in the case of CV_8U data)
+and MSE is the mean squared error between the two arrays.
+
+@param src1 first input array.
+@param src2 second input array of the same size as src1.
+@param R the maximum pixel value (255 by default)
-see http://en.wikipedia.org/wiki/Peak_signal-to-noise_ratio for details
-@todo document
*/
-CV_EXPORTS_W double PSNR(InputArray src1, InputArray src2);
+CV_EXPORTS_W double PSNR(InputArray src1, InputArray src2, double R=255.);
/** @brief naive nearest neighbor finder
@@ -692,7 +723,7 @@ CV_EXPORTS_W void batchDistance(InputArray src1, InputArray src2,
/** @brief Normalizes the norm or value range of an array.
-The functions normalize scale and shift the input array elements so that
+The function cv::normalize normalizes scale and shift the input array elements so that
\f[\| \texttt{dst} \| _{L_p}= \texttt{alpha}\f]
(where p=Inf, 1 or 2) when normType=NORM_INF, NORM_L1, or NORM_L2, respectively; or so that
\f[\min _I \texttt{dst} (I)= \texttt{alpha} , \, \, \max _I \texttt{dst} (I)= \texttt{beta}\f]
@@ -762,11 +793,11 @@ CV_EXPORTS void normalize( const SparseMat& src, SparseMat& dst, double alpha, i
/** @brief Finds the global minimum and maximum in an array.
-The functions minMaxLoc find the minimum and maximum element values and their positions. The
+The function cv::minMaxLoc finds the minimum and maximum element values and their positions. The
extremums are searched across the whole array or, if mask is not an empty array, in the specified
array region.
-The functions do not work with multi-channel arrays. If you need to find minimum or maximum
+The function do not work with multi-channel arrays. If you need to find minimum or maximum
elements across all the channels, use Mat::reshape first to reinterpret the array as
single-channel. Or you may extract the particular channel using either extractImageCOI , or
mixChannels , or split .
@@ -785,7 +816,7 @@ CV_EXPORTS_W void minMaxLoc(InputArray src, CV_OUT double* minVal,
/** @brief Finds the global minimum and maximum in an array
-The function minMaxIdx finds the minimum and maximum element values and their positions. The
+The function cv::minMaxIdx finds the minimum and maximum element values and their positions. The
extremums are searched across the whole array or, if mask is not an empty array, in the specified
array region. The function does not work with multi-channel arrays. If you need to find minimum or
maximum elements across all the channels, use Mat::reshape first to reinterpret the array as
@@ -823,17 +854,24 @@ CV_EXPORTS void minMaxLoc(const SparseMat& a, double* minVal,
/** @brief Reduces a matrix to a vector.
-The function reduce reduces the matrix to a vector by treating the matrix rows/columns as a set of
+The function #reduce reduces the matrix to a vector by treating the matrix rows/columns as a set of
1D vectors and performing the specified operation on the vectors until a single row/column is
obtained. For example, the function can be used to compute horizontal and vertical projections of a
-raster image. In case of REDUCE_SUM and REDUCE_AVG , the output may have a larger element
-bit-depth to preserve accuracy. And multi-channel arrays are also supported in these two reduction
-modes.
+raster image. In case of #REDUCE_MAX and #REDUCE_MIN , the output image should have the same type as the source one.
+In case of #REDUCE_SUM and #REDUCE_AVG , the output may have a larger element bit-depth to preserve accuracy.
+And multi-channel arrays are also supported in these two reduction modes.
+
+The following code demonstrates its usage for a single channel matrix.
+@snippet snippets/core_reduce.cpp example
+
+And the following code demonstrates its usage for a two-channel matrix.
+@snippet snippets/core_reduce.cpp example2
+
@param src input 2D matrix.
@param dst output vector. Its size and type is defined by dim and dtype parameters.
@param dim dimension index along which the matrix is reduced. 0 means that the matrix is reduced to
a single row. 1 means that the matrix is reduced to a single column.
-@param rtype reduction operation that could be one of cv::ReduceTypes
+@param rtype reduction operation that could be one of #ReduceTypes
@param dtype when negative, the output vector will have the same type as the input matrix,
otherwise, its type will be CV_MAKE_TYPE(CV_MAT_DEPTH(dtype), src.channels()).
@sa repeat
@@ -842,12 +880,16 @@ CV_EXPORTS_W void reduce(InputArray src, OutputArray dst, int dim, int rtype, in
/** @brief Creates one multi-channel array out of several single-channel ones.
-The function merge merges several arrays to make a single multi-channel array. That is, each
+The function cv::merge merges several arrays to make a single multi-channel array. That is, each
element of the output array will be a concatenation of the elements of the input arrays, where
elements of i-th input array are treated as mv[i].channels()-element vectors.
The function cv::split does the reverse operation. If you need to shuffle channels in some other
advanced way, use cv::mixChannels.
+
+The following example shows how to merge 3 single channel matrices into a single 3-channel matrix.
+@snippet snippets/core_merge.cpp example
+
@param mv input array of matrices to be merged; all the matrices in mv must have the same
size and the same depth.
@param count number of input matrices when mv is a plain C array; it must be greater than zero.
@@ -867,10 +909,14 @@ CV_EXPORTS_W void merge(InputArrayOfArrays mv, OutputArray dst);
/** @brief Divides a multi-channel array into several single-channel arrays.
-The functions split split a multi-channel array into separate single-channel arrays:
+The function cv::split splits a multi-channel array into separate single-channel arrays:
\f[\texttt{mv} [c](I) = \texttt{src} (I)_c\f]
If you need to extract a single channel or do some other sophisticated channel permutation, use
mixChannels .
+
+The following example demonstrates how to split a 3-channel matrix into 3 single channel matrices.
+@snippet snippets/core_split.cpp example
+
@param src input multi-channel array.
@param mvbegin output array; the number of arrays must match src.channels(); the arrays themselves are
reallocated, if needed.
@@ -889,7 +935,7 @@ output arrays.
The function cv::mixChannels provides an advanced mechanism for shuffling image channels.
-cv::split and cv::merge and some forms of cv::cvtColor are partial cases of cv::mixChannels .
+cv::split,cv::merge,cv::extractChannel,cv::insertChannel and some forms of cv::cvtColor are partial cases of cv::mixChannels.
In the example below, the code splits a 4-channel BGRA image into a 3-channel BGR (with B and R
channels swapped) and a separate alpha-channel image:
@@ -923,7 +969,7 @@ src[0].channels() + src[1].channels()-1, and so on, the same scheme is used for
channels; as a special case, when fromTo[k\*2] is negative, the corresponding output channel is
filled with zero .
@param npairs number of index pairs in `fromTo`.
-@sa cv::split, cv::merge, cv::cvtColor
+@sa split, merge, extractChannel, insertChannel, cvtColor
*/
CV_EXPORTS void mixChannels(const Mat* src, size_t nsrcs, Mat* dst, size_t ndsts,
const int* fromTo, size_t npairs);
@@ -961,19 +1007,25 @@ filled with zero .
CV_EXPORTS_W void mixChannels(InputArrayOfArrays src, InputOutputArrayOfArrays dst,
const std::vector& fromTo);
-/** @brief extracts a single channel from src (coi is 0-based index)
-@todo document
+/** @brief Extracts a single channel from src (coi is 0-based index)
+@param src input array
+@param dst output array
+@param coi index of channel to extract
+@sa mixChannels, split
*/
CV_EXPORTS_W void extractChannel(InputArray src, OutputArray dst, int coi);
-/** @brief inserts a single channel to dst (coi is 0-based index)
-@todo document
+/** @brief Inserts a single channel to dst (coi is 0-based index)
+@param src input array
+@param dst output array
+@param coi index of channel for insertion
+@sa mixChannels, merge
*/
CV_EXPORTS_W void insertChannel(InputArray src, InputOutputArray dst, int coi);
/** @brief Flips a 2D array around vertical, horizontal, or both axes.
-The function flip flips the array in one of three different ways (row
+The function cv::flip flips the array in one of three different ways (row
and column indices are 0-based):
\f[\texttt{dst} _{ij} =
\left\{
@@ -1005,6 +1057,24 @@ around both axes.
*/
CV_EXPORTS_W void flip(InputArray src, OutputArray dst, int flipCode);
+enum RotateFlags {
+ ROTATE_90_CLOCKWISE = 0, //!
--DBL_MAX and maxVal \< DBL_MAX, the functions also check that each value is between minVal and
+The function cv::checkRange checks that every array element is neither NaN nor infinite. When minVal \>
+-DBL_MAX and maxVal \< DBL_MAX, the function also checks that each value is between minVal and
maxVal. In case of multi-channel arrays, each channel is processed independently. If some values
are out of range, position of the first outlier is stored in pos (when pos != NULL). Then, the
-functions either return false (when quiet=true) or throw an exception.
+function either returns false (when quiet=true) or throws an exception.
@param a input array.
@param quiet a flag, indicating whether the functions quietly return false when the array elements
are out of range or they throw an exception.
@@ -1542,7 +1620,7 @@ CV_EXPORTS_W void patchNaNs(InputOutputArray a, double val = 0);
/** @brief Performs generalized matrix multiplication.
-The function performs generalized matrix multiplication similar to the
+The function cv::gemm performs generalized matrix multiplication similar to the
gemm functions in BLAS level 3. For example,
`gemm(src1, src2, alpha, src3, beta, dst, GEMM_1_T + GEMM_3_T)`
corresponds to
@@ -1573,7 +1651,7 @@ CV_EXPORTS_W void gemm(InputArray src1, InputArray src2, double alpha,
/** @brief Calculates the product of a matrix and its transposition.
-The function mulTransposed calculates the product of src and its
+The function cv::mulTransposed calculates the product of src and its
transposition:
\f[\texttt{dst} = \texttt{scale} ( \texttt{src} - \texttt{delta} )^T ( \texttt{src} - \texttt{delta} )\f]
if aTa=true , and
@@ -1605,9 +1683,9 @@ CV_EXPORTS_W void mulTransposed( InputArray src, OutputArray dst, bool aTa,
/** @brief Transposes a matrix.
-The function transpose transposes the matrix src :
+The function cv::transpose transposes the matrix src :
\f[\texttt{dst} (i,j) = \texttt{src} (j,i)\f]
-@note No complex conjugation is done in case of a complex matrix. It it
+@note No complex conjugation is done in case of a complex matrix. It
should be done separately if needed.
@param src input array.
@param dst output array of the same type as src.
@@ -1616,7 +1694,7 @@ CV_EXPORTS_W void transpose(InputArray src, OutputArray dst);
/** @brief Performs the matrix transformation of every array element.
-The function transform performs the matrix transformation of every
+The function cv::transform performs the matrix transformation of every
element of the array src and stores the results in dst :
\f[\texttt{dst} (I) = \texttt{m} \cdot \texttt{src} (I)\f]
(when m.cols=src.channels() ), or
@@ -1636,13 +1714,13 @@ m.cols or m.cols-1.
@param dst output array of the same size and depth as src; it has as
many channels as m.rows.
@param m transformation 2x2 or 2x3 floating-point matrix.
-@sa perspectiveTransform, getAffineTransform, estimateRigidTransform, warpAffine, warpPerspective
+@sa perspectiveTransform, getAffineTransform, estimateAffine2D, warpAffine, warpPerspective
*/
CV_EXPORTS_W void transform(InputArray src, OutputArray dst, InputArray m );
/** @brief Performs the perspective matrix transformation of vectors.
-The function perspectiveTransform transforms every element of src by
+The function cv::perspectiveTransform transforms every element of src by
treating it as a 2D or 3D vector, in the following way:
\f[(x, y, z) \rightarrow (x'/w, y'/w, z'/w)\f]
where
@@ -1667,24 +1745,25 @@ element is a 2D/3D vector to be transformed.
*/
CV_EXPORTS_W void perspectiveTransform(InputArray src, OutputArray dst, InputArray m );
-/** @brief Copies the lower or the upper half of a square matrix to another half.
+/** @brief Copies the lower or the upper half of a square matrix to its another half.
-The function completeSymm copies the lower half of a square matrix to
+The function cv::completeSymm copies the lower or the upper half of a square matrix to
its another half. The matrix diagonal remains unchanged:
-* \f$\texttt{mtx}_{ij}=\texttt{mtx}_{ji}\f$ for \f$i > j\f$ if
+ - \f$\texttt{m}_{ij}=\texttt{m}_{ji}\f$ for \f$i > j\f$ if
lowerToUpper=false
-* \f$\texttt{mtx}_{ij}=\texttt{mtx}_{ji}\f$ for \f$i < j\f$ if
+ - \f$\texttt{m}_{ij}=\texttt{m}_{ji}\f$ for \f$i < j\f$ if
lowerToUpper=true
-@param mtx input-output floating-point square matrix.
+
+@param m input-output floating-point square matrix.
@param lowerToUpper operation flag; if true, the lower half is copied to
the upper half. Otherwise, the upper half is copied to the lower half.
@sa flip, transpose
*/
-CV_EXPORTS_W void completeSymm(InputOutputArray mtx, bool lowerToUpper = false);
+CV_EXPORTS_W void completeSymm(InputOutputArray m, bool lowerToUpper = false);
/** @brief Initializes a scaled identity matrix.
-The function setIdentity initializes a scaled identity matrix:
+The function cv::setIdentity initializes a scaled identity matrix:
\f[\texttt{mtx} (i,j)= \fork{\texttt{value}}{ if \(i=j\)}{0}{otherwise}\f]
The function can also be emulated using the matrix initializers and the
@@ -1701,7 +1780,7 @@ CV_EXPORTS_W void setIdentity(InputOutputArray mtx, const Scalar& s = Scalar(1))
/** @brief Returns the determinant of a square floating-point matrix.
-The function determinant calculates and returns the determinant of the
+The function cv::determinant calculates and returns the determinant of the
specified matrix. For small matrices ( mtx.cols=mtx.rows\<=3 ), the
direct method is used. For larger matrices, the function uses LU
factorization with partial pivoting.
@@ -1716,7 +1795,7 @@ CV_EXPORTS_W double determinant(InputArray mtx);
/** @brief Returns the trace of a matrix.
-The function trace returns the sum of the diagonal elements of the
+The function cv::trace returns the sum of the diagonal elements of the
matrix mtx .
\f[\mathrm{tr} ( \texttt{mtx} ) = \sum _i \texttt{mtx} (i,i)\f]
@param mtx input matrix.
@@ -1725,20 +1804,20 @@ CV_EXPORTS_W Scalar trace(InputArray mtx);
/** @brief Finds the inverse or pseudo-inverse of a matrix.
-The function invert inverts the matrix src and stores the result in dst
+The function cv::invert inverts the matrix src and stores the result in dst
. When the matrix src is singular or non-square, the function calculates
the pseudo-inverse matrix (the dst matrix) so that norm(src\*dst - I) is
minimal, where I is an identity matrix.
-In case of the DECOMP_LU method, the function returns non-zero value if
+In case of the #DECOMP_LU method, the function returns non-zero value if
the inverse has been successfully calculated and 0 if src is singular.
-In case of the DECOMP_SVD method, the function returns the inverse
+In case of the #DECOMP_SVD method, the function returns the inverse
condition number of src (the ratio of the smallest singular value to the
largest singular value) and 0 if src is singular. The SVD method
calculates a pseudo-inverse matrix if src is singular.
-Similarly to DECOMP_LU, the method DECOMP_CHOLESKY works only with
+Similarly to #DECOMP_LU, the method #DECOMP_CHOLESKY works only with
non-singular square matrices that should also be symmetrical and
positively defined. In this case, the function stores the inverted
matrix in dst and returns non-zero. Otherwise, it returns 0.
@@ -1752,12 +1831,12 @@ CV_EXPORTS_W double invert(InputArray src, OutputArray dst, int flags = DECOMP_L
/** @brief Solves one or more linear systems or least-squares problems.
-The function solve solves a linear system or least-squares problem (the
+The function cv::solve solves a linear system or least-squares problem (the
latter is possible with SVD or QR methods, or by specifying the flag
-DECOMP_NORMAL ):
+#DECOMP_NORMAL ):
\f[\texttt{dst} = \arg \min _X \| \texttt{src1} \cdot \texttt{X} - \texttt{src2} \|\f]
-If DECOMP_LU or DECOMP_CHOLESKY method is used, the function returns 1
+If #DECOMP_LU or #DECOMP_CHOLESKY method is used, the function returns 1
if src1 (or \f$\texttt{src1}^T\texttt{src1}\f$ ) is non-singular. Otherwise,
it returns 0. In the latter case, dst is not valid. Other methods find a
pseudo-solution in case of a singular left-hand side part.
@@ -1769,7 +1848,7 @@ will not do the work. Use SVD::solveZ instead.
@param src1 input matrix on the left-hand side of the system.
@param src2 input matrix on the right-hand side of the system.
@param dst output solution.
-@param flags solution (matrix inversion) method (cv::DecompTypes)
+@param flags solution (matrix inversion) method (#DecompTypes)
@sa invert, SVD, eigen
*/
CV_EXPORTS_W bool solve(InputArray src1, InputArray src2,
@@ -1777,7 +1856,7 @@ CV_EXPORTS_W bool solve(InputArray src1, InputArray src2,
/** @brief Sorts each row or each column of a matrix.
-The function sort sorts each matrix row or each matrix column in
+The function cv::sort sorts each matrix row or each matrix column in
ascending or descending order. So you should pass two operation flags to
get desired behaviour. If you want to sort matrix rows or columns
lexicographically, you can use STL std::sort generic function with the
@@ -1785,14 +1864,14 @@ proper comparison predicate.
@param src input single-channel array.
@param dst output array of the same size and type as src.
-@param flags operation flags, a combination of cv::SortFlags
+@param flags operation flags, a combination of #SortFlags
@sa sortIdx, randShuffle
*/
CV_EXPORTS_W void sort(InputArray src, OutputArray dst, int flags);
/** @brief Sorts each row or each column of a matrix.
-The function sortIdx sorts each matrix row or each matrix column in the
+The function cv::sortIdx sorts each matrix row or each matrix column in the
ascending or descending order. So you should pass two operation flags to
get desired behaviour. Instead of reordering the elements themselves, it
stores the indices of sorted elements in the output array. For example:
@@ -1821,12 +1900,13 @@ The function solveCubic finds the real roots of a cubic equation:
The roots are stored in the roots array.
@param coeffs equation coefficients, an array of 3 or 4 elements.
@param roots output array of real roots that has 1 or 3 elements.
+@return number of real roots. It can be 0, 1 or 2.
*/
CV_EXPORTS_W int solveCubic(InputArray coeffs, OutputArray roots);
/** @brief Finds the real or complex roots of a polynomial equation.
-The function solvePoly finds real and complex roots of a polynomial equation:
+The function cv::solvePoly finds real and complex roots of a polynomial equation:
\f[\texttt{coeffs} [n] x^{n} + \texttt{coeffs} [n-1] x^{n-1} + ... + \texttt{coeffs} [1] x + \texttt{coeffs} [0] = 0\f]
@param coeffs array of polynomial coefficients.
@param roots output (complex) array of roots.
@@ -1836,13 +1916,14 @@ CV_EXPORTS_W double solvePoly(InputArray coeffs, OutputArray roots, int maxIters
/** @brief Calculates eigenvalues and eigenvectors of a symmetric matrix.
-The functions eigen calculate just eigenvalues, or eigenvalues and eigenvectors of the symmetric
+The function cv::eigen calculates just eigenvalues, or eigenvalues and eigenvectors of the symmetric
matrix src:
@code
src*eigenvectors.row(i).t() = eigenvalues.at(i)*eigenvectors.row(i).t()
@endcode
-@note in the new and the old interfaces different ordering of eigenvalues and eigenvectors
-parameters is used.
+
+@note Use cv::eigenNonSymmetric for calculation of real eigenvalues and eigenvectors of non-symmetric matrix.
+
@param src input matrix that must have CV_32FC1 or CV_64FC1 type, square size and be symmetrical
(src ^T^ == src).
@param eigenvalues output vector of eigenvalues of the same type as src; the eigenvalues are stored
@@ -1850,20 +1931,37 @@ in the descending order.
@param eigenvectors output matrix of eigenvectors; it has the same size and type as src; the
eigenvectors are stored as subsequent matrix rows, in the same order as the corresponding
eigenvalues.
-@sa completeSymm , PCA
+@sa eigenNonSymmetric, completeSymm , PCA
*/
CV_EXPORTS_W bool eigen(InputArray src, OutputArray eigenvalues,
OutputArray eigenvectors = noArray());
+/** @brief Calculates eigenvalues and eigenvectors of a non-symmetric matrix (real eigenvalues only).
+
+@note Assumes real eigenvalues.
+
+The function calculates eigenvalues and eigenvectors (optional) of the square matrix src:
+@code
+ src*eigenvectors.row(i).t() = eigenvalues.at(i)*eigenvectors.row(i).t()
+@endcode
+
+@param src input matrix (CV_32FC1 or CV_64FC1 type).
+@param eigenvalues output vector of eigenvalues (type is the same type as src).
+@param eigenvectors output matrix of eigenvectors (type is the same type as src). The eigenvectors are stored as subsequent matrix rows, in the same order as the corresponding eigenvalues.
+@sa eigen
+*/
+CV_EXPORTS_W void eigenNonSymmetric(InputArray src, OutputArray eigenvalues,
+ OutputArray eigenvectors);
+
/** @brief Calculates the covariance matrix of a set of vectors.
-The functions calcCovarMatrix calculate the covariance matrix and, optionally, the mean vector of
+The function cv::calcCovarMatrix calculates the covariance matrix and, optionally, the mean vector of
the set of input vectors.
@param samples samples stored as separate matrices
@param nsamples number of samples
@param covar output covariance matrix of the type ctype and square size.
@param mean input or output (depending on the flags) array as the average value of the input vectors.
-@param flags operation flags as a combination of cv::CovarFlags
+@param flags operation flags as a combination of #CovarFlags
@param ctype type of the matrixl; it equals 'CV_64F' by default.
@sa PCA, mulTransposed, Mahalanobis
@todo InputArrayOfArrays
@@ -1872,11 +1970,11 @@ CV_EXPORTS void calcCovarMatrix( const Mat* samples, int nsamples, Mat& covar, M
int flags, int ctype = CV_64F);
/** @overload
-@note use cv::COVAR_ROWS or cv::COVAR_COLS flag
+@note use #COVAR_ROWS or #COVAR_COLS flag
@param samples samples stored as rows/columns of a single matrix.
@param covar output covariance matrix of the type ctype and square size.
@param mean input or output (depending on the flags) array as the average value of the input vectors.
-@param flags operation flags as a combination of cv::CovarFlags
+@param flags operation flags as a combination of #CovarFlags
@param ctype type of the matrixl; it equals 'CV_64F' by default.
*/
CV_EXPORTS_W void calcCovarMatrix( InputArray samples, OutputArray covar,
@@ -1886,10 +1984,20 @@ CV_EXPORTS_W void calcCovarMatrix( InputArray samples, OutputArray covar,
CV_EXPORTS_W void PCACompute(InputArray data, InputOutputArray mean,
OutputArray eigenvectors, int maxComponents = 0);
+/** wrap PCA::operator() and add eigenvalues output parameter */
+CV_EXPORTS_AS(PCACompute2) void PCACompute(InputArray data, InputOutputArray mean,
+ OutputArray eigenvectors, OutputArray eigenvalues,
+ int maxComponents = 0);
+
/** wrap PCA::operator() */
CV_EXPORTS_W void PCACompute(InputArray data, InputOutputArray mean,
OutputArray eigenvectors, double retainedVariance);
+/** wrap PCA::operator() and add eigenvalues output parameter */
+CV_EXPORTS_AS(PCACompute2) void PCACompute(InputArray data, InputOutputArray mean,
+ OutputArray eigenvectors, OutputArray eigenvalues,
+ double retainedVariance);
+
/** wrap PCA::project */
CV_EXPORTS_W void PCAProject(InputArray data, InputArray mean,
InputArray eigenvectors, OutputArray result);
@@ -1907,10 +2015,10 @@ CV_EXPORTS_W void SVBackSubst( InputArray w, InputArray u, InputArray vt,
/** @brief Calculates the Mahalanobis distance between two vectors.
-The function Mahalanobis calculates and returns the weighted distance between two vectors:
+The function cv::Mahalanobis calculates and returns the weighted distance between two vectors:
\f[d( \texttt{vec1} , \texttt{vec2} )= \sqrt{\sum_{i,j}{\texttt{icovar(i,j)}\cdot(\texttt{vec1}(I)-\texttt{vec2}(I))\cdot(\texttt{vec1(j)}-\texttt{vec2(j)})} }\f]
-The covariance matrix may be calculated using the cv::calcCovarMatrix function and then inverted using
-the invert function (preferably using the cv::DECOMP_SVD method, as the most accurate).
+The covariance matrix may be calculated using the #calcCovarMatrix function and then inverted using
+the invert function (preferably using the #DECOMP_SVD method, as the most accurate).
@param v1 first 1D input vector.
@param v2 second 1D input vector.
@param icovar inverse covariance matrix.
@@ -1919,7 +2027,7 @@ CV_EXPORTS_W double Mahalanobis(InputArray v1, InputArray v2, InputArray icovar)
/** @brief Performs a forward or inverse Discrete Fourier transform of a 1D or 2D floating-point array.
-The function performs one of the following:
+The function cv::dft performs one of the following:
- Forward the Fourier transform of a 1D vector of N elements:
\f[Y = F^{(N)} \cdot X,\f]
where \f$F^{(N)}_{jk}=\exp(-2\pi i j k/N)\f$ and \f$i=\sqrt{-1}\f$
@@ -1940,28 +2048,28 @@ is how 2D *CCS* spectrum looks:
In case of 1D transform of a real vector, the output looks like the first row of the matrix above.
So, the function chooses an operation mode depending on the flags and size of the input array:
-- If DFT_ROWS is set or the input array has a single row or single column, the function
- performs a 1D forward or inverse transform of each row of a matrix when DFT_ROWS is set.
+- If #DFT_ROWS is set or the input array has a single row or single column, the function
+ performs a 1D forward or inverse transform of each row of a matrix when #DFT_ROWS is set.
Otherwise, it performs a 2D transform.
-- If the input array is real and DFT_INVERSE is not set, the function performs a forward 1D or
+- If the input array is real and #DFT_INVERSE is not set, the function performs a forward 1D or
2D transform:
- - When DFT_COMPLEX_OUTPUT is set, the output is a complex matrix of the same size as
+ - When #DFT_COMPLEX_OUTPUT is set, the output is a complex matrix of the same size as
input.
- - When DFT_COMPLEX_OUTPUT is not set, the output is a real matrix of the same size as
+ - When #DFT_COMPLEX_OUTPUT is not set, the output is a real matrix of the same size as
input. In case of 2D transform, it uses the packed format as shown above. In case of a
single 1D transform, it looks like the first row of the matrix above. In case of
- multiple 1D transforms (when using the DFT_ROWS flag), each row of the output matrix
+ multiple 1D transforms (when using the #DFT_ROWS flag), each row of the output matrix
looks like the first row of the matrix above.
-- If the input array is complex and either DFT_INVERSE or DFT_REAL_OUTPUT are not set, the
+- If the input array is complex and either #DFT_INVERSE or #DFT_REAL_OUTPUT are not set, the
output is a complex array of the same size as input. The function performs a forward or
inverse 1D or 2D transform of the whole input array or each row of the input array
independently, depending on the flags DFT_INVERSE and DFT_ROWS.
-- When DFT_INVERSE is set and the input array is real, or it is complex but DFT_REAL_OUTPUT
+- When #DFT_INVERSE is set and the input array is real, or it is complex but #DFT_REAL_OUTPUT
is set, the output is a real array of the same size as input. The function performs a 1D or 2D
inverse transformation of the whole input array or each individual row, depending on the flags
- DFT_INVERSE and DFT_ROWS.
+ #DFT_INVERSE and #DFT_ROWS.
-If DFT_SCALE is set, the scaling is done after the transformation.
+If #DFT_SCALE is set, the scaling is done after the transformation.
Unlike dct , the function supports arrays of arbitrary size. But only those arrays are processed
efficiently, whose sizes can be factorized in a product of small prime numbers (2, 3, and 5 in the
@@ -2027,7 +2135,7 @@ To optimize this sample, consider the following approaches:
- If different tiles in C can be calculated in parallel and, thus, the convolution is done by
parts, the loop can be threaded.
-All of the above improvements have been implemented in matchTemplate and filter2D . Therefore, by
+All of the above improvements have been implemented in #matchTemplate and #filter2D . Therefore, by
using them, you can get the performance even better than with the above theoretically optimal
implementation. Though, those two functions actually calculate cross-correlation, not convolution,
so you need to "flip" the second convolution operand B vertically and horizontally using flip .
@@ -2040,10 +2148,10 @@ so you need to "flip" the second convolution operand B vertically and horizontal
opencv_source/samples/python/dft.py
@param src input array that could be real or complex.
@param dst output array whose size and type depends on the flags .
-@param flags transformation flags, representing a combination of the cv::DftFlags
+@param flags transformation flags, representing a combination of the #DftFlags
@param nonzeroRows when the parameter is not zero, the function assumes that only the first
-nonzeroRows rows of the input array (DFT_INVERSE is not set) or only the first nonzeroRows of the
-output array (DFT_INVERSE is set) contain non-zeros, thus, the function can handle the rest of the
+nonzeroRows rows of the input array (#DFT_INVERSE is not set) or only the first nonzeroRows of the
+output array (#DFT_INVERSE is set) contain non-zeros, thus, the function can handle the rest of the
rows more efficiently and save some time; this technique is very useful for calculating array
cross-correlation or convolution using DFT.
@sa dct , getOptimalDFTSize , mulSpectrums, filter2D , matchTemplate , flip , cartToPolar ,
@@ -2053,13 +2161,13 @@ CV_EXPORTS_W void dft(InputArray src, OutputArray dst, int flags = 0, int nonzer
/** @brief Calculates the inverse Discrete Fourier Transform of a 1D or 2D array.
-idft(src, dst, flags) is equivalent to dft(src, dst, flags | DFT_INVERSE) .
-@note None of dft and idft scales the result by default. So, you should pass DFT_SCALE to one of
+idft(src, dst, flags) is equivalent to dft(src, dst, flags | #DFT_INVERSE) .
+@note None of dft and idft scales the result by default. So, you should pass #DFT_SCALE to one of
dft or idft explicitly to make these transforms mutually inverse.
@sa dft, dct, idct, mulSpectrums, getOptimalDFTSize
@param src input floating-point real or complex array.
@param dst output array whose size and type depend on the flags.
-@param flags operation flags (see dft and cv::DftFlags).
+@param flags operation flags (see dft and #DftFlags).
@param nonzeroRows number of dst rows to process; the rest of the rows have undefined content (see
the convolution sample in dft description.
*/
@@ -2067,7 +2175,7 @@ CV_EXPORTS_W void idft(InputArray src, OutputArray dst, int flags = 0, int nonze
/** @brief Performs a forward or inverse discrete Cosine transform of 1D or 2D array.
-The function dct performs a forward or inverse discrete Cosine transform (DCT) of a 1D or 2D
+The function cv::dct performs a forward or inverse discrete Cosine transform (DCT) of a 1D or 2D
floating-point array:
- Forward Cosine transform of a 1D vector of N elements:
\f[Y = C^{(N)} \cdot X\f]
@@ -2084,9 +2192,9 @@ floating-point array:
\f[X = \left (C^{(N)} \right )^T \cdot X \cdot C^{(N)}\f]
The function chooses the mode of operation by looking at the flags and size of the input array:
-- If (flags & DCT_INVERSE) == 0 , the function does a forward 1D or 2D transform. Otherwise, it
+- If (flags & #DCT_INVERSE) == 0 , the function does a forward 1D or 2D transform. Otherwise, it
is an inverse 1D or 2D transform.
-- If (flags & DCT_ROWS) != 0 , the function performs a 1D transform of each row.
+- If (flags & #DCT_ROWS) != 0 , the function performs a 1D transform of each row.
- If the array is a single column or a single row, the function performs a 1D transform.
- If none of the above is true, the function performs a 2D transform.
@@ -2118,7 +2226,7 @@ CV_EXPORTS_W void idct(InputArray src, OutputArray dst, int flags = 0);
/** @brief Performs the per-element multiplication of two Fourier spectrums.
-The function mulSpectrums performs the per-element multiplication of the two CCS-packed or complex
+The function cv::mulSpectrums performs the per-element multiplication of the two CCS-packed or complex
matrices that are results of a real or complex Fourier transform.
The function, together with dft and idft , may be used to calculate convolution (pass conjB=false )
@@ -2145,7 +2253,7 @@ original one. Arrays whose size is a power-of-two (2, 4, 8, 16, 32, ...) are the
Though, the arrays whose size is a product of 2's, 3's, and 5's (for example, 300 = 5\*5\*3\*2\*2)
are also processed quite efficiently.
-The function getOptimalDFTSize returns the minimum number N that is greater than or equal to vecsize
+The function cv::getOptimalDFTSize returns the minimum number N that is greater than or equal to vecsize
so that the DFT of a vector of size N can be processed efficiently. In the current implementation N
= 2 ^p^ \* 3 ^q^ \* 5 ^r^ for some integer p, q, r.
@@ -2161,7 +2269,7 @@ CV_EXPORTS_W int getOptimalDFTSize(int vecsize);
/** @brief Returns the default random number generator.
-The function theRNG returns the default random number generator. For each thread, there is a
+The function cv::theRNG returns the default random number generator. For each thread, there is a
separate random number generator, so you can use the function safely in multi-thread environments.
If you just need to get a single random number using this generator or initialize an array, you can
use randu or randn instead. But if you are going to generate many random numbers inside a loop, it
@@ -2170,6 +2278,14 @@ is much faster to use this function to retrieve the generator and then use RNG::
*/
CV_EXPORTS RNG& theRNG();
+/** @brief Sets state of default random number generator.
+
+The function cv::setRNGSeed sets state of default random number generator to custom value.
+@param seed new state for default random number generator
+@sa RNG, randu, randn
+*/
+CV_EXPORTS_W void setRNGSeed(int seed);
+
/** @brief Generates a single uniformly-distributed random number or an array of random numbers.
Non-template variant of the function fills the matrix dst with uniformly-distributed
@@ -2184,7 +2300,7 @@ CV_EXPORTS_W void randu(InputOutputArray dst, InputArray low, InputArray high);
/** @brief Fills the array with normally distributed random numbers.
-The function randn fills the matrix dst with normally distributed random numbers with the specified
+The function cv::randn fills the matrix dst with normally distributed random numbers with the specified
mean vector and the standard deviation matrix. The generated random numbers are clipped to fit the
value range of the output array data type.
@param dst output array of random numbers; the array must be pre-allocated and have 1 to 4 channels.
@@ -2197,7 +2313,7 @@ CV_EXPORTS_W void randn(InputOutputArray dst, InputArray mean, InputArray stddev
/** @brief Shuffles the array elements randomly.
-The function randShuffle shuffles the specified 1D array by randomly choosing pairs of elements and
+The function cv::randShuffle shuffles the specified 1D array by randomly choosing pairs of elements and
swapping them. The number of such swap operations will be dst.rows\*dst.cols\*iterFactor .
@param dst input/output numerical 1D array.
@param iterFactor scale factor that determines the number of random swap operations (see the details
@@ -2316,11 +2432,11 @@ class CV_EXPORTS PCA
The operator performs %PCA of the supplied dataset. It is safe to reuse
the same PCA structure for multiple datasets. That is, if the structure
has been previously used with another dataset, the existing internal
- data is reclaimed and the new eigenvalues, @ref eigenvectors , and @ref
+ data is reclaimed and the new @ref eigenvalues, @ref eigenvectors and @ref
mean are allocated and computed.
- The computed eigenvalues are sorted from the largest to the smallest and
- the corresponding eigenvectors are stored as eigenvectors rows.
+ The computed @ref eigenvalues are sorted from the largest to the smallest and
+ the corresponding @ref eigenvectors are stored as eigenvectors rows.
@param data input samples stored as the matrix rows or as the matrix
columns.
@@ -2400,25 +2516,35 @@ class CV_EXPORTS PCA
*/
void backProject(InputArray vec, OutputArray result) const;
- /** @brief write and load PCA matrix
+ /** @brief write PCA objects
-*/
- void write(FileStorage& fs ) const;
- void read(const FileNode& fs);
+ Writes @ref eigenvalues @ref eigenvectors and @ref mean to specified FileStorage
+ */
+ void write(FileStorage& fs) const;
+
+ /** @brief load PCA objects
+
+ Loads @ref eigenvalues @ref eigenvectors and @ref mean from specified FileNode
+ */
+ void read(const FileNode& fn);
Mat eigenvectors; //!< eigenvectors of the covariation matrix
Mat eigenvalues; //!< eigenvalues of the covariation matrix
Mat mean; //!< mean value subtracted before the projection and added after the back projection
};
-/** @example pca.cpp
- An example using %PCA for dimensionality reduction while maintaining an amount of variance
- */
+/** @example samples/cpp/pca.cpp
+An example using %PCA for dimensionality reduction while maintaining an amount of variance
+*/
+
+/** @example samples/cpp/tutorial_code/ml/introduction_to_pca/introduction_to_pca.cpp
+Check @ref tutorial_introduction_to_pca "the corresponding tutorial" for more details
+*/
/**
- @brief Linear Discriminant Analysis
- @todo document this class
- */
+@brief Linear Discriminant Analysis
+@todo document this class
+*/
class CV_EXPORTS LDA
{
public:
@@ -2480,7 +2606,6 @@ class CV_EXPORTS LDA
static Mat subspaceReconstruct(InputArray W, InputArray mean, InputArray src);
protected:
- bool _dataAsRow; // unused, but needed for 3.0 ABI compatibility.
int _num_components;
Mat _eigenvectors;
Mat _eigenvalues;
@@ -2525,7 +2650,7 @@ class CV_EXPORTS SVD
/** @overload
initializes an empty SVD structure and then calls SVD::operator()
- @param src decomposed matrix.
+ @param src decomposed matrix. The depth has to be CV_32F or CV_64F.
@param flags operation flags (SVD::Flags)
*/
SVD( InputArray src, int flags = 0 );
@@ -2538,7 +2663,7 @@ class CV_EXPORTS SVD
different matrices. Each time, if needed, the previous u,`vt` , and w
are reclaimed and the new matrices are created, which is all handled by
Mat::create.
- @param src decomposed matrix.
+ @param src decomposed matrix. The depth has to be CV_32F or CV_64F.
@param flags operation flags (SVD::Flags)
*/
SVD& operator ()( InputArray src, int flags = 0 );
@@ -2554,18 +2679,18 @@ class CV_EXPORTS SVD
SVD::compute(A, w, u, vt);
@endcode
- @param src decomposed matrix
+ @param src decomposed matrix. The depth has to be CV_32F or CV_64F.
@param w calculated singular values
@param u calculated left singular vectors
- @param vt transposed matrix of right singular values
- @param flags operation flags - see SVD::SVD.
+ @param vt transposed matrix of right singular vectors
+ @param flags operation flags - see SVD::Flags.
*/
static void compute( InputArray src, OutputArray w,
OutputArray u, OutputArray vt, int flags = 0 );
/** @overload
computes singular values of a matrix
- @param src decomposed matrix
+ @param src decomposed matrix. The depth has to be CV_32F or CV_64F.
@param w calculated singular values
@param flags operation flags - see SVD::Flags.
*/
@@ -2609,7 +2734,7 @@ class CV_EXPORTS SVD
if you need to solve many linear systems with the same left-hand side
(for example, src ). If all you need is to solve a single system
(possibly with multiple rhs immediately available), simply call solve
- add pass DECOMP_SVD there. It does absolutely the same thing.
+ add pass #DECOMP_SVD there. It does absolutely the same thing.
*/
void backSubst( InputArray rhs, OutputArray dst ) const;
@@ -2716,7 +2841,7 @@ class CV_EXPORTS RNG
double a1 = rng.uniform((double)0, (double)1);
// produces float from [0, 1)
- double b = rng.uniform(0.f, 1.f);
+ float b = rng.uniform(0.f, 1.f);
// produces double from [0, 1)
double c = rng.uniform(0., 1.);
@@ -2732,9 +2857,9 @@ class CV_EXPORTS RNG
want a floating-point random number, but the range boundaries are
integer numbers, either put dots in the end, if they are constants, or
use explicit type cast operators, as in the a1 initialization above.
- @param a lower inclusive boundary of the returned random numbers.
- @param b upper non-inclusive boundary of the returned random numbers.
- */
+ @param a lower inclusive boundary of the returned random number.
+ @param b upper non-inclusive boundary of the returned random number.
+ */
int uniform(int a, int b);
/** @overload */
float uniform(float a, float b);
@@ -2788,13 +2913,15 @@ class CV_EXPORTS RNG
double gaussian(double sigma);
uint64 state;
+
+ bool operator ==(const RNG& other) const;
};
/** @brief Mersenne Twister random number generator
Inspired by http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/MT2002/CODES/mt19937ar.c
@todo document
- */
+*/
class CV_EXPORTS RNG_MT19937
{
public:
@@ -2812,17 +2939,11 @@ class CV_EXPORTS RNG_MT19937
unsigned operator ()(unsigned N);
unsigned operator ()();
- /** @brief returns uniformly distributed integer random number from [a,b) range
-
-*/
+ /** @brief returns uniformly distributed integer random number from [a,b) range*/
int uniform(int a, int b);
- /** @brief returns uniformly distributed floating-point random number from [a,b) range
-
-*/
+ /** @brief returns uniformly distributed floating-point random number from [a,b) range*/
float uniform(float a, float b);
- /** @brief returns uniformly distributed double-precision floating-point random number from [a,b) range
-
-*/
+ /** @brief returns uniformly distributed double-precision floating-point random number from [a,b) range*/
double uniform(double a, double b);
private:
@@ -2836,14 +2957,14 @@ class CV_EXPORTS RNG_MT19937
//! @addtogroup core_cluster
//! @{
-/** @example kmeans.cpp
- An example on K-means clustering
+/** @example samples/cpp/kmeans.cpp
+An example on K-means clustering
*/
/** @brief Finds centers of clusters and groups input samples around the clusters.
The function kmeans implements a k-means algorithm that finds the centers of cluster_count clusters
-and groups the input samples around the clusters. As an output, \f$\texttt{labels}_i\f$ contains a
+and groups the input samples around the clusters. As an output, \f$\texttt{bestLabels}_i\f$ contains a
0-based cluster index for the sample stored in the \f$i^{th}\f$ row of the samples matrix.
@note
@@ -2870,7 +2991,7 @@ function parameter).
after every attempt. The best (minimum) value is chosen and the corresponding labels and the
compactness value are returned by the function. Basically, you can use only the core of the
function, set the number of attempts to 1, initialize labels each time using a custom algorithm,
-pass them with the ( flags = KMEANS_USE_INITIAL_LABELS ) flag, and then choose the best
+pass them with the ( flags = #KMEANS_USE_INITIAL_LABELS ) flag, and then choose the best
(most-compact) clustering.
*/
CV_EXPORTS_W double kmeans( InputArray data, int K, InputOutputArray bestLabels,
@@ -2897,7 +3018,8 @@ class CV_EXPORTS Formatted
class CV_EXPORTS Formatter
{
public:
- enum { FMT_DEFAULT = 0,
+ enum FormatType {
+ FMT_DEFAULT = 0,
FMT_MATLAB = 1,
FMT_CSV = 2,
FMT_PYTHON = 3,
@@ -2909,11 +3031,12 @@ class CV_EXPORTS Formatter
virtual Ptr format(const Mat& mtx) const = 0;
+ virtual void set16fPrecision(int p = 4) = 0;
virtual void set32fPrecision(int p = 8) = 0;
virtual void set64fPrecision(int p = 16) = 0;
virtual void setMultiline(bool ml = true) = 0;
- static Ptr get(int fmt = FMT_DEFAULT);
+ static Ptr get(Formatter::FormatType fmt = FMT_DEFAULT);
};
@@ -2936,7 +3059,7 @@ String& operator << (String& out, const Mat& mtx)
class CV_EXPORTS Algorithm;
-template struct ParamType {};
+template struct ParamType {};
/** @brief This is a base class for all more or less complex algorithms in OpenCV
@@ -2947,32 +3070,9 @@ matching, graph-cut etc.), background subtraction (which can be done using mixtu
models, codebook-based algorithm etc.), optical flow (block matching, Lucas-Kanade, Horn-Schunck
etc.).
-Here is example of SIFT use in your application via Algorithm interface:
-@code
- #include "opencv2/opencv.hpp"
- #include "opencv2/xfeatures2d.hpp"
- using namespace cv::xfeatures2d;
-
- Ptr sift = SIFT::create();
- FileStorage fs("sift_params.xml", FileStorage::READ);
- if( fs.isOpened() ) // if we have file with parameters, read them
- {
- sift->read(fs["sift_params"]);
- fs.release();
- }
- else // else modify the parameters and store them; user can later edit the file to use different parameters
- {
- sift->setContrastThreshold(0.01f); // lower the contrast threshold, compared to the default value
- {
- WriteStructContext ws(fs, "sift_params", CV_NODE_MAP);
- sift->write(fs);
- }
- }
- Mat image = imread("myimage.png", 0), descriptors;
- vector keypoints;
- sift->detectAndCompute(image, noArray(), keypoints, descriptors);
-@endcode
- */
+Here is example of SimpleBlobDetector use in your application via Algorithm interface:
+@snippet snippets/core_various.cpp Algorithm
+*/
class CV_EXPORTS_W Algorithm
{
public:
@@ -2985,26 +3085,32 @@ class CV_EXPORTS_W Algorithm
/** @brief Stores algorithm parameters in a file storage
*/
- virtual void write(FileStorage& fs) const { (void)fs; }
+ virtual void write(FileStorage& fs) const { CV_UNUSED(fs); }
+
+ /** @brief simplified API for language bindings
+ * @overload
+ */
+ CV_WRAP void write(const Ptr& fs, const String& name = String()) const;
/** @brief Reads algorithm parameters from a file storage
*/
- virtual void read(const FileNode& fn) { (void)fn; }
+ CV_WRAP virtual void read(const FileNode& fn) { CV_UNUSED(fn); }
/** @brief Returns true if the Algorithm is empty (e.g. in the very beginning or after unsuccessful read
- */
- virtual bool empty() const { return false; }
+ */
+ CV_WRAP virtual bool empty() const { return false; }
/** @brief Reads algorithm from the file node
- This is static template method of Algorithm. It's usage is following (in the case of SVM):
- @code
- Ptr svm = Algorithm::read(fn);
- @endcode
- In order to make this method work, the derived class must overwrite Algorithm::read(const
- FileNode& fn) and also have static create() method without parameters
- (or with all the optional parameters)
- */
+ This is static template method of Algorithm. It's usage is following (in the case of SVM):
+ @code
+ cv::FileStorage fsRead("example.xml", FileStorage::READ);
+ Ptr svm = Algorithm::read(fsRead.root());
+ @endcode
+ In order to make this method work, the derived class must overwrite Algorithm::read(const
+ FileNode& fn) and also have static create() method without parameters
+ (or with all the optional parameters)
+ */
template static Ptr<_Tp> read(const FileNode& fn)
{
Ptr<_Tp> obj = _Tp::create();
@@ -3014,20 +3120,22 @@ class CV_EXPORTS_W Algorithm
/** @brief Loads algorithm from the file
- @param filename Name of the file to read.
- @param objname The optional name of the node to read (if empty, the first top-level node will be used)
+ @param filename Name of the file to read.
+ @param objname The optional name of the node to read (if empty, the first top-level node will be used)
- This is static template method of Algorithm. It's usage is following (in the case of SVM):
- @code
- Ptr svm = Algorithm::load("my_svm_model.xml");
- @endcode
- In order to make this method work, the derived class must overwrite Algorithm::read(const
- FileNode& fn).
- */
+ This is static template method of Algorithm. It's usage is following (in the case of SVM):
+ @code
+ Ptr svm = Algorithm::load("my_svm_model.xml");
+ @endcode
+ In order to make this method work, the derived class must overwrite Algorithm::read(const
+ FileNode& fn).
+ */
template static Ptr<_Tp> load(const String& filename, const String& objname=String())
{
FileStorage fs(filename, FileStorage::READ);
+ CV_Assert(fs.isOpened());
FileNode fn = objname.empty() ? fs.getFirstTopLevelNode() : fs[objname];
+ if (fn.empty()) return Ptr<_Tp>();
Ptr<_Tp> obj = _Tp::create();
obj->read(fn);
return !obj->empty() ? obj : Ptr<_Tp>();
@@ -3035,14 +3143,14 @@ class CV_EXPORTS_W Algorithm
/** @brief Loads algorithm from a String
- @param strModel The string variable containing the model you want to load.
- @param objname The optional name of the node to read (if empty, the first top-level node will be used)
+ @param strModel The string variable containing the model you want to load.
+ @param objname The optional name of the node to read (if empty, the first top-level node will be used)
- This is static template method of Algorithm. It's usage is following (in the case of SVM):
- @code
- Ptr svm = Algorithm::loadFromString(myStringModel);
- @endcode
- */
+ This is static template method of Algorithm. It's usage is following (in the case of SVM):
+ @code
+ Ptr svm = Algorithm::loadFromString(myStringModel);
+ @endcode
+ */
template static Ptr<_Tp> loadFromString(const String& strModel, const String& objname=String())
{
FileStorage fs(strModel, FileStorage::READ + FileStorage::MEMORY);
@@ -3053,17 +3161,20 @@ class CV_EXPORTS_W Algorithm
}
/** Saves the algorithm to a file.
- In order to make this method work, the derived class must implement Algorithm::write(FileStorage& fs). */
+ In order to make this method work, the derived class must implement Algorithm::write(FileStorage& fs). */
CV_WRAP virtual void save(const String& filename) const;
/** Returns the algorithm string identifier.
- This string is used as top level xml/yml node tag when the object is saved to a file or string. */
+ This string is used as top level xml/yml node tag when the object is saved to a file or string. */
CV_WRAP virtual String getDefaultName() const;
+
+protected:
+ void writeFormat(FileStorage& fs) const;
};
-struct Param {
- enum { INT=0, BOOLEAN=1, REAL=2, STRING=3, MAT=4, MAT_VECTOR=5, ALGORITHM=6, FLOAT=7,
- UNSIGNED_INT=8, UINT64=9, UCHAR=11 };
+enum struct Param {
+ INT=0, BOOLEAN=1, REAL=2, STRING=3, MAT=4, MAT_VECTOR=5, ALGORITHM=6, FLOAT=7,
+ UNSIGNED_INT=8, UINT64=9, UCHAR=11, SCALAR=12
};
@@ -3073,7 +3184,7 @@ template<> struct ParamType
typedef bool const_param_type;
typedef bool member_type;
- enum { type = Param::BOOLEAN };
+ static const Param type = Param::BOOLEAN;
};
template<> struct ParamType
@@ -3081,7 +3192,7 @@ template<> struct ParamType
typedef int const_param_type;
typedef int member_type;
- enum { type = Param::INT };
+ static const Param type = Param::INT;
};
template<> struct ParamType
@@ -3089,7 +3200,7 @@ template<> struct ParamType
typedef double const_param_type;
typedef double member_type;
- enum { type = Param::REAL };
+ static const Param type = Param::REAL;
};
template<> struct ParamType
@@ -3097,7 +3208,7 @@ template<> struct ParamType
typedef const String& const_param_type;
typedef String member_type;
- enum { type = Param::STRING };
+ static const Param type = Param::STRING;
};
template<> struct ParamType
@@ -3105,7 +3216,7 @@ template<> struct ParamType
typedef const Mat& const_param_type;
typedef Mat member_type;
- enum { type = Param::MAT };
+ static const Param type = Param::MAT;
};
template<> struct ParamType >
@@ -3113,7 +3224,7 @@ template<> struct ParamType >
typedef const std::vector& const_param_type;
typedef std::vector member_type;
- enum { type = Param::MAT_VECTOR };
+ static const Param type = Param::MAT_VECTOR;
};
template<> struct ParamType
@@ -3121,7 +3232,7 @@ template<> struct ParamType
typedef const Ptr& const_param_type;
typedef Ptr member_type;
- enum { type = Param::ALGORITHM };
+ static const Param type = Param::ALGORITHM;
};
template<> struct ParamType
@@ -3129,7 +3240,7 @@ template<> struct ParamType
typedef float const_param_type;
typedef float member_type;
- enum { type = Param::FLOAT };
+ static const Param type = Param::FLOAT;
};
template<> struct ParamType
@@ -3137,7 +3248,7 @@ template<> struct ParamType
typedef unsigned const_param_type;
typedef unsigned member_type;
- enum { type = Param::UNSIGNED_INT };
+ static const Param type = Param::UNSIGNED_INT;
};
template<> struct ParamType
@@ -3145,7 +3256,7 @@ template<> struct ParamType
typedef uint64 const_param_type;
typedef uint64 member_type;
- enum { type = Param::UINT64 };
+ static const Param type = Param::UINT64;
};
template<> struct ParamType
@@ -3153,7 +3264,24 @@ template<> struct ParamType
typedef uchar const_param_type;
typedef uchar member_type;
- enum { type = Param::UCHAR };
+ static const Param type = Param::UCHAR;
+};
+
+template<> struct ParamType
+{
+ typedef const Scalar& const_param_type;
+ typedef Scalar member_type;
+
+ static const Param type = Param::SCALAR;
+};
+
+template
+struct ParamType<_Tp, typename std::enable_if< std::is_enum<_Tp>::value >::type>
+{
+ typedef typename std::underlying_type<_Tp>::type const_param_type;
+ typedef typename std::underlying_type<_Tp>::type member_type;
+
+ static const Param type = Param::INT;
};
//! @} core_basic
@@ -3164,5 +3292,6 @@ template<> struct ParamType
#include "opencv2/core/cvstd.inl.hpp"
#include "opencv2/core/utility.hpp"
#include "opencv2/core/optim.hpp"
+#include "opencv2/core/ovx.hpp"
-#endif /*__OPENCV_CORE_HPP__*/
+#endif /*OPENCV_CORE_HPP*/
diff --git a/IPL/include/opencv/opencv2/core/affine.hpp b/IPL/include/opencv/opencv2/core/affine.hpp
index 7f8deb5..7e2ed30 100644
--- a/IPL/include/opencv/opencv2/core/affine.hpp
+++ b/IPL/include/opencv/opencv2/core/affine.hpp
@@ -41,8 +41,8 @@
//
//M*/
-#ifndef __OPENCV_CORE_AFFINE3_HPP__
-#define __OPENCV_CORE_AFFINE3_HPP__
+#ifndef OPENCV_CORE_AFFINE3_HPP
+#define OPENCV_CORE_AFFINE3_HPP
#ifdef __cplusplus
@@ -55,7 +55,72 @@ namespace cv
//! @{
/** @brief Affine transform
- @todo document
+ *
+ * It represents a 4x4 homogeneous transformation matrix \f$T\f$
+ *
+ * \f[T =
+ * \begin{bmatrix}
+ * R & t\\
+ * 0 & 1\\
+ * \end{bmatrix}
+ * \f]
+ *
+ * where \f$R\f$ is a 3x3 rotation matrix and \f$t\f$ is a 3x1 translation vector.
+ *
+ * You can specify \f$R\f$ either by a 3x3 rotation matrix or by a 3x1 rotation vector,
+ * which is converted to a 3x3 rotation matrix by the Rodrigues formula.
+ *
+ * To construct a matrix \f$T\f$ representing first rotation around the axis \f$r\f$ with rotation
+ * angle \f$|r|\f$ in radian (right hand rule) and then translation by the vector \f$t\f$, you can use
+ *
+ * @code
+ * cv::Vec3f r, t;
+ * cv::Affine3f T(r, t);
+ * @endcode
+ *
+ * If you already have the rotation matrix \f$R\f$, then you can use
+ *
+ * @code
+ * cv::Matx33f R;
+ * cv::Affine3f T(R, t);
+ * @endcode
+ *
+ * To extract the rotation matrix \f$R\f$ from \f$T\f$, use
+ *
+ * @code
+ * cv::Matx33f R = T.rotation();
+ * @endcode
+ *
+ * To extract the translation vector \f$t\f$ from \f$T\f$, use
+ *
+ * @code
+ * cv::Vec3f t = T.translation();
+ * @endcode
+ *
+ * To extract the rotation vector \f$r\f$ from \f$T\f$, use
+ *
+ * @code
+ * cv::Vec3f r = T.rvec();
+ * @endcode
+ *
+ * Note that since the mapping from rotation vectors to rotation matrices
+ * is many to one. The returned rotation vector is not necessarily the one
+ * you used before to set the matrix.
+ *
+ * If you have two transformations \f$T = T_1 * T_2\f$, use
+ *
+ * @code
+ * cv::Affine3f T, T1, T2;
+ * T = T2.concatenate(T1);
+ * @endcode
+ *
+ * To get the inverse transform of \f$T\f$, use
+ *
+ * @code
+ * cv::Affine3f T, T_inv;
+ * T_inv = T.inv();
+ * @endcode
+ *
*/
template
class Affine3
@@ -66,45 +131,127 @@ namespace cv
typedef Matx Mat4;
typedef Vec Vec3;
+ //! Default constructor. It represents a 4x4 identity matrix.
Affine3();
//! Augmented affine matrix
Affine3(const Mat4& affine);
- //! Rotation matrix
+ /**
+ * The resulting 4x4 matrix is
+ *
+ * \f[
+ * \begin{bmatrix}
+ * R & t\\
+ * 0 & 1\\
+ * \end{bmatrix}
+ * \f]
+ *
+ * @param R 3x3 rotation matrix.
+ * @param t 3x1 translation vector.
+ */
Affine3(const Mat3& R, const Vec3& t = Vec3::all(0));
- //! Rodrigues vector
+ /**
+ * Rodrigues vector.
+ *
+ * The last row of the current matrix is set to [0,0,0,1].
+ *
+ * @param rvec 3x1 rotation vector. Its direction indicates the rotation axis and its length
+ * indicates the rotation angle in radian (using right hand rule).
+ * @param t 3x1 translation vector.
+ */
Affine3(const Vec3& rvec, const Vec3& t = Vec3::all(0));
- //! Combines all contructors above. Supports 4x4, 4x3, 3x3, 1x3, 3x1 sizes of data matrix
+ /**
+ * Combines all constructors above. Supports 4x4, 3x4, 3x3, 1x3, 3x1 sizes of data matrix.
+ *
+ * The last row of the current matrix is set to [0,0,0,1] when data is not 4x4.
+ *
+ * @param data 1-channel matrix.
+ * when it is 4x4, it is copied to the current matrix and t is not used.
+ * When it is 3x4, it is copied to the upper part 3x4 of the current matrix and t is not used.
+ * When it is 3x3, it is copied to the upper left 3x3 part of the current matrix.
+ * When it is 3x1 or 1x3, it is treated as a rotation vector and the Rodrigues formula is used
+ * to compute a 3x3 rotation matrix.
+ * @param t 3x1 translation vector. It is used only when data is neither 4x4 nor 3x4.
+ */
explicit Affine3(const Mat& data, const Vec3& t = Vec3::all(0));
- //! From 16th element array
+ //! From 16-element array
explicit Affine3(const float_type* vals);
- //! Create identity transform
+ //! Create an 4x4 identity transform
static Affine3 Identity();
- //! Rotation matrix
+ /**
+ * Rotation matrix.
+ *
+ * Copy the rotation matrix to the upper left 3x3 part of the current matrix.
+ * The remaining elements of the current matrix are not changed.
+ *
+ * @param R 3x3 rotation matrix.
+ *
+ */
void rotation(const Mat3& R);
- //! Rodrigues vector
+ /**
+ * Rodrigues vector.
+ *
+ * It sets the upper left 3x3 part of the matrix. The remaining part is unaffected.
+ *
+ * @param rvec 3x1 rotation vector. The direction indicates the rotation axis and
+ * its length indicates the rotation angle in radian (using the right thumb convention).
+ */
void rotation(const Vec3& rvec);
- //! Combines rotation methods above. Suports 3x3, 1x3, 3x1 sizes of data matrix;
+ /**
+ * Combines rotation methods above. Supports 3x3, 1x3, 3x1 sizes of data matrix.
+ *
+ * It sets the upper left 3x3 part of the matrix. The remaining part is unaffected.
+ *
+ * @param data 1-channel matrix.
+ * When it is a 3x3 matrix, it sets the upper left 3x3 part of the current matrix.
+ * When it is a 1x3 or 3x1 matrix, it is used as a rotation vector. The Rodrigues formula
+ * is used to compute the rotation matrix and sets the upper left 3x3 part of the current matrix.
+ */
void rotation(const Mat& data);
+ /**
+ * Copy the 3x3 matrix L to the upper left part of the current matrix
+ *
+ * It sets the upper left 3x3 part of the matrix. The remaining part is unaffected.
+ *
+ * @param L 3x3 matrix.
+ */
void linear(const Mat3& L);
+
+ /**
+ * Copy t to the first three elements of the last column of the current matrix
+ *
+ * It sets the upper right 3x1 part of the matrix. The remaining part is unaffected.
+ *
+ * @param t 3x1 translation vector.
+ */
void translation(const Vec3& t);
+ //! @return the upper left 3x3 part
Mat3 rotation() const;
+
+ //! @return the upper left 3x3 part
Mat3 linear() const;
+
+ //! @return the upper right 3x1 part
Vec3 translation() const;
- //! Rodrigues vector
+ //! Rodrigues vector.
+ //! @return a vector representing the upper left 3x3 rotation matrix of the current matrix.
+ //! @warning Since the mapping between rotation vectors and rotation matrices is many to one,
+ //! this function returns only one rotation vector that represents the current rotation matrix,
+ //! which is not necessarily the same one set by `rotation(const Vec3& rvec)`.
Vec3 rvec() const;
+ //! @return the inverse of the current matrix.
Affine3 inv(int method = cv::DECOMP_SVD) const;
//! a.rotate(R) is equivalent to Affine(R, 0) * a;
@@ -113,7 +260,7 @@ namespace cv
//! a.rotate(rvec) is equivalent to Affine(rvec, 0) * a;
Affine3 rotate(const Vec3& rvec) const;
- //! a.translate(t) is equivalent to Affine(E, t) * a;
+ //! a.translate(t) is equivalent to Affine(E, t) * a, where E is an identity matrix
Affine3 translate(const Vec3& t) const;
//! a.concatenate(affine) is equivalent to affine * a;
@@ -136,6 +283,7 @@ namespace cv
template static
Affine3 operator*(const Affine3& affine1, const Affine3& affine2);
+ //! V is a 3-element vector with member fields x, y and z
template static
V operator*(const Affine3& affine, const V& vector);
@@ -153,15 +301,24 @@ namespace cv
typedef _Tp channel_type;
enum { generic_type = 0,
- depth = DataType::depth,
channels = 16,
- fmt = DataType::fmt + ((channels - 1) << 8),
- type = CV_MAKETYPE(depth, channels)
+ fmt = traits::SafeFmt::fmt + ((channels - 1) << 8)
+#ifdef OPENCV_TRAITS_ENABLE_DEPRECATED
+ ,depth = DataType::depth
+ ,type = CV_MAKETYPE(depth, channels)
+#endif
};
typedef Vec vec_type;
};
+ namespace traits {
+ template
+ struct Depth< Affine3<_Tp> > { enum { value = Depth<_Tp>::value }; };
+ template
+ struct Type< Affine3<_Tp> > { enum { value = CV_MAKETYPE(Depth<_Tp>::value, 16) }; };
+ } // namespace
+
//! @} core
}
@@ -169,7 +326,7 @@ namespace cv
//! @cond IGNORED
///////////////////////////////////////////////////////////////////////////////////
-// Implementaiton
+// Implementation
template inline
cv::Affine3::Affine3()
@@ -202,7 +359,8 @@ cv::Affine3::Affine3(const Vec3& _rvec, const Vec3& t)
template inline
cv::Affine3::Affine3(const cv::Mat& data, const Vec3& t)
{
- CV_Assert(data.type() == cv::DataType::type);
+ CV_Assert(data.type() == cv::traits::Type::value);
+ CV_Assert(data.channels() == 1);
if (data.cols == 4 && data.rows == 4)
{
@@ -213,11 +371,13 @@ cv::Affine3::Affine3(const cv::Mat& data, const Vec3& t)
{
rotation(data(Rect(0, 0, 3, 3)));
translation(data(Rect(3, 0, 1, 3)));
- return;
+ }
+ else
+ {
+ rotation(data);
+ translation(t);
}
- rotation(data);
- translation(t);
matrix.val[12] = matrix.val[13] = matrix.val[14] = 0;
matrix.val[15] = 1;
}
@@ -265,11 +425,12 @@ void cv::Affine3::rotation(const Vec3& _rvec)
}
}
-//Combines rotation methods above. Suports 3x3, 1x3, 3x1 sizes of data matrix;
+//Combines rotation methods above. Supports 3x3, 1x3, 3x1 sizes of data matrix;
template inline
void cv::Affine3::rotation(const cv::Mat& data)
{
- CV_Assert(data.type() == cv::DataType::type);
+ CV_Assert(data.type() == cv::traits::Type::value);
+ CV_Assert(data.channels() == 1);
if (data.cols == 3 && data.rows == 3)
{
@@ -284,7 +445,7 @@ void cv::Affine3::rotation(const cv::Mat& data)
rotation(_rvec);
}
else
- CV_Assert(!"Input marix can be 3x3, 1x3 or 3x1");
+ CV_Error(Error::StsError, "Input matrix can only be 3x3, 1x3 or 3x1");
}
template inline
@@ -483,21 +644,21 @@ cv::Vec3d cv::operator*(const cv::Affine3d& affine, const cv::Vec3d& v)
template inline
cv::Affine3::Affine3(const Eigen::Transform& affine)
{
- cv::Mat(4, 4, cv::DataType::type, affine.matrix().data()).copyTo(matrix);
+ cv::Mat(4, 4, cv::traits::Type::value, affine.matrix().data()).copyTo(matrix);
}
template inline
cv::Affine3::Affine3(const Eigen::Transform& affine)
{
Eigen::Transform a = affine;
- cv::Mat(4, 4, cv::DataType::type, a.matrix().data()).copyTo(matrix);
+ cv::Mat(4, 4, cv::traits::Type::value, a.matrix().data()).copyTo(matrix);
}
template inline
cv::Affine3::operator Eigen::Transform() const
{
Eigen::Transform r;
- cv::Mat hdr(4, 4, cv::DataType::type, r.matrix().data());
+ cv::Mat hdr(4, 4, cv::traits::Type::value, r.matrix().data());
cv::Mat(matrix, false).copyTo(hdr);
return r;
}
@@ -514,4 +675,4 @@ cv::Affine3::operator Eigen::Transform() const
#endif /* __cplusplus */
-#endif /* __OPENCV_CORE_AFFINE3_HPP__ */
+#endif /* OPENCV_CORE_AFFINE3_HPP */
diff --git a/IPL/include/opencv/opencv2/core/async.hpp b/IPL/include/opencv/opencv2/core/async.hpp
new file mode 100644
index 0000000..54560c7
--- /dev/null
+++ b/IPL/include/opencv/opencv2/core/async.hpp
@@ -0,0 +1,105 @@
+// This file is part of OpenCV project.
+// It is subject to the license terms in the LICENSE file found in the top-level directory
+// of this distribution and at http://opencv.org/license.html.
+
+#ifndef OPENCV_CORE_ASYNC_HPP
+#define OPENCV_CORE_ASYNC_HPP
+
+#include
+
+#ifdef CV_CXX11
+//#include
+#include
+#endif
+
+namespace cv {
+
+/** @addtogroup core_async
+
+@{
+*/
+
+
+/** @brief Returns result of asynchronous operations
+
+Object has attached asynchronous state.
+Assignment operator doesn't clone asynchronous state (it is shared between all instances).
+
+Result can be fetched via get() method only once.
+
+*/
+class CV_EXPORTS_W AsyncArray
+{
+public:
+ ~AsyncArray() CV_NOEXCEPT;
+ CV_WRAP AsyncArray() CV_NOEXCEPT;
+ AsyncArray(const AsyncArray& o) CV_NOEXCEPT;
+ AsyncArray& operator=(const AsyncArray& o) CV_NOEXCEPT;
+ CV_WRAP void release() CV_NOEXCEPT;
+
+ /** Fetch the result.
+ @param[out] dst destination array
+
+ Waits for result until container has valid result.
+ Throws exception if exception was stored as a result.
+
+ Throws exception on invalid container state.
+
+ @note Result or stored exception can be fetched only once.
+ */
+ CV_WRAP void get(OutputArray dst) const;
+
+ /** Retrieving the result with timeout
+ @param[out] dst destination array
+ @param[in] timeoutNs timeout in nanoseconds, -1 for infinite wait
+
+ @returns true if result is ready, false if the timeout has expired
+
+ @note Result or stored exception can be fetched only once.
+ */
+ bool get(OutputArray dst, int64 timeoutNs) const;
+
+ CV_WRAP inline
+ bool get(OutputArray dst, double timeoutNs) const { return get(dst, (int64)timeoutNs); }
+
+ bool wait_for(int64 timeoutNs) const;
+
+ CV_WRAP inline
+ bool wait_for(double timeoutNs) const { return wait_for((int64)timeoutNs); }
+
+ CV_WRAP bool valid() const CV_NOEXCEPT;
+
+#ifdef CV_CXX11
+ inline AsyncArray(AsyncArray&& o) { p = o.p; o.p = NULL; }
+ inline AsyncArray& operator=(AsyncArray&& o) CV_NOEXCEPT { std::swap(p, o.p); return *this; }
+
+ template
+ inline bool get(OutputArray dst, const std::chrono::duration<_Rep, _Period>& timeout)
+ {
+ return get(dst, (int64)(std::chrono::nanoseconds(timeout).count()));
+ }
+
+ template
+ inline bool wait_for(const std::chrono::duration<_Rep, _Period>& timeout)
+ {
+ return wait_for((int64)(std::chrono::nanoseconds(timeout).count()));
+ }
+
+#if 0
+ std::future getFutureMat() const;
+ std::future getFutureUMat() const;
+#endif
+#endif
+
+
+ // PImpl
+ struct Impl; friend struct Impl;
+ inline void* _getImpl() const CV_NOEXCEPT { return p; }
+protected:
+ Impl* p;
+};
+
+
+//! @}
+} // namespace
+#endif // OPENCV_CORE_ASYNC_HPP
diff --git a/IPL/include/opencv/opencv2/core/base.hpp b/IPL/include/opencv/opencv2/core/base.hpp
index ed633f5..a3a3e51 100644
--- a/IPL/include/opencv/opencv2/core/base.hpp
+++ b/IPL/include/opencv/opencv2/core/base.hpp
@@ -42,13 +42,15 @@
//
//M*/
-#ifndef __OPENCV_CORE_BASE_HPP__
-#define __OPENCV_CORE_BASE_HPP__
+#ifndef OPENCV_CORE_BASE_HPP
+#define OPENCV_CORE_BASE_HPP
#ifndef __cplusplus
# error base.hpp header must be compiled as C++
#endif
+#include "opencv2/opencv_modules.hpp"
+
#include
#include
@@ -64,38 +66,38 @@ namespace cv
namespace Error {
//! error codes
enum Code {
- StsOk= 0, //!< everithing is ok
+ StsOk= 0, //!< everything is ok
StsBackTrace= -1, //!< pseudo error for back trace
StsError= -2, //!< unknown /unspecified error
StsInternal= -3, //!< internal error (bad state)
StsNoMem= -4, //!< insufficient memory
StsBadArg= -5, //!< function arg/param is bad
StsBadFunc= -6, //!< unsupported function
- StsNoConv= -7, //!< iter. didn't converge
+ StsNoConv= -7, //!< iteration didn't converge
StsAutoTrace= -8, //!< tracing
HeaderIsNull= -9, //!< image header is NULL
BadImageSize= -10, //!< image size is invalid
BadOffset= -11, //!< offset is invalid
BadDataPtr= -12, //!<
- BadStep= -13, //!<
+ BadStep= -13, //!< image step is wrong, this may happen for a non-continuous matrix.
BadModelOrChSeq= -14, //!<
- BadNumChannels= -15, //!<
+ BadNumChannels= -15, //!< bad number of channels, for example, some functions accept only single channel matrices.
BadNumChannel1U= -16, //!<
- BadDepth= -17, //!<
+ BadDepth= -17, //!< input image depth is not supported by the function
BadAlphaChannel= -18, //!<
- BadOrder= -19, //!<
- BadOrigin= -20, //!<
- BadAlign= -21, //!<
+ BadOrder= -19, //!< number of dimensions is out of range
+ BadOrigin= -20, //!< incorrect input origin
+ BadAlign= -21, //!< incorrect input align
BadCallBack= -22, //!<
BadTileSize= -23, //!<
- BadCOI= -24, //!<
- BadROISize= -25, //!<
+ BadCOI= -24, //!< input COI is not supported
+ BadROISize= -25, //!< incorrect input roi
MaskIsTiled= -26, //!<
StsNullPtr= -27, //!< null pointer
StsVecLengthErr= -28, //!< incorrect vector length
- StsFilterStructContentErr= -29, //!< incorr. filter structure content
- StsKernelStructContentErr= -30, //!< incorr. transform kernel content
- StsFilterOffsetErr= -31, //!< incorrect filter ofset value
+ StsFilterStructContentErr= -29, //!< incorrect filter structure content
+ StsKernelStructContentErr= -30, //!< incorrect transform kernel content
+ StsFilterOffsetErr= -31, //!< incorrect filter offset value
StsBadSize= -201, //!< the input/output structure size is incorrect
StsDivByZero= -202, //!< division by zero
StsInplaceNotSupported= -203, //!< in-place operation is not supported
@@ -111,13 +113,13 @@ enum Code {
StsNotImplemented= -213, //!< the requested function/feature is not implemented
StsBadMemBlock= -214, //!< an allocated block has been corrupted
StsAssert= -215, //!< assertion failed
- GpuNotSupported= -216,
- GpuApiCallError= -217,
- OpenGlNotSupported= -218,
- OpenGlApiCallError= -219,
- OpenCLApiCallError= -220,
+ GpuNotSupported= -216, //!< no CUDA support
+ GpuApiCallError= -217, //!< GPU API call error
+ OpenGlNotSupported= -218, //!< no OpenGL support
+ OpenGlApiCallError= -219, //!< OpenGL API call error
+ OpenCLApiCallError= -220, //!< OpenCL API call error
OpenCLDoubleNotSupported= -221,
- OpenCLInitError= -222,
+ OpenCLInitError= -222, //!< OpenCL initialization error
OpenCLNoAMDBlasFft= -223
};
} //Error
@@ -150,46 +152,57 @@ enum DecompTypes {
};
/** norm types
-- For one array:
-\f[norm = \forkthree{\|\texttt{src1}\|_{L_{\infty}} = \max _I | \texttt{src1} (I)|}{if \(\texttt{normType} = \texttt{NORM_INF}\) }
-{ \| \texttt{src1} \| _{L_1} = \sum _I | \texttt{src1} (I)|}{if \(\texttt{normType} = \texttt{NORM_L1}\) }
-{ \| \texttt{src1} \| _{L_2} = \sqrt{\sum_I \texttt{src1}(I)^2} }{if \(\texttt{normType} = \texttt{NORM_L2}\) }\f]
-
-- Absolute norm for two arrays
-\f[norm = \forkthree{\|\texttt{src1}-\texttt{src2}\|_{L_{\infty}} = \max _I | \texttt{src1} (I) - \texttt{src2} (I)|}{if \(\texttt{normType} = \texttt{NORM_INF}\) }
-{ \| \texttt{src1} - \texttt{src2} \| _{L_1} = \sum _I | \texttt{src1} (I) - \texttt{src2} (I)|}{if \(\texttt{normType} = \texttt{NORM_L1}\) }
-{ \| \texttt{src1} - \texttt{src2} \| _{L_2} = \sqrt{\sum_I (\texttt{src1}(I) - \texttt{src2}(I))^2} }{if \(\texttt{normType} = \texttt{NORM_L2}\) }\f]
-
-- Relative norm for two arrays
-\f[norm = \forkthree{\frac{\|\texttt{src1}-\texttt{src2}\|_{L_{\infty}} }{\|\texttt{src2}\|_{L_{\infty}} }}{if \(\texttt{normType} = \texttt{NORM_RELATIVE_INF}\) }
-{ \frac{\|\texttt{src1}-\texttt{src2}\|_{L_1} }{\|\texttt{src2}\|_{L_1}} }{if \(\texttt{normType} = \texttt{NORM_RELATIVE_L1}\) }
-{ \frac{\|\texttt{src1}-\texttt{src2}\|_{L_2} }{\|\texttt{src2}\|_{L_2}} }{if \(\texttt{normType} = \texttt{NORM_RELATIVE_L2}\) }\f]
-
-As example for one array consider the function \f$r(x)= \begin{pmatrix} x \\ 1-x \end{pmatrix}, x \in [-1;1]\f$.
-The \f$ L_{1}, L_{2} \f$ and \f$ L_{\infty} \f$ norm for the sample value \f$r(-1) = \begin{pmatrix} -1 \\ 2 \end{pmatrix}\f$
-is calculated as follows
-\f{align*}
- \| r(-1) \|_{L_1} &= |-1| + |2| = 3 \\
- \| r(-1) \|_{L_2} &= \sqrt{(-1)^{2} + (2)^{2}} = \sqrt{5} \\
- \| r(-1) \|_{L_\infty} &= \max(|-1|,|2|) = 2
-\f}
-and for \f$r(0.5) = \begin{pmatrix} 0.5 \\ 0.5 \end{pmatrix}\f$ the calculation is
-\f{align*}
- \| r(0.5) \|_{L_1} &= |0.5| + |0.5| = 1 \\
- \| r(0.5) \|_{L_2} &= \sqrt{(0.5)^{2} + (0.5)^{2}} = \sqrt{0.5} \\
- \| r(0.5) \|_{L_\infty} &= \max(|0.5|,|0.5|) = 0.5.
-\f}
-The following graphic shows all values for the three norm functions \f$\| r(x) \|_{L_1}, \| r(x) \|_{L_2}\f$ and \f$\| r(x) \|_{L_\infty}\f$.
-It is notable that the \f$ L_{1} \f$ norm forms the upper and the \f$ L_{\infty} \f$ norm forms the lower border for the example function \f$ r(x) \f$.
-
- */
-enum NormTypes { NORM_INF = 1,
+
+src1 and src2 denote input arrays.
+*/
+
+enum NormTypes {
+ /**
+ \f[
+ norm = \forkthree
+ {\|\texttt{src1}\|_{L_{\infty}} = \max _I | \texttt{src1} (I)|}{if \(\texttt{normType} = \texttt{NORM_INF}\) }
+ {\|\texttt{src1}-\texttt{src2}\|_{L_{\infty}} = \max _I | \texttt{src1} (I) - \texttt{src2} (I)|}{if \(\texttt{normType} = \texttt{NORM_INF}\) }
+ {\frac{\|\texttt{src1}-\texttt{src2}\|_{L_{\infty}} }{\|\texttt{src2}\|_{L_{\infty}} }}{if \(\texttt{normType} = \texttt{NORM_RELATIVE | NORM_INF}\) }
+ \f]
+ */
+ NORM_INF = 1,
+ /**
+ \f[
+ norm = \forkthree
+ {\| \texttt{src1} \| _{L_1} = \sum _I | \texttt{src1} (I)|}{if \(\texttt{normType} = \texttt{NORM_L1}\)}
+ { \| \texttt{src1} - \texttt{src2} \| _{L_1} = \sum _I | \texttt{src1} (I) - \texttt{src2} (I)|}{if \(\texttt{normType} = \texttt{NORM_L1}\) }
+ { \frac{\|\texttt{src1}-\texttt{src2}\|_{L_1} }{\|\texttt{src2}\|_{L_1}} }{if \(\texttt{normType} = \texttt{NORM_RELATIVE | NORM_L1}\) }
+ \f]*/
NORM_L1 = 2,
+ /**
+ \f[
+ norm = \forkthree
+ { \| \texttt{src1} \| _{L_2} = \sqrt{\sum_I \texttt{src1}(I)^2} }{if \(\texttt{normType} = \texttt{NORM_L2}\) }
+ { \| \texttt{src1} - \texttt{src2} \| _{L_2} = \sqrt{\sum_I (\texttt{src1}(I) - \texttt{src2}(I))^2} }{if \(\texttt{normType} = \texttt{NORM_L2}\) }
+ { \frac{\|\texttt{src1}-\texttt{src2}\|_{L_2} }{\|\texttt{src2}\|_{L_2}} }{if \(\texttt{normType} = \texttt{NORM_RELATIVE | NORM_L2}\) }
+ \f]
+ */
NORM_L2 = 4,
+ /**
+ \f[
+ norm = \forkthree
+ { \| \texttt{src1} \| _{L_2} ^{2} = \sum_I \texttt{src1}(I)^2} {if \(\texttt{normType} = \texttt{NORM_L2SQR}\)}
+ { \| \texttt{src1} - \texttt{src2} \| _{L_2} ^{2} = \sum_I (\texttt{src1}(I) - \texttt{src2}(I))^2 }{if \(\texttt{normType} = \texttt{NORM_L2SQR}\) }
+ { \left(\frac{\|\texttt{src1}-\texttt{src2}\|_{L_2} }{\|\texttt{src2}\|_{L_2}}\right)^2 }{if \(\texttt{normType} = \texttt{NORM_RELATIVE | NORM_L2SQR}\) }
+ \f]
+ */
NORM_L2SQR = 5,
+ /**
+ In the case of one input array, calculates the Hamming distance of the array from zero,
+ In the case of two input arrays, calculates the Hamming distance between the arrays.
+ */
NORM_HAMMING = 6,
+ /**
+ Similar to NORM_HAMMING, but in the calculation, each two bits of the input sequence will
+ be added and treated as a single bit to be used in the same calculation as NORM_HAMMING.
+ */
NORM_HAMMING2 = 7,
- NORM_TYPE_MASK = 7,
+ NORM_TYPE_MASK = 7, //!< bit-mask which can be used to separate norm type from norm flags
NORM_RELATIVE = 8, //!< flag
NORM_MINMAX = 32 //!< flag
};
@@ -237,6 +250,10 @@ enum DftFlags {
into a real array and inverse transformation is executed, the function treats the input as a
packed complex-conjugate symmetrical array, and the output will also be a real array). */
DFT_REAL_OUTPUT = 32,
+ /** specifies that input is complex input. If this flag is set, the input must have 2 channels.
+ On the other hand, for backwards compatibility reason, if input has 2 channels, input is
+ already considered complex. */
+ DFT_COMPLEX_INPUT = 64,
/** performs an inverse 1D or 2D transform instead of the default forward transform. */
DCT_INVERSE = DFT_INVERSE,
/** performs a forward or inverse transform of every individual row of the input
@@ -254,7 +271,7 @@ enum BorderTypes {
BORDER_REFLECT = 2, //!< `fedcba|abcdefgh|hgfedcb`
BORDER_WRAP = 3, //!< `cdefgh|abcdefgh|abcdefg`
BORDER_REFLECT_101 = 4, //!< `gfedcb|abcdefgh|gfedcba`
- BORDER_TRANSPARENT = 5, //!< `uvwxyz|absdefgh|ijklmno`
+ BORDER_TRANSPARENT = 5, //!< `uvwxyz|abcdefgh|ijklmno`
BORDER_REFLECT101 = BORDER_REFLECT_101, //!< same as BORDER_REFLECT_101
BORDER_DEFAULT = BORDER_REFLECT_101, //!< same as BORDER_REFLECT_101
@@ -266,68 +283,6 @@ enum BorderTypes {
//! @addtogroup core_utils
//! @{
-//! @cond IGNORED
-
-//////////////// static assert /////////////////
-#define CVAUX_CONCAT_EXP(a, b) a##b
-#define CVAUX_CONCAT(a, b) CVAUX_CONCAT_EXP(a,b)
-
-#if defined(__clang__)
-# ifndef __has_extension
-# define __has_extension __has_feature /* compatibility, for older versions of clang */
-# endif
-# if __has_extension(cxx_static_assert)
-# define CV_StaticAssert(condition, reason) static_assert((condition), reason " " #condition)
-# elif __has_extension(c_static_assert)
-# define CV_StaticAssert(condition, reason) _Static_assert((condition), reason " " #condition)
-# endif
-#elif defined(__GNUC__)
-# if (defined(__GXX_EXPERIMENTAL_CXX0X__) || __cplusplus >= 201103L)
-# define CV_StaticAssert(condition, reason) static_assert((condition), reason " " #condition)
-# endif
-#elif defined(_MSC_VER)
-# if _MSC_VER >= 1600 /* MSVC 10 */
-# define CV_StaticAssert(condition, reason) static_assert((condition), reason " " #condition)
-# endif
-#endif
-#ifndef CV_StaticAssert
-# if !defined(__clang__) && defined(__GNUC__) && (__GNUC__*100 + __GNUC_MINOR__ > 302)
-# define CV_StaticAssert(condition, reason) ({ extern int __attribute__((error("CV_StaticAssert: " reason " " #condition))) CV_StaticAssert(); ((condition) ? 0 : CV_StaticAssert()); })
-# else
- template struct CV_StaticAssert_failed;
- template <> struct CV_StaticAssert_failed { enum { val = 1 }; };
- template struct CV_StaticAssert_test {};
-# define CV_StaticAssert(condition, reason)\
- typedef cv::CV_StaticAssert_test< sizeof(cv::CV_StaticAssert_failed< static_cast(condition) >) > CVAUX_CONCAT(CV_StaticAssert_failed_at_, __LINE__)
-# endif
-#endif
-
-// Suppress warning "-Wdeprecated-declarations" / C4996
-#if defined(_MSC_VER)
- #define CV_DO_PRAGMA(x) __pragma(x)
-#elif defined(__GNUC__)
- #define CV_DO_PRAGMA(x) _Pragma (#x)
-#else
- #define CV_DO_PRAGMA(x)
-#endif
-
-#ifdef _MSC_VER
-#define CV_SUPPRESS_DEPRECATED_START \
- CV_DO_PRAGMA(warning(push)) \
- CV_DO_PRAGMA(warning(disable: 4996))
-#define CV_SUPPRESS_DEPRECATED_END CV_DO_PRAGMA(warning(pop))
-#elif defined (__clang__) || ((__GNUC__) && (__GNUC__*100 + __GNUC_MINOR__ > 405))
-#define CV_SUPPRESS_DEPRECATED_START \
- CV_DO_PRAGMA(GCC diagnostic push) \
- CV_DO_PRAGMA(GCC diagnostic ignored "-Wdeprecated-declarations")
-#define CV_SUPPRESS_DEPRECATED_END CV_DO_PRAGMA(GCC diagnostic pop)
-#else
-#define CV_SUPPRESS_DEPRECATED_START
-#define CV_SUPPRESS_DEPRECATED_END
-#endif
-#define CV_UNUSED(name) (void)name
-//! @endcond
-
/*! @brief Signals an error and raises the exception.
By default the function prints information about the error to stderr,
@@ -336,44 +291,21 @@ It is possible to alternate error processing by using redirectError().
@param _code - error code (Error::Code)
@param _err - error description
@param _func - function name. Available only when the compiler supports getting it
-@param _file - source file name where the error has occured
-@param _line - line number in the source file where the error has occured
-@see CV_Error, CV_Error_, CV_ErrorNoReturn, CV_ErrorNoReturn_, CV_Assert, CV_DbgAssert
+@param _file - source file name where the error has occurred
+@param _line - line number in the source file where the error has occurred
+@see CV_Error, CV_Error_, CV_Assert, CV_DbgAssert
*/
-CV_EXPORTS void error(int _code, const String& _err, const char* _func, const char* _file, int _line);
+CV_EXPORTS CV_NORETURN void error(int _code, const String& _err, const char* _func, const char* _file, int _line);
-#ifdef __GNUC__
-# if defined __clang__ || defined __APPLE__
-# pragma GCC diagnostic push
-# pragma GCC diagnostic ignored "-Winvalid-noreturn"
-# endif
-#endif
+#ifdef CV_STATIC_ANALYSIS
-/** same as cv::error, but does not return */
-CV_INLINE CV_NORETURN void errorNoReturn(int _code, const String& _err, const char* _func, const char* _file, int _line)
-{
- error(_code, _err, _func, _file, _line);
-#ifdef __GNUC__
-# if !defined __clang__ && !defined __APPLE__
- // this suppresses this warning: "noreturn" function does return [enabled by default]
- __builtin_trap();
- // or use infinite loop: for (;;) {}
-# endif
-#endif
-}
-#ifdef __GNUC__
-# if defined __clang__ || defined __APPLE__
-# pragma GCC diagnostic pop
-# endif
-#endif
+// In practice, some macro are not processed correctly (noreturn is not detected).
+// We need to use simplified definition for them.
+#define CV_Error(code, msg) do { (void)(code); (void)(msg); abort(); } while (0)
+#define CV_Error_(code, args) do { (void)(code); (void)(cv::format args); abort(); } while (0)
+#define CV_Assert( expr ) do { if (!(expr)) abort(); } while (0)
-#if defined __GNUC__
-#define CV_Func __func__
-#elif defined _MSC_VER
-#define CV_Func __FUNCTION__
-#else
-#define CV_Func ""
-#endif
+#else // CV_STATIC_ANALYSIS
/** @brief Call the error handler.
@@ -393,7 +325,7 @@ This macro can be used to construct an error message on-fly to include some dyna
for example:
@code
// note the extra parentheses around the formatted text message
- CV_Error_( CV_StsOutOfRange,
+ CV_Error_(Error::StsOutOfRange,
("the value at (%d, %d)=%g is out of range", badPt.x, badPt.y, badValue));
@endcode
@param code one of Error::Code
@@ -407,18 +339,39 @@ The macros CV_Assert (and CV_DbgAssert(expr)) evaluate the specified expression.
raise an error (see cv::error). The macro CV_Assert checks the condition in both Debug and Release
configurations while CV_DbgAssert is only retained in the Debug configuration.
*/
-#define CV_Assert( expr ) if(!!(expr)) ; else cv::error( cv::Error::StsAssert, #expr, CV_Func, __FILE__, __LINE__ )
+#define CV_Assert( expr ) do { if(!!(expr)) ; else cv::error( cv::Error::StsAssert, #expr, CV_Func, __FILE__, __LINE__ ); } while(0)
-/** same as CV_Error(code,msg), but does not return */
-#define CV_ErrorNoReturn( code, msg ) cv::errorNoReturn( code, msg, CV_Func, __FILE__, __LINE__ )
+#endif // CV_STATIC_ANALYSIS
-/** same as CV_Error_(code,args), but does not return */
-#define CV_ErrorNoReturn_( code, args ) cv::errorNoReturn( code, cv::format args, CV_Func, __FILE__, __LINE__ )
+//! @cond IGNORED
+#if !defined(__OPENCV_BUILD) // TODO: backward compatibility only
+#ifndef CV_ErrorNoReturn
+#define CV_ErrorNoReturn CV_Error
+#endif
+#ifndef CV_ErrorNoReturn_
+#define CV_ErrorNoReturn_ CV_Error_
+#endif
+#endif
-/** replaced with CV_Assert(expr) in Debug configuration */
-#ifdef _DEBUG
+#define CV_Assert_1 CV_Assert
+#define CV_Assert_2( expr, ... ) CV_Assert_1(expr); __CV_EXPAND(CV_Assert_1( __VA_ARGS__ ))
+#define CV_Assert_3( expr, ... ) CV_Assert_1(expr); __CV_EXPAND(CV_Assert_2( __VA_ARGS__ ))
+#define CV_Assert_4( expr, ... ) CV_Assert_1(expr); __CV_EXPAND(CV_Assert_3( __VA_ARGS__ ))
+#define CV_Assert_5( expr, ... ) CV_Assert_1(expr); __CV_EXPAND(CV_Assert_4( __VA_ARGS__ ))
+#define CV_Assert_6( expr, ... ) CV_Assert_1(expr); __CV_EXPAND(CV_Assert_5( __VA_ARGS__ ))
+#define CV_Assert_7( expr, ... ) CV_Assert_1(expr); __CV_EXPAND(CV_Assert_6( __VA_ARGS__ ))
+#define CV_Assert_8( expr, ... ) CV_Assert_1(expr); __CV_EXPAND(CV_Assert_7( __VA_ARGS__ ))
+#define CV_Assert_9( expr, ... ) CV_Assert_1(expr); __CV_EXPAND(CV_Assert_8( __VA_ARGS__ ))
+#define CV_Assert_10( expr, ... ) CV_Assert_1(expr); __CV_EXPAND(CV_Assert_9( __VA_ARGS__ ))
+
+#define CV_Assert_N(...) do { __CV_EXPAND(__CV_CAT(CV_Assert_, __CV_VA_NUM_ARGS(__VA_ARGS__)) (__VA_ARGS__)); } while(0)
+
+//! @endcond
+
+#if defined _DEBUG || defined CV_STATIC_ANALYSIS
# define CV_DbgAssert(expr) CV_Assert(expr)
#else
+/** replaced with CV_Assert(expr) in Debug configuration */
# define CV_DbgAssert(expr)
#endif
@@ -428,7 +381,7 @@ configurations while CV_DbgAssert is only retained in the Debug configuration.
*/
struct CV_EXPORTS Hamming
{
- enum { normType = NORM_HAMMING };
+ static const NormTypes normType = NORM_HAMMING;
typedef unsigned char ValueType;
typedef int ResultType;
@@ -665,13 +618,23 @@ namespace cudev
namespace ipp
{
-CV_EXPORTS int getIppFeatures();
-CV_EXPORTS void setIppStatus(int status, const char * const funcname = NULL, const char * const filename = NULL,
+CV_EXPORTS unsigned long long getIppFeatures();
+CV_EXPORTS void setIppStatus(int status, const char * const funcname = NULL, const char * const filename = NULL,
int line = 0);
-CV_EXPORTS int getIppStatus();
-CV_EXPORTS String getIppErrorLocation();
-CV_EXPORTS bool useIPP();
-CV_EXPORTS void setUseIPP(bool flag);
+CV_EXPORTS int getIppStatus();
+CV_EXPORTS String getIppErrorLocation();
+CV_EXPORTS_W bool useIPP();
+CV_EXPORTS_W void setUseIPP(bool flag);
+CV_EXPORTS_W String getIppVersion();
+
+// IPP Not-Exact mode. This function may force use of IPP then both IPP and OpenCV provide proper results
+// but have internal accuracy differences which have too much direct or indirect impact on accuracy tests.
+CV_EXPORTS_W bool useIPP_NotExact();
+CV_EXPORTS_W void setUseIPP_NotExact(bool flag);
+#ifndef DISABLE_OPENCV_3_COMPATIBILITY
+static inline bool useIPP_NE() { return useIPP_NotExact(); }
+static inline void setUseIPP_NE(bool flag) { setUseIPP_NotExact(flag); }
+#endif
} // ipp
@@ -685,5 +648,7 @@ CV_EXPORTS void setUseIPP(bool flag);
} // cv
#include "opencv2/core/neon_utils.hpp"
+#include "opencv2/core/vsx_utils.hpp"
+#include "opencv2/core/check.hpp"
-#endif //__OPENCV_CORE_BASE_HPP__
+#endif //OPENCV_CORE_BASE_HPP
diff --git a/IPL/include/opencv/opencv2/core/bindings_utils.hpp b/IPL/include/opencv/opencv2/core/bindings_utils.hpp
new file mode 100644
index 0000000..f693dc8
--- /dev/null
+++ b/IPL/include/opencv/opencv2/core/bindings_utils.hpp
@@ -0,0 +1,87 @@
+// This file is part of OpenCV project.
+// It is subject to the license terms in the LICENSE file found in the top-level directory
+// of this distribution and at http://opencv.org/license.html.
+
+#ifndef OPENCV_CORE_BINDINGS_UTILS_HPP
+#define OPENCV_CORE_BINDINGS_UTILS_HPP
+
+#include