Best way to get Contour's extreme points with C++?
Im working on my C++ project, and it require detecting V-shape-like contour.With extreme points i will be able to tell which contour is suitable. Example: the pointy metal bar in the middle of the cross road
This is my current code to find extreme point is doing its job but when i put it into header file and run on jetson tk1, its too slow and i wonder if there is a way to make run faster or maybe another method that work better and faster. The code, here:
vector<Point> exLeft;
vector<Point> exRight;
vector<Point> exTop;
vector<Point> exBott;
for (size_t i = 0; i < cnts.size();i++){
Point tmpLeft;
Point tmpRight;
Point tmpTop;
Point tmpBott;
tmpLeft.x = 1000;
tmpRight.x = -1000;
tmpBott.y = -1000;
tmpTop.y = 1000;
vector<Point> cnt;
cnt = cnts[i];
for (size_t j=0; j < cnt.size();j++){
Point current = cnt[j];
if (current.x < tmpLeft.x){
tmpLeft = current;
}
if (current.x > tmpRight.x){
tmpRight = current;
}
if (current.y > tmpBott.y){
tmpBott = current;
}
if (current.y < tmpTop.y){
tmpTop = current;
}
}
exLeft.push_back(tmpLeft);
exRight.push_back(tmpRight);
exTop.push_back(tmpTop);
exBott.push_back(tmpBott);
}
Could you please add the complete code (including the Pre-processing step)? In my opinion you should find Hough Line Transform to find the intersection of these lines!
I tried with houghLine but its not really accurate, so i though of extreme point in contour and it work very well, but a bit slow for some reason, i need to increase FPS
"I tried with houghLine but its not really accurate" Can you show us the results so that we can help further?