rust-cv / cv

Rust CV mono-repo. Contains pure-Rust dependencies which attempt to encapsulate the capability of OpenCV, OpenMVG, and vSLAM frameworks in a cohesive set of APIs.
831 stars 64 forks source link

Fix akaze orientation (from upstream branch) #65

Closed vadixidav closed 1 year ago

vadixidav commented 1 year ago

This is the same branch as #64 but added to the upstream repository as the original branch was not modifiable by maintainers.

vadixidav commented 1 year ago

@stephanemagnenat I have incorporated your changes along with my own. Could you please compare the Rust CV akaze against the OpenCV implementation again to see if the behavior is now the same.

stephanemagnenat commented 1 year ago

On my unpublished branch, I had the following code for half_size:

Self(ImageBuffer::from_fn(width, height, |x, y| {
    let x = x * 2;
    let y = y * 2;
    let mut sum = self.0.get_pixel(x, y).0[0];
    let mut count = 1.0;
    let horiz_ok = x + 1 < self.0.width();
    let vert_ok = y + 1 < self.0.height();
    if horiz_ok {
        sum += self.0.get_pixel(x + 1, y).0[0];
        count += 1.0;
    }
    if vert_ok {
        sum += self.0.get_pixel(x, y + 1).0[0];
        count += 1.0;
    }
    if vert_ok && horiz_ok {
        sum += self.0.get_pixel(x + 1, y + 1).0[0];
        count += 1.0;
    }
    Luma([sum / count])
}))

It would be interesting to see which one is faster, compared to the one in this PR, that uses iterators and save tests in the inner loop, but touches the right pixels out of order.

stephanemagnenat commented 1 year ago

Further corrections in #66, with the debug dumps.

stephanemagnenat commented 1 year ago

Ok, now the push works, thanks!