I have been working on a python extension, using
pyo3 = "0.21.1"
numpy = "0.21.0"
opencv = { version = "0.92.0" , features = ["clang-runtime"]}
The main issue I'm facing now is that Python OpenCV code is now reading images as numpy arrays, so that's what I have to pass to Rust. But those numpy arrays have too many channels, so when I actually need to call any Rust OpenCV methods - I need to convert this back to Mat, but the reshape fails due to CV_CN_MAX, which is 512.
It seems there is some way of tackling this within the C++ OpenCV Python extensions. It'd be really nice to introduce a way of doing that for Rust too.
Here's the code in question:
// channels variable is > 512
let reshaped_mat = mat.reshape_nd(*channels, shape);
Here's some context: opencv/opencv#20070
It looks like the PythonWrapper knows how to convert these things back and forth, reshaping to fit the bill.
I have been working on a python extension, using
The main issue I'm facing now is that Python OpenCV code is now reading images as numpy arrays, so that's what I have to pass to Rust. But those numpy arrays have too many channels, so when I actually need to call any Rust OpenCV methods - I need to convert this back to Mat, but the reshape fails due to
CV_CN_MAX, which is512.It seems there is some way of tackling this within the C++ OpenCV Python extensions. It'd be really nice to introduce a way of doing that for Rust too.
Here's the code in question:
Here's some context: opencv/opencv#20070
It looks like the PythonWrapper knows how to convert these things back and forth, reshaping to fit the bill.