OpenCV bindings for D

Guillaume Piolat via Digitalmars-d digitalmars-d at puremagic.com
Mon Mar 21 09:01:59 PDT 2016


On Monday, 21 March 2016 at 15:45:36 UTC, wobbles wrote:
> Hi Folks,
>
> I have a project in mind that I'd like to run on my new 
> Raspberry Pi 3.
> Essentially a security camera that will only record when it 
> detects changes between frames.
> Now, this is already a solved problem I believe, however in the 
> interest of learning I want to do it myself.
>
> Ideally, I'd compare two images using the OpenCV library, and 
> ideally I'd do that from D code.
>
> However, there exists no OpenCV binding for D that I can find. 
> Is there a technical reason for this?
>
> I understand the OpenCV C api is quite old and dated, and it's 
> recommended to use the C++ one as a result.
> On that, where is C++ / D linkage at?
>
> I know very little about linking the two, but it's something 
> I'd like to learn more about and see this as an opportunity for 
> that - before I sink a load of time into it, however, it'd be 
> good to know if it's even feasibly possible to do so.
>
> Thanks!

It's quite easy to write bindings for libraries that have a C 
interface (ie most), if only a bit boring.

- First check in code.dlang.org or 
https://github.com/D-Programming-Deimos it doesn't not already 
exist.

- Choose to create a static or dynamic bindings. For 
multiplatform a dynamic loader will be easier dependency-wise, 
for *nix systems static linking may be easier.

- When porting C headers, there is a few gotchas: 
https://p0nce.github.io/d-idioms/#Porting-from-C-gotchas

- Take inspiraton at either Deimos or Derelict to create either.


More information about the Digitalmars-d mailing list