GithubHelp home page GithubHelp logo

hawkingrei / opencv-rust Goto Github PK

View Code? Open in Web Editor NEW

This project forked from twistedfall/opencv-rust

0.0 2.0 0.0 163 KB

My shot at generating rust bindings for opencv

License: MIT License

Rust 99.59% C 0.41%

opencv-rust's Introduction

Rust OpenCV bindings

Build Status

This is my shot at generating Rust bindings for OpenCV.

This is absolutely not ready for prime time.

Instead of binding the deprecated C-compatible interface, I chose to mimick the python and java wrappers: parsing C++ headers, generating a C interface to the C++ api, and wrapping that in Rust.

Try it

There are quite a few moving parts here. I'm working on MacOS, and Travis runs on Ubuntu 12.0.4, so these two are known to work. I expect any relatively recent Linux to work fine, and I can't see anything serious preventing this to work under Windows if you are willing to spend a few hours on it.

You will need OpenCV 2.4.11. Other 2.4 versions may work, feel free to try and tell me what happens. 3.0 will not work as is.

You will also need python.

API Documentation — or what I managed to extract from opencv widely inconsistent doxygen. At least you can see what has been ported or not to rust and how. You'll probably need to refer to the official OpenCV C++ documentation.

All the major modules in the C++ API are merged together in a huge cv:: namespace, leaving the client developper to manage its namespace by selectively including relevant headers. I instead made one rust module for each major OpenCV module. So C++ cv::Mat is ::opencv::core::Mat in Rust, etc.

The methods and field names have been snake_cased. Methods arguments with default value loose these default values, but they are reported in the API documentation.

Overloaded methods have been — manually — given a different name.

All methods return a Result, because... yeah, exceptions.

API coverage

I don't know or use the whole OpenCV library. I have deliberately let some modules out of these bindings in order to focus on parts I understand and/or have a need for. Due to the widely inconsistent use of C++ features and syntax in the library headers, adding them may be a matter of minutes or days, but we'll get there. PR are welcome.

Even in the covered modules, some classes or methods have been left out because they were referring to some C++ feature that the script did not understand. If we need them, we'll get them. Eventually. Please report them.

And at some point, obviously, I want this to move to OpenCV 3.0.

Hack it

Please don't tell me how ugly these scripts look. Believe me, I am already painfully aware of this.

hdr_parser.py comes from opencv python/java generator. I have tried not to mess too much with this file, but had to make a few changes.

gen_rust is initially a copy of gen_java, also from the OpenCV generators, but is now so far from the initial stuff that I consider it an original work.

The license for the original work is MIT.

Special thanks to ttacon for yielding the crate name.

opencv-rust's People

Contributors

kali avatar bentheelder avatar erezny avatar oli-obk avatar phdoerfler avatar sebasgarcep avatar

Watchers

Weizhen Wang avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.