mirror of
https://github.com/MaaAssistantArknights/MaaAssistantArknights.git
synced 2026-07-14 17:00:31 +08:00
Compare commits
114 Commits
release.be
...
release.be
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e2333696ed | ||
|
|
3b87ba0d59 | ||
|
|
5e10406849 | ||
|
|
edcd68274e | ||
|
|
e20b427ce8 | ||
|
|
c30f32c6b6 | ||
|
|
4dda5ae185 | ||
|
|
3016054a0a | ||
|
|
bfb4362fd2 | ||
|
|
3f2658970f | ||
|
|
3854b059f0 | ||
|
|
354e431054 | ||
|
|
3e9513adbd | ||
|
|
2b97fd26ac | ||
|
|
b15bc0502c | ||
|
|
ba91e81eef | ||
|
|
17bb6b4b07 | ||
|
|
3d9dad8e07 | ||
|
|
924f383dac | ||
|
|
5be7671e55 | ||
|
|
96856786e1 | ||
|
|
b6398357c7 | ||
|
|
5f6be6ea5b | ||
|
|
3244511831 | ||
|
|
c40a384b84 | ||
|
|
7756917150 | ||
|
|
a9ae7a674e | ||
|
|
e759623aba | ||
|
|
4799dfd477 | ||
|
|
233b3c31c4 | ||
|
|
c6f0c9f52a | ||
|
|
fa5eb93463 | ||
|
|
d6fb554d71 | ||
|
|
bce5fa0740 | ||
|
|
9c3df883ef | ||
|
|
f2d36824f5 | ||
|
|
d27637d439 | ||
|
|
98b5fcad55 | ||
|
|
1dc5830b2e | ||
|
|
804d7d83b0 | ||
|
|
c33c86c5a7 | ||
|
|
707c32f477 | ||
|
|
0ab487d6cd | ||
|
|
2ada30fae0 | ||
|
|
a626d69d76 | ||
|
|
33f9d8d73f | ||
|
|
7d80db3c63 | ||
|
|
47df3959e4 | ||
|
|
c2d628f944 | ||
|
|
9171399ea4 | ||
|
|
776f7e316c | ||
|
|
b00b3d2077 | ||
|
|
73a82a889a | ||
|
|
2c78538955 | ||
|
|
f5cf750013 | ||
|
|
1e8f255866 | ||
|
|
c155040e01 | ||
|
|
0afda9211d | ||
|
|
1fdde9a89f | ||
|
|
a32e625826 | ||
|
|
20ed4c8ea6 | ||
|
|
309abf6916 | ||
|
|
37ae306091 | ||
|
|
bf71156d78 | ||
|
|
044392c560 | ||
|
|
b924211b00 | ||
|
|
29c622e0be | ||
|
|
d9ddff0166 | ||
|
|
40823886de | ||
|
|
89d9915dc8 | ||
|
|
6811b963d9 | ||
|
|
d844e49ded | ||
|
|
a1168f8b40 | ||
|
|
b0e378c1d0 | ||
|
|
112a733bca | ||
|
|
7dbe5933c5 | ||
|
|
05b7b5c4f0 | ||
|
|
7dbe2f99f1 | ||
|
|
f9bfe0b444 | ||
|
|
28c4d4ad37 | ||
|
|
a521088057 | ||
|
|
f8521c2183 | ||
|
|
d6edce4190 | ||
|
|
453dc3004a | ||
|
|
af8634876a | ||
|
|
343eb875ec | ||
|
|
3be4eee85b | ||
|
|
d3fa659413 | ||
|
|
4a199c1ad4 | ||
|
|
2c41ee0998 | ||
|
|
72166acda0 | ||
|
|
bf8a4f7e93 | ||
|
|
a4a8b0cfb0 | ||
|
|
d6868e9439 | ||
|
|
d2165c0454 | ||
|
|
5c47ee0d82 | ||
|
|
2af89dfed6 | ||
|
|
9d15b33b50 | ||
|
|
3e0e7e29ec | ||
|
|
c1f0feca45 | ||
|
|
5b08671fae | ||
|
|
2171b630e1 | ||
|
|
97d9d8b15e | ||
|
|
1690532cce | ||
|
|
4042062d8b | ||
|
|
245f5fec32 | ||
|
|
c7986fee91 | ||
|
|
d95a04aba5 | ||
|
|
0fbf23946f | ||
|
|
39fe244308 | ||
|
|
d6db919239 | ||
|
|
50c85554cb | ||
|
|
cd6183a397 | ||
|
|
3dfdb5be73 |
0
.gitattributes
vendored
0
.gitattributes
vendored
3
.gitignore
vendored
3
.gitignore
vendored
@@ -425,3 +425,6 @@ FodyWeavers.xsd
|
||||
# JetBrains Rider
|
||||
.idea/
|
||||
*.sln.iml
|
||||
|
||||
screen.png
|
||||
adb_screen.png
|
||||
0
.gitmodules
vendored
0
.gitmodules
vendored
@@ -1,32 +0,0 @@
|
||||
/*
|
||||
* ** File generated automatically, do not modify **
|
||||
*
|
||||
* This file defines the list of modules available in current build configuration
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
// This definition means that OpenCV is built with enabled non-free code.
|
||||
// For example, patented algorithms for non-profit/non-commercial use only.
|
||||
/* #undef OPENCV_ENABLE_NONFREE */
|
||||
|
||||
#define HAVE_OPENCV_CALIB3D
|
||||
#define HAVE_OPENCV_CORE
|
||||
#define HAVE_OPENCV_DNN
|
||||
#define HAVE_OPENCV_FEATURES2D
|
||||
#define HAVE_OPENCV_FLANN
|
||||
#define HAVE_OPENCV_HIGHGUI
|
||||
#define HAVE_OPENCV_IMGCODECS
|
||||
#define HAVE_OPENCV_IMGPROC
|
||||
#define HAVE_OPENCV_ML
|
||||
#define HAVE_OPENCV_OBJDETECT
|
||||
#define HAVE_OPENCV_PHOTO
|
||||
#define HAVE_OPENCV_SHAPE
|
||||
#define HAVE_OPENCV_STITCHING
|
||||
#define HAVE_OPENCV_SUPERRES
|
||||
#define HAVE_OPENCV_VIDEO
|
||||
#define HAVE_OPENCV_VIDEOIO
|
||||
#define HAVE_OPENCV_VIDEOSTAB
|
||||
#define HAVE_OPENCV_WORLD
|
||||
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@@ -23,12 +23,12 @@ namespace json
|
||||
array(const raw_array& arr);
|
||||
array(raw_array&& arr) noexcept;
|
||||
array(std::initializer_list<raw_array::value_type> init_list);
|
||||
template<typename EleType>
|
||||
array(std::vector<EleType> vec) {
|
||||
template<typename ArrayType>
|
||||
array(ArrayType arr) {
|
||||
static_assert(
|
||||
std::is_constructible<json::value, EleType>::value,
|
||||
std::is_constructible<json::value, typename ArrayType::value_type>::value,
|
||||
"Parameter can't be used to construct a json::value");
|
||||
for (auto&& ele : vec) {
|
||||
for (auto&& ele : arr) {
|
||||
_array_data.emplace_back(std::move(ele));
|
||||
}
|
||||
}
|
||||
@@ -68,11 +68,15 @@ namespace json
|
||||
|
||||
iterator begin() noexcept;
|
||||
iterator end() noexcept;
|
||||
const_iterator begin() const noexcept;
|
||||
const_iterator end() const noexcept;
|
||||
const_iterator cbegin() const noexcept;
|
||||
const_iterator cend() const noexcept;
|
||||
|
||||
reverse_iterator rbegin() noexcept;
|
||||
reverse_iterator rend() noexcept;
|
||||
const_reverse_iterator rbegin() const noexcept;
|
||||
const_reverse_iterator rend() const noexcept;
|
||||
const_reverse_iterator crbegin() const noexcept;
|
||||
const_reverse_iterator crend() const noexcept;
|
||||
|
||||
@@ -21,7 +21,16 @@ namespace json
|
||||
object(const raw_object& raw_obj);
|
||||
object(raw_object&& raw_obj);
|
||||
object(std::initializer_list<raw_object::value_type> init_list);
|
||||
|
||||
template<typename MapType>
|
||||
object(MapType map) {
|
||||
static_assert(
|
||||
std::is_constructible<raw_object::value_type, typename MapType::value_type>::value,
|
||||
"Parameter can't be used to construct a json::object::raw_object::value_type");
|
||||
for (auto&& ele : map) {
|
||||
_object_data.emplace(std::move(ele));
|
||||
}
|
||||
}
|
||||
|
||||
~object() = default;
|
||||
|
||||
bool empty() const noexcept { return _object_data.empty(); }
|
||||
@@ -57,6 +66,8 @@ namespace json
|
||||
|
||||
iterator begin() noexcept;
|
||||
iterator end() noexcept;
|
||||
const_iterator begin() const noexcept;
|
||||
const_iterator end() const noexcept;
|
||||
const_iterator cbegin() const noexcept;
|
||||
const_iterator cend() const noexcept;
|
||||
|
||||
604
3rdparty/include/opencv2/aruco.hpp
vendored
Normal file
604
3rdparty/include/opencv2/aruco.hpp
vendored
Normal file
@@ -0,0 +1,604 @@
|
||||
/*
|
||||
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
|
||||
(3-clause BSD License)
|
||||
|
||||
Copyright (C) 2013, OpenCV Foundation, all rights reserved.
|
||||
Third party copyrights are property of their respective owners.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions 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.
|
||||
|
||||
* Neither the names of the copyright holders nor the names of the contributors
|
||||
may 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 copyright holders or contributors be liable for
|
||||
any direct, indirect, incidental, special, exemplary, or consequential damages
|
||||
(including, but not limited to, procurement of substitute goods or services;
|
||||
loss of use, data, or profits; or business interruption) however caused
|
||||
and on any theory of liability, whether in contract, strict liability,
|
||||
or tort (including negligence or otherwise) arising in any way out of
|
||||
the use of this software, even if advised of the possibility of such damage.
|
||||
*/
|
||||
|
||||
#ifndef __OPENCV_ARUCO_HPP__
|
||||
#define __OPENCV_ARUCO_HPP__
|
||||
|
||||
#include <opencv2/core.hpp>
|
||||
#include <vector>
|
||||
#include "opencv2/aruco/dictionary.hpp"
|
||||
|
||||
/**
|
||||
* @defgroup aruco ArUco Marker Detection
|
||||
* This module is dedicated to square fiducial markers (also known as Augmented Reality Markers)
|
||||
* These markers are useful for easy, fast and robust camera pose estimation.ç
|
||||
*
|
||||
* The main functionalities are:
|
||||
* - 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 @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".
|
||||
* Pattern Recogn. 47, 6 (June 2014), 2280-2292. DOI=10.1016/j.patcog.2014.01.005
|
||||
*
|
||||
* @sa http://www.uco.es/investiga/grupos/ava/node/26
|
||||
*
|
||||
* This module has been originally developed by Sergio Garrido-Jurado as a project
|
||||
* for Google Summer of Code 2015 (GSoC 15).
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
namespace cv {
|
||||
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:
|
||||
* - adaptiveThreshWinSizeMin: minimum window size for adaptive thresholding before finding
|
||||
* contours (default 3).
|
||||
* - adaptiveThreshWinSizeMax: maximum window size for adaptive thresholding before finding
|
||||
* contours (default 23).
|
||||
* - adaptiveThreshWinSizeStep: increments from adaptiveThreshWinSizeMin to adaptiveThreshWinSizeMax
|
||||
* during the thresholding (default 10).
|
||||
* - adaptiveThreshConstant: constant for adaptive thresholding before finding contours (default 7)
|
||||
* - minMarkerPerimeterRate: determine minimum perimeter for marker contour to be detected. This
|
||||
* is defined as a rate respect to the maximum dimension of the input image (default 0.03).
|
||||
* - maxMarkerPerimeterRate: determine maximum perimeter for marker contour to be detected. This
|
||||
* is defined as a rate respect to the maximum dimension of the input image (default 4.0).
|
||||
* - polygonalApproxAccuracyRate: minimum accuracy during the polygonal approximation process to
|
||||
* determine which contours are squares. (default 0.03)
|
||||
* - minCornerDistanceRate: minimum distance between corners for detected markers relative to its
|
||||
* perimeter (default 0.05)
|
||||
* - minDistanceToBorder: minimum distance of any corner to the image border for detected markers
|
||||
* (in pixels) (default 3)
|
||||
* - 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).
|
||||
* - 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). (default CORNER_REFINE_NONE)
|
||||
* - 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).
|
||||
* - perspectiveRemovePixelPerCell: number of bits (per dimension) for each cell of the marker
|
||||
* when removing the perspective (default 4).
|
||||
* - 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. 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).
|
||||
* - minOtsuStdDev: minimun standard deviation in pixels values during the decodification step to
|
||||
* apply Otsu thresholding (otherwise, all the bits are set to 0 or 1 depending on mean higher
|
||||
* 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. (default 5)
|
||||
* - aprilTagMaxNmaxima: how many corner candidates to consider when segmenting a group of pixels into a quad. (default 10)
|
||||
* - 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) (default 10*PI/180)
|
||||
* - 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. (default 10.0)
|
||||
* - 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]). (default 5)
|
||||
* - aprilTagDeglitch: should the thresholded image be deglitched? Only useful for very noisy images. (default 0)
|
||||
* - 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. (default 0.0)
|
||||
* - 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). (default 0.0)
|
||||
* - 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 {
|
||||
|
||||
DetectorParameters();
|
||||
|
||||
CV_WRAP static Ptr<DetectorParameters> create();
|
||||
|
||||
CV_PROP_RW int adaptiveThreshWinSizeMin;
|
||||
CV_PROP_RW int adaptiveThreshWinSizeMax;
|
||||
CV_PROP_RW int adaptiveThreshWinSizeStep;
|
||||
CV_PROP_RW double adaptiveThreshConstant;
|
||||
CV_PROP_RW double minMarkerPerimeterRate;
|
||||
CV_PROP_RW double maxMarkerPerimeterRate;
|
||||
CV_PROP_RW double polygonalApproxAccuracyRate;
|
||||
CV_PROP_RW double minCornerDistanceRate;
|
||||
CV_PROP_RW int minDistanceToBorder;
|
||||
CV_PROP_RW double minMarkerDistanceRate;
|
||||
CV_PROP_RW int cornerRefinementMethod;
|
||||
CV_PROP_RW int cornerRefinementWinSize;
|
||||
CV_PROP_RW int cornerRefinementMaxIterations;
|
||||
CV_PROP_RW double cornerRefinementMinAccuracy;
|
||||
CV_PROP_RW int markerBorderBits;
|
||||
CV_PROP_RW int perspectiveRemovePixelPerCell;
|
||||
CV_PROP_RW double perspectiveRemoveIgnoredMarginPerCell;
|
||||
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;
|
||||
};
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @brief Basic marker detection
|
||||
*
|
||||
* @param image input image
|
||||
* @param dictionary indicates the type of markers that will be searched
|
||||
* @param corners vector of detected marker corners. For each marker, its four corners
|
||||
* are provided, (e.g std::vector<std::vector<cv::Point2f> > ). For N detected markers,
|
||||
* the dimensions of this array is Nx4. The order of the corners is clockwise.
|
||||
* @param ids vector of identifiers of the detected markers. The identifier is of type int
|
||||
* (e.g. std::vector<int>). For N detected markers, the size of ids is also N.
|
||||
* The identifiers have the same order than the markers in the imgPoints array.
|
||||
* @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
|
||||
* and its corresponding identifier.
|
||||
* Note that this function does not perform pose estimation.
|
||||
* @sa estimatePoseSingleMarkers, estimatePoseBoard
|
||||
*
|
||||
*/
|
||||
CV_EXPORTS_W void detectMarkers(InputArray image, const Ptr<Dictionary> &dictionary, OutputArrayOfArrays corners,
|
||||
OutputArray ids, const Ptr<DetectorParameters> ¶meters = DetectorParameters::create(),
|
||||
OutputArrayOfArrays rejectedImgPoints = noArray(), InputArray cameraMatrix= noArray(), InputArray distCoeff= noArray());
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @brief Pose estimation for single markers
|
||||
*
|
||||
* @param corners vector of already detected markers corners. For each marker, its four corners
|
||||
* are provided, (e.g std::vector<std::vector<cv::Point2f> > ). For N detected markers,
|
||||
* the dimensions of this array should be Nx4. The order of the corners should be clockwise.
|
||||
* @sa detectMarkers
|
||||
* @param markerLength the length of the markers' side. The returning translation vectors will
|
||||
* be in the same unit. Normally, unit is meters.
|
||||
* @param cameraMatrix input 3x3 floating-point camera matrix
|
||||
* \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<cv::Vec3d>).
|
||||
* Each element in rvecs corresponds to the specific marker in imgPoints.
|
||||
* @param tvecs array of output translation vectors (e.g. std::vector<cv::Vec3d>).
|
||||
* 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.
|
||||
* The returned transformation is the one that transforms points from each marker coordinate system
|
||||
* to the camera coordinate system.
|
||||
* The marker corrdinate system is centered on the middle of the marker, with the Z axis
|
||||
* perpendicular to the marker plane.
|
||||
* The coordinates of the four corners of the marker in its own coordinate system are:
|
||||
* (-markerLength/2, markerLength/2, 0), (markerLength/2, markerLength/2, 0),
|
||||
* (markerLength/2, -markerLength/2, 0), (-markerLength/2, -markerLength/2, 0)
|
||||
*/
|
||||
CV_EXPORTS_W void estimatePoseSingleMarkers(InputArrayOfArrays corners, float markerLength,
|
||||
InputArray cameraMatrix, InputArray distCoeffs,
|
||||
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 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.
|
||||
* - The dictionary which indicates the type of markers of the board
|
||||
* - The identifier of all the markers in the board.
|
||||
*/
|
||||
class CV_EXPORTS_W Board {
|
||||
|
||||
public:
|
||||
/**
|
||||
* @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<Board> create(InputArrayOfArrays objPoints, const Ptr<Dictionary> &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> 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 arrangement.
|
||||
* The board can be drawn using drawPlanarBoard() function (@sa drawPlanarBoard)
|
||||
*/
|
||||
class CV_EXPORTS_W GridBoard : public Board {
|
||||
|
||||
public:
|
||||
/**
|
||||
* @brief Draw a GridBoard
|
||||
*
|
||||
* @param outSize size of the output image in pixels.
|
||||
* @param img output image with the board. The size of this image will be outSize
|
||||
* and the board will be on the center, keeping the board proportions.
|
||||
* @param marginSize minimum margins (in pixels) of the board in the output image
|
||||
* @param borderBits width of the marker borders.
|
||||
*
|
||||
* This function return the image of the GridBoard, ready to be printed.
|
||||
*/
|
||||
CV_WRAP void draw(Size outSize, OutputArray img, int marginSize = 0, int borderBits = 1);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Create a GridBoard object
|
||||
*
|
||||
* @param markersX number of markers in X direction
|
||||
* @param markersY number of markers in Y direction
|
||||
* @param markerLength marker side length (normally in meters)
|
||||
* @param markerSeparation separation between two markers (same unit as markerLength)
|
||||
* @param dictionary dictionary of markers indicating the type of markers
|
||||
* @param firstMarker id of first marker in dictionary to use on board.
|
||||
* @return the output GridBoard object
|
||||
*
|
||||
* This functions creates a GridBoard object given the number of markers in each direction and
|
||||
* the marker size and marker separation.
|
||||
*/
|
||||
CV_WRAP static Ptr<GridBoard> create(int markersX, int markersY, float markerLength,
|
||||
float markerSeparation, const Ptr<Dictionary> &dictionary, int firstMarker = 0);
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
CV_WRAP Size getGridSize() const { return Size(_markersX, _markersY); }
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
CV_WRAP float getMarkerLength() const { return _markerLength; }
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
CV_WRAP float getMarkerSeparation() const { return _markerSeparation; }
|
||||
|
||||
|
||||
private:
|
||||
// number of markers in X and Y directions
|
||||
int _markersX, _markersY;
|
||||
|
||||
// marker side length (normally in meters)
|
||||
float _markerLength;
|
||||
|
||||
// separation between markers in the grid
|
||||
float _markerSeparation;
|
||||
};
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @brief Pose estimation for a board of markers
|
||||
*
|
||||
* @param corners vector of already detected markers corners. For each marker, its four corners
|
||||
* are provided, (e.g std::vector<std::vector<cv::Point2f> > ). For N detected markers, the
|
||||
* dimensions of this array should be Nx4. The order of the corners should be clockwise.
|
||||
* @param ids list of identifiers for each marker in corners
|
||||
* @param board layout of markers in the board. The layout is composed by the marker identifiers
|
||||
* and the positions of each marker corner in the board reference system.
|
||||
* @param cameraMatrix input 3x3 floating-point camera matrix
|
||||
* \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 rvec Output vector (e.g. cv::Mat) corresponding to the rotation vector of the board
|
||||
* (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.
|
||||
* A Board of marker has a single world coordinate system which is defined by the board layout.
|
||||
* The returned transformation is the one that transforms points from the board coordinate system
|
||||
* to the camera coordinate system.
|
||||
* Input markers that are not included in the board layout are ignored.
|
||||
* 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, const Ptr<Board> &board,
|
||||
InputArray cameraMatrix, InputArray distCoeffs, OutputArray rvec,
|
||||
OutputArray tvec, bool useExtrinsicGuess = false);
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @brief Refind not detected markers based on the already detected and the board layout
|
||||
*
|
||||
* @param image input image
|
||||
* @param board layout of markers in the board.
|
||||
* @param detectedCorners vector of already detected marker corners.
|
||||
* @param detectedIds vector of already detected marker identifiers.
|
||||
* @param rejectedCorners vector of rejected candidates during the marker detection process.
|
||||
* @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 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 minRepDistance minimum distance between the corners of the rejected candidate and the
|
||||
* reprojected marker in order to consider it as a correspondence.
|
||||
* @param errorCorrectionRate rate of allowed erroneous bits respect to the error correction
|
||||
* capability of the used dictionary. -1 ignores the error correction step.
|
||||
* @param checkAllOrders Consider the four posible corner orders in the rejectedCorners array.
|
||||
* If it set to false, only the provided corner order is considered (default true).
|
||||
* @param recoveredIdxs Optional array to returns the indexes of the recovered candidates in the
|
||||
* original rejectedCorners array.
|
||||
* @param parameters marker detection parameters
|
||||
*
|
||||
* This function tries to find markers that were not detected in the basic detecMarkers function.
|
||||
* First, based on the current detected marker and the board layout, the function interpolates
|
||||
* the position of the missing markers. Then it tries to find correspondence between the reprojected
|
||||
* markers and the rejected candidates based on the minRepDistance and errorCorrectionRate
|
||||
* parameters.
|
||||
* If camera parameters and distortion coefficients are provided, missing markers are reprojected
|
||||
* using projectPoint function. If not, missing marker projections are interpolated using global
|
||||
* homography, and all the marker corners in the board must have the same Z coordinate.
|
||||
*/
|
||||
CV_EXPORTS_W void refineDetectedMarkers(
|
||||
InputArray image,const Ptr<Board> &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<DetectorParameters> ¶meters = DetectorParameters::create());
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @brief Draw detected markers in image
|
||||
*
|
||||
* @param image input/output image. It must have 1 or 3 channels. The number of channels is not
|
||||
* altered.
|
||||
* @param corners positions of marker corners on input image.
|
||||
* (e.g std::vector<std::vector<cv::Point2f> > ). For N detected markers, the dimensions of
|
||||
* this array should be Nx4. The order of the corners should be clockwise.
|
||||
* @param ids vector of identifiers for markers in markersCorners .
|
||||
* Optional, if not provided, ids are not painted.
|
||||
* @param borderColor color of marker borders. Rest of colors (text color and first corner color)
|
||||
* are calculated based on this one to improve visualization.
|
||||
*
|
||||
* Given an array of detected marker corners and its corresponding ids, this functions draws
|
||||
* the markers in the image. The marker borders are painted and the markers identifiers if provided.
|
||||
* Useful for debugging purposes.
|
||||
*/
|
||||
CV_EXPORTS_W void drawDetectedMarkers(InputOutputArray image, InputArrayOfArrays corners,
|
||||
InputArray ids = noArray(),
|
||||
Scalar borderColor = Scalar(0, 255, 0));
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @brief Draw coordinate system axis from pose estimation
|
||||
*
|
||||
* @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 camera matrix
|
||||
* \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 rvec rotation vector of the coordinate system that will be drawn. (@sa Rodrigues).
|
||||
* @param tvec translation vector of the coordinate system that will be drawn.
|
||||
* @param length length of the painted axis in the same unit than tvec (usually in meters)
|
||||
*
|
||||
* 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);
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @brief Draw a canonical marker image
|
||||
*
|
||||
* @param dictionary dictionary of markers indicating the type of markers
|
||||
* @param id identifier of the marker that will be returned. It has to be a valid id
|
||||
* in the specified dictionary.
|
||||
* @param sidePixels size of the image in pixels
|
||||
* @param img output image with the marker
|
||||
* @param borderBits width of the marker border.
|
||||
*
|
||||
* This function returns a marker image in its canonical form (i.e. ready to be printed)
|
||||
*/
|
||||
CV_EXPORTS_W void drawMarker(const Ptr<Dictionary> &dictionary, int id, int sidePixels, OutputArray img,
|
||||
int borderBits = 1);
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @brief Draw a planar board
|
||||
* @sa _drawPlanarBoardImpl
|
||||
*
|
||||
* @param board layout of the board that will be drawn. The board should be planar,
|
||||
* z coordinate is ignored
|
||||
* @param outSize size of the output image in pixels.
|
||||
* @param img output image with the board. The size of this image will be outSize
|
||||
* and the board will be on the center, keeping the board proportions.
|
||||
* @param marginSize minimum margins (in pixels) of the board in the output image
|
||||
* @param borderBits width of the marker borders.
|
||||
*
|
||||
* 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(const Ptr<Board> &board, Size outSize, OutputArray img,
|
||||
int marginSize = 0, int borderBits = 1);
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @brief Implementation of drawPlanarBoard that accepts a raw Board pointer.
|
||||
*/
|
||||
void _drawPlanarBoardImpl(Board *board, Size outSize, OutputArray img,
|
||||
int marginSize = 0, int borderBits = 1);
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @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 (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
|
||||
* @param imageSize Size of the image used only to initialize the intrinsic camera matrix.
|
||||
* @param cameraMatrix 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
|
||||
* initialized before calling the function.
|
||||
* @param distCoeffs 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]])\f$ of 4, 5, 8 or 12 elements
|
||||
* @param rvecs Output vector of rotation vectors (see Rodrigues ) estimated for each board view
|
||||
* (e.g. std::vector<cv::Mat>>). That is, each k-th rotation vector together with the corresponding
|
||||
* k-th translation vector (see the next output parameter description) brings the board pattern
|
||||
* 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 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_AS(calibrateCameraArucoExtended) double calibrateCameraAruco(
|
||||
InputArrayOfArrays corners, InputArray ids, InputArray counter, const Ptr<Board> &board,
|
||||
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));
|
||||
|
||||
|
||||
/** @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> &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> &board, InputArrayOfArrays detectedCorners,
|
||||
InputArray detectedIds, OutputArray objPoints, OutputArray imgPoints);
|
||||
|
||||
|
||||
//! @}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
354
3rdparty/include/opencv2/aruco/charuco.hpp
vendored
Normal file
354
3rdparty/include/opencv2/aruco/charuco.hpp
vendored
Normal file
@@ -0,0 +1,354 @@
|
||||
/*
|
||||
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
|
||||
(3-clause BSD License)
|
||||
|
||||
Copyright (C) 2013, OpenCV Foundation, all rights reserved.
|
||||
Third party copyrights are property of their respective owners.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions 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.
|
||||
|
||||
* Neither the names of the copyright holders nor the names of the contributors
|
||||
may 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 copyright holders or contributors be liable for
|
||||
any direct, indirect, incidental, special, exemplary, or consequential damages
|
||||
(including, but not limited to, procurement of substitute goods or services;
|
||||
loss of use, data, or profits; or business interruption) however caused
|
||||
and on any theory of liability, whether in contract, strict liability,
|
||||
or tort (including negligence or otherwise) arising in any way out of
|
||||
the use of this software, even if advised of the possibility of such damage.
|
||||
*/
|
||||
|
||||
#ifndef __OPENCV_CHARUCO_HPP__
|
||||
#define __OPENCV_CHARUCO_HPP__
|
||||
|
||||
#include <opencv2/core.hpp>
|
||||
#include <vector>
|
||||
#include <opencv2/aruco.hpp>
|
||||
|
||||
|
||||
namespace cv {
|
||||
namespace aruco {
|
||||
|
||||
//! @addtogroup aruco
|
||||
//! @{
|
||||
|
||||
|
||||
/**
|
||||
* @brief ChArUco board
|
||||
* Specific class for ChArUco boards. A ChArUco board is a planar board where the markers are placed
|
||||
* inside the white squares of a chessboard. The benefits of ChArUco boards is that they provide
|
||||
* both, ArUco markers versatility and chessboard corner precision, which is important for
|
||||
* calibration and pose estimation.
|
||||
* This class also allows the easy creation and drawing of ChArUco boards.
|
||||
*/
|
||||
class CV_EXPORTS_W CharucoBoard : public Board {
|
||||
|
||||
public:
|
||||
// vector of chessboard 3D corners precalculated
|
||||
CV_PROP std::vector< Point3f > chessboardCorners;
|
||||
|
||||
// for each charuco corner, nearest marker id and nearest marker corner id of each marker
|
||||
CV_PROP std::vector< std::vector< int > > nearestMarkerIdx;
|
||||
CV_PROP std::vector< std::vector< int > > nearestMarkerCorners;
|
||||
|
||||
/**
|
||||
* @brief Draw a ChArUco board
|
||||
*
|
||||
* @param outSize size of the output image in pixels.
|
||||
* @param img output image with the board. The size of this image will be outSize
|
||||
* and the board will be on the center, keeping the board proportions.
|
||||
* @param marginSize minimum margins (in pixels) of the board in the output image
|
||||
* @param borderBits width of the marker borders.
|
||||
*
|
||||
* This function return the image of the ChArUco board, ready to be printed.
|
||||
*/
|
||||
CV_WRAP void draw(Size outSize, OutputArray img, int marginSize = 0, int borderBits = 1);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Create a CharucoBoard object
|
||||
*
|
||||
* @param squaresX number of chessboard squares in X direction
|
||||
* @param squaresY number of chessboard squares in Y direction
|
||||
* @param squareLength chessboard square side length (normally in meters)
|
||||
* @param markerLength marker side length (same unit than squareLength)
|
||||
* @param dictionary dictionary of markers indicating the type of markers.
|
||||
* The first markers in the dictionary are used to fill the white chessboard squares.
|
||||
* @return the output CharucoBoard object
|
||||
*
|
||||
* This functions creates a CharucoBoard object given the number of squares in each direction
|
||||
* and the size of the markers and chessboard squares.
|
||||
*/
|
||||
CV_WRAP static Ptr<CharucoBoard> create(int squaresX, int squaresY, float squareLength,
|
||||
float markerLength, const Ptr<Dictionary> &dictionary);
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
CV_WRAP Size getChessboardSize() const { return Size(_squaresX, _squaresY); }
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
CV_WRAP float getSquareLength() const { return _squareLength; }
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
CV_WRAP float getMarkerLength() const { return _markerLength; }
|
||||
|
||||
private:
|
||||
void _getNearestMarkerCorners();
|
||||
|
||||
// number of markers in X and Y directions
|
||||
int _squaresX, _squaresY;
|
||||
|
||||
// size of chessboard squares side (normally in meters)
|
||||
float _squareLength;
|
||||
|
||||
// marker side length (normally in meters)
|
||||
float _markerLength;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @brief Interpolate position of ChArUco board corners
|
||||
* @param markerCorners vector of already detected markers corners. For each marker, its four
|
||||
* corners are provided, (e.g std::vector<std::vector<cv::Point2f> > ). For N detected markers, the
|
||||
* dimensions of this array should be Nx4. The order of the corners should be clockwise.
|
||||
* @param markerIds list of identifiers for each marker in corners
|
||||
* @param image input image necesary for corner refinement. Note that markers are not detected and
|
||||
* should be sent in corners and ids parameters.
|
||||
* @param board layout of ChArUco board.
|
||||
* @param charucoCorners interpolated chessboard corners
|
||||
* @param charucoIds interpolated chessboard corners identifiers
|
||||
* @param cameraMatrix optional 3x3 floating-point camera matrix
|
||||
* \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,
|
||||
* the process is based in an approximated pose estimation, else it is based on local homography.
|
||||
* Only visible corners are returned. For each corner, its corresponding identifier is
|
||||
* also returned in charucoIds.
|
||||
* The function returns the number of interpolated corners.
|
||||
*/
|
||||
CV_EXPORTS_W int interpolateCornersCharuco(InputArrayOfArrays markerCorners, InputArray markerIds,
|
||||
InputArray image, const Ptr<CharucoBoard> &board,
|
||||
OutputArray charucoCorners, OutputArray charucoIds,
|
||||
InputArray cameraMatrix = noArray(),
|
||||
InputArray distCoeffs = noArray(), int minMarkers = 2);
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @brief Pose estimation for a ChArUco board given some of their corners
|
||||
* @param charucoCorners vector of detected charuco corners
|
||||
* @param charucoIds list of identifiers for each corner in charucoCorners
|
||||
* @param board layout of ChArUco board.
|
||||
* @param cameraMatrix input 3x3 floating-point camera matrix
|
||||
* \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 rvec Output vector (e.g. cv::Mat) corresponding to the rotation vector of the board
|
||||
* (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,
|
||||
const Ptr<CharucoBoard> &board, InputArray cameraMatrix,
|
||||
InputArray distCoeffs, OutputArray rvec, OutputArray tvec,
|
||||
bool useExtrinsicGuess = false);
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @brief Draws a set of Charuco corners
|
||||
* @param image input/output image. It must have 1 or 3 channels. The number of channels is not
|
||||
* altered.
|
||||
* @param charucoCorners vector of detected charuco corners
|
||||
* @param charucoIds list of identifiers for each corner in charucoCorners
|
||||
* @param cornerColor color of the square surrounding each corner
|
||||
*
|
||||
* This function draws a set of detected Charuco corners. If identifiers vector is provided, it also
|
||||
* draws the id of each corner.
|
||||
*/
|
||||
CV_EXPORTS_W void drawDetectedCornersCharuco(InputOutputArray image, InputArray charucoCorners,
|
||||
InputArray charucoIds = noArray(),
|
||||
Scalar cornerColor = Scalar(255, 0, 0));
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @brief Calibrate a camera using Charuco corners
|
||||
*
|
||||
* @param charucoCorners vector of detected charuco corners per frame
|
||||
* @param charucoIds list of identifiers for each corner in charucoCorners per frame
|
||||
* @param board Marker Board layout
|
||||
* @param imageSize input image size
|
||||
* @param cameraMatrix 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
|
||||
* initialized before calling the function.
|
||||
* @param distCoeffs 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]])\f$ of 4, 5, 8 or 12 elements
|
||||
* @param rvecs Output vector of rotation vectors (see Rodrigues ) estimated for each board view
|
||||
* (e.g. std::vector<cv::Mat>>). That is, each k-th rotation vector together with the corresponding
|
||||
* k-th translation vector (see the next output parameter description) brings the board pattern
|
||||
* 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 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_AS(calibrateCameraCharucoExtended) double calibrateCameraCharuco(
|
||||
InputArrayOfArrays charucoCorners, InputArrayOfArrays charucoIds, const Ptr<CharucoBoard> &board,
|
||||
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));
|
||||
|
||||
/** @brief It's the same function as #calibrateCameraCharuco but without calibration error estimation.
|
||||
*/
|
||||
CV_EXPORTS_W double calibrateCameraCharuco(
|
||||
InputArrayOfArrays charucoCorners, InputArrayOfArrays charucoIds, const Ptr<CharucoBoard> &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 Detect ChArUco Diamond markers
|
||||
*
|
||||
* @param image input image necessary for corner subpixel.
|
||||
* @param markerCorners list of detected marker corners from detectMarkers function.
|
||||
* @param markerIds list of marker ids in markerCorners.
|
||||
* @param squareMarkerLengthRate rate between square and marker length:
|
||||
* squareMarkerLengthRate = squareLength/markerLength. The real units are not necessary.
|
||||
* @param diamondCorners output list of detected diamond corners (4 corners per diamond). The order
|
||||
* is the same than in marker corners: top left, top right, bottom right and bottom left. Similar
|
||||
* format than the corners returned by detectMarkers (e.g std::vector<std::vector<cv::Point2f> > ).
|
||||
* @param diamondIds ids of the diamonds in diamondCorners. The id of each diamond is in fact of
|
||||
* type Vec4i, so each diamond has 4 ids, which are the ids of the aruco markers composing the
|
||||
* diamond.
|
||||
* @param cameraMatrix Optional camera calibration matrix.
|
||||
* @param distCoeffs Optional camera distortion coefficients.
|
||||
*
|
||||
* This function detects Diamond markers from the previous detected ArUco markers. The diamonds
|
||||
* are returned in the diamondCorners and diamondIds parameters. If camera calibration parameters
|
||||
* are provided, the diamond search is based on reprojection. If not, diamond search is based on
|
||||
* homography. Homography is faster than reprojection but can slightly reduce the detection rate.
|
||||
*/
|
||||
CV_EXPORTS_W void detectCharucoDiamond(InputArray image, InputArrayOfArrays markerCorners,
|
||||
InputArray markerIds, float squareMarkerLengthRate,
|
||||
OutputArrayOfArrays diamondCorners, OutputArray diamondIds,
|
||||
InputArray cameraMatrix = noArray(),
|
||||
InputArray distCoeffs = noArray());
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @brief Draw a set of detected ChArUco Diamond markers
|
||||
*
|
||||
* @param image input/output image. It must have 1 or 3 channels. The number of channels is not
|
||||
* altered.
|
||||
* @param diamondCorners positions of diamond corners in the same format returned by
|
||||
* detectCharucoDiamond(). (e.g std::vector<std::vector<cv::Point2f> > ). For N detected markers,
|
||||
* the dimensions of this array should be Nx4. The order of the corners should be clockwise.
|
||||
* @param diamondIds vector of identifiers for diamonds in diamondCorners, in the same format
|
||||
* returned by detectCharucoDiamond() (e.g. std::vector<Vec4i>).
|
||||
* Optional, if not provided, ids are not painted.
|
||||
* @param borderColor color of marker borders. Rest of colors (text color and first corner color)
|
||||
* are calculated based on this one.
|
||||
*
|
||||
* Given an array of detected diamonds, this functions draws them in the image. The marker borders
|
||||
* are painted and the markers identifiers if provided.
|
||||
* Useful for debugging purposes.
|
||||
*/
|
||||
CV_EXPORTS_W void drawDetectedDiamonds(InputOutputArray image, InputArrayOfArrays diamondCorners,
|
||||
InputArray diamondIds = noArray(),
|
||||
Scalar borderColor = Scalar(0, 0, 255));
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @brief Draw a ChArUco Diamond marker
|
||||
*
|
||||
* @param dictionary dictionary of markers indicating the type of markers.
|
||||
* @param ids list of 4 ids for each ArUco marker in the ChArUco marker.
|
||||
* @param squareLength size of the chessboard squares in pixels.
|
||||
* @param markerLength size of the markers in pixels.
|
||||
* @param img output image with the marker. The size of this image will be
|
||||
* 3*squareLength + 2*marginSize,.
|
||||
* @param marginSize minimum margins (in pixels) of the marker in the output image
|
||||
* @param borderBits width of the marker borders.
|
||||
*
|
||||
* 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(const Ptr<Dictionary> &dictionary, Vec4i ids, int squareLength,
|
||||
int markerLength, OutputArray img, int marginSize = 0,
|
||||
int borderBits = 1);
|
||||
|
||||
|
||||
/**
|
||||
* @brief test whether the ChArUco markers are collinear
|
||||
*
|
||||
* @param _board layout of ChArUco board.
|
||||
* @param _charucoIds list of identifiers for each corner in charucoCorners per frame.
|
||||
* @return bool value, 1 (true) if detected corners form a line, 0 (false) if they do not.
|
||||
solvePnP, calibration functions will fail if the corners are collinear (true).
|
||||
*
|
||||
* The number of ids in charucoIDs should be <= the number of chessboard corners in the board. This functions checks whether the charuco corners are on a straight line (returns true, if so), or not (false). Axis parallel, as well as diagonal and other straight lines detected. Degenerate cases: for number of charucoIDs <= 2, the function returns true.
|
||||
*/
|
||||
CV_EXPORTS_W bool testCharucoCornersCollinear(const Ptr<CharucoBoard> &_board,
|
||||
InputArray _charucoIds);
|
||||
|
||||
//! @}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
212
3rdparty/include/opencv2/aruco/dictionary.hpp
vendored
Normal file
212
3rdparty/include/opencv2/aruco/dictionary.hpp
vendored
Normal file
@@ -0,0 +1,212 @@
|
||||
/*
|
||||
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
|
||||
(3-clause BSD License)
|
||||
|
||||
Copyright (C) 2013, OpenCV Foundation, all rights reserved.
|
||||
Third party copyrights are property of their respective owners.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions 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.
|
||||
|
||||
* Neither the names of the copyright holders nor the names of the contributors
|
||||
may 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 copyright holders or contributors be liable for
|
||||
any direct, indirect, incidental, special, exemplary, or consequential damages
|
||||
(including, but not limited to, procurement of substitute goods or services;
|
||||
loss of use, data, or profits; or business interruption) however caused
|
||||
and on any theory of liability, whether in contract, strict liability,
|
||||
or tort (including negligence or otherwise) arising in any way out of
|
||||
the use of this software, even if advised of the possibility of such damage.
|
||||
*/
|
||||
|
||||
#ifndef __OPENCV_DICTIONARY_HPP__
|
||||
#define __OPENCV_DICTIONARY_HPP__
|
||||
|
||||
#include <opencv2/core.hpp>
|
||||
|
||||
namespace cv {
|
||||
namespace aruco {
|
||||
|
||||
//! @addtogroup aruco
|
||||
//! @{
|
||||
|
||||
|
||||
/**
|
||||
* @brief Dictionary/Set of markers. It contains the inner codification
|
||||
*
|
||||
* bytesList contains the marker codewords where
|
||||
* - bytesList.rows is the dictionary size
|
||||
* - each marker is encoded using `nbytes = ceil(markerSize*markerSize/8.)`
|
||||
* - each row contains all 4 rotations of the marker, so its length is `4*nbytes`
|
||||
*
|
||||
* `bytesList.ptr(i)[k*nbytes + j]` is then the j-th byte of i-th marker, in its k-th rotation.
|
||||
*/
|
||||
class CV_EXPORTS_W Dictionary {
|
||||
|
||||
public:
|
||||
CV_PROP_RW Mat bytesList; // marker code information
|
||||
CV_PROP_RW int markerSize; // number of bits per dimension
|
||||
CV_PROP_RW int maxCorrectionBits; // maximum number of bits that can be corrected
|
||||
|
||||
|
||||
/**
|
||||
*/
|
||||
Dictionary(const Mat &_bytesList = Mat(), int _markerSize = 0, int _maxcorr = 0);
|
||||
|
||||
|
||||
/**
|
||||
Dictionary(const Dictionary &_dictionary);
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
*/
|
||||
Dictionary(const Ptr<Dictionary> &_dictionary);
|
||||
|
||||
|
||||
/**
|
||||
* @see generateCustomDictionary
|
||||
*/
|
||||
CV_WRAP_AS(create) static Ptr<Dictionary> create(int nMarkers, int markerSize, int randomSeed=0);
|
||||
|
||||
|
||||
/**
|
||||
* @see generateCustomDictionary
|
||||
*/
|
||||
CV_WRAP_AS(create_from) static Ptr<Dictionary> create(int nMarkers, int markerSize,
|
||||
const Ptr<Dictionary> &baseDictionary, int randomSeed=0);
|
||||
|
||||
/**
|
||||
* @see getPredefinedDictionary
|
||||
*/
|
||||
CV_WRAP static Ptr<Dictionary> get(int dict);
|
||||
|
||||
/**
|
||||
* @brief Given a matrix of bits. Returns whether if marker is identified or not.
|
||||
* It returns by reference the correct id (if any) and the correct rotation
|
||||
*/
|
||||
bool identify(const Mat &onlyBits, int &idx, int &rotation, double maxCorrectionRate) const;
|
||||
|
||||
/**
|
||||
* @brief Returns the distance of the input bits to the specific id. If allRotations is true,
|
||||
* the four posible bits rotation are considered
|
||||
*/
|
||||
int getDistanceToId(InputArray bits, int id, bool allRotations = true) const;
|
||||
|
||||
|
||||
/**
|
||||
* @brief Draw a canonical marker image
|
||||
*/
|
||||
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
|
||||
*/
|
||||
CV_WRAP static Mat getByteListFromBits(const Mat &bits);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Transform list of bytes to matrix of bits
|
||||
*/
|
||||
CV_WRAP static Mat getBitsFromByteList(const Mat &byteList, int markerSize);
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @brief Predefined markers dictionaries/sets
|
||||
* Each dictionary indicates the number of bits and the number of markers contained
|
||||
* - DICT_ARUCO_ORIGINAL: standard ArUco Library Markers. 1024 markers, 5x5 bits, 0 minimum
|
||||
distance
|
||||
*/
|
||||
enum PREDEFINED_DICTIONARY_NAME {
|
||||
DICT_4X4_50 = 0,
|
||||
DICT_4X4_100,
|
||||
DICT_4X4_250,
|
||||
DICT_4X4_1000,
|
||||
DICT_5X5_50,
|
||||
DICT_5X5_100,
|
||||
DICT_5X5_250,
|
||||
DICT_5X5_1000,
|
||||
DICT_6X6_50,
|
||||
DICT_6X6_100,
|
||||
DICT_6X6_250,
|
||||
DICT_6X6_1000,
|
||||
DICT_7X7_50,
|
||||
DICT_7X7_100,
|
||||
DICT_7X7_250,
|
||||
DICT_7X7_1000,
|
||||
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
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @brief Returns one of the predefined dictionaries defined in PREDEFINED_DICTIONARY_NAME
|
||||
*/
|
||||
CV_EXPORTS Ptr<Dictionary> getPredefinedDictionary(PREDEFINED_DICTIONARY_NAME name);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Returns one of the predefined dictionaries referenced by DICT_*.
|
||||
*/
|
||||
CV_EXPORTS_W Ptr<Dictionary> getPredefinedDictionary(int dict);
|
||||
|
||||
|
||||
/**
|
||||
* @see generateCustomDictionary
|
||||
*/
|
||||
CV_EXPORTS_AS(custom_dictionary) Ptr<Dictionary> generateCustomDictionary(
|
||||
int nMarkers,
|
||||
int markerSize,
|
||||
int randomSeed=0);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Generates a new customizable marker dictionary
|
||||
*
|
||||
* @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
|
||||
* included and the rest are generated based on them. If the size of baseDictionary is higher
|
||||
* than nMarkers, only the first nMarkers in baseDictionary are taken and no new marker is added.
|
||||
*/
|
||||
CV_EXPORTS_AS(custom_dictionary_from) Ptr<Dictionary> generateCustomDictionary(
|
||||
int nMarkers,
|
||||
int markerSize,
|
||||
const Ptr<Dictionary> &baseDictionary,
|
||||
int randomSeed=0);
|
||||
|
||||
|
||||
|
||||
//! @}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
380
3rdparty/include/opencv2/bgsegm.hpp
vendored
Normal file
380
3rdparty/include/opencv2/bgsegm.hpp
vendored
Normal file
@@ -0,0 +1,380 @@
|
||||
/*
|
||||
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
|
||||
(3-clause BSD License)
|
||||
|
||||
Copyright (C) 2013, OpenCV Foundation, all rights reserved.
|
||||
Third party copyrights are property of their respective owners.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions 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.
|
||||
|
||||
* Neither the names of the copyright holders nor the names of the contributors
|
||||
may 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 copyright holders or contributors be liable for
|
||||
any direct, indirect, incidental, special, exemplary, or consequential damages
|
||||
(including, but not limited to, procurement of substitute goods or services;
|
||||
loss of use, data, or profits; or business interruption) however caused
|
||||
and on any theory of liability, whether in contract, strict liability,
|
||||
or tort (including negligence or otherwise) arising in any way out of
|
||||
the use of this software, even if advised of the possibility of such damage.
|
||||
*/
|
||||
|
||||
#ifndef __OPENCV_BGSEGM_HPP__
|
||||
#define __OPENCV_BGSEGM_HPP__
|
||||
|
||||
#include "opencv2/video.hpp"
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
/** @defgroup bgsegm Improved Background-Foreground Segmentation Methods
|
||||
*/
|
||||
|
||||
namespace cv
|
||||
{
|
||||
namespace bgsegm
|
||||
{
|
||||
|
||||
//! @addtogroup bgsegm
|
||||
//! @{
|
||||
|
||||
/** @brief Gaussian Mixture-based Background/Foreground Segmentation Algorithm.
|
||||
|
||||
The class implements the algorithm described in @cite KB2001 .
|
||||
*/
|
||||
class CV_EXPORTS_W BackgroundSubtractorMOG : public BackgroundSubtractor
|
||||
{
|
||||
public:
|
||||
CV_WRAP virtual int getHistory() const = 0;
|
||||
CV_WRAP virtual void setHistory(int nframes) = 0;
|
||||
|
||||
CV_WRAP virtual int getNMixtures() const = 0;
|
||||
CV_WRAP virtual void setNMixtures(int nmix) = 0;
|
||||
|
||||
CV_WRAP virtual double getBackgroundRatio() const = 0;
|
||||
CV_WRAP virtual void setBackgroundRatio(double backgroundRatio) = 0;
|
||||
|
||||
CV_WRAP virtual double getNoiseSigma() const = 0;
|
||||
CV_WRAP virtual void setNoiseSigma(double noiseSigma) = 0;
|
||||
};
|
||||
|
||||
/** @brief Creates mixture-of-gaussian background subtractor
|
||||
|
||||
@param history Length of the history.
|
||||
@param nmixtures Number of Gaussian mixtures.
|
||||
@param backgroundRatio Background ratio.
|
||||
@param noiseSigma Noise strength (standard deviation of the brightness or each color channel). 0
|
||||
means some automatic value.
|
||||
*/
|
||||
CV_EXPORTS_W Ptr<BackgroundSubtractorMOG>
|
||||
createBackgroundSubtractorMOG(int history=200, int nmixtures=5,
|
||||
double backgroundRatio=0.7, double noiseSigma=0);
|
||||
|
||||
|
||||
/** @brief Background Subtractor module based on the algorithm given in @cite Gold2012 .
|
||||
|
||||
Takes a series of images and returns a sequence of mask (8UC1)
|
||||
images of the same size, where 255 indicates Foreground and 0 represents Background.
|
||||
This class implements an algorithm described in "Visual Tracking of Human Visitors under
|
||||
Variable-Lighting Conditions for a Responsive Audio Art Installation," A. Godbehere,
|
||||
A. Matsukawa, K. Goldberg, American Control Conference, Montreal, June 2012.
|
||||
*/
|
||||
class CV_EXPORTS_W BackgroundSubtractorGMG : public BackgroundSubtractor
|
||||
{
|
||||
public:
|
||||
/** @brief Returns total number of distinct colors to maintain in histogram.
|
||||
*/
|
||||
CV_WRAP virtual int getMaxFeatures() const = 0;
|
||||
/** @brief Sets total number of distinct colors to maintain in histogram.
|
||||
*/
|
||||
CV_WRAP virtual void setMaxFeatures(int maxFeatures) = 0;
|
||||
|
||||
/** @brief Returns the learning rate of the algorithm.
|
||||
|
||||
It lies between 0.0 and 1.0. It determines how quickly features are "forgotten" from
|
||||
histograms.
|
||||
*/
|
||||
CV_WRAP virtual double getDefaultLearningRate() const = 0;
|
||||
/** @brief Sets the learning rate of the algorithm.
|
||||
*/
|
||||
CV_WRAP virtual void setDefaultLearningRate(double lr) = 0;
|
||||
|
||||
/** @brief Returns the number of frames used to initialize background model.
|
||||
*/
|
||||
CV_WRAP virtual int getNumFrames() const = 0;
|
||||
/** @brief Sets the number of frames used to initialize background model.
|
||||
*/
|
||||
CV_WRAP virtual void setNumFrames(int nframes) = 0;
|
||||
|
||||
/** @brief Returns the parameter used for quantization of color-space.
|
||||
|
||||
It is the number of discrete levels in each channel to be used in histograms.
|
||||
*/
|
||||
CV_WRAP virtual int getQuantizationLevels() const = 0;
|
||||
/** @brief Sets the parameter used for quantization of color-space
|
||||
*/
|
||||
CV_WRAP virtual void setQuantizationLevels(int nlevels) = 0;
|
||||
|
||||
/** @brief Returns the prior probability that each individual pixel is a background pixel.
|
||||
*/
|
||||
CV_WRAP virtual double getBackgroundPrior() const = 0;
|
||||
/** @brief Sets the prior probability that each individual pixel is a background pixel.
|
||||
*/
|
||||
CV_WRAP virtual void setBackgroundPrior(double bgprior) = 0;
|
||||
|
||||
/** @brief Returns the kernel radius used for morphological operations
|
||||
*/
|
||||
CV_WRAP virtual int getSmoothingRadius() const = 0;
|
||||
/** @brief Sets the kernel radius used for morphological operations
|
||||
*/
|
||||
CV_WRAP virtual void setSmoothingRadius(int radius) = 0;
|
||||
|
||||
/** @brief Returns the value of decision threshold.
|
||||
|
||||
Decision value is the value above which pixel is determined to be FG.
|
||||
*/
|
||||
CV_WRAP virtual double getDecisionThreshold() const = 0;
|
||||
/** @brief Sets the value of decision threshold.
|
||||
*/
|
||||
CV_WRAP virtual void setDecisionThreshold(double thresh) = 0;
|
||||
|
||||
/** @brief Returns the status of background model update
|
||||
*/
|
||||
CV_WRAP virtual bool getUpdateBackgroundModel() const = 0;
|
||||
/** @brief Sets the status of background model update
|
||||
*/
|
||||
CV_WRAP virtual void setUpdateBackgroundModel(bool update) = 0;
|
||||
|
||||
/** @brief Returns the minimum value taken on by pixels in image sequence. Usually 0.
|
||||
*/
|
||||
CV_WRAP virtual double getMinVal() const = 0;
|
||||
/** @brief Sets the minimum value taken on by pixels in image sequence.
|
||||
*/
|
||||
CV_WRAP virtual void setMinVal(double val) = 0;
|
||||
|
||||
/** @brief Returns the maximum value taken on by pixels in image sequence. e.g. 1.0 or 255.
|
||||
*/
|
||||
CV_WRAP virtual double getMaxVal() const = 0;
|
||||
/** @brief Sets the maximum value taken on by pixels in image sequence.
|
||||
*/
|
||||
CV_WRAP virtual void setMaxVal(double val) = 0;
|
||||
};
|
||||
|
||||
/** @brief Creates a GMG Background Subtractor
|
||||
|
||||
@param initializationFrames number of frames used to initialize the background models.
|
||||
@param decisionThreshold Threshold value, above which it is marked foreground, else background.
|
||||
*/
|
||||
CV_EXPORTS_W Ptr<BackgroundSubtractorGMG> createBackgroundSubtractorGMG(int initializationFrames=120,
|
||||
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<BackgroundSubtractorCNT>
|
||||
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<BackgroundSubtractorGSOC> 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<BackgroundSubtractorLSBP> 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<SyntheticSequenceGenerator> createSyntheticSequenceGenerator(InputArray background, InputArray object, double amplitude = 2.0, double wavelength = 20.0, double wavespeed = 0.2, double objspeed = 6.0);
|
||||
|
||||
//! @}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif
|
||||
60
3rdparty/include/opencv2/bioinspired.hpp
vendored
Normal file
60
3rdparty/include/opencv2/bioinspired.hpp
vendored
Normal file
@@ -0,0 +1,60 @@
|
||||
/*M///////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
|
||||
//
|
||||
// By downloading, copying, installing or using the software you agree to this license.
|
||||
// If you do not agree to this license, do not download, install,
|
||||
// copy or use the software.
|
||||
//
|
||||
//
|
||||
// License Agreement
|
||||
// For Open Source Computer Vision Library
|
||||
//
|
||||
// Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
|
||||
// Copyright (C) 2009, Willow Garage Inc., all rights reserved.
|
||||
// Third party copyrights are property of their respective owners.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
// are permitted provided that the following conditions are met:
|
||||
//
|
||||
// * Redistribution's of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// * Redistribution's in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
//
|
||||
// * The name of the copyright holders may not be used to endorse or promote products
|
||||
// derived from this software without specific prior written permission.
|
||||
//
|
||||
// This software is provided by the copyright holders and contributors "as is" and
|
||||
// any express or implied warranties, including, but not limited to, the implied
|
||||
// warranties of merchantability and fitness for a particular purpose are disclaimed.
|
||||
// In no event shall the Intel Corporation or contributors be liable for any direct,
|
||||
// indirect, incidental, special, exemplary, or consequential damages
|
||||
// (including, but not limited to, procurement of substitute goods or services;
|
||||
// loss of use, data, or profits; or business interruption) however caused
|
||||
// and on any theory of liability, whether in contract, strict liability,
|
||||
// or tort (including negligence or otherwise) arising in any way out of
|
||||
// the use of this software, even if advised of the possibility of such damage.
|
||||
//
|
||||
//M*/
|
||||
|
||||
#ifndef __OPENCV_BIOINSPIRED_HPP__
|
||||
#define __OPENCV_BIOINSPIRED_HPP__
|
||||
|
||||
#include "opencv2/core.hpp"
|
||||
#include "opencv2/bioinspired/retina.hpp"
|
||||
#include "opencv2/bioinspired/retinafasttonemapping.hpp"
|
||||
#include "opencv2/bioinspired/transientareassegmentationmodule.hpp"
|
||||
|
||||
/** @defgroup bioinspired Biologically inspired vision models and derivated tools
|
||||
|
||||
The module provides biological visual systems models (human visual system and others). It also
|
||||
provides derivated objects that take advantage of those bio-inspired models.
|
||||
|
||||
@ref bioinspired_retina
|
||||
|
||||
*/
|
||||
|
||||
#endif
|
||||
48
3rdparty/include/opencv2/bioinspired/bioinspired.hpp
vendored
Normal file
48
3rdparty/include/opencv2/bioinspired/bioinspired.hpp
vendored
Normal file
@@ -0,0 +1,48 @@
|
||||
/*M///////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
|
||||
//
|
||||
// By downloading, copying, installing or using the software you agree to this license.
|
||||
// If you do not agree to this license, do not download, install,
|
||||
// copy or use the software.
|
||||
//
|
||||
//
|
||||
// License Agreement
|
||||
// For Open Source Computer Vision Library
|
||||
//
|
||||
// Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
|
||||
// Copyright (C) 2009, Willow Garage Inc., all rights reserved.
|
||||
// Copyright (C) 2013, OpenCV Foundation, all rights reserved.
|
||||
// Third party copyrights are property of their respective owners.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
// are permitted provided that the following conditions are met:
|
||||
//
|
||||
// * Redistribution's of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// * Redistribution's in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
//
|
||||
// * The name of the copyright holders may not be used to endorse or promote products
|
||||
// derived from this software without specific prior written permission.
|
||||
//
|
||||
// This software is provided by the copyright holders and contributors "as is" and
|
||||
// any express or implied warranties, including, but not limited to, the implied
|
||||
// warranties of merchantability and fitness for a particular purpose are disclaimed.
|
||||
// In no event shall the Intel Corporation or contributors be liable for any direct,
|
||||
// indirect, incidental, special, exemplary, or consequential damages
|
||||
// (including, but not limited to, procurement of substitute goods or services;
|
||||
// loss of use, data, or profits; or business interruption) however caused
|
||||
// and on any theory of liability, whether in contract, strict liability,
|
||||
// or tort (including negligence or otherwise) arising in any way out of
|
||||
// the use of this software, even if advised of the possibility of such damage.
|
||||
//
|
||||
//M*/
|
||||
|
||||
#ifdef __OPENCV_BUILD
|
||||
#error this is a compatibility header which should not be used inside the OpenCV library
|
||||
#endif
|
||||
|
||||
#include "opencv2/bioinspired.hpp"
|
||||
454
3rdparty/include/opencv2/bioinspired/retina.hpp
vendored
Normal file
454
3rdparty/include/opencv2/bioinspired/retina.hpp
vendored
Normal file
@@ -0,0 +1,454 @@
|
||||
/*#******************************************************************************
|
||||
** 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.
|
||||
**
|
||||
**
|
||||
** bioinspired : interfaces allowing OpenCV users to integrate Human Vision System models. Presented models originate from Jeanny Herault's original research and have been reused and adapted by the author&collaborators for computed vision applications since his thesis with Alice Caplier at Gipsa-Lab.
|
||||
** Use: extract still images & image sequences features, from contours details to motion spatio-temporal features, etc. for high level visual scene analysis. Also contribute to image enhancement/compression such as tone mapping.
|
||||
**
|
||||
** Maintainers : Listic lab (code author current affiliation & applications) and Gipsa Lab (original research origins & applications)
|
||||
**
|
||||
** Creation - enhancement process 2007-2015
|
||||
** Author: Alexandre Benoit (benoit.alexandre.vision@gmail.com), LISTIC lab, Annecy le vieux, France
|
||||
**
|
||||
** Theses algorithm have been developped by Alexandre BENOIT since his thesis with Alice Caplier at Gipsa-Lab (www.gipsa-lab.inpg.fr) and the research he pursues at LISTIC Lab (www.listic.univ-savoie.fr).
|
||||
** Refer to the following research paper for more information:
|
||||
** Benoit A., Caplier A., Durette B., Herault, J., "USING HUMAN VISUAL SYSTEM MODELING FOR BIO-INSPIRED LOW LEVEL IMAGE PROCESSING", Elsevier, Computer Vision and Image Understanding 114 (2010), pp. 758-773, DOI: http://dx.doi.org/10.1016/j.cviu.2010.01.011
|
||||
** This work have been carried out thanks to Jeanny Herault who's research and great discussions are the basis of all this work, please take a look at his book:
|
||||
** Vision: Images, Signals and Neural Networks: Models of Neural Processing in Visual Perception (Progress in Neural Processing),By: Jeanny Herault, ISBN: 9814273686. WAPI (Tower ID): 113266891.
|
||||
**
|
||||
** The retina filter includes the research contributions of phd/research collegues from which code has been redrawn by the author :
|
||||
** _take a look at the retinacolor.hpp module to discover Brice Chaix de Lavarene color mosaicing/demosaicing and the reference paper:
|
||||
** ====> B. Chaix de Lavarene, D. Alleysson, B. Durette, J. Herault (2007). "Efficient demosaicing through recursive filtering", IEEE International Conference on Image Processing ICIP 2007
|
||||
** _take a look at imagelogpolprojection.hpp to discover retina spatial log sampling which originates from Barthelemy Durette phd with Jeanny Herault. A Retina / V1 cortex projection is also proposed and originates from Jeanny's discussions.
|
||||
** ====> more informations in the above cited Jeanny Heraults's book.
|
||||
**
|
||||
** License Agreement
|
||||
** For Open Source Computer Vision Library
|
||||
**
|
||||
** Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
|
||||
** Copyright (C) 2008-2011, Willow Garage Inc., all rights reserved.
|
||||
**
|
||||
** For Human Visual System tools (bioinspired)
|
||||
** Copyright (C) 2007-2015, LISTIC Lab, Annecy le Vieux and GIPSA Lab, Grenoble, France, 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:
|
||||
**
|
||||
** * Redistributions of source code must retain the above copyright notice,
|
||||
** this list of conditions and the following disclaimer.
|
||||
**
|
||||
** * Redistributions 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.
|
||||
*******************************************************************************/
|
||||
|
||||
#ifndef __OPENCV_BIOINSPIRED_RETINA_HPP__
|
||||
#define __OPENCV_BIOINSPIRED_RETINA_HPP__
|
||||
|
||||
/**
|
||||
@file
|
||||
@date Jul 19, 2011
|
||||
@author Alexandre Benoit
|
||||
*/
|
||||
|
||||
#include "opencv2/core.hpp" // for all OpenCV core functionalities access, including cv::Exception support
|
||||
|
||||
|
||||
namespace cv{
|
||||
namespace bioinspired{
|
||||
|
||||
//! @addtogroup bioinspired
|
||||
//! @{
|
||||
|
||||
enum {
|
||||
RETINA_COLOR_RANDOM, //!< each pixel position is either R, G or B in a random choice
|
||||
RETINA_COLOR_DIAGONAL,//!< color sampling is RGBRGBRGB..., line 2 BRGBRGBRG..., line 3, GBRGBRGBR...
|
||||
RETINA_COLOR_BAYER//!< standard bayer sampling
|
||||
};
|
||||
|
||||
|
||||
/** @brief retina model parameters structure
|
||||
|
||||
For better clarity, check explenations on the comments of methods : setupOPLandIPLParvoChannel and setupIPLMagnoChannel
|
||||
|
||||
Here is the default configuration file of the retina module. It gives results such as the first
|
||||
retina output shown on the top of this page.
|
||||
|
||||
@code{xml}
|
||||
<?xml version="1.0"?>
|
||||
<opencv_storage>
|
||||
<OPLandIPLparvo>
|
||||
<colorMode>1</colorMode>
|
||||
<normaliseOutput>1</normaliseOutput>
|
||||
<photoreceptorsLocalAdaptationSensitivity>7.5e-01</photoreceptorsLocalAdaptationSensitivity>
|
||||
<photoreceptorsTemporalConstant>9.0e-01</photoreceptorsTemporalConstant>
|
||||
<photoreceptorsSpatialConstant>5.3e-01</photoreceptorsSpatialConstant>
|
||||
<horizontalCellsGain>0.01</horizontalCellsGain>
|
||||
<hcellsTemporalConstant>0.5</hcellsTemporalConstant>
|
||||
<hcellsSpatialConstant>7.</hcellsSpatialConstant>
|
||||
<ganglionCellsSensitivity>7.5e-01</ganglionCellsSensitivity></OPLandIPLparvo>
|
||||
<IPLmagno>
|
||||
<normaliseOutput>1</normaliseOutput>
|
||||
<parasolCells_beta>0.</parasolCells_beta>
|
||||
<parasolCells_tau>0.</parasolCells_tau>
|
||||
<parasolCells_k>7.</parasolCells_k>
|
||||
<amacrinCellsTemporalCutFrequency>2.0e+00</amacrinCellsTemporalCutFrequency>
|
||||
<V0CompressionParameter>9.5e-01</V0CompressionParameter>
|
||||
<localAdaptintegration_tau>0.</localAdaptintegration_tau>
|
||||
<localAdaptintegration_k>7.</localAdaptintegration_k></IPLmagno>
|
||||
</opencv_storage>
|
||||
@endcode
|
||||
|
||||
Here is the 'realistic" setup used to obtain the second retina output shown on the top of this page.
|
||||
|
||||
@code{xml}
|
||||
<?xml version="1.0"?>
|
||||
<opencv_storage>
|
||||
<OPLandIPLparvo>
|
||||
<colorMode>1</colorMode>
|
||||
<normaliseOutput>1</normaliseOutput>
|
||||
<photoreceptorsLocalAdaptationSensitivity>8.9e-01</photoreceptorsLocalAdaptationSensitivity>
|
||||
<photoreceptorsTemporalConstant>9.0e-01</photoreceptorsTemporalConstant>
|
||||
<photoreceptorsSpatialConstant>5.3e-01</photoreceptorsSpatialConstant>
|
||||
<horizontalCellsGain>0.3</horizontalCellsGain>
|
||||
<hcellsTemporalConstant>0.5</hcellsTemporalConstant>
|
||||
<hcellsSpatialConstant>7.</hcellsSpatialConstant>
|
||||
<ganglionCellsSensitivity>8.9e-01</ganglionCellsSensitivity></OPLandIPLparvo>
|
||||
<IPLmagno>
|
||||
<normaliseOutput>1</normaliseOutput>
|
||||
<parasolCells_beta>0.</parasolCells_beta>
|
||||
<parasolCells_tau>0.</parasolCells_tau>
|
||||
<parasolCells_k>7.</parasolCells_k>
|
||||
<amacrinCellsTemporalCutFrequency>2.0e+00</amacrinCellsTemporalCutFrequency>
|
||||
<V0CompressionParameter>9.5e-01</V0CompressionParameter>
|
||||
<localAdaptintegration_tau>0.</localAdaptintegration_tau>
|
||||
<localAdaptintegration_k>7.</localAdaptintegration_k></IPLmagno>
|
||||
</opencv_storage>
|
||||
@endcode
|
||||
*/
|
||||
struct RetinaParameters{
|
||||
//! Outer Plexiform Layer (OPL) and Inner Plexiform Layer Parvocellular (IplParvo) parameters
|
||||
struct OPLandIplParvoParameters{
|
||||
OPLandIplParvoParameters():colorMode(true),
|
||||
normaliseOutput(true),
|
||||
photoreceptorsLocalAdaptationSensitivity(0.75f),
|
||||
photoreceptorsTemporalConstant(0.9f),
|
||||
photoreceptorsSpatialConstant(0.53f),
|
||||
horizontalCellsGain(0.01f),
|
||||
hcellsTemporalConstant(0.5f),
|
||||
hcellsSpatialConstant(7.f),
|
||||
ganglionCellsSensitivity(0.75f) { } // default setup
|
||||
bool colorMode, normaliseOutput;
|
||||
float photoreceptorsLocalAdaptationSensitivity, photoreceptorsTemporalConstant, photoreceptorsSpatialConstant, horizontalCellsGain, hcellsTemporalConstant, hcellsSpatialConstant, ganglionCellsSensitivity;
|
||||
};
|
||||
//! Inner Plexiform Layer Magnocellular channel (IplMagno)
|
||||
struct IplMagnoParameters{
|
||||
IplMagnoParameters():
|
||||
normaliseOutput(true),
|
||||
parasolCells_beta(0.f),
|
||||
parasolCells_tau(0.f),
|
||||
parasolCells_k(7.f),
|
||||
amacrinCellsTemporalCutFrequency(2.0f),
|
||||
V0CompressionParameter(0.95f),
|
||||
localAdaptintegration_tau(0.f),
|
||||
localAdaptintegration_k(7.f) { } // default setup
|
||||
bool normaliseOutput;
|
||||
float parasolCells_beta, parasolCells_tau, parasolCells_k, amacrinCellsTemporalCutFrequency, V0CompressionParameter, localAdaptintegration_tau, localAdaptintegration_k;
|
||||
};
|
||||
OPLandIplParvoParameters OPLandIplParvo;
|
||||
IplMagnoParameters IplMagno;
|
||||
};
|
||||
|
||||
|
||||
|
||||
/** @brief class which allows the Gipsa/Listic Labs model to be used with OpenCV.
|
||||
|
||||
This retina model allows spatio-temporal image processing (applied on still images, video sequences).
|
||||
As a summary, these are the retina model properties:
|
||||
- It applies a spectral whithening (mid-frequency details enhancement)
|
||||
- high frequency spatio-temporal noise reduction
|
||||
- low frequency luminance to be reduced (luminance range compression)
|
||||
- local logarithmic luminance compression allows details to be enhanced in low light conditions
|
||||
|
||||
USE : this model can be used basically for spatio-temporal video effects but also for :
|
||||
_using the getParvo method output matrix : texture analysiswith enhanced signal to noise ratio and enhanced details robust against input images luminance ranges
|
||||
_using the getMagno method output matrix : motion analysis also with the previously cited properties
|
||||
|
||||
for more information, reer to the following papers :
|
||||
Benoit A., Caplier A., Durette B., Herault, J., "USING HUMAN VISUAL SYSTEM MODELING FOR BIO-INSPIRED LOW LEVEL IMAGE PROCESSING", Elsevier, Computer Vision and Image Understanding 114 (2010), pp. 758-773, DOI: http://dx.doi.org/10.1016/j.cviu.2010.01.011
|
||||
Vision: Images, Signals and Neural Networks: Models of Neural Processing in Visual Perception (Progress in Neural Processing),By: Jeanny Herault, ISBN: 9814273686. WAPI (Tower ID): 113266891.
|
||||
|
||||
The retina filter includes the research contributions of phd/research collegues from which code has been redrawn by the author :
|
||||
take a look at the retinacolor.hpp module to discover Brice Chaix de Lavarene color mosaicing/demosaicing and the reference paper:
|
||||
B. Chaix de Lavarene, D. Alleysson, B. Durette, J. Herault (2007). "Efficient demosaicing through recursive filtering", IEEE International Conference on Image Processing ICIP 2007
|
||||
take a look at imagelogpolprojection.hpp to discover retina spatial log sampling which originates from Barthelemy Durette phd with Jeanny Herault. A Retina / V1 cortex projection is also proposed and originates from Jeanny's discussions.
|
||||
more informations in the above cited Jeanny Heraults's book.
|
||||
*/
|
||||
class CV_EXPORTS_W Retina : public Algorithm {
|
||||
|
||||
public:
|
||||
|
||||
|
||||
/** @brief Retreive retina input buffer size
|
||||
@return the retina input buffer size
|
||||
*/
|
||||
CV_WRAP virtual Size getInputSize()=0;
|
||||
|
||||
/** @brief Retreive retina output buffer size that can be different from the input if a spatial log
|
||||
transformation is applied
|
||||
@return the retina output buffer size
|
||||
*/
|
||||
CV_WRAP virtual Size getOutputSize()=0;
|
||||
|
||||
/** @brief Try to open an XML retina parameters file to adjust current retina instance setup
|
||||
|
||||
- if the xml file does not exist, then default setup is applied
|
||||
- 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 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;
|
||||
|
||||
/** @overload
|
||||
@param fs the open Filestorage which contains retina parameters
|
||||
@param applyDefaultSetupOnFailure set to true if an error must be thrown on error
|
||||
*/
|
||||
virtual void setup(cv::FileStorage &fs, const bool applyDefaultSetupOnFailure=true)=0;
|
||||
|
||||
/** @overload
|
||||
@param newParameters a parameters structures updated with the new target configuration.
|
||||
*/
|
||||
virtual void setup(RetinaParameters newParameters)=0;
|
||||
|
||||
/**
|
||||
@return the current parameters setup
|
||||
*/
|
||||
virtual RetinaParameters getParameters()=0;
|
||||
|
||||
/** @brief Outputs a string showing the used parameters setup
|
||||
@return a string which contains formated parameters information
|
||||
*/
|
||||
CV_WRAP virtual const String printSetup()=0;
|
||||
|
||||
/** @brief Write xml/yml formated parameters information
|
||||
@param fs the filename of the xml file that will be open and writen with formatted parameters
|
||||
information
|
||||
*/
|
||||
CV_WRAP virtual void write( String fs ) const=0;
|
||||
|
||||
/** @overload */
|
||||
virtual void write( FileStorage& fs ) const CV_OVERRIDE = 0;
|
||||
|
||||
/** @brief Setup the OPL and IPL parvo channels (see biologocal model)
|
||||
|
||||
OPL is referred as Outer Plexiform Layer of the retina, it allows the spatio-temporal filtering
|
||||
which withens the spectrum and reduces spatio-temporal noise while attenuating global luminance
|
||||
(low frequency energy) IPL parvo is the OPL next processing stage, it refers to a part of the
|
||||
Inner Plexiform layer of the retina, it allows high contours sensitivity in foveal vision. See
|
||||
reference papers for more informations.
|
||||
for more informations, please have a look at the paper Benoit A., Caplier A., Durette B., Herault, J., "USING HUMAN VISUAL SYSTEM MODELING FOR BIO-INSPIRED LOW LEVEL IMAGE PROCESSING", Elsevier, Computer Vision and Image Understanding 114 (2010), pp. 758-773, DOI: http://dx.doi.org/10.1016/j.cviu.2010.01.011
|
||||
@param colorMode specifies if (true) color is processed of not (false) to then processing gray
|
||||
level image
|
||||
@param normaliseOutput specifies if (true) output is rescaled between 0 and 255 of not (false)
|
||||
@param photoreceptorsLocalAdaptationSensitivity the photoreceptors sensitivity renage is 0-1
|
||||
(more log compression effect when value increases)
|
||||
@param photoreceptorsTemporalConstant the time constant of the first order low pass filter of
|
||||
the photoreceptors, use it to cut high temporal frequencies (noise or fast motion), unit is
|
||||
frames, typical value is 1 frame
|
||||
@param photoreceptorsSpatialConstant the spatial constant of the first order low pass filter of
|
||||
the photoreceptors, use it to cut high spatial frequencies (noise or thick contours), unit is
|
||||
pixels, typical value is 1 pixel
|
||||
@param horizontalCellsGain gain of the horizontal cells network, if 0, then the mean value of
|
||||
the output is zero, if the parameter is near 1, then, the luminance is not filtered and is
|
||||
still reachable at the output, typicall value is 0
|
||||
@param HcellsTemporalConstant the time constant of the first order low pass filter of the
|
||||
horizontal cells, use it to cut low temporal frequencies (local luminance variations), unit is
|
||||
frames, typical value is 1 frame, as the photoreceptors
|
||||
@param HcellsSpatialConstant the spatial constant of the first order low pass filter of the
|
||||
horizontal cells, use it to cut low spatial frequencies (local luminance), unit is pixels,
|
||||
typical value is 5 pixel, this value is also used for local contrast computing when computing
|
||||
the local contrast adaptation at the ganglion cells level (Inner Plexiform Layer parvocellular
|
||||
channel model)
|
||||
@param ganglionCellsSensitivity the compression strengh of the ganglion cells local adaptation
|
||||
output, set a value between 0.6 and 1 for best results, a high value increases more the low
|
||||
value sensitivity... and the output saturates faster, recommended value: 0.7
|
||||
*/
|
||||
CV_WRAP virtual void setupOPLandIPLParvoChannel(const bool colorMode=true, const bool normaliseOutput = true, const float photoreceptorsLocalAdaptationSensitivity=0.7f, const float photoreceptorsTemporalConstant=0.5f, const float photoreceptorsSpatialConstant=0.53f, const float horizontalCellsGain=0.f, const float HcellsTemporalConstant=1.f, const float HcellsSpatialConstant=7.f, const float ganglionCellsSensitivity=0.7f)=0;
|
||||
|
||||
/** @brief Set parameters values for the Inner Plexiform Layer (IPL) magnocellular channel
|
||||
|
||||
this channel processes signals output from OPL processing stage in peripheral vision, it allows
|
||||
motion information enhancement. It is decorrelated from the details channel. See reference
|
||||
papers for more details.
|
||||
|
||||
@param normaliseOutput specifies if (true) output is rescaled between 0 and 255 of not (false)
|
||||
@param parasolCells_beta the low pass filter gain used for local contrast adaptation at the
|
||||
IPL level of the retina (for ganglion cells local adaptation), typical value is 0
|
||||
@param parasolCells_tau the low pass filter time constant used for local contrast adaptation
|
||||
at the IPL level of the retina (for ganglion cells local adaptation), unit is frame, typical
|
||||
value is 0 (immediate response)
|
||||
@param parasolCells_k the low pass filter spatial constant used for local contrast adaptation
|
||||
at the IPL level of the retina (for ganglion cells local adaptation), unit is pixels, typical
|
||||
value is 5
|
||||
@param amacrinCellsTemporalCutFrequency the time constant of the first order high pass fiter of
|
||||
the magnocellular way (motion information channel), unit is frames, typical value is 1.2
|
||||
@param V0CompressionParameter the compression strengh of the ganglion cells local adaptation
|
||||
output, set a value between 0.6 and 1 for best results, a high value increases more the low
|
||||
value sensitivity... and the output saturates faster, recommended value: 0.95
|
||||
@param localAdaptintegration_tau specifies the temporal constant of the low pas filter
|
||||
involved in the computation of the local "motion mean" for the local adaptation computation
|
||||
@param localAdaptintegration_k specifies the spatial constant of the low pas filter involved
|
||||
in the computation of the local "motion mean" for the local adaptation computation
|
||||
*/
|
||||
CV_WRAP virtual void setupIPLMagnoChannel(const bool normaliseOutput = true, const float parasolCells_beta=0.f, const float parasolCells_tau=0.f, const float parasolCells_k=7.f, const float amacrinCellsTemporalCutFrequency=1.2f, const float V0CompressionParameter=0.95f, const float localAdaptintegration_tau=0.f, const float localAdaptintegration_k=7.f)=0;
|
||||
|
||||
/** @brief Method which allows retina to be applied on an input image,
|
||||
|
||||
after run, encapsulated retina module is ready to deliver its outputs using dedicated
|
||||
acccessors, see getParvo and getMagno methods
|
||||
@param inputImage the input Mat image to be processed, can be gray level or BGR coded in any
|
||||
format (from 8bit to 16bits)
|
||||
*/
|
||||
CV_WRAP virtual void run(InputArray inputImage)=0;
|
||||
|
||||
/** @brief Method which processes an image in the aim to correct its luminance correct
|
||||
backlight problems, enhance details in shadows.
|
||||
|
||||
This method is designed to perform High Dynamic Range image tone mapping (compress \>8bit/pixel
|
||||
images to 8bit/pixel). This is a simplified version of the Retina Parvocellular model
|
||||
(simplified version of the run/getParvo methods call) since it does not include the
|
||||
spatio-temporal filter modelling the Outer Plexiform Layer of the retina that performs spectral
|
||||
whitening and many other stuff. However, it works great for tone mapping and in a faster way.
|
||||
|
||||
Check the demos and experiments section to see examples and the way to perform tone mapping
|
||||
using the original retina model and the method.
|
||||
|
||||
@param inputImage the input image to process (should be coded in float format : CV_32F,
|
||||
CV_32FC1, CV_32F_C3, CV_32F_C4, the 4th channel won't be considered).
|
||||
@param outputToneMappedImage the output 8bit/channel tone mapped image (CV_8U or CV_8UC3 format).
|
||||
*/
|
||||
CV_WRAP virtual void applyFastToneMapping(InputArray inputImage, OutputArray outputToneMappedImage)=0;
|
||||
|
||||
/** @brief Accessor of the details channel of the retina (models foveal vision).
|
||||
|
||||
Warning, getParvoRAW methods return buffers that are not rescaled within range [0;255] while
|
||||
the non RAW method allows a normalized matrix to be retrieved.
|
||||
|
||||
@param retinaOutput_parvo the output buffer (reallocated if necessary), format can be :
|
||||
- a Mat, this output is rescaled for standard 8bits image processing use in OpenCV
|
||||
- RAW methods actually return a 1D matrix (encoding is R1, R2, ... Rn, G1, G2, ..., Gn, B1,
|
||||
B2, ...Bn), this output is the original retina filter model output, without any
|
||||
quantification or rescaling.
|
||||
@see getParvoRAW
|
||||
*/
|
||||
CV_WRAP virtual void getParvo(OutputArray retinaOutput_parvo)=0;
|
||||
|
||||
/** @brief Accessor of the details channel of the retina (models foveal vision).
|
||||
@see getParvo
|
||||
*/
|
||||
CV_WRAP virtual void getParvoRAW(OutputArray retinaOutput_parvo)=0;
|
||||
|
||||
/** @brief Accessor of the motion channel of the retina (models peripheral vision).
|
||||
|
||||
Warning, getMagnoRAW methods return buffers that are not rescaled within range [0;255] while
|
||||
the non RAW method allows a normalized matrix to be retrieved.
|
||||
@param retinaOutput_magno the output buffer (reallocated if necessary), format can be :
|
||||
- a Mat, this output is rescaled for standard 8bits image processing use in OpenCV
|
||||
- RAW methods actually return a 1D matrix (encoding is M1, M2,... Mn), this output is the
|
||||
original retina filter model output, without any quantification or rescaling.
|
||||
@see getMagnoRAW
|
||||
*/
|
||||
CV_WRAP virtual void getMagno(OutputArray retinaOutput_magno)=0;
|
||||
|
||||
/** @brief Accessor of the motion channel of the retina (models peripheral vision).
|
||||
@see getMagno
|
||||
*/
|
||||
CV_WRAP virtual void getMagnoRAW(OutputArray retinaOutput_magno)=0;
|
||||
|
||||
/** @overload */
|
||||
CV_WRAP virtual const Mat getMagnoRAW() const=0;
|
||||
/** @overload */
|
||||
CV_WRAP virtual const Mat getParvoRAW() const=0;
|
||||
|
||||
/** @brief Activate color saturation as the final step of the color demultiplexing process -\> this
|
||||
saturation is a sigmoide function applied to each channel of the demultiplexed image.
|
||||
@param saturateColors boolean that activates color saturation (if true) or desactivate (if false)
|
||||
@param colorSaturationValue the saturation factor : a simple factor applied on the chrominance
|
||||
buffers
|
||||
*/
|
||||
CV_WRAP virtual void setColorSaturation(const bool saturateColors=true, const float colorSaturationValue=4.0f)=0;
|
||||
|
||||
/** @brief Clears all retina buffers
|
||||
|
||||
(equivalent to opening the eyes after a long period of eye close ;o) whatchout the temporal
|
||||
transition occuring just after this method call.
|
||||
*/
|
||||
CV_WRAP virtual void clearBuffers()=0;
|
||||
|
||||
/** @brief Activate/desactivate the Magnocellular pathway processing (motion information extraction), by
|
||||
default, it is activated
|
||||
@param activate true if Magnocellular output should be activated, false if not... if activated,
|
||||
the Magnocellular output can be retrieved using the **getMagno** methods
|
||||
*/
|
||||
CV_WRAP virtual void activateMovingContoursProcessing(const bool activate)=0;
|
||||
|
||||
/** @brief Activate/desactivate the Parvocellular pathway processing (contours information extraction), by
|
||||
default, it is activated
|
||||
@param activate true if Parvocellular (contours information extraction) output should be
|
||||
activated, false if not... if activated, the Parvocellular output can be retrieved using the
|
||||
Retina::getParvo methods
|
||||
*/
|
||||
CV_WRAP virtual void activateContoursProcessing(const bool activate)=0;
|
||||
|
||||
/** @overload */
|
||||
CV_WRAP static Ptr<Retina> 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<Retina> 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);
|
||||
};
|
||||
|
||||
//! @}
|
||||
|
||||
}
|
||||
}
|
||||
#endif /* __OPENCV_BIOINSPIRED_RETINA_HPP__ */
|
||||
138
3rdparty/include/opencv2/bioinspired/retinafasttonemapping.hpp
vendored
Normal file
138
3rdparty/include/opencv2/bioinspired/retinafasttonemapping.hpp
vendored
Normal file
@@ -0,0 +1,138 @@
|
||||
|
||||
/*#******************************************************************************
|
||||
** 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.
|
||||
**
|
||||
**
|
||||
** bioinspired : interfaces allowing OpenCV users to integrate Human Vision System models. Presented models originate from Jeanny Herault's original research and have been reused and adapted by the author&collaborators for computed vision applications since his thesis with Alice Caplier at Gipsa-Lab.
|
||||
**
|
||||
** Maintainers : Listic lab (code author current affiliation & applications) and Gipsa Lab (original research origins & applications)
|
||||
**
|
||||
** Creation - enhancement process 2007-2013
|
||||
** Author: Alexandre Benoit (benoit.alexandre.vision@gmail.com), LISTIC lab, Annecy le vieux, France
|
||||
**
|
||||
** Theses algorithm have been developped by Alexandre BENOIT since his thesis with Alice Caplier at Gipsa-Lab (www.gipsa-lab.inpg.fr) and the research he pursues at LISTIC Lab (www.listic.univ-savoie.fr).
|
||||
** Refer to the following research paper for more information:
|
||||
** Benoit A., Caplier A., Durette B., Herault, J., "USING HUMAN VISUAL SYSTEM MODELING FOR BIO-INSPIRED LOW LEVEL IMAGE PROCESSING", Elsevier, Computer Vision and Image Understanding 114 (2010), pp. 758-773, DOI: http://dx.doi.org/10.1016/j.cviu.2010.01.011
|
||||
** This work have been carried out thanks to Jeanny Herault who's research and great discussions are the basis of all this work, please take a look at his book:
|
||||
** Vision: Images, Signals and Neural Networks: Models of Neural Processing in Visual Perception (Progress in Neural Processing),By: Jeanny Herault, ISBN: 9814273686. WAPI (Tower ID): 113266891.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** This class is based on image processing tools of the author and already used within the Retina class (this is the same code as method retina::applyFastToneMapping, but in an independent class, it is ligth from a memory requirement point of view). It implements an adaptation of the efficient tone mapping algorithm propose by David Alleyson, Sabine Susstruck and Laurence Meylan's work, please cite:
|
||||
** -> Meylan L., Alleysson D., and Susstrunk S., A Model of Retinal Local Adaptation for the Tone Mapping of Color Filter Array Images, Journal of Optical Society of America, A, Vol. 24, N 9, September, 1st, 2007, pp. 2807-2816
|
||||
**
|
||||
**
|
||||
** License Agreement
|
||||
** For Open Source Computer Vision Library
|
||||
**
|
||||
** Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
|
||||
** Copyright (C) 2008-2011, Willow Garage Inc., all rights reserved.
|
||||
**
|
||||
** For Human Visual System tools (bioinspired)
|
||||
** Copyright (C) 2007-2011, LISTIC Lab, Annecy le Vieux and GIPSA Lab, Grenoble, France, 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:
|
||||
**
|
||||
** * Redistributions of source code must retain the above copyright notice,
|
||||
** this list of conditions and the following disclaimer.
|
||||
**
|
||||
** * Redistributions 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.
|
||||
*******************************************************************************/
|
||||
|
||||
#ifndef __OPENCV_BIOINSPIRED_RETINAFASTTONEMAPPING_HPP__
|
||||
#define __OPENCV_BIOINSPIRED_RETINAFASTTONEMAPPING_HPP__
|
||||
|
||||
/**
|
||||
@file
|
||||
@date May 26, 2013
|
||||
@author Alexandre Benoit
|
||||
*/
|
||||
|
||||
#include "opencv2/core.hpp" // for all OpenCV core functionalities access, including cv::Exception support
|
||||
|
||||
namespace cv{
|
||||
namespace bioinspired{
|
||||
|
||||
//! @addtogroup bioinspired
|
||||
//! @{
|
||||
|
||||
/** @brief a wrapper class which allows the tone mapping algorithm of Meylan&al(2007) to be used with OpenCV.
|
||||
|
||||
This algorithm is already implemented in thre Retina class (retina::applyFastToneMapping) but used it does not require all the retina model to be allocated. This allows a light memory use for low memory devices (smartphones, etc.
|
||||
As a summary, these are the model properties:
|
||||
- 2 stages of local luminance adaptation with a different local neighborhood for each.
|
||||
- first stage models the retina photorecetors local luminance adaptation
|
||||
- second stage models th ganglion cells local information adaptation
|
||||
- compared to the initial publication, this class uses spatio-temporal low pass filters instead of spatial only filters.
|
||||
this can help noise robustness and temporal stability for video sequence use cases.
|
||||
|
||||
for more information, read to the following papers :
|
||||
Meylan L., Alleysson D., and Susstrunk S., A Model of Retinal Local Adaptation for the Tone Mapping of Color Filter Array Images, Journal of Optical Society of America, A, Vol. 24, N 9, September, 1st, 2007, pp. 2807-2816Benoit A., Caplier A., Durette B., Herault, J., "USING HUMAN VISUAL SYSTEM MODELING FOR BIO-INSPIRED LOW LEVEL IMAGE PROCESSING", Elsevier, Computer Vision and Image Understanding 114 (2010), pp. 758-773, DOI: http://dx.doi.org/10.1016/j.cviu.2010.01.011
|
||||
regarding spatio-temporal filter and the bigger retina model :
|
||||
Vision: Images, Signals and Neural Networks: Models of Neural Processing in Visual Perception (Progress in Neural Processing),By: Jeanny Herault, ISBN: 9814273686. WAPI (Tower ID): 113266891.
|
||||
*/
|
||||
class CV_EXPORTS_W RetinaFastToneMapping : public Algorithm
|
||||
{
|
||||
public:
|
||||
|
||||
/** @brief applies a luminance correction (initially High Dynamic Range (HDR) tone mapping)
|
||||
|
||||
using only the 2 local adaptation stages of the retina parvocellular channel : photoreceptors
|
||||
level and ganlion cells level. Spatio temporal filtering is applied but limited to temporal
|
||||
smoothing and eventually high frequencies attenuation. This is a lighter method than the one
|
||||
available using the regular retina::run method. It is then faster but it does not include
|
||||
complete temporal filtering nor retina spectral whitening. Then, it can have a more limited
|
||||
effect on images with a very high dynamic range. This is an adptation of the original still
|
||||
image HDR tone mapping algorithm of David Alleyson, Sabine Susstruck and Laurence Meylan's
|
||||
work, please cite: -> Meylan L., Alleysson D., and Susstrunk S., A Model of Retinal Local
|
||||
Adaptation for the Tone Mapping of Color Filter Array Images, Journal of Optical Society of
|
||||
America, A, Vol. 24, N 9, September, 1st, 2007, pp. 2807-2816
|
||||
|
||||
@param inputImage the input image to process RGB or gray levels
|
||||
@param outputToneMappedImage the output tone mapped image
|
||||
*/
|
||||
CV_WRAP virtual void applyFastToneMapping(InputArray inputImage, OutputArray outputToneMappedImage)=0;
|
||||
|
||||
/** @brief updates tone mapping behaviors by adjusing the local luminance computation area
|
||||
|
||||
@param photoreceptorsNeighborhoodRadius the first stage local adaptation area
|
||||
@param ganglioncellsNeighborhoodRadius the second stage local adaptation area
|
||||
@param meanLuminanceModulatorK the factor applied to modulate the meanLuminance information
|
||||
(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<RetinaFastToneMapping> create(Size inputSize);
|
||||
};
|
||||
|
||||
|
||||
//! @}
|
||||
|
||||
}
|
||||
}
|
||||
#endif /* __OPENCV_BIOINSPIRED_RETINAFASTTONEMAPPING_HPP__ */
|
||||
204
3rdparty/include/opencv2/bioinspired/transientareassegmentationmodule.hpp
vendored
Normal file
204
3rdparty/include/opencv2/bioinspired/transientareassegmentationmodule.hpp
vendored
Normal file
@@ -0,0 +1,204 @@
|
||||
/*#******************************************************************************
|
||||
** 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.
|
||||
**
|
||||
**
|
||||
** bioinspired : interfaces allowing OpenCV users to integrate Human Vision System models.
|
||||
** TransientAreasSegmentationModule Use: extract areas that present spatio-temporal changes.
|
||||
** => It should be used at the output of the cv::bioinspired::Retina::getMagnoRAW() output that enhances spatio-temporal changes
|
||||
**
|
||||
** Maintainers : Listic lab (code author current affiliation & applications)
|
||||
**
|
||||
** Creation - enhancement process 2007-2015
|
||||
** Author: Alexandre Benoit (benoit.alexandre.vision@gmail.com), LISTIC lab, Annecy le vieux, France
|
||||
**
|
||||
** Theses algorithm have been developped by Alexandre BENOIT since his thesis with Alice Caplier at Gipsa-Lab (www.gipsa-lab.inpg.fr) and the research he pursues at LISTIC Lab (www.listic.univ-savoie.fr).
|
||||
** Refer to the following research paper for more information:
|
||||
** Strat, S.T.; Benoit, A.; Lambert, P., "Retina enhanced bag of words descriptors for video classification," Signal Processing Conference (EUSIPCO), 2014 Proceedings of the 22nd European , vol., no., pp.1307,1311, 1-5 Sept. 2014 (http://ieeexplore.ieee.org/stamp/stamp.jsp?tp=&arnumber=6952461&isnumber=6951911)
|
||||
** Benoit A., Caplier A., Durette B., Herault, J., "USING HUMAN VISUAL SYSTEM MODELING FOR BIO-INSPIRED LOW LEVEL IMAGE PROCESSING", Elsevier, Computer Vision and Image Understanding 114 (2010), pp. 758-773, DOI: http://dx.doi.org/10.1016/j.cviu.2010.01.011
|
||||
** This work have been carried out thanks to Jeanny Herault who's research and great discussions are the basis of all this work, please take a look at his book:
|
||||
** Vision: Images, Signals and Neural Networks: Models of Neural Processing in Visual Perception (Progress in Neural Processing),By: Jeanny Herault, ISBN: 9814273686. WAPI (Tower ID): 113266891.
|
||||
**
|
||||
**
|
||||
** License Agreement
|
||||
** For Open Source Computer Vision Library
|
||||
**
|
||||
** Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
|
||||
** Copyright (C) 2008-2011, Willow Garage Inc., all rights reserved.
|
||||
**
|
||||
** For Human Visual System tools (bioinspired)
|
||||
** Copyright (C) 2007-2015, LISTIC Lab, Annecy le Vieux and GIPSA Lab, Grenoble, France, 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:
|
||||
**
|
||||
** * Redistributions of source code must retain the above copyright notice,
|
||||
** this list of conditions and the following disclaimer.
|
||||
**
|
||||
** * Redistributions 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.
|
||||
*******************************************************************************/
|
||||
|
||||
#ifndef SEGMENTATIONMODULE_HPP_
|
||||
#define SEGMENTATIONMODULE_HPP_
|
||||
|
||||
/**
|
||||
@file
|
||||
@date 2007-2013
|
||||
@author Alexandre BENOIT, benoit.alexandre.vision@gmail.com
|
||||
*/
|
||||
|
||||
#include "opencv2/core.hpp" // for all OpenCV core functionalities access, including cv::Exception support
|
||||
|
||||
namespace cv
|
||||
{
|
||||
namespace bioinspired
|
||||
{
|
||||
//! @addtogroup 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
|
||||
SegmentationParameters():
|
||||
thresholdON(100),
|
||||
thresholdOFF(100),
|
||||
localEnergy_temporalConstant(0.5),
|
||||
localEnergy_spatialConstant(5),
|
||||
neighborhoodEnergy_temporalConstant(1),
|
||||
neighborhoodEnergy_spatialConstant(15),
|
||||
contextEnergy_temporalConstant(1),
|
||||
contextEnergy_spatialConstant(75){};
|
||||
// all properties list
|
||||
float thresholdON;
|
||||
float thresholdOFF;
|
||||
//! the time constant of the first order low pass filter, use it to cut high temporal frequencies (noise or fast motion), unit is frames, typical value is 0.5 frame
|
||||
float localEnergy_temporalConstant;
|
||||
//! the spatial constant of the first order low pass filter, use it to cut high spatial frequencies (noise or thick contours), unit is pixels, typical value is 5 pixel
|
||||
float localEnergy_spatialConstant;
|
||||
//! local neighborhood energy filtering parameters : the aim is to get information about the energy neighborhood to perform a center surround energy analysis
|
||||
float neighborhoodEnergy_temporalConstant;
|
||||
float neighborhoodEnergy_spatialConstant;
|
||||
//! context neighborhood energy filtering parameters : the aim is to get information about the energy on a wide neighborhood area to filtered out local effects
|
||||
float contextEnergy_temporalConstant;
|
||||
float contextEnergy_spatialConstant;
|
||||
};
|
||||
|
||||
/** @brief class which provides a transient/moving areas segmentation module
|
||||
|
||||
perform a locally adapted segmentation by using the retina magno input data Based on Alexandre
|
||||
BENOIT thesis: "Le système visuel humain au secours de la vision par ordinateur"
|
||||
|
||||
3 spatio temporal filters are used:
|
||||
- a first one which filters the noise and local variations of the input motion energy
|
||||
- a second (more powerfull low pass spatial filter) which gives the neighborhood motion energy the
|
||||
segmentation consists in the comparison of these both outputs, if the local motion energy is higher
|
||||
to the neighborhood otion energy, then the area is considered as moving and is segmented
|
||||
- a stronger third low pass filter helps decision by providing a smooth information about the
|
||||
"motion context" in a wider area
|
||||
*/
|
||||
|
||||
class CV_EXPORTS_W TransientAreasSegmentationModule: public Algorithm
|
||||
{
|
||||
public:
|
||||
|
||||
|
||||
/** @brief return the sze of the manage input and output images
|
||||
*/
|
||||
CV_WRAP virtual Size getSize()=0;
|
||||
|
||||
/** @brief try to open an XML segmentation parameters file to adjust current segmentation instance setup
|
||||
|
||||
- if the xml file does not exist, then default setup is applied
|
||||
- warning, Exceptions are thrown if read XML file is not valid
|
||||
@param segmentationParameterFile : the parameters filename
|
||||
@param applyDefaultSetupOnFailure : set to true if an error must be thrown on error
|
||||
*/
|
||||
CV_WRAP virtual void setup(String segmentationParameterFile="", const bool applyDefaultSetupOnFailure=true)=0;
|
||||
|
||||
/** @brief try to open an XML segmentation parameters file to adjust current segmentation instance setup
|
||||
|
||||
- if the xml file does not exist, then default setup is applied
|
||||
- warning, Exceptions are thrown if read XML file is not valid
|
||||
@param fs : the open Filestorage which contains segmentation parameters
|
||||
@param applyDefaultSetupOnFailure : set to true if an error must be thrown on error
|
||||
*/
|
||||
virtual void setup(cv::FileStorage &fs, const bool applyDefaultSetupOnFailure=true)=0;
|
||||
|
||||
/** @brief try to open an XML segmentation parameters file to adjust current segmentation instance setup
|
||||
|
||||
- if the xml file does not exist, then default setup is applied
|
||||
- warning, Exceptions are thrown if read XML file is not valid
|
||||
@param newParameters : a parameters structures updated with the new target configuration
|
||||
*/
|
||||
virtual void setup(SegmentationParameters newParameters)=0;
|
||||
|
||||
/** @brief return the current parameters setup
|
||||
*/
|
||||
virtual SegmentationParameters getParameters()=0;
|
||||
|
||||
/** @brief parameters setup display method
|
||||
@return a string which contains formatted parameters information
|
||||
*/
|
||||
CV_WRAP virtual const String printSetup()=0;
|
||||
|
||||
/** @brief write xml/yml formated parameters information
|
||||
@param fs : the filename of the xml file that will be open and writen with formatted parameters information
|
||||
*/
|
||||
CV_WRAP virtual void write( String fs ) const=0;
|
||||
|
||||
/** @brief write xml/yml formated parameters information
|
||||
@param fs : a cv::Filestorage object ready to be filled
|
||||
*/
|
||||
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 !
|
||||
@param channelIndex : the channel to process in case of multichannel images
|
||||
*/
|
||||
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
|
||||
*/
|
||||
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)
|
||||
*/
|
||||
CV_WRAP static Ptr<TransientAreasSegmentationModule> create(Size inputSize);
|
||||
};
|
||||
|
||||
//! @}
|
||||
|
||||
}} // namespaces end : cv and bioinspired
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -1510,8 +1510,8 @@ concatenated together.
|
||||
@param imageSize Size of the image used only to initialize the camera intrinsic matrix.
|
||||
@param cameraMatrix Input/output 3x3 floating-point camera intrinsic matrix
|
||||
\f$\cameramatrix{A}\f$ . If @ref CALIB_USE_INTRINSIC_GUESS
|
||||
and/or @ref CALIB_FIX_ASPECT_RATIO, @ref CALIB_FIX_PRINCIPAL_POINT or @ref CALIB_FIX_FOCAL_LENGTH
|
||||
are specified, some or all of fx, fy, cx, cy must be initialized before calling the function.
|
||||
and/or @ref CALIB_FIX_ASPECT_RATIO are specified, some or all of fx, fy, cx, cy must be
|
||||
initialized before calling the function.
|
||||
@param distCoeffs Input/output vector of distortion coefficients
|
||||
\f$\distcoeffs\f$.
|
||||
@param rvecs Output vector of rotation vectors (@ref Rodrigues ) estimated for each pattern view
|
||||
@@ -1537,7 +1537,7 @@ the number of pattern views. \f$R_i, T_i\f$ are concatenated 1x3 vectors.
|
||||
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 @ref solvePnP instead.
|
||||
estimate extrinsic parameters. Use solvePnP instead.
|
||||
- @ref 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
|
||||
@ref CALIB_USE_INTRINSIC_GUESS is set too.
|
||||
@@ -1547,23 +1547,24 @@ ratio fx/fy stays the same as in the input cameraMatrix . When
|
||||
ignored, only their ratio is computed and used further.
|
||||
- @ref CALIB_ZERO_TANGENT_DIST Tangential distortion coefficients \f$(p_1, p_2)\f$ are set
|
||||
to zeros and stay zero.
|
||||
- @ref CALIB_FIX_FOCAL_LENGTH The focal length is not changed during the global optimization if
|
||||
@ref CALIB_USE_INTRINSIC_GUESS is set.
|
||||
- @ref CALIB_FIX_K1,..., @ref CALIB_FIX_K6 The corresponding radial distortion
|
||||
coefficient is not changed during the optimization. If @ref CALIB_USE_INTRINSIC_GUESS is
|
||||
set, the coefficient from the supplied distCoeffs matrix is used. Otherwise, it is set to 0.
|
||||
- @ref 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 or more.
|
||||
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.
|
||||
- @ref CALIB_THIN_PRISM_MODEL Coefficients s1, s2, s3 and s4 are enabled. To provide the
|
||||
backward compatibility, this extra flag should be explicitly specified to make the
|
||||
calibration function use the thin prism model and return 12 coefficients or more.
|
||||
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.
|
||||
- @ref CALIB_FIX_S1_S2_S3_S4 The thin prism distortion coefficients are not changed during
|
||||
the optimization. If @ref CALIB_USE_INTRINSIC_GUESS is set, the coefficient from the
|
||||
supplied distCoeffs matrix is used. Otherwise, it is set to 0.
|
||||
- @ref 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.
|
||||
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.
|
||||
- @ref CALIB_FIX_TAUX_TAUY The coefficients of the tilted sensor model are not changed during
|
||||
the optimization. If @ref CALIB_USE_INTRINSIC_GUESS is set, the coefficient from the
|
||||
supplied distCoeffs matrix is used. Otherwise, it is set to 0.
|
||||
@@ -1588,12 +1589,12 @@ The algorithm performs the following steps:
|
||||
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 @ref solvePnP .
|
||||
done using solvePnP .
|
||||
|
||||
- Run the global Levenberg-Marquardt optimization algorithm to minimize the reprojection error,
|
||||
that is, the total sum of squared distances between the observed feature points imagePoints and
|
||||
the projected (using the current estimates for camera parameters and the poses) object points
|
||||
objectPoints. See @ref projectPoints for details.
|
||||
objectPoints. See projectPoints for details.
|
||||
|
||||
@note
|
||||
If you use a non-square (i.e. non-N-by-N) grid and @ref findChessboardCorners for calibration,
|
||||
@@ -2240,7 +2241,6 @@ final fundamental matrix. It can be set to something like 1-3, depending on the
|
||||
point localization, image resolution, and the image noise.
|
||||
@param mask Output array of N elements, every element of which is set to 0 for outliers and to 1
|
||||
for the other points. The array is computed only in the RANSAC and LMedS methods.
|
||||
@param maxIters The maximum number of robust method iterations.
|
||||
|
||||
This function estimates essential matrix based on the five-point algorithm solver in @cite Nister03 .
|
||||
@cite SteweniusCFS is also a related. The epipolar geometry is described by the following equation:
|
||||
@@ -2251,12 +2251,6 @@ where \f$E\f$ is an essential matrix, \f$p_1\f$ and \f$p_2\f$ are corresponding
|
||||
second images, respectively. The result of this function may be passed further to
|
||||
decomposeEssentialMat or recoverPose to recover the relative pose between cameras.
|
||||
*/
|
||||
CV_EXPORTS_W Mat findEssentialMat( InputArray points1, InputArray points2,
|
||||
InputArray cameraMatrix, int method,
|
||||
double prob, double threshold,
|
||||
int maxIters, OutputArray mask = noArray() );
|
||||
|
||||
/** @overload */
|
||||
CV_EXPORTS_W Mat findEssentialMat( InputArray points1, InputArray points2,
|
||||
InputArray cameraMatrix, int method = RANSAC,
|
||||
double prob = 0.999, double threshold = 1.0,
|
||||
@@ -2280,7 +2274,6 @@ point localization, image resolution, and the image noise.
|
||||
confidence (probability) that the estimated matrix is correct.
|
||||
@param mask Output array of N elements, every element of which is set to 0 for outliers and to 1
|
||||
for the other points. The array is computed only in the RANSAC and LMedS methods.
|
||||
@param maxIters The maximum number of robust method iterations.
|
||||
|
||||
This function differs from the one above that it computes camera intrinsic matrix from focal length and
|
||||
principal point:
|
||||
@@ -2292,13 +2285,6 @@ f & 0 & x_{pp} \\
|
||||
0 & 0 & 1
|
||||
\end{bmatrix}\f]
|
||||
*/
|
||||
CV_EXPORTS_W Mat findEssentialMat( InputArray points1, InputArray points2,
|
||||
double focal, Point2d pp,
|
||||
int method, double prob,
|
||||
double threshold, int maxIters,
|
||||
OutputArray mask = noArray() );
|
||||
|
||||
/** @overload */
|
||||
CV_EXPORTS_W Mat findEssentialMat( InputArray points1, InputArray points2,
|
||||
double focal = 1.0, Point2d pp = Point2d(0, 0),
|
||||
int method = RANSAC, double prob = 0.999,
|
||||
157
3rdparty/include/opencv2/ccalib.hpp
vendored
Normal file
157
3rdparty/include/opencv2/ccalib.hpp
vendored
Normal file
@@ -0,0 +1,157 @@
|
||||
/*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) 2014, OpenCV Foundation, all rights reserved.
|
||||
// Third party copyrights are property of their respective owners.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
// are permitted provided that the following conditions are met:
|
||||
//
|
||||
// * Redistribution's of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// * Redistribution's in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
//
|
||||
// * The name of the copyright holders may not be used to endorse or promote products
|
||||
// derived from this software without specific prior written permission.
|
||||
//
|
||||
// This software is provided by the copyright holders and contributors "as is" and
|
||||
// any express or implied warranties, including, but not limited to, the implied
|
||||
// warranties of merchantability and fitness for a particular purpose are disclaimed.
|
||||
// In no event shall the Intel Corporation or contributors be liable for any direct,
|
||||
// indirect, incidental, special, exemplary, or consequential damages
|
||||
// (including, but not limited to, procurement of substitute goods or services;
|
||||
// loss of use, data, or profits; or business interruption) however caused
|
||||
// and on any theory of liability, whether in contract, strict liability,
|
||||
// or tort (including negligence or otherwise) arising in any way out of
|
||||
// the use of this software, even if advised of the possibility of such damage.
|
||||
//
|
||||
//M*/
|
||||
|
||||
#ifndef __OPENCV_CCALIB_HPP__
|
||||
#define __OPENCV_CCALIB_HPP__
|
||||
|
||||
#include <opencv2/core.hpp>
|
||||
#include <opencv2/features2d.hpp>
|
||||
#include <opencv2/imgproc.hpp>
|
||||
#include <opencv2/calib3d.hpp>
|
||||
|
||||
#include <vector>
|
||||
|
||||
/** @defgroup ccalib Custom Calibration Pattern for 3D reconstruction
|
||||
*/
|
||||
|
||||
namespace cv{ namespace ccalib{
|
||||
|
||||
//! @addtogroup ccalib
|
||||
//! @{
|
||||
|
||||
class CV_EXPORTS CustomPattern : public Algorithm
|
||||
{
|
||||
public:
|
||||
CustomPattern();
|
||||
virtual ~CustomPattern();
|
||||
|
||||
bool create(InputArray pattern, const Size2f boardSize, OutputArray output = noArray());
|
||||
|
||||
bool findPattern(InputArray image, OutputArray matched_features, OutputArray pattern_points, const double ratio = 0.7,
|
||||
const double proj_error = 8.0, const bool refine_position = false, OutputArray out = noArray(),
|
||||
OutputArray H = noArray(), OutputArray pattern_corners = noArray());
|
||||
|
||||
bool isInitialized();
|
||||
|
||||
void getPatternPoints(std::vector<KeyPoint>& original_points);
|
||||
/**<
|
||||
Returns a vector<Point> of the original points.
|
||||
*/
|
||||
double getPixelSize();
|
||||
/**<
|
||||
Get the pixel size of the pattern
|
||||
*/
|
||||
|
||||
bool setFeatureDetector(Ptr<FeatureDetector> featureDetector);
|
||||
bool setDescriptorExtractor(Ptr<DescriptorExtractor> extractor);
|
||||
bool setDescriptorMatcher(Ptr<DescriptorMatcher> matcher);
|
||||
|
||||
Ptr<FeatureDetector> getFeatureDetector();
|
||||
Ptr<DescriptorExtractor> getDescriptorExtractor();
|
||||
Ptr<DescriptorMatcher> getDescriptorMatcher();
|
||||
|
||||
double calibrate(InputArrayOfArrays objectPoints, InputArrayOfArrays imagePoints,
|
||||
Size imageSize, InputOutputArray cameraMatrix, InputOutputArray distCoeffs,
|
||||
OutputArrayOfArrays rvecs, OutputArrayOfArrays tvecs, int flags = 0,
|
||||
TermCriteria criteria = TermCriteria(TermCriteria::COUNT + TermCriteria::EPS, 30, DBL_EPSILON));
|
||||
/**<
|
||||
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);
|
||||
/**<
|
||||
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);
|
||||
/**<
|
||||
Uses solvePnPRansac()
|
||||
*/
|
||||
|
||||
void drawOrientation(InputOutputArray image, InputArray tvec, InputArray rvec, InputArray cameraMatrix,
|
||||
InputArray distCoeffs, double axis_length = 3, int axis_width = 2);
|
||||
/**<
|
||||
pattern_corners -> projected over the image position of the edges of the pattern.
|
||||
*/
|
||||
|
||||
private:
|
||||
|
||||
Mat img_roi;
|
||||
std::vector<Point2f> obj_corners;
|
||||
double pxSize;
|
||||
|
||||
bool initialized;
|
||||
|
||||
Ptr<FeatureDetector> detector;
|
||||
Ptr<DescriptorExtractor> descriptorExtractor;
|
||||
Ptr<DescriptorMatcher> descriptorMatcher;
|
||||
|
||||
std::vector<KeyPoint> keypoints;
|
||||
std::vector<Point3f> points3d;
|
||||
Mat descriptor;
|
||||
|
||||
bool init(Mat& image, const float pixel_size, OutputArray output = noArray());
|
||||
bool findPatternPass(const Mat& image, std::vector<Point2f>& matched_features, std::vector<Point3f>& pattern_points,
|
||||
Mat& H, std::vector<Point2f>& scene_corners, const double pratio, const double proj_error,
|
||||
const bool refine_position = false, const Mat& mask = Mat(), OutputArray output = noArray());
|
||||
void scaleFoundPoints(const double squareSize, const std::vector<KeyPoint>& corners, std::vector<Point3f>& pts3d);
|
||||
void check_matches(std::vector<Point2f>& matched, const std::vector<Point2f>& pattern, std::vector<DMatch>& good, std::vector<Point3f>& pattern_3d, const Mat& H);
|
||||
|
||||
void keypoints2points(const std::vector<KeyPoint>& in, std::vector<Point2f>& out);
|
||||
void updateKeypointsPos(std::vector<KeyPoint>& in, const std::vector<Point2f>& new_pos);
|
||||
void refinePointsPos(const Mat& img, std::vector<Point2f>& p);
|
||||
void refineKeypointsPos(const Mat& img, std::vector<KeyPoint>& kp);
|
||||
};
|
||||
|
||||
//! @}
|
||||
|
||||
}} // namespace ccalib, cv
|
||||
|
||||
#endif
|
||||
212
3rdparty/include/opencv2/ccalib/multicalib.hpp
vendored
Normal file
212
3rdparty/include/opencv2/ccalib/multicalib.hpp
vendored
Normal file
@@ -0,0 +1,212 @@
|
||||
/*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) 2015, Baisheng Lai (laibaisheng@gmail.com), Zhejiang University,
|
||||
// all rights reserved.
|
||||
//
|
||||
// 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_MULTICAMERACALIBRATION_HPP__
|
||||
#define __OPENCV_MULTICAMERACALIBRATION_HPP__
|
||||
|
||||
#include "opencv2/ccalib/randpattern.hpp"
|
||||
#include "opencv2/ccalib/omnidir.hpp"
|
||||
#include <string>
|
||||
#include <iostream>
|
||||
|
||||
namespace cv { namespace multicalib {
|
||||
|
||||
//! @addtogroup ccalib
|
||||
//! @{
|
||||
|
||||
#define HEAD -1
|
||||
#define INVALID -2
|
||||
|
||||
/** @brief Class for multiple camera calibration that supports pinhole camera and omnidirection camera.
|
||||
For omnidirectional camera model, please refer to omnidir.hpp in ccalib module.
|
||||
It first calibrate each camera individually, then a bundle adjustment like optimization is applied to
|
||||
refine extrinsic parameters. So far, it only support "random" pattern for calibration,
|
||||
see randomPattern.hpp in ccalib module for details.
|
||||
Images that are used should be named by "cameraIdx-timestamp.*", several images with the same timestamp
|
||||
means that they are the same pattern that are photographed. cameraIdx should start from 0.
|
||||
|
||||
For more details, please refer to paper
|
||||
B. Li, L. Heng, K. Kevin and M. Pollefeys, "A Multiple-Camera System
|
||||
Calibration Toolbox Using A Feature Descriptor-Based Calibration
|
||||
Pattern", in IROS 2013.
|
||||
*/
|
||||
|
||||
class CV_EXPORTS MultiCameraCalibration
|
||||
{
|
||||
public:
|
||||
enum {
|
||||
PINHOLE,
|
||||
OMNIDIRECTIONAL
|
||||
//FISHEYE
|
||||
};
|
||||
|
||||
// an edge connects a camera and pattern
|
||||
struct edge
|
||||
{
|
||||
int cameraVertex; // vertex index for camera in this edge
|
||||
int photoVertex; // vertex index for pattern in this edge
|
||||
int photoIndex; // photo index among photos for this camera
|
||||
Mat transform; // transform from pattern to camera
|
||||
|
||||
edge(int cv, int pv, int pi, Mat trans)
|
||||
{
|
||||
cameraVertex = cv;
|
||||
photoVertex = pv;
|
||||
photoIndex = pi;
|
||||
transform = trans;
|
||||
}
|
||||
};
|
||||
|
||||
struct vertex
|
||||
{
|
||||
Mat pose; // relative pose to the first camera. For camera vertex, it is the
|
||||
// transform from the first camera to this camera, for pattern vertex,
|
||||
// it is the transform from pattern to the first camera
|
||||
int timestamp; // timestamp of photo, only available for photo vertex
|
||||
|
||||
vertex(Mat po, int ts)
|
||||
{
|
||||
pose = po;
|
||||
timestamp = ts;
|
||||
}
|
||||
|
||||
vertex()
|
||||
{
|
||||
pose = Mat::eye(4, 4, CV_32F);
|
||||
timestamp = -1;
|
||||
}
|
||||
};
|
||||
/* @brief Constructor
|
||||
@param cameraType camera type, PINHOLE or OMNIDIRECTIONAL
|
||||
@param nCameras number of cameras
|
||||
@fileName filename of string list that are used for calibration, the file is generated
|
||||
by imagelist_creator from OpenCv samples. The first one in the list is the pattern filename.
|
||||
@patternWidth the physical width of pattern, in user defined unit.
|
||||
@patternHeight the physical height of pattern, in user defined unit.
|
||||
@showExtration whether show extracted features and feature filtering.
|
||||
@nMiniMatches minimal number of matched features for a frame.
|
||||
@flags Calibration flags
|
||||
@criteria optimization stopping criteria.
|
||||
@detector feature detector that detect feature points in pattern and images.
|
||||
@descriptor feature descriptor.
|
||||
@matcher feature matcher.
|
||||
*/
|
||||
MultiCameraCalibration(int cameraType, int nCameras, const std::string& fileName, float patternWidth,
|
||||
float patternHeight, int verbose = 0, int showExtration = 0, int nMiniMatches = 20, int flags = 0,
|
||||
TermCriteria criteria = TermCriteria(TermCriteria::COUNT + TermCriteria::EPS, 200, 1e-7),
|
||||
Ptr<FeatureDetector> detector = AKAZE::create(AKAZE::DESCRIPTOR_MLDB, 0, 3, 0.006f),
|
||||
Ptr<DescriptorExtractor> descriptor = AKAZE::create(AKAZE::DESCRIPTOR_MLDB,0, 3, 0.006f),
|
||||
Ptr<DescriptorMatcher> matcher = DescriptorMatcher::create("BruteForce-L1"));
|
||||
|
||||
/* @brief load images
|
||||
*/
|
||||
void loadImages();
|
||||
|
||||
/* @brief initialize multiple camera calibration. It calibrates each camera individually.
|
||||
*/
|
||||
void initialize();
|
||||
|
||||
/* @brief optimization extrinsic parameters
|
||||
*/
|
||||
double optimizeExtrinsics();
|
||||
|
||||
/* @brief run multi-camera camera calibration, it runs loadImage(), initialize() and optimizeExtrinsics()
|
||||
*/
|
||||
double run();
|
||||
|
||||
/* @brief write camera parameters to file.
|
||||
*/
|
||||
void writeParameters(const std::string& filename);
|
||||
|
||||
private:
|
||||
std::vector<std::string> readStringList();
|
||||
|
||||
int getPhotoVertex(int timestamp);
|
||||
|
||||
void graphTraverse(const Mat& G, int begin, std::vector<int>& order, std::vector<int>& pre);
|
||||
|
||||
void findRowNonZero(const Mat& row, Mat& idx);
|
||||
|
||||
void computeJacobianExtrinsic(const Mat& extrinsicParams, Mat& JTJ_inv, Mat& JTE);
|
||||
|
||||
void computePhotoCameraJacobian(const Mat& rvecPhoto, const Mat& tvecPhoto, const Mat& rvecCamera,
|
||||
const Mat& tvecCamera, Mat& rvecTran, Mat& tvecTran, const Mat& objectPoints, const Mat& imagePoints, const Mat& K,
|
||||
const Mat& distort, const Mat& xi, Mat& jacobianPhoto, Mat& jacobianCamera, Mat& E);
|
||||
|
||||
void compose_motion(InputArray _om1, InputArray _T1, InputArray _om2, InputArray _T2, Mat& om3, Mat& T3, Mat& dom3dom1,
|
||||
Mat& dom3dT1, Mat& dom3dom2, Mat& dom3dT2, Mat& dT3dom1, Mat& dT3dT1, Mat& dT3dom2, Mat& dT3dT2);
|
||||
|
||||
void JRodriguesMatlab(const Mat& src, Mat& dst);
|
||||
void dAB(InputArray A, InputArray B, OutputArray dABdA, OutputArray dABdB);
|
||||
|
||||
double computeProjectError(Mat& parameters);
|
||||
|
||||
void vector2parameters(const Mat& parameters, std::vector<Vec3f>& rvecVertex, std::vector<Vec3f>& tvecVertexs);
|
||||
void parameters2vector(const std::vector<Vec3f>& rvecVertex, const std::vector<Vec3f>& tvecVertex, Mat& parameters);
|
||||
|
||||
int _camType; //PINHOLE, FISHEYE or OMNIDIRECTIONAL
|
||||
int _nCamera;
|
||||
int _nMiniMatches;
|
||||
int _flags;
|
||||
int _verbose;
|
||||
double _error;
|
||||
float _patternWidth, _patternHeight;
|
||||
TermCriteria _criteria;
|
||||
std::string _filename;
|
||||
int _showExtraction;
|
||||
Ptr<FeatureDetector> _detector;
|
||||
Ptr<DescriptorExtractor> _descriptor;
|
||||
Ptr<DescriptorMatcher> _matcher;
|
||||
|
||||
std::vector<edge> _edgeList;
|
||||
std::vector<vertex> _vertexList;
|
||||
std::vector<std::vector<cv::Mat> > _objectPointsForEachCamera;
|
||||
std::vector<std::vector<cv::Mat> > _imagePointsForEachCamera;
|
||||
std::vector<cv::Mat> _cameraMatrix;
|
||||
std::vector<cv::Mat> _distortCoeffs;
|
||||
std::vector<cv::Mat> _xi;
|
||||
std::vector<std::vector<Mat> > _omEachCamera, _tEachCamera;
|
||||
};
|
||||
|
||||
//! @}
|
||||
|
||||
}} // namespace multicalib, cv
|
||||
#endif
|
||||
315
3rdparty/include/opencv2/ccalib/omnidir.hpp
vendored
Normal file
315
3rdparty/include/opencv2/ccalib/omnidir.hpp
vendored
Normal file
@@ -0,0 +1,315 @@
|
||||
/*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) 2015, Baisheng Lai (laibaisheng@gmail.com), Zhejiang University,
|
||||
// all rights reserved.
|
||||
//
|
||||
// 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_OMNIDIR_HPP__
|
||||
#define __OPENCV_OMNIDIR_HPP__
|
||||
|
||||
#include "opencv2/core.hpp"
|
||||
#include "opencv2/core/affine.hpp"
|
||||
#include <vector>
|
||||
|
||||
namespace cv
|
||||
{
|
||||
namespace omnidir
|
||||
{
|
||||
//! @addtogroup ccalib
|
||||
//! @{
|
||||
|
||||
enum {
|
||||
CALIB_USE_GUESS = 1,
|
||||
CALIB_FIX_SKEW = 2,
|
||||
CALIB_FIX_K1 = 4,
|
||||
CALIB_FIX_K2 = 8,
|
||||
CALIB_FIX_P1 = 16,
|
||||
CALIB_FIX_P2 = 32,
|
||||
CALIB_FIX_XI = 64,
|
||||
CALIB_FIX_GAMMA = 128,
|
||||
CALIB_FIX_CENTER = 256
|
||||
};
|
||||
|
||||
enum{
|
||||
RECTIFY_PERSPECTIVE = 1,
|
||||
RECTIFY_CYLINDRICAL = 2,
|
||||
RECTIFY_LONGLATI = 3,
|
||||
RECTIFY_STEREOGRAPHIC = 4
|
||||
};
|
||||
|
||||
enum{
|
||||
XYZRGB = 1,
|
||||
XYZ = 2
|
||||
};
|
||||
/**
|
||||
* This module was accepted as a GSoC 2015 project for OpenCV, authored by
|
||||
* Baisheng Lai, mentored by Bo Li.
|
||||
*/
|
||||
|
||||
/** @brief Projects points for omnidirectional camera using CMei's model
|
||||
|
||||
@param objectPoints Object points in world coordinate, vector of vector of Vec3f or Mat of
|
||||
1xN/Nx1 3-channel of type CV_32F and N is the number of points. 64F is also acceptable.
|
||||
@param imagePoints Output array of image points, vector of vector of Vec2f or
|
||||
1xN/Nx1 2-channel of type CV_32F. 64F is also acceptable.
|
||||
@param rvec vector of rotation between world coordinate and camera coordinate, i.e., om
|
||||
@param tvec vector of translation between pattern coordinate and camera coordinate
|
||||
@param K Camera matrix \f$K = \vecthreethree{f_x}{s}{c_x}{0}{f_y}{c_y}{0}{0}{_1}\f$.
|
||||
@param D Input vector of distortion coefficients \f$(k_1, k_2, p_1, p_2)\f$.
|
||||
@param xi The parameter xi for CMei's model
|
||||
@param jacobian Optional output 2Nx16 of type CV_64F jacobian matrix, contains the derivatives of
|
||||
image pixel points wrt parameters including \f$om, T, f_x, f_y, s, c_x, c_y, xi, k_1, k_2, p_1, p_2\f$.
|
||||
This matrix will be used in calibration by optimization.
|
||||
|
||||
The function projects object 3D points of world coordinate to image pixels, parameter by intrinsic
|
||||
and extrinsic parameters. Also, it optionally compute a by-product: the jacobian matrix containing
|
||||
contains the derivatives of image pixel points wrt intrinsic and extrinsic parameters.
|
||||
*/
|
||||
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
|
||||
or 1xN/Nx1 2-channel Mat of type CV_32F, 64F depth is also acceptable
|
||||
@param K Camera matrix \f$K = \vecthreethree{f_x}{s}{c_x}{0}{f_y}{c_y}{0}{0}{_1}\f$.
|
||||
@param D Distortion coefficients \f$(k_1, k_2, p_1, p_2)\f$.
|
||||
@param xi The parameter xi for CMei's model
|
||||
@param R Rotation trainsform between the original and object space : 3x3 1-channel, or vector: 3x1/1x3
|
||||
1-channel or 1x1 3-channel
|
||||
@param undistorted array of normalized object points, vector of Vec2f/Vec2d or 1xN/Nx1 2-channel Mat with the same
|
||||
depth of distorted points.
|
||||
*/
|
||||
CV_EXPORTS_W void undistortPoints(InputArray distorted, OutputArray undistorted, InputArray K, InputArray D, InputArray xi, InputArray R);
|
||||
|
||||
/** @brief Computes undistortion and rectification maps for omnidirectional camera image transform by a rotation R.
|
||||
It output two maps that are used for cv::remap(). If D is empty then zero distortion is used,
|
||||
if R or P is empty then identity matrices are used.
|
||||
|
||||
@param K Camera matrix \f$K = \vecthreethree{f_x}{s}{c_x}{0}{f_y}{c_y}{0}{0}{_1}\f$, with depth CV_32F or CV_64F
|
||||
@param D Input vector of distortion coefficients \f$(k_1, k_2, p_1, p_2)\f$, with depth CV_32F or CV_64F
|
||||
@param xi The parameter xi for CMei's model
|
||||
@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 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.
|
||||
@param flags Flags indicates the rectification type, RECTIFY_PERSPECTIVE, RECTIFY_CYLINDRICAL, RECTIFY_LONGLATI and RECTIFY_STEREOGRAPHIC
|
||||
are supported.
|
||||
*/
|
||||
CV_EXPORTS_W void initUndistortRectifyMap(InputArray K, InputArray D, InputArray xi, InputArray R, InputArray P, const cv::Size& size,
|
||||
int m1type, OutputArray map1, OutputArray map2, int flags);
|
||||
|
||||
/** @brief Undistort omnidirectional images to perspective images
|
||||
|
||||
@param distorted The input omnidirectional image.
|
||||
@param undistorted The output undistorted image.
|
||||
@param K Camera matrix \f$K = \vecthreethree{f_x}{s}{c_x}{0}{f_y}{c_y}{0}{0}{_1}\f$.
|
||||
@param D Input vector of distortion coefficients \f$(k_1, k_2, p_1, p_2)\f$.
|
||||
@param xi The parameter xi for CMei's model.
|
||||
@param flags Flags indicates the rectification type, RECTIFY_PERSPECTIVE, RECTIFY_CYLINDRICAL, RECTIFY_LONGLATI and RECTIFY_STEREOGRAPHIC
|
||||
@param Knew Camera matrix of the distorted image. If it is not assigned, it is just K.
|
||||
@param new_size The new image size. By default, it is the size of distorted.
|
||||
@param R Rotation matrix between the input and output images. By default, it is identity matrix.
|
||||
*/
|
||||
CV_EXPORTS_W void undistortImage(InputArray distorted, OutputArray undistorted, InputArray K, InputArray D, InputArray xi, int flags,
|
||||
InputArray Knew = cv::noArray(), const Size& new_size = Size(), InputArray R = Mat::eye(3, 3, CV_64F));
|
||||
|
||||
/** @brief Perform omnidirectional camera calibration, the default depth of outputs is CV_64F.
|
||||
|
||||
@param objectPoints Vector of vector of Vec3f object points in world (pattern) coordinate.
|
||||
It also can be vector of Mat with size 1xN/Nx1 and type CV_32FC3. Data with depth of 64_F is also acceptable.
|
||||
@param imagePoints Vector of vector of Vec2f corresponding image points of objectPoints. It must be the same
|
||||
size and the same type with objectPoints.
|
||||
@param size Image size of calibration images.
|
||||
@param K Output calibrated camera matrix.
|
||||
@param xi Output parameter xi for CMei's model
|
||||
@param D Output distortion parameters \f$(k_1, k_2, p_1, p_2)\f$
|
||||
@param rvecs Output rotations for each calibration images
|
||||
@param tvecs Output translation for each calibration images
|
||||
@param flags The flags that control calibrate
|
||||
@param criteria Termination criteria for optimization
|
||||
@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(InputArrayOfArrays objectPoints, InputArrayOfArrays imagePoints, Size size,
|
||||
InputOutputArray K, InputOutputArray xi, InputOutputArray D, OutputArrayOfArrays rvecs, OutputArrayOfArrays tvecs,
|
||||
int flags, TermCriteria criteria, OutputArray idx=noArray());
|
||||
|
||||
/** @brief Stereo calibration for omnidirectional camera model. It computes the intrinsic parameters for two
|
||||
cameras and the extrinsic parameters between two cameras. The default depth of outputs is CV_64F.
|
||||
|
||||
@param objectPoints Object points in world (pattern) coordinate. Its type is vector<vector<Vec3f> >.
|
||||
It also can be vector of Mat with size 1xN/Nx1 and type CV_32FC3. Data with depth of 64_F is also acceptable.
|
||||
@param imagePoints1 The corresponding image points of the first camera, with type vector<vector<Vec2f> >.
|
||||
It must be the same size and the same type as objectPoints.
|
||||
@param imagePoints2 The corresponding image points of the second camera, with type vector<vector<Vec2f> >.
|
||||
It must be the same size and the same type as objectPoints.
|
||||
@param imageSize1 Image size of calibration images of the first camera.
|
||||
@param imageSize2 Image size of calibration images of the second camera.
|
||||
@param K1 Output camera matrix for the first camera.
|
||||
@param xi1 Output parameter xi of Mei's model for the first camera
|
||||
@param D1 Output distortion parameters \f$(k_1, k_2, p_1, p_2)\f$ for the first camera
|
||||
@param K2 Output camera matrix for the first camera.
|
||||
@param xi2 Output parameter xi of CMei's model for the second camera
|
||||
@param D2 Output distortion parameters \f$(k_1, k_2, p_1, p_2)\f$ for the second camera
|
||||
@param rvec Output rotation between the first and second camera
|
||||
@param tvec Output translation between the first and second camera
|
||||
@param rvecsL Output rotation for each image of the first camera
|
||||
@param tvecsL Output translation for each image of the first camera
|
||||
@param flags The flags that control stereoCalibrate
|
||||
@param criteria Termination criteria for optimization
|
||||
@param idx Indices of image pairs that pass initialization, which are really used in calibration. So the size of rvecs is the
|
||||
same as idx.total().
|
||||
@
|
||||
*/
|
||||
CV_EXPORTS_W double stereoCalibrate(InputOutputArrayOfArrays objectPoints, InputOutputArrayOfArrays imagePoints1, InputOutputArrayOfArrays imagePoints2,
|
||||
const Size& imageSize1, const Size& imageSize2, InputOutputArray K1, InputOutputArray xi1, InputOutputArray D1, InputOutputArray K2, InputOutputArray xi2,
|
||||
InputOutputArray D2, OutputArray rvec, OutputArray tvec, OutputArrayOfArrays rvecsL, OutputArrayOfArrays tvecsL, int flags, TermCriteria criteria, OutputArray idx=noArray());
|
||||
|
||||
/** @brief Stereo rectification for omnidirectional camera model. It computes the rectification rotations for two cameras
|
||||
|
||||
@param R Rotation between the first and second camera
|
||||
@param T Translation between the first and second camera
|
||||
@param R1 Output 3x3 rotation matrix for the first camera
|
||||
@param R2 Output 3x3 rotation matrix for the second camera
|
||||
*/
|
||||
CV_EXPORTS_W void stereoRectify(InputArray R, InputArray T, OutputArray R1, OutputArray R2);
|
||||
|
||||
/** @brief Stereo 3D reconstruction from a pair of images
|
||||
|
||||
@param image1 The first input image
|
||||
@param image2 The second input image
|
||||
@param K1 Input camera matrix of the first camera
|
||||
@param D1 Input distortion parameters \f$(k_1, k_2, p_1, p_2)\f$ for the first camera
|
||||
@param xi1 Input parameter xi for the first camera for CMei's model
|
||||
@param K2 Input camera matrix of the second camera
|
||||
@param D2 Input distortion parameters \f$(k_1, k_2, p_1, p_2)\f$ for the second camera
|
||||
@param xi2 Input parameter xi for the second camera for CMei's model
|
||||
@param R Rotation between the first and second camera
|
||||
@param T Translation between the first and second camera
|
||||
@param flag Flag of rectification type, RECTIFY_PERSPECTIVE or RECTIFY_LONGLATI
|
||||
@param numDisparities The parameter 'numDisparities' in StereoSGBM, see StereoSGBM for details.
|
||||
@param SADWindowSize The parameter 'SADWindowSize' in StereoSGBM, see StereoSGBM for details.
|
||||
@param disparity Disparity map generated by stereo matching
|
||||
@param image1Rec Rectified image of the first image
|
||||
@param image2Rec rectified image of the second image
|
||||
@param newSize Image size of rectified image, see omnidir::undistortImage
|
||||
@param Knew New camera matrix of rectified image, see omnidir::undistortImage
|
||||
@param pointCloud Point cloud of 3D reconstruction, with type CV_64FC3
|
||||
@param pointType Point cloud type, it can be XYZRGB or XYZ
|
||||
*/
|
||||
CV_EXPORTS_W void stereoReconstruct(InputArray image1, InputArray image2, InputArray K1, InputArray D1, InputArray xi1,
|
||||
InputArray K2, InputArray D2, InputArray xi2, InputArray R, InputArray T, int flag, int numDisparities, int SADWindowSize,
|
||||
OutputArray disparity, OutputArray image1Rec, OutputArray image2Rec, const Size& newSize = Size(), InputArray Knew = cv::noArray(),
|
||||
OutputArray pointCloud = cv::noArray(), int pointType = XYZRGB);
|
||||
|
||||
namespace internal
|
||||
{
|
||||
void initializeCalibration(InputArrayOfArrays objectPoints, InputArrayOfArrays imagePoints, Size size, OutputArrayOfArrays omAll,
|
||||
OutputArrayOfArrays tAll, OutputArray K, double& xi, OutputArray idx = noArray());
|
||||
|
||||
void initializeStereoCalibration(InputArrayOfArrays objectPoints, InputArrayOfArrays imagePoints1, InputArrayOfArrays imagePoints2,
|
||||
const Size& size1, const Size& size2, OutputArray om, OutputArray T, OutputArrayOfArrays omL, OutputArrayOfArrays tL, OutputArray K1, OutputArray D1, OutputArray K2, OutputArray D2,
|
||||
double &xi1, double &xi2, int flags, OutputArray idx);
|
||||
|
||||
void computeJacobian(InputArrayOfArrays objectPoints, InputArrayOfArrays imagePoints, InputArray parameters, Mat& JTJ_inv, Mat& JTE, int flags,
|
||||
double epsilon);
|
||||
|
||||
void computeJacobianStereo(InputArrayOfArrays objectPoints, InputArrayOfArrays imagePoints1, InputArrayOfArrays imagePoints2,
|
||||
InputArray parameters, Mat& JTJ_inv, Mat& JTE, int flags, double epsilon);
|
||||
|
||||
void encodeParameters(InputArray K, InputArrayOfArrays omAll, InputArrayOfArrays tAll, InputArray distoaration, double xi, OutputArray parameters);
|
||||
|
||||
void encodeParametersStereo(InputArray K1, InputArray K2, InputArray om, InputArray T, InputArrayOfArrays omL, InputArrayOfArrays tL,
|
||||
InputArray D1, InputArray D2, double xi1, double xi2, OutputArray parameters);
|
||||
|
||||
void decodeParameters(InputArray paramsters, OutputArray K, OutputArrayOfArrays omAll, OutputArrayOfArrays tAll, OutputArray distoration, double& xi);
|
||||
|
||||
void decodeParametersStereo(InputArray parameters, OutputArray K1, OutputArray K2, OutputArray om, OutputArray T, OutputArrayOfArrays omL,
|
||||
OutputArrayOfArrays tL, OutputArray D1, OutputArray D2, double& xi1, double& xi2);
|
||||
|
||||
void estimateUncertainties(InputArrayOfArrays objectPoints, InputArrayOfArrays imagePoints, InputArray parameters, Mat& errors, Vec2d& std_error, double& rms, int flags);
|
||||
|
||||
void estimateUncertaintiesStereo(InputArrayOfArrays objectPoints, InputArrayOfArrays imagePoints1, InputArrayOfArrays imagePoints2, InputArray parameters, Mat& errors,
|
||||
Vec2d& std_error, double& rms, int flags);
|
||||
|
||||
double computeMeanReproErr(InputArrayOfArrays imagePoints, InputArrayOfArrays proImagePoints);
|
||||
|
||||
double computeMeanReproErr(InputArrayOfArrays objectPoints, InputArrayOfArrays imagePoints, InputArray K, InputArray D, double xi, InputArrayOfArrays omAll,
|
||||
InputArrayOfArrays tAll);
|
||||
|
||||
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 subMatrix(const Mat& src, Mat& dst, const std::vector<int>& cols, const std::vector<int>& rows);
|
||||
|
||||
void flags2idx(int flags, std::vector<int>& idx, int n);
|
||||
|
||||
void flags2idxStereo(int flags, std::vector<int>& idx, int n);
|
||||
|
||||
void fillFixed(Mat&G, int flags, int n);
|
||||
|
||||
void fillFixedStereo(Mat& G, int flags, int n);
|
||||
|
||||
double findMedian(const Mat& row);
|
||||
|
||||
Vec3d findMedian3(InputArray mat);
|
||||
|
||||
void getInterset(InputArray idx1, InputArray idx2, OutputArray inter1, OutputArray inter2, OutputArray inter_ori);
|
||||
|
||||
void compose_motion(InputArray _om1, InputArray _T1, InputArray _om2, InputArray _T2, Mat& om3, Mat& T3, Mat& dom3dom1,
|
||||
Mat& dom3dT1, Mat& dom3dom2, Mat& dom3dT2, Mat& dT3dom1, Mat& dT3dT1, Mat& dT3dom2, Mat& dT3dT2);
|
||||
|
||||
//void JRodriguesMatlab(const Mat& src, Mat& dst);
|
||||
|
||||
//void dAB(InputArray A, InputArray B, OutputArray dABdA, OutputArray dABdB);
|
||||
} // internal
|
||||
|
||||
//! @}
|
||||
|
||||
} // omnidir
|
||||
|
||||
} //cv
|
||||
#endif
|
||||
184
3rdparty/include/opencv2/ccalib/randpattern.hpp
vendored
Normal file
184
3rdparty/include/opencv2/ccalib/randpattern.hpp
vendored
Normal file
@@ -0,0 +1,184 @@
|
||||
/*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) 2015, Baisheng Lai (laibaisheng@gmail.com), Zhejiang University,
|
||||
// all rights reserved.
|
||||
//
|
||||
// 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_RANDOMPATTERN_HPP__
|
||||
#define __OPENCV_RANDOMPATTERN_HPP__
|
||||
|
||||
#include "opencv2/features2d.hpp"
|
||||
#include "opencv2/highgui.hpp"
|
||||
|
||||
namespace cv { namespace randpattern {
|
||||
|
||||
|
||||
//! @addtogroup ccalib
|
||||
//! @{
|
||||
|
||||
/** @brief Class for finding features points and corresponding 3D in world coordinate of
|
||||
a "random" pattern, which can be to be used in calibration. It is useful when pattern is
|
||||
partly occluded or only a part of pattern can be observed in multiple cameras calibration.
|
||||
The pattern can be generated by RandomPatternGenerator class described in this file.
|
||||
|
||||
Please refer to paper
|
||||
B. Li, L. Heng, K. Kevin and M. Pollefeys, "A Multiple-Camera System
|
||||
Calibration Toolbox Using A Feature Descriptor-Based Calibration
|
||||
Pattern", in IROS 2013.
|
||||
*/
|
||||
|
||||
class CV_EXPORTS RandomPatternCornerFinder
|
||||
{
|
||||
public:
|
||||
|
||||
/* @brief Construct RandomPatternCornerFinder object
|
||||
|
||||
@param patternWidth the real width of "random" pattern in a user defined unit.
|
||||
@param patternHeight the real height of "random" pattern in a user defined unit.
|
||||
@param nMiniMatch number of minimal matches, otherwise that image is abandoned
|
||||
@depth depth of output objectPoints and imagePoints, set it to be CV_32F or CV_64F.
|
||||
@showExtraction whether show feature extraction, 0 for no and 1 for yes.
|
||||
@detector feature detector to detect feature points in pattern and images.
|
||||
@descriptor feature descriptor.
|
||||
@matcher feature matcher.
|
||||
*/
|
||||
RandomPatternCornerFinder(float patternWidth, float patternHeight,
|
||||
int nminiMatch = 20, int depth = CV_32F, int verbose = 0, int showExtraction = 0,
|
||||
Ptr<FeatureDetector> detector = AKAZE::create(AKAZE::DESCRIPTOR_MLDB, 0, 3, 0.005f),
|
||||
Ptr<DescriptorExtractor> descriptor = AKAZE::create(AKAZE::DESCRIPTOR_MLDB,0, 3, 0.005f),
|
||||
Ptr<DescriptorMatcher> matcher = DescriptorMatcher::create("BruteForce-L1"));
|
||||
|
||||
/* @brief Load pattern image and compute features for pattern
|
||||
@param patternImage image for "random" pattern generated by RandomPatternGenerator, run it first.
|
||||
*/
|
||||
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<cv::KeyPoint> &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()
|
||||
and getImagePoints() to get them.
|
||||
|
||||
@param inputImages vector of 8-bit grayscale images containing "random" pattern
|
||||
that are used for calibration.
|
||||
*/
|
||||
void computeObjectImagePoints(std::vector<cv::Mat> inputImages);
|
||||
|
||||
//void computeObjectImagePoints2(std::vector<cv::Mat> inputImages);
|
||||
|
||||
/* @brief Compute object and image points for a single image. It returns a vector<Mat> that
|
||||
the first element stores the imagePoints and the second one stores the objectPoints.
|
||||
|
||||
@param inputImage single input image for calibration
|
||||
*/
|
||||
std::vector<cv::Mat> computeObjectImagePointsForSingle(cv::Mat inputImage);
|
||||
|
||||
/* @brief Get object(3D) points
|
||||
*/
|
||||
const std::vector<cv::Mat> &getObjectPoints();
|
||||
|
||||
/* @brief and image(2D) points
|
||||
*/
|
||||
const std::vector<cv::Mat> &getImagePoints();
|
||||
|
||||
private:
|
||||
|
||||
std::vector<cv::Mat> _objectPonits, _imagePoints;
|
||||
float _patternWidth, _patternHeight;
|
||||
cv::Size _patternImageSize;
|
||||
int _nminiMatch;
|
||||
int _depth;
|
||||
int _verbose;
|
||||
|
||||
Ptr<FeatureDetector> _detector;
|
||||
Ptr<DescriptorExtractor> _descriptor;
|
||||
Ptr<DescriptorMatcher> _matcher;
|
||||
Mat _descriptorPattern;
|
||||
std::vector<cv::KeyPoint> _keypointsPattern;
|
||||
Mat _patternImage;
|
||||
int _showExtraction;
|
||||
|
||||
void keyPoints2MatchedLocation(const std::vector<cv::KeyPoint>& imageKeypoints,
|
||||
const std::vector<cv::KeyPoint>& patternKeypoints, const std::vector<cv::DMatch> matchces,
|
||||
cv::Mat& matchedImagelocation, cv::Mat& matchedPatternLocation);
|
||||
void getFilteredLocation(cv::Mat& imageKeypoints, cv::Mat& patternKeypoints, const cv::Mat mask);
|
||||
void getObjectImagePoints(const cv::Mat& imageKeypoints, const cv::Mat& patternKeypoints);
|
||||
void crossCheckMatching( cv::Ptr<DescriptorMatcher>& descriptorMatcher,
|
||||
const Mat& descriptors1, const Mat& descriptors2,
|
||||
std::vector<DMatch>& filteredMatches12, int knn=1 );
|
||||
void drawCorrespondence(const Mat& image1, const std::vector<cv::KeyPoint> keypoint1,
|
||||
const Mat& image2, const std::vector<cv::KeyPoint> keypoint2, const std::vector<cv::DMatch> matchces,
|
||||
const Mat& mask1, const Mat& mask2, const int step);
|
||||
};
|
||||
|
||||
/* @brief Class to generate "random" pattern image that are used for RandomPatternCornerFinder
|
||||
Please refer to paper
|
||||
B. Li, L. Heng, K. Kevin and M. Pollefeys, "A Multiple-Camera System
|
||||
Calibration Toolbox Using A Feature Descriptor-Based Calibration
|
||||
Pattern", in IROS 2013.
|
||||
*/
|
||||
class CV_EXPORTS RandomPatternGenerator
|
||||
{
|
||||
public:
|
||||
/* @brief Construct RandomPatternGenerator
|
||||
|
||||
@param imageWidth image width of the generated pattern image
|
||||
@param imageHeight image height of the generated pattern image
|
||||
*/
|
||||
RandomPatternGenerator(int imageWidth, int imageHeight);
|
||||
|
||||
/* @brief Generate pattern
|
||||
*/
|
||||
void generatePattern();
|
||||
/* @brief Get pattern
|
||||
*/
|
||||
cv::Mat getPattern();
|
||||
private:
|
||||
cv::Mat _pattern;
|
||||
int _imageWidth, _imageHeight;
|
||||
};
|
||||
|
||||
//! @}
|
||||
|
||||
}} //namespace randpattern, cv
|
||||
#endif
|
||||
@@ -50,6 +50,7 @@
|
||||
#endif
|
||||
|
||||
#include "opencv2/core/cvdef.h"
|
||||
#include "opencv2/core/version.hpp"
|
||||
#include "opencv2/core/base.hpp"
|
||||
#include "opencv2/core/cvstd.hpp"
|
||||
#include "opencv2/core/traits.hpp"
|
||||
@@ -587,21 +587,6 @@ _AccTp normInf(const _Tp* a, const _Tp* b, int n)
|
||||
*/
|
||||
CV_EXPORTS_W float cubeRoot(float val);
|
||||
|
||||
/** @overload
|
||||
|
||||
cubeRoot with argument of `double` type calls `std::cbrt(double)` (C++11) or falls back on `pow()` for C++98 compilation mode.
|
||||
*/
|
||||
static inline
|
||||
double cubeRoot(double val)
|
||||
{
|
||||
#ifdef CV_CXX11
|
||||
return std::cbrt(val);
|
||||
#else
|
||||
double v = pow(abs(val), 1/3.); // pow doesn't support negative inputs with fractional exponents
|
||||
return val >= 0 ? v : -v;
|
||||
#endif
|
||||
}
|
||||
|
||||
/** @brief Calculates the angle of a 2D vector in degrees.
|
||||
|
||||
The function fastAtan2 calculates the full-range angle of an input 2D vector. The angle is measured
|
||||
@@ -7,9 +7,6 @@
|
||||
|
||||
#include <opencv2/core/async.hpp>
|
||||
#include <opencv2/core/detail/async_promise.hpp>
|
||||
#include <opencv2/core/utils/logger.hpp>
|
||||
|
||||
#include <stdexcept>
|
||||
|
||||
namespace cv { namespace utils {
|
||||
//! @addtogroup core_utils
|
||||
@@ -67,61 +64,6 @@ String dumpString(const String& argument)
|
||||
return cv::format("String: %s", argument.c_str());
|
||||
}
|
||||
|
||||
CV_WRAP static inline
|
||||
String testOverloadResolution(int value, const Point& point = Point(42, 24))
|
||||
{
|
||||
return format("overload (int=%d, point=(x=%d, y=%d))", value, point.x,
|
||||
point.y);
|
||||
}
|
||||
|
||||
CV_WRAP static inline
|
||||
String testOverloadResolution(const Rect& rect)
|
||||
{
|
||||
return format("overload (rect=(x=%d, y=%d, w=%d, h=%d))", rect.x, rect.y,
|
||||
rect.width, rect.height);
|
||||
}
|
||||
|
||||
CV_WRAP static inline
|
||||
String dumpRect(const Rect& argument)
|
||||
{
|
||||
return format("rect: (x=%d, y=%d, w=%d, h=%d)", argument.x, argument.y,
|
||||
argument.width, argument.height);
|
||||
}
|
||||
|
||||
CV_WRAP static inline
|
||||
String dumpTermCriteria(const TermCriteria& argument)
|
||||
{
|
||||
return format("term_criteria: (type=%d, max_count=%d, epsilon=%lf",
|
||||
argument.type, argument.maxCount, argument.epsilon);
|
||||
}
|
||||
|
||||
CV_WRAP static inline
|
||||
String dumpRotatedRect(const RotatedRect& argument)
|
||||
{
|
||||
return format("rotated_rect: (c_x=%f, c_y=%f, w=%f, h=%f, a=%f)",
|
||||
argument.center.x, argument.center.y, argument.size.width,
|
||||
argument.size.height, argument.angle);
|
||||
}
|
||||
|
||||
CV_WRAP static inline
|
||||
String dumpRange(const Range& argument)
|
||||
{
|
||||
if (argument == Range::all())
|
||||
{
|
||||
return "range: all";
|
||||
}
|
||||
else
|
||||
{
|
||||
return format("range: (s=%d, e=%d)", argument.start, argument.end);
|
||||
}
|
||||
}
|
||||
|
||||
CV_WRAP static inline
|
||||
void testRaiseGeneralException()
|
||||
{
|
||||
throw std::runtime_error("exception text");
|
||||
}
|
||||
|
||||
CV_WRAP static inline
|
||||
AsyncArray testAsyncArray(InputArray argument)
|
||||
{
|
||||
@@ -145,26 +87,7 @@ AsyncArray testAsyncException()
|
||||
return p.getArrayResult();
|
||||
}
|
||||
|
||||
//! @} // core_utils
|
||||
} // namespace cv::utils
|
||||
|
||||
//! @cond IGNORED
|
||||
|
||||
CV_WRAP static inline
|
||||
int setLogLevel(int level)
|
||||
{
|
||||
// NB: Binding generators doesn't work with enums properly yet, so we define separate overload here
|
||||
return cv::utils::logging::setLogLevel((cv::utils::logging::LogLevel)level);
|
||||
}
|
||||
|
||||
CV_WRAP static inline
|
||||
int getLogLevel()
|
||||
{
|
||||
return cv::utils::logging::getLogLevel();
|
||||
}
|
||||
|
||||
//! @endcond IGNORED
|
||||
|
||||
} // namespaces cv / utils
|
||||
//! @}
|
||||
}} // namespace
|
||||
|
||||
#endif // OPENCV_CORE_BINDINGS_UTILS_HPP
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user