Intel® Integrated Performance Primitives (Intel® IPP) Library for OpenCV*
+
Intel® Integrated Performance Primitives (Intel® IPP) library for OpenCV* is a subset of Intel IPP functions for image processing and computer vision.
+
+No license (express or implied, by estoppel or otherwise) to any intellectual property rights is granted by this document.
+
+Intel disclaims all express and implied warranties, including without limitation, the implied warranties of merchantability, fitness for a particular purpose, and non-infringement, as well as any warranty arising from course of performance, course of dealing, or usage in trade.
+
+This document contains information on products, services and/or processes in development. All information provided here is subject to change without notice. Contact your Intel representative to obtain the latest forecast, schedule, specifications and roadmaps.
+
+The products and services described may contain defects or errors known as errata which may cause deviations from published specifications. Current characterized errata are available on request.
+
+Intel and the Intel logo are trademarks of Intel Corporation or its subsidiaries in the U.S. and/or other countries.
+
+*Other names and brands may be claimed as the property of others
+
This API (Application Programming Interface) document has pages corresponding to the items in the navigation bar, described as follows.
+
+
+
+
+
Overview
+
The Overview page is the front page of this API document and provides a list of all packages with a summary for each. This page can also contain an overall description of the set of packages.
+
+
+
Package
+
Each package has a page that contains a list of its classes and interfaces, with a summary for each. This page can contain six categories:
+
+
Interfaces (italic)
+
Classes
+
Enums
+
Exceptions
+
Errors
+
Annotation Types
+
+
+
+
Class/Interface
+
Each class, interface, nested class and nested interface has its own separate page. Each of these pages has three sections consisting of a class/interface description, summary tables, and detailed member descriptions:
+
+
Class inheritance diagram
+
Direct Subclasses
+
All Known Subinterfaces
+
All Known Implementing Classes
+
Class/interface declaration
+
Class/interface description
+
+
+
Nested Class Summary
+
Field Summary
+
Constructor Summary
+
Method Summary
+
+
+
Field Detail
+
Constructor Detail
+
Method Detail
+
+
Each summary entry contains the first sentence from the detailed description for that item. The summary entries are alphabetical, while the detailed descriptions are in the order they appear in the source code. This preserves the logical groupings established by the programmer.
+
+
+
Annotation Type
+
Each annotation type has its own separate page with the following sections:
+
+
Annotation Type declaration
+
Annotation Type description
+
Required Element Summary
+
Optional Element Summary
+
Element Detail
+
+
+
+
Enum
+
Each enum has its own separate page with the following sections:
+
+
Enum declaration
+
Enum description
+
Enum Constant Summary
+
Enum Constant Detail
+
+
+
+
Tree (Class Hierarchy)
+
There is a Class Hierarchy page for all packages, plus a hierarchy for each package. Each hierarchy page contains a list of classes and a list of interfaces. The classes are organized by inheritance structure starting with java.lang.Object. The interfaces do not inherit from java.lang.Object.
+
+
When viewing the Overview page, clicking on "Tree" displays the hierarchy for all packages.
+
When viewing a particular package, class or interface page, clicking "Tree" displays the hierarchy for only that package.
+
+
+
+
Index
+
The Index contains an alphabetic list of all classes, interfaces, constructors, methods, and fields.
+
+
+
Prev/Next
+
These links take you to the next or previous class, interface, package, or related page.
+
+
+
Frames/No Frames
+
These links show and hide the HTML frames. All pages are available with or without frames.
+
+
+
All Classes
+
The All Classes link shows all classes and interfaces except non-static nested types.
+
+
+
Serialized Form
+
Each serializable or externalizable class has a description of its serialization fields and methods. This information is of interest to re-implementors, not to developers using the API. While there is no link in the navigation bar, you can get to this information by going to any serialized class and clicking "Serialized Form" in the "See also" section of the class description.
Append samples search data sub directory
+
+ General usage is to add OpenCV modules name (<opencv_contrib>/modules/<name>/samples/data -> <name>/samples/data + modules/<name>/samples/data).
This is a base class for all more or less complex algorithms in OpenCV
+
+ especially for classes of algorithms, for which there can be multiple implementations.
This algorithm converts images to median threshold bitmaps (1 for pixels brighter than median
+ luminance and 0 otherwise) and than aligns the resulting bitmaps using bit operations.
+
+
all() - Static method in class org.opencv.core.Range
computes bitwise conjunction of the two arrays (dst = src1 & src2)
+ Calculates the per-element bit-wise conjunction of two arrays or an
+ array and a scalar.
computes bitwise conjunction of the two arrays (dst = src1 & src2)
+ Calculates the per-element bit-wise conjunction of two arrays or an
+ array and a scalar.
This class interface is abstract representation of single frame from camera for onCameraFrame callback
+ Attention: Do not use objects, that represents this interface out of onCameraFrame callback!
computes the connected components labeled image of boolean image
+
+ image with 4 or 8 way connectivity - returns N, the total number of labels [0, N-1] where 0
+ represents the background label.
computes the connected components labeled image of boolean image and also produces a statistics output for each label
+
+ image with 4 or 8 way connectivity - returns N, the total number of labels [0, N-1] where 0
+ represents the background label.
create(int) - Static method in class org.opencv.features2d.ORB
+
+
The ORB constructor
+
+
create() - Static method in class org.opencv.features2d.ORB
+
+
The ORB constructor
+
+ pyramid, where each next level has 4x less pixels than the previous, but such a big scale factor
+ will degrade feature matching scores dramatically.
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.
This method is provided for clients, so they can disable camera connection and stop
+ the delivery of frames even though the surface view itself is not destroyed and still stays on the screen
Perform image denoising using Non-local Means Denoising algorithm
+ <http://www.ipol.im/pub/algo/bcm_non_local_means_denoising/> with several computational
+ optimizations.
Perform image denoising using Non-local Means Denoising algorithm
+ <http://www.ipol.im/pub/algo/bcm_non_local_means_denoising/> with several computational
+ optimizations.
Perform image denoising using Non-local Means Denoising algorithm
+ <http://www.ipol.im/pub/algo/bcm_non_local_means_denoising/> with several computational
+ optimizations.
Perform image denoising using Non-local Means Denoising algorithm
+ <http://www.ipol.im/pub/algo/bcm_non_local_means_denoising/> with several computational
+ optimizations.
Perform image denoising using Non-local Means Denoising algorithm
+ <http://www.ipol.im/pub/algo/bcm_non_local_means_denoising/> with several computational
+ optimizations.
Perform image denoising using Non-local Means Denoising algorithm
+ <http://www.ipol.im/pub/algo/bcm_non_local_means_denoising/> with several computational
+ optimizations.
Perform image denoising using Non-local Means Denoising algorithm
+ <http://www.ipol.im/pub/algo/bcm_non_local_means_denoising/> with several computational
+ optimizations.
Perform image denoising using Non-local Means Denoising algorithm
+ <http://www.ipol.im/pub/algo/bcm_non_local_means_denoising/> with several computational
+ optimizations.
Returns the list of locations of non-zero pixels
+
+ Given a binary matrix (likely returned from an operation such
+ as threshold(), compare(), >, ==, etc, return all of
+ the non-zero indices as a cv::Mat or std::vector<cv::Point> (x,y)
+ For example:
+
+ cv::Mat binaryImage; // input, binary image
+ cv::Mat locations; // output, locations of non-zero pixels
+ cv::findNonZero(binaryImage, locations);
+
+ // access pixel coordinates
+ Point pnt = locations.at<Point>(i);
+
+ or
+
+ cv::Mat binaryImage; // input, binary image
+ vector<Point> locations; // output, locations of non-zero pixels
+ cv::findNonZero(binaryImage, locations);
+
+ // access pixel coordinates
+ Point pnt = locations[i];
+
finds arbitrary template in the grayscale image using Generalized Hough Transform
+
+ Detects position only without translation and rotation CITE: Ballard1981 .
Returns the "background ratio" parameter of the algorithm
+
+ If a foreground pixel keeps semi-constant value for about backgroundRatio\*history frames, it's
+ considered background and added to the model as a center of a new component.
Returns the threshold on the squared distance between the pixel and the sample
+
+ The threshold on the squared distance between the pixel and the sample to decide whether a pixel is
+ close to a data sample.
Returns the cluster centers (means of the Gaussian mixture)
+
+ Returns matrix with the number of rows equal to the number of mixtures and number of columns
+ equal to the space dimensionality.
Retrieves all the support vectors
+
+ The method returns all the support vectors as a floating-point matrix, where support vectors are
+ stored as matrix rows.
Retrieves all the uncompressed support vectors of a linear %SVM
+
+ The method returns all the uncompressed support vectors of a linear %SVM that the compressed
+ support vector, used for prediction, was derived from.
Returns the variance threshold for the pixel-model match
+
+ The main threshold on the squared Mahalanobis distance to decide if the sample is well described by
+ the background model or not.
Returns the variance threshold for the pixel-model match used for new mixture component generation
+
+ Threshold for the squared Mahalanobis distance that helps decide when a sample is close to the
+ existing components (corresponds to Tg in the paper).
Applying an appropriate non-linear transformation to the gradient field inside the selection and
+ then integrating back with a Poisson solver, modifies locally the apparent illumination of an image.
Applying an appropriate non-linear transformation to the gradient field inside the selection and
+ then integrating back with a Poisson solver, modifies locally the apparent illumination of an image.
Applying an appropriate non-linear transformation to the gradient field inside the selection and
+ then integrating back with a Poisson solver, modifies locally the apparent illumination of an image.
Returns the number of images inside the give file
+
+ The function imcount will return the number of pages in a multi-page image, or 1 for single-page images
Returns the number of images inside the give file
+
+ The function imcount will return the number of pages in a multi-page image, or 1 for single-page images
Intelligent Scissors image segmentation
+
+ This class is used to find the path (contour) between two points
+ which can be used for image segmentation.
Loads and creates a serialized NormalBayesClassifier from a file
+
+ Use NormalBayesClassifier::save to serialize and store an NormalBayesClassifier to disk.
Loads and creates a serialized NormalBayesClassifier from a file
+
+ Use NormalBayesClassifier::save to serialize and store an NormalBayesClassifier to disk.
Maximally stable extremal region extractor
+
+ The class encapsulates all the parameters of the %MSER extraction algorithm (see [wiki
+ article](http://en.wikipedia.org/wiki/Maximally_stable_extremal_regions)).
+
+
mu02 - Variable in class org.opencv.imgproc.Moments
+
+
mu03 - Variable in class org.opencv.imgproc.Moments
+
+
mu11 - Variable in class org.opencv.imgproc.Moments
+
+
mu12 - Variable in class org.opencv.imgproc.Moments
+
+
mu20 - Variable in class org.opencv.imgproc.Moments
+
+
mu21 - Variable in class org.opencv.imgproc.Moments
+
+
mu30 - Variable in class org.opencv.imgproc.Moments
Opens a video file or a capturing device or an IP video stream for video capturing with API Preference and parameters
+
+
+
+ The params parameter allows to specify extra parameters encoded as pairs (paramId_1, paramValue_1, paramId_2, paramValue_2, ...).
Opens a camera for video capturing with API Preference and parameters
+
+
+
+ The params parameter allows to specify extra parameters encoded as pairs (paramId_1, paramValue_1, paramId_2, paramValue_2, ...).
Recovers the relative camera rotation and the translation from an estimated essential
+ matrix and the corresponding points in two images, using chirality check.
Recovers the relative camera rotation and the translation from an estimated essential
+ matrix and the corresponding points in two images, using chirality check.
Finds indices of max elements along provided axis
+
+ Note:
+ - If input or output array is not continuous, this function will create an internal copy.
Finds indices of max elements along provided axis
+
+ Note:
+ - If input or output array is not continuous, this function will create an internal copy.
Finds indices of min elements along provided axis
+
+ Note:
+ - If input or output array is not continuous, this function will create an internal copy.
Finds indices of min elements along provided axis
+
+ Note:
+ - If input or output array is not continuous, this function will create an internal copy.
Switch edge feature extractor to use Canny edge detector
+
+ Note: "Laplacian Zero-Crossing" feature extractor is used by default (following to original article)
+
+ SEE: Canny
Switch edge feature extractor to use Canny edge detector
+
+ Note: "Laplacian Zero-Crossing" feature extractor is used by default (following to original article)
+
+ SEE: Canny
Switch edge feature extractor to use Canny edge detector
+
+ Note: "Laplacian Zero-Crossing" feature extractor is used by default (following to original article)
+
+ SEE: Canny
Switch to "Laplacian Zero-Crossing" edge feature extractor and specify its parameters
+
+ This feature extractor is used by default according to article.
Switch to "Laplacian Zero-Crossing" edge feature extractor and specify its parameters
+
+ This feature extractor is used by default according to article.
Specify gradient magnitude max value threshold
+
+ Zero limit value is used to disable gradient magnitude thresholding (default behavior, as described in original article).
Specify gradient magnitude max value threshold
+
+ Zero limit value is used to disable gradient magnitude thresholding (default behavior, as described in original article).
Splits the training data into the training and test parts
+
+ The function selects a subset of specified relative size and then returns it as the training
+ set.
Splits the training data into the training and test parts
+
+ The function selects a subset of specified relative size and then returns it as the training
+ set.
Specify weights of feature functions
+
+ Consider keeping weights normalized (sum of weights equals to 1.0)
+ Discrete dynamic programming (DP) goal is minimization of costs between pixels.
Refine a pose (the translation and the rotation that transform a 3D point expressed in the object coordinate frame
+ to the camera coordinate frame) from a 3D-2D point correspondences and starting from an initial solution.
Refine a pose (the translation and the rotation that transform a 3D point expressed in the object coordinate frame
+ to the camera coordinate frame) from a 3D-2D point correspondences and starting from an initial solution.
Refine a pose (the translation and the rotation that transform a 3D point expressed in the object coordinate frame
+ to the camera coordinate frame) from a 3D-2D point correspondences and starting from an initial solution.
Refine a pose (the translation and the rotation that transform a 3D point expressed in the object coordinate frame
+ to the camera coordinate frame) from a 3D-2D point correspondences and starting from an initial solution.
Refine a pose (the translation and the rotation that transform a 3D point expressed in the object coordinate frame
+ to the camera coordinate frame) from a 3D-2D point correspondences and starting from an initial solution.
Calculates the first order image derivative in both x and y using a Sobel operator
+
+ Equivalent to calling:
+
+
+ Sobel( src, dx, CV_16SC1, 1, 0, 3 );
+ Sobel( src, dy, CV_16SC1, 0, 1, 3 );
+
Calculates the first order image derivative in both x and y using a Sobel operator
+
+ Equivalent to calling:
+
+
+ Sobel( src, dx, CV_16SC1, 1, 0, 3 );
+ Sobel( src, dy, CV_16SC1, 0, 1, 3 );
+
Calculates the first order image derivative in both x and y using a Sobel operator
+
+ Equivalent to calling:
+
+
+ Sobel( src, dx, CV_16SC1, 1, 0, 3 );
+ Sobel( src, dy, CV_16SC1, 0, 1, 3 );
+
Create Text Recognition model from deep learning network
+ Call setDecodeType() and setVocabulary() after constructor to initialize the decoding method
Create text recognition model from network represented in one of the supported formats
+ Call setDecodeType() and setVocabulary() after constructor to initialize the decoding method
Create text recognition model from network represented in one of the supported formats
+ Call setDecodeType() and setVocabulary() after constructor to initialize the decoding method
By retaining only the gradients at edge locations, before integrating with the Poisson solver, one
+ washes out the texture of the selected region, giving its contents a flat aspect.
By retaining only the gradients at edge locations, before integrating with the Poisson solver, one
+ washes out the texture of the selected region, giving its contents a flat aspect.
By retaining only the gradients at edge locations, before integrating with the Poisson solver, one
+ washes out the texture of the selected region, giving its contents a flat aspect.
By retaining only the gradients at edge locations, before integrating with the Poisson solver, one
+ washes out the texture of the selected region, giving its contents a flat aspect.
This algorithm transforms image to contrast using gradients on all levels of gaussian pyramid,
+ transforms contrast values to HVS response and scales the response.
the GOTURN (Generic Object Tracking Using Regression Networks) tracker
+
+ GOTURN (CITE: GOTURN) is kind of trackers based on Convolutional Neural Networks (CNN).
Default constructor
+ Note: In REF: videoio_c "C API", when you finished working with video, release CvCapture structure with
+ cvReleaseCapture(), or use Ptr<CvCapture> that calls cvReleaseCapture() automatically in the
+ destructor.
Opens a video file or a capturing device or an IP video stream for video capturing with API Preference and parameters
+
+ The params parameter allows to specify extra parameters encoded as pairs (paramId_1, paramValue_1, paramId_2, paramValue_2, ...).
Opens a camera for video capturing with API Preference and parameters
+
+ The params parameter allows to specify extra parameters encoded as pairs (paramId_1, paramValue_1, paramId_2, paramValue_2, ...).
public static interface CameraBridgeViewBase.CvCameraViewFrame
+
This class interface is abstract representation of single frame from camera for onCameraFrame callback
+ Attention: Do not use objects, that represents this interface out of onCameraFrame callback!
This method is invoked when delivery of the frame needs to be done.
+ The returned values - is a modified frame which needs to be displayed on the screen.
+ TODO: pass the parameters specifying the format of the frame (BPP, YUV or RGB and etc)
This method is invoked when camera preview has started. After this method is invoked
+ the frames will start to be delivered to client via the onCameraFrame() callback.
+
+
Parameters:
+
width - - the width of the frames that will be delivered
+
height - - the height of the frames that will be delivered
This method is invoked when camera preview has been stopped for some reason.
+ No frames will be delivered via onCameraFrame() callback after this method is called.
This method is invoked when delivery of the frame needs to be done.
+ The returned values - is a modified frame which needs to be displayed on the screen.
+ TODO: pass the parameters specifying the format of the frame (BPP, YUV or RGB and etc)
This method is invoked when camera preview has started. After this method is invoked
+ the frames will start to be delivered to client via the onCameraFrame() callback.
+
+
Parameters:
+
width - - the width of the frames that will be delivered
+
height - - the height of the frames that will be delivered
This method is invoked when camera preview has been stopped for some reason.
+ No frames will be delivered via onCameraFrame() callback after this method is called.
public abstract class CameraBridgeViewBase
+extends android.view.SurfaceView
+implements android.view.SurfaceHolder.Callback
+
This is a basic class, implementing the interaction with Camera and OpenCV library.
+ The main responsibility of it - is to control when camera can be enabled, process the frame,
+ call external listener to make any adjustments to the frame and then draw the resulting
+ frame to the screen.
+ The clients shall implement CvCameraViewListener.
This class interface is abstract representation of single frame from camera for onCameraFrame callback
+ Attention: Do not use objects, that represents this interface out of onCameraFrame callback!
This method is provided for clients, so they can disable camera connection and stop
+ the delivery of frames even though the surface view itself is not destroyed and still stays on the screen
This method is provided for clients, so they can disable camera connection and stop
+ the delivery of frames even though the surface view itself is not destroyed and still stays on the screen
This method is provided for clients, so they can enable the camera connection.
+ The actual onCameraViewStarted callback will be delivered only after setCameraPermissionGranted
+ and enableView have been called and surface is available
This method is provided for clients, so they can signal camera permission has been granted.
+ The actual onCameraViewStarted callback will be delivered only after setCameraPermissionGranted
+ and enableView have been called and surface is available
public void setMaxFrameSize(int maxWidth,
+ int maxHeight)
+
This method sets the maximum size that camera frame is allowed to be. When selecting
+ size - the biggest size which less or equal the size set will be selected.
+ As an example - we set setMaxFrameSize(200,200) and we have 176x152 and 320x240 sizes. The
+ preview frame will be selected with 176x152 size.
+ This method is useful when need to restrict the size of preview frame for some reason (for example for video recording)
+
+
Parameters:
+
maxWidth - - the maximum width allowed for camera frame.
+
maxHeight - - the maximum height allowed for camera frame
public abstract class CameraGLRendererBase
+extends java.lang.Object
+implements android.opengl.GLSurfaceView.Renderer, android.graphics.SurfaceTexture.OnFrameAvailableListener
This method is invoked when camera preview has started. After this method is invoked
+ the frames will start to be delivered to client via the onCameraFrame() callback.
+
+
Parameters:
+
width - - the width of the frames that will be delivered
+
height - - the height of the frames that will be delivered
This method is invoked when camera preview has been stopped for some reason.
+ No frames will be delivered via onCameraFrame() callback after this method is called.
This class is an implementation of the Bridge View between OpenCV and Java Camera.
+ This class relays on the functionality available in base class and only implements
+ required functions:
+ connectCamera - opens Java camera and sets the PreviewCallback to be delivered.
+ disconnectCamera - closes the camera and stops preview.
+ When frame is delivered via callback from Camera - it processed via OpenCV to be
+ converted to RGBA32 and then passed to the external callback for modifications if required.
public class JavaCameraView
+extends CameraBridgeViewBase
+implements android.hardware.Camera.PreviewCallback
+
This class is an implementation of the Bridge View between OpenCV and Java Camera.
+ This class relays on the functionality available in base class and only implements
+ required functions:
+ connectCamera - opens Java camera and sets the PreviewCallback to be delivered.
+ disconnectCamera - closes the camera and stops preview.
+ When frame is delivered via callback from Camera - it processed via OpenCV to be
+ converted to RGBA32 and then passed to the external callback for modifications if required.
public static void bitmapToMat(android.graphics.Bitmap bmp,
+ Mat mat,
+ boolean unPremultiplyAlpha)
+
Converts Android Bitmap to OpenCV Mat.
+
+ This function converts an Android Bitmap image to the OpenCV Mat.
+ 'ARGB_8888' and 'RGB_565' input Bitmap formats are supported.
+ The output Mat is always created of the same size as the input Bitmap and of the 'CV_8UC4' type,
+ it keeps the image in RGBA format.
+ This function throws an exception if the conversion fails.
+
+
Parameters:
+
bmp - is a valid input Bitmap object of the type 'ARGB_8888' or 'RGB_565'.
+
mat - is a valid output Mat object, it will be reallocated if needed, so it may be empty.
+
unPremultiplyAlpha - is a flag, that determines, whether the bitmap needs to be converted from alpha premultiplied format (like Android keeps 'ARGB_8888' ones) to regular one; this flag is ignored for 'RGB_565' bitmaps.
+ This function converts an image in the OpenCV Mat representation to the Android Bitmap.
+ The input Mat object has to be of the types 'CV_8UC1' (gray-scale), 'CV_8UC3' (RGB) or 'CV_8UC4' (RGBA).
+ The output Bitmap object has to be of the same size as the input Mat and of the types 'ARGB_8888' or 'RGB_565'.
+ This function throws an exception if the conversion fails.
+
+
Parameters:
+
mat - is a valid input Mat object of types 'CV_8UC1', 'CV_8UC3' or 'CV_8UC4'.
+
bmp - is a valid Bitmap object of the same size as the Mat and of type 'ARGB_8888' or 'RGB_565'.
+
premultiplyAlpha - is a flag, that determines, whether the Mat needs to be converted to alpha premultiplied format (like Android keeps 'ARGB_8888' bitmaps); the flag is ignored for 'RGB_565' bitmaps.
This class interface is abstract representation of single frame from camera for onCameraFrame callback
+ Attention: Do not use objects, that represents this interface out of onCameraFrame callback!
calibrateCamera(java.util.List<Mat> objectPoints,
+ java.util.List<Mat> imagePoints,
+ Size imageSize,
+ Mat cameraMatrix,
+ Mat distCoeffs,
+ java.util.List<Mat> rvecs,
+ java.util.List<Mat> tvecs)
+
+
+
static double
+
calibrateCamera(java.util.List<Mat> objectPoints,
+ java.util.List<Mat> imagePoints,
+ Size imageSize,
+ Mat cameraMatrix,
+ Mat distCoeffs,
+ java.util.List<Mat> rvecs,
+ java.util.List<Mat> tvecs,
+ int flags)
+
+
+
static double
+
calibrateCamera(java.util.List<Mat> objectPoints,
+ java.util.List<Mat> imagePoints,
+ Size imageSize,
+ Mat cameraMatrix,
+ Mat distCoeffs,
+ java.util.List<Mat> rvecs,
+ java.util.List<Mat> tvecs,
+ int flags,
+ TermCriteria criteria)
+
+
+
static double
+
calibrateCameraExtended(java.util.List<Mat> objectPoints,
+ java.util.List<Mat> imagePoints,
+ Size imageSize,
+ Mat cameraMatrix,
+ Mat distCoeffs,
+ java.util.List<Mat> rvecs,
+ java.util.List<Mat> tvecs,
+ Mat stdDeviationsIntrinsics,
+ Mat stdDeviationsExtrinsics,
+ Mat perViewErrors)
+
Finds the camera intrinsic and extrinsic parameters from several views of a calibration
+ pattern.
+
+
+
+
static double
+
calibrateCameraExtended(java.util.List<Mat> objectPoints,
+ java.util.List<Mat> imagePoints,
+ Size imageSize,
+ Mat cameraMatrix,
+ Mat distCoeffs,
+ java.util.List<Mat> rvecs,
+ java.util.List<Mat> tvecs,
+ Mat stdDeviationsIntrinsics,
+ Mat stdDeviationsExtrinsics,
+ Mat perViewErrors,
+ int flags)
+
Finds the camera intrinsic and extrinsic parameters from several views of a calibration
+ pattern.
+
+
+
+
static double
+
calibrateCameraExtended(java.util.List<Mat> objectPoints,
+ java.util.List<Mat> imagePoints,
+ Size imageSize,
+ Mat cameraMatrix,
+ Mat distCoeffs,
+ java.util.List<Mat> rvecs,
+ java.util.List<Mat> tvecs,
+ Mat stdDeviationsIntrinsics,
+ Mat stdDeviationsExtrinsics,
+ Mat perViewErrors,
+ int flags,
+ TermCriteria criteria)
+
Finds the camera intrinsic and extrinsic parameters from several views of a calibration
+ pattern.
+
+
+
+
static double
+
calibrateCameraRO(java.util.List<Mat> objectPoints,
+ java.util.List<Mat> imagePoints,
+ Size imageSize,
+ int iFixedPoint,
+ Mat cameraMatrix,
+ Mat distCoeffs,
+ java.util.List<Mat> rvecs,
+ java.util.List<Mat> tvecs,
+ Mat newObjPoints)
+
+
+
static double
+
calibrateCameraRO(java.util.List<Mat> objectPoints,
+ java.util.List<Mat> imagePoints,
+ Size imageSize,
+ int iFixedPoint,
+ Mat cameraMatrix,
+ Mat distCoeffs,
+ java.util.List<Mat> rvecs,
+ java.util.List<Mat> tvecs,
+ Mat newObjPoints,
+ int flags)
+
+
+
static double
+
calibrateCameraRO(java.util.List<Mat> objectPoints,
+ java.util.List<Mat> imagePoints,
+ Size imageSize,
+ int iFixedPoint,
+ Mat cameraMatrix,
+ Mat distCoeffs,
+ java.util.List<Mat> rvecs,
+ java.util.List<Mat> tvecs,
+ Mat newObjPoints,
+ int flags,
+ TermCriteria criteria)
+
+
+
static double
+
calibrateCameraROExtended(java.util.List<Mat> objectPoints,
+ java.util.List<Mat> imagePoints,
+ Size imageSize,
+ int iFixedPoint,
+ Mat cameraMatrix,
+ Mat distCoeffs,
+ java.util.List<Mat> rvecs,
+ java.util.List<Mat> tvecs,
+ Mat newObjPoints,
+ Mat stdDeviationsIntrinsics,
+ Mat stdDeviationsExtrinsics,
+ Mat stdDeviationsObjPoints,
+ Mat perViewErrors)
+
Finds the camera intrinsic and extrinsic parameters from several views of a calibration pattern.
+
+
+
+
static double
+
calibrateCameraROExtended(java.util.List<Mat> objectPoints,
+ java.util.List<Mat> imagePoints,
+ Size imageSize,
+ int iFixedPoint,
+ Mat cameraMatrix,
+ Mat distCoeffs,
+ java.util.List<Mat> rvecs,
+ java.util.List<Mat> tvecs,
+ Mat newObjPoints,
+ Mat stdDeviationsIntrinsics,
+ Mat stdDeviationsExtrinsics,
+ Mat stdDeviationsObjPoints,
+ Mat perViewErrors,
+ int flags)
+
Finds the camera intrinsic and extrinsic parameters from several views of a calibration pattern.
+
+
+
+
static double
+
calibrateCameraROExtended(java.util.List<Mat> objectPoints,
+ java.util.List<Mat> imagePoints,
+ Size imageSize,
+ int iFixedPoint,
+ Mat cameraMatrix,
+ Mat distCoeffs,
+ java.util.List<Mat> rvecs,
+ java.util.List<Mat> tvecs,
+ Mat newObjPoints,
+ Mat stdDeviationsIntrinsics,
+ Mat stdDeviationsExtrinsics,
+ Mat stdDeviationsObjPoints,
+ Mat perViewErrors,
+ int flags,
+ TermCriteria criteria)
+
Finds the camera intrinsic and extrinsic parameters from several views of a calibration pattern.
+
+
+
+
static void
+
calibrateHandEye(java.util.List<Mat> R_gripper2base,
+ java.util.List<Mat> t_gripper2base,
+ java.util.List<Mat> R_target2cam,
+ java.util.List<Mat> t_target2cam,
+ Mat R_cam2gripper,
+ Mat t_cam2gripper)
+
estimateAffine2D(Mat from,
+ Mat to,
+ Mat inliers,
+ int method,
+ double ransacReprojThreshold,
+ long maxIters,
+ double confidence,
+ long refineIters)
+
Computes an optimal affine transformation between two 2D point sets.
estimateAffinePartial2D(Mat from,
+ Mat to,
+ Mat inliers,
+ int method,
+ double ransacReprojThreshold,
+ long maxIters,
+ double confidence,
+ long refineIters)
+
Computes an optimal limited affine transformation with 4 degrees of freedom between
+ two 2D point sets.
findEssentialMat(Mat points1,
+ Mat points2,
+ Mat cameraMatrix1,
+ Mat distCoeffs1,
+ Mat cameraMatrix2,
+ Mat distCoeffs2,
+ int method,
+ double prob)
+
Calculates an essential matrix from the corresponding points in two images from potentially two different cameras.
findEssentialMat(Mat points1,
+ Mat points2,
+ Mat cameraMatrix1,
+ Mat distCoeffs1,
+ Mat cameraMatrix2,
+ Mat distCoeffs2,
+ int method,
+ double prob,
+ double threshold)
+
Calculates an essential matrix from the corresponding points in two images from potentially two different cameras.
findEssentialMat(Mat points1,
+ Mat points2,
+ Mat cameraMatrix1,
+ Mat distCoeffs1,
+ Mat cameraMatrix2,
+ Mat distCoeffs2,
+ int method,
+ double prob,
+ double threshold,
+ Mat mask)
+
Calculates an essential matrix from the corresponding points in two images from potentially two different cameras.
fisheye_stereoCalibrate(java.util.List<Mat> objectPoints,
+ java.util.List<Mat> imagePoints1,
+ java.util.List<Mat> imagePoints2,
+ Mat K1,
+ Mat D1,
+ Mat K2,
+ Mat D2,
+ Size imageSize,
+ Mat R,
+ Mat T,
+ int flags)
Recovers the relative camera rotation and the translation from an estimated essential
+ matrix and the corresponding points in two images, using chirality check.
Recovers the relative camera rotation and the translation from an estimated essential
+ matrix and the corresponding points in two images, using chirality check.
Recovers the relative camera rotation and the translation from corresponding points in two images from two different cameras, using cheirality check.
+
+
+
+
static int
+
recoverPose(Mat points1,
+ Mat points2,
+ Mat cameraMatrix1,
+ Mat distCoeffs1,
+ Mat cameraMatrix2,
+ Mat distCoeffs2,
+ Mat E,
+ Mat R,
+ Mat t,
+ int method)
+
Recovers the relative camera rotation and the translation from corresponding points in two images from two different cameras, using cheirality check.
+
+
+
+
static int
+
recoverPose(Mat points1,
+ Mat points2,
+ Mat cameraMatrix1,
+ Mat distCoeffs1,
+ Mat cameraMatrix2,
+ Mat distCoeffs2,
+ Mat E,
+ Mat R,
+ Mat t,
+ int method,
+ double prob)
+
Recovers the relative camera rotation and the translation from corresponding points in two images from two different cameras, using cheirality check.
+
+
+
+
static int
+
recoverPose(Mat points1,
+ Mat points2,
+ Mat cameraMatrix1,
+ Mat distCoeffs1,
+ Mat cameraMatrix2,
+ Mat distCoeffs2,
+ Mat E,
+ Mat R,
+ Mat t,
+ int method,
+ double prob,
+ double threshold)
+
Recovers the relative camera rotation and the translation from corresponding points in two images from two different cameras, using cheirality check.
+
+
+
+
static int
+
recoverPose(Mat points1,
+ Mat points2,
+ Mat cameraMatrix1,
+ Mat distCoeffs1,
+ Mat cameraMatrix2,
+ Mat distCoeffs2,
+ Mat E,
+ Mat R,
+ Mat t,
+ int method,
+ double prob,
+ double threshold,
+ Mat mask)
+
Recovers the relative camera rotation and the translation from corresponding points in two images from two different cameras, using cheirality check.
+
+
+
+
static float
+
rectify3Collinear(Mat cameraMatrix1,
+ Mat distCoeffs1,
+ Mat cameraMatrix2,
+ Mat distCoeffs2,
+ Mat cameraMatrix3,
+ Mat distCoeffs3,
+ java.util.List<Mat> imgpt1,
+ java.util.List<Mat> imgpt3,
+ Size imageSize,
+ Mat R12,
+ Mat T12,
+ Mat R13,
+ Mat T13,
+ Mat R1,
+ Mat R2,
+ Mat R3,
+ Mat P1,
+ Mat P2,
+ Mat P3,
+ Mat Q,
+ double alpha,
+ Size newImgSize,
+ Rect roi1,
+ Rect roi2,
+ int flags)
Finds an object pose from 3D-2D point correspondences.
+
+
+
+
static int
+
solvePnPGeneric(Mat objectPoints,
+ Mat imagePoints,
+ Mat cameraMatrix,
+ Mat distCoeffs,
+ java.util.List<Mat> rvecs,
+ java.util.List<Mat> tvecs)
+
Finds an object pose from 3D-2D point correspondences.
+
+
+
+
static int
+
solvePnPGeneric(Mat objectPoints,
+ Mat imagePoints,
+ Mat cameraMatrix,
+ Mat distCoeffs,
+ java.util.List<Mat> rvecs,
+ java.util.List<Mat> tvecs,
+ boolean useExtrinsicGuess)
+
Finds an object pose from 3D-2D point correspondences.
+
+
+
+
static int
+
solvePnPGeneric(Mat objectPoints,
+ Mat imagePoints,
+ Mat cameraMatrix,
+ Mat distCoeffs,
+ java.util.List<Mat> rvecs,
+ java.util.List<Mat> tvecs,
+ boolean useExtrinsicGuess,
+ int flags)
+
Finds an object pose from 3D-2D point correspondences.
+
+
+
+
static int
+
solvePnPGeneric(Mat objectPoints,
+ Mat imagePoints,
+ Mat cameraMatrix,
+ Mat distCoeffs,
+ java.util.List<Mat> rvecs,
+ java.util.List<Mat> tvecs,
+ boolean useExtrinsicGuess,
+ int flags,
+ Mat rvec)
+
Finds an object pose from 3D-2D point correspondences.
+
+
+
+
static int
+
solvePnPGeneric(Mat objectPoints,
+ Mat imagePoints,
+ Mat cameraMatrix,
+ Mat distCoeffs,
+ java.util.List<Mat> rvecs,
+ java.util.List<Mat> tvecs,
+ boolean useExtrinsicGuess,
+ int flags,
+ Mat rvec,
+ Mat tvec)
+
Finds an object pose from 3D-2D point correspondences.
+
+
+
+
static int
+
solvePnPGeneric(Mat objectPoints,
+ Mat imagePoints,
+ Mat cameraMatrix,
+ Mat distCoeffs,
+ java.util.List<Mat> rvecs,
+ java.util.List<Mat> tvecs,
+ boolean useExtrinsicGuess,
+ int flags,
+ Mat rvec,
+ Mat tvec,
+ Mat reprojectionError)
+
Finds an object pose from 3D-2D point correspondences.
Refine a pose (the translation and the rotation that transform a 3D point expressed in the object coordinate frame
+ to the camera coordinate frame) from a 3D-2D point correspondences and starting from an initial solution.
Refine a pose (the translation and the rotation that transform a 3D point expressed in the object coordinate frame
+ to the camera coordinate frame) from a 3D-2D point correspondences and starting from an initial solution.
Refine a pose (the translation and the rotation that transform a 3D point expressed in the object coordinate frame
+ to the camera coordinate frame) from a 3D-2D point correspondences and starting from an initial solution.
Refine a pose (the translation and the rotation that transform a 3D point expressed in the object coordinate frame
+ to the camera coordinate frame) from a 3D-2D point correspondences and starting from an initial solution.
Refine a pose (the translation and the rotation that transform a 3D point expressed in the object coordinate frame
+ to the camera coordinate frame) from a 3D-2D point correspondences and starting from an initial solution.
+
+
+
+
static double
+
stereoCalibrate(java.util.List<Mat> objectPoints,
+ java.util.List<Mat> imagePoints1,
+ java.util.List<Mat> imagePoints2,
+ Mat cameraMatrix1,
+ Mat distCoeffs1,
+ Mat cameraMatrix2,
+ Mat distCoeffs2,
+ Size imageSize,
+ Mat R,
+ Mat T,
+ Mat E,
+ Mat F)
+
+
+
static double
+
stereoCalibrate(java.util.List<Mat> objectPoints,
+ java.util.List<Mat> imagePoints1,
+ java.util.List<Mat> imagePoints2,
+ Mat cameraMatrix1,
+ Mat distCoeffs1,
+ Mat cameraMatrix2,
+ Mat distCoeffs2,
+ Size imageSize,
+ Mat R,
+ Mat T,
+ Mat E,
+ Mat F,
+ int flags)
+
+
+
static double
+
stereoCalibrate(java.util.List<Mat> objectPoints,
+ java.util.List<Mat> imagePoints1,
+ java.util.List<Mat> imagePoints2,
+ Mat cameraMatrix1,
+ Mat distCoeffs1,
+ Mat cameraMatrix2,
+ Mat distCoeffs2,
+ Size imageSize,
+ Mat R,
+ Mat T,
+ Mat E,
+ Mat F,
+ int flags,
+ TermCriteria criteria)
+
+
+
static double
+
stereoCalibrate(java.util.List<Mat> objectPoints,
+ java.util.List<Mat> imagePoints1,
+ java.util.List<Mat> imagePoints2,
+ Mat cameraMatrix1,
+ Mat distCoeffs1,
+ Mat cameraMatrix2,
+ Mat distCoeffs2,
+ Size imageSize,
+ Mat R,
+ Mat T,
+ Mat E,
+ Mat F,
+ Mat perViewErrors)
+
+
+
static double
+
stereoCalibrate(java.util.List<Mat> objectPoints,
+ java.util.List<Mat> imagePoints1,
+ java.util.List<Mat> imagePoints2,
+ Mat cameraMatrix1,
+ Mat distCoeffs1,
+ Mat cameraMatrix2,
+ Mat distCoeffs2,
+ Size imageSize,
+ Mat R,
+ Mat T,
+ Mat E,
+ Mat F,
+ Mat perViewErrors,
+ int flags)
+
+
+
static double
+
stereoCalibrate(java.util.List<Mat> objectPoints,
+ java.util.List<Mat> imagePoints1,
+ java.util.List<Mat> imagePoints2,
+ Mat cameraMatrix1,
+ Mat distCoeffs1,
+ Mat cameraMatrix2,
+ Mat distCoeffs2,
+ Size imageSize,
+ Mat R,
+ Mat T,
+ Mat E,
+ Mat F,
+ Mat perViewErrors,
+ int flags,
+ TermCriteria criteria)
+
+
+
static double
+
stereoCalibrateExtended(java.util.List<Mat> objectPoints,
+ java.util.List<Mat> imagePoints1,
+ java.util.List<Mat> imagePoints2,
+ Mat cameraMatrix1,
+ Mat distCoeffs1,
+ Mat cameraMatrix2,
+ Mat distCoeffs2,
+ Size imageSize,
+ Mat R,
+ Mat T,
+ Mat E,
+ Mat F,
+ java.util.List<Mat> rvecs,
+ java.util.List<Mat> tvecs,
+ Mat perViewErrors)
+
Calibrates a stereo camera set up.
+
+
+
+
static double
+
stereoCalibrateExtended(java.util.List<Mat> objectPoints,
+ java.util.List<Mat> imagePoints1,
+ java.util.List<Mat> imagePoints2,
+ Mat cameraMatrix1,
+ Mat distCoeffs1,
+ Mat cameraMatrix2,
+ Mat distCoeffs2,
+ Size imageSize,
+ Mat R,
+ Mat T,
+ Mat E,
+ Mat F,
+ java.util.List<Mat> rvecs,
+ java.util.List<Mat> tvecs,
+ Mat perViewErrors,
+ int flags)
+
Calibrates a stereo camera set up.
+
+
+
+
static double
+
stereoCalibrateExtended(java.util.List<Mat> objectPoints,
+ java.util.List<Mat> imagePoints1,
+ java.util.List<Mat> imagePoints2,
+ Mat cameraMatrix1,
+ Mat distCoeffs1,
+ Mat cameraMatrix2,
+ Mat distCoeffs2,
+ Size imageSize,
+ Mat R,
+ Mat T,
+ Mat E,
+ Mat F,
+ java.util.List<Mat> rvecs,
+ java.util.List<Mat> tvecs,
+ Mat perViewErrors,
+ int flags,
+ TermCriteria criteria)
+
Computes rectification transforms for each head of a calibrated stereo camera.
+
+
+
+
static void
+
stereoRectify(Mat cameraMatrix1,
+ Mat distCoeffs1,
+ Mat cameraMatrix2,
+ Mat distCoeffs2,
+ Size imageSize,
+ Mat R,
+ Mat T,
+ Mat R1,
+ Mat R2,
+ Mat P1,
+ Mat P2,
+ Mat Q,
+ int flags,
+ double alpha)
+
Computes rectification transforms for each head of a calibrated stereo camera.
+
+
+
+
static void
+
stereoRectify(Mat cameraMatrix1,
+ Mat distCoeffs1,
+ Mat cameraMatrix2,
+ Mat distCoeffs2,
+ Size imageSize,
+ Mat R,
+ Mat T,
+ Mat R1,
+ Mat R2,
+ Mat P1,
+ Mat P2,
+ Mat Q,
+ int flags,
+ double alpha,
+ Size newImageSize)
+
Computes rectification transforms for each head of a calibrated stereo camera.
+
+
+
+
static void
+
stereoRectify(Mat cameraMatrix1,
+ Mat distCoeffs1,
+ Mat cameraMatrix2,
+ Mat distCoeffs2,
+ Size imageSize,
+ Mat R,
+ Mat T,
+ Mat R1,
+ Mat R2,
+ Mat P1,
+ Mat P2,
+ Mat Q,
+ int flags,
+ double alpha,
+ Size newImageSize,
+ Rect validPixROI1)
+
Computes rectification transforms for each head of a calibrated stereo camera.
+
+
+
+
static void
+
stereoRectify(Mat cameraMatrix1,
+ Mat distCoeffs1,
+ Mat cameraMatrix2,
+ Mat distCoeffs2,
+ Size imageSize,
+ Mat R,
+ Mat T,
+ Mat R1,
+ Mat R2,
+ Mat P1,
+ Mat P2,
+ Mat Q,
+ int flags,
+ double alpha,
+ Size newImageSize,
+ Rect validPixROI1,
+ Rect validPixROI2)
+
Computes rectification transforms for each head of a calibrated stereo camera.
public static double calibrateCameraExtended(java.util.List<Mat> objectPoints,
+ java.util.List<Mat> imagePoints,
+ Size imageSize,
+ Mat cameraMatrix,
+ Mat distCoeffs,
+ java.util.List<Mat> rvecs,
+ java.util.List<Mat> tvecs,
+ Mat stdDeviationsIntrinsics,
+ Mat stdDeviationsExtrinsics,
+ Mat perViewErrors)
+
Finds the camera intrinsic and extrinsic parameters from several views of a calibration
+ pattern.
+
+
Parameters:
+
objectPoints - In the new interface it is a vector of vectors of calibration pattern points in
+ the calibration pattern coordinate space (e.g. std::vector<std::vector<cv::Vec3f>>). The outer
+ vector contains as many elements as the number of pattern views. If the same calibration pattern
+ is shown in each view and it is fully visible, all the vectors will be the same. Although, it is
+ possible to use partially occluded patterns or even different patterns in different views. Then,
+ the vectors will be different. Although the points are 3D, they all lie in the calibration pattern's
+ XY coordinate plane (thus 0 in the Z-coordinate), if the used calibration pattern is a planar rig.
+ In the old interface all the vectors of object points from different views are concatenated
+ together.
+
imagePoints - In the new interface it is a vector of vectors of the projections of calibration
+ pattern points (e.g. std::vector<std::vector<cv::Vec2f>>). imagePoints.size() and
+ objectPoints.size(), and imagePoints[i].size() and objectPoints[i].size() for each i, must be equal,
+ respectively. In the old interface all the vectors of object points from different views are
+ concatenated together.
+
imageSize - Size of the image used only to initialize the camera intrinsic matrix.
+
cameraMatrix - Input/output 3x3 floating-point camera intrinsic matrix
+ \(\cameramatrix{A}\) . 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.
+
distCoeffs - Input/output vector of distortion coefficients
+ \(\distcoeffs\).
+
rvecs - Output vector of rotation vectors (REF: Rodrigues ) estimated for each pattern view
+ (e.g. std::vector<cv::Mat>>). That is, each i-th rotation vector together with the corresponding
+ i-th translation vector (see the next output parameter description) brings the calibration pattern
+ from the object coordinate space (in which object points are specified) to the camera coordinate
+ space. In more technical terms, the tuple of the i-th rotation and translation vector performs
+ a change of basis from object coordinate space to camera coordinate space. Due to its duality, this
+ tuple is equivalent to the position of the calibration pattern with respect to the camera coordinate
+ space.
+
tvecs - Output vector of translation vectors estimated for each pattern view, see parameter
+ describtion above.
+
stdDeviationsIntrinsics - Output vector of standard deviations estimated for intrinsic
+ parameters. Order of deviations values:
+ \((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)\) If one of parameters is not estimated, it's deviation is equals to zero.
+
stdDeviationsExtrinsics - Output vector of standard deviations estimated for extrinsic
+ parameters. Order of deviations values: \((R_0, T_0, \dotsc , R_{M - 1}, T_{M - 1})\) where M is
+ the number of pattern views. \(R_i, T_i\) are concatenated 1x3 vectors.
+
perViewErrors - Output vector of the RMS re-projection error estimated for each pattern view.
+
+
+ REF: CALIB_USE_INTRINSIC_GUESS cameraMatrix contains valid initial values of
+ fx, fy, cx, cy that are optimized further. Otherwise, (cx, cy) is initially set to the image
+ center ( imageSize is used), and focal distances are computed in a least-squares fashion.
+ Note, that if intrinsic parameters are known, there is no need to use this function just to
+ estimate extrinsic parameters. Use REF: 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.
+
+
+ REF: CALIB_FIX_ASPECT_RATIO The functions consider only fy as a free parameter. The
+ ratio fx/fy stays the same as in the input cameraMatrix . When
+ REF: CALIB_USE_INTRINSIC_GUESS is not set, the actual input values of fx and fy are
+ ignored, only their ratio is computed and used further.
+
+
+ REF: CALIB_ZERO_TANGENT_DIST Tangential distortion coefficients \((p_1, p_2)\) 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.
+
+
+ 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.
+
+
+ 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.
+
+
+ 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.
+
+
+
Returns:
+
the overall RMS re-projection error.
+
+ The function estimates the intrinsic camera parameters and extrinsic parameters for each of the
+ views. The algorithm is based on CITE: Zhang2000 and CITE: BouguetMCT . The coordinates of 3D object
+ points and their corresponding 2D projections in each view must be specified. That may be achieved
+ by using an object with known geometry and easily detectable feature points. Such an object is
+ called a calibration rig or calibration pattern, and OpenCV has built-in support for a chessboard as
+ a calibration rig (see REF: findChessboardCorners). Currently, initialization of intrinsic
+ parameters (when REF: CALIB_USE_INTRINSIC_GUESS is not set) is only implemented for planar calibration
+ patterns (where Z-coordinates of the object points must be all zeros). 3D calibration rigs can also
+ be used as long as initial cameraMatrix is provided.
+
+ The algorithm performs the following steps:
+
+
+
+ Compute the initial intrinsic parameters (the option only available for planar calibration
+ patterns) or read them from the input parameters. The distortion coefficients are all set to
+ zeros initially unless some of 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 .
+
+
+
+
+
+ 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.
+
+
+
+ Note:
+ If you use a non-square (i.e. non-N-by-N) grid and REF: findChessboardCorners for calibration,
+ and REF: calibrateCamera returns bad values (zero distortion coefficients, \(c_x\) and
+ \(c_y\) very far from the image center, and/or large differences between \(f_x\) and
+ \(f_y\) (ratios of 10:1 or more)), then you are probably using patternSize=cvSize(rows,cols)
+ instead of using patternSize=cvSize(cols,rows) in REF: findChessboardCorners.
+
+ SEE:
+ calibrateCameraRO, findChessboardCorners, solvePnP, initCameraMatrix2D, stereoCalibrate,
+ undistort
public static double calibrateCameraExtended(java.util.List<Mat> objectPoints,
+ java.util.List<Mat> imagePoints,
+ Size imageSize,
+ Mat cameraMatrix,
+ Mat distCoeffs,
+ java.util.List<Mat> rvecs,
+ java.util.List<Mat> tvecs,
+ Mat stdDeviationsIntrinsics,
+ Mat stdDeviationsExtrinsics,
+ Mat perViewErrors,
+ int flags)
+
Finds the camera intrinsic and extrinsic parameters from several views of a calibration
+ pattern.
+
+
Parameters:
+
objectPoints - In the new interface it is a vector of vectors of calibration pattern points in
+ the calibration pattern coordinate space (e.g. std::vector<std::vector<cv::Vec3f>>). The outer
+ vector contains as many elements as the number of pattern views. If the same calibration pattern
+ is shown in each view and it is fully visible, all the vectors will be the same. Although, it is
+ possible to use partially occluded patterns or even different patterns in different views. Then,
+ the vectors will be different. Although the points are 3D, they all lie in the calibration pattern's
+ XY coordinate plane (thus 0 in the Z-coordinate), if the used calibration pattern is a planar rig.
+ In the old interface all the vectors of object points from different views are concatenated
+ together.
+
imagePoints - In the new interface it is a vector of vectors of the projections of calibration
+ pattern points (e.g. std::vector<std::vector<cv::Vec2f>>). imagePoints.size() and
+ objectPoints.size(), and imagePoints[i].size() and objectPoints[i].size() for each i, must be equal,
+ respectively. In the old interface all the vectors of object points from different views are
+ concatenated together.
+
imageSize - Size of the image used only to initialize the camera intrinsic matrix.
+
cameraMatrix - Input/output 3x3 floating-point camera intrinsic matrix
+ \(\cameramatrix{A}\) . 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.
+
distCoeffs - Input/output vector of distortion coefficients
+ \(\distcoeffs\).
+
rvecs - Output vector of rotation vectors (REF: Rodrigues ) estimated for each pattern view
+ (e.g. std::vector<cv::Mat>>). That is, each i-th rotation vector together with the corresponding
+ i-th translation vector (see the next output parameter description) brings the calibration pattern
+ from the object coordinate space (in which object points are specified) to the camera coordinate
+ space. In more technical terms, the tuple of the i-th rotation and translation vector performs
+ a change of basis from object coordinate space to camera coordinate space. Due to its duality, this
+ tuple is equivalent to the position of the calibration pattern with respect to the camera coordinate
+ space.
+
tvecs - Output vector of translation vectors estimated for each pattern view, see parameter
+ describtion above.
+
stdDeviationsIntrinsics - Output vector of standard deviations estimated for intrinsic
+ parameters. Order of deviations values:
+ \((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)\) If one of parameters is not estimated, it's deviation is equals to zero.
+
stdDeviationsExtrinsics - Output vector of standard deviations estimated for extrinsic
+ parameters. Order of deviations values: \((R_0, T_0, \dotsc , R_{M - 1}, T_{M - 1})\) where M is
+ the number of pattern views. \(R_i, T_i\) are concatenated 1x3 vectors.
+
perViewErrors - Output vector of the RMS re-projection error estimated for each pattern view.
+
flags - Different flags that may be zero or a combination of the following values:
+
+
+ REF: CALIB_USE_INTRINSIC_GUESS cameraMatrix contains valid initial values of
+ fx, fy, cx, cy that are optimized further. Otherwise, (cx, cy) is initially set to the image
+ center ( imageSize is used), and focal distances are computed in a least-squares fashion.
+ Note, that if intrinsic parameters are known, there is no need to use this function just to
+ estimate extrinsic parameters. Use REF: 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.
+
+
+ REF: CALIB_FIX_ASPECT_RATIO The functions consider only fy as a free parameter. The
+ ratio fx/fy stays the same as in the input cameraMatrix . When
+ REF: CALIB_USE_INTRINSIC_GUESS is not set, the actual input values of fx and fy are
+ ignored, only their ratio is computed and used further.
+
+
+ REF: CALIB_ZERO_TANGENT_DIST Tangential distortion coefficients \((p_1, p_2)\) 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.
+
+
+ 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.
+
+
+ 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.
+
+
+ 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.
+
+
+
Returns:
+
the overall RMS re-projection error.
+
+ The function estimates the intrinsic camera parameters and extrinsic parameters for each of the
+ views. The algorithm is based on CITE: Zhang2000 and CITE: BouguetMCT . The coordinates of 3D object
+ points and their corresponding 2D projections in each view must be specified. That may be achieved
+ by using an object with known geometry and easily detectable feature points. Such an object is
+ called a calibration rig or calibration pattern, and OpenCV has built-in support for a chessboard as
+ a calibration rig (see REF: findChessboardCorners). Currently, initialization of intrinsic
+ parameters (when REF: CALIB_USE_INTRINSIC_GUESS is not set) is only implemented for planar calibration
+ patterns (where Z-coordinates of the object points must be all zeros). 3D calibration rigs can also
+ be used as long as initial cameraMatrix is provided.
+
+ The algorithm performs the following steps:
+
+
+
+ Compute the initial intrinsic parameters (the option only available for planar calibration
+ patterns) or read them from the input parameters. The distortion coefficients are all set to
+ zeros initially unless some of 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 .
+
+
+
+
+
+ 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.
+
+
+
+ Note:
+ If you use a non-square (i.e. non-N-by-N) grid and REF: findChessboardCorners for calibration,
+ and REF: calibrateCamera returns bad values (zero distortion coefficients, \(c_x\) and
+ \(c_y\) very far from the image center, and/or large differences between \(f_x\) and
+ \(f_y\) (ratios of 10:1 or more)), then you are probably using patternSize=cvSize(rows,cols)
+ instead of using patternSize=cvSize(cols,rows) in REF: findChessboardCorners.
+
+ SEE:
+ calibrateCameraRO, findChessboardCorners, solvePnP, initCameraMatrix2D, stereoCalibrate,
+ undistort
public static double calibrateCameraExtended(java.util.List<Mat> objectPoints,
+ java.util.List<Mat> imagePoints,
+ Size imageSize,
+ Mat cameraMatrix,
+ Mat distCoeffs,
+ java.util.List<Mat> rvecs,
+ java.util.List<Mat> tvecs,
+ Mat stdDeviationsIntrinsics,
+ Mat stdDeviationsExtrinsics,
+ Mat perViewErrors,
+ int flags,
+ TermCriteria criteria)
+
Finds the camera intrinsic and extrinsic parameters from several views of a calibration
+ pattern.
+
+
Parameters:
+
objectPoints - In the new interface it is a vector of vectors of calibration pattern points in
+ the calibration pattern coordinate space (e.g. std::vector<std::vector<cv::Vec3f>>). The outer
+ vector contains as many elements as the number of pattern views. If the same calibration pattern
+ is shown in each view and it is fully visible, all the vectors will be the same. Although, it is
+ possible to use partially occluded patterns or even different patterns in different views. Then,
+ the vectors will be different. Although the points are 3D, they all lie in the calibration pattern's
+ XY coordinate plane (thus 0 in the Z-coordinate), if the used calibration pattern is a planar rig.
+ In the old interface all the vectors of object points from different views are concatenated
+ together.
+
imagePoints - In the new interface it is a vector of vectors of the projections of calibration
+ pattern points (e.g. std::vector<std::vector<cv::Vec2f>>). imagePoints.size() and
+ objectPoints.size(), and imagePoints[i].size() and objectPoints[i].size() for each i, must be equal,
+ respectively. In the old interface all the vectors of object points from different views are
+ concatenated together.
+
imageSize - Size of the image used only to initialize the camera intrinsic matrix.
+
cameraMatrix - Input/output 3x3 floating-point camera intrinsic matrix
+ \(\cameramatrix{A}\) . 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.
+
distCoeffs - Input/output vector of distortion coefficients
+ \(\distcoeffs\).
+
rvecs - Output vector of rotation vectors (REF: Rodrigues ) estimated for each pattern view
+ (e.g. std::vector<cv::Mat>>). That is, each i-th rotation vector together with the corresponding
+ i-th translation vector (see the next output parameter description) brings the calibration pattern
+ from the object coordinate space (in which object points are specified) to the camera coordinate
+ space. In more technical terms, the tuple of the i-th rotation and translation vector performs
+ a change of basis from object coordinate space to camera coordinate space. Due to its duality, this
+ tuple is equivalent to the position of the calibration pattern with respect to the camera coordinate
+ space.
+
tvecs - Output vector of translation vectors estimated for each pattern view, see parameter
+ describtion above.
+
stdDeviationsIntrinsics - Output vector of standard deviations estimated for intrinsic
+ parameters. Order of deviations values:
+ \((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)\) If one of parameters is not estimated, it's deviation is equals to zero.
+
stdDeviationsExtrinsics - Output vector of standard deviations estimated for extrinsic
+ parameters. Order of deviations values: \((R_0, T_0, \dotsc , R_{M - 1}, T_{M - 1})\) where M is
+ the number of pattern views. \(R_i, T_i\) are concatenated 1x3 vectors.
+
perViewErrors - Output vector of the RMS re-projection error estimated for each pattern view.
+
flags - Different flags that may be zero or a combination of the following values:
+
+
+ REF: CALIB_USE_INTRINSIC_GUESS cameraMatrix contains valid initial values of
+ fx, fy, cx, cy that are optimized further. Otherwise, (cx, cy) is initially set to the image
+ center ( imageSize is used), and focal distances are computed in a least-squares fashion.
+ Note, that if intrinsic parameters are known, there is no need to use this function just to
+ estimate extrinsic parameters. Use REF: 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.
+
+
+ REF: CALIB_FIX_ASPECT_RATIO The functions consider only fy as a free parameter. The
+ ratio fx/fy stays the same as in the input cameraMatrix . When
+ REF: CALIB_USE_INTRINSIC_GUESS is not set, the actual input values of fx and fy are
+ ignored, only their ratio is computed and used further.
+
+
+ REF: CALIB_ZERO_TANGENT_DIST Tangential distortion coefficients \((p_1, p_2)\) 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.
+
+
+ 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.
+
+
+ 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.
+
+
+ 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.
+
+
+
criteria - Termination criteria for the iterative optimization algorithm.
+
Returns:
+
the overall RMS re-projection error.
+
+ The function estimates the intrinsic camera parameters and extrinsic parameters for each of the
+ views. The algorithm is based on CITE: Zhang2000 and CITE: BouguetMCT . The coordinates of 3D object
+ points and their corresponding 2D projections in each view must be specified. That may be achieved
+ by using an object with known geometry and easily detectable feature points. Such an object is
+ called a calibration rig or calibration pattern, and OpenCV has built-in support for a chessboard as
+ a calibration rig (see REF: findChessboardCorners). Currently, initialization of intrinsic
+ parameters (when REF: CALIB_USE_INTRINSIC_GUESS is not set) is only implemented for planar calibration
+ patterns (where Z-coordinates of the object points must be all zeros). 3D calibration rigs can also
+ be used as long as initial cameraMatrix is provided.
+
+ The algorithm performs the following steps:
+
+
+
+ Compute the initial intrinsic parameters (the option only available for planar calibration
+ patterns) or read them from the input parameters. The distortion coefficients are all set to
+ zeros initially unless some of 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 .
+
+
+
+
+
+ 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.
+
+
+
+ Note:
+ If you use a non-square (i.e. non-N-by-N) grid and REF: findChessboardCorners for calibration,
+ and REF: calibrateCamera returns bad values (zero distortion coefficients, \(c_x\) and
+ \(c_y\) very far from the image center, and/or large differences between \(f_x\) and
+ \(f_y\) (ratios of 10:1 or more)), then you are probably using patternSize=cvSize(rows,cols)
+ instead of using patternSize=cvSize(cols,rows) in REF: findChessboardCorners.
+
+ SEE:
+ calibrateCameraRO, findChessboardCorners, solvePnP, initCameraMatrix2D, stereoCalibrate,
+ undistort
public static double calibrateCameraROExtended(java.util.List<Mat> objectPoints,
+ java.util.List<Mat> imagePoints,
+ Size imageSize,
+ int iFixedPoint,
+ Mat cameraMatrix,
+ Mat distCoeffs,
+ java.util.List<Mat> rvecs,
+ java.util.List<Mat> tvecs,
+ Mat newObjPoints,
+ Mat stdDeviationsIntrinsics,
+ Mat stdDeviationsExtrinsics,
+ Mat stdDeviationsObjPoints,
+ Mat perViewErrors)
+
Finds the camera intrinsic and extrinsic parameters from several views of a calibration pattern.
+
+ This function is an extension of #calibrateCamera with the method of releasing object which was
+ proposed in CITE: strobl2011iccv. In many common cases with inaccurate, unmeasured, roughly planar
+ targets (calibration plates), this method can dramatically improve the precision of the estimated
+ camera parameters. Both the object-releasing method and standard method are supported by this
+ function. Use the parameter iFixedPoint for method selection. In the internal implementation,
+ #calibrateCamera is a wrapper for this function.
+
+
Parameters:
+
objectPoints - Vector of vectors of calibration pattern points in the calibration pattern
+ coordinate space. See #calibrateCamera for details. If the method of releasing object to be used,
+ the identical calibration board must be used in each view and it must be fully visible, and all
+ objectPoints[i] must be the same and all points should be roughly close to a plane. The calibration
+ target has to be rigid, or at least static if the camera (rather than the calibration target) is
+ shifted for grabbing images.
+
imagePoints - Vector of vectors of the projections of calibration pattern points. See
+ #calibrateCamera for details.
+
imageSize - Size of the image used only to initialize the intrinsic camera matrix.
+
iFixedPoint - The index of the 3D object point in objectPoints[0] to be fixed. It also acts as
+ a switch for calibration method selection. If object-releasing method to be used, pass in the
+ parameter in the range of [1, objectPoints[0].size()-2], otherwise a value out of this range will
+ make standard calibration method selected. Usually the top-right corner point of the calibration
+ board grid is recommended to be fixed when object-releasing method being utilized. According to
+ \cite strobl2011iccv, two other points are also fixed. In this implementation, objectPoints[0].front
+ and objectPoints[0].back.z are used. With object-releasing method, accurate rvecs, tvecs and
+ newObjPoints are only possible if coordinates of these three fixed points are accurate enough.
+
cameraMatrix - Output 3x3 floating-point camera matrix. See #calibrateCamera for details.
+
distCoeffs - Output vector of distortion coefficients. See #calibrateCamera for details.
+
rvecs - Output vector of rotation vectors estimated for each pattern view. See #calibrateCamera
+ for details.
+
tvecs - Output vector of translation vectors estimated for each pattern view.
+
newObjPoints - The updated output vector of calibration pattern points. The coordinates might
+ be scaled based on three fixed points. The returned coordinates are accurate only if the above
+ mentioned three fixed points are accurate. If not needed, noArray() can be passed in. This parameter
+ is ignored with standard calibration method.
+
stdDeviationsIntrinsics - Output vector of standard deviations estimated for intrinsic parameters.
+ See #calibrateCamera for details.
+
stdDeviationsExtrinsics - Output vector of standard deviations estimated for extrinsic parameters.
+ See #calibrateCamera for details.
+
stdDeviationsObjPoints - Output vector of standard deviations estimated for refined coordinates
+ of calibration pattern points. It has the same size and order as objectPoints[0] vector. This
+ parameter is ignored with standard calibration method.
+
perViewErrors - Output vector of the RMS re-projection error estimated for each pattern view.
+ #calibrateCamera for details. If the method of releasing object is used, the calibration time may
+ be much longer. CALIB_USE_QR or CALIB_USE_LU could be used for faster calibration with potentially
+ less precise and less stable in some rare cases.
+
Returns:
+
the overall RMS re-projection error.
+
+ The function estimates the intrinsic camera parameters and extrinsic parameters for each of the
+ views. The algorithm is based on CITE: Zhang2000, CITE: BouguetMCT and CITE: strobl2011iccv. See
+ #calibrateCamera for other detailed explanations.
+ SEE:
+ calibrateCamera, findChessboardCorners, solvePnP, initCameraMatrix2D, stereoCalibrate, undistort
public static double calibrateCameraROExtended(java.util.List<Mat> objectPoints,
+ java.util.List<Mat> imagePoints,
+ Size imageSize,
+ int iFixedPoint,
+ Mat cameraMatrix,
+ Mat distCoeffs,
+ java.util.List<Mat> rvecs,
+ java.util.List<Mat> tvecs,
+ Mat newObjPoints,
+ Mat stdDeviationsIntrinsics,
+ Mat stdDeviationsExtrinsics,
+ Mat stdDeviationsObjPoints,
+ Mat perViewErrors,
+ int flags)
+
Finds the camera intrinsic and extrinsic parameters from several views of a calibration pattern.
+
+ This function is an extension of #calibrateCamera with the method of releasing object which was
+ proposed in CITE: strobl2011iccv. In many common cases with inaccurate, unmeasured, roughly planar
+ targets (calibration plates), this method can dramatically improve the precision of the estimated
+ camera parameters. Both the object-releasing method and standard method are supported by this
+ function. Use the parameter iFixedPoint for method selection. In the internal implementation,
+ #calibrateCamera is a wrapper for this function.
+
+
Parameters:
+
objectPoints - Vector of vectors of calibration pattern points in the calibration pattern
+ coordinate space. See #calibrateCamera for details. If the method of releasing object to be used,
+ the identical calibration board must be used in each view and it must be fully visible, and all
+ objectPoints[i] must be the same and all points should be roughly close to a plane. The calibration
+ target has to be rigid, or at least static if the camera (rather than the calibration target) is
+ shifted for grabbing images.
+
imagePoints - Vector of vectors of the projections of calibration pattern points. See
+ #calibrateCamera for details.
+
imageSize - Size of the image used only to initialize the intrinsic camera matrix.
+
iFixedPoint - The index of the 3D object point in objectPoints[0] to be fixed. It also acts as
+ a switch for calibration method selection. If object-releasing method to be used, pass in the
+ parameter in the range of [1, objectPoints[0].size()-2], otherwise a value out of this range will
+ make standard calibration method selected. Usually the top-right corner point of the calibration
+ board grid is recommended to be fixed when object-releasing method being utilized. According to
+ \cite strobl2011iccv, two other points are also fixed. In this implementation, objectPoints[0].front
+ and objectPoints[0].back.z are used. With object-releasing method, accurate rvecs, tvecs and
+ newObjPoints are only possible if coordinates of these three fixed points are accurate enough.
+
cameraMatrix - Output 3x3 floating-point camera matrix. See #calibrateCamera for details.
+
distCoeffs - Output vector of distortion coefficients. See #calibrateCamera for details.
+
rvecs - Output vector of rotation vectors estimated for each pattern view. See #calibrateCamera
+ for details.
+
tvecs - Output vector of translation vectors estimated for each pattern view.
+
newObjPoints - The updated output vector of calibration pattern points. The coordinates might
+ be scaled based on three fixed points. The returned coordinates are accurate only if the above
+ mentioned three fixed points are accurate. If not needed, noArray() can be passed in. This parameter
+ is ignored with standard calibration method.
+
stdDeviationsIntrinsics - Output vector of standard deviations estimated for intrinsic parameters.
+ See #calibrateCamera for details.
+
stdDeviationsExtrinsics - Output vector of standard deviations estimated for extrinsic parameters.
+ See #calibrateCamera for details.
+
stdDeviationsObjPoints - Output vector of standard deviations estimated for refined coordinates
+ of calibration pattern points. It has the same size and order as objectPoints[0] vector. This
+ parameter is ignored with standard calibration method.
+
perViewErrors - Output vector of the RMS re-projection error estimated for each pattern view.
+
flags - Different flags that may be zero or a combination of some predefined values. See
+ #calibrateCamera for details. If the method of releasing object is used, the calibration time may
+ be much longer. CALIB_USE_QR or CALIB_USE_LU could be used for faster calibration with potentially
+ less precise and less stable in some rare cases.
+
Returns:
+
the overall RMS re-projection error.
+
+ The function estimates the intrinsic camera parameters and extrinsic parameters for each of the
+ views. The algorithm is based on CITE: Zhang2000, CITE: BouguetMCT and CITE: strobl2011iccv. See
+ #calibrateCamera for other detailed explanations.
+ SEE:
+ calibrateCamera, findChessboardCorners, solvePnP, initCameraMatrix2D, stereoCalibrate, undistort
public static double calibrateCameraROExtended(java.util.List<Mat> objectPoints,
+ java.util.List<Mat> imagePoints,
+ Size imageSize,
+ int iFixedPoint,
+ Mat cameraMatrix,
+ Mat distCoeffs,
+ java.util.List<Mat> rvecs,
+ java.util.List<Mat> tvecs,
+ Mat newObjPoints,
+ Mat stdDeviationsIntrinsics,
+ Mat stdDeviationsExtrinsics,
+ Mat stdDeviationsObjPoints,
+ Mat perViewErrors,
+ int flags,
+ TermCriteria criteria)
+
Finds the camera intrinsic and extrinsic parameters from several views of a calibration pattern.
+
+ This function is an extension of #calibrateCamera with the method of releasing object which was
+ proposed in CITE: strobl2011iccv. In many common cases with inaccurate, unmeasured, roughly planar
+ targets (calibration plates), this method can dramatically improve the precision of the estimated
+ camera parameters. Both the object-releasing method and standard method are supported by this
+ function. Use the parameter iFixedPoint for method selection. In the internal implementation,
+ #calibrateCamera is a wrapper for this function.
+
+
Parameters:
+
objectPoints - Vector of vectors of calibration pattern points in the calibration pattern
+ coordinate space. See #calibrateCamera for details. If the method of releasing object to be used,
+ the identical calibration board must be used in each view and it must be fully visible, and all
+ objectPoints[i] must be the same and all points should be roughly close to a plane. The calibration
+ target has to be rigid, or at least static if the camera (rather than the calibration target) is
+ shifted for grabbing images.
+
imagePoints - Vector of vectors of the projections of calibration pattern points. See
+ #calibrateCamera for details.
+
imageSize - Size of the image used only to initialize the intrinsic camera matrix.
+
iFixedPoint - The index of the 3D object point in objectPoints[0] to be fixed. It also acts as
+ a switch for calibration method selection. If object-releasing method to be used, pass in the
+ parameter in the range of [1, objectPoints[0].size()-2], otherwise a value out of this range will
+ make standard calibration method selected. Usually the top-right corner point of the calibration
+ board grid is recommended to be fixed when object-releasing method being utilized. According to
+ \cite strobl2011iccv, two other points are also fixed. In this implementation, objectPoints[0].front
+ and objectPoints[0].back.z are used. With object-releasing method, accurate rvecs, tvecs and
+ newObjPoints are only possible if coordinates of these three fixed points are accurate enough.
+
cameraMatrix - Output 3x3 floating-point camera matrix. See #calibrateCamera for details.
+
distCoeffs - Output vector of distortion coefficients. See #calibrateCamera for details.
+
rvecs - Output vector of rotation vectors estimated for each pattern view. See #calibrateCamera
+ for details.
+
tvecs - Output vector of translation vectors estimated for each pattern view.
+
newObjPoints - The updated output vector of calibration pattern points. The coordinates might
+ be scaled based on three fixed points. The returned coordinates are accurate only if the above
+ mentioned three fixed points are accurate. If not needed, noArray() can be passed in. This parameter
+ is ignored with standard calibration method.
+
stdDeviationsIntrinsics - Output vector of standard deviations estimated for intrinsic parameters.
+ See #calibrateCamera for details.
+
stdDeviationsExtrinsics - Output vector of standard deviations estimated for extrinsic parameters.
+ See #calibrateCamera for details.
+
stdDeviationsObjPoints - Output vector of standard deviations estimated for refined coordinates
+ of calibration pattern points. It has the same size and order as objectPoints[0] vector. This
+ parameter is ignored with standard calibration method.
+
perViewErrors - Output vector of the RMS re-projection error estimated for each pattern view.
+
flags - Different flags that may be zero or a combination of some predefined values. See
+ #calibrateCamera for details. If the method of releasing object is used, the calibration time may
+ be much longer. CALIB_USE_QR or CALIB_USE_LU could be used for faster calibration with potentially
+ less precise and less stable in some rare cases.
+
criteria - Termination criteria for the iterative optimization algorithm.
+
Returns:
+
the overall RMS re-projection error.
+
+ The function estimates the intrinsic camera parameters and extrinsic parameters for each of the
+ views. The algorithm is based on CITE: Zhang2000, CITE: BouguetMCT and CITE: strobl2011iccv. See
+ #calibrateCamera for other detailed explanations.
+ SEE:
+ calibrateCamera, findChessboardCorners, solvePnP, initCameraMatrix2D, stereoCalibrate, undistort
R_gripper2base - Rotation part extracted from the homogeneous matrix that transforms a point
+ expressed in the gripper frame to the robot base frame (\(_{}^{b}\textrm{T}_g\)).
+ This is a vector (vector<Mat>) that contains the rotation, (3x3) rotation matrices or (3x1) rotation vectors,
+ for all the transformations from gripper frame to robot base frame.
+
t_gripper2base - Translation part extracted from the homogeneous matrix that transforms a point
+ expressed in the gripper frame to the robot base frame (\(_{}^{b}\textrm{T}_g\)).
+ This is a vector (vector<Mat>) that contains the (3x1) translation vectors for all the transformations
+ from gripper frame to robot base frame.
+
R_target2cam - Rotation part extracted from the homogeneous matrix that transforms a point
+ expressed in the target frame to the camera frame (\(_{}^{c}\textrm{T}_t\)).
+ This is a vector (vector<Mat>) that contains the rotation, (3x3) rotation matrices or (3x1) rotation vectors,
+ for all the transformations from calibration target frame to camera frame.
+
t_target2cam - Rotation part extracted from the homogeneous matrix that transforms a point
+ expressed in the target frame to the camera frame (\(_{}^{c}\textrm{T}_t\)).
+ This is a vector (vector<Mat>) that contains the (3x1) translation vectors for all the transformations
+ from calibration target frame to camera frame.
+
R_cam2gripper - Estimated (3x3) rotation part extracted from the homogeneous matrix that transforms a point
+ expressed in the camera frame to the gripper frame (\(_{}^{g}\textrm{T}_c\)).
+
t_cam2gripper - Estimated (3x1) translation part extracted from the homogeneous matrix that transforms a point
+ expressed in the camera frame to the gripper frame (\(_{}^{g}\textrm{T}_c\)).
+
+ The function performs the Hand-Eye calibration using various methods. One approach consists in estimating the
+ rotation then the translation (separable solutions) and the following methods are implemented:
+
+
+ R. Tsai, R. Lenz A New Technique for Fully Autonomous and Efficient 3D Robotics Hand/EyeCalibration \cite Tsai89
+
+
+ F. Park, B. Martin Robot Sensor Calibration: Solving AX = XB on the Euclidean Group \cite Park94
+
+
+ R. Horaud, F. Dornaika Hand-Eye Calibration \cite Horaud95
+
+
+
+ Another approach consists in estimating simultaneously the rotation and the translation (simultaneous solutions),
+ with the following implemented methods:
+
+
+ N. Andreff, R. Horaud, B. Espiau On-line Hand-Eye Calibration \cite Andreff99
+
+
+ K. Daniilidis Hand-Eye Calibration Using Dual Quaternions \cite Daniilidis98
+
+
+
+ The following picture describes the Hand-Eye calibration problem where the transformation between a camera ("eye")
+ mounted on a robot gripper ("hand") has to be estimated. This configuration is called eye-in-hand.
+
+ The eye-to-hand configuration consists in a static camera observing a calibration pattern mounted on the robot
+ end-effector. The transformation from the camera to the robot base frame can then be estimated by inputting
+ the suitable transformations to the function, see below.
+
+ 
+
+ The calibration procedure is the following:
+
+
+ a static calibration pattern is used to estimate the transformation between the target frame
+ and the camera frame
+
+
+ the robot gripper is moved in order to acquire several poses
+
+
+ for each pose, the homogeneous transformation between the gripper frame and the robot base frame is recorded using for
+ instance the robot kinematics
+ \(
+ \begin{bmatrix}
+ X_b\\
+ Y_b\\
+ Z_b\\
+ 1
+ \end{bmatrix}
+ =
+ \begin{bmatrix}
+ _{}^{b}\textrm{R}_g & _{}^{b}\textrm{t}_g \\
+ 0_{1 \times 3} & 1
+ \end{bmatrix}
+ \begin{bmatrix}
+ X_g\\
+ Y_g\\
+ Z_g\\
+ 1
+ \end{bmatrix}
+ \)
+
+
+ for each pose, the homogeneous transformation between the calibration target frame and the camera frame is recorded using
+ for instance a pose estimation method (PnP) from 2D-3D point correspondences
+ \(
+ \begin{bmatrix}
+ X_c\\
+ Y_c\\
+ Z_c\\
+ 1
+ \end{bmatrix}
+ =
+ \begin{bmatrix}
+ _{}^{c}\textrm{R}_t & _{}^{c}\textrm{t}_t \\
+ 0_{1 \times 3} & 1
+ \end{bmatrix}
+ \begin{bmatrix}
+ X_t\\
+ Y_t\\
+ Z_t\\
+ 1
+ \end{bmatrix}
+ \)
+
+
+
+ The Hand-Eye calibration procedure returns the following homogeneous transformation
+ \(
+ \begin{bmatrix}
+ X_g\\
+ Y_g\\
+ Z_g\\
+ 1
+ \end{bmatrix}
+ =
+ \begin{bmatrix}
+ _{}^{g}\textrm{R}_c & _{}^{g}\textrm{t}_c \\
+ 0_{1 \times 3} & 1
+ \end{bmatrix}
+ \begin{bmatrix}
+ X_c\\
+ Y_c\\
+ Z_c\\
+ 1
+ \end{bmatrix}
+ \)
+
+ This problem is also known as solving the \(\mathbf{A}\mathbf{X}=\mathbf{X}\mathbf{B}\) equation:
+
+
+ (^{g}{\textrm{T}_b}^{(2)})^{-1} \hspace{0.2em} ^{g}{\textrm{T}_b}^{(1)} \hspace{0.2em} ^{b}\textrm{T}_c &=
+ \hspace{0.1em} ^{b}\textrm{T}_c \hspace{0.2em} ^{c}{\textrm{T}_t}^{(2)} (^{c}{\textrm{T}_t}^{(1)})^{-1} \\
+
+ \textrm{A}_i \textrm{X} &= \textrm{X} \textrm{B}_i \\
+ \end{align*}
+ \)
+
+ \note
+ Additional information can be found on this [website](http://campar.in.tum.de/Chair/HandEyeCalibration).
+ \note
+ A minimum of 2 motions with non parallel rotation axes are necessary to determine the hand-eye transformation.
+ So at least 3 different poses are required, but it is strongly recommended to use many more poses.
R_gripper2base - Rotation part extracted from the homogeneous matrix that transforms a point
+ expressed in the gripper frame to the robot base frame (\(_{}^{b}\textrm{T}_g\)).
+ This is a vector (vector<Mat>) that contains the rotation, (3x3) rotation matrices or (3x1) rotation vectors,
+ for all the transformations from gripper frame to robot base frame.
+
t_gripper2base - Translation part extracted from the homogeneous matrix that transforms a point
+ expressed in the gripper frame to the robot base frame (\(_{}^{b}\textrm{T}_g\)).
+ This is a vector (vector<Mat>) that contains the (3x1) translation vectors for all the transformations
+ from gripper frame to robot base frame.
+
R_target2cam - Rotation part extracted from the homogeneous matrix that transforms a point
+ expressed in the target frame to the camera frame (\(_{}^{c}\textrm{T}_t\)).
+ This is a vector (vector<Mat>) that contains the rotation, (3x3) rotation matrices or (3x1) rotation vectors,
+ for all the transformations from calibration target frame to camera frame.
+
t_target2cam - Rotation part extracted from the homogeneous matrix that transforms a point
+ expressed in the target frame to the camera frame (\(_{}^{c}\textrm{T}_t\)).
+ This is a vector (vector<Mat>) that contains the (3x1) translation vectors for all the transformations
+ from calibration target frame to camera frame.
+
R_cam2gripper - Estimated (3x3) rotation part extracted from the homogeneous matrix that transforms a point
+ expressed in the camera frame to the gripper frame (\(_{}^{g}\textrm{T}_c\)).
+
t_cam2gripper - Estimated (3x1) translation part extracted from the homogeneous matrix that transforms a point
+ expressed in the camera frame to the gripper frame (\(_{}^{g}\textrm{T}_c\)).
+
method - One of the implemented Hand-Eye calibration method, see cv::HandEyeCalibrationMethod
+
+ The function performs the Hand-Eye calibration using various methods. One approach consists in estimating the
+ rotation then the translation (separable solutions) and the following methods are implemented:
+
+
+ R. Tsai, R. Lenz A New Technique for Fully Autonomous and Efficient 3D Robotics Hand/EyeCalibration \cite Tsai89
+
+
+ F. Park, B. Martin Robot Sensor Calibration: Solving AX = XB on the Euclidean Group \cite Park94
+
+
+ R. Horaud, F. Dornaika Hand-Eye Calibration \cite Horaud95
+
+
+
+ Another approach consists in estimating simultaneously the rotation and the translation (simultaneous solutions),
+ with the following implemented methods:
+
+
+ N. Andreff, R. Horaud, B. Espiau On-line Hand-Eye Calibration \cite Andreff99
+
+
+ K. Daniilidis Hand-Eye Calibration Using Dual Quaternions \cite Daniilidis98
+
+
+
+ The following picture describes the Hand-Eye calibration problem where the transformation between a camera ("eye")
+ mounted on a robot gripper ("hand") has to be estimated. This configuration is called eye-in-hand.
+
+ The eye-to-hand configuration consists in a static camera observing a calibration pattern mounted on the robot
+ end-effector. The transformation from the camera to the robot base frame can then be estimated by inputting
+ the suitable transformations to the function, see below.
+
+ 
+
+ The calibration procedure is the following:
+
+
+ a static calibration pattern is used to estimate the transformation between the target frame
+ and the camera frame
+
+
+ the robot gripper is moved in order to acquire several poses
+
+
+ for each pose, the homogeneous transformation between the gripper frame and the robot base frame is recorded using for
+ instance the robot kinematics
+ \(
+ \begin{bmatrix}
+ X_b\\
+ Y_b\\
+ Z_b\\
+ 1
+ \end{bmatrix}
+ =
+ \begin{bmatrix}
+ _{}^{b}\textrm{R}_g & _{}^{b}\textrm{t}_g \\
+ 0_{1 \times 3} & 1
+ \end{bmatrix}
+ \begin{bmatrix}
+ X_g\\
+ Y_g\\
+ Z_g\\
+ 1
+ \end{bmatrix}
+ \)
+
+
+ for each pose, the homogeneous transformation between the calibration target frame and the camera frame is recorded using
+ for instance a pose estimation method (PnP) from 2D-3D point correspondences
+ \(
+ \begin{bmatrix}
+ X_c\\
+ Y_c\\
+ Z_c\\
+ 1
+ \end{bmatrix}
+ =
+ \begin{bmatrix}
+ _{}^{c}\textrm{R}_t & _{}^{c}\textrm{t}_t \\
+ 0_{1 \times 3} & 1
+ \end{bmatrix}
+ \begin{bmatrix}
+ X_t\\
+ Y_t\\
+ Z_t\\
+ 1
+ \end{bmatrix}
+ \)
+
+
+
+ The Hand-Eye calibration procedure returns the following homogeneous transformation
+ \(
+ \begin{bmatrix}
+ X_g\\
+ Y_g\\
+ Z_g\\
+ 1
+ \end{bmatrix}
+ =
+ \begin{bmatrix}
+ _{}^{g}\textrm{R}_c & _{}^{g}\textrm{t}_c \\
+ 0_{1 \times 3} & 1
+ \end{bmatrix}
+ \begin{bmatrix}
+ X_c\\
+ Y_c\\
+ Z_c\\
+ 1
+ \end{bmatrix}
+ \)
+
+ This problem is also known as solving the \(\mathbf{A}\mathbf{X}=\mathbf{X}\mathbf{B}\) equation:
+
+
+ (^{g}{\textrm{T}_b}^{(2)})^{-1} \hspace{0.2em} ^{g}{\textrm{T}_b}^{(1)} \hspace{0.2em} ^{b}\textrm{T}_c &=
+ \hspace{0.1em} ^{b}\textrm{T}_c \hspace{0.2em} ^{c}{\textrm{T}_t}^{(2)} (^{c}{\textrm{T}_t}^{(1)})^{-1} \\
+
+ \textrm{A}_i \textrm{X} &= \textrm{X} \textrm{B}_i \\
+ \end{align*}
+ \)
+
+ \note
+ Additional information can be found on this [website](http://campar.in.tum.de/Chair/HandEyeCalibration).
+ \note
+ A minimum of 2 motions with non parallel rotation axes are necessary to determine the hand-eye transformation.
+ So at least 3 different poses are required, but it is strongly recommended to use many more poses.
public static void calibrateRobotWorldHandEye(java.util.List<Mat> R_world2cam,
+ java.util.List<Mat> t_world2cam,
+ java.util.List<Mat> R_base2gripper,
+ java.util.List<Mat> t_base2gripper,
+ Mat R_base2world,
+ Mat t_base2world,
+ Mat R_gripper2cam,
+ Mat t_gripper2cam)
+
Computes Robot-World/Hand-Eye calibration: \(_{}^{w}\textrm{T}_b\) and \(_{}^{c}\textrm{T}_g\)
+
+
Parameters:
+
R_world2cam - Rotation part extracted from the homogeneous matrix that transforms a point
+ expressed in the world frame to the camera frame (\(_{}^{c}\textrm{T}_w\)).
+ This is a vector (vector<Mat>) that contains the rotation, (3x3) rotation matrices or (3x1) rotation vectors,
+ for all the transformations from world frame to the camera frame.
+
t_world2cam - Translation part extracted from the homogeneous matrix that transforms a point
+ expressed in the world frame to the camera frame (\(_{}^{c}\textrm{T}_w\)).
+ This is a vector (vector<Mat>) that contains the (3x1) translation vectors for all the transformations
+ from world frame to the camera frame.
+
R_base2gripper - Rotation part extracted from the homogeneous matrix that transforms a point
+ expressed in the robot base frame to the gripper frame (\(_{}^{g}\textrm{T}_b\)).
+ This is a vector (vector<Mat>) that contains the rotation, (3x3) rotation matrices or (3x1) rotation vectors,
+ for all the transformations from robot base frame to the gripper frame.
+
t_base2gripper - Rotation part extracted from the homogeneous matrix that transforms a point
+ expressed in the robot base frame to the gripper frame (\(_{}^{g}\textrm{T}_b\)).
+ This is a vector (vector<Mat>) that contains the (3x1) translation vectors for all the transformations
+ from robot base frame to the gripper frame.
+
R_base2world - Estimated (3x3) rotation part extracted from the homogeneous matrix that transforms a point
+ expressed in the robot base frame to the world frame (\(_{}^{w}\textrm{T}_b\)).
+
t_base2world - Estimated (3x1) translation part extracted from the homogeneous matrix that transforms a point
+ expressed in the robot base frame to the world frame (\(_{}^{w}\textrm{T}_b\)).
+
R_gripper2cam - Estimated (3x3) rotation part extracted from the homogeneous matrix that transforms a point
+ expressed in the gripper frame to the camera frame (\(_{}^{c}\textrm{T}_g\)).
+
t_gripper2cam - Estimated (3x1) translation part extracted from the homogeneous matrix that transforms a point
+ expressed in the gripper frame to the camera frame (\(_{}^{c}\textrm{T}_g\)).
+
+ The function performs the Robot-World/Hand-Eye calibration using various methods. One approach consists in estimating the
+ rotation then the translation (separable solutions):
+
+
+ M. Shah, Solving the robot-world/hand-eye calibration problem using the kronecker product \cite Shah2013SolvingTR
+
+
+
+ Another approach consists in estimating simultaneously the rotation and the translation (simultaneous solutions),
+ with the following implemented method:
+
+
+ A. Li, L. Wang, and D. Wu, Simultaneous robot-world and hand-eye calibration using dual-quaternions and kronecker product \cite Li2010SimultaneousRA
+
+
+
+ The following picture describes the Robot-World/Hand-Eye calibration problem where the transformations between a robot and a world frame
+ and between a robot gripper ("hand") and a camera ("eye") mounted at the robot end-effector have to be estimated.
+
+ 
+
+ The calibration procedure is the following:
+
+
+ a static calibration pattern is used to estimate the transformation between the target frame
+ and the camera frame
+
+
+ the robot gripper is moved in order to acquire several poses
+
+
+ for each pose, the homogeneous transformation between the gripper frame and the robot base frame is recorded using for
+ instance the robot kinematics
+ \(
+ \begin{bmatrix}
+ X_g\\
+ Y_g\\
+ Z_g\\
+ 1
+ \end{bmatrix}
+ =
+ \begin{bmatrix}
+ _{}^{g}\textrm{R}_b & _{}^{g}\textrm{t}_b \\
+ 0_{1 \times 3} & 1
+ \end{bmatrix}
+ \begin{bmatrix}
+ X_b\\
+ Y_b\\
+ Z_b\\
+ 1
+ \end{bmatrix}
+ \)
+
+
+ for each pose, the homogeneous transformation between the calibration target frame (the world frame) and the camera frame is recorded using
+ for instance a pose estimation method (PnP) from 2D-3D point correspondences
+ \(
+ \begin{bmatrix}
+ X_c\\
+ Y_c\\
+ Z_c\\
+ 1
+ \end{bmatrix}
+ =
+ \begin{bmatrix}
+ _{}^{c}\textrm{R}_w & _{}^{c}\textrm{t}_w \\
+ 0_{1 \times 3} & 1
+ \end{bmatrix}
+ \begin{bmatrix}
+ X_w\\
+ Y_w\\
+ Z_w\\
+ 1
+ \end{bmatrix}
+ \)
+
public static void calibrateRobotWorldHandEye(java.util.List<Mat> R_world2cam,
+ java.util.List<Mat> t_world2cam,
+ java.util.List<Mat> R_base2gripper,
+ java.util.List<Mat> t_base2gripper,
+ Mat R_base2world,
+ Mat t_base2world,
+ Mat R_gripper2cam,
+ Mat t_gripper2cam,
+ int method)
+
Computes Robot-World/Hand-Eye calibration: \(_{}^{w}\textrm{T}_b\) and \(_{}^{c}\textrm{T}_g\)
+
+
Parameters:
+
R_world2cam - Rotation part extracted from the homogeneous matrix that transforms a point
+ expressed in the world frame to the camera frame (\(_{}^{c}\textrm{T}_w\)).
+ This is a vector (vector<Mat>) that contains the rotation, (3x3) rotation matrices or (3x1) rotation vectors,
+ for all the transformations from world frame to the camera frame.
+
t_world2cam - Translation part extracted from the homogeneous matrix that transforms a point
+ expressed in the world frame to the camera frame (\(_{}^{c}\textrm{T}_w\)).
+ This is a vector (vector<Mat>) that contains the (3x1) translation vectors for all the transformations
+ from world frame to the camera frame.
+
R_base2gripper - Rotation part extracted from the homogeneous matrix that transforms a point
+ expressed in the robot base frame to the gripper frame (\(_{}^{g}\textrm{T}_b\)).
+ This is a vector (vector<Mat>) that contains the rotation, (3x3) rotation matrices or (3x1) rotation vectors,
+ for all the transformations from robot base frame to the gripper frame.
+
t_base2gripper - Rotation part extracted from the homogeneous matrix that transforms a point
+ expressed in the robot base frame to the gripper frame (\(_{}^{g}\textrm{T}_b\)).
+ This is a vector (vector<Mat>) that contains the (3x1) translation vectors for all the transformations
+ from robot base frame to the gripper frame.
+
R_base2world - Estimated (3x3) rotation part extracted from the homogeneous matrix that transforms a point
+ expressed in the robot base frame to the world frame (\(_{}^{w}\textrm{T}_b\)).
+
t_base2world - Estimated (3x1) translation part extracted from the homogeneous matrix that transforms a point
+ expressed in the robot base frame to the world frame (\(_{}^{w}\textrm{T}_b\)).
+
R_gripper2cam - Estimated (3x3) rotation part extracted from the homogeneous matrix that transforms a point
+ expressed in the gripper frame to the camera frame (\(_{}^{c}\textrm{T}_g\)).
+
t_gripper2cam - Estimated (3x1) translation part extracted from the homogeneous matrix that transforms a point
+ expressed in the gripper frame to the camera frame (\(_{}^{c}\textrm{T}_g\)).
+
method - One of the implemented Robot-World/Hand-Eye calibration method, see cv::RobotWorldHandEyeCalibrationMethod
+
+ The function performs the Robot-World/Hand-Eye calibration using various methods. One approach consists in estimating the
+ rotation then the translation (separable solutions):
+
+
+ M. Shah, Solving the robot-world/hand-eye calibration problem using the kronecker product \cite Shah2013SolvingTR
+
+
+
+ Another approach consists in estimating simultaneously the rotation and the translation (simultaneous solutions),
+ with the following implemented method:
+
+
+ A. Li, L. Wang, and D. Wu, Simultaneous robot-world and hand-eye calibration using dual-quaternions and kronecker product \cite Li2010SimultaneousRA
+
+
+
+ The following picture describes the Robot-World/Hand-Eye calibration problem where the transformations between a robot and a world frame
+ and between a robot gripper ("hand") and a camera ("eye") mounted at the robot end-effector have to be estimated.
+
+ 
+
+ The calibration procedure is the following:
+
+
+ a static calibration pattern is used to estimate the transformation between the target frame
+ and the camera frame
+
+
+ the robot gripper is moved in order to acquire several poses
+
+
+ for each pose, the homogeneous transformation between the gripper frame and the robot base frame is recorded using for
+ instance the robot kinematics
+ \(
+ \begin{bmatrix}
+ X_g\\
+ Y_g\\
+ Z_g\\
+ 1
+ \end{bmatrix}
+ =
+ \begin{bmatrix}
+ _{}^{g}\textrm{R}_b & _{}^{g}\textrm{t}_b \\
+ 0_{1 \times 3} & 1
+ \end{bmatrix}
+ \begin{bmatrix}
+ X_b\\
+ Y_b\\
+ Z_b\\
+ 1
+ \end{bmatrix}
+ \)
+
+
+ for each pose, the homogeneous transformation between the calibration target frame (the world frame) and the camera frame is recorded using
+ for instance a pose estimation method (PnP) from 2D-3D point correspondences
+ \(
+ \begin{bmatrix}
+ X_c\\
+ Y_c\\
+ Z_c\\
+ 1
+ \end{bmatrix}
+ =
+ \begin{bmatrix}
+ _{}^{c}\textrm{R}_w & _{}^{c}\textrm{t}_w \\
+ 0_{1 \times 3} & 1
+ \end{bmatrix}
+ \begin{bmatrix}
+ X_w\\
+ Y_w\\
+ Z_w\\
+ 1
+ \end{bmatrix}
+ \)
+
Computes useful camera characteristics from the camera intrinsic matrix.
+
+
Parameters:
+
cameraMatrix - Input camera intrinsic matrix that can be estimated by #calibrateCamera or
+ #stereoCalibrate .
+
imageSize - Input image size in pixels.
+
apertureWidth - Physical width in mm of the sensor.
+
apertureHeight - Physical height in mm of the sensor.
+
fovx - Output field of view in degrees along the horizontal sensor axis.
+
fovy - Output field of view in degrees along the vertical sensor axis.
+
focalLength - Focal length of the lens in mm.
+
principalPoint - Principal point in mm.
+
aspectRatio - \(f_y/f_x\)
+
+ The function computes various useful camera characteristics from the previously estimated camera
+ matrix.
+
+ Note:
+ Do keep in mind that the unity measure 'mm' stands for whatever unit of measure one chooses for
+ the chessboard pitch (it can thus be any value).
public static void composeRT(Mat rvec1,
+ Mat tvec1,
+ Mat rvec2,
+ Mat tvec2,
+ Mat rvec3,
+ Mat tvec3)
+
Combines two rotation-and-shift transformations.
+
+
Parameters:
+
rvec1 - First rotation vector.
+
tvec1 - First translation vector.
+
rvec2 - Second rotation vector.
+
tvec2 - Second translation vector.
+
rvec3 - Output rotation vector of the superposition.
+
tvec3 - Output translation vector of the superposition.
+
+ The functions compute:
+
+ \(\begin{array}{l} \texttt{rvec3} = \mathrm{rodrigues} ^{-1} \left ( \mathrm{rodrigues} ( \texttt{rvec2} ) \cdot \mathrm{rodrigues} ( \texttt{rvec1} ) \right ) \\ \texttt{tvec3} = \mathrm{rodrigues} ( \texttt{rvec2} ) \cdot \texttt{tvec1} + \texttt{tvec2} \end{array} ,\)
+
+ where \(\mathrm{rodrigues}\) denotes a rotation vector to a rotation matrix transformation, and
+ \(\mathrm{rodrigues}^{-1}\) denotes the inverse transformation. See #Rodrigues for details.
+
+ Also, the functions can compute the derivatives of the output vectors with regards to the input
+ vectors (see #matMulDeriv ). The functions are used inside #stereoCalibrate but can also be used in
+ your own code where Levenberg-Marquardt or another gradient-based solver is used to optimize a
+ function that contains a matrix multiplication.
public static void composeRT(Mat rvec1,
+ Mat tvec1,
+ Mat rvec2,
+ Mat tvec2,
+ Mat rvec3,
+ Mat tvec3,
+ Mat dr3dr1)
+
Combines two rotation-and-shift transformations.
+
+
Parameters:
+
rvec1 - First rotation vector.
+
tvec1 - First translation vector.
+
rvec2 - Second rotation vector.
+
tvec2 - Second translation vector.
+
rvec3 - Output rotation vector of the superposition.
+
tvec3 - Output translation vector of the superposition.
+
dr3dr1 - Optional output derivative of rvec3 with regard to rvec1
+
+ The functions compute:
+
+ \(\begin{array}{l} \texttt{rvec3} = \mathrm{rodrigues} ^{-1} \left ( \mathrm{rodrigues} ( \texttt{rvec2} ) \cdot \mathrm{rodrigues} ( \texttt{rvec1} ) \right ) \\ \texttt{tvec3} = \mathrm{rodrigues} ( \texttt{rvec2} ) \cdot \texttt{tvec1} + \texttt{tvec2} \end{array} ,\)
+
+ where \(\mathrm{rodrigues}\) denotes a rotation vector to a rotation matrix transformation, and
+ \(\mathrm{rodrigues}^{-1}\) denotes the inverse transformation. See #Rodrigues for details.
+
+ Also, the functions can compute the derivatives of the output vectors with regards to the input
+ vectors (see #matMulDeriv ). The functions are used inside #stereoCalibrate but can also be used in
+ your own code where Levenberg-Marquardt or another gradient-based solver is used to optimize a
+ function that contains a matrix multiplication.
public static void composeRT(Mat rvec1,
+ Mat tvec1,
+ Mat rvec2,
+ Mat tvec2,
+ Mat rvec3,
+ Mat tvec3,
+ Mat dr3dr1,
+ Mat dr3dt1)
+
Combines two rotation-and-shift transformations.
+
+
Parameters:
+
rvec1 - First rotation vector.
+
tvec1 - First translation vector.
+
rvec2 - Second rotation vector.
+
tvec2 - Second translation vector.
+
rvec3 - Output rotation vector of the superposition.
+
tvec3 - Output translation vector of the superposition.
+
dr3dr1 - Optional output derivative of rvec3 with regard to rvec1
+
dr3dt1 - Optional output derivative of rvec3 with regard to tvec1
+
+ The functions compute:
+
+ \(\begin{array}{l} \texttt{rvec3} = \mathrm{rodrigues} ^{-1} \left ( \mathrm{rodrigues} ( \texttt{rvec2} ) \cdot \mathrm{rodrigues} ( \texttt{rvec1} ) \right ) \\ \texttt{tvec3} = \mathrm{rodrigues} ( \texttt{rvec2} ) \cdot \texttt{tvec1} + \texttt{tvec2} \end{array} ,\)
+
+ where \(\mathrm{rodrigues}\) denotes a rotation vector to a rotation matrix transformation, and
+ \(\mathrm{rodrigues}^{-1}\) denotes the inverse transformation. See #Rodrigues for details.
+
+ Also, the functions can compute the derivatives of the output vectors with regards to the input
+ vectors (see #matMulDeriv ). The functions are used inside #stereoCalibrate but can also be used in
+ your own code where Levenberg-Marquardt or another gradient-based solver is used to optimize a
+ function that contains a matrix multiplication.
public static void composeRT(Mat rvec1,
+ Mat tvec1,
+ Mat rvec2,
+ Mat tvec2,
+ Mat rvec3,
+ Mat tvec3,
+ Mat dr3dr1,
+ Mat dr3dt1,
+ Mat dr3dr2)
+
Combines two rotation-and-shift transformations.
+
+
Parameters:
+
rvec1 - First rotation vector.
+
tvec1 - First translation vector.
+
rvec2 - Second rotation vector.
+
tvec2 - Second translation vector.
+
rvec3 - Output rotation vector of the superposition.
+
tvec3 - Output translation vector of the superposition.
+
dr3dr1 - Optional output derivative of rvec3 with regard to rvec1
+
dr3dt1 - Optional output derivative of rvec3 with regard to tvec1
+
dr3dr2 - Optional output derivative of rvec3 with regard to rvec2
+
+ The functions compute:
+
+ \(\begin{array}{l} \texttt{rvec3} = \mathrm{rodrigues} ^{-1} \left ( \mathrm{rodrigues} ( \texttt{rvec2} ) \cdot \mathrm{rodrigues} ( \texttt{rvec1} ) \right ) \\ \texttt{tvec3} = \mathrm{rodrigues} ( \texttt{rvec2} ) \cdot \texttt{tvec1} + \texttt{tvec2} \end{array} ,\)
+
+ where \(\mathrm{rodrigues}\) denotes a rotation vector to a rotation matrix transformation, and
+ \(\mathrm{rodrigues}^{-1}\) denotes the inverse transformation. See #Rodrigues for details.
+
+ Also, the functions can compute the derivatives of the output vectors with regards to the input
+ vectors (see #matMulDeriv ). The functions are used inside #stereoCalibrate but can also be used in
+ your own code where Levenberg-Marquardt or another gradient-based solver is used to optimize a
+ function that contains a matrix multiplication.
public static void composeRT(Mat rvec1,
+ Mat tvec1,
+ Mat rvec2,
+ Mat tvec2,
+ Mat rvec3,
+ Mat tvec3,
+ Mat dr3dr1,
+ Mat dr3dt1,
+ Mat dr3dr2,
+ Mat dr3dt2)
+
Combines two rotation-and-shift transformations.
+
+
Parameters:
+
rvec1 - First rotation vector.
+
tvec1 - First translation vector.
+
rvec2 - Second rotation vector.
+
tvec2 - Second translation vector.
+
rvec3 - Output rotation vector of the superposition.
+
tvec3 - Output translation vector of the superposition.
+
dr3dr1 - Optional output derivative of rvec3 with regard to rvec1
+
dr3dt1 - Optional output derivative of rvec3 with regard to tvec1
+
dr3dr2 - Optional output derivative of rvec3 with regard to rvec2
+
dr3dt2 - Optional output derivative of rvec3 with regard to tvec2
+
+ The functions compute:
+
+ \(\begin{array}{l} \texttt{rvec3} = \mathrm{rodrigues} ^{-1} \left ( \mathrm{rodrigues} ( \texttt{rvec2} ) \cdot \mathrm{rodrigues} ( \texttt{rvec1} ) \right ) \\ \texttt{tvec3} = \mathrm{rodrigues} ( \texttt{rvec2} ) \cdot \texttt{tvec1} + \texttt{tvec2} \end{array} ,\)
+
+ where \(\mathrm{rodrigues}\) denotes a rotation vector to a rotation matrix transformation, and
+ \(\mathrm{rodrigues}^{-1}\) denotes the inverse transformation. See #Rodrigues for details.
+
+ Also, the functions can compute the derivatives of the output vectors with regards to the input
+ vectors (see #matMulDeriv ). The functions are used inside #stereoCalibrate but can also be used in
+ your own code where Levenberg-Marquardt or another gradient-based solver is used to optimize a
+ function that contains a matrix multiplication.
public static void composeRT(Mat rvec1,
+ Mat tvec1,
+ Mat rvec2,
+ Mat tvec2,
+ Mat rvec3,
+ Mat tvec3,
+ Mat dr3dr1,
+ Mat dr3dt1,
+ Mat dr3dr2,
+ Mat dr3dt2,
+ Mat dt3dr1)
+
Combines two rotation-and-shift transformations.
+
+
Parameters:
+
rvec1 - First rotation vector.
+
tvec1 - First translation vector.
+
rvec2 - Second rotation vector.
+
tvec2 - Second translation vector.
+
rvec3 - Output rotation vector of the superposition.
+
tvec3 - Output translation vector of the superposition.
+
dr3dr1 - Optional output derivative of rvec3 with regard to rvec1
+
dr3dt1 - Optional output derivative of rvec3 with regard to tvec1
+
dr3dr2 - Optional output derivative of rvec3 with regard to rvec2
+
dr3dt2 - Optional output derivative of rvec3 with regard to tvec2
+
dt3dr1 - Optional output derivative of tvec3 with regard to rvec1
+
+ The functions compute:
+
+ \(\begin{array}{l} \texttt{rvec3} = \mathrm{rodrigues} ^{-1} \left ( \mathrm{rodrigues} ( \texttt{rvec2} ) \cdot \mathrm{rodrigues} ( \texttt{rvec1} ) \right ) \\ \texttt{tvec3} = \mathrm{rodrigues} ( \texttt{rvec2} ) \cdot \texttt{tvec1} + \texttt{tvec2} \end{array} ,\)
+
+ where \(\mathrm{rodrigues}\) denotes a rotation vector to a rotation matrix transformation, and
+ \(\mathrm{rodrigues}^{-1}\) denotes the inverse transformation. See #Rodrigues for details.
+
+ Also, the functions can compute the derivatives of the output vectors with regards to the input
+ vectors (see #matMulDeriv ). The functions are used inside #stereoCalibrate but can also be used in
+ your own code where Levenberg-Marquardt or another gradient-based solver is used to optimize a
+ function that contains a matrix multiplication.
public static void composeRT(Mat rvec1,
+ Mat tvec1,
+ Mat rvec2,
+ Mat tvec2,
+ Mat rvec3,
+ Mat tvec3,
+ Mat dr3dr1,
+ Mat dr3dt1,
+ Mat dr3dr2,
+ Mat dr3dt2,
+ Mat dt3dr1,
+ Mat dt3dt1)
+
Combines two rotation-and-shift transformations.
+
+
Parameters:
+
rvec1 - First rotation vector.
+
tvec1 - First translation vector.
+
rvec2 - Second rotation vector.
+
tvec2 - Second translation vector.
+
rvec3 - Output rotation vector of the superposition.
+
tvec3 - Output translation vector of the superposition.
+
dr3dr1 - Optional output derivative of rvec3 with regard to rvec1
+
dr3dt1 - Optional output derivative of rvec3 with regard to tvec1
+
dr3dr2 - Optional output derivative of rvec3 with regard to rvec2
+
dr3dt2 - Optional output derivative of rvec3 with regard to tvec2
+
dt3dr1 - Optional output derivative of tvec3 with regard to rvec1
+
dt3dt1 - Optional output derivative of tvec3 with regard to tvec1
+
+ The functions compute:
+
+ \(\begin{array}{l} \texttt{rvec3} = \mathrm{rodrigues} ^{-1} \left ( \mathrm{rodrigues} ( \texttt{rvec2} ) \cdot \mathrm{rodrigues} ( \texttt{rvec1} ) \right ) \\ \texttt{tvec3} = \mathrm{rodrigues} ( \texttt{rvec2} ) \cdot \texttt{tvec1} + \texttt{tvec2} \end{array} ,\)
+
+ where \(\mathrm{rodrigues}\) denotes a rotation vector to a rotation matrix transformation, and
+ \(\mathrm{rodrigues}^{-1}\) denotes the inverse transformation. See #Rodrigues for details.
+
+ Also, the functions can compute the derivatives of the output vectors with regards to the input
+ vectors (see #matMulDeriv ). The functions are used inside #stereoCalibrate but can also be used in
+ your own code where Levenberg-Marquardt or another gradient-based solver is used to optimize a
+ function that contains a matrix multiplication.
public static void composeRT(Mat rvec1,
+ Mat tvec1,
+ Mat rvec2,
+ Mat tvec2,
+ Mat rvec3,
+ Mat tvec3,
+ Mat dr3dr1,
+ Mat dr3dt1,
+ Mat dr3dr2,
+ Mat dr3dt2,
+ Mat dt3dr1,
+ Mat dt3dt1,
+ Mat dt3dr2)
+
Combines two rotation-and-shift transformations.
+
+
Parameters:
+
rvec1 - First rotation vector.
+
tvec1 - First translation vector.
+
rvec2 - Second rotation vector.
+
tvec2 - Second translation vector.
+
rvec3 - Output rotation vector of the superposition.
+
tvec3 - Output translation vector of the superposition.
+
dr3dr1 - Optional output derivative of rvec3 with regard to rvec1
+
dr3dt1 - Optional output derivative of rvec3 with regard to tvec1
+
dr3dr2 - Optional output derivative of rvec3 with regard to rvec2
+
dr3dt2 - Optional output derivative of rvec3 with regard to tvec2
+
dt3dr1 - Optional output derivative of tvec3 with regard to rvec1
+
dt3dt1 - Optional output derivative of tvec3 with regard to tvec1
+
dt3dr2 - Optional output derivative of tvec3 with regard to rvec2
+
+ The functions compute:
+
+ \(\begin{array}{l} \texttt{rvec3} = \mathrm{rodrigues} ^{-1} \left ( \mathrm{rodrigues} ( \texttt{rvec2} ) \cdot \mathrm{rodrigues} ( \texttt{rvec1} ) \right ) \\ \texttt{tvec3} = \mathrm{rodrigues} ( \texttt{rvec2} ) \cdot \texttt{tvec1} + \texttt{tvec2} \end{array} ,\)
+
+ where \(\mathrm{rodrigues}\) denotes a rotation vector to a rotation matrix transformation, and
+ \(\mathrm{rodrigues}^{-1}\) denotes the inverse transformation. See #Rodrigues for details.
+
+ Also, the functions can compute the derivatives of the output vectors with regards to the input
+ vectors (see #matMulDeriv ). The functions are used inside #stereoCalibrate but can also be used in
+ your own code where Levenberg-Marquardt or another gradient-based solver is used to optimize a
+ function that contains a matrix multiplication.
public static void composeRT(Mat rvec1,
+ Mat tvec1,
+ Mat rvec2,
+ Mat tvec2,
+ Mat rvec3,
+ Mat tvec3,
+ Mat dr3dr1,
+ Mat dr3dt1,
+ Mat dr3dr2,
+ Mat dr3dt2,
+ Mat dt3dr1,
+ Mat dt3dt1,
+ Mat dt3dr2,
+ Mat dt3dt2)
+
Combines two rotation-and-shift transformations.
+
+
Parameters:
+
rvec1 - First rotation vector.
+
tvec1 - First translation vector.
+
rvec2 - Second rotation vector.
+
tvec2 - Second translation vector.
+
rvec3 - Output rotation vector of the superposition.
+
tvec3 - Output translation vector of the superposition.
+
dr3dr1 - Optional output derivative of rvec3 with regard to rvec1
+
dr3dt1 - Optional output derivative of rvec3 with regard to tvec1
+
dr3dr2 - Optional output derivative of rvec3 with regard to rvec2
+
dr3dt2 - Optional output derivative of rvec3 with regard to tvec2
+
dt3dr1 - Optional output derivative of tvec3 with regard to rvec1
+
dt3dt1 - Optional output derivative of tvec3 with regard to tvec1
+
dt3dr2 - Optional output derivative of tvec3 with regard to rvec2
+
dt3dt2 - Optional output derivative of tvec3 with regard to tvec2
+
+ The functions compute:
+
+ \(\begin{array}{l} \texttt{rvec3} = \mathrm{rodrigues} ^{-1} \left ( \mathrm{rodrigues} ( \texttt{rvec2} ) \cdot \mathrm{rodrigues} ( \texttt{rvec1} ) \right ) \\ \texttt{tvec3} = \mathrm{rodrigues} ( \texttt{rvec2} ) \cdot \texttt{tvec1} + \texttt{tvec2} \end{array} ,\)
+
+ where \(\mathrm{rodrigues}\) denotes a rotation vector to a rotation matrix transformation, and
+ \(\mathrm{rodrigues}^{-1}\) denotes the inverse transformation. See #Rodrigues for details.
+
+ Also, the functions can compute the derivatives of the output vectors with regards to the input
+ vectors (see #matMulDeriv ). The functions are used inside #stereoCalibrate but can also be used in
+ your own code where Levenberg-Marquardt or another gradient-based solver is used to optimize a
+ function that contains a matrix multiplication.
public static void computeCorrespondEpilines(Mat points,
+ int whichImage,
+ Mat F,
+ Mat lines)
+
For points in an image of a stereo pair, computes the corresponding epilines in the other image.
+
+
Parameters:
+
points - Input points. \(N \times 1\) or \(1 \times N\) matrix of type CV_32FC2 or
+ vector<Point2f> .
+
whichImage - Index of the image (1 or 2) that contains the points .
+
F - Fundamental matrix that can be estimated using #findFundamentalMat or #stereoRectify .
+
lines - Output vector of the epipolar lines corresponding to the points in the other image.
+ Each line \(ax + by + c=0\) is encoded by 3 numbers \((a, b, c)\) .
+
+ For every point in one of the two images of a stereo pair, the function finds the equation of the
+ corresponding epipolar line in the other image.
+
+ From the fundamental matrix definition (see #findFundamentalMat ), line \(l^{(2)}_i\) in the second
+ image for the point \(p^{(1)}_i\) in the first image (when whichImage=1 ) is computed as:
+
+ \(l^{(2)}_i = F p^{(1)}_i\)
+
+ And vice versa, when whichImage=2, \(l^{(1)}_i\) is computed from \(p^{(2)}_i\) as:
+
+ \(l^{(1)}_i = F^T p^{(2)}_i\)
+
+ Line coefficients are defined up to a scale. They are normalized so that \(a_i^2+b_i^2=1\) .
public static void convertPointsFromHomogeneous(Mat src,
+ Mat dst)
+
Converts points from homogeneous to Euclidean space.
+
+
Parameters:
+
src - Input vector of N-dimensional points.
+
dst - Output vector of N-1-dimensional points.
+
+ The function converts points homogeneous to Euclidean space using perspective projection. That is,
+ each point (x1, x2, ... x(n-1), xn) is converted to (x1/xn, x2/xn, ..., x(n-1)/xn). When xn=0, the
+ output point coordinates will be (0,0,0,...).
public static void convertPointsToHomogeneous(Mat src,
+ Mat dst)
+
Converts points from Euclidean to homogeneous space.
+
+
Parameters:
+
src - Input vector of N-dimensional points.
+
dst - Output vector of N+1-dimensional points.
+
+ The function converts points from Euclidean to homogeneous space by appending 1's to the tuple of
+ point coordinates. That is, each point (x1, x2, ..., xn) is converted to (x1, x2, ..., xn, 1).
public static void correctMatches(Mat F,
+ Mat points1,
+ Mat points2,
+ Mat newPoints1,
+ Mat newPoints2)
+
Refines coordinates of corresponding points.
+
+
Parameters:
+
F - 3x3 fundamental matrix.
+
points1 - 1xN array containing the first set of points.
+
points2 - 1xN array containing the second set of points.
+
newPoints1 - The optimized points1.
+
newPoints2 - The optimized points2.
+
+ The function implements the Optimal Triangulation Method (see Multiple View Geometry CITE: HartleyZ00 for details).
+ For each given point correspondence points1[i] <-> points2[i], and a fundamental matrix F, it
+ computes the corrected correspondences newPoints1[i] <-> newPoints2[i] that minimize the geometric
+ error \(d(points1[i], newPoints1[i])^2 + d(points2[i],newPoints2[i])^2\) (where \(d(a,b)\) is the
+ geometric distance between points \(a\) and \(b\) ) subject to the epipolar constraint
+ \(newPoints2^T \cdot F \cdot newPoints1 = 0\) .
public static void decomposeEssentialMat(Mat E,
+ Mat R1,
+ Mat R2,
+ Mat t)
+
Decompose an essential matrix to possible rotations and translation.
+
+
Parameters:
+
E - The input essential matrix.
+
R1 - One possible rotation matrix.
+
R2 - Another possible rotation matrix.
+
t - One possible translation.
+
+ This function decomposes the essential matrix E using svd decomposition CITE: HartleyZ00. In
+ general, four possible poses exist for the decomposition of E. They are \([R_1, t]\),
+ \([R_1, -t]\), \([R_2, t]\), \([R_2, -t]\).
+
+ If E gives the epipolar constraint \([p_2; 1]^T A^{-T} E A^{-1} [p_1; 1] = 0\) between the image
+ points \(p_1\) in the first image and \(p_2\) in second image, then any of the tuples
+ \([R_1, t]\), \([R_1, -t]\), \([R_2, t]\), \([R_2, -t]\) is a change of basis from the first
+ camera's coordinate system to the second camera's coordinate system. However, by decomposing E, one
+ can only get the direction of the translation. For this reason, the translation t is returned with
+ unit length.
public static int decomposeHomographyMat(Mat H,
+ Mat K,
+ java.util.List<Mat> rotations,
+ java.util.List<Mat> translations,
+ java.util.List<Mat> normals)
+
Decompose a homography matrix to rotation(s), translation(s) and plane normal(s).
+
+
Parameters:
+
H - The input homography matrix between two images.
+
K - The input camera intrinsic matrix.
+
rotations - Array of rotation matrices.
+
translations - Array of translation matrices.
+
normals - Array of plane normal matrices.
+
+ This function extracts relative camera motion between two views of a planar object and returns up to
+ four mathematical solution tuples of rotation, translation, and plane normal. The decomposition of
+ the homography matrix H is described in detail in CITE: Malis2007.
+
+ If the homography H, induced by the plane, gives the constraint
+ \(s_i \vecthree{x'_i}{y'_i}{1} \sim H \vecthree{x_i}{y_i}{1}\) on the source image points
+ \(p_i\) and the destination image points \(p'_i\), then the tuple of rotations[k] and
+ translations[k] is a change of basis from the source camera's coordinate system to the destination
+ camera's coordinate system. However, by decomposing H, one can only get the translation normalized
+ by the (typically unknown) depth of the scene, i.e. its direction but with normalized length.
+
+ If point correspondences are available, at least two solutions may further be invalidated, by
+ applying positive depth constraint, i.e. all points must be in front of the camera.
public static void decomposeProjectionMatrix(Mat projMatrix,
+ Mat cameraMatrix,
+ Mat rotMatrix,
+ Mat transVect)
+
Decomposes a projection matrix into a rotation matrix and a camera intrinsic matrix.
+
+
Parameters:
+
projMatrix - 3x4 input projection matrix P.
+
cameraMatrix - Output 3x3 camera intrinsic matrix \(\cameramatrix{A}\).
+
rotMatrix - Output 3x3 external rotation matrix R.
+
transVect - Output 4x1 translation vector T.
+ degrees.
+
+ The function computes a decomposition of a projection matrix into a calibration and a rotation
+ matrix and the position of a camera.
+
+ It optionally returns three rotation matrices, one for each axis, and three Euler angles that could
+ be used in OpenGL. Note, there is always more than one sequence of rotations about the three
+ principal axes that results in the same orientation of an object, e.g. see CITE: Slabaugh . Returned
+ tree rotation matrices and corresponding three Euler angles are only one of the possible solutions.
+
+ The function is based on #RQDecomp3x3 .
public static void decomposeProjectionMatrix(Mat projMatrix,
+ Mat cameraMatrix,
+ Mat rotMatrix,
+ Mat transVect,
+ Mat rotMatrixX)
+
Decomposes a projection matrix into a rotation matrix and a camera intrinsic matrix.
+
+
Parameters:
+
projMatrix - 3x4 input projection matrix P.
+
cameraMatrix - Output 3x3 camera intrinsic matrix \(\cameramatrix{A}\).
+
rotMatrix - Output 3x3 external rotation matrix R.
+
transVect - Output 4x1 translation vector T.
+
rotMatrixX - Optional 3x3 rotation matrix around x-axis.
+ degrees.
+
+ The function computes a decomposition of a projection matrix into a calibration and a rotation
+ matrix and the position of a camera.
+
+ It optionally returns three rotation matrices, one for each axis, and three Euler angles that could
+ be used in OpenGL. Note, there is always more than one sequence of rotations about the three
+ principal axes that results in the same orientation of an object, e.g. see CITE: Slabaugh . Returned
+ tree rotation matrices and corresponding three Euler angles are only one of the possible solutions.
+
+ The function is based on #RQDecomp3x3 .
public static void decomposeProjectionMatrix(Mat projMatrix,
+ Mat cameraMatrix,
+ Mat rotMatrix,
+ Mat transVect,
+ Mat rotMatrixX,
+ Mat rotMatrixY)
+
Decomposes a projection matrix into a rotation matrix and a camera intrinsic matrix.
+
+
Parameters:
+
projMatrix - 3x4 input projection matrix P.
+
cameraMatrix - Output 3x3 camera intrinsic matrix \(\cameramatrix{A}\).
+
rotMatrix - Output 3x3 external rotation matrix R.
+
transVect - Output 4x1 translation vector T.
+
rotMatrixX - Optional 3x3 rotation matrix around x-axis.
+
rotMatrixY - Optional 3x3 rotation matrix around y-axis.
+ degrees.
+
+ The function computes a decomposition of a projection matrix into a calibration and a rotation
+ matrix and the position of a camera.
+
+ It optionally returns three rotation matrices, one for each axis, and three Euler angles that could
+ be used in OpenGL. Note, there is always more than one sequence of rotations about the three
+ principal axes that results in the same orientation of an object, e.g. see CITE: Slabaugh . Returned
+ tree rotation matrices and corresponding three Euler angles are only one of the possible solutions.
+
+ The function is based on #RQDecomp3x3 .
public static void decomposeProjectionMatrix(Mat projMatrix,
+ Mat cameraMatrix,
+ Mat rotMatrix,
+ Mat transVect,
+ Mat rotMatrixX,
+ Mat rotMatrixY,
+ Mat rotMatrixZ)
+
Decomposes a projection matrix into a rotation matrix and a camera intrinsic matrix.
+
+
Parameters:
+
projMatrix - 3x4 input projection matrix P.
+
cameraMatrix - Output 3x3 camera intrinsic matrix \(\cameramatrix{A}\).
+
rotMatrix - Output 3x3 external rotation matrix R.
+
transVect - Output 4x1 translation vector T.
+
rotMatrixX - Optional 3x3 rotation matrix around x-axis.
+
rotMatrixY - Optional 3x3 rotation matrix around y-axis.
+
rotMatrixZ - Optional 3x3 rotation matrix around z-axis.
+ degrees.
+
+ The function computes a decomposition of a projection matrix into a calibration and a rotation
+ matrix and the position of a camera.
+
+ It optionally returns three rotation matrices, one for each axis, and three Euler angles that could
+ be used in OpenGL. Note, there is always more than one sequence of rotations about the three
+ principal axes that results in the same orientation of an object, e.g. see CITE: Slabaugh . Returned
+ tree rotation matrices and corresponding three Euler angles are only one of the possible solutions.
+
+ The function is based on #RQDecomp3x3 .
public static void decomposeProjectionMatrix(Mat projMatrix,
+ Mat cameraMatrix,
+ Mat rotMatrix,
+ Mat transVect,
+ Mat rotMatrixX,
+ Mat rotMatrixY,
+ Mat rotMatrixZ,
+ Mat eulerAngles)
+
Decomposes a projection matrix into a rotation matrix and a camera intrinsic matrix.
+
+
Parameters:
+
projMatrix - 3x4 input projection matrix P.
+
cameraMatrix - Output 3x3 camera intrinsic matrix \(\cameramatrix{A}\).
+
rotMatrix - Output 3x3 external rotation matrix R.
+
transVect - Output 4x1 translation vector T.
+
rotMatrixX - Optional 3x3 rotation matrix around x-axis.
+
rotMatrixY - Optional 3x3 rotation matrix around y-axis.
+
rotMatrixZ - Optional 3x3 rotation matrix around z-axis.
+
eulerAngles - Optional three-element vector containing three Euler angles of rotation in
+ degrees.
+
+ The function computes a decomposition of a projection matrix into a calibration and a rotation
+ matrix and the position of a camera.
+
+ It optionally returns three rotation matrices, one for each axis, and three Euler angles that could
+ be used in OpenGL. Note, there is always more than one sequence of rotations about the three
+ principal axes that results in the same orientation of an object, e.g. see CITE: Slabaugh . Returned
+ tree rotation matrices and corresponding three Euler angles are only one of the possible solutions.
+
+ The function is based on #RQDecomp3x3 .
image - Destination image. It must be an 8-bit color image.
+
patternSize - Number of inner corners per a chessboard row and column
+ (patternSize = cv::Size(points_per_row,points_per_column)).
+
corners - Array of detected corners, the output of #findChessboardCorners.
+
patternWasFound - Parameter indicating whether the complete board was found or not. The
+ return value of #findChessboardCorners should be passed here.
+
+ The function draws individual chessboard corners detected either as red circles if the board was not
+ found, or as colored corners connected with lines if the board was found.
public static void drawFrameAxes(Mat image,
+ Mat cameraMatrix,
+ Mat distCoeffs,
+ Mat rvec,
+ Mat tvec,
+ float length)
+
Draw axes of the world/object coordinate system from pose estimation. SEE: solvePnP
+
+
Parameters:
+
image - Input/output image. It must have 1 or 3 channels. The number of channels is not altered.
+
cameraMatrix - Input 3x3 floating-point matrix of camera intrinsic parameters.
+ \(\cameramatrix{A}\)
+
distCoeffs - Input vector of distortion coefficients
+ \(\distcoeffs\). If the vector is empty, the zero distortion coefficients are assumed.
+
rvec - Rotation vector (see REF: Rodrigues ) that, together with tvec, brings points from
+ the model coordinate system to the camera coordinate system.
+
tvec - Translation vector.
+
length - Length of the painted axes in the same unit than tvec (usually in meters).
+
+ This function draws the axes of the world/object coordinate system w.r.t. to the camera frame.
+ OX is drawn in red, OY in green and OZ in blue.
public static void drawFrameAxes(Mat image,
+ Mat cameraMatrix,
+ Mat distCoeffs,
+ Mat rvec,
+ Mat tvec,
+ float length,
+ int thickness)
+
Draw axes of the world/object coordinate system from pose estimation. SEE: solvePnP
+
+
Parameters:
+
image - Input/output image. It must have 1 or 3 channels. The number of channels is not altered.
+
cameraMatrix - Input 3x3 floating-point matrix of camera intrinsic parameters.
+ \(\cameramatrix{A}\)
+
distCoeffs - Input vector of distortion coefficients
+ \(\distcoeffs\). If the vector is empty, the zero distortion coefficients are assumed.
+
rvec - Rotation vector (see REF: Rodrigues ) that, together with tvec, brings points from
+ the model coordinate system to the camera coordinate system.
+
tvec - Translation vector.
+
length - Length of the painted axes in the same unit than tvec (usually in meters).
+
thickness - Line thickness of the painted axes.
+
+ This function draws the axes of the world/object coordinate system w.r.t. to the camera frame.
+ OX is drawn in red, OY in green and OZ in blue.
from - First input 2D point set containing \((X,Y)\).
+
to - Second input 2D point set containing \((x,y)\).
+
+
+ REF: RANSAC - RANSAC-based robust method
+
+
+ REF: LMEDS - Least-Median robust method
+ RANSAC is the default method.
+
+
+ a point as an inlier. Applies only to RANSAC.
+ between 0.95 and 0.99 is usually good enough. Values too close to 1 can slow down the estimation
+ significantly. Values lower than 0.8-0.9 can result in an incorrectly estimated transformation.
+ Passing 0 will disable refining, so the output matrix will be output of robust method.
+
Returns:
+
Output 2D affine transformation matrix \(2 \times 3\) or empty matrix if transformation
+ could not be estimated. The returned matrix has the following form:
+ \(
+ \begin{bmatrix}
+ a_{11} & a_{12} & b_1\\
+ a_{21} & a_{22} & b_2\\
+ \end{bmatrix}
+ \)
+
+ The function estimates an optimal 2D affine transformation between two 2D point sets using the
+ selected robust algorithm.
+
+ The computed transformation is then refined further (using only inliers) with the
+ Levenberg-Marquardt method to reduce the re-projection error even more.
+
+ Note:
+ The RANSAC method can handle practically any ratio of outliers but needs a threshold to
+ distinguish inliers from outliers. The method LMeDS does not need any threshold but it works
+ correctly only when there are more than 50% of inliers.
+
+ SEE: estimateAffinePartial2D, getAffineTransform
from - First input 2D point set containing \((X,Y)\).
+
to - Second input 2D point set containing \((x,y)\).
+
inliers - Output vector indicating which points are inliers (1-inlier, 0-outlier).
+
+
+ REF: RANSAC - RANSAC-based robust method
+
+
+ REF: LMEDS - Least-Median robust method
+ RANSAC is the default method.
+
+
+ a point as an inlier. Applies only to RANSAC.
+ between 0.95 and 0.99 is usually good enough. Values too close to 1 can slow down the estimation
+ significantly. Values lower than 0.8-0.9 can result in an incorrectly estimated transformation.
+ Passing 0 will disable refining, so the output matrix will be output of robust method.
+
Returns:
+
Output 2D affine transformation matrix \(2 \times 3\) or empty matrix if transformation
+ could not be estimated. The returned matrix has the following form:
+ \(
+ \begin{bmatrix}
+ a_{11} & a_{12} & b_1\\
+ a_{21} & a_{22} & b_2\\
+ \end{bmatrix}
+ \)
+
+ The function estimates an optimal 2D affine transformation between two 2D point sets using the
+ selected robust algorithm.
+
+ The computed transformation is then refined further (using only inliers) with the
+ Levenberg-Marquardt method to reduce the re-projection error even more.
+
+ Note:
+ The RANSAC method can handle practically any ratio of outliers but needs a threshold to
+ distinguish inliers from outliers. The method LMeDS does not need any threshold but it works
+ correctly only when there are more than 50% of inliers.
+
+ SEE: estimateAffinePartial2D, getAffineTransform
from - First input 2D point set containing \((X,Y)\).
+
to - Second input 2D point set containing \((x,y)\).
+
inliers - Output vector indicating which points are inliers (1-inlier, 0-outlier).
+
method - Robust method used to compute transformation. The following methods are possible:
+
+
+ REF: RANSAC - RANSAC-based robust method
+
+
+ REF: LMEDS - Least-Median robust method
+ RANSAC is the default method.
+
+
+ a point as an inlier. Applies only to RANSAC.
+ between 0.95 and 0.99 is usually good enough. Values too close to 1 can slow down the estimation
+ significantly. Values lower than 0.8-0.9 can result in an incorrectly estimated transformation.
+ Passing 0 will disable refining, so the output matrix will be output of robust method.
+
Returns:
+
Output 2D affine transformation matrix \(2 \times 3\) or empty matrix if transformation
+ could not be estimated. The returned matrix has the following form:
+ \(
+ \begin{bmatrix}
+ a_{11} & a_{12} & b_1\\
+ a_{21} & a_{22} & b_2\\
+ \end{bmatrix}
+ \)
+
+ The function estimates an optimal 2D affine transformation between two 2D point sets using the
+ selected robust algorithm.
+
+ The computed transformation is then refined further (using only inliers) with the
+ Levenberg-Marquardt method to reduce the re-projection error even more.
+
+ Note:
+ The RANSAC method can handle practically any ratio of outliers but needs a threshold to
+ distinguish inliers from outliers. The method LMeDS does not need any threshold but it works
+ correctly only when there are more than 50% of inliers.
+
+ SEE: estimateAffinePartial2D, getAffineTransform
from - First input 2D point set containing \((X,Y)\).
+
to - Second input 2D point set containing \((x,y)\).
+
inliers - Output vector indicating which points are inliers (1-inlier, 0-outlier).
+
method - Robust method used to compute transformation. The following methods are possible:
+
+
+ REF: RANSAC - RANSAC-based robust method
+
+
+ REF: LMEDS - Least-Median robust method
+ RANSAC is the default method.
+
+
+
ransacReprojThreshold - Maximum reprojection error in the RANSAC algorithm to consider
+ a point as an inlier. Applies only to RANSAC.
+ between 0.95 and 0.99 is usually good enough. Values too close to 1 can slow down the estimation
+ significantly. Values lower than 0.8-0.9 can result in an incorrectly estimated transformation.
+ Passing 0 will disable refining, so the output matrix will be output of robust method.
+
Returns:
+
Output 2D affine transformation matrix \(2 \times 3\) or empty matrix if transformation
+ could not be estimated. The returned matrix has the following form:
+ \(
+ \begin{bmatrix}
+ a_{11} & a_{12} & b_1\\
+ a_{21} & a_{22} & b_2\\
+ \end{bmatrix}
+ \)
+
+ The function estimates an optimal 2D affine transformation between two 2D point sets using the
+ selected robust algorithm.
+
+ The computed transformation is then refined further (using only inliers) with the
+ Levenberg-Marquardt method to reduce the re-projection error even more.
+
+ Note:
+ The RANSAC method can handle practically any ratio of outliers but needs a threshold to
+ distinguish inliers from outliers. The method LMeDS does not need any threshold but it works
+ correctly only when there are more than 50% of inliers.
+
+ SEE: estimateAffinePartial2D, getAffineTransform
from - First input 2D point set containing \((X,Y)\).
+
to - Second input 2D point set containing \((x,y)\).
+
inliers - Output vector indicating which points are inliers (1-inlier, 0-outlier).
+
method - Robust method used to compute transformation. The following methods are possible:
+
+
+ REF: RANSAC - RANSAC-based robust method
+
+
+ REF: LMEDS - Least-Median robust method
+ RANSAC is the default method.
+
+
+
ransacReprojThreshold - Maximum reprojection error in the RANSAC algorithm to consider
+ a point as an inlier. Applies only to RANSAC.
+
maxIters - The maximum number of robust method iterations.
+ between 0.95 and 0.99 is usually good enough. Values too close to 1 can slow down the estimation
+ significantly. Values lower than 0.8-0.9 can result in an incorrectly estimated transformation.
+ Passing 0 will disable refining, so the output matrix will be output of robust method.
+
Returns:
+
Output 2D affine transformation matrix \(2 \times 3\) or empty matrix if transformation
+ could not be estimated. The returned matrix has the following form:
+ \(
+ \begin{bmatrix}
+ a_{11} & a_{12} & b_1\\
+ a_{21} & a_{22} & b_2\\
+ \end{bmatrix}
+ \)
+
+ The function estimates an optimal 2D affine transformation between two 2D point sets using the
+ selected robust algorithm.
+
+ The computed transformation is then refined further (using only inliers) with the
+ Levenberg-Marquardt method to reduce the re-projection error even more.
+
+ Note:
+ The RANSAC method can handle practically any ratio of outliers but needs a threshold to
+ distinguish inliers from outliers. The method LMeDS does not need any threshold but it works
+ correctly only when there are more than 50% of inliers.
+
+ SEE: estimateAffinePartial2D, getAffineTransform
public static Mat estimateAffine2D(Mat from,
+ Mat to,
+ Mat inliers,
+ int method,
+ double ransacReprojThreshold,
+ long maxIters,
+ double confidence)
from - First input 2D point set containing \((X,Y)\).
+
to - Second input 2D point set containing \((x,y)\).
+
inliers - Output vector indicating which points are inliers (1-inlier, 0-outlier).
+
method - Robust method used to compute transformation. The following methods are possible:
+
+
+ REF: RANSAC - RANSAC-based robust method
+
+
+ REF: LMEDS - Least-Median robust method
+ RANSAC is the default method.
+
+
+
ransacReprojThreshold - Maximum reprojection error in the RANSAC algorithm to consider
+ a point as an inlier. Applies only to RANSAC.
+
maxIters - The maximum number of robust method iterations.
+
confidence - Confidence level, between 0 and 1, for the estimated transformation. Anything
+ between 0.95 and 0.99 is usually good enough. Values too close to 1 can slow down the estimation
+ significantly. Values lower than 0.8-0.9 can result in an incorrectly estimated transformation.
+ Passing 0 will disable refining, so the output matrix will be output of robust method.
+
Returns:
+
Output 2D affine transformation matrix \(2 \times 3\) or empty matrix if transformation
+ could not be estimated. The returned matrix has the following form:
+ \(
+ \begin{bmatrix}
+ a_{11} & a_{12} & b_1\\
+ a_{21} & a_{22} & b_2\\
+ \end{bmatrix}
+ \)
+
+ The function estimates an optimal 2D affine transformation between two 2D point sets using the
+ selected robust algorithm.
+
+ The computed transformation is then refined further (using only inliers) with the
+ Levenberg-Marquardt method to reduce the re-projection error even more.
+
+ Note:
+ The RANSAC method can handle practically any ratio of outliers but needs a threshold to
+ distinguish inliers from outliers. The method LMeDS does not need any threshold but it works
+ correctly only when there are more than 50% of inliers.
+
+ SEE: estimateAffinePartial2D, getAffineTransform
public static Mat estimateAffine2D(Mat from,
+ Mat to,
+ Mat inliers,
+ int method,
+ double ransacReprojThreshold,
+ long maxIters,
+ double confidence,
+ long refineIters)
from - First input 2D point set containing \((X,Y)\).
+
to - Second input 2D point set containing \((x,y)\).
+
inliers - Output vector indicating which points are inliers (1-inlier, 0-outlier).
+
method - Robust method used to compute transformation. The following methods are possible:
+
+
+ REF: RANSAC - RANSAC-based robust method
+
+
+ REF: LMEDS - Least-Median robust method
+ RANSAC is the default method.
+
+
+
ransacReprojThreshold - Maximum reprojection error in the RANSAC algorithm to consider
+ a point as an inlier. Applies only to RANSAC.
+
maxIters - The maximum number of robust method iterations.
+
confidence - Confidence level, between 0 and 1, for the estimated transformation. Anything
+ between 0.95 and 0.99 is usually good enough. Values too close to 1 can slow down the estimation
+ significantly. Values lower than 0.8-0.9 can result in an incorrectly estimated transformation.
+
refineIters - Maximum number of iterations of refining algorithm (Levenberg-Marquardt).
+ Passing 0 will disable refining, so the output matrix will be output of robust method.
+
Returns:
+
Output 2D affine transformation matrix \(2 \times 3\) or empty matrix if transformation
+ could not be estimated. The returned matrix has the following form:
+ \(
+ \begin{bmatrix}
+ a_{11} & a_{12} & b_1\\
+ a_{21} & a_{22} & b_2\\
+ \end{bmatrix}
+ \)
+
+ The function estimates an optimal 2D affine transformation between two 2D point sets using the
+ selected robust algorithm.
+
+ The computed transformation is then refined further (using only inliers) with the
+ Levenberg-Marquardt method to reduce the re-projection error even more.
+
+ Note:
+ The RANSAC method can handle practically any ratio of outliers but needs a threshold to
+ distinguish inliers from outliers. The method LMeDS does not need any threshold but it works
+ correctly only when there are more than 50% of inliers.
+
+ SEE: estimateAffinePartial2D, getAffineTransform
public static Mat estimateAffine3D(Mat src,
+ Mat dst)
+
Computes an optimal affine transformation between two 3D point sets.
+
+ It computes \(R,s,t\) minimizing \(\sum{i} dst_i - c \cdot R \cdot src_i \)
+ where \(R\) is a 3x3 rotation matrix, \(t\) is a 3x1 translation vector and \(s\) is a
+ scalar size value. This is an implementation of the algorithm by Umeyama \cite umeyama1991least .
+ The estimated affine transform has a homogeneous scale which is a subclass of affine
+ transformations with 7 degrees of freedom. The paired point sets need to comprise at least 3
+ points each.
+
+
Parameters:
+
src - First input 3D point set.
+
dst - Second input 3D point set.
+ Else the pointed-to variable will be set to the optimal scale.
+ This might be unwanted, e.g. when optimizing a transform between a right- and a
+ left-handed coordinate system.
+
Returns:
+
3D affine transformation matrix \(3 \times 4\) of the form
+ \(T =
+ \begin{bmatrix}
+ R & t\\
+ \end{bmatrix}
+ \)
public static Mat estimateAffine3D(Mat src,
+ Mat dst,
+ double[] scale)
+
Computes an optimal affine transformation between two 3D point sets.
+
+ It computes \(R,s,t\) minimizing \(\sum{i} dst_i - c \cdot R \cdot src_i \)
+ where \(R\) is a 3x3 rotation matrix, \(t\) is a 3x1 translation vector and \(s\) is a
+ scalar size value. This is an implementation of the algorithm by Umeyama \cite umeyama1991least .
+ The estimated affine transform has a homogeneous scale which is a subclass of affine
+ transformations with 7 degrees of freedom. The paired point sets need to comprise at least 3
+ points each.
+
+
Parameters:
+
src - First input 3D point set.
+
dst - Second input 3D point set.
+
scale - If null is passed, the scale parameter c will be assumed to be 1.0.
+ Else the pointed-to variable will be set to the optimal scale.
+ This might be unwanted, e.g. when optimizing a transform between a right- and a
+ left-handed coordinate system.
+
Returns:
+
3D affine transformation matrix \(3 \times 4\) of the form
+ \(T =
+ \begin{bmatrix}
+ R & t\\
+ \end{bmatrix}
+ \)
public static Mat estimateAffine3D(Mat src,
+ Mat dst,
+ double[] scale,
+ boolean force_rotation)
+
Computes an optimal affine transformation between two 3D point sets.
+
+ It computes \(R,s,t\) minimizing \(\sum{i} dst_i - c \cdot R \cdot src_i \)
+ where \(R\) is a 3x3 rotation matrix, \(t\) is a 3x1 translation vector and \(s\) is a
+ scalar size value. This is an implementation of the algorithm by Umeyama \cite umeyama1991least .
+ The estimated affine transform has a homogeneous scale which is a subclass of affine
+ transformations with 7 degrees of freedom. The paired point sets need to comprise at least 3
+ points each.
+
+
Parameters:
+
src - First input 3D point set.
+
dst - Second input 3D point set.
+
scale - If null is passed, the scale parameter c will be assumed to be 1.0.
+ Else the pointed-to variable will be set to the optimal scale.
+
force_rotation - If true, the returned rotation will never be a reflection.
+ This might be unwanted, e.g. when optimizing a transform between a right- and a
+ left-handed coordinate system.
+
Returns:
+
3D affine transformation matrix \(3 \times 4\) of the form
+ \(T =
+ \begin{bmatrix}
+ R & t\\
+ \end{bmatrix}
+ \)
src - First input 3D point set containing \((X,Y,Z)\).
+
dst - Second input 3D point set containing \((x,y,z)\).
+
out - Output 3D affine transformation matrix \(3 \times 4\) of the form
+ \(
+ \begin{bmatrix}
+ a_{11} & a_{12} & a_{13} & b_1\\
+ a_{21} & a_{22} & a_{23} & b_2\\
+ a_{31} & a_{32} & a_{33} & b_3\\
+ \end{bmatrix}
+ \)
+
inliers - Output vector indicating which points are inliers (1-inlier, 0-outlier).
+ an inlier.
+ between 0.95 and 0.99 is usually good enough. Values too close to 1 can slow down the estimation
+ significantly. Values lower than 0.8-0.9 can result in an incorrectly estimated transformation.
+
+ The function estimates an optimal 3D affine transformation between two 3D point sets using the
+ RANSAC algorithm.
src - First input 3D point set containing \((X,Y,Z)\).
+
dst - Second input 3D point set containing \((x,y,z)\).
+
out - Output 3D affine transformation matrix \(3 \times 4\) of the form
+ \(
+ \begin{bmatrix}
+ a_{11} & a_{12} & a_{13} & b_1\\
+ a_{21} & a_{22} & a_{23} & b_2\\
+ a_{31} & a_{32} & a_{33} & b_3\\
+ \end{bmatrix}
+ \)
+
inliers - Output vector indicating which points are inliers (1-inlier, 0-outlier).
+
ransacThreshold - Maximum reprojection error in the RANSAC algorithm to consider a point as
+ an inlier.
+ between 0.95 and 0.99 is usually good enough. Values too close to 1 can slow down the estimation
+ significantly. Values lower than 0.8-0.9 can result in an incorrectly estimated transformation.
+
+ The function estimates an optimal 3D affine transformation between two 3D point sets using the
+ RANSAC algorithm.
src - First input 3D point set containing \((X,Y,Z)\).
+
dst - Second input 3D point set containing \((x,y,z)\).
+
out - Output 3D affine transformation matrix \(3 \times 4\) of the form
+ \(
+ \begin{bmatrix}
+ a_{11} & a_{12} & a_{13} & b_1\\
+ a_{21} & a_{22} & a_{23} & b_2\\
+ a_{31} & a_{32} & a_{33} & b_3\\
+ \end{bmatrix}
+ \)
+
inliers - Output vector indicating which points are inliers (1-inlier, 0-outlier).
+
ransacThreshold - Maximum reprojection error in the RANSAC algorithm to consider a point as
+ an inlier.
+
confidence - Confidence level, between 0 and 1, for the estimated transformation. Anything
+ between 0.95 and 0.99 is usually good enough. Values too close to 1 can slow down the estimation
+ significantly. Values lower than 0.8-0.9 can result in an incorrectly estimated transformation.
+
+ The function estimates an optimal 3D affine transformation between two 3D point sets using the
+ RANSAC algorithm.
public static Mat estimateAffinePartial2D(Mat from,
+ Mat to)
+
Computes an optimal limited affine transformation with 4 degrees of freedom between
+ two 2D point sets.
+
+
Parameters:
+
from - First input 2D point set.
+
to - Second input 2D point set.
+
+
+ REF: RANSAC - RANSAC-based robust method
+
+
+ REF: LMEDS - Least-Median robust method
+ RANSAC is the default method.
+
+
+ a point as an inlier. Applies only to RANSAC.
+ between 0.95 and 0.99 is usually good enough. Values too close to 1 can slow down the estimation
+ significantly. Values lower than 0.8-0.9 can result in an incorrectly estimated transformation.
+ Passing 0 will disable refining, so the output matrix will be output of robust method.
+
Returns:
+
Output 2D affine transformation (4 degrees of freedom) matrix \(2 \times 3\) or
+ empty matrix if transformation could not be estimated.
+
+ The function estimates an optimal 2D affine transformation with 4 degrees of freedom limited to
+ combinations of translation, rotation, and uniform scaling. Uses the selected algorithm for robust
+ estimation.
+
+ The computed transformation is then refined further (using only inliers) with the
+ Levenberg-Marquardt method to reduce the re-projection error even more.
+
+ Estimated transformation matrix is:
+ \( \begin{bmatrix} \cos(\theta) \cdot s & -\sin(\theta) \cdot s & t_x \\
+ \sin(\theta) \cdot s & \cos(\theta) \cdot s & t_y
+ \end{bmatrix} \)
+ Where \( \theta \) is the rotation angle, \( s \) the scaling factor and \( t_x, t_y \) are
+ translations in \( x, y \) axes respectively.
+
+ Note:
+ The RANSAC method can handle practically any ratio of outliers but need a threshold to
+ distinguish inliers from outliers. The method LMeDS does not need any threshold but it works
+ correctly only when there are more than 50% of inliers.
+
+ SEE: estimateAffine2D, getAffineTransform
public static Mat estimateAffinePartial2D(Mat from,
+ Mat to,
+ Mat inliers)
+
Computes an optimal limited affine transformation with 4 degrees of freedom between
+ two 2D point sets.
+
+
Parameters:
+
from - First input 2D point set.
+
to - Second input 2D point set.
+
inliers - Output vector indicating which points are inliers.
+
+
+ REF: RANSAC - RANSAC-based robust method
+
+
+ REF: LMEDS - Least-Median robust method
+ RANSAC is the default method.
+
+
+ a point as an inlier. Applies only to RANSAC.
+ between 0.95 and 0.99 is usually good enough. Values too close to 1 can slow down the estimation
+ significantly. Values lower than 0.8-0.9 can result in an incorrectly estimated transformation.
+ Passing 0 will disable refining, so the output matrix will be output of robust method.
+
Returns:
+
Output 2D affine transformation (4 degrees of freedom) matrix \(2 \times 3\) or
+ empty matrix if transformation could not be estimated.
+
+ The function estimates an optimal 2D affine transformation with 4 degrees of freedom limited to
+ combinations of translation, rotation, and uniform scaling. Uses the selected algorithm for robust
+ estimation.
+
+ The computed transformation is then refined further (using only inliers) with the
+ Levenberg-Marquardt method to reduce the re-projection error even more.
+
+ Estimated transformation matrix is:
+ \( \begin{bmatrix} \cos(\theta) \cdot s & -\sin(\theta) \cdot s & t_x \\
+ \sin(\theta) \cdot s & \cos(\theta) \cdot s & t_y
+ \end{bmatrix} \)
+ Where \( \theta \) is the rotation angle, \( s \) the scaling factor and \( t_x, t_y \) are
+ translations in \( x, y \) axes respectively.
+
+ Note:
+ The RANSAC method can handle practically any ratio of outliers but need a threshold to
+ distinguish inliers from outliers. The method LMeDS does not need any threshold but it works
+ correctly only when there are more than 50% of inliers.
+
+ SEE: estimateAffine2D, getAffineTransform
public static Mat estimateAffinePartial2D(Mat from,
+ Mat to,
+ Mat inliers,
+ int method)
+
Computes an optimal limited affine transformation with 4 degrees of freedom between
+ two 2D point sets.
+
+
Parameters:
+
from - First input 2D point set.
+
to - Second input 2D point set.
+
inliers - Output vector indicating which points are inliers.
+
method - Robust method used to compute transformation. The following methods are possible:
+
+
+ REF: RANSAC - RANSAC-based robust method
+
+
+ REF: LMEDS - Least-Median robust method
+ RANSAC is the default method.
+
+
+ a point as an inlier. Applies only to RANSAC.
+ between 0.95 and 0.99 is usually good enough. Values too close to 1 can slow down the estimation
+ significantly. Values lower than 0.8-0.9 can result in an incorrectly estimated transformation.
+ Passing 0 will disable refining, so the output matrix will be output of robust method.
+
Returns:
+
Output 2D affine transformation (4 degrees of freedom) matrix \(2 \times 3\) or
+ empty matrix if transformation could not be estimated.
+
+ The function estimates an optimal 2D affine transformation with 4 degrees of freedom limited to
+ combinations of translation, rotation, and uniform scaling. Uses the selected algorithm for robust
+ estimation.
+
+ The computed transformation is then refined further (using only inliers) with the
+ Levenberg-Marquardt method to reduce the re-projection error even more.
+
+ Estimated transformation matrix is:
+ \( \begin{bmatrix} \cos(\theta) \cdot s & -\sin(\theta) \cdot s & t_x \\
+ \sin(\theta) \cdot s & \cos(\theta) \cdot s & t_y
+ \end{bmatrix} \)
+ Where \( \theta \) is the rotation angle, \( s \) the scaling factor and \( t_x, t_y \) are
+ translations in \( x, y \) axes respectively.
+
+ Note:
+ The RANSAC method can handle practically any ratio of outliers but need a threshold to
+ distinguish inliers from outliers. The method LMeDS does not need any threshold but it works
+ correctly only when there are more than 50% of inliers.
+
+ SEE: estimateAffine2D, getAffineTransform
public static Mat estimateAffinePartial2D(Mat from,
+ Mat to,
+ Mat inliers,
+ int method,
+ double ransacReprojThreshold)
+
Computes an optimal limited affine transformation with 4 degrees of freedom between
+ two 2D point sets.
+
+
Parameters:
+
from - First input 2D point set.
+
to - Second input 2D point set.
+
inliers - Output vector indicating which points are inliers.
+
method - Robust method used to compute transformation. The following methods are possible:
+
+
+ REF: RANSAC - RANSAC-based robust method
+
+
+ REF: LMEDS - Least-Median robust method
+ RANSAC is the default method.
+
+
+
ransacReprojThreshold - Maximum reprojection error in the RANSAC algorithm to consider
+ a point as an inlier. Applies only to RANSAC.
+ between 0.95 and 0.99 is usually good enough. Values too close to 1 can slow down the estimation
+ significantly. Values lower than 0.8-0.9 can result in an incorrectly estimated transformation.
+ Passing 0 will disable refining, so the output matrix will be output of robust method.
+
Returns:
+
Output 2D affine transformation (4 degrees of freedom) matrix \(2 \times 3\) or
+ empty matrix if transformation could not be estimated.
+
+ The function estimates an optimal 2D affine transformation with 4 degrees of freedom limited to
+ combinations of translation, rotation, and uniform scaling. Uses the selected algorithm for robust
+ estimation.
+
+ The computed transformation is then refined further (using only inliers) with the
+ Levenberg-Marquardt method to reduce the re-projection error even more.
+
+ Estimated transformation matrix is:
+ \( \begin{bmatrix} \cos(\theta) \cdot s & -\sin(\theta) \cdot s & t_x \\
+ \sin(\theta) \cdot s & \cos(\theta) \cdot s & t_y
+ \end{bmatrix} \)
+ Where \( \theta \) is the rotation angle, \( s \) the scaling factor and \( t_x, t_y \) are
+ translations in \( x, y \) axes respectively.
+
+ Note:
+ The RANSAC method can handle practically any ratio of outliers but need a threshold to
+ distinguish inliers from outliers. The method LMeDS does not need any threshold but it works
+ correctly only when there are more than 50% of inliers.
+
+ SEE: estimateAffine2D, getAffineTransform
public static Mat estimateAffinePartial2D(Mat from,
+ Mat to,
+ Mat inliers,
+ int method,
+ double ransacReprojThreshold,
+ long maxIters)
+
Computes an optimal limited affine transformation with 4 degrees of freedom between
+ two 2D point sets.
+
+
Parameters:
+
from - First input 2D point set.
+
to - Second input 2D point set.
+
inliers - Output vector indicating which points are inliers.
+
method - Robust method used to compute transformation. The following methods are possible:
+
+
+ REF: RANSAC - RANSAC-based robust method
+
+
+ REF: LMEDS - Least-Median robust method
+ RANSAC is the default method.
+
+
+
ransacReprojThreshold - Maximum reprojection error in the RANSAC algorithm to consider
+ a point as an inlier. Applies only to RANSAC.
+
maxIters - The maximum number of robust method iterations.
+ between 0.95 and 0.99 is usually good enough. Values too close to 1 can slow down the estimation
+ significantly. Values lower than 0.8-0.9 can result in an incorrectly estimated transformation.
+ Passing 0 will disable refining, so the output matrix will be output of robust method.
+
Returns:
+
Output 2D affine transformation (4 degrees of freedom) matrix \(2 \times 3\) or
+ empty matrix if transformation could not be estimated.
+
+ The function estimates an optimal 2D affine transformation with 4 degrees of freedom limited to
+ combinations of translation, rotation, and uniform scaling. Uses the selected algorithm for robust
+ estimation.
+
+ The computed transformation is then refined further (using only inliers) with the
+ Levenberg-Marquardt method to reduce the re-projection error even more.
+
+ Estimated transformation matrix is:
+ \( \begin{bmatrix} \cos(\theta) \cdot s & -\sin(\theta) \cdot s & t_x \\
+ \sin(\theta) \cdot s & \cos(\theta) \cdot s & t_y
+ \end{bmatrix} \)
+ Where \( \theta \) is the rotation angle, \( s \) the scaling factor and \( t_x, t_y \) are
+ translations in \( x, y \) axes respectively.
+
+ Note:
+ The RANSAC method can handle practically any ratio of outliers but need a threshold to
+ distinguish inliers from outliers. The method LMeDS does not need any threshold but it works
+ correctly only when there are more than 50% of inliers.
+
+ SEE: estimateAffine2D, getAffineTransform
public static Mat estimateAffinePartial2D(Mat from,
+ Mat to,
+ Mat inliers,
+ int method,
+ double ransacReprojThreshold,
+ long maxIters,
+ double confidence)
+
Computes an optimal limited affine transformation with 4 degrees of freedom between
+ two 2D point sets.
+
+
Parameters:
+
from - First input 2D point set.
+
to - Second input 2D point set.
+
inliers - Output vector indicating which points are inliers.
+
method - Robust method used to compute transformation. The following methods are possible:
+
+
+ REF: RANSAC - RANSAC-based robust method
+
+
+ REF: LMEDS - Least-Median robust method
+ RANSAC is the default method.
+
+
+
ransacReprojThreshold - Maximum reprojection error in the RANSAC algorithm to consider
+ a point as an inlier. Applies only to RANSAC.
+
maxIters - The maximum number of robust method iterations.
+
confidence - Confidence level, between 0 and 1, for the estimated transformation. Anything
+ between 0.95 and 0.99 is usually good enough. Values too close to 1 can slow down the estimation
+ significantly. Values lower than 0.8-0.9 can result in an incorrectly estimated transformation.
+ Passing 0 will disable refining, so the output matrix will be output of robust method.
+
Returns:
+
Output 2D affine transformation (4 degrees of freedom) matrix \(2 \times 3\) or
+ empty matrix if transformation could not be estimated.
+
+ The function estimates an optimal 2D affine transformation with 4 degrees of freedom limited to
+ combinations of translation, rotation, and uniform scaling. Uses the selected algorithm for robust
+ estimation.
+
+ The computed transformation is then refined further (using only inliers) with the
+ Levenberg-Marquardt method to reduce the re-projection error even more.
+
+ Estimated transformation matrix is:
+ \( \begin{bmatrix} \cos(\theta) \cdot s & -\sin(\theta) \cdot s & t_x \\
+ \sin(\theta) \cdot s & \cos(\theta) \cdot s & t_y
+ \end{bmatrix} \)
+ Where \( \theta \) is the rotation angle, \( s \) the scaling factor and \( t_x, t_y \) are
+ translations in \( x, y \) axes respectively.
+
+ Note:
+ The RANSAC method can handle practically any ratio of outliers but need a threshold to
+ distinguish inliers from outliers. The method LMeDS does not need any threshold but it works
+ correctly only when there are more than 50% of inliers.
+
+ SEE: estimateAffine2D, getAffineTransform
public static Mat estimateAffinePartial2D(Mat from,
+ Mat to,
+ Mat inliers,
+ int method,
+ double ransacReprojThreshold,
+ long maxIters,
+ double confidence,
+ long refineIters)
+
Computes an optimal limited affine transformation with 4 degrees of freedom between
+ two 2D point sets.
+
+
Parameters:
+
from - First input 2D point set.
+
to - Second input 2D point set.
+
inliers - Output vector indicating which points are inliers.
+
method - Robust method used to compute transformation. The following methods are possible:
+
+
+ REF: RANSAC - RANSAC-based robust method
+
+
+ REF: LMEDS - Least-Median robust method
+ RANSAC is the default method.
+
+
+
ransacReprojThreshold - Maximum reprojection error in the RANSAC algorithm to consider
+ a point as an inlier. Applies only to RANSAC.
+
maxIters - The maximum number of robust method iterations.
+
confidence - Confidence level, between 0 and 1, for the estimated transformation. Anything
+ between 0.95 and 0.99 is usually good enough. Values too close to 1 can slow down the estimation
+ significantly. Values lower than 0.8-0.9 can result in an incorrectly estimated transformation.
+
refineIters - Maximum number of iterations of refining algorithm (Levenberg-Marquardt).
+ Passing 0 will disable refining, so the output matrix will be output of robust method.
+
Returns:
+
Output 2D affine transformation (4 degrees of freedom) matrix \(2 \times 3\) or
+ empty matrix if transformation could not be estimated.
+
+ The function estimates an optimal 2D affine transformation with 4 degrees of freedom limited to
+ combinations of translation, rotation, and uniform scaling. Uses the selected algorithm for robust
+ estimation.
+
+ The computed transformation is then refined further (using only inliers) with the
+ Levenberg-Marquardt method to reduce the re-projection error even more.
+
+ Estimated transformation matrix is:
+ \( \begin{bmatrix} \cos(\theta) \cdot s & -\sin(\theta) \cdot s & t_x \\
+ \sin(\theta) \cdot s & \cos(\theta) \cdot s & t_y
+ \end{bmatrix} \)
+ Where \( \theta \) is the rotation angle, \( s \) the scaling factor and \( t_x, t_y \) are
+ translations in \( x, y \) axes respectively.
+
+ Note:
+ The RANSAC method can handle practically any ratio of outliers but need a threshold to
+ distinguish inliers from outliers. The method LMeDS does not need any threshold but it works
+ correctly only when there are more than 50% of inliers.
+
+ SEE: estimateAffine2D, getAffineTransform
public static Scalar estimateChessboardSharpness(Mat image,
+ Size patternSize,
+ Mat corners)
+
Estimates the sharpness of a detected chessboard.
+
+ Image sharpness, as well as brightness, are a critical parameter for accuracte
+ camera calibration. For accessing these parameters for filtering out
+ problematic calibraiton images, this method calculates edge profiles by traveling from
+ black to white chessboard cell centers. Based on this, the number of pixels is
+ calculated required to transit from black to white. This width of the
+ transition area is a good indication of how sharp the chessboard is imaged
+ and should be below ~3.0 pixels.
+
+
Parameters:
+
image - Gray image used to find chessboard corners
+
patternSize - Size of a found chessboard pattern
+
corners - Corners found by #findChessboardCornersSB
+
+ The optional sharpness array is of type CV_32FC1 and has for each calculated
+ profile one row with the following five entries:
+ 0 = x coordinate of the underlying edge in the image
+ 1 = y coordinate of the underlying edge in the image
+ 2 = width of the transition area (sharpness)
+ 3 = signal strength in the black cell (min brightness)
+ 4 = signal strength in the white cell (max brightness)
+
Returns:
+
Scalar(average sharpness, average min brightness, average max brightness,0)
public static Scalar estimateChessboardSharpness(Mat image,
+ Size patternSize,
+ Mat corners,
+ float rise_distance)
+
Estimates the sharpness of a detected chessboard.
+
+ Image sharpness, as well as brightness, are a critical parameter for accuracte
+ camera calibration. For accessing these parameters for filtering out
+ problematic calibraiton images, this method calculates edge profiles by traveling from
+ black to white chessboard cell centers. Based on this, the number of pixels is
+ calculated required to transit from black to white. This width of the
+ transition area is a good indication of how sharp the chessboard is imaged
+ and should be below ~3.0 pixels.
+
+
Parameters:
+
image - Gray image used to find chessboard corners
+
patternSize - Size of a found chessboard pattern
+
corners - Corners found by #findChessboardCornersSB
+
rise_distance - Rise distance 0.8 means 10% ... 90% of the final signal strength
+
+ The optional sharpness array is of type CV_32FC1 and has for each calculated
+ profile one row with the following five entries:
+ 0 = x coordinate of the underlying edge in the image
+ 1 = y coordinate of the underlying edge in the image
+ 2 = width of the transition area (sharpness)
+ 3 = signal strength in the black cell (min brightness)
+ 4 = signal strength in the white cell (max brightness)
+
Returns:
+
Scalar(average sharpness, average min brightness, average max brightness,0)
public static Scalar estimateChessboardSharpness(Mat image,
+ Size patternSize,
+ Mat corners,
+ float rise_distance,
+ boolean vertical)
+
Estimates the sharpness of a detected chessboard.
+
+ Image sharpness, as well as brightness, are a critical parameter for accuracte
+ camera calibration. For accessing these parameters for filtering out
+ problematic calibraiton images, this method calculates edge profiles by traveling from
+ black to white chessboard cell centers. Based on this, the number of pixels is
+ calculated required to transit from black to white. This width of the
+ transition area is a good indication of how sharp the chessboard is imaged
+ and should be below ~3.0 pixels.
+
+
Parameters:
+
image - Gray image used to find chessboard corners
+
patternSize - Size of a found chessboard pattern
+
corners - Corners found by #findChessboardCornersSB
+
rise_distance - Rise distance 0.8 means 10% ... 90% of the final signal strength
+
vertical - By default edge responses for horizontal lines are calculated
+
+ The optional sharpness array is of type CV_32FC1 and has for each calculated
+ profile one row with the following five entries:
+ 0 = x coordinate of the underlying edge in the image
+ 1 = y coordinate of the underlying edge in the image
+ 2 = width of the transition area (sharpness)
+ 3 = signal strength in the black cell (min brightness)
+ 4 = signal strength in the white cell (max brightness)
+
Returns:
+
Scalar(average sharpness, average min brightness, average max brightness,0)
public static Scalar estimateChessboardSharpness(Mat image,
+ Size patternSize,
+ Mat corners,
+ float rise_distance,
+ boolean vertical,
+ Mat sharpness)
+
Estimates the sharpness of a detected chessboard.
+
+ Image sharpness, as well as brightness, are a critical parameter for accuracte
+ camera calibration. For accessing these parameters for filtering out
+ problematic calibraiton images, this method calculates edge profiles by traveling from
+ black to white chessboard cell centers. Based on this, the number of pixels is
+ calculated required to transit from black to white. This width of the
+ transition area is a good indication of how sharp the chessboard is imaged
+ and should be below ~3.0 pixels.
+
+
Parameters:
+
image - Gray image used to find chessboard corners
+
patternSize - Size of a found chessboard pattern
+
corners - Corners found by #findChessboardCornersSB
+
rise_distance - Rise distance 0.8 means 10% ... 90% of the final signal strength
+
vertical - By default edge responses for horizontal lines are calculated
+
sharpness - Optional output array with a sharpness value for calculated edge responses (see description)
+
+ The optional sharpness array is of type CV_32FC1 and has for each calculated
+ profile one row with the following five entries:
+ 0 = x coordinate of the underlying edge in the image
+ 1 = y coordinate of the underlying edge in the image
+ 2 = width of the transition area (sharpness)
+ 3 = signal strength in the black cell (min brightness)
+ 4 = signal strength in the white cell (max brightness)
+
Returns:
+
Scalar(average sharpness, average min brightness, average max brightness,0)
public static int estimateTranslation3D(Mat src,
+ Mat dst,
+ Mat out,
+ Mat inliers)
+
Computes an optimal translation between two 3D point sets.
+
+ It computes
+ \(
+ \begin{bmatrix}
+ x\\
+ y\\
+ z\\
+ \end{bmatrix}
+ =
+ \begin{bmatrix}
+ X\\
+ Y\\
+ Z\\
+ \end{bmatrix}
+ +
+ \begin{bmatrix}
+ b_1\\
+ b_2\\
+ b_3\\
+ \end{bmatrix}
+ \)
+
+
Parameters:
+
src - First input 3D point set containing \((X,Y,Z)\).
+
dst - Second input 3D point set containing \((x,y,z)\).
+
out - Output 3D translation vector \(3 \times 1\) of the form
+ \(
+ \begin{bmatrix}
+ b_1 \\
+ b_2 \\
+ b_3 \\
+ \end{bmatrix}
+ \)
+
inliers - Output vector indicating which points are inliers (1-inlier, 0-outlier).
+ an inlier.
+ between 0.95 and 0.99 is usually good enough. Values too close to 1 can slow down the estimation
+ significantly. Values lower than 0.8-0.9 can result in an incorrectly estimated transformation.
+
+ The function estimates an optimal 3D translation between two 3D point sets using the
+ RANSAC algorithm.
public static int estimateTranslation3D(Mat src,
+ Mat dst,
+ Mat out,
+ Mat inliers,
+ double ransacThreshold)
+
Computes an optimal translation between two 3D point sets.
+
+ It computes
+ \(
+ \begin{bmatrix}
+ x\\
+ y\\
+ z\\
+ \end{bmatrix}
+ =
+ \begin{bmatrix}
+ X\\
+ Y\\
+ Z\\
+ \end{bmatrix}
+ +
+ \begin{bmatrix}
+ b_1\\
+ b_2\\
+ b_3\\
+ \end{bmatrix}
+ \)
+
+
Parameters:
+
src - First input 3D point set containing \((X,Y,Z)\).
+
dst - Second input 3D point set containing \((x,y,z)\).
+
out - Output 3D translation vector \(3 \times 1\) of the form
+ \(
+ \begin{bmatrix}
+ b_1 \\
+ b_2 \\
+ b_3 \\
+ \end{bmatrix}
+ \)
+
inliers - Output vector indicating which points are inliers (1-inlier, 0-outlier).
+
ransacThreshold - Maximum reprojection error in the RANSAC algorithm to consider a point as
+ an inlier.
+ between 0.95 and 0.99 is usually good enough. Values too close to 1 can slow down the estimation
+ significantly. Values lower than 0.8-0.9 can result in an incorrectly estimated transformation.
+
+ The function estimates an optimal 3D translation between two 3D point sets using the
+ RANSAC algorithm.
public static int estimateTranslation3D(Mat src,
+ Mat dst,
+ Mat out,
+ Mat inliers,
+ double ransacThreshold,
+ double confidence)
+
Computes an optimal translation between two 3D point sets.
+
+ It computes
+ \(
+ \begin{bmatrix}
+ x\\
+ y\\
+ z\\
+ \end{bmatrix}
+ =
+ \begin{bmatrix}
+ X\\
+ Y\\
+ Z\\
+ \end{bmatrix}
+ +
+ \begin{bmatrix}
+ b_1\\
+ b_2\\
+ b_3\\
+ \end{bmatrix}
+ \)
+
+
Parameters:
+
src - First input 3D point set containing \((X,Y,Z)\).
+
dst - Second input 3D point set containing \((x,y,z)\).
+
out - Output 3D translation vector \(3 \times 1\) of the form
+ \(
+ \begin{bmatrix}
+ b_1 \\
+ b_2 \\
+ b_3 \\
+ \end{bmatrix}
+ \)
+
inliers - Output vector indicating which points are inliers (1-inlier, 0-outlier).
+
ransacThreshold - Maximum reprojection error in the RANSAC algorithm to consider a point as
+ an inlier.
+
confidence - Confidence level, between 0 and 1, for the estimated transformation. Anything
+ between 0.95 and 0.99 is usually good enough. Values too close to 1 can slow down the estimation
+ significantly. Values lower than 0.8-0.9 can result in an incorrectly estimated transformation.
+
+ The function estimates an optimal 3D translation between two 3D point sets using the
+ RANSAC algorithm.
public static void filterHomographyDecompByVisibleRefpoints(java.util.List<Mat> rotations,
+ java.util.List<Mat> normals,
+ Mat beforePoints,
+ Mat afterPoints,
+ Mat possibleSolutions)
+
Filters homography decompositions based on additional information.
+
+
Parameters:
+
rotations - Vector of rotation matrices.
+
normals - Vector of plane normal matrices.
+
beforePoints - Vector of (rectified) visible reference points before the homography is applied
+
afterPoints - Vector of (rectified) visible reference points after the homography is applied
+
possibleSolutions - Vector of int indices representing the viable solution set after filtering
+
+ This function is intended to filter the output of the #decomposeHomographyMat based on additional
+ information as described in CITE: Malis2007 . The summary of the method: the #decomposeHomographyMat function
+ returns 2 unique solutions and their "opposites" for a total of 4 solutions. If we have access to the
+ sets of points visible in the camera frame before and after the homography transformation is applied,
+ we can determine which are the true potential solutions and which are the opposites by verifying which
+ homographies are consistent with all visible reference points being in front of the camera. The inputs
+ are left unchanged; the filtered solution set is returned as indices into the existing one.
public static void filterHomographyDecompByVisibleRefpoints(java.util.List<Mat> rotations,
+ java.util.List<Mat> normals,
+ Mat beforePoints,
+ Mat afterPoints,
+ Mat possibleSolutions,
+ Mat pointsMask)
+
Filters homography decompositions based on additional information.
+
+
Parameters:
+
rotations - Vector of rotation matrices.
+
normals - Vector of plane normal matrices.
+
beforePoints - Vector of (rectified) visible reference points before the homography is applied
+
afterPoints - Vector of (rectified) visible reference points after the homography is applied
+
possibleSolutions - Vector of int indices representing the viable solution set after filtering
+
pointsMask - optional Mat/Vector of 8u type representing the mask for the inliers as given by the #findHomography function
+
+ This function is intended to filter the output of the #decomposeHomographyMat based on additional
+ information as described in CITE: Malis2007 . The summary of the method: the #decomposeHomographyMat function
+ returns 2 unique solutions and their "opposites" for a total of 4 solutions. If we have access to the
+ sets of points visible in the camera frame before and after the homography transformation is applied,
+ we can determine which are the true potential solutions and which are the opposites by verifying which
+ homographies are consistent with all visible reference points being in front of the camera. The inputs
+ are left unchanged; the filtered solution set is returned as indices into the existing one.
public static void filterSpeckles(Mat img,
+ double newVal,
+ int maxSpeckleSize,
+ double maxDiff)
+
Filters off small noise blobs (speckles) in the disparity map
+
+
Parameters:
+
img - The input 16-bit signed disparity image
+
newVal - The disparity value used to paint-off the speckles
+
maxSpeckleSize - The maximum speckle size to consider it a speckle. Larger blobs are not
+ affected by the algorithm
+
maxDiff - Maximum difference between neighbor disparity pixels to put them into the same
+ blob. Note that since StereoBM, StereoSGBM and may be other algorithms return a fixed-point
+ disparity map, where disparity values are multiplied by 16, this scale factor should be taken into
+ account when specifying this parameter value.
public static void filterSpeckles(Mat img,
+ double newVal,
+ int maxSpeckleSize,
+ double maxDiff,
+ Mat buf)
+
Filters off small noise blobs (speckles) in the disparity map
+
+
Parameters:
+
img - The input 16-bit signed disparity image
+
newVal - The disparity value used to paint-off the speckles
+
maxSpeckleSize - The maximum speckle size to consider it a speckle. Larger blobs are not
+ affected by the algorithm
+
maxDiff - Maximum difference between neighbor disparity pixels to put them into the same
+ blob. Note that since StereoBM, StereoSGBM and may be other algorithms return a fixed-point
+ disparity map, where disparity values are multiplied by 16, this scale factor should be taken into
+ account when specifying this parameter value.
+
buf - The optional temporary buffer to avoid memory allocation within the function.
Finds the positions of internal corners of the chessboard.
+
+
Parameters:
+
image - Source chessboard view. It must be an 8-bit grayscale or color image.
+
patternSize - Number of inner corners per a chessboard row and column
+ ( patternSize = cv::Size(points_per_row,points_per_colum) = cv::Size(columns,rows) ).
+
corners - Output array of detected corners.
+
+
+ REF: CALIB_CB_ADAPTIVE_THRESH Use adaptive thresholding to convert the image to black
+ and white, rather than a fixed threshold level (computed from the average image brightness).
+
+
+ REF: CALIB_CB_NORMALIZE_IMAGE Normalize the image gamma with #equalizeHist before
+ applying fixed or adaptive thresholding.
+
+
+ REF: CALIB_CB_FILTER_QUADS Use additional criteria (like contour area, perimeter,
+ square-like shape) to filter out false quads extracted at the contour retrieval stage.
+
+
+ REF: CALIB_CB_FAST_CHECK Run a fast check on the image that looks for chessboard corners,
+ and shortcut the call if none is found. This can drastically speed up the call in the
+ degenerate condition when no chessboard is observed.
+
+
+
+ The function attempts to determine whether the input image is a view of the chessboard pattern and
+ locate the internal chessboard corners. The function returns a non-zero value if all of the corners
+ are found and they are placed in a certain order (row by row, left to right in every row).
+ Otherwise, if the function fails to find all the corners or reorder them, it returns 0. For example,
+ a regular chessboard has 8 x 8 squares and 7 x 7 internal corners, that is, points where the black
+ squares touch each other. The detected coordinates are approximate, and to determine their positions
+ more accurately, the function calls #cornerSubPix. You also may use the function #cornerSubPix with
+ different parameters if returned coordinates are not accurate enough.
+
+ Sample usage of detecting and drawing chessboard corners: :
+
+ Size patternsize(8,6); //interior number of corners
+ Mat gray = ....; //source image
+ vector<Point2f> corners; //this will be filled by the detected corners
+
+ //CALIB_CB_FAST_CHECK saves a lot of time on images
+ //that do not contain any chessboard corners
+ bool patternfound = findChessboardCorners(gray, patternsize, corners,
+ CALIB_CB_ADAPTIVE_THRESH + CALIB_CB_NORMALIZE_IMAGE
+ + CALIB_CB_FAST_CHECK);
+
+ if(patternfound)
+ cornerSubPix(gray, corners, Size(11, 11), Size(-1, -1),
+ TermCriteria(CV_TERMCRIT_EPS + CV_TERMCRIT_ITER, 30, 0.1));
+
+ drawChessboardCorners(img, patternsize, Mat(corners), patternfound);
+
+ Note: The function requires white space (like a square-thick border, the wider the better) around
+ the board to make the detection more robust in various environments. Otherwise, if there is no
+ border and the background is dark, the outer black squares cannot be segmented properly and so the
+ square grouping and ordering algorithm fails.
+
+ Use gen_pattern.py (REF: tutorial_camera_calibration_pattern) to create checkerboard.
public static boolean findChessboardCorners(Mat image,
+ Size patternSize,
+ MatOfPoint2f corners,
+ int flags)
+
Finds the positions of internal corners of the chessboard.
+
+
Parameters:
+
image - Source chessboard view. It must be an 8-bit grayscale or color image.
+
patternSize - Number of inner corners per a chessboard row and column
+ ( patternSize = cv::Size(points_per_row,points_per_colum) = cv::Size(columns,rows) ).
+
corners - Output array of detected corners.
+
flags - Various operation flags that can be zero or a combination of the following values:
+
+
+ REF: CALIB_CB_ADAPTIVE_THRESH Use adaptive thresholding to convert the image to black
+ and white, rather than a fixed threshold level (computed from the average image brightness).
+
+
+ REF: CALIB_CB_NORMALIZE_IMAGE Normalize the image gamma with #equalizeHist before
+ applying fixed or adaptive thresholding.
+
+
+ REF: CALIB_CB_FILTER_QUADS Use additional criteria (like contour area, perimeter,
+ square-like shape) to filter out false quads extracted at the contour retrieval stage.
+
+
+ REF: CALIB_CB_FAST_CHECK Run a fast check on the image that looks for chessboard corners,
+ and shortcut the call if none is found. This can drastically speed up the call in the
+ degenerate condition when no chessboard is observed.
+
+
+
+ The function attempts to determine whether the input image is a view of the chessboard pattern and
+ locate the internal chessboard corners. The function returns a non-zero value if all of the corners
+ are found and they are placed in a certain order (row by row, left to right in every row).
+ Otherwise, if the function fails to find all the corners or reorder them, it returns 0. For example,
+ a regular chessboard has 8 x 8 squares and 7 x 7 internal corners, that is, points where the black
+ squares touch each other. The detected coordinates are approximate, and to determine their positions
+ more accurately, the function calls #cornerSubPix. You also may use the function #cornerSubPix with
+ different parameters if returned coordinates are not accurate enough.
+
+ Sample usage of detecting and drawing chessboard corners: :
+
+ Size patternsize(8,6); //interior number of corners
+ Mat gray = ....; //source image
+ vector<Point2f> corners; //this will be filled by the detected corners
+
+ //CALIB_CB_FAST_CHECK saves a lot of time on images
+ //that do not contain any chessboard corners
+ bool patternfound = findChessboardCorners(gray, patternsize, corners,
+ CALIB_CB_ADAPTIVE_THRESH + CALIB_CB_NORMALIZE_IMAGE
+ + CALIB_CB_FAST_CHECK);
+
+ if(patternfound)
+ cornerSubPix(gray, corners, Size(11, 11), Size(-1, -1),
+ TermCriteria(CV_TERMCRIT_EPS + CV_TERMCRIT_ITER, 30, 0.1));
+
+ drawChessboardCorners(img, patternsize, Mat(corners), patternfound);
+
+ Note: The function requires white space (like a square-thick border, the wider the better) around
+ the board to make the detection more robust in various environments. Otherwise, if there is no
+ border and the background is dark, the outer black squares cannot be segmented properly and so the
+ square grouping and ordering algorithm fails.
+
+ Use gen_pattern.py (REF: tutorial_camera_calibration_pattern) to create checkerboard.
public static boolean findChessboardCornersSBWithMeta(Mat image,
+ Size patternSize,
+ Mat corners,
+ int flags,
+ Mat meta)
+
Finds the positions of internal corners of the chessboard using a sector based approach.
+
+
Parameters:
+
image - Source chessboard view. It must be an 8-bit grayscale or color image.
+
patternSize - Number of inner corners per a chessboard row and column
+ ( patternSize = cv::Size(points_per_row,points_per_colum) = cv::Size(columns,rows) ).
+
corners - Output array of detected corners.
+
flags - Various operation flags that can be zero or a combination of the following values:
+
+
+ REF: CALIB_CB_NORMALIZE_IMAGE Normalize the image gamma with equalizeHist before detection.
+
+
+ REF: CALIB_CB_EXHAUSTIVE Run an exhaustive search to improve detection rate.
+
+
+ REF: CALIB_CB_ACCURACY Up sample input image to improve sub-pixel accuracy due to aliasing effects.
+
+
+ REF: CALIB_CB_LARGER The detected pattern is allowed to be larger than patternSize (see description).
+
+
+ REF: CALIB_CB_MARKER The detected pattern must have a marker (see description).
+ This should be used if an accurate camera calibration is required.
+
+
+
meta - Optional output arrray of detected corners (CV_8UC1 and size = cv::Size(columns,rows)).
+ Each entry stands for one corner of the pattern and can have one of the following values:
+
+
+ 0 = no meta data attached
+
+
+ 1 = left-top corner of a black cell
+
+
+ 2 = left-top corner of a white cell
+
+
+ 3 = left-top corner of a black cell with a white marker dot
+
+
+ 4 = left-top corner of a white cell with a black marker dot (pattern origin in case of markers otherwise first corner)
+
+
+
+ The function is analog to #findChessboardCorners but uses a localized radon
+ transformation approximated by box filters being more robust to all sort of
+ noise, faster on larger images and is able to directly return the sub-pixel
+ position of the internal chessboard corners. The Method is based on the paper
+ CITE: duda2018 "Accurate Detection and Localization of Checkerboard Corners for
+ Calibration" demonstrating that the returned sub-pixel positions are more
+ accurate than the one returned by cornerSubPix allowing a precise camera
+ calibration for demanding applications.
+
+ In the case, the flags REF: CALIB_CB_LARGER or REF: CALIB_CB_MARKER are given,
+ the result can be recovered from the optional meta array. Both flags are
+ helpful to use calibration patterns exceeding the field of view of the camera.
+ These oversized patterns allow more accurate calibrations as corners can be
+ utilized, which are as close as possible to the image borders. For a
+ consistent coordinate system across all images, the optional marker (see image
+ below) can be used to move the origin of the board to the location where the
+ black circle is located.
+
+ Note: The function requires a white boarder with roughly the same width as one
+ of the checkerboard fields around the whole board to improve the detection in
+ various environments. In addition, because of the localized radon
+ transformation it is beneficial to use round corners for the field corners
+ which are located on the outside of the board. The following figure illustrates
+ a sample checkerboard optimized for the detection. However, any other checkerboard
+ can be used as well.
+
+ Use gen_pattern.py (REF: tutorial_camera_calibration_pattern) to create checkerboard.
+ 
public static Mat findEssentialMat(Mat points1,
+ Mat points2)
+
+
Parameters:
+
points1 - Array of N (N >= 5) 2D points from the first image. The point coordinates should
+ be floating-point (single or double precision).
+
points2 - Array of the second image points of the same size and format as points1 .
+ are feature points from cameras with same focal length and principal point.
+
+
+ REF: RANSAC for the RANSAC algorithm.
+
+
+ REF: LMEDS for the LMedS algorithm.
+
+
+ line in pixels, beyond which the point is considered an outlier and is not used for computing the
+ final fundamental matrix. It can be set to something like 1-3, depending on the accuracy of the
+ point localization, image resolution, and the image noise.
+ confidence (probability) that the estimated matrix is correct.
+ for the other points. The array is computed only in the RANSAC and LMedS methods.
+
+ This function differs from the one above that it computes camera intrinsic matrix from focal length and
+ principal point:
+
+ \(A =
+ \begin{bmatrix}
+ f & 0 & x_{pp} \\
+ 0 & f & y_{pp} \\
+ 0 & 0 & 1
+ \end{bmatrix}\)
public static Mat findEssentialMat(Mat points1,
+ Mat points2,
+ double focal)
+
+
Parameters:
+
points1 - Array of N (N >= 5) 2D points from the first image. The point coordinates should
+ be floating-point (single or double precision).
+
points2 - Array of the second image points of the same size and format as points1 .
+
focal - focal length of the camera. Note that this function assumes that points1 and points2
+ are feature points from cameras with same focal length and principal point.
+
+
+ REF: RANSAC for the RANSAC algorithm.
+
+
+ REF: LMEDS for the LMedS algorithm.
+
+
+ line in pixels, beyond which the point is considered an outlier and is not used for computing the
+ final fundamental matrix. It can be set to something like 1-3, depending on the accuracy of the
+ point localization, image resolution, and the image noise.
+ confidence (probability) that the estimated matrix is correct.
+ for the other points. The array is computed only in the RANSAC and LMedS methods.
+
+ This function differs from the one above that it computes camera intrinsic matrix from focal length and
+ principal point:
+
+ \(A =
+ \begin{bmatrix}
+ f & 0 & x_{pp} \\
+ 0 & f & y_{pp} \\
+ 0 & 0 & 1
+ \end{bmatrix}\)
public static Mat findEssentialMat(Mat points1,
+ Mat points2,
+ double focal,
+ Point pp)
+
+
Parameters:
+
points1 - Array of N (N >= 5) 2D points from the first image. The point coordinates should
+ be floating-point (single or double precision).
+
points2 - Array of the second image points of the same size and format as points1 .
+
focal - focal length of the camera. Note that this function assumes that points1 and points2
+ are feature points from cameras with same focal length and principal point.
+
pp - principal point of the camera.
+
+
+ REF: RANSAC for the RANSAC algorithm.
+
+
+ REF: LMEDS for the LMedS algorithm.
+
+
+ line in pixels, beyond which the point is considered an outlier and is not used for computing the
+ final fundamental matrix. It can be set to something like 1-3, depending on the accuracy of the
+ point localization, image resolution, and the image noise.
+ confidence (probability) that the estimated matrix is correct.
+ for the other points. The array is computed only in the RANSAC and LMedS methods.
+
+ This function differs from the one above that it computes camera intrinsic matrix from focal length and
+ principal point:
+
+ \(A =
+ \begin{bmatrix}
+ f & 0 & x_{pp} \\
+ 0 & f & y_{pp} \\
+ 0 & 0 & 1
+ \end{bmatrix}\)
public static Mat findEssentialMat(Mat points1,
+ Mat points2,
+ double focal,
+ Point pp,
+ int method)
+
+
Parameters:
+
points1 - Array of N (N >= 5) 2D points from the first image. The point coordinates should
+ be floating-point (single or double precision).
+
points2 - Array of the second image points of the same size and format as points1 .
+
focal - focal length of the camera. Note that this function assumes that points1 and points2
+ are feature points from cameras with same focal length and principal point.
+
pp - principal point of the camera.
+
method - Method for computing a fundamental matrix.
+
+
+ REF: RANSAC for the RANSAC algorithm.
+
+
+ REF: LMEDS for the LMedS algorithm.
+
+
+ line in pixels, beyond which the point is considered an outlier and is not used for computing the
+ final fundamental matrix. It can be set to something like 1-3, depending on the accuracy of the
+ point localization, image resolution, and the image noise.
+ confidence (probability) that the estimated matrix is correct.
+ for the other points. The array is computed only in the RANSAC and LMedS methods.
+
+ This function differs from the one above that it computes camera intrinsic matrix from focal length and
+ principal point:
+
+ \(A =
+ \begin{bmatrix}
+ f & 0 & x_{pp} \\
+ 0 & f & y_{pp} \\
+ 0 & 0 & 1
+ \end{bmatrix}\)
public static Mat findEssentialMat(Mat points1,
+ Mat points2,
+ double focal,
+ Point pp,
+ int method,
+ double prob)
+
+
Parameters:
+
points1 - Array of N (N >= 5) 2D points from the first image. The point coordinates should
+ be floating-point (single or double precision).
+
points2 - Array of the second image points of the same size and format as points1 .
+
focal - focal length of the camera. Note that this function assumes that points1 and points2
+ are feature points from cameras with same focal length and principal point.
+
pp - principal point of the camera.
+
method - Method for computing a fundamental matrix.
+
+
+ REF: RANSAC for the RANSAC algorithm.
+
+
+ REF: LMEDS for the LMedS algorithm.
+
+
+ line in pixels, beyond which the point is considered an outlier and is not used for computing the
+ final fundamental matrix. It can be set to something like 1-3, depending on the accuracy of the
+ point localization, image resolution, and the image noise.
+
prob - Parameter used for the RANSAC or LMedS methods only. It specifies a desirable level of
+ confidence (probability) that the estimated matrix is correct.
+ for the other points. The array is computed only in the RANSAC and LMedS methods.
+
+ This function differs from the one above that it computes camera intrinsic matrix from focal length and
+ principal point:
+
+ \(A =
+ \begin{bmatrix}
+ f & 0 & x_{pp} \\
+ 0 & f & y_{pp} \\
+ 0 & 0 & 1
+ \end{bmatrix}\)
public static Mat findEssentialMat(Mat points1,
+ Mat points2,
+ double focal,
+ Point pp,
+ int method,
+ double prob,
+ double threshold)
+
+
Parameters:
+
points1 - Array of N (N >= 5) 2D points from the first image. The point coordinates should
+ be floating-point (single or double precision).
+
points2 - Array of the second image points of the same size and format as points1 .
+
focal - focal length of the camera. Note that this function assumes that points1 and points2
+ are feature points from cameras with same focal length and principal point.
+
pp - principal point of the camera.
+
method - Method for computing a fundamental matrix.
+
+
+ REF: RANSAC for the RANSAC algorithm.
+
+
+ REF: LMEDS for the LMedS algorithm.
+
+
+
threshold - Parameter used for RANSAC. It is the maximum distance from a point to an epipolar
+ line in pixels, beyond which the point is considered an outlier and is not used for computing the
+ final fundamental matrix. It can be set to something like 1-3, depending on the accuracy of the
+ point localization, image resolution, and the image noise.
+
prob - Parameter used for the RANSAC or LMedS methods only. It specifies a desirable level of
+ confidence (probability) that the estimated matrix is correct.
+ for the other points. The array is computed only in the RANSAC and LMedS methods.
+
+ This function differs from the one above that it computes camera intrinsic matrix from focal length and
+ principal point:
+
+ \(A =
+ \begin{bmatrix}
+ f & 0 & x_{pp} \\
+ 0 & f & y_{pp} \\
+ 0 & 0 & 1
+ \end{bmatrix}\)
public static Mat findEssentialMat(Mat points1,
+ Mat points2,
+ double focal,
+ Point pp,
+ int method,
+ double prob,
+ double threshold,
+ int maxIters)
+
+
Parameters:
+
points1 - Array of N (N >= 5) 2D points from the first image. The point coordinates should
+ be floating-point (single or double precision).
+
points2 - Array of the second image points of the same size and format as points1 .
+
focal - focal length of the camera. Note that this function assumes that points1 and points2
+ are feature points from cameras with same focal length and principal point.
+
pp - principal point of the camera.
+
method - Method for computing a fundamental matrix.
+
+
+ REF: RANSAC for the RANSAC algorithm.
+
+
+ REF: LMEDS for the LMedS algorithm.
+
+
+
threshold - Parameter used for RANSAC. It is the maximum distance from a point to an epipolar
+ line in pixels, beyond which the point is considered an outlier and is not used for computing the
+ final fundamental matrix. It can be set to something like 1-3, depending on the accuracy of the
+ point localization, image resolution, and the image noise.
+
prob - Parameter used for the RANSAC or LMedS methods only. It specifies a desirable level of
+ confidence (probability) that the estimated matrix is correct.
+ for the other points. The array is computed only in the RANSAC and LMedS methods.
+
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:
+
+ \(A =
+ \begin{bmatrix}
+ f & 0 & x_{pp} \\
+ 0 & f & y_{pp} \\
+ 0 & 0 & 1
+ \end{bmatrix}\)
public static Mat findEssentialMat(Mat points1,
+ Mat points2,
+ double focal,
+ Point pp,
+ int method,
+ double prob,
+ double threshold,
+ int maxIters,
+ Mat mask)
+
+
Parameters:
+
points1 - Array of N (N >= 5) 2D points from the first image. The point coordinates should
+ be floating-point (single or double precision).
+
points2 - Array of the second image points of the same size and format as points1 .
+
focal - focal length of the camera. Note that this function assumes that points1 and points2
+ are feature points from cameras with same focal length and principal point.
+
pp - principal point of the camera.
+
method - Method for computing a fundamental matrix.
+
+
+ REF: RANSAC for the RANSAC algorithm.
+
+
+ REF: LMEDS for the LMedS algorithm.
+
+
+
threshold - Parameter used for RANSAC. It is the maximum distance from a point to an epipolar
+ line in pixels, beyond which the point is considered an outlier and is not used for computing the
+ final fundamental matrix. It can be set to something like 1-3, depending on the accuracy of the
+ point localization, image resolution, and the image noise.
+
prob - Parameter used for the RANSAC or LMedS methods only. It specifies a desirable level of
+ confidence (probability) that the estimated matrix is correct.
+
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.
+
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:
+
+ \(A =
+ \begin{bmatrix}
+ f & 0 & x_{pp} \\
+ 0 & f & y_{pp} \\
+ 0 & 0 & 1
+ \end{bmatrix}\)
public static Mat findEssentialMat(Mat points1,
+ Mat points2,
+ Mat cameraMatrix)
+
Calculates an essential matrix from the corresponding points in two images.
+
+
Parameters:
+
points1 - Array of N (N >= 5) 2D points from the first image. The point coordinates should
+ be floating-point (single or double precision).
+
points2 - Array of the second image points of the same size and format as points1 .
+
cameraMatrix - Camera intrinsic matrix \(\cameramatrix{A}\) .
+ Note that this function assumes that points1 and points2 are feature points from cameras with the
+ same camera intrinsic matrix. If this assumption does not hold for your use case, use
+ #undistortPoints with P = cv::NoArray() for both cameras to transform image points
+ to normalized image coordinates, which are valid for the identity camera intrinsic matrix. When
+ passing these coordinates, pass the identity matrix for this parameter.
+
+
+ REF: RANSAC for the RANSAC algorithm.
+
+
+ REF: LMEDS for the LMedS algorithm.
+
+
+ confidence (probability) that the estimated matrix is correct.
+ line in pixels, beyond which the point is considered an outlier and is not used for computing the
+ final fundamental matrix. It can be set to something like 1-3, depending on the accuracy of the
+ point localization, image resolution, and the image noise.
+ for the other points. The array is computed only in the RANSAC and LMedS methods.
+
+ 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:
+
+ \([p_2; 1]^T K^{-T} E K^{-1} [p_1; 1] = 0\)
+
+ where \(E\) is an essential matrix, \(p_1\) and \(p_2\) are corresponding points in the first and the
+ second images, respectively. The result of this function may be passed further to
+ #decomposeEssentialMat or #recoverPose to recover the relative pose between cameras.
public static Mat findEssentialMat(Mat points1,
+ Mat points2,
+ Mat cameraMatrix,
+ int method)
+
Calculates an essential matrix from the corresponding points in two images.
+
+
Parameters:
+
points1 - Array of N (N >= 5) 2D points from the first image. The point coordinates should
+ be floating-point (single or double precision).
+
points2 - Array of the second image points of the same size and format as points1 .
+
cameraMatrix - Camera intrinsic matrix \(\cameramatrix{A}\) .
+ Note that this function assumes that points1 and points2 are feature points from cameras with the
+ same camera intrinsic matrix. If this assumption does not hold for your use case, use
+ #undistortPoints with P = cv::NoArray() for both cameras to transform image points
+ to normalized image coordinates, which are valid for the identity camera intrinsic matrix. When
+ passing these coordinates, pass the identity matrix for this parameter.
+
method - Method for computing an essential matrix.
+
+
+ REF: RANSAC for the RANSAC algorithm.
+
+
+ REF: LMEDS for the LMedS algorithm.
+
+
+ confidence (probability) that the estimated matrix is correct.
+ line in pixels, beyond which the point is considered an outlier and is not used for computing the
+ final fundamental matrix. It can be set to something like 1-3, depending on the accuracy of the
+ point localization, image resolution, and the image noise.
+ for the other points. The array is computed only in the RANSAC and LMedS methods.
+
+ 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:
+
+ \([p_2; 1]^T K^{-T} E K^{-1} [p_1; 1] = 0\)
+
+ where \(E\) is an essential matrix, \(p_1\) and \(p_2\) are corresponding points in the first and the
+ second images, respectively. The result of this function may be passed further to
+ #decomposeEssentialMat or #recoverPose to recover the relative pose between cameras.
public static Mat findEssentialMat(Mat points1,
+ Mat points2,
+ Mat cameraMatrix,
+ int method,
+ double prob)
+
Calculates an essential matrix from the corresponding points in two images.
+
+
Parameters:
+
points1 - Array of N (N >= 5) 2D points from the first image. The point coordinates should
+ be floating-point (single or double precision).
+
points2 - Array of the second image points of the same size and format as points1 .
+
cameraMatrix - Camera intrinsic matrix \(\cameramatrix{A}\) .
+ Note that this function assumes that points1 and points2 are feature points from cameras with the
+ same camera intrinsic matrix. If this assumption does not hold for your use case, use
+ #undistortPoints with P = cv::NoArray() for both cameras to transform image points
+ to normalized image coordinates, which are valid for the identity camera intrinsic matrix. When
+ passing these coordinates, pass the identity matrix for this parameter.
+
method - Method for computing an essential matrix.
+
+
+ REF: RANSAC for the RANSAC algorithm.
+
+
+ REF: LMEDS for the LMedS algorithm.
+
+
+
prob - Parameter used for the RANSAC or LMedS methods only. It specifies a desirable level of
+ confidence (probability) that the estimated matrix is correct.
+ line in pixels, beyond which the point is considered an outlier and is not used for computing the
+ final fundamental matrix. It can be set to something like 1-3, depending on the accuracy of the
+ point localization, image resolution, and the image noise.
+ for the other points. The array is computed only in the RANSAC and LMedS methods.
+
+ 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:
+
+ \([p_2; 1]^T K^{-T} E K^{-1} [p_1; 1] = 0\)
+
+ where \(E\) is an essential matrix, \(p_1\) and \(p_2\) are corresponding points in the first and the
+ second images, respectively. The result of this function may be passed further to
+ #decomposeEssentialMat or #recoverPose to recover the relative pose between cameras.
public static Mat findEssentialMat(Mat points1,
+ Mat points2,
+ Mat cameraMatrix,
+ int method,
+ double prob,
+ double threshold)
+
Calculates an essential matrix from the corresponding points in two images.
+
+
Parameters:
+
points1 - Array of N (N >= 5) 2D points from the first image. The point coordinates should
+ be floating-point (single or double precision).
+
points2 - Array of the second image points of the same size and format as points1 .
+
cameraMatrix - Camera intrinsic matrix \(\cameramatrix{A}\) .
+ Note that this function assumes that points1 and points2 are feature points from cameras with the
+ same camera intrinsic matrix. If this assumption does not hold for your use case, use
+ #undistortPoints with P = cv::NoArray() for both cameras to transform image points
+ to normalized image coordinates, which are valid for the identity camera intrinsic matrix. When
+ passing these coordinates, pass the identity matrix for this parameter.
+
method - Method for computing an essential matrix.
+
+
+ REF: RANSAC for the RANSAC algorithm.
+
+
+ REF: LMEDS for the LMedS algorithm.
+
+
+
prob - Parameter used for the RANSAC or LMedS methods only. It specifies a desirable level of
+ confidence (probability) that the estimated matrix is correct.
+
threshold - Parameter used for RANSAC. It is the maximum distance from a point to an epipolar
+ line in pixels, beyond which the point is considered an outlier and is not used for computing the
+ final fundamental matrix. It can be set to something like 1-3, depending on the accuracy of the
+ point localization, image resolution, and the image noise.
+ for the other points. The array is computed only in the RANSAC and LMedS methods.
+
+ 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:
+
+ \([p_2; 1]^T K^{-T} E K^{-1} [p_1; 1] = 0\)
+
+ where \(E\) is an essential matrix, \(p_1\) and \(p_2\) are corresponding points in the first and the
+ second images, respectively. The result of this function may be passed further to
+ #decomposeEssentialMat or #recoverPose to recover the relative pose between cameras.
public static Mat findEssentialMat(Mat points1,
+ Mat points2,
+ Mat cameraMatrix,
+ int method,
+ double prob,
+ double threshold,
+ int maxIters)
+
Calculates an essential matrix from the corresponding points in two images.
+
+
Parameters:
+
points1 - Array of N (N >= 5) 2D points from the first image. The point coordinates should
+ be floating-point (single or double precision).
+
points2 - Array of the second image points of the same size and format as points1 .
+
cameraMatrix - Camera intrinsic matrix \(\cameramatrix{A}\) .
+ Note that this function assumes that points1 and points2 are feature points from cameras with the
+ same camera intrinsic matrix. If this assumption does not hold for your use case, use
+ #undistortPoints with P = cv::NoArray() for both cameras to transform image points
+ to normalized image coordinates, which are valid for the identity camera intrinsic matrix. When
+ passing these coordinates, pass the identity matrix for this parameter.
+
method - Method for computing an essential matrix.
+
+
+ REF: RANSAC for the RANSAC algorithm.
+
+
+ REF: LMEDS for the LMedS algorithm.
+
+
+
prob - Parameter used for the RANSAC or LMedS methods only. It specifies a desirable level of
+ confidence (probability) that the estimated matrix is correct.
+
threshold - Parameter used for RANSAC. It is the maximum distance from a point to an epipolar
+ line in pixels, beyond which the point is considered an outlier and is not used for computing the
+ final fundamental matrix. It can be set to something like 1-3, depending on the accuracy of the
+ point localization, image resolution, and the image noise.
+ for the other points. The array is computed only in the RANSAC and LMedS methods.
+
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:
+
+ \([p_2; 1]^T K^{-T} E K^{-1} [p_1; 1] = 0\)
+
+ where \(E\) is an essential matrix, \(p_1\) and \(p_2\) are corresponding points in the first and the
+ second images, respectively. The result of this function may be passed further to
+ #decomposeEssentialMat or #recoverPose to recover the relative pose between cameras.
public static Mat findEssentialMat(Mat points1,
+ Mat points2,
+ Mat cameraMatrix,
+ int method,
+ double prob,
+ double threshold,
+ int maxIters,
+ Mat mask)
+
Calculates an essential matrix from the corresponding points in two images.
+
+
Parameters:
+
points1 - Array of N (N >= 5) 2D points from the first image. The point coordinates should
+ be floating-point (single or double precision).
+
points2 - Array of the second image points of the same size and format as points1 .
+
cameraMatrix - Camera intrinsic matrix \(\cameramatrix{A}\) .
+ Note that this function assumes that points1 and points2 are feature points from cameras with the
+ same camera intrinsic matrix. If this assumption does not hold for your use case, use
+ #undistortPoints with P = cv::NoArray() for both cameras to transform image points
+ to normalized image coordinates, which are valid for the identity camera intrinsic matrix. When
+ passing these coordinates, pass the identity matrix for this parameter.
+
method - Method for computing an essential matrix.
+
+
+ REF: RANSAC for the RANSAC algorithm.
+
+
+ REF: LMEDS for the LMedS algorithm.
+
+
+
prob - Parameter used for the RANSAC or LMedS methods only. It specifies a desirable level of
+ confidence (probability) that the estimated matrix is correct.
+
threshold - Parameter used for RANSAC. It is the maximum distance from a point to an epipolar
+ line in pixels, beyond which the point is considered an outlier and is not used for computing the
+ final fundamental matrix. It can be set to something like 1-3, depending on the accuracy of the
+ point localization, image resolution, and the image noise.
+
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.
+
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:
+
+ \([p_2; 1]^T K^{-T} E K^{-1} [p_1; 1] = 0\)
+
+ where \(E\) is an essential matrix, \(p_1\) and \(p_2\) are corresponding points in the first and the
+ second images, respectively. The result of this function may be passed further to
+ #decomposeEssentialMat or #recoverPose to recover the relative pose between cameras.
public static Mat findEssentialMat(Mat points1,
+ Mat points2,
+ Mat cameraMatrix1,
+ Mat distCoeffs1,
+ Mat cameraMatrix2,
+ Mat distCoeffs2)
+
Calculates an essential matrix from the corresponding points in two images from potentially two different cameras.
+
+
Parameters:
+
points1 - Array of N (N >= 5) 2D points from the first image. The point coordinates should
+ be floating-point (single or double precision).
+
points2 - Array of the second image points of the same size and format as points1 .
+
cameraMatrix1 - Camera matrix \(K = \vecthreethree{f_x}{0}{c_x}{0}{f_y}{c_y}{0}{0}{1}\) .
+ Note that this function assumes that points1 and points2 are feature points from cameras with the
+ same camera matrix. If this assumption does not hold for your use case, use
+ #undistortPoints with P = cv::NoArray() for both cameras to transform image points
+ to normalized image coordinates, which are valid for the identity camera matrix. When
+ passing these coordinates, pass the identity matrix for this parameter.
+
cameraMatrix2 - Camera matrix \(K = \vecthreethree{f_x}{0}{c_x}{0}{f_y}{c_y}{0}{0}{1}\) .
+ Note that this function assumes that points1 and points2 are feature points from cameras with the
+ same camera matrix. If this assumption does not hold for your use case, use
+ #undistortPoints with P = cv::NoArray() for both cameras to transform image points
+ to normalized image coordinates, which are valid for the identity camera matrix. When
+ passing these coordinates, pass the identity matrix for this parameter.
+
distCoeffs1 - Input vector of distortion coefficients
+ \((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]]]])\)
+ of 4, 5, 8, 12 or 14 elements. If the vector is NULL/empty, the zero distortion coefficients are assumed.
+
distCoeffs2 - Input vector of distortion coefficients
+ \((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]]]])\)
+ of 4, 5, 8, 12 or 14 elements. If the vector is NULL/empty, the zero distortion coefficients are assumed.
+
+
+ REF: RANSAC for the RANSAC algorithm.
+
+
+ REF: LMEDS for the LMedS algorithm.
+
+
+ confidence (probability) that the estimated matrix is correct.
+ line in pixels, beyond which the point is considered an outlier and is not used for computing the
+ final fundamental matrix. It can be set to something like 1-3, depending on the accuracy of the
+ point localization, image resolution, and the image noise.
+ for the other points. The array is computed only in the RANSAC and LMedS methods.
+
+ 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:
+
+ \([p_2; 1]^T K^{-T} E K^{-1} [p_1; 1] = 0\)
+
+ where \(E\) is an essential matrix, \(p_1\) and \(p_2\) are corresponding points in the first and the
+ second images, respectively. The result of this function may be passed further to
+ #decomposeEssentialMat or #recoverPose to recover the relative pose between cameras.
public static Mat findEssentialMat(Mat points1,
+ Mat points2,
+ Mat cameraMatrix1,
+ Mat distCoeffs1,
+ Mat cameraMatrix2,
+ Mat distCoeffs2,
+ int method)
+
Calculates an essential matrix from the corresponding points in two images from potentially two different cameras.
+
+
Parameters:
+
points1 - Array of N (N >= 5) 2D points from the first image. The point coordinates should
+ be floating-point (single or double precision).
+
points2 - Array of the second image points of the same size and format as points1 .
+
cameraMatrix1 - Camera matrix \(K = \vecthreethree{f_x}{0}{c_x}{0}{f_y}{c_y}{0}{0}{1}\) .
+ Note that this function assumes that points1 and points2 are feature points from cameras with the
+ same camera matrix. If this assumption does not hold for your use case, use
+ #undistortPoints with P = cv::NoArray() for both cameras to transform image points
+ to normalized image coordinates, which are valid for the identity camera matrix. When
+ passing these coordinates, pass the identity matrix for this parameter.
+
cameraMatrix2 - Camera matrix \(K = \vecthreethree{f_x}{0}{c_x}{0}{f_y}{c_y}{0}{0}{1}\) .
+ Note that this function assumes that points1 and points2 are feature points from cameras with the
+ same camera matrix. If this assumption does not hold for your use case, use
+ #undistortPoints with P = cv::NoArray() for both cameras to transform image points
+ to normalized image coordinates, which are valid for the identity camera matrix. When
+ passing these coordinates, pass the identity matrix for this parameter.
+
distCoeffs1 - Input vector of distortion coefficients
+ \((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]]]])\)
+ of 4, 5, 8, 12 or 14 elements. If the vector is NULL/empty, the zero distortion coefficients are assumed.
+
distCoeffs2 - Input vector of distortion coefficients
+ \((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]]]])\)
+ of 4, 5, 8, 12 or 14 elements. If the vector is NULL/empty, the zero distortion coefficients are assumed.
+
method - Method for computing an essential matrix.
+
+
+ REF: RANSAC for the RANSAC algorithm.
+
+
+ REF: LMEDS for the LMedS algorithm.
+
+
+ confidence (probability) that the estimated matrix is correct.
+ line in pixels, beyond which the point is considered an outlier and is not used for computing the
+ final fundamental matrix. It can be set to something like 1-3, depending on the accuracy of the
+ point localization, image resolution, and the image noise.
+ for the other points. The array is computed only in the RANSAC and LMedS methods.
+
+ 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:
+
+ \([p_2; 1]^T K^{-T} E K^{-1} [p_1; 1] = 0\)
+
+ where \(E\) is an essential matrix, \(p_1\) and \(p_2\) are corresponding points in the first and the
+ second images, respectively. The result of this function may be passed further to
+ #decomposeEssentialMat or #recoverPose to recover the relative pose between cameras.
public static Mat findEssentialMat(Mat points1,
+ Mat points2,
+ Mat cameraMatrix1,
+ Mat distCoeffs1,
+ Mat cameraMatrix2,
+ Mat distCoeffs2,
+ int method,
+ double prob)
+
Calculates an essential matrix from the corresponding points in two images from potentially two different cameras.
+
+
Parameters:
+
points1 - Array of N (N >= 5) 2D points from the first image. The point coordinates should
+ be floating-point (single or double precision).
+
points2 - Array of the second image points of the same size and format as points1 .
+
cameraMatrix1 - Camera matrix \(K = \vecthreethree{f_x}{0}{c_x}{0}{f_y}{c_y}{0}{0}{1}\) .
+ Note that this function assumes that points1 and points2 are feature points from cameras with the
+ same camera matrix. If this assumption does not hold for your use case, use
+ #undistortPoints with P = cv::NoArray() for both cameras to transform image points
+ to normalized image coordinates, which are valid for the identity camera matrix. When
+ passing these coordinates, pass the identity matrix for this parameter.
+
cameraMatrix2 - Camera matrix \(K = \vecthreethree{f_x}{0}{c_x}{0}{f_y}{c_y}{0}{0}{1}\) .
+ Note that this function assumes that points1 and points2 are feature points from cameras with the
+ same camera matrix. If this assumption does not hold for your use case, use
+ #undistortPoints with P = cv::NoArray() for both cameras to transform image points
+ to normalized image coordinates, which are valid for the identity camera matrix. When
+ passing these coordinates, pass the identity matrix for this parameter.
+
distCoeffs1 - Input vector of distortion coefficients
+ \((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]]]])\)
+ of 4, 5, 8, 12 or 14 elements. If the vector is NULL/empty, the zero distortion coefficients are assumed.
+
distCoeffs2 - Input vector of distortion coefficients
+ \((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]]]])\)
+ of 4, 5, 8, 12 or 14 elements. If the vector is NULL/empty, the zero distortion coefficients are assumed.
+
method - Method for computing an essential matrix.
+
+
+ REF: RANSAC for the RANSAC algorithm.
+
+
+ REF: LMEDS for the LMedS algorithm.
+
+
+
prob - Parameter used for the RANSAC or LMedS methods only. It specifies a desirable level of
+ confidence (probability) that the estimated matrix is correct.
+ line in pixels, beyond which the point is considered an outlier and is not used for computing the
+ final fundamental matrix. It can be set to something like 1-3, depending on the accuracy of the
+ point localization, image resolution, and the image noise.
+ for the other points. The array is computed only in the RANSAC and LMedS methods.
+
+ 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:
+
+ \([p_2; 1]^T K^{-T} E K^{-1} [p_1; 1] = 0\)
+
+ where \(E\) is an essential matrix, \(p_1\) and \(p_2\) are corresponding points in the first and the
+ second images, respectively. The result of this function may be passed further to
+ #decomposeEssentialMat or #recoverPose to recover the relative pose between cameras.
public static Mat findEssentialMat(Mat points1,
+ Mat points2,
+ Mat cameraMatrix1,
+ Mat distCoeffs1,
+ Mat cameraMatrix2,
+ Mat distCoeffs2,
+ int method,
+ double prob,
+ double threshold)
+
Calculates an essential matrix from the corresponding points in two images from potentially two different cameras.
+
+
Parameters:
+
points1 - Array of N (N >= 5) 2D points from the first image. The point coordinates should
+ be floating-point (single or double precision).
+
points2 - Array of the second image points of the same size and format as points1 .
+
cameraMatrix1 - Camera matrix \(K = \vecthreethree{f_x}{0}{c_x}{0}{f_y}{c_y}{0}{0}{1}\) .
+ Note that this function assumes that points1 and points2 are feature points from cameras with the
+ same camera matrix. If this assumption does not hold for your use case, use
+ #undistortPoints with P = cv::NoArray() for both cameras to transform image points
+ to normalized image coordinates, which are valid for the identity camera matrix. When
+ passing these coordinates, pass the identity matrix for this parameter.
+
cameraMatrix2 - Camera matrix \(K = \vecthreethree{f_x}{0}{c_x}{0}{f_y}{c_y}{0}{0}{1}\) .
+ Note that this function assumes that points1 and points2 are feature points from cameras with the
+ same camera matrix. If this assumption does not hold for your use case, use
+ #undistortPoints with P = cv::NoArray() for both cameras to transform image points
+ to normalized image coordinates, which are valid for the identity camera matrix. When
+ passing these coordinates, pass the identity matrix for this parameter.
+
distCoeffs1 - Input vector of distortion coefficients
+ \((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]]]])\)
+ of 4, 5, 8, 12 or 14 elements. If the vector is NULL/empty, the zero distortion coefficients are assumed.
+
distCoeffs2 - Input vector of distortion coefficients
+ \((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]]]])\)
+ of 4, 5, 8, 12 or 14 elements. If the vector is NULL/empty, the zero distortion coefficients are assumed.
+
method - Method for computing an essential matrix.
+
+
+ REF: RANSAC for the RANSAC algorithm.
+
+
+ REF: LMEDS for the LMedS algorithm.
+
+
+
prob - Parameter used for the RANSAC or LMedS methods only. It specifies a desirable level of
+ confidence (probability) that the estimated matrix is correct.
+
threshold - Parameter used for RANSAC. It is the maximum distance from a point to an epipolar
+ line in pixels, beyond which the point is considered an outlier and is not used for computing the
+ final fundamental matrix. It can be set to something like 1-3, depending on the accuracy of the
+ point localization, image resolution, and the image noise.
+ for the other points. The array is computed only in the RANSAC and LMedS methods.
+
+ 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:
+
+ \([p_2; 1]^T K^{-T} E K^{-1} [p_1; 1] = 0\)
+
+ where \(E\) is an essential matrix, \(p_1\) and \(p_2\) are corresponding points in the first and the
+ second images, respectively. The result of this function may be passed further to
+ #decomposeEssentialMat or #recoverPose to recover the relative pose between cameras.
public static Mat findEssentialMat(Mat points1,
+ Mat points2,
+ Mat cameraMatrix1,
+ Mat distCoeffs1,
+ Mat cameraMatrix2,
+ Mat distCoeffs2,
+ int method,
+ double prob,
+ double threshold,
+ Mat mask)
+
Calculates an essential matrix from the corresponding points in two images from potentially two different cameras.
+
+
Parameters:
+
points1 - Array of N (N >= 5) 2D points from the first image. The point coordinates should
+ be floating-point (single or double precision).
+
points2 - Array of the second image points of the same size and format as points1 .
+
cameraMatrix1 - Camera matrix \(K = \vecthreethree{f_x}{0}{c_x}{0}{f_y}{c_y}{0}{0}{1}\) .
+ Note that this function assumes that points1 and points2 are feature points from cameras with the
+ same camera matrix. If this assumption does not hold for your use case, use
+ #undistortPoints with P = cv::NoArray() for both cameras to transform image points
+ to normalized image coordinates, which are valid for the identity camera matrix. When
+ passing these coordinates, pass the identity matrix for this parameter.
+
cameraMatrix2 - Camera matrix \(K = \vecthreethree{f_x}{0}{c_x}{0}{f_y}{c_y}{0}{0}{1}\) .
+ Note that this function assumes that points1 and points2 are feature points from cameras with the
+ same camera matrix. If this assumption does not hold for your use case, use
+ #undistortPoints with P = cv::NoArray() for both cameras to transform image points
+ to normalized image coordinates, which are valid for the identity camera matrix. When
+ passing these coordinates, pass the identity matrix for this parameter.
+
distCoeffs1 - Input vector of distortion coefficients
+ \((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]]]])\)
+ of 4, 5, 8, 12 or 14 elements. If the vector is NULL/empty, the zero distortion coefficients are assumed.
+
distCoeffs2 - Input vector of distortion coefficients
+ \((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]]]])\)
+ of 4, 5, 8, 12 or 14 elements. If the vector is NULL/empty, the zero distortion coefficients are assumed.
+
method - Method for computing an essential matrix.
+
+
+ REF: RANSAC for the RANSAC algorithm.
+
+
+ REF: LMEDS for the LMedS algorithm.
+
+
+
prob - Parameter used for the RANSAC or LMedS methods only. It specifies a desirable level of
+ confidence (probability) that the estimated matrix is correct.
+
threshold - Parameter used for RANSAC. It is the maximum distance from a point to an epipolar
+ line in pixels, beyond which the point is considered an outlier and is not used for computing the
+ final fundamental matrix. It can be set to something like 1-3, depending on the accuracy of the
+ point localization, image resolution, and the image noise.
+
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.
+
+ 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:
+
+ \([p_2; 1]^T K^{-T} E K^{-1} [p_1; 1] = 0\)
+
+ where \(E\) is an essential matrix, \(p_1\) and \(p_2\) are corresponding points in the first and the
+ second images, respectively. The result of this function may be passed further to
+ #decomposeEssentialMat or #recoverPose to recover the relative pose between cameras.
public static Mat findEssentialMat(Mat points1,
+ Mat points2,
+ Mat cameraMatrix1,
+ Mat cameraMatrix2,
+ Mat dist_coeff1,
+ Mat dist_coeff2,
+ Mat mask,
+ UsacParams params)
public static Mat findFundamentalMat(MatOfPoint2f points1,
+ MatOfPoint2f points2,
+ int method,
+ double ransacReprojThreshold,
+ double confidence,
+ int maxIters)
+
Calculates a fundamental matrix from the corresponding points in two images.
+
+
Parameters:
+
points1 - Array of N points from the first image. The point coordinates should be
+ floating-point (single or double precision).
+
points2 - Array of the second image points of the same size and format as points1 .
+
method - Method for computing a fundamental matrix.
+
+
+ REF: FM_7POINT for a 7-point algorithm. \(N = 7\)
+
+
+ REF: FM_8POINT for an 8-point algorithm. \(N \ge 8\)
+
+
+ REF: FM_RANSAC for the RANSAC algorithm. \(N \ge 8\)
+
+
+ REF: FM_LMEDS for the LMedS algorithm. \(N \ge 8\)
+
+
+
ransacReprojThreshold - Parameter used only for RANSAC. It is the maximum distance from a point to an epipolar
+ line in pixels, beyond which the point is considered an outlier and is not used for computing the
+ final fundamental matrix. It can be set to something like 1-3, depending on the accuracy of the
+ point localization, image resolution, and the image noise.
+
confidence - Parameter used for the RANSAC and LMedS methods only. It specifies a desirable level
+ of confidence (probability) that the estimated matrix is correct.
+
maxIters - The maximum number of robust method iterations.
+
+ The epipolar geometry is described by the following equation:
+
+ \([p_2; 1]^T F [p_1; 1] = 0\)
+
+ where \(F\) is a fundamental matrix, \(p_1\) and \(p_2\) are corresponding points in the first and the
+ second images, respectively.
+
+ The function calculates the fundamental matrix using one of four methods listed above and returns
+ the found fundamental matrix. Normally just one matrix is found. But in case of the 7-point
+ algorithm, the function may return up to 3 solutions ( \(9 \times 3\) matrix that stores all 3
+ matrices sequentially).
+
+ The calculated fundamental matrix may be passed further to #computeCorrespondEpilines that finds the
+ epipolar lines corresponding to the specified points. It can also be passed to
+ #stereoRectifyUncalibrated to compute the rectification transformation. :
+
+ // Example. Estimation of fundamental matrix using the RANSAC algorithm
+ int point_count = 100;
+ vector<Point2f> points1(point_count);
+ vector<Point2f> points2(point_count);
+
+ // initialize the points here ...
+ for( int i = 0; i < point_count; i++ )
+ {
+ points1[i] = ...;
+ points2[i] = ...;
+ }
+
+ Mat fundamental_matrix =
+ findFundamentalMat(points1, points2, FM_RANSAC, 3, 0.99);
+
public static Mat findFundamentalMat(MatOfPoint2f points1,
+ MatOfPoint2f points2,
+ int method,
+ double ransacReprojThreshold,
+ double confidence,
+ int maxIters,
+ Mat mask)
+
Calculates a fundamental matrix from the corresponding points in two images.
+
+
Parameters:
+
points1 - Array of N points from the first image. The point coordinates should be
+ floating-point (single or double precision).
+
points2 - Array of the second image points of the same size and format as points1 .
+
method - Method for computing a fundamental matrix.
+
+
+ REF: FM_7POINT for a 7-point algorithm. \(N = 7\)
+
+
+ REF: FM_8POINT for an 8-point algorithm. \(N \ge 8\)
+
+
+ REF: FM_RANSAC for the RANSAC algorithm. \(N \ge 8\)
+
+
+ REF: FM_LMEDS for the LMedS algorithm. \(N \ge 8\)
+
+
+
ransacReprojThreshold - Parameter used only for RANSAC. It is the maximum distance from a point to an epipolar
+ line in pixels, beyond which the point is considered an outlier and is not used for computing the
+ final fundamental matrix. It can be set to something like 1-3, depending on the accuracy of the
+ point localization, image resolution, and the image noise.
+
confidence - Parameter used for the RANSAC and LMedS methods only. It specifies a desirable level
+ of confidence (probability) that the estimated matrix is correct.
+
mask - optional output mask
+
maxIters - The maximum number of robust method iterations.
+
+ The epipolar geometry is described by the following equation:
+
+ \([p_2; 1]^T F [p_1; 1] = 0\)
+
+ where \(F\) is a fundamental matrix, \(p_1\) and \(p_2\) are corresponding points in the first and the
+ second images, respectively.
+
+ The function calculates the fundamental matrix using one of four methods listed above and returns
+ the found fundamental matrix. Normally just one matrix is found. But in case of the 7-point
+ algorithm, the function may return up to 3 solutions ( \(9 \times 3\) matrix that stores all 3
+ matrices sequentially).
+
+ The calculated fundamental matrix may be passed further to #computeCorrespondEpilines that finds the
+ epipolar lines corresponding to the specified points. It can also be passed to
+ #stereoRectifyUncalibrated to compute the rectification transformation. :
+
+ // Example. Estimation of fundamental matrix using the RANSAC algorithm
+ int point_count = 100;
+ vector<Point2f> points1(point_count);
+ vector<Point2f> points2(point_count);
+
+ // initialize the points here ...
+ for( int i = 0; i < point_count; i++ )
+ {
+ points1[i] = ...;
+ points2[i] = ...;
+ }
+
+ Mat fundamental_matrix =
+ findFundamentalMat(points1, points2, FM_RANSAC, 3, 0.99);
+
public static Mat findFundamentalMat(MatOfPoint2f points1,
+ MatOfPoint2f points2,
+ int method,
+ double ransacReprojThreshold,
+ double confidence,
+ Mat mask)
Finds a perspective transformation between two planes.
+
+
Parameters:
+
srcPoints - Coordinates of the points in the original plane, a matrix of the type CV_32FC2
+ or vector<Point2f> .
+
dstPoints - Coordinates of the points in the target plane, a matrix of the type CV_32FC2 or
+ a vector<Point2f> .
+
+
+ 0 - a regular method using all the points, i.e., the least squares method
+
+
+ REF: RANSAC - RANSAC-based robust method
+
+
+ REF: LMEDS - Least-Median robust method
+
+
+ REF: RHO - PROSAC-based robust method
+
+
+ (used in the RANSAC and RHO methods only). That is, if
+ \(\| \texttt{dstPoints} _i - \texttt{convertPointsHomogeneous} ( \texttt{H} \cdot \texttt{srcPoints} _i) \|_2 > \texttt{ransacReprojThreshold}\)
+ then the point \(i\) is considered as an outlier. If srcPoints and dstPoints are measured in pixels,
+ it usually makes sense to set this parameter somewhere in the range of 1 to 10.
+ mask values are ignored.
+
+ The function finds and returns the perspective transformation \(H\) between the source and the
+ destination planes:
+
+ \(s_i \vecthree{x'_i}{y'_i}{1} \sim H \vecthree{x_i}{y_i}{1}\)
+
+ so that the back-projection error
+
+ \(\sum _i \left ( x'_i- \frac{h_{11} x_i + h_{12} y_i + h_{13}}{h_{31} x_i + h_{32} y_i + h_{33}} \right )^2+ \left ( y'_i- \frac{h_{21} x_i + h_{22} y_i + h_{23}}{h_{31} x_i + h_{32} y_i + h_{33}} \right )^2\)
+
+ is minimized. If the parameter method is set to the default value 0, the function uses all the point
+ pairs to compute an initial homography estimate with a simple least-squares scheme.
+
+ However, if not all of the point pairs ( \(srcPoints_i\), \(dstPoints_i\) ) fit the rigid perspective
+ transformation (that is, there are some outliers), this initial estimate will be poor. In this case,
+ you can use one of the three robust methods. The methods RANSAC, LMeDS and RHO try many different
+ random subsets of the corresponding point pairs (of four pairs each, collinear pairs are discarded), estimate the homography matrix
+ using this subset and a simple least-squares algorithm, and then compute the quality/goodness of the
+ computed homography (which is the number of inliers for RANSAC or the least median re-projection error for
+ LMeDS). The best subset is then used to produce the initial estimate of the homography matrix and
+ the mask of inliers/outliers.
+
+ Regardless of the method, robust or not, the computed homography matrix is refined further (using
+ inliers only in case of a robust method) with the Levenberg-Marquardt method to reduce the
+ re-projection error even more.
+
+ The methods RANSAC and RHO can handle practically any ratio of outliers but need a threshold to
+ distinguish inliers from outliers. The method LMeDS does not need any threshold but it works
+ correctly only when there are more than 50% of inliers. Finally, if there are no outliers and the
+ noise is rather small, use the default method (method=0).
+
+ The function is used to find initial intrinsic and extrinsic matrices. Homography matrix is
+ determined up to a scale. Thus, it is normalized so that \(h_{33}=1\). Note that whenever an \(H\) matrix
+ cannot be estimated, an empty one will be returned.
+
+ SEE:
+ getAffineTransform, estimateAffine2D, estimateAffinePartial2D, getPerspectiveTransform, warpPerspective,
+ perspectiveTransform
Finds a perspective transformation between two planes.
+
+
Parameters:
+
srcPoints - Coordinates of the points in the original plane, a matrix of the type CV_32FC2
+ or vector<Point2f> .
+
dstPoints - Coordinates of the points in the target plane, a matrix of the type CV_32FC2 or
+ a vector<Point2f> .
+
method - Method used to compute a homography matrix. The following methods are possible:
+
+
+ 0 - a regular method using all the points, i.e., the least squares method
+
+
+ REF: RANSAC - RANSAC-based robust method
+
+
+ REF: LMEDS - Least-Median robust method
+
+
+ REF: RHO - PROSAC-based robust method
+
+
+ (used in the RANSAC and RHO methods only). That is, if
+ \(\| \texttt{dstPoints} _i - \texttt{convertPointsHomogeneous} ( \texttt{H} \cdot \texttt{srcPoints} _i) \|_2 > \texttt{ransacReprojThreshold}\)
+ then the point \(i\) is considered as an outlier. If srcPoints and dstPoints are measured in pixels,
+ it usually makes sense to set this parameter somewhere in the range of 1 to 10.
+ mask values are ignored.
+
+ The function finds and returns the perspective transformation \(H\) between the source and the
+ destination planes:
+
+ \(s_i \vecthree{x'_i}{y'_i}{1} \sim H \vecthree{x_i}{y_i}{1}\)
+
+ so that the back-projection error
+
+ \(\sum _i \left ( x'_i- \frac{h_{11} x_i + h_{12} y_i + h_{13}}{h_{31} x_i + h_{32} y_i + h_{33}} \right )^2+ \left ( y'_i- \frac{h_{21} x_i + h_{22} y_i + h_{23}}{h_{31} x_i + h_{32} y_i + h_{33}} \right )^2\)
+
+ is minimized. If the parameter method is set to the default value 0, the function uses all the point
+ pairs to compute an initial homography estimate with a simple least-squares scheme.
+
+ However, if not all of the point pairs ( \(srcPoints_i\), \(dstPoints_i\) ) fit the rigid perspective
+ transformation (that is, there are some outliers), this initial estimate will be poor. In this case,
+ you can use one of the three robust methods. The methods RANSAC, LMeDS and RHO try many different
+ random subsets of the corresponding point pairs (of four pairs each, collinear pairs are discarded), estimate the homography matrix
+ using this subset and a simple least-squares algorithm, and then compute the quality/goodness of the
+ computed homography (which is the number of inliers for RANSAC or the least median re-projection error for
+ LMeDS). The best subset is then used to produce the initial estimate of the homography matrix and
+ the mask of inliers/outliers.
+
+ Regardless of the method, robust or not, the computed homography matrix is refined further (using
+ inliers only in case of a robust method) with the Levenberg-Marquardt method to reduce the
+ re-projection error even more.
+
+ The methods RANSAC and RHO can handle practically any ratio of outliers but need a threshold to
+ distinguish inliers from outliers. The method LMeDS does not need any threshold but it works
+ correctly only when there are more than 50% of inliers. Finally, if there are no outliers and the
+ noise is rather small, use the default method (method=0).
+
+ The function is used to find initial intrinsic and extrinsic matrices. Homography matrix is
+ determined up to a scale. Thus, it is normalized so that \(h_{33}=1\). Note that whenever an \(H\) matrix
+ cannot be estimated, an empty one will be returned.
+
+ SEE:
+ getAffineTransform, estimateAffine2D, estimateAffinePartial2D, getPerspectiveTransform, warpPerspective,
+ perspectiveTransform
public static Mat findHomography(MatOfPoint2f srcPoints,
+ MatOfPoint2f dstPoints,
+ int method,
+ double ransacReprojThreshold)
+
Finds a perspective transformation between two planes.
+
+
Parameters:
+
srcPoints - Coordinates of the points in the original plane, a matrix of the type CV_32FC2
+ or vector<Point2f> .
+
dstPoints - Coordinates of the points in the target plane, a matrix of the type CV_32FC2 or
+ a vector<Point2f> .
+
method - Method used to compute a homography matrix. The following methods are possible:
+
+
+ 0 - a regular method using all the points, i.e., the least squares method
+
+
+ REF: RANSAC - RANSAC-based robust method
+
+
+ REF: LMEDS - Least-Median robust method
+
+
+ REF: RHO - PROSAC-based robust method
+
+
+
ransacReprojThreshold - Maximum allowed reprojection error to treat a point pair as an inlier
+ (used in the RANSAC and RHO methods only). That is, if
+ \(\| \texttt{dstPoints} _i - \texttt{convertPointsHomogeneous} ( \texttt{H} \cdot \texttt{srcPoints} _i) \|_2 > \texttt{ransacReprojThreshold}\)
+ then the point \(i\) is considered as an outlier. If srcPoints and dstPoints are measured in pixels,
+ it usually makes sense to set this parameter somewhere in the range of 1 to 10.
+ mask values are ignored.
+
+ The function finds and returns the perspective transformation \(H\) between the source and the
+ destination planes:
+
+ \(s_i \vecthree{x'_i}{y'_i}{1} \sim H \vecthree{x_i}{y_i}{1}\)
+
+ so that the back-projection error
+
+ \(\sum _i \left ( x'_i- \frac{h_{11} x_i + h_{12} y_i + h_{13}}{h_{31} x_i + h_{32} y_i + h_{33}} \right )^2+ \left ( y'_i- \frac{h_{21} x_i + h_{22} y_i + h_{23}}{h_{31} x_i + h_{32} y_i + h_{33}} \right )^2\)
+
+ is minimized. If the parameter method is set to the default value 0, the function uses all the point
+ pairs to compute an initial homography estimate with a simple least-squares scheme.
+
+ However, if not all of the point pairs ( \(srcPoints_i\), \(dstPoints_i\) ) fit the rigid perspective
+ transformation (that is, there are some outliers), this initial estimate will be poor. In this case,
+ you can use one of the three robust methods. The methods RANSAC, LMeDS and RHO try many different
+ random subsets of the corresponding point pairs (of four pairs each, collinear pairs are discarded), estimate the homography matrix
+ using this subset and a simple least-squares algorithm, and then compute the quality/goodness of the
+ computed homography (which is the number of inliers for RANSAC or the least median re-projection error for
+ LMeDS). The best subset is then used to produce the initial estimate of the homography matrix and
+ the mask of inliers/outliers.
+
+ Regardless of the method, robust or not, the computed homography matrix is refined further (using
+ inliers only in case of a robust method) with the Levenberg-Marquardt method to reduce the
+ re-projection error even more.
+
+ The methods RANSAC and RHO can handle practically any ratio of outliers but need a threshold to
+ distinguish inliers from outliers. The method LMeDS does not need any threshold but it works
+ correctly only when there are more than 50% of inliers. Finally, if there are no outliers and the
+ noise is rather small, use the default method (method=0).
+
+ The function is used to find initial intrinsic and extrinsic matrices. Homography matrix is
+ determined up to a scale. Thus, it is normalized so that \(h_{33}=1\). Note that whenever an \(H\) matrix
+ cannot be estimated, an empty one will be returned.
+
+ SEE:
+ getAffineTransform, estimateAffine2D, estimateAffinePartial2D, getPerspectiveTransform, warpPerspective,
+ perspectiveTransform
public static Mat findHomography(MatOfPoint2f srcPoints,
+ MatOfPoint2f dstPoints,
+ int method,
+ double ransacReprojThreshold,
+ Mat mask)
+
Finds a perspective transformation between two planes.
+
+
Parameters:
+
srcPoints - Coordinates of the points in the original plane, a matrix of the type CV_32FC2
+ or vector<Point2f> .
+
dstPoints - Coordinates of the points in the target plane, a matrix of the type CV_32FC2 or
+ a vector<Point2f> .
+
method - Method used to compute a homography matrix. The following methods are possible:
+
+
+ 0 - a regular method using all the points, i.e., the least squares method
+
+
+ REF: RANSAC - RANSAC-based robust method
+
+
+ REF: LMEDS - Least-Median robust method
+
+
+ REF: RHO - PROSAC-based robust method
+
+
+
ransacReprojThreshold - Maximum allowed reprojection error to treat a point pair as an inlier
+ (used in the RANSAC and RHO methods only). That is, if
+ \(\| \texttt{dstPoints} _i - \texttt{convertPointsHomogeneous} ( \texttt{H} \cdot \texttt{srcPoints} _i) \|_2 > \texttt{ransacReprojThreshold}\)
+ then the point \(i\) is considered as an outlier. If srcPoints and dstPoints are measured in pixels,
+ it usually makes sense to set this parameter somewhere in the range of 1 to 10.
+
mask - Optional output mask set by a robust method ( RANSAC or LMeDS ). Note that the input
+ mask values are ignored.
+
+ The function finds and returns the perspective transformation \(H\) between the source and the
+ destination planes:
+
+ \(s_i \vecthree{x'_i}{y'_i}{1} \sim H \vecthree{x_i}{y_i}{1}\)
+
+ so that the back-projection error
+
+ \(\sum _i \left ( x'_i- \frac{h_{11} x_i + h_{12} y_i + h_{13}}{h_{31} x_i + h_{32} y_i + h_{33}} \right )^2+ \left ( y'_i- \frac{h_{21} x_i + h_{22} y_i + h_{23}}{h_{31} x_i + h_{32} y_i + h_{33}} \right )^2\)
+
+ is minimized. If the parameter method is set to the default value 0, the function uses all the point
+ pairs to compute an initial homography estimate with a simple least-squares scheme.
+
+ However, if not all of the point pairs ( \(srcPoints_i\), \(dstPoints_i\) ) fit the rigid perspective
+ transformation (that is, there are some outliers), this initial estimate will be poor. In this case,
+ you can use one of the three robust methods. The methods RANSAC, LMeDS and RHO try many different
+ random subsets of the corresponding point pairs (of four pairs each, collinear pairs are discarded), estimate the homography matrix
+ using this subset and a simple least-squares algorithm, and then compute the quality/goodness of the
+ computed homography (which is the number of inliers for RANSAC or the least median re-projection error for
+ LMeDS). The best subset is then used to produce the initial estimate of the homography matrix and
+ the mask of inliers/outliers.
+
+ Regardless of the method, robust or not, the computed homography matrix is refined further (using
+ inliers only in case of a robust method) with the Levenberg-Marquardt method to reduce the
+ re-projection error even more.
+
+ The methods RANSAC and RHO can handle practically any ratio of outliers but need a threshold to
+ distinguish inliers from outliers. The method LMeDS does not need any threshold but it works
+ correctly only when there are more than 50% of inliers. Finally, if there are no outliers and the
+ noise is rather small, use the default method (method=0).
+
+ The function is used to find initial intrinsic and extrinsic matrices. Homography matrix is
+ determined up to a scale. Thus, it is normalized so that \(h_{33}=1\). Note that whenever an \(H\) matrix
+ cannot be estimated, an empty one will be returned.
+
+ SEE:
+ getAffineTransform, estimateAffine2D, estimateAffinePartial2D, getPerspectiveTransform, warpPerspective,
+ perspectiveTransform
public static Mat findHomography(MatOfPoint2f srcPoints,
+ MatOfPoint2f dstPoints,
+ int method,
+ double ransacReprojThreshold,
+ Mat mask,
+ int maxIters)
+
Finds a perspective transformation between two planes.
+
+
Parameters:
+
srcPoints - Coordinates of the points in the original plane, a matrix of the type CV_32FC2
+ or vector<Point2f> .
+
dstPoints - Coordinates of the points in the target plane, a matrix of the type CV_32FC2 or
+ a vector<Point2f> .
+
method - Method used to compute a homography matrix. The following methods are possible:
+
+
+ 0 - a regular method using all the points, i.e., the least squares method
+
+
+ REF: RANSAC - RANSAC-based robust method
+
+
+ REF: LMEDS - Least-Median robust method
+
+
+ REF: RHO - PROSAC-based robust method
+
+
+
ransacReprojThreshold - Maximum allowed reprojection error to treat a point pair as an inlier
+ (used in the RANSAC and RHO methods only). That is, if
+ \(\| \texttt{dstPoints} _i - \texttt{convertPointsHomogeneous} ( \texttt{H} \cdot \texttt{srcPoints} _i) \|_2 > \texttt{ransacReprojThreshold}\)
+ then the point \(i\) is considered as an outlier. If srcPoints and dstPoints are measured in pixels,
+ it usually makes sense to set this parameter somewhere in the range of 1 to 10.
+
mask - Optional output mask set by a robust method ( RANSAC or LMeDS ). Note that the input
+ mask values are ignored.
+
maxIters - The maximum number of RANSAC iterations.
+
+ The function finds and returns the perspective transformation \(H\) between the source and the
+ destination planes:
+
+ \(s_i \vecthree{x'_i}{y'_i}{1} \sim H \vecthree{x_i}{y_i}{1}\)
+
+ so that the back-projection error
+
+ \(\sum _i \left ( x'_i- \frac{h_{11} x_i + h_{12} y_i + h_{13}}{h_{31} x_i + h_{32} y_i + h_{33}} \right )^2+ \left ( y'_i- \frac{h_{21} x_i + h_{22} y_i + h_{23}}{h_{31} x_i + h_{32} y_i + h_{33}} \right )^2\)
+
+ is minimized. If the parameter method is set to the default value 0, the function uses all the point
+ pairs to compute an initial homography estimate with a simple least-squares scheme.
+
+ However, if not all of the point pairs ( \(srcPoints_i\), \(dstPoints_i\) ) fit the rigid perspective
+ transformation (that is, there are some outliers), this initial estimate will be poor. In this case,
+ you can use one of the three robust methods. The methods RANSAC, LMeDS and RHO try many different
+ random subsets of the corresponding point pairs (of four pairs each, collinear pairs are discarded), estimate the homography matrix
+ using this subset and a simple least-squares algorithm, and then compute the quality/goodness of the
+ computed homography (which is the number of inliers for RANSAC or the least median re-projection error for
+ LMeDS). The best subset is then used to produce the initial estimate of the homography matrix and
+ the mask of inliers/outliers.
+
+ Regardless of the method, robust or not, the computed homography matrix is refined further (using
+ inliers only in case of a robust method) with the Levenberg-Marquardt method to reduce the
+ re-projection error even more.
+
+ The methods RANSAC and RHO can handle practically any ratio of outliers but need a threshold to
+ distinguish inliers from outliers. The method LMeDS does not need any threshold but it works
+ correctly only when there are more than 50% of inliers. Finally, if there are no outliers and the
+ noise is rather small, use the default method (method=0).
+
+ The function is used to find initial intrinsic and extrinsic matrices. Homography matrix is
+ determined up to a scale. Thus, it is normalized so that \(h_{33}=1\). Note that whenever an \(H\) matrix
+ cannot be estimated, an empty one will be returned.
+
+ SEE:
+ getAffineTransform, estimateAffine2D, estimateAffinePartial2D, getPerspectiveTransform, warpPerspective,
+ perspectiveTransform
public static Mat findHomography(MatOfPoint2f srcPoints,
+ MatOfPoint2f dstPoints,
+ int method,
+ double ransacReprojThreshold,
+ Mat mask,
+ int maxIters,
+ double confidence)
+
Finds a perspective transformation between two planes.
+
+
Parameters:
+
srcPoints - Coordinates of the points in the original plane, a matrix of the type CV_32FC2
+ or vector<Point2f> .
+
dstPoints - Coordinates of the points in the target plane, a matrix of the type CV_32FC2 or
+ a vector<Point2f> .
+
method - Method used to compute a homography matrix. The following methods are possible:
+
+
+ 0 - a regular method using all the points, i.e., the least squares method
+
+
+ REF: RANSAC - RANSAC-based robust method
+
+
+ REF: LMEDS - Least-Median robust method
+
+
+ REF: RHO - PROSAC-based robust method
+
+
+
ransacReprojThreshold - Maximum allowed reprojection error to treat a point pair as an inlier
+ (used in the RANSAC and RHO methods only). That is, if
+ \(\| \texttt{dstPoints} _i - \texttt{convertPointsHomogeneous} ( \texttt{H} \cdot \texttt{srcPoints} _i) \|_2 > \texttt{ransacReprojThreshold}\)
+ then the point \(i\) is considered as an outlier. If srcPoints and dstPoints are measured in pixels,
+ it usually makes sense to set this parameter somewhere in the range of 1 to 10.
+
mask - Optional output mask set by a robust method ( RANSAC or LMeDS ). Note that the input
+ mask values are ignored.
+
maxIters - The maximum number of RANSAC iterations.
+
confidence - Confidence level, between 0 and 1.
+
+ The function finds and returns the perspective transformation \(H\) between the source and the
+ destination planes:
+
+ \(s_i \vecthree{x'_i}{y'_i}{1} \sim H \vecthree{x_i}{y_i}{1}\)
+
+ so that the back-projection error
+
+ \(\sum _i \left ( x'_i- \frac{h_{11} x_i + h_{12} y_i + h_{13}}{h_{31} x_i + h_{32} y_i + h_{33}} \right )^2+ \left ( y'_i- \frac{h_{21} x_i + h_{22} y_i + h_{23}}{h_{31} x_i + h_{32} y_i + h_{33}} \right )^2\)
+
+ is minimized. If the parameter method is set to the default value 0, the function uses all the point
+ pairs to compute an initial homography estimate with a simple least-squares scheme.
+
+ However, if not all of the point pairs ( \(srcPoints_i\), \(dstPoints_i\) ) fit the rigid perspective
+ transformation (that is, there are some outliers), this initial estimate will be poor. In this case,
+ you can use one of the three robust methods. The methods RANSAC, LMeDS and RHO try many different
+ random subsets of the corresponding point pairs (of four pairs each, collinear pairs are discarded), estimate the homography matrix
+ using this subset and a simple least-squares algorithm, and then compute the quality/goodness of the
+ computed homography (which is the number of inliers for RANSAC or the least median re-projection error for
+ LMeDS). The best subset is then used to produce the initial estimate of the homography matrix and
+ the mask of inliers/outliers.
+
+ Regardless of the method, robust or not, the computed homography matrix is refined further (using
+ inliers only in case of a robust method) with the Levenberg-Marquardt method to reduce the
+ re-projection error even more.
+
+ The methods RANSAC and RHO can handle practically any ratio of outliers but need a threshold to
+ distinguish inliers from outliers. The method LMeDS does not need any threshold but it works
+ correctly only when there are more than 50% of inliers. Finally, if there are no outliers and the
+ noise is rather small, use the default method (method=0).
+
+ The function is used to find initial intrinsic and extrinsic matrices. Homography matrix is
+ determined up to a scale. Thus, it is normalized so that \(h_{33}=1\). Note that whenever an \(H\) matrix
+ cannot be estimated, an empty one will be returned.
+
+ SEE:
+ getAffineTransform, estimateAffine2D, estimateAffinePartial2D, getPerspectiveTransform, warpPerspective,
+ perspectiveTransform
public static double fisheye_calibrate(java.util.List<Mat> objectPoints,
+ java.util.List<Mat> imagePoints,
+ Size image_size,
+ Mat K,
+ Mat D,
+ java.util.List<Mat> rvecs,
+ java.util.List<Mat> tvecs)
+
Performs camera calibration
+
+
Parameters:
+
objectPoints - vector of vectors of calibration pattern points in the calibration pattern
+ coordinate space.
+
imagePoints - vector of vectors of the projections of calibration pattern points.
+ imagePoints.size() and objectPoints.size() and imagePoints[i].size() must be equal to
+ objectPoints[i].size() for each i.
+
image_size - Size of the image used only to initialize the camera intrinsic matrix.
+
K - Output 3x3 floating-point camera intrinsic matrix
+ \(\cameramatrix{A}\) . If
+ REF: fisheye::CALIB_USE_INTRINSIC_GUESS is specified, some or all of fx, fy, cx, cy must be
+ initialized before calling the function.
+
D - Output vector of distortion coefficients \(\distcoeffsfisheye\).
+
rvecs - Output vector of rotation vectors (see Rodrigues ) estimated for each pattern view.
+ That is, each k-th rotation vector together with the corresponding k-th translation vector (see
+ the next output parameter description) brings the calibration pattern from the model coordinate
+ space (in which object points are specified) to the world coordinate space, that is, a real
+ position of the calibration pattern in the k-th pattern view (k=0.. *M* -1).
+
tvecs - Output vector of translation vectors estimated for each pattern view.
+
+
+ REF: fisheye::CALIB_USE_INTRINSIC_GUESS cameraMatrix contains valid initial values of
+ fx, fy, cx, cy that are optimized further. Otherwise, (cx, cy) is initially set to the image
+ center ( imageSize is used), and focal distances are computed in a least-squares fashion.
+
+
+ REF: fisheye::CALIB_RECOMPUTE_EXTRINSIC Extrinsic will be recomputed after each iteration
+ of intrinsic optimization.
+
+
+ REF: fisheye::CALIB_CHECK_COND The functions will check validity of condition number.
+
+
+ REF: fisheye::CALIB_FIX_SKEW Skew coefficient (alpha) is set to zero and stay zero.
+
+
+ REF: fisheye::CALIB_FIX_K1,..., REF: fisheye::CALIB_FIX_K4 Selected distortion coefficients
+ are set to zeros and stay zero.
+
+
+ REF: fisheye::CALIB_FIX_PRINCIPAL_POINT The principal point is not changed during the global
+ optimization. It stays at the center or at a different location specified when REF: fisheye::CALIB_USE_INTRINSIC_GUESS is set too.
+
+
+ REF: fisheye::CALIB_FIX_FOCAL_LENGTH The focal length is not changed during the global
+ optimization. It is the \(max(width,height)/\pi\) or the provided \(f_x\), \(f_y\) when REF: fisheye::CALIB_USE_INTRINSIC_GUESS is set too.
+
public static double fisheye_calibrate(java.util.List<Mat> objectPoints,
+ java.util.List<Mat> imagePoints,
+ Size image_size,
+ Mat K,
+ Mat D,
+ java.util.List<Mat> rvecs,
+ java.util.List<Mat> tvecs,
+ int flags)
+
Performs camera calibration
+
+
Parameters:
+
objectPoints - vector of vectors of calibration pattern points in the calibration pattern
+ coordinate space.
+
imagePoints - vector of vectors of the projections of calibration pattern points.
+ imagePoints.size() and objectPoints.size() and imagePoints[i].size() must be equal to
+ objectPoints[i].size() for each i.
+
image_size - Size of the image used only to initialize the camera intrinsic matrix.
+
K - Output 3x3 floating-point camera intrinsic matrix
+ \(\cameramatrix{A}\) . If
+ REF: fisheye::CALIB_USE_INTRINSIC_GUESS is specified, some or all of fx, fy, cx, cy must be
+ initialized before calling the function.
+
D - Output vector of distortion coefficients \(\distcoeffsfisheye\).
+
rvecs - Output vector of rotation vectors (see Rodrigues ) estimated for each pattern view.
+ That is, each k-th rotation vector together with the corresponding k-th translation vector (see
+ the next output parameter description) brings the calibration pattern from the model coordinate
+ space (in which object points are specified) to the world coordinate space, that is, a real
+ position of the calibration pattern in the k-th pattern view (k=0.. *M* -1).
+
tvecs - Output vector of translation vectors estimated for each pattern view.
+
flags - Different flags that may be zero or a combination of the following values:
+
+
+ REF: fisheye::CALIB_USE_INTRINSIC_GUESS cameraMatrix contains valid initial values of
+ fx, fy, cx, cy that are optimized further. Otherwise, (cx, cy) is initially set to the image
+ center ( imageSize is used), and focal distances are computed in a least-squares fashion.
+
+
+ REF: fisheye::CALIB_RECOMPUTE_EXTRINSIC Extrinsic will be recomputed after each iteration
+ of intrinsic optimization.
+
+
+ REF: fisheye::CALIB_CHECK_COND The functions will check validity of condition number.
+
+
+ REF: fisheye::CALIB_FIX_SKEW Skew coefficient (alpha) is set to zero and stay zero.
+
+
+ REF: fisheye::CALIB_FIX_K1,..., REF: fisheye::CALIB_FIX_K4 Selected distortion coefficients
+ are set to zeros and stay zero.
+
+
+ REF: fisheye::CALIB_FIX_PRINCIPAL_POINT The principal point is not changed during the global
+ optimization. It stays at the center or at a different location specified when REF: fisheye::CALIB_USE_INTRINSIC_GUESS is set too.
+
+
+ REF: fisheye::CALIB_FIX_FOCAL_LENGTH The focal length is not changed during the global
+ optimization. It is the \(max(width,height)/\pi\) or the provided \(f_x\), \(f_y\) when REF: fisheye::CALIB_USE_INTRINSIC_GUESS is set too.
+
public static double fisheye_calibrate(java.util.List<Mat> objectPoints,
+ java.util.List<Mat> imagePoints,
+ Size image_size,
+ Mat K,
+ Mat D,
+ java.util.List<Mat> rvecs,
+ java.util.List<Mat> tvecs,
+ int flags,
+ TermCriteria criteria)
+
Performs camera calibration
+
+
Parameters:
+
objectPoints - vector of vectors of calibration pattern points in the calibration pattern
+ coordinate space.
+
imagePoints - vector of vectors of the projections of calibration pattern points.
+ imagePoints.size() and objectPoints.size() and imagePoints[i].size() must be equal to
+ objectPoints[i].size() for each i.
+
image_size - Size of the image used only to initialize the camera intrinsic matrix.
+
K - Output 3x3 floating-point camera intrinsic matrix
+ \(\cameramatrix{A}\) . If
+ REF: fisheye::CALIB_USE_INTRINSIC_GUESS is specified, some or all of fx, fy, cx, cy must be
+ initialized before calling the function.
+
D - Output vector of distortion coefficients \(\distcoeffsfisheye\).
+
rvecs - Output vector of rotation vectors (see Rodrigues ) estimated for each pattern view.
+ That is, each k-th rotation vector together with the corresponding k-th translation vector (see
+ the next output parameter description) brings the calibration pattern from the model coordinate
+ space (in which object points are specified) to the world coordinate space, that is, a real
+ position of the calibration pattern in the k-th pattern view (k=0.. *M* -1).
+
tvecs - Output vector of translation vectors estimated for each pattern view.
+
flags - Different flags that may be zero or a combination of the following values:
+
+
+ REF: fisheye::CALIB_USE_INTRINSIC_GUESS cameraMatrix contains valid initial values of
+ fx, fy, cx, cy that are optimized further. Otherwise, (cx, cy) is initially set to the image
+ center ( imageSize is used), and focal distances are computed in a least-squares fashion.
+
+
+ REF: fisheye::CALIB_RECOMPUTE_EXTRINSIC Extrinsic will be recomputed after each iteration
+ of intrinsic optimization.
+
+
+ REF: fisheye::CALIB_CHECK_COND The functions will check validity of condition number.
+
+
+ REF: fisheye::CALIB_FIX_SKEW Skew coefficient (alpha) is set to zero and stay zero.
+
+
+ REF: fisheye::CALIB_FIX_K1,..., REF: fisheye::CALIB_FIX_K4 Selected distortion coefficients
+ are set to zeros and stay zero.
+
+
+ REF: fisheye::CALIB_FIX_PRINCIPAL_POINT The principal point is not changed during the global
+ optimization. It stays at the center or at a different location specified when REF: fisheye::CALIB_USE_INTRINSIC_GUESS is set too.
+
+
+ REF: fisheye::CALIB_FIX_FOCAL_LENGTH The focal length is not changed during the global
+ optimization. It is the \(max(width,height)/\pi\) or the provided \(f_x\), \(f_y\) when REF: fisheye::CALIB_USE_INTRINSIC_GUESS is set too.
+
+
+
criteria - Termination criteria for the iterative optimization algorithm.
public static void fisheye_distortPoints(Mat undistorted,
+ Mat distorted,
+ Mat K,
+ Mat D)
+
Distorts 2D points using fisheye model.
+
+
Parameters:
+
undistorted - Array of object points, 1xN/Nx1 2-channel (or vector<Point2f> ), where N is
+ the number of points in the view.
+
K - Camera intrinsic matrix \(cameramatrix{K}\).
+
D - Input vector of distortion coefficients \(\distcoeffsfisheye\).
+
distorted - Output array of image points, 1xN/Nx1 2-channel, or vector<Point2f> .
+
+ Note that the function assumes the camera intrinsic matrix of the undistorted points to be identity.
+ This means if you want to distort image points you have to multiply them with \(K^{-1}\).
public static void fisheye_distortPoints(Mat undistorted,
+ Mat distorted,
+ Mat K,
+ Mat D,
+ double alpha)
+
Distorts 2D points using fisheye model.
+
+
Parameters:
+
undistorted - Array of object points, 1xN/Nx1 2-channel (or vector<Point2f> ), where N is
+ the number of points in the view.
+
K - Camera intrinsic matrix \(cameramatrix{K}\).
+
D - Input vector of distortion coefficients \(\distcoeffsfisheye\).
+
alpha - The skew coefficient.
+
distorted - Output array of image points, 1xN/Nx1 2-channel, or vector<Point2f> .
+
+ Note that the function assumes the camera intrinsic matrix of the undistorted points to be identity.
+ This means if you want to distort image points you have to multiply them with \(K^{-1}\).
public static void fisheye_initUndistortRectifyMap(Mat K,
+ Mat D,
+ Mat R,
+ Mat P,
+ Size size,
+ int m1type,
+ Mat map1,
+ Mat map2)
+
Computes undistortion and rectification maps for image transform by #remap. If D is empty zero
+ distortion is used, if R or P is empty identity matrixes are used.
+
+
Parameters:
+
K - Camera intrinsic matrix \(cameramatrix{K}\).
+
D - Input vector of distortion coefficients \(\distcoeffsfisheye\).
+
R - Rectification transformation in the object space: 3x3 1-channel, or vector: 3x1/1x3
+ 1-channel or 1x1 3-channel
+
P - New camera intrinsic matrix (3x3) or new projection matrix (3x4)
+
size - Undistorted image size.
+
m1type - Type of the first output map that can be CV_32FC1 or CV_16SC2 . See #convertMaps
+ for details.
public static void fisheye_projectPoints(Mat objectPoints,
+ Mat imagePoints,
+ Mat rvec,
+ Mat tvec,
+ Mat K,
+ Mat D,
+ double alpha,
+ Mat jacobian)
public static double fisheye_stereoCalibrate(java.util.List<Mat> objectPoints,
+ java.util.List<Mat> imagePoints1,
+ java.util.List<Mat> imagePoints2,
+ Mat K1,
+ Mat D1,
+ Mat K2,
+ Mat D2,
+ Size imageSize,
+ Mat R,
+ Mat T)
public static double fisheye_stereoCalibrate(java.util.List<Mat> objectPoints,
+ java.util.List<Mat> imagePoints1,
+ java.util.List<Mat> imagePoints2,
+ Mat K1,
+ Mat D1,
+ Mat K2,
+ Mat D2,
+ Size imageSize,
+ Mat R,
+ Mat T,
+ int flags)
public static double fisheye_stereoCalibrate(java.util.List<Mat> objectPoints,
+ java.util.List<Mat> imagePoints1,
+ java.util.List<Mat> imagePoints2,
+ Mat K1,
+ Mat D1,
+ Mat K2,
+ Mat D2,
+ Size imageSize,
+ Mat R,
+ Mat T,
+ int flags,
+ TermCriteria criteria)
public static double fisheye_stereoCalibrate(java.util.List<Mat> objectPoints,
+ java.util.List<Mat> imagePoints1,
+ java.util.List<Mat> imagePoints2,
+ Mat K1,
+ Mat D1,
+ Mat K2,
+ Mat D2,
+ Size imageSize,
+ Mat R,
+ Mat T,
+ java.util.List<Mat> rvecs,
+ java.util.List<Mat> tvecs)
+
Performs stereo calibration
+
+
Parameters:
+
objectPoints - Vector of vectors of the calibration pattern points.
+
imagePoints1 - Vector of vectors of the projections of the calibration pattern points,
+ observed by the first camera.
+
imagePoints2 - Vector of vectors of the projections of the calibration pattern points,
+ observed by the second camera.
+
K1 - Input/output first camera intrinsic matrix:
+ \(\vecthreethree{f_x^{(j)}}{0}{c_x^{(j)}}{0}{f_y^{(j)}}{c_y^{(j)}}{0}{0}{1}\) , \(j = 0,\, 1\) . If
+ any of REF: fisheye::CALIB_USE_INTRINSIC_GUESS , REF: fisheye::CALIB_FIX_INTRINSIC are specified,
+ some or all of the matrix components must be initialized.
+
D1 - Input/output vector of distortion coefficients \(\distcoeffsfisheye\) of 4 elements.
+
K2 - Input/output second camera intrinsic matrix. The parameter is similar to K1 .
+
D2 - Input/output lens distortion coefficients for the second camera. The parameter is
+ similar to D1 .
+
imageSize - Size of the image used only to initialize camera intrinsic matrix.
+
R - Output rotation matrix between the 1st and the 2nd camera coordinate systems.
+
T - Output translation vector between the coordinate systems of the cameras.
+
rvecs - Output vector of rotation vectors ( REF: Rodrigues ) estimated for each pattern view in the
+ coordinate system of the first camera of the stereo pair (e.g. std::vector<cv::Mat>). More in detail, each
+ i-th rotation vector together with the corresponding i-th translation vector (see the next output parameter
+ description) brings the calibration pattern from the object coordinate space (in which object points are
+ specified) to the camera coordinate space of the first camera of the stereo pair. In more technical terms,
+ the tuple of the i-th rotation and translation vector performs a change of basis from object coordinate space
+ to camera coordinate space of the first camera of the stereo pair.
+
tvecs - Output vector of translation vectors estimated for each pattern view, see parameter description
+ of previous output parameter ( rvecs ).
+
+
+ REF: fisheye::CALIB_FIX_INTRINSIC Fix K1, K2? and D1, D2? so that only R, T matrices
+ are estimated.
+
+
+ REF: fisheye::CALIB_USE_INTRINSIC_GUESS K1, K2 contains valid initial values of
+ fx, fy, cx, cy that are optimized further. Otherwise, (cx, cy) is initially set to the image
+ center (imageSize is used), and focal distances are computed in a least-squares fashion.
+
+
+ REF: fisheye::CALIB_RECOMPUTE_EXTRINSIC Extrinsic will be recomputed after each iteration
+ of intrinsic optimization.
+
+
+ REF: fisheye::CALIB_CHECK_COND The functions will check validity of condition number.
+
+
+ REF: fisheye::CALIB_FIX_SKEW Skew coefficient (alpha) is set to zero and stay zero.
+
+
+ REF: fisheye::CALIB_FIX_K1,..., REF: fisheye::CALIB_FIX_K4 Selected distortion coefficients are set to zeros and stay
+ zero.
+
public static double fisheye_stereoCalibrate(java.util.List<Mat> objectPoints,
+ java.util.List<Mat> imagePoints1,
+ java.util.List<Mat> imagePoints2,
+ Mat K1,
+ Mat D1,
+ Mat K2,
+ Mat D2,
+ Size imageSize,
+ Mat R,
+ Mat T,
+ java.util.List<Mat> rvecs,
+ java.util.List<Mat> tvecs,
+ int flags)
+
Performs stereo calibration
+
+
Parameters:
+
objectPoints - Vector of vectors of the calibration pattern points.
+
imagePoints1 - Vector of vectors of the projections of the calibration pattern points,
+ observed by the first camera.
+
imagePoints2 - Vector of vectors of the projections of the calibration pattern points,
+ observed by the second camera.
+
K1 - Input/output first camera intrinsic matrix:
+ \(\vecthreethree{f_x^{(j)}}{0}{c_x^{(j)}}{0}{f_y^{(j)}}{c_y^{(j)}}{0}{0}{1}\) , \(j = 0,\, 1\) . If
+ any of REF: fisheye::CALIB_USE_INTRINSIC_GUESS , REF: fisheye::CALIB_FIX_INTRINSIC are specified,
+ some or all of the matrix components must be initialized.
+
D1 - Input/output vector of distortion coefficients \(\distcoeffsfisheye\) of 4 elements.
+
K2 - Input/output second camera intrinsic matrix. The parameter is similar to K1 .
+
D2 - Input/output lens distortion coefficients for the second camera. The parameter is
+ similar to D1 .
+
imageSize - Size of the image used only to initialize camera intrinsic matrix.
+
R - Output rotation matrix between the 1st and the 2nd camera coordinate systems.
+
T - Output translation vector between the coordinate systems of the cameras.
+
rvecs - Output vector of rotation vectors ( REF: Rodrigues ) estimated for each pattern view in the
+ coordinate system of the first camera of the stereo pair (e.g. std::vector<cv::Mat>). More in detail, each
+ i-th rotation vector together with the corresponding i-th translation vector (see the next output parameter
+ description) brings the calibration pattern from the object coordinate space (in which object points are
+ specified) to the camera coordinate space of the first camera of the stereo pair. In more technical terms,
+ the tuple of the i-th rotation and translation vector performs a change of basis from object coordinate space
+ to camera coordinate space of the first camera of the stereo pair.
+
tvecs - Output vector of translation vectors estimated for each pattern view, see parameter description
+ of previous output parameter ( rvecs ).
+
flags - Different flags that may be zero or a combination of the following values:
+
+
+ REF: fisheye::CALIB_FIX_INTRINSIC Fix K1, K2? and D1, D2? so that only R, T matrices
+ are estimated.
+
+
+ REF: fisheye::CALIB_USE_INTRINSIC_GUESS K1, K2 contains valid initial values of
+ fx, fy, cx, cy that are optimized further. Otherwise, (cx, cy) is initially set to the image
+ center (imageSize is used), and focal distances are computed in a least-squares fashion.
+
+
+ REF: fisheye::CALIB_RECOMPUTE_EXTRINSIC Extrinsic will be recomputed after each iteration
+ of intrinsic optimization.
+
+
+ REF: fisheye::CALIB_CHECK_COND The functions will check validity of condition number.
+
+
+ REF: fisheye::CALIB_FIX_SKEW Skew coefficient (alpha) is set to zero and stay zero.
+
+
+ REF: fisheye::CALIB_FIX_K1,..., REF: fisheye::CALIB_FIX_K4 Selected distortion coefficients are set to zeros and stay
+ zero.
+
public static double fisheye_stereoCalibrate(java.util.List<Mat> objectPoints,
+ java.util.List<Mat> imagePoints1,
+ java.util.List<Mat> imagePoints2,
+ Mat K1,
+ Mat D1,
+ Mat K2,
+ Mat D2,
+ Size imageSize,
+ Mat R,
+ Mat T,
+ java.util.List<Mat> rvecs,
+ java.util.List<Mat> tvecs,
+ int flags,
+ TermCriteria criteria)
+
Performs stereo calibration
+
+
Parameters:
+
objectPoints - Vector of vectors of the calibration pattern points.
+
imagePoints1 - Vector of vectors of the projections of the calibration pattern points,
+ observed by the first camera.
+
imagePoints2 - Vector of vectors of the projections of the calibration pattern points,
+ observed by the second camera.
+
K1 - Input/output first camera intrinsic matrix:
+ \(\vecthreethree{f_x^{(j)}}{0}{c_x^{(j)}}{0}{f_y^{(j)}}{c_y^{(j)}}{0}{0}{1}\) , \(j = 0,\, 1\) . If
+ any of REF: fisheye::CALIB_USE_INTRINSIC_GUESS , REF: fisheye::CALIB_FIX_INTRINSIC are specified,
+ some or all of the matrix components must be initialized.
+
D1 - Input/output vector of distortion coefficients \(\distcoeffsfisheye\) of 4 elements.
+
K2 - Input/output second camera intrinsic matrix. The parameter is similar to K1 .
+
D2 - Input/output lens distortion coefficients for the second camera. The parameter is
+ similar to D1 .
+
imageSize - Size of the image used only to initialize camera intrinsic matrix.
+
R - Output rotation matrix between the 1st and the 2nd camera coordinate systems.
+
T - Output translation vector between the coordinate systems of the cameras.
+
rvecs - Output vector of rotation vectors ( REF: Rodrigues ) estimated for each pattern view in the
+ coordinate system of the first camera of the stereo pair (e.g. std::vector<cv::Mat>). More in detail, each
+ i-th rotation vector together with the corresponding i-th translation vector (see the next output parameter
+ description) brings the calibration pattern from the object coordinate space (in which object points are
+ specified) to the camera coordinate space of the first camera of the stereo pair. In more technical terms,
+ the tuple of the i-th rotation and translation vector performs a change of basis from object coordinate space
+ to camera coordinate space of the first camera of the stereo pair.
+
tvecs - Output vector of translation vectors estimated for each pattern view, see parameter description
+ of previous output parameter ( rvecs ).
+
flags - Different flags that may be zero or a combination of the following values:
+
+
+ REF: fisheye::CALIB_FIX_INTRINSIC Fix K1, K2? and D1, D2? so that only R, T matrices
+ are estimated.
+
+
+ REF: fisheye::CALIB_USE_INTRINSIC_GUESS K1, K2 contains valid initial values of
+ fx, fy, cx, cy that are optimized further. Otherwise, (cx, cy) is initially set to the image
+ center (imageSize is used), and focal distances are computed in a least-squares fashion.
+
+
+ REF: fisheye::CALIB_RECOMPUTE_EXTRINSIC Extrinsic will be recomputed after each iteration
+ of intrinsic optimization.
+
+
+ REF: fisheye::CALIB_CHECK_COND The functions will check validity of condition number.
+
+
+ REF: fisheye::CALIB_FIX_SKEW Skew coefficient (alpha) is set to zero and stay zero.
+
+
+ REF: fisheye::CALIB_FIX_K1,..., REF: fisheye::CALIB_FIX_K4 Selected distortion coefficients are set to zeros and stay
+ zero.
+
+
+
criteria - Termination criteria for the iterative optimization algorithm.
public static void fisheye_stereoRectify(Mat K1,
+ Mat D1,
+ Mat K2,
+ Mat D2,
+ Size imageSize,
+ Mat R,
+ Mat tvec,
+ Mat R1,
+ Mat R2,
+ Mat P1,
+ Mat P2,
+ Mat Q,
+ int flags)
+
Stereo rectification for fisheye camera model
+
+
Parameters:
+
K1 - First camera intrinsic matrix.
+
D1 - First camera distortion parameters.
+
K2 - Second camera intrinsic matrix.
+
D2 - Second camera distortion parameters.
+
imageSize - Size of the image used for stereo calibration.
+
R - Rotation matrix between the coordinate systems of the first and the second
+ cameras.
+
tvec - Translation vector between coordinate systems of the cameras.
+
R1 - Output 3x3 rectification transform (rotation matrix) for the first camera.
+
R2 - Output 3x3 rectification transform (rotation matrix) for the second camera.
+
P1 - Output 3x4 projection matrix in the new (rectified) coordinate systems for the first
+ camera.
+
P2 - Output 3x4 projection matrix in the new (rectified) coordinate systems for the second
+ camera.
flags - Operation flags that may be zero or REF: fisheye::CALIB_ZERO_DISPARITY . If the flag is set,
+ the function makes the principal points of each camera have the same pixel coordinates in the
+ rectified views. And if the flag is not set, the function may still shift the images in the
+ horizontal or vertical direction (depending on the orientation of epipolar lines) to maximize the
+ useful image area.
+ #initUndistortRectifyMap (see the stereo_calib.cpp sample in OpenCV samples directory). When (0,0)
+ is passed (default), it is set to the original imageSize . Setting it to larger value can help you
+ preserve details in the original image, especially when there is a big radial distortion.
+ length. Balance is in range of [0, 1].
public static void fisheye_stereoRectify(Mat K1,
+ Mat D1,
+ Mat K2,
+ Mat D2,
+ Size imageSize,
+ Mat R,
+ Mat tvec,
+ Mat R1,
+ Mat R2,
+ Mat P1,
+ Mat P2,
+ Mat Q,
+ int flags,
+ Size newImageSize)
+
Stereo rectification for fisheye camera model
+
+
Parameters:
+
K1 - First camera intrinsic matrix.
+
D1 - First camera distortion parameters.
+
K2 - Second camera intrinsic matrix.
+
D2 - Second camera distortion parameters.
+
imageSize - Size of the image used for stereo calibration.
+
R - Rotation matrix between the coordinate systems of the first and the second
+ cameras.
+
tvec - Translation vector between coordinate systems of the cameras.
+
R1 - Output 3x3 rectification transform (rotation matrix) for the first camera.
+
R2 - Output 3x3 rectification transform (rotation matrix) for the second camera.
+
P1 - Output 3x4 projection matrix in the new (rectified) coordinate systems for the first
+ camera.
+
P2 - Output 3x4 projection matrix in the new (rectified) coordinate systems for the second
+ camera.
flags - Operation flags that may be zero or REF: fisheye::CALIB_ZERO_DISPARITY . If the flag is set,
+ the function makes the principal points of each camera have the same pixel coordinates in the
+ rectified views. And if the flag is not set, the function may still shift the images in the
+ horizontal or vertical direction (depending on the orientation of epipolar lines) to maximize the
+ useful image area.
+
newImageSize - New image resolution after rectification. The same size should be passed to
+ #initUndistortRectifyMap (see the stereo_calib.cpp sample in OpenCV samples directory). When (0,0)
+ is passed (default), it is set to the original imageSize . Setting it to larger value can help you
+ preserve details in the original image, especially when there is a big radial distortion.
+ length. Balance is in range of [0, 1].
public static void fisheye_stereoRectify(Mat K1,
+ Mat D1,
+ Mat K2,
+ Mat D2,
+ Size imageSize,
+ Mat R,
+ Mat tvec,
+ Mat R1,
+ Mat R2,
+ Mat P1,
+ Mat P2,
+ Mat Q,
+ int flags,
+ Size newImageSize,
+ double balance)
+
Stereo rectification for fisheye camera model
+
+
Parameters:
+
K1 - First camera intrinsic matrix.
+
D1 - First camera distortion parameters.
+
K2 - Second camera intrinsic matrix.
+
D2 - Second camera distortion parameters.
+
imageSize - Size of the image used for stereo calibration.
+
R - Rotation matrix between the coordinate systems of the first and the second
+ cameras.
+
tvec - Translation vector between coordinate systems of the cameras.
+
R1 - Output 3x3 rectification transform (rotation matrix) for the first camera.
+
R2 - Output 3x3 rectification transform (rotation matrix) for the second camera.
+
P1 - Output 3x4 projection matrix in the new (rectified) coordinate systems for the first
+ camera.
+
P2 - Output 3x4 projection matrix in the new (rectified) coordinate systems for the second
+ camera.
flags - Operation flags that may be zero or REF: fisheye::CALIB_ZERO_DISPARITY . If the flag is set,
+ the function makes the principal points of each camera have the same pixel coordinates in the
+ rectified views. And if the flag is not set, the function may still shift the images in the
+ horizontal or vertical direction (depending on the orientation of epipolar lines) to maximize the
+ useful image area.
+
newImageSize - New image resolution after rectification. The same size should be passed to
+ #initUndistortRectifyMap (see the stereo_calib.cpp sample in OpenCV samples directory). When (0,0)
+ is passed (default), it is set to the original imageSize . Setting it to larger value can help you
+ preserve details in the original image, especially when there is a big radial distortion.
+
balance - Sets the new focal length in range between the min focal length and the max focal
+ length. Balance is in range of [0, 1].
public static void fisheye_stereoRectify(Mat K1,
+ Mat D1,
+ Mat K2,
+ Mat D2,
+ Size imageSize,
+ Mat R,
+ Mat tvec,
+ Mat R1,
+ Mat R2,
+ Mat P1,
+ Mat P2,
+ Mat Q,
+ int flags,
+ Size newImageSize,
+ double balance,
+ double fov_scale)
+
Stereo rectification for fisheye camera model
+
+
Parameters:
+
K1 - First camera intrinsic matrix.
+
D1 - First camera distortion parameters.
+
K2 - Second camera intrinsic matrix.
+
D2 - Second camera distortion parameters.
+
imageSize - Size of the image used for stereo calibration.
+
R - Rotation matrix between the coordinate systems of the first and the second
+ cameras.
+
tvec - Translation vector between coordinate systems of the cameras.
+
R1 - Output 3x3 rectification transform (rotation matrix) for the first camera.
+
R2 - Output 3x3 rectification transform (rotation matrix) for the second camera.
+
P1 - Output 3x4 projection matrix in the new (rectified) coordinate systems for the first
+ camera.
+
P2 - Output 3x4 projection matrix in the new (rectified) coordinate systems for the second
+ camera.
flags - Operation flags that may be zero or REF: fisheye::CALIB_ZERO_DISPARITY . If the flag is set,
+ the function makes the principal points of each camera have the same pixel coordinates in the
+ rectified views. And if the flag is not set, the function may still shift the images in the
+ horizontal or vertical direction (depending on the orientation of epipolar lines) to maximize the
+ useful image area.
+
newImageSize - New image resolution after rectification. The same size should be passed to
+ #initUndistortRectifyMap (see the stereo_calib.cpp sample in OpenCV samples directory). When (0,0)
+ is passed (default), it is set to the original imageSize . Setting it to larger value can help you
+ preserve details in the original image, especially when there is a big radial distortion.
+
balance - Sets the new focal length in range between the min focal length and the max focal
+ length. Balance is in range of [0, 1].
public static void fisheye_undistortImage(Mat distorted,
+ Mat undistorted,
+ Mat K,
+ Mat D)
+
Transforms an image to compensate for fisheye lens distortion.
+
+
Parameters:
+
distorted - image with fisheye lens distortion.
+
undistorted - Output image with compensated fisheye lens distortion.
+
K - Camera intrinsic matrix \(cameramatrix{K}\).
+
D - Input vector of distortion coefficients \(\distcoeffsfisheye\).
+ may additionally scale and shift the result by using a different matrix.
+
+ The function transforms an image to compensate radial and tangential lens distortion.
+
+ The function is simply a combination of #fisheye::initUndistortRectifyMap (with unity R ) and #remap
+ (with bilinear interpolation). See the former function for details of the transformation being
+ performed.
+
+ See below the results of undistortImage.
+
+
+ a\) result of undistort of perspective camera model (all possible coefficients (k_1, k_2, k_3,
+ k_4, k_5, k_6) of distortion were optimized under calibration)
+
+
+ b\) result of #fisheye::undistortImage of fisheye camera model (all possible coefficients (k_1, k_2,
+ k_3, k_4) of fisheye distortion were optimized under calibration)
+
+
+ c\) original image was captured with fisheye lens
+
+
+
+ Pictures a) and b) almost the same. But if we consider points of image located far from the center
+ of image, we can notice that on image a) these points are distorted.
+
public static void fisheye_undistortImage(Mat distorted,
+ Mat undistorted,
+ Mat K,
+ Mat D,
+ Mat Knew)
+
Transforms an image to compensate for fisheye lens distortion.
+
+
Parameters:
+
distorted - image with fisheye lens distortion.
+
undistorted - Output image with compensated fisheye lens distortion.
+
K - Camera intrinsic matrix \(cameramatrix{K}\).
+
D - Input vector of distortion coefficients \(\distcoeffsfisheye\).
+
Knew - Camera intrinsic matrix of the distorted image. By default, it is the identity matrix but you
+ may additionally scale and shift the result by using a different matrix.
+
+ The function transforms an image to compensate radial and tangential lens distortion.
+
+ The function is simply a combination of #fisheye::initUndistortRectifyMap (with unity R ) and #remap
+ (with bilinear interpolation). See the former function for details of the transformation being
+ performed.
+
+ See below the results of undistortImage.
+
+
+ a\) result of undistort of perspective camera model (all possible coefficients (k_1, k_2, k_3,
+ k_4, k_5, k_6) of distortion were optimized under calibration)
+
+
+ b\) result of #fisheye::undistortImage of fisheye camera model (all possible coefficients (k_1, k_2,
+ k_3, k_4) of fisheye distortion were optimized under calibration)
+
+
+ c\) original image was captured with fisheye lens
+
+
+
+ Pictures a) and b) almost the same. But if we consider points of image located far from the center
+ of image, we can notice that on image a) these points are distorted.
+
public static void fisheye_undistortImage(Mat distorted,
+ Mat undistorted,
+ Mat K,
+ Mat D,
+ Mat Knew,
+ Size new_size)
+
Transforms an image to compensate for fisheye lens distortion.
+
+
Parameters:
+
distorted - image with fisheye lens distortion.
+
undistorted - Output image with compensated fisheye lens distortion.
+
K - Camera intrinsic matrix \(cameramatrix{K}\).
+
D - Input vector of distortion coefficients \(\distcoeffsfisheye\).
+
Knew - Camera intrinsic matrix of the distorted image. By default, it is the identity matrix but you
+ may additionally scale and shift the result by using a different matrix.
+
new_size - the new size
+
+ The function transforms an image to compensate radial and tangential lens distortion.
+
+ The function is simply a combination of #fisheye::initUndistortRectifyMap (with unity R ) and #remap
+ (with bilinear interpolation). See the former function for details of the transformation being
+ performed.
+
+ See below the results of undistortImage.
+
+
+ a\) result of undistort of perspective camera model (all possible coefficients (k_1, k_2, k_3,
+ k_4, k_5, k_6) of distortion were optimized under calibration)
+
+
+ b\) result of #fisheye::undistortImage of fisheye camera model (all possible coefficients (k_1, k_2,
+ k_3, k_4) of fisheye distortion were optimized under calibration)
+
+
+ c\) original image was captured with fisheye lens
+
+
+
+ Pictures a) and b) almost the same. But if we consider points of image located far from the center
+ of image, we can notice that on image a) these points are distorted.
+
public static Mat getDefaultNewCameraMatrix(Mat cameraMatrix)
+
Returns the default new camera matrix.
+
+ The function returns the camera matrix that is either an exact copy of the input cameraMatrix (when
+ centerPrinicipalPoint=false ), or the modified one (when centerPrincipalPoint=true).
+
+ In the latter case, the new camera matrix will be:
+
+ \(\begin{bmatrix} f_x && 0 && ( \texttt{imgSize.width} -1)*0.5 \\ 0 && f_y && ( \texttt{imgSize.height} -1)*0.5 \\ 0 && 0 && 1 \end{bmatrix} ,\)
+
+ where \(f_x\) and \(f_y\) are \((0,0)\) and \((1,1)\) elements of cameraMatrix, respectively.
+
+ By default, the undistortion functions in OpenCV (see #initUndistortRectifyMap, #undistort) do not
+ move the principal point. However, when you work with stereo, it is important to move the principal
+ points in both views to the same y-coordinate (which is required by most of stereo correspondence
+ algorithms), and may be to the same x-coordinate too. So, you can form the new camera matrix for
+ each view where the principal points are located at the center.
+
+
Parameters:
+
cameraMatrix - Input camera matrix.
+ parameter indicates whether this location should be at the image center or not.
public static Mat getDefaultNewCameraMatrix(Mat cameraMatrix,
+ Size imgsize)
+
Returns the default new camera matrix.
+
+ The function returns the camera matrix that is either an exact copy of the input cameraMatrix (when
+ centerPrinicipalPoint=false ), or the modified one (when centerPrincipalPoint=true).
+
+ In the latter case, the new camera matrix will be:
+
+ \(\begin{bmatrix} f_x && 0 && ( \texttt{imgSize.width} -1)*0.5 \\ 0 && f_y && ( \texttt{imgSize.height} -1)*0.5 \\ 0 && 0 && 1 \end{bmatrix} ,\)
+
+ where \(f_x\) and \(f_y\) are \((0,0)\) and \((1,1)\) elements of cameraMatrix, respectively.
+
+ By default, the undistortion functions in OpenCV (see #initUndistortRectifyMap, #undistort) do not
+ move the principal point. However, when you work with stereo, it is important to move the principal
+ points in both views to the same y-coordinate (which is required by most of stereo correspondence
+ algorithms), and may be to the same x-coordinate too. So, you can form the new camera matrix for
+ each view where the principal points are located at the center.
+
+
Parameters:
+
cameraMatrix - Input camera matrix.
+
imgsize - Camera view image size in pixels.
+ parameter indicates whether this location should be at the image center or not.
public static Mat getDefaultNewCameraMatrix(Mat cameraMatrix,
+ Size imgsize,
+ boolean centerPrincipalPoint)
+
Returns the default new camera matrix.
+
+ The function returns the camera matrix that is either an exact copy of the input cameraMatrix (when
+ centerPrinicipalPoint=false ), or the modified one (when centerPrincipalPoint=true).
+
+ In the latter case, the new camera matrix will be:
+
+ \(\begin{bmatrix} f_x && 0 && ( \texttt{imgSize.width} -1)*0.5 \\ 0 && f_y && ( \texttt{imgSize.height} -1)*0.5 \\ 0 && 0 && 1 \end{bmatrix} ,\)
+
+ where \(f_x\) and \(f_y\) are \((0,0)\) and \((1,1)\) elements of cameraMatrix, respectively.
+
+ By default, the undistortion functions in OpenCV (see #initUndistortRectifyMap, #undistort) do not
+ move the principal point. However, when you work with stereo, it is important to move the principal
+ points in both views to the same y-coordinate (which is required by most of stereo correspondence
+ algorithms), and may be to the same x-coordinate too. So, you can form the new camera matrix for
+ each view where the principal points are located at the center.
+
+
Parameters:
+
cameraMatrix - Input camera matrix.
+
imgsize - Camera view image size in pixels.
+
centerPrincipalPoint - Location of the principal point in the new camera matrix. The
+ parameter indicates whether this location should be at the image center or not.
public static Mat getOptimalNewCameraMatrix(Mat cameraMatrix,
+ Mat distCoeffs,
+ Size imageSize,
+ double alpha)
+
Returns the new camera intrinsic matrix based on the free scaling parameter.
+
+
Parameters:
+
cameraMatrix - Input camera intrinsic matrix.
+
distCoeffs - Input vector of distortion coefficients
+ \(\distcoeffs\). If the vector is NULL/empty, the zero distortion coefficients are
+ assumed.
+
imageSize - Original image size.
+
alpha - Free scaling parameter between 0 (when all the pixels in the undistorted image are
+ valid) and 1 (when all the source image pixels are retained in the undistorted image). See
+ #stereoRectify for details.
+ undistorted image. See roi1, roi2 description in #stereoRectify .
+ principal point should be at the image center or not. By default, the principal point is chosen to
+ best fit a subset of the source image (determined by alpha) to the corrected image.
+
Returns:
+
new_camera_matrix Output new camera intrinsic matrix.
+
+ The function computes and returns the optimal new camera intrinsic matrix based on the free scaling parameter.
+ By varying this parameter, you may retrieve only sensible pixels alpha=0 , keep all the original
+ image pixels if there is valuable information in the corners alpha=1 , or get something in between.
+ When alpha>0 , the undistorted result is likely to have some black pixels corresponding to
+ "virtual" pixels outside of the captured distorted image. The original camera intrinsic matrix, distortion
+ coefficients, the computed new camera intrinsic matrix, and newImageSize should be passed to
+ #initUndistortRectifyMap to produce the maps for #remap .
public static Mat getOptimalNewCameraMatrix(Mat cameraMatrix,
+ Mat distCoeffs,
+ Size imageSize,
+ double alpha,
+ Size newImgSize)
+
Returns the new camera intrinsic matrix based on the free scaling parameter.
+
+
Parameters:
+
cameraMatrix - Input camera intrinsic matrix.
+
distCoeffs - Input vector of distortion coefficients
+ \(\distcoeffs\). If the vector is NULL/empty, the zero distortion coefficients are
+ assumed.
+
imageSize - Original image size.
+
alpha - Free scaling parameter between 0 (when all the pixels in the undistorted image are
+ valid) and 1 (when all the source image pixels are retained in the undistorted image). See
+ #stereoRectify for details.
+
newImgSize - Image size after rectification. By default, it is set to imageSize .
+ undistorted image. See roi1, roi2 description in #stereoRectify .
+ principal point should be at the image center or not. By default, the principal point is chosen to
+ best fit a subset of the source image (determined by alpha) to the corrected image.
+
Returns:
+
new_camera_matrix Output new camera intrinsic matrix.
+
+ The function computes and returns the optimal new camera intrinsic matrix based on the free scaling parameter.
+ By varying this parameter, you may retrieve only sensible pixels alpha=0 , keep all the original
+ image pixels if there is valuable information in the corners alpha=1 , or get something in between.
+ When alpha>0 , the undistorted result is likely to have some black pixels corresponding to
+ "virtual" pixels outside of the captured distorted image. The original camera intrinsic matrix, distortion
+ coefficients, the computed new camera intrinsic matrix, and newImageSize should be passed to
+ #initUndistortRectifyMap to produce the maps for #remap .
public static Mat getOptimalNewCameraMatrix(Mat cameraMatrix,
+ Mat distCoeffs,
+ Size imageSize,
+ double alpha,
+ Size newImgSize,
+ Rect validPixROI)
+
Returns the new camera intrinsic matrix based on the free scaling parameter.
+
+
Parameters:
+
cameraMatrix - Input camera intrinsic matrix.
+
distCoeffs - Input vector of distortion coefficients
+ \(\distcoeffs\). If the vector is NULL/empty, the zero distortion coefficients are
+ assumed.
+
imageSize - Original image size.
+
alpha - Free scaling parameter between 0 (when all the pixels in the undistorted image are
+ valid) and 1 (when all the source image pixels are retained in the undistorted image). See
+ #stereoRectify for details.
+
newImgSize - Image size after rectification. By default, it is set to imageSize .
+
validPixROI - Optional output rectangle that outlines all-good-pixels region in the
+ undistorted image. See roi1, roi2 description in #stereoRectify .
+ principal point should be at the image center or not. By default, the principal point is chosen to
+ best fit a subset of the source image (determined by alpha) to the corrected image.
+
Returns:
+
new_camera_matrix Output new camera intrinsic matrix.
+
+ The function computes and returns the optimal new camera intrinsic matrix based on the free scaling parameter.
+ By varying this parameter, you may retrieve only sensible pixels alpha=0 , keep all the original
+ image pixels if there is valuable information in the corners alpha=1 , or get something in between.
+ When alpha>0 , the undistorted result is likely to have some black pixels corresponding to
+ "virtual" pixels outside of the captured distorted image. The original camera intrinsic matrix, distortion
+ coefficients, the computed new camera intrinsic matrix, and newImageSize should be passed to
+ #initUndistortRectifyMap to produce the maps for #remap .
public static Mat getOptimalNewCameraMatrix(Mat cameraMatrix,
+ Mat distCoeffs,
+ Size imageSize,
+ double alpha,
+ Size newImgSize,
+ Rect validPixROI,
+ boolean centerPrincipalPoint)
+
Returns the new camera intrinsic matrix based on the free scaling parameter.
+
+
Parameters:
+
cameraMatrix - Input camera intrinsic matrix.
+
distCoeffs - Input vector of distortion coefficients
+ \(\distcoeffs\). If the vector is NULL/empty, the zero distortion coefficients are
+ assumed.
+
imageSize - Original image size.
+
alpha - Free scaling parameter between 0 (when all the pixels in the undistorted image are
+ valid) and 1 (when all the source image pixels are retained in the undistorted image). See
+ #stereoRectify for details.
+
newImgSize - Image size after rectification. By default, it is set to imageSize .
+
validPixROI - Optional output rectangle that outlines all-good-pixels region in the
+ undistorted image. See roi1, roi2 description in #stereoRectify .
+
centerPrincipalPoint - Optional flag that indicates whether in the new camera intrinsic matrix the
+ principal point should be at the image center or not. By default, the principal point is chosen to
+ best fit a subset of the source image (determined by alpha) to the corrected image.
+
Returns:
+
new_camera_matrix Output new camera intrinsic matrix.
+
+ The function computes and returns the optimal new camera intrinsic matrix based on the free scaling parameter.
+ By varying this parameter, you may retrieve only sensible pixels alpha=0 , keep all the original
+ image pixels if there is valuable information in the corners alpha=1 , or get something in between.
+ When alpha>0 , the undistorted result is likely to have some black pixels corresponding to
+ "virtual" pixels outside of the captured distorted image. The original camera intrinsic matrix, distortion
+ coefficients, the computed new camera intrinsic matrix, and newImageSize should be passed to
+ #initUndistortRectifyMap to produce the maps for #remap .
public static Mat initCameraMatrix2D(java.util.List<MatOfPoint3f> objectPoints,
+ java.util.List<MatOfPoint2f> imagePoints,
+ Size imageSize)
+
Finds an initial camera intrinsic matrix from 3D-2D point correspondences.
+
+
Parameters:
+
objectPoints - Vector of vectors of the calibration pattern points in the calibration pattern
+ coordinate space. In the old interface all the per-view vectors are concatenated. See
+ #calibrateCamera for details.
+
imagePoints - Vector of vectors of the projections of the calibration pattern points. In the
+ old interface all the per-view vectors are concatenated.
+
imageSize - Image size in pixels used to initialize the principal point.
+ Otherwise, \(f_x = f_y \cdot \texttt{aspectRatio}\) .
+
+ The function estimates and returns an initial camera intrinsic matrix for the camera calibration process.
+ Currently, the function only supports planar calibration patterns, which are patterns where each
+ object point has z-coordinate =0.
public static Mat initCameraMatrix2D(java.util.List<MatOfPoint3f> objectPoints,
+ java.util.List<MatOfPoint2f> imagePoints,
+ Size imageSize,
+ double aspectRatio)
+
Finds an initial camera intrinsic matrix from 3D-2D point correspondences.
+
+
Parameters:
+
objectPoints - Vector of vectors of the calibration pattern points in the calibration pattern
+ coordinate space. In the old interface all the per-view vectors are concatenated. See
+ #calibrateCamera for details.
+
imagePoints - Vector of vectors of the projections of the calibration pattern points. In the
+ old interface all the per-view vectors are concatenated.
+
imageSize - Image size in pixels used to initialize the principal point.
+
aspectRatio - If it is zero or negative, both \(f_x\) and \(f_y\) are estimated independently.
+ Otherwise, \(f_x = f_y \cdot \texttt{aspectRatio}\) .
+
+ The function estimates and returns an initial camera intrinsic matrix for the camera calibration process.
+ Currently, the function only supports planar calibration patterns, which are patterns where each
+ object point has z-coordinate =0.
public static void initInverseRectificationMap(Mat cameraMatrix,
+ Mat distCoeffs,
+ Mat R,
+ Mat newCameraMatrix,
+ Size size,
+ int m1type,
+ Mat map1,
+ Mat map2)
+
Computes the projection and inverse-rectification transformation map. In essense, this is the inverse of
+ #initUndistortRectifyMap to accomodate stereo-rectification of projectors ('inverse-cameras') in projector-camera pairs.
+
+ The function computes the joint projection and inverse rectification transformation and represents the
+ result in the form of maps for #remap. The projected image looks like a distorted version of the original which,
+ once projected by a projector, should visually match the original. In case of a monocular camera, newCameraMatrix
+ is usually equal to cameraMatrix, or it can be computed by
+ #getOptimalNewCameraMatrix for a better control over scaling. In case of a projector-camera pair,
+ newCameraMatrix is normally set to P1 or P2 computed by #stereoRectify .
+
+ The projector is oriented differently in the coordinate space, according to R. In case of projector-camera pairs,
+ this helps align the projector (in the same manner as #initUndistortRectifyMap for the camera) to create a stereo-rectified pair. This
+ allows epipolar lines on both images to become horizontal and have the same y-coordinate (in case of a horizontally aligned projector-camera pair).
+
+ The function builds the maps for the inverse mapping algorithm that is used by #remap. That
+ is, for each pixel \((u, v)\) in the destination (projected and inverse-rectified) image, the function
+ computes the corresponding coordinates in the source image (that is, in the original digital image). The following process is applied:
+
+ \(
+ \begin{array}{l}
+ \text{newCameraMatrix}\\
+ x \leftarrow (u - {c'}_x)/{f'}_x \\
+ y \leftarrow (v - {c'}_y)/{f'}_y \\
+
+ \\\text{Undistortion}
+ \\\scriptsize{\textit{though equation shown is for radial undistortion, function implements cv::undistortPoints()}}\\
+ r^2 \leftarrow x^2 + y^2 \\
+ \theta \leftarrow \frac{1 + k_1 r^2 + k_2 r^4 + k_3 r^6}{1 + k_4 r^2 + k_5 r^4 + k_6 r^6}\\
+ x' \leftarrow \frac{x}{\theta} \\
+ y' \leftarrow \frac{y}{\theta} \\
+
+ \\\text{Rectification}\\
+ {[X\,Y\,W]} ^T \leftarrow R*[x' \, y' \, 1]^T \\
+ x'' \leftarrow X/W \\
+ y'' \leftarrow Y/W \\
+
+ \\\text{cameraMatrix}\\
+ map_x(u,v) \leftarrow x'' f_x + c_x \\
+ map_y(u,v) \leftarrow y'' f_y + c_y
+ \end{array}
+ \)
+ where \((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]]]])\)
+ are the distortion coefficients vector distCoeffs.
+
+ In case of a stereo-rectified projector-camera pair, this function is called for the projector while #initUndistortRectifyMap is called for the camera head.
+ This is done after #stereoRectify, which in turn is called after #stereoCalibrate. If the projector-camera pair
+ is not calibrated, it is still possible to compute the rectification transformations directly from
+ the fundamental matrix using #stereoRectifyUncalibrated. For the projector and camera, the function computes
+ homography H as the rectification transformation in a pixel domain, not a rotation matrix R in 3D
+ space. R can be computed from H as
+ \(\texttt{R} = \texttt{cameraMatrix} ^{-1} \cdot \texttt{H} \cdot \texttt{cameraMatrix}\)
+ where cameraMatrix can be chosen arbitrarily.
+
+
Parameters:
+
cameraMatrix - Input camera matrix \(A=\vecthreethree{f_x}{0}{c_x}{0}{f_y}{c_y}{0}{0}{1}\) .
+
distCoeffs - Input vector of distortion coefficients
+ \((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]]]])\)
+ of 4, 5, 8, 12 or 14 elements. If the vector is NULL/empty, the zero distortion coefficients are assumed.
+
R - Optional rectification transformation in the object space (3x3 matrix). R1 or R2,
+ computed by #stereoRectify can be passed here. If the matrix is empty, the identity transformation
+ is assumed.
+
newCameraMatrix - New camera matrix \(A'=\vecthreethree{f_x'}{0}{c_x'}{0}{f_y'}{c_y'}{0}{0}{1}\).
+
size - Distorted image size.
+
m1type - Type of the first output map. Can be CV_32FC1, CV_32FC2 or CV_16SC2, see #convertMaps
public static void initUndistortRectifyMap(Mat cameraMatrix,
+ Mat distCoeffs,
+ Mat R,
+ Mat newCameraMatrix,
+ Size size,
+ int m1type,
+ Mat map1,
+ Mat map2)
+
Computes the undistortion and rectification transformation map.
+
+ The function computes the joint undistortion and rectification transformation and represents the
+ result in the form of maps for #remap. The undistorted image looks like original, as if it is
+ captured with a camera using the camera matrix =newCameraMatrix and zero distortion. In case of a
+ monocular camera, newCameraMatrix is usually equal to cameraMatrix, or it can be computed by
+ #getOptimalNewCameraMatrix for a better control over scaling. In case of a stereo camera,
+ newCameraMatrix is normally set to P1 or P2 computed by #stereoRectify .
+
+ Also, this new camera is oriented differently in the coordinate space, according to R. That, for
+ example, helps to align two heads of a stereo camera so that the epipolar lines on both images
+ become horizontal and have the same y- coordinate (in case of a horizontally aligned stereo camera).
+
+ The function actually builds the maps for the inverse mapping algorithm that is used by #remap. That
+ is, for each pixel \((u, v)\) in the destination (corrected and rectified) image, the function
+ computes the corresponding coordinates in the source image (that is, in the original image from
+ camera). The following process is applied:
+ \(
+ \begin{array}{l}
+ x \leftarrow (u - {c'}_x)/{f'}_x \\
+ y \leftarrow (v - {c'}_y)/{f'}_y \\
+ {[X\,Y\,W]} ^T \leftarrow R^{-1}*[x \, y \, 1]^T \\
+ x' \leftarrow X/W \\
+ y' \leftarrow Y/W \\
+ r^2 \leftarrow x'^2 + y'^2 \\
+ x'' \leftarrow x' \frac{1 + k_1 r^2 + k_2 r^4 + k_3 r^6}{1 + k_4 r^2 + k_5 r^4 + k_6 r^6}
+ + 2p_1 x' y' + p_2(r^2 + 2 x'^2) + s_1 r^2 + s_2 r^4\\
+ y'' \leftarrow y' \frac{1 + k_1 r^2 + k_2 r^4 + k_3 r^6}{1 + k_4 r^2 + k_5 r^4 + k_6 r^6}
+ + p_1 (r^2 + 2 y'^2) + 2 p_2 x' y' + s_3 r^2 + s_4 r^4 \\
+ s\vecthree{x'''}{y'''}{1} =
+ \vecthreethree{R_{33}(\tau_x, \tau_y)}{0}{-R_{13}((\tau_x, \tau_y)}
+ {0}{R_{33}(\tau_x, \tau_y)}{-R_{23}(\tau_x, \tau_y)}
+ {0}{0}{1} R(\tau_x, \tau_y) \vecthree{x''}{y''}{1}\\
+ map_x(u,v) \leftarrow x''' f_x + c_x \\
+ map_y(u,v) \leftarrow y''' f_y + c_y
+ \end{array}
+ \)
+ where \((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]]]])\)
+ are the distortion coefficients.
+
+ In case of a stereo camera, this function is called twice: once for each camera head, after
+ #stereoRectify, which in its turn is called after #stereoCalibrate. But if the stereo camera
+ was not calibrated, it is still possible to compute the rectification transformations directly from
+ the fundamental matrix using #stereoRectifyUncalibrated. For each camera, the function computes
+ homography H as the rectification transformation in a pixel domain, not a rotation matrix R in 3D
+ space. R can be computed from H as
+ \(\texttt{R} = \texttt{cameraMatrix} ^{-1} \cdot \texttt{H} \cdot \texttt{cameraMatrix}\)
+ where cameraMatrix can be chosen arbitrarily.
+
+
Parameters:
+
cameraMatrix - Input camera matrix \(A=\vecthreethree{f_x}{0}{c_x}{0}{f_y}{c_y}{0}{0}{1}\) .
+
distCoeffs - Input vector of distortion coefficients
+ \((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]]]])\)
+ of 4, 5, 8, 12 or 14 elements. If the vector is NULL/empty, the zero distortion coefficients are assumed.
+
R - Optional rectification transformation in the object space (3x3 matrix). R1 or R2 ,
+ computed by #stereoRectify can be passed here. If the matrix is empty, the identity transformation
+ is assumed. In #initUndistortRectifyMap R assumed to be an identity matrix.
+
newCameraMatrix - New camera matrix \(A'=\vecthreethree{f_x'}{0}{c_x'}{0}{f_y'}{c_y'}{0}{0}{1}\).
+
size - Undistorted image size.
+
m1type - Type of the first output map that can be CV_32FC1, CV_32FC2 or CV_16SC2, see #convertMaps
public static void matMulDeriv(Mat A,
+ Mat B,
+ Mat dABdA,
+ Mat dABdB)
+
Computes partial derivatives of the matrix product for each multiplied matrix.
+
+
Parameters:
+
A - First multiplied matrix.
+
B - Second multiplied matrix.
+
dABdA - First output derivative matrix d(A\*B)/dA of size
+ \(\texttt{A.rows*B.cols} \times {A.rows*A.cols}\) .
+
dABdB - Second output derivative matrix d(A\*B)/dB of size
+ \(\texttt{A.rows*B.cols} \times {B.rows*B.cols}\) .
+
+ The function computes partial derivatives of the elements of the matrix product \(A*B\) with regard to
+ the elements of each of the two input matrices. The function is used to compute the Jacobian
+ matrices in #stereoCalibrate but can also be used in any other similar optimization function.
objectPoints - Array of object points expressed wrt. the world coordinate frame. A 3xN/Nx3
+ 1-channel or 1xN/Nx1 3-channel (or vector<Point3f> ), where N is the number of points in the view.
+
rvec - The rotation vector (REF: Rodrigues) that, together with tvec, performs a change of
+ basis from world to camera coordinate system, see REF: calibrateCamera for details.
+
tvec - The translation vector, see parameter description above.
+
cameraMatrix - Camera intrinsic matrix \(\cameramatrix{A}\) .
+
distCoeffs - Input vector of distortion coefficients
+ \(\distcoeffs\) . If the vector is empty, the zero distortion coefficients are assumed.
+
imagePoints - Output array of image points, 1xN/Nx1 2-channel, or
+ vector<Point2f> .
+ points with respect to components of the rotation vector, translation vector, focal lengths,
+ coordinates of the principal point and the distortion coefficients. In the old interface different
+ components of the jacobian are returned via different output parameters.
+ function assumes that the aspect ratio (\(f_x / f_y\)) is fixed and correspondingly adjusts the
+ jacobian matrix.
+
+ The function computes the 2D projections of 3D points to the image plane, given intrinsic and
+ extrinsic camera parameters. Optionally, the function computes Jacobians -matrices of partial
+ derivatives of image points coordinates (as functions of all the input parameters) with respect to
+ the particular parameters, intrinsic and/or extrinsic. The Jacobians are used during the global
+ optimization in REF: calibrateCamera, REF: solvePnP, and REF: stereoCalibrate. The function itself
+ can also be used to compute a re-projection error, given the current intrinsic and extrinsic
+ parameters.
+
+ Note: By setting rvec = tvec = \([0, 0, 0]\), or by setting cameraMatrix to a 3x3 identity matrix,
+ or by passing zero distortion coefficients, one can get various useful partial cases of the
+ function. This means, one can compute the distorted coordinates for a sparse set of points or apply
+ a perspective transformation (and also compute the derivatives) in the ideal zero-distortion setup.
objectPoints - Array of object points expressed wrt. the world coordinate frame. A 3xN/Nx3
+ 1-channel or 1xN/Nx1 3-channel (or vector<Point3f> ), where N is the number of points in the view.
+
rvec - The rotation vector (REF: Rodrigues) that, together with tvec, performs a change of
+ basis from world to camera coordinate system, see REF: calibrateCamera for details.
+
tvec - The translation vector, see parameter description above.
+
cameraMatrix - Camera intrinsic matrix \(\cameramatrix{A}\) .
+
distCoeffs - Input vector of distortion coefficients
+ \(\distcoeffs\) . If the vector is empty, the zero distortion coefficients are assumed.
+
imagePoints - Output array of image points, 1xN/Nx1 2-channel, or
+ vector<Point2f> .
+
jacobian - Optional output 2Nx(10+<numDistCoeffs>) jacobian matrix of derivatives of image
+ points with respect to components of the rotation vector, translation vector, focal lengths,
+ coordinates of the principal point and the distortion coefficients. In the old interface different
+ components of the jacobian are returned via different output parameters.
+ function assumes that the aspect ratio (\(f_x / f_y\)) is fixed and correspondingly adjusts the
+ jacobian matrix.
+
+ The function computes the 2D projections of 3D points to the image plane, given intrinsic and
+ extrinsic camera parameters. Optionally, the function computes Jacobians -matrices of partial
+ derivatives of image points coordinates (as functions of all the input parameters) with respect to
+ the particular parameters, intrinsic and/or extrinsic. The Jacobians are used during the global
+ optimization in REF: calibrateCamera, REF: solvePnP, and REF: stereoCalibrate. The function itself
+ can also be used to compute a re-projection error, given the current intrinsic and extrinsic
+ parameters.
+
+ Note: By setting rvec = tvec = \([0, 0, 0]\), or by setting cameraMatrix to a 3x3 identity matrix,
+ or by passing zero distortion coefficients, one can get various useful partial cases of the
+ function. This means, one can compute the distorted coordinates for a sparse set of points or apply
+ a perspective transformation (and also compute the derivatives) in the ideal zero-distortion setup.
public static void projectPoints(MatOfPoint3f objectPoints,
+ Mat rvec,
+ Mat tvec,
+ Mat cameraMatrix,
+ MatOfDouble distCoeffs,
+ MatOfPoint2f imagePoints,
+ Mat jacobian,
+ double aspectRatio)
+
Projects 3D points to an image plane.
+
+
Parameters:
+
objectPoints - Array of object points expressed wrt. the world coordinate frame. A 3xN/Nx3
+ 1-channel or 1xN/Nx1 3-channel (or vector<Point3f> ), where N is the number of points in the view.
+
rvec - The rotation vector (REF: Rodrigues) that, together with tvec, performs a change of
+ basis from world to camera coordinate system, see REF: calibrateCamera for details.
+
tvec - The translation vector, see parameter description above.
+
cameraMatrix - Camera intrinsic matrix \(\cameramatrix{A}\) .
+
distCoeffs - Input vector of distortion coefficients
+ \(\distcoeffs\) . If the vector is empty, the zero distortion coefficients are assumed.
+
imagePoints - Output array of image points, 1xN/Nx1 2-channel, or
+ vector<Point2f> .
+
jacobian - Optional output 2Nx(10+<numDistCoeffs>) jacobian matrix of derivatives of image
+ points with respect to components of the rotation vector, translation vector, focal lengths,
+ coordinates of the principal point and the distortion coefficients. In the old interface different
+ components of the jacobian are returned via different output parameters.
+
aspectRatio - Optional "fixed aspect ratio" parameter. If the parameter is not 0, the
+ function assumes that the aspect ratio (\(f_x / f_y\)) is fixed and correspondingly adjusts the
+ jacobian matrix.
+
+ The function computes the 2D projections of 3D points to the image plane, given intrinsic and
+ extrinsic camera parameters. Optionally, the function computes Jacobians -matrices of partial
+ derivatives of image points coordinates (as functions of all the input parameters) with respect to
+ the particular parameters, intrinsic and/or extrinsic. The Jacobians are used during the global
+ optimization in REF: calibrateCamera, REF: solvePnP, and REF: stereoCalibrate. The function itself
+ can also be used to compute a re-projection error, given the current intrinsic and extrinsic
+ parameters.
+
+ Note: By setting rvec = tvec = \([0, 0, 0]\), or by setting cameraMatrix to a 3x3 identity matrix,
+ or by passing zero distortion coefficients, one can get various useful partial cases of the
+ function. This means, one can compute the distorted coordinates for a sparse set of points or apply
+ a perspective transformation (and also compute the derivatives) in the ideal zero-distortion setup.
public static int recoverPose(Mat E,
+ Mat points1,
+ Mat points2,
+ Mat R,
+ Mat t)
+
+
Parameters:
+
E - The input essential matrix.
+
points1 - Array of N 2D points from the first image. The point coordinates should be
+ floating-point (single or double precision).
+
points2 - Array of the second image points of the same size and format as points1 .
+
R - Output rotation matrix. Together with the translation vector, this matrix makes up a tuple
+ that performs a change of basis from the first camera's coordinate system to the second camera's
+ coordinate system. Note that, in general, t can not be used for this tuple, see the parameter
+ description below.
+
t - Output translation vector. This vector is obtained by REF: decomposeEssentialMat and
+ therefore is only known up to scale, i.e. t is the direction of the translation vector and has unit
+ length.
+ are feature points from cameras with same focal length and principal point.
+ inliers in points1 and points2 for the given essential matrix E. Only these inliers will be used to
+ recover pose. In the output mask only inliers which pass the chirality check.
+
+ This function differs from the one above that it computes camera intrinsic matrix from focal length and
+ principal point:
+
+ \(A =
+ \begin{bmatrix}
+ f & 0 & x_{pp} \\
+ 0 & f & y_{pp} \\
+ 0 & 0 & 1
+ \end{bmatrix}\)
public static int recoverPose(Mat E,
+ Mat points1,
+ Mat points2,
+ Mat R,
+ Mat t,
+ double focal)
+
+
Parameters:
+
E - The input essential matrix.
+
points1 - Array of N 2D points from the first image. The point coordinates should be
+ floating-point (single or double precision).
+
points2 - Array of the second image points of the same size and format as points1 .
+
R - Output rotation matrix. Together with the translation vector, this matrix makes up a tuple
+ that performs a change of basis from the first camera's coordinate system to the second camera's
+ coordinate system. Note that, in general, t can not be used for this tuple, see the parameter
+ description below.
+
t - Output translation vector. This vector is obtained by REF: decomposeEssentialMat and
+ therefore is only known up to scale, i.e. t is the direction of the translation vector and has unit
+ length.
+
focal - Focal length of the camera. Note that this function assumes that points1 and points2
+ are feature points from cameras with same focal length and principal point.
+ inliers in points1 and points2 for the given essential matrix E. Only these inliers will be used to
+ recover pose. In the output mask only inliers which pass the chirality check.
+
+ This function differs from the one above that it computes camera intrinsic matrix from focal length and
+ principal point:
+
+ \(A =
+ \begin{bmatrix}
+ f & 0 & x_{pp} \\
+ 0 & f & y_{pp} \\
+ 0 & 0 & 1
+ \end{bmatrix}\)
public static int recoverPose(Mat E,
+ Mat points1,
+ Mat points2,
+ Mat R,
+ Mat t,
+ double focal,
+ Point pp)
+
+
Parameters:
+
E - The input essential matrix.
+
points1 - Array of N 2D points from the first image. The point coordinates should be
+ floating-point (single or double precision).
+
points2 - Array of the second image points of the same size and format as points1 .
+
R - Output rotation matrix. Together with the translation vector, this matrix makes up a tuple
+ that performs a change of basis from the first camera's coordinate system to the second camera's
+ coordinate system. Note that, in general, t can not be used for this tuple, see the parameter
+ description below.
+
t - Output translation vector. This vector is obtained by REF: decomposeEssentialMat and
+ therefore is only known up to scale, i.e. t is the direction of the translation vector and has unit
+ length.
+
focal - Focal length of the camera. Note that this function assumes that points1 and points2
+ are feature points from cameras with same focal length and principal point.
+
pp - principal point of the camera.
+ inliers in points1 and points2 for the given essential matrix E. Only these inliers will be used to
+ recover pose. In the output mask only inliers which pass the chirality check.
+
+ This function differs from the one above that it computes camera intrinsic matrix from focal length and
+ principal point:
+
+ \(A =
+ \begin{bmatrix}
+ f & 0 & x_{pp} \\
+ 0 & f & y_{pp} \\
+ 0 & 0 & 1
+ \end{bmatrix}\)
public static int recoverPose(Mat E,
+ Mat points1,
+ Mat points2,
+ Mat R,
+ Mat t,
+ double focal,
+ Point pp,
+ Mat mask)
+
+
Parameters:
+
E - The input essential matrix.
+
points1 - Array of N 2D points from the first image. The point coordinates should be
+ floating-point (single or double precision).
+
points2 - Array of the second image points of the same size and format as points1 .
+
R - Output rotation matrix. Together with the translation vector, this matrix makes up a tuple
+ that performs a change of basis from the first camera's coordinate system to the second camera's
+ coordinate system. Note that, in general, t can not be used for this tuple, see the parameter
+ description below.
+
t - Output translation vector. This vector is obtained by REF: decomposeEssentialMat and
+ therefore is only known up to scale, i.e. t is the direction of the translation vector and has unit
+ length.
+
focal - Focal length of the camera. Note that this function assumes that points1 and points2
+ are feature points from cameras with same focal length and principal point.
+
pp - principal point of the camera.
+
mask - Input/output mask for inliers in points1 and points2. If it is not empty, then it marks
+ inliers in points1 and points2 for the given essential matrix E. Only these inliers will be used to
+ recover pose. In the output mask only inliers which pass the chirality check.
+
+ This function differs from the one above that it computes camera intrinsic matrix from focal length and
+ principal point:
+
+ \(A =
+ \begin{bmatrix}
+ f & 0 & x_{pp} \\
+ 0 & f & y_{pp} \\
+ 0 & 0 & 1
+ \end{bmatrix}\)
public static int recoverPose(Mat E,
+ Mat points1,
+ Mat points2,
+ Mat cameraMatrix,
+ Mat R,
+ Mat t)
+
Recovers the relative camera rotation and the translation from an estimated essential
+ matrix and the corresponding points in two images, using chirality check. Returns the number of
+ inliers that pass the check.
+
+
Parameters:
+
E - The input essential matrix.
+
points1 - Array of N 2D points from the first image. The point coordinates should be
+ floating-point (single or double precision).
+
points2 - Array of the second image points of the same size and format as points1 .
+
cameraMatrix - Camera intrinsic matrix \(\cameramatrix{A}\) .
+ Note that this function assumes that points1 and points2 are feature points from cameras with the
+ same camera intrinsic matrix.
+
R - Output rotation matrix. Together with the translation vector, this matrix makes up a tuple
+ that performs a change of basis from the first camera's coordinate system to the second camera's
+ coordinate system. Note that, in general, t can not be used for this tuple, see the parameter
+ described below.
+
t - Output translation vector. This vector is obtained by REF: decomposeEssentialMat and
+ therefore is only known up to scale, i.e. t is the direction of the translation vector and has unit
+ length.
+ inliers in points1 and points2 for the given essential matrix E. Only these inliers will be used to
+ recover pose. In the output mask only inliers which pass the chirality check.
+
+ This function decomposes an essential matrix using REF: decomposeEssentialMat and then verifies
+ possible pose hypotheses by doing chirality check. The chirality check means that the
+ triangulated 3D points should have positive depth. Some details can be found in CITE: Nister03.
+
+ This function can be used to process the output E and mask from REF: findEssentialMat. In this
+ scenario, points1 and points2 are the same input for #findEssentialMat :
+
+ // Example. Estimation of fundamental matrix using the RANSAC algorithm
+ int point_count = 100;
+ vector<Point2f> points1(point_count);
+ vector<Point2f> points2(point_count);
+
+ // initialize the points here ...
+ for( int i = 0; i < point_count; i++ )
+ {
+ points1[i] = ...;
+ points2[i] = ...;
+ }
+
+ // cametra matrix with both focal lengths = 1, and principal point = (0, 0)
+ Mat cameraMatrix = Mat::eye(3, 3, CV_64F);
+
+ Mat E, R, t, mask;
+
+ E = findEssentialMat(points1, points2, cameraMatrix, RANSAC, 0.999, 1.0, mask);
+ recoverPose(E, points1, points2, cameraMatrix, R, t, mask);
+
public static int recoverPose(Mat E,
+ Mat points1,
+ Mat points2,
+ Mat cameraMatrix,
+ Mat R,
+ Mat t,
+ double distanceThresh)
+
+
Parameters:
+
E - The input essential matrix.
+
points1 - Array of N 2D points from the first image. The point coordinates should be
+ floating-point (single or double precision).
+
points2 - Array of the second image points of the same size and format as points1.
+
cameraMatrix - Camera intrinsic matrix \(\cameramatrix{A}\) .
+ Note that this function assumes that points1 and points2 are feature points from cameras with the
+ same camera intrinsic matrix.
+
R - Output rotation matrix. Together with the translation vector, this matrix makes up a tuple
+ that performs a change of basis from the first camera's coordinate system to the second camera's
+ coordinate system. Note that, in general, t can not be used for this tuple, see the parameter
+ description below.
+
t - Output translation vector. This vector is obtained by REF: decomposeEssentialMat and
+ therefore is only known up to scale, i.e. t is the direction of the translation vector and has unit
+ length.
+
distanceThresh - threshold distance which is used to filter out far away points (i.e. infinite
+ points).
+ inliers in points1 and points2 for the given essential matrix E. Only these inliers will be used to
+ recover pose. In the output mask only inliers which pass the chirality check.
+
+ This function differs from the one above that it outputs the triangulated 3D point that are used for
+ the chirality check.
public static int recoverPose(Mat E,
+ Mat points1,
+ Mat points2,
+ Mat cameraMatrix,
+ Mat R,
+ Mat t,
+ double distanceThresh,
+ Mat mask)
+
+
Parameters:
+
E - The input essential matrix.
+
points1 - Array of N 2D points from the first image. The point coordinates should be
+ floating-point (single or double precision).
+
points2 - Array of the second image points of the same size and format as points1.
+
cameraMatrix - Camera intrinsic matrix \(\cameramatrix{A}\) .
+ Note that this function assumes that points1 and points2 are feature points from cameras with the
+ same camera intrinsic matrix.
+
R - Output rotation matrix. Together with the translation vector, this matrix makes up a tuple
+ that performs a change of basis from the first camera's coordinate system to the second camera's
+ coordinate system. Note that, in general, t can not be used for this tuple, see the parameter
+ description below.
+
t - Output translation vector. This vector is obtained by REF: decomposeEssentialMat and
+ therefore is only known up to scale, i.e. t is the direction of the translation vector and has unit
+ length.
+
distanceThresh - threshold distance which is used to filter out far away points (i.e. infinite
+ points).
+
mask - Input/output mask for inliers in points1 and points2. If it is not empty, then it marks
+ inliers in points1 and points2 for the given essential matrix E. Only these inliers will be used to
+ recover pose. In the output mask only inliers which pass the chirality check.
+
+ This function differs from the one above that it outputs the triangulated 3D point that are used for
+ the chirality check.
public static int recoverPose(Mat E,
+ Mat points1,
+ Mat points2,
+ Mat cameraMatrix,
+ Mat R,
+ Mat t,
+ double distanceThresh,
+ Mat mask,
+ Mat triangulatedPoints)
+
+
Parameters:
+
E - The input essential matrix.
+
points1 - Array of N 2D points from the first image. The point coordinates should be
+ floating-point (single or double precision).
+
points2 - Array of the second image points of the same size and format as points1.
+
cameraMatrix - Camera intrinsic matrix \(\cameramatrix{A}\) .
+ Note that this function assumes that points1 and points2 are feature points from cameras with the
+ same camera intrinsic matrix.
+
R - Output rotation matrix. Together with the translation vector, this matrix makes up a tuple
+ that performs a change of basis from the first camera's coordinate system to the second camera's
+ coordinate system. Note that, in general, t can not be used for this tuple, see the parameter
+ description below.
+
t - Output translation vector. This vector is obtained by REF: decomposeEssentialMat and
+ therefore is only known up to scale, i.e. t is the direction of the translation vector and has unit
+ length.
+
distanceThresh - threshold distance which is used to filter out far away points (i.e. infinite
+ points).
+
mask - Input/output mask for inliers in points1 and points2. If it is not empty, then it marks
+ inliers in points1 and points2 for the given essential matrix E. Only these inliers will be used to
+ recover pose. In the output mask only inliers which pass the chirality check.
+
triangulatedPoints - 3D points which were reconstructed by triangulation.
+
+ This function differs from the one above that it outputs the triangulated 3D point that are used for
+ the chirality check.
public static int recoverPose(Mat E,
+ Mat points1,
+ Mat points2,
+ Mat cameraMatrix,
+ Mat R,
+ Mat t,
+ Mat mask)
+
Recovers the relative camera rotation and the translation from an estimated essential
+ matrix and the corresponding points in two images, using chirality check. Returns the number of
+ inliers that pass the check.
+
+
Parameters:
+
E - The input essential matrix.
+
points1 - Array of N 2D points from the first image. The point coordinates should be
+ floating-point (single or double precision).
+
points2 - Array of the second image points of the same size and format as points1 .
+
cameraMatrix - Camera intrinsic matrix \(\cameramatrix{A}\) .
+ Note that this function assumes that points1 and points2 are feature points from cameras with the
+ same camera intrinsic matrix.
+
R - Output rotation matrix. Together with the translation vector, this matrix makes up a tuple
+ that performs a change of basis from the first camera's coordinate system to the second camera's
+ coordinate system. Note that, in general, t can not be used for this tuple, see the parameter
+ described below.
+
t - Output translation vector. This vector is obtained by REF: decomposeEssentialMat and
+ therefore is only known up to scale, i.e. t is the direction of the translation vector and has unit
+ length.
+
mask - Input/output mask for inliers in points1 and points2. If it is not empty, then it marks
+ inliers in points1 and points2 for the given essential matrix E. Only these inliers will be used to
+ recover pose. In the output mask only inliers which pass the chirality check.
+
+ This function decomposes an essential matrix using REF: decomposeEssentialMat and then verifies
+ possible pose hypotheses by doing chirality check. The chirality check means that the
+ triangulated 3D points should have positive depth. Some details can be found in CITE: Nister03.
+
+ This function can be used to process the output E and mask from REF: findEssentialMat. In this
+ scenario, points1 and points2 are the same input for #findEssentialMat :
+
+ // Example. Estimation of fundamental matrix using the RANSAC algorithm
+ int point_count = 100;
+ vector<Point2f> points1(point_count);
+ vector<Point2f> points2(point_count);
+
+ // initialize the points here ...
+ for( int i = 0; i < point_count; i++ )
+ {
+ points1[i] = ...;
+ points2[i] = ...;
+ }
+
+ // cametra matrix with both focal lengths = 1, and principal point = (0, 0)
+ Mat cameraMatrix = Mat::eye(3, 3, CV_64F);
+
+ Mat E, R, t, mask;
+
+ E = findEssentialMat(points1, points2, cameraMatrix, RANSAC, 0.999, 1.0, mask);
+ recoverPose(E, points1, points2, cameraMatrix, R, t, mask);
+
public static int recoverPose(Mat points1,
+ Mat points2,
+ Mat cameraMatrix1,
+ Mat distCoeffs1,
+ Mat cameraMatrix2,
+ Mat distCoeffs2,
+ Mat E,
+ Mat R,
+ Mat t)
+
Recovers the relative camera rotation and the translation from corresponding points in two images from two different cameras, using cheirality check. Returns the number of
+ inliers that pass the check.
+
+
Parameters:
+
points1 - Array of N 2D points from the first image. The point coordinates should be
+ floating-point (single or double precision).
+
points2 - Array of the second image points of the same size and format as points1 .
+
cameraMatrix1 - Input/output camera matrix for the first camera, the same as in
+ REF: calibrateCamera. Furthermore, for the stereo case, additional flags may be used, see below.
+
distCoeffs1 - Input/output vector of distortion coefficients, the same as in
+ REF: calibrateCamera.
+
cameraMatrix2 - Input/output camera matrix for the first camera, the same as in
+ REF: calibrateCamera. Furthermore, for the stereo case, additional flags may be used, see below.
+
distCoeffs2 - Input/output vector of distortion coefficients, the same as in
+ REF: calibrateCamera.
+
E - The output essential matrix.
+
R - Output rotation matrix. Together with the translation vector, this matrix makes up a tuple
+ that performs a change of basis from the first camera's coordinate system to the second camera's
+ coordinate system. Note that, in general, t can not be used for this tuple, see the parameter
+ described below.
+
t - Output translation vector. This vector is obtained by REF: decomposeEssentialMat and
+ therefore is only known up to scale, i.e. t is the direction of the translation vector and has unit
+ length.
+
+
+ REF: RANSAC for the RANSAC algorithm.
+
+
+ REF: LMEDS for the LMedS algorithm.
+
+
+ confidence (probability) that the estimated matrix is correct.
+ line in pixels, beyond which the point is considered an outlier and is not used for computing the
+ final fundamental matrix. It can be set to something like 1-3, depending on the accuracy of the
+ point localization, image resolution, and the image noise.
+ inliers in points1 and points2 for then given essential matrix E. Only these inliers will be used to
+ recover pose. In the output mask only inliers which pass the cheirality check.
+
+ This function decomposes an essential matrix using REF: decomposeEssentialMat and then verifies
+ possible pose hypotheses by doing cheirality check. The cheirality check means that the
+ triangulated 3D points should have positive depth. Some details can be found in CITE: Nister03.
+
+ This function can be used to process the output E and mask from REF: findEssentialMat. In this
+ scenario, points1 and points2 are the same input for findEssentialMat.:
+
+ // Example. Estimation of fundamental matrix using the RANSAC algorithm
+ int point_count = 100;
+ vector<Point2f> points1(point_count);
+ vector<Point2f> points2(point_count);
+
+ // initialize the points here ...
+ for( int i = 0; i < point_count; i++ )
+ {
+ points1[i] = ...;
+ points2[i] = ...;
+ }
+
+ // Input: camera calibration of both cameras, for example using intrinsic chessboard calibration.
+ Mat cameraMatrix1, distCoeffs1, cameraMatrix2, distCoeffs2;
+
+ // Output: Essential matrix, relative rotation and relative translation.
+ Mat E, R, t, mask;
+
+ recoverPose(points1, points2, cameraMatrix1, distCoeffs1, cameraMatrix2, distCoeffs2, E, R, t, mask);
+
public static int recoverPose(Mat points1,
+ Mat points2,
+ Mat cameraMatrix1,
+ Mat distCoeffs1,
+ Mat cameraMatrix2,
+ Mat distCoeffs2,
+ Mat E,
+ Mat R,
+ Mat t,
+ int method)
+
Recovers the relative camera rotation and the translation from corresponding points in two images from two different cameras, using cheirality check. Returns the number of
+ inliers that pass the check.
+
+
Parameters:
+
points1 - Array of N 2D points from the first image. The point coordinates should be
+ floating-point (single or double precision).
+
points2 - Array of the second image points of the same size and format as points1 .
+
cameraMatrix1 - Input/output camera matrix for the first camera, the same as in
+ REF: calibrateCamera. Furthermore, for the stereo case, additional flags may be used, see below.
+
distCoeffs1 - Input/output vector of distortion coefficients, the same as in
+ REF: calibrateCamera.
+
cameraMatrix2 - Input/output camera matrix for the first camera, the same as in
+ REF: calibrateCamera. Furthermore, for the stereo case, additional flags may be used, see below.
+
distCoeffs2 - Input/output vector of distortion coefficients, the same as in
+ REF: calibrateCamera.
+
E - The output essential matrix.
+
R - Output rotation matrix. Together with the translation vector, this matrix makes up a tuple
+ that performs a change of basis from the first camera's coordinate system to the second camera's
+ coordinate system. Note that, in general, t can not be used for this tuple, see the parameter
+ described below.
+
t - Output translation vector. This vector is obtained by REF: decomposeEssentialMat and
+ therefore is only known up to scale, i.e. t is the direction of the translation vector and has unit
+ length.
+
method - Method for computing an essential matrix.
+
+
+ REF: RANSAC for the RANSAC algorithm.
+
+
+ REF: LMEDS for the LMedS algorithm.
+
+
+ confidence (probability) that the estimated matrix is correct.
+ line in pixels, beyond which the point is considered an outlier and is not used for computing the
+ final fundamental matrix. It can be set to something like 1-3, depending on the accuracy of the
+ point localization, image resolution, and the image noise.
+ inliers in points1 and points2 for then given essential matrix E. Only these inliers will be used to
+ recover pose. In the output mask only inliers which pass the cheirality check.
+
+ This function decomposes an essential matrix using REF: decomposeEssentialMat and then verifies
+ possible pose hypotheses by doing cheirality check. The cheirality check means that the
+ triangulated 3D points should have positive depth. Some details can be found in CITE: Nister03.
+
+ This function can be used to process the output E and mask from REF: findEssentialMat. In this
+ scenario, points1 and points2 are the same input for findEssentialMat.:
+
+ // Example. Estimation of fundamental matrix using the RANSAC algorithm
+ int point_count = 100;
+ vector<Point2f> points1(point_count);
+ vector<Point2f> points2(point_count);
+
+ // initialize the points here ...
+ for( int i = 0; i < point_count; i++ )
+ {
+ points1[i] = ...;
+ points2[i] = ...;
+ }
+
+ // Input: camera calibration of both cameras, for example using intrinsic chessboard calibration.
+ Mat cameraMatrix1, distCoeffs1, cameraMatrix2, distCoeffs2;
+
+ // Output: Essential matrix, relative rotation and relative translation.
+ Mat E, R, t, mask;
+
+ recoverPose(points1, points2, cameraMatrix1, distCoeffs1, cameraMatrix2, distCoeffs2, E, R, t, mask);
+
public static int recoverPose(Mat points1,
+ Mat points2,
+ Mat cameraMatrix1,
+ Mat distCoeffs1,
+ Mat cameraMatrix2,
+ Mat distCoeffs2,
+ Mat E,
+ Mat R,
+ Mat t,
+ int method,
+ double prob)
+
Recovers the relative camera rotation and the translation from corresponding points in two images from two different cameras, using cheirality check. Returns the number of
+ inliers that pass the check.
+
+
Parameters:
+
points1 - Array of N 2D points from the first image. The point coordinates should be
+ floating-point (single or double precision).
+
points2 - Array of the second image points of the same size and format as points1 .
+
cameraMatrix1 - Input/output camera matrix for the first camera, the same as in
+ REF: calibrateCamera. Furthermore, for the stereo case, additional flags may be used, see below.
+
distCoeffs1 - Input/output vector of distortion coefficients, the same as in
+ REF: calibrateCamera.
+
cameraMatrix2 - Input/output camera matrix for the first camera, the same as in
+ REF: calibrateCamera. Furthermore, for the stereo case, additional flags may be used, see below.
+
distCoeffs2 - Input/output vector of distortion coefficients, the same as in
+ REF: calibrateCamera.
+
E - The output essential matrix.
+
R - Output rotation matrix. Together with the translation vector, this matrix makes up a tuple
+ that performs a change of basis from the first camera's coordinate system to the second camera's
+ coordinate system. Note that, in general, t can not be used for this tuple, see the parameter
+ described below.
+
t - Output translation vector. This vector is obtained by REF: decomposeEssentialMat and
+ therefore is only known up to scale, i.e. t is the direction of the translation vector and has unit
+ length.
+
method - Method for computing an essential matrix.
+
+
+ REF: RANSAC for the RANSAC algorithm.
+
+
+ REF: LMEDS for the LMedS algorithm.
+
+
+
prob - Parameter used for the RANSAC or LMedS methods only. It specifies a desirable level of
+ confidence (probability) that the estimated matrix is correct.
+ line in pixels, beyond which the point is considered an outlier and is not used for computing the
+ final fundamental matrix. It can be set to something like 1-3, depending on the accuracy of the
+ point localization, image resolution, and the image noise.
+ inliers in points1 and points2 for then given essential matrix E. Only these inliers will be used to
+ recover pose. In the output mask only inliers which pass the cheirality check.
+
+ This function decomposes an essential matrix using REF: decomposeEssentialMat and then verifies
+ possible pose hypotheses by doing cheirality check. The cheirality check means that the
+ triangulated 3D points should have positive depth. Some details can be found in CITE: Nister03.
+
+ This function can be used to process the output E and mask from REF: findEssentialMat. In this
+ scenario, points1 and points2 are the same input for findEssentialMat.:
+
+ // Example. Estimation of fundamental matrix using the RANSAC algorithm
+ int point_count = 100;
+ vector<Point2f> points1(point_count);
+ vector<Point2f> points2(point_count);
+
+ // initialize the points here ...
+ for( int i = 0; i < point_count; i++ )
+ {
+ points1[i] = ...;
+ points2[i] = ...;
+ }
+
+ // Input: camera calibration of both cameras, for example using intrinsic chessboard calibration.
+ Mat cameraMatrix1, distCoeffs1, cameraMatrix2, distCoeffs2;
+
+ // Output: Essential matrix, relative rotation and relative translation.
+ Mat E, R, t, mask;
+
+ recoverPose(points1, points2, cameraMatrix1, distCoeffs1, cameraMatrix2, distCoeffs2, E, R, t, mask);
+
public static int recoverPose(Mat points1,
+ Mat points2,
+ Mat cameraMatrix1,
+ Mat distCoeffs1,
+ Mat cameraMatrix2,
+ Mat distCoeffs2,
+ Mat E,
+ Mat R,
+ Mat t,
+ int method,
+ double prob,
+ double threshold)
+
Recovers the relative camera rotation and the translation from corresponding points in two images from two different cameras, using cheirality check. Returns the number of
+ inliers that pass the check.
+
+
Parameters:
+
points1 - Array of N 2D points from the first image. The point coordinates should be
+ floating-point (single or double precision).
+
points2 - Array of the second image points of the same size and format as points1 .
+
cameraMatrix1 - Input/output camera matrix for the first camera, the same as in
+ REF: calibrateCamera. Furthermore, for the stereo case, additional flags may be used, see below.
+
distCoeffs1 - Input/output vector of distortion coefficients, the same as in
+ REF: calibrateCamera.
+
cameraMatrix2 - Input/output camera matrix for the first camera, the same as in
+ REF: calibrateCamera. Furthermore, for the stereo case, additional flags may be used, see below.
+
distCoeffs2 - Input/output vector of distortion coefficients, the same as in
+ REF: calibrateCamera.
+
E - The output essential matrix.
+
R - Output rotation matrix. Together with the translation vector, this matrix makes up a tuple
+ that performs a change of basis from the first camera's coordinate system to the second camera's
+ coordinate system. Note that, in general, t can not be used for this tuple, see the parameter
+ described below.
+
t - Output translation vector. This vector is obtained by REF: decomposeEssentialMat and
+ therefore is only known up to scale, i.e. t is the direction of the translation vector and has unit
+ length.
+
method - Method for computing an essential matrix.
+
+
+ REF: RANSAC for the RANSAC algorithm.
+
+
+ REF: LMEDS for the LMedS algorithm.
+
+
+
prob - Parameter used for the RANSAC or LMedS methods only. It specifies a desirable level of
+ confidence (probability) that the estimated matrix is correct.
+
threshold - Parameter used for RANSAC. It is the maximum distance from a point to an epipolar
+ line in pixels, beyond which the point is considered an outlier and is not used for computing the
+ final fundamental matrix. It can be set to something like 1-3, depending on the accuracy of the
+ point localization, image resolution, and the image noise.
+ inliers in points1 and points2 for then given essential matrix E. Only these inliers will be used to
+ recover pose. In the output mask only inliers which pass the cheirality check.
+
+ This function decomposes an essential matrix using REF: decomposeEssentialMat and then verifies
+ possible pose hypotheses by doing cheirality check. The cheirality check means that the
+ triangulated 3D points should have positive depth. Some details can be found in CITE: Nister03.
+
+ This function can be used to process the output E and mask from REF: findEssentialMat. In this
+ scenario, points1 and points2 are the same input for findEssentialMat.:
+
+ // Example. Estimation of fundamental matrix using the RANSAC algorithm
+ int point_count = 100;
+ vector<Point2f> points1(point_count);
+ vector<Point2f> points2(point_count);
+
+ // initialize the points here ...
+ for( int i = 0; i < point_count; i++ )
+ {
+ points1[i] = ...;
+ points2[i] = ...;
+ }
+
+ // Input: camera calibration of both cameras, for example using intrinsic chessboard calibration.
+ Mat cameraMatrix1, distCoeffs1, cameraMatrix2, distCoeffs2;
+
+ // Output: Essential matrix, relative rotation and relative translation.
+ Mat E, R, t, mask;
+
+ recoverPose(points1, points2, cameraMatrix1, distCoeffs1, cameraMatrix2, distCoeffs2, E, R, t, mask);
+
public static int recoverPose(Mat points1,
+ Mat points2,
+ Mat cameraMatrix1,
+ Mat distCoeffs1,
+ Mat cameraMatrix2,
+ Mat distCoeffs2,
+ Mat E,
+ Mat R,
+ Mat t,
+ int method,
+ double prob,
+ double threshold,
+ Mat mask)
+
Recovers the relative camera rotation and the translation from corresponding points in two images from two different cameras, using cheirality check. Returns the number of
+ inliers that pass the check.
+
+
Parameters:
+
points1 - Array of N 2D points from the first image. The point coordinates should be
+ floating-point (single or double precision).
+
points2 - Array of the second image points of the same size and format as points1 .
+
cameraMatrix1 - Input/output camera matrix for the first camera, the same as in
+ REF: calibrateCamera. Furthermore, for the stereo case, additional flags may be used, see below.
+
distCoeffs1 - Input/output vector of distortion coefficients, the same as in
+ REF: calibrateCamera.
+
cameraMatrix2 - Input/output camera matrix for the first camera, the same as in
+ REF: calibrateCamera. Furthermore, for the stereo case, additional flags may be used, see below.
+
distCoeffs2 - Input/output vector of distortion coefficients, the same as in
+ REF: calibrateCamera.
+
E - The output essential matrix.
+
R - Output rotation matrix. Together with the translation vector, this matrix makes up a tuple
+ that performs a change of basis from the first camera's coordinate system to the second camera's
+ coordinate system. Note that, in general, t can not be used for this tuple, see the parameter
+ described below.
+
t - Output translation vector. This vector is obtained by REF: decomposeEssentialMat and
+ therefore is only known up to scale, i.e. t is the direction of the translation vector and has unit
+ length.
+
method - Method for computing an essential matrix.
+
+
+ REF: RANSAC for the RANSAC algorithm.
+
+
+ REF: LMEDS for the LMedS algorithm.
+
+
+
prob - Parameter used for the RANSAC or LMedS methods only. It specifies a desirable level of
+ confidence (probability) that the estimated matrix is correct.
+
threshold - Parameter used for RANSAC. It is the maximum distance from a point to an epipolar
+ line in pixels, beyond which the point is considered an outlier and is not used for computing the
+ final fundamental matrix. It can be set to something like 1-3, depending on the accuracy of the
+ point localization, image resolution, and the image noise.
+
mask - Input/output mask for inliers in points1 and points2. If it is not empty, then it marks
+ inliers in points1 and points2 for then given essential matrix E. Only these inliers will be used to
+ recover pose. In the output mask only inliers which pass the cheirality check.
+
+ This function decomposes an essential matrix using REF: decomposeEssentialMat and then verifies
+ possible pose hypotheses by doing cheirality check. The cheirality check means that the
+ triangulated 3D points should have positive depth. Some details can be found in CITE: Nister03.
+
+ This function can be used to process the output E and mask from REF: findEssentialMat. In this
+ scenario, points1 and points2 are the same input for findEssentialMat.:
+
+ // Example. Estimation of fundamental matrix using the RANSAC algorithm
+ int point_count = 100;
+ vector<Point2f> points1(point_count);
+ vector<Point2f> points2(point_count);
+
+ // initialize the points here ...
+ for( int i = 0; i < point_count; i++ )
+ {
+ points1[i] = ...;
+ points2[i] = ...;
+ }
+
+ // Input: camera calibration of both cameras, for example using intrinsic chessboard calibration.
+ Mat cameraMatrix1, distCoeffs1, cameraMatrix2, distCoeffs2;
+
+ // Output: Essential matrix, relative rotation and relative translation.
+ Mat E, R, t, mask;
+
+ recoverPose(points1, points2, cameraMatrix1, distCoeffs1, cameraMatrix2, distCoeffs2, E, R, t, mask);
+
public static float rectify3Collinear(Mat cameraMatrix1,
+ Mat distCoeffs1,
+ Mat cameraMatrix2,
+ Mat distCoeffs2,
+ Mat cameraMatrix3,
+ Mat distCoeffs3,
+ java.util.List<Mat> imgpt1,
+ java.util.List<Mat> imgpt3,
+ Size imageSize,
+ Mat R12,
+ Mat T12,
+ Mat R13,
+ Mat T13,
+ Mat R1,
+ Mat R2,
+ Mat R3,
+ Mat P1,
+ Mat P2,
+ Mat P3,
+ Mat Q,
+ double alpha,
+ Size newImgSize,
+ Rect roi1,
+ Rect roi2,
+ int flags)
public static void reprojectImageTo3D(Mat disparity,
+ Mat _3dImage,
+ Mat Q)
+
Reprojects a disparity image to 3D space.
+
+
Parameters:
+
disparity - Input single-channel 8-bit unsigned, 16-bit signed, 32-bit signed or 32-bit
+ floating-point disparity image. The values of 8-bit / 16-bit signed formats are assumed to have no
+ fractional bits. If the disparity is 16-bit signed format, as computed by REF: StereoBM or
+ REF: StereoSGBM and maybe other algorithms, it should be divided by 16 (and scaled to float) before
+ being used here.
+
_3dImage - Output 3-channel floating-point image of the same size as disparity. Each element of
+ _3dImage(x,y) contains 3D coordinates of the point (x,y) computed from the disparity map. If one
+ uses Q obtained by REF: stereoRectify, then the returned points are represented in the first
+ camera's rectified coordinate system.
+
Q - \(4 \times 4\) perspective transformation matrix that can be obtained with
+ REF: stereoRectify.
+ points where the disparity was not computed). If handleMissingValues=true, then pixels with the
+ minimal disparity that corresponds to the outliers (see StereoMatcher::compute ) are transformed
+ to 3D points with a very large Z value (currently set to 10000).
+ depth. ddepth can also be set to CV_16S, CV_32S or CV_32F.
+
+ The function transforms a single-channel disparity map to a 3-channel image representing a 3D
+ surface. That is, for each pixel (x,y) and the corresponding disparity d=disparity(x,y) , it
+ computes:
+
+ \(\begin{bmatrix}
+ X \\
+ Y \\
+ Z \\
+ W
+ \end{bmatrix} = Q \begin{bmatrix}
+ x \\
+ y \\
+ \texttt{disparity} (x,y) \\
+ z
+ \end{bmatrix}.\)
+
+ SEE:
+ To reproject a sparse set of points {(x,y,d),...} to 3D space, use perspectiveTransform.
public static void reprojectImageTo3D(Mat disparity,
+ Mat _3dImage,
+ Mat Q,
+ boolean handleMissingValues)
+
Reprojects a disparity image to 3D space.
+
+
Parameters:
+
disparity - Input single-channel 8-bit unsigned, 16-bit signed, 32-bit signed or 32-bit
+ floating-point disparity image. The values of 8-bit / 16-bit signed formats are assumed to have no
+ fractional bits. If the disparity is 16-bit signed format, as computed by REF: StereoBM or
+ REF: StereoSGBM and maybe other algorithms, it should be divided by 16 (and scaled to float) before
+ being used here.
+
_3dImage - Output 3-channel floating-point image of the same size as disparity. Each element of
+ _3dImage(x,y) contains 3D coordinates of the point (x,y) computed from the disparity map. If one
+ uses Q obtained by REF: stereoRectify, then the returned points are represented in the first
+ camera's rectified coordinate system.
+
Q - \(4 \times 4\) perspective transformation matrix that can be obtained with
+ REF: stereoRectify.
+
handleMissingValues - Indicates, whether the function should handle missing values (i.e.
+ points where the disparity was not computed). If handleMissingValues=true, then pixels with the
+ minimal disparity that corresponds to the outliers (see StereoMatcher::compute ) are transformed
+ to 3D points with a very large Z value (currently set to 10000).
+ depth. ddepth can also be set to CV_16S, CV_32S or CV_32F.
+
+ The function transforms a single-channel disparity map to a 3-channel image representing a 3D
+ surface. That is, for each pixel (x,y) and the corresponding disparity d=disparity(x,y) , it
+ computes:
+
+ \(\begin{bmatrix}
+ X \\
+ Y \\
+ Z \\
+ W
+ \end{bmatrix} = Q \begin{bmatrix}
+ x \\
+ y \\
+ \texttt{disparity} (x,y) \\
+ z
+ \end{bmatrix}.\)
+
+ SEE:
+ To reproject a sparse set of points {(x,y,d),...} to 3D space, use perspectiveTransform.
public static void reprojectImageTo3D(Mat disparity,
+ Mat _3dImage,
+ Mat Q,
+ boolean handleMissingValues,
+ int ddepth)
+
Reprojects a disparity image to 3D space.
+
+
Parameters:
+
disparity - Input single-channel 8-bit unsigned, 16-bit signed, 32-bit signed or 32-bit
+ floating-point disparity image. The values of 8-bit / 16-bit signed formats are assumed to have no
+ fractional bits. If the disparity is 16-bit signed format, as computed by REF: StereoBM or
+ REF: StereoSGBM and maybe other algorithms, it should be divided by 16 (and scaled to float) before
+ being used here.
+
_3dImage - Output 3-channel floating-point image of the same size as disparity. Each element of
+ _3dImage(x,y) contains 3D coordinates of the point (x,y) computed from the disparity map. If one
+ uses Q obtained by REF: stereoRectify, then the returned points are represented in the first
+ camera's rectified coordinate system.
+
Q - \(4 \times 4\) perspective transformation matrix that can be obtained with
+ REF: stereoRectify.
+
handleMissingValues - Indicates, whether the function should handle missing values (i.e.
+ points where the disparity was not computed). If handleMissingValues=true, then pixels with the
+ minimal disparity that corresponds to the outliers (see StereoMatcher::compute ) are transformed
+ to 3D points with a very large Z value (currently set to 10000).
+
ddepth - The optional output array depth. If it is -1, the output image will have CV_32F
+ depth. ddepth can also be set to CV_16S, CV_32S or CV_32F.
+
+ The function transforms a single-channel disparity map to a 3-channel image representing a 3D
+ surface. That is, for each pixel (x,y) and the corresponding disparity d=disparity(x,y) , it
+ computes:
+
+ \(\begin{bmatrix}
+ X \\
+ Y \\
+ Z \\
+ W
+ \end{bmatrix} = Q \begin{bmatrix}
+ x \\
+ y \\
+ \texttt{disparity} (x,y) \\
+ z
+ \end{bmatrix}.\)
+
+ SEE:
+ To reproject a sparse set of points {(x,y,d),...} to 3D space, use perspectiveTransform.
Converts a rotation matrix to a rotation vector or vice versa.
+
+
Parameters:
+
src - Input rotation vector (3x1 or 1x3) or rotation matrix (3x3).
+
dst - Output rotation matrix (3x3) or rotation vector (3x1 or 1x3), respectively.
+ derivatives of the output array components with respect to the input array components.
+
+ \(\begin{array}{l} \theta \leftarrow norm(r) \\ r \leftarrow r/ \theta \\ R = \cos(\theta) I + (1- \cos{\theta} ) r r^T + \sin(\theta) \vecthreethree{0}{-r_z}{r_y}{r_z}{0}{-r_x}{-r_y}{r_x}{0} \end{array}\)
+
+ Inverse transformation can be also done easily, since
+
+ \(\sin ( \theta ) \vecthreethree{0}{-r_z}{r_y}{r_z}{0}{-r_x}{-r_y}{r_x}{0} = \frac{R - R^T}{2}\)
+
+ A rotation vector is a convenient and most compact representation of a rotation matrix (since any
+ rotation matrix has just 3 degrees of freedom). The representation is used in the global 3D geometry
+ optimization procedures like REF: calibrateCamera, REF: stereoCalibrate, or REF: solvePnP .
+
+ Note: More information about the computation of the derivative of a 3D rotation matrix with respect to its exponential coordinate
+ can be found in:
+
+
+ A Compact Formula for the Derivative of a 3-D Rotation in Exponential Coordinates, Guillermo Gallego, Anthony J. Yezzi CITE: Gallego2014ACF
+
+
+
+ Note: Useful information on SE(3) and Lie Groups can be found in:
+
+
+ A tutorial on SE(3) transformation parameterizations and on-manifold optimization, Jose-Luis Blanco CITE: blanco2010tutorial
+
+
+ Lie Groups for 2D and 3D Transformation, Ethan Eade CITE: Eade17
+
+
+ A micro Lie theory for state estimation in robotics, Joan Solà, Jérémie Deray, Dinesh Atchuthan CITE: Sol2018AML
+
public static void Rodrigues(Mat src,
+ Mat dst,
+ Mat jacobian)
+
Converts a rotation matrix to a rotation vector or vice versa.
+
+
Parameters:
+
src - Input rotation vector (3x1 or 1x3) or rotation matrix (3x3).
+
dst - Output rotation matrix (3x3) or rotation vector (3x1 or 1x3), respectively.
+
jacobian - Optional output Jacobian matrix, 3x9 or 9x3, which is a matrix of partial
+ derivatives of the output array components with respect to the input array components.
+
+ \(\begin{array}{l} \theta \leftarrow norm(r) \\ r \leftarrow r/ \theta \\ R = \cos(\theta) I + (1- \cos{\theta} ) r r^T + \sin(\theta) \vecthreethree{0}{-r_z}{r_y}{r_z}{0}{-r_x}{-r_y}{r_x}{0} \end{array}\)
+
+ Inverse transformation can be also done easily, since
+
+ \(\sin ( \theta ) \vecthreethree{0}{-r_z}{r_y}{r_z}{0}{-r_x}{-r_y}{r_x}{0} = \frac{R - R^T}{2}\)
+
+ A rotation vector is a convenient and most compact representation of a rotation matrix (since any
+ rotation matrix has just 3 degrees of freedom). The representation is used in the global 3D geometry
+ optimization procedures like REF: calibrateCamera, REF: stereoCalibrate, or REF: solvePnP .
+
+ Note: More information about the computation of the derivative of a 3D rotation matrix with respect to its exponential coordinate
+ can be found in:
+
+
+ A Compact Formula for the Derivative of a 3-D Rotation in Exponential Coordinates, Guillermo Gallego, Anthony J. Yezzi CITE: Gallego2014ACF
+
+
+
+ Note: Useful information on SE(3) and Lie Groups can be found in:
+
+
+ A tutorial on SE(3) transformation parameterizations and on-manifold optimization, Jose-Luis Blanco CITE: blanco2010tutorial
+
+
+ Lie Groups for 2D and 3D Transformation, Ethan Eade CITE: Eade17
+
+
+ A micro Lie theory for state estimation in robotics, Joan Solà, Jérémie Deray, Dinesh Atchuthan CITE: Sol2018AML
+
public static double[] RQDecomp3x3(Mat src,
+ Mat mtxR,
+ Mat mtxQ)
+
Computes an RQ decomposition of 3x3 matrices.
+
+
Parameters:
+
src - 3x3 input matrix.
+
mtxR - Output 3x3 upper-triangular matrix.
+
mtxQ - Output 3x3 orthogonal matrix.
+
+ The function computes a RQ decomposition using the given rotations. This function is used in
+ #decomposeProjectionMatrix to decompose the left 3x3 submatrix of a projection matrix into a camera
+ and a rotation matrix.
+
+ It optionally returns three rotation matrices, one for each axis, and the three Euler angles in
+ degrees (as the return value) that could be used in OpenGL. Note, there is always more than one
+ sequence of rotations about the three principal axes that results in the same orientation of an
+ object, e.g. see CITE: Slabaugh . Returned tree rotation matrices and corresponding three Euler angles
+ are only one of the possible solutions.
public static double[] RQDecomp3x3(Mat src,
+ Mat mtxR,
+ Mat mtxQ,
+ Mat Qx)
+
Computes an RQ decomposition of 3x3 matrices.
+
+
Parameters:
+
src - 3x3 input matrix.
+
mtxR - Output 3x3 upper-triangular matrix.
+
mtxQ - Output 3x3 orthogonal matrix.
+
Qx - Optional output 3x3 rotation matrix around x-axis.
+
+ The function computes a RQ decomposition using the given rotations. This function is used in
+ #decomposeProjectionMatrix to decompose the left 3x3 submatrix of a projection matrix into a camera
+ and a rotation matrix.
+
+ It optionally returns three rotation matrices, one for each axis, and the three Euler angles in
+ degrees (as the return value) that could be used in OpenGL. Note, there is always more than one
+ sequence of rotations about the three principal axes that results in the same orientation of an
+ object, e.g. see CITE: Slabaugh . Returned tree rotation matrices and corresponding three Euler angles
+ are only one of the possible solutions.
public static double[] RQDecomp3x3(Mat src,
+ Mat mtxR,
+ Mat mtxQ,
+ Mat Qx,
+ Mat Qy)
+
Computes an RQ decomposition of 3x3 matrices.
+
+
Parameters:
+
src - 3x3 input matrix.
+
mtxR - Output 3x3 upper-triangular matrix.
+
mtxQ - Output 3x3 orthogonal matrix.
+
Qx - Optional output 3x3 rotation matrix around x-axis.
+
Qy - Optional output 3x3 rotation matrix around y-axis.
+
+ The function computes a RQ decomposition using the given rotations. This function is used in
+ #decomposeProjectionMatrix to decompose the left 3x3 submatrix of a projection matrix into a camera
+ and a rotation matrix.
+
+ It optionally returns three rotation matrices, one for each axis, and the three Euler angles in
+ degrees (as the return value) that could be used in OpenGL. Note, there is always more than one
+ sequence of rotations about the three principal axes that results in the same orientation of an
+ object, e.g. see CITE: Slabaugh . Returned tree rotation matrices and corresponding three Euler angles
+ are only one of the possible solutions.
public static double[] RQDecomp3x3(Mat src,
+ Mat mtxR,
+ Mat mtxQ,
+ Mat Qx,
+ Mat Qy,
+ Mat Qz)
+
Computes an RQ decomposition of 3x3 matrices.
+
+
Parameters:
+
src - 3x3 input matrix.
+
mtxR - Output 3x3 upper-triangular matrix.
+
mtxQ - Output 3x3 orthogonal matrix.
+
Qx - Optional output 3x3 rotation matrix around x-axis.
+
Qy - Optional output 3x3 rotation matrix around y-axis.
+
Qz - Optional output 3x3 rotation matrix around z-axis.
+
+ The function computes a RQ decomposition using the given rotations. This function is used in
+ #decomposeProjectionMatrix to decompose the left 3x3 submatrix of a projection matrix into a camera
+ and a rotation matrix.
+
+ It optionally returns three rotation matrices, one for each axis, and the three Euler angles in
+ degrees (as the return value) that could be used in OpenGL. Note, there is always more than one
+ sequence of rotations about the three principal axes that results in the same orientation of an
+ object, e.g. see CITE: Slabaugh . Returned tree rotation matrices and corresponding three Euler angles
+ are only one of the possible solutions.
public static double sampsonDistance(Mat pt1,
+ Mat pt2,
+ Mat F)
+
Calculates the Sampson Distance between two points.
+
+ The function cv::sampsonDistance calculates and returns the first order approximation of the geometric error as:
+ \(
+ sd( \texttt{pt1} , \texttt{pt2} )=
+ \frac{(\texttt{pt2}^t \cdot \texttt{F} \cdot \texttt{pt1})^2}
+ {((\texttt{F} \cdot \texttt{pt1})(0))^2 +
+ ((\texttt{F} \cdot \texttt{pt1})(1))^2 +
+ ((\texttt{F}^t \cdot \texttt{pt2})(0))^2 +
+ ((\texttt{F}^t \cdot \texttt{pt2})(1))^2}
+ \)
+ The fundamental matrix may be calculated using the #findFundamentalMat function. See CITE: HartleyZ00 11.4.3 for details.
public static int solveP3P(Mat objectPoints,
+ Mat imagePoints,
+ Mat cameraMatrix,
+ Mat distCoeffs,
+ java.util.List<Mat> rvecs,
+ java.util.List<Mat> tvecs,
+ int flags)
+
Finds an object pose from 3 3D-2D point correspondences.
+
+ SEE: REF: calib3d_solvePnP
+
+
Parameters:
+
objectPoints - Array of object points in the object coordinate space, 3x3 1-channel or
+ 1x3/3x1 3-channel. vector<Point3f> can be also passed here.
+
imagePoints - Array of corresponding image points, 3x2 1-channel or 1x3/3x1 2-channel.
+ vector<Point2f> can be also passed here.
+
cameraMatrix - Input camera intrinsic matrix \(\cameramatrix{A}\) .
+
distCoeffs - Input vector of distortion coefficients
+ \(\distcoeffs\). If the vector is NULL/empty, the zero distortion coefficients are
+ assumed.
+
rvecs - Output rotation vectors (see REF: Rodrigues ) that, together with tvecs, brings points from
+ the model coordinate system to the camera coordinate system. A P3P problem has up to 4 solutions.
+
tvecs - Output translation vectors.
+
flags - Method for solving a P3P problem:
+
+
+ REF: SOLVEPNP_P3P Method is based on the paper of X.S. Gao, X.-R. Hou, J. Tang, H.-F. Chang
+ "Complete Solution Classification for the Perspective-Three-Point Problem" (CITE: gao2003complete).
+
+
+ REF: SOLVEPNP_AP3P Method is based on the paper of T. Ke and S. Roumeliotis.
+ "An Efficient Algebraic Solution to the Perspective-Three-Point Problem" (CITE: Ke17).
+
+
+
+ The function estimates the object pose given 3 object points, their corresponding image
+ projections, as well as the camera intrinsic matrix and the distortion coefficients.
+
+ Note:
+ The solutions are sorted by reprojection errors (lowest to highest).
Finds an object pose from 3D-2D point correspondences.
+
+ SEE: REF: calib3d_solvePnP
+
+ This function returns the rotation and the translation vectors that transform a 3D point expressed in the object
+ coordinate frame to the camera coordinate frame, using different methods:
+
+
+ P3P methods (REF: SOLVEPNP_P3P, REF: SOLVEPNP_AP3P): need 4 input points to return a unique solution.
+
+
+ REF: SOLVEPNP_IPPE Input points must be >= 4 and object points must be coplanar.
+
+
+ REF: SOLVEPNP_IPPE_SQUARE Special case suitable for marker pose estimation.
+ Number of input points must be 4. Object points must be defined in the following order:
+
+ for all the other flags, number of input points must be >= 4 and object points can be in any configuration.
+
+
+
+
Parameters:
+
objectPoints - Array of object points in the object coordinate space, Nx3 1-channel or
+ 1xN/Nx1 3-channel, where N is the number of points. vector<Point3d> can be also passed here.
+
imagePoints - Array of corresponding image points, Nx2 1-channel or 1xN/Nx1 2-channel,
+ where N is the number of points. vector<Point2d> can be also passed here.
+
cameraMatrix - Input camera intrinsic matrix \(\cameramatrix{A}\) .
+
distCoeffs - Input vector of distortion coefficients
+ \(\distcoeffs\). If the vector is NULL/empty, the zero distortion coefficients are
+ assumed.
+
rvec - Output rotation vector (see REF: Rodrigues ) that, together with tvec, brings points from
+ the model coordinate system to the camera coordinate system.
+
tvec - Output translation vector.
+ the provided rvec and tvec values as initial approximations of the rotation and translation
+ vectors, respectively, and further optimizes them.
+
+ More information about Perspective-n-Points is described in REF: calib3d_solvePnP
+
+ Note:
+
+
+ An example of how to use solvePnP for planar augmented reality can be found at
+ opencv_source_code/samples/python/plane_ar.py
+
+
+ If you are using Python:
+
+
+ Numpy array slices won't work as input because solvePnP requires contiguous
+ arrays (enforced by the assertion using cv::Mat::checkVector() around line 55 of
+ modules/calib3d/src/solvepnp.cpp version 2.4.9)
+
+
+ The P3P algorithm requires image points to be in an array of shape (N,1,2) due
+ to its calling of #undistortPoints (around line 75 of modules/calib3d/src/solvepnp.cpp version 2.4.9)
+ which requires 2-channel information.
+
+
+ Thus, given some data D = np.array(...) where D.shape = (N,M), in order to use a subset of
+ it as, e.g., imagePoints, one must effectively copy it into a new array: imagePoints =
+ np.ascontiguousarray(D[:,:2]).reshape((N,1,2))
+
+
+
+ The methods REF: SOLVEPNP_DLS and REF: SOLVEPNP_UPNP cannot be used as the current implementations are
+ unstable and sometimes give completely wrong results. If you pass one of these two
+ flags, REF: SOLVEPNP_EPNP method will be used instead.
+
+
+ The minimum number of points is 4 in the general case. In the case of REF: SOLVEPNP_P3P and REF: SOLVEPNP_AP3P
+ methods, it is required to use exactly 4 points (the first 3 points are used to estimate all the solutions
+ of the P3P problem, the last one is used to retain the best solution that minimizes the reprojection error).
+
+
+ With REF: SOLVEPNP_ITERATIVE method and useExtrinsicGuess=true, the minimum number of points is 3 (3 points
+ are sufficient to compute a pose but there are up to 4 solutions). The initial solution should be close to the
+ global solution to converge.
+
+
+ With REF: SOLVEPNP_IPPE input points must be >= 4 and object points must be coplanar.
+
+
+ With REF: SOLVEPNP_IPPE_SQUARE this is a special case suitable for marker pose estimation.
+ Number of input points must be 4. Object points must be defined in the following order:
+
public static boolean solvePnP(MatOfPoint3f objectPoints,
+ MatOfPoint2f imagePoints,
+ Mat cameraMatrix,
+ MatOfDouble distCoeffs,
+ Mat rvec,
+ Mat tvec,
+ boolean useExtrinsicGuess)
+
Finds an object pose from 3D-2D point correspondences.
+
+ SEE: REF: calib3d_solvePnP
+
+ This function returns the rotation and the translation vectors that transform a 3D point expressed in the object
+ coordinate frame to the camera coordinate frame, using different methods:
+
+
+ P3P methods (REF: SOLVEPNP_P3P, REF: SOLVEPNP_AP3P): need 4 input points to return a unique solution.
+
+
+ REF: SOLVEPNP_IPPE Input points must be >= 4 and object points must be coplanar.
+
+
+ REF: SOLVEPNP_IPPE_SQUARE Special case suitable for marker pose estimation.
+ Number of input points must be 4. Object points must be defined in the following order:
+
+ for all the other flags, number of input points must be >= 4 and object points can be in any configuration.
+
+
+
+
Parameters:
+
objectPoints - Array of object points in the object coordinate space, Nx3 1-channel or
+ 1xN/Nx1 3-channel, where N is the number of points. vector<Point3d> can be also passed here.
+
imagePoints - Array of corresponding image points, Nx2 1-channel or 1xN/Nx1 2-channel,
+ where N is the number of points. vector<Point2d> can be also passed here.
+
cameraMatrix - Input camera intrinsic matrix \(\cameramatrix{A}\) .
+
distCoeffs - Input vector of distortion coefficients
+ \(\distcoeffs\). If the vector is NULL/empty, the zero distortion coefficients are
+ assumed.
+
rvec - Output rotation vector (see REF: Rodrigues ) that, together with tvec, brings points from
+ the model coordinate system to the camera coordinate system.
+
tvec - Output translation vector.
+
useExtrinsicGuess - Parameter used for #SOLVEPNP_ITERATIVE. If true (1), the function uses
+ the provided rvec and tvec values as initial approximations of the rotation and translation
+ vectors, respectively, and further optimizes them.
+
+ More information about Perspective-n-Points is described in REF: calib3d_solvePnP
+
+ Note:
+
+
+ An example of how to use solvePnP for planar augmented reality can be found at
+ opencv_source_code/samples/python/plane_ar.py
+
+
+ If you are using Python:
+
+
+ Numpy array slices won't work as input because solvePnP requires contiguous
+ arrays (enforced by the assertion using cv::Mat::checkVector() around line 55 of
+ modules/calib3d/src/solvepnp.cpp version 2.4.9)
+
+
+ The P3P algorithm requires image points to be in an array of shape (N,1,2) due
+ to its calling of #undistortPoints (around line 75 of modules/calib3d/src/solvepnp.cpp version 2.4.9)
+ which requires 2-channel information.
+
+
+ Thus, given some data D = np.array(...) where D.shape = (N,M), in order to use a subset of
+ it as, e.g., imagePoints, one must effectively copy it into a new array: imagePoints =
+ np.ascontiguousarray(D[:,:2]).reshape((N,1,2))
+
+
+
+ The methods REF: SOLVEPNP_DLS and REF: SOLVEPNP_UPNP cannot be used as the current implementations are
+ unstable and sometimes give completely wrong results. If you pass one of these two
+ flags, REF: SOLVEPNP_EPNP method will be used instead.
+
+
+ The minimum number of points is 4 in the general case. In the case of REF: SOLVEPNP_P3P and REF: SOLVEPNP_AP3P
+ methods, it is required to use exactly 4 points (the first 3 points are used to estimate all the solutions
+ of the P3P problem, the last one is used to retain the best solution that minimizes the reprojection error).
+
+
+ With REF: SOLVEPNP_ITERATIVE method and useExtrinsicGuess=true, the minimum number of points is 3 (3 points
+ are sufficient to compute a pose but there are up to 4 solutions). The initial solution should be close to the
+ global solution to converge.
+
+
+ With REF: SOLVEPNP_IPPE input points must be >= 4 and object points must be coplanar.
+
+
+ With REF: SOLVEPNP_IPPE_SQUARE this is a special case suitable for marker pose estimation.
+ Number of input points must be 4. Object points must be defined in the following order:
+
public static boolean solvePnP(MatOfPoint3f objectPoints,
+ MatOfPoint2f imagePoints,
+ Mat cameraMatrix,
+ MatOfDouble distCoeffs,
+ Mat rvec,
+ Mat tvec,
+ boolean useExtrinsicGuess,
+ int flags)
+
Finds an object pose from 3D-2D point correspondences.
+
+ SEE: REF: calib3d_solvePnP
+
+ This function returns the rotation and the translation vectors that transform a 3D point expressed in the object
+ coordinate frame to the camera coordinate frame, using different methods:
+
+
+ P3P methods (REF: SOLVEPNP_P3P, REF: SOLVEPNP_AP3P): need 4 input points to return a unique solution.
+
+
+ REF: SOLVEPNP_IPPE Input points must be >= 4 and object points must be coplanar.
+
+
+ REF: SOLVEPNP_IPPE_SQUARE Special case suitable for marker pose estimation.
+ Number of input points must be 4. Object points must be defined in the following order:
+
+ for all the other flags, number of input points must be >= 4 and object points can be in any configuration.
+
+
+
+
Parameters:
+
objectPoints - Array of object points in the object coordinate space, Nx3 1-channel or
+ 1xN/Nx1 3-channel, where N is the number of points. vector<Point3d> can be also passed here.
+
imagePoints - Array of corresponding image points, Nx2 1-channel or 1xN/Nx1 2-channel,
+ where N is the number of points. vector<Point2d> can be also passed here.
+
cameraMatrix - Input camera intrinsic matrix \(\cameramatrix{A}\) .
+
distCoeffs - Input vector of distortion coefficients
+ \(\distcoeffs\). If the vector is NULL/empty, the zero distortion coefficients are
+ assumed.
+
rvec - Output rotation vector (see REF: Rodrigues ) that, together with tvec, brings points from
+ the model coordinate system to the camera coordinate system.
+
tvec - Output translation vector.
+
useExtrinsicGuess - Parameter used for #SOLVEPNP_ITERATIVE. If true (1), the function uses
+ the provided rvec and tvec values as initial approximations of the rotation and translation
+ vectors, respectively, and further optimizes them.
+
flags - Method for solving a PnP problem: see REF: calib3d_solvePnP_flags
+
+ More information about Perspective-n-Points is described in REF: calib3d_solvePnP
+
+ Note:
+
+
+ An example of how to use solvePnP for planar augmented reality can be found at
+ opencv_source_code/samples/python/plane_ar.py
+
+
+ If you are using Python:
+
+
+ Numpy array slices won't work as input because solvePnP requires contiguous
+ arrays (enforced by the assertion using cv::Mat::checkVector() around line 55 of
+ modules/calib3d/src/solvepnp.cpp version 2.4.9)
+
+
+ The P3P algorithm requires image points to be in an array of shape (N,1,2) due
+ to its calling of #undistortPoints (around line 75 of modules/calib3d/src/solvepnp.cpp version 2.4.9)
+ which requires 2-channel information.
+
+
+ Thus, given some data D = np.array(...) where D.shape = (N,M), in order to use a subset of
+ it as, e.g., imagePoints, one must effectively copy it into a new array: imagePoints =
+ np.ascontiguousarray(D[:,:2]).reshape((N,1,2))
+
+
+
+ The methods REF: SOLVEPNP_DLS and REF: SOLVEPNP_UPNP cannot be used as the current implementations are
+ unstable and sometimes give completely wrong results. If you pass one of these two
+ flags, REF: SOLVEPNP_EPNP method will be used instead.
+
+
+ The minimum number of points is 4 in the general case. In the case of REF: SOLVEPNP_P3P and REF: SOLVEPNP_AP3P
+ methods, it is required to use exactly 4 points (the first 3 points are used to estimate all the solutions
+ of the P3P problem, the last one is used to retain the best solution that minimizes the reprojection error).
+
+
+ With REF: SOLVEPNP_ITERATIVE method and useExtrinsicGuess=true, the minimum number of points is 3 (3 points
+ are sufficient to compute a pose but there are up to 4 solutions). The initial solution should be close to the
+ global solution to converge.
+
+
+ With REF: SOLVEPNP_IPPE input points must be >= 4 and object points must be coplanar.
+
+
+ With REF: SOLVEPNP_IPPE_SQUARE this is a special case suitable for marker pose estimation.
+ Number of input points must be 4. Object points must be defined in the following order:
+
public static int solvePnPGeneric(Mat objectPoints,
+ Mat imagePoints,
+ Mat cameraMatrix,
+ Mat distCoeffs,
+ java.util.List<Mat> rvecs,
+ java.util.List<Mat> tvecs)
+
Finds an object pose from 3D-2D point correspondences.
+
+ SEE: REF: calib3d_solvePnP
+
+ This function returns a list of all the possible solutions (a solution is a <rotation vector, translation vector>
+ couple), depending on the number of input points and the chosen method:
+
+
+ P3P methods (REF: SOLVEPNP_P3P, REF: SOLVEPNP_AP3P): 3 or 4 input points. Number of returned solutions can be between 0 and 4 with 3 input points.
+
+
+ REF: SOLVEPNP_IPPE Input points must be >= 4 and object points must be coplanar. Returns 2 solutions.
+
+
+ REF: SOLVEPNP_IPPE_SQUARE Special case suitable for marker pose estimation.
+ Number of input points must be 4 and 2 solutions are returned. Object points must be defined in the following order:
+
+ for all the other flags, number of input points must be >= 4 and object points can be in any configuration.
+ Only 1 solution is returned.
+
+
+
+
Parameters:
+
objectPoints - Array of object points in the object coordinate space, Nx3 1-channel or
+ 1xN/Nx1 3-channel, where N is the number of points. vector<Point3d> can be also passed here.
+
imagePoints - Array of corresponding image points, Nx2 1-channel or 1xN/Nx1 2-channel,
+ where N is the number of points. vector<Point2d> can be also passed here.
+
cameraMatrix - Input camera intrinsic matrix \(\cameramatrix{A}\) .
+
distCoeffs - Input vector of distortion coefficients
+ \(\distcoeffs\). If the vector is NULL/empty, the zero distortion coefficients are
+ assumed.
+
rvecs - Vector of output rotation vectors (see REF: Rodrigues ) that, together with tvecs, brings points from
+ the model coordinate system to the camera coordinate system.
+
tvecs - Vector of output translation vectors.
+ the provided rvec and tvec values as initial approximations of the rotation and translation
+ vectors, respectively, and further optimizes them.
+ and useExtrinsicGuess is set to true.
+ and useExtrinsicGuess is set to true.
+ (\( \text{RMSE} = \sqrt{\frac{\sum_{i}^{N} \left ( \hat{y_i} - y_i \right )^2}{N}} \)) between the input image points
+ and the 3D object points projected with the estimated pose.
+
+ More information is described in REF: calib3d_solvePnP
+
+ Note:
+
+
+ An example of how to use solvePnP for planar augmented reality can be found at
+ opencv_source_code/samples/python/plane_ar.py
+
+
+ If you are using Python:
+
+
+ Numpy array slices won't work as input because solvePnP requires contiguous
+ arrays (enforced by the assertion using cv::Mat::checkVector() around line 55 of
+ modules/calib3d/src/solvepnp.cpp version 2.4.9)
+
+
+ The P3P algorithm requires image points to be in an array of shape (N,1,2) due
+ to its calling of #undistortPoints (around line 75 of modules/calib3d/src/solvepnp.cpp version 2.4.9)
+ which requires 2-channel information.
+
+
+ Thus, given some data D = np.array(...) where D.shape = (N,M), in order to use a subset of
+ it as, e.g., imagePoints, one must effectively copy it into a new array: imagePoints =
+ np.ascontiguousarray(D[:,:2]).reshape((N,1,2))
+
+
+
+ The methods REF: SOLVEPNP_DLS and REF: SOLVEPNP_UPNP cannot be used as the current implementations are
+ unstable and sometimes give completely wrong results. If you pass one of these two
+ flags, REF: SOLVEPNP_EPNP method will be used instead.
+
+
+ The minimum number of points is 4 in the general case. In the case of REF: SOLVEPNP_P3P and REF: SOLVEPNP_AP3P
+ methods, it is required to use exactly 4 points (the first 3 points are used to estimate all the solutions
+ of the P3P problem, the last one is used to retain the best solution that minimizes the reprojection error).
+
+
+ With REF: SOLVEPNP_ITERATIVE method and useExtrinsicGuess=true, the minimum number of points is 3 (3 points
+ are sufficient to compute a pose but there are up to 4 solutions). The initial solution should be close to the
+ global solution to converge.
+
+
+ With REF: SOLVEPNP_IPPE input points must be >= 4 and object points must be coplanar.
+
+
+ With REF: SOLVEPNP_IPPE_SQUARE this is a special case suitable for marker pose estimation.
+ Number of input points must be 4. Object points must be defined in the following order:
+
public static int solvePnPGeneric(Mat objectPoints,
+ Mat imagePoints,
+ Mat cameraMatrix,
+ Mat distCoeffs,
+ java.util.List<Mat> rvecs,
+ java.util.List<Mat> tvecs,
+ boolean useExtrinsicGuess)
+
Finds an object pose from 3D-2D point correspondences.
+
+ SEE: REF: calib3d_solvePnP
+
+ This function returns a list of all the possible solutions (a solution is a <rotation vector, translation vector>
+ couple), depending on the number of input points and the chosen method:
+
+
+ P3P methods (REF: SOLVEPNP_P3P, REF: SOLVEPNP_AP3P): 3 or 4 input points. Number of returned solutions can be between 0 and 4 with 3 input points.
+
+
+ REF: SOLVEPNP_IPPE Input points must be >= 4 and object points must be coplanar. Returns 2 solutions.
+
+
+ REF: SOLVEPNP_IPPE_SQUARE Special case suitable for marker pose estimation.
+ Number of input points must be 4 and 2 solutions are returned. Object points must be defined in the following order:
+
+ for all the other flags, number of input points must be >= 4 and object points can be in any configuration.
+ Only 1 solution is returned.
+
+
+
+
Parameters:
+
objectPoints - Array of object points in the object coordinate space, Nx3 1-channel or
+ 1xN/Nx1 3-channel, where N is the number of points. vector<Point3d> can be also passed here.
+
imagePoints - Array of corresponding image points, Nx2 1-channel or 1xN/Nx1 2-channel,
+ where N is the number of points. vector<Point2d> can be also passed here.
+
cameraMatrix - Input camera intrinsic matrix \(\cameramatrix{A}\) .
+
distCoeffs - Input vector of distortion coefficients
+ \(\distcoeffs\). If the vector is NULL/empty, the zero distortion coefficients are
+ assumed.
+
rvecs - Vector of output rotation vectors (see REF: Rodrigues ) that, together with tvecs, brings points from
+ the model coordinate system to the camera coordinate system.
+
tvecs - Vector of output translation vectors.
+
useExtrinsicGuess - Parameter used for #SOLVEPNP_ITERATIVE. If true (1), the function uses
+ the provided rvec and tvec values as initial approximations of the rotation and translation
+ vectors, respectively, and further optimizes them.
+ and useExtrinsicGuess is set to true.
+ and useExtrinsicGuess is set to true.
+ (\( \text{RMSE} = \sqrt{\frac{\sum_{i}^{N} \left ( \hat{y_i} - y_i \right )^2}{N}} \)) between the input image points
+ and the 3D object points projected with the estimated pose.
+
+ More information is described in REF: calib3d_solvePnP
+
+ Note:
+
+
+ An example of how to use solvePnP for planar augmented reality can be found at
+ opencv_source_code/samples/python/plane_ar.py
+
+
+ If you are using Python:
+
+
+ Numpy array slices won't work as input because solvePnP requires contiguous
+ arrays (enforced by the assertion using cv::Mat::checkVector() around line 55 of
+ modules/calib3d/src/solvepnp.cpp version 2.4.9)
+
+
+ The P3P algorithm requires image points to be in an array of shape (N,1,2) due
+ to its calling of #undistortPoints (around line 75 of modules/calib3d/src/solvepnp.cpp version 2.4.9)
+ which requires 2-channel information.
+
+
+ Thus, given some data D = np.array(...) where D.shape = (N,M), in order to use a subset of
+ it as, e.g., imagePoints, one must effectively copy it into a new array: imagePoints =
+ np.ascontiguousarray(D[:,:2]).reshape((N,1,2))
+
+
+
+ The methods REF: SOLVEPNP_DLS and REF: SOLVEPNP_UPNP cannot be used as the current implementations are
+ unstable and sometimes give completely wrong results. If you pass one of these two
+ flags, REF: SOLVEPNP_EPNP method will be used instead.
+
+
+ The minimum number of points is 4 in the general case. In the case of REF: SOLVEPNP_P3P and REF: SOLVEPNP_AP3P
+ methods, it is required to use exactly 4 points (the first 3 points are used to estimate all the solutions
+ of the P3P problem, the last one is used to retain the best solution that minimizes the reprojection error).
+
+
+ With REF: SOLVEPNP_ITERATIVE method and useExtrinsicGuess=true, the minimum number of points is 3 (3 points
+ are sufficient to compute a pose but there are up to 4 solutions). The initial solution should be close to the
+ global solution to converge.
+
+
+ With REF: SOLVEPNP_IPPE input points must be >= 4 and object points must be coplanar.
+
+
+ With REF: SOLVEPNP_IPPE_SQUARE this is a special case suitable for marker pose estimation.
+ Number of input points must be 4. Object points must be defined in the following order:
+
public static int solvePnPGeneric(Mat objectPoints,
+ Mat imagePoints,
+ Mat cameraMatrix,
+ Mat distCoeffs,
+ java.util.List<Mat> rvecs,
+ java.util.List<Mat> tvecs,
+ boolean useExtrinsicGuess,
+ int flags)
+
Finds an object pose from 3D-2D point correspondences.
+
+ SEE: REF: calib3d_solvePnP
+
+ This function returns a list of all the possible solutions (a solution is a <rotation vector, translation vector>
+ couple), depending on the number of input points and the chosen method:
+
+
+ P3P methods (REF: SOLVEPNP_P3P, REF: SOLVEPNP_AP3P): 3 or 4 input points. Number of returned solutions can be between 0 and 4 with 3 input points.
+
+
+ REF: SOLVEPNP_IPPE Input points must be >= 4 and object points must be coplanar. Returns 2 solutions.
+
+
+ REF: SOLVEPNP_IPPE_SQUARE Special case suitable for marker pose estimation.
+ Number of input points must be 4 and 2 solutions are returned. Object points must be defined in the following order:
+
+ for all the other flags, number of input points must be >= 4 and object points can be in any configuration.
+ Only 1 solution is returned.
+
+
+
+
Parameters:
+
objectPoints - Array of object points in the object coordinate space, Nx3 1-channel or
+ 1xN/Nx1 3-channel, where N is the number of points. vector<Point3d> can be also passed here.
+
imagePoints - Array of corresponding image points, Nx2 1-channel or 1xN/Nx1 2-channel,
+ where N is the number of points. vector<Point2d> can be also passed here.
+
cameraMatrix - Input camera intrinsic matrix \(\cameramatrix{A}\) .
+
distCoeffs - Input vector of distortion coefficients
+ \(\distcoeffs\). If the vector is NULL/empty, the zero distortion coefficients are
+ assumed.
+
rvecs - Vector of output rotation vectors (see REF: Rodrigues ) that, together with tvecs, brings points from
+ the model coordinate system to the camera coordinate system.
+
tvecs - Vector of output translation vectors.
+
useExtrinsicGuess - Parameter used for #SOLVEPNP_ITERATIVE. If true (1), the function uses
+ the provided rvec and tvec values as initial approximations of the rotation and translation
+ vectors, respectively, and further optimizes them.
+
flags - Method for solving a PnP problem: see REF: calib3d_solvePnP_flags
+ and useExtrinsicGuess is set to true.
+ and useExtrinsicGuess is set to true.
+ (\( \text{RMSE} = \sqrt{\frac{\sum_{i}^{N} \left ( \hat{y_i} - y_i \right )^2}{N}} \)) between the input image points
+ and the 3D object points projected with the estimated pose.
+
+ More information is described in REF: calib3d_solvePnP
+
+ Note:
+
+
+ An example of how to use solvePnP for planar augmented reality can be found at
+ opencv_source_code/samples/python/plane_ar.py
+
+
+ If you are using Python:
+
+
+ Numpy array slices won't work as input because solvePnP requires contiguous
+ arrays (enforced by the assertion using cv::Mat::checkVector() around line 55 of
+ modules/calib3d/src/solvepnp.cpp version 2.4.9)
+
+
+ The P3P algorithm requires image points to be in an array of shape (N,1,2) due
+ to its calling of #undistortPoints (around line 75 of modules/calib3d/src/solvepnp.cpp version 2.4.9)
+ which requires 2-channel information.
+
+
+ Thus, given some data D = np.array(...) where D.shape = (N,M), in order to use a subset of
+ it as, e.g., imagePoints, one must effectively copy it into a new array: imagePoints =
+ np.ascontiguousarray(D[:,:2]).reshape((N,1,2))
+
+
+
+ The methods REF: SOLVEPNP_DLS and REF: SOLVEPNP_UPNP cannot be used as the current implementations are
+ unstable and sometimes give completely wrong results. If you pass one of these two
+ flags, REF: SOLVEPNP_EPNP method will be used instead.
+
+
+ The minimum number of points is 4 in the general case. In the case of REF: SOLVEPNP_P3P and REF: SOLVEPNP_AP3P
+ methods, it is required to use exactly 4 points (the first 3 points are used to estimate all the solutions
+ of the P3P problem, the last one is used to retain the best solution that minimizes the reprojection error).
+
+
+ With REF: SOLVEPNP_ITERATIVE method and useExtrinsicGuess=true, the minimum number of points is 3 (3 points
+ are sufficient to compute a pose but there are up to 4 solutions). The initial solution should be close to the
+ global solution to converge.
+
+
+ With REF: SOLVEPNP_IPPE input points must be >= 4 and object points must be coplanar.
+
+
+ With REF: SOLVEPNP_IPPE_SQUARE this is a special case suitable for marker pose estimation.
+ Number of input points must be 4. Object points must be defined in the following order:
+
public static int solvePnPGeneric(Mat objectPoints,
+ Mat imagePoints,
+ Mat cameraMatrix,
+ Mat distCoeffs,
+ java.util.List<Mat> rvecs,
+ java.util.List<Mat> tvecs,
+ boolean useExtrinsicGuess,
+ int flags,
+ Mat rvec)
+
Finds an object pose from 3D-2D point correspondences.
+
+ SEE: REF: calib3d_solvePnP
+
+ This function returns a list of all the possible solutions (a solution is a <rotation vector, translation vector>
+ couple), depending on the number of input points and the chosen method:
+
+
+ P3P methods (REF: SOLVEPNP_P3P, REF: SOLVEPNP_AP3P): 3 or 4 input points. Number of returned solutions can be between 0 and 4 with 3 input points.
+
+
+ REF: SOLVEPNP_IPPE Input points must be >= 4 and object points must be coplanar. Returns 2 solutions.
+
+
+ REF: SOLVEPNP_IPPE_SQUARE Special case suitable for marker pose estimation.
+ Number of input points must be 4 and 2 solutions are returned. Object points must be defined in the following order:
+
+ for all the other flags, number of input points must be >= 4 and object points can be in any configuration.
+ Only 1 solution is returned.
+
+
+
+
Parameters:
+
objectPoints - Array of object points in the object coordinate space, Nx3 1-channel or
+ 1xN/Nx1 3-channel, where N is the number of points. vector<Point3d> can be also passed here.
+
imagePoints - Array of corresponding image points, Nx2 1-channel or 1xN/Nx1 2-channel,
+ where N is the number of points. vector<Point2d> can be also passed here.
+
cameraMatrix - Input camera intrinsic matrix \(\cameramatrix{A}\) .
+
distCoeffs - Input vector of distortion coefficients
+ \(\distcoeffs\). If the vector is NULL/empty, the zero distortion coefficients are
+ assumed.
+
rvecs - Vector of output rotation vectors (see REF: Rodrigues ) that, together with tvecs, brings points from
+ the model coordinate system to the camera coordinate system.
+
tvecs - Vector of output translation vectors.
+
useExtrinsicGuess - Parameter used for #SOLVEPNP_ITERATIVE. If true (1), the function uses
+ the provided rvec and tvec values as initial approximations of the rotation and translation
+ vectors, respectively, and further optimizes them.
+
flags - Method for solving a PnP problem: see REF: calib3d_solvePnP_flags
+
rvec - Rotation vector used to initialize an iterative PnP refinement algorithm, when flag is REF: SOLVEPNP_ITERATIVE
+ and useExtrinsicGuess is set to true.
+ and useExtrinsicGuess is set to true.
+ (\( \text{RMSE} = \sqrt{\frac{\sum_{i}^{N} \left ( \hat{y_i} - y_i \right )^2}{N}} \)) between the input image points
+ and the 3D object points projected with the estimated pose.
+
+ More information is described in REF: calib3d_solvePnP
+
+ Note:
+
+
+ An example of how to use solvePnP for planar augmented reality can be found at
+ opencv_source_code/samples/python/plane_ar.py
+
+
+ If you are using Python:
+
+
+ Numpy array slices won't work as input because solvePnP requires contiguous
+ arrays (enforced by the assertion using cv::Mat::checkVector() around line 55 of
+ modules/calib3d/src/solvepnp.cpp version 2.4.9)
+
+
+ The P3P algorithm requires image points to be in an array of shape (N,1,2) due
+ to its calling of #undistortPoints (around line 75 of modules/calib3d/src/solvepnp.cpp version 2.4.9)
+ which requires 2-channel information.
+
+
+ Thus, given some data D = np.array(...) where D.shape = (N,M), in order to use a subset of
+ it as, e.g., imagePoints, one must effectively copy it into a new array: imagePoints =
+ np.ascontiguousarray(D[:,:2]).reshape((N,1,2))
+
+
+
+ The methods REF: SOLVEPNP_DLS and REF: SOLVEPNP_UPNP cannot be used as the current implementations are
+ unstable and sometimes give completely wrong results. If you pass one of these two
+ flags, REF: SOLVEPNP_EPNP method will be used instead.
+
+
+ The minimum number of points is 4 in the general case. In the case of REF: SOLVEPNP_P3P and REF: SOLVEPNP_AP3P
+ methods, it is required to use exactly 4 points (the first 3 points are used to estimate all the solutions
+ of the P3P problem, the last one is used to retain the best solution that minimizes the reprojection error).
+
+
+ With REF: SOLVEPNP_ITERATIVE method and useExtrinsicGuess=true, the minimum number of points is 3 (3 points
+ are sufficient to compute a pose but there are up to 4 solutions). The initial solution should be close to the
+ global solution to converge.
+
+
+ With REF: SOLVEPNP_IPPE input points must be >= 4 and object points must be coplanar.
+
+
+ With REF: SOLVEPNP_IPPE_SQUARE this is a special case suitable for marker pose estimation.
+ Number of input points must be 4. Object points must be defined in the following order:
+
public static int solvePnPGeneric(Mat objectPoints,
+ Mat imagePoints,
+ Mat cameraMatrix,
+ Mat distCoeffs,
+ java.util.List<Mat> rvecs,
+ java.util.List<Mat> tvecs,
+ boolean useExtrinsicGuess,
+ int flags,
+ Mat rvec,
+ Mat tvec)
+
Finds an object pose from 3D-2D point correspondences.
+
+ SEE: REF: calib3d_solvePnP
+
+ This function returns a list of all the possible solutions (a solution is a <rotation vector, translation vector>
+ couple), depending on the number of input points and the chosen method:
+
+
+ P3P methods (REF: SOLVEPNP_P3P, REF: SOLVEPNP_AP3P): 3 or 4 input points. Number of returned solutions can be between 0 and 4 with 3 input points.
+
+
+ REF: SOLVEPNP_IPPE Input points must be >= 4 and object points must be coplanar. Returns 2 solutions.
+
+
+ REF: SOLVEPNP_IPPE_SQUARE Special case suitable for marker pose estimation.
+ Number of input points must be 4 and 2 solutions are returned. Object points must be defined in the following order:
+
+ for all the other flags, number of input points must be >= 4 and object points can be in any configuration.
+ Only 1 solution is returned.
+
+
+
+
Parameters:
+
objectPoints - Array of object points in the object coordinate space, Nx3 1-channel or
+ 1xN/Nx1 3-channel, where N is the number of points. vector<Point3d> can be also passed here.
+
imagePoints - Array of corresponding image points, Nx2 1-channel or 1xN/Nx1 2-channel,
+ where N is the number of points. vector<Point2d> can be also passed here.
+
cameraMatrix - Input camera intrinsic matrix \(\cameramatrix{A}\) .
+
distCoeffs - Input vector of distortion coefficients
+ \(\distcoeffs\). If the vector is NULL/empty, the zero distortion coefficients are
+ assumed.
+
rvecs - Vector of output rotation vectors (see REF: Rodrigues ) that, together with tvecs, brings points from
+ the model coordinate system to the camera coordinate system.
+
tvecs - Vector of output translation vectors.
+
useExtrinsicGuess - Parameter used for #SOLVEPNP_ITERATIVE. If true (1), the function uses
+ the provided rvec and tvec values as initial approximations of the rotation and translation
+ vectors, respectively, and further optimizes them.
+
flags - Method for solving a PnP problem: see REF: calib3d_solvePnP_flags
+
rvec - Rotation vector used to initialize an iterative PnP refinement algorithm, when flag is REF: SOLVEPNP_ITERATIVE
+ and useExtrinsicGuess is set to true.
+
tvec - Translation vector used to initialize an iterative PnP refinement algorithm, when flag is REF: SOLVEPNP_ITERATIVE
+ and useExtrinsicGuess is set to true.
+ (\( \text{RMSE} = \sqrt{\frac{\sum_{i}^{N} \left ( \hat{y_i} - y_i \right )^2}{N}} \)) between the input image points
+ and the 3D object points projected with the estimated pose.
+
+ More information is described in REF: calib3d_solvePnP
+
+ Note:
+
+
+ An example of how to use solvePnP for planar augmented reality can be found at
+ opencv_source_code/samples/python/plane_ar.py
+
+
+ If you are using Python:
+
+
+ Numpy array slices won't work as input because solvePnP requires contiguous
+ arrays (enforced by the assertion using cv::Mat::checkVector() around line 55 of
+ modules/calib3d/src/solvepnp.cpp version 2.4.9)
+
+
+ The P3P algorithm requires image points to be in an array of shape (N,1,2) due
+ to its calling of #undistortPoints (around line 75 of modules/calib3d/src/solvepnp.cpp version 2.4.9)
+ which requires 2-channel information.
+
+
+ Thus, given some data D = np.array(...) where D.shape = (N,M), in order to use a subset of
+ it as, e.g., imagePoints, one must effectively copy it into a new array: imagePoints =
+ np.ascontiguousarray(D[:,:2]).reshape((N,1,2))
+
+
+
+ The methods REF: SOLVEPNP_DLS and REF: SOLVEPNP_UPNP cannot be used as the current implementations are
+ unstable and sometimes give completely wrong results. If you pass one of these two
+ flags, REF: SOLVEPNP_EPNP method will be used instead.
+
+
+ The minimum number of points is 4 in the general case. In the case of REF: SOLVEPNP_P3P and REF: SOLVEPNP_AP3P
+ methods, it is required to use exactly 4 points (the first 3 points are used to estimate all the solutions
+ of the P3P problem, the last one is used to retain the best solution that minimizes the reprojection error).
+
+
+ With REF: SOLVEPNP_ITERATIVE method and useExtrinsicGuess=true, the minimum number of points is 3 (3 points
+ are sufficient to compute a pose but there are up to 4 solutions). The initial solution should be close to the
+ global solution to converge.
+
+
+ With REF: SOLVEPNP_IPPE input points must be >= 4 and object points must be coplanar.
+
+
+ With REF: SOLVEPNP_IPPE_SQUARE this is a special case suitable for marker pose estimation.
+ Number of input points must be 4. Object points must be defined in the following order:
+
public static int solvePnPGeneric(Mat objectPoints,
+ Mat imagePoints,
+ Mat cameraMatrix,
+ Mat distCoeffs,
+ java.util.List<Mat> rvecs,
+ java.util.List<Mat> tvecs,
+ boolean useExtrinsicGuess,
+ int flags,
+ Mat rvec,
+ Mat tvec,
+ Mat reprojectionError)
+
Finds an object pose from 3D-2D point correspondences.
+
+ SEE: REF: calib3d_solvePnP
+
+ This function returns a list of all the possible solutions (a solution is a <rotation vector, translation vector>
+ couple), depending on the number of input points and the chosen method:
+
+
+ P3P methods (REF: SOLVEPNP_P3P, REF: SOLVEPNP_AP3P): 3 or 4 input points. Number of returned solutions can be between 0 and 4 with 3 input points.
+
+
+ REF: SOLVEPNP_IPPE Input points must be >= 4 and object points must be coplanar. Returns 2 solutions.
+
+
+ REF: SOLVEPNP_IPPE_SQUARE Special case suitable for marker pose estimation.
+ Number of input points must be 4 and 2 solutions are returned. Object points must be defined in the following order:
+
+ for all the other flags, number of input points must be >= 4 and object points can be in any configuration.
+ Only 1 solution is returned.
+
+
+
+
Parameters:
+
objectPoints - Array of object points in the object coordinate space, Nx3 1-channel or
+ 1xN/Nx1 3-channel, where N is the number of points. vector<Point3d> can be also passed here.
+
imagePoints - Array of corresponding image points, Nx2 1-channel or 1xN/Nx1 2-channel,
+ where N is the number of points. vector<Point2d> can be also passed here.
+
cameraMatrix - Input camera intrinsic matrix \(\cameramatrix{A}\) .
+
distCoeffs - Input vector of distortion coefficients
+ \(\distcoeffs\). If the vector is NULL/empty, the zero distortion coefficients are
+ assumed.
+
rvecs - Vector of output rotation vectors (see REF: Rodrigues ) that, together with tvecs, brings points from
+ the model coordinate system to the camera coordinate system.
+
tvecs - Vector of output translation vectors.
+
useExtrinsicGuess - Parameter used for #SOLVEPNP_ITERATIVE. If true (1), the function uses
+ the provided rvec and tvec values as initial approximations of the rotation and translation
+ vectors, respectively, and further optimizes them.
+
flags - Method for solving a PnP problem: see REF: calib3d_solvePnP_flags
+
rvec - Rotation vector used to initialize an iterative PnP refinement algorithm, when flag is REF: SOLVEPNP_ITERATIVE
+ and useExtrinsicGuess is set to true.
+
tvec - Translation vector used to initialize an iterative PnP refinement algorithm, when flag is REF: SOLVEPNP_ITERATIVE
+ and useExtrinsicGuess is set to true.
+
reprojectionError - Optional vector of reprojection error, that is the RMS error
+ (\( \text{RMSE} = \sqrt{\frac{\sum_{i}^{N} \left ( \hat{y_i} - y_i \right )^2}{N}} \)) between the input image points
+ and the 3D object points projected with the estimated pose.
+
+ More information is described in REF: calib3d_solvePnP
+
+ Note:
+
+
+ An example of how to use solvePnP for planar augmented reality can be found at
+ opencv_source_code/samples/python/plane_ar.py
+
+
+ If you are using Python:
+
+
+ Numpy array slices won't work as input because solvePnP requires contiguous
+ arrays (enforced by the assertion using cv::Mat::checkVector() around line 55 of
+ modules/calib3d/src/solvepnp.cpp version 2.4.9)
+
+
+ The P3P algorithm requires image points to be in an array of shape (N,1,2) due
+ to its calling of #undistortPoints (around line 75 of modules/calib3d/src/solvepnp.cpp version 2.4.9)
+ which requires 2-channel information.
+
+
+ Thus, given some data D = np.array(...) where D.shape = (N,M), in order to use a subset of
+ it as, e.g., imagePoints, one must effectively copy it into a new array: imagePoints =
+ np.ascontiguousarray(D[:,:2]).reshape((N,1,2))
+
+
+
+ The methods REF: SOLVEPNP_DLS and REF: SOLVEPNP_UPNP cannot be used as the current implementations are
+ unstable and sometimes give completely wrong results. If you pass one of these two
+ flags, REF: SOLVEPNP_EPNP method will be used instead.
+
+
+ The minimum number of points is 4 in the general case. In the case of REF: SOLVEPNP_P3P and REF: SOLVEPNP_AP3P
+ methods, it is required to use exactly 4 points (the first 3 points are used to estimate all the solutions
+ of the P3P problem, the last one is used to retain the best solution that minimizes the reprojection error).
+
+
+ With REF: SOLVEPNP_ITERATIVE method and useExtrinsicGuess=true, the minimum number of points is 3 (3 points
+ are sufficient to compute a pose but there are up to 4 solutions). The initial solution should be close to the
+ global solution to converge.
+
+
+ With REF: SOLVEPNP_IPPE input points must be >= 4 and object points must be coplanar.
+
+
+ With REF: SOLVEPNP_IPPE_SQUARE this is a special case suitable for marker pose estimation.
+ Number of input points must be 4. Object points must be defined in the following order:
+
Finds an object pose from 3D-2D point correspondences using the RANSAC scheme.
+
+ SEE: REF: calib3d_solvePnP
+
+
Parameters:
+
objectPoints - Array of object points in the object coordinate space, Nx3 1-channel or
+ 1xN/Nx1 3-channel, where N is the number of points. vector<Point3d> can be also passed here.
+
imagePoints - Array of corresponding image points, Nx2 1-channel or 1xN/Nx1 2-channel,
+ where N is the number of points. vector<Point2d> can be also passed here.
+
cameraMatrix - Input camera intrinsic matrix \(\cameramatrix{A}\) .
+
distCoeffs - Input vector of distortion coefficients
+ \(\distcoeffs\). If the vector is NULL/empty, the zero distortion coefficients are
+ assumed.
+
rvec - Output rotation vector (see REF: Rodrigues ) that, together with tvec, brings points from
+ the model coordinate system to the camera coordinate system.
+
tvec - Output translation vector.
+ the provided rvec and tvec values as initial approximations of the rotation and translation
+ vectors, respectively, and further optimizes them.
+ is the maximum allowed distance between the observed and computed point projections to consider it
+ an inlier.
+
+ The function estimates an object pose given a set of object points, their corresponding image
+ projections, as well as the camera intrinsic matrix and the distortion coefficients. This function finds such
+ a pose that minimizes reprojection error, that is, the sum of squared distances between the observed
+ projections imagePoints and the projected (using REF: projectPoints ) objectPoints. The use of RANSAC
+ makes the function resistant to outliers.
+
+ Note:
+
+
+ An example of how to use solvePNPRansac for object detection can be found at
+ opencv_source_code/samples/cpp/tutorial_code/calib3d/real_time_pose_estimation/
+
+
+ The default method used to estimate the camera pose for the Minimal Sample Sets step
+ is #SOLVEPNP_EPNP. Exceptions are:
+
+
+ if you choose #SOLVEPNP_P3P or #SOLVEPNP_AP3P, these methods will be used.
+
+
+ if the number of input points is equal to 4, #SOLVEPNP_P3P is used.
+
+
+
+ The method used to estimate the camera pose using all the inliers is defined by the
+ flags parameters unless it is equal to #SOLVEPNP_P3P or #SOLVEPNP_AP3P. In this case,
+ the method #SOLVEPNP_EPNP will be used instead.
+
public static boolean solvePnPRansac(MatOfPoint3f objectPoints,
+ MatOfPoint2f imagePoints,
+ Mat cameraMatrix,
+ MatOfDouble distCoeffs,
+ Mat rvec,
+ Mat tvec,
+ boolean useExtrinsicGuess)
+
Finds an object pose from 3D-2D point correspondences using the RANSAC scheme.
+
+ SEE: REF: calib3d_solvePnP
+
+
Parameters:
+
objectPoints - Array of object points in the object coordinate space, Nx3 1-channel or
+ 1xN/Nx1 3-channel, where N is the number of points. vector<Point3d> can be also passed here.
+
imagePoints - Array of corresponding image points, Nx2 1-channel or 1xN/Nx1 2-channel,
+ where N is the number of points. vector<Point2d> can be also passed here.
+
cameraMatrix - Input camera intrinsic matrix \(\cameramatrix{A}\) .
+
distCoeffs - Input vector of distortion coefficients
+ \(\distcoeffs\). If the vector is NULL/empty, the zero distortion coefficients are
+ assumed.
+
rvec - Output rotation vector (see REF: Rodrigues ) that, together with tvec, brings points from
+ the model coordinate system to the camera coordinate system.
+
tvec - Output translation vector.
+
useExtrinsicGuess - Parameter used for REF: SOLVEPNP_ITERATIVE. If true (1), the function uses
+ the provided rvec and tvec values as initial approximations of the rotation and translation
+ vectors, respectively, and further optimizes them.
+ is the maximum allowed distance between the observed and computed point projections to consider it
+ an inlier.
+
+ The function estimates an object pose given a set of object points, their corresponding image
+ projections, as well as the camera intrinsic matrix and the distortion coefficients. This function finds such
+ a pose that minimizes reprojection error, that is, the sum of squared distances between the observed
+ projections imagePoints and the projected (using REF: projectPoints ) objectPoints. The use of RANSAC
+ makes the function resistant to outliers.
+
+ Note:
+
+
+ An example of how to use solvePNPRansac for object detection can be found at
+ opencv_source_code/samples/cpp/tutorial_code/calib3d/real_time_pose_estimation/
+
+
+ The default method used to estimate the camera pose for the Minimal Sample Sets step
+ is #SOLVEPNP_EPNP. Exceptions are:
+
+
+ if you choose #SOLVEPNP_P3P or #SOLVEPNP_AP3P, these methods will be used.
+
+
+ if the number of input points is equal to 4, #SOLVEPNP_P3P is used.
+
+
+
+ The method used to estimate the camera pose using all the inliers is defined by the
+ flags parameters unless it is equal to #SOLVEPNP_P3P or #SOLVEPNP_AP3P. In this case,
+ the method #SOLVEPNP_EPNP will be used instead.
+
public static boolean solvePnPRansac(MatOfPoint3f objectPoints,
+ MatOfPoint2f imagePoints,
+ Mat cameraMatrix,
+ MatOfDouble distCoeffs,
+ Mat rvec,
+ Mat tvec,
+ boolean useExtrinsicGuess,
+ int iterationsCount)
+
Finds an object pose from 3D-2D point correspondences using the RANSAC scheme.
+
+ SEE: REF: calib3d_solvePnP
+
+
Parameters:
+
objectPoints - Array of object points in the object coordinate space, Nx3 1-channel or
+ 1xN/Nx1 3-channel, where N is the number of points. vector<Point3d> can be also passed here.
+
imagePoints - Array of corresponding image points, Nx2 1-channel or 1xN/Nx1 2-channel,
+ where N is the number of points. vector<Point2d> can be also passed here.
+
cameraMatrix - Input camera intrinsic matrix \(\cameramatrix{A}\) .
+
distCoeffs - Input vector of distortion coefficients
+ \(\distcoeffs\). If the vector is NULL/empty, the zero distortion coefficients are
+ assumed.
+
rvec - Output rotation vector (see REF: Rodrigues ) that, together with tvec, brings points from
+ the model coordinate system to the camera coordinate system.
+
tvec - Output translation vector.
+
useExtrinsicGuess - Parameter used for REF: SOLVEPNP_ITERATIVE. If true (1), the function uses
+ the provided rvec and tvec values as initial approximations of the rotation and translation
+ vectors, respectively, and further optimizes them.
+
iterationsCount - Number of iterations.
+ is the maximum allowed distance between the observed and computed point projections to consider it
+ an inlier.
+
+ The function estimates an object pose given a set of object points, their corresponding image
+ projections, as well as the camera intrinsic matrix and the distortion coefficients. This function finds such
+ a pose that minimizes reprojection error, that is, the sum of squared distances between the observed
+ projections imagePoints and the projected (using REF: projectPoints ) objectPoints. The use of RANSAC
+ makes the function resistant to outliers.
+
+ Note:
+
+
+ An example of how to use solvePNPRansac for object detection can be found at
+ opencv_source_code/samples/cpp/tutorial_code/calib3d/real_time_pose_estimation/
+
+
+ The default method used to estimate the camera pose for the Minimal Sample Sets step
+ is #SOLVEPNP_EPNP. Exceptions are:
+
+
+ if you choose #SOLVEPNP_P3P or #SOLVEPNP_AP3P, these methods will be used.
+
+
+ if the number of input points is equal to 4, #SOLVEPNP_P3P is used.
+
+
+
+ The method used to estimate the camera pose using all the inliers is defined by the
+ flags parameters unless it is equal to #SOLVEPNP_P3P or #SOLVEPNP_AP3P. In this case,
+ the method #SOLVEPNP_EPNP will be used instead.
+
public static boolean solvePnPRansac(MatOfPoint3f objectPoints,
+ MatOfPoint2f imagePoints,
+ Mat cameraMatrix,
+ MatOfDouble distCoeffs,
+ Mat rvec,
+ Mat tvec,
+ boolean useExtrinsicGuess,
+ int iterationsCount,
+ float reprojectionError)
+
Finds an object pose from 3D-2D point correspondences using the RANSAC scheme.
+
+ SEE: REF: calib3d_solvePnP
+
+
Parameters:
+
objectPoints - Array of object points in the object coordinate space, Nx3 1-channel or
+ 1xN/Nx1 3-channel, where N is the number of points. vector<Point3d> can be also passed here.
+
imagePoints - Array of corresponding image points, Nx2 1-channel or 1xN/Nx1 2-channel,
+ where N is the number of points. vector<Point2d> can be also passed here.
+
cameraMatrix - Input camera intrinsic matrix \(\cameramatrix{A}\) .
+
distCoeffs - Input vector of distortion coefficients
+ \(\distcoeffs\). If the vector is NULL/empty, the zero distortion coefficients are
+ assumed.
+
rvec - Output rotation vector (see REF: Rodrigues ) that, together with tvec, brings points from
+ the model coordinate system to the camera coordinate system.
+
tvec - Output translation vector.
+
useExtrinsicGuess - Parameter used for REF: SOLVEPNP_ITERATIVE. If true (1), the function uses
+ the provided rvec and tvec values as initial approximations of the rotation and translation
+ vectors, respectively, and further optimizes them.
+
iterationsCount - Number of iterations.
+
reprojectionError - Inlier threshold value used by the RANSAC procedure. The parameter value
+ is the maximum allowed distance between the observed and computed point projections to consider it
+ an inlier.
+
+ The function estimates an object pose given a set of object points, their corresponding image
+ projections, as well as the camera intrinsic matrix and the distortion coefficients. This function finds such
+ a pose that minimizes reprojection error, that is, the sum of squared distances between the observed
+ projections imagePoints and the projected (using REF: projectPoints ) objectPoints. The use of RANSAC
+ makes the function resistant to outliers.
+
+ Note:
+
+
+ An example of how to use solvePNPRansac for object detection can be found at
+ opencv_source_code/samples/cpp/tutorial_code/calib3d/real_time_pose_estimation/
+
+
+ The default method used to estimate the camera pose for the Minimal Sample Sets step
+ is #SOLVEPNP_EPNP. Exceptions are:
+
+
+ if you choose #SOLVEPNP_P3P or #SOLVEPNP_AP3P, these methods will be used.
+
+
+ if the number of input points is equal to 4, #SOLVEPNP_P3P is used.
+
+
+
+ The method used to estimate the camera pose using all the inliers is defined by the
+ flags parameters unless it is equal to #SOLVEPNP_P3P or #SOLVEPNP_AP3P. In this case,
+ the method #SOLVEPNP_EPNP will be used instead.
+
public static boolean solvePnPRansac(MatOfPoint3f objectPoints,
+ MatOfPoint2f imagePoints,
+ Mat cameraMatrix,
+ MatOfDouble distCoeffs,
+ Mat rvec,
+ Mat tvec,
+ boolean useExtrinsicGuess,
+ int iterationsCount,
+ float reprojectionError,
+ double confidence)
+
Finds an object pose from 3D-2D point correspondences using the RANSAC scheme.
+
+ SEE: REF: calib3d_solvePnP
+
+
Parameters:
+
objectPoints - Array of object points in the object coordinate space, Nx3 1-channel or
+ 1xN/Nx1 3-channel, where N is the number of points. vector<Point3d> can be also passed here.
+
imagePoints - Array of corresponding image points, Nx2 1-channel or 1xN/Nx1 2-channel,
+ where N is the number of points. vector<Point2d> can be also passed here.
+
cameraMatrix - Input camera intrinsic matrix \(\cameramatrix{A}\) .
+
distCoeffs - Input vector of distortion coefficients
+ \(\distcoeffs\). If the vector is NULL/empty, the zero distortion coefficients are
+ assumed.
+
rvec - Output rotation vector (see REF: Rodrigues ) that, together with tvec, brings points from
+ the model coordinate system to the camera coordinate system.
+
tvec - Output translation vector.
+
useExtrinsicGuess - Parameter used for REF: SOLVEPNP_ITERATIVE. If true (1), the function uses
+ the provided rvec and tvec values as initial approximations of the rotation and translation
+ vectors, respectively, and further optimizes them.
+
iterationsCount - Number of iterations.
+
reprojectionError - Inlier threshold value used by the RANSAC procedure. The parameter value
+ is the maximum allowed distance between the observed and computed point projections to consider it
+ an inlier.
+
confidence - The probability that the algorithm produces a useful result.
+
+ The function estimates an object pose given a set of object points, their corresponding image
+ projections, as well as the camera intrinsic matrix and the distortion coefficients. This function finds such
+ a pose that minimizes reprojection error, that is, the sum of squared distances between the observed
+ projections imagePoints and the projected (using REF: projectPoints ) objectPoints. The use of RANSAC
+ makes the function resistant to outliers.
+
+ Note:
+
+
+ An example of how to use solvePNPRansac for object detection can be found at
+ opencv_source_code/samples/cpp/tutorial_code/calib3d/real_time_pose_estimation/
+
+
+ The default method used to estimate the camera pose for the Minimal Sample Sets step
+ is #SOLVEPNP_EPNP. Exceptions are:
+
+
+ if you choose #SOLVEPNP_P3P or #SOLVEPNP_AP3P, these methods will be used.
+
+
+ if the number of input points is equal to 4, #SOLVEPNP_P3P is used.
+
+
+
+ The method used to estimate the camera pose using all the inliers is defined by the
+ flags parameters unless it is equal to #SOLVEPNP_P3P or #SOLVEPNP_AP3P. In this case,
+ the method #SOLVEPNP_EPNP will be used instead.
+
public static boolean solvePnPRansac(MatOfPoint3f objectPoints,
+ MatOfPoint2f imagePoints,
+ Mat cameraMatrix,
+ MatOfDouble distCoeffs,
+ Mat rvec,
+ Mat tvec,
+ boolean useExtrinsicGuess,
+ int iterationsCount,
+ float reprojectionError,
+ double confidence,
+ Mat inliers)
+
Finds an object pose from 3D-2D point correspondences using the RANSAC scheme.
+
+ SEE: REF: calib3d_solvePnP
+
+
Parameters:
+
objectPoints - Array of object points in the object coordinate space, Nx3 1-channel or
+ 1xN/Nx1 3-channel, where N is the number of points. vector<Point3d> can be also passed here.
+
imagePoints - Array of corresponding image points, Nx2 1-channel or 1xN/Nx1 2-channel,
+ where N is the number of points. vector<Point2d> can be also passed here.
+
cameraMatrix - Input camera intrinsic matrix \(\cameramatrix{A}\) .
+
distCoeffs - Input vector of distortion coefficients
+ \(\distcoeffs\). If the vector is NULL/empty, the zero distortion coefficients are
+ assumed.
+
rvec - Output rotation vector (see REF: Rodrigues ) that, together with tvec, brings points from
+ the model coordinate system to the camera coordinate system.
+
tvec - Output translation vector.
+
useExtrinsicGuess - Parameter used for REF: SOLVEPNP_ITERATIVE. If true (1), the function uses
+ the provided rvec and tvec values as initial approximations of the rotation and translation
+ vectors, respectively, and further optimizes them.
+
iterationsCount - Number of iterations.
+
reprojectionError - Inlier threshold value used by the RANSAC procedure. The parameter value
+ is the maximum allowed distance between the observed and computed point projections to consider it
+ an inlier.
+
confidence - The probability that the algorithm produces a useful result.
+
inliers - Output vector that contains indices of inliers in objectPoints and imagePoints .
+
+ The function estimates an object pose given a set of object points, their corresponding image
+ projections, as well as the camera intrinsic matrix and the distortion coefficients. This function finds such
+ a pose that minimizes reprojection error, that is, the sum of squared distances between the observed
+ projections imagePoints and the projected (using REF: projectPoints ) objectPoints. The use of RANSAC
+ makes the function resistant to outliers.
+
+ Note:
+
+
+ An example of how to use solvePNPRansac for object detection can be found at
+ opencv_source_code/samples/cpp/tutorial_code/calib3d/real_time_pose_estimation/
+
+
+ The default method used to estimate the camera pose for the Minimal Sample Sets step
+ is #SOLVEPNP_EPNP. Exceptions are:
+
+
+ if you choose #SOLVEPNP_P3P or #SOLVEPNP_AP3P, these methods will be used.
+
+
+ if the number of input points is equal to 4, #SOLVEPNP_P3P is used.
+
+
+
+ The method used to estimate the camera pose using all the inliers is defined by the
+ flags parameters unless it is equal to #SOLVEPNP_P3P or #SOLVEPNP_AP3P. In this case,
+ the method #SOLVEPNP_EPNP will be used instead.
+
public static boolean solvePnPRansac(MatOfPoint3f objectPoints,
+ MatOfPoint2f imagePoints,
+ Mat cameraMatrix,
+ MatOfDouble distCoeffs,
+ Mat rvec,
+ Mat tvec,
+ boolean useExtrinsicGuess,
+ int iterationsCount,
+ float reprojectionError,
+ double confidence,
+ Mat inliers,
+ int flags)
+
Finds an object pose from 3D-2D point correspondences using the RANSAC scheme.
+
+ SEE: REF: calib3d_solvePnP
+
+
Parameters:
+
objectPoints - Array of object points in the object coordinate space, Nx3 1-channel or
+ 1xN/Nx1 3-channel, where N is the number of points. vector<Point3d> can be also passed here.
+
imagePoints - Array of corresponding image points, Nx2 1-channel or 1xN/Nx1 2-channel,
+ where N is the number of points. vector<Point2d> can be also passed here.
+
cameraMatrix - Input camera intrinsic matrix \(\cameramatrix{A}\) .
+
distCoeffs - Input vector of distortion coefficients
+ \(\distcoeffs\). If the vector is NULL/empty, the zero distortion coefficients are
+ assumed.
+
rvec - Output rotation vector (see REF: Rodrigues ) that, together with tvec, brings points from
+ the model coordinate system to the camera coordinate system.
+
tvec - Output translation vector.
+
useExtrinsicGuess - Parameter used for REF: SOLVEPNP_ITERATIVE. If true (1), the function uses
+ the provided rvec and tvec values as initial approximations of the rotation and translation
+ vectors, respectively, and further optimizes them.
+
iterationsCount - Number of iterations.
+
reprojectionError - Inlier threshold value used by the RANSAC procedure. The parameter value
+ is the maximum allowed distance between the observed and computed point projections to consider it
+ an inlier.
+
confidence - The probability that the algorithm produces a useful result.
+
inliers - Output vector that contains indices of inliers in objectPoints and imagePoints .
+
flags - Method for solving a PnP problem (see REF: solvePnP ).
+
+ The function estimates an object pose given a set of object points, their corresponding image
+ projections, as well as the camera intrinsic matrix and the distortion coefficients. This function finds such
+ a pose that minimizes reprojection error, that is, the sum of squared distances between the observed
+ projections imagePoints and the projected (using REF: projectPoints ) objectPoints. The use of RANSAC
+ makes the function resistant to outliers.
+
+ Note:
+
+
+ An example of how to use solvePNPRansac for object detection can be found at
+ opencv_source_code/samples/cpp/tutorial_code/calib3d/real_time_pose_estimation/
+
+
+ The default method used to estimate the camera pose for the Minimal Sample Sets step
+ is #SOLVEPNP_EPNP. Exceptions are:
+
+
+ if you choose #SOLVEPNP_P3P or #SOLVEPNP_AP3P, these methods will be used.
+
+
+ if the number of input points is equal to 4, #SOLVEPNP_P3P is used.
+
+
+
+ The method used to estimate the camera pose using all the inliers is defined by the
+ flags parameters unless it is equal to #SOLVEPNP_P3P or #SOLVEPNP_AP3P. In this case,
+ the method #SOLVEPNP_EPNP will be used instead.
+
public static void solvePnPRefineLM(Mat objectPoints,
+ Mat imagePoints,
+ Mat cameraMatrix,
+ Mat distCoeffs,
+ Mat rvec,
+ Mat tvec)
+
Refine a pose (the translation and the rotation that transform a 3D point expressed in the object coordinate frame
+ to the camera coordinate frame) from a 3D-2D point correspondences and starting from an initial solution.
+
+ SEE: REF: calib3d_solvePnP
+
+
Parameters:
+
objectPoints - Array of object points in the object coordinate space, Nx3 1-channel or 1xN/Nx1 3-channel,
+ where N is the number of points. vector<Point3d> can also be passed here.
+
imagePoints - Array of corresponding image points, Nx2 1-channel or 1xN/Nx1 2-channel,
+ where N is the number of points. vector<Point2d> can also be passed here.
+
cameraMatrix - Input camera intrinsic matrix \(\cameramatrix{A}\) .
+
distCoeffs - Input vector of distortion coefficients
+ \(\distcoeffs\). If the vector is NULL/empty, the zero distortion coefficients are
+ assumed.
+
rvec - Input/Output rotation vector (see REF: Rodrigues ) that, together with tvec, brings points from
+ the model coordinate system to the camera coordinate system. Input values are used as an initial solution.
+
tvec - Input/Output translation vector. Input values are used as an initial solution.
+
+ The function refines the object pose given at least 3 object points, their corresponding image
+ projections, an initial solution for the rotation and translation vector,
+ as well as the camera intrinsic matrix and the distortion coefficients.
+ The function minimizes the projection error with respect to the rotation and the translation vectors, according
+ to a Levenberg-Marquardt iterative minimization CITE: Madsen04 CITE: Eade13 process.
public static void solvePnPRefineLM(Mat objectPoints,
+ Mat imagePoints,
+ Mat cameraMatrix,
+ Mat distCoeffs,
+ Mat rvec,
+ Mat tvec,
+ TermCriteria criteria)
+
Refine a pose (the translation and the rotation that transform a 3D point expressed in the object coordinate frame
+ to the camera coordinate frame) from a 3D-2D point correspondences and starting from an initial solution.
+
+ SEE: REF: calib3d_solvePnP
+
+
Parameters:
+
objectPoints - Array of object points in the object coordinate space, Nx3 1-channel or 1xN/Nx1 3-channel,
+ where N is the number of points. vector<Point3d> can also be passed here.
+
imagePoints - Array of corresponding image points, Nx2 1-channel or 1xN/Nx1 2-channel,
+ where N is the number of points. vector<Point2d> can also be passed here.
+
cameraMatrix - Input camera intrinsic matrix \(\cameramatrix{A}\) .
+
distCoeffs - Input vector of distortion coefficients
+ \(\distcoeffs\). If the vector is NULL/empty, the zero distortion coefficients are
+ assumed.
+
rvec - Input/Output rotation vector (see REF: Rodrigues ) that, together with tvec, brings points from
+ the model coordinate system to the camera coordinate system. Input values are used as an initial solution.
+
tvec - Input/Output translation vector. Input values are used as an initial solution.
+
criteria - Criteria when to stop the Levenberg-Marquard iterative algorithm.
+
+ The function refines the object pose given at least 3 object points, their corresponding image
+ projections, an initial solution for the rotation and translation vector,
+ as well as the camera intrinsic matrix and the distortion coefficients.
+ The function minimizes the projection error with respect to the rotation and the translation vectors, according
+ to a Levenberg-Marquardt iterative minimization CITE: Madsen04 CITE: Eade13 process.
public static void solvePnPRefineVVS(Mat objectPoints,
+ Mat imagePoints,
+ Mat cameraMatrix,
+ Mat distCoeffs,
+ Mat rvec,
+ Mat tvec)
+
Refine a pose (the translation and the rotation that transform a 3D point expressed in the object coordinate frame
+ to the camera coordinate frame) from a 3D-2D point correspondences and starting from an initial solution.
+
+ SEE: REF: calib3d_solvePnP
+
+
Parameters:
+
objectPoints - Array of object points in the object coordinate space, Nx3 1-channel or 1xN/Nx1 3-channel,
+ where N is the number of points. vector<Point3d> can also be passed here.
+
imagePoints - Array of corresponding image points, Nx2 1-channel or 1xN/Nx1 2-channel,
+ where N is the number of points. vector<Point2d> can also be passed here.
+
cameraMatrix - Input camera intrinsic matrix \(\cameramatrix{A}\) .
+
distCoeffs - Input vector of distortion coefficients
+ \(\distcoeffs\). If the vector is NULL/empty, the zero distortion coefficients are
+ assumed.
+
rvec - Input/Output rotation vector (see REF: Rodrigues ) that, together with tvec, brings points from
+ the model coordinate system to the camera coordinate system. Input values are used as an initial solution.
+
tvec - Input/Output translation vector. Input values are used as an initial solution.
+ gain in the Damped Gauss-Newton formulation.
+
+ The function refines the object pose given at least 3 object points, their corresponding image
+ projections, an initial solution for the rotation and translation vector,
+ as well as the camera intrinsic matrix and the distortion coefficients.
+ The function minimizes the projection error with respect to the rotation and the translation vectors, using a
+ virtual visual servoing (VVS) CITE: Chaumette06 CITE: Marchand16 scheme.
public static void solvePnPRefineVVS(Mat objectPoints,
+ Mat imagePoints,
+ Mat cameraMatrix,
+ Mat distCoeffs,
+ Mat rvec,
+ Mat tvec,
+ TermCriteria criteria)
+
Refine a pose (the translation and the rotation that transform a 3D point expressed in the object coordinate frame
+ to the camera coordinate frame) from a 3D-2D point correspondences and starting from an initial solution.
+
+ SEE: REF: calib3d_solvePnP
+
+
Parameters:
+
objectPoints - Array of object points in the object coordinate space, Nx3 1-channel or 1xN/Nx1 3-channel,
+ where N is the number of points. vector<Point3d> can also be passed here.
+
imagePoints - Array of corresponding image points, Nx2 1-channel or 1xN/Nx1 2-channel,
+ where N is the number of points. vector<Point2d> can also be passed here.
+
cameraMatrix - Input camera intrinsic matrix \(\cameramatrix{A}\) .
+
distCoeffs - Input vector of distortion coefficients
+ \(\distcoeffs\). If the vector is NULL/empty, the zero distortion coefficients are
+ assumed.
+
rvec - Input/Output rotation vector (see REF: Rodrigues ) that, together with tvec, brings points from
+ the model coordinate system to the camera coordinate system. Input values are used as an initial solution.
+
tvec - Input/Output translation vector. Input values are used as an initial solution.
+
criteria - Criteria when to stop the Levenberg-Marquard iterative algorithm.
+ gain in the Damped Gauss-Newton formulation.
+
+ The function refines the object pose given at least 3 object points, their corresponding image
+ projections, an initial solution for the rotation and translation vector,
+ as well as the camera intrinsic matrix and the distortion coefficients.
+ The function minimizes the projection error with respect to the rotation and the translation vectors, using a
+ virtual visual servoing (VVS) CITE: Chaumette06 CITE: Marchand16 scheme.
public static void solvePnPRefineVVS(Mat objectPoints,
+ Mat imagePoints,
+ Mat cameraMatrix,
+ Mat distCoeffs,
+ Mat rvec,
+ Mat tvec,
+ TermCriteria criteria,
+ double VVSlambda)
+
Refine a pose (the translation and the rotation that transform a 3D point expressed in the object coordinate frame
+ to the camera coordinate frame) from a 3D-2D point correspondences and starting from an initial solution.
+
+ SEE: REF: calib3d_solvePnP
+
+
Parameters:
+
objectPoints - Array of object points in the object coordinate space, Nx3 1-channel or 1xN/Nx1 3-channel,
+ where N is the number of points. vector<Point3d> can also be passed here.
+
imagePoints - Array of corresponding image points, Nx2 1-channel or 1xN/Nx1 2-channel,
+ where N is the number of points. vector<Point2d> can also be passed here.
+
cameraMatrix - Input camera intrinsic matrix \(\cameramatrix{A}\) .
+
distCoeffs - Input vector of distortion coefficients
+ \(\distcoeffs\). If the vector is NULL/empty, the zero distortion coefficients are
+ assumed.
+
rvec - Input/Output rotation vector (see REF: Rodrigues ) that, together with tvec, brings points from
+ the model coordinate system to the camera coordinate system. Input values are used as an initial solution.
+
tvec - Input/Output translation vector. Input values are used as an initial solution.
+
criteria - Criteria when to stop the Levenberg-Marquard iterative algorithm.
+
VVSlambda - Gain for the virtual visual servoing control law, equivalent to the \(\alpha\)
+ gain in the Damped Gauss-Newton formulation.
+
+ The function refines the object pose given at least 3 object points, their corresponding image
+ projections, an initial solution for the rotation and translation vector,
+ as well as the camera intrinsic matrix and the distortion coefficients.
+ The function minimizes the projection error with respect to the rotation and the translation vectors, using a
+ virtual visual servoing (VVS) CITE: Chaumette06 CITE: Marchand16 scheme.
public static double stereoCalibrate(java.util.List<Mat> objectPoints,
+ java.util.List<Mat> imagePoints1,
+ java.util.List<Mat> imagePoints2,
+ Mat cameraMatrix1,
+ Mat distCoeffs1,
+ Mat cameraMatrix2,
+ Mat distCoeffs2,
+ Size imageSize,
+ Mat R,
+ Mat T,
+ Mat E,
+ Mat F)
public static double stereoCalibrate(java.util.List<Mat> objectPoints,
+ java.util.List<Mat> imagePoints1,
+ java.util.List<Mat> imagePoints2,
+ Mat cameraMatrix1,
+ Mat distCoeffs1,
+ Mat cameraMatrix2,
+ Mat distCoeffs2,
+ Size imageSize,
+ Mat R,
+ Mat T,
+ Mat E,
+ Mat F,
+ int flags)
public static double stereoCalibrate(java.util.List<Mat> objectPoints,
+ java.util.List<Mat> imagePoints1,
+ java.util.List<Mat> imagePoints2,
+ Mat cameraMatrix1,
+ Mat distCoeffs1,
+ Mat cameraMatrix2,
+ Mat distCoeffs2,
+ Size imageSize,
+ Mat R,
+ Mat T,
+ Mat E,
+ Mat F,
+ int flags,
+ TermCriteria criteria)
public static double stereoCalibrate(java.util.List<Mat> objectPoints,
+ java.util.List<Mat> imagePoints1,
+ java.util.List<Mat> imagePoints2,
+ Mat cameraMatrix1,
+ Mat distCoeffs1,
+ Mat cameraMatrix2,
+ Mat distCoeffs2,
+ Size imageSize,
+ Mat R,
+ Mat T,
+ Mat E,
+ Mat F,
+ Mat perViewErrors)
public static double stereoCalibrate(java.util.List<Mat> objectPoints,
+ java.util.List<Mat> imagePoints1,
+ java.util.List<Mat> imagePoints2,
+ Mat cameraMatrix1,
+ Mat distCoeffs1,
+ Mat cameraMatrix2,
+ Mat distCoeffs2,
+ Size imageSize,
+ Mat R,
+ Mat T,
+ Mat E,
+ Mat F,
+ Mat perViewErrors,
+ int flags)
public static double stereoCalibrate(java.util.List<Mat> objectPoints,
+ java.util.List<Mat> imagePoints1,
+ java.util.List<Mat> imagePoints2,
+ Mat cameraMatrix1,
+ Mat distCoeffs1,
+ Mat cameraMatrix2,
+ Mat distCoeffs2,
+ Size imageSize,
+ Mat R,
+ Mat T,
+ Mat E,
+ Mat F,
+ Mat perViewErrors,
+ int flags,
+ TermCriteria criteria)
public static double stereoCalibrateExtended(java.util.List<Mat> objectPoints,
+ java.util.List<Mat> imagePoints1,
+ java.util.List<Mat> imagePoints2,
+ Mat cameraMatrix1,
+ Mat distCoeffs1,
+ Mat cameraMatrix2,
+ Mat distCoeffs2,
+ Size imageSize,
+ Mat R,
+ Mat T,
+ Mat E,
+ Mat F,
+ java.util.List<Mat> rvecs,
+ java.util.List<Mat> tvecs,
+ Mat perViewErrors)
+
Calibrates a stereo camera set up. This function finds the intrinsic parameters
+ for each of the two cameras and the extrinsic parameters between the two cameras.
+
+
Parameters:
+
objectPoints - Vector of vectors of the calibration pattern points. The same structure as
+ in REF: calibrateCamera. For each pattern view, both cameras need to see the same object
+ points. Therefore, objectPoints.size(), imagePoints1.size(), and imagePoints2.size() need to be
+ equal as well as objectPoints[i].size(), imagePoints1[i].size(), and imagePoints2[i].size() need to
+ be equal for each i.
+
imagePoints1 - Vector of vectors of the projections of the calibration pattern points,
+ observed by the first camera. The same structure as in REF: calibrateCamera.
+
imagePoints2 - Vector of vectors of the projections of the calibration pattern points,
+ observed by the second camera. The same structure as in REF: calibrateCamera.
+
cameraMatrix1 - Input/output camera intrinsic matrix for the first camera, the same as in
+ REF: calibrateCamera. Furthermore, for the stereo case, additional flags may be used, see below.
+
distCoeffs1 - Input/output vector of distortion coefficients, the same as in
+ REF: calibrateCamera.
+
cameraMatrix2 - Input/output second camera intrinsic matrix for the second camera. See description for
+ cameraMatrix1.
+
distCoeffs2 - Input/output lens distortion coefficients for the second camera. See
+ description for distCoeffs1.
+
imageSize - Size of the image used only to initialize the camera intrinsic matrices.
+
R - Output rotation matrix. Together with the translation vector T, this matrix brings
+ points given in the first camera's coordinate system to points in the second camera's
+ coordinate system. In more technical terms, the tuple of R and T performs a change of basis
+ from the first camera's coordinate system to the second camera's coordinate system. Due to its
+ duality, this tuple is equivalent to the position of the first camera with respect to the
+ second camera coordinate system.
+
T - Output translation vector, see description above.
+
E - Output essential matrix.
+
F - Output fundamental matrix.
+
rvecs - Output vector of rotation vectors ( REF: Rodrigues ) estimated for each pattern view in the
+ coordinate system of the first camera of the stereo pair (e.g. std::vector<cv::Mat>). More in detail, each
+ i-th rotation vector together with the corresponding i-th translation vector (see the next output parameter
+ description) brings the calibration pattern from the object coordinate space (in which object points are
+ specified) to the camera coordinate space of the first camera of the stereo pair. In more technical terms,
+ the tuple of the i-th rotation and translation vector performs a change of basis from object coordinate space
+ to camera coordinate space of the first camera of the stereo pair.
+
tvecs - Output vector of translation vectors estimated for each pattern view, see parameter description
+ of previous output parameter ( rvecs ).
+
perViewErrors - Output vector of the RMS re-projection error estimated for each pattern view.
+
+
+ REF: CALIB_FIX_INTRINSIC Fix cameraMatrix? and distCoeffs? so that only R, T, E, and F
+ matrices are estimated.
+
+
+ REF: CALIB_USE_INTRINSIC_GUESS Optimize some or all of the intrinsic parameters
+ according to the specified flags. Initial values are provided by the user.
+
+
+ REF: CALIB_USE_EXTRINSIC_GUESS R and T contain valid initial values that are optimized further.
+ Otherwise R and T are initialized to the median value of the pattern views (each dimension separately).
+
+
+ REF: CALIB_FIX_PRINCIPAL_POINT Fix the principal points during the optimization.
+
+
+ REF: CALIB_FIX_FOCAL_LENGTH Fix \(f^{(j)}_x\) and \(f^{(j)}_y\) .
+
+
+ REF: CALIB_FIX_ASPECT_RATIO Optimize \(f^{(j)}_y\) . Fix the ratio \(f^{(j)}_x/f^{(j)}_y\)
+ .
+
+
+ REF: CALIB_SAME_FOCAL_LENGTH Enforce \(f^{(0)}_x=f^{(1)}_x\) and \(f^{(0)}_y=f^{(1)}_y\) .
+
+
+ REF: CALIB_ZERO_TANGENT_DIST Set tangential distortion coefficients for each camera to
+ zeros and fix there.
+
+
+ REF: CALIB_FIX_K1,..., REF: CALIB_FIX_K6 Do not change the corresponding radial
+ distortion coefficient 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 Enable coefficients k4, k5, and k6. To provide the backward
+ compatibility, this extra flag should be explicitly specified to make the calibration
+ function use the rational model and return 8 coefficients. If the flag is not set, the
+ function computes and returns only 5 distortion coefficients.
+
+
+ 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. 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. 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.
+
+
+
+ The function estimates the transformation between two cameras making a stereo pair. If one computes
+ the poses of an object relative to the first camera and to the second camera,
+ ( \(R_1\),\(T_1\) ) and (\(R_2\),\(T_2\)), respectively, for a stereo camera where the
+ relative position and orientation between the two cameras are fixed, then those poses definitely
+ relate to each other. This means, if the relative position and orientation (\(R\),\(T\)) of the
+ two cameras is known, it is possible to compute (\(R_2\),\(T_2\)) when (\(R_1\),\(T_1\)) is
+ given. This is what the described function does. It computes (\(R\),\(T\)) such that:
+
+ \(R_2=R R_1\)
+ \(T_2=R T_1 + T.\)
+
+ Therefore, one can compute the coordinate representation of a 3D point for the second camera's
+ coordinate system when given the point's coordinate representation in the first camera's coordinate
+ system:
+
+ \(\begin{bmatrix}
+ X_2 \\
+ Y_2 \\
+ Z_2 \\
+ 1
+ \end{bmatrix} = \begin{bmatrix}
+ R & T \\
+ 0 & 1
+ \end{bmatrix} \begin{bmatrix}
+ X_1 \\
+ Y_1 \\
+ Z_1 \\
+ 1
+ \end{bmatrix}.\)
+
+
+ Optionally, it computes the essential matrix E:
+
+ \(E= \vecthreethree{0}{-T_2}{T_1}{T_2}{0}{-T_0}{-T_1}{T_0}{0} R\)
+
+ where \(T_i\) are components of the translation vector \(T\) : \(T=[T_0, T_1, T_2]^T\) .
+ And the function can also compute the fundamental matrix F:
+
+ \(F = cameraMatrix2^{-T}\cdot E \cdot cameraMatrix1^{-1}\)
+
+ Besides the stereo-related information, the function can also perform a full calibration of each of
+ the two cameras. However, due to the high dimensionality of the parameter space and noise in the
+ input data, the function can diverge from the correct solution. If the intrinsic parameters can be
+ estimated with high accuracy for each of the cameras individually (for example, using
+ #calibrateCamera ), you are recommended to do so and then pass REF: CALIB_FIX_INTRINSIC flag to the
+ function along with the computed intrinsic parameters. Otherwise, if all the parameters are
+ estimated at once, it makes sense to restrict some parameters, for example, pass
+ REF: CALIB_SAME_FOCAL_LENGTH and REF: CALIB_ZERO_TANGENT_DIST flags, which is usually a
+ reasonable assumption.
+
+ Similarly to #calibrateCamera, the function minimizes the total re-projection error for all the
+ points in all the available views from both cameras. The function returns the final value of the
+ re-projection error.
public static double stereoCalibrateExtended(java.util.List<Mat> objectPoints,
+ java.util.List<Mat> imagePoints1,
+ java.util.List<Mat> imagePoints2,
+ Mat cameraMatrix1,
+ Mat distCoeffs1,
+ Mat cameraMatrix2,
+ Mat distCoeffs2,
+ Size imageSize,
+ Mat R,
+ Mat T,
+ Mat E,
+ Mat F,
+ java.util.List<Mat> rvecs,
+ java.util.List<Mat> tvecs,
+ Mat perViewErrors,
+ int flags)
+
Calibrates a stereo camera set up. This function finds the intrinsic parameters
+ for each of the two cameras and the extrinsic parameters between the two cameras.
+
+
Parameters:
+
objectPoints - Vector of vectors of the calibration pattern points. The same structure as
+ in REF: calibrateCamera. For each pattern view, both cameras need to see the same object
+ points. Therefore, objectPoints.size(), imagePoints1.size(), and imagePoints2.size() need to be
+ equal as well as objectPoints[i].size(), imagePoints1[i].size(), and imagePoints2[i].size() need to
+ be equal for each i.
+
imagePoints1 - Vector of vectors of the projections of the calibration pattern points,
+ observed by the first camera. The same structure as in REF: calibrateCamera.
+
imagePoints2 - Vector of vectors of the projections of the calibration pattern points,
+ observed by the second camera. The same structure as in REF: calibrateCamera.
+
cameraMatrix1 - Input/output camera intrinsic matrix for the first camera, the same as in
+ REF: calibrateCamera. Furthermore, for the stereo case, additional flags may be used, see below.
+
distCoeffs1 - Input/output vector of distortion coefficients, the same as in
+ REF: calibrateCamera.
+
cameraMatrix2 - Input/output second camera intrinsic matrix for the second camera. See description for
+ cameraMatrix1.
+
distCoeffs2 - Input/output lens distortion coefficients for the second camera. See
+ description for distCoeffs1.
+
imageSize - Size of the image used only to initialize the camera intrinsic matrices.
+
R - Output rotation matrix. Together with the translation vector T, this matrix brings
+ points given in the first camera's coordinate system to points in the second camera's
+ coordinate system. In more technical terms, the tuple of R and T performs a change of basis
+ from the first camera's coordinate system to the second camera's coordinate system. Due to its
+ duality, this tuple is equivalent to the position of the first camera with respect to the
+ second camera coordinate system.
+
T - Output translation vector, see description above.
+
E - Output essential matrix.
+
F - Output fundamental matrix.
+
rvecs - Output vector of rotation vectors ( REF: Rodrigues ) estimated for each pattern view in the
+ coordinate system of the first camera of the stereo pair (e.g. std::vector<cv::Mat>). More in detail, each
+ i-th rotation vector together with the corresponding i-th translation vector (see the next output parameter
+ description) brings the calibration pattern from the object coordinate space (in which object points are
+ specified) to the camera coordinate space of the first camera of the stereo pair. In more technical terms,
+ the tuple of the i-th rotation and translation vector performs a change of basis from object coordinate space
+ to camera coordinate space of the first camera of the stereo pair.
+
tvecs - Output vector of translation vectors estimated for each pattern view, see parameter description
+ of previous output parameter ( rvecs ).
+
perViewErrors - Output vector of the RMS re-projection error estimated for each pattern view.
+
flags - Different flags that may be zero or a combination of the following values:
+
+
+ REF: CALIB_FIX_INTRINSIC Fix cameraMatrix? and distCoeffs? so that only R, T, E, and F
+ matrices are estimated.
+
+
+ REF: CALIB_USE_INTRINSIC_GUESS Optimize some or all of the intrinsic parameters
+ according to the specified flags. Initial values are provided by the user.
+
+
+ REF: CALIB_USE_EXTRINSIC_GUESS R and T contain valid initial values that are optimized further.
+ Otherwise R and T are initialized to the median value of the pattern views (each dimension separately).
+
+
+ REF: CALIB_FIX_PRINCIPAL_POINT Fix the principal points during the optimization.
+
+
+ REF: CALIB_FIX_FOCAL_LENGTH Fix \(f^{(j)}_x\) and \(f^{(j)}_y\) .
+
+
+ REF: CALIB_FIX_ASPECT_RATIO Optimize \(f^{(j)}_y\) . Fix the ratio \(f^{(j)}_x/f^{(j)}_y\)
+ .
+
+
+ REF: CALIB_SAME_FOCAL_LENGTH Enforce \(f^{(0)}_x=f^{(1)}_x\) and \(f^{(0)}_y=f^{(1)}_y\) .
+
+
+ REF: CALIB_ZERO_TANGENT_DIST Set tangential distortion coefficients for each camera to
+ zeros and fix there.
+
+
+ REF: CALIB_FIX_K1,..., REF: CALIB_FIX_K6 Do not change the corresponding radial
+ distortion coefficient 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 Enable coefficients k4, k5, and k6. To provide the backward
+ compatibility, this extra flag should be explicitly specified to make the calibration
+ function use the rational model and return 8 coefficients. If the flag is not set, the
+ function computes and returns only 5 distortion coefficients.
+
+
+ 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. 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. 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.
+
+
+
+ The function estimates the transformation between two cameras making a stereo pair. If one computes
+ the poses of an object relative to the first camera and to the second camera,
+ ( \(R_1\),\(T_1\) ) and (\(R_2\),\(T_2\)), respectively, for a stereo camera where the
+ relative position and orientation between the two cameras are fixed, then those poses definitely
+ relate to each other. This means, if the relative position and orientation (\(R\),\(T\)) of the
+ two cameras is known, it is possible to compute (\(R_2\),\(T_2\)) when (\(R_1\),\(T_1\)) is
+ given. This is what the described function does. It computes (\(R\),\(T\)) such that:
+
+ \(R_2=R R_1\)
+ \(T_2=R T_1 + T.\)
+
+ Therefore, one can compute the coordinate representation of a 3D point for the second camera's
+ coordinate system when given the point's coordinate representation in the first camera's coordinate
+ system:
+
+ \(\begin{bmatrix}
+ X_2 \\
+ Y_2 \\
+ Z_2 \\
+ 1
+ \end{bmatrix} = \begin{bmatrix}
+ R & T \\
+ 0 & 1
+ \end{bmatrix} \begin{bmatrix}
+ X_1 \\
+ Y_1 \\
+ Z_1 \\
+ 1
+ \end{bmatrix}.\)
+
+
+ Optionally, it computes the essential matrix E:
+
+ \(E= \vecthreethree{0}{-T_2}{T_1}{T_2}{0}{-T_0}{-T_1}{T_0}{0} R\)
+
+ where \(T_i\) are components of the translation vector \(T\) : \(T=[T_0, T_1, T_2]^T\) .
+ And the function can also compute the fundamental matrix F:
+
+ \(F = cameraMatrix2^{-T}\cdot E \cdot cameraMatrix1^{-1}\)
+
+ Besides the stereo-related information, the function can also perform a full calibration of each of
+ the two cameras. However, due to the high dimensionality of the parameter space and noise in the
+ input data, the function can diverge from the correct solution. If the intrinsic parameters can be
+ estimated with high accuracy for each of the cameras individually (for example, using
+ #calibrateCamera ), you are recommended to do so and then pass REF: CALIB_FIX_INTRINSIC flag to the
+ function along with the computed intrinsic parameters. Otherwise, if all the parameters are
+ estimated at once, it makes sense to restrict some parameters, for example, pass
+ REF: CALIB_SAME_FOCAL_LENGTH and REF: CALIB_ZERO_TANGENT_DIST flags, which is usually a
+ reasonable assumption.
+
+ Similarly to #calibrateCamera, the function minimizes the total re-projection error for all the
+ points in all the available views from both cameras. The function returns the final value of the
+ re-projection error.
public static double stereoCalibrateExtended(java.util.List<Mat> objectPoints,
+ java.util.List<Mat> imagePoints1,
+ java.util.List<Mat> imagePoints2,
+ Mat cameraMatrix1,
+ Mat distCoeffs1,
+ Mat cameraMatrix2,
+ Mat distCoeffs2,
+ Size imageSize,
+ Mat R,
+ Mat T,
+ Mat E,
+ Mat F,
+ java.util.List<Mat> rvecs,
+ java.util.List<Mat> tvecs,
+ Mat perViewErrors,
+ int flags,
+ TermCriteria criteria)
+
Calibrates a stereo camera set up. This function finds the intrinsic parameters
+ for each of the two cameras and the extrinsic parameters between the two cameras.
+
+
Parameters:
+
objectPoints - Vector of vectors of the calibration pattern points. The same structure as
+ in REF: calibrateCamera. For each pattern view, both cameras need to see the same object
+ points. Therefore, objectPoints.size(), imagePoints1.size(), and imagePoints2.size() need to be
+ equal as well as objectPoints[i].size(), imagePoints1[i].size(), and imagePoints2[i].size() need to
+ be equal for each i.
+
imagePoints1 - Vector of vectors of the projections of the calibration pattern points,
+ observed by the first camera. The same structure as in REF: calibrateCamera.
+
imagePoints2 - Vector of vectors of the projections of the calibration pattern points,
+ observed by the second camera. The same structure as in REF: calibrateCamera.
+
cameraMatrix1 - Input/output camera intrinsic matrix for the first camera, the same as in
+ REF: calibrateCamera. Furthermore, for the stereo case, additional flags may be used, see below.
+
distCoeffs1 - Input/output vector of distortion coefficients, the same as in
+ REF: calibrateCamera.
+
cameraMatrix2 - Input/output second camera intrinsic matrix for the second camera. See description for
+ cameraMatrix1.
+
distCoeffs2 - Input/output lens distortion coefficients for the second camera. See
+ description for distCoeffs1.
+
imageSize - Size of the image used only to initialize the camera intrinsic matrices.
+
R - Output rotation matrix. Together with the translation vector T, this matrix brings
+ points given in the first camera's coordinate system to points in the second camera's
+ coordinate system. In more technical terms, the tuple of R and T performs a change of basis
+ from the first camera's coordinate system to the second camera's coordinate system. Due to its
+ duality, this tuple is equivalent to the position of the first camera with respect to the
+ second camera coordinate system.
+
T - Output translation vector, see description above.
+
E - Output essential matrix.
+
F - Output fundamental matrix.
+
rvecs - Output vector of rotation vectors ( REF: Rodrigues ) estimated for each pattern view in the
+ coordinate system of the first camera of the stereo pair (e.g. std::vector<cv::Mat>). More in detail, each
+ i-th rotation vector together with the corresponding i-th translation vector (see the next output parameter
+ description) brings the calibration pattern from the object coordinate space (in which object points are
+ specified) to the camera coordinate space of the first camera of the stereo pair. In more technical terms,
+ the tuple of the i-th rotation and translation vector performs a change of basis from object coordinate space
+ to camera coordinate space of the first camera of the stereo pair.
+
tvecs - Output vector of translation vectors estimated for each pattern view, see parameter description
+ of previous output parameter ( rvecs ).
+
perViewErrors - Output vector of the RMS re-projection error estimated for each pattern view.
+
flags - Different flags that may be zero or a combination of the following values:
+
+
+ REF: CALIB_FIX_INTRINSIC Fix cameraMatrix? and distCoeffs? so that only R, T, E, and F
+ matrices are estimated.
+
+
+ REF: CALIB_USE_INTRINSIC_GUESS Optimize some or all of the intrinsic parameters
+ according to the specified flags. Initial values are provided by the user.
+
+
+ REF: CALIB_USE_EXTRINSIC_GUESS R and T contain valid initial values that are optimized further.
+ Otherwise R and T are initialized to the median value of the pattern views (each dimension separately).
+
+
+ REF: CALIB_FIX_PRINCIPAL_POINT Fix the principal points during the optimization.
+
+
+ REF: CALIB_FIX_FOCAL_LENGTH Fix \(f^{(j)}_x\) and \(f^{(j)}_y\) .
+
+
+ REF: CALIB_FIX_ASPECT_RATIO Optimize \(f^{(j)}_y\) . Fix the ratio \(f^{(j)}_x/f^{(j)}_y\)
+ .
+
+
+ REF: CALIB_SAME_FOCAL_LENGTH Enforce \(f^{(0)}_x=f^{(1)}_x\) and \(f^{(0)}_y=f^{(1)}_y\) .
+
+
+ REF: CALIB_ZERO_TANGENT_DIST Set tangential distortion coefficients for each camera to
+ zeros and fix there.
+
+
+ REF: CALIB_FIX_K1,..., REF: CALIB_FIX_K6 Do not change the corresponding radial
+ distortion coefficient 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 Enable coefficients k4, k5, and k6. To provide the backward
+ compatibility, this extra flag should be explicitly specified to make the calibration
+ function use the rational model and return 8 coefficients. If the flag is not set, the
+ function computes and returns only 5 distortion coefficients.
+
+
+ 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. 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. 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.
+
+
+
criteria - Termination criteria for the iterative optimization algorithm.
+
+ The function estimates the transformation between two cameras making a stereo pair. If one computes
+ the poses of an object relative to the first camera and to the second camera,
+ ( \(R_1\),\(T_1\) ) and (\(R_2\),\(T_2\)), respectively, for a stereo camera where the
+ relative position and orientation between the two cameras are fixed, then those poses definitely
+ relate to each other. This means, if the relative position and orientation (\(R\),\(T\)) of the
+ two cameras is known, it is possible to compute (\(R_2\),\(T_2\)) when (\(R_1\),\(T_1\)) is
+ given. This is what the described function does. It computes (\(R\),\(T\)) such that:
+
+ \(R_2=R R_1\)
+ \(T_2=R T_1 + T.\)
+
+ Therefore, one can compute the coordinate representation of a 3D point for the second camera's
+ coordinate system when given the point's coordinate representation in the first camera's coordinate
+ system:
+
+ \(\begin{bmatrix}
+ X_2 \\
+ Y_2 \\
+ Z_2 \\
+ 1
+ \end{bmatrix} = \begin{bmatrix}
+ R & T \\
+ 0 & 1
+ \end{bmatrix} \begin{bmatrix}
+ X_1 \\
+ Y_1 \\
+ Z_1 \\
+ 1
+ \end{bmatrix}.\)
+
+
+ Optionally, it computes the essential matrix E:
+
+ \(E= \vecthreethree{0}{-T_2}{T_1}{T_2}{0}{-T_0}{-T_1}{T_0}{0} R\)
+
+ where \(T_i\) are components of the translation vector \(T\) : \(T=[T_0, T_1, T_2]^T\) .
+ And the function can also compute the fundamental matrix F:
+
+ \(F = cameraMatrix2^{-T}\cdot E \cdot cameraMatrix1^{-1}\)
+
+ Besides the stereo-related information, the function can also perform a full calibration of each of
+ the two cameras. However, due to the high dimensionality of the parameter space and noise in the
+ input data, the function can diverge from the correct solution. If the intrinsic parameters can be
+ estimated with high accuracy for each of the cameras individually (for example, using
+ #calibrateCamera ), you are recommended to do so and then pass REF: CALIB_FIX_INTRINSIC flag to the
+ function along with the computed intrinsic parameters. Otherwise, if all the parameters are
+ estimated at once, it makes sense to restrict some parameters, for example, pass
+ REF: CALIB_SAME_FOCAL_LENGTH and REF: CALIB_ZERO_TANGENT_DIST flags, which is usually a
+ reasonable assumption.
+
+ Similarly to #calibrateCamera, the function minimizes the total re-projection error for all the
+ points in all the available views from both cameras. The function returns the final value of the
+ re-projection error.
public static void stereoRectify(Mat cameraMatrix1,
+ Mat distCoeffs1,
+ Mat cameraMatrix2,
+ Mat distCoeffs2,
+ Size imageSize,
+ Mat R,
+ Mat T,
+ Mat R1,
+ Mat R2,
+ Mat P1,
+ Mat P2,
+ Mat Q)
+
Computes rectification transforms for each head of a calibrated stereo camera.
+
+
Parameters:
+
cameraMatrix1 - First camera intrinsic matrix.
+
distCoeffs1 - First camera distortion parameters.
+
cameraMatrix2 - Second camera intrinsic matrix.
+
distCoeffs2 - Second camera distortion parameters.
+
imageSize - Size of the image used for stereo calibration.
+
R - Rotation matrix from the coordinate system of the first camera to the second camera,
+ see REF: stereoCalibrate.
+
T - Translation vector from the coordinate system of the first camera to the second camera,
+ see REF: stereoCalibrate.
+
R1 - Output 3x3 rectification transform (rotation matrix) for the first camera. This matrix
+ brings points given in the unrectified first camera's coordinate system to points in the rectified
+ first camera's coordinate system. In more technical terms, it performs a change of basis from the
+ unrectified first camera's coordinate system to the rectified first camera's coordinate system.
+
R2 - Output 3x3 rectification transform (rotation matrix) for the second camera. This matrix
+ brings points given in the unrectified second camera's coordinate system to points in the rectified
+ second camera's coordinate system. In more technical terms, it performs a change of basis from the
+ unrectified second camera's coordinate system to the rectified second camera's coordinate system.
+
P1 - Output 3x4 projection matrix in the new (rectified) coordinate systems for the first
+ camera, i.e. it projects points given in the rectified first camera coordinate system into the
+ rectified first camera's image.
+
P2 - Output 3x4 projection matrix in the new (rectified) coordinate systems for the second
+ camera, i.e. it projects points given in the rectified first camera coordinate system into the
+ rectified second camera's image.
+
Q - Output \(4 \times 4\) disparity-to-depth mapping matrix (see REF: reprojectImageTo3D).
+ the function makes the principal points of each camera have the same pixel coordinates in the
+ rectified views. And if the flag is not set, the function may still shift the images in the
+ horizontal or vertical direction (depending on the orientation of epipolar lines) to maximize the
+ useful image area.
+ scaling. Otherwise, the parameter should be between 0 and 1. alpha=0 means that the rectified
+ images are zoomed and shifted so that only valid pixels are visible (no black areas after
+ rectification). alpha=1 means that the rectified image is decimated and shifted so that all the
+ pixels from the original images from the cameras are retained in the rectified images (no source
+ image pixels are lost). Any intermediate value yields an intermediate result between
+ those two extreme cases.
+ #initUndistortRectifyMap (see the stereo_calib.cpp sample in OpenCV samples directory). When (0,0)
+ is passed (default), it is set to the original imageSize . Setting it to a larger value can help you
+ preserve details in the original image, especially when there is a big radial distortion.
+ are valid. If alpha=0 , the ROIs cover the whole images. Otherwise, they are likely to be smaller
+ (see the picture below).
+ are valid. If alpha=0 , the ROIs cover the whole images. Otherwise, they are likely to be smaller
+ (see the picture below).
+
+ The function computes the rotation matrices for each camera that (virtually) make both camera image
+ planes the same plane. Consequently, this makes all the epipolar lines parallel and thus simplifies
+ the dense stereo correspondence problem. The function takes the matrices computed by #stereoCalibrate
+ as input. As output, it provides two rotation matrices and also two projection matrices in the new
+ coordinates. The function distinguishes the following two cases:
+
+
+
+ Horizontal stereo: the first and the second camera views are shifted relative to each other
+ mainly along the x-axis (with possible small vertical shift). In the rectified images, the
+ corresponding epipolar lines in the left and right cameras are horizontal and have the same
+ y-coordinate. P1 and P2 look like:
+
+
+
+ \(\texttt{P1} = \begin{bmatrix}
+ f & 0 & cx_1 & 0 \\
+ 0 & f & cy & 0 \\
+ 0 & 0 & 1 & 0
+ \end{bmatrix}\)
+
+ \(\texttt{P2} = \begin{bmatrix}
+ f & 0 & cx_2 & T_x \cdot f \\
+ 0 & f & cy & 0 \\
+ 0 & 0 & 1 & 0
+ \end{bmatrix} ,\)
+
+ \(\texttt{Q} = \begin{bmatrix}
+ 1 & 0 & 0 & -cx_1 \\
+ 0 & 1 & 0 & -cy \\
+ 0 & 0 & 0 & f \\
+ 0 & 0 & -\frac{1}{T_x} & \frac{cx_1 - cx_2}{T_x}
+ \end{bmatrix} \)
+
+ where \(T_x\) is a horizontal shift between the cameras and \(cx_1=cx_2\) if
+ REF: CALIB_ZERO_DISPARITY is set.
+
+
+
+ Vertical stereo: the first and the second camera views are shifted relative to each other
+ mainly in the vertical direction (and probably a bit in the horizontal direction too). The epipolar
+ lines in the rectified images are vertical and have the same x-coordinate. P1 and P2 look like:
+
+
+
+ \(\texttt{P1} = \begin{bmatrix}
+ f & 0 & cx & 0 \\
+ 0 & f & cy_1 & 0 \\
+ 0 & 0 & 1 & 0
+ \end{bmatrix}\)
+
+ \(\texttt{P2} = \begin{bmatrix}
+ f & 0 & cx & 0 \\
+ 0 & f & cy_2 & T_y \cdot f \\
+ 0 & 0 & 1 & 0
+ \end{bmatrix},\)
+
+ \(\texttt{Q} = \begin{bmatrix}
+ 1 & 0 & 0 & -cx \\
+ 0 & 1 & 0 & -cy_1 \\
+ 0 & 0 & 0 & f \\
+ 0 & 0 & -\frac{1}{T_y} & \frac{cy_1 - cy_2}{T_y}
+ \end{bmatrix} \)
+
+ where \(T_y\) is a vertical shift between the cameras and \(cy_1=cy_2\) if
+ REF: CALIB_ZERO_DISPARITY is set.
+
+ As you can see, the first three columns of P1 and P2 will effectively be the new "rectified" camera
+ matrices. The matrices, together with R1 and R2 , can then be passed to #initUndistortRectifyMap to
+ initialize the rectification map for each camera.
+
+ See below the screenshot from the stereo_calib.cpp sample. Some red horizontal lines pass through
+ the corresponding image regions. This means that the images are well rectified, which is what most
+ stereo correspondence algorithms rely on. The green rectangles are roi1 and roi2 . You see that
+ their interiors are all valid pixels.
+
+ 
public static void stereoRectify(Mat cameraMatrix1,
+ Mat distCoeffs1,
+ Mat cameraMatrix2,
+ Mat distCoeffs2,
+ Size imageSize,
+ Mat R,
+ Mat T,
+ Mat R1,
+ Mat R2,
+ Mat P1,
+ Mat P2,
+ Mat Q,
+ int flags)
+
Computes rectification transforms for each head of a calibrated stereo camera.
+
+
Parameters:
+
cameraMatrix1 - First camera intrinsic matrix.
+
distCoeffs1 - First camera distortion parameters.
+
cameraMatrix2 - Second camera intrinsic matrix.
+
distCoeffs2 - Second camera distortion parameters.
+
imageSize - Size of the image used for stereo calibration.
+
R - Rotation matrix from the coordinate system of the first camera to the second camera,
+ see REF: stereoCalibrate.
+
T - Translation vector from the coordinate system of the first camera to the second camera,
+ see REF: stereoCalibrate.
+
R1 - Output 3x3 rectification transform (rotation matrix) for the first camera. This matrix
+ brings points given in the unrectified first camera's coordinate system to points in the rectified
+ first camera's coordinate system. In more technical terms, it performs a change of basis from the
+ unrectified first camera's coordinate system to the rectified first camera's coordinate system.
+
R2 - Output 3x3 rectification transform (rotation matrix) for the second camera. This matrix
+ brings points given in the unrectified second camera's coordinate system to points in the rectified
+ second camera's coordinate system. In more technical terms, it performs a change of basis from the
+ unrectified second camera's coordinate system to the rectified second camera's coordinate system.
+
P1 - Output 3x4 projection matrix in the new (rectified) coordinate systems for the first
+ camera, i.e. it projects points given in the rectified first camera coordinate system into the
+ rectified first camera's image.
+
P2 - Output 3x4 projection matrix in the new (rectified) coordinate systems for the second
+ camera, i.e. it projects points given in the rectified first camera coordinate system into the
+ rectified second camera's image.
flags - Operation flags that may be zero or REF: CALIB_ZERO_DISPARITY . If the flag is set,
+ the function makes the principal points of each camera have the same pixel coordinates in the
+ rectified views. And if the flag is not set, the function may still shift the images in the
+ horizontal or vertical direction (depending on the orientation of epipolar lines) to maximize the
+ useful image area.
+ scaling. Otherwise, the parameter should be between 0 and 1. alpha=0 means that the rectified
+ images are zoomed and shifted so that only valid pixels are visible (no black areas after
+ rectification). alpha=1 means that the rectified image is decimated and shifted so that all the
+ pixels from the original images from the cameras are retained in the rectified images (no source
+ image pixels are lost). Any intermediate value yields an intermediate result between
+ those two extreme cases.
+ #initUndistortRectifyMap (see the stereo_calib.cpp sample in OpenCV samples directory). When (0,0)
+ is passed (default), it is set to the original imageSize . Setting it to a larger value can help you
+ preserve details in the original image, especially when there is a big radial distortion.
+ are valid. If alpha=0 , the ROIs cover the whole images. Otherwise, they are likely to be smaller
+ (see the picture below).
+ are valid. If alpha=0 , the ROIs cover the whole images. Otherwise, they are likely to be smaller
+ (see the picture below).
+
+ The function computes the rotation matrices for each camera that (virtually) make both camera image
+ planes the same plane. Consequently, this makes all the epipolar lines parallel and thus simplifies
+ the dense stereo correspondence problem. The function takes the matrices computed by #stereoCalibrate
+ as input. As output, it provides two rotation matrices and also two projection matrices in the new
+ coordinates. The function distinguishes the following two cases:
+
+
+
+ Horizontal stereo: the first and the second camera views are shifted relative to each other
+ mainly along the x-axis (with possible small vertical shift). In the rectified images, the
+ corresponding epipolar lines in the left and right cameras are horizontal and have the same
+ y-coordinate. P1 and P2 look like:
+
+
+
+ \(\texttt{P1} = \begin{bmatrix}
+ f & 0 & cx_1 & 0 \\
+ 0 & f & cy & 0 \\
+ 0 & 0 & 1 & 0
+ \end{bmatrix}\)
+
+ \(\texttt{P2} = \begin{bmatrix}
+ f & 0 & cx_2 & T_x \cdot f \\
+ 0 & f & cy & 0 \\
+ 0 & 0 & 1 & 0
+ \end{bmatrix} ,\)
+
+ \(\texttt{Q} = \begin{bmatrix}
+ 1 & 0 & 0 & -cx_1 \\
+ 0 & 1 & 0 & -cy \\
+ 0 & 0 & 0 & f \\
+ 0 & 0 & -\frac{1}{T_x} & \frac{cx_1 - cx_2}{T_x}
+ \end{bmatrix} \)
+
+ where \(T_x\) is a horizontal shift between the cameras and \(cx_1=cx_2\) if
+ REF: CALIB_ZERO_DISPARITY is set.
+
+
+
+ Vertical stereo: the first and the second camera views are shifted relative to each other
+ mainly in the vertical direction (and probably a bit in the horizontal direction too). The epipolar
+ lines in the rectified images are vertical and have the same x-coordinate. P1 and P2 look like:
+
+
+
+ \(\texttt{P1} = \begin{bmatrix}
+ f & 0 & cx & 0 \\
+ 0 & f & cy_1 & 0 \\
+ 0 & 0 & 1 & 0
+ \end{bmatrix}\)
+
+ \(\texttt{P2} = \begin{bmatrix}
+ f & 0 & cx & 0 \\
+ 0 & f & cy_2 & T_y \cdot f \\
+ 0 & 0 & 1 & 0
+ \end{bmatrix},\)
+
+ \(\texttt{Q} = \begin{bmatrix}
+ 1 & 0 & 0 & -cx \\
+ 0 & 1 & 0 & -cy_1 \\
+ 0 & 0 & 0 & f \\
+ 0 & 0 & -\frac{1}{T_y} & \frac{cy_1 - cy_2}{T_y}
+ \end{bmatrix} \)
+
+ where \(T_y\) is a vertical shift between the cameras and \(cy_1=cy_2\) if
+ REF: CALIB_ZERO_DISPARITY is set.
+
+ As you can see, the first three columns of P1 and P2 will effectively be the new "rectified" camera
+ matrices. The matrices, together with R1 and R2 , can then be passed to #initUndistortRectifyMap to
+ initialize the rectification map for each camera.
+
+ See below the screenshot from the stereo_calib.cpp sample. Some red horizontal lines pass through
+ the corresponding image regions. This means that the images are well rectified, which is what most
+ stereo correspondence algorithms rely on. The green rectangles are roi1 and roi2 . You see that
+ their interiors are all valid pixels.
+
+ 
public static void stereoRectify(Mat cameraMatrix1,
+ Mat distCoeffs1,
+ Mat cameraMatrix2,
+ Mat distCoeffs2,
+ Size imageSize,
+ Mat R,
+ Mat T,
+ Mat R1,
+ Mat R2,
+ Mat P1,
+ Mat P2,
+ Mat Q,
+ int flags,
+ double alpha)
+
Computes rectification transforms for each head of a calibrated stereo camera.
+
+
Parameters:
+
cameraMatrix1 - First camera intrinsic matrix.
+
distCoeffs1 - First camera distortion parameters.
+
cameraMatrix2 - Second camera intrinsic matrix.
+
distCoeffs2 - Second camera distortion parameters.
+
imageSize - Size of the image used for stereo calibration.
+
R - Rotation matrix from the coordinate system of the first camera to the second camera,
+ see REF: stereoCalibrate.
+
T - Translation vector from the coordinate system of the first camera to the second camera,
+ see REF: stereoCalibrate.
+
R1 - Output 3x3 rectification transform (rotation matrix) for the first camera. This matrix
+ brings points given in the unrectified first camera's coordinate system to points in the rectified
+ first camera's coordinate system. In more technical terms, it performs a change of basis from the
+ unrectified first camera's coordinate system to the rectified first camera's coordinate system.
+
R2 - Output 3x3 rectification transform (rotation matrix) for the second camera. This matrix
+ brings points given in the unrectified second camera's coordinate system to points in the rectified
+ second camera's coordinate system. In more technical terms, it performs a change of basis from the
+ unrectified second camera's coordinate system to the rectified second camera's coordinate system.
+
P1 - Output 3x4 projection matrix in the new (rectified) coordinate systems for the first
+ camera, i.e. it projects points given in the rectified first camera coordinate system into the
+ rectified first camera's image.
+
P2 - Output 3x4 projection matrix in the new (rectified) coordinate systems for the second
+ camera, i.e. it projects points given in the rectified first camera coordinate system into the
+ rectified second camera's image.
flags - Operation flags that may be zero or REF: CALIB_ZERO_DISPARITY . If the flag is set,
+ the function makes the principal points of each camera have the same pixel coordinates in the
+ rectified views. And if the flag is not set, the function may still shift the images in the
+ horizontal or vertical direction (depending on the orientation of epipolar lines) to maximize the
+ useful image area.
+
alpha - Free scaling parameter. If it is -1 or absent, the function performs the default
+ scaling. Otherwise, the parameter should be between 0 and 1. alpha=0 means that the rectified
+ images are zoomed and shifted so that only valid pixels are visible (no black areas after
+ rectification). alpha=1 means that the rectified image is decimated and shifted so that all the
+ pixels from the original images from the cameras are retained in the rectified images (no source
+ image pixels are lost). Any intermediate value yields an intermediate result between
+ those two extreme cases.
+ #initUndistortRectifyMap (see the stereo_calib.cpp sample in OpenCV samples directory). When (0,0)
+ is passed (default), it is set to the original imageSize . Setting it to a larger value can help you
+ preserve details in the original image, especially when there is a big radial distortion.
+ are valid. If alpha=0 , the ROIs cover the whole images. Otherwise, they are likely to be smaller
+ (see the picture below).
+ are valid. If alpha=0 , the ROIs cover the whole images. Otherwise, they are likely to be smaller
+ (see the picture below).
+
+ The function computes the rotation matrices for each camera that (virtually) make both camera image
+ planes the same plane. Consequently, this makes all the epipolar lines parallel and thus simplifies
+ the dense stereo correspondence problem. The function takes the matrices computed by #stereoCalibrate
+ as input. As output, it provides two rotation matrices and also two projection matrices in the new
+ coordinates. The function distinguishes the following two cases:
+
+
+
+ Horizontal stereo: the first and the second camera views are shifted relative to each other
+ mainly along the x-axis (with possible small vertical shift). In the rectified images, the
+ corresponding epipolar lines in the left and right cameras are horizontal and have the same
+ y-coordinate. P1 and P2 look like:
+
+
+
+ \(\texttt{P1} = \begin{bmatrix}
+ f & 0 & cx_1 & 0 \\
+ 0 & f & cy & 0 \\
+ 0 & 0 & 1 & 0
+ \end{bmatrix}\)
+
+ \(\texttt{P2} = \begin{bmatrix}
+ f & 0 & cx_2 & T_x \cdot f \\
+ 0 & f & cy & 0 \\
+ 0 & 0 & 1 & 0
+ \end{bmatrix} ,\)
+
+ \(\texttt{Q} = \begin{bmatrix}
+ 1 & 0 & 0 & -cx_1 \\
+ 0 & 1 & 0 & -cy \\
+ 0 & 0 & 0 & f \\
+ 0 & 0 & -\frac{1}{T_x} & \frac{cx_1 - cx_2}{T_x}
+ \end{bmatrix} \)
+
+ where \(T_x\) is a horizontal shift between the cameras and \(cx_1=cx_2\) if
+ REF: CALIB_ZERO_DISPARITY is set.
+
+
+
+ Vertical stereo: the first and the second camera views are shifted relative to each other
+ mainly in the vertical direction (and probably a bit in the horizontal direction too). The epipolar
+ lines in the rectified images are vertical and have the same x-coordinate. P1 and P2 look like:
+
+
+
+ \(\texttt{P1} = \begin{bmatrix}
+ f & 0 & cx & 0 \\
+ 0 & f & cy_1 & 0 \\
+ 0 & 0 & 1 & 0
+ \end{bmatrix}\)
+
+ \(\texttt{P2} = \begin{bmatrix}
+ f & 0 & cx & 0 \\
+ 0 & f & cy_2 & T_y \cdot f \\
+ 0 & 0 & 1 & 0
+ \end{bmatrix},\)
+
+ \(\texttt{Q} = \begin{bmatrix}
+ 1 & 0 & 0 & -cx \\
+ 0 & 1 & 0 & -cy_1 \\
+ 0 & 0 & 0 & f \\
+ 0 & 0 & -\frac{1}{T_y} & \frac{cy_1 - cy_2}{T_y}
+ \end{bmatrix} \)
+
+ where \(T_y\) is a vertical shift between the cameras and \(cy_1=cy_2\) if
+ REF: CALIB_ZERO_DISPARITY is set.
+
+ As you can see, the first three columns of P1 and P2 will effectively be the new "rectified" camera
+ matrices. The matrices, together with R1 and R2 , can then be passed to #initUndistortRectifyMap to
+ initialize the rectification map for each camera.
+
+ See below the screenshot from the stereo_calib.cpp sample. Some red horizontal lines pass through
+ the corresponding image regions. This means that the images are well rectified, which is what most
+ stereo correspondence algorithms rely on. The green rectangles are roi1 and roi2 . You see that
+ their interiors are all valid pixels.
+
+ 
public static void stereoRectify(Mat cameraMatrix1,
+ Mat distCoeffs1,
+ Mat cameraMatrix2,
+ Mat distCoeffs2,
+ Size imageSize,
+ Mat R,
+ Mat T,
+ Mat R1,
+ Mat R2,
+ Mat P1,
+ Mat P2,
+ Mat Q,
+ int flags,
+ double alpha,
+ Size newImageSize)
+
Computes rectification transforms for each head of a calibrated stereo camera.
+
+
Parameters:
+
cameraMatrix1 - First camera intrinsic matrix.
+
distCoeffs1 - First camera distortion parameters.
+
cameraMatrix2 - Second camera intrinsic matrix.
+
distCoeffs2 - Second camera distortion parameters.
+
imageSize - Size of the image used for stereo calibration.
+
R - Rotation matrix from the coordinate system of the first camera to the second camera,
+ see REF: stereoCalibrate.
+
T - Translation vector from the coordinate system of the first camera to the second camera,
+ see REF: stereoCalibrate.
+
R1 - Output 3x3 rectification transform (rotation matrix) for the first camera. This matrix
+ brings points given in the unrectified first camera's coordinate system to points in the rectified
+ first camera's coordinate system. In more technical terms, it performs a change of basis from the
+ unrectified first camera's coordinate system to the rectified first camera's coordinate system.
+
R2 - Output 3x3 rectification transform (rotation matrix) for the second camera. This matrix
+ brings points given in the unrectified second camera's coordinate system to points in the rectified
+ second camera's coordinate system. In more technical terms, it performs a change of basis from the
+ unrectified second camera's coordinate system to the rectified second camera's coordinate system.
+
P1 - Output 3x4 projection matrix in the new (rectified) coordinate systems for the first
+ camera, i.e. it projects points given in the rectified first camera coordinate system into the
+ rectified first camera's image.
+
P2 - Output 3x4 projection matrix in the new (rectified) coordinate systems for the second
+ camera, i.e. it projects points given in the rectified first camera coordinate system into the
+ rectified second camera's image.
flags - Operation flags that may be zero or REF: CALIB_ZERO_DISPARITY . If the flag is set,
+ the function makes the principal points of each camera have the same pixel coordinates in the
+ rectified views. And if the flag is not set, the function may still shift the images in the
+ horizontal or vertical direction (depending on the orientation of epipolar lines) to maximize the
+ useful image area.
+
alpha - Free scaling parameter. If it is -1 or absent, the function performs the default
+ scaling. Otherwise, the parameter should be between 0 and 1. alpha=0 means that the rectified
+ images are zoomed and shifted so that only valid pixels are visible (no black areas after
+ rectification). alpha=1 means that the rectified image is decimated and shifted so that all the
+ pixels from the original images from the cameras are retained in the rectified images (no source
+ image pixels are lost). Any intermediate value yields an intermediate result between
+ those two extreme cases.
+
newImageSize - New image resolution after rectification. The same size should be passed to
+ #initUndistortRectifyMap (see the stereo_calib.cpp sample in OpenCV samples directory). When (0,0)
+ is passed (default), it is set to the original imageSize . Setting it to a larger value can help you
+ preserve details in the original image, especially when there is a big radial distortion.
+ are valid. If alpha=0 , the ROIs cover the whole images. Otherwise, they are likely to be smaller
+ (see the picture below).
+ are valid. If alpha=0 , the ROIs cover the whole images. Otherwise, they are likely to be smaller
+ (see the picture below).
+
+ The function computes the rotation matrices for each camera that (virtually) make both camera image
+ planes the same plane. Consequently, this makes all the epipolar lines parallel and thus simplifies
+ the dense stereo correspondence problem. The function takes the matrices computed by #stereoCalibrate
+ as input. As output, it provides two rotation matrices and also two projection matrices in the new
+ coordinates. The function distinguishes the following two cases:
+
+
+
+ Horizontal stereo: the first and the second camera views are shifted relative to each other
+ mainly along the x-axis (with possible small vertical shift). In the rectified images, the
+ corresponding epipolar lines in the left and right cameras are horizontal and have the same
+ y-coordinate. P1 and P2 look like:
+
+
+
+ \(\texttt{P1} = \begin{bmatrix}
+ f & 0 & cx_1 & 0 \\
+ 0 & f & cy & 0 \\
+ 0 & 0 & 1 & 0
+ \end{bmatrix}\)
+
+ \(\texttt{P2} = \begin{bmatrix}
+ f & 0 & cx_2 & T_x \cdot f \\
+ 0 & f & cy & 0 \\
+ 0 & 0 & 1 & 0
+ \end{bmatrix} ,\)
+
+ \(\texttt{Q} = \begin{bmatrix}
+ 1 & 0 & 0 & -cx_1 \\
+ 0 & 1 & 0 & -cy \\
+ 0 & 0 & 0 & f \\
+ 0 & 0 & -\frac{1}{T_x} & \frac{cx_1 - cx_2}{T_x}
+ \end{bmatrix} \)
+
+ where \(T_x\) is a horizontal shift between the cameras and \(cx_1=cx_2\) if
+ REF: CALIB_ZERO_DISPARITY is set.
+
+
+
+ Vertical stereo: the first and the second camera views are shifted relative to each other
+ mainly in the vertical direction (and probably a bit in the horizontal direction too). The epipolar
+ lines in the rectified images are vertical and have the same x-coordinate. P1 and P2 look like:
+
+
+
+ \(\texttt{P1} = \begin{bmatrix}
+ f & 0 & cx & 0 \\
+ 0 & f & cy_1 & 0 \\
+ 0 & 0 & 1 & 0
+ \end{bmatrix}\)
+
+ \(\texttt{P2} = \begin{bmatrix}
+ f & 0 & cx & 0 \\
+ 0 & f & cy_2 & T_y \cdot f \\
+ 0 & 0 & 1 & 0
+ \end{bmatrix},\)
+
+ \(\texttt{Q} = \begin{bmatrix}
+ 1 & 0 & 0 & -cx \\
+ 0 & 1 & 0 & -cy_1 \\
+ 0 & 0 & 0 & f \\
+ 0 & 0 & -\frac{1}{T_y} & \frac{cy_1 - cy_2}{T_y}
+ \end{bmatrix} \)
+
+ where \(T_y\) is a vertical shift between the cameras and \(cy_1=cy_2\) if
+ REF: CALIB_ZERO_DISPARITY is set.
+
+ As you can see, the first three columns of P1 and P2 will effectively be the new "rectified" camera
+ matrices. The matrices, together with R1 and R2 , can then be passed to #initUndistortRectifyMap to
+ initialize the rectification map for each camera.
+
+ See below the screenshot from the stereo_calib.cpp sample. Some red horizontal lines pass through
+ the corresponding image regions. This means that the images are well rectified, which is what most
+ stereo correspondence algorithms rely on. The green rectangles are roi1 and roi2 . You see that
+ their interiors are all valid pixels.
+
+ 
public static void stereoRectify(Mat cameraMatrix1,
+ Mat distCoeffs1,
+ Mat cameraMatrix2,
+ Mat distCoeffs2,
+ Size imageSize,
+ Mat R,
+ Mat T,
+ Mat R1,
+ Mat R2,
+ Mat P1,
+ Mat P2,
+ Mat Q,
+ int flags,
+ double alpha,
+ Size newImageSize,
+ Rect validPixROI1)
+
Computes rectification transforms for each head of a calibrated stereo camera.
+
+
Parameters:
+
cameraMatrix1 - First camera intrinsic matrix.
+
distCoeffs1 - First camera distortion parameters.
+
cameraMatrix2 - Second camera intrinsic matrix.
+
distCoeffs2 - Second camera distortion parameters.
+
imageSize - Size of the image used for stereo calibration.
+
R - Rotation matrix from the coordinate system of the first camera to the second camera,
+ see REF: stereoCalibrate.
+
T - Translation vector from the coordinate system of the first camera to the second camera,
+ see REF: stereoCalibrate.
+
R1 - Output 3x3 rectification transform (rotation matrix) for the first camera. This matrix
+ brings points given in the unrectified first camera's coordinate system to points in the rectified
+ first camera's coordinate system. In more technical terms, it performs a change of basis from the
+ unrectified first camera's coordinate system to the rectified first camera's coordinate system.
+
R2 - Output 3x3 rectification transform (rotation matrix) for the second camera. This matrix
+ brings points given in the unrectified second camera's coordinate system to points in the rectified
+ second camera's coordinate system. In more technical terms, it performs a change of basis from the
+ unrectified second camera's coordinate system to the rectified second camera's coordinate system.
+
P1 - Output 3x4 projection matrix in the new (rectified) coordinate systems for the first
+ camera, i.e. it projects points given in the rectified first camera coordinate system into the
+ rectified first camera's image.
+
P2 - Output 3x4 projection matrix in the new (rectified) coordinate systems for the second
+ camera, i.e. it projects points given in the rectified first camera coordinate system into the
+ rectified second camera's image.
flags - Operation flags that may be zero or REF: CALIB_ZERO_DISPARITY . If the flag is set,
+ the function makes the principal points of each camera have the same pixel coordinates in the
+ rectified views. And if the flag is not set, the function may still shift the images in the
+ horizontal or vertical direction (depending on the orientation of epipolar lines) to maximize the
+ useful image area.
+
alpha - Free scaling parameter. If it is -1 or absent, the function performs the default
+ scaling. Otherwise, the parameter should be between 0 and 1. alpha=0 means that the rectified
+ images are zoomed and shifted so that only valid pixels are visible (no black areas after
+ rectification). alpha=1 means that the rectified image is decimated and shifted so that all the
+ pixels from the original images from the cameras are retained in the rectified images (no source
+ image pixels are lost). Any intermediate value yields an intermediate result between
+ those two extreme cases.
+
newImageSize - New image resolution after rectification. The same size should be passed to
+ #initUndistortRectifyMap (see the stereo_calib.cpp sample in OpenCV samples directory). When (0,0)
+ is passed (default), it is set to the original imageSize . Setting it to a larger value can help you
+ preserve details in the original image, especially when there is a big radial distortion.
+
validPixROI1 - Optional output rectangles inside the rectified images where all the pixels
+ are valid. If alpha=0 , the ROIs cover the whole images. Otherwise, they are likely to be smaller
+ (see the picture below).
+ are valid. If alpha=0 , the ROIs cover the whole images. Otherwise, they are likely to be smaller
+ (see the picture below).
+
+ The function computes the rotation matrices for each camera that (virtually) make both camera image
+ planes the same plane. Consequently, this makes all the epipolar lines parallel and thus simplifies
+ the dense stereo correspondence problem. The function takes the matrices computed by #stereoCalibrate
+ as input. As output, it provides two rotation matrices and also two projection matrices in the new
+ coordinates. The function distinguishes the following two cases:
+
+
+
+ Horizontal stereo: the first and the second camera views are shifted relative to each other
+ mainly along the x-axis (with possible small vertical shift). In the rectified images, the
+ corresponding epipolar lines in the left and right cameras are horizontal and have the same
+ y-coordinate. P1 and P2 look like:
+
+
+
+ \(\texttt{P1} = \begin{bmatrix}
+ f & 0 & cx_1 & 0 \\
+ 0 & f & cy & 0 \\
+ 0 & 0 & 1 & 0
+ \end{bmatrix}\)
+
+ \(\texttt{P2} = \begin{bmatrix}
+ f & 0 & cx_2 & T_x \cdot f \\
+ 0 & f & cy & 0 \\
+ 0 & 0 & 1 & 0
+ \end{bmatrix} ,\)
+
+ \(\texttt{Q} = \begin{bmatrix}
+ 1 & 0 & 0 & -cx_1 \\
+ 0 & 1 & 0 & -cy \\
+ 0 & 0 & 0 & f \\
+ 0 & 0 & -\frac{1}{T_x} & \frac{cx_1 - cx_2}{T_x}
+ \end{bmatrix} \)
+
+ where \(T_x\) is a horizontal shift between the cameras and \(cx_1=cx_2\) if
+ REF: CALIB_ZERO_DISPARITY is set.
+
+
+
+ Vertical stereo: the first and the second camera views are shifted relative to each other
+ mainly in the vertical direction (and probably a bit in the horizontal direction too). The epipolar
+ lines in the rectified images are vertical and have the same x-coordinate. P1 and P2 look like:
+
+
+
+ \(\texttt{P1} = \begin{bmatrix}
+ f & 0 & cx & 0 \\
+ 0 & f & cy_1 & 0 \\
+ 0 & 0 & 1 & 0
+ \end{bmatrix}\)
+
+ \(\texttt{P2} = \begin{bmatrix}
+ f & 0 & cx & 0 \\
+ 0 & f & cy_2 & T_y \cdot f \\
+ 0 & 0 & 1 & 0
+ \end{bmatrix},\)
+
+ \(\texttt{Q} = \begin{bmatrix}
+ 1 & 0 & 0 & -cx \\
+ 0 & 1 & 0 & -cy_1 \\
+ 0 & 0 & 0 & f \\
+ 0 & 0 & -\frac{1}{T_y} & \frac{cy_1 - cy_2}{T_y}
+ \end{bmatrix} \)
+
+ where \(T_y\) is a vertical shift between the cameras and \(cy_1=cy_2\) if
+ REF: CALIB_ZERO_DISPARITY is set.
+
+ As you can see, the first three columns of P1 and P2 will effectively be the new "rectified" camera
+ matrices. The matrices, together with R1 and R2 , can then be passed to #initUndistortRectifyMap to
+ initialize the rectification map for each camera.
+
+ See below the screenshot from the stereo_calib.cpp sample. Some red horizontal lines pass through
+ the corresponding image regions. This means that the images are well rectified, which is what most
+ stereo correspondence algorithms rely on. The green rectangles are roi1 and roi2 . You see that
+ their interiors are all valid pixels.
+
+ 
public static void stereoRectify(Mat cameraMatrix1,
+ Mat distCoeffs1,
+ Mat cameraMatrix2,
+ Mat distCoeffs2,
+ Size imageSize,
+ Mat R,
+ Mat T,
+ Mat R1,
+ Mat R2,
+ Mat P1,
+ Mat P2,
+ Mat Q,
+ int flags,
+ double alpha,
+ Size newImageSize,
+ Rect validPixROI1,
+ Rect validPixROI2)
+
Computes rectification transforms for each head of a calibrated stereo camera.
+
+
Parameters:
+
cameraMatrix1 - First camera intrinsic matrix.
+
distCoeffs1 - First camera distortion parameters.
+
cameraMatrix2 - Second camera intrinsic matrix.
+
distCoeffs2 - Second camera distortion parameters.
+
imageSize - Size of the image used for stereo calibration.
+
R - Rotation matrix from the coordinate system of the first camera to the second camera,
+ see REF: stereoCalibrate.
+
T - Translation vector from the coordinate system of the first camera to the second camera,
+ see REF: stereoCalibrate.
+
R1 - Output 3x3 rectification transform (rotation matrix) for the first camera. This matrix
+ brings points given in the unrectified first camera's coordinate system to points in the rectified
+ first camera's coordinate system. In more technical terms, it performs a change of basis from the
+ unrectified first camera's coordinate system to the rectified first camera's coordinate system.
+
R2 - Output 3x3 rectification transform (rotation matrix) for the second camera. This matrix
+ brings points given in the unrectified second camera's coordinate system to points in the rectified
+ second camera's coordinate system. In more technical terms, it performs a change of basis from the
+ unrectified second camera's coordinate system to the rectified second camera's coordinate system.
+
P1 - Output 3x4 projection matrix in the new (rectified) coordinate systems for the first
+ camera, i.e. it projects points given in the rectified first camera coordinate system into the
+ rectified first camera's image.
+
P2 - Output 3x4 projection matrix in the new (rectified) coordinate systems for the second
+ camera, i.e. it projects points given in the rectified first camera coordinate system into the
+ rectified second camera's image.
flags - Operation flags that may be zero or REF: CALIB_ZERO_DISPARITY . If the flag is set,
+ the function makes the principal points of each camera have the same pixel coordinates in the
+ rectified views. And if the flag is not set, the function may still shift the images in the
+ horizontal or vertical direction (depending on the orientation of epipolar lines) to maximize the
+ useful image area.
+
alpha - Free scaling parameter. If it is -1 or absent, the function performs the default
+ scaling. Otherwise, the parameter should be between 0 and 1. alpha=0 means that the rectified
+ images are zoomed and shifted so that only valid pixels are visible (no black areas after
+ rectification). alpha=1 means that the rectified image is decimated and shifted so that all the
+ pixels from the original images from the cameras are retained in the rectified images (no source
+ image pixels are lost). Any intermediate value yields an intermediate result between
+ those two extreme cases.
+
newImageSize - New image resolution after rectification. The same size should be passed to
+ #initUndistortRectifyMap (see the stereo_calib.cpp sample in OpenCV samples directory). When (0,0)
+ is passed (default), it is set to the original imageSize . Setting it to a larger value can help you
+ preserve details in the original image, especially when there is a big radial distortion.
+
validPixROI1 - Optional output rectangles inside the rectified images where all the pixels
+ are valid. If alpha=0 , the ROIs cover the whole images. Otherwise, they are likely to be smaller
+ (see the picture below).
+
validPixROI2 - Optional output rectangles inside the rectified images where all the pixels
+ are valid. If alpha=0 , the ROIs cover the whole images. Otherwise, they are likely to be smaller
+ (see the picture below).
+
+ The function computes the rotation matrices for each camera that (virtually) make both camera image
+ planes the same plane. Consequently, this makes all the epipolar lines parallel and thus simplifies
+ the dense stereo correspondence problem. The function takes the matrices computed by #stereoCalibrate
+ as input. As output, it provides two rotation matrices and also two projection matrices in the new
+ coordinates. The function distinguishes the following two cases:
+
+
+
+ Horizontal stereo: the first and the second camera views are shifted relative to each other
+ mainly along the x-axis (with possible small vertical shift). In the rectified images, the
+ corresponding epipolar lines in the left and right cameras are horizontal and have the same
+ y-coordinate. P1 and P2 look like:
+
+
+
+ \(\texttt{P1} = \begin{bmatrix}
+ f & 0 & cx_1 & 0 \\
+ 0 & f & cy & 0 \\
+ 0 & 0 & 1 & 0
+ \end{bmatrix}\)
+
+ \(\texttt{P2} = \begin{bmatrix}
+ f & 0 & cx_2 & T_x \cdot f \\
+ 0 & f & cy & 0 \\
+ 0 & 0 & 1 & 0
+ \end{bmatrix} ,\)
+
+ \(\texttt{Q} = \begin{bmatrix}
+ 1 & 0 & 0 & -cx_1 \\
+ 0 & 1 & 0 & -cy \\
+ 0 & 0 & 0 & f \\
+ 0 & 0 & -\frac{1}{T_x} & \frac{cx_1 - cx_2}{T_x}
+ \end{bmatrix} \)
+
+ where \(T_x\) is a horizontal shift between the cameras and \(cx_1=cx_2\) if
+ REF: CALIB_ZERO_DISPARITY is set.
+
+
+
+ Vertical stereo: the first and the second camera views are shifted relative to each other
+ mainly in the vertical direction (and probably a bit in the horizontal direction too). The epipolar
+ lines in the rectified images are vertical and have the same x-coordinate. P1 and P2 look like:
+
+
+
+ \(\texttt{P1} = \begin{bmatrix}
+ f & 0 & cx & 0 \\
+ 0 & f & cy_1 & 0 \\
+ 0 & 0 & 1 & 0
+ \end{bmatrix}\)
+
+ \(\texttt{P2} = \begin{bmatrix}
+ f & 0 & cx & 0 \\
+ 0 & f & cy_2 & T_y \cdot f \\
+ 0 & 0 & 1 & 0
+ \end{bmatrix},\)
+
+ \(\texttt{Q} = \begin{bmatrix}
+ 1 & 0 & 0 & -cx \\
+ 0 & 1 & 0 & -cy_1 \\
+ 0 & 0 & 0 & f \\
+ 0 & 0 & -\frac{1}{T_y} & \frac{cy_1 - cy_2}{T_y}
+ \end{bmatrix} \)
+
+ where \(T_y\) is a vertical shift between the cameras and \(cy_1=cy_2\) if
+ REF: CALIB_ZERO_DISPARITY is set.
+
+ As you can see, the first three columns of P1 and P2 will effectively be the new "rectified" camera
+ matrices. The matrices, together with R1 and R2 , can then be passed to #initUndistortRectifyMap to
+ initialize the rectification map for each camera.
+
+ See below the screenshot from the stereo_calib.cpp sample. Some red horizontal lines pass through
+ the corresponding image regions. This means that the images are well rectified, which is what most
+ stereo correspondence algorithms rely on. The green rectangles are roi1 and roi2 . You see that
+ their interiors are all valid pixels.
+
+ 
public static boolean stereoRectifyUncalibrated(Mat points1,
+ Mat points2,
+ Mat F,
+ Size imgSize,
+ Mat H1,
+ Mat H2)
+
Computes a rectification transform for an uncalibrated stereo camera.
+
+
Parameters:
+
points1 - Array of feature points in the first image.
+
points2 - The corresponding points in the second image. The same formats as in
+ #findFundamentalMat are supported.
+
F - Input fundamental matrix. It can be computed from the same set of point pairs using
+ #findFundamentalMat .
+
imgSize - Size of the image.
+
H1 - Output rectification homography matrix for the first image.
+
H2 - Output rectification homography matrix for the second image.
+ than zero, all the point pairs that do not comply with the epipolar geometry (that is, the points
+ for which \(|\texttt{points2[i]}^T \cdot \texttt{F} \cdot \texttt{points1[i]}|>\texttt{threshold}\) )
+ are rejected prior to computing the homographies. Otherwise, all the points are considered inliers.
+
+ The function computes the rectification transformations without knowing intrinsic parameters of the
+ cameras and their relative position in the space, which explains the suffix "uncalibrated". Another
+ related difference from #stereoRectify is that the function outputs not the rectification
+ transformations in the object (3D) space, but the planar perspective transformations encoded by the
+ homography matrices H1 and H2 . The function implements the algorithm CITE: Hartley99 .
+
+ Note:
+ While the algorithm does not need to know the intrinsic parameters of the cameras, it heavily
+ depends on the epipolar geometry. Therefore, if the camera lenses have a significant distortion,
+ it would be better to correct it before computing the fundamental matrix and calling this
+ function. For example, distortion coefficients can be estimated for each head of stereo camera
+ separately by using #calibrateCamera . Then, the images can be corrected using #undistort , or
+ just the point coordinates can be corrected with #undistortPoints .
public static boolean stereoRectifyUncalibrated(Mat points1,
+ Mat points2,
+ Mat F,
+ Size imgSize,
+ Mat H1,
+ Mat H2,
+ double threshold)
+
Computes a rectification transform for an uncalibrated stereo camera.
+
+
Parameters:
+
points1 - Array of feature points in the first image.
+
points2 - The corresponding points in the second image. The same formats as in
+ #findFundamentalMat are supported.
+
F - Input fundamental matrix. It can be computed from the same set of point pairs using
+ #findFundamentalMat .
+
imgSize - Size of the image.
+
H1 - Output rectification homography matrix for the first image.
+
H2 - Output rectification homography matrix for the second image.
+
threshold - Optional threshold used to filter out the outliers. If the parameter is greater
+ than zero, all the point pairs that do not comply with the epipolar geometry (that is, the points
+ for which \(|\texttt{points2[i]}^T \cdot \texttt{F} \cdot \texttt{points1[i]}|>\texttt{threshold}\) )
+ are rejected prior to computing the homographies. Otherwise, all the points are considered inliers.
+
+ The function computes the rectification transformations without knowing intrinsic parameters of the
+ cameras and their relative position in the space, which explains the suffix "uncalibrated". Another
+ related difference from #stereoRectify is that the function outputs not the rectification
+ transformations in the object (3D) space, but the planar perspective transformations encoded by the
+ homography matrices H1 and H2 . The function implements the algorithm CITE: Hartley99 .
+
+ Note:
+ While the algorithm does not need to know the intrinsic parameters of the cameras, it heavily
+ depends on the epipolar geometry. Therefore, if the camera lenses have a significant distortion,
+ it would be better to correct it before computing the fundamental matrix and calling this
+ function. For example, distortion coefficients can be estimated for each head of stereo camera
+ separately by using #calibrateCamera . Then, the images can be corrected using #undistort , or
+ just the point coordinates can be corrected with #undistortPoints .
public static void triangulatePoints(Mat projMatr1,
+ Mat projMatr2,
+ Mat projPoints1,
+ Mat projPoints2,
+ Mat points4D)
+
This function reconstructs 3-dimensional points (in homogeneous coordinates) by using
+ their observations with a stereo camera.
+
+
Parameters:
+
projMatr1 - 3x4 projection matrix of the first camera, i.e. this matrix projects 3D points
+ given in the world's coordinate system into the first image.
+
projMatr2 - 3x4 projection matrix of the second camera, i.e. this matrix projects 3D points
+ given in the world's coordinate system into the second image.
+
projPoints1 - 2xN array of feature points in the first image. In the case of the c++ version,
+ it can be also a vector of feature points or two-channel matrix of size 1xN or Nx1.
+
projPoints2 - 2xN array of corresponding points in the second image. In the case of the c++
+ version, it can be also a vector of feature points or two-channel matrix of size 1xN or Nx1.
+
points4D - 4xN array of reconstructed points in homogeneous coordinates. These points are
+ returned in the world's coordinate system.
+
+ Note:
+ Keep in mind that all input data should be of float type in order for this function to work.
+
+ Note:
+ If the projection matrices from REF: stereoRectify are used, then the returned points are
+ represented in the first camera's rectified coordinate system.
+
+ SEE:
+ reprojectImageTo3D
public static void undistort(Mat src,
+ Mat dst,
+ Mat cameraMatrix,
+ Mat distCoeffs)
+
Transforms an image to compensate for lens distortion.
+
+ The function transforms an image to compensate radial and tangential lens distortion.
+
+ The function is simply a combination of #initUndistortRectifyMap (with unity R ) and #remap
+ (with bilinear interpolation). See the former function for details of the transformation being
+ performed.
+
+ Those pixels in the destination image, for which there is no correspondent pixels in the source
+ image, are filled with zeros (black color).
+
+ A particular subset of the source image that will be visible in the corrected image can be regulated
+ by newCameraMatrix. You can use #getOptimalNewCameraMatrix to compute the appropriate
+ newCameraMatrix depending on your requirements.
+
+ The camera matrix and the distortion parameters can be determined using #calibrateCamera. If
+ the resolution of images is different from the resolution used at the calibration stage, \(f_x,
+ f_y, c_x\) and \(c_y\) need to be scaled accordingly, while the distortion coefficients remain
+ the same.
+
+
Parameters:
+
src - Input (distorted) image.
+
dst - Output (corrected) image that has the same size and type as src .
+
cameraMatrix - Input camera matrix \(A = \vecthreethree{f_x}{0}{c_x}{0}{f_y}{c_y}{0}{0}{1}\) .
+
distCoeffs - Input vector of distortion coefficients
+ \((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]]]])\)
+ of 4, 5, 8, 12 or 14 elements. If the vector is NULL/empty, the zero distortion coefficients are assumed.
+ cameraMatrix but you may additionally scale and shift the result by using a different matrix.
public static void undistort(Mat src,
+ Mat dst,
+ Mat cameraMatrix,
+ Mat distCoeffs,
+ Mat newCameraMatrix)
+
Transforms an image to compensate for lens distortion.
+
+ The function transforms an image to compensate radial and tangential lens distortion.
+
+ The function is simply a combination of #initUndistortRectifyMap (with unity R ) and #remap
+ (with bilinear interpolation). See the former function for details of the transformation being
+ performed.
+
+ Those pixels in the destination image, for which there is no correspondent pixels in the source
+ image, are filled with zeros (black color).
+
+ A particular subset of the source image that will be visible in the corrected image can be regulated
+ by newCameraMatrix. You can use #getOptimalNewCameraMatrix to compute the appropriate
+ newCameraMatrix depending on your requirements.
+
+ The camera matrix and the distortion parameters can be determined using #calibrateCamera. If
+ the resolution of images is different from the resolution used at the calibration stage, \(f_x,
+ f_y, c_x\) and \(c_y\) need to be scaled accordingly, while the distortion coefficients remain
+ the same.
+
+
Parameters:
+
src - Input (distorted) image.
+
dst - Output (corrected) image that has the same size and type as src .
+
cameraMatrix - Input camera matrix \(A = \vecthreethree{f_x}{0}{c_x}{0}{f_y}{c_y}{0}{0}{1}\) .
+
distCoeffs - Input vector of distortion coefficients
+ \((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]]]])\)
+ of 4, 5, 8, 12 or 14 elements. If the vector is NULL/empty, the zero distortion coefficients are assumed.
+
newCameraMatrix - Camera matrix of the distorted image. By default, it is the same as
+ cameraMatrix but you may additionally scale and shift the result by using a different matrix.
Computes the ideal point coordinates from the observed point coordinates.
+
+ The function is similar to #undistort and #initUndistortRectifyMap but it operates on a
+ sparse set of points instead of a raster image. Also the function performs a reverse transformation
+ to #projectPoints. In case of a 3D object, it does not reconstruct its 3D coordinates, but for a
+ planar object, it does, up to a translation vector, if the proper R is specified.
+
+ For each observed point coordinate \((u, v)\) the function computes:
+ \(
+ \begin{array}{l}
+ x^{"} \leftarrow (u - c_x)/f_x \\
+ y^{"} \leftarrow (v - c_y)/f_y \\
+ (x',y') = undistort(x^{"},y^{"}, \texttt{distCoeffs}) \\
+ {[X\,Y\,W]} ^T \leftarrow R*[x' \, y' \, 1]^T \\
+ x \leftarrow X/W \\
+ y \leftarrow Y/W \\
+ \text{only performed if P is specified:} \\
+ u' \leftarrow x {f'}_x + {c'}_x \\
+ v' \leftarrow y {f'}_y + {c'}_y
+ \end{array}
+ \)
+
+ where *undistort* is an approximate iterative algorithm that estimates the normalized original
+ point coordinates out of the normalized distorted point coordinates ("normalized" means that the
+ coordinates do not depend on the camera matrix).
+
+ The function can be used for both a stereo camera head or a monocular camera (when R is empty).
+
+
Parameters:
+
src - Observed point coordinates, 2xN/Nx2 1-channel or 1xN/Nx1 2-channel (CV_32FC2 or CV_64FC2) (or
+ vector<Point2f> ).
+
dst - Output ideal point coordinates (1xN/Nx1 2-channel or vector<Point2f> ) after undistortion and reverse perspective
+ transformation. If matrix P is identity or omitted, dst will contain normalized point coordinates.
+
cameraMatrix - Camera matrix \(\vecthreethree{f_x}{0}{c_x}{0}{f_y}{c_y}{0}{0}{1}\) .
+
distCoeffs - Input vector of distortion coefficients
+ \((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]]]])\)
+ of 4, 5, 8, 12 or 14 elements. If the vector is NULL/empty, the zero distortion coefficients are assumed.
+ #stereoRectify can be passed here. If the matrix is empty, the identity transformation is used.
+ #stereoRectify can be passed here. If the matrix is empty, the identity new camera matrix is used.
Computes the ideal point coordinates from the observed point coordinates.
+
+ The function is similar to #undistort and #initUndistortRectifyMap but it operates on a
+ sparse set of points instead of a raster image. Also the function performs a reverse transformation
+ to #projectPoints. In case of a 3D object, it does not reconstruct its 3D coordinates, but for a
+ planar object, it does, up to a translation vector, if the proper R is specified.
+
+ For each observed point coordinate \((u, v)\) the function computes:
+ \(
+ \begin{array}{l}
+ x^{"} \leftarrow (u - c_x)/f_x \\
+ y^{"} \leftarrow (v - c_y)/f_y \\
+ (x',y') = undistort(x^{"},y^{"}, \texttt{distCoeffs}) \\
+ {[X\,Y\,W]} ^T \leftarrow R*[x' \, y' \, 1]^T \\
+ x \leftarrow X/W \\
+ y \leftarrow Y/W \\
+ \text{only performed if P is specified:} \\
+ u' \leftarrow x {f'}_x + {c'}_x \\
+ v' \leftarrow y {f'}_y + {c'}_y
+ \end{array}
+ \)
+
+ where *undistort* is an approximate iterative algorithm that estimates the normalized original
+ point coordinates out of the normalized distorted point coordinates ("normalized" means that the
+ coordinates do not depend on the camera matrix).
+
+ The function can be used for both a stereo camera head or a monocular camera (when R is empty).
+
+
Parameters:
+
src - Observed point coordinates, 2xN/Nx2 1-channel or 1xN/Nx1 2-channel (CV_32FC2 or CV_64FC2) (or
+ vector<Point2f> ).
+
dst - Output ideal point coordinates (1xN/Nx1 2-channel or vector<Point2f> ) after undistortion and reverse perspective
+ transformation. If matrix P is identity or omitted, dst will contain normalized point coordinates.
+
cameraMatrix - Camera matrix \(\vecthreethree{f_x}{0}{c_x}{0}{f_y}{c_y}{0}{0}{1}\) .
+
distCoeffs - Input vector of distortion coefficients
+ \((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]]]])\)
+ of 4, 5, 8, 12 or 14 elements. If the vector is NULL/empty, the zero distortion coefficients are assumed.
+
R - Rectification transformation in the object space (3x3 matrix). R1 or R2 computed by
+ #stereoRectify can be passed here. If the matrix is empty, the identity transformation is used.
+ #stereoRectify can be passed here. If the matrix is empty, the identity new camera matrix is used.
Computes the ideal point coordinates from the observed point coordinates.
+
+ The function is similar to #undistort and #initUndistortRectifyMap but it operates on a
+ sparse set of points instead of a raster image. Also the function performs a reverse transformation
+ to #projectPoints. In case of a 3D object, it does not reconstruct its 3D coordinates, but for a
+ planar object, it does, up to a translation vector, if the proper R is specified.
+
+ For each observed point coordinate \((u, v)\) the function computes:
+ \(
+ \begin{array}{l}
+ x^{"} \leftarrow (u - c_x)/f_x \\
+ y^{"} \leftarrow (v - c_y)/f_y \\
+ (x',y') = undistort(x^{"},y^{"}, \texttt{distCoeffs}) \\
+ {[X\,Y\,W]} ^T \leftarrow R*[x' \, y' \, 1]^T \\
+ x \leftarrow X/W \\
+ y \leftarrow Y/W \\
+ \text{only performed if P is specified:} \\
+ u' \leftarrow x {f'}_x + {c'}_x \\
+ v' \leftarrow y {f'}_y + {c'}_y
+ \end{array}
+ \)
+
+ where *undistort* is an approximate iterative algorithm that estimates the normalized original
+ point coordinates out of the normalized distorted point coordinates ("normalized" means that the
+ coordinates do not depend on the camera matrix).
+
+ The function can be used for both a stereo camera head or a monocular camera (when R is empty).
+
+
Parameters:
+
src - Observed point coordinates, 2xN/Nx2 1-channel or 1xN/Nx1 2-channel (CV_32FC2 or CV_64FC2) (or
+ vector<Point2f> ).
+
dst - Output ideal point coordinates (1xN/Nx1 2-channel or vector<Point2f> ) after undistortion and reverse perspective
+ transformation. If matrix P is identity or omitted, dst will contain normalized point coordinates.
+
cameraMatrix - Camera matrix \(\vecthreethree{f_x}{0}{c_x}{0}{f_y}{c_y}{0}{0}{1}\) .
+
distCoeffs - Input vector of distortion coefficients
+ \((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]]]])\)
+ of 4, 5, 8, 12 or 14 elements. If the vector is NULL/empty, the zero distortion coefficients are assumed.
+
R - Rectification transformation in the object space (3x3 matrix). R1 or R2 computed by
+ #stereoRectify can be passed here. If the matrix is empty, the identity transformation is used.
+
P - New camera matrix (3x3) or new projection matrix (3x4) \(\begin{bmatrix} {f'}_x & 0 & {c'}_x & t_x \\ 0 & {f'}_y & {c'}_y & t_y \\ 0 & 0 & 1 & t_z \end{bmatrix}\). P1 or P2 computed by
+ #stereoRectify can be passed here. If the matrix is empty, the identity new camera matrix is used.
Creates StereoBM object
+
+ disparity from 0 (default minimum disparity) to numDisparities. The search range can then be
+ shifted by changing the minimum disparity.
+ (as the block is centered at the current pixel). Larger block size implies smoother, though less
+ accurate disparity map. Smaller block size gives more detailed disparity map, but there is higher
+ chance for algorithm to find a wrong correspondence.
+
+ The function create StereoBM object. You can then call StereoBM::compute() to compute disparity for
+ a specific stereo pair.
numDisparities - the disparity search range. For each pixel algorithm will find the best
+ disparity from 0 (default minimum disparity) to numDisparities. The search range can then be
+ shifted by changing the minimum disparity.
+ (as the block is centered at the current pixel). Larger block size implies smoother, though less
+ accurate disparity map. Smaller block size gives more detailed disparity map, but there is higher
+ chance for algorithm to find a wrong correspondence.
+
+ The function create StereoBM object. You can then call StereoBM::compute() to compute disparity for
+ a specific stereo pair.
public static StereoBM create(int numDisparities,
+ int blockSize)
+
Creates StereoBM object
+
+
Parameters:
+
numDisparities - the disparity search range. For each pixel algorithm will find the best
+ disparity from 0 (default minimum disparity) to numDisparities. The search range can then be
+ shifted by changing the minimum disparity.
+
blockSize - the linear size of the blocks compared by the algorithm. The size should be odd
+ (as the block is centered at the current pixel). Larger block size implies smoother, though less
+ accurate disparity map. Smaller block size gives more detailed disparity map, but there is higher
+ chance for algorithm to find a wrong correspondence.
+
+ The function create StereoBM object. You can then call StereoBM::compute() to compute disparity for
+ a specific stereo pair.
public void compute(Mat left,
+ Mat right,
+ Mat disparity)
+
Computes disparity map for the specified stereo pair
+
+
Parameters:
+
left - Left 8-bit single-channel image.
+
right - Right image of the same size and the same type as the left one.
+
disparity - Output disparity map. It has the same size as the input images. Some algorithms,
+ like StereoBM or StereoSGBM compute 16-bit fixed-point disparity map (where each disparity value
+ has 4 fractional bits), whereas other algorithms output 32-bit floating-point disparity map.
The class implements the modified H. Hirschmuller algorithm CITE: HH08 that differs from the original
+ one as follows:
+
+
+
+ By default, the algorithm is single-pass, which means that you consider only 5 directions
+ instead of 8. Set mode=StereoSGBM::MODE_HH in createStereoSGBM to run the full variant of the
+ algorithm but beware that it may consume a lot of memory.
+
+
+ The algorithm matches blocks, not individual pixels. Though, setting blockSize=1 reduces the
+ blocks to single pixels.
+
+
+ Mutual information cost function is not implemented. Instead, a simpler Birchfield-Tomasi
+ sub-pixel metric from CITE: BT98 is used. Though, the color images are supported as well.
+
+
+ Some pre- and post- processing steps from K. Konolige algorithm StereoBM are included, for
+ example: pre-filtering (StereoBM::PREFILTER_XSOBEL type) and post-filtering (uniqueness
+ check, quadratic interpolation and speckle filtering).
+
+
+
+ Note:
+
+
+ (Python) An example illustrating the use of the StereoSGBM matching algorithm can be found
+ at opencv_source_code/samples/python/stereo_match.py
+
create(int minDisparity,
+ int numDisparities,
+ int blockSize,
+ int P1,
+ int P2,
+ int disp12MaxDiff,
+ int preFilterCap,
+ int uniquenessRatio,
+ int speckleWindowSize)
+
create(int minDisparity,
+ int numDisparities,
+ int blockSize,
+ int P1,
+ int P2,
+ int disp12MaxDiff,
+ int preFilterCap,
+ int uniquenessRatio,
+ int speckleWindowSize,
+ int speckleRange)
+
create(int minDisparity,
+ int numDisparities,
+ int blockSize,
+ int P1,
+ int P2,
+ int disp12MaxDiff,
+ int preFilterCap,
+ int uniquenessRatio,
+ int speckleWindowSize,
+ int speckleRange,
+ int mode)
+
Creates StereoSGBM object
+
+ rectification algorithms can shift images, so this parameter needs to be adjusted accordingly.
+ zero. In the current implementation, this parameter must be divisible by 16.
+ somewhere in the 3..11 range.
+ the smoother the disparity is. P1 is the penalty on the disparity change by plus or minus 1
+ between neighbor pixels. P2 is the penalty on the disparity change by more than 1 between neighbor
+ pixels. The algorithm requires P2 > P1 . See stereo_match.cpp sample where some reasonably good
+ P1 and P2 values are shown (like 8\*number_of_image_channels\*blockSize\*blockSize and
+ 32\*number_of_image_channels\*blockSize\*blockSize , respectively).
+ disparity check. Set it to a non-positive value to disable the check.
+ computes x-derivative at each pixel and clips its value by [-preFilterCap, preFilterCap] interval.
+ The result values are passed to the Birchfield-Tomasi pixel cost function.
+ value should "win" the second best value to consider the found match correct. Normally, a value
+ within the 5-15 range is good enough.
+ and invalidate. Set it to 0 to disable speckle filtering. Otherwise, set it somewhere in the
+ 50-200 range.
+ filtering, set the parameter to a positive value, it will be implicitly multiplied by 16.
+ Normally, 1 or 2 is good enough.
+ algorithm. It will consume O(W\*H\*numDisparities) bytes, which is large for 640x480 stereo and
+ huge for HD-size pictures. By default, it is set to false .
+
+ The first constructor initializes StereoSGBM with all the default parameters. So, you only have to
+ set StereoSGBM::numDisparities at minimum. The second constructor enables you to set each parameter
+ to a custom value.
minDisparity - Minimum possible disparity value. Normally, it is zero but sometimes
+ rectification algorithms can shift images, so this parameter needs to be adjusted accordingly.
+ zero. In the current implementation, this parameter must be divisible by 16.
+ somewhere in the 3..11 range.
+ the smoother the disparity is. P1 is the penalty on the disparity change by plus or minus 1
+ between neighbor pixels. P2 is the penalty on the disparity change by more than 1 between neighbor
+ pixels. The algorithm requires P2 > P1 . See stereo_match.cpp sample where some reasonably good
+ P1 and P2 values are shown (like 8\*number_of_image_channels\*blockSize\*blockSize and
+ 32\*number_of_image_channels\*blockSize\*blockSize , respectively).
+ disparity check. Set it to a non-positive value to disable the check.
+ computes x-derivative at each pixel and clips its value by [-preFilterCap, preFilterCap] interval.
+ The result values are passed to the Birchfield-Tomasi pixel cost function.
+ value should "win" the second best value to consider the found match correct. Normally, a value
+ within the 5-15 range is good enough.
+ and invalidate. Set it to 0 to disable speckle filtering. Otherwise, set it somewhere in the
+ 50-200 range.
+ filtering, set the parameter to a positive value, it will be implicitly multiplied by 16.
+ Normally, 1 or 2 is good enough.
+ algorithm. It will consume O(W\*H\*numDisparities) bytes, which is large for 640x480 stereo and
+ huge for HD-size pictures. By default, it is set to false .
+
+ The first constructor initializes StereoSGBM with all the default parameters. So, you only have to
+ set StereoSGBM::numDisparities at minimum. The second constructor enables you to set each parameter
+ to a custom value.
public static StereoSGBM create(int minDisparity,
+ int numDisparities)
+
Creates StereoSGBM object
+
+
Parameters:
+
minDisparity - Minimum possible disparity value. Normally, it is zero but sometimes
+ rectification algorithms can shift images, so this parameter needs to be adjusted accordingly.
+
numDisparities - Maximum disparity minus minimum disparity. The value is always greater than
+ zero. In the current implementation, this parameter must be divisible by 16.
+ somewhere in the 3..11 range.
+ the smoother the disparity is. P1 is the penalty on the disparity change by plus or minus 1
+ between neighbor pixels. P2 is the penalty on the disparity change by more than 1 between neighbor
+ pixels. The algorithm requires P2 > P1 . See stereo_match.cpp sample where some reasonably good
+ P1 and P2 values are shown (like 8\*number_of_image_channels\*blockSize\*blockSize and
+ 32\*number_of_image_channels\*blockSize\*blockSize , respectively).
+ disparity check. Set it to a non-positive value to disable the check.
+ computes x-derivative at each pixel and clips its value by [-preFilterCap, preFilterCap] interval.
+ The result values are passed to the Birchfield-Tomasi pixel cost function.
+ value should "win" the second best value to consider the found match correct. Normally, a value
+ within the 5-15 range is good enough.
+ and invalidate. Set it to 0 to disable speckle filtering. Otherwise, set it somewhere in the
+ 50-200 range.
+ filtering, set the parameter to a positive value, it will be implicitly multiplied by 16.
+ Normally, 1 or 2 is good enough.
+ algorithm. It will consume O(W\*H\*numDisparities) bytes, which is large for 640x480 stereo and
+ huge for HD-size pictures. By default, it is set to false .
+
+ The first constructor initializes StereoSGBM with all the default parameters. So, you only have to
+ set StereoSGBM::numDisparities at minimum. The second constructor enables you to set each parameter
+ to a custom value.
public static StereoSGBM create(int minDisparity,
+ int numDisparities,
+ int blockSize)
+
Creates StereoSGBM object
+
+
Parameters:
+
minDisparity - Minimum possible disparity value. Normally, it is zero but sometimes
+ rectification algorithms can shift images, so this parameter needs to be adjusted accordingly.
+
numDisparities - Maximum disparity minus minimum disparity. The value is always greater than
+ zero. In the current implementation, this parameter must be divisible by 16.
+
blockSize - Matched block size. It must be an odd number >=1 . Normally, it should be
+ somewhere in the 3..11 range.
+ the smoother the disparity is. P1 is the penalty on the disparity change by plus or minus 1
+ between neighbor pixels. P2 is the penalty on the disparity change by more than 1 between neighbor
+ pixels. The algorithm requires P2 > P1 . See stereo_match.cpp sample where some reasonably good
+ P1 and P2 values are shown (like 8\*number_of_image_channels\*blockSize\*blockSize and
+ 32\*number_of_image_channels\*blockSize\*blockSize , respectively).
+ disparity check. Set it to a non-positive value to disable the check.
+ computes x-derivative at each pixel and clips its value by [-preFilterCap, preFilterCap] interval.
+ The result values are passed to the Birchfield-Tomasi pixel cost function.
+ value should "win" the second best value to consider the found match correct. Normally, a value
+ within the 5-15 range is good enough.
+ and invalidate. Set it to 0 to disable speckle filtering. Otherwise, set it somewhere in the
+ 50-200 range.
+ filtering, set the parameter to a positive value, it will be implicitly multiplied by 16.
+ Normally, 1 or 2 is good enough.
+ algorithm. It will consume O(W\*H\*numDisparities) bytes, which is large for 640x480 stereo and
+ huge for HD-size pictures. By default, it is set to false .
+
+ The first constructor initializes StereoSGBM with all the default parameters. So, you only have to
+ set StereoSGBM::numDisparities at minimum. The second constructor enables you to set each parameter
+ to a custom value.
public static StereoSGBM create(int minDisparity,
+ int numDisparities,
+ int blockSize,
+ int P1)
+
Creates StereoSGBM object
+
+
Parameters:
+
minDisparity - Minimum possible disparity value. Normally, it is zero but sometimes
+ rectification algorithms can shift images, so this parameter needs to be adjusted accordingly.
+
numDisparities - Maximum disparity minus minimum disparity. The value is always greater than
+ zero. In the current implementation, this parameter must be divisible by 16.
+
blockSize - Matched block size. It must be an odd number >=1 . Normally, it should be
+ somewhere in the 3..11 range.
+
P1 - The first parameter controlling the disparity smoothness. See below.
+ the smoother the disparity is. P1 is the penalty on the disparity change by plus or minus 1
+ between neighbor pixels. P2 is the penalty on the disparity change by more than 1 between neighbor
+ pixels. The algorithm requires P2 > P1 . See stereo_match.cpp sample where some reasonably good
+ P1 and P2 values are shown (like 8\*number_of_image_channels\*blockSize\*blockSize and
+ 32\*number_of_image_channels\*blockSize\*blockSize , respectively).
+ disparity check. Set it to a non-positive value to disable the check.
+ computes x-derivative at each pixel and clips its value by [-preFilterCap, preFilterCap] interval.
+ The result values are passed to the Birchfield-Tomasi pixel cost function.
+ value should "win" the second best value to consider the found match correct. Normally, a value
+ within the 5-15 range is good enough.
+ and invalidate. Set it to 0 to disable speckle filtering. Otherwise, set it somewhere in the
+ 50-200 range.
+ filtering, set the parameter to a positive value, it will be implicitly multiplied by 16.
+ Normally, 1 or 2 is good enough.
+ algorithm. It will consume O(W\*H\*numDisparities) bytes, which is large for 640x480 stereo and
+ huge for HD-size pictures. By default, it is set to false .
+
+ The first constructor initializes StereoSGBM with all the default parameters. So, you only have to
+ set StereoSGBM::numDisparities at minimum. The second constructor enables you to set each parameter
+ to a custom value.
public static StereoSGBM create(int minDisparity,
+ int numDisparities,
+ int blockSize,
+ int P1,
+ int P2)
+
Creates StereoSGBM object
+
+
Parameters:
+
minDisparity - Minimum possible disparity value. Normally, it is zero but sometimes
+ rectification algorithms can shift images, so this parameter needs to be adjusted accordingly.
+
numDisparities - Maximum disparity minus minimum disparity. The value is always greater than
+ zero. In the current implementation, this parameter must be divisible by 16.
+
blockSize - Matched block size. It must be an odd number >=1 . Normally, it should be
+ somewhere in the 3..11 range.
+
P1 - The first parameter controlling the disparity smoothness. See below.
+
P2 - The second parameter controlling the disparity smoothness. The larger the values are,
+ the smoother the disparity is. P1 is the penalty on the disparity change by plus or minus 1
+ between neighbor pixels. P2 is the penalty on the disparity change by more than 1 between neighbor
+ pixels. The algorithm requires P2 > P1 . See stereo_match.cpp sample where some reasonably good
+ P1 and P2 values are shown (like 8\*number_of_image_channels\*blockSize\*blockSize and
+ 32\*number_of_image_channels\*blockSize\*blockSize , respectively).
+ disparity check. Set it to a non-positive value to disable the check.
+ computes x-derivative at each pixel and clips its value by [-preFilterCap, preFilterCap] interval.
+ The result values are passed to the Birchfield-Tomasi pixel cost function.
+ value should "win" the second best value to consider the found match correct. Normally, a value
+ within the 5-15 range is good enough.
+ and invalidate. Set it to 0 to disable speckle filtering. Otherwise, set it somewhere in the
+ 50-200 range.
+ filtering, set the parameter to a positive value, it will be implicitly multiplied by 16.
+ Normally, 1 or 2 is good enough.
+ algorithm. It will consume O(W\*H\*numDisparities) bytes, which is large for 640x480 stereo and
+ huge for HD-size pictures. By default, it is set to false .
+
+ The first constructor initializes StereoSGBM with all the default parameters. So, you only have to
+ set StereoSGBM::numDisparities at minimum. The second constructor enables you to set each parameter
+ to a custom value.
public static StereoSGBM create(int minDisparity,
+ int numDisparities,
+ int blockSize,
+ int P1,
+ int P2,
+ int disp12MaxDiff)
+
Creates StereoSGBM object
+
+
Parameters:
+
minDisparity - Minimum possible disparity value. Normally, it is zero but sometimes
+ rectification algorithms can shift images, so this parameter needs to be adjusted accordingly.
+
numDisparities - Maximum disparity minus minimum disparity. The value is always greater than
+ zero. In the current implementation, this parameter must be divisible by 16.
+
blockSize - Matched block size. It must be an odd number >=1 . Normally, it should be
+ somewhere in the 3..11 range.
+
P1 - The first parameter controlling the disparity smoothness. See below.
+
P2 - The second parameter controlling the disparity smoothness. The larger the values are,
+ the smoother the disparity is. P1 is the penalty on the disparity change by plus or minus 1
+ between neighbor pixels. P2 is the penalty on the disparity change by more than 1 between neighbor
+ pixels. The algorithm requires P2 > P1 . See stereo_match.cpp sample where some reasonably good
+ P1 and P2 values are shown (like 8\*number_of_image_channels\*blockSize\*blockSize and
+ 32\*number_of_image_channels\*blockSize\*blockSize , respectively).
+
disp12MaxDiff - Maximum allowed difference (in integer pixel units) in the left-right
+ disparity check. Set it to a non-positive value to disable the check.
+ computes x-derivative at each pixel and clips its value by [-preFilterCap, preFilterCap] interval.
+ The result values are passed to the Birchfield-Tomasi pixel cost function.
+ value should "win" the second best value to consider the found match correct. Normally, a value
+ within the 5-15 range is good enough.
+ and invalidate. Set it to 0 to disable speckle filtering. Otherwise, set it somewhere in the
+ 50-200 range.
+ filtering, set the parameter to a positive value, it will be implicitly multiplied by 16.
+ Normally, 1 or 2 is good enough.
+ algorithm. It will consume O(W\*H\*numDisparities) bytes, which is large for 640x480 stereo and
+ huge for HD-size pictures. By default, it is set to false .
+
+ The first constructor initializes StereoSGBM with all the default parameters. So, you only have to
+ set StereoSGBM::numDisparities at minimum. The second constructor enables you to set each parameter
+ to a custom value.
public static StereoSGBM create(int minDisparity,
+ int numDisparities,
+ int blockSize,
+ int P1,
+ int P2,
+ int disp12MaxDiff,
+ int preFilterCap)
+
Creates StereoSGBM object
+
+
Parameters:
+
minDisparity - Minimum possible disparity value. Normally, it is zero but sometimes
+ rectification algorithms can shift images, so this parameter needs to be adjusted accordingly.
+
numDisparities - Maximum disparity minus minimum disparity. The value is always greater than
+ zero. In the current implementation, this parameter must be divisible by 16.
+
blockSize - Matched block size. It must be an odd number >=1 . Normally, it should be
+ somewhere in the 3..11 range.
+
P1 - The first parameter controlling the disparity smoothness. See below.
+
P2 - The second parameter controlling the disparity smoothness. The larger the values are,
+ the smoother the disparity is. P1 is the penalty on the disparity change by plus or minus 1
+ between neighbor pixels. P2 is the penalty on the disparity change by more than 1 between neighbor
+ pixels. The algorithm requires P2 > P1 . See stereo_match.cpp sample where some reasonably good
+ P1 and P2 values are shown (like 8\*number_of_image_channels\*blockSize\*blockSize and
+ 32\*number_of_image_channels\*blockSize\*blockSize , respectively).
+
disp12MaxDiff - Maximum allowed difference (in integer pixel units) in the left-right
+ disparity check. Set it to a non-positive value to disable the check.
+
preFilterCap - Truncation value for the prefiltered image pixels. The algorithm first
+ computes x-derivative at each pixel and clips its value by [-preFilterCap, preFilterCap] interval.
+ The result values are passed to the Birchfield-Tomasi pixel cost function.
+ value should "win" the second best value to consider the found match correct. Normally, a value
+ within the 5-15 range is good enough.
+ and invalidate. Set it to 0 to disable speckle filtering. Otherwise, set it somewhere in the
+ 50-200 range.
+ filtering, set the parameter to a positive value, it will be implicitly multiplied by 16.
+ Normally, 1 or 2 is good enough.
+ algorithm. It will consume O(W\*H\*numDisparities) bytes, which is large for 640x480 stereo and
+ huge for HD-size pictures. By default, it is set to false .
+
+ The first constructor initializes StereoSGBM with all the default parameters. So, you only have to
+ set StereoSGBM::numDisparities at minimum. The second constructor enables you to set each parameter
+ to a custom value.
public static StereoSGBM create(int minDisparity,
+ int numDisparities,
+ int blockSize,
+ int P1,
+ int P2,
+ int disp12MaxDiff,
+ int preFilterCap,
+ int uniquenessRatio)
+
Creates StereoSGBM object
+
+
Parameters:
+
minDisparity - Minimum possible disparity value. Normally, it is zero but sometimes
+ rectification algorithms can shift images, so this parameter needs to be adjusted accordingly.
+
numDisparities - Maximum disparity minus minimum disparity. The value is always greater than
+ zero. In the current implementation, this parameter must be divisible by 16.
+
blockSize - Matched block size. It must be an odd number >=1 . Normally, it should be
+ somewhere in the 3..11 range.
+
P1 - The first parameter controlling the disparity smoothness. See below.
+
P2 - The second parameter controlling the disparity smoothness. The larger the values are,
+ the smoother the disparity is. P1 is the penalty on the disparity change by plus or minus 1
+ between neighbor pixels. P2 is the penalty on the disparity change by more than 1 between neighbor
+ pixels. The algorithm requires P2 > P1 . See stereo_match.cpp sample where some reasonably good
+ P1 and P2 values are shown (like 8\*number_of_image_channels\*blockSize\*blockSize and
+ 32\*number_of_image_channels\*blockSize\*blockSize , respectively).
+
disp12MaxDiff - Maximum allowed difference (in integer pixel units) in the left-right
+ disparity check. Set it to a non-positive value to disable the check.
+
preFilterCap - Truncation value for the prefiltered image pixels. The algorithm first
+ computes x-derivative at each pixel and clips its value by [-preFilterCap, preFilterCap] interval.
+ The result values are passed to the Birchfield-Tomasi pixel cost function.
+
uniquenessRatio - Margin in percentage by which the best (minimum) computed cost function
+ value should "win" the second best value to consider the found match correct. Normally, a value
+ within the 5-15 range is good enough.
+ and invalidate. Set it to 0 to disable speckle filtering. Otherwise, set it somewhere in the
+ 50-200 range.
+ filtering, set the parameter to a positive value, it will be implicitly multiplied by 16.
+ Normally, 1 or 2 is good enough.
+ algorithm. It will consume O(W\*H\*numDisparities) bytes, which is large for 640x480 stereo and
+ huge for HD-size pictures. By default, it is set to false .
+
+ The first constructor initializes StereoSGBM with all the default parameters. So, you only have to
+ set StereoSGBM::numDisparities at minimum. The second constructor enables you to set each parameter
+ to a custom value.
public static StereoSGBM create(int minDisparity,
+ int numDisparities,
+ int blockSize,
+ int P1,
+ int P2,
+ int disp12MaxDiff,
+ int preFilterCap,
+ int uniquenessRatio,
+ int speckleWindowSize)
+
Creates StereoSGBM object
+
+
Parameters:
+
minDisparity - Minimum possible disparity value. Normally, it is zero but sometimes
+ rectification algorithms can shift images, so this parameter needs to be adjusted accordingly.
+
numDisparities - Maximum disparity minus minimum disparity. The value is always greater than
+ zero. In the current implementation, this parameter must be divisible by 16.
+
blockSize - Matched block size. It must be an odd number >=1 . Normally, it should be
+ somewhere in the 3..11 range.
+
P1 - The first parameter controlling the disparity smoothness. See below.
+
P2 - The second parameter controlling the disparity smoothness. The larger the values are,
+ the smoother the disparity is. P1 is the penalty on the disparity change by plus or minus 1
+ between neighbor pixels. P2 is the penalty on the disparity change by more than 1 between neighbor
+ pixels. The algorithm requires P2 > P1 . See stereo_match.cpp sample where some reasonably good
+ P1 and P2 values are shown (like 8\*number_of_image_channels\*blockSize\*blockSize and
+ 32\*number_of_image_channels\*blockSize\*blockSize , respectively).
+
disp12MaxDiff - Maximum allowed difference (in integer pixel units) in the left-right
+ disparity check. Set it to a non-positive value to disable the check.
+
preFilterCap - Truncation value for the prefiltered image pixels. The algorithm first
+ computes x-derivative at each pixel and clips its value by [-preFilterCap, preFilterCap] interval.
+ The result values are passed to the Birchfield-Tomasi pixel cost function.
+
uniquenessRatio - Margin in percentage by which the best (minimum) computed cost function
+ value should "win" the second best value to consider the found match correct. Normally, a value
+ within the 5-15 range is good enough.
+
speckleWindowSize - Maximum size of smooth disparity regions to consider their noise speckles
+ and invalidate. Set it to 0 to disable speckle filtering. Otherwise, set it somewhere in the
+ 50-200 range.
+ filtering, set the parameter to a positive value, it will be implicitly multiplied by 16.
+ Normally, 1 or 2 is good enough.
+ algorithm. It will consume O(W\*H\*numDisparities) bytes, which is large for 640x480 stereo and
+ huge for HD-size pictures. By default, it is set to false .
+
+ The first constructor initializes StereoSGBM with all the default parameters. So, you only have to
+ set StereoSGBM::numDisparities at minimum. The second constructor enables you to set each parameter
+ to a custom value.
public static StereoSGBM create(int minDisparity,
+ int numDisparities,
+ int blockSize,
+ int P1,
+ int P2,
+ int disp12MaxDiff,
+ int preFilterCap,
+ int uniquenessRatio,
+ int speckleWindowSize,
+ int speckleRange)
+
Creates StereoSGBM object
+
+
Parameters:
+
minDisparity - Minimum possible disparity value. Normally, it is zero but sometimes
+ rectification algorithms can shift images, so this parameter needs to be adjusted accordingly.
+
numDisparities - Maximum disparity minus minimum disparity. The value is always greater than
+ zero. In the current implementation, this parameter must be divisible by 16.
+
blockSize - Matched block size. It must be an odd number >=1 . Normally, it should be
+ somewhere in the 3..11 range.
+
P1 - The first parameter controlling the disparity smoothness. See below.
+
P2 - The second parameter controlling the disparity smoothness. The larger the values are,
+ the smoother the disparity is. P1 is the penalty on the disparity change by plus or minus 1
+ between neighbor pixels. P2 is the penalty on the disparity change by more than 1 between neighbor
+ pixels. The algorithm requires P2 > P1 . See stereo_match.cpp sample where some reasonably good
+ P1 and P2 values are shown (like 8\*number_of_image_channels\*blockSize\*blockSize and
+ 32\*number_of_image_channels\*blockSize\*blockSize , respectively).
+
disp12MaxDiff - Maximum allowed difference (in integer pixel units) in the left-right
+ disparity check. Set it to a non-positive value to disable the check.
+
preFilterCap - Truncation value for the prefiltered image pixels. The algorithm first
+ computes x-derivative at each pixel and clips its value by [-preFilterCap, preFilterCap] interval.
+ The result values are passed to the Birchfield-Tomasi pixel cost function.
+
uniquenessRatio - Margin in percentage by which the best (minimum) computed cost function
+ value should "win" the second best value to consider the found match correct. Normally, a value
+ within the 5-15 range is good enough.
+
speckleWindowSize - Maximum size of smooth disparity regions to consider their noise speckles
+ and invalidate. Set it to 0 to disable speckle filtering. Otherwise, set it somewhere in the
+ 50-200 range.
+
speckleRange - Maximum disparity variation within each connected component. If you do speckle
+ filtering, set the parameter to a positive value, it will be implicitly multiplied by 16.
+ Normally, 1 or 2 is good enough.
+ algorithm. It will consume O(W\*H\*numDisparities) bytes, which is large for 640x480 stereo and
+ huge for HD-size pictures. By default, it is set to false .
+
+ The first constructor initializes StereoSGBM with all the default parameters. So, you only have to
+ set StereoSGBM::numDisparities at minimum. The second constructor enables you to set each parameter
+ to a custom value.
public static StereoSGBM create(int minDisparity,
+ int numDisparities,
+ int blockSize,
+ int P1,
+ int P2,
+ int disp12MaxDiff,
+ int preFilterCap,
+ int uniquenessRatio,
+ int speckleWindowSize,
+ int speckleRange,
+ int mode)
+
Creates StereoSGBM object
+
+
Parameters:
+
minDisparity - Minimum possible disparity value. Normally, it is zero but sometimes
+ rectification algorithms can shift images, so this parameter needs to be adjusted accordingly.
+
numDisparities - Maximum disparity minus minimum disparity. The value is always greater than
+ zero. In the current implementation, this parameter must be divisible by 16.
+
blockSize - Matched block size. It must be an odd number >=1 . Normally, it should be
+ somewhere in the 3..11 range.
+
P1 - The first parameter controlling the disparity smoothness. See below.
+
P2 - The second parameter controlling the disparity smoothness. The larger the values are,
+ the smoother the disparity is. P1 is the penalty on the disparity change by plus or minus 1
+ between neighbor pixels. P2 is the penalty on the disparity change by more than 1 between neighbor
+ pixels. The algorithm requires P2 > P1 . See stereo_match.cpp sample where some reasonably good
+ P1 and P2 values are shown (like 8\*number_of_image_channels\*blockSize\*blockSize and
+ 32\*number_of_image_channels\*blockSize\*blockSize , respectively).
+
disp12MaxDiff - Maximum allowed difference (in integer pixel units) in the left-right
+ disparity check. Set it to a non-positive value to disable the check.
+
preFilterCap - Truncation value for the prefiltered image pixels. The algorithm first
+ computes x-derivative at each pixel and clips its value by [-preFilterCap, preFilterCap] interval.
+ The result values are passed to the Birchfield-Tomasi pixel cost function.
+
uniquenessRatio - Margin in percentage by which the best (minimum) computed cost function
+ value should "win" the second best value to consider the found match correct. Normally, a value
+ within the 5-15 range is good enough.
+
speckleWindowSize - Maximum size of smooth disparity regions to consider their noise speckles
+ and invalidate. Set it to 0 to disable speckle filtering. Otherwise, set it somewhere in the
+ 50-200 range.
+
speckleRange - Maximum disparity variation within each connected component. If you do speckle
+ filtering, set the parameter to a positive value, it will be implicitly multiplied by 16.
+ Normally, 1 or 2 is good enough.
+
mode - Set it to StereoSGBM::MODE_HH to run the full-scale two-pass dynamic programming
+ algorithm. It will consume O(W\*H\*numDisparities) bytes, which is large for 640x480 stereo and
+ huge for HD-size pictures. By default, it is set to false .
+
+ The first constructor initializes StereoSGBM with all the default parameters. So, you only have to
+ set StereoSGBM::numDisparities at minimum. The second constructor enables you to set each parameter
+ to a custom value.
This is a base class for all more or less complex algorithms in OpenCV
+
+ especially for classes of algorithms, for which there can be multiple implementations. The examples
+ are stereo correspondence (for which there are algorithms like block matching, semi-global block
+ matching, graph-cut etc.), background subtraction (which can be done using mixture-of-gaussians
+ models, codebook-based algorithm etc.), optical flow (block matching, Lucas-Kanade, Horn-Schunck
+ etc.).
+
+ Here is example of SimpleBlobDetector use in your application via Algorithm interface:
+ SNIPPET: snippets/core_various.cpp Algorithm
Append samples search data sub directory
+
+ General usage is to add OpenCV modules name (<opencv_contrib>/modules/<name>/samples/data -> <name>/samples/data + modules/<name>/samples/data).
+
+
+
+
static void
+
addWeighted(Mat src1,
+ double alpha,
+ Mat src2,
+ double beta,
+ double gamma,
+ Mat dst)
+
Calculates the weighted sum of two arrays.
+
+
+
+
static void
+
addWeighted(Mat src1,
+ double alpha,
+ Mat src2,
+ double beta,
+ double gamma,
+ Mat dst,
+ int dtype)
+
computes bitwise conjunction of the two arrays (dst = src1 & src2)
+ Calculates the per-element bit-wise conjunction of two arrays or an
+ array and a scalar.
computes bitwise conjunction of the two arrays (dst = src1 & src2)
+ Calculates the per-element bit-wise conjunction of two arrays or an
+ array and a scalar.
Returns the list of locations of non-zero pixels
+
+ Given a binary matrix (likely returned from an operation such
+ as threshold(), compare(), >, ==, etc, return all of
+ the non-zero indices as a cv::Mat or std::vector<cv::Point> (x,y)
+ For example:
+
+ cv::Mat binaryImage; // input, binary image
+ cv::Mat locations; // output, locations of non-zero pixels
+ cv::findNonZero(binaryImage, locations);
+
+ // access pixel coordinates
+ Point pnt = locations.at<Point>(i);
+
+ or
+
+ cv::Mat binaryImage; // input, binary image
+ vector<Point> locations; // output, locations of non-zero pixels
+ cv::findNonZero(binaryImage, locations);
+
+ // access pixel coordinates
+ Point pnt = locations[i];
+
Finds indices of max elements along provided axis
+
+ Note:
+ - If input or output array is not continuous, this function will create an internal copy.
Finds indices of max elements along provided axis
+
+ Note:
+ - If input or output array is not continuous, this function will create an internal copy.
Finds indices of min elements along provided axis
+
+ Note:
+ - If input or output array is not continuous, this function will create an internal copy.
Finds indices of min elements along provided axis
+
+ Note:
+ - If input or output array is not continuous, this function will create an internal copy.
public static void absdiff(Mat src1,
+ Mat src2,
+ Mat dst)
+
Calculates the per-element absolute difference between two arrays or between an array and a scalar.
+
+ The function cv::absdiff calculates:
+ Absolute difference between two arrays when they have the same
+ size and type:
+ \(\texttt{dst}(I) = \texttt{saturate} (| \texttt{src1}(I) - \texttt{src2}(I)|)\)
+ Absolute difference between an array and a scalar when the second
+ array is constructed from Scalar or has as many elements as the
+ number of channels in src1:
+ \(\texttt{dst}(I) = \texttt{saturate} (| \texttt{src1}(I) - \texttt{src2} |)\)
+ Absolute difference between a scalar and an array when the first
+ array is constructed from Scalar or has as many elements as the
+ number of channels in src2:
+ \(\texttt{dst}(I) = \texttt{saturate} (| \texttt{src1} - \texttt{src2}(I) |)\)
+ where I is a multi-dimensional index of array elements. In case of
+ multi-channel arrays, each channel is processed independently.
+ Note: Saturation is not applied when the arrays have the depth CV_32S.
+ You may even get a negative value in the case of overflow.
+
+
Parameters:
+
src1 - first input array or a scalar.
+
src2 - second input array or a scalar.
+
dst - output array that has the same size and type as input arrays.
+ SEE: cv::abs(const Mat&)
public static void add(Mat src1,
+ Mat src2,
+ Mat dst)
+
Calculates the per-element sum of two arrays or an array and a scalar.
+
+ The function add calculates:
+
+
+ Sum of two arrays when both input arrays have the same size and the same number of channels:
+ \(\texttt{dst}(I) = \texttt{saturate} ( \texttt{src1}(I) + \texttt{src2}(I)) \quad \texttt{if mask}(I) \ne0\)
+
+
+ Sum of an array and a scalar when src2 is constructed from Scalar or has the same number of
+ elements as src1.channels():
+ \(\texttt{dst}(I) = \texttt{saturate} ( \texttt{src1}(I) + \texttt{src2} ) \quad \texttt{if mask}(I) \ne0\)
+
+
+ Sum of a scalar and an array when src1 is constructed from Scalar or has the same number of
+ elements as src2.channels():
+ \(\texttt{dst}(I) = \texttt{saturate} ( \texttt{src1} + \texttt{src2}(I) ) \quad \texttt{if mask}(I) \ne0\)
+ where I is a multi-dimensional index of array elements. In case of multi-channel arrays, each
+ channel is processed independently.
+
+
+
+ The first function in the list above can be replaced with matrix expressions:
+
+ dst = src1 + src2;
+ dst += src1; // equivalent to add(dst, src1, dst);
+
+ The input arrays and the output array can all have the same or different depths. For example, you
+ can add a 16-bit unsigned array to a 8-bit signed array and store the sum as a 32-bit
+ floating-point array. Depth of the output array is determined by the dtype parameter. In the second
+ and third cases above, as well as in the first case, when src1.depth() == src2.depth(), dtype can
+ be set to the default -1. In this case, the output array will have the same depth as the input
+ array, be it src1, src2 or both.
+ Note: Saturation is not applied when the output array has the depth CV_32S. You may even get
+ result of an incorrect sign in the case of overflow.
+
+
Parameters:
+
src1 - first input array or a scalar.
+
src2 - second input array or a scalar.
+
dst - output array that has the same size and number of channels as the input array(s); the
+ depth is defined by dtype or src1/src2.
+ output array to be changed.
+ SEE: subtract, addWeighted, scaleAdd, Mat::convertTo
public static void add(Mat src1,
+ Mat src2,
+ Mat dst,
+ Mat mask)
+
Calculates the per-element sum of two arrays or an array and a scalar.
+
+ The function add calculates:
+
+
+ Sum of two arrays when both input arrays have the same size and the same number of channels:
+ \(\texttt{dst}(I) = \texttt{saturate} ( \texttt{src1}(I) + \texttt{src2}(I)) \quad \texttt{if mask}(I) \ne0\)
+
+
+ Sum of an array and a scalar when src2 is constructed from Scalar or has the same number of
+ elements as src1.channels():
+ \(\texttt{dst}(I) = \texttt{saturate} ( \texttt{src1}(I) + \texttt{src2} ) \quad \texttt{if mask}(I) \ne0\)
+
+
+ Sum of a scalar and an array when src1 is constructed from Scalar or has the same number of
+ elements as src2.channels():
+ \(\texttt{dst}(I) = \texttt{saturate} ( \texttt{src1} + \texttt{src2}(I) ) \quad \texttt{if mask}(I) \ne0\)
+ where I is a multi-dimensional index of array elements. In case of multi-channel arrays, each
+ channel is processed independently.
+
+
+
+ The first function in the list above can be replaced with matrix expressions:
+
+ dst = src1 + src2;
+ dst += src1; // equivalent to add(dst, src1, dst);
+
+ The input arrays and the output array can all have the same or different depths. For example, you
+ can add a 16-bit unsigned array to a 8-bit signed array and store the sum as a 32-bit
+ floating-point array. Depth of the output array is determined by the dtype parameter. In the second
+ and third cases above, as well as in the first case, when src1.depth() == src2.depth(), dtype can
+ be set to the default -1. In this case, the output array will have the same depth as the input
+ array, be it src1, src2 or both.
+ Note: Saturation is not applied when the output array has the depth CV_32S. You may even get
+ result of an incorrect sign in the case of overflow.
+
+
Parameters:
+
src1 - first input array or a scalar.
+
src2 - second input array or a scalar.
+
dst - output array that has the same size and number of channels as the input array(s); the
+ depth is defined by dtype or src1/src2.
+
mask - optional operation mask - 8-bit single channel array, that specifies elements of the
+ output array to be changed.
+ SEE: subtract, addWeighted, scaleAdd, Mat::convertTo
public static void add(Mat src1,
+ Mat src2,
+ Mat dst,
+ Mat mask,
+ int dtype)
+
Calculates the per-element sum of two arrays or an array and a scalar.
+
+ The function add calculates:
+
+
+ Sum of two arrays when both input arrays have the same size and the same number of channels:
+ \(\texttt{dst}(I) = \texttt{saturate} ( \texttt{src1}(I) + \texttt{src2}(I)) \quad \texttt{if mask}(I) \ne0\)
+
+
+ Sum of an array and a scalar when src2 is constructed from Scalar or has the same number of
+ elements as src1.channels():
+ \(\texttt{dst}(I) = \texttt{saturate} ( \texttt{src1}(I) + \texttt{src2} ) \quad \texttt{if mask}(I) \ne0\)
+
+
+ Sum of a scalar and an array when src1 is constructed from Scalar or has the same number of
+ elements as src2.channels():
+ \(\texttt{dst}(I) = \texttt{saturate} ( \texttt{src1} + \texttt{src2}(I) ) \quad \texttt{if mask}(I) \ne0\)
+ where I is a multi-dimensional index of array elements. In case of multi-channel arrays, each
+ channel is processed independently.
+
+
+
+ The first function in the list above can be replaced with matrix expressions:
+
+ dst = src1 + src2;
+ dst += src1; // equivalent to add(dst, src1, dst);
+
+ The input arrays and the output array can all have the same or different depths. For example, you
+ can add a 16-bit unsigned array to a 8-bit signed array and store the sum as a 32-bit
+ floating-point array. Depth of the output array is determined by the dtype parameter. In the second
+ and third cases above, as well as in the first case, when src1.depth() == src2.depth(), dtype can
+ be set to the default -1. In this case, the output array will have the same depth as the input
+ array, be it src1, src2 or both.
+ Note: Saturation is not applied when the output array has the depth CV_32S. You may even get
+ result of an incorrect sign in the case of overflow.
+
+
Parameters:
+
src1 - first input array or a scalar.
+
src2 - second input array or a scalar.
+
dst - output array that has the same size and number of channels as the input array(s); the
+ depth is defined by dtype or src1/src2.
+
mask - optional operation mask - 8-bit single channel array, that specifies elements of the
+ output array to be changed.
+
dtype - optional depth of the output array (see the discussion below).
+ SEE: subtract, addWeighted, scaleAdd, Mat::convertTo
public static void addSamplesDataSearchSubDirectory(java.lang.String subdir)
+
Append samples search data sub directory
+
+ General usage is to add OpenCV modules name (<opencv_contrib>/modules/<name>/samples/data -> <name>/samples/data + modules/<name>/samples/data).
+ Passed subdirectories are used in LIFO order.
public static void addWeighted(Mat src1,
+ double alpha,
+ Mat src2,
+ double beta,
+ double gamma,
+ Mat dst)
+
Calculates the weighted sum of two arrays.
+
+ The function addWeighted calculates the weighted sum of two arrays as follows:
+ \(\texttt{dst} (I)= \texttt{saturate} ( \texttt{src1} (I)* \texttt{alpha} + \texttt{src2} (I)* \texttt{beta} + \texttt{gamma} )\)
+ where I is a multi-dimensional index of array elements. In case of multi-channel arrays, each
+ channel is processed independently.
+ The function can be replaced with a matrix expression:
+
+ dst = src1*alpha + src2*beta + gamma;
+
+ Note: Saturation is not applied when the output array has the depth CV_32S. You may even get
+ result of an incorrect sign in the case of overflow.
+
+
Parameters:
+
src1 - first input array.
+
alpha - weight of the first array elements.
+
src2 - second input array of the same size and channel number as src1.
+
beta - weight of the second array elements.
+
gamma - scalar added to each sum.
+
dst - output array that has the same size and number of channels as the input arrays.
+ can be set to -1, which will be equivalent to src1.depth().
+ SEE: add, subtract, scaleAdd, Mat::convertTo
public static void addWeighted(Mat src1,
+ double alpha,
+ Mat src2,
+ double beta,
+ double gamma,
+ Mat dst,
+ int dtype)
+
Calculates the weighted sum of two arrays.
+
+ The function addWeighted calculates the weighted sum of two arrays as follows:
+ \(\texttt{dst} (I)= \texttt{saturate} ( \texttt{src1} (I)* \texttt{alpha} + \texttt{src2} (I)* \texttt{beta} + \texttt{gamma} )\)
+ where I is a multi-dimensional index of array elements. In case of multi-channel arrays, each
+ channel is processed independently.
+ The function can be replaced with a matrix expression:
+
+ dst = src1*alpha + src2*beta + gamma;
+
+ Note: Saturation is not applied when the output array has the depth CV_32S. You may even get
+ result of an incorrect sign in the case of overflow.
+
+
Parameters:
+
src1 - first input array.
+
alpha - weight of the first array elements.
+
src2 - second input array of the same size and channel number as src1.
+
beta - weight of the second array elements.
+
gamma - scalar added to each sum.
+
dst - output array that has the same size and number of channels as the input arrays.
+
dtype - optional depth of the output array; when both input arrays have the same depth, dtype
+ can be set to -1, which will be equivalent to src1.depth().
+ SEE: add, subtract, scaleAdd, Mat::convertTo
public static void batchDistance(Mat src1,
+ Mat src2,
+ Mat dist,
+ int dtype,
+ Mat nidx,
+ int normType,
+ int K,
+ Mat mask,
+ int update,
+ boolean crosscheck)
+
naive nearest neighbor finder
+
+ see http://en.wikipedia.org/wiki/Nearest_neighbor_search
+ TODO: document
public static void bitwise_and(Mat src1,
+ Mat src2,
+ Mat dst)
+
computes bitwise conjunction of the two arrays (dst = src1 & src2)
+ Calculates the per-element bit-wise conjunction of two arrays or an
+ array and a scalar.
+
+ The function cv::bitwise_and calculates the per-element bit-wise logical conjunction for:
+ Two arrays when src1 and src2 have the same size:
+ \(\texttt{dst} (I) = \texttt{src1} (I) \wedge \texttt{src2} (I) \quad \texttt{if mask} (I) \ne0\)
+ An array and a scalar when src2 is constructed from Scalar or has
+ the same number of elements as src1.channels():
+ \(\texttt{dst} (I) = \texttt{src1} (I) \wedge \texttt{src2} \quad \texttt{if mask} (I) \ne0\)
+ A scalar and an array when src1 is constructed from Scalar or has
+ the same number of elements as src2.channels():
+ \(\texttt{dst} (I) = \texttt{src1} \wedge \texttt{src2} (I) \quad \texttt{if mask} (I) \ne0\)
+ In case of floating-point arrays, their machine-specific bit
+ representations (usually IEEE754-compliant) are used for the operation.
+ In case of multi-channel arrays, each channel is processed
+ independently. In the second and third cases above, the scalar is first
+ converted to the array type.
+
+
Parameters:
+
src1 - first input array or a scalar.
+
src2 - second input array or a scalar.
+
dst - output array that has the same size and type as the input
+ arrays.
+ specifies elements of the output array to be changed.
public static void bitwise_and(Mat src1,
+ Mat src2,
+ Mat dst,
+ Mat mask)
+
computes bitwise conjunction of the two arrays (dst = src1 & src2)
+ Calculates the per-element bit-wise conjunction of two arrays or an
+ array and a scalar.
+
+ The function cv::bitwise_and calculates the per-element bit-wise logical conjunction for:
+ Two arrays when src1 and src2 have the same size:
+ \(\texttt{dst} (I) = \texttt{src1} (I) \wedge \texttt{src2} (I) \quad \texttt{if mask} (I) \ne0\)
+ An array and a scalar when src2 is constructed from Scalar or has
+ the same number of elements as src1.channels():
+ \(\texttt{dst} (I) = \texttt{src1} (I) \wedge \texttt{src2} \quad \texttt{if mask} (I) \ne0\)
+ A scalar and an array when src1 is constructed from Scalar or has
+ the same number of elements as src2.channels():
+ \(\texttt{dst} (I) = \texttt{src1} \wedge \texttt{src2} (I) \quad \texttt{if mask} (I) \ne0\)
+ In case of floating-point arrays, their machine-specific bit
+ representations (usually IEEE754-compliant) are used for the operation.
+ In case of multi-channel arrays, each channel is processed
+ independently. In the second and third cases above, the scalar is first
+ converted to the array type.
+
+
Parameters:
+
src1 - first input array or a scalar.
+
src2 - second input array or a scalar.
+
dst - output array that has the same size and type as the input
+ arrays.
+
mask - optional operation mask, 8-bit single channel array, that
+ specifies elements of the output array to be changed.
public static void bitwise_not(Mat src,
+ Mat dst)
+
Inverts every bit of an array.
+
+ The function cv::bitwise_not calculates per-element bit-wise inversion of the input
+ array:
+ \(\texttt{dst} (I) = \neg \texttt{src} (I)\)
+ In case of a floating-point input array, its machine-specific bit
+ representation (usually IEEE754-compliant) is used for the operation. In
+ case of multi-channel arrays, each channel is processed independently.
+
+
Parameters:
+
src - input array.
+
dst - output array that has the same size and type as the input
+ array.
+ specifies elements of the output array to be changed.
public static void bitwise_not(Mat src,
+ Mat dst,
+ Mat mask)
+
Inverts every bit of an array.
+
+ The function cv::bitwise_not calculates per-element bit-wise inversion of the input
+ array:
+ \(\texttt{dst} (I) = \neg \texttt{src} (I)\)
+ In case of a floating-point input array, its machine-specific bit
+ representation (usually IEEE754-compliant) is used for the operation. In
+ case of multi-channel arrays, each channel is processed independently.
+
+
Parameters:
+
src - input array.
+
dst - output array that has the same size and type as the input
+ array.
+
mask - optional operation mask, 8-bit single channel array, that
+ specifies elements of the output array to be changed.
public static void bitwise_or(Mat src1,
+ Mat src2,
+ Mat dst)
+
Calculates the per-element bit-wise disjunction of two arrays or an
+ array and a scalar.
+
+ The function cv::bitwise_or calculates the per-element bit-wise logical disjunction for:
+ Two arrays when src1 and src2 have the same size:
+ \(\texttt{dst} (I) = \texttt{src1} (I) \vee \texttt{src2} (I) \quad \texttt{if mask} (I) \ne0\)
+ An array and a scalar when src2 is constructed from Scalar or has
+ the same number of elements as src1.channels():
+ \(\texttt{dst} (I) = \texttt{src1} (I) \vee \texttt{src2} \quad \texttt{if mask} (I) \ne0\)
+ A scalar and an array when src1 is constructed from Scalar or has
+ the same number of elements as src2.channels():
+ \(\texttt{dst} (I) = \texttt{src1} \vee \texttt{src2} (I) \quad \texttt{if mask} (I) \ne0\)
+ In case of floating-point arrays, their machine-specific bit
+ representations (usually IEEE754-compliant) are used for the operation.
+ In case of multi-channel arrays, each channel is processed
+ independently. In the second and third cases above, the scalar is first
+ converted to the array type.
+
+
Parameters:
+
src1 - first input array or a scalar.
+
src2 - second input array or a scalar.
+
dst - output array that has the same size and type as the input
+ arrays.
+ specifies elements of the output array to be changed.
public static void bitwise_or(Mat src1,
+ Mat src2,
+ Mat dst,
+ Mat mask)
+
Calculates the per-element bit-wise disjunction of two arrays or an
+ array and a scalar.
+
+ The function cv::bitwise_or calculates the per-element bit-wise logical disjunction for:
+ Two arrays when src1 and src2 have the same size:
+ \(\texttt{dst} (I) = \texttt{src1} (I) \vee \texttt{src2} (I) \quad \texttt{if mask} (I) \ne0\)
+ An array and a scalar when src2 is constructed from Scalar or has
+ the same number of elements as src1.channels():
+ \(\texttt{dst} (I) = \texttt{src1} (I) \vee \texttt{src2} \quad \texttt{if mask} (I) \ne0\)
+ A scalar and an array when src1 is constructed from Scalar or has
+ the same number of elements as src2.channels():
+ \(\texttt{dst} (I) = \texttt{src1} \vee \texttt{src2} (I) \quad \texttt{if mask} (I) \ne0\)
+ In case of floating-point arrays, their machine-specific bit
+ representations (usually IEEE754-compliant) are used for the operation.
+ In case of multi-channel arrays, each channel is processed
+ independently. In the second and third cases above, the scalar is first
+ converted to the array type.
+
+
Parameters:
+
src1 - first input array or a scalar.
+
src2 - second input array or a scalar.
+
dst - output array that has the same size and type as the input
+ arrays.
+
mask - optional operation mask, 8-bit single channel array, that
+ specifies elements of the output array to be changed.
public static void bitwise_xor(Mat src1,
+ Mat src2,
+ Mat dst)
+
Calculates the per-element bit-wise "exclusive or" operation on two
+ arrays or an array and a scalar.
+
+ The function cv::bitwise_xor calculates the per-element bit-wise logical "exclusive-or"
+ operation for:
+ Two arrays when src1 and src2 have the same size:
+ \(\texttt{dst} (I) = \texttt{src1} (I) \oplus \texttt{src2} (I) \quad \texttt{if mask} (I) \ne0\)
+ An array and a scalar when src2 is constructed from Scalar or has
+ the same number of elements as src1.channels():
+ \(\texttt{dst} (I) = \texttt{src1} (I) \oplus \texttt{src2} \quad \texttt{if mask} (I) \ne0\)
+ A scalar and an array when src1 is constructed from Scalar or has
+ the same number of elements as src2.channels():
+ \(\texttt{dst} (I) = \texttt{src1} \oplus \texttt{src2} (I) \quad \texttt{if mask} (I) \ne0\)
+ In case of floating-point arrays, their machine-specific bit
+ representations (usually IEEE754-compliant) are used for the operation.
+ In case of multi-channel arrays, each channel is processed
+ independently. In the 2nd and 3rd cases above, the scalar is first
+ converted to the array type.
+
+
Parameters:
+
src1 - first input array or a scalar.
+
src2 - second input array or a scalar.
+
dst - output array that has the same size and type as the input
+ arrays.
+ specifies elements of the output array to be changed.
public static void bitwise_xor(Mat src1,
+ Mat src2,
+ Mat dst,
+ Mat mask)
+
Calculates the per-element bit-wise "exclusive or" operation on two
+ arrays or an array and a scalar.
+
+ The function cv::bitwise_xor calculates the per-element bit-wise logical "exclusive-or"
+ operation for:
+ Two arrays when src1 and src2 have the same size:
+ \(\texttt{dst} (I) = \texttt{src1} (I) \oplus \texttt{src2} (I) \quad \texttt{if mask} (I) \ne0\)
+ An array and a scalar when src2 is constructed from Scalar or has
+ the same number of elements as src1.channels():
+ \(\texttt{dst} (I) = \texttt{src1} (I) \oplus \texttt{src2} \quad \texttt{if mask} (I) \ne0\)
+ A scalar and an array when src1 is constructed from Scalar or has
+ the same number of elements as src2.channels():
+ \(\texttt{dst} (I) = \texttt{src1} \oplus \texttt{src2} (I) \quad \texttt{if mask} (I) \ne0\)
+ In case of floating-point arrays, their machine-specific bit
+ representations (usually IEEE754-compliant) are used for the operation.
+ In case of multi-channel arrays, each channel is processed
+ independently. In the 2nd and 3rd cases above, the scalar is first
+ converted to the array type.
+
+
Parameters:
+
src1 - first input array or a scalar.
+
src2 - second input array or a scalar.
+
dst - output array that has the same size and type as the input
+ arrays.
+
mask - optional operation mask, 8-bit single channel array, that
+ specifies elements of the output array to be changed.
public static int borderInterpolate(int p,
+ int len,
+ int borderType)
+
Computes the source location of an extrapolated pixel.
+
+ The function computes and returns the coordinate of a donor pixel corresponding to the specified
+ extrapolated pixel when using the specified extrapolation border mode. For example, if you use
+ cv::BORDER_WRAP mode in the horizontal direction, cv::BORDER_REFLECT_101 in the vertical direction and
+ want to compute value of the "virtual" pixel Point(-5, 100) in a floating-point image img , it
+ looks like:
+
+ float val = img.at<float>(borderInterpolate(100, img.rows, cv::BORDER_REFLECT_101),
+ borderInterpolate(-5, img.cols, cv::BORDER_WRAP));
+
+ Normally, the function is not called directly. It is used inside filtering functions and also in
+ copyMakeBorder.
+
+
Parameters:
+
p - 0-based coordinate of the extrapolated pixel along one of the axes, likely <0 or >= len
+
len - Length of the array along the corresponding axis.
+
borderType - Border type, one of the #BorderTypes, except for #BORDER_TRANSPARENT and
+ #BORDER_ISOLATED . When borderType==#BORDER_CONSTANT , the function always returns -1, regardless
+ of p and len.
+
+ SEE: copyMakeBorder
public static void cartToPolar(Mat x,
+ Mat y,
+ Mat magnitude,
+ Mat angle)
+
Calculates the magnitude and angle of 2D vectors.
+
+ The function cv::cartToPolar calculates either the magnitude, angle, or both
+ for every 2D vector (x(I),y(I)):
+ \(\begin{array}{l} \texttt{magnitude} (I)= \sqrt{\texttt{x}(I)^2+\texttt{y}(I)^2} , \\ \texttt{angle} (I)= \texttt{atan2} ( \texttt{y} (I), \texttt{x} (I))[ \cdot180 / \pi ] \end{array}\)
+
+ The angles are calculated with accuracy about 0.3 degrees. For the point
+ (0,0), the angle is set to 0.
+
+
Parameters:
+
x - array of x-coordinates; this must be a single-precision or
+ double-precision floating-point array.
+
y - array of y-coordinates, that must have the same size and same type as x.
+
magnitude - output array of magnitudes of the same size and type as x.
+
angle - output array of angles that has the same size and type as
+ x; the angles are measured in radians (from 0 to 2\*Pi) or in degrees (0 to 360 degrees).
+ in radians (which is by default), or in degrees.
+ SEE: Sobel, Scharr
public static void cartToPolar(Mat x,
+ Mat y,
+ Mat magnitude,
+ Mat angle,
+ boolean angleInDegrees)
+
Calculates the magnitude and angle of 2D vectors.
+
+ The function cv::cartToPolar calculates either the magnitude, angle, or both
+ for every 2D vector (x(I),y(I)):
+ \(\begin{array}{l} \texttt{magnitude} (I)= \sqrt{\texttt{x}(I)^2+\texttt{y}(I)^2} , \\ \texttt{angle} (I)= \texttt{atan2} ( \texttt{y} (I), \texttt{x} (I))[ \cdot180 / \pi ] \end{array}\)
+
+ The angles are calculated with accuracy about 0.3 degrees. For the point
+ (0,0), the angle is set to 0.
+
+
Parameters:
+
x - array of x-coordinates; this must be a single-precision or
+ double-precision floating-point array.
+
y - array of y-coordinates, that must have the same size and same type as x.
+
magnitude - output array of magnitudes of the same size and type as x.
+
angle - output array of angles that has the same size and type as
+ x; the angles are measured in radians (from 0 to 2\*Pi) or in degrees (0 to 360 degrees).
+
angleInDegrees - a flag, indicating whether the angles are measured
+ in radians (which is by default), or in degrees.
+ SEE: Sobel, Scharr
public static boolean checkHardwareSupport(int feature)
+
Returns true if the specified feature is supported by the host hardware.
+
+ The function returns true if the host hardware supports the specified feature. When user calls
+ setUseOptimized(false), the subsequent calls to checkHardwareSupport() will return false until
+ setUseOptimized(true) is called. This way user can dynamically switch on and off the optimized code
+ in OpenCV.
+
+
Parameters:
+
feature - The feature of interest, one of cv::CpuFeatures
Checks every element of an input array for invalid values.
+
+ The function cv::checkRange checks that every array element is neither NaN nor infinite. When minVal >
+
+
+ DBL_MAX and maxVal < DBL_MAX, the function also checks that each value is between minVal and
+ maxVal. In case of multi-channel arrays, each channel is processed independently. If some values
+ are out of range, position of the first outlier is stored in pos (when pos != NULL). Then, the
+ function either returns false (when quiet=true) or throws an exception.
+
+
+
+
Parameters:
+
a - input array.
+ are out of range or they throw an exception.
+ elements.
public static boolean checkRange(Mat a,
+ boolean quiet)
+
Checks every element of an input array for invalid values.
+
+ The function cv::checkRange checks that every array element is neither NaN nor infinite. When minVal >
+
+
+ DBL_MAX and maxVal < DBL_MAX, the function also checks that each value is between minVal and
+ maxVal. In case of multi-channel arrays, each channel is processed independently. If some values
+ are out of range, position of the first outlier is stored in pos (when pos != NULL). Then, the
+ function either returns false (when quiet=true) or throws an exception.
+
+
+
+
Parameters:
+
a - input array.
+
quiet - a flag, indicating whether the functions quietly return false when the array elements
+ are out of range or they throw an exception.
+ elements.
public static boolean checkRange(Mat a,
+ boolean quiet,
+ double minVal)
+
Checks every element of an input array for invalid values.
+
+ The function cv::checkRange checks that every array element is neither NaN nor infinite. When minVal >
+
+
+ DBL_MAX and maxVal < DBL_MAX, the function also checks that each value is between minVal and
+ maxVal. In case of multi-channel arrays, each channel is processed independently. If some values
+ are out of range, position of the first outlier is stored in pos (when pos != NULL). Then, the
+ function either returns false (when quiet=true) or throws an exception.
+
+
+
+
Parameters:
+
a - input array.
+
quiet - a flag, indicating whether the functions quietly return false when the array elements
+ are out of range or they throw an exception.
+ elements.
+
minVal - inclusive lower boundary of valid values range.
public static boolean checkRange(Mat a,
+ boolean quiet,
+ double minVal,
+ double maxVal)
+
Checks every element of an input array for invalid values.
+
+ The function cv::checkRange checks that every array element is neither NaN nor infinite. When minVal >
+
+
+ DBL_MAX and maxVal < DBL_MAX, the function also checks that each value is between minVal and
+ maxVal. In case of multi-channel arrays, each channel is processed independently. If some values
+ are out of range, position of the first outlier is stored in pos (when pos != NULL). Then, the
+ function either returns false (when quiet=true) or throws an exception.
+
+
+
+
Parameters:
+
a - input array.
+
quiet - a flag, indicating whether the functions quietly return false when the array elements
+ are out of range or they throw an exception.
+ elements.
+
minVal - inclusive lower boundary of valid values range.
+
maxVal - exclusive upper boundary of valid values range.
public static void compare(Mat src1,
+ Mat src2,
+ Mat dst,
+ int cmpop)
+
Performs the per-element comparison of two arrays or an array and scalar value.
+
+ The function compares:
+ Elements of two arrays when src1 and src2 have the same size:
+ \(\texttt{dst} (I) = \texttt{src1} (I) \,\texttt{cmpop}\, \texttt{src2} (I)\)
+ Elements of src1 with a scalar src2 when src2 is constructed from
+ Scalar or has a single element:
+ \(\texttt{dst} (I) = \texttt{src1}(I) \,\texttt{cmpop}\, \texttt{src2}\)
+ src1 with elements of src2 when src1 is constructed from Scalar or
+ has a single element:
+ \(\texttt{dst} (I) = \texttt{src1} \,\texttt{cmpop}\, \texttt{src2} (I)\)
+ When the comparison result is true, the corresponding element of output
+ array is set to 255. The comparison operations can be replaced with the
+ equivalent matrix expressions:
+
+ Mat dst1 = src1 >= src2;
+ Mat dst2 = src1 < 8;
+ ...
+
+
+
Parameters:
+
src1 - first input array or a scalar; when it is an array, it must have a single channel.
+
src2 - second input array or a scalar; when it is an array, it must have a single channel.
+
dst - output array of type ref CV_8U that has the same size and the same number of channels as
+ the input arrays.
+
cmpop - a flag, that specifies correspondence between the arrays (cv::CmpTypes)
+ SEE: checkRange, min, max, threshold
Copies the lower or the upper half of a square matrix to its another half.
+
+ The function cv::completeSymm copies the lower or the upper half of a square matrix to
+ its another half. The matrix diagonal remains unchanged:
+
+
+ \(\texttt{m}_{ij}=\texttt{m}_{ji}\) for \(i > j\) if
+ lowerToUpper=false
+
+
+ \(\texttt{m}_{ij}=\texttt{m}_{ji}\) for \(i < j\) if
+ lowerToUpper=true
+
+
+
+
Parameters:
+
m - input-output floating-point square matrix.
+ the upper half. Otherwise, the upper half is copied to the lower half.
+ SEE: flip, transpose
public static void completeSymm(Mat m,
+ boolean lowerToUpper)
+
Copies the lower or the upper half of a square matrix to its another half.
+
+ The function cv::completeSymm copies the lower or the upper half of a square matrix to
+ its another half. The matrix diagonal remains unchanged:
+
+
+ \(\texttt{m}_{ij}=\texttt{m}_{ji}\) for \(i > j\) if
+ lowerToUpper=false
+
+
+ \(\texttt{m}_{ij}=\texttt{m}_{ji}\) for \(i < j\) if
+ lowerToUpper=true
+
+
+
+
Parameters:
+
m - input-output floating-point square matrix.
+
lowerToUpper - operation flag; if true, the lower half is copied to
+ the upper half. Otherwise, the upper half is copied to the lower half.
+ SEE: flip, transpose
public static void convertFp16(Mat src,
+ Mat dst)
+
Converts an array to half precision floating number.
+
+ This function converts FP32 (single precision floating point) from/to FP16 (half precision floating point). CV_16S format is used to represent FP16 data.
+ There are two use modes (src -> dst): CV_32F -> CV_16S and CV_16S -> CV_32F. The input array has to have type of CV_32F or
+ CV_16S to represent the bit depth. If the input array is neither of them, the function will raise an error.
+ The format of half precision floating point is defined in IEEE 754-2008.
public static void convertScaleAbs(Mat src,
+ Mat dst)
+
Scales, calculates absolute values, and converts the result to 8-bit.
+
+ On each element of the input array, the function convertScaleAbs
+ performs three operations sequentially: scaling, taking an absolute
+ value, conversion to an unsigned 8-bit type:
+ \(\texttt{dst} (I)= \texttt{saturate\_cast<uchar>} (| \texttt{src} (I)* \texttt{alpha} + \texttt{beta} |)\)
+ In case of multi-channel arrays, the function processes each channel
+ independently. When the output is not 8-bit, the operation can be
+ emulated by calling the Mat::convertTo method (or by using matrix
+ expressions) and then by calculating an absolute value of the result.
+ For example:
+
+ Mat_<float> A(30,30);
+ randu(A, Scalar(-100), Scalar(100));
+ Mat_<float> B = A*5 + 3;
+ B = abs(B);
+ // Mat_<float> B = abs(A*5+3) will also do the job,
+ // but it will allocate a temporary matrix
+
public static void convertScaleAbs(Mat src,
+ Mat dst,
+ double alpha)
+
Scales, calculates absolute values, and converts the result to 8-bit.
+
+ On each element of the input array, the function convertScaleAbs
+ performs three operations sequentially: scaling, taking an absolute
+ value, conversion to an unsigned 8-bit type:
+ \(\texttt{dst} (I)= \texttt{saturate\_cast<uchar>} (| \texttt{src} (I)* \texttt{alpha} + \texttt{beta} |)\)
+ In case of multi-channel arrays, the function processes each channel
+ independently. When the output is not 8-bit, the operation can be
+ emulated by calling the Mat::convertTo method (or by using matrix
+ expressions) and then by calculating an absolute value of the result.
+ For example:
+
+ Mat_<float> A(30,30);
+ randu(A, Scalar(-100), Scalar(100));
+ Mat_<float> B = A*5 + 3;
+ B = abs(B);
+ // Mat_<float> B = abs(A*5+3) will also do the job,
+ // but it will allocate a temporary matrix
+
public static void convertScaleAbs(Mat src,
+ Mat dst,
+ double alpha,
+ double beta)
+
Scales, calculates absolute values, and converts the result to 8-bit.
+
+ On each element of the input array, the function convertScaleAbs
+ performs three operations sequentially: scaling, taking an absolute
+ value, conversion to an unsigned 8-bit type:
+ \(\texttt{dst} (I)= \texttt{saturate\_cast<uchar>} (| \texttt{src} (I)* \texttt{alpha} + \texttt{beta} |)\)
+ In case of multi-channel arrays, the function processes each channel
+ independently. When the output is not 8-bit, the operation can be
+ emulated by calling the Mat::convertTo method (or by using matrix
+ expressions) and then by calculating an absolute value of the result.
+ For example:
+
+ Mat_<float> A(30,30);
+ randu(A, Scalar(-100), Scalar(100));
+ Mat_<float> B = A*5 + 3;
+ B = abs(B);
+ // Mat_<float> B = abs(A*5+3) will also do the job,
+ // but it will allocate a temporary matrix
+
+
+
Parameters:
+
src - input array.
+
dst - output array.
+
alpha - optional scale factor.
+
beta - optional delta added to the scaled values.
+ SEE: Mat::convertTo, cv::abs(const Mat&)
public static void copyMakeBorder(Mat src,
+ Mat dst,
+ int top,
+ int bottom,
+ int left,
+ int right,
+ int borderType)
+
Forms a border around an image.
+
+ The function copies the source image into the middle of the destination image. The areas to the
+ left, to the right, above and below the copied source image will be filled with extrapolated
+ pixels. This is not what filtering functions based on it do (they extrapolate pixels on-fly), but
+ what other more complex functions, including your own, may do to simplify image boundary handling.
+
+ The function supports the mode when src is already in the middle of dst . In this case, the
+ function does not copy src itself but simply constructs the border, for example:
+
+
+ // let border be the same in all directions
+ int border=2;
+ // constructs a larger image to fit both the image and the border
+ Mat gray_buf(rgb.rows + border*2, rgb.cols + border*2, rgb.depth());
+ // select the middle part of it w/o copying data
+ Mat gray(gray_canvas, Rect(border, border, rgb.cols, rgb.rows));
+ // convert image from RGB to grayscale
+ cvtColor(rgb, gray, COLOR_RGB2GRAY);
+ // form a border in-place
+ copyMakeBorder(gray, gray_buf, border, border,
+ border, border, BORDER_REPLICATE);
+ // now do some custom filtering ...
+ ...
+
+ Note: When the source image is a part (ROI) of a bigger image, the function will try to use the
+ pixels outside of the ROI to form a border. To disable this feature and always do extrapolation, as
+ if src was not a ROI, use borderType | #BORDER_ISOLATED.
+
+
Parameters:
+
src - Source image.
+
dst - Destination image of the same type as src and the size Size(src.cols+left+right,
+ src.rows+top+bottom) .
+
top - the top pixels
+
bottom - the bottom pixels
+
left - the left pixels
+
right - Parameter specifying how many pixels in each direction from the source image rectangle
+ to extrapolate. For example, top=1, bottom=1, left=1, right=1 mean that 1 pixel-wide border needs
+ to be built.
+
borderType - Border type. See borderInterpolate for details.
+
+ SEE: borderInterpolate
public static void copyMakeBorder(Mat src,
+ Mat dst,
+ int top,
+ int bottom,
+ int left,
+ int right,
+ int borderType,
+ Scalar value)
+
Forms a border around an image.
+
+ The function copies the source image into the middle of the destination image. The areas to the
+ left, to the right, above and below the copied source image will be filled with extrapolated
+ pixels. This is not what filtering functions based on it do (they extrapolate pixels on-fly), but
+ what other more complex functions, including your own, may do to simplify image boundary handling.
+
+ The function supports the mode when src is already in the middle of dst . In this case, the
+ function does not copy src itself but simply constructs the border, for example:
+
+
+ // let border be the same in all directions
+ int border=2;
+ // constructs a larger image to fit both the image and the border
+ Mat gray_buf(rgb.rows + border*2, rgb.cols + border*2, rgb.depth());
+ // select the middle part of it w/o copying data
+ Mat gray(gray_canvas, Rect(border, border, rgb.cols, rgb.rows));
+ // convert image from RGB to grayscale
+ cvtColor(rgb, gray, COLOR_RGB2GRAY);
+ // form a border in-place
+ copyMakeBorder(gray, gray_buf, border, border,
+ border, border, BORDER_REPLICATE);
+ // now do some custom filtering ...
+ ...
+
+ Note: When the source image is a part (ROI) of a bigger image, the function will try to use the
+ pixels outside of the ROI to form a border. To disable this feature and always do extrapolation, as
+ if src was not a ROI, use borderType | #BORDER_ISOLATED.
+
+
Parameters:
+
src - Source image.
+
dst - Destination image of the same type as src and the size Size(src.cols+left+right,
+ src.rows+top+bottom) .
+
top - the top pixels
+
bottom - the bottom pixels
+
left - the left pixels
+
right - Parameter specifying how many pixels in each direction from the source image rectangle
+ to extrapolate. For example, top=1, bottom=1, left=1, right=1 mean that 1 pixel-wide border needs
+ to be built.
+
borderType - Border type. See borderInterpolate for details.
+
value - Border value if borderType==BORDER_CONSTANT .
+
+ SEE: borderInterpolate
public static void copyTo(Mat src,
+ Mat dst,
+ Mat mask)
+
This is an overloaded member function, provided for convenience (python)
+ Copies the matrix to another one.
+ When the operation mask is specified, if the Mat::create call shown above reallocates the matrix, the newly allocated matrix is initialized with all zeros before copying the data.
+
+
Parameters:
+
src - source matrix.
+
dst - Destination matrix. If it does not have a proper size or type before the operation, it is
+ reallocated.
+
mask - Operation mask of the same size as \*this. Its non-zero elements indicate which matrix
+ elements need to be copied. The mask has to be of type CV_8U and can have 1 or multiple channels.
Computes the cube root of an argument.
+
+ The function cubeRoot computes \(\sqrt[3]{\texttt{val}}\). Negative arguments are handled correctly.
+ NaN and Inf are not handled. The accuracy approaches the maximum possible accuracy for
+ single-precision data.
Performs a forward or inverse discrete Cosine transform of 1D or 2D array.
+
+ The function cv::dct performs a forward or inverse discrete Cosine transform (DCT) of a 1D or 2D
+ floating-point array:
+
+
+ Forward Cosine transform of a 1D vector of N elements:
+ \(Y = C^{(N)} \cdot X\)
+ where
+ \(C^{(N)}_{jk}= \sqrt{\alpha_j/N} \cos \left ( \frac{\pi(2k+1)j}{2N} \right )\)
+ and
+ \(\alpha_0=1\), \(\alpha_j=2\) for *j > 0*.
+
+
+ Inverse Cosine transform of a 1D vector of N elements:
+ \(X = \left (C^{(N)} \right )^{-1} \cdot Y = \left (C^{(N)} \right )^T \cdot Y\)
+ (since \(C^{(N)}\) is an orthogonal matrix, \(C^{(N)} \cdot \left(C^{(N)}\right)^T = I\) )
+
+
+ Forward 2D Cosine transform of M x N matrix:
+ \(Y = C^{(N)} \cdot X \cdot \left (C^{(N)} \right )^T\)
+
+
+ Inverse 2D Cosine transform of M x N matrix:
+ \(X = \left (C^{(N)} \right )^T \cdot X \cdot C^{(N)}\)
+
+
+
+ The function chooses the mode of operation by looking at the flags and size of the input array:
+
+
+ If (flags & #DCT_INVERSE) == 0 , the function does a forward 1D or 2D transform. Otherwise, it
+ is an inverse 1D or 2D transform.
+
+
+ If (flags & #DCT_ROWS) != 0 , the function performs a 1D transform of each row.
+
+
+ If the array is a single column or a single row, the function performs a 1D transform.
+
+
+ If none of the above is true, the function performs a 2D transform.
+
+
+
+ Note: Currently dct supports even-size arrays (2, 4, 6 ...). For data analysis and approximation, you
+ can pad the array when necessary.
+ Also, the function performance depends very much, and not monotonically, on the array size (see
+ getOptimalDFTSize ). In the current implementation DCT of a vector of size N is calculated via DFT
+ of a vector of size N/2 . Thus, the optimal DCT size N1 >= N can be calculated as:
+
+ size_t getOptimalDCTSize(size_t N) { return 2*getOptimalDFTSize((N+1)/2); }
+ N1 = getOptimalDCTSize(N);
+
+
+
Parameters:
+
src - input floating-point array.
+
dst - output array of the same size and type as src .
+ SEE: dft , getOptimalDFTSize , idct
public static void dct(Mat src,
+ Mat dst,
+ int flags)
+
Performs a forward or inverse discrete Cosine transform of 1D or 2D array.
+
+ The function cv::dct performs a forward or inverse discrete Cosine transform (DCT) of a 1D or 2D
+ floating-point array:
+
+
+ Forward Cosine transform of a 1D vector of N elements:
+ \(Y = C^{(N)} \cdot X\)
+ where
+ \(C^{(N)}_{jk}= \sqrt{\alpha_j/N} \cos \left ( \frac{\pi(2k+1)j}{2N} \right )\)
+ and
+ \(\alpha_0=1\), \(\alpha_j=2\) for *j > 0*.
+
+
+ Inverse Cosine transform of a 1D vector of N elements:
+ \(X = \left (C^{(N)} \right )^{-1} \cdot Y = \left (C^{(N)} \right )^T \cdot Y\)
+ (since \(C^{(N)}\) is an orthogonal matrix, \(C^{(N)} \cdot \left(C^{(N)}\right)^T = I\) )
+
+
+ Forward 2D Cosine transform of M x N matrix:
+ \(Y = C^{(N)} \cdot X \cdot \left (C^{(N)} \right )^T\)
+
+
+ Inverse 2D Cosine transform of M x N matrix:
+ \(X = \left (C^{(N)} \right )^T \cdot X \cdot C^{(N)}\)
+
+
+
+ The function chooses the mode of operation by looking at the flags and size of the input array:
+
+
+ If (flags & #DCT_INVERSE) == 0 , the function does a forward 1D or 2D transform. Otherwise, it
+ is an inverse 1D or 2D transform.
+
+
+ If (flags & #DCT_ROWS) != 0 , the function performs a 1D transform of each row.
+
+
+ If the array is a single column or a single row, the function performs a 1D transform.
+
+
+ If none of the above is true, the function performs a 2D transform.
+
+
+
+ Note: Currently dct supports even-size arrays (2, 4, 6 ...). For data analysis and approximation, you
+ can pad the array when necessary.
+ Also, the function performance depends very much, and not monotonically, on the array size (see
+ getOptimalDFTSize ). In the current implementation DCT of a vector of size N is calculated via DFT
+ of a vector of size N/2 . Thus, the optimal DCT size N1 >= N can be calculated as:
+
+ size_t getOptimalDCTSize(size_t N) { return 2*getOptimalDFTSize((N+1)/2); }
+ N1 = getOptimalDCTSize(N);
+
+
+
Parameters:
+
src - input floating-point array.
+
dst - output array of the same size and type as src .
+
flags - transformation flags as a combination of cv::DftFlags (DCT_*)
+ SEE: dft , getOptimalDFTSize , idct
Returns the determinant of a square floating-point matrix.
+
+ The function cv::determinant calculates and returns the determinant of the
+ specified matrix. For small matrices ( mtx.cols=mtx.rows<=3 ), the
+ direct method is used. For larger matrices, the function uses LU
+ factorization with partial pivoting.
+
+ For symmetric positively-determined matrices, it is also possible to use
+ eigen decomposition to calculate the determinant.
+
+
Parameters:
+
mtx - input matrix that must have CV_32FC1 or CV_64FC1 type and
+ square size.
+ SEE: trace, invert, solve, eigen, REF: MatrixExpressions
Performs a forward or inverse Discrete Fourier transform of a 1D or 2D floating-point array.
+
+ The function cv::dft performs one of the following:
+
+
+ Forward the Fourier transform of a 1D vector of N elements:
+ \(Y = F^{(N)} \cdot X,\)
+ where \(F^{(N)}_{jk}=\exp(-2\pi i j k/N)\) and \(i=\sqrt{-1}\)
+
+
+ Inverse the Fourier transform of a 1D vector of N elements:
+ \(\begin{array}{l} X'= \left (F^{(N)} \right )^{-1} \cdot Y = \left (F^{(N)} \right )^* \cdot y \\ X = (1/N) \cdot X, \end{array}\)
+ where \(F^*=\left(\textrm{Re}(F^{(N)})-\textrm{Im}(F^{(N)})\right)^T\)
+
+
+ Forward the 2D Fourier transform of a M x N matrix:
+ \(Y = F^{(M)} \cdot X \cdot F^{(N)}\)
+
+
+ Inverse the 2D Fourier transform of a M x N matrix:
+ \(\begin{array}{l} X'= \left (F^{(M)} \right )^* \cdot Y \cdot \left (F^{(N)} \right )^* \\ X = \frac{1}{M \cdot N} \cdot X' \end{array}\)
+
+
+
+ In case of real (single-channel) data, the output spectrum of the forward Fourier transform or input
+ spectrum of the inverse Fourier transform can be represented in a packed format called *CCS*
+ (complex-conjugate-symmetrical). It was borrowed from IPL (Intel\* Image Processing Library). Here
+ is how 2D *CCS* spectrum looks:
+ \(\begin{bmatrix} Re Y_{0,0} & Re Y_{0,1} & Im Y_{0,1} & Re Y_{0,2} & Im Y_{0,2} & \cdots & Re Y_{0,N/2-1} & Im Y_{0,N/2-1} & Re Y_{0,N/2} \\ Re Y_{1,0} & Re Y_{1,1} & Im Y_{1,1} & Re Y_{1,2} & Im Y_{1,2} & \cdots & Re Y_{1,N/2-1} & Im Y_{1,N/2-1} & Re Y_{1,N/2} \\ Im Y_{1,0} & Re Y_{2,1} & Im Y_{2,1} & Re Y_{2,2} & Im Y_{2,2} & \cdots & Re Y_{2,N/2-1} & Im Y_{2,N/2-1} & Im Y_{1,N/2} \\ \hdotsfor{9} \\ Re Y_{M/2-1,0} & Re Y_{M-3,1} & Im Y_{M-3,1} & \hdotsfor{3} & Re Y_{M-3,N/2-1} & Im Y_{M-3,N/2-1}& Re Y_{M/2-1,N/2} \\ Im Y_{M/2-1,0} & Re Y_{M-2,1} & Im Y_{M-2,1} & \hdotsfor{3} & Re Y_{M-2,N/2-1} & Im Y_{M-2,N/2-1}& Im Y_{M/2-1,N/2} \\ Re Y_{M/2,0} & Re Y_{M-1,1} & Im Y_{M-1,1} & \hdotsfor{3} & Re Y_{M-1,N/2-1} & Im Y_{M-1,N/2-1}& Re Y_{M/2,N/2} \end{bmatrix}\)
+
+ In case of 1D transform of a real vector, the output looks like the first row of the matrix above.
+
+ So, the function chooses an operation mode depending on the flags and size of the input array:
+
+
+ If #DFT_ROWS is set or the input array has a single row or single column, the function
+ performs a 1D forward or inverse transform of each row of a matrix when #DFT_ROWS is set.
+ Otherwise, it performs a 2D transform.
+
+
+ If the input array is real and #DFT_INVERSE is not set, the function performs a forward 1D or
+ 2D transform:
+
+
+ When #DFT_COMPLEX_OUTPUT is set, the output is a complex matrix of the same size as
+ input.
+
+
+ When #DFT_COMPLEX_OUTPUT is not set, the output is a real matrix of the same size as
+ input. In case of 2D transform, it uses the packed format as shown above. In case of a
+ single 1D transform, it looks like the first row of the matrix above. In case of
+ multiple 1D transforms (when using the #DFT_ROWS flag), each row of the output matrix
+ looks like the first row of the matrix above.
+
+
+
+ If the input array is complex and either #DFT_INVERSE or #DFT_REAL_OUTPUT are not set, the
+ output is a complex array of the same size as input. The function performs a forward or
+ inverse 1D or 2D transform of the whole input array or each row of the input array
+ independently, depending on the flags DFT_INVERSE and DFT_ROWS.
+
+
+ When #DFT_INVERSE is set and the input array is real, or it is complex but #DFT_REAL_OUTPUT
+ is set, the output is a real array of the same size as input. The function performs a 1D or 2D
+ inverse transformation of the whole input array or each individual row, depending on the flags
+ #DFT_INVERSE and #DFT_ROWS.
+
+
+
+ If #DFT_SCALE is set, the scaling is done after the transformation.
+
+ Unlike dct , the function supports arrays of arbitrary size. But only those arrays are processed
+ efficiently, whose sizes can be factorized in a product of small prime numbers (2, 3, and 5 in the
+ current implementation). Such an efficient DFT size can be calculated using the getOptimalDFTSize
+ method.
+
+ The sample below illustrates how to calculate a DFT-based convolution of two 2D real arrays:
+
+ void convolveDFT(InputArray A, InputArray B, OutputArray C)
+ {
+ // reallocate the output array if needed
+ C.create(abs(A.rows - B.rows)+1, abs(A.cols - B.cols)+1, A.type());
+ Size dftSize;
+ // calculate the size of DFT transform
+ dftSize.width = getOptimalDFTSize(A.cols + B.cols - 1);
+ dftSize.height = getOptimalDFTSize(A.rows + B.rows - 1);
+
+ // allocate temporary buffers and initialize them with 0's
+ Mat tempA(dftSize, A.type(), Scalar::all(0));
+ Mat tempB(dftSize, B.type(), Scalar::all(0));
+
+ // copy A and B to the top-left corners of tempA and tempB, respectively
+ Mat roiA(tempA, Rect(0,0,A.cols,A.rows));
+ A.copyTo(roiA);
+ Mat roiB(tempB, Rect(0,0,B.cols,B.rows));
+ B.copyTo(roiB);
+
+ // now transform the padded A & B in-place;
+ // use "nonzeroRows" hint for faster processing
+ dft(tempA, tempA, 0, A.rows);
+ dft(tempB, tempB, 0, B.rows);
+
+ // multiply the spectrums;
+ // the function handles packed spectrum representations well
+ mulSpectrums(tempA, tempB, tempA);
+
+ // transform the product back from the frequency domain.
+ // Even though all the result rows will be non-zero,
+ // you need only the first C.rows of them, and thus you
+ // pass nonzeroRows == C.rows
+ dft(tempA, tempA, DFT_INVERSE + DFT_SCALE, C.rows);
+
+ // now copy the result back to C.
+ tempA(Rect(0, 0, C.cols, C.rows)).copyTo(C);
+
+ // all the temporary buffers will be deallocated automatically
+ }
+
+ To optimize this sample, consider the following approaches:
+
+
+ Since nonzeroRows != 0 is passed to the forward transform calls and since A and B are copied to
+ the top-left corners of tempA and tempB, respectively, it is not necessary to clear the whole
+ tempA and tempB. It is only necessary to clear the tempA.cols - A.cols ( tempB.cols - B.cols)
+ rightmost columns of the matrices.
+
+
+ This DFT-based convolution does not have to be applied to the whole big arrays, especially if B
+ is significantly smaller than A or vice versa. Instead, you can calculate convolution by parts.
+ To do this, you need to split the output array C into multiple tiles. For each tile, estimate
+ which parts of A and B are required to calculate convolution in this tile. If the tiles in C are
+ too small, the speed will decrease a lot because of repeated work. In the ultimate case, when
+ each tile in C is a single pixel, the algorithm becomes equivalent to the naive convolution
+ algorithm. If the tiles are too big, the temporary arrays tempA and tempB become too big and
+ there is also a slowdown because of bad cache locality. So, there is an optimal tile size
+ somewhere in the middle.
+
+
+ If different tiles in C can be calculated in parallel and, thus, the convolution is done by
+ parts, the loop can be threaded.
+
+
+
+ All of the above improvements have been implemented in #matchTemplate and #filter2D . Therefore, by
+ using them, you can get the performance even better than with the above theoretically optimal
+ implementation. Though, those two functions actually calculate cross-correlation, not convolution,
+ so you need to "flip" the second convolution operand B vertically and horizontally using flip .
+ Note:
+
+
+ An example using the discrete fourier transform can be found at
+ opencv_source_code/samples/cpp/dft.cpp
+
+
+ (Python) An example using the dft functionality to perform Wiener deconvolution can be found
+ at opencv_source/samples/python/deconvolution.py
+
+
+ (Python) An example rearranging the quadrants of a Fourier image can be found at
+ opencv_source/samples/python/dft.py
+
+
+
+
Parameters:
+
src - input array that could be real or complex.
+
dst - output array whose size and type depends on the flags .
+ nonzeroRows rows of the input array (#DFT_INVERSE is not set) or only the first nonzeroRows of the
+ output array (#DFT_INVERSE is set) contain non-zeros, thus, the function can handle the rest of the
+ rows more efficiently and save some time; this technique is very useful for calculating array
+ cross-correlation or convolution using DFT.
+ SEE: dct , getOptimalDFTSize , mulSpectrums, filter2D , matchTemplate , flip , cartToPolar ,
+ magnitude , phase
public static void dft(Mat src,
+ Mat dst,
+ int flags)
+
Performs a forward or inverse Discrete Fourier transform of a 1D or 2D floating-point array.
+
+ The function cv::dft performs one of the following:
+
+
+ Forward the Fourier transform of a 1D vector of N elements:
+ \(Y = F^{(N)} \cdot X,\)
+ where \(F^{(N)}_{jk}=\exp(-2\pi i j k/N)\) and \(i=\sqrt{-1}\)
+
+
+ Inverse the Fourier transform of a 1D vector of N elements:
+ \(\begin{array}{l} X'= \left (F^{(N)} \right )^{-1} \cdot Y = \left (F^{(N)} \right )^* \cdot y \\ X = (1/N) \cdot X, \end{array}\)
+ where \(F^*=\left(\textrm{Re}(F^{(N)})-\textrm{Im}(F^{(N)})\right)^T\)
+
+
+ Forward the 2D Fourier transform of a M x N matrix:
+ \(Y = F^{(M)} \cdot X \cdot F^{(N)}\)
+
+
+ Inverse the 2D Fourier transform of a M x N matrix:
+ \(\begin{array}{l} X'= \left (F^{(M)} \right )^* \cdot Y \cdot \left (F^{(N)} \right )^* \\ X = \frac{1}{M \cdot N} \cdot X' \end{array}\)
+
+
+
+ In case of real (single-channel) data, the output spectrum of the forward Fourier transform or input
+ spectrum of the inverse Fourier transform can be represented in a packed format called *CCS*
+ (complex-conjugate-symmetrical). It was borrowed from IPL (Intel\* Image Processing Library). Here
+ is how 2D *CCS* spectrum looks:
+ \(\begin{bmatrix} Re Y_{0,0} & Re Y_{0,1} & Im Y_{0,1} & Re Y_{0,2} & Im Y_{0,2} & \cdots & Re Y_{0,N/2-1} & Im Y_{0,N/2-1} & Re Y_{0,N/2} \\ Re Y_{1,0} & Re Y_{1,1} & Im Y_{1,1} & Re Y_{1,2} & Im Y_{1,2} & \cdots & Re Y_{1,N/2-1} & Im Y_{1,N/2-1} & Re Y_{1,N/2} \\ Im Y_{1,0} & Re Y_{2,1} & Im Y_{2,1} & Re Y_{2,2} & Im Y_{2,2} & \cdots & Re Y_{2,N/2-1} & Im Y_{2,N/2-1} & Im Y_{1,N/2} \\ \hdotsfor{9} \\ Re Y_{M/2-1,0} & Re Y_{M-3,1} & Im Y_{M-3,1} & \hdotsfor{3} & Re Y_{M-3,N/2-1} & Im Y_{M-3,N/2-1}& Re Y_{M/2-1,N/2} \\ Im Y_{M/2-1,0} & Re Y_{M-2,1} & Im Y_{M-2,1} & \hdotsfor{3} & Re Y_{M-2,N/2-1} & Im Y_{M-2,N/2-1}& Im Y_{M/2-1,N/2} \\ Re Y_{M/2,0} & Re Y_{M-1,1} & Im Y_{M-1,1} & \hdotsfor{3} & Re Y_{M-1,N/2-1} & Im Y_{M-1,N/2-1}& Re Y_{M/2,N/2} \end{bmatrix}\)
+
+ In case of 1D transform of a real vector, the output looks like the first row of the matrix above.
+
+ So, the function chooses an operation mode depending on the flags and size of the input array:
+
+
+ If #DFT_ROWS is set or the input array has a single row or single column, the function
+ performs a 1D forward or inverse transform of each row of a matrix when #DFT_ROWS is set.
+ Otherwise, it performs a 2D transform.
+
+
+ If the input array is real and #DFT_INVERSE is not set, the function performs a forward 1D or
+ 2D transform:
+
+
+ When #DFT_COMPLEX_OUTPUT is set, the output is a complex matrix of the same size as
+ input.
+
+
+ When #DFT_COMPLEX_OUTPUT is not set, the output is a real matrix of the same size as
+ input. In case of 2D transform, it uses the packed format as shown above. In case of a
+ single 1D transform, it looks like the first row of the matrix above. In case of
+ multiple 1D transforms (when using the #DFT_ROWS flag), each row of the output matrix
+ looks like the first row of the matrix above.
+
+
+
+ If the input array is complex and either #DFT_INVERSE or #DFT_REAL_OUTPUT are not set, the
+ output is a complex array of the same size as input. The function performs a forward or
+ inverse 1D or 2D transform of the whole input array or each row of the input array
+ independently, depending on the flags DFT_INVERSE and DFT_ROWS.
+
+
+ When #DFT_INVERSE is set and the input array is real, or it is complex but #DFT_REAL_OUTPUT
+ is set, the output is a real array of the same size as input. The function performs a 1D or 2D
+ inverse transformation of the whole input array or each individual row, depending on the flags
+ #DFT_INVERSE and #DFT_ROWS.
+
+
+
+ If #DFT_SCALE is set, the scaling is done after the transformation.
+
+ Unlike dct , the function supports arrays of arbitrary size. But only those arrays are processed
+ efficiently, whose sizes can be factorized in a product of small prime numbers (2, 3, and 5 in the
+ current implementation). Such an efficient DFT size can be calculated using the getOptimalDFTSize
+ method.
+
+ The sample below illustrates how to calculate a DFT-based convolution of two 2D real arrays:
+
+ void convolveDFT(InputArray A, InputArray B, OutputArray C)
+ {
+ // reallocate the output array if needed
+ C.create(abs(A.rows - B.rows)+1, abs(A.cols - B.cols)+1, A.type());
+ Size dftSize;
+ // calculate the size of DFT transform
+ dftSize.width = getOptimalDFTSize(A.cols + B.cols - 1);
+ dftSize.height = getOptimalDFTSize(A.rows + B.rows - 1);
+
+ // allocate temporary buffers and initialize them with 0's
+ Mat tempA(dftSize, A.type(), Scalar::all(0));
+ Mat tempB(dftSize, B.type(), Scalar::all(0));
+
+ // copy A and B to the top-left corners of tempA and tempB, respectively
+ Mat roiA(tempA, Rect(0,0,A.cols,A.rows));
+ A.copyTo(roiA);
+ Mat roiB(tempB, Rect(0,0,B.cols,B.rows));
+ B.copyTo(roiB);
+
+ // now transform the padded A & B in-place;
+ // use "nonzeroRows" hint for faster processing
+ dft(tempA, tempA, 0, A.rows);
+ dft(tempB, tempB, 0, B.rows);
+
+ // multiply the spectrums;
+ // the function handles packed spectrum representations well
+ mulSpectrums(tempA, tempB, tempA);
+
+ // transform the product back from the frequency domain.
+ // Even though all the result rows will be non-zero,
+ // you need only the first C.rows of them, and thus you
+ // pass nonzeroRows == C.rows
+ dft(tempA, tempA, DFT_INVERSE + DFT_SCALE, C.rows);
+
+ // now copy the result back to C.
+ tempA(Rect(0, 0, C.cols, C.rows)).copyTo(C);
+
+ // all the temporary buffers will be deallocated automatically
+ }
+
+ To optimize this sample, consider the following approaches:
+
+
+ Since nonzeroRows != 0 is passed to the forward transform calls and since A and B are copied to
+ the top-left corners of tempA and tempB, respectively, it is not necessary to clear the whole
+ tempA and tempB. It is only necessary to clear the tempA.cols - A.cols ( tempB.cols - B.cols)
+ rightmost columns of the matrices.
+
+
+ This DFT-based convolution does not have to be applied to the whole big arrays, especially if B
+ is significantly smaller than A or vice versa. Instead, you can calculate convolution by parts.
+ To do this, you need to split the output array C into multiple tiles. For each tile, estimate
+ which parts of A and B are required to calculate convolution in this tile. If the tiles in C are
+ too small, the speed will decrease a lot because of repeated work. In the ultimate case, when
+ each tile in C is a single pixel, the algorithm becomes equivalent to the naive convolution
+ algorithm. If the tiles are too big, the temporary arrays tempA and tempB become too big and
+ there is also a slowdown because of bad cache locality. So, there is an optimal tile size
+ somewhere in the middle.
+
+
+ If different tiles in C can be calculated in parallel and, thus, the convolution is done by
+ parts, the loop can be threaded.
+
+
+
+ All of the above improvements have been implemented in #matchTemplate and #filter2D . Therefore, by
+ using them, you can get the performance even better than with the above theoretically optimal
+ implementation. Though, those two functions actually calculate cross-correlation, not convolution,
+ so you need to "flip" the second convolution operand B vertically and horizontally using flip .
+ Note:
+
+
+ An example using the discrete fourier transform can be found at
+ opencv_source_code/samples/cpp/dft.cpp
+
+
+ (Python) An example using the dft functionality to perform Wiener deconvolution can be found
+ at opencv_source/samples/python/deconvolution.py
+
+
+ (Python) An example rearranging the quadrants of a Fourier image can be found at
+ opencv_source/samples/python/dft.py
+
+
+
+
Parameters:
+
src - input array that could be real or complex.
+
dst - output array whose size and type depends on the flags .
+
flags - transformation flags, representing a combination of the #DftFlags
+ nonzeroRows rows of the input array (#DFT_INVERSE is not set) or only the first nonzeroRows of the
+ output array (#DFT_INVERSE is set) contain non-zeros, thus, the function can handle the rest of the
+ rows more efficiently and save some time; this technique is very useful for calculating array
+ cross-correlation or convolution using DFT.
+ SEE: dct , getOptimalDFTSize , mulSpectrums, filter2D , matchTemplate , flip , cartToPolar ,
+ magnitude , phase
public static void dft(Mat src,
+ Mat dst,
+ int flags,
+ int nonzeroRows)
+
Performs a forward or inverse Discrete Fourier transform of a 1D or 2D floating-point array.
+
+ The function cv::dft performs one of the following:
+
+
+ Forward the Fourier transform of a 1D vector of N elements:
+ \(Y = F^{(N)} \cdot X,\)
+ where \(F^{(N)}_{jk}=\exp(-2\pi i j k/N)\) and \(i=\sqrt{-1}\)
+
+
+ Inverse the Fourier transform of a 1D vector of N elements:
+ \(\begin{array}{l} X'= \left (F^{(N)} \right )^{-1} \cdot Y = \left (F^{(N)} \right )^* \cdot y \\ X = (1/N) \cdot X, \end{array}\)
+ where \(F^*=\left(\textrm{Re}(F^{(N)})-\textrm{Im}(F^{(N)})\right)^T\)
+
+
+ Forward the 2D Fourier transform of a M x N matrix:
+ \(Y = F^{(M)} \cdot X \cdot F^{(N)}\)
+
+
+ Inverse the 2D Fourier transform of a M x N matrix:
+ \(\begin{array}{l} X'= \left (F^{(M)} \right )^* \cdot Y \cdot \left (F^{(N)} \right )^* \\ X = \frac{1}{M \cdot N} \cdot X' \end{array}\)
+
+
+
+ In case of real (single-channel) data, the output spectrum of the forward Fourier transform or input
+ spectrum of the inverse Fourier transform can be represented in a packed format called *CCS*
+ (complex-conjugate-symmetrical). It was borrowed from IPL (Intel\* Image Processing Library). Here
+ is how 2D *CCS* spectrum looks:
+ \(\begin{bmatrix} Re Y_{0,0} & Re Y_{0,1} & Im Y_{0,1} & Re Y_{0,2} & Im Y_{0,2} & \cdots & Re Y_{0,N/2-1} & Im Y_{0,N/2-1} & Re Y_{0,N/2} \\ Re Y_{1,0} & Re Y_{1,1} & Im Y_{1,1} & Re Y_{1,2} & Im Y_{1,2} & \cdots & Re Y_{1,N/2-1} & Im Y_{1,N/2-1} & Re Y_{1,N/2} \\ Im Y_{1,0} & Re Y_{2,1} & Im Y_{2,1} & Re Y_{2,2} & Im Y_{2,2} & \cdots & Re Y_{2,N/2-1} & Im Y_{2,N/2-1} & Im Y_{1,N/2} \\ \hdotsfor{9} \\ Re Y_{M/2-1,0} & Re Y_{M-3,1} & Im Y_{M-3,1} & \hdotsfor{3} & Re Y_{M-3,N/2-1} & Im Y_{M-3,N/2-1}& Re Y_{M/2-1,N/2} \\ Im Y_{M/2-1,0} & Re Y_{M-2,1} & Im Y_{M-2,1} & \hdotsfor{3} & Re Y_{M-2,N/2-1} & Im Y_{M-2,N/2-1}& Im Y_{M/2-1,N/2} \\ Re Y_{M/2,0} & Re Y_{M-1,1} & Im Y_{M-1,1} & \hdotsfor{3} & Re Y_{M-1,N/2-1} & Im Y_{M-1,N/2-1}& Re Y_{M/2,N/2} \end{bmatrix}\)
+
+ In case of 1D transform of a real vector, the output looks like the first row of the matrix above.
+
+ So, the function chooses an operation mode depending on the flags and size of the input array:
+
+
+ If #DFT_ROWS is set or the input array has a single row or single column, the function
+ performs a 1D forward or inverse transform of each row of a matrix when #DFT_ROWS is set.
+ Otherwise, it performs a 2D transform.
+
+
+ If the input array is real and #DFT_INVERSE is not set, the function performs a forward 1D or
+ 2D transform:
+
+
+ When #DFT_COMPLEX_OUTPUT is set, the output is a complex matrix of the same size as
+ input.
+
+
+ When #DFT_COMPLEX_OUTPUT is not set, the output is a real matrix of the same size as
+ input. In case of 2D transform, it uses the packed format as shown above. In case of a
+ single 1D transform, it looks like the first row of the matrix above. In case of
+ multiple 1D transforms (when using the #DFT_ROWS flag), each row of the output matrix
+ looks like the first row of the matrix above.
+
+
+
+ If the input array is complex and either #DFT_INVERSE or #DFT_REAL_OUTPUT are not set, the
+ output is a complex array of the same size as input. The function performs a forward or
+ inverse 1D or 2D transform of the whole input array or each row of the input array
+ independently, depending on the flags DFT_INVERSE and DFT_ROWS.
+
+
+ When #DFT_INVERSE is set and the input array is real, or it is complex but #DFT_REAL_OUTPUT
+ is set, the output is a real array of the same size as input. The function performs a 1D or 2D
+ inverse transformation of the whole input array or each individual row, depending on the flags
+ #DFT_INVERSE and #DFT_ROWS.
+
+
+
+ If #DFT_SCALE is set, the scaling is done after the transformation.
+
+ Unlike dct , the function supports arrays of arbitrary size. But only those arrays are processed
+ efficiently, whose sizes can be factorized in a product of small prime numbers (2, 3, and 5 in the
+ current implementation). Such an efficient DFT size can be calculated using the getOptimalDFTSize
+ method.
+
+ The sample below illustrates how to calculate a DFT-based convolution of two 2D real arrays:
+
+ void convolveDFT(InputArray A, InputArray B, OutputArray C)
+ {
+ // reallocate the output array if needed
+ C.create(abs(A.rows - B.rows)+1, abs(A.cols - B.cols)+1, A.type());
+ Size dftSize;
+ // calculate the size of DFT transform
+ dftSize.width = getOptimalDFTSize(A.cols + B.cols - 1);
+ dftSize.height = getOptimalDFTSize(A.rows + B.rows - 1);
+
+ // allocate temporary buffers and initialize them with 0's
+ Mat tempA(dftSize, A.type(), Scalar::all(0));
+ Mat tempB(dftSize, B.type(), Scalar::all(0));
+
+ // copy A and B to the top-left corners of tempA and tempB, respectively
+ Mat roiA(tempA, Rect(0,0,A.cols,A.rows));
+ A.copyTo(roiA);
+ Mat roiB(tempB, Rect(0,0,B.cols,B.rows));
+ B.copyTo(roiB);
+
+ // now transform the padded A & B in-place;
+ // use "nonzeroRows" hint for faster processing
+ dft(tempA, tempA, 0, A.rows);
+ dft(tempB, tempB, 0, B.rows);
+
+ // multiply the spectrums;
+ // the function handles packed spectrum representations well
+ mulSpectrums(tempA, tempB, tempA);
+
+ // transform the product back from the frequency domain.
+ // Even though all the result rows will be non-zero,
+ // you need only the first C.rows of them, and thus you
+ // pass nonzeroRows == C.rows
+ dft(tempA, tempA, DFT_INVERSE + DFT_SCALE, C.rows);
+
+ // now copy the result back to C.
+ tempA(Rect(0, 0, C.cols, C.rows)).copyTo(C);
+
+ // all the temporary buffers will be deallocated automatically
+ }
+
+ To optimize this sample, consider the following approaches:
+
+
+ Since nonzeroRows != 0 is passed to the forward transform calls and since A and B are copied to
+ the top-left corners of tempA and tempB, respectively, it is not necessary to clear the whole
+ tempA and tempB. It is only necessary to clear the tempA.cols - A.cols ( tempB.cols - B.cols)
+ rightmost columns of the matrices.
+
+
+ This DFT-based convolution does not have to be applied to the whole big arrays, especially if B
+ is significantly smaller than A or vice versa. Instead, you can calculate convolution by parts.
+ To do this, you need to split the output array C into multiple tiles. For each tile, estimate
+ which parts of A and B are required to calculate convolution in this tile. If the tiles in C are
+ too small, the speed will decrease a lot because of repeated work. In the ultimate case, when
+ each tile in C is a single pixel, the algorithm becomes equivalent to the naive convolution
+ algorithm. If the tiles are too big, the temporary arrays tempA and tempB become too big and
+ there is also a slowdown because of bad cache locality. So, there is an optimal tile size
+ somewhere in the middle.
+
+
+ If different tiles in C can be calculated in parallel and, thus, the convolution is done by
+ parts, the loop can be threaded.
+
+
+
+ All of the above improvements have been implemented in #matchTemplate and #filter2D . Therefore, by
+ using them, you can get the performance even better than with the above theoretically optimal
+ implementation. Though, those two functions actually calculate cross-correlation, not convolution,
+ so you need to "flip" the second convolution operand B vertically and horizontally using flip .
+ Note:
+
+
+ An example using the discrete fourier transform can be found at
+ opencv_source_code/samples/cpp/dft.cpp
+
+
+ (Python) An example using the dft functionality to perform Wiener deconvolution can be found
+ at opencv_source/samples/python/deconvolution.py
+
+
+ (Python) An example rearranging the quadrants of a Fourier image can be found at
+ opencv_source/samples/python/dft.py
+
+
+
+
Parameters:
+
src - input array that could be real or complex.
+
dst - output array whose size and type depends on the flags .
+
flags - transformation flags, representing a combination of the #DftFlags
+
nonzeroRows - when the parameter is not zero, the function assumes that only the first
+ nonzeroRows rows of the input array (#DFT_INVERSE is not set) or only the first nonzeroRows of the
+ output array (#DFT_INVERSE is set) contain non-zeros, thus, the function can handle the rest of the
+ rows more efficiently and save some time; this technique is very useful for calculating array
+ cross-correlation or convolution using DFT.
+ SEE: dct , getOptimalDFTSize , mulSpectrums, filter2D , matchTemplate , flip , cartToPolar ,
+ magnitude , phase
public static void divide(Mat src1,
+ Mat src2,
+ Mat dst)
+
Performs per-element division of two arrays or a scalar by an array.
+
+ The function cv::divide divides one array by another:
+ \(\texttt{dst(I) = saturate(src1(I)*scale/src2(I))}\)
+ or a scalar by an array when there is no src1 :
+ \(\texttt{dst(I) = saturate(scale/src2(I))}\)
+
+ Different channels of multi-channel arrays are processed independently.
+
+ For integer types when src2(I) is zero, dst(I) will also be zero.
+
+ Note: In case of floating point data there is no special defined behavior for zero src2(I) values.
+ Regular floating-point division is used.
+ Expect correct IEEE-754 behaviour for floating-point data (with NaN, Inf result values).
+
+ Note: Saturation is not applied when the output array has the depth CV_32S. You may even get
+ result of an incorrect sign in the case of overflow.
+
+
Parameters:
+
src1 - first input array.
+
src2 - second input array of the same size and type as src1.
+
dst - output array of the same size and type as src2.
+ case of an array-by-array division, you can only pass -1 when src1.depth()==src2.depth().
+ SEE: multiply, add, subtract
public static void divide(Mat src1,
+ Mat src2,
+ Mat dst,
+ double scale)
+
Performs per-element division of two arrays or a scalar by an array.
+
+ The function cv::divide divides one array by another:
+ \(\texttt{dst(I) = saturate(src1(I)*scale/src2(I))}\)
+ or a scalar by an array when there is no src1 :
+ \(\texttt{dst(I) = saturate(scale/src2(I))}\)
+
+ Different channels of multi-channel arrays are processed independently.
+
+ For integer types when src2(I) is zero, dst(I) will also be zero.
+
+ Note: In case of floating point data there is no special defined behavior for zero src2(I) values.
+ Regular floating-point division is used.
+ Expect correct IEEE-754 behaviour for floating-point data (with NaN, Inf result values).
+
+ Note: Saturation is not applied when the output array has the depth CV_32S. You may even get
+ result of an incorrect sign in the case of overflow.
+
+
Parameters:
+
src1 - first input array.
+
src2 - second input array of the same size and type as src1.
+
scale - scalar factor.
+
dst - output array of the same size and type as src2.
+ case of an array-by-array division, you can only pass -1 when src1.depth()==src2.depth().
+ SEE: multiply, add, subtract
public static void divide(Mat src1,
+ Mat src2,
+ Mat dst,
+ double scale,
+ int dtype)
+
Performs per-element division of two arrays or a scalar by an array.
+
+ The function cv::divide divides one array by another:
+ \(\texttt{dst(I) = saturate(src1(I)*scale/src2(I))}\)
+ or a scalar by an array when there is no src1 :
+ \(\texttt{dst(I) = saturate(scale/src2(I))}\)
+
+ Different channels of multi-channel arrays are processed independently.
+
+ For integer types when src2(I) is zero, dst(I) will also be zero.
+
+ Note: In case of floating point data there is no special defined behavior for zero src2(I) values.
+ Regular floating-point division is used.
+ Expect correct IEEE-754 behaviour for floating-point data (with NaN, Inf result values).
+
+ Note: Saturation is not applied when the output array has the depth CV_32S. You may even get
+ result of an incorrect sign in the case of overflow.
+
+
Parameters:
+
src1 - first input array.
+
src2 - second input array of the same size and type as src1.
+
scale - scalar factor.
+
dst - output array of the same size and type as src2.
+
dtype - optional depth of the output array; if -1, dst will have depth src2.depth(), but in
+ case of an array-by-array division, you can only pass -1 when src1.depth()==src2.depth().
+ SEE: multiply, add, subtract
public static boolean eigen(Mat src,
+ Mat eigenvalues)
+
Calculates eigenvalues and eigenvectors of a symmetric matrix.
+
+ The function cv::eigen calculates just eigenvalues, or eigenvalues and eigenvectors of the symmetric
+ matrix src:
+
+ src*eigenvectors.row(i).t() = eigenvalues.at<srcType>(i)*eigenvectors.row(i).t()
+
+
+ Note: Use cv::eigenNonSymmetric for calculation of real eigenvalues and eigenvectors of non-symmetric matrix.
+
+
Parameters:
+
src - input matrix that must have CV_32FC1 or CV_64FC1 type, square size and be symmetrical
+ (src ^T^ == src).
+
eigenvalues - output vector of eigenvalues of the same type as src; the eigenvalues are stored
+ in the descending order.
+ eigenvectors are stored as subsequent matrix rows, in the same order as the corresponding
+ eigenvalues.
+ SEE: eigenNonSymmetric, completeSymm , PCA
public static boolean eigen(Mat src,
+ Mat eigenvalues,
+ Mat eigenvectors)
+
Calculates eigenvalues and eigenvectors of a symmetric matrix.
+
+ The function cv::eigen calculates just eigenvalues, or eigenvalues and eigenvectors of the symmetric
+ matrix src:
+
+ src*eigenvectors.row(i).t() = eigenvalues.at<srcType>(i)*eigenvectors.row(i).t()
+
+
+ Note: Use cv::eigenNonSymmetric for calculation of real eigenvalues and eigenvectors of non-symmetric matrix.
+
+
Parameters:
+
src - input matrix that must have CV_32FC1 or CV_64FC1 type, square size and be symmetrical
+ (src ^T^ == src).
+
eigenvalues - output vector of eigenvalues of the same type as src; the eigenvalues are stored
+ in the descending order.
+
eigenvectors - output matrix of eigenvectors; it has the same size and type as src; the
+ eigenvectors are stored as subsequent matrix rows, in the same order as the corresponding
+ eigenvalues.
+ SEE: eigenNonSymmetric, completeSymm , PCA
public static void eigenNonSymmetric(Mat src,
+ Mat eigenvalues,
+ Mat eigenvectors)
+
Calculates eigenvalues and eigenvectors of a non-symmetric matrix (real eigenvalues only).
+
+ Note: Assumes real eigenvalues.
+
+ The function calculates eigenvalues and eigenvectors (optional) of the square matrix src:
+
+ src*eigenvectors.row(i).t() = eigenvalues.at<srcType>(i)*eigenvectors.row(i).t()
+
+
+
Parameters:
+
src - input matrix (CV_32FC1 or CV_64FC1 type).
+
eigenvalues - output vector of eigenvalues (type is the same type as src).
+
eigenvectors - output matrix of eigenvectors (type is the same type as src). The eigenvectors are stored as subsequent matrix rows, in the same order as the corresponding eigenvalues.
+ SEE: eigen
Calculates the exponent of every array element.
+
+ The function cv::exp calculates the exponent of every element of the input
+ array:
+ \(\texttt{dst} [I] = e^{ src(I) }\)
+
+ The maximum relative error is about 7e-6 for single-precision input and
+ less than 1e-10 for double-precision input. Currently, the function
+ converts denormalized values to zeros on output. Special values (NaN,
+ Inf) are not handled.
+
+
Parameters:
+
src - input array.
+
dst - output array of the same size and type as src.
+ SEE: log , cartToPolar , polarToCart , phase , pow , sqrt , magnitude
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
+ in degrees and varies from 0 to 360 degrees. The accuracy is about 0.3 degrees.
public static java.lang.String findFile(java.lang.String relative_path)
+
Try to find requested data file
+
+ Search directories:
+
+ 1. Directories passed via addSamplesDataSearchPath()
+ 2. OPENCV_SAMPLES_DATA_PATH_HINT environment variable
+ 3. OPENCV_SAMPLES_DATA_PATH environment variable
+ If parameter value is not empty and nothing is found then stop searching.
+ 4. Detects build/install path based on:
+ a. current working directory (CWD)
+ b. and/or binary module location (opencv_core/opencv_world, doesn't work with static linkage)
+ 5. Scan <source>/{,data,samples/data} directories if build directory is detected or the current directory is in source tree.
+ 6. Scan <install>/share/OpenCV directory if install directory is detected.
+
+ SEE: cv::utils::findDataFile
+
+
Parameters:
+
relative_path - Relative path to data file
+ If true, function prints information message and raises cv::Exception.
+ If false, function returns empty result
+
Returns:
+
Returns path (absolute or relative to the current directory) or empty string if file is not found
public static java.lang.String findFile(java.lang.String relative_path,
+ boolean required)
+
Try to find requested data file
+
+ Search directories:
+
+ 1. Directories passed via addSamplesDataSearchPath()
+ 2. OPENCV_SAMPLES_DATA_PATH_HINT environment variable
+ 3. OPENCV_SAMPLES_DATA_PATH environment variable
+ If parameter value is not empty and nothing is found then stop searching.
+ 4. Detects build/install path based on:
+ a. current working directory (CWD)
+ b. and/or binary module location (opencv_core/opencv_world, doesn't work with static linkage)
+ 5. Scan <source>/{,data,samples/data} directories if build directory is detected or the current directory is in source tree.
+ 6. Scan <install>/share/OpenCV directory if install directory is detected.
+
+ SEE: cv::utils::findDataFile
+
+
Parameters:
+
relative_path - Relative path to data file
+
required - Specify "file not found" handling.
+ If true, function prints information message and raises cv::Exception.
+ If false, function returns empty result
+
Returns:
+
Returns path (absolute or relative to the current directory) or empty string if file is not found
Try to find requested data file
+
+ Search directories:
+
+ 1. Directories passed via addSamplesDataSearchPath()
+ 2. OPENCV_SAMPLES_DATA_PATH_HINT environment variable
+ 3. OPENCV_SAMPLES_DATA_PATH environment variable
+ If parameter value is not empty and nothing is found then stop searching.
+ 4. Detects build/install path based on:
+ a. current working directory (CWD)
+ b. and/or binary module location (opencv_core/opencv_world, doesn't work with static linkage)
+ 5. Scan <source>/{,data,samples/data} directories if build directory is detected or the current directory is in source tree.
+ 6. Scan <install>/share/OpenCV directory if install directory is detected.
+
+ SEE: cv::utils::findDataFile
+
+
Parameters:
+
relative_path - Relative path to data file
+
required - Specify "file not found" handling.
+ If true, function prints information message and raises cv::Exception.
+ If false, function returns empty result
+
silentMode - Disables messages
+
Returns:
+
Returns path (absolute or relative to the current directory) or empty string if file is not found
public static void findNonZero(Mat src,
+ Mat idx)
+
Returns the list of locations of non-zero pixels
+
+ Given a binary matrix (likely returned from an operation such
+ as threshold(), compare(), >, ==, etc, return all of
+ the non-zero indices as a cv::Mat or std::vector<cv::Point> (x,y)
+ For example:
+
+ cv::Mat binaryImage; // input, binary image
+ cv::Mat locations; // output, locations of non-zero pixels
+ cv::findNonZero(binaryImage, locations);
+
+ // access pixel coordinates
+ Point pnt = locations.at<Point>(i);
+
+ or
+
+ cv::Mat binaryImage; // input, binary image
+ vector<Point> locations; // output, locations of non-zero pixels
+ cv::findNonZero(binaryImage, locations);
+
+ // access pixel coordinates
+ Point pnt = locations[i];
+
+
+
Parameters:
+
src - single-channel array
+
idx - the output array, type of cv::Mat or std::vector<Point>, corresponding to non-zero indices in the input
public static void flip(Mat src,
+ Mat dst,
+ int flipCode)
+
Flips a 2D array around vertical, horizontal, or both axes.
+
+ The function cv::flip flips the array in one of three different ways (row
+ and column indices are 0-based):
+ \(\texttt{dst} _{ij} =
+ \left\{
+ \begin{array}{l l}
+ \texttt{src} _{\texttt{src.rows}-i-1,j} & if\; \texttt{flipCode} = 0 \\
+ \texttt{src} _{i, \texttt{src.cols} -j-1} & if\; \texttt{flipCode} > 0 \\
+ \texttt{src} _{ \texttt{src.rows} -i-1, \texttt{src.cols} -j-1} & if\; \texttt{flipCode} < 0 \\
+ \end{array}
+ \right.\)
+ The example scenarios of using the function are the following:
+ Vertical flipping of the image (flipCode == 0) to switch between
+ top-left and bottom-left image origin. This is a typical operation
+ in video processing on Microsoft Windows\* OS.
+ Horizontal flipping of the image with the subsequent horizontal
+ shift and absolute difference calculation to check for a
+ vertical-axis symmetry (flipCode > 0).
+ Simultaneous horizontal and vertical flipping of the image with
+ the subsequent shift and absolute difference calculation to check
+ for a central symmetry (flipCode < 0).
+ Reversing the order of point arrays (flipCode > 0 or
+ flipCode == 0).
+
+
Parameters:
+
src - input array.
+
dst - output array of the same size and type as src.
+
flipCode - a flag to specify how to flip the array; 0 means
+ flipping around the x-axis and positive value (for example, 1) means
+ flipping around y-axis. Negative value (for example, -1) means flipping
+ around both axes.
+ SEE: transpose , repeat , completeSymm
public static void gemm(Mat src1,
+ Mat src2,
+ double alpha,
+ Mat src3,
+ double beta,
+ Mat dst)
+
Performs generalized matrix multiplication.
+
+ The function cv::gemm performs generalized matrix multiplication similar to the
+ gemm functions in BLAS level 3. For example,
+ gemm(src1, src2, alpha, src3, beta, dst, GEMM_1_T + GEMM_3_T)
+ corresponds to
+ \(\texttt{dst} = \texttt{alpha} \cdot \texttt{src1} ^T \cdot \texttt{src2} + \texttt{beta} \cdot \texttt{src3} ^T\)
+
+ In case of complex (two-channel) data, performed a complex matrix
+ multiplication.
+
+ The function can be replaced with a matrix expression. For example, the
+ above call can be replaced with:
+
+ dst = alpha*src1.t()*src2 + beta*src3.t();
+
+
+
Parameters:
+
src1 - first multiplied input matrix that could be real(CV_32FC1,
+ CV_64FC1) or complex(CV_32FC2, CV_64FC2).
+
src2 - second multiplied input matrix of the same type as src1.
+
alpha - weight of the matrix product.
+
src3 - third optional delta matrix added to the matrix product; it
+ should have the same type as src1 and src2.
+
beta - weight of src3.
+
dst - output matrix; it has the proper size and the same type as
+ input matrices.
+ SEE: mulTransposed , transform
public static void gemm(Mat src1,
+ Mat src2,
+ double alpha,
+ Mat src3,
+ double beta,
+ Mat dst,
+ int flags)
+
Performs generalized matrix multiplication.
+
+ The function cv::gemm performs generalized matrix multiplication similar to the
+ gemm functions in BLAS level 3. For example,
+ gemm(src1, src2, alpha, src3, beta, dst, GEMM_1_T + GEMM_3_T)
+ corresponds to
+ \(\texttt{dst} = \texttt{alpha} \cdot \texttt{src1} ^T \cdot \texttt{src2} + \texttt{beta} \cdot \texttt{src3} ^T\)
+
+ In case of complex (two-channel) data, performed a complex matrix
+ multiplication.
+
+ The function can be replaced with a matrix expression. For example, the
+ above call can be replaced with:
+
+ dst = alpha*src1.t()*src2 + beta*src3.t();
+
+
+
Parameters:
+
src1 - first multiplied input matrix that could be real(CV_32FC1,
+ CV_64FC1) or complex(CV_32FC2, CV_64FC2).
+
src2 - second multiplied input matrix of the same type as src1.
+
alpha - weight of the matrix product.
+
src3 - third optional delta matrix added to the matrix product; it
+ should have the same type as src1 and src2.
+
beta - weight of src3.
+
dst - output matrix; it has the proper size and the same type as
+ input matrices.
public static java.lang.String getBuildInformation()
+
Returns full configuration time cmake output.
+
+ Returned value is raw cmake output including version control system revision, compiler version,
+ compiler flags, enabled modules and third party libraries, etc. Output format depends on target
+ architecture.
public static java.lang.String getCPUFeaturesLine()
+
Returns list of CPU features enabled during compilation.
+
+ Returned value is a string containing space separated list of CPU features with following markers:
+
+
+
+ no markers - baseline features
+
+
+ prefix * - features enabled in dispatcher
+
+
+ suffix ? - features enabled but not available in HW
+
Returns the number of CPU ticks.
+
+ The function returns the current number of CPU ticks on some architectures (such as x86, x64,
+ PowerPC). On other platforms the function is equivalent to getTickCount. It can also be used for
+ very accurate time measurements, as well as for RNG initialization. Note that in case of multi-CPU
+ systems a thread, from which getCPUTickCount is called, can be suspended and resumed at another CPU
+ with its own counter. So, theoretically (and practically) the subsequent calls to the function do
+ not necessary return the monotonously increasing values. Also, since a modern CPU varies the CPU
+ frequency depending on the load, the number of CPU clocks spent in some code cannot be directly
+ converted to time units. Therefore, getTickCount is generally a preferable solution for measuring
+ execution time.
Returns the number of threads used by OpenCV for parallel regions.
+
+ Always returns 1 if OpenCV is built without threading support.
+
+ The exact meaning of return value depends on the threading framework used by OpenCV library:
+
+
+ TBB - The number of threads, that OpenCV will try to use for parallel regions. If there is
+ any tbb::thread_scheduler_init in user code conflicting with OpenCV, then function returns
+ default number of threads used by TBB library.
+
+
+ OpenMP - An upper bound on the number of threads that could be used to form a new team.
+
+
+ Concurrency - The number of threads, that OpenCV will try to use for parallel regions.
+
+
+ GCD - Unsupported; returns the GCD thread pool limit (512) for compatibility.
+
+
+ C= - The number of threads, that OpenCV will try to use for parallel regions, if before
+ called setNumThreads with threads > 0, otherwise returns the number of logical CPUs,
+ available for the process.
+ SEE: setNumThreads, getThreadNum
+
Returns the optimal DFT size for a given vector size.
+
+ DFT performance is not a monotonic function of a vector size. Therefore, when you calculate
+ convolution of two arrays or perform the spectral analysis of an array, it usually makes sense to
+ pad the input data with zeros to get a bit larger array that can be transformed much faster than the
+ original one. Arrays whose size is a power-of-two (2, 4, 8, 16, 32, ...) are the fastest to process.
+ Though, the arrays whose size is a product of 2's, 3's, and 5's (for example, 300 = 5\*5\*3\*2\*2)
+ are also processed quite efficiently.
+
+ The function cv::getOptimalDFTSize returns the minimum number N that is greater than or equal to vecsize
+ so that the DFT of a vector of size N can be processed efficiently. In the current implementation N
+ = 2 ^p^ \* 3 ^q^ \* 5 ^r^ for some integer p, q, r.
+
+ The function returns a negative number if vecsize is too large (very close to INT_MAX ).
+
+ While the function cannot be used directly to estimate the optimal vector size for DCT transform
+ (since the current DCT implementation supports only even-size vectors), it can be easily processed
+ as getOptimalDFTSize((vecsize+1)/2)\*2.
Returns the number of ticks.
+
+ The function returns the number of ticks after the certain event (for example, when the machine was
+ turned on). It can be used to initialize RNG or to measure a function execution time by reading the
+ tick count before and after the function call.
+ SEE: getTickFrequency, TickMeter
Returns the number of ticks per second.
+
+ The function returns the number of ticks per second. That is, the following code computes the
+ execution time in seconds:
+
+ double t = (double)getTickCount();
+ // do something ...
+ t = ((double)getTickCount() - t)/getTickFrequency();
+
+ SEE: getTickCount, TickMeter
Calculates the inverse Discrete Fourier Transform of a 1D or 2D array.
+
+ idft(src, dst, flags) is equivalent to dft(src, dst, flags | #DFT_INVERSE) .
+ Note: None of dft and idft scales the result by default. So, you should pass #DFT_SCALE to one of
+ dft or idft explicitly to make these transforms mutually inverse.
+ SEE: dft, dct, idct, mulSpectrums, getOptimalDFTSize
+
+
Parameters:
+
src - input floating-point real or complex array.
+
dst - output array whose size and type depend on the flags.
+ the convolution sample in dft description.
public static void idft(Mat src,
+ Mat dst,
+ int flags)
+
Calculates the inverse Discrete Fourier Transform of a 1D or 2D array.
+
+ idft(src, dst, flags) is equivalent to dft(src, dst, flags | #DFT_INVERSE) .
+ Note: None of dft and idft scales the result by default. So, you should pass #DFT_SCALE to one of
+ dft or idft explicitly to make these transforms mutually inverse.
+ SEE: dft, dct, idct, mulSpectrums, getOptimalDFTSize
+
+
Parameters:
+
src - input floating-point real or complex array.
+
dst - output array whose size and type depend on the flags.
+
flags - operation flags (see dft and #DftFlags).
+ the convolution sample in dft description.
public static void idft(Mat src,
+ Mat dst,
+ int flags,
+ int nonzeroRows)
+
Calculates the inverse Discrete Fourier Transform of a 1D or 2D array.
+
+ idft(src, dst, flags) is equivalent to dft(src, dst, flags | #DFT_INVERSE) .
+ Note: None of dft and idft scales the result by default. So, you should pass #DFT_SCALE to one of
+ dft or idft explicitly to make these transforms mutually inverse.
+ SEE: dft, dct, idct, mulSpectrums, getOptimalDFTSize
+
+
Parameters:
+
src - input floating-point real or complex array.
+
dst - output array whose size and type depend on the flags.
+
flags - operation flags (see dft and #DftFlags).
+
nonzeroRows - number of dst rows to process; the rest of the rows have undefined content (see
+ the convolution sample in dft description.
public static void inRange(Mat src,
+ Scalar lowerb,
+ Scalar upperb,
+ Mat dst)
+
Checks if array elements lie between the elements of two other arrays.
+
+ The function checks the range as follows:
+
+
+ For every element of a single-channel input array:
+ \(\texttt{dst} (I)= \texttt{lowerb} (I)_0 \leq \texttt{src} (I)_0 \leq \texttt{upperb} (I)_0\)
+
+
+ That is, dst (I) is set to 255 (all 1 -bits) if src (I) is within the
+ specified 1D, 2D, 3D, ... box and 0 otherwise.
+
+ When the lower and/or upper boundary parameters are scalars, the indexes
+ (I) at lowerb and upperb in the above formulas should be omitted.
+
+
Parameters:
+
src - first input array.
+
lowerb - inclusive lower boundary array or a scalar.
+
upperb - inclusive upper boundary array or a scalar.
+
dst - output array of the same size as src and CV_8U type.
Finds the inverse or pseudo-inverse of a matrix.
+
+ The function cv::invert inverts the matrix src and stores the result in dst
+ . When the matrix src is singular or non-square, the function calculates
+ the pseudo-inverse matrix (the dst matrix) so that norm(src\*dst - I) is
+ minimal, where I is an identity matrix.
+
+ In case of the #DECOMP_LU method, the function returns non-zero value if
+ the inverse has been successfully calculated and 0 if src is singular.
+
+ In case of the #DECOMP_SVD method, the function returns the inverse
+ condition number of src (the ratio of the smallest singular value to the
+ largest singular value) and 0 if src is singular. The SVD method
+ calculates a pseudo-inverse matrix if src is singular.
+
+ Similarly to #DECOMP_LU, the method #DECOMP_CHOLESKY works only with
+ non-singular square matrices that should also be symmetrical and
+ positively defined. In this case, the function stores the inverted
+ matrix in dst and returns non-zero. Otherwise, it returns 0.
+
+
Parameters:
+
src - input floating-point M x N matrix.
+
dst - output matrix of N x M size and the same type as src.
+ SEE: solve, SVD
public static double invert(Mat src,
+ Mat dst,
+ int flags)
+
Finds the inverse or pseudo-inverse of a matrix.
+
+ The function cv::invert inverts the matrix src and stores the result in dst
+ . When the matrix src is singular or non-square, the function calculates
+ the pseudo-inverse matrix (the dst matrix) so that norm(src\*dst - I) is
+ minimal, where I is an identity matrix.
+
+ In case of the #DECOMP_LU method, the function returns non-zero value if
+ the inverse has been successfully calculated and 0 if src is singular.
+
+ In case of the #DECOMP_SVD method, the function returns the inverse
+ condition number of src (the ratio of the smallest singular value to the
+ largest singular value) and 0 if src is singular. The SVD method
+ calculates a pseudo-inverse matrix if src is singular.
+
+ Similarly to #DECOMP_LU, the method #DECOMP_CHOLESKY works only with
+ non-singular square matrices that should also be symmetrical and
+ positively defined. In this case, the function stores the inverted
+ matrix in dst and returns non-zero. Otherwise, it returns 0.
+
+
Parameters:
+
src - input floating-point M x N matrix.
+
dst - output matrix of N x M size and the same type as src.
public static double kmeans(Mat data,
+ int K,
+ Mat bestLabels,
+ TermCriteria criteria,
+ int attempts,
+ int flags)
+
Finds centers of clusters and groups input samples around the clusters.
+
+ The function kmeans implements a k-means algorithm that finds the centers of cluster_count clusters
+ and groups the input samples around the clusters. As an output, \(\texttt{bestLabels}_i\) contains a
+ 0-based cluster index for the sample stored in the \(i^{th}\) row of the samples matrix.
+
+ Note:
+
+
+ (Python) An example on K-means clustering can be found at
+ opencv_source_code/samples/python/kmeans.py
+
+
+
+
Parameters:
+
data - Data for clustering. An array of N-Dimensional points with float coordinates is needed.
+ Examples of this array can be:
+
+
+ Mat points(count, 2, CV_32F);
+
+
+ Mat points(count, 1, CV_32FC2);
+
+
+ Mat points(1, count, CV_32FC2);
+
+
+ std::vector<cv::Point2f> points(sampleCount);
+
+
+
K - Number of clusters to split the set by.
+
bestLabels - Input/output integer array that stores the cluster indices for every sample.
+
criteria - The algorithm termination criteria, that is, the maximum number of iterations and/or
+ the desired accuracy. The accuracy is specified as criteria.epsilon. As soon as each of the cluster
+ centers moves by less than criteria.epsilon on some iteration, the algorithm stops.
+
attempts - Flag to specify the number of times the algorithm is executed using different
+ initial labellings. The algorithm returns the labels that yield the best compactness (see the last
+ function parameter).
+
flags - Flag that can take values of cv::KmeansFlags
+
Returns:
+
The function returns the compactness measure that is computed as
+ \(\sum _i \| \texttt{samples} _i - \texttt{centers} _{ \texttt{labels} _i} \| ^2\)
+ after every attempt. The best (minimum) value is chosen and the corresponding labels and the
+ compactness value are returned by the function. Basically, you can use only the core of the
+ function, set the number of attempts to 1, initialize labels each time using a custom algorithm,
+ pass them with the ( flags = #KMEANS_USE_INITIAL_LABELS ) flag, and then choose the best
+ (most-compact) clustering.
public static double kmeans(Mat data,
+ int K,
+ Mat bestLabels,
+ TermCriteria criteria,
+ int attempts,
+ int flags,
+ Mat centers)
+
Finds centers of clusters and groups input samples around the clusters.
+
+ The function kmeans implements a k-means algorithm that finds the centers of cluster_count clusters
+ and groups the input samples around the clusters. As an output, \(\texttt{bestLabels}_i\) contains a
+ 0-based cluster index for the sample stored in the \(i^{th}\) row of the samples matrix.
+
+ Note:
+
+
+ (Python) An example on K-means clustering can be found at
+ opencv_source_code/samples/python/kmeans.py
+
+
+
+
Parameters:
+
data - Data for clustering. An array of N-Dimensional points with float coordinates is needed.
+ Examples of this array can be:
+
+
+ Mat points(count, 2, CV_32F);
+
+
+ Mat points(count, 1, CV_32FC2);
+
+
+ Mat points(1, count, CV_32FC2);
+
+
+ std::vector<cv::Point2f> points(sampleCount);
+
+
+
K - Number of clusters to split the set by.
+
bestLabels - Input/output integer array that stores the cluster indices for every sample.
+
criteria - The algorithm termination criteria, that is, the maximum number of iterations and/or
+ the desired accuracy. The accuracy is specified as criteria.epsilon. As soon as each of the cluster
+ centers moves by less than criteria.epsilon on some iteration, the algorithm stops.
+
attempts - Flag to specify the number of times the algorithm is executed using different
+ initial labellings. The algorithm returns the labels that yield the best compactness (see the last
+ function parameter).
+
flags - Flag that can take values of cv::KmeansFlags
+
centers - Output matrix of the cluster centers, one row per each cluster center.
+
Returns:
+
The function returns the compactness measure that is computed as
+ \(\sum _i \| \texttt{samples} _i - \texttt{centers} _{ \texttt{labels} _i} \| ^2\)
+ after every attempt. The best (minimum) value is chosen and the corresponding labels and the
+ compactness value are returned by the function. Basically, you can use only the core of the
+ function, set the number of attempts to 1, initialize labels each time using a custom algorithm,
+ pass them with the ( flags = #KMEANS_USE_INITIAL_LABELS ) flag, and then choose the best
+ (most-compact) clustering.
Calculates the natural logarithm of every array element.
+
+ The function cv::log calculates the natural logarithm of every element of the input array:
+ \(\texttt{dst} (I) = \log (\texttt{src}(I)) \)
+
+ Output on zero, negative and special (NaN, Inf) values is undefined.
+
+
Parameters:
+
src - input array.
+
dst - output array of the same size and type as src .
+ SEE: exp, cartToPolar, polarToCart, phase, pow, sqrt, magnitude
public static void LUT(Mat src,
+ Mat lut,
+ Mat dst)
+
Performs a look-up table transform of an array.
+
+ The function LUT fills the output array with values from the look-up table. Indices of the entries
+ are taken from the input array. That is, the function processes each element of src as follows:
+ \(\texttt{dst} (I) \leftarrow \texttt{lut(src(I) + d)}\)
+ where
+ \(d = \fork{0}{if \(\texttt{src}\) has depth \(\texttt{CV_8U}\)}{128}{if \(\texttt{src}\) has depth \(\texttt{CV_8S}\)}\)
+
+
Parameters:
+
src - input array of 8-bit elements.
+
lut - look-up table of 256 elements; in case of multi-channel input array, the table should
+ either have a single channel (in this case the same table is used for all channels) or the same
+ number of channels as in the input array.
+
dst - output array of the same size and number of channels as src, and the same depth as lut.
+ SEE: convertScaleAbs, Mat::convertTo
public static void magnitude(Mat x,
+ Mat y,
+ Mat magnitude)
+
Calculates the magnitude of 2D vectors.
+
+ The function cv::magnitude calculates the magnitude of 2D vectors formed
+ from the corresponding elements of x and y arrays:
+ \(\texttt{dst} (I) = \sqrt{\texttt{x}(I)^2 + \texttt{y}(I)^2}\)
+
+
Parameters:
+
x - floating-point array of x-coordinates of the vectors.
+
y - floating-point array of y-coordinates of the vectors; it must
+ have the same size as x.
+
magnitude - output array of the same size and type as x.
+ SEE: cartToPolar, polarToCart, phase, sqrt
public static double Mahalanobis(Mat v1,
+ Mat v2,
+ Mat icovar)
+
Calculates the Mahalanobis distance between two vectors.
+
+ The function cv::Mahalanobis calculates and returns the weighted distance between two vectors:
+ \(d( \texttt{vec1} , \texttt{vec2} )= \sqrt{\sum_{i,j}{\texttt{icovar(i,j)}\cdot(\texttt{vec1}(I)-\texttt{vec2}(I))\cdot(\texttt{vec1(j)}-\texttt{vec2(j)})} }\)
+ The covariance matrix may be calculated using the #calcCovarMatrix function and then inverted using
+ the invert function (preferably using the #DECOMP_SVD method, as the most accurate).
public static void max(Mat src1,
+ Mat src2,
+ Mat dst)
+
Calculates per-element maximum of two arrays or an array and a scalar.
+
+ The function cv::max calculates the per-element maximum of two arrays:
+ \(\texttt{dst} (I)= \max ( \texttt{src1} (I), \texttt{src2} (I))\)
+ or array and a scalar:
+ \(\texttt{dst} (I)= \max ( \texttt{src1} (I), \texttt{value} )\)
+
+
Parameters:
+
src1 - first input array.
+
src2 - second input array of the same size and type as src1 .
+
dst - output array of the same size and type as src1.
+ SEE: min, compare, inRange, minMaxLoc, REF: MatrixExpressions
Calculates an average (mean) of array elements.
+
+ The function cv::mean calculates the mean value M of array elements,
+ independently for each channel, and return it:
+ \(\begin{array}{l} N = \sum _{I: \; \texttt{mask} (I) \ne 0} 1 \\ M_c = \left ( \sum _{I: \; \texttt{mask} (I) \ne 0}{ \texttt{mtx} (I)_c} \right )/N \end{array}\)
+ When all the mask elements are 0's, the function returns Scalar::all(0)
+
+
Parameters:
+
src - input array that should have from 1 to 4 channels so that the result can be stored in
+ Scalar_ .
+ SEE: countNonZero, meanStdDev, norm, minMaxLoc
Calculates an average (mean) of array elements.
+
+ The function cv::mean calculates the mean value M of array elements,
+ independently for each channel, and return it:
+ \(\begin{array}{l} N = \sum _{I: \; \texttt{mask} (I) \ne 0} 1 \\ M_c = \left ( \sum _{I: \; \texttt{mask} (I) \ne 0}{ \texttt{mtx} (I)_c} \right )/N \end{array}\)
+ When all the mask elements are 0's, the function returns Scalar::all(0)
+
+
Parameters:
+
src - input array that should have from 1 to 4 channels so that the result can be stored in
+ Scalar_ .
Calculates a mean and standard deviation of array elements.
+
+ The function cv::meanStdDev calculates the mean and the standard deviation M
+ of array elements independently for each channel and returns it via the
+ output parameters:
+ \(\begin{array}{l} N = \sum _{I, \texttt{mask} (I) \ne 0} 1 \\ \texttt{mean} _c = \frac{\sum_{ I: \; \texttt{mask}(I) \ne 0} \texttt{src} (I)_c}{N} \\ \texttt{stddev} _c = \sqrt{\frac{\sum_{ I: \; \texttt{mask}(I) \ne 0} \left ( \texttt{src} (I)_c - \texttt{mean} _c \right )^2}{N}} \end{array}\)
+ When all the mask elements are 0's, the function returns
+ mean=stddev=Scalar::all(0).
+ Note: The calculated standard deviation is only the diagonal of the
+ complete normalized covariance matrix. If the full matrix is needed, you
+ can reshape the multi-channel array M x N to the single-channel array
+ M\*N x mtx.channels() (only possible when the matrix is continuous) and
+ then pass the matrix to calcCovarMatrix .
+
+
Parameters:
+
src - input array that should have from 1 to 4 channels so that the results can be stored in
+ Scalar_ 's.
Calculates a mean and standard deviation of array elements.
+
+ The function cv::meanStdDev calculates the mean and the standard deviation M
+ of array elements independently for each channel and returns it via the
+ output parameters:
+ \(\begin{array}{l} N = \sum _{I, \texttt{mask} (I) \ne 0} 1 \\ \texttt{mean} _c = \frac{\sum_{ I: \; \texttt{mask}(I) \ne 0} \texttt{src} (I)_c}{N} \\ \texttt{stddev} _c = \sqrt{\frac{\sum_{ I: \; \texttt{mask}(I) \ne 0} \left ( \texttt{src} (I)_c - \texttt{mean} _c \right )^2}{N}} \end{array}\)
+ When all the mask elements are 0's, the function returns
+ mean=stddev=Scalar::all(0).
+ Note: The calculated standard deviation is only the diagonal of the
+ complete normalized covariance matrix. If the full matrix is needed, you
+ can reshape the multi-channel array M x N to the single-channel array
+ M\*N x mtx.channels() (only possible when the matrix is continuous) and
+ then pass the matrix to calcCovarMatrix .
+
+
Parameters:
+
src - input array that should have from 1 to 4 channels so that the results can be stored in
+ Scalar_ 's.
+
mean - output parameter: calculated mean value.
+
stddev - output parameter: calculated standard deviation.
public static void min(Mat src1,
+ Mat src2,
+ Mat dst)
+
Calculates per-element minimum of two arrays or an array and a scalar.
+
+ The function cv::min calculates the per-element minimum of two arrays:
+ \(\texttt{dst} (I)= \min ( \texttt{src1} (I), \texttt{src2} (I))\)
+ or array and a scalar:
+ \(\texttt{dst} (I)= \min ( \texttt{src1} (I), \texttt{value} )\)
+
+
Parameters:
+
src1 - first input array.
+
src2 - second input array of the same size and type as src1.
+
dst - output array of the same size and type as src1.
+ SEE: max, compare, inRange, minMaxLoc
src - input array or vector of matrices; all of the matrices must have the same size and the
+ same depth.
+
dst - output array or vector of matrices; all the matrices must be allocated; their size and
+ depth must be the same as in src[0].
+
fromTo - array of index pairs specifying which channels are copied and where; fromTo[k\*2] is
+ a 0-based index of the input channel in src, fromTo[k\*2+1] is an index of the output channel in
+ dst; the continuous channel numbering is used: the first input image channels are indexed from 0 to
+ src[0].channels()-1, the second input image channels are indexed from src[0].channels() to
+ src[0].channels() + src[1].channels()-1, and so on, the same scheme is used for the output image
+ channels; as a special case, when fromTo[k\*2] is negative, the corresponding output channel is
+ filled with zero .
public static void mulSpectrums(Mat a,
+ Mat b,
+ Mat c,
+ int flags)
+
Performs the per-element multiplication of two Fourier spectrums.
+
+ The function cv::mulSpectrums performs the per-element multiplication of the two CCS-packed or complex
+ matrices that are results of a real or complex Fourier transform.
+
+ The function, together with dft and idft , may be used to calculate convolution (pass conjB=false )
+ or correlation (pass conjB=true ) of two arrays rapidly. When the arrays are complex, they are
+ simply multiplied (per element) with an optional conjugation of the second-array elements. When the
+ arrays are real, they are assumed to be CCS-packed (see dft for details).
+
+
Parameters:
+
a - first input array.
+
b - second input array of the same size and type as src1 .
+
c - output array of the same size and type as src1 .
+
flags - operation flags; currently, the only supported flag is cv::DFT_ROWS, which indicates that
+ each row of src1 and src2 is an independent 1D Fourier spectrum. If you do not want to use this flag, then simply add a 0 as value.
+ or not (false).
public static void mulSpectrums(Mat a,
+ Mat b,
+ Mat c,
+ int flags,
+ boolean conjB)
+
Performs the per-element multiplication of two Fourier spectrums.
+
+ The function cv::mulSpectrums performs the per-element multiplication of the two CCS-packed or complex
+ matrices that are results of a real or complex Fourier transform.
+
+ The function, together with dft and idft , may be used to calculate convolution (pass conjB=false )
+ or correlation (pass conjB=true ) of two arrays rapidly. When the arrays are complex, they are
+ simply multiplied (per element) with an optional conjugation of the second-array elements. When the
+ arrays are real, they are assumed to be CCS-packed (see dft for details).
+
+
Parameters:
+
a - first input array.
+
b - second input array of the same size and type as src1 .
+
c - output array of the same size and type as src1 .
+
flags - operation flags; currently, the only supported flag is cv::DFT_ROWS, which indicates that
+ each row of src1 and src2 is an independent 1D Fourier spectrum. If you do not want to use this flag, then simply add a 0 as value.
+
conjB - optional flag that conjugates the second input array before the multiplication (true)
+ or not (false).
public static void multiply(Mat src1,
+ Mat src2,
+ Mat dst)
+
Calculates the per-element scaled product of two arrays.
+
+ The function multiply calculates the per-element product of two arrays:
+
+ \(\texttt{dst} (I)= \texttt{saturate} ( \texttt{scale} \cdot \texttt{src1} (I) \cdot \texttt{src2} (I))\)
+
+ There is also a REF: MatrixExpressions -friendly variant of the first function. See Mat::mul .
+
+ For a not-per-element matrix product, see gemm .
+
+ Note: Saturation is not applied when the output array has the depth
+ CV_32S. You may even get result of an incorrect sign in the case of
+ overflow.
+
+
Parameters:
+
src1 - first input array.
+
src2 - second input array of the same size and the same type as src1.
+
dst - output array of the same size and type as src1.
+ SEE: add, subtract, divide, scaleAdd, addWeighted, accumulate, accumulateProduct, accumulateSquare,
+ Mat::convertTo
public static void multiply(Mat src1,
+ Mat src2,
+ Mat dst,
+ double scale)
+
Calculates the per-element scaled product of two arrays.
+
+ The function multiply calculates the per-element product of two arrays:
+
+ \(\texttt{dst} (I)= \texttt{saturate} ( \texttt{scale} \cdot \texttt{src1} (I) \cdot \texttt{src2} (I))\)
+
+ There is also a REF: MatrixExpressions -friendly variant of the first function. See Mat::mul .
+
+ For a not-per-element matrix product, see gemm .
+
+ Note: Saturation is not applied when the output array has the depth
+ CV_32S. You may even get result of an incorrect sign in the case of
+ overflow.
+
+
Parameters:
+
src1 - first input array.
+
src2 - second input array of the same size and the same type as src1.
+
dst - output array of the same size and type as src1.
public static void multiply(Mat src1,
+ Mat src2,
+ Mat dst,
+ double scale,
+ int dtype)
+
Calculates the per-element scaled product of two arrays.
+
+ The function multiply calculates the per-element product of two arrays:
+
+ \(\texttt{dst} (I)= \texttt{saturate} ( \texttt{scale} \cdot \texttt{src1} (I) \cdot \texttt{src2} (I))\)
+
+ There is also a REF: MatrixExpressions -friendly variant of the first function. See Mat::mul .
+
+ For a not-per-element matrix product, see gemm .
+
+ Note: Saturation is not applied when the output array has the depth
+ CV_32S. You may even get result of an incorrect sign in the case of
+ overflow.
+
+
Parameters:
+
src1 - first input array.
+
src2 - second input array of the same size and the same type as src1.
+
dst - output array of the same size and type as src1.
+
scale - optional scale factor.
+
dtype - optional depth of the output array
+ SEE: add, subtract, divide, scaleAdd, addWeighted, accumulate, accumulateProduct, accumulateSquare,
+ Mat::convertTo
public static void mulTransposed(Mat src,
+ Mat dst,
+ boolean aTa)
+
Calculates the product of a matrix and its transposition.
+
+ The function cv::mulTransposed calculates the product of src and its
+ transposition:
+ \(\texttt{dst} = \texttt{scale} ( \texttt{src} - \texttt{delta} )^T ( \texttt{src} - \texttt{delta} )\)
+ if aTa=true , and
+ \(\texttt{dst} = \texttt{scale} ( \texttt{src} - \texttt{delta} ) ( \texttt{src} - \texttt{delta} )^T\)
+ otherwise. The function is used to calculate the covariance matrix. With
+ zero delta, it can be used as a faster substitute for general matrix
+ product A\*B when B=A'
+
+
Parameters:
+
src - input single-channel matrix. Note that unlike gemm, the
+ function can multiply not only floating-point matrices.
+
dst - output square matrix.
+
aTa - Flag specifying the multiplication ordering. See the
+ description below.
+ multiplication. When the matrix is empty ( delta=noArray() ), it is
+ assumed to be zero, that is, nothing is subtracted. If it has the same
+ size as src , it is simply subtracted. Otherwise, it is "repeated" (see
+ repeat ) to cover the full src and then subtracted. Type of the delta
+ matrix, when it is not empty, must be the same as the type of created
+ output matrix. See the dtype parameter description below.
+ the output matrix will have the same type as src . Otherwise, it will be
+ type=CV_MAT_DEPTH(dtype) that should be either CV_32F or CV_64F .
+ SEE: calcCovarMatrix, gemm, repeat, reduce
public static void mulTransposed(Mat src,
+ Mat dst,
+ boolean aTa,
+ Mat delta)
+
Calculates the product of a matrix and its transposition.
+
+ The function cv::mulTransposed calculates the product of src and its
+ transposition:
+ \(\texttt{dst} = \texttt{scale} ( \texttt{src} - \texttt{delta} )^T ( \texttt{src} - \texttt{delta} )\)
+ if aTa=true , and
+ \(\texttt{dst} = \texttt{scale} ( \texttt{src} - \texttt{delta} ) ( \texttt{src} - \texttt{delta} )^T\)
+ otherwise. The function is used to calculate the covariance matrix. With
+ zero delta, it can be used as a faster substitute for general matrix
+ product A\*B when B=A'
+
+
Parameters:
+
src - input single-channel matrix. Note that unlike gemm, the
+ function can multiply not only floating-point matrices.
+
dst - output square matrix.
+
aTa - Flag specifying the multiplication ordering. See the
+ description below.
+
delta - Optional delta matrix subtracted from src before the
+ multiplication. When the matrix is empty ( delta=noArray() ), it is
+ assumed to be zero, that is, nothing is subtracted. If it has the same
+ size as src , it is simply subtracted. Otherwise, it is "repeated" (see
+ repeat ) to cover the full src and then subtracted. Type of the delta
+ matrix, when it is not empty, must be the same as the type of created
+ output matrix. See the dtype parameter description below.
+ the output matrix will have the same type as src . Otherwise, it will be
+ type=CV_MAT_DEPTH(dtype) that should be either CV_32F or CV_64F .
+ SEE: calcCovarMatrix, gemm, repeat, reduce
public static void mulTransposed(Mat src,
+ Mat dst,
+ boolean aTa,
+ Mat delta,
+ double scale)
+
Calculates the product of a matrix and its transposition.
+
+ The function cv::mulTransposed calculates the product of src and its
+ transposition:
+ \(\texttt{dst} = \texttt{scale} ( \texttt{src} - \texttt{delta} )^T ( \texttt{src} - \texttt{delta} )\)
+ if aTa=true , and
+ \(\texttt{dst} = \texttt{scale} ( \texttt{src} - \texttt{delta} ) ( \texttt{src} - \texttt{delta} )^T\)
+ otherwise. The function is used to calculate the covariance matrix. With
+ zero delta, it can be used as a faster substitute for general matrix
+ product A\*B when B=A'
+
+
Parameters:
+
src - input single-channel matrix. Note that unlike gemm, the
+ function can multiply not only floating-point matrices.
+
dst - output square matrix.
+
aTa - Flag specifying the multiplication ordering. See the
+ description below.
+
delta - Optional delta matrix subtracted from src before the
+ multiplication. When the matrix is empty ( delta=noArray() ), it is
+ assumed to be zero, that is, nothing is subtracted. If it has the same
+ size as src , it is simply subtracted. Otherwise, it is "repeated" (see
+ repeat ) to cover the full src and then subtracted. Type of the delta
+ matrix, when it is not empty, must be the same as the type of created
+ output matrix. See the dtype parameter description below.
+
scale - Optional scale factor for the matrix product.
+ the output matrix will have the same type as src . Otherwise, it will be
+ type=CV_MAT_DEPTH(dtype) that should be either CV_32F or CV_64F .
+ SEE: calcCovarMatrix, gemm, repeat, reduce
public static void mulTransposed(Mat src,
+ Mat dst,
+ boolean aTa,
+ Mat delta,
+ double scale,
+ int dtype)
+
Calculates the product of a matrix and its transposition.
+
+ The function cv::mulTransposed calculates the product of src and its
+ transposition:
+ \(\texttt{dst} = \texttt{scale} ( \texttt{src} - \texttt{delta} )^T ( \texttt{src} - \texttt{delta} )\)
+ if aTa=true , and
+ \(\texttt{dst} = \texttt{scale} ( \texttt{src} - \texttt{delta} ) ( \texttt{src} - \texttt{delta} )^T\)
+ otherwise. The function is used to calculate the covariance matrix. With
+ zero delta, it can be used as a faster substitute for general matrix
+ product A\*B when B=A'
+
+
Parameters:
+
src - input single-channel matrix. Note that unlike gemm, the
+ function can multiply not only floating-point matrices.
+
dst - output square matrix.
+
aTa - Flag specifying the multiplication ordering. See the
+ description below.
+
delta - Optional delta matrix subtracted from src before the
+ multiplication. When the matrix is empty ( delta=noArray() ), it is
+ assumed to be zero, that is, nothing is subtracted. If it has the same
+ size as src , it is simply subtracted. Otherwise, it is "repeated" (see
+ repeat ) to cover the full src and then subtracted. Type of the delta
+ matrix, when it is not empty, must be the same as the type of created
+ output matrix. See the dtype parameter description below.
+
scale - Optional scale factor for the matrix product.
+
dtype - Optional type of the output matrix. When it is negative,
+ the output matrix will have the same type as src . Otherwise, it will be
+ type=CV_MAT_DEPTH(dtype) that should be either CV_32F or CV_64F .
+ SEE: calcCovarMatrix, gemm, repeat, reduce
Calculates the absolute norm of an array.
+
+ This version of #norm calculates the absolute norm of src1. The type of norm to calculate is specified using #NormTypes.
+
+ As example for one array consider the function \(r(x)= \begin{pmatrix} x \\ 1-x \end{pmatrix}, x \in [-1;1]\).
+ The \( L_{1}, L_{2} \) and \( L_{\infty} \) norm for the sample value \(r(-1) = \begin{pmatrix} -1 \\ 2 \end{pmatrix}\)
+ is calculated as follows
+ \(align*}
+ \| r(-1) \|_{L_1} &= |-1| + |2| = 3 \\
+ \| r(-1) \|_{L_2} &= \sqrt{(-1)^{2} + (2)^{2}} = \sqrt{5} \\
+ \| r(-1) \|_{L_\infty} &= \max(|-1|,|2|) = 2
+ \)
+ and for \(r(0.5) = \begin{pmatrix} 0.5 \\ 0.5 \end{pmatrix}\) the calculation is
+ \(align*}
+ \| r(0.5) \|_{L_1} &= |0.5| + |0.5| = 1 \\
+ \| r(0.5) \|_{L_2} &= \sqrt{(0.5)^{2} + (0.5)^{2}} = \sqrt{0.5} \\
+ \| r(0.5) \|_{L_\infty} &= \max(|0.5|,|0.5|) = 0.5.
+ \)
+ The following graphic shows all values for the three norm functions \(\| r(x) \|_{L_1}, \| r(x) \|_{L_2}\) and \(\| r(x) \|_{L_\infty}\).
+ It is notable that the \( L_{1} \) norm forms the upper and the \( L_{\infty} \) norm forms the lower border for the example function \( r(x) \).
+ 
+
+ When the mask parameter is specified and it is not empty, the norm is
+
+ If normType is not specified, #NORM_L2 is used.
+ calculated only over the region specified by the mask.
+
+ Multi-channel input arrays are treated as single-channel arrays, that is,
+ the results for all channels are combined.
+
+ Hamming norms can only be calculated with CV_8U depth arrays.
public static double norm(Mat src1,
+ int normType)
+
Calculates the absolute norm of an array.
+
+ This version of #norm calculates the absolute norm of src1. The type of norm to calculate is specified using #NormTypes.
+
+ As example for one array consider the function \(r(x)= \begin{pmatrix} x \\ 1-x \end{pmatrix}, x \in [-1;1]\).
+ The \( L_{1}, L_{2} \) and \( L_{\infty} \) norm for the sample value \(r(-1) = \begin{pmatrix} -1 \\ 2 \end{pmatrix}\)
+ is calculated as follows
+ \(align*}
+ \| r(-1) \|_{L_1} &= |-1| + |2| = 3 \\
+ \| r(-1) \|_{L_2} &= \sqrt{(-1)^{2} + (2)^{2}} = \sqrt{5} \\
+ \| r(-1) \|_{L_\infty} &= \max(|-1|,|2|) = 2
+ \)
+ and for \(r(0.5) = \begin{pmatrix} 0.5 \\ 0.5 \end{pmatrix}\) the calculation is
+ \(align*}
+ \| r(0.5) \|_{L_1} &= |0.5| + |0.5| = 1 \\
+ \| r(0.5) \|_{L_2} &= \sqrt{(0.5)^{2} + (0.5)^{2}} = \sqrt{0.5} \\
+ \| r(0.5) \|_{L_\infty} &= \max(|0.5|,|0.5|) = 0.5.
+ \)
+ The following graphic shows all values for the three norm functions \(\| r(x) \|_{L_1}, \| r(x) \|_{L_2}\) and \(\| r(x) \|_{L_\infty}\).
+ It is notable that the \( L_{1} \) norm forms the upper and the \( L_{\infty} \) norm forms the lower border for the example function \( r(x) \).
+ 
+
+ When the mask parameter is specified and it is not empty, the norm is
+
+ If normType is not specified, #NORM_L2 is used.
+ calculated only over the region specified by the mask.
+
+ Multi-channel input arrays are treated as single-channel arrays, that is,
+ the results for all channels are combined.
+
+ Hamming norms can only be calculated with CV_8U depth arrays.
public static double norm(Mat src1,
+ int normType,
+ Mat mask)
+
Calculates the absolute norm of an array.
+
+ This version of #norm calculates the absolute norm of src1. The type of norm to calculate is specified using #NormTypes.
+
+ As example for one array consider the function \(r(x)= \begin{pmatrix} x \\ 1-x \end{pmatrix}, x \in [-1;1]\).
+ The \( L_{1}, L_{2} \) and \( L_{\infty} \) norm for the sample value \(r(-1) = \begin{pmatrix} -1 \\ 2 \end{pmatrix}\)
+ is calculated as follows
+ \(align*}
+ \| r(-1) \|_{L_1} &= |-1| + |2| = 3 \\
+ \| r(-1) \|_{L_2} &= \sqrt{(-1)^{2} + (2)^{2}} = \sqrt{5} \\
+ \| r(-1) \|_{L_\infty} &= \max(|-1|,|2|) = 2
+ \)
+ and for \(r(0.5) = \begin{pmatrix} 0.5 \\ 0.5 \end{pmatrix}\) the calculation is
+ \(align*}
+ \| r(0.5) \|_{L_1} &= |0.5| + |0.5| = 1 \\
+ \| r(0.5) \|_{L_2} &= \sqrt{(0.5)^{2} + (0.5)^{2}} = \sqrt{0.5} \\
+ \| r(0.5) \|_{L_\infty} &= \max(|0.5|,|0.5|) = 0.5.
+ \)
+ The following graphic shows all values for the three norm functions \(\| r(x) \|_{L_1}, \| r(x) \|_{L_2}\) and \(\| r(x) \|_{L_\infty}\).
+ It is notable that the \( L_{1} \) norm forms the upper and the \( L_{\infty} \) norm forms the lower border for the example function \( r(x) \).
+ 
+
+ When the mask parameter is specified and it is not empty, the norm is
+
+ If normType is not specified, #NORM_L2 is used.
+ calculated only over the region specified by the mask.
+
+ Multi-channel input arrays are treated as single-channel arrays, that is,
+ the results for all channels are combined.
+
+ Hamming norms can only be calculated with CV_8U depth arrays.
+
+
Parameters:
+
src1 - first input array.
+
normType - type of the norm (see #NormTypes).
+
mask - optional operation mask; it must have the same size as src1 and CV_8UC1 type.
Calculates an absolute difference norm or a relative difference norm.
+
+ This version of cv::norm calculates the absolute difference norm
+ or the relative difference norm of arrays src1 and src2.
+ The type of norm to calculate is specified using #NormTypes.
+
+
Parameters:
+
src1 - first input array.
+
src2 - second input array of the same size and the same type as src1.
public static double norm(Mat src1,
+ Mat src2,
+ int normType)
+
Calculates an absolute difference norm or a relative difference norm.
+
+ This version of cv::norm calculates the absolute difference norm
+ or the relative difference norm of arrays src1 and src2.
+ The type of norm to calculate is specified using #NormTypes.
+
+
Parameters:
+
src1 - first input array.
+
src2 - second input array of the same size and the same type as src1.
public static double norm(Mat src1,
+ Mat src2,
+ int normType,
+ Mat mask)
+
Calculates an absolute difference norm or a relative difference norm.
+
+ This version of cv::norm calculates the absolute difference norm
+ or the relative difference norm of arrays src1 and src2.
+ The type of norm to calculate is specified using #NormTypes.
+
+
Parameters:
+
src1 - first input array.
+
src2 - second input array of the same size and the same type as src1.
+
normType - type of the norm (see #NormTypes).
+
mask - optional operation mask; it must have the same size as src1 and CV_8UC1 type.
Normalizes the norm or value range of an array.
+
+ The function cv::normalize normalizes scale and shift the input array elements so that
+ \(\| \texttt{dst} \| _{L_p}= \texttt{alpha}\)
+ (where p=Inf, 1 or 2) when normType=NORM_INF, NORM_L1, or NORM_L2, respectively; or so that
+ \(\min _I \texttt{dst} (I)= \texttt{alpha} , \, \, \max _I \texttt{dst} (I)= \texttt{beta}\)
+
+ when normType=NORM_MINMAX (for dense arrays only). The optional mask specifies a sub-array to be
+ normalized. This means that the norm or min-n-max are calculated over the sub-array, and then this
+ sub-array is modified to be normalized. If you want to only use the mask to calculate the norm or
+ min-max but modify the whole array, you can use norm and Mat::convertTo.
+
+ In case of sparse matrices, only the non-zero values are analyzed and transformed. Because of this,
+ the range transformation for sparse matrices is not allowed since it can shift the zero level.
+
+ Possible usage with some positive example data:
+
+ vector<double> positiveData = { 2.0, 8.0, 10.0 };
+ vector<double> normalizedData_l1, normalizedData_l2, normalizedData_inf, normalizedData_minmax;
+
+ // Norm to probability (total count)
+ // sum(numbers) = 20.0
+ // 2.0 0.1 (2.0/20.0)
+ // 8.0 0.4 (8.0/20.0)
+ // 10.0 0.5 (10.0/20.0)
+ normalize(positiveData, normalizedData_l1, 1.0, 0.0, NORM_L1);
+
+ // Norm to unit vector: ||positiveData|| = 1.0
+ // 2.0 0.15
+ // 8.0 0.62
+ // 10.0 0.77
+ normalize(positiveData, normalizedData_l2, 1.0, 0.0, NORM_L2);
+
+ // Norm to max element
+ // 2.0 0.2 (2.0/10.0)
+ // 8.0 0.8 (8.0/10.0)
+ // 10.0 1.0 (10.0/10.0)
+ normalize(positiveData, normalizedData_inf, 1.0, 0.0, NORM_INF);
+
+ // Norm to range [0.0;1.0]
+ // 2.0 0.0 (shift to left border)
+ // 8.0 0.75 (6.0/8.0)
+ // 10.0 1.0 (shift to right border)
+ normalize(positiveData, normalizedData_minmax, 1.0, 0.0, NORM_MINMAX);
+
+
+
Parameters:
+
src - input array.
+
dst - output array of the same size as src .
+ normalization.
+ normalization.
+ number of channels as src and the depth =CV_MAT_DEPTH(dtype).
+ SEE: norm, Mat::convertTo, SparseMat::convertTo
public static void normalize(Mat src,
+ Mat dst,
+ double alpha)
+
Normalizes the norm or value range of an array.
+
+ The function cv::normalize normalizes scale and shift the input array elements so that
+ \(\| \texttt{dst} \| _{L_p}= \texttt{alpha}\)
+ (where p=Inf, 1 or 2) when normType=NORM_INF, NORM_L1, or NORM_L2, respectively; or so that
+ \(\min _I \texttt{dst} (I)= \texttt{alpha} , \, \, \max _I \texttt{dst} (I)= \texttt{beta}\)
+
+ when normType=NORM_MINMAX (for dense arrays only). The optional mask specifies a sub-array to be
+ normalized. This means that the norm or min-n-max are calculated over the sub-array, and then this
+ sub-array is modified to be normalized. If you want to only use the mask to calculate the norm or
+ min-max but modify the whole array, you can use norm and Mat::convertTo.
+
+ In case of sparse matrices, only the non-zero values are analyzed and transformed. Because of this,
+ the range transformation for sparse matrices is not allowed since it can shift the zero level.
+
+ Possible usage with some positive example data:
+
+ vector<double> positiveData = { 2.0, 8.0, 10.0 };
+ vector<double> normalizedData_l1, normalizedData_l2, normalizedData_inf, normalizedData_minmax;
+
+ // Norm to probability (total count)
+ // sum(numbers) = 20.0
+ // 2.0 0.1 (2.0/20.0)
+ // 8.0 0.4 (8.0/20.0)
+ // 10.0 0.5 (10.0/20.0)
+ normalize(positiveData, normalizedData_l1, 1.0, 0.0, NORM_L1);
+
+ // Norm to unit vector: ||positiveData|| = 1.0
+ // 2.0 0.15
+ // 8.0 0.62
+ // 10.0 0.77
+ normalize(positiveData, normalizedData_l2, 1.0, 0.0, NORM_L2);
+
+ // Norm to max element
+ // 2.0 0.2 (2.0/10.0)
+ // 8.0 0.8 (8.0/10.0)
+ // 10.0 1.0 (10.0/10.0)
+ normalize(positiveData, normalizedData_inf, 1.0, 0.0, NORM_INF);
+
+ // Norm to range [0.0;1.0]
+ // 2.0 0.0 (shift to left border)
+ // 8.0 0.75 (6.0/8.0)
+ // 10.0 1.0 (shift to right border)
+ normalize(positiveData, normalizedData_minmax, 1.0, 0.0, NORM_MINMAX);
+
+
+
Parameters:
+
src - input array.
+
dst - output array of the same size as src .
+
alpha - norm value to normalize to or the lower range boundary in case of the range
+ normalization.
+ normalization.
+ number of channels as src and the depth =CV_MAT_DEPTH(dtype).
+ SEE: norm, Mat::convertTo, SparseMat::convertTo
public static void normalize(Mat src,
+ Mat dst,
+ double alpha,
+ double beta)
+
Normalizes the norm or value range of an array.
+
+ The function cv::normalize normalizes scale and shift the input array elements so that
+ \(\| \texttt{dst} \| _{L_p}= \texttt{alpha}\)
+ (where p=Inf, 1 or 2) when normType=NORM_INF, NORM_L1, or NORM_L2, respectively; or so that
+ \(\min _I \texttt{dst} (I)= \texttt{alpha} , \, \, \max _I \texttt{dst} (I)= \texttt{beta}\)
+
+ when normType=NORM_MINMAX (for dense arrays only). The optional mask specifies a sub-array to be
+ normalized. This means that the norm or min-n-max are calculated over the sub-array, and then this
+ sub-array is modified to be normalized. If you want to only use the mask to calculate the norm or
+ min-max but modify the whole array, you can use norm and Mat::convertTo.
+
+ In case of sparse matrices, only the non-zero values are analyzed and transformed. Because of this,
+ the range transformation for sparse matrices is not allowed since it can shift the zero level.
+
+ Possible usage with some positive example data:
+
+ vector<double> positiveData = { 2.0, 8.0, 10.0 };
+ vector<double> normalizedData_l1, normalizedData_l2, normalizedData_inf, normalizedData_minmax;
+
+ // Norm to probability (total count)
+ // sum(numbers) = 20.0
+ // 2.0 0.1 (2.0/20.0)
+ // 8.0 0.4 (8.0/20.0)
+ // 10.0 0.5 (10.0/20.0)
+ normalize(positiveData, normalizedData_l1, 1.0, 0.0, NORM_L1);
+
+ // Norm to unit vector: ||positiveData|| = 1.0
+ // 2.0 0.15
+ // 8.0 0.62
+ // 10.0 0.77
+ normalize(positiveData, normalizedData_l2, 1.0, 0.0, NORM_L2);
+
+ // Norm to max element
+ // 2.0 0.2 (2.0/10.0)
+ // 8.0 0.8 (8.0/10.0)
+ // 10.0 1.0 (10.0/10.0)
+ normalize(positiveData, normalizedData_inf, 1.0, 0.0, NORM_INF);
+
+ // Norm to range [0.0;1.0]
+ // 2.0 0.0 (shift to left border)
+ // 8.0 0.75 (6.0/8.0)
+ // 10.0 1.0 (shift to right border)
+ normalize(positiveData, normalizedData_minmax, 1.0, 0.0, NORM_MINMAX);
+
+
+
Parameters:
+
src - input array.
+
dst - output array of the same size as src .
+
alpha - norm value to normalize to or the lower range boundary in case of the range
+ normalization.
+
beta - upper range boundary in case of the range normalization; it is not used for the norm
+ normalization.
+ number of channels as src and the depth =CV_MAT_DEPTH(dtype).
+ SEE: norm, Mat::convertTo, SparseMat::convertTo
public static void normalize(Mat src,
+ Mat dst,
+ double alpha,
+ double beta,
+ int norm_type)
+
Normalizes the norm or value range of an array.
+
+ The function cv::normalize normalizes scale and shift the input array elements so that
+ \(\| \texttt{dst} \| _{L_p}= \texttt{alpha}\)
+ (where p=Inf, 1 or 2) when normType=NORM_INF, NORM_L1, or NORM_L2, respectively; or so that
+ \(\min _I \texttt{dst} (I)= \texttt{alpha} , \, \, \max _I \texttt{dst} (I)= \texttt{beta}\)
+
+ when normType=NORM_MINMAX (for dense arrays only). The optional mask specifies a sub-array to be
+ normalized. This means that the norm or min-n-max are calculated over the sub-array, and then this
+ sub-array is modified to be normalized. If you want to only use the mask to calculate the norm or
+ min-max but modify the whole array, you can use norm and Mat::convertTo.
+
+ In case of sparse matrices, only the non-zero values are analyzed and transformed. Because of this,
+ the range transformation for sparse matrices is not allowed since it can shift the zero level.
+
+ Possible usage with some positive example data:
+
+ vector<double> positiveData = { 2.0, 8.0, 10.0 };
+ vector<double> normalizedData_l1, normalizedData_l2, normalizedData_inf, normalizedData_minmax;
+
+ // Norm to probability (total count)
+ // sum(numbers) = 20.0
+ // 2.0 0.1 (2.0/20.0)
+ // 8.0 0.4 (8.0/20.0)
+ // 10.0 0.5 (10.0/20.0)
+ normalize(positiveData, normalizedData_l1, 1.0, 0.0, NORM_L1);
+
+ // Norm to unit vector: ||positiveData|| = 1.0
+ // 2.0 0.15
+ // 8.0 0.62
+ // 10.0 0.77
+ normalize(positiveData, normalizedData_l2, 1.0, 0.0, NORM_L2);
+
+ // Norm to max element
+ // 2.0 0.2 (2.0/10.0)
+ // 8.0 0.8 (8.0/10.0)
+ // 10.0 1.0 (10.0/10.0)
+ normalize(positiveData, normalizedData_inf, 1.0, 0.0, NORM_INF);
+
+ // Norm to range [0.0;1.0]
+ // 2.0 0.0 (shift to left border)
+ // 8.0 0.75 (6.0/8.0)
+ // 10.0 1.0 (shift to right border)
+ normalize(positiveData, normalizedData_minmax, 1.0, 0.0, NORM_MINMAX);
+
+
+
Parameters:
+
src - input array.
+
dst - output array of the same size as src .
+
alpha - norm value to normalize to or the lower range boundary in case of the range
+ normalization.
+
beta - upper range boundary in case of the range normalization; it is not used for the norm
+ normalization.
+
norm_type - normalization type (see cv::NormTypes).
+ number of channels as src and the depth =CV_MAT_DEPTH(dtype).
+ SEE: norm, Mat::convertTo, SparseMat::convertTo
public static void normalize(Mat src,
+ Mat dst,
+ double alpha,
+ double beta,
+ int norm_type,
+ int dtype)
+
Normalizes the norm or value range of an array.
+
+ The function cv::normalize normalizes scale and shift the input array elements so that
+ \(\| \texttt{dst} \| _{L_p}= \texttt{alpha}\)
+ (where p=Inf, 1 or 2) when normType=NORM_INF, NORM_L1, or NORM_L2, respectively; or so that
+ \(\min _I \texttt{dst} (I)= \texttt{alpha} , \, \, \max _I \texttt{dst} (I)= \texttt{beta}\)
+
+ when normType=NORM_MINMAX (for dense arrays only). The optional mask specifies a sub-array to be
+ normalized. This means that the norm or min-n-max are calculated over the sub-array, and then this
+ sub-array is modified to be normalized. If you want to only use the mask to calculate the norm or
+ min-max but modify the whole array, you can use norm and Mat::convertTo.
+
+ In case of sparse matrices, only the non-zero values are analyzed and transformed. Because of this,
+ the range transformation for sparse matrices is not allowed since it can shift the zero level.
+
+ Possible usage with some positive example data:
+
+ vector<double> positiveData = { 2.0, 8.0, 10.0 };
+ vector<double> normalizedData_l1, normalizedData_l2, normalizedData_inf, normalizedData_minmax;
+
+ // Norm to probability (total count)
+ // sum(numbers) = 20.0
+ // 2.0 0.1 (2.0/20.0)
+ // 8.0 0.4 (8.0/20.0)
+ // 10.0 0.5 (10.0/20.0)
+ normalize(positiveData, normalizedData_l1, 1.0, 0.0, NORM_L1);
+
+ // Norm to unit vector: ||positiveData|| = 1.0
+ // 2.0 0.15
+ // 8.0 0.62
+ // 10.0 0.77
+ normalize(positiveData, normalizedData_l2, 1.0, 0.0, NORM_L2);
+
+ // Norm to max element
+ // 2.0 0.2 (2.0/10.0)
+ // 8.0 0.8 (8.0/10.0)
+ // 10.0 1.0 (10.0/10.0)
+ normalize(positiveData, normalizedData_inf, 1.0, 0.0, NORM_INF);
+
+ // Norm to range [0.0;1.0]
+ // 2.0 0.0 (shift to left border)
+ // 8.0 0.75 (6.0/8.0)
+ // 10.0 1.0 (shift to right border)
+ normalize(positiveData, normalizedData_minmax, 1.0, 0.0, NORM_MINMAX);
+
+
+
Parameters:
+
src - input array.
+
dst - output array of the same size as src .
+
alpha - norm value to normalize to or the lower range boundary in case of the range
+ normalization.
+
beta - upper range boundary in case of the range normalization; it is not used for the norm
+ normalization.
+
norm_type - normalization type (see cv::NormTypes).
+
dtype - when negative, the output array has the same type as src; otherwise, it has the same
+ number of channels as src and the depth =CV_MAT_DEPTH(dtype).
+ SEE: norm, Mat::convertTo, SparseMat::convertTo
public static void normalize(Mat src,
+ Mat dst,
+ double alpha,
+ double beta,
+ int norm_type,
+ int dtype,
+ Mat mask)
+
Normalizes the norm or value range of an array.
+
+ The function cv::normalize normalizes scale and shift the input array elements so that
+ \(\| \texttt{dst} \| _{L_p}= \texttt{alpha}\)
+ (where p=Inf, 1 or 2) when normType=NORM_INF, NORM_L1, or NORM_L2, respectively; or so that
+ \(\min _I \texttt{dst} (I)= \texttt{alpha} , \, \, \max _I \texttt{dst} (I)= \texttt{beta}\)
+
+ when normType=NORM_MINMAX (for dense arrays only). The optional mask specifies a sub-array to be
+ normalized. This means that the norm or min-n-max are calculated over the sub-array, and then this
+ sub-array is modified to be normalized. If you want to only use the mask to calculate the norm or
+ min-max but modify the whole array, you can use norm and Mat::convertTo.
+
+ In case of sparse matrices, only the non-zero values are analyzed and transformed. Because of this,
+ the range transformation for sparse matrices is not allowed since it can shift the zero level.
+
+ Possible usage with some positive example data:
+
+ vector<double> positiveData = { 2.0, 8.0, 10.0 };
+ vector<double> normalizedData_l1, normalizedData_l2, normalizedData_inf, normalizedData_minmax;
+
+ // Norm to probability (total count)
+ // sum(numbers) = 20.0
+ // 2.0 0.1 (2.0/20.0)
+ // 8.0 0.4 (8.0/20.0)
+ // 10.0 0.5 (10.0/20.0)
+ normalize(positiveData, normalizedData_l1, 1.0, 0.0, NORM_L1);
+
+ // Norm to unit vector: ||positiveData|| = 1.0
+ // 2.0 0.15
+ // 8.0 0.62
+ // 10.0 0.77
+ normalize(positiveData, normalizedData_l2, 1.0, 0.0, NORM_L2);
+
+ // Norm to max element
+ // 2.0 0.2 (2.0/10.0)
+ // 8.0 0.8 (8.0/10.0)
+ // 10.0 1.0 (10.0/10.0)
+ normalize(positiveData, normalizedData_inf, 1.0, 0.0, NORM_INF);
+
+ // Norm to range [0.0;1.0]
+ // 2.0 0.0 (shift to left border)
+ // 8.0 0.75 (6.0/8.0)
+ // 10.0 1.0 (shift to right border)
+ normalize(positiveData, normalizedData_minmax, 1.0, 0.0, NORM_MINMAX);
+
+
+
Parameters:
+
src - input array.
+
dst - output array of the same size as src .
+
alpha - norm value to normalize to or the lower range boundary in case of the range
+ normalization.
+
beta - upper range boundary in case of the range normalization; it is not used for the norm
+ normalization.
+
norm_type - normalization type (see cv::NormTypes).
+
dtype - when negative, the output array has the same type as src; otherwise, it has the same
+ number of channels as src and the depth =CV_MAT_DEPTH(dtype).
public static void perspectiveTransform(Mat src,
+ Mat dst,
+ Mat m)
+
Performs the perspective matrix transformation of vectors.
+
+ The function cv::perspectiveTransform transforms every element of src by
+ treating it as a 2D or 3D vector, in the following way:
+ \((x, y, z) \rightarrow (x'/w, y'/w, z'/w)\)
+ where
+ \((x', y', z', w') = \texttt{mat} \cdot \begin{bmatrix} x & y & z & 1 \end{bmatrix}\)
+ and
+ \(w = \fork{w'}{if \(w' \ne 0\)}{\infty}{otherwise}\)
+
+ Here a 3D vector transformation is shown. In case of a 2D vector
+ transformation, the z component is omitted.
+
+ Note: The function transforms a sparse set of 2D or 3D vectors. If you
+ want to transform an image using perspective transformation, use
+ warpPerspective . If you have an inverse problem, that is, you want to
+ compute the most probable perspective transformation out of several
+ pairs of corresponding points, you can use getPerspectiveTransform or
+ findHomography .
+
+
Parameters:
+
src - input two-channel or three-channel floating-point array; each
+ element is a 2D/3D vector to be transformed.
+
dst - output array of the same size and type as src.
+
m - 3x3 or 4x4 floating-point transformation matrix.
+ SEE: transform, warpPerspective, getPerspectiveTransform, findHomography
public static void phase(Mat x,
+ Mat y,
+ Mat angle)
+
Calculates the rotation angle of 2D vectors.
+
+ The function cv::phase calculates the rotation angle of each 2D vector that
+ is formed from the corresponding elements of x and y :
+ \(\texttt{angle} (I) = \texttt{atan2} ( \texttt{y} (I), \texttt{x} (I))\)
+
+ The angle estimation accuracy is about 0.3 degrees. When x(I)=y(I)=0 ,
+ the corresponding angle(I) is set to 0.
+
+
Parameters:
+
x - input floating-point array of x-coordinates of 2D vectors.
+
y - input array of y-coordinates of 2D vectors; it must have the
+ same size and the same type as x.
+
angle - output array of vector angles; it has the same size and
+ same type as x .
+ degrees, otherwise, they are measured in radians.
public static void phase(Mat x,
+ Mat y,
+ Mat angle,
+ boolean angleInDegrees)
+
Calculates the rotation angle of 2D vectors.
+
+ The function cv::phase calculates the rotation angle of each 2D vector that
+ is formed from the corresponding elements of x and y :
+ \(\texttt{angle} (I) = \texttt{atan2} ( \texttt{y} (I), \texttt{x} (I))\)
+
+ The angle estimation accuracy is about 0.3 degrees. When x(I)=y(I)=0 ,
+ the corresponding angle(I) is set to 0.
+
+
Parameters:
+
x - input floating-point array of x-coordinates of 2D vectors.
+
y - input array of y-coordinates of 2D vectors; it must have the
+ same size and the same type as x.
+
angle - output array of vector angles; it has the same size and
+ same type as x .
+
angleInDegrees - when true, the function calculates the angle in
+ degrees, otherwise, they are measured in radians.
public static void polarToCart(Mat magnitude,
+ Mat angle,
+ Mat x,
+ Mat y)
+
Calculates x and y coordinates of 2D vectors from their magnitude and angle.
+
+ The function cv::polarToCart calculates the Cartesian coordinates of each 2D
+ vector represented by the corresponding elements of magnitude and angle:
+ \(\begin{array}{l} \texttt{x} (I) = \texttt{magnitude} (I) \cos ( \texttt{angle} (I)) \\ \texttt{y} (I) = \texttt{magnitude} (I) \sin ( \texttt{angle} (I)) \\ \end{array}\)
+
+ The relative accuracy of the estimated coordinates is about 1e-6.
+
+
Parameters:
+
magnitude - input floating-point array of magnitudes of 2D vectors;
+ it can be an empty matrix (=Mat()), in this case, the function assumes
+ that all the magnitudes are =1; if it is not empty, it must have the
+ same size and type as angle.
+
angle - input floating-point array of angles of 2D vectors.
+
x - output array of x-coordinates of 2D vectors; it has the same
+ size and type as angle.
+
y - output array of y-coordinates of 2D vectors; it has the same
+ size and type as angle.
+ degrees, otherwise, they are measured in radians.
+ SEE: cartToPolar, magnitude, phase, exp, log, pow, sqrt
public static void polarToCart(Mat magnitude,
+ Mat angle,
+ Mat x,
+ Mat y,
+ boolean angleInDegrees)
+
Calculates x and y coordinates of 2D vectors from their magnitude and angle.
+
+ The function cv::polarToCart calculates the Cartesian coordinates of each 2D
+ vector represented by the corresponding elements of magnitude and angle:
+ \(\begin{array}{l} \texttt{x} (I) = \texttt{magnitude} (I) \cos ( \texttt{angle} (I)) \\ \texttt{y} (I) = \texttt{magnitude} (I) \sin ( \texttt{angle} (I)) \\ \end{array}\)
+
+ The relative accuracy of the estimated coordinates is about 1e-6.
+
+
Parameters:
+
magnitude - input floating-point array of magnitudes of 2D vectors;
+ it can be an empty matrix (=Mat()), in this case, the function assumes
+ that all the magnitudes are =1; if it is not empty, it must have the
+ same size and type as angle.
+
angle - input floating-point array of angles of 2D vectors.
+
x - output array of x-coordinates of 2D vectors; it has the same
+ size and type as angle.
+
y - output array of y-coordinates of 2D vectors; it has the same
+ size and type as angle.
+
angleInDegrees - when true, the input angles are measured in
+ degrees, otherwise, they are measured in radians.
+ SEE: cartToPolar, magnitude, phase, exp, log, pow, sqrt
public static void pow(Mat src,
+ double power,
+ Mat dst)
+
Raises every array element to a power.
+
+ The function cv::pow raises every element of the input array to power :
+ \(\texttt{dst} (I) = \fork{\texttt{src}(I)^{power}}{if \(\texttt{power}\) is integer}{|\texttt{src}(I)|^{power}}{otherwise}\)
+
+ So, for a non-integer power exponent, the absolute values of input array
+ elements are used. However, it is possible to get true values for
+ negative values using some extra operations. In the example below,
+ computing the 5th root of array src shows:
+
+ Mat mask = src < 0;
+ pow(src, 1./5, dst);
+ subtract(Scalar::all(0), dst, dst, mask);
+
+ For some values of power, such as integer values, 0.5 and -0.5,
+ specialized faster algorithms are used.
+
+ Special values (NaN, Inf) are not handled.
+
+
Parameters:
+
src - input array.
+
power - exponent of power.
+
dst - output array of the same size and type as src.
+ SEE: sqrt, exp, log, cartToPolar, polarToCart
Computes the Peak Signal-to-Noise Ratio (PSNR) image quality metric.
+
+ This function calculates the Peak Signal-to-Noise Ratio (PSNR) image quality metric in decibels (dB),
+ between two input arrays src1 and src2. The arrays must have the same type.
+
+ The PSNR is calculated as follows:
+
+ \(
+ \texttt{PSNR} = 10 \cdot \log_{10}{\left( \frac{R^2}{MSE} \right) }
+ \)
+
+ where R is the maximum integer value of depth (e.g. 255 in the case of CV_8U data)
+ and MSE is the mean squared error between the two arrays.
+
+
Parameters:
+
src1 - first input array.
+
src2 - second input array of the same size as src1.
public static double PSNR(Mat src1,
+ Mat src2,
+ double R)
+
Computes the Peak Signal-to-Noise Ratio (PSNR) image quality metric.
+
+ This function calculates the Peak Signal-to-Noise Ratio (PSNR) image quality metric in decibels (dB),
+ between two input arrays src1 and src2. The arrays must have the same type.
+
+ The PSNR is calculated as follows:
+
+ \(
+ \texttt{PSNR} = 10 \cdot \log_{10}{\left( \frac{R^2}{MSE} \right) }
+ \)
+
+ where R is the maximum integer value of depth (e.g. 255 in the case of CV_8U data)
+ and MSE is the mean squared error between the two arrays.
+
+
Parameters:
+
src1 - first input array.
+
src2 - second input array of the same size as src1.
Fills the array with normally distributed random numbers.
+
+ The function cv::randn fills the matrix dst with normally distributed random numbers with the specified
+ mean vector and the standard deviation matrix. The generated random numbers are clipped to fit the
+ value range of the output array data type.
+
+
Parameters:
+
dst - output array of random numbers; the array must be pre-allocated and have 1 to 4 channels.
+
mean - mean value (expectation) of the generated random numbers.
+
stddev - standard deviation of the generated random numbers; it can be either a vector (in
+ which case a diagonal standard deviation matrix is assumed) or a square matrix.
+ SEE: RNG, randu
Shuffles the array elements randomly.
+
+ The function cv::randShuffle shuffles the specified 1D array by randomly choosing pairs of elements and
+ swapping them. The number of such swap operations will be dst.rows\*dst.cols\*iterFactor .
public static void randShuffle(Mat dst,
+ double iterFactor)
+
Shuffles the array elements randomly.
+
+ The function cv::randShuffle shuffles the specified 1D array by randomly choosing pairs of elements and
+ swapping them. The number of such swap operations will be dst.rows\*dst.cols\*iterFactor .
+
+
Parameters:
+
dst - input/output numerical 1D array.
+
iterFactor - scale factor that determines the number of random swap operations (see the details
+ below).
+ instead.
+ SEE: RNG, sort
Generates a single uniformly-distributed random number or an array of random numbers.
+
+ Non-template variant of the function fills the matrix dst with uniformly-distributed
+ random numbers from the specified range:
+ \(\texttt{low} _c \leq \texttt{dst} (I)_c < \texttt{high} _c\)
+
+
Parameters:
+
dst - output array of random numbers; the array must be pre-allocated.
+
low - inclusive lower boundary of the generated random numbers.
+
high - exclusive upper boundary of the generated random numbers.
+ SEE: RNG, randn, theRNG
public static void reduce(Mat src,
+ Mat dst,
+ int dim,
+ int rtype)
+
Reduces a matrix to a vector.
+
+ The function #reduce reduces the matrix to a vector by treating the matrix rows/columns as a set of
+ 1D vectors and performing the specified operation on the vectors until a single row/column is
+ obtained. For example, the function can be used to compute horizontal and vertical projections of a
+ raster image. In case of #REDUCE_MAX and #REDUCE_MIN , the output image should have the same type as the source one.
+ In case of #REDUCE_SUM, #REDUCE_SUM2 and #REDUCE_AVG , the output may have a larger element bit-depth to preserve accuracy.
+ And multi-channel arrays are also supported in these two reduction modes.
+
+ The following code demonstrates its usage for a single channel matrix.
+ SNIPPET: snippets/core_reduce.cpp example
+
+ And the following code demonstrates its usage for a two-channel matrix.
+ SNIPPET: snippets/core_reduce.cpp example2
+
+
Parameters:
+
src - input 2D matrix.
+
dst - output vector. Its size and type is defined by dim and dtype parameters.
+
dim - dimension index along which the matrix is reduced. 0 means that the matrix is reduced to
+ a single row. 1 means that the matrix is reduced to a single column.
+
rtype - reduction operation that could be one of #ReduceTypes
+ otherwise, its type will be CV_MAKE_TYPE(CV_MAT_DEPTH(dtype), src.channels()).
+ SEE: repeat, reduceArgMin, reduceArgMax
public static void reduce(Mat src,
+ Mat dst,
+ int dim,
+ int rtype,
+ int dtype)
+
Reduces a matrix to a vector.
+
+ The function #reduce reduces the matrix to a vector by treating the matrix rows/columns as a set of
+ 1D vectors and performing the specified operation on the vectors until a single row/column is
+ obtained. For example, the function can be used to compute horizontal and vertical projections of a
+ raster image. In case of #REDUCE_MAX and #REDUCE_MIN , the output image should have the same type as the source one.
+ In case of #REDUCE_SUM, #REDUCE_SUM2 and #REDUCE_AVG , the output may have a larger element bit-depth to preserve accuracy.
+ And multi-channel arrays are also supported in these two reduction modes.
+
+ The following code demonstrates its usage for a single channel matrix.
+ SNIPPET: snippets/core_reduce.cpp example
+
+ And the following code demonstrates its usage for a two-channel matrix.
+ SNIPPET: snippets/core_reduce.cpp example2
+
+
Parameters:
+
src - input 2D matrix.
+
dst - output vector. Its size and type is defined by dim and dtype parameters.
+
dim - dimension index along which the matrix is reduced. 0 means that the matrix is reduced to
+ a single row. 1 means that the matrix is reduced to a single column.
+
rtype - reduction operation that could be one of #ReduceTypes
+
dtype - when negative, the output vector will have the same type as the input matrix,
+ otherwise, its type will be CV_MAKE_TYPE(CV_MAT_DEPTH(dtype), src.channels()).
+ SEE: repeat, reduceArgMin, reduceArgMax
public static void reduceArgMax(Mat src,
+ Mat dst,
+ int axis)
+
Finds indices of max elements along provided axis
+
+ Note:
+ - If input or output array is not continuous, this function will create an internal copy.
+ - NaN handling is left unspecified, see patchNaNs().
+ - The returned index is always in bounds of input matrix.
+
+
Parameters:
+
src - input single-channel array.
+
dst - output array of type CV_32SC1 with the same dimensionality as src,
+ except for axis being reduced - it should be set to 1.
public static void reduceArgMax(Mat src,
+ Mat dst,
+ int axis,
+ boolean lastIndex)
+
Finds indices of max elements along provided axis
+
+ Note:
+ - If input or output array is not continuous, this function will create an internal copy.
+ - NaN handling is left unspecified, see patchNaNs().
+ - The returned index is always in bounds of input matrix.
+
+
Parameters:
+
src - input single-channel array.
+
dst - output array of type CV_32SC1 with the same dimensionality as src,
+ except for axis being reduced - it should be set to 1.
+
lastIndex - whether to get the index of first or last occurrence of max.
public static void reduceArgMin(Mat src,
+ Mat dst,
+ int axis)
+
Finds indices of min elements along provided axis
+
+ Note:
+ - If input or output array is not continuous, this function will create an internal copy.
+ - NaN handling is left unspecified, see patchNaNs().
+ - The returned index is always in bounds of input matrix.
+
+
Parameters:
+
src - input single-channel array.
+
dst - output array of type CV_32SC1 with the same dimensionality as src,
+ except for axis being reduced - it should be set to 1.
public static void reduceArgMin(Mat src,
+ Mat dst,
+ int axis,
+ boolean lastIndex)
+
Finds indices of min elements along provided axis
+
+ Note:
+ - If input or output array is not continuous, this function will create an internal copy.
+ - NaN handling is left unspecified, see patchNaNs().
+ - The returned index is always in bounds of input matrix.
+
+
Parameters:
+
src - input single-channel array.
+
dst - output array of type CV_32SC1 with the same dimensionality as src,
+ except for axis being reduced - it should be set to 1.
+
lastIndex - whether to get the index of first or last occurrence of min.
public static void repeat(Mat src,
+ int ny,
+ int nx,
+ Mat dst)
+
Fills the output array with repeated copies of the input array.
+
+ The function cv::repeat duplicates the input array one or more times along each of the two axes:
+ \(\texttt{dst} _{ij}= \texttt{src} _{i\mod src.rows, \; j\mod src.cols }\)
+ The second variant of the function is more convenient to use with REF: MatrixExpressions.
+
+
Parameters:
+
src - input array to replicate.
+
ny - Flag to specify how many times the src is repeated along the
+ vertical axis.
+
nx - Flag to specify how many times the src is repeated along the
+ horizontal axis.
+
dst - output array of the same type as src.
+ SEE: cv::reduce
public static void rotate(Mat src,
+ Mat dst,
+ int rotateCode)
+
Rotates a 2D array in multiples of 90 degrees.
+ The function cv::rotate rotates the array in one of three different ways:
+ Rotate by 90 degrees clockwise (rotateCode = ROTATE_90_CLOCKWISE).
+ Rotate by 180 degrees clockwise (rotateCode = ROTATE_180).
+ Rotate by 270 degrees clockwise (rotateCode = ROTATE_90_COUNTERCLOCKWISE).
+
+
Parameters:
+
src - input array.
+
dst - output array of the same type as src. The size is the same with ROTATE_180,
+ and the rows and cols are switched for ROTATE_90_CLOCKWISE and ROTATE_90_COUNTERCLOCKWISE.
+
rotateCode - an enum to specify how to rotate the array; see the enum #RotateFlags
+ SEE: transpose , repeat , completeSymm, flip, RotateFlags
public static void scaleAdd(Mat src1,
+ double alpha,
+ Mat src2,
+ Mat dst)
+
Calculates the sum of a scaled array and another array.
+
+ The function scaleAdd is one of the classical primitive linear algebra operations, known as DAXPY
+ or SAXPY in [BLAS](http://en.wikipedia.org/wiki/Basic_Linear_Algebra_Subprograms). It calculates
+ the sum of a scaled array and another array:
+ \(\texttt{dst} (I)= \texttt{scale} \cdot \texttt{src1} (I) + \texttt{src2} (I)\)
+ The function can also be emulated with a matrix expression, for example:
+
+ Mat A(3, 3, CV_64F);
+ ...
+ A.row(0) = A.row(1)*2 + A.row(2);
+
+
+
Parameters:
+
src1 - first input array.
+
alpha - scale factor for the first array.
+
src2 - second input array of the same size and type as src1.
+
dst - output array of the same size and type as src1.
+ SEE: add, addWeighted, subtract, Mat::dot, Mat::convertTo
Initializes a scaled identity matrix.
+
+ The function cv::setIdentity initializes a scaled identity matrix:
+ \(\texttt{mtx} (i,j)= \fork{\texttt{value}}{ if \(i=j\)}{0}{otherwise}\)
+
+ The function can also be emulated using the matrix initializers and the
+ matrix expressions:
+
+ Mat A = Mat::eye(4, 3, CV_32F)*5;
+ // A will be set to [[5, 0, 0], [0, 5, 0], [0, 0, 5], [0, 0, 0]]
+
public static void setIdentity(Mat mtx,
+ Scalar s)
+
Initializes a scaled identity matrix.
+
+ The function cv::setIdentity initializes a scaled identity matrix:
+ \(\texttt{mtx} (i,j)= \fork{\texttt{value}}{ if \(i=j\)}{0}{otherwise}\)
+
+ The function can also be emulated using the matrix initializers and the
+ matrix expressions:
+
+ Mat A = Mat::eye(4, 3, CV_32F)*5;
+ // A will be set to [[5, 0, 0], [0, 5, 0], [0, 0, 5], [0, 0, 0]]
+
+
+
Parameters:
+
mtx - matrix to initialize (not necessarily square).
+
s - value to assign to diagonal elements.
+ SEE: Mat::zeros, Mat::ones, Mat::setTo, Mat::operator=
OpenCV will try to set the number of threads for subsequent parallel regions.
+
+ If threads == 1, OpenCV will disable threading optimizations and run all it's functions
+ sequentially. Passing threads < 0 will reset threads number to system default.
+ The function is not thread-safe. It must not be called in parallel region or concurrent threads.
+
+ OpenCV will try to run its functions with specified threads number, but some behaviour differs from
+ framework:
+
+
+ TBB - User-defined parallel constructions will run with the same threads number, if
+ another is not specified. If later on user creates his own scheduler, OpenCV will use it.
+
+
+ OpenMP - No special defined behaviour.
+
+
+ Concurrency - If threads == 1, OpenCV will disable threading optimizations and run its
+ functions sequentially.
+
+
+ GCD - Supports only values <= 0.
+
+
+ C= - No special defined behaviour.
+
+
+
+
Parameters:
+
nthreads - Number of threads used by OpenCV.
+ SEE: getNumThreads, getThreadNum
Enables or disables the optimized code.
+
+ The function can be used to dynamically turn on and off optimized dispatched code (code that uses SSE4.2, AVX/AVX2,
+ and other instructions on the platforms that support it). It sets a global flag that is further
+ checked by OpenCV functions. Since the flag is not checked in the inner OpenCV loops, it is only
+ safe to call the function on the very top level in your application where you can be sure that no
+ other OpenCV function is currently executed.
+
+ By default, the optimized code is enabled unless you disable it in CMake. The current status can be
+ retrieved using useOptimized.
+
+
Parameters:
+
onoff - The boolean flag specifying whether the optimized code should be used (onoff=true)
+ or not (onoff=false).
public static boolean solve(Mat src1,
+ Mat src2,
+ Mat dst)
+
Solves one or more linear systems or least-squares problems.
+
+ The function cv::solve solves a linear system or least-squares problem (the
+ latter is possible with SVD or QR methods, or by specifying the flag
+ #DECOMP_NORMAL ):
+ \(\texttt{dst} = \arg \min _X \| \texttt{src1} \cdot \texttt{X} - \texttt{src2} \|\)
+
+ If #DECOMP_LU or #DECOMP_CHOLESKY method is used, the function returns 1
+ if src1 (or \(\texttt{src1}^T\texttt{src1}\) ) is non-singular. Otherwise,
+ it returns 0. In the latter case, dst is not valid. Other methods find a
+ pseudo-solution in case of a singular left-hand side part.
+
+ Note: If you want to find a unity-norm solution of an under-defined
+ singular system \(\texttt{src1}\cdot\texttt{dst}=0\) , the function solve
+ will not do the work. Use SVD::solveZ instead.
+
+
Parameters:
+
src1 - input matrix on the left-hand side of the system.
+
src2 - input matrix on the right-hand side of the system.
public static boolean solve(Mat src1,
+ Mat src2,
+ Mat dst,
+ int flags)
+
Solves one or more linear systems or least-squares problems.
+
+ The function cv::solve solves a linear system or least-squares problem (the
+ latter is possible with SVD or QR methods, or by specifying the flag
+ #DECOMP_NORMAL ):
+ \(\texttt{dst} = \arg \min _X \| \texttt{src1} \cdot \texttt{X} - \texttt{src2} \|\)
+
+ If #DECOMP_LU or #DECOMP_CHOLESKY method is used, the function returns 1
+ if src1 (or \(\texttt{src1}^T\texttt{src1}\) ) is non-singular. Otherwise,
+ it returns 0. In the latter case, dst is not valid. Other methods find a
+ pseudo-solution in case of a singular left-hand side part.
+
+ Note: If you want to find a unity-norm solution of an under-defined
+ singular system \(\texttt{src1}\cdot\texttt{dst}=0\) , the function solve
+ will not do the work. Use SVD::solveZ instead.
+
+
Parameters:
+
src1 - input matrix on the left-hand side of the system.
+
src2 - input matrix on the right-hand side of the system.
public static double solvePoly(Mat coeffs,
+ Mat roots)
+
Finds the real or complex roots of a polynomial equation.
+
+ The function cv::solvePoly finds real and complex roots of a polynomial equation:
+ \(\texttt{coeffs} [n] x^{n} + \texttt{coeffs} [n-1] x^{n-1} + ... + \texttt{coeffs} [1] x + \texttt{coeffs} [0] = 0\)
public static double solvePoly(Mat coeffs,
+ Mat roots,
+ int maxIters)
+
Finds the real or complex roots of a polynomial equation.
+
+ The function cv::solvePoly finds real and complex roots of a polynomial equation:
+ \(\texttt{coeffs} [n] x^{n} + \texttt{coeffs} [n-1] x^{n-1} + ... + \texttt{coeffs} [1] x + \texttt{coeffs} [0] = 0\)
+
+
Parameters:
+
coeffs - array of polynomial coefficients.
+
roots - output (complex) array of roots.
+
maxIters - maximum number of iterations the algorithm does.
public static void sort(Mat src,
+ Mat dst,
+ int flags)
+
Sorts each row or each column of a matrix.
+
+ The function cv::sort sorts each matrix row or each matrix column in
+ ascending or descending order. So you should pass two operation flags to
+ get desired behaviour. If you want to sort matrix rows or columns
+ lexicographically, you can use STL std::sort generic function with the
+ proper comparison predicate.
+
+
Parameters:
+
src - input single-channel array.
+
dst - output array of the same size and type as src.
+
flags - operation flags, a combination of #SortFlags
+ SEE: sortIdx, randShuffle
public static void sortIdx(Mat src,
+ Mat dst,
+ int flags)
+
Sorts each row or each column of a matrix.
+
+ The function cv::sortIdx sorts each matrix row or each matrix column in the
+ ascending or descending order. So you should pass two operation flags to
+ get desired behaviour. Instead of reordering the elements themselves, it
+ stores the indices of sorted elements in the output array. For example:
+
+ Mat A = Mat::eye(3,3,CV_32F), B;
+ sortIdx(A, B, SORT_EVERY_ROW + SORT_ASCENDING);
+ // B will probably contain
+ // (because of equal elements in A some permutations are possible):
+ // [[1, 2, 0], [0, 2, 1], [0, 1, 2]]
+
+
+
Parameters:
+
src - input single-channel array.
+
dst - output integer array of the same size as src.
+
flags - operation flags that could be a combination of cv::SortFlags
+ SEE: sort, randShuffle
Calculates a square root of array elements.
+
+ The function cv::sqrt calculates a square root of each input array element.
+ In case of multi-channel arrays, each channel is processed
+ independently. The accuracy is approximately the same as of the built-in
+ std::sqrt .
+
+
Parameters:
+
src - input floating-point array.
+
dst - output array of the same size and type as src.
public static void subtract(Mat src1,
+ Mat src2,
+ Mat dst)
+
Calculates the per-element difference between two arrays or array and a scalar.
+
+ The function subtract calculates:
+
+
+ Difference between two arrays, when both input arrays have the same size and the same number of
+ channels:
+ \(\texttt{dst}(I) = \texttt{saturate} ( \texttt{src1}(I) - \texttt{src2}(I)) \quad \texttt{if mask}(I) \ne0\)
+
+
+ Difference between an array and a scalar, when src2 is constructed from Scalar or has the same
+ number of elements as src1.channels():
+ \(\texttt{dst}(I) = \texttt{saturate} ( \texttt{src1}(I) - \texttt{src2} ) \quad \texttt{if mask}(I) \ne0\)
+
+
+ Difference between a scalar and an array, when src1 is constructed from Scalar or has the same
+ number of elements as src2.channels():
+ \(\texttt{dst}(I) = \texttt{saturate} ( \texttt{src1} - \texttt{src2}(I) ) \quad \texttt{if mask}(I) \ne0\)
+
+
+ The reverse difference between a scalar and an array in the case of SubRS:
+ \(\texttt{dst}(I) = \texttt{saturate} ( \texttt{src2} - \texttt{src1}(I) ) \quad \texttt{if mask}(I) \ne0\)
+ where I is a multi-dimensional index of array elements. In case of multi-channel arrays, each
+ channel is processed independently.
+
+
+
+ The first function in the list above can be replaced with matrix expressions:
+
+ dst = src1 - src2;
+ dst -= src1; // equivalent to subtract(dst, src1, dst);
+
+ The input arrays and the output array can all have the same or different depths. For example, you
+ can subtract to 8-bit unsigned arrays and store the difference in a 16-bit signed array. Depth of
+ the output array is determined by dtype parameter. In the second and third cases above, as well as
+ in the first case, when src1.depth() == src2.depth(), dtype can be set to the default -1. In this
+ case the output array will have the same depth as the input array, be it src1, src2 or both.
+ Note: Saturation is not applied when the output array has the depth CV_32S. You may even get
+ result of an incorrect sign in the case of overflow.
+
+
Parameters:
+
src1 - first input array or a scalar.
+
src2 - second input array or a scalar.
+
dst - output array of the same size and the same number of channels as the input array.
+ of the output array to be changed.
+ SEE: add, addWeighted, scaleAdd, Mat::convertTo
public static void subtract(Mat src1,
+ Mat src2,
+ Mat dst,
+ Mat mask)
+
Calculates the per-element difference between two arrays or array and a scalar.
+
+ The function subtract calculates:
+
+
+ Difference between two arrays, when both input arrays have the same size and the same number of
+ channels:
+ \(\texttt{dst}(I) = \texttt{saturate} ( \texttt{src1}(I) - \texttt{src2}(I)) \quad \texttt{if mask}(I) \ne0\)
+
+
+ Difference between an array and a scalar, when src2 is constructed from Scalar or has the same
+ number of elements as src1.channels():
+ \(\texttt{dst}(I) = \texttt{saturate} ( \texttt{src1}(I) - \texttt{src2} ) \quad \texttt{if mask}(I) \ne0\)
+
+
+ Difference between a scalar and an array, when src1 is constructed from Scalar or has the same
+ number of elements as src2.channels():
+ \(\texttt{dst}(I) = \texttt{saturate} ( \texttt{src1} - \texttt{src2}(I) ) \quad \texttt{if mask}(I) \ne0\)
+
+
+ The reverse difference between a scalar and an array in the case of SubRS:
+ \(\texttt{dst}(I) = \texttt{saturate} ( \texttt{src2} - \texttt{src1}(I) ) \quad \texttt{if mask}(I) \ne0\)
+ where I is a multi-dimensional index of array elements. In case of multi-channel arrays, each
+ channel is processed independently.
+
+
+
+ The first function in the list above can be replaced with matrix expressions:
+
+ dst = src1 - src2;
+ dst -= src1; // equivalent to subtract(dst, src1, dst);
+
+ The input arrays and the output array can all have the same or different depths. For example, you
+ can subtract to 8-bit unsigned arrays and store the difference in a 16-bit signed array. Depth of
+ the output array is determined by dtype parameter. In the second and third cases above, as well as
+ in the first case, when src1.depth() == src2.depth(), dtype can be set to the default -1. In this
+ case the output array will have the same depth as the input array, be it src1, src2 or both.
+ Note: Saturation is not applied when the output array has the depth CV_32S. You may even get
+ result of an incorrect sign in the case of overflow.
+
+
Parameters:
+
src1 - first input array or a scalar.
+
src2 - second input array or a scalar.
+
dst - output array of the same size and the same number of channels as the input array.
+
mask - optional operation mask; this is an 8-bit single channel array that specifies elements
+ of the output array to be changed.
+ SEE: add, addWeighted, scaleAdd, Mat::convertTo
public static void subtract(Mat src1,
+ Mat src2,
+ Mat dst,
+ Mat mask,
+ int dtype)
+
Calculates the per-element difference between two arrays or array and a scalar.
+
+ The function subtract calculates:
+
+
+ Difference between two arrays, when both input arrays have the same size and the same number of
+ channels:
+ \(\texttt{dst}(I) = \texttt{saturate} ( \texttt{src1}(I) - \texttt{src2}(I)) \quad \texttt{if mask}(I) \ne0\)
+
+
+ Difference between an array and a scalar, when src2 is constructed from Scalar or has the same
+ number of elements as src1.channels():
+ \(\texttt{dst}(I) = \texttt{saturate} ( \texttt{src1}(I) - \texttt{src2} ) \quad \texttt{if mask}(I) \ne0\)
+
+
+ Difference between a scalar and an array, when src1 is constructed from Scalar or has the same
+ number of elements as src2.channels():
+ \(\texttt{dst}(I) = \texttt{saturate} ( \texttt{src1} - \texttt{src2}(I) ) \quad \texttt{if mask}(I) \ne0\)
+
+
+ The reverse difference between a scalar and an array in the case of SubRS:
+ \(\texttt{dst}(I) = \texttt{saturate} ( \texttt{src2} - \texttt{src1}(I) ) \quad \texttt{if mask}(I) \ne0\)
+ where I is a multi-dimensional index of array elements. In case of multi-channel arrays, each
+ channel is processed independently.
+
+
+
+ The first function in the list above can be replaced with matrix expressions:
+
+ dst = src1 - src2;
+ dst -= src1; // equivalent to subtract(dst, src1, dst);
+
+ The input arrays and the output array can all have the same or different depths. For example, you
+ can subtract to 8-bit unsigned arrays and store the difference in a 16-bit signed array. Depth of
+ the output array is determined by dtype parameter. In the second and third cases above, as well as
+ in the first case, when src1.depth() == src2.depth(), dtype can be set to the default -1. In this
+ case the output array will have the same depth as the input array, be it src1, src2 or both.
+ Note: Saturation is not applied when the output array has the depth CV_32S. You may even get
+ result of an incorrect sign in the case of overflow.
+
+
Parameters:
+
src1 - first input array or a scalar.
+
src2 - second input array or a scalar.
+
dst - output array of the same size and the same number of channels as the input array.
+
mask - optional operation mask; this is an 8-bit single channel array that specifies elements
+ of the output array to be changed.
+
dtype - optional depth of the output array
+ SEE: add, addWeighted, scaleAdd, Mat::convertTo
Returns the trace of a matrix.
+
+ The function cv::trace returns the sum of the diagonal elements of the
+ matrix mtx .
+ \(\mathrm{tr} ( \texttt{mtx} ) = \sum _i \texttt{mtx} (i,i)\)
public static void transform(Mat src,
+ Mat dst,
+ Mat m)
+
Performs the matrix transformation of every array element.
+
+ The function cv::transform performs the matrix transformation of every
+ element of the array src and stores the results in dst :
+ \(\texttt{dst} (I) = \texttt{m} \cdot \texttt{src} (I)\)
+ (when m.cols=src.channels() ), or
+ \(\texttt{dst} (I) = \texttt{m} \cdot [ \texttt{src} (I); 1]\)
+ (when m.cols=src.channels()+1 )
+
+ Every element of the N -channel array src is interpreted as N -element
+ vector that is transformed using the M x N or M x (N+1) matrix m to
+ M-element vector - the corresponding element of the output array dst .
+
+ The function may be used for geometrical transformation of
+ N -dimensional points, arbitrary linear color space transformation (such
+ as various kinds of RGB to YUV transforms), shuffling the image
+ channels, and so forth.
+
+
Parameters:
+
src - input array that must have as many channels (1 to 4) as
+ m.cols or m.cols-1.
+
dst - output array of the same size and depth as src; it has as
+ many channels as m.rows.
+
m - transformation 2x2 or 2x3 floating-point matrix.
+ SEE: perspectiveTransform, getAffineTransform, estimateAffine2D, warpAffine, warpPerspective
Transposes a matrix.
+
+ The function cv::transpose transposes the matrix src :
+ \(\texttt{dst} (i,j) = \texttt{src} (j,i)\)
+ Note: No complex conjugation is done in case of a complex matrix. It
+ should be done separately if needed.
public static void transposeND(Mat src,
+ MatOfInt order,
+ Mat dst)
+
Transpose for n-dimensional matrices.
+
+ Note: Input should be continuous single-channel matrix.
+
+
Parameters:
+
src - input array.
+
order - a permutation of [0,1,..,N-1] where N is the number of axes of src.
+ The i’th axis of dst will correspond to the axis numbered order[i] of the input.
a Class to measure passing time.
+
+ The class computes passing time by counting the number of ticks per second. That is, the following code computes the
+ execution time in seconds:
+ SNIPPET: snippets/core_various.cpp TickMeter_total
+
+ It is also possible to compute the average time over multiple runs:
+ SNIPPET: snippets/core_various.cpp TickMeter_average
+
+ SEE: getTickCount, getTickFrequency
This is a base class for all more or less complex algorithms in OpenCV
+
+ especially for classes of algorithms, for which there can be multiple implementations.
This class represents high-level API for classification models.
+
+ ClassificationModel allows to set params for preprocessing input image.
+ ClassificationModel creates net from file with trained weights and config,
+ sets preprocessing input, runs forward pass and return top-1 prediction.
Get enable/disable softmax post processing option.
+
+ This option defaults to false, softmax post processing is not applied within the classify() function.
Set enable/disable softmax post processing option.
+
+ If this option is true, softmax is applied after forward inference within the classify() function
+ to convert the confidences range to [0.0-1.0].
+ This function allows you to toggle this behavior.
+ Please turn true when not contain softmax layer in model.
+
+
Parameters:
+
enable - Set enable softmax post processing within the classify() function.
This class represents high-level API for object detection networks.
+
+ DetectionModel allows to set params for preprocessing input image.
+ DetectionModel creates net from file with trained weights and config,
+ sets preprocessing input, runs forward pass and return result detections.
+ For DetectionModel SSD, Faster R-CNN, YOLO topologies are supported.
Getter for nmsAcrossClasses. This variable defaults to false,
+ such that when non max suppression is used during the detect() function, it will do so only per-class
public DetectionModel setNmsAcrossClasses(boolean value)
+
nmsAcrossClasses defaults to false,
+ such that when non max suppression is used during the detect() function, it will do so per-class.
+ This function allows you to toggle this behaviour.
This struct stores the scalar value (or array) of one of the following type: double, cv::String or int64.
+ TODO: Maybe int64 is useless because double type exactly stores at least 2^52 integers.
Creates 4-dimensional blob from image. Optionally resizes and crops image from center,
+ subtract mean values, scales values by scalefactor, swap Blue and Red channels.
+
+
Parameters:
+
image - input image (with 1-, 3- or 4-channels).
+ to be in (mean-R, mean-G, mean-B) order if image has BGR ordering and swapRB is true.
+ in 3-channel image is necessary.
+ if crop is true, input image is resized so one side after resize is equal to corresponding
+ dimension in size and another one is equal or larger. Then, crop from the center is performed.
+ If crop is false, direct resize without cropping and preserving aspect ratio is performed.
+
Returns:
+
4-dimensional Mat with NCHW dimensions order.
+
+ Note:
+ The order and usage of scalefactor and mean are (input - mean) * scalefactor.
public static Mat blobFromImage(Mat image,
+ double scalefactor)
+
Creates 4-dimensional blob from image. Optionally resizes and crops image from center,
+ subtract mean values, scales values by scalefactor, swap Blue and Red channels.
+
+
Parameters:
+
image - input image (with 1-, 3- or 4-channels).
+
scalefactor - multiplier for images values.
+ to be in (mean-R, mean-G, mean-B) order if image has BGR ordering and swapRB is true.
+ in 3-channel image is necessary.
+ if crop is true, input image is resized so one side after resize is equal to corresponding
+ dimension in size and another one is equal or larger. Then, crop from the center is performed.
+ If crop is false, direct resize without cropping and preserving aspect ratio is performed.
+
Returns:
+
4-dimensional Mat with NCHW dimensions order.
+
+ Note:
+ The order and usage of scalefactor and mean are (input - mean) * scalefactor.
public static Mat blobFromImage(Mat image,
+ double scalefactor,
+ Size size)
+
Creates 4-dimensional blob from image. Optionally resizes and crops image from center,
+ subtract mean values, scales values by scalefactor, swap Blue and Red channels.
+
+
Parameters:
+
image - input image (with 1-, 3- or 4-channels).
+
scalefactor - multiplier for images values.
+
size - spatial size for output image
+ to be in (mean-R, mean-G, mean-B) order if image has BGR ordering and swapRB is true.
+ in 3-channel image is necessary.
+ if crop is true, input image is resized so one side after resize is equal to corresponding
+ dimension in size and another one is equal or larger. Then, crop from the center is performed.
+ If crop is false, direct resize without cropping and preserving aspect ratio is performed.
+
Returns:
+
4-dimensional Mat with NCHW dimensions order.
+
+ Note:
+ The order and usage of scalefactor and mean are (input - mean) * scalefactor.
public static Mat blobFromImage(Mat image,
+ double scalefactor,
+ Size size,
+ Scalar mean)
+
Creates 4-dimensional blob from image. Optionally resizes and crops image from center,
+ subtract mean values, scales values by scalefactor, swap Blue and Red channels.
+
+
Parameters:
+
image - input image (with 1-, 3- or 4-channels).
+
scalefactor - multiplier for images values.
+
size - spatial size for output image
+
mean - scalar with mean values which are subtracted from channels. Values are intended
+ to be in (mean-R, mean-G, mean-B) order if image has BGR ordering and swapRB is true.
+ in 3-channel image is necessary.
+ if crop is true, input image is resized so one side after resize is equal to corresponding
+ dimension in size and another one is equal or larger. Then, crop from the center is performed.
+ If crop is false, direct resize without cropping and preserving aspect ratio is performed.
+
Returns:
+
4-dimensional Mat with NCHW dimensions order.
+
+ Note:
+ The order and usage of scalefactor and mean are (input - mean) * scalefactor.
public static Mat blobFromImage(Mat image,
+ double scalefactor,
+ Size size,
+ Scalar mean,
+ boolean swapRB)
+
Creates 4-dimensional blob from image. Optionally resizes and crops image from center,
+ subtract mean values, scales values by scalefactor, swap Blue and Red channels.
+
+
Parameters:
+
image - input image (with 1-, 3- or 4-channels).
+
scalefactor - multiplier for images values.
+
size - spatial size for output image
+
mean - scalar with mean values which are subtracted from channels. Values are intended
+ to be in (mean-R, mean-G, mean-B) order if image has BGR ordering and swapRB is true.
+
swapRB - flag which indicates that swap first and last channels
+ in 3-channel image is necessary.
+ if crop is true, input image is resized so one side after resize is equal to corresponding
+ dimension in size and another one is equal or larger. Then, crop from the center is performed.
+ If crop is false, direct resize without cropping and preserving aspect ratio is performed.
+
Returns:
+
4-dimensional Mat with NCHW dimensions order.
+
+ Note:
+ The order and usage of scalefactor and mean are (input - mean) * scalefactor.
public static Mat blobFromImage(Mat image,
+ double scalefactor,
+ Size size,
+ Scalar mean,
+ boolean swapRB,
+ boolean crop)
+
Creates 4-dimensional blob from image. Optionally resizes and crops image from center,
+ subtract mean values, scales values by scalefactor, swap Blue and Red channels.
+
+
Parameters:
+
image - input image (with 1-, 3- or 4-channels).
+
scalefactor - multiplier for images values.
+
size - spatial size for output image
+
mean - scalar with mean values which are subtracted from channels. Values are intended
+ to be in (mean-R, mean-G, mean-B) order if image has BGR ordering and swapRB is true.
+
swapRB - flag which indicates that swap first and last channels
+ in 3-channel image is necessary.
+
crop - flag which indicates whether image will be cropped after resize or not
+ if crop is true, input image is resized so one side after resize is equal to corresponding
+ dimension in size and another one is equal or larger. Then, crop from the center is performed.
+ If crop is false, direct resize without cropping and preserving aspect ratio is performed.
+
Returns:
+
4-dimensional Mat with NCHW dimensions order.
+
+ Note:
+ The order and usage of scalefactor and mean are (input - mean) * scalefactor.
public static Mat blobFromImage(Mat image,
+ double scalefactor,
+ Size size,
+ Scalar mean,
+ boolean swapRB,
+ boolean crop,
+ int ddepth)
+
Creates 4-dimensional blob from image. Optionally resizes and crops image from center,
+ subtract mean values, scales values by scalefactor, swap Blue and Red channels.
+
+
Parameters:
+
image - input image (with 1-, 3- or 4-channels).
+
scalefactor - multiplier for images values.
+
size - spatial size for output image
+
mean - scalar with mean values which are subtracted from channels. Values are intended
+ to be in (mean-R, mean-G, mean-B) order if image has BGR ordering and swapRB is true.
+
swapRB - flag which indicates that swap first and last channels
+ in 3-channel image is necessary.
+
crop - flag which indicates whether image will be cropped after resize or not
+
ddepth - Depth of output blob. Choose CV_32F or CV_8U.
+ if crop is true, input image is resized so one side after resize is equal to corresponding
+ dimension in size and another one is equal or larger. Then, crop from the center is performed.
+ If crop is false, direct resize without cropping and preserving aspect ratio is performed.
+
Returns:
+
4-dimensional Mat with NCHW dimensions order.
+
+ Note:
+ The order and usage of scalefactor and mean are (input - mean) * scalefactor.
public static Mat blobFromImages(java.util.List<Mat> images)
+
Creates 4-dimensional blob from series of images. Optionally resizes and
+ crops images from center, subtract mean values, scales values by scalefactor,
+ swap Blue and Red channels.
+
+
Parameters:
+
images - input images (all with 1-, 3- or 4-channels).
+ to be in (mean-R, mean-G, mean-B) order if image has BGR ordering and swapRB is true.
+ in 3-channel image is necessary.
+ if crop is true, input image is resized so one side after resize is equal to corresponding
+ dimension in size and another one is equal or larger. Then, crop from the center is performed.
+ If crop is false, direct resize without cropping and preserving aspect ratio is performed.
+
Returns:
+
4-dimensional Mat with NCHW dimensions order.
+
+ Note:
+ The order and usage of scalefactor and mean are (input - mean) * scalefactor.
public static Mat blobFromImages(java.util.List<Mat> images,
+ double scalefactor)
+
Creates 4-dimensional blob from series of images. Optionally resizes and
+ crops images from center, subtract mean values, scales values by scalefactor,
+ swap Blue and Red channels.
+
+
Parameters:
+
images - input images (all with 1-, 3- or 4-channels).
+ to be in (mean-R, mean-G, mean-B) order if image has BGR ordering and swapRB is true.
+
scalefactor - multiplier for images values.
+ in 3-channel image is necessary.
+ if crop is true, input image is resized so one side after resize is equal to corresponding
+ dimension in size and another one is equal or larger. Then, crop from the center is performed.
+ If crop is false, direct resize without cropping and preserving aspect ratio is performed.
+
Returns:
+
4-dimensional Mat with NCHW dimensions order.
+
+ Note:
+ The order and usage of scalefactor and mean are (input - mean) * scalefactor.
public static Mat blobFromImages(java.util.List<Mat> images,
+ double scalefactor,
+ Size size)
+
Creates 4-dimensional blob from series of images. Optionally resizes and
+ crops images from center, subtract mean values, scales values by scalefactor,
+ swap Blue and Red channels.
+
+
Parameters:
+
images - input images (all with 1-, 3- or 4-channels).
+
size - spatial size for output image
+ to be in (mean-R, mean-G, mean-B) order if image has BGR ordering and swapRB is true.
+
scalefactor - multiplier for images values.
+ in 3-channel image is necessary.
+ if crop is true, input image is resized so one side after resize is equal to corresponding
+ dimension in size and another one is equal or larger. Then, crop from the center is performed.
+ If crop is false, direct resize without cropping and preserving aspect ratio is performed.
+
Returns:
+
4-dimensional Mat with NCHW dimensions order.
+
+ Note:
+ The order and usage of scalefactor and mean are (input - mean) * scalefactor.
public static Mat blobFromImages(java.util.List<Mat> images,
+ double scalefactor,
+ Size size,
+ Scalar mean)
+
Creates 4-dimensional blob from series of images. Optionally resizes and
+ crops images from center, subtract mean values, scales values by scalefactor,
+ swap Blue and Red channels.
+
+
Parameters:
+
images - input images (all with 1-, 3- or 4-channels).
+
size - spatial size for output image
+
mean - scalar with mean values which are subtracted from channels. Values are intended
+ to be in (mean-R, mean-G, mean-B) order if image has BGR ordering and swapRB is true.
+
scalefactor - multiplier for images values.
+ in 3-channel image is necessary.
+ if crop is true, input image is resized so one side after resize is equal to corresponding
+ dimension in size and another one is equal or larger. Then, crop from the center is performed.
+ If crop is false, direct resize without cropping and preserving aspect ratio is performed.
+
Returns:
+
4-dimensional Mat with NCHW dimensions order.
+
+ Note:
+ The order and usage of scalefactor and mean are (input - mean) * scalefactor.
public static Mat blobFromImages(java.util.List<Mat> images,
+ double scalefactor,
+ Size size,
+ Scalar mean,
+ boolean swapRB)
+
Creates 4-dimensional blob from series of images. Optionally resizes and
+ crops images from center, subtract mean values, scales values by scalefactor,
+ swap Blue and Red channels.
+
+
Parameters:
+
images - input images (all with 1-, 3- or 4-channels).
+
size - spatial size for output image
+
mean - scalar with mean values which are subtracted from channels. Values are intended
+ to be in (mean-R, mean-G, mean-B) order if image has BGR ordering and swapRB is true.
+
scalefactor - multiplier for images values.
+
swapRB - flag which indicates that swap first and last channels
+ in 3-channel image is necessary.
+ if crop is true, input image is resized so one side after resize is equal to corresponding
+ dimension in size and another one is equal or larger. Then, crop from the center is performed.
+ If crop is false, direct resize without cropping and preserving aspect ratio is performed.
+
Returns:
+
4-dimensional Mat with NCHW dimensions order.
+
+ Note:
+ The order and usage of scalefactor and mean are (input - mean) * scalefactor.
public static Mat blobFromImages(java.util.List<Mat> images,
+ double scalefactor,
+ Size size,
+ Scalar mean,
+ boolean swapRB,
+ boolean crop)
+
Creates 4-dimensional blob from series of images. Optionally resizes and
+ crops images from center, subtract mean values, scales values by scalefactor,
+ swap Blue and Red channels.
+
+
Parameters:
+
images - input images (all with 1-, 3- or 4-channels).
+
size - spatial size for output image
+
mean - scalar with mean values which are subtracted from channels. Values are intended
+ to be in (mean-R, mean-G, mean-B) order if image has BGR ordering and swapRB is true.
+
scalefactor - multiplier for images values.
+
swapRB - flag which indicates that swap first and last channels
+ in 3-channel image is necessary.
+
crop - flag which indicates whether image will be cropped after resize or not
+ if crop is true, input image is resized so one side after resize is equal to corresponding
+ dimension in size and another one is equal or larger. Then, crop from the center is performed.
+ If crop is false, direct resize without cropping and preserving aspect ratio is performed.
+
Returns:
+
4-dimensional Mat with NCHW dimensions order.
+
+ Note:
+ The order and usage of scalefactor and mean are (input - mean) * scalefactor.
public static Mat blobFromImages(java.util.List<Mat> images,
+ double scalefactor,
+ Size size,
+ Scalar mean,
+ boolean swapRB,
+ boolean crop,
+ int ddepth)
+
Creates 4-dimensional blob from series of images. Optionally resizes and
+ crops images from center, subtract mean values, scales values by scalefactor,
+ swap Blue and Red channels.
+
+
Parameters:
+
images - input images (all with 1-, 3- or 4-channels).
+
size - spatial size for output image
+
mean - scalar with mean values which are subtracted from channels. Values are intended
+ to be in (mean-R, mean-G, mean-B) order if image has BGR ordering and swapRB is true.
+
scalefactor - multiplier for images values.
+
swapRB - flag which indicates that swap first and last channels
+ in 3-channel image is necessary.
+
crop - flag which indicates whether image will be cropped after resize or not
+
ddepth - Depth of output blob. Choose CV_32F or CV_8U.
+ if crop is true, input image is resized so one side after resize is equal to corresponding
+ dimension in size and another one is equal or larger. Then, crop from the center is performed.
+ If crop is false, direct resize without cropping and preserving aspect ratio is performed.
+
Returns:
+
4-dimensional Mat with NCHW dimensions order.
+
+ Note:
+ The order and usage of scalefactor and mean are (input - mean) * scalefactor.
public static Mat blobFromImagesWithParams(java.util.List<Mat> images)
+
Creates 4-dimensional blob from series of images with given params.
+
+ This function is an extension of REF: blobFromImages to meet more image preprocess needs.
+ Given input image and preprocessing parameters, and function outputs the blob.
+
+
Parameters:
+
images - input image (all with 1-, 3- or 4-channels).
public static Mat blobFromImagesWithParams(java.util.List<Mat> images,
+ Image2BlobParams param)
+
Creates 4-dimensional blob from series of images with given params.
+
+ This function is an extension of REF: blobFromImages to meet more image preprocess needs.
+ Given input image and preprocessing parameters, and function outputs the blob.
+
+
Parameters:
+
images - input image (all with 1-, 3- or 4-channels).
+
param - struct of Image2BlobParams, contains all parameters needed by processing of image to blob.
public static Mat blobFromImageWithParams(Mat image)
+
Creates 4-dimensional blob from image with given params.
+
+ This function is an extension of REF: blobFromImage to meet more image preprocess needs.
+ Given input image and preprocessing parameters, and function outputs the blob.
+
+
Parameters:
+
image - input image (all with 1-, 3- or 4-channels).
Creates 4-dimensional blob from image with given params.
+
+ This function is an extension of REF: blobFromImage to meet more image preprocess needs.
+ Given input image and preprocessing parameters, and function outputs the blob.
+
+
Parameters:
+
image - input image (all with 1-, 3- or 4-channels).
+
param - struct of Image2BlobParams, contains all parameters needed by processing of image to blob.
public static void imagesFromBlob(Mat blob_,
+ java.util.List<Mat> images_)
+
Parse a 4D blob and output the images it contains as 2D arrays through a simpler data structure
+ (std::vector<cv::Mat>).
+
+
Parameters:
+
blob_ - 4 dimensional array (images, channels, height, width) in floating point precision (CV_32F) from
+ which you would like to extract the images.
+
images_ - array of 2D Mat containing the images extracted from the blob in floating point precision
+ (CV_32F). They are non normalized neither mean added. The number of returned images equals the first dimension
+ of the blob (batch size). Every image has a number of channels equals to the second dimension of the blob (depth).
Read deep learning network represented in one of the supported formats.
+
+
Parameters:
+
model - Binary file contains trained weights. The following file
+ extensions are expected for models from different frameworks:
+ * *.caffemodel (Caffe, http://caffe.berkeleyvision.org/)
+ * *.pb (TensorFlow, https://www.tensorflow.org/)
+ * *.t7 | *.net (Torch, http://torch.ch/)
+ * *.weights (Darknet, https://pjreddie.com/darknet/)
+ * *.bin (DLDT, https://software.intel.com/openvino-toolkit)
+ * *.onnx (ONNX, https://onnx.ai/)
+ file with the following extensions:
+ * *.prototxt (Caffe, http://caffe.berkeleyvision.org/)
+ * *.pbtxt (TensorFlow, https://www.tensorflow.org/)
+ * *.cfg (Darknet, https://pjreddie.com/darknet/)
+ * *.xml (DLDT, https://software.intel.com/openvino-toolkit)
+
Returns:
+
Net object.
+
+ This function automatically detects an origin framework of trained model
+ and calls an appropriate function such REF: readNetFromCaffe, REF: readNetFromTensorflow,
+ REF: readNetFromTorch or REF: readNetFromDarknet. An order of model and config
+ arguments does not matter.
public static Net readNet(java.lang.String framework,
+ MatOfByte bufferModel)
+
Read deep learning network represented in one of the supported formats.
+ This is an overloaded member function, provided for convenience.
+ It differs from the above function only in what argument(s) it accepts.
+
+
Parameters:
+
framework - Name of origin framework.
+
bufferModel - A buffer with a content of binary file with weights
public static Net readNet(java.lang.String framework,
+ MatOfByte bufferModel,
+ MatOfByte bufferConfig)
+
Read deep learning network represented in one of the supported formats.
+ This is an overloaded member function, provided for convenience.
+ It differs from the above function only in what argument(s) it accepts.
+
+
Parameters:
+
framework - Name of origin framework.
+
bufferModel - A buffer with a content of binary file with weights
+
bufferConfig - A buffer with a content of text file contains network configuration.
public static Net readNet(java.lang.String model,
+ java.lang.String config)
+
Read deep learning network represented in one of the supported formats.
+
+
Parameters:
+
model - Binary file contains trained weights. The following file
+ extensions are expected for models from different frameworks:
+ * *.caffemodel (Caffe, http://caffe.berkeleyvision.org/)
+ * *.pb (TensorFlow, https://www.tensorflow.org/)
+ * *.t7 | *.net (Torch, http://torch.ch/)
+ * *.weights (Darknet, https://pjreddie.com/darknet/)
+ * *.bin (DLDT, https://software.intel.com/openvino-toolkit)
+ * *.onnx (ONNX, https://onnx.ai/)
+
config - Text file contains network configuration. It could be a
+ file with the following extensions:
+ * *.prototxt (Caffe, http://caffe.berkeleyvision.org/)
+ * *.pbtxt (TensorFlow, https://www.tensorflow.org/)
+ * *.cfg (Darknet, https://pjreddie.com/darknet/)
+ * *.xml (DLDT, https://software.intel.com/openvino-toolkit)
+
Returns:
+
Net object.
+
+ This function automatically detects an origin framework of trained model
+ and calls an appropriate function such REF: readNetFromCaffe, REF: readNetFromTensorflow,
+ REF: readNetFromTorch or REF: readNetFromDarknet. An order of model and config
+ arguments does not matter.
public static Net readNet(java.lang.String model,
+ java.lang.String config,
+ java.lang.String framework)
+
Read deep learning network represented in one of the supported formats.
+
+
Parameters:
+
model - Binary file contains trained weights. The following file
+ extensions are expected for models from different frameworks:
+ * *.caffemodel (Caffe, http://caffe.berkeleyvision.org/)
+ * *.pb (TensorFlow, https://www.tensorflow.org/)
+ * *.t7 | *.net (Torch, http://torch.ch/)
+ * *.weights (Darknet, https://pjreddie.com/darknet/)
+ * *.bin (DLDT, https://software.intel.com/openvino-toolkit)
+ * *.onnx (ONNX, https://onnx.ai/)
+
config - Text file contains network configuration. It could be a
+ file with the following extensions:
+ * *.prototxt (Caffe, http://caffe.berkeleyvision.org/)
+ * *.pbtxt (TensorFlow, https://www.tensorflow.org/)
+ * *.cfg (Darknet, https://pjreddie.com/darknet/)
+ * *.xml (DLDT, https://software.intel.com/openvino-toolkit)
+
framework - Explicit framework name tag to determine a format.
+
Returns:
+
Net object.
+
+ This function automatically detects an origin framework of trained model
+ and calls an appropriate function such REF: readNetFromCaffe, REF: readNetFromTensorflow,
+ REF: readNetFromTorch or REF: readNetFromDarknet. An order of model and config
+ arguments does not matter.
public static Net readNetFromTensorflow(java.lang.String model)
+
Reads a network model stored in <a href="https://www.tensorflow.org/">TensorFlow</a> framework's format.
+
+
Parameters:
+
model - path to the .pb file with binary protobuf description of the network architecture
+ Resulting Net object is built by text graph using weights from a binary one that
+ let us make it more flexible.
public static Net readNetFromTensorflow(java.lang.String model,
+ java.lang.String config)
+
Reads a network model stored in <a href="https://www.tensorflow.org/">TensorFlow</a> framework's format.
+
+
Parameters:
+
model - path to the .pb file with binary protobuf description of the network architecture
+
config - path to the .pbtxt file that contains text graph definition in protobuf format.
+ Resulting Net object is built by text graph using weights from a binary one that
+ let us make it more flexible.
public static Net readNetFromTorch(java.lang.String model)
+
Reads a network model stored in <a href="http://torch.ch">Torch7</a> framework's format.
+
+
Parameters:
+
model - path to the file, dumped from Torch by using torch.save() function.
+
Returns:
+
Net object.
+
+ Note: Ascii mode of Torch serializer is more preferable, because binary mode extensively use long type of C language,
+ which has various bit-length on different systems.
+
+ The loading file must contain serialized <a href="https://github.com/torch/nn/blob/master/doc/module.md">nn.Module</a> object
+ with importing network. Try to eliminate a custom objects from serialazing data to avoid importing errors.
+
+ List of supported layers (i.e. object instances derived from Torch nn.Module class):
+ - nn.Sequential
+ - nn.Parallel
+ - nn.Concat
+ - nn.Linear
+ - nn.SpatialConvolution
+ - nn.SpatialMaxPooling, nn.SpatialAveragePooling
+ - nn.ReLU, nn.TanH, nn.Sigmoid
+ - nn.Reshape
+ - nn.SoftMax, nn.LogSoftMax
+
+ Also some equivalents of these classes from cunn, cudnn, and fbcunn may be successfully imported.
public static Net readNetFromTorch(java.lang.String model,
+ boolean isBinary)
+
Reads a network model stored in <a href="http://torch.ch">Torch7</a> framework's format.
+
+
Parameters:
+
model - path to the file, dumped from Torch by using torch.save() function.
+
isBinary - specifies whether the network was serialized in ascii mode or binary.
+
Returns:
+
Net object.
+
+ Note: Ascii mode of Torch serializer is more preferable, because binary mode extensively use long type of C language,
+ which has various bit-length on different systems.
+
+ The loading file must contain serialized <a href="https://github.com/torch/nn/blob/master/doc/module.md">nn.Module</a> object
+ with importing network. Try to eliminate a custom objects from serialazing data to avoid importing errors.
+
+ List of supported layers (i.e. object instances derived from Torch nn.Module class):
+ - nn.Sequential
+ - nn.Parallel
+ - nn.Concat
+ - nn.Linear
+ - nn.SpatialConvolution
+ - nn.SpatialMaxPooling, nn.SpatialAveragePooling
+ - nn.ReLU, nn.TanH, nn.Sigmoid
+ - nn.Reshape
+ - nn.SoftMax, nn.LogSoftMax
+
+ Also some equivalents of these classes from cunn, cudnn, and fbcunn may be successfully imported.
public static Net readNetFromTorch(java.lang.String model,
+ boolean isBinary,
+ boolean evaluate)
+
Reads a network model stored in <a href="http://torch.ch">Torch7</a> framework's format.
+
+
Parameters:
+
model - path to the file, dumped from Torch by using torch.save() function.
+
isBinary - specifies whether the network was serialized in ascii mode or binary.
+
evaluate - specifies testing phase of network. If true, it's similar to evaluate() method in Torch.
+
Returns:
+
Net object.
+
+ Note: Ascii mode of Torch serializer is more preferable, because binary mode extensively use long type of C language,
+ which has various bit-length on different systems.
+
+ The loading file must contain serialized <a href="https://github.com/torch/nn/blob/master/doc/module.md">nn.Module</a> object
+ with importing network. Try to eliminate a custom objects from serialazing data to avoid importing errors.
+
+ List of supported layers (i.e. object instances derived from Torch nn.Module class):
+ - nn.Sequential
+ - nn.Parallel
+ - nn.Concat
+ - nn.Linear
+ - nn.SpatialConvolution
+ - nn.SpatialMaxPooling, nn.SpatialAveragePooling
+ - nn.ReLU, nn.TanH, nn.Sigmoid
+ - nn.Reshape
+ - nn.SoftMax, nn.LogSoftMax
+
+ Also some equivalents of these classes from cunn, cudnn, and fbcunn may be successfully imported.
Release a Myriad device (binded by OpenCV).
+
+ Single Myriad device cannot be shared across multiple processes which uses
+ Inference Engine's Myriad plugin.
public static void shrinkCaffeModel(java.lang.String src,
+ java.lang.String dst)
+
Convert all weights of Caffe network to half precision floating point.
+
+
Parameters:
+
src - Path to origin model from Caffe framework contains single
+ precision floating point weights (usually has .caffemodel extension).
+
dst - Path to destination model with updated weights.
+ By default, converts only Convolutional and Fully-Connected layers'
+ weights.
+
+ Note: Shrinked model has no origin float32 weights so it can't be used
+ in origin Caffe framework anymore. However the structure of data
+ is taken from NVidia's Caffe fork: https://github.com/NVIDIA/caffe.
+ So the resulting model may be used there.
Convert all weights of Caffe network to half precision floating point.
+
+
Parameters:
+
src - Path to origin model from Caffe framework contains single
+ precision floating point weights (usually has .caffemodel extension).
+
dst - Path to destination model with updated weights.
+
layersTypes - Set of layers types which parameters will be converted.
+ By default, converts only Convolutional and Fully-Connected layers'
+ weights.
+
+ Note: Shrinked model has no origin float32 weights so it can't be used
+ in origin Caffe framework anymore. However the structure of data
+ is taken from NVidia's Caffe fork: https://github.com/NVIDIA/caffe.
+ So the resulting model may be used there.
public class Image2BlobParams
+extends java.lang.Object
+
Processing params of image to blob.
+
+ It includes all possible image processing operations and corresponding parameters.
+
+ SEE: blobFromImageWithParams
+
+ Note:
+ The order and usage of scalefactor and mean are (input - mean) * scalefactor.
+ The order and usage of scalefactor, size, mean, swapRB, and ddepth are consistent
+ with the function of REF: blobFromImage.
This class represents high-level API for keypoints models
+
+ KeypointsModel allows to set params for preprocessing input image.
+ KeypointsModel creates net from file with trained weights and config,
+ sets preprocessing input, runs forward pass and returns the x and y coordinates of each detected keypoint
This interface class allows to build new Layers - are building blocks of networks.
+
+ Each class, derived from Layer, must implement allocate() methods to declare own outputs and forward() to compute outputs.
+ Also before using the new layer into networks you must register your layer by using one of REF: dnnLayerFactory "LayerFactory" macros.
public void finalize(java.util.List<Mat> inputs,
+ java.util.List<Mat> outputs)
+
Computes and sets internal parameters according to inputs, outputs and blobs.
+
+
Parameters:
+
outputs - vector of already allocated output blobs
+
+ If this method is called after network has allocated all memory for input and output blobs
+ and before inferencing.
This class is presented high-level API for neural networks.
+
+ Model allows to set params for preprocessing input image.
+ Model creates net from file with trained weights and config,
+ sets preprocessing input and runs forward pass.
This class allows to create and manipulate comprehensive artificial neural networks.
+
+ Neural network is presented as directed acyclic graph (DAG), where vertices are Layer instances,
+ and edges specify relationships between layers inputs and outputs.
+
+ Each network layer has unique integer id and unique string name inside its network.
+ LayerId can store either layer name or layer id.
+
+ This class supports reference counting of its instances, i. e. copies point to the same instance.
public void connect(java.lang.String outPin,
+ java.lang.String inpPin)
+
Connects output of the first layer to input of the second layer.
+
+
Parameters:
+
outPin - descriptor of the first layer output.
+
inpPin - descriptor of the second layer input.
+
+ Descriptors have the following template <DFN><layer_name>[.input_number]</DFN>:
+ - the first part of the template <DFN>layer_name</DFN> is string name of the added layer.
+ If this part is empty then the network input pseudo layer will be used;
+ - the second optional part of the template <DFN>input_number</DFN>
+ is either number of the layer input, either label one.
+ If this part is omitted then the first layer input will be used.
+
+ SEE: setNetInputs(), Layer::inputNameToIndex(), Layer::outputNameToIndex()
String with structure, hyperparameters, backend, target and fusion
+ Call method after setInput(). To see correct backend, target and fusion run after forward().
Returns overall time for inference and timings (in ticks) for layers.
+
+ Indexes in returned vector correspond to layers ids. Some layers can be fused with others,
+ in this case zero ticks count will be return for that skipped layers. Supported by DNN_BACKEND_OPENCV on DNN_TARGET_CPU only.
public Net quantize(java.util.List<Mat> calibData,
+ int inputsDtype,
+ int outputsDtype)
+
Returns a quantized Net from a floating-point Net.
+
+
Parameters:
+
calibData - Calibration data to compute the quantization parameters.
+
inputsDtype - Datatype of quantized net's inputs. Can be CV_32F or CV_8S.
+
outputsDtype - Datatype of quantized net's outputs. Can be CV_32F or CV_8S.
+ in per-channel way (channel-wise). Set it false to quantize model in per-tensor way (or tensor-wise).
public Net quantize(java.util.List<Mat> calibData,
+ int inputsDtype,
+ int outputsDtype,
+ boolean perChannel)
+
Returns a quantized Net from a floating-point Net.
+
+
Parameters:
+
calibData - Calibration data to compute the quantization parameters.
+
inputsDtype - Datatype of quantized net's inputs. Can be CV_32F or CV_8S.
+
outputsDtype - Datatype of quantized net's outputs. Can be CV_32F or CV_8S.
+
perChannel - Quantization granularity of quantized Net. The default is true, that means quantize model
+ in per-channel way (channel-wise). Set it false to quantize model in per-tensor way (or tensor-wise).
public void setHalideScheduler(java.lang.String scheduler)
+
Compile Halide layers.
+
+
Parameters:
+
scheduler - Path to YAML file with scheduling directives.
+ SEE: setPreferableBackend
+
+ Schedule layers that support Halide backend. Then compile them for
+ specific target. For layers that not represented in scheduling file
+ or if no manual scheduling used at all, automatic scheduling will be applied.
blob - A new blob. Should have CV_32F or CV_8U depth.
+ SEE: connect(String, String) to know format of the descriptor.
+
+ If scale or mean values are specified, a final input blob is computed
+ as:
+ \(input(n,c,h,w) = scalefactor \times (blob(n,c,h,w) - mean_c)\)
public void setInput(Mat blob,
+ java.lang.String name)
+
Sets the new input value for the network
+
+
Parameters:
+
blob - A new blob. Should have CV_32F or CV_8U depth.
+
name - A name of input layer.
+ SEE: connect(String, String) to know format of the descriptor.
+
+ If scale or mean values are specified, a final input blob is computed
+ as:
+ \(input(n,c,h,w) = scalefactor \times (blob(n,c,h,w) - mean_c)\)
public void setInput(Mat blob,
+ java.lang.String name,
+ double scalefactor)
+
Sets the new input value for the network
+
+
Parameters:
+
blob - A new blob. Should have CV_32F or CV_8U depth.
+
name - A name of input layer.
+
scalefactor - An optional normalization scale.
+ SEE: connect(String, String) to know format of the descriptor.
+
+ If scale or mean values are specified, a final input blob is computed
+ as:
+ \(input(n,c,h,w) = scalefactor \times (blob(n,c,h,w) - mean_c)\)
blob - A new blob. Should have CV_32F or CV_8U depth.
+
name - A name of input layer.
+
scalefactor - An optional normalization scale.
+
mean - An optional mean subtraction values.
+ SEE: connect(String, String) to know format of the descriptor.
+
+ If scale or mean values are specified, a final input blob is computed
+ as:
+ \(input(n,c,h,w) = scalefactor \times (blob(n,c,h,w) - mean_c)\)
public void setInputsNames(java.util.List<java.lang.String> inputBlobNames)
+
Sets outputs names of the network input pseudo layer.
+
+ Each net always has special own the network input pseudo layer with id=0.
+ This layer stores the user blobs only and don't make any computations.
+ In fact, this layer provides the only way to pass user data into the network.
+ As any other layer, this layer can label its outputs and this function provides an easy way to do this.
public void setParam(int layer,
+ int numParam,
+ Mat blob)
+
Sets the new value for the learned param of the layer.
+
+
Parameters:
+
layer - name or id of the layer.
+
numParam - index of the layer parameter in the Layer::blobs array.
+
blob - the new value.
+ SEE: Layer::blobs
+ Note: If shape of the new blob differs from the previous shape,
+ then the following forward pass may fail.
Ask network to use specific computation backend where it supported.
+
+
Parameters:
+
backendId - backend identifier.
+ SEE: Backend
+
+ If OpenCV is compiled with Intel's Inference Engine library, DNN_BACKEND_DEFAULT
+ means DNN_BACKEND_INFERENCE_ENGINE. Otherwise it equals to DNN_BACKEND_OPENCV.
This class represents high-level API for segmentation models
+
+ SegmentationModel allows to set params for preprocessing input image.
+ SegmentationModel creates net from file with trained weights and config,
+ sets preprocessing input, runs forward pass and returns the class prediction for each pixel.
public void detect(Mat frame,
+ java.util.List<MatOfPoint> detections,
+ MatOfFloat confidences)
+
Performs detection
+
+ Given the input frame, prepare network input, run network inference, post-process network output and return result detections.
+
+ Each result is quadrangle's 4 points in this order:
+ - bottom-left
+ - top-left
+ - top-right
+ - bottom-right
+
+ Use cv::getPerspectiveTransform function to retrieve image region without perspective transformations.
+
+ Note: If DL model doesn't support that kind of output then result may be derived from detectTextRectangles() output.
+
+
Parameters:
+
frame - The input image
+
detections - array with detections' quadrangles (4 points per result)
Performs detection
+
+ Given the input frame, prepare network input, run network inference, post-process network output and return result detections.
+
+ Each result is rotated rectangle.
+
+ Note: Result may be inaccurate in case of strong perspective transformations.
+
+
Parameters:
+
frame - the input image
+
detections - array with detections' RotationRect results
This class represents high-level API for text detection DL networks compatible with DB model.
+
+ Related publications: CITE: liao2020real
+ Paper: https://arxiv.org/abs/1911.08947
+ For more information about the hyper-parameters setting, please refer to https://github.com/MhLiao/DB
+
+ Configurable parameters:
+ - (float) binaryThreshold - The threshold of the binary map. It is usually set to 0.3.
+ - (float) polygonThreshold - The threshold of text polygons. It is usually set to 0.5, 0.6, and 0.7. Default is 0.5f
+ - (double) unclipRatio - The unclip ratio of the detected text region, which determines the output size. It is usually set to 2.0.
+ - (int) maxCandidates - The max number of the output results.
This class represents high-level API for text detection DL networks compatible with EAST model.
+
+ Configurable parameters:
+ - (float) confThreshold - used to filter boxes by confidences, default: 0.5f
+ - (float) nmsThreshold - used in non maximum suppression, default: 0.0f
This class represents high-level API for text recognition networks.
+
+ TextRecognitionModel allows to set params for preprocessing input image.
+ TextRecognitionModel creates net from file with trained weights and config,
+ sets preprocessing input, runs forward pass and return recognition result.
+ For TextRecognitionModel, CRNN-CTC is supported.
Create Text Recognition model from deep learning network
+ Call setDecodeType() and setVocabulary() after constructor to initialize the decoding method
Create text recognition model from network represented in one of the supported formats
+ Call setDecodeType() and setVocabulary() after constructor to initialize the decoding method
Create text recognition model from network represented in one of the supported formats
+ Call setDecodeType() and setVocabulary() after constructor to initialize the decoding method
Create Text Recognition model from deep learning network
+ Call setDecodeType() and setVocabulary() after constructor to initialize the decoding method
public TextRecognitionModel(java.lang.String model)
+
Create text recognition model from network represented in one of the supported formats
+ Call setDecodeType() and setVocabulary() after constructor to initialize the decoding method
public TextRecognitionModel(java.lang.String model,
+ java.lang.String config)
+
Create text recognition model from network represented in one of the supported formats
+ Call setDecodeType() and setVocabulary() after constructor to initialize the decoding method
public TextRecognitionModel setDecodeOptsCTCPrefixBeamSearch(int beamSize,
+ int vocPruneSize)
+
Set the decoding method options for "CTC-prefix-beam-search" decode usage
+
+
Parameters:
+
beamSize - Beam size for search
+
vocPruneSize - Parameter to optimize big vocabulary search,
+ only take top vocPruneSize tokens in each search step, vocPruneSize <= 0 stands for disable this prune.
Set the decoding method of translating the network output into string
+
+
Parameters:
+
decodeType - The decoding method of translating the network output into string, currently supported type:
+ - "CTC-greedy" greedy decoding for the output of CTC-based methods
+ - "CTC-prefix-beam-search" Prefix beam search decoding for the output of CTC-based methods
Class implementing the AKAZE keypoint detector and descriptor extractor, described in CITE: ANB13.
+
+ AKAZE descriptors can only be used with KAZE or AKAZE keypoints. This class is thread-safe.
+
+ Note: When you need descriptors use Feature2D::detectAndCompute, which
+ provides better performance. When using Feature2D::detect followed by
+ Feature2D::compute scale space pyramid is computed twice.
+
+ Note: AKAZE implements T-API. When image is passed as UMat some parts of the algorithm
+ will use OpenCL.
+
+ Note: [ANB13] Fast Explicit Diffusion for Accelerated Features in Nonlinear
+ Scale Spaces. Pablo F. Alcantarilla, Jesús Nuevo and Adrien Bartoli. In
+ British Machine Vision Conference (BMVC), Bristol, UK, September 2013.
create(int descriptor_type,
+ int descriptor_size,
+ int descriptor_channels,
+ float threshold,
+ int nOctaves,
+ int nOctaveLayers,
+ int diffusivity)
+
descriptor_type - Type of the extracted descriptor: DESCRIPTOR_KAZE,
+ DESCRIPTOR_KAZE_UPRIGHT, DESCRIPTOR_MLDB or DESCRIPTOR_MLDB_UPRIGHT.
+ DIFF_CHARBONNIER
public static AKAZE create(int descriptor_type,
+ int descriptor_size,
+ int descriptor_channels,
+ float threshold,
+ int nOctaves,
+ int nOctaveLayers)
+
The AKAZE constructor
+
+
Parameters:
+
descriptor_type - Type of the extracted descriptor: DESCRIPTOR_KAZE,
+ DESCRIPTOR_KAZE_UPRIGHT, DESCRIPTOR_MLDB or DESCRIPTOR_MLDB_UPRIGHT.
+
descriptor_size - Size of the descriptor in bits. 0 -> Full size
+
descriptor_channels - Number of channels in the descriptor (1, 2, 3)
+
threshold - Detector response threshold to accept point
+
nOctaves - Maximum octave evolution of the image
+
nOctaveLayers - Default number of sublevels per scale level
+ DIFF_CHARBONNIER
public static AKAZE create(int descriptor_type,
+ int descriptor_size,
+ int descriptor_channels,
+ float threshold,
+ int nOctaves,
+ int nOctaveLayers,
+ int diffusivity)
+
The AKAZE constructor
+
+
Parameters:
+
descriptor_type - Type of the extracted descriptor: DESCRIPTOR_KAZE,
+ DESCRIPTOR_KAZE_UPRIGHT, DESCRIPTOR_MLDB or DESCRIPTOR_MLDB_UPRIGHT.
+
descriptor_size - Size of the descriptor in bits. 0 -> Full size
+
descriptor_channels - Number of channels in the descriptor (1, 2, 3)
+
threshold - Detector response threshold to accept point
+
nOctaves - Maximum octave evolution of the image
+
nOctaveLayers - Default number of sublevels per scale level
+
diffusivity - Diffusivity type. DIFF_PM_G1, DIFF_PM_G2, DIFF_WEICKERT or
+ DIFF_CHARBONNIER
Brute-force descriptor matcher.
+
+ For each descriptor in the first set, this matcher finds the closest descriptor in the second set
+ by trying each one. This descriptor matcher supports masking permissible matches of descriptor
+ sets.
Brute-force matcher create method.
+ preferable choices for SIFT and SURF descriptors, NORM_HAMMING should be used with ORB, BRISK and
+ BRIEF, NORM_HAMMING2 should be used with ORB when WTA_K==3 or 4 (see ORB::ORB constructor
+ description).
+ nearest neighbors for each query descriptor. If crossCheck==true, then the knnMatch() method with
+ k=1 will only return pairs (i,j) such that for i-th query descriptor the j-th descriptor in the
+ matcher's collection is the nearest and vice versa, i.e. the BFMatcher will only return consistent
+ pairs. Such technique usually produces best results with minimal number of outliers when there are
+ enough matches. This is alternative to the ratio test, used by D. Lowe in SIFT paper.
normType - One of NORM_L1, NORM_L2, NORM_HAMMING, NORM_HAMMING2. L1 and L2 norms are
+ preferable choices for SIFT and SURF descriptors, NORM_HAMMING should be used with ORB, BRISK and
+ BRIEF, NORM_HAMMING2 should be used with ORB when WTA_K==3 or 4 (see ORB::ORB constructor
+ description).
+ nearest neighbors for each query descriptor. If crossCheck==true, then the knnMatch() method with
+ k=1 will only return pairs (i,j) such that for i-th query descriptor the j-th descriptor in the
+ matcher's collection is the nearest and vice versa, i.e. the BFMatcher will only return consistent
+ pairs. Such technique usually produces best results with minimal number of outliers when there are
+ enough matches. This is alternative to the ratio test, used by D. Lowe in SIFT paper.
public static BFMatcher create(int normType,
+ boolean crossCheck)
+
Brute-force matcher create method.
+
+
Parameters:
+
normType - One of NORM_L1, NORM_L2, NORM_HAMMING, NORM_HAMMING2. L1 and L2 norms are
+ preferable choices for SIFT and SURF descriptors, NORM_HAMMING should be used with ORB, BRISK and
+ BRIEF, NORM_HAMMING2 should be used with ORB when WTA_K==3 or 4 (see ORB::ORB constructor
+ description).
+
crossCheck - If it is false, this is will be default BFMatcher behaviour when it finds the k
+ nearest neighbors for each query descriptor. If crossCheck==true, then the knnMatch() method with
+ k=1 will only return pairs (i,j) such that for i-th query descriptor the j-th descriptor in the
+ matcher's collection is the nearest and vice versa, i.e. the BFMatcher will only return consistent
+ pairs. Such technique usually produces best results with minimal number of outliers when there are
+ enough matches. This is alternative to the ratio test, used by D. Lowe in SIFT paper.
public class BOWImgDescriptorExtractor
+extends java.lang.Object
+
Class to compute an image descriptor using the *bag of visual words*.
+
+ Such a computation consists of the following steps:
+
+ 1. Compute descriptors for a given image and its keypoints set.
+ 2. Find the nearest visual words from the vocabulary for each keypoint descriptor.
+ 3. Compute the bag-of-words image descriptor as is a normalized histogram of vocabulary words
+ encountered in the image. The i-th bin of the histogram is a frequency of i-th word of the
+ vocabulary in the given image.
public void compute(Mat image,
+ MatOfKeyPoint keypoints,
+ Mat imgDescriptor)
+
+
Parameters:
+
imgDescriptor - Computed output image descriptor.
+ pointIdxsOfClusters[i] are keypoint indices that belong to the i -th cluster (word of vocabulary)
+ returned if it is non-zero.
descriptors - Descriptors to cluster. Each row of the descriptors matrix is a descriptor.
+ Descriptors are not added to the inner train descriptor set.
+
+ The vocabulary consists of cluster centers. So, this method returns the vocabulary. In the first
+ variant of the method, train descriptors stored in the object are clustered. In the second variant,
+ input descriptors are clustered.
Abstract base class for training the *bag of visual words* vocabulary from a set of descriptors.
+
+ For details, see, for example, *Visual Categorization with Bags of Keypoints* by Gabriella Csurka,
+ Christopher R. Dance, Lixin Fan, Jutta Willamowski, Cedric Bray, 2004. :
descriptors - Descriptors to add to a training set. Each row of the descriptors matrix is a
+ descriptor.
+
+ The training set is clustered using clustermethod to construct the vocabulary.
descriptors - Descriptors to cluster. Each row of the descriptors matrix is a descriptor.
+ Descriptors are not added to the inner train descriptor set.
+
+ The vocabulary consists of cluster centers. So, this method returns the vocabulary. In the first
+ variant of the method, train descriptors stored in the object are clustered. In the second variant,
+ input descriptors are clustered.
Abstract base class for matching keypoint descriptors.
+
+ It has two groups of match methods: for matching descriptors of an image with another image or with
+ an image set.
Adds descriptors to train a CPU(trainDescCollectionis) or GPU(utrainDescCollectionis) descriptor
+ collection.
+
+ If the collection is not empty, the new descriptors are added to existing train descriptors.
+
+
Parameters:
+
descriptors - Descriptors to add. Each descriptors[i] is a set of descriptors from the same
+ train image.
Clones the matcher.
+
+ that is, copies both parameters and train data. If emptyTrainData is true, the method creates an
+ object copy with the current parameters but with empty train data.
emptyTrainData - If emptyTrainData is false, the method creates a deep copy of the object,
+ that is, copies both parameters and train data. If emptyTrainData is true, the method creates an
+ object copy with the current parameters but with empty train data.
public void knnMatch(Mat queryDescriptors,
+ java.util.List<MatOfDMatch> matches,
+ int k)
+
+
Parameters:
+
queryDescriptors - Query set of descriptors.
+
matches - Matches. Each matches[i] is k or less matches for the same query descriptor.
+
k - Count of best matches found per each query descriptor or less if a query descriptor has
+ less than k possible matches in total.
+ descriptors and stored train descriptors from the i-th image trainDescCollection[i].
+ false, the matches vector has the same size as queryDescriptors rows. If compactResult is true,
+ the matches vector does not contain matches for fully masked-out query descriptors.
public void knnMatch(Mat queryDescriptors,
+ java.util.List<MatOfDMatch> matches,
+ int k,
+ java.util.List<Mat> masks)
+
+
Parameters:
+
queryDescriptors - Query set of descriptors.
+
matches - Matches. Each matches[i] is k or less matches for the same query descriptor.
+
k - Count of best matches found per each query descriptor or less if a query descriptor has
+ less than k possible matches in total.
+
masks - Set of masks. Each masks[i] specifies permissible matches between the input query
+ descriptors and stored train descriptors from the i-th image trainDescCollection[i].
+ false, the matches vector has the same size as queryDescriptors rows. If compactResult is true,
+ the matches vector does not contain matches for fully masked-out query descriptors.
public void knnMatch(Mat queryDescriptors,
+ java.util.List<MatOfDMatch> matches,
+ int k,
+ java.util.List<Mat> masks,
+ boolean compactResult)
+
+
Parameters:
+
queryDescriptors - Query set of descriptors.
+
matches - Matches. Each matches[i] is k or less matches for the same query descriptor.
+
k - Count of best matches found per each query descriptor or less if a query descriptor has
+ less than k possible matches in total.
+
masks - Set of masks. Each masks[i] specifies permissible matches between the input query
+ descriptors and stored train descriptors from the i-th image trainDescCollection[i].
+
compactResult - Parameter used when the mask (or masks) is not empty. If compactResult is
+ false, the matches vector has the same size as queryDescriptors rows. If compactResult is true,
+ the matches vector does not contain matches for fully masked-out query descriptors.
public void knnMatch(Mat queryDescriptors,
+ Mat trainDescriptors,
+ java.util.List<MatOfDMatch> matches,
+ int k)
+
Finds the k best matches for each descriptor from a query set.
+
+
Parameters:
+
queryDescriptors - Query set of descriptors.
+
trainDescriptors - Train set of descriptors. This set is not added to the train descriptors
+ collection stored in the class object.
+ descriptors.
+
matches - Matches. Each matches[i] is k or less matches for the same query descriptor.
+
k - Count of best matches found per each query descriptor or less if a query descriptor has
+ less than k possible matches in total.
+ false, the matches vector has the same size as queryDescriptors rows. If compactResult is true,
+ the matches vector does not contain matches for fully masked-out query descriptors.
+
+ These extended variants of DescriptorMatcher::match methods find several best matches for each query
+ descriptor. The matches are returned in the distance increasing order. See DescriptorMatcher::match
+ for the details about query and train descriptors.
public void knnMatch(Mat queryDescriptors,
+ Mat trainDescriptors,
+ java.util.List<MatOfDMatch> matches,
+ int k,
+ Mat mask)
+
Finds the k best matches for each descriptor from a query set.
+
+
Parameters:
+
queryDescriptors - Query set of descriptors.
+
trainDescriptors - Train set of descriptors. This set is not added to the train descriptors
+ collection stored in the class object.
+
mask - Mask specifying permissible matches between an input query and train matrices of
+ descriptors.
+
matches - Matches. Each matches[i] is k or less matches for the same query descriptor.
+
k - Count of best matches found per each query descriptor or less if a query descriptor has
+ less than k possible matches in total.
+ false, the matches vector has the same size as queryDescriptors rows. If compactResult is true,
+ the matches vector does not contain matches for fully masked-out query descriptors.
+
+ These extended variants of DescriptorMatcher::match methods find several best matches for each query
+ descriptor. The matches are returned in the distance increasing order. See DescriptorMatcher::match
+ for the details about query and train descriptors.
public void knnMatch(Mat queryDescriptors,
+ Mat trainDescriptors,
+ java.util.List<MatOfDMatch> matches,
+ int k,
+ Mat mask,
+ boolean compactResult)
+
Finds the k best matches for each descriptor from a query set.
+
+
Parameters:
+
queryDescriptors - Query set of descriptors.
+
trainDescriptors - Train set of descriptors. This set is not added to the train descriptors
+ collection stored in the class object.
+
mask - Mask specifying permissible matches between an input query and train matrices of
+ descriptors.
+
matches - Matches. Each matches[i] is k or less matches for the same query descriptor.
+
k - Count of best matches found per each query descriptor or less if a query descriptor has
+ less than k possible matches in total.
+
compactResult - Parameter used when the mask (or masks) is not empty. If compactResult is
+ false, the matches vector has the same size as queryDescriptors rows. If compactResult is true,
+ the matches vector does not contain matches for fully masked-out query descriptors.
+
+ These extended variants of DescriptorMatcher::match methods find several best matches for each query
+ descriptor. The matches are returned in the distance increasing order. See DescriptorMatcher::match
+ for the details about query and train descriptors.
public void match(Mat queryDescriptors,
+ Mat trainDescriptors,
+ MatOfDMatch matches)
+
Finds the best match for each descriptor from a query set.
+
+
Parameters:
+
queryDescriptors - Query set of descriptors.
+
trainDescriptors - Train set of descriptors. This set is not added to the train descriptors
+ collection stored in the class object.
+
matches - Matches. If a query descriptor is masked out in mask , no match is added for this
+ descriptor. So, matches size may be smaller than the query descriptors count.
+ descriptors.
+
+ In the first variant of this method, the train descriptors are passed as an input argument. In the
+ second variant of the method, train descriptors collection that was set by DescriptorMatcher::add is
+ used. Optional mask (or masks) can be passed to specify which query and training descriptors can be
+ matched. Namely, queryDescriptors[i] can be matched with trainDescriptors[j] only if
+ mask.at<uchar>(i,j) is non-zero.
public void match(Mat queryDescriptors,
+ Mat trainDescriptors,
+ MatOfDMatch matches,
+ Mat mask)
+
Finds the best match for each descriptor from a query set.
+
+
Parameters:
+
queryDescriptors - Query set of descriptors.
+
trainDescriptors - Train set of descriptors. This set is not added to the train descriptors
+ collection stored in the class object.
+
matches - Matches. If a query descriptor is masked out in mask , no match is added for this
+ descriptor. So, matches size may be smaller than the query descriptors count.
+
mask - Mask specifying permissible matches between an input query and train matrices of
+ descriptors.
+
+ In the first variant of this method, the train descriptors are passed as an input argument. In the
+ second variant of the method, train descriptors collection that was set by DescriptorMatcher::add is
+ used. Optional mask (or masks) can be passed to specify which query and training descriptors can be
+ matched. Namely, queryDescriptors[i] can be matched with trainDescriptors[j] only if
+ mask.at<uchar>(i,j) is non-zero.
public void match(Mat queryDescriptors,
+ MatOfDMatch matches)
+
+
Parameters:
+
queryDescriptors - Query set of descriptors.
+
matches - Matches. If a query descriptor is masked out in mask , no match is added for this
+ descriptor. So, matches size may be smaller than the query descriptors count.
+ descriptors and stored train descriptors from the i-th image trainDescCollection[i].
public void match(Mat queryDescriptors,
+ MatOfDMatch matches,
+ java.util.List<Mat> masks)
+
+
Parameters:
+
queryDescriptors - Query set of descriptors.
+
matches - Matches. If a query descriptor is masked out in mask , no match is added for this
+ descriptor. So, matches size may be smaller than the query descriptors count.
+
masks - Set of masks. Each masks[i] specifies permissible matches between the input query
+ descriptors and stored train descriptors from the i-th image trainDescCollection[i].
public void radiusMatch(Mat queryDescriptors,
+ java.util.List<MatOfDMatch> matches,
+ float maxDistance)
+
+
Parameters:
+
queryDescriptors - Query set of descriptors.
+
matches - Found matches.
+
maxDistance - Threshold for the distance between matched descriptors. Distance means here
+ metric distance (e.g. Hamming distance), not the distance between coordinates (which is measured
+ in Pixels)!
+ descriptors and stored train descriptors from the i-th image trainDescCollection[i].
+ false, the matches vector has the same size as queryDescriptors rows. If compactResult is true,
+ the matches vector does not contain matches for fully masked-out query descriptors.
maxDistance - Threshold for the distance between matched descriptors. Distance means here
+ metric distance (e.g. Hamming distance), not the distance between coordinates (which is measured
+ in Pixels)!
+
masks - Set of masks. Each masks[i] specifies permissible matches between the input query
+ descriptors and stored train descriptors from the i-th image trainDescCollection[i].
+ false, the matches vector has the same size as queryDescriptors rows. If compactResult is true,
+ the matches vector does not contain matches for fully masked-out query descriptors.
maxDistance - Threshold for the distance between matched descriptors. Distance means here
+ metric distance (e.g. Hamming distance), not the distance between coordinates (which is measured
+ in Pixels)!
+
masks - Set of masks. Each masks[i] specifies permissible matches between the input query
+ descriptors and stored train descriptors from the i-th image trainDescCollection[i].
+
compactResult - Parameter used when the mask (or masks) is not empty. If compactResult is
+ false, the matches vector has the same size as queryDescriptors rows. If compactResult is true,
+ the matches vector does not contain matches for fully masked-out query descriptors.
public void radiusMatch(Mat queryDescriptors,
+ Mat trainDescriptors,
+ java.util.List<MatOfDMatch> matches,
+ float maxDistance)
+
For each query descriptor, finds the training descriptors not farther than the specified distance.
+
+
Parameters:
+
queryDescriptors - Query set of descriptors.
+
trainDescriptors - Train set of descriptors. This set is not added to the train descriptors
+ collection stored in the class object.
+
matches - Found matches.
+ false, the matches vector has the same size as queryDescriptors rows. If compactResult is true,
+ the matches vector does not contain matches for fully masked-out query descriptors.
+
maxDistance - Threshold for the distance between matched descriptors. Distance means here
+ metric distance (e.g. Hamming distance), not the distance between coordinates (which is measured
+ in Pixels)!
+ descriptors.
+
+ For each query descriptor, the methods find such training descriptors that the distance between the
+ query descriptor and the training descriptor is equal or smaller than maxDistance. Found matches are
+ returned in the distance increasing order.
public void radiusMatch(Mat queryDescriptors,
+ Mat trainDescriptors,
+ java.util.List<MatOfDMatch> matches,
+ float maxDistance,
+ Mat mask)
+
For each query descriptor, finds the training descriptors not farther than the specified distance.
+
+
Parameters:
+
queryDescriptors - Query set of descriptors.
+
trainDescriptors - Train set of descriptors. This set is not added to the train descriptors
+ collection stored in the class object.
+
matches - Found matches.
+ false, the matches vector has the same size as queryDescriptors rows. If compactResult is true,
+ the matches vector does not contain matches for fully masked-out query descriptors.
+
maxDistance - Threshold for the distance between matched descriptors. Distance means here
+ metric distance (e.g. Hamming distance), not the distance between coordinates (which is measured
+ in Pixels)!
+
mask - Mask specifying permissible matches between an input query and train matrices of
+ descriptors.
+
+ For each query descriptor, the methods find such training descriptors that the distance between the
+ query descriptor and the training descriptor is equal or smaller than maxDistance. Found matches are
+ returned in the distance increasing order.
public void radiusMatch(Mat queryDescriptors,
+ Mat trainDescriptors,
+ java.util.List<MatOfDMatch> matches,
+ float maxDistance,
+ Mat mask,
+ boolean compactResult)
+
For each query descriptor, finds the training descriptors not farther than the specified distance.
+
+
Parameters:
+
queryDescriptors - Query set of descriptors.
+
trainDescriptors - Train set of descriptors. This set is not added to the train descriptors
+ collection stored in the class object.
+
matches - Found matches.
+
compactResult - Parameter used when the mask (or masks) is not empty. If compactResult is
+ false, the matches vector has the same size as queryDescriptors rows. If compactResult is true,
+ the matches vector does not contain matches for fully masked-out query descriptors.
+
maxDistance - Threshold for the distance between matched descriptors. Distance means here
+ metric distance (e.g. Hamming distance), not the distance between coordinates (which is measured
+ in Pixels)!
+
mask - Mask specifying permissible matches between an input query and train matrices of
+ descriptors.
+
+ For each query descriptor, the methods find such training descriptors that the distance between the
+ query descriptor and the training descriptor is equal or smaller than maxDistance. Found matches are
+ returned in the distance increasing order.
Trains a descriptor matcher
+
+ Trains a descriptor matcher (for example, the flann index). In all methods to match, the method
+ train() is run every time before matching. Some descriptor matchers (for example, BruteForceMatcher)
+ have an empty implementation of this method. Other matchers really train their inner structures (for
+ example, FlannBasedMatcher trains flann::Index ).
public void compute(java.util.List<Mat> images,
+ java.util.List<MatOfKeyPoint> keypoints,
+ java.util.List<Mat> descriptors)
+
+
Parameters:
+
images - Image set.
+
keypoints - Input collection of keypoints. Keypoints for which a descriptor cannot be
+ computed are removed. Sometimes new keypoints can be added, for example: SIFT duplicates keypoint
+ with several dominant orientations (for each orientation).
+
descriptors - Computed descriptors. In the second variant of the method descriptors[i] are
+ descriptors computed for a keypoints[i]. Row j is the keypoints (or keypoints[i]) is the
+ descriptor for keypoint j-th keypoint.
public void compute(Mat image,
+ MatOfKeyPoint keypoints,
+ Mat descriptors)
+
Computes the descriptors for a set of keypoints detected in an image (first variant) or image set
+ (second variant).
+
+
Parameters:
+
image - Image.
+
keypoints - Input collection of keypoints. Keypoints for which a descriptor cannot be
+ computed are removed. Sometimes new keypoints can be added, for example: SIFT duplicates keypoint
+ with several dominant orientations (for each orientation).
+
descriptors - Computed descriptors. In the second variant of the method descriptors[i] are
+ descriptors computed for a keypoints[i]. Row j is the keypoints (or keypoints[i]) is the
+ descriptor for keypoint j-th keypoint.
public void detect(java.util.List<Mat> images,
+ java.util.List<MatOfKeyPoint> keypoints)
+
+
Parameters:
+
images - Image set.
+
keypoints - The detected keypoints. In the second variant of the method keypoints[i] is a set
+ of keypoints detected in images[i] .
+ masks[i] is a mask for images[i].
Detects keypoints in an image (first variant) or image set (second variant).
+
+
Parameters:
+
image - Image.
+
keypoints - The detected keypoints. In the second variant of the method keypoints[i] is a set
+ of keypoints detected in images[i] .
+ matrix with non-zero values in the region of interest.
public static void drawKeypoints(Mat image,
+ MatOfKeyPoint keypoints,
+ Mat outImage)
+
Draws keypoints.
+
+
Parameters:
+
image - Source image.
+
keypoints - Keypoints from the source image.
+
outImage - Output image. Its content depends on the flags value defining what is drawn in the
+ output image. See possible flags bit values below.
+ DrawMatchesFlags. See details above in drawMatches .
+
+ Note:
+ For Python API, flags are modified as cv.DRAW_MATCHES_FLAGS_DEFAULT,
+ cv.DRAW_MATCHES_FLAGS_DRAW_RICH_KEYPOINTS, cv.DRAW_MATCHES_FLAGS_DRAW_OVER_OUTIMG,
+ cv.DRAW_MATCHES_FLAGS_NOT_DRAW_SINGLE_POINTS
public static void drawKeypoints(Mat image,
+ MatOfKeyPoint keypoints,
+ Mat outImage,
+ Scalar color)
+
Draws keypoints.
+
+
Parameters:
+
image - Source image.
+
keypoints - Keypoints from the source image.
+
outImage - Output image. Its content depends on the flags value defining what is drawn in the
+ output image. See possible flags bit values below.
+
color - Color of keypoints.
+ DrawMatchesFlags. See details above in drawMatches .
+
+ Note:
+ For Python API, flags are modified as cv.DRAW_MATCHES_FLAGS_DEFAULT,
+ cv.DRAW_MATCHES_FLAGS_DRAW_RICH_KEYPOINTS, cv.DRAW_MATCHES_FLAGS_DRAW_OVER_OUTIMG,
+ cv.DRAW_MATCHES_FLAGS_NOT_DRAW_SINGLE_POINTS
public static void drawKeypoints(Mat image,
+ MatOfKeyPoint keypoints,
+ Mat outImage,
+ Scalar color,
+ int flags)
+
Draws keypoints.
+
+
Parameters:
+
image - Source image.
+
keypoints - Keypoints from the source image.
+
outImage - Output image. Its content depends on the flags value defining what is drawn in the
+ output image. See possible flags bit values below.
+
color - Color of keypoints.
+
flags - Flags setting drawing features. Possible flags bit values are defined by
+ DrawMatchesFlags. See details above in drawMatches .
+
+ Note:
+ For Python API, flags are modified as cv.DRAW_MATCHES_FLAGS_DEFAULT,
+ cv.DRAW_MATCHES_FLAGS_DRAW_RICH_KEYPOINTS, cv.DRAW_MATCHES_FLAGS_DRAW_OVER_OUTIMG,
+ cv.DRAW_MATCHES_FLAGS_NOT_DRAW_SINGLE_POINTS
Draws the found matches of keypoints from two images.
+
+
Parameters:
+
img1 - First source image.
+
keypoints1 - Keypoints from the first source image.
+
img2 - Second source image.
+
keypoints2 - Keypoints from the second source image.
+
matches1to2 - Matches from the first image to the second one, which means that keypoints1[i]
+ has a corresponding point in keypoints2[matches[i]] .
+
outImg - Output image. Its content depends on the flags value defining what is drawn in the
+ output image. See possible flags bit values below.
+ , the color is generated randomly.
+ have the matches. If singlePointColor==Scalar::all(-1) , the color is generated randomly.
+ drawn.
+ DrawMatchesFlags.
+
+ This function draws matches of keypoints from two images in the output image. Match is a line
+ connecting two keypoints (circles). See cv::DrawMatchesFlags.
Draws the found matches of keypoints from two images.
+
+
Parameters:
+
img1 - First source image.
+
keypoints1 - Keypoints from the first source image.
+
img2 - Second source image.
+
keypoints2 - Keypoints from the second source image.
+
matches1to2 - Matches from the first image to the second one, which means that keypoints1[i]
+ has a corresponding point in keypoints2[matches[i]] .
+
outImg - Output image. Its content depends on the flags value defining what is drawn in the
+ output image. See possible flags bit values below.
+
matchColor - Color of matches (lines and connected keypoints). If matchColor==Scalar::all(-1)
+ , the color is generated randomly.
+ have the matches. If singlePointColor==Scalar::all(-1) , the color is generated randomly.
+ drawn.
+ DrawMatchesFlags.
+
+ This function draws matches of keypoints from two images in the output image. Match is a line
+ connecting two keypoints (circles). See cv::DrawMatchesFlags.
Draws the found matches of keypoints from two images.
+
+
Parameters:
+
img1 - First source image.
+
keypoints1 - Keypoints from the first source image.
+
img2 - Second source image.
+
keypoints2 - Keypoints from the second source image.
+
matches1to2 - Matches from the first image to the second one, which means that keypoints1[i]
+ has a corresponding point in keypoints2[matches[i]] .
+
outImg - Output image. Its content depends on the flags value defining what is drawn in the
+ output image. See possible flags bit values below.
+
matchColor - Color of matches (lines and connected keypoints). If matchColor==Scalar::all(-1)
+ , the color is generated randomly.
+
singlePointColor - Color of single keypoints (circles), which means that keypoints do not
+ have the matches. If singlePointColor==Scalar::all(-1) , the color is generated randomly.
+ drawn.
+ DrawMatchesFlags.
+
+ This function draws matches of keypoints from two images in the output image. Match is a line
+ connecting two keypoints (circles). See cv::DrawMatchesFlags.
Draws the found matches of keypoints from two images.
+
+
Parameters:
+
img1 - First source image.
+
keypoints1 - Keypoints from the first source image.
+
img2 - Second source image.
+
keypoints2 - Keypoints from the second source image.
+
matches1to2 - Matches from the first image to the second one, which means that keypoints1[i]
+ has a corresponding point in keypoints2[matches[i]] .
+
outImg - Output image. Its content depends on the flags value defining what is drawn in the
+ output image. See possible flags bit values below.
+
matchColor - Color of matches (lines and connected keypoints). If matchColor==Scalar::all(-1)
+ , the color is generated randomly.
+
singlePointColor - Color of single keypoints (circles), which means that keypoints do not
+ have the matches. If singlePointColor==Scalar::all(-1) , the color is generated randomly.
+
matchesMask - Mask determining which matches are drawn. If the mask is empty, all matches are
+ drawn.
+ DrawMatchesFlags.
+
+ This function draws matches of keypoints from two images in the output image. Match is a line
+ connecting two keypoints (circles). See cv::DrawMatchesFlags.
Draws the found matches of keypoints from two images.
+
+
Parameters:
+
img1 - First source image.
+
keypoints1 - Keypoints from the first source image.
+
img2 - Second source image.
+
keypoints2 - Keypoints from the second source image.
+
matches1to2 - Matches from the first image to the second one, which means that keypoints1[i]
+ has a corresponding point in keypoints2[matches[i]] .
+
outImg - Output image. Its content depends on the flags value defining what is drawn in the
+ output image. See possible flags bit values below.
+
matchColor - Color of matches (lines and connected keypoints). If matchColor==Scalar::all(-1)
+ , the color is generated randomly.
+
singlePointColor - Color of single keypoints (circles), which means that keypoints do not
+ have the matches. If singlePointColor==Scalar::all(-1) , the color is generated randomly.
+
matchesMask - Mask determining which matches are drawn. If the mask is empty, all matches are
+ drawn.
+
flags - Flags setting drawing features. Possible flags bit values are defined by
+ DrawMatchesFlags.
+
+ This function draws matches of keypoints from two images in the output image. Match is a line
+ connecting two keypoints (circles). See cv::DrawMatchesFlags.
Flann-based descriptor matcher.
+
+ This matcher trains cv::flann::Index on a train descriptor collection and calls its nearest search
+ methods to find the best matches. So, this matcher may be faster when matching a large train
+ collection than the brute force matcher. FlannBasedMatcher does not support masking permissible
+ matches of descriptor sets because flann::Index does not support this. :
Class implementing the KAZE keypoint detector and descriptor extractor, described in CITE: ABD12 .
+
+ Note: AKAZE descriptor can only be used with KAZE or AKAZE keypoints .. [ABD12] KAZE Features. Pablo
+ F. Alcantarilla, Adrien Bartoli and Andrew J. Davison. In European Conference on Computer Vision
+ (ECCV), Fiorenze, Italy, October 2012.
Maximally stable extremal region extractor
+
+ The class encapsulates all the parameters of the %MSER extraction algorithm (see [wiki
+ article](http://en.wikipedia.org/wiki/Maximally_stable_extremal_regions)).
+
+
+
+ there are two different implementation of %MSER: one for grey image, one for color image
+
+
+
+
+
+ the grey image algorithm is taken from: CITE: nister2008linear ; the paper claims to be faster
+ than union-find method; it actually get 1.5~2m/s on my centrino L7200 1.2GHz laptop.
+
+
+
+
+
+ the color image algorithm is taken from: CITE: forssen2007maximally ; it should be much slower
+ than grey image method ( 3~4 times )
+
+
+
+
+
+ (Python) A complete example showing the use of the %MSER detector can be found at samples/python/mser.py
+
Class implementing the ORB (*oriented BRIEF*) keypoint detector and descriptor extractor
+
+ described in CITE: RRKB11 . The algorithm uses FAST in pyramids to detect stable keypoints, selects
+ the strongest features using FAST or Harris response, finds their orientation using first-order
+ moments and computes the descriptors using BRIEF (where the coordinates of random point pairs (or
+ k-tuples) are rotated according to the measured orientation).
The ORB constructor
+
+ pyramid, where each next level has 4x less pixels than the previous, but such a big scale factor
+ will degrade feature matching scores dramatically.
create(int nfeatures,
+ float scaleFactor,
+ int nlevels,
+ int edgeThreshold,
+ int firstLevel,
+ int WTA_K,
+ int scoreType,
+ int patchSize,
+ int fastThreshold)
+
The ORB constructor
+
+ pyramid, where each next level has 4x less pixels than the previous, but such a big scale factor
+ will degrade feature matching scores dramatically. On the other hand, too close to 1 scale factor
+ will mean that to cover certain scale range you will need more pyramid levels and so the speed
+ will suffer.
+ input_image_linear_size/pow(scaleFactor, nlevels - firstLevel).
+ roughly match the patchSize parameter.
+ with upscaled source image.
+ default value 2 means the BRIEF where we take a random point pair and compare their brightnesses,
+ so we get 0/1 response. Other possible values are 3 and 4. For example, 3 means that we take 3
+ random points (of course, those point coordinates are random, but they are generated from the
+ pre-defined seed, so each element of BRIEF descriptor is computed deterministically from the pixel
+ rectangle), find point of maximum brightness and output index of the winner (0, 1 or 2). Such
+ output will occupy 2 bits, and therefore it will need a special variant of Hamming distance,
+ denoted as NORM_HAMMING2 (2 bits per bin). When WTA_K=4, we take 4 random points to compute each
+ bin (that will also occupy 2 bits with possible values 0, 1, 2 or 3).
+ (the score is written to KeyPoint::score and is used to retain best nfeatures features);
+ FAST_SCORE is alternative value of the parameter that produces slightly less stable keypoints,
+ but it is a little faster to compute.
+ pyramid layers the perceived image area covered by a feature will be larger.
nfeatures - The maximum number of features to retain.
+ pyramid, where each next level has 4x less pixels than the previous, but such a big scale factor
+ will degrade feature matching scores dramatically. On the other hand, too close to 1 scale factor
+ will mean that to cover certain scale range you will need more pyramid levels and so the speed
+ will suffer.
+ input_image_linear_size/pow(scaleFactor, nlevels - firstLevel).
+ roughly match the patchSize parameter.
+ with upscaled source image.
+ default value 2 means the BRIEF where we take a random point pair and compare their brightnesses,
+ so we get 0/1 response. Other possible values are 3 and 4. For example, 3 means that we take 3
+ random points (of course, those point coordinates are random, but they are generated from the
+ pre-defined seed, so each element of BRIEF descriptor is computed deterministically from the pixel
+ rectangle), find point of maximum brightness and output index of the winner (0, 1 or 2). Such
+ output will occupy 2 bits, and therefore it will need a special variant of Hamming distance,
+ denoted as NORM_HAMMING2 (2 bits per bin). When WTA_K=4, we take 4 random points to compute each
+ bin (that will also occupy 2 bits with possible values 0, 1, 2 or 3).
+ (the score is written to KeyPoint::score and is used to retain best nfeatures features);
+ FAST_SCORE is alternative value of the parameter that produces slightly less stable keypoints,
+ but it is a little faster to compute.
+ pyramid layers the perceived image area covered by a feature will be larger.
public static ORB create(int nfeatures,
+ float scaleFactor)
+
The ORB constructor
+
+
Parameters:
+
nfeatures - The maximum number of features to retain.
+
scaleFactor - Pyramid decimation ratio, greater than 1. scaleFactor==2 means the classical
+ pyramid, where each next level has 4x less pixels than the previous, but such a big scale factor
+ will degrade feature matching scores dramatically. On the other hand, too close to 1 scale factor
+ will mean that to cover certain scale range you will need more pyramid levels and so the speed
+ will suffer.
+ input_image_linear_size/pow(scaleFactor, nlevels - firstLevel).
+ roughly match the patchSize parameter.
+ with upscaled source image.
+ default value 2 means the BRIEF where we take a random point pair and compare their brightnesses,
+ so we get 0/1 response. Other possible values are 3 and 4. For example, 3 means that we take 3
+ random points (of course, those point coordinates are random, but they are generated from the
+ pre-defined seed, so each element of BRIEF descriptor is computed deterministically from the pixel
+ rectangle), find point of maximum brightness and output index of the winner (0, 1 or 2). Such
+ output will occupy 2 bits, and therefore it will need a special variant of Hamming distance,
+ denoted as NORM_HAMMING2 (2 bits per bin). When WTA_K=4, we take 4 random points to compute each
+ bin (that will also occupy 2 bits with possible values 0, 1, 2 or 3).
+ (the score is written to KeyPoint::score and is used to retain best nfeatures features);
+ FAST_SCORE is alternative value of the parameter that produces slightly less stable keypoints,
+ but it is a little faster to compute.
+ pyramid layers the perceived image area covered by a feature will be larger.
public static ORB create(int nfeatures,
+ float scaleFactor,
+ int nlevels)
+
The ORB constructor
+
+
Parameters:
+
nfeatures - The maximum number of features to retain.
+
scaleFactor - Pyramid decimation ratio, greater than 1. scaleFactor==2 means the classical
+ pyramid, where each next level has 4x less pixels than the previous, but such a big scale factor
+ will degrade feature matching scores dramatically. On the other hand, too close to 1 scale factor
+ will mean that to cover certain scale range you will need more pyramid levels and so the speed
+ will suffer.
+
nlevels - The number of pyramid levels. The smallest level will have linear size equal to
+ input_image_linear_size/pow(scaleFactor, nlevels - firstLevel).
+ roughly match the patchSize parameter.
+ with upscaled source image.
+ default value 2 means the BRIEF where we take a random point pair and compare their brightnesses,
+ so we get 0/1 response. Other possible values are 3 and 4. For example, 3 means that we take 3
+ random points (of course, those point coordinates are random, but they are generated from the
+ pre-defined seed, so each element of BRIEF descriptor is computed deterministically from the pixel
+ rectangle), find point of maximum brightness and output index of the winner (0, 1 or 2). Such
+ output will occupy 2 bits, and therefore it will need a special variant of Hamming distance,
+ denoted as NORM_HAMMING2 (2 bits per bin). When WTA_K=4, we take 4 random points to compute each
+ bin (that will also occupy 2 bits with possible values 0, 1, 2 or 3).
+ (the score is written to KeyPoint::score and is used to retain best nfeatures features);
+ FAST_SCORE is alternative value of the parameter that produces slightly less stable keypoints,
+ but it is a little faster to compute.
+ pyramid layers the perceived image area covered by a feature will be larger.
public static ORB create(int nfeatures,
+ float scaleFactor,
+ int nlevels,
+ int edgeThreshold)
+
The ORB constructor
+
+
Parameters:
+
nfeatures - The maximum number of features to retain.
+
scaleFactor - Pyramid decimation ratio, greater than 1. scaleFactor==2 means the classical
+ pyramid, where each next level has 4x less pixels than the previous, but such a big scale factor
+ will degrade feature matching scores dramatically. On the other hand, too close to 1 scale factor
+ will mean that to cover certain scale range you will need more pyramid levels and so the speed
+ will suffer.
+
nlevels - The number of pyramid levels. The smallest level will have linear size equal to
+ input_image_linear_size/pow(scaleFactor, nlevels - firstLevel).
+
edgeThreshold - This is size of the border where the features are not detected. It should
+ roughly match the patchSize parameter.
+ with upscaled source image.
+ default value 2 means the BRIEF where we take a random point pair and compare their brightnesses,
+ so we get 0/1 response. Other possible values are 3 and 4. For example, 3 means that we take 3
+ random points (of course, those point coordinates are random, but they are generated from the
+ pre-defined seed, so each element of BRIEF descriptor is computed deterministically from the pixel
+ rectangle), find point of maximum brightness and output index of the winner (0, 1 or 2). Such
+ output will occupy 2 bits, and therefore it will need a special variant of Hamming distance,
+ denoted as NORM_HAMMING2 (2 bits per bin). When WTA_K=4, we take 4 random points to compute each
+ bin (that will also occupy 2 bits with possible values 0, 1, 2 or 3).
+ (the score is written to KeyPoint::score and is used to retain best nfeatures features);
+ FAST_SCORE is alternative value of the parameter that produces slightly less stable keypoints,
+ but it is a little faster to compute.
+ pyramid layers the perceived image area covered by a feature will be larger.
public static ORB create(int nfeatures,
+ float scaleFactor,
+ int nlevels,
+ int edgeThreshold,
+ int firstLevel)
+
The ORB constructor
+
+
Parameters:
+
nfeatures - The maximum number of features to retain.
+
scaleFactor - Pyramid decimation ratio, greater than 1. scaleFactor==2 means the classical
+ pyramid, where each next level has 4x less pixels than the previous, but such a big scale factor
+ will degrade feature matching scores dramatically. On the other hand, too close to 1 scale factor
+ will mean that to cover certain scale range you will need more pyramid levels and so the speed
+ will suffer.
+
nlevels - The number of pyramid levels. The smallest level will have linear size equal to
+ input_image_linear_size/pow(scaleFactor, nlevels - firstLevel).
+
edgeThreshold - This is size of the border where the features are not detected. It should
+ roughly match the patchSize parameter.
+
firstLevel - The level of pyramid to put source image to. Previous layers are filled
+ with upscaled source image.
+ default value 2 means the BRIEF where we take a random point pair and compare their brightnesses,
+ so we get 0/1 response. Other possible values are 3 and 4. For example, 3 means that we take 3
+ random points (of course, those point coordinates are random, but they are generated from the
+ pre-defined seed, so each element of BRIEF descriptor is computed deterministically from the pixel
+ rectangle), find point of maximum brightness and output index of the winner (0, 1 or 2). Such
+ output will occupy 2 bits, and therefore it will need a special variant of Hamming distance,
+ denoted as NORM_HAMMING2 (2 bits per bin). When WTA_K=4, we take 4 random points to compute each
+ bin (that will also occupy 2 bits with possible values 0, 1, 2 or 3).
+ (the score is written to KeyPoint::score and is used to retain best nfeatures features);
+ FAST_SCORE is alternative value of the parameter that produces slightly less stable keypoints,
+ but it is a little faster to compute.
+ pyramid layers the perceived image area covered by a feature will be larger.
public static ORB create(int nfeatures,
+ float scaleFactor,
+ int nlevels,
+ int edgeThreshold,
+ int firstLevel,
+ int WTA_K)
+
The ORB constructor
+
+
Parameters:
+
nfeatures - The maximum number of features to retain.
+
scaleFactor - Pyramid decimation ratio, greater than 1. scaleFactor==2 means the classical
+ pyramid, where each next level has 4x less pixels than the previous, but such a big scale factor
+ will degrade feature matching scores dramatically. On the other hand, too close to 1 scale factor
+ will mean that to cover certain scale range you will need more pyramid levels and so the speed
+ will suffer.
+
nlevels - The number of pyramid levels. The smallest level will have linear size equal to
+ input_image_linear_size/pow(scaleFactor, nlevels - firstLevel).
+
edgeThreshold - This is size of the border where the features are not detected. It should
+ roughly match the patchSize parameter.
+
firstLevel - The level of pyramid to put source image to. Previous layers are filled
+ with upscaled source image.
+
WTA_K - The number of points that produce each element of the oriented BRIEF descriptor. The
+ default value 2 means the BRIEF where we take a random point pair and compare their brightnesses,
+ so we get 0/1 response. Other possible values are 3 and 4. For example, 3 means that we take 3
+ random points (of course, those point coordinates are random, but they are generated from the
+ pre-defined seed, so each element of BRIEF descriptor is computed deterministically from the pixel
+ rectangle), find point of maximum brightness and output index of the winner (0, 1 or 2). Such
+ output will occupy 2 bits, and therefore it will need a special variant of Hamming distance,
+ denoted as NORM_HAMMING2 (2 bits per bin). When WTA_K=4, we take 4 random points to compute each
+ bin (that will also occupy 2 bits with possible values 0, 1, 2 or 3).
+ (the score is written to KeyPoint::score and is used to retain best nfeatures features);
+ FAST_SCORE is alternative value of the parameter that produces slightly less stable keypoints,
+ but it is a little faster to compute.
+ pyramid layers the perceived image area covered by a feature will be larger.
public static ORB create(int nfeatures,
+ float scaleFactor,
+ int nlevels,
+ int edgeThreshold,
+ int firstLevel,
+ int WTA_K,
+ int scoreType)
+
The ORB constructor
+
+
Parameters:
+
nfeatures - The maximum number of features to retain.
+
scaleFactor - Pyramid decimation ratio, greater than 1. scaleFactor==2 means the classical
+ pyramid, where each next level has 4x less pixels than the previous, but such a big scale factor
+ will degrade feature matching scores dramatically. On the other hand, too close to 1 scale factor
+ will mean that to cover certain scale range you will need more pyramid levels and so the speed
+ will suffer.
+
nlevels - The number of pyramid levels. The smallest level will have linear size equal to
+ input_image_linear_size/pow(scaleFactor, nlevels - firstLevel).
+
edgeThreshold - This is size of the border where the features are not detected. It should
+ roughly match the patchSize parameter.
+
firstLevel - The level of pyramid to put source image to. Previous layers are filled
+ with upscaled source image.
+
WTA_K - The number of points that produce each element of the oriented BRIEF descriptor. The
+ default value 2 means the BRIEF where we take a random point pair and compare their brightnesses,
+ so we get 0/1 response. Other possible values are 3 and 4. For example, 3 means that we take 3
+ random points (of course, those point coordinates are random, but they are generated from the
+ pre-defined seed, so each element of BRIEF descriptor is computed deterministically from the pixel
+ rectangle), find point of maximum brightness and output index of the winner (0, 1 or 2). Such
+ output will occupy 2 bits, and therefore it will need a special variant of Hamming distance,
+ denoted as NORM_HAMMING2 (2 bits per bin). When WTA_K=4, we take 4 random points to compute each
+ bin (that will also occupy 2 bits with possible values 0, 1, 2 or 3).
+
scoreType - The default HARRIS_SCORE means that Harris algorithm is used to rank features
+ (the score is written to KeyPoint::score and is used to retain best nfeatures features);
+ FAST_SCORE is alternative value of the parameter that produces slightly less stable keypoints,
+ but it is a little faster to compute.
+ pyramid layers the perceived image area covered by a feature will be larger.
public static ORB create(int nfeatures,
+ float scaleFactor,
+ int nlevels,
+ int edgeThreshold,
+ int firstLevel,
+ int WTA_K,
+ int scoreType,
+ int patchSize)
+
The ORB constructor
+
+
Parameters:
+
nfeatures - The maximum number of features to retain.
+
scaleFactor - Pyramid decimation ratio, greater than 1. scaleFactor==2 means the classical
+ pyramid, where each next level has 4x less pixels than the previous, but such a big scale factor
+ will degrade feature matching scores dramatically. On the other hand, too close to 1 scale factor
+ will mean that to cover certain scale range you will need more pyramid levels and so the speed
+ will suffer.
+
nlevels - The number of pyramid levels. The smallest level will have linear size equal to
+ input_image_linear_size/pow(scaleFactor, nlevels - firstLevel).
+
edgeThreshold - This is size of the border where the features are not detected. It should
+ roughly match the patchSize parameter.
+
firstLevel - The level of pyramid to put source image to. Previous layers are filled
+ with upscaled source image.
+
WTA_K - The number of points that produce each element of the oriented BRIEF descriptor. The
+ default value 2 means the BRIEF where we take a random point pair and compare their brightnesses,
+ so we get 0/1 response. Other possible values are 3 and 4. For example, 3 means that we take 3
+ random points (of course, those point coordinates are random, but they are generated from the
+ pre-defined seed, so each element of BRIEF descriptor is computed deterministically from the pixel
+ rectangle), find point of maximum brightness and output index of the winner (0, 1 or 2). Such
+ output will occupy 2 bits, and therefore it will need a special variant of Hamming distance,
+ denoted as NORM_HAMMING2 (2 bits per bin). When WTA_K=4, we take 4 random points to compute each
+ bin (that will also occupy 2 bits with possible values 0, 1, 2 or 3).
+
scoreType - The default HARRIS_SCORE means that Harris algorithm is used to rank features
+ (the score is written to KeyPoint::score and is used to retain best nfeatures features);
+ FAST_SCORE is alternative value of the parameter that produces slightly less stable keypoints,
+ but it is a little faster to compute.
+
patchSize - size of the patch used by the oriented BRIEF descriptor. Of course, on smaller
+ pyramid layers the perceived image area covered by a feature will be larger.
public static ORB create(int nfeatures,
+ float scaleFactor,
+ int nlevels,
+ int edgeThreshold,
+ int firstLevel,
+ int WTA_K,
+ int scoreType,
+ int patchSize,
+ int fastThreshold)
+
The ORB constructor
+
+
Parameters:
+
nfeatures - The maximum number of features to retain.
+
scaleFactor - Pyramid decimation ratio, greater than 1. scaleFactor==2 means the classical
+ pyramid, where each next level has 4x less pixels than the previous, but such a big scale factor
+ will degrade feature matching scores dramatically. On the other hand, too close to 1 scale factor
+ will mean that to cover certain scale range you will need more pyramid levels and so the speed
+ will suffer.
+
nlevels - The number of pyramid levels. The smallest level will have linear size equal to
+ input_image_linear_size/pow(scaleFactor, nlevels - firstLevel).
+
edgeThreshold - This is size of the border where the features are not detected. It should
+ roughly match the patchSize parameter.
+
firstLevel - The level of pyramid to put source image to. Previous layers are filled
+ with upscaled source image.
+
WTA_K - The number of points that produce each element of the oriented BRIEF descriptor. The
+ default value 2 means the BRIEF where we take a random point pair and compare their brightnesses,
+ so we get 0/1 response. Other possible values are 3 and 4. For example, 3 means that we take 3
+ random points (of course, those point coordinates are random, but they are generated from the
+ pre-defined seed, so each element of BRIEF descriptor is computed deterministically from the pixel
+ rectangle), find point of maximum brightness and output index of the winner (0, 1 or 2). Such
+ output will occupy 2 bits, and therefore it will need a special variant of Hamming distance,
+ denoted as NORM_HAMMING2 (2 bits per bin). When WTA_K=4, we take 4 random points to compute each
+ bin (that will also occupy 2 bits with possible values 0, 1, 2 or 3).
+
scoreType - The default HARRIS_SCORE means that Harris algorithm is used to rank features
+ (the score is written to KeyPoint::score and is used to retain best nfeatures features);
+ FAST_SCORE is alternative value of the parameter that produces slightly less stable keypoints,
+ but it is a little faster to compute.
+
patchSize - size of the patch used by the oriented BRIEF descriptor. Of course, on smaller
+ pyramid layers the perceived image area covered by a feature will be larger.
(measured in SIFT algorithm as the local contrast)
+
+ number of octaves is computed automatically from the image resolution.
+
+ (low-contrast) regions. The larger the threshold, the less features are produced by the detector.
+
+ Note: The contrast threshold will be divided by nOctaveLayers when the filtering is applied. When
+ nOctaveLayers is set to default and if you want to use the value used in D. Lowe paper, 0.03, set
+ this argument to 0.09.
+
+ is different from the contrastThreshold, i.e. the larger the edgeThreshold, the less features are
+ filtered out (more features are retained).
+
+ is captured with a weak camera with soft lenses, you might want to reduce the number.
+
+ index \(\texttt{x}\) to \(\texttt{2x}\). This prevents localization bias. The option
+ is disabled by default.
nfeatures - The number of best features to retain. The features are ranked by their scores
+ (measured in SIFT algorithm as the local contrast)
+
+ number of octaves is computed automatically from the image resolution.
+
+ (low-contrast) regions. The larger the threshold, the less features are produced by the detector.
+
+ Note: The contrast threshold will be divided by nOctaveLayers when the filtering is applied. When
+ nOctaveLayers is set to default and if you want to use the value used in D. Lowe paper, 0.03, set
+ this argument to 0.09.
+
+ is different from the contrastThreshold, i.e. the larger the edgeThreshold, the less features are
+ filtered out (more features are retained).
+
+ is captured with a weak camera with soft lenses, you might want to reduce the number.
+
+ index \(\texttt{x}\) to \(\texttt{2x}\). This prevents localization bias. The option
+ is disabled by default.
public static SIFT create(int nfeatures,
+ int nOctaveLayers)
+
+
Parameters:
+
nfeatures - The number of best features to retain. The features are ranked by their scores
+ (measured in SIFT algorithm as the local contrast)
+
nOctaveLayers - The number of layers in each octave. 3 is the value used in D. Lowe paper. The
+ number of octaves is computed automatically from the image resolution.
+
+ (low-contrast) regions. The larger the threshold, the less features are produced by the detector.
+
+ Note: The contrast threshold will be divided by nOctaveLayers when the filtering is applied. When
+ nOctaveLayers is set to default and if you want to use the value used in D. Lowe paper, 0.03, set
+ this argument to 0.09.
+
+ is different from the contrastThreshold, i.e. the larger the edgeThreshold, the less features are
+ filtered out (more features are retained).
+
+ is captured with a weak camera with soft lenses, you might want to reduce the number.
+
+ index \(\texttt{x}\) to \(\texttt{2x}\). This prevents localization bias. The option
+ is disabled by default.
public static SIFT create(int nfeatures,
+ int nOctaveLayers,
+ double contrastThreshold)
+
+
Parameters:
+
nfeatures - The number of best features to retain. The features are ranked by their scores
+ (measured in SIFT algorithm as the local contrast)
+
nOctaveLayers - The number of layers in each octave. 3 is the value used in D. Lowe paper. The
+ number of octaves is computed automatically from the image resolution.
+
contrastThreshold - The contrast threshold used to filter out weak features in semi-uniform
+ (low-contrast) regions. The larger the threshold, the less features are produced by the detector.
+
+ Note: The contrast threshold will be divided by nOctaveLayers when the filtering is applied. When
+ nOctaveLayers is set to default and if you want to use the value used in D. Lowe paper, 0.03, set
+ this argument to 0.09.
+
+ is different from the contrastThreshold, i.e. the larger the edgeThreshold, the less features are
+ filtered out (more features are retained).
+
+ is captured with a weak camera with soft lenses, you might want to reduce the number.
+
+ index \(\texttt{x}\) to \(\texttt{2x}\). This prevents localization bias. The option
+ is disabled by default.
public static SIFT create(int nfeatures,
+ int nOctaveLayers,
+ double contrastThreshold,
+ double edgeThreshold)
+
+
Parameters:
+
nfeatures - The number of best features to retain. The features are ranked by their scores
+ (measured in SIFT algorithm as the local contrast)
+
nOctaveLayers - The number of layers in each octave. 3 is the value used in D. Lowe paper. The
+ number of octaves is computed automatically from the image resolution.
+
contrastThreshold - The contrast threshold used to filter out weak features in semi-uniform
+ (low-contrast) regions. The larger the threshold, the less features are produced by the detector.
+
+ Note: The contrast threshold will be divided by nOctaveLayers when the filtering is applied. When
+ nOctaveLayers is set to default and if you want to use the value used in D. Lowe paper, 0.03, set
+ this argument to 0.09.
+
edgeThreshold - The threshold used to filter out edge-like features. Note that the its meaning
+ is different from the contrastThreshold, i.e. the larger the edgeThreshold, the less features are
+ filtered out (more features are retained).
+
+ is captured with a weak camera with soft lenses, you might want to reduce the number.
+
+ index \(\texttt{x}\) to \(\texttt{2x}\). This prevents localization bias. The option
+ is disabled by default.
public static SIFT create(int nfeatures,
+ int nOctaveLayers,
+ double contrastThreshold,
+ double edgeThreshold,
+ double sigma)
+
+
Parameters:
+
nfeatures - The number of best features to retain. The features are ranked by their scores
+ (measured in SIFT algorithm as the local contrast)
+
nOctaveLayers - The number of layers in each octave. 3 is the value used in D. Lowe paper. The
+ number of octaves is computed automatically from the image resolution.
+
contrastThreshold - The contrast threshold used to filter out weak features in semi-uniform
+ (low-contrast) regions. The larger the threshold, the less features are produced by the detector.
+
+ Note: The contrast threshold will be divided by nOctaveLayers when the filtering is applied. When
+ nOctaveLayers is set to default and if you want to use the value used in D. Lowe paper, 0.03, set
+ this argument to 0.09.
+
edgeThreshold - The threshold used to filter out edge-like features. Note that the its meaning
+ is different from the contrastThreshold, i.e. the larger the edgeThreshold, the less features are
+ filtered out (more features are retained).
+
sigma - The sigma of the Gaussian applied to the input image at the octave \#0. If your image
+ is captured with a weak camera with soft lenses, you might want to reduce the number.
+
+ index \(\texttt{x}\) to \(\texttt{2x}\). This prevents localization bias. The option
+ is disabled by default.
public static SIFT create(int nfeatures,
+ int nOctaveLayers,
+ double contrastThreshold,
+ double edgeThreshold,
+ double sigma,
+ boolean enable_precise_upscale)
+
+
Parameters:
+
nfeatures - The number of best features to retain. The features are ranked by their scores
+ (measured in SIFT algorithm as the local contrast)
+
nOctaveLayers - The number of layers in each octave. 3 is the value used in D. Lowe paper. The
+ number of octaves is computed automatically from the image resolution.
+
contrastThreshold - The contrast threshold used to filter out weak features in semi-uniform
+ (low-contrast) regions. The larger the threshold, the less features are produced by the detector.
+
+ Note: The contrast threshold will be divided by nOctaveLayers when the filtering is applied. When
+ nOctaveLayers is set to default and if you want to use the value used in D. Lowe paper, 0.03, set
+ this argument to 0.09.
+
edgeThreshold - The threshold used to filter out edge-like features. Note that the its meaning
+ is different from the contrastThreshold, i.e. the larger the edgeThreshold, the less features are
+ filtered out (more features are retained).
+
sigma - The sigma of the Gaussian applied to the input image at the octave \#0. If your image
+ is captured with a weak camera with soft lenses, you might want to reduce the number.
+
enable_precise_upscale - Whether to enable precise upscaling in the scale pyramid, which maps
+ index \(\texttt{x}\) to \(\texttt{2x}\). This prevents localization bias. The option
+ is disabled by default.
public static SIFT create(int nfeatures,
+ int nOctaveLayers,
+ double contrastThreshold,
+ double edgeThreshold,
+ double sigma,
+ int descriptorType)
+
Create SIFT with specified descriptorType.
+
+
Parameters:
+
nfeatures - The number of best features to retain. The features are ranked by their scores
+ (measured in SIFT algorithm as the local contrast)
+
nOctaveLayers - The number of layers in each octave. 3 is the value used in D. Lowe paper. The
+ number of octaves is computed automatically from the image resolution.
+
contrastThreshold - The contrast threshold used to filter out weak features in semi-uniform
+ (low-contrast) regions. The larger the threshold, the less features are produced by the detector.
+
+ Note: The contrast threshold will be divided by nOctaveLayers when the filtering is applied. When
+ nOctaveLayers is set to default and if you want to use the value used in D. Lowe paper, 0.03, set
+ this argument to 0.09.
+
edgeThreshold - The threshold used to filter out edge-like features. Note that the its meaning
+ is different from the contrastThreshold, i.e. the larger the edgeThreshold, the less features are
+ filtered out (more features are retained).
+
sigma - The sigma of the Gaussian applied to the input image at the octave \#0. If your image
+ is captured with a weak camera with soft lenses, you might want to reduce the number.
+
descriptorType - The type of descriptors. Only CV_32F and CV_8U are supported.
+
+ index \(\texttt{x}\) to \(\texttt{2x}\). This prevents localization bias. The option
+ is disabled by default.
public static SIFT create(int nfeatures,
+ int nOctaveLayers,
+ double contrastThreshold,
+ double edgeThreshold,
+ double sigma,
+ int descriptorType,
+ boolean enable_precise_upscale)
+
Create SIFT with specified descriptorType.
+
+
Parameters:
+
nfeatures - The number of best features to retain. The features are ranked by their scores
+ (measured in SIFT algorithm as the local contrast)
+
nOctaveLayers - The number of layers in each octave. 3 is the value used in D. Lowe paper. The
+ number of octaves is computed automatically from the image resolution.
+
contrastThreshold - The contrast threshold used to filter out weak features in semi-uniform
+ (low-contrast) regions. The larger the threshold, the less features are produced by the detector.
+
+ Note: The contrast threshold will be divided by nOctaveLayers when the filtering is applied. When
+ nOctaveLayers is set to default and if you want to use the value used in D. Lowe paper, 0.03, set
+ this argument to 0.09.
+
edgeThreshold - The threshold used to filter out edge-like features. Note that the its meaning
+ is different from the contrastThreshold, i.e. the larger the edgeThreshold, the less features are
+ filtered out (more features are retained).
+
sigma - The sigma of the Gaussian applied to the input image at the octave \#0. If your image
+ is captured with a weak camera with soft lenses, you might want to reduce the number.
+
descriptorType - The type of descriptors. Only CV_32F and CV_8U are supported.
+
enable_precise_upscale - Whether to enable precise upscaling in the scale pyramid, which maps
+ index \(\texttt{x}\) to \(\texttt{2x}\). This prevents localization bias. The option
+ is disabled by default.
public class SimpleBlobDetector
+extends Feature2D
+
Class for extracting blobs from an image. :
+
+ The class implements a simple algorithm for extracting blobs from an image:
+
+ 1. Convert the source image to binary images by applying thresholding with several thresholds from
+ minThreshold (inclusive) to maxThreshold (exclusive) with distance thresholdStep between
+ neighboring thresholds.
+ 2. Extract connected components from every binary image by findContours and calculate their
+ centers.
+ 3. Group centers from several binary images by their coordinates. Close centers form one group that
+ corresponds to one blob, which is controlled by the minDistBetweenBlobs parameter.
+ 4. From the groups, estimate final centers of blobs and their radiuses and return as locations and
+ sizes of keypoints.
+
+ This class performs several filtrations of returned blobs. You should set filterBy\* to true/false
+ to turn on/off corresponding filtration. Available filtrations:
+
+
+
+ By color. This filter compares the intensity of a binary image at the center of a blob to
+ blobColor. If they differ, the blob is filtered out. Use blobColor = 0 to extract dark blobs
+ and blobColor = 255 to extract light blobs.
+
+
+ By area. Extracted blobs have an area between minArea (inclusive) and maxArea (exclusive).
+
+
+ By circularity. Extracted blobs have circularity
+ (\(\frac{4*\pi*Area}{perimeter * perimeter}\)) between minCircularity (inclusive) and
+ maxCircularity (exclusive).
+
+
+ By ratio of the minimum inertia to maximum inertia. Extracted blobs have this ratio
+ between minInertiaRatio (inclusive) and maxInertiaRatio (exclusive).
+
+
+ By convexity. Extracted blobs have convexity (area / area of blob convex hull) between
+ minConvexity (inclusive) and maxConvexity (exclusive).
+
+
+
+ Default values of parameters are tuned to extract dark circular blobs.
Maximally stable extremal region extractor
+
+ The class encapsulates all the parameters of the %MSER extraction algorithm (see [wiki
+ article](http://en.wikipedia.org/wiki/Maximally_stable_extremal_regions)).
Returns the number of images inside the give file
+
+ The function imcount will return the number of pages in a multi-page image, or 1 for single-page images
Returns the number of images inside the give file
+
+ The function imcount will return the number of pages in a multi-page image, or 1 for single-page images
public static long imcount(java.lang.String filename)
+
Returns the number of images inside the give file
+
+ The function imcount will return the number of pages in a multi-page image, or 1 for single-page images
public static long imcount(java.lang.String filename,
+ int flags)
+
Returns the number of images inside the give file
+
+ The function imcount will return the number of pages in a multi-page image, or 1 for single-page images
+
+
Parameters:
+
filename - Name of file to be loaded.
+
flags - Flag that can take values of cv::ImreadModes, default with cv::IMREAD_ANYCOLOR.
Reads an image from a buffer in memory.
+
+ The function imdecode reads an image from the specified buffer in the memory. If the buffer is too short or
+ contains invalid data, the function returns an empty matrix ( Mat::data==NULL ).
+
+ See cv::imread for the list of supported formats and flags description.
+
+ Note: In the case of color images, the decoded images will have the channels stored in B G R order.
+
+
Parameters:
+
buf - Input array or vector of bytes.
+
flags - The same flags as in cv::imread, see cv::ImreadModes.
public static boolean imdecodemulti(Mat buf,
+ int flags,
+ java.util.List<Mat> mats)
+
Reads a multi-page image from a buffer in memory.
+
+ The function imdecodemulti reads a multi-page image from the specified buffer in the memory. If the buffer is too short or
+ contains invalid data, the function returns false.
+
+ See cv::imreadmulti for the list of supported formats and flags description.
+
+ Note: In the case of color images, the decoded images will have the channels stored in B G R order.
+
+
Parameters:
+
buf - Input array or vector of bytes.
+
flags - The same flags as in cv::imread, see cv::ImreadModes.
+
mats - A vector of Mat objects holding each page, if more than one.
public static boolean imencode(java.lang.String ext,
+ Mat img,
+ MatOfByte buf)
+
Encodes an image into a memory buffer.
+
+ The function imencode compresses the image and stores it in the memory buffer that is resized to fit the
+ result. See cv::imwrite for the list of supported formats and flags description.
+
+
Parameters:
+
ext - File extension that defines the output format. Must include a leading period.
+
img - Image to be written.
+
buf - Output buffer resized to fit the compressed image.
public static boolean imencode(java.lang.String ext,
+ Mat img,
+ MatOfByte buf,
+ MatOfInt params)
+
Encodes an image into a memory buffer.
+
+ The function imencode compresses the image and stores it in the memory buffer that is resized to fit the
+ result. See cv::imwrite for the list of supported formats and flags description.
+
+
Parameters:
+
ext - File extension that defines the output format. Must include a leading period.
+
img - Image to be written.
+
buf - Output buffer resized to fit the compressed image.
+
params - Format-specific parameters. See cv::imwrite and cv::ImwriteFlags.
public static Mat imread(java.lang.String filename)
+
Loads an image from a file.
+
+ imread
+
+ The function imread loads an image from the specified file and returns it. If the image cannot be
+ read (because of missing file, improper permissions, unsupported or invalid format), the function
+ returns an empty matrix ( Mat::data==NULL ).
+
+ Currently, the following file formats are supported:
+
+
+
+ Windows bitmaps - \*.bmp, \*.dib (always supported)
+
+
+ JPEG files - \*.jpeg, \*.jpg, \*.jpe (see the *Note* section)
+
+
+ JPEG 2000 files - \*.jp2 (see the *Note* section)
+
+
+ Portable Network Graphics - \*.png (see the *Note* section)
+
+ Raster and Vector geospatial data supported by GDAL (see the *Note* section)
+
+
+
+ Note:
+
+
+ The function determines the type of an image by the content, not by the file extension.
+
+
+ In the case of color images, the decoded images will have the channels stored in B G R order.
+
+
+ When using IMREAD_GRAYSCALE, the codec's internal grayscale conversion will be used, if available.
+ Results may differ to the output of cvtColor()
+
+
+ On Microsoft Windows\* OS and MacOSX\*, the codecs shipped with an OpenCV image (libjpeg,
+ libpng, libtiff, and libjasper) are used by default. So, OpenCV can always read JPEGs, PNGs,
+ and TIFFs. On MacOSX, there is also an option to use native MacOSX image readers. But beware
+ that currently these native image loaders give images with different pixel values because of
+ the color management embedded into MacOSX.
+
+
+ On Linux\*, BSD flavors and other Unix-like open-source operating systems, OpenCV looks for
+ codecs supplied with an OS image. Install the relevant packages (do not forget the development
+ files, for example, "libjpeg-dev", in Debian\* and Ubuntu\*) to get the codec support or turn
+ on the OPENCV_BUILD_3RDPARTY_LIBS flag in CMake.
+
+
+ In the case you set *WITH_GDAL* flag to true in CMake and REF: IMREAD_LOAD_GDAL to load the image,
+ then the [GDAL](http://www.gdal.org) driver will be used in order to decode the image, supporting
+ the following formats: [Raster](http://www.gdal.org/formats_list.html),
+ [Vector](http://www.gdal.org/ogr_formats.html).
+
+
+ If EXIF information is embedded in the image file, the EXIF orientation will be taken into account
+ and thus the image will be rotated accordingly except if the flags REF: IMREAD_IGNORE_ORIENTATION
+ or REF: IMREAD_UNCHANGED are passed.
+
+
+ Use the IMREAD_UNCHANGED flag to keep the floating point values from PFM image.
+
+
+ By default number of pixels must be less than 2^30. Limit can be set using system
+ variable OPENCV_IO_MAX_IMAGE_PIXELS
+
public static Mat imread(java.lang.String filename,
+ int flags)
+
Loads an image from a file.
+
+ imread
+
+ The function imread loads an image from the specified file and returns it. If the image cannot be
+ read (because of missing file, improper permissions, unsupported or invalid format), the function
+ returns an empty matrix ( Mat::data==NULL ).
+
+ Currently, the following file formats are supported:
+
+
+
+ Windows bitmaps - \*.bmp, \*.dib (always supported)
+
+
+ JPEG files - \*.jpeg, \*.jpg, \*.jpe (see the *Note* section)
+
+
+ JPEG 2000 files - \*.jp2 (see the *Note* section)
+
+
+ Portable Network Graphics - \*.png (see the *Note* section)
+
+ Raster and Vector geospatial data supported by GDAL (see the *Note* section)
+
+
+
+ Note:
+
+
+ The function determines the type of an image by the content, not by the file extension.
+
+
+ In the case of color images, the decoded images will have the channels stored in B G R order.
+
+
+ When using IMREAD_GRAYSCALE, the codec's internal grayscale conversion will be used, if available.
+ Results may differ to the output of cvtColor()
+
+
+ On Microsoft Windows\* OS and MacOSX\*, the codecs shipped with an OpenCV image (libjpeg,
+ libpng, libtiff, and libjasper) are used by default. So, OpenCV can always read JPEGs, PNGs,
+ and TIFFs. On MacOSX, there is also an option to use native MacOSX image readers. But beware
+ that currently these native image loaders give images with different pixel values because of
+ the color management embedded into MacOSX.
+
+
+ On Linux\*, BSD flavors and other Unix-like open-source operating systems, OpenCV looks for
+ codecs supplied with an OS image. Install the relevant packages (do not forget the development
+ files, for example, "libjpeg-dev", in Debian\* and Ubuntu\*) to get the codec support or turn
+ on the OPENCV_BUILD_3RDPARTY_LIBS flag in CMake.
+
+
+ In the case you set *WITH_GDAL* flag to true in CMake and REF: IMREAD_LOAD_GDAL to load the image,
+ then the [GDAL](http://www.gdal.org) driver will be used in order to decode the image, supporting
+ the following formats: [Raster](http://www.gdal.org/formats_list.html),
+ [Vector](http://www.gdal.org/ogr_formats.html).
+
+
+ If EXIF information is embedded in the image file, the EXIF orientation will be taken into account
+ and thus the image will be rotated accordingly except if the flags REF: IMREAD_IGNORE_ORIENTATION
+ or REF: IMREAD_UNCHANGED are passed.
+
+
+ Use the IMREAD_UNCHANGED flag to keep the floating point values from PFM image.
+
+
+ By default number of pixels must be less than 2^30. Limit can be set using system
+ variable OPENCV_IO_MAX_IMAGE_PIXELS
+
+
+
+
Parameters:
+
filename - Name of file to be loaded.
+
flags - Flag that can take values of cv::ImreadModes
public static boolean imreadmulti(java.lang.String filename,
+ java.util.List<Mat> mats,
+ int start,
+ int count)
+
Loads a of images of a multi-page image from a file.
+
+ The function imreadmulti loads a specified range from a multi-page image from the specified file into a vector of Mat objects.
+
+
Parameters:
+
filename - Name of file to be loaded.
+
mats - A vector of Mat objects holding each page.
+
start - Start index of the image to load
+
count - Count number of images to load
+ SEE: cv::imread
public static boolean imreadmulti(java.lang.String filename,
+ java.util.List<Mat> mats,
+ int start,
+ int count,
+ int flags)
+
Loads a of images of a multi-page image from a file.
+
+ The function imreadmulti loads a specified range from a multi-page image from the specified file into a vector of Mat objects.
+
+
Parameters:
+
filename - Name of file to be loaded.
+
mats - A vector of Mat objects holding each page.
+
start - Start index of the image to load
+
count - Count number of images to load
+
flags - Flag that can take values of cv::ImreadModes, default with cv::IMREAD_ANYCOLOR.
+ SEE: cv::imread
public static boolean imwrite(java.lang.String filename,
+ Mat img)
+
Saves an image to a specified file.
+
+ The function imwrite saves the image to the specified file. The image format is chosen based on the
+ filename extension (see cv::imread for the list of extensions). In general, only 8-bit unsigned (CV_8U)
+ single-channel or 3-channel (with 'BGR' channel order) images
+ can be saved using this function, with these exceptions:
+
+
+
+ With OpenEXR encoder, only 32-bit float (CV_32F) images can be saved.
+
+
+ 8-bit unsigned (CV_8U) images are not supported.
+
+
+
+ With Radiance HDR encoder, non 64-bit float (CV_64F) images can be saved.
+
+
+ All images will be converted to 32-bit float (CV_32F).
+
+
+
+ With JPEG 2000 encoder, 8-bit unsigned (CV_8U) and 16-bit unsigned (CV_16U) images can be saved.
+
+
+ With PAM encoder, 8-bit unsigned (CV_8U) and 16-bit unsigned (CV_16U) images can be saved.
+
+
+ With PNG encoder, 8-bit unsigned (CV_8U) and 16-bit unsigned (CV_16U) images can be saved.
+
+
+ PNG images with an alpha channel can be saved using this function. To do this, create
+ 8-bit (or 16-bit) 4-channel image BGRA, where the alpha channel goes last. Fully transparent pixels
+ should have alpha set to 0, fully opaque pixels should have alpha set to 255/65535 (see the code sample below).
+
+
+
+ With PGM/PPM encoder, 8-bit unsigned (CV_8U) and 16-bit unsigned (CV_16U) images can be saved.
+
+
+ With TIFF encoder, 8-bit unsigned (CV_8U), 16-bit unsigned (CV_16U),
+ 32-bit float (CV_32F) and 64-bit float (CV_64F) images can be saved.
+
+
+ Multiple images (vector of Mat) can be saved in TIFF format (see the code sample below).
+
+
+ 32-bit float 3-channel (CV_32FC3) TIFF images will be saved
+ using the LogLuv high dynamic range encoding (4 bytes per pixel)
+
+
+
+ If the image format is not supported, the image will be converted to 8-bit unsigned (CV_8U) and saved that way.
+
+
+
+ If the format, depth or channel order is different, use
+ Mat::convertTo and cv::cvtColor to convert it before saving. Or, use the universal FileStorage I/O
+ functions to save the image to XML or YAML format.
+
+ The sample below shows how to create a BGRA image, how to set custom compression parameters and save it to a PNG file.
+ It also demonstrates how to save multiple images in a TIFF file:
+ INCLUDE: snippets/imgcodecs_imwrite.cpp
+
+
Parameters:
+
filename - Name of the file.
+
img - (Mat or vector of Mat) Image or Images to be saved.
public static boolean imwrite(java.lang.String filename,
+ Mat img,
+ MatOfInt params)
+
Saves an image to a specified file.
+
+ The function imwrite saves the image to the specified file. The image format is chosen based on the
+ filename extension (see cv::imread for the list of extensions). In general, only 8-bit unsigned (CV_8U)
+ single-channel or 3-channel (with 'BGR' channel order) images
+ can be saved using this function, with these exceptions:
+
+
+
+ With OpenEXR encoder, only 32-bit float (CV_32F) images can be saved.
+
+
+ 8-bit unsigned (CV_8U) images are not supported.
+
+
+
+ With Radiance HDR encoder, non 64-bit float (CV_64F) images can be saved.
+
+
+ All images will be converted to 32-bit float (CV_32F).
+
+
+
+ With JPEG 2000 encoder, 8-bit unsigned (CV_8U) and 16-bit unsigned (CV_16U) images can be saved.
+
+
+ With PAM encoder, 8-bit unsigned (CV_8U) and 16-bit unsigned (CV_16U) images can be saved.
+
+
+ With PNG encoder, 8-bit unsigned (CV_8U) and 16-bit unsigned (CV_16U) images can be saved.
+
+
+ PNG images with an alpha channel can be saved using this function. To do this, create
+ 8-bit (or 16-bit) 4-channel image BGRA, where the alpha channel goes last. Fully transparent pixels
+ should have alpha set to 0, fully opaque pixels should have alpha set to 255/65535 (see the code sample below).
+
+
+
+ With PGM/PPM encoder, 8-bit unsigned (CV_8U) and 16-bit unsigned (CV_16U) images can be saved.
+
+
+ With TIFF encoder, 8-bit unsigned (CV_8U), 16-bit unsigned (CV_16U),
+ 32-bit float (CV_32F) and 64-bit float (CV_64F) images can be saved.
+
+
+ Multiple images (vector of Mat) can be saved in TIFF format (see the code sample below).
+
+
+ 32-bit float 3-channel (CV_32FC3) TIFF images will be saved
+ using the LogLuv high dynamic range encoding (4 bytes per pixel)
+
+
+
+ If the image format is not supported, the image will be converted to 8-bit unsigned (CV_8U) and saved that way.
+
+
+
+ If the format, depth or channel order is different, use
+ Mat::convertTo and cv::cvtColor to convert it before saving. Or, use the universal FileStorage I/O
+ functions to save the image to XML or YAML format.
+
+ The sample below shows how to create a BGRA image, how to set custom compression parameters and save it to a PNG file.
+ It also demonstrates how to save multiple images in a TIFF file:
+ INCLUDE: snippets/imgcodecs_imwrite.cpp
+
+
Parameters:
+
filename - Name of the file.
+
img - (Mat or vector of Mat) Image or Images to be saved.
+
params - Format-specific parameters encoded as pairs (paramId_1, paramValue_1, paramId_2, paramValue_2, ... .) see cv::ImwriteFlags
finds arbitrary template in the grayscale image using Generalized Hough Transform
+
+ Detects position only without translation and rotation CITE: Ballard1981 .
computes the connected components labeled image of boolean image
+
+ image with 4 or 8 way connectivity - returns N, the total number of labels [0, N-1] where 0
+ represents the background label.
computes the connected components labeled image of boolean image and also produces a statistics output for each label
+
+ image with 4 or 8 way connectivity - returns N, the total number of labels [0, N-1] where 0
+ represents the background label.
drawContours(Mat image,
+ java.util.List<MatOfPoint> contours,
+ int contourIdx,
+ Scalar color,
+ int thickness,
+ int lineType)
+
Draws contours outlines or filled contours.
+
+
+
+
static void
+
drawContours(Mat image,
+ java.util.List<MatOfPoint> contours,
+ int contourIdx,
+ Scalar color,
+ int thickness,
+ int lineType,
+ Mat hierarchy)
+
Draws contours outlines or filled contours.
+
+
+
+
static void
+
drawContours(Mat image,
+ java.util.List<MatOfPoint> contours,
+ int contourIdx,
+ Scalar color,
+ int thickness,
+ int lineType,
+ Mat hierarchy,
+ int maxLevel)
+
Draws contours outlines or filled contours.
+
+
+
+
static void
+
drawContours(Mat image,
+ java.util.List<MatOfPoint> contours,
+ int contourIdx,
+ Scalar color,
+ int thickness,
+ int lineType,
+ Mat hierarchy,
+ int maxLevel,
+ Point offset)
+
Same as above, but returns also quality measure of the detected corners.
+
+
+
+
static void
+
goodFeaturesToTrackWithQuality(Mat image,
+ Mat corners,
+ int maxCorners,
+ double qualityLevel,
+ double minDistance,
+ Mat mask,
+ Mat cornersQuality,
+ int blockSize)
+
Same as above, but returns also quality measure of the detected corners.
+
+
+
+
static void
+
goodFeaturesToTrackWithQuality(Mat image,
+ Mat corners,
+ int maxCorners,
+ double qualityLevel,
+ double minDistance,
+ Mat mask,
+ Mat cornersQuality,
+ int blockSize,
+ int gradientSize)
+
Same as above, but returns also quality measure of the detected corners.
+
+
+
+
static void
+
goodFeaturesToTrackWithQuality(Mat image,
+ Mat corners,
+ int maxCorners,
+ double qualityLevel,
+ double minDistance,
+ Mat mask,
+ Mat cornersQuality,
+ int blockSize,
+ int gradientSize,
+ boolean useHarrisDetector)
+
Same as above, but returns also quality measure of the detected corners.
+
+
+
+
static void
+
goodFeaturesToTrackWithQuality(Mat image,
+ Mat corners,
+ int maxCorners,
+ double qualityLevel,
+ double minDistance,
+ Mat mask,
+ Mat cornersQuality,
+ int blockSize,
+ int gradientSize,
+ boolean useHarrisDetector,
+ double k)
+
Same as above, but returns also quality measure of the detected corners.
+
+
+
+
static void
+
grabCut(Mat img,
+ Mat mask,
+ Rect rect,
+ Mat bgdModel,
+ Mat fgdModel,
+ int iterCount)
+
Runs the GrabCut algorithm.
+
+
+
+
static void
+
grabCut(Mat img,
+ Mat mask,
+ Rect rect,
+ Mat bgdModel,
+ Mat fgdModel,
+ int iterCount,
+ int mode)
+
Runs the GrabCut algorithm.
+
+
+
+
static void
+
HoughCircles(Mat image,
+ Mat circles,
+ int method,
+ double dp,
+ double minDist)
+
Finds circles in a grayscale image using the Hough transform.
+
+
+
+
static void
+
HoughCircles(Mat image,
+ Mat circles,
+ int method,
+ double dp,
+ double minDist,
+ double param1)
+
Finds circles in a grayscale image using the Hough transform.
Calculates the first order image derivative in both x and y using a Sobel operator
+
+ Equivalent to calling:
+
+
+ Sobel( src, dx, CV_16SC1, 1, 0, 3 );
+ Sobel( src, dy, CV_16SC1, 0, 1, 3 );
+
Calculates the first order image derivative in both x and y using a Sobel operator
+
+ Equivalent to calling:
+
+
+ Sobel( src, dx, CV_16SC1, 1, 0, 3 );
+ Sobel( src, dy, CV_16SC1, 0, 1, 3 );
+
Calculates the first order image derivative in both x and y using a Sobel operator
+
+ Equivalent to calling:
+
+
+ Sobel( src, dx, CV_16SC1, 1, 0, 3 );
+ Sobel( src, dy, CV_16SC1, 0, 1, 3 );
+
Adds an image to the accumulator image.
+
+ The function adds src or some of its elements to dst :
+
+ \(\texttt{dst} (x,y) \leftarrow \texttt{dst} (x,y) + \texttt{src} (x,y) \quad \text{if} \quad \texttt{mask} (x,y) \ne 0\)
+
+ The function supports multi-channel images. Each channel is processed independently.
+
+ The function cv::accumulate can be used, for example, to collect statistics of a scene background
+ viewed by a still camera and for the further foreground-background segmentation.
+
+
Parameters:
+
src - Input image of type CV_8UC(n), CV_16UC(n), CV_32FC(n) or CV_64FC(n), where n is a positive integer.
+
dst - %Accumulator image with the same number of channels as input image, and a depth of CV_32F or CV_64F.
+
+ SEE: accumulateSquare, accumulateProduct, accumulateWeighted
public static void accumulate(Mat src,
+ Mat dst,
+ Mat mask)
+
Adds an image to the accumulator image.
+
+ The function adds src or some of its elements to dst :
+
+ \(\texttt{dst} (x,y) \leftarrow \texttt{dst} (x,y) + \texttt{src} (x,y) \quad \text{if} \quad \texttt{mask} (x,y) \ne 0\)
+
+ The function supports multi-channel images. Each channel is processed independently.
+
+ The function cv::accumulate can be used, for example, to collect statistics of a scene background
+ viewed by a still camera and for the further foreground-background segmentation.
+
+
Parameters:
+
src - Input image of type CV_8UC(n), CV_16UC(n), CV_32FC(n) or CV_64FC(n), where n is a positive integer.
+
dst - %Accumulator image with the same number of channels as input image, and a depth of CV_32F or CV_64F.
public static void accumulateProduct(Mat src1,
+ Mat src2,
+ Mat dst)
+
Adds the per-element product of two input images to the accumulator image.
+
+ The function adds the product of two images or their selected regions to the accumulator dst :
+
+ \(\texttt{dst} (x,y) \leftarrow \texttt{dst} (x,y) + \texttt{src1} (x,y) \cdot \texttt{src2} (x,y) \quad \text{if} \quad \texttt{mask} (x,y) \ne 0\)
+
+ The function supports multi-channel images. Each channel is processed independently.
+
+
Parameters:
+
src1 - First input image, 1- or 3-channel, 8-bit or 32-bit floating point.
+
src2 - Second input image of the same type and the same size as src1 .
+
dst - %Accumulator image with the same number of channels as input images, 32-bit or 64-bit
+ floating-point.
+
+ SEE: accumulate, accumulateSquare, accumulateWeighted
public static void accumulateProduct(Mat src1,
+ Mat src2,
+ Mat dst,
+ Mat mask)
+
Adds the per-element product of two input images to the accumulator image.
+
+ The function adds the product of two images or their selected regions to the accumulator dst :
+
+ \(\texttt{dst} (x,y) \leftarrow \texttt{dst} (x,y) + \texttt{src1} (x,y) \cdot \texttt{src2} (x,y) \quad \text{if} \quad \texttt{mask} (x,y) \ne 0\)
+
+ The function supports multi-channel images. Each channel is processed independently.
+
+
Parameters:
+
src1 - First input image, 1- or 3-channel, 8-bit or 32-bit floating point.
+
src2 - Second input image of the same type and the same size as src1 .
+
dst - %Accumulator image with the same number of channels as input images, 32-bit or 64-bit
+ floating-point.
public static void accumulateSquare(Mat src,
+ Mat dst)
+
Adds the square of a source image to the accumulator image.
+
+ The function adds the input image src or its selected region, raised to a power of 2, to the
+ accumulator dst :
+
+ \(\texttt{dst} (x,y) \leftarrow \texttt{dst} (x,y) + \texttt{src} (x,y)^2 \quad \text{if} \quad \texttt{mask} (x,y) \ne 0\)
+
+ The function supports multi-channel images. Each channel is processed independently.
+
+
Parameters:
+
src - Input image as 1- or 3-channel, 8-bit or 32-bit floating point.
+
dst - %Accumulator image with the same number of channels as input image, 32-bit or 64-bit
+ floating-point.
+
+ SEE: accumulateSquare, accumulateProduct, accumulateWeighted
public static void accumulateSquare(Mat src,
+ Mat dst,
+ Mat mask)
+
Adds the square of a source image to the accumulator image.
+
+ The function adds the input image src or its selected region, raised to a power of 2, to the
+ accumulator dst :
+
+ \(\texttt{dst} (x,y) \leftarrow \texttt{dst} (x,y) + \texttt{src} (x,y)^2 \quad \text{if} \quad \texttt{mask} (x,y) \ne 0\)
+
+ The function supports multi-channel images. Each channel is processed independently.
+
+
Parameters:
+
src - Input image as 1- or 3-channel, 8-bit or 32-bit floating point.
+
dst - %Accumulator image with the same number of channels as input image, 32-bit or 64-bit
+ floating-point.
public static void accumulateWeighted(Mat src,
+ Mat dst,
+ double alpha)
+
Updates a running average.
+
+ The function calculates the weighted sum of the input image src and the accumulator dst so that dst
+ becomes a running average of a frame sequence:
+
+ \(\texttt{dst} (x,y) \leftarrow (1- \texttt{alpha} ) \cdot \texttt{dst} (x,y) + \texttt{alpha} \cdot \texttt{src} (x,y) \quad \text{if} \quad \texttt{mask} (x,y) \ne 0\)
+
+ That is, alpha regulates the update speed (how fast the accumulator "forgets" about earlier images).
+ The function supports multi-channel images. Each channel is processed independently.
+
+
Parameters:
+
src - Input image as 1- or 3-channel, 8-bit or 32-bit floating point.
+
dst - %Accumulator image with the same number of channels as input image, 32-bit or 64-bit
+ floating-point.
+
alpha - Weight of the input image.
+
+ SEE: accumulate, accumulateSquare, accumulateProduct
public static void accumulateWeighted(Mat src,
+ Mat dst,
+ double alpha,
+ Mat mask)
+
Updates a running average.
+
+ The function calculates the weighted sum of the input image src and the accumulator dst so that dst
+ becomes a running average of a frame sequence:
+
+ \(\texttt{dst} (x,y) \leftarrow (1- \texttt{alpha} ) \cdot \texttt{dst} (x,y) + \texttt{alpha} \cdot \texttt{src} (x,y) \quad \text{if} \quad \texttt{mask} (x,y) \ne 0\)
+
+ That is, alpha regulates the update speed (how fast the accumulator "forgets" about earlier images).
+ The function supports multi-channel images. Each channel is processed independently.
+
+
Parameters:
+
src - Input image as 1- or 3-channel, 8-bit or 32-bit floating point.
+
dst - %Accumulator image with the same number of channels as input image, 32-bit or 64-bit
+ floating-point.
+ THRESH_BINARY_INV
+ \(dst(x,y) = \fork{0}{if \(src(x,y) > T(x,y)\)}{\texttt{maxValue}}{otherwise}\)
+ where \(T(x,y)\) is a threshold calculated individually for each pixel (see adaptiveMethod parameter).
+
+
+
+ The function can process the image in-place.
+
+
Parameters:
+
src - Source 8-bit single-channel image.
+
dst - Destination image of the same size and the same type as src.
+
maxValue - Non-zero value assigned to the pixels for which the condition is satisfied
+
adaptiveMethod - Adaptive thresholding algorithm to use, see #AdaptiveThresholdTypes.
+ The #BORDER_REPLICATE | #BORDER_ISOLATED is used to process boundaries.
+
thresholdType - Thresholding type that must be either #THRESH_BINARY or #THRESH_BINARY_INV,
+ see #ThresholdTypes.
+
blockSize - Size of a pixel neighborhood that is used to calculate a threshold value for the
+ pixel: 3, 5, 7, and so on.
+
C - Constant subtracted from the mean or weighted mean (see the details below). Normally, it
+ is positive but may be zero or negative as well.
+
+ SEE: threshold, blur, GaussianBlur
Approximates a polygonal curve(s) with the specified precision.
+
+ The function cv::approxPolyDP approximates a curve or a polygon with another curve/polygon with less
+ vertices so that the distance between them is less or equal to the specified precision. It uses the
+ Douglas-Peucker algorithm <http://en.wikipedia.org/wiki/Ramer-Douglas-Peucker_algorithm>
+
+
Parameters:
+
curve - Input vector of a 2D point stored in std::vector or Mat
+
approxCurve - Result of the approximation. The type should match the type of the input curve.
+
epsilon - Parameter specifying the approximation accuracy. This is the maximum distance
+ between the original curve and its approximation.
+
closed - If true, the approximated curve is closed (its first and last vertices are
+ connected). Otherwise, it is not closed.
public static void arrowedLine(Mat img,
+ Point pt1,
+ Point pt2,
+ Scalar color)
+
Draws an arrow segment pointing from the first point to the second one.
+
+ The function cv::arrowedLine draws an arrow between pt1 and pt2 points in the image. See also #line.
public static void arrowedLine(Mat img,
+ Point pt1,
+ Point pt2,
+ Scalar color,
+ int thickness)
+
Draws an arrow segment pointing from the first point to the second one.
+
+ The function cv::arrowedLine draws an arrow between pt1 and pt2 points in the image. See also #line.
public static void arrowedLine(Mat img,
+ Point pt1,
+ Point pt2,
+ Scalar color,
+ int thickness,
+ int line_type)
+
Draws an arrow segment pointing from the first point to the second one.
+
+ The function cv::arrowedLine draws an arrow between pt1 and pt2 points in the image. See also #line.
public static void arrowedLine(Mat img,
+ Point pt1,
+ Point pt2,
+ Scalar color,
+ int thickness,
+ int line_type,
+ int shift)
+
Draws an arrow segment pointing from the first point to the second one.
+
+ The function cv::arrowedLine draws an arrow between pt1 and pt2 points in the image. See also #line.
+
+
Parameters:
+
img - Image.
+
pt1 - The point the arrow starts from.
+
pt2 - The point the arrow points to.
+
color - Line color.
+
thickness - Line thickness.
+
line_type - Type of the line. See #LineTypes
+
shift - Number of fractional bits in the point coordinates.
public static void arrowedLine(Mat img,
+ Point pt1,
+ Point pt2,
+ Scalar color,
+ int thickness,
+ int line_type,
+ int shift,
+ double tipLength)
+
Draws an arrow segment pointing from the first point to the second one.
+
+ The function cv::arrowedLine draws an arrow between pt1 and pt2 points in the image. See also #line.
+
+
Parameters:
+
img - Image.
+
pt1 - The point the arrow starts from.
+
pt2 - The point the arrow points to.
+
color - Line color.
+
thickness - Line thickness.
+
line_type - Type of the line. See #LineTypes
+
shift - Number of fractional bits in the point coordinates.
+
tipLength - The length of the arrow tip in relation to the arrow length
public static void bilateralFilter(Mat src,
+ Mat dst,
+ int d,
+ double sigmaColor,
+ double sigmaSpace)
+
Applies the bilateral filter to an image.
+
+ The function applies bilateral filtering to the input image, as described in
+ http://www.dai.ed.ac.uk/CVonline/LOCAL_COPIES/MANDUCHI1/Bilateral_Filtering.html
+ bilateralFilter can reduce unwanted noise very well while keeping edges fairly sharp. However, it is
+ very slow compared to most filters.
+
+ _Sigma values_: For simplicity, you can set the 2 sigma values to be the same. If they are small (<
+ 10), the filter will not have much effect, whereas if they are large (> 150), they will have a very
+ strong effect, making the image look "cartoonish".
+
+ _Filter size_: Large filters (d > 5) are very slow, so it is recommended to use d=5 for real-time
+ applications, and perhaps d=9 for offline applications that need heavy noise filtering.
+
+ This filter does not work inplace.
+
+
Parameters:
+
src - Source 8-bit or floating-point, 1-channel or 3-channel image.
+
dst - Destination image of the same size and type as src .
+
d - Diameter of each pixel neighborhood that is used during filtering. If it is non-positive,
+ it is computed from sigmaSpace.
+
sigmaColor - Filter sigma in the color space. A larger value of the parameter means that
+ farther colors within the pixel neighborhood (see sigmaSpace) will be mixed together, resulting
+ in larger areas of semi-equal color.
+
sigmaSpace - Filter sigma in the coordinate space. A larger value of the parameter means that
+ farther pixels will influence each other as long as their colors are close enough (see sigmaColor
+ ). When d>0, it specifies the neighborhood size regardless of sigmaSpace. Otherwise, d is
+ proportional to sigmaSpace.
public static void bilateralFilter(Mat src,
+ Mat dst,
+ int d,
+ double sigmaColor,
+ double sigmaSpace,
+ int borderType)
+
Applies the bilateral filter to an image.
+
+ The function applies bilateral filtering to the input image, as described in
+ http://www.dai.ed.ac.uk/CVonline/LOCAL_COPIES/MANDUCHI1/Bilateral_Filtering.html
+ bilateralFilter can reduce unwanted noise very well while keeping edges fairly sharp. However, it is
+ very slow compared to most filters.
+
+ _Sigma values_: For simplicity, you can set the 2 sigma values to be the same. If they are small (<
+ 10), the filter will not have much effect, whereas if they are large (> 150), they will have a very
+ strong effect, making the image look "cartoonish".
+
+ _Filter size_: Large filters (d > 5) are very slow, so it is recommended to use d=5 for real-time
+ applications, and perhaps d=9 for offline applications that need heavy noise filtering.
+
+ This filter does not work inplace.
+
+
Parameters:
+
src - Source 8-bit or floating-point, 1-channel or 3-channel image.
+
dst - Destination image of the same size and type as src .
+
d - Diameter of each pixel neighborhood that is used during filtering. If it is non-positive,
+ it is computed from sigmaSpace.
+
sigmaColor - Filter sigma in the color space. A larger value of the parameter means that
+ farther colors within the pixel neighborhood (see sigmaSpace) will be mixed together, resulting
+ in larger areas of semi-equal color.
+
sigmaSpace - Filter sigma in the coordinate space. A larger value of the parameter means that
+ farther pixels will influence each other as long as their colors are close enough (see sigmaColor
+ ). When d>0, it specifies the neighborhood size regardless of sigmaSpace. Otherwise, d is
+ proportional to sigmaSpace.
+
borderType - border mode used to extrapolate pixels outside of the image, see #BorderTypes
public static void blur(Mat src,
+ Mat dst,
+ Size ksize)
+
Blurs an image using the normalized box filter.
+
+ The function smooths an image using the kernel:
+
+ \(\texttt{K} = \frac{1}{\texttt{ksize.width*ksize.height}} \begin{bmatrix} 1 & 1 & 1 & \cdots & 1 & 1 \\ 1 & 1 & 1 & \cdots & 1 & 1 \\ \hdotsfor{6} \\ 1 & 1 & 1 & \cdots & 1 & 1 \\ \end{bmatrix}\)
+
+ The call blur(src, dst, ksize, anchor, borderType) is equivalent to `boxFilter(src, dst, src.type(), ksize,
+ anchor, true, borderType)`.
+
+
Parameters:
+
src - input image; it can have any number of channels, which are processed independently, but
+ the depth should be CV_8U, CV_16U, CV_16S, CV_32F or CV_64F.
+
dst - output image of the same size and type as src.
public static void blur(Mat src,
+ Mat dst,
+ Size ksize,
+ Point anchor)
+
Blurs an image using the normalized box filter.
+
+ The function smooths an image using the kernel:
+
+ \(\texttt{K} = \frac{1}{\texttt{ksize.width*ksize.height}} \begin{bmatrix} 1 & 1 & 1 & \cdots & 1 & 1 \\ 1 & 1 & 1 & \cdots & 1 & 1 \\ \hdotsfor{6} \\ 1 & 1 & 1 & \cdots & 1 & 1 \\ \end{bmatrix}\)
+
+ The call blur(src, dst, ksize, anchor, borderType) is equivalent to `boxFilter(src, dst, src.type(), ksize,
+ anchor, true, borderType)`.
+
+
Parameters:
+
src - input image; it can have any number of channels, which are processed independently, but
+ the depth should be CV_8U, CV_16U, CV_16S, CV_32F or CV_64F.
+
dst - output image of the same size and type as src.
+
ksize - blurring kernel size.
+
anchor - anchor point; default value Point(-1,-1) means that the anchor is at the kernel
+ center.
+ SEE: boxFilter, bilateralFilter, GaussianBlur, medianBlur
public static void blur(Mat src,
+ Mat dst,
+ Size ksize,
+ Point anchor,
+ int borderType)
+
Blurs an image using the normalized box filter.
+
+ The function smooths an image using the kernel:
+
+ \(\texttt{K} = \frac{1}{\texttt{ksize.width*ksize.height}} \begin{bmatrix} 1 & 1 & 1 & \cdots & 1 & 1 \\ 1 & 1 & 1 & \cdots & 1 & 1 \\ \hdotsfor{6} \\ 1 & 1 & 1 & \cdots & 1 & 1 \\ \end{bmatrix}\)
+
+ The call blur(src, dst, ksize, anchor, borderType) is equivalent to `boxFilter(src, dst, src.type(), ksize,
+ anchor, true, borderType)`.
+
+
Parameters:
+
src - input image; it can have any number of channels, which are processed independently, but
+ the depth should be CV_8U, CV_16U, CV_16S, CV_32F or CV_64F.
+
dst - output image of the same size and type as src.
+
ksize - blurring kernel size.
+
anchor - anchor point; default value Point(-1,-1) means that the anchor is at the kernel
+ center.
+
borderType - border mode used to extrapolate pixels outside of the image, see #BorderTypes. #BORDER_WRAP is not supported.
+ SEE: boxFilter, bilateralFilter, GaussianBlur, medianBlur
Calculates the up-right bounding rectangle of a point set or non-zero pixels of gray-scale image.
+
+ The function calculates and returns the minimal up-right bounding rectangle for the specified point set or
+ non-zero pixels of gray-scale image.
+
+
Parameters:
+
array - Input gray-scale image or 2D point set, stored in std::vector or Mat.
public static void boxFilter(Mat src,
+ Mat dst,
+ int ddepth,
+ Size ksize)
+
Blurs an image using the box filter.
+
+ The function smooths an image using the kernel:
+
+ \(\texttt{K} = \alpha \begin{bmatrix} 1 & 1 & 1 & \cdots & 1 & 1 \\ 1 & 1 & 1 & \cdots & 1 & 1 \\ \hdotsfor{6} \\ 1 & 1 & 1 & \cdots & 1 & 1 \end{bmatrix}\)
+
+ where
+
+ \(\alpha = \begin{cases} \frac{1}{\texttt{ksize.width*ksize.height}} & \texttt{when } \texttt{normalize=true} \\1 & \texttt{otherwise}\end{cases}\)
+
+ Unnormalized box filter is useful for computing various integral characteristics over each pixel
+ neighborhood, such as covariance matrices of image derivatives (used in dense optical flow
+ algorithms, and so on). If you need to compute pixel sums over variable-size windows, use #integral.
+
+
Parameters:
+
src - input image.
+
dst - output image of the same size and type as src.
+
ddepth - the output image depth (-1 to use src.depth()).
public static void boxFilter(Mat src,
+ Mat dst,
+ int ddepth,
+ Size ksize,
+ Point anchor)
+
Blurs an image using the box filter.
+
+ The function smooths an image using the kernel:
+
+ \(\texttt{K} = \alpha \begin{bmatrix} 1 & 1 & 1 & \cdots & 1 & 1 \\ 1 & 1 & 1 & \cdots & 1 & 1 \\ \hdotsfor{6} \\ 1 & 1 & 1 & \cdots & 1 & 1 \end{bmatrix}\)
+
+ where
+
+ \(\alpha = \begin{cases} \frac{1}{\texttt{ksize.width*ksize.height}} & \texttt{when } \texttt{normalize=true} \\1 & \texttt{otherwise}\end{cases}\)
+
+ Unnormalized box filter is useful for computing various integral characteristics over each pixel
+ neighborhood, such as covariance matrices of image derivatives (used in dense optical flow
+ algorithms, and so on). If you need to compute pixel sums over variable-size windows, use #integral.
+
+
Parameters:
+
src - input image.
+
dst - output image of the same size and type as src.
+
ddepth - the output image depth (-1 to use src.depth()).
+
ksize - blurring kernel size.
+
anchor - anchor point; default value Point(-1,-1) means that the anchor is at the kernel
+ center.
+ SEE: blur, bilateralFilter, GaussianBlur, medianBlur, integral
public static void boxFilter(Mat src,
+ Mat dst,
+ int ddepth,
+ Size ksize,
+ Point anchor,
+ boolean normalize)
+
Blurs an image using the box filter.
+
+ The function smooths an image using the kernel:
+
+ \(\texttt{K} = \alpha \begin{bmatrix} 1 & 1 & 1 & \cdots & 1 & 1 \\ 1 & 1 & 1 & \cdots & 1 & 1 \\ \hdotsfor{6} \\ 1 & 1 & 1 & \cdots & 1 & 1 \end{bmatrix}\)
+
+ where
+
+ \(\alpha = \begin{cases} \frac{1}{\texttt{ksize.width*ksize.height}} & \texttt{when } \texttt{normalize=true} \\1 & \texttt{otherwise}\end{cases}\)
+
+ Unnormalized box filter is useful for computing various integral characteristics over each pixel
+ neighborhood, such as covariance matrices of image derivatives (used in dense optical flow
+ algorithms, and so on). If you need to compute pixel sums over variable-size windows, use #integral.
+
+
Parameters:
+
src - input image.
+
dst - output image of the same size and type as src.
+
ddepth - the output image depth (-1 to use src.depth()).
+
ksize - blurring kernel size.
+
anchor - anchor point; default value Point(-1,-1) means that the anchor is at the kernel
+ center.
+
normalize - flag, specifying whether the kernel is normalized by its area or not.
+ SEE: blur, bilateralFilter, GaussianBlur, medianBlur, integral
public static void boxFilter(Mat src,
+ Mat dst,
+ int ddepth,
+ Size ksize,
+ Point anchor,
+ boolean normalize,
+ int borderType)
+
Blurs an image using the box filter.
+
+ The function smooths an image using the kernel:
+
+ \(\texttt{K} = \alpha \begin{bmatrix} 1 & 1 & 1 & \cdots & 1 & 1 \\ 1 & 1 & 1 & \cdots & 1 & 1 \\ \hdotsfor{6} \\ 1 & 1 & 1 & \cdots & 1 & 1 \end{bmatrix}\)
+
+ where
+
+ \(\alpha = \begin{cases} \frac{1}{\texttt{ksize.width*ksize.height}} & \texttt{when } \texttt{normalize=true} \\1 & \texttt{otherwise}\end{cases}\)
+
+ Unnormalized box filter is useful for computing various integral characteristics over each pixel
+ neighborhood, such as covariance matrices of image derivatives (used in dense optical flow
+ algorithms, and so on). If you need to compute pixel sums over variable-size windows, use #integral.
+
+
Parameters:
+
src - input image.
+
dst - output image of the same size and type as src.
+
ddepth - the output image depth (-1 to use src.depth()).
+
ksize - blurring kernel size.
+
anchor - anchor point; default value Point(-1,-1) means that the anchor is at the kernel
+ center.
+
normalize - flag, specifying whether the kernel is normalized by its area or not.
+
borderType - border mode used to extrapolate pixels outside of the image, see #BorderTypes. #BORDER_WRAP is not supported.
+ SEE: blur, bilateralFilter, GaussianBlur, medianBlur, integral
public static void boxPoints(RotatedRect box,
+ Mat points)
+
Finds the four vertices of a rotated rect. Useful to draw the rotated rectangle.
+
+ The function finds the four vertices of a rotated rectangle. This function is useful to draw the
+ rectangle. In C++, instead of using this function, you can directly use RotatedRect::points method. Please
+ visit the REF: tutorial_bounding_rotated_ellipses "tutorial on Creating Bounding rotated boxes and ellipses for contours" for more information.
+
+
Parameters:
+
box - The input rotated rectangle. It may be the output of REF: minAreaRect.
+
points - The output array of four vertices of rectangles.
public static void calcHist(java.util.List<Mat> images,
+ MatOfInt channels,
+ Mat mask,
+ Mat hist,
+ MatOfInt histSize,
+ MatOfFloat ranges)
+
this variant supports only uniform histograms.
+
+ ranges argument is either empty vector or a flattened vector of histSize.size()*2 elements
+ (histSize.size() element pairs). The first and second elements of each pair specify the lower and
+ upper boundaries.
public static void calcHist(java.util.List<Mat> images,
+ MatOfInt channels,
+ Mat mask,
+ Mat hist,
+ MatOfInt histSize,
+ MatOfFloat ranges,
+ boolean accumulate)
+
this variant supports only uniform histograms.
+
+ ranges argument is either empty vector or a flattened vector of histSize.size()*2 elements
+ (histSize.size() element pairs). The first and second elements of each pair specify the lower and
+ upper boundaries.
public static void Canny(Mat image,
+ Mat edges,
+ double threshold1,
+ double threshold2)
+
Finds edges in an image using the Canny algorithm CITE: Canny86 .
+
+ The function finds edges in the input image and marks them in the output map edges using the
+ Canny algorithm. The smallest value between threshold1 and threshold2 is used for edge linking. The
+ largest value is used to find initial segments of strong edges. See
+ <http://en.wikipedia.org/wiki/Canny_edge_detector>
+
+
Parameters:
+
image - 8-bit input image.
+
edges - output edge map; single channels 8-bit image, which has the same size as image .
+
threshold1 - first threshold for the hysteresis procedure.
+
threshold2 - second threshold for the hysteresis procedure.
+ \(=\sqrt{(dI/dx)^2 + (dI/dy)^2}\) should be used to calculate the image gradient magnitude (
+ L2gradient=true ), or whether the default \(L_1\) norm \(=|dI/dx|+|dI/dy|\) is enough (
+ L2gradient=false ).
public static void Canny(Mat image,
+ Mat edges,
+ double threshold1,
+ double threshold2,
+ int apertureSize)
+
Finds edges in an image using the Canny algorithm CITE: Canny86 .
+
+ The function finds edges in the input image and marks them in the output map edges using the
+ Canny algorithm. The smallest value between threshold1 and threshold2 is used for edge linking. The
+ largest value is used to find initial segments of strong edges. See
+ <http://en.wikipedia.org/wiki/Canny_edge_detector>
+
+
Parameters:
+
image - 8-bit input image.
+
edges - output edge map; single channels 8-bit image, which has the same size as image .
+
threshold1 - first threshold for the hysteresis procedure.
+
threshold2 - second threshold for the hysteresis procedure.
+
apertureSize - aperture size for the Sobel operator.
+ \(=\sqrt{(dI/dx)^2 + (dI/dy)^2}\) should be used to calculate the image gradient magnitude (
+ L2gradient=true ), or whether the default \(L_1\) norm \(=|dI/dx|+|dI/dy|\) is enough (
+ L2gradient=false ).
public static void Canny(Mat image,
+ Mat edges,
+ double threshold1,
+ double threshold2,
+ int apertureSize,
+ boolean L2gradient)
+
Finds edges in an image using the Canny algorithm CITE: Canny86 .
+
+ The function finds edges in the input image and marks them in the output map edges using the
+ Canny algorithm. The smallest value between threshold1 and threshold2 is used for edge linking. The
+ largest value is used to find initial segments of strong edges. See
+ <http://en.wikipedia.org/wiki/Canny_edge_detector>
+
+
Parameters:
+
image - 8-bit input image.
+
edges - output edge map; single channels 8-bit image, which has the same size as image .
+
threshold1 - first threshold for the hysteresis procedure.
+
threshold2 - second threshold for the hysteresis procedure.
+
apertureSize - aperture size for the Sobel operator.
+
L2gradient - a flag, indicating whether a more accurate \(L_2\) norm
+ \(=\sqrt{(dI/dx)^2 + (dI/dy)^2}\) should be used to calculate the image gradient magnitude (
+ L2gradient=true ), or whether the default \(L_1\) norm \(=|dI/dx|+|dI/dy|\) is enough (
+ L2gradient=false ).
public static void Canny(Mat dx,
+ Mat dy,
+ Mat edges,
+ double threshold1,
+ double threshold2)
+
\overload
+
+ Finds edges in an image using the Canny algorithm with custom image gradient.
+
+
Parameters:
+
dx - 16-bit x derivative of input image (CV_16SC1 or CV_16SC3).
+
dy - 16-bit y derivative of input image (same type as dx).
+
edges - output edge map; single channels 8-bit image, which has the same size as image .
+
threshold1 - first threshold for the hysteresis procedure.
+
threshold2 - second threshold for the hysteresis procedure.
+ \(=\sqrt{(dI/dx)^2 + (dI/dy)^2}\) should be used to calculate the image gradient magnitude (
+ L2gradient=true ), or whether the default \(L_1\) norm \(=|dI/dx|+|dI/dy|\) is enough (
+ L2gradient=false ).
public static void Canny(Mat dx,
+ Mat dy,
+ Mat edges,
+ double threshold1,
+ double threshold2,
+ boolean L2gradient)
+
\overload
+
+ Finds edges in an image using the Canny algorithm with custom image gradient.
+
+
Parameters:
+
dx - 16-bit x derivative of input image (CV_16SC1 or CV_16SC3).
+
dy - 16-bit y derivative of input image (same type as dx).
+
edges - output edge map; single channels 8-bit image, which has the same size as image .
+
threshold1 - first threshold for the hysteresis procedure.
+
threshold2 - second threshold for the hysteresis procedure.
+
L2gradient - a flag, indicating whether a more accurate \(L_2\) norm
+ \(=\sqrt{(dI/dx)^2 + (dI/dy)^2}\) should be used to calculate the image gradient magnitude (
+ L2gradient=true ), or whether the default \(L_1\) norm \(=|dI/dx|+|dI/dy|\) is enough (
+ L2gradient=false ).
public static double compareHist(Mat H1,
+ Mat H2,
+ int method)
+
Compares two histograms.
+
+ The function cv::compareHist compares two dense or two sparse histograms using the specified method.
+
+ The function returns \(d(H_1, H_2)\) .
+
+ While the function works well with 1-, 2-, 3-dimensional dense histograms, it may not be suitable
+ for high-dimensional sparse histograms. In such histograms, because of aliasing and sampling
+ problems, the coordinates of non-zero histogram bins can slightly shift. To compare such histograms
+ or more general sparse configurations of weighted points, consider using the #EMD function.
+
+
Parameters:
+
H1 - First compared histogram.
+
H2 - Second compared histogram of the same size as H1 .
public static int connectedComponentsWithAlgorithm(Mat image,
+ Mat labels,
+ int connectivity,
+ int ltype,
+ int ccltype)
+
computes the connected components labeled image of boolean image
+
+ image with 4 or 8 way connectivity - returns N, the total number of labels [0, N-1] where 0
+ represents the background label. ltype specifies the output label image type, an important
+ consideration based on the total number of labels or alternatively the total number of pixels in
+ the source image. ccltype specifies the connected components labeling algorithm to use, currently
+ Bolelli (Spaghetti) CITE: Bolelli2019, Grana (BBDT) CITE: Grana2010 and Wu's (SAUF) CITE: Wu2009 algorithms
+ are supported, see the #ConnectedComponentsAlgorithmsTypes for details. Note that SAUF algorithm forces
+ a row major ordering of labels while Spaghetti and BBDT do not.
+ This function uses parallel version of the algorithms if at least one allowed
+ parallel framework is enabled and if the rows of the image are at least twice the number returned by #getNumberOfCPUs.
+
+
Parameters:
+
image - the 8-bit single-channel image to be labeled
+
labels - destination labeled image
+
connectivity - 8 or 4 for 8-way or 4-way connectivity respectively
+
ltype - output image label type. Currently CV_32S and CV_16U are supported.
+
ccltype - connected components algorithm type (see the #ConnectedComponentsAlgorithmsTypes).
public static int connectedComponentsWithStats(Mat image,
+ Mat labels,
+ Mat stats,
+ Mat centroids)
+
+
Parameters:
+
image - the 8-bit single-channel image to be labeled
+
labels - destination labeled image
+
stats - statistics output for each label, including the background label.
+ Statistics are accessed via stats(label, COLUMN) where COLUMN is one of
+ #ConnectedComponentsTypes, selecting the statistic. The data type is CV_32S.
+
centroids - centroid output for each label, including the background label. Centroids are
+ accessed via centroids(label, 0) for x and centroids(label, 1) for y. The data type CV_64F.
public static int connectedComponentsWithStats(Mat image,
+ Mat labels,
+ Mat stats,
+ Mat centroids,
+ int connectivity)
+
+
Parameters:
+
image - the 8-bit single-channel image to be labeled
+
labels - destination labeled image
+
stats - statistics output for each label, including the background label.
+ Statistics are accessed via stats(label, COLUMN) where COLUMN is one of
+ #ConnectedComponentsTypes, selecting the statistic. The data type is CV_32S.
+
centroids - centroid output for each label, including the background label. Centroids are
+ accessed via centroids(label, 0) for x and centroids(label, 1) for y. The data type CV_64F.
+
connectivity - 8 or 4 for 8-way or 4-way connectivity respectively
public static int connectedComponentsWithStats(Mat image,
+ Mat labels,
+ Mat stats,
+ Mat centroids,
+ int connectivity,
+ int ltype)
+
+
Parameters:
+
image - the 8-bit single-channel image to be labeled
+
labels - destination labeled image
+
stats - statistics output for each label, including the background label.
+ Statistics are accessed via stats(label, COLUMN) where COLUMN is one of
+ #ConnectedComponentsTypes, selecting the statistic. The data type is CV_32S.
+
centroids - centroid output for each label, including the background label. Centroids are
+ accessed via centroids(label, 0) for x and centroids(label, 1) for y. The data type CV_64F.
+
connectivity - 8 or 4 for 8-way or 4-way connectivity respectively
+
ltype - output image label type. Currently CV_32S and CV_16U are supported.
public static int connectedComponentsWithStatsWithAlgorithm(Mat image,
+ Mat labels,
+ Mat stats,
+ Mat centroids,
+ int connectivity,
+ int ltype,
+ int ccltype)
+
computes the connected components labeled image of boolean image and also produces a statistics output for each label
+
+ image with 4 or 8 way connectivity - returns N, the total number of labels [0, N-1] where 0
+ represents the background label. ltype specifies the output label image type, an important
+ consideration based on the total number of labels or alternatively the total number of pixels in
+ the source image. ccltype specifies the connected components labeling algorithm to use, currently
+ Bolelli (Spaghetti) CITE: Bolelli2019, Grana (BBDT) CITE: Grana2010 and Wu's (SAUF) CITE: Wu2009 algorithms
+ are supported, see the #ConnectedComponentsAlgorithmsTypes for details. Note that SAUF algorithm forces
+ a row major ordering of labels while Spaghetti and BBDT do not.
+ This function uses parallel version of the algorithms (statistics included) if at least one allowed
+ parallel framework is enabled and if the rows of the image are at least twice the number returned by #getNumberOfCPUs.
+
+
Parameters:
+
image - the 8-bit single-channel image to be labeled
+
labels - destination labeled image
+
stats - statistics output for each label, including the background label.
+ Statistics are accessed via stats(label, COLUMN) where COLUMN is one of
+ #ConnectedComponentsTypes, selecting the statistic. The data type is CV_32S.
+
centroids - centroid output for each label, including the background label. Centroids are
+ accessed via centroids(label, 0) for x and centroids(label, 1) for y. The data type CV_64F.
+
connectivity - 8 or 4 for 8-way or 4-way connectivity respectively
+
ltype - output image label type. Currently CV_32S and CV_16U are supported.
+
ccltype - connected components algorithm type (see #ConnectedComponentsAlgorithmsTypes).
Calculates a contour area.
+
+ The function computes a contour area. Similarly to moments , the area is computed using the Green
+ formula. Thus, the returned area and the number of non-zero pixels, if you draw the contour using
+ #drawContours or #fillPoly , can be different. Also, the function will most certainly give a wrong
+ results for contours with self-intersections.
+
+ Example:
+
+ vector<Point> contour;
+ contour.push_back(Point2f(0, 0));
+ contour.push_back(Point2f(10, 0));
+ contour.push_back(Point2f(10, 10));
+ contour.push_back(Point2f(5, 4));
+
+ double area0 = contourArea(contour);
+ vector<Point> approx;
+ approxPolyDP(contour, approx, 5, true);
+ double area1 = contourArea(approx);
+
+ cout << "area0 =" << area0 << endl <<
+ "area1 =" << area1 << endl <<
+ "approx poly vertices" << approx.size() << endl;
+
+
+
Parameters:
+
contour - Input vector of 2D points (contour vertices), stored in std::vector or Mat.
+ depending on the contour orientation (clockwise or counter-clockwise). Using this feature you can
+ determine orientation of a contour by taking the sign of an area. By default, the parameter is
+ false, which means that the absolute value is returned.
public static double contourArea(Mat contour,
+ boolean oriented)
+
Calculates a contour area.
+
+ The function computes a contour area. Similarly to moments , the area is computed using the Green
+ formula. Thus, the returned area and the number of non-zero pixels, if you draw the contour using
+ #drawContours or #fillPoly , can be different. Also, the function will most certainly give a wrong
+ results for contours with self-intersections.
+
+ Example:
+
+ vector<Point> contour;
+ contour.push_back(Point2f(0, 0));
+ contour.push_back(Point2f(10, 0));
+ contour.push_back(Point2f(10, 10));
+ contour.push_back(Point2f(5, 4));
+
+ double area0 = contourArea(contour);
+ vector<Point> approx;
+ approxPolyDP(contour, approx, 5, true);
+ double area1 = contourArea(approx);
+
+ cout << "area0 =" << area0 << endl <<
+ "area1 =" << area1 << endl <<
+ "approx poly vertices" << approx.size() << endl;
+
+
+
Parameters:
+
contour - Input vector of 2D points (contour vertices), stored in std::vector or Mat.
+
oriented - Oriented area flag. If it is true, the function returns a signed area value,
+ depending on the contour orientation (clockwise or counter-clockwise). Using this feature you can
+ determine orientation of a contour by taking the sign of an area. By default, the parameter is
+ false, which means that the absolute value is returned.
public static void convertMaps(Mat map1,
+ Mat map2,
+ Mat dstmap1,
+ Mat dstmap2,
+ int dstmap1type)
+
Converts image transformation maps from one representation to another.
+
+ The function converts a pair of maps for remap from one representation to another. The following
+ options ( (map1.type(), map2.type()) \(\rightarrow\) (dstmap1.type(), dstmap2.type()) ) are
+ supported:
+
+
+
+ \(\texttt{(CV_32FC1, CV_32FC1)} \rightarrow \texttt{(CV_16SC2, CV_16UC1)}\). This is the
+ most frequently used conversion operation, in which the original floating-point maps (see #remap)
+ are converted to a more compact and much faster fixed-point representation. The first output array
+ contains the rounded coordinates and the second array (created only when nninterpolation=false )
+ contains indices in the interpolation tables.
+
+
+
+
+
+ \(\texttt{(CV_32FC2)} \rightarrow \texttt{(CV_16SC2, CV_16UC1)}\). The same as above but
+ the original maps are stored in one 2-channel matrix.
+
+
+
+
+
+ Reverse conversion. Obviously, the reconstructed floating-point maps will not be exactly the same
+ as the originals.
+
+
+
+
Parameters:
+
map1 - The first input map of type CV_16SC2, CV_32FC1, or CV_32FC2 .
+
map2 - The second input map of type CV_16UC1, CV_32FC1, or none (empty matrix),
+ respectively.
+
dstmap1 - The first output map that has the type dstmap1type and the same size as src .
+
dstmap2 - The second output map.
+
dstmap1type - Type of the first output map that should be CV_16SC2, CV_32FC1, or
+ CV_32FC2 .
+ nearest-neighbor or for a more complex interpolation.
+
+ SEE: remap, undistort, initUndistortRectifyMap
public static void convertMaps(Mat map1,
+ Mat map2,
+ Mat dstmap1,
+ Mat dstmap2,
+ int dstmap1type,
+ boolean nninterpolation)
+
Converts image transformation maps from one representation to another.
+
+ The function converts a pair of maps for remap from one representation to another. The following
+ options ( (map1.type(), map2.type()) \(\rightarrow\) (dstmap1.type(), dstmap2.type()) ) are
+ supported:
+
+
+
+ \(\texttt{(CV_32FC1, CV_32FC1)} \rightarrow \texttt{(CV_16SC2, CV_16UC1)}\). This is the
+ most frequently used conversion operation, in which the original floating-point maps (see #remap)
+ are converted to a more compact and much faster fixed-point representation. The first output array
+ contains the rounded coordinates and the second array (created only when nninterpolation=false )
+ contains indices in the interpolation tables.
+
+
+
+
+
+ \(\texttt{(CV_32FC2)} \rightarrow \texttt{(CV_16SC2, CV_16UC1)}\). The same as above but
+ the original maps are stored in one 2-channel matrix.
+
+
+
+
+
+ Reverse conversion. Obviously, the reconstructed floating-point maps will not be exactly the same
+ as the originals.
+
+
+
+
Parameters:
+
map1 - The first input map of type CV_16SC2, CV_32FC1, or CV_32FC2 .
+
map2 - The second input map of type CV_16UC1, CV_32FC1, or none (empty matrix),
+ respectively.
+
dstmap1 - The first output map that has the type dstmap1type and the same size as src .
+
dstmap2 - The second output map.
+
dstmap1type - Type of the first output map that should be CV_16SC2, CV_32FC1, or
+ CV_32FC2 .
+
nninterpolation - Flag indicating whether the fixed-point maps are used for the
+ nearest-neighbor or for a more complex interpolation.
+
+ SEE: remap, undistort, initUndistortRectifyMap
Finds the convex hull of a point set.
+
+ The function cv::convexHull finds the convex hull of a 2D point set using the Sklansky's algorithm CITE: Sklansky82
+ that has *O(N logN)* complexity in the current implementation.
+
+
Parameters:
+
points - Input 2D point set, stored in std::vector or Mat.
+
hull - Output convex hull. It is either an integer vector of indices or vector of points. In
+ the first case, the hull elements are 0-based indices of the convex hull points in the original
+ array (since the set of convex hull points is a subset of the original point set). In the second
+ case, hull elements are the convex hull points themselves.
+ Otherwise, it is oriented counter-clockwise. The assumed coordinate system has its X axis pointing
+ to the right, and its Y axis pointing upwards.
+ returns convex hull points. Otherwise, it returns indices of the convex hull points. When the
+ output array is std::vector, the flag is ignored, and the output depends on the type of the
+ vector: std::vector<int> implies returnPoints=false, std::vector<Point> implies
+ returnPoints=true.
+
+ Note:points and hull should be different arrays, inplace processing isn't supported.
+
+ Check REF: tutorial_hull "the corresponding tutorial" for more details.
+
+ useful links:
+
+ https://www.learnopencv.com/convex-hull-using-opencv-in-python-and-c/
Finds the convex hull of a point set.
+
+ The function cv::convexHull finds the convex hull of a 2D point set using the Sklansky's algorithm CITE: Sklansky82
+ that has *O(N logN)* complexity in the current implementation.
+
+
Parameters:
+
points - Input 2D point set, stored in std::vector or Mat.
+
hull - Output convex hull. It is either an integer vector of indices or vector of points. In
+ the first case, the hull elements are 0-based indices of the convex hull points in the original
+ array (since the set of convex hull points is a subset of the original point set). In the second
+ case, hull elements are the convex hull points themselves.
+
clockwise - Orientation flag. If it is true, the output convex hull is oriented clockwise.
+ Otherwise, it is oriented counter-clockwise. The assumed coordinate system has its X axis pointing
+ to the right, and its Y axis pointing upwards.
+ returns convex hull points. Otherwise, it returns indices of the convex hull points. When the
+ output array is std::vector, the flag is ignored, and the output depends on the type of the
+ vector: std::vector<int> implies returnPoints=false, std::vector<Point> implies
+ returnPoints=true.
+
+ Note:points and hull should be different arrays, inplace processing isn't supported.
+
+ Check REF: tutorial_hull "the corresponding tutorial" for more details.
+
+ useful links:
+
+ https://www.learnopencv.com/convex-hull-using-opencv-in-python-and-c/
Finds the convexity defects of a contour.
+
+ The figure below displays convexity defects of a hand contour:
+
+ 
+
+
Parameters:
+
contour - Input contour.
+
convexhull - Convex hull obtained using convexHull that should contain indices of the contour
+ points that make the hull.
+
convexityDefects - The output vector of convexity defects. In C++ and the new Python/Java
+ interface each convexity defect is represented as 4-element integer vector (a.k.a. #Vec4i):
+ (start_index, end_index, farthest_pt_index, fixpt_depth), where indices are 0-based indices
+ in the original contour of the convexity defect beginning, end and the farthest point, and
+ fixpt_depth is fixed-point approximation (with 8 fractional bits) of the distance between the
+ farthest contour point and the hull. That is, to get the floating-point value of the depth will be
+ fixpt_depth/256.0.
public static void cornerEigenValsAndVecs(Mat src,
+ Mat dst,
+ int blockSize,
+ int ksize)
+
Calculates eigenvalues and eigenvectors of image blocks for corner detection.
+
+ For every pixel \(p\) , the function cornerEigenValsAndVecs considers a blockSize \(\times\) blockSize
+ neighborhood \(S(p)\) . It calculates the covariation matrix of derivatives over the neighborhood as:
+
+ \(M = \begin{bmatrix} \sum _{S(p)}(dI/dx)^2 & \sum _{S(p)}dI/dx dI/dy \\ \sum _{S(p)}dI/dx dI/dy & \sum _{S(p)}(dI/dy)^2 \end{bmatrix}\)
+
+ where the derivatives are computed using the Sobel operator.
+
+ After that, it finds eigenvectors and eigenvalues of \(M\) and stores them in the destination image as
+ \((\lambda_1, \lambda_2, x_1, y_1, x_2, y_2)\) where
+
+
+
+ \(\lambda_1, \lambda_2\) are the non-sorted eigenvalues of \(M\)
+
+
+ \(x_1, y_1\) are the eigenvectors corresponding to \(\lambda_1\)
+
+
+ \(x_2, y_2\) are the eigenvectors corresponding to \(\lambda_2\)
+
+
+
+ The output of the function can be used for robust edge or corner detection.
+
+
Parameters:
+
src - Input single-channel 8-bit or floating-point image.
+
dst - Image to store the results. It has the same size as src and the type CV_32FC(6) .
+
blockSize - Neighborhood size (see details below).
+
ksize - Aperture parameter for the Sobel operator.
+
+ SEE: cornerMinEigenVal, cornerHarris, preCornerDetect
public static void cornerEigenValsAndVecs(Mat src,
+ Mat dst,
+ int blockSize,
+ int ksize,
+ int borderType)
+
Calculates eigenvalues and eigenvectors of image blocks for corner detection.
+
+ For every pixel \(p\) , the function cornerEigenValsAndVecs considers a blockSize \(\times\) blockSize
+ neighborhood \(S(p)\) . It calculates the covariation matrix of derivatives over the neighborhood as:
+
+ \(M = \begin{bmatrix} \sum _{S(p)}(dI/dx)^2 & \sum _{S(p)}dI/dx dI/dy \\ \sum _{S(p)}dI/dx dI/dy & \sum _{S(p)}(dI/dy)^2 \end{bmatrix}\)
+
+ where the derivatives are computed using the Sobel operator.
+
+ After that, it finds eigenvectors and eigenvalues of \(M\) and stores them in the destination image as
+ \((\lambda_1, \lambda_2, x_1, y_1, x_2, y_2)\) where
+
+
+
+ \(\lambda_1, \lambda_2\) are the non-sorted eigenvalues of \(M\)
+
+
+ \(x_1, y_1\) are the eigenvectors corresponding to \(\lambda_1\)
+
+
+ \(x_2, y_2\) are the eigenvectors corresponding to \(\lambda_2\)
+
+
+
+ The output of the function can be used for robust edge or corner detection.
+
+
Parameters:
+
src - Input single-channel 8-bit or floating-point image.
+
dst - Image to store the results. It has the same size as src and the type CV_32FC(6) .
+
blockSize - Neighborhood size (see details below).
+
ksize - Aperture parameter for the Sobel operator.
+
borderType - Pixel extrapolation method. See #BorderTypes. #BORDER_WRAP is not supported.
+
+ SEE: cornerMinEigenVal, cornerHarris, preCornerDetect
public static void cornerHarris(Mat src,
+ Mat dst,
+ int blockSize,
+ int ksize,
+ double k)
+
Harris corner detector.
+
+ The function runs the Harris corner detector on the image. Similarly to cornerMinEigenVal and
+ cornerEigenValsAndVecs , for each pixel \((x, y)\) it calculates a \(2\times2\) gradient covariance
+ matrix \(M^{(x,y)}\) over a \(\texttt{blockSize} \times \texttt{blockSize}\) neighborhood. Then, it
+ computes the following characteristic:
+
+ \(\texttt{dst} (x,y) = \mathrm{det} M^{(x,y)} - k \cdot \left ( \mathrm{tr} M^{(x,y)} \right )^2\)
+
+ Corners in the image can be found as the local maxima of this response map.
+
+
Parameters:
+
src - Input single-channel 8-bit or floating-point image.
+
dst - Image to store the Harris detector responses. It has the type CV_32FC1 and the same
+ size as src .
+
blockSize - Neighborhood size (see the details on #cornerEigenValsAndVecs ).
+
ksize - Aperture parameter for the Sobel operator.
+
k - Harris detector free parameter. See the formula above.
public static void cornerHarris(Mat src,
+ Mat dst,
+ int blockSize,
+ int ksize,
+ double k,
+ int borderType)
+
Harris corner detector.
+
+ The function runs the Harris corner detector on the image. Similarly to cornerMinEigenVal and
+ cornerEigenValsAndVecs , for each pixel \((x, y)\) it calculates a \(2\times2\) gradient covariance
+ matrix \(M^{(x,y)}\) over a \(\texttt{blockSize} \times \texttt{blockSize}\) neighborhood. Then, it
+ computes the following characteristic:
+
+ \(\texttt{dst} (x,y) = \mathrm{det} M^{(x,y)} - k \cdot \left ( \mathrm{tr} M^{(x,y)} \right )^2\)
+
+ Corners in the image can be found as the local maxima of this response map.
+
+
Parameters:
+
src - Input single-channel 8-bit or floating-point image.
+
dst - Image to store the Harris detector responses. It has the type CV_32FC1 and the same
+ size as src .
+
blockSize - Neighborhood size (see the details on #cornerEigenValsAndVecs ).
+
ksize - Aperture parameter for the Sobel operator.
+
k - Harris detector free parameter. See the formula above.
+
borderType - Pixel extrapolation method. See #BorderTypes. #BORDER_WRAP is not supported.
public static void cornerMinEigenVal(Mat src,
+ Mat dst,
+ int blockSize)
+
Calculates the minimal eigenvalue of gradient matrices for corner detection.
+
+ The function is similar to cornerEigenValsAndVecs but it calculates and stores only the minimal
+ eigenvalue of the covariance matrix of derivatives, that is, \(\min(\lambda_1, \lambda_2)\) in terms
+ of the formulae in the cornerEigenValsAndVecs description.
+
+
Parameters:
+
src - Input single-channel 8-bit or floating-point image.
+
dst - Image to store the minimal eigenvalues. It has the type CV_32FC1 and the same size as
+ src .
+
blockSize - Neighborhood size (see the details on #cornerEigenValsAndVecs ).
public static void cornerMinEigenVal(Mat src,
+ Mat dst,
+ int blockSize,
+ int ksize)
+
Calculates the minimal eigenvalue of gradient matrices for corner detection.
+
+ The function is similar to cornerEigenValsAndVecs but it calculates and stores only the minimal
+ eigenvalue of the covariance matrix of derivatives, that is, \(\min(\lambda_1, \lambda_2)\) in terms
+ of the formulae in the cornerEigenValsAndVecs description.
+
+
Parameters:
+
src - Input single-channel 8-bit or floating-point image.
+
dst - Image to store the minimal eigenvalues. It has the type CV_32FC1 and the same size as
+ src .
+
blockSize - Neighborhood size (see the details on #cornerEigenValsAndVecs ).
+
ksize - Aperture parameter for the Sobel operator.
public static void cornerMinEigenVal(Mat src,
+ Mat dst,
+ int blockSize,
+ int ksize,
+ int borderType)
+
Calculates the minimal eigenvalue of gradient matrices for corner detection.
+
+ The function is similar to cornerEigenValsAndVecs but it calculates and stores only the minimal
+ eigenvalue of the covariance matrix of derivatives, that is, \(\min(\lambda_1, \lambda_2)\) in terms
+ of the formulae in the cornerEigenValsAndVecs description.
+
+
Parameters:
+
src - Input single-channel 8-bit or floating-point image.
+
dst - Image to store the minimal eigenvalues. It has the type CV_32FC1 and the same size as
+ src .
+
blockSize - Neighborhood size (see the details on #cornerEigenValsAndVecs ).
+
ksize - Aperture parameter for the Sobel operator.
+
borderType - Pixel extrapolation method. See #BorderTypes. #BORDER_WRAP is not supported.
public static void cornerSubPix(Mat image,
+ Mat corners,
+ Size winSize,
+ Size zeroZone,
+ TermCriteria criteria)
+
Refines the corner locations.
+
+ The function iterates to find the sub-pixel accurate location of corners or radial saddle
+ points as described in CITE: forstner1987fast, and as shown on the figure below.
+
+ 
+
+ Sub-pixel accurate corner locator is based on the observation that every vector from the center \(q\)
+ to a point \(p\) located within a neighborhood of \(q\) is orthogonal to the image gradient at \(p\)
+ subject to image and measurement noise. Consider the expression:
+
+ \(\epsilon _i = {DI_{p_i}}^T \cdot (q - p_i)\)
+
+ where \({DI_{p_i}}\) is an image gradient at one of the points \(p_i\) in a neighborhood of \(q\) . The
+ value of \(q\) is to be found so that \(\epsilon_i\) is minimized. A system of equations may be set up
+ with \(\epsilon_i\) set to zero:
+
+ \(\sum _i(DI_{p_i} \cdot {DI_{p_i}}^T) \cdot q - \sum _i(DI_{p_i} \cdot {DI_{p_i}}^T \cdot p_i)\)
+
+ where the gradients are summed within a neighborhood ("search window") of \(q\) . Calling the first
+ gradient term \(G\) and the second gradient term \(b\) gives:
+
+ \(q = G^{-1} \cdot b\)
+
+ The algorithm sets the center of the neighborhood window at this new center \(q\) and then iterates
+ until the center stays within a set threshold.
+
+
Parameters:
+
image - Input single-channel, 8-bit or float image.
+
corners - Initial coordinates of the input corners and refined coordinates provided for
+ output.
+
winSize - Half of the side length of the search window. For example, if winSize=Size(5,5) ,
+ then a \((5*2+1) \times (5*2+1) = 11 \times 11\) search window is used.
+
zeroZone - Half of the size of the dead region in the middle of the search zone over which
+ the summation in the formula below is not done. It is used sometimes to avoid possible
+ singularities of the autocorrelation matrix. The value of (-1,-1) indicates that there is no such
+ a size.
+
criteria - Criteria for termination of the iterative process of corner refinement. That is,
+ the process of corner position refinement stops either after criteria.maxCount iterations or when
+ the corner position moves by less than criteria.epsilon on some iteration.
Creates a smart pointer to a cv::CLAHE class and initializes it.
+
+ equally sized rectangular tiles. tileGridSize defines the number of tiles in row and column.
public static CLAHE createCLAHE(double clipLimit,
+ Size tileGridSize)
+
Creates a smart pointer to a cv::CLAHE class and initializes it.
+
+
Parameters:
+
clipLimit - Threshold for contrast limiting.
+
tileGridSize - Size of grid for histogram equalization. Input image will be divided into
+ equally sized rectangular tiles. tileGridSize defines the number of tiles in row and column.
public static void createHanningWindow(Mat dst,
+ Size winSize,
+ int type)
+
This function computes a Hanning window coefficients in two dimensions.
+
+ See (http://en.wikipedia.org/wiki/Hann_function) and (http://en.wikipedia.org/wiki/Window_function)
+ for more information.
+
+ An example is shown below:
+
+ // create hanning window of size 100x100 and type CV_32F
+ Mat hann;
+ createHanningWindow(hann, Size(100, 100), CV_32F);
+
+
+
Parameters:
+
dst - Destination array to place Hann coefficients in
+
winSize - The window size specifications (both width and height must be > 1)
Creates a smart pointer to a LineSegmentDetector object and initializes it.
+
+ The LineSegmentDetector algorithm is defined using the standard values. Only advanced users may want
+ to edit those, as to tailor it for their own application.
Creates a smart pointer to a LineSegmentDetector object and initializes it.
+
+ The LineSegmentDetector algorithm is defined using the standard values. Only advanced users may want
+ to edit those, as to tailor it for their own application.
+
+
Parameters:
+
refine - The way found lines will be refined, see #LineSegmentDetectorModes
public static LineSegmentDetector createLineSegmentDetector(int refine,
+ double scale)
+
Creates a smart pointer to a LineSegmentDetector object and initializes it.
+
+ The LineSegmentDetector algorithm is defined using the standard values. Only advanced users may want
+ to edit those, as to tailor it for their own application.
+
+
Parameters:
+
refine - The way found lines will be refined, see #LineSegmentDetectorModes
+
scale - The scale of the image that will be used to find the lines. Range (0..1].
Creates a smart pointer to a LineSegmentDetector object and initializes it.
+
+ The LineSegmentDetector algorithm is defined using the standard values. Only advanced users may want
+ to edit those, as to tailor it for their own application.
+
+
Parameters:
+
refine - The way found lines will be refined, see #LineSegmentDetectorModes
+
scale - The scale of the image that will be used to find the lines. Range (0..1].
+
sigma_scale - Sigma for Gaussian filter. It is computed as sigma = sigma_scale/scale.
Creates a smart pointer to a LineSegmentDetector object and initializes it.
+
+ The LineSegmentDetector algorithm is defined using the standard values. Only advanced users may want
+ to edit those, as to tailor it for their own application.
+
+
Parameters:
+
refine - The way found lines will be refined, see #LineSegmentDetectorModes
+
scale - The scale of the image that will be used to find the lines. Range (0..1].
+
sigma_scale - Sigma for Gaussian filter. It is computed as sigma = sigma_scale/scale.
+
quant - Bound to the quantization error on the gradient norm.
Creates a smart pointer to a LineSegmentDetector object and initializes it.
+
+ The LineSegmentDetector algorithm is defined using the standard values. Only advanced users may want
+ to edit those, as to tailor it for their own application.
+
+
Parameters:
+
refine - The way found lines will be refined, see #LineSegmentDetectorModes
+
scale - The scale of the image that will be used to find the lines. Range (0..1].
+
sigma_scale - Sigma for Gaussian filter. It is computed as sigma = sigma_scale/scale.
+
quant - Bound to the quantization error on the gradient norm.
Creates a smart pointer to a LineSegmentDetector object and initializes it.
+
+ The LineSegmentDetector algorithm is defined using the standard values. Only advanced users may want
+ to edit those, as to tailor it for their own application.
+
+
Parameters:
+
refine - The way found lines will be refined, see #LineSegmentDetectorModes
+
scale - The scale of the image that will be used to find the lines. Range (0..1].
+
sigma_scale - Sigma for Gaussian filter. It is computed as sigma = sigma_scale/scale.
+
quant - Bound to the quantization error on the gradient norm.
+
ang_th - Gradient angle tolerance in degrees.
+
log_eps - Detection threshold: -log10(NFA) > log_eps. Used only when advance refinement is chosen.
Creates a smart pointer to a LineSegmentDetector object and initializes it.
+
+ The LineSegmentDetector algorithm is defined using the standard values. Only advanced users may want
+ to edit those, as to tailor it for their own application.
+
+
Parameters:
+
refine - The way found lines will be refined, see #LineSegmentDetectorModes
+
scale - The scale of the image that will be used to find the lines. Range (0..1].
+
sigma_scale - Sigma for Gaussian filter. It is computed as sigma = sigma_scale/scale.
+
quant - Bound to the quantization error on the gradient norm.
+
ang_th - Gradient angle tolerance in degrees.
+
log_eps - Detection threshold: -log10(NFA) > log_eps. Used only when advance refinement is chosen.
+
density_th - Minimal density of aligned region points in the enclosing rectangle.
Creates a smart pointer to a LineSegmentDetector object and initializes it.
+
+ The LineSegmentDetector algorithm is defined using the standard values. Only advanced users may want
+ to edit those, as to tailor it for their own application.
+
+
Parameters:
+
refine - The way found lines will be refined, see #LineSegmentDetectorModes
+
scale - The scale of the image that will be used to find the lines. Range (0..1].
+
sigma_scale - Sigma for Gaussian filter. It is computed as sigma = sigma_scale/scale.
+
quant - Bound to the quantization error on the gradient norm.
+
ang_th - Gradient angle tolerance in degrees.
+
log_eps - Detection threshold: -log10(NFA) > log_eps. Used only when advance refinement is chosen.
+
density_th - Minimal density of aligned region points in the enclosing rectangle.
+
n_bins - Number of bins in pseudo-ordering of gradient modulus.
public static void cvtColor(Mat src,
+ Mat dst,
+ int code)
+
Converts an image from one color space to another.
+
+ The function converts an input image from one color space to another. In case of a transformation
+ to-from RGB color space, the order of the channels should be specified explicitly (RGB or BGR). Note
+ that the default color format in OpenCV is often referred to as RGB but it is actually BGR (the
+ bytes are reversed). So the first byte in a standard (24-bit) color image will be an 8-bit Blue
+ component, the second byte will be Green, and the third byte will be Red. The fourth, fifth, and
+ sixth bytes would then be the second pixel (Blue, then Green, then Red), and so on.
+
+ The conventional ranges for R, G, and B channel values are:
+
+
+ 0 to 255 for CV_8U images
+
+
+ 0 to 65535 for CV_16U images
+
+
+ 0 to 1 for CV_32F images
+
+
+
+ In case of linear transformations, the range does not matter. But in case of a non-linear
+ transformation, an input RGB image should be normalized to the proper value range to get the correct
+ results, for example, for RGB \(\rightarrow\) L\*u\*v\* transformation. For example, if you have a
+ 32-bit floating-point image directly converted from an 8-bit image without any scaling, then it will
+ have the 0..255 value range instead of 0..1 assumed by the function. So, before calling #cvtColor ,
+ you need first to scale the image down:
+
+ img *= 1./255;
+ cvtColor(img, img, COLOR_BGR2Luv);
+
+ If you use #cvtColor with 8-bit images, the conversion will have some information lost. For many
+ applications, this will not be noticeable but it is recommended to use 32-bit images in applications
+ that need the full range of colors or that convert an image before an operation and then convert
+ back.
+
+ If conversion adds the alpha channel, its value will set to the maximum of corresponding channel
+ range: 255 for CV_8U, 65535 for CV_16U, 1 for CV_32F.
dst - output image of the same size and depth as src.
+
code - color space conversion code (see #ColorConversionCodes).
+ channels is derived automatically from src and code.
+
+ SEE: REF: imgproc_color_conversions
public static void cvtColor(Mat src,
+ Mat dst,
+ int code,
+ int dstCn)
+
Converts an image from one color space to another.
+
+ The function converts an input image from one color space to another. In case of a transformation
+ to-from RGB color space, the order of the channels should be specified explicitly (RGB or BGR). Note
+ that the default color format in OpenCV is often referred to as RGB but it is actually BGR (the
+ bytes are reversed). So the first byte in a standard (24-bit) color image will be an 8-bit Blue
+ component, the second byte will be Green, and the third byte will be Red. The fourth, fifth, and
+ sixth bytes would then be the second pixel (Blue, then Green, then Red), and so on.
+
+ The conventional ranges for R, G, and B channel values are:
+
+
+ 0 to 255 for CV_8U images
+
+
+ 0 to 65535 for CV_16U images
+
+
+ 0 to 1 for CV_32F images
+
+
+
+ In case of linear transformations, the range does not matter. But in case of a non-linear
+ transformation, an input RGB image should be normalized to the proper value range to get the correct
+ results, for example, for RGB \(\rightarrow\) L\*u\*v\* transformation. For example, if you have a
+ 32-bit floating-point image directly converted from an 8-bit image without any scaling, then it will
+ have the 0..255 value range instead of 0..1 assumed by the function. So, before calling #cvtColor ,
+ you need first to scale the image down:
+
+ img *= 1./255;
+ cvtColor(img, img, COLOR_BGR2Luv);
+
+ If you use #cvtColor with 8-bit images, the conversion will have some information lost. For many
+ applications, this will not be noticeable but it is recommended to use 32-bit images in applications
+ that need the full range of colors or that convert an image before an operation and then convert
+ back.
+
+ If conversion adds the alpha channel, its value will set to the maximum of corresponding channel
+ range: 255 for CV_8U, 65535 for CV_16U, 1 for CV_32F.
dst - output image of the same size and depth as src.
+
code - color space conversion code (see #ColorConversionCodes).
+
dstCn - number of channels in the destination image; if the parameter is 0, the number of the
+ channels is derived automatically from src and code.
+
+ SEE: REF: imgproc_color_conversions
public static void cvtColorTwoPlane(Mat src1,
+ Mat src2,
+ Mat dst,
+ int code)
+
Converts an image from one color space to another where the source image is
+ stored in two planes.
+
+ This function only supports YUV420 to RGB conversion as of now.
+
+
public static void demosaicing(Mat src,
+ Mat dst,
+ int code)
+
main function for all demosaicing processes
+
+
Parameters:
+
src - input image: 8-bit unsigned or 16-bit unsigned.
+
dst - output image of the same size and depth as src.
+
code - Color space conversion code (see the description below).
+ channels is derived automatically from src and code.
+
+ The function can do the following transformations:
+
+
public static void demosaicing(Mat src,
+ Mat dst,
+ int code,
+ int dstCn)
+
main function for all demosaicing processes
+
+
Parameters:
+
src - input image: 8-bit unsigned or 16-bit unsigned.
+
dst - output image of the same size and depth as src.
+
code - Color space conversion code (see the description below).
+
dstCn - number of channels in the destination image; if the parameter is 0, the number of the
+ channels is derived automatically from src and code.
+
+ The function can do the following transformations:
+
+
public static void dilate(Mat src,
+ Mat dst,
+ Mat kernel)
+
Dilates an image by using a specific structuring element.
+
+ The function dilates the source image using the specified structuring element that determines the
+ shape of a pixel neighborhood over which the maximum is taken:
+ \(\texttt{dst} (x,y) = \max _{(x',y'): \, \texttt{element} (x',y') \ne0 } \texttt{src} (x+x',y+y')\)
+
+ The function supports the in-place mode. Dilation can be applied several ( iterations ) times. In
+ case of multi-channel images, each channel is processed independently.
+
+
Parameters:
+
src - input image; the number of channels can be arbitrary, but the depth should be one of
+ CV_8U, CV_16U, CV_16S, CV_32F or CV_64F.
+
dst - output image of the same size and type as src.
+
kernel - structuring element used for dilation; if element=Mat(), a 3 x 3 rectangular
+ structuring element is used. Kernel can be created using #getStructuringElement
+ anchor is at the element center.
+ SEE: erode, morphologyEx, getStructuringElement
public static void dilate(Mat src,
+ Mat dst,
+ Mat kernel,
+ Point anchor)
+
Dilates an image by using a specific structuring element.
+
+ The function dilates the source image using the specified structuring element that determines the
+ shape of a pixel neighborhood over which the maximum is taken:
+ \(\texttt{dst} (x,y) = \max _{(x',y'): \, \texttt{element} (x',y') \ne0 } \texttt{src} (x+x',y+y')\)
+
+ The function supports the in-place mode. Dilation can be applied several ( iterations ) times. In
+ case of multi-channel images, each channel is processed independently.
+
+
Parameters:
+
src - input image; the number of channels can be arbitrary, but the depth should be one of
+ CV_8U, CV_16U, CV_16S, CV_32F or CV_64F.
+
dst - output image of the same size and type as src.
+
kernel - structuring element used for dilation; if element=Mat(), a 3 x 3 rectangular
+ structuring element is used. Kernel can be created using #getStructuringElement
+
anchor - position of the anchor within the element; default value (-1, -1) means that the
+ anchor is at the element center.
+ SEE: erode, morphologyEx, getStructuringElement
public static void dilate(Mat src,
+ Mat dst,
+ Mat kernel,
+ Point anchor,
+ int iterations)
+
Dilates an image by using a specific structuring element.
+
+ The function dilates the source image using the specified structuring element that determines the
+ shape of a pixel neighborhood over which the maximum is taken:
+ \(\texttt{dst} (x,y) = \max _{(x',y'): \, \texttt{element} (x',y') \ne0 } \texttt{src} (x+x',y+y')\)
+
+ The function supports the in-place mode. Dilation can be applied several ( iterations ) times. In
+ case of multi-channel images, each channel is processed independently.
+
+
Parameters:
+
src - input image; the number of channels can be arbitrary, but the depth should be one of
+ CV_8U, CV_16U, CV_16S, CV_32F or CV_64F.
+
dst - output image of the same size and type as src.
+
kernel - structuring element used for dilation; if element=Mat(), a 3 x 3 rectangular
+ structuring element is used. Kernel can be created using #getStructuringElement
+
anchor - position of the anchor within the element; default value (-1, -1) means that the
+ anchor is at the element center.
+
iterations - number of times dilation is applied.
+ SEE: erode, morphologyEx, getStructuringElement
public static void dilate(Mat src,
+ Mat dst,
+ Mat kernel,
+ Point anchor,
+ int iterations,
+ int borderType)
+
Dilates an image by using a specific structuring element.
+
+ The function dilates the source image using the specified structuring element that determines the
+ shape of a pixel neighborhood over which the maximum is taken:
+ \(\texttt{dst} (x,y) = \max _{(x',y'): \, \texttt{element} (x',y') \ne0 } \texttt{src} (x+x',y+y')\)
+
+ The function supports the in-place mode. Dilation can be applied several ( iterations ) times. In
+ case of multi-channel images, each channel is processed independently.
+
+
Parameters:
+
src - input image; the number of channels can be arbitrary, but the depth should be one of
+ CV_8U, CV_16U, CV_16S, CV_32F or CV_64F.
+
dst - output image of the same size and type as src.
+
kernel - structuring element used for dilation; if element=Mat(), a 3 x 3 rectangular
+ structuring element is used. Kernel can be created using #getStructuringElement
+
anchor - position of the anchor within the element; default value (-1, -1) means that the
+ anchor is at the element center.
+
iterations - number of times dilation is applied.
+
borderType - pixel extrapolation method, see #BorderTypes. #BORDER_WRAP is not suported.
+ SEE: erode, morphologyEx, getStructuringElement
public static void dilate(Mat src,
+ Mat dst,
+ Mat kernel,
+ Point anchor,
+ int iterations,
+ int borderType,
+ Scalar borderValue)
+
Dilates an image by using a specific structuring element.
+
+ The function dilates the source image using the specified structuring element that determines the
+ shape of a pixel neighborhood over which the maximum is taken:
+ \(\texttt{dst} (x,y) = \max _{(x',y'): \, \texttt{element} (x',y') \ne0 } \texttt{src} (x+x',y+y')\)
+
+ The function supports the in-place mode. Dilation can be applied several ( iterations ) times. In
+ case of multi-channel images, each channel is processed independently.
+
+
Parameters:
+
src - input image; the number of channels can be arbitrary, but the depth should be one of
+ CV_8U, CV_16U, CV_16S, CV_32F or CV_64F.
+
dst - output image of the same size and type as src.
+
kernel - structuring element used for dilation; if element=Mat(), a 3 x 3 rectangular
+ structuring element is used. Kernel can be created using #getStructuringElement
+
anchor - position of the anchor within the element; default value (-1, -1) means that the
+ anchor is at the element center.
+
iterations - number of times dilation is applied.
+
borderType - pixel extrapolation method, see #BorderTypes. #BORDER_WRAP is not suported.
+
borderValue - border value in case of a constant border
+ SEE: erode, morphologyEx, getStructuringElement
dst - Output image with calculated distances. It is a 8-bit or 32-bit floating-point,
+ single-channel image of the same size as src .
+
distanceType - Type of distance, see #DistanceTypes
+
maskSize - Size of the distance transform mask, see #DistanceTransformMasks. In case of the
+ #DIST_L1 or #DIST_C distance type, the parameter is forced to 3 because a \(3\times 3\) mask gives
+ the same result as \(5\times 5\) or any larger aperture.
+ the first variant of the function and distanceType == #DIST_L1.
dst - Output image with calculated distances. It is a 8-bit or 32-bit floating-point,
+ single-channel image of the same size as src .
+
distanceType - Type of distance, see #DistanceTypes
+
maskSize - Size of the distance transform mask, see #DistanceTransformMasks. In case of the
+ #DIST_L1 or #DIST_C distance type, the parameter is forced to 3 because a \(3\times 3\) mask gives
+ the same result as \(5\times 5\) or any larger aperture.
+
dstType - Type of output image. It can be CV_8U or CV_32F. Type CV_8U can be used only for
+ the first variant of the function and distanceType == #DIST_L1.
public static void distanceTransformWithLabels(Mat src,
+ Mat dst,
+ Mat labels,
+ int distanceType,
+ int maskSize)
+
Calculates the distance to the closest zero pixel for each pixel of the source image.
+
+ The function cv::distanceTransform calculates the approximate or precise distance from every binary
+ image pixel to the nearest zero pixel. For zero image pixels, the distance will obviously be zero.
+
+ When maskSize == #DIST_MASK_PRECISE and distanceType == #DIST_L2 , the function runs the
+ algorithm described in CITE: Felzenszwalb04 . This algorithm is parallelized with the TBB library.
+
+ In other cases, the algorithm CITE: Borgefors86 is used. This means that for a pixel the function
+ finds the shortest path to the nearest zero pixel consisting of basic shifts: horizontal, vertical,
+ diagonal, or knight's move (the latest is available for a \(5\times 5\) mask). The overall
+ distance is calculated as a sum of these basic distances. Since the distance function should be
+ symmetric, all of the horizontal and vertical shifts must have the same cost (denoted as a ), all
+ the diagonal shifts must have the same cost (denoted as b), and all knight's moves must have the
+ same cost (denoted as c). For the #DIST_C and #DIST_L1 types, the distance is calculated
+ precisely, whereas for #DIST_L2 (Euclidean distance) the distance can be calculated only with a
+ relative error (a \(5\times 5\) mask gives more accurate results). For a,b, and c, OpenCV
+ uses the values suggested in the original paper:
+
+
+ DIST_L1: a = 1, b = 2
+
+
+ DIST_L2:
+
+
+ 3 x 3: a=0.955, b=1.3693
+
+
+ 5 x 5: a=1, b=1.4, c=2.1969
+
+
+
+ DIST_C: a = 1, b = 1
+
+
+
+ Typically, for a fast, coarse distance estimation #DIST_L2, a \(3\times 3\) mask is used. For a
+ more accurate distance estimation #DIST_L2, a \(5\times 5\) mask or the precise algorithm is used.
+ Note that both the precise and the approximate algorithms are linear on the number of pixels.
+
+ This variant of the function does not only compute the minimum distance for each pixel \((x, y)\)
+ but also identifies the nearest connected component consisting of zero pixels
+ (labelType==#DIST_LABEL_CCOMP) or the nearest zero pixel (labelType==#DIST_LABEL_PIXEL). Index of the
+ component/pixel is stored in labels(x, y). When labelType==#DIST_LABEL_CCOMP, the function
+ automatically finds connected components of zero pixels in the input image and marks them with
+ distinct labels. When labelType==#DIST_LABEL_PIXEL, the function scans through the input image and
+ marks all the zero pixels with distinct labels.
+
+ In this mode, the complexity is still linear. That is, the function provides a very fast way to
+ compute the Voronoi diagram for a binary image. Currently, the second variant can use only the
+ approximate distance transform algorithm, i.e. maskSize=#DIST_MASK_PRECISE is not supported
+ yet.
dst - Output image with calculated distances. It is a 8-bit or 32-bit floating-point,
+ single-channel image of the same size as src.
+
labels - Output 2D array of labels (the discrete Voronoi diagram). It has the type
+ CV_32SC1 and the same size as src.
+
distanceType - Type of distance, see #DistanceTypes
+
maskSize - Size of the distance transform mask, see #DistanceTransformMasks.
+ #DIST_MASK_PRECISE is not supported by this variant. In case of the #DIST_L1 or #DIST_C distance type,
+ the parameter is forced to 3 because a \(3\times 3\) mask gives the same result as \(5\times
+ 5\) or any larger aperture.
public static void distanceTransformWithLabels(Mat src,
+ Mat dst,
+ Mat labels,
+ int distanceType,
+ int maskSize,
+ int labelType)
+
Calculates the distance to the closest zero pixel for each pixel of the source image.
+
+ The function cv::distanceTransform calculates the approximate or precise distance from every binary
+ image pixel to the nearest zero pixel. For zero image pixels, the distance will obviously be zero.
+
+ When maskSize == #DIST_MASK_PRECISE and distanceType == #DIST_L2 , the function runs the
+ algorithm described in CITE: Felzenszwalb04 . This algorithm is parallelized with the TBB library.
+
+ In other cases, the algorithm CITE: Borgefors86 is used. This means that for a pixel the function
+ finds the shortest path to the nearest zero pixel consisting of basic shifts: horizontal, vertical,
+ diagonal, or knight's move (the latest is available for a \(5\times 5\) mask). The overall
+ distance is calculated as a sum of these basic distances. Since the distance function should be
+ symmetric, all of the horizontal and vertical shifts must have the same cost (denoted as a ), all
+ the diagonal shifts must have the same cost (denoted as b), and all knight's moves must have the
+ same cost (denoted as c). For the #DIST_C and #DIST_L1 types, the distance is calculated
+ precisely, whereas for #DIST_L2 (Euclidean distance) the distance can be calculated only with a
+ relative error (a \(5\times 5\) mask gives more accurate results). For a,b, and c, OpenCV
+ uses the values suggested in the original paper:
+
+
+ DIST_L1: a = 1, b = 2
+
+
+ DIST_L2:
+
+
+ 3 x 3: a=0.955, b=1.3693
+
+
+ 5 x 5: a=1, b=1.4, c=2.1969
+
+
+
+ DIST_C: a = 1, b = 1
+
+
+
+ Typically, for a fast, coarse distance estimation #DIST_L2, a \(3\times 3\) mask is used. For a
+ more accurate distance estimation #DIST_L2, a \(5\times 5\) mask or the precise algorithm is used.
+ Note that both the precise and the approximate algorithms are linear on the number of pixels.
+
+ This variant of the function does not only compute the minimum distance for each pixel \((x, y)\)
+ but also identifies the nearest connected component consisting of zero pixels
+ (labelType==#DIST_LABEL_CCOMP) or the nearest zero pixel (labelType==#DIST_LABEL_PIXEL). Index of the
+ component/pixel is stored in labels(x, y). When labelType==#DIST_LABEL_CCOMP, the function
+ automatically finds connected components of zero pixels in the input image and marks them with
+ distinct labels. When labelType==#DIST_LABEL_PIXEL, the function scans through the input image and
+ marks all the zero pixels with distinct labels.
+
+ In this mode, the complexity is still linear. That is, the function provides a very fast way to
+ compute the Voronoi diagram for a binary image. Currently, the second variant can use only the
+ approximate distance transform algorithm, i.e. maskSize=#DIST_MASK_PRECISE is not supported
+ yet.
dst - Output image with calculated distances. It is a 8-bit or 32-bit floating-point,
+ single-channel image of the same size as src.
+
labels - Output 2D array of labels (the discrete Voronoi diagram). It has the type
+ CV_32SC1 and the same size as src.
+
distanceType - Type of distance, see #DistanceTypes
+
maskSize - Size of the distance transform mask, see #DistanceTransformMasks.
+ #DIST_MASK_PRECISE is not supported by this variant. In case of the #DIST_L1 or #DIST_C distance type,
+ the parameter is forced to 3 because a \(3\times 3\) mask gives the same result as \(5\times
+ 5\) or any larger aperture.
+
labelType - Type of the label array to build, see #DistanceTransformLabelTypes.
public static void divSpectrums(Mat a,
+ Mat b,
+ Mat c,
+ int flags)
+
Performs the per-element division of the first Fourier spectrum by the second Fourier spectrum.
+
+ The function cv::divSpectrums performs the per-element division of the first array by the second array.
+ The arrays are CCS-packed or complex matrices that are results of a real or complex Fourier transform.
+
+
Parameters:
+
a - first input array.
+
b - second input array of the same size and type as src1 .
+
c - output array of the same size and type as src1 .
+
flags - operation flags; currently, the only supported flag is cv::DFT_ROWS, which indicates that
+ each row of src1 and src2 is an independent 1D Fourier spectrum. If you do not want to use this flag, then simply add a 0 as value.
+ or not (false).
public static void divSpectrums(Mat a,
+ Mat b,
+ Mat c,
+ int flags,
+ boolean conjB)
+
Performs the per-element division of the first Fourier spectrum by the second Fourier spectrum.
+
+ The function cv::divSpectrums performs the per-element division of the first array by the second array.
+ The arrays are CCS-packed or complex matrices that are results of a real or complex Fourier transform.
+
+
Parameters:
+
a - first input array.
+
b - second input array of the same size and type as src1 .
+
c - output array of the same size and type as src1 .
+
flags - operation flags; currently, the only supported flag is cv::DFT_ROWS, which indicates that
+ each row of src1 and src2 is an independent 1D Fourier spectrum. If you do not want to use this flag, then simply add a 0 as value.
+
conjB - optional flag that conjugates the second input array before the multiplication (true)
+ or not (false).
public static void drawContours(Mat image,
+ java.util.List<MatOfPoint> contours,
+ int contourIdx,
+ Scalar color)
+
Draws contours outlines or filled contours.
+
+ The function draws contour outlines in the image if \(\texttt{thickness} \ge 0\) or fills the area
+ bounded by the contours if \(\texttt{thickness}<0\) . The example below shows how to retrieve
+ connected components from the binary image and label them: :
+ INCLUDE: snippets/imgproc_drawContours.cpp
+
+
Parameters:
+
image - Destination image.
+
contours - All the input contours. Each contour is stored as a point vector.
+
contourIdx - Parameter indicating a contour to draw. If it is negative, all the contours are drawn.
+
color - Color of the contours.
+ thickness=#FILLED ), the contour interiors are drawn.
+ some of the contours (see maxLevel ).
+ If it is 1, the function draws the contour(s) and all the nested contours. If it is 2, the function
+ draws the contours, all the nested contours, all the nested-to-nested contours, and so on. This
+ parameter is only taken into account when there is hierarchy available.
+ \(\texttt{offset}=(dx,dy)\) .
+ Note: When thickness=#FILLED, the function is designed to handle connected components with holes correctly
+ even when no hierarchy data is provided. This is done by analyzing all the outlines together
+ using even-odd rule. This may give incorrect results if you have a joint collection of separately retrieved
+ contours. In order to solve this problem, you need to call #drawContours separately for each sub-group
+ of contours, or iterate over the collection using contourIdx parameter.
public static void drawContours(Mat image,
+ java.util.List<MatOfPoint> contours,
+ int contourIdx,
+ Scalar color,
+ int thickness)
+
Draws contours outlines or filled contours.
+
+ The function draws contour outlines in the image if \(\texttt{thickness} \ge 0\) or fills the area
+ bounded by the contours if \(\texttt{thickness}<0\) . The example below shows how to retrieve
+ connected components from the binary image and label them: :
+ INCLUDE: snippets/imgproc_drawContours.cpp
+
+
Parameters:
+
image - Destination image.
+
contours - All the input contours. Each contour is stored as a point vector.
+
contourIdx - Parameter indicating a contour to draw. If it is negative, all the contours are drawn.
+
color - Color of the contours.
+
thickness - Thickness of lines the contours are drawn with. If it is negative (for example,
+ thickness=#FILLED ), the contour interiors are drawn.
+ some of the contours (see maxLevel ).
+ If it is 1, the function draws the contour(s) and all the nested contours. If it is 2, the function
+ draws the contours, all the nested contours, all the nested-to-nested contours, and so on. This
+ parameter is only taken into account when there is hierarchy available.
+ \(\texttt{offset}=(dx,dy)\) .
+ Note: When thickness=#FILLED, the function is designed to handle connected components with holes correctly
+ even when no hierarchy data is provided. This is done by analyzing all the outlines together
+ using even-odd rule. This may give incorrect results if you have a joint collection of separately retrieved
+ contours. In order to solve this problem, you need to call #drawContours separately for each sub-group
+ of contours, or iterate over the collection using contourIdx parameter.
public static void drawContours(Mat image,
+ java.util.List<MatOfPoint> contours,
+ int contourIdx,
+ Scalar color,
+ int thickness,
+ int lineType)
+
Draws contours outlines or filled contours.
+
+ The function draws contour outlines in the image if \(\texttt{thickness} \ge 0\) or fills the area
+ bounded by the contours if \(\texttt{thickness}<0\) . The example below shows how to retrieve
+ connected components from the binary image and label them: :
+ INCLUDE: snippets/imgproc_drawContours.cpp
+
+
Parameters:
+
image - Destination image.
+
contours - All the input contours. Each contour is stored as a point vector.
+
contourIdx - Parameter indicating a contour to draw. If it is negative, all the contours are drawn.
+
color - Color of the contours.
+
thickness - Thickness of lines the contours are drawn with. If it is negative (for example,
+ thickness=#FILLED ), the contour interiors are drawn.
+
lineType - Line connectivity. See #LineTypes
+ some of the contours (see maxLevel ).
+ If it is 1, the function draws the contour(s) and all the nested contours. If it is 2, the function
+ draws the contours, all the nested contours, all the nested-to-nested contours, and so on. This
+ parameter is only taken into account when there is hierarchy available.
+ \(\texttt{offset}=(dx,dy)\) .
+ Note: When thickness=#FILLED, the function is designed to handle connected components with holes correctly
+ even when no hierarchy data is provided. This is done by analyzing all the outlines together
+ using even-odd rule. This may give incorrect results if you have a joint collection of separately retrieved
+ contours. In order to solve this problem, you need to call #drawContours separately for each sub-group
+ of contours, or iterate over the collection using contourIdx parameter.
public static void drawContours(Mat image,
+ java.util.List<MatOfPoint> contours,
+ int contourIdx,
+ Scalar color,
+ int thickness,
+ int lineType,
+ Mat hierarchy)
+
Draws contours outlines or filled contours.
+
+ The function draws contour outlines in the image if \(\texttt{thickness} \ge 0\) or fills the area
+ bounded by the contours if \(\texttt{thickness}<0\) . The example below shows how to retrieve
+ connected components from the binary image and label them: :
+ INCLUDE: snippets/imgproc_drawContours.cpp
+
+
Parameters:
+
image - Destination image.
+
contours - All the input contours. Each contour is stored as a point vector.
+
contourIdx - Parameter indicating a contour to draw. If it is negative, all the contours are drawn.
+
color - Color of the contours.
+
thickness - Thickness of lines the contours are drawn with. If it is negative (for example,
+ thickness=#FILLED ), the contour interiors are drawn.
+
lineType - Line connectivity. See #LineTypes
+
hierarchy - Optional information about hierarchy. It is only needed if you want to draw only
+ some of the contours (see maxLevel ).
+ If it is 1, the function draws the contour(s) and all the nested contours. If it is 2, the function
+ draws the contours, all the nested contours, all the nested-to-nested contours, and so on. This
+ parameter is only taken into account when there is hierarchy available.
+ \(\texttt{offset}=(dx,dy)\) .
+ Note: When thickness=#FILLED, the function is designed to handle connected components with holes correctly
+ even when no hierarchy data is provided. This is done by analyzing all the outlines together
+ using even-odd rule. This may give incorrect results if you have a joint collection of separately retrieved
+ contours. In order to solve this problem, you need to call #drawContours separately for each sub-group
+ of contours, or iterate over the collection using contourIdx parameter.
public static void drawContours(Mat image,
+ java.util.List<MatOfPoint> contours,
+ int contourIdx,
+ Scalar color,
+ int thickness,
+ int lineType,
+ Mat hierarchy,
+ int maxLevel)
+
Draws contours outlines or filled contours.
+
+ The function draws contour outlines in the image if \(\texttt{thickness} \ge 0\) or fills the area
+ bounded by the contours if \(\texttt{thickness}<0\) . The example below shows how to retrieve
+ connected components from the binary image and label them: :
+ INCLUDE: snippets/imgproc_drawContours.cpp
+
+
Parameters:
+
image - Destination image.
+
contours - All the input contours. Each contour is stored as a point vector.
+
contourIdx - Parameter indicating a contour to draw. If it is negative, all the contours are drawn.
+
color - Color of the contours.
+
thickness - Thickness of lines the contours are drawn with. If it is negative (for example,
+ thickness=#FILLED ), the contour interiors are drawn.
+
lineType - Line connectivity. See #LineTypes
+
hierarchy - Optional information about hierarchy. It is only needed if you want to draw only
+ some of the contours (see maxLevel ).
+
maxLevel - Maximal level for drawn contours. If it is 0, only the specified contour is drawn.
+ If it is 1, the function draws the contour(s) and all the nested contours. If it is 2, the function
+ draws the contours, all the nested contours, all the nested-to-nested contours, and so on. This
+ parameter is only taken into account when there is hierarchy available.
+ \(\texttt{offset}=(dx,dy)\) .
+ Note: When thickness=#FILLED, the function is designed to handle connected components with holes correctly
+ even when no hierarchy data is provided. This is done by analyzing all the outlines together
+ using even-odd rule. This may give incorrect results if you have a joint collection of separately retrieved
+ contours. In order to solve this problem, you need to call #drawContours separately for each sub-group
+ of contours, or iterate over the collection using contourIdx parameter.
public static void drawContours(Mat image,
+ java.util.List<MatOfPoint> contours,
+ int contourIdx,
+ Scalar color,
+ int thickness,
+ int lineType,
+ Mat hierarchy,
+ int maxLevel,
+ Point offset)
+
Draws contours outlines or filled contours.
+
+ The function draws contour outlines in the image if \(\texttt{thickness} \ge 0\) or fills the area
+ bounded by the contours if \(\texttt{thickness}<0\) . The example below shows how to retrieve
+ connected components from the binary image and label them: :
+ INCLUDE: snippets/imgproc_drawContours.cpp
+
+
Parameters:
+
image - Destination image.
+
contours - All the input contours. Each contour is stored as a point vector.
+
contourIdx - Parameter indicating a contour to draw. If it is negative, all the contours are drawn.
+
color - Color of the contours.
+
thickness - Thickness of lines the contours are drawn with. If it is negative (for example,
+ thickness=#FILLED ), the contour interiors are drawn.
+
lineType - Line connectivity. See #LineTypes
+
hierarchy - Optional information about hierarchy. It is only needed if you want to draw only
+ some of the contours (see maxLevel ).
+
maxLevel - Maximal level for drawn contours. If it is 0, only the specified contour is drawn.
+ If it is 1, the function draws the contour(s) and all the nested contours. If it is 2, the function
+ draws the contours, all the nested contours, all the nested-to-nested contours, and so on. This
+ parameter is only taken into account when there is hierarchy available.
+
offset - Optional contour shift parameter. Shift all the drawn contours by the specified
+ \(\texttt{offset}=(dx,dy)\) .
+ Note: When thickness=#FILLED, the function is designed to handle connected components with holes correctly
+ even when no hierarchy data is provided. This is done by analyzing all the outlines together
+ using even-odd rule. This may give incorrect results if you have a joint collection of separately retrieved
+ contours. In order to solve this problem, you need to call #drawContours separately for each sub-group
+ of contours, or iterate over the collection using contourIdx parameter.
public static void drawMarker(Mat img,
+ Point position,
+ Scalar color)
+
Draws a marker on a predefined position in an image.
+
+ The function cv::drawMarker draws a marker on a given position in the image. For the moment several
+ marker types are supported, see #MarkerTypes for more information.
+
+
Parameters:
+
img - Image.
+
position - The point where the crosshair is positioned.
public static void drawMarker(Mat img,
+ Point position,
+ Scalar color,
+ int markerType)
+
Draws a marker on a predefined position in an image.
+
+ The function cv::drawMarker draws a marker on a given position in the image. For the moment several
+ marker types are supported, see #MarkerTypes for more information.
+
+
Parameters:
+
img - Image.
+
position - The point where the crosshair is positioned.
+
color - Line color.
+
markerType - The specific type of marker you want to use, see #MarkerTypes
public static void drawMarker(Mat img,
+ Point position,
+ Scalar color,
+ int markerType,
+ int markerSize)
+
Draws a marker on a predefined position in an image.
+
+ The function cv::drawMarker draws a marker on a given position in the image. For the moment several
+ marker types are supported, see #MarkerTypes for more information.
+
+
Parameters:
+
img - Image.
+
position - The point where the crosshair is positioned.
+
color - Line color.
+
markerType - The specific type of marker you want to use, see #MarkerTypes
+
markerSize - The length of the marker axis [default = 20 pixels]
public static void drawMarker(Mat img,
+ Point position,
+ Scalar color,
+ int markerType,
+ int markerSize,
+ int thickness)
+
Draws a marker on a predefined position in an image.
+
+ The function cv::drawMarker draws a marker on a given position in the image. For the moment several
+ marker types are supported, see #MarkerTypes for more information.
+
+
Parameters:
+
img - Image.
+
position - The point where the crosshair is positioned.
+
color - Line color.
+
markerType - The specific type of marker you want to use, see #MarkerTypes
+
thickness - Line thickness.
+
markerSize - The length of the marker axis [default = 20 pixels]
public static void drawMarker(Mat img,
+ Point position,
+ Scalar color,
+ int markerType,
+ int markerSize,
+ int thickness,
+ int line_type)
+
Draws a marker on a predefined position in an image.
+
+ The function cv::drawMarker draws a marker on a given position in the image. For the moment several
+ marker types are supported, see #MarkerTypes for more information.
+
+
Parameters:
+
img - Image.
+
position - The point where the crosshair is positioned.
+
color - Line color.
+
markerType - The specific type of marker you want to use, see #MarkerTypes
+
thickness - Line thickness.
+
line_type - Type of the line, See #LineTypes
+
markerSize - The length of the marker axis [default = 20 pixels]
public static void ellipse(Mat img,
+ Point center,
+ Size axes,
+ double angle,
+ double startAngle,
+ double endAngle,
+ Scalar color)
+
Draws a simple or thick elliptic arc or fills an ellipse sector.
+
+ The function cv::ellipse with more parameters draws an ellipse outline, a filled ellipse, an elliptic
+ arc, or a filled ellipse sector. The drawing code uses general parametric form.
+ A piecewise-linear curve is used to approximate the elliptic arc
+ boundary. If you need more control of the ellipse rendering, you can retrieve the curve using
+ #ellipse2Poly and then render it with #polylines or fill it with #fillPoly. If you use the first
+ variant of the function and want to draw the whole ellipse, not an arc, pass startAngle=0 and
+ endAngle=360. If startAngle is greater than endAngle, they are swapped. The figure below explains
+ the meaning of the parameters to draw the blue arc.
+
+ 
+
+
Parameters:
+
img - Image.
+
center - Center of the ellipse.
+
axes - Half of the size of the ellipse main axes.
+
angle - Ellipse rotation angle in degrees.
+
startAngle - Starting angle of the elliptic arc in degrees.
+
endAngle - Ending angle of the elliptic arc in degrees.
+
color - Ellipse color.
+ a filled ellipse sector is to be drawn.
public static void ellipse(Mat img,
+ Point center,
+ Size axes,
+ double angle,
+ double startAngle,
+ double endAngle,
+ Scalar color,
+ int thickness)
+
Draws a simple or thick elliptic arc or fills an ellipse sector.
+
+ The function cv::ellipse with more parameters draws an ellipse outline, a filled ellipse, an elliptic
+ arc, or a filled ellipse sector. The drawing code uses general parametric form.
+ A piecewise-linear curve is used to approximate the elliptic arc
+ boundary. If you need more control of the ellipse rendering, you can retrieve the curve using
+ #ellipse2Poly and then render it with #polylines or fill it with #fillPoly. If you use the first
+ variant of the function and want to draw the whole ellipse, not an arc, pass startAngle=0 and
+ endAngle=360. If startAngle is greater than endAngle, they are swapped. The figure below explains
+ the meaning of the parameters to draw the blue arc.
+
+ 
+
+
Parameters:
+
img - Image.
+
center - Center of the ellipse.
+
axes - Half of the size of the ellipse main axes.
+
angle - Ellipse rotation angle in degrees.
+
startAngle - Starting angle of the elliptic arc in degrees.
+
endAngle - Ending angle of the elliptic arc in degrees.
+
color - Ellipse color.
+
thickness - Thickness of the ellipse arc outline, if positive. Otherwise, this indicates that
+ a filled ellipse sector is to be drawn.
public static void ellipse(Mat img,
+ Point center,
+ Size axes,
+ double angle,
+ double startAngle,
+ double endAngle,
+ Scalar color,
+ int thickness,
+ int lineType)
+
Draws a simple or thick elliptic arc or fills an ellipse sector.
+
+ The function cv::ellipse with more parameters draws an ellipse outline, a filled ellipse, an elliptic
+ arc, or a filled ellipse sector. The drawing code uses general parametric form.
+ A piecewise-linear curve is used to approximate the elliptic arc
+ boundary. If you need more control of the ellipse rendering, you can retrieve the curve using
+ #ellipse2Poly and then render it with #polylines or fill it with #fillPoly. If you use the first
+ variant of the function and want to draw the whole ellipse, not an arc, pass startAngle=0 and
+ endAngle=360. If startAngle is greater than endAngle, they are swapped. The figure below explains
+ the meaning of the parameters to draw the blue arc.
+
+ 
+
+
Parameters:
+
img - Image.
+
center - Center of the ellipse.
+
axes - Half of the size of the ellipse main axes.
+
angle - Ellipse rotation angle in degrees.
+
startAngle - Starting angle of the elliptic arc in degrees.
+
endAngle - Ending angle of the elliptic arc in degrees.
+
color - Ellipse color.
+
thickness - Thickness of the ellipse arc outline, if positive. Otherwise, this indicates that
+ a filled ellipse sector is to be drawn.
+
lineType - Type of the ellipse boundary. See #LineTypes
public static void ellipse(Mat img,
+ Point center,
+ Size axes,
+ double angle,
+ double startAngle,
+ double endAngle,
+ Scalar color,
+ int thickness,
+ int lineType,
+ int shift)
+
Draws a simple or thick elliptic arc or fills an ellipse sector.
+
+ The function cv::ellipse with more parameters draws an ellipse outline, a filled ellipse, an elliptic
+ arc, or a filled ellipse sector. The drawing code uses general parametric form.
+ A piecewise-linear curve is used to approximate the elliptic arc
+ boundary. If you need more control of the ellipse rendering, you can retrieve the curve using
+ #ellipse2Poly and then render it with #polylines or fill it with #fillPoly. If you use the first
+ variant of the function and want to draw the whole ellipse, not an arc, pass startAngle=0 and
+ endAngle=360. If startAngle is greater than endAngle, they are swapped. The figure below explains
+ the meaning of the parameters to draw the blue arc.
+
+ 
+
+
Parameters:
+
img - Image.
+
center - Center of the ellipse.
+
axes - Half of the size of the ellipse main axes.
+
angle - Ellipse rotation angle in degrees.
+
startAngle - Starting angle of the elliptic arc in degrees.
+
endAngle - Ending angle of the elliptic arc in degrees.
+
color - Ellipse color.
+
thickness - Thickness of the ellipse arc outline, if positive. Otherwise, this indicates that
+ a filled ellipse sector is to be drawn.
+
lineType - Type of the ellipse boundary. See #LineTypes
+
shift - Number of fractional bits in the coordinates of the center and values of axes.
public static void ellipse2Poly(Point center,
+ Size axes,
+ int angle,
+ int arcStart,
+ int arcEnd,
+ int delta,
+ MatOfPoint pts)
+
Approximates an elliptic arc with a polyline.
+
+ The function ellipse2Poly computes the vertices of a polyline that approximates the specified
+ elliptic arc. It is used by #ellipse. If arcStart is greater than arcEnd, they are swapped.
+
+
Parameters:
+
center - Center of the arc.
+
axes - Half of the size of the ellipse main axes. See #ellipse for details.
+
angle - Rotation angle of the ellipse in degrees. See #ellipse for details.
+
arcStart - Starting angle of the elliptic arc in degrees.
+
arcEnd - Ending angle of the elliptic arc in degrees.
+
delta - Angle between the subsequent polyline vertices. It defines the approximation
+ accuracy.
public static float EMD(Mat signature1,
+ Mat signature2,
+ int distType)
+
Computes the "minimal work" distance between two weighted point configurations.
+
+ The function computes the earth mover distance and/or a lower boundary of the distance between the
+ two weighted point configurations. One of the applications described in CITE: RubnerSept98,
+ CITE: Rubner2000 is multi-dimensional histogram comparison for image retrieval. EMD is a transportation
+ problem that is solved using some modification of a simplex algorithm, thus the complexity is
+ exponential in the worst case, though, on average it is much faster. In the case of a real metric
+ the lower boundary can be calculated even faster (using linear-time algorithm) and it can be used
+ to determine roughly whether the two signatures are far enough so that they cannot relate to the
+ same object.
+
+
Parameters:
+
signature1 - First signature, a \(\texttt{size1}\times \texttt{dims}+1\) floating-point matrix.
+ Each row stores the point weight followed by the point coordinates. The matrix is allowed to have
+ a single column (weights only) if the user-defined cost matrix is used. The weights must be
+ non-negative and have at least one non-zero value.
+
signature2 - Second signature of the same format as signature1 , though the number of rows
+ may be different. The total weights may be different. In this case an extra "dummy" point is added
+ to either signature1 or signature2. The weights must be non-negative and have at least one non-zero
+ value.
+
distType - Used metric. See #DistanceTypes.
+ is used, lower boundary lowerBound cannot be calculated because it needs a metric function.
+ signatures that is a distance between mass centers. The lower boundary may not be calculated if
+ the user-defined cost matrix is used, the total weights of point configurations are not equal, or
+ if the signatures consist of weights only (the signature matrices have a single column). You
+ must initialize \*lowerBound . If the calculated distance between mass centers is greater or
+ equal to \*lowerBound (it means that the signatures are far enough), the function does not
+ calculate EMD. In any case \*lowerBound is set to the calculated distance between mass centers on
+ return. Thus, if you want to calculate both distance between mass centers and EMD, \*lowerBound
+ should be set to 0.
+ a flow from \(i\) -th point of signature1 to \(j\) -th point of signature2 .
public static float EMD(Mat signature1,
+ Mat signature2,
+ int distType,
+ Mat cost)
+
Computes the "minimal work" distance between two weighted point configurations.
+
+ The function computes the earth mover distance and/or a lower boundary of the distance between the
+ two weighted point configurations. One of the applications described in CITE: RubnerSept98,
+ CITE: Rubner2000 is multi-dimensional histogram comparison for image retrieval. EMD is a transportation
+ problem that is solved using some modification of a simplex algorithm, thus the complexity is
+ exponential in the worst case, though, on average it is much faster. In the case of a real metric
+ the lower boundary can be calculated even faster (using linear-time algorithm) and it can be used
+ to determine roughly whether the two signatures are far enough so that they cannot relate to the
+ same object.
+
+
Parameters:
+
signature1 - First signature, a \(\texttt{size1}\times \texttt{dims}+1\) floating-point matrix.
+ Each row stores the point weight followed by the point coordinates. The matrix is allowed to have
+ a single column (weights only) if the user-defined cost matrix is used. The weights must be
+ non-negative and have at least one non-zero value.
+
signature2 - Second signature of the same format as signature1 , though the number of rows
+ may be different. The total weights may be different. In this case an extra "dummy" point is added
+ to either signature1 or signature2. The weights must be non-negative and have at least one non-zero
+ value.
+
distType - Used metric. See #DistanceTypes.
+
cost - User-defined \(\texttt{size1}\times \texttt{size2}\) cost matrix. Also, if a cost matrix
+ is used, lower boundary lowerBound cannot be calculated because it needs a metric function.
+ signatures that is a distance between mass centers. The lower boundary may not be calculated if
+ the user-defined cost matrix is used, the total weights of point configurations are not equal, or
+ if the signatures consist of weights only (the signature matrices have a single column). You
+ must initialize \*lowerBound . If the calculated distance between mass centers is greater or
+ equal to \*lowerBound (it means that the signatures are far enough), the function does not
+ calculate EMD. In any case \*lowerBound is set to the calculated distance between mass centers on
+ return. Thus, if you want to calculate both distance between mass centers and EMD, \*lowerBound
+ should be set to 0.
+ a flow from \(i\) -th point of signature1 to \(j\) -th point of signature2 .
public static float EMD(Mat signature1,
+ Mat signature2,
+ int distType,
+ Mat cost,
+ Mat flow)
+
Computes the "minimal work" distance between two weighted point configurations.
+
+ The function computes the earth mover distance and/or a lower boundary of the distance between the
+ two weighted point configurations. One of the applications described in CITE: RubnerSept98,
+ CITE: Rubner2000 is multi-dimensional histogram comparison for image retrieval. EMD is a transportation
+ problem that is solved using some modification of a simplex algorithm, thus the complexity is
+ exponential in the worst case, though, on average it is much faster. In the case of a real metric
+ the lower boundary can be calculated even faster (using linear-time algorithm) and it can be used
+ to determine roughly whether the two signatures are far enough so that they cannot relate to the
+ same object.
+
+
Parameters:
+
signature1 - First signature, a \(\texttt{size1}\times \texttt{dims}+1\) floating-point matrix.
+ Each row stores the point weight followed by the point coordinates. The matrix is allowed to have
+ a single column (weights only) if the user-defined cost matrix is used. The weights must be
+ non-negative and have at least one non-zero value.
+
signature2 - Second signature of the same format as signature1 , though the number of rows
+ may be different. The total weights may be different. In this case an extra "dummy" point is added
+ to either signature1 or signature2. The weights must be non-negative and have at least one non-zero
+ value.
+
distType - Used metric. See #DistanceTypes.
+
cost - User-defined \(\texttt{size1}\times \texttt{size2}\) cost matrix. Also, if a cost matrix
+ is used, lower boundary lowerBound cannot be calculated because it needs a metric function.
+ signatures that is a distance between mass centers. The lower boundary may not be calculated if
+ the user-defined cost matrix is used, the total weights of point configurations are not equal, or
+ if the signatures consist of weights only (the signature matrices have a single column). You
+ must initialize \*lowerBound . If the calculated distance between mass centers is greater or
+ equal to \*lowerBound (it means that the signatures are far enough), the function does not
+ calculate EMD. In any case \*lowerBound is set to the calculated distance between mass centers on
+ return. Thus, if you want to calculate both distance between mass centers and EMD, \*lowerBound
+ should be set to 0.
+
flow - Resultant \(\texttt{size1} \times \texttt{size2}\) flow matrix: \(\texttt{flow}_{i,j}\) is
+ a flow from \(i\) -th point of signature1 to \(j\) -th point of signature2 .
public static void erode(Mat src,
+ Mat dst,
+ Mat kernel)
+
Erodes an image by using a specific structuring element.
+
+ The function erodes the source image using the specified structuring element that determines the
+ shape of a pixel neighborhood over which the minimum is taken:
+
+ \(\texttt{dst} (x,y) = \min _{(x',y'): \, \texttt{element} (x',y') \ne0 } \texttt{src} (x+x',y+y')\)
+
+ The function supports the in-place mode. Erosion can be applied several ( iterations ) times. In
+ case of multi-channel images, each channel is processed independently.
+
+
Parameters:
+
src - input image; the number of channels can be arbitrary, but the depth should be one of
+ CV_8U, CV_16U, CV_16S, CV_32F or CV_64F.
+
dst - output image of the same size and type as src.
+
kernel - structuring element used for erosion; if element=Mat(), a 3 x 3 rectangular
+ structuring element is used. Kernel can be created using #getStructuringElement.
+ anchor is at the element center.
+ SEE: dilate, morphologyEx, getStructuringElement
public static void erode(Mat src,
+ Mat dst,
+ Mat kernel,
+ Point anchor)
+
Erodes an image by using a specific structuring element.
+
+ The function erodes the source image using the specified structuring element that determines the
+ shape of a pixel neighborhood over which the minimum is taken:
+
+ \(\texttt{dst} (x,y) = \min _{(x',y'): \, \texttt{element} (x',y') \ne0 } \texttt{src} (x+x',y+y')\)
+
+ The function supports the in-place mode. Erosion can be applied several ( iterations ) times. In
+ case of multi-channel images, each channel is processed independently.
+
+
Parameters:
+
src - input image; the number of channels can be arbitrary, but the depth should be one of
+ CV_8U, CV_16U, CV_16S, CV_32F or CV_64F.
+
dst - output image of the same size and type as src.
+
kernel - structuring element used for erosion; if element=Mat(), a 3 x 3 rectangular
+ structuring element is used. Kernel can be created using #getStructuringElement.
+
anchor - position of the anchor within the element; default value (-1, -1) means that the
+ anchor is at the element center.
+ SEE: dilate, morphologyEx, getStructuringElement
public static void erode(Mat src,
+ Mat dst,
+ Mat kernel,
+ Point anchor,
+ int iterations)
+
Erodes an image by using a specific structuring element.
+
+ The function erodes the source image using the specified structuring element that determines the
+ shape of a pixel neighborhood over which the minimum is taken:
+
+ \(\texttt{dst} (x,y) = \min _{(x',y'): \, \texttt{element} (x',y') \ne0 } \texttt{src} (x+x',y+y')\)
+
+ The function supports the in-place mode. Erosion can be applied several ( iterations ) times. In
+ case of multi-channel images, each channel is processed independently.
+
+
Parameters:
+
src - input image; the number of channels can be arbitrary, but the depth should be one of
+ CV_8U, CV_16U, CV_16S, CV_32F or CV_64F.
+
dst - output image of the same size and type as src.
+
kernel - structuring element used for erosion; if element=Mat(), a 3 x 3 rectangular
+ structuring element is used. Kernel can be created using #getStructuringElement.
+
anchor - position of the anchor within the element; default value (-1, -1) means that the
+ anchor is at the element center.
+
iterations - number of times erosion is applied.
+ SEE: dilate, morphologyEx, getStructuringElement
public static void erode(Mat src,
+ Mat dst,
+ Mat kernel,
+ Point anchor,
+ int iterations,
+ int borderType)
+
Erodes an image by using a specific structuring element.
+
+ The function erodes the source image using the specified structuring element that determines the
+ shape of a pixel neighborhood over which the minimum is taken:
+
+ \(\texttt{dst} (x,y) = \min _{(x',y'): \, \texttt{element} (x',y') \ne0 } \texttt{src} (x+x',y+y')\)
+
+ The function supports the in-place mode. Erosion can be applied several ( iterations ) times. In
+ case of multi-channel images, each channel is processed independently.
+
+
Parameters:
+
src - input image; the number of channels can be arbitrary, but the depth should be one of
+ CV_8U, CV_16U, CV_16S, CV_32F or CV_64F.
+
dst - output image of the same size and type as src.
+
kernel - structuring element used for erosion; if element=Mat(), a 3 x 3 rectangular
+ structuring element is used. Kernel can be created using #getStructuringElement.
+
anchor - position of the anchor within the element; default value (-1, -1) means that the
+ anchor is at the element center.
+
iterations - number of times erosion is applied.
+
borderType - pixel extrapolation method, see #BorderTypes. #BORDER_WRAP is not supported.
+ SEE: dilate, morphologyEx, getStructuringElement
public static void erode(Mat src,
+ Mat dst,
+ Mat kernel,
+ Point anchor,
+ int iterations,
+ int borderType,
+ Scalar borderValue)
+
Erodes an image by using a specific structuring element.
+
+ The function erodes the source image using the specified structuring element that determines the
+ shape of a pixel neighborhood over which the minimum is taken:
+
+ \(\texttt{dst} (x,y) = \min _{(x',y'): \, \texttt{element} (x',y') \ne0 } \texttt{src} (x+x',y+y')\)
+
+ The function supports the in-place mode. Erosion can be applied several ( iterations ) times. In
+ case of multi-channel images, each channel is processed independently.
+
+
Parameters:
+
src - input image; the number of channels can be arbitrary, but the depth should be one of
+ CV_8U, CV_16U, CV_16S, CV_32F or CV_64F.
+
dst - output image of the same size and type as src.
+
kernel - structuring element used for erosion; if element=Mat(), a 3 x 3 rectangular
+ structuring element is used. Kernel can be created using #getStructuringElement.
+
anchor - position of the anchor within the element; default value (-1, -1) means that the
+ anchor is at the element center.
+
iterations - number of times erosion is applied.
+
borderType - pixel extrapolation method, see #BorderTypes. #BORDER_WRAP is not supported.
+
borderValue - border value in case of a constant border
+ SEE: dilate, morphologyEx, getStructuringElement
Fills a convex polygon.
+
+ The function cv::fillConvexPoly draws a filled convex polygon. This function is much faster than the
+ function #fillPoly . It can fill not only convex polygons but any monotonic polygon without
+ self-intersections, that is, a polygon whose contour intersects every horizontal line (scan line)
+ twice at the most (though, its top-most and/or the bottom edge could be horizontal).
public static void fillConvexPoly(Mat img,
+ MatOfPoint points,
+ Scalar color,
+ int lineType)
+
Fills a convex polygon.
+
+ The function cv::fillConvexPoly draws a filled convex polygon. This function is much faster than the
+ function #fillPoly . It can fill not only convex polygons but any monotonic polygon without
+ self-intersections, that is, a polygon whose contour intersects every horizontal line (scan line)
+ twice at the most (though, its top-most and/or the bottom edge could be horizontal).
+
+
Parameters:
+
img - Image.
+
points - Polygon vertices.
+
color - Polygon color.
+
lineType - Type of the polygon boundaries. See #LineTypes
public static void fillConvexPoly(Mat img,
+ MatOfPoint points,
+ Scalar color,
+ int lineType,
+ int shift)
+
Fills a convex polygon.
+
+ The function cv::fillConvexPoly draws a filled convex polygon. This function is much faster than the
+ function #fillPoly . It can fill not only convex polygons but any monotonic polygon without
+ self-intersections, that is, a polygon whose contour intersects every horizontal line (scan line)
+ twice at the most (though, its top-most and/or the bottom edge could be horizontal).
+
+
Parameters:
+
img - Image.
+
points - Polygon vertices.
+
color - Polygon color.
+
lineType - Type of the polygon boundaries. See #LineTypes
+
shift - Number of fractional bits in the vertex coordinates.
Fills the area bounded by one or more polygons.
+
+ The function cv::fillPoly fills an area bounded by several polygonal contours. The function can fill
+ complex areas, for example, areas with holes, contours with self-intersections (some of their
+ parts), and so forth.
+
+
Parameters:
+
img - Image.
+
pts - Array of polygons where each polygon is represented as an array of points.
public static void fillPoly(Mat img,
+ java.util.List<MatOfPoint> pts,
+ Scalar color,
+ int lineType)
+
Fills the area bounded by one or more polygons.
+
+ The function cv::fillPoly fills an area bounded by several polygonal contours. The function can fill
+ complex areas, for example, areas with holes, contours with self-intersections (some of their
+ parts), and so forth.
+
+
Parameters:
+
img - Image.
+
pts - Array of polygons where each polygon is represented as an array of points.
+
color - Polygon color.
+
lineType - Type of the polygon boundaries. See #LineTypes
public static void fillPoly(Mat img,
+ java.util.List<MatOfPoint> pts,
+ Scalar color,
+ int lineType,
+ int shift)
+
Fills the area bounded by one or more polygons.
+
+ The function cv::fillPoly fills an area bounded by several polygonal contours. The function can fill
+ complex areas, for example, areas with holes, contours with self-intersections (some of their
+ parts), and so forth.
+
+
Parameters:
+
img - Image.
+
pts - Array of polygons where each polygon is represented as an array of points.
+
color - Polygon color.
+
lineType - Type of the polygon boundaries. See #LineTypes
+
shift - Number of fractional bits in the vertex coordinates.
public static void fillPoly(Mat img,
+ java.util.List<MatOfPoint> pts,
+ Scalar color,
+ int lineType,
+ int shift,
+ Point offset)
+
Fills the area bounded by one or more polygons.
+
+ The function cv::fillPoly fills an area bounded by several polygonal contours. The function can fill
+ complex areas, for example, areas with holes, contours with self-intersections (some of their
+ parts), and so forth.
+
+
Parameters:
+
img - Image.
+
pts - Array of polygons where each polygon is represented as an array of points.
+
color - Polygon color.
+
lineType - Type of the polygon boundaries. See #LineTypes
+
shift - Number of fractional bits in the vertex coordinates.
+
offset - Optional offset of all points of the contours.
public static void filter2D(Mat src,
+ Mat dst,
+ int ddepth,
+ Mat kernel)
+
Convolves an image with the kernel.
+
+ The function applies an arbitrary linear filter to an image. In-place operation is supported. When
+ the aperture is partially outside the image, the function interpolates outlier pixel values
+ according to the specified border mode.
+
+ The function does actually compute correlation, not the convolution:
+
+ \(\texttt{dst} (x,y) = \sum _{ \substack{0\leq x' < \texttt{kernel.cols}\\{0\leq y' < \texttt{kernel.rows}}}} \texttt{kernel} (x',y')* \texttt{src} (x+x'- \texttt{anchor.x} ,y+y'- \texttt{anchor.y} )\)
+
+ That is, the kernel is not mirrored around the anchor point. If you need a real convolution, flip
+ the kernel using #flip and set the new anchor to `(kernel.cols - anchor.x - 1, kernel.rows -
+ anchor.y - 1)`.
+
+ The function uses the DFT-based algorithm in case of sufficiently large kernels (~11 x 11 or
+ larger) and the direct algorithm for small kernels.
+
+
Parameters:
+
src - input image.
+
dst - output image of the same size and the same number of channels as src.
+
ddepth - desired depth of the destination image, see REF: filter_depths "combinations"
+
kernel - convolution kernel (or rather a correlation kernel), a single-channel floating point
+ matrix; if you want to apply different kernels to different channels, split the image into
+ separate color planes using split and process them individually.
+ the kernel; the anchor should lie within the kernel; default value (-1,-1) means that the anchor
+ is at the kernel center.
+ SEE: sepFilter2D, dft, matchTemplate
public static void filter2D(Mat src,
+ Mat dst,
+ int ddepth,
+ Mat kernel,
+ Point anchor)
+
Convolves an image with the kernel.
+
+ The function applies an arbitrary linear filter to an image. In-place operation is supported. When
+ the aperture is partially outside the image, the function interpolates outlier pixel values
+ according to the specified border mode.
+
+ The function does actually compute correlation, not the convolution:
+
+ \(\texttt{dst} (x,y) = \sum _{ \substack{0\leq x' < \texttt{kernel.cols}\\{0\leq y' < \texttt{kernel.rows}}}} \texttt{kernel} (x',y')* \texttt{src} (x+x'- \texttt{anchor.x} ,y+y'- \texttt{anchor.y} )\)
+
+ That is, the kernel is not mirrored around the anchor point. If you need a real convolution, flip
+ the kernel using #flip and set the new anchor to `(kernel.cols - anchor.x - 1, kernel.rows -
+ anchor.y - 1)`.
+
+ The function uses the DFT-based algorithm in case of sufficiently large kernels (~11 x 11 or
+ larger) and the direct algorithm for small kernels.
+
+
Parameters:
+
src - input image.
+
dst - output image of the same size and the same number of channels as src.
+
ddepth - desired depth of the destination image, see REF: filter_depths "combinations"
+
kernel - convolution kernel (or rather a correlation kernel), a single-channel floating point
+ matrix; if you want to apply different kernels to different channels, split the image into
+ separate color planes using split and process them individually.
+
anchor - anchor of the kernel that indicates the relative position of a filtered point within
+ the kernel; the anchor should lie within the kernel; default value (-1,-1) means that the anchor
+ is at the kernel center.
+ SEE: sepFilter2D, dft, matchTemplate
public static void filter2D(Mat src,
+ Mat dst,
+ int ddepth,
+ Mat kernel,
+ Point anchor,
+ double delta)
+
Convolves an image with the kernel.
+
+ The function applies an arbitrary linear filter to an image. In-place operation is supported. When
+ the aperture is partially outside the image, the function interpolates outlier pixel values
+ according to the specified border mode.
+
+ The function does actually compute correlation, not the convolution:
+
+ \(\texttt{dst} (x,y) = \sum _{ \substack{0\leq x' < \texttt{kernel.cols}\\{0\leq y' < \texttt{kernel.rows}}}} \texttt{kernel} (x',y')* \texttt{src} (x+x'- \texttt{anchor.x} ,y+y'- \texttt{anchor.y} )\)
+
+ That is, the kernel is not mirrored around the anchor point. If you need a real convolution, flip
+ the kernel using #flip and set the new anchor to `(kernel.cols - anchor.x - 1, kernel.rows -
+ anchor.y - 1)`.
+
+ The function uses the DFT-based algorithm in case of sufficiently large kernels (~11 x 11 or
+ larger) and the direct algorithm for small kernels.
+
+
Parameters:
+
src - input image.
+
dst - output image of the same size and the same number of channels as src.
+
ddepth - desired depth of the destination image, see REF: filter_depths "combinations"
+
kernel - convolution kernel (or rather a correlation kernel), a single-channel floating point
+ matrix; if you want to apply different kernels to different channels, split the image into
+ separate color planes using split and process them individually.
+
anchor - anchor of the kernel that indicates the relative position of a filtered point within
+ the kernel; the anchor should lie within the kernel; default value (-1,-1) means that the anchor
+ is at the kernel center.
+
delta - optional value added to the filtered pixels before storing them in dst.
+ SEE: sepFilter2D, dft, matchTemplate
public static void filter2D(Mat src,
+ Mat dst,
+ int ddepth,
+ Mat kernel,
+ Point anchor,
+ double delta,
+ int borderType)
+
Convolves an image with the kernel.
+
+ The function applies an arbitrary linear filter to an image. In-place operation is supported. When
+ the aperture is partially outside the image, the function interpolates outlier pixel values
+ according to the specified border mode.
+
+ The function does actually compute correlation, not the convolution:
+
+ \(\texttt{dst} (x,y) = \sum _{ \substack{0\leq x' < \texttt{kernel.cols}\\{0\leq y' < \texttt{kernel.rows}}}} \texttt{kernel} (x',y')* \texttt{src} (x+x'- \texttt{anchor.x} ,y+y'- \texttt{anchor.y} )\)
+
+ That is, the kernel is not mirrored around the anchor point. If you need a real convolution, flip
+ the kernel using #flip and set the new anchor to `(kernel.cols - anchor.x - 1, kernel.rows -
+ anchor.y - 1)`.
+
+ The function uses the DFT-based algorithm in case of sufficiently large kernels (~11 x 11 or
+ larger) and the direct algorithm for small kernels.
+
+
Parameters:
+
src - input image.
+
dst - output image of the same size and the same number of channels as src.
+
ddepth - desired depth of the destination image, see REF: filter_depths "combinations"
+
kernel - convolution kernel (or rather a correlation kernel), a single-channel floating point
+ matrix; if you want to apply different kernels to different channels, split the image into
+ separate color planes using split and process them individually.
+
anchor - anchor of the kernel that indicates the relative position of a filtered point within
+ the kernel; the anchor should lie within the kernel; default value (-1,-1) means that the anchor
+ is at the kernel center.
+
delta - optional value added to the filtered pixels before storing them in dst.
+
borderType - pixel extrapolation method, see #BorderTypes. #BORDER_WRAP is not supported.
+ SEE: sepFilter2D, dft, matchTemplate
public static void findContours(Mat image,
+ java.util.List<MatOfPoint> contours,
+ Mat hierarchy,
+ int mode,
+ int method)
+
Finds contours in a binary image.
+
+ The function retrieves contours from the binary image using the algorithm CITE: Suzuki85 . The contours
+ are a useful tool for shape analysis and object detection and recognition. See squares.cpp in the
+ OpenCV sample directory.
+ Note: Since opencv 3.2 source image is not modified by this function.
+
+
Parameters:
+
image - Source, an 8-bit single-channel image. Non-zero pixels are treated as 1's. Zero
+ pixels remain 0's, so the image is treated as binary . You can use #compare, #inRange, #threshold ,
+ #adaptiveThreshold, #Canny, and others to create a binary image out of a grayscale or color one.
+ If mode equals to #RETR_CCOMP or #RETR_FLOODFILL, the input can also be a 32-bit integer image of labels (CV_32SC1).
+
contours - Detected contours. Each contour is stored as a vector of points (e.g.
+ std::vector<std::vector<cv::Point> >).
+
hierarchy - Optional output vector (e.g. std::vector<cv::Vec4i>), containing information about the image topology. It has
+ as many elements as the number of contours. For each i-th contour contours[i], the elements
+ hierarchy[i][0] , hierarchy[i][1] , hierarchy[i][2] , and hierarchy[i][3] are set to 0-based indices
+ in contours of the next and previous contours at the same hierarchical level, the first child
+ contour and the parent contour, respectively. If for the contour i there are no next, previous,
+ parent, or nested contours, the corresponding elements of hierarchy[i] will be negative.
+ Note: In Python, hierarchy is nested inside a top level array. Use hierarchy[0][i] to access hierarchical elements of i-th contour.
+
mode - Contour retrieval mode, see #RetrievalModes
+
method - Contour approximation method, see #ContourApproximationModes
+ contours are extracted from the image ROI and then they should be analyzed in the whole image
+ context.
public static void findContours(Mat image,
+ java.util.List<MatOfPoint> contours,
+ Mat hierarchy,
+ int mode,
+ int method,
+ Point offset)
+
Finds contours in a binary image.
+
+ The function retrieves contours from the binary image using the algorithm CITE: Suzuki85 . The contours
+ are a useful tool for shape analysis and object detection and recognition. See squares.cpp in the
+ OpenCV sample directory.
+ Note: Since opencv 3.2 source image is not modified by this function.
+
+
Parameters:
+
image - Source, an 8-bit single-channel image. Non-zero pixels are treated as 1's. Zero
+ pixels remain 0's, so the image is treated as binary . You can use #compare, #inRange, #threshold ,
+ #adaptiveThreshold, #Canny, and others to create a binary image out of a grayscale or color one.
+ If mode equals to #RETR_CCOMP or #RETR_FLOODFILL, the input can also be a 32-bit integer image of labels (CV_32SC1).
+
contours - Detected contours. Each contour is stored as a vector of points (e.g.
+ std::vector<std::vector<cv::Point> >).
+
hierarchy - Optional output vector (e.g. std::vector<cv::Vec4i>), containing information about the image topology. It has
+ as many elements as the number of contours. For each i-th contour contours[i], the elements
+ hierarchy[i][0] , hierarchy[i][1] , hierarchy[i][2] , and hierarchy[i][3] are set to 0-based indices
+ in contours of the next and previous contours at the same hierarchical level, the first child
+ contour and the parent contour, respectively. If for the contour i there are no next, previous,
+ parent, or nested contours, the corresponding elements of hierarchy[i] will be negative.
+ Note: In Python, hierarchy is nested inside a top level array. Use hierarchy[0][i] to access hierarchical elements of i-th contour.
+
mode - Contour retrieval mode, see #RetrievalModes
+
method - Contour approximation method, see #ContourApproximationModes
+
offset - Optional offset by which every contour point is shifted. This is useful if the
+ contours are extracted from the image ROI and then they should be analyzed in the whole image
+ context.
Fits an ellipse around a set of 2D points.
+
+ The function calculates the ellipse that fits (in a least-squares sense) a set of 2D points best of
+ all. It returns the rotated rectangle in which the ellipse is inscribed. The first algorithm described by CITE: Fitzgibbon95
+ is used. Developer should keep in mind that it is possible that the returned
+ ellipse/rotatedRect data contains negative indices, due to the data points being close to the
+ border of the containing Mat element.
+
+
Parameters:
+
points - Input 2D point set, stored in std::vector<> or Mat
Fits an ellipse around a set of 2D points.
+
+ The function calculates the ellipse that fits a set of 2D points.
+ It returns the rotated rectangle in which the ellipse is inscribed.
+ The Approximate Mean Square (AMS) proposed by CITE: Taubin1991 is used.
+
+ For an ellipse, this basis set is \( \chi= \left(x^2, x y, y^2, x, y, 1\right) \),
+ which is a set of six free coefficients \( A^T=\left\{A_{\text{xx}},A_{\text{xy}},A_{\text{yy}},A_x,A_y,A_0\right\} \).
+ However, to specify an ellipse, all that is needed is five numbers; the major and minor axes lengths \( (a,b) \),
+ the position \( (x_0,y_0) \), and the orientation \( \theta \). This is because the basis set includes lines,
+ quadratics, parabolic and hyperbolic functions as well as elliptical functions as possible fits.
+ If the fit is found to be a parabolic or hyperbolic function then the standard #fitEllipse method is used.
+ The AMS method restricts the fit to parabolic, hyperbolic and elliptical curves
+ by imposing the condition that \( A^T ( D_x^T D_x + D_y^T D_y) A = 1 \) where
+ the matrices \( Dx \) and \( Dy \) are the partial derivatives of the design matrix \( D \) with
+ respect to x and y. The matrices are formed row by row applying the following to
+ each of the points in the set:
+ \(align*}{
+ D(i,:)&=\left\{x_i^2, x_i y_i, y_i^2, x_i, y_i, 1\right\} &
+ D_x(i,:)&=\left\{2 x_i,y_i,0,1,0,0\right\} &
+ D_y(i,:)&=\left\{0,x_i,2 y_i,0,1,0\right\}
+ \)
+ The AMS method minimizes the cost function
+ \(equation*}{
+ \epsilon ^2=\frac{ A^T D^T D A }{ A^T (D_x^T D_x + D_y^T D_y) A^T }
+ \)
+
+ The minimum cost is found by solving the generalized eigenvalue problem.
+
+ \(equation*}{
+ D^T D A = \lambda \left( D_x^T D_x + D_y^T D_y\right) A
+ \)
+
+
Parameters:
+
points - Input 2D point set, stored in std::vector<> or Mat
Fits an ellipse around a set of 2D points.
+
+ The function calculates the ellipse that fits a set of 2D points.
+ It returns the rotated rectangle in which the ellipse is inscribed.
+ The Direct least square (Direct) method by CITE: Fitzgibbon1999 is used.
+
+ For an ellipse, this basis set is \( \chi= \left(x^2, x y, y^2, x, y, 1\right) \),
+ which is a set of six free coefficients \( A^T=\left\{A_{\text{xx}},A_{\text{xy}},A_{\text{yy}},A_x,A_y,A_0\right\} \).
+ However, to specify an ellipse, all that is needed is five numbers; the major and minor axes lengths \( (a,b) \),
+ the position \( (x_0,y_0) \), and the orientation \( \theta \). This is because the basis set includes lines,
+ quadratics, parabolic and hyperbolic functions as well as elliptical functions as possible fits.
+ The Direct method confines the fit to ellipses by ensuring that \( 4 A_{xx} A_{yy}- A_{xy}^2 > 0 \).
+ The condition imposed is that \( 4 A_{xx} A_{yy}- A_{xy}^2=1 \) which satisfies the inequality
+ and as the coefficients can be arbitrarily scaled is not overly restrictive.
+
+ \(equation*}{
+ \epsilon ^2= A^T D^T D A \quad \text{with} \quad A^T C A =1 \quad \text{and} \quad C=\left(\begin{matrix}
+ 0 & 0 & 2 & 0 & 0 & 0 \\
+ 0 & -1 & 0 & 0 & 0 & 0 \\
+ 2 & 0 & 0 & 0 & 0 & 0 \\
+ 0 & 0 & 0 & 0 & 0 & 0 \\
+ 0 & 0 & 0 & 0 & 0 & 0 \\
+ 0 & 0 & 0 & 0 & 0 & 0
+ \end{matrix} \right)
+ \)
+
+ The minimum cost is found by solving the generalized eigenvalue problem.
+
+ \(equation*}{
+ D^T D A = \lambda \left( C\right) A
+ \)
+
+ The system produces only one positive eigenvalue \( \lambda\) which is chosen as the solution
+ with its eigenvector \(\mathbf{u}\). These are used to find the coefficients
+
+ \(equation*}{
+ A = \sqrt{\frac{1}{\mathbf{u}^T C \mathbf{u}}} \mathbf{u}
+ \)
+ The scaling factor guarantees that \(A^T C A =1\).
+
+
Parameters:
+
points - Input 2D point set, stored in std::vector<> or Mat
public static void fitLine(Mat points,
+ Mat line,
+ int distType,
+ double param,
+ double reps,
+ double aeps)
+
Fits a line to a 2D or 3D point set.
+
+ The function fitLine fits a line to a 2D or 3D point set by minimizing \(\sum_i \rho(r_i)\) where
+ \(r_i\) is a distance between the \(i^{th}\) point, the line and \(\rho(r)\) is a distance function, one
+ of the following:
+
+
+ DIST_L2
+ \(\rho (r) = r^2/2 \quad \text{(the simplest and the fastest least-squares method)}\)
+
+
+ The algorithm is based on the M-estimator ( <http://en.wikipedia.org/wiki/M-estimator> ) technique
+ that iteratively fits the line using the weighted least-squares algorithm. After each iteration the
+ weights \(w_i\) are adjusted to be inversely proportional to \(\rho(r_i)\) .
+
+
Parameters:
+
points - Input vector of 2D or 3D points, stored in std::vector<> or Mat.
+
line - Output line parameters. In case of 2D fitting, it should be a vector of 4 elements
+ (like Vec4f) - (vx, vy, x0, y0), where (vx, vy) is a normalized vector collinear to the line and
+ (x0, y0) is a point on the line. In case of 3D fitting, it should be a vector of 6 elements (like
+ Vec6f) - (vx, vy, vz, x0, y0, z0), where (vx, vy, vz) is a normalized vector collinear to the line
+ and (x0, y0, z0) is a point on the line.
+
distType - Distance used by the M-estimator, see #DistanceTypes
+
param - Numerical parameter ( C ) for some types of distances. If it is 0, an optimal value
+ is chosen.
+
reps - Sufficient accuracy for the radius (distance between the coordinate origin and the line).
+
aeps - Sufficient accuracy for the angle. 0.01 would be a good default value for reps and aeps.
public static int floodFill(Mat image,
+ Mat mask,
+ Point seedPoint,
+ Scalar newVal)
+
Fills a connected component with the given color.
+
+ The function cv::floodFill fills a connected component starting from the seed point with the specified
+ color. The connectivity is determined by the color/brightness closeness of the neighbor pixels. The
+ pixel at \((x,y)\) is considered to belong to the repainted domain if:
+
+
+
+ in case of a grayscale image and floating range
+ \(\texttt{src} (x',y')- \texttt{loDiff} \leq \texttt{src} (x,y) \leq \texttt{src} (x',y')+ \texttt{upDiff}\)
+
+
+
+
+
+
+ in case of a grayscale image and fixed range
+ \(\texttt{src} ( \texttt{seedPoint} .x, \texttt{seedPoint} .y)- \texttt{loDiff} \leq \texttt{src} (x,y) \leq \texttt{src} ( \texttt{seedPoint} .x, \texttt{seedPoint} .y)+ \texttt{upDiff}\)
+
+
+
+
+
+
+ in case of a color image and floating range
+ \(\texttt{src} (x',y')_r- \texttt{loDiff} _r \leq \texttt{src} (x,y)_r \leq \texttt{src} (x',y')_r+ \texttt{upDiff} _r,\)
+ \(\texttt{src} (x',y')_g- \texttt{loDiff} _g \leq \texttt{src} (x,y)_g \leq \texttt{src} (x',y')_g+ \texttt{upDiff} _g\)
+ and
+ \(\texttt{src} (x',y')_b- \texttt{loDiff} _b \leq \texttt{src} (x,y)_b \leq \texttt{src} (x',y')_b+ \texttt{upDiff} _b\)
+
+
+
+
+
+
+ in case of a color image and fixed range
+ \(\texttt{src} ( \texttt{seedPoint} .x, \texttt{seedPoint} .y)_r- \texttt{loDiff} _r \leq \texttt{src} (x,y)_r \leq \texttt{src} ( \texttt{seedPoint} .x, \texttt{seedPoint} .y)_r+ \texttt{upDiff} _r,\)
+ \(\texttt{src} ( \texttt{seedPoint} .x, \texttt{seedPoint} .y)_g- \texttt{loDiff} _g \leq \texttt{src} (x,y)_g \leq \texttt{src} ( \texttt{seedPoint} .x, \texttt{seedPoint} .y)_g+ \texttt{upDiff} _g\)
+ and
+ \(\texttt{src} ( \texttt{seedPoint} .x, \texttt{seedPoint} .y)_b- \texttt{loDiff} _b \leq \texttt{src} (x,y)_b \leq \texttt{src} ( \texttt{seedPoint} .x, \texttt{seedPoint} .y)_b+ \texttt{upDiff} _b\)
+
+
+
+
+ where \(src(x',y')\) is the value of one of pixel neighbors that is already known to belong to the
+ component. That is, to be added to the connected component, a color/brightness of the pixel should
+ be close enough to:
+
+
+ Color/brightness of one of its neighbors that already belong to the connected component in case
+ of a floating range.
+
+
+ Color/brightness of the seed point in case of a fixed range.
+
+
+
+ Use these functions to either mark a connected component with the specified color in-place, or build
+ a mask and then extract the contour, or copy the region to another image, and so on.
+
+
Parameters:
+
image - Input/output 1- or 3-channel, 8-bit, or floating-point image. It is modified by the
+ function unless the #FLOODFILL_MASK_ONLY flag is set in the second variant of the function. See
+ the details below.
+
mask - Operation mask that should be a single-channel 8-bit image, 2 pixels wider and 2 pixels
+ taller than image. If an empty Mat is passed it will be created automatically. Since this is both an
+ input and output parameter, you must take responsibility of initializing it.
+ Flood-filling cannot go across non-zero pixels in the input mask. For example,
+ an edge detector output can be used as a mask to stop filling at edges. On output, pixels in the
+ mask corresponding to filled pixels in the image are set to 1 or to the specified value in flags
+ as described below. Additionally, the function fills the border of the mask with ones to simplify
+ internal processing. It is therefore possible to use the same mask in multiple calls to the function
+ to make sure the filled areas do not overlap.
+
seedPoint - Starting point.
+
newVal - New value of the repainted domain pixels.
+ one of its neighbors belonging to the component, or a seed pixel being added to the component.
+ one of its neighbors belonging to the component, or a seed pixel being added to the component.
+ repainted domain.
+ 4 means that only the four nearest neighbor pixels (those that share an edge) are considered. A
+ connectivity value of 8 means that the eight nearest neighbor pixels (those that share a corner)
+ will be considered. The next 8 bits (8-16) contain a value between 1 and 255 with which to fill
+ the mask (the default value is 1). For example, 4 | ( 255 << 8 ) will consider 4 nearest
+ neighbours and fill the mask with a value of 255. The following additional options occupy higher
+ bits and therefore may be further combined with the connectivity and mask fill values using
+ bit-wise or (|), see #FloodFillFlags.
+
+ Note: Since the mask is larger than the filled image, a pixel \((x, y)\) in image corresponds to the
+ pixel \((x+1, y+1)\) in the mask .
+
+ SEE: findContours
public static int floodFill(Mat image,
+ Mat mask,
+ Point seedPoint,
+ Scalar newVal,
+ Rect rect)
+
Fills a connected component with the given color.
+
+ The function cv::floodFill fills a connected component starting from the seed point with the specified
+ color. The connectivity is determined by the color/brightness closeness of the neighbor pixels. The
+ pixel at \((x,y)\) is considered to belong to the repainted domain if:
+
+
+
+ in case of a grayscale image and floating range
+ \(\texttt{src} (x',y')- \texttt{loDiff} \leq \texttt{src} (x,y) \leq \texttt{src} (x',y')+ \texttt{upDiff}\)
+
+
+
+
+
+
+ in case of a grayscale image and fixed range
+ \(\texttt{src} ( \texttt{seedPoint} .x, \texttt{seedPoint} .y)- \texttt{loDiff} \leq \texttt{src} (x,y) \leq \texttt{src} ( \texttt{seedPoint} .x, \texttt{seedPoint} .y)+ \texttt{upDiff}\)
+
+
+
+
+
+
+ in case of a color image and floating range
+ \(\texttt{src} (x',y')_r- \texttt{loDiff} _r \leq \texttt{src} (x,y)_r \leq \texttt{src} (x',y')_r+ \texttt{upDiff} _r,\)
+ \(\texttt{src} (x',y')_g- \texttt{loDiff} _g \leq \texttt{src} (x,y)_g \leq \texttt{src} (x',y')_g+ \texttt{upDiff} _g\)
+ and
+ \(\texttt{src} (x',y')_b- \texttt{loDiff} _b \leq \texttt{src} (x,y)_b \leq \texttt{src} (x',y')_b+ \texttt{upDiff} _b\)
+
+
+
+
+
+
+ in case of a color image and fixed range
+ \(\texttt{src} ( \texttt{seedPoint} .x, \texttt{seedPoint} .y)_r- \texttt{loDiff} _r \leq \texttt{src} (x,y)_r \leq \texttt{src} ( \texttt{seedPoint} .x, \texttt{seedPoint} .y)_r+ \texttt{upDiff} _r,\)
+ \(\texttt{src} ( \texttt{seedPoint} .x, \texttt{seedPoint} .y)_g- \texttt{loDiff} _g \leq \texttt{src} (x,y)_g \leq \texttt{src} ( \texttt{seedPoint} .x, \texttt{seedPoint} .y)_g+ \texttt{upDiff} _g\)
+ and
+ \(\texttt{src} ( \texttt{seedPoint} .x, \texttt{seedPoint} .y)_b- \texttt{loDiff} _b \leq \texttt{src} (x,y)_b \leq \texttt{src} ( \texttt{seedPoint} .x, \texttt{seedPoint} .y)_b+ \texttt{upDiff} _b\)
+
+
+
+
+ where \(src(x',y')\) is the value of one of pixel neighbors that is already known to belong to the
+ component. That is, to be added to the connected component, a color/brightness of the pixel should
+ be close enough to:
+
+
+ Color/brightness of one of its neighbors that already belong to the connected component in case
+ of a floating range.
+
+
+ Color/brightness of the seed point in case of a fixed range.
+
+
+
+ Use these functions to either mark a connected component with the specified color in-place, or build
+ a mask and then extract the contour, or copy the region to another image, and so on.
+
+
Parameters:
+
image - Input/output 1- or 3-channel, 8-bit, or floating-point image. It is modified by the
+ function unless the #FLOODFILL_MASK_ONLY flag is set in the second variant of the function. See
+ the details below.
+
mask - Operation mask that should be a single-channel 8-bit image, 2 pixels wider and 2 pixels
+ taller than image. If an empty Mat is passed it will be created automatically. Since this is both an
+ input and output parameter, you must take responsibility of initializing it.
+ Flood-filling cannot go across non-zero pixels in the input mask. For example,
+ an edge detector output can be used as a mask to stop filling at edges. On output, pixels in the
+ mask corresponding to filled pixels in the image are set to 1 or to the specified value in flags
+ as described below. Additionally, the function fills the border of the mask with ones to simplify
+ internal processing. It is therefore possible to use the same mask in multiple calls to the function
+ to make sure the filled areas do not overlap.
+
seedPoint - Starting point.
+
newVal - New value of the repainted domain pixels.
+ one of its neighbors belonging to the component, or a seed pixel being added to the component.
+ one of its neighbors belonging to the component, or a seed pixel being added to the component.
+
rect - Optional output parameter set by the function to the minimum bounding rectangle of the
+ repainted domain.
+ 4 means that only the four nearest neighbor pixels (those that share an edge) are considered. A
+ connectivity value of 8 means that the eight nearest neighbor pixels (those that share a corner)
+ will be considered. The next 8 bits (8-16) contain a value between 1 and 255 with which to fill
+ the mask (the default value is 1). For example, 4 | ( 255 << 8 ) will consider 4 nearest
+ neighbours and fill the mask with a value of 255. The following additional options occupy higher
+ bits and therefore may be further combined with the connectivity and mask fill values using
+ bit-wise or (|), see #FloodFillFlags.
+
+ Note: Since the mask is larger than the filled image, a pixel \((x, y)\) in image corresponds to the
+ pixel \((x+1, y+1)\) in the mask .
+
+ SEE: findContours
public static int floodFill(Mat image,
+ Mat mask,
+ Point seedPoint,
+ Scalar newVal,
+ Rect rect,
+ Scalar loDiff)
+
Fills a connected component with the given color.
+
+ The function cv::floodFill fills a connected component starting from the seed point with the specified
+ color. The connectivity is determined by the color/brightness closeness of the neighbor pixels. The
+ pixel at \((x,y)\) is considered to belong to the repainted domain if:
+
+
+
+ in case of a grayscale image and floating range
+ \(\texttt{src} (x',y')- \texttt{loDiff} \leq \texttt{src} (x,y) \leq \texttt{src} (x',y')+ \texttt{upDiff}\)
+
+
+
+
+
+
+ in case of a grayscale image and fixed range
+ \(\texttt{src} ( \texttt{seedPoint} .x, \texttt{seedPoint} .y)- \texttt{loDiff} \leq \texttt{src} (x,y) \leq \texttt{src} ( \texttt{seedPoint} .x, \texttt{seedPoint} .y)+ \texttt{upDiff}\)
+
+
+
+
+
+
+ in case of a color image and floating range
+ \(\texttt{src} (x',y')_r- \texttt{loDiff} _r \leq \texttt{src} (x,y)_r \leq \texttt{src} (x',y')_r+ \texttt{upDiff} _r,\)
+ \(\texttt{src} (x',y')_g- \texttt{loDiff} _g \leq \texttt{src} (x,y)_g \leq \texttt{src} (x',y')_g+ \texttt{upDiff} _g\)
+ and
+ \(\texttt{src} (x',y')_b- \texttt{loDiff} _b \leq \texttt{src} (x,y)_b \leq \texttt{src} (x',y')_b+ \texttt{upDiff} _b\)
+
+
+
+
+
+
+ in case of a color image and fixed range
+ \(\texttt{src} ( \texttt{seedPoint} .x, \texttt{seedPoint} .y)_r- \texttt{loDiff} _r \leq \texttt{src} (x,y)_r \leq \texttt{src} ( \texttt{seedPoint} .x, \texttt{seedPoint} .y)_r+ \texttt{upDiff} _r,\)
+ \(\texttt{src} ( \texttt{seedPoint} .x, \texttt{seedPoint} .y)_g- \texttt{loDiff} _g \leq \texttt{src} (x,y)_g \leq \texttt{src} ( \texttt{seedPoint} .x, \texttt{seedPoint} .y)_g+ \texttt{upDiff} _g\)
+ and
+ \(\texttt{src} ( \texttt{seedPoint} .x, \texttt{seedPoint} .y)_b- \texttt{loDiff} _b \leq \texttt{src} (x,y)_b \leq \texttt{src} ( \texttt{seedPoint} .x, \texttt{seedPoint} .y)_b+ \texttt{upDiff} _b\)
+
+
+
+
+ where \(src(x',y')\) is the value of one of pixel neighbors that is already known to belong to the
+ component. That is, to be added to the connected component, a color/brightness of the pixel should
+ be close enough to:
+
+
+ Color/brightness of one of its neighbors that already belong to the connected component in case
+ of a floating range.
+
+
+ Color/brightness of the seed point in case of a fixed range.
+
+
+
+ Use these functions to either mark a connected component with the specified color in-place, or build
+ a mask and then extract the contour, or copy the region to another image, and so on.
+
+
Parameters:
+
image - Input/output 1- or 3-channel, 8-bit, or floating-point image. It is modified by the
+ function unless the #FLOODFILL_MASK_ONLY flag is set in the second variant of the function. See
+ the details below.
+
mask - Operation mask that should be a single-channel 8-bit image, 2 pixels wider and 2 pixels
+ taller than image. If an empty Mat is passed it will be created automatically. Since this is both an
+ input and output parameter, you must take responsibility of initializing it.
+ Flood-filling cannot go across non-zero pixels in the input mask. For example,
+ an edge detector output can be used as a mask to stop filling at edges. On output, pixels in the
+ mask corresponding to filled pixels in the image are set to 1 or to the specified value in flags
+ as described below. Additionally, the function fills the border of the mask with ones to simplify
+ internal processing. It is therefore possible to use the same mask in multiple calls to the function
+ to make sure the filled areas do not overlap.
+
seedPoint - Starting point.
+
newVal - New value of the repainted domain pixels.
+
loDiff - Maximal lower brightness/color difference between the currently observed pixel and
+ one of its neighbors belonging to the component, or a seed pixel being added to the component.
+ one of its neighbors belonging to the component, or a seed pixel being added to the component.
+
rect - Optional output parameter set by the function to the minimum bounding rectangle of the
+ repainted domain.
+ 4 means that only the four nearest neighbor pixels (those that share an edge) are considered. A
+ connectivity value of 8 means that the eight nearest neighbor pixels (those that share a corner)
+ will be considered. The next 8 bits (8-16) contain a value between 1 and 255 with which to fill
+ the mask (the default value is 1). For example, 4 | ( 255 << 8 ) will consider 4 nearest
+ neighbours and fill the mask with a value of 255. The following additional options occupy higher
+ bits and therefore may be further combined with the connectivity and mask fill values using
+ bit-wise or (|), see #FloodFillFlags.
+
+ Note: Since the mask is larger than the filled image, a pixel \((x, y)\) in image corresponds to the
+ pixel \((x+1, y+1)\) in the mask .
+
+ SEE: findContours
public static int floodFill(Mat image,
+ Mat mask,
+ Point seedPoint,
+ Scalar newVal,
+ Rect rect,
+ Scalar loDiff,
+ Scalar upDiff)
+
Fills a connected component with the given color.
+
+ The function cv::floodFill fills a connected component starting from the seed point with the specified
+ color. The connectivity is determined by the color/brightness closeness of the neighbor pixels. The
+ pixel at \((x,y)\) is considered to belong to the repainted domain if:
+
+
+
+ in case of a grayscale image and floating range
+ \(\texttt{src} (x',y')- \texttt{loDiff} \leq \texttt{src} (x,y) \leq \texttt{src} (x',y')+ \texttt{upDiff}\)
+
+
+
+
+
+
+ in case of a grayscale image and fixed range
+ \(\texttt{src} ( \texttt{seedPoint} .x, \texttt{seedPoint} .y)- \texttt{loDiff} \leq \texttt{src} (x,y) \leq \texttt{src} ( \texttt{seedPoint} .x, \texttt{seedPoint} .y)+ \texttt{upDiff}\)
+
+
+
+
+
+
+ in case of a color image and floating range
+ \(\texttt{src} (x',y')_r- \texttt{loDiff} _r \leq \texttt{src} (x,y)_r \leq \texttt{src} (x',y')_r+ \texttt{upDiff} _r,\)
+ \(\texttt{src} (x',y')_g- \texttt{loDiff} _g \leq \texttt{src} (x,y)_g \leq \texttt{src} (x',y')_g+ \texttt{upDiff} _g\)
+ and
+ \(\texttt{src} (x',y')_b- \texttt{loDiff} _b \leq \texttt{src} (x,y)_b \leq \texttt{src} (x',y')_b+ \texttt{upDiff} _b\)
+
+
+
+
+
+
+ in case of a color image and fixed range
+ \(\texttt{src} ( \texttt{seedPoint} .x, \texttt{seedPoint} .y)_r- \texttt{loDiff} _r \leq \texttt{src} (x,y)_r \leq \texttt{src} ( \texttt{seedPoint} .x, \texttt{seedPoint} .y)_r+ \texttt{upDiff} _r,\)
+ \(\texttt{src} ( \texttt{seedPoint} .x, \texttt{seedPoint} .y)_g- \texttt{loDiff} _g \leq \texttt{src} (x,y)_g \leq \texttt{src} ( \texttt{seedPoint} .x, \texttt{seedPoint} .y)_g+ \texttt{upDiff} _g\)
+ and
+ \(\texttt{src} ( \texttt{seedPoint} .x, \texttt{seedPoint} .y)_b- \texttt{loDiff} _b \leq \texttt{src} (x,y)_b \leq \texttt{src} ( \texttt{seedPoint} .x, \texttt{seedPoint} .y)_b+ \texttt{upDiff} _b\)
+
+
+
+
+ where \(src(x',y')\) is the value of one of pixel neighbors that is already known to belong to the
+ component. That is, to be added to the connected component, a color/brightness of the pixel should
+ be close enough to:
+
+
+ Color/brightness of one of its neighbors that already belong to the connected component in case
+ of a floating range.
+
+
+ Color/brightness of the seed point in case of a fixed range.
+
+
+
+ Use these functions to either mark a connected component with the specified color in-place, or build
+ a mask and then extract the contour, or copy the region to another image, and so on.
+
+
Parameters:
+
image - Input/output 1- or 3-channel, 8-bit, or floating-point image. It is modified by the
+ function unless the #FLOODFILL_MASK_ONLY flag is set in the second variant of the function. See
+ the details below.
+
mask - Operation mask that should be a single-channel 8-bit image, 2 pixels wider and 2 pixels
+ taller than image. If an empty Mat is passed it will be created automatically. Since this is both an
+ input and output parameter, you must take responsibility of initializing it.
+ Flood-filling cannot go across non-zero pixels in the input mask. For example,
+ an edge detector output can be used as a mask to stop filling at edges. On output, pixels in the
+ mask corresponding to filled pixels in the image are set to 1 or to the specified value in flags
+ as described below. Additionally, the function fills the border of the mask with ones to simplify
+ internal processing. It is therefore possible to use the same mask in multiple calls to the function
+ to make sure the filled areas do not overlap.
+
seedPoint - Starting point.
+
newVal - New value of the repainted domain pixels.
+
loDiff - Maximal lower brightness/color difference between the currently observed pixel and
+ one of its neighbors belonging to the component, or a seed pixel being added to the component.
+
upDiff - Maximal upper brightness/color difference between the currently observed pixel and
+ one of its neighbors belonging to the component, or a seed pixel being added to the component.
+
rect - Optional output parameter set by the function to the minimum bounding rectangle of the
+ repainted domain.
+ 4 means that only the four nearest neighbor pixels (those that share an edge) are considered. A
+ connectivity value of 8 means that the eight nearest neighbor pixels (those that share a corner)
+ will be considered. The next 8 bits (8-16) contain a value between 1 and 255 with which to fill
+ the mask (the default value is 1). For example, 4 | ( 255 << 8 ) will consider 4 nearest
+ neighbours and fill the mask with a value of 255. The following additional options occupy higher
+ bits and therefore may be further combined with the connectivity and mask fill values using
+ bit-wise or (|), see #FloodFillFlags.
+
+ Note: Since the mask is larger than the filled image, a pixel \((x, y)\) in image corresponds to the
+ pixel \((x+1, y+1)\) in the mask .
+
+ SEE: findContours
public static int floodFill(Mat image,
+ Mat mask,
+ Point seedPoint,
+ Scalar newVal,
+ Rect rect,
+ Scalar loDiff,
+ Scalar upDiff,
+ int flags)
+
Fills a connected component with the given color.
+
+ The function cv::floodFill fills a connected component starting from the seed point with the specified
+ color. The connectivity is determined by the color/brightness closeness of the neighbor pixels. The
+ pixel at \((x,y)\) is considered to belong to the repainted domain if:
+
+
+
+ in case of a grayscale image and floating range
+ \(\texttt{src} (x',y')- \texttt{loDiff} \leq \texttt{src} (x,y) \leq \texttt{src} (x',y')+ \texttt{upDiff}\)
+
+
+
+
+
+
+ in case of a grayscale image and fixed range
+ \(\texttt{src} ( \texttt{seedPoint} .x, \texttt{seedPoint} .y)- \texttt{loDiff} \leq \texttt{src} (x,y) \leq \texttt{src} ( \texttt{seedPoint} .x, \texttt{seedPoint} .y)+ \texttt{upDiff}\)
+
+
+
+
+
+
+ in case of a color image and floating range
+ \(\texttt{src} (x',y')_r- \texttt{loDiff} _r \leq \texttt{src} (x,y)_r \leq \texttt{src} (x',y')_r+ \texttt{upDiff} _r,\)
+ \(\texttt{src} (x',y')_g- \texttt{loDiff} _g \leq \texttt{src} (x,y)_g \leq \texttt{src} (x',y')_g+ \texttt{upDiff} _g\)
+ and
+ \(\texttt{src} (x',y')_b- \texttt{loDiff} _b \leq \texttt{src} (x,y)_b \leq \texttt{src} (x',y')_b+ \texttt{upDiff} _b\)
+
+
+
+
+
+
+ in case of a color image and fixed range
+ \(\texttt{src} ( \texttt{seedPoint} .x, \texttt{seedPoint} .y)_r- \texttt{loDiff} _r \leq \texttt{src} (x,y)_r \leq \texttt{src} ( \texttt{seedPoint} .x, \texttt{seedPoint} .y)_r+ \texttt{upDiff} _r,\)
+ \(\texttt{src} ( \texttt{seedPoint} .x, \texttt{seedPoint} .y)_g- \texttt{loDiff} _g \leq \texttt{src} (x,y)_g \leq \texttt{src} ( \texttt{seedPoint} .x, \texttt{seedPoint} .y)_g+ \texttt{upDiff} _g\)
+ and
+ \(\texttt{src} ( \texttt{seedPoint} .x, \texttt{seedPoint} .y)_b- \texttt{loDiff} _b \leq \texttt{src} (x,y)_b \leq \texttt{src} ( \texttt{seedPoint} .x, \texttt{seedPoint} .y)_b+ \texttt{upDiff} _b\)
+
+
+
+
+ where \(src(x',y')\) is the value of one of pixel neighbors that is already known to belong to the
+ component. That is, to be added to the connected component, a color/brightness of the pixel should
+ be close enough to:
+
+
+ Color/brightness of one of its neighbors that already belong to the connected component in case
+ of a floating range.
+
+
+ Color/brightness of the seed point in case of a fixed range.
+
+
+
+ Use these functions to either mark a connected component with the specified color in-place, or build
+ a mask and then extract the contour, or copy the region to another image, and so on.
+
+
Parameters:
+
image - Input/output 1- or 3-channel, 8-bit, or floating-point image. It is modified by the
+ function unless the #FLOODFILL_MASK_ONLY flag is set in the second variant of the function. See
+ the details below.
+
mask - Operation mask that should be a single-channel 8-bit image, 2 pixels wider and 2 pixels
+ taller than image. If an empty Mat is passed it will be created automatically. Since this is both an
+ input and output parameter, you must take responsibility of initializing it.
+ Flood-filling cannot go across non-zero pixels in the input mask. For example,
+ an edge detector output can be used as a mask to stop filling at edges. On output, pixels in the
+ mask corresponding to filled pixels in the image are set to 1 or to the specified value in flags
+ as described below. Additionally, the function fills the border of the mask with ones to simplify
+ internal processing. It is therefore possible to use the same mask in multiple calls to the function
+ to make sure the filled areas do not overlap.
+
seedPoint - Starting point.
+
newVal - New value of the repainted domain pixels.
+
loDiff - Maximal lower brightness/color difference between the currently observed pixel and
+ one of its neighbors belonging to the component, or a seed pixel being added to the component.
+
upDiff - Maximal upper brightness/color difference between the currently observed pixel and
+ one of its neighbors belonging to the component, or a seed pixel being added to the component.
+
rect - Optional output parameter set by the function to the minimum bounding rectangle of the
+ repainted domain.
+
flags - Operation flags. The first 8 bits contain a connectivity value. The default value of
+ 4 means that only the four nearest neighbor pixels (those that share an edge) are considered. A
+ connectivity value of 8 means that the eight nearest neighbor pixels (those that share a corner)
+ will be considered. The next 8 bits (8-16) contain a value between 1 and 255 with which to fill
+ the mask (the default value is 1). For example, 4 | ( 255 << 8 ) will consider 4 nearest
+ neighbours and fill the mask with a value of 255. The following additional options occupy higher
+ bits and therefore may be further combined with the connectivity and mask fill values using
+ bit-wise or (|), see #FloodFillFlags.
+
+ Note: Since the mask is larger than the filled image, a pixel \((x, y)\) in image corresponds to the
+ pixel \((x+1, y+1)\) in the mask .
+
+ SEE: findContours
public static void GaussianBlur(Mat src,
+ Mat dst,
+ Size ksize,
+ double sigmaX)
+
Blurs an image using a Gaussian filter.
+
+ The function convolves the source image with the specified Gaussian kernel. In-place filtering is
+ supported.
+
+
Parameters:
+
src - input image; the image can have any number of channels, which are processed
+ independently, but the depth should be CV_8U, CV_16U, CV_16S, CV_32F or CV_64F.
+
dst - output image of the same size and type as src.
+
ksize - Gaussian kernel size. ksize.width and ksize.height can differ but they both must be
+ positive and odd. Or, they can be zero's and then they are computed from sigma.
+
sigmaX - Gaussian kernel standard deviation in X direction.
+ equal to sigmaX, if both sigmas are zeros, they are computed from ksize.width and ksize.height,
+ respectively (see #getGaussianKernel for details); to fully control the result regardless of
+ possible future modifications of all this semantics, it is recommended to specify all of ksize,
+ sigmaX, and sigmaY.
+
+ SEE: sepFilter2D, filter2D, blur, boxFilter, bilateralFilter, medianBlur
public static void GaussianBlur(Mat src,
+ Mat dst,
+ Size ksize,
+ double sigmaX,
+ double sigmaY)
+
Blurs an image using a Gaussian filter.
+
+ The function convolves the source image with the specified Gaussian kernel. In-place filtering is
+ supported.
+
+
Parameters:
+
src - input image; the image can have any number of channels, which are processed
+ independently, but the depth should be CV_8U, CV_16U, CV_16S, CV_32F or CV_64F.
+
dst - output image of the same size and type as src.
+
ksize - Gaussian kernel size. ksize.width and ksize.height can differ but they both must be
+ positive and odd. Or, they can be zero's and then they are computed from sigma.
+
sigmaX - Gaussian kernel standard deviation in X direction.
+
sigmaY - Gaussian kernel standard deviation in Y direction; if sigmaY is zero, it is set to be
+ equal to sigmaX, if both sigmas are zeros, they are computed from ksize.width and ksize.height,
+ respectively (see #getGaussianKernel for details); to fully control the result regardless of
+ possible future modifications of all this semantics, it is recommended to specify all of ksize,
+ sigmaX, and sigmaY.
+
+ SEE: sepFilter2D, filter2D, blur, boxFilter, bilateralFilter, medianBlur
public static void GaussianBlur(Mat src,
+ Mat dst,
+ Size ksize,
+ double sigmaX,
+ double sigmaY,
+ int borderType)
+
Blurs an image using a Gaussian filter.
+
+ The function convolves the source image with the specified Gaussian kernel. In-place filtering is
+ supported.
+
+
Parameters:
+
src - input image; the image can have any number of channels, which are processed
+ independently, but the depth should be CV_8U, CV_16U, CV_16S, CV_32F or CV_64F.
+
dst - output image of the same size and type as src.
+
ksize - Gaussian kernel size. ksize.width and ksize.height can differ but they both must be
+ positive and odd. Or, they can be zero's and then they are computed from sigma.
+
sigmaX - Gaussian kernel standard deviation in X direction.
+
sigmaY - Gaussian kernel standard deviation in Y direction; if sigmaY is zero, it is set to be
+ equal to sigmaX, if both sigmas are zeros, they are computed from ksize.width and ksize.height,
+ respectively (see #getGaussianKernel for details); to fully control the result regardless of
+ possible future modifications of all this semantics, it is recommended to specify all of ksize,
+ sigmaX, and sigmaY.
+
borderType - pixel extrapolation method, see #BorderTypes. #BORDER_WRAP is not supported.
+
+ SEE: sepFilter2D, filter2D, blur, boxFilter, bilateralFilter, medianBlur
public static void getDerivKernels(Mat kx,
+ Mat ky,
+ int dx,
+ int dy,
+ int ksize)
+
Returns filter coefficients for computing spatial image derivatives.
+
+ The function computes and returns the filter coefficients for spatial image derivatives. When
+ ksize=FILTER_SCHARR, the Scharr \(3 \times 3\) kernels are generated (see #Scharr). Otherwise, Sobel
+ kernels are generated (see #Sobel). The filters are normally passed to #sepFilter2D or to
+
+
Parameters:
+
kx - Output matrix of row filter coefficients. It has the type ktype .
+
ky - Output matrix of column filter coefficients. It has the type ktype .
+
dx - Derivative order in respect of x.
+
dy - Derivative order in respect of y.
+
ksize - Aperture size. It can be FILTER_SCHARR, 1, 3, 5, or 7.
+ Theoretically, the coefficients should have the denominator \(=2^{ksize*2-dx-dy-2}\). If you are
+ going to filter floating-point images, you are likely to use the normalized kernels. But if you
+ compute derivatives of an 8-bit image, store the results in a 16-bit image, and wish to preserve
+ all the fractional bits, you may want to set normalize=false .
public static void getDerivKernels(Mat kx,
+ Mat ky,
+ int dx,
+ int dy,
+ int ksize,
+ boolean normalize)
+
Returns filter coefficients for computing spatial image derivatives.
+
+ The function computes and returns the filter coefficients for spatial image derivatives. When
+ ksize=FILTER_SCHARR, the Scharr \(3 \times 3\) kernels are generated (see #Scharr). Otherwise, Sobel
+ kernels are generated (see #Sobel). The filters are normally passed to #sepFilter2D or to
+
+
Parameters:
+
kx - Output matrix of row filter coefficients. It has the type ktype .
+
ky - Output matrix of column filter coefficients. It has the type ktype .
+
dx - Derivative order in respect of x.
+
dy - Derivative order in respect of y.
+
ksize - Aperture size. It can be FILTER_SCHARR, 1, 3, 5, or 7.
+
normalize - Flag indicating whether to normalize (scale down) the filter coefficients or not.
+ Theoretically, the coefficients should have the denominator \(=2^{ksize*2-dx-dy-2}\). If you are
+ going to filter floating-point images, you are likely to use the normalized kernels. But if you
+ compute derivatives of an 8-bit image, store the results in a 16-bit image, and wish to preserve
+ all the fractional bits, you may want to set normalize=false .
public static void getDerivKernels(Mat kx,
+ Mat ky,
+ int dx,
+ int dy,
+ int ksize,
+ boolean normalize,
+ int ktype)
+
Returns filter coefficients for computing spatial image derivatives.
+
+ The function computes and returns the filter coefficients for spatial image derivatives. When
+ ksize=FILTER_SCHARR, the Scharr \(3 \times 3\) kernels are generated (see #Scharr). Otherwise, Sobel
+ kernels are generated (see #Sobel). The filters are normally passed to #sepFilter2D or to
+
+
Parameters:
+
kx - Output matrix of row filter coefficients. It has the type ktype .
+
ky - Output matrix of column filter coefficients. It has the type ktype .
+
dx - Derivative order in respect of x.
+
dy - Derivative order in respect of y.
+
ksize - Aperture size. It can be FILTER_SCHARR, 1, 3, 5, or 7.
+
normalize - Flag indicating whether to normalize (scale down) the filter coefficients or not.
+ Theoretically, the coefficients should have the denominator \(=2^{ksize*2-dx-dy-2}\). If you are
+ going to filter floating-point images, you are likely to use the normalized kernels. But if you
+ compute derivatives of an 8-bit image, store the results in a 16-bit image, and wish to preserve
+ all the fractional bits, you may want to set normalize=false .
+
ktype - Type of filter coefficients. It can be CV_32f or CV_64F .
public static Mat getGaborKernel(Size ksize,
+ double sigma,
+ double theta,
+ double lambd,
+ double gamma)
+
Returns Gabor filter coefficients.
+
+ For more details about gabor filter equations and parameters, see: [Gabor
+ Filter](http://en.wikipedia.org/wiki/Gabor_filter).
+
+
Parameters:
+
ksize - Size of the filter returned.
+
sigma - Standard deviation of the gaussian envelope.
+
theta - Orientation of the normal to the parallel stripes of a Gabor function.
public static Mat getGaborKernel(Size ksize,
+ double sigma,
+ double theta,
+ double lambd,
+ double gamma,
+ double psi)
+
Returns Gabor filter coefficients.
+
+ For more details about gabor filter equations and parameters, see: [Gabor
+ Filter](http://en.wikipedia.org/wiki/Gabor_filter).
+
+
Parameters:
+
ksize - Size of the filter returned.
+
sigma - Standard deviation of the gaussian envelope.
+
theta - Orientation of the normal to the parallel stripes of a Gabor function.
public static Mat getGaborKernel(Size ksize,
+ double sigma,
+ double theta,
+ double lambd,
+ double gamma,
+ double psi,
+ int ktype)
+
Returns Gabor filter coefficients.
+
+ For more details about gabor filter equations and parameters, see: [Gabor
+ Filter](http://en.wikipedia.org/wiki/Gabor_filter).
+
+
Parameters:
+
ksize - Size of the filter returned.
+
sigma - Standard deviation of the gaussian envelope.
+
theta - Orientation of the normal to the parallel stripes of a Gabor function.
+
lambd - Wavelength of the sinusoidal factor.
+
gamma - Spatial aspect ratio.
+
psi - Phase offset.
+
ktype - Type of filter coefficients. It can be CV_32F or CV_64F .
public static Mat getGaussianKernel(int ksize,
+ double sigma)
+
Returns Gaussian filter coefficients.
+
+ The function computes and returns the \(\texttt{ksize} \times 1\) matrix of Gaussian filter
+ coefficients:
+
+ \(G_i= \alpha *e^{-(i-( \texttt{ksize} -1)/2)^2/(2* \texttt{sigma}^2)},\)
+
+ where \(i=0..\texttt{ksize}-1\) and \(\alpha\) is the scale factor chosen so that \(\sum_i G_i=1\).
+
+ Two of such generated kernels can be passed to sepFilter2D. Those functions automatically recognize
+ smoothing kernels (a symmetrical kernel with sum of weights equal to 1) and handle them accordingly.
+ You may also use the higher-level GaussianBlur.
+
+
Parameters:
+
ksize - Aperture size. It should be odd ( \(\texttt{ksize} \mod 2 = 1\) ) and positive.
+
sigma - Gaussian standard deviation. If it is non-positive, it is computed from ksize as
+ sigma = 0.3*((ksize-1)*0.5 - 1) + 0.8.
+ SEE: sepFilter2D, getDerivKernels, getStructuringElement, GaussianBlur
public static Mat getGaussianKernel(int ksize,
+ double sigma,
+ int ktype)
+
Returns Gaussian filter coefficients.
+
+ The function computes and returns the \(\texttt{ksize} \times 1\) matrix of Gaussian filter
+ coefficients:
+
+ \(G_i= \alpha *e^{-(i-( \texttt{ksize} -1)/2)^2/(2* \texttt{sigma}^2)},\)
+
+ where \(i=0..\texttt{ksize}-1\) and \(\alpha\) is the scale factor chosen so that \(\sum_i G_i=1\).
+
+ Two of such generated kernels can be passed to sepFilter2D. Those functions automatically recognize
+ smoothing kernels (a symmetrical kernel with sum of weights equal to 1) and handle them accordingly.
+ You may also use the higher-level GaussianBlur.
+
+
Parameters:
+
ksize - Aperture size. It should be odd ( \(\texttt{ksize} \mod 2 = 1\) ) and positive.
+
sigma - Gaussian standard deviation. If it is non-positive, it is computed from ksize as
+ sigma = 0.3*((ksize-1)*0.5 - 1) + 0.8.
+
ktype - Type of filter coefficients. It can be CV_32F or CV_64F .
+ SEE: sepFilter2D, getDerivKernels, getStructuringElement, GaussianBlur
public static Mat getPerspectiveTransform(Mat src,
+ Mat dst)
+
Calculates a perspective transform from four pairs of the corresponding points.
+
+ The function calculates the \(3 \times 3\) matrix of a perspective transform so that:
+
+ \(\begin{bmatrix} t_i x'_i \\ t_i y'_i \\ t_i \end{bmatrix} = \texttt{map_matrix} \cdot \begin{bmatrix} x_i \\ y_i \\ 1 \end{bmatrix}\)
+
+ where
+
+ \(dst(i)=(x'_i,y'_i), src(i)=(x_i, y_i), i=0,1,2,3\)
+
+
Parameters:
+
src - Coordinates of quadrangle vertices in the source image.
+
dst - Coordinates of the corresponding quadrangle vertices in the destination image.
+
+ SEE: findHomography, warpPerspective, perspectiveTransform
public static Mat getPerspectiveTransform(Mat src,
+ Mat dst,
+ int solveMethod)
+
Calculates a perspective transform from four pairs of the corresponding points.
+
+ The function calculates the \(3 \times 3\) matrix of a perspective transform so that:
+
+ \(\begin{bmatrix} t_i x'_i \\ t_i y'_i \\ t_i \end{bmatrix} = \texttt{map_matrix} \cdot \begin{bmatrix} x_i \\ y_i \\ 1 \end{bmatrix}\)
+
+ where
+
+ \(dst(i)=(x'_i,y'_i), src(i)=(x_i, y_i), i=0,1,2,3\)
+
+
Parameters:
+
src - Coordinates of quadrangle vertices in the source image.
+
dst - Coordinates of the corresponding quadrangle vertices in the destination image.
public static void getRectSubPix(Mat image,
+ Size patchSize,
+ Point center,
+ Mat patch)
+
Retrieves a pixel rectangle from an image with sub-pixel accuracy.
+
+ The function getRectSubPix extracts pixels from src:
+
+ \(patch(x, y) = src(x + \texttt{center.x} - ( \texttt{dst.cols} -1)*0.5, y + \texttt{center.y} - ( \texttt{dst.rows} -1)*0.5)\)
+
+ where the values of the pixels at non-integer coordinates are retrieved using bilinear
+ interpolation. Every channel of multi-channel images is processed independently. Also
+ the image should be a single channel or three channel image. While the center of the
+ rectangle must be inside the image, parts of the rectangle may be outside.
+
+
Parameters:
+
image - Source image.
+
patchSize - Size of the extracted patch.
+
center - Floating point coordinates of the center of the extracted rectangle within the
+ source image. The center must be inside the image.
+
patch - Extracted patch that has the size patchSize and the same number of channels as src .
+
+ SEE: warpAffine, warpPerspective
public static void getRectSubPix(Mat image,
+ Size patchSize,
+ Point center,
+ Mat patch,
+ int patchType)
+
Retrieves a pixel rectangle from an image with sub-pixel accuracy.
+
+ The function getRectSubPix extracts pixels from src:
+
+ \(patch(x, y) = src(x + \texttt{center.x} - ( \texttt{dst.cols} -1)*0.5, y + \texttt{center.y} - ( \texttt{dst.rows} -1)*0.5)\)
+
+ where the values of the pixels at non-integer coordinates are retrieved using bilinear
+ interpolation. Every channel of multi-channel images is processed independently. Also
+ the image should be a single channel or three channel image. While the center of the
+ rectangle must be inside the image, parts of the rectangle may be outside.
+
+
Parameters:
+
image - Source image.
+
patchSize - Size of the extracted patch.
+
center - Floating point coordinates of the center of the extracted rectangle within the
+ source image. The center must be inside the image.
+
patch - Extracted patch that has the size patchSize and the same number of channels as src .
+
patchType - Depth of the extracted pixels. By default, they have the same depth as src .
+
+ SEE: warpAffine, warpPerspective
public static Mat getStructuringElement(int shape,
+ Size ksize)
+
Returns a structuring element of the specified size and shape for morphological operations.
+
+ The function constructs and returns the structuring element that can be further passed to #erode,
+ #dilate or #morphologyEx. But you can also construct an arbitrary binary mask yourself and use it as
+ the structuring element.
+
+
Parameters:
+
shape - Element shape that could be one of #MorphShapes
+
ksize - Size of the structuring element.
+ anchor is at the center. Note that only the shape of a cross-shaped element depends on the anchor
+ position. In other cases the anchor just regulates how much the result of the morphological
+ operation is shifted.
public static Mat getStructuringElement(int shape,
+ Size ksize,
+ Point anchor)
+
Returns a structuring element of the specified size and shape for morphological operations.
+
+ The function constructs and returns the structuring element that can be further passed to #erode,
+ #dilate or #morphologyEx. But you can also construct an arbitrary binary mask yourself and use it as
+ the structuring element.
+
+
Parameters:
+
shape - Element shape that could be one of #MorphShapes
+
ksize - Size of the structuring element.
+
anchor - Anchor position within the element. The default value \((-1, -1)\) means that the
+ anchor is at the center. Note that only the shape of a cross-shaped element depends on the anchor
+ position. In other cases the anchor just regulates how much the result of the morphological
+ operation is shifted.
public static void goodFeaturesToTrack(Mat image,
+ MatOfPoint corners,
+ int maxCorners,
+ double qualityLevel,
+ double minDistance)
+
Determines strong corners on an image.
+
+ The function finds the most prominent corners in the image or in the specified image region, as
+ described in CITE: Shi94
+
+
+
+ Function calculates the corner quality measure at every source image pixel using the
+ #cornerMinEigenVal or #cornerHarris .
+
+
+ Function performs a non-maximum suppression (the local maximums in *3 x 3* neighborhood are
+ retained).
+
+
+ The corners with the minimal eigenvalue less than
+ \(\texttt{qualityLevel} \cdot \max_{x,y} qualityMeasureMap(x,y)\) are rejected.
+
+
+ The remaining corners are sorted by the quality measure in the descending order.
+
+
+ Function throws away each corner for which there is a stronger corner at a distance less than
+ maxDistance.
+
+
+
+ The function can be used to initialize a point-based tracker of an object.
+
+ Note: If the function is called with different values A and B of the parameter qualityLevel , and
+ A > B, the vector of returned corners with qualityLevel=A will be the prefix of the output vector
+ with qualityLevel=B .
+
+
Parameters:
+
image - Input 8-bit or floating-point 32-bit, single-channel image.
+
corners - Output vector of detected corners.
+
maxCorners - Maximum number of corners to return. If there are more corners than are found,
+ the strongest of them is returned. maxCorners <= 0 implies that no limit on the maximum is set
+ and all detected corners are returned.
+
qualityLevel - Parameter characterizing the minimal accepted quality of image corners. The
+ parameter value is multiplied by the best corner quality measure, which is the minimal eigenvalue
+ (see #cornerMinEigenVal ) or the Harris function response (see #cornerHarris ). The corners with the
+ quality measure less than the product are rejected. For example, if the best corner has the
+ quality measure = 1500, and the qualityLevel=0.01 , then all the corners with the quality measure
+ less than 15 are rejected.
+
minDistance - Minimum possible Euclidean distance between the returned corners.
+ CV_8UC1 and the same size as image ), it specifies the region in which the corners are detected.
+ pixel neighborhood. See cornerEigenValsAndVecs .
+ or #cornerMinEigenVal.
+
+ SEE: cornerMinEigenVal, cornerHarris, calcOpticalFlowPyrLK, estimateRigidTransform,
public static void goodFeaturesToTrack(Mat image,
+ MatOfPoint corners,
+ int maxCorners,
+ double qualityLevel,
+ double minDistance,
+ Mat mask)
+
Determines strong corners on an image.
+
+ The function finds the most prominent corners in the image or in the specified image region, as
+ described in CITE: Shi94
+
+
+
+ Function calculates the corner quality measure at every source image pixel using the
+ #cornerMinEigenVal or #cornerHarris .
+
+
+ Function performs a non-maximum suppression (the local maximums in *3 x 3* neighborhood are
+ retained).
+
+
+ The corners with the minimal eigenvalue less than
+ \(\texttt{qualityLevel} \cdot \max_{x,y} qualityMeasureMap(x,y)\) are rejected.
+
+
+ The remaining corners are sorted by the quality measure in the descending order.
+
+
+ Function throws away each corner for which there is a stronger corner at a distance less than
+ maxDistance.
+
+
+
+ The function can be used to initialize a point-based tracker of an object.
+
+ Note: If the function is called with different values A and B of the parameter qualityLevel , and
+ A > B, the vector of returned corners with qualityLevel=A will be the prefix of the output vector
+ with qualityLevel=B .
+
+
Parameters:
+
image - Input 8-bit or floating-point 32-bit, single-channel image.
+
corners - Output vector of detected corners.
+
maxCorners - Maximum number of corners to return. If there are more corners than are found,
+ the strongest of them is returned. maxCorners <= 0 implies that no limit on the maximum is set
+ and all detected corners are returned.
+
qualityLevel - Parameter characterizing the minimal accepted quality of image corners. The
+ parameter value is multiplied by the best corner quality measure, which is the minimal eigenvalue
+ (see #cornerMinEigenVal ) or the Harris function response (see #cornerHarris ). The corners with the
+ quality measure less than the product are rejected. For example, if the best corner has the
+ quality measure = 1500, and the qualityLevel=0.01 , then all the corners with the quality measure
+ less than 15 are rejected.
+
minDistance - Minimum possible Euclidean distance between the returned corners.
+
mask - Optional region of interest. If the image is not empty (it needs to have the type
+ CV_8UC1 and the same size as image ), it specifies the region in which the corners are detected.
+ pixel neighborhood. See cornerEigenValsAndVecs .
+ or #cornerMinEigenVal.
+
+ SEE: cornerMinEigenVal, cornerHarris, calcOpticalFlowPyrLK, estimateRigidTransform,
public static void goodFeaturesToTrack(Mat image,
+ MatOfPoint corners,
+ int maxCorners,
+ double qualityLevel,
+ double minDistance,
+ Mat mask,
+ int blockSize)
+
Determines strong corners on an image.
+
+ The function finds the most prominent corners in the image or in the specified image region, as
+ described in CITE: Shi94
+
+
+
+ Function calculates the corner quality measure at every source image pixel using the
+ #cornerMinEigenVal or #cornerHarris .
+
+
+ Function performs a non-maximum suppression (the local maximums in *3 x 3* neighborhood are
+ retained).
+
+
+ The corners with the minimal eigenvalue less than
+ \(\texttt{qualityLevel} \cdot \max_{x,y} qualityMeasureMap(x,y)\) are rejected.
+
+
+ The remaining corners are sorted by the quality measure in the descending order.
+
+
+ Function throws away each corner for which there is a stronger corner at a distance less than
+ maxDistance.
+
+
+
+ The function can be used to initialize a point-based tracker of an object.
+
+ Note: If the function is called with different values A and B of the parameter qualityLevel , and
+ A > B, the vector of returned corners with qualityLevel=A will be the prefix of the output vector
+ with qualityLevel=B .
+
+
Parameters:
+
image - Input 8-bit or floating-point 32-bit, single-channel image.
+
corners - Output vector of detected corners.
+
maxCorners - Maximum number of corners to return. If there are more corners than are found,
+ the strongest of them is returned. maxCorners <= 0 implies that no limit on the maximum is set
+ and all detected corners are returned.
+
qualityLevel - Parameter characterizing the minimal accepted quality of image corners. The
+ parameter value is multiplied by the best corner quality measure, which is the minimal eigenvalue
+ (see #cornerMinEigenVal ) or the Harris function response (see #cornerHarris ). The corners with the
+ quality measure less than the product are rejected. For example, if the best corner has the
+ quality measure = 1500, and the qualityLevel=0.01 , then all the corners with the quality measure
+ less than 15 are rejected.
+
minDistance - Minimum possible Euclidean distance between the returned corners.
+
mask - Optional region of interest. If the image is not empty (it needs to have the type
+ CV_8UC1 and the same size as image ), it specifies the region in which the corners are detected.
+
blockSize - Size of an average block for computing a derivative covariation matrix over each
+ pixel neighborhood. See cornerEigenValsAndVecs .
+ or #cornerMinEigenVal.
+
+ SEE: cornerMinEigenVal, cornerHarris, calcOpticalFlowPyrLK, estimateRigidTransform,
public static void goodFeaturesToTrack(Mat image,
+ MatOfPoint corners,
+ int maxCorners,
+ double qualityLevel,
+ double minDistance,
+ Mat mask,
+ int blockSize,
+ boolean useHarrisDetector)
+
Determines strong corners on an image.
+
+ The function finds the most prominent corners in the image or in the specified image region, as
+ described in CITE: Shi94
+
+
+
+ Function calculates the corner quality measure at every source image pixel using the
+ #cornerMinEigenVal or #cornerHarris .
+
+
+ Function performs a non-maximum suppression (the local maximums in *3 x 3* neighborhood are
+ retained).
+
+
+ The corners with the minimal eigenvalue less than
+ \(\texttt{qualityLevel} \cdot \max_{x,y} qualityMeasureMap(x,y)\) are rejected.
+
+
+ The remaining corners are sorted by the quality measure in the descending order.
+
+
+ Function throws away each corner for which there is a stronger corner at a distance less than
+ maxDistance.
+
+
+
+ The function can be used to initialize a point-based tracker of an object.
+
+ Note: If the function is called with different values A and B of the parameter qualityLevel , and
+ A > B, the vector of returned corners with qualityLevel=A will be the prefix of the output vector
+ with qualityLevel=B .
+
+
Parameters:
+
image - Input 8-bit or floating-point 32-bit, single-channel image.
+
corners - Output vector of detected corners.
+
maxCorners - Maximum number of corners to return. If there are more corners than are found,
+ the strongest of them is returned. maxCorners <= 0 implies that no limit on the maximum is set
+ and all detected corners are returned.
+
qualityLevel - Parameter characterizing the minimal accepted quality of image corners. The
+ parameter value is multiplied by the best corner quality measure, which is the minimal eigenvalue
+ (see #cornerMinEigenVal ) or the Harris function response (see #cornerHarris ). The corners with the
+ quality measure less than the product are rejected. For example, if the best corner has the
+ quality measure = 1500, and the qualityLevel=0.01 , then all the corners with the quality measure
+ less than 15 are rejected.
+
minDistance - Minimum possible Euclidean distance between the returned corners.
+
mask - Optional region of interest. If the image is not empty (it needs to have the type
+ CV_8UC1 and the same size as image ), it specifies the region in which the corners are detected.
+
blockSize - Size of an average block for computing a derivative covariation matrix over each
+ pixel neighborhood. See cornerEigenValsAndVecs .
+
useHarrisDetector - Parameter indicating whether to use a Harris detector (see #cornerHarris)
+ or #cornerMinEigenVal.
+
+ SEE: cornerMinEigenVal, cornerHarris, calcOpticalFlowPyrLK, estimateRigidTransform,
public static void goodFeaturesToTrack(Mat image,
+ MatOfPoint corners,
+ int maxCorners,
+ double qualityLevel,
+ double minDistance,
+ Mat mask,
+ int blockSize,
+ boolean useHarrisDetector,
+ double k)
+
Determines strong corners on an image.
+
+ The function finds the most prominent corners in the image or in the specified image region, as
+ described in CITE: Shi94
+
+
+
+ Function calculates the corner quality measure at every source image pixel using the
+ #cornerMinEigenVal or #cornerHarris .
+
+
+ Function performs a non-maximum suppression (the local maximums in *3 x 3* neighborhood are
+ retained).
+
+
+ The corners with the minimal eigenvalue less than
+ \(\texttt{qualityLevel} \cdot \max_{x,y} qualityMeasureMap(x,y)\) are rejected.
+
+
+ The remaining corners are sorted by the quality measure in the descending order.
+
+
+ Function throws away each corner for which there is a stronger corner at a distance less than
+ maxDistance.
+
+
+
+ The function can be used to initialize a point-based tracker of an object.
+
+ Note: If the function is called with different values A and B of the parameter qualityLevel , and
+ A > B, the vector of returned corners with qualityLevel=A will be the prefix of the output vector
+ with qualityLevel=B .
+
+
Parameters:
+
image - Input 8-bit or floating-point 32-bit, single-channel image.
+
corners - Output vector of detected corners.
+
maxCorners - Maximum number of corners to return. If there are more corners than are found,
+ the strongest of them is returned. maxCorners <= 0 implies that no limit on the maximum is set
+ and all detected corners are returned.
+
qualityLevel - Parameter characterizing the minimal accepted quality of image corners. The
+ parameter value is multiplied by the best corner quality measure, which is the minimal eigenvalue
+ (see #cornerMinEigenVal ) or the Harris function response (see #cornerHarris ). The corners with the
+ quality measure less than the product are rejected. For example, if the best corner has the
+ quality measure = 1500, and the qualityLevel=0.01 , then all the corners with the quality measure
+ less than 15 are rejected.
+
minDistance - Minimum possible Euclidean distance between the returned corners.
+
mask - Optional region of interest. If the image is not empty (it needs to have the type
+ CV_8UC1 and the same size as image ), it specifies the region in which the corners are detected.
+
blockSize - Size of an average block for computing a derivative covariation matrix over each
+ pixel neighborhood. See cornerEigenValsAndVecs .
+
useHarrisDetector - Parameter indicating whether to use a Harris detector (see #cornerHarris)
+ or #cornerMinEigenVal.
+
k - Free parameter of the Harris detector.
+
+ SEE: cornerMinEigenVal, cornerHarris, calcOpticalFlowPyrLK, estimateRigidTransform,
public static void goodFeaturesToTrackWithQuality(Mat image,
+ Mat corners,
+ int maxCorners,
+ double qualityLevel,
+ double minDistance,
+ Mat mask,
+ Mat cornersQuality)
+
Same as above, but returns also quality measure of the detected corners.
+
+
Parameters:
+
image - Input 8-bit or floating-point 32-bit, single-channel image.
+
corners - Output vector of detected corners.
+
maxCorners - Maximum number of corners to return. If there are more corners than are found,
+ the strongest of them is returned. maxCorners <= 0 implies that no limit on the maximum is set
+ and all detected corners are returned.
+
qualityLevel - Parameter characterizing the minimal accepted quality of image corners. The
+ parameter value is multiplied by the best corner quality measure, which is the minimal eigenvalue
+ (see #cornerMinEigenVal ) or the Harris function response (see #cornerHarris ). The corners with the
+ quality measure less than the product are rejected. For example, if the best corner has the
+ quality measure = 1500, and the qualityLevel=0.01 , then all the corners with the quality measure
+ less than 15 are rejected.
+
minDistance - Minimum possible Euclidean distance between the returned corners.
+
mask - Region of interest. If the image is not empty (it needs to have the type
+ CV_8UC1 and the same size as image ), it specifies the region in which the corners are detected.
+
cornersQuality - Output vector of quality measure of the detected corners.
+ pixel neighborhood. See cornerEigenValsAndVecs .
+ See cornerEigenValsAndVecs .
+ or #cornerMinEigenVal.
public static void goodFeaturesToTrackWithQuality(Mat image,
+ Mat corners,
+ int maxCorners,
+ double qualityLevel,
+ double minDistance,
+ Mat mask,
+ Mat cornersQuality,
+ int blockSize)
+
Same as above, but returns also quality measure of the detected corners.
+
+
Parameters:
+
image - Input 8-bit or floating-point 32-bit, single-channel image.
+
corners - Output vector of detected corners.
+
maxCorners - Maximum number of corners to return. If there are more corners than are found,
+ the strongest of them is returned. maxCorners <= 0 implies that no limit on the maximum is set
+ and all detected corners are returned.
+
qualityLevel - Parameter characterizing the minimal accepted quality of image corners. The
+ parameter value is multiplied by the best corner quality measure, which is the minimal eigenvalue
+ (see #cornerMinEigenVal ) or the Harris function response (see #cornerHarris ). The corners with the
+ quality measure less than the product are rejected. For example, if the best corner has the
+ quality measure = 1500, and the qualityLevel=0.01 , then all the corners with the quality measure
+ less than 15 are rejected.
+
minDistance - Minimum possible Euclidean distance between the returned corners.
+
mask - Region of interest. If the image is not empty (it needs to have the type
+ CV_8UC1 and the same size as image ), it specifies the region in which the corners are detected.
+
cornersQuality - Output vector of quality measure of the detected corners.
+
blockSize - Size of an average block for computing a derivative covariation matrix over each
+ pixel neighborhood. See cornerEigenValsAndVecs .
+ See cornerEigenValsAndVecs .
+ or #cornerMinEigenVal.
public static void goodFeaturesToTrackWithQuality(Mat image,
+ Mat corners,
+ int maxCorners,
+ double qualityLevel,
+ double minDistance,
+ Mat mask,
+ Mat cornersQuality,
+ int blockSize,
+ int gradientSize)
+
Same as above, but returns also quality measure of the detected corners.
+
+
Parameters:
+
image - Input 8-bit or floating-point 32-bit, single-channel image.
+
corners - Output vector of detected corners.
+
maxCorners - Maximum number of corners to return. If there are more corners than are found,
+ the strongest of them is returned. maxCorners <= 0 implies that no limit on the maximum is set
+ and all detected corners are returned.
+
qualityLevel - Parameter characterizing the minimal accepted quality of image corners. The
+ parameter value is multiplied by the best corner quality measure, which is the minimal eigenvalue
+ (see #cornerMinEigenVal ) or the Harris function response (see #cornerHarris ). The corners with the
+ quality measure less than the product are rejected. For example, if the best corner has the
+ quality measure = 1500, and the qualityLevel=0.01 , then all the corners with the quality measure
+ less than 15 are rejected.
+
minDistance - Minimum possible Euclidean distance between the returned corners.
+
mask - Region of interest. If the image is not empty (it needs to have the type
+ CV_8UC1 and the same size as image ), it specifies the region in which the corners are detected.
+
cornersQuality - Output vector of quality measure of the detected corners.
+
blockSize - Size of an average block for computing a derivative covariation matrix over each
+ pixel neighborhood. See cornerEigenValsAndVecs .
+
gradientSize - Aperture parameter for the Sobel operator used for derivatives computation.
+ See cornerEigenValsAndVecs .
+ or #cornerMinEigenVal.
public static void goodFeaturesToTrackWithQuality(Mat image,
+ Mat corners,
+ int maxCorners,
+ double qualityLevel,
+ double minDistance,
+ Mat mask,
+ Mat cornersQuality,
+ int blockSize,
+ int gradientSize,
+ boolean useHarrisDetector)
+
Same as above, but returns also quality measure of the detected corners.
+
+
Parameters:
+
image - Input 8-bit or floating-point 32-bit, single-channel image.
+
corners - Output vector of detected corners.
+
maxCorners - Maximum number of corners to return. If there are more corners than are found,
+ the strongest of them is returned. maxCorners <= 0 implies that no limit on the maximum is set
+ and all detected corners are returned.
+
qualityLevel - Parameter characterizing the minimal accepted quality of image corners. The
+ parameter value is multiplied by the best corner quality measure, which is the minimal eigenvalue
+ (see #cornerMinEigenVal ) or the Harris function response (see #cornerHarris ). The corners with the
+ quality measure less than the product are rejected. For example, if the best corner has the
+ quality measure = 1500, and the qualityLevel=0.01 , then all the corners with the quality measure
+ less than 15 are rejected.
+
minDistance - Minimum possible Euclidean distance between the returned corners.
+
mask - Region of interest. If the image is not empty (it needs to have the type
+ CV_8UC1 and the same size as image ), it specifies the region in which the corners are detected.
+
cornersQuality - Output vector of quality measure of the detected corners.
+
blockSize - Size of an average block for computing a derivative covariation matrix over each
+ pixel neighborhood. See cornerEigenValsAndVecs .
+
gradientSize - Aperture parameter for the Sobel operator used for derivatives computation.
+ See cornerEigenValsAndVecs .
+
useHarrisDetector - Parameter indicating whether to use a Harris detector (see #cornerHarris)
+ or #cornerMinEigenVal.
public static void goodFeaturesToTrackWithQuality(Mat image,
+ Mat corners,
+ int maxCorners,
+ double qualityLevel,
+ double minDistance,
+ Mat mask,
+ Mat cornersQuality,
+ int blockSize,
+ int gradientSize,
+ boolean useHarrisDetector,
+ double k)
+
Same as above, but returns also quality measure of the detected corners.
+
+
Parameters:
+
image - Input 8-bit or floating-point 32-bit, single-channel image.
+
corners - Output vector of detected corners.
+
maxCorners - Maximum number of corners to return. If there are more corners than are found,
+ the strongest of them is returned. maxCorners <= 0 implies that no limit on the maximum is set
+ and all detected corners are returned.
+
qualityLevel - Parameter characterizing the minimal accepted quality of image corners. The
+ parameter value is multiplied by the best corner quality measure, which is the minimal eigenvalue
+ (see #cornerMinEigenVal ) or the Harris function response (see #cornerHarris ). The corners with the
+ quality measure less than the product are rejected. For example, if the best corner has the
+ quality measure = 1500, and the qualityLevel=0.01 , then all the corners with the quality measure
+ less than 15 are rejected.
+
minDistance - Minimum possible Euclidean distance between the returned corners.
+
mask - Region of interest. If the image is not empty (it needs to have the type
+ CV_8UC1 and the same size as image ), it specifies the region in which the corners are detected.
+
cornersQuality - Output vector of quality measure of the detected corners.
+
blockSize - Size of an average block for computing a derivative covariation matrix over each
+ pixel neighborhood. See cornerEigenValsAndVecs .
+
gradientSize - Aperture parameter for the Sobel operator used for derivatives computation.
+ See cornerEigenValsAndVecs .
+
useHarrisDetector - Parameter indicating whether to use a Harris detector (see #cornerHarris)
+ or #cornerMinEigenVal.
public static void grabCut(Mat img,
+ Mat mask,
+ Rect rect,
+ Mat bgdModel,
+ Mat fgdModel,
+ int iterCount)
+
Runs the GrabCut algorithm.
+
+ The function implements the [GrabCut image segmentation algorithm](http://en.wikipedia.org/wiki/GrabCut).
+
+
Parameters:
+
img - Input 8-bit 3-channel image.
+
mask - Input/output 8-bit single-channel mask. The mask is initialized by the function when
+ mode is set to #GC_INIT_WITH_RECT. Its elements may have one of the #GrabCutClasses.
+
rect - ROI containing a segmented object. The pixels outside of the ROI are marked as
+ "obvious background". The parameter is only used when mode==#GC_INIT_WITH_RECT .
+
bgdModel - Temporary array for the background model. Do not modify it while you are
+ processing the same image.
+
fgdModel - Temporary arrays for the foreground model. Do not modify it while you are
+ processing the same image.
+
iterCount - Number of iterations the algorithm should make before returning the result. Note
+ that the result can be refined with further calls with mode==#GC_INIT_WITH_MASK or
+ mode==GC_EVAL .
public static void grabCut(Mat img,
+ Mat mask,
+ Rect rect,
+ Mat bgdModel,
+ Mat fgdModel,
+ int iterCount,
+ int mode)
+
Runs the GrabCut algorithm.
+
+ The function implements the [GrabCut image segmentation algorithm](http://en.wikipedia.org/wiki/GrabCut).
+
+
Parameters:
+
img - Input 8-bit 3-channel image.
+
mask - Input/output 8-bit single-channel mask. The mask is initialized by the function when
+ mode is set to #GC_INIT_WITH_RECT. Its elements may have one of the #GrabCutClasses.
+
rect - ROI containing a segmented object. The pixels outside of the ROI are marked as
+ "obvious background". The parameter is only used when mode==#GC_INIT_WITH_RECT .
+
bgdModel - Temporary array for the background model. Do not modify it while you are
+ processing the same image.
+
fgdModel - Temporary arrays for the foreground model. Do not modify it while you are
+ processing the same image.
+
iterCount - Number of iterations the algorithm should make before returning the result. Note
+ that the result can be refined with further calls with mode==#GC_INIT_WITH_MASK or
+ mode==GC_EVAL .
+
mode - Operation mode that could be one of the #GrabCutModes
public static void HoughCircles(Mat image,
+ Mat circles,
+ int method,
+ double dp,
+ double minDist)
+
Finds circles in a grayscale image using the Hough transform.
+
+ The function finds circles in a grayscale image using a modification of the Hough transform.
+
+ Example: :
+ INCLUDE: snippets/imgproc_HoughLinesCircles.cpp
+
+ Note: Usually the function detects the centers of circles well. However, it may fail to find correct
+ radii. You can assist to the function by specifying the radius range ( minRadius and maxRadius ) if
+ you know it. Or, in the case of #HOUGH_GRADIENT method you may set maxRadius to a negative number
+ to return centers only without radius search, and find the correct radius using an additional procedure.
+
+ It also helps to smooth image a bit unless it's already soft. For example,
+ GaussianBlur() with 7x7 kernel and 1.5x1.5 sigma or similar blurring may help.
circles - Output vector of found circles. Each vector is encoded as 3 or 4 element
+ floating-point vector \((x, y, radius)\) or \((x, y, radius, votes)\) .
+
method - Detection method, see #HoughModes. The available methods are #HOUGH_GRADIENT and #HOUGH_GRADIENT_ALT.
+
dp - Inverse ratio of the accumulator resolution to the image resolution. For example, if
+ dp=1 , the accumulator has the same resolution as the input image. If dp=2 , the accumulator has
+ half as big width and height. For #HOUGH_GRADIENT_ALT the recommended value is dp=1.5,
+ unless some small very circles need to be detected.
+
minDist - Minimum distance between the centers of the detected circles. If the parameter is
+ too small, multiple neighbor circles may be falsely detected in addition to a true one. If it is
+ too large, some circles may be missed.
+ it is the higher threshold of the two passed to the Canny edge detector (the lower one is twice smaller).
+ Note that #HOUGH_GRADIENT_ALT uses #Scharr algorithm to compute image derivatives, so the threshold value
+ shough normally be higher, such as 300 or normally exposed and contrasty images.
+ accumulator threshold for the circle centers at the detection stage. The smaller it is, the more
+ false circles may be detected. Circles, corresponding to the larger accumulator values, will be
+ returned first. In the case of #HOUGH_GRADIENT_ALT algorithm, this is the circle "perfectness" measure.
+ The closer it to 1, the better shaped circles algorithm selects. In most cases 0.9 should be fine.
+ If you want get better detection of small circles, you may decrease it to 0.85, 0.8 or even less.
+ But then also try to limit the search range [minRadius, maxRadius] to avoid many false circles.
+ centers without finding the radius. #HOUGH_GRADIENT_ALT always computes circle radiuses.
+
+ SEE: fitEllipse, minEnclosingCircle
public static void HoughCircles(Mat image,
+ Mat circles,
+ int method,
+ double dp,
+ double minDist,
+ double param1)
+
Finds circles in a grayscale image using the Hough transform.
+
+ The function finds circles in a grayscale image using a modification of the Hough transform.
+
+ Example: :
+ INCLUDE: snippets/imgproc_HoughLinesCircles.cpp
+
+ Note: Usually the function detects the centers of circles well. However, it may fail to find correct
+ radii. You can assist to the function by specifying the radius range ( minRadius and maxRadius ) if
+ you know it. Or, in the case of #HOUGH_GRADIENT method you may set maxRadius to a negative number
+ to return centers only without radius search, and find the correct radius using an additional procedure.
+
+ It also helps to smooth image a bit unless it's already soft. For example,
+ GaussianBlur() with 7x7 kernel and 1.5x1.5 sigma or similar blurring may help.
circles - Output vector of found circles. Each vector is encoded as 3 or 4 element
+ floating-point vector \((x, y, radius)\) or \((x, y, radius, votes)\) .
+
method - Detection method, see #HoughModes. The available methods are #HOUGH_GRADIENT and #HOUGH_GRADIENT_ALT.
+
dp - Inverse ratio of the accumulator resolution to the image resolution. For example, if
+ dp=1 , the accumulator has the same resolution as the input image. If dp=2 , the accumulator has
+ half as big width and height. For #HOUGH_GRADIENT_ALT the recommended value is dp=1.5,
+ unless some small very circles need to be detected.
+
minDist - Minimum distance between the centers of the detected circles. If the parameter is
+ too small, multiple neighbor circles may be falsely detected in addition to a true one. If it is
+ too large, some circles may be missed.
+
param1 - First method-specific parameter. In case of #HOUGH_GRADIENT and #HOUGH_GRADIENT_ALT,
+ it is the higher threshold of the two passed to the Canny edge detector (the lower one is twice smaller).
+ Note that #HOUGH_GRADIENT_ALT uses #Scharr algorithm to compute image derivatives, so the threshold value
+ shough normally be higher, such as 300 or normally exposed and contrasty images.
+ accumulator threshold for the circle centers at the detection stage. The smaller it is, the more
+ false circles may be detected. Circles, corresponding to the larger accumulator values, will be
+ returned first. In the case of #HOUGH_GRADIENT_ALT algorithm, this is the circle "perfectness" measure.
+ The closer it to 1, the better shaped circles algorithm selects. In most cases 0.9 should be fine.
+ If you want get better detection of small circles, you may decrease it to 0.85, 0.8 or even less.
+ But then also try to limit the search range [minRadius, maxRadius] to avoid many false circles.
+ centers without finding the radius. #HOUGH_GRADIENT_ALT always computes circle radiuses.
+
+ SEE: fitEllipse, minEnclosingCircle
public static void HoughCircles(Mat image,
+ Mat circles,
+ int method,
+ double dp,
+ double minDist,
+ double param1,
+ double param2)
+
Finds circles in a grayscale image using the Hough transform.
+
+ The function finds circles in a grayscale image using a modification of the Hough transform.
+
+ Example: :
+ INCLUDE: snippets/imgproc_HoughLinesCircles.cpp
+
+ Note: Usually the function detects the centers of circles well. However, it may fail to find correct
+ radii. You can assist to the function by specifying the radius range ( minRadius and maxRadius ) if
+ you know it. Or, in the case of #HOUGH_GRADIENT method you may set maxRadius to a negative number
+ to return centers only without radius search, and find the correct radius using an additional procedure.
+
+ It also helps to smooth image a bit unless it's already soft. For example,
+ GaussianBlur() with 7x7 kernel and 1.5x1.5 sigma or similar blurring may help.
circles - Output vector of found circles. Each vector is encoded as 3 or 4 element
+ floating-point vector \((x, y, radius)\) or \((x, y, radius, votes)\) .
+
method - Detection method, see #HoughModes. The available methods are #HOUGH_GRADIENT and #HOUGH_GRADIENT_ALT.
+
dp - Inverse ratio of the accumulator resolution to the image resolution. For example, if
+ dp=1 , the accumulator has the same resolution as the input image. If dp=2 , the accumulator has
+ half as big width and height. For #HOUGH_GRADIENT_ALT the recommended value is dp=1.5,
+ unless some small very circles need to be detected.
+
minDist - Minimum distance between the centers of the detected circles. If the parameter is
+ too small, multiple neighbor circles may be falsely detected in addition to a true one. If it is
+ too large, some circles may be missed.
+
param1 - First method-specific parameter. In case of #HOUGH_GRADIENT and #HOUGH_GRADIENT_ALT,
+ it is the higher threshold of the two passed to the Canny edge detector (the lower one is twice smaller).
+ Note that #HOUGH_GRADIENT_ALT uses #Scharr algorithm to compute image derivatives, so the threshold value
+ shough normally be higher, such as 300 or normally exposed and contrasty images.
+
param2 - Second method-specific parameter. In case of #HOUGH_GRADIENT, it is the
+ accumulator threshold for the circle centers at the detection stage. The smaller it is, the more
+ false circles may be detected. Circles, corresponding to the larger accumulator values, will be
+ returned first. In the case of #HOUGH_GRADIENT_ALT algorithm, this is the circle "perfectness" measure.
+ The closer it to 1, the better shaped circles algorithm selects. In most cases 0.9 should be fine.
+ If you want get better detection of small circles, you may decrease it to 0.85, 0.8 or even less.
+ But then also try to limit the search range [minRadius, maxRadius] to avoid many false circles.
+ centers without finding the radius. #HOUGH_GRADIENT_ALT always computes circle radiuses.
+
+ SEE: fitEllipse, minEnclosingCircle
public static void HoughCircles(Mat image,
+ Mat circles,
+ int method,
+ double dp,
+ double minDist,
+ double param1,
+ double param2,
+ int minRadius)
+
Finds circles in a grayscale image using the Hough transform.
+
+ The function finds circles in a grayscale image using a modification of the Hough transform.
+
+ Example: :
+ INCLUDE: snippets/imgproc_HoughLinesCircles.cpp
+
+ Note: Usually the function detects the centers of circles well. However, it may fail to find correct
+ radii. You can assist to the function by specifying the radius range ( minRadius and maxRadius ) if
+ you know it. Or, in the case of #HOUGH_GRADIENT method you may set maxRadius to a negative number
+ to return centers only without radius search, and find the correct radius using an additional procedure.
+
+ It also helps to smooth image a bit unless it's already soft. For example,
+ GaussianBlur() with 7x7 kernel and 1.5x1.5 sigma or similar blurring may help.
circles - Output vector of found circles. Each vector is encoded as 3 or 4 element
+ floating-point vector \((x, y, radius)\) or \((x, y, radius, votes)\) .
+
method - Detection method, see #HoughModes. The available methods are #HOUGH_GRADIENT and #HOUGH_GRADIENT_ALT.
+
dp - Inverse ratio of the accumulator resolution to the image resolution. For example, if
+ dp=1 , the accumulator has the same resolution as the input image. If dp=2 , the accumulator has
+ half as big width and height. For #HOUGH_GRADIENT_ALT the recommended value is dp=1.5,
+ unless some small very circles need to be detected.
+
minDist - Minimum distance between the centers of the detected circles. If the parameter is
+ too small, multiple neighbor circles may be falsely detected in addition to a true one. If it is
+ too large, some circles may be missed.
+
param1 - First method-specific parameter. In case of #HOUGH_GRADIENT and #HOUGH_GRADIENT_ALT,
+ it is the higher threshold of the two passed to the Canny edge detector (the lower one is twice smaller).
+ Note that #HOUGH_GRADIENT_ALT uses #Scharr algorithm to compute image derivatives, so the threshold value
+ shough normally be higher, such as 300 or normally exposed and contrasty images.
+
param2 - Second method-specific parameter. In case of #HOUGH_GRADIENT, it is the
+ accumulator threshold for the circle centers at the detection stage. The smaller it is, the more
+ false circles may be detected. Circles, corresponding to the larger accumulator values, will be
+ returned first. In the case of #HOUGH_GRADIENT_ALT algorithm, this is the circle "perfectness" measure.
+ The closer it to 1, the better shaped circles algorithm selects. In most cases 0.9 should be fine.
+ If you want get better detection of small circles, you may decrease it to 0.85, 0.8 or even less.
+ But then also try to limit the search range [minRadius, maxRadius] to avoid many false circles.
+
minRadius - Minimum circle radius.
+ centers without finding the radius. #HOUGH_GRADIENT_ALT always computes circle radiuses.
+
+ SEE: fitEllipse, minEnclosingCircle
public static void HoughCircles(Mat image,
+ Mat circles,
+ int method,
+ double dp,
+ double minDist,
+ double param1,
+ double param2,
+ int minRadius,
+ int maxRadius)
+
Finds circles in a grayscale image using the Hough transform.
+
+ The function finds circles in a grayscale image using a modification of the Hough transform.
+
+ Example: :
+ INCLUDE: snippets/imgproc_HoughLinesCircles.cpp
+
+ Note: Usually the function detects the centers of circles well. However, it may fail to find correct
+ radii. You can assist to the function by specifying the radius range ( minRadius and maxRadius ) if
+ you know it. Or, in the case of #HOUGH_GRADIENT method you may set maxRadius to a negative number
+ to return centers only without radius search, and find the correct radius using an additional procedure.
+
+ It also helps to smooth image a bit unless it's already soft. For example,
+ GaussianBlur() with 7x7 kernel and 1.5x1.5 sigma or similar blurring may help.
circles - Output vector of found circles. Each vector is encoded as 3 or 4 element
+ floating-point vector \((x, y, radius)\) or \((x, y, radius, votes)\) .
+
method - Detection method, see #HoughModes. The available methods are #HOUGH_GRADIENT and #HOUGH_GRADIENT_ALT.
+
dp - Inverse ratio of the accumulator resolution to the image resolution. For example, if
+ dp=1 , the accumulator has the same resolution as the input image. If dp=2 , the accumulator has
+ half as big width and height. For #HOUGH_GRADIENT_ALT the recommended value is dp=1.5,
+ unless some small very circles need to be detected.
+
minDist - Minimum distance between the centers of the detected circles. If the parameter is
+ too small, multiple neighbor circles may be falsely detected in addition to a true one. If it is
+ too large, some circles may be missed.
+
param1 - First method-specific parameter. In case of #HOUGH_GRADIENT and #HOUGH_GRADIENT_ALT,
+ it is the higher threshold of the two passed to the Canny edge detector (the lower one is twice smaller).
+ Note that #HOUGH_GRADIENT_ALT uses #Scharr algorithm to compute image derivatives, so the threshold value
+ shough normally be higher, such as 300 or normally exposed and contrasty images.
+
param2 - Second method-specific parameter. In case of #HOUGH_GRADIENT, it is the
+ accumulator threshold for the circle centers at the detection stage. The smaller it is, the more
+ false circles may be detected. Circles, corresponding to the larger accumulator values, will be
+ returned first. In the case of #HOUGH_GRADIENT_ALT algorithm, this is the circle "perfectness" measure.
+ The closer it to 1, the better shaped circles algorithm selects. In most cases 0.9 should be fine.
+ If you want get better detection of small circles, you may decrease it to 0.85, 0.8 or even less.
+ But then also try to limit the search range [minRadius, maxRadius] to avoid many false circles.
+
minRadius - Minimum circle radius.
+
maxRadius - Maximum circle radius. If <= 0, uses the maximum image dimension. If < 0, #HOUGH_GRADIENT returns
+ centers without finding the radius. #HOUGH_GRADIENT_ALT always computes circle radiuses.
+
+ SEE: fitEllipse, minEnclosingCircle
public static void HoughLines(Mat image,
+ Mat lines,
+ double rho,
+ double theta,
+ int threshold)
+
Finds lines in a binary image using the standard Hough transform.
+
+ The function implements the standard or standard multi-scale Hough transform algorithm for line
+ detection. See <http://homepages.inf.ed.ac.uk/rbf/HIPR2/hough.htm> for a good explanation of Hough
+ transform.
+
+
Parameters:
+
image - 8-bit, single-channel binary source image. The image may be modified by the function.
+
lines - Output vector of lines. Each line is represented by a 2 or 3 element vector
+ \((\rho, \theta)\) or \((\rho, \theta, \textrm{votes})\), where \(\rho\) is the distance from
+ the coordinate origin \((0,0)\) (top-left corner of the image), \(\theta\) is the line rotation
+ angle in radians ( \(0 \sim \textrm{vertical line}, \pi/2 \sim \textrm{horizontal line}\) ), and
+ \(\textrm{votes}\) is the value of accumulator.
+
rho - Distance resolution of the accumulator in pixels.
+
theta - Angle resolution of the accumulator in radians.
+
threshold - %Accumulator threshold parameter. Only those lines are returned that get enough
+ votes ( \(>\texttt{threshold}\) ).
+ The coarse accumulator distance resolution is rho and the accurate accumulator resolution is
+ rho/srn. If both srn=0 and stn=0, the classical Hough transform is used. Otherwise, both these
+ parameters should be positive.
+ Must fall between 0 and max_theta.
+ Must fall between min_theta and CV_PI. The actual maximum angle in the accumulator may be slightly
+ less than max_theta, depending on the parameters min_theta and theta.
public static void HoughLines(Mat image,
+ Mat lines,
+ double rho,
+ double theta,
+ int threshold,
+ double srn)
+
Finds lines in a binary image using the standard Hough transform.
+
+ The function implements the standard or standard multi-scale Hough transform algorithm for line
+ detection. See <http://homepages.inf.ed.ac.uk/rbf/HIPR2/hough.htm> for a good explanation of Hough
+ transform.
+
+
Parameters:
+
image - 8-bit, single-channel binary source image. The image may be modified by the function.
+
lines - Output vector of lines. Each line is represented by a 2 or 3 element vector
+ \((\rho, \theta)\) or \((\rho, \theta, \textrm{votes})\), where \(\rho\) is the distance from
+ the coordinate origin \((0,0)\) (top-left corner of the image), \(\theta\) is the line rotation
+ angle in radians ( \(0 \sim \textrm{vertical line}, \pi/2 \sim \textrm{horizontal line}\) ), and
+ \(\textrm{votes}\) is the value of accumulator.
+
rho - Distance resolution of the accumulator in pixels.
+
theta - Angle resolution of the accumulator in radians.
+
threshold - %Accumulator threshold parameter. Only those lines are returned that get enough
+ votes ( \(>\texttt{threshold}\) ).
+
srn - For the multi-scale Hough transform, it is a divisor for the distance resolution rho.
+ The coarse accumulator distance resolution is rho and the accurate accumulator resolution is
+ rho/srn. If both srn=0 and stn=0, the classical Hough transform is used. Otherwise, both these
+ parameters should be positive.
+ Must fall between 0 and max_theta.
+ Must fall between min_theta and CV_PI. The actual maximum angle in the accumulator may be slightly
+ less than max_theta, depending on the parameters min_theta and theta.
public static void HoughLines(Mat image,
+ Mat lines,
+ double rho,
+ double theta,
+ int threshold,
+ double srn,
+ double stn)
+
Finds lines in a binary image using the standard Hough transform.
+
+ The function implements the standard or standard multi-scale Hough transform algorithm for line
+ detection. See <http://homepages.inf.ed.ac.uk/rbf/HIPR2/hough.htm> for a good explanation of Hough
+ transform.
+
+
Parameters:
+
image - 8-bit, single-channel binary source image. The image may be modified by the function.
+
lines - Output vector of lines. Each line is represented by a 2 or 3 element vector
+ \((\rho, \theta)\) or \((\rho, \theta, \textrm{votes})\), where \(\rho\) is the distance from
+ the coordinate origin \((0,0)\) (top-left corner of the image), \(\theta\) is the line rotation
+ angle in radians ( \(0 \sim \textrm{vertical line}, \pi/2 \sim \textrm{horizontal line}\) ), and
+ \(\textrm{votes}\) is the value of accumulator.
+
rho - Distance resolution of the accumulator in pixels.
+
theta - Angle resolution of the accumulator in radians.
+
threshold - %Accumulator threshold parameter. Only those lines are returned that get enough
+ votes ( \(>\texttt{threshold}\) ).
+
srn - For the multi-scale Hough transform, it is a divisor for the distance resolution rho.
+ The coarse accumulator distance resolution is rho and the accurate accumulator resolution is
+ rho/srn. If both srn=0 and stn=0, the classical Hough transform is used. Otherwise, both these
+ parameters should be positive.
+
stn - For the multi-scale Hough transform, it is a divisor for the distance resolution theta.
+ Must fall between 0 and max_theta.
+ Must fall between min_theta and CV_PI. The actual maximum angle in the accumulator may be slightly
+ less than max_theta, depending on the parameters min_theta and theta.
public static void HoughLines(Mat image,
+ Mat lines,
+ double rho,
+ double theta,
+ int threshold,
+ double srn,
+ double stn,
+ double min_theta)
+
Finds lines in a binary image using the standard Hough transform.
+
+ The function implements the standard or standard multi-scale Hough transform algorithm for line
+ detection. See <http://homepages.inf.ed.ac.uk/rbf/HIPR2/hough.htm> for a good explanation of Hough
+ transform.
+
+
Parameters:
+
image - 8-bit, single-channel binary source image. The image may be modified by the function.
+
lines - Output vector of lines. Each line is represented by a 2 or 3 element vector
+ \((\rho, \theta)\) or \((\rho, \theta, \textrm{votes})\), where \(\rho\) is the distance from
+ the coordinate origin \((0,0)\) (top-left corner of the image), \(\theta\) is the line rotation
+ angle in radians ( \(0 \sim \textrm{vertical line}, \pi/2 \sim \textrm{horizontal line}\) ), and
+ \(\textrm{votes}\) is the value of accumulator.
+
rho - Distance resolution of the accumulator in pixels.
+
theta - Angle resolution of the accumulator in radians.
+
threshold - %Accumulator threshold parameter. Only those lines are returned that get enough
+ votes ( \(>\texttt{threshold}\) ).
+
srn - For the multi-scale Hough transform, it is a divisor for the distance resolution rho.
+ The coarse accumulator distance resolution is rho and the accurate accumulator resolution is
+ rho/srn. If both srn=0 and stn=0, the classical Hough transform is used. Otherwise, both these
+ parameters should be positive.
+
stn - For the multi-scale Hough transform, it is a divisor for the distance resolution theta.
+
min_theta - For standard and multi-scale Hough transform, minimum angle to check for lines.
+ Must fall between 0 and max_theta.
+ Must fall between min_theta and CV_PI. The actual maximum angle in the accumulator may be slightly
+ less than max_theta, depending on the parameters min_theta and theta.
public static void HoughLines(Mat image,
+ Mat lines,
+ double rho,
+ double theta,
+ int threshold,
+ double srn,
+ double stn,
+ double min_theta,
+ double max_theta)
+
Finds lines in a binary image using the standard Hough transform.
+
+ The function implements the standard or standard multi-scale Hough transform algorithm for line
+ detection. See <http://homepages.inf.ed.ac.uk/rbf/HIPR2/hough.htm> for a good explanation of Hough
+ transform.
+
+
Parameters:
+
image - 8-bit, single-channel binary source image. The image may be modified by the function.
+
lines - Output vector of lines. Each line is represented by a 2 or 3 element vector
+ \((\rho, \theta)\) or \((\rho, \theta, \textrm{votes})\), where \(\rho\) is the distance from
+ the coordinate origin \((0,0)\) (top-left corner of the image), \(\theta\) is the line rotation
+ angle in radians ( \(0 \sim \textrm{vertical line}, \pi/2 \sim \textrm{horizontal line}\) ), and
+ \(\textrm{votes}\) is the value of accumulator.
+
rho - Distance resolution of the accumulator in pixels.
+
theta - Angle resolution of the accumulator in radians.
+
threshold - %Accumulator threshold parameter. Only those lines are returned that get enough
+ votes ( \(>\texttt{threshold}\) ).
+
srn - For the multi-scale Hough transform, it is a divisor for the distance resolution rho.
+ The coarse accumulator distance resolution is rho and the accurate accumulator resolution is
+ rho/srn. If both srn=0 and stn=0, the classical Hough transform is used. Otherwise, both these
+ parameters should be positive.
+
stn - For the multi-scale Hough transform, it is a divisor for the distance resolution theta.
+
min_theta - For standard and multi-scale Hough transform, minimum angle to check for lines.
+ Must fall between 0 and max_theta.
+
max_theta - For standard and multi-scale Hough transform, an upper bound for the angle.
+ Must fall between min_theta and CV_PI. The actual maximum angle in the accumulator may be slightly
+ less than max_theta, depending on the parameters min_theta and theta.
public static void HoughLinesP(Mat image,
+ Mat lines,
+ double rho,
+ double theta,
+ int threshold)
+
Finds line segments in a binary image using the probabilistic Hough transform.
+
+ The function implements the probabilistic Hough transform algorithm for line detection, described
+ in CITE: Matas00
+
+ See the line detection example below:
+ INCLUDE: snippets/imgproc_HoughLinesP.cpp
+ This is a sample picture the function parameters have been tuned for:
+
+ 
+
+ And this is the output of the above program in case of the probabilistic Hough transform:
+
+ 
+
+
Parameters:
+
image - 8-bit, single-channel binary source image. The image may be modified by the function.
+
lines - Output vector of lines. Each line is represented by a 4-element vector
+ \((x_1, y_1, x_2, y_2)\) , where \((x_1,y_1)\) and \((x_2, y_2)\) are the ending points of each detected
+ line segment.
+
rho - Distance resolution of the accumulator in pixels.
+
theta - Angle resolution of the accumulator in radians.
+
threshold - %Accumulator threshold parameter. Only those lines are returned that get enough
+ votes ( \(>\texttt{threshold}\) ).
+
+ SEE: LineSegmentDetector
public static void HoughLinesP(Mat image,
+ Mat lines,
+ double rho,
+ double theta,
+ int threshold,
+ double minLineLength)
+
Finds line segments in a binary image using the probabilistic Hough transform.
+
+ The function implements the probabilistic Hough transform algorithm for line detection, described
+ in CITE: Matas00
+
+ See the line detection example below:
+ INCLUDE: snippets/imgproc_HoughLinesP.cpp
+ This is a sample picture the function parameters have been tuned for:
+
+ 
+
+ And this is the output of the above program in case of the probabilistic Hough transform:
+
+ 
+
+
Parameters:
+
image - 8-bit, single-channel binary source image. The image may be modified by the function.
+
lines - Output vector of lines. Each line is represented by a 4-element vector
+ \((x_1, y_1, x_2, y_2)\) , where \((x_1,y_1)\) and \((x_2, y_2)\) are the ending points of each detected
+ line segment.
+
rho - Distance resolution of the accumulator in pixels.
+
theta - Angle resolution of the accumulator in radians.
+
threshold - %Accumulator threshold parameter. Only those lines are returned that get enough
+ votes ( \(>\texttt{threshold}\) ).
+
minLineLength - Minimum line length. Line segments shorter than that are rejected.
+
+ SEE: LineSegmentDetector
public static void HoughLinesP(Mat image,
+ Mat lines,
+ double rho,
+ double theta,
+ int threshold,
+ double minLineLength,
+ double maxLineGap)
+
Finds line segments in a binary image using the probabilistic Hough transform.
+
+ The function implements the probabilistic Hough transform algorithm for line detection, described
+ in CITE: Matas00
+
+ See the line detection example below:
+ INCLUDE: snippets/imgproc_HoughLinesP.cpp
+ This is a sample picture the function parameters have been tuned for:
+
+ 
+
+ And this is the output of the above program in case of the probabilistic Hough transform:
+
+ 
+
+
Parameters:
+
image - 8-bit, single-channel binary source image. The image may be modified by the function.
+
lines - Output vector of lines. Each line is represented by a 4-element vector
+ \((x_1, y_1, x_2, y_2)\) , where \((x_1,y_1)\) and \((x_2, y_2)\) are the ending points of each detected
+ line segment.
+
rho - Distance resolution of the accumulator in pixels.
+
theta - Angle resolution of the accumulator in radians.
+
threshold - %Accumulator threshold parameter. Only those lines are returned that get enough
+ votes ( \(>\texttt{threshold}\) ).
+
minLineLength - Minimum line length. Line segments shorter than that are rejected.
+
maxLineGap - Maximum allowed gap between points on the same line to link them.
+
+ SEE: LineSegmentDetector
public static void HoughLinesPointSet(Mat point,
+ Mat lines,
+ int lines_max,
+ int threshold,
+ double min_rho,
+ double max_rho,
+ double rho_step,
+ double min_theta,
+ double max_theta,
+ double theta_step)
+
Finds lines in a set of points using the standard Hough transform.
+
+ The function finds lines in a set of points using a modification of the Hough transform.
+ INCLUDE: snippets/imgproc_HoughLinesPointSet.cpp
+
+
Parameters:
+
point - Input vector of points. Each vector must be encoded as a Point vector \((x,y)\). Type must be CV_32FC2 or CV_32SC2.
+
lines - Output vector of found lines. Each vector is encoded as a vector<Vec3d> \((votes, rho, theta)\).
+ The larger the value of 'votes', the higher the reliability of the Hough line.
+
lines_max - Max count of Hough lines.
+
threshold - %Accumulator threshold parameter. Only those lines are returned that get enough
+ votes ( \(>\texttt{threshold}\) ).
+
min_rho - Minimum value for \(\rho\) for the accumulator (Note: \(\rho\) can be negative. The absolute value \(|\rho|\) is the distance of a line to the origin.).
+
max_rho - Maximum value for \(\rho\) for the accumulator.
+
rho_step - Distance resolution of the accumulator.
+
min_theta - Minimum angle value of the accumulator in radians.
+
max_theta - Upper bound for the angle value of the accumulator in radians. The actual maximum
+ angle may be slightly less than max_theta, depending on the parameters min_theta and theta_step.
+
theta_step - Angle resolution of the accumulator in radians.
public static void HoughLinesWithAccumulator(Mat image,
+ Mat lines,
+ double rho,
+ double theta,
+ int threshold)
+
Finds lines in a binary image using the standard Hough transform and get accumulator.
+
+ Note: This function is for bindings use only. Use original function in C++ code
+
+ SEE: HoughLines
public static void HoughLinesWithAccumulator(Mat image,
+ Mat lines,
+ double rho,
+ double theta,
+ int threshold,
+ double srn)
+
Finds lines in a binary image using the standard Hough transform and get accumulator.
+
+ Note: This function is for bindings use only. Use original function in C++ code
+
+ SEE: HoughLines
public static void HoughLinesWithAccumulator(Mat image,
+ Mat lines,
+ double rho,
+ double theta,
+ int threshold,
+ double srn,
+ double stn)
+
Finds lines in a binary image using the standard Hough transform and get accumulator.
+
+ Note: This function is for bindings use only. Use original function in C++ code
+
+ SEE: HoughLines
public static void HoughLinesWithAccumulator(Mat image,
+ Mat lines,
+ double rho,
+ double theta,
+ int threshold,
+ double srn,
+ double stn,
+ double min_theta)
+
Finds lines in a binary image using the standard Hough transform and get accumulator.
+
+ Note: This function is for bindings use only. Use original function in C++ code
+
+ SEE: HoughLines
public static void HoughLinesWithAccumulator(Mat image,
+ Mat lines,
+ double rho,
+ double theta,
+ int threshold,
+ double srn,
+ double stn,
+ double min_theta,
+ double max_theta)
+
Finds lines in a binary image using the standard Hough transform and get accumulator.
+
+ Note: This function is for bindings use only. Use original function in C++ code
+
+ SEE: HoughLines
public static void integral3(Mat src,
+ Mat sum,
+ Mat sqsum,
+ Mat tilted)
+
Calculates the integral of an image.
+
+ The function calculates one or more integral images for the source image as follows:
+
+ \(\texttt{sum} (X,Y) = \sum _{x<X,y<Y} \texttt{image} (x,y)\)
+
+ \(\texttt{sqsum} (X,Y) = \sum _{x<X,y<Y} \texttt{image} (x,y)^2\)
+
+ \(\texttt{tilted} (X,Y) = \sum _{y<Y,abs(x-X+1) \leq Y-y-1} \texttt{image} (x,y)\)
+
+ Using these integral images, you can calculate sum, mean, and standard deviation over a specific
+ up-right or rotated rectangular region of the image in a constant time, for example:
+
+ \(\sum _{x_1 \leq x < x_2, \, y_1 \leq y < y_2} \texttt{image} (x,y) = \texttt{sum} (x_2,y_2)- \texttt{sum} (x_1,y_2)- \texttt{sum} (x_2,y_1)+ \texttt{sum} (x_1,y_1)\)
+
+ It makes possible to do a fast blurring or fast block correlation with a variable window size, for
+ example. In case of multi-channel images, sums for each channel are accumulated independently.
+
+ As a practical example, the next figure shows the calculation of the integral of a straight
+ rectangle Rect(4,4,3,2) and of a tilted rectangle Rect(5,1,2,3) . The selected pixels in the
+ original image are shown, as well as the relative pixels in the integral images sum and tilted .
+
+ 
+
+
Parameters:
+
src - input image as \(W \times H\), 8-bit or floating-point (32f or 64f).
+
sum - integral image as \((W+1)\times (H+1)\) , 32-bit integer or floating-point (32f or 64f).
+
sqsum - integral image for squared pixel values; it is \((W+1)\times (H+1)\), double-precision
+ floating-point (64f) array.
+
tilted - integral for the image rotated by 45 degrees; it is \((W+1)\times (H+1)\) array with
+ the same data type as sum.
+ CV_64F.
public static void integral3(Mat src,
+ Mat sum,
+ Mat sqsum,
+ Mat tilted,
+ int sdepth)
+
Calculates the integral of an image.
+
+ The function calculates one or more integral images for the source image as follows:
+
+ \(\texttt{sum} (X,Y) = \sum _{x<X,y<Y} \texttt{image} (x,y)\)
+
+ \(\texttt{sqsum} (X,Y) = \sum _{x<X,y<Y} \texttt{image} (x,y)^2\)
+
+ \(\texttt{tilted} (X,Y) = \sum _{y<Y,abs(x-X+1) \leq Y-y-1} \texttt{image} (x,y)\)
+
+ Using these integral images, you can calculate sum, mean, and standard deviation over a specific
+ up-right or rotated rectangular region of the image in a constant time, for example:
+
+ \(\sum _{x_1 \leq x < x_2, \, y_1 \leq y < y_2} \texttt{image} (x,y) = \texttt{sum} (x_2,y_2)- \texttt{sum} (x_1,y_2)- \texttt{sum} (x_2,y_1)+ \texttt{sum} (x_1,y_1)\)
+
+ It makes possible to do a fast blurring or fast block correlation with a variable window size, for
+ example. In case of multi-channel images, sums for each channel are accumulated independently.
+
+ As a practical example, the next figure shows the calculation of the integral of a straight
+ rectangle Rect(4,4,3,2) and of a tilted rectangle Rect(5,1,2,3) . The selected pixels in the
+ original image are shown, as well as the relative pixels in the integral images sum and tilted .
+
+ 
+
+
Parameters:
+
src - input image as \(W \times H\), 8-bit or floating-point (32f or 64f).
+
sum - integral image as \((W+1)\times (H+1)\) , 32-bit integer or floating-point (32f or 64f).
+
sqsum - integral image for squared pixel values; it is \((W+1)\times (H+1)\), double-precision
+ floating-point (64f) array.
+
tilted - integral for the image rotated by 45 degrees; it is \((W+1)\times (H+1)\) array with
+ the same data type as sum.
+
sdepth - desired depth of the integral and the tilted integral images, CV_32S, CV_32F, or
+ CV_64F.
public static void integral3(Mat src,
+ Mat sum,
+ Mat sqsum,
+ Mat tilted,
+ int sdepth,
+ int sqdepth)
+
Calculates the integral of an image.
+
+ The function calculates one or more integral images for the source image as follows:
+
+ \(\texttt{sum} (X,Y) = \sum _{x<X,y<Y} \texttt{image} (x,y)\)
+
+ \(\texttt{sqsum} (X,Y) = \sum _{x<X,y<Y} \texttt{image} (x,y)^2\)
+
+ \(\texttt{tilted} (X,Y) = \sum _{y<Y,abs(x-X+1) \leq Y-y-1} \texttt{image} (x,y)\)
+
+ Using these integral images, you can calculate sum, mean, and standard deviation over a specific
+ up-right or rotated rectangular region of the image in a constant time, for example:
+
+ \(\sum _{x_1 \leq x < x_2, \, y_1 \leq y < y_2} \texttt{image} (x,y) = \texttt{sum} (x_2,y_2)- \texttt{sum} (x_1,y_2)- \texttt{sum} (x_2,y_1)+ \texttt{sum} (x_1,y_1)\)
+
+ It makes possible to do a fast blurring or fast block correlation with a variable window size, for
+ example. In case of multi-channel images, sums for each channel are accumulated independently.
+
+ As a practical example, the next figure shows the calculation of the integral of a straight
+ rectangle Rect(4,4,3,2) and of a tilted rectangle Rect(5,1,2,3) . The selected pixels in the
+ original image are shown, as well as the relative pixels in the integral images sum and tilted .
+
+ 
+
+
Parameters:
+
src - input image as \(W \times H\), 8-bit or floating-point (32f or 64f).
+
sum - integral image as \((W+1)\times (H+1)\) , 32-bit integer or floating-point (32f or 64f).
+
sqsum - integral image for squared pixel values; it is \((W+1)\times (H+1)\), double-precision
+ floating-point (64f) array.
+
tilted - integral for the image rotated by 45 degrees; it is \((W+1)\times (H+1)\) array with
+ the same data type as sum.
+
sdepth - desired depth of the integral and the tilted integral images, CV_32S, CV_32F, or
+ CV_64F.
+
sqdepth - desired depth of the integral image of squared pixel values, CV_32F or CV_64F.
public static float intersectConvexConvex(Mat p1,
+ Mat p2,
+ Mat p12)
+
Finds intersection of two convex polygons
+
+
Parameters:
+
p1 - First polygon
+
p2 - Second polygon
+
p12 - Output polygon describing the intersecting area
+ When false, no intersection is found. If the polygons share a side or the vertex of one polygon lies on an edge
+ of the other, they are not considered nested and an intersection will be found regardless of the value of handleNested.
+
Returns:
+
Absolute value of area of intersecting polygon
+
+ Note: intersectConvexConvex doesn't confirm that both polygons are convex and will return invalid results if they aren't.
public static float intersectConvexConvex(Mat p1,
+ Mat p2,
+ Mat p12,
+ boolean handleNested)
+
Finds intersection of two convex polygons
+
+
Parameters:
+
p1 - First polygon
+
p2 - Second polygon
+
p12 - Output polygon describing the intersecting area
+
handleNested - When true, an intersection is found if one of the polygons is fully enclosed in the other.
+ When false, no intersection is found. If the polygons share a side or the vertex of one polygon lies on an edge
+ of the other, they are not considered nested and an intersection will be found regardless of the value of handleNested.
+
Returns:
+
Absolute value of area of intersecting polygon
+
+ Note: intersectConvexConvex doesn't confirm that both polygons are convex and will return invalid results if they aren't.
public static void invertAffineTransform(Mat M,
+ Mat iM)
+
Inverts an affine transformation.
+
+ The function computes an inverse affine transformation represented by \(2 \times 3\) matrix M:
+
+ \(\begin{bmatrix} a_{11} & a_{12} & b_1 \\ a_{21} & a_{22} & b_2 \end{bmatrix}\)
+
+ The result is also a \(2 \times 3\) matrix of the same type as M.
public static boolean isContourConvex(MatOfPoint contour)
+
Tests a contour convexity.
+
+ The function tests whether the input contour is convex or not. The contour must be simple, that is,
+ without self-intersections. Otherwise, the function output is undefined.
+
+
Parameters:
+
contour - Input vector of 2D points, stored in std::vector<> or Mat
public static void Laplacian(Mat src,
+ Mat dst,
+ int ddepth)
+
Calculates the Laplacian of an image.
+
+ The function calculates the Laplacian of the source image by adding up the second x and y
+ derivatives calculated using the Sobel operator:
+
+ \(\texttt{dst} = \Delta \texttt{src} = \frac{\partial^2 \texttt{src}}{\partial x^2} + \frac{\partial^2 \texttt{src}}{\partial y^2}\)
+
+ This is done when ksize > 1. When ksize == 1, the Laplacian is computed by filtering the image
+ with the following \(3 \times 3\) aperture:
+
+ \(\vecthreethree {0}{1}{0}{1}{-4}{1}{0}{1}{0}\)
+
+
Parameters:
+
src - Source image.
+
dst - Destination image of the same size and the same number of channels as src .
+
ddepth - Desired depth of the destination image, see REF: filter_depths "combinations".
+ details. The size must be positive and odd.
+ applied. See #getDerivKernels for details.
+ SEE: Sobel, Scharr
public static void Laplacian(Mat src,
+ Mat dst,
+ int ddepth,
+ int ksize)
+
Calculates the Laplacian of an image.
+
+ The function calculates the Laplacian of the source image by adding up the second x and y
+ derivatives calculated using the Sobel operator:
+
+ \(\texttt{dst} = \Delta \texttt{src} = \frac{\partial^2 \texttt{src}}{\partial x^2} + \frac{\partial^2 \texttt{src}}{\partial y^2}\)
+
+ This is done when ksize > 1. When ksize == 1, the Laplacian is computed by filtering the image
+ with the following \(3 \times 3\) aperture:
+
+ \(\vecthreethree {0}{1}{0}{1}{-4}{1}{0}{1}{0}\)
+
+
Parameters:
+
src - Source image.
+
dst - Destination image of the same size and the same number of channels as src .
+
ddepth - Desired depth of the destination image, see REF: filter_depths "combinations".
+
ksize - Aperture size used to compute the second-derivative filters. See #getDerivKernels for
+ details. The size must be positive and odd.
+ applied. See #getDerivKernels for details.
+ SEE: Sobel, Scharr
public static void Laplacian(Mat src,
+ Mat dst,
+ int ddepth,
+ int ksize,
+ double scale)
+
Calculates the Laplacian of an image.
+
+ The function calculates the Laplacian of the source image by adding up the second x and y
+ derivatives calculated using the Sobel operator:
+
+ \(\texttt{dst} = \Delta \texttt{src} = \frac{\partial^2 \texttt{src}}{\partial x^2} + \frac{\partial^2 \texttt{src}}{\partial y^2}\)
+
+ This is done when ksize > 1. When ksize == 1, the Laplacian is computed by filtering the image
+ with the following \(3 \times 3\) aperture:
+
+ \(\vecthreethree {0}{1}{0}{1}{-4}{1}{0}{1}{0}\)
+
+
Parameters:
+
src - Source image.
+
dst - Destination image of the same size and the same number of channels as src .
+
ddepth - Desired depth of the destination image, see REF: filter_depths "combinations".
+
ksize - Aperture size used to compute the second-derivative filters. See #getDerivKernels for
+ details. The size must be positive and odd.
+
scale - Optional scale factor for the computed Laplacian values. By default, no scaling is
+ applied. See #getDerivKernels for details.
+ SEE: Sobel, Scharr
public static void Laplacian(Mat src,
+ Mat dst,
+ int ddepth,
+ int ksize,
+ double scale,
+ double delta)
+
Calculates the Laplacian of an image.
+
+ The function calculates the Laplacian of the source image by adding up the second x and y
+ derivatives calculated using the Sobel operator:
+
+ \(\texttt{dst} = \Delta \texttt{src} = \frac{\partial^2 \texttt{src}}{\partial x^2} + \frac{\partial^2 \texttt{src}}{\partial y^2}\)
+
+ This is done when ksize > 1. When ksize == 1, the Laplacian is computed by filtering the image
+ with the following \(3 \times 3\) aperture:
+
+ \(\vecthreethree {0}{1}{0}{1}{-4}{1}{0}{1}{0}\)
+
+
Parameters:
+
src - Source image.
+
dst - Destination image of the same size and the same number of channels as src .
+
ddepth - Desired depth of the destination image, see REF: filter_depths "combinations".
+
ksize - Aperture size used to compute the second-derivative filters. See #getDerivKernels for
+ details. The size must be positive and odd.
+
scale - Optional scale factor for the computed Laplacian values. By default, no scaling is
+ applied. See #getDerivKernels for details.
+
delta - Optional delta value that is added to the results prior to storing them in dst .
+ SEE: Sobel, Scharr
public static void Laplacian(Mat src,
+ Mat dst,
+ int ddepth,
+ int ksize,
+ double scale,
+ double delta,
+ int borderType)
+
Calculates the Laplacian of an image.
+
+ The function calculates the Laplacian of the source image by adding up the second x and y
+ derivatives calculated using the Sobel operator:
+
+ \(\texttt{dst} = \Delta \texttt{src} = \frac{\partial^2 \texttt{src}}{\partial x^2} + \frac{\partial^2 \texttt{src}}{\partial y^2}\)
+
+ This is done when ksize > 1. When ksize == 1, the Laplacian is computed by filtering the image
+ with the following \(3 \times 3\) aperture:
+
+ \(\vecthreethree {0}{1}{0}{1}{-4}{1}{0}{1}{0}\)
+
+
Parameters:
+
src - Source image.
+
dst - Destination image of the same size and the same number of channels as src .
+
ddepth - Desired depth of the destination image, see REF: filter_depths "combinations".
+
ksize - Aperture size used to compute the second-derivative filters. See #getDerivKernels for
+ details. The size must be positive and odd.
+
scale - Optional scale factor for the computed Laplacian values. By default, no scaling is
+ applied. See #getDerivKernels for details.
+
delta - Optional delta value that is added to the results prior to storing them in dst .
+
borderType - Pixel extrapolation method, see #BorderTypes. #BORDER_WRAP is not supported.
+ SEE: Sobel, Scharr
Draws a line segment connecting two points.
+
+ The function line draws the line segment between pt1 and pt2 points in the image. The line is
+ clipped by the image boundaries. For non-antialiased lines with integer coordinates, the 8-connected
+ or 4-connected Bresenham algorithm is used. Thick lines are drawn with rounding endings. Antialiased
+ lines are drawn using Gaussian filtering.
public static void line(Mat img,
+ Point pt1,
+ Point pt2,
+ Scalar color,
+ int thickness)
+
Draws a line segment connecting two points.
+
+ The function line draws the line segment between pt1 and pt2 points in the image. The line is
+ clipped by the image boundaries. For non-antialiased lines with integer coordinates, the 8-connected
+ or 4-connected Bresenham algorithm is used. Thick lines are drawn with rounding endings. Antialiased
+ lines are drawn using Gaussian filtering.
public static void line(Mat img,
+ Point pt1,
+ Point pt2,
+ Scalar color,
+ int thickness,
+ int lineType)
+
Draws a line segment connecting two points.
+
+ The function line draws the line segment between pt1 and pt2 points in the image. The line is
+ clipped by the image boundaries. For non-antialiased lines with integer coordinates, the 8-connected
+ or 4-connected Bresenham algorithm is used. Thick lines are drawn with rounding endings. Antialiased
+ lines are drawn using Gaussian filtering.
public static void line(Mat img,
+ Point pt1,
+ Point pt2,
+ Scalar color,
+ int thickness,
+ int lineType,
+ int shift)
+
Draws a line segment connecting two points.
+
+ The function line draws the line segment between pt1 and pt2 points in the image. The line is
+ clipped by the image boundaries. For non-antialiased lines with integer coordinates, the 8-connected
+ or 4-connected Bresenham algorithm is used. Thick lines are drawn with rounding endings. Antialiased
+ lines are drawn using Gaussian filtering.
+
+
Parameters:
+
img - Image.
+
pt1 - First point of the line segment.
+
pt2 - Second point of the line segment.
+
color - Line color.
+
thickness - Line thickness.
+
lineType - Type of the line. See #LineTypes.
+
shift - Number of fractional bits in the point coordinates.
public static void matchTemplate(Mat image,
+ Mat templ,
+ Mat result,
+ int method)
+
Compares a template against overlapped image regions.
+
+ The function slides through image , compares the overlapped patches of size \(w \times h\) against
+ templ using the specified method and stores the comparison results in result . #TemplateMatchModes
+ describes the formulae for the available comparison methods ( \(I\) denotes image, \(T\)
+ template, \(R\) result, \(M\) the optional mask ). The summation is done over template and/or
+ the image patch: \(x' = 0...w-1, y' = 0...h-1\)
+
+ After the function finishes the comparison, the best matches can be found as global minimums (when
+ #TM_SQDIFF was used) or maximums (when #TM_CCORR or #TM_CCOEFF was used) using the
+ #minMaxLoc function. In case of a color image, template summation in the numerator and each sum in
+ the denominator is done over all of the channels and separate mean values are used for each channel.
+ That is, the function can take a color template and a color image. The result will still be a
+ single-channel image, which is easier to analyze.
+
+
Parameters:
+
image - Image where the search is running. It must be 8-bit or 32-bit floating-point.
+
templ - Searched template. It must be not greater than the source image and have the same
+ data type.
+
result - Map of comparison results. It must be single-channel 32-bit floating-point. If image
+ is \(W \times H\) and templ is \(w \times h\) , then result is \((W-w+1) \times (H-h+1)\) .
+
method - Parameter specifying the comparison method, see #TemplateMatchModes
+ of channels as template or only one channel, which is then used for all template and
+ image channels. If the data type is #CV_8U, the mask is interpreted as a binary mask,
+ meaning only elements where mask is nonzero are used and are kept unchanged independent
+ of the actual mask value (weight equals 1). For data tpye #CV_32F, the mask values are
+ used as weights. The exact formulas are documented in #TemplateMatchModes.
public static void matchTemplate(Mat image,
+ Mat templ,
+ Mat result,
+ int method,
+ Mat mask)
+
Compares a template against overlapped image regions.
+
+ The function slides through image , compares the overlapped patches of size \(w \times h\) against
+ templ using the specified method and stores the comparison results in result . #TemplateMatchModes
+ describes the formulae for the available comparison methods ( \(I\) denotes image, \(T\)
+ template, \(R\) result, \(M\) the optional mask ). The summation is done over template and/or
+ the image patch: \(x' = 0...w-1, y' = 0...h-1\)
+
+ After the function finishes the comparison, the best matches can be found as global minimums (when
+ #TM_SQDIFF was used) or maximums (when #TM_CCORR or #TM_CCOEFF was used) using the
+ #minMaxLoc function. In case of a color image, template summation in the numerator and each sum in
+ the denominator is done over all of the channels and separate mean values are used for each channel.
+ That is, the function can take a color template and a color image. The result will still be a
+ single-channel image, which is easier to analyze.
+
+
Parameters:
+
image - Image where the search is running. It must be 8-bit or 32-bit floating-point.
+
templ - Searched template. It must be not greater than the source image and have the same
+ data type.
+
result - Map of comparison results. It must be single-channel 32-bit floating-point. If image
+ is \(W \times H\) and templ is \(w \times h\) , then result is \((W-w+1) \times (H-h+1)\) .
+
method - Parameter specifying the comparison method, see #TemplateMatchModes
+
mask - Optional mask. It must have the same size as templ. It must either have the same number
+ of channels as template or only one channel, which is then used for all template and
+ image channels. If the data type is #CV_8U, the mask is interpreted as a binary mask,
+ meaning only elements where mask is nonzero are used and are kept unchanged independent
+ of the actual mask value (weight equals 1). For data tpye #CV_32F, the mask values are
+ used as weights. The exact formulas are documented in #TemplateMatchModes.
public static void medianBlur(Mat src,
+ Mat dst,
+ int ksize)
+
Blurs an image using the median filter.
+
+ The function smoothes an image using the median filter with the \(\texttt{ksize} \times
+ \texttt{ksize}\) aperture. Each channel of a multi-channel image is processed independently.
+ In-place operation is supported.
+
+ Note: The median filter uses #BORDER_REPLICATE internally to cope with border pixels, see #BorderTypes
+
+
Parameters:
+
src - input 1-, 3-, or 4-channel image; when ksize is 3 or 5, the image depth should be
+ CV_8U, CV_16U, or CV_32F, for larger aperture sizes, it can only be CV_8U.
+
dst - destination array of the same size and type as src.
+
ksize - aperture linear size; it must be odd and greater than 1, for example: 3, 5, 7 ...
+ SEE: bilateralFilter, blur, boxFilter, GaussianBlur
Finds a rotated rectangle of the minimum area enclosing the input 2D point set.
+
+ The function calculates and returns the minimum-area bounding rectangle (possibly rotated) for a
+ specified point set. Developer should keep in mind that the returned RotatedRect can contain negative
+ indices when data is close to the containing Mat element boundary.
+
+
Parameters:
+
points - Input vector of 2D points, stored in std::vector<> or Mat
public static void minEnclosingCircle(MatOfPoint2f points,
+ Point center,
+ float[] radius)
+
Finds a circle of the minimum area enclosing a 2D point set.
+
+ The function finds the minimal enclosing circle of a 2D point set using an iterative algorithm.
+
+
Parameters:
+
points - Input vector of 2D points, stored in std::vector<> or Mat
public static double minEnclosingTriangle(Mat points,
+ Mat triangle)
+
Finds a triangle of minimum area enclosing a 2D point set and returns its area.
+
+ The function finds a triangle of minimum area enclosing the given set of 2D points and returns its
+ area. The output for a given 2D point set is shown in the image below. 2D points are depicted in
+ red* and the enclosing triangle in *yellow*.
+
+ 
+
+ The implementation of the algorithm is based on O'Rourke's CITE: ORourke86 and Klee and Laskowski's
+ CITE: KleeLaskowski85 papers. O'Rourke provides a \(\theta(n)\) algorithm for finding the minimal
+ enclosing triangle of a 2D convex polygon with n vertices. Since the #minEnclosingTriangle function
+ takes a 2D point set as input an additional preprocessing step of computing the convex hull of the
+ 2D point set is required. The complexity of the #convexHull function is \(O(n log(n))\) which is higher
+ than \(\theta(n)\). Thus the overall complexity of the function is \(O(n log(n))\).
+
+
Parameters:
+
points - Input vector of 2D points with depth CV_32S or CV_32F, stored in std::vector<> or Mat
+
triangle - Output vector of three 2D points defining the vertices of the triangle. The depth
+ of the OutputArray must be CV_32F.
Calculates all of the moments up to the third order of a polygon or rasterized shape.
+
+ The function computes moments, up to the 3rd order, of a vector shape or a rasterized shape. The
+ results are returned in the structure cv::Moments.
+
+
Parameters:
+
array - Raster image (single-channel, 8-bit or floating-point 2D array) or an array (
+ \(1 \times N\) or \(N \times 1\) ) of 2D points (Point or Point2f ).
+ used for images only.
+
Returns:
+
moments.
+
+ Note: Only applicable to contour moments calculations from Python bindings: Note that the numpy
+ type for the input array should be either np.int32 or np.float32.
+
+ SEE: contourArea, arcLength
public static Moments moments(Mat array,
+ boolean binaryImage)
+
Calculates all of the moments up to the third order of a polygon or rasterized shape.
+
+ The function computes moments, up to the 3rd order, of a vector shape or a rasterized shape. The
+ results are returned in the structure cv::Moments.
+
+
Parameters:
+
array - Raster image (single-channel, 8-bit or floating-point 2D array) or an array (
+ \(1 \times N\) or \(N \times 1\) ) of 2D points (Point or Point2f ).
+
binaryImage - If it is true, all non-zero image pixels are treated as 1's. The parameter is
+ used for images only.
+
Returns:
+
moments.
+
+ Note: Only applicable to contour moments calculations from Python bindings: Note that the numpy
+ type for the input array should be either np.int32 or np.float32.
+
+ SEE: contourArea, arcLength
public static void morphologyEx(Mat src,
+ Mat dst,
+ int op,
+ Mat kernel)
+
Performs advanced morphological transformations.
+
+ The function cv::morphologyEx can perform advanced morphological transformations using an erosion and dilation as
+ basic operations.
+
+ Any of the operations can be done in-place. In case of multi-channel images, each channel is
+ processed independently.
+
+
Parameters:
+
src - Source image. The number of channels can be arbitrary. The depth should be one of
+ CV_8U, CV_16U, CV_16S, CV_32F or CV_64F.
+
dst - Destination image of the same size and type as source image.
+
op - Type of a morphological operation, see #MorphTypes
+
kernel - Structuring element. It can be created using #getStructuringElement.
+ kernel center.
+ meaning.
+ SEE: dilate, erode, getStructuringElement
+ Note: The number of iterations is the number of times erosion or dilatation operation will be applied.
+ For instance, an opening operation (#MORPH_OPEN) with two iterations is equivalent to apply
+ successively: erode -> erode -> dilate -> dilate (and not erode -> dilate -> erode -> dilate).
public static void morphologyEx(Mat src,
+ Mat dst,
+ int op,
+ Mat kernel,
+ Point anchor)
+
Performs advanced morphological transformations.
+
+ The function cv::morphologyEx can perform advanced morphological transformations using an erosion and dilation as
+ basic operations.
+
+ Any of the operations can be done in-place. In case of multi-channel images, each channel is
+ processed independently.
+
+
Parameters:
+
src - Source image. The number of channels can be arbitrary. The depth should be one of
+ CV_8U, CV_16U, CV_16S, CV_32F or CV_64F.
+
dst - Destination image of the same size and type as source image.
+
op - Type of a morphological operation, see #MorphTypes
+
kernel - Structuring element. It can be created using #getStructuringElement.
+
anchor - Anchor position with the kernel. Negative values mean that the anchor is at the
+ kernel center.
+ meaning.
+ SEE: dilate, erode, getStructuringElement
+ Note: The number of iterations is the number of times erosion or dilatation operation will be applied.
+ For instance, an opening operation (#MORPH_OPEN) with two iterations is equivalent to apply
+ successively: erode -> erode -> dilate -> dilate (and not erode -> dilate -> erode -> dilate).
public static void morphologyEx(Mat src,
+ Mat dst,
+ int op,
+ Mat kernel,
+ Point anchor,
+ int iterations)
+
Performs advanced morphological transformations.
+
+ The function cv::morphologyEx can perform advanced morphological transformations using an erosion and dilation as
+ basic operations.
+
+ Any of the operations can be done in-place. In case of multi-channel images, each channel is
+ processed independently.
+
+
Parameters:
+
src - Source image. The number of channels can be arbitrary. The depth should be one of
+ CV_8U, CV_16U, CV_16S, CV_32F or CV_64F.
+
dst - Destination image of the same size and type as source image.
+
op - Type of a morphological operation, see #MorphTypes
+
kernel - Structuring element. It can be created using #getStructuringElement.
+
anchor - Anchor position with the kernel. Negative values mean that the anchor is at the
+ kernel center.
+
iterations - Number of times erosion and dilation are applied.
+ meaning.
+ SEE: dilate, erode, getStructuringElement
+ Note: The number of iterations is the number of times erosion or dilatation operation will be applied.
+ For instance, an opening operation (#MORPH_OPEN) with two iterations is equivalent to apply
+ successively: erode -> erode -> dilate -> dilate (and not erode -> dilate -> erode -> dilate).
public static void morphologyEx(Mat src,
+ Mat dst,
+ int op,
+ Mat kernel,
+ Point anchor,
+ int iterations,
+ int borderType)
+
Performs advanced morphological transformations.
+
+ The function cv::morphologyEx can perform advanced morphological transformations using an erosion and dilation as
+ basic operations.
+
+ Any of the operations can be done in-place. In case of multi-channel images, each channel is
+ processed independently.
+
+
Parameters:
+
src - Source image. The number of channels can be arbitrary. The depth should be one of
+ CV_8U, CV_16U, CV_16S, CV_32F or CV_64F.
+
dst - Destination image of the same size and type as source image.
+
op - Type of a morphological operation, see #MorphTypes
+
kernel - Structuring element. It can be created using #getStructuringElement.
+
anchor - Anchor position with the kernel. Negative values mean that the anchor is at the
+ kernel center.
+
iterations - Number of times erosion and dilation are applied.
+
borderType - Pixel extrapolation method, see #BorderTypes. #BORDER_WRAP is not supported.
+ meaning.
+ SEE: dilate, erode, getStructuringElement
+ Note: The number of iterations is the number of times erosion or dilatation operation will be applied.
+ For instance, an opening operation (#MORPH_OPEN) with two iterations is equivalent to apply
+ successively: erode -> erode -> dilate -> dilate (and not erode -> dilate -> erode -> dilate).
public static void morphologyEx(Mat src,
+ Mat dst,
+ int op,
+ Mat kernel,
+ Point anchor,
+ int iterations,
+ int borderType,
+ Scalar borderValue)
+
Performs advanced morphological transformations.
+
+ The function cv::morphologyEx can perform advanced morphological transformations using an erosion and dilation as
+ basic operations.
+
+ Any of the operations can be done in-place. In case of multi-channel images, each channel is
+ processed independently.
+
+
Parameters:
+
src - Source image. The number of channels can be arbitrary. The depth should be one of
+ CV_8U, CV_16U, CV_16S, CV_32F or CV_64F.
+
dst - Destination image of the same size and type as source image.
+
op - Type of a morphological operation, see #MorphTypes
+
kernel - Structuring element. It can be created using #getStructuringElement.
+
anchor - Anchor position with the kernel. Negative values mean that the anchor is at the
+ kernel center.
+
iterations - Number of times erosion and dilation are applied.
+
borderType - Pixel extrapolation method, see #BorderTypes. #BORDER_WRAP is not supported.
+
borderValue - Border value in case of a constant border. The default value has a special
+ meaning.
+ SEE: dilate, erode, getStructuringElement
+ Note: The number of iterations is the number of times erosion or dilatation operation will be applied.
+ For instance, an opening operation (#MORPH_OPEN) with two iterations is equivalent to apply
+ successively: erode -> erode -> dilate -> dilate (and not erode -> dilate -> erode -> dilate).
public static Point phaseCorrelate(Mat src1,
+ Mat src2)
+
The function is used to detect translational shifts that occur between two images.
+
+ The operation takes advantage of the Fourier shift theorem for detecting the translational shift in
+ the frequency domain. It can be used for fast image registration as well as motion estimation. For
+ more information please see <http://en.wikipedia.org/wiki/Phase_correlation>
+
+ Calculates the cross-power spectrum of two supplied source arrays. The arrays are padded if needed
+ with getOptimalDFTSize.
+
+ The function performs the following equations:
+
+
+ First it applies a Hanning window (see <http://en.wikipedia.org/wiki/Hann_function>) to each
+ image to remove possible edge effects. This window is cached until the array size changes to speed
+ up processing time.
+
+
+ Next it computes the forward DFTs of each source array:
+ \(\mathbf{G}_a = \mathcal{F}\{src_1\}, \; \mathbf{G}_b = \mathcal{F}\{src_2\}\)
+ where \(\mathcal{F}\) is the forward DFT.
+
+
+ It then computes the cross-power spectrum of each frequency domain array:
+ \(R = \frac{ \mathbf{G}_a \mathbf{G}_b^*}{|\mathbf{G}_a \mathbf{G}_b^*|}\)
+
+
+ Next the cross-correlation is converted back into the time domain via the inverse DFT:
+ \(r = \mathcal{F}^{-1}\{R\}\)
+
+
+ Finally, it computes the peak location and computes a 5x5 weighted centroid around the peak to
+ achieve sub-pixel accuracy.
+ \((\Delta x, \Delta y) = \texttt{weightedCentroid} \{\arg \max_{(x, y)}\{r\}\}\)
+
+
+ If non-zero, the response parameter is computed as the sum of the elements of r within the 5x5
+ centroid around the peak location. It is normalized to a maximum of 1 (meaning there is a single
+ peak) and will be smaller when there are multiple peaks.
+
+
+
+
Parameters:
+
src1 - Source floating point array (CV_32FC1 or CV_64FC1)
+
src2 - Source floating point array (CV_32FC1 or CV_64FC1)
+
Returns:
+
detected phase shift (sub-pixel) between the two arrays.
+
+ SEE: dft, getOptimalDFTSize, idft, mulSpectrums createHanningWindow
public static Point phaseCorrelate(Mat src1,
+ Mat src2,
+ Mat window)
+
The function is used to detect translational shifts that occur between two images.
+
+ The operation takes advantage of the Fourier shift theorem for detecting the translational shift in
+ the frequency domain. It can be used for fast image registration as well as motion estimation. For
+ more information please see <http://en.wikipedia.org/wiki/Phase_correlation>
+
+ Calculates the cross-power spectrum of two supplied source arrays. The arrays are padded if needed
+ with getOptimalDFTSize.
+
+ The function performs the following equations:
+
+
+ First it applies a Hanning window (see <http://en.wikipedia.org/wiki/Hann_function>) to each
+ image to remove possible edge effects. This window is cached until the array size changes to speed
+ up processing time.
+
+
+ Next it computes the forward DFTs of each source array:
+ \(\mathbf{G}_a = \mathcal{F}\{src_1\}, \; \mathbf{G}_b = \mathcal{F}\{src_2\}\)
+ where \(\mathcal{F}\) is the forward DFT.
+
+
+ It then computes the cross-power spectrum of each frequency domain array:
+ \(R = \frac{ \mathbf{G}_a \mathbf{G}_b^*}{|\mathbf{G}_a \mathbf{G}_b^*|}\)
+
+
+ Next the cross-correlation is converted back into the time domain via the inverse DFT:
+ \(r = \mathcal{F}^{-1}\{R\}\)
+
+
+ Finally, it computes the peak location and computes a 5x5 weighted centroid around the peak to
+ achieve sub-pixel accuracy.
+ \((\Delta x, \Delta y) = \texttt{weightedCentroid} \{\arg \max_{(x, y)}\{r\}\}\)
+
+
+ If non-zero, the response parameter is computed as the sum of the elements of r within the 5x5
+ centroid around the peak location. It is normalized to a maximum of 1 (meaning there is a single
+ peak) and will be smaller when there are multiple peaks.
+
+
+
+
Parameters:
+
src1 - Source floating point array (CV_32FC1 or CV_64FC1)
+
src2 - Source floating point array (CV_32FC1 or CV_64FC1)
+
window - Floating point array with windowing coefficients to reduce edge effects (optional).
+
Returns:
+
detected phase shift (sub-pixel) between the two arrays.
+
+ SEE: dft, getOptimalDFTSize, idft, mulSpectrums createHanningWindow
public static Point phaseCorrelate(Mat src1,
+ Mat src2,
+ Mat window,
+ double[] response)
+
The function is used to detect translational shifts that occur between two images.
+
+ The operation takes advantage of the Fourier shift theorem for detecting the translational shift in
+ the frequency domain. It can be used for fast image registration as well as motion estimation. For
+ more information please see <http://en.wikipedia.org/wiki/Phase_correlation>
+
+ Calculates the cross-power spectrum of two supplied source arrays. The arrays are padded if needed
+ with getOptimalDFTSize.
+
+ The function performs the following equations:
+
+
+ First it applies a Hanning window (see <http://en.wikipedia.org/wiki/Hann_function>) to each
+ image to remove possible edge effects. This window is cached until the array size changes to speed
+ up processing time.
+
+
+ Next it computes the forward DFTs of each source array:
+ \(\mathbf{G}_a = \mathcal{F}\{src_1\}, \; \mathbf{G}_b = \mathcal{F}\{src_2\}\)
+ where \(\mathcal{F}\) is the forward DFT.
+
+
+ It then computes the cross-power spectrum of each frequency domain array:
+ \(R = \frac{ \mathbf{G}_a \mathbf{G}_b^*}{|\mathbf{G}_a \mathbf{G}_b^*|}\)
+
+
+ Next the cross-correlation is converted back into the time domain via the inverse DFT:
+ \(r = \mathcal{F}^{-1}\{R\}\)
+
+
+ Finally, it computes the peak location and computes a 5x5 weighted centroid around the peak to
+ achieve sub-pixel accuracy.
+ \((\Delta x, \Delta y) = \texttt{weightedCentroid} \{\arg \max_{(x, y)}\{r\}\}\)
+
+
+ If non-zero, the response parameter is computed as the sum of the elements of r within the 5x5
+ centroid around the peak location. It is normalized to a maximum of 1 (meaning there is a single
+ peak) and will be smaller when there are multiple peaks.
+
+
+
+
Parameters:
+
src1 - Source floating point array (CV_32FC1 or CV_64FC1)
+
src2 - Source floating point array (CV_32FC1 or CV_64FC1)
+
window - Floating point array with windowing coefficients to reduce edge effects (optional).
+
response - Signal power within the 5x5 centroid around the peak, between 0 and 1 (optional).
+
Returns:
+
detected phase shift (sub-pixel) between the two arrays.
+
+ SEE: dft, getOptimalDFTSize, idft, mulSpectrums createHanningWindow
public static double pointPolygonTest(MatOfPoint2f contour,
+ Point pt,
+ boolean measureDist)
+
Performs a point-in-contour test.
+
+ The function determines whether the point is inside a contour, outside, or lies on an edge (or
+ coincides with a vertex). It returns positive (inside), negative (outside), or zero (on an edge)
+ value, correspondingly. When measureDist=false , the return value is +1, -1, and 0, respectively.
+ Otherwise, the return value is a signed distance between the point and the nearest contour edge.
+
+ See below a sample output of the function where each image pixel is tested against the contour:
+
+ 
+
+
Parameters:
+
contour - Input contour.
+
pt - Point tested against the contour.
+
measureDist - If true, the function estimates the signed distance from the point to the
+ nearest contour edge. Otherwise, the function only checks if the point is inside a contour or not.
isClosed - Flag indicating whether the drawn polylines are closed or not. If they are closed,
+ the function draws a line from the last vertex of each curve to its first vertex.
+
color - Polyline color.
+
+ The function cv::polylines draws one or more polygonal curves.
public static void polylines(Mat img,
+ java.util.List<MatOfPoint> pts,
+ boolean isClosed,
+ Scalar color,
+ int thickness)
+
Draws several polygonal curves.
+
+
Parameters:
+
img - Image.
+
pts - Array of polygonal curves.
+
isClosed - Flag indicating whether the drawn polylines are closed or not. If they are closed,
+ the function draws a line from the last vertex of each curve to its first vertex.
+
color - Polyline color.
+
thickness - Thickness of the polyline edges.
+
+ The function cv::polylines draws one or more polygonal curves.
public static void polylines(Mat img,
+ java.util.List<MatOfPoint> pts,
+ boolean isClosed,
+ Scalar color,
+ int thickness,
+ int lineType)
+
Draws several polygonal curves.
+
+
Parameters:
+
img - Image.
+
pts - Array of polygonal curves.
+
isClosed - Flag indicating whether the drawn polylines are closed or not. If they are closed,
+ the function draws a line from the last vertex of each curve to its first vertex.
+
color - Polyline color.
+
thickness - Thickness of the polyline edges.
+
lineType - Type of the line segments. See #LineTypes
+
+ The function cv::polylines draws one or more polygonal curves.
public static void polylines(Mat img,
+ java.util.List<MatOfPoint> pts,
+ boolean isClosed,
+ Scalar color,
+ int thickness,
+ int lineType,
+ int shift)
+
Draws several polygonal curves.
+
+
Parameters:
+
img - Image.
+
pts - Array of polygonal curves.
+
isClosed - Flag indicating whether the drawn polylines are closed or not. If they are closed,
+ the function draws a line from the last vertex of each curve to its first vertex.
+
color - Polyline color.
+
thickness - Thickness of the polyline edges.
+
lineType - Type of the line segments. See #LineTypes
+
shift - Number of fractional bits in the vertex coordinates.
+
+ The function cv::polylines draws one or more polygonal curves.
public static void preCornerDetect(Mat src,
+ Mat dst,
+ int ksize)
+
Calculates a feature map for corner detection.
+
+ The function calculates the complex spatial derivative-based function of the source image
+
+ \(\texttt{dst} = (D_x \texttt{src} )^2 \cdot D_{yy} \texttt{src} + (D_y \texttt{src} )^2 \cdot D_{xx} \texttt{src} - 2 D_x \texttt{src} \cdot D_y \texttt{src} \cdot D_{xy} \texttt{src}\)
+
+ where \(D_x\),\(D_y\) are the first image derivatives, \(D_{xx}\),\(D_{yy}\) are the second image
+ derivatives, and \(D_{xy}\) is the mixed derivative.
+
+ The corners can be found as local maximums of the functions, as shown below:
+
+ Mat corners, dilated_corners;
+ preCornerDetect(image, corners, 3);
+ // dilation with 3x3 rectangular structuring element
+ dilate(corners, dilated_corners, Mat(), 1);
+ Mat corner_mask = corners == dilated_corners;
+
+
+
Parameters:
+
src - Source single-channel 8-bit of floating-point image.
+
dst - Output image that has the type CV_32F and the same size as src .
public static void preCornerDetect(Mat src,
+ Mat dst,
+ int ksize,
+ int borderType)
+
Calculates a feature map for corner detection.
+
+ The function calculates the complex spatial derivative-based function of the source image
+
+ \(\texttt{dst} = (D_x \texttt{src} )^2 \cdot D_{yy} \texttt{src} + (D_y \texttt{src} )^2 \cdot D_{xx} \texttt{src} - 2 D_x \texttt{src} \cdot D_y \texttt{src} \cdot D_{xy} \texttt{src}\)
+
+ where \(D_x\),\(D_y\) are the first image derivatives, \(D_{xx}\),\(D_{yy}\) are the second image
+ derivatives, and \(D_{xy}\) is the mixed derivative.
+
+ The corners can be found as local maximums of the functions, as shown below:
+
+ Mat corners, dilated_corners;
+ preCornerDetect(image, corners, 3);
+ // dilation with 3x3 rectangular structuring element
+ dilate(corners, dilated_corners, Mat(), 1);
+ Mat corner_mask = corners == dilated_corners;
+
+
+
Parameters:
+
src - Source single-channel 8-bit of floating-point image.
+
dst - Output image that has the type CV_32F and the same size as src .
+
ksize - %Aperture size of the Sobel .
+
borderType - Pixel extrapolation method. See #BorderTypes. #BORDER_WRAP is not supported.
public static void putText(Mat img,
+ java.lang.String text,
+ Point org,
+ int fontFace,
+ double fontScale,
+ Scalar color)
+
Draws a text string.
+
+ The function cv::putText renders the specified text string in the image. Symbols that cannot be rendered
+ using the specified font are replaced by question marks. See #getTextSize for a text rendering code
+ example.
+
+
Parameters:
+
img - Image.
+
text - Text string to be drawn.
+
org - Bottom-left corner of the text string in the image.
+
fontFace - Font type, see #HersheyFonts.
+
fontScale - Font scale factor that is multiplied by the font-specific base size.
+
color - Text color.
+ it is at the top-left corner.
public static void putText(Mat img,
+ java.lang.String text,
+ Point org,
+ int fontFace,
+ double fontScale,
+ Scalar color,
+ int thickness)
+
Draws a text string.
+
+ The function cv::putText renders the specified text string in the image. Symbols that cannot be rendered
+ using the specified font are replaced by question marks. See #getTextSize for a text rendering code
+ example.
+
+
Parameters:
+
img - Image.
+
text - Text string to be drawn.
+
org - Bottom-left corner of the text string in the image.
+
fontFace - Font type, see #HersheyFonts.
+
fontScale - Font scale factor that is multiplied by the font-specific base size.
+
color - Text color.
+
thickness - Thickness of the lines used to draw a text.
+ it is at the top-left corner.
public static void putText(Mat img,
+ java.lang.String text,
+ Point org,
+ int fontFace,
+ double fontScale,
+ Scalar color,
+ int thickness,
+ int lineType)
+
Draws a text string.
+
+ The function cv::putText renders the specified text string in the image. Symbols that cannot be rendered
+ using the specified font are replaced by question marks. See #getTextSize for a text rendering code
+ example.
+
+
Parameters:
+
img - Image.
+
text - Text string to be drawn.
+
org - Bottom-left corner of the text string in the image.
+
fontFace - Font type, see #HersheyFonts.
+
fontScale - Font scale factor that is multiplied by the font-specific base size.
+
color - Text color.
+
thickness - Thickness of the lines used to draw a text.
+
lineType - Line type. See #LineTypes
+ it is at the top-left corner.
public static void putText(Mat img,
+ java.lang.String text,
+ Point org,
+ int fontFace,
+ double fontScale,
+ Scalar color,
+ int thickness,
+ int lineType,
+ boolean bottomLeftOrigin)
+
Draws a text string.
+
+ The function cv::putText renders the specified text string in the image. Symbols that cannot be rendered
+ using the specified font are replaced by question marks. See #getTextSize for a text rendering code
+ example.
+
+
Parameters:
+
img - Image.
+
text - Text string to be drawn.
+
org - Bottom-left corner of the text string in the image.
+
fontFace - Font type, see #HersheyFonts.
+
fontScale - Font scale factor that is multiplied by the font-specific base size.
+
color - Text color.
+
thickness - Thickness of the lines used to draw a text.
+
lineType - Line type. See #LineTypes
+
bottomLeftOrigin - When true, the image data origin is at the bottom-left corner. Otherwise,
+ it is at the top-left corner.
Blurs an image and downsamples it.
+
+ By default, size of the output image is computed as Size((src.cols+1)/2, (src.rows+1)/2), but in
+ any case, the following conditions should be satisfied:
+
+ \(\begin{array}{l} | \texttt{dstsize.width} *2-src.cols| \leq 2 \\ | \texttt{dstsize.height} *2-src.rows| \leq 2 \end{array}\)
+
+ The function performs the downsampling step of the Gaussian pyramid construction. First, it
+ convolves the source image with the kernel:
+
+ \(\frac{1}{256} \begin{bmatrix} 1 & 4 & 6 & 4 & 1 \\ 4 & 16 & 24 & 16 & 4 \\ 6 & 24 & 36 & 24 & 6 \\ 4 & 16 & 24 & 16 & 4 \\ 1 & 4 & 6 & 4 & 1 \end{bmatrix}\)
+
+ Then, it downsamples the image by rejecting even rows and columns.
+
+
Parameters:
+
src - input image.
+
dst - output image; it has the specified size and the same type as src.
public static void pyrDown(Mat src,
+ Mat dst,
+ Size dstsize)
+
Blurs an image and downsamples it.
+
+ By default, size of the output image is computed as Size((src.cols+1)/2, (src.rows+1)/2), but in
+ any case, the following conditions should be satisfied:
+
+ \(\begin{array}{l} | \texttt{dstsize.width} *2-src.cols| \leq 2 \\ | \texttt{dstsize.height} *2-src.rows| \leq 2 \end{array}\)
+
+ The function performs the downsampling step of the Gaussian pyramid construction. First, it
+ convolves the source image with the kernel:
+
+ \(\frac{1}{256} \begin{bmatrix} 1 & 4 & 6 & 4 & 1 \\ 4 & 16 & 24 & 16 & 4 \\ 6 & 24 & 36 & 24 & 6 \\ 4 & 16 & 24 & 16 & 4 \\ 1 & 4 & 6 & 4 & 1 \end{bmatrix}\)
+
+ Then, it downsamples the image by rejecting even rows and columns.
+
+
Parameters:
+
src - input image.
+
dst - output image; it has the specified size and the same type as src.
public static void pyrDown(Mat src,
+ Mat dst,
+ Size dstsize,
+ int borderType)
+
Blurs an image and downsamples it.
+
+ By default, size of the output image is computed as Size((src.cols+1)/2, (src.rows+1)/2), but in
+ any case, the following conditions should be satisfied:
+
+ \(\begin{array}{l} | \texttt{dstsize.width} *2-src.cols| \leq 2 \\ | \texttt{dstsize.height} *2-src.rows| \leq 2 \end{array}\)
+
+ The function performs the downsampling step of the Gaussian pyramid construction. First, it
+ convolves the source image with the kernel:
+
+ \(\frac{1}{256} \begin{bmatrix} 1 & 4 & 6 & 4 & 1 \\ 4 & 16 & 24 & 16 & 4 \\ 6 & 24 & 36 & 24 & 6 \\ 4 & 16 & 24 & 16 & 4 \\ 1 & 4 & 6 & 4 & 1 \end{bmatrix}\)
+
+ Then, it downsamples the image by rejecting even rows and columns.
+
+
Parameters:
+
src - input image.
+
dst - output image; it has the specified size and the same type as src.
+
dstsize - size of the output image.
+
borderType - Pixel extrapolation method, see #BorderTypes (#BORDER_CONSTANT isn't supported)
public static void pyrMeanShiftFiltering(Mat src,
+ Mat dst,
+ double sp,
+ double sr)
+
Performs initial step of meanshift segmentation of an image.
+
+ The function implements the filtering stage of meanshift segmentation, that is, the output of the
+ function is the filtered "posterized" image with color gradients and fine-grain texture flattened.
+ At every pixel (X,Y) of the input image (or down-sized input image, see below) the function executes
+ meanshift iterations, that is, the pixel (X,Y) neighborhood in the joint space-color hyperspace is
+ considered:
+
+ \((x,y): X- \texttt{sp} \le x \le X+ \texttt{sp} , Y- \texttt{sp} \le y \le Y+ \texttt{sp} , ||(R,G,B)-(r,g,b)|| \le \texttt{sr}\)
+
+ where (R,G,B) and (r,g,b) are the vectors of color components at (X,Y) and (x,y), respectively
+ (though, the algorithm does not depend on the color space used, so any 3-component color space can
+ be used instead). Over the neighborhood the average spatial value (X',Y') and average color vector
+ (R',G',B') are found and they act as the neighborhood center on the next iteration:
+
+ \((X,Y)~(X',Y'), (R,G,B)~(R',G',B').\)
+
+ After the iterations over, the color components of the initial pixel (that is, the pixel from where
+ the iterations started) are set to the final value (average color at the last iteration):
+
+ \(I(X,Y) <- (R*,G*,B*)\)
+
+ When maxLevel > 0, the gaussian pyramid of maxLevel+1 levels is built, and the above procedure is
+ run on the smallest layer first. After that, the results are propagated to the larger layer and the
+ iterations are run again only on those pixels where the layer colors differ by more than sr from the
+ lower-resolution layer of the pyramid. That makes boundaries of color regions sharper. Note that the
+ results will be actually different from the ones obtained by running the meanshift procedure on the
+ whole original image (i.e. when maxLevel==0).
+
+
Parameters:
+
src - The source 8-bit, 3-channel image.
+
dst - The destination image of the same format and the same size as the source.
public static void pyrMeanShiftFiltering(Mat src,
+ Mat dst,
+ double sp,
+ double sr,
+ int maxLevel)
+
Performs initial step of meanshift segmentation of an image.
+
+ The function implements the filtering stage of meanshift segmentation, that is, the output of the
+ function is the filtered "posterized" image with color gradients and fine-grain texture flattened.
+ At every pixel (X,Y) of the input image (or down-sized input image, see below) the function executes
+ meanshift iterations, that is, the pixel (X,Y) neighborhood in the joint space-color hyperspace is
+ considered:
+
+ \((x,y): X- \texttt{sp} \le x \le X+ \texttt{sp} , Y- \texttt{sp} \le y \le Y+ \texttt{sp} , ||(R,G,B)-(r,g,b)|| \le \texttt{sr}\)
+
+ where (R,G,B) and (r,g,b) are the vectors of color components at (X,Y) and (x,y), respectively
+ (though, the algorithm does not depend on the color space used, so any 3-component color space can
+ be used instead). Over the neighborhood the average spatial value (X',Y') and average color vector
+ (R',G',B') are found and they act as the neighborhood center on the next iteration:
+
+ \((X,Y)~(X',Y'), (R,G,B)~(R',G',B').\)
+
+ After the iterations over, the color components of the initial pixel (that is, the pixel from where
+ the iterations started) are set to the final value (average color at the last iteration):
+
+ \(I(X,Y) <- (R*,G*,B*)\)
+
+ When maxLevel > 0, the gaussian pyramid of maxLevel+1 levels is built, and the above procedure is
+ run on the smallest layer first. After that, the results are propagated to the larger layer and the
+ iterations are run again only on those pixels where the layer colors differ by more than sr from the
+ lower-resolution layer of the pyramid. That makes boundaries of color regions sharper. Note that the
+ results will be actually different from the ones obtained by running the meanshift procedure on the
+ whole original image (i.e. when maxLevel==0).
+
+
Parameters:
+
src - The source 8-bit, 3-channel image.
+
dst - The destination image of the same format and the same size as the source.
+
sp - The spatial window radius.
+
sr - The color window radius.
+
maxLevel - Maximum level of the pyramid for the segmentation.
public static void pyrMeanShiftFiltering(Mat src,
+ Mat dst,
+ double sp,
+ double sr,
+ int maxLevel,
+ TermCriteria termcrit)
+
Performs initial step of meanshift segmentation of an image.
+
+ The function implements the filtering stage of meanshift segmentation, that is, the output of the
+ function is the filtered "posterized" image with color gradients and fine-grain texture flattened.
+ At every pixel (X,Y) of the input image (or down-sized input image, see below) the function executes
+ meanshift iterations, that is, the pixel (X,Y) neighborhood in the joint space-color hyperspace is
+ considered:
+
+ \((x,y): X- \texttt{sp} \le x \le X+ \texttt{sp} , Y- \texttt{sp} \le y \le Y+ \texttt{sp} , ||(R,G,B)-(r,g,b)|| \le \texttt{sr}\)
+
+ where (R,G,B) and (r,g,b) are the vectors of color components at (X,Y) and (x,y), respectively
+ (though, the algorithm does not depend on the color space used, so any 3-component color space can
+ be used instead). Over the neighborhood the average spatial value (X',Y') and average color vector
+ (R',G',B') are found and they act as the neighborhood center on the next iteration:
+
+ \((X,Y)~(X',Y'), (R,G,B)~(R',G',B').\)
+
+ After the iterations over, the color components of the initial pixel (that is, the pixel from where
+ the iterations started) are set to the final value (average color at the last iteration):
+
+ \(I(X,Y) <- (R*,G*,B*)\)
+
+ When maxLevel > 0, the gaussian pyramid of maxLevel+1 levels is built, and the above procedure is
+ run on the smallest layer first. After that, the results are propagated to the larger layer and the
+ iterations are run again only on those pixels where the layer colors differ by more than sr from the
+ lower-resolution layer of the pyramid. That makes boundaries of color regions sharper. Note that the
+ results will be actually different from the ones obtained by running the meanshift procedure on the
+ whole original image (i.e. when maxLevel==0).
+
+
Parameters:
+
src - The source 8-bit, 3-channel image.
+
dst - The destination image of the same format and the same size as the source.
+
sp - The spatial window radius.
+
sr - The color window radius.
+
maxLevel - Maximum level of the pyramid for the segmentation.
+
termcrit - Termination criteria: when to stop meanshift iterations.
Upsamples an image and then blurs it.
+
+ By default, size of the output image is computed as Size(src.cols\*2, (src.rows\*2), but in any
+ case, the following conditions should be satisfied:
+
+ \(\begin{array}{l} | \texttt{dstsize.width} -src.cols*2| \leq ( \texttt{dstsize.width} \mod 2) \\ | \texttt{dstsize.height} -src.rows*2| \leq ( \texttt{dstsize.height} \mod 2) \end{array}\)
+
+ The function performs the upsampling step of the Gaussian pyramid construction, though it can
+ actually be used to construct the Laplacian pyramid. First, it upsamples the source image by
+ injecting even zero rows and columns and then convolves the result with the same kernel as in
+ pyrDown multiplied by 4.
+
+
Parameters:
+
src - input image.
+
dst - output image. It has the specified size and the same type as src .
public static void pyrUp(Mat src,
+ Mat dst,
+ Size dstsize)
+
Upsamples an image and then blurs it.
+
+ By default, size of the output image is computed as Size(src.cols\*2, (src.rows\*2), but in any
+ case, the following conditions should be satisfied:
+
+ \(\begin{array}{l} | \texttt{dstsize.width} -src.cols*2| \leq ( \texttt{dstsize.width} \mod 2) \\ | \texttt{dstsize.height} -src.rows*2| \leq ( \texttt{dstsize.height} \mod 2) \end{array}\)
+
+ The function performs the upsampling step of the Gaussian pyramid construction, though it can
+ actually be used to construct the Laplacian pyramid. First, it upsamples the source image by
+ injecting even zero rows and columns and then convolves the result with the same kernel as in
+ pyrDown multiplied by 4.
+
+
Parameters:
+
src - input image.
+
dst - output image. It has the specified size and the same type as src .
public static void pyrUp(Mat src,
+ Mat dst,
+ Size dstsize,
+ int borderType)
+
Upsamples an image and then blurs it.
+
+ By default, size of the output image is computed as Size(src.cols\*2, (src.rows\*2), but in any
+ case, the following conditions should be satisfied:
+
+ \(\begin{array}{l} | \texttt{dstsize.width} -src.cols*2| \leq ( \texttt{dstsize.width} \mod 2) \\ | \texttt{dstsize.height} -src.rows*2| \leq ( \texttt{dstsize.height} \mod 2) \end{array}\)
+
+ The function performs the upsampling step of the Gaussian pyramid construction, though it can
+ actually be used to construct the Laplacian pyramid. First, it upsamples the source image by
+ injecting even zero rows and columns and then convolves the result with the same kernel as in
+ pyrDown multiplied by 4.
+
+
Parameters:
+
src - input image.
+
dst - output image. It has the specified size and the same type as src .
+
dstsize - size of the output image.
+
borderType - Pixel extrapolation method, see #BorderTypes (only #BORDER_DEFAULT is supported)
public static void rectangle(Mat img,
+ Point pt1,
+ Point pt2,
+ Scalar color)
+
Draws a simple, thick, or filled up-right rectangle.
+
+ The function cv::rectangle draws a rectangle outline or a filled rectangle whose two opposite corners
+ are pt1 and pt2.
+
+
Parameters:
+
img - Image.
+
pt1 - Vertex of the rectangle.
+
pt2 - Vertex of the rectangle opposite to pt1 .
+
color - Rectangle color or brightness (grayscale image).
+ mean that the function has to draw a filled rectangle.
public static void rectangle(Mat img,
+ Point pt1,
+ Point pt2,
+ Scalar color,
+ int thickness)
+
Draws a simple, thick, or filled up-right rectangle.
+
+ The function cv::rectangle draws a rectangle outline or a filled rectangle whose two opposite corners
+ are pt1 and pt2.
+
+
Parameters:
+
img - Image.
+
pt1 - Vertex of the rectangle.
+
pt2 - Vertex of the rectangle opposite to pt1 .
+
color - Rectangle color or brightness (grayscale image).
+
thickness - Thickness of lines that make up the rectangle. Negative values, like #FILLED,
+ mean that the function has to draw a filled rectangle.
public static void rectangle(Mat img,
+ Point pt1,
+ Point pt2,
+ Scalar color,
+ int thickness,
+ int lineType)
+
Draws a simple, thick, or filled up-right rectangle.
+
+ The function cv::rectangle draws a rectangle outline or a filled rectangle whose two opposite corners
+ are pt1 and pt2.
+
+
Parameters:
+
img - Image.
+
pt1 - Vertex of the rectangle.
+
pt2 - Vertex of the rectangle opposite to pt1 .
+
color - Rectangle color or brightness (grayscale image).
+
thickness - Thickness of lines that make up the rectangle. Negative values, like #FILLED,
+ mean that the function has to draw a filled rectangle.
public static void rectangle(Mat img,
+ Point pt1,
+ Point pt2,
+ Scalar color,
+ int thickness,
+ int lineType,
+ int shift)
+
Draws a simple, thick, or filled up-right rectangle.
+
+ The function cv::rectangle draws a rectangle outline or a filled rectangle whose two opposite corners
+ are pt1 and pt2.
+
+
Parameters:
+
img - Image.
+
pt1 - Vertex of the rectangle.
+
pt2 - Vertex of the rectangle opposite to pt1 .
+
color - Rectangle color or brightness (grayscale image).
+
thickness - Thickness of lines that make up the rectangle. Negative values, like #FILLED,
+ mean that the function has to draw a filled rectangle.
+
lineType - Type of the line. See #LineTypes
+
shift - Number of fractional bits in the point coordinates.
public static void remap(Mat src,
+ Mat dst,
+ Mat map1,
+ Mat map2,
+ int interpolation)
+
Applies a generic geometrical transformation to an image.
+
+ The function remap transforms the source image using the specified map:
+
+ \(\texttt{dst} (x,y) = \texttt{src} (map_x(x,y),map_y(x,y))\)
+
+ where values of pixels with non-integer coordinates are computed using one of available
+ interpolation methods. \(map_x\) and \(map_y\) can be encoded as separate floating-point maps
+ in \(map_1\) and \(map_2\) respectively, or interleaved floating-point maps of \((x,y)\) in
+ \(map_1\), or fixed-point maps created by using #convertMaps. The reason you might want to
+ convert from floating to fixed-point representations of a map is that they can yield much faster
+ (\~2x) remapping operations. In the converted case, \(map_1\) contains pairs (cvFloor(x),
+ cvFloor(y)) and \(map_2\) contains indices in a table of interpolation coefficients.
+
+ This function cannot operate in-place.
+
+
Parameters:
+
src - Source image.
+
dst - Destination image. It has the same size as map1 and the same type as src .
+
map1 - The first map of either (x,y) points or just x values having the type CV_16SC2 ,
+ CV_32FC1, or CV_32FC2. See #convertMaps for details on converting a floating point
+ representation to fixed-point for speed.
+
map2 - The second map of y values having the type CV_16UC1, CV_32FC1, or none (empty map
+ if map1 is (x,y) points), respectively.
+
interpolation - Interpolation method (see #InterpolationFlags). The methods #INTER_AREA
+ and #INTER_LINEAR_EXACT are not supported by this function.
+ borderMode=#BORDER_TRANSPARENT, it means that the pixels in the destination image that
+ corresponds to the "outliers" in the source image are not modified by the function.
+ Note:
+ Due to current implementation limitations the size of an input and output images should be less than 32767x32767.
public static void remap(Mat src,
+ Mat dst,
+ Mat map1,
+ Mat map2,
+ int interpolation,
+ int borderMode)
+
Applies a generic geometrical transformation to an image.
+
+ The function remap transforms the source image using the specified map:
+
+ \(\texttt{dst} (x,y) = \texttt{src} (map_x(x,y),map_y(x,y))\)
+
+ where values of pixels with non-integer coordinates are computed using one of available
+ interpolation methods. \(map_x\) and \(map_y\) can be encoded as separate floating-point maps
+ in \(map_1\) and \(map_2\) respectively, or interleaved floating-point maps of \((x,y)\) in
+ \(map_1\), or fixed-point maps created by using #convertMaps. The reason you might want to
+ convert from floating to fixed-point representations of a map is that they can yield much faster
+ (\~2x) remapping operations. In the converted case, \(map_1\) contains pairs (cvFloor(x),
+ cvFloor(y)) and \(map_2\) contains indices in a table of interpolation coefficients.
+
+ This function cannot operate in-place.
+
+
Parameters:
+
src - Source image.
+
dst - Destination image. It has the same size as map1 and the same type as src .
+
map1 - The first map of either (x,y) points or just x values having the type CV_16SC2 ,
+ CV_32FC1, or CV_32FC2. See #convertMaps for details on converting a floating point
+ representation to fixed-point for speed.
+
map2 - The second map of y values having the type CV_16UC1, CV_32FC1, or none (empty map
+ if map1 is (x,y) points), respectively.
+
interpolation - Interpolation method (see #InterpolationFlags). The methods #INTER_AREA
+ and #INTER_LINEAR_EXACT are not supported by this function.
+
borderMode - Pixel extrapolation method (see #BorderTypes). When
+ borderMode=#BORDER_TRANSPARENT, it means that the pixels in the destination image that
+ corresponds to the "outliers" in the source image are not modified by the function.
+ Note:
+ Due to current implementation limitations the size of an input and output images should be less than 32767x32767.
public static void remap(Mat src,
+ Mat dst,
+ Mat map1,
+ Mat map2,
+ int interpolation,
+ int borderMode,
+ Scalar borderValue)
+
Applies a generic geometrical transformation to an image.
+
+ The function remap transforms the source image using the specified map:
+
+ \(\texttt{dst} (x,y) = \texttt{src} (map_x(x,y),map_y(x,y))\)
+
+ where values of pixels with non-integer coordinates are computed using one of available
+ interpolation methods. \(map_x\) and \(map_y\) can be encoded as separate floating-point maps
+ in \(map_1\) and \(map_2\) respectively, or interleaved floating-point maps of \((x,y)\) in
+ \(map_1\), or fixed-point maps created by using #convertMaps. The reason you might want to
+ convert from floating to fixed-point representations of a map is that they can yield much faster
+ (\~2x) remapping operations. In the converted case, \(map_1\) contains pairs (cvFloor(x),
+ cvFloor(y)) and \(map_2\) contains indices in a table of interpolation coefficients.
+
+ This function cannot operate in-place.
+
+
Parameters:
+
src - Source image.
+
dst - Destination image. It has the same size as map1 and the same type as src .
+
map1 - The first map of either (x,y) points or just x values having the type CV_16SC2 ,
+ CV_32FC1, or CV_32FC2. See #convertMaps for details on converting a floating point
+ representation to fixed-point for speed.
+
map2 - The second map of y values having the type CV_16UC1, CV_32FC1, or none (empty map
+ if map1 is (x,y) points), respectively.
+
interpolation - Interpolation method (see #InterpolationFlags). The methods #INTER_AREA
+ and #INTER_LINEAR_EXACT are not supported by this function.
+
borderMode - Pixel extrapolation method (see #BorderTypes). When
+ borderMode=#BORDER_TRANSPARENT, it means that the pixels in the destination image that
+ corresponds to the "outliers" in the source image are not modified by the function.
+
borderValue - Value used in case of a constant border. By default, it is 0.
+ Note:
+ Due to current implementation limitations the size of an input and output images should be less than 32767x32767.
public static void resize(Mat src,
+ Mat dst,
+ Size dsize)
+
Resizes an image.
+
+ The function resize resizes the image src down to or up to the specified size. Note that the
+ initial dst type or size are not taken into account. Instead, the size and type are derived from
+ the src,dsize,fx, and fy. If you want to resize src so that it fits the pre-created dst,
+ you may call the function as follows:
+
+ // explicitly specify dsize=dst.size(); fx and fy will be computed from that.
+ resize(src, dst, dst.size(), 0, 0, interpolation);
+
+ If you want to decimate the image by factor of 2 in each direction, you can call the function this
+ way:
+
+ // specify fx and fy and let the function compute the destination image size.
+ resize(src, dst, Size(), 0.5, 0.5, interpolation);
+
+ To shrink an image, it will generally look best with #INTER_AREA interpolation, whereas to
+ enlarge an image, it will generally look best with #INTER_CUBIC (slow) or #INTER_LINEAR
+ (faster but still looks OK).
+
+
Parameters:
+
src - input image.
+
dst - output image; it has the size dsize (when it is non-zero) or the size computed from
+ src.size(), fx, and fy; the type of dst is the same as of src.
+
dsize - output image size; if it equals zero (None in Python), it is computed as:
+ \(\texttt{dsize = Size(round(fx*src.cols), round(fy*src.rows))}\)
+ Either dsize or both fx and fy must be non-zero.
+ \(\texttt{(double)dsize.width/src.cols}\)
+ \(\texttt{(double)dsize.height/src.rows}\)
+
+ SEE: warpAffine, warpPerspective, remap
public static void resize(Mat src,
+ Mat dst,
+ Size dsize,
+ double fx)
+
Resizes an image.
+
+ The function resize resizes the image src down to or up to the specified size. Note that the
+ initial dst type or size are not taken into account. Instead, the size and type are derived from
+ the src,dsize,fx, and fy. If you want to resize src so that it fits the pre-created dst,
+ you may call the function as follows:
+
+ // explicitly specify dsize=dst.size(); fx and fy will be computed from that.
+ resize(src, dst, dst.size(), 0, 0, interpolation);
+
+ If you want to decimate the image by factor of 2 in each direction, you can call the function this
+ way:
+
+ // specify fx and fy and let the function compute the destination image size.
+ resize(src, dst, Size(), 0.5, 0.5, interpolation);
+
+ To shrink an image, it will generally look best with #INTER_AREA interpolation, whereas to
+ enlarge an image, it will generally look best with #INTER_CUBIC (slow) or #INTER_LINEAR
+ (faster but still looks OK).
+
+
Parameters:
+
src - input image.
+
dst - output image; it has the size dsize (when it is non-zero) or the size computed from
+ src.size(), fx, and fy; the type of dst is the same as of src.
+
dsize - output image size; if it equals zero (None in Python), it is computed as:
+ \(\texttt{dsize = Size(round(fx*src.cols), round(fy*src.rows))}\)
+ Either dsize or both fx and fy must be non-zero.
+
fx - scale factor along the horizontal axis; when it equals 0, it is computed as
+ \(\texttt{(double)dsize.width/src.cols}\)
+ \(\texttt{(double)dsize.height/src.rows}\)
+
+ SEE: warpAffine, warpPerspective, remap
public static void resize(Mat src,
+ Mat dst,
+ Size dsize,
+ double fx,
+ double fy)
+
Resizes an image.
+
+ The function resize resizes the image src down to or up to the specified size. Note that the
+ initial dst type or size are not taken into account. Instead, the size and type are derived from
+ the src,dsize,fx, and fy. If you want to resize src so that it fits the pre-created dst,
+ you may call the function as follows:
+
+ // explicitly specify dsize=dst.size(); fx and fy will be computed from that.
+ resize(src, dst, dst.size(), 0, 0, interpolation);
+
+ If you want to decimate the image by factor of 2 in each direction, you can call the function this
+ way:
+
+ // specify fx and fy and let the function compute the destination image size.
+ resize(src, dst, Size(), 0.5, 0.5, interpolation);
+
+ To shrink an image, it will generally look best with #INTER_AREA interpolation, whereas to
+ enlarge an image, it will generally look best with #INTER_CUBIC (slow) or #INTER_LINEAR
+ (faster but still looks OK).
+
+
Parameters:
+
src - input image.
+
dst - output image; it has the size dsize (when it is non-zero) or the size computed from
+ src.size(), fx, and fy; the type of dst is the same as of src.
+
dsize - output image size; if it equals zero (None in Python), it is computed as:
+ \(\texttt{dsize = Size(round(fx*src.cols), round(fy*src.rows))}\)
+ Either dsize or both fx and fy must be non-zero.
+
fx - scale factor along the horizontal axis; when it equals 0, it is computed as
+ \(\texttt{(double)dsize.width/src.cols}\)
+
fy - scale factor along the vertical axis; when it equals 0, it is computed as
+ \(\texttt{(double)dsize.height/src.rows}\)
+
+ SEE: warpAffine, warpPerspective, remap
public static void resize(Mat src,
+ Mat dst,
+ Size dsize,
+ double fx,
+ double fy,
+ int interpolation)
+
Resizes an image.
+
+ The function resize resizes the image src down to or up to the specified size. Note that the
+ initial dst type or size are not taken into account. Instead, the size and type are derived from
+ the src,dsize,fx, and fy. If you want to resize src so that it fits the pre-created dst,
+ you may call the function as follows:
+
+ // explicitly specify dsize=dst.size(); fx and fy will be computed from that.
+ resize(src, dst, dst.size(), 0, 0, interpolation);
+
+ If you want to decimate the image by factor of 2 in each direction, you can call the function this
+ way:
+
+ // specify fx and fy and let the function compute the destination image size.
+ resize(src, dst, Size(), 0.5, 0.5, interpolation);
+
+ To shrink an image, it will generally look best with #INTER_AREA interpolation, whereas to
+ enlarge an image, it will generally look best with #INTER_CUBIC (slow) or #INTER_LINEAR
+ (faster but still looks OK).
+
+
Parameters:
+
src - input image.
+
dst - output image; it has the size dsize (when it is non-zero) or the size computed from
+ src.size(), fx, and fy; the type of dst is the same as of src.
+
dsize - output image size; if it equals zero (None in Python), it is computed as:
+ \(\texttt{dsize = Size(round(fx*src.cols), round(fy*src.rows))}\)
+ Either dsize or both fx and fy must be non-zero.
+
fx - scale factor along the horizontal axis; when it equals 0, it is computed as
+ \(\texttt{(double)dsize.width/src.cols}\)
+
fy - scale factor along the vertical axis; when it equals 0, it is computed as
+ \(\texttt{(double)dsize.height/src.rows}\)
public static int rotatedRectangleIntersection(RotatedRect rect1,
+ RotatedRect rect2,
+ Mat intersectingRegion)
+
Finds out if there is any intersection between two rotated rectangles.
+
+ If there is then the vertices of the intersecting region are returned as well.
+
+ Below are some examples of intersection configurations. The hatched pattern indicates the
+ intersecting region and the red vertices are returned by the function.
+
+ 
+
+
Parameters:
+
rect1 - First rectangle
+
rect2 - Second rectangle
+
intersectingRegion - The output array of the vertices of the intersecting region. It returns
+ at most 8 vertices. Stored as std::vector<cv::Point2f> or cv::Mat as Mx1 of type CV_32FC2.
public static void Scharr(Mat src,
+ Mat dst,
+ int ddepth,
+ int dx,
+ int dy)
+
Calculates the first x- or y- image derivative using Scharr operator.
+
+ The function computes the first x- or y- spatial image derivative using the Scharr operator. The
+ call
+
+ \(\texttt{Scharr(src, dst, ddepth, dx, dy, scale, delta, borderType)}\)
+
+ is equivalent to
+
+ \(\texttt{Sobel(src, dst, ddepth, dx, dy, FILTER_SCHARR, scale, delta, borderType)} .\)
+
+
Parameters:
+
src - input image.
+
dst - output image of the same size and the same number of channels as src.
+
ddepth - output image depth, see REF: filter_depths "combinations"
+
dx - order of the derivative x.
+
dy - order of the derivative y.
+ applied (see #getDerivKernels for details).
+ SEE: cartToPolar
public static void Scharr(Mat src,
+ Mat dst,
+ int ddepth,
+ int dx,
+ int dy,
+ double scale)
+
Calculates the first x- or y- image derivative using Scharr operator.
+
+ The function computes the first x- or y- spatial image derivative using the Scharr operator. The
+ call
+
+ \(\texttt{Scharr(src, dst, ddepth, dx, dy, scale, delta, borderType)}\)
+
+ is equivalent to
+
+ \(\texttt{Sobel(src, dst, ddepth, dx, dy, FILTER_SCHARR, scale, delta, borderType)} .\)
+
+
Parameters:
+
src - input image.
+
dst - output image of the same size and the same number of channels as src.
+
ddepth - output image depth, see REF: filter_depths "combinations"
+
dx - order of the derivative x.
+
dy - order of the derivative y.
+
scale - optional scale factor for the computed derivative values; by default, no scaling is
+ applied (see #getDerivKernels for details).
+ SEE: cartToPolar
public static void Scharr(Mat src,
+ Mat dst,
+ int ddepth,
+ int dx,
+ int dy,
+ double scale,
+ double delta)
+
Calculates the first x- or y- image derivative using Scharr operator.
+
+ The function computes the first x- or y- spatial image derivative using the Scharr operator. The
+ call
+
+ \(\texttt{Scharr(src, dst, ddepth, dx, dy, scale, delta, borderType)}\)
+
+ is equivalent to
+
+ \(\texttt{Sobel(src, dst, ddepth, dx, dy, FILTER_SCHARR, scale, delta, borderType)} .\)
+
+
Parameters:
+
src - input image.
+
dst - output image of the same size and the same number of channels as src.
+
ddepth - output image depth, see REF: filter_depths "combinations"
+
dx - order of the derivative x.
+
dy - order of the derivative y.
+
scale - optional scale factor for the computed derivative values; by default, no scaling is
+ applied (see #getDerivKernels for details).
+
delta - optional delta value that is added to the results prior to storing them in dst.
+ SEE: cartToPolar
public static void Scharr(Mat src,
+ Mat dst,
+ int ddepth,
+ int dx,
+ int dy,
+ double scale,
+ double delta,
+ int borderType)
+
Calculates the first x- or y- image derivative using Scharr operator.
+
+ The function computes the first x- or y- spatial image derivative using the Scharr operator. The
+ call
+
+ \(\texttt{Scharr(src, dst, ddepth, dx, dy, scale, delta, borderType)}\)
+
+ is equivalent to
+
+ \(\texttt{Sobel(src, dst, ddepth, dx, dy, FILTER_SCHARR, scale, delta, borderType)} .\)
+
+
Parameters:
+
src - input image.
+
dst - output image of the same size and the same number of channels as src.
+
ddepth - output image depth, see REF: filter_depths "combinations"
+
dx - order of the derivative x.
+
dy - order of the derivative y.
+
scale - optional scale factor for the computed derivative values; by default, no scaling is
+ applied (see #getDerivKernels for details).
+
delta - optional delta value that is added to the results prior to storing them in dst.
+
borderType - pixel extrapolation method, see #BorderTypes. #BORDER_WRAP is not supported.
+ SEE: cartToPolar
public static void sepFilter2D(Mat src,
+ Mat dst,
+ int ddepth,
+ Mat kernelX,
+ Mat kernelY)
+
Applies a separable linear filter to an image.
+
+ The function applies a separable linear filter to the image. That is, first, every row of src is
+ filtered with the 1D kernel kernelX. Then, every column of the result is filtered with the 1D
+ kernel kernelY. The final result shifted by delta is stored in dst .
+
+
Parameters:
+
src - Source image.
+
dst - Destination image of the same size and the same number of channels as src .
+
ddepth - Destination image depth, see REF: filter_depths "combinations"
+
kernelX - Coefficients for filtering each row.
+
kernelY - Coefficients for filtering each column.
+ is at the kernel center.
+ SEE: filter2D, Sobel, GaussianBlur, boxFilter, blur
public static void sepFilter2D(Mat src,
+ Mat dst,
+ int ddepth,
+ Mat kernelX,
+ Mat kernelY,
+ Point anchor)
+
Applies a separable linear filter to an image.
+
+ The function applies a separable linear filter to the image. That is, first, every row of src is
+ filtered with the 1D kernel kernelX. Then, every column of the result is filtered with the 1D
+ kernel kernelY. The final result shifted by delta is stored in dst .
+
+
Parameters:
+
src - Source image.
+
dst - Destination image of the same size and the same number of channels as src .
+
ddepth - Destination image depth, see REF: filter_depths "combinations"
+
kernelX - Coefficients for filtering each row.
+
kernelY - Coefficients for filtering each column.
+
anchor - Anchor position within the kernel. The default value \((-1,-1)\) means that the anchor
+ is at the kernel center.
+ SEE: filter2D, Sobel, GaussianBlur, boxFilter, blur
public static void sepFilter2D(Mat src,
+ Mat dst,
+ int ddepth,
+ Mat kernelX,
+ Mat kernelY,
+ Point anchor,
+ double delta)
+
Applies a separable linear filter to an image.
+
+ The function applies a separable linear filter to the image. That is, first, every row of src is
+ filtered with the 1D kernel kernelX. Then, every column of the result is filtered with the 1D
+ kernel kernelY. The final result shifted by delta is stored in dst .
+
+
Parameters:
+
src - Source image.
+
dst - Destination image of the same size and the same number of channels as src .
+
ddepth - Destination image depth, see REF: filter_depths "combinations"
+
kernelX - Coefficients for filtering each row.
+
kernelY - Coefficients for filtering each column.
+
anchor - Anchor position within the kernel. The default value \((-1,-1)\) means that the anchor
+ is at the kernel center.
+
delta - Value added to the filtered results before storing them.
+ SEE: filter2D, Sobel, GaussianBlur, boxFilter, blur
public static void sepFilter2D(Mat src,
+ Mat dst,
+ int ddepth,
+ Mat kernelX,
+ Mat kernelY,
+ Point anchor,
+ double delta,
+ int borderType)
+
Applies a separable linear filter to an image.
+
+ The function applies a separable linear filter to the image. That is, first, every row of src is
+ filtered with the 1D kernel kernelX. Then, every column of the result is filtered with the 1D
+ kernel kernelY. The final result shifted by delta is stored in dst .
+
+
Parameters:
+
src - Source image.
+
dst - Destination image of the same size and the same number of channels as src .
+
ddepth - Destination image depth, see REF: filter_depths "combinations"
+
kernelX - Coefficients for filtering each row.
+
kernelY - Coefficients for filtering each column.
+
anchor - Anchor position within the kernel. The default value \((-1,-1)\) means that the anchor
+ is at the kernel center.
+
delta - Value added to the filtered results before storing them.
+
borderType - Pixel extrapolation method, see #BorderTypes. #BORDER_WRAP is not supported.
+ SEE: filter2D, Sobel, GaussianBlur, boxFilter, blur
public static void Sobel(Mat src,
+ Mat dst,
+ int ddepth,
+ int dx,
+ int dy)
+
Calculates the first, second, third, or mixed image derivatives using an extended Sobel operator.
+
+ In all cases except one, the \(\texttt{ksize} \times \texttt{ksize}\) separable kernel is used to
+ calculate the derivative. When \(\texttt{ksize = 1}\), the \(3 \times 1\) or \(1 \times 3\)
+ kernel is used (that is, no Gaussian smoothing is done). ksize = 1 can only be used for the first
+ or the second x- or y- derivatives.
+
+ There is also the special value ksize = #FILTER_SCHARR (-1) that corresponds to the \(3\times3\) Scharr
+ filter that may give more accurate results than the \(3\times3\) Sobel. The Scharr aperture is
+
+ \(\vecthreethree{-3}{0}{3}{-10}{0}{10}{-3}{0}{3}\)
+
+ for the x-derivative, or transposed for the y-derivative.
+
+ The function calculates an image derivative by convolving the image with the appropriate kernel:
+
+ \(\texttt{dst} = \frac{\partial^{xorder+yorder} \texttt{src}}{\partial x^{xorder} \partial y^{yorder}}\)
+
+ The Sobel operators combine Gaussian smoothing and differentiation, so the result is more or less
+ resistant to the noise. Most often, the function is called with ( xorder = 1, yorder = 0, ksize = 3)
+ or ( xorder = 0, yorder = 1, ksize = 3) to calculate the first x- or y- image derivative. The first
+ case corresponds to a kernel of:
+
+ \(\vecthreethree{-1}{0}{1}{-2}{0}{2}{-1}{0}{1}\)
+
+ The second case corresponds to a kernel of:
+
+ \(\vecthreethree{-1}{-2}{-1}{0}{0}{0}{1}{2}{1}\)
+
+
Parameters:
+
src - input image.
+
dst - output image of the same size and the same number of channels as src .
+
ddepth - output image depth, see REF: filter_depths "combinations"; in the case of
+ 8-bit input images it will result in truncated derivatives.
+
dx - order of the derivative x.
+
dy - order of the derivative y.
+ applied (see #getDerivKernels for details).
+ SEE: Scharr, Laplacian, sepFilter2D, filter2D, GaussianBlur, cartToPolar
public static void Sobel(Mat src,
+ Mat dst,
+ int ddepth,
+ int dx,
+ int dy,
+ int ksize)
+
Calculates the first, second, third, or mixed image derivatives using an extended Sobel operator.
+
+ In all cases except one, the \(\texttt{ksize} \times \texttt{ksize}\) separable kernel is used to
+ calculate the derivative. When \(\texttt{ksize = 1}\), the \(3 \times 1\) or \(1 \times 3\)
+ kernel is used (that is, no Gaussian smoothing is done). ksize = 1 can only be used for the first
+ or the second x- or y- derivatives.
+
+ There is also the special value ksize = #FILTER_SCHARR (-1) that corresponds to the \(3\times3\) Scharr
+ filter that may give more accurate results than the \(3\times3\) Sobel. The Scharr aperture is
+
+ \(\vecthreethree{-3}{0}{3}{-10}{0}{10}{-3}{0}{3}\)
+
+ for the x-derivative, or transposed for the y-derivative.
+
+ The function calculates an image derivative by convolving the image with the appropriate kernel:
+
+ \(\texttt{dst} = \frac{\partial^{xorder+yorder} \texttt{src}}{\partial x^{xorder} \partial y^{yorder}}\)
+
+ The Sobel operators combine Gaussian smoothing and differentiation, so the result is more or less
+ resistant to the noise. Most often, the function is called with ( xorder = 1, yorder = 0, ksize = 3)
+ or ( xorder = 0, yorder = 1, ksize = 3) to calculate the first x- or y- image derivative. The first
+ case corresponds to a kernel of:
+
+ \(\vecthreethree{-1}{0}{1}{-2}{0}{2}{-1}{0}{1}\)
+
+ The second case corresponds to a kernel of:
+
+ \(\vecthreethree{-1}{-2}{-1}{0}{0}{0}{1}{2}{1}\)
+
+
Parameters:
+
src - input image.
+
dst - output image of the same size and the same number of channels as src .
+
ddepth - output image depth, see REF: filter_depths "combinations"; in the case of
+ 8-bit input images it will result in truncated derivatives.
+
dx - order of the derivative x.
+
dy - order of the derivative y.
+
ksize - size of the extended Sobel kernel; it must be 1, 3, 5, or 7.
+ applied (see #getDerivKernels for details).
+ SEE: Scharr, Laplacian, sepFilter2D, filter2D, GaussianBlur, cartToPolar
public static void Sobel(Mat src,
+ Mat dst,
+ int ddepth,
+ int dx,
+ int dy,
+ int ksize,
+ double scale)
+
Calculates the first, second, third, or mixed image derivatives using an extended Sobel operator.
+
+ In all cases except one, the \(\texttt{ksize} \times \texttt{ksize}\) separable kernel is used to
+ calculate the derivative. When \(\texttt{ksize = 1}\), the \(3 \times 1\) or \(1 \times 3\)
+ kernel is used (that is, no Gaussian smoothing is done). ksize = 1 can only be used for the first
+ or the second x- or y- derivatives.
+
+ There is also the special value ksize = #FILTER_SCHARR (-1) that corresponds to the \(3\times3\) Scharr
+ filter that may give more accurate results than the \(3\times3\) Sobel. The Scharr aperture is
+
+ \(\vecthreethree{-3}{0}{3}{-10}{0}{10}{-3}{0}{3}\)
+
+ for the x-derivative, or transposed for the y-derivative.
+
+ The function calculates an image derivative by convolving the image with the appropriate kernel:
+
+ \(\texttt{dst} = \frac{\partial^{xorder+yorder} \texttt{src}}{\partial x^{xorder} \partial y^{yorder}}\)
+
+ The Sobel operators combine Gaussian smoothing and differentiation, so the result is more or less
+ resistant to the noise. Most often, the function is called with ( xorder = 1, yorder = 0, ksize = 3)
+ or ( xorder = 0, yorder = 1, ksize = 3) to calculate the first x- or y- image derivative. The first
+ case corresponds to a kernel of:
+
+ \(\vecthreethree{-1}{0}{1}{-2}{0}{2}{-1}{0}{1}\)
+
+ The second case corresponds to a kernel of:
+
+ \(\vecthreethree{-1}{-2}{-1}{0}{0}{0}{1}{2}{1}\)
+
+
Parameters:
+
src - input image.
+
dst - output image of the same size and the same number of channels as src .
+
ddepth - output image depth, see REF: filter_depths "combinations"; in the case of
+ 8-bit input images it will result in truncated derivatives.
+
dx - order of the derivative x.
+
dy - order of the derivative y.
+
ksize - size of the extended Sobel kernel; it must be 1, 3, 5, or 7.
+
scale - optional scale factor for the computed derivative values; by default, no scaling is
+ applied (see #getDerivKernels for details).
+ SEE: Scharr, Laplacian, sepFilter2D, filter2D, GaussianBlur, cartToPolar
public static void Sobel(Mat src,
+ Mat dst,
+ int ddepth,
+ int dx,
+ int dy,
+ int ksize,
+ double scale,
+ double delta)
+
Calculates the first, second, third, or mixed image derivatives using an extended Sobel operator.
+
+ In all cases except one, the \(\texttt{ksize} \times \texttt{ksize}\) separable kernel is used to
+ calculate the derivative. When \(\texttt{ksize = 1}\), the \(3 \times 1\) or \(1 \times 3\)
+ kernel is used (that is, no Gaussian smoothing is done). ksize = 1 can only be used for the first
+ or the second x- or y- derivatives.
+
+ There is also the special value ksize = #FILTER_SCHARR (-1) that corresponds to the \(3\times3\) Scharr
+ filter that may give more accurate results than the \(3\times3\) Sobel. The Scharr aperture is
+
+ \(\vecthreethree{-3}{0}{3}{-10}{0}{10}{-3}{0}{3}\)
+
+ for the x-derivative, or transposed for the y-derivative.
+
+ The function calculates an image derivative by convolving the image with the appropriate kernel:
+
+ \(\texttt{dst} = \frac{\partial^{xorder+yorder} \texttt{src}}{\partial x^{xorder} \partial y^{yorder}}\)
+
+ The Sobel operators combine Gaussian smoothing and differentiation, so the result is more or less
+ resistant to the noise. Most often, the function is called with ( xorder = 1, yorder = 0, ksize = 3)
+ or ( xorder = 0, yorder = 1, ksize = 3) to calculate the first x- or y- image derivative. The first
+ case corresponds to a kernel of:
+
+ \(\vecthreethree{-1}{0}{1}{-2}{0}{2}{-1}{0}{1}\)
+
+ The second case corresponds to a kernel of:
+
+ \(\vecthreethree{-1}{-2}{-1}{0}{0}{0}{1}{2}{1}\)
+
+
Parameters:
+
src - input image.
+
dst - output image of the same size and the same number of channels as src .
+
ddepth - output image depth, see REF: filter_depths "combinations"; in the case of
+ 8-bit input images it will result in truncated derivatives.
+
dx - order of the derivative x.
+
dy - order of the derivative y.
+
ksize - size of the extended Sobel kernel; it must be 1, 3, 5, or 7.
+
scale - optional scale factor for the computed derivative values; by default, no scaling is
+ applied (see #getDerivKernels for details).
+
delta - optional delta value that is added to the results prior to storing them in dst.
+ SEE: Scharr, Laplacian, sepFilter2D, filter2D, GaussianBlur, cartToPolar
public static void Sobel(Mat src,
+ Mat dst,
+ int ddepth,
+ int dx,
+ int dy,
+ int ksize,
+ double scale,
+ double delta,
+ int borderType)
+
Calculates the first, second, third, or mixed image derivatives using an extended Sobel operator.
+
+ In all cases except one, the \(\texttt{ksize} \times \texttt{ksize}\) separable kernel is used to
+ calculate the derivative. When \(\texttt{ksize = 1}\), the \(3 \times 1\) or \(1 \times 3\)
+ kernel is used (that is, no Gaussian smoothing is done). ksize = 1 can only be used for the first
+ or the second x- or y- derivatives.
+
+ There is also the special value ksize = #FILTER_SCHARR (-1) that corresponds to the \(3\times3\) Scharr
+ filter that may give more accurate results than the \(3\times3\) Sobel. The Scharr aperture is
+
+ \(\vecthreethree{-3}{0}{3}{-10}{0}{10}{-3}{0}{3}\)
+
+ for the x-derivative, or transposed for the y-derivative.
+
+ The function calculates an image derivative by convolving the image with the appropriate kernel:
+
+ \(\texttt{dst} = \frac{\partial^{xorder+yorder} \texttt{src}}{\partial x^{xorder} \partial y^{yorder}}\)
+
+ The Sobel operators combine Gaussian smoothing and differentiation, so the result is more or less
+ resistant to the noise. Most often, the function is called with ( xorder = 1, yorder = 0, ksize = 3)
+ or ( xorder = 0, yorder = 1, ksize = 3) to calculate the first x- or y- image derivative. The first
+ case corresponds to a kernel of:
+
+ \(\vecthreethree{-1}{0}{1}{-2}{0}{2}{-1}{0}{1}\)
+
+ The second case corresponds to a kernel of:
+
+ \(\vecthreethree{-1}{-2}{-1}{0}{0}{0}{1}{2}{1}\)
+
+
Parameters:
+
src - input image.
+
dst - output image of the same size and the same number of channels as src .
+
ddepth - output image depth, see REF: filter_depths "combinations"; in the case of
+ 8-bit input images it will result in truncated derivatives.
+
dx - order of the derivative x.
+
dy - order of the derivative y.
+
ksize - size of the extended Sobel kernel; it must be 1, 3, 5, or 7.
+
scale - optional scale factor for the computed derivative values; by default, no scaling is
+ applied (see #getDerivKernels for details).
+
delta - optional delta value that is added to the results prior to storing them in dst.
+
borderType - pixel extrapolation method, see #BorderTypes. #BORDER_WRAP is not supported.
+ SEE: Scharr, Laplacian, sepFilter2D, filter2D, GaussianBlur, cartToPolar
public static void spatialGradient(Mat src,
+ Mat dx,
+ Mat dy)
+
Calculates the first order image derivative in both x and y using a Sobel operator
+
+ Equivalent to calling:
+
+
+ Sobel( src, dx, CV_16SC1, 1, 0, 3 );
+ Sobel( src, dy, CV_16SC1, 0, 1, 3 );
+
+
+
Parameters:
+
src - input image.
+
dx - output image with first-order derivative in x.
+
dy - output image with first-order derivative in y.
+ Only #BORDER_DEFAULT=#BORDER_REFLECT_101 and #BORDER_REPLICATE are supported.
+
+ SEE: Sobel
public static void spatialGradient(Mat src,
+ Mat dx,
+ Mat dy,
+ int ksize)
+
Calculates the first order image derivative in both x and y using a Sobel operator
+
+ Equivalent to calling:
+
+
+ Sobel( src, dx, CV_16SC1, 1, 0, 3 );
+ Sobel( src, dy, CV_16SC1, 0, 1, 3 );
+
+
+
Parameters:
+
src - input image.
+
dx - output image with first-order derivative in x.
+
dy - output image with first-order derivative in y.
+
ksize - size of Sobel kernel. It must be 3.
+ Only #BORDER_DEFAULT=#BORDER_REFLECT_101 and #BORDER_REPLICATE are supported.
+
+ SEE: Sobel
public static void spatialGradient(Mat src,
+ Mat dx,
+ Mat dy,
+ int ksize,
+ int borderType)
+
Calculates the first order image derivative in both x and y using a Sobel operator
+
+ Equivalent to calling:
+
+
+ Sobel( src, dx, CV_16SC1, 1, 0, 3 );
+ Sobel( src, dy, CV_16SC1, 0, 1, 3 );
+
+
+
Parameters:
+
src - input image.
+
dx - output image with first-order derivative in x.
+
dy - output image with first-order derivative in y.
+
ksize - size of Sobel kernel. It must be 3.
+
borderType - pixel extrapolation method, see #BorderTypes.
+ Only #BORDER_DEFAULT=#BORDER_REFLECT_101 and #BORDER_REPLICATE are supported.
+
+ SEE: Sobel
public static void sqrBoxFilter(Mat src,
+ Mat dst,
+ int ddepth,
+ Size ksize)
+
Calculates the normalized sum of squares of the pixel values overlapping the filter.
+
+ For every pixel \( (x, y) \) in the source image, the function calculates the sum of squares of those neighboring
+ pixel values which overlap the filter placed over the pixel \( (x, y) \).
+
+ The unnormalized square box filter can be useful in computing local image statistics such as the local
+ variance and standard deviation around the neighborhood of a pixel.
+
+
Parameters:
+
src - input image
+
dst - output image of the same size and type as src
+
ddepth - the output image depth (-1 to use src.depth())
public static void sqrBoxFilter(Mat src,
+ Mat dst,
+ int ddepth,
+ Size ksize,
+ Point anchor)
+
Calculates the normalized sum of squares of the pixel values overlapping the filter.
+
+ For every pixel \( (x, y) \) in the source image, the function calculates the sum of squares of those neighboring
+ pixel values which overlap the filter placed over the pixel \( (x, y) \).
+
+ The unnormalized square box filter can be useful in computing local image statistics such as the local
+ variance and standard deviation around the neighborhood of a pixel.
+
+
Parameters:
+
src - input image
+
dst - output image of the same size and type as src
+
ddepth - the output image depth (-1 to use src.depth())
+
ksize - kernel size
+
anchor - kernel anchor point. The default value of Point(-1, -1) denotes that the anchor is at the kernel
+ center.
+ SEE: boxFilter
public static void sqrBoxFilter(Mat src,
+ Mat dst,
+ int ddepth,
+ Size ksize,
+ Point anchor,
+ boolean normalize)
+
Calculates the normalized sum of squares of the pixel values overlapping the filter.
+
+ For every pixel \( (x, y) \) in the source image, the function calculates the sum of squares of those neighboring
+ pixel values which overlap the filter placed over the pixel \( (x, y) \).
+
+ The unnormalized square box filter can be useful in computing local image statistics such as the local
+ variance and standard deviation around the neighborhood of a pixel.
+
+
Parameters:
+
src - input image
+
dst - output image of the same size and type as src
+
ddepth - the output image depth (-1 to use src.depth())
+
ksize - kernel size
+
anchor - kernel anchor point. The default value of Point(-1, -1) denotes that the anchor is at the kernel
+ center.
+
normalize - flag, specifying whether the kernel is to be normalized by it's area or not.
+ SEE: boxFilter
public static void sqrBoxFilter(Mat src,
+ Mat dst,
+ int ddepth,
+ Size ksize,
+ Point anchor,
+ boolean normalize,
+ int borderType)
+
Calculates the normalized sum of squares of the pixel values overlapping the filter.
+
+ For every pixel \( (x, y) \) in the source image, the function calculates the sum of squares of those neighboring
+ pixel values which overlap the filter placed over the pixel \( (x, y) \).
+
+ The unnormalized square box filter can be useful in computing local image statistics such as the local
+ variance and standard deviation around the neighborhood of a pixel.
+
+
Parameters:
+
src - input image
+
dst - output image of the same size and type as src
+
ddepth - the output image depth (-1 to use src.depth())
+
ksize - kernel size
+
anchor - kernel anchor point. The default value of Point(-1, -1) denotes that the anchor is at the kernel
+ center.
+
normalize - flag, specifying whether the kernel is to be normalized by it's area or not.
+
borderType - border mode used to extrapolate pixels outside of the image, see #BorderTypes. #BORDER_WRAP is not supported.
+ SEE: boxFilter
public static void stackBlur(Mat src,
+ Mat dst,
+ Size ksize)
+
Blurs an image using the stackBlur.
+
+ The function applies and stackBlur to an image.
+ stackBlur can generate similar results as Gaussian blur, and the time consumption does not increase with the increase of kernel size.
+ It creates a kind of moving stack of colors whilst scanning through the image. Thereby it just has to add one new block of color to the right side
+ of the stack and remove the leftmost color. The remaining colors on the topmost layer of the stack are either added on or reduced by one,
+ depending on if they are on the right or on the left side of the stack. The only supported borderType is BORDER_REPLICATE.
+ Original paper was proposed by Mario Klingemann, which can be found http://underdestruction.com/2004/02/25/stackblur-2004.
+
+
Parameters:
+
src - input image. The number of channels can be arbitrary, but the depth should be one of
+ CV_8U, CV_16U, CV_16S or CV_32F.
+
dst - output image of the same size and type as src.
+
ksize - stack-blurring kernel size. The ksize.width and ksize.height can differ but they both must be
+ positive and odd.
public static double threshold(Mat src,
+ Mat dst,
+ double thresh,
+ double maxval,
+ int type)
+
Applies a fixed-level threshold to each array element.
+
+ The function applies fixed-level thresholding to a multiple-channel array. The function is typically
+ used to get a bi-level (binary) image out of a grayscale image ( #compare could be also used for
+ this purpose) or for removing a noise, that is, filtering out pixels with too small or too large
+ values. There are several types of thresholding supported by the function. They are determined by
+ type parameter.
+
+ Also, the special values #THRESH_OTSU or #THRESH_TRIANGLE may be combined with one of the
+ above values. In these cases, the function determines the optimal threshold value using the Otsu's
+ or Triangle algorithm and uses it instead of the specified thresh.
+
+ Note: Currently, the Otsu's and Triangle methods are implemented only for 8-bit single-channel images.
+
+
Parameters:
+
src - input array (multiple-channel, 8-bit or 32-bit floating point).
+
dst - output array of the same size and type and the same number of channels as src.
+
thresh - threshold value.
+
maxval - maximum value to use with the #THRESH_BINARY and #THRESH_BINARY_INV thresholding
+ types.
+
type - thresholding type (see #ThresholdTypes).
+
Returns:
+
the computed threshold value if Otsu's or Triangle methods used.
+
+ SEE: adaptiveThreshold, findContours, compare, min, max
public static void warpAffine(Mat src,
+ Mat dst,
+ Mat M,
+ Size dsize)
+
Applies an affine transformation to an image.
+
+ The function warpAffine transforms the source image using the specified matrix:
+
+ \(\texttt{dst} (x,y) = \texttt{src} ( \texttt{M} _{11} x + \texttt{M} _{12} y + \texttt{M} _{13}, \texttt{M} _{21} x + \texttt{M} _{22} y + \texttt{M} _{23})\)
+
+ when the flag #WARP_INVERSE_MAP is set. Otherwise, the transformation is first inverted
+ with #invertAffineTransform and then put in the formula above instead of M. The function cannot
+ operate in-place.
+
+
Parameters:
+
src - input image.
+
dst - output image that has the size dsize and the same type as src .
+
M - \(2\times 3\) transformation matrix.
+
dsize - size of the output image.
+ flag #WARP_INVERSE_MAP that means that M is the inverse transformation (
+ \(\texttt{dst}\rightarrow\texttt{src}\) ).
+ borderMode=#BORDER_TRANSPARENT, it means that the pixels in the destination image corresponding to
+ the "outliers" in the source image are not modified by the function.
+
+ SEE: warpPerspective, resize, remap, getRectSubPix, transform
public static void warpAffine(Mat src,
+ Mat dst,
+ Mat M,
+ Size dsize,
+ int flags)
+
Applies an affine transformation to an image.
+
+ The function warpAffine transforms the source image using the specified matrix:
+
+ \(\texttt{dst} (x,y) = \texttt{src} ( \texttt{M} _{11} x + \texttt{M} _{12} y + \texttt{M} _{13}, \texttt{M} _{21} x + \texttt{M} _{22} y + \texttt{M} _{23})\)
+
+ when the flag #WARP_INVERSE_MAP is set. Otherwise, the transformation is first inverted
+ with #invertAffineTransform and then put in the formula above instead of M. The function cannot
+ operate in-place.
+
+
Parameters:
+
src - input image.
+
dst - output image that has the size dsize and the same type as src .
+
M - \(2\times 3\) transformation matrix.
+
dsize - size of the output image.
+
flags - combination of interpolation methods (see #InterpolationFlags) and the optional
+ flag #WARP_INVERSE_MAP that means that M is the inverse transformation (
+ \(\texttt{dst}\rightarrow\texttt{src}\) ).
+ borderMode=#BORDER_TRANSPARENT, it means that the pixels in the destination image corresponding to
+ the "outliers" in the source image are not modified by the function.
+
+ SEE: warpPerspective, resize, remap, getRectSubPix, transform
public static void warpAffine(Mat src,
+ Mat dst,
+ Mat M,
+ Size dsize,
+ int flags,
+ int borderMode)
+
Applies an affine transformation to an image.
+
+ The function warpAffine transforms the source image using the specified matrix:
+
+ \(\texttt{dst} (x,y) = \texttt{src} ( \texttt{M} _{11} x + \texttt{M} _{12} y + \texttt{M} _{13}, \texttt{M} _{21} x + \texttt{M} _{22} y + \texttt{M} _{23})\)
+
+ when the flag #WARP_INVERSE_MAP is set. Otherwise, the transformation is first inverted
+ with #invertAffineTransform and then put in the formula above instead of M. The function cannot
+ operate in-place.
+
+
Parameters:
+
src - input image.
+
dst - output image that has the size dsize and the same type as src .
+
M - \(2\times 3\) transformation matrix.
+
dsize - size of the output image.
+
flags - combination of interpolation methods (see #InterpolationFlags) and the optional
+ flag #WARP_INVERSE_MAP that means that M is the inverse transformation (
+ \(\texttt{dst}\rightarrow\texttt{src}\) ).
+
borderMode - pixel extrapolation method (see #BorderTypes); when
+ borderMode=#BORDER_TRANSPARENT, it means that the pixels in the destination image corresponding to
+ the "outliers" in the source image are not modified by the function.
+
+ SEE: warpPerspective, resize, remap, getRectSubPix, transform
public static void warpAffine(Mat src,
+ Mat dst,
+ Mat M,
+ Size dsize,
+ int flags,
+ int borderMode,
+ Scalar borderValue)
+
Applies an affine transformation to an image.
+
+ The function warpAffine transforms the source image using the specified matrix:
+
+ \(\texttt{dst} (x,y) = \texttt{src} ( \texttt{M} _{11} x + \texttt{M} _{12} y + \texttt{M} _{13}, \texttt{M} _{21} x + \texttt{M} _{22} y + \texttt{M} _{23})\)
+
+ when the flag #WARP_INVERSE_MAP is set. Otherwise, the transformation is first inverted
+ with #invertAffineTransform and then put in the formula above instead of M. The function cannot
+ operate in-place.
+
+
Parameters:
+
src - input image.
+
dst - output image that has the size dsize and the same type as src .
+
M - \(2\times 3\) transformation matrix.
+
dsize - size of the output image.
+
flags - combination of interpolation methods (see #InterpolationFlags) and the optional
+ flag #WARP_INVERSE_MAP that means that M is the inverse transformation (
+ \(\texttt{dst}\rightarrow\texttt{src}\) ).
+
borderMode - pixel extrapolation method (see #BorderTypes); when
+ borderMode=#BORDER_TRANSPARENT, it means that the pixels in the destination image corresponding to
+ the "outliers" in the source image are not modified by the function.
+
borderValue - value used in case of a constant border; by default, it is 0.
+
+ SEE: warpPerspective, resize, remap, getRectSubPix, transform
public static void warpPerspective(Mat src,
+ Mat dst,
+ Mat M,
+ Size dsize)
+
Applies a perspective transformation to an image.
+
+ The function warpPerspective transforms the source image using the specified matrix:
+
+ \(\texttt{dst} (x,y) = \texttt{src} \left ( \frac{M_{11} x + M_{12} y + M_{13}}{M_{31} x + M_{32} y + M_{33}} ,
+ \frac{M_{21} x + M_{22} y + M_{23}}{M_{31} x + M_{32} y + M_{33}} \right )\)
+
+ when the flag #WARP_INVERSE_MAP is set. Otherwise, the transformation is first inverted with invert
+ and then put in the formula above instead of M. The function cannot operate in-place.
+
+
Parameters:
+
src - input image.
+
dst - output image that has the size dsize and the same type as src .
+
M - \(3\times 3\) transformation matrix.
+
dsize - size of the output image.
+ optional flag #WARP_INVERSE_MAP, that sets M as the inverse transformation (
+ \(\texttt{dst}\rightarrow\texttt{src}\) ).
+
+ SEE: warpAffine, resize, remap, getRectSubPix, perspectiveTransform
public static void warpPerspective(Mat src,
+ Mat dst,
+ Mat M,
+ Size dsize,
+ int flags)
+
Applies a perspective transformation to an image.
+
+ The function warpPerspective transforms the source image using the specified matrix:
+
+ \(\texttt{dst} (x,y) = \texttt{src} \left ( \frac{M_{11} x + M_{12} y + M_{13}}{M_{31} x + M_{32} y + M_{33}} ,
+ \frac{M_{21} x + M_{22} y + M_{23}}{M_{31} x + M_{32} y + M_{33}} \right )\)
+
+ when the flag #WARP_INVERSE_MAP is set. Otherwise, the transformation is first inverted with invert
+ and then put in the formula above instead of M. The function cannot operate in-place.
+
+
Parameters:
+
src - input image.
+
dst - output image that has the size dsize and the same type as src .
+
M - \(3\times 3\) transformation matrix.
+
dsize - size of the output image.
+
flags - combination of interpolation methods (#INTER_LINEAR or #INTER_NEAREST) and the
+ optional flag #WARP_INVERSE_MAP, that sets M as the inverse transformation (
+ \(\texttt{dst}\rightarrow\texttt{src}\) ).
+
+ SEE: warpAffine, resize, remap, getRectSubPix, perspectiveTransform
public static void warpPerspective(Mat src,
+ Mat dst,
+ Mat M,
+ Size dsize,
+ int flags,
+ int borderMode)
+
Applies a perspective transformation to an image.
+
+ The function warpPerspective transforms the source image using the specified matrix:
+
+ \(\texttt{dst} (x,y) = \texttt{src} \left ( \frac{M_{11} x + M_{12} y + M_{13}}{M_{31} x + M_{32} y + M_{33}} ,
+ \frac{M_{21} x + M_{22} y + M_{23}}{M_{31} x + M_{32} y + M_{33}} \right )\)
+
+ when the flag #WARP_INVERSE_MAP is set. Otherwise, the transformation is first inverted with invert
+ and then put in the formula above instead of M. The function cannot operate in-place.
+
+
Parameters:
+
src - input image.
+
dst - output image that has the size dsize and the same type as src .
+
M - \(3\times 3\) transformation matrix.
+
dsize - size of the output image.
+
flags - combination of interpolation methods (#INTER_LINEAR or #INTER_NEAREST) and the
+ optional flag #WARP_INVERSE_MAP, that sets M as the inverse transformation (
+ \(\texttt{dst}\rightarrow\texttt{src}\) ).
public static void warpPerspective(Mat src,
+ Mat dst,
+ Mat M,
+ Size dsize,
+ int flags,
+ int borderMode,
+ Scalar borderValue)
+
Applies a perspective transformation to an image.
+
+ The function warpPerspective transforms the source image using the specified matrix:
+
+ \(\texttt{dst} (x,y) = \texttt{src} \left ( \frac{M_{11} x + M_{12} y + M_{13}}{M_{31} x + M_{32} y + M_{33}} ,
+ \frac{M_{21} x + M_{22} y + M_{23}}{M_{31} x + M_{32} y + M_{33}} \right )\)
+
+ when the flag #WARP_INVERSE_MAP is set. Otherwise, the transformation is first inverted with invert
+ and then put in the formula above instead of M. The function cannot operate in-place.
+
+
Parameters:
+
src - input image.
+
dst - output image that has the size dsize and the same type as src .
+
M - \(3\times 3\) transformation matrix.
+
dsize - size of the output image.
+
flags - combination of interpolation methods (#INTER_LINEAR or #INTER_NEAREST) and the
+ optional flag #WARP_INVERSE_MAP, that sets M as the inverse transformation (
+ \(\texttt{dst}\rightarrow\texttt{src}\) ).
+
borderMode - pixel extrapolation method (#BORDER_CONSTANT or #BORDER_REPLICATE).
+
borderValue - value used in case of a constant border; by default, it equals 0.
+
+ SEE: warpAffine, resize, remap, getRectSubPix, perspectiveTransform
public static void warpPolar(Mat src,
+ Mat dst,
+ Size dsize,
+ Point center,
+ double maxRadius,
+ int flags)
+
Remaps an image to polar or semilog-polar coordinates space
+
+ polar_remaps_reference_image
+ 
+
+ Transform the source image using the following transformation:
+ \(
+ dst(\rho , \phi ) = src(x,y)
+ \)
+
+ where
+ \(
+ \begin{array}{l}
+ \vec{I} = (x - center.x, \;y - center.y) \\
+ \phi = Kangle \cdot \texttt{angle} (\vec{I}) \\
+ \rho = \left\{\begin{matrix}
+ Klin \cdot \texttt{magnitude} (\vec{I}) & default \\
+ Klog \cdot log_e(\texttt{magnitude} (\vec{I})) & if \; semilog \\
+ \end{matrix}\right.
+ \end{array}
+ \)
+
+ and
+ \(
+ \begin{array}{l}
+ Kangle = dsize.height / 2\Pi \\
+ Klin = dsize.width / maxRadius \\
+ Klog = dsize.width / log_e(maxRadius) \\
+ \end{array}
+ \)
+
+
+ \par Linear vs semilog mapping
+
+ Polar mapping can be linear or semi-log. Add one of #WarpPolarMode to flags to specify the polar mapping mode.
+
+ Linear is the default mode.
+
+ The semilog mapping emulates the human "foveal" vision that permit very high acuity on the line of sight (central vision)
+ in contrast to peripheral vision where acuity is minor.
+
+ \par Option on dsize:
+
+
+
+ if both values in dsize <=0 (default),
+ the destination image will have (almost) same area of source bounding circle:
+ \(\begin{array}{l}
+ dsize.area \leftarrow (maxRadius^2 \cdot \Pi) \\
+ dsize.width = \texttt{cvRound}(maxRadius) \\
+ dsize.height = \texttt{cvRound}(maxRadius \cdot \Pi) \\
+ \end{array}\)
+
+
+
+
+
+
+ if only dsize.height <= 0,
+ the destination image area will be proportional to the bounding circle area but scaled by Kx * Kx:
+ \(\begin{array}{l}
+ dsize.height = \texttt{cvRound}(dsize.width \cdot \Pi) \\
+ \end{array}
+ \)
+
+
+
+
+
+ if both values in dsize > 0 ,
+ the destination image will have the given size therefore the area of the bounding circle will be scaled to dsize.
+
+
+
+
+ \par Reverse mapping
+
+ You can get reverse mapping adding #WARP_INVERSE_MAP to flags
+ \snippet polar_transforms.cpp InverseMap
+
+ In addiction, to calculate the original coordinate from a polar mapped coordinate \((rho, phi)->(x, y)\):
+ \snippet polar_transforms.cpp InverseCoordinate
+
+
Parameters:
+
src - Source image.
+
dst - Destination image. It will have same type as src.
+
dsize - The destination image size (see description for valid options).
+
center - The transformation center.
+
maxRadius - The radius of the bounding circle to transform. It determines the inverse magnitude scale parameter too.
+
flags - A combination of interpolation methods, #InterpolationFlags + #WarpPolarMode.
+
+
+ Add #WARP_POLAR_LINEAR to select linear polar mapping (default)
+
+
+ Add #WARP_POLAR_LOG to select semilog polar mapping
+
+
+ Add #WARP_INVERSE_MAP for reverse mapping.
+
+
+ Note:
+
+
+ The function can not operate in-place.
+
+
+ To calculate magnitude and angle in degrees #cartToPolar is used internally thus angles are measured from 0 to 360 with accuracy about 0.3 degrees.
+
+
+ This function uses #remap. Due to current implementation limitations the size of an input and output images should be less than 32767x32767.
+
public static void watershed(Mat image,
+ Mat markers)
+
Performs a marker-based image segmentation using the watershed algorithm.
+
+ The function implements one of the variants of watershed, non-parametric marker-based segmentation
+ algorithm, described in CITE: Meyer92 .
+
+ Before passing the image to the function, you have to roughly outline the desired regions in the
+ image markers with positive (>0) indices. So, every region is represented as one or more connected
+ components with the pixel values 1, 2, 3, and so on. Such markers can be retrieved from a binary
+ mask using #findContours and #drawContours (see the watershed.cpp demo). The markers are "seeds" of
+ the future image regions. All the other pixels in markers , whose relation to the outlined regions
+ is not known and should be defined by the algorithm, should be set to 0's. In the function output,
+ each pixel in markers is set to a value of the "seed" components or to -1 at boundaries between the
+ regions.
+
+ Note: Any two neighbor connected components are not necessarily separated by a watershed boundary
+ (-1's pixels); for example, they can touch each other in the initial marker image passed to the
+ function.
+
+
Parameters:
+
image - Input 8-bit 3-channel image.
+
markers - Input/output 32-bit single-channel image (map) of markers. It should have the same
+ size as image .
+
+ SEE: findContours
public class IntelligentScissorsMB
+extends java.lang.Object
+
Intelligent Scissors image segmentation
+
+ This class is used to find the path (contour) between two points
+ which can be used for image segmentation.
+
+ Usage example:
+ SNIPPET: snippets/imgproc_segmentation.cpp usage_example_intelligent_scissors
+
+ Reference: <a href="http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.138.3811&rep=rep1&type=pdf">"Intelligent Scissors for Image Composition"</a>
+ algorithm designed by Eric N. Mortensen and William A. Barrett, Brigham Young University
+ CITE: Mortensen95intelligentscissors
Switch edge feature extractor to use Canny edge detector
+
+ Note: "Laplacian Zero-Crossing" feature extractor is used by default (following to original article)
+
+ SEE: Canny
Switch edge feature extractor to use Canny edge detector
+
+ Note: "Laplacian Zero-Crossing" feature extractor is used by default (following to original article)
+
+ SEE: Canny
Switch edge feature extractor to use Canny edge detector
+
+ Note: "Laplacian Zero-Crossing" feature extractor is used by default (following to original article)
+
+ SEE: Canny
Switch to "Laplacian Zero-Crossing" edge feature extractor and specify its parameters
+
+ This feature extractor is used by default according to article.
Switch to "Laplacian Zero-Crossing" edge feature extractor and specify its parameters
+
+ This feature extractor is used by default according to article.
Specify gradient magnitude max value threshold
+
+ Zero limit value is used to disable gradient magnitude thresholding (default behavior, as described in original article).
Specify gradient magnitude max value threshold
+
+ Zero limit value is used to disable gradient magnitude thresholding (default behavior, as described in original article).
Specify weights of feature functions
+
+ Consider keeping weights normalized (sum of weights equals to 1.0)
+ Discrete dynamic programming (DP) goal is minimization of costs between pixels.
public void getContour(Point targetPt,
+ Mat contour)
+
Extracts optimal contour for the given target point on the image
+
+ Note: buildMap() must be called before this call
+
+
Parameters:
+
targetPt - The target point
+
contour - The list of pixels which contains optimal path between the source and the target points of the image. Type is CV_32SC2 (compatible with std::vector<Point>)
public void getContour(Point targetPt,
+ Mat contour,
+ boolean backward)
+
Extracts optimal contour for the given target point on the image
+
+ Note: buildMap() must be called before this call
+
+
Parameters:
+
targetPt - The target point
+
contour - The list of pixels which contains optimal path between the source and the target points of the image. Type is CV_32SC2 (compatible with std::vector<Point>)
+
backward - Flag to indicate reverse order of retrived pixels (use "true" value to fetch points from the target to the source point)
public IntelligentScissorsMB setEdgeFeatureCannyParameters(double threshold1,
+ double threshold2)
+
Switch edge feature extractor to use Canny edge detector
+
+ Note: "Laplacian Zero-Crossing" feature extractor is used by default (following to original article)
+
+ SEE: Canny
public IntelligentScissorsMB setEdgeFeatureCannyParameters(double threshold1,
+ double threshold2,
+ int apertureSize)
+
Switch edge feature extractor to use Canny edge detector
+
+ Note: "Laplacian Zero-Crossing" feature extractor is used by default (following to original article)
+
+ SEE: Canny
public IntelligentScissorsMB setEdgeFeatureCannyParameters(double threshold1,
+ double threshold2,
+ int apertureSize,
+ boolean L2gradient)
+
Switch edge feature extractor to use Canny edge detector
+
+ Note: "Laplacian Zero-Crossing" feature extractor is used by default (following to original article)
+
+ SEE: Canny
Switch to "Laplacian Zero-Crossing" edge feature extractor and specify its parameters
+
+ This feature extractor is used by default according to article.
+
+ Implementation has additional filtering for regions with low-amplitude noise.
+ This filtering is enabled through parameter of minimal gradient amplitude (use some small value 4, 8, 16).
+
+ Note: Current implementation of this feature extractor is based on processing of grayscale images (color image is converted to grayscale image first).
+
+ Note: Canny edge detector is a bit slower, but provides better results (especially on color images): use setEdgeFeatureCannyParameters().
public IntelligentScissorsMB setEdgeFeatureZeroCrossingParameters(float gradient_magnitude_min_value)
+
Switch to "Laplacian Zero-Crossing" edge feature extractor and specify its parameters
+
+ This feature extractor is used by default according to article.
+
+ Implementation has additional filtering for regions with low-amplitude noise.
+ This filtering is enabled through parameter of minimal gradient amplitude (use some small value 4, 8, 16).
+
+ Note: Current implementation of this feature extractor is based on processing of grayscale images (color image is converted to grayscale image first).
+
+ Note: Canny edge detector is a bit slower, but provides better results (especially on color images): use setEdgeFeatureCannyParameters().
+
+
Parameters:
+
gradient_magnitude_min_value - Minimal gradient magnitude value for edge pixels (default: 0, check is disabled)
Specify gradient magnitude max value threshold
+
+ Zero limit value is used to disable gradient magnitude thresholding (default behavior, as described in original article).
+ Otherwize pixels with gradient magnitude >= threshold have zero cost.
+
+ Note: Thresholding should be used for images with irregular regions (to avoid stuck on parameters from high-contract areas, like embedded logos).
public IntelligentScissorsMB setGradientMagnitudeMaxLimit(float gradient_magnitude_threshold_max)
+
Specify gradient magnitude max value threshold
+
+ Zero limit value is used to disable gradient magnitude thresholding (default behavior, as described in original article).
+ Otherwize pixels with gradient magnitude >= threshold have zero cost.
+
+ Note: Thresholding should be used for images with irregular regions (to avoid stuck on parameters from high-contract areas, like embedded logos).
+
+
Parameters:
+
gradient_magnitude_threshold_max - Specify gradient magnitude max value threshold (default: 0, disabled)
public IntelligentScissorsMB setWeights(float weight_non_edge,
+ float weight_gradient_direction,
+ float weight_gradient_magnitude)
+
Specify weights of feature functions
+
+ Consider keeping weights normalized (sum of weights equals to 1.0)
+ Discrete dynamic programming (DP) goal is minimization of costs between pixels.
+
+
Parameters:
+
weight_non_edge - Specify cost of non-edge pixels (default: 0.43f)
+
weight_gradient_direction - Specify cost of gradient direction function (default: 0.43f)
+
weight_gradient_magnitude - Specify cost of gradient magnitude function (default: 0.14f)
public class LineSegmentDetector
+extends Algorithm
+
Line segment detector class
+
+ following the algorithm described at CITE: Rafael12 .
+
+ Note: Implementation has been removed from OpenCV version 3.4.6 to 3.4.15 and version 4.1.0 to 4.5.3 due original code license conflict.
+ restored again after [Computation of a NFA](https://github.com/rafael-grompone-von-gioi/binomial_nfa) code published under the MIT license.
public int compareSegments(Size size,
+ Mat lines1,
+ Mat lines2,
+ Mat image)
+
Draws two groups of lines in blue and red, counting the non overlapping (mismatching) pixels.
+
+
Parameters:
+
size - The size of the image, where lines1 and lines2 were found.
+
lines1 - The first group of lines that needs to be drawn. It is visualized in blue color.
+
lines2 - The second group of lines. They visualized in red color.
+
image - Optional image, where the lines will be drawn. The image should be color(3-channel)
+ in order for lines1 and lines2 to be drawn in the above mentioned colors.
Finds lines in the input image.
+
+ This is the output of the default parameters of the algorithm on the above shown image.
+
+ 
+
+
Parameters:
+
image - A grayscale (CV_8UC1) input image. If only a roi needs to be selected, use:
+ lsd_ptr->detect(image(roi), lines, ...); lines += Scalar(roi.x, roi.y, roi.x, roi.y);
+
lines - A vector of Vec4f elements specifying the beginning and ending point of a line. Where
+ Vec4f is (x1, y1, x2, y2), point 1 is the start, point 2 - end. Returned lines are strictly
+ oriented depending on the gradient.
+ bigger the value, logarithmically better the detection.
+
+
+ -1 corresponds to 10 mean false alarms
+
+
+ 0 corresponds to 1 mean false alarm
+
+
+ 1 corresponds to 0.1 mean false alarms
+ This vector will be calculated only when the objects type is #LSD_REFINE_ADV.
+
public void detect(Mat image,
+ Mat lines,
+ Mat width)
+
Finds lines in the input image.
+
+ This is the output of the default parameters of the algorithm on the above shown image.
+
+ 
+
+
Parameters:
+
image - A grayscale (CV_8UC1) input image. If only a roi needs to be selected, use:
+ lsd_ptr->detect(image(roi), lines, ...); lines += Scalar(roi.x, roi.y, roi.x, roi.y);
+
lines - A vector of Vec4f elements specifying the beginning and ending point of a line. Where
+ Vec4f is (x1, y1, x2, y2), point 1 is the start, point 2 - end. Returned lines are strictly
+ oriented depending on the gradient.
+
width - Vector of widths of the regions, where the lines are found. E.g. Width of line.
+ bigger the value, logarithmically better the detection.
+
+
+ -1 corresponds to 10 mean false alarms
+
+
+ 0 corresponds to 1 mean false alarm
+
+
+ 1 corresponds to 0.1 mean false alarms
+ This vector will be calculated only when the objects type is #LSD_REFINE_ADV.
+
public void detect(Mat image,
+ Mat lines,
+ Mat width,
+ Mat prec)
+
Finds lines in the input image.
+
+ This is the output of the default parameters of the algorithm on the above shown image.
+
+ 
+
+
Parameters:
+
image - A grayscale (CV_8UC1) input image. If only a roi needs to be selected, use:
+ lsd_ptr->detect(image(roi), lines, ...); lines += Scalar(roi.x, roi.y, roi.x, roi.y);
+
lines - A vector of Vec4f elements specifying the beginning and ending point of a line. Where
+ Vec4f is (x1, y1, x2, y2), point 1 is the start, point 2 - end. Returned lines are strictly
+ oriented depending on the gradient.
+
width - Vector of widths of the regions, where the lines are found. E.g. Width of line.
+
prec - Vector of precisions with which the lines are found.
+ bigger the value, logarithmically better the detection.
+
+
+ -1 corresponds to 10 mean false alarms
+
+
+ 0 corresponds to 1 mean false alarm
+
+
+ 1 corresponds to 0.1 mean false alarms
+ This vector will be calculated only when the objects type is #LSD_REFINE_ADV.
+
public void detect(Mat image,
+ Mat lines,
+ Mat width,
+ Mat prec,
+ Mat nfa)
+
Finds lines in the input image.
+
+ This is the output of the default parameters of the algorithm on the above shown image.
+
+ 
+
+
Parameters:
+
image - A grayscale (CV_8UC1) input image. If only a roi needs to be selected, use:
+ lsd_ptr->detect(image(roi), lines, ...); lines += Scalar(roi.x, roi.y, roi.x, roi.y);
+
lines - A vector of Vec4f elements specifying the beginning and ending point of a line. Where
+ Vec4f is (x1, y1, x2, y2), point 1 is the start, point 2 - end. Returned lines are strictly
+ oriented depending on the gradient.
+
width - Vector of widths of the regions, where the lines are found. E.g. Width of line.
+
prec - Vector of precisions with which the lines are found.
+
nfa - Vector containing number of false alarms in the line region, with precision of 10%. The
+ bigger the value, logarithmically better the detection.
+
+
+ -1 corresponds to 10 mean false alarms
+
+
+ 0 corresponds to 1 mean false alarm
+
+
+ 1 corresponds to 0.1 mean false alarms
+ This vector will be calculated only when the objects type is #LSD_REFINE_ADV.
+
rect - Rectangle that includes all of the 2D points that are to be added to the subdivision.
+
+ The function creates an empty Delaunay subdivision where 2D points can be added using the function
+ insert() . All of the points to be added must be within the specified rectangle, otherwise a runtime
+ error is raised.
Finds the subdivision vertex closest to the given point.
+
+
Parameters:
+
pt - Input point.
+
+ The function is another function that locates the input point within the subdivision. It finds the
+ subdivision vertex that is the closest to the input point. It is not necessarily one of vertices
+ of the facet containing the input point, though the facet (located using locate() ) is used as a
+ starting point.
public int findNearest(Point pt,
+ Point nearestPt)
+
Finds the subdivision vertex closest to the given point.
+
+
Parameters:
+
pt - Input point.
+
nearestPt - Output subdivision vertex point.
+
+ The function is another function that locates the input point within the subdivision. It finds the
+ subdivision vertex that is the closest to the input point. It is not necessarily one of vertices
+ of the facet containing the input point, though the facet (located using locate() ) is used as a
+ starting point.
edgeList - Output vector.
+
+ The function gives each edge as a 4 numbers vector, where each two are one of the edge
+ vertices. i.e. org_x = v[0], org_y = v[1], dst_x = v[2], dst_y = v[3].
public void getTriangleList(MatOfFloat6 triangleList)
+
Returns a list of all triangles.
+
+
Parameters:
+
triangleList - Output vector.
+
+ The function gives each triangle as a 6 numbers vector, where each two are one of the triangle
+ vertices. i.e. p1_x = v[0], p1_y = v[1], p2_x = v[2], p2_y = v[3], p3_x = v[4], p3_y = v[5].
Insert a single point into a Delaunay triangulation.
+
+
Parameters:
+
pt - Point to insert.
+
+ The function inserts a single point into a subdivision and modifies the subdivision topology
+ appropriately. If a point with the same coordinates exists already, no new point is added.
+
Returns:
+
the ID of the point.
+
+ Note: If the point is outside of the triangulation specified rect a runtime error is raised.
public int locate(Point pt,
+ int[] edge,
+ int[] vertex)
+
Returns the location of a point within a Delaunay triangulation.
+
+
Parameters:
+
pt - Point to locate.
+
edge - Output edge that the point belongs to or is located to the right of it.
+
vertex - Optional output vertex the input point coincides with.
+
+ The function locates the input point within the subdivision and gives one of the triangle edges
+ or vertices.
+
Returns:
+
an integer which specify one of the following five cases for point location:
+
+
+ The point falls into some facet. The function returns #PTLOC_INSIDE and edge will contain one of
+ edges of the facet.
+
+
+ The point falls onto the edge. The function returns #PTLOC_ON_EDGE and edge will contain this edge.
+
+
+ The point coincides with one of the subdivision vertices. The function returns #PTLOC_VERTEX and
+ vertex will contain a pointer to the vertex.
+
+
+ The point is outside the subdivision reference rectangle. The function returns #PTLOC_OUTSIDE_RECT
+ and no pointers are filled.
+
+
+ One of input arguments is invalid. A runtime error is raised or, if silent or "parent" error
+ processing mode is selected, #PTLOC_ERROR is returned.
+
finds arbitrary template in the grayscale image using Generalized Hough Transform
+
+ Detects position only without translation and rotation CITE: Ballard1981 .
Intelligent Scissors image segmentation
+
+ This class is used to find the path (contour) between two points
+ which can be used for image segmentation.
Artificial Neural Networks - Multi-Layer Perceptrons.
+
+ Unlike many other models in ML that are constructed and trained at once, in the MLP model these
+ steps are separated. First, a network with the specified topology is created using the non-default
+ constructor or the method ANN_MLP::create. All the weights are set to zeros. Then, the network is
+ trained using a set of input and output vectors. The training procedure can be repeated more than
+ once, that is, the weights can be adjusted based on the new training data.
+
+ Additional flags for StatModel::train are available: ANN_MLP::TrainFlags.
+
+ SEE: REF: ml_intro_ann
Creates empty model
+
+ Use StatModel::train to train the model, Algorithm::load<ANN_MLP>(filename) to load the pre-trained model.
+ Note that the train method has optional flags: ANN_MLP::TrainFlags.
Integer vector specifying the number of neurons in each layer including the input and output layers.
+ The very first element specifies the number of elements in the input layer.
+ The last element - number of elements in the output layer.
+ SEE: setLayerSizes
public static ANN_MLP load(java.lang.String filepath)
+
Loads and creates a serialized ANN from a file
+
+ Use ANN::save to serialize and store an ANN to disk.
+ Load the ANN from this file again, by calling this function with the path to the file.
Integer vector specifying the number of neurons in each layer including the input and output layers.
+ The very first element specifies the number of elements in the input layer.
+ The last element - number of elements in the output layer. Default value is empty Mat.
+ SEE: getLayerSizes
public static Boost load(java.lang.String filepath)
+
Loads and creates a serialized Boost from a file
+
+ Use Boost::save to serialize and store an RTree to disk.
+ Load the Boost from this file again, by calling this function with the path to the file.
+ Optionally specify the node for the file containing the classifier
public static Boost load(java.lang.String filepath,
+ java.lang.String nodeName)
+
Loads and creates a serialized Boost from a file
+
+ Use Boost::save to serialize and store an RTree to disk.
+ Load the Boost from this file again, by calling this function with the path to the file.
+ Optionally specify the node for the file containing the classifier
The class represents a single decision tree or a collection of decision trees.
+
+ The current public interface of the class allows user to train only a single decision tree, however
+ the class is capable of storing multiple decision trees and using them for prediction (by summing
+ responses or using a voting schemes), and the derived from DTrees classes (such as RTrees and Boost)
+ use this capability to implement decision tree ensembles.
+
+ SEE: REF: ml_intro_trees
Creates the empty model
+
+ The static method creates empty decision tree with the specified parameters. It should be then
+ trained using train method (see StatModel::train). Alternatively, you can load the model from
+ file using Algorithm::load<DTrees>(filename).
public static DTrees load(java.lang.String filepath)
+
Loads and creates a serialized DTrees from a file
+
+ Use DTree::save to serialize and store an DTree to disk.
+ Load the DTree from this file again, by calling this function with the path to the file.
+ Optionally specify the node for the file containing the classifier
public static DTrees load(java.lang.String filepath,
+ java.lang.String nodeName)
+
Loads and creates a serialized DTrees from a file
+
+ Use DTree::save to serialize and store an DTree to disk.
+ Load the DTree from this file again, by calling this function with the path to the file.
+ Optionally specify the node for the file containing the classifier
Returns the cluster centers (means of the Gaussian mixture)
+
+ Returns matrix with the number of rows equal to the number of mixtures and number of columns
+ equal to the space dimensionality.
Creates empty %EM model.
+ The model should be trained then using StatModel::train(traindata, flags) method. Alternatively, you
+ can use one of the EM::train\* methods or load it from file using Algorithm::load<EM>(filename).
Returns covariation matrices
+
+ Returns vector of covariation matrices. Number of matrices is the number of gaussian mixtures,
+ each matrix is a square floating-point matrix NxN, where N is the space dimensionality.
Returns the cluster centers (means of the Gaussian mixture)
+
+ Returns matrix with the number of rows equal to the number of mixtures and number of columns
+ equal to the space dimensionality.
Loads and creates a serialized EM from a file
+
+ Use EM::save to serialize and store an EM to disk.
+ Load the EM from this file again, by calling this function with the path to the file.
+ Optionally specify the node for the file containing the classifier
public static EM load(java.lang.String filepath,
+ java.lang.String nodeName)
+
Loads and creates a serialized EM from a file
+
+ Use EM::save to serialize and store an EM to disk.
+ Load the EM from this file again, by calling this function with the path to the file.
+ Optionally specify the node for the file containing the classifier
Returns a likelihood logarithm value and an index of the most probable mixture component
+ for the given sample.
+
+
Parameters:
+
sample - A sample for classification. It should be a one-channel matrix of
+ \(1 \times dims\) or \(dims \times 1\) size.
+
probs - Optional output matrix that contains posterior probabilities of each component
+ given the sample. It has \(1 \times nclusters\) size and CV_64FC1 type.
+
+ The method returns a two-element double vector. Zero element is a likelihood logarithm value for
+ the sample. First element is an index of the most probable mixture component for the given
+ sample.
Estimate the Gaussian mixture parameters from a samples set.
+
+ This variation starts with Expectation step. You need to provide initial means \(a_k\) of
+ mixture components. Optionally you can pass initial weights \(\pi_k\) and covariance matrices
+ \(S_k\) of mixture components.
+
+
Parameters:
+
samples - Samples from which the Gaussian mixture model will be estimated. It should be a
+ one-channel matrix, each row of which is a sample. If the matrix does not have CV_64F type
+ it will be converted to the inner matrix of such type for the further computing.
+
means0 - Initial means \(a_k\) of mixture components. It is a one-channel matrix of
+ \(nclusters \times dims\) size. If the matrix does not have CV_64F type it will be
+ converted to the inner matrix of such type for the further computing.
+ covariance matrices is a one-channel matrix of \(dims \times dims\) size. If the matrices
+ do not have CV_64F type they will be converted to the inner matrices of such type for the
+ further computing.
+ floating-point matrix with \(1 \times nclusters\) or \(nclusters \times 1\) size.
+ each sample. It has \(nsamples \times 1\) size and CV_64FC1 type.
+ \(\texttt{labels}_i=\texttt{arg max}_k(p_{i,k}), i=1..N\) (indices of the most probable
+ mixture component for each sample). It has \(nsamples \times 1\) size and CV_32SC1 type.
+ mixture component given the each sample. It has \(nsamples \times nclusters\) size and
+ CV_64FC1 type.
public boolean trainE(Mat samples,
+ Mat means0,
+ Mat covs0)
+
Estimate the Gaussian mixture parameters from a samples set.
+
+ This variation starts with Expectation step. You need to provide initial means \(a_k\) of
+ mixture components. Optionally you can pass initial weights \(\pi_k\) and covariance matrices
+ \(S_k\) of mixture components.
+
+
Parameters:
+
samples - Samples from which the Gaussian mixture model will be estimated. It should be a
+ one-channel matrix, each row of which is a sample. If the matrix does not have CV_64F type
+ it will be converted to the inner matrix of such type for the further computing.
+
means0 - Initial means \(a_k\) of mixture components. It is a one-channel matrix of
+ \(nclusters \times dims\) size. If the matrix does not have CV_64F type it will be
+ converted to the inner matrix of such type for the further computing.
+
covs0 - The vector of initial covariance matrices \(S_k\) of mixture components. Each of
+ covariance matrices is a one-channel matrix of \(dims \times dims\) size. If the matrices
+ do not have CV_64F type they will be converted to the inner matrices of such type for the
+ further computing.
+ floating-point matrix with \(1 \times nclusters\) or \(nclusters \times 1\) size.
+ each sample. It has \(nsamples \times 1\) size and CV_64FC1 type.
+ \(\texttt{labels}_i=\texttt{arg max}_k(p_{i,k}), i=1..N\) (indices of the most probable
+ mixture component for each sample). It has \(nsamples \times 1\) size and CV_32SC1 type.
+ mixture component given the each sample. It has \(nsamples \times nclusters\) size and
+ CV_64FC1 type.
public boolean trainE(Mat samples,
+ Mat means0,
+ Mat covs0,
+ Mat weights0)
+
Estimate the Gaussian mixture parameters from a samples set.
+
+ This variation starts with Expectation step. You need to provide initial means \(a_k\) of
+ mixture components. Optionally you can pass initial weights \(\pi_k\) and covariance matrices
+ \(S_k\) of mixture components.
+
+
Parameters:
+
samples - Samples from which the Gaussian mixture model will be estimated. It should be a
+ one-channel matrix, each row of which is a sample. If the matrix does not have CV_64F type
+ it will be converted to the inner matrix of such type for the further computing.
+
means0 - Initial means \(a_k\) of mixture components. It is a one-channel matrix of
+ \(nclusters \times dims\) size. If the matrix does not have CV_64F type it will be
+ converted to the inner matrix of such type for the further computing.
+
covs0 - The vector of initial covariance matrices \(S_k\) of mixture components. Each of
+ covariance matrices is a one-channel matrix of \(dims \times dims\) size. If the matrices
+ do not have CV_64F type they will be converted to the inner matrices of such type for the
+ further computing.
+
weights0 - Initial weights \(\pi_k\) of mixture components. It should be a one-channel
+ floating-point matrix with \(1 \times nclusters\) or \(nclusters \times 1\) size.
+ each sample. It has \(nsamples \times 1\) size and CV_64FC1 type.
+ \(\texttt{labels}_i=\texttt{arg max}_k(p_{i,k}), i=1..N\) (indices of the most probable
+ mixture component for each sample). It has \(nsamples \times 1\) size and CV_32SC1 type.
+ mixture component given the each sample. It has \(nsamples \times nclusters\) size and
+ CV_64FC1 type.
public boolean trainE(Mat samples,
+ Mat means0,
+ Mat covs0,
+ Mat weights0,
+ Mat logLikelihoods)
+
Estimate the Gaussian mixture parameters from a samples set.
+
+ This variation starts with Expectation step. You need to provide initial means \(a_k\) of
+ mixture components. Optionally you can pass initial weights \(\pi_k\) and covariance matrices
+ \(S_k\) of mixture components.
+
+
Parameters:
+
samples - Samples from which the Gaussian mixture model will be estimated. It should be a
+ one-channel matrix, each row of which is a sample. If the matrix does not have CV_64F type
+ it will be converted to the inner matrix of such type for the further computing.
+
means0 - Initial means \(a_k\) of mixture components. It is a one-channel matrix of
+ \(nclusters \times dims\) size. If the matrix does not have CV_64F type it will be
+ converted to the inner matrix of such type for the further computing.
+
covs0 - The vector of initial covariance matrices \(S_k\) of mixture components. Each of
+ covariance matrices is a one-channel matrix of \(dims \times dims\) size. If the matrices
+ do not have CV_64F type they will be converted to the inner matrices of such type for the
+ further computing.
+
weights0 - Initial weights \(\pi_k\) of mixture components. It should be a one-channel
+ floating-point matrix with \(1 \times nclusters\) or \(nclusters \times 1\) size.
+
logLikelihoods - The optional output matrix that contains a likelihood logarithm value for
+ each sample. It has \(nsamples \times 1\) size and CV_64FC1 type.
+ \(\texttt{labels}_i=\texttt{arg max}_k(p_{i,k}), i=1..N\) (indices of the most probable
+ mixture component for each sample). It has \(nsamples \times 1\) size and CV_32SC1 type.
+ mixture component given the each sample. It has \(nsamples \times nclusters\) size and
+ CV_64FC1 type.
public boolean trainE(Mat samples,
+ Mat means0,
+ Mat covs0,
+ Mat weights0,
+ Mat logLikelihoods,
+ Mat labels)
+
Estimate the Gaussian mixture parameters from a samples set.
+
+ This variation starts with Expectation step. You need to provide initial means \(a_k\) of
+ mixture components. Optionally you can pass initial weights \(\pi_k\) and covariance matrices
+ \(S_k\) of mixture components.
+
+
Parameters:
+
samples - Samples from which the Gaussian mixture model will be estimated. It should be a
+ one-channel matrix, each row of which is a sample. If the matrix does not have CV_64F type
+ it will be converted to the inner matrix of such type for the further computing.
+
means0 - Initial means \(a_k\) of mixture components. It is a one-channel matrix of
+ \(nclusters \times dims\) size. If the matrix does not have CV_64F type it will be
+ converted to the inner matrix of such type for the further computing.
+
covs0 - The vector of initial covariance matrices \(S_k\) of mixture components. Each of
+ covariance matrices is a one-channel matrix of \(dims \times dims\) size. If the matrices
+ do not have CV_64F type they will be converted to the inner matrices of such type for the
+ further computing.
+
weights0 - Initial weights \(\pi_k\) of mixture components. It should be a one-channel
+ floating-point matrix with \(1 \times nclusters\) or \(nclusters \times 1\) size.
+
logLikelihoods - The optional output matrix that contains a likelihood logarithm value for
+ each sample. It has \(nsamples \times 1\) size and CV_64FC1 type.
+
labels - The optional output "class label" for each sample:
+ \(\texttt{labels}_i=\texttt{arg max}_k(p_{i,k}), i=1..N\) (indices of the most probable
+ mixture component for each sample). It has \(nsamples \times 1\) size and CV_32SC1 type.
+ mixture component given the each sample. It has \(nsamples \times nclusters\) size and
+ CV_64FC1 type.
public boolean trainE(Mat samples,
+ Mat means0,
+ Mat covs0,
+ Mat weights0,
+ Mat logLikelihoods,
+ Mat labels,
+ Mat probs)
+
Estimate the Gaussian mixture parameters from a samples set.
+
+ This variation starts with Expectation step. You need to provide initial means \(a_k\) of
+ mixture components. Optionally you can pass initial weights \(\pi_k\) and covariance matrices
+ \(S_k\) of mixture components.
+
+
Parameters:
+
samples - Samples from which the Gaussian mixture model will be estimated. It should be a
+ one-channel matrix, each row of which is a sample. If the matrix does not have CV_64F type
+ it will be converted to the inner matrix of such type for the further computing.
+
means0 - Initial means \(a_k\) of mixture components. It is a one-channel matrix of
+ \(nclusters \times dims\) size. If the matrix does not have CV_64F type it will be
+ converted to the inner matrix of such type for the further computing.
+
covs0 - The vector of initial covariance matrices \(S_k\) of mixture components. Each of
+ covariance matrices is a one-channel matrix of \(dims \times dims\) size. If the matrices
+ do not have CV_64F type they will be converted to the inner matrices of such type for the
+ further computing.
+
weights0 - Initial weights \(\pi_k\) of mixture components. It should be a one-channel
+ floating-point matrix with \(1 \times nclusters\) or \(nclusters \times 1\) size.
+
logLikelihoods - The optional output matrix that contains a likelihood logarithm value for
+ each sample. It has \(nsamples \times 1\) size and CV_64FC1 type.
+
labels - The optional output "class label" for each sample:
+ \(\texttt{labels}_i=\texttt{arg max}_k(p_{i,k}), i=1..N\) (indices of the most probable
+ mixture component for each sample). It has \(nsamples \times 1\) size and CV_32SC1 type.
+
probs - The optional output matrix that contains posterior probabilities of each Gaussian
+ mixture component given the each sample. It has \(nsamples \times nclusters\) size and
+ CV_64FC1 type.
Estimate the Gaussian mixture parameters from a samples set.
+
+ This variation starts with Expectation step. Initial values of the model parameters will be
+ estimated by the k-means algorithm.
+
+ Unlike many of the ML models, %EM is an unsupervised learning algorithm and it does not take
+ responses (class labels or function values) as input. Instead, it computes the *Maximum
+ Likelihood Estimate* of the Gaussian mixture parameters from an input sample set, stores all the
+ parameters inside the structure: \(p_{i,k}\) in probs, \(a_k\) in means , \(S_k\) in
+ covs[k], \(\pi_k\) in weights , and optionally computes the output "class label" for each
+ sample: \(\texttt{labels}_i=\texttt{arg max}_k(p_{i,k}), i=1..N\) (indices of the most
+ probable mixture component for each sample).
+
+ The trained model can be used further for prediction, just like any other classifier. The
+ trained model is similar to the NormalBayesClassifier.
+
+
Parameters:
+
samples - Samples from which the Gaussian mixture model will be estimated. It should be a
+ one-channel matrix, each row of which is a sample. If the matrix does not have CV_64F type
+ it will be converted to the inner matrix of such type for the further computing.
+ each sample. It has \(nsamples \times 1\) size and CV_64FC1 type.
+ \(\texttt{labels}_i=\texttt{arg max}_k(p_{i,k}), i=1..N\) (indices of the most probable
+ mixture component for each sample). It has \(nsamples \times 1\) size and CV_32SC1 type.
+ mixture component given the each sample. It has \(nsamples \times nclusters\) size and
+ CV_64FC1 type.
public boolean trainEM(Mat samples,
+ Mat logLikelihoods)
+
Estimate the Gaussian mixture parameters from a samples set.
+
+ This variation starts with Expectation step. Initial values of the model parameters will be
+ estimated by the k-means algorithm.
+
+ Unlike many of the ML models, %EM is an unsupervised learning algorithm and it does not take
+ responses (class labels or function values) as input. Instead, it computes the *Maximum
+ Likelihood Estimate* of the Gaussian mixture parameters from an input sample set, stores all the
+ parameters inside the structure: \(p_{i,k}\) in probs, \(a_k\) in means , \(S_k\) in
+ covs[k], \(\pi_k\) in weights , and optionally computes the output "class label" for each
+ sample: \(\texttt{labels}_i=\texttt{arg max}_k(p_{i,k}), i=1..N\) (indices of the most
+ probable mixture component for each sample).
+
+ The trained model can be used further for prediction, just like any other classifier. The
+ trained model is similar to the NormalBayesClassifier.
+
+
Parameters:
+
samples - Samples from which the Gaussian mixture model will be estimated. It should be a
+ one-channel matrix, each row of which is a sample. If the matrix does not have CV_64F type
+ it will be converted to the inner matrix of such type for the further computing.
+
logLikelihoods - The optional output matrix that contains a likelihood logarithm value for
+ each sample. It has \(nsamples \times 1\) size and CV_64FC1 type.
+ \(\texttt{labels}_i=\texttt{arg max}_k(p_{i,k}), i=1..N\) (indices of the most probable
+ mixture component for each sample). It has \(nsamples \times 1\) size and CV_32SC1 type.
+ mixture component given the each sample. It has \(nsamples \times nclusters\) size and
+ CV_64FC1 type.
public boolean trainEM(Mat samples,
+ Mat logLikelihoods,
+ Mat labels)
+
Estimate the Gaussian mixture parameters from a samples set.
+
+ This variation starts with Expectation step. Initial values of the model parameters will be
+ estimated by the k-means algorithm.
+
+ Unlike many of the ML models, %EM is an unsupervised learning algorithm and it does not take
+ responses (class labels or function values) as input. Instead, it computes the *Maximum
+ Likelihood Estimate* of the Gaussian mixture parameters from an input sample set, stores all the
+ parameters inside the structure: \(p_{i,k}\) in probs, \(a_k\) in means , \(S_k\) in
+ covs[k], \(\pi_k\) in weights , and optionally computes the output "class label" for each
+ sample: \(\texttt{labels}_i=\texttt{arg max}_k(p_{i,k}), i=1..N\) (indices of the most
+ probable mixture component for each sample).
+
+ The trained model can be used further for prediction, just like any other classifier. The
+ trained model is similar to the NormalBayesClassifier.
+
+
Parameters:
+
samples - Samples from which the Gaussian mixture model will be estimated. It should be a
+ one-channel matrix, each row of which is a sample. If the matrix does not have CV_64F type
+ it will be converted to the inner matrix of such type for the further computing.
+
logLikelihoods - The optional output matrix that contains a likelihood logarithm value for
+ each sample. It has \(nsamples \times 1\) size and CV_64FC1 type.
+
labels - The optional output "class label" for each sample:
+ \(\texttt{labels}_i=\texttt{arg max}_k(p_{i,k}), i=1..N\) (indices of the most probable
+ mixture component for each sample). It has \(nsamples \times 1\) size and CV_32SC1 type.
+ mixture component given the each sample. It has \(nsamples \times nclusters\) size and
+ CV_64FC1 type.
public boolean trainEM(Mat samples,
+ Mat logLikelihoods,
+ Mat labels,
+ Mat probs)
+
Estimate the Gaussian mixture parameters from a samples set.
+
+ This variation starts with Expectation step. Initial values of the model parameters will be
+ estimated by the k-means algorithm.
+
+ Unlike many of the ML models, %EM is an unsupervised learning algorithm and it does not take
+ responses (class labels or function values) as input. Instead, it computes the *Maximum
+ Likelihood Estimate* of the Gaussian mixture parameters from an input sample set, stores all the
+ parameters inside the structure: \(p_{i,k}\) in probs, \(a_k\) in means , \(S_k\) in
+ covs[k], \(\pi_k\) in weights , and optionally computes the output "class label" for each
+ sample: \(\texttt{labels}_i=\texttt{arg max}_k(p_{i,k}), i=1..N\) (indices of the most
+ probable mixture component for each sample).
+
+ The trained model can be used further for prediction, just like any other classifier. The
+ trained model is similar to the NormalBayesClassifier.
+
+
Parameters:
+
samples - Samples from which the Gaussian mixture model will be estimated. It should be a
+ one-channel matrix, each row of which is a sample. If the matrix does not have CV_64F type
+ it will be converted to the inner matrix of such type for the further computing.
+
logLikelihoods - The optional output matrix that contains a likelihood logarithm value for
+ each sample. It has \(nsamples \times 1\) size and CV_64FC1 type.
+
labels - The optional output "class label" for each sample:
+ \(\texttt{labels}_i=\texttt{arg max}_k(p_{i,k}), i=1..N\) (indices of the most probable
+ mixture component for each sample). It has \(nsamples \times 1\) size and CV_32SC1 type.
+
probs - The optional output matrix that contains posterior probabilities of each Gaussian
+ mixture component given the each sample. It has \(nsamples \times nclusters\) size and
+ CV_64FC1 type.
Estimate the Gaussian mixture parameters from a samples set.
+
+ This variation starts with Maximization step. You need to provide initial probabilities
+ \(p_{i,k}\) to use this option.
+
+
Parameters:
+
samples - Samples from which the Gaussian mixture model will be estimated. It should be a
+ one-channel matrix, each row of which is a sample. If the matrix does not have CV_64F type
+ it will be converted to the inner matrix of such type for the further computing.
+
probs0 - the probabilities
+ each sample. It has \(nsamples \times 1\) size and CV_64FC1 type.
+ \(\texttt{labels}_i=\texttt{arg max}_k(p_{i,k}), i=1..N\) (indices of the most probable
+ mixture component for each sample). It has \(nsamples \times 1\) size and CV_32SC1 type.
+ mixture component given the each sample. It has \(nsamples \times nclusters\) size and
+ CV_64FC1 type.
public boolean trainM(Mat samples,
+ Mat probs0,
+ Mat logLikelihoods)
+
Estimate the Gaussian mixture parameters from a samples set.
+
+ This variation starts with Maximization step. You need to provide initial probabilities
+ \(p_{i,k}\) to use this option.
+
+
Parameters:
+
samples - Samples from which the Gaussian mixture model will be estimated. It should be a
+ one-channel matrix, each row of which is a sample. If the matrix does not have CV_64F type
+ it will be converted to the inner matrix of such type for the further computing.
+
probs0 - the probabilities
+
logLikelihoods - The optional output matrix that contains a likelihood logarithm value for
+ each sample. It has \(nsamples \times 1\) size and CV_64FC1 type.
+ \(\texttt{labels}_i=\texttt{arg max}_k(p_{i,k}), i=1..N\) (indices of the most probable
+ mixture component for each sample). It has \(nsamples \times 1\) size and CV_32SC1 type.
+ mixture component given the each sample. It has \(nsamples \times nclusters\) size and
+ CV_64FC1 type.
public boolean trainM(Mat samples,
+ Mat probs0,
+ Mat logLikelihoods,
+ Mat labels)
+
Estimate the Gaussian mixture parameters from a samples set.
+
+ This variation starts with Maximization step. You need to provide initial probabilities
+ \(p_{i,k}\) to use this option.
+
+
Parameters:
+
samples - Samples from which the Gaussian mixture model will be estimated. It should be a
+ one-channel matrix, each row of which is a sample. If the matrix does not have CV_64F type
+ it will be converted to the inner matrix of such type for the further computing.
+
probs0 - the probabilities
+
logLikelihoods - The optional output matrix that contains a likelihood logarithm value for
+ each sample. It has \(nsamples \times 1\) size and CV_64FC1 type.
+
labels - The optional output "class label" for each sample:
+ \(\texttt{labels}_i=\texttt{arg max}_k(p_{i,k}), i=1..N\) (indices of the most probable
+ mixture component for each sample). It has \(nsamples \times 1\) size and CV_32SC1 type.
+ mixture component given the each sample. It has \(nsamples \times nclusters\) size and
+ CV_64FC1 type.
public boolean trainM(Mat samples,
+ Mat probs0,
+ Mat logLikelihoods,
+ Mat labels,
+ Mat probs)
+
Estimate the Gaussian mixture parameters from a samples set.
+
+ This variation starts with Maximization step. You need to provide initial probabilities
+ \(p_{i,k}\) to use this option.
+
+
Parameters:
+
samples - Samples from which the Gaussian mixture model will be estimated. It should be a
+ one-channel matrix, each row of which is a sample. If the matrix does not have CV_64F type
+ it will be converted to the inner matrix of such type for the further computing.
+
probs0 - the probabilities
+
logLikelihoods - The optional output matrix that contains a likelihood logarithm value for
+ each sample. It has \(nsamples \times 1\) size and CV_64FC1 type.
+
labels - The optional output "class label" for each sample:
+ \(\texttt{labels}_i=\texttt{arg max}_k(p_{i,k}), i=1..N\) (indices of the most probable
+ mixture component for each sample). It has \(nsamples \times 1\) size and CV_32SC1 type.
+
probs - The optional output matrix that contains posterior probabilities of each Gaussian
+ mixture component given the each sample. It has \(nsamples \times nclusters\) size and
+ CV_64FC1 type.
public float findNearest(Mat samples,
+ int k,
+ Mat results)
+
Finds the neighbors and predicts responses for input vectors.
+
+
Parameters:
+
samples - Input samples stored by rows. It is a single-precision floating-point matrix of
+ <number_of_samples> * k size.
+
k - Number of used nearest neighbors. Should be greater than 1.
+
results - Vector with results of prediction (regression or classification) for each input
+ sample. It is a single-precision floating-point vector with <number_of_samples> elements.
+ precision floating-point matrix of <number_of_samples> * k size.
+ is a single-precision floating-point matrix of <number_of_samples> * k size.
+
+ For each input vector (a row of the matrix samples), the method finds the k nearest neighbors.
+ In case of regression, the predicted result is a mean value of the particular vector's neighbor
+ responses. In case of classification, the class is determined by voting.
+
+ For each input vector, the neighbors are sorted by their distances to the vector.
+
+ In case of C++ interface you can use output pointers to empty matrices and the function will
+ allocate memory itself.
+
+ If only a single input vector is passed, all output matrices are optional and the predicted
+ value is returned by the method.
+
+ The function is parallelized with the TBB library.
public float findNearest(Mat samples,
+ int k,
+ Mat results,
+ Mat neighborResponses)
+
Finds the neighbors and predicts responses for input vectors.
+
+
Parameters:
+
samples - Input samples stored by rows. It is a single-precision floating-point matrix of
+ <number_of_samples> * k size.
+
k - Number of used nearest neighbors. Should be greater than 1.
+
results - Vector with results of prediction (regression or classification) for each input
+ sample. It is a single-precision floating-point vector with <number_of_samples> elements.
+
neighborResponses - Optional output values for corresponding neighbors. It is a single-
+ precision floating-point matrix of <number_of_samples> * k size.
+ is a single-precision floating-point matrix of <number_of_samples> * k size.
+
+ For each input vector (a row of the matrix samples), the method finds the k nearest neighbors.
+ In case of regression, the predicted result is a mean value of the particular vector's neighbor
+ responses. In case of classification, the class is determined by voting.
+
+ For each input vector, the neighbors are sorted by their distances to the vector.
+
+ In case of C++ interface you can use output pointers to empty matrices and the function will
+ allocate memory itself.
+
+ If only a single input vector is passed, all output matrices are optional and the predicted
+ value is returned by the method.
+
+ The function is parallelized with the TBB library.
public float findNearest(Mat samples,
+ int k,
+ Mat results,
+ Mat neighborResponses,
+ Mat dist)
+
Finds the neighbors and predicts responses for input vectors.
+
+
Parameters:
+
samples - Input samples stored by rows. It is a single-precision floating-point matrix of
+ <number_of_samples> * k size.
+
k - Number of used nearest neighbors. Should be greater than 1.
+
results - Vector with results of prediction (regression or classification) for each input
+ sample. It is a single-precision floating-point vector with <number_of_samples> elements.
+
neighborResponses - Optional output values for corresponding neighbors. It is a single-
+ precision floating-point matrix of <number_of_samples> * k size.
+
dist - Optional output distances from the input vectors to the corresponding neighbors. It
+ is a single-precision floating-point matrix of <number_of_samples> * k size.
+
+ For each input vector (a row of the matrix samples), the method finds the k nearest neighbors.
+ In case of regression, the predicted result is a mean value of the particular vector's neighbor
+ responses. In case of classification, the class is determined by voting.
+
+ For each input vector, the neighbors are sorted by their distances to the vector.
+
+ In case of C++ interface you can use output pointers to empty matrices and the function will
+ allocate memory itself.
+
+ If only a single input vector is passed, all output matrices are optional and the predicted
+ value is returned by the method.
+
+ The function is parallelized with the TBB library.
public static KNearest load(java.lang.String filepath)
+
Loads and creates a serialized knearest from a file
+
+ Use KNearest::save to serialize and store an KNearest to disk.
+ Load the KNearest from this file again, by calling this function with the path to the file.
This function returns the trained parameters arranged across rows.
+
+ For a two class classification problem, it returns a row matrix. It returns learnt parameters of
+ the Logistic Regression as a matrix of type CV_32F.
Loads and creates a serialized LogisticRegression from a file
+
+ Use LogisticRegression::save to serialize and store an LogisticRegression to disk.
+ Load the LogisticRegression from this file again, by calling this function with the path to the file.
+ Optionally specify the node for the file containing the classifier
public static LogisticRegression load(java.lang.String filepath,
+ java.lang.String nodeName)
+
Loads and creates a serialized LogisticRegression from a file
+
+ Use LogisticRegression::save to serialize and store an LogisticRegression to disk.
+ Load the LogisticRegression from this file again, by calling this function with the path to the file.
+ Optionally specify the node for the file containing the classifier
samples - The input data for the prediction algorithm. Matrix [m x n], where each row
+ contains variables (features) of one object being classified. Should have data type CV_32F.
samples - The input data for the prediction algorithm. Matrix [m x n], where each row
+ contains variables (features) of one object being classified. Should have data type CV_32F.
+
results - Predicted labels as a column matrix of type CV_32S.
samples - The input data for the prediction algorithm. Matrix [m x n], where each row
+ contains variables (features) of one object being classified. Should have data type CV_32F.
+
results - Predicted labels as a column matrix of type CV_32S.
Loads and creates a serialized NormalBayesClassifier from a file
+
+ Use NormalBayesClassifier::save to serialize and store an NormalBayesClassifier to disk.
Loads and creates a serialized NormalBayesClassifier from a file
+
+ Use NormalBayesClassifier::save to serialize and store an NormalBayesClassifier to disk.
Loads and creates a serialized NormalBayesClassifier from a file
+
+ Use NormalBayesClassifier::save to serialize and store an NormalBayesClassifier to disk.
+ Load the NormalBayesClassifier from this file again, by calling this function with the path to the file.
+ Optionally specify the node for the file containing the classifier
+
+
Parameters:
+
filepath - path to serialized NormalBayesClassifier
public static NormalBayesClassifier load(java.lang.String filepath,
+ java.lang.String nodeName)
+
Loads and creates a serialized NormalBayesClassifier from a file
+
+ Use NormalBayesClassifier::save to serialize and store an NormalBayesClassifier to disk.
+ Load the NormalBayesClassifier from this file again, by calling this function with the path to the file.
+ Optionally specify the node for the file containing the classifier
+
+
Parameters:
+
filepath - path to serialized NormalBayesClassifier
public float predictProb(Mat inputs,
+ Mat outputs,
+ Mat outputProbs)
+
Predicts the response for sample(s).
+
+ The method estimates the most probable classes for input vectors. Input vectors (one or more)
+ are stored as rows of the matrix inputs. In case of multiple input vectors, there should be one
+ output vector outputs. The predicted class for a single input vector is returned by the method.
+ The vector outputProbs contains the output probabilities corresponding to each element of
+ result.
public float predictProb(Mat inputs,
+ Mat outputs,
+ Mat outputProbs,
+ int flags)
+
Predicts the response for sample(s).
+
+ The method estimates the most probable classes for input vectors. Input vectors (one or more)
+ are stored as rows of the matrix inputs. In case of multiple input vectors, there should be one
+ output vector outputs. The predicted class for a single input vector is returned by the method.
+ The vector outputProbs contains the output probabilities corresponding to each element of
+ result.
The structure represents the logarithmic grid range of statmodel parameters.
+
+ It is used for optimizing statmodel accuracy by varying model parameters, the accuracy estimate
+ being computed by cross-validation.
Creates the empty model.
+ Use StatModel::train to train the model, StatModel::train to create and train the model,
+ Algorithm::load to load the pre-trained model.
Returns the OOB error value, computed at the training stage when calcOOBError is set to true.
+ If this flag was set to false, 0 is returned. The OOB error is also scaled by sample weighting.
Returns the variable importance array.
+ The method returns the variable importance vector, computed at the training stage when
+ CalculateVarImportance is set to true. If this flag was set to false, the empty matrix is
+ returned.
public void getVotes(Mat samples,
+ Mat results,
+ int flags)
+
Returns the result of each individual tree in the forest.
+ In case the model is a regression problem, the method will return each of the trees'
+ results for each of the sample cases. If the model is a classifier, it will return
+ a Mat with samples + 1 rows, where the first row gives the class number and the
+ following rows return the votes each class had for each sample.
+
+
Parameters:
+
samples - Array containing the samples for which votes will be calculated.
+
results - Array where the result of the calculation will be written.
public static RTrees load(java.lang.String filepath)
+
Loads and creates a serialized RTree from a file
+
+ Use RTree::save to serialize and store an RTree to disk.
+ Load the RTree from this file again, by calling this function with the path to the file.
+ Optionally specify the node for the file containing the classifier
public static RTrees load(java.lang.String filepath,
+ java.lang.String nodeName)
+
Loads and creates a serialized RTree from a file
+
+ Use RTree::save to serialize and store an RTree to disk.
+ Load the RTree from this file again, by calling this function with the path to the file.
+ Optionally specify the node for the file containing the classifier
Retrieves all the support vectors
+
+ The method returns all the support vectors as a floating-point matrix, where support vectors are
+ stored as matrix rows.
Retrieves all the uncompressed support vectors of a linear %SVM
+
+ The method returns all the uncompressed support vectors of a linear %SVM that the compressed
+ support vector, used for prediction, was derived from.
Creates empty model.
+ Use StatModel::train to train the model. Since %SVM has several parameters, you may want to
+ find the best parameters for your problem, it can be done with SVM::trainAuto.
public double getDecisionFunction(int i,
+ Mat alpha,
+ Mat svidx)
+
Retrieves the decision function
+
+
Parameters:
+
i - the index of the decision function. If the problem solved is regression, 1-class or
+ 2-class classification, then there will be just one decision function and the index should
+ always be 0. Otherwise, in the case of N-class classification, there will be \(N(N-1)/2\)
+ decision functions.
+
alpha - the optional output vector for weights, corresponding to different support vectors.
+ In the case of linear %SVM all the alpha's will be 1's.
+
svidx - the optional output vector of indices of support vectors within the matrix of
+ support vectors (which can be retrieved by SVM::getSupportVectors). In the case of linear
+ %SVM each decision function consists of a single "compressed" support vector.
+
+ The method returns rho parameter of the decision function, a scalar subtracted from the weighted
+ sum of kernel responses.
public static ParamGrid getDefaultGridPtr(int param_id)
+
Generates a grid for %SVM parameters.
+
+
Parameters:
+
param_id - %SVM parameters IDs that must be one of the SVM::ParamTypes. The grid is
+ generated for the parameter with this ID.
+
+ The function generates a grid pointer for the specified parameter of the %SVM algorithm.
+ The grid may be passed to the function SVM::trainAuto.
Retrieves all the support vectors
+
+ The method returns all the support vectors as a floating-point matrix, where support vectors are
+ stored as matrix rows.
Retrieves all the uncompressed support vectors of a linear %SVM
+
+ The method returns all the uncompressed support vectors of a linear %SVM that the compressed
+ support vector, used for prediction, was derived from. They are returned in a floating-point
+ matrix, where the support vectors are stored as matrix rows.
Loads and creates a serialized svm from a file
+
+ Use SVM::save to serialize and store an SVM to disk.
+ Load the SVM from this file again, by calling this function with the path to the file.
public boolean trainAuto(Mat samples,
+ int layout,
+ Mat responses)
+
Trains an %SVM with optimal parameters
+
+
Parameters:
+
samples - training samples
+
layout - See ml::SampleTypes.
+
responses - vector of responses associated with the training samples.
+ subset is used to test the model, the others form the train set. So, the %SVM algorithm is
+ balanced cross-validation subsets that is proportions between classes in subsets are close
+ to such proportion in the whole train dataset.
+
+ The method trains the %SVM model automatically by choosing the optimal parameters C, gamma, p,
+ nu, coef0, degree. Parameters are considered optimal when the cross-validation
+ estimate of the test set error is minimal.
+
+ This function only makes use of SVM::getDefaultGrid for parameter optimization and thus only
+ offers rudimentary parameter options.
+
+ This function works for the classification (SVM::C_SVC or SVM::NU_SVC) as well as for the
+ regression (SVM::EPS_SVR or SVM::NU_SVR). If it is SVM::ONE_CLASS, no optimization is made and
+ the usual %SVM with parameters specified in params is executed.
public boolean trainAuto(Mat samples,
+ int layout,
+ Mat responses,
+ int kFold)
+
Trains an %SVM with optimal parameters
+
+
Parameters:
+
samples - training samples
+
layout - See ml::SampleTypes.
+
responses - vector of responses associated with the training samples.
+
kFold - Cross-validation parameter. The training set is divided into kFold subsets. One
+ subset is used to test the model, the others form the train set. So, the %SVM algorithm is
+ balanced cross-validation subsets that is proportions between classes in subsets are close
+ to such proportion in the whole train dataset.
+
+ The method trains the %SVM model automatically by choosing the optimal parameters C, gamma, p,
+ nu, coef0, degree. Parameters are considered optimal when the cross-validation
+ estimate of the test set error is minimal.
+
+ This function only makes use of SVM::getDefaultGrid for parameter optimization and thus only
+ offers rudimentary parameter options.
+
+ This function works for the classification (SVM::C_SVC or SVM::NU_SVC) as well as for the
+ regression (SVM::EPS_SVR or SVM::NU_SVR). If it is SVM::ONE_CLASS, no optimization is made and
+ the usual %SVM with parameters specified in params is executed.
public boolean trainAuto(Mat samples,
+ int layout,
+ Mat responses,
+ int kFold,
+ ParamGrid Cgrid)
+
Trains an %SVM with optimal parameters
+
+
Parameters:
+
samples - training samples
+
layout - See ml::SampleTypes.
+
responses - vector of responses associated with the training samples.
+
kFold - Cross-validation parameter. The training set is divided into kFold subsets. One
+ subset is used to test the model, the others form the train set. So, the %SVM algorithm is
+
Cgrid - grid for C
+ balanced cross-validation subsets that is proportions between classes in subsets are close
+ to such proportion in the whole train dataset.
+
+ The method trains the %SVM model automatically by choosing the optimal parameters C, gamma, p,
+ nu, coef0, degree. Parameters are considered optimal when the cross-validation
+ estimate of the test set error is minimal.
+
+ This function only makes use of SVM::getDefaultGrid for parameter optimization and thus only
+ offers rudimentary parameter options.
+
+ This function works for the classification (SVM::C_SVC or SVM::NU_SVC) as well as for the
+ regression (SVM::EPS_SVR or SVM::NU_SVR). If it is SVM::ONE_CLASS, no optimization is made and
+ the usual %SVM with parameters specified in params is executed.
public boolean trainAuto(Mat samples,
+ int layout,
+ Mat responses,
+ int kFold,
+ ParamGrid Cgrid,
+ ParamGrid gammaGrid)
+
Trains an %SVM with optimal parameters
+
+
Parameters:
+
samples - training samples
+
layout - See ml::SampleTypes.
+
responses - vector of responses associated with the training samples.
+
kFold - Cross-validation parameter. The training set is divided into kFold subsets. One
+ subset is used to test the model, the others form the train set. So, the %SVM algorithm is
+
Cgrid - grid for C
+
gammaGrid - grid for gamma
+ balanced cross-validation subsets that is proportions between classes in subsets are close
+ to such proportion in the whole train dataset.
+
+ The method trains the %SVM model automatically by choosing the optimal parameters C, gamma, p,
+ nu, coef0, degree. Parameters are considered optimal when the cross-validation
+ estimate of the test set error is minimal.
+
+ This function only makes use of SVM::getDefaultGrid for parameter optimization and thus only
+ offers rudimentary parameter options.
+
+ This function works for the classification (SVM::C_SVC or SVM::NU_SVC) as well as for the
+ regression (SVM::EPS_SVR or SVM::NU_SVR). If it is SVM::ONE_CLASS, no optimization is made and
+ the usual %SVM with parameters specified in params is executed.
public boolean trainAuto(Mat samples,
+ int layout,
+ Mat responses,
+ int kFold,
+ ParamGrid Cgrid,
+ ParamGrid gammaGrid,
+ ParamGrid pGrid)
+
Trains an %SVM with optimal parameters
+
+
Parameters:
+
samples - training samples
+
layout - See ml::SampleTypes.
+
responses - vector of responses associated with the training samples.
+
kFold - Cross-validation parameter. The training set is divided into kFold subsets. One
+ subset is used to test the model, the others form the train set. So, the %SVM algorithm is
+
Cgrid - grid for C
+
gammaGrid - grid for gamma
+
pGrid - grid for p
+ balanced cross-validation subsets that is proportions between classes in subsets are close
+ to such proportion in the whole train dataset.
+
+ The method trains the %SVM model automatically by choosing the optimal parameters C, gamma, p,
+ nu, coef0, degree. Parameters are considered optimal when the cross-validation
+ estimate of the test set error is minimal.
+
+ This function only makes use of SVM::getDefaultGrid for parameter optimization and thus only
+ offers rudimentary parameter options.
+
+ This function works for the classification (SVM::C_SVC or SVM::NU_SVC) as well as for the
+ regression (SVM::EPS_SVR or SVM::NU_SVR). If it is SVM::ONE_CLASS, no optimization is made and
+ the usual %SVM with parameters specified in params is executed.
responses - vector of responses associated with the training samples.
+
kFold - Cross-validation parameter. The training set is divided into kFold subsets. One
+ subset is used to test the model, the others form the train set. So, the %SVM algorithm is
+
Cgrid - grid for C
+
gammaGrid - grid for gamma
+
pGrid - grid for p
+
nuGrid - grid for nu
+ balanced cross-validation subsets that is proportions between classes in subsets are close
+ to such proportion in the whole train dataset.
+
+ The method trains the %SVM model automatically by choosing the optimal parameters C, gamma, p,
+ nu, coef0, degree. Parameters are considered optimal when the cross-validation
+ estimate of the test set error is minimal.
+
+ This function only makes use of SVM::getDefaultGrid for parameter optimization and thus only
+ offers rudimentary parameter options.
+
+ This function works for the classification (SVM::C_SVC or SVM::NU_SVC) as well as for the
+ regression (SVM::EPS_SVR or SVM::NU_SVR). If it is SVM::ONE_CLASS, no optimization is made and
+ the usual %SVM with parameters specified in params is executed.
responses - vector of responses associated with the training samples.
+
kFold - Cross-validation parameter. The training set is divided into kFold subsets. One
+ subset is used to test the model, the others form the train set. So, the %SVM algorithm is
+
Cgrid - grid for C
+
gammaGrid - grid for gamma
+
pGrid - grid for p
+
nuGrid - grid for nu
+
coeffGrid - grid for coeff
+ balanced cross-validation subsets that is proportions between classes in subsets are close
+ to such proportion in the whole train dataset.
+
+ The method trains the %SVM model automatically by choosing the optimal parameters C, gamma, p,
+ nu, coef0, degree. Parameters are considered optimal when the cross-validation
+ estimate of the test set error is minimal.
+
+ This function only makes use of SVM::getDefaultGrid for parameter optimization and thus only
+ offers rudimentary parameter options.
+
+ This function works for the classification (SVM::C_SVC or SVM::NU_SVC) as well as for the
+ regression (SVM::EPS_SVR or SVM::NU_SVR). If it is SVM::ONE_CLASS, no optimization is made and
+ the usual %SVM with parameters specified in params is executed.
responses - vector of responses associated with the training samples.
+
kFold - Cross-validation parameter. The training set is divided into kFold subsets. One
+ subset is used to test the model, the others form the train set. So, the %SVM algorithm is
+
Cgrid - grid for C
+
gammaGrid - grid for gamma
+
pGrid - grid for p
+
nuGrid - grid for nu
+
coeffGrid - grid for coeff
+
degreeGrid - grid for degree
+ balanced cross-validation subsets that is proportions between classes in subsets are close
+ to such proportion in the whole train dataset.
+
+ The method trains the %SVM model automatically by choosing the optimal parameters C, gamma, p,
+ nu, coef0, degree. Parameters are considered optimal when the cross-validation
+ estimate of the test set error is minimal.
+
+ This function only makes use of SVM::getDefaultGrid for parameter optimization and thus only
+ offers rudimentary parameter options.
+
+ This function works for the classification (SVM::C_SVC or SVM::NU_SVC) as well as for the
+ regression (SVM::EPS_SVR or SVM::NU_SVR). If it is SVM::ONE_CLASS, no optimization is made and
+ the usual %SVM with parameters specified in params is executed.
responses - vector of responses associated with the training samples.
+
kFold - Cross-validation parameter. The training set is divided into kFold subsets. One
+ subset is used to test the model, the others form the train set. So, the %SVM algorithm is
+
Cgrid - grid for C
+
gammaGrid - grid for gamma
+
pGrid - grid for p
+
nuGrid - grid for nu
+
coeffGrid - grid for coeff
+
degreeGrid - grid for degree
+
balanced - If true and the problem is 2-class classification then the method creates more
+ balanced cross-validation subsets that is proportions between classes in subsets are close
+ to such proportion in the whole train dataset.
+
+ The method trains the %SVM model automatically by choosing the optimal parameters C, gamma, p,
+ nu, coef0, degree. Parameters are considered optimal when the cross-validation
+ estimate of the test set error is minimal.
+
+ This function only makes use of SVM::getDefaultGrid for parameter optimization and thus only
+ offers rudimentary parameter options.
+
+ This function works for the classification (SVM::C_SVC or SVM::NU_SVC) as well as for the
+ regression (SVM::EPS_SVR or SVM::NU_SVR). If it is SVM::ONE_CLASS, no optimization is made and
+ the usual %SVM with parameters specified in params is executed.
Creates empty model.
+ Use StatModel::train to train the model. Since %SVMSGD has several parameters, you may want to
+ find the best parameters for your problem or use setOptimalParameters() to set some default parameters.
public static SVMSGD load(java.lang.String filepath)
+
Loads and creates a serialized SVMSGD from a file
+
+ Use SVMSGD::save to serialize and store an SVMSGD to disk.
+ Load the SVMSGD from this file again, by calling this function with the path to the file.
+ Optionally specify the node for the file containing the classifier
public static SVMSGD load(java.lang.String filepath,
+ java.lang.String nodeName)
+
Loads and creates a serialized SVMSGD from a file
+
+ Use SVMSGD::save to serialize and store an SVMSGD to disk.
+ Load the SVMSGD from this file again, by calling this function with the path to the file.
+ Optionally specify the node for the file containing the classifier
public float calcError(TrainData data,
+ boolean test,
+ Mat resp)
+
Computes error on the training or test dataset
+
+
Parameters:
+
data - the training data
+
test - if true, the error is computed over the test subset of the data, otherwise it's
+ computed over the training subset of the data. Please note that if you loaded a completely
+ different dataset to evaluate already trained classifier, you will probably want not to set
+ the test subset at all with TrainData::setTrainTestSplitRatio and specify test=false, so
+ that the error is computed for the whole new set. Yes, this sounds a bit confusing.
+
resp - the optional output responses.
+
+ The method uses StatModel::predict to compute the error. For regression models the error is
+ computed as RMS, for classifiers - as a percent of missclassified samples (0%-100%).
trainData - training data that can be loaded from file using TrainData::loadFromCSV or
+ created with TrainData::create.
+ new training samples, not completely overwritten (such as NormalBayesClassifier or ANN_MLP).
public boolean train(TrainData trainData,
+ int flags)
+
Trains the statistical model
+
+
Parameters:
+
trainData - training data that can be loaded from file using TrainData::loadFromCSV or
+ created with TrainData::create.
+
flags - optional flags, depending on the model. Some of the models can be updated with the
+ new training samples, not completely overwritten (such as NormalBayesClassifier or ANN_MLP).
Class encapsulating training data.
+
+ Please note that the class only specifies the interface of training data, but not implementation.
+ All the statistical model classes in _ml_ module accepts Ptr<TrainData> as parameter. In other
+ words, you can create your own class derived from TrainData and pass smart pointer to the instance
+ of this class into StatModel::train.
+
+ SEE: REF: ml_intro_data
Splits the training data into the training and test parts
+
+ The function selects a subset of specified relative size and then returns it as the training
+ set.
Splits the training data into the training and test parts
+
+ The function selects a subset of specified relative size and then returns it as the training
+ set.
public static TrainData create(Mat samples,
+ int layout,
+ Mat responses)
+
Creates training data from in-memory arrays.
+
+
Parameters:
+
samples - matrix of samples. It should have CV_32F type.
+
layout - see ml::SampleTypes.
+
responses - matrix of responses. If the responses are scalar, they should be stored as a
+ single row or as a single column. The matrix should have type CV_32F or CV_32S (in the
+ former case the responses are considered as ordered by default; in the latter case - as
+ categorical)
+ (CV_32S) containing 0-based variable indices or byte vector (CV_8U) containing a mask of
+ active variables.
+ vector (CV_32S) containing 0-based sample indices or byte vector (CV_8U) containing a mask
+ of training samples.
+ <number_of_variables_in_responses>`, containing types of each input and output variable. See
+ ml::VariableTypes.
public static TrainData create(Mat samples,
+ int layout,
+ Mat responses,
+ Mat varIdx)
+
Creates training data from in-memory arrays.
+
+
Parameters:
+
samples - matrix of samples. It should have CV_32F type.
+
layout - see ml::SampleTypes.
+
responses - matrix of responses. If the responses are scalar, they should be stored as a
+ single row or as a single column. The matrix should have type CV_32F or CV_32S (in the
+ former case the responses are considered as ordered by default; in the latter case - as
+ categorical)
+
varIdx - vector specifying which variables to use for training. It can be an integer vector
+ (CV_32S) containing 0-based variable indices or byte vector (CV_8U) containing a mask of
+ active variables.
+ vector (CV_32S) containing 0-based sample indices or byte vector (CV_8U) containing a mask
+ of training samples.
+ <number_of_variables_in_responses>`, containing types of each input and output variable. See
+ ml::VariableTypes.
public static TrainData create(Mat samples,
+ int layout,
+ Mat responses,
+ Mat varIdx,
+ Mat sampleIdx)
+
Creates training data from in-memory arrays.
+
+
Parameters:
+
samples - matrix of samples. It should have CV_32F type.
+
layout - see ml::SampleTypes.
+
responses - matrix of responses. If the responses are scalar, they should be stored as a
+ single row or as a single column. The matrix should have type CV_32F or CV_32S (in the
+ former case the responses are considered as ordered by default; in the latter case - as
+ categorical)
+
varIdx - vector specifying which variables to use for training. It can be an integer vector
+ (CV_32S) containing 0-based variable indices or byte vector (CV_8U) containing a mask of
+ active variables.
+
sampleIdx - vector specifying which samples to use for training. It can be an integer
+ vector (CV_32S) containing 0-based sample indices or byte vector (CV_8U) containing a mask
+ of training samples.
+ <number_of_variables_in_responses>`, containing types of each input and output variable. See
+ ml::VariableTypes.
public static TrainData create(Mat samples,
+ int layout,
+ Mat responses,
+ Mat varIdx,
+ Mat sampleIdx,
+ Mat sampleWeights)
+
Creates training data from in-memory arrays.
+
+
Parameters:
+
samples - matrix of samples. It should have CV_32F type.
+
layout - see ml::SampleTypes.
+
responses - matrix of responses. If the responses are scalar, they should be stored as a
+ single row or as a single column. The matrix should have type CV_32F or CV_32S (in the
+ former case the responses are considered as ordered by default; in the latter case - as
+ categorical)
+
varIdx - vector specifying which variables to use for training. It can be an integer vector
+ (CV_32S) containing 0-based variable indices or byte vector (CV_8U) containing a mask of
+ active variables.
+
sampleIdx - vector specifying which samples to use for training. It can be an integer
+ vector (CV_32S) containing 0-based sample indices or byte vector (CV_8U) containing a mask
+ of training samples.
+
sampleWeights - optional vector with weights for each sample. It should have CV_32F type.
+ <number_of_variables_in_responses>`, containing types of each input and output variable. See
+ ml::VariableTypes.
public static TrainData create(Mat samples,
+ int layout,
+ Mat responses,
+ Mat varIdx,
+ Mat sampleIdx,
+ Mat sampleWeights,
+ Mat varType)
+
Creates training data from in-memory arrays.
+
+
Parameters:
+
samples - matrix of samples. It should have CV_32F type.
+
layout - see ml::SampleTypes.
+
responses - matrix of responses. If the responses are scalar, they should be stored as a
+ single row or as a single column. The matrix should have type CV_32F or CV_32S (in the
+ former case the responses are considered as ordered by default; in the latter case - as
+ categorical)
+
varIdx - vector specifying which variables to use for training. It can be an integer vector
+ (CV_32S) containing 0-based variable indices or byte vector (CV_8U) containing a mask of
+ active variables.
+
sampleIdx - vector specifying which samples to use for training. It can be an integer
+ vector (CV_32S) containing 0-based sample indices or byte vector (CV_8U) containing a mask
+ of training samples.
+
sampleWeights - optional vector with weights for each sample. It should have CV_32F type.
+
varType - optional vector of type CV_8U and size `<number_of_variables_in_samples> +
+ <number_of_variables_in_responses>`, containing types of each input and output variable. See
+ ml::VariableTypes.
Returns the vector of normalized categorical responses
+
+ The function returns vector of responses. Each response is integer from 0 to `<number of
+ classes>-1`. The actual label value can be retrieved then from the class label vector, see
+ TrainData::getClassLabels.
Returns matrix of train samples
+
+ transposed. See ml::SampleTypes.
+ sampleIdx)
+ the active variables.
+
+ In current implementation the function tries to avoid physical data copying and returns the
+ matrix stored inside TrainData (unless the transposition or compression is needed).
layout - The requested layout. If it's different from the initial one, the matrix is
+ transposed. See ml::SampleTypes.
+ sampleIdx)
+ the active variables.
+
+ In current implementation the function tries to avoid physical data copying and returns the
+ matrix stored inside TrainData (unless the transposition or compression is needed).
public Mat getTrainSamples(int layout,
+ boolean compressSamples)
+
Returns matrix of train samples
+
+
Parameters:
+
layout - The requested layout. If it's different from the initial one, the matrix is
+ transposed. See ml::SampleTypes.
+
compressSamples - if true, the function returns only the training samples (specified by
+ sampleIdx)
+ the active variables.
+
+ In current implementation the function tries to avoid physical data copying and returns the
+ matrix stored inside TrainData (unless the transposition or compression is needed).
public Mat getTrainSamples(int layout,
+ boolean compressSamples,
+ boolean compressVars)
+
Returns matrix of train samples
+
+
Parameters:
+
layout - The requested layout. If it's different from the initial one, the matrix is
+ transposed. See ml::SampleTypes.
+
compressSamples - if true, the function returns only the training samples (specified by
+ sampleIdx)
+
compressVars - if true, the function returns the shorter training samples, containing only
+ the active variables.
+
+ In current implementation the function tries to avoid physical data copying and returns the
+ matrix stored inside TrainData (unless the transposition or compression is needed).
Splits the training data into the training and test parts
+
+ The function selects a subset of specified relative size and then returns it as the training
+ set. If the function is not called, all the data is used for training. Please, note that for
+ each of TrainData::getTrain\* there is corresponding TrainData::getTest\*, so that the test
+ subset can be retrieved and processed as well.
+ SEE: TrainData::setTrainTestSplit
public void setTrainTestSplitRatio(double ratio,
+ boolean shuffle)
+
Splits the training data into the training and test parts
+
+ The function selects a subset of specified relative size and then returns it as the training
+ set. If the function is not called, all the data is used for training. Please, note that for
+ each of TrainData::getTrain\* there is corresponding TrainData::getTest\*, so that the test
+ subset can be retrieved and processed as well.
+ SEE: TrainData::setTrainTestSplit
The main functionality of ArucoDetector class is detection of markers in an image with detectMarkers() method.
+
+ After detecting some markers in the image, you can try to find undetected markers from this dictionary with
+ refineDetectedMarkers() method.
+
+ SEE: DetectorParameters, RefineParameters
public void detectMarkers(Mat image,
+ java.util.List<Mat> corners,
+ Mat ids)
+
Basic marker detection
+
+
Parameters:
+
image - input image
+
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.
+
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.
+ correct codification. Useful for debugging purposes.
+
+ 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.
+ Note: The function does not correct lens distortion or takes it into account. It's recommended to undistort
+ input image with corresponding camera model, if camera parameters are known
+ SEE: undistort, estimatePoseSingleMarkers, estimatePoseBoard
public void detectMarkers(Mat image,
+ java.util.List<Mat> corners,
+ Mat ids,
+ java.util.List<Mat> rejectedImgPoints)
+
Basic marker detection
+
+
Parameters:
+
image - input image
+
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.
+
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.
+
rejectedImgPoints - contains the imgPoints of those squares whose inner code has not a
+ correct codification. Useful for debugging purposes.
+
+ 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.
+ Note: The function does not correct lens distortion or takes it into account. It's recommended to undistort
+ input image with corresponding camera model, if camera parameters are known
+ SEE: undistort, estimatePoseSingleMarkers, estimatePoseBoard
public void refineDetectedMarkers(Mat image,
+ Board board,
+ java.util.List<Mat> detectedCorners,
+ Mat detectedIds,
+ java.util.List<Mat> rejectedCorners)
+
Refine not detected markers based on the already detected and the board layout
+
+
Parameters:
+
image - input image
+
board - layout of markers in the board.
+
detectedCorners - vector of already detected marker corners.
+
detectedIds - vector of already detected marker identifiers.
+
rejectedCorners - vector of rejected candidates during the marker detection process.
+ \(A = \vecthreethree{f_x}{0}{c_x}{0}{f_y}{c_y}{0}{0}{1}\)
+ \((k_1, k_2, p_1, p_2[, k_3[, k_4, k_5, k_6],[s_1, s_2, s_3, s_4]])\) of 4, 5, 8 or 12 elements
+ original rejectedCorners array.
+
+ 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.
public void refineDetectedMarkers(Mat image,
+ Board board,
+ java.util.List<Mat> detectedCorners,
+ Mat detectedIds,
+ java.util.List<Mat> rejectedCorners,
+ Mat cameraMatrix)
+
Refine not detected markers based on the already detected and the board layout
+
+
Parameters:
+
image - input image
+
board - layout of markers in the board.
+
detectedCorners - vector of already detected marker corners.
+
detectedIds - vector of already detected marker identifiers.
+
rejectedCorners - vector of rejected candidates during the marker detection process.
+
cameraMatrix - optional input 3x3 floating-point camera matrix
+ \(A = \vecthreethree{f_x}{0}{c_x}{0}{f_y}{c_y}{0}{0}{1}\)
+ \((k_1, k_2, p_1, p_2[, k_3[, k_4, k_5, k_6],[s_1, s_2, s_3, s_4]])\) of 4, 5, 8 or 12 elements
+ original rejectedCorners array.
+
+ 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.
distCoeffs - optional vector of distortion coefficients
+ \((k_1, k_2, p_1, p_2[, k_3[, k_4, k_5, k_6],[s_1, s_2, s_3, s_4]])\) of 4, 5, 8 or 12 elements
+ original rejectedCorners array.
+
+ 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.
public void refineDetectedMarkers(Mat image,
+ Board board,
+ java.util.List<Mat> detectedCorners,
+ Mat detectedIds,
+ java.util.List<Mat> rejectedCorners,
+ Mat cameraMatrix,
+ Mat distCoeffs,
+ Mat recoveredIdxs)
+
Refine not detected markers based on the already detected and the board layout
+
+
Parameters:
+
image - input image
+
board - layout of markers in the board.
+
detectedCorners - vector of already detected marker corners.
+
detectedIds - vector of already detected marker identifiers.
+
rejectedCorners - vector of rejected candidates during the marker detection process.
distCoeffs - optional vector of distortion coefficients
+ \((k_1, k_2, p_1, p_2[, k_3[, k_4, k_5, k_6],[s_1, s_2, s_3, s_4]])\) of 4, 5, 8 or 12 elements
+
recoveredIdxs - Optional array to returns the indexes of the recovered candidates in the
+ original rejectedCorners array.
+
+ 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.
public boolean decodeWithType(Mat img,
+ Mat points,
+ java.util.List<java.lang.String> decoded_info,
+ java.util.List<java.lang.String> decoded_type)
+
Decodes barcode in image once it's found by the detect() method.
+
+
Parameters:
+
img - grayscale or color (BGR) image containing bar code.
+
points - vector of rotated rectangle vertices found by detect() method (or some other algorithm).
+ For N detected barcodes, the dimensions of this array should be [N][4].
+ Order of four points in vector<Point2f> is bottomLeft, topLeft, topRight, bottomRight.
+
decoded_info - UTF8-encoded output vector of string or empty vector of string if the codes cannot be decoded.
+
decoded_type - vector strings, specifies the type of these barcodes
+
Returns:
+
true if at least one valid barcode have been found
Board of ArUco 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.
public void generateImage(Size outSize,
+ Mat img)
+
Draw a planar board
+
+
Parameters:
+
outSize - size of the output image in pixels.
+
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.
+
+ This function return the image of the board, ready to be printed.
public java.util.List<MatOfPoint3f> getObjPoints()
+
return array of object points of all the marker corners in the board.
+
+ Each marker include its 4 corners in this order:
+ - objPoints[i][0] - left-top point of i-th marker
+ - objPoints[i][1] - right-top point of i-th marker
+ - objPoints[i][2] - right-bottom point of i-th marker
+ - objPoints[i][3] - left-bottom point of i-th marker
+
+ Markers are placed in a certain order - row by row, left to right in every row. For M markers, the size is Mx4.
public void matchImagePoints(java.util.List<Mat> detectedCorners,
+ Mat detectedIds,
+ Mat objPoints,
+ Mat imgPoints)
+
Given a board configuration and a set of detected markers, returns the corresponding
+ image points and object points, can be used in solvePnP()
+
+
Parameters:
+
detectedCorners - List of detected marker corners of the board.
+ For cv::Board and cv::GridBoard the method expects std::vector<std::vector<Point2f>> or std::vector<Mat> with Aruco marker corners.
+ For cv::CharucoBoard the method expects std::vector<Point2f> or Mat with ChAruco corners (chess board corners matched with Aruco markers).
+
detectedIds - List of identifiers for each marker or charuco corner.
+ For any Board class the method expects std::vector<int> or Mat.
+
objPoints - Vector of marker points in the board coordinate space.
+ For any Board class the method expects std::vector<cv::Point3f> objectPoints or cv::Mat
+
imgPoints - Vector of marker points in the image coordinate space.
+ For any Board class the method expects std::vector<cv::Point2f> objectPoints or cv::Mat
+
+ SEE: solvePnP
public void detectMultiScale(Mat image,
+ MatOfRect objects)
+
Detects objects of different sizes in the input image. The detected objects are returned as a list
+ of rectangles.
+
+
Parameters:
+
image - Matrix of the type CV_8U containing an image where objects are detected.
+
objects - Vector of rectangles where each rectangle contains the detected object, the
+ rectangles may be partially outside the original image.
+ to retain it.
+ cvHaarDetectObjects. It is not used for a new cascade.
public void detectMultiScale(Mat image,
+ MatOfRect objects,
+ double scaleFactor)
+
Detects objects of different sizes in the input image. The detected objects are returned as a list
+ of rectangles.
+
+
Parameters:
+
image - Matrix of the type CV_8U containing an image where objects are detected.
+
objects - Vector of rectangles where each rectangle contains the detected object, the
+ rectangles may be partially outside the original image.
+
scaleFactor - Parameter specifying how much the image size is reduced at each image scale.
+ to retain it.
+ cvHaarDetectObjects. It is not used for a new cascade.
public void detectMultiScale(Mat image,
+ MatOfRect objects,
+ double scaleFactor,
+ int minNeighbors)
+
Detects objects of different sizes in the input image. The detected objects are returned as a list
+ of rectangles.
+
+
Parameters:
+
image - Matrix of the type CV_8U containing an image where objects are detected.
+
objects - Vector of rectangles where each rectangle contains the detected object, the
+ rectangles may be partially outside the original image.
+
scaleFactor - Parameter specifying how much the image size is reduced at each image scale.
+
minNeighbors - Parameter specifying how many neighbors each candidate rectangle should have
+ to retain it.
+ cvHaarDetectObjects. It is not used for a new cascade.
public void detectMultiScale2(Mat image,
+ MatOfRect objects,
+ MatOfInt numDetections)
+
+
Parameters:
+
image - Matrix of the type CV_8U containing an image where objects are detected.
+
objects - Vector of rectangles where each rectangle contains the detected object, the
+ rectangles may be partially outside the original image.
+
numDetections - Vector of detection numbers for the corresponding objects. An object's number
+ of detections is the number of neighboring positively classified rectangles that were joined
+ together to form the object.
+ to retain it.
+ cvHaarDetectObjects. It is not used for a new cascade.
image - Matrix of the type CV_8U containing an image where objects are detected.
+
objects - Vector of rectangles where each rectangle contains the detected object, the
+ rectangles may be partially outside the original image.
+
numDetections - Vector of detection numbers for the corresponding objects. An object's number
+ of detections is the number of neighboring positively classified rectangles that were joined
+ together to form the object.
+
scaleFactor - Parameter specifying how much the image size is reduced at each image scale.
+ to retain it.
+ cvHaarDetectObjects. It is not used for a new cascade.
public void detectMultiScale2(Mat image,
+ MatOfRect objects,
+ MatOfInt numDetections,
+ double scaleFactor,
+ int minNeighbors)
+
+
Parameters:
+
image - Matrix of the type CV_8U containing an image where objects are detected.
+
objects - Vector of rectangles where each rectangle contains the detected object, the
+ rectangles may be partially outside the original image.
+
numDetections - Vector of detection numbers for the corresponding objects. An object's number
+ of detections is the number of neighboring positively classified rectangles that were joined
+ together to form the object.
+
scaleFactor - Parameter specifying how much the image size is reduced at each image scale.
+
minNeighbors - Parameter specifying how many neighbors each candidate rectangle should have
+ to retain it.
+ cvHaarDetectObjects. It is not used for a new cascade.
public void detectMultiScale2(Mat image,
+ MatOfRect objects,
+ MatOfInt numDetections,
+ double scaleFactor,
+ int minNeighbors,
+ int flags)
+
+
Parameters:
+
image - Matrix of the type CV_8U containing an image where objects are detected.
+
objects - Vector of rectangles where each rectangle contains the detected object, the
+ rectangles may be partially outside the original image.
+
numDetections - Vector of detection numbers for the corresponding objects. An object's number
+ of detections is the number of neighboring positively classified rectangles that were joined
+ together to form the object.
+
scaleFactor - Parameter specifying how much the image size is reduced at each image scale.
+
minNeighbors - Parameter specifying how many neighbors each candidate rectangle should have
+ to retain it.
+
flags - Parameter with the same meaning for an old cascade as in the function
+ cvHaarDetectObjects. It is not used for a new cascade.
public void detectMultiScale2(Mat image,
+ MatOfRect objects,
+ MatOfInt numDetections,
+ double scaleFactor,
+ int minNeighbors,
+ int flags,
+ Size minSize)
+
+
Parameters:
+
image - Matrix of the type CV_8U containing an image where objects are detected.
+
objects - Vector of rectangles where each rectangle contains the detected object, the
+ rectangles may be partially outside the original image.
+
numDetections - Vector of detection numbers for the corresponding objects. An object's number
+ of detections is the number of neighboring positively classified rectangles that were joined
+ together to form the object.
+
scaleFactor - Parameter specifying how much the image size is reduced at each image scale.
+
minNeighbors - Parameter specifying how many neighbors each candidate rectangle should have
+ to retain it.
+
flags - Parameter with the same meaning for an old cascade as in the function
+ cvHaarDetectObjects. It is not used for a new cascade.
+
minSize - Minimum possible object size. Objects smaller than that are ignored.
public void detectMultiScale2(Mat image,
+ MatOfRect objects,
+ MatOfInt numDetections,
+ double scaleFactor,
+ int minNeighbors,
+ int flags,
+ Size minSize,
+ Size maxSize)
+
+
Parameters:
+
image - Matrix of the type CV_8U containing an image where objects are detected.
+
objects - Vector of rectangles where each rectangle contains the detected object, the
+ rectangles may be partially outside the original image.
+
numDetections - Vector of detection numbers for the corresponding objects. An object's number
+ of detections is the number of neighboring positively classified rectangles that were joined
+ together to form the object.
+
scaleFactor - Parameter specifying how much the image size is reduced at each image scale.
+
minNeighbors - Parameter specifying how many neighbors each candidate rectangle should have
+ to retain it.
+
flags - Parameter with the same meaning for an old cascade as in the function
+ cvHaarDetectObjects. It is not used for a new cascade.
+
minSize - Minimum possible object size. Objects smaller than that are ignored.
+
maxSize - Maximum possible object size. Objects larger than that are ignored. If maxSize == minSize model is evaluated on single scale.
This function allows you to retrieve the final stage decision certainty of classification.
+ For this, one needs to set outputRejectLevels on true and provide the rejectLevels and levelWeights parameter.
+ For each resulting detection, levelWeights will then contain the certainty of classification at the final stage.
+ This value can then be used to separate strong from weaker classifications.
+
+ A code sample on how to use it efficiently can be found below:
+
+ Mat img;
+ vector<double> weights;
+ vector<int> levels;
+ vector<Rect> detections;
+ CascadeClassifier model("/path/to/your/model.xml");
+ model.detectMultiScale(img, detections, levels, weights, 1.1, 3, 0, Size(), Size(), true);
+ cerr << "Detection " << detections[0] << " with weight " << weights[0] << endl;
+
This function allows you to retrieve the final stage decision certainty of classification.
+ For this, one needs to set outputRejectLevels on true and provide the rejectLevels and levelWeights parameter.
+ For each resulting detection, levelWeights will then contain the certainty of classification at the final stage.
+ This value can then be used to separate strong from weaker classifications.
+
+ A code sample on how to use it efficiently can be found below:
+
+ Mat img;
+ vector<double> weights;
+ vector<int> levels;
+ vector<Rect> detections;
+ CascadeClassifier model("/path/to/your/model.xml");
+ model.detectMultiScale(img, detections, levels, weights, 1.1, 3, 0, Size(), Size(), true);
+ cerr << "Detection " << detections[0] << " with weight " << weights[0] << endl;
+
public void detectMultiScale3(Mat image,
+ MatOfRect objects,
+ MatOfInt rejectLevels,
+ MatOfDouble levelWeights,
+ double scaleFactor,
+ int minNeighbors)
+
This function allows you to retrieve the final stage decision certainty of classification.
+ For this, one needs to set outputRejectLevels on true and provide the rejectLevels and levelWeights parameter.
+ For each resulting detection, levelWeights will then contain the certainty of classification at the final stage.
+ This value can then be used to separate strong from weaker classifications.
+
+ A code sample on how to use it efficiently can be found below:
+
+ Mat img;
+ vector<double> weights;
+ vector<int> levels;
+ vector<Rect> detections;
+ CascadeClassifier model("/path/to/your/model.xml");
+ model.detectMultiScale(img, detections, levels, weights, 1.1, 3, 0, Size(), Size(), true);
+ cerr << "Detection " << detections[0] << " with weight " << weights[0] << endl;
+
public void detectMultiScale3(Mat image,
+ MatOfRect objects,
+ MatOfInt rejectLevels,
+ MatOfDouble levelWeights,
+ double scaleFactor,
+ int minNeighbors,
+ int flags)
+
This function allows you to retrieve the final stage decision certainty of classification.
+ For this, one needs to set outputRejectLevels on true and provide the rejectLevels and levelWeights parameter.
+ For each resulting detection, levelWeights will then contain the certainty of classification at the final stage.
+ This value can then be used to separate strong from weaker classifications.
+
+ A code sample on how to use it efficiently can be found below:
+
+ Mat img;
+ vector<double> weights;
+ vector<int> levels;
+ vector<Rect> detections;
+ CascadeClassifier model("/path/to/your/model.xml");
+ model.detectMultiScale(img, detections, levels, weights, 1.1, 3, 0, Size(), Size(), true);
+ cerr << "Detection " << detections[0] << " with weight " << weights[0] << endl;
+
public void detectMultiScale3(Mat image,
+ MatOfRect objects,
+ MatOfInt rejectLevels,
+ MatOfDouble levelWeights,
+ double scaleFactor,
+ int minNeighbors,
+ int flags,
+ Size minSize)
+
This function allows you to retrieve the final stage decision certainty of classification.
+ For this, one needs to set outputRejectLevels on true and provide the rejectLevels and levelWeights parameter.
+ For each resulting detection, levelWeights will then contain the certainty of classification at the final stage.
+ This value can then be used to separate strong from weaker classifications.
+
+ A code sample on how to use it efficiently can be found below:
+
+ Mat img;
+ vector<double> weights;
+ vector<int> levels;
+ vector<Rect> detections;
+ CascadeClassifier model("/path/to/your/model.xml");
+ model.detectMultiScale(img, detections, levels, weights, 1.1, 3, 0, Size(), Size(), true);
+ cerr << "Detection " << detections[0] << " with weight " << weights[0] << endl;
+
public void detectMultiScale3(Mat image,
+ MatOfRect objects,
+ MatOfInt rejectLevels,
+ MatOfDouble levelWeights,
+ double scaleFactor,
+ int minNeighbors,
+ int flags,
+ Size minSize,
+ Size maxSize)
+
This function allows you to retrieve the final stage decision certainty of classification.
+ For this, one needs to set outputRejectLevels on true and provide the rejectLevels and levelWeights parameter.
+ For each resulting detection, levelWeights will then contain the certainty of classification at the final stage.
+ This value can then be used to separate strong from weaker classifications.
+
+ A code sample on how to use it efficiently can be found below:
+
+ Mat img;
+ vector<double> weights;
+ vector<int> levels;
+ vector<Rect> detections;
+ CascadeClassifier model("/path/to/your/model.xml");
+ model.detectMultiScale(img, detections, levels, weights, 1.1, 3, 0, Size(), Size(), true);
+ cerr << "Detection " << detections[0] << " with weight " << weights[0] << endl;
+
This function allows you to retrieve the final stage decision certainty of classification.
+ For this, one needs to set outputRejectLevels on true and provide the rejectLevels and levelWeights parameter.
+ For each resulting detection, levelWeights will then contain the certainty of classification at the final stage.
+ This value can then be used to separate strong from weaker classifications.
+
+ A code sample on how to use it efficiently can be found below:
+
+ Mat img;
+ vector<double> weights;
+ vector<int> levels;
+ vector<Rect> detections;
+ CascadeClassifier model("/path/to/your/model.xml");
+ model.detectMultiScale(img, detections, levels, weights, 1.1, 3, 0, Size(), Size(), true);
+ cerr << "Detection " << detections[0] << " with weight " << weights[0] << endl;
+
filename - Name of the file from which the classifier is loaded. The file may contain an old
+ HAAR classifier trained by the haartraining application or a new cascade classifier trained by the
+ traincascade application.
ChArUco board is a planar chessboard 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. The board image can be drawn using generateImage() method.
public boolean checkCharucoCornersCollinear(Mat charucoIds)
+
check whether the ChArUco markers are collinear
+
+
Parameters:
+
charucoIds - list of identifiers for each corner in charucoCorners per frame.
+
Returns:
+
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.
public void setLegacyPattern(boolean legacyPattern)
+
set legacy chessboard pattern.
+
+ Legacy setting creates chessboard patterns starting with a white box in the upper left corner
+ if there is an even row count of chessboard boxes, otherwise it starts with a black box.
+ This setting ensures compatibility to patterns created with OpenCV versions prior OpenCV 4.6.0.
+ See https://github.com/opencv/opencv/issues/23152.
+
+ Default value: false.
public void detectBoard(Mat image,
+ Mat charucoCorners,
+ Mat charucoIds)
+
detect aruco markers and interpolate position of ChArUco board corners
+
+
Parameters:
+
image - input image necesary for corner refinement. Note that markers are not detected and
+ should be sent in corners and ids parameters.
+
charucoCorners - interpolated chessboard corners.
+
charucoIds - interpolated chessboard corners identifiers.
+ 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.
+ If markerCorners and markerCorners are empty, the function detect aruco markers and ids.
+ If markerCorners and markerCorners are empty, the function detect aruco markers and ids.
+
+ 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 markerCorners and markerCorners are empty, the detectMarkers() will run and detect aruco markers and ids.
+
+ 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.
+ SEE: findChessboardCorners
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.
+ If markerCorners and markerCorners are empty, the function detect aruco markers and ids.
+ If markerCorners and markerCorners are empty, the function detect aruco markers and ids.
+
+ 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 markerCorners and markerCorners are empty, the detectMarkers() will run and detect aruco markers and ids.
+
+ 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.
+ SEE: findChessboardCorners
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.
+ If markerCorners and markerCorners are empty, the function detect aruco markers and ids.
+
markerIds - list of identifiers for each marker in corners.
+ If markerCorners and markerCorners are empty, the function detect aruco markers and ids.
+
+ 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 markerCorners and markerCorners are empty, the detectMarkers() will run and detect aruco markers and ids.
+
+ 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.
+ SEE: findChessboardCorners
public void detectDiamonds(Mat image,
+ java.util.List<Mat> diamondCorners,
+ Mat diamondIds)
+
Detect ChArUco Diamond markers
+
+
Parameters:
+
image - input image necessary for corner subpixel.
+
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> > ).
+
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.
+ If markerCorners and markerCorners are empty, the function detect aruco markers and ids.
+ If markerCorners and markerCorners are empty, the function detect aruco markers and ids.
+
+ 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 less accurate.
public void detectDiamonds(Mat image,
+ java.util.List<Mat> diamondCorners,
+ Mat diamondIds,
+ java.util.List<Mat> markerCorners)
+
Detect ChArUco Diamond markers
+
+
Parameters:
+
image - input image necessary for corner subpixel.
+
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> > ).
+
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.
+
markerCorners - list of detected marker corners from detectMarkers function.
+ If markerCorners and markerCorners are empty, the function detect aruco markers and ids.
+ If markerCorners and markerCorners are empty, the function detect aruco markers and ids.
+
+ 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 less accurate.
public void detectDiamonds(Mat image,
+ java.util.List<Mat> diamondCorners,
+ Mat diamondIds,
+ java.util.List<Mat> markerCorners,
+ Mat markerIds)
+
Detect ChArUco Diamond markers
+
+
Parameters:
+
image - input image necessary for corner subpixel.
+
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> > ).
+
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.
+
markerCorners - list of detected marker corners from detectMarkers function.
+ If markerCorners and markerCorners are empty, the function detect aruco markers and ids.
+
markerIds - list of marker ids in markerCorners.
+ If markerCorners and markerCorners are empty, the function detect aruco markers and ids.
+
+ 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 less accurate.
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.
Detects faces in the input image. Following is an example output.
+
+ 
+
+
Parameters:
+
image - an image to detect
+
faces - detection results stored in a 2D cv::Mat of shape [num_faces, 15]
+ - 0-1: x, y of bbox top left corner
+ - 2-3: width, height of bbox
+ - 4-5: x, y of right eye (blue point in the example image)
+ - 6-7: x, y of left eye (red point in the example image)
+ - 8-9: x, y of nose tip (green point in the example image)
+ - 10-11: x, y of right corner of mouth (pink point in the example image)
+ - 12-13: x, y of left corner of mouth (yellow point in the example image)
+ - 14: face score
Set the size for the network input, which overwrites the input size of creating model. Call this method when the size of input image does not match the input size when creating model
public java.lang.String decode(Mat img,
+ Mat points)
+
Decodes graphical code in image once it's found by the detect() method.
+
+ Returns UTF8-encoded output string or empty string if the code cannot be decoded.
+
+
Parameters:
+
img - grayscale or color (BGR) image containing graphical code.
+
points - Quadrangle vertices found by detect() method (or some other algorithm).
public java.lang.String decode(Mat img,
+ Mat points,
+ Mat straight_code)
+
Decodes graphical code in image once it's found by the detect() method.
+
+ Returns UTF8-encoded output string or empty string if the code cannot be decoded.
+
+
Parameters:
+
img - grayscale or color (BGR) image containing graphical code.
+
points - Quadrangle vertices found by detect() method (or some other algorithm).
+
straight_code - The optional output image containing binarized code, will be empty if not found.
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 image can be drawn using generateImage() method.
Performs object detection without a multi-scale window.
+
+
Parameters:
+
img - Matrix of the type CV_8U or CV_8UC3 containing an image where objects are detected.
+
foundLocations - Vector of point where each point contains left-top corner point of detected object boundaries.
+
weights - Vector that will contain confidence values for each detected object.
+ Usually it is 0 and should be specified in the detector coefficients (as the last free coefficient).
+ But if the free coefficient is omitted (which is allowed), you can specify it manually here.
Performs object detection without a multi-scale window.
+
+
Parameters:
+
img - Matrix of the type CV_8U or CV_8UC3 containing an image where objects are detected.
+
foundLocations - Vector of point where each point contains left-top corner point of detected object boundaries.
+
weights - Vector that will contain confidence values for each detected object.
+
hitThreshold - Threshold for the distance between features and SVM classifying plane.
+ Usually it is 0 and should be specified in the detector coefficients (as the last free coefficient).
+ But if the free coefficient is omitted (which is allowed), you can specify it manually here.
Performs object detection without a multi-scale window.
+
+
Parameters:
+
img - Matrix of the type CV_8U or CV_8UC3 containing an image where objects are detected.
+
foundLocations - Vector of point where each point contains left-top corner point of detected object boundaries.
+
weights - Vector that will contain confidence values for each detected object.
+
hitThreshold - Threshold for the distance between features and SVM classifying plane.
+ Usually it is 0 and should be specified in the detector coefficients (as the last free coefficient).
+ But if the free coefficient is omitted (which is allowed), you can specify it manually here.
+
winStride - Window stride. It must be a multiple of block stride.
Performs object detection without a multi-scale window.
+
+
Parameters:
+
img - Matrix of the type CV_8U or CV_8UC3 containing an image where objects are detected.
+
foundLocations - Vector of point where each point contains left-top corner point of detected object boundaries.
+
weights - Vector that will contain confidence values for each detected object.
+
hitThreshold - Threshold for the distance between features and SVM classifying plane.
+ Usually it is 0 and should be specified in the detector coefficients (as the last free coefficient).
+ But if the free coefficient is omitted (which is allowed), you can specify it manually here.
+
winStride - Window stride. It must be a multiple of block stride.
Performs object detection without a multi-scale window.
+
+
Parameters:
+
img - Matrix of the type CV_8U or CV_8UC3 containing an image where objects are detected.
+
foundLocations - Vector of point where each point contains left-top corner point of detected object boundaries.
+
weights - Vector that will contain confidence values for each detected object.
+
hitThreshold - Threshold for the distance between features and SVM classifying plane.
+ Usually it is 0 and should be specified in the detector coefficients (as the last free coefficient).
+ But if the free coefficient is omitted (which is allowed), you can specify it manually here.
+
winStride - Window stride. It must be a multiple of block stride.
+
padding - Padding
+
searchLocations - Vector of Point includes set of requested locations to be evaluated.
public void detectMultiScale(Mat img,
+ MatOfRect foundLocations,
+ MatOfDouble foundWeights)
+
Detects objects of different sizes in the input image. The detected objects are returned as a list
+ of rectangles.
+
+
Parameters:
+
img - Matrix of the type CV_8U or CV_8UC3 containing an image where objects are detected.
+
foundLocations - Vector of rectangles where each rectangle contains the detected object.
+
foundWeights - Vector that will contain confidence values for each detected object.
+ Usually it is 0 and should be specified in the detector coefficients (as the last free coefficient).
+ But if the free coefficient is omitted (which is allowed), you can specify it manually here.
+ by many rectangles. 0 means not to perform grouping.
Detects objects of different sizes in the input image. The detected objects are returned as a list
+ of rectangles.
+
+
Parameters:
+
img - Matrix of the type CV_8U or CV_8UC3 containing an image where objects are detected.
+
foundLocations - Vector of rectangles where each rectangle contains the detected object.
+
foundWeights - Vector that will contain confidence values for each detected object.
+
hitThreshold - Threshold for the distance between features and SVM classifying plane.
+ Usually it is 0 and should be specified in the detector coefficients (as the last free coefficient).
+ But if the free coefficient is omitted (which is allowed), you can specify it manually here.
+ by many rectangles. 0 means not to perform grouping.
Detects objects of different sizes in the input image. The detected objects are returned as a list
+ of rectangles.
+
+
Parameters:
+
img - Matrix of the type CV_8U or CV_8UC3 containing an image where objects are detected.
+
foundLocations - Vector of rectangles where each rectangle contains the detected object.
+
foundWeights - Vector that will contain confidence values for each detected object.
+
hitThreshold - Threshold for the distance between features and SVM classifying plane.
+ Usually it is 0 and should be specified in the detector coefficients (as the last free coefficient).
+ But if the free coefficient is omitted (which is allowed), you can specify it manually here.
+
winStride - Window stride. It must be a multiple of block stride.
+ by many rectangles. 0 means not to perform grouping.
Detects objects of different sizes in the input image. The detected objects are returned as a list
+ of rectangles.
+
+
Parameters:
+
img - Matrix of the type CV_8U or CV_8UC3 containing an image where objects are detected.
+
foundLocations - Vector of rectangles where each rectangle contains the detected object.
+
foundWeights - Vector that will contain confidence values for each detected object.
+
hitThreshold - Threshold for the distance between features and SVM classifying plane.
+ Usually it is 0 and should be specified in the detector coefficients (as the last free coefficient).
+ But if the free coefficient is omitted (which is allowed), you can specify it manually here.
+
winStride - Window stride. It must be a multiple of block stride.
+
padding - Padding
+ by many rectangles. 0 means not to perform grouping.
Detects objects of different sizes in the input image. The detected objects are returned as a list
+ of rectangles.
+
+
Parameters:
+
img - Matrix of the type CV_8U or CV_8UC3 containing an image where objects are detected.
+
foundLocations - Vector of rectangles where each rectangle contains the detected object.
+
foundWeights - Vector that will contain confidence values for each detected object.
+
hitThreshold - Threshold for the distance between features and SVM classifying plane.
+ Usually it is 0 and should be specified in the detector coefficients (as the last free coefficient).
+ But if the free coefficient is omitted (which is allowed), you can specify it manually here.
+
winStride - Window stride. It must be a multiple of block stride.
+
padding - Padding
+
scale - Coefficient of the detection window increase.
+ by many rectangles. 0 means not to perform grouping.
Detects objects of different sizes in the input image. The detected objects are returned as a list
+ of rectangles.
+
+
Parameters:
+
img - Matrix of the type CV_8U or CV_8UC3 containing an image where objects are detected.
+
foundLocations - Vector of rectangles where each rectangle contains the detected object.
+
foundWeights - Vector that will contain confidence values for each detected object.
+
hitThreshold - Threshold for the distance between features and SVM classifying plane.
+ Usually it is 0 and should be specified in the detector coefficients (as the last free coefficient).
+ But if the free coefficient is omitted (which is allowed), you can specify it manually here.
+
winStride - Window stride. It must be a multiple of block stride.
+
padding - Padding
+
scale - Coefficient of the detection window increase.
+
groupThreshold - Coefficient to regulate the similarity threshold. When detected, some objects can be covered
+ by many rectangles. 0 means not to perform grouping.
Detects objects of different sizes in the input image. The detected objects are returned as a list
+ of rectangles.
+
+
Parameters:
+
img - Matrix of the type CV_8U or CV_8UC3 containing an image where objects are detected.
+
foundLocations - Vector of rectangles where each rectangle contains the detected object.
+
foundWeights - Vector that will contain confidence values for each detected object.
+
hitThreshold - Threshold for the distance between features and SVM classifying plane.
+ Usually it is 0 and should be specified in the detector coefficients (as the last free coefficient).
+ But if the free coefficient is omitted (which is allowed), you can specify it manually here.
+
winStride - Window stride. It must be a multiple of block stride.
+
padding - Padding
+
scale - Coefficient of the detection window increase.
+
groupThreshold - Coefficient to regulate the similarity threshold. When detected, some objects can be covered
+ by many rectangles. 0 means not to perform grouping.
public static void drawDetectedCornersCharuco(Mat image,
+ Mat charucoCorners)
+
Draws a set of Charuco corners
+
+
Parameters:
+
image - input/output image. It must have 1 or 3 channels. The number of channels is not
+ altered.
+
charucoCorners - vector of detected charuco corners
+
+ This function draws a set of detected Charuco corners. If identifiers vector is provided, it also
+ draws the id of each corner.
public static void drawDetectedCornersCharuco(Mat image,
+ Mat charucoCorners,
+ Mat charucoIds)
+
Draws a set of Charuco corners
+
+
Parameters:
+
image - input/output image. It must have 1 or 3 channels. The number of channels is not
+ altered.
+
charucoCorners - vector of detected charuco corners
+
charucoIds - list of identifiers for each corner in charucoCorners
+
+ This function draws a set of detected Charuco corners. If identifiers vector is provided, it also
+ draws the id of each corner.
public static void drawDetectedCornersCharuco(Mat image,
+ Mat charucoCorners,
+ Mat charucoIds,
+ Scalar cornerColor)
+
Draws a set of Charuco corners
+
+
Parameters:
+
image - input/output image. It must have 1 or 3 channels. The number of channels is not
+ altered.
+
charucoCorners - vector of detected charuco corners
+
charucoIds - list of identifiers for each corner in charucoCorners
+
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.
public static void drawDetectedDiamonds(Mat image,
+ java.util.List<Mat> diamondCorners)
+
Draw a set of detected ChArUco Diamond markers
+
+
Parameters:
+
image - input/output image. It must have 1 or 3 channels. The number of channels is not
+ altered.
+
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.
+ returned by detectCharucoDiamond() (e.g. std::vector<Vec4i>).
+ Optional, if not provided, ids are not painted.
+ 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.
public static void drawDetectedDiamonds(Mat image,
+ java.util.List<Mat> diamondCorners,
+ Mat diamondIds)
+
Draw a set of detected ChArUco Diamond markers
+
+
Parameters:
+
image - input/output image. It must have 1 or 3 channels. The number of channels is not
+ altered.
+
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.
+
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.
+ 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.
public static void drawDetectedDiamonds(Mat image,
+ java.util.List<Mat> diamondCorners,
+ Mat diamondIds,
+ Scalar borderColor)
+
Draw a set of detected ChArUco Diamond markers
+
+
Parameters:
+
image - input/output image. It must have 1 or 3 channels. The number of channels is not
+ altered.
+
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.
+
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.
+
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.
public static void drawDetectedMarkers(Mat image,
+ java.util.List<Mat> corners)
+
Draw detected markers in image
+
+
Parameters:
+
image - input/output image. It must have 1 or 3 channels. The number of channels is not altered.
+
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.
+ Optional, if not provided, ids are not painted.
+ 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.
public static void drawDetectedMarkers(Mat image,
+ java.util.List<Mat> corners,
+ Mat ids)
+
Draw detected markers in image
+
+
Parameters:
+
image - input/output image. It must have 1 or 3 channels. The number of channels is not altered.
+
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.
+
ids - vector of identifiers for markers in markersCorners .
+ Optional, if not provided, ids are not painted.
+ 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.
public static void drawDetectedMarkers(Mat image,
+ java.util.List<Mat> corners,
+ Mat ids,
+ Scalar borderColor)
+
Draw detected markers in image
+
+
Parameters:
+
image - input/output image. It must have 1 or 3 channels. The number of channels is not altered.
+
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.
+
ids - vector of identifiers for markers in markersCorners .
+ Optional, if not provided, ids are not painted.
+
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.
public static Dictionary extendDictionary(int nMarkers,
+ int markerSize)
+
Extend base dictionary by new nMarkers
+
+
Parameters:
+
nMarkers - number of markers in the dictionary
+
markerSize - number of bits per dimension of each markers
+
+ 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.
public static Dictionary extendDictionary(int nMarkers,
+ int markerSize,
+ Dictionary baseDictionary)
+
Extend base dictionary by new nMarkers
+
+
Parameters:
+
nMarkers - number of markers in the dictionary
+
markerSize - number of bits per dimension of each markers
+
baseDictionary - Include the markers in this dictionary at the beginning (optional)
+
+ 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.
public static Dictionary extendDictionary(int nMarkers,
+ int markerSize,
+ Dictionary baseDictionary,
+ int randomSeed)
+
Extend base dictionary by new nMarkers
+
+
Parameters:
+
nMarkers - number of markers in the dictionary
+
markerSize - number of bits per dimension of each markers
+
baseDictionary - Include the markers in this dictionary at the beginning (optional)
+
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.
public java.lang.String decodeCurved(Mat img,
+ Mat points)
+
Decodes QR code on a curved surface in image once it's found by the detect() method.
+
+ Returns UTF8-encoded output string or empty string if the code cannot be decoded.
+
+
Parameters:
+
img - grayscale or color (BGR) image containing QR code.
+
points - Quadrangle vertices found by detect() method (or some other algorithm).
public java.lang.String decodeCurved(Mat img,
+ Mat points,
+ Mat straight_qrcode)
+
Decodes QR code on a curved surface in image once it's found by the detect() method.
+
+ Returns UTF8-encoded output string or empty string if the code cannot be decoded.
+
+
Parameters:
+
img - grayscale or color (BGR) image containing QR code.
+
points - Quadrangle vertices found by detect() method (or some other algorithm).
+
straight_qrcode - The optional output image containing rectified and binarized QR code
public class QRCodeEncoder
+extends java.lang.Object
+
Groups the object candidate rectangles.
+ rectList Input/output vector of rectangles. Output vector includes retained and grouped rectangles. (The Python list is not modified in place.)
+ weights Input/output vector of weights of rectangles. Output vector includes weights of retained and grouped rectangles. (The Python list is not modified in place.)
+ groupThreshold Minimum possible number of rectangles minus 1. The threshold is used in a group of rectangles to retain it.
+ eps Relative difference between sides of the rectangles to merge them into a group.
public class QRCodeEncoder_Params
+extends java.lang.Object
+
QR code encoder parameters.
+ version The optional version of QR code (by default - maximum possible depending on
+ the length of the string).
+ correction_level The optional level of error correction (by default - the lowest).
+ mode The optional encoding mode - Numeric, Alphanumeric, Byte, Kanji, ECI or Structured Append.
+ structure_number The optional number of QR codes to generate in Structured Append mode.
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.
public class OpenCVNativeLoader
+extends java.lang.Object
+implements OpenCVInterface
+
This class is intended to provide a convenient way to load OpenCV's native
+ library from the Java bundle. If Blueprint is enabled in the OSGi container
+ this class will be instantiated automatically and the init() method called
+ loading the native library.
This algorithm converts images to median threshold bitmaps (1 for pixels brighter than median
+ luminance and 0 otherwise) and than aligns the resulting bitmaps using bit operations.
+
+ It is invariant to exposure, so exposure values and camera response are not necessary.
+
+ In this implementation new image regions are filled with zeros.
+
+ For more information see CITE: GW03 .
public class CalibrateDebevec
+extends CalibrateCRF
+
Inverse camera response function is extracted for each brightness value by minimizing an objective
+ function as linear system. Objective function is constructed using pixel values on the same position
+ in all images, extra term is added to make the result smoother.
+
+ For more information see CITE: DM97 .
public class CalibrateRobertson
+extends CalibrateCRF
+
Inverse camera response function is extracted for each brightness value by minimizing an objective
+ function as linear system. This algorithm uses all image pixels.
+
+ For more information see CITE: RB99 .
The resulting HDR image is calculated as weighted average of the exposures considering exposure
+ values and camera response.
+
+ For more information see CITE: DM97 .
Pixels are weighted using contrast, saturation and well-exposedness measures, than images are
+ combined using laplacian pyramids.
+
+ The resulting image weight is constructed as weighted average of contrast, saturation and
+ well-exposedness measures.
+
+ The resulting image doesn't require tonemapping and can be converted to 8-bit image by multiplying
+ by 255, but it's recommended to apply gamma correction and/or linear tonemapping.
+
+ For more information see CITE: MK07 .
The resulting HDR image is calculated as weighted average of the exposures considering exposure
+ values and camera response.
+
+ For more information see CITE: RB99 .
Perform image denoising using Non-local Means Denoising algorithm
+ <http://www.ipol.im/pub/algo/bcm_non_local_means_denoising/> with several computational
+ optimizations.
Perform image denoising using Non-local Means Denoising algorithm
+ <http://www.ipol.im/pub/algo/bcm_non_local_means_denoising/> with several computational
+ optimizations.
Perform image denoising using Non-local Means Denoising algorithm
+ <http://www.ipol.im/pub/algo/bcm_non_local_means_denoising/> with several computational
+ optimizations.
Perform image denoising using Non-local Means Denoising algorithm
+ <http://www.ipol.im/pub/algo/bcm_non_local_means_denoising/> with several computational
+ optimizations.
Perform image denoising using Non-local Means Denoising algorithm
+ <http://www.ipol.im/pub/algo/bcm_non_local_means_denoising/> with several computational
+ optimizations.
Perform image denoising using Non-local Means Denoising algorithm
+ <http://www.ipol.im/pub/algo/bcm_non_local_means_denoising/> with several computational
+ optimizations.
Perform image denoising using Non-local Means Denoising algorithm
+ <http://www.ipol.im/pub/algo/bcm_non_local_means_denoising/> with several computational
+ optimizations.
Perform image denoising using Non-local Means Denoising algorithm
+ <http://www.ipol.im/pub/algo/bcm_non_local_means_denoising/> with several computational
+ optimizations.
Modification of fastNlMeansDenoisingMulti function for colored images sequences
+
+
+
+
static void
+
fastNlMeansDenoisingColoredMulti(java.util.List<Mat> srcImgs,
+ Mat dst,
+ int imgToDenoiseIndex,
+ int temporalWindowSize,
+ float h,
+ float hColor)
+
Modification of fastNlMeansDenoisingMulti function for colored images sequences
+
+
+
+
static void
+
fastNlMeansDenoisingColoredMulti(java.util.List<Mat> srcImgs,
+ Mat dst,
+ int imgToDenoiseIndex,
+ int temporalWindowSize,
+ float h,
+ float hColor,
+ int templateWindowSize)
+
Modification of fastNlMeansDenoisingMulti function for colored images sequences
+
+
+
+
static void
+
fastNlMeansDenoisingColoredMulti(java.util.List<Mat> srcImgs,
+ Mat dst,
+ int imgToDenoiseIndex,
+ int temporalWindowSize,
+ float h,
+ float hColor,
+ int templateWindowSize,
+ int searchWindowSize)
+
Modification of fastNlMeansDenoisingMulti function for colored images sequences
Modification of fastNlMeansDenoising function for images sequence where consecutive images have been
+ captured in small period of time.
+
+
+
+
static void
+
fastNlMeansDenoisingMulti(java.util.List<Mat> srcImgs,
+ Mat dst,
+ int imgToDenoiseIndex,
+ int temporalWindowSize,
+ float h)
+
Modification of fastNlMeansDenoising function for images sequence where consecutive images have been
+ captured in small period of time.
+
+
+
+
static void
+
fastNlMeansDenoisingMulti(java.util.List<Mat> srcImgs,
+ Mat dst,
+ int imgToDenoiseIndex,
+ int temporalWindowSize,
+ float h,
+ int templateWindowSize)
+
Modification of fastNlMeansDenoising function for images sequence where consecutive images have been
+ captured in small period of time.
+
+
+
+
static void
+
fastNlMeansDenoisingMulti(java.util.List<Mat> srcImgs,
+ Mat dst,
+ int imgToDenoiseIndex,
+ int temporalWindowSize,
+ float h,
+ int templateWindowSize,
+ int searchWindowSize)
+
Modification of fastNlMeansDenoising function for images sequence where consecutive images have been
+ captured in small period of time.
Modification of fastNlMeansDenoising function for images sequence where consecutive images have been
+ captured in small period of time.
+
+
+
+
static void
+
fastNlMeansDenoisingMulti(java.util.List<Mat> srcImgs,
+ Mat dst,
+ int imgToDenoiseIndex,
+ int temporalWindowSize,
+ MatOfFloat h,
+ int templateWindowSize,
+ int searchWindowSize)
+
Modification of fastNlMeansDenoising function for images sequence where consecutive images have been
+ captured in small period of time.
+
+
+
+
static void
+
fastNlMeansDenoisingMulti(java.util.List<Mat> srcImgs,
+ Mat dst,
+ int imgToDenoiseIndex,
+ int temporalWindowSize,
+ MatOfFloat h,
+ int templateWindowSize,
+ int searchWindowSize,
+ int normType)
+
Modification of fastNlMeansDenoising function for images sequence where consecutive images have been
+ captured in small period of time.
Applying an appropriate non-linear transformation to the gradient field inside the selection and
+ then integrating back with a Poisson solver, modifies locally the apparent illumination of an image.
Applying an appropriate non-linear transformation to the gradient field inside the selection and
+ then integrating back with a Poisson solver, modifies locally the apparent illumination of an image.
Applying an appropriate non-linear transformation to the gradient field inside the selection and
+ then integrating back with a Poisson solver, modifies locally the apparent illumination of an image.
+
+
+
+
static void
+
inpaint(Mat src,
+ Mat inpaintMask,
+ Mat dst,
+ double inpaintRadius,
+ int flags)
+
Restores the selected region in an image using the region neighborhood.
By retaining only the gradients at edge locations, before integrating with the Poisson solver, one
+ washes out the texture of the selected region, giving its contents a flat aspect.
By retaining only the gradients at edge locations, before integrating with the Poisson solver, one
+ washes out the texture of the selected region, giving its contents a flat aspect.
By retaining only the gradients at edge locations, before integrating with the Poisson solver, one
+ washes out the texture of the selected region, giving its contents a flat aspect.
+
+
+
+
static void
+
textureFlattening(Mat src,
+ Mat mask,
+ Mat dst,
+ float low_threshold,
+ float high_threshold,
+ int kernel_size)
+
By retaining only the gradients at edge locations, before integrating with the Poisson solver, one
+ washes out the texture of the selected region, giving its contents a flat aspect.
public static AlignMTB createAlignMTB(int max_bits)
+
Creates AlignMTB object
+
+
Parameters:
+
max_bits - logarithm to the base 2 of maximal shift in each dimension. Values of 5 and 6 are
+ usually good enough (31 and 63 pixels shift respectively).
+ median value.
public static AlignMTB createAlignMTB(int max_bits,
+ int exclude_range)
+
Creates AlignMTB object
+
+
Parameters:
+
max_bits - logarithm to the base 2 of maximal shift in each dimension. Values of 5 and 6 are
+ usually good enough (31 and 63 pixels shift respectively).
+
exclude_range - range for exclusion bitmap that is constructed to suppress noise around the
+ median value.
public static AlignMTB createAlignMTB(int max_bits,
+ int exclude_range,
+ boolean cut)
+
Creates AlignMTB object
+
+
Parameters:
+
max_bits - logarithm to the base 2 of maximal shift in each dimension. Values of 5 and 6 are
+ usually good enough (31 and 63 pixels shift respectively).
+
exclude_range - range for exclusion bitmap that is constructed to suppress noise around the
+ median value.
+
cut - if true cuts images, otherwise fills the new regions with zeros.
Creates simple linear mapper with gamma correction
+
+ equal to 2.2f is suitable for most displays.
+ Generally gamma > 1 brightens the image and gamma < 1 darkens it.
Creates simple linear mapper with gamma correction
+
+
Parameters:
+
gamma - positive value for gamma correction. Gamma value of 1.0 implies no correction, gamma
+ equal to 2.2f is suitable for most displays.
+ Generally gamma > 1 brightens the image and gamma < 1 darkens it.
public static TonemapDrago createTonemapDrago(float gamma)
+
Creates TonemapDrago object
+
+
Parameters:
+
gamma - gamma value for gamma correction. See createTonemap
+ than 1 increase saturation and values less than 1 decrease it.
+ results, default value is 0.85.
public static TonemapDrago createTonemapDrago(float gamma,
+ float saturation)
+
Creates TonemapDrago object
+
+
Parameters:
+
gamma - gamma value for gamma correction. See createTonemap
+
saturation - positive saturation enhancement value. 1.0 preserves saturation, values greater
+ than 1 increase saturation and values less than 1 decrease it.
+ results, default value is 0.85.
gamma - gamma value for gamma correction. See createTonemap
+
saturation - positive saturation enhancement value. 1.0 preserves saturation, values greater
+ than 1 increase saturation and values less than 1 decrease it.
+
bias - value for bias function in [0, 1] range. Values from 0.7 to 0.9 usually give best
+ results, default value is 0.85.
public static TonemapMantiuk createTonemapMantiuk(float gamma,
+ float scale)
+
Creates TonemapMantiuk object
+
+
Parameters:
+
gamma - gamma value for gamma correction. See createTonemap
+
scale - contrast scale factor. HVS response is multiplied by this parameter, thus compressing
+ dynamic range. Values from 0.6 to 0.9 produce best results.
gamma - gamma value for gamma correction. See createTonemap
+
scale - contrast scale factor. HVS response is multiplied by this parameter, thus compressing
+ dynamic range. Values from 0.6 to 0.9 produce best results.
+
saturation - saturation enhancement value. See createTonemapDrago
Creates TonemapReinhard object
+
+ value, if 0 it's global, otherwise it's a weighted mean of this two cases.
+ if 0 adaptation level is the same for each channel.
public static TonemapReinhard createTonemapReinhard(float gamma)
+
Creates TonemapReinhard object
+
+
Parameters:
+
gamma - gamma value for gamma correction. See createTonemap
+ value, if 0 it's global, otherwise it's a weighted mean of this two cases.
+ if 0 adaptation level is the same for each channel.
public static TonemapReinhard createTonemapReinhard(float gamma,
+ float intensity)
+
Creates TonemapReinhard object
+
+
Parameters:
+
gamma - gamma value for gamma correction. See createTonemap
+
intensity - result intensity in [-8, 8] range. Greater intensity produces brighter results.
+ value, if 0 it's global, otherwise it's a weighted mean of this two cases.
+ if 0 adaptation level is the same for each channel.
gamma - gamma value for gamma correction. See createTonemap
+
intensity - result intensity in [-8, 8] range. Greater intensity produces brighter results.
+
light_adapt - light adaptation in [0, 1] range. If 1 adaptation is based only on pixel
+ value, if 0 it's global, otherwise it's a weighted mean of this two cases.
+ if 0 adaptation level is the same for each channel.
gamma - gamma value for gamma correction. See createTonemap
+
intensity - result intensity in [-8, 8] range. Greater intensity produces brighter results.
+
light_adapt - light adaptation in [0, 1] range. If 1 adaptation is based only on pixel
+ value, if 0 it's global, otherwise it's a weighted mean of this two cases.
+
color_adapt - chromatic adaptation in [0, 1] range. If 1 channels are treated independently,
+ if 0 adaptation level is the same for each channel.
public static void decolor(Mat src,
+ Mat grayscale,
+ Mat color_boost)
+
Transforms a color image to a grayscale image. It is a basic tool in digital printing, stylized
+ black-and-white photograph rendering, and in many single channel image processing applications
+ CITE: CL12 .
+
+
Parameters:
+
src - Input 8-bit 3-channel image.
+
grayscale - Output 8-bit 1-channel image.
+
color_boost - Output 8-bit 3-channel image.
+
+ This function is to be applied on color images.
public static void denoise_TVL1(java.util.List<Mat> observations,
+ Mat result)
+
Primal-dual algorithm is an algorithm for solving special types of variational problems (that is,
+ finding a function to minimize some functional). As the image denoising, in particular, may be seen
+ as the variational problem, primal-dual algorithm then can be used to perform denoising and this is
+ exactly what is implemented.
+
+ It should be noted, that this implementation was taken from the July 2013 blog entry
+ CITE: MA13 , which also contained (slightly more general) ready-to-use source code on Python.
+ Subsequently, that code was rewritten on C++ with the usage of openCV by Vadim Pisarevsky at the end
+ of July 2013 and finally it was slightly adapted by later authors.
+
+ Although the thorough discussion and justification of the algorithm involved may be found in
+ CITE: ChambolleEtAl, it might make sense to skim over it here, following CITE: MA13 . To begin
+ with, we consider the 1-byte gray-level images as the functions from the rectangular domain of
+ pixels (it may be seen as set
+ \(\left\{(x,y)\in\mathbb{N}\times\mathbb{N}\mid 1\leq x\leq n,\;1\leq y\leq m\right\}\) for some
+ \(m,\;n\in\mathbb{N}\)) into \(\{0,1,\dots,255\}\). We shall denote the noised images as \(f_i\) and with
+ this view, given some image \(x\) of the same size, we may measure how bad it is by the formula
+
+ \(\left\|\left\|\nabla x\right\|\right\| + \lambda\sum_i\left\|\left\|x-f_i\right\|\right\|\)
+
+ \(\|\|\cdot\|\|\) here denotes \(L_2\)-norm and as you see, the first addend states that we want our
+ image to be smooth (ideally, having zero gradient, thus being constant) and the second states that
+ we want our result to be close to the observations we've got. If we treat \(x\) as a function, this is
+ exactly the functional what we seek to minimize and here the Primal-Dual algorithm comes into play.
+
+
Parameters:
+
observations - This array should contain one or more noised versions of the image that is to
+ be restored.
+
result - Here the denoised image will be stored. There is no need to do pre-allocation of
+ storage space, as it will be automatically allocated, if necessary.
+ (blurred) images are treated more favorably than detailed (but maybe more noised) ones. Roughly
+ speaking, as it becomes smaller, the result will be more blur but more sever outliers will be
+ removed.
+ better, but it is hard to quantitatively refine this statement, so just use the default and
+ increase it if the results are poor.
public static void denoise_TVL1(java.util.List<Mat> observations,
+ Mat result,
+ double lambda)
+
Primal-dual algorithm is an algorithm for solving special types of variational problems (that is,
+ finding a function to minimize some functional). As the image denoising, in particular, may be seen
+ as the variational problem, primal-dual algorithm then can be used to perform denoising and this is
+ exactly what is implemented.
+
+ It should be noted, that this implementation was taken from the July 2013 blog entry
+ CITE: MA13 , which also contained (slightly more general) ready-to-use source code on Python.
+ Subsequently, that code was rewritten on C++ with the usage of openCV by Vadim Pisarevsky at the end
+ of July 2013 and finally it was slightly adapted by later authors.
+
+ Although the thorough discussion and justification of the algorithm involved may be found in
+ CITE: ChambolleEtAl, it might make sense to skim over it here, following CITE: MA13 . To begin
+ with, we consider the 1-byte gray-level images as the functions from the rectangular domain of
+ pixels (it may be seen as set
+ \(\left\{(x,y)\in\mathbb{N}\times\mathbb{N}\mid 1\leq x\leq n,\;1\leq y\leq m\right\}\) for some
+ \(m,\;n\in\mathbb{N}\)) into \(\{0,1,\dots,255\}\). We shall denote the noised images as \(f_i\) and with
+ this view, given some image \(x\) of the same size, we may measure how bad it is by the formula
+
+ \(\left\|\left\|\nabla x\right\|\right\| + \lambda\sum_i\left\|\left\|x-f_i\right\|\right\|\)
+
+ \(\|\|\cdot\|\|\) here denotes \(L_2\)-norm and as you see, the first addend states that we want our
+ image to be smooth (ideally, having zero gradient, thus being constant) and the second states that
+ we want our result to be close to the observations we've got. If we treat \(x\) as a function, this is
+ exactly the functional what we seek to minimize and here the Primal-Dual algorithm comes into play.
+
+
Parameters:
+
observations - This array should contain one or more noised versions of the image that is to
+ be restored.
+
result - Here the denoised image will be stored. There is no need to do pre-allocation of
+ storage space, as it will be automatically allocated, if necessary.
+
lambda - Corresponds to \(\lambda\) in the formulas above. As it is enlarged, the smooth
+ (blurred) images are treated more favorably than detailed (but maybe more noised) ones. Roughly
+ speaking, as it becomes smaller, the result will be more blur but more sever outliers will be
+ removed.
+ better, but it is hard to quantitatively refine this statement, so just use the default and
+ increase it if the results are poor.
public static void denoise_TVL1(java.util.List<Mat> observations,
+ Mat result,
+ double lambda,
+ int niters)
+
Primal-dual algorithm is an algorithm for solving special types of variational problems (that is,
+ finding a function to minimize some functional). As the image denoising, in particular, may be seen
+ as the variational problem, primal-dual algorithm then can be used to perform denoising and this is
+ exactly what is implemented.
+
+ It should be noted, that this implementation was taken from the July 2013 blog entry
+ CITE: MA13 , which also contained (slightly more general) ready-to-use source code on Python.
+ Subsequently, that code was rewritten on C++ with the usage of openCV by Vadim Pisarevsky at the end
+ of July 2013 and finally it was slightly adapted by later authors.
+
+ Although the thorough discussion and justification of the algorithm involved may be found in
+ CITE: ChambolleEtAl, it might make sense to skim over it here, following CITE: MA13 . To begin
+ with, we consider the 1-byte gray-level images as the functions from the rectangular domain of
+ pixels (it may be seen as set
+ \(\left\{(x,y)\in\mathbb{N}\times\mathbb{N}\mid 1\leq x\leq n,\;1\leq y\leq m\right\}\) for some
+ \(m,\;n\in\mathbb{N}\)) into \(\{0,1,\dots,255\}\). We shall denote the noised images as \(f_i\) and with
+ this view, given some image \(x\) of the same size, we may measure how bad it is by the formula
+
+ \(\left\|\left\|\nabla x\right\|\right\| + \lambda\sum_i\left\|\left\|x-f_i\right\|\right\|\)
+
+ \(\|\|\cdot\|\|\) here denotes \(L_2\)-norm and as you see, the first addend states that we want our
+ image to be smooth (ideally, having zero gradient, thus being constant) and the second states that
+ we want our result to be close to the observations we've got. If we treat \(x\) as a function, this is
+ exactly the functional what we seek to minimize and here the Primal-Dual algorithm comes into play.
+
+
Parameters:
+
observations - This array should contain one or more noised versions of the image that is to
+ be restored.
+
result - Here the denoised image will be stored. There is no need to do pre-allocation of
+ storage space, as it will be automatically allocated, if necessary.
+
lambda - Corresponds to \(\lambda\) in the formulas above. As it is enlarged, the smooth
+ (blurred) images are treated more favorably than detailed (but maybe more noised) ones. Roughly
+ speaking, as it becomes smaller, the result will be more blur but more sever outliers will be
+ removed.
+
niters - Number of iterations that the algorithm will run. Of course, as more iterations as
+ better, but it is hard to quantitatively refine this statement, so just use the default and
+ increase it if the results are poor.
public static void edgePreservingFilter(Mat src,
+ Mat dst)
+
Filtering is the fundamental operation in image and video processing. Edge-preserving smoothing
+ filters are used in many different applications CITE: EM11 .
public static void edgePreservingFilter(Mat src,
+ Mat dst,
+ int flags)
+
Filtering is the fundamental operation in image and video processing. Edge-preserving smoothing
+ filters are used in many different applications CITE: EM11 .
+
+
Parameters:
+
src - Input 8-bit 3-channel image.
+
dst - Output 8-bit 3-channel image.
+
flags - Edge preserving filters: cv::RECURS_FILTER or cv::NORMCONV_FILTER
public static void edgePreservingFilter(Mat src,
+ Mat dst,
+ int flags,
+ float sigma_s)
+
Filtering is the fundamental operation in image and video processing. Edge-preserving smoothing
+ filters are used in many different applications CITE: EM11 .
+
+
Parameters:
+
src - Input 8-bit 3-channel image.
+
dst - Output 8-bit 3-channel image.
+
flags - Edge preserving filters: cv::RECURS_FILTER or cv::NORMCONV_FILTER
public static void edgePreservingFilter(Mat src,
+ Mat dst,
+ int flags,
+ float sigma_s,
+ float sigma_r)
+
Filtering is the fundamental operation in image and video processing. Edge-preserving smoothing
+ filters are used in many different applications CITE: EM11 .
+
+
Parameters:
+
src - Input 8-bit 3-channel image.
+
dst - Output 8-bit 3-channel image.
+
flags - Edge preserving filters: cv::RECURS_FILTER or cv::NORMCONV_FILTER
public static void fastNlMeansDenoising(Mat src,
+ Mat dst)
+
Perform image denoising using Non-local Means Denoising algorithm
+ <http://www.ipol.im/pub/algo/bcm_non_local_means_denoising/> with several computational
+ optimizations. Noise expected to be a gaussian white noise
+
+
Parameters:
+
src - Input 8-bit 1-channel, 2-channel, 3-channel or 4-channel image.
+
dst - Output image with the same size and type as src .
+ Should be odd. Recommended value 7 pixels
+ given pixel. Should be odd. Affect performance linearly: greater searchWindowsSize - greater
+ denoising time. Recommended value 21 pixels
+ removes image details, smaller h value preserves details but also preserves some noise
+
+ This function expected to be applied to grayscale images. For colored images look at
+ fastNlMeansDenoisingColored. Advanced usage of this functions can be manual denoising of colored
+ image in different colorspaces. Such approach is used in fastNlMeansDenoisingColored by converting
+ image to CIELAB colorspace and then separately denoise L and AB components with different h
+ parameter.
public static void fastNlMeansDenoising(Mat src,
+ Mat dst,
+ float h)
+
Perform image denoising using Non-local Means Denoising algorithm
+ <http://www.ipol.im/pub/algo/bcm_non_local_means_denoising/> with several computational
+ optimizations. Noise expected to be a gaussian white noise
+
+
Parameters:
+
src - Input 8-bit 1-channel, 2-channel, 3-channel or 4-channel image.
+
dst - Output image with the same size and type as src .
+ Should be odd. Recommended value 7 pixels
+ given pixel. Should be odd. Affect performance linearly: greater searchWindowsSize - greater
+ denoising time. Recommended value 21 pixels
+
h - Parameter regulating filter strength. Big h value perfectly removes noise but also
+ removes image details, smaller h value preserves details but also preserves some noise
+
+ This function expected to be applied to grayscale images. For colored images look at
+ fastNlMeansDenoisingColored. Advanced usage of this functions can be manual denoising of colored
+ image in different colorspaces. Such approach is used in fastNlMeansDenoisingColored by converting
+ image to CIELAB colorspace and then separately denoise L and AB components with different h
+ parameter.
public static void fastNlMeansDenoising(Mat src,
+ Mat dst,
+ float h,
+ int templateWindowSize)
+
Perform image denoising using Non-local Means Denoising algorithm
+ <http://www.ipol.im/pub/algo/bcm_non_local_means_denoising/> with several computational
+ optimizations. Noise expected to be a gaussian white noise
+
+
Parameters:
+
src - Input 8-bit 1-channel, 2-channel, 3-channel or 4-channel image.
+
dst - Output image with the same size and type as src .
+
templateWindowSize - Size in pixels of the template patch that is used to compute weights.
+ Should be odd. Recommended value 7 pixels
+ given pixel. Should be odd. Affect performance linearly: greater searchWindowsSize - greater
+ denoising time. Recommended value 21 pixels
+
h - Parameter regulating filter strength. Big h value perfectly removes noise but also
+ removes image details, smaller h value preserves details but also preserves some noise
+
+ This function expected to be applied to grayscale images. For colored images look at
+ fastNlMeansDenoisingColored. Advanced usage of this functions can be manual denoising of colored
+ image in different colorspaces. Such approach is used in fastNlMeansDenoisingColored by converting
+ image to CIELAB colorspace and then separately denoise L and AB components with different h
+ parameter.
public static void fastNlMeansDenoising(Mat src,
+ Mat dst,
+ float h,
+ int templateWindowSize,
+ int searchWindowSize)
+
Perform image denoising using Non-local Means Denoising algorithm
+ <http://www.ipol.im/pub/algo/bcm_non_local_means_denoising/> with several computational
+ optimizations. Noise expected to be a gaussian white noise
+
+
Parameters:
+
src - Input 8-bit 1-channel, 2-channel, 3-channel or 4-channel image.
+
dst - Output image with the same size and type as src .
+
templateWindowSize - Size in pixels of the template patch that is used to compute weights.
+ Should be odd. Recommended value 7 pixels
+
searchWindowSize - Size in pixels of the window that is used to compute weighted average for
+ given pixel. Should be odd. Affect performance linearly: greater searchWindowsSize - greater
+ denoising time. Recommended value 21 pixels
+
h - Parameter regulating filter strength. Big h value perfectly removes noise but also
+ removes image details, smaller h value preserves details but also preserves some noise
+
+ This function expected to be applied to grayscale images. For colored images look at
+ fastNlMeansDenoisingColored. Advanced usage of this functions can be manual denoising of colored
+ image in different colorspaces. Such approach is used in fastNlMeansDenoisingColored by converting
+ image to CIELAB colorspace and then separately denoise L and AB components with different h
+ parameter.
public static void fastNlMeansDenoising(Mat src,
+ Mat dst,
+ MatOfFloat h)
+
Perform image denoising using Non-local Means Denoising algorithm
+ <http://www.ipol.im/pub/algo/bcm_non_local_means_denoising/> with several computational
+ optimizations. Noise expected to be a gaussian white noise
+
+
Parameters:
+
src - Input 8-bit or 16-bit (only with NORM_L1) 1-channel,
+ 2-channel, 3-channel or 4-channel image.
+
dst - Output image with the same size and type as src .
+ Should be odd. Recommended value 7 pixels
+ given pixel. Should be odd. Affect performance linearly: greater searchWindowsSize - greater
+ denoising time. Recommended value 21 pixels
+
h - Array of parameters regulating filter strength, either one
+ parameter applied to all channels or one per channel in dst. Big h value
+ perfectly removes noise but also removes image details, smaller h
+ value preserves details but also preserves some noise
+
+ This function expected to be applied to grayscale images. For colored images look at
+ fastNlMeansDenoisingColored. Advanced usage of this functions can be manual denoising of colored
+ image in different colorspaces. Such approach is used in fastNlMeansDenoisingColored by converting
+ image to CIELAB colorspace and then separately denoise L and AB components with different h
+ parameter.
public static void fastNlMeansDenoising(Mat src,
+ Mat dst,
+ MatOfFloat h,
+ int templateWindowSize)
+
Perform image denoising using Non-local Means Denoising algorithm
+ <http://www.ipol.im/pub/algo/bcm_non_local_means_denoising/> with several computational
+ optimizations. Noise expected to be a gaussian white noise
+
+
Parameters:
+
src - Input 8-bit or 16-bit (only with NORM_L1) 1-channel,
+ 2-channel, 3-channel or 4-channel image.
+
dst - Output image with the same size and type as src .
+
templateWindowSize - Size in pixels of the template patch that is used to compute weights.
+ Should be odd. Recommended value 7 pixels
+ given pixel. Should be odd. Affect performance linearly: greater searchWindowsSize - greater
+ denoising time. Recommended value 21 pixels
+
h - Array of parameters regulating filter strength, either one
+ parameter applied to all channels or one per channel in dst. Big h value
+ perfectly removes noise but also removes image details, smaller h
+ value preserves details but also preserves some noise
+
+ This function expected to be applied to grayscale images. For colored images look at
+ fastNlMeansDenoisingColored. Advanced usage of this functions can be manual denoising of colored
+ image in different colorspaces. Such approach is used in fastNlMeansDenoisingColored by converting
+ image to CIELAB colorspace and then separately denoise L and AB components with different h
+ parameter.
public static void fastNlMeansDenoising(Mat src,
+ Mat dst,
+ MatOfFloat h,
+ int templateWindowSize,
+ int searchWindowSize)
+
Perform image denoising using Non-local Means Denoising algorithm
+ <http://www.ipol.im/pub/algo/bcm_non_local_means_denoising/> with several computational
+ optimizations. Noise expected to be a gaussian white noise
+
+
Parameters:
+
src - Input 8-bit or 16-bit (only with NORM_L1) 1-channel,
+ 2-channel, 3-channel or 4-channel image.
+
dst - Output image with the same size and type as src .
+
templateWindowSize - Size in pixels of the template patch that is used to compute weights.
+ Should be odd. Recommended value 7 pixels
+
searchWindowSize - Size in pixels of the window that is used to compute weighted average for
+ given pixel. Should be odd. Affect performance linearly: greater searchWindowsSize - greater
+ denoising time. Recommended value 21 pixels
+
h - Array of parameters regulating filter strength, either one
+ parameter applied to all channels or one per channel in dst. Big h value
+ perfectly removes noise but also removes image details, smaller h
+ value preserves details but also preserves some noise
+
+ This function expected to be applied to grayscale images. For colored images look at
+ fastNlMeansDenoisingColored. Advanced usage of this functions can be manual denoising of colored
+ image in different colorspaces. Such approach is used in fastNlMeansDenoisingColored by converting
+ image to CIELAB colorspace and then separately denoise L and AB components with different h
+ parameter.
public static void fastNlMeansDenoising(Mat src,
+ Mat dst,
+ MatOfFloat h,
+ int templateWindowSize,
+ int searchWindowSize,
+ int normType)
+
Perform image denoising using Non-local Means Denoising algorithm
+ <http://www.ipol.im/pub/algo/bcm_non_local_means_denoising/> with several computational
+ optimizations. Noise expected to be a gaussian white noise
+
+
Parameters:
+
src - Input 8-bit or 16-bit (only with NORM_L1) 1-channel,
+ 2-channel, 3-channel or 4-channel image.
+
dst - Output image with the same size and type as src .
+
templateWindowSize - Size in pixels of the template patch that is used to compute weights.
+ Should be odd. Recommended value 7 pixels
+
searchWindowSize - Size in pixels of the window that is used to compute weighted average for
+ given pixel. Should be odd. Affect performance linearly: greater searchWindowsSize - greater
+ denoising time. Recommended value 21 pixels
+
h - Array of parameters regulating filter strength, either one
+ parameter applied to all channels or one per channel in dst. Big h value
+ perfectly removes noise but also removes image details, smaller h
+ value preserves details but also preserves some noise
+
normType - Type of norm used for weight calculation. Can be either NORM_L2 or NORM_L1
+
+ This function expected to be applied to grayscale images. For colored images look at
+ fastNlMeansDenoisingColored. Advanced usage of this functions can be manual denoising of colored
+ image in different colorspaces. Such approach is used in fastNlMeansDenoisingColored by converting
+ image to CIELAB colorspace and then separately denoise L and AB components with different h
+ parameter.
public static void fastNlMeansDenoisingColored(Mat src,
+ Mat dst)
+
Modification of fastNlMeansDenoising function for colored images
+
+
Parameters:
+
src - Input 8-bit 3-channel image.
+
dst - Output image with the same size and type as src .
+ Should be odd. Recommended value 7 pixels
+ given pixel. Should be odd. Affect performance linearly: greater searchWindowsSize - greater
+ denoising time. Recommended value 21 pixels
+ removes noise but also removes image details, smaller h value preserves details but also preserves
+ some noise
+ will be enough to remove colored noise and do not distort colors
+
+ The function converts image to CIELAB colorspace and then separately denoise L and AB components
+ with given h parameters using fastNlMeansDenoising function.
public static void fastNlMeansDenoisingColored(Mat src,
+ Mat dst,
+ float h)
+
Modification of fastNlMeansDenoising function for colored images
+
+
Parameters:
+
src - Input 8-bit 3-channel image.
+
dst - Output image with the same size and type as src .
+ Should be odd. Recommended value 7 pixels
+ given pixel. Should be odd. Affect performance linearly: greater searchWindowsSize - greater
+ denoising time. Recommended value 21 pixels
+
h - Parameter regulating filter strength for luminance component. Bigger h value perfectly
+ removes noise but also removes image details, smaller h value preserves details but also preserves
+ some noise
+ will be enough to remove colored noise and do not distort colors
+
+ The function converts image to CIELAB colorspace and then separately denoise L and AB components
+ with given h parameters using fastNlMeansDenoising function.
public static void fastNlMeansDenoisingColored(Mat src,
+ Mat dst,
+ float h,
+ float hColor)
+
Modification of fastNlMeansDenoising function for colored images
+
+
Parameters:
+
src - Input 8-bit 3-channel image.
+
dst - Output image with the same size and type as src .
+ Should be odd. Recommended value 7 pixels
+ given pixel. Should be odd. Affect performance linearly: greater searchWindowsSize - greater
+ denoising time. Recommended value 21 pixels
+
h - Parameter regulating filter strength for luminance component. Bigger h value perfectly
+ removes noise but also removes image details, smaller h value preserves details but also preserves
+ some noise
+
hColor - The same as h but for color components. For most images value equals 10
+ will be enough to remove colored noise and do not distort colors
+
+ The function converts image to CIELAB colorspace and then separately denoise L and AB components
+ with given h parameters using fastNlMeansDenoising function.
public static void fastNlMeansDenoisingColored(Mat src,
+ Mat dst,
+ float h,
+ float hColor,
+ int templateWindowSize)
+
Modification of fastNlMeansDenoising function for colored images
+
+
Parameters:
+
src - Input 8-bit 3-channel image.
+
dst - Output image with the same size and type as src .
+
templateWindowSize - Size in pixels of the template patch that is used to compute weights.
+ Should be odd. Recommended value 7 pixels
+ given pixel. Should be odd. Affect performance linearly: greater searchWindowsSize - greater
+ denoising time. Recommended value 21 pixels
+
h - Parameter regulating filter strength for luminance component. Bigger h value perfectly
+ removes noise but also removes image details, smaller h value preserves details but also preserves
+ some noise
+
hColor - The same as h but for color components. For most images value equals 10
+ will be enough to remove colored noise and do not distort colors
+
+ The function converts image to CIELAB colorspace and then separately denoise L and AB components
+ with given h parameters using fastNlMeansDenoising function.
public static void fastNlMeansDenoisingColored(Mat src,
+ Mat dst,
+ float h,
+ float hColor,
+ int templateWindowSize,
+ int searchWindowSize)
+
Modification of fastNlMeansDenoising function for colored images
+
+
Parameters:
+
src - Input 8-bit 3-channel image.
+
dst - Output image with the same size and type as src .
+
templateWindowSize - Size in pixels of the template patch that is used to compute weights.
+ Should be odd. Recommended value 7 pixels
+
searchWindowSize - Size in pixels of the window that is used to compute weighted average for
+ given pixel. Should be odd. Affect performance linearly: greater searchWindowsSize - greater
+ denoising time. Recommended value 21 pixels
+
h - Parameter regulating filter strength for luminance component. Bigger h value perfectly
+ removes noise but also removes image details, smaller h value preserves details but also preserves
+ some noise
+
hColor - The same as h but for color components. For most images value equals 10
+ will be enough to remove colored noise and do not distort colors
+
+ The function converts image to CIELAB colorspace and then separately denoise L and AB components
+ with given h parameters using fastNlMeansDenoising function.
public static void fastNlMeansDenoisingColoredMulti(java.util.List<Mat> srcImgs,
+ Mat dst,
+ int imgToDenoiseIndex,
+ int temporalWindowSize)
+
Modification of fastNlMeansDenoisingMulti function for colored images sequences
+
+
Parameters:
+
srcImgs - Input 8-bit 3-channel images sequence. All images should have the same type and
+ size.
+
imgToDenoiseIndex - Target image to denoise index in srcImgs sequence
+
temporalWindowSize - Number of surrounding images to use for target image denoising. Should
+ be odd. Images from imgToDenoiseIndex - temporalWindowSize / 2 to
+ imgToDenoiseIndex - temporalWindowSize / 2 from srcImgs will be used to denoise
+ srcImgs[imgToDenoiseIndex] image.
+
dst - Output image with the same size and type as srcImgs images.
+ Should be odd. Recommended value 7 pixels
+ given pixel. Should be odd. Affect performance linearly: greater searchWindowsSize - greater
+ denoising time. Recommended value 21 pixels
+ removes noise but also removes image details, smaller h value preserves details but also preserves
+ some noise.
+
+ The function converts images to CIELAB colorspace and then separately denoise L and AB components
+ with given h parameters using fastNlMeansDenoisingMulti function.
public static void fastNlMeansDenoisingColoredMulti(java.util.List<Mat> srcImgs,
+ Mat dst,
+ int imgToDenoiseIndex,
+ int temporalWindowSize,
+ float h)
+
Modification of fastNlMeansDenoisingMulti function for colored images sequences
+
+
Parameters:
+
srcImgs - Input 8-bit 3-channel images sequence. All images should have the same type and
+ size.
+
imgToDenoiseIndex - Target image to denoise index in srcImgs sequence
+
temporalWindowSize - Number of surrounding images to use for target image denoising. Should
+ be odd. Images from imgToDenoiseIndex - temporalWindowSize / 2 to
+ imgToDenoiseIndex - temporalWindowSize / 2 from srcImgs will be used to denoise
+ srcImgs[imgToDenoiseIndex] image.
+
dst - Output image with the same size and type as srcImgs images.
+ Should be odd. Recommended value 7 pixels
+ given pixel. Should be odd. Affect performance linearly: greater searchWindowsSize - greater
+ denoising time. Recommended value 21 pixels
+
h - Parameter regulating filter strength for luminance component. Bigger h value perfectly
+ removes noise but also removes image details, smaller h value preserves details but also preserves
+ some noise.
+
+ The function converts images to CIELAB colorspace and then separately denoise L and AB components
+ with given h parameters using fastNlMeansDenoisingMulti function.
public static void fastNlMeansDenoisingColoredMulti(java.util.List<Mat> srcImgs,
+ Mat dst,
+ int imgToDenoiseIndex,
+ int temporalWindowSize,
+ float h,
+ float hColor)
+
Modification of fastNlMeansDenoisingMulti function for colored images sequences
+
+
Parameters:
+
srcImgs - Input 8-bit 3-channel images sequence. All images should have the same type and
+ size.
+
imgToDenoiseIndex - Target image to denoise index in srcImgs sequence
+
temporalWindowSize - Number of surrounding images to use for target image denoising. Should
+ be odd. Images from imgToDenoiseIndex - temporalWindowSize / 2 to
+ imgToDenoiseIndex - temporalWindowSize / 2 from srcImgs will be used to denoise
+ srcImgs[imgToDenoiseIndex] image.
+
dst - Output image with the same size and type as srcImgs images.
+ Should be odd. Recommended value 7 pixels
+ given pixel. Should be odd. Affect performance linearly: greater searchWindowsSize - greater
+ denoising time. Recommended value 21 pixels
+
h - Parameter regulating filter strength for luminance component. Bigger h value perfectly
+ removes noise but also removes image details, smaller h value preserves details but also preserves
+ some noise.
+
hColor - The same as h but for color components.
+
+ The function converts images to CIELAB colorspace and then separately denoise L and AB components
+ with given h parameters using fastNlMeansDenoisingMulti function.
public static void fastNlMeansDenoisingColoredMulti(java.util.List<Mat> srcImgs,
+ Mat dst,
+ int imgToDenoiseIndex,
+ int temporalWindowSize,
+ float h,
+ float hColor,
+ int templateWindowSize)
+
Modification of fastNlMeansDenoisingMulti function for colored images sequences
+
+
Parameters:
+
srcImgs - Input 8-bit 3-channel images sequence. All images should have the same type and
+ size.
+
imgToDenoiseIndex - Target image to denoise index in srcImgs sequence
+
temporalWindowSize - Number of surrounding images to use for target image denoising. Should
+ be odd. Images from imgToDenoiseIndex - temporalWindowSize / 2 to
+ imgToDenoiseIndex - temporalWindowSize / 2 from srcImgs will be used to denoise
+ srcImgs[imgToDenoiseIndex] image.
+
dst - Output image with the same size and type as srcImgs images.
+
templateWindowSize - Size in pixels of the template patch that is used to compute weights.
+ Should be odd. Recommended value 7 pixels
+ given pixel. Should be odd. Affect performance linearly: greater searchWindowsSize - greater
+ denoising time. Recommended value 21 pixels
+
h - Parameter regulating filter strength for luminance component. Bigger h value perfectly
+ removes noise but also removes image details, smaller h value preserves details but also preserves
+ some noise.
+
hColor - The same as h but for color components.
+
+ The function converts images to CIELAB colorspace and then separately denoise L and AB components
+ with given h parameters using fastNlMeansDenoisingMulti function.
public static void fastNlMeansDenoisingColoredMulti(java.util.List<Mat> srcImgs,
+ Mat dst,
+ int imgToDenoiseIndex,
+ int temporalWindowSize,
+ float h,
+ float hColor,
+ int templateWindowSize,
+ int searchWindowSize)
+
Modification of fastNlMeansDenoisingMulti function for colored images sequences
+
+
Parameters:
+
srcImgs - Input 8-bit 3-channel images sequence. All images should have the same type and
+ size.
+
imgToDenoiseIndex - Target image to denoise index in srcImgs sequence
+
temporalWindowSize - Number of surrounding images to use for target image denoising. Should
+ be odd. Images from imgToDenoiseIndex - temporalWindowSize / 2 to
+ imgToDenoiseIndex - temporalWindowSize / 2 from srcImgs will be used to denoise
+ srcImgs[imgToDenoiseIndex] image.
+
dst - Output image with the same size and type as srcImgs images.
+
templateWindowSize - Size in pixels of the template patch that is used to compute weights.
+ Should be odd. Recommended value 7 pixels
+
searchWindowSize - Size in pixels of the window that is used to compute weighted average for
+ given pixel. Should be odd. Affect performance linearly: greater searchWindowsSize - greater
+ denoising time. Recommended value 21 pixels
+
h - Parameter regulating filter strength for luminance component. Bigger h value perfectly
+ removes noise but also removes image details, smaller h value preserves details but also preserves
+ some noise.
+
hColor - The same as h but for color components.
+
+ The function converts images to CIELAB colorspace and then separately denoise L and AB components
+ with given h parameters using fastNlMeansDenoisingMulti function.
public static void fastNlMeansDenoisingMulti(java.util.List<Mat> srcImgs,
+ Mat dst,
+ int imgToDenoiseIndex,
+ int temporalWindowSize)
+
Modification of fastNlMeansDenoising function for images sequence where consecutive images have been
+ captured in small period of time. For example video. This version of the function is for grayscale
+ images or for manual manipulation with colorspaces. See CITE: Buades2005DenoisingIS for more details
+ (open access [here](https://static.aminer.org/pdf/PDF/000/317/196/spatio_temporal_wiener_filtering_of_image_sequences_using_a_parametric.pdf)).
+
+
Parameters:
+
srcImgs - Input 8-bit 1-channel, 2-channel, 3-channel or
+ 4-channel images sequence. All images should have the same type and
+ size.
+
imgToDenoiseIndex - Target image to denoise index in srcImgs sequence
+
temporalWindowSize - Number of surrounding images to use for target image denoising. Should
+ be odd. Images from imgToDenoiseIndex - temporalWindowSize / 2 to
+ imgToDenoiseIndex - temporalWindowSize / 2 from srcImgs will be used to denoise
+ srcImgs[imgToDenoiseIndex] image.
+
dst - Output image with the same size and type as srcImgs images.
+ Should be odd. Recommended value 7 pixels
+ given pixel. Should be odd. Affect performance linearly: greater searchWindowsSize - greater
+ denoising time. Recommended value 21 pixels
+ perfectly removes noise but also removes image details, smaller h
+ value preserves details but also preserves some noise
public static void fastNlMeansDenoisingMulti(java.util.List<Mat> srcImgs,
+ Mat dst,
+ int imgToDenoiseIndex,
+ int temporalWindowSize,
+ float h)
+
Modification of fastNlMeansDenoising function for images sequence where consecutive images have been
+ captured in small period of time. For example video. This version of the function is for grayscale
+ images or for manual manipulation with colorspaces. See CITE: Buades2005DenoisingIS for more details
+ (open access [here](https://static.aminer.org/pdf/PDF/000/317/196/spatio_temporal_wiener_filtering_of_image_sequences_using_a_parametric.pdf)).
+
+
Parameters:
+
srcImgs - Input 8-bit 1-channel, 2-channel, 3-channel or
+ 4-channel images sequence. All images should have the same type and
+ size.
+
imgToDenoiseIndex - Target image to denoise index in srcImgs sequence
+
temporalWindowSize - Number of surrounding images to use for target image denoising. Should
+ be odd. Images from imgToDenoiseIndex - temporalWindowSize / 2 to
+ imgToDenoiseIndex - temporalWindowSize / 2 from srcImgs will be used to denoise
+ srcImgs[imgToDenoiseIndex] image.
+
dst - Output image with the same size and type as srcImgs images.
+ Should be odd. Recommended value 7 pixels
+ given pixel. Should be odd. Affect performance linearly: greater searchWindowsSize - greater
+ denoising time. Recommended value 21 pixels
+
h - Parameter regulating filter strength. Bigger h value
+ perfectly removes noise but also removes image details, smaller h
+ value preserves details but also preserves some noise
public static void fastNlMeansDenoisingMulti(java.util.List<Mat> srcImgs,
+ Mat dst,
+ int imgToDenoiseIndex,
+ int temporalWindowSize,
+ float h,
+ int templateWindowSize)
+
Modification of fastNlMeansDenoising function for images sequence where consecutive images have been
+ captured in small period of time. For example video. This version of the function is for grayscale
+ images or for manual manipulation with colorspaces. See CITE: Buades2005DenoisingIS for more details
+ (open access [here](https://static.aminer.org/pdf/PDF/000/317/196/spatio_temporal_wiener_filtering_of_image_sequences_using_a_parametric.pdf)).
+
+
Parameters:
+
srcImgs - Input 8-bit 1-channel, 2-channel, 3-channel or
+ 4-channel images sequence. All images should have the same type and
+ size.
+
imgToDenoiseIndex - Target image to denoise index in srcImgs sequence
+
temporalWindowSize - Number of surrounding images to use for target image denoising. Should
+ be odd. Images from imgToDenoiseIndex - temporalWindowSize / 2 to
+ imgToDenoiseIndex - temporalWindowSize / 2 from srcImgs will be used to denoise
+ srcImgs[imgToDenoiseIndex] image.
+
dst - Output image with the same size and type as srcImgs images.
+
templateWindowSize - Size in pixels of the template patch that is used to compute weights.
+ Should be odd. Recommended value 7 pixels
+ given pixel. Should be odd. Affect performance linearly: greater searchWindowsSize - greater
+ denoising time. Recommended value 21 pixels
+
h - Parameter regulating filter strength. Bigger h value
+ perfectly removes noise but also removes image details, smaller h
+ value preserves details but also preserves some noise
public static void fastNlMeansDenoisingMulti(java.util.List<Mat> srcImgs,
+ Mat dst,
+ int imgToDenoiseIndex,
+ int temporalWindowSize,
+ float h,
+ int templateWindowSize,
+ int searchWindowSize)
+
Modification of fastNlMeansDenoising function for images sequence where consecutive images have been
+ captured in small period of time. For example video. This version of the function is for grayscale
+ images or for manual manipulation with colorspaces. See CITE: Buades2005DenoisingIS for more details
+ (open access [here](https://static.aminer.org/pdf/PDF/000/317/196/spatio_temporal_wiener_filtering_of_image_sequences_using_a_parametric.pdf)).
+
+
Parameters:
+
srcImgs - Input 8-bit 1-channel, 2-channel, 3-channel or
+ 4-channel images sequence. All images should have the same type and
+ size.
+
imgToDenoiseIndex - Target image to denoise index in srcImgs sequence
+
temporalWindowSize - Number of surrounding images to use for target image denoising. Should
+ be odd. Images from imgToDenoiseIndex - temporalWindowSize / 2 to
+ imgToDenoiseIndex - temporalWindowSize / 2 from srcImgs will be used to denoise
+ srcImgs[imgToDenoiseIndex] image.
+
dst - Output image with the same size and type as srcImgs images.
+
templateWindowSize - Size in pixels of the template patch that is used to compute weights.
+ Should be odd. Recommended value 7 pixels
+
searchWindowSize - Size in pixels of the window that is used to compute weighted average for
+ given pixel. Should be odd. Affect performance linearly: greater searchWindowsSize - greater
+ denoising time. Recommended value 21 pixels
+
h - Parameter regulating filter strength. Bigger h value
+ perfectly removes noise but also removes image details, smaller h
+ value preserves details but also preserves some noise
public static void fastNlMeansDenoisingMulti(java.util.List<Mat> srcImgs,
+ Mat dst,
+ int imgToDenoiseIndex,
+ int temporalWindowSize,
+ MatOfFloat h)
+
Modification of fastNlMeansDenoising function for images sequence where consecutive images have been
+ captured in small period of time. For example video. This version of the function is for grayscale
+ images or for manual manipulation with colorspaces. See CITE: Buades2005DenoisingIS for more details
+ (open access [here](https://static.aminer.org/pdf/PDF/000/317/196/spatio_temporal_wiener_filtering_of_image_sequences_using_a_parametric.pdf)).
+
+
Parameters:
+
srcImgs - Input 8-bit or 16-bit (only with NORM_L1) 1-channel,
+ 2-channel, 3-channel or 4-channel images sequence. All images should
+ have the same type and size.
+
imgToDenoiseIndex - Target image to denoise index in srcImgs sequence
+
temporalWindowSize - Number of surrounding images to use for target image denoising. Should
+ be odd. Images from imgToDenoiseIndex - temporalWindowSize / 2 to
+ imgToDenoiseIndex - temporalWindowSize / 2 from srcImgs will be used to denoise
+ srcImgs[imgToDenoiseIndex] image.
+
dst - Output image with the same size and type as srcImgs images.
+ Should be odd. Recommended value 7 pixels
+ given pixel. Should be odd. Affect performance linearly: greater searchWindowsSize - greater
+ denoising time. Recommended value 21 pixels
+
h - Array of parameters regulating filter strength, either one
+ parameter applied to all channels or one per channel in dst. Big h value
+ perfectly removes noise but also removes image details, smaller h
+ value preserves details but also preserves some noise
public static void fastNlMeansDenoisingMulti(java.util.List<Mat> srcImgs,
+ Mat dst,
+ int imgToDenoiseIndex,
+ int temporalWindowSize,
+ MatOfFloat h,
+ int templateWindowSize)
+
Modification of fastNlMeansDenoising function for images sequence where consecutive images have been
+ captured in small period of time. For example video. This version of the function is for grayscale
+ images or for manual manipulation with colorspaces. See CITE: Buades2005DenoisingIS for more details
+ (open access [here](https://static.aminer.org/pdf/PDF/000/317/196/spatio_temporal_wiener_filtering_of_image_sequences_using_a_parametric.pdf)).
+
+
Parameters:
+
srcImgs - Input 8-bit or 16-bit (only with NORM_L1) 1-channel,
+ 2-channel, 3-channel or 4-channel images sequence. All images should
+ have the same type and size.
+
imgToDenoiseIndex - Target image to denoise index in srcImgs sequence
+
temporalWindowSize - Number of surrounding images to use for target image denoising. Should
+ be odd. Images from imgToDenoiseIndex - temporalWindowSize / 2 to
+ imgToDenoiseIndex - temporalWindowSize / 2 from srcImgs will be used to denoise
+ srcImgs[imgToDenoiseIndex] image.
+
dst - Output image with the same size and type as srcImgs images.
+
templateWindowSize - Size in pixels of the template patch that is used to compute weights.
+ Should be odd. Recommended value 7 pixels
+ given pixel. Should be odd. Affect performance linearly: greater searchWindowsSize - greater
+ denoising time. Recommended value 21 pixels
+
h - Array of parameters regulating filter strength, either one
+ parameter applied to all channels or one per channel in dst. Big h value
+ perfectly removes noise but also removes image details, smaller h
+ value preserves details but also preserves some noise
public static void fastNlMeansDenoisingMulti(java.util.List<Mat> srcImgs,
+ Mat dst,
+ int imgToDenoiseIndex,
+ int temporalWindowSize,
+ MatOfFloat h,
+ int templateWindowSize,
+ int searchWindowSize)
+
Modification of fastNlMeansDenoising function for images sequence where consecutive images have been
+ captured in small period of time. For example video. This version of the function is for grayscale
+ images or for manual manipulation with colorspaces. See CITE: Buades2005DenoisingIS for more details
+ (open access [here](https://static.aminer.org/pdf/PDF/000/317/196/spatio_temporal_wiener_filtering_of_image_sequences_using_a_parametric.pdf)).
+
+
Parameters:
+
srcImgs - Input 8-bit or 16-bit (only with NORM_L1) 1-channel,
+ 2-channel, 3-channel or 4-channel images sequence. All images should
+ have the same type and size.
+
imgToDenoiseIndex - Target image to denoise index in srcImgs sequence
+
temporalWindowSize - Number of surrounding images to use for target image denoising. Should
+ be odd. Images from imgToDenoiseIndex - temporalWindowSize / 2 to
+ imgToDenoiseIndex - temporalWindowSize / 2 from srcImgs will be used to denoise
+ srcImgs[imgToDenoiseIndex] image.
+
dst - Output image with the same size and type as srcImgs images.
+
templateWindowSize - Size in pixels of the template patch that is used to compute weights.
+ Should be odd. Recommended value 7 pixels
+
searchWindowSize - Size in pixels of the window that is used to compute weighted average for
+ given pixel. Should be odd. Affect performance linearly: greater searchWindowsSize - greater
+ denoising time. Recommended value 21 pixels
+
h - Array of parameters regulating filter strength, either one
+ parameter applied to all channels or one per channel in dst. Big h value
+ perfectly removes noise but also removes image details, smaller h
+ value preserves details but also preserves some noise
public static void fastNlMeansDenoisingMulti(java.util.List<Mat> srcImgs,
+ Mat dst,
+ int imgToDenoiseIndex,
+ int temporalWindowSize,
+ MatOfFloat h,
+ int templateWindowSize,
+ int searchWindowSize,
+ int normType)
+
Modification of fastNlMeansDenoising function for images sequence where consecutive images have been
+ captured in small period of time. For example video. This version of the function is for grayscale
+ images or for manual manipulation with colorspaces. See CITE: Buades2005DenoisingIS for more details
+ (open access [here](https://static.aminer.org/pdf/PDF/000/317/196/spatio_temporal_wiener_filtering_of_image_sequences_using_a_parametric.pdf)).
+
+
Parameters:
+
srcImgs - Input 8-bit or 16-bit (only with NORM_L1) 1-channel,
+ 2-channel, 3-channel or 4-channel images sequence. All images should
+ have the same type and size.
+
imgToDenoiseIndex - Target image to denoise index in srcImgs sequence
+
temporalWindowSize - Number of surrounding images to use for target image denoising. Should
+ be odd. Images from imgToDenoiseIndex - temporalWindowSize / 2 to
+ imgToDenoiseIndex - temporalWindowSize / 2 from srcImgs will be used to denoise
+ srcImgs[imgToDenoiseIndex] image.
+
dst - Output image with the same size and type as srcImgs images.
+
templateWindowSize - Size in pixels of the template patch that is used to compute weights.
+ Should be odd. Recommended value 7 pixels
+
searchWindowSize - Size in pixels of the window that is used to compute weighted average for
+ given pixel. Should be odd. Affect performance linearly: greater searchWindowsSize - greater
+ denoising time. Recommended value 21 pixels
+
h - Array of parameters regulating filter strength, either one
+ parameter applied to all channels or one per channel in dst. Big h value
+ perfectly removes noise but also removes image details, smaller h
+ value preserves details but also preserves some noise
+
normType - Type of norm used for weight calculation. Can be either NORM_L2 or NORM_L1
public static void illuminationChange(Mat src,
+ Mat mask,
+ Mat dst)
+
Applying an appropriate non-linear transformation to the gradient field inside the selection and
+ then integrating back with a Poisson solver, modifies locally the apparent illumination of an image.
+
+
Parameters:
+
src - Input 8-bit 3-channel image.
+
mask - Input 8-bit 1 or 3-channel image.
+
dst - Output image with the same size and type as src.
+
+ This is useful to highlight under-exposed foreground objects or to reduce specular reflections.
public static void illuminationChange(Mat src,
+ Mat mask,
+ Mat dst,
+ float alpha)
+
Applying an appropriate non-linear transformation to the gradient field inside the selection and
+ then integrating back with a Poisson solver, modifies locally the apparent illumination of an image.
+
+
Parameters:
+
src - Input 8-bit 3-channel image.
+
mask - Input 8-bit 1 or 3-channel image.
+
dst - Output image with the same size and type as src.
+
alpha - Value ranges between 0-2.
+
+ This is useful to highlight under-exposed foreground objects or to reduce specular reflections.
public static void illuminationChange(Mat src,
+ Mat mask,
+ Mat dst,
+ float alpha,
+ float beta)
+
Applying an appropriate non-linear transformation to the gradient field inside the selection and
+ then integrating back with a Poisson solver, modifies locally the apparent illumination of an image.
+
+
Parameters:
+
src - Input 8-bit 3-channel image.
+
mask - Input 8-bit 1 or 3-channel image.
+
dst - Output image with the same size and type as src.
+
alpha - Value ranges between 0-2.
+
beta - Value ranges between 0-2.
+
+ This is useful to highlight under-exposed foreground objects or to reduce specular reflections.
public static void inpaint(Mat src,
+ Mat inpaintMask,
+ Mat dst,
+ double inpaintRadius,
+ int flags)
+
Restores the selected region in an image using the region neighborhood.
+
+
Parameters:
+
src - Input 8-bit, 16-bit unsigned or 32-bit float 1-channel or 8-bit 3-channel image.
+
inpaintMask - Inpainting mask, 8-bit 1-channel image. Non-zero pixels indicate the area that
+ needs to be inpainted.
+
dst - Output image with the same size and type as src .
+
inpaintRadius - Radius of a circular neighborhood of each point inpainted that is considered
+ by the algorithm.
+
flags - Inpainting method that could be cv::INPAINT_NS or cv::INPAINT_TELEA
+
+ The function reconstructs the selected image area from the pixel near the area boundary. The
+ function may be used to remove dust and scratches from a scanned photo, or to remove undesirable
+ objects from still images or video. See <http://en.wikipedia.org/wiki/Inpainting> for more details.
+
+ Note:
+
+
+ An example using the inpainting technique can be found at
+ opencv_source_code/samples/cpp/inpaint.cpp
+
+
+ (Python) An example using the inpainting technique can be found at
+ opencv_source_code/samples/python/inpaint.py
+
public static void seamlessClone(Mat src,
+ Mat dst,
+ Mat mask,
+ Point p,
+ Mat blend,
+ int flags)
+
Image editing tasks concern either global changes (color/intensity corrections, filters,
+ deformations) or local changes concerned to a selection. Here we are interested in achieving local
+ changes, ones that are restricted to a region manually selected (ROI), in a seamless and effortless
+ manner. The extent of the changes ranges from slight distortions to complete replacement by novel
+ content CITE: PM03 .
+
+
Parameters:
+
src - Input 8-bit 3-channel image.
+
dst - Input 8-bit 3-channel image.
+
mask - Input 8-bit 1 or 3-channel image.
+
p - Point in dst image where object is placed.
+
blend - Output image with the same size and type as dst.
+
flags - Cloning method that could be cv::NORMAL_CLONE, cv::MIXED_CLONE or cv::MONOCHROME_TRANSFER
public static void stylization(Mat src,
+ Mat dst)
+
Stylization aims to produce digital imagery with a wide variety of effects not focused on
+ photorealism. Edge-aware filters are ideal for stylization, as they can abstract regions of low
+ contrast while preserving, or enhancing, high-contrast features.
+
+
Parameters:
+
src - Input 8-bit 3-channel image.
+
dst - Output image with the same size and type as src.
public static void stylization(Mat src,
+ Mat dst,
+ float sigma_s)
+
Stylization aims to produce digital imagery with a wide variety of effects not focused on
+ photorealism. Edge-aware filters are ideal for stylization, as they can abstract regions of low
+ contrast while preserving, or enhancing, high-contrast features.
+
+
Parameters:
+
src - Input 8-bit 3-channel image.
+
dst - Output image with the same size and type as src.
public static void stylization(Mat src,
+ Mat dst,
+ float sigma_s,
+ float sigma_r)
+
Stylization aims to produce digital imagery with a wide variety of effects not focused on
+ photorealism. Edge-aware filters are ideal for stylization, as they can abstract regions of low
+ contrast while preserving, or enhancing, high-contrast features.
+
+
Parameters:
+
src - Input 8-bit 3-channel image.
+
dst - Output image with the same size and type as src.
public static void textureFlattening(Mat src,
+ Mat mask,
+ Mat dst)
+
By retaining only the gradients at edge locations, before integrating with the Poisson solver, one
+ washes out the texture of the selected region, giving its contents a flat aspect. Here Canny Edge %Detector is used.
+
+
Parameters:
+
src - Input 8-bit 3-channel image.
+
mask - Input 8-bit 1 or 3-channel image.
+
dst - Output image with the same size and type as src.
+
+ Note:
+ The algorithm assumes that the color of the source image is close to that of the destination. This
+ assumption means that when the colors don't match, the source image color gets tinted toward the
+ color of the destination image.
public static void textureFlattening(Mat src,
+ Mat mask,
+ Mat dst,
+ float low_threshold)
+
By retaining only the gradients at edge locations, before integrating with the Poisson solver, one
+ washes out the texture of the selected region, giving its contents a flat aspect. Here Canny Edge %Detector is used.
+
+
Parameters:
+
src - Input 8-bit 3-channel image.
+
mask - Input 8-bit 1 or 3-channel image.
+
dst - Output image with the same size and type as src.
+
low_threshold - %Range from 0 to 100.
+
+ Note:
+ The algorithm assumes that the color of the source image is close to that of the destination. This
+ assumption means that when the colors don't match, the source image color gets tinted toward the
+ color of the destination image.
public static void textureFlattening(Mat src,
+ Mat mask,
+ Mat dst,
+ float low_threshold,
+ float high_threshold)
+
By retaining only the gradients at edge locations, before integrating with the Poisson solver, one
+ washes out the texture of the selected region, giving its contents a flat aspect. Here Canny Edge %Detector is used.
+
+
Parameters:
+
src - Input 8-bit 3-channel image.
+
mask - Input 8-bit 1 or 3-channel image.
+
dst - Output image with the same size and type as src.
+
low_threshold - %Range from 0 to 100.
+
high_threshold - Value > 100.
+
+ Note:
+ The algorithm assumes that the color of the source image is close to that of the destination. This
+ assumption means that when the colors don't match, the source image color gets tinted toward the
+ color of the destination image.
public static void textureFlattening(Mat src,
+ Mat mask,
+ Mat dst,
+ float low_threshold,
+ float high_threshold,
+ int kernel_size)
+
By retaining only the gradients at edge locations, before integrating with the Poisson solver, one
+ washes out the texture of the selected region, giving its contents a flat aspect. Here Canny Edge %Detector is used.
+
+
Parameters:
+
src - Input 8-bit 3-channel image.
+
mask - Input 8-bit 1 or 3-channel image.
+
dst - Output image with the same size and type as src.
+
low_threshold - %Range from 0 to 100.
+
high_threshold - Value > 100.
+
kernel_size - The size of the Sobel kernel to be used.
+
+ Note:
+ The algorithm assumes that the color of the source image is close to that of the destination. This
+ assumption means that when the colors don't match, the source image color gets tinted toward the
+ color of the destination image.
Adaptive logarithmic mapping is a fast global tonemapping algorithm that scales the image in
+ logarithmic domain.
+
+ Since it's a global operator the same function is applied to all the pixels, it is controlled by the
+ bias parameter.
+
+ Optional saturation enhancement is possible as described in CITE: FL02 .
+
+ For more information see CITE: DM03 .
This algorithm transforms image to contrast using gradients on all levels of gaussian pyramid,
+ transforms contrast values to HVS response and scales the response. After this the image is
+ reconstructed from new contrast values.
+
+ For more information see CITE: MM06 .
This is a global tonemapping operator that models human visual system.
+
+ Mapping function is controlled by adaptation parameter, that is computed using light adaptation and
+ color adaptation.
+
+ For more information see CITE: RD05 .
This algorithm converts images to median threshold bitmaps (1 for pixels brighter than median
+ luminance and 0 otherwise) and than aligns the resulting bitmaps using bit operations.
This algorithm transforms image to contrast using gradients on all levels of gaussian pyramid,
+ transforms contrast values to HVS response and scales the response.
public class BackgroundSubtractor
+extends Algorithm
+
Base class for background/foreground segmentation. :
+
+ The class is only used to define the common interface for the whole family of background/foreground
+ segmentation algorithms.
fgmask - The output foreground mask as an 8-bit binary image.
+ learnt. Negative parameter value makes the algorithm to use some automatically chosen learning
+ rate. 0 means that the background model is not updated at all, 1 means that the background model
+ is completely reinitialized from the last frame.
public void apply(Mat image,
+ Mat fgmask,
+ double learningRate)
+
Computes a foreground mask.
+
+
Parameters:
+
image - Next video frame.
+
fgmask - The output foreground mask as an 8-bit binary image.
+
learningRate - The value between 0 and 1 that indicates how fast the background model is
+ learnt. Negative parameter value makes the algorithm to use some automatically chosen learning
+ rate. 0 means that the background model is not updated at all, 1 means that the background model
+ is completely reinitialized from the last frame.
public void getBackgroundImage(Mat backgroundImage)
+
Computes a background image.
+
+
Parameters:
+
backgroundImage - The output background image.
+
+ Note: Sometimes the background image can be very blurry, as it contain the average background
+ statistics.
K-nearest neighbours - based Background/Foreground Segmentation Algorithm.
+
+ The class implements the K-nearest neighbours background subtraction described in CITE: Zivkovic2006 .
+ Very efficient if number of foreground pixels is low.
Returns the threshold on the squared distance between the pixel and the sample
+
+ The threshold on the squared distance between the pixel and the sample to decide whether a pixel is
+ close to a data sample.
Returns the threshold on the squared distance between the pixel and the sample
+
+ The threshold on the squared distance between the pixel and the sample to decide whether a pixel is
+ close to a data sample.
Returns the number of neighbours, the k in the kNN.
+
+ K is the number of samples that need to be within dist2Threshold in order to decide that that
+ pixel is matching the kNN background model.
Returns the shadow threshold
+
+ A shadow is detected if pixel is a darker version of the background. The shadow threshold (Tau in
+ the paper) is a threshold defining how much darker the shadow can be. Tau= 0.5 means that if a pixel
+ is more than twice darker then it is not shadow. See Prati, Mikic, Trivedi and Cucchiara,
+ Detecting Moving Shadows...*, IEEE PAMI,2003.
Returns the shadow value
+
+ Shadow value is the value used to mark shadows in the foreground mask. Default value is 127. Value 0
+ in the mask always means background, 255 means foreground.
Gaussian Mixture-based Background/Foreground Segmentation Algorithm.
+
+ The class implements the Gaussian mixture model background subtraction described in CITE: Zivkovic2004
+ and CITE: Zivkovic2006 .
Returns the "background ratio" parameter of the algorithm
+
+ If a foreground pixel keeps semi-constant value for about backgroundRatio\*history frames, it's
+ considered background and added to the model as a center of a new component.
Returns the variance threshold for the pixel-model match
+
+ The main threshold on the squared Mahalanobis distance to decide if the sample is well described by
+ the background model or not.
Returns the variance threshold for the pixel-model match used for new mixture component generation
+
+ Threshold for the squared Mahalanobis distance that helps decide when a sample is close to the
+ existing components (corresponds to Tg in the paper).
image - Next video frame. Floating point frame will be used without scaling and should be in range \([0,255]\).
+
fgmask - The output foreground mask as an 8-bit binary image.
+ learnt. Negative parameter value makes the algorithm to use some automatically chosen learning
+ rate. 0 means that the background model is not updated at all, 1 means that the background model
+ is completely reinitialized from the last frame.
image - Next video frame. Floating point frame will be used without scaling and should be in range \([0,255]\).
+
fgmask - The output foreground mask as an 8-bit binary image.
+
learningRate - The value between 0 and 1 that indicates how fast the background model is
+ learnt. Negative parameter value makes the algorithm to use some automatically chosen learning
+ rate. 0 means that the background model is not updated at all, 1 means that the background model
+ is completely reinitialized from the last frame.
Returns the "background ratio" parameter of the algorithm
+
+ If a foreground pixel keeps semi-constant value for about backgroundRatio\*history frames, it's
+ considered background and added to the model as a center of a new component. It corresponds to TB
+ parameter in the paper.
Returns the complexity reduction threshold
+
+ This parameter defines the number of samples needed to accept to prove the component exists. CT=0.05
+ is a default value for all the samples. By setting CT=0 you get an algorithm very similar to the
+ standard Stauffer&Grimson algorithm.
Returns the shadow threshold
+
+ A shadow is detected if pixel is a darker version of the background. The shadow threshold (Tau in
+ the paper) is a threshold defining how much darker the shadow can be. Tau= 0.5 means that if a pixel
+ is more than twice darker then it is not shadow. See Prati, Mikic, Trivedi and Cucchiara,
+ Detecting Moving Shadows...*, IEEE PAMI,2003.
Returns the shadow value
+
+ Shadow value is the value used to mark shadows in the foreground mask. Default value is 127. Value 0
+ in the mask always means background, 255 means foreground.
Returns the variance threshold for the pixel-model match
+
+ The main threshold on the squared Mahalanobis distance to decide if the sample is well described by
+ the background model or not. Related to Cthr from the paper.
Returns the variance threshold for the pixel-model match used for new mixture component generation
+
+ Threshold for the squared Mahalanobis distance that helps decide when a sample is close to the
+ existing components (corresponds to Tg in the paper). If a pixel is not close to any component, it
+ is considered foreground or added as a new component. 3 sigma => Tg=3\*3=9 is default. A smaller Tg
+ value generates more components. A higher Tg value may result in a small number of components but
+ they can grow too large.
DIS optical flow algorithm.
+
+ This class implements the Dense Inverse Search (DIS) optical flow algorithm. More
+ details about the algorithm can be found at CITE: Kroeger2016 . Includes three presets with preselected
+ parameters to provide reasonable trade-off between speed and quality. However, even the slowest preset is
+ still relatively fast, use DeepFlow if you need better quality and don't care about speed.
+
+ This implementation includes several additional features compared to the algorithm described in the paper,
+ including spatial propagation of flow vectors (REF: getUseSpatialPropagation), as well as an option to
+ utilize an initial flow approximation passed to REF: calc (which is, essentially, temporal propagation,
+ if the previous frame's flow field is passed).
Finest level of the Gaussian pyramid on which the flow is computed (zero level
+ corresponds to the original image resolution). The final flow is obtained by bilinear upscaling.
+ SEE: setFinestScale
Maximum number of gradient descent iterations in the patch inverse search stage. Higher values
+ may improve quality in some cases.
+ SEE: setGradientDescentIterations
Whether to use mean-normalization of patches when computing patch distance. It is turned on
+ by default as it typically provides a noticeable quality boost because of increased robustness to
+ illumination variations. Turn it off if you are certain that your sequence doesn't contain any changes
+ in illumination.
+ SEE: setUseMeanNormalization
Whether to use spatial propagation of good optical flow vectors. This option is turned on by
+ default, as it tends to work better on average and can sometimes help recover from major errors
+ introduced by the coarse-to-fine scheme employed by the DIS optical flow algorithm. Turning this
+ option off can make the output flow field a bit smoother, however.
+ SEE: setUseSpatialPropagation
Number of fixed point iterations of variational refinement per scale. Set to zero to
+ disable variational refinement completely. Higher values will typically result in more smooth and
+ high-quality flow.
+ SEE: setGradientDescentIterations
public class KalmanFilter
+extends java.lang.Object
+
Kalman filter class.
+
+ The class implements a standard Kalman filter <http://en.wikipedia.org/wiki/Kalman_filter>,
+ CITE: Welch95 . However, you can modify transitionMatrix, controlMatrix, and measurementMatrix to get
+ an extended Kalman filter functionality.
+ Note: In C API when CvKalman\* kalmanFilter structure is not needed anymore, it should be released
+ with cvReleaseKalman(&kalmanFilter)
public void calc(Mat prevImg,
+ Mat nextImg,
+ Mat prevPts,
+ Mat nextPts,
+ Mat status)
+
Calculates a sparse optical flow.
+
+
Parameters:
+
prevImg - First input image.
+
nextImg - Second input image of the same size and the same type as prevImg.
+
prevPts - Vector of 2D points for which the flow needs to be found.
+
nextPts - Output vector of 2D points containing the calculated new positions of input features in the second image.
+
status - Output status vector. Each element of the vector is set to 1 if the
+ flow for the corresponding features has been found. Otherwise, it is set to 0.
public void calc(Mat prevImg,
+ Mat nextImg,
+ Mat prevPts,
+ Mat nextPts,
+ Mat status,
+ Mat err)
+
Calculates a sparse optical flow.
+
+
Parameters:
+
prevImg - First input image.
+
nextImg - Second input image of the same size and the same type as prevImg.
+
prevPts - Vector of 2D points for which the flow needs to be found.
+
nextPts - Output vector of 2D points containing the calculated new positions of input features in the second image.
+
status - Output status vector. Each element of the vector is set to 1 if the
+ flow for the corresponding features has been found. Otherwise, it is set to 0.
+
err - Optional output vector that contains error response for each point (inverse confidence).
Class used for calculating a sparse optical flow.
+
+ The class can calculate an optical flow for a sparse feature set using the
+ iterative Lucas-Kanade method with pyramids.
+
+ SEE: calcOpticalFlowPyrLK
public boolean update(Mat image,
+ Rect boundingBox)
+
Update the tracker, find the new most likely bounding box for the target
+
+
Parameters:
+
image - The current frame
+
boundingBox - The bounding box that represent the new target location, if true was returned, not
+ modified otherwise
+
Returns:
+
True means that target was located and false means that tracker cannot locate target in
+ current frame. Note, that latter *does not* imply that tracker has failed, maybe target is indeed
+ missing from the frame (say, out of sight)
the GOTURN (Generic Object Tracking Using Regression Networks) tracker
+
+ GOTURN (CITE: GOTURN) is kind of trackers based on Convolutional Neural Networks (CNN). While taking all advantages of CNN trackers,
+ GOTURN is much faster due to offline training without online fine-tuning nature.
+ GOTURN tracker addresses the problem of single target tracking: given a bounding box label of an object in the first frame of the video,
+ we track that object through the rest of the video. NOTE: Current method of GOTURN does not handle occlusions; however, it is fairly
+ robust to viewpoint changes, lighting changes, and deformations.
+ Inputs of GOTURN are two RGB patches representing Target and Search patches resized to 227x227.
+ Outputs of GOTURN are predicted bounding box coordinates, relative to Search patch coordinate system, in format X1,Y1,X2,Y2.
+ Original paper is here: <http://davheld.github.io/GOTURN/GOTURN.pdf>
+ As long as original authors implementation: <https://github.com/davheld/GOTURN#train-the-tracker>
+ Implementation of training algorithm is placed in separately here due to 3d-party dependencies:
+ <https://github.com/Auron-X/GOTURN_Training_Toolkit>
+ GOTURN architecture goturn.prototxt and trained model goturn.caffemodel are accessible on opencv_extra GitHub repository.
The MIL algorithm trains a classifier in an online manner to separate the object from the
+ background.
+
+ Multiple Instance Learning avoids the drift problem for a robust tracking. The implementation is
+ based on CITE: MIL .
+
+ Original code can be found here <http://vision.ucsd.edu/~bbabenko/project_miltrack.shtml>
the Nano tracker is a super lightweight dnn-based general object tracking.
+
+ Nano tracker is much faster and extremely lightweight due to special model structure, the whole model size is about 1.9 MB.
+ Nano tracker needs two models: one for feature extraction (backbone) and the another for localization (neckhead).
+ Model download link: https://github.com/HonglinChu/SiamTrackers/tree/master/NanoTrack/models/nanotrackv2
+ Original repo is here: https://github.com/HonglinChu/NanoTrack
+ Author: HongLinChu, 1628464345@qq.com
Variational optical flow refinement
+
+ This class implements variational refinement of the input flow field, i.e.
+ it uses input flow to initialize the minimization of the following functional:
+ \(E(U) = \int_{\Omega} \delta \Psi(E_I) + \gamma \Psi(E_G) + \alpha \Psi(E_S) \),
+ where \(E_I,E_G,E_S\) are color constancy, gradient constancy and smoothness terms
+ respectively. \(\Psi(s^2)=\sqrt{s^2+\epsilon^2}\) is a robust penalizer to limit the
+ influence of outliers. A complete formulation and a description of the minimization
+ procedure can be found in CITE: Brox2004
Number of inner successive over-relaxation (SOR) iterations
+ in the minimization procedure to solve the respective linear system.
+ SEE: setSorIterations
Constructs the image pyramid which can be passed to calcOpticalFlowPyrLK.
+
+
+
+
static int
+
buildOpticalFlowPyramid(Mat img,
+ java.util.List<Mat> pyramid,
+ Size winSize,
+ int maxLevel,
+ boolean withDerivatives,
+ int pyrBorder)
+
Constructs the image pyramid which can be passed to calcOpticalFlowPyrLK.
+
+
+
+
static int
+
buildOpticalFlowPyramid(Mat img,
+ java.util.List<Mat> pyramid,
+ Size winSize,
+ int maxLevel,
+ boolean withDerivatives,
+ int pyrBorder,
+ int derivBorder)
+
Constructs the image pyramid which can be passed to calcOpticalFlowPyrLK.
+
+
+
+
static int
+
buildOpticalFlowPyramid(Mat img,
+ java.util.List<Mat> pyramid,
+ Size winSize,
+ int maxLevel,
+ boolean withDerivatives,
+ int pyrBorder,
+ int derivBorder,
+ boolean tryReuseInputImage)
+
Constructs the image pyramid which can be passed to calcOpticalFlowPyrLK.
+
+
+
+
static void
+
calcOpticalFlowFarneback(Mat prev,
+ Mat next,
+ Mat flow,
+ double pyr_scale,
+ int levels,
+ int winsize,
+ int iterations,
+ int poly_n,
+ double poly_sigma,
+ int flags)
+
Computes a dense optical flow using the Gunnar Farneback's algorithm.
public static int buildOpticalFlowPyramid(Mat img,
+ java.util.List<Mat> pyramid,
+ Size winSize,
+ int maxLevel)
+
Constructs the image pyramid which can be passed to calcOpticalFlowPyrLK.
+
+
Parameters:
+
img - 8-bit input image.
+
pyramid - output pyramid.
+
winSize - window size of optical flow algorithm. Must be not less than winSize argument of
+ calcOpticalFlowPyrLK. It is needed to calculate required padding for pyramid levels.
+
maxLevel - 0-based maximal pyramid level number.
+ constructed without the gradients then calcOpticalFlowPyrLK will calculate them internally.
+ to force data copying.
+
Returns:
+
number of levels in constructed pyramid. Can be less than maxLevel.
public static int buildOpticalFlowPyramid(Mat img,
+ java.util.List<Mat> pyramid,
+ Size winSize,
+ int maxLevel,
+ boolean withDerivatives)
+
Constructs the image pyramid which can be passed to calcOpticalFlowPyrLK.
+
+
Parameters:
+
img - 8-bit input image.
+
pyramid - output pyramid.
+
winSize - window size of optical flow algorithm. Must be not less than winSize argument of
+ calcOpticalFlowPyrLK. It is needed to calculate required padding for pyramid levels.
+
maxLevel - 0-based maximal pyramid level number.
+
withDerivatives - set to precompute gradients for the every pyramid level. If pyramid is
+ constructed without the gradients then calcOpticalFlowPyrLK will calculate them internally.
+ to force data copying.
+
Returns:
+
number of levels in constructed pyramid. Can be less than maxLevel.
public static int buildOpticalFlowPyramid(Mat img,
+ java.util.List<Mat> pyramid,
+ Size winSize,
+ int maxLevel,
+ boolean withDerivatives,
+ int pyrBorder)
+
Constructs the image pyramid which can be passed to calcOpticalFlowPyrLK.
+
+
Parameters:
+
img - 8-bit input image.
+
pyramid - output pyramid.
+
winSize - window size of optical flow algorithm. Must be not less than winSize argument of
+ calcOpticalFlowPyrLK. It is needed to calculate required padding for pyramid levels.
+
maxLevel - 0-based maximal pyramid level number.
+
withDerivatives - set to precompute gradients for the every pyramid level. If pyramid is
+ constructed without the gradients then calcOpticalFlowPyrLK will calculate them internally.
+
pyrBorder - the border mode for pyramid layers.
+ to force data copying.
+
Returns:
+
number of levels in constructed pyramid. Can be less than maxLevel.
public static int buildOpticalFlowPyramid(Mat img,
+ java.util.List<Mat> pyramid,
+ Size winSize,
+ int maxLevel,
+ boolean withDerivatives,
+ int pyrBorder,
+ int derivBorder)
+
Constructs the image pyramid which can be passed to calcOpticalFlowPyrLK.
+
+
Parameters:
+
img - 8-bit input image.
+
pyramid - output pyramid.
+
winSize - window size of optical flow algorithm. Must be not less than winSize argument of
+ calcOpticalFlowPyrLK. It is needed to calculate required padding for pyramid levels.
+
maxLevel - 0-based maximal pyramid level number.
+
withDerivatives - set to precompute gradients for the every pyramid level. If pyramid is
+ constructed without the gradients then calcOpticalFlowPyrLK will calculate them internally.
+
pyrBorder - the border mode for pyramid layers.
+
derivBorder - the border mode for gradients.
+ to force data copying.
+
Returns:
+
number of levels in constructed pyramid. Can be less than maxLevel.
public static int buildOpticalFlowPyramid(Mat img,
+ java.util.List<Mat> pyramid,
+ Size winSize,
+ int maxLevel,
+ boolean withDerivatives,
+ int pyrBorder,
+ int derivBorder,
+ boolean tryReuseInputImage)
+
Constructs the image pyramid which can be passed to calcOpticalFlowPyrLK.
+
+
Parameters:
+
img - 8-bit input image.
+
pyramid - output pyramid.
+
winSize - window size of optical flow algorithm. Must be not less than winSize argument of
+ calcOpticalFlowPyrLK. It is needed to calculate required padding for pyramid levels.
+
maxLevel - 0-based maximal pyramid level number.
+
withDerivatives - set to precompute gradients for the every pyramid level. If pyramid is
+ constructed without the gradients then calcOpticalFlowPyrLK will calculate them internally.
+
pyrBorder - the border mode for pyramid layers.
+
derivBorder - the border mode for gradients.
+
tryReuseInputImage - put ROI of input image into the pyramid if possible. You can pass false
+ to force data copying.
+
Returns:
+
number of levels in constructed pyramid. Can be less than maxLevel.
public static void calcOpticalFlowFarneback(Mat prev,
+ Mat next,
+ Mat flow,
+ double pyr_scale,
+ int levels,
+ int winsize,
+ int iterations,
+ int poly_n,
+ double poly_sigma,
+ int flags)
+
Computes a dense optical flow using the Gunnar Farneback's algorithm.
+
+
Parameters:
+
prev - first 8-bit single-channel input image.
+
next - second input image of the same size and the same type as prev.
+
flow - computed flow image that has the same size as prev and type CV_32FC2.
+
pyr_scale - parameter, specifying the image scale (<1) to build pyramids for each image;
+ pyr_scale=0.5 means a classical pyramid, where each next layer is twice smaller than the previous
+ one.
+
levels - number of pyramid layers including the initial image; levels=1 means that no extra
+ layers are created and only the original images are used.
+
winsize - averaging window size; larger values increase the algorithm robustness to image
+ noise and give more chances for fast motion detection, but yield more blurred motion field.
+
iterations - number of iterations the algorithm does at each pyramid level.
+
poly_n - size of the pixel neighborhood used to find polynomial expansion in each pixel;
+ larger values mean that the image will be approximated with smoother surfaces, yielding more
+ robust algorithm and more blurred motion field, typically poly_n =5 or 7.
+
poly_sigma - standard deviation of the Gaussian that is used to smooth derivatives used as a
+ basis for the polynomial expansion; for poly_n=5, you can set poly_sigma=1.1, for poly_n=7, a
+ good value would be poly_sigma=1.5.
+
flags - operation flags that can be a combination of the following:
+
+
+ OPTFLOW_USE_INITIAL_FLOW uses the input flow as an initial flow approximation.
+
+
+ OPTFLOW_FARNEBACK_GAUSSIAN uses the Gaussian \(\texttt{winsize}\times\texttt{winsize}\)
+ filter instead of a box filter of the same size for optical flow estimation; usually, this
+ option gives z more accurate flow than with a box filter, at the cost of lower speed;
+ normally, winsize for a Gaussian window should be set to a larger value to achieve the same
+ level of robustness.
+
+
+
+ The function finds an optical flow for each prev pixel using the CITE: Farneback2003 algorithm so that
+
+ \(\texttt{prev} (y,x) \sim \texttt{next} ( y + \texttt{flow} (y,x)[1], x + \texttt{flow} (y,x)[0])\)
+
+ Note:
+
+
+
+ An example using the optical flow algorithm described by Gunnar Farneback can be found at
+ opencv_source_code/samples/cpp/fback.cpp
+
+
+ (Python) An example using the optical flow algorithm described by Gunnar Farneback can be
+ found at opencv_source_code/samples/python/opt_flow.py
+
Calculates an optical flow for a sparse feature set using the iterative Lucas-Kanade method with
+ pyramids.
+
+
Parameters:
+
prevImg - first 8-bit input image or pyramid constructed by buildOpticalFlowPyramid.
+
nextImg - second input image or pyramid of the same size and the same type as prevImg.
+
prevPts - vector of 2D points for which the flow needs to be found; point coordinates must be
+ single-precision floating-point numbers.
+
nextPts - output vector of 2D points (with single-precision floating-point coordinates)
+ containing the calculated new positions of input features in the second image; when
+ OPTFLOW_USE_INITIAL_FLOW flag is passed, the vector must have the same size as in the input.
+
status - output status vector (of unsigned chars); each element of the vector is set to 1 if
+ the flow for the corresponding features has been found, otherwise, it is set to 0.
+
err - output vector of errors; each element of the vector is set to an error for the
+ corresponding feature, type of the error measure can be set in flags parameter; if the flow wasn't
+ found then the error is not defined (use the status parameter to find such cases).
+ level), if set to 1, two levels are used, and so on; if pyramids are passed to input then
+ algorithm will use as many levels as pyramids have but no more than maxLevel.
+ (after the specified maximum number of iterations criteria.maxCount or when the search window
+ moves by less than criteria.epsilon.
+
+
+ OPTFLOW_USE_INITIAL_FLOW uses initial estimations, stored in nextPts; if the flag is
+ not set, then prevPts is copied to nextPts and is considered the initial estimate.
+
+
+ OPTFLOW_LK_GET_MIN_EIGENVALS use minimum eigen values as an error measure (see
+ minEigThreshold description); if the flag is not set, then L1 distance between patches
+ around the original and a moved point, divided by number of pixels in a window, is used as a
+ error measure.
+
+
+ optical flow equations (this matrix is called a spatial gradient matrix in CITE: Bouguet00), divided
+ by number of pixels in a window; if this value is less than minEigThreshold, then a corresponding
+ feature is filtered out and its flow is not processed, so it allows to remove bad points and get a
+ performance boost.
+
+ The function implements a sparse iterative version of the Lucas-Kanade optical flow in pyramids. See
+ CITE: Bouguet00 . The function is parallelized with the TBB library.
+
+ Note:
+
+
+
+ An example using the Lucas-Kanade optical flow algorithm can be found at
+ opencv_source_code/samples/cpp/lkdemo.cpp
+
+
+ (Python) An example using the Lucas-Kanade optical flow algorithm can be found at
+ opencv_source_code/samples/python/lk_track.py
+
+
+ (Python) An example using the Lucas-Kanade tracker for homography matching can be found at
+ opencv_source_code/samples/python/lk_homography.py
+
Calculates an optical flow for a sparse feature set using the iterative Lucas-Kanade method with
+ pyramids.
+
+
Parameters:
+
prevImg - first 8-bit input image or pyramid constructed by buildOpticalFlowPyramid.
+
nextImg - second input image or pyramid of the same size and the same type as prevImg.
+
prevPts - vector of 2D points for which the flow needs to be found; point coordinates must be
+ single-precision floating-point numbers.
+
nextPts - output vector of 2D points (with single-precision floating-point coordinates)
+ containing the calculated new positions of input features in the second image; when
+ OPTFLOW_USE_INITIAL_FLOW flag is passed, the vector must have the same size as in the input.
+
status - output status vector (of unsigned chars); each element of the vector is set to 1 if
+ the flow for the corresponding features has been found, otherwise, it is set to 0.
+
err - output vector of errors; each element of the vector is set to an error for the
+ corresponding feature, type of the error measure can be set in flags parameter; if the flow wasn't
+ found then the error is not defined (use the status parameter to find such cases).
+
winSize - size of the search window at each pyramid level.
+ level), if set to 1, two levels are used, and so on; if pyramids are passed to input then
+ algorithm will use as many levels as pyramids have but no more than maxLevel.
+ (after the specified maximum number of iterations criteria.maxCount or when the search window
+ moves by less than criteria.epsilon.
+
+
+ OPTFLOW_USE_INITIAL_FLOW uses initial estimations, stored in nextPts; if the flag is
+ not set, then prevPts is copied to nextPts and is considered the initial estimate.
+
+
+ OPTFLOW_LK_GET_MIN_EIGENVALS use minimum eigen values as an error measure (see
+ minEigThreshold description); if the flag is not set, then L1 distance between patches
+ around the original and a moved point, divided by number of pixels in a window, is used as a
+ error measure.
+
+
+ optical flow equations (this matrix is called a spatial gradient matrix in CITE: Bouguet00), divided
+ by number of pixels in a window; if this value is less than minEigThreshold, then a corresponding
+ feature is filtered out and its flow is not processed, so it allows to remove bad points and get a
+ performance boost.
+
+ The function implements a sparse iterative version of the Lucas-Kanade optical flow in pyramids. See
+ CITE: Bouguet00 . The function is parallelized with the TBB library.
+
+ Note:
+
+
+
+ An example using the Lucas-Kanade optical flow algorithm can be found at
+ opencv_source_code/samples/cpp/lkdemo.cpp
+
+
+ (Python) An example using the Lucas-Kanade optical flow algorithm can be found at
+ opencv_source_code/samples/python/lk_track.py
+
+
+ (Python) An example using the Lucas-Kanade tracker for homography matching can be found at
+ opencv_source_code/samples/python/lk_homography.py
+
Calculates an optical flow for a sparse feature set using the iterative Lucas-Kanade method with
+ pyramids.
+
+
Parameters:
+
prevImg - first 8-bit input image or pyramid constructed by buildOpticalFlowPyramid.
+
nextImg - second input image or pyramid of the same size and the same type as prevImg.
+
prevPts - vector of 2D points for which the flow needs to be found; point coordinates must be
+ single-precision floating-point numbers.
+
nextPts - output vector of 2D points (with single-precision floating-point coordinates)
+ containing the calculated new positions of input features in the second image; when
+ OPTFLOW_USE_INITIAL_FLOW flag is passed, the vector must have the same size as in the input.
+
status - output status vector (of unsigned chars); each element of the vector is set to 1 if
+ the flow for the corresponding features has been found, otherwise, it is set to 0.
+
err - output vector of errors; each element of the vector is set to an error for the
+ corresponding feature, type of the error measure can be set in flags parameter; if the flow wasn't
+ found then the error is not defined (use the status parameter to find such cases).
+
winSize - size of the search window at each pyramid level.
+
maxLevel - 0-based maximal pyramid level number; if set to 0, pyramids are not used (single
+ level), if set to 1, two levels are used, and so on; if pyramids are passed to input then
+ algorithm will use as many levels as pyramids have but no more than maxLevel.
+ (after the specified maximum number of iterations criteria.maxCount or when the search window
+ moves by less than criteria.epsilon.
+
+
+ OPTFLOW_USE_INITIAL_FLOW uses initial estimations, stored in nextPts; if the flag is
+ not set, then prevPts is copied to nextPts and is considered the initial estimate.
+
+
+ OPTFLOW_LK_GET_MIN_EIGENVALS use minimum eigen values as an error measure (see
+ minEigThreshold description); if the flag is not set, then L1 distance between patches
+ around the original and a moved point, divided by number of pixels in a window, is used as a
+ error measure.
+
+
+ optical flow equations (this matrix is called a spatial gradient matrix in CITE: Bouguet00), divided
+ by number of pixels in a window; if this value is less than minEigThreshold, then a corresponding
+ feature is filtered out and its flow is not processed, so it allows to remove bad points and get a
+ performance boost.
+
+ The function implements a sparse iterative version of the Lucas-Kanade optical flow in pyramids. See
+ CITE: Bouguet00 . The function is parallelized with the TBB library.
+
+ Note:
+
+
+
+ An example using the Lucas-Kanade optical flow algorithm can be found at
+ opencv_source_code/samples/cpp/lkdemo.cpp
+
+
+ (Python) An example using the Lucas-Kanade optical flow algorithm can be found at
+ opencv_source_code/samples/python/lk_track.py
+
+
+ (Python) An example using the Lucas-Kanade tracker for homography matching can be found at
+ opencv_source_code/samples/python/lk_homography.py
+
Calculates an optical flow for a sparse feature set using the iterative Lucas-Kanade method with
+ pyramids.
+
+
Parameters:
+
prevImg - first 8-bit input image or pyramid constructed by buildOpticalFlowPyramid.
+
nextImg - second input image or pyramid of the same size and the same type as prevImg.
+
prevPts - vector of 2D points for which the flow needs to be found; point coordinates must be
+ single-precision floating-point numbers.
+
nextPts - output vector of 2D points (with single-precision floating-point coordinates)
+ containing the calculated new positions of input features in the second image; when
+ OPTFLOW_USE_INITIAL_FLOW flag is passed, the vector must have the same size as in the input.
+
status - output status vector (of unsigned chars); each element of the vector is set to 1 if
+ the flow for the corresponding features has been found, otherwise, it is set to 0.
+
err - output vector of errors; each element of the vector is set to an error for the
+ corresponding feature, type of the error measure can be set in flags parameter; if the flow wasn't
+ found then the error is not defined (use the status parameter to find such cases).
+
winSize - size of the search window at each pyramid level.
+
maxLevel - 0-based maximal pyramid level number; if set to 0, pyramids are not used (single
+ level), if set to 1, two levels are used, and so on; if pyramids are passed to input then
+ algorithm will use as many levels as pyramids have but no more than maxLevel.
+
criteria - parameter, specifying the termination criteria of the iterative search algorithm
+ (after the specified maximum number of iterations criteria.maxCount or when the search window
+ moves by less than criteria.epsilon.
+
+
+ OPTFLOW_USE_INITIAL_FLOW uses initial estimations, stored in nextPts; if the flag is
+ not set, then prevPts is copied to nextPts and is considered the initial estimate.
+
+
+ OPTFLOW_LK_GET_MIN_EIGENVALS use minimum eigen values as an error measure (see
+ minEigThreshold description); if the flag is not set, then L1 distance between patches
+ around the original and a moved point, divided by number of pixels in a window, is used as a
+ error measure.
+
+
+ optical flow equations (this matrix is called a spatial gradient matrix in CITE: Bouguet00), divided
+ by number of pixels in a window; if this value is less than minEigThreshold, then a corresponding
+ feature is filtered out and its flow is not processed, so it allows to remove bad points and get a
+ performance boost.
+
+ The function implements a sparse iterative version of the Lucas-Kanade optical flow in pyramids. See
+ CITE: Bouguet00 . The function is parallelized with the TBB library.
+
+ Note:
+
+
+
+ An example using the Lucas-Kanade optical flow algorithm can be found at
+ opencv_source_code/samples/cpp/lkdemo.cpp
+
+
+ (Python) An example using the Lucas-Kanade optical flow algorithm can be found at
+ opencv_source_code/samples/python/lk_track.py
+
+
+ (Python) An example using the Lucas-Kanade tracker for homography matching can be found at
+ opencv_source_code/samples/python/lk_homography.py
+
Calculates an optical flow for a sparse feature set using the iterative Lucas-Kanade method with
+ pyramids.
+
+
Parameters:
+
prevImg - first 8-bit input image or pyramid constructed by buildOpticalFlowPyramid.
+
nextImg - second input image or pyramid of the same size and the same type as prevImg.
+
prevPts - vector of 2D points for which the flow needs to be found; point coordinates must be
+ single-precision floating-point numbers.
+
nextPts - output vector of 2D points (with single-precision floating-point coordinates)
+ containing the calculated new positions of input features in the second image; when
+ OPTFLOW_USE_INITIAL_FLOW flag is passed, the vector must have the same size as in the input.
+
status - output status vector (of unsigned chars); each element of the vector is set to 1 if
+ the flow for the corresponding features has been found, otherwise, it is set to 0.
+
err - output vector of errors; each element of the vector is set to an error for the
+ corresponding feature, type of the error measure can be set in flags parameter; if the flow wasn't
+ found then the error is not defined (use the status parameter to find such cases).
+
winSize - size of the search window at each pyramid level.
+
maxLevel - 0-based maximal pyramid level number; if set to 0, pyramids are not used (single
+ level), if set to 1, two levels are used, and so on; if pyramids are passed to input then
+ algorithm will use as many levels as pyramids have but no more than maxLevel.
+
criteria - parameter, specifying the termination criteria of the iterative search algorithm
+ (after the specified maximum number of iterations criteria.maxCount or when the search window
+ moves by less than criteria.epsilon.
+
flags - operation flags:
+
+
+ OPTFLOW_USE_INITIAL_FLOW uses initial estimations, stored in nextPts; if the flag is
+ not set, then prevPts is copied to nextPts and is considered the initial estimate.
+
+
+ OPTFLOW_LK_GET_MIN_EIGENVALS use minimum eigen values as an error measure (see
+ minEigThreshold description); if the flag is not set, then L1 distance between patches
+ around the original and a moved point, divided by number of pixels in a window, is used as a
+ error measure.
+
+
+ optical flow equations (this matrix is called a spatial gradient matrix in CITE: Bouguet00), divided
+ by number of pixels in a window; if this value is less than minEigThreshold, then a corresponding
+ feature is filtered out and its flow is not processed, so it allows to remove bad points and get a
+ performance boost.
+
+ The function implements a sparse iterative version of the Lucas-Kanade optical flow in pyramids. See
+ CITE: Bouguet00 . The function is parallelized with the TBB library.
+
+ Note:
+
+
+
+ An example using the Lucas-Kanade optical flow algorithm can be found at
+ opencv_source_code/samples/cpp/lkdemo.cpp
+
+
+ (Python) An example using the Lucas-Kanade optical flow algorithm can be found at
+ opencv_source_code/samples/python/lk_track.py
+
+
+ (Python) An example using the Lucas-Kanade tracker for homography matching can be found at
+ opencv_source_code/samples/python/lk_homography.py
+
Calculates an optical flow for a sparse feature set using the iterative Lucas-Kanade method with
+ pyramids.
+
+
Parameters:
+
prevImg - first 8-bit input image or pyramid constructed by buildOpticalFlowPyramid.
+
nextImg - second input image or pyramid of the same size and the same type as prevImg.
+
prevPts - vector of 2D points for which the flow needs to be found; point coordinates must be
+ single-precision floating-point numbers.
+
nextPts - output vector of 2D points (with single-precision floating-point coordinates)
+ containing the calculated new positions of input features in the second image; when
+ OPTFLOW_USE_INITIAL_FLOW flag is passed, the vector must have the same size as in the input.
+
status - output status vector (of unsigned chars); each element of the vector is set to 1 if
+ the flow for the corresponding features has been found, otherwise, it is set to 0.
+
err - output vector of errors; each element of the vector is set to an error for the
+ corresponding feature, type of the error measure can be set in flags parameter; if the flow wasn't
+ found then the error is not defined (use the status parameter to find such cases).
+
winSize - size of the search window at each pyramid level.
+
maxLevel - 0-based maximal pyramid level number; if set to 0, pyramids are not used (single
+ level), if set to 1, two levels are used, and so on; if pyramids are passed to input then
+ algorithm will use as many levels as pyramids have but no more than maxLevel.
+
criteria - parameter, specifying the termination criteria of the iterative search algorithm
+ (after the specified maximum number of iterations criteria.maxCount or when the search window
+ moves by less than criteria.epsilon.
+
flags - operation flags:
+
+
+ OPTFLOW_USE_INITIAL_FLOW uses initial estimations, stored in nextPts; if the flag is
+ not set, then prevPts is copied to nextPts and is considered the initial estimate.
+
+
+ OPTFLOW_LK_GET_MIN_EIGENVALS use minimum eigen values as an error measure (see
+ minEigThreshold description); if the flag is not set, then L1 distance between patches
+ around the original and a moved point, divided by number of pixels in a window, is used as a
+ error measure.
+
+
+
minEigThreshold - the algorithm calculates the minimum eigen value of a 2x2 normal matrix of
+ optical flow equations (this matrix is called a spatial gradient matrix in CITE: Bouguet00), divided
+ by number of pixels in a window; if this value is less than minEigThreshold, then a corresponding
+ feature is filtered out and its flow is not processed, so it allows to remove bad points and get a
+ performance boost.
+
+ The function implements a sparse iterative version of the Lucas-Kanade optical flow in pyramids. See
+ CITE: Bouguet00 . The function is parallelized with the TBB library.
+
+ Note:
+
+
+
+ An example using the Lucas-Kanade optical flow algorithm can be found at
+ opencv_source_code/samples/cpp/lkdemo.cpp
+
+
+ (Python) An example using the Lucas-Kanade optical flow algorithm can be found at
+ opencv_source_code/samples/python/lk_track.py
+
+
+ (Python) An example using the Lucas-Kanade tracker for homography matching can be found at
+ opencv_source_code/samples/python/lk_homography.py
+
probImage - Back projection of the object histogram. See calcBackProject.
+
window - Initial search window.
+
criteria - Stop criteria for the underlying meanShift.
+ returns
+ (in old interfaces) Number of iterations CAMSHIFT took to converge
+ The function implements the CAMSHIFT object tracking algorithm CITE: Bradski98 . First, it finds an
+ object center using meanShift and then adjusts the window size and finds the optimal rotation. The
+ function returns the rotated rectangle structure that includes the object position, size, and
+ orientation. The next position of the search window can be obtained with RotatedRect::boundingRect()
+
+ See the OpenCV sample camshiftdemo.c that tracks colored objects.
+
+ Note:
+
+
+ (Python) A sample explaining the camshift tracking algorithm can be found at
+ opencv_source_code/samples/python/camshift.py
+
public static double computeECC(Mat templateImage,
+ Mat inputImage)
+
Computes the Enhanced Correlation Coefficient value between two images CITE: EP08 .
+
+
Parameters:
+
templateImage - single-channel template image; CV_8U or CV_32F array.
+
inputImage - single-channel input image to be warped to provide an image similar to
+ templateImage, same type as templateImage.
+
+ SEE:
+ findTransformECC
Creates KNN Background Subtractor
+
+ whether a pixel is close to that sample. This parameter does not affect the background update.
+ speed a bit, so if you do not need this feature, set the parameter to false.
history - Length of the history.
+ whether a pixel is close to that sample. This parameter does not affect the background update.
+ speed a bit, so if you do not need this feature, set the parameter to false.
public static BackgroundSubtractorKNN createBackgroundSubtractorKNN(int history,
+ double dist2Threshold)
+
Creates KNN Background Subtractor
+
+
Parameters:
+
history - Length of the history.
+
dist2Threshold - Threshold on the squared distance between the pixel and the sample to decide
+ whether a pixel is close to that sample. This parameter does not affect the background update.
+ speed a bit, so if you do not need this feature, set the parameter to false.
dist2Threshold - Threshold on the squared distance between the pixel and the sample to decide
+ whether a pixel is close to that sample. This parameter does not affect the background update.
+
detectShadows - If true, the algorithm will detect shadows and mark them. It decreases the
+ speed a bit, so if you do not need this feature, set the parameter to false.
Creates MOG2 Background Subtractor
+
+ to decide whether a pixel is well described by the background model. This parameter does not
+ affect the background update.
+ speed a bit, so if you do not need this feature, set the parameter to false.
history - Length of the history.
+ to decide whether a pixel is well described by the background model. This parameter does not
+ affect the background update.
+ speed a bit, so if you do not need this feature, set the parameter to false.
public static BackgroundSubtractorMOG2 createBackgroundSubtractorMOG2(int history,
+ double varThreshold)
+
Creates MOG2 Background Subtractor
+
+
Parameters:
+
history - Length of the history.
+
varThreshold - Threshold on the squared Mahalanobis distance between the pixel and the model
+ to decide whether a pixel is well described by the background model. This parameter does not
+ affect the background update.
+ speed a bit, so if you do not need this feature, set the parameter to false.
varThreshold - Threshold on the squared Mahalanobis distance between the pixel and the model
+ to decide whether a pixel is well described by the background model. This parameter does not
+ affect the background update.
+
detectShadows - If true, the algorithm will detect shadows and mark them. It decreases the
+ speed a bit, so if you do not need this feature, set the parameter to false.
public static double findTransformECC(Mat templateImage,
+ Mat inputImage,
+ Mat warpMatrix,
+ int motionType,
+ TermCriteria criteria,
+ Mat inputMask)
public static double findTransformECC(Mat templateImage,
+ Mat inputImage,
+ Mat warpMatrix,
+ int motionType,
+ TermCriteria criteria,
+ Mat inputMask,
+ int gaussFiltSize)
+
Finds the geometric transform (warp) between two images in terms of the ECC criterion CITE: EP08 .
+
+
Parameters:
+
templateImage - single-channel template image; CV_8U or CV_32F array.
+
inputImage - single-channel input image which should be warped with the final warpMatrix in
+ order to provide an image similar to templateImage, same type as templateImage.
motionType - parameter, specifying the type of motion:
+
+
+ MOTION_TRANSLATION sets a translational motion model; warpMatrix is \(2\times 3\) with
+ the first \(2\times 2\) part being the unity matrix and the rest two parameters being
+ estimated.
+
+
+ MOTION_EUCLIDEAN sets a Euclidean (rigid) transformation as motion model; three
+ parameters are estimated; warpMatrix is \(2\times 3\).
+
+
+ MOTION_AFFINE sets an affine motion model (DEFAULT); six parameters are estimated;
+ warpMatrix is \(2\times 3\).
+
+
+ MOTION_HOMOGRAPHY sets a homography as a motion model; eight parameters are
+ estimated;\warpMatrix\ is \(3\times 3\).
+
+
+
criteria - parameter, specifying the termination criteria of the ECC algorithm;
+ criteria.epsilon defines the threshold of the increment in the correlation coefficient between two
+ iterations (a negative criteria.epsilon makes criteria.maxcount the only termination criterion).
+ Default values are shown in the declaration above.
+
inputMask - An optional mask to indicate valid values of inputImage.
+
gaussFiltSize - An optional value indicating size of gaussian blur filter; (DEFAULT: 5)
+
+ The function estimates the optimum transformation (warpMatrix) with respect to ECC criterion
+ (CITE: EP08), that is
+
+ \(\texttt{warpMatrix} = \arg\max_{W} \texttt{ECC}(\texttt{templateImage}(x,y),\texttt{inputImage}(x',y'))\)
+
+ where
+
+ \(\begin{bmatrix} x' \\ y' \end{bmatrix} = W \cdot \begin{bmatrix} x \\ y \\ 1 \end{bmatrix}\)
+
+ (the equation holds with homogeneous coordinates for homography). It returns the final enhanced
+ correlation coefficient, that is the correlation coefficient between the template image and the
+ final warped input image. When a \(3\times 3\) matrix is given with motionType =0, 1 or 2, the third
+ row is ignored.
+
+ Unlike findHomography and estimateRigidTransform, the function findTransformECC implements an
+ area-based alignment that builds on intensity similarities. In essence, the function updates the
+ initial transformation that roughly aligns the images. If this information is missing, the identity
+ warp (unity matrix) is used as an initialization. Note that if images undergo strong
+ displacements/rotations, an initial transformation that roughly aligns the images is necessary
+ (e.g., a simple euclidean/similarity transform that allows for the images showing the same image
+ content approximately). Use inverse warping in the second image to take an image close to the first
+ one, i.e. use the flag WARP_INVERSE_MAP with warpAffine or warpPerspective. See also the OpenCV
+ sample image_alignment.cpp that demonstrates the use of the function. Note that the function throws
+ an exception if algorithm does not converges.
+
+ SEE:
+ computeECC, estimateAffine2D, estimateAffinePartial2D, findHomography
public static int meanShift(Mat probImage,
+ Rect window,
+ TermCriteria criteria)
+
Finds an object on a back projection image.
+
+
Parameters:
+
probImage - Back projection of the object histogram. See calcBackProject for details.
+
window - Initial search window.
+
criteria - Stop criteria for the iterative search algorithm.
+ returns
+ : Number of iterations CAMSHIFT took to converge.
+ The function implements the iterative object search algorithm. It takes the input back projection of
+ an object and the initial position. The mass center in window of the back projection image is
+ computed and the search window center shifts to the mass center. The procedure is repeated until the
+ specified number of iterations criteria.maxCount is done or until the window center shifts by less
+ than criteria.epsilon. The algorithm is used inside CamShift and, unlike CamShift , the search
+ window size or orientation do not change during the search. You can simply pass the output of
+ calcBackProject to this function. But better results can be obtained if you pre-filter the back
+ projection and remove the noise. For example, you can do this by retrieving connected components
+ with findContours , throwing away contours with small area ( contourArea ), and rendering the
+ remaining contours with drawContours.
public static Mat readOpticalFlow(java.lang.String path)
+
Read a .flo file
+
+
Parameters:
+
path - Path to the file to be loaded
+
+ The function readOpticalFlow loads a flow field from a file and returns it as a single matrix.
+ Resulting Mat has a type CV_32FC2 - floating-point, 2-channel. First channel corresponds to the
+ flow in the horizontal direction (u), second - vertical (v).
public static boolean writeOpticalFlow(java.lang.String path,
+ Mat flow)
+
Write a .flo to disk
+
+
Parameters:
+
path - Path to the file to be written
+
flow - Flow field to be stored
+
+ The function stores a flow field in a file, returns true on success, false otherwise.
+ The flow field must be a 2-channel, floating-point matrix (CV_32FC2). First channel corresponds
+ to the flow in the horizontal direction (u), second - vertical (v).
the GOTURN (Generic Object Tracking Using Regression Networks) tracker
+
+ GOTURN (CITE: GOTURN) is kind of trackers based on Convolutional Neural Networks (CNN).
public class VideoCapture
+extends java.lang.Object
+
Class for video capturing from video files, image sequences or cameras.
+
+ The class provides C++ API for capturing video from cameras or for reading video files and image sequences.
+
+ Here is how the class can be used:
+ INCLUDE: samples/cpp/videocapture_basic.cpp
+
+ Note: In REF: videoio_c "C API" the black-box structure CvCapture is used instead of %VideoCapture.
+ Note:
+
+
+ (C++) A basic sample on using the %VideoCapture interface can be found at
+ OPENCV_SOURCE_CODE/samples/cpp/videocapture_starter.cpp
+
+
+ (Python) A basic sample on using the %VideoCapture interface can be found at
+ OPENCV_SOURCE_CODE/samples/python/video.py
+
+
+ (Python) A multi threaded video processing sample can be found at
+ OPENCV_SOURCE_CODE/samples/python/video_threaded.py
+
+
+ (Python) %VideoCapture sample showcasing some features of the Video4Linux2 backend
+ OPENCV_SOURCE_CODE/samples/python/video_v4l2.py
+
Default constructor
+ Note: In REF: videoio_c "C API", when you finished working with video, release CvCapture structure with
+ cvReleaseCapture(), or use Ptr<CvCapture> that calls cvReleaseCapture() automatically in the
+ destructor.
Opens a camera for video capturing with API Preference and parameters
+
+ The params parameter allows to specify extra parameters encoded as pairs (paramId_1, paramValue_1, paramId_2, paramValue_2, ...).
Opens a video file or a capturing device or an IP video stream for video capturing with API Preference
+
+
+
+
VideoCapture(java.lang.String filename,
+ int apiPreference)
+
Opens a video file or a capturing device or an IP video stream for video capturing with API Preference
+
+
+
+
VideoCapture(java.lang.String filename,
+ int apiPreference,
+ MatOfInt params)
+
Opens a video file or a capturing device or an IP video stream for video capturing with API Preference and parameters
+
+ The params parameter allows to specify extra parameters encoded as pairs (paramId_1, paramValue_1, paramId_2, paramValue_2, ...).
Opens a camera for video capturing
+
+
+
+ Parameters are same as the constructor VideoCapture(int index, int apiPreference = CAP_ANY)
+
+
+
+
boolean
+
open(int index,
+ int apiPreference,
+ MatOfInt params)
+
Opens a camera for video capturing with API Preference and parameters
+
+
+
+ The params parameter allows to specify extra parameters encoded as pairs (paramId_1, paramValue_1, paramId_2, paramValue_2, ...).
Opens a video file or a capturing device or an IP video stream for video capturing.
+
+
+
+
boolean
+
open(java.lang.String filename,
+ int apiPreference)
+
Opens a video file or a capturing device or an IP video stream for video capturing.
+
+
+
+
boolean
+
open(java.lang.String filename,
+ int apiPreference,
+ MatOfInt params)
+
Opens a video file or a capturing device or an IP video stream for video capturing with API Preference and parameters
+
+
+
+ The params parameter allows to specify extra parameters encoded as pairs (paramId_1, paramValue_1, paramId_2, paramValue_2, ...).
Default constructor
+ Note: In REF: videoio_c "C API", when you finished working with video, release CvCapture structure with
+ cvReleaseCapture(), or use Ptr<CvCapture> that calls cvReleaseCapture() automatically in the
+ destructor.
index - id of the video capturing device to open. To open default camera using default backend just pass 0.
+ (to backward compatibility usage of camera_id + domain_offset (CAP_*) is valid when apiPreference is CAP_ANY)
+ implementation if multiple are available: e.g. cv::CAP_DSHOW or cv::CAP_MSMF or cv::CAP_V4L.
+
+ SEE: cv::VideoCaptureAPIs
public VideoCapture(int index,
+ int apiPreference)
+
Opens a camera for video capturing
+
+
Parameters:
+
index - id of the video capturing device to open. To open default camera using default backend just pass 0.
+ (to backward compatibility usage of camera_id + domain_offset (CAP_*) is valid when apiPreference is CAP_ANY)
+
apiPreference - preferred Capture API backends to use. Can be used to enforce a specific reader
+ implementation if multiple are available: e.g. cv::CAP_DSHOW or cv::CAP_MSMF or cv::CAP_V4L.
+
+ SEE: cv::VideoCaptureAPIs
public VideoCapture(int index,
+ int apiPreference,
+ MatOfInt params)
+
Opens a camera for video capturing with API Preference and parameters
+
+ The params parameter allows to specify extra parameters encoded as pairs (paramId_1, paramValue_1, paramId_2, paramValue_2, ...).
+ See cv::VideoCaptureProperties
Opens a video file or a capturing device or an IP video stream for video capturing with API Preference
+
+
Parameters:
+
filename - it can be:
+
+
+ name of video file (eg. video.avi)
+
+
+ or image sequence (eg. img_%02d.jpg, which will read samples like img_00.jpg, img_01.jpg, img_02.jpg, ...)
+
+
+ or URL of video stream (eg. protocol://host:port/script_name?script_params|auth)
+
+
+ or GStreamer pipeline string in gst-launch tool format in case if GStreamer is used as backend
+ Note that each video stream or IP camera feed has its own URL scheme. Please refer to the
+ documentation of source stream to know the right URL.
+
+
+ implementation if multiple are available: e.g. cv::CAP_FFMPEG or cv::CAP_IMAGES or cv::CAP_DSHOW.
+
+ SEE: cv::VideoCaptureAPIs
public VideoCapture(java.lang.String filename,
+ int apiPreference)
+
Opens a video file or a capturing device or an IP video stream for video capturing with API Preference
+
+
Parameters:
+
filename - it can be:
+
+
+ name of video file (eg. video.avi)
+
+
+ or image sequence (eg. img_%02d.jpg, which will read samples like img_00.jpg, img_01.jpg, img_02.jpg, ...)
+
+
+ or URL of video stream (eg. protocol://host:port/script_name?script_params|auth)
+
+
+ or GStreamer pipeline string in gst-launch tool format in case if GStreamer is used as backend
+ Note that each video stream or IP camera feed has its own URL scheme. Please refer to the
+ documentation of source stream to know the right URL.
+
+
+
apiPreference - preferred Capture API backends to use. Can be used to enforce a specific reader
+ implementation if multiple are available: e.g. cv::CAP_FFMPEG or cv::CAP_IMAGES or cv::CAP_DSHOW.
+
+ SEE: cv::VideoCaptureAPIs
public VideoCapture(java.lang.String filename,
+ int apiPreference,
+ MatOfInt params)
+
Opens a video file or a capturing device or an IP video stream for video capturing with API Preference and parameters
+
+ The params parameter allows to specify extra parameters encoded as pairs (paramId_1, paramValue_1, paramId_2, paramValue_2, ...).
+ See cv::VideoCaptureProperties
propId - Property identifier from cv::VideoCaptureProperties (eg. cv::CAP_PROP_POS_MSEC, cv::CAP_PROP_POS_FRAMES, ...)
+ or one from REF: videoio_flags_others
+
Returns:
+
Value for the specified property. Value 0 is returned when querying a property that is
+ not supported by the backend used by the VideoCapture instance.
+
+ Note: Reading / writing properties involves many layers. Some unexpected result might happens
+ along this chain.
+
+ VideoCapture -> API Backend -> Operating System -> Device Driver -> Device Hardware
+
+ The returned value might be different from what really used by the device or it could be encoded
+ using device dependent rules (eg. steps or percentage). Effective behaviour depends from device
+ driver and API Backend
Grabs the next frame from video file or capturing device.
+
+
Returns:
+
true (non-zero) in the case of success.
+
+ The method/function grabs the next frame from video file or camera and returns true (non-zero) in
+ the case of success.
+
+ The primary use of the function is in multi-camera environments, especially when the cameras do not
+ have hardware synchronization. That is, you call VideoCapture::grab() for each camera and after that
+ call the slower method VideoCapture::retrieve() to decode and get frame from each camera. This way
+ the overhead on demosaicing or motion jpeg decompression etc. is eliminated and the retrieved frames
+ from different cameras will be closer in time.
+
+ Also, when a connected camera is multi-head (for example, a stereo camera or a Kinect device), the
+ correct way of retrieving data from it is to call VideoCapture::grab() first and then call
+ VideoCapture::retrieve() one or more times with different values of the channel parameter.
+
+ REF: tutorial_kinect_openni
Returns true if video capturing has been initialized already.
+
+ If the previous call to VideoCapture constructor or VideoCapture::open() succeeded, the method returns
+ true.
public boolean open(int index,
+ int apiPreference,
+ MatOfInt params)
+
Opens a camera for video capturing with API Preference and parameters
+
+
+
+ The params parameter allows to specify extra parameters encoded as pairs (paramId_1, paramValue_1, paramId_2, paramValue_2, ...).
+ See cv::VideoCaptureProperties
+
+
Parameters:
+
index - automatically generated
+
apiPreference - automatically generated
+
params - automatically generated
+
Returns:
+
true if the camera has been successfully opened.
+
+ The method first calls VideoCapture::release to close the already opened file or camera.
Opens a video file or a capturing device or an IP video stream for video capturing.
+
+
+
+ Parameters are same as the constructor VideoCapture(const String& filename, int apiPreference = CAP_ANY)
+
+
Parameters:
+
filename - automatically generated
+
Returns:
+
true if the file has been successfully opened
+
+ The method first calls VideoCapture::release to close the already opened file or camera.
public boolean open(java.lang.String filename,
+ int apiPreference)
+
Opens a video file or a capturing device or an IP video stream for video capturing.
+
+
+
+ Parameters are same as the constructor VideoCapture(const String& filename, int apiPreference = CAP_ANY)
+
+
Parameters:
+
filename - automatically generated
+
apiPreference - automatically generated
+
Returns:
+
true if the file has been successfully opened
+
+ The method first calls VideoCapture::release to close the already opened file or camera.
public boolean open(java.lang.String filename,
+ int apiPreference,
+ MatOfInt params)
+
Opens a video file or a capturing device or an IP video stream for video capturing with API Preference and parameters
+
+
+
+ The params parameter allows to specify extra parameters encoded as pairs (paramId_1, paramValue_1, paramId_2, paramValue_2, ...).
+ See cv::VideoCaptureProperties
+
+
Parameters:
+
filename - automatically generated
+
apiPreference - automatically generated
+
params - automatically generated
+
Returns:
+
true if the file has been successfully opened
+
+ The method first calls VideoCapture::release to close the already opened file or camera.
false if no frames has been grabbed
+
+ The method/function combines VideoCapture::grab() and VideoCapture::retrieve() in one call. This is the
+ most convenient method for reading video files or capturing data from decode and returns the just
+ grabbed frame. If no frames has been grabbed (camera has been disconnected, or there are no more
+ frames in video file), the method returns false and the function returns empty image (with %cv::Mat, test it with Mat::empty()).
+
+ Note: In REF: videoio_c "C API", functions cvRetrieveFrame() and cv.RetrieveFrame() return image stored inside the video
+ capturing structure. It is not allowed to modify or release the image! You can copy the frame using
+ cvCloneImage and then do whatever you want with the copy.
Closes video file or capturing device.
+
+ The method is automatically called by subsequent VideoCapture::open and by VideoCapture
+ destructor.
+
+ The C function also deallocates memory and clears \*capture pointer.
false if no frames has been grabbed
+
+ The method decodes and returns the just grabbed frame. If no frames has been grabbed
+ (camera has been disconnected, or there are no more frames in video file), the method returns false
+ and the function returns an empty image (with %cv::Mat, test it with Mat::empty()).
+
+ SEE: read()
+
+ Note: In REF: videoio_c "C API", functions cvRetrieveFrame() and cv.RetrieveFrame() return image stored inside the video
+ capturing structure. It is not allowed to modify or release the image! You can copy the frame using
+ cvCloneImage and then do whatever you want with the copy.
flag - it could be a frame index or a driver specific flag
+
image - automatically generated
+
Returns:
+
false if no frames has been grabbed
+
+ The method decodes and returns the just grabbed frame. If no frames has been grabbed
+ (camera has been disconnected, or there are no more frames in video file), the method returns false
+ and the function returns an empty image (with %cv::Mat, test it with Mat::empty()).
+
+ SEE: read()
+
+ Note: In REF: videoio_c "C API", functions cvRetrieveFrame() and cv.RetrieveFrame() return image stored inside the video
+ capturing structure. It is not allowed to modify or release the image! You can copy the frame using
+ cvCloneImage and then do whatever you want with the copy.
propId - Property identifier from cv::VideoCaptureProperties (eg. cv::CAP_PROP_POS_MSEC, cv::CAP_PROP_POS_FRAMES, ...)
+ or one from REF: videoio_flags_others
+
value - Value of the property.
+
Returns:
+
true if the property is supported by backend used by the VideoCapture instance.
+ Note: Even if it returns true this doesn't ensure that the property
+ value has been accepted by the capture device. See note in VideoCapture::get()
public VideoWriter(java.lang.String filename,
+ int fourcc,
+ double fps,
+ Size frameSize)
+
+
Parameters:
+
filename - Name of the output video file.
+
fourcc - 4-character code of codec used to compress the frames. For example,
+ VideoWriter::fourcc('P','I','M','1') is a MPEG-1 codec, VideoWriter::fourcc('M','J','P','G')
+ is a motion-jpeg codec etc. List of codes can be obtained at
+ [MSDN](https://docs.microsoft.com/en-us/windows/win32/medfound/video-fourccs) page
+ or with this [archived page](https://web.archive.org/web/20220316062600/http://www.fourcc.org/codecs.php)
+ of the fourcc site for a more complete list). FFMPEG backend with MP4 container natively uses
+ other values as fourcc code: see [ObjectType](http://mp4ra.org/#/codecs),
+ so you may receive a warning message from OpenCV about fourcc code conversion.
+
fps - Framerate of the created video stream.
+
frameSize - Size of the video frames.
+ will work with grayscale frames.
+
+ Tips:
+
+
+ With some backends fourcc=-1 pops up the codec selection dialog from the system.
+
+
+ To save image sequence use a proper filename (eg. img_%02d.jpg) and fourcc=0
+ OR fps=0. Use uncompressed image format (eg. img_%02d.BMP) to save raw frames.
+
+
+ Most codecs are lossy. If you want lossless video file you need to use a lossless codecs
+ (eg. FFMPEG FFV1, Huffman HFYU, Lagarith LAGS, etc...)
+
+
+ If FFMPEG is enabled, using codec=0; fps=0; you can create an uncompressed (raw) video file.
+
public VideoWriter(java.lang.String filename,
+ int fourcc,
+ double fps,
+ Size frameSize,
+ boolean isColor)
+
+
Parameters:
+
filename - Name of the output video file.
+
fourcc - 4-character code of codec used to compress the frames. For example,
+ VideoWriter::fourcc('P','I','M','1') is a MPEG-1 codec, VideoWriter::fourcc('M','J','P','G')
+ is a motion-jpeg codec etc. List of codes can be obtained at
+ [MSDN](https://docs.microsoft.com/en-us/windows/win32/medfound/video-fourccs) page
+ or with this [archived page](https://web.archive.org/web/20220316062600/http://www.fourcc.org/codecs.php)
+ of the fourcc site for a more complete list). FFMPEG backend with MP4 container natively uses
+ other values as fourcc code: see [ObjectType](http://mp4ra.org/#/codecs),
+ so you may receive a warning message from OpenCV about fourcc code conversion.
+
fps - Framerate of the created video stream.
+
frameSize - Size of the video frames.
+
isColor - If it is not zero, the encoder will expect and encode color frames, otherwise it
+ will work with grayscale frames.
+
+ Tips:
+
+
+ With some backends fourcc=-1 pops up the codec selection dialog from the system.
+
+
+ To save image sequence use a proper filename (eg. img_%02d.jpg) and fourcc=0
+ OR fps=0. Use uncompressed image format (eg. img_%02d.BMP) to save raw frames.
+
+
+ Most codecs are lossy. If you want lossless video file you need to use a lossless codecs
+ (eg. FFMPEG FFV1, Huffman HFYU, Lagarith LAGS, etc...)
+
+
+ If FFMPEG is enabled, using codec=0; fps=0; you can create an uncompressed (raw) video file.
+
public VideoWriter(java.lang.String filename,
+ int fourcc,
+ double fps,
+ Size frameSize,
+ MatOfInt params)
+
The params parameter allows to specify extra encoder parameters encoded as pairs (paramId_1, paramValue_1, paramId_2, paramValue_2, ... .)
+ see cv::VideoWriterProperties
public VideoWriter(java.lang.String filename,
+ int apiPreference,
+ int fourcc,
+ double fps,
+ Size frameSize)
+
The apiPreference parameter allows to specify API backends to use. Can be used to enforce a specific reader implementation
+ if multiple are available: e.g. cv::CAP_FFMPEG or cv::CAP_GSTREAMER.
public VideoWriter(java.lang.String filename,
+ int apiPreference,
+ int fourcc,
+ double fps,
+ Size frameSize,
+ boolean isColor)
+
The apiPreference parameter allows to specify API backends to use. Can be used to enforce a specific reader implementation
+ if multiple are available: e.g. cv::CAP_FFMPEG or cv::CAP_GSTREAMER.
public static int fourcc(char c1,
+ char c2,
+ char c3,
+ char c4)
+
Concatenates 4 chars to a fourcc code
+
+
Parameters:
+
c1 - automatically generated
+
c2 - automatically generated
+
c3 - automatically generated
+
c4 - automatically generated
+
Returns:
+
a fourcc code
+
+ This static method constructs the fourcc code of the codec to be used in the constructor
+ VideoWriter::VideoWriter or VideoWriter::open.
propId - Property identifier from cv::VideoWriterProperties (eg. cv::VIDEOWRITER_PROP_QUALITY)
+ or one of REF: videoio_flags_others
+
Returns:
+
Value for the specified property. Value 0 is returned when querying a property that is
+ not supported by the backend used by the VideoWriter instance.
public boolean open(java.lang.String filename,
+ int fourcc,
+ double fps,
+ Size frameSize)
+
Initializes or reinitializes video writer.
+
+ The method opens video writer. Parameters are the same as in the constructor
+ VideoWriter::VideoWriter.
+
+
Parameters:
+
filename - automatically generated
+
fourcc - automatically generated
+
fps - automatically generated
+
frameSize - automatically generated
+
Returns:
+
true if video writer has been successfully initialized
+
+ The method first calls VideoWriter::release to close the already opened file.
public boolean open(java.lang.String filename,
+ int fourcc,
+ double fps,
+ Size frameSize,
+ boolean isColor)
+
Initializes or reinitializes video writer.
+
+ The method opens video writer. Parameters are the same as in the constructor
+ VideoWriter::VideoWriter.
+
+
Parameters:
+
filename - automatically generated
+
fourcc - automatically generated
+
fps - automatically generated
+
frameSize - automatically generated
+
isColor - automatically generated
+
Returns:
+
true if video writer has been successfully initialized
+
+ The method first calls VideoWriter::release to close the already opened file.
image - The written frame. In general, color images are expected in BGR format.
+
+ The function/method writes the specified image to video file. It must have the same size as has
+ been specified when opening the video writer.
+
+
diff --git a/ZPI-App/opencv/java/javadoc/stylesheet.css b/ZPI-App/opencv/java/javadoc/stylesheet.css
new file mode 100644
index 000000000..98055b22d
--- /dev/null
+++ b/ZPI-App/opencv/java/javadoc/stylesheet.css
@@ -0,0 +1,574 @@
+/* Javadoc style sheet */
+/*
+Overall document style
+*/
+
+@import url('resources/fonts/dejavu.css');
+
+body {
+ background-color:#ffffff;
+ color:#353833;
+ font-family:'DejaVu Sans', Arial, Helvetica, sans-serif;
+ font-size:14px;
+ margin:0;
+}
+a:link, a:visited {
+ text-decoration:none;
+ color:#4A6782;
+}
+a:hover, a:focus {
+ text-decoration:none;
+ color:#bb7a2a;
+}
+a:active {
+ text-decoration:none;
+ color:#4A6782;
+}
+a[name] {
+ color:#353833;
+}
+a[name]:hover {
+ text-decoration:none;
+ color:#353833;
+}
+pre {
+ font-family:'DejaVu Sans Mono', monospace;
+ font-size:14px;
+}
+h1 {
+ font-size:20px;
+}
+h2 {
+ font-size:18px;
+}
+h3 {
+ font-size:16px;
+ font-style:italic;
+}
+h4 {
+ font-size:13px;
+}
+h5 {
+ font-size:12px;
+}
+h6 {
+ font-size:11px;
+}
+ul {
+ list-style-type:disc;
+}
+code, tt {
+ font-family:'DejaVu Sans Mono', monospace;
+ font-size:14px;
+ padding-top:4px;
+ margin-top:8px;
+ line-height:1.4em;
+}
+dt code {
+ font-family:'DejaVu Sans Mono', monospace;
+ font-size:14px;
+ padding-top:4px;
+}
+table tr td dt code {
+ font-family:'DejaVu Sans Mono', monospace;
+ font-size:14px;
+ vertical-align:top;
+ padding-top:4px;
+}
+sup {
+ font-size:8px;
+}
+/*
+Document title and Copyright styles
+*/
+.clear {
+ clear:both;
+ height:0px;
+ overflow:hidden;
+}
+.aboutLanguage {
+ float:right;
+ padding:0px 21px;
+ font-size:11px;
+ z-index:200;
+ margin-top:-9px;
+}
+.legalCopy {
+ margin-left:.5em;
+}
+.bar a, .bar a:link, .bar a:visited, .bar a:active {
+ color:#FFFFFF;
+ text-decoration:none;
+}
+.bar a:hover, .bar a:focus {
+ color:#bb7a2a;
+}
+.tab {
+ background-color:#0066FF;
+ color:#ffffff;
+ padding:8px;
+ width:5em;
+ font-weight:bold;
+}
+/*
+Navigation bar styles
+*/
+.bar {
+ background-color:#4D7A97;
+ color:#FFFFFF;
+ padding:.8em .5em .4em .8em;
+ height:auto;/*height:1.8em;*/
+ font-size:11px;
+ margin:0;
+}
+.topNav {
+ background-color:#4D7A97;
+ color:#FFFFFF;
+ float:left;
+ padding:0;
+ width:100%;
+ clear:right;
+ height:2.8em;
+ padding-top:10px;
+ overflow:hidden;
+ font-size:12px;
+}
+.bottomNav {
+ margin-top:10px;
+ background-color:#4D7A97;
+ color:#FFFFFF;
+ float:left;
+ padding:0;
+ width:100%;
+ clear:right;
+ height:2.8em;
+ padding-top:10px;
+ overflow:hidden;
+ font-size:12px;
+}
+.subNav {
+ background-color:#dee3e9;
+ float:left;
+ width:100%;
+ overflow:hidden;
+ font-size:12px;
+}
+.subNav div {
+ clear:left;
+ float:left;
+ padding:0 0 5px 6px;
+ text-transform:uppercase;
+}
+ul.navList, ul.subNavList {
+ float:left;
+ margin:0 25px 0 0;
+ padding:0;
+}
+ul.navList li{
+ list-style:none;
+ float:left;
+ padding: 5px 6px;
+ text-transform:uppercase;
+}
+ul.subNavList li{
+ list-style:none;
+ float:left;
+}
+.topNav a:link, .topNav a:active, .topNav a:visited, .bottomNav a:link, .bottomNav a:active, .bottomNav a:visited {
+ color:#FFFFFF;
+ text-decoration:none;
+ text-transform:uppercase;
+}
+.topNav a:hover, .bottomNav a:hover {
+ text-decoration:none;
+ color:#bb7a2a;
+ text-transform:uppercase;
+}
+.navBarCell1Rev {
+ background-color:#F8981D;
+ color:#253441;
+ margin: auto 5px;
+}
+.skipNav {
+ position:absolute;
+ top:auto;
+ left:-9999px;
+ overflow:hidden;
+}
+/*
+Page header and footer styles
+*/
+.header, .footer {
+ clear:both;
+ margin:0 20px;
+ padding:5px 0 0 0;
+}
+.indexHeader {
+ margin:10px;
+ position:relative;
+}
+.indexHeader span{
+ margin-right:15px;
+}
+.indexHeader h1 {
+ font-size:13px;
+}
+.title {
+ color:#2c4557;
+ margin:10px 0;
+}
+.subTitle {
+ margin:5px 0 0 0;
+}
+.header ul {
+ margin:0 0 15px 0;
+ padding:0;
+}
+.footer ul {
+ margin:20px 0 5px 0;
+}
+.header ul li, .footer ul li {
+ list-style:none;
+ font-size:13px;
+}
+/*
+Heading styles
+*/
+div.details ul.blockList ul.blockList ul.blockList li.blockList h4, div.details ul.blockList ul.blockList ul.blockListLast li.blockList h4 {
+ background-color:#dee3e9;
+ border:1px solid #d0d9e0;
+ margin:0 0 6px -8px;
+ padding:7px 5px;
+}
+ul.blockList ul.blockList ul.blockList li.blockList h3 {
+ background-color:#dee3e9;
+ border:1px solid #d0d9e0;
+ margin:0 0 6px -8px;
+ padding:7px 5px;
+}
+ul.blockList ul.blockList li.blockList h3 {
+ padding:0;
+ margin:15px 0;
+}
+ul.blockList li.blockList h2 {
+ padding:0px 0 20px 0;
+}
+/*
+Page layout container styles
+*/
+.contentContainer, .sourceContainer, .classUseContainer, .serializedFormContainer, .constantValuesContainer {
+ clear:both;
+ padding:10px 20px;
+ position:relative;
+}
+.indexContainer {
+ margin:10px;
+ position:relative;
+ font-size:12px;
+}
+.indexContainer h2 {
+ font-size:13px;
+ padding:0 0 3px 0;
+}
+.indexContainer ul {
+ margin:0;
+ padding:0;
+}
+.indexContainer ul li {
+ list-style:none;
+ padding-top:2px;
+}
+.contentContainer .description dl dt, .contentContainer .details dl dt, .serializedFormContainer dl dt {
+ font-size:12px;
+ font-weight:bold;
+ margin:10px 0 0 0;
+ color:#4E4E4E;
+}
+.contentContainer .description dl dd, .contentContainer .details dl dd, .serializedFormContainer dl dd {
+ margin:5px 0 10px 0px;
+ font-size:14px;
+ font-family:'DejaVu Sans Mono',monospace;
+}
+.serializedFormContainer dl.nameValue dt {
+ margin-left:1px;
+ font-size:1.1em;
+ display:inline;
+ font-weight:bold;
+}
+.serializedFormContainer dl.nameValue dd {
+ margin:0 0 0 1px;
+ font-size:1.1em;
+ display:inline;
+}
+/*
+List styles
+*/
+ul.horizontal li {
+ display:inline;
+ font-size:0.9em;
+}
+ul.inheritance {
+ margin:0;
+ padding:0;
+}
+ul.inheritance li {
+ display:inline;
+ list-style:none;
+}
+ul.inheritance li ul.inheritance {
+ margin-left:15px;
+ padding-left:15px;
+ padding-top:1px;
+}
+ul.blockList, ul.blockListLast {
+ margin:10px 0 10px 0;
+ padding:0;
+}
+ul.blockList li.blockList, ul.blockListLast li.blockList {
+ list-style:none;
+ margin-bottom:15px;
+ line-height:1.4;
+}
+ul.blockList ul.blockList li.blockList, ul.blockList ul.blockListLast li.blockList {
+ padding:0px 20px 5px 10px;
+ border:1px solid #ededed;
+ background-color:#f8f8f8;
+}
+ul.blockList ul.blockList ul.blockList li.blockList, ul.blockList ul.blockList ul.blockListLast li.blockList {
+ padding:0 0 5px 8px;
+ background-color:#ffffff;
+ border:none;
+}
+ul.blockList ul.blockList ul.blockList ul.blockList li.blockList {
+ margin-left:0;
+ padding-left:0;
+ padding-bottom:15px;
+ border:none;
+}
+ul.blockList ul.blockList ul.blockList ul.blockList li.blockListLast {
+ list-style:none;
+ border-bottom:none;
+ padding-bottom:0;
+}
+table tr td dl, table tr td dl dt, table tr td dl dd {
+ margin-top:0;
+ margin-bottom:1px;
+}
+/*
+Table styles
+*/
+.overviewSummary, .memberSummary, .typeSummary, .useSummary, .constantsSummary, .deprecatedSummary {
+ width:100%;
+ border-left:1px solid #EEE;
+ border-right:1px solid #EEE;
+ border-bottom:1px solid #EEE;
+}
+.overviewSummary, .memberSummary {
+ padding:0px;
+}
+.overviewSummary caption, .memberSummary caption, .typeSummary caption,
+.useSummary caption, .constantsSummary caption, .deprecatedSummary caption {
+ position:relative;
+ text-align:left;
+ background-repeat:no-repeat;
+ color:#253441;
+ font-weight:bold;
+ clear:none;
+ overflow:hidden;
+ padding:0px;
+ padding-top:10px;
+ padding-left:1px;
+ margin:0px;
+ white-space:pre;
+}
+.overviewSummary caption a:link, .memberSummary caption a:link, .typeSummary caption a:link,
+.useSummary caption a:link, .constantsSummary caption a:link, .deprecatedSummary caption a:link,
+.overviewSummary caption a:hover, .memberSummary caption a:hover, .typeSummary caption a:hover,
+.useSummary caption a:hover, .constantsSummary caption a:hover, .deprecatedSummary caption a:hover,
+.overviewSummary caption a:active, .memberSummary caption a:active, .typeSummary caption a:active,
+.useSummary caption a:active, .constantsSummary caption a:active, .deprecatedSummary caption a:active,
+.overviewSummary caption a:visited, .memberSummary caption a:visited, .typeSummary caption a:visited,
+.useSummary caption a:visited, .constantsSummary caption a:visited, .deprecatedSummary caption a:visited {
+ color:#FFFFFF;
+}
+.overviewSummary caption span, .memberSummary caption span, .typeSummary caption span,
+.useSummary caption span, .constantsSummary caption span, .deprecatedSummary caption span {
+ white-space:nowrap;
+ padding-top:5px;
+ padding-left:12px;
+ padding-right:12px;
+ padding-bottom:7px;
+ display:inline-block;
+ float:left;
+ background-color:#F8981D;
+ border: none;
+ height:16px;
+}
+.memberSummary caption span.activeTableTab span {
+ white-space:nowrap;
+ padding-top:5px;
+ padding-left:12px;
+ padding-right:12px;
+ margin-right:3px;
+ display:inline-block;
+ float:left;
+ background-color:#F8981D;
+ height:16px;
+}
+.memberSummary caption span.tableTab span {
+ white-space:nowrap;
+ padding-top:5px;
+ padding-left:12px;
+ padding-right:12px;
+ margin-right:3px;
+ display:inline-block;
+ float:left;
+ background-color:#4D7A97;
+ height:16px;
+}
+.memberSummary caption span.tableTab, .memberSummary caption span.activeTableTab {
+ padding-top:0px;
+ padding-left:0px;
+ padding-right:0px;
+ background-image:none;
+ float:none;
+ display:inline;
+}
+.overviewSummary .tabEnd, .memberSummary .tabEnd, .typeSummary .tabEnd,
+.useSummary .tabEnd, .constantsSummary .tabEnd, .deprecatedSummary .tabEnd {
+ display:none;
+ width:5px;
+ position:relative;
+ float:left;
+ background-color:#F8981D;
+}
+.memberSummary .activeTableTab .tabEnd {
+ display:none;
+ width:5px;
+ margin-right:3px;
+ position:relative;
+ float:left;
+ background-color:#F8981D;
+}
+.memberSummary .tableTab .tabEnd {
+ display:none;
+ width:5px;
+ margin-right:3px;
+ position:relative;
+ background-color:#4D7A97;
+ float:left;
+
+}
+.overviewSummary td, .memberSummary td, .typeSummary td,
+.useSummary td, .constantsSummary td, .deprecatedSummary td {
+ text-align:left;
+ padding:0px 0px 12px 10px;
+}
+th.colOne, th.colFirst, th.colLast, .useSummary th, .constantsSummary th,
+td.colOne, td.colFirst, td.colLast, .useSummary td, .constantsSummary td{
+ vertical-align:top;
+ padding-right:0px;
+ padding-top:8px;
+ padding-bottom:3px;
+}
+th.colFirst, th.colLast, th.colOne, .constantsSummary th {
+ background:#dee3e9;
+ text-align:left;
+ padding:8px 3px 3px 7px;
+}
+td.colFirst, th.colFirst {
+ white-space:nowrap;
+ font-size:13px;
+}
+td.colLast, th.colLast {
+ font-size:13px;
+}
+td.colOne, th.colOne {
+ font-size:13px;
+}
+.overviewSummary td.colFirst, .overviewSummary th.colFirst,
+.useSummary td.colFirst, .useSummary th.colFirst,
+.overviewSummary td.colOne, .overviewSummary th.colOne,
+.memberSummary td.colFirst, .memberSummary th.colFirst,
+.memberSummary td.colOne, .memberSummary th.colOne,
+.typeSummary td.colFirst{
+ width:25%;
+ vertical-align:top;
+}
+td.colOne a:link, td.colOne a:active, td.colOne a:visited, td.colOne a:hover, td.colFirst a:link, td.colFirst a:active, td.colFirst a:visited, td.colFirst a:hover, td.colLast a:link, td.colLast a:active, td.colLast a:visited, td.colLast a:hover, .constantValuesContainer td a:link, .constantValuesContainer td a:active, .constantValuesContainer td a:visited, .constantValuesContainer td a:hover {
+ font-weight:bold;
+}
+.tableSubHeadingColor {
+ background-color:#EEEEFF;
+}
+.altColor {
+ background-color:#FFFFFF;
+}
+.rowColor {
+ background-color:#EEEEEF;
+}
+/*
+Content styles
+*/
+.description pre {
+ margin-top:0;
+}
+.deprecatedContent {
+ margin:0;
+ padding:10px 0;
+}
+.docSummary {
+ padding:0;
+}
+
+ul.blockList ul.blockList ul.blockList li.blockList h3 {
+ font-style:normal;
+}
+
+div.block {
+ font-size:14px;
+ font-family:'DejaVu Serif', Georgia, "Times New Roman", Times, serif;
+}
+
+td.colLast div {
+ padding-top:0px;
+}
+
+
+td.colLast a {
+ padding-bottom:3px;
+}
+/*
+Formatting effect styles
+*/
+.sourceLineNo {
+ color:green;
+ padding:0 30px 0 0;
+}
+h1.hidden {
+ visibility:hidden;
+ overflow:hidden;
+ font-size:10px;
+}
+.block {
+ display:block;
+ margin:3px 10px 2px 0px;
+ color:#474747;
+}
+.deprecatedLabel, .descfrmTypeLabel, .memberNameLabel, .memberNameLink,
+.overrideSpecifyLabel, .packageHierarchyLabel, .paramLabel, .returnLabel,
+.seeLabel, .simpleTagLabel, .throwsLabel, .typeNameLabel, .typeNameLink {
+ font-weight:bold;
+}
+.deprecationComment, .emphasizedPhrase, .interfaceName {
+ font-style:italic;
+}
+
+div.block div.block span.deprecationComment, div.block div.block span.emphasizedPhrase,
+div.block div.block span.interfaceName {
+ font-style:normal;
+}
+
+div.contentContainer ul.blockList li.blockList h2{
+ padding-bottom:0px;
+}
diff --git a/ZPI-App/opencv/java/res/values/attrs.xml b/ZPI-App/opencv/java/res/values/attrs.xml
new file mode 100644
index 000000000..6902621f6
--- /dev/null
+++ b/ZPI-App/opencv/java/res/values/attrs.xml
@@ -0,0 +1,11 @@
+
+
+
+
+
+
+
+
+
+
+
diff --git a/ZPI-App/opencv/java/src/org/opencv/android/AsyncServiceHelper.java b/ZPI-App/opencv/java/src/org/opencv/android/AsyncServiceHelper.java
new file mode 100644
index 000000000..cb3c6428d
--- /dev/null
+++ b/ZPI-App/opencv/java/src/org/opencv/android/AsyncServiceHelper.java
@@ -0,0 +1,391 @@
+package org.opencv.android;
+
+import java.io.File;
+import java.util.StringTokenizer;
+
+import org.opencv.core.Core;
+import org.opencv.engine.OpenCVEngineInterface;
+
+import android.content.ComponentName;
+import android.content.Context;
+import android.content.Intent;
+import android.content.ServiceConnection;
+import android.net.Uri;
+import android.os.IBinder;
+import android.os.RemoteException;
+import android.util.Log;
+
+class AsyncServiceHelper
+{
+ public static boolean initOpenCV(String Version, final Context AppContext,
+ final LoaderCallbackInterface Callback)
+ {
+ AsyncServiceHelper helper = new AsyncServiceHelper(Version, AppContext, Callback);
+ Intent intent = new Intent("org.opencv.engine.BIND");
+ intent.setPackage("org.opencv.engine");
+ if (AppContext.bindService(intent, helper.mServiceConnection, Context.BIND_AUTO_CREATE))
+ {
+ return true;
+ }
+ else
+ {
+ AppContext.unbindService(helper.mServiceConnection);
+ InstallService(AppContext, Callback);
+ return false;
+ }
+ }
+
+ protected AsyncServiceHelper(String Version, Context AppContext, LoaderCallbackInterface Callback)
+ {
+ mOpenCVersion = Version;
+ mUserAppCallback = Callback;
+ mAppContext = AppContext;
+ }
+
+ protected static final String TAG = "OpenCVManager/Helper";
+ protected static final int MINIMUM_ENGINE_VERSION = 2;
+ protected OpenCVEngineInterface mEngineService;
+ protected LoaderCallbackInterface mUserAppCallback;
+ protected String mOpenCVersion;
+ protected Context mAppContext;
+ protected static boolean mServiceInstallationProgress = false;
+ protected static boolean mLibraryInstallationProgress = false;
+
+ protected static boolean InstallServiceQuiet(Context context)
+ {
+ boolean result = true;
+ try
+ {
+ Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(OPEN_CV_SERVICE_URL));
+ intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
+ context.startActivity(intent);
+ }
+ catch(Exception e)
+ {
+ result = false;
+ }
+
+ return result;
+ }
+
+ protected static void InstallService(final Context AppContext, final LoaderCallbackInterface Callback)
+ {
+ if (!mServiceInstallationProgress)
+ {
+ Log.d(TAG, "Request new service installation");
+ InstallCallbackInterface InstallQuery = new InstallCallbackInterface() {
+ private LoaderCallbackInterface mUserAppCallback = Callback;
+ public String getPackageName()
+ {
+ return "OpenCV Manager";
+ }
+ public void install() {
+ Log.d(TAG, "Trying to install OpenCV Manager via Google Play");
+
+ boolean result = InstallServiceQuiet(AppContext);
+ if (result)
+ {
+ mServiceInstallationProgress = true;
+ Log.d(TAG, "Package installation started");
+ }
+ else
+ {
+ Log.d(TAG, "OpenCV package was not installed!");
+ int Status = LoaderCallbackInterface.MARKET_ERROR;
+ Log.d(TAG, "Init finished with status " + Status);
+ Log.d(TAG, "Unbind from service");
+ Log.d(TAG, "Calling using callback");
+ mUserAppCallback.onManagerConnected(Status);
+ }
+ }
+
+ public void cancel()
+ {
+ Log.d(TAG, "OpenCV library installation was canceled");
+ int Status = LoaderCallbackInterface.INSTALL_CANCELED;
+ Log.d(TAG, "Init finished with status " + Status);
+ Log.d(TAG, "Calling using callback");
+ mUserAppCallback.onManagerConnected(Status);
+ }
+
+ public void wait_install()
+ {
+ Log.e(TAG, "Installation was not started! Nothing to wait!");
+ }
+ };
+
+ Callback.onPackageInstall(InstallCallbackInterface.NEW_INSTALLATION, InstallQuery);
+ }
+ else
+ {
+ Log.d(TAG, "Waiting current installation process");
+ InstallCallbackInterface WaitQuery = new InstallCallbackInterface() {
+ private LoaderCallbackInterface mUserAppCallback = Callback;
+ public String getPackageName()
+ {
+ return "OpenCV Manager";
+ }
+ public void install()
+ {
+ Log.e(TAG, "Nothing to install we just wait current installation");
+ }
+ public void cancel()
+ {
+ Log.d(TAG, "Waiting for OpenCV canceled by user");
+ mServiceInstallationProgress = false;
+ int Status = LoaderCallbackInterface.INSTALL_CANCELED;
+ Log.d(TAG, "Init finished with status " + Status);
+ Log.d(TAG, "Calling using callback");
+ mUserAppCallback.onManagerConnected(Status);
+ }
+ public void wait_install()
+ {
+ InstallServiceQuiet(AppContext);
+ }
+ };
+
+ Callback.onPackageInstall(InstallCallbackInterface.INSTALLATION_PROGRESS, WaitQuery);
+ }
+ }
+
+ /**
+ * URL of OpenCV Manager page on Google Play Market.
+ */
+ protected static final String OPEN_CV_SERVICE_URL = "market://details?id=org.opencv.engine";
+
+ protected ServiceConnection mServiceConnection = new ServiceConnection()
+ {
+ public void onServiceConnected(ComponentName className, IBinder service)
+ {
+ Log.d(TAG, "Service connection created");
+ mEngineService = OpenCVEngineInterface.Stub.asInterface(service);
+ if (null == mEngineService)
+ {
+ Log.d(TAG, "OpenCV Manager Service connection fails. May be service was not installed?");
+ InstallService(mAppContext, mUserAppCallback);
+ }
+ else
+ {
+ mServiceInstallationProgress = false;
+ try
+ {
+ if (mEngineService.getEngineVersion() < MINIMUM_ENGINE_VERSION)
+ {
+ Log.d(TAG, "Init finished with status " + LoaderCallbackInterface.INCOMPATIBLE_MANAGER_VERSION);
+ Log.d(TAG, "Unbind from service");
+ mAppContext.unbindService(mServiceConnection);
+ Log.d(TAG, "Calling using callback");
+ mUserAppCallback.onManagerConnected(LoaderCallbackInterface.INCOMPATIBLE_MANAGER_VERSION);
+ return;
+ }
+
+ Log.d(TAG, "Trying to get library path");
+ String path = mEngineService.getLibPathByVersion(mOpenCVersion);
+ if ((null == path) || (path.length() == 0))
+ {
+ if (!mLibraryInstallationProgress)
+ {
+ InstallCallbackInterface InstallQuery = new InstallCallbackInterface() {
+ public String getPackageName()
+ {
+ return "OpenCV library";
+ }
+ public void install() {
+ Log.d(TAG, "Trying to install OpenCV lib via Google Play");
+ try
+ {
+ if (mEngineService.installVersion(mOpenCVersion))
+ {
+ mLibraryInstallationProgress = true;
+ Log.d(TAG, "Package installation started");
+ Log.d(TAG, "Unbind from service");
+ mAppContext.unbindService(mServiceConnection);
+ }
+ else
+ {
+ Log.d(TAG, "OpenCV package was not installed!");
+ Log.d(TAG, "Init finished with status " + LoaderCallbackInterface.MARKET_ERROR);
+ Log.d(TAG, "Unbind from service");
+ mAppContext.unbindService(mServiceConnection);
+ Log.d(TAG, "Calling using callback");
+ mUserAppCallback.onManagerConnected(LoaderCallbackInterface.MARKET_ERROR);
+ }
+ } catch (RemoteException e) {
+ e.printStackTrace();;
+ Log.d(TAG, "Init finished with status " + LoaderCallbackInterface.INIT_FAILED);
+ Log.d(TAG, "Unbind from service");
+ mAppContext.unbindService(mServiceConnection);
+ Log.d(TAG, "Calling using callback");
+ mUserAppCallback.onManagerConnected(LoaderCallbackInterface.INIT_FAILED);
+ }
+ }
+ public void cancel() {
+ Log.d(TAG, "OpenCV library installation was canceled");
+ Log.d(TAG, "Init finished with status " + LoaderCallbackInterface.INSTALL_CANCELED);
+ Log.d(TAG, "Unbind from service");
+ mAppContext.unbindService(mServiceConnection);
+ Log.d(TAG, "Calling using callback");
+ mUserAppCallback.onManagerConnected(LoaderCallbackInterface.INSTALL_CANCELED);
+ }
+ public void wait_install() {
+ Log.e(TAG, "Installation was not started! Nothing to wait!");
+ }
+ };
+
+ mUserAppCallback.onPackageInstall(InstallCallbackInterface.NEW_INSTALLATION, InstallQuery);
+ }
+ else
+ {
+ InstallCallbackInterface WaitQuery = new InstallCallbackInterface() {
+ public String getPackageName()
+ {
+ return "OpenCV library";
+ }
+
+ public void install() {
+ Log.e(TAG, "Nothing to install we just wait current installation");
+ }
+ public void cancel()
+ {
+ Log.d(TAG, "OpenCV library installation was canceled");
+ mLibraryInstallationProgress = false;
+ Log.d(TAG, "Init finished with status " + LoaderCallbackInterface.INSTALL_CANCELED);
+ Log.d(TAG, "Unbind from service");
+ mAppContext.unbindService(mServiceConnection);
+ Log.d(TAG, "Calling using callback");
+ mUserAppCallback.onManagerConnected(LoaderCallbackInterface.INSTALL_CANCELED);
+ }
+ public void wait_install() {
+ Log.d(TAG, "Waiting for current installation");
+ try
+ {
+ if (!mEngineService.installVersion(mOpenCVersion))
+ {
+ Log.d(TAG, "OpenCV package was not installed!");
+ Log.d(TAG, "Init finished with status " + LoaderCallbackInterface.MARKET_ERROR);
+ Log.d(TAG, "Calling using callback");
+ mUserAppCallback.onManagerConnected(LoaderCallbackInterface.MARKET_ERROR);
+ }
+ else
+ {
+ Log.d(TAG, "Waiting for package installation");
+ }
+
+ Log.d(TAG, "Unbind from service");
+ mAppContext.unbindService(mServiceConnection);
+
+ } catch (RemoteException e) {
+ e.printStackTrace();
+ Log.d(TAG, "Init finished with status " + LoaderCallbackInterface.INIT_FAILED);
+ Log.d(TAG, "Unbind from service");
+ mAppContext.unbindService(mServiceConnection);
+ Log.d(TAG, "Calling using callback");
+ mUserAppCallback.onManagerConnected(LoaderCallbackInterface.INIT_FAILED);
+ }
+ }
+ };
+
+ mUserAppCallback.onPackageInstall(InstallCallbackInterface.INSTALLATION_PROGRESS, WaitQuery);
+ }
+ return;
+ }
+ else
+ {
+ Log.d(TAG, "Trying to get library list");
+ mLibraryInstallationProgress = false;
+ String libs = mEngineService.getLibraryList(mOpenCVersion);
+ Log.d(TAG, "Library list: \"" + libs + "\"");
+ Log.d(TAG, "First attempt to load libs");
+ int status;
+ if (initOpenCVLibs(path, libs))
+ {
+ Log.d(TAG, "First attempt to load libs is OK");
+ String eol = System.getProperty("line.separator");
+ for (String str : Core.getBuildInformation().split(eol))
+ Log.i(TAG, str);
+
+ status = LoaderCallbackInterface.SUCCESS;
+ }
+ else
+ {
+ Log.d(TAG, "First attempt to load libs fails");
+ status = LoaderCallbackInterface.INIT_FAILED;
+ }
+
+ Log.d(TAG, "Init finished with status " + status);
+ Log.d(TAG, "Unbind from service");
+ mAppContext.unbindService(mServiceConnection);
+ Log.d(TAG, "Calling using callback");
+ mUserAppCallback.onManagerConnected(status);
+ }
+ }
+ catch (RemoteException e)
+ {
+ e.printStackTrace();
+ Log.d(TAG, "Init finished with status " + LoaderCallbackInterface.INIT_FAILED);
+ Log.d(TAG, "Unbind from service");
+ mAppContext.unbindService(mServiceConnection);
+ Log.d(TAG, "Calling using callback");
+ mUserAppCallback.onManagerConnected(LoaderCallbackInterface.INIT_FAILED);
+ }
+ }
+ }
+
+ public void onServiceDisconnected(ComponentName className)
+ {
+ mEngineService = null;
+ }
+ };
+
+ private boolean loadLibrary(String AbsPath)
+ {
+ boolean result = true;
+
+ Log.d(TAG, "Trying to load library " + AbsPath);
+ try
+ {
+ System.load(AbsPath);
+ Log.d(TAG, "OpenCV libs init was ok!");
+ }
+ catch(UnsatisfiedLinkError e)
+ {
+ Log.d(TAG, "Cannot load library \"" + AbsPath + "\"");
+ e.printStackTrace();
+ result = false;
+ }
+
+ return result;
+ }
+
+ private boolean initOpenCVLibs(String Path, String Libs)
+ {
+ Log.d(TAG, "Trying to init OpenCV libs");
+ if ((null != Path) && (Path.length() != 0))
+ {
+ boolean result = true;
+ if ((null != Libs) && (Libs.length() != 0))
+ {
+ Log.d(TAG, "Trying to load libs by dependency list");
+ StringTokenizer splitter = new StringTokenizer(Libs, ";");
+ while(splitter.hasMoreTokens())
+ {
+ String AbsLibraryPath = Path + File.separator + splitter.nextToken();
+ result &= loadLibrary(AbsLibraryPath);
+ }
+ }
+ else
+ {
+ // If the dependencies list is not defined or empty.
+ String AbsLibraryPath = Path + File.separator + "libopencv_java4.so";
+ result = loadLibrary(AbsLibraryPath);
+ }
+
+ return result;
+ }
+ else
+ {
+ Log.d(TAG, "Library path \"" + Path + "\" is empty");
+ return false;
+ }
+ }
+}
diff --git a/ZPI-App/opencv/java/src/org/opencv/android/BaseLoaderCallback.java b/ZPI-App/opencv/java/src/org/opencv/android/BaseLoaderCallback.java
new file mode 100644
index 000000000..8ece66251
--- /dev/null
+++ b/ZPI-App/opencv/java/src/org/opencv/android/BaseLoaderCallback.java
@@ -0,0 +1,141 @@
+package org.opencv.android;
+
+import android.app.Activity;
+import android.app.AlertDialog;
+import android.content.Context;
+import android.content.DialogInterface;
+import android.content.DialogInterface.OnClickListener;
+import android.util.Log;
+
+/**
+ * Basic implementation of LoaderCallbackInterface.
+ */
+public abstract class BaseLoaderCallback implements LoaderCallbackInterface {
+
+ public BaseLoaderCallback(Context AppContext) {
+ mAppContext = AppContext;
+ }
+
+ public void onManagerConnected(int status)
+ {
+ switch (status)
+ {
+ /** OpenCV initialization was successful. **/
+ case LoaderCallbackInterface.SUCCESS:
+ {
+ /** Application must override this method to handle successful library initialization. **/
+ } break;
+ /** OpenCV loader can not start Google Play Market. **/
+ case LoaderCallbackInterface.MARKET_ERROR:
+ {
+ Log.e(TAG, "Package installation failed!");
+ AlertDialog MarketErrorMessage = new AlertDialog.Builder(mAppContext).create();
+ MarketErrorMessage.setTitle("OpenCV Manager");
+ MarketErrorMessage.setMessage("Package installation failed!");
+ MarketErrorMessage.setCancelable(false); // This blocks the 'BACK' button
+ MarketErrorMessage.setButton(AlertDialog.BUTTON_POSITIVE, "OK", new OnClickListener() {
+ public void onClick(DialogInterface dialog, int which) {
+ finish();
+ }
+ });
+ MarketErrorMessage.show();
+ } break;
+ /** Package installation has been canceled. **/
+ case LoaderCallbackInterface.INSTALL_CANCELED:
+ {
+ Log.d(TAG, "OpenCV library installation was canceled by user");
+ finish();
+ } break;
+ /** Application is incompatible with this version of OpenCV Manager. Possibly, a service update is required. **/
+ case LoaderCallbackInterface.INCOMPATIBLE_MANAGER_VERSION:
+ {
+ Log.d(TAG, "OpenCV Manager Service is uncompatible with this app!");
+ AlertDialog IncomatibilityMessage = new AlertDialog.Builder(mAppContext).create();
+ IncomatibilityMessage.setTitle("OpenCV Manager");
+ IncomatibilityMessage.setMessage("OpenCV Manager service is incompatible with this app. Try to update it via Google Play.");
+ IncomatibilityMessage.setCancelable(false); // This blocks the 'BACK' button
+ IncomatibilityMessage.setButton(AlertDialog.BUTTON_POSITIVE, "OK", new OnClickListener() {
+ public void onClick(DialogInterface dialog, int which) {
+ finish();
+ }
+ });
+ IncomatibilityMessage.show();
+ } break;
+ /** Other status, i.e. INIT_FAILED. **/
+ default:
+ {
+ Log.e(TAG, "OpenCV loading failed!");
+ AlertDialog InitFailedDialog = new AlertDialog.Builder(mAppContext).create();
+ InitFailedDialog.setTitle("OpenCV error");
+ InitFailedDialog.setMessage("OpenCV was not initialised correctly. Application will be shut down");
+ InitFailedDialog.setCancelable(false); // This blocks the 'BACK' button
+ InitFailedDialog.setButton(AlertDialog.BUTTON_POSITIVE, "OK", new OnClickListener() {
+
+ public void onClick(DialogInterface dialog, int which) {
+ finish();
+ }
+ });
+
+ InitFailedDialog.show();
+ } break;
+ }
+ }
+
+ public void onPackageInstall(final int operation, final InstallCallbackInterface callback)
+ {
+ switch (operation)
+ {
+ case InstallCallbackInterface.NEW_INSTALLATION:
+ {
+ AlertDialog InstallMessage = new AlertDialog.Builder(mAppContext).create();
+ InstallMessage.setTitle("Package not found");
+ InstallMessage.setMessage(callback.getPackageName() + " package was not found! Try to install it?");
+ InstallMessage.setCancelable(false); // This blocks the 'BACK' button
+ InstallMessage.setButton(AlertDialog.BUTTON_POSITIVE, "Yes", new OnClickListener()
+ {
+ public void onClick(DialogInterface dialog, int which)
+ {
+ callback.install();
+ }
+ });
+
+ InstallMessage.setButton(AlertDialog.BUTTON_NEGATIVE, "No", new OnClickListener() {
+
+ public void onClick(DialogInterface dialog, int which)
+ {
+ callback.cancel();
+ }
+ });
+
+ InstallMessage.show();
+ } break;
+ case InstallCallbackInterface.INSTALLATION_PROGRESS:
+ {
+ AlertDialog WaitMessage = new AlertDialog.Builder(mAppContext).create();
+ WaitMessage.setTitle("OpenCV is not ready");
+ WaitMessage.setMessage("Installation is in progress. Wait or exit?");
+ WaitMessage.setCancelable(false); // This blocks the 'BACK' button
+ WaitMessage.setButton(AlertDialog.BUTTON_POSITIVE, "Wait", new OnClickListener() {
+ public void onClick(DialogInterface dialog, int which) {
+ callback.wait_install();
+ }
+ });
+ WaitMessage.setButton(AlertDialog.BUTTON_NEGATIVE, "Exit", new OnClickListener() {
+ public void onClick(DialogInterface dialog, int which) {
+ callback.cancel();
+ }
+ });
+
+ WaitMessage.show();
+ } break;
+ }
+ }
+
+ void finish()
+ {
+ ((Activity) mAppContext).finish();
+ }
+
+ protected Context mAppContext;
+ private final static String TAG = "OCV/BaseLoaderCallback";
+}
diff --git a/ZPI-App/opencv/java/src/org/opencv/android/Camera2Renderer.java b/ZPI-App/opencv/java/src/org/opencv/android/Camera2Renderer.java
new file mode 100644
index 000000000..408214057
--- /dev/null
+++ b/ZPI-App/opencv/java/src/org/opencv/android/Camera2Renderer.java
@@ -0,0 +1,302 @@
+package org.opencv.android;
+
+import java.util.Arrays;
+import java.util.concurrent.Semaphore;
+import java.util.concurrent.TimeUnit;
+import android.annotation.TargetApi;
+import android.content.Context;
+import android.graphics.SurfaceTexture;
+import android.hardware.camera2.CameraAccessException;
+import android.hardware.camera2.CameraCaptureSession;
+import android.hardware.camera2.CameraCharacteristics;
+import android.hardware.camera2.CameraDevice;
+import android.hardware.camera2.CameraManager;
+import android.hardware.camera2.CaptureRequest;
+import android.hardware.camera2.params.StreamConfigurationMap;
+import android.os.Handler;
+import android.os.HandlerThread;
+import android.util.Log;
+import android.util.Size;
+import android.view.Surface;
+
+@TargetApi(21)
+public class Camera2Renderer extends CameraGLRendererBase {
+
+ protected final String LOGTAG = "Camera2Renderer";
+ private CameraDevice mCameraDevice;
+ private CameraCaptureSession mCaptureSession;
+ private CaptureRequest.Builder mPreviewRequestBuilder;
+ private String mCameraID;
+ private Size mPreviewSize = new Size(-1, -1);
+
+ private HandlerThread mBackgroundThread;
+ private Handler mBackgroundHandler;
+ private Semaphore mCameraOpenCloseLock = new Semaphore(1);
+
+ Camera2Renderer(CameraGLSurfaceView view) {
+ super(view);
+ }
+
+ @Override
+ protected void doStart() {
+ Log.d(LOGTAG, "doStart");
+ startBackgroundThread();
+ super.doStart();
+ }
+
+
+ @Override
+ protected void doStop() {
+ Log.d(LOGTAG, "doStop");
+ super.doStop();
+ stopBackgroundThread();
+ }
+
+ boolean cacPreviewSize(final int width, final int height) {
+ Log.i(LOGTAG, "cacPreviewSize: "+width+"x"+height);
+ if(mCameraID == null) {
+ Log.e(LOGTAG, "Camera isn't initialized!");
+ return false;
+ }
+ CameraManager manager = (CameraManager) mView.getContext()
+ .getSystemService(Context.CAMERA_SERVICE);
+ try {
+ CameraCharacteristics characteristics = manager
+ .getCameraCharacteristics(mCameraID);
+ StreamConfigurationMap map = characteristics
+ .get(CameraCharacteristics.SCALER_STREAM_CONFIGURATION_MAP);
+ int bestWidth = 0, bestHeight = 0;
+ float aspect = (float)width / height;
+ for (Size psize : map.getOutputSizes(SurfaceTexture.class)) {
+ int w = psize.getWidth(), h = psize.getHeight();
+ Log.d(LOGTAG, "trying size: "+w+"x"+h);
+ if ( width >= w && height >= h &&
+ bestWidth <= w && bestHeight <= h &&
+ Math.abs(aspect - (float)w/h) < 0.2 ) {
+ bestWidth = w;
+ bestHeight = h;
+ }
+ }
+ Log.i(LOGTAG, "best size: "+bestWidth+"x"+bestHeight);
+ if( bestWidth == 0 || bestHeight == 0 ||
+ mPreviewSize.getWidth() == bestWidth &&
+ mPreviewSize.getHeight() == bestHeight )
+ return false;
+ else {
+ mPreviewSize = new Size(bestWidth, bestHeight);
+ return true;
+ }
+ } catch (CameraAccessException e) {
+ Log.e(LOGTAG, "cacPreviewSize - Camera Access Exception");
+ } catch (IllegalArgumentException e) {
+ Log.e(LOGTAG, "cacPreviewSize - Illegal Argument Exception");
+ } catch (SecurityException e) {
+ Log.e(LOGTAG, "cacPreviewSize - Security Exception");
+ }
+ return false;
+ }
+
+ @Override
+ protected void openCamera(int id) {
+ Log.i(LOGTAG, "openCamera");
+ CameraManager manager = (CameraManager) mView.getContext().getSystemService(Context.CAMERA_SERVICE);
+ try {
+ String camList[] = manager.getCameraIdList();
+ if(camList.length == 0) {
+ Log.e(LOGTAG, "Error: camera isn't detected.");
+ return;
+ }
+ if(id == CameraBridgeViewBase.CAMERA_ID_ANY) {
+ mCameraID = camList[0];
+ } else {
+ for (String cameraID : camList) {
+ CameraCharacteristics characteristics = manager.getCameraCharacteristics(cameraID);
+ if( id == CameraBridgeViewBase.CAMERA_ID_BACK &&
+ characteristics.get(CameraCharacteristics.LENS_FACING) == CameraCharacteristics.LENS_FACING_BACK ||
+ id == CameraBridgeViewBase.CAMERA_ID_FRONT &&
+ characteristics.get(CameraCharacteristics.LENS_FACING) == CameraCharacteristics.LENS_FACING_FRONT) {
+ mCameraID = cameraID;
+ break;
+ }
+ }
+ }
+ if(mCameraID != null) {
+ if (!mCameraOpenCloseLock.tryAcquire(2500, TimeUnit.MILLISECONDS)) {
+ throw new RuntimeException(
+ "Time out waiting to lock camera opening.");
+ }
+ Log.i(LOGTAG, "Opening camera: " + mCameraID);
+ manager.openCamera(mCameraID, mStateCallback, mBackgroundHandler);
+ }
+ } catch (CameraAccessException e) {
+ Log.e(LOGTAG, "OpenCamera - Camera Access Exception");
+ } catch (IllegalArgumentException e) {
+ Log.e(LOGTAG, "OpenCamera - Illegal Argument Exception");
+ } catch (SecurityException e) {
+ Log.e(LOGTAG, "OpenCamera - Security Exception");
+ } catch (InterruptedException e) {
+ Log.e(LOGTAG, "OpenCamera - Interrupted Exception");
+ }
+ }
+
+ @Override
+ protected void closeCamera() {
+ Log.i(LOGTAG, "closeCamera");
+ try {
+ mCameraOpenCloseLock.acquire();
+ if (null != mCaptureSession) {
+ mCaptureSession.close();
+ mCaptureSession = null;
+ }
+ if (null != mCameraDevice) {
+ mCameraDevice.close();
+ mCameraDevice = null;
+ }
+ } catch (InterruptedException e) {
+ throw new RuntimeException("Interrupted while trying to lock camera closing.", e);
+ } finally {
+ mCameraOpenCloseLock.release();
+ }
+ }
+
+ private final CameraDevice.StateCallback mStateCallback = new CameraDevice.StateCallback() {
+
+ @Override
+ public void onOpened(CameraDevice cameraDevice) {
+ mCameraDevice = cameraDevice;
+ mCameraOpenCloseLock.release();
+ createCameraPreviewSession();
+ }
+
+ @Override
+ public void onDisconnected(CameraDevice cameraDevice) {
+ cameraDevice.close();
+ mCameraDevice = null;
+ mCameraOpenCloseLock.release();
+ }
+
+ @Override
+ public void onError(CameraDevice cameraDevice, int error) {
+ cameraDevice.close();
+ mCameraDevice = null;
+ mCameraOpenCloseLock.release();
+ }
+
+ };
+
+ private void createCameraPreviewSession() {
+ int w=mPreviewSize.getWidth(), h=mPreviewSize.getHeight();
+ Log.i(LOGTAG, "createCameraPreviewSession("+w+"x"+h+")");
+ if(w<0 || h<0)
+ return;
+ try {
+ mCameraOpenCloseLock.acquire();
+ if (null == mCameraDevice) {
+ mCameraOpenCloseLock.release();
+ Log.e(LOGTAG, "createCameraPreviewSession: camera isn't opened");
+ return;
+ }
+ if (null != mCaptureSession) {
+ mCameraOpenCloseLock.release();
+ Log.e(LOGTAG, "createCameraPreviewSession: mCaptureSession is already started");
+ return;
+ }
+ if(null == mSTexture) {
+ mCameraOpenCloseLock.release();
+ Log.e(LOGTAG, "createCameraPreviewSession: preview SurfaceTexture is null");
+ return;
+ }
+ mSTexture.setDefaultBufferSize(w, h);
+
+ Surface surface = new Surface(mSTexture);
+
+ mPreviewRequestBuilder = mCameraDevice
+ .createCaptureRequest(CameraDevice.TEMPLATE_PREVIEW);
+ mPreviewRequestBuilder.addTarget(surface);
+
+ mCameraDevice.createCaptureSession(Arrays.asList(surface),
+ new CameraCaptureSession.StateCallback() {
+ @Override
+ public void onConfigured( CameraCaptureSession cameraCaptureSession) {
+ mCaptureSession = cameraCaptureSession;
+ try {
+ mPreviewRequestBuilder.set(CaptureRequest.CONTROL_AF_MODE, CaptureRequest.CONTROL_AF_MODE_CONTINUOUS_PICTURE);
+ mPreviewRequestBuilder.set(CaptureRequest.CONTROL_AE_MODE, CaptureRequest.CONTROL_AE_MODE_ON_AUTO_FLASH);
+
+ mCaptureSession.setRepeatingRequest(mPreviewRequestBuilder.build(), null, mBackgroundHandler);
+ Log.i(LOGTAG, "CameraPreviewSession has been started");
+ } catch (CameraAccessException e) {
+ Log.e(LOGTAG, "createCaptureSession failed");
+ }
+ mCameraOpenCloseLock.release();
+ }
+
+ @Override
+ public void onConfigureFailed(
+ CameraCaptureSession cameraCaptureSession) {
+ Log.e(LOGTAG, "createCameraPreviewSession failed");
+ mCameraOpenCloseLock.release();
+ }
+ }, mBackgroundHandler);
+ } catch (CameraAccessException e) {
+ Log.e(LOGTAG, "createCameraPreviewSession");
+ } catch (InterruptedException e) {
+ throw new RuntimeException(
+ "Interrupted while createCameraPreviewSession", e);
+ }
+ finally {
+ //mCameraOpenCloseLock.release();
+ }
+ }
+
+ private void startBackgroundThread() {
+ Log.i(LOGTAG, "startBackgroundThread");
+ stopBackgroundThread();
+ mBackgroundThread = new HandlerThread("CameraBackground");
+ mBackgroundThread.start();
+ mBackgroundHandler = new Handler(mBackgroundThread.getLooper());
+ }
+
+ private void stopBackgroundThread() {
+ Log.i(LOGTAG, "stopBackgroundThread");
+ if(mBackgroundThread == null)
+ return;
+ mBackgroundThread.quitSafely();
+ try {
+ mBackgroundThread.join();
+ mBackgroundThread = null;
+ mBackgroundHandler = null;
+ } catch (InterruptedException e) {
+ Log.e(LOGTAG, "stopBackgroundThread");
+ }
+ }
+
+ @Override
+ protected void setCameraPreviewSize(int width, int height) {
+ Log.i(LOGTAG, "setCameraPreviewSize("+width+"x"+height+")");
+ if(mMaxCameraWidth > 0 && mMaxCameraWidth < width) width = mMaxCameraWidth;
+ if(mMaxCameraHeight > 0 && mMaxCameraHeight < height) height = mMaxCameraHeight;
+ try {
+ mCameraOpenCloseLock.acquire();
+
+ boolean needReconfig = cacPreviewSize(width, height);
+ mCameraWidth = mPreviewSize.getWidth();
+ mCameraHeight = mPreviewSize.getHeight();
+
+ if( !needReconfig ) {
+ mCameraOpenCloseLock.release();
+ return;
+ }
+ if (null != mCaptureSession) {
+ Log.d(LOGTAG, "closing existing previewSession");
+ mCaptureSession.close();
+ mCaptureSession = null;
+ }
+ mCameraOpenCloseLock.release();
+ createCameraPreviewSession();
+ } catch (InterruptedException e) {
+ mCameraOpenCloseLock.release();
+ throw new RuntimeException("Interrupted while setCameraPreviewSize.", e);
+ }
+ }
+}
diff --git a/ZPI-App/opencv/java/src/org/opencv/android/CameraActivity.java b/ZPI-App/opencv/java/src/org/opencv/android/CameraActivity.java
new file mode 100644
index 000000000..ea066048b
--- /dev/null
+++ b/ZPI-App/opencv/java/src/org/opencv/android/CameraActivity.java
@@ -0,0 +1,60 @@
+package org.opencv.android;
+
+import android.annotation.TargetApi;
+import android.app.Activity;
+import android.content.Context;
+import android.content.pm.PackageManager;
+import android.os.Build;
+import android.util.AttributeSet;
+import android.view.View;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import static android.Manifest.permission.CAMERA;
+
+public class CameraActivity extends Activity {
+
+ private static final int CAMERA_PERMISSION_REQUEST_CODE = 200;
+
+ protected List extends CameraBridgeViewBase> getCameraViewList() {
+ return new ArrayList();
+ }
+
+ protected void onCameraPermissionGranted() {
+ List extends CameraBridgeViewBase> cameraViews = getCameraViewList();
+ if (cameraViews == null) {
+ return;
+ }
+ for (CameraBridgeViewBase cameraBridgeViewBase: cameraViews) {
+ if (cameraBridgeViewBase != null) {
+ cameraBridgeViewBase.setCameraPermissionGranted();
+ }
+ }
+ }
+
+ @Override
+ protected void onStart() {
+ super.onStart();
+ boolean havePermission = true;
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
+ if (checkSelfPermission(CAMERA) != PackageManager.PERMISSION_GRANTED) {
+ requestPermissions(new String[]{CAMERA}, CAMERA_PERMISSION_REQUEST_CODE);
+ havePermission = false;
+ }
+ }
+ if (havePermission) {
+ onCameraPermissionGranted();
+ }
+ }
+
+ @Override
+ @TargetApi(Build.VERSION_CODES.M)
+ public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {
+ if (requestCode == CAMERA_PERMISSION_REQUEST_CODE && grantResults.length > 0
+ && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
+ onCameraPermissionGranted();
+ }
+ super.onRequestPermissionsResult(requestCode, permissions, grantResults);
+ }
+}
diff --git a/ZPI-App/opencv/java/src/org/opencv/android/CameraBridgeViewBase.java b/ZPI-App/opencv/java/src/org/opencv/android/CameraBridgeViewBase.java
new file mode 100644
index 000000000..1993cf140
--- /dev/null
+++ b/ZPI-App/opencv/java/src/org/opencv/android/CameraBridgeViewBase.java
@@ -0,0 +1,519 @@
+package org.opencv.android;
+
+import java.util.List;
+
+import org.opencv.BuildConfig;
+import org.opencv.R;
+import org.opencv.core.Mat;
+import org.opencv.core.Size;
+
+import android.app.Activity;
+import android.app.AlertDialog;
+import android.content.Context;
+import android.content.DialogInterface;
+import android.content.res.TypedArray;
+import android.graphics.Bitmap;
+import android.graphics.Canvas;
+import android.graphics.Rect;
+import android.util.AttributeSet;
+import android.util.Log;
+import android.view.SurfaceHolder;
+import android.view.SurfaceView;
+
+/**
+ * This is a basic class, implementing the interaction with Camera and OpenCV library.
+ * The main responsibility of it - is to control when camera can be enabled, process the frame,
+ * call external listener to make any adjustments to the frame and then draw the resulting
+ * frame to the screen.
+ * The clients shall implement CvCameraViewListener.
+ */
+public abstract class CameraBridgeViewBase extends SurfaceView implements SurfaceHolder.Callback {
+
+ private static final String TAG = "CameraBridge";
+ protected static final int MAX_UNSPECIFIED = -1;
+ private static final int STOPPED = 0;
+ private static final int STARTED = 1;
+
+ private int mState = STOPPED;
+ private Bitmap mCacheBitmap;
+ private CvCameraViewListener2 mListener;
+ private boolean mSurfaceExist;
+ private final Object mSyncObject = new Object();
+
+ protected int mFrameWidth;
+ protected int mFrameHeight;
+ protected int mMaxHeight;
+ protected int mMaxWidth;
+ protected float mScale = 0;
+ protected int mPreviewFormat = RGBA;
+ protected int mCameraIndex = CAMERA_ID_ANY;
+ protected boolean mEnabled;
+ protected boolean mCameraPermissionGranted = false;
+ protected FpsMeter mFpsMeter = null;
+
+ public static final int CAMERA_ID_ANY = -1;
+ public static final int CAMERA_ID_BACK = 99;
+ public static final int CAMERA_ID_FRONT = 98;
+ public static final int RGBA = 1;
+ public static final int GRAY = 2;
+
+ public CameraBridgeViewBase(Context context, int cameraId) {
+ super(context);
+ mCameraIndex = cameraId;
+ getHolder().addCallback(this);
+ mMaxWidth = MAX_UNSPECIFIED;
+ mMaxHeight = MAX_UNSPECIFIED;
+ }
+
+ public CameraBridgeViewBase(Context context, AttributeSet attrs) {
+ super(context, attrs);
+
+ int count = attrs.getAttributeCount();
+ Log.d(TAG, "Attr count: " + Integer.valueOf(count));
+
+ TypedArray styledAttrs = getContext().obtainStyledAttributes(attrs, R.styleable.CameraBridgeViewBase);
+ if (styledAttrs.getBoolean(R.styleable.CameraBridgeViewBase_show_fps, false))
+ enableFpsMeter();
+
+ mCameraIndex = styledAttrs.getInt(R.styleable.CameraBridgeViewBase_camera_id, -1);
+
+ getHolder().addCallback(this);
+ mMaxWidth = MAX_UNSPECIFIED;
+ mMaxHeight = MAX_UNSPECIFIED;
+ styledAttrs.recycle();
+ }
+
+ /**
+ * Sets the camera index
+ * @param cameraIndex new camera index
+ */
+ public void setCameraIndex(int cameraIndex) {
+ this.mCameraIndex = cameraIndex;
+ }
+
+ public interface CvCameraViewListener {
+ /**
+ * This method is invoked when camera preview has started. After this method is invoked
+ * the frames will start to be delivered to client via the onCameraFrame() callback.
+ * @param width - the width of the frames that will be delivered
+ * @param height - the height of the frames that will be delivered
+ */
+ public void onCameraViewStarted(int width, int height);
+
+ /**
+ * This method is invoked when camera preview has been stopped for some reason.
+ * No frames will be delivered via onCameraFrame() callback after this method is called.
+ */
+ public void onCameraViewStopped();
+
+ /**
+ * This method is invoked when delivery of the frame needs to be done.
+ * The returned values - is a modified frame which needs to be displayed on the screen.
+ * TODO: pass the parameters specifying the format of the frame (BPP, YUV or RGB and etc)
+ */
+ public Mat onCameraFrame(Mat inputFrame);
+ }
+
+ public interface CvCameraViewListener2 {
+ /**
+ * This method is invoked when camera preview has started. After this method is invoked
+ * the frames will start to be delivered to client via the onCameraFrame() callback.
+ * @param width - the width of the frames that will be delivered
+ * @param height - the height of the frames that will be delivered
+ */
+ public void onCameraViewStarted(int width, int height);
+
+ /**
+ * This method is invoked when camera preview has been stopped for some reason.
+ * No frames will be delivered via onCameraFrame() callback after this method is called.
+ */
+ public void onCameraViewStopped();
+
+ /**
+ * This method is invoked when delivery of the frame needs to be done.
+ * The returned values - is a modified frame which needs to be displayed on the screen.
+ * TODO: pass the parameters specifying the format of the frame (BPP, YUV or RGB and etc)
+ */
+ public Mat onCameraFrame(CvCameraViewFrame inputFrame);
+ };
+
+ protected class CvCameraViewListenerAdapter implements CvCameraViewListener2 {
+ public CvCameraViewListenerAdapter(CvCameraViewListener oldStypeListener) {
+ mOldStyleListener = oldStypeListener;
+ }
+
+ public void onCameraViewStarted(int width, int height) {
+ mOldStyleListener.onCameraViewStarted(width, height);
+ }
+
+ public void onCameraViewStopped() {
+ mOldStyleListener.onCameraViewStopped();
+ }
+
+ public Mat onCameraFrame(CvCameraViewFrame inputFrame) {
+ Mat result = null;
+ switch (mPreviewFormat) {
+ case RGBA:
+ result = mOldStyleListener.onCameraFrame(inputFrame.rgba());
+ break;
+ case GRAY:
+ result = mOldStyleListener.onCameraFrame(inputFrame.gray());
+ break;
+ default:
+ Log.e(TAG, "Invalid frame format! Only RGBA and Gray Scale are supported!");
+ };
+
+ return result;
+ }
+
+ public void setFrameFormat(int format) {
+ mPreviewFormat = format;
+ }
+
+ private int mPreviewFormat = RGBA;
+ private CvCameraViewListener mOldStyleListener;
+ };
+
+ /**
+ * This class interface is abstract representation of single frame from camera for onCameraFrame callback
+ * Attention: Do not use objects, that represents this interface out of onCameraFrame callback!
+ */
+ public interface CvCameraViewFrame {
+
+ /**
+ * This method returns RGBA Mat with frame
+ */
+ public Mat rgba();
+
+ /**
+ * This method returns single channel gray scale Mat with frame
+ */
+ public Mat gray();
+ };
+
+ public void surfaceChanged(SurfaceHolder arg0, int arg1, int arg2, int arg3) {
+ Log.d(TAG, "call surfaceChanged event");
+ synchronized(mSyncObject) {
+ if (!mSurfaceExist) {
+ mSurfaceExist = true;
+ checkCurrentState();
+ } else {
+ /** Surface changed. We need to stop camera and restart with new parameters */
+ /* Pretend that old surface has been destroyed */
+ mSurfaceExist = false;
+ checkCurrentState();
+ /* Now use new surface. Say we have it now */
+ mSurfaceExist = true;
+ checkCurrentState();
+ }
+ }
+ }
+
+ public void surfaceCreated(SurfaceHolder holder) {
+ /* Do nothing. Wait until surfaceChanged delivered */
+ }
+
+ public void surfaceDestroyed(SurfaceHolder holder) {
+ synchronized(mSyncObject) {
+ mSurfaceExist = false;
+ checkCurrentState();
+ }
+ }
+
+
+ /**
+ * This method is provided for clients, so they can signal camera permission has been granted.
+ * The actual onCameraViewStarted callback will be delivered only after setCameraPermissionGranted
+ * and enableView have been called and surface is available
+ */
+ public void setCameraPermissionGranted() {
+ synchronized(mSyncObject) {
+ mCameraPermissionGranted = true;
+ checkCurrentState();
+ }
+ }
+
+
+ /**
+ * This method is provided for clients, so they can enable the camera connection.
+ * The actual onCameraViewStarted callback will be delivered only after setCameraPermissionGranted
+ * and enableView have been called and surface is available
+ */
+ public void enableView() {
+ synchronized(mSyncObject) {
+ mEnabled = true;
+ checkCurrentState();
+ }
+ }
+
+ /**
+ * This method is provided for clients, so they can disable camera connection and stop
+ * the delivery of frames even though the surface view itself is not destroyed and still stays on the screen
+ */
+ public void disableView() {
+ synchronized(mSyncObject) {
+ mEnabled = false;
+ checkCurrentState();
+ }
+ }
+
+ /**
+ * This method enables label with fps value on the screen
+ */
+ public void enableFpsMeter() {
+ if (mFpsMeter == null) {
+ mFpsMeter = new FpsMeter();
+ mFpsMeter.setResolution(mFrameWidth, mFrameHeight);
+ }
+ }
+
+ public void disableFpsMeter() {
+ mFpsMeter = null;
+ }
+
+ /**
+ *
+ * @param listener
+ */
+
+ public void setCvCameraViewListener(CvCameraViewListener2 listener) {
+ mListener = listener;
+ }
+
+ public void setCvCameraViewListener(CvCameraViewListener listener) {
+ CvCameraViewListenerAdapter adapter = new CvCameraViewListenerAdapter(listener);
+ adapter.setFrameFormat(mPreviewFormat);
+ mListener = adapter;
+ }
+
+ /**
+ * This method sets the maximum size that camera frame is allowed to be. When selecting
+ * size - the biggest size which less or equal the size set will be selected.
+ * As an example - we set setMaxFrameSize(200,200) and we have 176x152 and 320x240 sizes. The
+ * preview frame will be selected with 176x152 size.
+ * This method is useful when need to restrict the size of preview frame for some reason (for example for video recording)
+ * @param maxWidth - the maximum width allowed for camera frame.
+ * @param maxHeight - the maximum height allowed for camera frame
+ */
+ public void setMaxFrameSize(int maxWidth, int maxHeight) {
+ mMaxWidth = maxWidth;
+ mMaxHeight = maxHeight;
+ }
+
+ public void SetCaptureFormat(int format)
+ {
+ mPreviewFormat = format;
+ if (mListener instanceof CvCameraViewListenerAdapter) {
+ CvCameraViewListenerAdapter adapter = (CvCameraViewListenerAdapter) mListener;
+ adapter.setFrameFormat(mPreviewFormat);
+ }
+ }
+
+ /**
+ * Called when mSyncObject lock is held
+ */
+ private void checkCurrentState() {
+ Log.d(TAG, "call checkCurrentState");
+ int targetState;
+
+ if (mEnabled && mCameraPermissionGranted && mSurfaceExist && getVisibility() == VISIBLE) {
+ targetState = STARTED;
+ } else {
+ targetState = STOPPED;
+ }
+
+ if (targetState != mState) {
+ /* The state change detected. Need to exit the current state and enter target state */
+ processExitState(mState);
+ mState = targetState;
+ processEnterState(mState);
+ }
+ }
+
+ private void processEnterState(int state) {
+ Log.d(TAG, "call processEnterState: " + state);
+ switch(state) {
+ case STARTED:
+ onEnterStartedState();
+ if (mListener != null) {
+ mListener.onCameraViewStarted(mFrameWidth, mFrameHeight);
+ }
+ break;
+ case STOPPED:
+ onEnterStoppedState();
+ if (mListener != null) {
+ mListener.onCameraViewStopped();
+ }
+ break;
+ };
+ }
+
+ private void processExitState(int state) {
+ Log.d(TAG, "call processExitState: " + state);
+ switch(state) {
+ case STARTED:
+ onExitStartedState();
+ break;
+ case STOPPED:
+ onExitStoppedState();
+ break;
+ };
+ }
+
+ private void onEnterStoppedState() {
+ /* nothing to do */
+ }
+
+ private void onExitStoppedState() {
+ /* nothing to do */
+ }
+
+ // NOTE: The order of bitmap constructor and camera connection is important for android 4.1.x
+ // Bitmap must be constructed before surface
+ private void onEnterStartedState() {
+ Log.d(TAG, "call onEnterStartedState");
+ /* Connect camera */
+ if (!connectCamera(getWidth(), getHeight())) {
+ AlertDialog ad = new AlertDialog.Builder(getContext()).create();
+ ad.setCancelable(false); // This blocks the 'BACK' button
+ ad.setMessage("It seems that your device does not support camera (or it is locked). Application will be closed.");
+ ad.setButton(DialogInterface.BUTTON_NEUTRAL, "OK", new DialogInterface.OnClickListener() {
+ public void onClick(DialogInterface dialog, int which) {
+ dialog.dismiss();
+ ((Activity) getContext()).finish();
+ }
+ });
+ ad.show();
+
+ }
+ }
+
+ private void onExitStartedState() {
+ disconnectCamera();
+ if (mCacheBitmap != null) {
+ mCacheBitmap.recycle();
+ }
+ }
+
+ /**
+ * This method shall be called by the subclasses when they have valid
+ * object and want it to be delivered to external client (via callback) and
+ * then displayed on the screen.
+ * @param frame - the current frame to be delivered
+ */
+ protected void deliverAndDrawFrame(CvCameraViewFrame frame) {
+ Mat modified;
+
+ if (mListener != null) {
+ modified = mListener.onCameraFrame(frame);
+ } else {
+ modified = frame.rgba();
+ }
+
+ boolean bmpValid = true;
+ if (modified != null) {
+ try {
+ Utils.matToBitmap(modified, mCacheBitmap);
+ } catch(Exception e) {
+ Log.e(TAG, "Mat type: " + modified);
+ Log.e(TAG, "Bitmap type: " + mCacheBitmap.getWidth() + "*" + mCacheBitmap.getHeight());
+ Log.e(TAG, "Utils.matToBitmap() throws an exception: " + e.getMessage());
+ bmpValid = false;
+ }
+ }
+
+ if (bmpValid && mCacheBitmap != null) {
+ Canvas canvas = getHolder().lockCanvas();
+ if (canvas != null) {
+ canvas.drawColor(0, android.graphics.PorterDuff.Mode.CLEAR);
+ if (BuildConfig.DEBUG)
+ Log.d(TAG, "mStretch value: " + mScale);
+
+ if (mScale != 0) {
+ canvas.drawBitmap(mCacheBitmap, new Rect(0,0,mCacheBitmap.getWidth(), mCacheBitmap.getHeight()),
+ new Rect((int)((canvas.getWidth() - mScale*mCacheBitmap.getWidth()) / 2),
+ (int)((canvas.getHeight() - mScale*mCacheBitmap.getHeight()) / 2),
+ (int)((canvas.getWidth() - mScale*mCacheBitmap.getWidth()) / 2 + mScale*mCacheBitmap.getWidth()),
+ (int)((canvas.getHeight() - mScale*mCacheBitmap.getHeight()) / 2 + mScale*mCacheBitmap.getHeight())), null);
+ } else {
+ canvas.drawBitmap(mCacheBitmap, new Rect(0,0,mCacheBitmap.getWidth(), mCacheBitmap.getHeight()),
+ new Rect((canvas.getWidth() - mCacheBitmap.getWidth()) / 2,
+ (canvas.getHeight() - mCacheBitmap.getHeight()) / 2,
+ (canvas.getWidth() - mCacheBitmap.getWidth()) / 2 + mCacheBitmap.getWidth(),
+ (canvas.getHeight() - mCacheBitmap.getHeight()) / 2 + mCacheBitmap.getHeight()), null);
+ }
+
+ if (mFpsMeter != null) {
+ mFpsMeter.measure();
+ mFpsMeter.draw(canvas, 20, 30);
+ }
+ getHolder().unlockCanvasAndPost(canvas);
+ }
+ }
+ }
+
+ /**
+ * This method is invoked shall perform concrete operation to initialize the camera.
+ * CONTRACT: as a result of this method variables mFrameWidth and mFrameHeight MUST be
+ * initialized with the size of the Camera frames that will be delivered to external processor.
+ * @param width - the width of this SurfaceView
+ * @param height - the height of this SurfaceView
+ */
+ protected abstract boolean connectCamera(int width, int height);
+
+ /**
+ * Disconnects and release the particular camera object being connected to this surface view.
+ * Called when syncObject lock is held
+ */
+ protected abstract void disconnectCamera();
+
+ // NOTE: On Android 4.1.x the function must be called before SurfaceTexture constructor!
+ protected void AllocateCache()
+ {
+ mCacheBitmap = Bitmap.createBitmap(mFrameWidth, mFrameHeight, Bitmap.Config.ARGB_8888);
+ }
+
+ public interface ListItemAccessor {
+ public int getWidth(Object obj);
+ public int getHeight(Object obj);
+ };
+
+ /**
+ * This helper method can be called by subclasses to select camera preview size.
+ * It goes over the list of the supported preview sizes and selects the maximum one which
+ * fits both values set via setMaxFrameSize() and surface frame allocated for this view
+ * @param supportedSizes
+ * @param surfaceWidth
+ * @param surfaceHeight
+ * @return optimal frame size
+ */
+ protected Size calculateCameraFrameSize(List> supportedSizes, ListItemAccessor accessor, int surfaceWidth, int surfaceHeight) {
+ int calcWidth = 0;
+ int calcHeight = 0;
+
+ int maxAllowedWidth = (mMaxWidth != MAX_UNSPECIFIED && mMaxWidth < surfaceWidth)? mMaxWidth : surfaceWidth;
+ int maxAllowedHeight = (mMaxHeight != MAX_UNSPECIFIED && mMaxHeight < surfaceHeight)? mMaxHeight : surfaceHeight;
+
+ for (Object size : supportedSizes) {
+ int width = accessor.getWidth(size);
+ int height = accessor.getHeight(size);
+ Log.d(TAG, "trying size: " + width + "x" + height);
+
+ if (width <= maxAllowedWidth && height <= maxAllowedHeight) {
+ if (width >= calcWidth && height >= calcHeight) {
+ calcWidth = (int) width;
+ calcHeight = (int) height;
+ }
+ }
+ }
+ if ((calcWidth == 0 || calcHeight == 0) && supportedSizes.size() > 0)
+ {
+ Log.i(TAG, "fallback to the first frame size");
+ Object size = supportedSizes.get(0);
+ calcWidth = accessor.getWidth(size);
+ calcHeight = accessor.getHeight(size);
+ }
+
+ return new Size(calcWidth, calcHeight);
+ }
+}
diff --git a/ZPI-App/opencv/java/src/org/opencv/android/CameraGLRendererBase.java b/ZPI-App/opencv/java/src/org/opencv/android/CameraGLRendererBase.java
new file mode 100644
index 000000000..60c37c304
--- /dev/null
+++ b/ZPI-App/opencv/java/src/org/opencv/android/CameraGLRendererBase.java
@@ -0,0 +1,440 @@
+package org.opencv.android;
+
+import java.nio.ByteBuffer;
+import java.nio.ByteOrder;
+import java.nio.FloatBuffer;
+
+import javax.microedition.khronos.egl.EGLConfig;
+import javax.microedition.khronos.opengles.GL10;
+
+import org.opencv.android.CameraGLSurfaceView.CameraTextureListener;
+
+import android.annotation.TargetApi;
+import android.graphics.SurfaceTexture;
+import android.opengl.GLES11Ext;
+import android.opengl.GLES20;
+import android.opengl.GLSurfaceView;
+import android.util.Log;
+import android.view.View;
+
+@TargetApi(15)
+public abstract class CameraGLRendererBase implements GLSurfaceView.Renderer, SurfaceTexture.OnFrameAvailableListener {
+
+ protected final String LOGTAG = "CameraGLRendererBase";
+
+ // shaders
+ private final String vss = ""
+ + "attribute vec2 vPosition;\n"
+ + "attribute vec2 vTexCoord;\n" + "varying vec2 texCoord;\n"
+ + "void main() {\n" + " texCoord = vTexCoord;\n"
+ + " gl_Position = vec4 ( vPosition.x, vPosition.y, 0.0, 1.0 );\n"
+ + "}";
+
+ private final String fssOES = ""
+ + "#extension GL_OES_EGL_image_external : require\n"
+ + "precision mediump float;\n"
+ + "uniform samplerExternalOES sTexture;\n"
+ + "varying vec2 texCoord;\n"
+ + "void main() {\n"
+ + " gl_FragColor = texture2D(sTexture,texCoord);\n" + "}";
+
+ private final String fss2D = ""
+ + "precision mediump float;\n"
+ + "uniform sampler2D sTexture;\n"
+ + "varying vec2 texCoord;\n"
+ + "void main() {\n"
+ + " gl_FragColor = texture2D(sTexture,texCoord);\n" + "}";
+
+ // coord-s
+ private final float vertices[] = {
+ -1, -1,
+ -1, 1,
+ 1, -1,
+ 1, 1 };
+ private final float texCoordOES[] = {
+ 0, 1,
+ 0, 0,
+ 1, 1,
+ 1, 0 };
+ private final float texCoord2D[] = {
+ 0, 0,
+ 0, 1,
+ 1, 0,
+ 1, 1 };
+
+ private int[] texCamera = {0}, texFBO = {0}, texDraw = {0};
+ private int[] FBO = {0};
+ private int progOES = -1, prog2D = -1;
+ private int vPosOES, vTCOES, vPos2D, vTC2D;
+
+ private FloatBuffer vert, texOES, tex2D;
+
+ protected int mCameraWidth = -1, mCameraHeight = -1;
+ protected int mFBOWidth = -1, mFBOHeight = -1;
+ protected int mMaxCameraWidth = -1, mMaxCameraHeight = -1;
+ protected int mCameraIndex = CameraBridgeViewBase.CAMERA_ID_ANY;
+
+ protected SurfaceTexture mSTexture;
+
+ protected boolean mHaveSurface = false;
+ protected boolean mHaveFBO = false;
+ protected boolean mUpdateST = false;
+ protected boolean mEnabled = true;
+ protected boolean mIsStarted = false;
+
+ protected CameraGLSurfaceView mView;
+
+ protected abstract void openCamera(int id);
+ protected abstract void closeCamera();
+ protected abstract void setCameraPreviewSize(int width, int height); // updates mCameraWidth & mCameraHeight
+
+ public CameraGLRendererBase(CameraGLSurfaceView view) {
+ mView = view;
+ int bytes = vertices.length * Float.SIZE / Byte.SIZE;
+ vert = ByteBuffer.allocateDirect(bytes).order(ByteOrder.nativeOrder()).asFloatBuffer();
+ texOES = ByteBuffer.allocateDirect(bytes).order(ByteOrder.nativeOrder()).asFloatBuffer();
+ tex2D = ByteBuffer.allocateDirect(bytes).order(ByteOrder.nativeOrder()).asFloatBuffer();
+ vert.put(vertices).position(0);
+ texOES.put(texCoordOES).position(0);
+ tex2D.put(texCoord2D).position(0);
+ }
+
+ @Override
+ public synchronized void onFrameAvailable(SurfaceTexture surfaceTexture) {
+ //Log.i(LOGTAG, "onFrameAvailable");
+ mUpdateST = true;
+ mView.requestRender();
+ }
+
+ @Override
+ public void onDrawFrame(GL10 gl) {
+ //Log.i(LOGTAG, "onDrawFrame start");
+
+ if (!mHaveFBO)
+ return;
+
+ synchronized(this) {
+ if (mUpdateST) {
+ mSTexture.updateTexImage();
+ mUpdateST = false;
+ }
+
+ GLES20.glClear(GLES20.GL_COLOR_BUFFER_BIT);
+
+ CameraTextureListener texListener = mView.getCameraTextureListener();
+ if(texListener != null) {
+ //Log.d(LOGTAG, "haveUserCallback");
+ // texCamera(OES) -> texFBO
+ drawTex(texCamera[0], true, FBO[0]);
+
+ // call user code (texFBO -> texDraw)
+ boolean modified = texListener.onCameraTexture(texFBO[0], texDraw[0], mCameraWidth, mCameraHeight);
+
+ if(modified) {
+ // texDraw -> screen
+ drawTex(texDraw[0], false, 0);
+ } else {
+ // texFBO -> screen
+ drawTex(texFBO[0], false, 0);
+ }
+ } else {
+ Log.d(LOGTAG, "texCamera(OES) -> screen");
+ // texCamera(OES) -> screen
+ drawTex(texCamera[0], true, 0);
+ }
+ //Log.i(LOGTAG, "onDrawFrame end");
+ }
+ }
+
+ @Override
+ public void onSurfaceChanged(GL10 gl, int surfaceWidth, int surfaceHeight) {
+ Log.i(LOGTAG, "onSurfaceChanged("+surfaceWidth+"x"+surfaceHeight+")");
+ mHaveSurface = true;
+ updateState();
+ setPreviewSize(surfaceWidth, surfaceHeight);
+ }
+
+ @Override
+ public void onSurfaceCreated(GL10 gl, EGLConfig config) {
+ Log.i(LOGTAG, "onSurfaceCreated");
+ initShaders();
+ }
+
+ private void initShaders() {
+ String strGLVersion = GLES20.glGetString(GLES20.GL_VERSION);
+ if (strGLVersion != null)
+ Log.i(LOGTAG, "OpenGL ES version: " + strGLVersion);
+
+ GLES20.glClearColor(1.0f, 1.0f, 1.0f, 1.0f);
+
+ progOES = loadShader(vss, fssOES);
+ vPosOES = GLES20.glGetAttribLocation(progOES, "vPosition");
+ vTCOES = GLES20.glGetAttribLocation(progOES, "vTexCoord");
+ GLES20.glEnableVertexAttribArray(vPosOES);
+ GLES20.glEnableVertexAttribArray(vTCOES);
+
+ prog2D = loadShader(vss, fss2D);
+ vPos2D = GLES20.glGetAttribLocation(prog2D, "vPosition");
+ vTC2D = GLES20.glGetAttribLocation(prog2D, "vTexCoord");
+ GLES20.glEnableVertexAttribArray(vPos2D);
+ GLES20.glEnableVertexAttribArray(vTC2D);
+ }
+
+ private void initSurfaceTexture() {
+ Log.d(LOGTAG, "initSurfaceTexture");
+ deleteSurfaceTexture();
+ initTexOES(texCamera);
+ mSTexture = new SurfaceTexture(texCamera[0]);
+ mSTexture.setOnFrameAvailableListener(this);
+ }
+
+ private void deleteSurfaceTexture() {
+ Log.d(LOGTAG, "deleteSurfaceTexture");
+ if(mSTexture != null) {
+ mSTexture.release();
+ mSTexture = null;
+ deleteTex(texCamera);
+ }
+ }
+
+ private void initTexOES(int[] tex) {
+ if(tex.length == 1) {
+ GLES20.glGenTextures(1, tex, 0);
+ GLES20.glBindTexture(GLES11Ext.GL_TEXTURE_EXTERNAL_OES, tex[0]);
+ GLES20.glTexParameteri(GLES11Ext.GL_TEXTURE_EXTERNAL_OES, GLES20.GL_TEXTURE_WRAP_S, GLES20.GL_CLAMP_TO_EDGE);
+ GLES20.glTexParameteri(GLES11Ext.GL_TEXTURE_EXTERNAL_OES, GLES20.GL_TEXTURE_WRAP_T, GLES20.GL_CLAMP_TO_EDGE);
+ GLES20.glTexParameteri(GLES11Ext.GL_TEXTURE_EXTERNAL_OES, GLES20.GL_TEXTURE_MIN_FILTER, GLES20.GL_NEAREST);
+ GLES20.glTexParameteri(GLES11Ext.GL_TEXTURE_EXTERNAL_OES, GLES20.GL_TEXTURE_MAG_FILTER, GLES20.GL_NEAREST);
+ }
+ }
+
+ private static void deleteTex(int[] tex) {
+ if(tex.length == 1) {
+ GLES20.glDeleteTextures(1, tex, 0);
+ }
+ }
+
+ private static int loadShader(String vss, String fss) {
+ Log.d("CameraGLRendererBase", "loadShader");
+ int vshader = GLES20.glCreateShader(GLES20.GL_VERTEX_SHADER);
+ GLES20.glShaderSource(vshader, vss);
+ GLES20.glCompileShader(vshader);
+ int[] status = new int[1];
+ GLES20.glGetShaderiv(vshader, GLES20.GL_COMPILE_STATUS, status, 0);
+ if (status[0] == 0) {
+ Log.e("CameraGLRendererBase", "Could not compile vertex shader: "+GLES20.glGetShaderInfoLog(vshader));
+ GLES20.glDeleteShader(vshader);
+ vshader = 0;
+ return 0;
+ }
+
+ int fshader = GLES20.glCreateShader(GLES20.GL_FRAGMENT_SHADER);
+ GLES20.glShaderSource(fshader, fss);
+ GLES20.glCompileShader(fshader);
+ GLES20.glGetShaderiv(fshader, GLES20.GL_COMPILE_STATUS, status, 0);
+ if (status[0] == 0) {
+ Log.e("CameraGLRendererBase", "Could not compile fragment shader:"+GLES20.glGetShaderInfoLog(fshader));
+ GLES20.glDeleteShader(vshader);
+ GLES20.glDeleteShader(fshader);
+ fshader = 0;
+ return 0;
+ }
+
+ int program = GLES20.glCreateProgram();
+ GLES20.glAttachShader(program, vshader);
+ GLES20.glAttachShader(program, fshader);
+ GLES20.glLinkProgram(program);
+ GLES20.glDeleteShader(vshader);
+ GLES20.glDeleteShader(fshader);
+ GLES20.glGetProgramiv(program, GLES20.GL_LINK_STATUS, status, 0);
+ if (status[0] == 0) {
+ Log.e("CameraGLRendererBase", "Could not link shader program: "+GLES20.glGetProgramInfoLog(program));
+ program = 0;
+ return 0;
+ }
+ GLES20.glValidateProgram(program);
+ GLES20.glGetProgramiv(program, GLES20.GL_VALIDATE_STATUS, status, 0);
+ if (status[0] == 0)
+ {
+ Log.e("CameraGLRendererBase", "Shader program validation error: "+GLES20.glGetProgramInfoLog(program));
+ GLES20.glDeleteProgram(program);
+ program = 0;
+ return 0;
+ }
+
+ Log.d("CameraGLRendererBase", "Shader program is built OK");
+
+ return program;
+ }
+
+ private void deleteFBO()
+ {
+ Log.d(LOGTAG, "deleteFBO("+mFBOWidth+"x"+mFBOHeight+")");
+ GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER, 0);
+ GLES20.glDeleteFramebuffers(1, FBO, 0);
+
+ deleteTex(texFBO);
+ deleteTex(texDraw);
+ mFBOWidth = mFBOHeight = 0;
+ }
+
+ private void initFBO(int width, int height)
+ {
+ Log.d(LOGTAG, "initFBO("+width+"x"+height+")");
+
+ deleteFBO();
+
+ GLES20.glGenTextures(1, texDraw, 0);
+ GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, texDraw[0]);
+ GLES20.glTexImage2D(GLES20.GL_TEXTURE_2D, 0, GLES20.GL_RGBA, width, height, 0, GLES20.GL_RGBA, GLES20.GL_UNSIGNED_BYTE, null);
+ GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_WRAP_S, GLES20.GL_CLAMP_TO_EDGE);
+ GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_WRAP_T, GLES20.GL_CLAMP_TO_EDGE);
+ GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_MIN_FILTER, GLES20.GL_NEAREST);
+ GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_MAG_FILTER, GLES20.GL_NEAREST);
+
+ GLES20.glGenTextures(1, texFBO, 0);
+ GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, texFBO[0]);
+ GLES20.glTexImage2D(GLES20.GL_TEXTURE_2D, 0, GLES20.GL_RGBA, width, height, 0, GLES20.GL_RGBA, GLES20.GL_UNSIGNED_BYTE, null);
+ GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_WRAP_S, GLES20.GL_CLAMP_TO_EDGE);
+ GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_WRAP_T, GLES20.GL_CLAMP_TO_EDGE);
+ GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_MIN_FILTER, GLES20.GL_NEAREST);
+ GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_MAG_FILTER, GLES20.GL_NEAREST);
+
+ //int hFBO;
+ GLES20.glGenFramebuffers(1, FBO, 0);
+ GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER, FBO[0]);
+ GLES20.glFramebufferTexture2D(GLES20.GL_FRAMEBUFFER, GLES20.GL_COLOR_ATTACHMENT0, GLES20.GL_TEXTURE_2D, texFBO[0], 0);
+ Log.d(LOGTAG, "initFBO error status: " + GLES20.glGetError());
+
+ int FBOstatus = GLES20.glCheckFramebufferStatus(GLES20.GL_FRAMEBUFFER);
+ if (FBOstatus != GLES20.GL_FRAMEBUFFER_COMPLETE)
+ Log.e(LOGTAG, "initFBO failed, status: " + FBOstatus);
+
+ mFBOWidth = width;
+ mFBOHeight = height;
+ }
+
+ // draw texture to FBO or to screen if fbo == 0
+ private void drawTex(int tex, boolean isOES, int fbo)
+ {
+ GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER, fbo);
+
+ if(fbo == 0)
+ GLES20.glViewport(0, 0, mView.getWidth(), mView.getHeight());
+ else
+ GLES20.glViewport(0, 0, mFBOWidth, mFBOHeight);
+
+ GLES20.glClear(GLES20.GL_COLOR_BUFFER_BIT);
+
+ if(isOES) {
+ GLES20.glUseProgram(progOES);
+ GLES20.glVertexAttribPointer(vPosOES, 2, GLES20.GL_FLOAT, false, 4*2, vert);
+ GLES20.glVertexAttribPointer(vTCOES, 2, GLES20.GL_FLOAT, false, 4*2, texOES);
+ } else {
+ GLES20.glUseProgram(prog2D);
+ GLES20.glVertexAttribPointer(vPos2D, 2, GLES20.GL_FLOAT, false, 4*2, vert);
+ GLES20.glVertexAttribPointer(vTC2D, 2, GLES20.GL_FLOAT, false, 4*2, tex2D);
+ }
+
+ GLES20.glActiveTexture(GLES20.GL_TEXTURE0);
+
+ if(isOES) {
+ GLES20.glBindTexture(GLES11Ext.GL_TEXTURE_EXTERNAL_OES, tex);
+ GLES20.glUniform1i(GLES20.glGetUniformLocation(progOES, "sTexture"), 0);
+ } else {
+ GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, tex);
+ GLES20.glUniform1i(GLES20.glGetUniformLocation(prog2D, "sTexture"), 0);
+ }
+
+ GLES20.glDrawArrays(GLES20.GL_TRIANGLE_STRIP, 0, 4);
+ GLES20.glFlush();
+ }
+
+ public synchronized void enableView() {
+ Log.d(LOGTAG, "enableView");
+ mEnabled = true;
+ updateState();
+ }
+
+ public synchronized void disableView() {
+ Log.d(LOGTAG, "disableView");
+ mEnabled = false;
+ updateState();
+ }
+
+ protected void updateState() {
+ Log.d(LOGTAG, "updateState");
+ Log.d(LOGTAG, "mEnabled="+mEnabled+", mHaveSurface="+mHaveSurface);
+ boolean willStart = mEnabled && mHaveSurface && mView.getVisibility() == View.VISIBLE;
+ if (willStart != mIsStarted) {
+ if(willStart) doStart();
+ else doStop();
+ } else {
+ Log.d(LOGTAG, "keeping State unchanged");
+ }
+ Log.d(LOGTAG, "updateState end");
+ }
+
+ protected synchronized void doStart() {
+ Log.d(LOGTAG, "doStart");
+ initSurfaceTexture();
+ openCamera(mCameraIndex);
+ mIsStarted = true;
+ if(mCameraWidth>0 && mCameraHeight>0)
+ setPreviewSize(mCameraWidth, mCameraHeight); // start preview and call listener.onCameraViewStarted()
+ }
+
+
+ protected void doStop() {
+ Log.d(LOGTAG, "doStop");
+ synchronized(this) {
+ mUpdateST = false;
+ mIsStarted = false;
+ mHaveFBO = false;
+ closeCamera();
+ deleteSurfaceTexture();
+ }
+ CameraTextureListener listener = mView.getCameraTextureListener();
+ if(listener != null) listener.onCameraViewStopped();
+
+ }
+
+ protected void setPreviewSize(int width, int height) {
+ synchronized(this) {
+ mHaveFBO = false;
+ mCameraWidth = width;
+ mCameraHeight = height;
+ setCameraPreviewSize(width, height); // can change mCameraWidth & mCameraHeight
+ initFBO(mCameraWidth, mCameraHeight);
+ mHaveFBO = true;
+ }
+
+ CameraTextureListener listener = mView.getCameraTextureListener();
+ if(listener != null) listener.onCameraViewStarted(mCameraWidth, mCameraHeight);
+ }
+
+ public void setCameraIndex(int cameraIndex) {
+ disableView();
+ mCameraIndex = cameraIndex;
+ enableView();
+ }
+
+ public void setMaxCameraPreviewSize(int maxWidth, int maxHeight) {
+ disableView();
+ mMaxCameraWidth = maxWidth;
+ mMaxCameraHeight = maxHeight;
+ enableView();
+ }
+
+ public void onResume() {
+ Log.i(LOGTAG, "onResume");
+ }
+
+ public void onPause() {
+ Log.i(LOGTAG, "onPause");
+ mHaveSurface = false;
+ updateState();
+ mCameraWidth = mCameraHeight = -1;
+ }
+
+}
diff --git a/ZPI-App/opencv/java/src/org/opencv/android/CameraGLSurfaceView.java b/ZPI-App/opencv/java/src/org/opencv/android/CameraGLSurfaceView.java
new file mode 100644
index 000000000..05f950b47
--- /dev/null
+++ b/ZPI-App/opencv/java/src/org/opencv/android/CameraGLSurfaceView.java
@@ -0,0 +1,119 @@
+package org.opencv.android;
+
+import org.opencv.R;
+
+import android.content.Context;
+import android.content.res.TypedArray;
+import android.opengl.GLSurfaceView;
+import android.util.AttributeSet;
+import android.util.Log;
+import android.view.SurfaceHolder;
+
+public class CameraGLSurfaceView extends GLSurfaceView {
+
+ private static final String LOGTAG = "CameraGLSurfaceView";
+
+ public interface CameraTextureListener {
+ /**
+ * This method is invoked when camera preview has started. After this method is invoked
+ * the frames will start to be delivered to client via the onCameraFrame() callback.
+ * @param width - the width of the frames that will be delivered
+ * @param height - the height of the frames that will be delivered
+ */
+ public void onCameraViewStarted(int width, int height);
+
+ /**
+ * This method is invoked when camera preview has been stopped for some reason.
+ * No frames will be delivered via onCameraFrame() callback after this method is called.
+ */
+ public void onCameraViewStopped();
+
+ /**
+ * This method is invoked when a new preview frame from Camera is ready.
+ * @param texIn - the OpenGL texture ID that contains frame in RGBA format
+ * @param texOut - the OpenGL texture ID that can be used to store modified frame image t display
+ * @param width - the width of the frame
+ * @param height - the height of the frame
+ * @return `true` if `texOut` should be displayed, `false` - to show `texIn`
+ */
+ public boolean onCameraTexture(int texIn, int texOut, int width, int height);
+ };
+
+ private CameraTextureListener mTexListener;
+ private CameraGLRendererBase mRenderer;
+
+ public CameraGLSurfaceView(Context context, AttributeSet attrs) {
+ super(context, attrs);
+
+ TypedArray styledAttrs = getContext().obtainStyledAttributes(attrs, R.styleable.CameraBridgeViewBase);
+ int cameraIndex = styledAttrs.getInt(R.styleable.CameraBridgeViewBase_camera_id, -1);
+ styledAttrs.recycle();
+
+ if(android.os.Build.VERSION.SDK_INT >= 21)
+ mRenderer = new Camera2Renderer(this);
+ else
+ mRenderer = new CameraRenderer(this);
+
+ setCameraIndex(cameraIndex);
+
+ setEGLContextClientVersion(2);
+ setRenderer(mRenderer);
+ setRenderMode(GLSurfaceView.RENDERMODE_WHEN_DIRTY);
+ }
+
+ public void setCameraTextureListener(CameraTextureListener texListener)
+ {
+ mTexListener = texListener;
+ }
+
+ public CameraTextureListener getCameraTextureListener()
+ {
+ return mTexListener;
+ }
+
+ public void setCameraIndex(int cameraIndex) {
+ mRenderer.setCameraIndex(cameraIndex);
+ }
+
+ public void setMaxCameraPreviewSize(int maxWidth, int maxHeight) {
+ mRenderer.setMaxCameraPreviewSize(maxWidth, maxHeight);
+ }
+
+ @Override
+ public void surfaceCreated(SurfaceHolder holder) {
+ super.surfaceCreated(holder);
+ }
+
+ @Override
+ public void surfaceDestroyed(SurfaceHolder holder) {
+ mRenderer.mHaveSurface = false;
+ super.surfaceDestroyed(holder);
+ }
+
+ @Override
+ public void surfaceChanged(SurfaceHolder holder, int format, int w, int h) {
+ super.surfaceChanged(holder, format, w, h);
+ }
+
+ @Override
+ public void onResume() {
+ Log.i(LOGTAG, "onResume");
+ super.onResume();
+ mRenderer.onResume();
+ }
+
+ @Override
+ public void onPause() {
+ Log.i(LOGTAG, "onPause");
+ mRenderer.onPause();
+ super.onPause();
+ }
+
+ public void enableView() {
+ mRenderer.enableView();
+ }
+
+ public void disableView() {
+ mRenderer.disableView();
+ }
+}
diff --git a/ZPI-App/opencv/java/src/org/opencv/android/CameraRenderer.java b/ZPI-App/opencv/java/src/org/opencv/android/CameraRenderer.java
new file mode 100644
index 000000000..2d668ffa6
--- /dev/null
+++ b/ZPI-App/opencv/java/src/org/opencv/android/CameraRenderer.java
@@ -0,0 +1,166 @@
+package org.opencv.android;
+
+import java.io.IOException;
+import java.util.List;
+
+import android.annotation.TargetApi;
+import android.hardware.Camera;
+import android.hardware.Camera.Size;
+import android.os.Build;
+import android.util.Log;
+
+@TargetApi(15)
+@SuppressWarnings("deprecation")
+public class CameraRenderer extends CameraGLRendererBase {
+
+ public static final String LOGTAG = "CameraRenderer";
+
+ private Camera mCamera;
+ private boolean mPreviewStarted = false;
+
+ CameraRenderer(CameraGLSurfaceView view) {
+ super(view);
+ }
+
+ @Override
+ protected synchronized void closeCamera() {
+ Log.i(LOGTAG, "closeCamera");
+ if(mCamera != null) {
+ mCamera.stopPreview();
+ mPreviewStarted = false;
+ mCamera.release();
+ mCamera = null;
+ }
+ }
+
+ @Override
+ protected synchronized void openCamera(int id) {
+ Log.i(LOGTAG, "openCamera");
+ closeCamera();
+ if (id == CameraBridgeViewBase.CAMERA_ID_ANY) {
+ Log.d(LOGTAG, "Trying to open camera with old open()");
+ try {
+ mCamera = Camera.open();
+ }
+ catch (Exception e){
+ Log.e(LOGTAG, "Camera is not available (in use or does not exist): " + e.getLocalizedMessage());
+ }
+
+ if(mCamera == null && Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD) {
+ boolean connected = false;
+ for (int camIdx = 0; camIdx < Camera.getNumberOfCameras(); ++camIdx) {
+ Log.d(LOGTAG, "Trying to open camera with new open(" + camIdx + ")");
+ try {
+ mCamera = Camera.open(camIdx);
+ connected = true;
+ } catch (RuntimeException e) {
+ Log.e(LOGTAG, "Camera #" + camIdx + "failed to open: " + e.getLocalizedMessage());
+ }
+ if (connected) break;
+ }
+ }
+ } else {
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD) {
+ int localCameraIndex = mCameraIndex;
+ if (mCameraIndex == CameraBridgeViewBase.CAMERA_ID_BACK) {
+ Log.i(LOGTAG, "Trying to open BACK camera");
+ Camera.CameraInfo cameraInfo = new Camera.CameraInfo();
+ for (int camIdx = 0; camIdx < Camera.getNumberOfCameras(); ++camIdx) {
+ Camera.getCameraInfo( camIdx, cameraInfo );
+ if (cameraInfo.facing == Camera.CameraInfo.CAMERA_FACING_BACK) {
+ localCameraIndex = camIdx;
+ break;
+ }
+ }
+ } else if (mCameraIndex == CameraBridgeViewBase.CAMERA_ID_FRONT) {
+ Log.i(LOGTAG, "Trying to open FRONT camera");
+ Camera.CameraInfo cameraInfo = new Camera.CameraInfo();
+ for (int camIdx = 0; camIdx < Camera.getNumberOfCameras(); ++camIdx) {
+ Camera.getCameraInfo( camIdx, cameraInfo );
+ if (cameraInfo.facing == Camera.CameraInfo.CAMERA_FACING_FRONT) {
+ localCameraIndex = camIdx;
+ break;
+ }
+ }
+ }
+ if (localCameraIndex == CameraBridgeViewBase.CAMERA_ID_BACK) {
+ Log.e(LOGTAG, "Back camera not found!");
+ } else if (localCameraIndex == CameraBridgeViewBase.CAMERA_ID_FRONT) {
+ Log.e(LOGTAG, "Front camera not found!");
+ } else {
+ Log.d(LOGTAG, "Trying to open camera with new open(" + localCameraIndex + ")");
+ try {
+ mCamera = Camera.open(localCameraIndex);
+ } catch (RuntimeException e) {
+ Log.e(LOGTAG, "Camera #" + localCameraIndex + "failed to open: " + e.getLocalizedMessage());
+ }
+ }
+ }
+ }
+ if(mCamera == null) {
+ Log.e(LOGTAG, "Error: can't open camera");
+ return;
+ }
+ Camera.Parameters params = mCamera.getParameters();
+ List FocusModes = params.getSupportedFocusModes();
+ if (FocusModes != null && FocusModes.contains(Camera.Parameters.FOCUS_MODE_CONTINUOUS_VIDEO))
+ {
+ params.setFocusMode(Camera.Parameters.FOCUS_MODE_CONTINUOUS_VIDEO);
+ }
+ mCamera.setParameters(params);
+
+ try {
+ mCamera.setPreviewTexture(mSTexture);
+ } catch (IOException ioe) {
+ Log.e(LOGTAG, "setPreviewTexture() failed: " + ioe.getMessage());
+ }
+ }
+
+ @Override
+ public synchronized void setCameraPreviewSize(int width, int height) {
+ Log.i(LOGTAG, "setCameraPreviewSize: "+width+"x"+height);
+ if(mCamera == null) {
+ Log.e(LOGTAG, "Camera isn't initialized!");
+ return;
+ }
+
+ if(mMaxCameraWidth > 0 && mMaxCameraWidth < width) width = mMaxCameraWidth;
+ if(mMaxCameraHeight > 0 && mMaxCameraHeight < height) height = mMaxCameraHeight;
+
+ Camera.Parameters param = mCamera.getParameters();
+ List psize = param.getSupportedPreviewSizes();
+ int bestWidth = 0, bestHeight = 0;
+ if (psize.size() > 0) {
+ float aspect = (float)width / height;
+ for (Size size : psize) {
+ int w = size.width, h = size.height;
+ Log.d(LOGTAG, "checking camera preview size: "+w+"x"+h);
+ if ( w <= width && h <= height &&
+ w >= bestWidth && h >= bestHeight &&
+ Math.abs(aspect - (float)w/h) < 0.2 ) {
+ bestWidth = w;
+ bestHeight = h;
+ }
+ }
+ if(bestWidth <= 0 || bestHeight <= 0) {
+ bestWidth = psize.get(0).width;
+ bestHeight = psize.get(0).height;
+ Log.e(LOGTAG, "Error: best size was not selected, using "+bestWidth+" x "+bestHeight);
+ } else {
+ Log.i(LOGTAG, "Selected best size: "+bestWidth+" x "+bestHeight);
+ }
+
+ if(mPreviewStarted) {
+ mCamera.stopPreview();
+ mPreviewStarted = false;
+ }
+ mCameraWidth = bestWidth;
+ mCameraHeight = bestHeight;
+ param.setPreviewSize(bestWidth, bestHeight);
+ }
+ param.set("orientation", "landscape");
+ mCamera.setParameters(param);
+ mCamera.startPreview();
+ mPreviewStarted = true;
+ }
+}
\ No newline at end of file
diff --git a/ZPI-App/opencv/java/src/org/opencv/android/FpsMeter.java b/ZPI-App/opencv/java/src/org/opencv/android/FpsMeter.java
new file mode 100644
index 000000000..d22c68e41
--- /dev/null
+++ b/ZPI-App/opencv/java/src/org/opencv/android/FpsMeter.java
@@ -0,0 +1,66 @@
+package org.opencv.android;
+
+import java.text.DecimalFormat;
+
+import org.opencv.core.Core;
+
+import android.graphics.Canvas;
+import android.graphics.Color;
+import android.graphics.Paint;
+import android.util.Log;
+
+public class FpsMeter {
+ private static final String TAG = "FpsMeter";
+ private static final int STEP = 20;
+ private static final DecimalFormat FPS_FORMAT = new DecimalFormat("0.00");
+
+ private int mFramesCounter;
+ private double mFrequency;
+ private long mprevFrameTime;
+ private String mStrfps;
+ Paint mPaint;
+ boolean mIsInitialized = false;
+ int mWidth = 0;
+ int mHeight = 0;
+
+ public void init() {
+ mFramesCounter = 0;
+ mFrequency = Core.getTickFrequency();
+ mprevFrameTime = Core.getTickCount();
+ mStrfps = "";
+
+ mPaint = new Paint();
+ mPaint.setColor(Color.BLUE);
+ mPaint.setTextSize(20);
+ }
+
+ public void measure() {
+ if (!mIsInitialized) {
+ init();
+ mIsInitialized = true;
+ } else {
+ mFramesCounter++;
+ if (mFramesCounter % STEP == 0) {
+ long time = Core.getTickCount();
+ double fps = STEP * mFrequency / (time - mprevFrameTime);
+ mprevFrameTime = time;
+ if (mWidth != 0 && mHeight != 0)
+ mStrfps = FPS_FORMAT.format(fps) + " FPS@" + Integer.valueOf(mWidth) + "x" + Integer.valueOf(mHeight);
+ else
+ mStrfps = FPS_FORMAT.format(fps) + " FPS";
+ Log.i(TAG, mStrfps);
+ }
+ }
+ }
+
+ public void setResolution(int width, int height) {
+ mWidth = width;
+ mHeight = height;
+ }
+
+ public void draw(Canvas canvas, float offsetx, float offsety) {
+ Log.d(TAG, mStrfps);
+ canvas.drawText(mStrfps, offsetx, offsety, mPaint);
+ }
+
+}
diff --git a/ZPI-App/opencv/java/src/org/opencv/android/InstallCallbackInterface.java b/ZPI-App/opencv/java/src/org/opencv/android/InstallCallbackInterface.java
new file mode 100644
index 000000000..f68027a7b
--- /dev/null
+++ b/ZPI-App/opencv/java/src/org/opencv/android/InstallCallbackInterface.java
@@ -0,0 +1,34 @@
+package org.opencv.android;
+
+/**
+ * Installation callback interface.
+ */
+public interface InstallCallbackInterface
+{
+ /**
+ * New package installation is required.
+ */
+ static final int NEW_INSTALLATION = 0;
+ /**
+ * Current package installation is in progress.
+ */
+ static final int INSTALLATION_PROGRESS = 1;
+
+ /**
+ * Target package name.
+ * @return Return target package name.
+ */
+ public String getPackageName();
+ /**
+ * Installation is approved.
+ */
+ public void install();
+ /**
+ * Installation is canceled.
+ */
+ public void cancel();
+ /**
+ * Wait for package installation.
+ */
+ public void wait_install();
+};
diff --git a/ZPI-App/opencv/java/src/org/opencv/android/JavaCamera2View.java b/ZPI-App/opencv/java/src/org/opencv/android/JavaCamera2View.java
new file mode 100644
index 000000000..017de7f26
--- /dev/null
+++ b/ZPI-App/opencv/java/src/org/opencv/android/JavaCamera2View.java
@@ -0,0 +1,447 @@
+package org.opencv.android;
+
+import java.nio.ByteBuffer;
+import java.util.Arrays;
+import java.util.List;
+
+import android.annotation.TargetApi;
+import android.content.Context;
+import android.graphics.ImageFormat;
+import android.hardware.camera2.CameraAccessException;
+import android.hardware.camera2.CameraCaptureSession;
+import android.hardware.camera2.CameraCharacteristics;
+import android.hardware.camera2.CameraDevice;
+import android.hardware.camera2.CameraManager;
+import android.hardware.camera2.CaptureRequest;
+import android.hardware.camera2.params.StreamConfigurationMap;
+import android.media.Image;
+import android.media.ImageReader;
+import android.os.Handler;
+import android.os.HandlerThread;
+import android.util.AttributeSet;
+import android.util.Log;
+import android.view.Surface;
+import android.view.ViewGroup.LayoutParams;
+
+import org.opencv.core.CvType;
+import org.opencv.core.Mat;
+import org.opencv.core.Size;
+import org.opencv.imgproc.Imgproc;
+
+/**
+ * This class is an implementation of the Bridge View between OpenCV and Java Camera.
+ * This class relays on the functionality available in base class and only implements
+ * required functions:
+ * connectCamera - opens Java camera and sets the PreviewCallback to be delivered.
+ * disconnectCamera - closes the camera and stops preview.
+ * When frame is delivered via callback from Camera - it processed via OpenCV to be
+ * converted to RGBA32 and then passed to the external callback for modifications if required.
+ */
+
+@TargetApi(21)
+public class JavaCamera2View extends CameraBridgeViewBase {
+
+ private static final String LOGTAG = "JavaCamera2View";
+
+ protected ImageReader mImageReader;
+ protected int mPreviewFormat = ImageFormat.YUV_420_888;
+
+ protected CameraDevice mCameraDevice;
+ protected CameraCaptureSession mCaptureSession;
+ protected CaptureRequest.Builder mPreviewRequestBuilder;
+ protected String mCameraID;
+ protected android.util.Size mPreviewSize = new android.util.Size(-1, -1);
+
+ private HandlerThread mBackgroundThread;
+ protected Handler mBackgroundHandler;
+
+ public JavaCamera2View(Context context, int cameraId) {
+ super(context, cameraId);
+ }
+
+ public JavaCamera2View(Context context, AttributeSet attrs) {
+ super(context, attrs);
+ }
+
+ private void startBackgroundThread() {
+ Log.i(LOGTAG, "startBackgroundThread");
+ stopBackgroundThread();
+ mBackgroundThread = new HandlerThread("OpenCVCameraBackground");
+ mBackgroundThread.start();
+ mBackgroundHandler = new Handler(mBackgroundThread.getLooper());
+ }
+
+ private void stopBackgroundThread() {
+ Log.i(LOGTAG, "stopBackgroundThread");
+ if (mBackgroundThread == null)
+ return;
+ mBackgroundThread.quitSafely();
+ try {
+ mBackgroundThread.join();
+ mBackgroundThread = null;
+ mBackgroundHandler = null;
+ } catch (InterruptedException e) {
+ Log.e(LOGTAG, "stopBackgroundThread", e);
+ }
+ }
+
+ protected boolean initializeCamera() {
+ Log.i(LOGTAG, "initializeCamera");
+ CameraManager manager = (CameraManager) getContext().getSystemService(Context.CAMERA_SERVICE);
+ try {
+ String camList[] = manager.getCameraIdList();
+ if (camList.length == 0) {
+ Log.e(LOGTAG, "Error: camera isn't detected.");
+ return false;
+ }
+ if (mCameraIndex == CameraBridgeViewBase.CAMERA_ID_ANY) {
+ mCameraID = camList[0];
+ } else {
+ for (String cameraID : camList) {
+ CameraCharacteristics characteristics = manager.getCameraCharacteristics(cameraID);
+ if ((mCameraIndex == CameraBridgeViewBase.CAMERA_ID_BACK &&
+ characteristics.get(CameraCharacteristics.LENS_FACING) == CameraCharacteristics.LENS_FACING_BACK) ||
+ (mCameraIndex == CameraBridgeViewBase.CAMERA_ID_FRONT &&
+ characteristics.get(CameraCharacteristics.LENS_FACING) == CameraCharacteristics.LENS_FACING_FRONT)
+ ) {
+ mCameraID = cameraID;
+ break;
+ }
+ }
+ }
+ if (mCameraID != null) {
+ Log.i(LOGTAG, "Opening camera: " + mCameraID);
+ manager.openCamera(mCameraID, mStateCallback, mBackgroundHandler);
+ } else { // make JavaCamera2View behaves in the same way as JavaCameraView
+ Log.i(LOGTAG, "Trying to open camera with the value (" + mCameraIndex + ")");
+ if (mCameraIndex < camList.length) {
+ mCameraID = camList[mCameraIndex];
+ manager.openCamera(mCameraID, mStateCallback, mBackgroundHandler);
+ } else {
+ // CAMERA_DISCONNECTED is used when the camera id is no longer valid
+ throw new CameraAccessException(CameraAccessException.CAMERA_DISCONNECTED);
+ }
+ }
+ return true;
+ } catch (CameraAccessException e) {
+ Log.e(LOGTAG, "OpenCamera - Camera Access Exception", e);
+ } catch (IllegalArgumentException e) {
+ Log.e(LOGTAG, "OpenCamera - Illegal Argument Exception", e);
+ } catch (SecurityException e) {
+ Log.e(LOGTAG, "OpenCamera - Security Exception", e);
+ }
+ return false;
+ }
+
+ private final CameraDevice.StateCallback mStateCallback = new CameraDevice.StateCallback() {
+
+ @Override
+ public void onOpened(CameraDevice cameraDevice) {
+ mCameraDevice = cameraDevice;
+ createCameraPreviewSession();
+ }
+
+ @Override
+ public void onDisconnected(CameraDevice cameraDevice) {
+ cameraDevice.close();
+ mCameraDevice = null;
+ }
+
+ @Override
+ public void onError(CameraDevice cameraDevice, int error) {
+ cameraDevice.close();
+ mCameraDevice = null;
+ }
+
+ };
+
+ private void createCameraPreviewSession() {
+ final int w = mPreviewSize.getWidth(), h = mPreviewSize.getHeight();
+ Log.i(LOGTAG, "createCameraPreviewSession(" + w + "x" + h + ")");
+ if (w < 0 || h < 0)
+ return;
+ try {
+ if (null == mCameraDevice) {
+ Log.e(LOGTAG, "createCameraPreviewSession: camera isn't opened");
+ return;
+ }
+ if (null != mCaptureSession) {
+ Log.e(LOGTAG, "createCameraPreviewSession: mCaptureSession is already started");
+ return;
+ }
+
+ mImageReader = ImageReader.newInstance(w, h, mPreviewFormat, 2);
+ mImageReader.setOnImageAvailableListener(new ImageReader.OnImageAvailableListener() {
+ @Override
+ public void onImageAvailable(ImageReader reader) {
+ Image image = reader.acquireLatestImage();
+ if (image == null)
+ return;
+
+ // sanity checks - 3 planes
+ Image.Plane[] planes = image.getPlanes();
+ assert (planes.length == 3);
+ assert (image.getFormat() == mPreviewFormat);
+
+ JavaCamera2Frame tempFrame = new JavaCamera2Frame(image);
+ deliverAndDrawFrame(tempFrame);
+ tempFrame.release();
+ image.close();
+ }
+ }, mBackgroundHandler);
+ Surface surface = mImageReader.getSurface();
+
+ mPreviewRequestBuilder = mCameraDevice.createCaptureRequest(CameraDevice.TEMPLATE_PREVIEW);
+ mPreviewRequestBuilder.addTarget(surface);
+
+ mCameraDevice.createCaptureSession(Arrays.asList(surface),
+ new CameraCaptureSession.StateCallback() {
+ @Override
+ public void onConfigured(CameraCaptureSession cameraCaptureSession) {
+ Log.i(LOGTAG, "createCaptureSession::onConfigured");
+ if (null == mCameraDevice) {
+ return; // camera is already closed
+ }
+ mCaptureSession = cameraCaptureSession;
+ try {
+ mPreviewRequestBuilder.set(CaptureRequest.CONTROL_AF_MODE,
+ CaptureRequest.CONTROL_AF_MODE_CONTINUOUS_PICTURE);
+ mPreviewRequestBuilder.set(CaptureRequest.CONTROL_AE_MODE,
+ CaptureRequest.CONTROL_AE_MODE_ON_AUTO_FLASH);
+
+ mCaptureSession.setRepeatingRequest(mPreviewRequestBuilder.build(), null, mBackgroundHandler);
+ Log.i(LOGTAG, "CameraPreviewSession has been started");
+ } catch (Exception e) {
+ Log.e(LOGTAG, "createCaptureSession failed", e);
+ }
+ }
+
+ @Override
+ public void onConfigureFailed(CameraCaptureSession cameraCaptureSession) {
+ Log.e(LOGTAG, "createCameraPreviewSession failed");
+ }
+ },
+ null
+ );
+ } catch (CameraAccessException e) {
+ Log.e(LOGTAG, "createCameraPreviewSession", e);
+ }
+ }
+
+ @Override
+ protected void disconnectCamera() {
+ Log.i(LOGTAG, "close camera");
+ try {
+ CameraDevice c = mCameraDevice;
+ mCameraDevice = null;
+ if (null != mCaptureSession) {
+ mCaptureSession.close();
+ mCaptureSession = null;
+ }
+ if (null != c) {
+ c.close();
+ }
+ } finally {
+ stopBackgroundThread();
+ if (null != mImageReader) {
+ mImageReader.close();
+ mImageReader = null;
+ }
+ }
+ Log.i(LOGTAG, "camera closed!");
+ }
+
+ public static class JavaCameraSizeAccessor implements ListItemAccessor {
+ @Override
+ public int getWidth(Object obj) {
+ android.util.Size size = (android.util.Size)obj;
+ return size.getWidth();
+ }
+
+ @Override
+ public int getHeight(Object obj) {
+ android.util.Size size = (android.util.Size)obj;
+ return size.getHeight();
+ }
+ }
+
+ boolean calcPreviewSize(final int width, final int height) {
+ Log.i(LOGTAG, "calcPreviewSize: " + width + "x" + height);
+ if (mCameraID == null) {
+ Log.e(LOGTAG, "Camera isn't initialized!");
+ return false;
+ }
+ CameraManager manager = (CameraManager) getContext().getSystemService(Context.CAMERA_SERVICE);
+ try {
+ CameraCharacteristics characteristics = manager.getCameraCharacteristics(mCameraID);
+ StreamConfigurationMap map = characteristics.get(CameraCharacteristics.SCALER_STREAM_CONFIGURATION_MAP);
+ android.util.Size[] sizes = map.getOutputSizes(ImageReader.class);
+ List sizes_list = Arrays.asList(sizes);
+ Size frameSize = calculateCameraFrameSize(sizes_list, new JavaCameraSizeAccessor(), width, height);
+ Log.i(LOGTAG, "Selected preview size to " + Integer.valueOf((int)frameSize.width) + "x" + Integer.valueOf((int)frameSize.height));
+ assert(!(frameSize.width == 0 || frameSize.height == 0));
+ if (mPreviewSize.getWidth() == frameSize.width && mPreviewSize.getHeight() == frameSize.height)
+ return false;
+ else {
+ mPreviewSize = new android.util.Size((int)frameSize.width, (int)frameSize.height);
+ return true;
+ }
+ } catch (CameraAccessException e) {
+ Log.e(LOGTAG, "calcPreviewSize - Camera Access Exception", e);
+ } catch (IllegalArgumentException e) {
+ Log.e(LOGTAG, "calcPreviewSize - Illegal Argument Exception", e);
+ } catch (SecurityException e) {
+ Log.e(LOGTAG, "calcPreviewSize - Security Exception", e);
+ }
+ return false;
+ }
+
+ @Override
+ protected boolean connectCamera(int width, int height) {
+ Log.i(LOGTAG, "setCameraPreviewSize(" + width + "x" + height + ")");
+ startBackgroundThread();
+ initializeCamera();
+ try {
+ boolean needReconfig = calcPreviewSize(width, height);
+ mFrameWidth = mPreviewSize.getWidth();
+ mFrameHeight = mPreviewSize.getHeight();
+
+ if ((getLayoutParams().width == LayoutParams.MATCH_PARENT) && (getLayoutParams().height == LayoutParams.MATCH_PARENT))
+ mScale = Math.min(((float)height)/mFrameHeight, ((float)width)/mFrameWidth);
+ else
+ mScale = 0;
+
+ AllocateCache();
+
+ if (needReconfig) {
+ if (null != mCaptureSession) {
+ Log.d(LOGTAG, "closing existing previewSession");
+ mCaptureSession.close();
+ mCaptureSession = null;
+ }
+ createCameraPreviewSession();
+ }
+ } catch (RuntimeException e) {
+ throw new RuntimeException("Interrupted while setCameraPreviewSize.", e);
+ }
+ return true;
+ }
+
+ private class JavaCamera2Frame implements CvCameraViewFrame {
+ @Override
+ public Mat gray() {
+ Image.Plane[] planes = mImage.getPlanes();
+ int w = mImage.getWidth();
+ int h = mImage.getHeight();
+ assert(planes[0].getPixelStride() == 1);
+ ByteBuffer y_plane = planes[0].getBuffer();
+ int y_plane_step = planes[0].getRowStride();
+ mGray = new Mat(h, w, CvType.CV_8UC1, y_plane, y_plane_step);
+ return mGray;
+ }
+
+ @Override
+ public Mat rgba() {
+ Image.Plane[] planes = mImage.getPlanes();
+ int w = mImage.getWidth();
+ int h = mImage.getHeight();
+ int chromaPixelStride = planes[1].getPixelStride();
+
+
+ if (chromaPixelStride == 2) { // Chroma channels are interleaved
+ assert(planes[0].getPixelStride() == 1);
+ assert(planes[2].getPixelStride() == 2);
+ ByteBuffer y_plane = planes[0].getBuffer();
+ int y_plane_step = planes[0].getRowStride();
+ ByteBuffer uv_plane1 = planes[1].getBuffer();
+ int uv_plane1_step = planes[1].getRowStride();
+ ByteBuffer uv_plane2 = planes[2].getBuffer();
+ int uv_plane2_step = planes[2].getRowStride();
+ Mat y_mat = new Mat(h, w, CvType.CV_8UC1, y_plane, y_plane_step);
+ Mat uv_mat1 = new Mat(h / 2, w / 2, CvType.CV_8UC2, uv_plane1, uv_plane1_step);
+ Mat uv_mat2 = new Mat(h / 2, w / 2, CvType.CV_8UC2, uv_plane2, uv_plane2_step);
+ long addr_diff = uv_mat2.dataAddr() - uv_mat1.dataAddr();
+ if (addr_diff > 0) {
+ assert(addr_diff == 1);
+ Imgproc.cvtColorTwoPlane(y_mat, uv_mat1, mRgba, Imgproc.COLOR_YUV2RGBA_NV12);
+ } else {
+ assert(addr_diff == -1);
+ Imgproc.cvtColorTwoPlane(y_mat, uv_mat2, mRgba, Imgproc.COLOR_YUV2RGBA_NV21);
+ }
+ return mRgba;
+ } else { // Chroma channels are not interleaved
+ byte[] yuv_bytes = new byte[w*(h+h/2)];
+ ByteBuffer y_plane = planes[0].getBuffer();
+ ByteBuffer u_plane = planes[1].getBuffer();
+ ByteBuffer v_plane = planes[2].getBuffer();
+
+ int yuv_bytes_offset = 0;
+
+ int y_plane_step = planes[0].getRowStride();
+ if (y_plane_step == w) {
+ y_plane.get(yuv_bytes, 0, w*h);
+ yuv_bytes_offset = w*h;
+ } else {
+ int padding = y_plane_step - w;
+ for (int i = 0; i < h; i++){
+ y_plane.get(yuv_bytes, yuv_bytes_offset, w);
+ yuv_bytes_offset += w;
+ if (i < h - 1) {
+ y_plane.position(y_plane.position() + padding);
+ }
+ }
+ assert(yuv_bytes_offset == w * h);
+ }
+
+ int chromaRowStride = planes[1].getRowStride();
+ int chromaRowPadding = chromaRowStride - w/2;
+
+ if (chromaRowPadding == 0){
+ // When the row stride of the chroma channels equals their width, we can copy
+ // the entire channels in one go
+ u_plane.get(yuv_bytes, yuv_bytes_offset, w*h/4);
+ yuv_bytes_offset += w*h/4;
+ v_plane.get(yuv_bytes, yuv_bytes_offset, w*h/4);
+ } else {
+ // When not equal, we need to copy the channels row by row
+ for (int i = 0; i < h/2; i++){
+ u_plane.get(yuv_bytes, yuv_bytes_offset, w/2);
+ yuv_bytes_offset += w/2;
+ if (i < h/2-1){
+ u_plane.position(u_plane.position() + chromaRowPadding);
+ }
+ }
+ for (int i = 0; i < h/2; i++){
+ v_plane.get(yuv_bytes, yuv_bytes_offset, w/2);
+ yuv_bytes_offset += w/2;
+ if (i < h/2-1){
+ v_plane.position(v_plane.position() + chromaRowPadding);
+ }
+ }
+ }
+
+ Mat yuv_mat = new Mat(h+h/2, w, CvType.CV_8UC1);
+ yuv_mat.put(0, 0, yuv_bytes);
+ Imgproc.cvtColor(yuv_mat, mRgba, Imgproc.COLOR_YUV2RGBA_I420, 4);
+ return mRgba;
+ }
+ }
+
+
+ public JavaCamera2Frame(Image image) {
+ super();
+ mImage = image;
+ mRgba = new Mat();
+ mGray = new Mat();
+ }
+
+ public void release() {
+ mRgba.release();
+ mGray.release();
+ }
+
+ private Image mImage;
+ private Mat mRgba;
+ private Mat mGray;
+ };
+}
diff --git a/ZPI-App/opencv/java/src/org/opencv/android/JavaCameraView.java b/ZPI-App/opencv/java/src/org/opencv/android/JavaCameraView.java
new file mode 100644
index 000000000..a7c72e43f
--- /dev/null
+++ b/ZPI-App/opencv/java/src/org/opencv/android/JavaCameraView.java
@@ -0,0 +1,379 @@
+package org.opencv.android;
+
+import java.util.List;
+
+import android.content.Context;
+import android.graphics.ImageFormat;
+import android.graphics.SurfaceTexture;
+import android.hardware.Camera;
+import android.hardware.Camera.PreviewCallback;
+import android.os.Build;
+import android.util.AttributeSet;
+import android.util.Log;
+import android.view.ViewGroup.LayoutParams;
+
+import org.opencv.BuildConfig;
+import org.opencv.core.CvType;
+import org.opencv.core.Mat;
+import org.opencv.core.Size;
+import org.opencv.imgproc.Imgproc;
+
+/**
+ * This class is an implementation of the Bridge View between OpenCV and Java Camera.
+ * This class relays on the functionality available in base class and only implements
+ * required functions:
+ * connectCamera - opens Java camera and sets the PreviewCallback to be delivered.
+ * disconnectCamera - closes the camera and stops preview.
+ * When frame is delivered via callback from Camera - it processed via OpenCV to be
+ * converted to RGBA32 and then passed to the external callback for modifications if required.
+ */
+public class JavaCameraView extends CameraBridgeViewBase implements PreviewCallback {
+
+ private static final int MAGIC_TEXTURE_ID = 10;
+ private static final String TAG = "JavaCameraView";
+
+ private byte mBuffer[];
+ private Mat[] mFrameChain;
+ private int mChainIdx = 0;
+ private Thread mThread;
+ private boolean mStopThread;
+
+ protected Camera mCamera;
+ protected JavaCameraFrame[] mCameraFrame;
+ private SurfaceTexture mSurfaceTexture;
+ private int mPreviewFormat = ImageFormat.NV21;
+
+ public static class JavaCameraSizeAccessor implements ListItemAccessor {
+
+ @Override
+ public int getWidth(Object obj) {
+ Camera.Size size = (Camera.Size) obj;
+ return size.width;
+ }
+
+ @Override
+ public int getHeight(Object obj) {
+ Camera.Size size = (Camera.Size) obj;
+ return size.height;
+ }
+ }
+
+ public JavaCameraView(Context context, int cameraId) {
+ super(context, cameraId);
+ }
+
+ public JavaCameraView(Context context, AttributeSet attrs) {
+ super(context, attrs);
+ }
+
+ protected boolean initializeCamera(int width, int height) {
+ Log.d(TAG, "Initialize java camera");
+ boolean result = true;
+ synchronized (this) {
+ mCamera = null;
+
+ if (mCameraIndex == CAMERA_ID_ANY) {
+ Log.d(TAG, "Trying to open camera with old open()");
+ try {
+ mCamera = Camera.open();
+ }
+ catch (Exception e){
+ Log.e(TAG, "Camera is not available (in use or does not exist): " + e.getLocalizedMessage());
+ }
+
+ if(mCamera == null && Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD) {
+ boolean connected = false;
+ for (int camIdx = 0; camIdx < Camera.getNumberOfCameras(); ++camIdx) {
+ Log.d(TAG, "Trying to open camera with new open(" + Integer.valueOf(camIdx) + ")");
+ try {
+ mCamera = Camera.open(camIdx);
+ connected = true;
+ } catch (RuntimeException e) {
+ Log.e(TAG, "Camera #" + camIdx + "failed to open: " + e.getLocalizedMessage());
+ }
+ if (connected) break;
+ }
+ }
+ } else {
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD) {
+ int localCameraIndex = mCameraIndex;
+ if (mCameraIndex == CAMERA_ID_BACK) {
+ Log.i(TAG, "Trying to open back camera");
+ Camera.CameraInfo cameraInfo = new Camera.CameraInfo();
+ for (int camIdx = 0; camIdx < Camera.getNumberOfCameras(); ++camIdx) {
+ Camera.getCameraInfo( camIdx, cameraInfo );
+ if (cameraInfo.facing == Camera.CameraInfo.CAMERA_FACING_BACK) {
+ localCameraIndex = camIdx;
+ break;
+ }
+ }
+ } else if (mCameraIndex == CAMERA_ID_FRONT) {
+ Log.i(TAG, "Trying to open front camera");
+ Camera.CameraInfo cameraInfo = new Camera.CameraInfo();
+ for (int camIdx = 0; camIdx < Camera.getNumberOfCameras(); ++camIdx) {
+ Camera.getCameraInfo( camIdx, cameraInfo );
+ if (cameraInfo.facing == Camera.CameraInfo.CAMERA_FACING_FRONT) {
+ localCameraIndex = camIdx;
+ break;
+ }
+ }
+ }
+ if (localCameraIndex == CAMERA_ID_BACK) {
+ Log.e(TAG, "Back camera not found!");
+ } else if (localCameraIndex == CAMERA_ID_FRONT) {
+ Log.e(TAG, "Front camera not found!");
+ } else {
+ Log.d(TAG, "Trying to open camera with new open(" + Integer.valueOf(localCameraIndex) + ")");
+ try {
+ mCamera = Camera.open(localCameraIndex);
+ } catch (RuntimeException e) {
+ Log.e(TAG, "Camera #" + localCameraIndex + "failed to open: " + e.getLocalizedMessage());
+ }
+ }
+ }
+ }
+
+ if (mCamera == null)
+ return false;
+
+ /* Now set camera parameters */
+ try {
+ Camera.Parameters params = mCamera.getParameters();
+ Log.d(TAG, "getSupportedPreviewSizes()");
+ List sizes = params.getSupportedPreviewSizes();
+
+ if (sizes != null) {
+ /* Select the size that fits surface considering maximum size allowed */
+ Size frameSize = calculateCameraFrameSize(sizes, new JavaCameraSizeAccessor(), width, height);
+
+ /* Image format NV21 causes issues in the Android emulators */
+ if (Build.FINGERPRINT.startsWith("generic")
+ || Build.FINGERPRINT.startsWith("unknown")
+ || Build.MODEL.contains("google_sdk")
+ || Build.MODEL.contains("Emulator")
+ || Build.MODEL.contains("Android SDK built for x86")
+ || Build.MANUFACTURER.contains("Genymotion")
+ || (Build.BRAND.startsWith("generic") && Build.DEVICE.startsWith("generic"))
+ || "google_sdk".equals(Build.PRODUCT))
+ params.setPreviewFormat(ImageFormat.YV12); // "generic" or "android" = android emulator
+ else
+ params.setPreviewFormat(ImageFormat.NV21);
+
+ mPreviewFormat = params.getPreviewFormat();
+
+ Log.d(TAG, "Set preview size to " + Integer.valueOf((int)frameSize.width) + "x" + Integer.valueOf((int)frameSize.height));
+ params.setPreviewSize((int)frameSize.width, (int)frameSize.height);
+
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH && !android.os.Build.MODEL.equals("GT-I9100"))
+ params.setRecordingHint(true);
+
+ List FocusModes = params.getSupportedFocusModes();
+ if (FocusModes != null && FocusModes.contains(Camera.Parameters.FOCUS_MODE_CONTINUOUS_VIDEO))
+ {
+ params.setFocusMode(Camera.Parameters.FOCUS_MODE_CONTINUOUS_VIDEO);
+ }
+
+ mCamera.setParameters(params);
+ params = mCamera.getParameters();
+
+ mFrameWidth = params.getPreviewSize().width;
+ mFrameHeight = params.getPreviewSize().height;
+
+ if ((getLayoutParams().width == LayoutParams.MATCH_PARENT) && (getLayoutParams().height == LayoutParams.MATCH_PARENT))
+ mScale = Math.min(((float)height)/mFrameHeight, ((float)width)/mFrameWidth);
+ else
+ mScale = 0;
+
+ if (mFpsMeter != null) {
+ mFpsMeter.setResolution(mFrameWidth, mFrameHeight);
+ }
+
+ int size = mFrameWidth * mFrameHeight;
+ size = size * ImageFormat.getBitsPerPixel(params.getPreviewFormat()) / 8;
+ mBuffer = new byte[size];
+
+ mCamera.addCallbackBuffer(mBuffer);
+ mCamera.setPreviewCallbackWithBuffer(this);
+
+ mFrameChain = new Mat[2];
+ mFrameChain[0] = new Mat(mFrameHeight + (mFrameHeight/2), mFrameWidth, CvType.CV_8UC1);
+ mFrameChain[1] = new Mat(mFrameHeight + (mFrameHeight/2), mFrameWidth, CvType.CV_8UC1);
+
+ AllocateCache();
+
+ mCameraFrame = new JavaCameraFrame[2];
+ mCameraFrame[0] = new JavaCameraFrame(mFrameChain[0], mFrameWidth, mFrameHeight);
+ mCameraFrame[1] = new JavaCameraFrame(mFrameChain[1], mFrameWidth, mFrameHeight);
+
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
+ mSurfaceTexture = new SurfaceTexture(MAGIC_TEXTURE_ID);
+ mCamera.setPreviewTexture(mSurfaceTexture);
+ } else
+ mCamera.setPreviewDisplay(null);
+
+ /* Finally we are ready to start the preview */
+ Log.d(TAG, "startPreview");
+ mCamera.startPreview();
+ }
+ else
+ result = false;
+ } catch (Exception e) {
+ result = false;
+ e.printStackTrace();
+ }
+ }
+
+ return result;
+ }
+
+ protected void releaseCamera() {
+ synchronized (this) {
+ if (mCamera != null) {
+ mCamera.stopPreview();
+ mCamera.setPreviewCallback(null);
+
+ mCamera.release();
+ }
+ mCamera = null;
+ if (mFrameChain != null) {
+ mFrameChain[0].release();
+ mFrameChain[1].release();
+ }
+ if (mCameraFrame != null) {
+ mCameraFrame[0].release();
+ mCameraFrame[1].release();
+ }
+ }
+ }
+
+ private boolean mCameraFrameReady = false;
+
+ @Override
+ protected boolean connectCamera(int width, int height) {
+
+ /* 1. We need to instantiate camera
+ * 2. We need to start thread which will be getting frames
+ */
+ /* First step - initialize camera connection */
+ Log.d(TAG, "Connecting to camera");
+ if (!initializeCamera(width, height))
+ return false;
+
+ mCameraFrameReady = false;
+
+ /* now we can start update thread */
+ Log.d(TAG, "Starting processing thread");
+ mStopThread = false;
+ mThread = new Thread(new CameraWorker());
+ mThread.start();
+
+ return true;
+ }
+
+ @Override
+ protected void disconnectCamera() {
+ /* 1. We need to stop thread which updating the frames
+ * 2. Stop camera and release it
+ */
+ Log.d(TAG, "Disconnecting from camera");
+ try {
+ mStopThread = true;
+ Log.d(TAG, "Notify thread");
+ synchronized (this) {
+ this.notify();
+ }
+ Log.d(TAG, "Waiting for thread");
+ if (mThread != null)
+ mThread.join();
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ } finally {
+ mThread = null;
+ }
+
+ /* Now release camera */
+ releaseCamera();
+
+ mCameraFrameReady = false;
+ }
+
+ @Override
+ public void onPreviewFrame(byte[] frame, Camera arg1) {
+ if (BuildConfig.DEBUG)
+ Log.d(TAG, "Preview Frame received. Frame size: " + frame.length);
+ synchronized (this) {
+ mFrameChain[mChainIdx].put(0, 0, frame);
+ mCameraFrameReady = true;
+ this.notify();
+ }
+ if (mCamera != null)
+ mCamera.addCallbackBuffer(mBuffer);
+ }
+
+ private class JavaCameraFrame implements CvCameraViewFrame {
+ @Override
+ public Mat gray() {
+ return mYuvFrameData.submat(0, mHeight, 0, mWidth);
+ }
+
+ @Override
+ public Mat rgba() {
+ if (mPreviewFormat == ImageFormat.NV21)
+ Imgproc.cvtColor(mYuvFrameData, mRgba, Imgproc.COLOR_YUV2RGBA_NV21, 4);
+ else if (mPreviewFormat == ImageFormat.YV12)
+ Imgproc.cvtColor(mYuvFrameData, mRgba, Imgproc.COLOR_YUV2RGB_I420, 4); // COLOR_YUV2RGBA_YV12 produces inverted colors
+ else
+ throw new IllegalArgumentException("Preview Format can be NV21 or YV12");
+
+ return mRgba;
+ }
+
+ public JavaCameraFrame(Mat Yuv420sp, int width, int height) {
+ super();
+ mWidth = width;
+ mHeight = height;
+ mYuvFrameData = Yuv420sp;
+ mRgba = new Mat();
+ }
+
+ public void release() {
+ mRgba.release();
+ }
+
+ private Mat mYuvFrameData;
+ private Mat mRgba;
+ private int mWidth;
+ private int mHeight;
+ };
+
+ private class CameraWorker implements Runnable {
+
+ @Override
+ public void run() {
+ do {
+ boolean hasFrame = false;
+ synchronized (JavaCameraView.this) {
+ try {
+ while (!mCameraFrameReady && !mStopThread) {
+ JavaCameraView.this.wait();
+ }
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ if (mCameraFrameReady)
+ {
+ mChainIdx = 1 - mChainIdx;
+ mCameraFrameReady = false;
+ hasFrame = true;
+ }
+ }
+
+ if (!mStopThread && hasFrame) {
+ if (!mFrameChain[1 - mChainIdx].empty())
+ deliverAndDrawFrame(mCameraFrame[1 - mChainIdx]);
+ }
+ } while (!mStopThread);
+ Log.d(TAG, "Finish processing thread");
+ }
+ }
+}
diff --git a/ZPI-App/opencv/java/src/org/opencv/android/LoaderCallbackInterface.java b/ZPI-App/opencv/java/src/org/opencv/android/LoaderCallbackInterface.java
new file mode 100644
index 000000000..a941e8377
--- /dev/null
+++ b/ZPI-App/opencv/java/src/org/opencv/android/LoaderCallbackInterface.java
@@ -0,0 +1,40 @@
+package org.opencv.android;
+
+/**
+ * Interface for callback object in case of asynchronous initialization of OpenCV.
+ */
+public interface LoaderCallbackInterface
+{
+ /**
+ * OpenCV initialization finished successfully.
+ */
+ static final int SUCCESS = 0;
+ /**
+ * Google Play Market cannot be invoked.
+ */
+ static final int MARKET_ERROR = 2;
+ /**
+ * OpenCV library installation has been canceled by the user.
+ */
+ static final int INSTALL_CANCELED = 3;
+ /**
+ * This version of OpenCV Manager Service is incompatible with the app. Possibly, a service update is required.
+ */
+ static final int INCOMPATIBLE_MANAGER_VERSION = 4;
+ /**
+ * OpenCV library initialization has failed.
+ */
+ static final int INIT_FAILED = 0xff;
+
+ /**
+ * Callback method, called after OpenCV library initialization.
+ * @param status status of initialization (see initialization status constants).
+ */
+ public void onManagerConnected(int status);
+
+ /**
+ * Callback method, called in case the package installation is needed.
+ * @param callback answer object with approve and cancel methods and the package description.
+ */
+ public void onPackageInstall(final int operation, InstallCallbackInterface callback);
+};
diff --git a/ZPI-App/opencv/java/src/org/opencv/android/OpenCVLoader.java b/ZPI-App/opencv/java/src/org/opencv/android/OpenCVLoader.java
new file mode 100644
index 000000000..f474f7364
--- /dev/null
+++ b/ZPI-App/opencv/java/src/org/opencv/android/OpenCVLoader.java
@@ -0,0 +1,132 @@
+package org.opencv.android;
+
+import android.content.Context;
+
+/**
+ * Helper class provides common initialization methods for OpenCV library.
+ */
+public class OpenCVLoader
+{
+ /**
+ * OpenCV Library version 2.4.2.
+ */
+ public static final String OPENCV_VERSION_2_4_2 = "2.4.2";
+
+ /**
+ * OpenCV Library version 2.4.3.
+ */
+ public static final String OPENCV_VERSION_2_4_3 = "2.4.3";
+
+ /**
+ * OpenCV Library version 2.4.4.
+ */
+ public static final String OPENCV_VERSION_2_4_4 = "2.4.4";
+
+ /**
+ * OpenCV Library version 2.4.5.
+ */
+ public static final String OPENCV_VERSION_2_4_5 = "2.4.5";
+
+ /**
+ * OpenCV Library version 2.4.6.
+ */
+ public static final String OPENCV_VERSION_2_4_6 = "2.4.6";
+
+ /**
+ * OpenCV Library version 2.4.7.
+ */
+ public static final String OPENCV_VERSION_2_4_7 = "2.4.7";
+
+ /**
+ * OpenCV Library version 2.4.8.
+ */
+ public static final String OPENCV_VERSION_2_4_8 = "2.4.8";
+
+ /**
+ * OpenCV Library version 2.4.9.
+ */
+ public static final String OPENCV_VERSION_2_4_9 = "2.4.9";
+
+ /**
+ * OpenCV Library version 2.4.10.
+ */
+ public static final String OPENCV_VERSION_2_4_10 = "2.4.10";
+
+ /**
+ * OpenCV Library version 2.4.11.
+ */
+ public static final String OPENCV_VERSION_2_4_11 = "2.4.11";
+
+ /**
+ * OpenCV Library version 2.4.12.
+ */
+ public static final String OPENCV_VERSION_2_4_12 = "2.4.12";
+
+ /**
+ * OpenCV Library version 2.4.13.
+ */
+ public static final String OPENCV_VERSION_2_4_13 = "2.4.13";
+
+ /**
+ * OpenCV Library version 3.0.0.
+ */
+ public static final String OPENCV_VERSION_3_0_0 = "3.0.0";
+
+ /**
+ * OpenCV Library version 3.1.0.
+ */
+ public static final String OPENCV_VERSION_3_1_0 = "3.1.0";
+
+ /**
+ * OpenCV Library version 3.2.0.
+ */
+ public static final String OPENCV_VERSION_3_2_0 = "3.2.0";
+
+ /**
+ * OpenCV Library version 3.3.0.
+ */
+ public static final String OPENCV_VERSION_3_3_0 = "3.3.0";
+
+ /**
+ * OpenCV Library version 3.4.0.
+ */
+ public static final String OPENCV_VERSION_3_4_0 = "3.4.0";
+
+ /**
+ * Current OpenCV Library version
+ */
+ public static final String OPENCV_VERSION = "4.8.1";
+
+
+ /**
+ * Loads and initializes OpenCV library from current application package. Roughly, it's an analog of system.loadLibrary("opencv_java").
+ * @return Returns true is initialization of OpenCV was successful.
+ */
+ public static boolean initDebug()
+ {
+ return StaticHelper.initOpenCV(false);
+ }
+
+ /**
+ * Loads and initializes OpenCV library from current application package. Roughly, it's an analog of system.loadLibrary("opencv_java").
+ * @param InitCuda load and initialize CUDA runtime libraries.
+ * @return Returns true is initialization of OpenCV was successful.
+ */
+ public static boolean initDebug(boolean InitCuda)
+ {
+ return StaticHelper.initOpenCV(InitCuda);
+ }
+
+ /**
+ * Loads and initializes OpenCV library using OpenCV Engine service.
+ * @param Version OpenCV library version.
+ * @param AppContext application context for connecting to the service.
+ * @param Callback object, that implements LoaderCallbackInterface for handling the connection status.
+ * @return Returns true if initialization of OpenCV is successful.
+ */
+ public static boolean initAsync(String Version, Context AppContext,
+ LoaderCallbackInterface Callback)
+ {
+ return AsyncServiceHelper.initOpenCV(Version, AppContext, Callback);
+ }
+}
diff --git a/ZPI-App/opencv/java/src/org/opencv/android/StaticHelper.java b/ZPI-App/opencv/java/src/org/opencv/android/StaticHelper.java
new file mode 100644
index 000000000..934dd7570
--- /dev/null
+++ b/ZPI-App/opencv/java/src/org/opencv/android/StaticHelper.java
@@ -0,0 +1,104 @@
+package org.opencv.android;
+
+import org.opencv.core.Core;
+
+import java.util.StringTokenizer;
+import android.util.Log;
+
+class StaticHelper {
+
+ public static boolean initOpenCV(boolean InitCuda)
+ {
+ boolean result;
+ String libs = "";
+
+ if(InitCuda)
+ {
+ loadLibrary("cudart");
+ loadLibrary("nppc");
+ loadLibrary("nppi");
+ loadLibrary("npps");
+ loadLibrary("cufft");
+ loadLibrary("cublas");
+ }
+
+ Log.d(TAG, "Trying to get library list");
+
+ try
+ {
+ System.loadLibrary("opencv_info");
+ libs = getLibraryList();
+ }
+ catch(UnsatisfiedLinkError e)
+ {
+ Log.e(TAG, "OpenCV error: Cannot load info library for OpenCV");
+ }
+
+ Log.d(TAG, "Library list: \"" + libs + "\"");
+ Log.d(TAG, "First attempt to load libs");
+ if (initOpenCVLibs(libs))
+ {
+ Log.d(TAG, "First attempt to load libs is OK");
+ String eol = System.getProperty("line.separator");
+ for (String str : Core.getBuildInformation().split(eol))
+ Log.i(TAG, str);
+
+ result = true;
+ }
+ else
+ {
+ Log.d(TAG, "First attempt to load libs fails");
+ result = false;
+ }
+
+ return result;
+ }
+
+ private static boolean loadLibrary(String Name)
+ {
+ boolean result = true;
+
+ Log.d(TAG, "Trying to load library " + Name);
+ try
+ {
+ System.loadLibrary(Name);
+ Log.d(TAG, "Library " + Name + " loaded");
+ }
+ catch(UnsatisfiedLinkError e)
+ {
+ Log.d(TAG, "Cannot load library \"" + Name + "\"");
+ e.printStackTrace();
+ result = false;
+ }
+
+ return result;
+ }
+
+ private static boolean initOpenCVLibs(String Libs)
+ {
+ Log.d(TAG, "Trying to init OpenCV libs");
+
+ boolean result = true;
+
+ if ((null != Libs) && (Libs.length() != 0))
+ {
+ Log.d(TAG, "Trying to load libs by dependency list");
+ StringTokenizer splitter = new StringTokenizer(Libs, ";");
+ while(splitter.hasMoreTokens())
+ {
+ result &= loadLibrary(splitter.nextToken());
+ }
+ }
+ else
+ {
+ // If dependencies list is not defined or empty.
+ result = loadLibrary("opencv_java4");
+ }
+
+ return result;
+ }
+
+ private static final String TAG = "OpenCV/StaticHelper";
+
+ private static native String getLibraryList();
+}
diff --git a/ZPI-App/opencv/java/src/org/opencv/android/Utils.java b/ZPI-App/opencv/java/src/org/opencv/android/Utils.java
new file mode 100644
index 000000000..eef4c4562
--- /dev/null
+++ b/ZPI-App/opencv/java/src/org/opencv/android/Utils.java
@@ -0,0 +1,139 @@
+package org.opencv.android;
+
+import android.content.Context;
+import android.graphics.Bitmap;
+
+import org.opencv.core.CvException;
+import org.opencv.core.CvType;
+import org.opencv.core.Mat;
+import org.opencv.imgcodecs.Imgcodecs;
+
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+
+public class Utils {
+
+ public static String exportResource(Context context, int resourceId) {
+ return exportResource(context, resourceId, "OpenCV_data");
+ }
+
+ public static String exportResource(Context context, int resourceId, String dirname) {
+ String fullname = context.getResources().getString(resourceId);
+ String resName = fullname.substring(fullname.lastIndexOf("/") + 1);
+ try {
+ InputStream is = context.getResources().openRawResource(resourceId);
+ File resDir = context.getDir(dirname, Context.MODE_PRIVATE);
+ File resFile = new File(resDir, resName);
+
+ FileOutputStream os = new FileOutputStream(resFile);
+
+ byte[] buffer = new byte[4096];
+ int bytesRead;
+ while ((bytesRead = is.read(buffer)) != -1) {
+ os.write(buffer, 0, bytesRead);
+ }
+ is.close();
+ os.close();
+
+ return resFile.getAbsolutePath();
+ } catch (IOException e) {
+ e.printStackTrace();
+ throw new CvException("Failed to export resource " + resName
+ + ". Exception thrown: " + e);
+ }
+ }
+
+ public static Mat loadResource(Context context, int resourceId) throws IOException
+ {
+ return loadResource(context, resourceId, -1);
+ }
+
+ public static Mat loadResource(Context context, int resourceId, int flags) throws IOException
+ {
+ InputStream is = context.getResources().openRawResource(resourceId);
+ ByteArrayOutputStream os = new ByteArrayOutputStream(is.available());
+
+ byte[] buffer = new byte[4096];
+ int bytesRead;
+ while ((bytesRead = is.read(buffer)) != -1) {
+ os.write(buffer, 0, bytesRead);
+ }
+ is.close();
+
+ Mat encoded = new Mat(1, os.size(), CvType.CV_8U);
+ encoded.put(0, 0, os.toByteArray());
+ os.close();
+
+ Mat decoded = Imgcodecs.imdecode(encoded, flags);
+ encoded.release();
+
+ return decoded;
+ }
+
+ /**
+ * Converts Android Bitmap to OpenCV Mat.
+ *
+ * This function converts an Android Bitmap image to the OpenCV Mat.
+ * 'ARGB_8888' and 'RGB_565' input Bitmap formats are supported.
+ * The output Mat is always created of the same size as the input Bitmap and of the 'CV_8UC4' type,
+ * it keeps the image in RGBA format.
+ * This function throws an exception if the conversion fails.
+ * @param bmp is a valid input Bitmap object of the type 'ARGB_8888' or 'RGB_565'.
+ * @param mat is a valid output Mat object, it will be reallocated if needed, so it may be empty.
+ * @param unPremultiplyAlpha is a flag, that determines, whether the bitmap needs to be converted from alpha premultiplied format (like Android keeps 'ARGB_8888' ones) to regular one; this flag is ignored for 'RGB_565' bitmaps.
+ */
+ public static void bitmapToMat(Bitmap bmp, Mat mat, boolean unPremultiplyAlpha) {
+ if (bmp == null)
+ throw new IllegalArgumentException("bmp == null");
+ if (mat == null)
+ throw new IllegalArgumentException("mat == null");
+ nBitmapToMat2(bmp, mat.nativeObj, unPremultiplyAlpha);
+ }
+
+ /**
+ * Short form of the bitmapToMat(bmp, mat, unPremultiplyAlpha=false).
+ * @param bmp is a valid input Bitmap object of the type 'ARGB_8888' or 'RGB_565'.
+ * @param mat is a valid output Mat object, it will be reallocated if needed, so Mat may be empty.
+ */
+ public static void bitmapToMat(Bitmap bmp, Mat mat) {
+ bitmapToMat(bmp, mat, false);
+ }
+
+
+ /**
+ * Converts OpenCV Mat to Android Bitmap.
+ *
+ * This function converts an image in the OpenCV Mat representation to the Android Bitmap.
+ * The input Mat object has to be of the types 'CV_8UC1' (gray-scale), 'CV_8UC3' (RGB) or 'CV_8UC4' (RGBA).
+ * The output Bitmap object has to be of the same size as the input Mat and of the types 'ARGB_8888' or 'RGB_565'.
+ * This function throws an exception if the conversion fails.
+ *
+ * @param mat is a valid input Mat object of types 'CV_8UC1', 'CV_8UC3' or 'CV_8UC4'.
+ * @param bmp is a valid Bitmap object of the same size as the Mat and of type 'ARGB_8888' or 'RGB_565'.
+ * @param premultiplyAlpha is a flag, that determines, whether the Mat needs to be converted to alpha premultiplied format (like Android keeps 'ARGB_8888' bitmaps); the flag is ignored for 'RGB_565' bitmaps.
+ */
+ public static void matToBitmap(Mat mat, Bitmap bmp, boolean premultiplyAlpha) {
+ if (mat == null)
+ throw new IllegalArgumentException("mat == null");
+ if (bmp == null)
+ throw new IllegalArgumentException("bmp == null");
+ nMatToBitmap2(mat.nativeObj, bmp, premultiplyAlpha);
+ }
+
+ /**
+ * Short form of the matToBitmap(mat, bmp, premultiplyAlpha=false)
+ * @param mat is a valid input Mat object of the types 'CV_8UC1', 'CV_8UC3' or 'CV_8UC4'.
+ * @param bmp is a valid Bitmap object of the same size as the Mat and of type 'ARGB_8888' or 'RGB_565'.
+ */
+ public static void matToBitmap(Mat mat, Bitmap bmp) {
+ matToBitmap(mat, bmp, false);
+ }
+
+
+ private static native void nBitmapToMat2(Bitmap b, long m_addr, boolean unPremultiplyAlpha);
+
+ private static native void nMatToBitmap2(long m_addr, Bitmap b, boolean premultiplyAlpha);
+}
diff --git a/ZPI-App/opencv/java/src/org/opencv/calib3d/Calib3d.java b/ZPI-App/opencv/java/src/org/opencv/calib3d/Calib3d.java
new file mode 100644
index 000000000..8e3741b31
--- /dev/null
+++ b/ZPI-App/opencv/java/src/org/opencv/calib3d/Calib3d.java
@@ -0,0 +1,12296 @@
+//
+// This file is auto-generated. Please don't modify it!
+//
+package org.opencv.calib3d;
+
+import java.util.ArrayList;
+import java.util.List;
+import org.opencv.calib3d.UsacParams;
+import org.opencv.core.Mat;
+import org.opencv.core.MatOfDouble;
+import org.opencv.core.MatOfPoint2f;
+import org.opencv.core.MatOfPoint3f;
+import org.opencv.core.Point;
+import org.opencv.core.Rect;
+import org.opencv.core.Scalar;
+import org.opencv.core.Size;
+import org.opencv.core.TermCriteria;
+import org.opencv.utils.Converters;
+
+// C++: class Calib3d
+
+public class Calib3d {
+
+ // C++: enum
+ public static final int
+ CV_ITERATIVE = 0,
+ CV_EPNP = 1,
+ CV_P3P = 2,
+ CV_DLS = 3,
+ CvLevMarq_DONE = 0,
+ CvLevMarq_STARTED = 1,
+ CvLevMarq_CALC_J = 2,
+ CvLevMarq_CHECK_ERR = 3,
+ LMEDS = 4,
+ RANSAC = 8,
+ RHO = 16,
+ USAC_DEFAULT = 32,
+ USAC_PARALLEL = 33,
+ USAC_FM_8PTS = 34,
+ USAC_FAST = 35,
+ USAC_ACCURATE = 36,
+ USAC_PROSAC = 37,
+ USAC_MAGSAC = 38,
+ CALIB_CB_ADAPTIVE_THRESH = 1,
+ CALIB_CB_NORMALIZE_IMAGE = 2,
+ CALIB_CB_FILTER_QUADS = 4,
+ CALIB_CB_FAST_CHECK = 8,
+ CALIB_CB_EXHAUSTIVE = 16,
+ CALIB_CB_ACCURACY = 32,
+ CALIB_CB_LARGER = 64,
+ CALIB_CB_MARKER = 128,
+ CALIB_CB_SYMMETRIC_GRID = 1,
+ CALIB_CB_ASYMMETRIC_GRID = 2,
+ CALIB_CB_CLUSTERING = 4,
+ CALIB_NINTRINSIC = 18,
+ CALIB_USE_INTRINSIC_GUESS = 0x00001,
+ CALIB_FIX_ASPECT_RATIO = 0x00002,
+ CALIB_FIX_PRINCIPAL_POINT = 0x00004,
+ CALIB_ZERO_TANGENT_DIST = 0x00008,
+ CALIB_FIX_FOCAL_LENGTH = 0x00010,
+ CALIB_FIX_K1 = 0x00020,
+ CALIB_FIX_K2 = 0x00040,
+ CALIB_FIX_K3 = 0x00080,
+ CALIB_FIX_K4 = 0x00800,
+ CALIB_FIX_K5 = 0x01000,
+ CALIB_FIX_K6 = 0x02000,
+ CALIB_RATIONAL_MODEL = 0x04000,
+ CALIB_THIN_PRISM_MODEL = 0x08000,
+ CALIB_FIX_S1_S2_S3_S4 = 0x10000,
+ CALIB_TILTED_MODEL = 0x40000,
+ CALIB_FIX_TAUX_TAUY = 0x80000,
+ CALIB_USE_QR = 0x100000,
+ CALIB_FIX_TANGENT_DIST = 0x200000,
+ CALIB_FIX_INTRINSIC = 0x00100,
+ CALIB_SAME_FOCAL_LENGTH = 0x00200,
+ CALIB_ZERO_DISPARITY = 0x00400,
+ CALIB_USE_LU = (1 << 17),
+ CALIB_USE_EXTRINSIC_GUESS = (1 << 22),
+ FM_7POINT = 1,
+ FM_8POINT = 2,
+ FM_LMEDS = 4,
+ FM_RANSAC = 8,
+ fisheye_CALIB_USE_INTRINSIC_GUESS = 1 << 0,
+ fisheye_CALIB_RECOMPUTE_EXTRINSIC = 1 << 1,
+ fisheye_CALIB_CHECK_COND = 1 << 2,
+ fisheye_CALIB_FIX_SKEW = 1 << 3,
+ fisheye_CALIB_FIX_K1 = 1 << 4,
+ fisheye_CALIB_FIX_K2 = 1 << 5,
+ fisheye_CALIB_FIX_K3 = 1 << 6,
+ fisheye_CALIB_FIX_K4 = 1 << 7,
+ fisheye_CALIB_FIX_INTRINSIC = 1 << 8,
+ fisheye_CALIB_FIX_PRINCIPAL_POINT = 1 << 9,
+ fisheye_CALIB_ZERO_DISPARITY = 1 << 10,
+ fisheye_CALIB_FIX_FOCAL_LENGTH = 1 << 11;
+
+
+ // C++: enum GridType (cv.CirclesGridFinderParameters.GridType)
+ public static final int
+ CirclesGridFinderParameters_SYMMETRIC_GRID = 0,
+ CirclesGridFinderParameters_ASYMMETRIC_GRID = 1;
+
+
+ // C++: enum HandEyeCalibrationMethod (cv.HandEyeCalibrationMethod)
+ public static final int
+ CALIB_HAND_EYE_TSAI = 0,
+ CALIB_HAND_EYE_PARK = 1,
+ CALIB_HAND_EYE_HORAUD = 2,
+ CALIB_HAND_EYE_ANDREFF = 3,
+ CALIB_HAND_EYE_DANIILIDIS = 4;
+
+
+ // C++: enum LocalOptimMethod (cv.LocalOptimMethod)
+ public static final int
+ LOCAL_OPTIM_NULL = 0,
+ LOCAL_OPTIM_INNER_LO = 1,
+ LOCAL_OPTIM_INNER_AND_ITER_LO = 2,
+ LOCAL_OPTIM_GC = 3,
+ LOCAL_OPTIM_SIGMA = 4;
+
+
+ // C++: enum NeighborSearchMethod (cv.NeighborSearchMethod)
+ public static final int
+ NEIGH_FLANN_KNN = 0,
+ NEIGH_GRID = 1,
+ NEIGH_FLANN_RADIUS = 2;
+
+
+ // C++: enum PolishingMethod (cv.PolishingMethod)
+ public static final int
+ NONE_POLISHER = 0,
+ LSQ_POLISHER = 1,
+ MAGSAC = 2,
+ COV_POLISHER = 3;
+
+
+ // C++: enum RobotWorldHandEyeCalibrationMethod (cv.RobotWorldHandEyeCalibrationMethod)
+ public static final int
+ CALIB_ROBOT_WORLD_HAND_EYE_SHAH = 0,
+ CALIB_ROBOT_WORLD_HAND_EYE_LI = 1;
+
+
+ // C++: enum SamplingMethod (cv.SamplingMethod)
+ public static final int
+ SAMPLING_UNIFORM = 0,
+ SAMPLING_PROGRESSIVE_NAPSAC = 1,
+ SAMPLING_NAPSAC = 2,
+ SAMPLING_PROSAC = 3;
+
+
+ // C++: enum ScoreMethod (cv.ScoreMethod)
+ public static final int
+ SCORE_METHOD_RANSAC = 0,
+ SCORE_METHOD_MSAC = 1,
+ SCORE_METHOD_MAGSAC = 2,
+ SCORE_METHOD_LMEDS = 3;
+
+
+ // C++: enum SolvePnPMethod (cv.SolvePnPMethod)
+ public static final int
+ SOLVEPNP_ITERATIVE = 0,
+ SOLVEPNP_EPNP = 1,
+ SOLVEPNP_P3P = 2,
+ SOLVEPNP_DLS = 3,
+ SOLVEPNP_UPNP = 4,
+ SOLVEPNP_AP3P = 5,
+ SOLVEPNP_IPPE = 6,
+ SOLVEPNP_IPPE_SQUARE = 7,
+ SOLVEPNP_SQPNP = 8,
+ SOLVEPNP_MAX_COUNT = 8+1;
+
+
+ // C++: enum UndistortTypes (cv.UndistortTypes)
+ public static final int
+ PROJ_SPHERICAL_ORTHO = 0,
+ PROJ_SPHERICAL_EQRECT = 1;
+
+
+ //
+ // C++: void cv::Rodrigues(Mat src, Mat& dst, Mat& jacobian = Mat())
+ //
+
+ /**
+ * Converts a rotation matrix to a rotation vector or vice versa.
+ *
+ * @param src Input rotation vector (3x1 or 1x3) or rotation matrix (3x3).
+ * @param dst Output rotation matrix (3x3) or rotation vector (3x1 or 1x3), respectively.
+ * @param jacobian Optional output Jacobian matrix, 3x9 or 9x3, which is a matrix of partial
+ * derivatives of the output array components with respect to the input array components.
+ *
+ * \(\begin{array}{l} \theta \leftarrow norm(r) \\ r \leftarrow r/ \theta \\ R = \cos(\theta) I + (1- \cos{\theta} ) r r^T + \sin(\theta) \vecthreethree{0}{-r_z}{r_y}{r_z}{0}{-r_x}{-r_y}{r_x}{0} \end{array}\)
+ *
+ * Inverse transformation can be also done easily, since
+ *
+ * \(\sin ( \theta ) \vecthreethree{0}{-r_z}{r_y}{r_z}{0}{-r_x}{-r_y}{r_x}{0} = \frac{R - R^T}{2}\)
+ *
+ * A rotation vector is a convenient and most compact representation of a rotation matrix (since any
+ * rotation matrix has just 3 degrees of freedom). The representation is used in the global 3D geometry
+ * optimization procedures like REF: calibrateCamera, REF: stereoCalibrate, or REF: solvePnP .
+ *
+ * Note: More information about the computation of the derivative of a 3D rotation matrix with respect to its exponential coordinate
+ * can be found in:
+ *
+ *
+ * A Compact Formula for the Derivative of a 3-D Rotation in Exponential Coordinates, Guillermo Gallego, Anthony J. Yezzi CITE: Gallego2014ACF
+ *
+ *
+ *
+ * Note: Useful information on SE(3) and Lie Groups can be found in:
+ *
+ *
+ * A tutorial on SE(3) transformation parameterizations and on-manifold optimization, Jose-Luis Blanco CITE: blanco2010tutorial
+ *
+ *
+ * Lie Groups for 2D and 3D Transformation, Ethan Eade CITE: Eade17
+ *
+ *
+ * A micro Lie theory for state estimation in robotics, Joan Solà, Jérémie Deray, Dinesh Atchuthan CITE: Sol2018AML
+ *
+ *
+ */
+ public static void Rodrigues(Mat src, Mat dst, Mat jacobian) {
+ Rodrigues_0(src.nativeObj, dst.nativeObj, jacobian.nativeObj);
+ }
+
+ /**
+ * Converts a rotation matrix to a rotation vector or vice versa.
+ *
+ * @param src Input rotation vector (3x1 or 1x3) or rotation matrix (3x3).
+ * @param dst Output rotation matrix (3x3) or rotation vector (3x1 or 1x3), respectively.
+ * derivatives of the output array components with respect to the input array components.
+ *
+ * \(\begin{array}{l} \theta \leftarrow norm(r) \\ r \leftarrow r/ \theta \\ R = \cos(\theta) I + (1- \cos{\theta} ) r r^T + \sin(\theta) \vecthreethree{0}{-r_z}{r_y}{r_z}{0}{-r_x}{-r_y}{r_x}{0} \end{array}\)
+ *
+ * Inverse transformation can be also done easily, since
+ *
+ * \(\sin ( \theta ) \vecthreethree{0}{-r_z}{r_y}{r_z}{0}{-r_x}{-r_y}{r_x}{0} = \frac{R - R^T}{2}\)
+ *
+ * A rotation vector is a convenient and most compact representation of a rotation matrix (since any
+ * rotation matrix has just 3 degrees of freedom). The representation is used in the global 3D geometry
+ * optimization procedures like REF: calibrateCamera, REF: stereoCalibrate, or REF: solvePnP .
+ *
+ * Note: More information about the computation of the derivative of a 3D rotation matrix with respect to its exponential coordinate
+ * can be found in:
+ *
+ *
+ * A Compact Formula for the Derivative of a 3-D Rotation in Exponential Coordinates, Guillermo Gallego, Anthony J. Yezzi CITE: Gallego2014ACF
+ *
+ *
+ *
+ * Note: Useful information on SE(3) and Lie Groups can be found in:
+ *
+ *
+ * A tutorial on SE(3) transformation parameterizations and on-manifold optimization, Jose-Luis Blanco CITE: blanco2010tutorial
+ *
+ *
+ * Lie Groups for 2D and 3D Transformation, Ethan Eade CITE: Eade17
+ *
+ *
+ * A micro Lie theory for state estimation in robotics, Joan Solà, Jérémie Deray, Dinesh Atchuthan CITE: Sol2018AML
+ *
+ *
+ */
+ public static void Rodrigues(Mat src, Mat dst) {
+ Rodrigues_1(src.nativeObj, dst.nativeObj);
+ }
+
+
+ //
+ // C++: Mat cv::findHomography(vector_Point2f srcPoints, vector_Point2f dstPoints, int method = 0, double ransacReprojThreshold = 3, Mat& mask = Mat(), int maxIters = 2000, double confidence = 0.995)
+ //
+
+ /**
+ * Finds a perspective transformation between two planes.
+ *
+ * @param srcPoints Coordinates of the points in the original plane, a matrix of the type CV_32FC2
+ * or vector<Point2f> .
+ * @param dstPoints Coordinates of the points in the target plane, a matrix of the type CV_32FC2 or
+ * a vector<Point2f> .
+ * @param method Method used to compute a homography matrix. The following methods are possible:
+ *
+ *
+ * 0 - a regular method using all the points, i.e., the least squares method
+ *
+ *
+ * REF: RANSAC - RANSAC-based robust method
+ *
+ *
+ * REF: LMEDS - Least-Median robust method
+ *
+ *
+ * REF: RHO - PROSAC-based robust method
+ *
+ *
+ * @param ransacReprojThreshold Maximum allowed reprojection error to treat a point pair as an inlier
+ * (used in the RANSAC and RHO methods only). That is, if
+ * \(\| \texttt{dstPoints} _i - \texttt{convertPointsHomogeneous} ( \texttt{H} \cdot \texttt{srcPoints} _i) \|_2 > \texttt{ransacReprojThreshold}\)
+ * then the point \(i\) is considered as an outlier. If srcPoints and dstPoints are measured in pixels,
+ * it usually makes sense to set this parameter somewhere in the range of 1 to 10.
+ * @param mask Optional output mask set by a robust method ( RANSAC or LMeDS ). Note that the input
+ * mask values are ignored.
+ * @param maxIters The maximum number of RANSAC iterations.
+ * @param confidence Confidence level, between 0 and 1.
+ *
+ * The function finds and returns the perspective transformation \(H\) between the source and the
+ * destination planes:
+ *
+ * \(s_i \vecthree{x'_i}{y'_i}{1} \sim H \vecthree{x_i}{y_i}{1}\)
+ *
+ * so that the back-projection error
+ *
+ * \(\sum _i \left ( x'_i- \frac{h_{11} x_i + h_{12} y_i + h_{13}}{h_{31} x_i + h_{32} y_i + h_{33}} \right )^2+ \left ( y'_i- \frac{h_{21} x_i + h_{22} y_i + h_{23}}{h_{31} x_i + h_{32} y_i + h_{33}} \right )^2\)
+ *
+ * is minimized. If the parameter method is set to the default value 0, the function uses all the point
+ * pairs to compute an initial homography estimate with a simple least-squares scheme.
+ *
+ * However, if not all of the point pairs ( \(srcPoints_i\), \(dstPoints_i\) ) fit the rigid perspective
+ * transformation (that is, there are some outliers), this initial estimate will be poor. In this case,
+ * you can use one of the three robust methods. The methods RANSAC, LMeDS and RHO try many different
+ * random subsets of the corresponding point pairs (of four pairs each, collinear pairs are discarded), estimate the homography matrix
+ * using this subset and a simple least-squares algorithm, and then compute the quality/goodness of the
+ * computed homography (which is the number of inliers for RANSAC or the least median re-projection error for
+ * LMeDS). The best subset is then used to produce the initial estimate of the homography matrix and
+ * the mask of inliers/outliers.
+ *
+ * Regardless of the method, robust or not, the computed homography matrix is refined further (using
+ * inliers only in case of a robust method) with the Levenberg-Marquardt method to reduce the
+ * re-projection error even more.
+ *
+ * The methods RANSAC and RHO can handle practically any ratio of outliers but need a threshold to
+ * distinguish inliers from outliers. The method LMeDS does not need any threshold but it works
+ * correctly only when there are more than 50% of inliers. Finally, if there are no outliers and the
+ * noise is rather small, use the default method (method=0).
+ *
+ * The function is used to find initial intrinsic and extrinsic matrices. Homography matrix is
+ * determined up to a scale. Thus, it is normalized so that \(h_{33}=1\). Note that whenever an \(H\) matrix
+ * cannot be estimated, an empty one will be returned.
+ *
+ * SEE:
+ * getAffineTransform, estimateAffine2D, estimateAffinePartial2D, getPerspectiveTransform, warpPerspective,
+ * perspectiveTransform
+ * @return automatically generated
+ */
+ public static Mat findHomography(MatOfPoint2f srcPoints, MatOfPoint2f dstPoints, int method, double ransacReprojThreshold, Mat mask, int maxIters, double confidence) {
+ Mat srcPoints_mat = srcPoints;
+ Mat dstPoints_mat = dstPoints;
+ return new Mat(findHomography_0(srcPoints_mat.nativeObj, dstPoints_mat.nativeObj, method, ransacReprojThreshold, mask.nativeObj, maxIters, confidence));
+ }
+
+ /**
+ * Finds a perspective transformation between two planes.
+ *
+ * @param srcPoints Coordinates of the points in the original plane, a matrix of the type CV_32FC2
+ * or vector<Point2f> .
+ * @param dstPoints Coordinates of the points in the target plane, a matrix of the type CV_32FC2 or
+ * a vector<Point2f> .
+ * @param method Method used to compute a homography matrix. The following methods are possible:
+ *
+ *
+ * 0 - a regular method using all the points, i.e., the least squares method
+ *
+ *
+ * REF: RANSAC - RANSAC-based robust method
+ *
+ *
+ * REF: LMEDS - Least-Median robust method
+ *
+ *
+ * REF: RHO - PROSAC-based robust method
+ *
+ *
+ * @param ransacReprojThreshold Maximum allowed reprojection error to treat a point pair as an inlier
+ * (used in the RANSAC and RHO methods only). That is, if
+ * \(\| \texttt{dstPoints} _i - \texttt{convertPointsHomogeneous} ( \texttt{H} \cdot \texttt{srcPoints} _i) \|_2 > \texttt{ransacReprojThreshold}\)
+ * then the point \(i\) is considered as an outlier. If srcPoints and dstPoints are measured in pixels,
+ * it usually makes sense to set this parameter somewhere in the range of 1 to 10.
+ * @param mask Optional output mask set by a robust method ( RANSAC or LMeDS ). Note that the input
+ * mask values are ignored.
+ * @param maxIters The maximum number of RANSAC iterations.
+ *
+ * The function finds and returns the perspective transformation \(H\) between the source and the
+ * destination planes:
+ *
+ * \(s_i \vecthree{x'_i}{y'_i}{1} \sim H \vecthree{x_i}{y_i}{1}\)
+ *
+ * so that the back-projection error
+ *
+ * \(\sum _i \left ( x'_i- \frac{h_{11} x_i + h_{12} y_i + h_{13}}{h_{31} x_i + h_{32} y_i + h_{33}} \right )^2+ \left ( y'_i- \frac{h_{21} x_i + h_{22} y_i + h_{23}}{h_{31} x_i + h_{32} y_i + h_{33}} \right )^2\)
+ *
+ * is minimized. If the parameter method is set to the default value 0, the function uses all the point
+ * pairs to compute an initial homography estimate with a simple least-squares scheme.
+ *
+ * However, if not all of the point pairs ( \(srcPoints_i\), \(dstPoints_i\) ) fit the rigid perspective
+ * transformation (that is, there are some outliers), this initial estimate will be poor. In this case,
+ * you can use one of the three robust methods. The methods RANSAC, LMeDS and RHO try many different
+ * random subsets of the corresponding point pairs (of four pairs each, collinear pairs are discarded), estimate the homography matrix
+ * using this subset and a simple least-squares algorithm, and then compute the quality/goodness of the
+ * computed homography (which is the number of inliers for RANSAC or the least median re-projection error for
+ * LMeDS). The best subset is then used to produce the initial estimate of the homography matrix and
+ * the mask of inliers/outliers.
+ *
+ * Regardless of the method, robust or not, the computed homography matrix is refined further (using
+ * inliers only in case of a robust method) with the Levenberg-Marquardt method to reduce the
+ * re-projection error even more.
+ *
+ * The methods RANSAC and RHO can handle practically any ratio of outliers but need a threshold to
+ * distinguish inliers from outliers. The method LMeDS does not need any threshold but it works
+ * correctly only when there are more than 50% of inliers. Finally, if there are no outliers and the
+ * noise is rather small, use the default method (method=0).
+ *
+ * The function is used to find initial intrinsic and extrinsic matrices. Homography matrix is
+ * determined up to a scale. Thus, it is normalized so that \(h_{33}=1\). Note that whenever an \(H\) matrix
+ * cannot be estimated, an empty one will be returned.
+ *
+ * SEE:
+ * getAffineTransform, estimateAffine2D, estimateAffinePartial2D, getPerspectiveTransform, warpPerspective,
+ * perspectiveTransform
+ * @return automatically generated
+ */
+ public static Mat findHomography(MatOfPoint2f srcPoints, MatOfPoint2f dstPoints, int method, double ransacReprojThreshold, Mat mask, int maxIters) {
+ Mat srcPoints_mat = srcPoints;
+ Mat dstPoints_mat = dstPoints;
+ return new Mat(findHomography_1(srcPoints_mat.nativeObj, dstPoints_mat.nativeObj, method, ransacReprojThreshold, mask.nativeObj, maxIters));
+ }
+
+ /**
+ * Finds a perspective transformation between two planes.
+ *
+ * @param srcPoints Coordinates of the points in the original plane, a matrix of the type CV_32FC2
+ * or vector<Point2f> .
+ * @param dstPoints Coordinates of the points in the target plane, a matrix of the type CV_32FC2 or
+ * a vector<Point2f> .
+ * @param method Method used to compute a homography matrix. The following methods are possible:
+ *
+ *
+ * 0 - a regular method using all the points, i.e., the least squares method
+ *
+ *
+ * REF: RANSAC - RANSAC-based robust method
+ *
+ *
+ * REF: LMEDS - Least-Median robust method
+ *
+ *
+ * REF: RHO - PROSAC-based robust method
+ *
+ *
+ * @param ransacReprojThreshold Maximum allowed reprojection error to treat a point pair as an inlier
+ * (used in the RANSAC and RHO methods only). That is, if
+ * \(\| \texttt{dstPoints} _i - \texttt{convertPointsHomogeneous} ( \texttt{H} \cdot \texttt{srcPoints} _i) \|_2 > \texttt{ransacReprojThreshold}\)
+ * then the point \(i\) is considered as an outlier. If srcPoints and dstPoints are measured in pixels,
+ * it usually makes sense to set this parameter somewhere in the range of 1 to 10.
+ * @param mask Optional output mask set by a robust method ( RANSAC or LMeDS ). Note that the input
+ * mask values are ignored.
+ *
+ * The function finds and returns the perspective transformation \(H\) between the source and the
+ * destination planes:
+ *
+ * \(s_i \vecthree{x'_i}{y'_i}{1} \sim H \vecthree{x_i}{y_i}{1}\)
+ *
+ * so that the back-projection error
+ *
+ * \(\sum _i \left ( x'_i- \frac{h_{11} x_i + h_{12} y_i + h_{13}}{h_{31} x_i + h_{32} y_i + h_{33}} \right )^2+ \left ( y'_i- \frac{h_{21} x_i + h_{22} y_i + h_{23}}{h_{31} x_i + h_{32} y_i + h_{33}} \right )^2\)
+ *
+ * is minimized. If the parameter method is set to the default value 0, the function uses all the point
+ * pairs to compute an initial homography estimate with a simple least-squares scheme.
+ *
+ * However, if not all of the point pairs ( \(srcPoints_i\), \(dstPoints_i\) ) fit the rigid perspective
+ * transformation (that is, there are some outliers), this initial estimate will be poor. In this case,
+ * you can use one of the three robust methods. The methods RANSAC, LMeDS and RHO try many different
+ * random subsets of the corresponding point pairs (of four pairs each, collinear pairs are discarded), estimate the homography matrix
+ * using this subset and a simple least-squares algorithm, and then compute the quality/goodness of the
+ * computed homography (which is the number of inliers for RANSAC or the least median re-projection error for
+ * LMeDS). The best subset is then used to produce the initial estimate of the homography matrix and
+ * the mask of inliers/outliers.
+ *
+ * Regardless of the method, robust or not, the computed homography matrix is refined further (using
+ * inliers only in case of a robust method) with the Levenberg-Marquardt method to reduce the
+ * re-projection error even more.
+ *
+ * The methods RANSAC and RHO can handle practically any ratio of outliers but need a threshold to
+ * distinguish inliers from outliers. The method LMeDS does not need any threshold but it works
+ * correctly only when there are more than 50% of inliers. Finally, if there are no outliers and the
+ * noise is rather small, use the default method (method=0).
+ *
+ * The function is used to find initial intrinsic and extrinsic matrices. Homography matrix is
+ * determined up to a scale. Thus, it is normalized so that \(h_{33}=1\). Note that whenever an \(H\) matrix
+ * cannot be estimated, an empty one will be returned.
+ *
+ * SEE:
+ * getAffineTransform, estimateAffine2D, estimateAffinePartial2D, getPerspectiveTransform, warpPerspective,
+ * perspectiveTransform
+ * @return automatically generated
+ */
+ public static Mat findHomography(MatOfPoint2f srcPoints, MatOfPoint2f dstPoints, int method, double ransacReprojThreshold, Mat mask) {
+ Mat srcPoints_mat = srcPoints;
+ Mat dstPoints_mat = dstPoints;
+ return new Mat(findHomography_2(srcPoints_mat.nativeObj, dstPoints_mat.nativeObj, method, ransacReprojThreshold, mask.nativeObj));
+ }
+
+ /**
+ * Finds a perspective transformation between two planes.
+ *
+ * @param srcPoints Coordinates of the points in the original plane, a matrix of the type CV_32FC2
+ * or vector<Point2f> .
+ * @param dstPoints Coordinates of the points in the target plane, a matrix of the type CV_32FC2 or
+ * a vector<Point2f> .
+ * @param method Method used to compute a homography matrix. The following methods are possible:
+ *
+ *
+ * 0 - a regular method using all the points, i.e., the least squares method
+ *
+ *
+ * REF: RANSAC - RANSAC-based robust method
+ *
+ *
+ * REF: LMEDS - Least-Median robust method
+ *
+ *
+ * REF: RHO - PROSAC-based robust method
+ *
+ *
+ * @param ransacReprojThreshold Maximum allowed reprojection error to treat a point pair as an inlier
+ * (used in the RANSAC and RHO methods only). That is, if
+ * \(\| \texttt{dstPoints} _i - \texttt{convertPointsHomogeneous} ( \texttt{H} \cdot \texttt{srcPoints} _i) \|_2 > \texttt{ransacReprojThreshold}\)
+ * then the point \(i\) is considered as an outlier. If srcPoints and dstPoints are measured in pixels,
+ * it usually makes sense to set this parameter somewhere in the range of 1 to 10.
+ * mask values are ignored.
+ *
+ * The function finds and returns the perspective transformation \(H\) between the source and the
+ * destination planes:
+ *
+ * \(s_i \vecthree{x'_i}{y'_i}{1} \sim H \vecthree{x_i}{y_i}{1}\)
+ *
+ * so that the back-projection error
+ *
+ * \(\sum _i \left ( x'_i- \frac{h_{11} x_i + h_{12} y_i + h_{13}}{h_{31} x_i + h_{32} y_i + h_{33}} \right )^2+ \left ( y'_i- \frac{h_{21} x_i + h_{22} y_i + h_{23}}{h_{31} x_i + h_{32} y_i + h_{33}} \right )^2\)
+ *
+ * is minimized. If the parameter method is set to the default value 0, the function uses all the point
+ * pairs to compute an initial homography estimate with a simple least-squares scheme.
+ *
+ * However, if not all of the point pairs ( \(srcPoints_i\), \(dstPoints_i\) ) fit the rigid perspective
+ * transformation (that is, there are some outliers), this initial estimate will be poor. In this case,
+ * you can use one of the three robust methods. The methods RANSAC, LMeDS and RHO try many different
+ * random subsets of the corresponding point pairs (of four pairs each, collinear pairs are discarded), estimate the homography matrix
+ * using this subset and a simple least-squares algorithm, and then compute the quality/goodness of the
+ * computed homography (which is the number of inliers for RANSAC or the least median re-projection error for
+ * LMeDS). The best subset is then used to produce the initial estimate of the homography matrix and
+ * the mask of inliers/outliers.
+ *
+ * Regardless of the method, robust or not, the computed homography matrix is refined further (using
+ * inliers only in case of a robust method) with the Levenberg-Marquardt method to reduce the
+ * re-projection error even more.
+ *
+ * The methods RANSAC and RHO can handle practically any ratio of outliers but need a threshold to
+ * distinguish inliers from outliers. The method LMeDS does not need any threshold but it works
+ * correctly only when there are more than 50% of inliers. Finally, if there are no outliers and the
+ * noise is rather small, use the default method (method=0).
+ *
+ * The function is used to find initial intrinsic and extrinsic matrices. Homography matrix is
+ * determined up to a scale. Thus, it is normalized so that \(h_{33}=1\). Note that whenever an \(H\) matrix
+ * cannot be estimated, an empty one will be returned.
+ *
+ * SEE:
+ * getAffineTransform, estimateAffine2D, estimateAffinePartial2D, getPerspectiveTransform, warpPerspective,
+ * perspectiveTransform
+ * @return automatically generated
+ */
+ public static Mat findHomography(MatOfPoint2f srcPoints, MatOfPoint2f dstPoints, int method, double ransacReprojThreshold) {
+ Mat srcPoints_mat = srcPoints;
+ Mat dstPoints_mat = dstPoints;
+ return new Mat(findHomography_3(srcPoints_mat.nativeObj, dstPoints_mat.nativeObj, method, ransacReprojThreshold));
+ }
+
+ /**
+ * Finds a perspective transformation between two planes.
+ *
+ * @param srcPoints Coordinates of the points in the original plane, a matrix of the type CV_32FC2
+ * or vector<Point2f> .
+ * @param dstPoints Coordinates of the points in the target plane, a matrix of the type CV_32FC2 or
+ * a vector<Point2f> .
+ * @param method Method used to compute a homography matrix. The following methods are possible:
+ *
+ *
+ * 0 - a regular method using all the points, i.e., the least squares method
+ *
+ *
+ * REF: RANSAC - RANSAC-based robust method
+ *
+ *
+ * REF: LMEDS - Least-Median robust method
+ *
+ *
+ * REF: RHO - PROSAC-based robust method
+ *
+ *
+ * (used in the RANSAC and RHO methods only). That is, if
+ * \(\| \texttt{dstPoints} _i - \texttt{convertPointsHomogeneous} ( \texttt{H} \cdot \texttt{srcPoints} _i) \|_2 > \texttt{ransacReprojThreshold}\)
+ * then the point \(i\) is considered as an outlier. If srcPoints and dstPoints are measured in pixels,
+ * it usually makes sense to set this parameter somewhere in the range of 1 to 10.
+ * mask values are ignored.
+ *
+ * The function finds and returns the perspective transformation \(H\) between the source and the
+ * destination planes:
+ *
+ * \(s_i \vecthree{x'_i}{y'_i}{1} \sim H \vecthree{x_i}{y_i}{1}\)
+ *
+ * so that the back-projection error
+ *
+ * \(\sum _i \left ( x'_i- \frac{h_{11} x_i + h_{12} y_i + h_{13}}{h_{31} x_i + h_{32} y_i + h_{33}} \right )^2+ \left ( y'_i- \frac{h_{21} x_i + h_{22} y_i + h_{23}}{h_{31} x_i + h_{32} y_i + h_{33}} \right )^2\)
+ *
+ * is minimized. If the parameter method is set to the default value 0, the function uses all the point
+ * pairs to compute an initial homography estimate with a simple least-squares scheme.
+ *
+ * However, if not all of the point pairs ( \(srcPoints_i\), \(dstPoints_i\) ) fit the rigid perspective
+ * transformation (that is, there are some outliers), this initial estimate will be poor. In this case,
+ * you can use one of the three robust methods. The methods RANSAC, LMeDS and RHO try many different
+ * random subsets of the corresponding point pairs (of four pairs each, collinear pairs are discarded), estimate the homography matrix
+ * using this subset and a simple least-squares algorithm, and then compute the quality/goodness of the
+ * computed homography (which is the number of inliers for RANSAC or the least median re-projection error for
+ * LMeDS). The best subset is then used to produce the initial estimate of the homography matrix and
+ * the mask of inliers/outliers.
+ *
+ * Regardless of the method, robust or not, the computed homography matrix is refined further (using
+ * inliers only in case of a robust method) with the Levenberg-Marquardt method to reduce the
+ * re-projection error even more.
+ *
+ * The methods RANSAC and RHO can handle practically any ratio of outliers but need a threshold to
+ * distinguish inliers from outliers. The method LMeDS does not need any threshold but it works
+ * correctly only when there are more than 50% of inliers. Finally, if there are no outliers and the
+ * noise is rather small, use the default method (method=0).
+ *
+ * The function is used to find initial intrinsic and extrinsic matrices. Homography matrix is
+ * determined up to a scale. Thus, it is normalized so that \(h_{33}=1\). Note that whenever an \(H\) matrix
+ * cannot be estimated, an empty one will be returned.
+ *
+ * SEE:
+ * getAffineTransform, estimateAffine2D, estimateAffinePartial2D, getPerspectiveTransform, warpPerspective,
+ * perspectiveTransform
+ * @return automatically generated
+ */
+ public static Mat findHomography(MatOfPoint2f srcPoints, MatOfPoint2f dstPoints, int method) {
+ Mat srcPoints_mat = srcPoints;
+ Mat dstPoints_mat = dstPoints;
+ return new Mat(findHomography_4(srcPoints_mat.nativeObj, dstPoints_mat.nativeObj, method));
+ }
+
+ /**
+ * Finds a perspective transformation between two planes.
+ *
+ * @param srcPoints Coordinates of the points in the original plane, a matrix of the type CV_32FC2
+ * or vector<Point2f> .
+ * @param dstPoints Coordinates of the points in the target plane, a matrix of the type CV_32FC2 or
+ * a vector<Point2f> .
+ *
+ *
+ * 0 - a regular method using all the points, i.e., the least squares method
+ *
+ *
+ * REF: RANSAC - RANSAC-based robust method
+ *
+ *
+ * REF: LMEDS - Least-Median robust method
+ *
+ *
+ * REF: RHO - PROSAC-based robust method
+ *
+ *
+ * (used in the RANSAC and RHO methods only). That is, if
+ * \(\| \texttt{dstPoints} _i - \texttt{convertPointsHomogeneous} ( \texttt{H} \cdot \texttt{srcPoints} _i) \|_2 > \texttt{ransacReprojThreshold}\)
+ * then the point \(i\) is considered as an outlier. If srcPoints and dstPoints are measured in pixels,
+ * it usually makes sense to set this parameter somewhere in the range of 1 to 10.
+ * mask values are ignored.
+ *
+ * The function finds and returns the perspective transformation \(H\) between the source and the
+ * destination planes:
+ *
+ * \(s_i \vecthree{x'_i}{y'_i}{1} \sim H \vecthree{x_i}{y_i}{1}\)
+ *
+ * so that the back-projection error
+ *
+ * \(\sum _i \left ( x'_i- \frac{h_{11} x_i + h_{12} y_i + h_{13}}{h_{31} x_i + h_{32} y_i + h_{33}} \right )^2+ \left ( y'_i- \frac{h_{21} x_i + h_{22} y_i + h_{23}}{h_{31} x_i + h_{32} y_i + h_{33}} \right )^2\)
+ *
+ * is minimized. If the parameter method is set to the default value 0, the function uses all the point
+ * pairs to compute an initial homography estimate with a simple least-squares scheme.
+ *
+ * However, if not all of the point pairs ( \(srcPoints_i\), \(dstPoints_i\) ) fit the rigid perspective
+ * transformation (that is, there are some outliers), this initial estimate will be poor. In this case,
+ * you can use one of the three robust methods. The methods RANSAC, LMeDS and RHO try many different
+ * random subsets of the corresponding point pairs (of four pairs each, collinear pairs are discarded), estimate the homography matrix
+ * using this subset and a simple least-squares algorithm, and then compute the quality/goodness of the
+ * computed homography (which is the number of inliers for RANSAC or the least median re-projection error for
+ * LMeDS). The best subset is then used to produce the initial estimate of the homography matrix and
+ * the mask of inliers/outliers.
+ *
+ * Regardless of the method, robust or not, the computed homography matrix is refined further (using
+ * inliers only in case of a robust method) with the Levenberg-Marquardt method to reduce the
+ * re-projection error even more.
+ *
+ * The methods RANSAC and RHO can handle practically any ratio of outliers but need a threshold to
+ * distinguish inliers from outliers. The method LMeDS does not need any threshold but it works
+ * correctly only when there are more than 50% of inliers. Finally, if there are no outliers and the
+ * noise is rather small, use the default method (method=0).
+ *
+ * The function is used to find initial intrinsic and extrinsic matrices. Homography matrix is
+ * determined up to a scale. Thus, it is normalized so that \(h_{33}=1\). Note that whenever an \(H\) matrix
+ * cannot be estimated, an empty one will be returned.
+ *
+ * SEE:
+ * getAffineTransform, estimateAffine2D, estimateAffinePartial2D, getPerspectiveTransform, warpPerspective,
+ * perspectiveTransform
+ * @return automatically generated
+ */
+ public static Mat findHomography(MatOfPoint2f srcPoints, MatOfPoint2f dstPoints) {
+ Mat srcPoints_mat = srcPoints;
+ Mat dstPoints_mat = dstPoints;
+ return new Mat(findHomography_5(srcPoints_mat.nativeObj, dstPoints_mat.nativeObj));
+ }
+
+
+ //
+ // C++: Mat cv::findHomography(vector_Point2f srcPoints, vector_Point2f dstPoints, Mat& mask, UsacParams params)
+ //
+
+ public static Mat findHomography(MatOfPoint2f srcPoints, MatOfPoint2f dstPoints, Mat mask, UsacParams params) {
+ Mat srcPoints_mat = srcPoints;
+ Mat dstPoints_mat = dstPoints;
+ return new Mat(findHomography_6(srcPoints_mat.nativeObj, dstPoints_mat.nativeObj, mask.nativeObj, params.nativeObj));
+ }
+
+
+ //
+ // C++: Vec3d cv::RQDecomp3x3(Mat src, Mat& mtxR, Mat& mtxQ, Mat& Qx = Mat(), Mat& Qy = Mat(), Mat& Qz = Mat())
+ //
+
+ /**
+ * Computes an RQ decomposition of 3x3 matrices.
+ *
+ * @param src 3x3 input matrix.
+ * @param mtxR Output 3x3 upper-triangular matrix.
+ * @param mtxQ Output 3x3 orthogonal matrix.
+ * @param Qx Optional output 3x3 rotation matrix around x-axis.
+ * @param Qy Optional output 3x3 rotation matrix around y-axis.
+ * @param Qz Optional output 3x3 rotation matrix around z-axis.
+ *
+ * The function computes a RQ decomposition using the given rotations. This function is used in
+ * #decomposeProjectionMatrix to decompose the left 3x3 submatrix of a projection matrix into a camera
+ * and a rotation matrix.
+ *
+ * It optionally returns three rotation matrices, one for each axis, and the three Euler angles in
+ * degrees (as the return value) that could be used in OpenGL. Note, there is always more than one
+ * sequence of rotations about the three principal axes that results in the same orientation of an
+ * object, e.g. see CITE: Slabaugh . Returned tree rotation matrices and corresponding three Euler angles
+ * are only one of the possible solutions.
+ * @return automatically generated
+ */
+ public static double[] RQDecomp3x3(Mat src, Mat mtxR, Mat mtxQ, Mat Qx, Mat Qy, Mat Qz) {
+ return RQDecomp3x3_0(src.nativeObj, mtxR.nativeObj, mtxQ.nativeObj, Qx.nativeObj, Qy.nativeObj, Qz.nativeObj);
+ }
+
+ /**
+ * Computes an RQ decomposition of 3x3 matrices.
+ *
+ * @param src 3x3 input matrix.
+ * @param mtxR Output 3x3 upper-triangular matrix.
+ * @param mtxQ Output 3x3 orthogonal matrix.
+ * @param Qx Optional output 3x3 rotation matrix around x-axis.
+ * @param Qy Optional output 3x3 rotation matrix around y-axis.
+ *
+ * The function computes a RQ decomposition using the given rotations. This function is used in
+ * #decomposeProjectionMatrix to decompose the left 3x3 submatrix of a projection matrix into a camera
+ * and a rotation matrix.
+ *
+ * It optionally returns three rotation matrices, one for each axis, and the three Euler angles in
+ * degrees (as the return value) that could be used in OpenGL. Note, there is always more than one
+ * sequence of rotations about the three principal axes that results in the same orientation of an
+ * object, e.g. see CITE: Slabaugh . Returned tree rotation matrices and corresponding three Euler angles
+ * are only one of the possible solutions.
+ * @return automatically generated
+ */
+ public static double[] RQDecomp3x3(Mat src, Mat mtxR, Mat mtxQ, Mat Qx, Mat Qy) {
+ return RQDecomp3x3_1(src.nativeObj, mtxR.nativeObj, mtxQ.nativeObj, Qx.nativeObj, Qy.nativeObj);
+ }
+
+ /**
+ * Computes an RQ decomposition of 3x3 matrices.
+ *
+ * @param src 3x3 input matrix.
+ * @param mtxR Output 3x3 upper-triangular matrix.
+ * @param mtxQ Output 3x3 orthogonal matrix.
+ * @param Qx Optional output 3x3 rotation matrix around x-axis.
+ *
+ * The function computes a RQ decomposition using the given rotations. This function is used in
+ * #decomposeProjectionMatrix to decompose the left 3x3 submatrix of a projection matrix into a camera
+ * and a rotation matrix.
+ *
+ * It optionally returns three rotation matrices, one for each axis, and the three Euler angles in
+ * degrees (as the return value) that could be used in OpenGL. Note, there is always more than one
+ * sequence of rotations about the three principal axes that results in the same orientation of an
+ * object, e.g. see CITE: Slabaugh . Returned tree rotation matrices and corresponding three Euler angles
+ * are only one of the possible solutions.
+ * @return automatically generated
+ */
+ public static double[] RQDecomp3x3(Mat src, Mat mtxR, Mat mtxQ, Mat Qx) {
+ return RQDecomp3x3_2(src.nativeObj, mtxR.nativeObj, mtxQ.nativeObj, Qx.nativeObj);
+ }
+
+ /**
+ * Computes an RQ decomposition of 3x3 matrices.
+ *
+ * @param src 3x3 input matrix.
+ * @param mtxR Output 3x3 upper-triangular matrix.
+ * @param mtxQ Output 3x3 orthogonal matrix.
+ *
+ * The function computes a RQ decomposition using the given rotations. This function is used in
+ * #decomposeProjectionMatrix to decompose the left 3x3 submatrix of a projection matrix into a camera
+ * and a rotation matrix.
+ *
+ * It optionally returns three rotation matrices, one for each axis, and the three Euler angles in
+ * degrees (as the return value) that could be used in OpenGL. Note, there is always more than one
+ * sequence of rotations about the three principal axes that results in the same orientation of an
+ * object, e.g. see CITE: Slabaugh . Returned tree rotation matrices and corresponding three Euler angles
+ * are only one of the possible solutions.
+ * @return automatically generated
+ */
+ public static double[] RQDecomp3x3(Mat src, Mat mtxR, Mat mtxQ) {
+ return RQDecomp3x3_3(src.nativeObj, mtxR.nativeObj, mtxQ.nativeObj);
+ }
+
+
+ //
+ // C++: void cv::decomposeProjectionMatrix(Mat projMatrix, Mat& cameraMatrix, Mat& rotMatrix, Mat& transVect, Mat& rotMatrixX = Mat(), Mat& rotMatrixY = Mat(), Mat& rotMatrixZ = Mat(), Mat& eulerAngles = Mat())
+ //
+
+ /**
+ * Decomposes a projection matrix into a rotation matrix and a camera intrinsic matrix.
+ *
+ * @param projMatrix 3x4 input projection matrix P.
+ * @param cameraMatrix Output 3x3 camera intrinsic matrix \(\cameramatrix{A}\).
+ * @param rotMatrix Output 3x3 external rotation matrix R.
+ * @param transVect Output 4x1 translation vector T.
+ * @param rotMatrixX Optional 3x3 rotation matrix around x-axis.
+ * @param rotMatrixY Optional 3x3 rotation matrix around y-axis.
+ * @param rotMatrixZ Optional 3x3 rotation matrix around z-axis.
+ * @param eulerAngles Optional three-element vector containing three Euler angles of rotation in
+ * degrees.
+ *
+ * The function computes a decomposition of a projection matrix into a calibration and a rotation
+ * matrix and the position of a camera.
+ *
+ * It optionally returns three rotation matrices, one for each axis, and three Euler angles that could
+ * be used in OpenGL. Note, there is always more than one sequence of rotations about the three
+ * principal axes that results in the same orientation of an object, e.g. see CITE: Slabaugh . Returned
+ * tree rotation matrices and corresponding three Euler angles are only one of the possible solutions.
+ *
+ * The function is based on #RQDecomp3x3 .
+ */
+ public static void decomposeProjectionMatrix(Mat projMatrix, Mat cameraMatrix, Mat rotMatrix, Mat transVect, Mat rotMatrixX, Mat rotMatrixY, Mat rotMatrixZ, Mat eulerAngles) {
+ decomposeProjectionMatrix_0(projMatrix.nativeObj, cameraMatrix.nativeObj, rotMatrix.nativeObj, transVect.nativeObj, rotMatrixX.nativeObj, rotMatrixY.nativeObj, rotMatrixZ.nativeObj, eulerAngles.nativeObj);
+ }
+
+ /**
+ * Decomposes a projection matrix into a rotation matrix and a camera intrinsic matrix.
+ *
+ * @param projMatrix 3x4 input projection matrix P.
+ * @param cameraMatrix Output 3x3 camera intrinsic matrix \(\cameramatrix{A}\).
+ * @param rotMatrix Output 3x3 external rotation matrix R.
+ * @param transVect Output 4x1 translation vector T.
+ * @param rotMatrixX Optional 3x3 rotation matrix around x-axis.
+ * @param rotMatrixY Optional 3x3 rotation matrix around y-axis.
+ * @param rotMatrixZ Optional 3x3 rotation matrix around z-axis.
+ * degrees.
+ *
+ * The function computes a decomposition of a projection matrix into a calibration and a rotation
+ * matrix and the position of a camera.
+ *
+ * It optionally returns three rotation matrices, one for each axis, and three Euler angles that could
+ * be used in OpenGL. Note, there is always more than one sequence of rotations about the three
+ * principal axes that results in the same orientation of an object, e.g. see CITE: Slabaugh . Returned
+ * tree rotation matrices and corresponding three Euler angles are only one of the possible solutions.
+ *
+ * The function is based on #RQDecomp3x3 .
+ */
+ public static void decomposeProjectionMatrix(Mat projMatrix, Mat cameraMatrix, Mat rotMatrix, Mat transVect, Mat rotMatrixX, Mat rotMatrixY, Mat rotMatrixZ) {
+ decomposeProjectionMatrix_1(projMatrix.nativeObj, cameraMatrix.nativeObj, rotMatrix.nativeObj, transVect.nativeObj, rotMatrixX.nativeObj, rotMatrixY.nativeObj, rotMatrixZ.nativeObj);
+ }
+
+ /**
+ * Decomposes a projection matrix into a rotation matrix and a camera intrinsic matrix.
+ *
+ * @param projMatrix 3x4 input projection matrix P.
+ * @param cameraMatrix Output 3x3 camera intrinsic matrix \(\cameramatrix{A}\).
+ * @param rotMatrix Output 3x3 external rotation matrix R.
+ * @param transVect Output 4x1 translation vector T.
+ * @param rotMatrixX Optional 3x3 rotation matrix around x-axis.
+ * @param rotMatrixY Optional 3x3 rotation matrix around y-axis.
+ * degrees.
+ *
+ * The function computes a decomposition of a projection matrix into a calibration and a rotation
+ * matrix and the position of a camera.
+ *
+ * It optionally returns three rotation matrices, one for each axis, and three Euler angles that could
+ * be used in OpenGL. Note, there is always more than one sequence of rotations about the three
+ * principal axes that results in the same orientation of an object, e.g. see CITE: Slabaugh . Returned
+ * tree rotation matrices and corresponding three Euler angles are only one of the possible solutions.
+ *
+ * The function is based on #RQDecomp3x3 .
+ */
+ public static void decomposeProjectionMatrix(Mat projMatrix, Mat cameraMatrix, Mat rotMatrix, Mat transVect, Mat rotMatrixX, Mat rotMatrixY) {
+ decomposeProjectionMatrix_2(projMatrix.nativeObj, cameraMatrix.nativeObj, rotMatrix.nativeObj, transVect.nativeObj, rotMatrixX.nativeObj, rotMatrixY.nativeObj);
+ }
+
+ /**
+ * Decomposes a projection matrix into a rotation matrix and a camera intrinsic matrix.
+ *
+ * @param projMatrix 3x4 input projection matrix P.
+ * @param cameraMatrix Output 3x3 camera intrinsic matrix \(\cameramatrix{A}\).
+ * @param rotMatrix Output 3x3 external rotation matrix R.
+ * @param transVect Output 4x1 translation vector T.
+ * @param rotMatrixX Optional 3x3 rotation matrix around x-axis.
+ * degrees.
+ *
+ * The function computes a decomposition of a projection matrix into a calibration and a rotation
+ * matrix and the position of a camera.
+ *
+ * It optionally returns three rotation matrices, one for each axis, and three Euler angles that could
+ * be used in OpenGL. Note, there is always more than one sequence of rotations about the three
+ * principal axes that results in the same orientation of an object, e.g. see CITE: Slabaugh . Returned
+ * tree rotation matrices and corresponding three Euler angles are only one of the possible solutions.
+ *
+ * The function is based on #RQDecomp3x3 .
+ */
+ public static void decomposeProjectionMatrix(Mat projMatrix, Mat cameraMatrix, Mat rotMatrix, Mat transVect, Mat rotMatrixX) {
+ decomposeProjectionMatrix_3(projMatrix.nativeObj, cameraMatrix.nativeObj, rotMatrix.nativeObj, transVect.nativeObj, rotMatrixX.nativeObj);
+ }
+
+ /**
+ * Decomposes a projection matrix into a rotation matrix and a camera intrinsic matrix.
+ *
+ * @param projMatrix 3x4 input projection matrix P.
+ * @param cameraMatrix Output 3x3 camera intrinsic matrix \(\cameramatrix{A}\).
+ * @param rotMatrix Output 3x3 external rotation matrix R.
+ * @param transVect Output 4x1 translation vector T.
+ * degrees.
+ *
+ * The function computes a decomposition of a projection matrix into a calibration and a rotation
+ * matrix and the position of a camera.
+ *
+ * It optionally returns three rotation matrices, one for each axis, and three Euler angles that could
+ * be used in OpenGL. Note, there is always more than one sequence of rotations about the three
+ * principal axes that results in the same orientation of an object, e.g. see CITE: Slabaugh . Returned
+ * tree rotation matrices and corresponding three Euler angles are only one of the possible solutions.
+ *
+ * The function is based on #RQDecomp3x3 .
+ */
+ public static void decomposeProjectionMatrix(Mat projMatrix, Mat cameraMatrix, Mat rotMatrix, Mat transVect) {
+ decomposeProjectionMatrix_4(projMatrix.nativeObj, cameraMatrix.nativeObj, rotMatrix.nativeObj, transVect.nativeObj);
+ }
+
+
+ //
+ // C++: void cv::matMulDeriv(Mat A, Mat B, Mat& dABdA, Mat& dABdB)
+ //
+
+ /**
+ * Computes partial derivatives of the matrix product for each multiplied matrix.
+ *
+ * @param A First multiplied matrix.
+ * @param B Second multiplied matrix.
+ * @param dABdA First output derivative matrix d(A\*B)/dA of size
+ * \(\texttt{A.rows*B.cols} \times {A.rows*A.cols}\) .
+ * @param dABdB Second output derivative matrix d(A\*B)/dB of size
+ * \(\texttt{A.rows*B.cols} \times {B.rows*B.cols}\) .
+ *
+ * The function computes partial derivatives of the elements of the matrix product \(A*B\) with regard to
+ * the elements of each of the two input matrices. The function is used to compute the Jacobian
+ * matrices in #stereoCalibrate but can also be used in any other similar optimization function.
+ */
+ public static void matMulDeriv(Mat A, Mat B, Mat dABdA, Mat dABdB) {
+ matMulDeriv_0(A.nativeObj, B.nativeObj, dABdA.nativeObj, dABdB.nativeObj);
+ }
+
+
+ //
+ // C++: void cv::composeRT(Mat rvec1, Mat tvec1, Mat rvec2, Mat tvec2, Mat& rvec3, Mat& tvec3, Mat& dr3dr1 = Mat(), Mat& dr3dt1 = Mat(), Mat& dr3dr2 = Mat(), Mat& dr3dt2 = Mat(), Mat& dt3dr1 = Mat(), Mat& dt3dt1 = Mat(), Mat& dt3dr2 = Mat(), Mat& dt3dt2 = Mat())
+ //
+
+ /**
+ * Combines two rotation-and-shift transformations.
+ *
+ * @param rvec1 First rotation vector.
+ * @param tvec1 First translation vector.
+ * @param rvec2 Second rotation vector.
+ * @param tvec2 Second translation vector.
+ * @param rvec3 Output rotation vector of the superposition.
+ * @param tvec3 Output translation vector of the superposition.
+ * @param dr3dr1 Optional output derivative of rvec3 with regard to rvec1
+ * @param dr3dt1 Optional output derivative of rvec3 with regard to tvec1
+ * @param dr3dr2 Optional output derivative of rvec3 with regard to rvec2
+ * @param dr3dt2 Optional output derivative of rvec3 with regard to tvec2
+ * @param dt3dr1 Optional output derivative of tvec3 with regard to rvec1
+ * @param dt3dt1 Optional output derivative of tvec3 with regard to tvec1
+ * @param dt3dr2 Optional output derivative of tvec3 with regard to rvec2
+ * @param dt3dt2 Optional output derivative of tvec3 with regard to tvec2
+ *
+ * The functions compute:
+ *
+ * \(\begin{array}{l} \texttt{rvec3} = \mathrm{rodrigues} ^{-1} \left ( \mathrm{rodrigues} ( \texttt{rvec2} ) \cdot \mathrm{rodrigues} ( \texttt{rvec1} ) \right ) \\ \texttt{tvec3} = \mathrm{rodrigues} ( \texttt{rvec2} ) \cdot \texttt{tvec1} + \texttt{tvec2} \end{array} ,\)
+ *
+ * where \(\mathrm{rodrigues}\) denotes a rotation vector to a rotation matrix transformation, and
+ * \(\mathrm{rodrigues}^{-1}\) denotes the inverse transformation. See #Rodrigues for details.
+ *
+ * Also, the functions can compute the derivatives of the output vectors with regards to the input
+ * vectors (see #matMulDeriv ). The functions are used inside #stereoCalibrate but can also be used in
+ * your own code where Levenberg-Marquardt or another gradient-based solver is used to optimize a
+ * function that contains a matrix multiplication.
+ */
+ public static void composeRT(Mat rvec1, Mat tvec1, Mat rvec2, Mat tvec2, Mat rvec3, Mat tvec3, Mat dr3dr1, Mat dr3dt1, Mat dr3dr2, Mat dr3dt2, Mat dt3dr1, Mat dt3dt1, Mat dt3dr2, Mat dt3dt2) {
+ composeRT_0(rvec1.nativeObj, tvec1.nativeObj, rvec2.nativeObj, tvec2.nativeObj, rvec3.nativeObj, tvec3.nativeObj, dr3dr1.nativeObj, dr3dt1.nativeObj, dr3dr2.nativeObj, dr3dt2.nativeObj, dt3dr1.nativeObj, dt3dt1.nativeObj, dt3dr2.nativeObj, dt3dt2.nativeObj);
+ }
+
+ /**
+ * Combines two rotation-and-shift transformations.
+ *
+ * @param rvec1 First rotation vector.
+ * @param tvec1 First translation vector.
+ * @param rvec2 Second rotation vector.
+ * @param tvec2 Second translation vector.
+ * @param rvec3 Output rotation vector of the superposition.
+ * @param tvec3 Output translation vector of the superposition.
+ * @param dr3dr1 Optional output derivative of rvec3 with regard to rvec1
+ * @param dr3dt1 Optional output derivative of rvec3 with regard to tvec1
+ * @param dr3dr2 Optional output derivative of rvec3 with regard to rvec2
+ * @param dr3dt2 Optional output derivative of rvec3 with regard to tvec2
+ * @param dt3dr1 Optional output derivative of tvec3 with regard to rvec1
+ * @param dt3dt1 Optional output derivative of tvec3 with regard to tvec1
+ * @param dt3dr2 Optional output derivative of tvec3 with regard to rvec2
+ *
+ * The functions compute:
+ *
+ * \(\begin{array}{l} \texttt{rvec3} = \mathrm{rodrigues} ^{-1} \left ( \mathrm{rodrigues} ( \texttt{rvec2} ) \cdot \mathrm{rodrigues} ( \texttt{rvec1} ) \right ) \\ \texttt{tvec3} = \mathrm{rodrigues} ( \texttt{rvec2} ) \cdot \texttt{tvec1} + \texttt{tvec2} \end{array} ,\)
+ *
+ * where \(\mathrm{rodrigues}\) denotes a rotation vector to a rotation matrix transformation, and
+ * \(\mathrm{rodrigues}^{-1}\) denotes the inverse transformation. See #Rodrigues for details.
+ *
+ * Also, the functions can compute the derivatives of the output vectors with regards to the input
+ * vectors (see #matMulDeriv ). The functions are used inside #stereoCalibrate but can also be used in
+ * your own code where Levenberg-Marquardt or another gradient-based solver is used to optimize a
+ * function that contains a matrix multiplication.
+ */
+ public static void composeRT(Mat rvec1, Mat tvec1, Mat rvec2, Mat tvec2, Mat rvec3, Mat tvec3, Mat dr3dr1, Mat dr3dt1, Mat dr3dr2, Mat dr3dt2, Mat dt3dr1, Mat dt3dt1, Mat dt3dr2) {
+ composeRT_1(rvec1.nativeObj, tvec1.nativeObj, rvec2.nativeObj, tvec2.nativeObj, rvec3.nativeObj, tvec3.nativeObj, dr3dr1.nativeObj, dr3dt1.nativeObj, dr3dr2.nativeObj, dr3dt2.nativeObj, dt3dr1.nativeObj, dt3dt1.nativeObj, dt3dr2.nativeObj);
+ }
+
+ /**
+ * Combines two rotation-and-shift transformations.
+ *
+ * @param rvec1 First rotation vector.
+ * @param tvec1 First translation vector.
+ * @param rvec2 Second rotation vector.
+ * @param tvec2 Second translation vector.
+ * @param rvec3 Output rotation vector of the superposition.
+ * @param tvec3 Output translation vector of the superposition.
+ * @param dr3dr1 Optional output derivative of rvec3 with regard to rvec1
+ * @param dr3dt1 Optional output derivative of rvec3 with regard to tvec1
+ * @param dr3dr2 Optional output derivative of rvec3 with regard to rvec2
+ * @param dr3dt2 Optional output derivative of rvec3 with regard to tvec2
+ * @param dt3dr1 Optional output derivative of tvec3 with regard to rvec1
+ * @param dt3dt1 Optional output derivative of tvec3 with regard to tvec1
+ *
+ * The functions compute:
+ *
+ * \(\begin{array}{l} \texttt{rvec3} = \mathrm{rodrigues} ^{-1} \left ( \mathrm{rodrigues} ( \texttt{rvec2} ) \cdot \mathrm{rodrigues} ( \texttt{rvec1} ) \right ) \\ \texttt{tvec3} = \mathrm{rodrigues} ( \texttt{rvec2} ) \cdot \texttt{tvec1} + \texttt{tvec2} \end{array} ,\)
+ *
+ * where \(\mathrm{rodrigues}\) denotes a rotation vector to a rotation matrix transformation, and
+ * \(\mathrm{rodrigues}^{-1}\) denotes the inverse transformation. See #Rodrigues for details.
+ *
+ * Also, the functions can compute the derivatives of the output vectors with regards to the input
+ * vectors (see #matMulDeriv ). The functions are used inside #stereoCalibrate but can also be used in
+ * your own code where Levenberg-Marquardt or another gradient-based solver is used to optimize a
+ * function that contains a matrix multiplication.
+ */
+ public static void composeRT(Mat rvec1, Mat tvec1, Mat rvec2, Mat tvec2, Mat rvec3, Mat tvec3, Mat dr3dr1, Mat dr3dt1, Mat dr3dr2, Mat dr3dt2, Mat dt3dr1, Mat dt3dt1) {
+ composeRT_2(rvec1.nativeObj, tvec1.nativeObj, rvec2.nativeObj, tvec2.nativeObj, rvec3.nativeObj, tvec3.nativeObj, dr3dr1.nativeObj, dr3dt1.nativeObj, dr3dr2.nativeObj, dr3dt2.nativeObj, dt3dr1.nativeObj, dt3dt1.nativeObj);
+ }
+
+ /**
+ * Combines two rotation-and-shift transformations.
+ *
+ * @param rvec1 First rotation vector.
+ * @param tvec1 First translation vector.
+ * @param rvec2 Second rotation vector.
+ * @param tvec2 Second translation vector.
+ * @param rvec3 Output rotation vector of the superposition.
+ * @param tvec3 Output translation vector of the superposition.
+ * @param dr3dr1 Optional output derivative of rvec3 with regard to rvec1
+ * @param dr3dt1 Optional output derivative of rvec3 with regard to tvec1
+ * @param dr3dr2 Optional output derivative of rvec3 with regard to rvec2
+ * @param dr3dt2 Optional output derivative of rvec3 with regard to tvec2
+ * @param dt3dr1 Optional output derivative of tvec3 with regard to rvec1
+ *
+ * The functions compute:
+ *
+ * \(\begin{array}{l} \texttt{rvec3} = \mathrm{rodrigues} ^{-1} \left ( \mathrm{rodrigues} ( \texttt{rvec2} ) \cdot \mathrm{rodrigues} ( \texttt{rvec1} ) \right ) \\ \texttt{tvec3} = \mathrm{rodrigues} ( \texttt{rvec2} ) \cdot \texttt{tvec1} + \texttt{tvec2} \end{array} ,\)
+ *
+ * where \(\mathrm{rodrigues}\) denotes a rotation vector to a rotation matrix transformation, and
+ * \(\mathrm{rodrigues}^{-1}\) denotes the inverse transformation. See #Rodrigues for details.
+ *
+ * Also, the functions can compute the derivatives of the output vectors with regards to the input
+ * vectors (see #matMulDeriv ). The functions are used inside #stereoCalibrate but can also be used in
+ * your own code where Levenberg-Marquardt or another gradient-based solver is used to optimize a
+ * function that contains a matrix multiplication.
+ */
+ public static void composeRT(Mat rvec1, Mat tvec1, Mat rvec2, Mat tvec2, Mat rvec3, Mat tvec3, Mat dr3dr1, Mat dr3dt1, Mat dr3dr2, Mat dr3dt2, Mat dt3dr1) {
+ composeRT_3(rvec1.nativeObj, tvec1.nativeObj, rvec2.nativeObj, tvec2.nativeObj, rvec3.nativeObj, tvec3.nativeObj, dr3dr1.nativeObj, dr3dt1.nativeObj, dr3dr2.nativeObj, dr3dt2.nativeObj, dt3dr1.nativeObj);
+ }
+
+ /**
+ * Combines two rotation-and-shift transformations.
+ *
+ * @param rvec1 First rotation vector.
+ * @param tvec1 First translation vector.
+ * @param rvec2 Second rotation vector.
+ * @param tvec2 Second translation vector.
+ * @param rvec3 Output rotation vector of the superposition.
+ * @param tvec3 Output translation vector of the superposition.
+ * @param dr3dr1 Optional output derivative of rvec3 with regard to rvec1
+ * @param dr3dt1 Optional output derivative of rvec3 with regard to tvec1
+ * @param dr3dr2 Optional output derivative of rvec3 with regard to rvec2
+ * @param dr3dt2 Optional output derivative of rvec3 with regard to tvec2
+ *
+ * The functions compute:
+ *
+ * \(\begin{array}{l} \texttt{rvec3} = \mathrm{rodrigues} ^{-1} \left ( \mathrm{rodrigues} ( \texttt{rvec2} ) \cdot \mathrm{rodrigues} ( \texttt{rvec1} ) \right ) \\ \texttt{tvec3} = \mathrm{rodrigues} ( \texttt{rvec2} ) \cdot \texttt{tvec1} + \texttt{tvec2} \end{array} ,\)
+ *
+ * where \(\mathrm{rodrigues}\) denotes a rotation vector to a rotation matrix transformation, and
+ * \(\mathrm{rodrigues}^{-1}\) denotes the inverse transformation. See #Rodrigues for details.
+ *
+ * Also, the functions can compute the derivatives of the output vectors with regards to the input
+ * vectors (see #matMulDeriv ). The functions are used inside #stereoCalibrate but can also be used in
+ * your own code where Levenberg-Marquardt or another gradient-based solver is used to optimize a
+ * function that contains a matrix multiplication.
+ */
+ public static void composeRT(Mat rvec1, Mat tvec1, Mat rvec2, Mat tvec2, Mat rvec3, Mat tvec3, Mat dr3dr1, Mat dr3dt1, Mat dr3dr2, Mat dr3dt2) {
+ composeRT_4(rvec1.nativeObj, tvec1.nativeObj, rvec2.nativeObj, tvec2.nativeObj, rvec3.nativeObj, tvec3.nativeObj, dr3dr1.nativeObj, dr3dt1.nativeObj, dr3dr2.nativeObj, dr3dt2.nativeObj);
+ }
+
+ /**
+ * Combines two rotation-and-shift transformations.
+ *
+ * @param rvec1 First rotation vector.
+ * @param tvec1 First translation vector.
+ * @param rvec2 Second rotation vector.
+ * @param tvec2 Second translation vector.
+ * @param rvec3 Output rotation vector of the superposition.
+ * @param tvec3 Output translation vector of the superposition.
+ * @param dr3dr1 Optional output derivative of rvec3 with regard to rvec1
+ * @param dr3dt1 Optional output derivative of rvec3 with regard to tvec1
+ * @param dr3dr2 Optional output derivative of rvec3 with regard to rvec2
+ *
+ * The functions compute:
+ *
+ * \(\begin{array}{l} \texttt{rvec3} = \mathrm{rodrigues} ^{-1} \left ( \mathrm{rodrigues} ( \texttt{rvec2} ) \cdot \mathrm{rodrigues} ( \texttt{rvec1} ) \right ) \\ \texttt{tvec3} = \mathrm{rodrigues} ( \texttt{rvec2} ) \cdot \texttt{tvec1} + \texttt{tvec2} \end{array} ,\)
+ *
+ * where \(\mathrm{rodrigues}\) denotes a rotation vector to a rotation matrix transformation, and
+ * \(\mathrm{rodrigues}^{-1}\) denotes the inverse transformation. See #Rodrigues for details.
+ *
+ * Also, the functions can compute the derivatives of the output vectors with regards to the input
+ * vectors (see #matMulDeriv ). The functions are used inside #stereoCalibrate but can also be used in
+ * your own code where Levenberg-Marquardt or another gradient-based solver is used to optimize a
+ * function that contains a matrix multiplication.
+ */
+ public static void composeRT(Mat rvec1, Mat tvec1, Mat rvec2, Mat tvec2, Mat rvec3, Mat tvec3, Mat dr3dr1, Mat dr3dt1, Mat dr3dr2) {
+ composeRT_5(rvec1.nativeObj, tvec1.nativeObj, rvec2.nativeObj, tvec2.nativeObj, rvec3.nativeObj, tvec3.nativeObj, dr3dr1.nativeObj, dr3dt1.nativeObj, dr3dr2.nativeObj);
+ }
+
+ /**
+ * Combines two rotation-and-shift transformations.
+ *
+ * @param rvec1 First rotation vector.
+ * @param tvec1 First translation vector.
+ * @param rvec2 Second rotation vector.
+ * @param tvec2 Second translation vector.
+ * @param rvec3 Output rotation vector of the superposition.
+ * @param tvec3 Output translation vector of the superposition.
+ * @param dr3dr1 Optional output derivative of rvec3 with regard to rvec1
+ * @param dr3dt1 Optional output derivative of rvec3 with regard to tvec1
+ *
+ * The functions compute:
+ *
+ * \(\begin{array}{l} \texttt{rvec3} = \mathrm{rodrigues} ^{-1} \left ( \mathrm{rodrigues} ( \texttt{rvec2} ) \cdot \mathrm{rodrigues} ( \texttt{rvec1} ) \right ) \\ \texttt{tvec3} = \mathrm{rodrigues} ( \texttt{rvec2} ) \cdot \texttt{tvec1} + \texttt{tvec2} \end{array} ,\)
+ *
+ * where \(\mathrm{rodrigues}\) denotes a rotation vector to a rotation matrix transformation, and
+ * \(\mathrm{rodrigues}^{-1}\) denotes the inverse transformation. See #Rodrigues for details.
+ *
+ * Also, the functions can compute the derivatives of the output vectors with regards to the input
+ * vectors (see #matMulDeriv ). The functions are used inside #stereoCalibrate but can also be used in
+ * your own code where Levenberg-Marquardt or another gradient-based solver is used to optimize a
+ * function that contains a matrix multiplication.
+ */
+ public static void composeRT(Mat rvec1, Mat tvec1, Mat rvec2, Mat tvec2, Mat rvec3, Mat tvec3, Mat dr3dr1, Mat dr3dt1) {
+ composeRT_6(rvec1.nativeObj, tvec1.nativeObj, rvec2.nativeObj, tvec2.nativeObj, rvec3.nativeObj, tvec3.nativeObj, dr3dr1.nativeObj, dr3dt1.nativeObj);
+ }
+
+ /**
+ * Combines two rotation-and-shift transformations.
+ *
+ * @param rvec1 First rotation vector.
+ * @param tvec1 First translation vector.
+ * @param rvec2 Second rotation vector.
+ * @param tvec2 Second translation vector.
+ * @param rvec3 Output rotation vector of the superposition.
+ * @param tvec3 Output translation vector of the superposition.
+ * @param dr3dr1 Optional output derivative of rvec3 with regard to rvec1
+ *
+ * The functions compute:
+ *
+ * \(\begin{array}{l} \texttt{rvec3} = \mathrm{rodrigues} ^{-1} \left ( \mathrm{rodrigues} ( \texttt{rvec2} ) \cdot \mathrm{rodrigues} ( \texttt{rvec1} ) \right ) \\ \texttt{tvec3} = \mathrm{rodrigues} ( \texttt{rvec2} ) \cdot \texttt{tvec1} + \texttt{tvec2} \end{array} ,\)
+ *
+ * where \(\mathrm{rodrigues}\) denotes a rotation vector to a rotation matrix transformation, and
+ * \(\mathrm{rodrigues}^{-1}\) denotes the inverse transformation. See #Rodrigues for details.
+ *
+ * Also, the functions can compute the derivatives of the output vectors with regards to the input
+ * vectors (see #matMulDeriv ). The functions are used inside #stereoCalibrate but can also be used in
+ * your own code where Levenberg-Marquardt or another gradient-based solver is used to optimize a
+ * function that contains a matrix multiplication.
+ */
+ public static void composeRT(Mat rvec1, Mat tvec1, Mat rvec2, Mat tvec2, Mat rvec3, Mat tvec3, Mat dr3dr1) {
+ composeRT_7(rvec1.nativeObj, tvec1.nativeObj, rvec2.nativeObj, tvec2.nativeObj, rvec3.nativeObj, tvec3.nativeObj, dr3dr1.nativeObj);
+ }
+
+ /**
+ * Combines two rotation-and-shift transformations.
+ *
+ * @param rvec1 First rotation vector.
+ * @param tvec1 First translation vector.
+ * @param rvec2 Second rotation vector.
+ * @param tvec2 Second translation vector.
+ * @param rvec3 Output rotation vector of the superposition.
+ * @param tvec3 Output translation vector of the superposition.
+ *
+ * The functions compute:
+ *
+ * \(\begin{array}{l} \texttt{rvec3} = \mathrm{rodrigues} ^{-1} \left ( \mathrm{rodrigues} ( \texttt{rvec2} ) \cdot \mathrm{rodrigues} ( \texttt{rvec1} ) \right ) \\ \texttt{tvec3} = \mathrm{rodrigues} ( \texttt{rvec2} ) \cdot \texttt{tvec1} + \texttt{tvec2} \end{array} ,\)
+ *
+ * where \(\mathrm{rodrigues}\) denotes a rotation vector to a rotation matrix transformation, and
+ * \(\mathrm{rodrigues}^{-1}\) denotes the inverse transformation. See #Rodrigues for details.
+ *
+ * Also, the functions can compute the derivatives of the output vectors with regards to the input
+ * vectors (see #matMulDeriv ). The functions are used inside #stereoCalibrate but can also be used in
+ * your own code where Levenberg-Marquardt or another gradient-based solver is used to optimize a
+ * function that contains a matrix multiplication.
+ */
+ public static void composeRT(Mat rvec1, Mat tvec1, Mat rvec2, Mat tvec2, Mat rvec3, Mat tvec3) {
+ composeRT_8(rvec1.nativeObj, tvec1.nativeObj, rvec2.nativeObj, tvec2.nativeObj, rvec3.nativeObj, tvec3.nativeObj);
+ }
+
+
+ //
+ // C++: void cv::projectPoints(vector_Point3f objectPoints, Mat rvec, Mat tvec, Mat cameraMatrix, vector_double distCoeffs, vector_Point2f& imagePoints, Mat& jacobian = Mat(), double aspectRatio = 0)
+ //
+
+ /**
+ * Projects 3D points to an image plane.
+ *
+ * @param objectPoints Array of object points expressed wrt. the world coordinate frame. A 3xN/Nx3
+ * 1-channel or 1xN/Nx1 3-channel (or vector<Point3f> ), where N is the number of points in the view.
+ * @param rvec The rotation vector (REF: Rodrigues) that, together with tvec, performs a change of
+ * basis from world to camera coordinate system, see REF: calibrateCamera for details.
+ * @param tvec The translation vector, see parameter description above.
+ * @param cameraMatrix Camera intrinsic matrix \(\cameramatrix{A}\) .
+ * @param distCoeffs Input vector of distortion coefficients
+ * \(\distcoeffs\) . If the vector is empty, the zero distortion coefficients are assumed.
+ * @param imagePoints Output array of image points, 1xN/Nx1 2-channel, or
+ * vector<Point2f> .
+ * @param jacobian Optional output 2Nx(10+<numDistCoeffs>) jacobian matrix of derivatives of image
+ * points with respect to components of the rotation vector, translation vector, focal lengths,
+ * coordinates of the principal point and the distortion coefficients. In the old interface different
+ * components of the jacobian are returned via different output parameters.
+ * @param aspectRatio Optional "fixed aspect ratio" parameter. If the parameter is not 0, the
+ * function assumes that the aspect ratio (\(f_x / f_y\)) is fixed and correspondingly adjusts the
+ * jacobian matrix.
+ *
+ * The function computes the 2D projections of 3D points to the image plane, given intrinsic and
+ * extrinsic camera parameters. Optionally, the function computes Jacobians -matrices of partial
+ * derivatives of image points coordinates (as functions of all the input parameters) with respect to
+ * the particular parameters, intrinsic and/or extrinsic. The Jacobians are used during the global
+ * optimization in REF: calibrateCamera, REF: solvePnP, and REF: stereoCalibrate. The function itself
+ * can also be used to compute a re-projection error, given the current intrinsic and extrinsic
+ * parameters.
+ *
+ * Note: By setting rvec = tvec = \([0, 0, 0]\), or by setting cameraMatrix to a 3x3 identity matrix,
+ * or by passing zero distortion coefficients, one can get various useful partial cases of the
+ * function. This means, one can compute the distorted coordinates for a sparse set of points or apply
+ * a perspective transformation (and also compute the derivatives) in the ideal zero-distortion setup.
+ */
+ public static void projectPoints(MatOfPoint3f objectPoints, Mat rvec, Mat tvec, Mat cameraMatrix, MatOfDouble distCoeffs, MatOfPoint2f imagePoints, Mat jacobian, double aspectRatio) {
+ Mat objectPoints_mat = objectPoints;
+ Mat distCoeffs_mat = distCoeffs;
+ Mat imagePoints_mat = imagePoints;
+ projectPoints_0(objectPoints_mat.nativeObj, rvec.nativeObj, tvec.nativeObj, cameraMatrix.nativeObj, distCoeffs_mat.nativeObj, imagePoints_mat.nativeObj, jacobian.nativeObj, aspectRatio);
+ }
+
+ /**
+ * Projects 3D points to an image plane.
+ *
+ * @param objectPoints Array of object points expressed wrt. the world coordinate frame. A 3xN/Nx3
+ * 1-channel or 1xN/Nx1 3-channel (or vector<Point3f> ), where N is the number of points in the view.
+ * @param rvec The rotation vector (REF: Rodrigues) that, together with tvec, performs a change of
+ * basis from world to camera coordinate system, see REF: calibrateCamera for details.
+ * @param tvec The translation vector, see parameter description above.
+ * @param cameraMatrix Camera intrinsic matrix \(\cameramatrix{A}\) .
+ * @param distCoeffs Input vector of distortion coefficients
+ * \(\distcoeffs\) . If the vector is empty, the zero distortion coefficients are assumed.
+ * @param imagePoints Output array of image points, 1xN/Nx1 2-channel, or
+ * vector<Point2f> .
+ * @param jacobian Optional output 2Nx(10+<numDistCoeffs>) jacobian matrix of derivatives of image
+ * points with respect to components of the rotation vector, translation vector, focal lengths,
+ * coordinates of the principal point and the distortion coefficients. In the old interface different
+ * components of the jacobian are returned via different output parameters.
+ * function assumes that the aspect ratio (\(f_x / f_y\)) is fixed and correspondingly adjusts the
+ * jacobian matrix.
+ *
+ * The function computes the 2D projections of 3D points to the image plane, given intrinsic and
+ * extrinsic camera parameters. Optionally, the function computes Jacobians -matrices of partial
+ * derivatives of image points coordinates (as functions of all the input parameters) with respect to
+ * the particular parameters, intrinsic and/or extrinsic. The Jacobians are used during the global
+ * optimization in REF: calibrateCamera, REF: solvePnP, and REF: stereoCalibrate. The function itself
+ * can also be used to compute a re-projection error, given the current intrinsic and extrinsic
+ * parameters.
+ *
+ * Note: By setting rvec = tvec = \([0, 0, 0]\), or by setting cameraMatrix to a 3x3 identity matrix,
+ * or by passing zero distortion coefficients, one can get various useful partial cases of the
+ * function. This means, one can compute the distorted coordinates for a sparse set of points or apply
+ * a perspective transformation (and also compute the derivatives) in the ideal zero-distortion setup.
+ */
+ public static void projectPoints(MatOfPoint3f objectPoints, Mat rvec, Mat tvec, Mat cameraMatrix, MatOfDouble distCoeffs, MatOfPoint2f imagePoints, Mat jacobian) {
+ Mat objectPoints_mat = objectPoints;
+ Mat distCoeffs_mat = distCoeffs;
+ Mat imagePoints_mat = imagePoints;
+ projectPoints_1(objectPoints_mat.nativeObj, rvec.nativeObj, tvec.nativeObj, cameraMatrix.nativeObj, distCoeffs_mat.nativeObj, imagePoints_mat.nativeObj, jacobian.nativeObj);
+ }
+
+ /**
+ * Projects 3D points to an image plane.
+ *
+ * @param objectPoints Array of object points expressed wrt. the world coordinate frame. A 3xN/Nx3
+ * 1-channel or 1xN/Nx1 3-channel (or vector<Point3f> ), where N is the number of points in the view.
+ * @param rvec The rotation vector (REF: Rodrigues) that, together with tvec, performs a change of
+ * basis from world to camera coordinate system, see REF: calibrateCamera for details.
+ * @param tvec The translation vector, see parameter description above.
+ * @param cameraMatrix Camera intrinsic matrix \(\cameramatrix{A}\) .
+ * @param distCoeffs Input vector of distortion coefficients
+ * \(\distcoeffs\) . If the vector is empty, the zero distortion coefficients are assumed.
+ * @param imagePoints Output array of image points, 1xN/Nx1 2-channel, or
+ * vector<Point2f> .
+ * points with respect to components of the rotation vector, translation vector, focal lengths,
+ * coordinates of the principal point and the distortion coefficients. In the old interface different
+ * components of the jacobian are returned via different output parameters.
+ * function assumes that the aspect ratio (\(f_x / f_y\)) is fixed and correspondingly adjusts the
+ * jacobian matrix.
+ *
+ * The function computes the 2D projections of 3D points to the image plane, given intrinsic and
+ * extrinsic camera parameters. Optionally, the function computes Jacobians -matrices of partial
+ * derivatives of image points coordinates (as functions of all the input parameters) with respect to
+ * the particular parameters, intrinsic and/or extrinsic. The Jacobians are used during the global
+ * optimization in REF: calibrateCamera, REF: solvePnP, and REF: stereoCalibrate. The function itself
+ * can also be used to compute a re-projection error, given the current intrinsic and extrinsic
+ * parameters.
+ *
+ * Note: By setting rvec = tvec = \([0, 0, 0]\), or by setting cameraMatrix to a 3x3 identity matrix,
+ * or by passing zero distortion coefficients, one can get various useful partial cases of the
+ * function. This means, one can compute the distorted coordinates for a sparse set of points or apply
+ * a perspective transformation (and also compute the derivatives) in the ideal zero-distortion setup.
+ */
+ public static void projectPoints(MatOfPoint3f objectPoints, Mat rvec, Mat tvec, Mat cameraMatrix, MatOfDouble distCoeffs, MatOfPoint2f imagePoints) {
+ Mat objectPoints_mat = objectPoints;
+ Mat distCoeffs_mat = distCoeffs;
+ Mat imagePoints_mat = imagePoints;
+ projectPoints_2(objectPoints_mat.nativeObj, rvec.nativeObj, tvec.nativeObj, cameraMatrix.nativeObj, distCoeffs_mat.nativeObj, imagePoints_mat.nativeObj);
+ }
+
+
+ //
+ // C++: bool cv::solvePnP(vector_Point3f objectPoints, vector_Point2f imagePoints, Mat cameraMatrix, vector_double distCoeffs, Mat& rvec, Mat& tvec, bool useExtrinsicGuess = false, int flags = SOLVEPNP_ITERATIVE)
+ //
+
+ /**
+ * Finds an object pose from 3D-2D point correspondences.
+ *
+ * SEE: REF: calib3d_solvePnP
+ *
+ * This function returns the rotation and the translation vectors that transform a 3D point expressed in the object
+ * coordinate frame to the camera coordinate frame, using different methods:
+ *
+ *
+ * P3P methods (REF: SOLVEPNP_P3P, REF: SOLVEPNP_AP3P): need 4 input points to return a unique solution.
+ *
+ *
+ * REF: SOLVEPNP_IPPE Input points must be >= 4 and object points must be coplanar.
+ *
+ *
+ * REF: SOLVEPNP_IPPE_SQUARE Special case suitable for marker pose estimation.
+ * Number of input points must be 4. Object points must be defined in the following order:
+ *
+ * for all the other flags, number of input points must be >= 4 and object points can be in any configuration.
+ *
+ *
+ *
+ * @param objectPoints Array of object points in the object coordinate space, Nx3 1-channel or
+ * 1xN/Nx1 3-channel, where N is the number of points. vector<Point3d> can be also passed here.
+ * @param imagePoints Array of corresponding image points, Nx2 1-channel or 1xN/Nx1 2-channel,
+ * where N is the number of points. vector<Point2d> can be also passed here.
+ * @param cameraMatrix Input camera intrinsic matrix \(\cameramatrix{A}\) .
+ * @param distCoeffs Input vector of distortion coefficients
+ * \(\distcoeffs\). If the vector is NULL/empty, the zero distortion coefficients are
+ * assumed.
+ * @param rvec Output rotation vector (see REF: Rodrigues ) that, together with tvec, brings points from
+ * the model coordinate system to the camera coordinate system.
+ * @param tvec Output translation vector.
+ * @param useExtrinsicGuess Parameter used for #SOLVEPNP_ITERATIVE. If true (1), the function uses
+ * the provided rvec and tvec values as initial approximations of the rotation and translation
+ * vectors, respectively, and further optimizes them.
+ * @param flags Method for solving a PnP problem: see REF: calib3d_solvePnP_flags
+ *
+ * More information about Perspective-n-Points is described in REF: calib3d_solvePnP
+ *
+ * Note:
+ *
+ *
+ * An example of how to use solvePnP for planar augmented reality can be found at
+ * opencv_source_code/samples/python/plane_ar.py
+ *
+ *
+ * If you are using Python:
+ *
+ *
+ * Numpy array slices won't work as input because solvePnP requires contiguous
+ * arrays (enforced by the assertion using cv::Mat::checkVector() around line 55 of
+ * modules/calib3d/src/solvepnp.cpp version 2.4.9)
+ *
+ *
+ * The P3P algorithm requires image points to be in an array of shape (N,1,2) due
+ * to its calling of #undistortPoints (around line 75 of modules/calib3d/src/solvepnp.cpp version 2.4.9)
+ * which requires 2-channel information.
+ *
+ *
+ * Thus, given some data D = np.array(...) where D.shape = (N,M), in order to use a subset of
+ * it as, e.g., imagePoints, one must effectively copy it into a new array: imagePoints =
+ * np.ascontiguousarray(D[:,:2]).reshape((N,1,2))
+ *
+ *
+ *
+ * The methods REF: SOLVEPNP_DLS and REF: SOLVEPNP_UPNP cannot be used as the current implementations are
+ * unstable and sometimes give completely wrong results. If you pass one of these two
+ * flags, REF: SOLVEPNP_EPNP method will be used instead.
+ *
+ *
+ * The minimum number of points is 4 in the general case. In the case of REF: SOLVEPNP_P3P and REF: SOLVEPNP_AP3P
+ * methods, it is required to use exactly 4 points (the first 3 points are used to estimate all the solutions
+ * of the P3P problem, the last one is used to retain the best solution that minimizes the reprojection error).
+ *
+ *
+ * With REF: SOLVEPNP_ITERATIVE method and {@code useExtrinsicGuess=true}, the minimum number of points is 3 (3 points
+ * are sufficient to compute a pose but there are up to 4 solutions). The initial solution should be close to the
+ * global solution to converge.
+ *
+ *
+ * With REF: SOLVEPNP_IPPE input points must be >= 4 and object points must be coplanar.
+ *
+ *
+ * With REF: SOLVEPNP_IPPE_SQUARE this is a special case suitable for marker pose estimation.
+ * Number of input points must be 4. Object points must be defined in the following order:
+ *
+ * With REF: SOLVEPNP_SQPNP input points must be >= 3
+ *
+ *
+ *
+ *
+ * @return automatically generated
+ */
+ public static boolean solvePnP(MatOfPoint3f objectPoints, MatOfPoint2f imagePoints, Mat cameraMatrix, MatOfDouble distCoeffs, Mat rvec, Mat tvec, boolean useExtrinsicGuess, int flags) {
+ Mat objectPoints_mat = objectPoints;
+ Mat imagePoints_mat = imagePoints;
+ Mat distCoeffs_mat = distCoeffs;
+ return solvePnP_0(objectPoints_mat.nativeObj, imagePoints_mat.nativeObj, cameraMatrix.nativeObj, distCoeffs_mat.nativeObj, rvec.nativeObj, tvec.nativeObj, useExtrinsicGuess, flags);
+ }
+
+ /**
+ * Finds an object pose from 3D-2D point correspondences.
+ *
+ * SEE: REF: calib3d_solvePnP
+ *
+ * This function returns the rotation and the translation vectors that transform a 3D point expressed in the object
+ * coordinate frame to the camera coordinate frame, using different methods:
+ *
+ *
+ * P3P methods (REF: SOLVEPNP_P3P, REF: SOLVEPNP_AP3P): need 4 input points to return a unique solution.
+ *
+ *
+ * REF: SOLVEPNP_IPPE Input points must be >= 4 and object points must be coplanar.
+ *
+ *
+ * REF: SOLVEPNP_IPPE_SQUARE Special case suitable for marker pose estimation.
+ * Number of input points must be 4. Object points must be defined in the following order:
+ *
+ * for all the other flags, number of input points must be >= 4 and object points can be in any configuration.
+ *
+ *
+ *
+ * @param objectPoints Array of object points in the object coordinate space, Nx3 1-channel or
+ * 1xN/Nx1 3-channel, where N is the number of points. vector<Point3d> can be also passed here.
+ * @param imagePoints Array of corresponding image points, Nx2 1-channel or 1xN/Nx1 2-channel,
+ * where N is the number of points. vector<Point2d> can be also passed here.
+ * @param cameraMatrix Input camera intrinsic matrix \(\cameramatrix{A}\) .
+ * @param distCoeffs Input vector of distortion coefficients
+ * \(\distcoeffs\). If the vector is NULL/empty, the zero distortion coefficients are
+ * assumed.
+ * @param rvec Output rotation vector (see REF: Rodrigues ) that, together with tvec, brings points from
+ * the model coordinate system to the camera coordinate system.
+ * @param tvec Output translation vector.
+ * @param useExtrinsicGuess Parameter used for #SOLVEPNP_ITERATIVE. If true (1), the function uses
+ * the provided rvec and tvec values as initial approximations of the rotation and translation
+ * vectors, respectively, and further optimizes them.
+ *
+ * More information about Perspective-n-Points is described in REF: calib3d_solvePnP
+ *
+ * Note:
+ *
+ *
+ * An example of how to use solvePnP for planar augmented reality can be found at
+ * opencv_source_code/samples/python/plane_ar.py
+ *
+ *
+ * If you are using Python:
+ *
+ *
+ * Numpy array slices won't work as input because solvePnP requires contiguous
+ * arrays (enforced by the assertion using cv::Mat::checkVector() around line 55 of
+ * modules/calib3d/src/solvepnp.cpp version 2.4.9)
+ *
+ *
+ * The P3P algorithm requires image points to be in an array of shape (N,1,2) due
+ * to its calling of #undistortPoints (around line 75 of modules/calib3d/src/solvepnp.cpp version 2.4.9)
+ * which requires 2-channel information.
+ *
+ *
+ * Thus, given some data D = np.array(...) where D.shape = (N,M), in order to use a subset of
+ * it as, e.g., imagePoints, one must effectively copy it into a new array: imagePoints =
+ * np.ascontiguousarray(D[:,:2]).reshape((N,1,2))
+ *
+ *
+ *
+ * The methods REF: SOLVEPNP_DLS and REF: SOLVEPNP_UPNP cannot be used as the current implementations are
+ * unstable and sometimes give completely wrong results. If you pass one of these two
+ * flags, REF: SOLVEPNP_EPNP method will be used instead.
+ *
+ *
+ * The minimum number of points is 4 in the general case. In the case of REF: SOLVEPNP_P3P and REF: SOLVEPNP_AP3P
+ * methods, it is required to use exactly 4 points (the first 3 points are used to estimate all the solutions
+ * of the P3P problem, the last one is used to retain the best solution that minimizes the reprojection error).
+ *
+ *
+ * With REF: SOLVEPNP_ITERATIVE method and {@code useExtrinsicGuess=true}, the minimum number of points is 3 (3 points
+ * are sufficient to compute a pose but there are up to 4 solutions). The initial solution should be close to the
+ * global solution to converge.
+ *
+ *
+ * With REF: SOLVEPNP_IPPE input points must be >= 4 and object points must be coplanar.
+ *
+ *
+ * With REF: SOLVEPNP_IPPE_SQUARE this is a special case suitable for marker pose estimation.
+ * Number of input points must be 4. Object points must be defined in the following order:
+ *
+ * With REF: SOLVEPNP_SQPNP input points must be >= 3
+ *
+ *
+ *
+ *
+ * @return automatically generated
+ */
+ public static boolean solvePnP(MatOfPoint3f objectPoints, MatOfPoint2f imagePoints, Mat cameraMatrix, MatOfDouble distCoeffs, Mat rvec, Mat tvec, boolean useExtrinsicGuess) {
+ Mat objectPoints_mat = objectPoints;
+ Mat imagePoints_mat = imagePoints;
+ Mat distCoeffs_mat = distCoeffs;
+ return solvePnP_1(objectPoints_mat.nativeObj, imagePoints_mat.nativeObj, cameraMatrix.nativeObj, distCoeffs_mat.nativeObj, rvec.nativeObj, tvec.nativeObj, useExtrinsicGuess);
+ }
+
+ /**
+ * Finds an object pose from 3D-2D point correspondences.
+ *
+ * SEE: REF: calib3d_solvePnP
+ *
+ * This function returns the rotation and the translation vectors that transform a 3D point expressed in the object
+ * coordinate frame to the camera coordinate frame, using different methods:
+ *
+ *
+ * P3P methods (REF: SOLVEPNP_P3P, REF: SOLVEPNP_AP3P): need 4 input points to return a unique solution.
+ *
+ *
+ * REF: SOLVEPNP_IPPE Input points must be >= 4 and object points must be coplanar.
+ *
+ *
+ * REF: SOLVEPNP_IPPE_SQUARE Special case suitable for marker pose estimation.
+ * Number of input points must be 4. Object points must be defined in the following order:
+ *
+ * for all the other flags, number of input points must be >= 4 and object points can be in any configuration.
+ *
+ *
+ *
+ * @param objectPoints Array of object points in the object coordinate space, Nx3 1-channel or
+ * 1xN/Nx1 3-channel, where N is the number of points. vector<Point3d> can be also passed here.
+ * @param imagePoints Array of corresponding image points, Nx2 1-channel or 1xN/Nx1 2-channel,
+ * where N is the number of points. vector<Point2d> can be also passed here.
+ * @param cameraMatrix Input camera intrinsic matrix \(\cameramatrix{A}\) .
+ * @param distCoeffs Input vector of distortion coefficients
+ * \(\distcoeffs\). If the vector is NULL/empty, the zero distortion coefficients are
+ * assumed.
+ * @param rvec Output rotation vector (see REF: Rodrigues ) that, together with tvec, brings points from
+ * the model coordinate system to the camera coordinate system.
+ * @param tvec Output translation vector.
+ * the provided rvec and tvec values as initial approximations of the rotation and translation
+ * vectors, respectively, and further optimizes them.
+ *
+ * More information about Perspective-n-Points is described in REF: calib3d_solvePnP
+ *
+ * Note:
+ *
+ *
+ * An example of how to use solvePnP for planar augmented reality can be found at
+ * opencv_source_code/samples/python/plane_ar.py
+ *
+ *
+ * If you are using Python:
+ *
+ *
+ * Numpy array slices won't work as input because solvePnP requires contiguous
+ * arrays (enforced by the assertion using cv::Mat::checkVector() around line 55 of
+ * modules/calib3d/src/solvepnp.cpp version 2.4.9)
+ *
+ *
+ * The P3P algorithm requires image points to be in an array of shape (N,1,2) due
+ * to its calling of #undistortPoints (around line 75 of modules/calib3d/src/solvepnp.cpp version 2.4.9)
+ * which requires 2-channel information.
+ *
+ *
+ * Thus, given some data D = np.array(...) where D.shape = (N,M), in order to use a subset of
+ * it as, e.g., imagePoints, one must effectively copy it into a new array: imagePoints =
+ * np.ascontiguousarray(D[:,:2]).reshape((N,1,2))
+ *
+ *
+ *
+ * The methods REF: SOLVEPNP_DLS and REF: SOLVEPNP_UPNP cannot be used as the current implementations are
+ * unstable and sometimes give completely wrong results. If you pass one of these two
+ * flags, REF: SOLVEPNP_EPNP method will be used instead.
+ *
+ *
+ * The minimum number of points is 4 in the general case. In the case of REF: SOLVEPNP_P3P and REF: SOLVEPNP_AP3P
+ * methods, it is required to use exactly 4 points (the first 3 points are used to estimate all the solutions
+ * of the P3P problem, the last one is used to retain the best solution that minimizes the reprojection error).
+ *
+ *
+ * With REF: SOLVEPNP_ITERATIVE method and {@code useExtrinsicGuess=true}, the minimum number of points is 3 (3 points
+ * are sufficient to compute a pose but there are up to 4 solutions). The initial solution should be close to the
+ * global solution to converge.
+ *
+ *
+ * With REF: SOLVEPNP_IPPE input points must be >= 4 and object points must be coplanar.
+ *
+ *
+ * With REF: SOLVEPNP_IPPE_SQUARE this is a special case suitable for marker pose estimation.
+ * Number of input points must be 4. Object points must be defined in the following order:
+ *
+ * With REF: SOLVEPNP_SQPNP input points must be >= 3
+ *
+ *
+ *
+ *
+ * @return automatically generated
+ */
+ public static boolean solvePnP(MatOfPoint3f objectPoints, MatOfPoint2f imagePoints, Mat cameraMatrix, MatOfDouble distCoeffs, Mat rvec, Mat tvec) {
+ Mat objectPoints_mat = objectPoints;
+ Mat imagePoints_mat = imagePoints;
+ Mat distCoeffs_mat = distCoeffs;
+ return solvePnP_2(objectPoints_mat.nativeObj, imagePoints_mat.nativeObj, cameraMatrix.nativeObj, distCoeffs_mat.nativeObj, rvec.nativeObj, tvec.nativeObj);
+ }
+
+
+ //
+ // C++: bool cv::solvePnPRansac(vector_Point3f objectPoints, vector_Point2f imagePoints, Mat cameraMatrix, vector_double distCoeffs, Mat& rvec, Mat& tvec, bool useExtrinsicGuess = false, int iterationsCount = 100, float reprojectionError = 8.0, double confidence = 0.99, Mat& inliers = Mat(), int flags = SOLVEPNP_ITERATIVE)
+ //
+
+ /**
+ * Finds an object pose from 3D-2D point correspondences using the RANSAC scheme.
+ *
+ * SEE: REF: calib3d_solvePnP
+ *
+ * @param objectPoints Array of object points in the object coordinate space, Nx3 1-channel or
+ * 1xN/Nx1 3-channel, where N is the number of points. vector<Point3d> can be also passed here.
+ * @param imagePoints Array of corresponding image points, Nx2 1-channel or 1xN/Nx1 2-channel,
+ * where N is the number of points. vector<Point2d> can be also passed here.
+ * @param cameraMatrix Input camera intrinsic matrix \(\cameramatrix{A}\) .
+ * @param distCoeffs Input vector of distortion coefficients
+ * \(\distcoeffs\). If the vector is NULL/empty, the zero distortion coefficients are
+ * assumed.
+ * @param rvec Output rotation vector (see REF: Rodrigues ) that, together with tvec, brings points from
+ * the model coordinate system to the camera coordinate system.
+ * @param tvec Output translation vector.
+ * @param useExtrinsicGuess Parameter used for REF: SOLVEPNP_ITERATIVE. If true (1), the function uses
+ * the provided rvec and tvec values as initial approximations of the rotation and translation
+ * vectors, respectively, and further optimizes them.
+ * @param iterationsCount Number of iterations.
+ * @param reprojectionError Inlier threshold value used by the RANSAC procedure. The parameter value
+ * is the maximum allowed distance between the observed and computed point projections to consider it
+ * an inlier.
+ * @param confidence The probability that the algorithm produces a useful result.
+ * @param inliers Output vector that contains indices of inliers in objectPoints and imagePoints .
+ * @param flags Method for solving a PnP problem (see REF: solvePnP ).
+ *
+ * The function estimates an object pose given a set of object points, their corresponding image
+ * projections, as well as the camera intrinsic matrix and the distortion coefficients. This function finds such
+ * a pose that minimizes reprojection error, that is, the sum of squared distances between the observed
+ * projections imagePoints and the projected (using REF: projectPoints ) objectPoints. The use of RANSAC
+ * makes the function resistant to outliers.
+ *
+ * Note:
+ *
+ *
+ * An example of how to use solvePNPRansac for object detection can be found at
+ * opencv_source_code/samples/cpp/tutorial_code/calib3d/real_time_pose_estimation/
+ *
+ *
+ * The default method used to estimate the camera pose for the Minimal Sample Sets step
+ * is #SOLVEPNP_EPNP. Exceptions are:
+ *
+ *
+ * if you choose #SOLVEPNP_P3P or #SOLVEPNP_AP3P, these methods will be used.
+ *
+ *
+ * if the number of input points is equal to 4, #SOLVEPNP_P3P is used.
+ *
+ *
+ *
+ * The method used to estimate the camera pose using all the inliers is defined by the
+ * flags parameters unless it is equal to #SOLVEPNP_P3P or #SOLVEPNP_AP3P. In this case,
+ * the method #SOLVEPNP_EPNP will be used instead.
+ *
+ *
+ * @return automatically generated
+ */
+ public static boolean solvePnPRansac(MatOfPoint3f objectPoints, MatOfPoint2f imagePoints, Mat cameraMatrix, MatOfDouble distCoeffs, Mat rvec, Mat tvec, boolean useExtrinsicGuess, int iterationsCount, float reprojectionError, double confidence, Mat inliers, int flags) {
+ Mat objectPoints_mat = objectPoints;
+ Mat imagePoints_mat = imagePoints;
+ Mat distCoeffs_mat = distCoeffs;
+ return solvePnPRansac_0(objectPoints_mat.nativeObj, imagePoints_mat.nativeObj, cameraMatrix.nativeObj, distCoeffs_mat.nativeObj, rvec.nativeObj, tvec.nativeObj, useExtrinsicGuess, iterationsCount, reprojectionError, confidence, inliers.nativeObj, flags);
+ }
+
+ /**
+ * Finds an object pose from 3D-2D point correspondences using the RANSAC scheme.
+ *
+ * SEE: REF: calib3d_solvePnP
+ *
+ * @param objectPoints Array of object points in the object coordinate space, Nx3 1-channel or
+ * 1xN/Nx1 3-channel, where N is the number of points. vector<Point3d> can be also passed here.
+ * @param imagePoints Array of corresponding image points, Nx2 1-channel or 1xN/Nx1 2-channel,
+ * where N is the number of points. vector<Point2d> can be also passed here.
+ * @param cameraMatrix Input camera intrinsic matrix \(\cameramatrix{A}\) .
+ * @param distCoeffs Input vector of distortion coefficients
+ * \(\distcoeffs\). If the vector is NULL/empty, the zero distortion coefficients are
+ * assumed.
+ * @param rvec Output rotation vector (see REF: Rodrigues ) that, together with tvec, brings points from
+ * the model coordinate system to the camera coordinate system.
+ * @param tvec Output translation vector.
+ * @param useExtrinsicGuess Parameter used for REF: SOLVEPNP_ITERATIVE. If true (1), the function uses
+ * the provided rvec and tvec values as initial approximations of the rotation and translation
+ * vectors, respectively, and further optimizes them.
+ * @param iterationsCount Number of iterations.
+ * @param reprojectionError Inlier threshold value used by the RANSAC procedure. The parameter value
+ * is the maximum allowed distance between the observed and computed point projections to consider it
+ * an inlier.
+ * @param confidence The probability that the algorithm produces a useful result.
+ * @param inliers Output vector that contains indices of inliers in objectPoints and imagePoints .
+ *
+ * The function estimates an object pose given a set of object points, their corresponding image
+ * projections, as well as the camera intrinsic matrix and the distortion coefficients. This function finds such
+ * a pose that minimizes reprojection error, that is, the sum of squared distances between the observed
+ * projections imagePoints and the projected (using REF: projectPoints ) objectPoints. The use of RANSAC
+ * makes the function resistant to outliers.
+ *
+ * Note:
+ *
+ *
+ * An example of how to use solvePNPRansac for object detection can be found at
+ * opencv_source_code/samples/cpp/tutorial_code/calib3d/real_time_pose_estimation/
+ *
+ *
+ * The default method used to estimate the camera pose for the Minimal Sample Sets step
+ * is #SOLVEPNP_EPNP. Exceptions are:
+ *
+ *
+ * if you choose #SOLVEPNP_P3P or #SOLVEPNP_AP3P, these methods will be used.
+ *
+ *
+ * if the number of input points is equal to 4, #SOLVEPNP_P3P is used.
+ *
+ *
+ *
+ * The method used to estimate the camera pose using all the inliers is defined by the
+ * flags parameters unless it is equal to #SOLVEPNP_P3P or #SOLVEPNP_AP3P. In this case,
+ * the method #SOLVEPNP_EPNP will be used instead.
+ *
+ *
+ * @return automatically generated
+ */
+ public static boolean solvePnPRansac(MatOfPoint3f objectPoints, MatOfPoint2f imagePoints, Mat cameraMatrix, MatOfDouble distCoeffs, Mat rvec, Mat tvec, boolean useExtrinsicGuess, int iterationsCount, float reprojectionError, double confidence, Mat inliers) {
+ Mat objectPoints_mat = objectPoints;
+ Mat imagePoints_mat = imagePoints;
+ Mat distCoeffs_mat = distCoeffs;
+ return solvePnPRansac_1(objectPoints_mat.nativeObj, imagePoints_mat.nativeObj, cameraMatrix.nativeObj, distCoeffs_mat.nativeObj, rvec.nativeObj, tvec.nativeObj, useExtrinsicGuess, iterationsCount, reprojectionError, confidence, inliers.nativeObj);
+ }
+
+ /**
+ * Finds an object pose from 3D-2D point correspondences using the RANSAC scheme.
+ *
+ * SEE: REF: calib3d_solvePnP
+ *
+ * @param objectPoints Array of object points in the object coordinate space, Nx3 1-channel or
+ * 1xN/Nx1 3-channel, where N is the number of points. vector<Point3d> can be also passed here.
+ * @param imagePoints Array of corresponding image points, Nx2 1-channel or 1xN/Nx1 2-channel,
+ * where N is the number of points. vector<Point2d> can be also passed here.
+ * @param cameraMatrix Input camera intrinsic matrix \(\cameramatrix{A}\) .
+ * @param distCoeffs Input vector of distortion coefficients
+ * \(\distcoeffs\). If the vector is NULL/empty, the zero distortion coefficients are
+ * assumed.
+ * @param rvec Output rotation vector (see REF: Rodrigues ) that, together with tvec, brings points from
+ * the model coordinate system to the camera coordinate system.
+ * @param tvec Output translation vector.
+ * @param useExtrinsicGuess Parameter used for REF: SOLVEPNP_ITERATIVE. If true (1), the function uses
+ * the provided rvec and tvec values as initial approximations of the rotation and translation
+ * vectors, respectively, and further optimizes them.
+ * @param iterationsCount Number of iterations.
+ * @param reprojectionError Inlier threshold value used by the RANSAC procedure. The parameter value
+ * is the maximum allowed distance between the observed and computed point projections to consider it
+ * an inlier.
+ * @param confidence The probability that the algorithm produces a useful result.
+ *
+ * The function estimates an object pose given a set of object points, their corresponding image
+ * projections, as well as the camera intrinsic matrix and the distortion coefficients. This function finds such
+ * a pose that minimizes reprojection error, that is, the sum of squared distances between the observed
+ * projections imagePoints and the projected (using REF: projectPoints ) objectPoints. The use of RANSAC
+ * makes the function resistant to outliers.
+ *
+ * Note:
+ *
+ *
+ * An example of how to use solvePNPRansac for object detection can be found at
+ * opencv_source_code/samples/cpp/tutorial_code/calib3d/real_time_pose_estimation/
+ *
+ *
+ * The default method used to estimate the camera pose for the Minimal Sample Sets step
+ * is #SOLVEPNP_EPNP. Exceptions are:
+ *
+ *
+ * if you choose #SOLVEPNP_P3P or #SOLVEPNP_AP3P, these methods will be used.
+ *
+ *
+ * if the number of input points is equal to 4, #SOLVEPNP_P3P is used.
+ *
+ *
+ *
+ * The method used to estimate the camera pose using all the inliers is defined by the
+ * flags parameters unless it is equal to #SOLVEPNP_P3P or #SOLVEPNP_AP3P. In this case,
+ * the method #SOLVEPNP_EPNP will be used instead.
+ *
+ *
+ * @return automatically generated
+ */
+ public static boolean solvePnPRansac(MatOfPoint3f objectPoints, MatOfPoint2f imagePoints, Mat cameraMatrix, MatOfDouble distCoeffs, Mat rvec, Mat tvec, boolean useExtrinsicGuess, int iterationsCount, float reprojectionError, double confidence) {
+ Mat objectPoints_mat = objectPoints;
+ Mat imagePoints_mat = imagePoints;
+ Mat distCoeffs_mat = distCoeffs;
+ return solvePnPRansac_2(objectPoints_mat.nativeObj, imagePoints_mat.nativeObj, cameraMatrix.nativeObj, distCoeffs_mat.nativeObj, rvec.nativeObj, tvec.nativeObj, useExtrinsicGuess, iterationsCount, reprojectionError, confidence);
+ }
+
+ /**
+ * Finds an object pose from 3D-2D point correspondences using the RANSAC scheme.
+ *
+ * SEE: REF: calib3d_solvePnP
+ *
+ * @param objectPoints Array of object points in the object coordinate space, Nx3 1-channel or
+ * 1xN/Nx1 3-channel, where N is the number of points. vector<Point3d> can be also passed here.
+ * @param imagePoints Array of corresponding image points, Nx2 1-channel or 1xN/Nx1 2-channel,
+ * where N is the number of points. vector<Point2d> can be also passed here.
+ * @param cameraMatrix Input camera intrinsic matrix \(\cameramatrix{A}\) .
+ * @param distCoeffs Input vector of distortion coefficients
+ * \(\distcoeffs\). If the vector is NULL/empty, the zero distortion coefficients are
+ * assumed.
+ * @param rvec Output rotation vector (see REF: Rodrigues ) that, together with tvec, brings points from
+ * the model coordinate system to the camera coordinate system.
+ * @param tvec Output translation vector.
+ * @param useExtrinsicGuess Parameter used for REF: SOLVEPNP_ITERATIVE. If true (1), the function uses
+ * the provided rvec and tvec values as initial approximations of the rotation and translation
+ * vectors, respectively, and further optimizes them.
+ * @param iterationsCount Number of iterations.
+ * @param reprojectionError Inlier threshold value used by the RANSAC procedure. The parameter value
+ * is the maximum allowed distance between the observed and computed point projections to consider it
+ * an inlier.
+ *
+ * The function estimates an object pose given a set of object points, their corresponding image
+ * projections, as well as the camera intrinsic matrix and the distortion coefficients. This function finds such
+ * a pose that minimizes reprojection error, that is, the sum of squared distances between the observed
+ * projections imagePoints and the projected (using REF: projectPoints ) objectPoints. The use of RANSAC
+ * makes the function resistant to outliers.
+ *
+ * Note:
+ *
+ *
+ * An example of how to use solvePNPRansac for object detection can be found at
+ * opencv_source_code/samples/cpp/tutorial_code/calib3d/real_time_pose_estimation/
+ *
+ *
+ * The default method used to estimate the camera pose for the Minimal Sample Sets step
+ * is #SOLVEPNP_EPNP. Exceptions are:
+ *
+ *
+ * if you choose #SOLVEPNP_P3P or #SOLVEPNP_AP3P, these methods will be used.
+ *
+ *
+ * if the number of input points is equal to 4, #SOLVEPNP_P3P is used.
+ *
+ *
+ *
+ * The method used to estimate the camera pose using all the inliers is defined by the
+ * flags parameters unless it is equal to #SOLVEPNP_P3P or #SOLVEPNP_AP3P. In this case,
+ * the method #SOLVEPNP_EPNP will be used instead.
+ *
+ *
+ * @return automatically generated
+ */
+ public static boolean solvePnPRansac(MatOfPoint3f objectPoints, MatOfPoint2f imagePoints, Mat cameraMatrix, MatOfDouble distCoeffs, Mat rvec, Mat tvec, boolean useExtrinsicGuess, int iterationsCount, float reprojectionError) {
+ Mat objectPoints_mat = objectPoints;
+ Mat imagePoints_mat = imagePoints;
+ Mat distCoeffs_mat = distCoeffs;
+ return solvePnPRansac_3(objectPoints_mat.nativeObj, imagePoints_mat.nativeObj, cameraMatrix.nativeObj, distCoeffs_mat.nativeObj, rvec.nativeObj, tvec.nativeObj, useExtrinsicGuess, iterationsCount, reprojectionError);
+ }
+
+ /**
+ * Finds an object pose from 3D-2D point correspondences using the RANSAC scheme.
+ *
+ * SEE: REF: calib3d_solvePnP
+ *
+ * @param objectPoints Array of object points in the object coordinate space, Nx3 1-channel or
+ * 1xN/Nx1 3-channel, where N is the number of points. vector<Point3d> can be also passed here.
+ * @param imagePoints Array of corresponding image points, Nx2 1-channel or 1xN/Nx1 2-channel,
+ * where N is the number of points. vector<Point2d> can be also passed here.
+ * @param cameraMatrix Input camera intrinsic matrix \(\cameramatrix{A}\) .
+ * @param distCoeffs Input vector of distortion coefficients
+ * \(\distcoeffs\). If the vector is NULL/empty, the zero distortion coefficients are
+ * assumed.
+ * @param rvec Output rotation vector (see REF: Rodrigues ) that, together with tvec, brings points from
+ * the model coordinate system to the camera coordinate system.
+ * @param tvec Output translation vector.
+ * @param useExtrinsicGuess Parameter used for REF: SOLVEPNP_ITERATIVE. If true (1), the function uses
+ * the provided rvec and tvec values as initial approximations of the rotation and translation
+ * vectors, respectively, and further optimizes them.
+ * @param iterationsCount Number of iterations.
+ * is the maximum allowed distance between the observed and computed point projections to consider it
+ * an inlier.
+ *
+ * The function estimates an object pose given a set of object points, their corresponding image
+ * projections, as well as the camera intrinsic matrix and the distortion coefficients. This function finds such
+ * a pose that minimizes reprojection error, that is, the sum of squared distances between the observed
+ * projections imagePoints and the projected (using REF: projectPoints ) objectPoints. The use of RANSAC
+ * makes the function resistant to outliers.
+ *
+ * Note:
+ *
+ *
+ * An example of how to use solvePNPRansac for object detection can be found at
+ * opencv_source_code/samples/cpp/tutorial_code/calib3d/real_time_pose_estimation/
+ *
+ *
+ * The default method used to estimate the camera pose for the Minimal Sample Sets step
+ * is #SOLVEPNP_EPNP. Exceptions are:
+ *
+ *
+ * if you choose #SOLVEPNP_P3P or #SOLVEPNP_AP3P, these methods will be used.
+ *
+ *
+ * if the number of input points is equal to 4, #SOLVEPNP_P3P is used.
+ *
+ *
+ *
+ * The method used to estimate the camera pose using all the inliers is defined by the
+ * flags parameters unless it is equal to #SOLVEPNP_P3P or #SOLVEPNP_AP3P. In this case,
+ * the method #SOLVEPNP_EPNP will be used instead.
+ *
+ *
+ * @return automatically generated
+ */
+ public static boolean solvePnPRansac(MatOfPoint3f objectPoints, MatOfPoint2f imagePoints, Mat cameraMatrix, MatOfDouble distCoeffs, Mat rvec, Mat tvec, boolean useExtrinsicGuess, int iterationsCount) {
+ Mat objectPoints_mat = objectPoints;
+ Mat imagePoints_mat = imagePoints;
+ Mat distCoeffs_mat = distCoeffs;
+ return solvePnPRansac_4(objectPoints_mat.nativeObj, imagePoints_mat.nativeObj, cameraMatrix.nativeObj, distCoeffs_mat.nativeObj, rvec.nativeObj, tvec.nativeObj, useExtrinsicGuess, iterationsCount);
+ }
+
+ /**
+ * Finds an object pose from 3D-2D point correspondences using the RANSAC scheme.
+ *
+ * SEE: REF: calib3d_solvePnP
+ *
+ * @param objectPoints Array of object points in the object coordinate space, Nx3 1-channel or
+ * 1xN/Nx1 3-channel, where N is the number of points. vector<Point3d> can be also passed here.
+ * @param imagePoints Array of corresponding image points, Nx2 1-channel or 1xN/Nx1 2-channel,
+ * where N is the number of points. vector<Point2d> can be also passed here.
+ * @param cameraMatrix Input camera intrinsic matrix \(\cameramatrix{A}\) .
+ * @param distCoeffs Input vector of distortion coefficients
+ * \(\distcoeffs\). If the vector is NULL/empty, the zero distortion coefficients are
+ * assumed.
+ * @param rvec Output rotation vector (see REF: Rodrigues ) that, together with tvec, brings points from
+ * the model coordinate system to the camera coordinate system.
+ * @param tvec Output translation vector.
+ * @param useExtrinsicGuess Parameter used for REF: SOLVEPNP_ITERATIVE. If true (1), the function uses
+ * the provided rvec and tvec values as initial approximations of the rotation and translation
+ * vectors, respectively, and further optimizes them.
+ * is the maximum allowed distance between the observed and computed point projections to consider it
+ * an inlier.
+ *
+ * The function estimates an object pose given a set of object points, their corresponding image
+ * projections, as well as the camera intrinsic matrix and the distortion coefficients. This function finds such
+ * a pose that minimizes reprojection error, that is, the sum of squared distances between the observed
+ * projections imagePoints and the projected (using REF: projectPoints ) objectPoints. The use of RANSAC
+ * makes the function resistant to outliers.
+ *
+ * Note:
+ *
+ *
+ * An example of how to use solvePNPRansac for object detection can be found at
+ * opencv_source_code/samples/cpp/tutorial_code/calib3d/real_time_pose_estimation/
+ *
+ *
+ * The default method used to estimate the camera pose for the Minimal Sample Sets step
+ * is #SOLVEPNP_EPNP. Exceptions are:
+ *
+ *
+ * if you choose #SOLVEPNP_P3P or #SOLVEPNP_AP3P, these methods will be used.
+ *
+ *
+ * if the number of input points is equal to 4, #SOLVEPNP_P3P is used.
+ *
+ *
+ *
+ * The method used to estimate the camera pose using all the inliers is defined by the
+ * flags parameters unless it is equal to #SOLVEPNP_P3P or #SOLVEPNP_AP3P. In this case,
+ * the method #SOLVEPNP_EPNP will be used instead.
+ *
+ *
+ * @return automatically generated
+ */
+ public static boolean solvePnPRansac(MatOfPoint3f objectPoints, MatOfPoint2f imagePoints, Mat cameraMatrix, MatOfDouble distCoeffs, Mat rvec, Mat tvec, boolean useExtrinsicGuess) {
+ Mat objectPoints_mat = objectPoints;
+ Mat imagePoints_mat = imagePoints;
+ Mat distCoeffs_mat = distCoeffs;
+ return solvePnPRansac_5(objectPoints_mat.nativeObj, imagePoints_mat.nativeObj, cameraMatrix.nativeObj, distCoeffs_mat.nativeObj, rvec.nativeObj, tvec.nativeObj, useExtrinsicGuess);
+ }
+
+ /**
+ * Finds an object pose from 3D-2D point correspondences using the RANSAC scheme.
+ *
+ * SEE: REF: calib3d_solvePnP
+ *
+ * @param objectPoints Array of object points in the object coordinate space, Nx3 1-channel or
+ * 1xN/Nx1 3-channel, where N is the number of points. vector<Point3d> can be also passed here.
+ * @param imagePoints Array of corresponding image points, Nx2 1-channel or 1xN/Nx1 2-channel,
+ * where N is the number of points. vector<Point2d> can be also passed here.
+ * @param cameraMatrix Input camera intrinsic matrix \(\cameramatrix{A}\) .
+ * @param distCoeffs Input vector of distortion coefficients
+ * \(\distcoeffs\). If the vector is NULL/empty, the zero distortion coefficients are
+ * assumed.
+ * @param rvec Output rotation vector (see REF: Rodrigues ) that, together with tvec, brings points from
+ * the model coordinate system to the camera coordinate system.
+ * @param tvec Output translation vector.
+ * the provided rvec and tvec values as initial approximations of the rotation and translation
+ * vectors, respectively, and further optimizes them.
+ * is the maximum allowed distance between the observed and computed point projections to consider it
+ * an inlier.
+ *
+ * The function estimates an object pose given a set of object points, their corresponding image
+ * projections, as well as the camera intrinsic matrix and the distortion coefficients. This function finds such
+ * a pose that minimizes reprojection error, that is, the sum of squared distances between the observed
+ * projections imagePoints and the projected (using REF: projectPoints ) objectPoints. The use of RANSAC
+ * makes the function resistant to outliers.
+ *
+ * Note:
+ *
+ *
+ * An example of how to use solvePNPRansac for object detection can be found at
+ * opencv_source_code/samples/cpp/tutorial_code/calib3d/real_time_pose_estimation/
+ *
+ *
+ * The default method used to estimate the camera pose for the Minimal Sample Sets step
+ * is #SOLVEPNP_EPNP. Exceptions are:
+ *
+ *
+ * if you choose #SOLVEPNP_P3P or #SOLVEPNP_AP3P, these methods will be used.
+ *
+ *
+ * if the number of input points is equal to 4, #SOLVEPNP_P3P is used.
+ *
+ *
+ *
+ * The method used to estimate the camera pose using all the inliers is defined by the
+ * flags parameters unless it is equal to #SOLVEPNP_P3P or #SOLVEPNP_AP3P. In this case,
+ * the method #SOLVEPNP_EPNP will be used instead.
+ *
+ *
+ * @return automatically generated
+ */
+ public static boolean solvePnPRansac(MatOfPoint3f objectPoints, MatOfPoint2f imagePoints, Mat cameraMatrix, MatOfDouble distCoeffs, Mat rvec, Mat tvec) {
+ Mat objectPoints_mat = objectPoints;
+ Mat imagePoints_mat = imagePoints;
+ Mat distCoeffs_mat = distCoeffs;
+ return solvePnPRansac_6(objectPoints_mat.nativeObj, imagePoints_mat.nativeObj, cameraMatrix.nativeObj, distCoeffs_mat.nativeObj, rvec.nativeObj, tvec.nativeObj);
+ }
+
+
+ //
+ // C++: bool cv::solvePnPRansac(vector_Point3f objectPoints, vector_Point2f imagePoints, Mat& cameraMatrix, vector_double distCoeffs, Mat& rvec, Mat& tvec, Mat& inliers, UsacParams params = UsacParams())
+ //
+
+ public static boolean solvePnPRansac(MatOfPoint3f objectPoints, MatOfPoint2f imagePoints, Mat cameraMatrix, MatOfDouble distCoeffs, Mat rvec, Mat tvec, Mat inliers, UsacParams params) {
+ Mat objectPoints_mat = objectPoints;
+ Mat imagePoints_mat = imagePoints;
+ Mat distCoeffs_mat = distCoeffs;
+ return solvePnPRansac_7(objectPoints_mat.nativeObj, imagePoints_mat.nativeObj, cameraMatrix.nativeObj, distCoeffs_mat.nativeObj, rvec.nativeObj, tvec.nativeObj, inliers.nativeObj, params.nativeObj);
+ }
+
+ public static boolean solvePnPRansac(MatOfPoint3f objectPoints, MatOfPoint2f imagePoints, Mat cameraMatrix, MatOfDouble distCoeffs, Mat rvec, Mat tvec, Mat inliers) {
+ Mat objectPoints_mat = objectPoints;
+ Mat imagePoints_mat = imagePoints;
+ Mat distCoeffs_mat = distCoeffs;
+ return solvePnPRansac_8(objectPoints_mat.nativeObj, imagePoints_mat.nativeObj, cameraMatrix.nativeObj, distCoeffs_mat.nativeObj, rvec.nativeObj, tvec.nativeObj, inliers.nativeObj);
+ }
+
+
+ //
+ // C++: int cv::solveP3P(Mat objectPoints, Mat imagePoints, Mat cameraMatrix, Mat distCoeffs, vector_Mat& rvecs, vector_Mat& tvecs, int flags)
+ //
+
+ /**
+ * Finds an object pose from 3 3D-2D point correspondences.
+ *
+ * SEE: REF: calib3d_solvePnP
+ *
+ * @param objectPoints Array of object points in the object coordinate space, 3x3 1-channel or
+ * 1x3/3x1 3-channel. vector<Point3f> can be also passed here.
+ * @param imagePoints Array of corresponding image points, 3x2 1-channel or 1x3/3x1 2-channel.
+ * vector<Point2f> can be also passed here.
+ * @param cameraMatrix Input camera intrinsic matrix \(\cameramatrix{A}\) .
+ * @param distCoeffs Input vector of distortion coefficients
+ * \(\distcoeffs\). If the vector is NULL/empty, the zero distortion coefficients are
+ * assumed.
+ * @param rvecs Output rotation vectors (see REF: Rodrigues ) that, together with tvecs, brings points from
+ * the model coordinate system to the camera coordinate system. A P3P problem has up to 4 solutions.
+ * @param tvecs Output translation vectors.
+ * @param flags Method for solving a P3P problem:
+ *
+ *
+ * REF: SOLVEPNP_P3P Method is based on the paper of X.S. Gao, X.-R. Hou, J. Tang, H.-F. Chang
+ * "Complete Solution Classification for the Perspective-Three-Point Problem" (CITE: gao2003complete).
+ *
+ *
+ * REF: SOLVEPNP_AP3P Method is based on the paper of T. Ke and S. Roumeliotis.
+ * "An Efficient Algebraic Solution to the Perspective-Three-Point Problem" (CITE: Ke17).
+ *
+ *
+ *
+ * The function estimates the object pose given 3 object points, their corresponding image
+ * projections, as well as the camera intrinsic matrix and the distortion coefficients.
+ *
+ * Note:
+ * The solutions are sorted by reprojection errors (lowest to highest).
+ * @return automatically generated
+ */
+ public static int solveP3P(Mat objectPoints, Mat imagePoints, Mat cameraMatrix, Mat distCoeffs, List rvecs, List tvecs, int flags) {
+ Mat rvecs_mat = new Mat();
+ Mat tvecs_mat = new Mat();
+ int retVal = solveP3P_0(objectPoints.nativeObj, imagePoints.nativeObj, cameraMatrix.nativeObj, distCoeffs.nativeObj, rvecs_mat.nativeObj, tvecs_mat.nativeObj, flags);
+ Converters.Mat_to_vector_Mat(rvecs_mat, rvecs);
+ rvecs_mat.release();
+ Converters.Mat_to_vector_Mat(tvecs_mat, tvecs);
+ tvecs_mat.release();
+ return retVal;
+ }
+
+
+ //
+ // C++: void cv::solvePnPRefineLM(Mat objectPoints, Mat imagePoints, Mat cameraMatrix, Mat distCoeffs, Mat& rvec, Mat& tvec, TermCriteria criteria = TermCriteria(TermCriteria::EPS + TermCriteria::COUNT, 20, FLT_EPSILON))
+ //
+
+ /**
+ * Refine a pose (the translation and the rotation that transform a 3D point expressed in the object coordinate frame
+ * to the camera coordinate frame) from a 3D-2D point correspondences and starting from an initial solution.
+ *
+ * SEE: REF: calib3d_solvePnP
+ *
+ * @param objectPoints Array of object points in the object coordinate space, Nx3 1-channel or 1xN/Nx1 3-channel,
+ * where N is the number of points. vector<Point3d> can also be passed here.
+ * @param imagePoints Array of corresponding image points, Nx2 1-channel or 1xN/Nx1 2-channel,
+ * where N is the number of points. vector<Point2d> can also be passed here.
+ * @param cameraMatrix Input camera intrinsic matrix \(\cameramatrix{A}\) .
+ * @param distCoeffs Input vector of distortion coefficients
+ * \(\distcoeffs\). If the vector is NULL/empty, the zero distortion coefficients are
+ * assumed.
+ * @param rvec Input/Output rotation vector (see REF: Rodrigues ) that, together with tvec, brings points from
+ * the model coordinate system to the camera coordinate system. Input values are used as an initial solution.
+ * @param tvec Input/Output translation vector. Input values are used as an initial solution.
+ * @param criteria Criteria when to stop the Levenberg-Marquard iterative algorithm.
+ *
+ * The function refines the object pose given at least 3 object points, their corresponding image
+ * projections, an initial solution for the rotation and translation vector,
+ * as well as the camera intrinsic matrix and the distortion coefficients.
+ * The function minimizes the projection error with respect to the rotation and the translation vectors, according
+ * to a Levenberg-Marquardt iterative minimization CITE: Madsen04 CITE: Eade13 process.
+ */
+ public static void solvePnPRefineLM(Mat objectPoints, Mat imagePoints, Mat cameraMatrix, Mat distCoeffs, Mat rvec, Mat tvec, TermCriteria criteria) {
+ solvePnPRefineLM_0(objectPoints.nativeObj, imagePoints.nativeObj, cameraMatrix.nativeObj, distCoeffs.nativeObj, rvec.nativeObj, tvec.nativeObj, criteria.type, criteria.maxCount, criteria.epsilon);
+ }
+
+ /**
+ * Refine a pose (the translation and the rotation that transform a 3D point expressed in the object coordinate frame
+ * to the camera coordinate frame) from a 3D-2D point correspondences and starting from an initial solution.
+ *
+ * SEE: REF: calib3d_solvePnP
+ *
+ * @param objectPoints Array of object points in the object coordinate space, Nx3 1-channel or 1xN/Nx1 3-channel,
+ * where N is the number of points. vector<Point3d> can also be passed here.
+ * @param imagePoints Array of corresponding image points, Nx2 1-channel or 1xN/Nx1 2-channel,
+ * where N is the number of points. vector<Point2d> can also be passed here.
+ * @param cameraMatrix Input camera intrinsic matrix \(\cameramatrix{A}\) .
+ * @param distCoeffs Input vector of distortion coefficients
+ * \(\distcoeffs\). If the vector is NULL/empty, the zero distortion coefficients are
+ * assumed.
+ * @param rvec Input/Output rotation vector (see REF: Rodrigues ) that, together with tvec, brings points from
+ * the model coordinate system to the camera coordinate system. Input values are used as an initial solution.
+ * @param tvec Input/Output translation vector. Input values are used as an initial solution.
+ *
+ * The function refines the object pose given at least 3 object points, their corresponding image
+ * projections, an initial solution for the rotation and translation vector,
+ * as well as the camera intrinsic matrix and the distortion coefficients.
+ * The function minimizes the projection error with respect to the rotation and the translation vectors, according
+ * to a Levenberg-Marquardt iterative minimization CITE: Madsen04 CITE: Eade13 process.
+ */
+ public static void solvePnPRefineLM(Mat objectPoints, Mat imagePoints, Mat cameraMatrix, Mat distCoeffs, Mat rvec, Mat tvec) {
+ solvePnPRefineLM_1(objectPoints.nativeObj, imagePoints.nativeObj, cameraMatrix.nativeObj, distCoeffs.nativeObj, rvec.nativeObj, tvec.nativeObj);
+ }
+
+
+ //
+ // C++: void cv::solvePnPRefineVVS(Mat objectPoints, Mat imagePoints, Mat cameraMatrix, Mat distCoeffs, Mat& rvec, Mat& tvec, TermCriteria criteria = TermCriteria(TermCriteria::EPS + TermCriteria::COUNT, 20, FLT_EPSILON), double VVSlambda = 1)
+ //
+
+ /**
+ * Refine a pose (the translation and the rotation that transform a 3D point expressed in the object coordinate frame
+ * to the camera coordinate frame) from a 3D-2D point correspondences and starting from an initial solution.
+ *
+ * SEE: REF: calib3d_solvePnP
+ *
+ * @param objectPoints Array of object points in the object coordinate space, Nx3 1-channel or 1xN/Nx1 3-channel,
+ * where N is the number of points. vector<Point3d> can also be passed here.
+ * @param imagePoints Array of corresponding image points, Nx2 1-channel or 1xN/Nx1 2-channel,
+ * where N is the number of points. vector<Point2d> can also be passed here.
+ * @param cameraMatrix Input camera intrinsic matrix \(\cameramatrix{A}\) .
+ * @param distCoeffs Input vector of distortion coefficients
+ * \(\distcoeffs\). If the vector is NULL/empty, the zero distortion coefficients are
+ * assumed.
+ * @param rvec Input/Output rotation vector (see REF: Rodrigues ) that, together with tvec, brings points from
+ * the model coordinate system to the camera coordinate system. Input values are used as an initial solution.
+ * @param tvec Input/Output translation vector. Input values are used as an initial solution.
+ * @param criteria Criteria when to stop the Levenberg-Marquard iterative algorithm.
+ * @param VVSlambda Gain for the virtual visual servoing control law, equivalent to the \(\alpha\)
+ * gain in the Damped Gauss-Newton formulation.
+ *
+ * The function refines the object pose given at least 3 object points, their corresponding image
+ * projections, an initial solution for the rotation and translation vector,
+ * as well as the camera intrinsic matrix and the distortion coefficients.
+ * The function minimizes the projection error with respect to the rotation and the translation vectors, using a
+ * virtual visual servoing (VVS) CITE: Chaumette06 CITE: Marchand16 scheme.
+ */
+ public static void solvePnPRefineVVS(Mat objectPoints, Mat imagePoints, Mat cameraMatrix, Mat distCoeffs, Mat rvec, Mat tvec, TermCriteria criteria, double VVSlambda) {
+ solvePnPRefineVVS_0(objectPoints.nativeObj, imagePoints.nativeObj, cameraMatrix.nativeObj, distCoeffs.nativeObj, rvec.nativeObj, tvec.nativeObj, criteria.type, criteria.maxCount, criteria.epsilon, VVSlambda);
+ }
+
+ /**
+ * Refine a pose (the translation and the rotation that transform a 3D point expressed in the object coordinate frame
+ * to the camera coordinate frame) from a 3D-2D point correspondences and starting from an initial solution.
+ *
+ * SEE: REF: calib3d_solvePnP
+ *
+ * @param objectPoints Array of object points in the object coordinate space, Nx3 1-channel or 1xN/Nx1 3-channel,
+ * where N is the number of points. vector<Point3d> can also be passed here.
+ * @param imagePoints Array of corresponding image points, Nx2 1-channel or 1xN/Nx1 2-channel,
+ * where N is the number of points. vector<Point2d> can also be passed here.
+ * @param cameraMatrix Input camera intrinsic matrix \(\cameramatrix{A}\) .
+ * @param distCoeffs Input vector of distortion coefficients
+ * \(\distcoeffs\). If the vector is NULL/empty, the zero distortion coefficients are
+ * assumed.
+ * @param rvec Input/Output rotation vector (see REF: Rodrigues ) that, together with tvec, brings points from
+ * the model coordinate system to the camera coordinate system. Input values are used as an initial solution.
+ * @param tvec Input/Output translation vector. Input values are used as an initial solution.
+ * @param criteria Criteria when to stop the Levenberg-Marquard iterative algorithm.
+ * gain in the Damped Gauss-Newton formulation.
+ *
+ * The function refines the object pose given at least 3 object points, their corresponding image
+ * projections, an initial solution for the rotation and translation vector,
+ * as well as the camera intrinsic matrix and the distortion coefficients.
+ * The function minimizes the projection error with respect to the rotation and the translation vectors, using a
+ * virtual visual servoing (VVS) CITE: Chaumette06 CITE: Marchand16 scheme.
+ */
+ public static void solvePnPRefineVVS(Mat objectPoints, Mat imagePoints, Mat cameraMatrix, Mat distCoeffs, Mat rvec, Mat tvec, TermCriteria criteria) {
+ solvePnPRefineVVS_1(objectPoints.nativeObj, imagePoints.nativeObj, cameraMatrix.nativeObj, distCoeffs.nativeObj, rvec.nativeObj, tvec.nativeObj, criteria.type, criteria.maxCount, criteria.epsilon);
+ }
+
+ /**
+ * Refine a pose (the translation and the rotation that transform a 3D point expressed in the object coordinate frame
+ * to the camera coordinate frame) from a 3D-2D point correspondences and starting from an initial solution.
+ *
+ * SEE: REF: calib3d_solvePnP
+ *
+ * @param objectPoints Array of object points in the object coordinate space, Nx3 1-channel or 1xN/Nx1 3-channel,
+ * where N is the number of points. vector<Point3d> can also be passed here.
+ * @param imagePoints Array of corresponding image points, Nx2 1-channel or 1xN/Nx1 2-channel,
+ * where N is the number of points. vector<Point2d> can also be passed here.
+ * @param cameraMatrix Input camera intrinsic matrix \(\cameramatrix{A}\) .
+ * @param distCoeffs Input vector of distortion coefficients
+ * \(\distcoeffs\). If the vector is NULL/empty, the zero distortion coefficients are
+ * assumed.
+ * @param rvec Input/Output rotation vector (see REF: Rodrigues ) that, together with tvec, brings points from
+ * the model coordinate system to the camera coordinate system. Input values are used as an initial solution.
+ * @param tvec Input/Output translation vector. Input values are used as an initial solution.
+ * gain in the Damped Gauss-Newton formulation.
+ *
+ * The function refines the object pose given at least 3 object points, their corresponding image
+ * projections, an initial solution for the rotation and translation vector,
+ * as well as the camera intrinsic matrix and the distortion coefficients.
+ * The function minimizes the projection error with respect to the rotation and the translation vectors, using a
+ * virtual visual servoing (VVS) CITE: Chaumette06 CITE: Marchand16 scheme.
+ */
+ public static void solvePnPRefineVVS(Mat objectPoints, Mat imagePoints, Mat cameraMatrix, Mat distCoeffs, Mat rvec, Mat tvec) {
+ solvePnPRefineVVS_2(objectPoints.nativeObj, imagePoints.nativeObj, cameraMatrix.nativeObj, distCoeffs.nativeObj, rvec.nativeObj, tvec.nativeObj);
+ }
+
+
+ //
+ // C++: int cv::solvePnPGeneric(Mat objectPoints, Mat imagePoints, Mat cameraMatrix, Mat distCoeffs, vector_Mat& rvecs, vector_Mat& tvecs, bool useExtrinsicGuess = false, SolvePnPMethod flags = SOLVEPNP_ITERATIVE, Mat rvec = Mat(), Mat tvec = Mat(), Mat& reprojectionError = Mat())
+ //
+
+ /**
+ * Finds an object pose from 3D-2D point correspondences.
+ *
+ * SEE: REF: calib3d_solvePnP
+ *
+ * This function returns a list of all the possible solutions (a solution is a <rotation vector, translation vector>
+ * couple), depending on the number of input points and the chosen method:
+ *
+ *
+ * P3P methods (REF: SOLVEPNP_P3P, REF: SOLVEPNP_AP3P): 3 or 4 input points. Number of returned solutions can be between 0 and 4 with 3 input points.
+ *
+ *
+ * REF: SOLVEPNP_IPPE Input points must be >= 4 and object points must be coplanar. Returns 2 solutions.
+ *
+ *
+ * REF: SOLVEPNP_IPPE_SQUARE Special case suitable for marker pose estimation.
+ * Number of input points must be 4 and 2 solutions are returned. Object points must be defined in the following order:
+ *
+ * for all the other flags, number of input points must be >= 4 and object points can be in any configuration.
+ * Only 1 solution is returned.
+ *
+ *
+ *
+ * @param objectPoints Array of object points in the object coordinate space, Nx3 1-channel or
+ * 1xN/Nx1 3-channel, where N is the number of points. vector<Point3d> can be also passed here.
+ * @param imagePoints Array of corresponding image points, Nx2 1-channel or 1xN/Nx1 2-channel,
+ * where N is the number of points. vector<Point2d> can be also passed here.
+ * @param cameraMatrix Input camera intrinsic matrix \(\cameramatrix{A}\) .
+ * @param distCoeffs Input vector of distortion coefficients
+ * \(\distcoeffs\). If the vector is NULL/empty, the zero distortion coefficients are
+ * assumed.
+ * @param rvecs Vector of output rotation vectors (see REF: Rodrigues ) that, together with tvecs, brings points from
+ * the model coordinate system to the camera coordinate system.
+ * @param tvecs Vector of output translation vectors.
+ * @param useExtrinsicGuess Parameter used for #SOLVEPNP_ITERATIVE. If true (1), the function uses
+ * the provided rvec and tvec values as initial approximations of the rotation and translation
+ * vectors, respectively, and further optimizes them.
+ * @param flags Method for solving a PnP problem: see REF: calib3d_solvePnP_flags
+ * @param rvec Rotation vector used to initialize an iterative PnP refinement algorithm, when flag is REF: SOLVEPNP_ITERATIVE
+ * and useExtrinsicGuess is set to true.
+ * @param tvec Translation vector used to initialize an iterative PnP refinement algorithm, when flag is REF: SOLVEPNP_ITERATIVE
+ * and useExtrinsicGuess is set to true.
+ * @param reprojectionError Optional vector of reprojection error, that is the RMS error
+ * (\( \text{RMSE} = \sqrt{\frac{\sum_{i}^{N} \left ( \hat{y_i} - y_i \right )^2}{N}} \)) between the input image points
+ * and the 3D object points projected with the estimated pose.
+ *
+ * More information is described in REF: calib3d_solvePnP
+ *
+ * Note:
+ *
+ *
+ * An example of how to use solvePnP for planar augmented reality can be found at
+ * opencv_source_code/samples/python/plane_ar.py
+ *
+ *
+ * If you are using Python:
+ *
+ *
+ * Numpy array slices won't work as input because solvePnP requires contiguous
+ * arrays (enforced by the assertion using cv::Mat::checkVector() around line 55 of
+ * modules/calib3d/src/solvepnp.cpp version 2.4.9)
+ *
+ *
+ * The P3P algorithm requires image points to be in an array of shape (N,1,2) due
+ * to its calling of #undistortPoints (around line 75 of modules/calib3d/src/solvepnp.cpp version 2.4.9)
+ * which requires 2-channel information.
+ *
+ *
+ * Thus, given some data D = np.array(...) where D.shape = (N,M), in order to use a subset of
+ * it as, e.g., imagePoints, one must effectively copy it into a new array: imagePoints =
+ * np.ascontiguousarray(D[:,:2]).reshape((N,1,2))
+ *
+ *
+ *
+ * The methods REF: SOLVEPNP_DLS and REF: SOLVEPNP_UPNP cannot be used as the current implementations are
+ * unstable and sometimes give completely wrong results. If you pass one of these two
+ * flags, REF: SOLVEPNP_EPNP method will be used instead.
+ *
+ *
+ * The minimum number of points is 4 in the general case. In the case of REF: SOLVEPNP_P3P and REF: SOLVEPNP_AP3P
+ * methods, it is required to use exactly 4 points (the first 3 points are used to estimate all the solutions
+ * of the P3P problem, the last one is used to retain the best solution that minimizes the reprojection error).
+ *
+ *
+ * With REF: SOLVEPNP_ITERATIVE method and {@code useExtrinsicGuess=true}, the minimum number of points is 3 (3 points
+ * are sufficient to compute a pose but there are up to 4 solutions). The initial solution should be close to the
+ * global solution to converge.
+ *
+ *
+ * With REF: SOLVEPNP_IPPE input points must be >= 4 and object points must be coplanar.
+ *
+ *
+ * With REF: SOLVEPNP_IPPE_SQUARE this is a special case suitable for marker pose estimation.
+ * Number of input points must be 4. Object points must be defined in the following order:
+ *
+ * @return automatically generated
+ */
+ public static int solvePnPGeneric(Mat objectPoints, Mat imagePoints, Mat cameraMatrix, Mat distCoeffs, List rvecs, List tvecs, boolean useExtrinsicGuess, int flags, Mat rvec, Mat tvec, Mat reprojectionError) {
+ Mat rvecs_mat = new Mat();
+ Mat tvecs_mat = new Mat();
+ int retVal = solvePnPGeneric_0(objectPoints.nativeObj, imagePoints.nativeObj, cameraMatrix.nativeObj, distCoeffs.nativeObj, rvecs_mat.nativeObj, tvecs_mat.nativeObj, useExtrinsicGuess, flags, rvec.nativeObj, tvec.nativeObj, reprojectionError.nativeObj);
+ Converters.Mat_to_vector_Mat(rvecs_mat, rvecs);
+ rvecs_mat.release();
+ Converters.Mat_to_vector_Mat(tvecs_mat, tvecs);
+ tvecs_mat.release();
+ return retVal;
+ }
+
+ /**
+ * Finds an object pose from 3D-2D point correspondences.
+ *
+ * SEE: REF: calib3d_solvePnP
+ *
+ * This function returns a list of all the possible solutions (a solution is a <rotation vector, translation vector>
+ * couple), depending on the number of input points and the chosen method:
+ *
+ *
+ * P3P methods (REF: SOLVEPNP_P3P, REF: SOLVEPNP_AP3P): 3 or 4 input points. Number of returned solutions can be between 0 and 4 with 3 input points.
+ *
+ *
+ * REF: SOLVEPNP_IPPE Input points must be >= 4 and object points must be coplanar. Returns 2 solutions.
+ *
+ *
+ * REF: SOLVEPNP_IPPE_SQUARE Special case suitable for marker pose estimation.
+ * Number of input points must be 4 and 2 solutions are returned. Object points must be defined in the following order:
+ *
+ * for all the other flags, number of input points must be >= 4 and object points can be in any configuration.
+ * Only 1 solution is returned.
+ *
+ *
+ *
+ * @param objectPoints Array of object points in the object coordinate space, Nx3 1-channel or
+ * 1xN/Nx1 3-channel, where N is the number of points. vector<Point3d> can be also passed here.
+ * @param imagePoints Array of corresponding image points, Nx2 1-channel or 1xN/Nx1 2-channel,
+ * where N is the number of points. vector<Point2d> can be also passed here.
+ * @param cameraMatrix Input camera intrinsic matrix \(\cameramatrix{A}\) .
+ * @param distCoeffs Input vector of distortion coefficients
+ * \(\distcoeffs\). If the vector is NULL/empty, the zero distortion coefficients are
+ * assumed.
+ * @param rvecs Vector of output rotation vectors (see REF: Rodrigues ) that, together with tvecs, brings points from
+ * the model coordinate system to the camera coordinate system.
+ * @param tvecs Vector of output translation vectors.
+ * @param useExtrinsicGuess Parameter used for #SOLVEPNP_ITERATIVE. If true (1), the function uses
+ * the provided rvec and tvec values as initial approximations of the rotation and translation
+ * vectors, respectively, and further optimizes them.
+ * @param flags Method for solving a PnP problem: see REF: calib3d_solvePnP_flags
+ * @param rvec Rotation vector used to initialize an iterative PnP refinement algorithm, when flag is REF: SOLVEPNP_ITERATIVE
+ * and useExtrinsicGuess is set to true.
+ * @param tvec Translation vector used to initialize an iterative PnP refinement algorithm, when flag is REF: SOLVEPNP_ITERATIVE
+ * and useExtrinsicGuess is set to true.
+ * (\( \text{RMSE} = \sqrt{\frac{\sum_{i}^{N} \left ( \hat{y_i} - y_i \right )^2}{N}} \)) between the input image points
+ * and the 3D object points projected with the estimated pose.
+ *
+ * More information is described in REF: calib3d_solvePnP
+ *
+ * Note:
+ *
+ *
+ * An example of how to use solvePnP for planar augmented reality can be found at
+ * opencv_source_code/samples/python/plane_ar.py
+ *
+ *
+ * If you are using Python:
+ *
+ *
+ * Numpy array slices won't work as input because solvePnP requires contiguous
+ * arrays (enforced by the assertion using cv::Mat::checkVector() around line 55 of
+ * modules/calib3d/src/solvepnp.cpp version 2.4.9)
+ *
+ *
+ * The P3P algorithm requires image points to be in an array of shape (N,1,2) due
+ * to its calling of #undistortPoints (around line 75 of modules/calib3d/src/solvepnp.cpp version 2.4.9)
+ * which requires 2-channel information.
+ *
+ *
+ * Thus, given some data D = np.array(...) where D.shape = (N,M), in order to use a subset of
+ * it as, e.g., imagePoints, one must effectively copy it into a new array: imagePoints =
+ * np.ascontiguousarray(D[:,:2]).reshape((N,1,2))
+ *
+ *
+ *
+ * The methods REF: SOLVEPNP_DLS and REF: SOLVEPNP_UPNP cannot be used as the current implementations are
+ * unstable and sometimes give completely wrong results. If you pass one of these two
+ * flags, REF: SOLVEPNP_EPNP method will be used instead.
+ *
+ *
+ * The minimum number of points is 4 in the general case. In the case of REF: SOLVEPNP_P3P and REF: SOLVEPNP_AP3P
+ * methods, it is required to use exactly 4 points (the first 3 points are used to estimate all the solutions
+ * of the P3P problem, the last one is used to retain the best solution that minimizes the reprojection error).
+ *
+ *
+ * With REF: SOLVEPNP_ITERATIVE method and {@code useExtrinsicGuess=true}, the minimum number of points is 3 (3 points
+ * are sufficient to compute a pose but there are up to 4 solutions). The initial solution should be close to the
+ * global solution to converge.
+ *
+ *
+ * With REF: SOLVEPNP_IPPE input points must be >= 4 and object points must be coplanar.
+ *
+ *
+ * With REF: SOLVEPNP_IPPE_SQUARE this is a special case suitable for marker pose estimation.
+ * Number of input points must be 4. Object points must be defined in the following order:
+ *
+ * @return automatically generated
+ */
+ public static int solvePnPGeneric(Mat objectPoints, Mat imagePoints, Mat cameraMatrix, Mat distCoeffs, List rvecs, List tvecs, boolean useExtrinsicGuess, int flags, Mat rvec, Mat tvec) {
+ Mat rvecs_mat = new Mat();
+ Mat tvecs_mat = new Mat();
+ int retVal = solvePnPGeneric_1(objectPoints.nativeObj, imagePoints.nativeObj, cameraMatrix.nativeObj, distCoeffs.nativeObj, rvecs_mat.nativeObj, tvecs_mat.nativeObj, useExtrinsicGuess, flags, rvec.nativeObj, tvec.nativeObj);
+ Converters.Mat_to_vector_Mat(rvecs_mat, rvecs);
+ rvecs_mat.release();
+ Converters.Mat_to_vector_Mat(tvecs_mat, tvecs);
+ tvecs_mat.release();
+ return retVal;
+ }
+
+ /**
+ * Finds an object pose from 3D-2D point correspondences.
+ *
+ * SEE: REF: calib3d_solvePnP
+ *
+ * This function returns a list of all the possible solutions (a solution is a <rotation vector, translation vector>
+ * couple), depending on the number of input points and the chosen method:
+ *
+ *
+ * P3P methods (REF: SOLVEPNP_P3P, REF: SOLVEPNP_AP3P): 3 or 4 input points. Number of returned solutions can be between 0 and 4 with 3 input points.
+ *
+ *
+ * REF: SOLVEPNP_IPPE Input points must be >= 4 and object points must be coplanar. Returns 2 solutions.
+ *
+ *
+ * REF: SOLVEPNP_IPPE_SQUARE Special case suitable for marker pose estimation.
+ * Number of input points must be 4 and 2 solutions are returned. Object points must be defined in the following order:
+ *
+ * for all the other flags, number of input points must be >= 4 and object points can be in any configuration.
+ * Only 1 solution is returned.
+ *
+ *
+ *
+ * @param objectPoints Array of object points in the object coordinate space, Nx3 1-channel or
+ * 1xN/Nx1 3-channel, where N is the number of points. vector<Point3d> can be also passed here.
+ * @param imagePoints Array of corresponding image points, Nx2 1-channel or 1xN/Nx1 2-channel,
+ * where N is the number of points. vector<Point2d> can be also passed here.
+ * @param cameraMatrix Input camera intrinsic matrix \(\cameramatrix{A}\) .
+ * @param distCoeffs Input vector of distortion coefficients
+ * \(\distcoeffs\). If the vector is NULL/empty, the zero distortion coefficients are
+ * assumed.
+ * @param rvecs Vector of output rotation vectors (see REF: Rodrigues ) that, together with tvecs, brings points from
+ * the model coordinate system to the camera coordinate system.
+ * @param tvecs Vector of output translation vectors.
+ * @param useExtrinsicGuess Parameter used for #SOLVEPNP_ITERATIVE. If true (1), the function uses
+ * the provided rvec and tvec values as initial approximations of the rotation and translation
+ * vectors, respectively, and further optimizes them.
+ * @param flags Method for solving a PnP problem: see REF: calib3d_solvePnP_flags
+ * @param rvec Rotation vector used to initialize an iterative PnP refinement algorithm, when flag is REF: SOLVEPNP_ITERATIVE
+ * and useExtrinsicGuess is set to true.
+ * and useExtrinsicGuess is set to true.
+ * (\( \text{RMSE} = \sqrt{\frac{\sum_{i}^{N} \left ( \hat{y_i} - y_i \right )^2}{N}} \)) between the input image points
+ * and the 3D object points projected with the estimated pose.
+ *
+ * More information is described in REF: calib3d_solvePnP
+ *
+ * Note:
+ *
+ *
+ * An example of how to use solvePnP for planar augmented reality can be found at
+ * opencv_source_code/samples/python/plane_ar.py
+ *
+ *
+ * If you are using Python:
+ *
+ *
+ * Numpy array slices won't work as input because solvePnP requires contiguous
+ * arrays (enforced by the assertion using cv::Mat::checkVector() around line 55 of
+ * modules/calib3d/src/solvepnp.cpp version 2.4.9)
+ *
+ *
+ * The P3P algorithm requires image points to be in an array of shape (N,1,2) due
+ * to its calling of #undistortPoints (around line 75 of modules/calib3d/src/solvepnp.cpp version 2.4.9)
+ * which requires 2-channel information.
+ *
+ *
+ * Thus, given some data D = np.array(...) where D.shape = (N,M), in order to use a subset of
+ * it as, e.g., imagePoints, one must effectively copy it into a new array: imagePoints =
+ * np.ascontiguousarray(D[:,:2]).reshape((N,1,2))
+ *
+ *
+ *
+ * The methods REF: SOLVEPNP_DLS and REF: SOLVEPNP_UPNP cannot be used as the current implementations are
+ * unstable and sometimes give completely wrong results. If you pass one of these two
+ * flags, REF: SOLVEPNP_EPNP method will be used instead.
+ *
+ *
+ * The minimum number of points is 4 in the general case. In the case of REF: SOLVEPNP_P3P and REF: SOLVEPNP_AP3P
+ * methods, it is required to use exactly 4 points (the first 3 points are used to estimate all the solutions
+ * of the P3P problem, the last one is used to retain the best solution that minimizes the reprojection error).
+ *
+ *
+ * With REF: SOLVEPNP_ITERATIVE method and {@code useExtrinsicGuess=true}, the minimum number of points is 3 (3 points
+ * are sufficient to compute a pose but there are up to 4 solutions). The initial solution should be close to the
+ * global solution to converge.
+ *
+ *
+ * With REF: SOLVEPNP_IPPE input points must be >= 4 and object points must be coplanar.
+ *
+ *
+ * With REF: SOLVEPNP_IPPE_SQUARE this is a special case suitable for marker pose estimation.
+ * Number of input points must be 4. Object points must be defined in the following order:
+ *
+ * @return automatically generated
+ */
+ public static int solvePnPGeneric(Mat objectPoints, Mat imagePoints, Mat cameraMatrix, Mat distCoeffs, List rvecs, List tvecs, boolean useExtrinsicGuess, int flags, Mat rvec) {
+ Mat rvecs_mat = new Mat();
+ Mat tvecs_mat = new Mat();
+ int retVal = solvePnPGeneric_2(objectPoints.nativeObj, imagePoints.nativeObj, cameraMatrix.nativeObj, distCoeffs.nativeObj, rvecs_mat.nativeObj, tvecs_mat.nativeObj, useExtrinsicGuess, flags, rvec.nativeObj);
+ Converters.Mat_to_vector_Mat(rvecs_mat, rvecs);
+ rvecs_mat.release();
+ Converters.Mat_to_vector_Mat(tvecs_mat, tvecs);
+ tvecs_mat.release();
+ return retVal;
+ }
+
+ /**
+ * Finds an object pose from 3D-2D point correspondences.
+ *
+ * SEE: REF: calib3d_solvePnP
+ *
+ * This function returns a list of all the possible solutions (a solution is a <rotation vector, translation vector>
+ * couple), depending on the number of input points and the chosen method:
+ *
+ *
+ * P3P methods (REF: SOLVEPNP_P3P, REF: SOLVEPNP_AP3P): 3 or 4 input points. Number of returned solutions can be between 0 and 4 with 3 input points.
+ *
+ *
+ * REF: SOLVEPNP_IPPE Input points must be >= 4 and object points must be coplanar. Returns 2 solutions.
+ *
+ *
+ * REF: SOLVEPNP_IPPE_SQUARE Special case suitable for marker pose estimation.
+ * Number of input points must be 4 and 2 solutions are returned. Object points must be defined in the following order:
+ *
+ * for all the other flags, number of input points must be >= 4 and object points can be in any configuration.
+ * Only 1 solution is returned.
+ *
+ *
+ *
+ * @param objectPoints Array of object points in the object coordinate space, Nx3 1-channel or
+ * 1xN/Nx1 3-channel, where N is the number of points. vector<Point3d> can be also passed here.
+ * @param imagePoints Array of corresponding image points, Nx2 1-channel or 1xN/Nx1 2-channel,
+ * where N is the number of points. vector<Point2d> can be also passed here.
+ * @param cameraMatrix Input camera intrinsic matrix \(\cameramatrix{A}\) .
+ * @param distCoeffs Input vector of distortion coefficients
+ * \(\distcoeffs\). If the vector is NULL/empty, the zero distortion coefficients are
+ * assumed.
+ * @param rvecs Vector of output rotation vectors (see REF: Rodrigues ) that, together with tvecs, brings points from
+ * the model coordinate system to the camera coordinate system.
+ * @param tvecs Vector of output translation vectors.
+ * @param useExtrinsicGuess Parameter used for #SOLVEPNP_ITERATIVE. If true (1), the function uses
+ * the provided rvec and tvec values as initial approximations of the rotation and translation
+ * vectors, respectively, and further optimizes them.
+ * @param flags Method for solving a PnP problem: see REF: calib3d_solvePnP_flags
+ * and useExtrinsicGuess is set to true.
+ * and useExtrinsicGuess is set to true.
+ * (\( \text{RMSE} = \sqrt{\frac{\sum_{i}^{N} \left ( \hat{y_i} - y_i \right )^2}{N}} \)) between the input image points
+ * and the 3D object points projected with the estimated pose.
+ *
+ * More information is described in REF: calib3d_solvePnP
+ *
+ * Note:
+ *
+ *
+ * An example of how to use solvePnP for planar augmented reality can be found at
+ * opencv_source_code/samples/python/plane_ar.py
+ *
+ *
+ * If you are using Python:
+ *
+ *
+ * Numpy array slices won't work as input because solvePnP requires contiguous
+ * arrays (enforced by the assertion using cv::Mat::checkVector() around line 55 of
+ * modules/calib3d/src/solvepnp.cpp version 2.4.9)
+ *
+ *
+ * The P3P algorithm requires image points to be in an array of shape (N,1,2) due
+ * to its calling of #undistortPoints (around line 75 of modules/calib3d/src/solvepnp.cpp version 2.4.9)
+ * which requires 2-channel information.
+ *
+ *
+ * Thus, given some data D = np.array(...) where D.shape = (N,M), in order to use a subset of
+ * it as, e.g., imagePoints, one must effectively copy it into a new array: imagePoints =
+ * np.ascontiguousarray(D[:,:2]).reshape((N,1,2))
+ *
+ *
+ *
+ * The methods REF: SOLVEPNP_DLS and REF: SOLVEPNP_UPNP cannot be used as the current implementations are
+ * unstable and sometimes give completely wrong results. If you pass one of these two
+ * flags, REF: SOLVEPNP_EPNP method will be used instead.
+ *
+ *
+ * The minimum number of points is 4 in the general case. In the case of REF: SOLVEPNP_P3P and REF: SOLVEPNP_AP3P
+ * methods, it is required to use exactly 4 points (the first 3 points are used to estimate all the solutions
+ * of the P3P problem, the last one is used to retain the best solution that minimizes the reprojection error).
+ *
+ *
+ * With REF: SOLVEPNP_ITERATIVE method and {@code useExtrinsicGuess=true}, the minimum number of points is 3 (3 points
+ * are sufficient to compute a pose but there are up to 4 solutions). The initial solution should be close to the
+ * global solution to converge.
+ *
+ *
+ * With REF: SOLVEPNP_IPPE input points must be >= 4 and object points must be coplanar.
+ *
+ *
+ * With REF: SOLVEPNP_IPPE_SQUARE this is a special case suitable for marker pose estimation.
+ * Number of input points must be 4. Object points must be defined in the following order:
+ *
+ * @return automatically generated
+ */
+ public static int solvePnPGeneric(Mat objectPoints, Mat imagePoints, Mat cameraMatrix, Mat distCoeffs, List rvecs, List tvecs, boolean useExtrinsicGuess, int flags) {
+ Mat rvecs_mat = new Mat();
+ Mat tvecs_mat = new Mat();
+ int retVal = solvePnPGeneric_3(objectPoints.nativeObj, imagePoints.nativeObj, cameraMatrix.nativeObj, distCoeffs.nativeObj, rvecs_mat.nativeObj, tvecs_mat.nativeObj, useExtrinsicGuess, flags);
+ Converters.Mat_to_vector_Mat(rvecs_mat, rvecs);
+ rvecs_mat.release();
+ Converters.Mat_to_vector_Mat(tvecs_mat, tvecs);
+ tvecs_mat.release();
+ return retVal;
+ }
+
+ /**
+ * Finds an object pose from 3D-2D point correspondences.
+ *
+ * SEE: REF: calib3d_solvePnP
+ *
+ * This function returns a list of all the possible solutions (a solution is a <rotation vector, translation vector>
+ * couple), depending on the number of input points and the chosen method:
+ *
+ *
+ * P3P methods (REF: SOLVEPNP_P3P, REF: SOLVEPNP_AP3P): 3 or 4 input points. Number of returned solutions can be between 0 and 4 with 3 input points.
+ *
+ *
+ * REF: SOLVEPNP_IPPE Input points must be >= 4 and object points must be coplanar. Returns 2 solutions.
+ *
+ *
+ * REF: SOLVEPNP_IPPE_SQUARE Special case suitable for marker pose estimation.
+ * Number of input points must be 4 and 2 solutions are returned. Object points must be defined in the following order:
+ *
+ * for all the other flags, number of input points must be >= 4 and object points can be in any configuration.
+ * Only 1 solution is returned.
+ *
+ *
+ *
+ * @param objectPoints Array of object points in the object coordinate space, Nx3 1-channel or
+ * 1xN/Nx1 3-channel, where N is the number of points. vector<Point3d> can be also passed here.
+ * @param imagePoints Array of corresponding image points, Nx2 1-channel or 1xN/Nx1 2-channel,
+ * where N is the number of points. vector<Point2d> can be also passed here.
+ * @param cameraMatrix Input camera intrinsic matrix \(\cameramatrix{A}\) .
+ * @param distCoeffs Input vector of distortion coefficients
+ * \(\distcoeffs\). If the vector is NULL/empty, the zero distortion coefficients are
+ * assumed.
+ * @param rvecs Vector of output rotation vectors (see REF: Rodrigues ) that, together with tvecs, brings points from
+ * the model coordinate system to the camera coordinate system.
+ * @param tvecs Vector of output translation vectors.
+ * @param useExtrinsicGuess Parameter used for #SOLVEPNP_ITERATIVE. If true (1), the function uses
+ * the provided rvec and tvec values as initial approximations of the rotation and translation
+ * vectors, respectively, and further optimizes them.
+ * and useExtrinsicGuess is set to true.
+ * and useExtrinsicGuess is set to true.
+ * (\( \text{RMSE} = \sqrt{\frac{\sum_{i}^{N} \left ( \hat{y_i} - y_i \right )^2}{N}} \)) between the input image points
+ * and the 3D object points projected with the estimated pose.
+ *
+ * More information is described in REF: calib3d_solvePnP
+ *
+ * Note:
+ *
+ *
+ * An example of how to use solvePnP for planar augmented reality can be found at
+ * opencv_source_code/samples/python/plane_ar.py
+ *
+ *
+ * If you are using Python:
+ *
+ *
+ * Numpy array slices won't work as input because solvePnP requires contiguous
+ * arrays (enforced by the assertion using cv::Mat::checkVector() around line 55 of
+ * modules/calib3d/src/solvepnp.cpp version 2.4.9)
+ *
+ *
+ * The P3P algorithm requires image points to be in an array of shape (N,1,2) due
+ * to its calling of #undistortPoints (around line 75 of modules/calib3d/src/solvepnp.cpp version 2.4.9)
+ * which requires 2-channel information.
+ *
+ *
+ * Thus, given some data D = np.array(...) where D.shape = (N,M), in order to use a subset of
+ * it as, e.g., imagePoints, one must effectively copy it into a new array: imagePoints =
+ * np.ascontiguousarray(D[:,:2]).reshape((N,1,2))
+ *
+ *
+ *
+ * The methods REF: SOLVEPNP_DLS and REF: SOLVEPNP_UPNP cannot be used as the current implementations are
+ * unstable and sometimes give completely wrong results. If you pass one of these two
+ * flags, REF: SOLVEPNP_EPNP method will be used instead.
+ *
+ *
+ * The minimum number of points is 4 in the general case. In the case of REF: SOLVEPNP_P3P and REF: SOLVEPNP_AP3P
+ * methods, it is required to use exactly 4 points (the first 3 points are used to estimate all the solutions
+ * of the P3P problem, the last one is used to retain the best solution that minimizes the reprojection error).
+ *
+ *
+ * With REF: SOLVEPNP_ITERATIVE method and {@code useExtrinsicGuess=true}, the minimum number of points is 3 (3 points
+ * are sufficient to compute a pose but there are up to 4 solutions). The initial solution should be close to the
+ * global solution to converge.
+ *
+ *
+ * With REF: SOLVEPNP_IPPE input points must be >= 4 and object points must be coplanar.
+ *
+ *
+ * With REF: SOLVEPNP_IPPE_SQUARE this is a special case suitable for marker pose estimation.
+ * Number of input points must be 4. Object points must be defined in the following order:
+ *
+ * @return automatically generated
+ */
+ public static int solvePnPGeneric(Mat objectPoints, Mat imagePoints, Mat cameraMatrix, Mat distCoeffs, List rvecs, List tvecs, boolean useExtrinsicGuess) {
+ Mat rvecs_mat = new Mat();
+ Mat tvecs_mat = new Mat();
+ int retVal = solvePnPGeneric_4(objectPoints.nativeObj, imagePoints.nativeObj, cameraMatrix.nativeObj, distCoeffs.nativeObj, rvecs_mat.nativeObj, tvecs_mat.nativeObj, useExtrinsicGuess);
+ Converters.Mat_to_vector_Mat(rvecs_mat, rvecs);
+ rvecs_mat.release();
+ Converters.Mat_to_vector_Mat(tvecs_mat, tvecs);
+ tvecs_mat.release();
+ return retVal;
+ }
+
+ /**
+ * Finds an object pose from 3D-2D point correspondences.
+ *
+ * SEE: REF: calib3d_solvePnP
+ *
+ * This function returns a list of all the possible solutions (a solution is a <rotation vector, translation vector>
+ * couple), depending on the number of input points and the chosen method:
+ *
+ *
+ * P3P methods (REF: SOLVEPNP_P3P, REF: SOLVEPNP_AP3P): 3 or 4 input points. Number of returned solutions can be between 0 and 4 with 3 input points.
+ *
+ *
+ * REF: SOLVEPNP_IPPE Input points must be >= 4 and object points must be coplanar. Returns 2 solutions.
+ *
+ *
+ * REF: SOLVEPNP_IPPE_SQUARE Special case suitable for marker pose estimation.
+ * Number of input points must be 4 and 2 solutions are returned. Object points must be defined in the following order:
+ *
+ * for all the other flags, number of input points must be >= 4 and object points can be in any configuration.
+ * Only 1 solution is returned.
+ *
+ *
+ *
+ * @param objectPoints Array of object points in the object coordinate space, Nx3 1-channel or
+ * 1xN/Nx1 3-channel, where N is the number of points. vector<Point3d> can be also passed here.
+ * @param imagePoints Array of corresponding image points, Nx2 1-channel or 1xN/Nx1 2-channel,
+ * where N is the number of points. vector<Point2d> can be also passed here.
+ * @param cameraMatrix Input camera intrinsic matrix \(\cameramatrix{A}\) .
+ * @param distCoeffs Input vector of distortion coefficients
+ * \(\distcoeffs\). If the vector is NULL/empty, the zero distortion coefficients are
+ * assumed.
+ * @param rvecs Vector of output rotation vectors (see REF: Rodrigues ) that, together with tvecs, brings points from
+ * the model coordinate system to the camera coordinate system.
+ * @param tvecs Vector of output translation vectors.
+ * the provided rvec and tvec values as initial approximations of the rotation and translation
+ * vectors, respectively, and further optimizes them.
+ * and useExtrinsicGuess is set to true.
+ * and useExtrinsicGuess is set to true.
+ * (\( \text{RMSE} = \sqrt{\frac{\sum_{i}^{N} \left ( \hat{y_i} - y_i \right )^2}{N}} \)) between the input image points
+ * and the 3D object points projected with the estimated pose.
+ *
+ * More information is described in REF: calib3d_solvePnP
+ *
+ * Note:
+ *
+ *
+ * An example of how to use solvePnP for planar augmented reality can be found at
+ * opencv_source_code/samples/python/plane_ar.py
+ *
+ *
+ * If you are using Python:
+ *
+ *
+ * Numpy array slices won't work as input because solvePnP requires contiguous
+ * arrays (enforced by the assertion using cv::Mat::checkVector() around line 55 of
+ * modules/calib3d/src/solvepnp.cpp version 2.4.9)
+ *
+ *
+ * The P3P algorithm requires image points to be in an array of shape (N,1,2) due
+ * to its calling of #undistortPoints (around line 75 of modules/calib3d/src/solvepnp.cpp version 2.4.9)
+ * which requires 2-channel information.
+ *
+ *
+ * Thus, given some data D = np.array(...) where D.shape = (N,M), in order to use a subset of
+ * it as, e.g., imagePoints, one must effectively copy it into a new array: imagePoints =
+ * np.ascontiguousarray(D[:,:2]).reshape((N,1,2))
+ *
+ *
+ *
+ * The methods REF: SOLVEPNP_DLS and REF: SOLVEPNP_UPNP cannot be used as the current implementations are
+ * unstable and sometimes give completely wrong results. If you pass one of these two
+ * flags, REF: SOLVEPNP_EPNP method will be used instead.
+ *
+ *
+ * The minimum number of points is 4 in the general case. In the case of REF: SOLVEPNP_P3P and REF: SOLVEPNP_AP3P
+ * methods, it is required to use exactly 4 points (the first 3 points are used to estimate all the solutions
+ * of the P3P problem, the last one is used to retain the best solution that minimizes the reprojection error).
+ *
+ *
+ * With REF: SOLVEPNP_ITERATIVE method and {@code useExtrinsicGuess=true}, the minimum number of points is 3 (3 points
+ * are sufficient to compute a pose but there are up to 4 solutions). The initial solution should be close to the
+ * global solution to converge.
+ *
+ *
+ * With REF: SOLVEPNP_IPPE input points must be >= 4 and object points must be coplanar.
+ *
+ *
+ * With REF: SOLVEPNP_IPPE_SQUARE this is a special case suitable for marker pose estimation.
+ * Number of input points must be 4. Object points must be defined in the following order:
+ *
+ * @return automatically generated
+ */
+ public static int solvePnPGeneric(Mat objectPoints, Mat imagePoints, Mat cameraMatrix, Mat distCoeffs, List rvecs, List tvecs) {
+ Mat rvecs_mat = new Mat();
+ Mat tvecs_mat = new Mat();
+ int retVal = solvePnPGeneric_5(objectPoints.nativeObj, imagePoints.nativeObj, cameraMatrix.nativeObj, distCoeffs.nativeObj, rvecs_mat.nativeObj, tvecs_mat.nativeObj);
+ Converters.Mat_to_vector_Mat(rvecs_mat, rvecs);
+ rvecs_mat.release();
+ Converters.Mat_to_vector_Mat(tvecs_mat, tvecs);
+ tvecs_mat.release();
+ return retVal;
+ }
+
+
+ //
+ // C++: Mat cv::initCameraMatrix2D(vector_vector_Point3f objectPoints, vector_vector_Point2f imagePoints, Size imageSize, double aspectRatio = 1.0)
+ //
+
+ /**
+ * Finds an initial camera intrinsic matrix from 3D-2D point correspondences.
+ *
+ * @param objectPoints Vector of vectors of the calibration pattern points in the calibration pattern
+ * coordinate space. In the old interface all the per-view vectors are concatenated. See
+ * #calibrateCamera for details.
+ * @param imagePoints Vector of vectors of the projections of the calibration pattern points. In the
+ * old interface all the per-view vectors are concatenated.
+ * @param imageSize Image size in pixels used to initialize the principal point.
+ * @param aspectRatio If it is zero or negative, both \(f_x\) and \(f_y\) are estimated independently.
+ * Otherwise, \(f_x = f_y \cdot \texttt{aspectRatio}\) .
+ *
+ * The function estimates and returns an initial camera intrinsic matrix for the camera calibration process.
+ * Currently, the function only supports planar calibration patterns, which are patterns where each
+ * object point has z-coordinate =0.
+ * @return automatically generated
+ */
+ public static Mat initCameraMatrix2D(List objectPoints, List imagePoints, Size imageSize, double aspectRatio) {
+ List objectPoints_tmplm = new ArrayList((objectPoints != null) ? objectPoints.size() : 0);
+ Mat objectPoints_mat = Converters.vector_vector_Point3f_to_Mat(objectPoints, objectPoints_tmplm);
+ List imagePoints_tmplm = new ArrayList((imagePoints != null) ? imagePoints.size() : 0);
+ Mat imagePoints_mat = Converters.vector_vector_Point2f_to_Mat(imagePoints, imagePoints_tmplm);
+ return new Mat(initCameraMatrix2D_0(objectPoints_mat.nativeObj, imagePoints_mat.nativeObj, imageSize.width, imageSize.height, aspectRatio));
+ }
+
+ /**
+ * Finds an initial camera intrinsic matrix from 3D-2D point correspondences.
+ *
+ * @param objectPoints Vector of vectors of the calibration pattern points in the calibration pattern
+ * coordinate space. In the old interface all the per-view vectors are concatenated. See
+ * #calibrateCamera for details.
+ * @param imagePoints Vector of vectors of the projections of the calibration pattern points. In the
+ * old interface all the per-view vectors are concatenated.
+ * @param imageSize Image size in pixels used to initialize the principal point.
+ * Otherwise, \(f_x = f_y \cdot \texttt{aspectRatio}\) .
+ *
+ * The function estimates and returns an initial camera intrinsic matrix for the camera calibration process.
+ * Currently, the function only supports planar calibration patterns, which are patterns where each
+ * object point has z-coordinate =0.
+ * @return automatically generated
+ */
+ public static Mat initCameraMatrix2D(List objectPoints, List imagePoints, Size imageSize) {
+ List objectPoints_tmplm = new ArrayList((objectPoints != null) ? objectPoints.size() : 0);
+ Mat objectPoints_mat = Converters.vector_vector_Point3f_to_Mat(objectPoints, objectPoints_tmplm);
+ List imagePoints_tmplm = new ArrayList((imagePoints != null) ? imagePoints.size() : 0);
+ Mat imagePoints_mat = Converters.vector_vector_Point2f_to_Mat(imagePoints, imagePoints_tmplm);
+ return new Mat(initCameraMatrix2D_1(objectPoints_mat.nativeObj, imagePoints_mat.nativeObj, imageSize.width, imageSize.height));
+ }
+
+
+ //
+ // C++: bool cv::findChessboardCorners(Mat image, Size patternSize, vector_Point2f& corners, int flags = CALIB_CB_ADAPTIVE_THRESH + CALIB_CB_NORMALIZE_IMAGE)
+ //
+
+ /**
+ * Finds the positions of internal corners of the chessboard.
+ *
+ * @param image Source chessboard view. It must be an 8-bit grayscale or color image.
+ * @param patternSize Number of inner corners per a chessboard row and column
+ * ( patternSize = cv::Size(points_per_row,points_per_colum) = cv::Size(columns,rows) ).
+ * @param corners Output array of detected corners.
+ * @param flags Various operation flags that can be zero or a combination of the following values:
+ *
+ *
+ * REF: CALIB_CB_ADAPTIVE_THRESH Use adaptive thresholding to convert the image to black
+ * and white, rather than a fixed threshold level (computed from the average image brightness).
+ *
+ *
+ * REF: CALIB_CB_NORMALIZE_IMAGE Normalize the image gamma with #equalizeHist before
+ * applying fixed or adaptive thresholding.
+ *
+ *
+ * REF: CALIB_CB_FILTER_QUADS Use additional criteria (like contour area, perimeter,
+ * square-like shape) to filter out false quads extracted at the contour retrieval stage.
+ *
+ *
+ * REF: CALIB_CB_FAST_CHECK Run a fast check on the image that looks for chessboard corners,
+ * and shortcut the call if none is found. This can drastically speed up the call in the
+ * degenerate condition when no chessboard is observed.
+ *
+ *
+ *
+ * The function attempts to determine whether the input image is a view of the chessboard pattern and
+ * locate the internal chessboard corners. The function returns a non-zero value if all of the corners
+ * are found and they are placed in a certain order (row by row, left to right in every row).
+ * Otherwise, if the function fails to find all the corners or reorder them, it returns 0. For example,
+ * a regular chessboard has 8 x 8 squares and 7 x 7 internal corners, that is, points where the black
+ * squares touch each other. The detected coordinates are approximate, and to determine their positions
+ * more accurately, the function calls #cornerSubPix. You also may use the function #cornerSubPix with
+ * different parameters if returned coordinates are not accurate enough.
+ *
+ * Sample usage of detecting and drawing chessboard corners: :
+ *
+ * Size patternsize(8,6); //interior number of corners
+ * Mat gray = ....; //source image
+ * vector<Point2f> corners; //this will be filled by the detected corners
+ *
+ * //CALIB_CB_FAST_CHECK saves a lot of time on images
+ * //that do not contain any chessboard corners
+ * bool patternfound = findChessboardCorners(gray, patternsize, corners,
+ * CALIB_CB_ADAPTIVE_THRESH + CALIB_CB_NORMALIZE_IMAGE
+ * + CALIB_CB_FAST_CHECK);
+ *
+ * if(patternfound)
+ * cornerSubPix(gray, corners, Size(11, 11), Size(-1, -1),
+ * TermCriteria(CV_TERMCRIT_EPS + CV_TERMCRIT_ITER, 30, 0.1));
+ *
+ * drawChessboardCorners(img, patternsize, Mat(corners), patternfound);
+ *
+ * Note: The function requires white space (like a square-thick border, the wider the better) around
+ * the board to make the detection more robust in various environments. Otherwise, if there is no
+ * border and the background is dark, the outer black squares cannot be segmented properly and so the
+ * square grouping and ordering algorithm fails.
+ *
+ * Use gen_pattern.py (REF: tutorial_camera_calibration_pattern) to create checkerboard.
+ * @return automatically generated
+ */
+ public static boolean findChessboardCorners(Mat image, Size patternSize, MatOfPoint2f corners, int flags) {
+ Mat corners_mat = corners;
+ return findChessboardCorners_0(image.nativeObj, patternSize.width, patternSize.height, corners_mat.nativeObj, flags);
+ }
+
+ /**
+ * Finds the positions of internal corners of the chessboard.
+ *
+ * @param image Source chessboard view. It must be an 8-bit grayscale or color image.
+ * @param patternSize Number of inner corners per a chessboard row and column
+ * ( patternSize = cv::Size(points_per_row,points_per_colum) = cv::Size(columns,rows) ).
+ * @param corners Output array of detected corners.
+ *
+ *
+ * REF: CALIB_CB_ADAPTIVE_THRESH Use adaptive thresholding to convert the image to black
+ * and white, rather than a fixed threshold level (computed from the average image brightness).
+ *
+ *
+ * REF: CALIB_CB_NORMALIZE_IMAGE Normalize the image gamma with #equalizeHist before
+ * applying fixed or adaptive thresholding.
+ *
+ *
+ * REF: CALIB_CB_FILTER_QUADS Use additional criteria (like contour area, perimeter,
+ * square-like shape) to filter out false quads extracted at the contour retrieval stage.
+ *
+ *
+ * REF: CALIB_CB_FAST_CHECK Run a fast check on the image that looks for chessboard corners,
+ * and shortcut the call if none is found. This can drastically speed up the call in the
+ * degenerate condition when no chessboard is observed.
+ *
+ *
+ *
+ * The function attempts to determine whether the input image is a view of the chessboard pattern and
+ * locate the internal chessboard corners. The function returns a non-zero value if all of the corners
+ * are found and they are placed in a certain order (row by row, left to right in every row).
+ * Otherwise, if the function fails to find all the corners or reorder them, it returns 0. For example,
+ * a regular chessboard has 8 x 8 squares and 7 x 7 internal corners, that is, points where the black
+ * squares touch each other. The detected coordinates are approximate, and to determine their positions
+ * more accurately, the function calls #cornerSubPix. You also may use the function #cornerSubPix with
+ * different parameters if returned coordinates are not accurate enough.
+ *
+ * Sample usage of detecting and drawing chessboard corners: :
+ *
+ * Size patternsize(8,6); //interior number of corners
+ * Mat gray = ....; //source image
+ * vector<Point2f> corners; //this will be filled by the detected corners
+ *
+ * //CALIB_CB_FAST_CHECK saves a lot of time on images
+ * //that do not contain any chessboard corners
+ * bool patternfound = findChessboardCorners(gray, patternsize, corners,
+ * CALIB_CB_ADAPTIVE_THRESH + CALIB_CB_NORMALIZE_IMAGE
+ * + CALIB_CB_FAST_CHECK);
+ *
+ * if(patternfound)
+ * cornerSubPix(gray, corners, Size(11, 11), Size(-1, -1),
+ * TermCriteria(CV_TERMCRIT_EPS + CV_TERMCRIT_ITER, 30, 0.1));
+ *
+ * drawChessboardCorners(img, patternsize, Mat(corners), patternfound);
+ *
+ * Note: The function requires white space (like a square-thick border, the wider the better) around
+ * the board to make the detection more robust in various environments. Otherwise, if there is no
+ * border and the background is dark, the outer black squares cannot be segmented properly and so the
+ * square grouping and ordering algorithm fails.
+ *
+ * Use gen_pattern.py (REF: tutorial_camera_calibration_pattern) to create checkerboard.
+ * @return automatically generated
+ */
+ public static boolean findChessboardCorners(Mat image, Size patternSize, MatOfPoint2f corners) {
+ Mat corners_mat = corners;
+ return findChessboardCorners_1(image.nativeObj, patternSize.width, patternSize.height, corners_mat.nativeObj);
+ }
+
+
+ //
+ // C++: bool cv::checkChessboard(Mat img, Size size)
+ //
+
+ public static boolean checkChessboard(Mat img, Size size) {
+ return checkChessboard_0(img.nativeObj, size.width, size.height);
+ }
+
+
+ //
+ // C++: bool cv::findChessboardCornersSB(Mat image, Size patternSize, Mat& corners, int flags, Mat& meta)
+ //
+
+ /**
+ * Finds the positions of internal corners of the chessboard using a sector based approach.
+ *
+ * @param image Source chessboard view. It must be an 8-bit grayscale or color image.
+ * @param patternSize Number of inner corners per a chessboard row and column
+ * ( patternSize = cv::Size(points_per_row,points_per_colum) = cv::Size(columns,rows) ).
+ * @param corners Output array of detected corners.
+ * @param flags Various operation flags that can be zero or a combination of the following values:
+ *
+ *
+ * REF: CALIB_CB_NORMALIZE_IMAGE Normalize the image gamma with equalizeHist before detection.
+ *
+ *
+ * REF: CALIB_CB_EXHAUSTIVE Run an exhaustive search to improve detection rate.
+ *
+ *
+ * REF: CALIB_CB_ACCURACY Up sample input image to improve sub-pixel accuracy due to aliasing effects.
+ *
+ *
+ * REF: CALIB_CB_LARGER The detected pattern is allowed to be larger than patternSize (see description).
+ *
+ *
+ * REF: CALIB_CB_MARKER The detected pattern must have a marker (see description).
+ * This should be used if an accurate camera calibration is required.
+ *
+ *
+ * @param meta Optional output arrray of detected corners (CV_8UC1 and size = cv::Size(columns,rows)).
+ * Each entry stands for one corner of the pattern and can have one of the following values:
+ *
+ *
+ * 0 = no meta data attached
+ *
+ *
+ * 1 = left-top corner of a black cell
+ *
+ *
+ * 2 = left-top corner of a white cell
+ *
+ *
+ * 3 = left-top corner of a black cell with a white marker dot
+ *
+ *
+ * 4 = left-top corner of a white cell with a black marker dot (pattern origin in case of markers otherwise first corner)
+ *
+ *
+ *
+ * The function is analog to #findChessboardCorners but uses a localized radon
+ * transformation approximated by box filters being more robust to all sort of
+ * noise, faster on larger images and is able to directly return the sub-pixel
+ * position of the internal chessboard corners. The Method is based on the paper
+ * CITE: duda2018 "Accurate Detection and Localization of Checkerboard Corners for
+ * Calibration" demonstrating that the returned sub-pixel positions are more
+ * accurate than the one returned by cornerSubPix allowing a precise camera
+ * calibration for demanding applications.
+ *
+ * In the case, the flags REF: CALIB_CB_LARGER or REF: CALIB_CB_MARKER are given,
+ * the result can be recovered from the optional meta array. Both flags are
+ * helpful to use calibration patterns exceeding the field of view of the camera.
+ * These oversized patterns allow more accurate calibrations as corners can be
+ * utilized, which are as close as possible to the image borders. For a
+ * consistent coordinate system across all images, the optional marker (see image
+ * below) can be used to move the origin of the board to the location where the
+ * black circle is located.
+ *
+ * Note: The function requires a white boarder with roughly the same width as one
+ * of the checkerboard fields around the whole board to improve the detection in
+ * various environments. In addition, because of the localized radon
+ * transformation it is beneficial to use round corners for the field corners
+ * which are located on the outside of the board. The following figure illustrates
+ * a sample checkerboard optimized for the detection. However, any other checkerboard
+ * can be used as well.
+ *
+ * Use gen_pattern.py (REF: tutorial_camera_calibration_pattern) to create checkerboard.
+ * 
+ * @return automatically generated
+ */
+ public static boolean findChessboardCornersSBWithMeta(Mat image, Size patternSize, Mat corners, int flags, Mat meta) {
+ return findChessboardCornersSBWithMeta_0(image.nativeObj, patternSize.width, patternSize.height, corners.nativeObj, flags, meta.nativeObj);
+ }
+
+
+ //
+ // C++: bool cv::findChessboardCornersSB(Mat image, Size patternSize, Mat& corners, int flags = 0)
+ //
+
+ public static boolean findChessboardCornersSB(Mat image, Size patternSize, Mat corners, int flags) {
+ return findChessboardCornersSB_0(image.nativeObj, patternSize.width, patternSize.height, corners.nativeObj, flags);
+ }
+
+ public static boolean findChessboardCornersSB(Mat image, Size patternSize, Mat corners) {
+ return findChessboardCornersSB_1(image.nativeObj, patternSize.width, patternSize.height, corners.nativeObj);
+ }
+
+
+ //
+ // C++: Scalar cv::estimateChessboardSharpness(Mat image, Size patternSize, Mat corners, float rise_distance = 0.8F, bool vertical = false, Mat& sharpness = Mat())
+ //
+
+ /**
+ * Estimates the sharpness of a detected chessboard.
+ *
+ * Image sharpness, as well as brightness, are a critical parameter for accuracte
+ * camera calibration. For accessing these parameters for filtering out
+ * problematic calibraiton images, this method calculates edge profiles by traveling from
+ * black to white chessboard cell centers. Based on this, the number of pixels is
+ * calculated required to transit from black to white. This width of the
+ * transition area is a good indication of how sharp the chessboard is imaged
+ * and should be below ~3.0 pixels.
+ *
+ * @param image Gray image used to find chessboard corners
+ * @param patternSize Size of a found chessboard pattern
+ * @param corners Corners found by #findChessboardCornersSB
+ * @param rise_distance Rise distance 0.8 means 10% ... 90% of the final signal strength
+ * @param vertical By default edge responses for horizontal lines are calculated
+ * @param sharpness Optional output array with a sharpness value for calculated edge responses (see description)
+ *
+ * The optional sharpness array is of type CV_32FC1 and has for each calculated
+ * profile one row with the following five entries:
+ * 0 = x coordinate of the underlying edge in the image
+ * 1 = y coordinate of the underlying edge in the image
+ * 2 = width of the transition area (sharpness)
+ * 3 = signal strength in the black cell (min brightness)
+ * 4 = signal strength in the white cell (max brightness)
+ *
+ * @return Scalar(average sharpness, average min brightness, average max brightness,0)
+ */
+ public static Scalar estimateChessboardSharpness(Mat image, Size patternSize, Mat corners, float rise_distance, boolean vertical, Mat sharpness) {
+ return new Scalar(estimateChessboardSharpness_0(image.nativeObj, patternSize.width, patternSize.height, corners.nativeObj, rise_distance, vertical, sharpness.nativeObj));
+ }
+
+ /**
+ * Estimates the sharpness of a detected chessboard.
+ *
+ * Image sharpness, as well as brightness, are a critical parameter for accuracte
+ * camera calibration. For accessing these parameters for filtering out
+ * problematic calibraiton images, this method calculates edge profiles by traveling from
+ * black to white chessboard cell centers. Based on this, the number of pixels is
+ * calculated required to transit from black to white. This width of the
+ * transition area is a good indication of how sharp the chessboard is imaged
+ * and should be below ~3.0 pixels.
+ *
+ * @param image Gray image used to find chessboard corners
+ * @param patternSize Size of a found chessboard pattern
+ * @param corners Corners found by #findChessboardCornersSB
+ * @param rise_distance Rise distance 0.8 means 10% ... 90% of the final signal strength
+ * @param vertical By default edge responses for horizontal lines are calculated
+ *
+ * The optional sharpness array is of type CV_32FC1 and has for each calculated
+ * profile one row with the following five entries:
+ * 0 = x coordinate of the underlying edge in the image
+ * 1 = y coordinate of the underlying edge in the image
+ * 2 = width of the transition area (sharpness)
+ * 3 = signal strength in the black cell (min brightness)
+ * 4 = signal strength in the white cell (max brightness)
+ *
+ * @return Scalar(average sharpness, average min brightness, average max brightness,0)
+ */
+ public static Scalar estimateChessboardSharpness(Mat image, Size patternSize, Mat corners, float rise_distance, boolean vertical) {
+ return new Scalar(estimateChessboardSharpness_1(image.nativeObj, patternSize.width, patternSize.height, corners.nativeObj, rise_distance, vertical));
+ }
+
+ /**
+ * Estimates the sharpness of a detected chessboard.
+ *
+ * Image sharpness, as well as brightness, are a critical parameter for accuracte
+ * camera calibration. For accessing these parameters for filtering out
+ * problematic calibraiton images, this method calculates edge profiles by traveling from
+ * black to white chessboard cell centers. Based on this, the number of pixels is
+ * calculated required to transit from black to white. This width of the
+ * transition area is a good indication of how sharp the chessboard is imaged
+ * and should be below ~3.0 pixels.
+ *
+ * @param image Gray image used to find chessboard corners
+ * @param patternSize Size of a found chessboard pattern
+ * @param corners Corners found by #findChessboardCornersSB
+ * @param rise_distance Rise distance 0.8 means 10% ... 90% of the final signal strength
+ *
+ * The optional sharpness array is of type CV_32FC1 and has for each calculated
+ * profile one row with the following five entries:
+ * 0 = x coordinate of the underlying edge in the image
+ * 1 = y coordinate of the underlying edge in the image
+ * 2 = width of the transition area (sharpness)
+ * 3 = signal strength in the black cell (min brightness)
+ * 4 = signal strength in the white cell (max brightness)
+ *
+ * @return Scalar(average sharpness, average min brightness, average max brightness,0)
+ */
+ public static Scalar estimateChessboardSharpness(Mat image, Size patternSize, Mat corners, float rise_distance) {
+ return new Scalar(estimateChessboardSharpness_2(image.nativeObj, patternSize.width, patternSize.height, corners.nativeObj, rise_distance));
+ }
+
+ /**
+ * Estimates the sharpness of a detected chessboard.
+ *
+ * Image sharpness, as well as brightness, are a critical parameter for accuracte
+ * camera calibration. For accessing these parameters for filtering out
+ * problematic calibraiton images, this method calculates edge profiles by traveling from
+ * black to white chessboard cell centers. Based on this, the number of pixels is
+ * calculated required to transit from black to white. This width of the
+ * transition area is a good indication of how sharp the chessboard is imaged
+ * and should be below ~3.0 pixels.
+ *
+ * @param image Gray image used to find chessboard corners
+ * @param patternSize Size of a found chessboard pattern
+ * @param corners Corners found by #findChessboardCornersSB
+ *
+ * The optional sharpness array is of type CV_32FC1 and has for each calculated
+ * profile one row with the following five entries:
+ * 0 = x coordinate of the underlying edge in the image
+ * 1 = y coordinate of the underlying edge in the image
+ * 2 = width of the transition area (sharpness)
+ * 3 = signal strength in the black cell (min brightness)
+ * 4 = signal strength in the white cell (max brightness)
+ *
+ * @return Scalar(average sharpness, average min brightness, average max brightness,0)
+ */
+ public static Scalar estimateChessboardSharpness(Mat image, Size patternSize, Mat corners) {
+ return new Scalar(estimateChessboardSharpness_3(image.nativeObj, patternSize.width, patternSize.height, corners.nativeObj));
+ }
+
+
+ //
+ // C++: bool cv::find4QuadCornerSubpix(Mat img, Mat& corners, Size region_size)
+ //
+
+ public static boolean find4QuadCornerSubpix(Mat img, Mat corners, Size region_size) {
+ return find4QuadCornerSubpix_0(img.nativeObj, corners.nativeObj, region_size.width, region_size.height);
+ }
+
+
+ //
+ // C++: void cv::drawChessboardCorners(Mat& image, Size patternSize, vector_Point2f corners, bool patternWasFound)
+ //
+
+ /**
+ * Renders the detected chessboard corners.
+ *
+ * @param image Destination image. It must be an 8-bit color image.
+ * @param patternSize Number of inner corners per a chessboard row and column
+ * (patternSize = cv::Size(points_per_row,points_per_column)).
+ * @param corners Array of detected corners, the output of #findChessboardCorners.
+ * @param patternWasFound Parameter indicating whether the complete board was found or not. The
+ * return value of #findChessboardCorners should be passed here.
+ *
+ * The function draws individual chessboard corners detected either as red circles if the board was not
+ * found, or as colored corners connected with lines if the board was found.
+ */
+ public static void drawChessboardCorners(Mat image, Size patternSize, MatOfPoint2f corners, boolean patternWasFound) {
+ Mat corners_mat = corners;
+ drawChessboardCorners_0(image.nativeObj, patternSize.width, patternSize.height, corners_mat.nativeObj, patternWasFound);
+ }
+
+
+ //
+ // C++: void cv::drawFrameAxes(Mat& image, Mat cameraMatrix, Mat distCoeffs, Mat rvec, Mat tvec, float length, int thickness = 3)
+ //
+
+ /**
+ * Draw axes of the world/object coordinate system from pose estimation. SEE: solvePnP
+ *
+ * @param image Input/output image. It must have 1 or 3 channels. The number of channels is not altered.
+ * @param cameraMatrix Input 3x3 floating-point matrix of camera intrinsic parameters.
+ * \(\cameramatrix{A}\)
+ * @param distCoeffs Input vector of distortion coefficients
+ * \(\distcoeffs\). If the vector is empty, the zero distortion coefficients are assumed.
+ * @param rvec Rotation vector (see REF: Rodrigues ) that, together with tvec, brings points from
+ * the model coordinate system to the camera coordinate system.
+ * @param tvec Translation vector.
+ * @param length Length of the painted axes in the same unit than tvec (usually in meters).
+ * @param thickness Line thickness of the painted axes.
+ *
+ * This function draws the axes of the world/object coordinate system w.r.t. to the camera frame.
+ * OX is drawn in red, OY in green and OZ in blue.
+ */
+ public static void drawFrameAxes(Mat image, Mat cameraMatrix, Mat distCoeffs, Mat rvec, Mat tvec, float length, int thickness) {
+ drawFrameAxes_0(image.nativeObj, cameraMatrix.nativeObj, distCoeffs.nativeObj, rvec.nativeObj, tvec.nativeObj, length, thickness);
+ }
+
+ /**
+ * Draw axes of the world/object coordinate system from pose estimation. SEE: solvePnP
+ *
+ * @param image Input/output image. It must have 1 or 3 channels. The number of channels is not altered.
+ * @param cameraMatrix Input 3x3 floating-point matrix of camera intrinsic parameters.
+ * \(\cameramatrix{A}\)
+ * @param distCoeffs Input vector of distortion coefficients
+ * \(\distcoeffs\). If the vector is empty, the zero distortion coefficients are assumed.
+ * @param rvec Rotation vector (see REF: Rodrigues ) that, together with tvec, brings points from
+ * the model coordinate system to the camera coordinate system.
+ * @param tvec Translation vector.
+ * @param length Length of the painted axes in the same unit than tvec (usually in meters).
+ *
+ * This function draws the axes of the world/object coordinate system w.r.t. to the camera frame.
+ * OX is drawn in red, OY in green and OZ in blue.
+ */
+ public static void drawFrameAxes(Mat image, Mat cameraMatrix, Mat distCoeffs, Mat rvec, Mat tvec, float length) {
+ drawFrameAxes_1(image.nativeObj, cameraMatrix.nativeObj, distCoeffs.nativeObj, rvec.nativeObj, tvec.nativeObj, length);
+ }
+
+
+ //
+ // C++: bool cv::findCirclesGrid(Mat image, Size patternSize, Mat& centers, int flags, Ptr_FeatureDetector blobDetector, CirclesGridFinderParameters parameters)
+ //
+
+ // Unknown type 'Ptr_FeatureDetector' (I), skipping the function
+
+
+ //
+ // C++: bool cv::findCirclesGrid(Mat image, Size patternSize, Mat& centers, int flags = CALIB_CB_SYMMETRIC_GRID, Ptr_FeatureDetector blobDetector = SimpleBlobDetector::create())
+ //
+
+ public static boolean findCirclesGrid(Mat image, Size patternSize, Mat centers, int flags) {
+ return findCirclesGrid_0(image.nativeObj, patternSize.width, patternSize.height, centers.nativeObj, flags);
+ }
+
+ public static boolean findCirclesGrid(Mat image, Size patternSize, Mat centers) {
+ return findCirclesGrid_2(image.nativeObj, patternSize.width, patternSize.height, centers.nativeObj);
+ }
+
+
+ //
+ // C++: double cv::calibrateCamera(vector_Mat objectPoints, vector_Mat imagePoints, Size imageSize, Mat& cameraMatrix, Mat& distCoeffs, vector_Mat& rvecs, vector_Mat& tvecs, Mat& stdDeviationsIntrinsics, Mat& stdDeviationsExtrinsics, Mat& perViewErrors, int flags = 0, TermCriteria criteria = TermCriteria( TermCriteria::COUNT + TermCriteria::EPS, 30, DBL_EPSILON))
+ //
+
+ /**
+ * Finds the camera intrinsic and extrinsic parameters from several views of a calibration
+ * pattern.
+ *
+ * @param objectPoints In the new interface it is a vector of vectors of calibration pattern points in
+ * the calibration pattern coordinate space (e.g. std::vector<std::vector<cv::Vec3f>>). The outer
+ * vector contains as many elements as the number of pattern views. If the same calibration pattern
+ * is shown in each view and it is fully visible, all the vectors will be the same. Although, it is
+ * possible to use partially occluded patterns or even different patterns in different views. Then,
+ * the vectors will be different. Although the points are 3D, they all lie in the calibration pattern's
+ * XY coordinate plane (thus 0 in the Z-coordinate), if the used calibration pattern is a planar rig.
+ * In the old interface all the vectors of object points from different views are concatenated
+ * together.
+ * @param imagePoints In the new interface it is a vector of vectors of the projections of calibration
+ * pattern points (e.g. std::vector<std::vector<cv::Vec2f>>). imagePoints.size() and
+ * objectPoints.size(), and imagePoints[i].size() and objectPoints[i].size() for each i, must be equal,
+ * respectively. In the old interface all the vectors of object points from different views are
+ * concatenated together.
+ * @param imageSize Size of the image used only to initialize the camera intrinsic matrix.
+ * @param cameraMatrix Input/output 3x3 floating-point camera intrinsic matrix
+ * \(\cameramatrix{A}\) . 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.
+ * @param distCoeffs Input/output vector of distortion coefficients
+ * \(\distcoeffs\).
+ * @param rvecs Output vector of rotation vectors (REF: Rodrigues ) estimated for each pattern view
+ * (e.g. std::vector<cv::Mat>>). That is, each i-th rotation vector together with the corresponding
+ * i-th translation vector (see the next output parameter description) brings the calibration pattern
+ * from the object coordinate space (in which object points are specified) to the camera coordinate
+ * space. In more technical terms, the tuple of the i-th rotation and translation vector performs
+ * a change of basis from object coordinate space to camera coordinate space. Due to its duality, this
+ * tuple is equivalent to the position of the calibration pattern with respect to the camera coordinate
+ * space.
+ * @param tvecs Output vector of translation vectors estimated for each pattern view, see parameter
+ * describtion above.
+ * @param stdDeviationsIntrinsics Output vector of standard deviations estimated for intrinsic
+ * parameters. Order of deviations values:
+ * \((f_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)\) 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: \((R_0, T_0, \dotsc , R_{M - 1}, T_{M - 1})\) where M is
+ * the number of pattern views. \(R_i, T_i\) are concatenated 1x3 vectors.
+ * @param perViewErrors Output vector of the RMS re-projection error estimated for each pattern view.
+ * @param flags Different flags that may be zero or a combination of the following values:
+ *
+ *
+ * REF: CALIB_USE_INTRINSIC_GUESS cameraMatrix contains valid initial values of
+ * fx, fy, cx, cy that are optimized further. Otherwise, (cx, cy) is initially set to the image
+ * center ( imageSize is used), and focal distances are computed in a least-squares fashion.
+ * Note, that if intrinsic parameters are known, there is no need to use this function just to
+ * estimate extrinsic parameters. Use REF: 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.
+ *
+ *
+ * REF: CALIB_FIX_ASPECT_RATIO The functions consider only fy as a free parameter. The
+ * ratio fx/fy stays the same as in the input cameraMatrix . When
+ * REF: CALIB_USE_INTRINSIC_GUESS is not set, the actual input values of fx and fy are
+ * ignored, only their ratio is computed and used further.
+ *
+ *
+ * REF: CALIB_ZERO_TANGENT_DIST Tangential distortion coefficients \((p_1, p_2)\) 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.
+ *
+ *
+ * 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.
+ *
+ *
+ * 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.
+ *
+ *
+ * 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.
+ *
+ *
+ * @param criteria Termination criteria for the iterative optimization algorithm.
+ *
+ * @return the overall RMS re-projection error.
+ *
+ * The function estimates the intrinsic camera parameters and extrinsic parameters for each of the
+ * views. The algorithm is based on CITE: Zhang2000 and CITE: BouguetMCT . The coordinates of 3D object
+ * points and their corresponding 2D projections in each view must be specified. That may be achieved
+ * by using an object with known geometry and easily detectable feature points. Such an object is
+ * called a calibration rig or calibration pattern, and OpenCV has built-in support for a chessboard as
+ * a calibration rig (see REF: findChessboardCorners). Currently, initialization of intrinsic
+ * parameters (when REF: CALIB_USE_INTRINSIC_GUESS is not set) is only implemented for planar calibration
+ * patterns (where Z-coordinates of the object points must be all zeros). 3D calibration rigs can also
+ * be used as long as initial cameraMatrix is provided.
+ *
+ * The algorithm performs the following steps:
+ *
+ *
+ *
+ * Compute the initial intrinsic parameters (the option only available for planar calibration
+ * patterns) or read them from the input parameters. The distortion coefficients are all set to
+ * zeros initially unless some of 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 .
+ *
+ *
+ *
+ *
+ *
+ * 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.
+ *
+ *
+ *
+ * Note:
+ * If you use a non-square (i.e. non-N-by-N) grid and REF: findChessboardCorners for calibration,
+ * and REF: calibrateCamera returns bad values (zero distortion coefficients, \(c_x\) and
+ * \(c_y\) very far from the image center, and/or large differences between \(f_x\) and
+ * \(f_y\) (ratios of 10:1 or more)), then you are probably using patternSize=cvSize(rows,cols)
+ * instead of using patternSize=cvSize(cols,rows) in REF: findChessboardCorners.
+ *
+ * SEE:
+ * calibrateCameraRO, findChessboardCorners, solvePnP, initCameraMatrix2D, stereoCalibrate,
+ * undistort
+ */
+ public static double calibrateCameraExtended(List objectPoints, List imagePoints, Size imageSize, Mat cameraMatrix, Mat distCoeffs, List rvecs, List tvecs, Mat stdDeviationsIntrinsics, Mat stdDeviationsExtrinsics, Mat perViewErrors, int flags, TermCriteria criteria) {
+ Mat objectPoints_mat = Converters.vector_Mat_to_Mat(objectPoints);
+ Mat imagePoints_mat = Converters.vector_Mat_to_Mat(imagePoints);
+ Mat rvecs_mat = new Mat();
+ Mat tvecs_mat = new Mat();
+ double retVal = calibrateCameraExtended_0(objectPoints_mat.nativeObj, imagePoints_mat.nativeObj, imageSize.width, imageSize.height, cameraMatrix.nativeObj, distCoeffs.nativeObj, rvecs_mat.nativeObj, tvecs_mat.nativeObj, stdDeviationsIntrinsics.nativeObj, stdDeviationsExtrinsics.nativeObj, perViewErrors.nativeObj, flags, criteria.type, criteria.maxCount, criteria.epsilon);
+ Converters.Mat_to_vector_Mat(rvecs_mat, rvecs);
+ rvecs_mat.release();
+ Converters.Mat_to_vector_Mat(tvecs_mat, tvecs);
+ tvecs_mat.release();
+ return retVal;
+ }
+
+ /**
+ * Finds the camera intrinsic and extrinsic parameters from several views of a calibration
+ * pattern.
+ *
+ * @param objectPoints In the new interface it is a vector of vectors of calibration pattern points in
+ * the calibration pattern coordinate space (e.g. std::vector<std::vector<cv::Vec3f>>). The outer
+ * vector contains as many elements as the number of pattern views. If the same calibration pattern
+ * is shown in each view and it is fully visible, all the vectors will be the same. Although, it is
+ * possible to use partially occluded patterns or even different patterns in different views. Then,
+ * the vectors will be different. Although the points are 3D, they all lie in the calibration pattern's
+ * XY coordinate plane (thus 0 in the Z-coordinate), if the used calibration pattern is a planar rig.
+ * In the old interface all the vectors of object points from different views are concatenated
+ * together.
+ * @param imagePoints In the new interface it is a vector of vectors of the projections of calibration
+ * pattern points (e.g. std::vector<std::vector<cv::Vec2f>>). imagePoints.size() and
+ * objectPoints.size(), and imagePoints[i].size() and objectPoints[i].size() for each i, must be equal,
+ * respectively. In the old interface all the vectors of object points from different views are
+ * concatenated together.
+ * @param imageSize Size of the image used only to initialize the camera intrinsic matrix.
+ * @param cameraMatrix Input/output 3x3 floating-point camera intrinsic matrix
+ * \(\cameramatrix{A}\) . 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.
+ * @param distCoeffs Input/output vector of distortion coefficients
+ * \(\distcoeffs\).
+ * @param rvecs Output vector of rotation vectors (REF: Rodrigues ) estimated for each pattern view
+ * (e.g. std::vector<cv::Mat>>). That is, each i-th rotation vector together with the corresponding
+ * i-th translation vector (see the next output parameter description) brings the calibration pattern
+ * from the object coordinate space (in which object points are specified) to the camera coordinate
+ * space. In more technical terms, the tuple of the i-th rotation and translation vector performs
+ * a change of basis from object coordinate space to camera coordinate space. Due to its duality, this
+ * tuple is equivalent to the position of the calibration pattern with respect to the camera coordinate
+ * space.
+ * @param tvecs Output vector of translation vectors estimated for each pattern view, see parameter
+ * describtion above.
+ * @param stdDeviationsIntrinsics Output vector of standard deviations estimated for intrinsic
+ * parameters. Order of deviations values:
+ * \((f_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)\) 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: \((R_0, T_0, \dotsc , R_{M - 1}, T_{M - 1})\) where M is
+ * the number of pattern views. \(R_i, T_i\) are concatenated 1x3 vectors.
+ * @param perViewErrors Output vector of the RMS re-projection error estimated for each pattern view.
+ * @param flags Different flags that may be zero or a combination of the following values:
+ *
+ *
+ * REF: CALIB_USE_INTRINSIC_GUESS cameraMatrix contains valid initial values of
+ * fx, fy, cx, cy that are optimized further. Otherwise, (cx, cy) is initially set to the image
+ * center ( imageSize is used), and focal distances are computed in a least-squares fashion.
+ * Note, that if intrinsic parameters are known, there is no need to use this function just to
+ * estimate extrinsic parameters. Use REF: 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.
+ *
+ *
+ * REF: CALIB_FIX_ASPECT_RATIO The functions consider only fy as a free parameter. The
+ * ratio fx/fy stays the same as in the input cameraMatrix . When
+ * REF: CALIB_USE_INTRINSIC_GUESS is not set, the actual input values of fx and fy are
+ * ignored, only their ratio is computed and used further.
+ *
+ *
+ * REF: CALIB_ZERO_TANGENT_DIST Tangential distortion coefficients \((p_1, p_2)\) 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.
+ *
+ *
+ * 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.
+ *
+ *
+ * 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.
+ *
+ *
+ * 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.
+ *
+ *
+ *
+ * @return the overall RMS re-projection error.
+ *
+ * The function estimates the intrinsic camera parameters and extrinsic parameters for each of the
+ * views. The algorithm is based on CITE: Zhang2000 and CITE: BouguetMCT . The coordinates of 3D object
+ * points and their corresponding 2D projections in each view must be specified. That may be achieved
+ * by using an object with known geometry and easily detectable feature points. Such an object is
+ * called a calibration rig or calibration pattern, and OpenCV has built-in support for a chessboard as
+ * a calibration rig (see REF: findChessboardCorners). Currently, initialization of intrinsic
+ * parameters (when REF: CALIB_USE_INTRINSIC_GUESS is not set) is only implemented for planar calibration
+ * patterns (where Z-coordinates of the object points must be all zeros). 3D calibration rigs can also
+ * be used as long as initial cameraMatrix is provided.
+ *
+ * The algorithm performs the following steps:
+ *
+ *
+ *
+ * Compute the initial intrinsic parameters (the option only available for planar calibration
+ * patterns) or read them from the input parameters. The distortion coefficients are all set to
+ * zeros initially unless some of 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 .
+ *
+ *
+ *
+ *
+ *
+ * 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.
+ *
+ *
+ *
+ * Note:
+ * If you use a non-square (i.e. non-N-by-N) grid and REF: findChessboardCorners for calibration,
+ * and REF: calibrateCamera returns bad values (zero distortion coefficients, \(c_x\) and
+ * \(c_y\) very far from the image center, and/or large differences between \(f_x\) and
+ * \(f_y\) (ratios of 10:1 or more)), then you are probably using patternSize=cvSize(rows,cols)
+ * instead of using patternSize=cvSize(cols,rows) in REF: findChessboardCorners.
+ *
+ * SEE:
+ * calibrateCameraRO, findChessboardCorners, solvePnP, initCameraMatrix2D, stereoCalibrate,
+ * undistort
+ */
+ public static double calibrateCameraExtended(List objectPoints, List imagePoints, Size imageSize, Mat cameraMatrix, Mat distCoeffs, List rvecs, List tvecs, Mat stdDeviationsIntrinsics, Mat stdDeviationsExtrinsics, Mat perViewErrors, int flags) {
+ Mat objectPoints_mat = Converters.vector_Mat_to_Mat(objectPoints);
+ Mat imagePoints_mat = Converters.vector_Mat_to_Mat(imagePoints);
+ Mat rvecs_mat = new Mat();
+ Mat tvecs_mat = new Mat();
+ double retVal = calibrateCameraExtended_1(objectPoints_mat.nativeObj, imagePoints_mat.nativeObj, imageSize.width, imageSize.height, cameraMatrix.nativeObj, distCoeffs.nativeObj, rvecs_mat.nativeObj, tvecs_mat.nativeObj, stdDeviationsIntrinsics.nativeObj, stdDeviationsExtrinsics.nativeObj, perViewErrors.nativeObj, flags);
+ Converters.Mat_to_vector_Mat(rvecs_mat, rvecs);
+ rvecs_mat.release();
+ Converters.Mat_to_vector_Mat(tvecs_mat, tvecs);
+ tvecs_mat.release();
+ return retVal;
+ }
+
+ /**
+ * Finds the camera intrinsic and extrinsic parameters from several views of a calibration
+ * pattern.
+ *
+ * @param objectPoints In the new interface it is a vector of vectors of calibration pattern points in
+ * the calibration pattern coordinate space (e.g. std::vector<std::vector<cv::Vec3f>>). The outer
+ * vector contains as many elements as the number of pattern views. If the same calibration pattern
+ * is shown in each view and it is fully visible, all the vectors will be the same. Although, it is
+ * possible to use partially occluded patterns or even different patterns in different views. Then,
+ * the vectors will be different. Although the points are 3D, they all lie in the calibration pattern's
+ * XY coordinate plane (thus 0 in the Z-coordinate), if the used calibration pattern is a planar rig.
+ * In the old interface all the vectors of object points from different views are concatenated
+ * together.
+ * @param imagePoints In the new interface it is a vector of vectors of the projections of calibration
+ * pattern points (e.g. std::vector<std::vector<cv::Vec2f>>). imagePoints.size() and
+ * objectPoints.size(), and imagePoints[i].size() and objectPoints[i].size() for each i, must be equal,
+ * respectively. In the old interface all the vectors of object points from different views are
+ * concatenated together.
+ * @param imageSize Size of the image used only to initialize the camera intrinsic matrix.
+ * @param cameraMatrix Input/output 3x3 floating-point camera intrinsic matrix
+ * \(\cameramatrix{A}\) . 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.
+ * @param distCoeffs Input/output vector of distortion coefficients
+ * \(\distcoeffs\).
+ * @param rvecs Output vector of rotation vectors (REF: Rodrigues ) estimated for each pattern view
+ * (e.g. std::vector<cv::Mat>>). That is, each i-th rotation vector together with the corresponding
+ * i-th translation vector (see the next output parameter description) brings the calibration pattern
+ * from the object coordinate space (in which object points are specified) to the camera coordinate
+ * space. In more technical terms, the tuple of the i-th rotation and translation vector performs
+ * a change of basis from object coordinate space to camera coordinate space. Due to its duality, this
+ * tuple is equivalent to the position of the calibration pattern with respect to the camera coordinate
+ * space.
+ * @param tvecs Output vector of translation vectors estimated for each pattern view, see parameter
+ * describtion above.
+ * @param stdDeviationsIntrinsics Output vector of standard deviations estimated for intrinsic
+ * parameters. Order of deviations values:
+ * \((f_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)\) 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: \((R_0, T_0, \dotsc , R_{M - 1}, T_{M - 1})\) where M is
+ * the number of pattern views. \(R_i, T_i\) are concatenated 1x3 vectors.
+ * @param perViewErrors Output vector of the RMS re-projection error estimated for each pattern view.
+ *
+ *
+ * REF: CALIB_USE_INTRINSIC_GUESS cameraMatrix contains valid initial values of
+ * fx, fy, cx, cy that are optimized further. Otherwise, (cx, cy) is initially set to the image
+ * center ( imageSize is used), and focal distances are computed in a least-squares fashion.
+ * Note, that if intrinsic parameters are known, there is no need to use this function just to
+ * estimate extrinsic parameters. Use REF: 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.
+ *
+ *
+ * REF: CALIB_FIX_ASPECT_RATIO The functions consider only fy as a free parameter. The
+ * ratio fx/fy stays the same as in the input cameraMatrix . When
+ * REF: CALIB_USE_INTRINSIC_GUESS is not set, the actual input values of fx and fy are
+ * ignored, only their ratio is computed and used further.
+ *
+ *
+ * REF: CALIB_ZERO_TANGENT_DIST Tangential distortion coefficients \((p_1, p_2)\) 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.
+ *
+ *
+ * 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.
+ *
+ *
+ * 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.
+ *
+ *
+ * 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.
+ *
+ *
+ *
+ * @return the overall RMS re-projection error.
+ *
+ * The function estimates the intrinsic camera parameters and extrinsic parameters for each of the
+ * views. The algorithm is based on CITE: Zhang2000 and CITE: BouguetMCT . The coordinates of 3D object
+ * points and their corresponding 2D projections in each view must be specified. That may be achieved
+ * by using an object with known geometry and easily detectable feature points. Such an object is
+ * called a calibration rig or calibration pattern, and OpenCV has built-in support for a chessboard as
+ * a calibration rig (see REF: findChessboardCorners). Currently, initialization of intrinsic
+ * parameters (when REF: CALIB_USE_INTRINSIC_GUESS is not set) is only implemented for planar calibration
+ * patterns (where Z-coordinates of the object points must be all zeros). 3D calibration rigs can also
+ * be used as long as initial cameraMatrix is provided.
+ *
+ * The algorithm performs the following steps:
+ *
+ *
+ *
+ * Compute the initial intrinsic parameters (the option only available for planar calibration
+ * patterns) or read them from the input parameters. The distortion coefficients are all set to
+ * zeros initially unless some of 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 .
+ *
+ *
+ *
+ *
+ *
+ * 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.
+ *
+ *
+ *
+ * Note:
+ * If you use a non-square (i.e. non-N-by-N) grid and REF: findChessboardCorners for calibration,
+ * and REF: calibrateCamera returns bad values (zero distortion coefficients, \(c_x\) and
+ * \(c_y\) very far from the image center, and/or large differences between \(f_x\) and
+ * \(f_y\) (ratios of 10:1 or more)), then you are probably using patternSize=cvSize(rows,cols)
+ * instead of using patternSize=cvSize(cols,rows) in REF: findChessboardCorners.
+ *
+ * SEE:
+ * calibrateCameraRO, findChessboardCorners, solvePnP, initCameraMatrix2D, stereoCalibrate,
+ * undistort
+ */
+ public static double calibrateCameraExtended(List objectPoints, List imagePoints, Size imageSize, Mat cameraMatrix, Mat distCoeffs, List rvecs, List tvecs, Mat stdDeviationsIntrinsics, Mat stdDeviationsExtrinsics, Mat perViewErrors) {
+ Mat objectPoints_mat = Converters.vector_Mat_to_Mat(objectPoints);
+ Mat imagePoints_mat = Converters.vector_Mat_to_Mat(imagePoints);
+ Mat rvecs_mat = new Mat();
+ Mat tvecs_mat = new Mat();
+ double retVal = calibrateCameraExtended_2(objectPoints_mat.nativeObj, imagePoints_mat.nativeObj, imageSize.width, imageSize.height, cameraMatrix.nativeObj, distCoeffs.nativeObj, rvecs_mat.nativeObj, tvecs_mat.nativeObj, stdDeviationsIntrinsics.nativeObj, stdDeviationsExtrinsics.nativeObj, perViewErrors.nativeObj);
+ Converters.Mat_to_vector_Mat(rvecs_mat, rvecs);
+ rvecs_mat.release();
+ Converters.Mat_to_vector_Mat(tvecs_mat, tvecs);
+ tvecs_mat.release();
+ return retVal;
+ }
+
+
+ //
+ // C++: double cv::calibrateCamera(vector_Mat objectPoints, vector_Mat imagePoints, Size imageSize, Mat& cameraMatrix, Mat& distCoeffs, vector_Mat& rvecs, vector_Mat& tvecs, int flags = 0, TermCriteria criteria = TermCriteria( TermCriteria::COUNT + TermCriteria::EPS, 30, DBL_EPSILON))
+ //
+
+ public static double calibrateCamera(List objectPoints, List imagePoints, Size imageSize, Mat cameraMatrix, Mat distCoeffs, List rvecs, List tvecs, int flags, TermCriteria criteria) {
+ Mat objectPoints_mat = Converters.vector_Mat_to_Mat(objectPoints);
+ Mat imagePoints_mat = Converters.vector_Mat_to_Mat(imagePoints);
+ Mat rvecs_mat = new Mat();
+ Mat tvecs_mat = new Mat();
+ double retVal = calibrateCamera_0(objectPoints_mat.nativeObj, imagePoints_mat.nativeObj, imageSize.width, imageSize.height, cameraMatrix.nativeObj, distCoeffs.nativeObj, rvecs_mat.nativeObj, tvecs_mat.nativeObj, flags, criteria.type, criteria.maxCount, criteria.epsilon);
+ Converters.Mat_to_vector_Mat(rvecs_mat, rvecs);
+ rvecs_mat.release();
+ Converters.Mat_to_vector_Mat(tvecs_mat, tvecs);
+ tvecs_mat.release();
+ return retVal;
+ }
+
+ public static double calibrateCamera(List objectPoints, List imagePoints, Size imageSize, Mat cameraMatrix, Mat distCoeffs, List rvecs, List tvecs, int flags) {
+ Mat objectPoints_mat = Converters.vector_Mat_to_Mat(objectPoints);
+ Mat imagePoints_mat = Converters.vector_Mat_to_Mat(imagePoints);
+ Mat rvecs_mat = new Mat();
+ Mat tvecs_mat = new Mat();
+ double retVal = calibrateCamera_1(objectPoints_mat.nativeObj, imagePoints_mat.nativeObj, imageSize.width, imageSize.height, cameraMatrix.nativeObj, distCoeffs.nativeObj, rvecs_mat.nativeObj, tvecs_mat.nativeObj, flags);
+ Converters.Mat_to_vector_Mat(rvecs_mat, rvecs);
+ rvecs_mat.release();
+ Converters.Mat_to_vector_Mat(tvecs_mat, tvecs);
+ tvecs_mat.release();
+ return retVal;
+ }
+
+ public static double calibrateCamera(List objectPoints, List imagePoints, Size imageSize, Mat cameraMatrix, Mat distCoeffs, List rvecs, List tvecs) {
+ Mat objectPoints_mat = Converters.vector_Mat_to_Mat(objectPoints);
+ Mat imagePoints_mat = Converters.vector_Mat_to_Mat(imagePoints);
+ Mat rvecs_mat = new Mat();
+ Mat tvecs_mat = new Mat();
+ double retVal = calibrateCamera_2(objectPoints_mat.nativeObj, imagePoints_mat.nativeObj, imageSize.width, imageSize.height, cameraMatrix.nativeObj, distCoeffs.nativeObj, rvecs_mat.nativeObj, tvecs_mat.nativeObj);
+ Converters.Mat_to_vector_Mat(rvecs_mat, rvecs);
+ rvecs_mat.release();
+ Converters.Mat_to_vector_Mat(tvecs_mat, tvecs);
+ tvecs_mat.release();
+ return retVal;
+ }
+
+
+ //
+ // C++: double cv::calibrateCameraRO(vector_Mat objectPoints, vector_Mat imagePoints, Size imageSize, int iFixedPoint, Mat& cameraMatrix, Mat& distCoeffs, vector_Mat& rvecs, vector_Mat& tvecs, Mat& newObjPoints, Mat& stdDeviationsIntrinsics, Mat& stdDeviationsExtrinsics, Mat& stdDeviationsObjPoints, Mat& perViewErrors, int flags = 0, TermCriteria criteria = TermCriteria( TermCriteria::COUNT + TermCriteria::EPS, 30, DBL_EPSILON))
+ //
+
+ /**
+ * Finds the camera intrinsic and extrinsic parameters from several views of a calibration pattern.
+ *
+ * This function is an extension of #calibrateCamera with the method of releasing object which was
+ * proposed in CITE: strobl2011iccv. In many common cases with inaccurate, unmeasured, roughly planar
+ * targets (calibration plates), this method can dramatically improve the precision of the estimated
+ * camera parameters. Both the object-releasing method and standard method are supported by this
+ * function. Use the parameter iFixedPoint for method selection. In the internal implementation,
+ * #calibrateCamera is a wrapper for this function.
+ *
+ * @param objectPoints Vector of vectors of calibration pattern points in the calibration pattern
+ * coordinate space. See #calibrateCamera for details. If the method of releasing object to be used,
+ * the identical calibration board must be used in each view and it must be fully visible, and all
+ * objectPoints[i] must be the same and all points should be roughly close to a plane. The calibration
+ * target has to be rigid, or at least static if the camera (rather than the calibration target) is
+ * shifted for grabbing images.
+ * @param imagePoints Vector of vectors of the projections of calibration pattern points. See
+ * #calibrateCamera for details.
+ * @param imageSize Size of the image used only to initialize the intrinsic camera matrix.
+ * @param iFixedPoint The index of the 3D object point in objectPoints[0] to be fixed. It also acts as
+ * a switch for calibration method selection. If object-releasing method to be used, pass in the
+ * parameter in the range of [1, objectPoints[0].size()-2], otherwise a value out of this range will
+ * make standard calibration method selected. Usually the top-right corner point of the calibration
+ * board grid is recommended to be fixed when object-releasing method being utilized. According to
+ * \cite strobl2011iccv, two other points are also fixed. In this implementation, objectPoints[0].front
+ * and objectPoints[0].back.z are used. With object-releasing method, accurate rvecs, tvecs and
+ * newObjPoints are only possible if coordinates of these three fixed points are accurate enough.
+ * @param cameraMatrix Output 3x3 floating-point camera matrix. See #calibrateCamera for details.
+ * @param distCoeffs Output vector of distortion coefficients. See #calibrateCamera for details.
+ * @param rvecs Output vector of rotation vectors estimated for each pattern view. See #calibrateCamera
+ * for details.
+ * @param tvecs Output vector of translation vectors estimated for each pattern view.
+ * @param newObjPoints The updated output vector of calibration pattern points. The coordinates might
+ * be scaled based on three fixed points. The returned coordinates are accurate only if the above
+ * mentioned three fixed points are accurate. If not needed, noArray() can be passed in. This parameter
+ * is ignored with standard calibration method.
+ * @param stdDeviationsIntrinsics Output vector of standard deviations estimated for intrinsic parameters.
+ * See #calibrateCamera for details.
+ * @param stdDeviationsExtrinsics Output vector of standard deviations estimated for extrinsic parameters.
+ * See #calibrateCamera for details.
+ * @param stdDeviationsObjPoints Output vector of standard deviations estimated for refined coordinates
+ * of calibration pattern points. It has the same size and order as objectPoints[0] vector. This
+ * parameter is ignored with standard calibration method.
+ * @param perViewErrors Output vector of the RMS re-projection error estimated for each pattern view.
+ * @param flags Different flags that may be zero or a combination of some predefined values. See
+ * #calibrateCamera for details. If the method of releasing object is used, the calibration time may
+ * be much longer. CALIB_USE_QR or CALIB_USE_LU could be used for faster calibration with potentially
+ * less precise and less stable in some rare cases.
+ * @param criteria Termination criteria for the iterative optimization algorithm.
+ *
+ * @return the overall RMS re-projection error.
+ *
+ * The function estimates the intrinsic camera parameters and extrinsic parameters for each of the
+ * views. The algorithm is based on CITE: Zhang2000, CITE: BouguetMCT and CITE: strobl2011iccv. See
+ * #calibrateCamera for other detailed explanations.
+ * SEE:
+ * calibrateCamera, findChessboardCorners, solvePnP, initCameraMatrix2D, stereoCalibrate, undistort
+ */
+ public static double calibrateCameraROExtended(List objectPoints, List imagePoints, Size imageSize, int iFixedPoint, Mat cameraMatrix, Mat distCoeffs, List rvecs, List tvecs, Mat newObjPoints, Mat stdDeviationsIntrinsics, Mat stdDeviationsExtrinsics, Mat stdDeviationsObjPoints, Mat perViewErrors, int flags, TermCriteria criteria) {
+ Mat objectPoints_mat = Converters.vector_Mat_to_Mat(objectPoints);
+ Mat imagePoints_mat = Converters.vector_Mat_to_Mat(imagePoints);
+ Mat rvecs_mat = new Mat();
+ Mat tvecs_mat = new Mat();
+ double retVal = calibrateCameraROExtended_0(objectPoints_mat.nativeObj, imagePoints_mat.nativeObj, imageSize.width, imageSize.height, iFixedPoint, cameraMatrix.nativeObj, distCoeffs.nativeObj, rvecs_mat.nativeObj, tvecs_mat.nativeObj, newObjPoints.nativeObj, stdDeviationsIntrinsics.nativeObj, stdDeviationsExtrinsics.nativeObj, stdDeviationsObjPoints.nativeObj, perViewErrors.nativeObj, flags, criteria.type, criteria.maxCount, criteria.epsilon);
+ Converters.Mat_to_vector_Mat(rvecs_mat, rvecs);
+ rvecs_mat.release();
+ Converters.Mat_to_vector_Mat(tvecs_mat, tvecs);
+ tvecs_mat.release();
+ return retVal;
+ }
+
+ /**
+ * Finds the camera intrinsic and extrinsic parameters from several views of a calibration pattern.
+ *
+ * This function is an extension of #calibrateCamera with the method of releasing object which was
+ * proposed in CITE: strobl2011iccv. In many common cases with inaccurate, unmeasured, roughly planar
+ * targets (calibration plates), this method can dramatically improve the precision of the estimated
+ * camera parameters. Both the object-releasing method and standard method are supported by this
+ * function. Use the parameter iFixedPoint for method selection. In the internal implementation,
+ * #calibrateCamera is a wrapper for this function.
+ *
+ * @param objectPoints Vector of vectors of calibration pattern points in the calibration pattern
+ * coordinate space. See #calibrateCamera for details. If the method of releasing object to be used,
+ * the identical calibration board must be used in each view and it must be fully visible, and all
+ * objectPoints[i] must be the same and all points should be roughly close to a plane. The calibration
+ * target has to be rigid, or at least static if the camera (rather than the calibration target) is
+ * shifted for grabbing images.
+ * @param imagePoints Vector of vectors of the projections of calibration pattern points. See
+ * #calibrateCamera for details.
+ * @param imageSize Size of the image used only to initialize the intrinsic camera matrix.
+ * @param iFixedPoint The index of the 3D object point in objectPoints[0] to be fixed. It also acts as
+ * a switch for calibration method selection. If object-releasing method to be used, pass in the
+ * parameter in the range of [1, objectPoints[0].size()-2], otherwise a value out of this range will
+ * make standard calibration method selected. Usually the top-right corner point of the calibration
+ * board grid is recommended to be fixed when object-releasing method being utilized. According to
+ * \cite strobl2011iccv, two other points are also fixed. In this implementation, objectPoints[0].front
+ * and objectPoints[0].back.z are used. With object-releasing method, accurate rvecs, tvecs and
+ * newObjPoints are only possible if coordinates of these three fixed points are accurate enough.
+ * @param cameraMatrix Output 3x3 floating-point camera matrix. See #calibrateCamera for details.
+ * @param distCoeffs Output vector of distortion coefficients. See #calibrateCamera for details.
+ * @param rvecs Output vector of rotation vectors estimated for each pattern view. See #calibrateCamera
+ * for details.
+ * @param tvecs Output vector of translation vectors estimated for each pattern view.
+ * @param newObjPoints The updated output vector of calibration pattern points. The coordinates might
+ * be scaled based on three fixed points. The returned coordinates are accurate only if the above
+ * mentioned three fixed points are accurate. If not needed, noArray() can be passed in. This parameter
+ * is ignored with standard calibration method.
+ * @param stdDeviationsIntrinsics Output vector of standard deviations estimated for intrinsic parameters.
+ * See #calibrateCamera for details.
+ * @param stdDeviationsExtrinsics Output vector of standard deviations estimated for extrinsic parameters.
+ * See #calibrateCamera for details.
+ * @param stdDeviationsObjPoints Output vector of standard deviations estimated for refined coordinates
+ * of calibration pattern points. It has the same size and order as objectPoints[0] vector. This
+ * parameter is ignored with standard calibration method.
+ * @param perViewErrors Output vector of the RMS re-projection error estimated for each pattern view.
+ * @param flags Different flags that may be zero or a combination of some predefined values. See
+ * #calibrateCamera for details. If the method of releasing object is used, the calibration time may
+ * be much longer. CALIB_USE_QR or CALIB_USE_LU could be used for faster calibration with potentially
+ * less precise and less stable in some rare cases.
+ *
+ * @return the overall RMS re-projection error.
+ *
+ * The function estimates the intrinsic camera parameters and extrinsic parameters for each of the
+ * views. The algorithm is based on CITE: Zhang2000, CITE: BouguetMCT and CITE: strobl2011iccv. See
+ * #calibrateCamera for other detailed explanations.
+ * SEE:
+ * calibrateCamera, findChessboardCorners, solvePnP, initCameraMatrix2D, stereoCalibrate, undistort
+ */
+ public static double calibrateCameraROExtended(List objectPoints, List imagePoints, Size imageSize, int iFixedPoint, Mat cameraMatrix, Mat distCoeffs, List rvecs, List tvecs, Mat newObjPoints, Mat stdDeviationsIntrinsics, Mat stdDeviationsExtrinsics, Mat stdDeviationsObjPoints, Mat perViewErrors, int flags) {
+ Mat objectPoints_mat = Converters.vector_Mat_to_Mat(objectPoints);
+ Mat imagePoints_mat = Converters.vector_Mat_to_Mat(imagePoints);
+ Mat rvecs_mat = new Mat();
+ Mat tvecs_mat = new Mat();
+ double retVal = calibrateCameraROExtended_1(objectPoints_mat.nativeObj, imagePoints_mat.nativeObj, imageSize.width, imageSize.height, iFixedPoint, cameraMatrix.nativeObj, distCoeffs.nativeObj, rvecs_mat.nativeObj, tvecs_mat.nativeObj, newObjPoints.nativeObj, stdDeviationsIntrinsics.nativeObj, stdDeviationsExtrinsics.nativeObj, stdDeviationsObjPoints.nativeObj, perViewErrors.nativeObj, flags);
+ Converters.Mat_to_vector_Mat(rvecs_mat, rvecs);
+ rvecs_mat.release();
+ Converters.Mat_to_vector_Mat(tvecs_mat, tvecs);
+ tvecs_mat.release();
+ return retVal;
+ }
+
+ /**
+ * Finds the camera intrinsic and extrinsic parameters from several views of a calibration pattern.
+ *
+ * This function is an extension of #calibrateCamera with the method of releasing object which was
+ * proposed in CITE: strobl2011iccv. In many common cases with inaccurate, unmeasured, roughly planar
+ * targets (calibration plates), this method can dramatically improve the precision of the estimated
+ * camera parameters. Both the object-releasing method and standard method are supported by this
+ * function. Use the parameter iFixedPoint for method selection. In the internal implementation,
+ * #calibrateCamera is a wrapper for this function.
+ *
+ * @param objectPoints Vector of vectors of calibration pattern points in the calibration pattern
+ * coordinate space. See #calibrateCamera for details. If the method of releasing object to be used,
+ * the identical calibration board must be used in each view and it must be fully visible, and all
+ * objectPoints[i] must be the same and all points should be roughly close to a plane. The calibration
+ * target has to be rigid, or at least static if the camera (rather than the calibration target) is
+ * shifted for grabbing images.
+ * @param imagePoints Vector of vectors of the projections of calibration pattern points. See
+ * #calibrateCamera for details.
+ * @param imageSize Size of the image used only to initialize the intrinsic camera matrix.
+ * @param iFixedPoint The index of the 3D object point in objectPoints[0] to be fixed. It also acts as
+ * a switch for calibration method selection. If object-releasing method to be used, pass in the
+ * parameter in the range of [1, objectPoints[0].size()-2], otherwise a value out of this range will
+ * make standard calibration method selected. Usually the top-right corner point of the calibration
+ * board grid is recommended to be fixed when object-releasing method being utilized. According to
+ * \cite strobl2011iccv, two other points are also fixed. In this implementation, objectPoints[0].front
+ * and objectPoints[0].back.z are used. With object-releasing method, accurate rvecs, tvecs and
+ * newObjPoints are only possible if coordinates of these three fixed points are accurate enough.
+ * @param cameraMatrix Output 3x3 floating-point camera matrix. See #calibrateCamera for details.
+ * @param distCoeffs Output vector of distortion coefficients. See #calibrateCamera for details.
+ * @param rvecs Output vector of rotation vectors estimated for each pattern view. See #calibrateCamera
+ * for details.
+ * @param tvecs Output vector of translation vectors estimated for each pattern view.
+ * @param newObjPoints The updated output vector of calibration pattern points. The coordinates might
+ * be scaled based on three fixed points. The returned coordinates are accurate only if the above
+ * mentioned three fixed points are accurate. If not needed, noArray() can be passed in. This parameter
+ * is ignored with standard calibration method.
+ * @param stdDeviationsIntrinsics Output vector of standard deviations estimated for intrinsic parameters.
+ * See #calibrateCamera for details.
+ * @param stdDeviationsExtrinsics Output vector of standard deviations estimated for extrinsic parameters.
+ * See #calibrateCamera for details.
+ * @param stdDeviationsObjPoints Output vector of standard deviations estimated for refined coordinates
+ * of calibration pattern points. It has the same size and order as objectPoints[0] vector. This
+ * parameter is ignored with standard calibration method.
+ * @param perViewErrors Output vector of the RMS re-projection error estimated for each pattern view.
+ * #calibrateCamera for details. If the method of releasing object is used, the calibration time may
+ * be much longer. CALIB_USE_QR or CALIB_USE_LU could be used for faster calibration with potentially
+ * less precise and less stable in some rare cases.
+ *
+ * @return the overall RMS re-projection error.
+ *
+ * The function estimates the intrinsic camera parameters and extrinsic parameters for each of the
+ * views. The algorithm is based on CITE: Zhang2000, CITE: BouguetMCT and CITE: strobl2011iccv. See
+ * #calibrateCamera for other detailed explanations.
+ * SEE:
+ * calibrateCamera, findChessboardCorners, solvePnP, initCameraMatrix2D, stereoCalibrate, undistort
+ */
+ public static double calibrateCameraROExtended(List objectPoints, List imagePoints, Size imageSize, int iFixedPoint, Mat cameraMatrix, Mat distCoeffs, List rvecs, List tvecs, Mat newObjPoints, Mat stdDeviationsIntrinsics, Mat stdDeviationsExtrinsics, Mat stdDeviationsObjPoints, Mat perViewErrors) {
+ Mat objectPoints_mat = Converters.vector_Mat_to_Mat(objectPoints);
+ Mat imagePoints_mat = Converters.vector_Mat_to_Mat(imagePoints);
+ Mat rvecs_mat = new Mat();
+ Mat tvecs_mat = new Mat();
+ double retVal = calibrateCameraROExtended_2(objectPoints_mat.nativeObj, imagePoints_mat.nativeObj, imageSize.width, imageSize.height, iFixedPoint, cameraMatrix.nativeObj, distCoeffs.nativeObj, rvecs_mat.nativeObj, tvecs_mat.nativeObj, newObjPoints.nativeObj, stdDeviationsIntrinsics.nativeObj, stdDeviationsExtrinsics.nativeObj, stdDeviationsObjPoints.nativeObj, perViewErrors.nativeObj);
+ Converters.Mat_to_vector_Mat(rvecs_mat, rvecs);
+ rvecs_mat.release();
+ Converters.Mat_to_vector_Mat(tvecs_mat, tvecs);
+ tvecs_mat.release();
+ return retVal;
+ }
+
+
+ //
+ // C++: double cv::calibrateCameraRO(vector_Mat objectPoints, vector_Mat imagePoints, Size imageSize, int iFixedPoint, Mat& cameraMatrix, Mat& distCoeffs, vector_Mat& rvecs, vector_Mat& tvecs, Mat& newObjPoints, int flags = 0, TermCriteria criteria = TermCriteria( TermCriteria::COUNT + TermCriteria::EPS, 30, DBL_EPSILON))
+ //
+
+ public static double calibrateCameraRO(List objectPoints, List imagePoints, Size imageSize, int iFixedPoint, Mat cameraMatrix, Mat distCoeffs, List rvecs, List tvecs, Mat newObjPoints, int flags, TermCriteria criteria) {
+ Mat objectPoints_mat = Converters.vector_Mat_to_Mat(objectPoints);
+ Mat imagePoints_mat = Converters.vector_Mat_to_Mat(imagePoints);
+ Mat rvecs_mat = new Mat();
+ Mat tvecs_mat = new Mat();
+ double retVal = calibrateCameraRO_0(objectPoints_mat.nativeObj, imagePoints_mat.nativeObj, imageSize.width, imageSize.height, iFixedPoint, cameraMatrix.nativeObj, distCoeffs.nativeObj, rvecs_mat.nativeObj, tvecs_mat.nativeObj, newObjPoints.nativeObj, flags, criteria.type, criteria.maxCount, criteria.epsilon);
+ Converters.Mat_to_vector_Mat(rvecs_mat, rvecs);
+ rvecs_mat.release();
+ Converters.Mat_to_vector_Mat(tvecs_mat, tvecs);
+ tvecs_mat.release();
+ return retVal;
+ }
+
+ public static double calibrateCameraRO(List objectPoints, List imagePoints, Size imageSize, int iFixedPoint, Mat cameraMatrix, Mat distCoeffs, List rvecs, List tvecs, Mat newObjPoints, int flags) {
+ Mat objectPoints_mat = Converters.vector_Mat_to_Mat(objectPoints);
+ Mat imagePoints_mat = Converters.vector_Mat_to_Mat(imagePoints);
+ Mat rvecs_mat = new Mat();
+ Mat tvecs_mat = new Mat();
+ double retVal = calibrateCameraRO_1(objectPoints_mat.nativeObj, imagePoints_mat.nativeObj, imageSize.width, imageSize.height, iFixedPoint, cameraMatrix.nativeObj, distCoeffs.nativeObj, rvecs_mat.nativeObj, tvecs_mat.nativeObj, newObjPoints.nativeObj, flags);
+ Converters.Mat_to_vector_Mat(rvecs_mat, rvecs);
+ rvecs_mat.release();
+ Converters.Mat_to_vector_Mat(tvecs_mat, tvecs);
+ tvecs_mat.release();
+ return retVal;
+ }
+
+ public static double calibrateCameraRO(List objectPoints, List imagePoints, Size imageSize, int iFixedPoint, Mat cameraMatrix, Mat distCoeffs, List rvecs, List tvecs, Mat newObjPoints) {
+ Mat objectPoints_mat = Converters.vector_Mat_to_Mat(objectPoints);
+ Mat imagePoints_mat = Converters.vector_Mat_to_Mat(imagePoints);
+ Mat rvecs_mat = new Mat();
+ Mat tvecs_mat = new Mat();
+ double retVal = calibrateCameraRO_2(objectPoints_mat.nativeObj, imagePoints_mat.nativeObj, imageSize.width, imageSize.height, iFixedPoint, cameraMatrix.nativeObj, distCoeffs.nativeObj, rvecs_mat.nativeObj, tvecs_mat.nativeObj, newObjPoints.nativeObj);
+ Converters.Mat_to_vector_Mat(rvecs_mat, rvecs);
+ rvecs_mat.release();
+ Converters.Mat_to_vector_Mat(tvecs_mat, tvecs);
+ tvecs_mat.release();
+ return retVal;
+ }
+
+
+ //
+ // C++: void cv::calibrationMatrixValues(Mat cameraMatrix, Size imageSize, double apertureWidth, double apertureHeight, double& fovx, double& fovy, double& focalLength, Point2d& principalPoint, double& aspectRatio)
+ //
+
+ /**
+ * Computes useful camera characteristics from the camera intrinsic matrix.
+ *
+ * @param cameraMatrix Input camera intrinsic matrix that can be estimated by #calibrateCamera or
+ * #stereoCalibrate .
+ * @param imageSize Input image size in pixels.
+ * @param apertureWidth Physical width in mm of the sensor.
+ * @param apertureHeight Physical height in mm of the sensor.
+ * @param fovx Output field of view in degrees along the horizontal sensor axis.
+ * @param fovy Output field of view in degrees along the vertical sensor axis.
+ * @param focalLength Focal length of the lens in mm.
+ * @param principalPoint Principal point in mm.
+ * @param aspectRatio \(f_y/f_x\)
+ *
+ * The function computes various useful camera characteristics from the previously estimated camera
+ * matrix.
+ *
+ * Note:
+ * Do keep in mind that the unity measure 'mm' stands for whatever unit of measure one chooses for
+ * the chessboard pitch (it can thus be any value).
+ */
+ public static void calibrationMatrixValues(Mat cameraMatrix, Size imageSize, double apertureWidth, double apertureHeight, double[] fovx, double[] fovy, double[] focalLength, Point principalPoint, double[] aspectRatio) {
+ double[] fovx_out = new double[1];
+ double[] fovy_out = new double[1];
+ double[] focalLength_out = new double[1];
+ double[] principalPoint_out = new double[2];
+ double[] aspectRatio_out = new double[1];
+ calibrationMatrixValues_0(cameraMatrix.nativeObj, imageSize.width, imageSize.height, apertureWidth, apertureHeight, fovx_out, fovy_out, focalLength_out, principalPoint_out, aspectRatio_out);
+ if(fovx!=null) fovx[0] = (double)fovx_out[0];
+ if(fovy!=null) fovy[0] = (double)fovy_out[0];
+ if(focalLength!=null) focalLength[0] = (double)focalLength_out[0];
+ if(principalPoint!=null){ principalPoint.x = principalPoint_out[0]; principalPoint.y = principalPoint_out[1]; }
+ if(aspectRatio!=null) aspectRatio[0] = (double)aspectRatio_out[0];
+ }
+
+
+ //
+ // C++: double cv::stereoCalibrate(vector_Mat objectPoints, vector_Mat imagePoints1, vector_Mat imagePoints2, Mat& cameraMatrix1, Mat& distCoeffs1, Mat& cameraMatrix2, Mat& distCoeffs2, Size imageSize, Mat& R, Mat& T, Mat& E, Mat& F, vector_Mat& rvecs, vector_Mat& tvecs, Mat& perViewErrors, int flags = CALIB_FIX_INTRINSIC, TermCriteria criteria = TermCriteria(TermCriteria::COUNT+TermCriteria::EPS, 30, 1e-6))
+ //
+
+ /**
+ * Calibrates a stereo camera set up. This function finds the intrinsic parameters
+ * for each of the two cameras and the extrinsic parameters between the two cameras.
+ *
+ * @param objectPoints Vector of vectors of the calibration pattern points. The same structure as
+ * in REF: calibrateCamera. For each pattern view, both cameras need to see the same object
+ * points. Therefore, objectPoints.size(), imagePoints1.size(), and imagePoints2.size() need to be
+ * equal as well as objectPoints[i].size(), imagePoints1[i].size(), and imagePoints2[i].size() need to
+ * be equal for each i.
+ * @param imagePoints1 Vector of vectors of the projections of the calibration pattern points,
+ * observed by the first camera. The same structure as in REF: calibrateCamera.
+ * @param imagePoints2 Vector of vectors of the projections of the calibration pattern points,
+ * observed by the second camera. The same structure as in REF: calibrateCamera.
+ * @param cameraMatrix1 Input/output camera intrinsic matrix for the first camera, the same as in
+ * REF: calibrateCamera. Furthermore, for the stereo case, additional flags may be used, see below.
+ * @param distCoeffs1 Input/output vector of distortion coefficients, the same as in
+ * REF: calibrateCamera.
+ * @param cameraMatrix2 Input/output second camera intrinsic matrix for the second camera. See description for
+ * cameraMatrix1.
+ * @param distCoeffs2 Input/output lens distortion coefficients for the second camera. See
+ * description for distCoeffs1.
+ * @param imageSize Size of the image used only to initialize the camera intrinsic matrices.
+ * @param R Output rotation matrix. Together with the translation vector T, this matrix brings
+ * points given in the first camera's coordinate system to points in the second camera's
+ * coordinate system. In more technical terms, the tuple of R and T performs a change of basis
+ * from the first camera's coordinate system to the second camera's coordinate system. Due to its
+ * duality, this tuple is equivalent to the position of the first camera with respect to the
+ * second camera coordinate system.
+ * @param T Output translation vector, see description above.
+ * @param E Output essential matrix.
+ * @param F Output fundamental matrix.
+ * @param rvecs Output vector of rotation vectors ( REF: Rodrigues ) estimated for each pattern view in the
+ * coordinate system of the first camera of the stereo pair (e.g. std::vector<cv::Mat>). More in detail, each
+ * i-th rotation vector together with the corresponding i-th translation vector (see the next output parameter
+ * description) brings the calibration pattern from the object coordinate space (in which object points are
+ * specified) to the camera coordinate space of the first camera of the stereo pair. In more technical terms,
+ * the tuple of the i-th rotation and translation vector performs a change of basis from object coordinate space
+ * to camera coordinate space of the first camera of the stereo pair.
+ * @param tvecs Output vector of translation vectors estimated for each pattern view, see parameter description
+ * of previous output parameter ( rvecs ).
+ * @param perViewErrors Output vector of the RMS re-projection error estimated for each pattern view.
+ * @param flags Different flags that may be zero or a combination of the following values:
+ *
+ *
+ * REF: CALIB_FIX_INTRINSIC Fix cameraMatrix? and distCoeffs? so that only R, T, E, and F
+ * matrices are estimated.
+ *
+ *
+ * REF: CALIB_USE_INTRINSIC_GUESS Optimize some or all of the intrinsic parameters
+ * according to the specified flags. Initial values are provided by the user.
+ *
+ *
+ * REF: CALIB_USE_EXTRINSIC_GUESS R and T contain valid initial values that are optimized further.
+ * Otherwise R and T are initialized to the median value of the pattern views (each dimension separately).
+ *
+ *
+ * REF: CALIB_FIX_PRINCIPAL_POINT Fix the principal points during the optimization.
+ *
+ * REF: CALIB_ZERO_TANGENT_DIST Set tangential distortion coefficients for each camera to
+ * zeros and fix there.
+ *
+ *
+ * REF: CALIB_FIX_K1,..., REF: CALIB_FIX_K6 Do not change the corresponding radial
+ * distortion coefficient 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 Enable coefficients k4, k5, and k6. To provide the backward
+ * compatibility, this extra flag should be explicitly specified to make the calibration
+ * function use the rational model and return 8 coefficients. If the flag is not set, the
+ * function computes and returns only 5 distortion coefficients.
+ *
+ *
+ * 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. 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. 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.
+ *
+ *
+ * @param criteria Termination criteria for the iterative optimization algorithm.
+ *
+ * The function estimates the transformation between two cameras making a stereo pair. If one computes
+ * the poses of an object relative to the first camera and to the second camera,
+ * ( \(R_1\),\(T_1\) ) and (\(R_2\),\(T_2\)), respectively, for a stereo camera where the
+ * relative position and orientation between the two cameras are fixed, then those poses definitely
+ * relate to each other. This means, if the relative position and orientation (\(R\),\(T\)) of the
+ * two cameras is known, it is possible to compute (\(R_2\),\(T_2\)) when (\(R_1\),\(T_1\)) is
+ * given. This is what the described function does. It computes (\(R\),\(T\)) such that:
+ *
+ * \(R_2=R R_1\)
+ * \(T_2=R T_1 + T.\)
+ *
+ * Therefore, one can compute the coordinate representation of a 3D point for the second camera's
+ * coordinate system when given the point's coordinate representation in the first camera's coordinate
+ * system:
+ *
+ * \(\begin{bmatrix}
+ * X_2 \\
+ * Y_2 \\
+ * Z_2 \\
+ * 1
+ * \end{bmatrix} = \begin{bmatrix}
+ * R & T \\
+ * 0 & 1
+ * \end{bmatrix} \begin{bmatrix}
+ * X_1 \\
+ * Y_1 \\
+ * Z_1 \\
+ * 1
+ * \end{bmatrix}.\)
+ *
+ *
+ * Optionally, it computes the essential matrix E:
+ *
+ * \(E= \vecthreethree{0}{-T_2}{T_1}{T_2}{0}{-T_0}{-T_1}{T_0}{0} R\)
+ *
+ * where \(T_i\) are components of the translation vector \(T\) : \(T=[T_0, T_1, T_2]^T\) .
+ * And the function can also compute the fundamental matrix F:
+ *
+ * \(F = cameraMatrix2^{-T}\cdot E \cdot cameraMatrix1^{-1}\)
+ *
+ * Besides the stereo-related information, the function can also perform a full calibration of each of
+ * the two cameras. However, due to the high dimensionality of the parameter space and noise in the
+ * input data, the function can diverge from the correct solution. If the intrinsic parameters can be
+ * estimated with high accuracy for each of the cameras individually (for example, using
+ * #calibrateCamera ), you are recommended to do so and then pass REF: CALIB_FIX_INTRINSIC flag to the
+ * function along with the computed intrinsic parameters. Otherwise, if all the parameters are
+ * estimated at once, it makes sense to restrict some parameters, for example, pass
+ * REF: CALIB_SAME_FOCAL_LENGTH and REF: CALIB_ZERO_TANGENT_DIST flags, which is usually a
+ * reasonable assumption.
+ *
+ * Similarly to #calibrateCamera, the function minimizes the total re-projection error for all the
+ * points in all the available views from both cameras. The function returns the final value of the
+ * re-projection error.
+ * @return automatically generated
+ */
+ public static double stereoCalibrateExtended(List objectPoints, List imagePoints1, List imagePoints2, Mat cameraMatrix1, Mat distCoeffs1, Mat cameraMatrix2, Mat distCoeffs2, Size imageSize, Mat R, Mat T, Mat E, Mat F, List rvecs, List tvecs, Mat perViewErrors, int flags, TermCriteria criteria) {
+ Mat objectPoints_mat = Converters.vector_Mat_to_Mat(objectPoints);
+ Mat imagePoints1_mat = Converters.vector_Mat_to_Mat(imagePoints1);
+ Mat imagePoints2_mat = Converters.vector_Mat_to_Mat(imagePoints2);
+ Mat rvecs_mat = new Mat();
+ Mat tvecs_mat = new Mat();
+ double retVal = stereoCalibrateExtended_0(objectPoints_mat.nativeObj, imagePoints1_mat.nativeObj, imagePoints2_mat.nativeObj, cameraMatrix1.nativeObj, distCoeffs1.nativeObj, cameraMatrix2.nativeObj, distCoeffs2.nativeObj, imageSize.width, imageSize.height, R.nativeObj, T.nativeObj, E.nativeObj, F.nativeObj, rvecs_mat.nativeObj, tvecs_mat.nativeObj, perViewErrors.nativeObj, flags, criteria.type, criteria.maxCount, criteria.epsilon);
+ Converters.Mat_to_vector_Mat(rvecs_mat, rvecs);
+ rvecs_mat.release();
+ Converters.Mat_to_vector_Mat(tvecs_mat, tvecs);
+ tvecs_mat.release();
+ return retVal;
+ }
+
+ /**
+ * Calibrates a stereo camera set up. This function finds the intrinsic parameters
+ * for each of the two cameras and the extrinsic parameters between the two cameras.
+ *
+ * @param objectPoints Vector of vectors of the calibration pattern points. The same structure as
+ * in REF: calibrateCamera. For each pattern view, both cameras need to see the same object
+ * points. Therefore, objectPoints.size(), imagePoints1.size(), and imagePoints2.size() need to be
+ * equal as well as objectPoints[i].size(), imagePoints1[i].size(), and imagePoints2[i].size() need to
+ * be equal for each i.
+ * @param imagePoints1 Vector of vectors of the projections of the calibration pattern points,
+ * observed by the first camera. The same structure as in REF: calibrateCamera.
+ * @param imagePoints2 Vector of vectors of the projections of the calibration pattern points,
+ * observed by the second camera. The same structure as in REF: calibrateCamera.
+ * @param cameraMatrix1 Input/output camera intrinsic matrix for the first camera, the same as in
+ * REF: calibrateCamera. Furthermore, for the stereo case, additional flags may be used, see below.
+ * @param distCoeffs1 Input/output vector of distortion coefficients, the same as in
+ * REF: calibrateCamera.
+ * @param cameraMatrix2 Input/output second camera intrinsic matrix for the second camera. See description for
+ * cameraMatrix1.
+ * @param distCoeffs2 Input/output lens distortion coefficients for the second camera. See
+ * description for distCoeffs1.
+ * @param imageSize Size of the image used only to initialize the camera intrinsic matrices.
+ * @param R Output rotation matrix. Together with the translation vector T, this matrix brings
+ * points given in the first camera's coordinate system to points in the second camera's
+ * coordinate system. In more technical terms, the tuple of R and T performs a change of basis
+ * from the first camera's coordinate system to the second camera's coordinate system. Due to its
+ * duality, this tuple is equivalent to the position of the first camera with respect to the
+ * second camera coordinate system.
+ * @param T Output translation vector, see description above.
+ * @param E Output essential matrix.
+ * @param F Output fundamental matrix.
+ * @param rvecs Output vector of rotation vectors ( REF: Rodrigues ) estimated for each pattern view in the
+ * coordinate system of the first camera of the stereo pair (e.g. std::vector<cv::Mat>). More in detail, each
+ * i-th rotation vector together with the corresponding i-th translation vector (see the next output parameter
+ * description) brings the calibration pattern from the object coordinate space (in which object points are
+ * specified) to the camera coordinate space of the first camera of the stereo pair. In more technical terms,
+ * the tuple of the i-th rotation and translation vector performs a change of basis from object coordinate space
+ * to camera coordinate space of the first camera of the stereo pair.
+ * @param tvecs Output vector of translation vectors estimated for each pattern view, see parameter description
+ * of previous output parameter ( rvecs ).
+ * @param perViewErrors Output vector of the RMS re-projection error estimated for each pattern view.
+ * @param flags Different flags that may be zero or a combination of the following values:
+ *
+ *
+ * REF: CALIB_FIX_INTRINSIC Fix cameraMatrix? and distCoeffs? so that only R, T, E, and F
+ * matrices are estimated.
+ *
+ *
+ * REF: CALIB_USE_INTRINSIC_GUESS Optimize some or all of the intrinsic parameters
+ * according to the specified flags. Initial values are provided by the user.
+ *
+ *
+ * REF: CALIB_USE_EXTRINSIC_GUESS R and T contain valid initial values that are optimized further.
+ * Otherwise R and T are initialized to the median value of the pattern views (each dimension separately).
+ *
+ *
+ * REF: CALIB_FIX_PRINCIPAL_POINT Fix the principal points during the optimization.
+ *
+ * REF: CALIB_ZERO_TANGENT_DIST Set tangential distortion coefficients for each camera to
+ * zeros and fix there.
+ *
+ *
+ * REF: CALIB_FIX_K1,..., REF: CALIB_FIX_K6 Do not change the corresponding radial
+ * distortion coefficient 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 Enable coefficients k4, k5, and k6. To provide the backward
+ * compatibility, this extra flag should be explicitly specified to make the calibration
+ * function use the rational model and return 8 coefficients. If the flag is not set, the
+ * function computes and returns only 5 distortion coefficients.
+ *
+ *
+ * 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. 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. 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.
+ *
+ *
+ *
+ * The function estimates the transformation between two cameras making a stereo pair. If one computes
+ * the poses of an object relative to the first camera and to the second camera,
+ * ( \(R_1\),\(T_1\) ) and (\(R_2\),\(T_2\)), respectively, for a stereo camera where the
+ * relative position and orientation between the two cameras are fixed, then those poses definitely
+ * relate to each other. This means, if the relative position and orientation (\(R\),\(T\)) of the
+ * two cameras is known, it is possible to compute (\(R_2\),\(T_2\)) when (\(R_1\),\(T_1\)) is
+ * given. This is what the described function does. It computes (\(R\),\(T\)) such that:
+ *
+ * \(R_2=R R_1\)
+ * \(T_2=R T_1 + T.\)
+ *
+ * Therefore, one can compute the coordinate representation of a 3D point for the second camera's
+ * coordinate system when given the point's coordinate representation in the first camera's coordinate
+ * system:
+ *
+ * \(\begin{bmatrix}
+ * X_2 \\
+ * Y_2 \\
+ * Z_2 \\
+ * 1
+ * \end{bmatrix} = \begin{bmatrix}
+ * R & T \\
+ * 0 & 1
+ * \end{bmatrix} \begin{bmatrix}
+ * X_1 \\
+ * Y_1 \\
+ * Z_1 \\
+ * 1
+ * \end{bmatrix}.\)
+ *
+ *
+ * Optionally, it computes the essential matrix E:
+ *
+ * \(E= \vecthreethree{0}{-T_2}{T_1}{T_2}{0}{-T_0}{-T_1}{T_0}{0} R\)
+ *
+ * where \(T_i\) are components of the translation vector \(T\) : \(T=[T_0, T_1, T_2]^T\) .
+ * And the function can also compute the fundamental matrix F:
+ *
+ * \(F = cameraMatrix2^{-T}\cdot E \cdot cameraMatrix1^{-1}\)
+ *
+ * Besides the stereo-related information, the function can also perform a full calibration of each of
+ * the two cameras. However, due to the high dimensionality of the parameter space and noise in the
+ * input data, the function can diverge from the correct solution. If the intrinsic parameters can be
+ * estimated with high accuracy for each of the cameras individually (for example, using
+ * #calibrateCamera ), you are recommended to do so and then pass REF: CALIB_FIX_INTRINSIC flag to the
+ * function along with the computed intrinsic parameters. Otherwise, if all the parameters are
+ * estimated at once, it makes sense to restrict some parameters, for example, pass
+ * REF: CALIB_SAME_FOCAL_LENGTH and REF: CALIB_ZERO_TANGENT_DIST flags, which is usually a
+ * reasonable assumption.
+ *
+ * Similarly to #calibrateCamera, the function minimizes the total re-projection error for all the
+ * points in all the available views from both cameras. The function returns the final value of the
+ * re-projection error.
+ * @return automatically generated
+ */
+ public static double stereoCalibrateExtended(List objectPoints, List imagePoints1, List imagePoints2, Mat cameraMatrix1, Mat distCoeffs1, Mat cameraMatrix2, Mat distCoeffs2, Size imageSize, Mat R, Mat T, Mat E, Mat F, List rvecs, List tvecs, Mat perViewErrors, int flags) {
+ Mat objectPoints_mat = Converters.vector_Mat_to_Mat(objectPoints);
+ Mat imagePoints1_mat = Converters.vector_Mat_to_Mat(imagePoints1);
+ Mat imagePoints2_mat = Converters.vector_Mat_to_Mat(imagePoints2);
+ Mat rvecs_mat = new Mat();
+ Mat tvecs_mat = new Mat();
+ double retVal = stereoCalibrateExtended_1(objectPoints_mat.nativeObj, imagePoints1_mat.nativeObj, imagePoints2_mat.nativeObj, cameraMatrix1.nativeObj, distCoeffs1.nativeObj, cameraMatrix2.nativeObj, distCoeffs2.nativeObj, imageSize.width, imageSize.height, R.nativeObj, T.nativeObj, E.nativeObj, F.nativeObj, rvecs_mat.nativeObj, tvecs_mat.nativeObj, perViewErrors.nativeObj, flags);
+ Converters.Mat_to_vector_Mat(rvecs_mat, rvecs);
+ rvecs_mat.release();
+ Converters.Mat_to_vector_Mat(tvecs_mat, tvecs);
+ tvecs_mat.release();
+ return retVal;
+ }
+
+ /**
+ * Calibrates a stereo camera set up. This function finds the intrinsic parameters
+ * for each of the two cameras and the extrinsic parameters between the two cameras.
+ *
+ * @param objectPoints Vector of vectors of the calibration pattern points. The same structure as
+ * in REF: calibrateCamera. For each pattern view, both cameras need to see the same object
+ * points. Therefore, objectPoints.size(), imagePoints1.size(), and imagePoints2.size() need to be
+ * equal as well as objectPoints[i].size(), imagePoints1[i].size(), and imagePoints2[i].size() need to
+ * be equal for each i.
+ * @param imagePoints1 Vector of vectors of the projections of the calibration pattern points,
+ * observed by the first camera. The same structure as in REF: calibrateCamera.
+ * @param imagePoints2 Vector of vectors of the projections of the calibration pattern points,
+ * observed by the second camera. The same structure as in REF: calibrateCamera.
+ * @param cameraMatrix1 Input/output camera intrinsic matrix for the first camera, the same as in
+ * REF: calibrateCamera. Furthermore, for the stereo case, additional flags may be used, see below.
+ * @param distCoeffs1 Input/output vector of distortion coefficients, the same as in
+ * REF: calibrateCamera.
+ * @param cameraMatrix2 Input/output second camera intrinsic matrix for the second camera. See description for
+ * cameraMatrix1.
+ * @param distCoeffs2 Input/output lens distortion coefficients for the second camera. See
+ * description for distCoeffs1.
+ * @param imageSize Size of the image used only to initialize the camera intrinsic matrices.
+ * @param R Output rotation matrix. Together with the translation vector T, this matrix brings
+ * points given in the first camera's coordinate system to points in the second camera's
+ * coordinate system. In more technical terms, the tuple of R and T performs a change of basis
+ * from the first camera's coordinate system to the second camera's coordinate system. Due to its
+ * duality, this tuple is equivalent to the position of the first camera with respect to the
+ * second camera coordinate system.
+ * @param T Output translation vector, see description above.
+ * @param E Output essential matrix.
+ * @param F Output fundamental matrix.
+ * @param rvecs Output vector of rotation vectors ( REF: Rodrigues ) estimated for each pattern view in the
+ * coordinate system of the first camera of the stereo pair (e.g. std::vector<cv::Mat>). More in detail, each
+ * i-th rotation vector together with the corresponding i-th translation vector (see the next output parameter
+ * description) brings the calibration pattern from the object coordinate space (in which object points are
+ * specified) to the camera coordinate space of the first camera of the stereo pair. In more technical terms,
+ * the tuple of the i-th rotation and translation vector performs a change of basis from object coordinate space
+ * to camera coordinate space of the first camera of the stereo pair.
+ * @param tvecs Output vector of translation vectors estimated for each pattern view, see parameter description
+ * of previous output parameter ( rvecs ).
+ * @param perViewErrors Output vector of the RMS re-projection error estimated for each pattern view.
+ *
+ *
+ * REF: CALIB_FIX_INTRINSIC Fix cameraMatrix? and distCoeffs? so that only R, T, E, and F
+ * matrices are estimated.
+ *
+ *
+ * REF: CALIB_USE_INTRINSIC_GUESS Optimize some or all of the intrinsic parameters
+ * according to the specified flags. Initial values are provided by the user.
+ *
+ *
+ * REF: CALIB_USE_EXTRINSIC_GUESS R and T contain valid initial values that are optimized further.
+ * Otherwise R and T are initialized to the median value of the pattern views (each dimension separately).
+ *
+ *
+ * REF: CALIB_FIX_PRINCIPAL_POINT Fix the principal points during the optimization.
+ *
+ * REF: CALIB_ZERO_TANGENT_DIST Set tangential distortion coefficients for each camera to
+ * zeros and fix there.
+ *
+ *
+ * REF: CALIB_FIX_K1,..., REF: CALIB_FIX_K6 Do not change the corresponding radial
+ * distortion coefficient 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 Enable coefficients k4, k5, and k6. To provide the backward
+ * compatibility, this extra flag should be explicitly specified to make the calibration
+ * function use the rational model and return 8 coefficients. If the flag is not set, the
+ * function computes and returns only 5 distortion coefficients.
+ *
+ *
+ * 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. 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. 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.
+ *
+ *
+ *
+ * The function estimates the transformation between two cameras making a stereo pair. If one computes
+ * the poses of an object relative to the first camera and to the second camera,
+ * ( \(R_1\),\(T_1\) ) and (\(R_2\),\(T_2\)), respectively, for a stereo camera where the
+ * relative position and orientation between the two cameras are fixed, then those poses definitely
+ * relate to each other. This means, if the relative position and orientation (\(R\),\(T\)) of the
+ * two cameras is known, it is possible to compute (\(R_2\),\(T_2\)) when (\(R_1\),\(T_1\)) is
+ * given. This is what the described function does. It computes (\(R\),\(T\)) such that:
+ *
+ * \(R_2=R R_1\)
+ * \(T_2=R T_1 + T.\)
+ *
+ * Therefore, one can compute the coordinate representation of a 3D point for the second camera's
+ * coordinate system when given the point's coordinate representation in the first camera's coordinate
+ * system:
+ *
+ * \(\begin{bmatrix}
+ * X_2 \\
+ * Y_2 \\
+ * Z_2 \\
+ * 1
+ * \end{bmatrix} = \begin{bmatrix}
+ * R & T \\
+ * 0 & 1
+ * \end{bmatrix} \begin{bmatrix}
+ * X_1 \\
+ * Y_1 \\
+ * Z_1 \\
+ * 1
+ * \end{bmatrix}.\)
+ *
+ *
+ * Optionally, it computes the essential matrix E:
+ *
+ * \(E= \vecthreethree{0}{-T_2}{T_1}{T_2}{0}{-T_0}{-T_1}{T_0}{0} R\)
+ *
+ * where \(T_i\) are components of the translation vector \(T\) : \(T=[T_0, T_1, T_2]^T\) .
+ * And the function can also compute the fundamental matrix F:
+ *
+ * \(F = cameraMatrix2^{-T}\cdot E \cdot cameraMatrix1^{-1}\)
+ *
+ * Besides the stereo-related information, the function can also perform a full calibration of each of
+ * the two cameras. However, due to the high dimensionality of the parameter space and noise in the
+ * input data, the function can diverge from the correct solution. If the intrinsic parameters can be
+ * estimated with high accuracy for each of the cameras individually (for example, using
+ * #calibrateCamera ), you are recommended to do so and then pass REF: CALIB_FIX_INTRINSIC flag to the
+ * function along with the computed intrinsic parameters. Otherwise, if all the parameters are
+ * estimated at once, it makes sense to restrict some parameters, for example, pass
+ * REF: CALIB_SAME_FOCAL_LENGTH and REF: CALIB_ZERO_TANGENT_DIST flags, which is usually a
+ * reasonable assumption.
+ *
+ * Similarly to #calibrateCamera, the function minimizes the total re-projection error for all the
+ * points in all the available views from both cameras. The function returns the final value of the
+ * re-projection error.
+ * @return automatically generated
+ */
+ public static double stereoCalibrateExtended(List objectPoints, List imagePoints1, List imagePoints2, Mat cameraMatrix1, Mat distCoeffs1, Mat cameraMatrix2, Mat distCoeffs2, Size imageSize, Mat R, Mat T, Mat E, Mat F, List rvecs, List tvecs, Mat perViewErrors) {
+ Mat objectPoints_mat = Converters.vector_Mat_to_Mat(objectPoints);
+ Mat imagePoints1_mat = Converters.vector_Mat_to_Mat(imagePoints1);
+ Mat imagePoints2_mat = Converters.vector_Mat_to_Mat(imagePoints2);
+ Mat rvecs_mat = new Mat();
+ Mat tvecs_mat = new Mat();
+ double retVal = stereoCalibrateExtended_2(objectPoints_mat.nativeObj, imagePoints1_mat.nativeObj, imagePoints2_mat.nativeObj, cameraMatrix1.nativeObj, distCoeffs1.nativeObj, cameraMatrix2.nativeObj, distCoeffs2.nativeObj, imageSize.width, imageSize.height, R.nativeObj, T.nativeObj, E.nativeObj, F.nativeObj, rvecs_mat.nativeObj, tvecs_mat.nativeObj, perViewErrors.nativeObj);
+ Converters.Mat_to_vector_Mat(rvecs_mat, rvecs);
+ rvecs_mat.release();
+ Converters.Mat_to_vector_Mat(tvecs_mat, tvecs);
+ tvecs_mat.release();
+ return retVal;
+ }
+
+
+ //
+ // C++: double cv::stereoCalibrate(vector_Mat objectPoints, vector_Mat imagePoints1, vector_Mat imagePoints2, Mat& cameraMatrix1, Mat& distCoeffs1, Mat& cameraMatrix2, Mat& distCoeffs2, Size imageSize, Mat& R, Mat& T, Mat& E, Mat& F, int flags = CALIB_FIX_INTRINSIC, TermCriteria criteria = TermCriteria(TermCriteria::COUNT+TermCriteria::EPS, 30, 1e-6))
+ //
+
+ public static double stereoCalibrate(List objectPoints, List imagePoints1, List imagePoints2, Mat cameraMatrix1, Mat distCoeffs1, Mat cameraMatrix2, Mat distCoeffs2, Size imageSize, Mat R, Mat T, Mat E, Mat F, int flags, TermCriteria criteria) {
+ Mat objectPoints_mat = Converters.vector_Mat_to_Mat(objectPoints);
+ Mat imagePoints1_mat = Converters.vector_Mat_to_Mat(imagePoints1);
+ Mat imagePoints2_mat = Converters.vector_Mat_to_Mat(imagePoints2);
+ return stereoCalibrate_0(objectPoints_mat.nativeObj, imagePoints1_mat.nativeObj, imagePoints2_mat.nativeObj, cameraMatrix1.nativeObj, distCoeffs1.nativeObj, cameraMatrix2.nativeObj, distCoeffs2.nativeObj, imageSize.width, imageSize.height, R.nativeObj, T.nativeObj, E.nativeObj, F.nativeObj, flags, criteria.type, criteria.maxCount, criteria.epsilon);
+ }
+
+ public static double stereoCalibrate(List objectPoints, List imagePoints1, List imagePoints2, Mat cameraMatrix1, Mat distCoeffs1, Mat cameraMatrix2, Mat distCoeffs2, Size imageSize, Mat R, Mat T, Mat E, Mat F, int flags) {
+ Mat objectPoints_mat = Converters.vector_Mat_to_Mat(objectPoints);
+ Mat imagePoints1_mat = Converters.vector_Mat_to_Mat(imagePoints1);
+ Mat imagePoints2_mat = Converters.vector_Mat_to_Mat(imagePoints2);
+ return stereoCalibrate_1(objectPoints_mat.nativeObj, imagePoints1_mat.nativeObj, imagePoints2_mat.nativeObj, cameraMatrix1.nativeObj, distCoeffs1.nativeObj, cameraMatrix2.nativeObj, distCoeffs2.nativeObj, imageSize.width, imageSize.height, R.nativeObj, T.nativeObj, E.nativeObj, F.nativeObj, flags);
+ }
+
+ public static double stereoCalibrate(List objectPoints, List imagePoints1, List imagePoints2, Mat cameraMatrix1, Mat distCoeffs1, Mat cameraMatrix2, Mat distCoeffs2, Size imageSize, Mat R, Mat T, Mat E, Mat F) {
+ Mat objectPoints_mat = Converters.vector_Mat_to_Mat(objectPoints);
+ Mat imagePoints1_mat = Converters.vector_Mat_to_Mat(imagePoints1);
+ Mat imagePoints2_mat = Converters.vector_Mat_to_Mat(imagePoints2);
+ return stereoCalibrate_2(objectPoints_mat.nativeObj, imagePoints1_mat.nativeObj, imagePoints2_mat.nativeObj, cameraMatrix1.nativeObj, distCoeffs1.nativeObj, cameraMatrix2.nativeObj, distCoeffs2.nativeObj, imageSize.width, imageSize.height, R.nativeObj, T.nativeObj, E.nativeObj, F.nativeObj);
+ }
+
+
+ //
+ // C++: double cv::stereoCalibrate(vector_Mat objectPoints, vector_Mat imagePoints1, vector_Mat imagePoints2, Mat& cameraMatrix1, Mat& distCoeffs1, Mat& cameraMatrix2, Mat& distCoeffs2, Size imageSize, Mat& R, Mat& T, Mat& E, Mat& F, Mat& perViewErrors, int flags = CALIB_FIX_INTRINSIC, TermCriteria criteria = TermCriteria(TermCriteria::COUNT+TermCriteria::EPS, 30, 1e-6))
+ //
+
+ public static double stereoCalibrate(List objectPoints, List imagePoints1, List imagePoints2, Mat cameraMatrix1, Mat distCoeffs1, Mat cameraMatrix2, Mat distCoeffs2, Size imageSize, Mat R, Mat T, Mat E, Mat F, Mat perViewErrors, int flags, TermCriteria criteria) {
+ Mat objectPoints_mat = Converters.vector_Mat_to_Mat(objectPoints);
+ Mat imagePoints1_mat = Converters.vector_Mat_to_Mat(imagePoints1);
+ Mat imagePoints2_mat = Converters.vector_Mat_to_Mat(imagePoints2);
+ return stereoCalibrate_3(objectPoints_mat.nativeObj, imagePoints1_mat.nativeObj, imagePoints2_mat.nativeObj, cameraMatrix1.nativeObj, distCoeffs1.nativeObj, cameraMatrix2.nativeObj, distCoeffs2.nativeObj, imageSize.width, imageSize.height, R.nativeObj, T.nativeObj, E.nativeObj, F.nativeObj, perViewErrors.nativeObj, flags, criteria.type, criteria.maxCount, criteria.epsilon);
+ }
+
+ public static double stereoCalibrate(List objectPoints, List imagePoints1, List imagePoints2, Mat cameraMatrix1, Mat distCoeffs1, Mat cameraMatrix2, Mat distCoeffs2, Size imageSize, Mat R, Mat T, Mat E, Mat F, Mat perViewErrors, int flags) {
+ Mat objectPoints_mat = Converters.vector_Mat_to_Mat(objectPoints);
+ Mat imagePoints1_mat = Converters.vector_Mat_to_Mat(imagePoints1);
+ Mat imagePoints2_mat = Converters.vector_Mat_to_Mat(imagePoints2);
+ return stereoCalibrate_4(objectPoints_mat.nativeObj, imagePoints1_mat.nativeObj, imagePoints2_mat.nativeObj, cameraMatrix1.nativeObj, distCoeffs1.nativeObj, cameraMatrix2.nativeObj, distCoeffs2.nativeObj, imageSize.width, imageSize.height, R.nativeObj, T.nativeObj, E.nativeObj, F.nativeObj, perViewErrors.nativeObj, flags);
+ }
+
+ public static double stereoCalibrate(List objectPoints, List imagePoints1, List imagePoints2, Mat cameraMatrix1, Mat distCoeffs1, Mat cameraMatrix2, Mat distCoeffs2, Size imageSize, Mat R, Mat T, Mat E, Mat F, Mat perViewErrors) {
+ Mat objectPoints_mat = Converters.vector_Mat_to_Mat(objectPoints);
+ Mat imagePoints1_mat = Converters.vector_Mat_to_Mat(imagePoints1);
+ Mat imagePoints2_mat = Converters.vector_Mat_to_Mat(imagePoints2);
+ return stereoCalibrate_5(objectPoints_mat.nativeObj, imagePoints1_mat.nativeObj, imagePoints2_mat.nativeObj, cameraMatrix1.nativeObj, distCoeffs1.nativeObj, cameraMatrix2.nativeObj, distCoeffs2.nativeObj, imageSize.width, imageSize.height, R.nativeObj, T.nativeObj, E.nativeObj, F.nativeObj, perViewErrors.nativeObj);
+ }
+
+
+ //
+ // C++: void cv::stereoRectify(Mat cameraMatrix1, Mat distCoeffs1, Mat cameraMatrix2, Mat distCoeffs2, Size imageSize, Mat R, Mat T, Mat& R1, Mat& R2, Mat& P1, Mat& P2, Mat& Q, int flags = CALIB_ZERO_DISPARITY, double alpha = -1, Size newImageSize = Size(), Rect* validPixROI1 = 0, Rect* validPixROI2 = 0)
+ //
+
+ /**
+ * Computes rectification transforms for each head of a calibrated stereo camera.
+ *
+ * @param cameraMatrix1 First camera intrinsic matrix.
+ * @param distCoeffs1 First camera distortion parameters.
+ * @param cameraMatrix2 Second camera intrinsic matrix.
+ * @param distCoeffs2 Second camera distortion parameters.
+ * @param imageSize Size of the image used for stereo calibration.
+ * @param R Rotation matrix from the coordinate system of the first camera to the second camera,
+ * see REF: stereoCalibrate.
+ * @param T Translation vector from the coordinate system of the first camera to the second camera,
+ * see REF: stereoCalibrate.
+ * @param R1 Output 3x3 rectification transform (rotation matrix) for the first camera. This matrix
+ * brings points given in the unrectified first camera's coordinate system to points in the rectified
+ * first camera's coordinate system. In more technical terms, it performs a change of basis from the
+ * unrectified first camera's coordinate system to the rectified first camera's coordinate system.
+ * @param R2 Output 3x3 rectification transform (rotation matrix) for the second camera. This matrix
+ * brings points given in the unrectified second camera's coordinate system to points in the rectified
+ * second camera's coordinate system. In more technical terms, it performs a change of basis from the
+ * unrectified second camera's coordinate system to the rectified second camera's coordinate system.
+ * @param P1 Output 3x4 projection matrix in the new (rectified) coordinate systems for the first
+ * camera, i.e. it projects points given in the rectified first camera coordinate system into the
+ * rectified first camera's image.
+ * @param P2 Output 3x4 projection matrix in the new (rectified) coordinate systems for the second
+ * camera, i.e. it projects points given in the rectified first camera coordinate system into the
+ * rectified second camera's image.
+ * @param Q Output \(4 \times 4\) disparity-to-depth mapping matrix (see REF: reprojectImageTo3D).
+ * @param flags Operation flags that may be zero or REF: CALIB_ZERO_DISPARITY . If the flag is set,
+ * the function makes the principal points of each camera have the same pixel coordinates in the
+ * rectified views. And if the flag is not set, the function may still shift the images in the
+ * horizontal or vertical direction (depending on the orientation of epipolar lines) to maximize the
+ * useful image area.
+ * @param alpha Free scaling parameter. If it is -1 or absent, the function performs the default
+ * scaling. Otherwise, the parameter should be between 0 and 1. alpha=0 means that the rectified
+ * images are zoomed and shifted so that only valid pixels are visible (no black areas after
+ * rectification). alpha=1 means that the rectified image is decimated and shifted so that all the
+ * pixels from the original images from the cameras are retained in the rectified images (no source
+ * image pixels are lost). Any intermediate value yields an intermediate result between
+ * those two extreme cases.
+ * @param newImageSize New image resolution after rectification. The same size should be passed to
+ * #initUndistortRectifyMap (see the stereo_calib.cpp sample in OpenCV samples directory). When (0,0)
+ * is passed (default), it is set to the original imageSize . Setting it to a larger value can help you
+ * preserve details in the original image, especially when there is a big radial distortion.
+ * @param validPixROI1 Optional output rectangles inside the rectified images where all the pixels
+ * are valid. If alpha=0 , the ROIs cover the whole images. Otherwise, they are likely to be smaller
+ * (see the picture below).
+ * @param validPixROI2 Optional output rectangles inside the rectified images where all the pixels
+ * are valid. If alpha=0 , the ROIs cover the whole images. Otherwise, they are likely to be smaller
+ * (see the picture below).
+ *
+ * The function computes the rotation matrices for each camera that (virtually) make both camera image
+ * planes the same plane. Consequently, this makes all the epipolar lines parallel and thus simplifies
+ * the dense stereo correspondence problem. The function takes the matrices computed by #stereoCalibrate
+ * as input. As output, it provides two rotation matrices and also two projection matrices in the new
+ * coordinates. The function distinguishes the following two cases:
+ *
+ *
+ *
+ * Horizontal stereo: the first and the second camera views are shifted relative to each other
+ * mainly along the x-axis (with possible small vertical shift). In the rectified images, the
+ * corresponding epipolar lines in the left and right cameras are horizontal and have the same
+ * y-coordinate. P1 and P2 look like:
+ *
+ * Vertical stereo: the first and the second camera views are shifted relative to each other
+ * mainly in the vertical direction (and probably a bit in the horizontal direction too). The epipolar
+ * lines in the rectified images are vertical and have the same x-coordinate. P1 and P2 look like:
+ *
+ *
+ *
+ * \(\texttt{P1} = \begin{bmatrix}
+ * f & 0 & cx & 0 \\
+ * 0 & f & cy_1 & 0 \\
+ * 0 & 0 & 1 & 0
+ * \end{bmatrix}\)
+ *
+ * \(\texttt{P2} = \begin{bmatrix}
+ * f & 0 & cx & 0 \\
+ * 0 & f & cy_2 & T_y \cdot f \\
+ * 0 & 0 & 1 & 0
+ * \end{bmatrix},\)
+ *
+ * \(\texttt{Q} = \begin{bmatrix}
+ * 1 & 0 & 0 & -cx \\
+ * 0 & 1 & 0 & -cy_1 \\
+ * 0 & 0 & 0 & f \\
+ * 0 & 0 & -\frac{1}{T_y} & \frac{cy_1 - cy_2}{T_y}
+ * \end{bmatrix} \)
+ *
+ * where \(T_y\) is a vertical shift between the cameras and \(cy_1=cy_2\) if
+ * REF: CALIB_ZERO_DISPARITY is set.
+ *
+ * As you can see, the first three columns of P1 and P2 will effectively be the new "rectified" camera
+ * matrices. The matrices, together with R1 and R2 , can then be passed to #initUndistortRectifyMap to
+ * initialize the rectification map for each camera.
+ *
+ * See below the screenshot from the stereo_calib.cpp sample. Some red horizontal lines pass through
+ * the corresponding image regions. This means that the images are well rectified, which is what most
+ * stereo correspondence algorithms rely on. The green rectangles are roi1 and roi2 . You see that
+ * their interiors are all valid pixels.
+ *
+ * 
+ */
+ public static void stereoRectify(Mat cameraMatrix1, Mat distCoeffs1, Mat cameraMatrix2, Mat distCoeffs2, Size imageSize, Mat R, Mat T, Mat R1, Mat R2, Mat P1, Mat P2, Mat Q, int flags, double alpha, Size newImageSize, Rect validPixROI1, Rect validPixROI2) {
+ double[] validPixROI1_out = new double[4];
+ double[] validPixROI2_out = new double[4];
+ stereoRectify_0(cameraMatrix1.nativeObj, distCoeffs1.nativeObj, cameraMatrix2.nativeObj, distCoeffs2.nativeObj, imageSize.width, imageSize.height, R.nativeObj, T.nativeObj, R1.nativeObj, R2.nativeObj, P1.nativeObj, P2.nativeObj, Q.nativeObj, flags, alpha, newImageSize.width, newImageSize.height, validPixROI1_out, validPixROI2_out);
+ if(validPixROI1!=null){ validPixROI1.x = (int)validPixROI1_out[0]; validPixROI1.y = (int)validPixROI1_out[1]; validPixROI1.width = (int)validPixROI1_out[2]; validPixROI1.height = (int)validPixROI1_out[3]; }
+ if(validPixROI2!=null){ validPixROI2.x = (int)validPixROI2_out[0]; validPixROI2.y = (int)validPixROI2_out[1]; validPixROI2.width = (int)validPixROI2_out[2]; validPixROI2.height = (int)validPixROI2_out[3]; }
+ }
+
+ /**
+ * Computes rectification transforms for each head of a calibrated stereo camera.
+ *
+ * @param cameraMatrix1 First camera intrinsic matrix.
+ * @param distCoeffs1 First camera distortion parameters.
+ * @param cameraMatrix2 Second camera intrinsic matrix.
+ * @param distCoeffs2 Second camera distortion parameters.
+ * @param imageSize Size of the image used for stereo calibration.
+ * @param R Rotation matrix from the coordinate system of the first camera to the second camera,
+ * see REF: stereoCalibrate.
+ * @param T Translation vector from the coordinate system of the first camera to the second camera,
+ * see REF: stereoCalibrate.
+ * @param R1 Output 3x3 rectification transform (rotation matrix) for the first camera. This matrix
+ * brings points given in the unrectified first camera's coordinate system to points in the rectified
+ * first camera's coordinate system. In more technical terms, it performs a change of basis from the
+ * unrectified first camera's coordinate system to the rectified first camera's coordinate system.
+ * @param R2 Output 3x3 rectification transform (rotation matrix) for the second camera. This matrix
+ * brings points given in the unrectified second camera's coordinate system to points in the rectified
+ * second camera's coordinate system. In more technical terms, it performs a change of basis from the
+ * unrectified second camera's coordinate system to the rectified second camera's coordinate system.
+ * @param P1 Output 3x4 projection matrix in the new (rectified) coordinate systems for the first
+ * camera, i.e. it projects points given in the rectified first camera coordinate system into the
+ * rectified first camera's image.
+ * @param P2 Output 3x4 projection matrix in the new (rectified) coordinate systems for the second
+ * camera, i.e. it projects points given in the rectified first camera coordinate system into the
+ * rectified second camera's image.
+ * @param Q Output \(4 \times 4\) disparity-to-depth mapping matrix (see REF: reprojectImageTo3D).
+ * @param flags Operation flags that may be zero or REF: CALIB_ZERO_DISPARITY . If the flag is set,
+ * the function makes the principal points of each camera have the same pixel coordinates in the
+ * rectified views. And if the flag is not set, the function may still shift the images in the
+ * horizontal or vertical direction (depending on the orientation of epipolar lines) to maximize the
+ * useful image area.
+ * @param alpha Free scaling parameter. If it is -1 or absent, the function performs the default
+ * scaling. Otherwise, the parameter should be between 0 and 1. alpha=0 means that the rectified
+ * images are zoomed and shifted so that only valid pixels are visible (no black areas after
+ * rectification). alpha=1 means that the rectified image is decimated and shifted so that all the
+ * pixels from the original images from the cameras are retained in the rectified images (no source
+ * image pixels are lost). Any intermediate value yields an intermediate result between
+ * those two extreme cases.
+ * @param newImageSize New image resolution after rectification. The same size should be passed to
+ * #initUndistortRectifyMap (see the stereo_calib.cpp sample in OpenCV samples directory). When (0,0)
+ * is passed (default), it is set to the original imageSize . Setting it to a larger value can help you
+ * preserve details in the original image, especially when there is a big radial distortion.
+ * @param validPixROI1 Optional output rectangles inside the rectified images where all the pixels
+ * are valid. If alpha=0 , the ROIs cover the whole images. Otherwise, they are likely to be smaller
+ * (see the picture below).
+ * are valid. If alpha=0 , the ROIs cover the whole images. Otherwise, they are likely to be smaller
+ * (see the picture below).
+ *
+ * The function computes the rotation matrices for each camera that (virtually) make both camera image
+ * planes the same plane. Consequently, this makes all the epipolar lines parallel and thus simplifies
+ * the dense stereo correspondence problem. The function takes the matrices computed by #stereoCalibrate
+ * as input. As output, it provides two rotation matrices and also two projection matrices in the new
+ * coordinates. The function distinguishes the following two cases:
+ *
+ *
+ *
+ * Horizontal stereo: the first and the second camera views are shifted relative to each other
+ * mainly along the x-axis (with possible small vertical shift). In the rectified images, the
+ * corresponding epipolar lines in the left and right cameras are horizontal and have the same
+ * y-coordinate. P1 and P2 look like:
+ *
+ * Vertical stereo: the first and the second camera views are shifted relative to each other
+ * mainly in the vertical direction (and probably a bit in the horizontal direction too). The epipolar
+ * lines in the rectified images are vertical and have the same x-coordinate. P1 and P2 look like:
+ *
+ *
+ *
+ * \(\texttt{P1} = \begin{bmatrix}
+ * f & 0 & cx & 0 \\
+ * 0 & f & cy_1 & 0 \\
+ * 0 & 0 & 1 & 0
+ * \end{bmatrix}\)
+ *
+ * \(\texttt{P2} = \begin{bmatrix}
+ * f & 0 & cx & 0 \\
+ * 0 & f & cy_2 & T_y \cdot f \\
+ * 0 & 0 & 1 & 0
+ * \end{bmatrix},\)
+ *
+ * \(\texttt{Q} = \begin{bmatrix}
+ * 1 & 0 & 0 & -cx \\
+ * 0 & 1 & 0 & -cy_1 \\
+ * 0 & 0 & 0 & f \\
+ * 0 & 0 & -\frac{1}{T_y} & \frac{cy_1 - cy_2}{T_y}
+ * \end{bmatrix} \)
+ *
+ * where \(T_y\) is a vertical shift between the cameras and \(cy_1=cy_2\) if
+ * REF: CALIB_ZERO_DISPARITY is set.
+ *
+ * As you can see, the first three columns of P1 and P2 will effectively be the new "rectified" camera
+ * matrices. The matrices, together with R1 and R2 , can then be passed to #initUndistortRectifyMap to
+ * initialize the rectification map for each camera.
+ *
+ * See below the screenshot from the stereo_calib.cpp sample. Some red horizontal lines pass through
+ * the corresponding image regions. This means that the images are well rectified, which is what most
+ * stereo correspondence algorithms rely on. The green rectangles are roi1 and roi2 . You see that
+ * their interiors are all valid pixels.
+ *
+ * 
+ */
+ public static void stereoRectify(Mat cameraMatrix1, Mat distCoeffs1, Mat cameraMatrix2, Mat distCoeffs2, Size imageSize, Mat R, Mat T, Mat R1, Mat R2, Mat P1, Mat P2, Mat Q, int flags, double alpha, Size newImageSize, Rect validPixROI1) {
+ double[] validPixROI1_out = new double[4];
+ stereoRectify_1(cameraMatrix1.nativeObj, distCoeffs1.nativeObj, cameraMatrix2.nativeObj, distCoeffs2.nativeObj, imageSize.width, imageSize.height, R.nativeObj, T.nativeObj, R1.nativeObj, R2.nativeObj, P1.nativeObj, P2.nativeObj, Q.nativeObj, flags, alpha, newImageSize.width, newImageSize.height, validPixROI1_out);
+ if(validPixROI1!=null){ validPixROI1.x = (int)validPixROI1_out[0]; validPixROI1.y = (int)validPixROI1_out[1]; validPixROI1.width = (int)validPixROI1_out[2]; validPixROI1.height = (int)validPixROI1_out[3]; }
+ }
+
+ /**
+ * Computes rectification transforms for each head of a calibrated stereo camera.
+ *
+ * @param cameraMatrix1 First camera intrinsic matrix.
+ * @param distCoeffs1 First camera distortion parameters.
+ * @param cameraMatrix2 Second camera intrinsic matrix.
+ * @param distCoeffs2 Second camera distortion parameters.
+ * @param imageSize Size of the image used for stereo calibration.
+ * @param R Rotation matrix from the coordinate system of the first camera to the second camera,
+ * see REF: stereoCalibrate.
+ * @param T Translation vector from the coordinate system of the first camera to the second camera,
+ * see REF: stereoCalibrate.
+ * @param R1 Output 3x3 rectification transform (rotation matrix) for the first camera. This matrix
+ * brings points given in the unrectified first camera's coordinate system to points in the rectified
+ * first camera's coordinate system. In more technical terms, it performs a change of basis from the
+ * unrectified first camera's coordinate system to the rectified first camera's coordinate system.
+ * @param R2 Output 3x3 rectification transform (rotation matrix) for the second camera. This matrix
+ * brings points given in the unrectified second camera's coordinate system to points in the rectified
+ * second camera's coordinate system. In more technical terms, it performs a change of basis from the
+ * unrectified second camera's coordinate system to the rectified second camera's coordinate system.
+ * @param P1 Output 3x4 projection matrix in the new (rectified) coordinate systems for the first
+ * camera, i.e. it projects points given in the rectified first camera coordinate system into the
+ * rectified first camera's image.
+ * @param P2 Output 3x4 projection matrix in the new (rectified) coordinate systems for the second
+ * camera, i.e. it projects points given in the rectified first camera coordinate system into the
+ * rectified second camera's image.
+ * @param Q Output \(4 \times 4\) disparity-to-depth mapping matrix (see REF: reprojectImageTo3D).
+ * @param flags Operation flags that may be zero or REF: CALIB_ZERO_DISPARITY . If the flag is set,
+ * the function makes the principal points of each camera have the same pixel coordinates in the
+ * rectified views. And if the flag is not set, the function may still shift the images in the
+ * horizontal or vertical direction (depending on the orientation of epipolar lines) to maximize the
+ * useful image area.
+ * @param alpha Free scaling parameter. If it is -1 or absent, the function performs the default
+ * scaling. Otherwise, the parameter should be between 0 and 1. alpha=0 means that the rectified
+ * images are zoomed and shifted so that only valid pixels are visible (no black areas after
+ * rectification). alpha=1 means that the rectified image is decimated and shifted so that all the
+ * pixels from the original images from the cameras are retained in the rectified images (no source
+ * image pixels are lost). Any intermediate value yields an intermediate result between
+ * those two extreme cases.
+ * @param newImageSize New image resolution after rectification. The same size should be passed to
+ * #initUndistortRectifyMap (see the stereo_calib.cpp sample in OpenCV samples directory). When (0,0)
+ * is passed (default), it is set to the original imageSize . Setting it to a larger value can help you
+ * preserve details in the original image, especially when there is a big radial distortion.
+ * are valid. If alpha=0 , the ROIs cover the whole images. Otherwise, they are likely to be smaller
+ * (see the picture below).
+ * are valid. If alpha=0 , the ROIs cover the whole images. Otherwise, they are likely to be smaller
+ * (see the picture below).
+ *
+ * The function computes the rotation matrices for each camera that (virtually) make both camera image
+ * planes the same plane. Consequently, this makes all the epipolar lines parallel and thus simplifies
+ * the dense stereo correspondence problem. The function takes the matrices computed by #stereoCalibrate
+ * as input. As output, it provides two rotation matrices and also two projection matrices in the new
+ * coordinates. The function distinguishes the following two cases:
+ *
+ *
+ *
+ * Horizontal stereo: the first and the second camera views are shifted relative to each other
+ * mainly along the x-axis (with possible small vertical shift). In the rectified images, the
+ * corresponding epipolar lines in the left and right cameras are horizontal and have the same
+ * y-coordinate. P1 and P2 look like:
+ *
+ * Vertical stereo: the first and the second camera views are shifted relative to each other
+ * mainly in the vertical direction (and probably a bit in the horizontal direction too). The epipolar
+ * lines in the rectified images are vertical and have the same x-coordinate. P1 and P2 look like:
+ *
+ *
+ *
+ * \(\texttt{P1} = \begin{bmatrix}
+ * f & 0 & cx & 0 \\
+ * 0 & f & cy_1 & 0 \\
+ * 0 & 0 & 1 & 0
+ * \end{bmatrix}\)
+ *
+ * \(\texttt{P2} = \begin{bmatrix}
+ * f & 0 & cx & 0 \\
+ * 0 & f & cy_2 & T_y \cdot f \\
+ * 0 & 0 & 1 & 0
+ * \end{bmatrix},\)
+ *
+ * \(\texttt{Q} = \begin{bmatrix}
+ * 1 & 0 & 0 & -cx \\
+ * 0 & 1 & 0 & -cy_1 \\
+ * 0 & 0 & 0 & f \\
+ * 0 & 0 & -\frac{1}{T_y} & \frac{cy_1 - cy_2}{T_y}
+ * \end{bmatrix} \)
+ *
+ * where \(T_y\) is a vertical shift between the cameras and \(cy_1=cy_2\) if
+ * REF: CALIB_ZERO_DISPARITY is set.
+ *
+ * As you can see, the first three columns of P1 and P2 will effectively be the new "rectified" camera
+ * matrices. The matrices, together with R1 and R2 , can then be passed to #initUndistortRectifyMap to
+ * initialize the rectification map for each camera.
+ *
+ * See below the screenshot from the stereo_calib.cpp sample. Some red horizontal lines pass through
+ * the corresponding image regions. This means that the images are well rectified, which is what most
+ * stereo correspondence algorithms rely on. The green rectangles are roi1 and roi2 . You see that
+ * their interiors are all valid pixels.
+ *
+ * 
+ */
+ public static void stereoRectify(Mat cameraMatrix1, Mat distCoeffs1, Mat cameraMatrix2, Mat distCoeffs2, Size imageSize, Mat R, Mat T, Mat R1, Mat R2, Mat P1, Mat P2, Mat Q, int flags, double alpha, Size newImageSize) {
+ stereoRectify_2(cameraMatrix1.nativeObj, distCoeffs1.nativeObj, cameraMatrix2.nativeObj, distCoeffs2.nativeObj, imageSize.width, imageSize.height, R.nativeObj, T.nativeObj, R1.nativeObj, R2.nativeObj, P1.nativeObj, P2.nativeObj, Q.nativeObj, flags, alpha, newImageSize.width, newImageSize.height);
+ }
+
+ /**
+ * Computes rectification transforms for each head of a calibrated stereo camera.
+ *
+ * @param cameraMatrix1 First camera intrinsic matrix.
+ * @param distCoeffs1 First camera distortion parameters.
+ * @param cameraMatrix2 Second camera intrinsic matrix.
+ * @param distCoeffs2 Second camera distortion parameters.
+ * @param imageSize Size of the image used for stereo calibration.
+ * @param R Rotation matrix from the coordinate system of the first camera to the second camera,
+ * see REF: stereoCalibrate.
+ * @param T Translation vector from the coordinate system of the first camera to the second camera,
+ * see REF: stereoCalibrate.
+ * @param R1 Output 3x3 rectification transform (rotation matrix) for the first camera. This matrix
+ * brings points given in the unrectified first camera's coordinate system to points in the rectified
+ * first camera's coordinate system. In more technical terms, it performs a change of basis from the
+ * unrectified first camera's coordinate system to the rectified first camera's coordinate system.
+ * @param R2 Output 3x3 rectification transform (rotation matrix) for the second camera. This matrix
+ * brings points given in the unrectified second camera's coordinate system to points in the rectified
+ * second camera's coordinate system. In more technical terms, it performs a change of basis from the
+ * unrectified second camera's coordinate system to the rectified second camera's coordinate system.
+ * @param P1 Output 3x4 projection matrix in the new (rectified) coordinate systems for the first
+ * camera, i.e. it projects points given in the rectified first camera coordinate system into the
+ * rectified first camera's image.
+ * @param P2 Output 3x4 projection matrix in the new (rectified) coordinate systems for the second
+ * camera, i.e. it projects points given in the rectified first camera coordinate system into the
+ * rectified second camera's image.
+ * @param Q Output \(4 \times 4\) disparity-to-depth mapping matrix (see REF: reprojectImageTo3D).
+ * @param flags Operation flags that may be zero or REF: CALIB_ZERO_DISPARITY . If the flag is set,
+ * the function makes the principal points of each camera have the same pixel coordinates in the
+ * rectified views. And if the flag is not set, the function may still shift the images in the
+ * horizontal or vertical direction (depending on the orientation of epipolar lines) to maximize the
+ * useful image area.
+ * @param alpha Free scaling parameter. If it is -1 or absent, the function performs the default
+ * scaling. Otherwise, the parameter should be between 0 and 1. alpha=0 means that the rectified
+ * images are zoomed and shifted so that only valid pixels are visible (no black areas after
+ * rectification). alpha=1 means that the rectified image is decimated and shifted so that all the
+ * pixels from the original images from the cameras are retained in the rectified images (no source
+ * image pixels are lost). Any intermediate value yields an intermediate result between
+ * those two extreme cases.
+ * #initUndistortRectifyMap (see the stereo_calib.cpp sample in OpenCV samples directory). When (0,0)
+ * is passed (default), it is set to the original imageSize . Setting it to a larger value can help you
+ * preserve details in the original image, especially when there is a big radial distortion.
+ * are valid. If alpha=0 , the ROIs cover the whole images. Otherwise, they are likely to be smaller
+ * (see the picture below).
+ * are valid. If alpha=0 , the ROIs cover the whole images. Otherwise, they are likely to be smaller
+ * (see the picture below).
+ *
+ * The function computes the rotation matrices for each camera that (virtually) make both camera image
+ * planes the same plane. Consequently, this makes all the epipolar lines parallel and thus simplifies
+ * the dense stereo correspondence problem. The function takes the matrices computed by #stereoCalibrate
+ * as input. As output, it provides two rotation matrices and also two projection matrices in the new
+ * coordinates. The function distinguishes the following two cases:
+ *
+ *
+ *
+ * Horizontal stereo: the first and the second camera views are shifted relative to each other
+ * mainly along the x-axis (with possible small vertical shift). In the rectified images, the
+ * corresponding epipolar lines in the left and right cameras are horizontal and have the same
+ * y-coordinate. P1 and P2 look like:
+ *
+ * Vertical stereo: the first and the second camera views are shifted relative to each other
+ * mainly in the vertical direction (and probably a bit in the horizontal direction too). The epipolar
+ * lines in the rectified images are vertical and have the same x-coordinate. P1 and P2 look like:
+ *
+ *
+ *
+ * \(\texttt{P1} = \begin{bmatrix}
+ * f & 0 & cx & 0 \\
+ * 0 & f & cy_1 & 0 \\
+ * 0 & 0 & 1 & 0
+ * \end{bmatrix}\)
+ *
+ * \(\texttt{P2} = \begin{bmatrix}
+ * f & 0 & cx & 0 \\
+ * 0 & f & cy_2 & T_y \cdot f \\
+ * 0 & 0 & 1 & 0
+ * \end{bmatrix},\)
+ *
+ * \(\texttt{Q} = \begin{bmatrix}
+ * 1 & 0 & 0 & -cx \\
+ * 0 & 1 & 0 & -cy_1 \\
+ * 0 & 0 & 0 & f \\
+ * 0 & 0 & -\frac{1}{T_y} & \frac{cy_1 - cy_2}{T_y}
+ * \end{bmatrix} \)
+ *
+ * where \(T_y\) is a vertical shift between the cameras and \(cy_1=cy_2\) if
+ * REF: CALIB_ZERO_DISPARITY is set.
+ *
+ * As you can see, the first three columns of P1 and P2 will effectively be the new "rectified" camera
+ * matrices. The matrices, together with R1 and R2 , can then be passed to #initUndistortRectifyMap to
+ * initialize the rectification map for each camera.
+ *
+ * See below the screenshot from the stereo_calib.cpp sample. Some red horizontal lines pass through
+ * the corresponding image regions. This means that the images are well rectified, which is what most
+ * stereo correspondence algorithms rely on. The green rectangles are roi1 and roi2 . You see that
+ * their interiors are all valid pixels.
+ *
+ * 
+ */
+ public static void stereoRectify(Mat cameraMatrix1, Mat distCoeffs1, Mat cameraMatrix2, Mat distCoeffs2, Size imageSize, Mat R, Mat T, Mat R1, Mat R2, Mat P1, Mat P2, Mat Q, int flags, double alpha) {
+ stereoRectify_3(cameraMatrix1.nativeObj, distCoeffs1.nativeObj, cameraMatrix2.nativeObj, distCoeffs2.nativeObj, imageSize.width, imageSize.height, R.nativeObj, T.nativeObj, R1.nativeObj, R2.nativeObj, P1.nativeObj, P2.nativeObj, Q.nativeObj, flags, alpha);
+ }
+
+ /**
+ * Computes rectification transforms for each head of a calibrated stereo camera.
+ *
+ * @param cameraMatrix1 First camera intrinsic matrix.
+ * @param distCoeffs1 First camera distortion parameters.
+ * @param cameraMatrix2 Second camera intrinsic matrix.
+ * @param distCoeffs2 Second camera distortion parameters.
+ * @param imageSize Size of the image used for stereo calibration.
+ * @param R Rotation matrix from the coordinate system of the first camera to the second camera,
+ * see REF: stereoCalibrate.
+ * @param T Translation vector from the coordinate system of the first camera to the second camera,
+ * see REF: stereoCalibrate.
+ * @param R1 Output 3x3 rectification transform (rotation matrix) for the first camera. This matrix
+ * brings points given in the unrectified first camera's coordinate system to points in the rectified
+ * first camera's coordinate system. In more technical terms, it performs a change of basis from the
+ * unrectified first camera's coordinate system to the rectified first camera's coordinate system.
+ * @param R2 Output 3x3 rectification transform (rotation matrix) for the second camera. This matrix
+ * brings points given in the unrectified second camera's coordinate system to points in the rectified
+ * second camera's coordinate system. In more technical terms, it performs a change of basis from the
+ * unrectified second camera's coordinate system to the rectified second camera's coordinate system.
+ * @param P1 Output 3x4 projection matrix in the new (rectified) coordinate systems for the first
+ * camera, i.e. it projects points given in the rectified first camera coordinate system into the
+ * rectified first camera's image.
+ * @param P2 Output 3x4 projection matrix in the new (rectified) coordinate systems for the second
+ * camera, i.e. it projects points given in the rectified first camera coordinate system into the
+ * rectified second camera's image.
+ * @param Q Output \(4 \times 4\) disparity-to-depth mapping matrix (see REF: reprojectImageTo3D).
+ * @param flags Operation flags that may be zero or REF: CALIB_ZERO_DISPARITY . If the flag is set,
+ * the function makes the principal points of each camera have the same pixel coordinates in the
+ * rectified views. And if the flag is not set, the function may still shift the images in the
+ * horizontal or vertical direction (depending on the orientation of epipolar lines) to maximize the
+ * useful image area.
+ * scaling. Otherwise, the parameter should be between 0 and 1. alpha=0 means that the rectified
+ * images are zoomed and shifted so that only valid pixels are visible (no black areas after
+ * rectification). alpha=1 means that the rectified image is decimated and shifted so that all the
+ * pixels from the original images from the cameras are retained in the rectified images (no source
+ * image pixels are lost). Any intermediate value yields an intermediate result between
+ * those two extreme cases.
+ * #initUndistortRectifyMap (see the stereo_calib.cpp sample in OpenCV samples directory). When (0,0)
+ * is passed (default), it is set to the original imageSize . Setting it to a larger value can help you
+ * preserve details in the original image, especially when there is a big radial distortion.
+ * are valid. If alpha=0 , the ROIs cover the whole images. Otherwise, they are likely to be smaller
+ * (see the picture below).
+ * are valid. If alpha=0 , the ROIs cover the whole images. Otherwise, they are likely to be smaller
+ * (see the picture below).
+ *
+ * The function computes the rotation matrices for each camera that (virtually) make both camera image
+ * planes the same plane. Consequently, this makes all the epipolar lines parallel and thus simplifies
+ * the dense stereo correspondence problem. The function takes the matrices computed by #stereoCalibrate
+ * as input. As output, it provides two rotation matrices and also two projection matrices in the new
+ * coordinates. The function distinguishes the following two cases:
+ *
+ *
+ *
+ * Horizontal stereo: the first and the second camera views are shifted relative to each other
+ * mainly along the x-axis (with possible small vertical shift). In the rectified images, the
+ * corresponding epipolar lines in the left and right cameras are horizontal and have the same
+ * y-coordinate. P1 and P2 look like:
+ *
+ * Vertical stereo: the first and the second camera views are shifted relative to each other
+ * mainly in the vertical direction (and probably a bit in the horizontal direction too). The epipolar
+ * lines in the rectified images are vertical and have the same x-coordinate. P1 and P2 look like:
+ *
+ *
+ *
+ * \(\texttt{P1} = \begin{bmatrix}
+ * f & 0 & cx & 0 \\
+ * 0 & f & cy_1 & 0 \\
+ * 0 & 0 & 1 & 0
+ * \end{bmatrix}\)
+ *
+ * \(\texttt{P2} = \begin{bmatrix}
+ * f & 0 & cx & 0 \\
+ * 0 & f & cy_2 & T_y \cdot f \\
+ * 0 & 0 & 1 & 0
+ * \end{bmatrix},\)
+ *
+ * \(\texttt{Q} = \begin{bmatrix}
+ * 1 & 0 & 0 & -cx \\
+ * 0 & 1 & 0 & -cy_1 \\
+ * 0 & 0 & 0 & f \\
+ * 0 & 0 & -\frac{1}{T_y} & \frac{cy_1 - cy_2}{T_y}
+ * \end{bmatrix} \)
+ *
+ * where \(T_y\) is a vertical shift between the cameras and \(cy_1=cy_2\) if
+ * REF: CALIB_ZERO_DISPARITY is set.
+ *
+ * As you can see, the first three columns of P1 and P2 will effectively be the new "rectified" camera
+ * matrices. The matrices, together with R1 and R2 , can then be passed to #initUndistortRectifyMap to
+ * initialize the rectification map for each camera.
+ *
+ * See below the screenshot from the stereo_calib.cpp sample. Some red horizontal lines pass through
+ * the corresponding image regions. This means that the images are well rectified, which is what most
+ * stereo correspondence algorithms rely on. The green rectangles are roi1 and roi2 . You see that
+ * their interiors are all valid pixels.
+ *
+ * 
+ */
+ public static void stereoRectify(Mat cameraMatrix1, Mat distCoeffs1, Mat cameraMatrix2, Mat distCoeffs2, Size imageSize, Mat R, Mat T, Mat R1, Mat R2, Mat P1, Mat P2, Mat Q, int flags) {
+ stereoRectify_4(cameraMatrix1.nativeObj, distCoeffs1.nativeObj, cameraMatrix2.nativeObj, distCoeffs2.nativeObj, imageSize.width, imageSize.height, R.nativeObj, T.nativeObj, R1.nativeObj, R2.nativeObj, P1.nativeObj, P2.nativeObj, Q.nativeObj, flags);
+ }
+
+ /**
+ * Computes rectification transforms for each head of a calibrated stereo camera.
+ *
+ * @param cameraMatrix1 First camera intrinsic matrix.
+ * @param distCoeffs1 First camera distortion parameters.
+ * @param cameraMatrix2 Second camera intrinsic matrix.
+ * @param distCoeffs2 Second camera distortion parameters.
+ * @param imageSize Size of the image used for stereo calibration.
+ * @param R Rotation matrix from the coordinate system of the first camera to the second camera,
+ * see REF: stereoCalibrate.
+ * @param T Translation vector from the coordinate system of the first camera to the second camera,
+ * see REF: stereoCalibrate.
+ * @param R1 Output 3x3 rectification transform (rotation matrix) for the first camera. This matrix
+ * brings points given in the unrectified first camera's coordinate system to points in the rectified
+ * first camera's coordinate system. In more technical terms, it performs a change of basis from the
+ * unrectified first camera's coordinate system to the rectified first camera's coordinate system.
+ * @param R2 Output 3x3 rectification transform (rotation matrix) for the second camera. This matrix
+ * brings points given in the unrectified second camera's coordinate system to points in the rectified
+ * second camera's coordinate system. In more technical terms, it performs a change of basis from the
+ * unrectified second camera's coordinate system to the rectified second camera's coordinate system.
+ * @param P1 Output 3x4 projection matrix in the new (rectified) coordinate systems for the first
+ * camera, i.e. it projects points given in the rectified first camera coordinate system into the
+ * rectified first camera's image.
+ * @param P2 Output 3x4 projection matrix in the new (rectified) coordinate systems for the second
+ * camera, i.e. it projects points given in the rectified first camera coordinate system into the
+ * rectified second camera's image.
+ * @param Q Output \(4 \times 4\) disparity-to-depth mapping matrix (see REF: reprojectImageTo3D).
+ * the function makes the principal points of each camera have the same pixel coordinates in the
+ * rectified views. And if the flag is not set, the function may still shift the images in the
+ * horizontal or vertical direction (depending on the orientation of epipolar lines) to maximize the
+ * useful image area.
+ * scaling. Otherwise, the parameter should be between 0 and 1. alpha=0 means that the rectified
+ * images are zoomed and shifted so that only valid pixels are visible (no black areas after
+ * rectification). alpha=1 means that the rectified image is decimated and shifted so that all the
+ * pixels from the original images from the cameras are retained in the rectified images (no source
+ * image pixels are lost). Any intermediate value yields an intermediate result between
+ * those two extreme cases.
+ * #initUndistortRectifyMap (see the stereo_calib.cpp sample in OpenCV samples directory). When (0,0)
+ * is passed (default), it is set to the original imageSize . Setting it to a larger value can help you
+ * preserve details in the original image, especially when there is a big radial distortion.
+ * are valid. If alpha=0 , the ROIs cover the whole images. Otherwise, they are likely to be smaller
+ * (see the picture below).
+ * are valid. If alpha=0 , the ROIs cover the whole images. Otherwise, they are likely to be smaller
+ * (see the picture below).
+ *
+ * The function computes the rotation matrices for each camera that (virtually) make both camera image
+ * planes the same plane. Consequently, this makes all the epipolar lines parallel and thus simplifies
+ * the dense stereo correspondence problem. The function takes the matrices computed by #stereoCalibrate
+ * as input. As output, it provides two rotation matrices and also two projection matrices in the new
+ * coordinates. The function distinguishes the following two cases:
+ *
+ *
+ *
+ * Horizontal stereo: the first and the second camera views are shifted relative to each other
+ * mainly along the x-axis (with possible small vertical shift). In the rectified images, the
+ * corresponding epipolar lines in the left and right cameras are horizontal and have the same
+ * y-coordinate. P1 and P2 look like:
+ *
+ * Vertical stereo: the first and the second camera views are shifted relative to each other
+ * mainly in the vertical direction (and probably a bit in the horizontal direction too). The epipolar
+ * lines in the rectified images are vertical and have the same x-coordinate. P1 and P2 look like:
+ *
+ *
+ *
+ * \(\texttt{P1} = \begin{bmatrix}
+ * f & 0 & cx & 0 \\
+ * 0 & f & cy_1 & 0 \\
+ * 0 & 0 & 1 & 0
+ * \end{bmatrix}\)
+ *
+ * \(\texttt{P2} = \begin{bmatrix}
+ * f & 0 & cx & 0 \\
+ * 0 & f & cy_2 & T_y \cdot f \\
+ * 0 & 0 & 1 & 0
+ * \end{bmatrix},\)
+ *
+ * \(\texttt{Q} = \begin{bmatrix}
+ * 1 & 0 & 0 & -cx \\
+ * 0 & 1 & 0 & -cy_1 \\
+ * 0 & 0 & 0 & f \\
+ * 0 & 0 & -\frac{1}{T_y} & \frac{cy_1 - cy_2}{T_y}
+ * \end{bmatrix} \)
+ *
+ * where \(T_y\) is a vertical shift between the cameras and \(cy_1=cy_2\) if
+ * REF: CALIB_ZERO_DISPARITY is set.
+ *
+ * As you can see, the first three columns of P1 and P2 will effectively be the new "rectified" camera
+ * matrices. The matrices, together with R1 and R2 , can then be passed to #initUndistortRectifyMap to
+ * initialize the rectification map for each camera.
+ *
+ * See below the screenshot from the stereo_calib.cpp sample. Some red horizontal lines pass through
+ * the corresponding image regions. This means that the images are well rectified, which is what most
+ * stereo correspondence algorithms rely on. The green rectangles are roi1 and roi2 . You see that
+ * their interiors are all valid pixels.
+ *
+ * 
+ */
+ public static void stereoRectify(Mat cameraMatrix1, Mat distCoeffs1, Mat cameraMatrix2, Mat distCoeffs2, Size imageSize, Mat R, Mat T, Mat R1, Mat R2, Mat P1, Mat P2, Mat Q) {
+ stereoRectify_5(cameraMatrix1.nativeObj, distCoeffs1.nativeObj, cameraMatrix2.nativeObj, distCoeffs2.nativeObj, imageSize.width, imageSize.height, R.nativeObj, T.nativeObj, R1.nativeObj, R2.nativeObj, P1.nativeObj, P2.nativeObj, Q.nativeObj);
+ }
+
+
+ //
+ // C++: bool cv::stereoRectifyUncalibrated(Mat points1, Mat points2, Mat F, Size imgSize, Mat& H1, Mat& H2, double threshold = 5)
+ //
+
+ /**
+ * Computes a rectification transform for an uncalibrated stereo camera.
+ *
+ * @param points1 Array of feature points in the first image.
+ * @param points2 The corresponding points in the second image. The same formats as in
+ * #findFundamentalMat are supported.
+ * @param F Input fundamental matrix. It can be computed from the same set of point pairs using
+ * #findFundamentalMat .
+ * @param imgSize Size of the image.
+ * @param H1 Output rectification homography matrix for the first image.
+ * @param H2 Output rectification homography matrix for the second image.
+ * @param threshold Optional threshold used to filter out the outliers. If the parameter is greater
+ * than zero, all the point pairs that do not comply with the epipolar geometry (that is, the points
+ * for which \(|\texttt{points2[i]}^T \cdot \texttt{F} \cdot \texttt{points1[i]}|>\texttt{threshold}\) )
+ * are rejected prior to computing the homographies. Otherwise, all the points are considered inliers.
+ *
+ * The function computes the rectification transformations without knowing intrinsic parameters of the
+ * cameras and their relative position in the space, which explains the suffix "uncalibrated". Another
+ * related difference from #stereoRectify is that the function outputs not the rectification
+ * transformations in the object (3D) space, but the planar perspective transformations encoded by the
+ * homography matrices H1 and H2 . The function implements the algorithm CITE: Hartley99 .
+ *
+ * Note:
+ * While the algorithm does not need to know the intrinsic parameters of the cameras, it heavily
+ * depends on the epipolar geometry. Therefore, if the camera lenses have a significant distortion,
+ * it would be better to correct it before computing the fundamental matrix and calling this
+ * function. For example, distortion coefficients can be estimated for each head of stereo camera
+ * separately by using #calibrateCamera . Then, the images can be corrected using #undistort , or
+ * just the point coordinates can be corrected with #undistortPoints .
+ * @return automatically generated
+ */
+ public static boolean stereoRectifyUncalibrated(Mat points1, Mat points2, Mat F, Size imgSize, Mat H1, Mat H2, double threshold) {
+ return stereoRectifyUncalibrated_0(points1.nativeObj, points2.nativeObj, F.nativeObj, imgSize.width, imgSize.height, H1.nativeObj, H2.nativeObj, threshold);
+ }
+
+ /**
+ * Computes a rectification transform for an uncalibrated stereo camera.
+ *
+ * @param points1 Array of feature points in the first image.
+ * @param points2 The corresponding points in the second image. The same formats as in
+ * #findFundamentalMat are supported.
+ * @param F Input fundamental matrix. It can be computed from the same set of point pairs using
+ * #findFundamentalMat .
+ * @param imgSize Size of the image.
+ * @param H1 Output rectification homography matrix for the first image.
+ * @param H2 Output rectification homography matrix for the second image.
+ * than zero, all the point pairs that do not comply with the epipolar geometry (that is, the points
+ * for which \(|\texttt{points2[i]}^T \cdot \texttt{F} \cdot \texttt{points1[i]}|>\texttt{threshold}\) )
+ * are rejected prior to computing the homographies. Otherwise, all the points are considered inliers.
+ *
+ * The function computes the rectification transformations without knowing intrinsic parameters of the
+ * cameras and their relative position in the space, which explains the suffix "uncalibrated". Another
+ * related difference from #stereoRectify is that the function outputs not the rectification
+ * transformations in the object (3D) space, but the planar perspective transformations encoded by the
+ * homography matrices H1 and H2 . The function implements the algorithm CITE: Hartley99 .
+ *
+ * Note:
+ * While the algorithm does not need to know the intrinsic parameters of the cameras, it heavily
+ * depends on the epipolar geometry. Therefore, if the camera lenses have a significant distortion,
+ * it would be better to correct it before computing the fundamental matrix and calling this
+ * function. For example, distortion coefficients can be estimated for each head of stereo camera
+ * separately by using #calibrateCamera . Then, the images can be corrected using #undistort , or
+ * just the point coordinates can be corrected with #undistortPoints .
+ * @return automatically generated
+ */
+ public static boolean stereoRectifyUncalibrated(Mat points1, Mat points2, Mat F, Size imgSize, Mat H1, Mat H2) {
+ return stereoRectifyUncalibrated_1(points1.nativeObj, points2.nativeObj, F.nativeObj, imgSize.width, imgSize.height, H1.nativeObj, H2.nativeObj);
+ }
+
+
+ //
+ // C++: float cv::rectify3Collinear(Mat cameraMatrix1, Mat distCoeffs1, Mat cameraMatrix2, Mat distCoeffs2, Mat cameraMatrix3, Mat distCoeffs3, vector_Mat imgpt1, vector_Mat imgpt3, Size imageSize, Mat R12, Mat T12, Mat R13, Mat T13, Mat& R1, Mat& R2, Mat& R3, Mat& P1, Mat& P2, Mat& P3, Mat& Q, double alpha, Size newImgSize, Rect* roi1, Rect* roi2, int flags)
+ //
+
+ public static float rectify3Collinear(Mat cameraMatrix1, Mat distCoeffs1, Mat cameraMatrix2, Mat distCoeffs2, Mat cameraMatrix3, Mat distCoeffs3, List imgpt1, List imgpt3, Size imageSize, Mat R12, Mat T12, Mat R13, Mat T13, Mat R1, Mat R2, Mat R3, Mat P1, Mat P2, Mat P3, Mat Q, double alpha, Size newImgSize, Rect roi1, Rect roi2, int flags) {
+ Mat imgpt1_mat = Converters.vector_Mat_to_Mat(imgpt1);
+ Mat imgpt3_mat = Converters.vector_Mat_to_Mat(imgpt3);
+ double[] roi1_out = new double[4];
+ double[] roi2_out = new double[4];
+ float retVal = rectify3Collinear_0(cameraMatrix1.nativeObj, distCoeffs1.nativeObj, cameraMatrix2.nativeObj, distCoeffs2.nativeObj, cameraMatrix3.nativeObj, distCoeffs3.nativeObj, imgpt1_mat.nativeObj, imgpt3_mat.nativeObj, imageSize.width, imageSize.height, R12.nativeObj, T12.nativeObj, R13.nativeObj, T13.nativeObj, R1.nativeObj, R2.nativeObj, R3.nativeObj, P1.nativeObj, P2.nativeObj, P3.nativeObj, Q.nativeObj, alpha, newImgSize.width, newImgSize.height, roi1_out, roi2_out, flags);
+ if(roi1!=null){ roi1.x = (int)roi1_out[0]; roi1.y = (int)roi1_out[1]; roi1.width = (int)roi1_out[2]; roi1.height = (int)roi1_out[3]; }
+ if(roi2!=null){ roi2.x = (int)roi2_out[0]; roi2.y = (int)roi2_out[1]; roi2.width = (int)roi2_out[2]; roi2.height = (int)roi2_out[3]; }
+ return retVal;
+ }
+
+
+ //
+ // C++: Mat cv::getOptimalNewCameraMatrix(Mat cameraMatrix, Mat distCoeffs, Size imageSize, double alpha, Size newImgSize = Size(), Rect* validPixROI = 0, bool centerPrincipalPoint = false)
+ //
+
+ /**
+ * Returns the new camera intrinsic matrix based on the free scaling parameter.
+ *
+ * @param cameraMatrix Input camera intrinsic matrix.
+ * @param distCoeffs Input vector of distortion coefficients
+ * \(\distcoeffs\). If the vector is NULL/empty, the zero distortion coefficients are
+ * assumed.
+ * @param imageSize Original image size.
+ * @param alpha Free scaling parameter between 0 (when all the pixels in the undistorted image are
+ * valid) and 1 (when all the source image pixels are retained in the undistorted image). See
+ * #stereoRectify for details.
+ * @param newImgSize Image size after rectification. By default, it is set to imageSize .
+ * @param validPixROI Optional output rectangle that outlines all-good-pixels region in the
+ * undistorted image. See roi1, roi2 description in #stereoRectify .
+ * @param centerPrincipalPoint Optional flag that indicates whether in the new camera intrinsic matrix the
+ * principal point should be at the image center or not. By default, the principal point is chosen to
+ * best fit a subset of the source image (determined by alpha) to the corrected image.
+ * @return new_camera_matrix Output new camera intrinsic matrix.
+ *
+ * The function computes and returns the optimal new camera intrinsic matrix based on the free scaling parameter.
+ * By varying this parameter, you may retrieve only sensible pixels alpha=0 , keep all the original
+ * image pixels if there is valuable information in the corners alpha=1 , or get something in between.
+ * When alpha>0 , the undistorted result is likely to have some black pixels corresponding to
+ * "virtual" pixels outside of the captured distorted image. The original camera intrinsic matrix, distortion
+ * coefficients, the computed new camera intrinsic matrix, and newImageSize should be passed to
+ * #initUndistortRectifyMap to produce the maps for #remap .
+ */
+ public static Mat getOptimalNewCameraMatrix(Mat cameraMatrix, Mat distCoeffs, Size imageSize, double alpha, Size newImgSize, Rect validPixROI, boolean centerPrincipalPoint) {
+ double[] validPixROI_out = new double[4];
+ Mat retVal = new Mat(getOptimalNewCameraMatrix_0(cameraMatrix.nativeObj, distCoeffs.nativeObj, imageSize.width, imageSize.height, alpha, newImgSize.width, newImgSize.height, validPixROI_out, centerPrincipalPoint));
+ if(validPixROI!=null){ validPixROI.x = (int)validPixROI_out[0]; validPixROI.y = (int)validPixROI_out[1]; validPixROI.width = (int)validPixROI_out[2]; validPixROI.height = (int)validPixROI_out[3]; }
+ return retVal;
+ }
+
+ /**
+ * Returns the new camera intrinsic matrix based on the free scaling parameter.
+ *
+ * @param cameraMatrix Input camera intrinsic matrix.
+ * @param distCoeffs Input vector of distortion coefficients
+ * \(\distcoeffs\). If the vector is NULL/empty, the zero distortion coefficients are
+ * assumed.
+ * @param imageSize Original image size.
+ * @param alpha Free scaling parameter between 0 (when all the pixels in the undistorted image are
+ * valid) and 1 (when all the source image pixels are retained in the undistorted image). See
+ * #stereoRectify for details.
+ * @param newImgSize Image size after rectification. By default, it is set to imageSize .
+ * @param validPixROI Optional output rectangle that outlines all-good-pixels region in the
+ * undistorted image. See roi1, roi2 description in #stereoRectify .
+ * principal point should be at the image center or not. By default, the principal point is chosen to
+ * best fit a subset of the source image (determined by alpha) to the corrected image.
+ * @return new_camera_matrix Output new camera intrinsic matrix.
+ *
+ * The function computes and returns the optimal new camera intrinsic matrix based on the free scaling parameter.
+ * By varying this parameter, you may retrieve only sensible pixels alpha=0 , keep all the original
+ * image pixels if there is valuable information in the corners alpha=1 , or get something in between.
+ * When alpha>0 , the undistorted result is likely to have some black pixels corresponding to
+ * "virtual" pixels outside of the captured distorted image. The original camera intrinsic matrix, distortion
+ * coefficients, the computed new camera intrinsic matrix, and newImageSize should be passed to
+ * #initUndistortRectifyMap to produce the maps for #remap .
+ */
+ public static Mat getOptimalNewCameraMatrix(Mat cameraMatrix, Mat distCoeffs, Size imageSize, double alpha, Size newImgSize, Rect validPixROI) {
+ double[] validPixROI_out = new double[4];
+ Mat retVal = new Mat(getOptimalNewCameraMatrix_1(cameraMatrix.nativeObj, distCoeffs.nativeObj, imageSize.width, imageSize.height, alpha, newImgSize.width, newImgSize.height, validPixROI_out));
+ if(validPixROI!=null){ validPixROI.x = (int)validPixROI_out[0]; validPixROI.y = (int)validPixROI_out[1]; validPixROI.width = (int)validPixROI_out[2]; validPixROI.height = (int)validPixROI_out[3]; }
+ return retVal;
+ }
+
+ /**
+ * Returns the new camera intrinsic matrix based on the free scaling parameter.
+ *
+ * @param cameraMatrix Input camera intrinsic matrix.
+ * @param distCoeffs Input vector of distortion coefficients
+ * \(\distcoeffs\). If the vector is NULL/empty, the zero distortion coefficients are
+ * assumed.
+ * @param imageSize Original image size.
+ * @param alpha Free scaling parameter between 0 (when all the pixels in the undistorted image are
+ * valid) and 1 (when all the source image pixels are retained in the undistorted image). See
+ * #stereoRectify for details.
+ * @param newImgSize Image size after rectification. By default, it is set to imageSize .
+ * undistorted image. See roi1, roi2 description in #stereoRectify .
+ * principal point should be at the image center or not. By default, the principal point is chosen to
+ * best fit a subset of the source image (determined by alpha) to the corrected image.
+ * @return new_camera_matrix Output new camera intrinsic matrix.
+ *
+ * The function computes and returns the optimal new camera intrinsic matrix based on the free scaling parameter.
+ * By varying this parameter, you may retrieve only sensible pixels alpha=0 , keep all the original
+ * image pixels if there is valuable information in the corners alpha=1 , or get something in between.
+ * When alpha>0 , the undistorted result is likely to have some black pixels corresponding to
+ * "virtual" pixels outside of the captured distorted image. The original camera intrinsic matrix, distortion
+ * coefficients, the computed new camera intrinsic matrix, and newImageSize should be passed to
+ * #initUndistortRectifyMap to produce the maps for #remap .
+ */
+ public static Mat getOptimalNewCameraMatrix(Mat cameraMatrix, Mat distCoeffs, Size imageSize, double alpha, Size newImgSize) {
+ return new Mat(getOptimalNewCameraMatrix_2(cameraMatrix.nativeObj, distCoeffs.nativeObj, imageSize.width, imageSize.height, alpha, newImgSize.width, newImgSize.height));
+ }
+
+ /**
+ * Returns the new camera intrinsic matrix based on the free scaling parameter.
+ *
+ * @param cameraMatrix Input camera intrinsic matrix.
+ * @param distCoeffs Input vector of distortion coefficients
+ * \(\distcoeffs\). If the vector is NULL/empty, the zero distortion coefficients are
+ * assumed.
+ * @param imageSize Original image size.
+ * @param alpha Free scaling parameter between 0 (when all the pixels in the undistorted image are
+ * valid) and 1 (when all the source image pixels are retained in the undistorted image). See
+ * #stereoRectify for details.
+ * undistorted image. See roi1, roi2 description in #stereoRectify .
+ * principal point should be at the image center or not. By default, the principal point is chosen to
+ * best fit a subset of the source image (determined by alpha) to the corrected image.
+ * @return new_camera_matrix Output new camera intrinsic matrix.
+ *
+ * The function computes and returns the optimal new camera intrinsic matrix based on the free scaling parameter.
+ * By varying this parameter, you may retrieve only sensible pixels alpha=0 , keep all the original
+ * image pixels if there is valuable information in the corners alpha=1 , or get something in between.
+ * When alpha>0 , the undistorted result is likely to have some black pixels corresponding to
+ * "virtual" pixels outside of the captured distorted image. The original camera intrinsic matrix, distortion
+ * coefficients, the computed new camera intrinsic matrix, and newImageSize should be passed to
+ * #initUndistortRectifyMap to produce the maps for #remap .
+ */
+ public static Mat getOptimalNewCameraMatrix(Mat cameraMatrix, Mat distCoeffs, Size imageSize, double alpha) {
+ return new Mat(getOptimalNewCameraMatrix_3(cameraMatrix.nativeObj, distCoeffs.nativeObj, imageSize.width, imageSize.height, alpha));
+ }
+
+
+ //
+ // C++: void cv::calibrateHandEye(vector_Mat R_gripper2base, vector_Mat t_gripper2base, vector_Mat R_target2cam, vector_Mat t_target2cam, Mat& R_cam2gripper, Mat& t_cam2gripper, HandEyeCalibrationMethod method = CALIB_HAND_EYE_TSAI)
+ //
+
+ /**
+ * Computes Hand-Eye calibration: \(_{}^{g}\textrm{T}_c\)
+ *
+ * @param R_gripper2base Rotation part extracted from the homogeneous matrix that transforms a point
+ * expressed in the gripper frame to the robot base frame (\(_{}^{b}\textrm{T}_g\)).
+ * This is a vector ({@code vector<Mat>}) that contains the rotation, {@code (3x3)} rotation matrices or {@code (3x1)} rotation vectors,
+ * for all the transformations from gripper frame to robot base frame.
+ * @param t_gripper2base Translation part extracted from the homogeneous matrix that transforms a point
+ * expressed in the gripper frame to the robot base frame (\(_{}^{b}\textrm{T}_g\)).
+ * This is a vector ({@code vector<Mat>}) that contains the {@code (3x1)} translation vectors for all the transformations
+ * from gripper frame to robot base frame.
+ * @param R_target2cam Rotation part extracted from the homogeneous matrix that transforms a point
+ * expressed in the target frame to the camera frame (\(_{}^{c}\textrm{T}_t\)).
+ * This is a vector ({@code vector<Mat>}) that contains the rotation, {@code (3x3)} rotation matrices or {@code (3x1)} rotation vectors,
+ * for all the transformations from calibration target frame to camera frame.
+ * @param t_target2cam Rotation part extracted from the homogeneous matrix that transforms a point
+ * expressed in the target frame to the camera frame (\(_{}^{c}\textrm{T}_t\)).
+ * This is a vector ({@code vector<Mat>}) that contains the {@code (3x1)} translation vectors for all the transformations
+ * from calibration target frame to camera frame.
+ * @param R_cam2gripper Estimated {@code (3x3)} rotation part extracted from the homogeneous matrix that transforms a point
+ * expressed in the camera frame to the gripper frame (\(_{}^{g}\textrm{T}_c\)).
+ * @param t_cam2gripper Estimated {@code (3x1)} translation part extracted from the homogeneous matrix that transforms a point
+ * expressed in the camera frame to the gripper frame (\(_{}^{g}\textrm{T}_c\)).
+ * @param method One of the implemented Hand-Eye calibration method, see cv::HandEyeCalibrationMethod
+ *
+ * The function performs the Hand-Eye calibration using various methods. One approach consists in estimating the
+ * rotation then the translation (separable solutions) and the following methods are implemented:
+ *
+ *
+ * R. Tsai, R. Lenz A New Technique for Fully Autonomous and Efficient 3D Robotics Hand/EyeCalibration \cite Tsai89
+ *
+ *
+ * F. Park, B. Martin Robot Sensor Calibration: Solving AX = XB on the Euclidean Group \cite Park94
+ *
+ *
+ * R. Horaud, F. Dornaika Hand-Eye Calibration \cite Horaud95
+ *
+ *
+ *
+ * Another approach consists in estimating simultaneously the rotation and the translation (simultaneous solutions),
+ * with the following implemented methods:
+ *
+ *
+ * N. Andreff, R. Horaud, B. Espiau On-line Hand-Eye Calibration \cite Andreff99
+ *
+ *
+ * K. Daniilidis Hand-Eye Calibration Using Dual Quaternions \cite Daniilidis98
+ *
+ *
+ *
+ * The following picture describes the Hand-Eye calibration problem where the transformation between a camera ("eye")
+ * mounted on a robot gripper ("hand") has to be estimated. This configuration is called eye-in-hand.
+ *
+ * The eye-to-hand configuration consists in a static camera observing a calibration pattern mounted on the robot
+ * end-effector. The transformation from the camera to the robot base frame can then be estimated by inputting
+ * the suitable transformations to the function, see below.
+ *
+ * 
+ *
+ * The calibration procedure is the following:
+ *
+ *
+ * a static calibration pattern is used to estimate the transformation between the target frame
+ * and the camera frame
+ *
+ *
+ * the robot gripper is moved in order to acquire several poses
+ *
+ *
+ * for each pose, the homogeneous transformation between the gripper frame and the robot base frame is recorded using for
+ * instance the robot kinematics
+ * \(
+ * \begin{bmatrix}
+ * X_b\\
+ * Y_b\\
+ * Z_b\\
+ * 1
+ * \end{bmatrix}
+ * =
+ * \begin{bmatrix}
+ * _{}^{b}\textrm{R}_g & _{}^{b}\textrm{t}_g \\
+ * 0_{1 \times 3} & 1
+ * \end{bmatrix}
+ * \begin{bmatrix}
+ * X_g\\
+ * Y_g\\
+ * Z_g\\
+ * 1
+ * \end{bmatrix}
+ * \)
+ *
+ *
+ * for each pose, the homogeneous transformation between the calibration target frame and the camera frame is recorded using
+ * for instance a pose estimation method (PnP) from 2D-3D point correspondences
+ * \(
+ * \begin{bmatrix}
+ * X_c\\
+ * Y_c\\
+ * Z_c\\
+ * 1
+ * \end{bmatrix}
+ * =
+ * \begin{bmatrix}
+ * _{}^{c}\textrm{R}_t & _{}^{c}\textrm{t}_t \\
+ * 0_{1 \times 3} & 1
+ * \end{bmatrix}
+ * \begin{bmatrix}
+ * X_t\\
+ * Y_t\\
+ * Z_t\\
+ * 1
+ * \end{bmatrix}
+ * \)
+ *
+ *
+ *
+ * The Hand-Eye calibration procedure returns the following homogeneous transformation
+ * \(
+ * \begin{bmatrix}
+ * X_g\\
+ * Y_g\\
+ * Z_g\\
+ * 1
+ * \end{bmatrix}
+ * =
+ * \begin{bmatrix}
+ * _{}^{g}\textrm{R}_c & _{}^{g}\textrm{t}_c \\
+ * 0_{1 \times 3} & 1
+ * \end{bmatrix}
+ * \begin{bmatrix}
+ * X_c\\
+ * Y_c\\
+ * Z_c\\
+ * 1
+ * \end{bmatrix}
+ * \)
+ *
+ * This problem is also known as solving the \(\mathbf{A}\mathbf{X}=\mathbf{X}\mathbf{B}\) equation:
+ *
+ *
+ * (^{g}{\textrm{T}_b}^{(2)})^{-1} \hspace{0.2em} ^{g}{\textrm{T}_b}^{(1)} \hspace{0.2em} ^{b}\textrm{T}_c &=
+ * \hspace{0.1em} ^{b}\textrm{T}_c \hspace{0.2em} ^{c}{\textrm{T}_t}^{(2)} (^{c}{\textrm{T}_t}^{(1)})^{-1} \\
+ *
+ * \textrm{A}_i \textrm{X} &= \textrm{X} \textrm{B}_i \\
+ * \end{align*}
+ * \)
+ *
+ * \note
+ * Additional information can be found on this [website](http://campar.in.tum.de/Chair/HandEyeCalibration).
+ * \note
+ * A minimum of 2 motions with non parallel rotation axes are necessary to determine the hand-eye transformation.
+ * So at least 3 different poses are required, but it is strongly recommended to use many more poses.
+ */
+ public static void calibrateHandEye(List R_gripper2base, List t_gripper2base, List R_target2cam, List t_target2cam, Mat R_cam2gripper, Mat t_cam2gripper, int method) {
+ Mat R_gripper2base_mat = Converters.vector_Mat_to_Mat(R_gripper2base);
+ Mat t_gripper2base_mat = Converters.vector_Mat_to_Mat(t_gripper2base);
+ Mat R_target2cam_mat = Converters.vector_Mat_to_Mat(R_target2cam);
+ Mat t_target2cam_mat = Converters.vector_Mat_to_Mat(t_target2cam);
+ calibrateHandEye_0(R_gripper2base_mat.nativeObj, t_gripper2base_mat.nativeObj, R_target2cam_mat.nativeObj, t_target2cam_mat.nativeObj, R_cam2gripper.nativeObj, t_cam2gripper.nativeObj, method);
+ }
+
+ /**
+ * Computes Hand-Eye calibration: \(_{}^{g}\textrm{T}_c\)
+ *
+ * @param R_gripper2base Rotation part extracted from the homogeneous matrix that transforms a point
+ * expressed in the gripper frame to the robot base frame (\(_{}^{b}\textrm{T}_g\)).
+ * This is a vector ({@code vector<Mat>}) that contains the rotation, {@code (3x3)} rotation matrices or {@code (3x1)} rotation vectors,
+ * for all the transformations from gripper frame to robot base frame.
+ * @param t_gripper2base Translation part extracted from the homogeneous matrix that transforms a point
+ * expressed in the gripper frame to the robot base frame (\(_{}^{b}\textrm{T}_g\)).
+ * This is a vector ({@code vector<Mat>}) that contains the {@code (3x1)} translation vectors for all the transformations
+ * from gripper frame to robot base frame.
+ * @param R_target2cam Rotation part extracted from the homogeneous matrix that transforms a point
+ * expressed in the target frame to the camera frame (\(_{}^{c}\textrm{T}_t\)).
+ * This is a vector ({@code vector<Mat>}) that contains the rotation, {@code (3x3)} rotation matrices or {@code (3x1)} rotation vectors,
+ * for all the transformations from calibration target frame to camera frame.
+ * @param t_target2cam Rotation part extracted from the homogeneous matrix that transforms a point
+ * expressed in the target frame to the camera frame (\(_{}^{c}\textrm{T}_t\)).
+ * This is a vector ({@code vector<Mat>}) that contains the {@code (3x1)} translation vectors for all the transformations
+ * from calibration target frame to camera frame.
+ * @param R_cam2gripper Estimated {@code (3x3)} rotation part extracted from the homogeneous matrix that transforms a point
+ * expressed in the camera frame to the gripper frame (\(_{}^{g}\textrm{T}_c\)).
+ * @param t_cam2gripper Estimated {@code (3x1)} translation part extracted from the homogeneous matrix that transforms a point
+ * expressed in the camera frame to the gripper frame (\(_{}^{g}\textrm{T}_c\)).
+ *
+ * The function performs the Hand-Eye calibration using various methods. One approach consists in estimating the
+ * rotation then the translation (separable solutions) and the following methods are implemented:
+ *
+ *
+ * R. Tsai, R. Lenz A New Technique for Fully Autonomous and Efficient 3D Robotics Hand/EyeCalibration \cite Tsai89
+ *
+ *
+ * F. Park, B. Martin Robot Sensor Calibration: Solving AX = XB on the Euclidean Group \cite Park94
+ *
+ *
+ * R. Horaud, F. Dornaika Hand-Eye Calibration \cite Horaud95
+ *
+ *
+ *
+ * Another approach consists in estimating simultaneously the rotation and the translation (simultaneous solutions),
+ * with the following implemented methods:
+ *
+ *
+ * N. Andreff, R. Horaud, B. Espiau On-line Hand-Eye Calibration \cite Andreff99
+ *
+ *
+ * K. Daniilidis Hand-Eye Calibration Using Dual Quaternions \cite Daniilidis98
+ *
+ *
+ *
+ * The following picture describes the Hand-Eye calibration problem where the transformation between a camera ("eye")
+ * mounted on a robot gripper ("hand") has to be estimated. This configuration is called eye-in-hand.
+ *
+ * The eye-to-hand configuration consists in a static camera observing a calibration pattern mounted on the robot
+ * end-effector. The transformation from the camera to the robot base frame can then be estimated by inputting
+ * the suitable transformations to the function, see below.
+ *
+ * 
+ *
+ * The calibration procedure is the following:
+ *
+ *
+ * a static calibration pattern is used to estimate the transformation between the target frame
+ * and the camera frame
+ *
+ *
+ * the robot gripper is moved in order to acquire several poses
+ *
+ *
+ * for each pose, the homogeneous transformation between the gripper frame and the robot base frame is recorded using for
+ * instance the robot kinematics
+ * \(
+ * \begin{bmatrix}
+ * X_b\\
+ * Y_b\\
+ * Z_b\\
+ * 1
+ * \end{bmatrix}
+ * =
+ * \begin{bmatrix}
+ * _{}^{b}\textrm{R}_g & _{}^{b}\textrm{t}_g \\
+ * 0_{1 \times 3} & 1
+ * \end{bmatrix}
+ * \begin{bmatrix}
+ * X_g\\
+ * Y_g\\
+ * Z_g\\
+ * 1
+ * \end{bmatrix}
+ * \)
+ *
+ *
+ * for each pose, the homogeneous transformation between the calibration target frame and the camera frame is recorded using
+ * for instance a pose estimation method (PnP) from 2D-3D point correspondences
+ * \(
+ * \begin{bmatrix}
+ * X_c\\
+ * Y_c\\
+ * Z_c\\
+ * 1
+ * \end{bmatrix}
+ * =
+ * \begin{bmatrix}
+ * _{}^{c}\textrm{R}_t & _{}^{c}\textrm{t}_t \\
+ * 0_{1 \times 3} & 1
+ * \end{bmatrix}
+ * \begin{bmatrix}
+ * X_t\\
+ * Y_t\\
+ * Z_t\\
+ * 1
+ * \end{bmatrix}
+ * \)
+ *
+ *
+ *
+ * The Hand-Eye calibration procedure returns the following homogeneous transformation
+ * \(
+ * \begin{bmatrix}
+ * X_g\\
+ * Y_g\\
+ * Z_g\\
+ * 1
+ * \end{bmatrix}
+ * =
+ * \begin{bmatrix}
+ * _{}^{g}\textrm{R}_c & _{}^{g}\textrm{t}_c \\
+ * 0_{1 \times 3} & 1
+ * \end{bmatrix}
+ * \begin{bmatrix}
+ * X_c\\
+ * Y_c\\
+ * Z_c\\
+ * 1
+ * \end{bmatrix}
+ * \)
+ *
+ * This problem is also known as solving the \(\mathbf{A}\mathbf{X}=\mathbf{X}\mathbf{B}\) equation:
+ *
+ *
+ * (^{g}{\textrm{T}_b}^{(2)})^{-1} \hspace{0.2em} ^{g}{\textrm{T}_b}^{(1)} \hspace{0.2em} ^{b}\textrm{T}_c &=
+ * \hspace{0.1em} ^{b}\textrm{T}_c \hspace{0.2em} ^{c}{\textrm{T}_t}^{(2)} (^{c}{\textrm{T}_t}^{(1)})^{-1} \\
+ *
+ * \textrm{A}_i \textrm{X} &= \textrm{X} \textrm{B}_i \\
+ * \end{align*}
+ * \)
+ *
+ * \note
+ * Additional information can be found on this [website](http://campar.in.tum.de/Chair/HandEyeCalibration).
+ * \note
+ * A minimum of 2 motions with non parallel rotation axes are necessary to determine the hand-eye transformation.
+ * So at least 3 different poses are required, but it is strongly recommended to use many more poses.
+ */
+ public static void calibrateHandEye(List R_gripper2base, List t_gripper2base, List R_target2cam, List t_target2cam, Mat R_cam2gripper, Mat t_cam2gripper) {
+ Mat R_gripper2base_mat = Converters.vector_Mat_to_Mat(R_gripper2base);
+ Mat t_gripper2base_mat = Converters.vector_Mat_to_Mat(t_gripper2base);
+ Mat R_target2cam_mat = Converters.vector_Mat_to_Mat(R_target2cam);
+ Mat t_target2cam_mat = Converters.vector_Mat_to_Mat(t_target2cam);
+ calibrateHandEye_1(R_gripper2base_mat.nativeObj, t_gripper2base_mat.nativeObj, R_target2cam_mat.nativeObj, t_target2cam_mat.nativeObj, R_cam2gripper.nativeObj, t_cam2gripper.nativeObj);
+ }
+
+
+ //
+ // C++: void cv::calibrateRobotWorldHandEye(vector_Mat R_world2cam, vector_Mat t_world2cam, vector_Mat R_base2gripper, vector_Mat t_base2gripper, Mat& R_base2world, Mat& t_base2world, Mat& R_gripper2cam, Mat& t_gripper2cam, RobotWorldHandEyeCalibrationMethod method = CALIB_ROBOT_WORLD_HAND_EYE_SHAH)
+ //
+
+ /**
+ * Computes Robot-World/Hand-Eye calibration: \(_{}^{w}\textrm{T}_b\) and \(_{}^{c}\textrm{T}_g\)
+ *
+ * @param R_world2cam Rotation part extracted from the homogeneous matrix that transforms a point
+ * expressed in the world frame to the camera frame (\(_{}^{c}\textrm{T}_w\)).
+ * This is a vector ({@code vector<Mat>}) that contains the rotation, {@code (3x3)} rotation matrices or {@code (3x1)} rotation vectors,
+ * for all the transformations from world frame to the camera frame.
+ * @param t_world2cam Translation part extracted from the homogeneous matrix that transforms a point
+ * expressed in the world frame to the camera frame (\(_{}^{c}\textrm{T}_w\)).
+ * This is a vector ({@code vector<Mat>}) that contains the {@code (3x1)} translation vectors for all the transformations
+ * from world frame to the camera frame.
+ * @param R_base2gripper Rotation part extracted from the homogeneous matrix that transforms a point
+ * expressed in the robot base frame to the gripper frame (\(_{}^{g}\textrm{T}_b\)).
+ * This is a vector ({@code vector<Mat>}) that contains the rotation, {@code (3x3)} rotation matrices or {@code (3x1)} rotation vectors,
+ * for all the transformations from robot base frame to the gripper frame.
+ * @param t_base2gripper Rotation part extracted from the homogeneous matrix that transforms a point
+ * expressed in the robot base frame to the gripper frame (\(_{}^{g}\textrm{T}_b\)).
+ * This is a vector ({@code vector<Mat>}) that contains the {@code (3x1)} translation vectors for all the transformations
+ * from robot base frame to the gripper frame.
+ * @param R_base2world Estimated {@code (3x3)} rotation part extracted from the homogeneous matrix that transforms a point
+ * expressed in the robot base frame to the world frame (\(_{}^{w}\textrm{T}_b\)).
+ * @param t_base2world Estimated {@code (3x1)} translation part extracted from the homogeneous matrix that transforms a point
+ * expressed in the robot base frame to the world frame (\(_{}^{w}\textrm{T}_b\)).
+ * @param R_gripper2cam Estimated {@code (3x3)} rotation part extracted from the homogeneous matrix that transforms a point
+ * expressed in the gripper frame to the camera frame (\(_{}^{c}\textrm{T}_g\)).
+ * @param t_gripper2cam Estimated {@code (3x1)} translation part extracted from the homogeneous matrix that transforms a point
+ * expressed in the gripper frame to the camera frame (\(_{}^{c}\textrm{T}_g\)).
+ * @param method One of the implemented Robot-World/Hand-Eye calibration method, see cv::RobotWorldHandEyeCalibrationMethod
+ *
+ * The function performs the Robot-World/Hand-Eye calibration using various methods. One approach consists in estimating the
+ * rotation then the translation (separable solutions):
+ *
+ *
+ * M. Shah, Solving the robot-world/hand-eye calibration problem using the kronecker product \cite Shah2013SolvingTR
+ *
+ *
+ *
+ * Another approach consists in estimating simultaneously the rotation and the translation (simultaneous solutions),
+ * with the following implemented method:
+ *
+ *
+ * A. Li, L. Wang, and D. Wu, Simultaneous robot-world and hand-eye calibration using dual-quaternions and kronecker product \cite Li2010SimultaneousRA
+ *
+ *
+ *
+ * The following picture describes the Robot-World/Hand-Eye calibration problem where the transformations between a robot and a world frame
+ * and between a robot gripper ("hand") and a camera ("eye") mounted at the robot end-effector have to be estimated.
+ *
+ * 
+ *
+ * The calibration procedure is the following:
+ *
+ *
+ * a static calibration pattern is used to estimate the transformation between the target frame
+ * and the camera frame
+ *
+ *
+ * the robot gripper is moved in order to acquire several poses
+ *
+ *
+ * for each pose, the homogeneous transformation between the gripper frame and the robot base frame is recorded using for
+ * instance the robot kinematics
+ * \(
+ * \begin{bmatrix}
+ * X_g\\
+ * Y_g\\
+ * Z_g\\
+ * 1
+ * \end{bmatrix}
+ * =
+ * \begin{bmatrix}
+ * _{}^{g}\textrm{R}_b & _{}^{g}\textrm{t}_b \\
+ * 0_{1 \times 3} & 1
+ * \end{bmatrix}
+ * \begin{bmatrix}
+ * X_b\\
+ * Y_b\\
+ * Z_b\\
+ * 1
+ * \end{bmatrix}
+ * \)
+ *
+ *
+ * for each pose, the homogeneous transformation between the calibration target frame (the world frame) and the camera frame is recorded using
+ * for instance a pose estimation method (PnP) from 2D-3D point correspondences
+ * \(
+ * \begin{bmatrix}
+ * X_c\\
+ * Y_c\\
+ * Z_c\\
+ * 1
+ * \end{bmatrix}
+ * =
+ * \begin{bmatrix}
+ * _{}^{c}\textrm{R}_w & _{}^{c}\textrm{t}_w \\
+ * 0_{1 \times 3} & 1
+ * \end{bmatrix}
+ * \begin{bmatrix}
+ * X_w\\
+ * Y_w\\
+ * Z_w\\
+ * 1
+ * \end{bmatrix}
+ * \)
+ *
+ *
+ * \note
+ * At least 3 measurements are required (input vectors size must be greater or equal to 3).
+ */
+ public static void calibrateRobotWorldHandEye(List R_world2cam, List t_world2cam, List R_base2gripper, List t_base2gripper, Mat R_base2world, Mat t_base2world, Mat R_gripper2cam, Mat t_gripper2cam, int method) {
+ Mat R_world2cam_mat = Converters.vector_Mat_to_Mat(R_world2cam);
+ Mat t_world2cam_mat = Converters.vector_Mat_to_Mat(t_world2cam);
+ Mat R_base2gripper_mat = Converters.vector_Mat_to_Mat(R_base2gripper);
+ Mat t_base2gripper_mat = Converters.vector_Mat_to_Mat(t_base2gripper);
+ calibrateRobotWorldHandEye_0(R_world2cam_mat.nativeObj, t_world2cam_mat.nativeObj, R_base2gripper_mat.nativeObj, t_base2gripper_mat.nativeObj, R_base2world.nativeObj, t_base2world.nativeObj, R_gripper2cam.nativeObj, t_gripper2cam.nativeObj, method);
+ }
+
+ /**
+ * Computes Robot-World/Hand-Eye calibration: \(_{}^{w}\textrm{T}_b\) and \(_{}^{c}\textrm{T}_g\)
+ *
+ * @param R_world2cam Rotation part extracted from the homogeneous matrix that transforms a point
+ * expressed in the world frame to the camera frame (\(_{}^{c}\textrm{T}_w\)).
+ * This is a vector ({@code vector<Mat>}) that contains the rotation, {@code (3x3)} rotation matrices or {@code (3x1)} rotation vectors,
+ * for all the transformations from world frame to the camera frame.
+ * @param t_world2cam Translation part extracted from the homogeneous matrix that transforms a point
+ * expressed in the world frame to the camera frame (\(_{}^{c}\textrm{T}_w\)).
+ * This is a vector ({@code vector<Mat>}) that contains the {@code (3x1)} translation vectors for all the transformations
+ * from world frame to the camera frame.
+ * @param R_base2gripper Rotation part extracted from the homogeneous matrix that transforms a point
+ * expressed in the robot base frame to the gripper frame (\(_{}^{g}\textrm{T}_b\)).
+ * This is a vector ({@code vector<Mat>}) that contains the rotation, {@code (3x3)} rotation matrices or {@code (3x1)} rotation vectors,
+ * for all the transformations from robot base frame to the gripper frame.
+ * @param t_base2gripper Rotation part extracted from the homogeneous matrix that transforms a point
+ * expressed in the robot base frame to the gripper frame (\(_{}^{g}\textrm{T}_b\)).
+ * This is a vector ({@code vector<Mat>}) that contains the {@code (3x1)} translation vectors for all the transformations
+ * from robot base frame to the gripper frame.
+ * @param R_base2world Estimated {@code (3x3)} rotation part extracted from the homogeneous matrix that transforms a point
+ * expressed in the robot base frame to the world frame (\(_{}^{w}\textrm{T}_b\)).
+ * @param t_base2world Estimated {@code (3x1)} translation part extracted from the homogeneous matrix that transforms a point
+ * expressed in the robot base frame to the world frame (\(_{}^{w}\textrm{T}_b\)).
+ * @param R_gripper2cam Estimated {@code (3x3)} rotation part extracted from the homogeneous matrix that transforms a point
+ * expressed in the gripper frame to the camera frame (\(_{}^{c}\textrm{T}_g\)).
+ * @param t_gripper2cam Estimated {@code (3x1)} translation part extracted from the homogeneous matrix that transforms a point
+ * expressed in the gripper frame to the camera frame (\(_{}^{c}\textrm{T}_g\)).
+ *
+ * The function performs the Robot-World/Hand-Eye calibration using various methods. One approach consists in estimating the
+ * rotation then the translation (separable solutions):
+ *
+ *
+ * M. Shah, Solving the robot-world/hand-eye calibration problem using the kronecker product \cite Shah2013SolvingTR
+ *
+ *
+ *
+ * Another approach consists in estimating simultaneously the rotation and the translation (simultaneous solutions),
+ * with the following implemented method:
+ *
+ *
+ * A. Li, L. Wang, and D. Wu, Simultaneous robot-world and hand-eye calibration using dual-quaternions and kronecker product \cite Li2010SimultaneousRA
+ *
+ *
+ *
+ * The following picture describes the Robot-World/Hand-Eye calibration problem where the transformations between a robot and a world frame
+ * and between a robot gripper ("hand") and a camera ("eye") mounted at the robot end-effector have to be estimated.
+ *
+ * 
+ *
+ * The calibration procedure is the following:
+ *
+ *
+ * a static calibration pattern is used to estimate the transformation between the target frame
+ * and the camera frame
+ *
+ *
+ * the robot gripper is moved in order to acquire several poses
+ *
+ *
+ * for each pose, the homogeneous transformation between the gripper frame and the robot base frame is recorded using for
+ * instance the robot kinematics
+ * \(
+ * \begin{bmatrix}
+ * X_g\\
+ * Y_g\\
+ * Z_g\\
+ * 1
+ * \end{bmatrix}
+ * =
+ * \begin{bmatrix}
+ * _{}^{g}\textrm{R}_b & _{}^{g}\textrm{t}_b \\
+ * 0_{1 \times 3} & 1
+ * \end{bmatrix}
+ * \begin{bmatrix}
+ * X_b\\
+ * Y_b\\
+ * Z_b\\
+ * 1
+ * \end{bmatrix}
+ * \)
+ *
+ *
+ * for each pose, the homogeneous transformation between the calibration target frame (the world frame) and the camera frame is recorded using
+ * for instance a pose estimation method (PnP) from 2D-3D point correspondences
+ * \(
+ * \begin{bmatrix}
+ * X_c\\
+ * Y_c\\
+ * Z_c\\
+ * 1
+ * \end{bmatrix}
+ * =
+ * \begin{bmatrix}
+ * _{}^{c}\textrm{R}_w & _{}^{c}\textrm{t}_w \\
+ * 0_{1 \times 3} & 1
+ * \end{bmatrix}
+ * \begin{bmatrix}
+ * X_w\\
+ * Y_w\\
+ * Z_w\\
+ * 1
+ * \end{bmatrix}
+ * \)
+ *
+ *
+ * \note
+ * At least 3 measurements are required (input vectors size must be greater or equal to 3).
+ */
+ public static void calibrateRobotWorldHandEye(List R_world2cam, List t_world2cam, List R_base2gripper, List t_base2gripper, Mat R_base2world, Mat t_base2world, Mat R_gripper2cam, Mat t_gripper2cam) {
+ Mat R_world2cam_mat = Converters.vector_Mat_to_Mat(R_world2cam);
+ Mat t_world2cam_mat = Converters.vector_Mat_to_Mat(t_world2cam);
+ Mat R_base2gripper_mat = Converters.vector_Mat_to_Mat(R_base2gripper);
+ Mat t_base2gripper_mat = Converters.vector_Mat_to_Mat(t_base2gripper);
+ calibrateRobotWorldHandEye_1(R_world2cam_mat.nativeObj, t_world2cam_mat.nativeObj, R_base2gripper_mat.nativeObj, t_base2gripper_mat.nativeObj, R_base2world.nativeObj, t_base2world.nativeObj, R_gripper2cam.nativeObj, t_gripper2cam.nativeObj);
+ }
+
+
+ //
+ // C++: void cv::convertPointsToHomogeneous(Mat src, Mat& dst)
+ //
+
+ /**
+ * Converts points from Euclidean to homogeneous space.
+ *
+ * @param src Input vector of N-dimensional points.
+ * @param dst Output vector of N+1-dimensional points.
+ *
+ * The function converts points from Euclidean to homogeneous space by appending 1's to the tuple of
+ * point coordinates. That is, each point (x1, x2, ..., xn) is converted to (x1, x2, ..., xn, 1).
+ */
+ public static void convertPointsToHomogeneous(Mat src, Mat dst) {
+ convertPointsToHomogeneous_0(src.nativeObj, dst.nativeObj);
+ }
+
+
+ //
+ // C++: void cv::convertPointsFromHomogeneous(Mat src, Mat& dst)
+ //
+
+ /**
+ * Converts points from homogeneous to Euclidean space.
+ *
+ * @param src Input vector of N-dimensional points.
+ * @param dst Output vector of N-1-dimensional points.
+ *
+ * The function converts points homogeneous to Euclidean space using perspective projection. That is,
+ * each point (x1, x2, ... x(n-1), xn) is converted to (x1/xn, x2/xn, ..., x(n-1)/xn). When xn=0, the
+ * output point coordinates will be (0,0,0,...).
+ */
+ public static void convertPointsFromHomogeneous(Mat src, Mat dst) {
+ convertPointsFromHomogeneous_0(src.nativeObj, dst.nativeObj);
+ }
+
+
+ //
+ // C++: Mat cv::findFundamentalMat(vector_Point2f points1, vector_Point2f points2, int method, double ransacReprojThreshold, double confidence, int maxIters, Mat& mask = Mat())
+ //
+
+ /**
+ * Calculates a fundamental matrix from the corresponding points in two images.
+ *
+ * @param points1 Array of N points from the first image. The point coordinates should be
+ * floating-point (single or double precision).
+ * @param points2 Array of the second image points of the same size and format as points1 .
+ * @param method Method for computing a fundamental matrix.
+ *
+ *
+ * REF: FM_7POINT for a 7-point algorithm. \(N = 7\)
+ *
+ *
+ * REF: FM_8POINT for an 8-point algorithm. \(N \ge 8\)
+ *
+ *
+ * REF: FM_RANSAC for the RANSAC algorithm. \(N \ge 8\)
+ *
+ *
+ * REF: FM_LMEDS for the LMedS algorithm. \(N \ge 8\)
+ *
+ *
+ * @param ransacReprojThreshold Parameter used only for RANSAC. It is the maximum distance from a point to an epipolar
+ * line in pixels, beyond which the point is considered an outlier and is not used for computing the
+ * final fundamental matrix. It can be set to something like 1-3, depending on the accuracy of the
+ * point localization, image resolution, and the image noise.
+ * @param confidence Parameter used for the RANSAC and LMedS methods only. It specifies a desirable level
+ * of confidence (probability) that the estimated matrix is correct.
+ * @param mask optional output mask
+ * @param maxIters The maximum number of robust method iterations.
+ *
+ * The epipolar geometry is described by the following equation:
+ *
+ * \([p_2; 1]^T F [p_1; 1] = 0\)
+ *
+ * where \(F\) is a fundamental matrix, \(p_1\) and \(p_2\) are corresponding points in the first and the
+ * second images, respectively.
+ *
+ * The function calculates the fundamental matrix using one of four methods listed above and returns
+ * the found fundamental matrix. Normally just one matrix is found. But in case of the 7-point
+ * algorithm, the function may return up to 3 solutions ( \(9 \times 3\) matrix that stores all 3
+ * matrices sequentially).
+ *
+ * The calculated fundamental matrix may be passed further to #computeCorrespondEpilines that finds the
+ * epipolar lines corresponding to the specified points. It can also be passed to
+ * #stereoRectifyUncalibrated to compute the rectification transformation. :
+ *
+ * // Example. Estimation of fundamental matrix using the RANSAC algorithm
+ * int point_count = 100;
+ * vector<Point2f> points1(point_count);
+ * vector<Point2f> points2(point_count);
+ *
+ * // initialize the points here ...
+ * for( int i = 0; i < point_count; i++ )
+ * {
+ * points1[i] = ...;
+ * points2[i] = ...;
+ * }
+ *
+ * Mat fundamental_matrix =
+ * findFundamentalMat(points1, points2, FM_RANSAC, 3, 0.99);
+ *
+ * @return automatically generated
+ */
+ public static Mat findFundamentalMat(MatOfPoint2f points1, MatOfPoint2f points2, int method, double ransacReprojThreshold, double confidence, int maxIters, Mat mask) {
+ Mat points1_mat = points1;
+ Mat points2_mat = points2;
+ return new Mat(findFundamentalMat_0(points1_mat.nativeObj, points2_mat.nativeObj, method, ransacReprojThreshold, confidence, maxIters, mask.nativeObj));
+ }
+
+ /**
+ * Calculates a fundamental matrix from the corresponding points in two images.
+ *
+ * @param points1 Array of N points from the first image. The point coordinates should be
+ * floating-point (single or double precision).
+ * @param points2 Array of the second image points of the same size and format as points1 .
+ * @param method Method for computing a fundamental matrix.
+ *
+ *
+ * REF: FM_7POINT for a 7-point algorithm. \(N = 7\)
+ *
+ *
+ * REF: FM_8POINT for an 8-point algorithm. \(N \ge 8\)
+ *
+ *
+ * REF: FM_RANSAC for the RANSAC algorithm. \(N \ge 8\)
+ *
+ *
+ * REF: FM_LMEDS for the LMedS algorithm. \(N \ge 8\)
+ *
+ *
+ * @param ransacReprojThreshold Parameter used only for RANSAC. It is the maximum distance from a point to an epipolar
+ * line in pixels, beyond which the point is considered an outlier and is not used for computing the
+ * final fundamental matrix. It can be set to something like 1-3, depending on the accuracy of the
+ * point localization, image resolution, and the image noise.
+ * @param confidence Parameter used for the RANSAC and LMedS methods only. It specifies a desirable level
+ * of confidence (probability) that the estimated matrix is correct.
+ * @param maxIters The maximum number of robust method iterations.
+ *
+ * The epipolar geometry is described by the following equation:
+ *
+ * \([p_2; 1]^T F [p_1; 1] = 0\)
+ *
+ * where \(F\) is a fundamental matrix, \(p_1\) and \(p_2\) are corresponding points in the first and the
+ * second images, respectively.
+ *
+ * The function calculates the fundamental matrix using one of four methods listed above and returns
+ * the found fundamental matrix. Normally just one matrix is found. But in case of the 7-point
+ * algorithm, the function may return up to 3 solutions ( \(9 \times 3\) matrix that stores all 3
+ * matrices sequentially).
+ *
+ * The calculated fundamental matrix may be passed further to #computeCorrespondEpilines that finds the
+ * epipolar lines corresponding to the specified points. It can also be passed to
+ * #stereoRectifyUncalibrated to compute the rectification transformation. :
+ *
+ * // Example. Estimation of fundamental matrix using the RANSAC algorithm
+ * int point_count = 100;
+ * vector<Point2f> points1(point_count);
+ * vector<Point2f> points2(point_count);
+ *
+ * // initialize the points here ...
+ * for( int i = 0; i < point_count; i++ )
+ * {
+ * points1[i] = ...;
+ * points2[i] = ...;
+ * }
+ *
+ * Mat fundamental_matrix =
+ * findFundamentalMat(points1, points2, FM_RANSAC, 3, 0.99);
+ *
+ * @return automatically generated
+ */
+ public static Mat findFundamentalMat(MatOfPoint2f points1, MatOfPoint2f points2, int method, double ransacReprojThreshold, double confidence, int maxIters) {
+ Mat points1_mat = points1;
+ Mat points2_mat = points2;
+ return new Mat(findFundamentalMat_1(points1_mat.nativeObj, points2_mat.nativeObj, method, ransacReprojThreshold, confidence, maxIters));
+ }
+
+
+ //
+ // C++: Mat cv::findFundamentalMat(vector_Point2f points1, vector_Point2f points2, int method = FM_RANSAC, double ransacReprojThreshold = 3., double confidence = 0.99, Mat& mask = Mat())
+ //
+
+ public static Mat findFundamentalMat(MatOfPoint2f points1, MatOfPoint2f points2, int method, double ransacReprojThreshold, double confidence, Mat mask) {
+ Mat points1_mat = points1;
+ Mat points2_mat = points2;
+ return new Mat(findFundamentalMat_2(points1_mat.nativeObj, points2_mat.nativeObj, method, ransacReprojThreshold, confidence, mask.nativeObj));
+ }
+
+ public static Mat findFundamentalMat(MatOfPoint2f points1, MatOfPoint2f points2, int method, double ransacReprojThreshold, double confidence) {
+ Mat points1_mat = points1;
+ Mat points2_mat = points2;
+ return new Mat(findFundamentalMat_3(points1_mat.nativeObj, points2_mat.nativeObj, method, ransacReprojThreshold, confidence));
+ }
+
+ public static Mat findFundamentalMat(MatOfPoint2f points1, MatOfPoint2f points2, int method, double ransacReprojThreshold) {
+ Mat points1_mat = points1;
+ Mat points2_mat = points2;
+ return new Mat(findFundamentalMat_4(points1_mat.nativeObj, points2_mat.nativeObj, method, ransacReprojThreshold));
+ }
+
+ public static Mat findFundamentalMat(MatOfPoint2f points1, MatOfPoint2f points2, int method) {
+ Mat points1_mat = points1;
+ Mat points2_mat = points2;
+ return new Mat(findFundamentalMat_5(points1_mat.nativeObj, points2_mat.nativeObj, method));
+ }
+
+ public static Mat findFundamentalMat(MatOfPoint2f points1, MatOfPoint2f points2) {
+ Mat points1_mat = points1;
+ Mat points2_mat = points2;
+ return new Mat(findFundamentalMat_6(points1_mat.nativeObj, points2_mat.nativeObj));
+ }
+
+
+ //
+ // C++: Mat cv::findFundamentalMat(vector_Point2f points1, vector_Point2f points2, Mat& mask, UsacParams params)
+ //
+
+ public static Mat findFundamentalMat(MatOfPoint2f points1, MatOfPoint2f points2, Mat mask, UsacParams params) {
+ Mat points1_mat = points1;
+ Mat points2_mat = points2;
+ return new Mat(findFundamentalMat_7(points1_mat.nativeObj, points2_mat.nativeObj, mask.nativeObj, params.nativeObj));
+ }
+
+
+ //
+ // C++: Mat cv::findEssentialMat(Mat points1, Mat points2, Mat cameraMatrix, int method = RANSAC, double prob = 0.999, double threshold = 1.0, int maxIters = 1000, Mat& mask = Mat())
+ //
+
+ /**
+ * Calculates an essential matrix from the corresponding points in two images.
+ *
+ * @param points1 Array of N (N >= 5) 2D points from the first image. The point coordinates should
+ * be floating-point (single or double precision).
+ * @param points2 Array of the second image points of the same size and format as points1 .
+ * @param cameraMatrix Camera intrinsic matrix \(\cameramatrix{A}\) .
+ * Note that this function assumes that points1 and points2 are feature points from cameras with the
+ * same camera intrinsic matrix. If this assumption does not hold for your use case, use
+ * #undistortPoints with {@code P = cv::NoArray()} for both cameras to transform image points
+ * to normalized image coordinates, which are valid for the identity camera intrinsic matrix. When
+ * passing these coordinates, pass the identity matrix for this parameter.
+ * @param method Method for computing an essential matrix.
+ *
+ *
+ * REF: RANSAC for the RANSAC algorithm.
+ *
+ *
+ * REF: LMEDS for the LMedS algorithm.
+ *
+ *
+ * @param prob Parameter used for the RANSAC or LMedS methods only. It specifies a desirable level of
+ * confidence (probability) that the estimated matrix is correct.
+ * @param threshold Parameter used for RANSAC. It is the maximum distance from a point to an epipolar
+ * line in pixels, beyond which the point is considered an outlier and is not used for computing the
+ * final fundamental matrix. It can be set to something like 1-3, depending on the accuracy of the
+ * point localization, image resolution, and the image noise.
+ * @param 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:
+ *
+ * \([p_2; 1]^T K^{-T} E K^{-1} [p_1; 1] = 0\)
+ *
+ * where \(E\) is an essential matrix, \(p_1\) and \(p_2\) are corresponding points in the first and the
+ * second images, respectively. The result of this function may be passed further to
+ * #decomposeEssentialMat or #recoverPose to recover the relative pose between cameras.
+ * @return automatically generated
+ */
+ public static Mat findEssentialMat(Mat points1, Mat points2, Mat cameraMatrix, int method, double prob, double threshold, int maxIters, Mat mask) {
+ return new Mat(findEssentialMat_0(points1.nativeObj, points2.nativeObj, cameraMatrix.nativeObj, method, prob, threshold, maxIters, mask.nativeObj));
+ }
+
+ /**
+ * Calculates an essential matrix from the corresponding points in two images.
+ *
+ * @param points1 Array of N (N >= 5) 2D points from the first image. The point coordinates should
+ * be floating-point (single or double precision).
+ * @param points2 Array of the second image points of the same size and format as points1 .
+ * @param cameraMatrix Camera intrinsic matrix \(\cameramatrix{A}\) .
+ * Note that this function assumes that points1 and points2 are feature points from cameras with the
+ * same camera intrinsic matrix. If this assumption does not hold for your use case, use
+ * #undistortPoints with {@code P = cv::NoArray()} for both cameras to transform image points
+ * to normalized image coordinates, which are valid for the identity camera intrinsic matrix. When
+ * passing these coordinates, pass the identity matrix for this parameter.
+ * @param method Method for computing an essential matrix.
+ *
+ *
+ * REF: RANSAC for the RANSAC algorithm.
+ *
+ *
+ * REF: LMEDS for the LMedS algorithm.
+ *
+ *
+ * @param prob Parameter used for the RANSAC or LMedS methods only. It specifies a desirable level of
+ * confidence (probability) that the estimated matrix is correct.
+ * @param threshold Parameter used for RANSAC. It is the maximum distance from a point to an epipolar
+ * line in pixels, beyond which the point is considered an outlier and is not used for computing the
+ * final fundamental matrix. It can be set to something like 1-3, depending on the accuracy of the
+ * point localization, image resolution, and the image noise.
+ * 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:
+ *
+ * \([p_2; 1]^T K^{-T} E K^{-1} [p_1; 1] = 0\)
+ *
+ * where \(E\) is an essential matrix, \(p_1\) and \(p_2\) are corresponding points in the first and the
+ * second images, respectively. The result of this function may be passed further to
+ * #decomposeEssentialMat or #recoverPose to recover the relative pose between cameras.
+ * @return automatically generated
+ */
+ public static Mat findEssentialMat(Mat points1, Mat points2, Mat cameraMatrix, int method, double prob, double threshold, int maxIters) {
+ return new Mat(findEssentialMat_1(points1.nativeObj, points2.nativeObj, cameraMatrix.nativeObj, method, prob, threshold, maxIters));
+ }
+
+ /**
+ * Calculates an essential matrix from the corresponding points in two images.
+ *
+ * @param points1 Array of N (N >= 5) 2D points from the first image. The point coordinates should
+ * be floating-point (single or double precision).
+ * @param points2 Array of the second image points of the same size and format as points1 .
+ * @param cameraMatrix Camera intrinsic matrix \(\cameramatrix{A}\) .
+ * Note that this function assumes that points1 and points2 are feature points from cameras with the
+ * same camera intrinsic matrix. If this assumption does not hold for your use case, use
+ * #undistortPoints with {@code P = cv::NoArray()} for both cameras to transform image points
+ * to normalized image coordinates, which are valid for the identity camera intrinsic matrix. When
+ * passing these coordinates, pass the identity matrix for this parameter.
+ * @param method Method for computing an essential matrix.
+ *
+ *
+ * REF: RANSAC for the RANSAC algorithm.
+ *
+ *
+ * REF: LMEDS for the LMedS algorithm.
+ *
+ *
+ * @param prob Parameter used for the RANSAC or LMedS methods only. It specifies a desirable level of
+ * confidence (probability) that the estimated matrix is correct.
+ * @param threshold Parameter used for RANSAC. It is the maximum distance from a point to an epipolar
+ * line in pixels, beyond which the point is considered an outlier and is not used for computing the
+ * final fundamental matrix. It can be set to something like 1-3, depending on the accuracy of the
+ * point localization, image resolution, and the image noise.
+ * for the other points. The array is computed only in the RANSAC and LMedS methods.
+ *
+ * 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:
+ *
+ * \([p_2; 1]^T K^{-T} E K^{-1} [p_1; 1] = 0\)
+ *
+ * where \(E\) is an essential matrix, \(p_1\) and \(p_2\) are corresponding points in the first and the
+ * second images, respectively. The result of this function may be passed further to
+ * #decomposeEssentialMat or #recoverPose to recover the relative pose between cameras.
+ * @return automatically generated
+ */
+ public static Mat findEssentialMat(Mat points1, Mat points2, Mat cameraMatrix, int method, double prob, double threshold) {
+ return new Mat(findEssentialMat_2(points1.nativeObj, points2.nativeObj, cameraMatrix.nativeObj, method, prob, threshold));
+ }
+
+ /**
+ * Calculates an essential matrix from the corresponding points in two images.
+ *
+ * @param points1 Array of N (N >= 5) 2D points from the first image. The point coordinates should
+ * be floating-point (single or double precision).
+ * @param points2 Array of the second image points of the same size and format as points1 .
+ * @param cameraMatrix Camera intrinsic matrix \(\cameramatrix{A}\) .
+ * Note that this function assumes that points1 and points2 are feature points from cameras with the
+ * same camera intrinsic matrix. If this assumption does not hold for your use case, use
+ * #undistortPoints with {@code P = cv::NoArray()} for both cameras to transform image points
+ * to normalized image coordinates, which are valid for the identity camera intrinsic matrix. When
+ * passing these coordinates, pass the identity matrix for this parameter.
+ * @param method Method for computing an essential matrix.
+ *
+ *
+ * REF: RANSAC for the RANSAC algorithm.
+ *
+ *
+ * REF: LMEDS for the LMedS algorithm.
+ *
+ *
+ * @param prob Parameter used for the RANSAC or LMedS methods only. It specifies a desirable level of
+ * confidence (probability) that the estimated matrix is correct.
+ * line in pixels, beyond which the point is considered an outlier and is not used for computing the
+ * final fundamental matrix. It can be set to something like 1-3, depending on the accuracy of the
+ * point localization, image resolution, and the image noise.
+ * for the other points. The array is computed only in the RANSAC and LMedS methods.
+ *
+ * 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:
+ *
+ * \([p_2; 1]^T K^{-T} E K^{-1} [p_1; 1] = 0\)
+ *
+ * where \(E\) is an essential matrix, \(p_1\) and \(p_2\) are corresponding points in the first and the
+ * second images, respectively. The result of this function may be passed further to
+ * #decomposeEssentialMat or #recoverPose to recover the relative pose between cameras.
+ * @return automatically generated
+ */
+ public static Mat findEssentialMat(Mat points1, Mat points2, Mat cameraMatrix, int method, double prob) {
+ return new Mat(findEssentialMat_3(points1.nativeObj, points2.nativeObj, cameraMatrix.nativeObj, method, prob));
+ }
+
+ /**
+ * Calculates an essential matrix from the corresponding points in two images.
+ *
+ * @param points1 Array of N (N >= 5) 2D points from the first image. The point coordinates should
+ * be floating-point (single or double precision).
+ * @param points2 Array of the second image points of the same size and format as points1 .
+ * @param cameraMatrix Camera intrinsic matrix \(\cameramatrix{A}\) .
+ * Note that this function assumes that points1 and points2 are feature points from cameras with the
+ * same camera intrinsic matrix. If this assumption does not hold for your use case, use
+ * #undistortPoints with {@code P = cv::NoArray()} for both cameras to transform image points
+ * to normalized image coordinates, which are valid for the identity camera intrinsic matrix. When
+ * passing these coordinates, pass the identity matrix for this parameter.
+ * @param method Method for computing an essential matrix.
+ *
+ *
+ * REF: RANSAC for the RANSAC algorithm.
+ *
+ *
+ * REF: LMEDS for the LMedS algorithm.
+ *
+ *
+ * confidence (probability) that the estimated matrix is correct.
+ * line in pixels, beyond which the point is considered an outlier and is not used for computing the
+ * final fundamental matrix. It can be set to something like 1-3, depending on the accuracy of the
+ * point localization, image resolution, and the image noise.
+ * for the other points. The array is computed only in the RANSAC and LMedS methods.
+ *
+ * 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:
+ *
+ * \([p_2; 1]^T K^{-T} E K^{-1} [p_1; 1] = 0\)
+ *
+ * where \(E\) is an essential matrix, \(p_1\) and \(p_2\) are corresponding points in the first and the
+ * second images, respectively. The result of this function may be passed further to
+ * #decomposeEssentialMat or #recoverPose to recover the relative pose between cameras.
+ * @return automatically generated
+ */
+ public static Mat findEssentialMat(Mat points1, Mat points2, Mat cameraMatrix, int method) {
+ return new Mat(findEssentialMat_4(points1.nativeObj, points2.nativeObj, cameraMatrix.nativeObj, method));
+ }
+
+ /**
+ * Calculates an essential matrix from the corresponding points in two images.
+ *
+ * @param points1 Array of N (N >= 5) 2D points from the first image. The point coordinates should
+ * be floating-point (single or double precision).
+ * @param points2 Array of the second image points of the same size and format as points1 .
+ * @param cameraMatrix Camera intrinsic matrix \(\cameramatrix{A}\) .
+ * Note that this function assumes that points1 and points2 are feature points from cameras with the
+ * same camera intrinsic matrix. If this assumption does not hold for your use case, use
+ * #undistortPoints with {@code P = cv::NoArray()} for both cameras to transform image points
+ * to normalized image coordinates, which are valid for the identity camera intrinsic matrix. When
+ * passing these coordinates, pass the identity matrix for this parameter.
+ *
+ *
+ * REF: RANSAC for the RANSAC algorithm.
+ *
+ *
+ * REF: LMEDS for the LMedS algorithm.
+ *
+ *
+ * confidence (probability) that the estimated matrix is correct.
+ * line in pixels, beyond which the point is considered an outlier and is not used for computing the
+ * final fundamental matrix. It can be set to something like 1-3, depending on the accuracy of the
+ * point localization, image resolution, and the image noise.
+ * for the other points. The array is computed only in the RANSAC and LMedS methods.
+ *
+ * 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:
+ *
+ * \([p_2; 1]^T K^{-T} E K^{-1} [p_1; 1] = 0\)
+ *
+ * where \(E\) is an essential matrix, \(p_1\) and \(p_2\) are corresponding points in the first and the
+ * second images, respectively. The result of this function may be passed further to
+ * #decomposeEssentialMat or #recoverPose to recover the relative pose between cameras.
+ * @return automatically generated
+ */
+ public static Mat findEssentialMat(Mat points1, Mat points2, Mat cameraMatrix) {
+ return new Mat(findEssentialMat_5(points1.nativeObj, points2.nativeObj, cameraMatrix.nativeObj));
+ }
+
+
+ //
+ // C++: Mat cv::findEssentialMat(Mat points1, Mat points2, double focal = 1.0, Point2d pp = Point2d(0, 0), int method = RANSAC, double prob = 0.999, double threshold = 1.0, int maxIters = 1000, Mat& mask = Mat())
+ //
+
+ /**
+ *
+ * @param points1 Array of N (N >= 5) 2D points from the first image. The point coordinates should
+ * be floating-point (single or double precision).
+ * @param points2 Array of the second image points of the same size and format as points1 .
+ * @param focal focal length of the camera. Note that this function assumes that points1 and points2
+ * are feature points from cameras with same focal length and principal point.
+ * @param pp principal point of the camera.
+ * @param method Method for computing a fundamental matrix.
+ *
+ *
+ * REF: RANSAC for the RANSAC algorithm.
+ *
+ *
+ * REF: LMEDS for the LMedS algorithm.
+ *
+ *
+ * @param threshold Parameter used for RANSAC. It is the maximum distance from a point to an epipolar
+ * line in pixels, beyond which the point is considered an outlier and is not used for computing the
+ * final fundamental matrix. It can be set to something like 1-3, depending on the accuracy of the
+ * point localization, image resolution, and the image noise.
+ * @param prob Parameter used for the RANSAC or LMedS methods only. It specifies a desirable level of
+ * confidence (probability) that the estimated matrix is correct.
+ * @param 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:
+ *
+ * \(A =
+ * \begin{bmatrix}
+ * f & 0 & x_{pp} \\
+ * 0 & f & y_{pp} \\
+ * 0 & 0 & 1
+ * \end{bmatrix}\)
+ * @return automatically generated
+ */
+ public static Mat findEssentialMat(Mat points1, Mat points2, double focal, Point pp, int method, double prob, double threshold, int maxIters, Mat mask) {
+ return new Mat(findEssentialMat_6(points1.nativeObj, points2.nativeObj, focal, pp.x, pp.y, method, prob, threshold, maxIters, mask.nativeObj));
+ }
+
+ /**
+ *
+ * @param points1 Array of N (N >= 5) 2D points from the first image. The point coordinates should
+ * be floating-point (single or double precision).
+ * @param points2 Array of the second image points of the same size and format as points1 .
+ * @param focal focal length of the camera. Note that this function assumes that points1 and points2
+ * are feature points from cameras with same focal length and principal point.
+ * @param pp principal point of the camera.
+ * @param method Method for computing a fundamental matrix.
+ *
+ *
+ * REF: RANSAC for the RANSAC algorithm.
+ *
+ *
+ * REF: LMEDS for the LMedS algorithm.
+ *
+ *
+ * @param threshold Parameter used for RANSAC. It is the maximum distance from a point to an epipolar
+ * line in pixels, beyond which the point is considered an outlier and is not used for computing the
+ * final fundamental matrix. It can be set to something like 1-3, depending on the accuracy of the
+ * point localization, image resolution, and the image noise.
+ * @param prob Parameter used for the RANSAC or LMedS methods only. It specifies a desirable level of
+ * confidence (probability) that the estimated matrix is correct.
+ * 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:
+ *
+ * \(A =
+ * \begin{bmatrix}
+ * f & 0 & x_{pp} \\
+ * 0 & f & y_{pp} \\
+ * 0 & 0 & 1
+ * \end{bmatrix}\)
+ * @return automatically generated
+ */
+ public static Mat findEssentialMat(Mat points1, Mat points2, double focal, Point pp, int method, double prob, double threshold, int maxIters) {
+ return new Mat(findEssentialMat_7(points1.nativeObj, points2.nativeObj, focal, pp.x, pp.y, method, prob, threshold, maxIters));
+ }
+
+ /**
+ *
+ * @param points1 Array of N (N >= 5) 2D points from the first image. The point coordinates should
+ * be floating-point (single or double precision).
+ * @param points2 Array of the second image points of the same size and format as points1 .
+ * @param focal focal length of the camera. Note that this function assumes that points1 and points2
+ * are feature points from cameras with same focal length and principal point.
+ * @param pp principal point of the camera.
+ * @param method Method for computing a fundamental matrix.
+ *
+ *
+ * REF: RANSAC for the RANSAC algorithm.
+ *
+ *
+ * REF: LMEDS for the LMedS algorithm.
+ *
+ *
+ * @param threshold Parameter used for RANSAC. It is the maximum distance from a point to an epipolar
+ * line in pixels, beyond which the point is considered an outlier and is not used for computing the
+ * final fundamental matrix. It can be set to something like 1-3, depending on the accuracy of the
+ * point localization, image resolution, and the image noise.
+ * @param prob Parameter used for the RANSAC or LMedS methods only. It specifies a desirable level of
+ * confidence (probability) that the estimated matrix is correct.
+ * for the other points. The array is computed only in the RANSAC and LMedS methods.
+ *
+ * This function differs from the one above that it computes camera intrinsic matrix from focal length and
+ * principal point:
+ *
+ * \(A =
+ * \begin{bmatrix}
+ * f & 0 & x_{pp} \\
+ * 0 & f & y_{pp} \\
+ * 0 & 0 & 1
+ * \end{bmatrix}\)
+ * @return automatically generated
+ */
+ public static Mat findEssentialMat(Mat points1, Mat points2, double focal, Point pp, int method, double prob, double threshold) {
+ return new Mat(findEssentialMat_8(points1.nativeObj, points2.nativeObj, focal, pp.x, pp.y, method, prob, threshold));
+ }
+
+ /**
+ *
+ * @param points1 Array of N (N >= 5) 2D points from the first image. The point coordinates should
+ * be floating-point (single or double precision).
+ * @param points2 Array of the second image points of the same size and format as points1 .
+ * @param focal focal length of the camera. Note that this function assumes that points1 and points2
+ * are feature points from cameras with same focal length and principal point.
+ * @param pp principal point of the camera.
+ * @param method Method for computing a fundamental matrix.
+ *
+ *
+ * REF: RANSAC for the RANSAC algorithm.
+ *
+ *
+ * REF: LMEDS for the LMedS algorithm.
+ *
+ *
+ * line in pixels, beyond which the point is considered an outlier and is not used for computing the
+ * final fundamental matrix. It can be set to something like 1-3, depending on the accuracy of the
+ * point localization, image resolution, and the image noise.
+ * @param prob Parameter used for the RANSAC or LMedS methods only. It specifies a desirable level of
+ * confidence (probability) that the estimated matrix is correct.
+ * for the other points. The array is computed only in the RANSAC and LMedS methods.
+ *
+ * This function differs from the one above that it computes camera intrinsic matrix from focal length and
+ * principal point:
+ *
+ * \(A =
+ * \begin{bmatrix}
+ * f & 0 & x_{pp} \\
+ * 0 & f & y_{pp} \\
+ * 0 & 0 & 1
+ * \end{bmatrix}\)
+ * @return automatically generated
+ */
+ public static Mat findEssentialMat(Mat points1, Mat points2, double focal, Point pp, int method, double prob) {
+ return new Mat(findEssentialMat_9(points1.nativeObj, points2.nativeObj, focal, pp.x, pp.y, method, prob));
+ }
+
+ /**
+ *
+ * @param points1 Array of N (N >= 5) 2D points from the first image. The point coordinates should
+ * be floating-point (single or double precision).
+ * @param points2 Array of the second image points of the same size and format as points1 .
+ * @param focal focal length of the camera. Note that this function assumes that points1 and points2
+ * are feature points from cameras with same focal length and principal point.
+ * @param pp principal point of the camera.
+ * @param method Method for computing a fundamental matrix.
+ *
+ *
+ * REF: RANSAC for the RANSAC algorithm.
+ *
+ *
+ * REF: LMEDS for the LMedS algorithm.
+ *
+ *
+ * line in pixels, beyond which the point is considered an outlier and is not used for computing the
+ * final fundamental matrix. It can be set to something like 1-3, depending on the accuracy of the
+ * point localization, image resolution, and the image noise.
+ * confidence (probability) that the estimated matrix is correct.
+ * for the other points. The array is computed only in the RANSAC and LMedS methods.
+ *
+ * This function differs from the one above that it computes camera intrinsic matrix from focal length and
+ * principal point:
+ *
+ * \(A =
+ * \begin{bmatrix}
+ * f & 0 & x_{pp} \\
+ * 0 & f & y_{pp} \\
+ * 0 & 0 & 1
+ * \end{bmatrix}\)
+ * @return automatically generated
+ */
+ public static Mat findEssentialMat(Mat points1, Mat points2, double focal, Point pp, int method) {
+ return new Mat(findEssentialMat_10(points1.nativeObj, points2.nativeObj, focal, pp.x, pp.y, method));
+ }
+
+ /**
+ *
+ * @param points1 Array of N (N >= 5) 2D points from the first image. The point coordinates should
+ * be floating-point (single or double precision).
+ * @param points2 Array of the second image points of the same size and format as points1 .
+ * @param focal focal length of the camera. Note that this function assumes that points1 and points2
+ * are feature points from cameras with same focal length and principal point.
+ * @param pp principal point of the camera.
+ *
+ *
+ * REF: RANSAC for the RANSAC algorithm.
+ *
+ *
+ * REF: LMEDS for the LMedS algorithm.
+ *
+ *
+ * line in pixels, beyond which the point is considered an outlier and is not used for computing the
+ * final fundamental matrix. It can be set to something like 1-3, depending on the accuracy of the
+ * point localization, image resolution, and the image noise.
+ * confidence (probability) that the estimated matrix is correct.
+ * for the other points. The array is computed only in the RANSAC and LMedS methods.
+ *
+ * This function differs from the one above that it computes camera intrinsic matrix from focal length and
+ * principal point:
+ *
+ * \(A =
+ * \begin{bmatrix}
+ * f & 0 & x_{pp} \\
+ * 0 & f & y_{pp} \\
+ * 0 & 0 & 1
+ * \end{bmatrix}\)
+ * @return automatically generated
+ */
+ public static Mat findEssentialMat(Mat points1, Mat points2, double focal, Point pp) {
+ return new Mat(findEssentialMat_11(points1.nativeObj, points2.nativeObj, focal, pp.x, pp.y));
+ }
+
+ /**
+ *
+ * @param points1 Array of N (N >= 5) 2D points from the first image. The point coordinates should
+ * be floating-point (single or double precision).
+ * @param points2 Array of the second image points of the same size and format as points1 .
+ * @param focal focal length of the camera. Note that this function assumes that points1 and points2
+ * are feature points from cameras with same focal length and principal point.
+ *
+ *
+ * REF: RANSAC for the RANSAC algorithm.
+ *
+ *
+ * REF: LMEDS for the LMedS algorithm.
+ *
+ *
+ * line in pixels, beyond which the point is considered an outlier and is not used for computing the
+ * final fundamental matrix. It can be set to something like 1-3, depending on the accuracy of the
+ * point localization, image resolution, and the image noise.
+ * confidence (probability) that the estimated matrix is correct.
+ * for the other points. The array is computed only in the RANSAC and LMedS methods.
+ *
+ * This function differs from the one above that it computes camera intrinsic matrix from focal length and
+ * principal point:
+ *
+ * \(A =
+ * \begin{bmatrix}
+ * f & 0 & x_{pp} \\
+ * 0 & f & y_{pp} \\
+ * 0 & 0 & 1
+ * \end{bmatrix}\)
+ * @return automatically generated
+ */
+ public static Mat findEssentialMat(Mat points1, Mat points2, double focal) {
+ return new Mat(findEssentialMat_12(points1.nativeObj, points2.nativeObj, focal));
+ }
+
+ /**
+ *
+ * @param points1 Array of N (N >= 5) 2D points from the first image. The point coordinates should
+ * be floating-point (single or double precision).
+ * @param points2 Array of the second image points of the same size and format as points1 .
+ * are feature points from cameras with same focal length and principal point.
+ *
+ *
+ * REF: RANSAC for the RANSAC algorithm.
+ *
+ *
+ * REF: LMEDS for the LMedS algorithm.
+ *
+ *
+ * line in pixels, beyond which the point is considered an outlier and is not used for computing the
+ * final fundamental matrix. It can be set to something like 1-3, depending on the accuracy of the
+ * point localization, image resolution, and the image noise.
+ * confidence (probability) that the estimated matrix is correct.
+ * for the other points. The array is computed only in the RANSAC and LMedS methods.
+ *
+ * This function differs from the one above that it computes camera intrinsic matrix from focal length and
+ * principal point:
+ *
+ * \(A =
+ * \begin{bmatrix}
+ * f & 0 & x_{pp} \\
+ * 0 & f & y_{pp} \\
+ * 0 & 0 & 1
+ * \end{bmatrix}\)
+ * @return automatically generated
+ */
+ public static Mat findEssentialMat(Mat points1, Mat points2) {
+ return new Mat(findEssentialMat_13(points1.nativeObj, points2.nativeObj));
+ }
+
+
+ //
+ // C++: Mat cv::findEssentialMat(Mat points1, Mat points2, Mat cameraMatrix1, Mat distCoeffs1, Mat cameraMatrix2, Mat distCoeffs2, int method = RANSAC, double prob = 0.999, double threshold = 1.0, Mat& mask = Mat())
+ //
+
+ /**
+ * Calculates an essential matrix from the corresponding points in two images from potentially two different cameras.
+ *
+ * @param points1 Array of N (N >= 5) 2D points from the first image. The point coordinates should
+ * be floating-point (single or double precision).
+ * @param points2 Array of the second image points of the same size and format as points1 .
+ * @param cameraMatrix1 Camera matrix \(K = \vecthreethree{f_x}{0}{c_x}{0}{f_y}{c_y}{0}{0}{1}\) .
+ * Note that this function assumes that points1 and points2 are feature points from cameras with the
+ * same camera matrix. If this assumption does not hold for your use case, use
+ * #undistortPoints with {@code P = cv::NoArray()} for both cameras to transform image points
+ * to normalized image coordinates, which are valid for the identity camera matrix. When
+ * passing these coordinates, pass the identity matrix for this parameter.
+ * @param cameraMatrix2 Camera matrix \(K = \vecthreethree{f_x}{0}{c_x}{0}{f_y}{c_y}{0}{0}{1}\) .
+ * Note that this function assumes that points1 and points2 are feature points from cameras with the
+ * same camera matrix. If this assumption does not hold for your use case, use
+ * #undistortPoints with {@code P = cv::NoArray()} for both cameras to transform image points
+ * to normalized image coordinates, which are valid for the identity camera matrix. When
+ * passing these coordinates, pass the identity matrix for this parameter.
+ * @param distCoeffs1 Input vector of distortion coefficients
+ * \((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]]]])\)
+ * of 4, 5, 8, 12 or 14 elements. If the vector is NULL/empty, the zero distortion coefficients are assumed.
+ * @param distCoeffs2 Input vector of distortion coefficients
+ * \((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]]]])\)
+ * of 4, 5, 8, 12 or 14 elements. If the vector is NULL/empty, the zero distortion coefficients are assumed.
+ * @param method Method for computing an essential matrix.
+ *
+ *
+ * REF: RANSAC for the RANSAC algorithm.
+ *
+ *
+ * REF: LMEDS for the LMedS algorithm.
+ *
+ *
+ * @param prob Parameter used for the RANSAC or LMedS methods only. It specifies a desirable level of
+ * confidence (probability) that the estimated matrix is correct.
+ * @param threshold Parameter used for RANSAC. It is the maximum distance from a point to an epipolar
+ * line in pixels, beyond which the point is considered an outlier and is not used for computing the
+ * final fundamental matrix. It can be set to something like 1-3, depending on the accuracy of the
+ * point localization, image resolution, and the image noise.
+ * @param 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.
+ *
+ * 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:
+ *
+ * \([p_2; 1]^T K^{-T} E K^{-1} [p_1; 1] = 0\)
+ *
+ * where \(E\) is an essential matrix, \(p_1\) and \(p_2\) are corresponding points in the first and the
+ * second images, respectively. The result of this function may be passed further to
+ * #decomposeEssentialMat or #recoverPose to recover the relative pose between cameras.
+ * @return automatically generated
+ */
+ public static Mat findEssentialMat(Mat points1, Mat points2, Mat cameraMatrix1, Mat distCoeffs1, Mat cameraMatrix2, Mat distCoeffs2, int method, double prob, double threshold, Mat mask) {
+ return new Mat(findEssentialMat_14(points1.nativeObj, points2.nativeObj, cameraMatrix1.nativeObj, distCoeffs1.nativeObj, cameraMatrix2.nativeObj, distCoeffs2.nativeObj, method, prob, threshold, mask.nativeObj));
+ }
+
+ /**
+ * Calculates an essential matrix from the corresponding points in two images from potentially two different cameras.
+ *
+ * @param points1 Array of N (N >= 5) 2D points from the first image. The point coordinates should
+ * be floating-point (single or double precision).
+ * @param points2 Array of the second image points of the same size and format as points1 .
+ * @param cameraMatrix1 Camera matrix \(K = \vecthreethree{f_x}{0}{c_x}{0}{f_y}{c_y}{0}{0}{1}\) .
+ * Note that this function assumes that points1 and points2 are feature points from cameras with the
+ * same camera matrix. If this assumption does not hold for your use case, use
+ * #undistortPoints with {@code P = cv::NoArray()} for both cameras to transform image points
+ * to normalized image coordinates, which are valid for the identity camera matrix. When
+ * passing these coordinates, pass the identity matrix for this parameter.
+ * @param cameraMatrix2 Camera matrix \(K = \vecthreethree{f_x}{0}{c_x}{0}{f_y}{c_y}{0}{0}{1}\) .
+ * Note that this function assumes that points1 and points2 are feature points from cameras with the
+ * same camera matrix. If this assumption does not hold for your use case, use
+ * #undistortPoints with {@code P = cv::NoArray()} for both cameras to transform image points
+ * to normalized image coordinates, which are valid for the identity camera matrix. When
+ * passing these coordinates, pass the identity matrix for this parameter.
+ * @param distCoeffs1 Input vector of distortion coefficients
+ * \((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]]]])\)
+ * of 4, 5, 8, 12 or 14 elements. If the vector is NULL/empty, the zero distortion coefficients are assumed.
+ * @param distCoeffs2 Input vector of distortion coefficients
+ * \((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]]]])\)
+ * of 4, 5, 8, 12 or 14 elements. If the vector is NULL/empty, the zero distortion coefficients are assumed.
+ * @param method Method for computing an essential matrix.
+ *
+ *
+ * REF: RANSAC for the RANSAC algorithm.
+ *
+ *
+ * REF: LMEDS for the LMedS algorithm.
+ *
+ *
+ * @param prob Parameter used for the RANSAC or LMedS methods only. It specifies a desirable level of
+ * confidence (probability) that the estimated matrix is correct.
+ * @param threshold Parameter used for RANSAC. It is the maximum distance from a point to an epipolar
+ * line in pixels, beyond which the point is considered an outlier and is not used for computing the
+ * final fundamental matrix. It can be set to something like 1-3, depending on the accuracy of the
+ * point localization, image resolution, and the image noise.
+ * for the other points. The array is computed only in the RANSAC and LMedS methods.
+ *
+ * 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:
+ *
+ * \([p_2; 1]^T K^{-T} E K^{-1} [p_1; 1] = 0\)
+ *
+ * where \(E\) is an essential matrix, \(p_1\) and \(p_2\) are corresponding points in the first and the
+ * second images, respectively. The result of this function may be passed further to
+ * #decomposeEssentialMat or #recoverPose to recover the relative pose between cameras.
+ * @return automatically generated
+ */
+ public static Mat findEssentialMat(Mat points1, Mat points2, Mat cameraMatrix1, Mat distCoeffs1, Mat cameraMatrix2, Mat distCoeffs2, int method, double prob, double threshold) {
+ return new Mat(findEssentialMat_15(points1.nativeObj, points2.nativeObj, cameraMatrix1.nativeObj, distCoeffs1.nativeObj, cameraMatrix2.nativeObj, distCoeffs2.nativeObj, method, prob, threshold));
+ }
+
+ /**
+ * Calculates an essential matrix from the corresponding points in two images from potentially two different cameras.
+ *
+ * @param points1 Array of N (N >= 5) 2D points from the first image. The point coordinates should
+ * be floating-point (single or double precision).
+ * @param points2 Array of the second image points of the same size and format as points1 .
+ * @param cameraMatrix1 Camera matrix \(K = \vecthreethree{f_x}{0}{c_x}{0}{f_y}{c_y}{0}{0}{1}\) .
+ * Note that this function assumes that points1 and points2 are feature points from cameras with the
+ * same camera matrix. If this assumption does not hold for your use case, use
+ * #undistortPoints with {@code P = cv::NoArray()} for both cameras to transform image points
+ * to normalized image coordinates, which are valid for the identity camera matrix. When
+ * passing these coordinates, pass the identity matrix for this parameter.
+ * @param cameraMatrix2 Camera matrix \(K = \vecthreethree{f_x}{0}{c_x}{0}{f_y}{c_y}{0}{0}{1}\) .
+ * Note that this function assumes that points1 and points2 are feature points from cameras with the
+ * same camera matrix. If this assumption does not hold for your use case, use
+ * #undistortPoints with {@code P = cv::NoArray()} for both cameras to transform image points
+ * to normalized image coordinates, which are valid for the identity camera matrix. When
+ * passing these coordinates, pass the identity matrix for this parameter.
+ * @param distCoeffs1 Input vector of distortion coefficients
+ * \((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]]]])\)
+ * of 4, 5, 8, 12 or 14 elements. If the vector is NULL/empty, the zero distortion coefficients are assumed.
+ * @param distCoeffs2 Input vector of distortion coefficients
+ * \((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]]]])\)
+ * of 4, 5, 8, 12 or 14 elements. If the vector is NULL/empty, the zero distortion coefficients are assumed.
+ * @param method Method for computing an essential matrix.
+ *
+ *
+ * REF: RANSAC for the RANSAC algorithm.
+ *
+ *
+ * REF: LMEDS for the LMedS algorithm.
+ *
+ *
+ * @param prob Parameter used for the RANSAC or LMedS methods only. It specifies a desirable level of
+ * confidence (probability) that the estimated matrix is correct.
+ * line in pixels, beyond which the point is considered an outlier and is not used for computing the
+ * final fundamental matrix. It can be set to something like 1-3, depending on the accuracy of the
+ * point localization, image resolution, and the image noise.
+ * for the other points. The array is computed only in the RANSAC and LMedS methods.
+ *
+ * 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:
+ *
+ * \([p_2; 1]^T K^{-T} E K^{-1} [p_1; 1] = 0\)
+ *
+ * where \(E\) is an essential matrix, \(p_1\) and \(p_2\) are corresponding points in the first and the
+ * second images, respectively. The result of this function may be passed further to
+ * #decomposeEssentialMat or #recoverPose to recover the relative pose between cameras.
+ * @return automatically generated
+ */
+ public static Mat findEssentialMat(Mat points1, Mat points2, Mat cameraMatrix1, Mat distCoeffs1, Mat cameraMatrix2, Mat distCoeffs2, int method, double prob) {
+ return new Mat(findEssentialMat_16(points1.nativeObj, points2.nativeObj, cameraMatrix1.nativeObj, distCoeffs1.nativeObj, cameraMatrix2.nativeObj, distCoeffs2.nativeObj, method, prob));
+ }
+
+ /**
+ * Calculates an essential matrix from the corresponding points in two images from potentially two different cameras.
+ *
+ * @param points1 Array of N (N >= 5) 2D points from the first image. The point coordinates should
+ * be floating-point (single or double precision).
+ * @param points2 Array of the second image points of the same size and format as points1 .
+ * @param cameraMatrix1 Camera matrix \(K = \vecthreethree{f_x}{0}{c_x}{0}{f_y}{c_y}{0}{0}{1}\) .
+ * Note that this function assumes that points1 and points2 are feature points from cameras with the
+ * same camera matrix. If this assumption does not hold for your use case, use
+ * #undistortPoints with {@code P = cv::NoArray()} for both cameras to transform image points
+ * to normalized image coordinates, which are valid for the identity camera matrix. When
+ * passing these coordinates, pass the identity matrix for this parameter.
+ * @param cameraMatrix2 Camera matrix \(K = \vecthreethree{f_x}{0}{c_x}{0}{f_y}{c_y}{0}{0}{1}\) .
+ * Note that this function assumes that points1 and points2 are feature points from cameras with the
+ * same camera matrix. If this assumption does not hold for your use case, use
+ * #undistortPoints with {@code P = cv::NoArray()} for both cameras to transform image points
+ * to normalized image coordinates, which are valid for the identity camera matrix. When
+ * passing these coordinates, pass the identity matrix for this parameter.
+ * @param distCoeffs1 Input vector of distortion coefficients
+ * \((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]]]])\)
+ * of 4, 5, 8, 12 or 14 elements. If the vector is NULL/empty, the zero distortion coefficients are assumed.
+ * @param distCoeffs2 Input vector of distortion coefficients
+ * \((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]]]])\)
+ * of 4, 5, 8, 12 or 14 elements. If the vector is NULL/empty, the zero distortion coefficients are assumed.
+ * @param method Method for computing an essential matrix.
+ *
+ *
+ * REF: RANSAC for the RANSAC algorithm.
+ *
+ *
+ * REF: LMEDS for the LMedS algorithm.
+ *
+ *
+ * confidence (probability) that the estimated matrix is correct.
+ * line in pixels, beyond which the point is considered an outlier and is not used for computing the
+ * final fundamental matrix. It can be set to something like 1-3, depending on the accuracy of the
+ * point localization, image resolution, and the image noise.
+ * for the other points. The array is computed only in the RANSAC and LMedS methods.
+ *
+ * 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:
+ *
+ * \([p_2; 1]^T K^{-T} E K^{-1} [p_1; 1] = 0\)
+ *
+ * where \(E\) is an essential matrix, \(p_1\) and \(p_2\) are corresponding points in the first and the
+ * second images, respectively. The result of this function may be passed further to
+ * #decomposeEssentialMat or #recoverPose to recover the relative pose between cameras.
+ * @return automatically generated
+ */
+ public static Mat findEssentialMat(Mat points1, Mat points2, Mat cameraMatrix1, Mat distCoeffs1, Mat cameraMatrix2, Mat distCoeffs2, int method) {
+ return new Mat(findEssentialMat_17(points1.nativeObj, points2.nativeObj, cameraMatrix1.nativeObj, distCoeffs1.nativeObj, cameraMatrix2.nativeObj, distCoeffs2.nativeObj, method));
+ }
+
+ /**
+ * Calculates an essential matrix from the corresponding points in two images from potentially two different cameras.
+ *
+ * @param points1 Array of N (N >= 5) 2D points from the first image. The point coordinates should
+ * be floating-point (single or double precision).
+ * @param points2 Array of the second image points of the same size and format as points1 .
+ * @param cameraMatrix1 Camera matrix \(K = \vecthreethree{f_x}{0}{c_x}{0}{f_y}{c_y}{0}{0}{1}\) .
+ * Note that this function assumes that points1 and points2 are feature points from cameras with the
+ * same camera matrix. If this assumption does not hold for your use case, use
+ * #undistortPoints with {@code P = cv::NoArray()} for both cameras to transform image points
+ * to normalized image coordinates, which are valid for the identity camera matrix. When
+ * passing these coordinates, pass the identity matrix for this parameter.
+ * @param cameraMatrix2 Camera matrix \(K = \vecthreethree{f_x}{0}{c_x}{0}{f_y}{c_y}{0}{0}{1}\) .
+ * Note that this function assumes that points1 and points2 are feature points from cameras with the
+ * same camera matrix. If this assumption does not hold for your use case, use
+ * #undistortPoints with {@code P = cv::NoArray()} for both cameras to transform image points
+ * to normalized image coordinates, which are valid for the identity camera matrix. When
+ * passing these coordinates, pass the identity matrix for this parameter.
+ * @param distCoeffs1 Input vector of distortion coefficients
+ * \((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]]]])\)
+ * of 4, 5, 8, 12 or 14 elements. If the vector is NULL/empty, the zero distortion coefficients are assumed.
+ * @param distCoeffs2 Input vector of distortion coefficients
+ * \((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]]]])\)
+ * of 4, 5, 8, 12 or 14 elements. If the vector is NULL/empty, the zero distortion coefficients are assumed.
+ *
+ *
+ * REF: RANSAC for the RANSAC algorithm.
+ *
+ *
+ * REF: LMEDS for the LMedS algorithm.
+ *
+ *
+ * confidence (probability) that the estimated matrix is correct.
+ * line in pixels, beyond which the point is considered an outlier and is not used for computing the
+ * final fundamental matrix. It can be set to something like 1-3, depending on the accuracy of the
+ * point localization, image resolution, and the image noise.
+ * for the other points. The array is computed only in the RANSAC and LMedS methods.
+ *
+ * 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:
+ *
+ * \([p_2; 1]^T K^{-T} E K^{-1} [p_1; 1] = 0\)
+ *
+ * where \(E\) is an essential matrix, \(p_1\) and \(p_2\) are corresponding points in the first and the
+ * second images, respectively. The result of this function may be passed further to
+ * #decomposeEssentialMat or #recoverPose to recover the relative pose between cameras.
+ * @return automatically generated
+ */
+ public static Mat findEssentialMat(Mat points1, Mat points2, Mat cameraMatrix1, Mat distCoeffs1, Mat cameraMatrix2, Mat distCoeffs2) {
+ return new Mat(findEssentialMat_18(points1.nativeObj, points2.nativeObj, cameraMatrix1.nativeObj, distCoeffs1.nativeObj, cameraMatrix2.nativeObj, distCoeffs2.nativeObj));
+ }
+
+
+ //
+ // C++: Mat cv::findEssentialMat(Mat points1, Mat points2, Mat cameraMatrix1, Mat cameraMatrix2, Mat dist_coeff1, Mat dist_coeff2, Mat& mask, UsacParams params)
+ //
+
+ public static Mat findEssentialMat(Mat points1, Mat points2, Mat cameraMatrix1, Mat cameraMatrix2, Mat dist_coeff1, Mat dist_coeff2, Mat mask, UsacParams params) {
+ return new Mat(findEssentialMat_19(points1.nativeObj, points2.nativeObj, cameraMatrix1.nativeObj, cameraMatrix2.nativeObj, dist_coeff1.nativeObj, dist_coeff2.nativeObj, mask.nativeObj, params.nativeObj));
+ }
+
+
+ //
+ // C++: void cv::decomposeEssentialMat(Mat E, Mat& R1, Mat& R2, Mat& t)
+ //
+
+ /**
+ * Decompose an essential matrix to possible rotations and translation.
+ *
+ * @param E The input essential matrix.
+ * @param R1 One possible rotation matrix.
+ * @param R2 Another possible rotation matrix.
+ * @param t One possible translation.
+ *
+ * This function decomposes the essential matrix E using svd decomposition CITE: HartleyZ00. In
+ * general, four possible poses exist for the decomposition of E. They are \([R_1, t]\),
+ * \([R_1, -t]\), \([R_2, t]\), \([R_2, -t]\).
+ *
+ * If E gives the epipolar constraint \([p_2; 1]^T A^{-T} E A^{-1} [p_1; 1] = 0\) between the image
+ * points \(p_1\) in the first image and \(p_2\) in second image, then any of the tuples
+ * \([R_1, t]\), \([R_1, -t]\), \([R_2, t]\), \([R_2, -t]\) is a change of basis from the first
+ * camera's coordinate system to the second camera's coordinate system. However, by decomposing E, one
+ * can only get the direction of the translation. For this reason, the translation t is returned with
+ * unit length.
+ */
+ public static void decomposeEssentialMat(Mat E, Mat R1, Mat R2, Mat t) {
+ decomposeEssentialMat_0(E.nativeObj, R1.nativeObj, R2.nativeObj, t.nativeObj);
+ }
+
+
+ //
+ // C++: int cv::recoverPose(Mat points1, Mat points2, Mat cameraMatrix1, Mat distCoeffs1, Mat cameraMatrix2, Mat distCoeffs2, Mat& E, Mat& R, Mat& t, int method = cv::RANSAC, double prob = 0.999, double threshold = 1.0, Mat& mask = Mat())
+ //
+
+ /**
+ * Recovers the relative camera rotation and the translation from corresponding points in two images from two different cameras, using cheirality check. Returns the number of
+ * inliers that pass the check.
+ *
+ * @param points1 Array of N 2D points from the first image. The point coordinates should be
+ * floating-point (single or double precision).
+ * @param points2 Array of the second image points of the same size and format as points1 .
+ * @param cameraMatrix1 Input/output camera matrix for the first camera, the same as in
+ * REF: calibrateCamera. Furthermore, for the stereo case, additional flags may be used, see below.
+ * @param distCoeffs1 Input/output vector of distortion coefficients, the same as in
+ * REF: calibrateCamera.
+ * @param cameraMatrix2 Input/output camera matrix for the first camera, the same as in
+ * REF: calibrateCamera. Furthermore, for the stereo case, additional flags may be used, see below.
+ * @param distCoeffs2 Input/output vector of distortion coefficients, the same as in
+ * REF: calibrateCamera.
+ * @param E The output essential matrix.
+ * @param R Output rotation matrix. Together with the translation vector, this matrix makes up a tuple
+ * that performs a change of basis from the first camera's coordinate system to the second camera's
+ * coordinate system. Note that, in general, t can not be used for this tuple, see the parameter
+ * described below.
+ * @param t Output translation vector. This vector is obtained by REF: decomposeEssentialMat and
+ * therefore is only known up to scale, i.e. t is the direction of the translation vector and has unit
+ * length.
+ * @param method Method for computing an essential matrix.
+ *
+ *
+ * REF: RANSAC for the RANSAC algorithm.
+ *
+ *
+ * REF: LMEDS for the LMedS algorithm.
+ *
+ *
+ * @param prob Parameter used for the RANSAC or LMedS methods only. It specifies a desirable level of
+ * confidence (probability) that the estimated matrix is correct.
+ * @param threshold Parameter used for RANSAC. It is the maximum distance from a point to an epipolar
+ * line in pixels, beyond which the point is considered an outlier and is not used for computing the
+ * final fundamental matrix. It can be set to something like 1-3, depending on the accuracy of the
+ * point localization, image resolution, and the image noise.
+ * @param mask Input/output mask for inliers in points1 and points2. If it is not empty, then it marks
+ * inliers in points1 and points2 for then given essential matrix E. Only these inliers will be used to
+ * recover pose. In the output mask only inliers which pass the cheirality check.
+ *
+ * This function decomposes an essential matrix using REF: decomposeEssentialMat and then verifies
+ * possible pose hypotheses by doing cheirality check. The cheirality check means that the
+ * triangulated 3D points should have positive depth. Some details can be found in CITE: Nister03.
+ *
+ * This function can be used to process the output E and mask from REF: findEssentialMat. In this
+ * scenario, points1 and points2 are the same input for findEssentialMat.:
+ *
+ * // Example. Estimation of fundamental matrix using the RANSAC algorithm
+ * int point_count = 100;
+ * vector<Point2f> points1(point_count);
+ * vector<Point2f> points2(point_count);
+ *
+ * // initialize the points here ...
+ * for( int i = 0; i < point_count; i++ )
+ * {
+ * points1[i] = ...;
+ * points2[i] = ...;
+ * }
+ *
+ * // Input: camera calibration of both cameras, for example using intrinsic chessboard calibration.
+ * Mat cameraMatrix1, distCoeffs1, cameraMatrix2, distCoeffs2;
+ *
+ * // Output: Essential matrix, relative rotation and relative translation.
+ * Mat E, R, t, mask;
+ *
+ * recoverPose(points1, points2, cameraMatrix1, distCoeffs1, cameraMatrix2, distCoeffs2, E, R, t, mask);
+ *
+ * @return automatically generated
+ */
+ public static int recoverPose(Mat points1, Mat points2, Mat cameraMatrix1, Mat distCoeffs1, Mat cameraMatrix2, Mat distCoeffs2, Mat E, Mat R, Mat t, int method, double prob, double threshold, Mat mask) {
+ return recoverPose_0(points1.nativeObj, points2.nativeObj, cameraMatrix1.nativeObj, distCoeffs1.nativeObj, cameraMatrix2.nativeObj, distCoeffs2.nativeObj, E.nativeObj, R.nativeObj, t.nativeObj, method, prob, threshold, mask.nativeObj);
+ }
+
+ /**
+ * Recovers the relative camera rotation and the translation from corresponding points in two images from two different cameras, using cheirality check. Returns the number of
+ * inliers that pass the check.
+ *
+ * @param points1 Array of N 2D points from the first image. The point coordinates should be
+ * floating-point (single or double precision).
+ * @param points2 Array of the second image points of the same size and format as points1 .
+ * @param cameraMatrix1 Input/output camera matrix for the first camera, the same as in
+ * REF: calibrateCamera. Furthermore, for the stereo case, additional flags may be used, see below.
+ * @param distCoeffs1 Input/output vector of distortion coefficients, the same as in
+ * REF: calibrateCamera.
+ * @param cameraMatrix2 Input/output camera matrix for the first camera, the same as in
+ * REF: calibrateCamera. Furthermore, for the stereo case, additional flags may be used, see below.
+ * @param distCoeffs2 Input/output vector of distortion coefficients, the same as in
+ * REF: calibrateCamera.
+ * @param E The output essential matrix.
+ * @param R Output rotation matrix. Together with the translation vector, this matrix makes up a tuple
+ * that performs a change of basis from the first camera's coordinate system to the second camera's
+ * coordinate system. Note that, in general, t can not be used for this tuple, see the parameter
+ * described below.
+ * @param t Output translation vector. This vector is obtained by REF: decomposeEssentialMat and
+ * therefore is only known up to scale, i.e. t is the direction of the translation vector and has unit
+ * length.
+ * @param method Method for computing an essential matrix.
+ *
+ *
+ * REF: RANSAC for the RANSAC algorithm.
+ *
+ *
+ * REF: LMEDS for the LMedS algorithm.
+ *
+ *
+ * @param prob Parameter used for the RANSAC or LMedS methods only. It specifies a desirable level of
+ * confidence (probability) that the estimated matrix is correct.
+ * @param threshold Parameter used for RANSAC. It is the maximum distance from a point to an epipolar
+ * line in pixels, beyond which the point is considered an outlier and is not used for computing the
+ * final fundamental matrix. It can be set to something like 1-3, depending on the accuracy of the
+ * point localization, image resolution, and the image noise.
+ * inliers in points1 and points2 for then given essential matrix E. Only these inliers will be used to
+ * recover pose. In the output mask only inliers which pass the cheirality check.
+ *
+ * This function decomposes an essential matrix using REF: decomposeEssentialMat and then verifies
+ * possible pose hypotheses by doing cheirality check. The cheirality check means that the
+ * triangulated 3D points should have positive depth. Some details can be found in CITE: Nister03.
+ *
+ * This function can be used to process the output E and mask from REF: findEssentialMat. In this
+ * scenario, points1 and points2 are the same input for findEssentialMat.:
+ *
+ * // Example. Estimation of fundamental matrix using the RANSAC algorithm
+ * int point_count = 100;
+ * vector<Point2f> points1(point_count);
+ * vector<Point2f> points2(point_count);
+ *
+ * // initialize the points here ...
+ * for( int i = 0; i < point_count; i++ )
+ * {
+ * points1[i] = ...;
+ * points2[i] = ...;
+ * }
+ *
+ * // Input: camera calibration of both cameras, for example using intrinsic chessboard calibration.
+ * Mat cameraMatrix1, distCoeffs1, cameraMatrix2, distCoeffs2;
+ *
+ * // Output: Essential matrix, relative rotation and relative translation.
+ * Mat E, R, t, mask;
+ *
+ * recoverPose(points1, points2, cameraMatrix1, distCoeffs1, cameraMatrix2, distCoeffs2, E, R, t, mask);
+ *
+ * @return automatically generated
+ */
+ public static int recoverPose(Mat points1, Mat points2, Mat cameraMatrix1, Mat distCoeffs1, Mat cameraMatrix2, Mat distCoeffs2, Mat E, Mat R, Mat t, int method, double prob, double threshold) {
+ return recoverPose_1(points1.nativeObj, points2.nativeObj, cameraMatrix1.nativeObj, distCoeffs1.nativeObj, cameraMatrix2.nativeObj, distCoeffs2.nativeObj, E.nativeObj, R.nativeObj, t.nativeObj, method, prob, threshold);
+ }
+
+ /**
+ * Recovers the relative camera rotation and the translation from corresponding points in two images from two different cameras, using cheirality check. Returns the number of
+ * inliers that pass the check.
+ *
+ * @param points1 Array of N 2D points from the first image. The point coordinates should be
+ * floating-point (single or double precision).
+ * @param points2 Array of the second image points of the same size and format as points1 .
+ * @param cameraMatrix1 Input/output camera matrix for the first camera, the same as in
+ * REF: calibrateCamera. Furthermore, for the stereo case, additional flags may be used, see below.
+ * @param distCoeffs1 Input/output vector of distortion coefficients, the same as in
+ * REF: calibrateCamera.
+ * @param cameraMatrix2 Input/output camera matrix for the first camera, the same as in
+ * REF: calibrateCamera. Furthermore, for the stereo case, additional flags may be used, see below.
+ * @param distCoeffs2 Input/output vector of distortion coefficients, the same as in
+ * REF: calibrateCamera.
+ * @param E The output essential matrix.
+ * @param R Output rotation matrix. Together with the translation vector, this matrix makes up a tuple
+ * that performs a change of basis from the first camera's coordinate system to the second camera's
+ * coordinate system. Note that, in general, t can not be used for this tuple, see the parameter
+ * described below.
+ * @param t Output translation vector. This vector is obtained by REF: decomposeEssentialMat and
+ * therefore is only known up to scale, i.e. t is the direction of the translation vector and has unit
+ * length.
+ * @param method Method for computing an essential matrix.
+ *
+ *
+ * REF: RANSAC for the RANSAC algorithm.
+ *
+ *
+ * REF: LMEDS for the LMedS algorithm.
+ *
+ *
+ * @param prob Parameter used for the RANSAC or LMedS methods only. It specifies a desirable level of
+ * confidence (probability) that the estimated matrix is correct.
+ * line in pixels, beyond which the point is considered an outlier and is not used for computing the
+ * final fundamental matrix. It can be set to something like 1-3, depending on the accuracy of the
+ * point localization, image resolution, and the image noise.
+ * inliers in points1 and points2 for then given essential matrix E. Only these inliers will be used to
+ * recover pose. In the output mask only inliers which pass the cheirality check.
+ *
+ * This function decomposes an essential matrix using REF: decomposeEssentialMat and then verifies
+ * possible pose hypotheses by doing cheirality check. The cheirality check means that the
+ * triangulated 3D points should have positive depth. Some details can be found in CITE: Nister03.
+ *
+ * This function can be used to process the output E and mask from REF: findEssentialMat. In this
+ * scenario, points1 and points2 are the same input for findEssentialMat.:
+ *
+ * // Example. Estimation of fundamental matrix using the RANSAC algorithm
+ * int point_count = 100;
+ * vector<Point2f> points1(point_count);
+ * vector<Point2f> points2(point_count);
+ *
+ * // initialize the points here ...
+ * for( int i = 0; i < point_count; i++ )
+ * {
+ * points1[i] = ...;
+ * points2[i] = ...;
+ * }
+ *
+ * // Input: camera calibration of both cameras, for example using intrinsic chessboard calibration.
+ * Mat cameraMatrix1, distCoeffs1, cameraMatrix2, distCoeffs2;
+ *
+ * // Output: Essential matrix, relative rotation and relative translation.
+ * Mat E, R, t, mask;
+ *
+ * recoverPose(points1, points2, cameraMatrix1, distCoeffs1, cameraMatrix2, distCoeffs2, E, R, t, mask);
+ *
+ * @return automatically generated
+ */
+ public static int recoverPose(Mat points1, Mat points2, Mat cameraMatrix1, Mat distCoeffs1, Mat cameraMatrix2, Mat distCoeffs2, Mat E, Mat R, Mat t, int method, double prob) {
+ return recoverPose_2(points1.nativeObj, points2.nativeObj, cameraMatrix1.nativeObj, distCoeffs1.nativeObj, cameraMatrix2.nativeObj, distCoeffs2.nativeObj, E.nativeObj, R.nativeObj, t.nativeObj, method, prob);
+ }
+
+ /**
+ * Recovers the relative camera rotation and the translation from corresponding points in two images from two different cameras, using cheirality check. Returns the number of
+ * inliers that pass the check.
+ *
+ * @param points1 Array of N 2D points from the first image. The point coordinates should be
+ * floating-point (single or double precision).
+ * @param points2 Array of the second image points of the same size and format as points1 .
+ * @param cameraMatrix1 Input/output camera matrix for the first camera, the same as in
+ * REF: calibrateCamera. Furthermore, for the stereo case, additional flags may be used, see below.
+ * @param distCoeffs1 Input/output vector of distortion coefficients, the same as in
+ * REF: calibrateCamera.
+ * @param cameraMatrix2 Input/output camera matrix for the first camera, the same as in
+ * REF: calibrateCamera. Furthermore, for the stereo case, additional flags may be used, see below.
+ * @param distCoeffs2 Input/output vector of distortion coefficients, the same as in
+ * REF: calibrateCamera.
+ * @param E The output essential matrix.
+ * @param R Output rotation matrix. Together with the translation vector, this matrix makes up a tuple
+ * that performs a change of basis from the first camera's coordinate system to the second camera's
+ * coordinate system. Note that, in general, t can not be used for this tuple, see the parameter
+ * described below.
+ * @param t Output translation vector. This vector is obtained by REF: decomposeEssentialMat and
+ * therefore is only known up to scale, i.e. t is the direction of the translation vector and has unit
+ * length.
+ * @param method Method for computing an essential matrix.
+ *
+ *
+ * REF: RANSAC for the RANSAC algorithm.
+ *
+ *
+ * REF: LMEDS for the LMedS algorithm.
+ *
+ *
+ * confidence (probability) that the estimated matrix is correct.
+ * line in pixels, beyond which the point is considered an outlier and is not used for computing the
+ * final fundamental matrix. It can be set to something like 1-3, depending on the accuracy of the
+ * point localization, image resolution, and the image noise.
+ * inliers in points1 and points2 for then given essential matrix E. Only these inliers will be used to
+ * recover pose. In the output mask only inliers which pass the cheirality check.
+ *
+ * This function decomposes an essential matrix using REF: decomposeEssentialMat and then verifies
+ * possible pose hypotheses by doing cheirality check. The cheirality check means that the
+ * triangulated 3D points should have positive depth. Some details can be found in CITE: Nister03.
+ *
+ * This function can be used to process the output E and mask from REF: findEssentialMat. In this
+ * scenario, points1 and points2 are the same input for findEssentialMat.:
+ *
+ * // Example. Estimation of fundamental matrix using the RANSAC algorithm
+ * int point_count = 100;
+ * vector<Point2f> points1(point_count);
+ * vector<Point2f> points2(point_count);
+ *
+ * // initialize the points here ...
+ * for( int i = 0; i < point_count; i++ )
+ * {
+ * points1[i] = ...;
+ * points2[i] = ...;
+ * }
+ *
+ * // Input: camera calibration of both cameras, for example using intrinsic chessboard calibration.
+ * Mat cameraMatrix1, distCoeffs1, cameraMatrix2, distCoeffs2;
+ *
+ * // Output: Essential matrix, relative rotation and relative translation.
+ * Mat E, R, t, mask;
+ *
+ * recoverPose(points1, points2, cameraMatrix1, distCoeffs1, cameraMatrix2, distCoeffs2, E, R, t, mask);
+ *
+ * @return automatically generated
+ */
+ public static int recoverPose(Mat points1, Mat points2, Mat cameraMatrix1, Mat distCoeffs1, Mat cameraMatrix2, Mat distCoeffs2, Mat E, Mat R, Mat t, int method) {
+ return recoverPose_3(points1.nativeObj, points2.nativeObj, cameraMatrix1.nativeObj, distCoeffs1.nativeObj, cameraMatrix2.nativeObj, distCoeffs2.nativeObj, E.nativeObj, R.nativeObj, t.nativeObj, method);
+ }
+
+ /**
+ * Recovers the relative camera rotation and the translation from corresponding points in two images from two different cameras, using cheirality check. Returns the number of
+ * inliers that pass the check.
+ *
+ * @param points1 Array of N 2D points from the first image. The point coordinates should be
+ * floating-point (single or double precision).
+ * @param points2 Array of the second image points of the same size and format as points1 .
+ * @param cameraMatrix1 Input/output camera matrix for the first camera, the same as in
+ * REF: calibrateCamera. Furthermore, for the stereo case, additional flags may be used, see below.
+ * @param distCoeffs1 Input/output vector of distortion coefficients, the same as in
+ * REF: calibrateCamera.
+ * @param cameraMatrix2 Input/output camera matrix for the first camera, the same as in
+ * REF: calibrateCamera. Furthermore, for the stereo case, additional flags may be used, see below.
+ * @param distCoeffs2 Input/output vector of distortion coefficients, the same as in
+ * REF: calibrateCamera.
+ * @param E The output essential matrix.
+ * @param R Output rotation matrix. Together with the translation vector, this matrix makes up a tuple
+ * that performs a change of basis from the first camera's coordinate system to the second camera's
+ * coordinate system. Note that, in general, t can not be used for this tuple, see the parameter
+ * described below.
+ * @param t Output translation vector. This vector is obtained by REF: decomposeEssentialMat and
+ * therefore is only known up to scale, i.e. t is the direction of the translation vector and has unit
+ * length.
+ *
+ *
+ * REF: RANSAC for the RANSAC algorithm.
+ *
+ *
+ * REF: LMEDS for the LMedS algorithm.
+ *
+ *
+ * confidence (probability) that the estimated matrix is correct.
+ * line in pixels, beyond which the point is considered an outlier and is not used for computing the
+ * final fundamental matrix. It can be set to something like 1-3, depending on the accuracy of the
+ * point localization, image resolution, and the image noise.
+ * inliers in points1 and points2 for then given essential matrix E. Only these inliers will be used to
+ * recover pose. In the output mask only inliers which pass the cheirality check.
+ *
+ * This function decomposes an essential matrix using REF: decomposeEssentialMat and then verifies
+ * possible pose hypotheses by doing cheirality check. The cheirality check means that the
+ * triangulated 3D points should have positive depth. Some details can be found in CITE: Nister03.
+ *
+ * This function can be used to process the output E and mask from REF: findEssentialMat. In this
+ * scenario, points1 and points2 are the same input for findEssentialMat.:
+ *
+ * // Example. Estimation of fundamental matrix using the RANSAC algorithm
+ * int point_count = 100;
+ * vector<Point2f> points1(point_count);
+ * vector<Point2f> points2(point_count);
+ *
+ * // initialize the points here ...
+ * for( int i = 0; i < point_count; i++ )
+ * {
+ * points1[i] = ...;
+ * points2[i] = ...;
+ * }
+ *
+ * // Input: camera calibration of both cameras, for example using intrinsic chessboard calibration.
+ * Mat cameraMatrix1, distCoeffs1, cameraMatrix2, distCoeffs2;
+ *
+ * // Output: Essential matrix, relative rotation and relative translation.
+ * Mat E, R, t, mask;
+ *
+ * recoverPose(points1, points2, cameraMatrix1, distCoeffs1, cameraMatrix2, distCoeffs2, E, R, t, mask);
+ *
+ * @return automatically generated
+ */
+ public static int recoverPose(Mat points1, Mat points2, Mat cameraMatrix1, Mat distCoeffs1, Mat cameraMatrix2, Mat distCoeffs2, Mat E, Mat R, Mat t) {
+ return recoverPose_4(points1.nativeObj, points2.nativeObj, cameraMatrix1.nativeObj, distCoeffs1.nativeObj, cameraMatrix2.nativeObj, distCoeffs2.nativeObj, E.nativeObj, R.nativeObj, t.nativeObj);
+ }
+
+
+ //
+ // C++: int cv::recoverPose(Mat E, Mat points1, Mat points2, Mat cameraMatrix, Mat& R, Mat& t, Mat& mask = Mat())
+ //
+
+ /**
+ * Recovers the relative camera rotation and the translation from an estimated essential
+ * matrix and the corresponding points in two images, using chirality check. Returns the number of
+ * inliers that pass the check.
+ *
+ * @param E The input essential matrix.
+ * @param points1 Array of N 2D points from the first image. The point coordinates should be
+ * floating-point (single or double precision).
+ * @param points2 Array of the second image points of the same size and format as points1 .
+ * @param cameraMatrix Camera intrinsic matrix \(\cameramatrix{A}\) .
+ * Note that this function assumes that points1 and points2 are feature points from cameras with the
+ * same camera intrinsic matrix.
+ * @param R Output rotation matrix. Together with the translation vector, this matrix makes up a tuple
+ * that performs a change of basis from the first camera's coordinate system to the second camera's
+ * coordinate system. Note that, in general, t can not be used for this tuple, see the parameter
+ * described below.
+ * @param t Output translation vector. This vector is obtained by REF: decomposeEssentialMat and
+ * therefore is only known up to scale, i.e. t is the direction of the translation vector and has unit
+ * length.
+ * @param mask Input/output mask for inliers in points1 and points2. If it is not empty, then it marks
+ * inliers in points1 and points2 for the given essential matrix E. Only these inliers will be used to
+ * recover pose. In the output mask only inliers which pass the chirality check.
+ *
+ * This function decomposes an essential matrix using REF: decomposeEssentialMat and then verifies
+ * possible pose hypotheses by doing chirality check. The chirality check means that the
+ * triangulated 3D points should have positive depth. Some details can be found in CITE: Nister03.
+ *
+ * This function can be used to process the output E and mask from REF: findEssentialMat. In this
+ * scenario, points1 and points2 are the same input for #findEssentialMat :
+ *
+ * // Example. Estimation of fundamental matrix using the RANSAC algorithm
+ * int point_count = 100;
+ * vector<Point2f> points1(point_count);
+ * vector<Point2f> points2(point_count);
+ *
+ * // initialize the points here ...
+ * for( int i = 0; i < point_count; i++ )
+ * {
+ * points1[i] = ...;
+ * points2[i] = ...;
+ * }
+ *
+ * // cametra matrix with both focal lengths = 1, and principal point = (0, 0)
+ * Mat cameraMatrix = Mat::eye(3, 3, CV_64F);
+ *
+ * Mat E, R, t, mask;
+ *
+ * E = findEssentialMat(points1, points2, cameraMatrix, RANSAC, 0.999, 1.0, mask);
+ * recoverPose(E, points1, points2, cameraMatrix, R, t, mask);
+ *
+ * @return automatically generated
+ */
+ public static int recoverPose(Mat E, Mat points1, Mat points2, Mat cameraMatrix, Mat R, Mat t, Mat mask) {
+ return recoverPose_5(E.nativeObj, points1.nativeObj, points2.nativeObj, cameraMatrix.nativeObj, R.nativeObj, t.nativeObj, mask.nativeObj);
+ }
+
+ /**
+ * Recovers the relative camera rotation and the translation from an estimated essential
+ * matrix and the corresponding points in two images, using chirality check. Returns the number of
+ * inliers that pass the check.
+ *
+ * @param E The input essential matrix.
+ * @param points1 Array of N 2D points from the first image. The point coordinates should be
+ * floating-point (single or double precision).
+ * @param points2 Array of the second image points of the same size and format as points1 .
+ * @param cameraMatrix Camera intrinsic matrix \(\cameramatrix{A}\) .
+ * Note that this function assumes that points1 and points2 are feature points from cameras with the
+ * same camera intrinsic matrix.
+ * @param R Output rotation matrix. Together with the translation vector, this matrix makes up a tuple
+ * that performs a change of basis from the first camera's coordinate system to the second camera's
+ * coordinate system. Note that, in general, t can not be used for this tuple, see the parameter
+ * described below.
+ * @param t Output translation vector. This vector is obtained by REF: decomposeEssentialMat and
+ * therefore is only known up to scale, i.e. t is the direction of the translation vector and has unit
+ * length.
+ * inliers in points1 and points2 for the given essential matrix E. Only these inliers will be used to
+ * recover pose. In the output mask only inliers which pass the chirality check.
+ *
+ * This function decomposes an essential matrix using REF: decomposeEssentialMat and then verifies
+ * possible pose hypotheses by doing chirality check. The chirality check means that the
+ * triangulated 3D points should have positive depth. Some details can be found in CITE: Nister03.
+ *
+ * This function can be used to process the output E and mask from REF: findEssentialMat. In this
+ * scenario, points1 and points2 are the same input for #findEssentialMat :
+ *
+ * // Example. Estimation of fundamental matrix using the RANSAC algorithm
+ * int point_count = 100;
+ * vector<Point2f> points1(point_count);
+ * vector<Point2f> points2(point_count);
+ *
+ * // initialize the points here ...
+ * for( int i = 0; i < point_count; i++ )
+ * {
+ * points1[i] = ...;
+ * points2[i] = ...;
+ * }
+ *
+ * // cametra matrix with both focal lengths = 1, and principal point = (0, 0)
+ * Mat cameraMatrix = Mat::eye(3, 3, CV_64F);
+ *
+ * Mat E, R, t, mask;
+ *
+ * E = findEssentialMat(points1, points2, cameraMatrix, RANSAC, 0.999, 1.0, mask);
+ * recoverPose(E, points1, points2, cameraMatrix, R, t, mask);
+ *
+ * @return automatically generated
+ */
+ public static int recoverPose(Mat E, Mat points1, Mat points2, Mat cameraMatrix, Mat R, Mat t) {
+ return recoverPose_6(E.nativeObj, points1.nativeObj, points2.nativeObj, cameraMatrix.nativeObj, R.nativeObj, t.nativeObj);
+ }
+
+
+ //
+ // C++: int cv::recoverPose(Mat E, Mat points1, Mat points2, Mat& R, Mat& t, double focal = 1.0, Point2d pp = Point2d(0, 0), Mat& mask = Mat())
+ //
+
+ /**
+ *
+ * @param E The input essential matrix.
+ * @param points1 Array of N 2D points from the first image. The point coordinates should be
+ * floating-point (single or double precision).
+ * @param points2 Array of the second image points of the same size and format as points1 .
+ * @param R Output rotation matrix. Together with the translation vector, this matrix makes up a tuple
+ * that performs a change of basis from the first camera's coordinate system to the second camera's
+ * coordinate system. Note that, in general, t can not be used for this tuple, see the parameter
+ * description below.
+ * @param t Output translation vector. This vector is obtained by REF: decomposeEssentialMat and
+ * therefore is only known up to scale, i.e. t is the direction of the translation vector and has unit
+ * length.
+ * @param focal Focal length of the camera. Note that this function assumes that points1 and points2
+ * are feature points from cameras with same focal length and principal point.
+ * @param pp principal point of the camera.
+ * @param mask Input/output mask for inliers in points1 and points2. If it is not empty, then it marks
+ * inliers in points1 and points2 for the given essential matrix E. Only these inliers will be used to
+ * recover pose. In the output mask only inliers which pass the chirality check.
+ *
+ * This function differs from the one above that it computes camera intrinsic matrix from focal length and
+ * principal point:
+ *
+ * \(A =
+ * \begin{bmatrix}
+ * f & 0 & x_{pp} \\
+ * 0 & f & y_{pp} \\
+ * 0 & 0 & 1
+ * \end{bmatrix}\)
+ * @return automatically generated
+ */
+ public static int recoverPose(Mat E, Mat points1, Mat points2, Mat R, Mat t, double focal, Point pp, Mat mask) {
+ return recoverPose_7(E.nativeObj, points1.nativeObj, points2.nativeObj, R.nativeObj, t.nativeObj, focal, pp.x, pp.y, mask.nativeObj);
+ }
+
+ /**
+ *
+ * @param E The input essential matrix.
+ * @param points1 Array of N 2D points from the first image. The point coordinates should be
+ * floating-point (single or double precision).
+ * @param points2 Array of the second image points of the same size and format as points1 .
+ * @param R Output rotation matrix. Together with the translation vector, this matrix makes up a tuple
+ * that performs a change of basis from the first camera's coordinate system to the second camera's
+ * coordinate system. Note that, in general, t can not be used for this tuple, see the parameter
+ * description below.
+ * @param t Output translation vector. This vector is obtained by REF: decomposeEssentialMat and
+ * therefore is only known up to scale, i.e. t is the direction of the translation vector and has unit
+ * length.
+ * @param focal Focal length of the camera. Note that this function assumes that points1 and points2
+ * are feature points from cameras with same focal length and principal point.
+ * @param pp principal point of the camera.
+ * inliers in points1 and points2 for the given essential matrix E. Only these inliers will be used to
+ * recover pose. In the output mask only inliers which pass the chirality check.
+ *
+ * This function differs from the one above that it computes camera intrinsic matrix from focal length and
+ * principal point:
+ *
+ * \(A =
+ * \begin{bmatrix}
+ * f & 0 & x_{pp} \\
+ * 0 & f & y_{pp} \\
+ * 0 & 0 & 1
+ * \end{bmatrix}\)
+ * @return automatically generated
+ */
+ public static int recoverPose(Mat E, Mat points1, Mat points2, Mat R, Mat t, double focal, Point pp) {
+ return recoverPose_8(E.nativeObj, points1.nativeObj, points2.nativeObj, R.nativeObj, t.nativeObj, focal, pp.x, pp.y);
+ }
+
+ /**
+ *
+ * @param E The input essential matrix.
+ * @param points1 Array of N 2D points from the first image. The point coordinates should be
+ * floating-point (single or double precision).
+ * @param points2 Array of the second image points of the same size and format as points1 .
+ * @param R Output rotation matrix. Together with the translation vector, this matrix makes up a tuple
+ * that performs a change of basis from the first camera's coordinate system to the second camera's
+ * coordinate system. Note that, in general, t can not be used for this tuple, see the parameter
+ * description below.
+ * @param t Output translation vector. This vector is obtained by REF: decomposeEssentialMat and
+ * therefore is only known up to scale, i.e. t is the direction of the translation vector and has unit
+ * length.
+ * @param focal Focal length of the camera. Note that this function assumes that points1 and points2
+ * are feature points from cameras with same focal length and principal point.
+ * inliers in points1 and points2 for the given essential matrix E. Only these inliers will be used to
+ * recover pose. In the output mask only inliers which pass the chirality check.
+ *
+ * This function differs from the one above that it computes camera intrinsic matrix from focal length and
+ * principal point:
+ *
+ * \(A =
+ * \begin{bmatrix}
+ * f & 0 & x_{pp} \\
+ * 0 & f & y_{pp} \\
+ * 0 & 0 & 1
+ * \end{bmatrix}\)
+ * @return automatically generated
+ */
+ public static int recoverPose(Mat E, Mat points1, Mat points2, Mat R, Mat t, double focal) {
+ return recoverPose_9(E.nativeObj, points1.nativeObj, points2.nativeObj, R.nativeObj, t.nativeObj, focal);
+ }
+
+ /**
+ *
+ * @param E The input essential matrix.
+ * @param points1 Array of N 2D points from the first image. The point coordinates should be
+ * floating-point (single or double precision).
+ * @param points2 Array of the second image points of the same size and format as points1 .
+ * @param R Output rotation matrix. Together with the translation vector, this matrix makes up a tuple
+ * that performs a change of basis from the first camera's coordinate system to the second camera's
+ * coordinate system. Note that, in general, t can not be used for this tuple, see the parameter
+ * description below.
+ * @param t Output translation vector. This vector is obtained by REF: decomposeEssentialMat and
+ * therefore is only known up to scale, i.e. t is the direction of the translation vector and has unit
+ * length.
+ * are feature points from cameras with same focal length and principal point.
+ * inliers in points1 and points2 for the given essential matrix E. Only these inliers will be used to
+ * recover pose. In the output mask only inliers which pass the chirality check.
+ *
+ * This function differs from the one above that it computes camera intrinsic matrix from focal length and
+ * principal point:
+ *
+ * \(A =
+ * \begin{bmatrix}
+ * f & 0 & x_{pp} \\
+ * 0 & f & y_{pp} \\
+ * 0 & 0 & 1
+ * \end{bmatrix}\)
+ * @return automatically generated
+ */
+ public static int recoverPose(Mat E, Mat points1, Mat points2, Mat R, Mat t) {
+ return recoverPose_10(E.nativeObj, points1.nativeObj, points2.nativeObj, R.nativeObj, t.nativeObj);
+ }
+
+
+ //
+ // C++: int cv::recoverPose(Mat E, Mat points1, Mat points2, Mat cameraMatrix, Mat& R, Mat& t, double distanceThresh, Mat& mask = Mat(), Mat& triangulatedPoints = Mat())
+ //
+
+ /**
+ *
+ * @param E The input essential matrix.
+ * @param points1 Array of N 2D points from the first image. The point coordinates should be
+ * floating-point (single or double precision).
+ * @param points2 Array of the second image points of the same size and format as points1.
+ * @param cameraMatrix Camera intrinsic matrix \(\cameramatrix{A}\) .
+ * Note that this function assumes that points1 and points2 are feature points from cameras with the
+ * same camera intrinsic matrix.
+ * @param R Output rotation matrix. Together with the translation vector, this matrix makes up a tuple
+ * that performs a change of basis from the first camera's coordinate system to the second camera's
+ * coordinate system. Note that, in general, t can not be used for this tuple, see the parameter
+ * description below.
+ * @param t Output translation vector. This vector is obtained by REF: decomposeEssentialMat and
+ * therefore is only known up to scale, i.e. t is the direction of the translation vector and has unit
+ * length.
+ * @param distanceThresh threshold distance which is used to filter out far away points (i.e. infinite
+ * points).
+ * @param mask Input/output mask for inliers in points1 and points2. If it is not empty, then it marks
+ * inliers in points1 and points2 for the given essential matrix E. Only these inliers will be used to
+ * recover pose. In the output mask only inliers which pass the chirality check.
+ * @param triangulatedPoints 3D points which were reconstructed by triangulation.
+ *
+ * This function differs from the one above that it outputs the triangulated 3D point that are used for
+ * the chirality check.
+ * @return automatically generated
+ */
+ public static int recoverPose(Mat E, Mat points1, Mat points2, Mat cameraMatrix, Mat R, Mat t, double distanceThresh, Mat mask, Mat triangulatedPoints) {
+ return recoverPose_11(E.nativeObj, points1.nativeObj, points2.nativeObj, cameraMatrix.nativeObj, R.nativeObj, t.nativeObj, distanceThresh, mask.nativeObj, triangulatedPoints.nativeObj);
+ }
+
+ /**
+ *
+ * @param E The input essential matrix.
+ * @param points1 Array of N 2D points from the first image. The point coordinates should be
+ * floating-point (single or double precision).
+ * @param points2 Array of the second image points of the same size and format as points1.
+ * @param cameraMatrix Camera intrinsic matrix \(\cameramatrix{A}\) .
+ * Note that this function assumes that points1 and points2 are feature points from cameras with the
+ * same camera intrinsic matrix.
+ * @param R Output rotation matrix. Together with the translation vector, this matrix makes up a tuple
+ * that performs a change of basis from the first camera's coordinate system to the second camera's
+ * coordinate system. Note that, in general, t can not be used for this tuple, see the parameter
+ * description below.
+ * @param t Output translation vector. This vector is obtained by REF: decomposeEssentialMat and
+ * therefore is only known up to scale, i.e. t is the direction of the translation vector and has unit
+ * length.
+ * @param distanceThresh threshold distance which is used to filter out far away points (i.e. infinite
+ * points).
+ * @param mask Input/output mask for inliers in points1 and points2. If it is not empty, then it marks
+ * inliers in points1 and points2 for the given essential matrix E. Only these inliers will be used to
+ * recover pose. In the output mask only inliers which pass the chirality check.
+ *
+ * This function differs from the one above that it outputs the triangulated 3D point that are used for
+ * the chirality check.
+ * @return automatically generated
+ */
+ public static int recoverPose(Mat E, Mat points1, Mat points2, Mat cameraMatrix, Mat R, Mat t, double distanceThresh, Mat mask) {
+ return recoverPose_12(E.nativeObj, points1.nativeObj, points2.nativeObj, cameraMatrix.nativeObj, R.nativeObj, t.nativeObj, distanceThresh, mask.nativeObj);
+ }
+
+ /**
+ *
+ * @param E The input essential matrix.
+ * @param points1 Array of N 2D points from the first image. The point coordinates should be
+ * floating-point (single or double precision).
+ * @param points2 Array of the second image points of the same size and format as points1.
+ * @param cameraMatrix Camera intrinsic matrix \(\cameramatrix{A}\) .
+ * Note that this function assumes that points1 and points2 are feature points from cameras with the
+ * same camera intrinsic matrix.
+ * @param R Output rotation matrix. Together with the translation vector, this matrix makes up a tuple
+ * that performs a change of basis from the first camera's coordinate system to the second camera's
+ * coordinate system. Note that, in general, t can not be used for this tuple, see the parameter
+ * description below.
+ * @param t Output translation vector. This vector is obtained by REF: decomposeEssentialMat and
+ * therefore is only known up to scale, i.e. t is the direction of the translation vector and has unit
+ * length.
+ * @param distanceThresh threshold distance which is used to filter out far away points (i.e. infinite
+ * points).
+ * inliers in points1 and points2 for the given essential matrix E. Only these inliers will be used to
+ * recover pose. In the output mask only inliers which pass the chirality check.
+ *
+ * This function differs from the one above that it outputs the triangulated 3D point that are used for
+ * the chirality check.
+ * @return automatically generated
+ */
+ public static int recoverPose(Mat E, Mat points1, Mat points2, Mat cameraMatrix, Mat R, Mat t, double distanceThresh) {
+ return recoverPose_13(E.nativeObj, points1.nativeObj, points2.nativeObj, cameraMatrix.nativeObj, R.nativeObj, t.nativeObj, distanceThresh);
+ }
+
+
+ //
+ // C++: void cv::computeCorrespondEpilines(Mat points, int whichImage, Mat F, Mat& lines)
+ //
+
+ /**
+ * For points in an image of a stereo pair, computes the corresponding epilines in the other image.
+ *
+ * @param points Input points. \(N \times 1\) or \(1 \times N\) matrix of type CV_32FC2 or
+ * vector<Point2f> .
+ * @param whichImage Index of the image (1 or 2) that contains the points .
+ * @param F Fundamental matrix that can be estimated using #findFundamentalMat or #stereoRectify .
+ * @param lines Output vector of the epipolar lines corresponding to the points in the other image.
+ * Each line \(ax + by + c=0\) is encoded by 3 numbers \((a, b, c)\) .
+ *
+ * For every point in one of the two images of a stereo pair, the function finds the equation of the
+ * corresponding epipolar line in the other image.
+ *
+ * From the fundamental matrix definition (see #findFundamentalMat ), line \(l^{(2)}_i\) in the second
+ * image for the point \(p^{(1)}_i\) in the first image (when whichImage=1 ) is computed as:
+ *
+ * \(l^{(2)}_i = F p^{(1)}_i\)
+ *
+ * And vice versa, when whichImage=2, \(l^{(1)}_i\) is computed from \(p^{(2)}_i\) as:
+ *
+ * \(l^{(1)}_i = F^T p^{(2)}_i\)
+ *
+ * Line coefficients are defined up to a scale. They are normalized so that \(a_i^2+b_i^2=1\) .
+ */
+ public static void computeCorrespondEpilines(Mat points, int whichImage, Mat F, Mat lines) {
+ computeCorrespondEpilines_0(points.nativeObj, whichImage, F.nativeObj, lines.nativeObj);
+ }
+
+
+ //
+ // C++: void cv::triangulatePoints(Mat projMatr1, Mat projMatr2, Mat projPoints1, Mat projPoints2, Mat& points4D)
+ //
+
+ /**
+ * This function reconstructs 3-dimensional points (in homogeneous coordinates) by using
+ * their observations with a stereo camera.
+ *
+ * @param projMatr1 3x4 projection matrix of the first camera, i.e. this matrix projects 3D points
+ * given in the world's coordinate system into the first image.
+ * @param projMatr2 3x4 projection matrix of the second camera, i.e. this matrix projects 3D points
+ * given in the world's coordinate system into the second image.
+ * @param projPoints1 2xN array of feature points in the first image. In the case of the c++ version,
+ * it can be also a vector of feature points or two-channel matrix of size 1xN or Nx1.
+ * @param projPoints2 2xN array of corresponding points in the second image. In the case of the c++
+ * version, it can be also a vector of feature points or two-channel matrix of size 1xN or Nx1.
+ * @param points4D 4xN array of reconstructed points in homogeneous coordinates. These points are
+ * returned in the world's coordinate system.
+ *
+ * Note:
+ * Keep in mind that all input data should be of float type in order for this function to work.
+ *
+ * Note:
+ * If the projection matrices from REF: stereoRectify are used, then the returned points are
+ * represented in the first camera's rectified coordinate system.
+ *
+ * SEE:
+ * reprojectImageTo3D
+ */
+ public static void triangulatePoints(Mat projMatr1, Mat projMatr2, Mat projPoints1, Mat projPoints2, Mat points4D) {
+ triangulatePoints_0(projMatr1.nativeObj, projMatr2.nativeObj, projPoints1.nativeObj, projPoints2.nativeObj, points4D.nativeObj);
+ }
+
+
+ //
+ // C++: void cv::correctMatches(Mat F, Mat points1, Mat points2, Mat& newPoints1, Mat& newPoints2)
+ //
+
+ /**
+ * Refines coordinates of corresponding points.
+ *
+ * @param F 3x3 fundamental matrix.
+ * @param points1 1xN array containing the first set of points.
+ * @param points2 1xN array containing the second set of points.
+ * @param newPoints1 The optimized points1.
+ * @param newPoints2 The optimized points2.
+ *
+ * The function implements the Optimal Triangulation Method (see Multiple View Geometry CITE: HartleyZ00 for details).
+ * For each given point correspondence points1[i] <-> points2[i], and a fundamental matrix F, it
+ * computes the corrected correspondences newPoints1[i] <-> newPoints2[i] that minimize the geometric
+ * error \(d(points1[i], newPoints1[i])^2 + d(points2[i],newPoints2[i])^2\) (where \(d(a,b)\) is the
+ * geometric distance between points \(a\) and \(b\) ) subject to the epipolar constraint
+ * \(newPoints2^T \cdot F \cdot newPoints1 = 0\) .
+ */
+ public static void correctMatches(Mat F, Mat points1, Mat points2, Mat newPoints1, Mat newPoints2) {
+ correctMatches_0(F.nativeObj, points1.nativeObj, points2.nativeObj, newPoints1.nativeObj, newPoints2.nativeObj);
+ }
+
+
+ //
+ // C++: void cv::filterSpeckles(Mat& img, double newVal, int maxSpeckleSize, double maxDiff, Mat& buf = Mat())
+ //
+
+ /**
+ * Filters off small noise blobs (speckles) in the disparity map
+ *
+ * @param img The input 16-bit signed disparity image
+ * @param newVal The disparity value used to paint-off the speckles
+ * @param maxSpeckleSize The maximum speckle size to consider it a speckle. Larger blobs are not
+ * affected by the algorithm
+ * @param maxDiff Maximum difference between neighbor disparity pixels to put them into the same
+ * blob. Note that since StereoBM, StereoSGBM and may be other algorithms return a fixed-point
+ * disparity map, where disparity values are multiplied by 16, this scale factor should be taken into
+ * account when specifying this parameter value.
+ * @param buf The optional temporary buffer to avoid memory allocation within the function.
+ */
+ public static void filterSpeckles(Mat img, double newVal, int maxSpeckleSize, double maxDiff, Mat buf) {
+ filterSpeckles_0(img.nativeObj, newVal, maxSpeckleSize, maxDiff, buf.nativeObj);
+ }
+
+ /**
+ * Filters off small noise blobs (speckles) in the disparity map
+ *
+ * @param img The input 16-bit signed disparity image
+ * @param newVal The disparity value used to paint-off the speckles
+ * @param maxSpeckleSize The maximum speckle size to consider it a speckle. Larger blobs are not
+ * affected by the algorithm
+ * @param maxDiff Maximum difference between neighbor disparity pixels to put them into the same
+ * blob. Note that since StereoBM, StereoSGBM and may be other algorithms return a fixed-point
+ * disparity map, where disparity values are multiplied by 16, this scale factor should be taken into
+ * account when specifying this parameter value.
+ */
+ public static void filterSpeckles(Mat img, double newVal, int maxSpeckleSize, double maxDiff) {
+ filterSpeckles_1(img.nativeObj, newVal, maxSpeckleSize, maxDiff);
+ }
+
+
+ //
+ // C++: Rect cv::getValidDisparityROI(Rect roi1, Rect roi2, int minDisparity, int numberOfDisparities, int blockSize)
+ //
+
+ public static Rect getValidDisparityROI(Rect roi1, Rect roi2, int minDisparity, int numberOfDisparities, int blockSize) {
+ return new Rect(getValidDisparityROI_0(roi1.x, roi1.y, roi1.width, roi1.height, roi2.x, roi2.y, roi2.width, roi2.height, minDisparity, numberOfDisparities, blockSize));
+ }
+
+
+ //
+ // C++: void cv::validateDisparity(Mat& disparity, Mat cost, int minDisparity, int numberOfDisparities, int disp12MaxDisp = 1)
+ //
+
+ public static void validateDisparity(Mat disparity, Mat cost, int minDisparity, int numberOfDisparities, int disp12MaxDisp) {
+ validateDisparity_0(disparity.nativeObj, cost.nativeObj, minDisparity, numberOfDisparities, disp12MaxDisp);
+ }
+
+ public static void validateDisparity(Mat disparity, Mat cost, int minDisparity, int numberOfDisparities) {
+ validateDisparity_1(disparity.nativeObj, cost.nativeObj, minDisparity, numberOfDisparities);
+ }
+
+
+ //
+ // C++: void cv::reprojectImageTo3D(Mat disparity, Mat& _3dImage, Mat Q, bool handleMissingValues = false, int ddepth = -1)
+ //
+
+ /**
+ * Reprojects a disparity image to 3D space.
+ *
+ * @param disparity Input single-channel 8-bit unsigned, 16-bit signed, 32-bit signed or 32-bit
+ * floating-point disparity image. The values of 8-bit / 16-bit signed formats are assumed to have no
+ * fractional bits. If the disparity is 16-bit signed format, as computed by REF: StereoBM or
+ * REF: StereoSGBM and maybe other algorithms, it should be divided by 16 (and scaled to float) before
+ * being used here.
+ * @param _3dImage Output 3-channel floating-point image of the same size as disparity. Each element of
+ * _3dImage(x,y) contains 3D coordinates of the point (x,y) computed from the disparity map. If one
+ * uses Q obtained by REF: stereoRectify, then the returned points are represented in the first
+ * camera's rectified coordinate system.
+ * @param Q \(4 \times 4\) perspective transformation matrix that can be obtained with
+ * REF: stereoRectify.
+ * @param handleMissingValues Indicates, whether the function should handle missing values (i.e.
+ * points where the disparity was not computed). If handleMissingValues=true, then pixels with the
+ * minimal disparity that corresponds to the outliers (see StereoMatcher::compute ) are transformed
+ * to 3D points with a very large Z value (currently set to 10000).
+ * @param ddepth The optional output array depth. If it is -1, the output image will have CV_32F
+ * depth. ddepth can also be set to CV_16S, CV_32S or CV_32F.
+ *
+ * The function transforms a single-channel disparity map to a 3-channel image representing a 3D
+ * surface. That is, for each pixel (x,y) and the corresponding disparity d=disparity(x,y) , it
+ * computes:
+ *
+ * \(\begin{bmatrix}
+ * X \\
+ * Y \\
+ * Z \\
+ * W
+ * \end{bmatrix} = Q \begin{bmatrix}
+ * x \\
+ * y \\
+ * \texttt{disparity} (x,y) \\
+ * z
+ * \end{bmatrix}.\)
+ *
+ * SEE:
+ * To reproject a sparse set of points {(x,y,d),...} to 3D space, use perspectiveTransform.
+ */
+ public static void reprojectImageTo3D(Mat disparity, Mat _3dImage, Mat Q, boolean handleMissingValues, int ddepth) {
+ reprojectImageTo3D_0(disparity.nativeObj, _3dImage.nativeObj, Q.nativeObj, handleMissingValues, ddepth);
+ }
+
+ /**
+ * Reprojects a disparity image to 3D space.
+ *
+ * @param disparity Input single-channel 8-bit unsigned, 16-bit signed, 32-bit signed or 32-bit
+ * floating-point disparity image. The values of 8-bit / 16-bit signed formats are assumed to have no
+ * fractional bits. If the disparity is 16-bit signed format, as computed by REF: StereoBM or
+ * REF: StereoSGBM and maybe other algorithms, it should be divided by 16 (and scaled to float) before
+ * being used here.
+ * @param _3dImage Output 3-channel floating-point image of the same size as disparity. Each element of
+ * _3dImage(x,y) contains 3D coordinates of the point (x,y) computed from the disparity map. If one
+ * uses Q obtained by REF: stereoRectify, then the returned points are represented in the first
+ * camera's rectified coordinate system.
+ * @param Q \(4 \times 4\) perspective transformation matrix that can be obtained with
+ * REF: stereoRectify.
+ * @param handleMissingValues Indicates, whether the function should handle missing values (i.e.
+ * points where the disparity was not computed). If handleMissingValues=true, then pixels with the
+ * minimal disparity that corresponds to the outliers (see StereoMatcher::compute ) are transformed
+ * to 3D points with a very large Z value (currently set to 10000).
+ * depth. ddepth can also be set to CV_16S, CV_32S or CV_32F.
+ *
+ * The function transforms a single-channel disparity map to a 3-channel image representing a 3D
+ * surface. That is, for each pixel (x,y) and the corresponding disparity d=disparity(x,y) , it
+ * computes:
+ *
+ * \(\begin{bmatrix}
+ * X \\
+ * Y \\
+ * Z \\
+ * W
+ * \end{bmatrix} = Q \begin{bmatrix}
+ * x \\
+ * y \\
+ * \texttt{disparity} (x,y) \\
+ * z
+ * \end{bmatrix}.\)
+ *
+ * SEE:
+ * To reproject a sparse set of points {(x,y,d),...} to 3D space, use perspectiveTransform.
+ */
+ public static void reprojectImageTo3D(Mat disparity, Mat _3dImage, Mat Q, boolean handleMissingValues) {
+ reprojectImageTo3D_1(disparity.nativeObj, _3dImage.nativeObj, Q.nativeObj, handleMissingValues);
+ }
+
+ /**
+ * Reprojects a disparity image to 3D space.
+ *
+ * @param disparity Input single-channel 8-bit unsigned, 16-bit signed, 32-bit signed or 32-bit
+ * floating-point disparity image. The values of 8-bit / 16-bit signed formats are assumed to have no
+ * fractional bits. If the disparity is 16-bit signed format, as computed by REF: StereoBM or
+ * REF: StereoSGBM and maybe other algorithms, it should be divided by 16 (and scaled to float) before
+ * being used here.
+ * @param _3dImage Output 3-channel floating-point image of the same size as disparity. Each element of
+ * _3dImage(x,y) contains 3D coordinates of the point (x,y) computed from the disparity map. If one
+ * uses Q obtained by REF: stereoRectify, then the returned points are represented in the first
+ * camera's rectified coordinate system.
+ * @param Q \(4 \times 4\) perspective transformation matrix that can be obtained with
+ * REF: stereoRectify.
+ * points where the disparity was not computed). If handleMissingValues=true, then pixels with the
+ * minimal disparity that corresponds to the outliers (see StereoMatcher::compute ) are transformed
+ * to 3D points with a very large Z value (currently set to 10000).
+ * depth. ddepth can also be set to CV_16S, CV_32S or CV_32F.
+ *
+ * The function transforms a single-channel disparity map to a 3-channel image representing a 3D
+ * surface. That is, for each pixel (x,y) and the corresponding disparity d=disparity(x,y) , it
+ * computes:
+ *
+ * \(\begin{bmatrix}
+ * X \\
+ * Y \\
+ * Z \\
+ * W
+ * \end{bmatrix} = Q \begin{bmatrix}
+ * x \\
+ * y \\
+ * \texttt{disparity} (x,y) \\
+ * z
+ * \end{bmatrix}.\)
+ *
+ * SEE:
+ * To reproject a sparse set of points {(x,y,d),...} to 3D space, use perspectiveTransform.
+ */
+ public static void reprojectImageTo3D(Mat disparity, Mat _3dImage, Mat Q) {
+ reprojectImageTo3D_2(disparity.nativeObj, _3dImage.nativeObj, Q.nativeObj);
+ }
+
+
+ //
+ // C++: double cv::sampsonDistance(Mat pt1, Mat pt2, Mat F)
+ //
+
+ /**
+ * Calculates the Sampson Distance between two points.
+ *
+ * The function cv::sampsonDistance calculates and returns the first order approximation of the geometric error as:
+ * \(
+ * sd( \texttt{pt1} , \texttt{pt2} )=
+ * \frac{(\texttt{pt2}^t \cdot \texttt{F} \cdot \texttt{pt1})^2}
+ * {((\texttt{F} \cdot \texttt{pt1})(0))^2 +
+ * ((\texttt{F} \cdot \texttt{pt1})(1))^2 +
+ * ((\texttt{F}^t \cdot \texttt{pt2})(0))^2 +
+ * ((\texttt{F}^t \cdot \texttt{pt2})(1))^2}
+ * \)
+ * The fundamental matrix may be calculated using the #findFundamentalMat function. See CITE: HartleyZ00 11.4.3 for details.
+ * @param pt1 first homogeneous 2d point
+ * @param pt2 second homogeneous 2d point
+ * @param F fundamental matrix
+ * @return The computed Sampson distance.
+ */
+ public static double sampsonDistance(Mat pt1, Mat pt2, Mat F) {
+ return sampsonDistance_0(pt1.nativeObj, pt2.nativeObj, F.nativeObj);
+ }
+
+
+ //
+ // C++: int cv::estimateAffine3D(Mat src, Mat dst, Mat& out, Mat& inliers, double ransacThreshold = 3, double confidence = 0.99)
+ //
+
+ /**
+ * Computes an optimal affine transformation between two 3D point sets.
+ *
+ * It computes
+ * \(
+ * \begin{bmatrix}
+ * x\\
+ * y\\
+ * z\\
+ * \end{bmatrix}
+ * =
+ * \begin{bmatrix}
+ * a_{11} & a_{12} & a_{13}\\
+ * a_{21} & a_{22} & a_{23}\\
+ * a_{31} & a_{32} & a_{33}\\
+ * \end{bmatrix}
+ * \begin{bmatrix}
+ * X\\
+ * Y\\
+ * Z\\
+ * \end{bmatrix}
+ * +
+ * \begin{bmatrix}
+ * b_1\\
+ * b_2\\
+ * b_3\\
+ * \end{bmatrix}
+ * \)
+ *
+ * @param src First input 3D point set containing \((X,Y,Z)\).
+ * @param dst Second input 3D point set containing \((x,y,z)\).
+ * @param out Output 3D affine transformation matrix \(3 \times 4\) of the form
+ * \(
+ * \begin{bmatrix}
+ * a_{11} & a_{12} & a_{13} & b_1\\
+ * a_{21} & a_{22} & a_{23} & b_2\\
+ * a_{31} & a_{32} & a_{33} & b_3\\
+ * \end{bmatrix}
+ * \)
+ * @param inliers Output vector indicating which points are inliers (1-inlier, 0-outlier).
+ * @param ransacThreshold Maximum reprojection error in the RANSAC algorithm to consider a point as
+ * an inlier.
+ * @param confidence Confidence level, between 0 and 1, for the estimated transformation. Anything
+ * between 0.95 and 0.99 is usually good enough. Values too close to 1 can slow down the estimation
+ * significantly. Values lower than 0.8-0.9 can result in an incorrectly estimated transformation.
+ *
+ * The function estimates an optimal 3D affine transformation between two 3D point sets using the
+ * RANSAC algorithm.
+ * @return automatically generated
+ */
+ public static int estimateAffine3D(Mat src, Mat dst, Mat out, Mat inliers, double ransacThreshold, double confidence) {
+ return estimateAffine3D_0(src.nativeObj, dst.nativeObj, out.nativeObj, inliers.nativeObj, ransacThreshold, confidence);
+ }
+
+ /**
+ * Computes an optimal affine transformation between two 3D point sets.
+ *
+ * It computes
+ * \(
+ * \begin{bmatrix}
+ * x\\
+ * y\\
+ * z\\
+ * \end{bmatrix}
+ * =
+ * \begin{bmatrix}
+ * a_{11} & a_{12} & a_{13}\\
+ * a_{21} & a_{22} & a_{23}\\
+ * a_{31} & a_{32} & a_{33}\\
+ * \end{bmatrix}
+ * \begin{bmatrix}
+ * X\\
+ * Y\\
+ * Z\\
+ * \end{bmatrix}
+ * +
+ * \begin{bmatrix}
+ * b_1\\
+ * b_2\\
+ * b_3\\
+ * \end{bmatrix}
+ * \)
+ *
+ * @param src First input 3D point set containing \((X,Y,Z)\).
+ * @param dst Second input 3D point set containing \((x,y,z)\).
+ * @param out Output 3D affine transformation matrix \(3 \times 4\) of the form
+ * \(
+ * \begin{bmatrix}
+ * a_{11} & a_{12} & a_{13} & b_1\\
+ * a_{21} & a_{22} & a_{23} & b_2\\
+ * a_{31} & a_{32} & a_{33} & b_3\\
+ * \end{bmatrix}
+ * \)
+ * @param inliers Output vector indicating which points are inliers (1-inlier, 0-outlier).
+ * @param ransacThreshold Maximum reprojection error in the RANSAC algorithm to consider a point as
+ * an inlier.
+ * between 0.95 and 0.99 is usually good enough. Values too close to 1 can slow down the estimation
+ * significantly. Values lower than 0.8-0.9 can result in an incorrectly estimated transformation.
+ *
+ * The function estimates an optimal 3D affine transformation between two 3D point sets using the
+ * RANSAC algorithm.
+ * @return automatically generated
+ */
+ public static int estimateAffine3D(Mat src, Mat dst, Mat out, Mat inliers, double ransacThreshold) {
+ return estimateAffine3D_1(src.nativeObj, dst.nativeObj, out.nativeObj, inliers.nativeObj, ransacThreshold);
+ }
+
+ /**
+ * Computes an optimal affine transformation between two 3D point sets.
+ *
+ * It computes
+ * \(
+ * \begin{bmatrix}
+ * x\\
+ * y\\
+ * z\\
+ * \end{bmatrix}
+ * =
+ * \begin{bmatrix}
+ * a_{11} & a_{12} & a_{13}\\
+ * a_{21} & a_{22} & a_{23}\\
+ * a_{31} & a_{32} & a_{33}\\
+ * \end{bmatrix}
+ * \begin{bmatrix}
+ * X\\
+ * Y\\
+ * Z\\
+ * \end{bmatrix}
+ * +
+ * \begin{bmatrix}
+ * b_1\\
+ * b_2\\
+ * b_3\\
+ * \end{bmatrix}
+ * \)
+ *
+ * @param src First input 3D point set containing \((X,Y,Z)\).
+ * @param dst Second input 3D point set containing \((x,y,z)\).
+ * @param out Output 3D affine transformation matrix \(3 \times 4\) of the form
+ * \(
+ * \begin{bmatrix}
+ * a_{11} & a_{12} & a_{13} & b_1\\
+ * a_{21} & a_{22} & a_{23} & b_2\\
+ * a_{31} & a_{32} & a_{33} & b_3\\
+ * \end{bmatrix}
+ * \)
+ * @param inliers Output vector indicating which points are inliers (1-inlier, 0-outlier).
+ * an inlier.
+ * between 0.95 and 0.99 is usually good enough. Values too close to 1 can slow down the estimation
+ * significantly. Values lower than 0.8-0.9 can result in an incorrectly estimated transformation.
+ *
+ * The function estimates an optimal 3D affine transformation between two 3D point sets using the
+ * RANSAC algorithm.
+ * @return automatically generated
+ */
+ public static int estimateAffine3D(Mat src, Mat dst, Mat out, Mat inliers) {
+ return estimateAffine3D_2(src.nativeObj, dst.nativeObj, out.nativeObj, inliers.nativeObj);
+ }
+
+
+ //
+ // C++: Mat cv::estimateAffine3D(Mat src, Mat dst, double* scale = nullptr, bool force_rotation = true)
+ //
+
+ /**
+ * Computes an optimal affine transformation between two 3D point sets.
+ *
+ * It computes \(R,s,t\) minimizing \(\sum{i} dst_i - c \cdot R \cdot src_i \)
+ * where \(R\) is a 3x3 rotation matrix, \(t\) is a 3x1 translation vector and \(s\) is a
+ * scalar size value. This is an implementation of the algorithm by Umeyama \cite umeyama1991least .
+ * The estimated affine transform has a homogeneous scale which is a subclass of affine
+ * transformations with 7 degrees of freedom. The paired point sets need to comprise at least 3
+ * points each.
+ *
+ * @param src First input 3D point set.
+ * @param dst Second input 3D point set.
+ * @param scale If null is passed, the scale parameter c will be assumed to be 1.0.
+ * Else the pointed-to variable will be set to the optimal scale.
+ * @param force_rotation If true, the returned rotation will never be a reflection.
+ * This might be unwanted, e.g. when optimizing a transform between a right- and a
+ * left-handed coordinate system.
+ * @return 3D affine transformation matrix \(3 \times 4\) of the form
+ * \(T =
+ * \begin{bmatrix}
+ * R & t\\
+ * \end{bmatrix}
+ * \)
+ */
+ public static Mat estimateAffine3D(Mat src, Mat dst, double[] scale, boolean force_rotation) {
+ double[] scale_out = new double[1];
+ Mat retVal = new Mat(estimateAffine3D_3(src.nativeObj, dst.nativeObj, scale_out, force_rotation));
+ if(scale!=null) scale[0] = (double)scale_out[0];
+ return retVal;
+ }
+
+ /**
+ * Computes an optimal affine transformation between two 3D point sets.
+ *
+ * It computes \(R,s,t\) minimizing \(\sum{i} dst_i - c \cdot R \cdot src_i \)
+ * where \(R\) is a 3x3 rotation matrix, \(t\) is a 3x1 translation vector and \(s\) is a
+ * scalar size value. This is an implementation of the algorithm by Umeyama \cite umeyama1991least .
+ * The estimated affine transform has a homogeneous scale which is a subclass of affine
+ * transformations with 7 degrees of freedom. The paired point sets need to comprise at least 3
+ * points each.
+ *
+ * @param src First input 3D point set.
+ * @param dst Second input 3D point set.
+ * @param scale If null is passed, the scale parameter c will be assumed to be 1.0.
+ * Else the pointed-to variable will be set to the optimal scale.
+ * This might be unwanted, e.g. when optimizing a transform between a right- and a
+ * left-handed coordinate system.
+ * @return 3D affine transformation matrix \(3 \times 4\) of the form
+ * \(T =
+ * \begin{bmatrix}
+ * R & t\\
+ * \end{bmatrix}
+ * \)
+ */
+ public static Mat estimateAffine3D(Mat src, Mat dst, double[] scale) {
+ double[] scale_out = new double[1];
+ Mat retVal = new Mat(estimateAffine3D_4(src.nativeObj, dst.nativeObj, scale_out));
+ if(scale!=null) scale[0] = (double)scale_out[0];
+ return retVal;
+ }
+
+ /**
+ * Computes an optimal affine transformation between two 3D point sets.
+ *
+ * It computes \(R,s,t\) minimizing \(\sum{i} dst_i - c \cdot R \cdot src_i \)
+ * where \(R\) is a 3x3 rotation matrix, \(t\) is a 3x1 translation vector and \(s\) is a
+ * scalar size value. This is an implementation of the algorithm by Umeyama \cite umeyama1991least .
+ * The estimated affine transform has a homogeneous scale which is a subclass of affine
+ * transformations with 7 degrees of freedom. The paired point sets need to comprise at least 3
+ * points each.
+ *
+ * @param src First input 3D point set.
+ * @param dst Second input 3D point set.
+ * Else the pointed-to variable will be set to the optimal scale.
+ * This might be unwanted, e.g. when optimizing a transform between a right- and a
+ * left-handed coordinate system.
+ * @return 3D affine transformation matrix \(3 \times 4\) of the form
+ * \(T =
+ * \begin{bmatrix}
+ * R & t\\
+ * \end{bmatrix}
+ * \)
+ */
+ public static Mat estimateAffine3D(Mat src, Mat dst) {
+ return new Mat(estimateAffine3D_5(src.nativeObj, dst.nativeObj));
+ }
+
+
+ //
+ // C++: int cv::estimateTranslation3D(Mat src, Mat dst, Mat& out, Mat& inliers, double ransacThreshold = 3, double confidence = 0.99)
+ //
+
+ /**
+ * Computes an optimal translation between two 3D point sets.
+ *
+ * It computes
+ * \(
+ * \begin{bmatrix}
+ * x\\
+ * y\\
+ * z\\
+ * \end{bmatrix}
+ * =
+ * \begin{bmatrix}
+ * X\\
+ * Y\\
+ * Z\\
+ * \end{bmatrix}
+ * +
+ * \begin{bmatrix}
+ * b_1\\
+ * b_2\\
+ * b_3\\
+ * \end{bmatrix}
+ * \)
+ *
+ * @param src First input 3D point set containing \((X,Y,Z)\).
+ * @param dst Second input 3D point set containing \((x,y,z)\).
+ * @param out Output 3D translation vector \(3 \times 1\) of the form
+ * \(
+ * \begin{bmatrix}
+ * b_1 \\
+ * b_2 \\
+ * b_3 \\
+ * \end{bmatrix}
+ * \)
+ * @param inliers Output vector indicating which points are inliers (1-inlier, 0-outlier).
+ * @param ransacThreshold Maximum reprojection error in the RANSAC algorithm to consider a point as
+ * an inlier.
+ * @param confidence Confidence level, between 0 and 1, for the estimated transformation. Anything
+ * between 0.95 and 0.99 is usually good enough. Values too close to 1 can slow down the estimation
+ * significantly. Values lower than 0.8-0.9 can result in an incorrectly estimated transformation.
+ *
+ * The function estimates an optimal 3D translation between two 3D point sets using the
+ * RANSAC algorithm.
+ *
+ * @return automatically generated
+ */
+ public static int estimateTranslation3D(Mat src, Mat dst, Mat out, Mat inliers, double ransacThreshold, double confidence) {
+ return estimateTranslation3D_0(src.nativeObj, dst.nativeObj, out.nativeObj, inliers.nativeObj, ransacThreshold, confidence);
+ }
+
+ /**
+ * Computes an optimal translation between two 3D point sets.
+ *
+ * It computes
+ * \(
+ * \begin{bmatrix}
+ * x\\
+ * y\\
+ * z\\
+ * \end{bmatrix}
+ * =
+ * \begin{bmatrix}
+ * X\\
+ * Y\\
+ * Z\\
+ * \end{bmatrix}
+ * +
+ * \begin{bmatrix}
+ * b_1\\
+ * b_2\\
+ * b_3\\
+ * \end{bmatrix}
+ * \)
+ *
+ * @param src First input 3D point set containing \((X,Y,Z)\).
+ * @param dst Second input 3D point set containing \((x,y,z)\).
+ * @param out Output 3D translation vector \(3 \times 1\) of the form
+ * \(
+ * \begin{bmatrix}
+ * b_1 \\
+ * b_2 \\
+ * b_3 \\
+ * \end{bmatrix}
+ * \)
+ * @param inliers Output vector indicating which points are inliers (1-inlier, 0-outlier).
+ * @param ransacThreshold Maximum reprojection error in the RANSAC algorithm to consider a point as
+ * an inlier.
+ * between 0.95 and 0.99 is usually good enough. Values too close to 1 can slow down the estimation
+ * significantly. Values lower than 0.8-0.9 can result in an incorrectly estimated transformation.
+ *
+ * The function estimates an optimal 3D translation between two 3D point sets using the
+ * RANSAC algorithm.
+ *
+ * @return automatically generated
+ */
+ public static int estimateTranslation3D(Mat src, Mat dst, Mat out, Mat inliers, double ransacThreshold) {
+ return estimateTranslation3D_1(src.nativeObj, dst.nativeObj, out.nativeObj, inliers.nativeObj, ransacThreshold);
+ }
+
+ /**
+ * Computes an optimal translation between two 3D point sets.
+ *
+ * It computes
+ * \(
+ * \begin{bmatrix}
+ * x\\
+ * y\\
+ * z\\
+ * \end{bmatrix}
+ * =
+ * \begin{bmatrix}
+ * X\\
+ * Y\\
+ * Z\\
+ * \end{bmatrix}
+ * +
+ * \begin{bmatrix}
+ * b_1\\
+ * b_2\\
+ * b_3\\
+ * \end{bmatrix}
+ * \)
+ *
+ * @param src First input 3D point set containing \((X,Y,Z)\).
+ * @param dst Second input 3D point set containing \((x,y,z)\).
+ * @param out Output 3D translation vector \(3 \times 1\) of the form
+ * \(
+ * \begin{bmatrix}
+ * b_1 \\
+ * b_2 \\
+ * b_3 \\
+ * \end{bmatrix}
+ * \)
+ * @param inliers Output vector indicating which points are inliers (1-inlier, 0-outlier).
+ * an inlier.
+ * between 0.95 and 0.99 is usually good enough. Values too close to 1 can slow down the estimation
+ * significantly. Values lower than 0.8-0.9 can result in an incorrectly estimated transformation.
+ *
+ * The function estimates an optimal 3D translation between two 3D point sets using the
+ * RANSAC algorithm.
+ *
+ * @return automatically generated
+ */
+ public static int estimateTranslation3D(Mat src, Mat dst, Mat out, Mat inliers) {
+ return estimateTranslation3D_2(src.nativeObj, dst.nativeObj, out.nativeObj, inliers.nativeObj);
+ }
+
+
+ //
+ // C++: Mat cv::estimateAffine2D(Mat from, Mat to, Mat& inliers = Mat(), int method = RANSAC, double ransacReprojThreshold = 3, size_t maxIters = 2000, double confidence = 0.99, size_t refineIters = 10)
+ //
+
+ /**
+ * Computes an optimal affine transformation between two 2D point sets.
+ *
+ * It computes
+ * \(
+ * \begin{bmatrix}
+ * x\\
+ * y\\
+ * \end{bmatrix}
+ * =
+ * \begin{bmatrix}
+ * a_{11} & a_{12}\\
+ * a_{21} & a_{22}\\
+ * \end{bmatrix}
+ * \begin{bmatrix}
+ * X\\
+ * Y\\
+ * \end{bmatrix}
+ * +
+ * \begin{bmatrix}
+ * b_1\\
+ * b_2\\
+ * \end{bmatrix}
+ * \)
+ *
+ * @param from First input 2D point set containing \((X,Y)\).
+ * @param to Second input 2D point set containing \((x,y)\).
+ * @param inliers Output vector indicating which points are inliers (1-inlier, 0-outlier).
+ * @param method Robust method used to compute transformation. The following methods are possible:
+ *
+ *
+ * REF: RANSAC - RANSAC-based robust method
+ *
+ *
+ * REF: LMEDS - Least-Median robust method
+ * RANSAC is the default method.
+ *
+ *
+ * @param ransacReprojThreshold Maximum reprojection error in the RANSAC algorithm to consider
+ * a point as an inlier. Applies only to RANSAC.
+ * @param maxIters The maximum number of robust method iterations.
+ * @param confidence Confidence level, between 0 and 1, for the estimated transformation. Anything
+ * between 0.95 and 0.99 is usually good enough. Values too close to 1 can slow down the estimation
+ * significantly. Values lower than 0.8-0.9 can result in an incorrectly estimated transformation.
+ * @param refineIters Maximum number of iterations of refining algorithm (Levenberg-Marquardt).
+ * Passing 0 will disable refining, so the output matrix will be output of robust method.
+ *
+ * @return Output 2D affine transformation matrix \(2 \times 3\) or empty matrix if transformation
+ * could not be estimated. The returned matrix has the following form:
+ * \(
+ * \begin{bmatrix}
+ * a_{11} & a_{12} & b_1\\
+ * a_{21} & a_{22} & b_2\\
+ * \end{bmatrix}
+ * \)
+ *
+ * The function estimates an optimal 2D affine transformation between two 2D point sets using the
+ * selected robust algorithm.
+ *
+ * The computed transformation is then refined further (using only inliers) with the
+ * Levenberg-Marquardt method to reduce the re-projection error even more.
+ *
+ * Note:
+ * The RANSAC method can handle practically any ratio of outliers but needs a threshold to
+ * distinguish inliers from outliers. The method LMeDS does not need any threshold but it works
+ * correctly only when there are more than 50% of inliers.
+ *
+ * SEE: estimateAffinePartial2D, getAffineTransform
+ */
+ public static Mat estimateAffine2D(Mat from, Mat to, Mat inliers, int method, double ransacReprojThreshold, long maxIters, double confidence, long refineIters) {
+ return new Mat(estimateAffine2D_0(from.nativeObj, to.nativeObj, inliers.nativeObj, method, ransacReprojThreshold, maxIters, confidence, refineIters));
+ }
+
+ /**
+ * Computes an optimal affine transformation between two 2D point sets.
+ *
+ * It computes
+ * \(
+ * \begin{bmatrix}
+ * x\\
+ * y\\
+ * \end{bmatrix}
+ * =
+ * \begin{bmatrix}
+ * a_{11} & a_{12}\\
+ * a_{21} & a_{22}\\
+ * \end{bmatrix}
+ * \begin{bmatrix}
+ * X\\
+ * Y\\
+ * \end{bmatrix}
+ * +
+ * \begin{bmatrix}
+ * b_1\\
+ * b_2\\
+ * \end{bmatrix}
+ * \)
+ *
+ * @param from First input 2D point set containing \((X,Y)\).
+ * @param to Second input 2D point set containing \((x,y)\).
+ * @param inliers Output vector indicating which points are inliers (1-inlier, 0-outlier).
+ * @param method Robust method used to compute transformation. The following methods are possible:
+ *
+ *
+ * REF: RANSAC - RANSAC-based robust method
+ *
+ *
+ * REF: LMEDS - Least-Median robust method
+ * RANSAC is the default method.
+ *
+ *
+ * @param ransacReprojThreshold Maximum reprojection error in the RANSAC algorithm to consider
+ * a point as an inlier. Applies only to RANSAC.
+ * @param maxIters The maximum number of robust method iterations.
+ * @param confidence Confidence level, between 0 and 1, for the estimated transformation. Anything
+ * between 0.95 and 0.99 is usually good enough. Values too close to 1 can slow down the estimation
+ * significantly. Values lower than 0.8-0.9 can result in an incorrectly estimated transformation.
+ * Passing 0 will disable refining, so the output matrix will be output of robust method.
+ *
+ * @return Output 2D affine transformation matrix \(2 \times 3\) or empty matrix if transformation
+ * could not be estimated. The returned matrix has the following form:
+ * \(
+ * \begin{bmatrix}
+ * a_{11} & a_{12} & b_1\\
+ * a_{21} & a_{22} & b_2\\
+ * \end{bmatrix}
+ * \)
+ *
+ * The function estimates an optimal 2D affine transformation between two 2D point sets using the
+ * selected robust algorithm.
+ *
+ * The computed transformation is then refined further (using only inliers) with the
+ * Levenberg-Marquardt method to reduce the re-projection error even more.
+ *
+ * Note:
+ * The RANSAC method can handle practically any ratio of outliers but needs a threshold to
+ * distinguish inliers from outliers. The method LMeDS does not need any threshold but it works
+ * correctly only when there are more than 50% of inliers.
+ *
+ * SEE: estimateAffinePartial2D, getAffineTransform
+ */
+ public static Mat estimateAffine2D(Mat from, Mat to, Mat inliers, int method, double ransacReprojThreshold, long maxIters, double confidence) {
+ return new Mat(estimateAffine2D_1(from.nativeObj, to.nativeObj, inliers.nativeObj, method, ransacReprojThreshold, maxIters, confidence));
+ }
+
+ /**
+ * Computes an optimal affine transformation between two 2D point sets.
+ *
+ * It computes
+ * \(
+ * \begin{bmatrix}
+ * x\\
+ * y\\
+ * \end{bmatrix}
+ * =
+ * \begin{bmatrix}
+ * a_{11} & a_{12}\\
+ * a_{21} & a_{22}\\
+ * \end{bmatrix}
+ * \begin{bmatrix}
+ * X\\
+ * Y\\
+ * \end{bmatrix}
+ * +
+ * \begin{bmatrix}
+ * b_1\\
+ * b_2\\
+ * \end{bmatrix}
+ * \)
+ *
+ * @param from First input 2D point set containing \((X,Y)\).
+ * @param to Second input 2D point set containing \((x,y)\).
+ * @param inliers Output vector indicating which points are inliers (1-inlier, 0-outlier).
+ * @param method Robust method used to compute transformation. The following methods are possible:
+ *
+ *
+ * REF: RANSAC - RANSAC-based robust method
+ *
+ *
+ * REF: LMEDS - Least-Median robust method
+ * RANSAC is the default method.
+ *
+ *
+ * @param ransacReprojThreshold Maximum reprojection error in the RANSAC algorithm to consider
+ * a point as an inlier. Applies only to RANSAC.
+ * @param maxIters The maximum number of robust method iterations.
+ * between 0.95 and 0.99 is usually good enough. Values too close to 1 can slow down the estimation
+ * significantly. Values lower than 0.8-0.9 can result in an incorrectly estimated transformation.
+ * Passing 0 will disable refining, so the output matrix will be output of robust method.
+ *
+ * @return Output 2D affine transformation matrix \(2 \times 3\) or empty matrix if transformation
+ * could not be estimated. The returned matrix has the following form:
+ * \(
+ * \begin{bmatrix}
+ * a_{11} & a_{12} & b_1\\
+ * a_{21} & a_{22} & b_2\\
+ * \end{bmatrix}
+ * \)
+ *
+ * The function estimates an optimal 2D affine transformation between two 2D point sets using the
+ * selected robust algorithm.
+ *
+ * The computed transformation is then refined further (using only inliers) with the
+ * Levenberg-Marquardt method to reduce the re-projection error even more.
+ *
+ * Note:
+ * The RANSAC method can handle practically any ratio of outliers but needs a threshold to
+ * distinguish inliers from outliers. The method LMeDS does not need any threshold but it works
+ * correctly only when there are more than 50% of inliers.
+ *
+ * SEE: estimateAffinePartial2D, getAffineTransform
+ */
+ public static Mat estimateAffine2D(Mat from, Mat to, Mat inliers, int method, double ransacReprojThreshold, long maxIters) {
+ return new Mat(estimateAffine2D_2(from.nativeObj, to.nativeObj, inliers.nativeObj, method, ransacReprojThreshold, maxIters));
+ }
+
+ /**
+ * Computes an optimal affine transformation between two 2D point sets.
+ *
+ * It computes
+ * \(
+ * \begin{bmatrix}
+ * x\\
+ * y\\
+ * \end{bmatrix}
+ * =
+ * \begin{bmatrix}
+ * a_{11} & a_{12}\\
+ * a_{21} & a_{22}\\
+ * \end{bmatrix}
+ * \begin{bmatrix}
+ * X\\
+ * Y\\
+ * \end{bmatrix}
+ * +
+ * \begin{bmatrix}
+ * b_1\\
+ * b_2\\
+ * \end{bmatrix}
+ * \)
+ *
+ * @param from First input 2D point set containing \((X,Y)\).
+ * @param to Second input 2D point set containing \((x,y)\).
+ * @param inliers Output vector indicating which points are inliers (1-inlier, 0-outlier).
+ * @param method Robust method used to compute transformation. The following methods are possible:
+ *
+ *
+ * REF: RANSAC - RANSAC-based robust method
+ *
+ *
+ * REF: LMEDS - Least-Median robust method
+ * RANSAC is the default method.
+ *
+ *
+ * @param ransacReprojThreshold Maximum reprojection error in the RANSAC algorithm to consider
+ * a point as an inlier. Applies only to RANSAC.
+ * between 0.95 and 0.99 is usually good enough. Values too close to 1 can slow down the estimation
+ * significantly. Values lower than 0.8-0.9 can result in an incorrectly estimated transformation.
+ * Passing 0 will disable refining, so the output matrix will be output of robust method.
+ *
+ * @return Output 2D affine transformation matrix \(2 \times 3\) or empty matrix if transformation
+ * could not be estimated. The returned matrix has the following form:
+ * \(
+ * \begin{bmatrix}
+ * a_{11} & a_{12} & b_1\\
+ * a_{21} & a_{22} & b_2\\
+ * \end{bmatrix}
+ * \)
+ *
+ * The function estimates an optimal 2D affine transformation between two 2D point sets using the
+ * selected robust algorithm.
+ *
+ * The computed transformation is then refined further (using only inliers) with the
+ * Levenberg-Marquardt method to reduce the re-projection error even more.
+ *
+ * Note:
+ * The RANSAC method can handle practically any ratio of outliers but needs a threshold to
+ * distinguish inliers from outliers. The method LMeDS does not need any threshold but it works
+ * correctly only when there are more than 50% of inliers.
+ *
+ * SEE: estimateAffinePartial2D, getAffineTransform
+ */
+ public static Mat estimateAffine2D(Mat from, Mat to, Mat inliers, int method, double ransacReprojThreshold) {
+ return new Mat(estimateAffine2D_3(from.nativeObj, to.nativeObj, inliers.nativeObj, method, ransacReprojThreshold));
+ }
+
+ /**
+ * Computes an optimal affine transformation between two 2D point sets.
+ *
+ * It computes
+ * \(
+ * \begin{bmatrix}
+ * x\\
+ * y\\
+ * \end{bmatrix}
+ * =
+ * \begin{bmatrix}
+ * a_{11} & a_{12}\\
+ * a_{21} & a_{22}\\
+ * \end{bmatrix}
+ * \begin{bmatrix}
+ * X\\
+ * Y\\
+ * \end{bmatrix}
+ * +
+ * \begin{bmatrix}
+ * b_1\\
+ * b_2\\
+ * \end{bmatrix}
+ * \)
+ *
+ * @param from First input 2D point set containing \((X,Y)\).
+ * @param to Second input 2D point set containing \((x,y)\).
+ * @param inliers Output vector indicating which points are inliers (1-inlier, 0-outlier).
+ * @param method Robust method used to compute transformation. The following methods are possible:
+ *
+ *
+ * REF: RANSAC - RANSAC-based robust method
+ *
+ *
+ * REF: LMEDS - Least-Median robust method
+ * RANSAC is the default method.
+ *
+ *
+ * a point as an inlier. Applies only to RANSAC.
+ * between 0.95 and 0.99 is usually good enough. Values too close to 1 can slow down the estimation
+ * significantly. Values lower than 0.8-0.9 can result in an incorrectly estimated transformation.
+ * Passing 0 will disable refining, so the output matrix will be output of robust method.
+ *
+ * @return Output 2D affine transformation matrix \(2 \times 3\) or empty matrix if transformation
+ * could not be estimated. The returned matrix has the following form:
+ * \(
+ * \begin{bmatrix}
+ * a_{11} & a_{12} & b_1\\
+ * a_{21} & a_{22} & b_2\\
+ * \end{bmatrix}
+ * \)
+ *
+ * The function estimates an optimal 2D affine transformation between two 2D point sets using the
+ * selected robust algorithm.
+ *
+ * The computed transformation is then refined further (using only inliers) with the
+ * Levenberg-Marquardt method to reduce the re-projection error even more.
+ *
+ * Note:
+ * The RANSAC method can handle practically any ratio of outliers but needs a threshold to
+ * distinguish inliers from outliers. The method LMeDS does not need any threshold but it works
+ * correctly only when there are more than 50% of inliers.
+ *
+ * SEE: estimateAffinePartial2D, getAffineTransform
+ */
+ public static Mat estimateAffine2D(Mat from, Mat to, Mat inliers, int method) {
+ return new Mat(estimateAffine2D_4(from.nativeObj, to.nativeObj, inliers.nativeObj, method));
+ }
+
+ /**
+ * Computes an optimal affine transformation between two 2D point sets.
+ *
+ * It computes
+ * \(
+ * \begin{bmatrix}
+ * x\\
+ * y\\
+ * \end{bmatrix}
+ * =
+ * \begin{bmatrix}
+ * a_{11} & a_{12}\\
+ * a_{21} & a_{22}\\
+ * \end{bmatrix}
+ * \begin{bmatrix}
+ * X\\
+ * Y\\
+ * \end{bmatrix}
+ * +
+ * \begin{bmatrix}
+ * b_1\\
+ * b_2\\
+ * \end{bmatrix}
+ * \)
+ *
+ * @param from First input 2D point set containing \((X,Y)\).
+ * @param to Second input 2D point set containing \((x,y)\).
+ * @param inliers Output vector indicating which points are inliers (1-inlier, 0-outlier).
+ *
+ *
+ * REF: RANSAC - RANSAC-based robust method
+ *
+ *
+ * REF: LMEDS - Least-Median robust method
+ * RANSAC is the default method.
+ *
+ *
+ * a point as an inlier. Applies only to RANSAC.
+ * between 0.95 and 0.99 is usually good enough. Values too close to 1 can slow down the estimation
+ * significantly. Values lower than 0.8-0.9 can result in an incorrectly estimated transformation.
+ * Passing 0 will disable refining, so the output matrix will be output of robust method.
+ *
+ * @return Output 2D affine transformation matrix \(2 \times 3\) or empty matrix if transformation
+ * could not be estimated. The returned matrix has the following form:
+ * \(
+ * \begin{bmatrix}
+ * a_{11} & a_{12} & b_1\\
+ * a_{21} & a_{22} & b_2\\
+ * \end{bmatrix}
+ * \)
+ *
+ * The function estimates an optimal 2D affine transformation between two 2D point sets using the
+ * selected robust algorithm.
+ *
+ * The computed transformation is then refined further (using only inliers) with the
+ * Levenberg-Marquardt method to reduce the re-projection error even more.
+ *
+ * Note:
+ * The RANSAC method can handle practically any ratio of outliers but needs a threshold to
+ * distinguish inliers from outliers. The method LMeDS does not need any threshold but it works
+ * correctly only when there are more than 50% of inliers.
+ *
+ * SEE: estimateAffinePartial2D, getAffineTransform
+ */
+ public static Mat estimateAffine2D(Mat from, Mat to, Mat inliers) {
+ return new Mat(estimateAffine2D_5(from.nativeObj, to.nativeObj, inliers.nativeObj));
+ }
+
+ /**
+ * Computes an optimal affine transformation between two 2D point sets.
+ *
+ * It computes
+ * \(
+ * \begin{bmatrix}
+ * x\\
+ * y\\
+ * \end{bmatrix}
+ * =
+ * \begin{bmatrix}
+ * a_{11} & a_{12}\\
+ * a_{21} & a_{22}\\
+ * \end{bmatrix}
+ * \begin{bmatrix}
+ * X\\
+ * Y\\
+ * \end{bmatrix}
+ * +
+ * \begin{bmatrix}
+ * b_1\\
+ * b_2\\
+ * \end{bmatrix}
+ * \)
+ *
+ * @param from First input 2D point set containing \((X,Y)\).
+ * @param to Second input 2D point set containing \((x,y)\).
+ *
+ *
+ * REF: RANSAC - RANSAC-based robust method
+ *
+ *
+ * REF: LMEDS - Least-Median robust method
+ * RANSAC is the default method.
+ *
+ *
+ * a point as an inlier. Applies only to RANSAC.
+ * between 0.95 and 0.99 is usually good enough. Values too close to 1 can slow down the estimation
+ * significantly. Values lower than 0.8-0.9 can result in an incorrectly estimated transformation.
+ * Passing 0 will disable refining, so the output matrix will be output of robust method.
+ *
+ * @return Output 2D affine transformation matrix \(2 \times 3\) or empty matrix if transformation
+ * could not be estimated. The returned matrix has the following form:
+ * \(
+ * \begin{bmatrix}
+ * a_{11} & a_{12} & b_1\\
+ * a_{21} & a_{22} & b_2\\
+ * \end{bmatrix}
+ * \)
+ *
+ * The function estimates an optimal 2D affine transformation between two 2D point sets using the
+ * selected robust algorithm.
+ *
+ * The computed transformation is then refined further (using only inliers) with the
+ * Levenberg-Marquardt method to reduce the re-projection error even more.
+ *
+ * Note:
+ * The RANSAC method can handle practically any ratio of outliers but needs a threshold to
+ * distinguish inliers from outliers. The method LMeDS does not need any threshold but it works
+ * correctly only when there are more than 50% of inliers.
+ *
+ * SEE: estimateAffinePartial2D, getAffineTransform
+ */
+ public static Mat estimateAffine2D(Mat from, Mat to) {
+ return new Mat(estimateAffine2D_6(from.nativeObj, to.nativeObj));
+ }
+
+
+ //
+ // C++: Mat cv::estimateAffine2D(Mat pts1, Mat pts2, Mat& inliers, UsacParams params)
+ //
+
+ public static Mat estimateAffine2D(Mat pts1, Mat pts2, Mat inliers, UsacParams params) {
+ return new Mat(estimateAffine2D_7(pts1.nativeObj, pts2.nativeObj, inliers.nativeObj, params.nativeObj));
+ }
+
+
+ //
+ // C++: Mat cv::estimateAffinePartial2D(Mat from, Mat to, Mat& inliers = Mat(), int method = RANSAC, double ransacReprojThreshold = 3, size_t maxIters = 2000, double confidence = 0.99, size_t refineIters = 10)
+ //
+
+ /**
+ * Computes an optimal limited affine transformation with 4 degrees of freedom between
+ * two 2D point sets.
+ *
+ * @param from First input 2D point set.
+ * @param to Second input 2D point set.
+ * @param inliers Output vector indicating which points are inliers.
+ * @param method Robust method used to compute transformation. The following methods are possible:
+ *
+ *
+ * REF: RANSAC - RANSAC-based robust method
+ *
+ *
+ * REF: LMEDS - Least-Median robust method
+ * RANSAC is the default method.
+ *
+ *
+ * @param ransacReprojThreshold Maximum reprojection error in the RANSAC algorithm to consider
+ * a point as an inlier. Applies only to RANSAC.
+ * @param maxIters The maximum number of robust method iterations.
+ * @param confidence Confidence level, between 0 and 1, for the estimated transformation. Anything
+ * between 0.95 and 0.99 is usually good enough. Values too close to 1 can slow down the estimation
+ * significantly. Values lower than 0.8-0.9 can result in an incorrectly estimated transformation.
+ * @param refineIters Maximum number of iterations of refining algorithm (Levenberg-Marquardt).
+ * Passing 0 will disable refining, so the output matrix will be output of robust method.
+ *
+ * @return Output 2D affine transformation (4 degrees of freedom) matrix \(2 \times 3\) or
+ * empty matrix if transformation could not be estimated.
+ *
+ * The function estimates an optimal 2D affine transformation with 4 degrees of freedom limited to
+ * combinations of translation, rotation, and uniform scaling. Uses the selected algorithm for robust
+ * estimation.
+ *
+ * The computed transformation is then refined further (using only inliers) with the
+ * Levenberg-Marquardt method to reduce the re-projection error even more.
+ *
+ * Estimated transformation matrix is:
+ * \( \begin{bmatrix} \cos(\theta) \cdot s & -\sin(\theta) \cdot s & t_x \\
+ * \sin(\theta) \cdot s & \cos(\theta) \cdot s & t_y
+ * \end{bmatrix} \)
+ * Where \( \theta \) is the rotation angle, \( s \) the scaling factor and \( t_x, t_y \) are
+ * translations in \( x, y \) axes respectively.
+ *
+ * Note:
+ * The RANSAC method can handle practically any ratio of outliers but need a threshold to
+ * distinguish inliers from outliers. The method LMeDS does not need any threshold but it works
+ * correctly only when there are more than 50% of inliers.
+ *
+ * SEE: estimateAffine2D, getAffineTransform
+ */
+ public static Mat estimateAffinePartial2D(Mat from, Mat to, Mat inliers, int method, double ransacReprojThreshold, long maxIters, double confidence, long refineIters) {
+ return new Mat(estimateAffinePartial2D_0(from.nativeObj, to.nativeObj, inliers.nativeObj, method, ransacReprojThreshold, maxIters, confidence, refineIters));
+ }
+
+ /**
+ * Computes an optimal limited affine transformation with 4 degrees of freedom between
+ * two 2D point sets.
+ *
+ * @param from First input 2D point set.
+ * @param to Second input 2D point set.
+ * @param inliers Output vector indicating which points are inliers.
+ * @param method Robust method used to compute transformation. The following methods are possible:
+ *
+ *
+ * REF: RANSAC - RANSAC-based robust method
+ *
+ *
+ * REF: LMEDS - Least-Median robust method
+ * RANSAC is the default method.
+ *
+ *
+ * @param ransacReprojThreshold Maximum reprojection error in the RANSAC algorithm to consider
+ * a point as an inlier. Applies only to RANSAC.
+ * @param maxIters The maximum number of robust method iterations.
+ * @param confidence Confidence level, between 0 and 1, for the estimated transformation. Anything
+ * between 0.95 and 0.99 is usually good enough. Values too close to 1 can slow down the estimation
+ * significantly. Values lower than 0.8-0.9 can result in an incorrectly estimated transformation.
+ * Passing 0 will disable refining, so the output matrix will be output of robust method.
+ *
+ * @return Output 2D affine transformation (4 degrees of freedom) matrix \(2 \times 3\) or
+ * empty matrix if transformation could not be estimated.
+ *
+ * The function estimates an optimal 2D affine transformation with 4 degrees of freedom limited to
+ * combinations of translation, rotation, and uniform scaling. Uses the selected algorithm for robust
+ * estimation.
+ *
+ * The computed transformation is then refined further (using only inliers) with the
+ * Levenberg-Marquardt method to reduce the re-projection error even more.
+ *
+ * Estimated transformation matrix is:
+ * \( \begin{bmatrix} \cos(\theta) \cdot s & -\sin(\theta) \cdot s & t_x \\
+ * \sin(\theta) \cdot s & \cos(\theta) \cdot s & t_y
+ * \end{bmatrix} \)
+ * Where \( \theta \) is the rotation angle, \( s \) the scaling factor and \( t_x, t_y \) are
+ * translations in \( x, y \) axes respectively.
+ *
+ * Note:
+ * The RANSAC method can handle practically any ratio of outliers but need a threshold to
+ * distinguish inliers from outliers. The method LMeDS does not need any threshold but it works
+ * correctly only when there are more than 50% of inliers.
+ *
+ * SEE: estimateAffine2D, getAffineTransform
+ */
+ public static Mat estimateAffinePartial2D(Mat from, Mat to, Mat inliers, int method, double ransacReprojThreshold, long maxIters, double confidence) {
+ return new Mat(estimateAffinePartial2D_1(from.nativeObj, to.nativeObj, inliers.nativeObj, method, ransacReprojThreshold, maxIters, confidence));
+ }
+
+ /**
+ * Computes an optimal limited affine transformation with 4 degrees of freedom between
+ * two 2D point sets.
+ *
+ * @param from First input 2D point set.
+ * @param to Second input 2D point set.
+ * @param inliers Output vector indicating which points are inliers.
+ * @param method Robust method used to compute transformation. The following methods are possible:
+ *
+ *
+ * REF: RANSAC - RANSAC-based robust method
+ *
+ *
+ * REF: LMEDS - Least-Median robust method
+ * RANSAC is the default method.
+ *
+ *
+ * @param ransacReprojThreshold Maximum reprojection error in the RANSAC algorithm to consider
+ * a point as an inlier. Applies only to RANSAC.
+ * @param maxIters The maximum number of robust method iterations.
+ * between 0.95 and 0.99 is usually good enough. Values too close to 1 can slow down the estimation
+ * significantly. Values lower than 0.8-0.9 can result in an incorrectly estimated transformation.
+ * Passing 0 will disable refining, so the output matrix will be output of robust method.
+ *
+ * @return Output 2D affine transformation (4 degrees of freedom) matrix \(2 \times 3\) or
+ * empty matrix if transformation could not be estimated.
+ *
+ * The function estimates an optimal 2D affine transformation with 4 degrees of freedom limited to
+ * combinations of translation, rotation, and uniform scaling. Uses the selected algorithm for robust
+ * estimation.
+ *
+ * The computed transformation is then refined further (using only inliers) with the
+ * Levenberg-Marquardt method to reduce the re-projection error even more.
+ *
+ * Estimated transformation matrix is:
+ * \( \begin{bmatrix} \cos(\theta) \cdot s & -\sin(\theta) \cdot s & t_x \\
+ * \sin(\theta) \cdot s & \cos(\theta) \cdot s & t_y
+ * \end{bmatrix} \)
+ * Where \( \theta \) is the rotation angle, \( s \) the scaling factor and \( t_x, t_y \) are
+ * translations in \( x, y \) axes respectively.
+ *
+ * Note:
+ * The RANSAC method can handle practically any ratio of outliers but need a threshold to
+ * distinguish inliers from outliers. The method LMeDS does not need any threshold but it works
+ * correctly only when there are more than 50% of inliers.
+ *
+ * SEE: estimateAffine2D, getAffineTransform
+ */
+ public static Mat estimateAffinePartial2D(Mat from, Mat to, Mat inliers, int method, double ransacReprojThreshold, long maxIters) {
+ return new Mat(estimateAffinePartial2D_2(from.nativeObj, to.nativeObj, inliers.nativeObj, method, ransacReprojThreshold, maxIters));
+ }
+
+ /**
+ * Computes an optimal limited affine transformation with 4 degrees of freedom between
+ * two 2D point sets.
+ *
+ * @param from First input 2D point set.
+ * @param to Second input 2D point set.
+ * @param inliers Output vector indicating which points are inliers.
+ * @param method Robust method used to compute transformation. The following methods are possible:
+ *
+ *
+ * REF: RANSAC - RANSAC-based robust method
+ *
+ *
+ * REF: LMEDS - Least-Median robust method
+ * RANSAC is the default method.
+ *
+ *
+ * @param ransacReprojThreshold Maximum reprojection error in the RANSAC algorithm to consider
+ * a point as an inlier. Applies only to RANSAC.
+ * between 0.95 and 0.99 is usually good enough. Values too close to 1 can slow down the estimation
+ * significantly. Values lower than 0.8-0.9 can result in an incorrectly estimated transformation.
+ * Passing 0 will disable refining, so the output matrix will be output of robust method.
+ *
+ * @return Output 2D affine transformation (4 degrees of freedom) matrix \(2 \times 3\) or
+ * empty matrix if transformation could not be estimated.
+ *
+ * The function estimates an optimal 2D affine transformation with 4 degrees of freedom limited to
+ * combinations of translation, rotation, and uniform scaling. Uses the selected algorithm for robust
+ * estimation.
+ *
+ * The computed transformation is then refined further (using only inliers) with the
+ * Levenberg-Marquardt method to reduce the re-projection error even more.
+ *
+ * Estimated transformation matrix is:
+ * \( \begin{bmatrix} \cos(\theta) \cdot s & -\sin(\theta) \cdot s & t_x \\
+ * \sin(\theta) \cdot s & \cos(\theta) \cdot s & t_y
+ * \end{bmatrix} \)
+ * Where \( \theta \) is the rotation angle, \( s \) the scaling factor and \( t_x, t_y \) are
+ * translations in \( x, y \) axes respectively.
+ *
+ * Note:
+ * The RANSAC method can handle practically any ratio of outliers but need a threshold to
+ * distinguish inliers from outliers. The method LMeDS does not need any threshold but it works
+ * correctly only when there are more than 50% of inliers.
+ *
+ * SEE: estimateAffine2D, getAffineTransform
+ */
+ public static Mat estimateAffinePartial2D(Mat from, Mat to, Mat inliers, int method, double ransacReprojThreshold) {
+ return new Mat(estimateAffinePartial2D_3(from.nativeObj, to.nativeObj, inliers.nativeObj, method, ransacReprojThreshold));
+ }
+
+ /**
+ * Computes an optimal limited affine transformation with 4 degrees of freedom between
+ * two 2D point sets.
+ *
+ * @param from First input 2D point set.
+ * @param to Second input 2D point set.
+ * @param inliers Output vector indicating which points are inliers.
+ * @param method Robust method used to compute transformation. The following methods are possible:
+ *
+ *
+ * REF: RANSAC - RANSAC-based robust method
+ *
+ *
+ * REF: LMEDS - Least-Median robust method
+ * RANSAC is the default method.
+ *
+ *
+ * a point as an inlier. Applies only to RANSAC.
+ * between 0.95 and 0.99 is usually good enough. Values too close to 1 can slow down the estimation
+ * significantly. Values lower than 0.8-0.9 can result in an incorrectly estimated transformation.
+ * Passing 0 will disable refining, so the output matrix will be output of robust method.
+ *
+ * @return Output 2D affine transformation (4 degrees of freedom) matrix \(2 \times 3\) or
+ * empty matrix if transformation could not be estimated.
+ *
+ * The function estimates an optimal 2D affine transformation with 4 degrees of freedom limited to
+ * combinations of translation, rotation, and uniform scaling. Uses the selected algorithm for robust
+ * estimation.
+ *
+ * The computed transformation is then refined further (using only inliers) with the
+ * Levenberg-Marquardt method to reduce the re-projection error even more.
+ *
+ * Estimated transformation matrix is:
+ * \( \begin{bmatrix} \cos(\theta) \cdot s & -\sin(\theta) \cdot s & t_x \\
+ * \sin(\theta) \cdot s & \cos(\theta) \cdot s & t_y
+ * \end{bmatrix} \)
+ * Where \( \theta \) is the rotation angle, \( s \) the scaling factor and \( t_x, t_y \) are
+ * translations in \( x, y \) axes respectively.
+ *
+ * Note:
+ * The RANSAC method can handle practically any ratio of outliers but need a threshold to
+ * distinguish inliers from outliers. The method LMeDS does not need any threshold but it works
+ * correctly only when there are more than 50% of inliers.
+ *
+ * SEE: estimateAffine2D, getAffineTransform
+ */
+ public static Mat estimateAffinePartial2D(Mat from, Mat to, Mat inliers, int method) {
+ return new Mat(estimateAffinePartial2D_4(from.nativeObj, to.nativeObj, inliers.nativeObj, method));
+ }
+
+ /**
+ * Computes an optimal limited affine transformation with 4 degrees of freedom between
+ * two 2D point sets.
+ *
+ * @param from First input 2D point set.
+ * @param to Second input 2D point set.
+ * @param inliers Output vector indicating which points are inliers.
+ *
+ *
+ * REF: RANSAC - RANSAC-based robust method
+ *
+ *
+ * REF: LMEDS - Least-Median robust method
+ * RANSAC is the default method.
+ *
+ *
+ * a point as an inlier. Applies only to RANSAC.
+ * between 0.95 and 0.99 is usually good enough. Values too close to 1 can slow down the estimation
+ * significantly. Values lower than 0.8-0.9 can result in an incorrectly estimated transformation.
+ * Passing 0 will disable refining, so the output matrix will be output of robust method.
+ *
+ * @return Output 2D affine transformation (4 degrees of freedom) matrix \(2 \times 3\) or
+ * empty matrix if transformation could not be estimated.
+ *
+ * The function estimates an optimal 2D affine transformation with 4 degrees of freedom limited to
+ * combinations of translation, rotation, and uniform scaling. Uses the selected algorithm for robust
+ * estimation.
+ *
+ * The computed transformation is then refined further (using only inliers) with the
+ * Levenberg-Marquardt method to reduce the re-projection error even more.
+ *
+ * Estimated transformation matrix is:
+ * \( \begin{bmatrix} \cos(\theta) \cdot s & -\sin(\theta) \cdot s & t_x \\
+ * \sin(\theta) \cdot s & \cos(\theta) \cdot s & t_y
+ * \end{bmatrix} \)
+ * Where \( \theta \) is the rotation angle, \( s \) the scaling factor and \( t_x, t_y \) are
+ * translations in \( x, y \) axes respectively.
+ *
+ * Note:
+ * The RANSAC method can handle practically any ratio of outliers but need a threshold to
+ * distinguish inliers from outliers. The method LMeDS does not need any threshold but it works
+ * correctly only when there are more than 50% of inliers.
+ *
+ * SEE: estimateAffine2D, getAffineTransform
+ */
+ public static Mat estimateAffinePartial2D(Mat from, Mat to, Mat inliers) {
+ return new Mat(estimateAffinePartial2D_5(from.nativeObj, to.nativeObj, inliers.nativeObj));
+ }
+
+ /**
+ * Computes an optimal limited affine transformation with 4 degrees of freedom between
+ * two 2D point sets.
+ *
+ * @param from First input 2D point set.
+ * @param to Second input 2D point set.
+ *
+ *
+ * REF: RANSAC - RANSAC-based robust method
+ *
+ *
+ * REF: LMEDS - Least-Median robust method
+ * RANSAC is the default method.
+ *
+ *
+ * a point as an inlier. Applies only to RANSAC.
+ * between 0.95 and 0.99 is usually good enough. Values too close to 1 can slow down the estimation
+ * significantly. Values lower than 0.8-0.9 can result in an incorrectly estimated transformation.
+ * Passing 0 will disable refining, so the output matrix will be output of robust method.
+ *
+ * @return Output 2D affine transformation (4 degrees of freedom) matrix \(2 \times 3\) or
+ * empty matrix if transformation could not be estimated.
+ *
+ * The function estimates an optimal 2D affine transformation with 4 degrees of freedom limited to
+ * combinations of translation, rotation, and uniform scaling. Uses the selected algorithm for robust
+ * estimation.
+ *
+ * The computed transformation is then refined further (using only inliers) with the
+ * Levenberg-Marquardt method to reduce the re-projection error even more.
+ *
+ * Estimated transformation matrix is:
+ * \( \begin{bmatrix} \cos(\theta) \cdot s & -\sin(\theta) \cdot s & t_x \\
+ * \sin(\theta) \cdot s & \cos(\theta) \cdot s & t_y
+ * \end{bmatrix} \)
+ * Where \( \theta \) is the rotation angle, \( s \) the scaling factor and \( t_x, t_y \) are
+ * translations in \( x, y \) axes respectively.
+ *
+ * Note:
+ * The RANSAC method can handle practically any ratio of outliers but need a threshold to
+ * distinguish inliers from outliers. The method LMeDS does not need any threshold but it works
+ * correctly only when there are more than 50% of inliers.
+ *
+ * SEE: estimateAffine2D, getAffineTransform
+ */
+ public static Mat estimateAffinePartial2D(Mat from, Mat to) {
+ return new Mat(estimateAffinePartial2D_6(from.nativeObj, to.nativeObj));
+ }
+
+
+ //
+ // C++: int cv::decomposeHomographyMat(Mat H, Mat K, vector_Mat& rotations, vector_Mat& translations, vector_Mat& normals)
+ //
+
+ /**
+ * Decompose a homography matrix to rotation(s), translation(s) and plane normal(s).
+ *
+ * @param H The input homography matrix between two images.
+ * @param K The input camera intrinsic matrix.
+ * @param rotations Array of rotation matrices.
+ * @param translations Array of translation matrices.
+ * @param normals Array of plane normal matrices.
+ *
+ * This function extracts relative camera motion between two views of a planar object and returns up to
+ * four mathematical solution tuples of rotation, translation, and plane normal. The decomposition of
+ * the homography matrix H is described in detail in CITE: Malis2007.
+ *
+ * If the homography H, induced by the plane, gives the constraint
+ * \(s_i \vecthree{x'_i}{y'_i}{1} \sim H \vecthree{x_i}{y_i}{1}\) on the source image points
+ * \(p_i\) and the destination image points \(p'_i\), then the tuple of rotations[k] and
+ * translations[k] is a change of basis from the source camera's coordinate system to the destination
+ * camera's coordinate system. However, by decomposing H, one can only get the translation normalized
+ * by the (typically unknown) depth of the scene, i.e. its direction but with normalized length.
+ *
+ * If point correspondences are available, at least two solutions may further be invalidated, by
+ * applying positive depth constraint, i.e. all points must be in front of the camera.
+ * @return automatically generated
+ */
+ public static int decomposeHomographyMat(Mat H, Mat K, List rotations, List translations, List normals) {
+ Mat rotations_mat = new Mat();
+ Mat translations_mat = new Mat();
+ Mat normals_mat = new Mat();
+ int retVal = decomposeHomographyMat_0(H.nativeObj, K.nativeObj, rotations_mat.nativeObj, translations_mat.nativeObj, normals_mat.nativeObj);
+ Converters.Mat_to_vector_Mat(rotations_mat, rotations);
+ rotations_mat.release();
+ Converters.Mat_to_vector_Mat(translations_mat, translations);
+ translations_mat.release();
+ Converters.Mat_to_vector_Mat(normals_mat, normals);
+ normals_mat.release();
+ return retVal;
+ }
+
+
+ //
+ // C++: void cv::filterHomographyDecompByVisibleRefpoints(vector_Mat rotations, vector_Mat normals, Mat beforePoints, Mat afterPoints, Mat& possibleSolutions, Mat pointsMask = Mat())
+ //
+
+ /**
+ * Filters homography decompositions based on additional information.
+ *
+ * @param rotations Vector of rotation matrices.
+ * @param normals Vector of plane normal matrices.
+ * @param beforePoints Vector of (rectified) visible reference points before the homography is applied
+ * @param afterPoints Vector of (rectified) visible reference points after the homography is applied
+ * @param possibleSolutions Vector of int indices representing the viable solution set after filtering
+ * @param pointsMask optional Mat/Vector of 8u type representing the mask for the inliers as given by the #findHomography function
+ *
+ * This function is intended to filter the output of the #decomposeHomographyMat based on additional
+ * information as described in CITE: Malis2007 . The summary of the method: the #decomposeHomographyMat function
+ * returns 2 unique solutions and their "opposites" for a total of 4 solutions. If we have access to the
+ * sets of points visible in the camera frame before and after the homography transformation is applied,
+ * we can determine which are the true potential solutions and which are the opposites by verifying which
+ * homographies are consistent with all visible reference points being in front of the camera. The inputs
+ * are left unchanged; the filtered solution set is returned as indices into the existing one.
+ */
+ public static void filterHomographyDecompByVisibleRefpoints(List rotations, List normals, Mat beforePoints, Mat afterPoints, Mat possibleSolutions, Mat pointsMask) {
+ Mat rotations_mat = Converters.vector_Mat_to_Mat(rotations);
+ Mat normals_mat = Converters.vector_Mat_to_Mat(normals);
+ filterHomographyDecompByVisibleRefpoints_0(rotations_mat.nativeObj, normals_mat.nativeObj, beforePoints.nativeObj, afterPoints.nativeObj, possibleSolutions.nativeObj, pointsMask.nativeObj);
+ }
+
+ /**
+ * Filters homography decompositions based on additional information.
+ *
+ * @param rotations Vector of rotation matrices.
+ * @param normals Vector of plane normal matrices.
+ * @param beforePoints Vector of (rectified) visible reference points before the homography is applied
+ * @param afterPoints Vector of (rectified) visible reference points after the homography is applied
+ * @param possibleSolutions Vector of int indices representing the viable solution set after filtering
+ *
+ * This function is intended to filter the output of the #decomposeHomographyMat based on additional
+ * information as described in CITE: Malis2007 . The summary of the method: the #decomposeHomographyMat function
+ * returns 2 unique solutions and their "opposites" for a total of 4 solutions. If we have access to the
+ * sets of points visible in the camera frame before and after the homography transformation is applied,
+ * we can determine which are the true potential solutions and which are the opposites by verifying which
+ * homographies are consistent with all visible reference points being in front of the camera. The inputs
+ * are left unchanged; the filtered solution set is returned as indices into the existing one.
+ */
+ public static void filterHomographyDecompByVisibleRefpoints(List rotations, List normals, Mat beforePoints, Mat afterPoints, Mat possibleSolutions) {
+ Mat rotations_mat = Converters.vector_Mat_to_Mat(rotations);
+ Mat normals_mat = Converters.vector_Mat_to_Mat(normals);
+ filterHomographyDecompByVisibleRefpoints_1(rotations_mat.nativeObj, normals_mat.nativeObj, beforePoints.nativeObj, afterPoints.nativeObj, possibleSolutions.nativeObj);
+ }
+
+
+ //
+ // C++: void cv::undistort(Mat src, Mat& dst, Mat cameraMatrix, Mat distCoeffs, Mat newCameraMatrix = Mat())
+ //
+
+ /**
+ * Transforms an image to compensate for lens distortion.
+ *
+ * The function transforms an image to compensate radial and tangential lens distortion.
+ *
+ * The function is simply a combination of #initUndistortRectifyMap (with unity R ) and #remap
+ * (with bilinear interpolation). See the former function for details of the transformation being
+ * performed.
+ *
+ * Those pixels in the destination image, for which there is no correspondent pixels in the source
+ * image, are filled with zeros (black color).
+ *
+ * A particular subset of the source image that will be visible in the corrected image can be regulated
+ * by newCameraMatrix. You can use #getOptimalNewCameraMatrix to compute the appropriate
+ * newCameraMatrix depending on your requirements.
+ *
+ * The camera matrix and the distortion parameters can be determined using #calibrateCamera. If
+ * the resolution of images is different from the resolution used at the calibration stage, \(f_x,
+ * f_y, c_x\) and \(c_y\) need to be scaled accordingly, while the distortion coefficients remain
+ * the same.
+ *
+ * @param src Input (distorted) image.
+ * @param dst Output (corrected) image that has the same size and type as src .
+ * @param cameraMatrix Input camera matrix \(A = \vecthreethree{f_x}{0}{c_x}{0}{f_y}{c_y}{0}{0}{1}\) .
+ * @param distCoeffs Input vector of distortion coefficients
+ * \((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]]]])\)
+ * of 4, 5, 8, 12 or 14 elements. If the vector is NULL/empty, the zero distortion coefficients are assumed.
+ * @param newCameraMatrix Camera matrix of the distorted image. By default, it is the same as
+ * cameraMatrix but you may additionally scale and shift the result by using a different matrix.
+ */
+ public static void undistort(Mat src, Mat dst, Mat cameraMatrix, Mat distCoeffs, Mat newCameraMatrix) {
+ undistort_0(src.nativeObj, dst.nativeObj, cameraMatrix.nativeObj, distCoeffs.nativeObj, newCameraMatrix.nativeObj);
+ }
+
+ /**
+ * Transforms an image to compensate for lens distortion.
+ *
+ * The function transforms an image to compensate radial and tangential lens distortion.
+ *
+ * The function is simply a combination of #initUndistortRectifyMap (with unity R ) and #remap
+ * (with bilinear interpolation). See the former function for details of the transformation being
+ * performed.
+ *
+ * Those pixels in the destination image, for which there is no correspondent pixels in the source
+ * image, are filled with zeros (black color).
+ *
+ * A particular subset of the source image that will be visible in the corrected image can be regulated
+ * by newCameraMatrix. You can use #getOptimalNewCameraMatrix to compute the appropriate
+ * newCameraMatrix depending on your requirements.
+ *
+ * The camera matrix and the distortion parameters can be determined using #calibrateCamera. If
+ * the resolution of images is different from the resolution used at the calibration stage, \(f_x,
+ * f_y, c_x\) and \(c_y\) need to be scaled accordingly, while the distortion coefficients remain
+ * the same.
+ *
+ * @param src Input (distorted) image.
+ * @param dst Output (corrected) image that has the same size and type as src .
+ * @param cameraMatrix Input camera matrix \(A = \vecthreethree{f_x}{0}{c_x}{0}{f_y}{c_y}{0}{0}{1}\) .
+ * @param distCoeffs Input vector of distortion coefficients
+ * \((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]]]])\)
+ * of 4, 5, 8, 12 or 14 elements. If the vector is NULL/empty, the zero distortion coefficients are assumed.
+ * cameraMatrix but you may additionally scale and shift the result by using a different matrix.
+ */
+ public static void undistort(Mat src, Mat dst, Mat cameraMatrix, Mat distCoeffs) {
+ undistort_1(src.nativeObj, dst.nativeObj, cameraMatrix.nativeObj, distCoeffs.nativeObj);
+ }
+
+
+ //
+ // C++: void cv::initUndistortRectifyMap(Mat cameraMatrix, Mat distCoeffs, Mat R, Mat newCameraMatrix, Size size, int m1type, Mat& map1, Mat& map2)
+ //
+
+ /**
+ * Computes the undistortion and rectification transformation map.
+ *
+ * The function computes the joint undistortion and rectification transformation and represents the
+ * result in the form of maps for #remap. The undistorted image looks like original, as if it is
+ * captured with a camera using the camera matrix =newCameraMatrix and zero distortion. In case of a
+ * monocular camera, newCameraMatrix is usually equal to cameraMatrix, or it can be computed by
+ * #getOptimalNewCameraMatrix for a better control over scaling. In case of a stereo camera,
+ * newCameraMatrix is normally set to P1 or P2 computed by #stereoRectify .
+ *
+ * Also, this new camera is oriented differently in the coordinate space, according to R. That, for
+ * example, helps to align two heads of a stereo camera so that the epipolar lines on both images
+ * become horizontal and have the same y- coordinate (in case of a horizontally aligned stereo camera).
+ *
+ * The function actually builds the maps for the inverse mapping algorithm that is used by #remap. That
+ * is, for each pixel \((u, v)\) in the destination (corrected and rectified) image, the function
+ * computes the corresponding coordinates in the source image (that is, in the original image from
+ * camera). The following process is applied:
+ * \(
+ * \begin{array}{l}
+ * x \leftarrow (u - {c'}_x)/{f'}_x \\
+ * y \leftarrow (v - {c'}_y)/{f'}_y \\
+ * {[X\,Y\,W]} ^T \leftarrow R^{-1}*[x \, y \, 1]^T \\
+ * x' \leftarrow X/W \\
+ * y' \leftarrow Y/W \\
+ * r^2 \leftarrow x'^2 + y'^2 \\
+ * x'' \leftarrow x' \frac{1 + k_1 r^2 + k_2 r^4 + k_3 r^6}{1 + k_4 r^2 + k_5 r^4 + k_6 r^6}
+ * + 2p_1 x' y' + p_2(r^2 + 2 x'^2) + s_1 r^2 + s_2 r^4\\
+ * y'' \leftarrow y' \frac{1 + k_1 r^2 + k_2 r^4 + k_3 r^6}{1 + k_4 r^2 + k_5 r^4 + k_6 r^6}
+ * + p_1 (r^2 + 2 y'^2) + 2 p_2 x' y' + s_3 r^2 + s_4 r^4 \\
+ * s\vecthree{x'''}{y'''}{1} =
+ * \vecthreethree{R_{33}(\tau_x, \tau_y)}{0}{-R_{13}((\tau_x, \tau_y)}
+ * {0}{R_{33}(\tau_x, \tau_y)}{-R_{23}(\tau_x, \tau_y)}
+ * {0}{0}{1} R(\tau_x, \tau_y) \vecthree{x''}{y''}{1}\\
+ * map_x(u,v) \leftarrow x''' f_x + c_x \\
+ * map_y(u,v) \leftarrow y''' f_y + c_y
+ * \end{array}
+ * \)
+ * where \((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]]]])\)
+ * are the distortion coefficients.
+ *
+ * In case of a stereo camera, this function is called twice: once for each camera head, after
+ * #stereoRectify, which in its turn is called after #stereoCalibrate. But if the stereo camera
+ * was not calibrated, it is still possible to compute the rectification transformations directly from
+ * the fundamental matrix using #stereoRectifyUncalibrated. For each camera, the function computes
+ * homography H as the rectification transformation in a pixel domain, not a rotation matrix R in 3D
+ * space. R can be computed from H as
+ * \(\texttt{R} = \texttt{cameraMatrix} ^{-1} \cdot \texttt{H} \cdot \texttt{cameraMatrix}\)
+ * where cameraMatrix can be chosen arbitrarily.
+ *
+ * @param cameraMatrix Input camera matrix \(A=\vecthreethree{f_x}{0}{c_x}{0}{f_y}{c_y}{0}{0}{1}\) .
+ * @param distCoeffs Input vector of distortion coefficients
+ * \((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]]]])\)
+ * of 4, 5, 8, 12 or 14 elements. If the vector is NULL/empty, the zero distortion coefficients are assumed.
+ * @param R Optional rectification transformation in the object space (3x3 matrix). R1 or R2 ,
+ * computed by #stereoRectify can be passed here. If the matrix is empty, the identity transformation
+ * is assumed. In #initUndistortRectifyMap R assumed to be an identity matrix.
+ * @param newCameraMatrix New camera matrix \(A'=\vecthreethree{f_x'}{0}{c_x'}{0}{f_y'}{c_y'}{0}{0}{1}\).
+ * @param size Undistorted image size.
+ * @param m1type Type of the first output map that can be CV_32FC1, CV_32FC2 or CV_16SC2, see #convertMaps
+ * @param map1 The first output map.
+ * @param map2 The second output map.
+ */
+ public static void initUndistortRectifyMap(Mat cameraMatrix, Mat distCoeffs, Mat R, Mat newCameraMatrix, Size size, int m1type, Mat map1, Mat map2) {
+ initUndistortRectifyMap_0(cameraMatrix.nativeObj, distCoeffs.nativeObj, R.nativeObj, newCameraMatrix.nativeObj, size.width, size.height, m1type, map1.nativeObj, map2.nativeObj);
+ }
+
+
+ //
+ // C++: void cv::initInverseRectificationMap(Mat cameraMatrix, Mat distCoeffs, Mat R, Mat newCameraMatrix, Size size, int m1type, Mat& map1, Mat& map2)
+ //
+
+ /**
+ * Computes the projection and inverse-rectification transformation map. In essense, this is the inverse of
+ * #initUndistortRectifyMap to accomodate stereo-rectification of projectors ('inverse-cameras') in projector-camera pairs.
+ *
+ * The function computes the joint projection and inverse rectification transformation and represents the
+ * result in the form of maps for #remap. The projected image looks like a distorted version of the original which,
+ * once projected by a projector, should visually match the original. In case of a monocular camera, newCameraMatrix
+ * is usually equal to cameraMatrix, or it can be computed by
+ * #getOptimalNewCameraMatrix for a better control over scaling. In case of a projector-camera pair,
+ * newCameraMatrix is normally set to P1 or P2 computed by #stereoRectify .
+ *
+ * The projector is oriented differently in the coordinate space, according to R. In case of projector-camera pairs,
+ * this helps align the projector (in the same manner as #initUndistortRectifyMap for the camera) to create a stereo-rectified pair. This
+ * allows epipolar lines on both images to become horizontal and have the same y-coordinate (in case of a horizontally aligned projector-camera pair).
+ *
+ * The function builds the maps for the inverse mapping algorithm that is used by #remap. That
+ * is, for each pixel \((u, v)\) in the destination (projected and inverse-rectified) image, the function
+ * computes the corresponding coordinates in the source image (that is, in the original digital image). The following process is applied:
+ *
+ * \(
+ * \begin{array}{l}
+ * \text{newCameraMatrix}\\
+ * x \leftarrow (u - {c'}_x)/{f'}_x \\
+ * y \leftarrow (v - {c'}_y)/{f'}_y \\
+ *
+ * \\\text{Undistortion}
+ * \\\scriptsize{\textit{though equation shown is for radial undistortion, function implements cv::undistortPoints()}}\\
+ * r^2 \leftarrow x^2 + y^2 \\
+ * \theta \leftarrow \frac{1 + k_1 r^2 + k_2 r^4 + k_3 r^6}{1 + k_4 r^2 + k_5 r^4 + k_6 r^6}\\
+ * x' \leftarrow \frac{x}{\theta} \\
+ * y' \leftarrow \frac{y}{\theta} \\
+ *
+ * \\\text{Rectification}\\
+ * {[X\,Y\,W]} ^T \leftarrow R*[x' \, y' \, 1]^T \\
+ * x'' \leftarrow X/W \\
+ * y'' \leftarrow Y/W \\
+ *
+ * \\\text{cameraMatrix}\\
+ * map_x(u,v) \leftarrow x'' f_x + c_x \\
+ * map_y(u,v) \leftarrow y'' f_y + c_y
+ * \end{array}
+ * \)
+ * where \((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]]]])\)
+ * are the distortion coefficients vector distCoeffs.
+ *
+ * In case of a stereo-rectified projector-camera pair, this function is called for the projector while #initUndistortRectifyMap is called for the camera head.
+ * This is done after #stereoRectify, which in turn is called after #stereoCalibrate. If the projector-camera pair
+ * is not calibrated, it is still possible to compute the rectification transformations directly from
+ * the fundamental matrix using #stereoRectifyUncalibrated. For the projector and camera, the function computes
+ * homography H as the rectification transformation in a pixel domain, not a rotation matrix R in 3D
+ * space. R can be computed from H as
+ * \(\texttt{R} = \texttt{cameraMatrix} ^{-1} \cdot \texttt{H} \cdot \texttt{cameraMatrix}\)
+ * where cameraMatrix can be chosen arbitrarily.
+ *
+ * @param cameraMatrix Input camera matrix \(A=\vecthreethree{f_x}{0}{c_x}{0}{f_y}{c_y}{0}{0}{1}\) .
+ * @param distCoeffs Input vector of distortion coefficients
+ * \((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]]]])\)
+ * of 4, 5, 8, 12 or 14 elements. If the vector is NULL/empty, the zero distortion coefficients are assumed.
+ * @param R Optional rectification transformation in the object space (3x3 matrix). R1 or R2,
+ * computed by #stereoRectify can be passed here. If the matrix is empty, the identity transformation
+ * is assumed.
+ * @param newCameraMatrix New camera matrix \(A'=\vecthreethree{f_x'}{0}{c_x'}{0}{f_y'}{c_y'}{0}{0}{1}\).
+ * @param size Distorted image size.
+ * @param m1type Type of the first output map. Can be CV_32FC1, CV_32FC2 or CV_16SC2, see #convertMaps
+ * @param map1 The first output map for #remap.
+ * @param map2 The second output map for #remap.
+ */
+ public static void initInverseRectificationMap(Mat cameraMatrix, Mat distCoeffs, Mat R, Mat newCameraMatrix, Size size, int m1type, Mat map1, Mat map2) {
+ initInverseRectificationMap_0(cameraMatrix.nativeObj, distCoeffs.nativeObj, R.nativeObj, newCameraMatrix.nativeObj, size.width, size.height, m1type, map1.nativeObj, map2.nativeObj);
+ }
+
+
+ //
+ // C++: Mat cv::getDefaultNewCameraMatrix(Mat cameraMatrix, Size imgsize = Size(), bool centerPrincipalPoint = false)
+ //
+
+ /**
+ * Returns the default new camera matrix.
+ *
+ * The function returns the camera matrix that is either an exact copy of the input cameraMatrix (when
+ * centerPrinicipalPoint=false ), or the modified one (when centerPrincipalPoint=true).
+ *
+ * In the latter case, the new camera matrix will be:
+ *
+ * \(\begin{bmatrix} f_x && 0 && ( \texttt{imgSize.width} -1)*0.5 \\ 0 && f_y && ( \texttt{imgSize.height} -1)*0.5 \\ 0 && 0 && 1 \end{bmatrix} ,\)
+ *
+ * where \(f_x\) and \(f_y\) are \((0,0)\) and \((1,1)\) elements of cameraMatrix, respectively.
+ *
+ * By default, the undistortion functions in OpenCV (see #initUndistortRectifyMap, #undistort) do not
+ * move the principal point. However, when you work with stereo, it is important to move the principal
+ * points in both views to the same y-coordinate (which is required by most of stereo correspondence
+ * algorithms), and may be to the same x-coordinate too. So, you can form the new camera matrix for
+ * each view where the principal points are located at the center.
+ *
+ * @param cameraMatrix Input camera matrix.
+ * @param imgsize Camera view image size in pixels.
+ * @param centerPrincipalPoint Location of the principal point in the new camera matrix. The
+ * parameter indicates whether this location should be at the image center or not.
+ * @return automatically generated
+ */
+ public static Mat getDefaultNewCameraMatrix(Mat cameraMatrix, Size imgsize, boolean centerPrincipalPoint) {
+ return new Mat(getDefaultNewCameraMatrix_0(cameraMatrix.nativeObj, imgsize.width, imgsize.height, centerPrincipalPoint));
+ }
+
+ /**
+ * Returns the default new camera matrix.
+ *
+ * The function returns the camera matrix that is either an exact copy of the input cameraMatrix (when
+ * centerPrinicipalPoint=false ), or the modified one (when centerPrincipalPoint=true).
+ *
+ * In the latter case, the new camera matrix will be:
+ *
+ * \(\begin{bmatrix} f_x && 0 && ( \texttt{imgSize.width} -1)*0.5 \\ 0 && f_y && ( \texttt{imgSize.height} -1)*0.5 \\ 0 && 0 && 1 \end{bmatrix} ,\)
+ *
+ * where \(f_x\) and \(f_y\) are \((0,0)\) and \((1,1)\) elements of cameraMatrix, respectively.
+ *
+ * By default, the undistortion functions in OpenCV (see #initUndistortRectifyMap, #undistort) do not
+ * move the principal point. However, when you work with stereo, it is important to move the principal
+ * points in both views to the same y-coordinate (which is required by most of stereo correspondence
+ * algorithms), and may be to the same x-coordinate too. So, you can form the new camera matrix for
+ * each view where the principal points are located at the center.
+ *
+ * @param cameraMatrix Input camera matrix.
+ * @param imgsize Camera view image size in pixels.
+ * parameter indicates whether this location should be at the image center or not.
+ * @return automatically generated
+ */
+ public static Mat getDefaultNewCameraMatrix(Mat cameraMatrix, Size imgsize) {
+ return new Mat(getDefaultNewCameraMatrix_1(cameraMatrix.nativeObj, imgsize.width, imgsize.height));
+ }
+
+ /**
+ * Returns the default new camera matrix.
+ *
+ * The function returns the camera matrix that is either an exact copy of the input cameraMatrix (when
+ * centerPrinicipalPoint=false ), or the modified one (when centerPrincipalPoint=true).
+ *
+ * In the latter case, the new camera matrix will be:
+ *
+ * \(\begin{bmatrix} f_x && 0 && ( \texttt{imgSize.width} -1)*0.5 \\ 0 && f_y && ( \texttt{imgSize.height} -1)*0.5 \\ 0 && 0 && 1 \end{bmatrix} ,\)
+ *
+ * where \(f_x\) and \(f_y\) are \((0,0)\) and \((1,1)\) elements of cameraMatrix, respectively.
+ *
+ * By default, the undistortion functions in OpenCV (see #initUndistortRectifyMap, #undistort) do not
+ * move the principal point. However, when you work with stereo, it is important to move the principal
+ * points in both views to the same y-coordinate (which is required by most of stereo correspondence
+ * algorithms), and may be to the same x-coordinate too. So, you can form the new camera matrix for
+ * each view where the principal points are located at the center.
+ *
+ * @param cameraMatrix Input camera matrix.
+ * parameter indicates whether this location should be at the image center or not.
+ * @return automatically generated
+ */
+ public static Mat getDefaultNewCameraMatrix(Mat cameraMatrix) {
+ return new Mat(getDefaultNewCameraMatrix_2(cameraMatrix.nativeObj));
+ }
+
+
+ //
+ // C++: void cv::undistortPoints(vector_Point2f src, vector_Point2f& dst, Mat cameraMatrix, Mat distCoeffs, Mat R = Mat(), Mat P = Mat())
+ //
+
+ /**
+ * Computes the ideal point coordinates from the observed point coordinates.
+ *
+ * The function is similar to #undistort and #initUndistortRectifyMap but it operates on a
+ * sparse set of points instead of a raster image. Also the function performs a reverse transformation
+ * to #projectPoints. In case of a 3D object, it does not reconstruct its 3D coordinates, but for a
+ * planar object, it does, up to a translation vector, if the proper R is specified.
+ *
+ * For each observed point coordinate \((u, v)\) the function computes:
+ * \(
+ * \begin{array}{l}
+ * x^{"} \leftarrow (u - c_x)/f_x \\
+ * y^{"} \leftarrow (v - c_y)/f_y \\
+ * (x',y') = undistort(x^{"},y^{"}, \texttt{distCoeffs}) \\
+ * {[X\,Y\,W]} ^T \leftarrow R*[x' \, y' \, 1]^T \\
+ * x \leftarrow X/W \\
+ * y \leftarrow Y/W \\
+ * \text{only performed if P is specified:} \\
+ * u' \leftarrow x {f'}_x + {c'}_x \\
+ * v' \leftarrow y {f'}_y + {c'}_y
+ * \end{array}
+ * \)
+ *
+ * where *undistort* is an approximate iterative algorithm that estimates the normalized original
+ * point coordinates out of the normalized distorted point coordinates ("normalized" means that the
+ * coordinates do not depend on the camera matrix).
+ *
+ * The function can be used for both a stereo camera head or a monocular camera (when R is empty).
+ * @param src Observed point coordinates, 2xN/Nx2 1-channel or 1xN/Nx1 2-channel (CV_32FC2 or CV_64FC2) (or
+ * vector<Point2f> ).
+ * @param dst Output ideal point coordinates (1xN/Nx1 2-channel or vector<Point2f> ) after undistortion and reverse perspective
+ * transformation. If matrix P is identity or omitted, dst will contain normalized point coordinates.
+ * @param cameraMatrix Camera matrix \(\vecthreethree{f_x}{0}{c_x}{0}{f_y}{c_y}{0}{0}{1}\) .
+ * @param distCoeffs Input vector of distortion coefficients
+ * \((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]]]])\)
+ * of 4, 5, 8, 12 or 14 elements. If the vector is NULL/empty, the zero distortion coefficients are assumed.
+ * @param R Rectification transformation in the object space (3x3 matrix). R1 or R2 computed by
+ * #stereoRectify can be passed here. If the matrix is empty, the identity transformation is used.
+ * @param P New camera matrix (3x3) or new projection matrix (3x4) \(\begin{bmatrix} {f'}_x & 0 & {c'}_x & t_x \\ 0 & {f'}_y & {c'}_y & t_y \\ 0 & 0 & 1 & t_z \end{bmatrix}\). P1 or P2 computed by
+ * #stereoRectify can be passed here. If the matrix is empty, the identity new camera matrix is used.
+ */
+ public static void undistortPoints(MatOfPoint2f src, MatOfPoint2f dst, Mat cameraMatrix, Mat distCoeffs, Mat R, Mat P) {
+ Mat src_mat = src;
+ Mat dst_mat = dst;
+ undistortPoints_0(src_mat.nativeObj, dst_mat.nativeObj, cameraMatrix.nativeObj, distCoeffs.nativeObj, R.nativeObj, P.nativeObj);
+ }
+
+ /**
+ * Computes the ideal point coordinates from the observed point coordinates.
+ *
+ * The function is similar to #undistort and #initUndistortRectifyMap but it operates on a
+ * sparse set of points instead of a raster image. Also the function performs a reverse transformation
+ * to #projectPoints. In case of a 3D object, it does not reconstruct its 3D coordinates, but for a
+ * planar object, it does, up to a translation vector, if the proper R is specified.
+ *
+ * For each observed point coordinate \((u, v)\) the function computes:
+ * \(
+ * \begin{array}{l}
+ * x^{"} \leftarrow (u - c_x)/f_x \\
+ * y^{"} \leftarrow (v - c_y)/f_y \\
+ * (x',y') = undistort(x^{"},y^{"}, \texttt{distCoeffs}) \\
+ * {[X\,Y\,W]} ^T \leftarrow R*[x' \, y' \, 1]^T \\
+ * x \leftarrow X/W \\
+ * y \leftarrow Y/W \\
+ * \text{only performed if P is specified:} \\
+ * u' \leftarrow x {f'}_x + {c'}_x \\
+ * v' \leftarrow y {f'}_y + {c'}_y
+ * \end{array}
+ * \)
+ *
+ * where *undistort* is an approximate iterative algorithm that estimates the normalized original
+ * point coordinates out of the normalized distorted point coordinates ("normalized" means that the
+ * coordinates do not depend on the camera matrix).
+ *
+ * The function can be used for both a stereo camera head or a monocular camera (when R is empty).
+ * @param src Observed point coordinates, 2xN/Nx2 1-channel or 1xN/Nx1 2-channel (CV_32FC2 or CV_64FC2) (or
+ * vector<Point2f> ).
+ * @param dst Output ideal point coordinates (1xN/Nx1 2-channel or vector<Point2f> ) after undistortion and reverse perspective
+ * transformation. If matrix P is identity or omitted, dst will contain normalized point coordinates.
+ * @param cameraMatrix Camera matrix \(\vecthreethree{f_x}{0}{c_x}{0}{f_y}{c_y}{0}{0}{1}\) .
+ * @param distCoeffs Input vector of distortion coefficients
+ * \((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]]]])\)
+ * of 4, 5, 8, 12 or 14 elements. If the vector is NULL/empty, the zero distortion coefficients are assumed.
+ * @param R Rectification transformation in the object space (3x3 matrix). R1 or R2 computed by
+ * #stereoRectify can be passed here. If the matrix is empty, the identity transformation is used.
+ * #stereoRectify can be passed here. If the matrix is empty, the identity new camera matrix is used.
+ */
+ public static void undistortPoints(MatOfPoint2f src, MatOfPoint2f dst, Mat cameraMatrix, Mat distCoeffs, Mat R) {
+ Mat src_mat = src;
+ Mat dst_mat = dst;
+ undistortPoints_1(src_mat.nativeObj, dst_mat.nativeObj, cameraMatrix.nativeObj, distCoeffs.nativeObj, R.nativeObj);
+ }
+
+ /**
+ * Computes the ideal point coordinates from the observed point coordinates.
+ *
+ * The function is similar to #undistort and #initUndistortRectifyMap but it operates on a
+ * sparse set of points instead of a raster image. Also the function performs a reverse transformation
+ * to #projectPoints. In case of a 3D object, it does not reconstruct its 3D coordinates, but for a
+ * planar object, it does, up to a translation vector, if the proper R is specified.
+ *
+ * For each observed point coordinate \((u, v)\) the function computes:
+ * \(
+ * \begin{array}{l}
+ * x^{"} \leftarrow (u - c_x)/f_x \\
+ * y^{"} \leftarrow (v - c_y)/f_y \\
+ * (x',y') = undistort(x^{"},y^{"}, \texttt{distCoeffs}) \\
+ * {[X\,Y\,W]} ^T \leftarrow R*[x' \, y' \, 1]^T \\
+ * x \leftarrow X/W \\
+ * y \leftarrow Y/W \\
+ * \text{only performed if P is specified:} \\
+ * u' \leftarrow x {f'}_x + {c'}_x \\
+ * v' \leftarrow y {f'}_y + {c'}_y
+ * \end{array}
+ * \)
+ *
+ * where *undistort* is an approximate iterative algorithm that estimates the normalized original
+ * point coordinates out of the normalized distorted point coordinates ("normalized" means that the
+ * coordinates do not depend on the camera matrix).
+ *
+ * The function can be used for both a stereo camera head or a monocular camera (when R is empty).
+ * @param src Observed point coordinates, 2xN/Nx2 1-channel or 1xN/Nx1 2-channel (CV_32FC2 or CV_64FC2) (or
+ * vector<Point2f> ).
+ * @param dst Output ideal point coordinates (1xN/Nx1 2-channel or vector<Point2f> ) after undistortion and reverse perspective
+ * transformation. If matrix P is identity or omitted, dst will contain normalized point coordinates.
+ * @param cameraMatrix Camera matrix \(\vecthreethree{f_x}{0}{c_x}{0}{f_y}{c_y}{0}{0}{1}\) .
+ * @param distCoeffs Input vector of distortion coefficients
+ * \((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]]]])\)
+ * of 4, 5, 8, 12 or 14 elements. If the vector is NULL/empty, the zero distortion coefficients are assumed.
+ * #stereoRectify can be passed here. If the matrix is empty, the identity transformation is used.
+ * #stereoRectify can be passed here. If the matrix is empty, the identity new camera matrix is used.
+ */
+ public static void undistortPoints(MatOfPoint2f src, MatOfPoint2f dst, Mat cameraMatrix, Mat distCoeffs) {
+ Mat src_mat = src;
+ Mat dst_mat = dst;
+ undistortPoints_2(src_mat.nativeObj, dst_mat.nativeObj, cameraMatrix.nativeObj, distCoeffs.nativeObj);
+ }
+
+
+ //
+ // C++: void cv::undistortPoints(Mat src, Mat& dst, Mat cameraMatrix, Mat distCoeffs, Mat R, Mat P, TermCriteria criteria)
+ //
+
+ /**
+ *
+ * Note: Default version of #undistortPoints does 5 iterations to compute undistorted points.
+ * @param src automatically generated
+ * @param dst automatically generated
+ * @param cameraMatrix automatically generated
+ * @param distCoeffs automatically generated
+ * @param R automatically generated
+ * @param P automatically generated
+ * @param criteria automatically generated
+ */
+ public static void undistortPointsIter(Mat src, Mat dst, Mat cameraMatrix, Mat distCoeffs, Mat R, Mat P, TermCriteria criteria) {
+ undistortPointsIter_0(src.nativeObj, dst.nativeObj, cameraMatrix.nativeObj, distCoeffs.nativeObj, R.nativeObj, P.nativeObj, criteria.type, criteria.maxCount, criteria.epsilon);
+ }
+
+
+ //
+ // C++: void cv::undistortImagePoints(Mat src, Mat& dst, Mat cameraMatrix, Mat distCoeffs, TermCriteria arg1 = TermCriteria(TermCriteria::MAX_ITER + TermCriteria::EPS, 5, 0.01))
+ //
+
+ /**
+ * Compute undistorted image points position
+ *
+ * @param src Observed points position, 2xN/Nx2 1-channel or 1xN/Nx1 2-channel (CV_32FC2 or
+ * CV_64FC2) (or vector<Point2f> ).
+ * @param dst Output undistorted points position (1xN/Nx1 2-channel or vector<Point2f> ).
+ * @param cameraMatrix Camera matrix \(\vecthreethree{f_x}{0}{c_x}{0}{f_y}{c_y}{0}{0}{1}\) .
+ * @param distCoeffs Distortion coefficients
+ * @param arg1 automatically generated
+ */
+ public static void undistortImagePoints(Mat src, Mat dst, Mat cameraMatrix, Mat distCoeffs, TermCriteria arg1) {
+ undistortImagePoints_0(src.nativeObj, dst.nativeObj, cameraMatrix.nativeObj, distCoeffs.nativeObj, arg1.type, arg1.maxCount, arg1.epsilon);
+ }
+
+ /**
+ * Compute undistorted image points position
+ *
+ * @param src Observed points position, 2xN/Nx2 1-channel or 1xN/Nx1 2-channel (CV_32FC2 or
+ * CV_64FC2) (or vector<Point2f> ).
+ * @param dst Output undistorted points position (1xN/Nx1 2-channel or vector<Point2f> ).
+ * @param cameraMatrix Camera matrix \(\vecthreethree{f_x}{0}{c_x}{0}{f_y}{c_y}{0}{0}{1}\) .
+ * @param distCoeffs Distortion coefficients
+ */
+ public static void undistortImagePoints(Mat src, Mat dst, Mat cameraMatrix, Mat distCoeffs) {
+ undistortImagePoints_1(src.nativeObj, dst.nativeObj, cameraMatrix.nativeObj, distCoeffs.nativeObj);
+ }
+
+
+ //
+ // C++: void cv::fisheye::projectPoints(Mat objectPoints, Mat& imagePoints, Mat rvec, Mat tvec, Mat K, Mat D, double alpha = 0, Mat& jacobian = Mat())
+ //
+
+ public static void fisheye_projectPoints(Mat objectPoints, Mat imagePoints, Mat rvec, Mat tvec, Mat K, Mat D, double alpha, Mat jacobian) {
+ fisheye_projectPoints_0(objectPoints.nativeObj, imagePoints.nativeObj, rvec.nativeObj, tvec.nativeObj, K.nativeObj, D.nativeObj, alpha, jacobian.nativeObj);
+ }
+
+ public static void fisheye_projectPoints(Mat objectPoints, Mat imagePoints, Mat rvec, Mat tvec, Mat K, Mat D, double alpha) {
+ fisheye_projectPoints_1(objectPoints.nativeObj, imagePoints.nativeObj, rvec.nativeObj, tvec.nativeObj, K.nativeObj, D.nativeObj, alpha);
+ }
+
+ public static void fisheye_projectPoints(Mat objectPoints, Mat imagePoints, Mat rvec, Mat tvec, Mat K, Mat D) {
+ fisheye_projectPoints_2(objectPoints.nativeObj, imagePoints.nativeObj, rvec.nativeObj, tvec.nativeObj, K.nativeObj, D.nativeObj);
+ }
+
+
+ //
+ // C++: void cv::fisheye::distortPoints(Mat undistorted, Mat& distorted, Mat K, Mat D, double alpha = 0)
+ //
+
+ /**
+ * Distorts 2D points using fisheye model.
+ *
+ * @param undistorted Array of object points, 1xN/Nx1 2-channel (or vector<Point2f> ), where N is
+ * the number of points in the view.
+ * @param K Camera intrinsic matrix \(cameramatrix{K}\).
+ * @param D Input vector of distortion coefficients \(\distcoeffsfisheye\).
+ * @param alpha The skew coefficient.
+ * @param distorted Output array of image points, 1xN/Nx1 2-channel, or vector<Point2f> .
+ *
+ * Note that the function assumes the camera intrinsic matrix of the undistorted points to be identity.
+ * This means if you want to distort image points you have to multiply them with \(K^{-1}\).
+ */
+ public static void fisheye_distortPoints(Mat undistorted, Mat distorted, Mat K, Mat D, double alpha) {
+ fisheye_distortPoints_0(undistorted.nativeObj, distorted.nativeObj, K.nativeObj, D.nativeObj, alpha);
+ }
+
+ /**
+ * Distorts 2D points using fisheye model.
+ *
+ * @param undistorted Array of object points, 1xN/Nx1 2-channel (or vector<Point2f> ), where N is
+ * the number of points in the view.
+ * @param K Camera intrinsic matrix \(cameramatrix{K}\).
+ * @param D Input vector of distortion coefficients \(\distcoeffsfisheye\).
+ * @param distorted Output array of image points, 1xN/Nx1 2-channel, or vector<Point2f> .
+ *
+ * Note that the function assumes the camera intrinsic matrix of the undistorted points to be identity.
+ * This means if you want to distort image points you have to multiply them with \(K^{-1}\).
+ */
+ public static void fisheye_distortPoints(Mat undistorted, Mat distorted, Mat K, Mat D) {
+ fisheye_distortPoints_1(undistorted.nativeObj, distorted.nativeObj, K.nativeObj, D.nativeObj);
+ }
+
+
+ //
+ // C++: void cv::fisheye::undistortPoints(Mat distorted, Mat& undistorted, Mat K, Mat D, Mat R = Mat(), Mat P = Mat(), TermCriteria criteria = TermCriteria(TermCriteria::MAX_ITER + TermCriteria::EPS, 10, 1e-8))
+ //
+
+ /**
+ * Undistorts 2D points using fisheye model
+ *
+ * @param distorted Array of object points, 1xN/Nx1 2-channel (or vector<Point2f> ), where N is the
+ * number of points in the view.
+ * @param K Camera intrinsic matrix \(cameramatrix{K}\).
+ * @param D Input vector of distortion coefficients \(\distcoeffsfisheye\).
+ * @param R Rectification transformation in the object space: 3x3 1-channel, or vector: 3x1/1x3
+ * 1-channel or 1x1 3-channel
+ * @param P New camera intrinsic matrix (3x3) or new projection matrix (3x4)
+ * @param criteria Termination criteria
+ * @param undistorted Output array of image points, 1xN/Nx1 2-channel, or vector<Point2f> .
+ */
+ public static void fisheye_undistortPoints(Mat distorted, Mat undistorted, Mat K, Mat D, Mat R, Mat P, TermCriteria criteria) {
+ fisheye_undistortPoints_0(distorted.nativeObj, undistorted.nativeObj, K.nativeObj, D.nativeObj, R.nativeObj, P.nativeObj, criteria.type, criteria.maxCount, criteria.epsilon);
+ }
+
+ /**
+ * Undistorts 2D points using fisheye model
+ *
+ * @param distorted Array of object points, 1xN/Nx1 2-channel (or vector<Point2f> ), where N is the
+ * number of points in the view.
+ * @param K Camera intrinsic matrix \(cameramatrix{K}\).
+ * @param D Input vector of distortion coefficients \(\distcoeffsfisheye\).
+ * @param R Rectification transformation in the object space: 3x3 1-channel, or vector: 3x1/1x3
+ * 1-channel or 1x1 3-channel
+ * @param P New camera intrinsic matrix (3x3) or new projection matrix (3x4)
+ * @param undistorted Output array of image points, 1xN/Nx1 2-channel, or vector<Point2f> .
+ */
+ public static void fisheye_undistortPoints(Mat distorted, Mat undistorted, Mat K, Mat D, Mat R, Mat P) {
+ fisheye_undistortPoints_1(distorted.nativeObj, undistorted.nativeObj, K.nativeObj, D.nativeObj, R.nativeObj, P.nativeObj);
+ }
+
+ /**
+ * Undistorts 2D points using fisheye model
+ *
+ * @param distorted Array of object points, 1xN/Nx1 2-channel (or vector<Point2f> ), where N is the
+ * number of points in the view.
+ * @param K Camera intrinsic matrix \(cameramatrix{K}\).
+ * @param D Input vector of distortion coefficients \(\distcoeffsfisheye\).
+ * @param R Rectification transformation in the object space: 3x3 1-channel, or vector: 3x1/1x3
+ * 1-channel or 1x1 3-channel
+ * @param undistorted Output array of image points, 1xN/Nx1 2-channel, or vector<Point2f> .
+ */
+ public static void fisheye_undistortPoints(Mat distorted, Mat undistorted, Mat K, Mat D, Mat R) {
+ fisheye_undistortPoints_2(distorted.nativeObj, undistorted.nativeObj, K.nativeObj, D.nativeObj, R.nativeObj);
+ }
+
+ /**
+ * Undistorts 2D points using fisheye model
+ *
+ * @param distorted Array of object points, 1xN/Nx1 2-channel (or vector<Point2f> ), where N is the
+ * number of points in the view.
+ * @param K Camera intrinsic matrix \(cameramatrix{K}\).
+ * @param D Input vector of distortion coefficients \(\distcoeffsfisheye\).
+ * 1-channel or 1x1 3-channel
+ * @param undistorted Output array of image points, 1xN/Nx1 2-channel, or vector<Point2f> .
+ */
+ public static void fisheye_undistortPoints(Mat distorted, Mat undistorted, Mat K, Mat D) {
+ fisheye_undistortPoints_3(distorted.nativeObj, undistorted.nativeObj, K.nativeObj, D.nativeObj);
+ }
+
+
+ //
+ // C++: void cv::fisheye::initUndistortRectifyMap(Mat K, Mat D, Mat R, Mat P, Size size, int m1type, Mat& map1, Mat& map2)
+ //
+
+ /**
+ * Computes undistortion and rectification maps for image transform by #remap. If D is empty zero
+ * distortion is used, if R or P is empty identity matrixes are used.
+ *
+ * @param K Camera intrinsic matrix \(cameramatrix{K}\).
+ * @param D Input vector of distortion coefficients \(\distcoeffsfisheye\).
+ * @param R Rectification transformation in the object space: 3x3 1-channel, or vector: 3x1/1x3
+ * 1-channel or 1x1 3-channel
+ * @param P New camera intrinsic 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.
+ */
+ public static void fisheye_initUndistortRectifyMap(Mat K, Mat D, Mat R, Mat P, Size size, int m1type, Mat map1, Mat map2) {
+ fisheye_initUndistortRectifyMap_0(K.nativeObj, D.nativeObj, R.nativeObj, P.nativeObj, size.width, size.height, m1type, map1.nativeObj, map2.nativeObj);
+ }
+
+
+ //
+ // C++: void cv::fisheye::undistortImage(Mat distorted, Mat& undistorted, Mat K, Mat D, Mat Knew = cv::Mat(), Size new_size = Size())
+ //
+
+ /**
+ * Transforms an image to compensate for fisheye lens distortion.
+ *
+ * @param distorted image with fisheye lens distortion.
+ * @param undistorted Output image with compensated fisheye lens distortion.
+ * @param K Camera intrinsic matrix \(cameramatrix{K}\).
+ * @param D Input vector of distortion coefficients \(\distcoeffsfisheye\).
+ * @param Knew Camera intrinsic matrix of the distorted image. By default, it is the identity matrix but you
+ * may additionally scale and shift the result by using a different matrix.
+ * @param new_size the new size
+ *
+ * The function transforms an image to compensate radial and tangential lens distortion.
+ *
+ * The function is simply a combination of #fisheye::initUndistortRectifyMap (with unity R ) and #remap
+ * (with bilinear interpolation). See the former function for details of the transformation being
+ * performed.
+ *
+ * See below the results of undistortImage.
+ *
+ *
+ * a\) result of undistort of perspective camera model (all possible coefficients (k_1, k_2, k_3,
+ * k_4, k_5, k_6) of distortion were optimized under calibration)
+ *
+ *
+ * b\) result of #fisheye::undistortImage of fisheye camera model (all possible coefficients (k_1, k_2,
+ * k_3, k_4) of fisheye distortion were optimized under calibration)
+ *
+ *
+ * c\) original image was captured with fisheye lens
+ *
+ *
+ *
+ * Pictures a) and b) almost the same. But if we consider points of image located far from the center
+ * of image, we can notice that on image a) these points are distorted.
+ *
+ *
+ *
+ * 
+ */
+ public static void fisheye_undistortImage(Mat distorted, Mat undistorted, Mat K, Mat D, Mat Knew, Size new_size) {
+ fisheye_undistortImage_0(distorted.nativeObj, undistorted.nativeObj, K.nativeObj, D.nativeObj, Knew.nativeObj, new_size.width, new_size.height);
+ }
+
+ /**
+ * Transforms an image to compensate for fisheye lens distortion.
+ *
+ * @param distorted image with fisheye lens distortion.
+ * @param undistorted Output image with compensated fisheye lens distortion.
+ * @param K Camera intrinsic matrix \(cameramatrix{K}\).
+ * @param D Input vector of distortion coefficients \(\distcoeffsfisheye\).
+ * @param Knew Camera intrinsic matrix of the distorted image. By default, it is the identity matrix but you
+ * may additionally scale and shift the result by using a different matrix.
+ *
+ * The function transforms an image to compensate radial and tangential lens distortion.
+ *
+ * The function is simply a combination of #fisheye::initUndistortRectifyMap (with unity R ) and #remap
+ * (with bilinear interpolation). See the former function for details of the transformation being
+ * performed.
+ *
+ * See below the results of undistortImage.
+ *
+ *
+ * a\) result of undistort of perspective camera model (all possible coefficients (k_1, k_2, k_3,
+ * k_4, k_5, k_6) of distortion were optimized under calibration)
+ *
+ *
+ * b\) result of #fisheye::undistortImage of fisheye camera model (all possible coefficients (k_1, k_2,
+ * k_3, k_4) of fisheye distortion were optimized under calibration)
+ *
+ *
+ * c\) original image was captured with fisheye lens
+ *
+ *
+ *
+ * Pictures a) and b) almost the same. But if we consider points of image located far from the center
+ * of image, we can notice that on image a) these points are distorted.
+ *
+ *
+ *
+ * 
+ */
+ public static void fisheye_undistortImage(Mat distorted, Mat undistorted, Mat K, Mat D, Mat Knew) {
+ fisheye_undistortImage_1(distorted.nativeObj, undistorted.nativeObj, K.nativeObj, D.nativeObj, Knew.nativeObj);
+ }
+
+ /**
+ * Transforms an image to compensate for fisheye lens distortion.
+ *
+ * @param distorted image with fisheye lens distortion.
+ * @param undistorted Output image with compensated fisheye lens distortion.
+ * @param K Camera intrinsic matrix \(cameramatrix{K}\).
+ * @param D Input vector of distortion coefficients \(\distcoeffsfisheye\).
+ * may additionally scale and shift the result by using a different matrix.
+ *
+ * The function transforms an image to compensate radial and tangential lens distortion.
+ *
+ * The function is simply a combination of #fisheye::initUndistortRectifyMap (with unity R ) and #remap
+ * (with bilinear interpolation). See the former function for details of the transformation being
+ * performed.
+ *
+ * See below the results of undistortImage.
+ *
+ *
+ * a\) result of undistort of perspective camera model (all possible coefficients (k_1, k_2, k_3,
+ * k_4, k_5, k_6) of distortion were optimized under calibration)
+ *
+ *
+ * b\) result of #fisheye::undistortImage of fisheye camera model (all possible coefficients (k_1, k_2,
+ * k_3, k_4) of fisheye distortion were optimized under calibration)
+ *
+ *
+ * c\) original image was captured with fisheye lens
+ *
+ *
+ *
+ * Pictures a) and b) almost the same. But if we consider points of image located far from the center
+ * of image, we can notice that on image a) these points are distorted.
+ *
+ *
+ *
+ * 
+ */
+ public static void fisheye_undistortImage(Mat distorted, Mat undistorted, Mat K, Mat D) {
+ fisheye_undistortImage_2(distorted.nativeObj, undistorted.nativeObj, K.nativeObj, D.nativeObj);
+ }
+
+
+ //
+ // C++: void cv::fisheye::estimateNewCameraMatrixForUndistortRectify(Mat K, Mat D, Size image_size, Mat R, Mat& P, double balance = 0.0, Size new_size = Size(), double fov_scale = 1.0)
+ //
+
+ /**
+ * Estimates new camera intrinsic matrix for undistortion or rectification.
+ *
+ * @param K Camera intrinsic matrix \(cameramatrix{K}\).
+ * @param image_size Size of the image
+ * @param D Input vector of distortion coefficients \(\distcoeffsfisheye\).
+ * @param R Rectification transformation in the object space: 3x3 1-channel, or vector: 3x1/1x3
+ * 1-channel or 1x1 3-channel
+ * @param P New camera intrinsic matrix (3x3) or new projection matrix (3x4)
+ * @param balance Sets the new focal length in range between the min focal length and the max focal
+ * length. Balance is in range of [0, 1].
+ * @param new_size the new size
+ * @param fov_scale Divisor for new focal length.
+ */
+ public static void fisheye_estimateNewCameraMatrixForUndistortRectify(Mat K, Mat D, Size image_size, Mat R, Mat P, double balance, Size new_size, double fov_scale) {
+ fisheye_estimateNewCameraMatrixForUndistortRectify_0(K.nativeObj, D.nativeObj, image_size.width, image_size.height, R.nativeObj, P.nativeObj, balance, new_size.width, new_size.height, fov_scale);
+ }
+
+ /**
+ * Estimates new camera intrinsic matrix for undistortion or rectification.
+ *
+ * @param K Camera intrinsic matrix \(cameramatrix{K}\).
+ * @param image_size Size of the image
+ * @param D Input vector of distortion coefficients \(\distcoeffsfisheye\).
+ * @param R Rectification transformation in the object space: 3x3 1-channel, or vector: 3x1/1x3
+ * 1-channel or 1x1 3-channel
+ * @param P New camera intrinsic matrix (3x3) or new projection matrix (3x4)
+ * @param balance Sets the new focal length in range between the min focal length and the max focal
+ * length. Balance is in range of [0, 1].
+ * @param new_size the new size
+ */
+ public static void fisheye_estimateNewCameraMatrixForUndistortRectify(Mat K, Mat D, Size image_size, Mat R, Mat P, double balance, Size new_size) {
+ fisheye_estimateNewCameraMatrixForUndistortRectify_1(K.nativeObj, D.nativeObj, image_size.width, image_size.height, R.nativeObj, P.nativeObj, balance, new_size.width, new_size.height);
+ }
+
+ /**
+ * Estimates new camera intrinsic matrix for undistortion or rectification.
+ *
+ * @param K Camera intrinsic matrix \(cameramatrix{K}\).
+ * @param image_size Size of the image
+ * @param D Input vector of distortion coefficients \(\distcoeffsfisheye\).
+ * @param R Rectification transformation in the object space: 3x3 1-channel, or vector: 3x1/1x3
+ * 1-channel or 1x1 3-channel
+ * @param P New camera intrinsic matrix (3x3) or new projection matrix (3x4)
+ * @param balance Sets the new focal length in range between the min focal length and the max focal
+ * length. Balance is in range of [0, 1].
+ */
+ public static void fisheye_estimateNewCameraMatrixForUndistortRectify(Mat K, Mat D, Size image_size, Mat R, Mat P, double balance) {
+ fisheye_estimateNewCameraMatrixForUndistortRectify_2(K.nativeObj, D.nativeObj, image_size.width, image_size.height, R.nativeObj, P.nativeObj, balance);
+ }
+
+ /**
+ * Estimates new camera intrinsic matrix for undistortion or rectification.
+ *
+ * @param K Camera intrinsic matrix \(cameramatrix{K}\).
+ * @param image_size Size of the image
+ * @param D Input vector of distortion coefficients \(\distcoeffsfisheye\).
+ * @param R Rectification transformation in the object space: 3x3 1-channel, or vector: 3x1/1x3
+ * 1-channel or 1x1 3-channel
+ * @param P New camera intrinsic matrix (3x3) or new projection matrix (3x4)
+ * length. Balance is in range of [0, 1].
+ */
+ public static void fisheye_estimateNewCameraMatrixForUndistortRectify(Mat K, Mat D, Size image_size, Mat R, Mat P) {
+ fisheye_estimateNewCameraMatrixForUndistortRectify_3(K.nativeObj, D.nativeObj, image_size.width, image_size.height, R.nativeObj, P.nativeObj);
+ }
+
+
+ //
+ // C++: double cv::fisheye::calibrate(vector_Mat objectPoints, vector_Mat imagePoints, Size image_size, Mat& K, Mat& D, vector_Mat& rvecs, vector_Mat& tvecs, int flags = 0, TermCriteria criteria = TermCriteria(TermCriteria::COUNT + TermCriteria::EPS, 100, DBL_EPSILON))
+ //
+
+ /**
+ * Performs camera calibration
+ *
+ * @param objectPoints vector of vectors of calibration pattern points in the calibration pattern
+ * coordinate space.
+ * @param imagePoints vector of vectors of the projections of calibration pattern points.
+ * imagePoints.size() and objectPoints.size() and imagePoints[i].size() must be equal to
+ * objectPoints[i].size() for each i.
+ * @param image_size Size of the image used only to initialize the camera intrinsic matrix.
+ * @param K Output 3x3 floating-point camera intrinsic matrix
+ * \(\cameramatrix{A}\) . If
+ * REF: fisheye::CALIB_USE_INTRINSIC_GUESS is specified, some or all of fx, fy, cx, cy must be
+ * initialized before calling the function.
+ * @param D Output vector of distortion coefficients \(\distcoeffsfisheye\).
+ * @param rvecs Output vector of rotation vectors (see Rodrigues ) estimated for each pattern view.
+ * That is, each k-th rotation vector together with the corresponding k-th translation vector (see
+ * the next output parameter description) brings the calibration pattern from the model coordinate
+ * space (in which object points are specified) to the world coordinate space, that is, a real
+ * position of the calibration pattern in the k-th pattern view (k=0.. *M* -1).
+ * @param tvecs Output vector of translation vectors estimated for each pattern view.
+ * @param flags Different flags that may be zero or a combination of the following values:
+ *
+ *
+ * REF: fisheye::CALIB_USE_INTRINSIC_GUESS cameraMatrix contains valid initial values of
+ * fx, fy, cx, cy that are optimized further. Otherwise, (cx, cy) is initially set to the image
+ * center ( imageSize is used), and focal distances are computed in a least-squares fashion.
+ *
+ *
+ * REF: fisheye::CALIB_RECOMPUTE_EXTRINSIC Extrinsic will be recomputed after each iteration
+ * of intrinsic optimization.
+ *
+ *
+ * REF: fisheye::CALIB_CHECK_COND The functions will check validity of condition number.
+ *
+ *
+ * REF: fisheye::CALIB_FIX_SKEW Skew coefficient (alpha) is set to zero and stay zero.
+ *
+ *
+ * REF: fisheye::CALIB_FIX_K1,..., REF: fisheye::CALIB_FIX_K4 Selected distortion coefficients
+ * are set to zeros and stay zero.
+ *
+ *
+ * REF: fisheye::CALIB_FIX_PRINCIPAL_POINT The principal point is not changed during the global
+ * optimization. It stays at the center or at a different location specified when REF: fisheye::CALIB_USE_INTRINSIC_GUESS is set too.
+ *
+ *
+ * REF: fisheye::CALIB_FIX_FOCAL_LENGTH The focal length is not changed during the global
+ * optimization. It is the \(max(width,height)/\pi\) or the provided \(f_x\), \(f_y\) when REF: fisheye::CALIB_USE_INTRINSIC_GUESS is set too.
+ *
+ *
+ * @param criteria Termination criteria for the iterative optimization algorithm.
+ * @return automatically generated
+ */
+ public static double fisheye_calibrate(List objectPoints, List imagePoints, Size image_size, Mat K, Mat D, List rvecs, List tvecs, int flags, TermCriteria criteria) {
+ Mat objectPoints_mat = Converters.vector_Mat_to_Mat(objectPoints);
+ Mat imagePoints_mat = Converters.vector_Mat_to_Mat(imagePoints);
+ Mat rvecs_mat = new Mat();
+ Mat tvecs_mat = new Mat();
+ double retVal = fisheye_calibrate_0(objectPoints_mat.nativeObj, imagePoints_mat.nativeObj, image_size.width, image_size.height, K.nativeObj, D.nativeObj, rvecs_mat.nativeObj, tvecs_mat.nativeObj, flags, criteria.type, criteria.maxCount, criteria.epsilon);
+ Converters.Mat_to_vector_Mat(rvecs_mat, rvecs);
+ rvecs_mat.release();
+ Converters.Mat_to_vector_Mat(tvecs_mat, tvecs);
+ tvecs_mat.release();
+ return retVal;
+ }
+
+ /**
+ * Performs camera calibration
+ *
+ * @param objectPoints vector of vectors of calibration pattern points in the calibration pattern
+ * coordinate space.
+ * @param imagePoints vector of vectors of the projections of calibration pattern points.
+ * imagePoints.size() and objectPoints.size() and imagePoints[i].size() must be equal to
+ * objectPoints[i].size() for each i.
+ * @param image_size Size of the image used only to initialize the camera intrinsic matrix.
+ * @param K Output 3x3 floating-point camera intrinsic matrix
+ * \(\cameramatrix{A}\) . If
+ * REF: fisheye::CALIB_USE_INTRINSIC_GUESS is specified, some or all of fx, fy, cx, cy must be
+ * initialized before calling the function.
+ * @param D Output vector of distortion coefficients \(\distcoeffsfisheye\).
+ * @param rvecs Output vector of rotation vectors (see Rodrigues ) estimated for each pattern view.
+ * That is, each k-th rotation vector together with the corresponding k-th translation vector (see
+ * the next output parameter description) brings the calibration pattern from the model coordinate
+ * space (in which object points are specified) to the world coordinate space, that is, a real
+ * position of the calibration pattern in the k-th pattern view (k=0.. *M* -1).
+ * @param tvecs Output vector of translation vectors estimated for each pattern view.
+ * @param flags Different flags that may be zero or a combination of the following values:
+ *
+ *
+ * REF: fisheye::CALIB_USE_INTRINSIC_GUESS cameraMatrix contains valid initial values of
+ * fx, fy, cx, cy that are optimized further. Otherwise, (cx, cy) is initially set to the image
+ * center ( imageSize is used), and focal distances are computed in a least-squares fashion.
+ *
+ *
+ * REF: fisheye::CALIB_RECOMPUTE_EXTRINSIC Extrinsic will be recomputed after each iteration
+ * of intrinsic optimization.
+ *
+ *
+ * REF: fisheye::CALIB_CHECK_COND The functions will check validity of condition number.
+ *
+ *
+ * REF: fisheye::CALIB_FIX_SKEW Skew coefficient (alpha) is set to zero and stay zero.
+ *
+ *
+ * REF: fisheye::CALIB_FIX_K1,..., REF: fisheye::CALIB_FIX_K4 Selected distortion coefficients
+ * are set to zeros and stay zero.
+ *
+ *
+ * REF: fisheye::CALIB_FIX_PRINCIPAL_POINT The principal point is not changed during the global
+ * optimization. It stays at the center or at a different location specified when REF: fisheye::CALIB_USE_INTRINSIC_GUESS is set too.
+ *
+ *
+ * REF: fisheye::CALIB_FIX_FOCAL_LENGTH The focal length is not changed during the global
+ * optimization. It is the \(max(width,height)/\pi\) or the provided \(f_x\), \(f_y\) when REF: fisheye::CALIB_USE_INTRINSIC_GUESS is set too.
+ *
+ *
+ * @return automatically generated
+ */
+ public static double fisheye_calibrate(List objectPoints, List imagePoints, Size image_size, Mat K, Mat D, List rvecs, List tvecs, int flags) {
+ Mat objectPoints_mat = Converters.vector_Mat_to_Mat(objectPoints);
+ Mat imagePoints_mat = Converters.vector_Mat_to_Mat(imagePoints);
+ Mat rvecs_mat = new Mat();
+ Mat tvecs_mat = new Mat();
+ double retVal = fisheye_calibrate_1(objectPoints_mat.nativeObj, imagePoints_mat.nativeObj, image_size.width, image_size.height, K.nativeObj, D.nativeObj, rvecs_mat.nativeObj, tvecs_mat.nativeObj, flags);
+ Converters.Mat_to_vector_Mat(rvecs_mat, rvecs);
+ rvecs_mat.release();
+ Converters.Mat_to_vector_Mat(tvecs_mat, tvecs);
+ tvecs_mat.release();
+ return retVal;
+ }
+
+ /**
+ * Performs camera calibration
+ *
+ * @param objectPoints vector of vectors of calibration pattern points in the calibration pattern
+ * coordinate space.
+ * @param imagePoints vector of vectors of the projections of calibration pattern points.
+ * imagePoints.size() and objectPoints.size() and imagePoints[i].size() must be equal to
+ * objectPoints[i].size() for each i.
+ * @param image_size Size of the image used only to initialize the camera intrinsic matrix.
+ * @param K Output 3x3 floating-point camera intrinsic matrix
+ * \(\cameramatrix{A}\) . If
+ * REF: fisheye::CALIB_USE_INTRINSIC_GUESS is specified, some or all of fx, fy, cx, cy must be
+ * initialized before calling the function.
+ * @param D Output vector of distortion coefficients \(\distcoeffsfisheye\).
+ * @param rvecs Output vector of rotation vectors (see Rodrigues ) estimated for each pattern view.
+ * That is, each k-th rotation vector together with the corresponding k-th translation vector (see
+ * the next output parameter description) brings the calibration pattern from the model coordinate
+ * space (in which object points are specified) to the world coordinate space, that is, a real
+ * position of the calibration pattern in the k-th pattern view (k=0.. *M* -1).
+ * @param tvecs Output vector of translation vectors estimated for each pattern view.
+ *
+ *
+ * REF: fisheye::CALIB_USE_INTRINSIC_GUESS cameraMatrix contains valid initial values of
+ * fx, fy, cx, cy that are optimized further. Otherwise, (cx, cy) is initially set to the image
+ * center ( imageSize is used), and focal distances are computed in a least-squares fashion.
+ *
+ *
+ * REF: fisheye::CALIB_RECOMPUTE_EXTRINSIC Extrinsic will be recomputed after each iteration
+ * of intrinsic optimization.
+ *
+ *
+ * REF: fisheye::CALIB_CHECK_COND The functions will check validity of condition number.
+ *
+ *
+ * REF: fisheye::CALIB_FIX_SKEW Skew coefficient (alpha) is set to zero and stay zero.
+ *
+ *
+ * REF: fisheye::CALIB_FIX_K1,..., REF: fisheye::CALIB_FIX_K4 Selected distortion coefficients
+ * are set to zeros and stay zero.
+ *
+ *
+ * REF: fisheye::CALIB_FIX_PRINCIPAL_POINT The principal point is not changed during the global
+ * optimization. It stays at the center or at a different location specified when REF: fisheye::CALIB_USE_INTRINSIC_GUESS is set too.
+ *
+ *
+ * REF: fisheye::CALIB_FIX_FOCAL_LENGTH The focal length is not changed during the global
+ * optimization. It is the \(max(width,height)/\pi\) or the provided \(f_x\), \(f_y\) when REF: fisheye::CALIB_USE_INTRINSIC_GUESS is set too.
+ *
+ *
+ * @return automatically generated
+ */
+ public static double fisheye_calibrate(List objectPoints, List imagePoints, Size image_size, Mat K, Mat D, List rvecs, List tvecs) {
+ Mat objectPoints_mat = Converters.vector_Mat_to_Mat(objectPoints);
+ Mat imagePoints_mat = Converters.vector_Mat_to_Mat(imagePoints);
+ Mat rvecs_mat = new Mat();
+ Mat tvecs_mat = new Mat();
+ double retVal = fisheye_calibrate_2(objectPoints_mat.nativeObj, imagePoints_mat.nativeObj, image_size.width, image_size.height, K.nativeObj, D.nativeObj, rvecs_mat.nativeObj, tvecs_mat.nativeObj);
+ Converters.Mat_to_vector_Mat(rvecs_mat, rvecs);
+ rvecs_mat.release();
+ Converters.Mat_to_vector_Mat(tvecs_mat, tvecs);
+ tvecs_mat.release();
+ return retVal;
+ }
+
+
+ //
+ // C++: void cv::fisheye::stereoRectify(Mat K1, Mat D1, Mat K2, Mat D2, Size imageSize, Mat R, Mat tvec, Mat& R1, Mat& R2, Mat& P1, Mat& P2, Mat& Q, int flags, Size newImageSize = Size(), double balance = 0.0, double fov_scale = 1.0)
+ //
+
+ /**
+ * Stereo rectification for fisheye camera model
+ *
+ * @param K1 First camera intrinsic matrix.
+ * @param D1 First camera distortion parameters.
+ * @param K2 Second camera intrinsic matrix.
+ * @param D2 Second camera distortion parameters.
+ * @param imageSize Size of the image used for stereo calibration.
+ * @param R Rotation matrix between the coordinate systems of the first and the second
+ * cameras.
+ * @param tvec Translation vector between coordinate systems of the cameras.
+ * @param R1 Output 3x3 rectification transform (rotation matrix) for the first camera.
+ * @param R2 Output 3x3 rectification transform (rotation matrix) for the second camera.
+ * @param P1 Output 3x4 projection matrix in the new (rectified) coordinate systems for the first
+ * camera.
+ * @param P2 Output 3x4 projection matrix in the new (rectified) coordinate systems for the second
+ * camera.
+ * @param Q Output \(4 \times 4\) disparity-to-depth mapping matrix (see #reprojectImageTo3D ).
+ * @param flags Operation flags that may be zero or REF: fisheye::CALIB_ZERO_DISPARITY . If the flag is set,
+ * the function makes the principal points of each camera have the same pixel coordinates in the
+ * rectified views. And if the flag is not set, the function may still shift the images in the
+ * horizontal or vertical direction (depending on the orientation of epipolar lines) to maximize the
+ * useful image area.
+ * @param newImageSize New image resolution after rectification. The same size should be passed to
+ * #initUndistortRectifyMap (see the stereo_calib.cpp sample in OpenCV samples directory). When (0,0)
+ * is passed (default), it is set to the original imageSize . Setting it to larger value can help you
+ * preserve details in the original image, especially when there is a big radial distortion.
+ * @param balance Sets the new focal length in range between the min focal length and the max focal
+ * length. Balance is in range of [0, 1].
+ * @param fov_scale Divisor for new focal length.
+ */
+ public static void fisheye_stereoRectify(Mat K1, Mat D1, Mat K2, Mat D2, Size imageSize, Mat R, Mat tvec, Mat R1, Mat R2, Mat P1, Mat P2, Mat Q, int flags, Size newImageSize, double balance, double fov_scale) {
+ fisheye_stereoRectify_0(K1.nativeObj, D1.nativeObj, K2.nativeObj, D2.nativeObj, imageSize.width, imageSize.height, R.nativeObj, tvec.nativeObj, R1.nativeObj, R2.nativeObj, P1.nativeObj, P2.nativeObj, Q.nativeObj, flags, newImageSize.width, newImageSize.height, balance, fov_scale);
+ }
+
+ /**
+ * Stereo rectification for fisheye camera model
+ *
+ * @param K1 First camera intrinsic matrix.
+ * @param D1 First camera distortion parameters.
+ * @param K2 Second camera intrinsic matrix.
+ * @param D2 Second camera distortion parameters.
+ * @param imageSize Size of the image used for stereo calibration.
+ * @param R Rotation matrix between the coordinate systems of the first and the second
+ * cameras.
+ * @param tvec Translation vector between coordinate systems of the cameras.
+ * @param R1 Output 3x3 rectification transform (rotation matrix) for the first camera.
+ * @param R2 Output 3x3 rectification transform (rotation matrix) for the second camera.
+ * @param P1 Output 3x4 projection matrix in the new (rectified) coordinate systems for the first
+ * camera.
+ * @param P2 Output 3x4 projection matrix in the new (rectified) coordinate systems for the second
+ * camera.
+ * @param Q Output \(4 \times 4\) disparity-to-depth mapping matrix (see #reprojectImageTo3D ).
+ * @param flags Operation flags that may be zero or REF: fisheye::CALIB_ZERO_DISPARITY . If the flag is set,
+ * the function makes the principal points of each camera have the same pixel coordinates in the
+ * rectified views. And if the flag is not set, the function may still shift the images in the
+ * horizontal or vertical direction (depending on the orientation of epipolar lines) to maximize the
+ * useful image area.
+ * @param newImageSize New image resolution after rectification. The same size should be passed to
+ * #initUndistortRectifyMap (see the stereo_calib.cpp sample in OpenCV samples directory). When (0,0)
+ * is passed (default), it is set to the original imageSize . Setting it to larger value can help you
+ * preserve details in the original image, especially when there is a big radial distortion.
+ * @param balance Sets the new focal length in range between the min focal length and the max focal
+ * length. Balance is in range of [0, 1].
+ */
+ public static void fisheye_stereoRectify(Mat K1, Mat D1, Mat K2, Mat D2, Size imageSize, Mat R, Mat tvec, Mat R1, Mat R2, Mat P1, Mat P2, Mat Q, int flags, Size newImageSize, double balance) {
+ fisheye_stereoRectify_1(K1.nativeObj, D1.nativeObj, K2.nativeObj, D2.nativeObj, imageSize.width, imageSize.height, R.nativeObj, tvec.nativeObj, R1.nativeObj, R2.nativeObj, P1.nativeObj, P2.nativeObj, Q.nativeObj, flags, newImageSize.width, newImageSize.height, balance);
+ }
+
+ /**
+ * Stereo rectification for fisheye camera model
+ *
+ * @param K1 First camera intrinsic matrix.
+ * @param D1 First camera distortion parameters.
+ * @param K2 Second camera intrinsic matrix.
+ * @param D2 Second camera distortion parameters.
+ * @param imageSize Size of the image used for stereo calibration.
+ * @param R Rotation matrix between the coordinate systems of the first and the second
+ * cameras.
+ * @param tvec Translation vector between coordinate systems of the cameras.
+ * @param R1 Output 3x3 rectification transform (rotation matrix) for the first camera.
+ * @param R2 Output 3x3 rectification transform (rotation matrix) for the second camera.
+ * @param P1 Output 3x4 projection matrix in the new (rectified) coordinate systems for the first
+ * camera.
+ * @param P2 Output 3x4 projection matrix in the new (rectified) coordinate systems for the second
+ * camera.
+ * @param Q Output \(4 \times 4\) disparity-to-depth mapping matrix (see #reprojectImageTo3D ).
+ * @param flags Operation flags that may be zero or REF: fisheye::CALIB_ZERO_DISPARITY . If the flag is set,
+ * the function makes the principal points of each camera have the same pixel coordinates in the
+ * rectified views. And if the flag is not set, the function may still shift the images in the
+ * horizontal or vertical direction (depending on the orientation of epipolar lines) to maximize the
+ * useful image area.
+ * @param newImageSize New image resolution after rectification. The same size should be passed to
+ * #initUndistortRectifyMap (see the stereo_calib.cpp sample in OpenCV samples directory). When (0,0)
+ * is passed (default), it is set to the original imageSize . Setting it to larger value can help you
+ * preserve details in the original image, especially when there is a big radial distortion.
+ * length. Balance is in range of [0, 1].
+ */
+ public static void fisheye_stereoRectify(Mat K1, Mat D1, Mat K2, Mat D2, Size imageSize, Mat R, Mat tvec, Mat R1, Mat R2, Mat P1, Mat P2, Mat Q, int flags, Size newImageSize) {
+ fisheye_stereoRectify_2(K1.nativeObj, D1.nativeObj, K2.nativeObj, D2.nativeObj, imageSize.width, imageSize.height, R.nativeObj, tvec.nativeObj, R1.nativeObj, R2.nativeObj, P1.nativeObj, P2.nativeObj, Q.nativeObj, flags, newImageSize.width, newImageSize.height);
+ }
+
+ /**
+ * Stereo rectification for fisheye camera model
+ *
+ * @param K1 First camera intrinsic matrix.
+ * @param D1 First camera distortion parameters.
+ * @param K2 Second camera intrinsic matrix.
+ * @param D2 Second camera distortion parameters.
+ * @param imageSize Size of the image used for stereo calibration.
+ * @param R Rotation matrix between the coordinate systems of the first and the second
+ * cameras.
+ * @param tvec Translation vector between coordinate systems of the cameras.
+ * @param R1 Output 3x3 rectification transform (rotation matrix) for the first camera.
+ * @param R2 Output 3x3 rectification transform (rotation matrix) for the second camera.
+ * @param P1 Output 3x4 projection matrix in the new (rectified) coordinate systems for the first
+ * camera.
+ * @param P2 Output 3x4 projection matrix in the new (rectified) coordinate systems for the second
+ * camera.
+ * @param Q Output \(4 \times 4\) disparity-to-depth mapping matrix (see #reprojectImageTo3D ).
+ * @param flags Operation flags that may be zero or REF: fisheye::CALIB_ZERO_DISPARITY . If the flag is set,
+ * the function makes the principal points of each camera have the same pixel coordinates in the
+ * rectified views. And if the flag is not set, the function may still shift the images in the
+ * horizontal or vertical direction (depending on the orientation of epipolar lines) to maximize the
+ * useful image area.
+ * #initUndistortRectifyMap (see the stereo_calib.cpp sample in OpenCV samples directory). When (0,0)
+ * is passed (default), it is set to the original imageSize . Setting it to larger value can help you
+ * preserve details in the original image, especially when there is a big radial distortion.
+ * length. Balance is in range of [0, 1].
+ */
+ public static void fisheye_stereoRectify(Mat K1, Mat D1, Mat K2, Mat D2, Size imageSize, Mat R, Mat tvec, Mat R1, Mat R2, Mat P1, Mat P2, Mat Q, int flags) {
+ fisheye_stereoRectify_3(K1.nativeObj, D1.nativeObj, K2.nativeObj, D2.nativeObj, imageSize.width, imageSize.height, R.nativeObj, tvec.nativeObj, R1.nativeObj, R2.nativeObj, P1.nativeObj, P2.nativeObj, Q.nativeObj, flags);
+ }
+
+
+ //
+ // C++: double cv::fisheye::stereoCalibrate(vector_Mat objectPoints, vector_Mat imagePoints1, vector_Mat imagePoints2, Mat& K1, Mat& D1, Mat& K2, Mat& D2, Size imageSize, Mat& R, Mat& T, vector_Mat& rvecs, vector_Mat& tvecs, int flags = fisheye::CALIB_FIX_INTRINSIC, TermCriteria criteria = TermCriteria(TermCriteria::COUNT + TermCriteria::EPS, 100, DBL_EPSILON))
+ //
+
+ /**
+ * Performs stereo calibration
+ *
+ * @param objectPoints Vector of vectors of the calibration pattern points.
+ * @param imagePoints1 Vector of vectors of the projections of the calibration pattern points,
+ * observed by the first camera.
+ * @param imagePoints2 Vector of vectors of the projections of the calibration pattern points,
+ * observed by the second camera.
+ * @param K1 Input/output first camera intrinsic matrix:
+ * \(\vecthreethree{f_x^{(j)}}{0}{c_x^{(j)}}{0}{f_y^{(j)}}{c_y^{(j)}}{0}{0}{1}\) , \(j = 0,\, 1\) . If
+ * any of REF: fisheye::CALIB_USE_INTRINSIC_GUESS , REF: fisheye::CALIB_FIX_INTRINSIC are specified,
+ * some or all of the matrix components must be initialized.
+ * @param D1 Input/output vector of distortion coefficients \(\distcoeffsfisheye\) of 4 elements.
+ * @param K2 Input/output second camera intrinsic matrix. The parameter is similar to K1 .
+ * @param D2 Input/output lens distortion coefficients for the second camera. The parameter is
+ * similar to D1 .
+ * @param imageSize Size of the image used only to initialize camera intrinsic matrix.
+ * @param R Output rotation matrix between the 1st and the 2nd camera coordinate systems.
+ * @param T Output translation vector between the coordinate systems of the cameras.
+ * @param rvecs Output vector of rotation vectors ( REF: Rodrigues ) estimated for each pattern view in the
+ * coordinate system of the first camera of the stereo pair (e.g. std::vector<cv::Mat>). More in detail, each
+ * i-th rotation vector together with the corresponding i-th translation vector (see the next output parameter
+ * description) brings the calibration pattern from the object coordinate space (in which object points are
+ * specified) to the camera coordinate space of the first camera of the stereo pair. In more technical terms,
+ * the tuple of the i-th rotation and translation vector performs a change of basis from object coordinate space
+ * to camera coordinate space of the first camera of the stereo pair.
+ * @param tvecs Output vector of translation vectors estimated for each pattern view, see parameter description
+ * of previous output parameter ( rvecs ).
+ * @param flags Different flags that may be zero or a combination of the following values:
+ *
+ *
+ * REF: fisheye::CALIB_FIX_INTRINSIC Fix K1, K2? and D1, D2? so that only R, T matrices
+ * are estimated.
+ *
+ *
+ * REF: fisheye::CALIB_USE_INTRINSIC_GUESS K1, K2 contains valid initial values of
+ * fx, fy, cx, cy that are optimized further. Otherwise, (cx, cy) is initially set to the image
+ * center (imageSize is used), and focal distances are computed in a least-squares fashion.
+ *
+ *
+ * REF: fisheye::CALIB_RECOMPUTE_EXTRINSIC Extrinsic will be recomputed after each iteration
+ * of intrinsic optimization.
+ *
+ *
+ * REF: fisheye::CALIB_CHECK_COND The functions will check validity of condition number.
+ *
+ *
+ * REF: fisheye::CALIB_FIX_SKEW Skew coefficient (alpha) is set to zero and stay zero.
+ *
+ *
+ * REF: fisheye::CALIB_FIX_K1,..., REF: fisheye::CALIB_FIX_K4 Selected distortion coefficients are set to zeros and stay
+ * zero.
+ *
+ *
+ * @param criteria Termination criteria for the iterative optimization algorithm.
+ * @return automatically generated
+ */
+ public static double fisheye_stereoCalibrate(List objectPoints, List imagePoints1, List imagePoints2, Mat K1, Mat D1, Mat K2, Mat D2, Size imageSize, Mat R, Mat T, List rvecs, List tvecs, int flags, TermCriteria criteria) {
+ Mat objectPoints_mat = Converters.vector_Mat_to_Mat(objectPoints);
+ Mat imagePoints1_mat = Converters.vector_Mat_to_Mat(imagePoints1);
+ Mat imagePoints2_mat = Converters.vector_Mat_to_Mat(imagePoints2);
+ Mat rvecs_mat = new Mat();
+ Mat tvecs_mat = new Mat();
+ double retVal = fisheye_stereoCalibrate_0(objectPoints_mat.nativeObj, imagePoints1_mat.nativeObj, imagePoints2_mat.nativeObj, K1.nativeObj, D1.nativeObj, K2.nativeObj, D2.nativeObj, imageSize.width, imageSize.height, R.nativeObj, T.nativeObj, rvecs_mat.nativeObj, tvecs_mat.nativeObj, flags, criteria.type, criteria.maxCount, criteria.epsilon);
+ Converters.Mat_to_vector_Mat(rvecs_mat, rvecs);
+ rvecs_mat.release();
+ Converters.Mat_to_vector_Mat(tvecs_mat, tvecs);
+ tvecs_mat.release();
+ return retVal;
+ }
+
+ /**
+ * Performs stereo calibration
+ *
+ * @param objectPoints Vector of vectors of the calibration pattern points.
+ * @param imagePoints1 Vector of vectors of the projections of the calibration pattern points,
+ * observed by the first camera.
+ * @param imagePoints2 Vector of vectors of the projections of the calibration pattern points,
+ * observed by the second camera.
+ * @param K1 Input/output first camera intrinsic matrix:
+ * \(\vecthreethree{f_x^{(j)}}{0}{c_x^{(j)}}{0}{f_y^{(j)}}{c_y^{(j)}}{0}{0}{1}\) , \(j = 0,\, 1\) . If
+ * any of REF: fisheye::CALIB_USE_INTRINSIC_GUESS , REF: fisheye::CALIB_FIX_INTRINSIC are specified,
+ * some or all of the matrix components must be initialized.
+ * @param D1 Input/output vector of distortion coefficients \(\distcoeffsfisheye\) of 4 elements.
+ * @param K2 Input/output second camera intrinsic matrix. The parameter is similar to K1 .
+ * @param D2 Input/output lens distortion coefficients for the second camera. The parameter is
+ * similar to D1 .
+ * @param imageSize Size of the image used only to initialize camera intrinsic matrix.
+ * @param R Output rotation matrix between the 1st and the 2nd camera coordinate systems.
+ * @param T Output translation vector between the coordinate systems of the cameras.
+ * @param rvecs Output vector of rotation vectors ( REF: Rodrigues ) estimated for each pattern view in the
+ * coordinate system of the first camera of the stereo pair (e.g. std::vector<cv::Mat>). More in detail, each
+ * i-th rotation vector together with the corresponding i-th translation vector (see the next output parameter
+ * description) brings the calibration pattern from the object coordinate space (in which object points are
+ * specified) to the camera coordinate space of the first camera of the stereo pair. In more technical terms,
+ * the tuple of the i-th rotation and translation vector performs a change of basis from object coordinate space
+ * to camera coordinate space of the first camera of the stereo pair.
+ * @param tvecs Output vector of translation vectors estimated for each pattern view, see parameter description
+ * of previous output parameter ( rvecs ).
+ * @param flags Different flags that may be zero or a combination of the following values:
+ *
+ *
+ * REF: fisheye::CALIB_FIX_INTRINSIC Fix K1, K2? and D1, D2? so that only R, T matrices
+ * are estimated.
+ *
+ *
+ * REF: fisheye::CALIB_USE_INTRINSIC_GUESS K1, K2 contains valid initial values of
+ * fx, fy, cx, cy that are optimized further. Otherwise, (cx, cy) is initially set to the image
+ * center (imageSize is used), and focal distances are computed in a least-squares fashion.
+ *
+ *
+ * REF: fisheye::CALIB_RECOMPUTE_EXTRINSIC Extrinsic will be recomputed after each iteration
+ * of intrinsic optimization.
+ *
+ *
+ * REF: fisheye::CALIB_CHECK_COND The functions will check validity of condition number.
+ *
+ *
+ * REF: fisheye::CALIB_FIX_SKEW Skew coefficient (alpha) is set to zero and stay zero.
+ *
+ *
+ * REF: fisheye::CALIB_FIX_K1,..., REF: fisheye::CALIB_FIX_K4 Selected distortion coefficients are set to zeros and stay
+ * zero.
+ *
+ *
+ * @return automatically generated
+ */
+ public static double fisheye_stereoCalibrate(List objectPoints, List imagePoints1, List imagePoints2, Mat K1, Mat D1, Mat K2, Mat D2, Size imageSize, Mat R, Mat T, List rvecs, List tvecs, int flags) {
+ Mat objectPoints_mat = Converters.vector_Mat_to_Mat(objectPoints);
+ Mat imagePoints1_mat = Converters.vector_Mat_to_Mat(imagePoints1);
+ Mat imagePoints2_mat = Converters.vector_Mat_to_Mat(imagePoints2);
+ Mat rvecs_mat = new Mat();
+ Mat tvecs_mat = new Mat();
+ double retVal = fisheye_stereoCalibrate_1(objectPoints_mat.nativeObj, imagePoints1_mat.nativeObj, imagePoints2_mat.nativeObj, K1.nativeObj, D1.nativeObj, K2.nativeObj, D2.nativeObj, imageSize.width, imageSize.height, R.nativeObj, T.nativeObj, rvecs_mat.nativeObj, tvecs_mat.nativeObj, flags);
+ Converters.Mat_to_vector_Mat(rvecs_mat, rvecs);
+ rvecs_mat.release();
+ Converters.Mat_to_vector_Mat(tvecs_mat, tvecs);
+ tvecs_mat.release();
+ return retVal;
+ }
+
+ /**
+ * Performs stereo calibration
+ *
+ * @param objectPoints Vector of vectors of the calibration pattern points.
+ * @param imagePoints1 Vector of vectors of the projections of the calibration pattern points,
+ * observed by the first camera.
+ * @param imagePoints2 Vector of vectors of the projections of the calibration pattern points,
+ * observed by the second camera.
+ * @param K1 Input/output first camera intrinsic matrix:
+ * \(\vecthreethree{f_x^{(j)}}{0}{c_x^{(j)}}{0}{f_y^{(j)}}{c_y^{(j)}}{0}{0}{1}\) , \(j = 0,\, 1\) . If
+ * any of REF: fisheye::CALIB_USE_INTRINSIC_GUESS , REF: fisheye::CALIB_FIX_INTRINSIC are specified,
+ * some or all of the matrix components must be initialized.
+ * @param D1 Input/output vector of distortion coefficients \(\distcoeffsfisheye\) of 4 elements.
+ * @param K2 Input/output second camera intrinsic matrix. The parameter is similar to K1 .
+ * @param D2 Input/output lens distortion coefficients for the second camera. The parameter is
+ * similar to D1 .
+ * @param imageSize Size of the image used only to initialize camera intrinsic matrix.
+ * @param R Output rotation matrix between the 1st and the 2nd camera coordinate systems.
+ * @param T Output translation vector between the coordinate systems of the cameras.
+ * @param rvecs Output vector of rotation vectors ( REF: Rodrigues ) estimated for each pattern view in the
+ * coordinate system of the first camera of the stereo pair (e.g. std::vector<cv::Mat>). More in detail, each
+ * i-th rotation vector together with the corresponding i-th translation vector (see the next output parameter
+ * description) brings the calibration pattern from the object coordinate space (in which object points are
+ * specified) to the camera coordinate space of the first camera of the stereo pair. In more technical terms,
+ * the tuple of the i-th rotation and translation vector performs a change of basis from object coordinate space
+ * to camera coordinate space of the first camera of the stereo pair.
+ * @param tvecs Output vector of translation vectors estimated for each pattern view, see parameter description
+ * of previous output parameter ( rvecs ).
+ *
+ *
+ * REF: fisheye::CALIB_FIX_INTRINSIC Fix K1, K2? and D1, D2? so that only R, T matrices
+ * are estimated.
+ *
+ *
+ * REF: fisheye::CALIB_USE_INTRINSIC_GUESS K1, K2 contains valid initial values of
+ * fx, fy, cx, cy that are optimized further. Otherwise, (cx, cy) is initially set to the image
+ * center (imageSize is used), and focal distances are computed in a least-squares fashion.
+ *
+ *
+ * REF: fisheye::CALIB_RECOMPUTE_EXTRINSIC Extrinsic will be recomputed after each iteration
+ * of intrinsic optimization.
+ *
+ *
+ * REF: fisheye::CALIB_CHECK_COND The functions will check validity of condition number.
+ *
+ *
+ * REF: fisheye::CALIB_FIX_SKEW Skew coefficient (alpha) is set to zero and stay zero.
+ *
+ *
+ * REF: fisheye::CALIB_FIX_K1,..., REF: fisheye::CALIB_FIX_K4 Selected distortion coefficients are set to zeros and stay
+ * zero.
+ *
+ *
+ * @return automatically generated
+ */
+ public static double fisheye_stereoCalibrate(List objectPoints, List imagePoints1, List imagePoints2, Mat K1, Mat D1, Mat K2, Mat D2, Size imageSize, Mat R, Mat T, List rvecs, List tvecs) {
+ Mat objectPoints_mat = Converters.vector_Mat_to_Mat(objectPoints);
+ Mat imagePoints1_mat = Converters.vector_Mat_to_Mat(imagePoints1);
+ Mat imagePoints2_mat = Converters.vector_Mat_to_Mat(imagePoints2);
+ Mat rvecs_mat = new Mat();
+ Mat tvecs_mat = new Mat();
+ double retVal = fisheye_stereoCalibrate_2(objectPoints_mat.nativeObj, imagePoints1_mat.nativeObj, imagePoints2_mat.nativeObj, K1.nativeObj, D1.nativeObj, K2.nativeObj, D2.nativeObj, imageSize.width, imageSize.height, R.nativeObj, T.nativeObj, rvecs_mat.nativeObj, tvecs_mat.nativeObj);
+ Converters.Mat_to_vector_Mat(rvecs_mat, rvecs);
+ rvecs_mat.release();
+ Converters.Mat_to_vector_Mat(tvecs_mat, tvecs);
+ tvecs_mat.release();
+ return retVal;
+ }
+
+
+ //
+ // C++: double cv::fisheye::stereoCalibrate(vector_Mat objectPoints, vector_Mat imagePoints1, vector_Mat imagePoints2, Mat& K1, Mat& D1, Mat& K2, Mat& D2, Size imageSize, Mat& R, Mat& T, int flags = fisheye::CALIB_FIX_INTRINSIC, TermCriteria criteria = TermCriteria(TermCriteria::COUNT + TermCriteria::EPS, 100, DBL_EPSILON))
+ //
+
+ public static double fisheye_stereoCalibrate(List objectPoints, List imagePoints1, List imagePoints2, Mat K1, Mat D1, Mat K2, Mat D2, Size imageSize, Mat R, Mat T, int flags, TermCriteria criteria) {
+ Mat objectPoints_mat = Converters.vector_Mat_to_Mat(objectPoints);
+ Mat imagePoints1_mat = Converters.vector_Mat_to_Mat(imagePoints1);
+ Mat imagePoints2_mat = Converters.vector_Mat_to_Mat(imagePoints2);
+ return fisheye_stereoCalibrate_3(objectPoints_mat.nativeObj, imagePoints1_mat.nativeObj, imagePoints2_mat.nativeObj, K1.nativeObj, D1.nativeObj, K2.nativeObj, D2.nativeObj, imageSize.width, imageSize.height, R.nativeObj, T.nativeObj, flags, criteria.type, criteria.maxCount, criteria.epsilon);
+ }
+
+ public static double fisheye_stereoCalibrate(List objectPoints, List imagePoints1, List imagePoints2, Mat K1, Mat D1, Mat K2, Mat D2, Size imageSize, Mat R, Mat T, int flags) {
+ Mat objectPoints_mat = Converters.vector_Mat_to_Mat(objectPoints);
+ Mat imagePoints1_mat = Converters.vector_Mat_to_Mat(imagePoints1);
+ Mat imagePoints2_mat = Converters.vector_Mat_to_Mat(imagePoints2);
+ return fisheye_stereoCalibrate_4(objectPoints_mat.nativeObj, imagePoints1_mat.nativeObj, imagePoints2_mat.nativeObj, K1.nativeObj, D1.nativeObj, K2.nativeObj, D2.nativeObj, imageSize.width, imageSize.height, R.nativeObj, T.nativeObj, flags);
+ }
+
+ public static double fisheye_stereoCalibrate(List objectPoints, List imagePoints1, List imagePoints2, Mat K1, Mat D1, Mat K2, Mat D2, Size imageSize, Mat R, Mat T) {
+ Mat objectPoints_mat = Converters.vector_Mat_to_Mat(objectPoints);
+ Mat imagePoints1_mat = Converters.vector_Mat_to_Mat(imagePoints1);
+ Mat imagePoints2_mat = Converters.vector_Mat_to_Mat(imagePoints2);
+ return fisheye_stereoCalibrate_5(objectPoints_mat.nativeObj, imagePoints1_mat.nativeObj, imagePoints2_mat.nativeObj, K1.nativeObj, D1.nativeObj, K2.nativeObj, D2.nativeObj, imageSize.width, imageSize.height, R.nativeObj, T.nativeObj);
+ }
+
+
+
+
+ // C++: void cv::Rodrigues(Mat src, Mat& dst, Mat& jacobian = Mat())
+ private static native void Rodrigues_0(long src_nativeObj, long dst_nativeObj, long jacobian_nativeObj);
+ private static native void Rodrigues_1(long src_nativeObj, long dst_nativeObj);
+
+ // C++: Mat cv::findHomography(vector_Point2f srcPoints, vector_Point2f dstPoints, int method = 0, double ransacReprojThreshold = 3, Mat& mask = Mat(), int maxIters = 2000, double confidence = 0.995)
+ private static native long findHomography_0(long srcPoints_mat_nativeObj, long dstPoints_mat_nativeObj, int method, double ransacReprojThreshold, long mask_nativeObj, int maxIters, double confidence);
+ private static native long findHomography_1(long srcPoints_mat_nativeObj, long dstPoints_mat_nativeObj, int method, double ransacReprojThreshold, long mask_nativeObj, int maxIters);
+ private static native long findHomography_2(long srcPoints_mat_nativeObj, long dstPoints_mat_nativeObj, int method, double ransacReprojThreshold, long mask_nativeObj);
+ private static native long findHomography_3(long srcPoints_mat_nativeObj, long dstPoints_mat_nativeObj, int method, double ransacReprojThreshold);
+ private static native long findHomography_4(long srcPoints_mat_nativeObj, long dstPoints_mat_nativeObj, int method);
+ private static native long findHomography_5(long srcPoints_mat_nativeObj, long dstPoints_mat_nativeObj);
+
+ // C++: Mat cv::findHomography(vector_Point2f srcPoints, vector_Point2f dstPoints, Mat& mask, UsacParams params)
+ private static native long findHomography_6(long srcPoints_mat_nativeObj, long dstPoints_mat_nativeObj, long mask_nativeObj, long params_nativeObj);
+
+ // C++: Vec3d cv::RQDecomp3x3(Mat src, Mat& mtxR, Mat& mtxQ, Mat& Qx = Mat(), Mat& Qy = Mat(), Mat& Qz = Mat())
+ private static native double[] RQDecomp3x3_0(long src_nativeObj, long mtxR_nativeObj, long mtxQ_nativeObj, long Qx_nativeObj, long Qy_nativeObj, long Qz_nativeObj);
+ private static native double[] RQDecomp3x3_1(long src_nativeObj, long mtxR_nativeObj, long mtxQ_nativeObj, long Qx_nativeObj, long Qy_nativeObj);
+ private static native double[] RQDecomp3x3_2(long src_nativeObj, long mtxR_nativeObj, long mtxQ_nativeObj, long Qx_nativeObj);
+ private static native double[] RQDecomp3x3_3(long src_nativeObj, long mtxR_nativeObj, long mtxQ_nativeObj);
+
+ // C++: void cv::decomposeProjectionMatrix(Mat projMatrix, Mat& cameraMatrix, Mat& rotMatrix, Mat& transVect, Mat& rotMatrixX = Mat(), Mat& rotMatrixY = Mat(), Mat& rotMatrixZ = Mat(), Mat& eulerAngles = Mat())
+ private static native void decomposeProjectionMatrix_0(long projMatrix_nativeObj, long cameraMatrix_nativeObj, long rotMatrix_nativeObj, long transVect_nativeObj, long rotMatrixX_nativeObj, long rotMatrixY_nativeObj, long rotMatrixZ_nativeObj, long eulerAngles_nativeObj);
+ private static native void decomposeProjectionMatrix_1(long projMatrix_nativeObj, long cameraMatrix_nativeObj, long rotMatrix_nativeObj, long transVect_nativeObj, long rotMatrixX_nativeObj, long rotMatrixY_nativeObj, long rotMatrixZ_nativeObj);
+ private static native void decomposeProjectionMatrix_2(long projMatrix_nativeObj, long cameraMatrix_nativeObj, long rotMatrix_nativeObj, long transVect_nativeObj, long rotMatrixX_nativeObj, long rotMatrixY_nativeObj);
+ private static native void decomposeProjectionMatrix_3(long projMatrix_nativeObj, long cameraMatrix_nativeObj, long rotMatrix_nativeObj, long transVect_nativeObj, long rotMatrixX_nativeObj);
+ private static native void decomposeProjectionMatrix_4(long projMatrix_nativeObj, long cameraMatrix_nativeObj, long rotMatrix_nativeObj, long transVect_nativeObj);
+
+ // C++: void cv::matMulDeriv(Mat A, Mat B, Mat& dABdA, Mat& dABdB)
+ private static native void matMulDeriv_0(long A_nativeObj, long B_nativeObj, long dABdA_nativeObj, long dABdB_nativeObj);
+
+ // C++: void cv::composeRT(Mat rvec1, Mat tvec1, Mat rvec2, Mat tvec2, Mat& rvec3, Mat& tvec3, Mat& dr3dr1 = Mat(), Mat& dr3dt1 = Mat(), Mat& dr3dr2 = Mat(), Mat& dr3dt2 = Mat(), Mat& dt3dr1 = Mat(), Mat& dt3dt1 = Mat(), Mat& dt3dr2 = Mat(), Mat& dt3dt2 = Mat())
+ private static native void composeRT_0(long rvec1_nativeObj, long tvec1_nativeObj, long rvec2_nativeObj, long tvec2_nativeObj, long rvec3_nativeObj, long tvec3_nativeObj, long dr3dr1_nativeObj, long dr3dt1_nativeObj, long dr3dr2_nativeObj, long dr3dt2_nativeObj, long dt3dr1_nativeObj, long dt3dt1_nativeObj, long dt3dr2_nativeObj, long dt3dt2_nativeObj);
+ private static native void composeRT_1(long rvec1_nativeObj, long tvec1_nativeObj, long rvec2_nativeObj, long tvec2_nativeObj, long rvec3_nativeObj, long tvec3_nativeObj, long dr3dr1_nativeObj, long dr3dt1_nativeObj, long dr3dr2_nativeObj, long dr3dt2_nativeObj, long dt3dr1_nativeObj, long dt3dt1_nativeObj, long dt3dr2_nativeObj);
+ private static native void composeRT_2(long rvec1_nativeObj, long tvec1_nativeObj, long rvec2_nativeObj, long tvec2_nativeObj, long rvec3_nativeObj, long tvec3_nativeObj, long dr3dr1_nativeObj, long dr3dt1_nativeObj, long dr3dr2_nativeObj, long dr3dt2_nativeObj, long dt3dr1_nativeObj, long dt3dt1_nativeObj);
+ private static native void composeRT_3(long rvec1_nativeObj, long tvec1_nativeObj, long rvec2_nativeObj, long tvec2_nativeObj, long rvec3_nativeObj, long tvec3_nativeObj, long dr3dr1_nativeObj, long dr3dt1_nativeObj, long dr3dr2_nativeObj, long dr3dt2_nativeObj, long dt3dr1_nativeObj);
+ private static native void composeRT_4(long rvec1_nativeObj, long tvec1_nativeObj, long rvec2_nativeObj, long tvec2_nativeObj, long rvec3_nativeObj, long tvec3_nativeObj, long dr3dr1_nativeObj, long dr3dt1_nativeObj, long dr3dr2_nativeObj, long dr3dt2_nativeObj);
+ private static native void composeRT_5(long rvec1_nativeObj, long tvec1_nativeObj, long rvec2_nativeObj, long tvec2_nativeObj, long rvec3_nativeObj, long tvec3_nativeObj, long dr3dr1_nativeObj, long dr3dt1_nativeObj, long dr3dr2_nativeObj);
+ private static native void composeRT_6(long rvec1_nativeObj, long tvec1_nativeObj, long rvec2_nativeObj, long tvec2_nativeObj, long rvec3_nativeObj, long tvec3_nativeObj, long dr3dr1_nativeObj, long dr3dt1_nativeObj);
+ private static native void composeRT_7(long rvec1_nativeObj, long tvec1_nativeObj, long rvec2_nativeObj, long tvec2_nativeObj, long rvec3_nativeObj, long tvec3_nativeObj, long dr3dr1_nativeObj);
+ private static native void composeRT_8(long rvec1_nativeObj, long tvec1_nativeObj, long rvec2_nativeObj, long tvec2_nativeObj, long rvec3_nativeObj, long tvec3_nativeObj);
+
+ // C++: void cv::projectPoints(vector_Point3f objectPoints, Mat rvec, Mat tvec, Mat cameraMatrix, vector_double distCoeffs, vector_Point2f& imagePoints, Mat& jacobian = Mat(), double aspectRatio = 0)
+ private static native void projectPoints_0(long objectPoints_mat_nativeObj, long rvec_nativeObj, long tvec_nativeObj, long cameraMatrix_nativeObj, long distCoeffs_mat_nativeObj, long imagePoints_mat_nativeObj, long jacobian_nativeObj, double aspectRatio);
+ private static native void projectPoints_1(long objectPoints_mat_nativeObj, long rvec_nativeObj, long tvec_nativeObj, long cameraMatrix_nativeObj, long distCoeffs_mat_nativeObj, long imagePoints_mat_nativeObj, long jacobian_nativeObj);
+ private static native void projectPoints_2(long objectPoints_mat_nativeObj, long rvec_nativeObj, long tvec_nativeObj, long cameraMatrix_nativeObj, long distCoeffs_mat_nativeObj, long imagePoints_mat_nativeObj);
+
+ // C++: bool cv::solvePnP(vector_Point3f objectPoints, vector_Point2f imagePoints, Mat cameraMatrix, vector_double distCoeffs, Mat& rvec, Mat& tvec, bool useExtrinsicGuess = false, int flags = SOLVEPNP_ITERATIVE)
+ private static native boolean solvePnP_0(long objectPoints_mat_nativeObj, long imagePoints_mat_nativeObj, long cameraMatrix_nativeObj, long distCoeffs_mat_nativeObj, long rvec_nativeObj, long tvec_nativeObj, boolean useExtrinsicGuess, int flags);
+ private static native boolean solvePnP_1(long objectPoints_mat_nativeObj, long imagePoints_mat_nativeObj, long cameraMatrix_nativeObj, long distCoeffs_mat_nativeObj, long rvec_nativeObj, long tvec_nativeObj, boolean useExtrinsicGuess);
+ private static native boolean solvePnP_2(long objectPoints_mat_nativeObj, long imagePoints_mat_nativeObj, long cameraMatrix_nativeObj, long distCoeffs_mat_nativeObj, long rvec_nativeObj, long tvec_nativeObj);
+
+ // C++: bool cv::solvePnPRansac(vector_Point3f objectPoints, vector_Point2f imagePoints, Mat cameraMatrix, vector_double distCoeffs, Mat& rvec, Mat& tvec, bool useExtrinsicGuess = false, int iterationsCount = 100, float reprojectionError = 8.0, double confidence = 0.99, Mat& inliers = Mat(), int flags = SOLVEPNP_ITERATIVE)
+ private static native boolean solvePnPRansac_0(long objectPoints_mat_nativeObj, long imagePoints_mat_nativeObj, long cameraMatrix_nativeObj, long distCoeffs_mat_nativeObj, long rvec_nativeObj, long tvec_nativeObj, boolean useExtrinsicGuess, int iterationsCount, float reprojectionError, double confidence, long inliers_nativeObj, int flags);
+ private static native boolean solvePnPRansac_1(long objectPoints_mat_nativeObj, long imagePoints_mat_nativeObj, long cameraMatrix_nativeObj, long distCoeffs_mat_nativeObj, long rvec_nativeObj, long tvec_nativeObj, boolean useExtrinsicGuess, int iterationsCount, float reprojectionError, double confidence, long inliers_nativeObj);
+ private static native boolean solvePnPRansac_2(long objectPoints_mat_nativeObj, long imagePoints_mat_nativeObj, long cameraMatrix_nativeObj, long distCoeffs_mat_nativeObj, long rvec_nativeObj, long tvec_nativeObj, boolean useExtrinsicGuess, int iterationsCount, float reprojectionError, double confidence);
+ private static native boolean solvePnPRansac_3(long objectPoints_mat_nativeObj, long imagePoints_mat_nativeObj, long cameraMatrix_nativeObj, long distCoeffs_mat_nativeObj, long rvec_nativeObj, long tvec_nativeObj, boolean useExtrinsicGuess, int iterationsCount, float reprojectionError);
+ private static native boolean solvePnPRansac_4(long objectPoints_mat_nativeObj, long imagePoints_mat_nativeObj, long cameraMatrix_nativeObj, long distCoeffs_mat_nativeObj, long rvec_nativeObj, long tvec_nativeObj, boolean useExtrinsicGuess, int iterationsCount);
+ private static native boolean solvePnPRansac_5(long objectPoints_mat_nativeObj, long imagePoints_mat_nativeObj, long cameraMatrix_nativeObj, long distCoeffs_mat_nativeObj, long rvec_nativeObj, long tvec_nativeObj, boolean useExtrinsicGuess);
+ private static native boolean solvePnPRansac_6(long objectPoints_mat_nativeObj, long imagePoints_mat_nativeObj, long cameraMatrix_nativeObj, long distCoeffs_mat_nativeObj, long rvec_nativeObj, long tvec_nativeObj);
+
+ // C++: bool cv::solvePnPRansac(vector_Point3f objectPoints, vector_Point2f imagePoints, Mat& cameraMatrix, vector_double distCoeffs, Mat& rvec, Mat& tvec, Mat& inliers, UsacParams params = UsacParams())
+ private static native boolean solvePnPRansac_7(long objectPoints_mat_nativeObj, long imagePoints_mat_nativeObj, long cameraMatrix_nativeObj, long distCoeffs_mat_nativeObj, long rvec_nativeObj, long tvec_nativeObj, long inliers_nativeObj, long params_nativeObj);
+ private static native boolean solvePnPRansac_8(long objectPoints_mat_nativeObj, long imagePoints_mat_nativeObj, long cameraMatrix_nativeObj, long distCoeffs_mat_nativeObj, long rvec_nativeObj, long tvec_nativeObj, long inliers_nativeObj);
+
+ // C++: int cv::solveP3P(Mat objectPoints, Mat imagePoints, Mat cameraMatrix, Mat distCoeffs, vector_Mat& rvecs, vector_Mat& tvecs, int flags)
+ private static native int solveP3P_0(long objectPoints_nativeObj, long imagePoints_nativeObj, long cameraMatrix_nativeObj, long distCoeffs_nativeObj, long rvecs_mat_nativeObj, long tvecs_mat_nativeObj, int flags);
+
+ // C++: void cv::solvePnPRefineLM(Mat objectPoints, Mat imagePoints, Mat cameraMatrix, Mat distCoeffs, Mat& rvec, Mat& tvec, TermCriteria criteria = TermCriteria(TermCriteria::EPS + TermCriteria::COUNT, 20, FLT_EPSILON))
+ private static native void solvePnPRefineLM_0(long objectPoints_nativeObj, long imagePoints_nativeObj, long cameraMatrix_nativeObj, long distCoeffs_nativeObj, long rvec_nativeObj, long tvec_nativeObj, int criteria_type, int criteria_maxCount, double criteria_epsilon);
+ private static native void solvePnPRefineLM_1(long objectPoints_nativeObj, long imagePoints_nativeObj, long cameraMatrix_nativeObj, long distCoeffs_nativeObj, long rvec_nativeObj, long tvec_nativeObj);
+
+ // C++: void cv::solvePnPRefineVVS(Mat objectPoints, Mat imagePoints, Mat cameraMatrix, Mat distCoeffs, Mat& rvec, Mat& tvec, TermCriteria criteria = TermCriteria(TermCriteria::EPS + TermCriteria::COUNT, 20, FLT_EPSILON), double VVSlambda = 1)
+ private static native void solvePnPRefineVVS_0(long objectPoints_nativeObj, long imagePoints_nativeObj, long cameraMatrix_nativeObj, long distCoeffs_nativeObj, long rvec_nativeObj, long tvec_nativeObj, int criteria_type, int criteria_maxCount, double criteria_epsilon, double VVSlambda);
+ private static native void solvePnPRefineVVS_1(long objectPoints_nativeObj, long imagePoints_nativeObj, long cameraMatrix_nativeObj, long distCoeffs_nativeObj, long rvec_nativeObj, long tvec_nativeObj, int criteria_type, int criteria_maxCount, double criteria_epsilon);
+ private static native void solvePnPRefineVVS_2(long objectPoints_nativeObj, long imagePoints_nativeObj, long cameraMatrix_nativeObj, long distCoeffs_nativeObj, long rvec_nativeObj, long tvec_nativeObj);
+
+ // C++: int cv::solvePnPGeneric(Mat objectPoints, Mat imagePoints, Mat cameraMatrix, Mat distCoeffs, vector_Mat& rvecs, vector_Mat& tvecs, bool useExtrinsicGuess = false, SolvePnPMethod flags = SOLVEPNP_ITERATIVE, Mat rvec = Mat(), Mat tvec = Mat(), Mat& reprojectionError = Mat())
+ private static native int solvePnPGeneric_0(long objectPoints_nativeObj, long imagePoints_nativeObj, long cameraMatrix_nativeObj, long distCoeffs_nativeObj, long rvecs_mat_nativeObj, long tvecs_mat_nativeObj, boolean useExtrinsicGuess, int flags, long rvec_nativeObj, long tvec_nativeObj, long reprojectionError_nativeObj);
+ private static native int solvePnPGeneric_1(long objectPoints_nativeObj, long imagePoints_nativeObj, long cameraMatrix_nativeObj, long distCoeffs_nativeObj, long rvecs_mat_nativeObj, long tvecs_mat_nativeObj, boolean useExtrinsicGuess, int flags, long rvec_nativeObj, long tvec_nativeObj);
+ private static native int solvePnPGeneric_2(long objectPoints_nativeObj, long imagePoints_nativeObj, long cameraMatrix_nativeObj, long distCoeffs_nativeObj, long rvecs_mat_nativeObj, long tvecs_mat_nativeObj, boolean useExtrinsicGuess, int flags, long rvec_nativeObj);
+ private static native int solvePnPGeneric_3(long objectPoints_nativeObj, long imagePoints_nativeObj, long cameraMatrix_nativeObj, long distCoeffs_nativeObj, long rvecs_mat_nativeObj, long tvecs_mat_nativeObj, boolean useExtrinsicGuess, int flags);
+ private static native int solvePnPGeneric_4(long objectPoints_nativeObj, long imagePoints_nativeObj, long cameraMatrix_nativeObj, long distCoeffs_nativeObj, long rvecs_mat_nativeObj, long tvecs_mat_nativeObj, boolean useExtrinsicGuess);
+ private static native int solvePnPGeneric_5(long objectPoints_nativeObj, long imagePoints_nativeObj, long cameraMatrix_nativeObj, long distCoeffs_nativeObj, long rvecs_mat_nativeObj, long tvecs_mat_nativeObj);
+
+ // C++: Mat cv::initCameraMatrix2D(vector_vector_Point3f objectPoints, vector_vector_Point2f imagePoints, Size imageSize, double aspectRatio = 1.0)
+ private static native long initCameraMatrix2D_0(long objectPoints_mat_nativeObj, long imagePoints_mat_nativeObj, double imageSize_width, double imageSize_height, double aspectRatio);
+ private static native long initCameraMatrix2D_1(long objectPoints_mat_nativeObj, long imagePoints_mat_nativeObj, double imageSize_width, double imageSize_height);
+
+ // C++: bool cv::findChessboardCorners(Mat image, Size patternSize, vector_Point2f& corners, int flags = CALIB_CB_ADAPTIVE_THRESH + CALIB_CB_NORMALIZE_IMAGE)
+ private static native boolean findChessboardCorners_0(long image_nativeObj, double patternSize_width, double patternSize_height, long corners_mat_nativeObj, int flags);
+ private static native boolean findChessboardCorners_1(long image_nativeObj, double patternSize_width, double patternSize_height, long corners_mat_nativeObj);
+
+ // C++: bool cv::checkChessboard(Mat img, Size size)
+ private static native boolean checkChessboard_0(long img_nativeObj, double size_width, double size_height);
+
+ // C++: bool cv::findChessboardCornersSB(Mat image, Size patternSize, Mat& corners, int flags, Mat& meta)
+ private static native boolean findChessboardCornersSBWithMeta_0(long image_nativeObj, double patternSize_width, double patternSize_height, long corners_nativeObj, int flags, long meta_nativeObj);
+
+ // C++: bool cv::findChessboardCornersSB(Mat image, Size patternSize, Mat& corners, int flags = 0)
+ private static native boolean findChessboardCornersSB_0(long image_nativeObj, double patternSize_width, double patternSize_height, long corners_nativeObj, int flags);
+ private static native boolean findChessboardCornersSB_1(long image_nativeObj, double patternSize_width, double patternSize_height, long corners_nativeObj);
+
+ // C++: Scalar cv::estimateChessboardSharpness(Mat image, Size patternSize, Mat corners, float rise_distance = 0.8F, bool vertical = false, Mat& sharpness = Mat())
+ private static native double[] estimateChessboardSharpness_0(long image_nativeObj, double patternSize_width, double patternSize_height, long corners_nativeObj, float rise_distance, boolean vertical, long sharpness_nativeObj);
+ private static native double[] estimateChessboardSharpness_1(long image_nativeObj, double patternSize_width, double patternSize_height, long corners_nativeObj, float rise_distance, boolean vertical);
+ private static native double[] estimateChessboardSharpness_2(long image_nativeObj, double patternSize_width, double patternSize_height, long corners_nativeObj, float rise_distance);
+ private static native double[] estimateChessboardSharpness_3(long image_nativeObj, double patternSize_width, double patternSize_height, long corners_nativeObj);
+
+ // C++: bool cv::find4QuadCornerSubpix(Mat img, Mat& corners, Size region_size)
+ private static native boolean find4QuadCornerSubpix_0(long img_nativeObj, long corners_nativeObj, double region_size_width, double region_size_height);
+
+ // C++: void cv::drawChessboardCorners(Mat& image, Size patternSize, vector_Point2f corners, bool patternWasFound)
+ private static native void drawChessboardCorners_0(long image_nativeObj, double patternSize_width, double patternSize_height, long corners_mat_nativeObj, boolean patternWasFound);
+
+ // C++: void cv::drawFrameAxes(Mat& image, Mat cameraMatrix, Mat distCoeffs, Mat rvec, Mat tvec, float length, int thickness = 3)
+ private static native void drawFrameAxes_0(long image_nativeObj, long cameraMatrix_nativeObj, long distCoeffs_nativeObj, long rvec_nativeObj, long tvec_nativeObj, float length, int thickness);
+ private static native void drawFrameAxes_1(long image_nativeObj, long cameraMatrix_nativeObj, long distCoeffs_nativeObj, long rvec_nativeObj, long tvec_nativeObj, float length);
+
+ // C++: bool cv::findCirclesGrid(Mat image, Size patternSize, Mat& centers, int flags = CALIB_CB_SYMMETRIC_GRID, Ptr_FeatureDetector blobDetector = SimpleBlobDetector::create())
+ private static native boolean findCirclesGrid_0(long image_nativeObj, double patternSize_width, double patternSize_height, long centers_nativeObj, int flags);
+ private static native boolean findCirclesGrid_2(long image_nativeObj, double patternSize_width, double patternSize_height, long centers_nativeObj);
+
+ // C++: double cv::calibrateCamera(vector_Mat objectPoints, vector_Mat imagePoints, Size imageSize, Mat& cameraMatrix, Mat& distCoeffs, vector_Mat& rvecs, vector_Mat& tvecs, Mat& stdDeviationsIntrinsics, Mat& stdDeviationsExtrinsics, Mat& perViewErrors, int flags = 0, TermCriteria criteria = TermCriteria( TermCriteria::COUNT + TermCriteria::EPS, 30, DBL_EPSILON))
+ private static native double calibrateCameraExtended_0(long objectPoints_mat_nativeObj, long imagePoints_mat_nativeObj, double imageSize_width, double imageSize_height, long cameraMatrix_nativeObj, long distCoeffs_nativeObj, long rvecs_mat_nativeObj, long tvecs_mat_nativeObj, long stdDeviationsIntrinsics_nativeObj, long stdDeviationsExtrinsics_nativeObj, long perViewErrors_nativeObj, int flags, int criteria_type, int criteria_maxCount, double criteria_epsilon);
+ private static native double calibrateCameraExtended_1(long objectPoints_mat_nativeObj, long imagePoints_mat_nativeObj, double imageSize_width, double imageSize_height, long cameraMatrix_nativeObj, long distCoeffs_nativeObj, long rvecs_mat_nativeObj, long tvecs_mat_nativeObj, long stdDeviationsIntrinsics_nativeObj, long stdDeviationsExtrinsics_nativeObj, long perViewErrors_nativeObj, int flags);
+ private static native double calibrateCameraExtended_2(long objectPoints_mat_nativeObj, long imagePoints_mat_nativeObj, double imageSize_width, double imageSize_height, long cameraMatrix_nativeObj, long distCoeffs_nativeObj, long rvecs_mat_nativeObj, long tvecs_mat_nativeObj, long stdDeviationsIntrinsics_nativeObj, long stdDeviationsExtrinsics_nativeObj, long perViewErrors_nativeObj);
+
+ // C++: double cv::calibrateCamera(vector_Mat objectPoints, vector_Mat imagePoints, Size imageSize, Mat& cameraMatrix, Mat& distCoeffs, vector_Mat& rvecs, vector_Mat& tvecs, int flags = 0, TermCriteria criteria = TermCriteria( TermCriteria::COUNT + TermCriteria::EPS, 30, DBL_EPSILON))
+ private static native double calibrateCamera_0(long objectPoints_mat_nativeObj, long imagePoints_mat_nativeObj, double imageSize_width, double imageSize_height, long cameraMatrix_nativeObj, long distCoeffs_nativeObj, long rvecs_mat_nativeObj, long tvecs_mat_nativeObj, int flags, int criteria_type, int criteria_maxCount, double criteria_epsilon);
+ private static native double calibrateCamera_1(long objectPoints_mat_nativeObj, long imagePoints_mat_nativeObj, double imageSize_width, double imageSize_height, long cameraMatrix_nativeObj, long distCoeffs_nativeObj, long rvecs_mat_nativeObj, long tvecs_mat_nativeObj, int flags);
+ private static native double calibrateCamera_2(long objectPoints_mat_nativeObj, long imagePoints_mat_nativeObj, double imageSize_width, double imageSize_height, long cameraMatrix_nativeObj, long distCoeffs_nativeObj, long rvecs_mat_nativeObj, long tvecs_mat_nativeObj);
+
+ // C++: double cv::calibrateCameraRO(vector_Mat objectPoints, vector_Mat imagePoints, Size imageSize, int iFixedPoint, Mat& cameraMatrix, Mat& distCoeffs, vector_Mat& rvecs, vector_Mat& tvecs, Mat& newObjPoints, Mat& stdDeviationsIntrinsics, Mat& stdDeviationsExtrinsics, Mat& stdDeviationsObjPoints, Mat& perViewErrors, int flags = 0, TermCriteria criteria = TermCriteria( TermCriteria::COUNT + TermCriteria::EPS, 30, DBL_EPSILON))
+ private static native double calibrateCameraROExtended_0(long objectPoints_mat_nativeObj, long imagePoints_mat_nativeObj, double imageSize_width, double imageSize_height, int iFixedPoint, long cameraMatrix_nativeObj, long distCoeffs_nativeObj, long rvecs_mat_nativeObj, long tvecs_mat_nativeObj, long newObjPoints_nativeObj, long stdDeviationsIntrinsics_nativeObj, long stdDeviationsExtrinsics_nativeObj, long stdDeviationsObjPoints_nativeObj, long perViewErrors_nativeObj, int flags, int criteria_type, int criteria_maxCount, double criteria_epsilon);
+ private static native double calibrateCameraROExtended_1(long objectPoints_mat_nativeObj, long imagePoints_mat_nativeObj, double imageSize_width, double imageSize_height, int iFixedPoint, long cameraMatrix_nativeObj, long distCoeffs_nativeObj, long rvecs_mat_nativeObj, long tvecs_mat_nativeObj, long newObjPoints_nativeObj, long stdDeviationsIntrinsics_nativeObj, long stdDeviationsExtrinsics_nativeObj, long stdDeviationsObjPoints_nativeObj, long perViewErrors_nativeObj, int flags);
+ private static native double calibrateCameraROExtended_2(long objectPoints_mat_nativeObj, long imagePoints_mat_nativeObj, double imageSize_width, double imageSize_height, int iFixedPoint, long cameraMatrix_nativeObj, long distCoeffs_nativeObj, long rvecs_mat_nativeObj, long tvecs_mat_nativeObj, long newObjPoints_nativeObj, long stdDeviationsIntrinsics_nativeObj, long stdDeviationsExtrinsics_nativeObj, long stdDeviationsObjPoints_nativeObj, long perViewErrors_nativeObj);
+
+ // C++: double cv::calibrateCameraRO(vector_Mat objectPoints, vector_Mat imagePoints, Size imageSize, int iFixedPoint, Mat& cameraMatrix, Mat& distCoeffs, vector_Mat& rvecs, vector_Mat& tvecs, Mat& newObjPoints, int flags = 0, TermCriteria criteria = TermCriteria( TermCriteria::COUNT + TermCriteria::EPS, 30, DBL_EPSILON))
+ private static native double calibrateCameraRO_0(long objectPoints_mat_nativeObj, long imagePoints_mat_nativeObj, double imageSize_width, double imageSize_height, int iFixedPoint, long cameraMatrix_nativeObj, long distCoeffs_nativeObj, long rvecs_mat_nativeObj, long tvecs_mat_nativeObj, long newObjPoints_nativeObj, int flags, int criteria_type, int criteria_maxCount, double criteria_epsilon);
+ private static native double calibrateCameraRO_1(long objectPoints_mat_nativeObj, long imagePoints_mat_nativeObj, double imageSize_width, double imageSize_height, int iFixedPoint, long cameraMatrix_nativeObj, long distCoeffs_nativeObj, long rvecs_mat_nativeObj, long tvecs_mat_nativeObj, long newObjPoints_nativeObj, int flags);
+ private static native double calibrateCameraRO_2(long objectPoints_mat_nativeObj, long imagePoints_mat_nativeObj, double imageSize_width, double imageSize_height, int iFixedPoint, long cameraMatrix_nativeObj, long distCoeffs_nativeObj, long rvecs_mat_nativeObj, long tvecs_mat_nativeObj, long newObjPoints_nativeObj);
+
+ // C++: void cv::calibrationMatrixValues(Mat cameraMatrix, Size imageSize, double apertureWidth, double apertureHeight, double& fovx, double& fovy, double& focalLength, Point2d& principalPoint, double& aspectRatio)
+ private static native void calibrationMatrixValues_0(long cameraMatrix_nativeObj, double imageSize_width, double imageSize_height, double apertureWidth, double apertureHeight, double[] fovx_out, double[] fovy_out, double[] focalLength_out, double[] principalPoint_out, double[] aspectRatio_out);
+
+ // C++: double cv::stereoCalibrate(vector_Mat objectPoints, vector_Mat imagePoints1, vector_Mat imagePoints2, Mat& cameraMatrix1, Mat& distCoeffs1, Mat& cameraMatrix2, Mat& distCoeffs2, Size imageSize, Mat& R, Mat& T, Mat& E, Mat& F, vector_Mat& rvecs, vector_Mat& tvecs, Mat& perViewErrors, int flags = CALIB_FIX_INTRINSIC, TermCriteria criteria = TermCriteria(TermCriteria::COUNT+TermCriteria::EPS, 30, 1e-6))
+ private static native double stereoCalibrateExtended_0(long objectPoints_mat_nativeObj, long imagePoints1_mat_nativeObj, long imagePoints2_mat_nativeObj, long cameraMatrix1_nativeObj, long distCoeffs1_nativeObj, long cameraMatrix2_nativeObj, long distCoeffs2_nativeObj, double imageSize_width, double imageSize_height, long R_nativeObj, long T_nativeObj, long E_nativeObj, long F_nativeObj, long rvecs_mat_nativeObj, long tvecs_mat_nativeObj, long perViewErrors_nativeObj, int flags, int criteria_type, int criteria_maxCount, double criteria_epsilon);
+ private static native double stereoCalibrateExtended_1(long objectPoints_mat_nativeObj, long imagePoints1_mat_nativeObj, long imagePoints2_mat_nativeObj, long cameraMatrix1_nativeObj, long distCoeffs1_nativeObj, long cameraMatrix2_nativeObj, long distCoeffs2_nativeObj, double imageSize_width, double imageSize_height, long R_nativeObj, long T_nativeObj, long E_nativeObj, long F_nativeObj, long rvecs_mat_nativeObj, long tvecs_mat_nativeObj, long perViewErrors_nativeObj, int flags);
+ private static native double stereoCalibrateExtended_2(long objectPoints_mat_nativeObj, long imagePoints1_mat_nativeObj, long imagePoints2_mat_nativeObj, long cameraMatrix1_nativeObj, long distCoeffs1_nativeObj, long cameraMatrix2_nativeObj, long distCoeffs2_nativeObj, double imageSize_width, double imageSize_height, long R_nativeObj, long T_nativeObj, long E_nativeObj, long F_nativeObj, long rvecs_mat_nativeObj, long tvecs_mat_nativeObj, long perViewErrors_nativeObj);
+
+ // C++: double cv::stereoCalibrate(vector_Mat objectPoints, vector_Mat imagePoints1, vector_Mat imagePoints2, Mat& cameraMatrix1, Mat& distCoeffs1, Mat& cameraMatrix2, Mat& distCoeffs2, Size imageSize, Mat& R, Mat& T, Mat& E, Mat& F, int flags = CALIB_FIX_INTRINSIC, TermCriteria criteria = TermCriteria(TermCriteria::COUNT+TermCriteria::EPS, 30, 1e-6))
+ private static native double stereoCalibrate_0(long objectPoints_mat_nativeObj, long imagePoints1_mat_nativeObj, long imagePoints2_mat_nativeObj, long cameraMatrix1_nativeObj, long distCoeffs1_nativeObj, long cameraMatrix2_nativeObj, long distCoeffs2_nativeObj, double imageSize_width, double imageSize_height, long R_nativeObj, long T_nativeObj, long E_nativeObj, long F_nativeObj, int flags, int criteria_type, int criteria_maxCount, double criteria_epsilon);
+ private static native double stereoCalibrate_1(long objectPoints_mat_nativeObj, long imagePoints1_mat_nativeObj, long imagePoints2_mat_nativeObj, long cameraMatrix1_nativeObj, long distCoeffs1_nativeObj, long cameraMatrix2_nativeObj, long distCoeffs2_nativeObj, double imageSize_width, double imageSize_height, long R_nativeObj, long T_nativeObj, long E_nativeObj, long F_nativeObj, int flags);
+ private static native double stereoCalibrate_2(long objectPoints_mat_nativeObj, long imagePoints1_mat_nativeObj, long imagePoints2_mat_nativeObj, long cameraMatrix1_nativeObj, long distCoeffs1_nativeObj, long cameraMatrix2_nativeObj, long distCoeffs2_nativeObj, double imageSize_width, double imageSize_height, long R_nativeObj, long T_nativeObj, long E_nativeObj, long F_nativeObj);
+
+ // C++: double cv::stereoCalibrate(vector_Mat objectPoints, vector_Mat imagePoints1, vector_Mat imagePoints2, Mat& cameraMatrix1, Mat& distCoeffs1, Mat& cameraMatrix2, Mat& distCoeffs2, Size imageSize, Mat& R, Mat& T, Mat& E, Mat& F, Mat& perViewErrors, int flags = CALIB_FIX_INTRINSIC, TermCriteria criteria = TermCriteria(TermCriteria::COUNT+TermCriteria::EPS, 30, 1e-6))
+ private static native double stereoCalibrate_3(long objectPoints_mat_nativeObj, long imagePoints1_mat_nativeObj, long imagePoints2_mat_nativeObj, long cameraMatrix1_nativeObj, long distCoeffs1_nativeObj, long cameraMatrix2_nativeObj, long distCoeffs2_nativeObj, double imageSize_width, double imageSize_height, long R_nativeObj, long T_nativeObj, long E_nativeObj, long F_nativeObj, long perViewErrors_nativeObj, int flags, int criteria_type, int criteria_maxCount, double criteria_epsilon);
+ private static native double stereoCalibrate_4(long objectPoints_mat_nativeObj, long imagePoints1_mat_nativeObj, long imagePoints2_mat_nativeObj, long cameraMatrix1_nativeObj, long distCoeffs1_nativeObj, long cameraMatrix2_nativeObj, long distCoeffs2_nativeObj, double imageSize_width, double imageSize_height, long R_nativeObj, long T_nativeObj, long E_nativeObj, long F_nativeObj, long perViewErrors_nativeObj, int flags);
+ private static native double stereoCalibrate_5(long objectPoints_mat_nativeObj, long imagePoints1_mat_nativeObj, long imagePoints2_mat_nativeObj, long cameraMatrix1_nativeObj, long distCoeffs1_nativeObj, long cameraMatrix2_nativeObj, long distCoeffs2_nativeObj, double imageSize_width, double imageSize_height, long R_nativeObj, long T_nativeObj, long E_nativeObj, long F_nativeObj, long perViewErrors_nativeObj);
+
+ // C++: void cv::stereoRectify(Mat cameraMatrix1, Mat distCoeffs1, Mat cameraMatrix2, Mat distCoeffs2, Size imageSize, Mat R, Mat T, Mat& R1, Mat& R2, Mat& P1, Mat& P2, Mat& Q, int flags = CALIB_ZERO_DISPARITY, double alpha = -1, Size newImageSize = Size(), Rect* validPixROI1 = 0, Rect* validPixROI2 = 0)
+ private static native void stereoRectify_0(long cameraMatrix1_nativeObj, long distCoeffs1_nativeObj, long cameraMatrix2_nativeObj, long distCoeffs2_nativeObj, double imageSize_width, double imageSize_height, long R_nativeObj, long T_nativeObj, long R1_nativeObj, long R2_nativeObj, long P1_nativeObj, long P2_nativeObj, long Q_nativeObj, int flags, double alpha, double newImageSize_width, double newImageSize_height, double[] validPixROI1_out, double[] validPixROI2_out);
+ private static native void stereoRectify_1(long cameraMatrix1_nativeObj, long distCoeffs1_nativeObj, long cameraMatrix2_nativeObj, long distCoeffs2_nativeObj, double imageSize_width, double imageSize_height, long R_nativeObj, long T_nativeObj, long R1_nativeObj, long R2_nativeObj, long P1_nativeObj, long P2_nativeObj, long Q_nativeObj, int flags, double alpha, double newImageSize_width, double newImageSize_height, double[] validPixROI1_out);
+ private static native void stereoRectify_2(long cameraMatrix1_nativeObj, long distCoeffs1_nativeObj, long cameraMatrix2_nativeObj, long distCoeffs2_nativeObj, double imageSize_width, double imageSize_height, long R_nativeObj, long T_nativeObj, long R1_nativeObj, long R2_nativeObj, long P1_nativeObj, long P2_nativeObj, long Q_nativeObj, int flags, double alpha, double newImageSize_width, double newImageSize_height);
+ private static native void stereoRectify_3(long cameraMatrix1_nativeObj, long distCoeffs1_nativeObj, long cameraMatrix2_nativeObj, long distCoeffs2_nativeObj, double imageSize_width, double imageSize_height, long R_nativeObj, long T_nativeObj, long R1_nativeObj, long R2_nativeObj, long P1_nativeObj, long P2_nativeObj, long Q_nativeObj, int flags, double alpha);
+ private static native void stereoRectify_4(long cameraMatrix1_nativeObj, long distCoeffs1_nativeObj, long cameraMatrix2_nativeObj, long distCoeffs2_nativeObj, double imageSize_width, double imageSize_height, long R_nativeObj, long T_nativeObj, long R1_nativeObj, long R2_nativeObj, long P1_nativeObj, long P2_nativeObj, long Q_nativeObj, int flags);
+ private static native void stereoRectify_5(long cameraMatrix1_nativeObj, long distCoeffs1_nativeObj, long cameraMatrix2_nativeObj, long distCoeffs2_nativeObj, double imageSize_width, double imageSize_height, long R_nativeObj, long T_nativeObj, long R1_nativeObj, long R2_nativeObj, long P1_nativeObj, long P2_nativeObj, long Q_nativeObj);
+
+ // C++: bool cv::stereoRectifyUncalibrated(Mat points1, Mat points2, Mat F, Size imgSize, Mat& H1, Mat& H2, double threshold = 5)
+ private static native boolean stereoRectifyUncalibrated_0(long points1_nativeObj, long points2_nativeObj, long F_nativeObj, double imgSize_width, double imgSize_height, long H1_nativeObj, long H2_nativeObj, double threshold);
+ private static native boolean stereoRectifyUncalibrated_1(long points1_nativeObj, long points2_nativeObj, long F_nativeObj, double imgSize_width, double imgSize_height, long H1_nativeObj, long H2_nativeObj);
+
+ // C++: float cv::rectify3Collinear(Mat cameraMatrix1, Mat distCoeffs1, Mat cameraMatrix2, Mat distCoeffs2, Mat cameraMatrix3, Mat distCoeffs3, vector_Mat imgpt1, vector_Mat imgpt3, Size imageSize, Mat R12, Mat T12, Mat R13, Mat T13, Mat& R1, Mat& R2, Mat& R3, Mat& P1, Mat& P2, Mat& P3, Mat& Q, double alpha, Size newImgSize, Rect* roi1, Rect* roi2, int flags)
+ private static native float rectify3Collinear_0(long cameraMatrix1_nativeObj, long distCoeffs1_nativeObj, long cameraMatrix2_nativeObj, long distCoeffs2_nativeObj, long cameraMatrix3_nativeObj, long distCoeffs3_nativeObj, long imgpt1_mat_nativeObj, long imgpt3_mat_nativeObj, double imageSize_width, double imageSize_height, long R12_nativeObj, long T12_nativeObj, long R13_nativeObj, long T13_nativeObj, long R1_nativeObj, long R2_nativeObj, long R3_nativeObj, long P1_nativeObj, long P2_nativeObj, long P3_nativeObj, long Q_nativeObj, double alpha, double newImgSize_width, double newImgSize_height, double[] roi1_out, double[] roi2_out, int flags);
+
+ // C++: Mat cv::getOptimalNewCameraMatrix(Mat cameraMatrix, Mat distCoeffs, Size imageSize, double alpha, Size newImgSize = Size(), Rect* validPixROI = 0, bool centerPrincipalPoint = false)
+ private static native long getOptimalNewCameraMatrix_0(long cameraMatrix_nativeObj, long distCoeffs_nativeObj, double imageSize_width, double imageSize_height, double alpha, double newImgSize_width, double newImgSize_height, double[] validPixROI_out, boolean centerPrincipalPoint);
+ private static native long getOptimalNewCameraMatrix_1(long cameraMatrix_nativeObj, long distCoeffs_nativeObj, double imageSize_width, double imageSize_height, double alpha, double newImgSize_width, double newImgSize_height, double[] validPixROI_out);
+ private static native long getOptimalNewCameraMatrix_2(long cameraMatrix_nativeObj, long distCoeffs_nativeObj, double imageSize_width, double imageSize_height, double alpha, double newImgSize_width, double newImgSize_height);
+ private static native long getOptimalNewCameraMatrix_3(long cameraMatrix_nativeObj, long distCoeffs_nativeObj, double imageSize_width, double imageSize_height, double alpha);
+
+ // C++: void cv::calibrateHandEye(vector_Mat R_gripper2base, vector_Mat t_gripper2base, vector_Mat R_target2cam, vector_Mat t_target2cam, Mat& R_cam2gripper, Mat& t_cam2gripper, HandEyeCalibrationMethod method = CALIB_HAND_EYE_TSAI)
+ private static native void calibrateHandEye_0(long R_gripper2base_mat_nativeObj, long t_gripper2base_mat_nativeObj, long R_target2cam_mat_nativeObj, long t_target2cam_mat_nativeObj, long R_cam2gripper_nativeObj, long t_cam2gripper_nativeObj, int method);
+ private static native void calibrateHandEye_1(long R_gripper2base_mat_nativeObj, long t_gripper2base_mat_nativeObj, long R_target2cam_mat_nativeObj, long t_target2cam_mat_nativeObj, long R_cam2gripper_nativeObj, long t_cam2gripper_nativeObj);
+
+ // C++: void cv::calibrateRobotWorldHandEye(vector_Mat R_world2cam, vector_Mat t_world2cam, vector_Mat R_base2gripper, vector_Mat t_base2gripper, Mat& R_base2world, Mat& t_base2world, Mat& R_gripper2cam, Mat& t_gripper2cam, RobotWorldHandEyeCalibrationMethod method = CALIB_ROBOT_WORLD_HAND_EYE_SHAH)
+ private static native void calibrateRobotWorldHandEye_0(long R_world2cam_mat_nativeObj, long t_world2cam_mat_nativeObj, long R_base2gripper_mat_nativeObj, long t_base2gripper_mat_nativeObj, long R_base2world_nativeObj, long t_base2world_nativeObj, long R_gripper2cam_nativeObj, long t_gripper2cam_nativeObj, int method);
+ private static native void calibrateRobotWorldHandEye_1(long R_world2cam_mat_nativeObj, long t_world2cam_mat_nativeObj, long R_base2gripper_mat_nativeObj, long t_base2gripper_mat_nativeObj, long R_base2world_nativeObj, long t_base2world_nativeObj, long R_gripper2cam_nativeObj, long t_gripper2cam_nativeObj);
+
+ // C++: void cv::convertPointsToHomogeneous(Mat src, Mat& dst)
+ private static native void convertPointsToHomogeneous_0(long src_nativeObj, long dst_nativeObj);
+
+ // C++: void cv::convertPointsFromHomogeneous(Mat src, Mat& dst)
+ private static native void convertPointsFromHomogeneous_0(long src_nativeObj, long dst_nativeObj);
+
+ // C++: Mat cv::findFundamentalMat(vector_Point2f points1, vector_Point2f points2, int method, double ransacReprojThreshold, double confidence, int maxIters, Mat& mask = Mat())
+ private static native long findFundamentalMat_0(long points1_mat_nativeObj, long points2_mat_nativeObj, int method, double ransacReprojThreshold, double confidence, int maxIters, long mask_nativeObj);
+ private static native long findFundamentalMat_1(long points1_mat_nativeObj, long points2_mat_nativeObj, int method, double ransacReprojThreshold, double confidence, int maxIters);
+
+ // C++: Mat cv::findFundamentalMat(vector_Point2f points1, vector_Point2f points2, int method = FM_RANSAC, double ransacReprojThreshold = 3., double confidence = 0.99, Mat& mask = Mat())
+ private static native long findFundamentalMat_2(long points1_mat_nativeObj, long points2_mat_nativeObj, int method, double ransacReprojThreshold, double confidence, long mask_nativeObj);
+ private static native long findFundamentalMat_3(long points1_mat_nativeObj, long points2_mat_nativeObj, int method, double ransacReprojThreshold, double confidence);
+ private static native long findFundamentalMat_4(long points1_mat_nativeObj, long points2_mat_nativeObj, int method, double ransacReprojThreshold);
+ private static native long findFundamentalMat_5(long points1_mat_nativeObj, long points2_mat_nativeObj, int method);
+ private static native long findFundamentalMat_6(long points1_mat_nativeObj, long points2_mat_nativeObj);
+
+ // C++: Mat cv::findFundamentalMat(vector_Point2f points1, vector_Point2f points2, Mat& mask, UsacParams params)
+ private static native long findFundamentalMat_7(long points1_mat_nativeObj, long points2_mat_nativeObj, long mask_nativeObj, long params_nativeObj);
+
+ // C++: Mat cv::findEssentialMat(Mat points1, Mat points2, Mat cameraMatrix, int method = RANSAC, double prob = 0.999, double threshold = 1.0, int maxIters = 1000, Mat& mask = Mat())
+ private static native long findEssentialMat_0(long points1_nativeObj, long points2_nativeObj, long cameraMatrix_nativeObj, int method, double prob, double threshold, int maxIters, long mask_nativeObj);
+ private static native long findEssentialMat_1(long points1_nativeObj, long points2_nativeObj, long cameraMatrix_nativeObj, int method, double prob, double threshold, int maxIters);
+ private static native long findEssentialMat_2(long points1_nativeObj, long points2_nativeObj, long cameraMatrix_nativeObj, int method, double prob, double threshold);
+ private static native long findEssentialMat_3(long points1_nativeObj, long points2_nativeObj, long cameraMatrix_nativeObj, int method, double prob);
+ private static native long findEssentialMat_4(long points1_nativeObj, long points2_nativeObj, long cameraMatrix_nativeObj, int method);
+ private static native long findEssentialMat_5(long points1_nativeObj, long points2_nativeObj, long cameraMatrix_nativeObj);
+
+ // C++: Mat cv::findEssentialMat(Mat points1, Mat points2, double focal = 1.0, Point2d pp = Point2d(0, 0), int method = RANSAC, double prob = 0.999, double threshold = 1.0, int maxIters = 1000, Mat& mask = Mat())
+ private static native long findEssentialMat_6(long points1_nativeObj, long points2_nativeObj, double focal, double pp_x, double pp_y, int method, double prob, double threshold, int maxIters, long mask_nativeObj);
+ private static native long findEssentialMat_7(long points1_nativeObj, long points2_nativeObj, double focal, double pp_x, double pp_y, int method, double prob, double threshold, int maxIters);
+ private static native long findEssentialMat_8(long points1_nativeObj, long points2_nativeObj, double focal, double pp_x, double pp_y, int method, double prob, double threshold);
+ private static native long findEssentialMat_9(long points1_nativeObj, long points2_nativeObj, double focal, double pp_x, double pp_y, int method, double prob);
+ private static native long findEssentialMat_10(long points1_nativeObj, long points2_nativeObj, double focal, double pp_x, double pp_y, int method);
+ private static native long findEssentialMat_11(long points1_nativeObj, long points2_nativeObj, double focal, double pp_x, double pp_y);
+ private static native long findEssentialMat_12(long points1_nativeObj, long points2_nativeObj, double focal);
+ private static native long findEssentialMat_13(long points1_nativeObj, long points2_nativeObj);
+
+ // C++: Mat cv::findEssentialMat(Mat points1, Mat points2, Mat cameraMatrix1, Mat distCoeffs1, Mat cameraMatrix2, Mat distCoeffs2, int method = RANSAC, double prob = 0.999, double threshold = 1.0, Mat& mask = Mat())
+ private static native long findEssentialMat_14(long points1_nativeObj, long points2_nativeObj, long cameraMatrix1_nativeObj, long distCoeffs1_nativeObj, long cameraMatrix2_nativeObj, long distCoeffs2_nativeObj, int method, double prob, double threshold, long mask_nativeObj);
+ private static native long findEssentialMat_15(long points1_nativeObj, long points2_nativeObj, long cameraMatrix1_nativeObj, long distCoeffs1_nativeObj, long cameraMatrix2_nativeObj, long distCoeffs2_nativeObj, int method, double prob, double threshold);
+ private static native long findEssentialMat_16(long points1_nativeObj, long points2_nativeObj, long cameraMatrix1_nativeObj, long distCoeffs1_nativeObj, long cameraMatrix2_nativeObj, long distCoeffs2_nativeObj, int method, double prob);
+ private static native long findEssentialMat_17(long points1_nativeObj, long points2_nativeObj, long cameraMatrix1_nativeObj, long distCoeffs1_nativeObj, long cameraMatrix2_nativeObj, long distCoeffs2_nativeObj, int method);
+ private static native long findEssentialMat_18(long points1_nativeObj, long points2_nativeObj, long cameraMatrix1_nativeObj, long distCoeffs1_nativeObj, long cameraMatrix2_nativeObj, long distCoeffs2_nativeObj);
+
+ // C++: Mat cv::findEssentialMat(Mat points1, Mat points2, Mat cameraMatrix1, Mat cameraMatrix2, Mat dist_coeff1, Mat dist_coeff2, Mat& mask, UsacParams params)
+ private static native long findEssentialMat_19(long points1_nativeObj, long points2_nativeObj, long cameraMatrix1_nativeObj, long cameraMatrix2_nativeObj, long dist_coeff1_nativeObj, long dist_coeff2_nativeObj, long mask_nativeObj, long params_nativeObj);
+
+ // C++: void cv::decomposeEssentialMat(Mat E, Mat& R1, Mat& R2, Mat& t)
+ private static native void decomposeEssentialMat_0(long E_nativeObj, long R1_nativeObj, long R2_nativeObj, long t_nativeObj);
+
+ // C++: int cv::recoverPose(Mat points1, Mat points2, Mat cameraMatrix1, Mat distCoeffs1, Mat cameraMatrix2, Mat distCoeffs2, Mat& E, Mat& R, Mat& t, int method = cv::RANSAC, double prob = 0.999, double threshold = 1.0, Mat& mask = Mat())
+ private static native int recoverPose_0(long points1_nativeObj, long points2_nativeObj, long cameraMatrix1_nativeObj, long distCoeffs1_nativeObj, long cameraMatrix2_nativeObj, long distCoeffs2_nativeObj, long E_nativeObj, long R_nativeObj, long t_nativeObj, int method, double prob, double threshold, long mask_nativeObj);
+ private static native int recoverPose_1(long points1_nativeObj, long points2_nativeObj, long cameraMatrix1_nativeObj, long distCoeffs1_nativeObj, long cameraMatrix2_nativeObj, long distCoeffs2_nativeObj, long E_nativeObj, long R_nativeObj, long t_nativeObj, int method, double prob, double threshold);
+ private static native int recoverPose_2(long points1_nativeObj, long points2_nativeObj, long cameraMatrix1_nativeObj, long distCoeffs1_nativeObj, long cameraMatrix2_nativeObj, long distCoeffs2_nativeObj, long E_nativeObj, long R_nativeObj, long t_nativeObj, int method, double prob);
+ private static native int recoverPose_3(long points1_nativeObj, long points2_nativeObj, long cameraMatrix1_nativeObj, long distCoeffs1_nativeObj, long cameraMatrix2_nativeObj, long distCoeffs2_nativeObj, long E_nativeObj, long R_nativeObj, long t_nativeObj, int method);
+ private static native int recoverPose_4(long points1_nativeObj, long points2_nativeObj, long cameraMatrix1_nativeObj, long distCoeffs1_nativeObj, long cameraMatrix2_nativeObj, long distCoeffs2_nativeObj, long E_nativeObj, long R_nativeObj, long t_nativeObj);
+
+ // C++: int cv::recoverPose(Mat E, Mat points1, Mat points2, Mat cameraMatrix, Mat& R, Mat& t, Mat& mask = Mat())
+ private static native int recoverPose_5(long E_nativeObj, long points1_nativeObj, long points2_nativeObj, long cameraMatrix_nativeObj, long R_nativeObj, long t_nativeObj, long mask_nativeObj);
+ private static native int recoverPose_6(long E_nativeObj, long points1_nativeObj, long points2_nativeObj, long cameraMatrix_nativeObj, long R_nativeObj, long t_nativeObj);
+
+ // C++: int cv::recoverPose(Mat E, Mat points1, Mat points2, Mat& R, Mat& t, double focal = 1.0, Point2d pp = Point2d(0, 0), Mat& mask = Mat())
+ private static native int recoverPose_7(long E_nativeObj, long points1_nativeObj, long points2_nativeObj, long R_nativeObj, long t_nativeObj, double focal, double pp_x, double pp_y, long mask_nativeObj);
+ private static native int recoverPose_8(long E_nativeObj, long points1_nativeObj, long points2_nativeObj, long R_nativeObj, long t_nativeObj, double focal, double pp_x, double pp_y);
+ private static native int recoverPose_9(long E_nativeObj, long points1_nativeObj, long points2_nativeObj, long R_nativeObj, long t_nativeObj, double focal);
+ private static native int recoverPose_10(long E_nativeObj, long points1_nativeObj, long points2_nativeObj, long R_nativeObj, long t_nativeObj);
+
+ // C++: int cv::recoverPose(Mat E, Mat points1, Mat points2, Mat cameraMatrix, Mat& R, Mat& t, double distanceThresh, Mat& mask = Mat(), Mat& triangulatedPoints = Mat())
+ private static native int recoverPose_11(long E_nativeObj, long points1_nativeObj, long points2_nativeObj, long cameraMatrix_nativeObj, long R_nativeObj, long t_nativeObj, double distanceThresh, long mask_nativeObj, long triangulatedPoints_nativeObj);
+ private static native int recoverPose_12(long E_nativeObj, long points1_nativeObj, long points2_nativeObj, long cameraMatrix_nativeObj, long R_nativeObj, long t_nativeObj, double distanceThresh, long mask_nativeObj);
+ private static native int recoverPose_13(long E_nativeObj, long points1_nativeObj, long points2_nativeObj, long cameraMatrix_nativeObj, long R_nativeObj, long t_nativeObj, double distanceThresh);
+
+ // C++: void cv::computeCorrespondEpilines(Mat points, int whichImage, Mat F, Mat& lines)
+ private static native void computeCorrespondEpilines_0(long points_nativeObj, int whichImage, long F_nativeObj, long lines_nativeObj);
+
+ // C++: void cv::triangulatePoints(Mat projMatr1, Mat projMatr2, Mat projPoints1, Mat projPoints2, Mat& points4D)
+ private static native void triangulatePoints_0(long projMatr1_nativeObj, long projMatr2_nativeObj, long projPoints1_nativeObj, long projPoints2_nativeObj, long points4D_nativeObj);
+
+ // C++: void cv::correctMatches(Mat F, Mat points1, Mat points2, Mat& newPoints1, Mat& newPoints2)
+ private static native void correctMatches_0(long F_nativeObj, long points1_nativeObj, long points2_nativeObj, long newPoints1_nativeObj, long newPoints2_nativeObj);
+
+ // C++: void cv::filterSpeckles(Mat& img, double newVal, int maxSpeckleSize, double maxDiff, Mat& buf = Mat())
+ private static native void filterSpeckles_0(long img_nativeObj, double newVal, int maxSpeckleSize, double maxDiff, long buf_nativeObj);
+ private static native void filterSpeckles_1(long img_nativeObj, double newVal, int maxSpeckleSize, double maxDiff);
+
+ // C++: Rect cv::getValidDisparityROI(Rect roi1, Rect roi2, int minDisparity, int numberOfDisparities, int blockSize)
+ private static native double[] getValidDisparityROI_0(int roi1_x, int roi1_y, int roi1_width, int roi1_height, int roi2_x, int roi2_y, int roi2_width, int roi2_height, int minDisparity, int numberOfDisparities, int blockSize);
+
+ // C++: void cv::validateDisparity(Mat& disparity, Mat cost, int minDisparity, int numberOfDisparities, int disp12MaxDisp = 1)
+ private static native void validateDisparity_0(long disparity_nativeObj, long cost_nativeObj, int minDisparity, int numberOfDisparities, int disp12MaxDisp);
+ private static native void validateDisparity_1(long disparity_nativeObj, long cost_nativeObj, int minDisparity, int numberOfDisparities);
+
+ // C++: void cv::reprojectImageTo3D(Mat disparity, Mat& _3dImage, Mat Q, bool handleMissingValues = false, int ddepth = -1)
+ private static native void reprojectImageTo3D_0(long disparity_nativeObj, long _3dImage_nativeObj, long Q_nativeObj, boolean handleMissingValues, int ddepth);
+ private static native void reprojectImageTo3D_1(long disparity_nativeObj, long _3dImage_nativeObj, long Q_nativeObj, boolean handleMissingValues);
+ private static native void reprojectImageTo3D_2(long disparity_nativeObj, long _3dImage_nativeObj, long Q_nativeObj);
+
+ // C++: double cv::sampsonDistance(Mat pt1, Mat pt2, Mat F)
+ private static native double sampsonDistance_0(long pt1_nativeObj, long pt2_nativeObj, long F_nativeObj);
+
+ // C++: int cv::estimateAffine3D(Mat src, Mat dst, Mat& out, Mat& inliers, double ransacThreshold = 3, double confidence = 0.99)
+ private static native int estimateAffine3D_0(long src_nativeObj, long dst_nativeObj, long out_nativeObj, long inliers_nativeObj, double ransacThreshold, double confidence);
+ private static native int estimateAffine3D_1(long src_nativeObj, long dst_nativeObj, long out_nativeObj, long inliers_nativeObj, double ransacThreshold);
+ private static native int estimateAffine3D_2(long src_nativeObj, long dst_nativeObj, long out_nativeObj, long inliers_nativeObj);
+
+ // C++: Mat cv::estimateAffine3D(Mat src, Mat dst, double* scale = nullptr, bool force_rotation = true)
+ private static native long estimateAffine3D_3(long src_nativeObj, long dst_nativeObj, double[] scale_out, boolean force_rotation);
+ private static native long estimateAffine3D_4(long src_nativeObj, long dst_nativeObj, double[] scale_out);
+ private static native long estimateAffine3D_5(long src_nativeObj, long dst_nativeObj);
+
+ // C++: int cv::estimateTranslation3D(Mat src, Mat dst, Mat& out, Mat& inliers, double ransacThreshold = 3, double confidence = 0.99)
+ private static native int estimateTranslation3D_0(long src_nativeObj, long dst_nativeObj, long out_nativeObj, long inliers_nativeObj, double ransacThreshold, double confidence);
+ private static native int estimateTranslation3D_1(long src_nativeObj, long dst_nativeObj, long out_nativeObj, long inliers_nativeObj, double ransacThreshold);
+ private static native int estimateTranslation3D_2(long src_nativeObj, long dst_nativeObj, long out_nativeObj, long inliers_nativeObj);
+
+ // C++: Mat cv::estimateAffine2D(Mat from, Mat to, Mat& inliers = Mat(), int method = RANSAC, double ransacReprojThreshold = 3, size_t maxIters = 2000, double confidence = 0.99, size_t refineIters = 10)
+ private static native long estimateAffine2D_0(long from_nativeObj, long to_nativeObj, long inliers_nativeObj, int method, double ransacReprojThreshold, long maxIters, double confidence, long refineIters);
+ private static native long estimateAffine2D_1(long from_nativeObj, long to_nativeObj, long inliers_nativeObj, int method, double ransacReprojThreshold, long maxIters, double confidence);
+ private static native long estimateAffine2D_2(long from_nativeObj, long to_nativeObj, long inliers_nativeObj, int method, double ransacReprojThreshold, long maxIters);
+ private static native long estimateAffine2D_3(long from_nativeObj, long to_nativeObj, long inliers_nativeObj, int method, double ransacReprojThreshold);
+ private static native long estimateAffine2D_4(long from_nativeObj, long to_nativeObj, long inliers_nativeObj, int method);
+ private static native long estimateAffine2D_5(long from_nativeObj, long to_nativeObj, long inliers_nativeObj);
+ private static native long estimateAffine2D_6(long from_nativeObj, long to_nativeObj);
+
+ // C++: Mat cv::estimateAffine2D(Mat pts1, Mat pts2, Mat& inliers, UsacParams params)
+ private static native long estimateAffine2D_7(long pts1_nativeObj, long pts2_nativeObj, long inliers_nativeObj, long params_nativeObj);
+
+ // C++: Mat cv::estimateAffinePartial2D(Mat from, Mat to, Mat& inliers = Mat(), int method = RANSAC, double ransacReprojThreshold = 3, size_t maxIters = 2000, double confidence = 0.99, size_t refineIters = 10)
+ private static native long estimateAffinePartial2D_0(long from_nativeObj, long to_nativeObj, long inliers_nativeObj, int method, double ransacReprojThreshold, long maxIters, double confidence, long refineIters);
+ private static native long estimateAffinePartial2D_1(long from_nativeObj, long to_nativeObj, long inliers_nativeObj, int method, double ransacReprojThreshold, long maxIters, double confidence);
+ private static native long estimateAffinePartial2D_2(long from_nativeObj, long to_nativeObj, long inliers_nativeObj, int method, double ransacReprojThreshold, long maxIters);
+ private static native long estimateAffinePartial2D_3(long from_nativeObj, long to_nativeObj, long inliers_nativeObj, int method, double ransacReprojThreshold);
+ private static native long estimateAffinePartial2D_4(long from_nativeObj, long to_nativeObj, long inliers_nativeObj, int method);
+ private static native long estimateAffinePartial2D_5(long from_nativeObj, long to_nativeObj, long inliers_nativeObj);
+ private static native long estimateAffinePartial2D_6(long from_nativeObj, long to_nativeObj);
+
+ // C++: int cv::decomposeHomographyMat(Mat H, Mat K, vector_Mat& rotations, vector_Mat& translations, vector_Mat& normals)
+ private static native int decomposeHomographyMat_0(long H_nativeObj, long K_nativeObj, long rotations_mat_nativeObj, long translations_mat_nativeObj, long normals_mat_nativeObj);
+
+ // C++: void cv::filterHomographyDecompByVisibleRefpoints(vector_Mat rotations, vector_Mat normals, Mat beforePoints, Mat afterPoints, Mat& possibleSolutions, Mat pointsMask = Mat())
+ private static native void filterHomographyDecompByVisibleRefpoints_0(long rotations_mat_nativeObj, long normals_mat_nativeObj, long beforePoints_nativeObj, long afterPoints_nativeObj, long possibleSolutions_nativeObj, long pointsMask_nativeObj);
+ private static native void filterHomographyDecompByVisibleRefpoints_1(long rotations_mat_nativeObj, long normals_mat_nativeObj, long beforePoints_nativeObj, long afterPoints_nativeObj, long possibleSolutions_nativeObj);
+
+ // C++: void cv::undistort(Mat src, Mat& dst, Mat cameraMatrix, Mat distCoeffs, Mat newCameraMatrix = Mat())
+ private static native void undistort_0(long src_nativeObj, long dst_nativeObj, long cameraMatrix_nativeObj, long distCoeffs_nativeObj, long newCameraMatrix_nativeObj);
+ private static native void undistort_1(long src_nativeObj, long dst_nativeObj, long cameraMatrix_nativeObj, long distCoeffs_nativeObj);
+
+ // C++: void cv::initUndistortRectifyMap(Mat cameraMatrix, Mat distCoeffs, Mat R, Mat newCameraMatrix, Size size, int m1type, Mat& map1, Mat& map2)
+ private static native void initUndistortRectifyMap_0(long cameraMatrix_nativeObj, long distCoeffs_nativeObj, long R_nativeObj, long newCameraMatrix_nativeObj, double size_width, double size_height, int m1type, long map1_nativeObj, long map2_nativeObj);
+
+ // C++: void cv::initInverseRectificationMap(Mat cameraMatrix, Mat distCoeffs, Mat R, Mat newCameraMatrix, Size size, int m1type, Mat& map1, Mat& map2)
+ private static native void initInverseRectificationMap_0(long cameraMatrix_nativeObj, long distCoeffs_nativeObj, long R_nativeObj, long newCameraMatrix_nativeObj, double size_width, double size_height, int m1type, long map1_nativeObj, long map2_nativeObj);
+
+ // C++: Mat cv::getDefaultNewCameraMatrix(Mat cameraMatrix, Size imgsize = Size(), bool centerPrincipalPoint = false)
+ private static native long getDefaultNewCameraMatrix_0(long cameraMatrix_nativeObj, double imgsize_width, double imgsize_height, boolean centerPrincipalPoint);
+ private static native long getDefaultNewCameraMatrix_1(long cameraMatrix_nativeObj, double imgsize_width, double imgsize_height);
+ private static native long getDefaultNewCameraMatrix_2(long cameraMatrix_nativeObj);
+
+ // C++: void cv::undistortPoints(vector_Point2f src, vector_Point2f& dst, Mat cameraMatrix, Mat distCoeffs, Mat R = Mat(), Mat P = Mat())
+ private static native void undistortPoints_0(long src_mat_nativeObj, long dst_mat_nativeObj, long cameraMatrix_nativeObj, long distCoeffs_nativeObj, long R_nativeObj, long P_nativeObj);
+ private static native void undistortPoints_1(long src_mat_nativeObj, long dst_mat_nativeObj, long cameraMatrix_nativeObj, long distCoeffs_nativeObj, long R_nativeObj);
+ private static native void undistortPoints_2(long src_mat_nativeObj, long dst_mat_nativeObj, long cameraMatrix_nativeObj, long distCoeffs_nativeObj);
+
+ // C++: void cv::undistortPoints(Mat src, Mat& dst, Mat cameraMatrix, Mat distCoeffs, Mat R, Mat P, TermCriteria criteria)
+ private static native void undistortPointsIter_0(long src_nativeObj, long dst_nativeObj, long cameraMatrix_nativeObj, long distCoeffs_nativeObj, long R_nativeObj, long P_nativeObj, int criteria_type, int criteria_maxCount, double criteria_epsilon);
+
+ // C++: void cv::undistortImagePoints(Mat src, Mat& dst, Mat cameraMatrix, Mat distCoeffs, TermCriteria arg1 = TermCriteria(TermCriteria::MAX_ITER + TermCriteria::EPS, 5, 0.01))
+ private static native void undistortImagePoints_0(long src_nativeObj, long dst_nativeObj, long cameraMatrix_nativeObj, long distCoeffs_nativeObj, int arg1_type, int arg1_maxCount, double arg1_epsilon);
+ private static native void undistortImagePoints_1(long src_nativeObj, long dst_nativeObj, long cameraMatrix_nativeObj, long distCoeffs_nativeObj);
+
+ // C++: void cv::fisheye::projectPoints(Mat objectPoints, Mat& imagePoints, Mat rvec, Mat tvec, Mat K, Mat D, double alpha = 0, Mat& jacobian = Mat())
+ private static native void fisheye_projectPoints_0(long objectPoints_nativeObj, long imagePoints_nativeObj, long rvec_nativeObj, long tvec_nativeObj, long K_nativeObj, long D_nativeObj, double alpha, long jacobian_nativeObj);
+ private static native void fisheye_projectPoints_1(long objectPoints_nativeObj, long imagePoints_nativeObj, long rvec_nativeObj, long tvec_nativeObj, long K_nativeObj, long D_nativeObj, double alpha);
+ private static native void fisheye_projectPoints_2(long objectPoints_nativeObj, long imagePoints_nativeObj, long rvec_nativeObj, long tvec_nativeObj, long K_nativeObj, long D_nativeObj);
+
+ // C++: void cv::fisheye::distortPoints(Mat undistorted, Mat& distorted, Mat K, Mat D, double alpha = 0)
+ private static native void fisheye_distortPoints_0(long undistorted_nativeObj, long distorted_nativeObj, long K_nativeObj, long D_nativeObj, double alpha);
+ private static native void fisheye_distortPoints_1(long undistorted_nativeObj, long distorted_nativeObj, long K_nativeObj, long D_nativeObj);
+
+ // C++: void cv::fisheye::undistortPoints(Mat distorted, Mat& undistorted, Mat K, Mat D, Mat R = Mat(), Mat P = Mat(), TermCriteria criteria = TermCriteria(TermCriteria::MAX_ITER + TermCriteria::EPS, 10, 1e-8))
+ private static native void fisheye_undistortPoints_0(long distorted_nativeObj, long undistorted_nativeObj, long K_nativeObj, long D_nativeObj, long R_nativeObj, long P_nativeObj, int criteria_type, int criteria_maxCount, double criteria_epsilon);
+ private static native void fisheye_undistortPoints_1(long distorted_nativeObj, long undistorted_nativeObj, long K_nativeObj, long D_nativeObj, long R_nativeObj, long P_nativeObj);
+ private static native void fisheye_undistortPoints_2(long distorted_nativeObj, long undistorted_nativeObj, long K_nativeObj, long D_nativeObj, long R_nativeObj);
+ private static native void fisheye_undistortPoints_3(long distorted_nativeObj, long undistorted_nativeObj, long K_nativeObj, long D_nativeObj);
+
+ // C++: void cv::fisheye::initUndistortRectifyMap(Mat K, Mat D, Mat R, Mat P, Size size, int m1type, Mat& map1, Mat& map2)
+ private static native void fisheye_initUndistortRectifyMap_0(long K_nativeObj, long D_nativeObj, long R_nativeObj, long P_nativeObj, double size_width, double size_height, int m1type, long map1_nativeObj, long map2_nativeObj);
+
+ // C++: void cv::fisheye::undistortImage(Mat distorted, Mat& undistorted, Mat K, Mat D, Mat Knew = cv::Mat(), Size new_size = Size())
+ private static native void fisheye_undistortImage_0(long distorted_nativeObj, long undistorted_nativeObj, long K_nativeObj, long D_nativeObj, long Knew_nativeObj, double new_size_width, double new_size_height);
+ private static native void fisheye_undistortImage_1(long distorted_nativeObj, long undistorted_nativeObj, long K_nativeObj, long D_nativeObj, long Knew_nativeObj);
+ private static native void fisheye_undistortImage_2(long distorted_nativeObj, long undistorted_nativeObj, long K_nativeObj, long D_nativeObj);
+
+ // C++: void cv::fisheye::estimateNewCameraMatrixForUndistortRectify(Mat K, Mat D, Size image_size, Mat R, Mat& P, double balance = 0.0, Size new_size = Size(), double fov_scale = 1.0)
+ private static native void fisheye_estimateNewCameraMatrixForUndistortRectify_0(long K_nativeObj, long D_nativeObj, double image_size_width, double image_size_height, long R_nativeObj, long P_nativeObj, double balance, double new_size_width, double new_size_height, double fov_scale);
+ private static native void fisheye_estimateNewCameraMatrixForUndistortRectify_1(long K_nativeObj, long D_nativeObj, double image_size_width, double image_size_height, long R_nativeObj, long P_nativeObj, double balance, double new_size_width, double new_size_height);
+ private static native void fisheye_estimateNewCameraMatrixForUndistortRectify_2(long K_nativeObj, long D_nativeObj, double image_size_width, double image_size_height, long R_nativeObj, long P_nativeObj, double balance);
+ private static native void fisheye_estimateNewCameraMatrixForUndistortRectify_3(long K_nativeObj, long D_nativeObj, double image_size_width, double image_size_height, long R_nativeObj, long P_nativeObj);
+
+ // C++: double cv::fisheye::calibrate(vector_Mat objectPoints, vector_Mat imagePoints, Size image_size, Mat& K, Mat& D, vector_Mat& rvecs, vector_Mat& tvecs, int flags = 0, TermCriteria criteria = TermCriteria(TermCriteria::COUNT + TermCriteria::EPS, 100, DBL_EPSILON))
+ private static native double fisheye_calibrate_0(long objectPoints_mat_nativeObj, long imagePoints_mat_nativeObj, double image_size_width, double image_size_height, long K_nativeObj, long D_nativeObj, long rvecs_mat_nativeObj, long tvecs_mat_nativeObj, int flags, int criteria_type, int criteria_maxCount, double criteria_epsilon);
+ private static native double fisheye_calibrate_1(long objectPoints_mat_nativeObj, long imagePoints_mat_nativeObj, double image_size_width, double image_size_height, long K_nativeObj, long D_nativeObj, long rvecs_mat_nativeObj, long tvecs_mat_nativeObj, int flags);
+ private static native double fisheye_calibrate_2(long objectPoints_mat_nativeObj, long imagePoints_mat_nativeObj, double image_size_width, double image_size_height, long K_nativeObj, long D_nativeObj, long rvecs_mat_nativeObj, long tvecs_mat_nativeObj);
+
+ // C++: void cv::fisheye::stereoRectify(Mat K1, Mat D1, Mat K2, Mat D2, Size imageSize, Mat R, Mat tvec, Mat& R1, Mat& R2, Mat& P1, Mat& P2, Mat& Q, int flags, Size newImageSize = Size(), double balance = 0.0, double fov_scale = 1.0)
+ private static native void fisheye_stereoRectify_0(long K1_nativeObj, long D1_nativeObj, long K2_nativeObj, long D2_nativeObj, double imageSize_width, double imageSize_height, long R_nativeObj, long tvec_nativeObj, long R1_nativeObj, long R2_nativeObj, long P1_nativeObj, long P2_nativeObj, long Q_nativeObj, int flags, double newImageSize_width, double newImageSize_height, double balance, double fov_scale);
+ private static native void fisheye_stereoRectify_1(long K1_nativeObj, long D1_nativeObj, long K2_nativeObj, long D2_nativeObj, double imageSize_width, double imageSize_height, long R_nativeObj, long tvec_nativeObj, long R1_nativeObj, long R2_nativeObj, long P1_nativeObj, long P2_nativeObj, long Q_nativeObj, int flags, double newImageSize_width, double newImageSize_height, double balance);
+ private static native void fisheye_stereoRectify_2(long K1_nativeObj, long D1_nativeObj, long K2_nativeObj, long D2_nativeObj, double imageSize_width, double imageSize_height, long R_nativeObj, long tvec_nativeObj, long R1_nativeObj, long R2_nativeObj, long P1_nativeObj, long P2_nativeObj, long Q_nativeObj, int flags, double newImageSize_width, double newImageSize_height);
+ private static native void fisheye_stereoRectify_3(long K1_nativeObj, long D1_nativeObj, long K2_nativeObj, long D2_nativeObj, double imageSize_width, double imageSize_height, long R_nativeObj, long tvec_nativeObj, long R1_nativeObj, long R2_nativeObj, long P1_nativeObj, long P2_nativeObj, long Q_nativeObj, int flags);
+
+ // C++: double cv::fisheye::stereoCalibrate(vector_Mat objectPoints, vector_Mat imagePoints1, vector_Mat imagePoints2, Mat& K1, Mat& D1, Mat& K2, Mat& D2, Size imageSize, Mat& R, Mat& T, vector_Mat& rvecs, vector_Mat& tvecs, int flags = fisheye::CALIB_FIX_INTRINSIC, TermCriteria criteria = TermCriteria(TermCriteria::COUNT + TermCriteria::EPS, 100, DBL_EPSILON))
+ private static native double fisheye_stereoCalibrate_0(long objectPoints_mat_nativeObj, long imagePoints1_mat_nativeObj, long imagePoints2_mat_nativeObj, long K1_nativeObj, long D1_nativeObj, long K2_nativeObj, long D2_nativeObj, double imageSize_width, double imageSize_height, long R_nativeObj, long T_nativeObj, long rvecs_mat_nativeObj, long tvecs_mat_nativeObj, int flags, int criteria_type, int criteria_maxCount, double criteria_epsilon);
+ private static native double fisheye_stereoCalibrate_1(long objectPoints_mat_nativeObj, long imagePoints1_mat_nativeObj, long imagePoints2_mat_nativeObj, long K1_nativeObj, long D1_nativeObj, long K2_nativeObj, long D2_nativeObj, double imageSize_width, double imageSize_height, long R_nativeObj, long T_nativeObj, long rvecs_mat_nativeObj, long tvecs_mat_nativeObj, int flags);
+ private static native double fisheye_stereoCalibrate_2(long objectPoints_mat_nativeObj, long imagePoints1_mat_nativeObj, long imagePoints2_mat_nativeObj, long K1_nativeObj, long D1_nativeObj, long K2_nativeObj, long D2_nativeObj, double imageSize_width, double imageSize_height, long R_nativeObj, long T_nativeObj, long rvecs_mat_nativeObj, long tvecs_mat_nativeObj);
+
+ // C++: double cv::fisheye::stereoCalibrate(vector_Mat objectPoints, vector_Mat imagePoints1, vector_Mat imagePoints2, Mat& K1, Mat& D1, Mat& K2, Mat& D2, Size imageSize, Mat& R, Mat& T, int flags = fisheye::CALIB_FIX_INTRINSIC, TermCriteria criteria = TermCriteria(TermCriteria::COUNT + TermCriteria::EPS, 100, DBL_EPSILON))
+ private static native double fisheye_stereoCalibrate_3(long objectPoints_mat_nativeObj, long imagePoints1_mat_nativeObj, long imagePoints2_mat_nativeObj, long K1_nativeObj, long D1_nativeObj, long K2_nativeObj, long D2_nativeObj, double imageSize_width, double imageSize_height, long R_nativeObj, long T_nativeObj, int flags, int criteria_type, int criteria_maxCount, double criteria_epsilon);
+ private static native double fisheye_stereoCalibrate_4(long objectPoints_mat_nativeObj, long imagePoints1_mat_nativeObj, long imagePoints2_mat_nativeObj, long K1_nativeObj, long D1_nativeObj, long K2_nativeObj, long D2_nativeObj, double imageSize_width, double imageSize_height, long R_nativeObj, long T_nativeObj, int flags);
+ private static native double fisheye_stereoCalibrate_5(long objectPoints_mat_nativeObj, long imagePoints1_mat_nativeObj, long imagePoints2_mat_nativeObj, long K1_nativeObj, long D1_nativeObj, long K2_nativeObj, long D2_nativeObj, double imageSize_width, double imageSize_height, long R_nativeObj, long T_nativeObj);
+
+}
diff --git a/ZPI-App/opencv/java/src/org/opencv/calib3d/StereoBM.java b/ZPI-App/opencv/java/src/org/opencv/calib3d/StereoBM.java
new file mode 100644
index 000000000..d8275082f
--- /dev/null
+++ b/ZPI-App/opencv/java/src/org/opencv/calib3d/StereoBM.java
@@ -0,0 +1,294 @@
+//
+// This file is auto-generated. Please don't modify it!
+//
+package org.opencv.calib3d;
+
+import org.opencv.calib3d.StereoBM;
+import org.opencv.calib3d.StereoMatcher;
+import org.opencv.core.Rect;
+
+// C++: class StereoBM
+/**
+ * Class for computing stereo correspondence using the block matching algorithm, introduced and
+ * contributed to OpenCV by K. Konolige.
+ */
+public class StereoBM extends StereoMatcher {
+
+ protected StereoBM(long addr) { super(addr); }
+
+ // internal usage only
+ public static StereoBM __fromPtr__(long addr) { return new StereoBM(addr); }
+
+ // C++: enum
+ public static final int
+ PREFILTER_NORMALIZED_RESPONSE = 0,
+ PREFILTER_XSOBEL = 1;
+
+
+ //
+ // C++: int cv::StereoBM::getPreFilterType()
+ //
+
+ public int getPreFilterType() {
+ return getPreFilterType_0(nativeObj);
+ }
+
+
+ //
+ // C++: void cv::StereoBM::setPreFilterType(int preFilterType)
+ //
+
+ public void setPreFilterType(int preFilterType) {
+ setPreFilterType_0(nativeObj, preFilterType);
+ }
+
+
+ //
+ // C++: int cv::StereoBM::getPreFilterSize()
+ //
+
+ public int getPreFilterSize() {
+ return getPreFilterSize_0(nativeObj);
+ }
+
+
+ //
+ // C++: void cv::StereoBM::setPreFilterSize(int preFilterSize)
+ //
+
+ public void setPreFilterSize(int preFilterSize) {
+ setPreFilterSize_0(nativeObj, preFilterSize);
+ }
+
+
+ //
+ // C++: int cv::StereoBM::getPreFilterCap()
+ //
+
+ public int getPreFilterCap() {
+ return getPreFilterCap_0(nativeObj);
+ }
+
+
+ //
+ // C++: void cv::StereoBM::setPreFilterCap(int preFilterCap)
+ //
+
+ public void setPreFilterCap(int preFilterCap) {
+ setPreFilterCap_0(nativeObj, preFilterCap);
+ }
+
+
+ //
+ // C++: int cv::StereoBM::getTextureThreshold()
+ //
+
+ public int getTextureThreshold() {
+ return getTextureThreshold_0(nativeObj);
+ }
+
+
+ //
+ // C++: void cv::StereoBM::setTextureThreshold(int textureThreshold)
+ //
+
+ public void setTextureThreshold(int textureThreshold) {
+ setTextureThreshold_0(nativeObj, textureThreshold);
+ }
+
+
+ //
+ // C++: int cv::StereoBM::getUniquenessRatio()
+ //
+
+ public int getUniquenessRatio() {
+ return getUniquenessRatio_0(nativeObj);
+ }
+
+
+ //
+ // C++: void cv::StereoBM::setUniquenessRatio(int uniquenessRatio)
+ //
+
+ public void setUniquenessRatio(int uniquenessRatio) {
+ setUniquenessRatio_0(nativeObj, uniquenessRatio);
+ }
+
+
+ //
+ // C++: int cv::StereoBM::getSmallerBlockSize()
+ //
+
+ public int getSmallerBlockSize() {
+ return getSmallerBlockSize_0(nativeObj);
+ }
+
+
+ //
+ // C++: void cv::StereoBM::setSmallerBlockSize(int blockSize)
+ //
+
+ public void setSmallerBlockSize(int blockSize) {
+ setSmallerBlockSize_0(nativeObj, blockSize);
+ }
+
+
+ //
+ // C++: Rect cv::StereoBM::getROI1()
+ //
+
+ public Rect getROI1() {
+ return new Rect(getROI1_0(nativeObj));
+ }
+
+
+ //
+ // C++: void cv::StereoBM::setROI1(Rect roi1)
+ //
+
+ public void setROI1(Rect roi1) {
+ setROI1_0(nativeObj, roi1.x, roi1.y, roi1.width, roi1.height);
+ }
+
+
+ //
+ // C++: Rect cv::StereoBM::getROI2()
+ //
+
+ public Rect getROI2() {
+ return new Rect(getROI2_0(nativeObj));
+ }
+
+
+ //
+ // C++: void cv::StereoBM::setROI2(Rect roi2)
+ //
+
+ public void setROI2(Rect roi2) {
+ setROI2_0(nativeObj, roi2.x, roi2.y, roi2.width, roi2.height);
+ }
+
+
+ //
+ // C++: static Ptr_StereoBM cv::StereoBM::create(int numDisparities = 0, int blockSize = 21)
+ //
+
+ /**
+ * Creates StereoBM object
+ *
+ * @param numDisparities the disparity search range. For each pixel algorithm will find the best
+ * disparity from 0 (default minimum disparity) to numDisparities. The search range can then be
+ * shifted by changing the minimum disparity.
+ * @param blockSize the linear size of the blocks compared by the algorithm. The size should be odd
+ * (as the block is centered at the current pixel). Larger block size implies smoother, though less
+ * accurate disparity map. Smaller block size gives more detailed disparity map, but there is higher
+ * chance for algorithm to find a wrong correspondence.
+ *
+ * The function create StereoBM object. You can then call StereoBM::compute() to compute disparity for
+ * a specific stereo pair.
+ * @return automatically generated
+ */
+ public static StereoBM create(int numDisparities, int blockSize) {
+ return StereoBM.__fromPtr__(create_0(numDisparities, blockSize));
+ }
+
+ /**
+ * Creates StereoBM object
+ *
+ * @param numDisparities the disparity search range. For each pixel algorithm will find the best
+ * disparity from 0 (default minimum disparity) to numDisparities. The search range can then be
+ * shifted by changing the minimum disparity.
+ * (as the block is centered at the current pixel). Larger block size implies smoother, though less
+ * accurate disparity map. Smaller block size gives more detailed disparity map, but there is higher
+ * chance for algorithm to find a wrong correspondence.
+ *
+ * The function create StereoBM object. You can then call StereoBM::compute() to compute disparity for
+ * a specific stereo pair.
+ * @return automatically generated
+ */
+ public static StereoBM create(int numDisparities) {
+ return StereoBM.__fromPtr__(create_1(numDisparities));
+ }
+
+ /**
+ * Creates StereoBM object
+ *
+ * disparity from 0 (default minimum disparity) to numDisparities. The search range can then be
+ * shifted by changing the minimum disparity.
+ * (as the block is centered at the current pixel). Larger block size implies smoother, though less
+ * accurate disparity map. Smaller block size gives more detailed disparity map, but there is higher
+ * chance for algorithm to find a wrong correspondence.
+ *
+ * The function create StereoBM object. You can then call StereoBM::compute() to compute disparity for
+ * a specific stereo pair.
+ * @return automatically generated
+ */
+ public static StereoBM create() {
+ return StereoBM.__fromPtr__(create_2());
+ }
+
+
+ @Override
+ protected void finalize() throws Throwable {
+ delete(nativeObj);
+ }
+
+
+
+ // C++: int cv::StereoBM::getPreFilterType()
+ private static native int getPreFilterType_0(long nativeObj);
+
+ // C++: void cv::StereoBM::setPreFilterType(int preFilterType)
+ private static native void setPreFilterType_0(long nativeObj, int preFilterType);
+
+ // C++: int cv::StereoBM::getPreFilterSize()
+ private static native int getPreFilterSize_0(long nativeObj);
+
+ // C++: void cv::StereoBM::setPreFilterSize(int preFilterSize)
+ private static native void setPreFilterSize_0(long nativeObj, int preFilterSize);
+
+ // C++: int cv::StereoBM::getPreFilterCap()
+ private static native int getPreFilterCap_0(long nativeObj);
+
+ // C++: void cv::StereoBM::setPreFilterCap(int preFilterCap)
+ private static native void setPreFilterCap_0(long nativeObj, int preFilterCap);
+
+ // C++: int cv::StereoBM::getTextureThreshold()
+ private static native int getTextureThreshold_0(long nativeObj);
+
+ // C++: void cv::StereoBM::setTextureThreshold(int textureThreshold)
+ private static native void setTextureThreshold_0(long nativeObj, int textureThreshold);
+
+ // C++: int cv::StereoBM::getUniquenessRatio()
+ private static native int getUniquenessRatio_0(long nativeObj);
+
+ // C++: void cv::StereoBM::setUniquenessRatio(int uniquenessRatio)
+ private static native void setUniquenessRatio_0(long nativeObj, int uniquenessRatio);
+
+ // C++: int cv::StereoBM::getSmallerBlockSize()
+ private static native int getSmallerBlockSize_0(long nativeObj);
+
+ // C++: void cv::StereoBM::setSmallerBlockSize(int blockSize)
+ private static native void setSmallerBlockSize_0(long nativeObj, int blockSize);
+
+ // C++: Rect cv::StereoBM::getROI1()
+ private static native double[] getROI1_0(long nativeObj);
+
+ // C++: void cv::StereoBM::setROI1(Rect roi1)
+ private static native void setROI1_0(long nativeObj, int roi1_x, int roi1_y, int roi1_width, int roi1_height);
+
+ // C++: Rect cv::StereoBM::getROI2()
+ private static native double[] getROI2_0(long nativeObj);
+
+ // C++: void cv::StereoBM::setROI2(Rect roi2)
+ private static native void setROI2_0(long nativeObj, int roi2_x, int roi2_y, int roi2_width, int roi2_height);
+
+ // C++: static Ptr_StereoBM cv::StereoBM::create(int numDisparities = 0, int blockSize = 21)
+ private static native long create_0(int numDisparities, int blockSize);
+ private static native long create_1(int numDisparities);
+ private static native long create_2();
+
+ // native support for java finalize()
+ private static native void delete(long nativeObj);
+
+}
diff --git a/ZPI-App/opencv/java/src/org/opencv/calib3d/StereoMatcher.java b/ZPI-App/opencv/java/src/org/opencv/calib3d/StereoMatcher.java
new file mode 100644
index 000000000..9e4c87e88
--- /dev/null
+++ b/ZPI-App/opencv/java/src/org/opencv/calib3d/StereoMatcher.java
@@ -0,0 +1,201 @@
+//
+// This file is auto-generated. Please don't modify it!
+//
+package org.opencv.calib3d;
+
+import org.opencv.core.Algorithm;
+import org.opencv.core.Mat;
+
+// C++: class StereoMatcher
+/**
+ * The base class for stereo correspondence algorithms.
+ */
+public class StereoMatcher extends Algorithm {
+
+ protected StereoMatcher(long addr) { super(addr); }
+
+ // internal usage only
+ public static StereoMatcher __fromPtr__(long addr) { return new StereoMatcher(addr); }
+
+ // C++: enum
+ public static final int
+ DISP_SHIFT = 4,
+ DISP_SCALE = (1 << DISP_SHIFT);
+
+
+ //
+ // C++: void cv::StereoMatcher::compute(Mat left, Mat right, Mat& disparity)
+ //
+
+ /**
+ * Computes disparity map for the specified stereo pair
+ *
+ * @param left Left 8-bit single-channel image.
+ * @param right Right image of the same size and the same type as the left one.
+ * @param disparity Output disparity map. It has the same size as the input images. Some algorithms,
+ * like StereoBM or StereoSGBM compute 16-bit fixed-point disparity map (where each disparity value
+ * has 4 fractional bits), whereas other algorithms output 32-bit floating-point disparity map.
+ */
+ public void compute(Mat left, Mat right, Mat disparity) {
+ compute_0(nativeObj, left.nativeObj, right.nativeObj, disparity.nativeObj);
+ }
+
+
+ //
+ // C++: int cv::StereoMatcher::getMinDisparity()
+ //
+
+ public int getMinDisparity() {
+ return getMinDisparity_0(nativeObj);
+ }
+
+
+ //
+ // C++: void cv::StereoMatcher::setMinDisparity(int minDisparity)
+ //
+
+ public void setMinDisparity(int minDisparity) {
+ setMinDisparity_0(nativeObj, minDisparity);
+ }
+
+
+ //
+ // C++: int cv::StereoMatcher::getNumDisparities()
+ //
+
+ public int getNumDisparities() {
+ return getNumDisparities_0(nativeObj);
+ }
+
+
+ //
+ // C++: void cv::StereoMatcher::setNumDisparities(int numDisparities)
+ //
+
+ public void setNumDisparities(int numDisparities) {
+ setNumDisparities_0(nativeObj, numDisparities);
+ }
+
+
+ //
+ // C++: int cv::StereoMatcher::getBlockSize()
+ //
+
+ public int getBlockSize() {
+ return getBlockSize_0(nativeObj);
+ }
+
+
+ //
+ // C++: void cv::StereoMatcher::setBlockSize(int blockSize)
+ //
+
+ public void setBlockSize(int blockSize) {
+ setBlockSize_0(nativeObj, blockSize);
+ }
+
+
+ //
+ // C++: int cv::StereoMatcher::getSpeckleWindowSize()
+ //
+
+ public int getSpeckleWindowSize() {
+ return getSpeckleWindowSize_0(nativeObj);
+ }
+
+
+ //
+ // C++: void cv::StereoMatcher::setSpeckleWindowSize(int speckleWindowSize)
+ //
+
+ public void setSpeckleWindowSize(int speckleWindowSize) {
+ setSpeckleWindowSize_0(nativeObj, speckleWindowSize);
+ }
+
+
+ //
+ // C++: int cv::StereoMatcher::getSpeckleRange()
+ //
+
+ public int getSpeckleRange() {
+ return getSpeckleRange_0(nativeObj);
+ }
+
+
+ //
+ // C++: void cv::StereoMatcher::setSpeckleRange(int speckleRange)
+ //
+
+ public void setSpeckleRange(int speckleRange) {
+ setSpeckleRange_0(nativeObj, speckleRange);
+ }
+
+
+ //
+ // C++: int cv::StereoMatcher::getDisp12MaxDiff()
+ //
+
+ public int getDisp12MaxDiff() {
+ return getDisp12MaxDiff_0(nativeObj);
+ }
+
+
+ //
+ // C++: void cv::StereoMatcher::setDisp12MaxDiff(int disp12MaxDiff)
+ //
+
+ public void setDisp12MaxDiff(int disp12MaxDiff) {
+ setDisp12MaxDiff_0(nativeObj, disp12MaxDiff);
+ }
+
+
+ @Override
+ protected void finalize() throws Throwable {
+ delete(nativeObj);
+ }
+
+
+
+ // C++: void cv::StereoMatcher::compute(Mat left, Mat right, Mat& disparity)
+ private static native void compute_0(long nativeObj, long left_nativeObj, long right_nativeObj, long disparity_nativeObj);
+
+ // C++: int cv::StereoMatcher::getMinDisparity()
+ private static native int getMinDisparity_0(long nativeObj);
+
+ // C++: void cv::StereoMatcher::setMinDisparity(int minDisparity)
+ private static native void setMinDisparity_0(long nativeObj, int minDisparity);
+
+ // C++: int cv::StereoMatcher::getNumDisparities()
+ private static native int getNumDisparities_0(long nativeObj);
+
+ // C++: void cv::StereoMatcher::setNumDisparities(int numDisparities)
+ private static native void setNumDisparities_0(long nativeObj, int numDisparities);
+
+ // C++: int cv::StereoMatcher::getBlockSize()
+ private static native int getBlockSize_0(long nativeObj);
+
+ // C++: void cv::StereoMatcher::setBlockSize(int blockSize)
+ private static native void setBlockSize_0(long nativeObj, int blockSize);
+
+ // C++: int cv::StereoMatcher::getSpeckleWindowSize()
+ private static native int getSpeckleWindowSize_0(long nativeObj);
+
+ // C++: void cv::StereoMatcher::setSpeckleWindowSize(int speckleWindowSize)
+ private static native void setSpeckleWindowSize_0(long nativeObj, int speckleWindowSize);
+
+ // C++: int cv::StereoMatcher::getSpeckleRange()
+ private static native int getSpeckleRange_0(long nativeObj);
+
+ // C++: void cv::StereoMatcher::setSpeckleRange(int speckleRange)
+ private static native void setSpeckleRange_0(long nativeObj, int speckleRange);
+
+ // C++: int cv::StereoMatcher::getDisp12MaxDiff()
+ private static native int getDisp12MaxDiff_0(long nativeObj);
+
+ // C++: void cv::StereoMatcher::setDisp12MaxDiff(int disp12MaxDiff)
+ private static native void setDisp12MaxDiff_0(long nativeObj, int disp12MaxDiff);
+
+ // native support for java finalize()
+ private static native void delete(long nativeObj);
+
+}
diff --git a/ZPI-App/opencv/java/src/org/opencv/calib3d/StereoSGBM.java b/ZPI-App/opencv/java/src/org/opencv/calib3d/StereoSGBM.java
new file mode 100644
index 000000000..30b2f0a4b
--- /dev/null
+++ b/ZPI-App/opencv/java/src/org/opencv/calib3d/StereoSGBM.java
@@ -0,0 +1,657 @@
+//
+// This file is auto-generated. Please don't modify it!
+//
+package org.opencv.calib3d;
+
+import org.opencv.calib3d.StereoMatcher;
+import org.opencv.calib3d.StereoSGBM;
+
+// C++: class StereoSGBM
+/**
+ * The class implements the modified H. Hirschmuller algorithm CITE: HH08 that differs from the original
+ * one as follows:
+ *
+ *
+ *
+ * By default, the algorithm is single-pass, which means that you consider only 5 directions
+ * instead of 8. Set mode=StereoSGBM::MODE_HH in createStereoSGBM to run the full variant of the
+ * algorithm but beware that it may consume a lot of memory.
+ *
+ *
+ * The algorithm matches blocks, not individual pixels. Though, setting blockSize=1 reduces the
+ * blocks to single pixels.
+ *
+ *
+ * Mutual information cost function is not implemented. Instead, a simpler Birchfield-Tomasi
+ * sub-pixel metric from CITE: BT98 is used. Though, the color images are supported as well.
+ *
+ *
+ * Some pre- and post- processing steps from K. Konolige algorithm StereoBM are included, for
+ * example: pre-filtering (StereoBM::PREFILTER_XSOBEL type) and post-filtering (uniqueness
+ * check, quadratic interpolation and speckle filtering).
+ *
+ *
+ *
+ * Note:
+ *
+ *
+ * (Python) An example illustrating the use of the StereoSGBM matching algorithm can be found
+ * at opencv_source_code/samples/python/stereo_match.py
+ *
+ *
+ */
+public class StereoSGBM extends StereoMatcher {
+
+ protected StereoSGBM(long addr) { super(addr); }
+
+ // internal usage only
+ public static StereoSGBM __fromPtr__(long addr) { return new StereoSGBM(addr); }
+
+ // C++: enum
+ public static final int
+ MODE_SGBM = 0,
+ MODE_HH = 1,
+ MODE_SGBM_3WAY = 2,
+ MODE_HH4 = 3;
+
+
+ //
+ // C++: int cv::StereoSGBM::getPreFilterCap()
+ //
+
+ public int getPreFilterCap() {
+ return getPreFilterCap_0(nativeObj);
+ }
+
+
+ //
+ // C++: void cv::StereoSGBM::setPreFilterCap(int preFilterCap)
+ //
+
+ public void setPreFilterCap(int preFilterCap) {
+ setPreFilterCap_0(nativeObj, preFilterCap);
+ }
+
+
+ //
+ // C++: int cv::StereoSGBM::getUniquenessRatio()
+ //
+
+ public int getUniquenessRatio() {
+ return getUniquenessRatio_0(nativeObj);
+ }
+
+
+ //
+ // C++: void cv::StereoSGBM::setUniquenessRatio(int uniquenessRatio)
+ //
+
+ public void setUniquenessRatio(int uniquenessRatio) {
+ setUniquenessRatio_0(nativeObj, uniquenessRatio);
+ }
+
+
+ //
+ // C++: int cv::StereoSGBM::getP1()
+ //
+
+ public int getP1() {
+ return getP1_0(nativeObj);
+ }
+
+
+ //
+ // C++: void cv::StereoSGBM::setP1(int P1)
+ //
+
+ public void setP1(int P1) {
+ setP1_0(nativeObj, P1);
+ }
+
+
+ //
+ // C++: int cv::StereoSGBM::getP2()
+ //
+
+ public int getP2() {
+ return getP2_0(nativeObj);
+ }
+
+
+ //
+ // C++: void cv::StereoSGBM::setP2(int P2)
+ //
+
+ public void setP2(int P2) {
+ setP2_0(nativeObj, P2);
+ }
+
+
+ //
+ // C++: int cv::StereoSGBM::getMode()
+ //
+
+ public int getMode() {
+ return getMode_0(nativeObj);
+ }
+
+
+ //
+ // C++: void cv::StereoSGBM::setMode(int mode)
+ //
+
+ public void setMode(int mode) {
+ setMode_0(nativeObj, mode);
+ }
+
+
+ //
+ // C++: static Ptr_StereoSGBM cv::StereoSGBM::create(int minDisparity = 0, int numDisparities = 16, int blockSize = 3, int P1 = 0, int P2 = 0, int disp12MaxDiff = 0, int preFilterCap = 0, int uniquenessRatio = 0, int speckleWindowSize = 0, int speckleRange = 0, int mode = StereoSGBM::MODE_SGBM)
+ //
+
+ /**
+ * Creates StereoSGBM object
+ *
+ * @param minDisparity Minimum possible disparity value. Normally, it is zero but sometimes
+ * rectification algorithms can shift images, so this parameter needs to be adjusted accordingly.
+ * @param numDisparities Maximum disparity minus minimum disparity. The value is always greater than
+ * zero. In the current implementation, this parameter must be divisible by 16.
+ * @param blockSize Matched block size. It must be an odd number >=1 . Normally, it should be
+ * somewhere in the 3..11 range.
+ * @param P1 The first parameter controlling the disparity smoothness. See below.
+ * @param P2 The second parameter controlling the disparity smoothness. The larger the values are,
+ * the smoother the disparity is. P1 is the penalty on the disparity change by plus or minus 1
+ * between neighbor pixels. P2 is the penalty on the disparity change by more than 1 between neighbor
+ * pixels. The algorithm requires P2 > P1 . See stereo_match.cpp sample where some reasonably good
+ * P1 and P2 values are shown (like 8\*number_of_image_channels\*blockSize\*blockSize and
+ * 32\*number_of_image_channels\*blockSize\*blockSize , respectively).
+ * @param disp12MaxDiff Maximum allowed difference (in integer pixel units) in the left-right
+ * disparity check. Set it to a non-positive value to disable the check.
+ * @param preFilterCap Truncation value for the prefiltered image pixels. The algorithm first
+ * computes x-derivative at each pixel and clips its value by [-preFilterCap, preFilterCap] interval.
+ * The result values are passed to the Birchfield-Tomasi pixel cost function.
+ * @param uniquenessRatio Margin in percentage by which the best (minimum) computed cost function
+ * value should "win" the second best value to consider the found match correct. Normally, a value
+ * within the 5-15 range is good enough.
+ * @param speckleWindowSize Maximum size of smooth disparity regions to consider their noise speckles
+ * and invalidate. Set it to 0 to disable speckle filtering. Otherwise, set it somewhere in the
+ * 50-200 range.
+ * @param speckleRange Maximum disparity variation within each connected component. If you do speckle
+ * filtering, set the parameter to a positive value, it will be implicitly multiplied by 16.
+ * Normally, 1 or 2 is good enough.
+ * @param mode Set it to StereoSGBM::MODE_HH to run the full-scale two-pass dynamic programming
+ * algorithm. It will consume O(W\*H\*numDisparities) bytes, which is large for 640x480 stereo and
+ * huge for HD-size pictures. By default, it is set to false .
+ *
+ * The first constructor initializes StereoSGBM with all the default parameters. So, you only have to
+ * set StereoSGBM::numDisparities at minimum. The second constructor enables you to set each parameter
+ * to a custom value.
+ * @return automatically generated
+ */
+ public static StereoSGBM create(int minDisparity, int numDisparities, int blockSize, int P1, int P2, int disp12MaxDiff, int preFilterCap, int uniquenessRatio, int speckleWindowSize, int speckleRange, int mode) {
+ return StereoSGBM.__fromPtr__(create_0(minDisparity, numDisparities, blockSize, P1, P2, disp12MaxDiff, preFilterCap, uniquenessRatio, speckleWindowSize, speckleRange, mode));
+ }
+
+ /**
+ * Creates StereoSGBM object
+ *
+ * @param minDisparity Minimum possible disparity value. Normally, it is zero but sometimes
+ * rectification algorithms can shift images, so this parameter needs to be adjusted accordingly.
+ * @param numDisparities Maximum disparity minus minimum disparity. The value is always greater than
+ * zero. In the current implementation, this parameter must be divisible by 16.
+ * @param blockSize Matched block size. It must be an odd number >=1 . Normally, it should be
+ * somewhere in the 3..11 range.
+ * @param P1 The first parameter controlling the disparity smoothness. See below.
+ * @param P2 The second parameter controlling the disparity smoothness. The larger the values are,
+ * the smoother the disparity is. P1 is the penalty on the disparity change by plus or minus 1
+ * between neighbor pixels. P2 is the penalty on the disparity change by more than 1 between neighbor
+ * pixels. The algorithm requires P2 > P1 . See stereo_match.cpp sample where some reasonably good
+ * P1 and P2 values are shown (like 8\*number_of_image_channels\*blockSize\*blockSize and
+ * 32\*number_of_image_channels\*blockSize\*blockSize , respectively).
+ * @param disp12MaxDiff Maximum allowed difference (in integer pixel units) in the left-right
+ * disparity check. Set it to a non-positive value to disable the check.
+ * @param preFilterCap Truncation value for the prefiltered image pixels. The algorithm first
+ * computes x-derivative at each pixel and clips its value by [-preFilterCap, preFilterCap] interval.
+ * The result values are passed to the Birchfield-Tomasi pixel cost function.
+ * @param uniquenessRatio Margin in percentage by which the best (minimum) computed cost function
+ * value should "win" the second best value to consider the found match correct. Normally, a value
+ * within the 5-15 range is good enough.
+ * @param speckleWindowSize Maximum size of smooth disparity regions to consider their noise speckles
+ * and invalidate. Set it to 0 to disable speckle filtering. Otherwise, set it somewhere in the
+ * 50-200 range.
+ * @param speckleRange Maximum disparity variation within each connected component. If you do speckle
+ * filtering, set the parameter to a positive value, it will be implicitly multiplied by 16.
+ * Normally, 1 or 2 is good enough.
+ * algorithm. It will consume O(W\*H\*numDisparities) bytes, which is large for 640x480 stereo and
+ * huge for HD-size pictures. By default, it is set to false .
+ *
+ * The first constructor initializes StereoSGBM with all the default parameters. So, you only have to
+ * set StereoSGBM::numDisparities at minimum. The second constructor enables you to set each parameter
+ * to a custom value.
+ * @return automatically generated
+ */
+ public static StereoSGBM create(int minDisparity, int numDisparities, int blockSize, int P1, int P2, int disp12MaxDiff, int preFilterCap, int uniquenessRatio, int speckleWindowSize, int speckleRange) {
+ return StereoSGBM.__fromPtr__(create_1(minDisparity, numDisparities, blockSize, P1, P2, disp12MaxDiff, preFilterCap, uniquenessRatio, speckleWindowSize, speckleRange));
+ }
+
+ /**
+ * Creates StereoSGBM object
+ *
+ * @param minDisparity Minimum possible disparity value. Normally, it is zero but sometimes
+ * rectification algorithms can shift images, so this parameter needs to be adjusted accordingly.
+ * @param numDisparities Maximum disparity minus minimum disparity. The value is always greater than
+ * zero. In the current implementation, this parameter must be divisible by 16.
+ * @param blockSize Matched block size. It must be an odd number >=1 . Normally, it should be
+ * somewhere in the 3..11 range.
+ * @param P1 The first parameter controlling the disparity smoothness. See below.
+ * @param P2 The second parameter controlling the disparity smoothness. The larger the values are,
+ * the smoother the disparity is. P1 is the penalty on the disparity change by plus or minus 1
+ * between neighbor pixels. P2 is the penalty on the disparity change by more than 1 between neighbor
+ * pixels. The algorithm requires P2 > P1 . See stereo_match.cpp sample where some reasonably good
+ * P1 and P2 values are shown (like 8\*number_of_image_channels\*blockSize\*blockSize and
+ * 32\*number_of_image_channels\*blockSize\*blockSize , respectively).
+ * @param disp12MaxDiff Maximum allowed difference (in integer pixel units) in the left-right
+ * disparity check. Set it to a non-positive value to disable the check.
+ * @param preFilterCap Truncation value for the prefiltered image pixels. The algorithm first
+ * computes x-derivative at each pixel and clips its value by [-preFilterCap, preFilterCap] interval.
+ * The result values are passed to the Birchfield-Tomasi pixel cost function.
+ * @param uniquenessRatio Margin in percentage by which the best (minimum) computed cost function
+ * value should "win" the second best value to consider the found match correct. Normally, a value
+ * within the 5-15 range is good enough.
+ * @param speckleWindowSize Maximum size of smooth disparity regions to consider their noise speckles
+ * and invalidate. Set it to 0 to disable speckle filtering. Otherwise, set it somewhere in the
+ * 50-200 range.
+ * filtering, set the parameter to a positive value, it will be implicitly multiplied by 16.
+ * Normally, 1 or 2 is good enough.
+ * algorithm. It will consume O(W\*H\*numDisparities) bytes, which is large for 640x480 stereo and
+ * huge for HD-size pictures. By default, it is set to false .
+ *
+ * The first constructor initializes StereoSGBM with all the default parameters. So, you only have to
+ * set StereoSGBM::numDisparities at minimum. The second constructor enables you to set each parameter
+ * to a custom value.
+ * @return automatically generated
+ */
+ public static StereoSGBM create(int minDisparity, int numDisparities, int blockSize, int P1, int P2, int disp12MaxDiff, int preFilterCap, int uniquenessRatio, int speckleWindowSize) {
+ return StereoSGBM.__fromPtr__(create_2(minDisparity, numDisparities, blockSize, P1, P2, disp12MaxDiff, preFilterCap, uniquenessRatio, speckleWindowSize));
+ }
+
+ /**
+ * Creates StereoSGBM object
+ *
+ * @param minDisparity Minimum possible disparity value. Normally, it is zero but sometimes
+ * rectification algorithms can shift images, so this parameter needs to be adjusted accordingly.
+ * @param numDisparities Maximum disparity minus minimum disparity. The value is always greater than
+ * zero. In the current implementation, this parameter must be divisible by 16.
+ * @param blockSize Matched block size. It must be an odd number >=1 . Normally, it should be
+ * somewhere in the 3..11 range.
+ * @param P1 The first parameter controlling the disparity smoothness. See below.
+ * @param P2 The second parameter controlling the disparity smoothness. The larger the values are,
+ * the smoother the disparity is. P1 is the penalty on the disparity change by plus or minus 1
+ * between neighbor pixels. P2 is the penalty on the disparity change by more than 1 between neighbor
+ * pixels. The algorithm requires P2 > P1 . See stereo_match.cpp sample where some reasonably good
+ * P1 and P2 values are shown (like 8\*number_of_image_channels\*blockSize\*blockSize and
+ * 32\*number_of_image_channels\*blockSize\*blockSize , respectively).
+ * @param disp12MaxDiff Maximum allowed difference (in integer pixel units) in the left-right
+ * disparity check. Set it to a non-positive value to disable the check.
+ * @param preFilterCap Truncation value for the prefiltered image pixels. The algorithm first
+ * computes x-derivative at each pixel and clips its value by [-preFilterCap, preFilterCap] interval.
+ * The result values are passed to the Birchfield-Tomasi pixel cost function.
+ * @param uniquenessRatio Margin in percentage by which the best (minimum) computed cost function
+ * value should "win" the second best value to consider the found match correct. Normally, a value
+ * within the 5-15 range is good enough.
+ * and invalidate. Set it to 0 to disable speckle filtering. Otherwise, set it somewhere in the
+ * 50-200 range.
+ * filtering, set the parameter to a positive value, it will be implicitly multiplied by 16.
+ * Normally, 1 or 2 is good enough.
+ * algorithm. It will consume O(W\*H\*numDisparities) bytes, which is large for 640x480 stereo and
+ * huge for HD-size pictures. By default, it is set to false .
+ *
+ * The first constructor initializes StereoSGBM with all the default parameters. So, you only have to
+ * set StereoSGBM::numDisparities at minimum. The second constructor enables you to set each parameter
+ * to a custom value.
+ * @return automatically generated
+ */
+ public static StereoSGBM create(int minDisparity, int numDisparities, int blockSize, int P1, int P2, int disp12MaxDiff, int preFilterCap, int uniquenessRatio) {
+ return StereoSGBM.__fromPtr__(create_3(minDisparity, numDisparities, blockSize, P1, P2, disp12MaxDiff, preFilterCap, uniquenessRatio));
+ }
+
+ /**
+ * Creates StereoSGBM object
+ *
+ * @param minDisparity Minimum possible disparity value. Normally, it is zero but sometimes
+ * rectification algorithms can shift images, so this parameter needs to be adjusted accordingly.
+ * @param numDisparities Maximum disparity minus minimum disparity. The value is always greater than
+ * zero. In the current implementation, this parameter must be divisible by 16.
+ * @param blockSize Matched block size. It must be an odd number >=1 . Normally, it should be
+ * somewhere in the 3..11 range.
+ * @param P1 The first parameter controlling the disparity smoothness. See below.
+ * @param P2 The second parameter controlling the disparity smoothness. The larger the values are,
+ * the smoother the disparity is. P1 is the penalty on the disparity change by plus or minus 1
+ * between neighbor pixels. P2 is the penalty on the disparity change by more than 1 between neighbor
+ * pixels. The algorithm requires P2 > P1 . See stereo_match.cpp sample where some reasonably good
+ * P1 and P2 values are shown (like 8\*number_of_image_channels\*blockSize\*blockSize and
+ * 32\*number_of_image_channels\*blockSize\*blockSize , respectively).
+ * @param disp12MaxDiff Maximum allowed difference (in integer pixel units) in the left-right
+ * disparity check. Set it to a non-positive value to disable the check.
+ * @param preFilterCap Truncation value for the prefiltered image pixels. The algorithm first
+ * computes x-derivative at each pixel and clips its value by [-preFilterCap, preFilterCap] interval.
+ * The result values are passed to the Birchfield-Tomasi pixel cost function.
+ * value should "win" the second best value to consider the found match correct. Normally, a value
+ * within the 5-15 range is good enough.
+ * and invalidate. Set it to 0 to disable speckle filtering. Otherwise, set it somewhere in the
+ * 50-200 range.
+ * filtering, set the parameter to a positive value, it will be implicitly multiplied by 16.
+ * Normally, 1 or 2 is good enough.
+ * algorithm. It will consume O(W\*H\*numDisparities) bytes, which is large for 640x480 stereo and
+ * huge for HD-size pictures. By default, it is set to false .
+ *
+ * The first constructor initializes StereoSGBM with all the default parameters. So, you only have to
+ * set StereoSGBM::numDisparities at minimum. The second constructor enables you to set each parameter
+ * to a custom value.
+ * @return automatically generated
+ */
+ public static StereoSGBM create(int minDisparity, int numDisparities, int blockSize, int P1, int P2, int disp12MaxDiff, int preFilterCap) {
+ return StereoSGBM.__fromPtr__(create_4(minDisparity, numDisparities, blockSize, P1, P2, disp12MaxDiff, preFilterCap));
+ }
+
+ /**
+ * Creates StereoSGBM object
+ *
+ * @param minDisparity Minimum possible disparity value. Normally, it is zero but sometimes
+ * rectification algorithms can shift images, so this parameter needs to be adjusted accordingly.
+ * @param numDisparities Maximum disparity minus minimum disparity. The value is always greater than
+ * zero. In the current implementation, this parameter must be divisible by 16.
+ * @param blockSize Matched block size. It must be an odd number >=1 . Normally, it should be
+ * somewhere in the 3..11 range.
+ * @param P1 The first parameter controlling the disparity smoothness. See below.
+ * @param P2 The second parameter controlling the disparity smoothness. The larger the values are,
+ * the smoother the disparity is. P1 is the penalty on the disparity change by plus or minus 1
+ * between neighbor pixels. P2 is the penalty on the disparity change by more than 1 between neighbor
+ * pixels. The algorithm requires P2 > P1 . See stereo_match.cpp sample where some reasonably good
+ * P1 and P2 values are shown (like 8\*number_of_image_channels\*blockSize\*blockSize and
+ * 32\*number_of_image_channels\*blockSize\*blockSize , respectively).
+ * @param disp12MaxDiff Maximum allowed difference (in integer pixel units) in the left-right
+ * disparity check. Set it to a non-positive value to disable the check.
+ * computes x-derivative at each pixel and clips its value by [-preFilterCap, preFilterCap] interval.
+ * The result values are passed to the Birchfield-Tomasi pixel cost function.
+ * value should "win" the second best value to consider the found match correct. Normally, a value
+ * within the 5-15 range is good enough.
+ * and invalidate. Set it to 0 to disable speckle filtering. Otherwise, set it somewhere in the
+ * 50-200 range.
+ * filtering, set the parameter to a positive value, it will be implicitly multiplied by 16.
+ * Normally, 1 or 2 is good enough.
+ * algorithm. It will consume O(W\*H\*numDisparities) bytes, which is large for 640x480 stereo and
+ * huge for HD-size pictures. By default, it is set to false .
+ *
+ * The first constructor initializes StereoSGBM with all the default parameters. So, you only have to
+ * set StereoSGBM::numDisparities at minimum. The second constructor enables you to set each parameter
+ * to a custom value.
+ * @return automatically generated
+ */
+ public static StereoSGBM create(int minDisparity, int numDisparities, int blockSize, int P1, int P2, int disp12MaxDiff) {
+ return StereoSGBM.__fromPtr__(create_5(minDisparity, numDisparities, blockSize, P1, P2, disp12MaxDiff));
+ }
+
+ /**
+ * Creates StereoSGBM object
+ *
+ * @param minDisparity Minimum possible disparity value. Normally, it is zero but sometimes
+ * rectification algorithms can shift images, so this parameter needs to be adjusted accordingly.
+ * @param numDisparities Maximum disparity minus minimum disparity. The value is always greater than
+ * zero. In the current implementation, this parameter must be divisible by 16.
+ * @param blockSize Matched block size. It must be an odd number >=1 . Normally, it should be
+ * somewhere in the 3..11 range.
+ * @param P1 The first parameter controlling the disparity smoothness. See below.
+ * @param P2 The second parameter controlling the disparity smoothness. The larger the values are,
+ * the smoother the disparity is. P1 is the penalty on the disparity change by plus or minus 1
+ * between neighbor pixels. P2 is the penalty on the disparity change by more than 1 between neighbor
+ * pixels. The algorithm requires P2 > P1 . See stereo_match.cpp sample where some reasonably good
+ * P1 and P2 values are shown (like 8\*number_of_image_channels\*blockSize\*blockSize and
+ * 32\*number_of_image_channels\*blockSize\*blockSize , respectively).
+ * disparity check. Set it to a non-positive value to disable the check.
+ * computes x-derivative at each pixel and clips its value by [-preFilterCap, preFilterCap] interval.
+ * The result values are passed to the Birchfield-Tomasi pixel cost function.
+ * value should "win" the second best value to consider the found match correct. Normally, a value
+ * within the 5-15 range is good enough.
+ * and invalidate. Set it to 0 to disable speckle filtering. Otherwise, set it somewhere in the
+ * 50-200 range.
+ * filtering, set the parameter to a positive value, it will be implicitly multiplied by 16.
+ * Normally, 1 or 2 is good enough.
+ * algorithm. It will consume O(W\*H\*numDisparities) bytes, which is large for 640x480 stereo and
+ * huge for HD-size pictures. By default, it is set to false .
+ *
+ * The first constructor initializes StereoSGBM with all the default parameters. So, you only have to
+ * set StereoSGBM::numDisparities at minimum. The second constructor enables you to set each parameter
+ * to a custom value.
+ * @return automatically generated
+ */
+ public static StereoSGBM create(int minDisparity, int numDisparities, int blockSize, int P1, int P2) {
+ return StereoSGBM.__fromPtr__(create_6(minDisparity, numDisparities, blockSize, P1, P2));
+ }
+
+ /**
+ * Creates StereoSGBM object
+ *
+ * @param minDisparity Minimum possible disparity value. Normally, it is zero but sometimes
+ * rectification algorithms can shift images, so this parameter needs to be adjusted accordingly.
+ * @param numDisparities Maximum disparity minus minimum disparity. The value is always greater than
+ * zero. In the current implementation, this parameter must be divisible by 16.
+ * @param blockSize Matched block size. It must be an odd number >=1 . Normally, it should be
+ * somewhere in the 3..11 range.
+ * @param P1 The first parameter controlling the disparity smoothness. See below.
+ * the smoother the disparity is. P1 is the penalty on the disparity change by plus or minus 1
+ * between neighbor pixels. P2 is the penalty on the disparity change by more than 1 between neighbor
+ * pixels. The algorithm requires P2 > P1 . See stereo_match.cpp sample where some reasonably good
+ * P1 and P2 values are shown (like 8\*number_of_image_channels\*blockSize\*blockSize and
+ * 32\*number_of_image_channels\*blockSize\*blockSize , respectively).
+ * disparity check. Set it to a non-positive value to disable the check.
+ * computes x-derivative at each pixel and clips its value by [-preFilterCap, preFilterCap] interval.
+ * The result values are passed to the Birchfield-Tomasi pixel cost function.
+ * value should "win" the second best value to consider the found match correct. Normally, a value
+ * within the 5-15 range is good enough.
+ * and invalidate. Set it to 0 to disable speckle filtering. Otherwise, set it somewhere in the
+ * 50-200 range.
+ * filtering, set the parameter to a positive value, it will be implicitly multiplied by 16.
+ * Normally, 1 or 2 is good enough.
+ * algorithm. It will consume O(W\*H\*numDisparities) bytes, which is large for 640x480 stereo and
+ * huge for HD-size pictures. By default, it is set to false .
+ *
+ * The first constructor initializes StereoSGBM with all the default parameters. So, you only have to
+ * set StereoSGBM::numDisparities at minimum. The second constructor enables you to set each parameter
+ * to a custom value.
+ * @return automatically generated
+ */
+ public static StereoSGBM create(int minDisparity, int numDisparities, int blockSize, int P1) {
+ return StereoSGBM.__fromPtr__(create_7(minDisparity, numDisparities, blockSize, P1));
+ }
+
+ /**
+ * Creates StereoSGBM object
+ *
+ * @param minDisparity Minimum possible disparity value. Normally, it is zero but sometimes
+ * rectification algorithms can shift images, so this parameter needs to be adjusted accordingly.
+ * @param numDisparities Maximum disparity minus minimum disparity. The value is always greater than
+ * zero. In the current implementation, this parameter must be divisible by 16.
+ * @param blockSize Matched block size. It must be an odd number >=1 . Normally, it should be
+ * somewhere in the 3..11 range.
+ * the smoother the disparity is. P1 is the penalty on the disparity change by plus or minus 1
+ * between neighbor pixels. P2 is the penalty on the disparity change by more than 1 between neighbor
+ * pixels. The algorithm requires P2 > P1 . See stereo_match.cpp sample where some reasonably good
+ * P1 and P2 values are shown (like 8\*number_of_image_channels\*blockSize\*blockSize and
+ * 32\*number_of_image_channels\*blockSize\*blockSize , respectively).
+ * disparity check. Set it to a non-positive value to disable the check.
+ * computes x-derivative at each pixel and clips its value by [-preFilterCap, preFilterCap] interval.
+ * The result values are passed to the Birchfield-Tomasi pixel cost function.
+ * value should "win" the second best value to consider the found match correct. Normally, a value
+ * within the 5-15 range is good enough.
+ * and invalidate. Set it to 0 to disable speckle filtering. Otherwise, set it somewhere in the
+ * 50-200 range.
+ * filtering, set the parameter to a positive value, it will be implicitly multiplied by 16.
+ * Normally, 1 or 2 is good enough.
+ * algorithm. It will consume O(W\*H\*numDisparities) bytes, which is large for 640x480 stereo and
+ * huge for HD-size pictures. By default, it is set to false .
+ *
+ * The first constructor initializes StereoSGBM with all the default parameters. So, you only have to
+ * set StereoSGBM::numDisparities at minimum. The second constructor enables you to set each parameter
+ * to a custom value.
+ * @return automatically generated
+ */
+ public static StereoSGBM create(int minDisparity, int numDisparities, int blockSize) {
+ return StereoSGBM.__fromPtr__(create_8(minDisparity, numDisparities, blockSize));
+ }
+
+ /**
+ * Creates StereoSGBM object
+ *
+ * @param minDisparity Minimum possible disparity value. Normally, it is zero but sometimes
+ * rectification algorithms can shift images, so this parameter needs to be adjusted accordingly.
+ * @param numDisparities Maximum disparity minus minimum disparity. The value is always greater than
+ * zero. In the current implementation, this parameter must be divisible by 16.
+ * somewhere in the 3..11 range.
+ * the smoother the disparity is. P1 is the penalty on the disparity change by plus or minus 1
+ * between neighbor pixels. P2 is the penalty on the disparity change by more than 1 between neighbor
+ * pixels. The algorithm requires P2 > P1 . See stereo_match.cpp sample where some reasonably good
+ * P1 and P2 values are shown (like 8\*number_of_image_channels\*blockSize\*blockSize and
+ * 32\*number_of_image_channels\*blockSize\*blockSize , respectively).
+ * disparity check. Set it to a non-positive value to disable the check.
+ * computes x-derivative at each pixel and clips its value by [-preFilterCap, preFilterCap] interval.
+ * The result values are passed to the Birchfield-Tomasi pixel cost function.
+ * value should "win" the second best value to consider the found match correct. Normally, a value
+ * within the 5-15 range is good enough.
+ * and invalidate. Set it to 0 to disable speckle filtering. Otherwise, set it somewhere in the
+ * 50-200 range.
+ * filtering, set the parameter to a positive value, it will be implicitly multiplied by 16.
+ * Normally, 1 or 2 is good enough.
+ * algorithm. It will consume O(W\*H\*numDisparities) bytes, which is large for 640x480 stereo and
+ * huge for HD-size pictures. By default, it is set to false .
+ *
+ * The first constructor initializes StereoSGBM with all the default parameters. So, you only have to
+ * set StereoSGBM::numDisparities at minimum. The second constructor enables you to set each parameter
+ * to a custom value.
+ * @return automatically generated
+ */
+ public static StereoSGBM create(int minDisparity, int numDisparities) {
+ return StereoSGBM.__fromPtr__(create_9(minDisparity, numDisparities));
+ }
+
+ /**
+ * Creates StereoSGBM object
+ *
+ * @param minDisparity Minimum possible disparity value. Normally, it is zero but sometimes
+ * rectification algorithms can shift images, so this parameter needs to be adjusted accordingly.
+ * zero. In the current implementation, this parameter must be divisible by 16.
+ * somewhere in the 3..11 range.
+ * the smoother the disparity is. P1 is the penalty on the disparity change by plus or minus 1
+ * between neighbor pixels. P2 is the penalty on the disparity change by more than 1 between neighbor
+ * pixels. The algorithm requires P2 > P1 . See stereo_match.cpp sample where some reasonably good
+ * P1 and P2 values are shown (like 8\*number_of_image_channels\*blockSize\*blockSize and
+ * 32\*number_of_image_channels\*blockSize\*blockSize , respectively).
+ * disparity check. Set it to a non-positive value to disable the check.
+ * computes x-derivative at each pixel and clips its value by [-preFilterCap, preFilterCap] interval.
+ * The result values are passed to the Birchfield-Tomasi pixel cost function.
+ * value should "win" the second best value to consider the found match correct. Normally, a value
+ * within the 5-15 range is good enough.
+ * and invalidate. Set it to 0 to disable speckle filtering. Otherwise, set it somewhere in the
+ * 50-200 range.
+ * filtering, set the parameter to a positive value, it will be implicitly multiplied by 16.
+ * Normally, 1 or 2 is good enough.
+ * algorithm. It will consume O(W\*H\*numDisparities) bytes, which is large for 640x480 stereo and
+ * huge for HD-size pictures. By default, it is set to false .
+ *
+ * The first constructor initializes StereoSGBM with all the default parameters. So, you only have to
+ * set StereoSGBM::numDisparities at minimum. The second constructor enables you to set each parameter
+ * to a custom value.
+ * @return automatically generated
+ */
+ public static StereoSGBM create(int minDisparity) {
+ return StereoSGBM.__fromPtr__(create_10(minDisparity));
+ }
+
+ /**
+ * Creates StereoSGBM object
+ *
+ * rectification algorithms can shift images, so this parameter needs to be adjusted accordingly.
+ * zero. In the current implementation, this parameter must be divisible by 16.
+ * somewhere in the 3..11 range.
+ * the smoother the disparity is. P1 is the penalty on the disparity change by plus or minus 1
+ * between neighbor pixels. P2 is the penalty on the disparity change by more than 1 between neighbor
+ * pixels. The algorithm requires P2 > P1 . See stereo_match.cpp sample where some reasonably good
+ * P1 and P2 values are shown (like 8\*number_of_image_channels\*blockSize\*blockSize and
+ * 32\*number_of_image_channels\*blockSize\*blockSize , respectively).
+ * disparity check. Set it to a non-positive value to disable the check.
+ * computes x-derivative at each pixel and clips its value by [-preFilterCap, preFilterCap] interval.
+ * The result values are passed to the Birchfield-Tomasi pixel cost function.
+ * value should "win" the second best value to consider the found match correct. Normally, a value
+ * within the 5-15 range is good enough.
+ * and invalidate. Set it to 0 to disable speckle filtering. Otherwise, set it somewhere in the
+ * 50-200 range.
+ * filtering, set the parameter to a positive value, it will be implicitly multiplied by 16.
+ * Normally, 1 or 2 is good enough.
+ * algorithm. It will consume O(W\*H\*numDisparities) bytes, which is large for 640x480 stereo and
+ * huge for HD-size pictures. By default, it is set to false .
+ *
+ * The first constructor initializes StereoSGBM with all the default parameters. So, you only have to
+ * set StereoSGBM::numDisparities at minimum. The second constructor enables you to set each parameter
+ * to a custom value.
+ * @return automatically generated
+ */
+ public static StereoSGBM create() {
+ return StereoSGBM.__fromPtr__(create_11());
+ }
+
+
+ @Override
+ protected void finalize() throws Throwable {
+ delete(nativeObj);
+ }
+
+
+
+ // C++: int cv::StereoSGBM::getPreFilterCap()
+ private static native int getPreFilterCap_0(long nativeObj);
+
+ // C++: void cv::StereoSGBM::setPreFilterCap(int preFilterCap)
+ private static native void setPreFilterCap_0(long nativeObj, int preFilterCap);
+
+ // C++: int cv::StereoSGBM::getUniquenessRatio()
+ private static native int getUniquenessRatio_0(long nativeObj);
+
+ // C++: void cv::StereoSGBM::setUniquenessRatio(int uniquenessRatio)
+ private static native void setUniquenessRatio_0(long nativeObj, int uniquenessRatio);
+
+ // C++: int cv::StereoSGBM::getP1()
+ private static native int getP1_0(long nativeObj);
+
+ // C++: void cv::StereoSGBM::setP1(int P1)
+ private static native void setP1_0(long nativeObj, int P1);
+
+ // C++: int cv::StereoSGBM::getP2()
+ private static native int getP2_0(long nativeObj);
+
+ // C++: void cv::StereoSGBM::setP2(int P2)
+ private static native void setP2_0(long nativeObj, int P2);
+
+ // C++: int cv::StereoSGBM::getMode()
+ private static native int getMode_0(long nativeObj);
+
+ // C++: void cv::StereoSGBM::setMode(int mode)
+ private static native void setMode_0(long nativeObj, int mode);
+
+ // C++: static Ptr_StereoSGBM cv::StereoSGBM::create(int minDisparity = 0, int numDisparities = 16, int blockSize = 3, int P1 = 0, int P2 = 0, int disp12MaxDiff = 0, int preFilterCap = 0, int uniquenessRatio = 0, int speckleWindowSize = 0, int speckleRange = 0, int mode = StereoSGBM::MODE_SGBM)
+ private static native long create_0(int minDisparity, int numDisparities, int blockSize, int P1, int P2, int disp12MaxDiff, int preFilterCap, int uniquenessRatio, int speckleWindowSize, int speckleRange, int mode);
+ private static native long create_1(int minDisparity, int numDisparities, int blockSize, int P1, int P2, int disp12MaxDiff, int preFilterCap, int uniquenessRatio, int speckleWindowSize, int speckleRange);
+ private static native long create_2(int minDisparity, int numDisparities, int blockSize, int P1, int P2, int disp12MaxDiff, int preFilterCap, int uniquenessRatio, int speckleWindowSize);
+ private static native long create_3(int minDisparity, int numDisparities, int blockSize, int P1, int P2, int disp12MaxDiff, int preFilterCap, int uniquenessRatio);
+ private static native long create_4(int minDisparity, int numDisparities, int blockSize, int P1, int P2, int disp12MaxDiff, int preFilterCap);
+ private static native long create_5(int minDisparity, int numDisparities, int blockSize, int P1, int P2, int disp12MaxDiff);
+ private static native long create_6(int minDisparity, int numDisparities, int blockSize, int P1, int P2);
+ private static native long create_7(int minDisparity, int numDisparities, int blockSize, int P1);
+ private static native long create_8(int minDisparity, int numDisparities, int blockSize);
+ private static native long create_9(int minDisparity, int numDisparities);
+ private static native long create_10(int minDisparity);
+ private static native long create_11();
+
+ // native support for java finalize()
+ private static native void delete(long nativeObj);
+
+}
diff --git a/ZPI-App/opencv/java/src/org/opencv/calib3d/UsacParams.java b/ZPI-App/opencv/java/src/org/opencv/calib3d/UsacParams.java
new file mode 100644
index 000000000..1d4358375
--- /dev/null
+++ b/ZPI-App/opencv/java/src/org/opencv/calib3d/UsacParams.java
@@ -0,0 +1,354 @@
+//
+// This file is auto-generated. Please don't modify it!
+//
+package org.opencv.calib3d;
+
+
+
+// C++: class UsacParams
+
+public class UsacParams {
+
+ protected final long nativeObj;
+ protected UsacParams(long addr) { nativeObj = addr; }
+
+ public long getNativeObjAddr() { return nativeObj; }
+
+ // internal usage only
+ public static UsacParams __fromPtr__(long addr) { return new UsacParams(addr); }
+
+ //
+ // C++: cv::UsacParams::UsacParams()
+ //
+
+ public UsacParams() {
+ nativeObj = UsacParams_0();
+ }
+
+
+ //
+ // C++: double UsacParams::confidence
+ //
+
+ public double get_confidence() {
+ return get_confidence_0(nativeObj);
+ }
+
+
+ //
+ // C++: void UsacParams::confidence
+ //
+
+ public void set_confidence(double confidence) {
+ set_confidence_0(nativeObj, confidence);
+ }
+
+
+ //
+ // C++: bool UsacParams::isParallel
+ //
+
+ public boolean get_isParallel() {
+ return get_isParallel_0(nativeObj);
+ }
+
+
+ //
+ // C++: void UsacParams::isParallel
+ //
+
+ public void set_isParallel(boolean isParallel) {
+ set_isParallel_0(nativeObj, isParallel);
+ }
+
+
+ //
+ // C++: int UsacParams::loIterations
+ //
+
+ public int get_loIterations() {
+ return get_loIterations_0(nativeObj);
+ }
+
+
+ //
+ // C++: void UsacParams::loIterations
+ //
+
+ public void set_loIterations(int loIterations) {
+ set_loIterations_0(nativeObj, loIterations);
+ }
+
+
+ //
+ // C++: LocalOptimMethod UsacParams::loMethod
+ //
+
+ public int get_loMethod() {
+ return get_loMethod_0(nativeObj);
+ }
+
+
+ //
+ // C++: void UsacParams::loMethod
+ //
+
+ public void set_loMethod(int loMethod) {
+ set_loMethod_0(nativeObj, loMethod);
+ }
+
+
+ //
+ // C++: int UsacParams::loSampleSize
+ //
+
+ public int get_loSampleSize() {
+ return get_loSampleSize_0(nativeObj);
+ }
+
+
+ //
+ // C++: void UsacParams::loSampleSize
+ //
+
+ public void set_loSampleSize(int loSampleSize) {
+ set_loSampleSize_0(nativeObj, loSampleSize);
+ }
+
+
+ //
+ // C++: int UsacParams::maxIterations
+ //
+
+ public int get_maxIterations() {
+ return get_maxIterations_0(nativeObj);
+ }
+
+
+ //
+ // C++: void UsacParams::maxIterations
+ //
+
+ public void set_maxIterations(int maxIterations) {
+ set_maxIterations_0(nativeObj, maxIterations);
+ }
+
+
+ //
+ // C++: NeighborSearchMethod UsacParams::neighborsSearch
+ //
+
+ public int get_neighborsSearch() {
+ return get_neighborsSearch_0(nativeObj);
+ }
+
+
+ //
+ // C++: void UsacParams::neighborsSearch
+ //
+
+ public void set_neighborsSearch(int neighborsSearch) {
+ set_neighborsSearch_0(nativeObj, neighborsSearch);
+ }
+
+
+ //
+ // C++: int UsacParams::randomGeneratorState
+ //
+
+ public int get_randomGeneratorState() {
+ return get_randomGeneratorState_0(nativeObj);
+ }
+
+
+ //
+ // C++: void UsacParams::randomGeneratorState
+ //
+
+ public void set_randomGeneratorState(int randomGeneratorState) {
+ set_randomGeneratorState_0(nativeObj, randomGeneratorState);
+ }
+
+
+ //
+ // C++: SamplingMethod UsacParams::sampler
+ //
+
+ public int get_sampler() {
+ return get_sampler_0(nativeObj);
+ }
+
+
+ //
+ // C++: void UsacParams::sampler
+ //
+
+ public void set_sampler(int sampler) {
+ set_sampler_0(nativeObj, sampler);
+ }
+
+
+ //
+ // C++: ScoreMethod UsacParams::score
+ //
+
+ public int get_score() {
+ return get_score_0(nativeObj);
+ }
+
+
+ //
+ // C++: void UsacParams::score
+ //
+
+ public void set_score(int score) {
+ set_score_0(nativeObj, score);
+ }
+
+
+ //
+ // C++: double UsacParams::threshold
+ //
+
+ public double get_threshold() {
+ return get_threshold_0(nativeObj);
+ }
+
+
+ //
+ // C++: void UsacParams::threshold
+ //
+
+ public void set_threshold(double threshold) {
+ set_threshold_0(nativeObj, threshold);
+ }
+
+
+ //
+ // C++: PolishingMethod UsacParams::final_polisher
+ //
+
+ public int get_final_polisher() {
+ return get_final_polisher_0(nativeObj);
+ }
+
+
+ //
+ // C++: void UsacParams::final_polisher
+ //
+
+ public void set_final_polisher(int final_polisher) {
+ set_final_polisher_0(nativeObj, final_polisher);
+ }
+
+
+ //
+ // C++: int UsacParams::final_polisher_iterations
+ //
+
+ public int get_final_polisher_iterations() {
+ return get_final_polisher_iterations_0(nativeObj);
+ }
+
+
+ //
+ // C++: void UsacParams::final_polisher_iterations
+ //
+
+ public void set_final_polisher_iterations(int final_polisher_iterations) {
+ set_final_polisher_iterations_0(nativeObj, final_polisher_iterations);
+ }
+
+
+ @Override
+ protected void finalize() throws Throwable {
+ delete(nativeObj);
+ }
+
+
+
+ // C++: cv::UsacParams::UsacParams()
+ private static native long UsacParams_0();
+
+ // C++: double UsacParams::confidence
+ private static native double get_confidence_0(long nativeObj);
+
+ // C++: void UsacParams::confidence
+ private static native void set_confidence_0(long nativeObj, double confidence);
+
+ // C++: bool UsacParams::isParallel
+ private static native boolean get_isParallel_0(long nativeObj);
+
+ // C++: void UsacParams::isParallel
+ private static native void set_isParallel_0(long nativeObj, boolean isParallel);
+
+ // C++: int UsacParams::loIterations
+ private static native int get_loIterations_0(long nativeObj);
+
+ // C++: void UsacParams::loIterations
+ private static native void set_loIterations_0(long nativeObj, int loIterations);
+
+ // C++: LocalOptimMethod UsacParams::loMethod
+ private static native int get_loMethod_0(long nativeObj);
+
+ // C++: void UsacParams::loMethod
+ private static native void set_loMethod_0(long nativeObj, int loMethod);
+
+ // C++: int UsacParams::loSampleSize
+ private static native int get_loSampleSize_0(long nativeObj);
+
+ // C++: void UsacParams::loSampleSize
+ private static native void set_loSampleSize_0(long nativeObj, int loSampleSize);
+
+ // C++: int UsacParams::maxIterations
+ private static native int get_maxIterations_0(long nativeObj);
+
+ // C++: void UsacParams::maxIterations
+ private static native void set_maxIterations_0(long nativeObj, int maxIterations);
+
+ // C++: NeighborSearchMethod UsacParams::neighborsSearch
+ private static native int get_neighborsSearch_0(long nativeObj);
+
+ // C++: void UsacParams::neighborsSearch
+ private static native void set_neighborsSearch_0(long nativeObj, int neighborsSearch);
+
+ // C++: int UsacParams::randomGeneratorState
+ private static native int get_randomGeneratorState_0(long nativeObj);
+
+ // C++: void UsacParams::randomGeneratorState
+ private static native void set_randomGeneratorState_0(long nativeObj, int randomGeneratorState);
+
+ // C++: SamplingMethod UsacParams::sampler
+ private static native int get_sampler_0(long nativeObj);
+
+ // C++: void UsacParams::sampler
+ private static native void set_sampler_0(long nativeObj, int sampler);
+
+ // C++: ScoreMethod UsacParams::score
+ private static native int get_score_0(long nativeObj);
+
+ // C++: void UsacParams::score
+ private static native void set_score_0(long nativeObj, int score);
+
+ // C++: double UsacParams::threshold
+ private static native double get_threshold_0(long nativeObj);
+
+ // C++: void UsacParams::threshold
+ private static native void set_threshold_0(long nativeObj, double threshold);
+
+ // C++: PolishingMethod UsacParams::final_polisher
+ private static native int get_final_polisher_0(long nativeObj);
+
+ // C++: void UsacParams::final_polisher
+ private static native void set_final_polisher_0(long nativeObj, int final_polisher);
+
+ // C++: int UsacParams::final_polisher_iterations
+ private static native int get_final_polisher_iterations_0(long nativeObj);
+
+ // C++: void UsacParams::final_polisher_iterations
+ private static native void set_final_polisher_iterations_0(long nativeObj, int final_polisher_iterations);
+
+ // native support for java finalize()
+ private static native void delete(long nativeObj);
+
+}
diff --git a/ZPI-App/opencv/java/src/org/opencv/core/Algorithm.java b/ZPI-App/opencv/java/src/org/opencv/core/Algorithm.java
new file mode 100644
index 000000000..cde24fddd
--- /dev/null
+++ b/ZPI-App/opencv/java/src/org/opencv/core/Algorithm.java
@@ -0,0 +1,127 @@
+//
+// This file is auto-generated. Please don't modify it!
+//
+package org.opencv.core;
+
+
+
+// C++: class Algorithm
+/**
+ * This is a base class for all more or less complex algorithms in OpenCV
+ *
+ * especially for classes of algorithms, for which there can be multiple implementations. The examples
+ * are stereo correspondence (for which there are algorithms like block matching, semi-global block
+ * matching, graph-cut etc.), background subtraction (which can be done using mixture-of-gaussians
+ * models, codebook-based algorithm etc.), optical flow (block matching, Lucas-Kanade, Horn-Schunck
+ * etc.).
+ *
+ * Here is example of SimpleBlobDetector use in your application via Algorithm interface:
+ * SNIPPET: snippets/core_various.cpp Algorithm
+ */
+public class Algorithm {
+
+ protected final long nativeObj;
+ protected Algorithm(long addr) { nativeObj = addr; }
+
+ public long getNativeObjAddr() { return nativeObj; }
+
+ // internal usage only
+ public static Algorithm __fromPtr__(long addr) { return new Algorithm(addr); }
+
+ //
+ // C++: void cv::Algorithm::clear()
+ //
+
+ /**
+ * Clears the algorithm state
+ */
+ public void clear() {
+ clear_0(nativeObj);
+ }
+
+
+ //
+ // C++: void cv::Algorithm::write(FileStorage fs)
+ //
+
+ // Unknown type 'FileStorage' (I), skipping the function
+
+
+ //
+ // C++: void cv::Algorithm::write(FileStorage fs, String name)
+ //
+
+ // Unknown type 'FileStorage' (I), skipping the function
+
+
+ //
+ // C++: void cv::Algorithm::read(FileNode fn)
+ //
+
+ // Unknown type 'FileNode' (I), skipping the function
+
+
+ //
+ // C++: bool cv::Algorithm::empty()
+ //
+
+ /**
+ * Returns true if the Algorithm is empty (e.g. in the very beginning or after unsuccessful read
+ * @return automatically generated
+ */
+ public boolean empty() {
+ return empty_0(nativeObj);
+ }
+
+
+ //
+ // C++: void cv::Algorithm::save(String filename)
+ //
+
+ /**
+ * Saves the algorithm to a file.
+ * In order to make this method work, the derived class must implement Algorithm::write(FileStorage& fs).
+ * @param filename automatically generated
+ */
+ public void save(String filename) {
+ save_0(nativeObj, filename);
+ }
+
+
+ //
+ // C++: String cv::Algorithm::getDefaultName()
+ //
+
+ /**
+ * Returns the algorithm string identifier.
+ * This string is used as top level xml/yml node tag when the object is saved to a file or string.
+ * @return automatically generated
+ */
+ public String getDefaultName() {
+ return getDefaultName_0(nativeObj);
+ }
+
+
+ @Override
+ protected void finalize() throws Throwable {
+ delete(nativeObj);
+ }
+
+
+
+ // C++: void cv::Algorithm::clear()
+ private static native void clear_0(long nativeObj);
+
+ // C++: bool cv::Algorithm::empty()
+ private static native boolean empty_0(long nativeObj);
+
+ // C++: void cv::Algorithm::save(String filename)
+ private static native void save_0(long nativeObj, String filename);
+
+ // C++: String cv::Algorithm::getDefaultName()
+ private static native String getDefaultName_0(long nativeObj);
+
+ // native support for java finalize()
+ private static native void delete(long nativeObj);
+
+}
diff --git a/ZPI-App/opencv/java/src/org/opencv/core/Core.java b/ZPI-App/opencv/java/src/org/opencv/core/Core.java
new file mode 100644
index 000000000..e42b5a7f5
--- /dev/null
+++ b/ZPI-App/opencv/java/src/org/opencv/core/Core.java
@@ -0,0 +1,6402 @@
+//
+// This file is auto-generated. Please don't modify it!
+//
+package org.opencv.core;
+
+import java.util.ArrayList;
+import java.util.List;
+import org.opencv.core.Mat;
+import org.opencv.core.MatOfDouble;
+import org.opencv.core.MatOfInt;
+import org.opencv.core.Scalar;
+import org.opencv.core.TermCriteria;
+import org.opencv.utils.Converters;
+
+// C++: class Core
+
+public class Core {
+ // these constants are wrapped inside functions to prevent inlining
+ private static String getVersion() { return "4.8.1"; }
+ private static String getNativeLibraryName() { return "opencv_java481"; }
+ private static int getVersionMajorJ() { return 4; }
+ private static int getVersionMinorJ() { return 8; }
+ private static int getVersionRevisionJ() { return 1; }
+ private static String getVersionStatusJ() { return ""; }
+
+ public static final String VERSION = getVersion();
+ public static final String NATIVE_LIBRARY_NAME = getNativeLibraryName();
+ public static final int VERSION_MAJOR = getVersionMajorJ();
+ public static final int VERSION_MINOR = getVersionMinorJ();
+ public static final int VERSION_REVISION = getVersionRevisionJ();
+ public static final String VERSION_STATUS = getVersionStatusJ();
+
+ private static final int
+ CV_8U = 0,
+ CV_8S = 1,
+ CV_16U = 2,
+ CV_16S = 3,
+ CV_32S = 4,
+ CV_32F = 5,
+ CV_64F = 6,
+ CV_USRTYPE1 = 7;
+
+
+ // C++: enum
+ public static final int
+ SVD_MODIFY_A = 1,
+ SVD_NO_UV = 2,
+ SVD_FULL_UV = 4,
+ FILLED = -1,
+ REDUCE_SUM = 0,
+ REDUCE_AVG = 1,
+ REDUCE_MAX = 2,
+ REDUCE_MIN = 3,
+ RNG_UNIFORM = 0,
+ RNG_NORMAL = 1;
+
+
+ // C++: enum BorderTypes (cv.BorderTypes)
+ public static final int
+ BORDER_CONSTANT = 0,
+ BORDER_REPLICATE = 1,
+ BORDER_REFLECT = 2,
+ BORDER_WRAP = 3,
+ BORDER_REFLECT_101 = 4,
+ BORDER_TRANSPARENT = 5,
+ BORDER_REFLECT101 = BORDER_REFLECT_101,
+ BORDER_DEFAULT = BORDER_REFLECT_101,
+ BORDER_ISOLATED = 16;
+
+
+ // C++: enum CmpTypes (cv.CmpTypes)
+ public static final int
+ CMP_EQ = 0,
+ CMP_GT = 1,
+ CMP_GE = 2,
+ CMP_LT = 3,
+ CMP_LE = 4,
+ CMP_NE = 5;
+
+
+ // C++: enum CovarFlags (cv.CovarFlags)
+ public static final int
+ COVAR_SCRAMBLED = 0,
+ COVAR_NORMAL = 1,
+ COVAR_USE_AVG = 2,
+ COVAR_SCALE = 4,
+ COVAR_ROWS = 8,
+ COVAR_COLS = 16;
+
+
+ // C++: enum DecompTypes (cv.DecompTypes)
+ public static final int
+ DECOMP_LU = 0,
+ DECOMP_SVD = 1,
+ DECOMP_EIG = 2,
+ DECOMP_CHOLESKY = 3,
+ DECOMP_QR = 4,
+ DECOMP_NORMAL = 16;
+
+
+ // C++: enum DftFlags (cv.DftFlags)
+ public static final int
+ DFT_INVERSE = 1,
+ DFT_SCALE = 2,
+ DFT_ROWS = 4,
+ DFT_COMPLEX_OUTPUT = 16,
+ DFT_REAL_OUTPUT = 32,
+ DFT_COMPLEX_INPUT = 64,
+ DCT_INVERSE = DFT_INVERSE,
+ DCT_ROWS = DFT_ROWS;
+
+
+ // C++: enum Code (cv.Error.Code)
+ public static final int
+ StsOk = 0,
+ StsBackTrace = -1,
+ StsError = -2,
+ StsInternal = -3,
+ StsNoMem = -4,
+ StsBadArg = -5,
+ StsBadFunc = -6,
+ StsNoConv = -7,
+ StsAutoTrace = -8,
+ HeaderIsNull = -9,
+ BadImageSize = -10,
+ BadOffset = -11,
+ BadDataPtr = -12,
+ BadStep = -13,
+ BadModelOrChSeq = -14,
+ BadNumChannels = -15,
+ BadNumChannel1U = -16,
+ BadDepth = -17,
+ BadAlphaChannel = -18,
+ BadOrder = -19,
+ BadOrigin = -20,
+ BadAlign = -21,
+ BadCallBack = -22,
+ BadTileSize = -23,
+ BadCOI = -24,
+ BadROISize = -25,
+ MaskIsTiled = -26,
+ StsNullPtr = -27,
+ StsVecLengthErr = -28,
+ StsFilterStructContentErr = -29,
+ StsKernelStructContentErr = -30,
+ StsFilterOffsetErr = -31,
+ StsBadSize = -201,
+ StsDivByZero = -202,
+ StsInplaceNotSupported = -203,
+ StsObjectNotFound = -204,
+ StsUnmatchedFormats = -205,
+ StsBadFlag = -206,
+ StsBadPoint = -207,
+ StsBadMask = -208,
+ StsUnmatchedSizes = -209,
+ StsUnsupportedFormat = -210,
+ StsOutOfRange = -211,
+ StsParseError = -212,
+ StsNotImplemented = -213,
+ StsBadMemBlock = -214,
+ StsAssert = -215,
+ GpuNotSupported = -216,
+ GpuApiCallError = -217,
+ OpenGlNotSupported = -218,
+ OpenGlApiCallError = -219,
+ OpenCLApiCallError = -220,
+ OpenCLDoubleNotSupported = -221,
+ OpenCLInitError = -222,
+ OpenCLNoAMDBlasFft = -223;
+
+
+ // C++: enum FormatType (cv.Formatter.FormatType)
+ public static final int
+ Formatter_FMT_DEFAULT = 0,
+ Formatter_FMT_MATLAB = 1,
+ Formatter_FMT_CSV = 2,
+ Formatter_FMT_PYTHON = 3,
+ Formatter_FMT_NUMPY = 4,
+ Formatter_FMT_C = 5;
+
+
+ // C++: enum GemmFlags (cv.GemmFlags)
+ public static final int
+ GEMM_1_T = 1,
+ GEMM_2_T = 2,
+ GEMM_3_T = 4;
+
+
+ // C++: enum KmeansFlags (cv.KmeansFlags)
+ public static final int
+ KMEANS_RANDOM_CENTERS = 0,
+ KMEANS_PP_CENTERS = 2,
+ KMEANS_USE_INITIAL_LABELS = 1;
+
+
+ // C++: enum NormTypes (cv.NormTypes)
+ public static final int
+ NORM_INF = 1,
+ NORM_L1 = 2,
+ NORM_L2 = 4,
+ NORM_L2SQR = 5,
+ NORM_HAMMING = 6,
+ NORM_HAMMING2 = 7,
+ NORM_TYPE_MASK = 7,
+ NORM_RELATIVE = 8,
+ NORM_MINMAX = 32;
+
+
+ // C++: enum Flags (cv.PCA.Flags)
+ public static final int
+ PCA_DATA_AS_ROW = 0,
+ PCA_DATA_AS_COL = 1,
+ PCA_USE_AVG = 2;
+
+
+ // C++: enum Param (cv.Param)
+ public static final int
+ Param_INT = 0,
+ Param_BOOLEAN = 1,
+ Param_REAL = 2,
+ Param_STRING = 3,
+ Param_MAT = 4,
+ Param_MAT_VECTOR = 5,
+ Param_ALGORITHM = 6,
+ Param_FLOAT = 7,
+ Param_UNSIGNED_INT = 8,
+ Param_UINT64 = 9,
+ Param_UCHAR = 11,
+ Param_SCALAR = 12;
+
+
+ // C++: enum ReduceTypes (cv.ReduceTypes)
+ public static final int
+ REDUCE_SUM2 = 4;
+
+
+ // C++: enum RotateFlags (cv.RotateFlags)
+ public static final int
+ ROTATE_90_CLOCKWISE = 0,
+ ROTATE_180 = 1,
+ ROTATE_90_COUNTERCLOCKWISE = 2;
+
+
+ // C++: enum SortFlags (cv.SortFlags)
+ public static final int
+ SORT_EVERY_ROW = 0,
+ SORT_EVERY_COLUMN = 1,
+ SORT_ASCENDING = 0,
+ SORT_DESCENDING = 16;
+
+
+ //
+ // C++: float cv::cubeRoot(float val)
+ //
+
+ /**
+ * Computes the cube root of an argument.
+ *
+ * The function cubeRoot computes \(\sqrt[3]{\texttt{val}}\). Negative arguments are handled correctly.
+ * NaN and Inf are not handled. The accuracy approaches the maximum possible accuracy for
+ * single-precision data.
+ * @param val A function argument.
+ * @return automatically generated
+ */
+ public static float cubeRoot(float val) {
+ return cubeRoot_0(val);
+ }
+
+
+ //
+ // C++: float cv::fastAtan2(float y, float x)
+ //
+
+ /**
+ * 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
+ * in degrees and varies from 0 to 360 degrees. The accuracy is about 0.3 degrees.
+ * @param x x-coordinate of the vector.
+ * @param y y-coordinate of the vector.
+ * @return automatically generated
+ */
+ public static float fastAtan2(float y, float x) {
+ return fastAtan2_0(y, x);
+ }
+
+
+ //
+ // C++: bool cv::ipp::useIPP()
+ //
+
+ /**
+ * proxy for hal::Cholesky
+ * @return automatically generated
+ */
+ public static boolean useIPP() {
+ return useIPP_0();
+ }
+
+
+ //
+ // C++: void cv::ipp::setUseIPP(bool flag)
+ //
+
+ public static void setUseIPP(boolean flag) {
+ setUseIPP_0(flag);
+ }
+
+
+ //
+ // C++: String cv::ipp::getIppVersion()
+ //
+
+ public static String getIppVersion() {
+ return getIppVersion_0();
+ }
+
+
+ //
+ // C++: bool cv::ipp::useIPP_NotExact()
+ //
+
+ public static boolean useIPP_NotExact() {
+ return useIPP_NotExact_0();
+ }
+
+
+ //
+ // C++: void cv::ipp::setUseIPP_NotExact(bool flag)
+ //
+
+ public static void setUseIPP_NotExact(boolean flag) {
+ setUseIPP_NotExact_0(flag);
+ }
+
+
+ //
+ // C++: int cv::borderInterpolate(int p, int len, int borderType)
+ //
+
+ /**
+ * Computes the source location of an extrapolated pixel.
+ *
+ * The function computes and returns the coordinate of a donor pixel corresponding to the specified
+ * extrapolated pixel when using the specified extrapolation border mode. For example, if you use
+ * cv::BORDER_WRAP mode in the horizontal direction, cv::BORDER_REFLECT_101 in the vertical direction and
+ * want to compute value of the "virtual" pixel Point(-5, 100) in a floating-point image img , it
+ * looks like:
+ *
+ * float val = img.at<float>(borderInterpolate(100, img.rows, cv::BORDER_REFLECT_101),
+ * borderInterpolate(-5, img.cols, cv::BORDER_WRAP));
+ *
+ * Normally, the function is not called directly. It is used inside filtering functions and also in
+ * copyMakeBorder.
+ * @param p 0-based coordinate of the extrapolated pixel along one of the axes, likely <0 or >= len
+ * @param len Length of the array along the corresponding axis.
+ * @param borderType Border type, one of the #BorderTypes, except for #BORDER_TRANSPARENT and
+ * #BORDER_ISOLATED . When borderType==#BORDER_CONSTANT , the function always returns -1, regardless
+ * of p and len.
+ *
+ * SEE: copyMakeBorder
+ * @return automatically generated
+ */
+ public static int borderInterpolate(int p, int len, int borderType) {
+ return borderInterpolate_0(p, len, borderType);
+ }
+
+
+ //
+ // C++: void cv::copyMakeBorder(Mat src, Mat& dst, int top, int bottom, int left, int right, int borderType, Scalar value = Scalar())
+ //
+
+ /**
+ * Forms a border around an image.
+ *
+ * The function copies the source image into the middle of the destination image. The areas to the
+ * left, to the right, above and below the copied source image will be filled with extrapolated
+ * pixels. This is not what filtering functions based on it do (they extrapolate pixels on-fly), but
+ * what other more complex functions, including your own, may do to simplify image boundary handling.
+ *
+ * The function supports the mode when src is already in the middle of dst . In this case, the
+ * function does not copy src itself but simply constructs the border, for example:
+ *
+ *
+ * // let border be the same in all directions
+ * int border=2;
+ * // constructs a larger image to fit both the image and the border
+ * Mat gray_buf(rgb.rows + border*2, rgb.cols + border*2, rgb.depth());
+ * // select the middle part of it w/o copying data
+ * Mat gray(gray_canvas, Rect(border, border, rgb.cols, rgb.rows));
+ * // convert image from RGB to grayscale
+ * cvtColor(rgb, gray, COLOR_RGB2GRAY);
+ * // form a border in-place
+ * copyMakeBorder(gray, gray_buf, border, border,
+ * border, border, BORDER_REPLICATE);
+ * // now do some custom filtering ...
+ * ...
+ *
+ * Note: When the source image is a part (ROI) of a bigger image, the function will try to use the
+ * pixels outside of the ROI to form a border. To disable this feature and always do extrapolation, as
+ * if src was not a ROI, use borderType | #BORDER_ISOLATED.
+ *
+ * @param src Source image.
+ * @param dst Destination image of the same type as src and the size Size(src.cols+left+right,
+ * src.rows+top+bottom) .
+ * @param top the top pixels
+ * @param bottom the bottom pixels
+ * @param left the left pixels
+ * @param right Parameter specifying how many pixels in each direction from the source image rectangle
+ * to extrapolate. For example, top=1, bottom=1, left=1, right=1 mean that 1 pixel-wide border needs
+ * to be built.
+ * @param borderType Border type. See borderInterpolate for details.
+ * @param value Border value if borderType==BORDER_CONSTANT .
+ *
+ * SEE: borderInterpolate
+ */
+ public static void copyMakeBorder(Mat src, Mat dst, int top, int bottom, int left, int right, int borderType, Scalar value) {
+ copyMakeBorder_0(src.nativeObj, dst.nativeObj, top, bottom, left, right, borderType, value.val[0], value.val[1], value.val[2], value.val[3]);
+ }
+
+ /**
+ * Forms a border around an image.
+ *
+ * The function copies the source image into the middle of the destination image. The areas to the
+ * left, to the right, above and below the copied source image will be filled with extrapolated
+ * pixels. This is not what filtering functions based on it do (they extrapolate pixels on-fly), but
+ * what other more complex functions, including your own, may do to simplify image boundary handling.
+ *
+ * The function supports the mode when src is already in the middle of dst . In this case, the
+ * function does not copy src itself but simply constructs the border, for example:
+ *
+ *
+ * // let border be the same in all directions
+ * int border=2;
+ * // constructs a larger image to fit both the image and the border
+ * Mat gray_buf(rgb.rows + border*2, rgb.cols + border*2, rgb.depth());
+ * // select the middle part of it w/o copying data
+ * Mat gray(gray_canvas, Rect(border, border, rgb.cols, rgb.rows));
+ * // convert image from RGB to grayscale
+ * cvtColor(rgb, gray, COLOR_RGB2GRAY);
+ * // form a border in-place
+ * copyMakeBorder(gray, gray_buf, border, border,
+ * border, border, BORDER_REPLICATE);
+ * // now do some custom filtering ...
+ * ...
+ *
+ * Note: When the source image is a part (ROI) of a bigger image, the function will try to use the
+ * pixels outside of the ROI to form a border. To disable this feature and always do extrapolation, as
+ * if src was not a ROI, use borderType | #BORDER_ISOLATED.
+ *
+ * @param src Source image.
+ * @param dst Destination image of the same type as src and the size Size(src.cols+left+right,
+ * src.rows+top+bottom) .
+ * @param top the top pixels
+ * @param bottom the bottom pixels
+ * @param left the left pixels
+ * @param right Parameter specifying how many pixels in each direction from the source image rectangle
+ * to extrapolate. For example, top=1, bottom=1, left=1, right=1 mean that 1 pixel-wide border needs
+ * to be built.
+ * @param borderType Border type. See borderInterpolate for details.
+ *
+ * SEE: borderInterpolate
+ */
+ public static void copyMakeBorder(Mat src, Mat dst, int top, int bottom, int left, int right, int borderType) {
+ copyMakeBorder_1(src.nativeObj, dst.nativeObj, top, bottom, left, right, borderType);
+ }
+
+
+ //
+ // C++: void cv::add(Mat src1, Mat src2, Mat& dst, Mat mask = Mat(), int dtype = -1)
+ //
+
+ /**
+ * Calculates the per-element sum of two arrays or an array and a scalar.
+ *
+ * The function add calculates:
+ *
+ *
+ * Sum of two arrays when both input arrays have the same size and the same number of channels:
+ * \(\texttt{dst}(I) = \texttt{saturate} ( \texttt{src1}(I) + \texttt{src2}(I)) \quad \texttt{if mask}(I) \ne0\)
+ *
+ *
+ * Sum of an array and a scalar when src2 is constructed from Scalar or has the same number of
+ * elements as {@code src1.channels()}:
+ * \(\texttt{dst}(I) = \texttt{saturate} ( \texttt{src1}(I) + \texttt{src2} ) \quad \texttt{if mask}(I) \ne0\)
+ *
+ *
+ * Sum of a scalar and an array when src1 is constructed from Scalar or has the same number of
+ * elements as {@code src2.channels()}:
+ * \(\texttt{dst}(I) = \texttt{saturate} ( \texttt{src1} + \texttt{src2}(I) ) \quad \texttt{if mask}(I) \ne0\)
+ * where {@code I} is a multi-dimensional index of array elements. In case of multi-channel arrays, each
+ * channel is processed independently.
+ *
+ *
+ *
+ * The first function in the list above can be replaced with matrix expressions:
+ *
+ * dst = src1 + src2;
+ * dst += src1; // equivalent to add(dst, src1, dst);
+ *
+ * The input arrays and the output array can all have the same or different depths. For example, you
+ * can add a 16-bit unsigned array to a 8-bit signed array and store the sum as a 32-bit
+ * floating-point array. Depth of the output array is determined by the dtype parameter. In the second
+ * and third cases above, as well as in the first case, when src1.depth() == src2.depth(), dtype can
+ * be set to the default -1. In this case, the output array will have the same depth as the input
+ * array, be it src1, src2 or both.
+ * Note: Saturation is not applied when the output array has the depth CV_32S. You may even get
+ * result of an incorrect sign in the case of overflow.
+ * @param src1 first input array or a scalar.
+ * @param src2 second input array or a scalar.
+ * @param dst output array that has the same size and number of channels as the input array(s); the
+ * depth is defined by dtype or src1/src2.
+ * @param mask optional operation mask - 8-bit single channel array, that specifies elements of the
+ * output array to be changed.
+ * @param dtype optional depth of the output array (see the discussion below).
+ * SEE: subtract, addWeighted, scaleAdd, Mat::convertTo
+ */
+ public static void add(Mat src1, Mat src2, Mat dst, Mat mask, int dtype) {
+ add_0(src1.nativeObj, src2.nativeObj, dst.nativeObj, mask.nativeObj, dtype);
+ }
+
+ /**
+ * Calculates the per-element sum of two arrays or an array and a scalar.
+ *
+ * The function add calculates:
+ *
+ *
+ * Sum of two arrays when both input arrays have the same size and the same number of channels:
+ * \(\texttt{dst}(I) = \texttt{saturate} ( \texttt{src1}(I) + \texttt{src2}(I)) \quad \texttt{if mask}(I) \ne0\)
+ *
+ *
+ * Sum of an array and a scalar when src2 is constructed from Scalar or has the same number of
+ * elements as {@code src1.channels()}:
+ * \(\texttt{dst}(I) = \texttt{saturate} ( \texttt{src1}(I) + \texttt{src2} ) \quad \texttt{if mask}(I) \ne0\)
+ *
+ *
+ * Sum of a scalar and an array when src1 is constructed from Scalar or has the same number of
+ * elements as {@code src2.channels()}:
+ * \(\texttt{dst}(I) = \texttt{saturate} ( \texttt{src1} + \texttt{src2}(I) ) \quad \texttt{if mask}(I) \ne0\)
+ * where {@code I} is a multi-dimensional index of array elements. In case of multi-channel arrays, each
+ * channel is processed independently.
+ *
+ *
+ *
+ * The first function in the list above can be replaced with matrix expressions:
+ *
+ * dst = src1 + src2;
+ * dst += src1; // equivalent to add(dst, src1, dst);
+ *
+ * The input arrays and the output array can all have the same or different depths. For example, you
+ * can add a 16-bit unsigned array to a 8-bit signed array and store the sum as a 32-bit
+ * floating-point array. Depth of the output array is determined by the dtype parameter. In the second
+ * and third cases above, as well as in the first case, when src1.depth() == src2.depth(), dtype can
+ * be set to the default -1. In this case, the output array will have the same depth as the input
+ * array, be it src1, src2 or both.
+ * Note: Saturation is not applied when the output array has the depth CV_32S. You may even get
+ * result of an incorrect sign in the case of overflow.
+ * @param src1 first input array or a scalar.
+ * @param src2 second input array or a scalar.
+ * @param dst output array that has the same size and number of channels as the input array(s); the
+ * depth is defined by dtype or src1/src2.
+ * @param mask optional operation mask - 8-bit single channel array, that specifies elements of the
+ * output array to be changed.
+ * SEE: subtract, addWeighted, scaleAdd, Mat::convertTo
+ */
+ public static void add(Mat src1, Mat src2, Mat dst, Mat mask) {
+ add_1(src1.nativeObj, src2.nativeObj, dst.nativeObj, mask.nativeObj);
+ }
+
+ /**
+ * Calculates the per-element sum of two arrays or an array and a scalar.
+ *
+ * The function add calculates:
+ *
+ *
+ * Sum of two arrays when both input arrays have the same size and the same number of channels:
+ * \(\texttt{dst}(I) = \texttt{saturate} ( \texttt{src1}(I) + \texttt{src2}(I)) \quad \texttt{if mask}(I) \ne0\)
+ *
+ *
+ * Sum of an array and a scalar when src2 is constructed from Scalar or has the same number of
+ * elements as {@code src1.channels()}:
+ * \(\texttt{dst}(I) = \texttt{saturate} ( \texttt{src1}(I) + \texttt{src2} ) \quad \texttt{if mask}(I) \ne0\)
+ *
+ *
+ * Sum of a scalar and an array when src1 is constructed from Scalar or has the same number of
+ * elements as {@code src2.channels()}:
+ * \(\texttt{dst}(I) = \texttt{saturate} ( \texttt{src1} + \texttt{src2}(I) ) \quad \texttt{if mask}(I) \ne0\)
+ * where {@code I} is a multi-dimensional index of array elements. In case of multi-channel arrays, each
+ * channel is processed independently.
+ *
+ *
+ *
+ * The first function in the list above can be replaced with matrix expressions:
+ *
+ * dst = src1 + src2;
+ * dst += src1; // equivalent to add(dst, src1, dst);
+ *
+ * The input arrays and the output array can all have the same or different depths. For example, you
+ * can add a 16-bit unsigned array to a 8-bit signed array and store the sum as a 32-bit
+ * floating-point array. Depth of the output array is determined by the dtype parameter. In the second
+ * and third cases above, as well as in the first case, when src1.depth() == src2.depth(), dtype can
+ * be set to the default -1. In this case, the output array will have the same depth as the input
+ * array, be it src1, src2 or both.
+ * Note: Saturation is not applied when the output array has the depth CV_32S. You may even get
+ * result of an incorrect sign in the case of overflow.
+ * @param src1 first input array or a scalar.
+ * @param src2 second input array or a scalar.
+ * @param dst output array that has the same size and number of channels as the input array(s); the
+ * depth is defined by dtype or src1/src2.
+ * output array to be changed.
+ * SEE: subtract, addWeighted, scaleAdd, Mat::convertTo
+ */
+ public static void add(Mat src1, Mat src2, Mat dst) {
+ add_2(src1.nativeObj, src2.nativeObj, dst.nativeObj);
+ }
+
+
+ //
+ // C++: void cv::subtract(Mat src1, Mat src2, Mat& dst, Mat mask = Mat(), int dtype = -1)
+ //
+
+ /**
+ * Calculates the per-element difference between two arrays or array and a scalar.
+ *
+ * The function subtract calculates:
+ *
+ *
+ * Difference between two arrays, when both input arrays have the same size and the same number of
+ * channels:
+ * \(\texttt{dst}(I) = \texttt{saturate} ( \texttt{src1}(I) - \texttt{src2}(I)) \quad \texttt{if mask}(I) \ne0\)
+ *
+ *
+ * Difference between an array and a scalar, when src2 is constructed from Scalar or has the same
+ * number of elements as {@code src1.channels()}:
+ * \(\texttt{dst}(I) = \texttt{saturate} ( \texttt{src1}(I) - \texttt{src2} ) \quad \texttt{if mask}(I) \ne0\)
+ *
+ *
+ * Difference between a scalar and an array, when src1 is constructed from Scalar or has the same
+ * number of elements as {@code src2.channels()}:
+ * \(\texttt{dst}(I) = \texttt{saturate} ( \texttt{src1} - \texttt{src2}(I) ) \quad \texttt{if mask}(I) \ne0\)
+ *
+ *
+ * The reverse difference between a scalar and an array in the case of {@code SubRS}:
+ * \(\texttt{dst}(I) = \texttt{saturate} ( \texttt{src2} - \texttt{src1}(I) ) \quad \texttt{if mask}(I) \ne0\)
+ * where I is a multi-dimensional index of array elements. In case of multi-channel arrays, each
+ * channel is processed independently.
+ *
+ *
+ *
+ * The first function in the list above can be replaced with matrix expressions:
+ *
+ * dst = src1 - src2;
+ * dst -= src1; // equivalent to subtract(dst, src1, dst);
+ *
+ * The input arrays and the output array can all have the same or different depths. For example, you
+ * can subtract to 8-bit unsigned arrays and store the difference in a 16-bit signed array. Depth of
+ * the output array is determined by dtype parameter. In the second and third cases above, as well as
+ * in the first case, when src1.depth() == src2.depth(), dtype can be set to the default -1. In this
+ * case the output array will have the same depth as the input array, be it src1, src2 or both.
+ * Note: Saturation is not applied when the output array has the depth CV_32S. You may even get
+ * result of an incorrect sign in the case of overflow.
+ * @param src1 first input array or a scalar.
+ * @param src2 second input array or a scalar.
+ * @param dst output array of the same size and the same number of channels as the input array.
+ * @param mask optional operation mask; this is an 8-bit single channel array that specifies elements
+ * of the output array to be changed.
+ * @param dtype optional depth of the output array
+ * SEE: add, addWeighted, scaleAdd, Mat::convertTo
+ */
+ public static void subtract(Mat src1, Mat src2, Mat dst, Mat mask, int dtype) {
+ subtract_0(src1.nativeObj, src2.nativeObj, dst.nativeObj, mask.nativeObj, dtype);
+ }
+
+ /**
+ * Calculates the per-element difference between two arrays or array and a scalar.
+ *
+ * The function subtract calculates:
+ *
+ *
+ * Difference between two arrays, when both input arrays have the same size and the same number of
+ * channels:
+ * \(\texttt{dst}(I) = \texttt{saturate} ( \texttt{src1}(I) - \texttt{src2}(I)) \quad \texttt{if mask}(I) \ne0\)
+ *
+ *
+ * Difference between an array and a scalar, when src2 is constructed from Scalar or has the same
+ * number of elements as {@code src1.channels()}:
+ * \(\texttt{dst}(I) = \texttt{saturate} ( \texttt{src1}(I) - \texttt{src2} ) \quad \texttt{if mask}(I) \ne0\)
+ *
+ *
+ * Difference between a scalar and an array, when src1 is constructed from Scalar or has the same
+ * number of elements as {@code src2.channels()}:
+ * \(\texttt{dst}(I) = \texttt{saturate} ( \texttt{src1} - \texttt{src2}(I) ) \quad \texttt{if mask}(I) \ne0\)
+ *
+ *
+ * The reverse difference between a scalar and an array in the case of {@code SubRS}:
+ * \(\texttt{dst}(I) = \texttt{saturate} ( \texttt{src2} - \texttt{src1}(I) ) \quad \texttt{if mask}(I) \ne0\)
+ * where I is a multi-dimensional index of array elements. In case of multi-channel arrays, each
+ * channel is processed independently.
+ *
+ *
+ *
+ * The first function in the list above can be replaced with matrix expressions:
+ *
+ * dst = src1 - src2;
+ * dst -= src1; // equivalent to subtract(dst, src1, dst);
+ *
+ * The input arrays and the output array can all have the same or different depths. For example, you
+ * can subtract to 8-bit unsigned arrays and store the difference in a 16-bit signed array. Depth of
+ * the output array is determined by dtype parameter. In the second and third cases above, as well as
+ * in the first case, when src1.depth() == src2.depth(), dtype can be set to the default -1. In this
+ * case the output array will have the same depth as the input array, be it src1, src2 or both.
+ * Note: Saturation is not applied when the output array has the depth CV_32S. You may even get
+ * result of an incorrect sign in the case of overflow.
+ * @param src1 first input array or a scalar.
+ * @param src2 second input array or a scalar.
+ * @param dst output array of the same size and the same number of channels as the input array.
+ * @param mask optional operation mask; this is an 8-bit single channel array that specifies elements
+ * of the output array to be changed.
+ * SEE: add, addWeighted, scaleAdd, Mat::convertTo
+ */
+ public static void subtract(Mat src1, Mat src2, Mat dst, Mat mask) {
+ subtract_1(src1.nativeObj, src2.nativeObj, dst.nativeObj, mask.nativeObj);
+ }
+
+ /**
+ * Calculates the per-element difference between two arrays or array and a scalar.
+ *
+ * The function subtract calculates:
+ *
+ *
+ * Difference between two arrays, when both input arrays have the same size and the same number of
+ * channels:
+ * \(\texttt{dst}(I) = \texttt{saturate} ( \texttt{src1}(I) - \texttt{src2}(I)) \quad \texttt{if mask}(I) \ne0\)
+ *
+ *
+ * Difference between an array and a scalar, when src2 is constructed from Scalar or has the same
+ * number of elements as {@code src1.channels()}:
+ * \(\texttt{dst}(I) = \texttt{saturate} ( \texttt{src1}(I) - \texttt{src2} ) \quad \texttt{if mask}(I) \ne0\)
+ *
+ *
+ * Difference between a scalar and an array, when src1 is constructed from Scalar or has the same
+ * number of elements as {@code src2.channels()}:
+ * \(\texttt{dst}(I) = \texttt{saturate} ( \texttt{src1} - \texttt{src2}(I) ) \quad \texttt{if mask}(I) \ne0\)
+ *
+ *
+ * The reverse difference between a scalar and an array in the case of {@code SubRS}:
+ * \(\texttt{dst}(I) = \texttt{saturate} ( \texttt{src2} - \texttt{src1}(I) ) \quad \texttt{if mask}(I) \ne0\)
+ * where I is a multi-dimensional index of array elements. In case of multi-channel arrays, each
+ * channel is processed independently.
+ *
+ *
+ *
+ * The first function in the list above can be replaced with matrix expressions:
+ *
+ * dst = src1 - src2;
+ * dst -= src1; // equivalent to subtract(dst, src1, dst);
+ *
+ * The input arrays and the output array can all have the same or different depths. For example, you
+ * can subtract to 8-bit unsigned arrays and store the difference in a 16-bit signed array. Depth of
+ * the output array is determined by dtype parameter. In the second and third cases above, as well as
+ * in the first case, when src1.depth() == src2.depth(), dtype can be set to the default -1. In this
+ * case the output array will have the same depth as the input array, be it src1, src2 or both.
+ * Note: Saturation is not applied when the output array has the depth CV_32S. You may even get
+ * result of an incorrect sign in the case of overflow.
+ * @param src1 first input array or a scalar.
+ * @param src2 second input array or a scalar.
+ * @param dst output array of the same size and the same number of channels as the input array.
+ * of the output array to be changed.
+ * SEE: add, addWeighted, scaleAdd, Mat::convertTo
+ */
+ public static void subtract(Mat src1, Mat src2, Mat dst) {
+ subtract_2(src1.nativeObj, src2.nativeObj, dst.nativeObj);
+ }
+
+
+ //
+ // C++: void cv::multiply(Mat src1, Mat src2, Mat& dst, double scale = 1, int dtype = -1)
+ //
+
+ /**
+ * Calculates the per-element scaled product of two arrays.
+ *
+ * The function multiply calculates the per-element product of two arrays:
+ *
+ * \(\texttt{dst} (I)= \texttt{saturate} ( \texttt{scale} \cdot \texttt{src1} (I) \cdot \texttt{src2} (I))\)
+ *
+ * There is also a REF: MatrixExpressions -friendly variant of the first function. See Mat::mul .
+ *
+ * For a not-per-element matrix product, see gemm .
+ *
+ * Note: Saturation is not applied when the output array has the depth
+ * CV_32S. You may even get result of an incorrect sign in the case of
+ * overflow.
+ * @param src1 first input array.
+ * @param src2 second input array of the same size and the same type as src1.
+ * @param dst output array of the same size and type as src1.
+ * @param scale optional scale factor.
+ * @param dtype optional depth of the output array
+ * SEE: add, subtract, divide, scaleAdd, addWeighted, accumulate, accumulateProduct, accumulateSquare,
+ * Mat::convertTo
+ */
+ public static void multiply(Mat src1, Mat src2, Mat dst, double scale, int dtype) {
+ multiply_0(src1.nativeObj, src2.nativeObj, dst.nativeObj, scale, dtype);
+ }
+
+ /**
+ * Calculates the per-element scaled product of two arrays.
+ *
+ * The function multiply calculates the per-element product of two arrays:
+ *
+ * \(\texttt{dst} (I)= \texttt{saturate} ( \texttt{scale} \cdot \texttt{src1} (I) \cdot \texttt{src2} (I))\)
+ *
+ * There is also a REF: MatrixExpressions -friendly variant of the first function. See Mat::mul .
+ *
+ * For a not-per-element matrix product, see gemm .
+ *
+ * Note: Saturation is not applied when the output array has the depth
+ * CV_32S. You may even get result of an incorrect sign in the case of
+ * overflow.
+ * @param src1 first input array.
+ * @param src2 second input array of the same size and the same type as src1.
+ * @param dst output array of the same size and type as src1.
+ * @param scale optional scale factor.
+ * SEE: add, subtract, divide, scaleAdd, addWeighted, accumulate, accumulateProduct, accumulateSquare,
+ * Mat::convertTo
+ */
+ public static void multiply(Mat src1, Mat src2, Mat dst, double scale) {
+ multiply_1(src1.nativeObj, src2.nativeObj, dst.nativeObj, scale);
+ }
+
+ /**
+ * Calculates the per-element scaled product of two arrays.
+ *
+ * The function multiply calculates the per-element product of two arrays:
+ *
+ * \(\texttt{dst} (I)= \texttt{saturate} ( \texttt{scale} \cdot \texttt{src1} (I) \cdot \texttt{src2} (I))\)
+ *
+ * There is also a REF: MatrixExpressions -friendly variant of the first function. See Mat::mul .
+ *
+ * For a not-per-element matrix product, see gemm .
+ *
+ * Note: Saturation is not applied when the output array has the depth
+ * CV_32S. You may even get result of an incorrect sign in the case of
+ * overflow.
+ * @param src1 first input array.
+ * @param src2 second input array of the same size and the same type as src1.
+ * @param dst output array of the same size and type as src1.
+ * SEE: add, subtract, divide, scaleAdd, addWeighted, accumulate, accumulateProduct, accumulateSquare,
+ * Mat::convertTo
+ */
+ public static void multiply(Mat src1, Mat src2, Mat dst) {
+ multiply_2(src1.nativeObj, src2.nativeObj, dst.nativeObj);
+ }
+
+
+ //
+ // C++: void cv::divide(Mat src1, Mat src2, Mat& dst, double scale = 1, int dtype = -1)
+ //
+
+ /**
+ * Performs per-element division of two arrays or a scalar by an array.
+ *
+ * The function cv::divide divides one array by another:
+ * \(\texttt{dst(I) = saturate(src1(I)*scale/src2(I))}\)
+ * or a scalar by an array when there is no src1 :
+ * \(\texttt{dst(I) = saturate(scale/src2(I))}\)
+ *
+ * Different channels of multi-channel arrays are processed independently.
+ *
+ * For integer types when src2(I) is zero, dst(I) will also be zero.
+ *
+ * Note: In case of floating point data there is no special defined behavior for zero src2(I) values.
+ * Regular floating-point division is used.
+ * Expect correct IEEE-754 behaviour for floating-point data (with NaN, Inf result values).
+ *
+ * Note: Saturation is not applied when the output array has the depth CV_32S. You may even get
+ * result of an incorrect sign in the case of overflow.
+ * @param src1 first input array.
+ * @param src2 second input array of the same size and type as src1.
+ * @param scale scalar factor.
+ * @param dst output array of the same size and type as src2.
+ * @param dtype optional depth of the output array; if -1, dst will have depth src2.depth(), but in
+ * case of an array-by-array division, you can only pass -1 when src1.depth()==src2.depth().
+ * SEE: multiply, add, subtract
+ */
+ public static void divide(Mat src1, Mat src2, Mat dst, double scale, int dtype) {
+ divide_0(src1.nativeObj, src2.nativeObj, dst.nativeObj, scale, dtype);
+ }
+
+ /**
+ * Performs per-element division of two arrays or a scalar by an array.
+ *
+ * The function cv::divide divides one array by another:
+ * \(\texttt{dst(I) = saturate(src1(I)*scale/src2(I))}\)
+ * or a scalar by an array when there is no src1 :
+ * \(\texttt{dst(I) = saturate(scale/src2(I))}\)
+ *
+ * Different channels of multi-channel arrays are processed independently.
+ *
+ * For integer types when src2(I) is zero, dst(I) will also be zero.
+ *
+ * Note: In case of floating point data there is no special defined behavior for zero src2(I) values.
+ * Regular floating-point division is used.
+ * Expect correct IEEE-754 behaviour for floating-point data (with NaN, Inf result values).
+ *
+ * Note: Saturation is not applied when the output array has the depth CV_32S. You may even get
+ * result of an incorrect sign in the case of overflow.
+ * @param src1 first input array.
+ * @param src2 second input array of the same size and type as src1.
+ * @param scale scalar factor.
+ * @param dst output array of the same size and type as src2.
+ * case of an array-by-array division, you can only pass -1 when src1.depth()==src2.depth().
+ * SEE: multiply, add, subtract
+ */
+ public static void divide(Mat src1, Mat src2, Mat dst, double scale) {
+ divide_1(src1.nativeObj, src2.nativeObj, dst.nativeObj, scale);
+ }
+
+ /**
+ * Performs per-element division of two arrays or a scalar by an array.
+ *
+ * The function cv::divide divides one array by another:
+ * \(\texttt{dst(I) = saturate(src1(I)*scale/src2(I))}\)
+ * or a scalar by an array when there is no src1 :
+ * \(\texttt{dst(I) = saturate(scale/src2(I))}\)
+ *
+ * Different channels of multi-channel arrays are processed independently.
+ *
+ * For integer types when src2(I) is zero, dst(I) will also be zero.
+ *
+ * Note: In case of floating point data there is no special defined behavior for zero src2(I) values.
+ * Regular floating-point division is used.
+ * Expect correct IEEE-754 behaviour for floating-point data (with NaN, Inf result values).
+ *
+ * Note: Saturation is not applied when the output array has the depth CV_32S. You may even get
+ * result of an incorrect sign in the case of overflow.
+ * @param src1 first input array.
+ * @param src2 second input array of the same size and type as src1.
+ * @param dst output array of the same size and type as src2.
+ * case of an array-by-array division, you can only pass -1 when src1.depth()==src2.depth().
+ * SEE: multiply, add, subtract
+ */
+ public static void divide(Mat src1, Mat src2, Mat dst) {
+ divide_2(src1.nativeObj, src2.nativeObj, dst.nativeObj);
+ }
+
+
+ //
+ // C++: void cv::divide(double scale, Mat src2, Mat& dst, int dtype = -1)
+ //
+
+ public static void divide(double scale, Mat src2, Mat dst, int dtype) {
+ divide_3(scale, src2.nativeObj, dst.nativeObj, dtype);
+ }
+
+ public static void divide(double scale, Mat src2, Mat dst) {
+ divide_4(scale, src2.nativeObj, dst.nativeObj);
+ }
+
+
+ //
+ // C++: void cv::scaleAdd(Mat src1, double alpha, Mat src2, Mat& dst)
+ //
+
+ /**
+ * Calculates the sum of a scaled array and another array.
+ *
+ * The function scaleAdd is one of the classical primitive linear algebra operations, known as DAXPY
+ * or SAXPY in [BLAS](http://en.wikipedia.org/wiki/Basic_Linear_Algebra_Subprograms). It calculates
+ * the sum of a scaled array and another array:
+ * \(\texttt{dst} (I)= \texttt{scale} \cdot \texttt{src1} (I) + \texttt{src2} (I)\)
+ * The function can also be emulated with a matrix expression, for example:
+ *
+ * Mat A(3, 3, CV_64F);
+ * ...
+ * A.row(0) = A.row(1)*2 + A.row(2);
+ *
+ * @param src1 first input array.
+ * @param alpha scale factor for the first array.
+ * @param src2 second input array of the same size and type as src1.
+ * @param dst output array of the same size and type as src1.
+ * SEE: add, addWeighted, subtract, Mat::dot, Mat::convertTo
+ */
+ public static void scaleAdd(Mat src1, double alpha, Mat src2, Mat dst) {
+ scaleAdd_0(src1.nativeObj, alpha, src2.nativeObj, dst.nativeObj);
+ }
+
+
+ //
+ // C++: void cv::addWeighted(Mat src1, double alpha, Mat src2, double beta, double gamma, Mat& dst, int dtype = -1)
+ //
+
+ /**
+ * Calculates the weighted sum of two arrays.
+ *
+ * The function addWeighted calculates the weighted sum of two arrays as follows:
+ * \(\texttt{dst} (I)= \texttt{saturate} ( \texttt{src1} (I)* \texttt{alpha} + \texttt{src2} (I)* \texttt{beta} + \texttt{gamma} )\)
+ * where I is a multi-dimensional index of array elements. In case of multi-channel arrays, each
+ * channel is processed independently.
+ * The function can be replaced with a matrix expression:
+ *
+ * dst = src1*alpha + src2*beta + gamma;
+ *
+ * Note: Saturation is not applied when the output array has the depth CV_32S. You may even get
+ * result of an incorrect sign in the case of overflow.
+ * @param src1 first input array.
+ * @param alpha weight of the first array elements.
+ * @param src2 second input array of the same size and channel number as src1.
+ * @param beta weight of the second array elements.
+ * @param gamma scalar added to each sum.
+ * @param dst output array that has the same size and number of channels as the input arrays.
+ * @param dtype optional depth of the output array; when both input arrays have the same depth, dtype
+ * can be set to -1, which will be equivalent to src1.depth().
+ * SEE: add, subtract, scaleAdd, Mat::convertTo
+ */
+ public static void addWeighted(Mat src1, double alpha, Mat src2, double beta, double gamma, Mat dst, int dtype) {
+ addWeighted_0(src1.nativeObj, alpha, src2.nativeObj, beta, gamma, dst.nativeObj, dtype);
+ }
+
+ /**
+ * Calculates the weighted sum of two arrays.
+ *
+ * The function addWeighted calculates the weighted sum of two arrays as follows:
+ * \(\texttt{dst} (I)= \texttt{saturate} ( \texttt{src1} (I)* \texttt{alpha} + \texttt{src2} (I)* \texttt{beta} + \texttt{gamma} )\)
+ * where I is a multi-dimensional index of array elements. In case of multi-channel arrays, each
+ * channel is processed independently.
+ * The function can be replaced with a matrix expression:
+ *
+ * dst = src1*alpha + src2*beta + gamma;
+ *
+ * Note: Saturation is not applied when the output array has the depth CV_32S. You may even get
+ * result of an incorrect sign in the case of overflow.
+ * @param src1 first input array.
+ * @param alpha weight of the first array elements.
+ * @param src2 second input array of the same size and channel number as src1.
+ * @param beta weight of the second array elements.
+ * @param gamma scalar added to each sum.
+ * @param dst output array that has the same size and number of channels as the input arrays.
+ * can be set to -1, which will be equivalent to src1.depth().
+ * SEE: add, subtract, scaleAdd, Mat::convertTo
+ */
+ public static void addWeighted(Mat src1, double alpha, Mat src2, double beta, double gamma, Mat dst) {
+ addWeighted_1(src1.nativeObj, alpha, src2.nativeObj, beta, gamma, dst.nativeObj);
+ }
+
+
+ //
+ // C++: void cv::convertScaleAbs(Mat src, Mat& dst, double alpha = 1, double beta = 0)
+ //
+
+ /**
+ * Scales, calculates absolute values, and converts the result to 8-bit.
+ *
+ * On each element of the input array, the function convertScaleAbs
+ * performs three operations sequentially: scaling, taking an absolute
+ * value, conversion to an unsigned 8-bit type:
+ * \(\texttt{dst} (I)= \texttt{saturate\_cast<uchar>} (| \texttt{src} (I)* \texttt{alpha} + \texttt{beta} |)\)
+ * In case of multi-channel arrays, the function processes each channel
+ * independently. When the output is not 8-bit, the operation can be
+ * emulated by calling the Mat::convertTo method (or by using matrix
+ * expressions) and then by calculating an absolute value of the result.
+ * For example:
+ *
+ * Mat_<float> A(30,30);
+ * randu(A, Scalar(-100), Scalar(100));
+ * Mat_<float> B = A*5 + 3;
+ * B = abs(B);
+ * // Mat_<float> B = abs(A*5+3) will also do the job,
+ * // but it will allocate a temporary matrix
+ *
+ * @param src input array.
+ * @param dst output array.
+ * @param alpha optional scale factor.
+ * @param beta optional delta added to the scaled values.
+ * SEE: Mat::convertTo, cv::abs(const Mat&)
+ */
+ public static void convertScaleAbs(Mat src, Mat dst, double alpha, double beta) {
+ convertScaleAbs_0(src.nativeObj, dst.nativeObj, alpha, beta);
+ }
+
+ /**
+ * Scales, calculates absolute values, and converts the result to 8-bit.
+ *
+ * On each element of the input array, the function convertScaleAbs
+ * performs three operations sequentially: scaling, taking an absolute
+ * value, conversion to an unsigned 8-bit type:
+ * \(\texttt{dst} (I)= \texttt{saturate\_cast<uchar>} (| \texttt{src} (I)* \texttt{alpha} + \texttt{beta} |)\)
+ * In case of multi-channel arrays, the function processes each channel
+ * independently. When the output is not 8-bit, the operation can be
+ * emulated by calling the Mat::convertTo method (or by using matrix
+ * expressions) and then by calculating an absolute value of the result.
+ * For example:
+ *
+ * Mat_<float> A(30,30);
+ * randu(A, Scalar(-100), Scalar(100));
+ * Mat_<float> B = A*5 + 3;
+ * B = abs(B);
+ * // Mat_<float> B = abs(A*5+3) will also do the job,
+ * // but it will allocate a temporary matrix
+ *
+ * @param src input array.
+ * @param dst output array.
+ * @param alpha optional scale factor.
+ * SEE: Mat::convertTo, cv::abs(const Mat&)
+ */
+ public static void convertScaleAbs(Mat src, Mat dst, double alpha) {
+ convertScaleAbs_1(src.nativeObj, dst.nativeObj, alpha);
+ }
+
+ /**
+ * Scales, calculates absolute values, and converts the result to 8-bit.
+ *
+ * On each element of the input array, the function convertScaleAbs
+ * performs three operations sequentially: scaling, taking an absolute
+ * value, conversion to an unsigned 8-bit type:
+ * \(\texttt{dst} (I)= \texttt{saturate\_cast<uchar>} (| \texttt{src} (I)* \texttt{alpha} + \texttt{beta} |)\)
+ * In case of multi-channel arrays, the function processes each channel
+ * independently. When the output is not 8-bit, the operation can be
+ * emulated by calling the Mat::convertTo method (or by using matrix
+ * expressions) and then by calculating an absolute value of the result.
+ * For example:
+ *
+ * Mat_<float> A(30,30);
+ * randu(A, Scalar(-100), Scalar(100));
+ * Mat_<float> B = A*5 + 3;
+ * B = abs(B);
+ * // Mat_<float> B = abs(A*5+3) will also do the job,
+ * // but it will allocate a temporary matrix
+ *
+ * @param src input array.
+ * @param dst output array.
+ * SEE: Mat::convertTo, cv::abs(const Mat&)
+ */
+ public static void convertScaleAbs(Mat src, Mat dst) {
+ convertScaleAbs_2(src.nativeObj, dst.nativeObj);
+ }
+
+
+ //
+ // C++: void cv::convertFp16(Mat src, Mat& dst)
+ //
+
+ /**
+ * Converts an array to half precision floating number.
+ *
+ * This function converts FP32 (single precision floating point) from/to FP16 (half precision floating point). CV_16S format is used to represent FP16 data.
+ * There are two use modes (src -> dst): CV_32F -> CV_16S and CV_16S -> CV_32F. The input array has to have type of CV_32F or
+ * CV_16S to represent the bit depth. If the input array is neither of them, the function will raise an error.
+ * The format of half precision floating point is defined in IEEE 754-2008.
+ *
+ * @param src input array.
+ * @param dst output array.
+ */
+ public static void convertFp16(Mat src, Mat dst) {
+ convertFp16_0(src.nativeObj, dst.nativeObj);
+ }
+
+
+ //
+ // C++: void cv::LUT(Mat src, Mat lut, Mat& dst)
+ //
+
+ /**
+ * Performs a look-up table transform of an array.
+ *
+ * The function LUT fills the output array with values from the look-up table. Indices of the entries
+ * are taken from the input array. That is, the function processes each element of src as follows:
+ * \(\texttt{dst} (I) \leftarrow \texttt{lut(src(I) + d)}\)
+ * where
+ * \(d = \fork{0}{if \(\texttt{src}\) has depth \(\texttt{CV_8U}\)}{128}{if \(\texttt{src}\) has depth \(\texttt{CV_8S}\)}\)
+ * @param src input array of 8-bit elements.
+ * @param lut look-up table of 256 elements; in case of multi-channel input array, the table should
+ * either have a single channel (in this case the same table is used for all channels) or the same
+ * number of channels as in the input array.
+ * @param dst output array of the same size and number of channels as src, and the same depth as lut.
+ * SEE: convertScaleAbs, Mat::convertTo
+ */
+ public static void LUT(Mat src, Mat lut, Mat dst) {
+ LUT_0(src.nativeObj, lut.nativeObj, dst.nativeObj);
+ }
+
+
+ //
+ // C++: Scalar cv::sum(Mat src)
+ //
+
+ /**
+ * Calculates the sum of array elements.
+ *
+ * The function cv::sum calculates and returns the sum of array elements,
+ * independently for each channel.
+ * @param src input array that must have from 1 to 4 channels.
+ * SEE: countNonZero, mean, meanStdDev, norm, minMaxLoc, reduce
+ * @return automatically generated
+ */
+ public static Scalar sumElems(Mat src) {
+ return new Scalar(sumElems_0(src.nativeObj));
+ }
+
+
+ //
+ // C++: bool cv::hasNonZero(Mat src)
+ //
+
+ /**
+ * Checks for the presence of at least one non-zero array element.
+ *
+ * The function returns whether there are non-zero elements in src
+ * @param src single-channel array.
+ * SEE: mean, meanStdDev, norm, minMaxLoc, calcCovarMatrix
+ * @return automatically generated
+ */
+ public static boolean hasNonZero(Mat src) {
+ return hasNonZero_0(src.nativeObj);
+ }
+
+
+ //
+ // C++: int cv::countNonZero(Mat src)
+ //
+
+ /**
+ * Counts non-zero array elements.
+ *
+ * The function returns the number of non-zero elements in src :
+ * \(\sum _{I: \; \texttt{src} (I) \ne0 } 1\)
+ * @param src single-channel array.
+ * SEE: mean, meanStdDev, norm, minMaxLoc, calcCovarMatrix
+ * @return automatically generated
+ */
+ public static int countNonZero(Mat src) {
+ return countNonZero_0(src.nativeObj);
+ }
+
+
+ //
+ // C++: void cv::findNonZero(Mat src, Mat& idx)
+ //
+
+ /**
+ * Returns the list of locations of non-zero pixels
+ *
+ * Given a binary matrix (likely returned from an operation such
+ * as threshold(), compare(), >, ==, etc, return all of
+ * the non-zero indices as a cv::Mat or std::vector<cv::Point> (x,y)
+ * For example:
+ *
+ * cv::Mat binaryImage; // input, binary image
+ * cv::Mat locations; // output, locations of non-zero pixels
+ * cv::findNonZero(binaryImage, locations);
+ *
+ * // access pixel coordinates
+ * Point pnt = locations.at<Point>(i);
+ *
+ * or
+ *
+ * cv::Mat binaryImage; // input, binary image
+ * vector<Point> locations; // output, locations of non-zero pixels
+ * cv::findNonZero(binaryImage, locations);
+ *
+ * // access pixel coordinates
+ * Point pnt = locations[i];
+ *
+ * @param src single-channel array
+ * @param idx the output array, type of cv::Mat or std::vector<Point>, corresponding to non-zero indices in the input
+ */
+ public static void findNonZero(Mat src, Mat idx) {
+ findNonZero_0(src.nativeObj, idx.nativeObj);
+ }
+
+
+ //
+ // C++: Scalar cv::mean(Mat src, Mat mask = Mat())
+ //
+
+ /**
+ * Calculates an average (mean) of array elements.
+ *
+ * The function cv::mean calculates the mean value M of array elements,
+ * independently for each channel, and return it:
+ * \(\begin{array}{l} N = \sum _{I: \; \texttt{mask} (I) \ne 0} 1 \\ M_c = \left ( \sum _{I: \; \texttt{mask} (I) \ne 0}{ \texttt{mtx} (I)_c} \right )/N \end{array}\)
+ * When all the mask elements are 0's, the function returns Scalar::all(0)
+ * @param src input array that should have from 1 to 4 channels so that the result can be stored in
+ * Scalar_ .
+ * @param mask optional operation mask.
+ * SEE: countNonZero, meanStdDev, norm, minMaxLoc
+ * @return automatically generated
+ */
+ public static Scalar mean(Mat src, Mat mask) {
+ return new Scalar(mean_0(src.nativeObj, mask.nativeObj));
+ }
+
+ /**
+ * Calculates an average (mean) of array elements.
+ *
+ * The function cv::mean calculates the mean value M of array elements,
+ * independently for each channel, and return it:
+ * \(\begin{array}{l} N = \sum _{I: \; \texttt{mask} (I) \ne 0} 1 \\ M_c = \left ( \sum _{I: \; \texttt{mask} (I) \ne 0}{ \texttt{mtx} (I)_c} \right )/N \end{array}\)
+ * When all the mask elements are 0's, the function returns Scalar::all(0)
+ * @param src input array that should have from 1 to 4 channels so that the result can be stored in
+ * Scalar_ .
+ * SEE: countNonZero, meanStdDev, norm, minMaxLoc
+ * @return automatically generated
+ */
+ public static Scalar mean(Mat src) {
+ return new Scalar(mean_1(src.nativeObj));
+ }
+
+
+ //
+ // C++: void cv::meanStdDev(Mat src, vector_double& mean, vector_double& stddev, Mat mask = Mat())
+ //
+
+ /**
+ * Calculates a mean and standard deviation of array elements.
+ *
+ * The function cv::meanStdDev calculates the mean and the standard deviation M
+ * of array elements independently for each channel and returns it via the
+ * output parameters:
+ * \(\begin{array}{l} N = \sum _{I, \texttt{mask} (I) \ne 0} 1 \\ \texttt{mean} _c = \frac{\sum_{ I: \; \texttt{mask}(I) \ne 0} \texttt{src} (I)_c}{N} \\ \texttt{stddev} _c = \sqrt{\frac{\sum_{ I: \; \texttt{mask}(I) \ne 0} \left ( \texttt{src} (I)_c - \texttt{mean} _c \right )^2}{N}} \end{array}\)
+ * When all the mask elements are 0's, the function returns
+ * mean=stddev=Scalar::all(0).
+ * Note: The calculated standard deviation is only the diagonal of the
+ * complete normalized covariance matrix. If the full matrix is needed, you
+ * can reshape the multi-channel array M x N to the single-channel array
+ * M\*N x mtx.channels() (only possible when the matrix is continuous) and
+ * then pass the matrix to calcCovarMatrix .
+ * @param src input array that should have from 1 to 4 channels so that the results can be stored in
+ * Scalar_ 's.
+ * @param mean output parameter: calculated mean value.
+ * @param stddev output parameter: calculated standard deviation.
+ * @param mask optional operation mask.
+ * SEE: countNonZero, mean, norm, minMaxLoc, calcCovarMatrix
+ */
+ public static void meanStdDev(Mat src, MatOfDouble mean, MatOfDouble stddev, Mat mask) {
+ Mat mean_mat = mean;
+ Mat stddev_mat = stddev;
+ meanStdDev_0(src.nativeObj, mean_mat.nativeObj, stddev_mat.nativeObj, mask.nativeObj);
+ }
+
+ /**
+ * Calculates a mean and standard deviation of array elements.
+ *
+ * The function cv::meanStdDev calculates the mean and the standard deviation M
+ * of array elements independently for each channel and returns it via the
+ * output parameters:
+ * \(\begin{array}{l} N = \sum _{I, \texttt{mask} (I) \ne 0} 1 \\ \texttt{mean} _c = \frac{\sum_{ I: \; \texttt{mask}(I) \ne 0} \texttt{src} (I)_c}{N} \\ \texttt{stddev} _c = \sqrt{\frac{\sum_{ I: \; \texttt{mask}(I) \ne 0} \left ( \texttt{src} (I)_c - \texttt{mean} _c \right )^2}{N}} \end{array}\)
+ * When all the mask elements are 0's, the function returns
+ * mean=stddev=Scalar::all(0).
+ * Note: The calculated standard deviation is only the diagonal of the
+ * complete normalized covariance matrix. If the full matrix is needed, you
+ * can reshape the multi-channel array M x N to the single-channel array
+ * M\*N x mtx.channels() (only possible when the matrix is continuous) and
+ * then pass the matrix to calcCovarMatrix .
+ * @param src input array that should have from 1 to 4 channels so that the results can be stored in
+ * Scalar_ 's.
+ * @param mean output parameter: calculated mean value.
+ * @param stddev output parameter: calculated standard deviation.
+ * SEE: countNonZero, mean, norm, minMaxLoc, calcCovarMatrix
+ */
+ public static void meanStdDev(Mat src, MatOfDouble mean, MatOfDouble stddev) {
+ Mat mean_mat = mean;
+ Mat stddev_mat = stddev;
+ meanStdDev_1(src.nativeObj, mean_mat.nativeObj, stddev_mat.nativeObj);
+ }
+
+
+ //
+ // C++: double cv::norm(Mat src1, int normType = NORM_L2, Mat mask = Mat())
+ //
+
+ /**
+ * Calculates the absolute norm of an array.
+ *
+ * This version of #norm calculates the absolute norm of src1. The type of norm to calculate is specified using #NormTypes.
+ *
+ * As example for one array consider the function \(r(x)= \begin{pmatrix} x \\ 1-x \end{pmatrix}, x \in [-1;1]\).
+ * The \( L_{1}, L_{2} \) and \( L_{\infty} \) norm for the sample value \(r(-1) = \begin{pmatrix} -1 \\ 2 \end{pmatrix}\)
+ * is calculated as follows
+ * \(align*}
+ * \| r(-1) \|_{L_1} &= |-1| + |2| = 3 \\
+ * \| r(-1) \|_{L_2} &= \sqrt{(-1)^{2} + (2)^{2}} = \sqrt{5} \\
+ * \| r(-1) \|_{L_\infty} &= \max(|-1|,|2|) = 2
+ * \)
+ * and for \(r(0.5) = \begin{pmatrix} 0.5 \\ 0.5 \end{pmatrix}\) the calculation is
+ * \(align*}
+ * \| r(0.5) \|_{L_1} &= |0.5| + |0.5| = 1 \\
+ * \| r(0.5) \|_{L_2} &= \sqrt{(0.5)^{2} + (0.5)^{2}} = \sqrt{0.5} \\
+ * \| r(0.5) \|_{L_\infty} &= \max(|0.5|,|0.5|) = 0.5.
+ * \)
+ * The following graphic shows all values for the three norm functions \(\| r(x) \|_{L_1}, \| r(x) \|_{L_2}\) and \(\| r(x) \|_{L_\infty}\).
+ * It is notable that the \( L_{1} \) norm forms the upper and the \( L_{\infty} \) norm forms the lower border for the example function \( r(x) \).
+ * 
+ *
+ * When the mask parameter is specified and it is not empty, the norm is
+ *
+ * If normType is not specified, #NORM_L2 is used.
+ * calculated only over the region specified by the mask.
+ *
+ * Multi-channel input arrays are treated as single-channel arrays, that is,
+ * the results for all channels are combined.
+ *
+ * Hamming norms can only be calculated with CV_8U depth arrays.
+ *
+ * @param src1 first input array.
+ * @param normType type of the norm (see #NormTypes).
+ * @param mask optional operation mask; it must have the same size as src1 and CV_8UC1 type.
+ * @return automatically generated
+ */
+ public static double norm(Mat src1, int normType, Mat mask) {
+ return norm_0(src1.nativeObj, normType, mask.nativeObj);
+ }
+
+ /**
+ * Calculates the absolute norm of an array.
+ *
+ * This version of #norm calculates the absolute norm of src1. The type of norm to calculate is specified using #NormTypes.
+ *
+ * As example for one array consider the function \(r(x)= \begin{pmatrix} x \\ 1-x \end{pmatrix}, x \in [-1;1]\).
+ * The \( L_{1}, L_{2} \) and \( L_{\infty} \) norm for the sample value \(r(-1) = \begin{pmatrix} -1 \\ 2 \end{pmatrix}\)
+ * is calculated as follows
+ * \(align*}
+ * \| r(-1) \|_{L_1} &= |-1| + |2| = 3 \\
+ * \| r(-1) \|_{L_2} &= \sqrt{(-1)^{2} + (2)^{2}} = \sqrt{5} \\
+ * \| r(-1) \|_{L_\infty} &= \max(|-1|,|2|) = 2
+ * \)
+ * and for \(r(0.5) = \begin{pmatrix} 0.5 \\ 0.5 \end{pmatrix}\) the calculation is
+ * \(align*}
+ * \| r(0.5) \|_{L_1} &= |0.5| + |0.5| = 1 \\
+ * \| r(0.5) \|_{L_2} &= \sqrt{(0.5)^{2} + (0.5)^{2}} = \sqrt{0.5} \\
+ * \| r(0.5) \|_{L_\infty} &= \max(|0.5|,|0.5|) = 0.5.
+ * \)
+ * The following graphic shows all values for the three norm functions \(\| r(x) \|_{L_1}, \| r(x) \|_{L_2}\) and \(\| r(x) \|_{L_\infty}\).
+ * It is notable that the \( L_{1} \) norm forms the upper and the \( L_{\infty} \) norm forms the lower border for the example function \( r(x) \).
+ * 
+ *
+ * When the mask parameter is specified and it is not empty, the norm is
+ *
+ * If normType is not specified, #NORM_L2 is used.
+ * calculated only over the region specified by the mask.
+ *
+ * Multi-channel input arrays are treated as single-channel arrays, that is,
+ * the results for all channels are combined.
+ *
+ * Hamming norms can only be calculated with CV_8U depth arrays.
+ *
+ * @param src1 first input array.
+ * @param normType type of the norm (see #NormTypes).
+ * @return automatically generated
+ */
+ public static double norm(Mat src1, int normType) {
+ return norm_1(src1.nativeObj, normType);
+ }
+
+ /**
+ * Calculates the absolute norm of an array.
+ *
+ * This version of #norm calculates the absolute norm of src1. The type of norm to calculate is specified using #NormTypes.
+ *
+ * As example for one array consider the function \(r(x)= \begin{pmatrix} x \\ 1-x \end{pmatrix}, x \in [-1;1]\).
+ * The \( L_{1}, L_{2} \) and \( L_{\infty} \) norm for the sample value \(r(-1) = \begin{pmatrix} -1 \\ 2 \end{pmatrix}\)
+ * is calculated as follows
+ * \(align*}
+ * \| r(-1) \|_{L_1} &= |-1| + |2| = 3 \\
+ * \| r(-1) \|_{L_2} &= \sqrt{(-1)^{2} + (2)^{2}} = \sqrt{5} \\
+ * \| r(-1) \|_{L_\infty} &= \max(|-1|,|2|) = 2
+ * \)
+ * and for \(r(0.5) = \begin{pmatrix} 0.5 \\ 0.5 \end{pmatrix}\) the calculation is
+ * \(align*}
+ * \| r(0.5) \|_{L_1} &= |0.5| + |0.5| = 1 \\
+ * \| r(0.5) \|_{L_2} &= \sqrt{(0.5)^{2} + (0.5)^{2}} = \sqrt{0.5} \\
+ * \| r(0.5) \|_{L_\infty} &= \max(|0.5|,|0.5|) = 0.5.
+ * \)
+ * The following graphic shows all values for the three norm functions \(\| r(x) \|_{L_1}, \| r(x) \|_{L_2}\) and \(\| r(x) \|_{L_\infty}\).
+ * It is notable that the \( L_{1} \) norm forms the upper and the \( L_{\infty} \) norm forms the lower border for the example function \( r(x) \).
+ * 
+ *
+ * When the mask parameter is specified and it is not empty, the norm is
+ *
+ * If normType is not specified, #NORM_L2 is used.
+ * calculated only over the region specified by the mask.
+ *
+ * Multi-channel input arrays are treated as single-channel arrays, that is,
+ * the results for all channels are combined.
+ *
+ * Hamming norms can only be calculated with CV_8U depth arrays.
+ *
+ * @param src1 first input array.
+ * @return automatically generated
+ */
+ public static double norm(Mat src1) {
+ return norm_2(src1.nativeObj);
+ }
+
+
+ //
+ // C++: double cv::norm(Mat src1, Mat src2, int normType = NORM_L2, Mat mask = Mat())
+ //
+
+ /**
+ * Calculates an absolute difference norm or a relative difference norm.
+ *
+ * This version of cv::norm calculates the absolute difference norm
+ * or the relative difference norm of arrays src1 and src2.
+ * The type of norm to calculate is specified using #NormTypes.
+ *
+ * @param src1 first input array.
+ * @param src2 second input array of the same size and the same type as src1.
+ * @param normType type of the norm (see #NormTypes).
+ * @param mask optional operation mask; it must have the same size as src1 and CV_8UC1 type.
+ * @return automatically generated
+ */
+ public static double norm(Mat src1, Mat src2, int normType, Mat mask) {
+ return norm_3(src1.nativeObj, src2.nativeObj, normType, mask.nativeObj);
+ }
+
+ /**
+ * Calculates an absolute difference norm or a relative difference norm.
+ *
+ * This version of cv::norm calculates the absolute difference norm
+ * or the relative difference norm of arrays src1 and src2.
+ * The type of norm to calculate is specified using #NormTypes.
+ *
+ * @param src1 first input array.
+ * @param src2 second input array of the same size and the same type as src1.
+ * @param normType type of the norm (see #NormTypes).
+ * @return automatically generated
+ */
+ public static double norm(Mat src1, Mat src2, int normType) {
+ return norm_4(src1.nativeObj, src2.nativeObj, normType);
+ }
+
+ /**
+ * Calculates an absolute difference norm or a relative difference norm.
+ *
+ * This version of cv::norm calculates the absolute difference norm
+ * or the relative difference norm of arrays src1 and src2.
+ * The type of norm to calculate is specified using #NormTypes.
+ *
+ * @param src1 first input array.
+ * @param src2 second input array of the same size and the same type as src1.
+ * @return automatically generated
+ */
+ public static double norm(Mat src1, Mat src2) {
+ return norm_5(src1.nativeObj, src2.nativeObj);
+ }
+
+
+ //
+ // C++: double cv::PSNR(Mat src1, Mat src2, double R = 255.)
+ //
+
+ /**
+ * Computes the Peak Signal-to-Noise Ratio (PSNR) image quality metric.
+ *
+ * This function calculates the Peak Signal-to-Noise Ratio (PSNR) image quality metric in decibels (dB),
+ * between two input arrays src1 and src2. The arrays must have the same type.
+ *
+ * The PSNR is calculated as follows:
+ *
+ * \(
+ * \texttt{PSNR} = 10 \cdot \log_{10}{\left( \frac{R^2}{MSE} \right) }
+ * \)
+ *
+ * where R is the maximum integer value of depth (e.g. 255 in the case of CV_8U data)
+ * and MSE is the mean squared error between the two arrays.
+ *
+ * @param src1 first input array.
+ * @param src2 second input array of the same size as src1.
+ * @param R the maximum pixel value (255 by default)
+ * @return automatically generated
+ */
+ public static double PSNR(Mat src1, Mat src2, double R) {
+ return PSNR_0(src1.nativeObj, src2.nativeObj, R);
+ }
+
+ /**
+ * Computes the Peak Signal-to-Noise Ratio (PSNR) image quality metric.
+ *
+ * This function calculates the Peak Signal-to-Noise Ratio (PSNR) image quality metric in decibels (dB),
+ * between two input arrays src1 and src2. The arrays must have the same type.
+ *
+ * The PSNR is calculated as follows:
+ *
+ * \(
+ * \texttt{PSNR} = 10 \cdot \log_{10}{\left( \frac{R^2}{MSE} \right) }
+ * \)
+ *
+ * where R is the maximum integer value of depth (e.g. 255 in the case of CV_8U data)
+ * and MSE is the mean squared error between the two arrays.
+ *
+ * @param src1 first input array.
+ * @param src2 second input array of the same size as src1.
+ * @return automatically generated
+ */
+ public static double PSNR(Mat src1, Mat src2) {
+ return PSNR_1(src1.nativeObj, src2.nativeObj);
+ }
+
+
+ //
+ // C++: void cv::batchDistance(Mat src1, Mat src2, Mat& dist, int dtype, Mat& nidx, int normType = NORM_L2, int K = 0, Mat mask = Mat(), int update = 0, bool crosscheck = false)
+ //
+
+ /**
+ * naive nearest neighbor finder
+ *
+ * see http://en.wikipedia.org/wiki/Nearest_neighbor_search
+ * TODO: document
+ * @param src1 automatically generated
+ * @param src2 automatically generated
+ * @param dist automatically generated
+ * @param dtype automatically generated
+ * @param nidx automatically generated
+ * @param normType automatically generated
+ * @param K automatically generated
+ * @param mask automatically generated
+ * @param update automatically generated
+ * @param crosscheck automatically generated
+ */
+ public static void batchDistance(Mat src1, Mat src2, Mat dist, int dtype, Mat nidx, int normType, int K, Mat mask, int update, boolean crosscheck) {
+ batchDistance_0(src1.nativeObj, src2.nativeObj, dist.nativeObj, dtype, nidx.nativeObj, normType, K, mask.nativeObj, update, crosscheck);
+ }
+
+ /**
+ * naive nearest neighbor finder
+ *
+ * see http://en.wikipedia.org/wiki/Nearest_neighbor_search
+ * TODO: document
+ * @param src1 automatically generated
+ * @param src2 automatically generated
+ * @param dist automatically generated
+ * @param dtype automatically generated
+ * @param nidx automatically generated
+ * @param normType automatically generated
+ * @param K automatically generated
+ * @param mask automatically generated
+ * @param update automatically generated
+ */
+ public static void batchDistance(Mat src1, Mat src2, Mat dist, int dtype, Mat nidx, int normType, int K, Mat mask, int update) {
+ batchDistance_1(src1.nativeObj, src2.nativeObj, dist.nativeObj, dtype, nidx.nativeObj, normType, K, mask.nativeObj, update);
+ }
+
+ /**
+ * naive nearest neighbor finder
+ *
+ * see http://en.wikipedia.org/wiki/Nearest_neighbor_search
+ * TODO: document
+ * @param src1 automatically generated
+ * @param src2 automatically generated
+ * @param dist automatically generated
+ * @param dtype automatically generated
+ * @param nidx automatically generated
+ * @param normType automatically generated
+ * @param K automatically generated
+ * @param mask automatically generated
+ */
+ public static void batchDistance(Mat src1, Mat src2, Mat dist, int dtype, Mat nidx, int normType, int K, Mat mask) {
+ batchDistance_2(src1.nativeObj, src2.nativeObj, dist.nativeObj, dtype, nidx.nativeObj, normType, K, mask.nativeObj);
+ }
+
+ /**
+ * naive nearest neighbor finder
+ *
+ * see http://en.wikipedia.org/wiki/Nearest_neighbor_search
+ * TODO: document
+ * @param src1 automatically generated
+ * @param src2 automatically generated
+ * @param dist automatically generated
+ * @param dtype automatically generated
+ * @param nidx automatically generated
+ * @param normType automatically generated
+ * @param K automatically generated
+ */
+ public static void batchDistance(Mat src1, Mat src2, Mat dist, int dtype, Mat nidx, int normType, int K) {
+ batchDistance_3(src1.nativeObj, src2.nativeObj, dist.nativeObj, dtype, nidx.nativeObj, normType, K);
+ }
+
+ /**
+ * naive nearest neighbor finder
+ *
+ * see http://en.wikipedia.org/wiki/Nearest_neighbor_search
+ * TODO: document
+ * @param src1 automatically generated
+ * @param src2 automatically generated
+ * @param dist automatically generated
+ * @param dtype automatically generated
+ * @param nidx automatically generated
+ * @param normType automatically generated
+ */
+ public static void batchDistance(Mat src1, Mat src2, Mat dist, int dtype, Mat nidx, int normType) {
+ batchDistance_4(src1.nativeObj, src2.nativeObj, dist.nativeObj, dtype, nidx.nativeObj, normType);
+ }
+
+ /**
+ * naive nearest neighbor finder
+ *
+ * see http://en.wikipedia.org/wiki/Nearest_neighbor_search
+ * TODO: document
+ * @param src1 automatically generated
+ * @param src2 automatically generated
+ * @param dist automatically generated
+ * @param dtype automatically generated
+ * @param nidx automatically generated
+ */
+ public static void batchDistance(Mat src1, Mat src2, Mat dist, int dtype, Mat nidx) {
+ batchDistance_5(src1.nativeObj, src2.nativeObj, dist.nativeObj, dtype, nidx.nativeObj);
+ }
+
+
+ //
+ // C++: void cv::normalize(Mat src, Mat& dst, double alpha = 1, double beta = 0, int norm_type = NORM_L2, int dtype = -1, Mat mask = Mat())
+ //
+
+ /**
+ * Normalizes the norm or value range of an array.
+ *
+ * The function cv::normalize normalizes scale and shift the input array elements so that
+ * \(\| \texttt{dst} \| _{L_p}= \texttt{alpha}\)
+ * (where p=Inf, 1 or 2) when normType=NORM_INF, NORM_L1, or NORM_L2, respectively; or so that
+ * \(\min _I \texttt{dst} (I)= \texttt{alpha} , \, \, \max _I \texttt{dst} (I)= \texttt{beta}\)
+ *
+ * when normType=NORM_MINMAX (for dense arrays only). The optional mask specifies a sub-array to be
+ * normalized. This means that the norm or min-n-max are calculated over the sub-array, and then this
+ * sub-array is modified to be normalized. If you want to only use the mask to calculate the norm or
+ * min-max but modify the whole array, you can use norm and Mat::convertTo.
+ *
+ * In case of sparse matrices, only the non-zero values are analyzed and transformed. Because of this,
+ * the range transformation for sparse matrices is not allowed since it can shift the zero level.
+ *
+ * Possible usage with some positive example data:
+ *
+ * vector<double> positiveData = { 2.0, 8.0, 10.0 };
+ * vector<double> normalizedData_l1, normalizedData_l2, normalizedData_inf, normalizedData_minmax;
+ *
+ * // Norm to probability (total count)
+ * // sum(numbers) = 20.0
+ * // 2.0 0.1 (2.0/20.0)
+ * // 8.0 0.4 (8.0/20.0)
+ * // 10.0 0.5 (10.0/20.0)
+ * normalize(positiveData, normalizedData_l1, 1.0, 0.0, NORM_L1);
+ *
+ * // Norm to unit vector: ||positiveData|| = 1.0
+ * // 2.0 0.15
+ * // 8.0 0.62
+ * // 10.0 0.77
+ * normalize(positiveData, normalizedData_l2, 1.0, 0.0, NORM_L2);
+ *
+ * // Norm to max element
+ * // 2.0 0.2 (2.0/10.0)
+ * // 8.0 0.8 (8.0/10.0)
+ * // 10.0 1.0 (10.0/10.0)
+ * normalize(positiveData, normalizedData_inf, 1.0, 0.0, NORM_INF);
+ *
+ * // Norm to range [0.0;1.0]
+ * // 2.0 0.0 (shift to left border)
+ * // 8.0 0.75 (6.0/8.0)
+ * // 10.0 1.0 (shift to right border)
+ * normalize(positiveData, normalizedData_minmax, 1.0, 0.0, NORM_MINMAX);
+ *
+ *
+ * @param src input array.
+ * @param dst output array of the same size as src .
+ * @param alpha norm value to normalize to or the lower range boundary in case of the range
+ * normalization.
+ * @param beta upper range boundary in case of the range normalization; it is not used for the norm
+ * normalization.
+ * @param norm_type normalization type (see cv::NormTypes).
+ * @param dtype when negative, the output array has the same type as src; otherwise, it has the same
+ * number of channels as src and the depth =CV_MAT_DEPTH(dtype).
+ * @param mask optional operation mask.
+ * SEE: norm, Mat::convertTo, SparseMat::convertTo
+ */
+ public static void normalize(Mat src, Mat dst, double alpha, double beta, int norm_type, int dtype, Mat mask) {
+ normalize_0(src.nativeObj, dst.nativeObj, alpha, beta, norm_type, dtype, mask.nativeObj);
+ }
+
+ /**
+ * Normalizes the norm or value range of an array.
+ *
+ * The function cv::normalize normalizes scale and shift the input array elements so that
+ * \(\| \texttt{dst} \| _{L_p}= \texttt{alpha}\)
+ * (where p=Inf, 1 or 2) when normType=NORM_INF, NORM_L1, or NORM_L2, respectively; or so that
+ * \(\min _I \texttt{dst} (I)= \texttt{alpha} , \, \, \max _I \texttt{dst} (I)= \texttt{beta}\)
+ *
+ * when normType=NORM_MINMAX (for dense arrays only). The optional mask specifies a sub-array to be
+ * normalized. This means that the norm or min-n-max are calculated over the sub-array, and then this
+ * sub-array is modified to be normalized. If you want to only use the mask to calculate the norm or
+ * min-max but modify the whole array, you can use norm and Mat::convertTo.
+ *
+ * In case of sparse matrices, only the non-zero values are analyzed and transformed. Because of this,
+ * the range transformation for sparse matrices is not allowed since it can shift the zero level.
+ *
+ * Possible usage with some positive example data:
+ *
+ * vector<double> positiveData = { 2.0, 8.0, 10.0 };
+ * vector<double> normalizedData_l1, normalizedData_l2, normalizedData_inf, normalizedData_minmax;
+ *
+ * // Norm to probability (total count)
+ * // sum(numbers) = 20.0
+ * // 2.0 0.1 (2.0/20.0)
+ * // 8.0 0.4 (8.0/20.0)
+ * // 10.0 0.5 (10.0/20.0)
+ * normalize(positiveData, normalizedData_l1, 1.0, 0.0, NORM_L1);
+ *
+ * // Norm to unit vector: ||positiveData|| = 1.0
+ * // 2.0 0.15
+ * // 8.0 0.62
+ * // 10.0 0.77
+ * normalize(positiveData, normalizedData_l2, 1.0, 0.0, NORM_L2);
+ *
+ * // Norm to max element
+ * // 2.0 0.2 (2.0/10.0)
+ * // 8.0 0.8 (8.0/10.0)
+ * // 10.0 1.0 (10.0/10.0)
+ * normalize(positiveData, normalizedData_inf, 1.0, 0.0, NORM_INF);
+ *
+ * // Norm to range [0.0;1.0]
+ * // 2.0 0.0 (shift to left border)
+ * // 8.0 0.75 (6.0/8.0)
+ * // 10.0 1.0 (shift to right border)
+ * normalize(positiveData, normalizedData_minmax, 1.0, 0.0, NORM_MINMAX);
+ *
+ *
+ * @param src input array.
+ * @param dst output array of the same size as src .
+ * @param alpha norm value to normalize to or the lower range boundary in case of the range
+ * normalization.
+ * @param beta upper range boundary in case of the range normalization; it is not used for the norm
+ * normalization.
+ * @param norm_type normalization type (see cv::NormTypes).
+ * @param dtype when negative, the output array has the same type as src; otherwise, it has the same
+ * number of channels as src and the depth =CV_MAT_DEPTH(dtype).
+ * SEE: norm, Mat::convertTo, SparseMat::convertTo
+ */
+ public static void normalize(Mat src, Mat dst, double alpha, double beta, int norm_type, int dtype) {
+ normalize_1(src.nativeObj, dst.nativeObj, alpha, beta, norm_type, dtype);
+ }
+
+ /**
+ * Normalizes the norm or value range of an array.
+ *
+ * The function cv::normalize normalizes scale and shift the input array elements so that
+ * \(\| \texttt{dst} \| _{L_p}= \texttt{alpha}\)
+ * (where p=Inf, 1 or 2) when normType=NORM_INF, NORM_L1, or NORM_L2, respectively; or so that
+ * \(\min _I \texttt{dst} (I)= \texttt{alpha} , \, \, \max _I \texttt{dst} (I)= \texttt{beta}\)
+ *
+ * when normType=NORM_MINMAX (for dense arrays only). The optional mask specifies a sub-array to be
+ * normalized. This means that the norm or min-n-max are calculated over the sub-array, and then this
+ * sub-array is modified to be normalized. If you want to only use the mask to calculate the norm or
+ * min-max but modify the whole array, you can use norm and Mat::convertTo.
+ *
+ * In case of sparse matrices, only the non-zero values are analyzed and transformed. Because of this,
+ * the range transformation for sparse matrices is not allowed since it can shift the zero level.
+ *
+ * Possible usage with some positive example data:
+ *
+ * vector<double> positiveData = { 2.0, 8.0, 10.0 };
+ * vector<double> normalizedData_l1, normalizedData_l2, normalizedData_inf, normalizedData_minmax;
+ *
+ * // Norm to probability (total count)
+ * // sum(numbers) = 20.0
+ * // 2.0 0.1 (2.0/20.0)
+ * // 8.0 0.4 (8.0/20.0)
+ * // 10.0 0.5 (10.0/20.0)
+ * normalize(positiveData, normalizedData_l1, 1.0, 0.0, NORM_L1);
+ *
+ * // Norm to unit vector: ||positiveData|| = 1.0
+ * // 2.0 0.15
+ * // 8.0 0.62
+ * // 10.0 0.77
+ * normalize(positiveData, normalizedData_l2, 1.0, 0.0, NORM_L2);
+ *
+ * // Norm to max element
+ * // 2.0 0.2 (2.0/10.0)
+ * // 8.0 0.8 (8.0/10.0)
+ * // 10.0 1.0 (10.0/10.0)
+ * normalize(positiveData, normalizedData_inf, 1.0, 0.0, NORM_INF);
+ *
+ * // Norm to range [0.0;1.0]
+ * // 2.0 0.0 (shift to left border)
+ * // 8.0 0.75 (6.0/8.0)
+ * // 10.0 1.0 (shift to right border)
+ * normalize(positiveData, normalizedData_minmax, 1.0, 0.0, NORM_MINMAX);
+ *
+ *
+ * @param src input array.
+ * @param dst output array of the same size as src .
+ * @param alpha norm value to normalize to or the lower range boundary in case of the range
+ * normalization.
+ * @param beta upper range boundary in case of the range normalization; it is not used for the norm
+ * normalization.
+ * @param norm_type normalization type (see cv::NormTypes).
+ * number of channels as src and the depth =CV_MAT_DEPTH(dtype).
+ * SEE: norm, Mat::convertTo, SparseMat::convertTo
+ */
+ public static void normalize(Mat src, Mat dst, double alpha, double beta, int norm_type) {
+ normalize_2(src.nativeObj, dst.nativeObj, alpha, beta, norm_type);
+ }
+
+ /**
+ * Normalizes the norm or value range of an array.
+ *
+ * The function cv::normalize normalizes scale and shift the input array elements so that
+ * \(\| \texttt{dst} \| _{L_p}= \texttt{alpha}\)
+ * (where p=Inf, 1 or 2) when normType=NORM_INF, NORM_L1, or NORM_L2, respectively; or so that
+ * \(\min _I \texttt{dst} (I)= \texttt{alpha} , \, \, \max _I \texttt{dst} (I)= \texttt{beta}\)
+ *
+ * when normType=NORM_MINMAX (for dense arrays only). The optional mask specifies a sub-array to be
+ * normalized. This means that the norm or min-n-max are calculated over the sub-array, and then this
+ * sub-array is modified to be normalized. If you want to only use the mask to calculate the norm or
+ * min-max but modify the whole array, you can use norm and Mat::convertTo.
+ *
+ * In case of sparse matrices, only the non-zero values are analyzed and transformed. Because of this,
+ * the range transformation for sparse matrices is not allowed since it can shift the zero level.
+ *
+ * Possible usage with some positive example data:
+ *
+ * vector<double> positiveData = { 2.0, 8.0, 10.0 };
+ * vector<double> normalizedData_l1, normalizedData_l2, normalizedData_inf, normalizedData_minmax;
+ *
+ * // Norm to probability (total count)
+ * // sum(numbers) = 20.0
+ * // 2.0 0.1 (2.0/20.0)
+ * // 8.0 0.4 (8.0/20.0)
+ * // 10.0 0.5 (10.0/20.0)
+ * normalize(positiveData, normalizedData_l1, 1.0, 0.0, NORM_L1);
+ *
+ * // Norm to unit vector: ||positiveData|| = 1.0
+ * // 2.0 0.15
+ * // 8.0 0.62
+ * // 10.0 0.77
+ * normalize(positiveData, normalizedData_l2, 1.0, 0.0, NORM_L2);
+ *
+ * // Norm to max element
+ * // 2.0 0.2 (2.0/10.0)
+ * // 8.0 0.8 (8.0/10.0)
+ * // 10.0 1.0 (10.0/10.0)
+ * normalize(positiveData, normalizedData_inf, 1.0, 0.0, NORM_INF);
+ *
+ * // Norm to range [0.0;1.0]
+ * // 2.0 0.0 (shift to left border)
+ * // 8.0 0.75 (6.0/8.0)
+ * // 10.0 1.0 (shift to right border)
+ * normalize(positiveData, normalizedData_minmax, 1.0, 0.0, NORM_MINMAX);
+ *
+ *
+ * @param src input array.
+ * @param dst output array of the same size as src .
+ * @param alpha norm value to normalize to or the lower range boundary in case of the range
+ * normalization.
+ * @param beta upper range boundary in case of the range normalization; it is not used for the norm
+ * normalization.
+ * number of channels as src and the depth =CV_MAT_DEPTH(dtype).
+ * SEE: norm, Mat::convertTo, SparseMat::convertTo
+ */
+ public static void normalize(Mat src, Mat dst, double alpha, double beta) {
+ normalize_3(src.nativeObj, dst.nativeObj, alpha, beta);
+ }
+
+ /**
+ * Normalizes the norm or value range of an array.
+ *
+ * The function cv::normalize normalizes scale and shift the input array elements so that
+ * \(\| \texttt{dst} \| _{L_p}= \texttt{alpha}\)
+ * (where p=Inf, 1 or 2) when normType=NORM_INF, NORM_L1, or NORM_L2, respectively; or so that
+ * \(\min _I \texttt{dst} (I)= \texttt{alpha} , \, \, \max _I \texttt{dst} (I)= \texttt{beta}\)
+ *
+ * when normType=NORM_MINMAX (for dense arrays only). The optional mask specifies a sub-array to be
+ * normalized. This means that the norm or min-n-max are calculated over the sub-array, and then this
+ * sub-array is modified to be normalized. If you want to only use the mask to calculate the norm or
+ * min-max but modify the whole array, you can use norm and Mat::convertTo.
+ *
+ * In case of sparse matrices, only the non-zero values are analyzed and transformed. Because of this,
+ * the range transformation for sparse matrices is not allowed since it can shift the zero level.
+ *
+ * Possible usage with some positive example data:
+ *
+ * vector<double> positiveData = { 2.0, 8.0, 10.0 };
+ * vector<double> normalizedData_l1, normalizedData_l2, normalizedData_inf, normalizedData_minmax;
+ *
+ * // Norm to probability (total count)
+ * // sum(numbers) = 20.0
+ * // 2.0 0.1 (2.0/20.0)
+ * // 8.0 0.4 (8.0/20.0)
+ * // 10.0 0.5 (10.0/20.0)
+ * normalize(positiveData, normalizedData_l1, 1.0, 0.0, NORM_L1);
+ *
+ * // Norm to unit vector: ||positiveData|| = 1.0
+ * // 2.0 0.15
+ * // 8.0 0.62
+ * // 10.0 0.77
+ * normalize(positiveData, normalizedData_l2, 1.0, 0.0, NORM_L2);
+ *
+ * // Norm to max element
+ * // 2.0 0.2 (2.0/10.0)
+ * // 8.0 0.8 (8.0/10.0)
+ * // 10.0 1.0 (10.0/10.0)
+ * normalize(positiveData, normalizedData_inf, 1.0, 0.0, NORM_INF);
+ *
+ * // Norm to range [0.0;1.0]
+ * // 2.0 0.0 (shift to left border)
+ * // 8.0 0.75 (6.0/8.0)
+ * // 10.0 1.0 (shift to right border)
+ * normalize(positiveData, normalizedData_minmax, 1.0, 0.0, NORM_MINMAX);
+ *
+ *
+ * @param src input array.
+ * @param dst output array of the same size as src .
+ * @param alpha norm value to normalize to or the lower range boundary in case of the range
+ * normalization.
+ * normalization.
+ * number of channels as src and the depth =CV_MAT_DEPTH(dtype).
+ * SEE: norm, Mat::convertTo, SparseMat::convertTo
+ */
+ public static void normalize(Mat src, Mat dst, double alpha) {
+ normalize_4(src.nativeObj, dst.nativeObj, alpha);
+ }
+
+ /**
+ * Normalizes the norm or value range of an array.
+ *
+ * The function cv::normalize normalizes scale and shift the input array elements so that
+ * \(\| \texttt{dst} \| _{L_p}= \texttt{alpha}\)
+ * (where p=Inf, 1 or 2) when normType=NORM_INF, NORM_L1, or NORM_L2, respectively; or so that
+ * \(\min _I \texttt{dst} (I)= \texttt{alpha} , \, \, \max _I \texttt{dst} (I)= \texttt{beta}\)
+ *
+ * when normType=NORM_MINMAX (for dense arrays only). The optional mask specifies a sub-array to be
+ * normalized. This means that the norm or min-n-max are calculated over the sub-array, and then this
+ * sub-array is modified to be normalized. If you want to only use the mask to calculate the norm or
+ * min-max but modify the whole array, you can use norm and Mat::convertTo.
+ *
+ * In case of sparse matrices, only the non-zero values are analyzed and transformed. Because of this,
+ * the range transformation for sparse matrices is not allowed since it can shift the zero level.
+ *
+ * Possible usage with some positive example data:
+ *
+ * vector<double> positiveData = { 2.0, 8.0, 10.0 };
+ * vector<double> normalizedData_l1, normalizedData_l2, normalizedData_inf, normalizedData_minmax;
+ *
+ * // Norm to probability (total count)
+ * // sum(numbers) = 20.0
+ * // 2.0 0.1 (2.0/20.0)
+ * // 8.0 0.4 (8.0/20.0)
+ * // 10.0 0.5 (10.0/20.0)
+ * normalize(positiveData, normalizedData_l1, 1.0, 0.0, NORM_L1);
+ *
+ * // Norm to unit vector: ||positiveData|| = 1.0
+ * // 2.0 0.15
+ * // 8.0 0.62
+ * // 10.0 0.77
+ * normalize(positiveData, normalizedData_l2, 1.0, 0.0, NORM_L2);
+ *
+ * // Norm to max element
+ * // 2.0 0.2 (2.0/10.0)
+ * // 8.0 0.8 (8.0/10.0)
+ * // 10.0 1.0 (10.0/10.0)
+ * normalize(positiveData, normalizedData_inf, 1.0, 0.0, NORM_INF);
+ *
+ * // Norm to range [0.0;1.0]
+ * // 2.0 0.0 (shift to left border)
+ * // 8.0 0.75 (6.0/8.0)
+ * // 10.0 1.0 (shift to right border)
+ * normalize(positiveData, normalizedData_minmax, 1.0, 0.0, NORM_MINMAX);
+ *
+ *
+ * @param src input array.
+ * @param dst output array of the same size as src .
+ * normalization.
+ * normalization.
+ * number of channels as src and the depth =CV_MAT_DEPTH(dtype).
+ * SEE: norm, Mat::convertTo, SparseMat::convertTo
+ */
+ public static void normalize(Mat src, Mat dst) {
+ normalize_5(src.nativeObj, dst.nativeObj);
+ }
+
+
+ //
+ // C++: void cv::reduceArgMin(Mat src, Mat& dst, int axis, bool lastIndex = false)
+ //
+
+ /**
+ * Finds indices of min elements along provided axis
+ *
+ * Note:
+ * - If input or output array is not continuous, this function will create an internal copy.
+ * - NaN handling is left unspecified, see patchNaNs().
+ * - The returned index is always in bounds of input matrix.
+ *
+ * @param src input single-channel array.
+ * @param dst output array of type CV_32SC1 with the same dimensionality as src,
+ * except for axis being reduced - it should be set to 1.
+ * @param lastIndex whether to get the index of first or last occurrence of min.
+ * @param axis axis to reduce along.
+ * SEE: reduceArgMax, minMaxLoc, min, max, compare, reduce
+ */
+ public static void reduceArgMin(Mat src, Mat dst, int axis, boolean lastIndex) {
+ reduceArgMin_0(src.nativeObj, dst.nativeObj, axis, lastIndex);
+ }
+
+ /**
+ * Finds indices of min elements along provided axis
+ *
+ * Note:
+ * - If input or output array is not continuous, this function will create an internal copy.
+ * - NaN handling is left unspecified, see patchNaNs().
+ * - The returned index is always in bounds of input matrix.
+ *
+ * @param src input single-channel array.
+ * @param dst output array of type CV_32SC1 with the same dimensionality as src,
+ * except for axis being reduced - it should be set to 1.
+ * @param axis axis to reduce along.
+ * SEE: reduceArgMax, minMaxLoc, min, max, compare, reduce
+ */
+ public static void reduceArgMin(Mat src, Mat dst, int axis) {
+ reduceArgMin_1(src.nativeObj, dst.nativeObj, axis);
+ }
+
+
+ //
+ // C++: void cv::reduceArgMax(Mat src, Mat& dst, int axis, bool lastIndex = false)
+ //
+
+ /**
+ * Finds indices of max elements along provided axis
+ *
+ * Note:
+ * - If input or output array is not continuous, this function will create an internal copy.
+ * - NaN handling is left unspecified, see patchNaNs().
+ * - The returned index is always in bounds of input matrix.
+ *
+ * @param src input single-channel array.
+ * @param dst output array of type CV_32SC1 with the same dimensionality as src,
+ * except for axis being reduced - it should be set to 1.
+ * @param lastIndex whether to get the index of first or last occurrence of max.
+ * @param axis axis to reduce along.
+ * SEE: reduceArgMin, minMaxLoc, min, max, compare, reduce
+ */
+ public static void reduceArgMax(Mat src, Mat dst, int axis, boolean lastIndex) {
+ reduceArgMax_0(src.nativeObj, dst.nativeObj, axis, lastIndex);
+ }
+
+ /**
+ * Finds indices of max elements along provided axis
+ *
+ * Note:
+ * - If input or output array is not continuous, this function will create an internal copy.
+ * - NaN handling is left unspecified, see patchNaNs().
+ * - The returned index is always in bounds of input matrix.
+ *
+ * @param src input single-channel array.
+ * @param dst output array of type CV_32SC1 with the same dimensionality as src,
+ * except for axis being reduced - it should be set to 1.
+ * @param axis axis to reduce along.
+ * SEE: reduceArgMin, minMaxLoc, min, max, compare, reduce
+ */
+ public static void reduceArgMax(Mat src, Mat dst, int axis) {
+ reduceArgMax_1(src.nativeObj, dst.nativeObj, axis);
+ }
+
+
+ //
+ // C++: void cv::reduce(Mat src, Mat& dst, int dim, int rtype, int dtype = -1)
+ //
+
+ /**
+ * Reduces a matrix to a vector.
+ *
+ * The function #reduce reduces the matrix to a vector by treating the matrix rows/columns as a set of
+ * 1D vectors and performing the specified operation on the vectors until a single row/column is
+ * obtained. For example, the function can be used to compute horizontal and vertical projections of a
+ * raster image. In case of #REDUCE_MAX and #REDUCE_MIN , the output image should have the same type as the source one.
+ * In case of #REDUCE_SUM, #REDUCE_SUM2 and #REDUCE_AVG , the output may have a larger element bit-depth to preserve accuracy.
+ * And multi-channel arrays are also supported in these two reduction modes.
+ *
+ * The following code demonstrates its usage for a single channel matrix.
+ * SNIPPET: snippets/core_reduce.cpp example
+ *
+ * And the following code demonstrates its usage for a two-channel matrix.
+ * SNIPPET: snippets/core_reduce.cpp example2
+ *
+ * @param src input 2D matrix.
+ * @param dst output vector. Its size and type is defined by dim and dtype parameters.
+ * @param dim dimension index along which the matrix is reduced. 0 means that the matrix is reduced to
+ * a single row. 1 means that the matrix is reduced to a single column.
+ * @param rtype reduction operation that could be one of #ReduceTypes
+ * @param dtype when negative, the output vector will have the same type as the input matrix,
+ * otherwise, its type will be CV_MAKE_TYPE(CV_MAT_DEPTH(dtype), src.channels()).
+ * SEE: repeat, reduceArgMin, reduceArgMax
+ */
+ public static void reduce(Mat src, Mat dst, int dim, int rtype, int dtype) {
+ reduce_0(src.nativeObj, dst.nativeObj, dim, rtype, dtype);
+ }
+
+ /**
+ * Reduces a matrix to a vector.
+ *
+ * The function #reduce reduces the matrix to a vector by treating the matrix rows/columns as a set of
+ * 1D vectors and performing the specified operation on the vectors until a single row/column is
+ * obtained. For example, the function can be used to compute horizontal and vertical projections of a
+ * raster image. In case of #REDUCE_MAX and #REDUCE_MIN , the output image should have the same type as the source one.
+ * In case of #REDUCE_SUM, #REDUCE_SUM2 and #REDUCE_AVG , the output may have a larger element bit-depth to preserve accuracy.
+ * And multi-channel arrays are also supported in these two reduction modes.
+ *
+ * The following code demonstrates its usage for a single channel matrix.
+ * SNIPPET: snippets/core_reduce.cpp example
+ *
+ * And the following code demonstrates its usage for a two-channel matrix.
+ * SNIPPET: snippets/core_reduce.cpp example2
+ *
+ * @param src input 2D matrix.
+ * @param dst output vector. Its size and type is defined by dim and dtype parameters.
+ * @param dim dimension index along which the matrix is reduced. 0 means that the matrix is reduced to
+ * a single row. 1 means that the matrix is reduced to a single column.
+ * @param rtype reduction operation that could be one of #ReduceTypes
+ * otherwise, its type will be CV_MAKE_TYPE(CV_MAT_DEPTH(dtype), src.channels()).
+ * SEE: repeat, reduceArgMin, reduceArgMax
+ */
+ public static void reduce(Mat src, Mat dst, int dim, int rtype) {
+ reduce_1(src.nativeObj, dst.nativeObj, dim, rtype);
+ }
+
+
+ //
+ // C++: void cv::merge(vector_Mat mv, Mat& dst)
+ //
+
+ /**
+ *
+ * @param mv input vector of matrices to be merged; all the matrices in mv must have the same
+ * size and the same depth.
+ * @param dst output array of the same size and the same depth as mv[0]; The number of channels will
+ * be the total number of channels in the matrix array.
+ */
+ public static void merge(List mv, Mat dst) {
+ Mat mv_mat = Converters.vector_Mat_to_Mat(mv);
+ merge_0(mv_mat.nativeObj, dst.nativeObj);
+ }
+
+
+ //
+ // C++: void cv::split(Mat m, vector_Mat& mv)
+ //
+
+ /**
+ *
+ * @param m input multi-channel array.
+ * @param mv output vector of arrays; the arrays themselves are reallocated, if needed.
+ */
+ public static void split(Mat m, List mv) {
+ Mat mv_mat = new Mat();
+ split_0(m.nativeObj, mv_mat.nativeObj);
+ Converters.Mat_to_vector_Mat(mv_mat, mv);
+ mv_mat.release();
+ }
+
+
+ //
+ // C++: void cv::mixChannels(vector_Mat src, vector_Mat dst, vector_int fromTo)
+ //
+
+ /**
+ *
+ * @param src input array or vector of matrices; all of the matrices must have the same size and the
+ * same depth.
+ * @param dst output array or vector of matrices; all the matrices must be allocated; their size and
+ * depth must be the same as in src[0].
+ * @param fromTo array of index pairs specifying which channels are copied and where; fromTo[k\*2] is
+ * a 0-based index of the input channel in src, fromTo[k\*2+1] is an index of the output channel in
+ * dst; the continuous channel numbering is used: the first input image channels are indexed from 0 to
+ * src[0].channels()-1, the second input image channels are indexed from src[0].channels() to
+ * src[0].channels() + src[1].channels()-1, and so on, the same scheme is used for the output image
+ * channels; as a special case, when fromTo[k\*2] is negative, the corresponding output channel is
+ * filled with zero .
+ */
+ public static void mixChannels(List src, List dst, MatOfInt fromTo) {
+ Mat src_mat = Converters.vector_Mat_to_Mat(src);
+ Mat dst_mat = Converters.vector_Mat_to_Mat(dst);
+ Mat fromTo_mat = fromTo;
+ mixChannels_0(src_mat.nativeObj, dst_mat.nativeObj, fromTo_mat.nativeObj);
+ }
+
+
+ //
+ // C++: void cv::extractChannel(Mat src, Mat& dst, int coi)
+ //
+
+ /**
+ * Extracts a single channel from src (coi is 0-based index)
+ * @param src input array
+ * @param dst output array
+ * @param coi index of channel to extract
+ * SEE: mixChannels, split
+ */
+ public static void extractChannel(Mat src, Mat dst, int coi) {
+ extractChannel_0(src.nativeObj, dst.nativeObj, coi);
+ }
+
+
+ //
+ // C++: void cv::insertChannel(Mat src, Mat& dst, int coi)
+ //
+
+ /**
+ * Inserts a single channel to dst (coi is 0-based index)
+ * @param src input array
+ * @param dst output array
+ * @param coi index of channel for insertion
+ * SEE: mixChannels, merge
+ */
+ public static void insertChannel(Mat src, Mat dst, int coi) {
+ insertChannel_0(src.nativeObj, dst.nativeObj, coi);
+ }
+
+
+ //
+ // C++: void cv::flip(Mat src, Mat& dst, int flipCode)
+ //
+
+ /**
+ * Flips a 2D array around vertical, horizontal, or both axes.
+ *
+ * The function cv::flip flips the array in one of three different ways (row
+ * and column indices are 0-based):
+ * \(\texttt{dst} _{ij} =
+ * \left\{
+ * \begin{array}{l l}
+ * \texttt{src} _{\texttt{src.rows}-i-1,j} & if\; \texttt{flipCode} = 0 \\
+ * \texttt{src} _{i, \texttt{src.cols} -j-1} & if\; \texttt{flipCode} > 0 \\
+ * \texttt{src} _{ \texttt{src.rows} -i-1, \texttt{src.cols} -j-1} & if\; \texttt{flipCode} < 0 \\
+ * \end{array}
+ * \right.\)
+ * The example scenarios of using the function are the following:
+ * Vertical flipping of the image (flipCode == 0) to switch between
+ * top-left and bottom-left image origin. This is a typical operation
+ * in video processing on Microsoft Windows\* OS.
+ * Horizontal flipping of the image with the subsequent horizontal
+ * shift and absolute difference calculation to check for a
+ * vertical-axis symmetry (flipCode > 0).
+ * Simultaneous horizontal and vertical flipping of the image with
+ * the subsequent shift and absolute difference calculation to check
+ * for a central symmetry (flipCode < 0).
+ * Reversing the order of point arrays (flipCode > 0 or
+ * flipCode == 0).
+ * @param src input array.
+ * @param dst output array of the same size and type as src.
+ * @param flipCode a flag to specify how to flip the array; 0 means
+ * flipping around the x-axis and positive value (for example, 1) means
+ * flipping around y-axis. Negative value (for example, -1) means flipping
+ * around both axes.
+ * SEE: transpose , repeat , completeSymm
+ */
+ public static void flip(Mat src, Mat dst, int flipCode) {
+ flip_0(src.nativeObj, dst.nativeObj, flipCode);
+ }
+
+
+ //
+ // C++: void cv::flipND(Mat src, Mat& dst, int axis)
+ //
+
+ /**
+ * Flips a n-dimensional at given axis
+ * @param src input array
+ * @param dst output array that has the same shape of src
+ * @param axis axis that performs a flip on. 0 <= axis < src.dims.
+ */
+ public static void flipND(Mat src, Mat dst, int axis) {
+ flipND_0(src.nativeObj, dst.nativeObj, axis);
+ }
+
+
+ //
+ // C++: void cv::rotate(Mat src, Mat& dst, int rotateCode)
+ //
+
+ /**
+ * Rotates a 2D array in multiples of 90 degrees.
+ * The function cv::rotate rotates the array in one of three different ways:
+ * Rotate by 90 degrees clockwise (rotateCode = ROTATE_90_CLOCKWISE).
+ * Rotate by 180 degrees clockwise (rotateCode = ROTATE_180).
+ * Rotate by 270 degrees clockwise (rotateCode = ROTATE_90_COUNTERCLOCKWISE).
+ * @param src input array.
+ * @param dst output array of the same type as src. The size is the same with ROTATE_180,
+ * and the rows and cols are switched for ROTATE_90_CLOCKWISE and ROTATE_90_COUNTERCLOCKWISE.
+ * @param rotateCode an enum to specify how to rotate the array; see the enum #RotateFlags
+ * SEE: transpose , repeat , completeSymm, flip, RotateFlags
+ */
+ public static void rotate(Mat src, Mat dst, int rotateCode) {
+ rotate_0(src.nativeObj, dst.nativeObj, rotateCode);
+ }
+
+
+ //
+ // C++: void cv::repeat(Mat src, int ny, int nx, Mat& dst)
+ //
+
+ /**
+ * Fills the output array with repeated copies of the input array.
+ *
+ * The function cv::repeat duplicates the input array one or more times along each of the two axes:
+ * \(\texttt{dst} _{ij}= \texttt{src} _{i\mod src.rows, \; j\mod src.cols }\)
+ * The second variant of the function is more convenient to use with REF: MatrixExpressions.
+ * @param src input array to replicate.
+ * @param ny Flag to specify how many times the {@code src} is repeated along the
+ * vertical axis.
+ * @param nx Flag to specify how many times the {@code src} is repeated along the
+ * horizontal axis.
+ * @param dst output array of the same type as {@code src}.
+ * SEE: cv::reduce
+ */
+ public static void repeat(Mat src, int ny, int nx, Mat dst) {
+ repeat_0(src.nativeObj, ny, nx, dst.nativeObj);
+ }
+
+
+ //
+ // C++: void cv::hconcat(vector_Mat src, Mat& dst)
+ //
+
+ /**
+ *
+ *
+ * std::vector<cv::Mat> matrices = { cv::Mat(4, 1, CV_8UC1, cv::Scalar(1)),
+ * cv::Mat(4, 1, CV_8UC1, cv::Scalar(2)),
+ * cv::Mat(4, 1, CV_8UC1, cv::Scalar(3)),};
+ *
+ * cv::Mat out;
+ * cv::hconcat( matrices, out );
+ * //out:
+ * //[1, 2, 3;
+ * // 1, 2, 3;
+ * // 1, 2, 3;
+ * // 1, 2, 3]
+ *
+ * @param src input array or vector of matrices. all of the matrices must have the same number of rows and the same depth.
+ * @param dst output array. It has the same number of rows and depth as the src, and the sum of cols of the src.
+ * same depth.
+ */
+ public static void hconcat(List src, Mat dst) {
+ Mat src_mat = Converters.vector_Mat_to_Mat(src);
+ hconcat_0(src_mat.nativeObj, dst.nativeObj);
+ }
+
+
+ //
+ // C++: void cv::vconcat(vector_Mat src, Mat& dst)
+ //
+
+ /**
+ *
+ *
+ * std::vector<cv::Mat> matrices = { cv::Mat(1, 4, CV_8UC1, cv::Scalar(1)),
+ * cv::Mat(1, 4, CV_8UC1, cv::Scalar(2)),
+ * cv::Mat(1, 4, CV_8UC1, cv::Scalar(3)),};
+ *
+ * cv::Mat out;
+ * cv::vconcat( matrices, out );
+ * //out:
+ * //[1, 1, 1, 1;
+ * // 2, 2, 2, 2;
+ * // 3, 3, 3, 3]
+ *
+ * @param src input array or vector of matrices. all of the matrices must have the same number of cols and the same depth
+ * @param dst output array. It has the same number of cols and depth as the src, and the sum of rows of the src.
+ * same depth.
+ */
+ public static void vconcat(List src, Mat dst) {
+ Mat src_mat = Converters.vector_Mat_to_Mat(src);
+ vconcat_0(src_mat.nativeObj, dst.nativeObj);
+ }
+
+
+ //
+ // C++: void cv::bitwise_and(Mat src1, Mat src2, Mat& dst, Mat mask = Mat())
+ //
+
+ /**
+ * computes bitwise conjunction of the two arrays (dst = src1 & src2)
+ * Calculates the per-element bit-wise conjunction of two arrays or an
+ * array and a scalar.
+ *
+ * The function cv::bitwise_and calculates the per-element bit-wise logical conjunction for:
+ * Two arrays when src1 and src2 have the same size:
+ * \(\texttt{dst} (I) = \texttt{src1} (I) \wedge \texttt{src2} (I) \quad \texttt{if mask} (I) \ne0\)
+ * An array and a scalar when src2 is constructed from Scalar or has
+ * the same number of elements as {@code src1.channels()}:
+ * \(\texttt{dst} (I) = \texttt{src1} (I) \wedge \texttt{src2} \quad \texttt{if mask} (I) \ne0\)
+ * A scalar and an array when src1 is constructed from Scalar or has
+ * the same number of elements as {@code src2.channels()}:
+ * \(\texttt{dst} (I) = \texttt{src1} \wedge \texttt{src2} (I) \quad \texttt{if mask} (I) \ne0\)
+ * In case of floating-point arrays, their machine-specific bit
+ * representations (usually IEEE754-compliant) are used for the operation.
+ * In case of multi-channel arrays, each channel is processed
+ * independently. In the second and third cases above, the scalar is first
+ * converted to the array type.
+ * @param src1 first input array or a scalar.
+ * @param src2 second input array or a scalar.
+ * @param dst output array that has the same size and type as the input
+ * arrays.
+ * @param mask optional operation mask, 8-bit single channel array, that
+ * specifies elements of the output array to be changed.
+ */
+ public static void bitwise_and(Mat src1, Mat src2, Mat dst, Mat mask) {
+ bitwise_and_0(src1.nativeObj, src2.nativeObj, dst.nativeObj, mask.nativeObj);
+ }
+
+ /**
+ * computes bitwise conjunction of the two arrays (dst = src1 & src2)
+ * Calculates the per-element bit-wise conjunction of two arrays or an
+ * array and a scalar.
+ *
+ * The function cv::bitwise_and calculates the per-element bit-wise logical conjunction for:
+ * Two arrays when src1 and src2 have the same size:
+ * \(\texttt{dst} (I) = \texttt{src1} (I) \wedge \texttt{src2} (I) \quad \texttt{if mask} (I) \ne0\)
+ * An array and a scalar when src2 is constructed from Scalar or has
+ * the same number of elements as {@code src1.channels()}:
+ * \(\texttt{dst} (I) = \texttt{src1} (I) \wedge \texttt{src2} \quad \texttt{if mask} (I) \ne0\)
+ * A scalar and an array when src1 is constructed from Scalar or has
+ * the same number of elements as {@code src2.channels()}:
+ * \(\texttt{dst} (I) = \texttt{src1} \wedge \texttt{src2} (I) \quad \texttt{if mask} (I) \ne0\)
+ * In case of floating-point arrays, their machine-specific bit
+ * representations (usually IEEE754-compliant) are used for the operation.
+ * In case of multi-channel arrays, each channel is processed
+ * independently. In the second and third cases above, the scalar is first
+ * converted to the array type.
+ * @param src1 first input array or a scalar.
+ * @param src2 second input array or a scalar.
+ * @param dst output array that has the same size and type as the input
+ * arrays.
+ * specifies elements of the output array to be changed.
+ */
+ public static void bitwise_and(Mat src1, Mat src2, Mat dst) {
+ bitwise_and_1(src1.nativeObj, src2.nativeObj, dst.nativeObj);
+ }
+
+
+ //
+ // C++: void cv::bitwise_or(Mat src1, Mat src2, Mat& dst, Mat mask = Mat())
+ //
+
+ /**
+ * Calculates the per-element bit-wise disjunction of two arrays or an
+ * array and a scalar.
+ *
+ * The function cv::bitwise_or calculates the per-element bit-wise logical disjunction for:
+ * Two arrays when src1 and src2 have the same size:
+ * \(\texttt{dst} (I) = \texttt{src1} (I) \vee \texttt{src2} (I) \quad \texttt{if mask} (I) \ne0\)
+ * An array and a scalar when src2 is constructed from Scalar or has
+ * the same number of elements as {@code src1.channels()}:
+ * \(\texttt{dst} (I) = \texttt{src1} (I) \vee \texttt{src2} \quad \texttt{if mask} (I) \ne0\)
+ * A scalar and an array when src1 is constructed from Scalar or has
+ * the same number of elements as {@code src2.channels()}:
+ * \(\texttt{dst} (I) = \texttt{src1} \vee \texttt{src2} (I) \quad \texttt{if mask} (I) \ne0\)
+ * In case of floating-point arrays, their machine-specific bit
+ * representations (usually IEEE754-compliant) are used for the operation.
+ * In case of multi-channel arrays, each channel is processed
+ * independently. In the second and third cases above, the scalar is first
+ * converted to the array type.
+ * @param src1 first input array or a scalar.
+ * @param src2 second input array or a scalar.
+ * @param dst output array that has the same size and type as the input
+ * arrays.
+ * @param mask optional operation mask, 8-bit single channel array, that
+ * specifies elements of the output array to be changed.
+ */
+ public static void bitwise_or(Mat src1, Mat src2, Mat dst, Mat mask) {
+ bitwise_or_0(src1.nativeObj, src2.nativeObj, dst.nativeObj, mask.nativeObj);
+ }
+
+ /**
+ * Calculates the per-element bit-wise disjunction of two arrays or an
+ * array and a scalar.
+ *
+ * The function cv::bitwise_or calculates the per-element bit-wise logical disjunction for:
+ * Two arrays when src1 and src2 have the same size:
+ * \(\texttt{dst} (I) = \texttt{src1} (I) \vee \texttt{src2} (I) \quad \texttt{if mask} (I) \ne0\)
+ * An array and a scalar when src2 is constructed from Scalar or has
+ * the same number of elements as {@code src1.channels()}:
+ * \(\texttt{dst} (I) = \texttt{src1} (I) \vee \texttt{src2} \quad \texttt{if mask} (I) \ne0\)
+ * A scalar and an array when src1 is constructed from Scalar or has
+ * the same number of elements as {@code src2.channels()}:
+ * \(\texttt{dst} (I) = \texttt{src1} \vee \texttt{src2} (I) \quad \texttt{if mask} (I) \ne0\)
+ * In case of floating-point arrays, their machine-specific bit
+ * representations (usually IEEE754-compliant) are used for the operation.
+ * In case of multi-channel arrays, each channel is processed
+ * independently. In the second and third cases above, the scalar is first
+ * converted to the array type.
+ * @param src1 first input array or a scalar.
+ * @param src2 second input array or a scalar.
+ * @param dst output array that has the same size and type as the input
+ * arrays.
+ * specifies elements of the output array to be changed.
+ */
+ public static void bitwise_or(Mat src1, Mat src2, Mat dst) {
+ bitwise_or_1(src1.nativeObj, src2.nativeObj, dst.nativeObj);
+ }
+
+
+ //
+ // C++: void cv::bitwise_xor(Mat src1, Mat src2, Mat& dst, Mat mask = Mat())
+ //
+
+ /**
+ * Calculates the per-element bit-wise "exclusive or" operation on two
+ * arrays or an array and a scalar.
+ *
+ * The function cv::bitwise_xor calculates the per-element bit-wise logical "exclusive-or"
+ * operation for:
+ * Two arrays when src1 and src2 have the same size:
+ * \(\texttt{dst} (I) = \texttt{src1} (I) \oplus \texttt{src2} (I) \quad \texttt{if mask} (I) \ne0\)
+ * An array and a scalar when src2 is constructed from Scalar or has
+ * the same number of elements as {@code src1.channels()}:
+ * \(\texttt{dst} (I) = \texttt{src1} (I) \oplus \texttt{src2} \quad \texttt{if mask} (I) \ne0\)
+ * A scalar and an array when src1 is constructed from Scalar or has
+ * the same number of elements as {@code src2.channels()}:
+ * \(\texttt{dst} (I) = \texttt{src1} \oplus \texttt{src2} (I) \quad \texttt{if mask} (I) \ne0\)
+ * In case of floating-point arrays, their machine-specific bit
+ * representations (usually IEEE754-compliant) are used for the operation.
+ * In case of multi-channel arrays, each channel is processed
+ * independently. In the 2nd and 3rd cases above, the scalar is first
+ * converted to the array type.
+ * @param src1 first input array or a scalar.
+ * @param src2 second input array or a scalar.
+ * @param dst output array that has the same size and type as the input
+ * arrays.
+ * @param mask optional operation mask, 8-bit single channel array, that
+ * specifies elements of the output array to be changed.
+ */
+ public static void bitwise_xor(Mat src1, Mat src2, Mat dst, Mat mask) {
+ bitwise_xor_0(src1.nativeObj, src2.nativeObj, dst.nativeObj, mask.nativeObj);
+ }
+
+ /**
+ * Calculates the per-element bit-wise "exclusive or" operation on two
+ * arrays or an array and a scalar.
+ *
+ * The function cv::bitwise_xor calculates the per-element bit-wise logical "exclusive-or"
+ * operation for:
+ * Two arrays when src1 and src2 have the same size:
+ * \(\texttt{dst} (I) = \texttt{src1} (I) \oplus \texttt{src2} (I) \quad \texttt{if mask} (I) \ne0\)
+ * An array and a scalar when src2 is constructed from Scalar or has
+ * the same number of elements as {@code src1.channels()}:
+ * \(\texttt{dst} (I) = \texttt{src1} (I) \oplus \texttt{src2} \quad \texttt{if mask} (I) \ne0\)
+ * A scalar and an array when src1 is constructed from Scalar or has
+ * the same number of elements as {@code src2.channels()}:
+ * \(\texttt{dst} (I) = \texttt{src1} \oplus \texttt{src2} (I) \quad \texttt{if mask} (I) \ne0\)
+ * In case of floating-point arrays, their machine-specific bit
+ * representations (usually IEEE754-compliant) are used for the operation.
+ * In case of multi-channel arrays, each channel is processed
+ * independently. In the 2nd and 3rd cases above, the scalar is first
+ * converted to the array type.
+ * @param src1 first input array or a scalar.
+ * @param src2 second input array or a scalar.
+ * @param dst output array that has the same size and type as the input
+ * arrays.
+ * specifies elements of the output array to be changed.
+ */
+ public static void bitwise_xor(Mat src1, Mat src2, Mat dst) {
+ bitwise_xor_1(src1.nativeObj, src2.nativeObj, dst.nativeObj);
+ }
+
+
+ //
+ // C++: void cv::bitwise_not(Mat src, Mat& dst, Mat mask = Mat())
+ //
+
+ /**
+ * Inverts every bit of an array.
+ *
+ * The function cv::bitwise_not calculates per-element bit-wise inversion of the input
+ * array:
+ * \(\texttt{dst} (I) = \neg \texttt{src} (I)\)
+ * In case of a floating-point input array, its machine-specific bit
+ * representation (usually IEEE754-compliant) is used for the operation. In
+ * case of multi-channel arrays, each channel is processed independently.
+ * @param src input array.
+ * @param dst output array that has the same size and type as the input
+ * array.
+ * @param mask optional operation mask, 8-bit single channel array, that
+ * specifies elements of the output array to be changed.
+ */
+ public static void bitwise_not(Mat src, Mat dst, Mat mask) {
+ bitwise_not_0(src.nativeObj, dst.nativeObj, mask.nativeObj);
+ }
+
+ /**
+ * Inverts every bit of an array.
+ *
+ * The function cv::bitwise_not calculates per-element bit-wise inversion of the input
+ * array:
+ * \(\texttt{dst} (I) = \neg \texttt{src} (I)\)
+ * In case of a floating-point input array, its machine-specific bit
+ * representation (usually IEEE754-compliant) is used for the operation. In
+ * case of multi-channel arrays, each channel is processed independently.
+ * @param src input array.
+ * @param dst output array that has the same size and type as the input
+ * array.
+ * specifies elements of the output array to be changed.
+ */
+ public static void bitwise_not(Mat src, Mat dst) {
+ bitwise_not_1(src.nativeObj, dst.nativeObj);
+ }
+
+
+ //
+ // C++: void cv::absdiff(Mat src1, Mat src2, Mat& dst)
+ //
+
+ /**
+ * Calculates the per-element absolute difference between two arrays or between an array and a scalar.
+ *
+ * The function cv::absdiff calculates:
+ * Absolute difference between two arrays when they have the same
+ * size and type:
+ * \(\texttt{dst}(I) = \texttt{saturate} (| \texttt{src1}(I) - \texttt{src2}(I)|)\)
+ * Absolute difference between an array and a scalar when the second
+ * array is constructed from Scalar or has as many elements as the
+ * number of channels in {@code src1}:
+ * \(\texttt{dst}(I) = \texttt{saturate} (| \texttt{src1}(I) - \texttt{src2} |)\)
+ * Absolute difference between a scalar and an array when the first
+ * array is constructed from Scalar or has as many elements as the
+ * number of channels in {@code src2}:
+ * \(\texttt{dst}(I) = \texttt{saturate} (| \texttt{src1} - \texttt{src2}(I) |)\)
+ * where I is a multi-dimensional index of array elements. In case of
+ * multi-channel arrays, each channel is processed independently.
+ * Note: Saturation is not applied when the arrays have the depth CV_32S.
+ * You may even get a negative value in the case of overflow.
+ * @param src1 first input array or a scalar.
+ * @param src2 second input array or a scalar.
+ * @param dst output array that has the same size and type as input arrays.
+ * SEE: cv::abs(const Mat&)
+ */
+ public static void absdiff(Mat src1, Mat src2, Mat dst) {
+ absdiff_0(src1.nativeObj, src2.nativeObj, dst.nativeObj);
+ }
+
+
+ //
+ // C++: void cv::copyTo(Mat src, Mat& dst, Mat mask)
+ //
+
+ /**
+ * This is an overloaded member function, provided for convenience (python)
+ * Copies the matrix to another one.
+ * When the operation mask is specified, if the Mat::create call shown above reallocates the matrix, the newly allocated matrix is initialized with all zeros before copying the data.
+ * @param src source matrix.
+ * @param dst Destination matrix. If it does not have a proper size or type before the operation, it is
+ * reallocated.
+ * @param mask Operation mask of the same size as \*this. Its non-zero elements indicate which matrix
+ * elements need to be copied. The mask has to be of type CV_8U and can have 1 or multiple channels.
+ */
+ public static void copyTo(Mat src, Mat dst, Mat mask) {
+ copyTo_0(src.nativeObj, dst.nativeObj, mask.nativeObj);
+ }
+
+
+ //
+ // C++: void cv::inRange(Mat src, Scalar lowerb, Scalar upperb, Mat& dst)
+ //
+
+ /**
+ * Checks if array elements lie between the elements of two other arrays.
+ *
+ * The function checks the range as follows:
+ *
+ *
+ * For every element of a single-channel input array:
+ * \(\texttt{dst} (I)= \texttt{lowerb} (I)_0 \leq \texttt{src} (I)_0 \leq \texttt{upperb} (I)_0\)
+ *
+ *
+ * That is, dst (I) is set to 255 (all 1 -bits) if src (I) is within the
+ * specified 1D, 2D, 3D, ... box and 0 otherwise.
+ *
+ * When the lower and/or upper boundary parameters are scalars, the indexes
+ * (I) at lowerb and upperb in the above formulas should be omitted.
+ * @param src first input array.
+ * @param lowerb inclusive lower boundary array or a scalar.
+ * @param upperb inclusive upper boundary array or a scalar.
+ * @param dst output array of the same size as src and CV_8U type.
+ */
+ public static void inRange(Mat src, Scalar lowerb, Scalar upperb, Mat dst) {
+ inRange_0(src.nativeObj, lowerb.val[0], lowerb.val[1], lowerb.val[2], lowerb.val[3], upperb.val[0], upperb.val[1], upperb.val[2], upperb.val[3], dst.nativeObj);
+ }
+
+
+ //
+ // C++: void cv::compare(Mat src1, Mat src2, Mat& dst, int cmpop)
+ //
+
+ /**
+ * Performs the per-element comparison of two arrays or an array and scalar value.
+ *
+ * The function compares:
+ * Elements of two arrays when src1 and src2 have the same size:
+ * \(\texttt{dst} (I) = \texttt{src1} (I) \,\texttt{cmpop}\, \texttt{src2} (I)\)
+ * Elements of src1 with a scalar src2 when src2 is constructed from
+ * Scalar or has a single element:
+ * \(\texttt{dst} (I) = \texttt{src1}(I) \,\texttt{cmpop}\, \texttt{src2}\)
+ * src1 with elements of src2 when src1 is constructed from Scalar or
+ * has a single element:
+ * \(\texttt{dst} (I) = \texttt{src1} \,\texttt{cmpop}\, \texttt{src2} (I)\)
+ * When the comparison result is true, the corresponding element of output
+ * array is set to 255. The comparison operations can be replaced with the
+ * equivalent matrix expressions:
+ *
+ * Mat dst1 = src1 >= src2;
+ * Mat dst2 = src1 < 8;
+ * ...
+ *
+ * @param src1 first input array or a scalar; when it is an array, it must have a single channel.
+ * @param src2 second input array or a scalar; when it is an array, it must have a single channel.
+ * @param dst output array of type ref CV_8U that has the same size and the same number of channels as
+ * the input arrays.
+ * @param cmpop a flag, that specifies correspondence between the arrays (cv::CmpTypes)
+ * SEE: checkRange, min, max, threshold
+ */
+ public static void compare(Mat src1, Mat src2, Mat dst, int cmpop) {
+ compare_0(src1.nativeObj, src2.nativeObj, dst.nativeObj, cmpop);
+ }
+
+
+ //
+ // C++: void cv::min(Mat src1, Mat src2, Mat& dst)
+ //
+
+ /**
+ * Calculates per-element minimum of two arrays or an array and a scalar.
+ *
+ * The function cv::min calculates the per-element minimum of two arrays:
+ * \(\texttt{dst} (I)= \min ( \texttt{src1} (I), \texttt{src2} (I))\)
+ * or array and a scalar:
+ * \(\texttt{dst} (I)= \min ( \texttt{src1} (I), \texttt{value} )\)
+ * @param src1 first input array.
+ * @param src2 second input array of the same size and type as src1.
+ * @param dst output array of the same size and type as src1.
+ * SEE: max, compare, inRange, minMaxLoc
+ */
+ public static void min(Mat src1, Mat src2, Mat dst) {
+ min_0(src1.nativeObj, src2.nativeObj, dst.nativeObj);
+ }
+
+
+ //
+ // C++: void cv::max(Mat src1, Mat src2, Mat& dst)
+ //
+
+ /**
+ * Calculates per-element maximum of two arrays or an array and a scalar.
+ *
+ * The function cv::max calculates the per-element maximum of two arrays:
+ * \(\texttt{dst} (I)= \max ( \texttt{src1} (I), \texttt{src2} (I))\)
+ * or array and a scalar:
+ * \(\texttt{dst} (I)= \max ( \texttt{src1} (I), \texttt{value} )\)
+ * @param src1 first input array.
+ * @param src2 second input array of the same size and type as src1 .
+ * @param dst output array of the same size and type as src1.
+ * SEE: min, compare, inRange, minMaxLoc, REF: MatrixExpressions
+ */
+ public static void max(Mat src1, Mat src2, Mat dst) {
+ max_0(src1.nativeObj, src2.nativeObj, dst.nativeObj);
+ }
+
+
+ //
+ // C++: void cv::sqrt(Mat src, Mat& dst)
+ //
+
+ /**
+ * Calculates a square root of array elements.
+ *
+ * The function cv::sqrt calculates a square root of each input array element.
+ * In case of multi-channel arrays, each channel is processed
+ * independently. The accuracy is approximately the same as of the built-in
+ * std::sqrt .
+ * @param src input floating-point array.
+ * @param dst output array of the same size and type as src.
+ */
+ public static void sqrt(Mat src, Mat dst) {
+ sqrt_0(src.nativeObj, dst.nativeObj);
+ }
+
+
+ //
+ // C++: void cv::pow(Mat src, double power, Mat& dst)
+ //
+
+ /**
+ * Raises every array element to a power.
+ *
+ * The function cv::pow raises every element of the input array to power :
+ * \(\texttt{dst} (I) = \fork{\texttt{src}(I)^{power}}{if \(\texttt{power}\) is integer}{|\texttt{src}(I)|^{power}}{otherwise}\)
+ *
+ * So, for a non-integer power exponent, the absolute values of input array
+ * elements are used. However, it is possible to get true values for
+ * negative values using some extra operations. In the example below,
+ * computing the 5th root of array src shows:
+ *
+ * Mat mask = src < 0;
+ * pow(src, 1./5, dst);
+ * subtract(Scalar::all(0), dst, dst, mask);
+ *
+ * For some values of power, such as integer values, 0.5 and -0.5,
+ * specialized faster algorithms are used.
+ *
+ * Special values (NaN, Inf) are not handled.
+ * @param src input array.
+ * @param power exponent of power.
+ * @param dst output array of the same size and type as src.
+ * SEE: sqrt, exp, log, cartToPolar, polarToCart
+ */
+ public static void pow(Mat src, double power, Mat dst) {
+ pow_0(src.nativeObj, power, dst.nativeObj);
+ }
+
+
+ //
+ // C++: void cv::exp(Mat src, Mat& dst)
+ //
+
+ /**
+ * Calculates the exponent of every array element.
+ *
+ * The function cv::exp calculates the exponent of every element of the input
+ * array:
+ * \(\texttt{dst} [I] = e^{ src(I) }\)
+ *
+ * The maximum relative error is about 7e-6 for single-precision input and
+ * less than 1e-10 for double-precision input. Currently, the function
+ * converts denormalized values to zeros on output. Special values (NaN,
+ * Inf) are not handled.
+ * @param src input array.
+ * @param dst output array of the same size and type as src.
+ * SEE: log , cartToPolar , polarToCart , phase , pow , sqrt , magnitude
+ */
+ public static void exp(Mat src, Mat dst) {
+ exp_0(src.nativeObj, dst.nativeObj);
+ }
+
+
+ //
+ // C++: void cv::log(Mat src, Mat& dst)
+ //
+
+ /**
+ * Calculates the natural logarithm of every array element.
+ *
+ * The function cv::log calculates the natural logarithm of every element of the input array:
+ * \(\texttt{dst} (I) = \log (\texttt{src}(I)) \)
+ *
+ * Output on zero, negative and special (NaN, Inf) values is undefined.
+ *
+ * @param src input array.
+ * @param dst output array of the same size and type as src .
+ * SEE: exp, cartToPolar, polarToCart, phase, pow, sqrt, magnitude
+ */
+ public static void log(Mat src, Mat dst) {
+ log_0(src.nativeObj, dst.nativeObj);
+ }
+
+
+ //
+ // C++: void cv::polarToCart(Mat magnitude, Mat angle, Mat& x, Mat& y, bool angleInDegrees = false)
+ //
+
+ /**
+ * Calculates x and y coordinates of 2D vectors from their magnitude and angle.
+ *
+ * The function cv::polarToCart calculates the Cartesian coordinates of each 2D
+ * vector represented by the corresponding elements of magnitude and angle:
+ * \(\begin{array}{l} \texttt{x} (I) = \texttt{magnitude} (I) \cos ( \texttt{angle} (I)) \\ \texttt{y} (I) = \texttt{magnitude} (I) \sin ( \texttt{angle} (I)) \\ \end{array}\)
+ *
+ * The relative accuracy of the estimated coordinates is about 1e-6.
+ * @param magnitude input floating-point array of magnitudes of 2D vectors;
+ * it can be an empty matrix (=Mat()), in this case, the function assumes
+ * that all the magnitudes are =1; if it is not empty, it must have the
+ * same size and type as angle.
+ * @param angle input floating-point array of angles of 2D vectors.
+ * @param x output array of x-coordinates of 2D vectors; it has the same
+ * size and type as angle.
+ * @param y output array of y-coordinates of 2D vectors; it has the same
+ * size and type as angle.
+ * @param angleInDegrees when true, the input angles are measured in
+ * degrees, otherwise, they are measured in radians.
+ * SEE: cartToPolar, magnitude, phase, exp, log, pow, sqrt
+ */
+ public static void polarToCart(Mat magnitude, Mat angle, Mat x, Mat y, boolean angleInDegrees) {
+ polarToCart_0(magnitude.nativeObj, angle.nativeObj, x.nativeObj, y.nativeObj, angleInDegrees);
+ }
+
+ /**
+ * Calculates x and y coordinates of 2D vectors from their magnitude and angle.
+ *
+ * The function cv::polarToCart calculates the Cartesian coordinates of each 2D
+ * vector represented by the corresponding elements of magnitude and angle:
+ * \(\begin{array}{l} \texttt{x} (I) = \texttt{magnitude} (I) \cos ( \texttt{angle} (I)) \\ \texttt{y} (I) = \texttt{magnitude} (I) \sin ( \texttt{angle} (I)) \\ \end{array}\)
+ *
+ * The relative accuracy of the estimated coordinates is about 1e-6.
+ * @param magnitude input floating-point array of magnitudes of 2D vectors;
+ * it can be an empty matrix (=Mat()), in this case, the function assumes
+ * that all the magnitudes are =1; if it is not empty, it must have the
+ * same size and type as angle.
+ * @param angle input floating-point array of angles of 2D vectors.
+ * @param x output array of x-coordinates of 2D vectors; it has the same
+ * size and type as angle.
+ * @param y output array of y-coordinates of 2D vectors; it has the same
+ * size and type as angle.
+ * degrees, otherwise, they are measured in radians.
+ * SEE: cartToPolar, magnitude, phase, exp, log, pow, sqrt
+ */
+ public static void polarToCart(Mat magnitude, Mat angle, Mat x, Mat y) {
+ polarToCart_1(magnitude.nativeObj, angle.nativeObj, x.nativeObj, y.nativeObj);
+ }
+
+
+ //
+ // C++: void cv::cartToPolar(Mat x, Mat y, Mat& magnitude, Mat& angle, bool angleInDegrees = false)
+ //
+
+ /**
+ * Calculates the magnitude and angle of 2D vectors.
+ *
+ * The function cv::cartToPolar calculates either the magnitude, angle, or both
+ * for every 2D vector (x(I),y(I)):
+ * \(\begin{array}{l} \texttt{magnitude} (I)= \sqrt{\texttt{x}(I)^2+\texttt{y}(I)^2} , \\ \texttt{angle} (I)= \texttt{atan2} ( \texttt{y} (I), \texttt{x} (I))[ \cdot180 / \pi ] \end{array}\)
+ *
+ * The angles are calculated with accuracy about 0.3 degrees. For the point
+ * (0,0), the angle is set to 0.
+ * @param x array of x-coordinates; this must be a single-precision or
+ * double-precision floating-point array.
+ * @param y array of y-coordinates, that must have the same size and same type as x.
+ * @param magnitude output array of magnitudes of the same size and type as x.
+ * @param angle output array of angles that has the same size and type as
+ * x; the angles are measured in radians (from 0 to 2\*Pi) or in degrees (0 to 360 degrees).
+ * @param angleInDegrees a flag, indicating whether the angles are measured
+ * in radians (which is by default), or in degrees.
+ * SEE: Sobel, Scharr
+ */
+ public static void cartToPolar(Mat x, Mat y, Mat magnitude, Mat angle, boolean angleInDegrees) {
+ cartToPolar_0(x.nativeObj, y.nativeObj, magnitude.nativeObj, angle.nativeObj, angleInDegrees);
+ }
+
+ /**
+ * Calculates the magnitude and angle of 2D vectors.
+ *
+ * The function cv::cartToPolar calculates either the magnitude, angle, or both
+ * for every 2D vector (x(I),y(I)):
+ * \(\begin{array}{l} \texttt{magnitude} (I)= \sqrt{\texttt{x}(I)^2+\texttt{y}(I)^2} , \\ \texttt{angle} (I)= \texttt{atan2} ( \texttt{y} (I), \texttt{x} (I))[ \cdot180 / \pi ] \end{array}\)
+ *
+ * The angles are calculated with accuracy about 0.3 degrees. For the point
+ * (0,0), the angle is set to 0.
+ * @param x array of x-coordinates; this must be a single-precision or
+ * double-precision floating-point array.
+ * @param y array of y-coordinates, that must have the same size and same type as x.
+ * @param magnitude output array of magnitudes of the same size and type as x.
+ * @param angle output array of angles that has the same size and type as
+ * x; the angles are measured in radians (from 0 to 2\*Pi) or in degrees (0 to 360 degrees).
+ * in radians (which is by default), or in degrees.
+ * SEE: Sobel, Scharr
+ */
+ public static void cartToPolar(Mat x, Mat y, Mat magnitude, Mat angle) {
+ cartToPolar_1(x.nativeObj, y.nativeObj, magnitude.nativeObj, angle.nativeObj);
+ }
+
+
+ //
+ // C++: void cv::phase(Mat x, Mat y, Mat& angle, bool angleInDegrees = false)
+ //
+
+ /**
+ * Calculates the rotation angle of 2D vectors.
+ *
+ * The function cv::phase calculates the rotation angle of each 2D vector that
+ * is formed from the corresponding elements of x and y :
+ * \(\texttt{angle} (I) = \texttt{atan2} ( \texttt{y} (I), \texttt{x} (I))\)
+ *
+ * The angle estimation accuracy is about 0.3 degrees. When x(I)=y(I)=0 ,
+ * the corresponding angle(I) is set to 0.
+ * @param x input floating-point array of x-coordinates of 2D vectors.
+ * @param y input array of y-coordinates of 2D vectors; it must have the
+ * same size and the same type as x.
+ * @param angle output array of vector angles; it has the same size and
+ * same type as x .
+ * @param angleInDegrees when true, the function calculates the angle in
+ * degrees, otherwise, they are measured in radians.
+ */
+ public static void phase(Mat x, Mat y, Mat angle, boolean angleInDegrees) {
+ phase_0(x.nativeObj, y.nativeObj, angle.nativeObj, angleInDegrees);
+ }
+
+ /**
+ * Calculates the rotation angle of 2D vectors.
+ *
+ * The function cv::phase calculates the rotation angle of each 2D vector that
+ * is formed from the corresponding elements of x and y :
+ * \(\texttt{angle} (I) = \texttt{atan2} ( \texttt{y} (I), \texttt{x} (I))\)
+ *
+ * The angle estimation accuracy is about 0.3 degrees. When x(I)=y(I)=0 ,
+ * the corresponding angle(I) is set to 0.
+ * @param x input floating-point array of x-coordinates of 2D vectors.
+ * @param y input array of y-coordinates of 2D vectors; it must have the
+ * same size and the same type as x.
+ * @param angle output array of vector angles; it has the same size and
+ * same type as x .
+ * degrees, otherwise, they are measured in radians.
+ */
+ public static void phase(Mat x, Mat y, Mat angle) {
+ phase_1(x.nativeObj, y.nativeObj, angle.nativeObj);
+ }
+
+
+ //
+ // C++: void cv::magnitude(Mat x, Mat y, Mat& magnitude)
+ //
+
+ /**
+ * Calculates the magnitude of 2D vectors.
+ *
+ * The function cv::magnitude calculates the magnitude of 2D vectors formed
+ * from the corresponding elements of x and y arrays:
+ * \(\texttt{dst} (I) = \sqrt{\texttt{x}(I)^2 + \texttt{y}(I)^2}\)
+ * @param x floating-point array of x-coordinates of the vectors.
+ * @param y floating-point array of y-coordinates of the vectors; it must
+ * have the same size as x.
+ * @param magnitude output array of the same size and type as x.
+ * SEE: cartToPolar, polarToCart, phase, sqrt
+ */
+ public static void magnitude(Mat x, Mat y, Mat magnitude) {
+ magnitude_0(x.nativeObj, y.nativeObj, magnitude.nativeObj);
+ }
+
+
+ //
+ // C++: bool cv::checkRange(Mat a, bool quiet = true, _hidden_ * pos = 0, double minVal = -DBL_MAX, double maxVal = DBL_MAX)
+ //
+
+ /**
+ * Checks every element of an input array for invalid values.
+ *
+ * The function cv::checkRange checks that every array element is neither NaN nor infinite. When minVal >
+ *
+ *
+ * DBL_MAX and maxVal < DBL_MAX, the function also checks that each value is between minVal and
+ * maxVal. In case of multi-channel arrays, each channel is processed independently. If some values
+ * are out of range, position of the first outlier is stored in pos (when pos != NULL). Then, the
+ * function either returns false (when quiet=true) or throws an exception.
+ *
+ *
+ * @param a input array.
+ * @param quiet a flag, indicating whether the functions quietly return false when the array elements
+ * are out of range or they throw an exception.
+ * elements.
+ * @param minVal inclusive lower boundary of valid values range.
+ * @param maxVal exclusive upper boundary of valid values range.
+ * @return automatically generated
+ */
+ public static boolean checkRange(Mat a, boolean quiet, double minVal, double maxVal) {
+ return checkRange_0(a.nativeObj, quiet, minVal, maxVal);
+ }
+
+ /**
+ * Checks every element of an input array for invalid values.
+ *
+ * The function cv::checkRange checks that every array element is neither NaN nor infinite. When minVal >
+ *
+ *
+ * DBL_MAX and maxVal < DBL_MAX, the function also checks that each value is between minVal and
+ * maxVal. In case of multi-channel arrays, each channel is processed independently. If some values
+ * are out of range, position of the first outlier is stored in pos (when pos != NULL). Then, the
+ * function either returns false (when quiet=true) or throws an exception.
+ *
+ *
+ * @param a input array.
+ * @param quiet a flag, indicating whether the functions quietly return false when the array elements
+ * are out of range or they throw an exception.
+ * elements.
+ * @param minVal inclusive lower boundary of valid values range.
+ * @return automatically generated
+ */
+ public static boolean checkRange(Mat a, boolean quiet, double minVal) {
+ return checkRange_1(a.nativeObj, quiet, minVal);
+ }
+
+ /**
+ * Checks every element of an input array for invalid values.
+ *
+ * The function cv::checkRange checks that every array element is neither NaN nor infinite. When minVal >
+ *
+ *
+ * DBL_MAX and maxVal < DBL_MAX, the function also checks that each value is between minVal and
+ * maxVal. In case of multi-channel arrays, each channel is processed independently. If some values
+ * are out of range, position of the first outlier is stored in pos (when pos != NULL). Then, the
+ * function either returns false (when quiet=true) or throws an exception.
+ *
+ *
+ * @param a input array.
+ * @param quiet a flag, indicating whether the functions quietly return false when the array elements
+ * are out of range or they throw an exception.
+ * elements.
+ * @return automatically generated
+ */
+ public static boolean checkRange(Mat a, boolean quiet) {
+ return checkRange_2(a.nativeObj, quiet);
+ }
+
+ /**
+ * Checks every element of an input array for invalid values.
+ *
+ * The function cv::checkRange checks that every array element is neither NaN nor infinite. When minVal >
+ *
+ *
+ * DBL_MAX and maxVal < DBL_MAX, the function also checks that each value is between minVal and
+ * maxVal. In case of multi-channel arrays, each channel is processed independently. If some values
+ * are out of range, position of the first outlier is stored in pos (when pos != NULL). Then, the
+ * function either returns false (when quiet=true) or throws an exception.
+ *
+ *
+ * @param a input array.
+ * are out of range or they throw an exception.
+ * elements.
+ * @return automatically generated
+ */
+ public static boolean checkRange(Mat a) {
+ return checkRange_4(a.nativeObj);
+ }
+
+
+ //
+ // C++: void cv::patchNaNs(Mat& a, double val = 0)
+ //
+
+ /**
+ * converts NaNs to the given number
+ * @param a input/output matrix (CV_32F type).
+ * @param val value to convert the NaNs
+ */
+ public static void patchNaNs(Mat a, double val) {
+ patchNaNs_0(a.nativeObj, val);
+ }
+
+ /**
+ * converts NaNs to the given number
+ * @param a input/output matrix (CV_32F type).
+ */
+ public static void patchNaNs(Mat a) {
+ patchNaNs_1(a.nativeObj);
+ }
+
+
+ //
+ // C++: void cv::gemm(Mat src1, Mat src2, double alpha, Mat src3, double beta, Mat& dst, int flags = 0)
+ //
+
+ /**
+ * Performs generalized matrix multiplication.
+ *
+ * The function cv::gemm performs generalized matrix multiplication similar to the
+ * gemm functions in BLAS level 3. For example,
+ * {@code gemm(src1, src2, alpha, src3, beta, dst, GEMM_1_T + GEMM_3_T)}
+ * corresponds to
+ * \(\texttt{dst} = \texttt{alpha} \cdot \texttt{src1} ^T \cdot \texttt{src2} + \texttt{beta} \cdot \texttt{src3} ^T\)
+ *
+ * In case of complex (two-channel) data, performed a complex matrix
+ * multiplication.
+ *
+ * The function can be replaced with a matrix expression. For example, the
+ * above call can be replaced with:
+ *
+ * dst = alpha*src1.t()*src2 + beta*src3.t();
+ *
+ * @param src1 first multiplied input matrix that could be real(CV_32FC1,
+ * CV_64FC1) or complex(CV_32FC2, CV_64FC2).
+ * @param src2 second multiplied input matrix of the same type as src1.
+ * @param alpha weight of the matrix product.
+ * @param src3 third optional delta matrix added to the matrix product; it
+ * should have the same type as src1 and src2.
+ * @param beta weight of src3.
+ * @param dst output matrix; it has the proper size and the same type as
+ * input matrices.
+ * @param flags operation flags (cv::GemmFlags)
+ * SEE: mulTransposed , transform
+ */
+ public static void gemm(Mat src1, Mat src2, double alpha, Mat src3, double beta, Mat dst, int flags) {
+ gemm_0(src1.nativeObj, src2.nativeObj, alpha, src3.nativeObj, beta, dst.nativeObj, flags);
+ }
+
+ /**
+ * Performs generalized matrix multiplication.
+ *
+ * The function cv::gemm performs generalized matrix multiplication similar to the
+ * gemm functions in BLAS level 3. For example,
+ * {@code gemm(src1, src2, alpha, src3, beta, dst, GEMM_1_T + GEMM_3_T)}
+ * corresponds to
+ * \(\texttt{dst} = \texttt{alpha} \cdot \texttt{src1} ^T \cdot \texttt{src2} + \texttt{beta} \cdot \texttt{src3} ^T\)
+ *
+ * In case of complex (two-channel) data, performed a complex matrix
+ * multiplication.
+ *
+ * The function can be replaced with a matrix expression. For example, the
+ * above call can be replaced with:
+ *
+ * dst = alpha*src1.t()*src2 + beta*src3.t();
+ *
+ * @param src1 first multiplied input matrix that could be real(CV_32FC1,
+ * CV_64FC1) or complex(CV_32FC2, CV_64FC2).
+ * @param src2 second multiplied input matrix of the same type as src1.
+ * @param alpha weight of the matrix product.
+ * @param src3 third optional delta matrix added to the matrix product; it
+ * should have the same type as src1 and src2.
+ * @param beta weight of src3.
+ * @param dst output matrix; it has the proper size and the same type as
+ * input matrices.
+ * SEE: mulTransposed , transform
+ */
+ public static void gemm(Mat src1, Mat src2, double alpha, Mat src3, double beta, Mat dst) {
+ gemm_1(src1.nativeObj, src2.nativeObj, alpha, src3.nativeObj, beta, dst.nativeObj);
+ }
+
+
+ //
+ // C++: void cv::mulTransposed(Mat src, Mat& dst, bool aTa, Mat delta = Mat(), double scale = 1, int dtype = -1)
+ //
+
+ /**
+ * Calculates the product of a matrix and its transposition.
+ *
+ * The function cv::mulTransposed calculates the product of src and its
+ * transposition:
+ * \(\texttt{dst} = \texttt{scale} ( \texttt{src} - \texttt{delta} )^T ( \texttt{src} - \texttt{delta} )\)
+ * if aTa=true , and
+ * \(\texttt{dst} = \texttt{scale} ( \texttt{src} - \texttt{delta} ) ( \texttt{src} - \texttt{delta} )^T\)
+ * otherwise. The function is used to calculate the covariance matrix. With
+ * zero delta, it can be used as a faster substitute for general matrix
+ * product A\*B when B=A'
+ * @param src input single-channel matrix. Note that unlike gemm, the
+ * function can multiply not only floating-point matrices.
+ * @param dst output square matrix.
+ * @param aTa Flag specifying the multiplication ordering. See the
+ * description below.
+ * @param delta Optional delta matrix subtracted from src before the
+ * multiplication. When the matrix is empty ( delta=noArray() ), it is
+ * assumed to be zero, that is, nothing is subtracted. If it has the same
+ * size as src , it is simply subtracted. Otherwise, it is "repeated" (see
+ * repeat ) to cover the full src and then subtracted. Type of the delta
+ * matrix, when it is not empty, must be the same as the type of created
+ * output matrix. See the dtype parameter description below.
+ * @param scale Optional scale factor for the matrix product.
+ * @param dtype Optional type of the output matrix. When it is negative,
+ * the output matrix will have the same type as src . Otherwise, it will be
+ * type=CV_MAT_DEPTH(dtype) that should be either CV_32F or CV_64F .
+ * SEE: calcCovarMatrix, gemm, repeat, reduce
+ */
+ public static void mulTransposed(Mat src, Mat dst, boolean aTa, Mat delta, double scale, int dtype) {
+ mulTransposed_0(src.nativeObj, dst.nativeObj, aTa, delta.nativeObj, scale, dtype);
+ }
+
+ /**
+ * Calculates the product of a matrix and its transposition.
+ *
+ * The function cv::mulTransposed calculates the product of src and its
+ * transposition:
+ * \(\texttt{dst} = \texttt{scale} ( \texttt{src} - \texttt{delta} )^T ( \texttt{src} - \texttt{delta} )\)
+ * if aTa=true , and
+ * \(\texttt{dst} = \texttt{scale} ( \texttt{src} - \texttt{delta} ) ( \texttt{src} - \texttt{delta} )^T\)
+ * otherwise. The function is used to calculate the covariance matrix. With
+ * zero delta, it can be used as a faster substitute for general matrix
+ * product A\*B when B=A'
+ * @param src input single-channel matrix. Note that unlike gemm, the
+ * function can multiply not only floating-point matrices.
+ * @param dst output square matrix.
+ * @param aTa Flag specifying the multiplication ordering. See the
+ * description below.
+ * @param delta Optional delta matrix subtracted from src before the
+ * multiplication. When the matrix is empty ( delta=noArray() ), it is
+ * assumed to be zero, that is, nothing is subtracted. If it has the same
+ * size as src , it is simply subtracted. Otherwise, it is "repeated" (see
+ * repeat ) to cover the full src and then subtracted. Type of the delta
+ * matrix, when it is not empty, must be the same as the type of created
+ * output matrix. See the dtype parameter description below.
+ * @param scale Optional scale factor for the matrix product.
+ * the output matrix will have the same type as src . Otherwise, it will be
+ * type=CV_MAT_DEPTH(dtype) that should be either CV_32F or CV_64F .
+ * SEE: calcCovarMatrix, gemm, repeat, reduce
+ */
+ public static void mulTransposed(Mat src, Mat dst, boolean aTa, Mat delta, double scale) {
+ mulTransposed_1(src.nativeObj, dst.nativeObj, aTa, delta.nativeObj, scale);
+ }
+
+ /**
+ * Calculates the product of a matrix and its transposition.
+ *
+ * The function cv::mulTransposed calculates the product of src and its
+ * transposition:
+ * \(\texttt{dst} = \texttt{scale} ( \texttt{src} - \texttt{delta} )^T ( \texttt{src} - \texttt{delta} )\)
+ * if aTa=true , and
+ * \(\texttt{dst} = \texttt{scale} ( \texttt{src} - \texttt{delta} ) ( \texttt{src} - \texttt{delta} )^T\)
+ * otherwise. The function is used to calculate the covariance matrix. With
+ * zero delta, it can be used as a faster substitute for general matrix
+ * product A\*B when B=A'
+ * @param src input single-channel matrix. Note that unlike gemm, the
+ * function can multiply not only floating-point matrices.
+ * @param dst output square matrix.
+ * @param aTa Flag specifying the multiplication ordering. See the
+ * description below.
+ * @param delta Optional delta matrix subtracted from src before the
+ * multiplication. When the matrix is empty ( delta=noArray() ), it is
+ * assumed to be zero, that is, nothing is subtracted. If it has the same
+ * size as src , it is simply subtracted. Otherwise, it is "repeated" (see
+ * repeat ) to cover the full src and then subtracted. Type of the delta
+ * matrix, when it is not empty, must be the same as the type of created
+ * output matrix. See the dtype parameter description below.
+ * the output matrix will have the same type as src . Otherwise, it will be
+ * type=CV_MAT_DEPTH(dtype) that should be either CV_32F or CV_64F .
+ * SEE: calcCovarMatrix, gemm, repeat, reduce
+ */
+ public static void mulTransposed(Mat src, Mat dst, boolean aTa, Mat delta) {
+ mulTransposed_2(src.nativeObj, dst.nativeObj, aTa, delta.nativeObj);
+ }
+
+ /**
+ * Calculates the product of a matrix and its transposition.
+ *
+ * The function cv::mulTransposed calculates the product of src and its
+ * transposition:
+ * \(\texttt{dst} = \texttt{scale} ( \texttt{src} - \texttt{delta} )^T ( \texttt{src} - \texttt{delta} )\)
+ * if aTa=true , and
+ * \(\texttt{dst} = \texttt{scale} ( \texttt{src} - \texttt{delta} ) ( \texttt{src} - \texttt{delta} )^T\)
+ * otherwise. The function is used to calculate the covariance matrix. With
+ * zero delta, it can be used as a faster substitute for general matrix
+ * product A\*B when B=A'
+ * @param src input single-channel matrix. Note that unlike gemm, the
+ * function can multiply not only floating-point matrices.
+ * @param dst output square matrix.
+ * @param aTa Flag specifying the multiplication ordering. See the
+ * description below.
+ * multiplication. When the matrix is empty ( delta=noArray() ), it is
+ * assumed to be zero, that is, nothing is subtracted. If it has the same
+ * size as src , it is simply subtracted. Otherwise, it is "repeated" (see
+ * repeat ) to cover the full src and then subtracted. Type of the delta
+ * matrix, when it is not empty, must be the same as the type of created
+ * output matrix. See the dtype parameter description below.
+ * the output matrix will have the same type as src . Otherwise, it will be
+ * type=CV_MAT_DEPTH(dtype) that should be either CV_32F or CV_64F .
+ * SEE: calcCovarMatrix, gemm, repeat, reduce
+ */
+ public static void mulTransposed(Mat src, Mat dst, boolean aTa) {
+ mulTransposed_3(src.nativeObj, dst.nativeObj, aTa);
+ }
+
+
+ //
+ // C++: void cv::transpose(Mat src, Mat& dst)
+ //
+
+ /**
+ * Transposes a matrix.
+ *
+ * The function cv::transpose transposes the matrix src :
+ * \(\texttt{dst} (i,j) = \texttt{src} (j,i)\)
+ * Note: No complex conjugation is done in case of a complex matrix. It
+ * should be done separately if needed.
+ * @param src input array.
+ * @param dst output array of the same type as src.
+ */
+ public static void transpose(Mat src, Mat dst) {
+ transpose_0(src.nativeObj, dst.nativeObj);
+ }
+
+
+ //
+ // C++: void cv::transposeND(Mat src, vector_int order, Mat& dst)
+ //
+
+ /**
+ * Transpose for n-dimensional matrices.
+ *
+ * Note: Input should be continuous single-channel matrix.
+ * @param src input array.
+ * @param order a permutation of [0,1,..,N-1] where N is the number of axes of src.
+ * The i’th axis of dst will correspond to the axis numbered order[i] of the input.
+ * @param dst output array of the same type as src.
+ */
+ public static void transposeND(Mat src, MatOfInt order, Mat dst) {
+ Mat order_mat = order;
+ transposeND_0(src.nativeObj, order_mat.nativeObj, dst.nativeObj);
+ }
+
+
+ //
+ // C++: void cv::transform(Mat src, Mat& dst, Mat m)
+ //
+
+ /**
+ * Performs the matrix transformation of every array element.
+ *
+ * The function cv::transform performs the matrix transformation of every
+ * element of the array src and stores the results in dst :
+ * \(\texttt{dst} (I) = \texttt{m} \cdot \texttt{src} (I)\)
+ * (when m.cols=src.channels() ), or
+ * \(\texttt{dst} (I) = \texttt{m} \cdot [ \texttt{src} (I); 1]\)
+ * (when m.cols=src.channels()+1 )
+ *
+ * Every element of the N -channel array src is interpreted as N -element
+ * vector that is transformed using the M x N or M x (N+1) matrix m to
+ * M-element vector - the corresponding element of the output array dst .
+ *
+ * The function may be used for geometrical transformation of
+ * N -dimensional points, arbitrary linear color space transformation (such
+ * as various kinds of RGB to YUV transforms), shuffling the image
+ * channels, and so forth.
+ * @param src input array that must have as many channels (1 to 4) as
+ * m.cols or m.cols-1.
+ * @param dst output array of the same size and depth as src; it has as
+ * many channels as m.rows.
+ * @param m transformation 2x2 or 2x3 floating-point matrix.
+ * SEE: perspectiveTransform, getAffineTransform, estimateAffine2D, warpAffine, warpPerspective
+ */
+ public static void transform(Mat src, Mat dst, Mat m) {
+ transform_0(src.nativeObj, dst.nativeObj, m.nativeObj);
+ }
+
+
+ //
+ // C++: void cv::perspectiveTransform(Mat src, Mat& dst, Mat m)
+ //
+
+ /**
+ * Performs the perspective matrix transformation of vectors.
+ *
+ * The function cv::perspectiveTransform transforms every element of src by
+ * treating it as a 2D or 3D vector, in the following way:
+ * \((x, y, z) \rightarrow (x'/w, y'/w, z'/w)\)
+ * where
+ * \((x', y', z', w') = \texttt{mat} \cdot \begin{bmatrix} x & y & z & 1 \end{bmatrix}\)
+ * and
+ * \(w = \fork{w'}{if \(w' \ne 0\)}{\infty}{otherwise}\)
+ *
+ * Here a 3D vector transformation is shown. In case of a 2D vector
+ * transformation, the z component is omitted.
+ *
+ * Note: The function transforms a sparse set of 2D or 3D vectors. If you
+ * want to transform an image using perspective transformation, use
+ * warpPerspective . If you have an inverse problem, that is, you want to
+ * compute the most probable perspective transformation out of several
+ * pairs of corresponding points, you can use getPerspectiveTransform or
+ * findHomography .
+ * @param src input two-channel or three-channel floating-point array; each
+ * element is a 2D/3D vector to be transformed.
+ * @param dst output array of the same size and type as src.
+ * @param m 3x3 or 4x4 floating-point transformation matrix.
+ * SEE: transform, warpPerspective, getPerspectiveTransform, findHomography
+ */
+ public static void perspectiveTransform(Mat src, Mat dst, Mat m) {
+ perspectiveTransform_0(src.nativeObj, dst.nativeObj, m.nativeObj);
+ }
+
+
+ //
+ // C++: void cv::completeSymm(Mat& m, bool lowerToUpper = false)
+ //
+
+ /**
+ * Copies the lower or the upper half of a square matrix to its another half.
+ *
+ * The function cv::completeSymm copies the lower or the upper half of a square matrix to
+ * its another half. The matrix diagonal remains unchanged:
+ *
+ *
+ * \(\texttt{m}_{ij}=\texttt{m}_{ji}\) for \(i > j\) if
+ * lowerToUpper=false
+ *
+ *
+ * \(\texttt{m}_{ij}=\texttt{m}_{ji}\) for \(i < j\) if
+ * lowerToUpper=true
+ *
+ *
+ *
+ * @param m input-output floating-point square matrix.
+ * @param lowerToUpper operation flag; if true, the lower half is copied to
+ * the upper half. Otherwise, the upper half is copied to the lower half.
+ * SEE: flip, transpose
+ */
+ public static void completeSymm(Mat m, boolean lowerToUpper) {
+ completeSymm_0(m.nativeObj, lowerToUpper);
+ }
+
+ /**
+ * Copies the lower or the upper half of a square matrix to its another half.
+ *
+ * The function cv::completeSymm copies the lower or the upper half of a square matrix to
+ * its another half. The matrix diagonal remains unchanged:
+ *
+ *
+ * \(\texttt{m}_{ij}=\texttt{m}_{ji}\) for \(i > j\) if
+ * lowerToUpper=false
+ *
+ *
+ * \(\texttt{m}_{ij}=\texttt{m}_{ji}\) for \(i < j\) if
+ * lowerToUpper=true
+ *
+ *
+ *
+ * @param m input-output floating-point square matrix.
+ * the upper half. Otherwise, the upper half is copied to the lower half.
+ * SEE: flip, transpose
+ */
+ public static void completeSymm(Mat m) {
+ completeSymm_1(m.nativeObj);
+ }
+
+
+ //
+ // C++: void cv::setIdentity(Mat& mtx, Scalar s = Scalar(1))
+ //
+
+ /**
+ * Initializes a scaled identity matrix.
+ *
+ * The function cv::setIdentity initializes a scaled identity matrix:
+ * \(\texttt{mtx} (i,j)= \fork{\texttt{value}}{ if \(i=j\)}{0}{otherwise}\)
+ *
+ * The function can also be emulated using the matrix initializers and the
+ * matrix expressions:
+ *
+ * Mat A = Mat::eye(4, 3, CV_32F)*5;
+ * // A will be set to [[5, 0, 0], [0, 5, 0], [0, 0, 5], [0, 0, 0]]
+ *
+ * @param mtx matrix to initialize (not necessarily square).
+ * @param s value to assign to diagonal elements.
+ * SEE: Mat::zeros, Mat::ones, Mat::setTo, Mat::operator=
+ */
+ public static void setIdentity(Mat mtx, Scalar s) {
+ setIdentity_0(mtx.nativeObj, s.val[0], s.val[1], s.val[2], s.val[3]);
+ }
+
+ /**
+ * Initializes a scaled identity matrix.
+ *
+ * The function cv::setIdentity initializes a scaled identity matrix:
+ * \(\texttt{mtx} (i,j)= \fork{\texttt{value}}{ if \(i=j\)}{0}{otherwise}\)
+ *
+ * The function can also be emulated using the matrix initializers and the
+ * matrix expressions:
+ *
+ * Mat A = Mat::eye(4, 3, CV_32F)*5;
+ * // A will be set to [[5, 0, 0], [0, 5, 0], [0, 0, 5], [0, 0, 0]]
+ *
+ * @param mtx matrix to initialize (not necessarily square).
+ * SEE: Mat::zeros, Mat::ones, Mat::setTo, Mat::operator=
+ */
+ public static void setIdentity(Mat mtx) {
+ setIdentity_1(mtx.nativeObj);
+ }
+
+
+ //
+ // C++: double cv::determinant(Mat mtx)
+ //
+
+ /**
+ * Returns the determinant of a square floating-point matrix.
+ *
+ * The function cv::determinant calculates and returns the determinant of the
+ * specified matrix. For small matrices ( mtx.cols=mtx.rows<=3 ), the
+ * direct method is used. For larger matrices, the function uses LU
+ * factorization with partial pivoting.
+ *
+ * For symmetric positively-determined matrices, it is also possible to use
+ * eigen decomposition to calculate the determinant.
+ * @param mtx input matrix that must have CV_32FC1 or CV_64FC1 type and
+ * square size.
+ * SEE: trace, invert, solve, eigen, REF: MatrixExpressions
+ * @return automatically generated
+ */
+ public static double determinant(Mat mtx) {
+ return determinant_0(mtx.nativeObj);
+ }
+
+
+ //
+ // C++: Scalar cv::trace(Mat mtx)
+ //
+
+ /**
+ * Returns the trace of a matrix.
+ *
+ * The function cv::trace returns the sum of the diagonal elements of the
+ * matrix mtx .
+ * \(\mathrm{tr} ( \texttt{mtx} ) = \sum _i \texttt{mtx} (i,i)\)
+ * @param mtx input matrix.
+ * @return automatically generated
+ */
+ public static Scalar trace(Mat mtx) {
+ return new Scalar(trace_0(mtx.nativeObj));
+ }
+
+
+ //
+ // C++: double cv::invert(Mat src, Mat& dst, int flags = DECOMP_LU)
+ //
+
+ /**
+ * Finds the inverse or pseudo-inverse of a matrix.
+ *
+ * The function cv::invert inverts the matrix src and stores the result in dst
+ * . When the matrix src is singular or non-square, the function calculates
+ * the pseudo-inverse matrix (the dst matrix) so that norm(src\*dst - I) is
+ * minimal, where I is an identity matrix.
+ *
+ * In case of the #DECOMP_LU method, the function returns non-zero value if
+ * the inverse has been successfully calculated and 0 if src is singular.
+ *
+ * In case of the #DECOMP_SVD method, the function returns the inverse
+ * condition number of src (the ratio of the smallest singular value to the
+ * largest singular value) and 0 if src is singular. The SVD method
+ * calculates a pseudo-inverse matrix if src is singular.
+ *
+ * Similarly to #DECOMP_LU, the method #DECOMP_CHOLESKY works only with
+ * non-singular square matrices that should also be symmetrical and
+ * positively defined. In this case, the function stores the inverted
+ * matrix in dst and returns non-zero. Otherwise, it returns 0.
+ *
+ * @param src input floating-point M x N matrix.
+ * @param dst output matrix of N x M size and the same type as src.
+ * @param flags inversion method (cv::DecompTypes)
+ * SEE: solve, SVD
+ * @return automatically generated
+ */
+ public static double invert(Mat src, Mat dst, int flags) {
+ return invert_0(src.nativeObj, dst.nativeObj, flags);
+ }
+
+ /**
+ * Finds the inverse or pseudo-inverse of a matrix.
+ *
+ * The function cv::invert inverts the matrix src and stores the result in dst
+ * . When the matrix src is singular or non-square, the function calculates
+ * the pseudo-inverse matrix (the dst matrix) so that norm(src\*dst - I) is
+ * minimal, where I is an identity matrix.
+ *
+ * In case of the #DECOMP_LU method, the function returns non-zero value if
+ * the inverse has been successfully calculated and 0 if src is singular.
+ *
+ * In case of the #DECOMP_SVD method, the function returns the inverse
+ * condition number of src (the ratio of the smallest singular value to the
+ * largest singular value) and 0 if src is singular. The SVD method
+ * calculates a pseudo-inverse matrix if src is singular.
+ *
+ * Similarly to #DECOMP_LU, the method #DECOMP_CHOLESKY works only with
+ * non-singular square matrices that should also be symmetrical and
+ * positively defined. In this case, the function stores the inverted
+ * matrix in dst and returns non-zero. Otherwise, it returns 0.
+ *
+ * @param src input floating-point M x N matrix.
+ * @param dst output matrix of N x M size and the same type as src.
+ * SEE: solve, SVD
+ * @return automatically generated
+ */
+ public static double invert(Mat src, Mat dst) {
+ return invert_1(src.nativeObj, dst.nativeObj);
+ }
+
+
+ //
+ // C++: bool cv::solve(Mat src1, Mat src2, Mat& dst, int flags = DECOMP_LU)
+ //
+
+ /**
+ * Solves one or more linear systems or least-squares problems.
+ *
+ * The function cv::solve solves a linear system or least-squares problem (the
+ * latter is possible with SVD or QR methods, or by specifying the flag
+ * #DECOMP_NORMAL ):
+ * \(\texttt{dst} = \arg \min _X \| \texttt{src1} \cdot \texttt{X} - \texttt{src2} \|\)
+ *
+ * If #DECOMP_LU or #DECOMP_CHOLESKY method is used, the function returns 1
+ * if src1 (or \(\texttt{src1}^T\texttt{src1}\) ) is non-singular. Otherwise,
+ * it returns 0. In the latter case, dst is not valid. Other methods find a
+ * pseudo-solution in case of a singular left-hand side part.
+ *
+ * Note: If you want to find a unity-norm solution of an under-defined
+ * singular system \(\texttt{src1}\cdot\texttt{dst}=0\) , the function solve
+ * will not do the work. Use SVD::solveZ instead.
+ *
+ * @param src1 input matrix on the left-hand side of the system.
+ * @param src2 input matrix on the right-hand side of the system.
+ * @param dst output solution.
+ * @param flags solution (matrix inversion) method (#DecompTypes)
+ * SEE: invert, SVD, eigen
+ * @return automatically generated
+ */
+ public static boolean solve(Mat src1, Mat src2, Mat dst, int flags) {
+ return solve_0(src1.nativeObj, src2.nativeObj, dst.nativeObj, flags);
+ }
+
+ /**
+ * Solves one or more linear systems or least-squares problems.
+ *
+ * The function cv::solve solves a linear system or least-squares problem (the
+ * latter is possible with SVD or QR methods, or by specifying the flag
+ * #DECOMP_NORMAL ):
+ * \(\texttt{dst} = \arg \min _X \| \texttt{src1} \cdot \texttt{X} - \texttt{src2} \|\)
+ *
+ * If #DECOMP_LU or #DECOMP_CHOLESKY method is used, the function returns 1
+ * if src1 (or \(\texttt{src1}^T\texttt{src1}\) ) is non-singular. Otherwise,
+ * it returns 0. In the latter case, dst is not valid. Other methods find a
+ * pseudo-solution in case of a singular left-hand side part.
+ *
+ * Note: If you want to find a unity-norm solution of an under-defined
+ * singular system \(\texttt{src1}\cdot\texttt{dst}=0\) , the function solve
+ * will not do the work. Use SVD::solveZ instead.
+ *
+ * @param src1 input matrix on the left-hand side of the system.
+ * @param src2 input matrix on the right-hand side of the system.
+ * @param dst output solution.
+ * SEE: invert, SVD, eigen
+ * @return automatically generated
+ */
+ public static boolean solve(Mat src1, Mat src2, Mat dst) {
+ return solve_1(src1.nativeObj, src2.nativeObj, dst.nativeObj);
+ }
+
+
+ //
+ // C++: void cv::sort(Mat src, Mat& dst, int flags)
+ //
+
+ /**
+ * Sorts each row or each column of a matrix.
+ *
+ * The function cv::sort sorts each matrix row or each matrix column in
+ * ascending or descending order. So you should pass two operation flags to
+ * get desired behaviour. If you want to sort matrix rows or columns
+ * lexicographically, you can use STL std::sort generic function with the
+ * proper comparison predicate.
+ *
+ * @param src input single-channel array.
+ * @param dst output array of the same size and type as src.
+ * @param flags operation flags, a combination of #SortFlags
+ * SEE: sortIdx, randShuffle
+ */
+ public static void sort(Mat src, Mat dst, int flags) {
+ sort_0(src.nativeObj, dst.nativeObj, flags);
+ }
+
+
+ //
+ // C++: void cv::sortIdx(Mat src, Mat& dst, int flags)
+ //
+
+ /**
+ * Sorts each row or each column of a matrix.
+ *
+ * The function cv::sortIdx sorts each matrix row or each matrix column in the
+ * ascending or descending order. So you should pass two operation flags to
+ * get desired behaviour. Instead of reordering the elements themselves, it
+ * stores the indices of sorted elements in the output array. For example:
+ *
+ * Mat A = Mat::eye(3,3,CV_32F), B;
+ * sortIdx(A, B, SORT_EVERY_ROW + SORT_ASCENDING);
+ * // B will probably contain
+ * // (because of equal elements in A some permutations are possible):
+ * // [[1, 2, 0], [0, 2, 1], [0, 1, 2]]
+ *
+ * @param src input single-channel array.
+ * @param dst output integer array of the same size as src.
+ * @param flags operation flags that could be a combination of cv::SortFlags
+ * SEE: sort, randShuffle
+ */
+ public static void sortIdx(Mat src, Mat dst, int flags) {
+ sortIdx_0(src.nativeObj, dst.nativeObj, flags);
+ }
+
+
+ //
+ // C++: int cv::solveCubic(Mat coeffs, Mat& roots)
+ //
+
+ /**
+ * Finds the real roots of a cubic equation.
+ *
+ * The function solveCubic finds the real roots of a cubic equation:
+ *
+ *
+ * if coeffs is a 4-element vector:
+ * \(\texttt{coeffs} [0] x^3 + \texttt{coeffs} [1] x^2 + \texttt{coeffs} [2] x + \texttt{coeffs} [3] = 0\)
+ *
+ *
+ * if coeffs is a 3-element vector:
+ * \(x^3 + \texttt{coeffs} [0] x^2 + \texttt{coeffs} [1] x + \texttt{coeffs} [2] = 0\)
+ *
+ *
+ *
+ * The roots are stored in the roots array.
+ * @param coeffs equation coefficients, an array of 3 or 4 elements.
+ * @param roots output array of real roots that has 1 or 3 elements.
+ * @return number of real roots. It can be 0, 1 or 2.
+ */
+ public static int solveCubic(Mat coeffs, Mat roots) {
+ return solveCubic_0(coeffs.nativeObj, roots.nativeObj);
+ }
+
+
+ //
+ // C++: double cv::solvePoly(Mat coeffs, Mat& roots, int maxIters = 300)
+ //
+
+ /**
+ * Finds the real or complex roots of a polynomial equation.
+ *
+ * The function cv::solvePoly finds real and complex roots of a polynomial equation:
+ * \(\texttt{coeffs} [n] x^{n} + \texttt{coeffs} [n-1] x^{n-1} + ... + \texttt{coeffs} [1] x + \texttt{coeffs} [0] = 0\)
+ * @param coeffs array of polynomial coefficients.
+ * @param roots output (complex) array of roots.
+ * @param maxIters maximum number of iterations the algorithm does.
+ * @return automatically generated
+ */
+ public static double solvePoly(Mat coeffs, Mat roots, int maxIters) {
+ return solvePoly_0(coeffs.nativeObj, roots.nativeObj, maxIters);
+ }
+
+ /**
+ * Finds the real or complex roots of a polynomial equation.
+ *
+ * The function cv::solvePoly finds real and complex roots of a polynomial equation:
+ * \(\texttt{coeffs} [n] x^{n} + \texttt{coeffs} [n-1] x^{n-1} + ... + \texttt{coeffs} [1] x + \texttt{coeffs} [0] = 0\)
+ * @param coeffs array of polynomial coefficients.
+ * @param roots output (complex) array of roots.
+ * @return automatically generated
+ */
+ public static double solvePoly(Mat coeffs, Mat roots) {
+ return solvePoly_1(coeffs.nativeObj, roots.nativeObj);
+ }
+
+
+ //
+ // C++: bool cv::eigen(Mat src, Mat& eigenvalues, Mat& eigenvectors = Mat())
+ //
+
+ /**
+ * Calculates eigenvalues and eigenvectors of a symmetric matrix.
+ *
+ * The function cv::eigen calculates just eigenvalues, or eigenvalues and eigenvectors of the symmetric
+ * matrix src:
+ *
+ * src*eigenvectors.row(i).t() = eigenvalues.at<srcType>(i)*eigenvectors.row(i).t()
+ *
+ *
+ * Note: Use cv::eigenNonSymmetric for calculation of real eigenvalues and eigenvectors of non-symmetric matrix.
+ *
+ * @param src input matrix that must have CV_32FC1 or CV_64FC1 type, square size and be symmetrical
+ * (src ^T^ == src).
+ * @param eigenvalues output vector of eigenvalues of the same type as src; the eigenvalues are stored
+ * in the descending order.
+ * @param eigenvectors output matrix of eigenvectors; it has the same size and type as src; the
+ * eigenvectors are stored as subsequent matrix rows, in the same order as the corresponding
+ * eigenvalues.
+ * SEE: eigenNonSymmetric, completeSymm , PCA
+ * @return automatically generated
+ */
+ public static boolean eigen(Mat src, Mat eigenvalues, Mat eigenvectors) {
+ return eigen_0(src.nativeObj, eigenvalues.nativeObj, eigenvectors.nativeObj);
+ }
+
+ /**
+ * Calculates eigenvalues and eigenvectors of a symmetric matrix.
+ *
+ * The function cv::eigen calculates just eigenvalues, or eigenvalues and eigenvectors of the symmetric
+ * matrix src:
+ *
+ * src*eigenvectors.row(i).t() = eigenvalues.at<srcType>(i)*eigenvectors.row(i).t()
+ *
+ *
+ * Note: Use cv::eigenNonSymmetric for calculation of real eigenvalues and eigenvectors of non-symmetric matrix.
+ *
+ * @param src input matrix that must have CV_32FC1 or CV_64FC1 type, square size and be symmetrical
+ * (src ^T^ == src).
+ * @param eigenvalues output vector of eigenvalues of the same type as src; the eigenvalues are stored
+ * in the descending order.
+ * eigenvectors are stored as subsequent matrix rows, in the same order as the corresponding
+ * eigenvalues.
+ * SEE: eigenNonSymmetric, completeSymm , PCA
+ * @return automatically generated
+ */
+ public static boolean eigen(Mat src, Mat eigenvalues) {
+ return eigen_1(src.nativeObj, eigenvalues.nativeObj);
+ }
+
+
+ //
+ // C++: void cv::eigenNonSymmetric(Mat src, Mat& eigenvalues, Mat& eigenvectors)
+ //
+
+ /**
+ * Calculates eigenvalues and eigenvectors of a non-symmetric matrix (real eigenvalues only).
+ *
+ * Note: Assumes real eigenvalues.
+ *
+ * The function calculates eigenvalues and eigenvectors (optional) of the square matrix src:
+ *
+ * src*eigenvectors.row(i).t() = eigenvalues.at<srcType>(i)*eigenvectors.row(i).t()
+ *
+ *
+ * @param src input matrix (CV_32FC1 or CV_64FC1 type).
+ * @param eigenvalues output vector of eigenvalues (type is the same type as src).
+ * @param eigenvectors output matrix of eigenvectors (type is the same type as src). The eigenvectors are stored as subsequent matrix rows, in the same order as the corresponding eigenvalues.
+ * SEE: eigen
+ */
+ public static void eigenNonSymmetric(Mat src, Mat eigenvalues, Mat eigenvectors) {
+ eigenNonSymmetric_0(src.nativeObj, eigenvalues.nativeObj, eigenvectors.nativeObj);
+ }
+
+
+ //
+ // C++: void cv::calcCovarMatrix(Mat samples, Mat& covar, Mat& mean, int flags, int ctype = CV_64F)
+ //
+
+ /**
+ *
+ * Note: use #COVAR_ROWS or #COVAR_COLS flag
+ * @param samples samples stored as rows/columns of a single matrix.
+ * @param covar output covariance matrix of the type ctype and square size.
+ * @param mean input or output (depending on the flags) array as the average value of the input vectors.
+ * @param flags operation flags as a combination of #CovarFlags
+ * @param ctype type of the matrixl; it equals 'CV_64F' by default.
+ */
+ public static void calcCovarMatrix(Mat samples, Mat covar, Mat mean, int flags, int ctype) {
+ calcCovarMatrix_0(samples.nativeObj, covar.nativeObj, mean.nativeObj, flags, ctype);
+ }
+
+ /**
+ *
+ * Note: use #COVAR_ROWS or #COVAR_COLS flag
+ * @param samples samples stored as rows/columns of a single matrix.
+ * @param covar output covariance matrix of the type ctype and square size.
+ * @param mean input or output (depending on the flags) array as the average value of the input vectors.
+ * @param flags operation flags as a combination of #CovarFlags
+ */
+ public static void calcCovarMatrix(Mat samples, Mat covar, Mat mean, int flags) {
+ calcCovarMatrix_1(samples.nativeObj, covar.nativeObj, mean.nativeObj, flags);
+ }
+
+
+ //
+ // C++: void cv::PCACompute(Mat data, Mat& mean, Mat& eigenvectors, int maxComponents = 0)
+ //
+
+ /**
+ * wrap PCA::operator()
+ * @param data automatically generated
+ * @param mean automatically generated
+ * @param eigenvectors automatically generated
+ * @param maxComponents automatically generated
+ */
+ public static void PCACompute(Mat data, Mat mean, Mat eigenvectors, int maxComponents) {
+ PCACompute_0(data.nativeObj, mean.nativeObj, eigenvectors.nativeObj, maxComponents);
+ }
+
+ /**
+ * wrap PCA::operator()
+ * @param data automatically generated
+ * @param mean automatically generated
+ * @param eigenvectors automatically generated
+ */
+ public static void PCACompute(Mat data, Mat mean, Mat eigenvectors) {
+ PCACompute_1(data.nativeObj, mean.nativeObj, eigenvectors.nativeObj);
+ }
+
+
+ //
+ // C++: void cv::PCACompute(Mat data, Mat& mean, Mat& eigenvectors, Mat& eigenvalues, int maxComponents = 0)
+ //
+
+ /**
+ * wrap PCA::operator() and add eigenvalues output parameter
+ * @param data automatically generated
+ * @param mean automatically generated
+ * @param eigenvectors automatically generated
+ * @param eigenvalues automatically generated
+ * @param maxComponents automatically generated
+ */
+ public static void PCACompute2(Mat data, Mat mean, Mat eigenvectors, Mat eigenvalues, int maxComponents) {
+ PCACompute2_0(data.nativeObj, mean.nativeObj, eigenvectors.nativeObj, eigenvalues.nativeObj, maxComponents);
+ }
+
+ /**
+ * wrap PCA::operator() and add eigenvalues output parameter
+ * @param data automatically generated
+ * @param mean automatically generated
+ * @param eigenvectors automatically generated
+ * @param eigenvalues automatically generated
+ */
+ public static void PCACompute2(Mat data, Mat mean, Mat eigenvectors, Mat eigenvalues) {
+ PCACompute2_1(data.nativeObj, mean.nativeObj, eigenvectors.nativeObj, eigenvalues.nativeObj);
+ }
+
+
+ //
+ // C++: void cv::PCACompute(Mat data, Mat& mean, Mat& eigenvectors, double retainedVariance)
+ //
+
+ /**
+ * wrap PCA::operator()
+ * @param data automatically generated
+ * @param mean automatically generated
+ * @param eigenvectors automatically generated
+ * @param retainedVariance automatically generated
+ */
+ public static void PCACompute(Mat data, Mat mean, Mat eigenvectors, double retainedVariance) {
+ PCACompute_2(data.nativeObj, mean.nativeObj, eigenvectors.nativeObj, retainedVariance);
+ }
+
+
+ //
+ // C++: void cv::PCACompute(Mat data, Mat& mean, Mat& eigenvectors, Mat& eigenvalues, double retainedVariance)
+ //
+
+ /**
+ * wrap PCA::operator() and add eigenvalues output parameter
+ * @param data automatically generated
+ * @param mean automatically generated
+ * @param eigenvectors automatically generated
+ * @param eigenvalues automatically generated
+ * @param retainedVariance automatically generated
+ */
+ public static void PCACompute2(Mat data, Mat mean, Mat eigenvectors, Mat eigenvalues, double retainedVariance) {
+ PCACompute2_2(data.nativeObj, mean.nativeObj, eigenvectors.nativeObj, eigenvalues.nativeObj, retainedVariance);
+ }
+
+
+ //
+ // C++: void cv::PCAProject(Mat data, Mat mean, Mat eigenvectors, Mat& result)
+ //
+
+ /**
+ * wrap PCA::project
+ * @param data automatically generated
+ * @param mean automatically generated
+ * @param eigenvectors automatically generated
+ * @param result automatically generated
+ */
+ public static void PCAProject(Mat data, Mat mean, Mat eigenvectors, Mat result) {
+ PCAProject_0(data.nativeObj, mean.nativeObj, eigenvectors.nativeObj, result.nativeObj);
+ }
+
+
+ //
+ // C++: void cv::PCABackProject(Mat data, Mat mean, Mat eigenvectors, Mat& result)
+ //
+
+ /**
+ * wrap PCA::backProject
+ * @param data automatically generated
+ * @param mean automatically generated
+ * @param eigenvectors automatically generated
+ * @param result automatically generated
+ */
+ public static void PCABackProject(Mat data, Mat mean, Mat eigenvectors, Mat result) {
+ PCABackProject_0(data.nativeObj, mean.nativeObj, eigenvectors.nativeObj, result.nativeObj);
+ }
+
+
+ //
+ // C++: void cv::SVDecomp(Mat src, Mat& w, Mat& u, Mat& vt, int flags = 0)
+ //
+
+ /**
+ * wrap SVD::compute
+ * @param src automatically generated
+ * @param w automatically generated
+ * @param u automatically generated
+ * @param vt automatically generated
+ * @param flags automatically generated
+ */
+ public static void SVDecomp(Mat src, Mat w, Mat u, Mat vt, int flags) {
+ SVDecomp_0(src.nativeObj, w.nativeObj, u.nativeObj, vt.nativeObj, flags);
+ }
+
+ /**
+ * wrap SVD::compute
+ * @param src automatically generated
+ * @param w automatically generated
+ * @param u automatically generated
+ * @param vt automatically generated
+ */
+ public static void SVDecomp(Mat src, Mat w, Mat u, Mat vt) {
+ SVDecomp_1(src.nativeObj, w.nativeObj, u.nativeObj, vt.nativeObj);
+ }
+
+
+ //
+ // C++: void cv::SVBackSubst(Mat w, Mat u, Mat vt, Mat rhs, Mat& dst)
+ //
+
+ /**
+ * wrap SVD::backSubst
+ * @param w automatically generated
+ * @param u automatically generated
+ * @param vt automatically generated
+ * @param rhs automatically generated
+ * @param dst automatically generated
+ */
+ public static void SVBackSubst(Mat w, Mat u, Mat vt, Mat rhs, Mat dst) {
+ SVBackSubst_0(w.nativeObj, u.nativeObj, vt.nativeObj, rhs.nativeObj, dst.nativeObj);
+ }
+
+
+ //
+ // C++: double cv::Mahalanobis(Mat v1, Mat v2, Mat icovar)
+ //
+
+ /**
+ * Calculates the Mahalanobis distance between two vectors.
+ *
+ * The function cv::Mahalanobis calculates and returns the weighted distance between two vectors:
+ * \(d( \texttt{vec1} , \texttt{vec2} )= \sqrt{\sum_{i,j}{\texttt{icovar(i,j)}\cdot(\texttt{vec1}(I)-\texttt{vec2}(I))\cdot(\texttt{vec1(j)}-\texttt{vec2(j)})} }\)
+ * The covariance matrix may be calculated using the #calcCovarMatrix function and then inverted using
+ * the invert function (preferably using the #DECOMP_SVD method, as the most accurate).
+ * @param v1 first 1D input vector.
+ * @param v2 second 1D input vector.
+ * @param icovar inverse covariance matrix.
+ * @return automatically generated
+ */
+ public static double Mahalanobis(Mat v1, Mat v2, Mat icovar) {
+ return Mahalanobis_0(v1.nativeObj, v2.nativeObj, icovar.nativeObj);
+ }
+
+
+ //
+ // C++: void cv::dft(Mat src, Mat& dst, int flags = 0, int nonzeroRows = 0)
+ //
+
+ /**
+ * Performs a forward or inverse Discrete Fourier transform of a 1D or 2D floating-point array.
+ *
+ * The function cv::dft performs one of the following:
+ *
+ *
+ * Forward the Fourier transform of a 1D vector of N elements:
+ * \(Y = F^{(N)} \cdot X,\)
+ * where \(F^{(N)}_{jk}=\exp(-2\pi i j k/N)\) and \(i=\sqrt{-1}\)
+ *
+ *
+ * Inverse the Fourier transform of a 1D vector of N elements:
+ * \(\begin{array}{l} X'= \left (F^{(N)} \right )^{-1} \cdot Y = \left (F^{(N)} \right )^* \cdot y \\ X = (1/N) \cdot X, \end{array}\)
+ * where \(F^*=\left(\textrm{Re}(F^{(N)})-\textrm{Im}(F^{(N)})\right)^T\)
+ *
+ *
+ * Forward the 2D Fourier transform of a M x N matrix:
+ * \(Y = F^{(M)} \cdot X \cdot F^{(N)}\)
+ *
+ *
+ * Inverse the 2D Fourier transform of a M x N matrix:
+ * \(\begin{array}{l} X'= \left (F^{(M)} \right )^* \cdot Y \cdot \left (F^{(N)} \right )^* \\ X = \frac{1}{M \cdot N} \cdot X' \end{array}\)
+ *
+ *
+ *
+ * In case of real (single-channel) data, the output spectrum of the forward Fourier transform or input
+ * spectrum of the inverse Fourier transform can be represented in a packed format called *CCS*
+ * (complex-conjugate-symmetrical). It was borrowed from IPL (Intel\* Image Processing Library). Here
+ * is how 2D *CCS* spectrum looks:
+ * \(\begin{bmatrix} Re Y_{0,0} & Re Y_{0,1} & Im Y_{0,1} & Re Y_{0,2} & Im Y_{0,2} & \cdots & Re Y_{0,N/2-1} & Im Y_{0,N/2-1} & Re Y_{0,N/2} \\ Re Y_{1,0} & Re Y_{1,1} & Im Y_{1,1} & Re Y_{1,2} & Im Y_{1,2} & \cdots & Re Y_{1,N/2-1} & Im Y_{1,N/2-1} & Re Y_{1,N/2} \\ Im Y_{1,0} & Re Y_{2,1} & Im Y_{2,1} & Re Y_{2,2} & Im Y_{2,2} & \cdots & Re Y_{2,N/2-1} & Im Y_{2,N/2-1} & Im Y_{1,N/2} \\ \hdotsfor{9} \\ Re Y_{M/2-1,0} & Re Y_{M-3,1} & Im Y_{M-3,1} & \hdotsfor{3} & Re Y_{M-3,N/2-1} & Im Y_{M-3,N/2-1}& Re Y_{M/2-1,N/2} \\ Im Y_{M/2-1,0} & Re Y_{M-2,1} & Im Y_{M-2,1} & \hdotsfor{3} & Re Y_{M-2,N/2-1} & Im Y_{M-2,N/2-1}& Im Y_{M/2-1,N/2} \\ Re Y_{M/2,0} & Re Y_{M-1,1} & Im Y_{M-1,1} & \hdotsfor{3} & Re Y_{M-1,N/2-1} & Im Y_{M-1,N/2-1}& Re Y_{M/2,N/2} \end{bmatrix}\)
+ *
+ * In case of 1D transform of a real vector, the output looks like the first row of the matrix above.
+ *
+ * So, the function chooses an operation mode depending on the flags and size of the input array:
+ *
+ *
+ * If #DFT_ROWS is set or the input array has a single row or single column, the function
+ * performs a 1D forward or inverse transform of each row of a matrix when #DFT_ROWS is set.
+ * Otherwise, it performs a 2D transform.
+ *
+ *
+ * If the input array is real and #DFT_INVERSE is not set, the function performs a forward 1D or
+ * 2D transform:
+ *