View Source Evision (Evision v0.1.31)

Link to this section Summary

Functions

Calculates the per-element absolute difference between two arrays or between an array and a scalar.

Calculates the per-element absolute difference between two arrays or between an array and a scalar.

Adds an image to the accumulator image.

Adds an image to the accumulator image.

Adds the per-element product of two input images to the accumulator image.

Adds the per-element product of two input images to the accumulator image.

Adds the square of a source image to the accumulator image.

Adds the square of a source image to the accumulator image.

Updates a running average.

Updates a running average.

Calculates the per-element sum of two arrays or an array and a scalar.

Calculates the per-element sum of two arrays or an array and a scalar.

Draws a text on the image.

Draws a text on the image.

Calculates the weighted sum of two arrays.

Calculates the weighted sum of two arrays.

Variant 1:

Applies a user colormap on a given image.

Variant 1:

Applies a user colormap on a given image.

Approximates a polygonal curve(s) with the specified precision.

Approximates a polygonal curve(s) with the specified precision.

Calculates a contour perimeter or a curve length.

Draws an arrow segment pointing from the first point to the second one.

Draws an arrow segment pointing from the first point to the second one.

naive nearest neighbor finder

naive nearest neighbor finder

Applies the bilateral filter to an image.

Applies the bilateral filter to an image.

Blurs an image using the normalized box filter.

Blurs an image using the normalized box filter.

Computes the source location of an extrapolated pixel.

Calculates the up-right bounding rectangle of a point set or non-zero pixels of gray-scale image.

Blurs an image using the box filter.

Blurs an image using the box filter.

Finds the four vertices of a rotated rect. Useful to draw the rotated rectangle.

Finds the four vertices of a rotated rect. Useful to draw the rotated rectangle.

Constructs the image pyramid which can be passed to calcOpticalFlowPyrLK.

Constructs the image pyramid which can be passed to calcOpticalFlowPyrLK.

Calculates an optical flow for a sparse feature set using the iterative Lucas-Kanade method with pyramids.

Calculates an optical flow for a sparse feature set using the iterative Lucas-Kanade method with pyramids.

Finds the camera intrinsic and extrinsic parameters from several views of a calibration pattern.

Finds the camera intrinsic and extrinsic parameters from several views of a calibration pattern.

Finds the camera intrinsic and extrinsic parameters from several views of a calibration pattern.

Finds the camera intrinsic and extrinsic parameters from several views of a calibration pattern.

Computes Hand-Eye calibration: \f$_{}^{g}\textrm{T}_c\f$

Computes Hand-Eye calibration: \f$_{}^{g}\textrm{T}_c\f$

Computes Robot-World/Hand-Eye calibration: \f$_{}^{w}\textrm{T}_b\f$ and \f$_{}^{c}\textrm{T}_g\f$

Computes Robot-World/Hand-Eye calibration: \f$_{}^{w}\textrm{T}_b\f$ and \f$_{}^{c}\textrm{T}_g\f$

Computes useful camera characteristics from the camera intrinsic matrix.

Finds an object center, size, and orientation.

Finds edges in an image using the Canny algorithm @cite Canny86 .

Calculates the magnitude and angle of 2D vectors.

Calculates the magnitude and angle of 2D vectors.

checkChessboard

Returns true if the specified feature is supported by the host hardware.

Checks every element of an input array for invalid values.

Checks every element of an input array for invalid values.

Given an original color image, two differently colored versions of this image can be mixed seamlessly.

Given an original color image, two differently colored versions of this image can be mixed seamlessly.

Performs the per-element comparison of two arrays or an array and scalar value.

Performs the per-element comparison of two arrays or an array and scalar value.

Compares two histograms.

Copies the lower or the upper half of a square matrix to its another half.

Copies the lower or the upper half of a square matrix to its another half.

Combines two rotation-and-shift transformations.

Combines two rotation-and-shift transformations.

For points in an image of a stereo pair, computes the corresponding epilines in the other image.

For points in an image of a stereo pair, computes the corresponding epilines in the other image.

Computes the Enhanced Correlation Coefficient value between two images @cite EP08 .

Computes the Enhanced Correlation Coefficient value between two images @cite EP08 .

connectedComponents

connectedComponents

computes the connected components labeled image of boolean image

computes the connected components labeled image of boolean image

connectedComponentsWithStats

connectedComponentsWithStats

computes the connected components labeled image of boolean image and also produces a statistics output for each label

computes the connected components labeled image of boolean image and also produces a statistics output for each label

Calculates a contour area.

Calculates a contour area.

Converts an array to half precision floating number.

Converts an array to half precision floating number.

Converts image transformation maps from one representation to another.

Converts image transformation maps from one representation to another.

Converts points from homogeneous to Euclidean space.

Converts points from homogeneous to Euclidean space.

Converts points from Euclidean to homogeneous space.

Converts points from Euclidean to homogeneous space.

Scales, calculates absolute values, and converts the result to 8-bit.

Scales, calculates absolute values, and converts the result to 8-bit.

Finds the convex hull of a point set.

Finds the convex hull of a point set.

Finds the convexity defects of a contour.

Finds the convexity defects of a contour.

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.

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.

Calculates eigenvalues and eigenvectors of image blocks for corner detection.

Calculates eigenvalues and eigenvectors of image blocks for corner detection.

Harris corner detector.

Calculates the minimal eigenvalue of gradient matrices for corner detection.

Calculates the minimal eigenvalue of gradient matrices for corner detection.

Refines coordinates of corresponding points.

Refines coordinates of corresponding points.

Counts non-zero array elements.

createAffineTransformer

Creates AlignMTB object

Creates AlignMTB object

Creates KNN Background Subtractor

Creates KNN Background Subtractor

Creates MOG2 Background Subtractor

Creates MOG2 Background Subtractor

Creates CalibrateDebevec object

Creates CalibrateDebevec object

Creates CalibrateRobertson object

Creates CalibrateRobertson object

createChiHistogramCostExtractor

createChiHistogramCostExtractor

Creates a smart pointer to a cv::CLAHE class and initializes it.

Creates a smart pointer to a cv::CLAHE class and initializes it.

createEMDHistogramCostExtractor

createEMDHistogramCostExtractor

createEMDL1HistogramCostExtractor

createEMDL1HistogramCostExtractor

Creates a smart pointer to a cv::GeneralizedHoughBallard class and initializes it.

Creates a smart pointer to a cv::GeneralizedHoughGuil class and initializes it.

This function computes a Hanning window coefficients in two dimensions.

This function computes a Hanning window coefficients in two dimensions.

createHausdorffDistanceExtractor

createHausdorffDistanceExtractor

Creates a smart pointer to a LineSegmentDetector object and initializes it.

Creates a smart pointer to a LineSegmentDetector object and initializes it.

Creates MergeDebevec object

Creates MergeMertens object

Creates MergeMertens object

Creates MergeRobertson object

createNormHistogramCostExtractor

createNormHistogramCostExtractor

createShapeContextDistanceExtractor

createShapeContextDistanceExtractor

createThinPlateSplineShapeTransformer

createThinPlateSplineShapeTransformer

Creates simple linear mapper with gamma correction

Creates simple linear mapper with gamma correction

Creates TonemapDrago object

Creates TonemapDrago object

Creates TonemapMantiuk object

Creates TonemapMantiuk object

Creates TonemapReinhard object

Creates TonemapReinhard object

Computes the cube root of an argument.

Converts an image from one color space to another.

Converts an image from one color space to another.

Converts an image from one color space to another where the source image is stored in two planes.

Converts an image from one color space to another where the source image is stored in two planes.

Performs a forward or inverse discrete Cosine transform of 1D or 2D array.

Performs a forward or inverse discrete Cosine transform of 1D or 2D array.

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

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

Decompose an essential matrix to possible rotations and translation.

Decompose an essential matrix to possible rotations and translation.

Decompose a homography matrix to rotation(s), translation(s) and plane normal(s).

Decompose a homography matrix to rotation(s), translation(s) and plane normal(s).

Decomposes a projection matrix into a rotation matrix and a camera intrinsic matrix.

Decomposes a projection matrix into a rotation matrix and a camera intrinsic matrix.

main function for all demosaicing processes

main function for all demosaicing processes

This filter enhances the details of a particular image.

This filter enhances the details of a particular image.

Returns the determinant of a square floating-point matrix.

Performs a forward or inverse Discrete Fourier transform of a 1D or 2D floating-point array.

Performs a forward or inverse Discrete Fourier transform of a 1D or 2D floating-point array.

Dilates an image by using a specific structuring element.

Dilates an image by using a specific structuring element.

Displays a text on a window image as an overlay for a specified duration.

Displays a text on a window image as an overlay for a specified duration.

Displays a text on the window statusbar during the specified period of time.

Displays a text on the window statusbar during the specified period of time.

Calculates the distance to the closest zero pixel for each pixel of the source image.

Calculates the distance to the closest zero pixel for each pixel of the source image.

Variant 1:

divide

Variant 1:

divide

Performs the per-element division of the first Fourier spectrum by the second Fourier spectrum.

Performs the per-element division of the first Fourier spectrum by the second Fourier spectrum.

Draws contours outlines or filled contours.

Draws contours outlines or filled contours.

Draw axes of the world/object coordinate system from pose estimation. @sa solvePnP

Draw axes of the world/object coordinate system from pose estimation. @sa solvePnP

Draws a marker on a predefined position in an image.

Draws a marker on a predefined position in an image.

Draws the found matches of keypoints from two images.

Filtering is the fundamental operation in image and video processing. Edge-preserving smoothing filters are used in many different applications @cite EM11 .

Filtering is the fundamental operation in image and video processing. Edge-preserving smoothing filters are used in many different applications @cite EM11 .

Calculates eigenvalues and eigenvectors of a symmetric matrix.

Calculates eigenvalues and eigenvectors of a symmetric matrix.

Calculates eigenvalues and eigenvectors of a non-symmetric matrix (real eigenvalues only).

Calculates eigenvalues and eigenvectors of a non-symmetric matrix (real eigenvalues only).

Approximates an elliptic arc with a polyline.

Draws a simple or thick elliptic arc or fills an ellipse sector.

Draws a simple or thick elliptic arc or fills an ellipse sector.

Computes the "minimal work" distance between two weighted point configurations.

Computes the "minimal work" distance between two weighted point configurations.

return a list of enabled modules in this build

Equalizes the histogram of a grayscale image.

Equalizes the histogram of a grayscale image.

Erodes an image by using a specific structuring element.

Erodes an image by using a specific structuring element.

Computes an optimal affine transformation between two 2D point sets.

Variant 1:

estimateAffine2D

Computes an optimal affine transformation between two 3D point sets.

Computes an optimal affine transformation between two 3D point sets.

Computes an optimal limited affine transformation with 4 degrees of freedom between two 2D point sets.

Computes an optimal limited affine transformation with 4 degrees of freedom between two 2D point sets.

Estimates the sharpness of a detected chessboard.

Estimates the sharpness of a detected chessboard.

Computes an optimal translation between two 3D point sets.

Computes an optimal translation between two 3D point sets.

Calculates the exponent of every array element.

Calculates the exponent of every array element.

Extracts a single channel from src (coi is 0-based index)

Extracts a single channel from src (coi is 0-based index)

Calculates the angle of a 2D vector in degrees.

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

Variant 1:

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

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

Modification of fastNlMeansDenoising function for colored images

Modification of fastNlMeansDenoising function for colored images

Modification of fastNlMeansDenoisingMulti function for colored images sequences

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. For example video. This version of the function is for grayscale images or for manual manipulation with colorspaces. For more details see http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.131.6394

Variant 1:

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. For more details see http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.131.6394

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. For more details see http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.131.6394

Fills a convex polygon.

Fills the area bounded by one or more polygons.

Fills the area bounded by one or more polygons.

Convolves an image with the kernel.

Convolves an image with the kernel.

Filters homography decompositions based on additional information.

Filters homography decompositions based on additional information.

Filters off small noise blobs (speckles) in the disparity map

Filters off small noise blobs (speckles) in the disparity map

Finds the positions of internal corners of the chessboard.

Finds the positions of internal corners of the chessboard.

Finds the positions of internal corners of the chessboard using a sector based approach.

Finds the positions of internal corners of the chessboard using a sector based approach.

Finds contours in a binary image.

Finds contours in a binary image.

Variant 1:

Calculates an essential matrix from the corresponding points in two images.

Calculates an essential matrix from the corresponding points in two images.

Calculates an essential matrix from the corresponding points in two images from potentially two different cameras.

Variant 1:

findFundamentalMat

Calculates a fundamental matrix from the corresponding points in two images.

Calculates a fundamental matrix from the corresponding points in two images.

Finds a perspective transformation between two planes.

Returns the list of locations of non-zero pixels

Returns the list of locations of non-zero pixels

Finds the geometric transform (warp) between two images in terms of the ECC criterion @cite EP08 .

Fits an ellipse around a set of 2D points.

Fits an ellipse around a set of 2D points.

Fits an ellipse around a set of 2D points.

Fits a line to a 2D or 3D point set.

Fits a line to a 2D or 3D point set.

Flips a 2D array around vertical, horizontal, or both axes.

Flips a 2D array around vertical, horizontal, or both axes.

Flips a n-dimensional at given axis

Flips a n-dimensional at given axis

Fills a connected component with the given color.

Fills a connected component with the given color.

Blurs an image using a Gaussian filter.

Blurs an image using a Gaussian filter.

Performs generalized matrix multiplication.

Performs generalized matrix multiplication.

getAffineTransform

Returns full configuration time cmake output.

Returns list of CPU features enabled during compilation.

Returns the number of CPU ticks.

Returns the default new camera matrix.

Returns the default new camera matrix.

Returns filter coefficients for computing spatial image derivatives.

Returns filter coefficients for computing spatial image derivatives.

Calculates the font-specific size to use to achieve a given height in pixels.

Calculates the font-specific size to use to achieve a given height in pixels.

Returns Gabor filter coefficients.

Returns Gabor filter coefficients.

Returns Gaussian filter coefficients.

Returns Gaussian filter coefficients.

Returns feature name by ID

getLogLevel

Returns the number of logical CPUs available for the process.

Returns the number of threads used by OpenCV for parallel regions.

Returns the optimal DFT size for a given vector size.

Returns the new camera intrinsic matrix based on the free scaling parameter.

Returns the new camera intrinsic matrix based on the free scaling parameter.

Calculates a perspective transform from four pairs of the corresponding points.

Calculates a perspective transform from four pairs of the corresponding points.

Retrieves a pixel rectangle from an image with sub-pixel accuracy.

Retrieves a pixel rectangle from an image with sub-pixel accuracy.

Calculates an affine matrix of 2D rotation.

Returns a structuring element of the specified size and shape for morphological operations.

Returns a structuring element of the specified size and shape for morphological operations.

Calculates the width and height of a text string.

Returns the index of the currently executed thread within the current parallel region. Always returns 0 if called outside of parallel region.

Returns the number of ticks.

Returns the number of ticks per second.

Returns the trackbar position.

Returns major library version

Returns minor library version

Returns revision field of the library version

Returns library version string

Provides rectangle of image in the window.

Provides parameters of a window.

Same as above, but returns also quality measure of the detected corners.

Same as above, but returns also quality measure of the detected corners.

Returns true if the specified image can be decoded by OpenCV

Returns true if an image with the specified filename can be encoded by OpenCV

haveOpenVX

hconcat

Finds circles in a grayscale image using the Hough transform.

Finds circles in a grayscale image using the Hough transform.

Finds lines in a binary image using the standard Hough transform.

Finds lines in a binary image using the standard Hough transform.

Finds line segments in a binary image using the probabilistic Hough transform.

Finds line segments in a binary image using the probabilistic Hough transform.

Finds lines in a binary image using the standard Hough transform and get accumulator.

Finds lines in a binary image using the standard Hough transform and get accumulator.

HuMoments

HuMoments

Calculates the inverse Discrete Cosine Transform of a 1D or 2D array.

Calculates the inverse Discrete Cosine Transform of a 1D or 2D array.

Calculates the inverse Discrete Fourier Transform of a 1D or 2D array.

Calculates the inverse Discrete Fourier Transform of a 1D or 2D array.

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

Returns the number of images inside the give file

Reads a multi-page image from a buffer in memory.

Reads a multi-page image from a buffer in memory.

Encodes an image into a memory buffer.

Encodes an image into a memory buffer.

Loads an image from a file.

Loads an image from a file.

Loads a multi-page image from a file.

Loads a multi-page image from a file.

Loads a of images of a multi-page image from a file.

Loads a of images of a multi-page image from a file.

Saves an image to a specified file.

Saves an image to a specified file.

Finds an initial camera intrinsic matrix from 3D-2D point correspondences.

Finds an initial camera intrinsic matrix from 3D-2D point correspondences.

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.

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.

Computes the undistortion and rectification transformation map.

Computes the undistortion and rectification transformation map.

Restores the selected region in an image using the region neighborhood.

Restores the selected region in an image using the region neighborhood.

Checks if array elements lie between the elements of two other arrays.

Checks if array elements lie between the elements of two other arrays.

Inserts a single channel to dst (coi is 0-based index)

integral2

Calculates the integral of an image.

Calculates the integral of an image.

integral

Finds intersection of two convex polygons

Finds intersection of two convex polygons

Finds the inverse or pseudo-inverse of a matrix.

Finds the inverse or pseudo-inverse of a matrix.

Inverts an affine transformation.

Inverts an affine transformation.

Tests a contour convexity.

Finds centers of clusters and groups input samples around the clusters.

Finds centers of clusters and groups input samples around the clusters.

Calculates the Laplacian of an image.

Calculates the Laplacian of an image.

Draws a line segment connecting two points.

Draws a line segment connecting two points.

Remaps an image to polar coordinates space.

Remaps an image to polar coordinates space.

Calculates the natural logarithm of every array element.

Calculates the natural logarithm of every array element.

Remaps an image to semilog-polar coordinates space.

Remaps an image to semilog-polar coordinates space.

Performs a look-up table transform of an array.

Performs a look-up table transform of an array.

Calculates the magnitude of 2D vectors.

Calculates the magnitude of 2D vectors.

Calculates the Mahalanobis distance between two vectors.

Compares a template against overlapped image regions.

Compares a template against overlapped image regions.

Computes partial derivatives of the matrix product for each multiplied matrix.

Computes partial derivatives of the matrix product for each multiplied matrix.

Calculates per-element maximum of two arrays or an array and a scalar.

Calculates per-element maximum of two arrays or an array and a scalar.

Calculates an average (mean) of array elements.

Calculates an average (mean) of array elements.

Finds an object on a back projection image.

meanStdDev

Blurs an image using the median filter.

Blurs an image using the median filter.

merge

Calculates per-element minimum of two arrays or an array and a scalar.

Calculates per-element minimum of two arrays or an array and a scalar.

Finds a rotated rectangle of the minimum area enclosing the input 2D point set.

Finds a circle of the minimum area enclosing a 2D point set.

Finds a triangle of minimum area enclosing a 2D point set and returns its area.

Finds a triangle of minimum area enclosing a 2D point set and returns its area.

Finds the global minimum and maximum in an array.

Finds the global minimum and maximum in an array.

Calculates all of the moments up to the third order of a polygon or rasterized shape.

Calculates all of the moments up to the third order of a polygon or rasterized shape.

Performs advanced morphological transformations.

Performs advanced morphological transformations.

Moves the window to the specified position

Performs the per-element multiplication of two Fourier spectrums.

Performs the per-element multiplication of two Fourier spectrums.

Calculates the product of a matrix and its transposition.

Calculates the product of a matrix and its transposition.

Calculates the per-element scaled product of two arrays.

Calculates the per-element scaled product of two arrays.

Creates a window.

Creates a window.

Calculates the absolute norm of an array.

Variant 1:

Calculates an absolute difference norm or a relative difference norm.

Calculates an absolute difference norm or a relative difference norm.

Normalizes the norm or value range of an array.

Normalizes the norm or value range of an array.

converts NaNs to the given number

converts NaNs to the given number

Variant 1:

PCACompute2

Variant 1:

PCACompute

Pencil-like non-photorealistic line drawing

Pencil-like non-photorealistic line drawing

Performs the perspective matrix transformation of vectors.

Performs the perspective matrix transformation of vectors.

Calculates the rotation angle of 2D vectors.

Calculates the rotation angle of 2D vectors.

The function is used to detect translational shifts that occur between two images.

The function is used to detect translational shifts that occur between two images.

Performs a point-in-contour test.

Calculates x and y coordinates of 2D vectors from their magnitude and angle.

Calculates x and y coordinates of 2D vectors from their magnitude and angle.

Polls for a pressed key.

Draws several polygonal curves.

Draws several polygonal curves.

Raises every array element to a power.

Raises every array element to a power.

Calculates a feature map for corner detection.

Calculates a feature map for corner detection.

Computes the Peak Signal-to-Noise Ratio (PSNR) image quality metric.

Computes the Peak Signal-to-Noise Ratio (PSNR) image quality metric.

Blurs an image and downsamples it.

Blurs an image and downsamples it.

Performs initial step of meanshift segmentation of an image.

Performs initial step of meanshift segmentation of an image.

Upsamples an image and then blurs it.

Upsamples an image and then blurs it.

Fills the array with normally distributed random numbers.

Shuffles the array elements randomly.

Shuffles the array elements randomly.

Generates a single uniformly-distributed random number or an array of random numbers.

Read a .flo file

Variant 1:

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.

Variant 1:

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.

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.

Variant 1:

Draws a simple, thick, or filled up-right rectangle.

Draws a simple, thick, or filled up-right rectangle.

Finds out if there is any intersection between two rectangles

Reduces a matrix to a vector.

Reduces a matrix to a vector.

Finds indices of max elements along provided axis

Finds indices of max elements along provided axis

Finds indices of min elements along provided axis

Finds indices of min elements along provided axis

Applies a generic geometrical transformation to an image.

Applies a generic geometrical transformation to an image.

Fills the output array with repeated copies of the input array.

Fills the output array with repeated copies of the input array.

Reprojects a disparity image to 3D space.

Reprojects a disparity image to 3D space.

Resizes an image.

Resizes an image.

Resizes the window to the specified size

Converts a rotation matrix to a rotation vector or vice versa.

Converts a rotation matrix to a rotation vector or vice versa.

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).

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).

Finds out if there is any intersection between two rotated rectangles.

Finds out if there is any intersection between two rotated rectangles.

Computes an RQ decomposition of 3x3 matrices.

Computes an RQ decomposition of 3x3 matrices.

Calculates the Sampson Distance between two points.

Calculates the sum of a scaled array and another array.

Calculates the sum of a scaled array and another array.

Calculates the first x- or y- image derivative using Scharr operator.

Calculates the first x- or y- image derivative using Scharr operator.

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 .

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 .

selectROI

Variant 1:

Allows users to select a ROI on the given image.

Allows users to select a ROI on the given image.

Allows users to select multiple ROIs on the given image.

Allows users to select multiple ROIs on the given image.

Applies a separable linear filter to an image.

Applies a separable linear filter to an image.

Initializes a scaled identity matrix.

Initializes a scaled identity matrix.

setLogLevel

OpenCV will try to set the number of threads for the next parallel region.

Sets state of default random number generator.

Sets the trackbar maximum position.

Sets the trackbar minimum position.

Sets the trackbar position.

setUseOpenVX

Enables or disables the optimized code.

Changes parameters of a window dynamically.

Updates window title

Calculates the first, second, third, or mixed image derivatives using an extended Sobel operator.

Calculates the first, second, third, or mixed image derivatives using an extended Sobel operator.

Solves one or more linear systems or least-squares problems.

Solves one or more linear systems or least-squares problems.

Finds the real roots of a cubic equation.

Finds the real roots of a cubic equation.

Solve given (non-integer) linear programming problem using the Simplex Algorithm (Simplex Method).

Solve given (non-integer) linear programming problem using the Simplex Algorithm (Simplex Method).

Finds an object pose from 3 3D-2D point correspondences.

Finds an object pose from 3 3D-2D point correspondences.

Finds an object pose from 3D-2D point correspondences.

Finds an object pose from 3D-2D point correspondences.

Finds an object pose from 3D-2D point correspondences.

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.

Finds the real or complex roots of a polynomial equation.

Finds the real or complex roots of a polynomial equation.

Sorts each row or each column of a matrix.

Sorts each row or each column of a matrix.

Sorts each row or each column of a matrix.

Sorts each row or each column of a matrix.

Calculates the first order image derivative in both x and y using a Sobel operator

Calculates the first order image derivative in both x and y using a Sobel operator

split

Calculates the normalized sum of squares of the pixel values overlapping the filter.

Calculates the normalized sum of squares of the pixel values overlapping the filter.

Calculates a square root of array elements.

Calculates a square root of array elements.

Blurs an image using the stackBlur.

Blurs an image using the stackBlur.

startWindowThread

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.

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.

Computes rectification transforms for each head of a calibrated stereo camera.

Computes rectification transforms for each head of a calibrated stereo camera.

Computes a rectification transform for an uncalibrated stereo camera.

Computes a rectification transform for an uncalibrated stereo camera.

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.

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.

Calculates the per-element difference between two arrays or array and a scalar.

Calculates the per-element difference between two arrays or array and a scalar.

Calculates the sum of array elements.

SVDecomp

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.

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.

Applies a fixed-level threshold to each array element.

Applies a fixed-level threshold to each array element.

Returns the trace of a matrix.

Performs the matrix transformation of every array element.

Performs the matrix transformation of every array element.

Transposes a matrix.

Transposes a matrix.

Transpose for n-dimensional matrices.

Transpose for n-dimensional matrices.

This function reconstructs 3-dimensional points (in homogeneous coordinates) by using their observations with a stereo camera.

This function reconstructs 3-dimensional points (in homogeneous coordinates) by using their observations with a stereo camera.

Transforms an image to compensate for lens distortion.

Transforms an image to compensate for lens distortion.

Compute undistorted image points position

Compute undistorted image points position

Computes the ideal point coordinates from the observed point coordinates.

Computes the ideal point coordinates from the observed point coordinates.

useOpenVX

Returns the status of optimized code usage.

vconcat

Similar to #waitKey, but returns full key code.

Similar to #waitKey, but returns full key code.

Applies an affine transformation to an image.

Applies an affine transformation to an image.

Applies a perspective transformation to an image.

Applies a perspective transformation to an image.

Performs a marker-based image segmentation using the watershed algorithm.

Write a .flo to disk

Link to this section Functions

Calculates the per-element absolute difference between two arrays or between an array and a scalar.

Positional Arguments
  • src1: Evision.Mat.t().

    first input array or a scalar.

  • src2: Evision.Mat.t().

    second input array or a scalar.

Return
  • dst: Evision.Mat.t().

    output array that has the same size and type as input arrays.

The function cv::absdiff calculates: Absolute difference between two arrays when they have the same size and type: \f[\texttt{dst}(I) = \texttt{saturate} (| \texttt{src1}(I) - \texttt{src2}(I)|)\f] 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: \f[\texttt{dst}(I) = \texttt{saturate} (| \texttt{src1}(I) - \texttt{src2} |)\f] 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: \f[\texttt{dst}(I) = \texttt{saturate} (| \texttt{src1} - \texttt{src2}(I) |)\f] 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. @sa cv::abs(const Mat&)

Python prototype (for reference only):

absdiff(src1, src2[, dst]) -> dst
Link to this function

absdiff(src1, src2, opts)

View Source
@spec absdiff(
  Evision.Mat.maybe_mat_in(),
  Evision.Mat.maybe_mat_in(),
  [{atom(), term()}, ...] | nil
) ::
  Evision.Mat.t() | {:error, String.t()}

Calculates the per-element absolute difference between two arrays or between an array and a scalar.

Positional Arguments
  • src1: Evision.Mat.t().

    first input array or a scalar.

  • src2: Evision.Mat.t().

    second input array or a scalar.

Return
  • dst: Evision.Mat.t().

    output array that has the same size and type as input arrays.

The function cv::absdiff calculates: Absolute difference between two arrays when they have the same size and type: \f[\texttt{dst}(I) = \texttt{saturate} (| \texttt{src1}(I) - \texttt{src2}(I)|)\f] 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: \f[\texttt{dst}(I) = \texttt{saturate} (| \texttt{src1}(I) - \texttt{src2} |)\f] 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: \f[\texttt{dst}(I) = \texttt{saturate} (| \texttt{src1} - \texttt{src2}(I) |)\f] 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. @sa cv::abs(const Mat&)

Python prototype (for reference only):

absdiff(src1, src2[, dst]) -> dst
@spec accumulate(Evision.Mat.maybe_mat_in(), Evision.Mat.maybe_mat_in()) ::
  Evision.Mat.t() | {:error, String.t()}

Adds an image to the accumulator image.

Positional Arguments
  • src: Evision.Mat.t().

    Input image of type CV_8UC(n), CV_16UC(n), CV_32FC(n) or CV_64FC(n), where n is a positive integer.

Keyword Arguments
  • mask: Evision.Mat.t().

    Optional operation mask.

Return
  • dst: Evision.Mat.t().

    %Accumulator image with the same number of channels as input image, and a depth of CV_32F or CV_64F.

The function adds src or some of its elements to dst : \f[\texttt{dst} (x,y) \leftarrow \texttt{dst} (x,y) + \texttt{src} (x,y) \quad \text{if} \quad \texttt{mask} (x,y) \ne 0\f] 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.

@sa accumulateSquare, accumulateProduct, accumulateWeighted

Python prototype (for reference only):

accumulate(src, dst[, mask]) -> dst
Link to this function

accumulate(src, dst, opts)

View Source
@spec accumulate(
  Evision.Mat.maybe_mat_in(),
  Evision.Mat.maybe_mat_in(),
  [{atom(), term()}, ...] | nil
) ::
  Evision.Mat.t() | {:error, String.t()}

Adds an image to the accumulator image.

Positional Arguments
  • src: Evision.Mat.t().

    Input image of type CV_8UC(n), CV_16UC(n), CV_32FC(n) or CV_64FC(n), where n is a positive integer.

Keyword Arguments
  • mask: Evision.Mat.t().

    Optional operation mask.

Return
  • dst: Evision.Mat.t().

    %Accumulator image with the same number of channels as input image, and a depth of CV_32F or CV_64F.

The function adds src or some of its elements to dst : \f[\texttt{dst} (x,y) \leftarrow \texttt{dst} (x,y) + \texttt{src} (x,y) \quad \text{if} \quad \texttt{mask} (x,y) \ne 0\f] 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.

@sa accumulateSquare, accumulateProduct, accumulateWeighted

Python prototype (for reference only):

accumulate(src, dst[, mask]) -> dst
Link to this function

accumulateProduct(src1, src2, dst)

View Source

Adds the per-element product of two input images to the accumulator image.

Positional Arguments
  • src1: Evision.Mat.t().

    First input image, 1- or 3-channel, 8-bit or 32-bit floating point.

  • src2: Evision.Mat.t().

    Second input image of the same type and the same size as src1 .

Keyword Arguments
  • mask: Evision.Mat.t().

    Optional operation mask.

Return
  • dst: Evision.Mat.t().

    %Accumulator image with the same number of channels as input images, 32-bit or 64-bit floating-point.

The function adds the product of two images or their selected regions to the accumulator dst : \f[\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\f] The function supports multi-channel images. Each channel is processed independently.

@sa accumulate, accumulateSquare, accumulateWeighted

Python prototype (for reference only):

accumulateProduct(src1, src2, dst[, mask]) -> dst
Link to this function

accumulateProduct(src1, src2, dst, opts)

View Source
@spec accumulateProduct(
  Evision.Mat.maybe_mat_in(),
  Evision.Mat.maybe_mat_in(),
  Evision.Mat.maybe_mat_in(),
  [{atom(), term()}, ...] | nil
) :: Evision.Mat.t() | {:error, String.t()}

Adds the per-element product of two input images to the accumulator image.

Positional Arguments
  • src1: Evision.Mat.t().

    First input image, 1- or 3-channel, 8-bit or 32-bit floating point.

  • src2: Evision.Mat.t().

    Second input image of the same type and the same size as src1 .

Keyword Arguments
  • mask: Evision.Mat.t().

    Optional operation mask.

Return
  • dst: Evision.Mat.t().

    %Accumulator image with the same number of channels as input images, 32-bit or 64-bit floating-point.

The function adds the product of two images or their selected regions to the accumulator dst : \f[\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\f] The function supports multi-channel images. Each channel is processed independently.

@sa accumulate, accumulateSquare, accumulateWeighted

Python prototype (for reference only):

accumulateProduct(src1, src2, dst[, mask]) -> dst
Link to this function

accumulateSquare(src, dst)

View Source
@spec accumulateSquare(Evision.Mat.maybe_mat_in(), Evision.Mat.maybe_mat_in()) ::
  Evision.Mat.t() | {:error, String.t()}

Adds the square of a source image to the accumulator image.

Positional Arguments
  • src: Evision.Mat.t().

    Input image as 1- or 3-channel, 8-bit or 32-bit floating point.

Keyword Arguments
  • mask: Evision.Mat.t().

    Optional operation mask.

Return
  • dst: Evision.Mat.t().

    %Accumulator image with the same number of channels as input image, 32-bit or 64-bit floating-point.

The function adds the input image src or its selected region, raised to a power of 2, to the accumulator dst : \f[\texttt{dst} (x,y) \leftarrow \texttt{dst} (x,y) + \texttt{src} (x,y)^2 \quad \text{if} \quad \texttt{mask} (x,y) \ne 0\f] The function supports multi-channel images. Each channel is processed independently.

@sa accumulateSquare, accumulateProduct, accumulateWeighted

Python prototype (for reference only):

accumulateSquare(src, dst[, mask]) -> dst
Link to this function

accumulateSquare(src, dst, opts)

View Source
@spec accumulateSquare(
  Evision.Mat.maybe_mat_in(),
  Evision.Mat.maybe_mat_in(),
  [{atom(), term()}, ...] | nil
) :: Evision.Mat.t() | {:error, String.t()}

Adds the square of a source image to the accumulator image.

Positional Arguments
  • src: Evision.Mat.t().

    Input image as 1- or 3-channel, 8-bit or 32-bit floating point.

Keyword Arguments
  • mask: Evision.Mat.t().

    Optional operation mask.

Return
  • dst: Evision.Mat.t().

    %Accumulator image with the same number of channels as input image, 32-bit or 64-bit floating-point.

The function adds the input image src or its selected region, raised to a power of 2, to the accumulator dst : \f[\texttt{dst} (x,y) \leftarrow \texttt{dst} (x,y) + \texttt{src} (x,y)^2 \quad \text{if} \quad \texttt{mask} (x,y) \ne 0\f] The function supports multi-channel images. Each channel is processed independently.

@sa accumulateSquare, accumulateProduct, accumulateWeighted

Python prototype (for reference only):

accumulateSquare(src, dst[, mask]) -> dst
Link to this function

accumulateWeighted(src, dst, alpha)

View Source
@spec accumulateWeighted(
  Evision.Mat.maybe_mat_in(),
  Evision.Mat.maybe_mat_in(),
  number()
) ::
  Evision.Mat.t() | {:error, String.t()}

Updates a running average.

Positional Arguments
  • src: Evision.Mat.t().

    Input image as 1- or 3-channel, 8-bit or 32-bit floating point.

  • alpha: double.

    Weight of the input image.

Keyword Arguments
  • mask: Evision.Mat.t().

    Optional operation mask.

Return
  • dst: Evision.Mat.t().

    %Accumulator image with the same number of channels as input image, 32-bit or 64-bit floating-point.

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: \f[\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\f] 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.

@sa accumulate, accumulateSquare, accumulateProduct

Python prototype (for reference only):

accumulateWeighted(src, dst, alpha[, mask]) -> dst
Link to this function

accumulateWeighted(src, dst, alpha, opts)

View Source
@spec accumulateWeighted(
  Evision.Mat.maybe_mat_in(),
  Evision.Mat.maybe_mat_in(),
  number(),
  [{atom(), term()}, ...] | nil
) :: Evision.Mat.t() | {:error, String.t()}

Updates a running average.

Positional Arguments
  • src: Evision.Mat.t().

    Input image as 1- or 3-channel, 8-bit or 32-bit floating point.

  • alpha: double.

    Weight of the input image.

Keyword Arguments
  • mask: Evision.Mat.t().

    Optional operation mask.

Return
  • dst: Evision.Mat.t().

    %Accumulator image with the same number of channels as input image, 32-bit or 64-bit floating-point.

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: \f[\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\f] 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.

@sa accumulate, accumulateSquare, accumulateProduct

Python prototype (for reference only):

accumulateWeighted(src, dst, alpha[, mask]) -> dst
Link to this function

adaptiveThreshold(src, maxValue, adaptiveMethod, thresholdType, blockSize, c)

View Source
@spec adaptiveThreshold(
  Evision.Mat.maybe_mat_in(),
  number(),
  integer(),
  integer(),
  integer(),
  number()
) ::
  Evision.Mat.t() | {:error, String.t()}

Applies an adaptive threshold to an array.

Positional Arguments
  • src: Evision.Mat.t().

    Source 8-bit single-channel image.

  • maxValue: double.

    Non-zero value assigned to the pixels for which the condition is satisfied

  • adaptiveMethod: int.

    Adaptive thresholding algorithm to use, see #AdaptiveThresholdTypes. The #BORDER_REPLICATE | #BORDER_ISOLATED is used to process boundaries.

  • thresholdType: int.

    Thresholding type that must be either #THRESH_BINARY or #THRESH_BINARY_INV, see #ThresholdTypes.

  • blockSize: int.

    Size of a pixel neighborhood that is used to calculate a threshold value for the pixel: 3, 5, 7, and so on.

  • c: double.

    Constant subtracted from the mean or weighted mean (see the details below). Normally, it is positive but may be zero or negative as well.

