www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.announce - Computer Vision Library in D

reply Relja Ljubobratovic <ljubobratovic.relja gmail.com> writes:
Hi everyone!

For a while I was looking for a computer vision library in D on 
the web, but haven't found any. There were few libraries I found, 
providing some basic image processing functionality, but none 
that could be remotely compared to opencv or other similar open 
source computer vision toolkits present for other languages. 
Surely for a year, even maybe two, this has been stopping me to 
switch completely to D from C/C++.

Anyhow, lately I've started working on such library [1]. The plan 
at first was to implement the most basic computer vision 
algorithms, on top of which other more complex algorithms could 
be built on. So far, I've mostly had experience with feature 
correspondence, optical flow and stereo vision, so those would 
probably be the first few modules I'd implement.

But I was really hopping to find other computer vision people in 
the D community, that would like the idea and help out. I'm not 
well experienced in D, and also It's fair to say that I'm not 
experienced well enough in computer vision area to take on an 
undertaking such as writing this library alone. So I feel it's 
evident that I'd need some help, to make this library usable to 
other computer vision scientists and engineers.

Is there anyone who would like to join me?

Cheers,
Relja

[1] https://github.com/ljubobratovicrelja/dcv
Apr 19 2016
next sibling parent reply =?UTF-8?B?Tm9yZGzDtnc=?= <per.nordlow gmail.com> writes:
On Tuesday, 19 April 2016 at 17:01:12 UTC, Relja Ljubobratovic 
wrote:
 [1] https://github.com/ljubobratovicrelja/dcv
Standard modules for color conversion already exists. See for instance https://github.com/TurkeyMan/color https://github.com/adamdruppe/arsd/blob/master/color.d Great that you've made compatible with ndslice!
Apr 19 2016
parent reply Relja Ljubobratovic <ljubobratovic.relja gmail.com> writes:
Hey guys, thank you all for responding!

 Standard modules for color conversion already exists. See for 
 instance
That's awesome, thanks! - I'll look into it!
 Wouldn't it be easier to just write bindings to C interface of 
 OpenCV, or make a thin D-style wrapper over that API, and use a 
 proven widely supported computer vision library rather than try 
 to reinvent the wheel?
