cv.jit.faces - sorting faces

ygreq's icon

I see that when I get more than one face, [cv.jit.faces] keeps on changing the order in which it detects the faces.

I looked through the forum with no luck! Is there a cv.jit object I can use in correlation with cv.jit.faces so that I know which face is which? Or another solution?

Thank you all!

Jean-Marc Pelletier's icon

The simplest solution, which will work in most situations, is to compare the position of the faces. Faces belonging to the same person should appear close to one another, if not in almost the same position.

The reason, the order of the faces change is because it is the order in which the faces were found. Relatively slight changes in relative positions may affect this order.

ygreq's icon

Thank you for your reply! To be honest I was hoping for you (or anyone willing to help) to say otherwise. I will try to see what I can do.

The thing is that the coordinates of the faces keep on switching between themselves while there are 2 faces on screen. Maybe cv.jit.faces looses count to often (due to bad light) and resets? And this is the reason why it is hard to keep track of every face.

I was thinking that as long as there was an order, I knew that the first face to be detected to be face A, let's say, and second face to be face B. But as they switch almost every 2 seconds, it's hell!

Somebody mentioned that you could use an object for blobs sorting and adapt it for faces. Is this a road I should follow? Is there an object like that that I should learn?

Thank you!

PS: I was also thinking about sorting them with jit.bsort, aligning them in relation to their x position. :)