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

getting a Projection by from_control_points makes program freezing #412

Closed
kingrongH opened this issue Mar 22, 2020 · 4 comments · Fixed by #417
Closed

getting a Projection by from_control_points makes program freezing #412

kingrongH opened this issue Mar 22, 2020 · 4 comments · Fixed by #417

Comments

@kingrongH
Copy link

This occurs every time you run the program. Here is the minimal code.

fn main() -> Result<(), Box<dyn Error>>{
    println!("get a projection from control points...");
    let from = [(0.0, 0.0), (250.0, 17.481735), (7.257017, 82.94814), (250.0, 104.18543)]; 
    let to = [(0.0, 0.0), (249.0, 0.0), (0.0, 105.0), (249.0, 105.0)];
    let projection = Projection::from_control_points(from, to);
    match projection {
        Some(_p) => println!("new projection"),
        None => println!("failed")
    }
    Ok(())
}

Here is all the output I get, nothing else:
image
I think Projection::from_control_points should either return Some(_) or None, rather than just keeps freezing.
Thanks all the work you have done! This may be a bug, please someone check it.

@theotherphil
Copy link
Contributor

I see "failed" printed when running in both debug and release modes using the following toolchain:

stable-x86_64-apple-darwin (default)
rustc 1.40.0 (73528e339 2019-12-16)

Which compiler version and architecture are you using?

@kingrongH
Copy link
Author

kingrongH commented Mar 22, 2020

sorry I forgot to mention that, my toolchain:

stable-x86_64-unknown-linux-gnu (default)
rustc 1.41.0 (5e1a79984 2020-01-27)

@kingrongH
Copy link
Author

I just run this demo using 1.40.0, still get freezing.
I'm using Pop!_OS 19.10

@Palladinium
Copy link
Contributor

Palladinium commented May 29, 2020

I can confirm 100% CPU usage and freezing from the example on imageproc 0.20.0.

Running Arch Linux x84_64, and tested on both debug and release with all of:

  • rustc 1.45.0-nightly (a74d1862d 2020-05-14)
  • rustc 1.44.0-beta.4 (02c25b359 2020-05-23)
  • rustc 1.43.1 (8d69840ab 2020-05-04)

Doing some basic profiling (flamegraph) points to somewhere inside the svd() call, so maybe the issue lies within rulinalg.
This issue looks like a likely cause.

Linear algebra is a bit out of my depth, but given that from_control_points is the only use of rulinalg in imageproc it might be worth looking at switching to a different implementation of SVD.

From some very cursory research it looks like nalgebra is a viable substitute, although it might not be sufficient due to this issue.
nalgebra_lapack avoids the issue but requires a non-Rust dependency, which may be undesirable.

Perhaps a feature gate for the SVD implementation would help with getting the best of both worlds.

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

Successfully merging a pull request may close this issue.

3 participants