Return
  • dst: Evision.Mat.t().

    Destination image of the same size and the same type as src.

The function transforms a grayscale image to a binary image according to the formulae:

  • THRESH_BINARY \f[dst(x,y) = \fork{\texttt{maxValue}}{if (src(x,y) > T(x,y))}{0}{otherwise}\f]

  • THRESH_BINARY_INV \f[dst(x,y) = \fork{0}{if (src(x,y) > T(x,y))}{\texttt{maxValue}}{otherwise}\f] where \f$T(x,y)\f$ is a threshold calculated individually for each pixel (see adaptiveMethod parameter).

The function can process the image in-place.

@sa threshold, blur, GaussianBlur

Python prototype (for reference only):

adaptiveThreshold(src, maxValue, adaptiveMethod, thresholdType, blockSize, C[, dst]) -> dst
Link to this function

adaptiveThreshold(src, maxValue, adaptiveMethod, thresholdType, blockSize, c, opts)

View Source
@spec adaptiveThreshold(
  Evision.Mat.maybe_mat_in(),
  number(),
  integer(),
  integer(),
  integer(),
  number(),
  [{atom(), term()}, ...] | nil
) :: Evision.Mat.t() | {:error, String.t()}

Applies an adaptive threshold to an array.

Positional Arguments
  • src: Evision.Mat.t().

    Source 8-bit single-channel image.

  • maxValue: double.

    Non-zero value assigned to the pixels for which the condition is satisfied

  • adaptiveMethod: int.

    Adaptive thresholding algorithm to use, see #AdaptiveThresholdTypes. The #BORDER_REPLICATE | #BORDER_ISOLATED is used to process boundaries.

  • thresholdType: int.

    Thresholding type that must be either #THRESH_BINARY or #THRESH_BINARY_INV, see #ThresholdTypes.

  • blockSize: int.

    Size of a pixel neighborhood that is used to calculate a threshold value for the pixel: 3, 5, 7, and so on.

  • c: double.

    Constant subtracted from the mean or weighted mean (see the details below). Normally, it is positive but may be zero or negative as well.

Return
  • dst: Evision.Mat.t().

    Destination image of the same size and the same type as src.

The function transforms a grayscale image to a binary image according to the formulae:

  • THRESH_BINARY \f[dst(x,y) = \fork{\texttt{maxValue}}{if (src(x,y) > T(x,y))}{0}{otherwise}\f]

  • THRESH_BINARY_INV \f[dst(x,y) = \fork{0}{if (src(x,y) > T(x,y))}{\texttt{maxValue}}{otherwise}\f] where \f$T(x,y)\f$ is a threshold calculated individually for each pixel (see adaptiveMethod parameter).

The function can process the image in-place.

@sa threshold, blur, GaussianBlur

Python prototype (for reference only):

adaptiveThreshold(src, maxValue, adaptiveMethod, thresholdType, blockSize, C[, dst]) -> dst

Calculates the per-element sum of two arrays or an array and a scalar.

Positional Arguments
  • src1: Evision.Mat.t().

    first input array or a scalar.

  • src2: Evision.Mat.t().

    second input array or a scalar.

Keyword Arguments
  • mask: Evision.Mat.t().

    optional operation mask - 8-bit single channel array, that specifies elements of the output array to be changed.

  • dtype: int.

    optional depth of the output array (see the discussion below).

Return
  • dst: Evision.Mat.t().

    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.

The function add calculates:

  • Sum of two arrays when both input arrays have the same size and the same number of channels: \f[\texttt{dst}(I) = \texttt{saturate} ( \texttt{src1}(I) + \texttt{src2}(I)) \quad \texttt{if mask}(I) \ne0\f]

  • Sum of an array and a scalar when src2 is constructed from Scalar or has the same number of elements as src1.channels(): \f[\texttt{dst}(I) = \texttt{saturate} ( \texttt{src1}(I) + \texttt{src2} ) \quad \texttt{if mask}(I) \ne0\f]

  • Sum of a scalar and an array when src1 is constructed from Scalar or has the same number of elements as src2.channels(): \f[\texttt{dst}(I) = \texttt{saturate} ( \texttt{src1} + \texttt{src2}(I) ) \quad \texttt{if mask}(I) \ne0\f] 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. @sa subtract, addWeighted, scaleAdd, Mat::convertTo

Python prototype (for reference only):

add(src1, src2[, dst[, mask[, dtype]]]) -> dst
@spec add(
  Evision.Mat.maybe_mat_in(),
  Evision.Mat.maybe_mat_in(),
  [{atom(), term()}, ...] | nil
) ::
  Evision.Mat.t() | {:error, String.t()}

Calculates the per-element sum of two arrays or an array and a scalar.

Positional Arguments
  • src1: Evision.Mat.t().

    first input array or a scalar.

  • src2: Evision.Mat.t().

    second input array or a scalar.

Keyword Arguments
  • mask: Evision.Mat.t().

    optional operation mask - 8-bit single channel array, that specifies elements of the output array to be changed.

  • dtype: int.

    optional depth of the output array (see the discussion below).

Return
  • dst: Evision.Mat.t().

    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.

The function add calculates:

  • Sum of two arrays when both input arrays have the same size and the same number of channels: \f[\texttt{dst}(I) = \texttt{saturate} ( \texttt{src1}(I) + \texttt{src2}(I)) \quad \texttt{if mask}(I) \ne0\f]

  • Sum of an array and a scalar when src2 is constructed from Scalar or has the same number of elements as src1.channels(): \f[\texttt{dst}(I) = \texttt{saturate} ( \texttt{src1}(I) + \texttt{src2} ) \quad \texttt{if mask}(I) \ne0\f]

  • Sum of a scalar and an array when src1 is constructed from Scalar or has the same number of elements as src2.channels(): \f[\texttt{dst}(I) = \texttt{saturate} ( \texttt{src1} + \texttt{src2}(I) ) \quad \texttt{if mask}(I) \ne0\f] 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. @sa subtract, addWeighted, scaleAdd, Mat::convertTo

Python prototype (for reference only):

add(src1, src2[, dst[, mask[, dtype]]]) -> dst
Link to this function

addText(img, text, org, nameFont)

View Source
@spec addText(Evision.Mat.maybe_mat_in(), binary(), {number(), number()}, binary()) ::
  :ok | {:error, String.t()}

Draws a text on the image.

Positional Arguments
  • img: Evision.Mat.t().

    8-bit 3-channel image where the text should be drawn.

  • text: String.

    Text to write on an image.

  • org: Point.

    Point(x,y) where the text should start on an image.

  • nameFont: String.

    Name of the font. The name should match the name of a system font (such as Times*). If the font is not found, a default one is used.

Keyword Arguments
  • pointSize: int.

    Size of the font. If not specified, equal zero or negative, the point size of the font is set to a system-dependent default value. Generally, this is 12 points.

  • color: Scalar.

    Color of the font in BGRA where A = 255 is fully transparent.

  • weight: int.

    Font weight. Available operation flags are : cv::QtFontWeights You can also specify a positive integer for better control.

  • style: int.

    Font style. Available operation flags are : cv::QtFontStyles

  • spacing: int.

    Spacing between characters. It can be negative or positive.

Python prototype (for reference only):

addText(img, text, org, nameFont[, pointSize[, color[, weight[, style[, spacing]]]]]) -> None
Link to this function

addText(img, text, org, nameFont, opts)

View Source
@spec addText(
  Evision.Mat.maybe_mat_in(),
  binary(),
  {number(), number()},
  binary(),
  [{atom(), term()}, ...] | nil
) :: :ok | {:error, String.t()}

Draws a text on the image.

Positional Arguments
  • img: Evision.Mat.t().

    8-bit 3-channel image where the text should be drawn.

  • text: String.

    Text to write on an image.

  • org: Point.

    Point(x,y) where the text should start on an image.

  • nameFont: String.

    Name of the font. The name should match the name of a system font (such as Times*). If the font is not found, a default one is used.

Keyword Arguments
  • pointSize: int.

    Size of the font. If not specified, equal zero or negative, the point size of the font is set to a system-dependent default value. Generally, this is 12 points.

  • color: Scalar.

    Color of the font in BGRA where A = 255 is fully transparent.

  • weight: int.

    Font weight. Available operation flags are : cv::QtFontWeights You can also specify a positive integer for better control.

  • style: int.

    Font style. Available operation flags are : cv::QtFontStyles

  • spacing: int.

    Spacing between characters. It can be negative or positive.

Python prototype (for reference only):

addText(img, text, org, nameFont[, pointSize[, color[, weight[, style[, spacing]]]]]) -> None
Link to this function

addWeighted(src1, alpha, src2, beta, gamma)

View Source
@spec addWeighted(
  Evision.Mat.maybe_mat_in(),
  number(),
  Evision.Mat.maybe_mat_in(),
  number(),
  number()
) ::
  Evision.Mat.t() | {:error, String.t()}

Calculates the weighted sum of two arrays.

Positional Arguments
  • src1: Evision.Mat.t().

    first input array.

  • alpha: double.

    weight of the first array elements.

  • src2: Evision.Mat.t().

    second input array of the same size and channel number as src1.

  • beta: double.

    weight of the second array elements.

  • gamma: double.

    scalar added to each sum.

Keyword Arguments
  • dtype: int.

    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().

Return
  • dst: Evision.Mat.t().

    output array that has the same size and number of channels as the input arrays.

The function addWeighted calculates the weighted sum of two arrays as follows: \f[\texttt{dst} (I)= \texttt{saturate} ( \texttt{src1} (I)* \texttt{alpha} + \texttt{src2} (I)* \texttt{beta} + \texttt{gamma} )\f] 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. @sa add, subtract, scaleAdd, Mat::convertTo

Python prototype (for reference only):

addWeighted(src1, alpha, src2, beta, gamma[, dst[, dtype]]) -> dst
Link to this function

addWeighted(src1, alpha, src2, beta, gamma, opts)

View Source
@spec addWeighted(
  Evision.Mat.maybe_mat_in(),
  number(),
  Evision.Mat.maybe_mat_in(),
  number(),
  number(),
  [{atom(), term()}, ...] | nil
) :: Evision.Mat.t() | {:error, String.t()}

Calculates the weighted sum of two arrays.

Positional Arguments
  • src1: Evision.Mat.t().

    first input array.

  • alpha: double.

    weight of the first array elements.

  • src2: Evision.Mat.t().

    second input array of the same size and channel number as src1.

  • beta: double.

    weight of the second array elements.

  • gamma: double.

    scalar added to each sum.

Keyword Arguments
  • dtype: int.

    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().

Return
  • dst: Evision.Mat.t().

    output array that has the same size and number of channels as the input arrays.

The function addWeighted calculates the weighted sum of two arrays as follows: \f[\texttt{dst} (I)= \texttt{saturate} ( \texttt{src1} (I)* \texttt{alpha} + \texttt{src2} (I)* \texttt{beta} + \texttt{gamma} )\f] 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. @sa add, subtract, scaleAdd, Mat::convertTo

Python prototype (for reference only):

addWeighted(src1, alpha, src2, beta, gamma[, dst[, dtype]]) -> dst
Link to this function

applyColorMap(src, userColor)

View Source
@spec applyColorMap(Evision.Mat.maybe_mat_in(), Evision.Mat.maybe_mat_in()) ::
  Evision.Mat.t() | {:error, String.t()}
@spec applyColorMap(Evision.Mat.maybe_mat_in(), integer()) ::
  Evision.Mat.t() | {:error, String.t()}

Variant 1:

Applies a user colormap on a given image.

Positional Arguments
  • src: Evision.Mat.t().

    The source image, grayscale or colored of type CV_8UC1 or CV_8UC3.

  • userColor: Evision.Mat.t().

    The colormap to apply of type CV_8UC1 or CV_8UC3 and size 256

Return
  • dst: Evision.Mat.t().

    The result is the colormapped source image. Note: Mat::create is called on dst.

Python prototype (for reference only):

applyColorMap(src, userColor[, dst]) -> dst

Variant 2:

Applies a GNU Octave/MATLAB equivalent colormap on a given image.

Positional Arguments
  • src: Evision.Mat.t().

    The source image, grayscale or colored of type CV_8UC1 or CV_8UC3.

  • colormap: int.

    The colormap to apply, see #ColormapTypes

Return
  • dst: Evision.Mat.t().

    The result is the colormapped source image. Note: Mat::create is called on dst.

Python prototype (for reference only):

applyColorMap(src, colormap[, dst]) -> dst
Link to this function

applyColorMap(src, userColor, opts)

View Source
@spec applyColorMap(
  Evision.Mat.maybe_mat_in(),
  Evision.Mat.maybe_mat_in(),
  [{atom(), term()}, ...] | nil
) :: Evision.Mat.t() | {:error, String.t()}
@spec applyColorMap(
  Evision.Mat.maybe_mat_in(),
  integer(),
  [{atom(), term()}, ...] | nil
) ::
  Evision.Mat.t() | {:error, String.t()}

Variant 1:

Applies a user colormap on a given image.

Positional Arguments
  • src: Evision.Mat.t().

    The source image, grayscale or colored of type CV_8UC1 or CV_8UC3.

  • userColor: Evision.Mat.t().

    The colormap to apply of type CV_8UC1 or CV_8UC3 and size 256

Return
  • dst: Evision.Mat.t().

    The result is the colormapped source image. Note: Mat::create is called on dst.

Python prototype (for reference only):

applyColorMap(src, userColor[, dst]) -> dst

Variant 2:

Applies a GNU Octave/MATLAB equivalent colormap on a given image.

Positional Arguments
  • src: Evision.Mat.t().

    The source image, grayscale or colored of type CV_8UC1 or CV_8UC3.

  • colormap: int.

    The colormap to apply, see #ColormapTypes

Return
  • dst: Evision.Mat.t().

    The result is the colormapped source image. Note: Mat::create is called on dst.

Python prototype (for reference only):

applyColorMap(src, colormap[, dst]) -> dst
Link to this function

approxPolyDP(curve, epsilon, closed)

View Source
@spec approxPolyDP(Evision.Mat.maybe_mat_in(), number(), boolean()) ::
  Evision.Mat.t() | {:error, String.t()}

Approximates a polygonal curve(s) with the specified precision.

Positional Arguments
  • curve: Evision.Mat.t().

    Input vector of a 2D point stored in std::vector or Mat

  • epsilon: double.

    Parameter specifying the approximation accuracy. This is the maximum distance between the original curve and its approximation.

  • closed: bool.

    If true, the approximated curve is closed (its first and last vertices are connected). Otherwise, it is not closed.

Return
  • approxCurve: Evision.Mat.t().

    Result of the approximation. The type should match the type of the input curve.

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

Python prototype (for reference only):

approxPolyDP(curve, epsilon, closed[, approxCurve]) -> approxCurve
Link to this function

approxPolyDP(curve, epsilon, closed, opts)

View Source
@spec approxPolyDP(
  Evision.Mat.maybe_mat_in(),
  number(),
  boolean(),
  [{atom(), term()}, ...] | nil
) ::
  Evision.Mat.t() | {:error, String.t()}

Approximates a polygonal curve(s) with the specified precision.

Positional Arguments
  • curve: Evision.Mat.t().

    Input vector of a 2D point stored in std::vector or Mat

  • epsilon: double.

    Parameter specifying the approximation accuracy. This is the maximum distance between the original curve and its approximation.

  • closed: bool.

    If true, the approximated curve is closed (its first and last vertices are connected). Otherwise, it is not closed.

Return
  • approxCurve: Evision.Mat.t().

    Result of the approximation. The type should match the type of the input curve.

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

Python prototype (for reference only):

approxPolyDP(curve, epsilon, closed[, approxCurve]) -> approxCurve
Link to this function

arcLength(curve, closed)

View Source
@spec arcLength(Evision.Mat.maybe_mat_in(), boolean()) ::
  number() | {:error, String.t()}

Calculates a contour perimeter or a curve length.

Positional Arguments
  • curve: Evision.Mat.t().

    Input vector of 2D points, stored in std::vector or Mat.

  • closed: bool.

    Flag indicating whether the curve is closed or not.

Return
  • retval: double

The function computes a curve length or a closed contour perimeter.

Python prototype (for reference only):

arcLength(curve, closed) -> retval
Link to this function

arrowedLine(img, pt1, pt2, color)

View Source
@spec arrowedLine(
  Evision.Mat.maybe_mat_in(),
  {number(), number()},
  {number(), number()},
  {number()}
  | {number(), number()}
  | {number(), number(), number()}
  | {number(), number(), number(), number()}
) :: Evision.Mat.t() | {:error, String.t()}

Draws an arrow segment pointing from the first point to the second one.

Positional Arguments
  • pt1: Point.

    The point the arrow starts from.

  • pt2: Point.

    The point the arrow points to.

  • color: Scalar.

    Line color.

Keyword Arguments
  • thickness: int.

    Line thickness.

  • line_type: int.

    Type of the line. See #LineTypes

  • shift: int.

    Number of fractional bits in the point coordinates.

  • tipLength: double.

    The length of the arrow tip in relation to the arrow length

Return
  • img: Evision.Mat.t().

    Image.

The function cv::arrowedLine draws an arrow between pt1 and pt2 points in the image. See also #line.

Python prototype (for reference only):

arrowedLine(img, pt1, pt2, color[, thickness[, line_type[, shift[, tipLength]]]]) -> img
Link to this function

arrowedLine(img, pt1, pt2, color, opts)

View Source
@spec arrowedLine(
  Evision.Mat.maybe_mat_in(),
  {number(), number()},
  {number(), number()},
  {number()}
  | {number(), number()}
  | {number(), number(), number()}
  | {number(), number(), number(), number()},
  [{atom(), term()}, ...] | nil
) :: Evision.Mat.t() | {:error, String.t()}

Draws an arrow segment pointing from the first point to the second one.

Positional Arguments
  • pt1: Point.

    The point the arrow starts from.

  • pt2: Point.

    The point the arrow points to.

  • color: Scalar.

    Line color.

Keyword Arguments
  • thickness: int.

    Line thickness.

  • line_type: int.

    Type of the line. See #LineTypes

  • shift: int.

    Number of fractional bits in the point coordinates.

  • tipLength: double.

    The length of the arrow tip in relation to the arrow length

Return
  • img: Evision.Mat.t().

    Image.

The function cv::arrowedLine draws an arrow between pt1 and pt2 points in the image. See also #line.

Python prototype (for reference only):

arrowedLine(img, pt1, pt2, color[, thickness[, line_type[, shift[, tipLength]]]]) -> img
Link to this function

batchDistance(src1, src2, dtype)

View Source
@spec batchDistance(Evision.Mat.maybe_mat_in(), Evision.Mat.maybe_mat_in(), integer()) ::
  {Evision.Mat.t(), Evision.Mat.t()} | {:error, String.t()}

naive nearest neighbor finder

Positional Arguments
  • src1: Evision.Mat.t()
  • src2: Evision.Mat.t()
  • dtype: int
Keyword Arguments
  • normType: int.
  • k: int.
  • mask: Evision.Mat.t().
  • update: int.
  • crosscheck: bool.
Return
  • dist: Evision.Mat.t().
  • nidx: Evision.Mat.t().

see http://en.wikipedia.org/wiki/Nearest_neighbor_search @todo document

Python prototype (for reference only):

batchDistance(src1, src2, dtype[, dist[, nidx[, normType[, K[, mask[, update[, crosscheck]]]]]]]) -> dist, nidx
Link to this function

batchDistance(src1, src2, dtype, opts)

View Source
@spec batchDistance(
  Evision.Mat.maybe_mat_in(),
  Evision.Mat.maybe_mat_in(),
  integer(),
  [{atom(), term()}, ...] | nil
) :: {Evision.Mat.t(), Evision.Mat.t()} | {:error, String.t()}

naive nearest neighbor finder

Positional Arguments
  • src1: Evision.Mat.t()
  • src2: Evision.Mat.t()
  • dtype: int
Keyword Arguments
  • normType: int.
  • k: int.
  • mask: Evision.Mat.t().
  • update: int.
  • crosscheck: bool.
Return
  • dist: Evision.Mat.t().
  • nidx: Evision.Mat.t().

see http://en.wikipedia.org/wiki/Nearest_neighbor_search @todo document

Python prototype (for reference only):

batchDistance(src1, src2, dtype[, dist[, nidx[, normType[, K[, mask[, update[, crosscheck]]]]]]]) -> dist, nidx
Link to this function

bilateralFilter(src, d, sigmaColor, sigmaSpace)

View Source
@spec bilateralFilter(Evision.Mat.maybe_mat_in(), integer(), number(), number()) ::
  Evision.Mat.t() | {:error, String.t()}

Applies the bilateral filter to an image.

Positional Arguments
  • src: Evision.Mat.t().

    Source 8-bit or floating-point, 1-channel or 3-channel image.

  • d: int.

    Diameter of each pixel neighborhood that is used during filtering. If it is non-positive, it is computed from sigmaSpace.

  • sigmaColor: double.

    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: double.

    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.

Keyword Arguments
  • borderType: int.

    border mode used to extrapolate pixels outside of the image, see #BorderTypes

Return
  • dst: Evision.Mat.t().

    Destination image of the same size and type as src .

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.

Python prototype (for reference only):

bilateralFilter(src, d, sigmaColor, sigmaSpace[, dst[, borderType]]) -> dst
Link to this function

bilateralFilter(src, d, sigmaColor, sigmaSpace, opts)

View Source
@spec bilateralFilter(
  Evision.Mat.maybe_mat_in(),
  integer(),
  number(),
  number(),
  [{atom(), term()}, ...] | nil
) :: Evision.Mat.t() | {:error, String.t()}

Applies the bilateral filter to an image.

Positional Arguments
  • src: Evision.Mat.t().

    Source 8-bit or floating-point, 1-channel or 3-channel image.

  • d: int.

    Diameter of each pixel neighborhood that is used during filtering. If it is non-positive, it is computed from sigmaSpace.

  • sigmaColor: double.

    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: double.

    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.

Keyword Arguments
  • borderType: int.

    border mode used to extrapolate pixels outside of the image, see #BorderTypes

Return
  • dst: Evision.Mat.t().

    Destination image of the same size and type as src .

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.

Python prototype (for reference only):

bilateralFilter(src, d, sigmaColor, sigmaSpace[, dst[, borderType]]) -> dst
Link to this function

blendLinear(src1, src2, weights1, weights2)

View Source

blendLinear

Positional Arguments
  • src1: Evision.Mat.t()
  • src2: Evision.Mat.t()
  • weights1: Evision.Mat.t()
  • weights2: Evision.Mat.t()
Return
  • dst: Evision.Mat.t().

Has overloading in C++

variant without mask parameter

Python prototype (for reference only):

blendLinear(src1, src2, weights1, weights2[, dst]) -> dst
Link to this function

blendLinear(src1, src2, weights1, weights2, opts)

View Source

blendLinear

Positional Arguments
  • src1: Evision.Mat.t()
  • src2: Evision.Mat.t()
  • weights1: Evision.Mat.t()
  • weights2: Evision.Mat.t()
Return
  • dst: Evision.Mat.t().

Has overloading in C++

variant without mask parameter

Python prototype (for reference only):

blendLinear(src1, src2, weights1, weights2[, dst]) -> dst
@spec blur(
  Evision.Mat.maybe_mat_in(),
  {number(), number()}
) :: Evision.Mat.t() | {:error, String.t()}

Blurs an image using the normalized box filter.

Positional Arguments
  • src: Evision.Mat.t().

    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.

  • ksize: Size.

    blurring kernel size.

Keyword Arguments
  • anchor: Point.

    anchor point; default value Point(-1,-1) means that the anchor is at the kernel center.

  • borderType: int.

    border mode used to extrapolate pixels outside of the image, see #BorderTypes. #BORDER_WRAP is not supported.

Return
  • dst: Evision.Mat.t().

    output image of the same size and type as src.

The function smooths an image using the kernel: \f[\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}\f] The call blur(src, dst, ksize, anchor, borderType) is equivalent to boxFilter(src, dst, src.type(), ksize, anchor, true, borderType). @sa boxFilter, bilateralFilter, GaussianBlur, medianBlur

Python prototype (for reference only):

blur(src, ksize[, dst[, anchor[, borderType]]]) -> dst
@spec blur(
  Evision.Mat.maybe_mat_in(),
  {number(), number()},
  [{atom(), term()}, ...] | nil
) ::
  Evision.Mat.t() | {:error, String.t()}

Blurs an image using the normalized box filter.

Positional Arguments
  • src: Evision.Mat.t().

    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.

  • ksize: Size.

    blurring kernel size.

Keyword Arguments
  • anchor: Point.

    anchor point; default value Point(-1,-1) means that the anchor is at the kernel center.

  • borderType: int.

    border mode used to extrapolate pixels outside of the image, see #BorderTypes. #BORDER_WRAP is not supported.

Return
  • dst: Evision.Mat.t().

    output image of the same size and type as src.

The function smooths an image using the kernel: \f[\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}\f] The call blur(src, dst, ksize, anchor, borderType) is equivalent to boxFilter(src, dst, src.type(), ksize, anchor, true, borderType). @sa boxFilter, bilateralFilter, GaussianBlur, medianBlur

Python prototype (for reference only):

blur(src, ksize[, dst[, anchor[, borderType]]]) -> dst
Link to this function

borderInterpolate(p, len, borderType)

View Source
@spec borderInterpolate(integer(), integer(), integer()) ::
  integer() | {:error, String.t()}

Computes the source location of an extrapolated pixel.

Positional Arguments
  • p: int.

    0-based coordinate of the extrapolated pixel along one of the axes, likely \<0 or >= len

  • len: int.

    Length of the array along the corresponding axis.

  • borderType: int.

    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.

Return
  • retval: int

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.

@sa copyMakeBorder

Python prototype (for reference only):

borderInterpolate(p, len, borderType) -> retval
@spec boundingRect(Evision.Mat.maybe_mat_in()) ::
  {number(), number(), number(), number()} | {:error, String.t()}

Calculates the up-right bounding rectangle of a point set or non-zero pixels of gray-scale image.

Positional Arguments
  • array: Evision.Mat.t().

    Input gray-scale image or 2D point set, stored in std::vector or Mat.

Return
  • retval: Rect

The function calculates and returns the minimal up-right bounding rectangle for the specified point set or non-zero pixels of gray-scale image.

Python prototype (for reference only):

boundingRect(array) -> retval
Link to this function

boxFilter(src, ddepth, ksize)

View Source
@spec boxFilter(Evision.Mat.maybe_mat_in(), integer(), {number(), number()}) ::
  Evision.Mat.t() | {:error, String.t()}

Blurs an image using the box filter.

Positional Arguments
  • src: Evision.Mat.t().

    input image.

  • ddepth: int.

    the output image depth (-1 to use src.depth()).

  • ksize: Size.

    blurring kernel size.

Keyword Arguments
  • anchor: Point.

    anchor point; default value Point(-1,-1) means that the anchor is at the kernel center.

  • normalize: bool.

    flag, specifying whether the kernel is normalized by its area or not.

  • borderType: int.

    border mode used to extrapolate pixels outside of the image, see #BorderTypes. #BORDER_WRAP is not supported.

Return
  • dst: Evision.Mat.t().

    output image of the same size and type as src.

The function smooths an image using the kernel: \f[\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}\f] where \f[\alpha = \begin{cases} \frac{1}{\texttt{ksize.width*ksize.height}} & \texttt{when } \texttt{normalize=true} \\1 & \texttt{otherwise}\end{cases}\f] 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. @sa blur, bilateralFilter, GaussianBlur, medianBlur, integral

Python prototype (for reference only):

boxFilter(src, ddepth, ksize[, dst[, anchor[, normalize[, borderType]]]]) -> dst
Link to this function

boxFilter(src, ddepth, ksize, opts)

View Source
@spec boxFilter(
  Evision.Mat.maybe_mat_in(),
  integer(),
  {number(), number()},
  [{atom(), term()}, ...] | nil
) :: Evision.Mat.t() | {:error, String.t()}

Blurs an image using the box filter.

Positional Arguments
  • src: Evision.Mat.t().

    input image.

  • ddepth: int.

    the output image depth (-1 to use src.depth()).

  • ksize: Size.

    blurring kernel size.

Keyword Arguments
  • anchor: Point.

    anchor point; default value Point(-1,-1) means that the anchor is at the kernel center.

  • normalize: bool.

    flag, specifying whether the kernel is normalized by its area or not.

  • borderType: int.

    border mode used to extrapolate pixels outside of the image, see #BorderTypes. #BORDER_WRAP is not supported.

Return
  • dst: Evision.Mat.t().

    output image of the same size and type as src.

The function smooths an image using the kernel: \f[\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}\f] where \f[\alpha = \begin{cases} \frac{1}{\texttt{ksize.width*ksize.height}} & \texttt{when } \texttt{normalize=true} \\1 & \texttt{otherwise}\end{cases}\f] 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. @sa blur, bilateralFilter, GaussianBlur, medianBlur, integral

Python prototype (for reference only):

boxFilter(src, ddepth, ksize[, dst[, anchor[, normalize[, borderType]]]]) -> dst
@spec boxPoints({{number(), number()}, {number(), number()}, number()}) ::
  Evision.Mat.t() | {:error, String.t()}

Finds the four vertices of a rotated rect. Useful to draw the rotated rectangle.

Positional Arguments
  • box: {centre={x, y}, size={s1, s2}, angle}.

    The input rotated rectangle. It may be the output of

Return
  • points: Evision.Mat.t().

    The output array of four vertices of rectangles.

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.

Python prototype (for reference only):

boxPoints(box[, points]) -> points
@spec boxPoints(
  {{number(), number()}, {number(), number()}, number()},
  [{atom(), term()}, ...] | nil
) ::
  Evision.Mat.t() | {:error, String.t()}

Finds the four vertices of a rotated rect. Useful to draw the rotated rectangle.

Positional Arguments
  • box: {centre={x, y}, size={s1, s2}, angle}.

    The input rotated rectangle. It may be the output of

Return
  • points: Evision.Mat.t().

    The output array of four vertices of rectangles.

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.

Python prototype (for reference only):

boxPoints(box[, points]) -> points
Link to this function

buildOpticalFlowPyramid(img, winSize, maxLevel)

View Source
@spec buildOpticalFlowPyramid(
  Evision.Mat.maybe_mat_in(),
  {number(), number()},
  integer()
) ::
  {integer(), [Evision.Mat.t()]} | {:error, String.t()}

Constructs the image pyramid which can be passed to calcOpticalFlowPyrLK.

Positional Arguments
  • img: Evision.Mat.t().

    8-bit input image.

  • winSize: Size.

    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: int.

    0-based maximal pyramid level number.

Keyword Arguments
  • withDerivatives: bool.

    set to precompute gradients for the every pyramid level. If pyramid is constructed without the gradients then calcOpticalFlowPyrLK will calculate them internally.

  • pyrBorder: int.

    the border mode for pyramid layers.

  • derivBorder: int.

    the border mode for gradients.

  • tryReuseInputImage: bool.

    put ROI of input image into the pyramid if possible. You can pass false to force data copying.

Return
  • retval: int

  • pyramid: [Evision.Mat].

    output pyramid.

@return number of levels in constructed pyramid. Can be less than maxLevel.

Python prototype (for reference only):

buildOpticalFlowPyramid(img, winSize, maxLevel[, pyramid[, withDerivatives[, pyrBorder[, derivBorder[, tryReuseInputImage]]]]]) -> retval, pyramid
Link to this function

buildOpticalFlowPyramid(img, winSize, maxLevel, opts)

View Source
@spec buildOpticalFlowPyramid(
  Evision.Mat.maybe_mat_in(),
  {number(), number()},
  integer(),
  [{atom(), term()}, ...] | nil
) :: {integer(), [Evision.Mat.t()]} | {:error, String.t()}

Constructs the image pyramid which can be passed to calcOpticalFlowPyrLK.

Positional Arguments
  • img: Evision.Mat.t().

    8-bit input image.

  • winSize: Size.

    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: int.

    0-based maximal pyramid level number.

Keyword Arguments
  • withDerivatives: bool.

    set to precompute gradients for the every pyramid level. If pyramid is constructed without the gradients then calcOpticalFlowPyrLK will calculate them internally.

  • pyrBorder: int.

    the border mode for pyramid layers.

  • derivBorder: int.

    the border mode for gradients.

  • tryReuseInputImage: bool.

    put ROI of input image into the pyramid if possible. You can pass false to force data copying.

Return
  • retval: int

  • pyramid: [Evision.Mat].

    output pyramid.

@return number of levels in constructed pyramid. Can be less than maxLevel.

Python prototype (for reference only):

buildOpticalFlowPyramid(img, winSize, maxLevel[, pyramid[, withDerivatives[, pyrBorder[, derivBorder[, tryReuseInputImage]]]]]) -> retval, pyramid
Link to this function

calcBackProject(images, channels, hist, ranges, scale)

View Source
@spec calcBackProject(
  [Evision.Mat.maybe_mat_in()],
  [integer()],
  Evision.Mat.maybe_mat_in(),
  [number()],
  number()
) :: Evision.Mat.t() | {:error, String.t()}

calcBackProject

Positional Arguments
  • images: [Evision.Mat]
  • channels: [int]
  • hist: Evision.Mat.t()
  • ranges: [float]
  • scale: double
Return
  • dst: Evision.Mat.t().

Has overloading in C++

Python prototype (for reference only):

calcBackProject(images, channels, hist, ranges, scale[, dst]) -> dst
Link to this function

calcBackProject(images, channels, hist, ranges, scale, opts)

View Source
@spec calcBackProject(
  [Evision.Mat.maybe_mat_in()],
  [integer()],
  Evision.Mat.maybe_mat_in(),
  [number()],
  number(),
  [{atom(), term()}, ...] | nil
) :: Evision.Mat.t() | {:error, String.t()}

calcBackProject

Positional Arguments
  • images: [Evision.Mat]
  • channels: [int]
  • hist: Evision.Mat.t()
  • ranges: [float]
  • scale: double
Return
  • dst: Evision.Mat.t().

Has overloading in C++

Python prototype (for reference only):

calcBackProject(images, channels, hist, ranges, scale[, dst]) -> dst
Link to this function

calcCovarMatrix(samples, mean, flags)

View Source
@spec calcCovarMatrix(
  Evision.Mat.maybe_mat_in(),
  Evision.Mat.maybe_mat_in(),
  integer()
) ::
  {Evision.Mat.t(), Evision.Mat.t()} | {:error, String.t()}

calcCovarMatrix

Positional Arguments
  • samples: Evision.Mat.t().

    samples stored as rows/columns of a single matrix.

  • flags: int.

    operation flags as a combination of #CovarFlags

Keyword Arguments
  • ctype: int.

    type of the matrixl; it equals 'CV_64F' by default.

Return
  • covar: Evision.Mat.t().

    output covariance matrix of the type ctype and square size.

  • mean: Evision.Mat.t().

    input or output (depending on the flags) array as the average value of the input vectors.

Has overloading in C++

Note: use #COVAR_ROWS or #COVAR_COLS flag

Python prototype (for reference only):

calcCovarMatrix(samples, mean, flags[, covar[, ctype]]) -> covar, mean
Link to this function

calcCovarMatrix(samples, mean, flags, opts)

View Source
@spec calcCovarMatrix(
  Evision.Mat.maybe_mat_in(),
  Evision.Mat.maybe_mat_in(),
  integer(),
  [{atom(), term()}, ...] | nil
) :: {Evision.Mat.t(), Evision.Mat.t()} | {:error, String.t()}

calcCovarMatrix

Positional Arguments
  • samples: Evision.Mat.t().

    samples stored as rows/columns of a single matrix.

  • flags: int.

    operation flags as a combination of #CovarFlags

Keyword Arguments
  • ctype: int.

    type of the matrixl; it equals 'CV_64F' by default.

Return
  • covar: Evision.Mat.t().

    output covariance matrix of the type ctype and square size.

  • mean: Evision.Mat.t().

    input or output (depending on the flags) array as the average value of the input vectors.

Has overloading in C++

Note: use #COVAR_ROWS or #COVAR_COLS flag

Python prototype (for reference only):

calcCovarMatrix(samples, mean, flags[, covar[, ctype]]) -> covar, mean
Link to this function

calcHist(images, channels, mask, histSize, ranges)

View Source
@spec calcHist(
  [Evision.Mat.maybe_mat_in()],
  [integer()],
  Evision.Mat.maybe_mat_in(),
  [integer()],
  [
    number()
  ]
) :: Evision.Mat.t() | {:error, String.t()}

calcHist

Positional Arguments
  • images: [Evision.Mat]
  • channels: [int]
  • mask: Evision.Mat.t()
  • histSize: [int]
  • ranges: [float]
Keyword Arguments
  • accumulate: bool.
Return
  • hist: Evision.Mat.t().

Has overloading in C++

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.

Python prototype (for reference only):

calcHist(images, channels, mask, histSize, ranges[, hist[, accumulate]]) -> hist
Link to this function

calcHist(images, channels, mask, histSize, ranges, opts)

View Source
@spec calcHist(
  [Evision.Mat.maybe_mat_in()],
  [integer()],
  Evision.Mat.maybe_mat_in(),
  [integer()],
  [number()],
  [{atom(), term()}, ...] | nil
) :: Evision.Mat.t() | {:error, String.t()}

calcHist

Positional Arguments
  • images: [Evision.Mat]
  • channels: [int]
  • mask: Evision.Mat.t()
  • histSize: [int]
  • ranges: [float]
Keyword Arguments
  • accumulate: bool.
Return
  • hist: Evision.Mat.t().

