CVCore.jl
CVCore
— Module.Core functionality
Basic usage
The primary export of the package is Mat{T,N}
, which is the Julia type for cv::Mat
. Mat{T,N}
is designed to be a subtype of AbstractArray{T,N}
. It has element type (T
) and dimension (N
) as type parameters, whereas cv::Mat
doesn't. Note that matrix construction interface is different between Julia and C++. cv::Mat(3,3,CV_8U)
in C++ can be translated in Julia as Mat{UInt8}(3,3)
.
Create uninitialized matrix:
using CVCore
julia> A = Mat{Float64}(3,3)
3×3 CVCore.Mat{Float64,2}:
3.39519e-313 4.94066e-324 2.122e-314
NaN 1.72723e-77 -2.32036e77
1.97626e-323 0.0 0.0
Create matrix filled with Scalar (cv::Scalar
)
julia> A = Mat{Float64}(3,3,Scalar(1))
3×3 CVCore.Mat{Float64,2}:
1.0 1.0 1.0
1.0 1.0 1.0
1.0 1.0 1.0
Matirx operations
julia> A * A
CVCore.MatExpr{Float64,2}
3×3 CVCore.Mat{Float64,2}:
3.0 3.0 3.0
3.0 3.0 3.0
3.0 3.0 3.0
julia> A + A
CVCore.MatExpr{Float64,2}
3×3 CVCore.Mat{Float64,2}:
2.0 2.0 2.0
2.0 2.0 2.0
2.0 2.0 2.0
julia> A - A
CVCore.MatExpr{Float64,2}
3×3 CVCore.Mat{Float64,2}:
0.0 0.0 0.0
0.0 0.0 0.0
0.0 0.0 0.0
Create multi-channel matrix
julia> A = Mat{Float64}(3,3,3,Scalar(1,2,3))
3×3×3 CVCore.Mat{Float64,3}:
[:, :, 1] =
1.0 1.0 1.0
1.0 1.0 1.0
1.0 1.0 1.0
[:, :, 2] =
2.0 2.0 2.0
2.0 2.0 2.0
2.0 2.0 2.0
[:, :, 3] =
3.0 3.0 3.0
3.0 3.0 3.0
3.0 3.0 3.0
Conversion between Mat{T,N}
and Array{T,N}
julia> B = Array(A)
3×3 Array{Float64,2}:
1.0 1.0 1.0
1.0 1.0 1.0
1.0 1.0 1.0
julia> C = Mat(B)
3×3 CVCore.Mat{Float64,2}:
1.0 1.0 1.0
1.0 1.0 1.0
1.0 1.0 1.0
Note that Mat(B)
where B
is an array shares the underlying data.
Index
Reference
CVCore.AbstractCvMat
— Type.AbstractCvMat{T,N} represents N
-dimentional arrays in OpenCV (cv::Mat, cv::UMat, etc), which element type are bound to T
.
CVCore.Mat
— Type.Mat{T,N} represents cv::Mat with encoded type information
Mat{T,N} keeps cv::Mat instance with: element type T
and dimention N
. Hence, in fact it behaves like cv::Mat_<T>. Note that Mat stores its internal data in column-major order, while Julia's arrays are in row-major.
NOTE: Mat{T,N} supports multi-channel 2-dimentional matrices and single-channel 2-dimentional matrices for now. Should be extended for N-dimentional cases.
CVCore.MatExpr
— Type.MatExpr{T,N} represents cv::MatExpr with encoded type information
T
and N
represents the element type and the dimension of Mat, respectively.
TODO: should consder wherther I make this a subtype of AbstractCvMat{T,N}
CVCore.UMat
— Type.UMat{T,N} represents cv::UMat with encoded type information
T
and N
represents the element type and the dimension of Mat, respectively.
CVCore.cvdepth
— Method.Determine cv::Mat depth from Julia type
CVCore.handle
— Function.Returns a refrence of the interal structure
CVCore.jltype
— Method.Determine julia type from the depth of cv::Mat
Core.Type
— Type.Single-channel 2-dimentaionl mat constructor with user provided data
Core.Type
— Type.Multi-channel 2-dimentaionl mat constructor with user provided data
Core.Type
— Method.Generic constructor
Core.Type
— Method.Multi-chanel 2-dimentional mat constructor
Core.Type
— Method.Single-channel 2-dimentional mat constructor
Core.Type
— Method.Generic constructor
Core.Type
— Method.Empty mat constructor