Comments (10)
I'll have a look to see if/how I can make it possible. I am also trying to get 3.1 to work.
from opencv-rust.
I looked into this a bit. It seems like the existing ptr(...)
methods would do the trick here. They're currently ignored during generation because they return pointer types, specifically uchar*
, but this is also a primitive type (based on the primitives
dict in gen_rust.py
). This is because the parse_type
function checks for raw pointers before it checks for primitive types. Changing the ordering there such that it looks for primitives first allows it to generate the ptr(...)
functions.
This leads to a second problem. There are two versions of every ptr(...)
overload, one that's const
(and returns a const uchar*
) and one that's normal. However, the generator doesn't take const
ness into account when generating the C++ methods (or at least it doesn't seem to; I haven't read through enough to fully understand the const
support). In any case, it generates two C++ methods with the exact same signature, which then fails to compile (complaining about redefining a symbol).
There's a few solutions I've thought of (and probably many I that haven't :P):
- Take
const
ness into account when generating the C++ methods (specifically in the method signatures). - Determine the set of things that go into a method and then coalesce methods so that we only generate each unique method once.
- Extend the functionality for ignoring methods to be able to take the attributes of the method into account (eg
const
ness). - Some entirely different approach for accessing the pixel data :)
What do you think a reasonable approach would be?
from opencv-rust.
Well, these methods are specifically enough that we may not want to generate them but just write them:
The generator is already very messy. This is because a huge lot of "c++ features" are used across opencv with or without consistency. This situation is actually a bit better in 3.x . Also, as soon as the pkg-config mess will improve in opencv size, we should be able to switch to the cv3 branch, where the generator has already been extensively modified.
Bottom line: it's not worth digging a trench in the generator just to support features used by one or two methods.
But instead, we can add these methods manually. I used this at the beginning, but it should still work: just add a Trait for these methods and impl it in the rust code in src, and put the matching C wrappers in native/something.cpp. The builder will compile and link code in native/*.cpp in the library along with the generated code.
Tell me what you think.
from opencv-rust.
I guess hand writing them is the best option. I'd like to help with that but unfortunately it exceeds my current rust knowledge by far (I still don't quite get how rust can even access C++. Even the rust manual says that only C is supported by the FFI). However if someone was willing to remote pair (e.g. via floobits) I'd love to give it a shot.
from opencv-rust.
Yeah. Rust does not call c++. The generator creates a C interface on top of the c++ class for rust FFI to talk to. The generated c interface is then built into a library by build.rs.
from opencv-rust.
Any news on this?
from opencv-rust.
I took a stab at one of the approaches for fixing this in #19. The solution worked for me, was a bit more general than handwriting, and didn't actually end up complicating the generator too much (at least, in my opinion). Even if it doesn't get merged in, you could probably patch it in locally @phdoerfler.
from opencv-rust.
Merged, built, and just released as 0.2.3 . Thanks again for the PR.
from opencv-rust.
Awesome! Thanks for doing this @FuegoFro
from opencv-rust.
Woo! No problem :)
from opencv-rust.
Related Issues (20)
- Build Failed on M3 Pro HOT 1
- [Question] Access Mat from BoxedRef<Mat> without cloning HOT 1
- LNK1181 with vcpkg-acquired "full" OpenCV on Windows HOT 3
- solve_pnp_generic assertion error
- Tutorial for static builds on windows? HOT 6
- raspberry pi 4 GPU usage with opencv
- Need help: How to build a CV::Mat from Vec<u8> of BGR24? HOT 4
- Compiled tracking module is not detected HOT 2
- Building 0.92.0 on Linux Mint => Memory not found HOT 1
- Ndarray to Mat conversion. HOT 5
- Why is it so terribly hard to build this? HOT 2
- I used orb to match image, but the result is too weird. HOT 3
- add method of resolve VSCode rust-analyzer dyld not load problem to troubleshoot
- Performance concern compared with C++ HOT 4
- Can't use opencv in Windows: C:\Users\Admin\.cargo\registry\src\index.crates.io-6f17d22bba15001f\opencv-0.92.0\src_cpp\ocvrs_common.hpp:16:10: fatal error: 'memory' file not found HOT 4
- How to invert black and white in image? Can't make bitwise_not operation work HOT 2
- How to statically linking OpenCV with CUDA and use dynamic linking for CUDA
- multiple definition of `ocvrs_create_string` HOT 9
- cannot find -lclang.dll: No such file or directory and error: linking with `x86_64-w64-mingw32-gcc` failed: exit code: 1
- inconsistency between two versions of linux (Debian and Archlinux) opencv with Aravis support HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from opencv-rust.