Describe the bug
When trying to generate binding for opencv build fails on cv::OutputArray. This happens when I tried to generate bindings for generate!("cv::VideoCapture"). Tried to add header file where cv::OutputArray is defined #include "opencv2/core/mat.hpp" still fails.
To Reproduce
Cargo.toml
[package]
name = "cpp_test"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
build = "build.rs"
links = "opencv4"
[dependencies]
cxx = "1.0.116"
autocxx = "0.26.0"
[build-dependencies]
pkg-config = "0.3.29"
autocxx-build = "0.26.0"
miette = { version = "5", features = ["fancy"] } # optional but gives nicer error messages!
build.rs
use std::path::PathBuf;
fn main() -> miette::Result<()> {
let mut include_paths: Vec<PathBuf> = vec![std::path::PathBuf::from("src")];
let mut opencv: pkg_config::Library = pkg_config::Config::new().probe("opencv4").unwrap();
include_paths.append(&mut opencv.include_paths);
let mut builder = autocxx_build::Builder::new("src/main.rs", include_paths).build()?;
builder
.flag_if_supported("-std=c++14")
.compile("opencv");
println!("cargo:rustc-link-lib=opencv_highgui");
println!("cargo:rustc-link-lib=opencv_videoio");
Ok(())
}
src/main.rs
use std::pin::Pin;
use autocxx::prelude::*;
use cxx::let_cxx_string;
autocxx::include_cpp! {
#include "opencv2/highgui.hpp"
#include "opencv2/videoio.hpp"
#include "opencv2/core/mat.hpp"
generate!("cv::namedWindow")
generate!("cv::VideoCapture")
// generate!("cv::OutputArray")
// block!("cv::OutputArray")
safety!(unsafe)
}
fn main() {
let_cxx_string!(winname = "hello");
ffi::cv::namedWindow(&winname, c_int(1));
let mut video_capture_pointer: cxx::UniquePtr<ffi::cv::VideoCapture> = ffi::cv::VideoCapture::new().within_unique_ptr();
let mut video_capture_pin: Pin<&mut ffi::cv::VideoCapture> = video_capture_pointer.pin_mut();
video_capture_pin.open2(c_int(0), c_int(0));
}
Expected behavior
Successful build and also working cv::VideoCapture.read() method which depends on this type
Describe the bug When trying to generate binding for opencv build fails on
cv::OutputArray
. This happens when I tried to generate bindings forgenerate!("cv::VideoCapture")
. Tried to add header file wherecv::OutputArray
is defined#include "opencv2/core/mat.hpp
" still fails.To Reproduce
Cargo.toml
build.rs
src/main.rs
Expected behavior Successful build and also working cv::VideoCapture.read() method which depends on this type
Additional context Error:
Where main information I believe is: