0

I am looking to build a system in which I am able to call Cool Image library functions (It's a C Language library for image processing tasks) by using Prolog.

There are functions in CoolImage Library such resizing an image, creating a mask etc. So I don't want to make any changes to those functions, it's just that by using Prolog I can call them and further use it for building a WIN32 API.

I would be thankful if someone can guide me regarding this i.e. any reference which I should refer or any way of implementation.

  • Are you referring to [CImg](http://cimg.eu/) ? Cannot find anything useful googling for 'CoolImage library'... but I know a bit of CImg, and could be interested to provide support to interface it to SWI-Prolog – CapelliC Sep 27 '19 at 04:52
  • Yes I am referring to CImg only, I apologize for incorrect information. – Palash Sharma Sep 27 '19 at 11:08
  • 1
    It's c++, then. Maybe this evening I'll try to craft a pack for CImg. Will let you know if it happens. – CapelliC Sep 27 '19 at 11:23
  • Okay,thanks for the information. It would be of great help for me, thanks a lot for this – Palash Sharma Sep 27 '19 at 15:53
  • @CapelliC Have you got any references for me regarding this problem statement. – Palash Sharma Sep 29 '19 at 16:32
  • Still working on it, sorry... had problems compiling on Windows, and I would like the pack to be portable. Anyway, this evening will load a demo on github to get you started. – CapelliC Sep 29 '19 at 17:02

1 Answers1

1

I've uploaded to github an example of a simple minded interface, running the first example found in CImg documentation (see example.pl) when passed as argument to the program.

It shows how to create objects and define methods that act on such objects. Take a look at what the code does, and feel free to ask for problems.

edit:

Updated the git repo introducing modules for the interface predicates. Now exposed members of CImg,CImgDisplay classes must be prefixed respectively by cImg,cImgDisplay, and constructors/destructors are named new, delete.

The file example.pl has been moved to examples/getting_started.pl, and it's shown how to fetch images located relative to the source:


    ...
    module_property(getting_started,file(ModuleFile)),
    file_directory_name(ModuleFile,ModuleDir),
    directory_file_path(ModuleDir,'img/milla.bmp',Milla),

    cImg:new(Milla,Image),
    cImg:blur(Image,2.5),

edit: When you find you need to call a member not yet implemented, you should add it in your swipl_cimg.cpp, in the appropriate section (I mean, where you see the #define PROLOG_MODULE className... corresponding to the object you need), dereference the object(s) using the cast functions and call the c++ method. It's a lengthy, boring way, sorry but I don't know nothing better... To cover the full CImg library, a lot of work is required. So, attempt to implement - and carefully test - only what is needed...

It's useful to follow some convention: input parameters first, output last.

CapelliC
  • 59,646
  • 5
  • 47
  • 90
  • I understood the way you did the compilation and execution of the prolog and cimg. I just wanted to know, what approach should I use to call other cimg functions by using prolog with this approach which you have used. – Palash Sharma Oct 01 '19 at 20:11