Has overloading in C++

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.

Python prototype (for reference only):

calcHist(images, channels, mask, histSize, ranges[, hist[, accumulate]]) -> hist
Link to this function

calcOpticalFlowFarneback(prev, next, flow, pyr_scale, levels, winsize, iterations, poly_n, poly_sigma, flags)

View Source
@spec calcOpticalFlowFarneback(
  Evision.Mat.maybe_mat_in(),
  Evision.Mat.maybe_mat_in(),
  Evision.Mat.maybe_mat_in(),
  number(),
  integer(),
  integer(),
  integer(),
  integer(),
  number(),
  integer()
) :: Evision.Mat.t() | {:error, String.t()}

Computes a dense optical flow using the Gunnar Farneback's algorithm.

Positional Arguments
  • prev: Evision.Mat.t().

    first 8-bit single-channel input image.

  • next: Evision.Mat.t().

    second input image of the same size and the same type as prev.

  • pyr_scale: double.

    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: int.

    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: int.

    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: int.

    number of iterations the algorithm does at each pyramid level.

  • poly_n: int.

    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: double.

    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: int.

    operation flags that can be a combination of the following:

    • OPTFLOW_USE_INITIAL_FLOW uses the input flow as an initial flow approximation.
    • OPTFLOW_FARNEBACK_GAUSSIAN uses the Gaussian \f$\texttt{winsize}\times\texttt{winsize}\f$ filter instead of a box filter of the same size for optical flow estimation; usually, this option gives z more accurate flow than with a box filter, at the cost of lower speed; normally, winsize for a Gaussian window should be set to a larger value to achieve the same level of robustness.
Return
  • flow: Evision.Mat.t().

    computed flow image that has the same size as prev and type CV_32FC2.

The function finds an optical flow for each prev pixel using the @cite Farneback2003 algorithm so that \f[\texttt{prev} (y,x) \sim \texttt{next} ( y + \texttt{flow} (y,x)[1], x + \texttt{flow} (y,x)[0])\f] Note:

  • An example using the optical flow algorithm described by Gunnar Farneback can be found at opencv_source_code/samples/cpp/fback.cpp

  • (Python) An example using the optical flow algorithm described by Gunnar Farneback can be found at opencv_source_code/samples/python/opt_flow.py

Python prototype (for reference only):

calcOpticalFlowFarneback(prev, next, flow, pyr_scale, levels, winsize, iterations, poly_n, poly_sigma, flags) -> flow
Link to this function

calcOpticalFlowPyrLK(prevImg, nextImg, prevPts, nextPts)

View Source

Calculates an optical flow for a sparse feature set using the iterative Lucas-Kanade method with pyramids.

Positional Arguments
  • prevImg: Evision.Mat.t().

    first 8-bit input image or pyramid constructed by buildOpticalFlowPyramid.

  • nextImg: Evision.Mat.t().

    second input image or pyramid of the same size and the same type as prevImg.

  • prevPts: Evision.Mat.t().

    vector of 2D points for which the flow needs to be found; point coordinates must be single-precision floating-point numbers.

Keyword Arguments
  • winSize: Size.

    size of the search window at each pyramid level.

  • maxLevel: int.

    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: TermCriteria.

    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: int.

    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: double.

    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.

Return
  • nextPts: Evision.Mat.t().

    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: Evision.Mat.t().

    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: Evision.Mat.t().

    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).

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

Python prototype (for reference only):

calcOpticalFlowPyrLK(prevImg, nextImg, prevPts, nextPts[, status[, err[, winSize[, maxLevel[, criteria[, flags[, minEigThreshold]]]]]]]) -> nextPts, status, err
Link to this function

calcOpticalFlowPyrLK(prevImg, nextImg, prevPts, nextPts, opts)

View Source

Calculates an optical flow for a sparse feature set using the iterative Lucas-Kanade method with pyramids.

Positional Arguments
  • prevImg: Evision.Mat.t().

    first 8-bit input image or pyramid constructed by buildOpticalFlowPyramid.

  • nextImg: Evision.Mat.t().

    second input image or pyramid of the same size and the same type as prevImg.

  • prevPts: Evision.Mat.t().

    vector of 2D points for which the flow needs to be found; point coordinates must be single-precision floating-point numbers.

Keyword Arguments
  • winSize: Size.

    size of the search window at each pyramid level.

  • maxLevel: int.

    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: TermCriteria.

    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: int.

    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: double.

    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.

Return
  • nextPts: Evision.Mat.t().

    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: Evision.Mat.t().

    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: Evision.Mat.t().

    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).

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

Python prototype (for reference only):

calcOpticalFlowPyrLK(prevImg, nextImg, prevPts, nextPts[, status[, err[, winSize[, maxLevel[, criteria[, flags[, minEigThreshold]]]]]]]) -> nextPts, status, err
Link to this function

calibrateCamera(objectPoints, imagePoints, imageSize, cameraMatrix, distCoeffs)

View Source

calibrateCamera

Positional Arguments
  • objectPoints: [Evision.Mat]
  • imagePoints: [Evision.Mat]
  • imageSize: Size
Keyword Arguments
  • flags: int.
  • criteria: TermCriteria.
Return
  • retval: double
  • cameraMatrix: Evision.Mat.t()
  • distCoeffs: Evision.Mat.t()
  • rvecs: [Evision.Mat].
  • tvecs: [Evision.Mat].

Has overloading in C++

Python prototype (for reference only):

calibrateCamera(objectPoints, imagePoints, imageSize, cameraMatrix, distCoeffs[, rvecs[, tvecs[, flags[, criteria]]]]) -> retval, cameraMatrix, distCoeffs, rvecs, tvecs
Link to this function

calibrateCamera(objectPoints, imagePoints, imageSize, cameraMatrix, distCoeffs, opts)

View Source

calibrateCamera

Positional Arguments
  • objectPoints: [Evision.Mat]
  • imagePoints: [Evision.Mat]
  • imageSize: Size
Keyword Arguments
  • flags: int.
  • criteria: TermCriteria.
Return
  • retval: double
  • cameraMatrix: Evision.Mat.t()
  • distCoeffs: Evision.Mat.t()
  • rvecs: [Evision.Mat].
  • tvecs: [Evision.Mat].

Has overloading in C++

Python prototype (for reference only):

calibrateCamera(objectPoints, imagePoints, imageSize, cameraMatrix, distCoeffs[, rvecs[, tvecs[, flags[, criteria]]]]) -> retval, cameraMatrix, distCoeffs, rvecs, tvecs
Link to this function

calibrateCameraExtended(objectPoints, imagePoints, imageSize, cameraMatrix, distCoeffs)

View Source

Finds the camera intrinsic and extrinsic parameters from several views of a calibration pattern.

Positional Arguments
  • objectPoints: [Evision.Mat].

    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: [Evision.Mat].

    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.

    Size of the image used only to initialize the camera intrinsic matrix.

Keyword Arguments
  • flags: int.

    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
  • criteria: TermCriteria.

    Termination criteria for the iterative optimization algorithm.

Return
  • retval: double

  • cameraMatrix: Evision.Mat.t().

    Input/output 3x3 floating-point camera intrinsic matrix \f$\cameramatrix{A}\f$ . If @ref CALIB_USE_INTRINSIC_GUESS and/or @ref CALIB_FIX_ASPECT_RATIO, @ref CALIB_FIX_PRINCIPAL_POINT or @ref CALIB_FIX_FOCAL_LENGTH are specified, some or all of fx, fy, cx, cy must be initialized before calling the function.

  • distCoeffs: Evision.Mat.t().

    Input/output vector of distortion coefficients \f$\distcoeffs\f$.

  • rvecs: [Evision.Mat].

    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: [Evision.Mat].

    Output vector of translation vectors estimated for each pattern view, see parameter describtion above.

  • stdDeviationsIntrinsics: Evision.Mat.t().

    Output vector of standard deviations estimated for intrinsic parameters. Order of deviations values: \f$(f_x, f_y, c_x, c_y, k_1, k_2, p_1, p_2, k_3, k_4, k_5, k_6 , s_1, s_2, s_3, s_4, \tau_x, \tau_y)\f$ If one of parameters is not estimated, it's deviation is equals to zero.

  • stdDeviationsExtrinsics: Evision.Mat.t().

    Output vector of standard deviations estimated for extrinsic parameters. Order of deviations values: \f$(R0, T_0, \dotsc , R{M - 1}, T_{M - 1})\f$ where M is the number of pattern views. \f$R_i, T_i\f$ are concatenated 1x3 vectors.

  • perViewErrors: Evision.Mat.t().

    Output vector of the RMS re-projection error estimated for each pattern view.

@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 \f$(p_1, p_2)\f$ are set to zeros and stay zero.

  • @ref CALIB_FIX_FOCAL_LENGTH The focal length is not changed during the global optimization if @ref CALIB_USE_INTRINSIC_GUESS is set.

  • @ref CALIB_FIX_K1,..., @ref CALIB_FIX_K6 The corresponding radial distortion coefficient is not changed during the optimization. If @ref CALIB_USE_INTRINSIC_GUESS is set, the coefficient from the supplied distCoeffs matrix is used. Otherwise, it is set to 0.

  • @ref CALIB_RATIONAL_MODEL Coefficients k4, k5, and k6 are enabled. To provide the backward compatibility, this extra flag should be explicitly specified to make the calibration function use the rational model and return 8 coefficients or more.

  • @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, \f$c_x\f$ and \f$c_y\f$ very far from the image center, and/or large differences between \f$f_x\f$ and \f$f_y\f$ (ratios of 10:1 or more)), then you are probably using patternSize=cvSize(rows,cols) instead of using patternSize=cvSize(cols,rows) in @ref findChessboardCorners. @sa calibrateCameraRO, findChessboardCorners, solvePnP, initCameraMatrix2D, stereoCalibrate, undistort

Python prototype (for reference only):

calibrateCameraExtended(objectPoints, imagePoints, imageSize, cameraMatrix, distCoeffs[, rvecs[, tvecs[, stdDeviationsIntrinsics[, stdDeviationsExtrinsics[, perViewErrors[, flags[, criteria]]]]]]]) -> retval, cameraMatrix, distCoeffs, rvecs, tvecs, stdDeviationsIntrinsics, stdDeviationsExtrinsics, perViewErrors
Link to this function

calibrateCameraExtended(objectPoints, imagePoints, imageSize, cameraMatrix, distCoeffs, opts)

View Source

Finds the camera intrinsic and extrinsic parameters from several views of a calibration pattern.

Positional Arguments
  • objectPoints: [Evision.Mat].

    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: [Evision.Mat].

    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.

    Size of the image used only to initialize the camera intrinsic matrix.

Keyword Arguments
  • flags: int.

    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
  • criteria: TermCriteria.

    Termination criteria for the iterative optimization algorithm.

Return
  • retval: double

  • cameraMatrix: Evision.Mat.t().

    Input/output 3x3 floating-point camera intrinsic matrix \f$\cameramatrix{A}\f$ . If @ref CALIB_USE_INTRINSIC_GUESS and/or @ref CALIB_FIX_ASPECT_RATIO, @ref CALIB_FIX_PRINCIPAL_POINT or @ref CALIB_FIX_FOCAL_LENGTH are specified, some or all of fx, fy, cx, cy must be initialized before calling the function.

  • distCoeffs: Evision.Mat.t().

    Input/output vector of distortion coefficients \f$\distcoeffs\f$.

  • rvecs: [Evision.Mat].

    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: [Evision.Mat].

    Output vector of translation vectors estimated for each pattern view, see parameter describtion above.

  • stdDeviationsIntrinsics: Evision.Mat.t().

    Output vector of standard deviations estimated for intrinsic parameters. Order of deviations values: \f$(f_x, f_y, c_x, c_y, k_1, k_2, p_1, p_2, k_3, k_4, k_5, k_6 , s_1, s_2, s_3, s_4, \tau_x, \tau_y)\f$ If one of parameters is not estimated, it's deviation is equals to zero.

  • stdDeviationsExtrinsics: Evision.Mat.t().

    Output vector of standard deviations estimated for extrinsic parameters. Order of deviations values: \f$(R0, T_0, \dotsc , R{M - 1}, T_{M - 1})\f$ where M is the number of pattern views. \f$R_i, T_i\f$ are concatenated 1x3 vectors.

  • perViewErrors: Evision.Mat.t().

    Output vector of the RMS re-projection error estimated for each pattern view.

@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 \f$(p_1, p_2)\f$ are set to zeros and stay zero.

  • @ref CALIB_FIX_FOCAL_LENGTH The focal length is not changed during the global optimization if @ref CALIB_USE_INTRINSIC_GUESS is set.

  • @ref CALIB_FIX_K1,..., @ref CALIB_FIX_K6 The corresponding radial distortion coefficient is not changed during the optimization. If @ref CALIB_USE_INTRINSIC_GUESS is set, the coefficient from the supplied distCoeffs matrix is used. Otherwise, it is set to 0.

  • @ref CALIB_RATIONAL_MODEL Coefficients k4, k5, and k6 are enabled. To provide the backward compatibility, this extra flag should be explicitly specified to make the calibration function use the rational model and return 8 coefficients or more.

  • @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, \f$c_x\f$ and \f$c_y\f$ very far from the image center, and/or large differences between \f$f_x\f$ and \f$f_y\f$ (ratios of 10:1 or more)), then you are probably using patternSize=cvSize(rows,cols) instead of using patternSize=cvSize(cols,rows) in @ref findChessboardCorners. @sa calibrateCameraRO, findChessboardCorners, solvePnP, initCameraMatrix2D, stereoCalibrate, undistort

Python prototype (for reference only):

calibrateCameraExtended(objectPoints, imagePoints, imageSize, cameraMatrix, distCoeffs[, rvecs[, tvecs[, stdDeviationsIntrinsics[, stdDeviationsExtrinsics[, perViewErrors[, flags[, criteria]]]]]]]) -> retval, cameraMatrix, distCoeffs, rvecs, tvecs, stdDeviationsIntrinsics, stdDeviationsExtrinsics, perViewErrors
Link to this function

calibrateCameraRO(objectPoints, imagePoints, imageSize, iFixedPoint, cameraMatrix, distCoeffs)

View Source

calibrateCameraRO

Positional Arguments
  • objectPoints: [Evision.Mat]
  • imagePoints: [Evision.Mat]
  • imageSize: Size
  • iFixedPoint: int
Keyword Arguments
  • flags: int.
  • criteria: TermCriteria.
Return
  • retval: double
  • cameraMatrix: Evision.Mat.t()
  • distCoeffs: Evision.Mat.t()
  • rvecs: [Evision.Mat].
  • tvecs: [Evision.Mat].
  • newObjPoints: Evision.Mat.t().

Has overloading in C++

Python prototype (for reference only):

calibrateCameraRO(objectPoints, imagePoints, imageSize, iFixedPoint, cameraMatrix, distCoeffs[, rvecs[, tvecs[, newObjPoints[, flags[, criteria]]]]]) -> retval, cameraMatrix, distCoeffs, rvecs, tvecs, newObjPoints
Link to this function

calibrateCameraRO(objectPoints, imagePoints, imageSize, iFixedPoint, cameraMatrix, distCoeffs, opts)

View Source

calibrateCameraRO

Positional Arguments
  • objectPoints: [Evision.Mat]
  • imagePoints: [Evision.Mat]
  • imageSize: Size
  • iFixedPoint: int
Keyword Arguments
  • flags: int.
  • criteria: TermCriteria.
Return
  • retval: double
  • cameraMatrix: Evision.Mat.t()
  • distCoeffs: Evision.Mat.t()
  • rvecs: [Evision.Mat].
  • tvecs: [Evision.Mat].
  • newObjPoints: Evision.Mat.t().

Has overloading in C++

Python prototype (for reference only):

calibrateCameraRO(objectPoints, imagePoints, imageSize, iFixedPoint, cameraMatrix, distCoeffs[, rvecs[, tvecs[, newObjPoints[, flags[, criteria]]]]]) -> retval, cameraMatrix, distCoeffs, rvecs, tvecs, newObjPoints
Link to this function

calibrateCameraROExtended(objectPoints, imagePoints, imageSize, iFixedPoint, cameraMatrix, distCoeffs)

View Source

Finds the camera intrinsic and extrinsic parameters from several views of a calibration pattern.

Positional Arguments
  • objectPoints: [Evision.Mat].

    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: [Evision.Mat].

    Vector of vectors of the projections of calibration pattern points. See #calibrateCamera for details.

  • imageSize: Size.

    Size of the image used only to initialize the intrinsic camera matrix.

  • iFixedPoint: int.

    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.

Keyword Arguments
  • flags: int.

    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: TermCriteria.

    Termination criteria for the iterative optimization algorithm.

Return
  • retval: double

  • cameraMatrix: Evision.Mat.t().

    Output 3x3 floating-point camera matrix. See #calibrateCamera for details.

  • distCoeffs: Evision.Mat.t().

    Output vector of distortion coefficients. See #calibrateCamera for details.

  • rvecs: [Evision.Mat].

    Output vector of rotation vectors estimated for each pattern view. See #calibrateCamera for details.

  • tvecs: [Evision.Mat].

    Output vector of translation vectors estimated for each pattern view.

  • newObjPoints: Evision.Mat.t().

    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: Evision.Mat.t().

    Output vector of standard deviations estimated for intrinsic parameters. See #calibrateCamera for details.

  • stdDeviationsExtrinsics: Evision.Mat.t().

    Output vector of standard deviations estimated for extrinsic parameters. See #calibrateCamera for details.

  • stdDeviationsObjPoints: Evision.Mat.t().

    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: Evision.Mat.t().

    Output vector of the RMS re-projection error estimated for each pattern view.

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.

@return the overall RMS re-projection error. The function estimates the intrinsic camera parameters and extrinsic parameters for each of the views. The algorithm is based on @cite Zhang2000, @cite BouguetMCT and @cite strobl2011iccv. See #calibrateCamera for other detailed explanations. @sa calibrateCamera, findChessboardCorners, solvePnP, initCameraMatrix2D, stereoCalibrate, undistort

Python prototype (for reference only):

calibrateCameraROExtended(objectPoints, imagePoints, imageSize, iFixedPoint, cameraMatrix, distCoeffs[, rvecs[, tvecs[, newObjPoints[, stdDeviationsIntrinsics[, stdDeviationsExtrinsics[, stdDeviationsObjPoints[, perViewErrors[, flags[, criteria]]]]]]]]]) -> retval, cameraMatrix, distCoeffs, rvecs, tvecs, newObjPoints, stdDeviationsIntrinsics, stdDeviationsExtrinsics, stdDeviationsObjPoints, perViewErrors
Link to this function

calibrateCameraROExtended(objectPoints, imagePoints, imageSize, iFixedPoint, cameraMatrix, distCoeffs, opts)

View Source

Finds the camera intrinsic and extrinsic parameters from several views of a calibration pattern.

Positional Arguments
  • objectPoints: [Evision.Mat].

    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: [Evision.Mat].

    Vector of vectors of the projections of calibration pattern points. See #calibrateCamera for details.

  • imageSize: Size.

    Size of the image used only to initialize the intrinsic camera matrix.

  • iFixedPoint: int.

    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.

Keyword Arguments
  • flags: int.

    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: TermCriteria.

    Termination criteria for the iterative optimization algorithm.

Return
  • retval: double

  • cameraMatrix: Evision.Mat.t().

    Output 3x3 floating-point camera matrix. See #calibrateCamera for details.

  • distCoeffs: Evision.Mat.t().

    Output vector of distortion coefficients. See #calibrateCamera for details.

  • rvecs: [Evision.Mat].

    Output vector of rotation vectors estimated for each pattern view. See #calibrateCamera for details.

  • tvecs: [Evision.Mat].

    Output vector of translation vectors estimated for each pattern view.

  • newObjPoints: Evision.Mat.t().

    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: Evision.Mat.t().

    Output vector of standard deviations estimated for intrinsic parameters. See #calibrateCamera for details.

  • stdDeviationsExtrinsics: Evision.Mat.t().

    Output vector of standard deviations estimated for extrinsic parameters. See #calibrateCamera for details.

  • stdDeviationsObjPoints: Evision.Mat.t().

    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: Evision.Mat.t().

    Output vector of the RMS re-projection error estimated for each pattern view.

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.

@return the overall RMS re-projection error. The function estimates the intrinsic camera parameters and extrinsic parameters for each of the views. The algorithm is based on @cite Zhang2000, @cite BouguetMCT and @cite strobl2011iccv. See #calibrateCamera for other detailed explanations. @sa calibrateCamera, findChessboardCorners, solvePnP, initCameraMatrix2D, stereoCalibrate, undistort

Python prototype (for reference only):

calibrateCameraROExtended(objectPoints, imagePoints, imageSize, iFixedPoint, cameraMatrix, distCoeffs[, rvecs[, tvecs[, newObjPoints[, stdDeviationsIntrinsics[, stdDeviationsExtrinsics[, stdDeviationsObjPoints[, perViewErrors[, flags[, criteria]]]]]]]]]) -> retval, cameraMatrix, distCoeffs, rvecs, tvecs, newObjPoints, stdDeviationsIntrinsics, stdDeviationsExtrinsics, stdDeviationsObjPoints, perViewErrors
Link to this function

calibrateHandEye(r_gripper2base, t_gripper2base, r_target2cam, t_target2cam)

View Source

Computes Hand-Eye calibration: \f$_{}^{g}\textrm{T}_c\f$

Positional Arguments
  • r_gripper2base: [Evision.Mat].

    Rotation part extracted from the homogeneous matrix that transforms a point expressed in the gripper frame to the robot base frame (\f$_{}^{b}\textrm{T}_g\f$). This is a vector (vector<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: [Evision.Mat].

    Translation part extracted from the homogeneous matrix that transforms a point expressed in the gripper frame to the robot base frame (\f$_{}^{b}\textrm{T}_g\f$). This is a vector (vector<Mat>) that contains the (3x1) translation vectors for all the transformations from gripper frame to robot base frame.

  • r_target2cam: [Evision.Mat].

    Rotation part extracted from the homogeneous matrix that transforms a point expressed in the target frame to the camera frame (\f$_{}^{c}\textrm{T}_t\f$). This is a vector (vector<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: [Evision.Mat].

    Rotation part extracted from the homogeneous matrix that transforms a point expressed in the target frame to the camera frame (\f$_{}^{c}\textrm{T}_t\f$). This is a vector (vector<Mat>) that contains the (3x1) translation vectors for all the transformations from calibration target frame to camera frame.

Keyword Arguments
  • method: HandEyeCalibrationMethod.

    One of the implemented Hand-Eye calibration method, see cv::HandEyeCalibrationMethod

Return
  • r_cam2gripper: Evision.Mat.t().

    Estimated (3x3) rotation part extracted from the homogeneous matrix that transforms a point expressed in the camera frame to the gripper frame (\f$_{}^{g}\textrm{T}_c\f$).

  • t_cam2gripper: Evision.Mat.t().

    Estimated (3x1) translation part extracted from the homogeneous matrix that transforms a point expressed in the camera frame to the gripper frame (\f$_{}^{g}\textrm{T}_c\f$).

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 \f[ \begin{bmatrix} X_b\\ Y_b\\ Z_b\\ 1 \end{bmatrix}= \begin{bmatrix} _{}^{b}\textrm{R}_g & _{}^{b}\textrm{t}_g \\ 0_{1 \times 3} & 1 \end{bmatrix} \begin{bmatrix} X_g\\ Y_g\\ Z_g\\ 1 \end{bmatrix} \f]

  • for each pose, the homogeneous transformation between the calibration target frame and the camera frame is recorded using for instance a pose estimation method (PnP) from 2D-3D point correspondences \f[ \begin{bmatrix} X_c\\ Y_c\\ Z_c\\ 1 \end{bmatrix}= \begin{bmatrix} _{}^{c}\textrm{R}_t & _{}^{c}\textrm{t}_t \\ 0_{1 \times 3} & 1 \end{bmatrix} \begin{bmatrix} X_t\\ Y_t\\ Z_t\\ 1 \end{bmatrix} \f]

The Hand-Eye calibration procedure returns the following homogeneous transformation \f[ \begin{bmatrix} X_g\\ Y_g\\ Z_g\\ 1 \end{bmatrix} \begin{bmatrix} _{}^{g}\textrm{R}_c & _{}^{g}\textrm{t}_c \\ 0_{1 \times 3} & 1 \end{bmatrix} \begin{bmatrix} X_c\\ Y_c\\ Z_c\\ 1 \end{bmatrix} \f] This problem is also known as solving the \f$\mathbf{A}\mathbf{X}=\mathbf{X}\mathbf{B}\f$ equation:

  • for an eye-in-hand configuration \f[ \begin{align*} ^{b}{\textrm{T}_g}^{(1)} \hspace{0.2em} ^{g}\textrm{T}_c \hspace{0.2em} ^{c}{\textrm{T}_t}^{(1)} &= \hspace{0.1em} ^{b}{\textrm{T}_g}^{(2)} \hspace{0.2em} ^{g}\textrm{T}_c \hspace{0.2em} ^{c}{\textrm{T}_t}^{(2)} \\ (^{b}{\textrm{T}_g}^{(2)})^{-1} \hspace{0.2em} ^{b}{\textrm{T}_g}^{(1)} \hspace{0.2em} ^{g}\textrm{T}_c &= \hspace{0.1em} ^{g}\textrm{T}_c \hspace{0.2em} ^{c}{\textrm{T}_t}^{(2)} (^{c}{\textrm{T}_t}^{(1)})^{-1} \\ \textrm{A}_i \textrm{X} &= \textrm{X} \textrm{B}_i \\ \end{align*} \f]

  • for an eye-to-hand configuration \f[ \begin{align*} ^{g}{\textrm{T}_b}^{(1)} \hspace{0.2em} ^{b}\textrm{T}_c \hspace{0.2em} ^{c}{\textrm{T}_t}^{(1)} &= \hspace{0.1em} ^{g}{\textrm{T}_b}^{(2)} \hspace{0.2em} ^{b}\textrm{T}_c \hspace{0.2em} ^{c}{\textrm{T}_t}^{(2)} \\ (^{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*} \f]

\note Additional information can be found on this website. \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.

Python prototype (for reference only):

calibrateHandEye(R_gripper2base, t_gripper2base, R_target2cam, t_target2cam[, R_cam2gripper[, t_cam2gripper[, method]]]) -> R_cam2gripper, t_cam2gripper
Link to this function

calibrateHandEye(r_gripper2base, t_gripper2base, r_target2cam, t_target2cam, opts)

View Source
@spec calibrateHandEye(
  [Evision.Mat.maybe_mat_in()],
  [Evision.Mat.maybe_mat_in()],
  [Evision.Mat.maybe_mat_in()],
  [Evision.Mat.maybe_mat_in()],
  [{atom(), term()}, ...] | nil
) :: {Evision.Mat.t(), Evision.Mat.t()} | {:error, String.t()}

Computes Hand-Eye calibration: \f$_{}^{g}\textrm{T}_c\f$

Positional Arguments
  • r_gripper2base: [Evision.Mat].

    Rotation part extracted from the homogeneous matrix that transforms a point expressed in the gripper frame to the robot base frame (\f$_{}^{b}\textrm{T}_g\f$). This is a vector (vector<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: [Evision.Mat].

    Translation part extracted from the homogeneous matrix that transforms a point expressed in the gripper frame to the robot base frame (\f$_{}^{b}\textrm{T}_g\f$). This is a vector (vector<Mat>) that contains the (3x1) translation vectors for all the transformations from gripper frame to robot base frame.

  • r_target2cam: [Evision.Mat].

    Rotation part extracted from the homogeneous matrix that transforms a point expressed in the target frame to the camera frame (\f$_{}^{c}\textrm{T}_t\f$). This is a vector (vector<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: [Evision.Mat].

    Rotation part extracted from the homogeneous matrix that transforms a point expressed in the target frame to the camera frame (\f$_{}^{c}\textrm{T}_t\f$). This is a vector (vector<Mat>) that contains the (3x1) translation vectors for all the transformations from calibration target frame to camera frame.

Keyword Arguments
  • method: HandEyeCalibrationMethod.

    One of the implemented Hand-Eye calibration method, see cv::HandEyeCalibrationMethod

Return
  • r_cam2gripper: Evision.Mat.t().

    Estimated (3x3) rotation part extracted from the homogeneous matrix that transforms a point expressed in the camera frame to the gripper frame (\f$_{}^{g}\textrm{T}_c\f$).

  • t_cam2gripper: Evision.Mat.t().

    Estimated (3x1) translation part extracted from the homogeneous matrix that transforms a point expressed in the camera frame to the gripper frame (\f$_{}^{g}\textrm{T}_c\f$).

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 \f[ \begin{bmatrix} X_b\\ Y_b\\ Z_b\\ 1 \end{bmatrix}= \begin{bmatrix} _{}^{b}\textrm{R}_g & _{}^{b}\textrm{t}_g \\ 0_{1 \times 3} & 1 \end{bmatrix} \begin{bmatrix} X_g\\ Y_g\\ Z_g\\ 1 \end{bmatrix} \f]

  • for each pose, the homogeneous transformation between the calibration target frame and the camera frame is recorded using for instance a pose estimation method (PnP) from 2D-3D point correspondences \f[ \begin{bmatrix} X_c\\ Y_c\\ Z_c\\ 1 \end{bmatrix}= \begin{bmatrix} _{}^{c}\textrm{R}_t & _{}^{c}\textrm{t}_t \\ 0_{1 \times 3} & 1 \end{bmatrix} \begin{bmatrix} X_t\\ Y_t\\ Z_t\\ 1 \end{bmatrix} \f]

The Hand-Eye calibration procedure returns the following homogeneous transformation \f[ \begin{bmatrix} X_g\\ Y_g\\ Z_g\\ 1 \end{bmatrix} \begin{bmatrix} _{}^{g}\textrm{R}_c & _{}^{g}\textrm{t}_c \\ 0_{1 \times 3} & 1 \end{bmatrix} \begin{bmatrix} X_c\\ Y_c\\ Z_c\\ 1 \end{bmatrix} \f] This problem is also known as solving the \f$\mathbf{A}\mathbf{X}=\mathbf{X}\mathbf{B}\f$ equation:

  • for an eye-in-hand configuration \f[ \begin{align*} ^{b}{\textrm{T}_g}^{(1)} \hspace{0.2em} ^{g}\textrm{T}_c \hspace{0.2em} ^{c}{\textrm{T}_t}^{(1)} &= \hspace{0.1em} ^{b}{\textrm{T}_g}^{(2)} \hspace{0.2em} ^{g}\textrm{T}_c \hspace{0.2em} ^{c}{\textrm{T}_t}^{(2)} \\ (^{b}{\textrm{T}_g}^{(2)})^{-1} \hspace{0.2em} ^{b}{\textrm{T}_g}^{(1)} \hspace{0.2em} ^{g}\textrm{T}_c &= \hspace{0.1em} ^{g}\textrm{T}_c \hspace{0.2em} ^{c}{\textrm{T}_t}^{(2)} (^{c}{\textrm{T}_t}^{(1)})^{-1} \\ \textrm{A}_i \textrm{X} &= \textrm{X} \textrm{B}_i \\ \end{align*} \f]

  • for an eye-to-hand configuration \f[ \begin{align*} ^{g}{\textrm{T}_b}^{(1)} \hspace{0.2em} ^{b}\textrm{T}_c \hspace{0.2em} ^{c}{\textrm{T}_t}^{(1)} &= \hspace{0.1em} ^{g}{\textrm{T}_b}^{(2)} \hspace{0.2em} ^{b}\textrm{T}_c \hspace{0.2em} ^{c}{\textrm{T}_t}^{(2)} \\ (^{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*} \f]

\note Additional information can be found on this website. \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.

Python prototype (for reference only):

calibrateHandEye(R_gripper2base, t_gripper2base, R_target2cam, t_target2cam[, R_cam2gripper[, t_cam2gripper[, method]]]) -> R_cam2gripper, t_cam2gripper
Link to this function

calibrateRobotWorldHandEye(r_world2cam, t_world2cam, r_base2gripper, t_base2gripper)

View Source

Computes Robot-World/Hand-Eye calibration: \f$_{}^{w}\textrm{T}_b\f$ and \f$_{}^{c}\textrm{T}_g\f$

Positional Arguments
  • r_world2cam: [Evision.Mat].

    Rotation part extracted from the homogeneous matrix that transforms a point expressed in the world frame to the camera frame (\f$_{}^{c}\textrm{T}_w\f$). 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: [Evision.Mat].

    Translation part extracted from the homogeneous matrix that transforms a point expressed in the world frame to the camera frame (\f$_{}^{c}\textrm{T}_w\f$). 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: [Evision.Mat].

    Rotation part extracted from the homogeneous matrix that transforms a point expressed in the robot base frame to the gripper frame (\f$_{}^{g}\textrm{T}_b\f$). 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: [Evision.Mat].

    Rotation part extracted from the homogeneous matrix that transforms a point expressed in the robot base frame to the gripper frame (\f$_{}^{g}\textrm{T}_b\f$). This is a vector (vector<Mat>) that contains the (3x1) translation vectors for all the transformations from robot base frame to the gripper frame.

Keyword Arguments
  • method: RobotWorldHandEyeCalibrationMethod.

    One of the implemented Robot-World/Hand-Eye calibration method, see cv::RobotWorldHandEyeCalibrationMethod

Return
  • r_base2world: Evision.Mat.t().

    Estimated (3x3) rotation part extracted from the homogeneous matrix that transforms a point expressed in the robot base frame to the world frame (\f$_{}^{w}\textrm{T}_b\f$).

  • t_base2world: Evision.Mat.t().

    Estimated (3x1) translation part extracted from the homogeneous matrix that transforms a point expressed in the robot base frame to the world frame (\f$_{}^{w}\textrm{T}_b\f$).

  • r_gripper2cam: Evision.Mat.t().

    Estimated (3x3) rotation part extracted from the homogeneous matrix that transforms a point expressed in the gripper frame to the camera frame (\f$_{}^{c}\textrm{T}_g\f$).

  • t_gripper2cam: Evision.Mat.t().

    Estimated (3x1) translation part extracted from the homogeneous matrix that transforms a point expressed in the gripper frame to the camera frame (\f$_{}^{c}\textrm{T}_g\f$).

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 \f[ \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} \f]

  • 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 \f[ \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} \f]

The Robot-World/Hand-Eye calibration procedure returns the following homogeneous transformations \f[ \begin{bmatrix} X_w\\ Y_w\\ Z_w\\ 1 \end{bmatrix} \begin{bmatrix} _{}^{w}\textrm{R}_b & _{}^{w}\textrm{t}_b \\ 0_{1 \times 3} & 1 \end{bmatrix} \begin{bmatrix} X_b\\ Y_b\\ Z_b\\ 1 \end{bmatrix} \f] \f[ \begin{bmatrix} X_c\\ Y_c\\ Z_c\\ 1 \end{bmatrix} \begin{bmatrix} _{}^{c}\textrm{R}_g & _{}^{c}\textrm{t}_g \\ 0_{1 \times 3} & 1 \end{bmatrix} \begin{bmatrix} X_g\\ Y_g\\ Z_g\\ 1 \end{bmatrix} \f] This problem is also known as solving the \f$\mathbf{A}\mathbf{X}=\mathbf{Z}\mathbf{B}\f$ equation, with:

  • \f$\mathbf{A} \Leftrightarrow \hspace{0.1em} _{}^{c}\textrm{T}_w\f$
  • \f$\mathbf{X} \Leftrightarrow \hspace{0.1em} _{}^{w}\textrm{T}_b\f$
  • \f$\mathbf{Z} \Leftrightarrow \hspace{0.1em} _{}^{c}\textrm{T}_g\f$
  • \f$\mathbf{B} \Leftrightarrow \hspace{0.1em} _{}^{g}\textrm{T}_b\f$

\note At least 3 measurements are required (input vectors size must be greater or equal to 3).

Python prototype (for reference only):

calibrateRobotWorldHandEye(R_world2cam, t_world2cam, R_base2gripper, t_base2gripper[, R_base2world[, t_base2world[, R_gripper2cam[, t_gripper2cam[, method]]]]]) -> R_base2world, t_base2world, R_gripper2cam, t_gripper2cam
Link to this function

calibrateRobotWorldHandEye(r_world2cam, t_world2cam, r_base2gripper, t_base2gripper, opts)

View Source
@spec calibrateRobotWorldHandEye(
  [Evision.Mat.maybe_mat_in()],
  [Evision.Mat.maybe_mat_in()],
  [Evision.Mat.maybe_mat_in()],
  [Evision.Mat.maybe_mat_in()],
  [{atom(), term()}, ...] | nil
) ::
  {Evision.Mat.t(), Evision.Mat.t(), Evision.Mat.t(), Evision.Mat.t()}
  | {:error, String.t()}

Computes Robot-World/Hand-Eye calibration: \f$_{}^{w}\textrm{T}_b\f$ and \f$_{}^{c}\textrm{T}_g\f$

Positional Arguments
  • r_world2cam: [Evision.Mat].

    Rotation part extracted from the homogeneous matrix that transforms a point expressed in the world frame to the camera frame (\f$_{}^{c}\textrm{T}_w\f$). 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: [Evision.Mat].

    Translation part extracted from the homogeneous matrix that transforms a point expressed in the world frame to the camera frame (\f$_{}^{c}\textrm{T}_w\f$). 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: [Evision.Mat].

    Rotation part extracted from the homogeneous matrix that transforms a point expressed in the robot base frame to the gripper frame (\f$_{}^{g}\textrm{T}_b\f$). 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: [Evision.Mat].

    Rotation part extracted from the homogeneous matrix that transforms a point expressed in the robot base frame to the gripper frame (\f$_{}^{g}\textrm{T}_b\f$). This is a vector (vector<Mat>) that contains the (3x1) translation vectors for all the transformations from robot base frame to the gripper frame.

Keyword Arguments
  • method: RobotWorldHandEyeCalibrationMethod.

    One of the implemented Robot-World/Hand-Eye calibration method, see cv::RobotWorldHandEyeCalibrationMethod

Return
  • r_base2world: Evision.Mat.t().

    Estimated (3x3) rotation part extracted from the homogeneous matrix that transforms a point expressed in the robot base frame to the world frame (\f$_{}^{w}\textrm{T}_b\f$).

  • t_base2world: Evision.Mat.t().

    Estimated (3x1) translation part extracted from the homogeneous matrix that transforms a point expressed in the robot base frame to the world frame (\f$_{}^{w}\textrm{T}_b\f$).

  • r_gripper2cam: Evision.Mat.t().

    Estimated (3x3) rotation part extracted from the homogeneous matrix that transforms a point expressed in the gripper frame to the camera frame (\f$_{}^{c}\textrm{T}_g\f$).

  • t_gripper2cam: Evision.Mat.t().

    Estimated (3x1) translation part extracted from the homogeneous matrix that transforms a point expressed in the gripper frame to the camera frame (\f$_{}^{c}\textrm{T}_g\f$).

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 \f[ \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} \f]

  • 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 \f[ \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} \f]

The Robot-World/Hand-Eye calibration procedure returns the following homogeneous transformations \f[ \begin{bmatrix} X_w\\ Y_w\\ Z_w\\ 1 \end{bmatrix} \begin{bmatrix} _{}^{w}\textrm{R}_b & _{}^{w}\textrm{t}_b \\ 0_{1 \times 3} & 1 \end{bmatrix} \begin{bmatrix} X_b\\ Y_b\\ Z_b\\ 1 \end{bmatrix} \f] \f[ \begin{bmatrix} X_c\\ Y_c\\ Z_c\\ 1 \end{bmatrix} \begin{bmatrix} _{}^{c}\textrm{R}_g & _{}^{c}\textrm{t}_g \\ 0_{1 \times 3} & 1 \end{bmatrix} \begin{bmatrix} X_g\\ Y_g\\ Z_g\\ 1 \end{bmatrix} \f] This problem is also known as solving the \f$\mathbf{A}\mathbf{X}=\mathbf{Z}\mathbf{B}\f$ equation, with:

  • \f$\mathbf{A} \Leftrightarrow \hspace{0.1em} _{}^{c}\textrm{T}_w\f$
  • \f$\mathbf{X} \Leftrightarrow \hspace{0.1em} _{}^{w}\textrm{T}_b\f$
  • \f$\mathbf{Z} \Leftrightarrow \hspace{0.1em} _{}^{c}\textrm{T}_g\f$
  • \f$\mathbf{B} \Leftrightarrow \hspace{0.1em} _{}^{g}\textrm{T}_b\f$

\note At least 3 measurements are required (input vectors size must be greater or equal to 3).

Python prototype (for reference only):

calibrateRobotWorldHandEye(R_world2cam, t_world2cam, R_base2gripper, t_base2gripper[, R_base2world[, t_base2world[, R_gripper2cam[, t_gripper2cam[, method]]]]]) -> R_base2world, t_base2world, R_gripper2cam, t_gripper2cam
Link to this function

calibrationMatrixValues(cameraMatrix, imageSize, apertureWidth, apertureHeight)

View Source
@spec calibrationMatrixValues(
  Evision.Mat.maybe_mat_in(),
  {number(), number()},
  number(),
  number()
) ::
  {number(), number(), number(), {number(), number()}, number()}
  | {:error, String.t()}

Computes useful camera characteristics from the camera intrinsic matrix.

Positional Arguments
  • cameraMatrix: Evision.Mat.t().

    Input camera intrinsic matrix that can be estimated by #calibrateCamera or #stereoCalibrate .

  • imageSize: Size.

    Input image size in pixels.

  • apertureWidth: double.

    Physical width in mm of the sensor.

  • apertureHeight: double.

    Physical height in mm of the sensor.

Return
  • fovx: double.

    Output field of view in degrees along the horizontal sensor axis.

  • fovy: double.

    Output field of view in degrees along the vertical sensor axis.

  • focalLength: double.

    Focal length of the lens in mm.

  • principalPoint: Point2d.

    Principal point in mm.

  • aspectRatio: double.

    \f$f_y/f_x\f$

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).

Python prototype (for reference only):

calibrationMatrixValues(cameraMatrix, imageSize, apertureWidth, apertureHeight) -> fovx, fovy, focalLength, principalPoint, aspectRatio
Link to this function

camShift(probImage, window, criteria)

View Source
@spec camShift(
  Evision.Mat.maybe_mat_in(),
  {number(), number(), number(), number()},
  {integer(), integer(), number()}
) ::
  {{{number(), number()}, {number(), number()}, number()},
   {number(), number(), number(), number()}}
  | {:error, String.t()}

Finds an object center, size, and orientation.

Positional Arguments
  • probImage: Evision.Mat.t().

    Back projection of the object histogram. See calcBackProject.

  • criteria: TermCriteria.

    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()

Return
  • retval: {centre={x, y}, size={s1, s2}, angle}

  • window: Rect.

    Initial search window.

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

Python prototype (for reference only):

CamShift(probImage, window, criteria) -> retval, window
Link to this function

canny(image, threshold1, threshold2)

View Source
@spec canny(Evision.Mat.maybe_mat_in(), number(), number()) ::
  Evision.Mat.t() | {:error, String.t()}

Finds edges in an image using the Canny algorithm @cite Canny86 .

Positional Arguments
  • image: Evision.Mat.t().

    8-bit input image.

  • threshold1: double.

    first threshold for the hysteresis procedure.

  • threshold2: double.

    second threshold for the hysteresis procedure.

Keyword Arguments
  • apertureSize: int.

    aperture size for the Sobel operator.

  • l2gradient: bool.

    a flag, indicating whether a more accurate \f$L_2\f$ norm \f$=\sqrt{(dI/dx)^2 + (dI/dy)^2}\f$ should be used to calculate the image gradient magnitude ( L2gradient=true ), or whether the default \f$L_1\f$ norm \f$=|dI/dx|+|dI/dy|\f$ is enough ( L2gradient=false ).

Return
  • edges: Evision.Mat.t().

    output edge map; single channels 8-bit image, which has the same size as image .

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

Python prototype (for reference only):

Canny(image, threshold1, threshold2[, edges[, apertureSize[, L2gradient]]]) -> edges
Link to this function

canny(image, threshold1, threshold2, opts)

View Source
@spec canny(
  Evision.Mat.maybe_mat_in(),
  number(),
  number(),
  [{atom(), term()}, ...] | nil
) ::
  Evision.Mat.t() | {:error, String.t()}
@spec canny(
  Evision.Mat.maybe_mat_in(),
  Evision.Mat.maybe_mat_in(),
  number(),
  number()
) ::
  Evision.Mat.t() | {:error, String.t()}

Variant 1:

Canny

Positional Arguments
  • dx: Evision.Mat.t().

    16-bit x derivative of input image (CV_16SC1 or CV_16SC3).

  • dy: Evision.Mat.t().

    16-bit y derivative of input image (same type as dx).

  • threshold1: double.

    first threshold for the hysteresis procedure.

  • threshold2: double.

    second threshold for the hysteresis procedure.

Keyword Arguments
  • l2gradient: bool.

    a flag, indicating whether a more accurate \f$L_2\f$ norm \f$=\sqrt{(dI/dx)^2 + (dI/dy)^2}\f$ should be used to calculate the image gradient magnitude ( L2gradient=true ), or whether the default \f$L_1\f$ norm \f$=|dI/dx|+|dI/dy|\f$ is enough ( L2gradient=false ).

Return
  • edges: Evision.Mat.t().

    output edge map; single channels 8-bit image, which has the same size as image .

Finds edges in an image using the Canny algorithm with custom image gradient.

Python prototype (for reference only):

Canny(dx, dy, threshold1, threshold2[, edges[, L2gradient]]) -> edges

Variant 2:

Finds edges in an image using the Canny algorithm @cite Canny86 .

Positional Arguments
  • image: Evision.Mat.t().

    8-bit input image.

  • threshold1: double.

    first threshold for the hysteresis procedure.

  • threshold2: double.

    second threshold for the hysteresis procedure.

Keyword Arguments
  • apertureSize: int.

    aperture size for the Sobel operator.

  • l2gradient: bool.

    a flag, indicating whether a more accurate \f$L_2\f$ norm \f$=\sqrt{(dI/dx)^2 + (dI/dy)^2}\f$ should be used to calculate the image gradient magnitude ( L2gradient=true ), or whether the default \f$L_1\f$ norm \f$=|dI/dx|+|dI/dy|\f$ is enough ( L2gradient=false ).

Return
  • edges: Evision.Mat.t().

    output edge map; single channels 8-bit image, which has the same size as image .

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

Python prototype (for reference only):

Canny(image, threshold1, threshold2[, edges[, apertureSize[, L2gradient]]]) -> edges
Link to this function

canny(dx, dy, threshold1, threshold2, opts)

View Source
@spec canny(
  Evision.Mat.maybe_mat_in(),
  Evision.Mat.maybe_mat_in(),
  number(),
  number(),
  [{atom(), term()}, ...] | nil
) :: Evision.Mat.t() | {:error, String.t()}

Canny

Positional Arguments
  • dx: Evision.Mat.t().

    16-bit x derivative of input image (CV_16SC1 or CV_16SC3).

  • dy: Evision.Mat.t().

    16-bit y derivative of input image (same type as dx).

  • threshold1: double.

    first threshold for the hysteresis procedure.

  • threshold2: double.

    second threshold for the hysteresis procedure.

Keyword Arguments
  • l2gradient: bool.

    a flag, indicating whether a more accurate \f$L_2\f$ norm \f$=\sqrt{(dI/dx)^2 + (dI/dy)^2}\f$ should be used to calculate the image gradient magnitude ( L2gradient=true ), or whether the default \f$L_1\f$ norm \f$=|dI/dx|+|dI/dy|\f$ is enough ( L2gradient=false ).

Return
  • edges: Evision.Mat.t().

    output edge map; single channels 8-bit image, which has the same size as image .

Finds edges in an image using the Canny algorithm with custom image gradient.

Python prototype (for reference only):

Canny(dx, dy, threshold1, threshold2[, edges[, L2gradient]]) -> edges

Calculates the magnitude and angle of 2D vectors.

Positional Arguments
  • x: Evision.Mat.t().

    array of x-coordinates; this must be a single-precision or double-precision floating-point array.

  • y: Evision.Mat.t().

    array of y-coordinates, that must have the same size and same type as x.

Keyword Arguments
  • angleInDegrees: bool.

    a flag, indicating whether the angles are measured in radians (which is by default), or in degrees.

Return
  • magnitude: Evision.Mat.t().

    output array of magnitudes of the same size and type as x.

  • angle: Evision.Mat.t().

    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).

