I am developing an android app with opencv and I have convert c++ code to java about finded hough circles in java. I find c++ code and convert limited.
this lines find and fill lists :
vector<vector<Vec3f> > bubble;
vector<pair<double,int> > row;
for(int i=0;i<circles.size();i++){
bool found = false;
int r = cvRound(circles[i][2]);
int x = cvRound(circles[i][0]);
int y= cvRound(circles[i][1]);
for(int j=0;j<row.size();j++){
int y2 = row[j].first;
if(y-r<y2&&y+r>y2){
bubble[j].push_back(circles[i]);
found = true;
break;
}
}
if(!found){
int l = row.size();
row.push_back(make_pair(y,l));
vector<Vec3f> v;
v.push_back(circles[i]);
bubble.push_back(v);
}
found = false;
}
this lines sort the lists:
bool comparator2(pair<double,int> a,pair<double,int> b){
retu a.first<b.first;
}
bool comparator3(Vec3f a,Vec3f b){
retu a[0]<b[0];
}
sort(row.begin(),row.end(),comparator2);
for(int i=0;i<bubble.size();i++){
sort(bubble[i].begin(),bubble[i].end(),comparator3);
}
