|
||||||
ERS-110, 111 |
ERS-210[A], 220[A] |
Programming AIBO with: YART, RCodePlus OpenR SDK
|
ERS-311[B], 312[B], 31L |
ERS7 |
||
|
Home
Movies (all) |
PDAs: CLIE
( Panel
Zipit )
Lesser Robots: Pleo ( RoboSapien ICybie ) Game Hacks: Nintendo Wii Nintendo DS ( PSP ) |
Email: aibopet@aibohack.com | ||||
RCodePlus Image (camera) features |
JPEG images |
Color Detection |
bit 0 = pink ball
bit 1 = another pink ball
bit 2 = ?
bit 3 = flesh
bit 4 = favorite (typically blue)
bit 5 = un-favorite (typically yellow/green)
bit 6 = ?
bit 7 = ?
A value of 3 (bit 0 + bit 1) is commonly used to match the PinkBall.
AP_COLORLVL bit_index output_variable
// bit_index = 0 -> 7
//example:
AP_COLORLVL 4 fav // fav in range 0 to 255
IF fav > 25 THEN
// do something when FAV color is seen
ENDIF
//example:
AP_COLORLVL 0 pink1
AP_COLORLVL 1 pink2
SET pinkBoth pink1
ADD pinkBoth pink2 // pinkBoth in the range 0 to 510
IF pinkBoth > 25 THEN // or some other threshold
// saw something pink
ENDIF
No color snapshot is required. The current color detection values are used (which are updated 25 times per second).
// prepare array (do this once)
SET cdt ? // some available array number
AP_DIM cdt 3168 // 88*72/2
AP_GETCOLORARRAY cdt
AP_COLORFND cdt_array colormask x y count
// inputs:
// cdt_array = array captured as described above
// colormask = byte color mask for all the colors you care about
// (eg: 3 for pink ball)
// outputs:
// x, y = returns center of matching color
// count = returns count of matching pixels [if 0 then x,y invalid]
From this x,y position, and the position of the head, you can determine where the object is.
The "count" can be used to infer the distance to a known size object like the ball.
AP_COLORGRID cdt_array colormask result_array xgrid ygrid
// inputs:
// cdt_array = array captured as described above
// colormask = byte color mask for all the colors you care about
// (eg: 3 for pink ball)
// xgrid = number of horizontal pieces
// ideally an even divisor of 88 (eg: 2, 4, 8)
// ygrid = number of vertical pieces
// ideally an even divisor of 72 (eg: 2, 3, 4, 6, 8)
// outputs:
// result_array = array of values,
// dimensioned to be at least xgrid * ygrid elements
// element order is:
// x=0, y=0
// x=1, y=0
// x=2, y=0
// ...
// x=xgrid-1, y=0
// x=0, y=1
// x=1, y=1
// ...
// x=xgrid-2, y=ygrid-1
// x=xgrid-1, y=ygrid-1