I've given this a lot of thought. I use OpenCV daily on the job, and I'm very familiar with it. I too believe it would probably be smarter, faster and safer to wrap its C interface with D, from the user's point of view. The reason why I chose not to do it is it's complexity - OpenCV has everything implemented/integrated inside - linear algebra, machine learning, optimization and all the other submodules that are needed for cv. In the dcv project, I'd really like to rely on third party libraries for such functionality - actualy I was encouraged and inspired to do it because of DlangScience guys. I'm hopping that scid and other such libraries would get a interface with ndslice in time, which is the reason I chose to use it as main array structure in the library. I believe (as many do I'm sure) that through the ndslice, D would get numeric ecosystem nice and well integrated as python, which I think would be a great success for the language. So the long story short - we could build a opencv wrapper, but here I wanted to start building something that would more nicely fit with DlangScience and other D libraries.
 You've got a bad  trusted here
Thanks - I'll fix it and try to learn bit more about trusted!
 I am happy to see that you use ndslice. We start to build 
 numeric library for science and machine learning. SVM, which is 
 used in CV is in out TODO list. You are welcome for feature 
 request and for contributing.
Hey Ilya! The text above tells that I've been closely following your work, and that I hope ndslice plays important part in D's numeric future. I will of course watch the SVM and other such projects from you guys, and will contribute whenever I can - thanks a lot for your effort!
 I'm interested in contributing towards parts that involve 
 machine learning/numerical optimisation. I have written some of 
 my own CV/ML programs with D in the past, but none of them are 
 particularly well engineered since they were all intended for 
 just my own use.
That's great, thanks Henry! As I've noted above, I think it would be wise to keep modules like ML and optimization apart from this library, and to integrate dcv with them through ndslice. Maybe it's more likely that you could contribute to DlangScience's SVM libray with those parts? But any of your previous CV experience is more than welcome for DCV - I'll contact you on the github so we could discuss this further, hope that's ok.
Apr 19 2016
next sibling parent reply rikki cattermole <rikki cattermole.co.nz> writes:
On the note of linear algebra.
Would you be willing to improve gfm:math (or start from scratch I don't 
really care too much) for Phobos inclusion?

Its one of the things I need for my work e.g. windowing + image.

Also how much do you know about color theory?
Manu really needs help to get his color work to support blending (its 
mostly time thing really) and that would really help since its meant for 
Phobos.
Apr 19 2016
parent reply Relja Ljubobratovic <ljubobratovic.relja gmail.com> writes:
On Wednesday, 20 April 2016 at 04:37:10 UTC, rikki cattermole 
wrote:
 On the note of linear algebra.
 Would you be willing to improve gfm:math (or start from scratch 
 I don't really care too much) for Phobos inclusion?
Frankly, I didn't know about the gfm project - it seems nice! About the math module, I'm not really sure how (or where) it would fit into Phobos? Seems to me that such module really should be kept as a library. Isn't there a isolated 3D math library present in dub? Anyways, I'll look into it more closely when I find time!
 Also how much do you know about color theory?
 Manu really needs help to get his color work to support 
 blending (its mostly time thing really) and that would really 
 help since its meant for Phobos.
I've given it only a quick look just now, and it seems great! - I'll definitely look into it!
Apr 19 2016
parent reply rikki cattermole <rikki cattermole.co.nz> writes:
On 20/04/2016 4:49 PM, Relja Ljubobratovic wrote:
 On Wednesday, 20 April 2016 at 04:37:10 UTC, rikki cattermole wrote:
 On the note of linear algebra.
 Would you be willing to improve gfm:math (or start from scratch I
 don't really care too much) for Phobos inclusion?
Frankly, I didn't know about the gfm project - it seems nice! About the math module, I'm not really sure how (or where) it would fit into Phobos? Seems to me that such module really should be kept as a library. Isn't there a isolated 3D math library present in dub? Anyways, I'll look into it more closely when I find time!
I was thinking std.math.linalg kinda seems like the right place once std.math is split up. There is an isolated one other than gfm.math. gl3n but I don't have permission to relicense to Boost. Its mostly ready unfortunately.
 Also how much do you know about color theory?
 Manu really needs help to get his color work to support blending (its
 mostly time thing really) and that would really help since its meant
 for Phobos.
I've given it only a quick look just now, and it seems great! - I'll definitely look into it!
Please!
Apr 19 2016
parent reply Relja Ljubobratovic <ljubobratovic.relja gmail.com> writes:
On Wednesday, 20 April 2016 at 06:14:58 UTC, rikki cattermole 
wrote:
 I was thinking std.math.linalg kinda seems like the right place 
 once std.math is split up.
 There is an isolated one other than gfm.math. gl3n but I don't 
 have permission to relicense to Boost. Its mostly ready 
 unfortunately.
I agree it sounds nice to have linalg package in the standard library. Although I'm still not sure about it - I've never seen such package in any other language's standard library. I'm not saying it's not right, just a bit strange to me.
Apr 20 2016
parent reply rikki cattermole <rikki cattermole.co.nz> writes:
On 20/04/2016 7:46 PM, Relja Ljubobratovic wrote:
 On Wednesday, 20 April 2016 at 06:14:58 UTC, rikki cattermole wrote:
 I was thinking std.math.linalg kinda seems like the right place once
 std.math is split up.
 There is an isolated one other than gfm.math. gl3n but I don't have
 permission to relicense to Boost. Its mostly ready unfortunately.
I agree it sounds nice to have linalg package in the standard library. Although I'm still not sure about it - I've never seen such package in any other language's standard library. I'm not saying it's not right, just a bit strange to me.
I only need matrices and vectors in Phobos. Whey do I want them? Simple. I want windowing in Phobos. Which just so happens to have contexts such as OpenGL, Vulkan and DirectX. Why does that matter? window.size * projMatrix is why. Making things just work without extra work. And yes, Java does have a definition in its standard lib for Point which is what I need. Its just better to unify instead of separating it out.
Apr 20 2016
parent reply Bill Baxter via Digitalmars-d-announce writes:
On Wed, Apr 20, 2016 at 9:26 PM, rikki cattermole via
Digitalmars-d-announce <digitalmars-d-announce puremagic.com> wrote:

 On 20/04/2016 7:46 PM, Relja Ljubobratovic wrote:

 On Wednesday, 20 April 2016 at 06:14:58 UTC, rikki cattermole wrote:

 I was thinking std.math.linalg kinda seems like the right place once
 std.math is split up.
 There is an isolated one other than gfm.math. gl3n but I don't have
 permission to relicense to Boost. Its mostly ready unfortunately.
I agree it sounds nice to have linalg package in the standard library. Although I'm still not sure about it - I've never seen such package in any other language's standard library. I'm not saying it's not right, just a bit strange to me.
Fortran has some linear algebra functions in the standard library. :-) Java and many other modern languages are pretty much actively hostile to doing numerical computation, so including a linear algebra package in the standard library of those languages would just highlight how bad they are at it. C++ has a tradition of not having a standard library for anything you might actually need to get work done, so I wouldn't follow their example. --bb
Apr 21 2016
parent reply Relja Ljubobratovic <ljubobratovic.relja gmail.com> writes:
On Thursday, 21 April 2016 at 16:13:31 UTC, Bill Baxter wrote:
 Fortran has some linear algebra functions in the standard 
 library.  :-)
 Java and many other modern languages are pretty much actively 
 hostile to
 doing numerical computation,
 so including a linear algebra package in the standard library 
 of those
 languages would just highlight how bad they are at it.
 C++ has a tradition of not having a standard library for 
 anything you might
 actually need to get work done, so I wouldn't follow their 
 example.

 --bb
Nice point about the Fortran, and also about the C++. :) I'd have to say I'm convinced - if there's a vote about such module joining Phobos, count me in! :) But really, when you look at it - the ndslice has made it to the Phobos, now it's probably natural to have some more extensive use of it in the standard library. Linear algebra stuff could be build nicely on top of the ndslice, you agree?
Apr 21 2016
parent reply Michael <michael toohuman.io> writes:
On Thursday, 21 April 2016 at 18:47:46 UTC, Relja Ljubobratovic 
wrote:
 Nice point about the Fortran, and also about the C++. :)

 I'd have to say I'm convinced - if there's a vote about such 
 module joining Phobos, count me in! :)

 But really, when you look at it - the ndslice has made it to 
 the Phobos, now it's probably natural to have some more 
 extensive use of it in the standard library. Linear algebra 
 stuff could be build nicely on top of the ndslice, you agree?
