int[][] GlobCenters discrepancy in JMyron
Brought to you by:
jtnimoy
The java wrapper "JMyron" was not returning the last globcenter when the number of globs was uneven (1 glob, 3 globs, 5 globs)
so i had a quick look at the code and noticed the following:
// i changed this *********************************************************
public int[][] globCenters(){
int b[] = native_globCenters();
int returnArray[][] = new int[b.length/2][2];
//the following line used to read
// for(int i=0;i<b.length/2-1;i++){
for(int i=0;i<b.length/2;i++){
returnArray[i][0] = b[i*2 ];
returnArray[i][1] = b[i*2+1];
}
return returnArray;
}
//*************************************************************************
i have compiled and tested this in processing, and globCenters now returns all globCenters
fixed wrapper
re-corrected JMyron.java
Logged In: YES
user_id=2147957
Originator: YES
::update::
this is not right either, since Myron returns THREE integers per-blob.
the last one appears to be an empty (0) at the end of native_globCenters[]
for example this is what it looks like when myron finds three globs :
16
186
119
211
207
224
0
0
0
the code should be as follows :
public int[][] globCenters(){
int b[] = native_globCenters();
//returnArray[] should be b.length/3 instead of b.length/2
int returnArray[][] = new int[b.length/3][2];
//Myron natively returns three (3)
//coordinates per-glob...
//since the last coordinate is added
//as a single zero at the end of native_globcenters[]
//we itterate through one third of the number
//of coordinates
//(we fetch two coordinates each time, so we actually
// get two third of the coordinates this way)
//id will point at the 'glob' whose coordinates we are getting
int id = 0;
//itterate through one third of the available coordinates
for(int i=0;i<b.length/3;i++){
returnArray[i][0] = b[id*2 ];
returnArray[i][1] = b[id*2+1];
//increment id
id++;
}
return returnArray;
}
i have attached the corrected .java file
File Added: JMyron.java