为什么会产生这种代码
(1, 1, 1, 1)
cv2.boundingRect
以格式返回rect
x,y,w,h
但是为什么呢
w,h
在这种情况下不是零吗?
import cv2
import numpy as np
cv2.__version__
'4.4.0'
np.__version__
'1.19.2'
a = np.ones((8,2))
x, y, w, h = cv2.boundingRect(a.astype(np.float32))
绑定文档中没有太多信息:
def boundingRect(array): # real signature unknown; restored from __doc__
"""
boundingRect(array) -> retval
. @brief Calculates the up-right bounding rectangle of a point set or non-zero pixels of gray-scale image.
.
. The function calculates and returns the minimal up-right bounding rectangle for the specified point set or
. non-zero pixels of gray-scale image.
.
. @param array Input gray-scale image or 2D point set, stored in std::vector or Mat.
"""
pass
更新:
return Rect(xmin, ymin, xmax - xmin + 1, ymax - ymin + 1);