Perhaps it's a bit late to add to the original conversation, but I believe: https://github.com/DerelictOrg would be the ideal place to host C bindings to OpenCV if that was actually the plan. I didn't realise, as somebody suggested, that they were planning to remove their own C bindings for OpenCV which is pretty sad. And I would also like to see some more scientific libraries make it into D. Though I understand that including it in the standard library can cause issues, it would be nice to at least get some Linear Algebra libraries in experimental or over with the rest of the science libraries.
Apr 28 2016
parent reply Edwin van Leeuwen <edder tkwsping.nl> writes:
On Thursday, 28 April 2016 at 11:32:25 UTC, Michael wrote:
 And I would also like to see some more scientific libraries 
 make it into D. Though I understand that including it in the 
 standard library can cause issues, it would be nice to at least 
 get some Linear Algebra libraries in experimental or over with 
 the rest of the science libraries.
As I understand it that is part of the goal of mir: https://code.dlang.org/packages/mir Not sure if you were aware, but there is also a group with the aim to promote scientific dlang work: https://gitter.im/DlangScience/public
Apr 28 2016
parent Michael <michael toohuman.io> writes:
On Thursday, 28 April 2016 at 11:50:55 UTC, Edwin van Leeuwen 
wrote:
 On Thursday, 28 April 2016 at 11:32:25 UTC, Michael wrote:
 And I would also like to see some more scientific libraries 
 make it into D. Though I understand that including it in the 
 standard library can cause issues, it would be nice to at 
 least get some Linear Algebra libraries in experimental or 
 over with the rest of the science libraries.
As I understand it that is part of the goal of mir: https://code.dlang.org/packages/mir Not sure if you were aware, but there is also a group with the aim to promote scientific dlang work: https://gitter.im/DlangScience/public
I've seen the mir project and it looks promising. I'm also aware of Dlang science and I hope that it gains some support.
Apr 28 2016
prev sibling next sibling parent reply tost <a b.cd> writes:
On Wednesday, 20 April 2016 at 04:31:33 UTC, Relja Ljubobratovic 
wrote:

 I'm interested in contributing towards parts that involve 
 machine learning/numerical optimisation. I have written some 
 of my own CV/ML programs with D in the past, but none of them 
 are particularly well engineered since they were all intended 
 for just my own use.
