13.07.2015 Views

Getting started with Imalab and Scheme - PRIMA

Getting started with Imalab and Scheme - PRIMA

Getting started with Imalab and Scheme - PRIMA

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

arguments, try (help ClassName FunctionName)./usr/local/include/PrimaVision/.If still not satisfied, look in the header files(help ClassName) displays all member functions of the class ClassName.(help ClassName FunctionName) displays information about the function FunctionName of theclass ClassName.(a-propos name) lists all functions, global variables <strong>and</strong> classes that contain the string name in theirname. This function is useful when you do not remember the exact name of a function.5.2 Interaction <strong>with</strong> imagesSee also example file point.scm (section 9).(require ’modModuleName) loads the module ModuleName. It must be a compiled module. Therequire call loads the modules located in the directories of *module-path*. The st<strong>and</strong>ard PrimaVisionmodules are modArray, modArrayBitmap, modArrayMatrix, modBitmap, modColorEncode,modFilter, modGeom2D, modList, modListBitmap, modeListGeom2D, modListMatrix,modMatrix, modRegionVS, modTGFilter. You should find the corresponding modName.x.scm <strong>and</strong>modName.so in/usr/local/lib/Ravi/Site-Module.The *module-path* <strong>and</strong> the *ld-path* are set in /.ravi2/paths.scm.(load "test") or (load "test.scm") With the load comm<strong>and</strong> local test scripts can be loaded.The directories specified by *ld-path* are searched. File name extensions: <strong>Scheme</strong> files should have extension.scm. The load comm<strong>and</strong> will first look for several extensions.(define img (new TBitmapABGR 256 128)) the new function calls the constructor of the correspondingc++ class <strong>and</strong> returns a pointer to the object. The object is referenced.Deleting objects under scheme is not necessary. <strong>Scheme</strong> has automatic memory management. C++ objectsare deleted automatically by the garbage collector when the reference counter is zero. The garbage collector isautomatically called from time to time.(garbage) calls the garbage collector. This is only necessary when very large data structures are manipulated<strong>and</strong> you risk to run out of memory before the garbage collector is called automatically.(define img (new-ppm "filename.ppm"))This loads an image from a filename. Typing the variable name <strong>with</strong>out parentheses displays information about thevariable. This is a way to test if the loading is successful.(send img GetPixelFloat i j) The send function ”sends” a method call to a c++ object.the way to execute c++ class methods. (The GetPixelFloat method returns the pixel at position (i, j).This is(send img SetPixel value i j b<strong>and</strong>) The channel b<strong>and</strong> of pixel (i,j) of img is set to value.The order of the color b<strong>and</strong>s can be machine dependent.(send img GetRedImage) returns the red byte image of a multi-b<strong>and</strong> image, independent of the machine.(define float img (send img Convert kFloat)) converts the image of type TBitmapByte, TBitmapABGR,or TBitmapRGB to TBitmapFloat.7

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!