# Camshift misunderstand

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

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.