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

issue with call create_trackbar fun #522

Closed
adminSxs opened this issue Dec 7, 2023 · 2 comments
Closed

issue with call create_trackbar fun #522

adminSxs opened this issue Dec 7, 2023 · 2 comments

Comments

@adminSxs
Copy link

adminSxs commented Dec 7, 2023

code

use opencv::core::mul_f64_mat;
use opencv::highgui::{create_trackbar, imshow, named_window, wait_key, WINDOW_AUTOSIZE};
use opencv::imgcodecs::{imread, IMREAD_COLOR};
fn main()->opencv::Result<()>{
    let img=imread("avatar.png",IMREAD_COLOR)?;
    named_window("window",WINDOW_AUTOSIZE)?;
    create_trackbar("track","window",None,100,Some(Box::new(onchange)))?;

    imshow("window",&img)?;
    wait_key(0)?;
    Ok(())
}
fn onchange(value : i32){
    let a= value as f64/100.;
    println!("val={a}");
    // mul_f64_mat(a,&img);
}

I want to in onchange method use img variable, how should to do

@adminSxs adminSxs changed the title issue with call create_trackbar fu issue with call create_trackbar fun Dec 7, 2023
@twistedfall
Copy link
Owner

The bindings don't expose the userdata argument as it's used for internal purposes. To capture the variables in your callback you should use Rust closures. You can check an example of this in the hough_lines example.

@adminSxs
Copy link
Author

The bindings don't expose the userdata argument as it's used for internal purposes. To capture the variables in your callback you should use Rust closures. You can check an example of this in the hough_lines example.

thanks

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