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

VectorOfDMatch mangles on push #109

Closed
roehroeh opened this issue Apr 2, 2020 · 2 comments
Closed

VectorOfDMatch mangles on push #109

roehroeh opened this issue Apr 2, 2020 · 2 comments

Comments

@roehroeh
Copy link

roehroeh commented Apr 2, 2020

Version info

OS: Ubuntu 19.10
Installed opencv via apt-get from default ubuntu repo
OpenCV version: 3.2.0

Problem

The following code snipped produces errors in my code by changing train_idx and query_idx on DMatch structs when pushing them to a VectorOfDMatch:

Code

extern crate opencv;
use opencv::core::DMatch;
use opencv::prelude::*;
use opencv::types::VectorOfDMatch;

fn main() {
    let mut matches = VectorOfDMatch::new();
    let m = DMatch::new(0, 1, 12.4).expect("ups");
    println!("{:?}", m);
    matches.push(m);
    println!("{:?}", matches.get(0));
}

Example

$ cargo run
    Finished dev [unoptimized + debuginfo] target(s) in 0.02s
     Running `target/debug/vectordmatchtest`
DMatch { query_idx: 0, train_idx: 1, img_idx: -1, distance: 12.4 }
Ok(DMatch { query_idx: -106533440, train_idx: 32765, img_idx: -1, distance: 12.4 })

Is this an error on my behalf or a valid bug in either opencv or this project?
If this is related, would collecting an iterator of DMatch struct into VectorOfDMatch be possible?

List of used packages, in case it's helpful

$ RUST_BACKTRACE=full cargo build -vv 
       Fresh autocfg v1.0.0
       Fresh lazy_static v1.4.0
       Fresh cfg-if v0.1.10
       Fresh scopeguard v1.1.0
       Fresh semver-parser v0.7.0
       Fresh either v1.5.3
       Fresh pkg-config v0.3.17
       Fresh glob v0.3.0
       Fresh once_cell v1.3.1
       Fresh slab v0.4.2
       Fresh semver v0.9.0
       Fresh crossbeam-utils v0.7.2
       Fresh libc v0.2.68
       Fresh memoffset v0.5.4
       Fresh maybe-uninit v2.0.0
       Fresh num-traits v0.2.11
       Fresh crossbeam-epoch v0.8.2
       Fresh crossbeam-queue v0.2.1
       Fresh num_cpus v1.12.0
       Fresh jobserver v0.1.21
       Fresh num-integer v0.1.42
       Fresh crossbeam-deque v0.7.3
       Fresh cc v1.0.50
       Fresh num-complex v0.2.4
       Fresh rayon-core v1.7.0
       Fresh num-bigint v0.2.6
       Fresh num-iter v0.1.40
       Fresh rayon v1.3.0
       Fresh num-rational v0.2.4
       Fresh num v0.2.1
       Fresh opencv v0.33.0
       Fresh vectordmatchtest v0.1.0 (/tmp/vectordmatchtest)
    Finished dev [unoptimized + debuginfo] target(s) in 0.02s
@twistedfall
Copy link
Owner

Looks like a bug in the crate, I'm going to check it out, thanks for the bugreport!

@twistedfall
Copy link
Owner

Fixed in 0.33.1

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