twistedfall / opencv-rust

Rust bindings for OpenCV 3 & 4

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Invisible bounding box in highgui::select_roi()

CodingCornerPDI opened this issue · comments

Windows 10 with the dlls opencv_world490.dll and opencv_videoio_ffmpeg490_64.dll next to the executable (copied from chocolatey installation of OpenCV) and rust 1.77.1.

let roi = highgui::select_roi(&window_name, &frame, true, false, false)?; spawns with a visible cursor as expected, but dragging the cursor doesn't display the bounding box itself.
roi will still be correct, so it's only a visual issue.

The same build on Arch Linux with OpenCV from the repos and no additional changes works perfectly.

Build log for the whole project is attached, it's probably me setting something up wrong but I'm stumped.

Thank you for any help.

build.log

Can you please attach the sample code that's exhibiting the issue?

On further investigation it seems to only be an issue when running from the UI framework Slint.

Here is a basic program that exhibits this:

use opencv::prelude::*;
use opencv::highgui;
use opencv::videoio::VideoCapture;

slint::include_modules!();


fn get_roi() -> opencv::Result<()> {
    let window_name = "Pain";

    let mut player = VideoCapture::from_file_def("/home/dirleyj/Videos/short.mp4")?;
    let mut frame = Mat::default();
    player.read(&mut frame)?;

    highgui::named_window(&window_name, highgui::WindowFlags::WINDOW_NORMAL.into())?;
    highgui::select_roi(&window_name, &frame, true, false, false)?;
    highgui::destroy_window(&window_name)?;

    Ok(())
}


fn main() -> opencv::Result<()> {
    let ui = AppWindow::new().unwrap();

    // Call get_roi() when the UI's roi_button() callback is triggered
    ui.global::<PlayerLogic>().on_roi_button(
        move || get_roi().unwrap()
    );

    ui.run().unwrap();
    Ok(())
}

ui.global::<PlayerLogic>().on_roi_button() gets triggered by the UI and is defined in a Slint file as a callback that takes no parameters.
get_roi() works as expected if it's called directly from main instead.
From just that code, I don't see why this bug of all things would occur. If there's nothing there that could go wrong, I'll open this bug with Slint instead.

Thank you again for the help.