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

Can't create WarperCreator and use StitcherTrait::set_warper #557

Closed
markhilb opened this issue Apr 5, 2024 · 5 comments
Closed

Can't create WarperCreator and use StitcherTrait::set_warper #557

markhilb opened this issue Apr 5, 2024 · 5 comments

Comments

@markhilb
Copy link

markhilb commented Apr 5, 2024

I am trying to stitch a panorama using the Sitcher struct with the warper: TransverseMercatorWarper.
However, the StitcherTrait::set_warper method takes in a Ptr<WarperCreator> which I can't seem to create,
since neither TransverseMercatorWarper nor WarperCreator has a new/create method.

Here is some example code showing the problem:

use opencv::{
    core::{Mat, Vector},
    imgcodecs::{imread_def, imwrite_def},
    stitching::{Stitcher, StitcherTrait, Stitcher_Mode},
    xfeatures2d::SURF,
};

pub fn stitch(files: Vec<String>) -> anyhow::Result<()> {
    let mut images = Vector::<Mat>::with_capacity(files.len());
    for f in files {
        images.push(imread_def(&f)?);
    }

    let mut stitcher = Stitcher::create(Stitcher_Mode::PANORAMA)?;

    let surf = SURF::create_def()?;
    stitcher.set_features_finder(surf.into())?;

    // What goes here?
    let warper = todo!();
    stitcher.set_warper(warper)?;

    let mut output = Mat::default();

    stitcher.stitch(&images, &mut output)?;
    imwrite_def("result.png", &output)?;
    Ok(())
}

In c++ the missing part would be written like this:

  auto warper = makePtr<cv::TransverseMercatorWarper>();
  stitcher->setWarper(warper);

Any idea how to create the warper in rust?

@twistedfall
Copy link
Owner

Looks like currently it's not possible to create an instance of the necessary warper. I'm going to look into this, thanks for the report!

@twistedfall
Copy link
Owner

Can you please check the rel branch to see it the following now works as expected:

    // What goes here?
    let warper = Ptr::new(TransverseMercatorWarper::default());
    stitcher.set_warper(warper.into())?;

@markhilb
Copy link
Author

Yes, that works great!

@twistedfall
Copy link
Owner

Perfect, I will release the version with the fix shortly

@twistedfall
Copy link
Owner

This has been released as part of 0.90 version

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

2 participants