Camshift misunderstand

asked 2016-11-09 22:28:33 -0500

greenworld gravatar image

updated 2016-11-09 22:29:54 -0500

Dear everyone, Can you help to explain below line of Camshift source code (https://github.com/opencv/opencv/blob...) :

int nx = std::min(std::max(cur_rect.x + dx, 0), size.width - cur_rect.width);
    int ny = std::min(std::max(cur_rect.y + dy, 0), size.height - cur_rect.height);

this is the calculation for the new coordinate of the window, but I do not know how it can select minimum between "size.width - cur_rect.width" and "cur_rect.x + dx" .

edit retag flag offensive close merge delete

Comments

I don't understand what you're asking, but here's my guess.

size.width - cur_rect.width is the closest it can be without the box going over the edge.

cur_rect.x + dx is where it wants to put the box. So it puts the box as close to where it wants to put the box without going over the edge.

Tetragramm gravatar imageTetragramm ( 2016-11-10 11:09:58 -0500 )edit