The function cv::cartToPolar calculates either the magnitude, angle, or both for every 2D vector (x(I),y(I)): \f[\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}\f] The angles are calculated with accuracy about 0.3 degrees. For the point (0,0), the angle is set to 0. @sa Sobel, Scharr

Python prototype (for reference only):

cartToPolar(x, y[, magnitude[, angle[, angleInDegrees]]]) -> magnitude, angle
@spec cartToPolar(
  Evision.Mat.maybe_mat_in(),
  Evision.Mat.maybe_mat_in(),
  [{atom(), term()}, ...] | nil
) ::
  {Evision.Mat.t(), Evision.Mat.t()} | {:error, String.t()}

Calculates the magnitude and angle of 2D vectors.

Positional Arguments
  • x: Evision.Mat.t().

    array of x-coordinates; this must be a single-precision or double-precision floating-point array.

  • y: Evision.Mat.t().

    array of y-coordinates, that must have the same size and same type as x.

Keyword Arguments
  • angleInDegrees: bool.

    a flag, indicating whether the angles are measured in radians (which is by default), or in degrees.

Return
  • magnitude: Evision.Mat.t().

    output array of magnitudes of the same size and type as x.

  • angle: Evision.Mat.t().

    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).

The function cv::cartToPolar calculates either the magnitude, angle, or both for every 2D vector (x(I),y(I)): \f[\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}\f] The angles are calculated with accuracy about 0.3 degrees. For the point (0,0), the angle is set to 0. @sa Sobel, Scharr

Python prototype (for reference only):

cartToPolar(x, y[, magnitude[, angle[, angleInDegrees]]]) -> magnitude, angle
Link to this function

checkChessboard(img, size)

View Source
@spec checkChessboard(
  Evision.Mat.maybe_mat_in(),
  {number(), number()}
) :: boolean() | {:error, String.t()}

checkChessboard

Positional Arguments
  • img: Evision.Mat.t()
  • size: Size
Return
  • retval: bool

Python prototype (for reference only):

checkChessboard(img, size) -> retval
Link to this function

checkHardwareSupport(feature)

View Source
@spec checkHardwareSupport(integer()) :: boolean() | {:error, String.t()}

Returns true if the specified feature is supported by the host hardware.

Positional Arguments
  • feature: int.

    The feature of interest, one of cv::CpuFeatures

Return
  • retval: bool

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.

Python prototype (for reference only):

checkHardwareSupport(feature) -> retval
@spec checkRange(Evision.Mat.maybe_mat_in()) ::
  {number(), number()} | false | {:error, String.t()}

Checks every element of an input array for invalid values.

Positional Arguments
  • a: Evision.Mat.t().

    input array.

Keyword Arguments
  • quiet: bool.

    a flag, indicating whether the functions quietly return false when the array elements are out of range or they throw an exception.

  • minVal: double.

    inclusive lower boundary of valid values range.

  • maxVal: double.

    exclusive upper boundary of valid values range.

Return
  • retval: bool

  • pos: Point*.

    optional output parameter, when not NULL, must be a pointer to array of src.dims elements.

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.

Python prototype (for reference only):

checkRange(a[, quiet[, minVal[, maxVal]]]) -> retval, pos
@spec checkRange(Evision.Mat.maybe_mat_in(), [{atom(), term()}, ...] | nil) ::
  {number(), number()} | false | {:error, String.t()}

Checks every element of an input array for invalid values.

Positional Arguments
  • a: Evision.Mat.t().

    input array.

Keyword Arguments
  • quiet: bool.

    a flag, indicating whether the functions quietly return false when the array elements are out of range or they throw an exception.

  • minVal: double.

    inclusive lower boundary of valid values range.

  • maxVal: double.

    exclusive upper boundary of valid values range.

Return
  • retval: bool

  • pos: Point*.

    optional output parameter, when not NULL, must be a pointer to array of src.dims elements.

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.

Python prototype (for reference only):

checkRange(a[, quiet[, minVal[, maxVal]]]) -> retval, pos
Link to this function

circle(img, center, radius, color)

View Source
@spec circle(
  Evision.Mat.maybe_mat_in(),
  {number(), number()},
  integer(),
  {number()}
  | {number(), number()}
  | {number(), number(), number()}
  | {number(), number(), number(), number()}
) :: Evision.Mat.t() | {:error, String.t()}

Draws a circle.

Positional Arguments
  • center: Point.

    Center of the circle.

  • radius: int.

    Radius of the circle.

  • color: Scalar.

    Circle color.

Keyword Arguments
  • thickness: int.

    Thickness of the circle outline, if positive. Negative values, like #FILLED, mean that a filled circle is to be drawn.

  • lineType: int.

    Type of the circle boundary. See #LineTypes

  • shift: int.

    Number of fractional bits in the coordinates of the center and in the radius value.

Return
  • img: Evision.Mat.t().

    Image where the circle is drawn.

The function cv::circle draws a simple or filled circle with a given center and radius.

Python prototype (for reference only):

circle(img, center, radius, color[, thickness[, lineType[, shift]]]) -> img
Link to this function

circle(img, center, radius, color, opts)

View Source
@spec circle(
  Evision.Mat.maybe_mat_in(),
  {number(), number()},
  integer(),
  {number()}
  | {number(), number()}
  | {number(), number(), number()}
  | {number(), number(), number(), number()},
  [{atom(), term()}, ...] | nil
) :: Evision.Mat.t() | {:error, String.t()}

Draws a circle.

Positional Arguments
  • center: Point.

    Center of the circle.

  • radius: int.

    Radius of the circle.

  • color: Scalar.

    Circle color.

Keyword Arguments
  • thickness: int.

    Thickness of the circle outline, if positive. Negative values, like #FILLED, mean that a filled circle is to be drawn.

  • lineType: int.

    Type of the circle boundary. See #LineTypes

  • shift: int.

    Number of fractional bits in the coordinates of the center and in the radius value.

Return
  • img: Evision.Mat.t().

    Image where the circle is drawn.

The function cv::circle draws a simple or filled circle with a given center and radius.

Python prototype (for reference only):

circle(img, center, radius, color[, thickness[, lineType[, shift]]]) -> img
Link to this function

clipLine(imgRect, pt1, pt2)

View Source
@spec clipLine(
  {number(), number(), number(), number()},
  {number(), number()},
  {number(), number()}
) ::
  {{number(), number()}, {number(), number()}} | false | {:error, String.t()}

clipLine

Positional Arguments
  • imgRect: Rect.

    Image rectangle.

Return
  • retval: bool

  • pt1: Point.

    First line point.

  • pt2: Point.

    Second line point.

Has overloading in C++

Python prototype (for reference only):

clipLine(imgRect, pt1, pt2) -> retval, pt1, pt2
@spec colorChange(Evision.Mat.maybe_mat_in(), Evision.Mat.maybe_mat_in()) ::
  Evision.Mat.t() | {:error, String.t()}

Given an original color image, two differently colored versions of this image can be mixed seamlessly.

Positional Arguments
  • src: Evision.Mat.t().

    Input 8-bit 3-channel image.

  • mask: Evision.Mat.t().

    Input 8-bit 1 or 3-channel image.

Keyword Arguments
  • red_mul: float.

    R-channel multiply factor.

  • green_mul: float.

    G-channel multiply factor.

  • blue_mul: float.

    B-channel multiply factor.

Return
  • dst: Evision.Mat.t().

    Output image with the same size and type as src .

Multiplication factor is between .5 to 2.5.

Python prototype (for reference only):

colorChange(src, mask[, dst[, red_mul[, green_mul[, blue_mul]]]]) -> dst
Link to this function

colorChange(src, mask, opts)

View Source
@spec colorChange(
  Evision.Mat.maybe_mat_in(),
  Evision.Mat.maybe_mat_in(),
  [{atom(), term()}, ...] | nil
) ::
  Evision.Mat.t() | {:error, String.t()}

Given an original color image, two differently colored versions of this image can be mixed seamlessly.

Positional Arguments
  • src: Evision.Mat.t().

    Input 8-bit 3-channel image.

  • mask: Evision.Mat.t().

    Input 8-bit 1 or 3-channel image.

Keyword Arguments
  • red_mul: float.

    R-channel multiply factor.

  • green_mul: float.

    G-channel multiply factor.

  • blue_mul: float.

    B-channel multiply factor.

Return
  • dst: Evision.Mat.t().

    Output image with the same size and type as src .

Multiplication factor is between .5 to 2.5.

Python prototype (for reference only):

colorChange(src, mask[, dst[, red_mul[, green_mul[, blue_mul]]]]) -> dst
Link to this function

compare(src1, src2, cmpop)

View Source

Performs the per-element comparison of two arrays or an array and scalar value.

Positional Arguments
  • src1: Evision.Mat.t().

    first input array or a scalar; when it is an array, it must have a single channel.

  • src2: Evision.Mat.t().

    second input array or a scalar; when it is an array, it must have a single channel.

  • cmpop: int.

    a flag, that specifies correspondence between the arrays (cv::CmpTypes)

Return
  • dst: Evision.Mat.t().

    output array of type ref CV_8U that has the same size and the same number of channels as the input arrays.

The function compares: Elements of two arrays when src1 and src2 have the same size: \f[\texttt{dst} (I) = \texttt{src1} (I) \,\texttt{cmpop}\, \texttt{src2} (I)\f] Elements of src1 with a scalar src2 when src2 is constructed from Scalar or has a single element: \f[\texttt{dst} (I) = \texttt{src1}(I) \,\texttt{cmpop}\, \texttt{src2}\f] src1 with elements of src2 when src1 is constructed from Scalar or has a single element: \f[\texttt{dst} (I) = \texttt{src1} \,\texttt{cmpop}\, \texttt{src2} (I)\f] 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;
...

@sa checkRange, min, max, threshold

Python prototype (for reference only):

compare(src1, src2, cmpop[, dst]) -> dst
Link to this function

compare(src1, src2, cmpop, opts)

View Source
@spec compare(
  Evision.Mat.maybe_mat_in(),
  Evision.Mat.maybe_mat_in(),
  integer(),
  [{atom(), term()}, ...] | nil
) :: Evision.Mat.t() | {:error, String.t()}

Performs the per-element comparison of two arrays or an array and scalar value.

Positional Arguments
  • src1: Evision.Mat.t().

    first input array or a scalar; when it is an array, it must have a single channel.

  • src2: Evision.Mat.t().

    second input array or a scalar; when it is an array, it must have a single channel.

  • cmpop: int.

    a flag, that specifies correspondence between the arrays (cv::CmpTypes)

Return
  • dst: Evision.Mat.t().

    output array of type ref CV_8U that has the same size and the same number of channels as the input arrays.

The function compares: Elements of two arrays when src1 and src2 have the same size: \f[\texttt{dst} (I) = \texttt{src1} (I) \,\texttt{cmpop}\, \texttt{src2} (I)\f] Elements of src1 with a scalar src2 when src2 is constructed from Scalar or has a single element: \f[\texttt{dst} (I) = \texttt{src1}(I) \,\texttt{cmpop}\, \texttt{src2}\f] src1 with elements of src2 when src1 is constructed from Scalar or has a single element: \f[\texttt{dst} (I) = \texttt{src1} \,\texttt{cmpop}\, \texttt{src2} (I)\f] 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;
...

@sa checkRange, min, max, threshold

Python prototype (for reference only):

compare(src1, src2, cmpop[, dst]) -> dst
Link to this function

compareHist(h1, h2, method)

View Source
@spec compareHist(Evision.Mat.maybe_mat_in(), Evision.Mat.maybe_mat_in(), integer()) ::
  number() | {:error, String.t()}

Compares two histograms.

Positional Arguments
  • h1: Evision.Mat.t().

    First compared histogram.

  • h2: Evision.Mat.t().

    Second compared histogram of the same size as H1 .

  • method: int.

    Comparison method, see #HistCompMethods

Return
  • retval: double

The function cv::compareHist compares two dense or two sparse histograms using the specified method. The function returns \f$d(H_1, H_2)\f$ . 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.

Python prototype (for reference only):

compareHist(H1, H2, method) -> retval
@spec completeSymm(Evision.Mat.maybe_mat_in()) ::
  Evision.Mat.t() | {:error, String.t()}

Copies the lower or the upper half of a square matrix to its another half.

Keyword Arguments
  • lowerToUpper: bool.

    operation flag; if true, the lower half is copied to the upper half. Otherwise, the upper half is copied to the lower half.

Return
  • m: Evision.Mat.t().

    input-output floating-point square matrix.

The function cv::completeSymm copies the lower or the upper half of a square matrix to its another half. The matrix diagonal remains unchanged:

  • \f$\texttt{m}_{ij}=\texttt{m}_{ji}\f$ for \f$i > j\f$ if lowerToUpper=false

  • \f$\texttt{m}_{ij}=\texttt{m}_{ji}\f$ for \f$i < j\f$ if lowerToUpper=true

@sa flip, transpose

Python prototype (for reference only):

completeSymm(m[, lowerToUpper]) -> m
@spec completeSymm(Evision.Mat.maybe_mat_in(), [{atom(), term()}, ...] | nil) ::
  Evision.Mat.t() | {:error, String.t()}

Copies the lower or the upper half of a square matrix to its another half.

Keyword Arguments
  • lowerToUpper: bool.

    operation flag; if true, the lower half is copied to the upper half. Otherwise, the upper half is copied to the lower half.

Return
  • m: Evision.Mat.t().

    input-output floating-point square matrix.

The function cv::completeSymm copies the lower or the upper half of a square matrix to its another half. The matrix diagonal remains unchanged:

  • \f$\texttt{m}_{ij}=\texttt{m}_{ji}\f$ for \f$i > j\f$ if lowerToUpper=false

  • \f$\texttt{m}_{ij}=\texttt{m}_{ji}\f$ for \f$i < j\f$ if lowerToUpper=true

@sa flip, transpose

Python prototype (for reference only):

completeSymm(m[, lowerToUpper]) -> m
Link to this function

composeRT(rvec1, tvec1, rvec2, tvec2)

View Source

Combines two rotation-and-shift transformations.

Positional Arguments
  • rvec1: Evision.Mat.t().

    First rotation vector.

  • tvec1: Evision.Mat.t().

    First translation vector.

  • rvec2: Evision.Mat.t().

    Second rotation vector.

  • tvec2: Evision.Mat.t().

    Second translation vector.

Return
  • rvec3: Evision.Mat.t().

    Output rotation vector of the superposition.

  • tvec3: Evision.Mat.t().

    Output translation vector of the superposition.

  • dr3dr1: Evision.Mat.t().

    Optional output derivative of rvec3 with regard to rvec1

  • dr3dt1: Evision.Mat.t().

    Optional output derivative of rvec3 with regard to tvec1

  • dr3dr2: Evision.Mat.t().

    Optional output derivative of rvec3 with regard to rvec2

  • dr3dt2: Evision.Mat.t().

    Optional output derivative of rvec3 with regard to tvec2

  • dt3dr1: Evision.Mat.t().

    Optional output derivative of tvec3 with regard to rvec1

  • dt3dt1: Evision.Mat.t().

    Optional output derivative of tvec3 with regard to tvec1

  • dt3dr2: Evision.Mat.t().

    Optional output derivative of tvec3 with regard to rvec2

  • dt3dt2: Evision.Mat.t().

    Optional output derivative of tvec3 with regard to tvec2

The functions compute: \f[\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} ,\f] where \f$\mathrm{rodrigues}\f$ denotes a rotation vector to a rotation matrix transformation, and \f$\mathrm{rodrigues}^{-1}\f$ 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.

Python prototype (for reference only):

composeRT(rvec1, tvec1, rvec2, tvec2[, rvec3[, tvec3[, dr3dr1[, dr3dt1[, dr3dr2[, dr3dt2[, dt3dr1[, dt3dt1[, dt3dr2[, dt3dt2]]]]]]]]]]) -> rvec3, tvec3, dr3dr1, dr3dt1, dr3dr2, dr3dt2, dt3dr1, dt3dt1, dt3dr2, dt3dt2
Link to this function

composeRT(rvec1, tvec1, rvec2, tvec2, opts)

View Source

Combines two rotation-and-shift transformations.

Positional Arguments
  • rvec1: Evision.Mat.t().

    First rotation vector.

  • tvec1: Evision.Mat.t().

    First translation vector.

  • rvec2: Evision.Mat.t().

    Second rotation vector.

  • tvec2: Evision.Mat.t().

    Second translation vector.

Return
  • rvec3: Evision.Mat.t().

    Output rotation vector of the superposition.

  • tvec3: Evision.Mat.t().

    Output translation vector of the superposition.

  • dr3dr1: Evision.Mat.t().

    Optional output derivative of rvec3 with regard to rvec1

  • dr3dt1: Evision.Mat.t().

    Optional output derivative of rvec3 with regard to tvec1

  • dr3dr2: Evision.Mat.t().

    Optional output derivative of rvec3 with regard to rvec2

  • dr3dt2: Evision.Mat.t().

    Optional output derivative of rvec3 with regard to tvec2

  • dt3dr1: Evision.Mat.t().

    Optional output derivative of tvec3 with regard to rvec1

  • dt3dt1: Evision.Mat.t().

    Optional output derivative of tvec3 with regard to tvec1

  • dt3dr2: Evision.Mat.t().

    Optional output derivative of tvec3 with regard to rvec2

  • dt3dt2: Evision.Mat.t().

    Optional output derivative of tvec3 with regard to tvec2

The functions compute: \f[\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} ,\f] where \f$\mathrm{rodrigues}\f$ denotes a rotation vector to a rotation matrix transformation, and \f$\mathrm{rodrigues}^{-1}\f$ 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.

Python prototype (for reference only):

composeRT(rvec1, tvec1, rvec2, tvec2[, rvec3[, tvec3[, dr3dr1[, dr3dt1[, dr3dr2[, dr3dt2[, dt3dr1[, dt3dt1[, dt3dr2[, dt3dt2]]]]]]]]]]) -> rvec3, tvec3, dr3dr1, dr3dt1, dr3dr2, dr3dt2, dt3dr1, dt3dt1, dt3dr2, dt3dt2
Link to this function

computeCorrespondEpilines(points, whichImage, f)

View Source
@spec computeCorrespondEpilines(
  Evision.Mat.maybe_mat_in(),
  integer(),
  Evision.Mat.maybe_mat_in()
) ::
  Evision.Mat.t() | {:error, String.t()}

For points in an image of a stereo pair, computes the corresponding epilines in the other image.

Positional Arguments
  • points: Evision.Mat.t().

    Input points. \f$N \times 1\f$ or \f$1 \times N\f$ matrix of type CV_32FC2 or vector\<Point2f> .

  • whichImage: int.

    Index of the image (1 or 2) that contains the points .

  • f: Evision.Mat.t().

    Fundamental matrix that can be estimated using #findFundamentalMat or #stereoRectify .

Return
  • lines: Evision.Mat.t().

    Output vector of the epipolar lines corresponding to the points in the other image. Each line \f$ax + by + c=0\f$ is encoded by 3 numbers \f$(a, b, c)\f$ .

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 \f$l^{(2)}_i\f$ in the second image for the point \f$p^{(1)}_i\f$ in the first image (when whichImage=1 ) is computed as: \f[l^{(2)}_i = F p^{(1)}_i\f] And vice versa, when whichImage=2, \f$l^{(1)}_i\f$ is computed from \f$p^{(2)}_i\f$ as: \f[l^{(1)}_i = F^T p^{(2)}_i\f] Line coefficients are defined up to a scale. They are normalized so that \f$a_i^2+b_i^2=1\f$ .

Python prototype (for reference only):

computeCorrespondEpilines(points, whichImage, F[, lines]) -> lines
Link to this function

computeCorrespondEpilines(points, whichImage, f, opts)

View Source
@spec computeCorrespondEpilines(
  Evision.Mat.maybe_mat_in(),
  integer(),
  Evision.Mat.maybe_mat_in(),
  [{atom(), term()}, ...] | nil
) :: Evision.Mat.t() | {:error, String.t()}

For points in an image of a stereo pair, computes the corresponding epilines in the other image.

Positional Arguments
  • points: Evision.Mat.t().

    Input points. \f$N \times 1\f$ or \f$1 \times N\f$ matrix of type CV_32FC2 or vector\<Point2f> .

  • whichImage: int.

    Index of the image (1 or 2) that contains the points .

  • f: Evision.Mat.t().

    Fundamental matrix that can be estimated using #findFundamentalMat or #stereoRectify .

Return
  • lines: Evision.Mat.t().

    Output vector of the epipolar lines corresponding to the points in the other image. Each line \f$ax + by + c=0\f$ is encoded by 3 numbers \f$(a, b, c)\f$ .

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 \f$l^{(2)}_i\f$ in the second image for the point \f$p^{(1)}_i\f$ in the first image (when whichImage=1 ) is computed as: \f[l^{(2)}_i = F p^{(1)}_i\f] And vice versa, when whichImage=2, \f$l^{(1)}_i\f$ is computed from \f$p^{(2)}_i\f$ as: \f[l^{(1)}_i = F^T p^{(2)}_i\f] Line coefficients are defined up to a scale. They are normalized so that \f$a_i^2+b_i^2=1\f$ .

Python prototype (for reference only):

computeCorrespondEpilines(points, whichImage, F[, lines]) -> lines
Link to this function

computeECC(templateImage, inputImage)

View Source
@spec computeECC(Evision.Mat.maybe_mat_in(), Evision.Mat.maybe_mat_in()) ::
  number() | {:error, String.t()}

Computes the Enhanced Correlation Coefficient value between two images @cite EP08 .

Positional Arguments
  • templateImage: Evision.Mat.t().

    single-channel template image; CV_8U or CV_32F array.

  • inputImage: Evision.Mat.t().

    single-channel input image to be warped to provide an image similar to templateImage, same type as templateImage.

Keyword Arguments
  • inputMask: Evision.Mat.t().

    An optional mask to indicate valid values of inputImage.

Return
  • retval: double

@sa findTransformECC

Python prototype (for reference only):

computeECC(templateImage, inputImage[, inputMask]) -> retval
Link to this function

computeECC(templateImage, inputImage, opts)

View Source
@spec computeECC(
  Evision.Mat.maybe_mat_in(),
  Evision.Mat.maybe_mat_in(),
  [{atom(), term()}, ...] | nil
) ::
  number() | {:error, String.t()}

Computes the Enhanced Correlation Coefficient value between two images @cite EP08 .

Positional Arguments
  • templateImage: Evision.Mat.t().

    single-channel template image; CV_8U or CV_32F array.

  • inputImage: Evision.Mat.t().

    single-channel input image to be warped to provide an image similar to templateImage, same type as templateImage.

Keyword Arguments
  • inputMask: Evision.Mat.t().

    An optional mask to indicate valid values of inputImage.

Return
  • retval: double

@sa findTransformECC

Python prototype (for reference only):

computeECC(templateImage, inputImage[, inputMask]) -> retval
Link to this function

connectedComponents(image)

View Source
@spec connectedComponents(Evision.Mat.maybe_mat_in()) ::
  {integer(), Evision.Mat.t()} | {:error, String.t()}

connectedComponents

Positional Arguments
  • image: Evision.Mat.t().

    the 8-bit single-channel image to be labeled

Keyword Arguments
  • connectivity: int.

    8 or 4 for 8-way or 4-way connectivity respectively

  • ltype: int.

    output image label type. Currently CV_32S and CV_16U are supported.

Return
  • retval: int

  • labels: Evision.Mat.t().

    destination labeled image

Has overloading in C++

Python prototype (for reference only):

connectedComponents(image[, labels[, connectivity[, ltype]]]) -> retval, labels
Link to this function

connectedComponents(image, opts)

View Source
@spec connectedComponents(Evision.Mat.maybe_mat_in(), [{atom(), term()}, ...] | nil) ::
  {integer(), Evision.Mat.t()} | {:error, String.t()}

connectedComponents

Positional Arguments
  • image: Evision.Mat.t().

    the 8-bit single-channel image to be labeled

Keyword Arguments
  • connectivity: int.

    8 or 4 for 8-way or 4-way connectivity respectively

  • ltype: int.

    output image label type. Currently CV_32S and CV_16U are supported.

Return
  • retval: int

  • labels: Evision.Mat.t().

    destination labeled image

Has overloading in C++

Python prototype (for reference only):

connectedComponents(image[, labels[, connectivity[, ltype]]]) -> retval, labels
Link to this function

connectedComponentsWithAlgorithm(image, connectivity, ltype, ccltype)

View Source
@spec connectedComponentsWithAlgorithm(
  Evision.Mat.maybe_mat_in(),
  integer(),
  integer(),
  integer()
) ::
  {integer(), Evision.Mat.t()} | {:error, String.t()}

computes the connected components labeled image of boolean image

