linked list iterate within main for loop impacts face processing

asked 2016-12-16 14:55:42 -0600

atv gravatar image

updated 2016-12-16 15:24:44 -0600

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;

}

edit retag flag offensive close merge delete

Comments

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.

Tetragramm gravatar imageTetragramm ( 2016-12-16 15:07:16 -0600 )edit

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).

atv gravatar imageatv ( 2016-12-16 15:26:06 -0600 )edit

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.

Tetragramm gravatar imageTetragramm ( 2016-12-16 16:16:26 -0600 )edit

"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 !)

berak gravatar imageberak ( 2016-12-17 02:24:03 -0600 )edit