That's great, thanks Henry! As I've noted above, I think it would be wise to keep modules like ML and optimization apart from this library, and to integrate dcv with them through ndslice. Maybe it's more likely that you could contribute to DlangScience's SVM libray with those parts? But any of your previous CV experience is more than welcome for DCV - I'll contact you on the github so we could discuss this further, hope that's ok.
I have an implementation of BFGS in D (except [open]BLAS :). BFGS is an algorithm for unconstrained optimization of nonlinear smooth functions. It is NOT L-BFGS and requires O(n*n) memory for optimizing f: R^n -> R. The linesearch may be useful to implement other algorithms. It works fine for me, but needs some refactoring. Given existing bindings for nlopt: would this be useful? If so, I start the refactoring. For now, there are no benchmarks, but it is definitely faster/fewer iterations than optim(method="BFGS") in R and the algorithm should be better than the version in GSL (if n is not too large, GSL uses some kind of L-BFGS).
Apr 19 2016
parent reply Relja Ljubobratovic <ljubobratovic.relja gmail.com> writes:
On Wednesday, 20 April 2016 at 06:10:50 UTC, tost wrote:
 On Wednesday, 20 April 2016 at 04:31:33 UTC, Relja
 I have an implementation of BFGS in D (except [open]BLAS :). 
 BFGS is an algorithm for unconstrained optimization of 
 nonlinear smooth functions. It is NOT L-BFGS and requires 
 O(n*n) memory for optimizing f: R^n -> R. The linesearch may be 
 useful to implement other algorithms.
Sound great! Although I'm far from implementing methods that use optimization techniques for dcv, I'll be sure to remember this. Maybe you should push the solution to github and have other people take a look?
Apr 20 2016
parent tost <a b.cd> writes:
On Wednesday, 20 April 2016 at 07:43:01 UTC, Relja Ljubobratovic 
wrote:
 Sound great! Although I'm far from implementing methods that 
 use optimization techniques for dcv, I'll be sure to remember 
 this. Maybe you should push the solution to github and have 
 other people take a look?
hopefully at the weekend. I want to tidy up first...
Apr 20 2016
prev sibling parent reply Jacob Carlborg <doob me.com> writes:
On 2016-04-20 06:31, Relja Ljubobratovic wrote:

 I've given this a lot of thought. I use OpenCV daily on the job, and I'm
 very familiar with it. I too believe it would probably be smarter,
 faster and safer to wrap its C interface with D, from the user's point
 of view.
https://github.com/jacob-carlborg/dstep -- /Jacob Carlborg
Apr 20 2016
parent tchaloupka <chalucha gmail.com> writes:
On Wednesday, 20 April 2016 at 19:53:27 UTC, Jacob Carlborg wrote:
 On 2016-04-20 06:31, Relja Ljubobratovic wrote:

 I've given this a lot of thought. I use OpenCV daily on the 
 job, and I'm
 very familiar with it. I too believe it would probably be 
 smarter,
 faster and safer to wrap its C interface with D, from the 
 user's point
 of view.
https://github.com/jacob-carlborg/dstep
Is it even safe to depend on currently unmaintained C interface? http://answers.opencv.org/question/17546/opencv-will-drop-c-api-support-soon/
Apr 20 2016
prev sibling next sibling parent JN <666total wp.pl> writes:
On Tuesday, 19 April 2016 at 17:01:12 UTC, Relja Ljubobratovic 
wrote:
 Hi everyone!

 For a while I was looking for a computer vision library in D on 
 the web, but haven't found any. There were few libraries I 
 found, providing some basic image processing functionality, but 
 none that could be remotely compared to opencv or other similar 
 open source computer vision toolkits present for other 
 languages. Surely for a year, even maybe two, this has been 
 stopping me to switch completely to D from C/C++.
OpenCV has a C interface. Wouldn't it be easier to just write bindings to C interface of OpenCV, or make a thin D-style wrapper over that API, and use a proven widely supported computer vision library rather than try to reinvent the wheel?
Apr 19 2016
prev sibling next sibling parent ag0aep6g <anonymous example.com> writes:
On 19.04.2016 19:01, Relja Ljubobratovic wrote:
 [1] https://github.com/ljubobratovicrelja/dcv
