int* poly = new int[lines.size()];
for(int i=0;i<lines.size();i++)poly[i] = - 1;
int curPoly = 0;
vector<vector<cv::Point2f> > corners;
for (int i = 0; i < lines.size(); i++)
{
for (int j = i+1; j < lines.size(); j++)
{
cv::Point2f pt = computeIntersect(lines[i], lines[j]);
if (pt.x >= 0 && pt.y >= 0&&pt.x<img2.size().width&&pt.y<img2.size().height){
if(poly[i]==-1&&poly[j] == -1){
vector<Point2f> v;
v.push_back(pt);
corners.push_back(v);
poly[i] = curPoly;
poly[j] = curPoly;
curPoly++;
continue;
}
if(poly[i]==-1&&poly[j]>=0){
corners[poly[j]].push_back(pt);
poly[i] = poly[j];
continue;
}
if(poly[i]>=0&&poly[j]==-1){
corners[poly[i]].push_back(pt);
poly[j] = poly[i];
continue;
}
if(poly[i]>=0&&poly[j]>=0){
if(poly[i]==poly[j]){
corners[poly[i]].push_back(pt);
continue;
}
for(int k=0;k<corners[poly[j]].size();k++){
corners[poly[i]].push_back(corners[poly[j]][k]);
}
corners[poly[j]].clear();
poly[j] = poly[i];
continue;
}
}
}
}
tayeb d
0
Newbie Poster
Recommended Answers
Jump to PostThat's not python. I dumped it into http://pythonfiddle.com/pysomething and it looks like you have a lot of work ahead.
You didn't post much detail. Just a post title and code. Don't be shy. If you want members to write your code, just ask. But read this first.
Jump to PostThe thing is, conversion is one thing, efficient is another. And then you have this: https://www.google.com/search?q=python+cs+c%2B%2B+speed
I can't guess why the move to Python, that's not revealed yet. I know folk learn it …
All 6 Replies
rproffitt
2,424
"Nothing to see here."
Moderator
tayeb d
0
Newbie Poster
tayeb d
0
Newbie Poster
rproffitt
2,424
"Nothing to see here."
Moderator
tayeb d
0
Newbie Poster
rproffitt
2,424
"Nothing to see here."
Moderator
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.