【发布时间】:2016-11-08 23:47:46
【问题描述】:
如何将cv2.boundingRect 应用于np.array 的点数?
以下代码会产生错误。
points = np.array([[1, 2], [3, 4]], dtype=np.float32)
import cv2
cv2.boundingRect(points)
错误:
OpenCV Error: Unsupported format or combination of formats (The image/matrix format is not supported by the function) in cvBoundingRect, file /build/buildd/opencv-2.4.8+dfsg1/modules/imgproc/src/shapedescr.cpp, line 97
File "<ipython-input-23-42e84e11f1a7>", line 1, in <module>
cv2.boundingRect(points)
error: /build/buildd/opencv-2.4.8+dfsg1/modules/imgproc/src/shapedescr.cpp:970: error: (-210) The image/matrix format is not supported by the function in function cvBoundingRect
【问题讨论】:
-
我打算建议
cv2.boundingRect(cv2.cv.fromarray(points)),但这似乎也不起作用。返回TypeError: points is not a numpy array, neither a scalar -
我试过你的代码,它给了我这个边界框没有错误(1、2、3、3),这似乎是真的。但是,我的 CV 版本是“3.1.0-dev”。