Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question: How to initialise Mat #53

Closed
augustocdias opened this issue Aug 29, 2019 · 4 comments
Closed

Question: How to initialise Mat #53

augustocdias opened this issue Aug 29, 2019 · 4 comments

Comments

@augustocdias
Copy link

How do initialise the Mat with ones or zeros like in C++ API?

Mat::zeros(3, 3, CV_32F);
@twistedfall
Copy link
Owner

It turned out that MatExpr generation was largely broken, it's fixed now in 0.19.3. You can now use zeros method:

let zero_mat = Mat::zeros(3, 3, f32::typ())?.to_mat()?;

@phunehehe
Copy link

I wonder if there's a way to make to_mat easier to discover. Now knowing it, I can see that MatExpr implements MatExprTrait which has to_mat. But when I was looking for it a bit earlier I couldn't find it. In any case, thanks for pointing out. This works!

@Tramac
Copy link

Tramac commented Jan 11, 2023

It turned out that MatExpr generation was largely broken, it's fixed now in 0.19.3. You can now use zeros method:

let zero_mat = Mat::zeros(3, 3, f32::typ())?.to_mat()?;

let measurement_noise_cov = Mat::ones(2, 2, CV_32F)?.to_mat()?;

image

@twistedfall
Copy link
Owner

Please make sure to import prelude:

use opencv::prelude::*;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants