libmir / dcv

Computer Vision Library for D Programming Language
http://dcv.dlang.io/
Boost Software License 1.0
91 stars 18 forks source link

Image I/O #49

Open ljubobratovicrelja opened 8 years ago

ljubobratovicrelja commented 8 years ago

As discussed in #48, maybe we should start planning on how to enrich the image I/O package of the library. Imageformats library is good (especially because it is purely written in D), but format coverage is poor (especially for encoders).

Use C libraries

So first idea is to build minimal bindings (or use existing ones) to popular C libraries:

Some people already translated some of the popular encoder/decoders to D. I feel that's not that easy to do, and I'd personally much more like to focus on the DCV's core, but if we decide to take this step, no problem.

Using FFmpeg

@henrygouk suggested we could use ffmpeg to encode/decode image formats. This also seems like a great choice since lot of formats are supported, and ffmpeg-d is already a dependency.

Custom image I/O library's synergy with dcv:core

There was also discussion that users should be free to use 3rd party libraries for image I/O with DCV. I believe this is already achievable in DCV - e.g. if user is working with gtkd, and dcv:core, he/she can load pixbuf from file, then slice it's data and work along with dcv algorithms. So, I believe we're OK here, except maybe we should make an example on this topic to show it to people.

Separation of Image I/O from Video

Also we discussed if image io should be separated from video - in #48 we defined dcv:io sub-package, where we could have defined dcv:ioimage, and dcv:iovideo. If we decide to go with first option (bind C libs), I really think we should do this since it would be heavy loaded with C libs.

Any comment is welcome.

ljubobratovicrelja commented 8 years ago

Pinging guys working on DCV @DmitryOlshansky @9il @henrygouk

henrygouk commented 8 years ago

It looks like ffmpeg supports all of those image formats [1], which could cut down on the amount of work required. It's also already a dependency for the video IO, so no new dependencies would need to be added.

ljubobratovicrelja commented 8 years ago

It looks like ffmpeg supports all of those image formats

Aw, snap - I'm sorry, forgot to add that one! Added to original post.

This actually sounds like a great plan! Relatively easy to implement, and truly powerful - whole lot of formats are supported there. Have you had any experience with this pipeline? Are there any potential drawbacks? I'd suppose there are none or very few...

henrygouk commented 8 years ago

I've never worked with the ffmpeg libraries before, so I'm not sure how easy it would be to use them. It looks like the ff_load_image function will come in handy, though saving images may be a bit more involved.

ljubobratovicrelja commented 8 years ago

We'll figure it out - ffmpeg tool has options to load image sequence and save them as video file, and vice versa, so there's a way to do this for sure.