Positional Arguments
  • image: Evision.Mat.t().

    the 8-bit single-channel image to be labeled

  • connectivity: int.

    8 or 4 for 8-way or 4-way connectivity respectively

  • ltype: int.

    output image label type. Currently CV_32S and CV_16U are supported.

  • ccltype: int.

    connected components algorithm type (see the #ConnectedComponentsAlgorithmsTypes).

Return
  • retval: int

  • labels: Evision.Mat.t().

    destination labeled 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.

Python prototype (for reference only):

connectedComponentsWithAlgorithm(image, connectivity, ltype, ccltype[, labels]) -> retval, labels
Link to this function

connectedComponentsWithAlgorithm(image, connectivity, ltype, ccltype, opts)

View Source
@spec connectedComponentsWithAlgorithm(
  Evision.Mat.maybe_mat_in(),
  integer(),
  integer(),
  integer(),
  [{atom(), term()}, ...] | nil
) :: {integer(), Evision.Mat.t()} | {:error, String.t()}

computes the connected components labeled image of boolean image

Positional Arguments
  • image: Evision.Mat.t().

    the 8-bit single-channel image to be labeled

  • connectivity: int.

    8 or 4 for 8-way or 4-way connectivity respectively

  • ltype: int.

    output image label type. Currently CV_32S and CV_16U are supported.

  • ccltype: int.

    connected components algorithm type (see the #ConnectedComponentsAlgorithmsTypes).

Return
  • retval: int

  • labels: Evision.Mat.t().

    destination labeled 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.

Python prototype (for reference only):

connectedComponentsWithAlgorithm(image, connectivity, ltype, ccltype[, labels]) -> retval, labels
Link to this function

connectedComponentsWithStats(image)

View Source
@spec connectedComponentsWithStats(Evision.Mat.maybe_mat_in()) ::
  {integer(), Evision.Mat.t(), Evision.Mat.t(), Evision.Mat.t()}
  | {:error, String.t()}

connectedComponentsWithStats

Positional Arguments
  • image: Evision.Mat.t().

    the 8-bit single-channel image to be labeled

Keyword Arguments
  • connectivity: int.

    8 or 4 for 8-way or 4-way connectivity respectively

  • ltype: int.

    output image label type. Currently CV_32S and CV_16U are supported.

Return
  • retval: int

  • labels: Evision.Mat.t().

    destination labeled image

  • stats: Evision.Mat.t().

    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: Evision.Mat.t().

    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.

Has overloading in C++

Python prototype (for reference only):

connectedComponentsWithStats(image[, labels[, stats[, centroids[, connectivity[, ltype]]]]]) -> retval, labels, stats, centroids
Link to this function

connectedComponentsWithStats(image, opts)

View Source
@spec connectedComponentsWithStats(
  Evision.Mat.maybe_mat_in(),
  [{atom(), term()}, ...] | nil
) ::
  {integer(), Evision.Mat.t(), Evision.Mat.t(), Evision.Mat.t()}
  | {:error, String.t()}

connectedComponentsWithStats

Positional Arguments
  • image: Evision.Mat.t().

    the 8-bit single-channel image to be labeled

Keyword Arguments
  • connectivity: int.

    8 or 4 for 8-way or 4-way connectivity respectively

  • ltype: int.

    output image label type. Currently CV_32S and CV_16U are supported.

Return
  • retval: int

  • labels: Evision.Mat.t().

    destination labeled image

  • stats: Evision.Mat.t().

    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: Evision.Mat.t().

    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.

Has overloading in C++

Python prototype (for reference only):

connectedComponentsWithStats(image[, labels[, stats[, centroids[, connectivity[, ltype]]]]]) -> retval, labels, stats, centroids
Link to this function

connectedComponentsWithStatsWithAlgorithm(image, connectivity, ltype, ccltype)

View Source
@spec connectedComponentsWithStatsWithAlgorithm(
  Evision.Mat.maybe_mat_in(),
  integer(),
  integer(),
  integer()
) ::
  {integer(), Evision.Mat.t(), Evision.Mat.t(), Evision.Mat.t()}
  | {:error, String.t()}

computes the connected components labeled image of boolean image and also produces a statistics output for each label

Positional Arguments
  • image: Evision.Mat.t().

    the 8-bit single-channel image to be labeled

  • connectivity: int.

    8 or 4 for 8-way or 4-way connectivity respectively

  • ltype: int.

    output image label type. Currently CV_32S and CV_16U are supported.

  • ccltype: int.

    connected components algorithm type (see #ConnectedComponentsAlgorithmsTypes).

Return
  • retval: int

  • labels: Evision.Mat.t().

    destination labeled image

  • stats: Evision.Mat.t().

    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: Evision.Mat.t().

    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.

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.

Python prototype (for reference only):

connectedComponentsWithStatsWithAlgorithm(image, connectivity, ltype, ccltype[, labels[, stats[, centroids]]]) -> retval, labels, stats, centroids
Link to this function

connectedComponentsWithStatsWithAlgorithm(image, connectivity, ltype, ccltype, opts)

View Source
@spec connectedComponentsWithStatsWithAlgorithm(
  Evision.Mat.maybe_mat_in(),
  integer(),
  integer(),
  integer(),
  [{atom(), term()}, ...] | nil
) ::
  {integer(), Evision.Mat.t(), Evision.Mat.t(), Evision.Mat.t()}
  | {:error, String.t()}

computes the connected components labeled image of boolean image and also produces a statistics output for each label

Positional Arguments
  • image: Evision.Mat.t().

    the 8-bit single-channel image to be labeled

  • connectivity: int.

    8 or 4 for 8-way or 4-way connectivity respectively

  • ltype: int.

    output image label type. Currently CV_32S and CV_16U are supported.

  • ccltype: int.

    connected components algorithm type (see #ConnectedComponentsAlgorithmsTypes).

Return
  • retval: int

  • labels: Evision.Mat.t().

    destination labeled image

  • stats: Evision.Mat.t().

    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: Evision.Mat.t().

    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.

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.

Python prototype (for reference only):

connectedComponentsWithStatsWithAlgorithm(image, connectivity, ltype, ccltype[, labels[, stats[, centroids]]]) -> retval, labels, stats, centroids
@spec contourArea(Evision.Mat.maybe_mat_in()) :: number() | {:error, String.t()}

Calculates a contour area.

Positional Arguments
  • contour: Evision.Mat.t().

    Input vector of 2D points (contour vertices), stored in std::vector or Mat.

Keyword Arguments
  • oriented: bool.

    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.

Return
  • retval: double

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;

Python prototype (for reference only):

contourArea(contour[, oriented]) -> retval
Link to this function

contourArea(contour, opts)

View Source
@spec contourArea(Evision.Mat.maybe_mat_in(), [{atom(), term()}, ...] | nil) ::
  number() | {:error, String.t()}

Calculates a contour area.

Positional Arguments
  • contour: Evision.Mat.t().

    Input vector of 2D points (contour vertices), stored in std::vector or Mat.

Keyword Arguments
  • oriented: bool.

    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.

Return
  • retval: double

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;

Python prototype (for reference only):

contourArea(contour[, oriented]) -> retval
@spec convertFp16(Evision.Mat.maybe_mat_in()) ::
  Evision.Mat.t() | {:error, String.t()}

Converts an array to half precision floating number.

Positional Arguments
  • src: Evision.Mat.t().

    input array.

Return
  • dst: Evision.Mat.t().

    output array.

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.

Python prototype (for reference only):

convertFp16(src[, dst]) -> dst
@spec convertFp16(Evision.Mat.maybe_mat_in(), [{atom(), term()}, ...] | nil) ::
  Evision.Mat.t() | {:error, String.t()}

Converts an array to half precision floating number.

Positional Arguments
  • src: Evision.Mat.t().

    input array.

Return
  • dst: Evision.Mat.t().

    output array.

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.

Python prototype (for reference only):

convertFp16(src[, dst]) -> dst
Link to this function

convertMaps(map1, map2, dstmap1type)

View Source

Converts image transformation maps from one representation to another.

Positional Arguments
  • map1: Evision.Mat.t().

    The first input map of type CV_16SC2, CV_32FC1, or CV_32FC2 .

  • map2: Evision.Mat.t().

    The second input map of type CV_16UC1, CV_32FC1, or none (empty matrix), respectively.

  • dstmap1type: int.

    Type of the first output map that should be CV_16SC2, CV_32FC1, or CV_32FC2 .

Keyword Arguments
  • nninterpolation: bool.

    Flag indicating whether the fixed-point maps are used for the nearest-neighbor or for a more complex interpolation.

Return
  • dstmap1: Evision.Mat.t().

    The first output map that has the type dstmap1type and the same size as src .

  • dstmap2: Evision.Mat.t().

    The second output map.

The function converts a pair of maps for remap from one representation to another. The following options ( (map1.type(), map2.type()) \f$\rightarrow\f$ (dstmap1.type(), dstmap2.type()) ) are supported:

  • \f$\texttt{(CV_32FC1, CV_32FC1)} \rightarrow \texttt{(CV_16SC2, CV_16UC1)}\f$. 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.

  • \f$\texttt{(CV_32FC2)} \rightarrow \texttt{(CV_16SC2, CV_16UC1)}\f$. 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.

@sa remap, undistort, initUndistortRectifyMap

Python prototype (for reference only):

convertMaps(map1, map2, dstmap1type[, dstmap1[, dstmap2[, nninterpolation]]]) -> dstmap1, dstmap2
Link to this function

convertMaps(map1, map2, dstmap1type, opts)

View Source
@spec convertMaps(
  Evision.Mat.maybe_mat_in(),
  Evision.Mat.maybe_mat_in(),
  integer(),
  [{atom(), term()}, ...] | nil
) :: {Evision.Mat.t(), Evision.Mat.t()} | {:error, String.t()}

Converts image transformation maps from one representation to another.

Positional Arguments
  • map1: Evision.Mat.t().

    The first input map of type CV_16SC2, CV_32FC1, or CV_32FC2 .

  • map2: Evision.Mat.t().

    The second input map of type CV_16UC1, CV_32FC1, or none (empty matrix), respectively.

  • dstmap1type: int.

    Type of the first output map that should be CV_16SC2, CV_32FC1, or CV_32FC2 .

Keyword Arguments
  • nninterpolation: bool.

    Flag indicating whether the fixed-point maps are used for the nearest-neighbor or for a more complex interpolation.

Return
  • dstmap1: Evision.Mat.t().

    The first output map that has the type dstmap1type and the same size as src .

  • dstmap2: Evision.Mat.t().

    The second output map.

The function converts a pair of maps for remap from one representation to another. The following options ( (map1.type(), map2.type()) \f$\rightarrow\f$ (dstmap1.type(), dstmap2.type()) ) are supported:

  • \f$\texttt{(CV_32FC1, CV_32FC1)} \rightarrow \texttt{(CV_16SC2, CV_16UC1)}\f$. 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.

  • \f$\texttt{(CV_32FC2)} \rightarrow \texttt{(CV_16SC2, CV_16UC1)}\f$. 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.

@sa remap, undistort, initUndistortRectifyMap

Python prototype (for reference only):

convertMaps(map1, map2, dstmap1type[, dstmap1[, dstmap2[, nninterpolation]]]) -> dstmap1, dstmap2
Link to this function

convertPointsFromHomogeneous(src)

View Source
@spec convertPointsFromHomogeneous(Evision.Mat.maybe_mat_in()) ::
  Evision.Mat.t() | {:error, String.t()}

Converts points from homogeneous to Euclidean space.

Positional Arguments
  • src: Evision.Mat.t().

    Input vector of N-dimensional points.

Return
  • dst: Evision.Mat.t().

    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,...).

Python prototype (for reference only):

convertPointsFromHomogeneous(src[, dst]) -> dst
Link to this function

convertPointsFromHomogeneous(src, opts)

View Source
@spec convertPointsFromHomogeneous(
  Evision.Mat.maybe_mat_in(),
  [{atom(), term()}, ...] | nil
) ::
  Evision.Mat.t() | {:error, String.t()}

Converts points from homogeneous to Euclidean space.

Positional Arguments
  • src: Evision.Mat.t().

    Input vector of N-dimensional points.

Return
  • dst: Evision.Mat.t().

    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,...).

Python prototype (for reference only):

convertPointsFromHomogeneous(src[, dst]) -> dst
Link to this function

convertPointsToHomogeneous(src)

View Source
@spec convertPointsToHomogeneous(Evision.Mat.maybe_mat_in()) ::
  Evision.Mat.t() | {:error, String.t()}

Converts points from Euclidean to homogeneous space.

Positional Arguments
  • src: Evision.Mat.t().

    Input vector of N-dimensional points.

Return
  • dst: Evision.Mat.t().

    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).

Python prototype (for reference only):

convertPointsToHomogeneous(src[, dst]) -> dst
Link to this function

convertPointsToHomogeneous(src, opts)

View Source
@spec convertPointsToHomogeneous(
  Evision.Mat.maybe_mat_in(),
  [{atom(), term()}, ...] | nil
) ::
  Evision.Mat.t() | {:error, String.t()}

Converts points from Euclidean to homogeneous space.

Positional Arguments
  • src: Evision.Mat.t().

    Input vector of N-dimensional points.

Return
  • dst: Evision.Mat.t().

    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).

Python prototype (for reference only):

convertPointsToHomogeneous(src[, dst]) -> dst
@spec convertScaleAbs(Evision.Mat.maybe_mat_in()) ::
  Evision.Mat.t() | {:error, String.t()}

Scales, calculates absolute values, and converts the result to 8-bit.

Positional Arguments
  • src: Evision.Mat.t().

    input array.

Keyword Arguments
  • alpha: double.

    optional scale factor.

  • beta: double.

    optional delta added to the scaled values.

Return
  • dst: Evision.Mat.t().

    output array.

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: \f[\texttt{dst} (I)= \texttt{saturate\_cast<uchar>} (| \texttt{src} (I)* \texttt{alpha} + \texttt{beta} |)\f] 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

@sa Mat::convertTo, cv::abs(const Mat&)

Python prototype (for reference only):

convertScaleAbs(src[, dst[, alpha[, beta]]]) -> dst
Link to this function

convertScaleAbs(src, opts)

View Source
@spec convertScaleAbs(Evision.Mat.maybe_mat_in(), [{atom(), term()}, ...] | nil) ::
  Evision.Mat.t() | {:error, String.t()}

Scales, calculates absolute values, and converts the result to 8-bit.

Positional Arguments
  • src: Evision.Mat.t().

    input array.

Keyword Arguments
  • alpha: double.

    optional scale factor.

  • beta: double.

    optional delta added to the scaled values.

Return
  • dst: Evision.Mat.t().

    output array.

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: \f[\texttt{dst} (I)= \texttt{saturate\_cast<uchar>} (| \texttt{src} (I)* \texttt{alpha} + \texttt{beta} |)\f] 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

@sa Mat::convertTo, cv::abs(const Mat&)

Python prototype (for reference only):

convertScaleAbs(src[, dst[, alpha[, beta]]]) -> dst
@spec convexHull(Evision.Mat.maybe_mat_in()) :: Evision.Mat.t() | {:error, String.t()}

Finds the convex hull of a point set.

Positional Arguments
  • points: Evision.Mat.t().

    Input 2D point set, stored in std::vector or Mat.

Keyword Arguments
  • clockwise: bool.

    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.

  • returnPoints: bool.

    Operation flag. In case of a matrix, when the flag is true, the function 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.

Return
  • hull: Evision.Mat.t().

    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.

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.

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/

Python prototype (for reference only):

convexHull(points[, hull[, clockwise[, returnPoints]]]) -> hull
Link to this function

convexHull(points, opts)

View Source
@spec convexHull(Evision.Mat.maybe_mat_in(), [{atom(), term()}, ...] | nil) ::
  Evision.Mat.t() | {:error, String.t()}

Finds the convex hull of a point set.

Positional Arguments
  • points: Evision.Mat.t().

    Input 2D point set, stored in std::vector or Mat.

Keyword Arguments
  • clockwise: bool.

    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.

  • returnPoints: bool.

    Operation flag. In case of a matrix, when the flag is true, the function 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.

Return
  • hull: Evision.Mat.t().

    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.

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.

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/

Python prototype (for reference only):

convexHull(points[, hull[, clockwise[, returnPoints]]]) -> hull
Link to this function

convexityDefects(contour, convexhull)

View Source
@spec convexityDefects(Evision.Mat.maybe_mat_in(), Evision.Mat.maybe_mat_in()) ::
  Evision.Mat.t() | {:error, String.t()}

Finds the convexity defects of a contour.

Positional Arguments
  • contour: Evision.Mat.t().

    Input contour.

  • convexhull: Evision.Mat.t().

    Convex hull obtained using convexHull that should contain indices of the contour points that make the hull.

Return
  • convexityDefects: Evision.Mat.t().

    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.

The figure below displays convexity defects of a hand contour: image

Python prototype (for reference only):

convexityDefects(contour, convexhull[, convexityDefects]) -> convexityDefects
Link to this function

convexityDefects(contour, convexhull, opts)

View Source
@spec convexityDefects(
  Evision.Mat.maybe_mat_in(),
  Evision.Mat.maybe_mat_in(),
  [{atom(), term()}, ...] | nil
) :: Evision.Mat.t() | {:error, String.t()}

Finds the convexity defects of a contour.

Positional Arguments
  • contour: Evision.Mat.t().

    Input contour.

  • convexhull: Evision.Mat.t().

    Convex hull obtained using convexHull that should contain indices of the contour points that make the hull.

Return
  • convexityDefects: Evision.Mat.t().

    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.

The figure below displays convexity defects of a hand contour: image

Python prototype (for reference only):

convexityDefects(contour, convexhull[, convexityDefects]) -> convexityDefects
Link to this function

copyMakeBorder(src, top, bottom, left, right, borderType)

View Source
@spec copyMakeBorder(
  Evision.Mat.maybe_mat_in(),
  integer(),
  integer(),
  integer(),
  integer(),
  integer()
) ::
  Evision.Mat.t() | {:error, String.t()}

Forms a border around an image.

Positional Arguments
  • src: Evision.Mat.t().

    Source image.

  • top: int.

    the top pixels

  • bottom: int.

    the bottom pixels

  • left: int.

    the left pixels

  • right: int.

    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: int.

    Border type. See borderInterpolate for details.

Keyword Arguments
  • value: Scalar.

    Border value if borderType==BORDER_CONSTANT .

Return
  • dst: Evision.Mat.t().

    Destination image of the same type as src and the size Size(src.cols+left+right, src.rows+top+bottom) .

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.

@sa borderInterpolate

Python prototype (for reference only):

copyMakeBorder(src, top, bottom, left, right, borderType[, dst[, value]]) -> dst
Link to this function

copyMakeBorder(src, top, bottom, left, right, borderType, opts)

View Source
@spec copyMakeBorder(
  Evision.Mat.maybe_mat_in(),
  integer(),
  integer(),
  integer(),
  integer(),
  integer(),
  [{atom(), term()}, ...] | nil
) :: Evision.Mat.t() | {:error, String.t()}

Forms a border around an image.

Positional Arguments
  • src: Evision.Mat.t().

    Source image.

  • top: int.

    the top pixels

  • bottom: int.

    the bottom pixels

  • left: int.

    the left pixels

  • right: int.

    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: int.

    Border type. See borderInterpolate for details.

Keyword Arguments
  • value: Scalar.

    Border value if borderType==BORDER_CONSTANT .

Return
  • dst: Evision.Mat.t().

    Destination image of the same type as src and the size Size(src.cols+left+right, src.rows+top+bottom) .

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.

@sa borderInterpolate

Python prototype (for reference only):

copyMakeBorder(src, top, bottom, left, right, borderType[, dst[, value]]) -> dst

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.

Positional Arguments
  • src: Evision.Mat.t().

    source matrix.

  • mask: Evision.Mat.t().

    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.

Return
  • dst: Evision.Mat.t().

    Destination matrix. If it does not have a proper size or type before the operation, it is reallocated.

Python prototype (for reference only):

copyTo(src, mask[, dst]) -> dst
@spec copyTo(
  Evision.Mat.maybe_mat_in(),
  Evision.Mat.maybe_mat_in(),
  [{atom(), term()}, ...] | nil
) ::
  Evision.Mat.t() | {:error, String.t()}

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.

Positional Arguments
  • src: Evision.Mat.t().

    source matrix.

  • mask: Evision.Mat.t().

    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.

Return
  • dst: Evision.Mat.t().

    Destination matrix. If it does not have a proper size or type before the operation, it is reallocated.

Python prototype (for reference only):

copyTo(src, mask[, dst]) -> dst
Link to this function

cornerEigenValsAndVecs(src, blockSize, ksize)

View Source
@spec cornerEigenValsAndVecs(Evision.Mat.maybe_mat_in(), integer(), integer()) ::
  Evision.Mat.t() | {:error, String.t()}

Calculates eigenvalues and eigenvectors of image blocks for corner detection.

Positional Arguments
  • src: Evision.Mat.t().

    Input single-channel 8-bit or floating-point image.

  • blockSize: int.

    Neighborhood size (see details below).

  • ksize: int.

    Aperture parameter for the Sobel operator.

Keyword Arguments
  • borderType: int.

    Pixel extrapolation method. See #BorderTypes. #BORDER_WRAP is not supported.

Return
  • dst: Evision.Mat.t().

    Image to store the results. It has the same size as src and the type CV_32FC(6) .

For every pixel \f$p\f$ , the function cornerEigenValsAndVecs considers a blockSize \f$\times\f$ blockSize neighborhood \f$S(p)\f$ . It calculates the covariation matrix of derivatives over the neighborhood as: \f[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}\f] where the derivatives are computed using the Sobel operator. After that, it finds eigenvectors and eigenvalues of \f$M\f$ and stores them in the destination image as \f$(\lambda_1, \lambda_2, x_1, y_1, x_2, y_2)\f$ where

  • \f$\lambda_1, \lambda_2\f$ are the non-sorted eigenvalues of \f$M\f$
  • \f$x_1, y_1\f$ are the eigenvectors corresponding to \f$\lambda_1\f$
  • \f$x_2, y_2\f$ are the eigenvectors corresponding to \f$\lambda_2\f$

The output of the function can be used for robust edge or corner detection.

@sa cornerMinEigenVal, cornerHarris, preCornerDetect

Python prototype (for reference only):

cornerEigenValsAndVecs(src, blockSize, ksize[, dst[, borderType]]) -> dst
Link to this function

cornerEigenValsAndVecs(src, blockSize, ksize, opts)

View Source
@spec cornerEigenValsAndVecs(
  Evision.Mat.maybe_mat_in(),
  integer(),
  integer(),
  [{atom(), term()}, ...] | nil
) :: Evision.Mat.t() | {:error, String.t()}

Calculates eigenvalues and eigenvectors of image blocks for corner detection.

Positional Arguments
  • src: Evision.Mat.t().

    Input single-channel 8-bit or floating-point image.

  • blockSize: int.

    Neighborhood size (see details below).

  • ksize: int.

    Aperture parameter for the Sobel operator.

Keyword Arguments
  • borderType: int.

    Pixel extrapolation method. See #BorderTypes. #BORDER_WRAP is not supported.

Return
  • dst: Evision.Mat.t().

    Image to store the results. It has the same size as src and the type CV_32FC(6) .

For every pixel \f$p\f$ , the function cornerEigenValsAndVecs considers a blockSize \f$\times\f$ blockSize neighborhood \f$S(p)\f$ . It calculates the covariation matrix of derivatives over the neighborhood as: \f[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}\f] where the derivatives are computed using the Sobel operator. After that, it finds eigenvectors and eigenvalues of \f$M\f$ and stores them in the destination image as \f$(\lambda_1, \lambda_2, x_1, y_1, x_2, y_2)\f$ where

  • \f$\lambda_1, \lambda_2\f$ are the non-sorted eigenvalues of \f$M\f$
  • \f$x_1, y_1\f$ are the eigenvectors corresponding to \f$\lambda_1\f$
  • \f$x_2, y_2\f$ are the eigenvectors corresponding to \f$\lambda_2\f$

The output of the function can be used for robust edge or corner detection.

@sa cornerMinEigenVal, cornerHarris, preCornerDetect

Python prototype (for reference only):

cornerEigenValsAndVecs(src, blockSize, ksize[, dst[, borderType]]) -> dst
Link to this function

cornerHarris(src, blockSize, ksize, k)

View Source
@spec cornerHarris(Evision.Mat.maybe_mat_in(), integer(), integer(), number()) ::
  Evision.Mat.t() | {:error, String.t()}

Harris corner detector.