You've got a bad trusted here: https://github.com/ljubobratovicrelja/dcv/blob/3b7e4908bfb535536f4b71862239ee071d22461d/source/dcv/core/algorithm.d#L23 You're trusting Range's empty, front, and popFront, but they may be unsafe. You're also trusting arbitrary code that's passed in via comparator.
Apr 19 2016
prev sibling next sibling parent Ilya Yaroshenko <ilyayaroshenko gmail.com> writes:
On Tuesday, 19 April 2016 at 17:01:12 UTC, Relja Ljubobratovic 
wrote:
 Hi everyone!

 For a while I was looking for a computer vision library in D on 
 the web, but haven't found any. There were few libraries I 
 found, providing some basic image processing functionality, but 
 none that could be remotely compared to opencv or other similar 
 open source computer vision toolkits present for other 
 languages. Surely for a year, even maybe two, this has been 
 stopping me to switch completely to D from C/C++.

 Anyhow, lately I've started working on such library [1]. The 
 plan at first was to implement the most basic computer vision 
 algorithms, on top of which other more complex algorithms could 
 be built on. So far, I've mostly had experience with feature 
 correspondence, optical flow and stereo vision, so those would 
 probably be the first few modules I'd implement.

 But I was really hopping to find other computer vision people 
 in the D community, that would like the idea and help out. I'm 
 not well experienced in D, and also It's fair to say that I'm 
 not experienced well enough in computer vision area to take on 
 an undertaking such as writing this library alone. So I feel 
 it's evident that I'd need some help, to make this library 
 usable to other computer vision scientists and engineers.

 Is there anyone who would like to join me?

 Cheers,
 Relja

 [1] https://github.com/ljubobratovicrelja/dcv
Hi Relja, I am happy to see that you use ndslice. We start to build numeric library for science and machine learning. SVM, which is used in CV is in out TODO list. You are welcome for feature request and for contributing. https://github.com/DlangScience/mir Best regards, Ilya
Apr 19 2016
prev sibling next sibling parent Henry Gouk <henry.gouk gmail.com> writes:
On Tuesday, 19 April 2016 at 17:01:12 UTC, Relja Ljubobratovic 
wrote:
 Hi everyone!

 For a while I was looking for a computer vision library in D on 
 the web, but haven't found any. There were few libraries I 
 found, providing some basic image processing functionality, but 
 none that could be remotely compared to opencv or other similar 
 open source computer vision toolkits present for other 
 languages. Surely for a year, even maybe two, this has been 
 stopping me to switch completely to D from C/C++.

 [...]
I'm interested in contributing towards parts that involve machine learning/numerical optimisation. I have written some of my own CV/ML programs with D in the past, but none of them are particularly well engineered since they were all intended for just my own use.
Apr 19 2016
prev sibling next sibling parent reply xenon325 <anm programmer.net> writes:
Great project, good luck!

A minor note. Any specific reason, you've chosen MIT license over 
Boost ?

AFAICT they are practically identical, but Boost is more popular 
in this community, so it would be easier in the future to 
exchange code between your project and dlang-science, for example.

-Alexander
Apr 20 2016
parent Relja Ljubobratovic <ljubobratovic.relja gmail.com> writes:
On Wednesday, 20 April 2016 at 07:13:44 UTC, xenon325 wrote:
 Great project, good luck!

 A minor note. Any specific reason, you've chosen MIT license 
 over Boost ?

 AFAICT they are practically identical, but Boost is more 
 popular in this community, so it would be easier in the future 
 to exchange code between your project and dlang-science, for 
 example.

 -Alexander
Hey Alexander, thanks! I chose the MIT at first, but I've realized since then it would be more appropriate to license it under Boost. I will change it to boost for sure. Thanks for the suggestion!
Apr 20 2016
prev sibling parent Ferhat =?UTF-8?B?S3VydHVsbXXFnw==?= <aferust gmail.com> writes:
On Tuesday, 19 April 2016 at 17:01:12 UTC, Relja Ljubobratovic 
wrote:
 Hi everyone!

 For a while I was looking for a computer vision library in D on 
 the web, but haven't found any. There were few libraries I 
 found, providing some basic image processing functionality, but 
 none that could be remotely compared to opencv or other similar 
 open source computer vision toolkits present for other 
 languages. Surely for a year, even maybe two, this has been 
 stopping me to switch completely to D from C/C++.

 [...]
I know it is a little late but I have just started this project https://github.com/aferust/opencvd
Apr 09 2019