LATEST VERSION 1.0 (26.06.2012)

Description

UKNearest is a module for Urbi to handle K-Nearest algorithm implemented in OpenCV. Very useful for robot learning tasks eg. color learning.
You can find more information here WIKIPEDIA, LINK.
See demo of the algorithm LINK.

Module functions

UKNearest.new(maxK); - init object with max K-Nearest neighbor number
UKNearest.loadData("fileName.xml"); - Load saved trained data
UKNearest.saveData("fileName.xml"); - Save trained data
UKNearest.train([data1,data2,...,datan], "label1"); - Train data
UKNearest.find([data1,data2,...,datan], no_of_k); - Check trained data with given number of K nearest neighbors
UKNearest.getMaxK(); - get max K-Nearest neighbor number
UKNearest.getVarCount(); - get number of classes
UKNearest.getSampleCount(); - get number of samples

Urbiscript example

loadModule("uknearest");
var u = UKNearest.new(32);
u.train([0, 0], "black");
u.train([0, 1], "black");
u.train([0, 2], "black");
u.train([0, 3], "black");
u.train([0, 4], "black");
u.train([0, 5], "black");
u.train([0, 6], "black");
u.train([0, 7], "black");
u.train([0, 8], "black");
u.train([0, 9], "black");
u.train([1, 0], "black");
u.train([1, 1], "black");
u.train([1, 2], "black");
u.train([1, 3], "black");
u.train([1, 4], "black");
u.train([1, 5], "black");
u.train([1, 6], "black");
u.train([1, 7], "black");
u.train([1, 8], "black");
u.train([1, 9], "black");
u.train([2, 0], "black");
u.train([2, 1], "black");
u.train([2, 2], "black");
u.train([2, 3], "black");
u.train([2, 4], "black");
u.train([2, 5], "black");
u.train([2, 6], "black");
u.train([2, 7], "black");
u.train([2, 8], "black");
u.train([2, 9], "black");
u.train([3, 0], "black");
u.train([3, 1], "black");
u.train([255, 255], "white");
u.train([255, 254], "white");
u.train([255, 253], "white");
u.train([255, 252], "white");
u.train([255, 251], "white");
u.train([255, 250], "white");
u.train([255, 249], "white");
u.train([255, 248], "white");
u.train([255, 247], "white");
u.train([255, 246], "white");
u.train([254, 255], "white");
u.train([254, 254], "white");
u.train([254, 253], "white");
u.train([254, 252], "white");
u.train([254, 251], "white");
u.train([254, 250], "white");
u.train([254, 249], "white");
u.train([254, 248], "white");
u.train([254, 247], "white");
u.train([254, 246], "white");
u.train([253, 255], "white");
u.train([253, 254], "white");
u.train([253, 253], "white");
u.train([253, 252], "white");
u.train([253, 251], "white");
u.train([253, 250], "white");
u.train([253, 249], "white");
u.train([253, 248], "white");
u.train([253, 247], "white");
u.train([253, 246], "white");
u.train([252, 255], "white");
u.train([252, 254], "white");
u.train([125, 125], "gray");
u.train([125, 124], "gray");
u.train([1000,1000], "nothing");
u.train([125, 123], "gray");
u.train([125, 122], "gray");
u.train([125, 121], "gray");
u.train([125, 120], "gray");
u.train([125, 119], "gray");
u.train([125, 118], "gray");
u.train([125, 117], "gray");
u.train([125, 116], "gray");
u.train([124, 125], "gray");
u.train([124, 124], "gray");
u.train([124, 123], "gray");
u.train([124, 122], "gray");
u.train([124, 121], "gray");
u.train([124, 120], "gray");
u.train([124, 119], "gray");
u.train([124, 118], "gray");
u.train([9000,9000], "nothingaaa");
u.train([124, 117], "gray");
u.train([124, 116], "gray");
u.train([123, 125], "gray");
u.train([123, 124], "gray");
u.train([123, 123], "gray");
u.train([123, 122], "gray");
u.train([123, 121], "gray");
u.train([123, 120], "gray");
u.train([123, 119], "gray");
u.train([123, 118], "gray");
u.train([123, 117], "gray");
u.train([123, 116], "gray");
u.train([122, 125], "gray");
u.train([122, 124], "gray");
 
echo("***************");
 
u.find([0,0],5);
u.find([255,255],5);
u.find([200,200],5);
u.find([128,128],5);
u.saveData("dane.xml");
var w = UKNearest.new(32);
w.loadData("dane.xml");
w.find([0,0],5);
w.find([255,255],5);
w.find([200,200],5);
w.find([128,128],5);

Download

LINK

 

 

 

EMYS and FLASH are Open Source and distributed according to the GPL v2.0 © Rev. 0.8.0, 27.04.2016

FLASH Documentation