Positional Arguments
  • src: Evision.Mat.t().

    Input single-channel 8-bit or floating-point image.

  • blockSize: int.

    Neighborhood size (see the details on #cornerEigenValsAndVecs ).

  • ksize: int.

    Aperture parameter for the Sobel operator.

  • k: double.

    Harris detector free parameter. See the formula above.

Keyword Arguments
  • borderType: int.

    Pixel extrapolation method. See #BorderTypes. #BORDER_WRAP is not supported.

Return
  • dst: Evision.Mat.t().

    Image to store the Harris detector responses. It has the type CV_32FC1 and the same size as src .

The function runs the Harris corner detector on the image. Similarly to cornerMinEigenVal and cornerEigenValsAndVecs , for each pixel \f$(x, y)\f$ it calculates a \f$2\times2\f$ gradient covariance matrix \f$M^{(x,y)}\f$ over a \f$\texttt{blockSize} \times \texttt{blockSize}\f$ neighborhood. Then, it computes the following characteristic: \f[\texttt{dst} (x,y) = \mathrm{det} M^{(x,y)} - k \cdot \left ( \mathrm{tr} M^{(x,y)} \right )^2\f] Corners in the image can be found as the local maxima of this response map.

Python prototype (for reference only):

cornerHarris(src, blockSize, ksize, k[, dst[, borderType]]) -> dst
Link to this function

cornerHarris(src, blockSize, ksize, k, opts)

View Source
@spec cornerHarris(
  Evision.Mat.maybe_mat_in(),
  integer(),
  integer(),
  number(),
  [{atom(), term()}, ...] | nil
) :: Evision.Mat.t() | {:error, String.t()}

Harris corner detector.

Positional Arguments
  • src: Evision.Mat.t().

    Input single-channel 8-bit or floating-point image.

  • blockSize: int.

    Neighborhood size (see the details on #cornerEigenValsAndVecs ).

  • ksize: int.

    Aperture parameter for the Sobel operator.

  • k: double.

    Harris detector free parameter. See the formula above.

Keyword Arguments
  • borderType: int.

    Pixel extrapolation method. See #BorderTypes. #BORDER_WRAP is not supported.

Return
  • dst: Evision.Mat.t().

    Image to store the Harris detector responses. It has the type CV_32FC1 and the same size as src .

The function runs the Harris corner detector on the image. Similarly to cornerMinEigenVal and cornerEigenValsAndVecs , for each pixel \f$(x, y)\f$ it calculates a \f$2\times2\f$ gradient covariance matrix \f$M^{(x,y)}\f$ over a \f$\texttt{blockSize} \times \texttt{blockSize}\f$ neighborhood. Then, it computes the following characteristic: \f[\texttt{dst} (x,y) = \mathrm{det} M^{(x,y)} - k \cdot \left ( \mathrm{tr} M^{(x,y)} \right )^2\f] Corners in the image can be found as the local maxima of this response map.

Python prototype (for reference only):

cornerHarris(src, blockSize, ksize, k[, dst[, borderType]]) -> dst
Link to this function

cornerMinEigenVal(src, blockSize)

View Source
@spec cornerMinEigenVal(Evision.Mat.maybe_mat_in(), integer()) ::
  Evision.Mat.t() | {:error, String.t()}

Calculates the minimal eigenvalue of gradient matrices for corner detection.

Positional Arguments
  • src: Evision.Mat.t().

    Input single-channel 8-bit or floating-point image.

  • blockSize: int.

    Neighborhood size (see the details on #cornerEigenValsAndVecs ).

Keyword Arguments
  • ksize: int.

    Aperture parameter for the Sobel operator.

  • borderType: int.

    Pixel extrapolation method. See #BorderTypes. #BORDER_WRAP is not supported.

Return
  • dst: Evision.Mat.t().

    Image to store the minimal eigenvalues. It has the type CV_32FC1 and the same size as src .

The function is similar to cornerEigenValsAndVecs but it calculates and stores only the minimal eigenvalue of the covariance matrix of derivatives, that is, \f$\min(\lambda_1, \lambda_2)\f$ in terms of the formulae in the cornerEigenValsAndVecs description.

Python prototype (for reference only):

cornerMinEigenVal(src, blockSize[, dst[, ksize[, borderType]]]) -> dst
Link to this function

cornerMinEigenVal(src, blockSize, opts)

View Source
@spec cornerMinEigenVal(
  Evision.Mat.maybe_mat_in(),
  integer(),
  [{atom(), term()}, ...] | nil
) ::
  Evision.Mat.t() | {:error, String.t()}

Calculates the minimal eigenvalue of gradient matrices for corner detection.

Positional Arguments
  • src: Evision.Mat.t().

    Input single-channel 8-bit or floating-point image.

  • blockSize: int.

    Neighborhood size (see the details on #cornerEigenValsAndVecs ).

Keyword Arguments
  • ksize: int.

    Aperture parameter for the Sobel operator.

  • borderType: int.

    Pixel extrapolation method. See #BorderTypes. #BORDER_WRAP is not supported.

Return
  • dst: Evision.Mat.t().

    Image to store the minimal eigenvalues. It has the type CV_32FC1 and the same size as src .

The function is similar to cornerEigenValsAndVecs but it calculates and stores only the minimal eigenvalue of the covariance matrix of derivatives, that is, \f$\min(\lambda_1, \lambda_2)\f$ in terms of the formulae in the cornerEigenValsAndVecs description.

Python prototype (for reference only):

cornerMinEigenVal(src, blockSize[, dst[, ksize[, borderType]]]) -> dst
Link to this function

cornerSubPix(image, corners, winSize, zeroZone, criteria)

View Source
@spec cornerSubPix(
  Evision.Mat.maybe_mat_in(),
  Evision.Mat.maybe_mat_in(),
  {number(), number()},
  {number(), number()},
  {integer(), integer(), number()}
) :: Evision.Mat.t() | {:error, String.t()}

Refines the corner locations.

Positional Arguments
  • image: Evision.Mat.t().

    Input single-channel, 8-bit or float image.

  • winSize: Size.

    Half of the side length of the search window. For example, if winSize=Size(5,5) , then a \f$(52+1) \times (52+1) = 11 \times 11\f$ search window is used.

  • zeroZone: Size.

    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: TermCriteria.

    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.

Return
  • corners: Evision.Mat.t().

    Initial coordinates of the input corners and refined coordinates provided for output.

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. image Sub-pixel accurate corner locator is based on the observation that every vector from the center \f$q\f$ to a point \f$p\f$ located within a neighborhood of \f$q\f$ is orthogonal to the image gradient at \f$p\f$ subject to image and measurement noise. Consider the expression: \f[\epsilon _i = {DI_{p_i}}^T \cdot (q - p_i)\f] where \f${DI_{p_i}}\f$ is an image gradient at one of the points \f$p_i\f$ in a neighborhood of \f$q\f$ . The value of \f$q\f$ is to be found so that \f$\epsilon_i\f$ is minimized. A system of equations may be set up with \f$\epsilon_i\f$ set to zero: \f[\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)\f] where the gradients are summed within a neighborhood ("search window") of \f$q\f$ . Calling the first gradient term \f$G\f$ and the second gradient term \f$b\f$ gives: \f[q = G^{-1} \cdot b\f] The algorithm sets the center of the neighborhood window at this new center \f$q\f$ and then iterates until the center stays within a set threshold.

Python prototype (for reference only):

cornerSubPix(image, corners, winSize, zeroZone, criteria) -> corners
Link to this function

correctMatches(f, points1, points2)

View Source

Refines coordinates of corresponding points.

Positional Arguments
  • f: Evision.Mat.t().

    3x3 fundamental matrix.

  • points1: Evision.Mat.t().

    1xN array containing the first set of points.

  • points2: Evision.Mat.t().

    1xN array containing the second set of points.

Return
  • newPoints1: Evision.Mat.t().

    The optimized points1.

  • newPoints2: Evision.Mat.t().

    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 \f$d(points1[i], newPoints1[i])^2 + d(points2[i],newPoints2[i])^2\f$ (where \f$d(a,b)\f$ is the geometric distance between points \f$a\f$ and \f$b\f$ ) subject to the epipolar constraint \f$newPoints2^T \cdot F \cdot newPoints1 = 0\f$ .

Python prototype (for reference only):

correctMatches(F, points1, points2[, newPoints1[, newPoints2]]) -> newPoints1, newPoints2
Link to this function

correctMatches(f, points1, points2, opts)

View Source
@spec correctMatches(
  Evision.Mat.maybe_mat_in(),
  Evision.Mat.maybe_mat_in(),
  Evision.Mat.maybe_mat_in(),
  [{atom(), term()}, ...] | nil
) :: {Evision.Mat.t(), Evision.Mat.t()} | {:error, String.t()}

Refines coordinates of corresponding points.

Positional Arguments
  • f: Evision.Mat.t().

    3x3 fundamental matrix.

  • points1: Evision.Mat.t().

    1xN array containing the first set of points.

  • points2: Evision.Mat.t().

    1xN array containing the second set of points.

Return
  • newPoints1: Evision.Mat.t().

    The optimized points1.

  • newPoints2: Evision.Mat.t().

    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 \f$d(points1[i], newPoints1[i])^2 + d(points2[i],newPoints2[i])^2\f$ (where \f$d(a,b)\f$ is the geometric distance between points \f$a\f$ and \f$b\f$ ) subject to the epipolar constraint \f$newPoints2^T \cdot F \cdot newPoints1 = 0\f$ .

Python prototype (for reference only):

correctMatches(F, points1, points2[, newPoints1[, newPoints2]]) -> newPoints1, newPoints2
@spec countNonZero(Evision.Mat.maybe_mat_in()) :: integer() | {:error, String.t()}

Counts non-zero array elements.

Positional Arguments
  • src: Evision.Mat.t().

    single-channel array.

Return
  • retval: int

The function returns the number of non-zero elements in src : \f[\sum _{I: \; \texttt{src} (I) \ne0 } 1\f] @sa mean, meanStdDev, norm, minMaxLoc, calcCovarMatrix

Python prototype (for reference only):

countNonZero(src) -> retval
Link to this function

createAffineTransformer(fullAffine)

View Source
@spec createAffineTransformer(boolean()) ::
  Evision.AffineTransformer.t() | {:error, String.t()}

createAffineTransformer

Positional Arguments
  • fullAffine: bool
Return
  • retval: Evision.AffineTransformer.t()

Complete constructor

Python prototype (for reference only):

createAffineTransformer(fullAffine) -> retval
@spec createAlignMTB() :: Evision.AlignMTB.t() | {:error, String.t()}

Creates AlignMTB object

Keyword Arguments
  • max_bits: int.

    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: int.

    range for exclusion bitmap that is constructed to suppress noise around the median value.

  • cut: bool.

    if true cuts images, otherwise fills the new regions with zeros.

Return
  • retval: Evision.AlignMTB.t()

Python prototype (for reference only):

createAlignMTB([, max_bits[, exclude_range[, cut]]]) -> retval
@spec createAlignMTB([{atom(), term()}, ...] | nil) ::
  Evision.AlignMTB.t() | {:error, String.t()}

Creates AlignMTB object

Keyword Arguments
  • max_bits: int.

    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: int.

    range for exclusion bitmap that is constructed to suppress noise around the median value.

  • cut: bool.

    if true cuts images, otherwise fills the new regions with zeros.

Return
  • retval: Evision.AlignMTB.t()

Python prototype (for reference only):

createAlignMTB([, max_bits[, exclude_range[, cut]]]) -> retval
Link to this function

createBackgroundSubtractorKNN()

View Source
@spec createBackgroundSubtractorKNN() ::
  Evision.BackgroundSubtractorKNN.t() | {:error, String.t()}

Creates KNN Background Subtractor

Keyword Arguments
  • history: int.

    Length of the history.

  • dist2Threshold: double.

    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: bool.

    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.

Return
  • retval: Evision.BackgroundSubtractorKNN.t()

Python prototype (for reference only):

createBackgroundSubtractorKNN([, history[, dist2Threshold[, detectShadows]]]) -> retval
Link to this function

createBackgroundSubtractorKNN(opts)

View Source
@spec createBackgroundSubtractorKNN([{atom(), term()}, ...] | nil) ::
  Evision.BackgroundSubtractorKNN.t() | {:error, String.t()}

Creates KNN Background Subtractor

Keyword Arguments
  • history: int.

    Length of the history.

  • dist2Threshold: double.

    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: bool.

    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.

Return
  • retval: Evision.BackgroundSubtractorKNN.t()

Python prototype (for reference only):

createBackgroundSubtractorKNN([, history[, dist2Threshold[, detectShadows]]]) -> retval
Link to this function

createBackgroundSubtractorMOG2()

View Source
@spec createBackgroundSubtractorMOG2() ::
  Evision.BackgroundSubtractorMOG2.t() | {:error, String.t()}

Creates MOG2 Background Subtractor

Keyword Arguments
  • history: int.

    Length of the history.

  • varThreshold: double.

    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: bool.

    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.

Return
  • retval: Evision.BackgroundSubtractorMOG2.t()

Python prototype (for reference only):

createBackgroundSubtractorMOG2([, history[, varThreshold[, detectShadows]]]) -> retval
Link to this function

createBackgroundSubtractorMOG2(opts)

View Source
@spec createBackgroundSubtractorMOG2([{atom(), term()}, ...] | nil) ::
  Evision.BackgroundSubtractorMOG2.t() | {:error, String.t()}

Creates MOG2 Background Subtractor

Keyword Arguments
  • history: int.

    Length of the history.

  • varThreshold: double.

    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: bool.

    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.

Return
  • retval: Evision.BackgroundSubtractorMOG2.t()

Python prototype (for reference only):

createBackgroundSubtractorMOG2([, history[, varThreshold[, detectShadows]]]) -> retval
Link to this function

createCalibrateDebevec()

View Source
@spec createCalibrateDebevec() :: Evision.CalibrateDebevec.t() | {:error, String.t()}

Creates CalibrateDebevec object

Keyword Arguments
  • samples: int.

    number of pixel locations to use

  • lambda: float.

    smoothness term weight. Greater values produce smoother results, but can alter the response.

  • random: bool.

    if true sample pixel locations are chosen at random, otherwise they form a rectangular grid.

Return
  • retval: Evision.CalibrateDebevec.t()

Python prototype (for reference only):

createCalibrateDebevec([, samples[, lambda[, random]]]) -> retval
Link to this function

createCalibrateDebevec(opts)

View Source
@spec createCalibrateDebevec([{atom(), term()}, ...] | nil) ::
  Evision.CalibrateDebevec.t() | {:error, String.t()}

Creates CalibrateDebevec object

Keyword Arguments
  • samples: int.

    number of pixel locations to use

  • lambda: float.

    smoothness term weight. Greater values produce smoother results, but can alter the response.

  • random: bool.

    if true sample pixel locations are chosen at random, otherwise they form a rectangular grid.

Return
  • retval: Evision.CalibrateDebevec.t()

Python prototype (for reference only):

createCalibrateDebevec([, samples[, lambda[, random]]]) -> retval
Link to this function

createCalibrateRobertson()

View Source
@spec createCalibrateRobertson() ::
  Evision.CalibrateRobertson.t() | {:error, String.t()}

Creates CalibrateRobertson object

Keyword Arguments
  • max_iter: int.

    maximal number of Gauss-Seidel solver iterations.

  • threshold: float.

    target difference between results of two successive steps of the minimization.

Return
  • retval: Evision.CalibrateRobertson.t()

Python prototype (for reference only):

createCalibrateRobertson([, max_iter[, threshold]]) -> retval
Link to this function

createCalibrateRobertson(opts)

View Source
@spec createCalibrateRobertson([{atom(), term()}, ...] | nil) ::
  Evision.CalibrateRobertson.t() | {:error, String.t()}

Creates CalibrateRobertson object

Keyword Arguments
  • max_iter: int.

    maximal number of Gauss-Seidel solver iterations.

  • threshold: float.

    target difference between results of two successive steps of the minimization.

Return
  • retval: Evision.CalibrateRobertson.t()

Python prototype (for reference only):

createCalibrateRobertson([, max_iter[, threshold]]) -> retval
Link to this function

createChiHistogramCostExtractor()

View Source
@spec createChiHistogramCostExtractor() ::
  Evision.HistogramCostExtractor.t() | {:error, String.t()}

createChiHistogramCostExtractor

Keyword Arguments
  • nDummies: int.
  • defaultCost: float.
Return
  • retval: Evision.HistogramCostExtractor.t()

Python prototype (for reference only):

createChiHistogramCostExtractor([, nDummies[, defaultCost]]) -> retval
Link to this function

createChiHistogramCostExtractor(opts)

View Source
@spec createChiHistogramCostExtractor([{atom(), term()}, ...] | nil) ::
  Evision.HistogramCostExtractor.t() | {:error, String.t()}

createChiHistogramCostExtractor

Keyword Arguments
  • nDummies: int.
  • defaultCost: float.
Return
  • retval: Evision.HistogramCostExtractor.t()

Python prototype (for reference only):

createChiHistogramCostExtractor([, nDummies[, defaultCost]]) -> retval
@spec createCLAHE() :: Evision.CLAHE.t() | {:error, String.t()}

Creates a smart pointer to a cv::CLAHE class and initializes it.

Keyword Arguments
  • clipLimit: double.

    Threshold for contrast limiting.

  • tileGridSize: Size.

    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.

Return
  • retval: Evision.CLAHE.t()

Python prototype (for reference only):

createCLAHE([, clipLimit[, tileGridSize]]) -> retval
@spec createCLAHE([{atom(), term()}, ...] | nil) ::
  Evision.CLAHE.t() | {:error, String.t()}

Creates a smart pointer to a cv::CLAHE class and initializes it.

Keyword Arguments
  • clipLimit: double.

    Threshold for contrast limiting.

  • tileGridSize: Size.

    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.

Return
  • retval: Evision.CLAHE.t()

Python prototype (for reference only):

createCLAHE([, clipLimit[, tileGridSize]]) -> retval
Link to this function

createEMDHistogramCostExtractor()

View Source
@spec createEMDHistogramCostExtractor() ::
  Evision.HistogramCostExtractor.t() | {:error, String.t()}

createEMDHistogramCostExtractor

Keyword Arguments
  • flag: int.
  • nDummies: int.
  • defaultCost: float.
Return
  • retval: Evision.HistogramCostExtractor.t()

Python prototype (for reference only):

createEMDHistogramCostExtractor([, flag[, nDummies[, defaultCost]]]) -> retval
Link to this function

createEMDHistogramCostExtractor(opts)

View Source
@spec createEMDHistogramCostExtractor([{atom(), term()}, ...] | nil) ::
  Evision.HistogramCostExtractor.t() | {:error, String.t()}

createEMDHistogramCostExtractor

Keyword Arguments
  • flag: int.
  • nDummies: int.
  • defaultCost: float.
Return
  • retval: Evision.HistogramCostExtractor.t()

Python prototype (for reference only):

createEMDHistogramCostExtractor([, flag[, nDummies[, defaultCost]]]) -> retval
Link to this function

createEMDL1HistogramCostExtractor()

View Source
@spec createEMDL1HistogramCostExtractor() ::
  Evision.HistogramCostExtractor.t() | {:error, String.t()}

createEMDL1HistogramCostExtractor

Keyword Arguments
  • nDummies: int.
  • defaultCost: float.
Return
  • retval: Evision.HistogramCostExtractor.t()

Python prototype (for reference only):

createEMDL1HistogramCostExtractor([, nDummies[, defaultCost]]) -> retval
Link to this function

createEMDL1HistogramCostExtractor(opts)

View Source
@spec createEMDL1HistogramCostExtractor([{atom(), term()}, ...] | nil) ::
  Evision.HistogramCostExtractor.t() | {:error, String.t()}

createEMDL1HistogramCostExtractor

Keyword Arguments
  • nDummies: int.
  • defaultCost: float.
Return
  • retval: Evision.HistogramCostExtractor.t()

Python prototype (for reference only):

createEMDL1HistogramCostExtractor([, nDummies[, defaultCost]]) -> retval
Link to this function

createGeneralizedHoughBallard()

View Source
@spec createGeneralizedHoughBallard() ::
  Evision.GeneralizedHoughBallard.t() | {:error, String.t()}

Creates a smart pointer to a cv::GeneralizedHoughBallard class and initializes it.

Return
  • retval: Evision.GeneralizedHoughBallard.t()

Python prototype (for reference only):

createGeneralizedHoughBallard() -> retval
Link to this function

createGeneralizedHoughGuil()

View Source
@spec createGeneralizedHoughGuil() ::
  Evision.GeneralizedHoughGuil.t() | {:error, String.t()}

Creates a smart pointer to a cv::GeneralizedHoughGuil class and initializes it.

Return
  • retval: Evision.GeneralizedHoughGuil.t()

Python prototype (for reference only):

createGeneralizedHoughGuil() -> retval
Link to this function

createHanningWindow(winSize, type)

View Source
@spec createHanningWindow(
  {number(), number()},
  integer()
) :: Evision.Mat.t() | {:error, String.t()}

This function computes a Hanning window coefficients in two dimensions.

Positional Arguments
  • winSize: Size.

    The window size specifications (both width and height must be > 1)

  • type: int.

    Created array type

Return
  • dst: Evision.Mat.t().

    Destination array to place Hann coefficients in

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);

Python prototype (for reference only):

createHanningWindow(winSize, type[, dst]) -> dst
Link to this function

createHanningWindow(winSize, type, opts)

View Source
@spec createHanningWindow(
  {number(), number()},
  integer(),
  [{atom(), term()}, ...] | nil
) ::
  Evision.Mat.t() | {:error, String.t()}

This function computes a Hanning window coefficients in two dimensions.

Positional Arguments
  • winSize: Size.

    The window size specifications (both width and height must be > 1)

  • type: int.

    Created array type

Return
  • dst: Evision.Mat.t().

    Destination array to place Hann coefficients in

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);

Python prototype (for reference only):

createHanningWindow(winSize, type[, dst]) -> dst
Link to this function

createHausdorffDistanceExtractor()

View Source
@spec createHausdorffDistanceExtractor() ::
  Evision.HausdorffDistanceExtractor.t() | {:error, String.t()}

createHausdorffDistanceExtractor

Keyword Arguments
  • distanceFlag: int.
  • rankProp: float.
Return
  • retval: Evision.HausdorffDistanceExtractor.t()

Python prototype (for reference only):

createHausdorffDistanceExtractor([, distanceFlag[, rankProp]]) -> retval
Link to this function

createHausdorffDistanceExtractor(opts)

View Source
@spec createHausdorffDistanceExtractor([{atom(), term()}, ...] | nil) ::
  Evision.HausdorffDistanceExtractor.t() | {:error, String.t()}

createHausdorffDistanceExtractor

Keyword Arguments
  • distanceFlag: int.
  • rankProp: float.
Return
  • retval: Evision.HausdorffDistanceExtractor.t()

Python prototype (for reference only):

createHausdorffDistanceExtractor([, distanceFlag[, rankProp]]) -> retval
Link to this function

createLineSegmentDetector()

View Source
@spec createLineSegmentDetector() ::
  Evision.LineSegmentDetector.t() | {:error, String.t()}

Creates a smart pointer to a LineSegmentDetector object and initializes it.

Keyword Arguments
  • refine: int.

    The way found lines will be refined, see #LineSegmentDetectorModes

  • scale: double.

    The scale of the image that will be used to find the lines. Range (0..1].

  • sigma_scale: double.

    Sigma for Gaussian filter. It is computed as sigma = sigma_scale/scale.

  • quant: double.

    Bound to the quantization error on the gradient norm.

  • ang_th: double.

    Gradient angle tolerance in degrees.

  • log_eps: double.

    Detection threshold: -log10(NFA) > log_eps. Used only when advance refinement is chosen.

  • density_th: double.

    Minimal density of aligned region points in the enclosing rectangle.

  • n_bins: int.

    Number of bins in pseudo-ordering of gradient modulus.

Return
  • retval: Evision.LineSegmentDetector.t()

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.

Python prototype (for reference only):

createLineSegmentDetector([, refine[, scale[, sigma_scale[, quant[, ang_th[, log_eps[, density_th[, n_bins]]]]]]]]) -> retval
Link to this function

createLineSegmentDetector(opts)

View Source
@spec createLineSegmentDetector([{atom(), term()}, ...] | nil) ::
  Evision.LineSegmentDetector.t() | {:error, String.t()}

Creates a smart pointer to a LineSegmentDetector object and initializes it.

Keyword Arguments
  • refine: int.

    The way found lines will be refined, see #LineSegmentDetectorModes

  • scale: double.

    The scale of the image that will be used to find the lines. Range (0..1].

  • sigma_scale: double.

    Sigma for Gaussian filter. It is computed as sigma = sigma_scale/scale.

  • quant: double.

    Bound to the quantization error on the gradient norm.

  • ang_th: double.

    Gradient angle tolerance in degrees.

  • log_eps: double.

    Detection threshold: -log10(NFA) > log_eps. Used only when advance refinement is chosen.

  • density_th: double.

    Minimal density of aligned region points in the enclosing rectangle.

  • n_bins: int.

    Number of bins in pseudo-ordering of gradient modulus.

Return
  • retval: Evision.LineSegmentDetector.t()

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.

Python prototype (for reference only):

createLineSegmentDetector([, refine[, scale[, sigma_scale[, quant[, ang_th[, log_eps[, density_th[, n_bins]]]]]]]]) -> retval
@spec createMergeDebevec() :: Evision.MergeDebevec.t() | {:error, String.t()}

Creates MergeDebevec object

Return
  • retval: Evision.MergeDebevec.t()

Python prototype (for reference only):

createMergeDebevec() -> retval
@spec createMergeMertens() :: Evision.MergeMertens.t() | {:error, String.t()}

Creates MergeMertens object

Keyword Arguments
  • contrast_weight: float.

    contrast measure weight. See MergeMertens.

  • saturation_weight: float.

    saturation measure weight

  • exposure_weight: float.

    well-exposedness measure weight

Return
  • retval: Evision.MergeMertens.t()

Python prototype (for reference only):

createMergeMertens([, contrast_weight[, saturation_weight[, exposure_weight]]]) -> retval
Link to this function

createMergeMertens(opts)

View Source
@spec createMergeMertens([{atom(), term()}, ...] | nil) ::
  Evision.MergeMertens.t() | {:error, String.t()}

Creates MergeMertens object

Keyword Arguments
  • contrast_weight: float.

    contrast measure weight. See MergeMertens.

  • saturation_weight: float.

    saturation measure weight

  • exposure_weight: float.

    well-exposedness measure weight

Return
  • retval: Evision.MergeMertens.t()

Python prototype (for reference only):

createMergeMertens([, contrast_weight[, saturation_weight[, exposure_weight]]]) -> retval
@spec createMergeRobertson() :: Evision.MergeRobertson.t() | {:error, String.t()}

Creates MergeRobertson object

Return
  • retval: Evision.MergeRobertson.t()

Python prototype (for reference only):

createMergeRobertson() -> retval
Link to this function

createNormHistogramCostExtractor()

View Source
@spec createNormHistogramCostExtractor() ::
  Evision.HistogramCostExtractor.t() | {:error, String.t()}

createNormHistogramCostExtractor

Keyword Arguments
  • flag: int.
  • nDummies: int.
  • defaultCost: float.
Return
  • retval: Evision.HistogramCostExtractor.t()

Python prototype (for reference only):

createNormHistogramCostExtractor([, flag[, nDummies[, defaultCost]]]) -> retval
Link to this function

createNormHistogramCostExtractor(opts)

View Source
@spec createNormHistogramCostExtractor([{atom(), term()}, ...] | nil) ::
  Evision.HistogramCostExtractor.t() | {:error, String.t()}

createNormHistogramCostExtractor

Keyword Arguments
  • flag: int.
  • nDummies: int.
  • defaultCost: float.
Return
  • retval: Evision.HistogramCostExtractor.t()

Python prototype (for reference only):

createNormHistogramCostExtractor([, flag[, nDummies[, defaultCost]]]) -> retval
Link to this function

createShapeContextDistanceExtractor()

View Source
@spec createShapeContextDistanceExtractor() ::
  Evision.ShapeContextDistanceExtractor.t() | {:error, String.t()}

createShapeContextDistanceExtractor

Keyword Arguments
  • nAngularBins: int.
  • nRadialBins: int.
  • innerRadius: float.
  • outerRadius: float.
  • iterations: int.
  • comparer: Evision.HistogramCostExtractor.t().
  • transformer: Evision.ShapeTransformer.t().
Return
  • retval: Evision.ShapeContextDistanceExtractor.t()

Python prototype (for reference only):

createShapeContextDistanceExtractor([, nAngularBins[, nRadialBins[, innerRadius[, outerRadius[, iterations[, comparer[, transformer]]]]]]]) -> retval
Link to this function

createShapeContextDistanceExtractor(opts)

View Source
@spec createShapeContextDistanceExtractor([{atom(), term()}, ...] | nil) ::
  Evision.ShapeContextDistanceExtractor.t() | {:error, String.t()}

createShapeContextDistanceExtractor

Keyword Arguments
  • nAngularBins: int.
  • nRadialBins: int.
  • innerRadius: float.
  • outerRadius: float.
  • iterations: int.
  • comparer: Evision.HistogramCostExtractor.t().
  • transformer: Evision.ShapeTransformer.t().
Return
  • retval: Evision.ShapeContextDistanceExtractor.t()

Python prototype (for reference only):

createShapeContextDistanceExtractor([, nAngularBins[, nRadialBins[, innerRadius[, outerRadius[, iterations[, comparer[, transformer]]]]]]]) -> retval
Link to this function

createThinPlateSplineShapeTransformer()

View Source
@spec createThinPlateSplineShapeTransformer() ::
  Evision.ThinPlateSplineShapeTransformer.t() | {:error, String.t()}

createThinPlateSplineShapeTransformer

Keyword Arguments
  • regularizationParameter: double.
Return
  • retval: Evision.ThinPlateSplineShapeTransformer.t()

Complete constructor

Python prototype (for reference only):

createThinPlateSplineShapeTransformer([, regularizationParameter]) -> retval
Link to this function

createThinPlateSplineShapeTransformer(opts)

View Source
@spec createThinPlateSplineShapeTransformer([{atom(), term()}, ...] | nil) ::
  Evision.ThinPlateSplineShapeTransformer.t() | {:error, String.t()}

createThinPlateSplineShapeTransformer

Keyword Arguments
  • regularizationParameter: double.
Return
  • retval: Evision.ThinPlateSplineShapeTransformer.t()

Complete constructor

Python prototype (for reference only):

createThinPlateSplineShapeTransformer([, regularizationParameter]) -> retval
@spec createTonemap() :: Evision.Tonemap.t() | {:error, String.t()}

Creates simple linear mapper with gamma correction

Keyword Arguments
  • gamma: float.

    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.

Return
  • retval: Evision.Tonemap.t()

Python prototype (for reference only):

createTonemap([, gamma]) -> retval
@spec createTonemap([{atom(), term()}, ...] | nil) ::
  Evision.Tonemap.t() | {:error, String.t()}

Creates simple linear mapper with gamma correction

Keyword Arguments
  • gamma: float.

    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.

Return
  • retval: Evision.Tonemap.t()

Python prototype (for reference only):

createTonemap([, gamma]) -> retval
@spec createTonemapDrago() :: Evision.TonemapDrago.t() | {:error, String.t()}

Creates TonemapDrago object

Keyword Arguments
  • gamma: float.

    gamma value for gamma correction. See createTonemap

  • saturation: float.

    positive saturation enhancement value. 1.0 preserves saturation, values greater than 1 increase saturation and values less than 1 decrease it.

  • bias: float.

    value for bias function in [0, 1] range. Values from 0.7 to 0.9 usually give best results, default value is 0.85.

Return
  • retval: Evision.TonemapDrago.t()

Python prototype (for reference only):

createTonemapDrago([, gamma[, saturation[, bias]]]) -> retval
Link to this function

createTonemapDrago(opts)

View Source
@spec createTonemapDrago([{atom(), term()}, ...] | nil) ::
  Evision.TonemapDrago.t() | {:error, String.t()}

Creates TonemapDrago object

Keyword Arguments
  • gamma: float.

    gamma value for gamma correction. See createTonemap

  • saturation: float.

    positive saturation enhancement value. 1.0 preserves saturation, values greater than 1 increase saturation and values less than 1 decrease it.

  • bias: float.

    value for bias function in [0, 1] range. Values from 0.7 to 0.9 usually give best results, default value is 0.85.

Return
  • retval: Evision.TonemapDrago.t()

Python prototype (for reference only):

createTonemapDrago([, gamma[, saturation[, bias]]]) -> retval
@spec createTonemapMantiuk() :: Evision.TonemapMantiuk.t() | {:error, String.t()}

Creates TonemapMantiuk object

Keyword Arguments
  • gamma: float.

    gamma value for gamma correction. See createTonemap

  • scale: float.

    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: float.

    saturation enhancement value. See createTonemapDrago

Return
  • retval: Evision.TonemapMantiuk.t()

Python prototype (for reference only):

createTonemapMantiuk([, gamma[, scale[, saturation]]]) -> retval
Link to this function

createTonemapMantiuk(opts)

View Source
@spec createTonemapMantiuk([{atom(), term()}, ...] | nil) ::
  Evision.TonemapMantiuk.t() | {:error, String.t()}

Creates TonemapMantiuk object

Keyword Arguments
  • gamma: float.

    gamma value for gamma correction. See createTonemap

  • scale: float.

    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: float.

    saturation enhancement value. See createTonemapDrago

Return
  • retval: Evision.TonemapMantiuk.t()

Python prototype (for reference only):

createTonemapMantiuk([, gamma[, scale[, saturation]]]) -> retval
@spec createTonemapReinhard() :: Evision.TonemapReinhard.t() | {:error, String.t()}

Creates TonemapReinhard object

Keyword Arguments
  • gamma: float.

    gamma value for gamma correction. See createTonemap

  • intensity: float.

    result intensity in [-8, 8] range. Greater intensity produces brighter results.

  • light_adapt: float.

    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: float.

    chromatic adaptation in [0, 1] range. If 1 channels are treated independently, if 0 adaptation level is the same for each channel.

Return
  • retval: Evision.TonemapReinhard.t()

Python prototype (for reference only):

createTonemapReinhard([, gamma[, intensity[, light_adapt[, color_adapt]]]]) -> retval
Link to this function

createTonemapReinhard(opts)

View Source
@spec createTonemapReinhard([{atom(), term()}, ...] | nil) ::
  Evision.TonemapReinhard.t() | {:error, String.t()}

Creates TonemapReinhard object

Keyword Arguments
  • gamma: float.

    gamma value for gamma correction. See createTonemap

  • intensity: float.

    result intensity in [-8, 8] range. Greater intensity produces brighter results.

  • light_adapt: float.

    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: float.

    chromatic adaptation in [0, 1] range. If 1 channels are treated independently, if 0 adaptation level is the same for each channel.

Return
  • retval: Evision.TonemapReinhard.t()

Python prototype (for reference only):

createTonemapReinhard([, gamma[, intensity[, light_adapt[, color_adapt]]]]) -> retval
@spec cubeRoot(number()) :: number() | {:error, String.t()}

Computes the cube root of an argument.

Positional Arguments
  • val: float.

    A function argument.

Return
  • retval: float

The function cubeRoot computes \f$\sqrt[3]{\texttt{val}}\f$. Negative arguments are handled correctly. NaN and Inf are not handled. The accuracy approaches the maximum possible accuracy for single-precision data.

Python prototype (for reference only):

cubeRoot(val) -> retval
@spec cvtColor(Evision.Mat.maybe_mat_in(), integer()) ::
  Evision.Mat.t() | {:error, String.t()}

Converts an image from one color space to another.

Positional Arguments
  • src: Evision.Mat.t().

    input image: 8-bit unsigned, 16-bit unsigned ( CV_16UC... ), or single-precision floating-point.

  • code: int.

    color space conversion code (see #ColorConversionCodes).

Keyword Arguments
  • dstCn: int.

    number of channels in the destination image; if the parameter is 0, the number of the channels is derived automatically from src and code.

Return
  • dst: Evision.Mat.t().

    output image of the same size and depth as src.

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 \f$\rightarrow\f$ 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.

@see @ref imgproc_color_conversions

Python prototype (for reference only):

cvtColor(src, code[, dst[, dstCn]]) -> dst
Link to this function

cvtColor(src, code, opts)

View Source
@spec cvtColor(Evision.Mat.maybe_mat_in(), integer(), [{atom(), term()}, ...] | nil) ::
  Evision.Mat.t() | {:error, String.t()}

Converts an image from one color space to another.

Positional Arguments
  • src: Evision.Mat.t().

    input image: 8-bit unsigned, 16-bit unsigned ( CV_16UC... ), or single-precision floating-point.

  • code: int.

    color space conversion code (see #ColorConversionCodes).

Keyword Arguments
  • dstCn: int.

    number of channels in the destination image; if the parameter is 0, the number of the channels is derived automatically from src and code.

Return
  • dst: Evision.Mat.t().

    output image of the same size and depth as src.

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 \f$\rightarrow\f$ 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.

@see @ref imgproc_color_conversions

Python prototype (for reference only):

cvtColor(src, code[, dst[, dstCn]]) -> dst
Link to this function

cvtColorTwoPlane(src1, src2, code)

View Source
@spec cvtColorTwoPlane(
  Evision.Mat.maybe_mat_in(),
  Evision.Mat.maybe_mat_in(),
  integer()
) ::
  Evision.Mat.t() | {:error, String.t()}

Converts an image from one color space to another where the source image is stored in two planes.

Positional Arguments
  • src1: Evision.Mat.t().

    8-bit image (#CV_8U) of the Y plane.

  • src2: Evision.Mat.t().

    image containing interleaved U/V plane.

  • code: int.

    Specifies the type of conversion. It can take any of the following values:

    • #COLOR_YUV2BGR_NV12
    • #COLOR_YUV2RGB_NV12
    • #COLOR_YUV2BGRA_NV12
    • #COLOR_YUV2RGBA_NV12
    • #COLOR_YUV2BGR_NV21
    • #COLOR_YUV2RGB_NV21
    • #COLOR_YUV2BGRA_NV21
    • #COLOR_YUV2RGBA_NV21
Return
  • dst: Evision.Mat.t().

    output image.

This function only supports YUV420 to RGB conversion as of now.

Python prototype (for reference only):

cvtColorTwoPlane(src1, src2, code[, dst]) -> dst
Link to this function

cvtColorTwoPlane(src1, src2, code, opts)

View Source
@spec cvtColorTwoPlane(
  Evision.Mat.maybe_mat_in(),
  Evision.Mat.maybe_mat_in(),
  integer(),
  [{atom(), term()}, ...] | nil
) :: Evision.Mat.t() | {:error, String.t()}

Converts an image from one color space to another where the source image is stored in two planes.

Positional Arguments
  • src1: Evision.Mat.t().

    8-bit image (#CV_8U) of the Y plane.

  • src2: Evision.Mat.t().

    image containing interleaved U/V plane.

  • code: int.

    Specifies the type of conversion. It can take any of the following values:

    • #COLOR_YUV2BGR_NV12
    • #COLOR_YUV2RGB_NV12
    • #COLOR_YUV2BGRA_NV12
    • #COLOR_YUV2RGBA_NV12
    • #COLOR_YUV2BGR_NV21
    • #COLOR_YUV2RGB_NV21
    • #COLOR_YUV2BGRA_NV21
    • #COLOR_YUV2RGBA_NV21
Return
  • dst: Evision.Mat.t().

    output image.

This function only supports YUV420 to RGB conversion as of now.

Python prototype (for reference only):

cvtColorTwoPlane(src1, src2, code[, dst]) -> dst
@spec dct(Evision.Mat.maybe_mat_in()) :: Evision.Mat.t() | {:error, String.t()}

Performs a forward or inverse discrete Cosine transform of 1D or 2D array.

Positional Arguments
  • src: Evision.Mat.t().

    input floating-point array.

Keyword Arguments
  • flags: int.

    transformation flags as a combination of cv::DftFlags (DCT_*)

Return
  • dst: Evision.Mat.t().

    output array of the same size and type as src .

The function cv::dct performs a forward or inverse discrete Cosine transform (DCT) of a 1D or 2D floating-point array:

  • Forward Cosine transform of a 1D vector of N elements: \f[Y = C^{(N)} \cdot X\f] where \f[C^{(N)}_{jk}= \sqrt{\alpha_j/N} \cos \left ( \frac{\pi(2k+1)j}{2N} \right )\f] and \f$\alpha_0=1\f$, \f$\alpha_j=2\f$ for j > 0.

  • Inverse Cosine transform of a 1D vector of N elements: \f[X = \left (C^{(N)} \right )^{-1} \cdot Y = \left (C^{(N)} \right )^T \cdot Y\f] (since \f$C^{(N)}\f$ is an orthogonal matrix, \f$C^{(N)} \cdot \left(C^{(N)}\right)^T = I\f$ )

  • Forward 2D Cosine transform of M x N matrix: \f[Y = C^{(N)} \cdot X \cdot \left (C^{(N)} \right )^T\f]

  • Inverse 2D Cosine transform of M x N matrix: \f[X = \left (C^{(N)} \right )^T \cdot X \cdot C^{(N)}\f]

The function chooses the mode of operation by looking at the flags and size of the input array:

  • If (flags & #DCT_INVERSE) == 0 , the function does a forward 1D or 2D transform. Otherwise, it 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);

@sa dft , getOptimalDFTSize , idct

Python prototype (for reference only):

dct(src[, dst[, flags]]) -> dst
@spec dct(Evision.Mat.maybe_mat_in(), [{atom(), term()}, ...] | nil) ::
  Evision.Mat.t() | {:error, String.t()}

Performs a forward or inverse discrete Cosine transform of 1D or 2D array.

Positional Arguments
  • src: Evision.Mat.t().

    input floating-point array.

Keyword Arguments
  • flags: int.

    transformation flags as a combination of cv::DftFlags (DCT_*)

Return
  • dst: Evision.Mat.t().

    output array of the same size and type as src .

The function cv::dct performs a forward or inverse discrete Cosine transform (DCT) of a 1D or 2D floating-point array:

  • Forward Cosine transform of a 1D vector of N elements: \f[Y = C^{(N)} \cdot X\f] where \f[C^{(N)}_{jk}= \sqrt{\alpha_j/N} \cos \left ( \frac{\pi(2k+1)j}{2N} \right )\f] and \f$\alpha_0=1\f$, \f$\alpha_j=2\f$ for j > 0.

  • Inverse Cosine transform of a 1D vector of N elements: \f[X = \left (C^{(N)} \right )^{-1} \cdot Y = \left (C^{(N)} \right )^T \cdot Y\f] (since \f$C^{(N)}\f$ is an orthogonal matrix, \f$C^{(N)} \cdot \left(C^{(N)}\right)^T = I\f$ )

  • Forward 2D Cosine transform of M x N matrix: \f[Y = C^{(N)} \cdot X \cdot \left (C^{(N)} \right )^T\f]

  • Inverse 2D Cosine transform of M x N matrix: \f[X = \left (C^{(N)} \right )^T \cdot X \cdot C^{(N)}\f]

The function chooses the mode of operation by looking at the flags and size of the input array:

  • If (flags & #DCT_INVERSE) == 0 , the function does a forward 1D or 2D transform. Otherwise, it 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);

@sa dft , getOptimalDFTSize , idct

Python prototype (for reference only):

dct(src[, dst[, flags]]) -> dst
@spec decolor(Evision.Mat.maybe_mat_in()) ::
  {Evision.Mat.t(), Evision.Mat.t()} | {:error, String.t()}

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

Positional Arguments
  • src: Evision.Mat.t().

    Input 8-bit 3-channel image.

Return
  • grayscale: Evision.Mat.t().

    Output 8-bit 1-channel image.

  • color_boost: Evision.Mat.t().

    Output 8-bit 3-channel image.

@cite CL12 .

This function is to be applied on color images.

Python prototype (for reference only):

decolor(src[, grayscale[, color_boost]]) -> grayscale, color_boost
@spec decolor(Evision.Mat.maybe_mat_in(), [{atom(), term()}, ...] | nil) ::
  {Evision.Mat.t(), Evision.Mat.t()} | {:error, String.t()}

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

Positional Arguments
  • src: Evision.Mat.t().

    Input 8-bit 3-channel image.

Return
  • grayscale: Evision.Mat.t().

    Output 8-bit 1-channel image.

  • color_boost: Evision.Mat.t().

    Output 8-bit 3-channel image.

@cite CL12 .

This function is to be applied on color images.

Python prototype (for reference only):

decolor(src[, grayscale[, color_boost]]) -> grayscale, color_boost
Link to this function

decomposeEssentialMat(e)

View Source
@spec decomposeEssentialMat(Evision.Mat.maybe_mat_in()) ::
  {Evision.Mat.t(), Evision.Mat.t(), Evision.Mat.t()} | {:error, String.t()}

Decompose an essential matrix to possible rotations and translation.

Positional Arguments
  • e: Evision.Mat.t().

    The input essential matrix.

Return
  • r1: Evision.Mat.t().

    One possible rotation matrix.

  • r2: Evision.Mat.t().

    Another possible rotation matrix.

  • t: Evision.Mat.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 \f$[R_1, t]\f$, \f$[R_1, -t]\f$, \f$[R_2, t]\f$, \f$[R_2, -t]\f$. If E gives the epipolar constraint \f$[p_2; 1]^T A^{-T} E A^{-1} [p_1; 1] = 0\f$ between the image points \f$p_1\f$ in the first image and \f$p_2\f$ in second image, then any of the tuples \f$[R_1, t]\f$, \f$[R_1, -t]\f$, \f$[R_2, t]\f$, \f$[R_2, -t]\f$ is a change of basis from the first camera's coordinate system to the second camera's coordinate system. However, by decomposing E, one can only get the direction of the translation. For this reason, the translation t is returned with unit length.

Python prototype (for reference only):

decomposeEssentialMat(E[, R1[, R2[, t]]]) -> R1, R2, t
Link to this function

decomposeEssentialMat(e, opts)

View Source
@spec decomposeEssentialMat(Evision.Mat.maybe_mat_in(), [{atom(), term()}, ...] | nil) ::
  {Evision.Mat.t(), Evision.Mat.t(), Evision.Mat.t()} | {:error, String.t()}

Decompose an essential matrix to possible rotations and translation.

Positional Arguments
  • e: Evision.Mat.t().

    The input essential matrix.

Return
  • r1: Evision.Mat.t().

    One possible rotation matrix.

  • r2: Evision.Mat.t().

    Another possible rotation matrix.

  • t: Evision.Mat.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 \f$[R_1, t]\f$, \f$[R_1, -t]\f$, \f$[R_2, t]\f$, \f$[R_2, -t]\f$. If E gives the epipolar constraint \f$[p_2; 1]^T A^{-T} E A^{-1} [p_1; 1] = 0\f$ between the image points \f$p_1\f$ in the first image and \f$p_2\f$ in second image, then any of the tuples \f$[R_1, t]\f$, \f$[R_1, -t]\f$, \f$[R_2, t]\f$, \f$[R_2, -t]\f$ is a change of basis from the first camera's coordinate system to the second camera's coordinate system. However, by decomposing E, one can only get the direction of the translation. For this reason, the translation t is returned with unit length.

Python prototype (for reference only):

decomposeEssentialMat(E[, R1[, R2[, t]]]) -> R1, R2, t
Link to this function

decomposeHomographyMat(h, k)

View Source
@spec decomposeHomographyMat(Evision.Mat.maybe_mat_in(), Evision.Mat.maybe_mat_in()) ::
  {integer(), [Evision.Mat.t()], [Evision.Mat.t()], [Evision.Mat.t()]}
  | {:error, String.t()}

Decompose a homography matrix to rotation(s), translation(s) and plane normal(s).

Positional Arguments
  • h: Evision.Mat.t().

    The input homography matrix between two images.

  • k: Evision.Mat.t().

    The input camera intrinsic matrix.

Return
  • retval: int

  • rotations: [Evision.Mat].

    Array of rotation matrices.

  • translations: [Evision.Mat].

    Array of translation matrices.

  • normals: [Evision.Mat].

    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 \f[s_i \vecthree{x'_i}{y'_i}{1} \sim H \vecthree{x_i}{y_i}{1}\f] on the source image points \f$p_i\f$ and the destination image points \f$p'_i\f$, then the tuple of rotations[k] and translations[k] is a change of basis from the source camera's coordinate system to the destination camera's coordinate system. However, by decomposing H, one can only get the translation normalized by the (typically unknown) depth of the scene, i.e. its direction but with normalized length. If point correspondences are available, at least two solutions may further be invalidated, by applying positive depth constraint, i.e. all points must be in front of the camera.

Python prototype (for reference only):

decomposeHomographyMat(H, K[, rotations[, translations[, normals]]]) -> retval, rotations, translations, normals
Link to this function

decomposeHomographyMat(h, k, opts)

View Source
@spec decomposeHomographyMat(
  Evision.Mat.maybe_mat_in(),
  Evision.Mat.maybe_mat_in(),
  [{atom(), term()}, ...] | nil
) ::
  {integer(), [Evision.Mat.t()], [Evision.Mat.t()], [Evision.Mat.t()]}
  | {:error, String.t()}

Decompose a homography matrix to rotation(s), translation(s) and plane normal(s).

Positional Arguments
  • h: Evision.Mat.t().

    The input homography matrix between two images.

  • k: Evision.Mat.t().

    The input camera intrinsic matrix.

Return
  • retval: int

  • rotations: [Evision.Mat].

    Array of rotation matrices.

  • translations: [Evision.Mat].

    Array of translation matrices.

  • normals: [Evision.Mat].

    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 \f[s_i \vecthree{x'_i}{y'_i}{1} \sim H \vecthree{x_i}{y_i}{1}\f] on the source image points \f$p_i\f$ and the destination image points \f$p'_i\f$, then the tuple of rotations[k] and translations[k] is a change of basis from the source camera's coordinate system to the destination camera's coordinate system. However, by decomposing H, one can only get the translation normalized by the (typically unknown) depth of the scene, i.e. its direction but with normalized length. If point correspondences are available, at least two solutions may further be invalidated, by applying positive depth constraint, i.e. all points must be in front of the camera.

Python prototype (for reference only):

decomposeHomographyMat(H, K[, rotations[, translations[, normals]]]) -> retval, rotations, translations, normals
Link to this function

decomposeProjectionMatrix(projMatrix)

View Source
@spec decomposeProjectionMatrix(Evision.Mat.maybe_mat_in()) ::
  {Evision.Mat.t(), Evision.Mat.t(), Evision.Mat.t(), Evision.Mat.t(),
   Evision.Mat.t(), Evision.Mat.t(), Evision.Mat.t()}
  | {:error, String.t()}

Decomposes a projection matrix into a rotation matrix and a camera intrinsic matrix.

Positional Arguments
  • projMatrix: Evision.Mat.t().

    3x4 input projection matrix P.

Return
  • cameraMatrix: Evision.Mat.t().

    Output 3x3 camera intrinsic matrix \f$\cameramatrix{A}\f$.

  • rotMatrix: Evision.Mat.t().

    Output 3x3 external rotation matrix R.

  • transVect: Evision.Mat.t().

    Output 4x1 translation vector T.

  • rotMatrixX: Evision.Mat.t().

    Optional 3x3 rotation matrix around x-axis.

  • rotMatrixY: Evision.Mat.t().

    Optional 3x3 rotation matrix around y-axis.

  • rotMatrixZ: Evision.Mat.t().

    Optional 3x3 rotation matrix around z-axis.

  • eulerAngles: Evision.Mat.t().

    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 .

Python prototype (for reference only):

decomposeProjectionMatrix(projMatrix[, cameraMatrix[, rotMatrix[, transVect[, rotMatrixX[, rotMatrixY[, rotMatrixZ[, eulerAngles]]]]]]]) -> cameraMatrix, rotMatrix, transVect, rotMatrixX, rotMatrixY, rotMatrixZ, eulerAngles
Link to this function

decomposeProjectionMatrix(projMatrix, opts)

View Source
@spec decomposeProjectionMatrix(
  Evision.Mat.maybe_mat_in(),
  [{atom(), term()}, ...] | nil
) ::
  {Evision.Mat.t(), Evision.Mat.t(), Evision.Mat.t(), Evision.Mat.t(),
   Evision.Mat.t(), Evision.Mat.t(), Evision.Mat.t()}
  | {:error, String.t()}

Decomposes a projection matrix into a rotation matrix and a camera intrinsic matrix.

Positional Arguments
  • projMatrix: Evision.Mat.t().

    3x4 input projection matrix P.

Return
  • cameraMatrix: Evision.Mat.t().

    Output 3x3 camera intrinsic matrix \f$\cameramatrix{A}\f$.

  • rotMatrix: Evision.Mat.t().

    Output 3x3 external rotation matrix R.

  • transVect: Evision.Mat.t().

    Output 4x1 translation vector T.

  • rotMatrixX: Evision.Mat.t().

    Optional 3x3 rotation matrix around x-axis.

  • rotMatrixY: Evision.Mat.t().

    Optional 3x3 rotation matrix around y-axis.

  • rotMatrixZ: Evision.Mat.t().

    Optional 3x3 rotation matrix around z-axis.

  • eulerAngles: Evision.Mat.t().

    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 .

Python prototype (for reference only):

decomposeProjectionMatrix(projMatrix[, cameraMatrix[, rotMatrix[, transVect[, rotMatrixX[, rotMatrixY[, rotMatrixZ[, eulerAngles]]]]]]]) -> cameraMatrix, rotMatrix, transVect, rotMatrixX, rotMatrixY, rotMatrixZ, eulerAngles
@spec demosaicing(Evision.Mat.maybe_mat_in(), integer()) ::
  Evision.Mat.t() | {:error, String.t()}

main function for all demosaicing processes

Positional Arguments
  • src: Evision.Mat.t().

    input image: 8-bit unsigned or 16-bit unsigned.

  • code: int.

    Color space conversion code (see the description below).

Keyword Arguments
  • dstCn: int.

    number of channels in the destination image; if the parameter is 0, the number of the channels is derived automatically from src and code.

Return
  • dst: Evision.Mat.t().

    output image of the same size and depth as src.

The function can do the following transformations:

  • Demosaicing using bilinear interpolation

#COLOR_BayerBG2BGR , #COLOR_BayerGB2BGR , #COLOR_BayerRG2BGR , #COLOR_BayerGR2BGR #COLOR_BayerBG2GRAY , #COLOR_BayerGB2GRAY , #COLOR_BayerRG2GRAY , #COLOR_BayerGR2GRAY

  • Demosaicing using Variable Number of Gradients.

#COLOR_BayerBG2BGR_VNG , #COLOR_BayerGB2BGR_VNG , #COLOR_BayerRG2BGR_VNG , #COLOR_BayerGR2BGR_VNG

  • Edge-Aware Demosaicing.

#COLOR_BayerBG2BGR_EA , #COLOR_BayerGB2BGR_EA , #COLOR_BayerRG2BGR_EA , #COLOR_BayerGR2BGR_EA

  • Demosaicing with alpha channel

#COLOR_BayerBG2BGRA , #COLOR_BayerGB2BGRA , #COLOR_BayerRG2BGRA , #COLOR_BayerGR2BGRA @sa cvtColor

Python prototype (for reference only):

demosaicing(src, code[, dst[, dstCn]]) -> dst
Link to this function

demosaicing(src, code, opts)

View Source
@spec demosaicing(
  Evision.Mat.maybe_mat_in(),
  integer(),
  [{atom(), term()}, ...] | nil
) ::
  Evision.Mat.t() | {:error, String.t()}

main function for all demosaicing processes

Positional Arguments
  • src: Evision.Mat.t().

    input image: 8-bit unsigned or 16-bit unsigned.

  • code: int.

    Color space conversion code (see the description below).

Keyword Arguments
  • dstCn: int.

    number of channels in the destination image; if the parameter is 0, the number of the channels is derived automatically from src and code.

Return
  • dst: Evision.Mat.t().

    output image of the same size and depth as src.

The function can do the following transformations:

  • Demosaicing using bilinear interpolation

#COLOR_BayerBG2BGR , #COLOR_BayerGB2BGR , #COLOR_BayerRG2BGR , #COLOR_BayerGR2BGR #COLOR_BayerBG2GRAY , #COLOR_BayerGB2GRAY , #COLOR_BayerRG2GRAY , #COLOR_BayerGR2GRAY

  • Demosaicing using Variable Number of Gradients.

#COLOR_BayerBG2BGR_VNG , #COLOR_BayerGB2BGR_VNG , #COLOR_BayerRG2BGR_VNG , #COLOR_BayerGR2BGR_VNG

  • Edge-Aware Demosaicing.

#COLOR_BayerBG2BGR_EA , #COLOR_BayerGB2BGR_EA , #COLOR_BayerRG2BGR_EA , #COLOR_BayerGR2BGR_EA

  • Demosaicing with alpha channel

#COLOR_BayerBG2BGRA , #COLOR_BayerGB2BGRA , #COLOR_BayerRG2BGRA , #COLOR_BayerGR2BGRA @sa cvtColor

Python prototype (for reference only):

demosaicing(src, code[, dst[, dstCn]]) -> dst
@spec detailEnhance(Evision.Mat.maybe_mat_in()) ::
  Evision.Mat.t() | {:error, String.t()}

This filter enhances the details of a particular image.

Positional Arguments
  • src: Evision.Mat.t().

    Input 8-bit 3-channel image.

Keyword Arguments
  • sigma_s: float.

    %Range between 0 to 200.

  • sigma_r: float.

    %Range between 0 to 1.

Return
  • dst: Evision.Mat.t().

    Output image with the same size and type as src.

Python prototype (for reference only):

detailEnhance(src[, dst[, sigma_s[, sigma_r]]]) -> dst
Link to this function

detailEnhance(src, opts)

View Source
@spec detailEnhance(Evision.Mat.maybe_mat_in(), [{atom(), term()}, ...] | nil) ::
  Evision.Mat.t() | {:error, String.t()}

This filter enhances the details of a particular image.

Positional Arguments
  • src: Evision.Mat.t().

    Input 8-bit 3-channel image.

Keyword Arguments
  • sigma_s: float.

    %Range between 0 to 200.

  • sigma_r: float.

    %Range between 0 to 1.

Return
  • dst: Evision.Mat.t().

    Output image with the same size and type as src.

Python prototype (for reference only):

detailEnhance(src[, dst[, sigma_s[, sigma_r]]]) -> dst
@spec determinant(Evision.Mat.maybe_mat_in()) :: number() | {:error, String.t()}

Returns the determinant of a square floating-point matrix.

Positional Arguments
  • mtx: Evision.Mat.t().

    input matrix that must have CV_32FC1 or CV_64FC1 type and square size.

Return
  • retval: double

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. @sa trace, invert, solve, eigen, @ref MatrixExpressions

Python prototype (for reference only):

determinant(mtx) -> retval
@spec dft(Evision.Mat.maybe_mat_in()) :: Evision.Mat.t() | {:error, String.t()}

Performs a forward or inverse Discrete Fourier transform of a 1D or 2D floating-point array.

Positional Arguments
  • src: Evision.Mat.t().

    input array that could be real or complex.

Keyword Arguments
  • flags: int.

    transformation flags, representing a combination of the #DftFlags

  • nonzeroRows: int.

    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.

Return
  • dst: Evision.Mat.t().

    output array whose size and type depends on the flags .

The function cv::dft performs one of the following:

  • Forward the Fourier transform of a 1D vector of N elements: \f[Y = F^{(N)} \cdot X,\f] where \f$F^{(N)}_{jk}=\exp(-2\pi i j k/N)\f$ and \f$i=\sqrt{-1}\f$

  • Inverse the Fourier transform of a 1D vector of N elements: \f[\begin{array}{l} X'= \left (F^{(N)} \right )^{-1} \cdot Y = \left (F^{(N)} \right )^* \cdot y \\ X = (1/N) \cdot X, \end{array}\f] where \f$F^*=\left(\textrm{Re}(F^{(N)})-\textrm{Im}(F^{(N)})\right)^T\f$

  • Forward the 2D Fourier transform of a M x N matrix: \f[Y = F^{(M)} \cdot X \cdot F^{(N)}\f]

  • Inverse the 2D Fourier transform of a M x N matrix: \f[\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}\f]

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: \f[\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}\f] 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

@sa dct , getOptimalDFTSize , mulSpectrums, filter2D , matchTemplate , flip , cartToPolar , magnitude , phase

Python prototype (for reference only):

dft(src[, dst[, flags[, nonzeroRows]]]) -> dst
@spec dft(Evision.Mat.maybe_mat_in(), [{atom(), term()}, ...] | nil) ::
  Evision.Mat.t() | {:error, String.t()}

Performs a forward or inverse Discrete Fourier transform of a 1D or 2D floating-point array.

Positional Arguments
  • src: Evision.Mat.t().

    input array that could be real or complex.

Keyword Arguments
  • flags: int.

    transformation flags, representing a combination of the #DftFlags

  • nonzeroRows: int.

    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.

Return
  • dst: Evision.Mat.t().

    output array whose size and type depends on the flags .

The function cv::dft performs one of the following:

  • Forward the Fourier transform of a 1D vector of N elements: \f[Y = F^{(N)} \cdot X,\f] where \f$F^{(N)}_{jk}=\exp(-2\pi i j k/N)\f$ and \f$i=\sqrt{-1}\f$

  • Inverse the Fourier transform of a 1D vector of N elements: \f[\begin{array}{l} X'= \left (F^{(N)} \right )^{-1} \cdot Y = \left (F^{(N)} \right )^* \cdot y \\ X = (1/N) \cdot X, \end{array}\f] where \f$F^*=\left(\textrm{Re}(F^{(N)})-\textrm{Im}(F^{(N)})\right)^T\f$

  • Forward the 2D Fourier transform of a M x N matrix: \f[Y = F^{(M)} \cdot X \cdot F^{(N)}\f]

  • Inverse the 2D Fourier transform of a M x N matrix: \f[\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}\f]

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: \f[\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}\f] 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

@sa dct , getOptimalDFTSize , mulSpectrums, filter2D , matchTemplate , flip , cartToPolar , magnitude , phase

Python prototype (for reference only):

dft(src[, dst[, flags[, nonzeroRows]]]) -> dst

Dilates an image by using a specific structuring element.

Positional Arguments
  • src: Evision.Mat.t().

    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.

  • kernel: Evision.Mat.t().

    structuring element used for dilation; if element=Mat(), a 3 x 3 rectangular structuring element is used. Kernel can be created using #getStructuringElement

Keyword Arguments
  • anchor: Point.

    position of the anchor within the element; default value (-1, -1) means that the anchor is at the element center.

  • iterations: int.

    number of times dilation is applied.

  • borderType: int.

    pixel extrapolation method, see #BorderTypes. #BORDER_WRAP is not suported.

  • borderValue: Scalar.

    border value in case of a constant border

Return
  • dst: Evision.Mat.t().

    output image of the same size and type as src.

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: \f[\texttt{dst} (x,y) = \max _{(x',y'): \, \texttt{element} (x',y') \ne0 } \texttt{src} (x+x',y+y')\f] 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. @sa erode, morphologyEx, getStructuringElement

Python prototype (for reference only):

dilate(src, kernel[, dst[, anchor[, iterations[, borderType[, borderValue]]]]]) -> dst
Link to this function

dilate(src, kernel, opts)

View Source
@spec dilate(
  Evision.Mat.maybe_mat_in(),
  Evision.Mat.maybe_mat_in(),
  [{atom(), term()}, ...] | nil
) ::
  Evision.Mat.t() | {:error, String.t()}

Dilates an image by using a specific structuring element.

Positional Arguments
  • src: Evision.Mat.t().

    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.

  • kernel: Evision.Mat.t().

    structuring element used for dilation; if element=Mat(), a 3 x 3 rectangular structuring element is used. Kernel can be created using #getStructuringElement

Keyword Arguments
  • anchor: Point.

    position of the anchor within the element; default value (-1, -1) means that the anchor is at the element center.

  • iterations: int.

    number of times dilation is applied.

  • borderType: int.

    pixel extrapolation method, see #BorderTypes. #BORDER_WRAP is not suported.

  • borderValue: Scalar.

    border value in case of a constant border

Return
  • dst: Evision.Mat.t().

    output image of the same size and type as src.

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: \f[\texttt{dst} (x,y) = \max _{(x',y'): \, \texttt{element} (x',y') \ne0 } \texttt{src} (x+x',y+y')\f] 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. @sa erode, morphologyEx, getStructuringElement

Python prototype (for reference only):

dilate(src, kernel[, dst[, anchor[, iterations[, borderType[, borderValue]]]]]) -> dst
Link to this function

displayOverlay(winname, text)

View Source
@spec displayOverlay(binary(), binary()) :: :ok | {:error, String.t()}

Displays a text on a window image as an overlay for a specified duration.

Positional Arguments
  • winname: String.

    Name of the window.

  • text: String.

    Overlay text to write on a window image.

Keyword Arguments
  • delayms: int.

    The period (in milliseconds), during which the overlay text is displayed. If this function is called before the previous overlay text timed out, the timer is restarted and the text is updated. If this value is zero, the text never disappears.

The function displayOverlay displays useful information/tips on top of the window for a certain amount of time delayms. The function does not modify the image, displayed in the window, that is, after the specified delay the original content of the window is restored.

Python prototype (for reference only):

displayOverlay(winname, text[, delayms]) -> None
Link to this function

displayOverlay(winname, text, opts)

View Source
@spec displayOverlay(binary(), binary(), [{atom(), term()}, ...] | nil) ::
  :ok | {:error, String.t()}

Displays a text on a window image as an overlay for a specified duration.

Positional Arguments
  • winname: String.

    Name of the window.

  • text: String.

    Overlay text to write on a window image.

Keyword Arguments
  • delayms: int.

    The period (in milliseconds), during which the overlay text is displayed. If this function is called before the previous overlay text timed out, the timer is restarted and the text is updated. If this value is zero, the text never disappears.

The function displayOverlay displays useful information/tips on top of the window for a certain amount of time delayms. The function does not modify the image, displayed in the window, that is, after the specified delay the original content of the window is restored.

Python prototype (for reference only):

displayOverlay(winname, text[, delayms]) -> None
Link to this function

displayStatusBar(winname, text)

View Source
@spec displayStatusBar(binary(), binary()) :: :ok | {:error, String.t()}

Displays a text on the window statusbar during the specified period of time.

Positional Arguments
  • winname: String.

    Name of the window.

  • text: String.

    Text to write on the window statusbar.

Keyword Arguments
  • delayms: int.

    Duration (in milliseconds) to display the text. If this function is called before the previous text timed out, the timer is restarted and the text is updated. If this value is zero, the text never disappears.

The function displayStatusBar displays useful information/tips on top of the window for a certain amount of time delayms . This information is displayed on the window statusbar (the window must be created with the CV_GUI_EXPANDED flags).

Python prototype (for reference only):

displayStatusBar(winname, text[, delayms]) -> None
Link to this function

displayStatusBar(winname, text, opts)

View Source
@spec displayStatusBar(binary(), binary(), [{atom(), term()}, ...] | nil) ::
  :ok | {:error, String.t()}

Displays a text on the window statusbar during the specified period of time.

Positional Arguments
  • winname: String.

    Name of the window.

  • text: String.

    Text to write on the window statusbar.

Keyword Arguments
  • delayms: int.

    Duration (in milliseconds) to display the text. If this function is called before the previous text timed out, the timer is restarted and the text is updated. If this value is zero, the text never disappears.

The function displayStatusBar displays useful information/tips on top of the window for a certain amount of time delayms . This information is displayed on the window statusbar (the window must be created with the CV_GUI_EXPANDED flags).

Python prototype (for reference only):

displayStatusBar(winname, text[, delayms]) -> None
Link to this function

distanceTransform(src, distanceType, maskSize)

View Source
@spec distanceTransform(Evision.Mat.maybe_mat_in(), integer(), integer()) ::
  Evision.Mat.t() | {:error, String.t()}

distanceTransform

Positional Arguments
  • src: Evision.Mat.t().

    8-bit, single-channel (binary) source image.

  • distanceType: int.

    Type of distance, see #DistanceTypes

  • maskSize: int.

    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 \f$3\times 3\f$ mask gives the same result as \f$5\times 5\f$ or any larger aperture.

Keyword Arguments
  • dstType: int.

    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.

Return
  • dst: Evision.Mat.t().

    Output image with calculated distances. It is a 8-bit or 32-bit floating-point, single-channel image of the same size as src .

Has overloading in C++

Python prototype (for reference only):

distanceTransform(src, distanceType, maskSize[, dst[, dstType]]) -> dst
Link to this function

distanceTransform(src, distanceType, maskSize, opts)

View Source
@spec distanceTransform(
  Evision.Mat.maybe_mat_in(),
  integer(),
  integer(),
  [{atom(), term()}, ...] | nil
) ::
  Evision.Mat.t() | {:error, String.t()}

distanceTransform

Positional Arguments
  • src: Evision.Mat.t().

    8-bit, single-channel (binary) source image.

  • distanceType: int.

    Type of distance, see #DistanceTypes

  • maskSize: int.

    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 \f$3\times 3\f$ mask gives the same result as \f$5\times 5\f$ or any larger aperture.

Keyword Arguments
  • dstType: int.

    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.

Return
  • dst: Evision.Mat.t().

    Output image with calculated distances. It is a 8-bit or 32-bit floating-point, single-channel image of the same size as src .

Has overloading in C++

Python prototype (for reference only):

distanceTransform(src, distanceType, maskSize[, dst[, dstType]]) -> dst
Link to this function

distanceTransformWithLabels(src, distanceType, maskSize)

View Source
@spec distanceTransformWithLabels(Evision.Mat.maybe_mat_in(), integer(), integer()) ::
  {Evision.Mat.t(), Evision.Mat.t()} | {:error, String.t()}

Calculates the distance to the closest zero pixel for each pixel of the source image.

Positional Arguments
  • src: Evision.Mat.t().

    8-bit, single-channel (binary) source image.

  • distanceType: int.

    Type of distance, see #DistanceTypes

  • maskSize: int.

    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 \f$3\times 3\f$ mask gives the same result as \f$5\times 5\f$ or any larger aperture.

Keyword Arguments
  • labelType: int.

    Type of the label array to build, see #DistanceTransformLabelTypes.

Return
  • dst: Evision.Mat.t().

    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: Evision.Mat.t().

    Output 2D array of labels (the discrete Voronoi diagram). It has the type CV_32SC1 and the same size as src.

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 \f$5\times 5\f$ 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 \f$5\times 5\f$ 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 \f$3\times 3\f$ mask is used. For a more accurate distance estimation #DIST_L2, a \f$5\times 5\f$ 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 \f$(x, y)\f$ 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.

Python prototype (for reference only):

distanceTransformWithLabels(src, distanceType, maskSize[, dst[, labels[, labelType]]]) -> dst, labels
Link to this function

distanceTransformWithLabels(src, distanceType, maskSize, opts)

View Source
@spec distanceTransformWithLabels(
  Evision.Mat.maybe_mat_in(),
  integer(),
  integer(),
  [{atom(), term()}, ...] | nil
) :: {Evision.Mat.t(), Evision.Mat.t()} | {:error, String.t()}

Calculates the distance to the closest zero pixel for each pixel of the source image.

Positional Arguments
  • src: Evision.Mat.t().

    8-bit, single-channel (binary) source image.

  • distanceType: int.

    Type of distance, see #DistanceTypes

  • maskSize: int.

    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 \f$3\times 3\f$ mask gives the same result as \f$5\times 5\f$ or any larger aperture.

Keyword Arguments
  • labelType: int.

    Type of the label array to build, see #DistanceTransformLabelTypes.

Return
  • dst: Evision.Mat.t().

    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: Evision.Mat.t().

    Output 2D array of labels (the discrete Voronoi diagram). It has the type CV_32SC1 and the same size as src.

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 \f$5\times 5\f$ 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 \f$5\times 5\f$ 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 \f$3\times 3\f$ mask is used. For a more accurate distance estimation #DIST_L2, a \f$5\times 5\f$ 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 \f$(x, y)\f$ 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.

Python prototype (for reference only):

distanceTransformWithLabels(src, distanceType, maskSize[, dst[, labels[, labelType]]]) -> dst, labels
@spec divide(number(), Evision.Mat.maybe_mat_in()) ::
  Evision.Mat.t() | {:error, String.t()}
@spec divide(Evision.Mat.maybe_mat_in(), Evision.Mat.maybe_mat_in()) ::
  Evision.Mat.t() | {:error, String.t()}

Variant 1:

divide

Positional Arguments
  • scale: double
  • src2: Evision.Mat.t()
Keyword Arguments
  • dtype: int.
Return
  • dst: Evision.Mat.t().

Has overloading in C++

Python prototype (for reference only):

divide(scale, src2[, dst[, dtype]]) -> dst

Variant 2:

Performs per-element division of two arrays or a scalar by an array.

Positional Arguments
  • src1: Evision.Mat.t().

    first input array.

  • src2: Evision.Mat.t().

    second input array of the same size and type as src1.

Keyword Arguments
  • scale: double.

    scalar factor.

  • dtype: int.

    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().

Return
  • dst: Evision.Mat.t().

    output array of the same size and type as src2.

The function cv::divide divides one array by another: \f[\texttt{dst(I) = saturate(src1(I)*scale/src2(I))}\f] or a scalar by an array when there is no src1 : \f[\texttt{dst(I) = saturate(scale/src2(I))}\f] 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. @sa multiply, add, subtract

Python prototype (for reference only):

divide(src1, src2[, dst[, scale[, dtype]]]) -> dst
Link to this function

divide(scale, src2, opts)

View Source
@spec divide(number(), Evision.Mat.maybe_mat_in(), [{atom(), term()}, ...] | nil) ::
  Evision.Mat.t() | {:error, String.t()}
@spec divide(
  Evision.Mat.maybe_mat_in(),
  Evision.Mat.maybe_mat_in(),
  [{atom(), term()}, ...] | nil
) ::
  Evision.Mat.t() | {:error, String.t()}

Variant 1:

divide

Positional Arguments
  • scale: double
  • src2: Evision.Mat.t()
Keyword Arguments
  • dtype: int.
Return
  • dst: Evision.Mat.t().

Has overloading in C++

Python prototype (for reference only):

divide(scale, src2[, dst[, dtype]]) -> dst

Variant 2:

Performs per-element division of two arrays or a scalar by an array.

Positional Arguments
  • src1: Evision.Mat.t().

    first input array.

  • src2: Evision.Mat.t().

    second input array of the same size and type as src1.

Keyword Arguments
  • scale: double.

    scalar factor.

  • dtype: int.

    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().

Return
  • dst: Evision.Mat.t().

    output array of the same size and type as src2.

The function cv::divide divides one array by another: \f[\texttt{dst(I) = saturate(src1(I)*scale/src2(I))}\f] or a scalar by an array when there is no src1 : \f[\texttt{dst(I) = saturate(scale/src2(I))}\f] 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. @sa multiply, add, subtract

Python prototype (for reference only):

divide(src1, src2[, dst[, scale[, dtype]]]) -> dst
Link to this function

divSpectrums(a, b, flags)

View Source
@spec divSpectrums(Evision.Mat.maybe_mat_in(), Evision.Mat.maybe_mat_in(), integer()) ::
  Evision.Mat.t() | {:error, String.t()}

Performs the per-element division of the first Fourier spectrum by the second Fourier spectrum.

Positional Arguments
  • a: Evision.Mat.t().

    first input array.

  • b: Evision.Mat.t().

    second input array of the same size and type as src1 .

  • flags: int.

    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.

Keyword Arguments
  • conjB: bool.

    optional flag that conjugates the second input array before the multiplication (true) or not (false).

Return
  • c: Evision.Mat.t().

    output array of the same size and type as src1 .

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.

Python prototype (for reference only):

divSpectrums(a, b, flags[, c[, conjB]]) -> c
Link to this function

divSpectrums(a, b, flags, opts)

View Source
@spec divSpectrums(
  Evision.Mat.maybe_mat_in(),
  Evision.Mat.maybe_mat_in(),
  integer(),
  [{atom(), term()}, ...] | nil
) :: Evision.Mat.t() | {:error, String.t()}

Performs the per-element division of the first Fourier spectrum by the second Fourier spectrum.

Positional Arguments
  • a: Evision.Mat.t().

    first input array.

  • b: Evision.Mat.t().

    second input array of the same size and type as src1 .

  • flags: int.

    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.

Keyword Arguments
  • conjB: bool.

    optional flag that conjugates the second input array before the multiplication (true) or not (false).

Return
  • c: Evision.Mat.t().

    output array of the same size and type as src1 .

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.

Python prototype (for reference only):

divSpectrums(a, b, flags[, c[, conjB]]) -> c
Link to this function

drawChessboardCorners(image, patternSize, corners, patternWasFound)

View Source
@spec drawChessboardCorners(
  Evision.Mat.maybe_mat_in(),
  {number(), number()},
  Evision.Mat.maybe_mat_in(),
  boolean()
) :: Evision.Mat.t() | {:error, String.t()}

Renders the detected chessboard corners.

Positional Arguments
  • patternSize: Size.

    Number of inner corners per a chessboard row and column (patternSize = cv::Size(points_per_row,points_per_column)).

  • corners: Evision.Mat.t().

    Array of detected corners, the output of #findChessboardCorners.

  • patternWasFound: bool.

    Parameter indicating whether the complete board was found or not. The return value of #findChessboardCorners should be passed here.

Return
  • image: Evision.Mat.t().

    Destination image. It must be an 8-bit color image.

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.

Python prototype (for reference only):

drawChessboardCorners(image, patternSize, corners, patternWasFound) -> image
Link to this function

drawContours(image, contours, contourIdx, color)

View Source
@spec drawContours(
  Evision.Mat.maybe_mat_in(),
  [Evision.Mat.maybe_mat_in()],
  integer(),
  {number()}
  | {number(), number()}
  | {number(), number(), number()}
  | {number(), number(), number(), number()}
) :: Evision.Mat.t() | {:error, String.t()}

Draws contours outlines or filled contours.

Positional Arguments
  • contours: [Evision.Mat].

    All the input contours. Each contour is stored as a point vector.

  • contourIdx: int.

    Parameter indicating a contour to draw. If it is negative, all the contours are drawn.

  • color: Scalar.

    Color of the contours.

Keyword Arguments
  • thickness: int.

    Thickness of lines the contours are drawn with. If it is negative (for example, thickness=#FILLED ), the contour interiors are drawn.

  • lineType: int.

    Line connectivity. See #LineTypes

  • hierarchy: Evision.Mat.t().

    Optional information about hierarchy. It is only needed if you want to draw only some of the contours (see maxLevel ).

  • maxLevel: int.

    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: Point.

    Optional contour shift parameter. Shift all the drawn contours by the specified \f$\texttt{offset}=(dx,dy)\f$ .

Return
  • image: Evision.Mat.t().

    Destination image.

The function draws contour outlines in the image if \f$\texttt{thickness} \ge 0\f$ or fills the area bounded by the contours if \f$\texttt{thickness}<0\f$ . The example below shows how to retrieve connected components from the binary image and label them: : @include snippets/imgproc_drawContours.cpp 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.

Python prototype (for reference only):

drawContours(image, contours, contourIdx, color[, thickness[, lineType[, hierarchy[, maxLevel[, offset]]]]]) -> image
Link to this function

drawContours(image, contours, contourIdx, color, opts)

View Source
@spec drawContours(
  Evision.Mat.maybe_mat_in(),
  [Evision.Mat.maybe_mat_in()],
  integer(),
  {number()}
  | {number(), number()}
  | {number(), number(), number()}
  | {number(), number(), number(), number()},
  [{atom(), term()}, ...] | nil
) :: Evision.Mat.t() | {:error, String.t()}

Draws contours outlines or filled contours.

Positional Arguments
  • contours: [Evision.Mat].

    All the input contours. Each contour is stored as a point vector.

  • contourIdx: int.

    Parameter indicating a contour to draw. If it is negative, all the contours are drawn.

  • color: Scalar.

    Color of the contours.

Keyword Arguments
  • thickness: int.

    Thickness of lines the contours are drawn with. If it is negative (for example, thickness=#FILLED ), the contour interiors are drawn.

  • lineType: int.

    Line connectivity. See #LineTypes

  • hierarchy: Evision.Mat.t().

    Optional information about hierarchy. It is only needed if you want to draw only some of the contours (see maxLevel ).

  • maxLevel: int.

    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: Point.

    Optional contour shift parameter. Shift all the drawn contours by the specified \f$\texttt{offset}=(dx,dy)\f$ .

Return
  • image: Evision.Mat.t().

    Destination image.

The function draws contour outlines in the image if \f$\texttt{thickness} \ge 0\f$ or fills the area bounded by the contours if \f$\texttt{thickness}<0\f$ . The example below shows how to retrieve connected components from the binary image and label them: : @include snippets/imgproc_drawContours.cpp 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.

Python prototype (for reference only):

drawContours(image, contours, contourIdx, color[, thickness[, lineType[, hierarchy[, maxLevel[, offset]]]]]) -> image
Link to this function

drawFrameAxes(image, cameraMatrix, distCoeffs, rvec, tvec, length)

View Source

Draw axes of the world/object coordinate system from pose estimation. @sa solvePnP

Positional Arguments
  • cameraMatrix: Evision.Mat.t().

    Input 3x3 floating-point matrix of camera intrinsic parameters. \f$\cameramatrix{A}\f$

  • distCoeffs: Evision.Mat.t().

    Input vector of distortion coefficients \f$\distcoeffs\f$. If the vector is empty, the zero distortion coefficients are assumed.

  • rvec: Evision.Mat.t().

    Rotation vector (see @ref Rodrigues ) that, together with tvec, brings points from the model coordinate system to the camera coordinate system.

  • tvec: Evision.Mat.t().

    Translation vector.

  • length: float.

    Length of the painted axes in the same unit than tvec (usually in meters).

Keyword Arguments
  • thickness: int.

    Line thickness of the painted axes.

Return
  • image: Evision.Mat.t().

    Input/output image. It must have 1 or 3 channels. The number of channels is not altered.

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.

Python prototype (for reference only):

drawFrameAxes(image, cameraMatrix, distCoeffs, rvec, tvec, length[, thickness]) -> image
Link to this function

drawFrameAxes(image, cameraMatrix, distCoeffs, rvec, tvec, length, opts)

View Source

Draw axes of the world/object coordinate system from pose estimation. @sa solvePnP

Positional Arguments
  • cameraMatrix: Evision.Mat.t().

    Input 3x3 floating-point matrix of camera intrinsic parameters. \f$\cameramatrix{A}\f$

  • distCoeffs: Evision.Mat.t().

    Input vector of distortion coefficients \f$\distcoeffs\f$. If the vector is empty, the zero distortion coefficients are assumed.

  • rvec: Evision.Mat.t().

    Rotation vector (see @ref Rodrigues ) that, together with tvec, brings points from the model coordinate system to the camera coordinate system.

  • tvec: Evision.Mat.t().

    Translation vector.

  • length: float.

    Length of the painted axes in the same unit than tvec (usually in meters).

Keyword Arguments
  • thickness: int.

    Line thickness of the painted axes.

Return
  • image: Evision.Mat.t().

    Input/output image. It must have 1 or 3 channels. The number of channels is not altered.

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.

Python prototype (for reference only):

drawFrameAxes(image, cameraMatrix, distCoeffs, rvec, tvec, length[, thickness]) -> image
Link to this function

drawKeypoints(image, keypoints, outImage)

View Source
@spec drawKeypoints(
  Evision.Mat.maybe_mat_in(),
  [Evision.KeyPoint.t()],
  Evision.Mat.maybe_mat_in()
) ::
  Evision.Mat.t() | {:error, String.t()}

Draws keypoints.

Positional Arguments
  • image: Evision.Mat.t().

    Source image.

  • keypoints: [Evision.KeyPoint].

    Keypoints from the source image.

Keyword Arguments
  • color: Scalar.

    Color of keypoints.

  • flags: DrawMatchesFlags.

    Flags setting drawing features. Possible flags bit values are defined by DrawMatchesFlags. See details above in drawMatches .

Return
  • outImage: Evision.Mat.t().

    Output image. Its content depends on the flags value defining what is drawn in the output image. See possible flags bit values below.

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

Python prototype (for reference only):

drawKeypoints(image, keypoints, outImage[, color[, flags]]) -> outImage
Link to this function

drawKeypoints(image, keypoints, outImage, opts)

View Source
@spec drawKeypoints(
  Evision.Mat.maybe_mat_in(),
  [Evision.KeyPoint.t()],
  Evision.Mat.maybe_mat_in(),
  [{atom(), term()}, ...] | nil
) :: Evision.Mat.t() | {:error, String.t()}

Draws keypoints.

Positional Arguments
  • image: Evision.Mat.t().

    Source image.

  • keypoints: [Evision.KeyPoint].

    Keypoints from the source image.

Keyword Arguments
  • color: Scalar.

    Color of keypoints.

  • flags: DrawMatchesFlags.

    Flags setting drawing features. Possible flags bit values are defined by DrawMatchesFlags. See details above in drawMatches .

Return
  • outImage: Evision.Mat.t().

    Output image. Its content depends on the flags value defining what is drawn in the output image. See possible flags bit values below.

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

Python prototype (for reference only):

drawKeypoints(image, keypoints, outImage[, color[, flags]]) -> outImage
Link to this function

drawMarker(img, position, color)

View Source
@spec drawMarker(
  Evision.Mat.maybe_mat_in(),
  {number(), number()},
  {number()}
  | {number(), number()}
  | {number(), number(), number()}
  | {number(), number(), number(), number()}
) :: Evision.Mat.t() | {:error, String.t()}

Draws a marker on a predefined position in an image.

Positional Arguments
  • position: Point.

    The point where the crosshair is positioned.

  • color: Scalar.

    Line color.

Keyword Arguments
  • markerType: int.

    The specific type of marker you want to use, see #MarkerTypes

  • markerSize: int.

    The length of the marker axis [default = 20 pixels]

  • thickness: int.

    Line thickness.

  • line_type: int.

    Type of the line, See #LineTypes

Return
  • img: Evision.Mat.t().

    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.

Python prototype (for reference only):

drawMarker(img, position, color[, markerType[, markerSize[, thickness[, line_type]]]]) -> img
Link to this function

drawMarker(img, position, color, opts)

View Source
@spec drawMarker(
  Evision.Mat.maybe_mat_in(),
  {number(), number()},
  {number()}
  | {number(), number()}
  | {number(), number(), number()}
  | {number(), number(), number(), number()},
  [{atom(), term()}, ...] | nil
) :: Evision.Mat.t() | {:error, String.t()}

Draws a marker on a predefined position in an image.

Positional Arguments
  • position: Point.

    The point where the crosshair is positioned.

  • color: Scalar.

    Line color.

Keyword Arguments
  • markerType: int.

    The specific type of marker you want to use, see #MarkerTypes

  • markerSize: int.

    The length of the marker axis [default = 20 pixels]

  • thickness: int.

    Line thickness.

  • line_type: int.

    Type of the line, See #LineTypes

Return
  • img: Evision.Mat.t().

    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.

Python prototype (for reference only):

drawMarker(img, position, color[, markerType[, markerSize[, thickness[, line_type]]]]) -> img
Link to this function

drawMatches(img1, keypoints1, img2, keypoints2, matches1to2, outImg)

View Source

Draws the found matches of keypoints from two images.

Positional Arguments
  • img1: Evision.Mat.t().

    First source image.

  • keypoints1: [Evision.KeyPoint].

    Keypoints from the first source image.

  • img2: Evision.Mat.t().

    Second source image.

  • keypoints2: [Evision.KeyPoint].

    Keypoints from the second source image.

  • matches1to2: [Evision.DMatch].

    Matches from the first image to the second one, which means that keypoints1[i] has a corresponding point in keypoints2[matches[i]] .

Keyword Arguments
  • matchColor: Scalar.

    Color of matches (lines and connected keypoints). If matchColor==Scalar::all(-1) , the color is generated randomly.

  • singlePointColor: Scalar.

    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: [char].

    Mask determining which matches are drawn. If the mask is empty, all matches are drawn.

  • flags: DrawMatchesFlags.

    Flags setting drawing features. Possible flags bit values are defined by DrawMatchesFlags.

Return
  • outImg: Evision.Mat.t().

    Output image. Its content depends on the flags value defining what is drawn in the output image. See possible flags bit values below.

This function draws matches of keypoints from two images in the output image. Match is a line connecting two keypoints (circles). See cv::DrawMatchesFlags.

Python prototype (for reference only):

drawMatches(img1, keypoints1, img2, keypoints2, matches1to2, outImg[, matchColor[, singlePointColor[, matchesMask[, flags]]]]) -> outImg
Link to this function

drawMatches(img1, keypoints1, img2, keypoints2, matches1to2, outImg, opts)

View Source

Variant 1:

drawMatches

Positional Arguments
  • img1: Evision.Mat.t()
  • keypoints1: [Evision.KeyPoint]
  • img2: Evision.Mat.t()
  • keypoints2: [Evision.KeyPoint]
  • matches1to2: [Evision.DMatch]
  • matchesThickness: int
Keyword Arguments
  • matchColor: Scalar.
  • singlePointColor: Scalar.
  • matchesMask: [char].
  • flags: DrawMatchesFlags.
Return
  • outImg: Evision.Mat.t()

Has overloading in C++

Python prototype (for reference only):

drawMatches(img1, keypoints1, img2, keypoints2, matches1to2, outImg, matchesThickness[, matchColor[, singlePointColor[, matchesMask[, flags]]]]) -> outImg

Variant 2:

Draws the found matches of keypoints from two images.

Positional Arguments
  • img1: Evision.Mat.t().

    First source image.

  • keypoints1: [Evision.KeyPoint].

    Keypoints from the first source image.

  • img2: Evision.Mat.t().

    Second source image.

  • keypoints2: [Evision.KeyPoint].

    Keypoints from the second source image.

  • matches1to2: [Evision.DMatch].

    Matches from the first image to the second one, which means that keypoints1[i] has a corresponding point in keypoints2[matches[i]] .

Keyword Arguments
  • matchColor: Scalar.

    Color of matches (lines and connected keypoints). If matchColor==Scalar::all(-1) , the color is generated randomly.

  • singlePointColor: Scalar.

    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: [char].

    Mask determining which matches are drawn. If the mask is empty, all matches are drawn.

  • flags: DrawMatchesFlags.

    Flags setting drawing features. Possible flags bit values are defined by DrawMatchesFlags.

Return
  • outImg: Evision.Mat.t().

    Output image. Its content depends on the flags value defining what is drawn in the output image. See possible flags bit values below.

This function draws matches of keypoints from two images in the output image. Match is a line connecting two keypoints (circles). See cv::DrawMatchesFlags.

Python prototype (for reference only):

drawMatches(img1, keypoints1, img2, keypoints2, matches1to2, outImg[, matchColor[, singlePointColor[, matchesMask[, flags]]]]) -> outImg
Link to this function

drawMatches(img1, keypoints1, img2, keypoints2, matches1to2, outImg, matchesThickness, opts)

View Source

drawMatches

Positional Arguments
  • img1: Evision.Mat.t()
  • keypoints1: [Evision.KeyPoint]
  • img2: Evision.Mat.t()
  • keypoints2: [Evision.KeyPoint]
  • matches1to2: [Evision.DMatch]
  • matchesThickness: int
Keyword Arguments
  • matchColor: Scalar.
  • singlePointColor: Scalar.
  • matchesMask: [char].
  • flags: DrawMatchesFlags.
Return
  • outImg: Evision.Mat.t()

Has overloading in C++

Python prototype (for reference only):

drawMatches(img1, keypoints1, img2, keypoints2, matches1to2, outImg, matchesThickness[, matchColor[, singlePointColor[, matchesMask[, flags]]]]) -> outImg
Link to this function

drawMatchesKnn(img1, keypoints1, img2, keypoints2, matches1to2, outImg)

View Source

drawMatchesKnn

Positional Arguments
  • img1: Evision.Mat.t()
  • keypoints1: [Evision.KeyPoint]
  • img2: Evision.Mat.t()
  • keypoints2: [Evision.KeyPoint]
  • matches1to2: [[Evision.DMatch]]
Keyword Arguments
  • matchColor: Scalar.
  • singlePointColor: Scalar.
  • matchesMask: [[char]].
  • flags: DrawMatchesFlags.
Return
  • outImg: Evision.Mat.t()

Python prototype (for reference only):

drawMatchesKnn(img1, keypoints1, img2, keypoints2, matches1to2, outImg[, matchColor[, singlePointColor[, matchesMask[, flags]]]]) -> outImg
Link to this function

drawMatchesKnn(img1, keypoints1, img2, keypoints2, matches1to2, outImg, opts)

View Source

drawMatchesKnn

Positional Arguments
  • img1: Evision.Mat.t()
  • keypoints1: [Evision.KeyPoint]
  • img2: Evision.Mat.t()
  • keypoints2: [Evision.KeyPoint]
  • matches1to2: [[Evision.DMatch]]
Keyword Arguments
  • matchColor: Scalar.
  • singlePointColor: Scalar.
  • matchesMask: [[char]].
  • flags: DrawMatchesFlags.
Return
  • outImg: Evision.Mat.t()

Python prototype (for reference only):

drawMatchesKnn(img1, keypoints1, img2, keypoints2, matches1to2, outImg[, matchColor[, singlePointColor[, matchesMask[, flags]]]]) -> outImg
Link to this function

edgePreservingFilter(src)

View Source
@spec edgePreservingFilter(Evision.Mat.maybe_mat_in()) ::
  Evision.Mat.t() | {:error, String.t()}

Filtering is the fundamental operation in image and video processing. Edge-preserving smoothing filters are used in many different applications @cite EM11 .

Positional Arguments
  • src: Evision.Mat.t().

    Input 8-bit 3-channel image.

Keyword Arguments
  • flags: int.

    Edge preserving filters: cv::RECURS_FILTER or cv::NORMCONV_FILTER

  • sigma_s: float.

    %Range between 0 to 200.

  • sigma_r: float.

    %Range between 0 to 1.

Return
  • dst: Evision.Mat.t().

    Output 8-bit 3-channel image.

Python prototype (for reference only):

edgePreservingFilter(src[, dst[, flags[, sigma_s[, sigma_r]]]]) -> dst
Link to this function

edgePreservingFilter(src, opts)

View Source
@spec edgePreservingFilter(Evision.Mat.maybe_mat_in(), [{atom(), term()}, ...] | nil) ::
  Evision.Mat.t() | {:error, String.t()}

Filtering is the fundamental operation in image and video processing. Edge-preserving smoothing filters are used in many different applications @cite EM11 .

Positional Arguments
  • src: Evision.Mat.t().

    Input 8-bit 3-channel image.

Keyword Arguments
  • flags: int.

    Edge preserving filters: cv::RECURS_FILTER or cv::NORMCONV_FILTER

  • sigma_s: float.

    %Range between 0 to 200.

  • sigma_r: float.

    %Range between 0 to 1.

Return
  • dst: Evision.Mat.t().

    Output 8-bit 3-channel image.

Python prototype (for reference only):

edgePreservingFilter(src[, dst[, flags[, sigma_s[, sigma_r]]]]) -> dst
@spec eigen(Evision.Mat.maybe_mat_in()) ::
  {Evision.Mat.t(), Evision.Mat.t()} | false | {:error, String.t()}

Calculates eigenvalues and eigenvectors of a symmetric matrix.

Positional Arguments
  • src: Evision.Mat.t().

    input matrix that must have CV_32FC1 or CV_64FC1 type, square size and be symmetrical (src ^T^ == src).

Return
  • retval: bool

  • eigenvalues: Evision.Mat.t().

    output vector of eigenvalues of the same type as src; the eigenvalues are stored in the descending order.

  • eigenvectors: Evision.Mat.t().

    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.

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. @sa eigenNonSymmetric, completeSymm , PCA

Python prototype (for reference only):

eigen(src[, eigenvalues[, eigenvectors]]) -> retval, eigenvalues, eigenvectors
@spec eigen(Evision.Mat.maybe_mat_in(), [{atom(), term()}, ...] | nil) ::
  {Evision.Mat.t(), Evision.Mat.t()} | false | {:error, String.t()}

Calculates eigenvalues and eigenvectors of a symmetric matrix.

Positional Arguments
  • src: Evision.Mat.t().

    input matrix that must have CV_32FC1 or CV_64FC1 type, square size and be symmetrical (src ^T^ == src).

Return
  • retval: bool

  • eigenvalues: Evision.Mat.t().

    output vector of eigenvalues of the same type as src; the eigenvalues are stored in the descending order.

  • eigenvectors: Evision.Mat.t().

    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.

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. @sa eigenNonSymmetric, completeSymm , PCA

Python prototype (for reference only):

eigen(src[, eigenvalues[, eigenvectors]]) -> retval, eigenvalues, eigenvectors
@spec eigenNonSymmetric(Evision.Mat.maybe_mat_in()) ::
  {Evision.Mat.t(), Evision.Mat.t()} | {:error, String.t()}

Calculates eigenvalues and eigenvectors of a non-symmetric matrix (real eigenvalues only).

Positional Arguments
  • src: Evision.Mat.t().

    input matrix (CV_32FC1 or CV_64FC1 type).

Return
  • eigenvalues: Evision.Mat.t().

    output vector of eigenvalues (type is the same type as src).

  • eigenvectors: Evision.Mat.t().

    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.

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()

@sa eigen

Python prototype (for reference only):

eigenNonSymmetric(src[, eigenvalues[, eigenvectors]]) -> eigenvalues, eigenvectors
Link to this function

eigenNonSymmetric(src, opts)

View Source
@spec eigenNonSymmetric(Evision.Mat.maybe_mat_in(), [{atom(), term()}, ...] | nil) ::
  {Evision.Mat.t(), Evision.Mat.t()} | {:error, String.t()}

Calculates eigenvalues and eigenvectors of a non-symmetric matrix (real eigenvalues only).

Positional Arguments
  • src: Evision.Mat.t().

    input matrix (CV_32FC1 or CV_64FC1 type).

Return
  • eigenvalues: Evision.Mat.t().

    output vector of eigenvalues (type is the same type as src).

  • eigenvectors: Evision.Mat.t().

    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.

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()

@sa eigen

Python prototype (for reference only):

eigenNonSymmetric(src[, eigenvalues[, eigenvectors]]) -> eigenvalues, eigenvectors
Link to this function

ellipse2Poly(center, axes, angle, arcStart, arcEnd, delta)

View Source
@spec ellipse2Poly(
  {number(), number()},
  {number(), number()},
  integer(),
  integer(),
  integer(),
  integer()
) :: [{number(), number()}] | {:error, String.t()}

Approximates an elliptic arc with a polyline.

Positional Arguments
  • center: Point.

    Center of the arc.

  • axes: Size.

    Half of the size of the ellipse main axes. See #ellipse for details.

  • angle: int.

    Rotation angle of the ellipse in degrees. See #ellipse for details.

  • arcStart: int.

    Starting angle of the elliptic arc in degrees.

  • arcEnd: int.

    Ending angle of the elliptic arc in degrees.

  • delta: int.

    Angle between the subsequent polyline vertices. It defines the approximation accuracy.

Return
  • pts: [Point].

    Output vector of polyline vertices.

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.

Python prototype (for reference only):

ellipse2Poly(center, axes, angle, arcStart, arcEnd, delta) -> pts
Link to this function

ellipse(img, box, color)

View Source
@spec ellipse(
  Evision.Mat.maybe_mat_in(),
  {{number(), number()}, {number(), number()}, number()},
  {number()}
  | {number(), number()}
  | {number(), number(), number()}
  | {number(), number(), number(), number()}
) :: Evision.Mat.t() | {:error, String.t()}

ellipse

Positional Arguments
  • box: {centre={x, y}, size={s1, s2}, angle}.

    Alternative ellipse representation via RotatedRect. This means that the function draws an ellipse inscribed in the rotated rectangle.

  • color: Scalar.

    Ellipse color.

Keyword Arguments
  • thickness: int.

    Thickness of the ellipse arc outline, if positive. Otherwise, this indicates that a filled ellipse sector is to be drawn.

  • lineType: int.

    Type of the ellipse boundary. See #LineTypes

Return
  • img: Evision.Mat.t().

    Image.

Has overloading in C++

Python prototype (for reference only):

ellipse(img, box, color[, thickness[, lineType]]) -> img
Link to this function

ellipse(img, box, color, opts)

View Source
@spec ellipse(
  Evision.Mat.maybe_mat_in(),
  {{number(), number()}, {number(), number()}, number()},
  {number()}
  | {number(), number()}
  | {number(), number(), number()}
  | {number(), number(), number(), number()},
  [{atom(), term()}, ...] | nil
) :: Evision.Mat.t() | {:error, String.t()}

ellipse

Positional Arguments
  • box: {centre={x, y}, size={s1, s2}, angle}.

    Alternative ellipse representation via RotatedRect. This means that the function draws an ellipse inscribed in the rotated rectangle.

  • color: Scalar.

    Ellipse color.

Keyword Arguments
  • thickness: int.

    Thickness of the ellipse arc outline, if positive. Otherwise, this indicates that a filled ellipse sector is to be drawn.

  • lineType: int.

    Type of the ellipse boundary. See #LineTypes

Return
  • img: Evision.Mat.t().

    Image.

Has overloading in C++

Python prototype (for reference only):

ellipse(img, box, color[, thickness[, lineType]]) -> img
Link to this function

ellipse(img, center, axes, angle, startAngle, endAngle, color)

View Source
@spec ellipse(
  Evision.Mat.maybe_mat_in(),
  {number(), number()},
  {number(), number()},
  number(),
  number(),
  number(),
  {number()}
  | {number(), number()}
  | {number(), number(), number()}
  | {number(), number(), number(), number()}
) :: Evision.Mat.t() | {:error, String.t()}

Draws a simple or thick elliptic arc or fills an ellipse sector.

Positional Arguments
  • center: Point.

    Center of the ellipse.

  • axes: Size.

    Half of the size of the ellipse main axes.

  • angle: double.

    Ellipse rotation angle in degrees.

  • startAngle: double.

    Starting angle of the elliptic arc in degrees.

  • endAngle: double.

    Ending angle of the elliptic arc in degrees.

  • color: Scalar.

    Ellipse color.

Keyword Arguments
  • thickness: int.

    Thickness of the ellipse arc outline, if positive. Otherwise, this indicates that a filled ellipse sector is to be drawn.

  • lineType: int.

    Type of the ellipse boundary. See #LineTypes

  • shift: int.

    Number of fractional bits in the coordinates of the center and values of axes.

Return
  • img: Evision.Mat.t().

    Image.

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 of Elliptic Arc

Python prototype (for reference only):

ellipse(img, center, axes, angle, startAngle, endAngle, color[, thickness[, lineType[, shift]]]) -> img
Link to this function

ellipse(img, center, axes, angle, startAngle, endAngle, color, opts)

View Source
@spec ellipse(
  Evision.Mat.maybe_mat_in(),
  {number(), number()},
  {number(), number()},
  number(),
  number(),
  number(),
  {number()}
  | {number(), number()}
  | {number(), number(), number()}
  | {number(), number(), number(), number()},
  [{atom(), term()}, ...] | nil
) :: Evision.Mat.t() | {:error, String.t()}

Draws a simple or thick elliptic arc or fills an ellipse sector.

Positional Arguments
  • center: Point.

    Center of the ellipse.

  • axes: Size.

    Half of the size of the ellipse main axes.

  • angle: double.

    Ellipse rotation angle in degrees.

  • startAngle: double.

    Starting angle of the elliptic arc in degrees.

  • endAngle: double.

    Ending angle of the elliptic arc in degrees.

  • color: Scalar.

    Ellipse color.

Keyword Arguments
  • thickness: int.

    Thickness of the ellipse arc outline, if positive. Otherwise, this indicates that a filled ellipse sector is to be drawn.

  • lineType: int.

    Type of the ellipse boundary. See #LineTypes

  • shift: int.

    Number of fractional bits in the coordinates of the center and values of axes.

Return
  • img: Evision.Mat.t().

    Image.

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 of Elliptic Arc

Python prototype (for reference only):

ellipse(img, center, axes, angle, startAngle, endAngle, color[, thickness[, lineType[, shift]]]) -> img
Link to this function

emd(signature1, signature2, distType)

View Source

Computes the "minimal work" distance between two weighted point configurations.

Positional Arguments
  • signature1: Evision.Mat.t().

    First signature, a \f$\texttt{size1}\times \texttt{dims}+1\f$ 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: Evision.Mat.t().

    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: int.

    Used metric. See #DistanceTypes.

Keyword Arguments
  • cost: Evision.Mat.t().

    User-defined \f$\texttt{size1}\times \texttt{size2}\f$ cost matrix. Also, if a cost matrix is used, lower boundary lowerBound cannot be calculated because it needs a metric function.

Return
  • retval: float

  • lowerBound: float.

    Optional input/output parameter: lower boundary of a distance between the two 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: Evision.Mat.t().

    Resultant \f$\texttt{size1} \times \texttt{size2}\f$ flow matrix: \f$\texttt{flow}_{i,j}\f$ is a flow from \f$i\f$ -th point of signature1 to \f$j\f$ -th point of signature2 .

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.

Python prototype (for reference only):

EMD(signature1, signature2, distType[, cost[, lowerBound[, flow]]]) -> retval, lowerBound, flow
Link to this function

emd(signature1, signature2, distType, opts)

View Source
@spec emd(
  Evision.Mat.maybe_mat_in(),
  Evision.Mat.maybe_mat_in(),
  integer(),
  [{atom(), term()}, ...] | nil
) :: {number(), number(), Evision.Mat.t()} | {:error, String.t()}

Computes the "minimal work" distance between two weighted point configurations.

Positional Arguments
  • signature1: Evision.Mat.t().

    First signature, a \f$\texttt{size1}\times \texttt{dims}+1\f$ 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: Evision.Mat.t().

    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: int.

    Used metric. See #DistanceTypes.

Keyword Arguments
  • cost: Evision.Mat.t().

    User-defined \f$\texttt{size1}\times \texttt{size2}\f$ cost matrix. Also, if a cost matrix is used, lower boundary lowerBound cannot be calculated because it needs a metric function.

Return
  • retval: float

  • lowerBound: float.

    Optional input/output parameter: lower boundary of a distance between the two 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: Evision.Mat.t().

    Resultant \f$\texttt{size1} \times \texttt{size2}\f$ flow matrix: \f$\texttt{flow}_{i,j}\f$ is a flow from \f$i\f$ -th point of signature1 to \f$j\f$ -th point of signature2 .

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.

Python prototype (for reference only):

EMD(signature1, signature2, distType[, cost[, lowerBound[, flow]]]) -> retval, lowerBound, flow

return a list of enabled modules in this build

@spec equalizeHist(Evision.Mat.maybe_mat_in()) ::
  Evision.Mat.t() | {:error, String.t()}

Equalizes the histogram of a grayscale image.

Positional Arguments
  • src: Evision.Mat.t().

    Source 8-bit single channel image.

Return
  • dst: Evision.Mat.t().

    Destination image of the same size and type as src .

The function equalizes the histogram of the input image using the following algorithm:

  • Calculate the histogram \f$H\f$ for src .

  • Normalize the histogram so that the sum of histogram bins is 255.

  • Compute the integral of the histogram: \f[H'_i = \sum _{0 \le j < i} H(j)\f]

  • Transform the image using \f$H'\f$ as a look-up table: \f$\texttt{dst}(x,y) = H'(\texttt{src}(x,y))\f$

The algorithm normalizes the brightness and increases the contrast of the image.

Python prototype (for reference only):

equalizeHist(src[, dst]) -> dst
@spec equalizeHist(Evision.Mat.maybe_mat_in(), [{atom(), term()}, ...] | nil) ::
  Evision.Mat.t() | {:error, String.t()}

Equalizes the histogram of a grayscale image.

Positional Arguments
  • src: Evision.Mat.t().

    Source 8-bit single channel image.

Return
  • dst: Evision.Mat.t().

    Destination image of the same size and type as src .

The function equalizes the histogram of the input image using the following algorithm:

  • Calculate the histogram \f$H\f$ for src .

  • Normalize the histogram so that the sum of histogram bins is 255.

  • Compute the integral of the histogram: \f[H'_i = \sum _{0 \le j < i} H(j)\f]

  • Transform the image using \f$H'\f$ as a look-up table: \f$\texttt{dst}(x,y) = H'(\texttt{src}(x,y))\f$

The algorithm normalizes the brightness and increases the contrast of the image.

Python prototype (for reference only):

equalizeHist(src[, dst]) -> dst

Erodes an image by using a specific structuring element.

Positional Arguments
  • src: Evision.Mat.t().

    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.

  • kernel: Evision.Mat.t().

    structuring element used for erosion; if element=Mat(), a 3 x 3 rectangular structuring element is used. Kernel can be created using #getStructuringElement.

Keyword Arguments
  • anchor: Point.

    position of the anchor within the element; default value (-1, -1) means that the anchor is at the element center.

  • iterations: int.

    number of times erosion is applied.

  • borderType: int.

    pixel extrapolation method, see #BorderTypes. #BORDER_WRAP is not supported.

  • borderValue: Scalar.

    border value in case of a constant border

Return
  • dst: Evision.Mat.t().

    output image of the same size and type as src.

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: \f[\texttt{dst} (x,y) = \min _{(x',y'): \, \texttt{element} (x',y') \ne0 } \texttt{src} (x+x',y+y')\f] 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. @sa dilate, morphologyEx, getStructuringElement

Python prototype (for reference only):

erode(src, kernel[, dst[, anchor[, iterations[, borderType[, borderValue]]]]]) -> dst
Link to this function

erode(src, kernel, opts)

View Source
@spec erode(
  Evision.Mat.maybe_mat_in(),
  Evision.Mat.maybe_mat_in(),
  [{atom(), term()}, ...] | nil
) ::
  Evision.Mat.t() | {:error, String.t()}

Erodes an image by using a specific structuring element.

Positional Arguments
  • src: Evision.Mat.t().

    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.

  • kernel: Evision.Mat.t().

    structuring element used for erosion; if element=Mat(), a 3 x 3 rectangular structuring element is used. Kernel can be created using #getStructuringElement.

Keyword Arguments
  • anchor: Point.

    position of the anchor within the element; default value (-1, -1) means that the anchor is at the element center.

  • iterations: int.

    number of times erosion is applied.

  • borderType: int.

    pixel extrapolation method, see #BorderTypes. #BORDER_WRAP is not supported.

  • borderValue: Scalar.

    border value in case of a constant border

Return
  • dst: Evision.Mat.t().

    output image of the same size and type as src.

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: \f[\texttt{dst} (x,y) = \min _{(x',y'): \, \texttt{element} (x',y') \ne0 } \texttt{src} (x+x',y+y')\f] 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. @sa dilate, morphologyEx, getStructuringElement

Python prototype (for reference only):

erode(src, kernel[, dst[, anchor[, iterations[, borderType[, borderValue]]]]]) -> dst
Link to this function

estimateAffine2D(from, to)

View Source
@spec estimateAffine2D(Evision.Mat.maybe_mat_in(), Evision.Mat.maybe_mat_in()) ::
  {Evision.Mat.t(), Evision.Mat.t()} | {:error, String.t()}

Computes an optimal affine transformation between two 2D point sets.

Positional Arguments
  • from: Evision.Mat.t().

    First input 2D point set containing \f$(X,Y)\f$.

  • to: Evision.Mat.t().

    Second input 2D point set containing \f$(x,y)\f$.

Keyword Arguments
  • method: int.

    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: double.

    Maximum reprojection error in the RANSAC algorithm to consider a point as an inlier. Applies only to RANSAC.

  • maxIters: size_t.

    The maximum number of robust method iterations.

  • confidence: double.

    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: size_t.

    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
  • retval: Evision.Mat.t()

  • inliers: Evision.Mat.t().

    Output vector indicating which points are inliers (1-inlier, 0-outlier).

It computes \f[ \begin{bmatrix} x\\ y\\ \end{bmatrix} \begin{bmatrix} a_{11} & a_{12}\\ a_{21} & a_{22}\\ \end{bmatrix} \begin{bmatrix} X\\ Y\\ \end{bmatrix} + \begin{bmatrix} b_1\\ b_2\\ \end{bmatrix} \f]

@return Output 2D affine transformation matrix \f$2 \times 3\f$ or empty matrix if transformation could not be estimated. The returned matrix has the following form: \f[ \begin{bmatrix} a_{11} & a_{12} & b_1\\ a_{21} & a_{22} & b_2\\ \end{bmatrix} \f] The function estimates an optimal 2D affine transformation between two 2D point sets using the selected robust algorithm. The computed transformation is then refined further (using only inliers) with the Levenberg-Marquardt method to reduce the re-projection error even more. Note: The RANSAC method can handle practically any ratio of outliers but needs a threshold to distinguish inliers from outliers. The method LMeDS does not need any threshold but it works correctly only when there are more than 50% of inliers. @sa estimateAffinePartial2D, getAffineTransform

Python prototype (for reference only):

estimateAffine2D(from, to[, inliers[, method[, ransacReprojThreshold[, maxIters[, confidence[, refineIters]]]]]]) -> retval, inliers
Link to this function

estimateAffine2D(from, to, opts)

View Source
@spec estimateAffine2D(
  Evision.Mat.maybe_mat_in(),
  Evision.Mat.maybe_mat_in(),
  [{atom(), term()}, ...] | nil
) :: {Evision.Mat.t(), Evision.Mat.t()} | {:error, String.t()}
@spec estimateAffine2D(
  Evision.Mat.maybe_mat_in(),
  Evision.Mat.maybe_mat_in(),
  Evision.UsacParams.t()
) ::
  {Evision.Mat.t(), Evision.Mat.t()} | {:error, String.t()}

Variant 1:

estimateAffine2D

Positional Arguments
  • pts1: Evision.Mat.t()
  • pts2: Evision.Mat.t()
  • params: Evision.UsacParams.t()
Return
  • retval: Evision.Mat.t()
  • inliers: Evision.Mat.t().

Python prototype (for reference only):

estimateAffine2D(pts1, pts2, params[, inliers]) -> retval, inliers

Variant 2:

Computes an optimal affine transformation between two 2D point sets.

Positional Arguments
  • from: Evision.Mat.t().

    First input 2D point set containing \f$(X,Y)\f$.

  • to: Evision.Mat.t().

    Second input 2D point set containing \f$(x,y)\f$.

Keyword Arguments
  • method: int.

    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: double.

    Maximum reprojection error in the RANSAC algorithm to consider a point as an inlier. Applies only to RANSAC.

  • maxIters: size_t.

    The maximum number of robust method iterations.

  • confidence: double.

    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: size_t.

    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
  • retval: Evision.Mat.t()

  • inliers: Evision.Mat.t().

    Output vector indicating which points are inliers (1-inlier, 0-outlier).

It computes \f[ \begin{bmatrix} x\\ y\\ \end{bmatrix} \begin{bmatrix} a_{11} & a_{12}\\ a_{21} & a_{22}\\ \end{bmatrix} \begin{bmatrix} X\\ Y\\ \end{bmatrix} + \begin{bmatrix} b_1\\ b_2\\ \end{bmatrix} \f]

@return Output 2D affine transformation matrix \f$2 \times 3\f$ or empty matrix if transformation could not be estimated. The returned matrix has the following form: \f[ \begin{bmatrix} a_{11} & a_{12} & b_1\\ a_{21} & a_{22} & b_2\\ \end{bmatrix} \f] The function estimates an optimal 2D affine transformation between two 2D point sets using the selected robust algorithm. The computed transformation is then refined further (using only inliers) with the Levenberg-Marquardt method to reduce the re-projection error even more. Note: The RANSAC method can handle practically any ratio of outliers but needs a threshold to distinguish inliers from outliers. The method LMeDS does not need any threshold but it works correctly only when there are more than 50% of inliers. @sa estimateAffinePartial2D, getAffineTransform

Python prototype (for reference only):

estimateAffine2D(from, to[, inliers[, method[, ransacReprojThreshold[, maxIters[, confidence[, refineIters]]]]]]) -> retval, inliers
Link to this function

estimateAffine2D(pts1, pts2, params, opts)

View Source
@spec estimateAffine2D(
  Evision.Mat.maybe_mat_in(),
  Evision.Mat.maybe_mat_in(),
  Evision.UsacParams.t(),
  [{atom(), term()}, ...] | nil
) :: {Evision.Mat.t(), Evision.Mat.t()} | {:error, String.t()}

estimateAffine2D

Positional Arguments
  • pts1: Evision.Mat.t()
  • pts2: Evision.Mat.t()
  • params: Evision.UsacParams.t()
Return
  • retval: Evision.Mat.t()
  • inliers: Evision.Mat.t().

Python prototype (for reference only):

estimateAffine2D(pts1, pts2, params[, inliers]) -> retval, inliers
Link to this function

estimateAffine3D(src, dst)

View Source
@spec estimateAffine3D(Evision.Mat.maybe_mat_in(), Evision.Mat.maybe_mat_in()) ::
  {Evision.Mat.t(), number()} | {:error, String.t()}

Computes an optimal affine transformation between two 3D point sets.

Positional Arguments
  • src: Evision.Mat.t().

    First input 3D point set.

  • dst: Evision.Mat.t().

    Second input 3D point set.

Keyword Arguments
  • force_rotation: bool.

    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
  • retval: Evision.Mat.t()

  • scale: double*.

    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.

It computes \f$R,s,t\f$ minimizing \f$\sum{i} dst_i - c \cdot R \cdot src_i \f$ where \f$R\f$ is a 3x3 rotation matrix, \f$t\f$ is a 3x1 translation vector and \f$s\f$ 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. @return 3D affine transformation matrix \f$3 \times 4\f$ of the form \f[T = \begin{bmatrix} R & t\\ \end{bmatrix} \f]

Python prototype (for reference only):

estimateAffine3D(src, dst[, force_rotation]) -> retval, scale
Link to this function

estimateAffine3D(src, dst, opts)

View Source
@spec estimateAffine3D(
  Evision.Mat.maybe_mat_in(),
  Evision.Mat.maybe_mat_in(),
  [{atom(), term()}, ...] | nil
) :: {Evision.Mat.t(), number()} | {:error, String.t()}

Computes an optimal affine transformation between two 3D point sets.

Positional Arguments
  • src: Evision.Mat.t().

    First input 3D point set.

  • dst: Evision.Mat.t().

    Second input 3D point set.

Keyword Arguments
  • force_rotation: bool.

    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
  • retval: Evision.Mat.t()

  • scale: double*.

    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.

It computes \f$R,s,t\f$ minimizing \f$\sum{i} dst_i - c \cdot R \cdot src_i \f$ where \f$R\f$ is a 3x3 rotation matrix, \f$t\f$ is a 3x1 translation vector and \f$s\f$ 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. @return 3D affine transformation matrix \f$3 \times 4\f$ of the form \f[T = \begin{bmatrix} R & t\\ \end{bmatrix} \f]

Python prototype (for reference only):

estimateAffine3D(src, dst[, force_rotation]) -> retval, scale
Link to this function

estimateAffinePartial2D(from, to)

View Source
@spec estimateAffinePartial2D(Evision.Mat.maybe_mat_in(), Evision.Mat.maybe_mat_in()) ::
  {Evision.Mat.t(), Evision.Mat.t()} | {:error, String.t()}

Computes an optimal limited affine transformation with 4 degrees of freedom between two 2D point sets.

Positional Arguments
  • from: Evision.Mat.t().

    First input 2D point set.

  • to: Evision.Mat.t().

    Second input 2D point set.

Keyword Arguments
  • method: int.

    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: double.

    Maximum reprojection error in the RANSAC algorithm to consider a point as an inlier. Applies only to RANSAC.

  • maxIters: size_t.

    The maximum number of robust method iterations.

  • confidence: double.

    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: size_t.

    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
  • retval: Evision.Mat.t()

  • inliers: Evision.Mat.t().

    Output vector indicating which points are inliers.

@return Output 2D affine transformation (4 degrees of freedom) matrix \f$2 \times 3\f$ or empty matrix if transformation could not be estimated. The function estimates an optimal 2D affine transformation with 4 degrees of freedom limited to combinations of translation, rotation, and uniform scaling. Uses the selected algorithm for robust estimation. The computed transformation is then refined further (using only inliers) with the Levenberg-Marquardt method to reduce the re-projection error even more. Estimated transformation matrix is: \f[ \begin{bmatrix} \cos(\theta) \cdot s & -\sin(\theta) \cdot s & t_x \\ \sin(\theta) \cdot s & \cos(\theta) \cdot s & t_y \end{bmatrix} \f] Where \f$ \theta \f$ is the rotation angle, \f$ s \f$ the scaling factor and \f$ t_x, t_y \f$ are translations in \f$ x, y \f$ axes respectively. Note: The RANSAC method can handle practically any ratio of outliers but need a threshold to distinguish inliers from outliers. The method LMeDS does not need any threshold but it works correctly only when there are more than 50% of inliers. @sa estimateAffine2D, getAffineTransform

Python prototype (for reference only):

estimateAffinePartial2D(from, to[, inliers[, method[, ransacReprojThreshold[, maxIters[, confidence[, refineIters]]]]]]) -> retval, inliers
Link to this function

estimateAffinePartial2D(from, to, opts)

View Source
@spec estimateAffinePartial2D(
  Evision.Mat.maybe_mat_in(),
  Evision.Mat.maybe_mat_in(),
  [{atom(), term()}, ...] | nil
) :: {Evision.Mat.t(), Evision.Mat.t()} | {:error, String.t()}

Computes an optimal limited affine transformation with 4 degrees of freedom between two 2D point sets.

Positional Arguments
  • from: Evision.Mat.t().

    First input 2D point set.

  • to: Evision.Mat.t().

    Second input 2D point set.

Keyword Arguments
  • method: int.

    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: double.

    Maximum reprojection error in the RANSAC algorithm to consider a point as an inlier. Applies only to RANSAC.

  • maxIters: size_t.

    The maximum number of robust method iterations.

  • confidence: double.

    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: size_t.

    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
  • retval: Evision.Mat.t()

  • inliers: Evision.Mat.t().

    Output vector indicating which points are inliers.

@return Output 2D affine transformation (4 degrees of freedom) matrix \f$2 \times 3\f$ or empty matrix if transformation could not be estimated. The function estimates an optimal 2D affine transformation with 4 degrees of freedom limited to combinations of translation, rotation, and uniform scaling. Uses the selected algorithm for robust estimation. The computed transformation is then refined further (using only inliers) with the Levenberg-Marquardt method to reduce the re-projection error even more. Estimated transformation matrix is: \f[ \begin{bmatrix} \cos(\theta) \cdot s & -\sin(\theta) \cdot s & t_x \\ \sin(\theta) \cdot s & \cos(\theta) \cdot s & t_y \end{bmatrix} \f] Where \f$ \theta \f$ is the rotation angle, \f$ s \f$ the scaling factor and \f$ t_x, t_y \f$ are translations in \f$ x, y \f$ axes respectively. Note: The RANSAC method can handle practically any ratio of outliers but need a threshold to distinguish inliers from outliers. The method LMeDS does not need any threshold but it works correctly only when there are more than 50% of inliers. @sa estimateAffine2D, getAffineTransform

Python prototype (for reference only):

estimateAffinePartial2D(from, to[, inliers[, method[, ransacReprojThreshold[, maxIters[, confidence[, refineIters]]]]]]) -> retval, inliers
Link to this function

estimateChessboardSharpness(image, patternSize, corners)

View Source
@spec estimateChessboardSharpness(
  Evision.Mat.maybe_mat_in(),
  {number(), number()},
  Evision.Mat.maybe_mat_in()
) ::
  {{number()}
   | {number(), number()}
   | {number(), number(), number()}
   | {number(), number(), number(), number()}, Evision.Mat.t()}
  | {:error, String.t()}

Estimates the sharpness of a detected chessboard.

Positional Arguments
  • image: Evision.Mat.t().

    Gray image used to find chessboard corners

  • patternSize: Size.

    Size of a found chessboard pattern

  • corners: Evision.Mat.t().

    Corners found by #findChessboardCornersSB

Keyword Arguments
  • rise_distance: float.

    Rise distance 0.8 means 10% ... 90% of the final signal strength

  • vertical: bool.

    By default edge responses for horizontal lines are calculated

Return
  • retval: Scalar

  • sharpness: Evision.Mat.t().

    Optional output array with a sharpness value for calculated edge responses (see description)

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.

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)

Python prototype (for reference only):

estimateChessboardSharpness(image, patternSize, corners[, rise_distance[, vertical[, sharpness]]]) -> retval, sharpness
Link to this function

estimateChessboardSharpness(image, patternSize, corners, opts)

View Source
@spec estimateChessboardSharpness(
  Evision.Mat.maybe_mat_in(),
  {number(), number()},
  Evision.Mat.maybe_mat_in(),
  [{atom(), term()}, ...] | nil
) ::
  {{number()}
   | {number(), number()}
   | {number(), number(), number()}
   | {number(), number(), number(), number()}, Evision.Mat.t()}
  | {:error, String.t()}

Estimates the sharpness of a detected chessboard.

Positional Arguments
  • image: Evision.Mat.t().

    Gray image used to find chessboard corners

  • patternSize: Size.

    Size of a found chessboard pattern

  • corners: Evision.Mat.t().

    Corners found by #findChessboardCornersSB

Keyword Arguments
  • rise_distance: float.

    Rise distance 0.8 means 10% ... 90% of the final signal strength

  • vertical: bool.

    By default edge responses for horizontal lines are calculated

Return
  • retval: Scalar

  • sharpness: Evision.Mat.t().

    Optional output array with a sharpness value for calculated edge responses (see description)

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.

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)

Python prototype (for reference only):

estimateChessboardSharpness(image, patternSize, corners[, rise_distance[, vertical[, sharpness]]]) -> retval, sharpness
Link to this function

estimateTranslation3D(src, dst)

View Source
@spec estimateTranslation3D(Evision.Mat.maybe_mat_in(), Evision.Mat.maybe_mat_in()) ::
  {integer(), Evision.Mat.t(), Evision.Mat.t()} | {:error, String.t()}

Computes an optimal translation between two 3D point sets.

Positional Arguments
  • src: Evision.Mat.t().

    First input 3D point set containing \f$(X,Y,Z)\f$.

  • dst: Evision.Mat.t().

    Second input 3D point set containing \f$(x,y,z)\f$.

Keyword Arguments
  • ransacThreshold: double.

    Maximum reprojection error in the RANSAC algorithm to consider a point as an inlier.

  • confidence: double.

    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.

Return
  • retval: int

  • out: Evision.Mat.t().

    Output 3D translation vector \f$3 \times 1\f$ of the form \f[ \begin{bmatrix} b_1 \\ b_2 \\ b_3 \\ \end{bmatrix} \f]

  • inliers: Evision.Mat.t().

    Output vector indicating which points are inliers (1-inlier, 0-outlier).

It computes \f[ \begin{bmatrix} x\\ y\\ z\\ \end{bmatrix} \begin{bmatrix} X\\ Y\\ Z\\ \end{bmatrix} + \begin{bmatrix} b_1\\ b_2\\ b_3\\ \end{bmatrix} \f]

The function estimates an optimal 3D translation between two 3D point sets using the RANSAC algorithm.

Python prototype (for reference only):

estimateTranslation3D(src, dst[, out[, inliers[, ransacThreshold[, confidence]]]]) -> retval, out, inliers