I am recently reading the code of cv::getRectSubPix
in OpenCV, which involves dealing rectangles out of image. Concretely, I am stuck on function adjustRect
that is used to reshape the out-of-bounds rectangular window.
According to the code of adjustRect
, top left corner p=(x,y)
of rectangle will shift to p'=(-x,-y)
(blue frame) if p
(red frame) is as follows:
What puzzled me was the last line in
adjustRect
:
return src - rect.x*pix_size;
why src
is shifted in x
direction only? To my understanding, proper code should be:
return src - rect.x*pix_size-rect.y*src_step
Besides, I think src
will point to undefined memory if both x
and y
are negative. Can anyone help?