Skip to content
khigia edited this page Sep 12, 2010 · 8 revisions

Intro

eocarve is mainly meant as an example of ocamerl library.

Usage example

(see the test folder for some complete code example)

Shortly, here is an Erlang session to crop image “test.jpg” by 20 pixels:


% create a carver thread on ocaml node
R1 = make_ref(),
{eocarving, ocaml@myhost} ! {self(), R1},
{ok, Carver} = receive {R1, P} -> {ok, P} after 1000 -> error end,

% set input file (could send the data directly …)
Carver ! {set_src_file, “test.jpg”},
% start the carving processing in ocaml
Carver ! {carve_h, -50},

% ask the carver to stop (ensure the previous pasks are done)
Carver ! {self(), stop},
ok = receive {Carver, stopped} → ok after 5000 → error end.
% new image is ready!

Implementation details

  • The main node is implemented in file carve.ml
  • Function doit create the node itself
  • Function create_main_process register a mboxe to enable eternal node to find the service; role of the process is to create worker processes which will do the carving
  • Function create_worker_process make the ocaml carver processes and dispatch accordingly message from external nodes
    Module Carve implement an interface to the seamcarving library (it is use by previous function).
Clone this wiki locally