Ask Your Question
0

Is C API alive or not

asked 2018-02-28 09:12:07 -0500

Pzixel gravatar image

updated 2018-02-28 09:12:41 -0500

I want to write a wrapper for OpenCV using different language. For obsious reasons I can only use C API. And I have two alternatives: write my own wrappers over C++ code and expose it OR I can take existing C API, but the drawback of this approach is my fear that C bindings may be abandoned.

I'm starting a new shiny project, but I don't want to write extra C code when I can reuse existing one. Or I can't? Because as I see multiple functions are missing, even very basic ones, like mat::zeroes or mat::eye.

edit retag flag offensive close merge delete

Comments

if i may ask: what is the nature of your "new shiny project" ? some kind of ffi bindings ? (to what ?)

berak gravatar imageberak ( 2018-02-28 12:12:28 -0500 )edit
1

I'm trying to port OpenCV interfaces to Rust that it may be used from safe language (e.g. see calcHist, looks pretty good imho). But for Now i have to write wrappers manually, e.g. mat.cc which is pretty annoying. So I looked forward code generators, but unfortunately they work fine with pure C code only, because they cannot support advanced C++ features and automatically generate code that works fine in all circumstances. This is why I wondered if C API can be an option.

Pzixel gravatar imagePzixel ( 2018-02-28 12:59:26 -0500 )edit
1

"I'm trying to port OpenCV interfaces to Rust" -- cool ;)

"code generation" -- you've seen this and this ?

adapting a ~1000 lines python monster (which to 90% covers weird edge cases) might look daunting, but on the other hand, doing things manually, like those folks try will result in a "toy example", that only covers the 5% most used cases. (which again IS cool, too, don't get me wrong. problem is, if you deviate only a millimeter from it, you're staring into an open abyss)

berak gravatar imageberak ( 2018-02-28 13:13:06 -0500 )edit
1

I feel that you are right. However, I don't believe I can handle it, because I'm not familiar with python at all, and my codegen experience ends on some plays with Roslyn. However, I'l try to give it a shot anyway, just to not be sorry for not even trying.

Pzixel gravatar imagePzixel ( 2018-02-28 13:39:53 -0500 )edit

you ARE trying, and that's good !

berak gravatar imageberak ( 2018-02-28 13:43:09 -0500 )edit

1 answer

Sort by ยป oldest newest most voted
2

answered 2018-02-28 09:32:37 -0500

berak gravatar image

it's dead since 2010. please do not attempt to write any new code this way

(write your own wrappers, yes)

((and even then, you'll have to use a c++ compiler, exceptions and whatnot))

edit flag offensive delete link more

Comments

It it planned to expose some "official" wrappers? Because there is multiple wrappers written in C#/Python/Java/... It seems logical to write some common shared API that allows to perform FFI calls.

Pzixel gravatar imagePzixel ( 2018-02-28 10:17:41 -0500 )edit

i dont think so. yea, i know. unfortunately, though all of python,java,gocv,emgu have to use some intermediary c code, it differs so much, that it can never be reused.

berak gravatar imageberak ( 2018-02-28 10:53:15 -0500 )edit

seehere for a similar issue: https://github.com/opencv/opencv/issu...

btw, openvx might be much more c-friendly, just saying ;)

berak gravatar imageberak ( 2018-02-28 10:56:11 -0500 )edit
1

Oh btw it might be nice to know, that OpenCV org literally deleted the C - interface from the list of interfaces on its website with the launch of 3.4.1, so forget using it :D

StevenPuttemans gravatar imageStevenPuttemans ( 2018-02-28 12:03:30 -0500 )edit
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2018-02-28 09:12:07 -0500

Seen: 1,746 times

Last updated: Feb 28 '18