Ok, time to do something concrete.
Usually examples are neat little programs, heavily commented, that do something completely useless. Since this is a tradition, I was unable to refrain using it. Unfortunadly GOCR can't do ``Hello World'', and so I had to imagine something equally uninteresting, and I used the filter example I just told you.
* A simple program, that applies a filter to a
* image, and outputs the image.
*/
#include <gocr.h>
int main(int argc, char **argv) {
if ( gocr_init(argc, argv) == -1 )
if ( gocr_setAttribute(VERBOSE, 0) == -1 )
if ( gocr_moduleLoad(''modulename.so'') == -1 )
if ( gocr_functionAppend(imageFilter, ''cleanDust'', NULL) != -1 )
if ( gocr_functionAppend(outputFormatter, ''imageOutput'',
''output.jpg'') != -1 )
if ( gocr_imageLoad(''image.jpg'', (void *)GOCR_NONE) )
gocr_runAllModules();
/* Ok, say good bye */
gocr_finalize();
When you call gocr_finalize(), it takes care of unloading shared objects, deleting module functions, closing the image, etc. Don't worry with hundreds or close()s, free()s, etc.