Struct cv::mat::Mat [−][src]
The class Mat
represents an n-dimensional dense numerical single-channel or multi-channel array.
It can be used to store real or complex-valued vectors and matrices, grayscale or color images,
voxel volumes, vector fields, point clouds, tensors, histograms
Fields
cols: c_int
Number of columns
rows: c_int
Number of rows
depth: c_int
Depth of this mat (it should be the type).
channels: c_int
Channels of this mat
Implementations
impl Mat
[src]
pub fn image_decode(buf: &[u8], mode: ImageReadMode) -> Mat
[src]
Decodes an image from buf
according to the specified mode.
pub fn image_encode(
&self,
ext: &str,
flags: Vec<ImageWriteMode>
) -> Result<Vec<u8>, Error>
[src]
&self,
ext: &str,
flags: Vec<ImageWriteMode>
) -> Result<Vec<u8>, Error>
Encodes an image; the encoding scheme depends on the extension provided; additional write flags can be passed in using a vector. If successful, returns an owned vector of the encoded image.
pub fn from_path<P: AsRef<Path>>(
path: P,
flags: ImageReadMode
) -> Result<Mat, Error>
[src]
path: P,
flags: ImageReadMode
) -> Result<Mat, Error>
Creates a Mat
from reading the image specified by the path.
impl Mat
[src]
pub fn line(&self, pt1: Point2i, pt2: Point2i)
[src]
Draws a simple line.
pub fn line_custom(
&self,
pt1: Point2i,
pt2: Point2i,
color: Scalar,
thickness: c_int,
linetype: LineType,
shift: c_int
)
[src]
&self,
pt1: Point2i,
pt2: Point2i,
color: Scalar,
thickness: c_int,
linetype: LineType,
shift: c_int
)
Draws a line with custom color, thickness and linetype.
pub fn rectangle(&self, rect: Rect)
[src]
Draws a simple, thick, or filled up-right rectangle.
pub fn rectangle_custom(
&self,
rect: Rect,
color: Scalar,
thickness: c_int,
linetype: LineType
)
[src]
&self,
rect: Rect,
color: Scalar,
thickness: c_int,
linetype: LineType
)
Draws a rectangle with custom color, thickness and linetype.
pub fn rectangle2f(&self, rect: Rect2f)
[src]
Draw a simple, thick, or filled up-right rectangle.
pub fn ellipse(
&self,
center: Point2i,
axes: Size2i,
angle: f64,
start_angle: f64,
end_angle: f64
)
[src]
&self,
center: Point2i,
axes: Size2i,
angle: f64,
start_angle: f64,
end_angle: f64
)
Draws a simple, thick ellipse
pub fn ellipse_custom(
&self,
center: Point2i,
axes: Size2i,
angle: f64,
start_angle: f64,
end_angle: f64,
color: Scalar,
thickness: c_int,
linetype: LineType,
shift: c_int
)
[src]
&self,
center: Point2i,
axes: Size2i,
angle: f64,
start_angle: f64,
end_angle: f64,
color: Scalar,
thickness: c_int,
linetype: LineType,
shift: c_int
)
Draws a custom ellipse
pub fn cvt_color(&self, code: ColorConversion) -> Mat
[src]
Convert an image from one color space to another.
pub fn pyr_down(&self) -> Mat
[src]
Blurs an image and downsamples it. This function performs the downsampling step of the Gaussian pyramid construction.
pub fn threshold(
&self,
thresh: f64,
maxval: f64,
threshold_type: ThresholdType
) -> Mat
[src]
&self,
thresh: f64,
maxval: f64,
threshold_type: ThresholdType
) -> Mat
Threshold
pub fn erode(
&self,
kernel: &Mat,
anchor: Point2i,
iterations: i32,
border_type: BorderType,
border_value: Scalar
) -> Mat
[src]
&self,
kernel: &Mat,
anchor: Point2i,
iterations: i32,
border_type: BorderType,
border_value: Scalar
) -> Mat
Erode
pub fn dilate(
&self,
kernel: &Mat,
anchor: Point2i,
iterations: i32,
border_type: BorderType,
border_value: Scalar
) -> Mat
[src]
&self,
kernel: &Mat,
anchor: Point2i,
iterations: i32,
border_type: BorderType,
border_value: Scalar
) -> Mat
Dilate
pub fn gaussian_blur(
&self,
dsize: Size2i,
sigma_x: f64,
sigma_y: f64,
border_type: BorderType
) -> Mat
[src]
&self,
dsize: Size2i,
sigma_x: f64,
sigma_y: f64,
border_type: BorderType
) -> Mat
Gaussian Blur
pub fn resize_to(&self, dsize: Size2i, interpolation: InterpolationFlag) -> Mat
[src]
Resizes an image.
The function resize resizes the image down to or up to the specified size.
pub fn resize_by(
&self,
fx: f64,
fy: f64,
interpolation: InterpolationFlag
) -> Mat
[src]
&self,
fx: f64,
fy: f64,
interpolation: InterpolationFlag
) -> Mat
Resizes an image.
The function resize resizes the image down to or up to the specified size.
pub fn calc_hist<T: AsRef<[c_int]>, U: AsRef<[c_int]>, MElem: AsRef<[f32]>, M: AsRef<[MElem]>>(
&self,
channels: T,
mask: &Mat,
hist_size: U,
ranges: M
) -> Mat
[src]
&self,
channels: T,
mask: &Mat,
hist_size: U,
ranges: M
) -> Mat
Calculate a histogram of an image.
pub fn calc_back_project<T: AsRef<[c_int]>, MElem: AsRef<[f32]>, M: AsRef<[MElem]>>(
&self,
channels: T,
hist: &Mat,
ranges: M
) -> Mat
[src]
&self,
channels: T,
hist: &Mat,
ranges: M
) -> Mat
Calculate the back projection of a histogram. The function calculates the back project of the histogram.
pub fn compare_hist(
&self,
other: &Mat,
method: HistogramComparisionMethod
) -> Result<f64, String>
[src]
&self,
other: &Mat,
method: HistogramComparisionMethod
) -> Result<f64, String>
Compares two histograms. The function compare two histograms using the specified method. The function returns d(first_image, second_image). 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 cv::EMD function.
pub fn sobel(
&self,
ddepth: i32,
dx: i32,
dy: i32,
k_size: i32,
scale: f64,
delta: f64,
border_type: BorderType
) -> Mat
[src]
&self,
ddepth: i32,
dx: i32,
dy: i32,
k_size: i32,
scale: f64,
delta: f64,
border_type: BorderType
) -> Mat
Calculates the first x- or y- image derivative using Sobel operator.
pub fn scharr(
&self,
ddepth: i32,
dx: i32,
dy: i32,
scale: f64,
delta: f64,
border_type: BorderType
) -> Mat
[src]
&self,
ddepth: i32,
dx: i32,
dy: i32,
scale: f64,
delta: f64,
border_type: BorderType
) -> Mat
Calculates the first x- or y- image derivative using Scharr operator.
pub fn canny(
&self,
threshold1: f64,
threshold2: f64,
aperture_size: i32,
l2_gradient: bool
) -> Result<Mat, String>
[src]
&self,
threshold1: f64,
threshold2: f64,
aperture_size: i32,
l2_gradient: bool
) -> Result<Mat, String>
Performs canny edge detection
impl Mat
[src]
pub fn from_file_storage<P: AsRef<Path>>(
path: P,
section: &str
) -> Result<Mat, Error>
[src]
path: P,
section: &str
) -> Result<Mat, Error>
Loads Mat
from file storage
pub fn new() -> Mat
[src]
Creates an empty Mat
struct.
pub fn from_buffer(rows: c_int, cols: c_int, cv_type: CvType, buf: &[u8]) -> Mat
[src]
Creates a new Mat
from buffer. Note that internally opencv function
won’t take ownership of the Mat, but when we call drop
, it will
deallocate the memory. To prevent double-freeing, you must mem::forget
it after use.
The following example shows how to get the data from an image and create a new image with the data (also forgets it).
let buffer = image.data(); let size = image.size(); let s = (size.width * size.height * 3) as usize; let mut vec = Vec::with_capacity(s); unsafe { vec.set_len(s); copy(buffer, vec.as_mut_ptr(), s); } let new_image = Mat::from_buffer( size.height, size.width, CvType::Cv8UC3 as i32, &vec); // . . . use new_image here, such as new_image.show(..) . . . ::std::mem::forget(new_image);
pub fn with_size(rows: c_int, cols: c_int, t: c_int) -> Self
[src]
Create an empty Mat
with specific size (rows, cols and types).
pub fn zeros(rows: c_int, cols: c_int, t: c_int) -> Self
[src]
Create an empty Mat
with specific size (rows, cols and types).
pub fn data(&self) -> &[u8]
[src]
Returns the raw data (as a u8
pointer)
pub fn total(&self) -> usize
[src]
Returns the total number of array elements. The method returns the number of array elements (a number of pixels if the array represents an image). For example, images with 1920x1080 resolution will return 2073600.
pub fn elem_size(&self) -> usize
[src]
Returns the matrix element size in bytes.
The method returns the matrix element size in bytes. For example, if the matrix type is CV_16SC3 , the method returns 3*sizeof(short) or 6.
pub fn elem_size1(&self) -> usize
[src]
Returns the size of each matrix element channel in bytes.
The method returns the matrix element channel size in bytes, that is, it ignores the number of channels. For example, if the matrix type is CV_16SC3 , the method returns sizeof(short) or 2.
pub fn step1(&self, i: c_int) -> usize
[src]
Returns a normalized step.
The method returns a matrix step divided by Mat::elemSize1() . It can be useful to quickly access an arbitrary matrix element
pub fn size(&self) -> Size2i
[src]
Returns the size of this matrix.
pub fn is_valid(&self) -> bool
[src]
Check if the Mat
is valid or not.
pub fn roi(&self, rect: Rect) -> Mat
[src]
Return a region of interest from a Mat
specfied by a Rect
.
pub fn flip(&mut self, code: FlipCode)
[src]
Flips an image around vertical, horizontal, or both axes.
pub fn cv_type(&self) -> CvType
[src]
Returns the images type. For supported types, please see CvType.
pub fn eye(rows: i32, cols: i32, cv_type: CvType) -> Mat
[src]
Returns an identity matrix of the specified size and type.
pub fn at<T: FromBytes>(&self, i0: i32) -> T
[src]
Returns individual pixel (element) information within the Mat. This
function may need type annotation to assist FromBytes
trait.
- If matrix is of type
CV_8U
then useMat.at<u8>(y,x)
. - If matrix is of type
CV_8S
then useMat.at<i8>(y,x)
. - If matrix is of type
CV_16U
then useMat.at<u16>(y,x)
. - If matrix is of type
CV_16S
then useMat.at<i16>(y,x)
. - If matrix is of type
CV_32S
then useMat.at<i32>(y,x)
. - If matrix is of type
CV_32F
then useMat.at<f32>(y,x)
. - If matrix is of type
CV_64F
then useMat.at<f64>(y,x)
.
pub fn at2<T: FromBytes>(&self, i0: i32, i1: i32) -> T
[src]
Returns individual pixel (element) information within the Mat. This
function may need type annotation to assist FromBytes
trait.
pub fn at3<T: FromBytes>(&self, i0: i32, i1: i32, i2: i32) -> T
[src]
Returns individual pixel (element) information within the Mat. This
function may need type annotation to assist FromBytes
trait.
pub fn in_range(&self, lowerb: Scalar, upperb: Scalar) -> Mat
[src]
Checks if Mat elements lie between the elements of two other arrays
(lowerb and upperb). The output Mat has the same size as self
and
CV_8U type.
pub fn min_max_loc(&self, mask: &Mat) -> (f64, f64, Point2i, Point2i)
[src]
Finds the global minimum and maximum in an array.
This function finds the minimum and maximum element values and their positions. The extremums are searched across the whole array or, if mask is not an empty array, in the specified array region.
N.B. Only work with single-channel Mat. For multi-channel arrays. If you need to find minimum or maximum elements across all the channels, use Mat::reshape first to reinterpret the array as single-channel. Or you may extract the particular channel using either extractImageCOI , or mixChannels, or split.
pub fn mix_channels<T: AsRef<[(c_int, c_int)]>>(
&self,
nsrcs: usize,
ndsts: usize,
from_to: T
) -> Mat
[src]
&self,
nsrcs: usize,
ndsts: usize,
from_to: T
) -> Mat
Copy specified channels from self
to the specified channels of output
Mat
.
pub fn normalize(&self, alpha: f64, beta: f64, t: NormType) -> Mat
[src]
Normalize the Mat according to the normalization type.
pub fn count_non_zero(&self) -> c_int
[src]
Counts non-zero array elements.
pub fn copy_make_border(
&self,
top: i32,
bottom: i32,
left: i32,
right: i32,
type_: BorderType,
color: Scalar
) -> Mat
[src]
&self,
top: i32,
bottom: i32,
left: i32,
right: i32,
type_: BorderType,
color: Scalar
) -> Mat
Forms a border around an image.
The function copies the source image into the middle of the destination image. The areas to the left, to the right, above and below the copied source image will be filled with extrapolated pixels. This is not what filtering functions based on it do (they extrapolate pixels on-fly), but what other more complex functions, including your own, may do to simplify image boundary handling.
impl Mat
[src]
pub fn camshift(&self, wndw: Rect, criteria: &TermCriteria) -> RotatedRect
[src]
Finds an object center, size, and orientation; returns as RotatedRect
.
wndw
- initial search window.criteria
- stop criteria for the underlying meanShift.
Trait Implementations
impl<'a> BitAnd<&'a Mat> for &'a Mat
[src]
type Output = Mat
The resulting type after applying the &
operator.
fn bitand(self, rhs: &'a Mat) -> Self::Output
[src]
impl BitAnd<Mat> for Mat
[src]
type Output = Self
The resulting type after applying the &
operator.
fn bitand(self, rhs: Self) -> Self::Output
[src]
impl<'a> BitOr<&'a Mat> for &'a Mat
[src]
type Output = Mat
The resulting type after applying the |
operator.
fn bitor(self, rhs: &'a Mat) -> Self::Output
[src]
impl BitOr<Mat> for Mat
[src]
type Output = Self
The resulting type after applying the |
operator.
fn bitor(self, rhs: Self) -> Self::Output
[src]
impl<'a> BitXor<&'a Mat> for &'a Mat
[src]
type Output = Mat
The resulting type after applying the ^
operator.
fn bitxor(self, rhs: &'a Mat) -> Self::Output
[src]
impl BitXor<Mat> for Mat
[src]
type Output = Self
The resulting type after applying the ^
operator.
fn bitxor(self, rhs: Self) -> Self::Output
[src]
impl Clone for Mat
[src]
fn clone(&self) -> Self
[src]
pub fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl Debug for Mat
[src]
impl Drop for Mat
[src]
impl From<GpuMat> for Mat
[src]
impl From<Mat> for GpuMat
[src]
impl Into<CMat> for Mat
[src]
impl Not for Mat
[src]
type Output = Self
The resulting type after applying the !
operator.
fn not(self) -> Self::Output
[src]
impl<'a> Not for &'a Mat
[src]
type Output = Mat
The resulting type after applying the !
operator.
fn not(self) -> Self::Output
[src]
impl Send for Mat
[src]
impl Show for Mat
[src]
Auto Trait Implementations
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,