linked list iterate within main for loop impacts face processing
Hi everyone. I'm using the following facerecognizer example. http://docs.opencv.org/2.4/modules/co...
Within the for loop in the main() function, i am iterating a linked list to search for intersecting rectangles. This seems to be having an impact in that it cant handle more then 2 faces.
What alternative is there? Should i use a vector? threads?
Thanks
update: This is the part i put in the for loop. The area() command seems to be the culprit.
tmp=head;
while(tmp) {
bool intersects=((a&tmp->b).area()>0);
if(intersects) cout << "intersected" << endl;
else cout << "not intersected" << endl;
tmp=tmp->next;
}
We'd have to see your code. This is far too generic. Try timing everything and see exactly which part is taking so long. See HERE for functions you can use to do the timing.
Thank you. Updated my question with code. I removed all the stuff and it seems the area() is actually what is taking so long. As i'm storing all the Rects of the faces in this linked list (so i can compare if they intersect), i'm not sure how to design around this (b in tmp is a Rect).
The area is just a multiplication, return width*height. How long is long? I ran a test. It seems to take something like 0.03 seconds per comparison. That's a lot more than I'd expect, but certainly not the sort of time that would limit you to 2 faces.
"This seems to be having an impact in that it cant handle more then 2 faces." -- why would that be ?
(and yes, use a vector !)